summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-03-16 18:27:34 -0400
committerR David Murray <rdmurray@bitdance.com>2011-03-16 18:27:34 -0400
commit676a72be33700a3df9f4930b7b080b800a93b011 (patch)
treeeeb73490e177be33ff1741b4ae6afcad190ff8ad /Lib
parenta6101cb3d1d6ebffa18cf7a784bdcaf98ee840d9 (diff)
parenta8ebdf3fd2c681864e0b6b0c6c4364cf6242904d (diff)
downloadcpython-676a72be33700a3df9f4930b7b080b800a93b011.tar.gz
Merge #11401 fix from 3.1.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_dummy_thread.py16
-rw-r--r--Lib/_markupbase.py8
-rw-r--r--Lib/_pyio.py217
-rw-r--r--Lib/_strptime.py50
-rw-r--r--Lib/_threading_local.py158
-rw-r--r--Lib/abc.py40
-rw-r--r--Lib/argparse.py2358
-rw-r--r--Lib/ast.py25
-rw-r--r--Lib/asyncore.py27
-rwxr-xr-xLib/base64.py17
-rw-r--r--Lib/bdb.py181
-rwxr-xr-xLib/cProfile.py9
-rwxr-xr-xLib/cgi.py263
-rw-r--r--Lib/cmd.py20
-rw-r--r--Lib/code.py5
-rw-r--r--Lib/codecs.py23
-rw-r--r--Lib/collections.py287
-rw-r--r--Lib/compileall.py278
-rw-r--r--Lib/concurrent/__init__.py1
-rw-r--r--Lib/concurrent/futures/__init__.py18
-rw-r--r--Lib/concurrent/futures/_base.py567
-rw-r--r--Lib/concurrent/futures/process.py363
-rw-r--r--Lib/concurrent/futures/thread.py136
-rw-r--r--Lib/configparser.py1288
-rw-r--r--Lib/contextlib.py62
-rw-r--r--Lib/copy.py4
-rw-r--r--Lib/csv.py16
-rw-r--r--Lib/ctypes/__init__.py57
-rw-r--r--Lib/ctypes/test/test_arrays.py4
-rw-r--r--Lib/ctypes/test/test_bitfields.py4
-rw-r--r--Lib/ctypes/test/test_buffers.py14
-rw-r--r--Lib/ctypes/test/test_bytes.py19
-rw-r--r--Lib/ctypes/test/test_callbacks.py34
-rw-r--r--Lib/ctypes/test/test_cast.py8
-rw-r--r--Lib/ctypes/test/test_cfuncs.py2
-rw-r--r--Lib/ctypes/test/test_errno.py75
-rw-r--r--Lib/ctypes/test/test_internals.py18
-rw-r--r--Lib/ctypes/test/test_keeprefs.py8
-rw-r--r--Lib/ctypes/test/test_libc.py2
-rw-r--r--Lib/ctypes/test/test_loading.py2
-rw-r--r--Lib/ctypes/test/test_objects.py4
-rw-r--r--Lib/ctypes/test/test_parameters.py10
-rw-r--r--Lib/ctypes/test/test_prototypes.py2
-rw-r--r--Lib/ctypes/test/test_python_api.py4
-rw-r--r--Lib/ctypes/test/test_random_things.py4
-rw-r--r--Lib/ctypes/test/test_repr.py4
-rw-r--r--Lib/ctypes/test/test_returnfuncptrs.py8
-rw-r--r--Lib/ctypes/test/test_sizes.py9
-rw-r--r--Lib/ctypes/test/test_stringptr.py6
-rw-r--r--Lib/ctypes/test/test_strings.py17
-rw-r--r--Lib/ctypes/test/test_structures.py24
-rw-r--r--Lib/ctypes/test/test_unicode.py103
-rw-r--r--Lib/ctypes/util.py31
-rw-r--r--Lib/ctypes/wintypes.py169
-rw-r--r--Lib/datetime.py2108
-rw-r--r--Lib/dbm/__init__.py23
-rw-r--r--Lib/dbm/dumb.py4
-rw-r--r--Lib/decimal.py589
-rw-r--r--Lib/difflib.py131
-rw-r--r--Lib/dis.py108
-rw-r--r--Lib/distutils/__init__.py2
-rw-r--r--Lib/distutils/command/bdist_msi.py1
-rw-r--r--Lib/distutils/command/build_ext.py6
-rw-r--r--Lib/distutils/command/install.py27
-rw-r--r--Lib/distutils/file_util.py9
-rw-r--r--Lib/distutils/sysconfig.py103
-rw-r--r--Lib/distutils/tests/test_bdist_msi.py25
-rw-r--r--Lib/distutils/tests/test_build.py55
-rw-r--r--Lib/distutils/tests/test_build_ext.py19
-rw-r--r--Lib/distutils/tests/test_dep_util.py81
-rw-r--r--Lib/distutils/tests/test_dist.py1
-rw-r--r--Lib/distutils/tests/test_sysconfig.py11
-rw-r--r--Lib/distutils/text_file.py5
-rw-r--r--Lib/distutils/util.py9
-rw-r--r--Lib/doctest.py39
-rw-r--r--Lib/email/__init__.py19
-rw-r--r--Lib/email/_parseaddr.py20
-rw-r--r--Lib/email/base64mime.py8
-rw-r--r--Lib/email/charset.py33
-rw-r--r--Lib/email/encoders.py9
-rw-r--r--Lib/email/feedparser.py7
-rw-r--r--Lib/email/generator.py215
-rw-r--r--Lib/email/header.py29
-rw-r--r--Lib/email/message.py104
-rw-r--r--Lib/email/parser.py47
-rw-r--r--Lib/email/quoprimime.py6
-rw-r--r--Lib/email/test/data/msg_10.txt7
-rw-r--r--Lib/email/test/data/msg_26.txt3
-rw-r--r--Lib/email/test/test_email.py468
-rw-r--r--Lib/email/test/test_email_codecs.py46
-rw-r--r--Lib/email/test/test_email_torture.py6
-rw-r--r--Lib/email/utils.py11
-rw-r--r--Lib/encodings/__init__.py2
-rw-r--r--Lib/encodings/aliases.py8
-rw-r--r--Lib/encodings/base64_codec.py55
-rw-r--r--Lib/encodings/bz2_codec.py77
-rw-r--r--Lib/encodings/cp720.py309
-rw-r--r--Lib/encodings/cp858.py698
-rw-r--r--Lib/encodings/hex_codec.py55
-rw-r--r--Lib/encodings/punycode.py1
-rw-r--r--Lib/encodings/quopri_codec.py56
-rwxr-xr-xLib/encodings/rot_13.py113
-rw-r--r--Lib/encodings/uu_codec.py99
-rw-r--r--Lib/encodings/zlib_codec.py77
-rw-r--r--Lib/fileinput.py6
-rw-r--r--Lib/fnmatch.py47
-rw-r--r--Lib/fractions.py102
-rw-r--r--Lib/ftplib.py314
-rw-r--r--Lib/functools.py158
-rw-r--r--Lib/genericpath.py2
-rw-r--r--Lib/getopt.py1
-rw-r--r--Lib/gettext.py50
-rw-r--r--Lib/gzip.py245
-rw-r--r--Lib/hashlib.py81
-rw-r--r--Lib/heapq.py4
-rw-r--r--Lib/hmac.py15
-rw-r--r--Lib/html/__init__.py21
-rw-r--r--Lib/html/parser.py99
-rw-r--r--Lib/http/client.py217
-rw-r--r--Lib/http/cookiejar.py20
-rw-r--r--Lib/http/cookies.py244
-rw-r--r--Lib/http/server.py92
-rw-r--r--Lib/idlelib/Bindings.py8
-rw-r--r--Lib/idlelib/EditorWindow.py14
-rw-r--r--Lib/idlelib/NEWS.txt4
-rw-r--r--Lib/idlelib/PyShell.py33
-rw-r--r--Lib/idlelib/idlever.py2
-rw-r--r--Lib/idlelib/macosxSupport.py96
-rw-r--r--Lib/idlelib/run.py7
-rw-r--r--Lib/imaplib.py80
-rw-r--r--Lib/importlib/__init__.py2
-rw-r--r--Lib/importlib/_bootstrap.py594
-rw-r--r--Lib/importlib/abc.py246
-rw-r--r--Lib/importlib/test/__init__.py31
-rw-r--r--Lib/importlib/test/__main__.py29
-rw-r--r--Lib/importlib/test/benchmark.py184
-rw-r--r--Lib/importlib/test/builtin/test_loader.py9
-rw-r--r--Lib/importlib/test/extension/test_case_sensitivity.py3
-rw-r--r--Lib/importlib/test/extension/test_finder.py3
-rw-r--r--Lib/importlib/test/extension/test_loader.py5
-rw-r--r--Lib/importlib/test/extension/test_path_hook.py2
-rw-r--r--Lib/importlib/test/frozen/test_loader.py7
-rw-r--r--Lib/importlib/test/import_/test___package__.py29
-rw-r--r--Lib/importlib/test/import_/test_api.py22
-rw-r--r--Lib/importlib/test/import_/test_fromlist.py11
-rw-r--r--Lib/importlib/test/import_/test_packages.py10
-rw-r--r--Lib/importlib/test/import_/test_path.py35
-rw-r--r--Lib/importlib/test/import_/test_relative_imports.py13
-rw-r--r--Lib/importlib/test/import_/util.py15
-rw-r--r--Lib/importlib/test/regrtest.py35
-rw-r--r--Lib/importlib/test/source/test_abc_loader.py556
-rw-r--r--Lib/importlib/test/source/test_case_sensitivity.py12
-rw-r--r--Lib/importlib/test/source/test_file_loader.py300
-rw-r--r--Lib/importlib/test/source/test_finder.py39
-rw-r--r--Lib/importlib/test/source/test_path_hook.py7
-rw-r--r--Lib/importlib/test/source/test_source_encoding.py13
-rw-r--r--Lib/importlib/test/source/util.py19
-rw-r--r--Lib/importlib/test/test_abc.py13
-rw-r--r--Lib/importlib/test/test_api.py5
-rw-r--r--Lib/importlib/test/test_util.py4
-rw-r--r--Lib/importlib/test/util.py27
-rw-r--r--Lib/importlib/util.py1
-rw-r--r--Lib/inspect.py221
-rw-r--r--Lib/json/decoder.py10
-rw-r--r--Lib/json/encoder.py11
-rw-r--r--Lib/json/scanner.py10
-rwxr-xr-xLib/keyword.py24
-rwxr-xr-xLib/lib2to3/pgen2/token.py2
-rwxr-xr-xLib/lib2to3/tests/pytree_idempotency.py2
-rw-r--r--Lib/linecache.py4
-rw-r--r--Lib/locale.py105
-rw-r--r--Lib/logging/__init__.py613
-rw-r--r--Lib/logging/config.py704
-rw-r--r--Lib/logging/handlers.py287
-rw-r--r--Lib/macpath.py5
-rw-r--r--Lib/mailbox.py422
-rw-r--r--Lib/mimetypes.py54
-rw-r--r--Lib/modulefinder.py22
-rw-r--r--Lib/msilib/__init__.py1
-rw-r--r--Lib/multiprocessing/__init__.py4
-rw-r--r--Lib/multiprocessing/connection.py29
-rw-r--r--Lib/multiprocessing/forking.py10
-rw-r--r--Lib/multiprocessing/managers.py2
-rw-r--r--Lib/multiprocessing/pool.py144
-rw-r--r--Lib/multiprocessing/synchronize.py3
-rw-r--r--Lib/nntplib.py1149
-rw-r--r--Lib/ntpath.py68
-rw-r--r--Lib/numbers.py2
-rw-r--r--Lib/opcode.py11
-rw-r--r--Lib/os.py236
-rw-r--r--Lib/os2emxpath.py3
-rw-r--r--Lib/pdb.doc202
-rwxr-xr-xLib/pdb.py1319
-rw-r--r--Lib/pickle.py98
-rw-r--r--Lib/pickletools.py79
-rw-r--r--Lib/pkgutil.py3
-rw-r--r--Lib/plat-atheos/IN.py944
-rw-r--r--Lib/plat-atheos/TYPES.py142
-rw-r--r--Lib/plat-atheos/regen3
-rwxr-xr-xLib/platform.py77
-rw-r--r--Lib/plistlib.py2
-rw-r--r--Lib/poplib.py18
-rw-r--r--Lib/posixpath.py9
-rw-r--r--Lib/pprint.py9
-rwxr-xr-xLib/profile.py20
-rw-r--r--Lib/pstats.py111
-rw-r--r--Lib/py_compile.py150
-rwxr-xr-xLib/pydoc.py656
-rw-r--r--Lib/pydoc_data/_pydoc.css6
-rw-r--r--Lib/pydoc_data/topics.py78
-rw-r--r--Lib/queue.py10
-rwxr-xr-xLib/quopri.py20
-rw-r--r--Lib/random.py137
-rw-r--r--Lib/re.py40
-rw-r--r--Lib/reprlib.py32
-rw-r--r--Lib/runpy.py193
-rw-r--r--Lib/shelve.py3
-rw-r--r--Lib/shutil.py491
-rw-r--r--Lib/site.py176
-rwxr-xr-xLib/smtpd.py244
-rwxr-xr-xLib/smtplib.py250
-rw-r--r--Lib/socket.py100
-rw-r--r--Lib/socketserver.py48
-rw-r--r--Lib/sqlite3/__init__.py3
-rw-r--r--Lib/sqlite3/dbapi2.py3
-rw-r--r--Lib/sqlite3/test/dbapi.py75
-rw-r--r--Lib/sqlite3/test/regression.py113
-rw-r--r--Lib/sqlite3/test/transactions.py20
-rw-r--r--Lib/sqlite3/test/types.py8
-rw-r--r--Lib/sre_compile.py2
-rw-r--r--Lib/ssl.py192
-rw-r--r--Lib/string.py51
-rw-r--r--Lib/struct.py2
-rw-r--r--Lib/subprocess.py479
-rw-r--r--Lib/sunau.py11
-rwxr-xr-xLib/symbol.py128
-rw-r--r--Lib/symtable.py9
-rw-r--r--Lib/sysconfig.py779
-rwxr-xr-xLib/tabnanny.py9
-rw-r--r--Lib/tarfile.py680
-rw-r--r--Lib/tempfile.py103
-rw-r--r--Lib/test/__main__.py13
-rw-r--r--Lib/test/badsyntax_nocaret.py2
-rw-r--r--Lib/test/capath/4e1295a3.014
-rw-r--r--Lib/test/capath/5ed36f99.041
-rw-r--r--Lib/test/capath/6e88d7b8.014
-rw-r--r--Lib/test/capath/99d0fa06.041
-rw-r--r--Lib/test/cfgparser.2537
-rw-r--r--Lib/test/cfgparser.369
-rw-r--r--Lib/test/cmath_testcases.txt31
-rw-r--r--Lib/test/crashers/recursive_call.py2
-rw-r--r--Lib/test/crashers/underlying_dict.py20
-rw-r--r--Lib/test/curses_tests.py2
-rw-r--r--Lib/test/data/README2
-rw-r--r--Lib/test/datetimetester.py3679
-rw-r--r--Lib/test/decimaltestdata/and.decTest676
-rw-r--r--Lib/test/decimaltestdata/class.decTest262
-rw-r--r--Lib/test/decimaltestdata/comparetotal.decTest1596
-rw-r--r--Lib/test/decimaltestdata/comparetotmag.decTest1580
-rw-r--r--Lib/test/decimaltestdata/copy.decTest172
-rw-r--r--Lib/test/decimaltestdata/copyabs.decTest172
-rw-r--r--Lib/test/decimaltestdata/copynegate.decTest172
-rw-r--r--Lib/test/decimaltestdata/copysign.decTest354
-rw-r--r--Lib/test/decimaltestdata/ddAbs.decTest252
-rw-r--r--Lib/test/decimaltestdata/ddAdd.decTest2656
-rw-r--r--Lib/test/decimaltestdata/ddAnd.decTest694
-rw-r--r--Lib/test/decimaltestdata/ddBase.decTest2208
-rw-r--r--Lib/test/decimaltestdata/ddCanonical.decTest714
-rw-r--r--Lib/test/decimaltestdata/ddClass.decTest152
-rw-r--r--Lib/test/decimaltestdata/ddCompare.decTest1488
-rw-r--r--Lib/test/decimaltestdata/ddCompareSig.decTest1294
-rw-r--r--Lib/test/decimaltestdata/ddCompareTotal.decTest1412
-rw-r--r--Lib/test/decimaltestdata/ddCompareTotalMag.decTest1412
-rw-r--r--Lib/test/decimaltestdata/ddCopy.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddCopyAbs.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddCopyNegate.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddCopySign.decTest350
-rw-r--r--Lib/test/decimaltestdata/ddDivide.decTest1726
-rw-r--r--Lib/test/decimaltestdata/ddDivideInt.decTest898
-rw-r--r--Lib/test/decimaltestdata/ddEncode.decTest990
-rw-r--r--Lib/test/decimaltestdata/ddFMA.decTest3396
-rw-r--r--Lib/test/decimaltestdata/ddInvert.decTest404
-rw-r--r--Lib/test/decimaltestdata/ddLogB.decTest318
-rw-r--r--Lib/test/decimaltestdata/ddMax.decTest644
-rw-r--r--Lib/test/decimaltestdata/ddMaxMag.decTest608
-rw-r--r--Lib/test/decimaltestdata/ddMin.decTest618
-rw-r--r--Lib/test/decimaltestdata/ddMinMag.decTest586
-rw-r--r--Lib/test/decimaltestdata/ddMinus.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddMultiply.decTest1106
-rw-r--r--Lib/test/decimaltestdata/ddNextMinus.decTest252
-rw-r--r--Lib/test/decimaltestdata/ddNextPlus.decTest248
-rw-r--r--Lib/test/decimaltestdata/ddNextToward.decTest748
-rw-r--r--Lib/test/decimaltestdata/ddOr.decTest584
-rw-r--r--Lib/test/decimaltestdata/ddPlus.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddQuantize.decTest1666
-rw-r--r--Lib/test/decimaltestdata/ddReduce.decTest364
-rw-r--r--Lib/test/decimaltestdata/ddRemainder.decTest1200
-rw-r--r--Lib/test/decimaltestdata/ddRemainderNear.decTest1258
-rw-r--r--Lib/test/decimaltestdata/ddRotate.decTest524
-rw-r--r--Lib/test/decimaltestdata/ddSameQuantum.decTest778
-rw-r--r--Lib/test/decimaltestdata/ddScaleB.decTest486
-rw-r--r--Lib/test/decimaltestdata/ddShift.decTest524
-rw-r--r--Lib/test/decimaltestdata/ddSubtract.decTest1258
-rw-r--r--Lib/test/decimaltestdata/ddToIntegral.decTest514
-rw-r--r--Lib/test/decimaltestdata/ddXor.decTest674
-rw-r--r--Lib/test/decimaltestdata/dqAbs.decTest252
-rw-r--r--Lib/test/decimaltestdata/dqAdd.decTest2430
-rw-r--r--Lib/test/decimaltestdata/dqAnd.decTest840
-rw-r--r--Lib/test/decimaltestdata/dqBase.decTest2162
-rw-r--r--Lib/test/decimaltestdata/dqCanonical.decTest744
-rw-r--r--Lib/test/decimaltestdata/dqClass.decTest154
-rw-r--r--Lib/test/decimaltestdata/dqCompare.decTest1506
-rw-r--r--Lib/test/decimaltestdata/dqCompareSig.decTest1294
-rw-r--r--Lib/test/decimaltestdata/dqCompareTotal.decTest1412
-rw-r--r--Lib/test/decimaltestdata/dqCompareTotalMag.decTest1412
-rw-r--r--Lib/test/decimaltestdata/dqCopy.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqCopyAbs.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqCopyNegate.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqCopySign.decTest350
-rw-r--r--Lib/test/decimaltestdata/dqDivide.decTest1616
-rw-r--r--Lib/test/decimaltestdata/dqDivideInt.decTest906
-rw-r--r--Lib/test/decimaltestdata/dqEncode.decTest954
-rw-r--r--Lib/test/decimaltestdata/dqFMA.decTest3572
-rw-r--r--Lib/test/decimaltestdata/dqInvert.decTest490
-rw-r--r--Lib/test/decimaltestdata/dqLogB.decTest320
-rw-r--r--Lib/test/decimaltestdata/dqMax.decTest644
-rw-r--r--Lib/test/decimaltestdata/dqMaxMag.decTest608
-rw-r--r--Lib/test/decimaltestdata/dqMin.decTest618
-rw-r--r--Lib/test/decimaltestdata/dqMinMag.decTest586
-rw-r--r--Lib/test/decimaltestdata/dqMinus.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqMultiply.decTest1178
-rw-r--r--Lib/test/decimaltestdata/dqNextMinus.decTest252
-rw-r--r--Lib/test/decimaltestdata/dqNextPlus.decTest248
-rw-r--r--Lib/test/decimaltestdata/dqNextToward.decTest750
-rw-r--r--Lib/test/decimaltestdata/dqOr.decTest802
-rw-r--r--Lib/test/decimaltestdata/dqPlus.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqQuantize.decTest1672
-rw-r--r--Lib/test/decimaltestdata/dqReduce.decTest366
-rw-r--r--Lib/test/decimaltestdata/dqRemainder.decTest1194
-rw-r--r--Lib/test/decimaltestdata/dqRemainderNear.decTest1262
-rw-r--r--Lib/test/decimaltestdata/dqRotate.decTest596
-rw-r--r--Lib/test/decimaltestdata/dqSameQuantum.decTest778
-rw-r--r--Lib/test/decimaltestdata/dqScaleB.decTest520
-rw-r--r--Lib/test/decimaltestdata/dqShift.decTest596
-rw-r--r--Lib/test/decimaltestdata/dqSubtract.decTest1270
-rw-r--r--Lib/test/decimaltestdata/dqToIntegral.decTest514
-rw-r--r--Lib/test/decimaltestdata/dqXor.decTest820
-rw-r--r--Lib/test/decimaltestdata/dsBase.decTest2124
-rw-r--r--Lib/test/decimaltestdata/dsEncode.decTest744
-rw-r--r--Lib/test/decimaltestdata/exp.decTest1348
-rw-r--r--Lib/test/decimaltestdata/fma.decTest6852
-rw-r--r--Lib/test/decimaltestdata/invert.decTest352
-rw-r--r--Lib/test/decimaltestdata/ln.decTest1222
-rw-r--r--Lib/test/decimaltestdata/log10.decTest1102
-rw-r--r--Lib/test/decimaltestdata/logb.decTest376
-rw-r--r--Lib/test/decimaltestdata/maxmag.decTest808
-rw-r--r--Lib/test/decimaltestdata/minmag.decTest780
-rw-r--r--Lib/test/decimaltestdata/nextminus.decTest296
-rw-r--r--Lib/test/decimaltestdata/nextplus.decTest300
-rw-r--r--Lib/test/decimaltestdata/nexttoward.decTest852
-rw-r--r--Lib/test/decimaltestdata/or.decTest668
-rw-r--r--Lib/test/decimaltestdata/powersqrt.decTest5940
-rw-r--r--Lib/test/decimaltestdata/rotate.decTest494
-rw-r--r--Lib/test/decimaltestdata/scaleb.decTest418
-rw-r--r--Lib/test/decimaltestdata/shift.decTest500
-rw-r--r--Lib/test/decimaltestdata/tointegralx.decTest510
-rw-r--r--Lib/test/decimaltestdata/xor.decTest670
-rw-r--r--Lib/test/doctest_aliases.py2
-rw-r--r--Lib/test/encoded_modules/__init__.py23
-rw-r--r--Lib/test/encoded_modules/module_iso_8859_1.py5
-rw-r--r--Lib/test/encoded_modules/module_koi8_r.py3
-rw-r--r--Lib/test/exception_hierarchy.txt1
-rw-r--r--Lib/test/fork_wait.py6
-rw-r--r--Lib/test/formatfloat_testcases.txt69
-rw-r--r--Lib/test/gdb_sample.py12
-rw-r--r--Lib/test/ieee754.txt6
-rw-r--r--Lib/test/json_tests/__init__.py (renamed from Lib/json/tests/__init__.py)2
-rw-r--r--Lib/test/json_tests/test_decode.py (renamed from Lib/json/tests/test_decode.py)28
-rw-r--r--Lib/test/json_tests/test_default.py (renamed from Lib/json/tests/test_default.py)0
-rw-r--r--Lib/test/json_tests/test_dump.py (renamed from Lib/json/tests/test_dump.py)0
-rw-r--r--Lib/test/json_tests/test_encode_basestring_ascii.py (renamed from Lib/json/tests/test_encode_basestring_ascii.py)0
-rw-r--r--Lib/test/json_tests/test_fail.py (renamed from Lib/json/tests/test_fail.py)0
-rw-r--r--Lib/test/json_tests/test_float.py (renamed from Lib/json/tests/test_float.py)0
-rw-r--r--Lib/test/json_tests/test_indent.py (renamed from Lib/json/tests/test_indent.py)40
-rw-r--r--Lib/test/json_tests/test_pass1.py (renamed from Lib/json/tests/test_pass1.py)0
-rw-r--r--Lib/test/json_tests/test_pass2.py (renamed from Lib/json/tests/test_pass2.py)0
-rw-r--r--Lib/test/json_tests/test_pass3.py (renamed from Lib/json/tests/test_pass3.py)0
-rw-r--r--Lib/test/json_tests/test_recursion.py (renamed from Lib/json/tests/test_recursion.py)0
-rw-r--r--Lib/test/json_tests/test_scanstring.py (renamed from Lib/json/tests/test_scanstring.py)0
-rw-r--r--Lib/test/json_tests/test_separators.py (renamed from Lib/json/tests/test_separators.py)0
-rw-r--r--Lib/test/json_tests/test_speedups.py (renamed from Lib/json/tests/test_speedups.py)1
-rw-r--r--Lib/test/json_tests/test_unicode.py (renamed from Lib/json/tests/test_unicode.py)0
-rw-r--r--Lib/test/keycert.pem59
-rw-r--r--Lib/test/keycert2.pem31
-rw-r--r--Lib/test/lock_tests.py320
-rw-r--r--Lib/test/make_ssl_certs.py64
-rw-r--r--Lib/test/mapping_tests.py46
-rw-r--r--Lib/test/math_testcases.txt519
-rw-r--r--Lib/test/mock_socket.py154
-rw-r--r--Lib/test/pickletester.py69
-rw-r--r--Lib/test/pstats.pckbin0 -> 66607 bytes
-rwxr-xr-xLib/test/pystone.py4
-rwxr-xr-xLib/test/re_tests.py2
-rwxr-xr-xLib/test/regrtest.py900
-rw-r--r--Lib/test/script_helper.py24
-rw-r--r--Lib/test/ssl_cert.pem25
-rw-r--r--Lib/test/ssl_key.pem25
-rw-r--r--Lib/test/ssl_servers.py189
-rw-r--r--Lib/test/string_tests.py37
-rw-r--r--Lib/test/subprocessdata/fd_status.py24
-rw-r--r--Lib/test/subprocessdata/input_reader.py7
-rw-r--r--Lib/test/subprocessdata/qcat.py7
-rw-r--r--Lib/test/subprocessdata/qgrep.py10
-rw-r--r--Lib/test/support.py591
-rw-r--r--Lib/test/test_SimpleHTTPServer.py41
-rw-r--r--Lib/test/test___all__.py8
-rw-r--r--Lib/test/test___future__.py2
-rw-r--r--Lib/test/test__locale.py2
-rw-r--r--Lib/test/test_abc.py68
-rw-r--r--Lib/test/test_abstract_numbers.py1
-rw-r--r--Lib/test/test_argparse.py4431
-rwxr-xr-xLib/test/test_array.py267
-rw-r--r--Lib/test/test_ascii_formatd.py64
-rw-r--r--Lib/test/test_ast.py30
-rw-r--r--Lib/test/test_asynchat.py174
-rw-r--r--Lib/test/test_asyncore.py602
-rw-r--r--Lib/test/test_atexit.py11
-rw-r--r--Lib/test/test_augassign.py4
-rw-r--r--Lib/test/test_base64.py18
-rw-r--r--Lib/test/test_bigmem.py44
-rw-r--r--[-rwxr-xr-x]Lib/test/test_binascii.py160
-rwxr-xr-xLib/test/test_binhex.py2
-rw-r--r--Lib/test/test_binop.py89
-rw-r--r--Lib/test/test_bool.py28
-rw-r--r--Lib/test/test_builtin.py396
-rw-r--r--Lib/test/test_bytes.py215
-rw-r--r--Lib/test/test_bz2.py229
-rw-r--r--Lib/test/test_calendar.py12
-rw-r--r--Lib/test/test_capi.py36
-rw-r--r--Lib/test/test_cfgparser.py1306
-rw-r--r--Lib/test/test_cgi.py136
-rw-r--r--[-rwxr-xr-x]Lib/test/test_cmath.py194
-rw-r--r--Lib/test/test_cmd.py25
-rw-r--r--Lib/test/test_cmd_line.py277
-rw-r--r--Lib/test/test_cmd_line_script.py256
-rw-r--r--Lib/test/test_code.py45
-rw-r--r--Lib/test/test_codecencodings_cn.py2
-rw-r--r--Lib/test/test_codecencodings_hk.py2
-rw-r--r--Lib/test/test_codecencodings_jp.py2
-rw-r--r--Lib/test/test_codecencodings_kr.py2
-rw-r--r--Lib/test/test_codecencodings_tw.py2
-rw-r--r--Lib/test/test_codecmaps_cn.py2
-rw-r--r--Lib/test/test_codecmaps_hk.py2
-rw-r--r--Lib/test/test_codecmaps_jp.py2
-rw-r--r--Lib/test/test_codecmaps_kr.py2
-rw-r--r--Lib/test/test_codecmaps_tw.py2
-rw-r--r--Lib/test/test_codecs.py86
-rw-r--r--Lib/test/test_codeop.py4
-rw-r--r--Lib/test/test_coding.py31
-rw-r--r--Lib/test/test_collections.py278
-rw-r--r--Lib/test/test_compile.py51
-rw-r--r--Lib/test/test_compileall.py285
-rw-r--r--Lib/test/test_complex.py170
-rw-r--r--Lib/test/test_concurrent_futures.py588
-rw-r--r--Lib/test/test_contains.py32
-rw-r--r--Lib/test/test_contextlib.py349
-rw-r--r--Lib/test/test_copy.py13
-rw-r--r--Lib/test/test_copyreg.py4
-rw-r--r--Lib/test/test_cprofile.py19
-rw-r--r--Lib/test/test_csv.py20
-rw-r--r--Lib/test/test_datetime.py3415
-rw-r--r--Lib/test/test_dbm.py12
-rw-r--r--Lib/test/test_dbm_dumb.py12
-rwxr-xr-xLib/test/test_dbm_gnu.py8
-rwxr-xr-xLib/test/test_dbm_ndbm.py2
-rw-r--r--Lib/test/test_decimal.py690
-rw-r--r--Lib/test/test_defaultdict.py16
-rw-r--r--Lib/test/test_deque.py52
-rw-r--r--Lib/test/test_descr.py152
-rw-r--r--Lib/test/test_dict.py163
-rw-r--r--Lib/test/test_dictviews.py133
-rw-r--r--Lib/test/test_difflib.py84
-rw-r--r--Lib/test/test_dis.py221
-rw-r--r--Lib/test/test_distutils.py1
-rw-r--r--Lib/test/test_doctest.py182
-rw-r--r--Lib/test/test_doctest2.py5
-rw-r--r--Lib/test/test_docxmlrpc.py86
-rw-r--r--Lib/test/test_dummy_thread.py10
-rw-r--r--Lib/test/test_dynamic.py143
-rw-r--r--Lib/test/test_email.py2
-rw-r--r--Lib/test/test_enumerate.py14
-rw-r--r--Lib/test/test_eof.py2
-rw-r--r--Lib/test/test_epoll.py2
-rwxr-xr-xLib/test/test_errno.py9
-rw-r--r--Lib/test/test_exceptions.py66
-rw-r--r--Lib/test/test_extcall.py35
-rw-r--r--[-rwxr-xr-x]Lib/test/test_fcntl.py13
-rw-r--r--Lib/test/test_file.py13
-rw-r--r--Lib/test/test_filecmp.py2
-rw-r--r--Lib/test/test_fileinput.py24
-rw-r--r--Lib/test/test_fileio.py10
-rw-r--r--Lib/test/test_float.py443
-rw-r--r--Lib/test/test_fnmatch.py35
-rw-r--r--Lib/test/test_fork1.py49
-rw-r--r--Lib/test/test_format.py35
-rw-r--r--Lib/test/test_fractions.py55
-rw-r--r--Lib/test/test_frozen.py25
-rw-r--r--Lib/test/test_ftplib.py433
-rw-r--r--Lib/test/test_funcattrs.py6
-rw-r--r--Lib/test/test_functools.py328
-rw-r--r--Lib/test/test_future.py2
-rw-r--r--Lib/test/test_future5.py2
-rw-r--r--Lib/test/test_gc.py49
-rw-r--r--Lib/test/test_gdb.py681
-rw-r--r--Lib/test/test_generators.py52
-rw-r--r--Lib/test/test_genericpath.py320
-rw-r--r--Lib/test/test_getargs2.py213
-rw-r--r--Lib/test/test_getopt.py1
-rw-r--r--Lib/test/test_glob.py16
-rw-r--r--Lib/test/test_global.py18
-rw-r--r--Lib/test/test_grammar.py22
-rw-r--r--[-rwxr-xr-x]Lib/test/test_grp.py8
-rw-r--r--Lib/test/test_gzip.py312
-rw-r--r--Lib/test/test_hash.py4
-rw-r--r--Lib/test/test_hashlib.py110
-rw-r--r--Lib/test/test_heapq.py2
-rw-r--r--Lib/test/test_hmac.py10
-rw-r--r--Lib/test/test_html.py24
-rw-r--r--[-rwxr-xr-x]Lib/test/test_htmlparser.py49
-rw-r--r--Lib/test/test_http_cookiejar.py117
-rw-r--r--Lib/test/test_http_cookies.py110
-rw-r--r--Lib/test/test_httplib.py221
-rw-r--r--Lib/test/test_httpservers.py347
-rw-r--r--Lib/test/test_imaplib.py30
-rw-r--r--Lib/test/test_imp.py235
-rw-r--r--Lib/test/test_import.py244
-rw-r--r--Lib/test/test_importhooks.py10
-rw-r--r--Lib/test/test_importlib.py7
-rw-r--r--Lib/test/test_index.py92
-rw-r--r--Lib/test/test_inspect.py553
-rw-r--r--Lib/test/test_int.py29
-rw-r--r--Lib/test/test_io.py340
-rw-r--r--Lib/test/test_ioctl.py10
-rw-r--r--Lib/test/test_isinstance.py14
-rw-r--r--Lib/test/test_iter.py25
-rw-r--r--Lib/test/test_itertools.py38
-rw-r--r--Lib/test/test_json.py4
-rw-r--r--Lib/test/test_keywordonlyarg.py10
-rw-r--r--Lib/test/test_kqueue.py11
-rw-r--r--Lib/test/test_linecache.py14
-rw-r--r--Lib/test/test_logging.py1315
-rw-r--r--Lib/test/test_long.py765
-rw-r--r--Lib/test/test_macpath.py46
-rw-r--r--Lib/test/test_mailbox.py263
-rw-r--r--Lib/test/test_marshal.py12
-rw-r--r--Lib/test/test_math.py326
-rw-r--r--Lib/test/test_memoryio.py167
-rw-r--r--Lib/test/test_memoryview.py52
-rw-r--r--Lib/test/test_mimetypes.py27
-rw-r--r--Lib/test/test_minidom.py41
-rw-r--r--Lib/test/test_mmap.py253
-rw-r--r--Lib/test/test_multibytecodec.py5
-rw-r--r--Lib/test/test_multibytecodec_support.py5
-rw-r--r--Lib/test/test_multiprocessing.py128
-rw-r--r--Lib/test/test_nis.py1
-rw-r--r--Lib/test/test_nntplib.py1243
-rw-r--r--Lib/test/test_normalization.py19
-rw-r--r--Lib/test/test_ntpath.py26
-rw-r--r--Lib/test/test_numeric_tower.py206
-rw-r--r--Lib/test/test_opcodes.py2
-rw-r--r--Lib/test/test_operator.py9
-rw-r--r--Lib/test/test_optparse.py13
-rw-r--r--Lib/test/test_os.py539
-rw-r--r--Lib/test/test_ossaudiodev.py10
-rw-r--r--Lib/test/test_parser.py22
-rw-r--r--Lib/test/test_pdb.py383
-rw-r--r--Lib/test/test_peepholer.py126
-rw-r--r--Lib/test/test_pep263.py2
-rw-r--r--Lib/test/test_pep277.py178
-rw-r--r--Lib/test/test_pep292.py60
-rw-r--r--Lib/test/test_pep3120.py3
-rw-r--r--Lib/test/test_pep3131.py1
-rw-r--r--Lib/test/test_pep352.py6
-rw-r--r--Lib/test/test_pickle.py23
-rw-r--r--Lib/test/test_pickletools.py4
-rw-r--r--Lib/test/test_pipes.py15
-rw-r--r--Lib/test/test_pkg.py37
-rw-r--r--Lib/test/test_pkgimport.py34
-rw-r--r--Lib/test/test_platform.py61
-rw-r--r--Lib/test/test_plistlib.py2
-rw-r--r--Lib/test/test_popen.py5
-rw-r--r--Lib/test/test_poplib.py28
-rw-r--r--Lib/test/test_posix.py117
-rw-r--r--Lib/test/test_posixpath.py631
-rw-r--r--Lib/test/test_pprint.py38
-rw-r--r--Lib/test/test_print.py1
-rw-r--r--[-rwxr-xr-x]Lib/test/test_profile.py3
-rw-r--r--Lib/test/test_property.py41
-rw-r--r--Lib/test/test_pstats.py19
-rw-r--r--Lib/test/test_pwd.py31
-rw-r--r--Lib/test/test_pyclbr.py9
-rw-r--r--Lib/test/test_pydoc.py179
-rw-r--r--Lib/test/test_pyexpat.py218
-rw-r--r--Lib/test/test_queue.py38
-rw-r--r--Lib/test/test_quopri.py2
-rw-r--r--Lib/test/test_raise.py24
-rw-r--r--Lib/test/test_random.py38
-rw-r--r--Lib/test/test_range.py380
-rw-r--r--Lib/test/test_re.py26
-rw-r--r--Lib/test/test_readline.py47
-rw-r--r--Lib/test/test_reprlib.py34
-rw-r--r--Lib/test/test_resource.py4
-rw-r--r--Lib/test/test_richcmp.py15
-rw-r--r--Lib/test/test_runpy.py233
-rw-r--r--Lib/test/test_sax.py130
-rw-r--r--Lib/test/test_sched.py80
-rw-r--r--Lib/test/test_scope.py360
-rw-r--r--Lib/test/test_select.py2
-rw-r--r--Lib/test/test_set.py104
-rw-r--r--Lib/test/test_shelve.py13
-rw-r--r--Lib/test/test_shutil.py619
-rw-r--r--Lib/test/test_site.py183
-rw-r--r--Lib/test/test_smtpd.py289
-rw-r--r--Lib/test/test_smtplib.py214
-rw-r--r--Lib/test/test_smtpnet.py2
-rw-r--r--Lib/test/test_socket.py613
-rw-r--r--Lib/test/test_socketserver.py15
-rw-r--r--Lib/test/test_sqlite.py18
-rw-r--r--Lib/test/test_ssl.py912
-rw-r--r--[-rwxr-xr-x]Lib/test/test_strftime.py1
-rw-r--r--Lib/test/test_string.py24
-rw-r--r--Lib/test/test_strptime.py21
-rw-r--r--Lib/test/test_strtod.py20
-rw-r--r--Lib/test/test_struct.py491
-rw-r--r--Lib/test/test_structmembers.py23
-rw-r--r--Lib/test/test_structseq.py15
-rw-r--r--Lib/test/test_subprocess.py1441
-rw-r--r--Lib/test/test_sundry.py15
-rw-r--r--Lib/test/test_symtable.py2
-rw-r--r--Lib/test/test_syntax.py53
-rw-r--r--Lib/test/test_sys.py264
-rw-r--r--Lib/test/test_sysconfig.py298
-rw-r--r--Lib/test/test_syslog.py2
-rw-r--r--Lib/test/test_tarfile.py1142
-rw-r--r--Lib/test/test_tcl.py12
-rw-r--r--Lib/test/test_telnetlib.py13
-rw-r--r--Lib/test/test_tempfile.py189
-rw-r--r--Lib/test/test_thread.py74
-rw-r--r--Lib/test/test_threaded_import.py4
-rw-r--r--Lib/test/test_threadedtempfile.py5
-rw-r--r--Lib/test/test_threading.py127
-rw-r--r--Lib/test/test_threading_local.py22
-rw-r--r--Lib/test/test_threadsignals.py145
-rw-r--r--Lib/test/test_time.py244
-rw-r--r--Lib/test/test_timeit.py305
-rw-r--r--Lib/test/test_timeout.py142
-rw-r--r--Lib/test/test_tokenize.py41
-rw-r--r--Lib/test/test_trace.py43
-rw-r--r--Lib/test/test_traceback.py37
-rw-r--r--Lib/test/test_ttk_guionly.py1
-rw-r--r--Lib/test/test_ttk_textonly.py1
-rw-r--r--Lib/test/test_tuple.py4
-rw-r--r--Lib/test/test_types.py184
-rw-r--r--Lib/test/test_ucn.py6
-rw-r--r--Lib/test/test_unicode.py351
-rw-r--r--Lib/test/test_unicode_file.py61
-rw-r--r--Lib/test/test_unicodedata.py36
-rw-r--r--Lib/test/test_unittest.py3361
-rw-r--r--Lib/test/test_unpack.py6
-rw-r--r--Lib/test/test_urllib.py52
-rw-r--r--Lib/test/test_urllib2.py90
-rw-r--r--Lib/test/test_urllib2_localnet.py64
-rw-r--r--Lib/test/test_urllib2net.py45
-rw-r--r--Lib/test/test_urllibnet.py22
-rw-r--r--Lib/test/test_urlparse.py293
-rw-r--r--Lib/test/test_userdict.py12
-rwxr-xr-xLib/test/test_userstring.py2
-rw-r--r--Lib/test/test_warnings.py127
-rw-r--r--Lib/test/test_wave.py14
-rw-r--r--Lib/test/test_weakref.py53
-rw-r--r--Lib/test/test_weakset.py52
-rw-r--r--Lib/test/test_winreg.py227
-rw-r--r--Lib/test/test_winsound.py1
-rw-r--r--Lib/test/test_with.py46
-rw-r--r--[-rwxr-xr-x]Lib/test/test_wsgiref.py67
-rw-r--r--Lib/test/test_xml_etree.py1734
-rw-r--r--Lib/test/test_xml_etree_c.py247
-rw-r--r--Lib/test/test_xmlrpc.py373
-rw-r--r--Lib/test/test_xmlrpc_net.py4
-rw-r--r--Lib/test/test_zipfile.py1720
-rw-r--r--Lib/test/test_zipimport.py72
-rw-r--r--Lib/test/test_zipimport_support.py173
-rw-r--r--Lib/test/test_zlib.py30
-rw-r--r--Lib/test/testtar.tarbin272384 -> 427008 bytes
-rw-r--r--Lib/test/threaded_import_hangers.py2
-rw-r--r--Lib/test/win_console_handler.py49
-rw-r--r--Lib/test/xmltestdata/simple-ns.xml7
-rw-r--r--Lib/test/xmltestdata/simple.xml6
-rw-r--r--Lib/test/xmltestdata/test.xml (renamed from Lib/test/test.xml)0
-rw-r--r--Lib/test/xmltestdata/test.xml.out (renamed from Lib/test/test.xml.out)0
-rw-r--r--Lib/test/zip_cp437_header.zipbin0 -> 270 bytes
-rw-r--r--Lib/threading.py349
-rw-r--r--Lib/timeit.py12
-rw-r--r--Lib/tkinter/__init__.py139
-rw-r--r--Lib/tkinter/__main__.py7
-rw-r--r--Lib/tkinter/font.py2
-rw-r--r--Lib/tkinter/scrolledtext.py7
-rw-r--r--Lib/tkinter/test/test_tkinter/test_font.py33
-rw-r--r--Lib/tkinter/test/test_tkinter/test_loadtk.py3
-rw-r--r--Lib/tkinter/test/test_ttk/test_widgets.py4
-rw-r--r--Lib/tkinter/tix.py175
-rw-r--r--Lib/tkinter/ttk.py12
-rwxr-xr-xLib/token.py18
-rw-r--r--Lib/tokenize.py159
-rw-r--r--Lib/trace.py187
-rw-r--r--Lib/turtle.py52
-rw-r--r--Lib/turtledemo/__init__.py0
-rwxr-xr-xLib/turtledemo/__main__.py266
-rw-r--r--Lib/turtledemo/about_turtle.txt76
-rw-r--r--Lib/turtledemo/about_turtledemo.txt13
-rw-r--r--Lib/turtledemo/bytedesign.py162
-rw-r--r--Lib/turtledemo/chaos.py59
-rw-r--r--Lib/turtledemo/clock.py132
-rw-r--r--Lib/turtledemo/colormixer.py60
-rw-r--r--Lib/turtledemo/demohelp.txt70
-rw-r--r--Lib/turtledemo/forest.py109
-rw-r--r--Lib/turtledemo/fractalcurves.py138
-rw-r--r--Lib/turtledemo/lindenmayer.py119
-rw-r--r--Lib/turtledemo/minimal_hanoi.py76
-rw-r--r--Lib/turtledemo/nim.py226
-rw-r--r--Lib/turtledemo/paint.py50
-rw-r--r--Lib/turtledemo/peace.py65
-rw-r--r--Lib/turtledemo/penrose.py181
-rw-r--r--Lib/turtledemo/planet_and_moon.py113
-rw-r--r--Lib/turtledemo/round_dance.py86
-rw-r--r--Lib/turtledemo/tree.py63
-rw-r--r--Lib/turtledemo/turtle.cfg10
-rw-r--r--Lib/turtledemo/two_canvases.py52
-rw-r--r--Lib/turtledemo/wikipedia.py65
-rw-r--r--Lib/turtledemo/yinyang.py49
-rw-r--r--Lib/unittest.py1623
-rw-r--r--Lib/unittest/__init__.py69
-rw-r--r--Lib/unittest/__main__.py12
-rw-r--r--Lib/unittest/case.py1256
-rw-r--r--Lib/unittest/loader.py321
-rw-r--r--Lib/unittest/main.py274
-rw-r--r--Lib/unittest/result.py186
-rw-r--r--Lib/unittest/runner.py213
-rw-r--r--Lib/unittest/signals.py57
-rw-r--r--Lib/unittest/suite.py285
-rw-r--r--Lib/unittest/test/__init__.py21
-rw-r--r--Lib/unittest/test/_test_warnings.py74
-rw-r--r--Lib/unittest/test/dummy.py1
-rw-r--r--Lib/unittest/test/support.py118
-rw-r--r--Lib/unittest/test/test_assertions.py286
-rw-r--r--Lib/unittest/test/test_break.py252
-rw-r--r--Lib/unittest/test/test_case.py1236
-rw-r--r--Lib/unittest/test/test_discovery.py395
-rw-r--r--Lib/unittest/test/test_functiontestcase.py144
-rw-r--r--Lib/unittest/test/test_loader.py1292
-rw-r--r--Lib/unittest/test/test_program.py358
-rw-r--r--Lib/unittest/test/test_result.py501
-rw-r--r--Lib/unittest/test/test_runner.py318
-rw-r--r--Lib/unittest/test/test_setups.py507
-rw-r--r--Lib/unittest/test/test_skipping.py134
-rw-r--r--Lib/unittest/test/test_suite.py368
-rw-r--r--Lib/unittest/util.py140
-rw-r--r--Lib/urllib/parse.py290
-rw-r--r--Lib/urllib/request.py71
-rwxr-xr-xLib/uu.py2
-rw-r--r--Lib/warnings.py19
-rw-r--r--Lib/wave.py8
-rw-r--r--Lib/weakref.py6
-rw-r--r--Lib/webbrowser.py50
-rw-r--r--Lib/wsgiref/handlers.py203
-rw-r--r--Lib/wsgiref/headers.py62
-rw-r--r--Lib/wsgiref/simple_server.py59
-rw-r--r--Lib/wsgiref/util.py40
-rw-r--r--Lib/wsgiref/validate.py42
-rw-r--r--Lib/xml/dom/minidom.py12
-rw-r--r--Lib/xml/etree/ElementInclude.py8
-rw-r--r--Lib/xml/etree/ElementPath.py351
-rw-r--r--Lib/xml/etree/ElementTree.py1238
-rw-r--r--Lib/xml/etree/__init__.py6
-rw-r--r--Lib/xml/parsers/expat.py6
-rw-r--r--Lib/xml/sax/expatreader.py3
-rw-r--r--Lib/xml/sax/saxutils.py42
-rw-r--r--Lib/xmlrpc/client.py290
-rw-r--r--Lib/xmlrpc/server.py114
-rw-r--r--Lib/zipfile.py514
790 files changed, 129214 insertions, 78809 deletions
diff --git a/Lib/_dummy_thread.py b/Lib/_dummy_thread.py
index 7aa6579efe..ed50520ab3 100644
--- a/Lib/_dummy_thread.py
+++ b/Lib/_dummy_thread.py
@@ -16,7 +16,13 @@ Suggested usage is::
__all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock',
'interrupt_main', 'LockType']
-import traceback as _traceback
+# A dummy value
+TIMEOUT_MAX = 2**31
+
+# NOTE: this module can be imported early in the extension building process,
+# and so top level imports of other modules should be avoided. Instead, all
+# imports are done when needed on a function-by-function basis. Since threads
+# are disabled, the import lock should not be an issue anyway (??).
class error(Exception):
"""Dummy implementation of _thread.error."""
@@ -48,7 +54,8 @@ def start_new_thread(function, args, kwargs={}):
except SystemExit:
pass
except:
- _traceback.print_exc()
+ import traceback
+ traceback.print_exc()
_main = True
global _interrupt
if _interrupt:
@@ -92,7 +99,7 @@ class LockType(object):
def __init__(self):
self.locked_status = False
- def acquire(self, waitflag=None):
+ def acquire(self, waitflag=None, timeout=-1):
"""Dummy implementation of acquire().
For blocking calls, self.locked_status is automatically set to
@@ -111,6 +118,9 @@ class LockType(object):
self.locked_status = True
return True
else:
+ if timeout > 0:
+ import time
+ time.sleep(timeout)
return False
__enter__ = acquire
diff --git a/Lib/_markupbase.py b/Lib/_markupbase.py
index adf6ba2f53..98b9037aff 100644
--- a/Lib/_markupbase.py
+++ b/Lib/_markupbase.py
@@ -122,7 +122,7 @@ class ParserBase:
# this could be handled in a separate doctype parser
if decltype == "doctype":
j = self._parse_doctype_subset(j + 1, i)
- elif decltype in ("attlist", "linktype", "link", "element"):
+ elif decltype in {"attlist", "linktype", "link", "element"}:
# must tolerate []'d groups in a content model in an element declaration
# also in data attribute specifications of attlist declaration
# also link type declaration subsets in linktype declarations
@@ -145,10 +145,10 @@ class ParserBase:
sectName, j = self._scan_name( i+3, i )
if j < 0:
return j
- if sectName in ("temp", "cdata", "ignore", "include", "rcdata"):
+ if sectName in {"temp", "cdata", "ignore", "include", "rcdata"}:
# look for standard ]]> ending
match= _markedsectionclose.search(rawdata, i+3)
- elif sectName in ("if", "else", "endif"):
+ elif sectName in {"if", "else", "endif"}:
# look for MS Office ]> ending
match= _msmarkedsectionclose.search(rawdata, i+3)
else:
@@ -203,7 +203,7 @@ class ParserBase:
name, j = self._scan_name(j + 2, declstartpos)
if j == -1:
return -1
- if name not in ("attlist", "element", "entity", "notation"):
+ if name not in {"attlist", "element", "entity", "notation"}:
self.updatepos(declstartpos, j + 2)
self.error(
"unknown declaration %r in internal subset" % name)
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index fa00eb4fb3..35dea411e7 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -13,8 +13,8 @@ except ImportError:
from _dummy_thread import allocate_lock as Lock
import io
-from io import __all__
-from io import SEEK_SET, SEEK_CUR, SEEK_END
+from io import (__all__, SEEK_SET, SEEK_CUR, SEEK_END)
+from errno import EINTR
# open() uses st_blksize whenever we can
DEFAULT_BUFFER_SIZE = 8 * 1024 # bytes
@@ -35,9 +35,8 @@ class BlockingIOError(IOError):
self.characters_written = characters_written
-def open(file, mode = "r", buffering = None,
- encoding = None, errors = None,
- newline = None, closefd = True) -> "IOBase":
+def open(file, mode="r", buffering=-1, encoding=None, errors=None,
+ newline=None, closefd=True):
r"""Open file and return a stream. Raise IOError upon failure.
@@ -97,7 +96,7 @@ def open(file, mode = "r", buffering = None,
use line buffering. Other text files use the policy described above
for binary files.
- encoding is the name of the encoding used to decode or encode the
+ encoding is the str name of the encoding used to decode or encode the
file. This should only be used in text mode. The default encoding is
platform dependent, but any encoding supported by Python can be
passed. See the codecs module for the list of supported encodings.
@@ -110,9 +109,9 @@ def open(file, mode = "r", buffering = None,
See the documentation for codecs.register for a list of the permitted
encoding error strings.
- newline controls how universal newlines works (it only applies to text
- mode). It can be None, '', '\n', '\r', and '\r\n'. It works as
- follows:
+ newline is a string controlling how universal newlines works (it only
+ applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works
+ as follows:
* On input, if newline is None, universal newlines mode is
enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
@@ -128,9 +127,9 @@ def open(file, mode = "r", buffering = None,
other legal values, any '\n' characters written are translated to
the given string.
- If closefd is False, the underlying file descriptor will be kept open
- when the file is closed. This does not work when a file name is given
- and must be True in that case.
+ closedfd is a bool. If closefd is False, the underlying file descriptor will
+ be kept open when the file is closed. This does not work when a file name is
+ given and must be True in that case.
open() returns a file object whose type depends on the mode, and
through which the standard file operations such as reading and writing
@@ -150,7 +149,7 @@ def open(file, mode = "r", buffering = None,
raise TypeError("invalid file: %r" % file)
if not isinstance(mode, str):
raise TypeError("invalid mode: %r" % mode)
- if buffering is not None and not isinstance(buffering, int):
+ if not isinstance(buffering, int):
raise TypeError("invalid buffering: %r" % buffering)
if encoding is not None and not isinstance(encoding, str):
raise TypeError("invalid encoding: %r" % encoding)
@@ -187,8 +186,6 @@ def open(file, mode = "r", buffering = None,
(appending and "a" or "") +
(updating and "+" or ""),
closefd)
- if buffering is None:
- buffering = -1
line_buffering = False
if buffering == 1 or buffering < 0 and raw.isatty():
buffering = -1
@@ -228,7 +225,7 @@ class DocDescriptor:
"""
def __get__(self, obj, typ):
return (
- "open(file, mode='r', buffering=None, encoding=None, "
+ "open(file, mode='r', buffering=-1, encoding=None, "
"errors=None, newline=None, closefd=True)\n\n" +
open.__doc__)
@@ -246,8 +243,13 @@ class OpenWrapper:
return open(*args, **kwargs)
-class UnsupportedOperation(ValueError, IOError):
- pass
+# In normal operation, both `UnsupportedOperation`s should be bound to the
+# same object.
+try:
+ UnsupportedOperation = io.UnsupportedOperation
+except AttributeError:
+ class UnsupportedOperation(ValueError, IOError):
+ pass
class IOBase(metaclass=abc.ABCMeta):
@@ -262,7 +264,8 @@ class IOBase(metaclass=abc.ABCMeta):
Even though IOBase does not declare read, readinto, or write because
their signatures will vary, implementations and clients should
consider those methods part of the interface. Also, implementations
- may raise a IOError when operations they do not support are called.
+ may raise UnsupportedOperation when operations they do not support are
+ called.
The basic type used for binary data read from or written to a file is
bytes. bytearrays are accepted too, and in some cases (such as
@@ -285,32 +288,32 @@ class IOBase(metaclass=abc.ABCMeta):
### Internal ###
def _unsupported(self, name):
- """Internal: raise an exception for unsupported operations."""
+ """Internal: raise an IOError exception for unsupported operations."""
raise UnsupportedOperation("%s.%s() not supported" %
(self.__class__.__name__, name))
### Positioning ###
- def seek(self, pos, whence = 0):
+ def seek(self, pos, whence=0):
"""Change stream position.
Change the stream position to byte offset offset. offset is
interpreted relative to the position indicated by whence. Values
- for whence are:
+ for whence are ints:
* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative
- Return the new absolute position.
+ Return an int indicating the new absolute position.
"""
self._unsupported("seek")
def tell(self):
- """Return current stream position."""
+ """Return an int indicating the current stream position."""
return self.seek(0, 1)
- def truncate(self, pos = None):
+ def truncate(self, pos=None):
"""Truncate file to size bytes.
Size defaults to the current IO position as reported by tell(). Return
@@ -354,49 +357,47 @@ class IOBase(metaclass=abc.ABCMeta):
### Inquiries ###
def seekable(self):
- """Return whether object supports random access.
+ """Return a bool indicating whether object supports random access.
- If False, seek(), tell() and truncate() will raise IOError.
+ If False, seek(), tell() and truncate() will raise UnsupportedOperation.
This method may need to do a test seek().
"""
return False
def _checkSeekable(self, msg=None):
- """Internal: raise an IOError if file is not seekable
+ """Internal: raise UnsupportedOperation if file is not seekable
"""
if not self.seekable():
- raise IOError("File or stream is not seekable."
- if msg is None else msg)
-
+ raise UnsupportedOperation("File or stream is not seekable."
+ if msg is None else msg)
def readable(self):
+ """Return a bool indicating whether object was opened for reading.
- """Return whether object was opened for reading.
-
- If False, read() will raise IOError.
+ If False, read() will raise UnsupportedOperation.
"""
return False
def _checkReadable(self, msg=None):
- """Internal: raise an IOError if file is not readable
+ """Internal: raise UnsupportedOperation if file is not readable
"""
if not self.readable():
- raise IOError("File or stream is not readable."
- if msg is None else msg)
+ raise UnsupportedOperation("File or stream is not readable."
+ if msg is None else msg)
def writable(self):
- """Return whether object was opened for writing.
+ """Return a bool indicating whether object was opened for writing.
- If False, write() and truncate() will raise IOError.
+ If False, write() and truncate() will raise UnsupportedOperation.
"""
return False
def _checkWritable(self, msg=None):
- """Internal: raise an IOError if file is not writable
+ """Internal: raise UnsupportedOperation if file is not writable
"""
if not self.writable():
- raise IOError("File or stream is not writable."
- if msg is None else msg)
+ raise UnsupportedOperation("File or stream is not writable."
+ if msg is None else msg)
@property
def closed(self):
@@ -416,7 +417,7 @@ class IOBase(metaclass=abc.ABCMeta):
### Context manager ###
def __enter__(self): # That's a forward reference
- """Context management protocol. Returns self."""
+ """Context management protocol. Returns self (an instance of IOBase)."""
self._checkClosed()
return self
@@ -429,14 +430,14 @@ class IOBase(metaclass=abc.ABCMeta):
# XXX Should these be present even if unimplemented?
def fileno(self):
- """Returns underlying file descriptor if one exists.
+ """Returns underlying file descriptor (an int) if one exists.
An IOError is raised if the IO object does not use a file descriptor.
"""
self._unsupported("fileno")
def isatty(self):
- """Return whether this is an 'interactive' stream.
+ """Return a bool indicating whether this is an 'interactive' stream.
Return False if it can't be determined.
"""
@@ -445,10 +446,11 @@ class IOBase(metaclass=abc.ABCMeta):
### Readline[s] and writelines ###
- def readline(self, limit = -1):
- r"""Read and return a line from the stream.
+ def readline(self, limit=-1):
+ r"""Read and return a line of bytes from the stream.
If limit is specified, at most limit bytes will be read.
+ Limit should be an int.
The line terminator is always b'\n' for binary files; for text
files, the newlines argument to open can be used to select the line
@@ -531,8 +533,8 @@ class RawIOBase(IOBase):
# primitive operation, but that would lead to nasty recursion in case
# a subclass doesn't implement either.)
- def read(self, n = -1):
- """Read and return up to n bytes.
+ def read(self, n=-1):
+ """Read and return up to n bytes, where n is an int.
Returns an empty bytes object on EOF, or None if the object is
set not to block and has no data to read.
@@ -559,10 +561,10 @@ class RawIOBase(IOBase):
return bytes(res)
def readinto(self, b):
- """Read up to len(b) bytes into b.
+ """Read up to len(b) bytes into bytearray b.
- Returns number of bytes read (0 for EOF), or None if the object
- is set not to block and has no data to read.
+ Returns an int representing the number of bytes read (0 for EOF), or
+ None if the object is set not to block and has no data to read.
"""
self._unsupported("readinto")
@@ -595,8 +597,8 @@ class BufferedIOBase(IOBase):
implementation, but wrap one.
"""
- def read(self, n = None):
- """Read and return up to n bytes.
+ def read(self, n=None):
+ """Read and return up to n bytes, where n is an int.
If the argument is omitted, None, or negative, reads and
returns all data until EOF.
@@ -615,17 +617,19 @@ class BufferedIOBase(IOBase):
"""
self._unsupported("read")
- def read1(self, n = None):
- """Read up to n bytes with at most one read() system call."""
+ def read1(self, n=None):
+ """Read up to n bytes with at most one read() system call,
+ where n is an int.
+ """
self._unsupported("read1")
def readinto(self, b):
- """Read up to len(b) bytes into b.
+ """Read up to len(b) bytes into bytearray b.
Like read(), this may issue multiple reads to the underlying raw
stream, unless the latter is 'interactive'.
- Returns the number of bytes read (0 for EOF).
+ Returns an int representing the number of bytes read (0 for EOF).
Raises BlockingIOError if the underlying raw stream has no
data at the moment.
@@ -643,7 +647,7 @@ class BufferedIOBase(IOBase):
return n
def write(self, b):
- """Write the given buffer to the IO stream.
+ """Write the given bytes buffer to the IO stream.
Return the number of bytes written, which is never less than
len(b).
@@ -750,6 +754,10 @@ class _BufferedIOMixin(BufferedIOBase):
def mode(self):
return self.raw.mode
+ def __getstate__(self):
+ raise TypeError("can not serialize a '{0}' object"
+ .format(self.__class__.__name__))
+
def __repr__(self):
clsname = self.__class__.__name__
try:
@@ -779,6 +787,11 @@ class BytesIO(BufferedIOBase):
self._buffer = buf
self._pos = 0
+ def __getstate__(self):
+ if self.closed:
+ raise ValueError("__getstate__ on closed file")
+ return self.__dict__.copy()
+
def getvalue(self):
"""Return the bytes value (contents) of the buffer
"""
@@ -786,6 +799,11 @@ class BytesIO(BufferedIOBase):
raise ValueError("getvalue on closed file")
return bytes(self._buffer)
+ def getbuffer(self):
+ """Return a readable and writable view of the buffer.
+ """
+ return memoryview(self._buffer)
+
def read(self, n=None):
if self.closed:
raise ValueError("read from closed file")
@@ -827,7 +845,7 @@ class BytesIO(BufferedIOBase):
if self.closed:
raise ValueError("seek on closed file")
try:
- pos = pos.__index__()
+ pos.__index__
except AttributeError as err:
raise TypeError("an integer is required") from err
if whence == 0:
@@ -852,8 +870,13 @@ class BytesIO(BufferedIOBase):
raise ValueError("truncate on closed file")
if pos is None:
pos = self._pos
- elif pos < 0:
- raise ValueError("negative truncate position %r" % (pos,))
+ else:
+ try:
+ pos.__index__
+ except AttributeError as err:
+ raise TypeError("an integer is required") from err
+ if pos < 0:
+ raise ValueError("negative truncate position %r" % (pos,))
del self._buffer[pos:]
return pos
@@ -921,7 +944,12 @@ class BufferedReader(_BufferedIOMixin):
current_size = 0
while True:
# Read until EOF or until read() would block.
- chunk = self.raw.read()
+ try:
+ chunk = self.raw.read()
+ except IOError as e:
+ if e.errno != EINTR:
+ raise
+ continue
if chunk in empty_values:
nodata_val = chunk
break
@@ -940,7 +968,12 @@ class BufferedReader(_BufferedIOMixin):
chunks = [buf[pos:]]
wanted = max(self.buffer_size, n)
while avail < n:
- chunk = self.raw.read(wanted)
+ try:
+ chunk = self.raw.read(wanted)
+ except IOError as e:
+ if e.errno != EINTR:
+ raise
+ continue
if chunk in empty_values:
nodata_val = chunk
break
@@ -969,7 +1002,14 @@ class BufferedReader(_BufferedIOMixin):
have = len(self._read_buf) - self._read_pos
if have < want or have <= 0:
to_read = self.buffer_size - have
- current = self.raw.read(to_read)
+ while True:
+ try:
+ current = self.raw.read(to_read)
+ except IOError as e:
+ if e.errno != EINTR:
+ raise
+ continue
+ break
if current:
self._read_buf = self._read_buf[self._read_pos:] + current
self._read_pos = 0
@@ -1076,7 +1116,12 @@ class BufferedWriter(_BufferedIOMixin):
written = 0
try:
while self._write_buf:
- n = self.raw.write(self._write_buf)
+ try:
+ n = self.raw.write(self._write_buf)
+ except IOError as e:
+ if e.errno != EINTR:
+ raise
+ continue
if n > len(self._write_buf) or n < 0:
raise IOError("write() returned incorrect number of bytes")
del self._write_buf[:n]
@@ -1252,20 +1297,22 @@ class TextIOBase(IOBase):
are immutable. There is no public constructor.
"""
- def read(self, n = -1):
- """Read at most n characters from stream.
+ def read(self, n=-1):
+ """Read at most n characters from stream, where n is an int.
Read from underlying buffer until we have n characters or we hit EOF.
If n is negative or omitted, read until EOF.
+
+ Returns a string.
"""
self._unsupported("read")
def write(self, s):
- """Write string s to stream."""
+ """Write string s to stream and returning an int."""
self._unsupported("write")
- def truncate(self, pos = None):
- """Truncate size to pos."""
+ def truncate(self, pos=None):
+ """Truncate size to pos, where pos is an int."""
self._unsupported("truncate")
def readline(self):
@@ -1484,13 +1531,20 @@ class TextIOWrapper(TextIOBase):
# - "chars_..." for integer variables that count decoded characters
def __repr__(self):
+ result = "<_pyio.TextIOWrapper"
try:
name = self.name
except AttributeError:
- return "<_pyio.TextIOWrapper encoding={0!r}>".format(self.encoding)
+ pass
else:
- return "<_pyio.TextIOWrapper name={0!r} encoding={1!r}>".format(
- name, self.encoding)
+ result += " name={0!r}".format(name)
+ try:
+ mode = self.mode
+ except AttributeError:
+ pass
+ else:
+ result += " mode={0!r}".format(mode)
+ return result + " encoding={0!r}>".format(self.encoding)
@property
def encoding(self):
@@ -1540,7 +1594,8 @@ class TextIOWrapper(TextIOBase):
def isatty(self):
return self.buffer.isatty()
- def write(self, s: str):
+ def write(self, s):
+ 'Write data, where s is a str'
if self.closed:
raise ValueError("write to closed file")
if not isinstance(s, str):
@@ -1651,7 +1706,7 @@ class TextIOWrapper(TextIOBase):
def tell(self):
if not self._seekable:
- raise IOError("underlying stream is not seekable")
+ raise UnsupportedOperation("underlying stream is not seekable")
if not self._telling:
raise IOError("telling position disabled by next() call")
self.flush()
@@ -1730,17 +1785,17 @@ class TextIOWrapper(TextIOBase):
if self.closed:
raise ValueError("tell on closed file")
if not self._seekable:
- raise IOError("underlying stream is not seekable")
+ raise UnsupportedOperation("underlying stream is not seekable")
if whence == 1: # seek relative to current position
if cookie != 0:
- raise IOError("can't do nonzero cur-relative seeks")
+ raise UnsupportedOperation("can't do nonzero cur-relative seeks")
# Seeking to the current position should attempt to
# sync the underlying buffer with the current position.
whence = 0
cookie = self.tell()
if whence == 2: # seek relative to end of file
if cookie != 0:
- raise IOError("can't do nonzero end-relative seeks")
+ raise UnsupportedOperation("can't do nonzero end-relative seeks")
self.flush()
position = self.buffer.seek(0, 2)
self._set_decoded_chars('')
@@ -1803,6 +1858,10 @@ class TextIOWrapper(TextIOBase):
if n is None:
n = -1
decoder = self._decoder or self._get_decoder()
+ try:
+ n.__index__
+ except AttributeError as err:
+ raise TypeError("an integer is required") from err
if n < 0:
# Read everything.
result = (self._get_decoded_chars() +
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index ee30b4216c..0ea4c43111 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -16,7 +16,9 @@ import calendar
from re import compile as re_compile
from re import IGNORECASE, ASCII
from re import escape as re_escape
-from datetime import date as datetime_date
+from datetime import (date as datetime_date,
+ timedelta as datetime_timedelta,
+ timezone as datetime_timezone)
try:
from _thread import allocate_lock as _thread_allocate_lock
except:
@@ -204,6 +206,7 @@ class TimeRE(dict):
#XXX: Does 'Y' need to worry about having less or more than
# 4 digits?
'Y': r"(?P<Y>\d\d\d\d)",
+ 'z': r"(?P<z>[+-]\d\d[0-5]\d)",
'A': self.__seqToRE(self.locale_time.f_weekday, 'A'),
'a': self.__seqToRE(self.locale_time.a_weekday, 'a'),
'B': self.__seqToRE(self.locale_time.f_month[1:], 'B'),
@@ -293,7 +296,9 @@ def _calc_julian_from_U_or_W(year, week_of_year, day_of_week, week_starts_Mon):
def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
- """Return a time struct based on the input string and the format string."""
+ """Return a 2-tuple consisting of a time struct and an int containing
+ the number of microseconds based on the input string and the
+ format string."""
for index, arg in enumerate([data_string, format]):
if not isinstance(arg, str):
@@ -333,10 +338,12 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
if len(data_string) != found.end():
raise ValueError("unconverted data remains: %s" %
data_string[found.end():])
+
year = 1900
month = day = 1
hour = minute = second = fraction = 0
tz = -1
+ tzoffset = None
# Default to -1 to signify that values not known; not critical to have,
# though
week_of_year = -1
@@ -417,6 +424,11 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
else:
# W starts week on Monday.
week_of_year_start = 0
+ elif group_key == 'z':
+ z = found_dict['z']
+ tzoffset = int(z[1:3]) * 60 + int(z[3:5])
+ if z.startswith("-"):
+ tzoffset = -tzoffset
elif group_key == 'Z':
# Since -1 is default value only need to worry about setting tz if
# it can be something other than -1.
@@ -453,9 +465,35 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
day = datetime_result.day
if weekday == -1:
weekday = datetime_date(year, month, day).weekday()
- return (time.struct_time((year, month, day,
- hour, minute, second,
- weekday, julian, tz)), fraction)
+ # Add timezone info
+ tzname = found_dict.get("Z")
+ if tzoffset is not None:
+ gmtoff = tzoffset * 60
+ else:
+ gmtoff = None
+
+ return (year, month, day,
+ hour, minute, second,
+ weekday, julian, tz, gmtoff, tzname), fraction
def _strptime_time(data_string, format="%a %b %d %H:%M:%S %Y"):
- return _strptime(data_string, format)[0]
+ """Return a time struct based on the input string and the
+ format string."""
+ tt = _strptime(data_string, format)[0]
+ return time.struct_time(tt[:9])
+
+def _strptime_datetime(cls, data_string, format="%a %b %d %H:%M:%S %Y"):
+ """Return a class cls instance based on the input string and the
+ format string."""
+ tt, fraction = _strptime(data_string, format)
+ gmtoff, tzname = tt[-2:]
+ args = tt[:6] + (fraction,)
+ if gmtoff is not None:
+ tzdelta = datetime_timedelta(seconds=gmtoff)
+ if tzname:
+ tz = datetime_timezone(tzdelta, tzname)
+ else:
+ tz = datetime_timezone(tzdelta)
+ args += (tz,)
+
+ return cls(*args)
diff --git a/Lib/_threading_local.py b/Lib/_threading_local.py
index afdd6eabca..4ec4828144 100644
--- a/Lib/_threading_local.py
+++ b/Lib/_threading_local.py
@@ -132,6 +132,9 @@ affects what we see:
>>> del mydata
"""
+from weakref import ref
+from contextlib import contextmanager
+
__all__ = ["local"]
# We need to use objects from the threading module, but the threading
@@ -139,112 +142,105 @@ __all__ = ["local"]
# isn't compiled in to the `thread` module. This creates potential problems
# with circular imports. For that reason, we don't import `threading`
# until the bottom of this file (a hack sufficient to worm around the
-# potential problems). Note that almost all platforms do have support for
-# locals in the `thread` module, and there is no circular import problem
+# potential problems). Note that all platforms on CPython do have support
+# for locals in the `thread` module, and there is no circular import problem
# then, so problems introduced by fiddling the order of imports here won't
-# manifest on most boxes.
+# manifest.
+
+class _localimpl:
+ """A class managing thread-local dicts"""
+ __slots__ = 'key', 'dicts', 'localargs', 'locallock', '__weakref__'
+
+ def __init__(self):
+ # The key used in the Thread objects' attribute dicts.
+ # We keep it a string for speed but make it unlikely to clash with
+ # a "real" attribute.
+ self.key = '_threading_local._localimpl.' + str(id(self))
+ # { id(Thread) -> (ref(Thread), thread-local dict) }
+ self.dicts = {}
+
+ def get_dict(self):
+ """Return the dict for the current thread. Raises KeyError if none
+ defined."""
+ thread = current_thread()
+ return self.dicts[id(thread)][1]
+
+ def create_dict(self):
+ """Create a new dict for the current thread, and return it."""
+ localdict = {}
+ key = self.key
+ thread = current_thread()
+ idt = id(thread)
+ def local_deleted(_, key=key):
+ # When the localimpl is deleted, remove the thread attribute.
+ thread = wrthread()
+ if thread is not None:
+ del thread.__dict__[key]
+ def thread_deleted(_, idt=idt):
+ # When the thread is deleted, remove the local dict.
+ # Note that this is suboptimal if the thread object gets
+ # caught in a reference loop. We would like to be called
+ # as soon as the OS-level thread ends instead.
+ local = wrlocal()
+ if local is not None:
+ dct = local.dicts.pop(idt)
+ wrlocal = ref(self, local_deleted)
+ wrthread = ref(thread, thread_deleted)
+ thread.__dict__[key] = wrlocal
+ self.dicts[idt] = wrthread, localdict
+ return localdict
+
+
+@contextmanager
+def _patch(self):
+ impl = object.__getattribute__(self, '_local__impl')
+ try:
+ dct = impl.get_dict()
+ except KeyError:
+ dct = impl.create_dict()
+ args, kw = impl.localargs
+ self.__init__(*args, **kw)
+ with impl.locallock:
+ object.__setattr__(self, '__dict__', dct)
+ yield
-class _localbase(object):
- __slots__ = '_local__key', '_local__args', '_local__lock'
- def __new__(cls, *args, **kw):
- self = object.__new__(cls)
- key = '_local__key', 'thread.local.' + str(id(self))
- object.__setattr__(self, '_local__key', key)
- object.__setattr__(self, '_local__args', (args, kw))
- object.__setattr__(self, '_local__lock', RLock())
+class local:
+ __slots__ = '_local__impl', '__dict__'
- if args or kw and (cls.__init__ is object.__init__):
+ def __new__(cls, *args, **kw):
+ if (args or kw) and (cls.__init__ is object.__init__):
raise TypeError("Initialization arguments are not supported")
-
+ self = object.__new__(cls)
+ impl = _localimpl()
+ impl.localargs = (args, kw)
+ impl.locallock = RLock()
+ object.__setattr__(self, '_local__impl', impl)
# We need to create the thread dict in anticipation of
# __init__ being called, to make sure we don't call it
# again ourselves.
- dict = object.__getattribute__(self, '__dict__')
- current_thread().__dict__[key] = dict
-
+ impl.create_dict()
return self
-def _patch(self):
- key = object.__getattribute__(self, '_local__key')
- d = current_thread().__dict__.get(key)
- if d is None:
- d = {}
- current_thread().__dict__[key] = d
- object.__setattr__(self, '__dict__', d)
-
- # we have a new instance dict, so call out __init__ if we have
- # one
- cls = type(self)
- if cls.__init__ is not object.__init__:
- args, kw = object.__getattribute__(self, '_local__args')
- cls.__init__(self, *args, **kw)
- else:
- object.__setattr__(self, '__dict__', d)
-
-class local(_localbase):
-
def __getattribute__(self, name):
- lock = object.__getattribute__(self, '_local__lock')
- lock.acquire()
- try:
- _patch(self)
+ with _patch(self):
return object.__getattribute__(self, name)
- finally:
- lock.release()
def __setattr__(self, name, value):
if name == '__dict__':
raise AttributeError(
"%r object attribute '__dict__' is read-only"
% self.__class__.__name__)
- lock = object.__getattribute__(self, '_local__lock')
- lock.acquire()
- try:
- _patch(self)
+ with _patch(self):
return object.__setattr__(self, name, value)
- finally:
- lock.release()
def __delattr__(self, name):
if name == '__dict__':
raise AttributeError(
"%r object attribute '__dict__' is read-only"
% self.__class__.__name__)
- lock = object.__getattribute__(self, '_local__lock')
- lock.acquire()
- try:
- _patch(self)
+ with _patch(self):
return object.__delattr__(self, name)
- finally:
- lock.release()
-
- def __del__(self):
- import threading
-
- key = object.__getattribute__(self, '_local__key')
-
- try:
- # We use the non-locking API since we might already hold the lock
- # (__del__ can be called at any point by the cyclic GC).
- threads = threading._enumerate()
- except:
- # If enumerating the current threads fails, as it seems to do
- # during shutdown, we'll skip cleanup under the assumption
- # that there is nothing to clean up.
- return
-
- for thread in threads:
- try:
- __dict__ = thread.__dict__
- except AttributeError:
- # Thread is dying, rest in peace.
- continue
-
- if key in __dict__:
- try:
- del __dict__[key]
- except KeyError:
- pass # didn't have anything in this thread
+
from threading import current_thread, RLock
diff --git a/Lib/abc.py b/Lib/abc.py
index 0f98036304..a6c2dc4877 100644
--- a/Lib/abc.py
+++ b/Lib/abc.py
@@ -25,6 +25,46 @@ def abstractmethod(funcobj):
return funcobj
+class abstractclassmethod(classmethod):
+ """A decorator indicating abstract classmethods.
+
+ Similar to abstractmethod.
+
+ Usage:
+
+ class C(metaclass=ABCMeta):
+ @abstractclassmethod
+ def my_abstract_classmethod(cls, ...):
+ ...
+ """
+
+ __isabstractmethod__ = True
+
+ def __init__(self, callable):
+ callable.__isabstractmethod__ = True
+ super().__init__(callable)
+
+
+class abstractstaticmethod(staticmethod):
+ """A decorator indicating abstract staticmethods.
+
+ Similar to abstractmethod.
+
+ Usage:
+
+ class C(metaclass=ABCMeta):
+ @abstractstaticmethod
+ def my_abstract_staticmethod(...):
+ ...
+ """
+
+ __isabstractmethod__ = True
+
+ def __init__(self, callable):
+ callable.__isabstractmethod__ = True
+ super().__init__(callable)
+
+
class abstractproperty(property):
"""A decorator indicating abstract properties.
diff --git a/Lib/argparse.py b/Lib/argparse.py
new file mode 100644
index 0000000000..de3cd11479
--- /dev/null
+++ b/Lib/argparse.py
@@ -0,0 +1,2358 @@
+# Author: Steven J. Bethard <steven.bethard@gmail.com>.
+
+"""Command-line parsing library
+
+This module is an optparse-inspired command-line parsing library that:
+
+ - handles both optional and positional arguments
+ - produces highly informative usage messages
+ - supports parsers that dispatch to sub-parsers
+
+The following is a simple usage example that sums integers from the
+command-line and writes the result to a file::
+
+ parser = argparse.ArgumentParser(
+ description='sum the integers at the command line')
+ parser.add_argument(
+ 'integers', metavar='int', nargs='+', type=int,
+ help='an integer to be summed')
+ parser.add_argument(
+ '--log', default=sys.stdout, type=argparse.FileType('w'),
+ help='the file where the sum should be written')
+ args = parser.parse_args()
+ args.log.write('%s' % sum(args.integers))
+ args.log.close()
+
+The module contains the following public classes:
+
+ - ArgumentParser -- The main entry point for command-line parsing. As the
+ example above shows, the add_argument() method is used to populate
+ the parser with actions for optional and positional arguments. Then
+ the parse_args() method is invoked to convert the args at the
+ command-line into an object with attributes.
+
+ - ArgumentError -- The exception raised by ArgumentParser objects when
+ there are errors with the parser's actions. Errors raised while
+ parsing the command-line are caught by ArgumentParser and emitted
+ as command-line messages.
+
+ - FileType -- A factory for defining types of files to be created. As the
+ example above shows, instances of FileType are typically passed as
+ the type= argument of add_argument() calls.
+
+ - Action -- The base class for parser actions. Typically actions are
+ selected by passing strings like 'store_true' or 'append_const' to
+ the action= argument of add_argument(). However, for greater
+ customization of ArgumentParser actions, subclasses of Action may
+ be defined and passed as the action= argument.
+
+ - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter,
+ ArgumentDefaultsHelpFormatter -- Formatter classes which
+ may be passed as the formatter_class= argument to the
+ ArgumentParser constructor. HelpFormatter is the default,
+ RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser
+ not to change the formatting for help text, and
+ ArgumentDefaultsHelpFormatter adds information about argument defaults
+ to the help.
+
+All other classes in this module are considered implementation details.
+(Also note that HelpFormatter and RawDescriptionHelpFormatter are only
+considered public as object names -- the API of the formatter objects is
+still considered an implementation detail.)
+"""
+
+__version__ = '1.1'
+__all__ = [
+ 'ArgumentParser',
+ 'ArgumentError',
+ 'ArgumentTypeError',
+ 'FileType',
+ 'HelpFormatter',
+ 'ArgumentDefaultsHelpFormatter',
+ 'RawDescriptionHelpFormatter',
+ 'RawTextHelpFormatter',
+ 'Namespace',
+ 'Action',
+ 'ONE_OR_MORE',
+ 'OPTIONAL',
+ 'PARSER',
+ 'REMAINDER',
+ 'SUPPRESS',
+ 'ZERO_OR_MORE',
+]
+
+
+import copy as _copy
+import os as _os
+import re as _re
+import sys as _sys
+import textwrap as _textwrap
+
+from gettext import gettext as _, ngettext
+
+
+def _callable(obj):
+ return hasattr(obj, '__call__') or hasattr(obj, '__bases__')
+
+
+SUPPRESS = '==SUPPRESS=='
+
+OPTIONAL = '?'
+ZERO_OR_MORE = '*'
+ONE_OR_MORE = '+'
+PARSER = 'A...'
+REMAINDER = '...'
+_UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args'
+
+# =============================
+# Utility functions and classes
+# =============================
+
+class _AttributeHolder(object):
+ """Abstract base class that provides __repr__.
+
+ The __repr__ method returns a string in the format::
+ ClassName(attr=name, attr=name, ...)
+ The attributes are determined either by a class-level attribute,
+ '_kwarg_names', or by inspecting the instance __dict__.
+ """
+
+ def __repr__(self):
+ type_name = type(self).__name__
+ arg_strings = []
+ for arg in self._get_args():
+ arg_strings.append(repr(arg))
+ for name, value in self._get_kwargs():
+ arg_strings.append('%s=%r' % (name, value))
+ return '%s(%s)' % (type_name, ', '.join(arg_strings))
+
+ def _get_kwargs(self):
+ return sorted(self.__dict__.items())
+
+ def _get_args(self):
+ return []
+
+
+def _ensure_value(namespace, name, value):
+ if getattr(namespace, name, None) is None:
+ setattr(namespace, name, value)
+ return getattr(namespace, name)
+
+
+# ===============
+# Formatting Help
+# ===============
+
+class HelpFormatter(object):
+ """Formatter for generating usage messages and argument help strings.
+
+ Only the name of this class is considered a public API. All the methods
+ provided by the class are considered an implementation detail.
+ """
+
+ def __init__(self,
+ prog,
+ indent_increment=2,
+ max_help_position=24,
+ width=None):
+
+ # default setting for width
+ if width is None:
+ try:
+ width = int(_os.environ['COLUMNS'])
+ except (KeyError, ValueError):
+ width = 80
+ width -= 2
+
+ self._prog = prog
+ self._indent_increment = indent_increment
+ self._max_help_position = max_help_position
+ self._width = width
+
+ self._current_indent = 0
+ self._level = 0
+ self._action_max_length = 0
+
+ self._root_section = self._Section(self, None)
+ self._current_section = self._root_section
+
+ self._whitespace_matcher = _re.compile(r'\s+')
+ self._long_break_matcher = _re.compile(r'\n\n\n+')
+
+ # ===============================
+ # Section and indentation methods
+ # ===============================
+ def _indent(self):
+ self._current_indent += self._indent_increment
+ self._level += 1
+
+ def _dedent(self):
+ self._current_indent -= self._indent_increment
+ assert self._current_indent >= 0, 'Indent decreased below 0.'
+ self._level -= 1
+
+ class _Section(object):
+
+ def __init__(self, formatter, parent, heading=None):
+ self.formatter = formatter
+ self.parent = parent
+ self.heading = heading
+ self.items = []
+
+ def format_help(self):
+ # format the indented section
+ if self.parent is not None:
+ self.formatter._indent()
+ join = self.formatter._join_parts
+ for func, args in self.items:
+ func(*args)
+ item_help = join([func(*args) for func, args in self.items])
+ if self.parent is not None:
+ self.formatter._dedent()
+
+ # return nothing if the section was empty
+ if not item_help:
+ return ''
+
+ # add the heading if the section was non-empty
+ if self.heading is not SUPPRESS and self.heading is not None:
+ current_indent = self.formatter._current_indent
+ heading = '%*s%s:\n' % (current_indent, '', self.heading)
+ else:
+ heading = ''
+
+ # join the section-initial newline, the heading and the help
+ return join(['\n', heading, item_help, '\n'])
+
+ def _add_item(self, func, args):
+ self._current_section.items.append((func, args))
+
+ # ========================
+ # Message building methods
+ # ========================
+ def start_section(self, heading):
+ self._indent()
+ section = self._Section(self, self._current_section, heading)
+ self._add_item(section.format_help, [])
+ self._current_section = section
+
+ def end_section(self):
+ self._current_section = self._current_section.parent
+ self._dedent()
+
+ def add_text(self, text):
+ if text is not SUPPRESS and text is not None:
+ self._add_item(self._format_text, [text])
+
+ def add_usage(self, usage, actions, groups, prefix=None):
+ if usage is not SUPPRESS:
+ args = usage, actions, groups, prefix
+ self._add_item(self._format_usage, args)
+
+ def add_argument(self, action):
+ if action.help is not SUPPRESS:
+
+ # find all invocations
+ get_invocation = self._format_action_invocation
+ invocations = [get_invocation(action)]
+ for subaction in self._iter_indented_subactions(action):
+ invocations.append(get_invocation(subaction))
+
+ # update the maximum item length
+ invocation_length = max([len(s) for s in invocations])
+ action_length = invocation_length + self._current_indent
+ self._action_max_length = max(self._action_max_length,
+ action_length)
+
+ # add the item to the list
+ self._add_item(self._format_action, [action])
+
+ def add_arguments(self, actions):
+ for action in actions:
+ self.add_argument(action)
+
+ # =======================
+ # Help-formatting methods
+ # =======================
+ def format_help(self):
+ help = self._root_section.format_help()
+ if help:
+ help = self._long_break_matcher.sub('\n\n', help)
+ help = help.strip('\n') + '\n'
+ return help
+
+ def _join_parts(self, part_strings):
+ return ''.join([part
+ for part in part_strings
+ if part and part is not SUPPRESS])
+
+ def _format_usage(self, usage, actions, groups, prefix):
+ if prefix is None:
+ prefix = _('usage: ')
+
+ # if usage is specified, use that
+ if usage is not None:
+ usage = usage % dict(prog=self._prog)
+
+ # if no optionals or positionals are available, usage is just prog
+ elif usage is None and not actions:
+ usage = '%(prog)s' % dict(prog=self._prog)
+
+ # if optionals and positionals are available, calculate usage
+ elif usage is None:
+ prog = '%(prog)s' % dict(prog=self._prog)
+
+ # split optionals from positionals
+ optionals = []
+ positionals = []
+ for action in actions:
+ if action.option_strings:
+ optionals.append(action)
+ else:
+ positionals.append(action)
+
+ # build full usage string
+ format = self._format_actions_usage
+ action_usage = format(optionals + positionals, groups)
+ usage = ' '.join([s for s in [prog, action_usage] if s])
+
+ # wrap the usage parts if it's too long
+ text_width = self._width - self._current_indent
+ if len(prefix) + len(usage) > text_width:
+
+ # break usage into wrappable parts
+ part_regexp = r'\(.*?\)+|\[.*?\]+|\S+'
+ opt_usage = format(optionals, groups)
+ pos_usage = format(positionals, groups)
+ opt_parts = _re.findall(part_regexp, opt_usage)
+ pos_parts = _re.findall(part_regexp, pos_usage)
+ assert ' '.join(opt_parts) == opt_usage
+ assert ' '.join(pos_parts) == pos_usage
+
+ # helper for wrapping lines
+ def get_lines(parts, indent, prefix=None):
+ lines = []
+ line = []
+ if prefix is not None:
+ line_len = len(prefix) - 1
+ else:
+ line_len = len(indent) - 1
+ for part in parts:
+ if line_len + 1 + len(part) > text_width:
+ lines.append(indent + ' '.join(line))
+ line = []
+ line_len = len(indent) - 1
+ line.append(part)
+ line_len += len(part) + 1
+ if line:
+ lines.append(indent + ' '.join(line))
+ if prefix is not None:
+ lines[0] = lines[0][len(indent):]
+ return lines
+
+ # if prog is short, follow it with optionals or positionals
+ if len(prefix) + len(prog) <= 0.75 * text_width:
+ indent = ' ' * (len(prefix) + len(prog) + 1)
+ if opt_parts:
+ lines = get_lines([prog] + opt_parts, indent, prefix)
+ lines.extend(get_lines(pos_parts, indent))
+ elif pos_parts:
+ lines = get_lines([prog] + pos_parts, indent, prefix)
+ else:
+ lines = [prog]
+
+ # if prog is long, put it on its own line
+ else:
+ indent = ' ' * len(prefix)
+ parts = opt_parts + pos_parts
+ lines = get_lines(parts, indent)
+ if len(lines) > 1:
+ lines = []
+ lines.extend(get_lines(opt_parts, indent))
+ lines.extend(get_lines(pos_parts, indent))
+ lines = [prog] + lines
+
+ # join lines into usage
+ usage = '\n'.join(lines)
+
+ # prefix with 'usage:'
+ return '%s%s\n\n' % (prefix, usage)
+
+ def _format_actions_usage(self, actions, groups):
+ # find group indices and identify actions in groups
+ group_actions = set()
+ inserts = {}
+ for group in groups:
+ try:
+ start = actions.index(group._group_actions[0])
+ except ValueError:
+ continue
+ else:
+ end = start + len(group._group_actions)
+ if actions[start:end] == group._group_actions:
+ for action in group._group_actions:
+ group_actions.add(action)
+ if not group.required:
+ if start in inserts:
+ inserts[start] += ' ['
+ else:
+ inserts[start] = '['
+ inserts[end] = ']'
+ else:
+ if start in inserts:
+ inserts[start] += ' ('
+ else:
+ inserts[start] = '('
+ inserts[end] = ')'
+ for i in range(start + 1, end):
+ inserts[i] = '|'
+
+ # collect all actions format strings
+ parts = []
+ for i, action in enumerate(actions):
+
+ # suppressed arguments are marked with None
+ # remove | separators for suppressed arguments
+ if action.help is SUPPRESS:
+ parts.append(None)
+ if inserts.get(i) == '|':
+ inserts.pop(i)
+ elif inserts.get(i + 1) == '|':
+ inserts.pop(i + 1)
+
+ # produce all arg strings
+ elif not action.option_strings:
+ part = self._format_args(action, action.dest)
+
+ # if it's in a group, strip the outer []
+ if action in group_actions:
+ if part[0] == '[' and part[-1] == ']':
+ part = part[1:-1]
+
+ # add the action string to the list
+ parts.append(part)
+
+ # produce the first way to invoke the option in brackets
+ else:
+ option_string = action.option_strings[0]
+
+ # if the Optional doesn't take a value, format is:
+ # -s or --long
+ if action.nargs == 0:
+ part = '%s' % option_string
+
+ # if the Optional takes a value, format is:
+ # -s ARGS or --long ARGS
+ else:
+ default = action.dest.upper()
+ args_string = self._format_args(action, default)
+ part = '%s %s' % (option_string, args_string)
+
+ # make it look optional if it's not required or in a group
+ if not action.required and action not in group_actions:
+ part = '[%s]' % part
+
+ # add the action string to the list
+ parts.append(part)
+
+ # insert things at the necessary indices
+ for i in sorted(inserts, reverse=True):
+ parts[i:i] = [inserts[i]]
+
+ # join all the action items with spaces
+ text = ' '.join([item for item in parts if item is not None])
+
+ # clean up separators for mutually exclusive groups
+ open = r'[\[(]'
+ close = r'[\])]'
+ text = _re.sub(r'(%s) ' % open, r'\1', text)
+ text = _re.sub(r' (%s)' % close, r'\1', text)
+ text = _re.sub(r'%s *%s' % (open, close), r'', text)
+ text = _re.sub(r'\(([^|]*)\)', r'\1', text)
+ text = text.strip()
+
+ # return the text
+ return text
+
+ def _format_text(self, text):
+ if '%(prog)' in text:
+ text = text % dict(prog=self._prog)
+ text_width = self._width - self._current_indent
+ indent = ' ' * self._current_indent
+ return self._fill_text(text, text_width, indent) + '\n\n'
+
+ def _format_action(self, action):
+ # determine the required width and the entry label
+ help_position = min(self._action_max_length + 2,
+ self._max_help_position)
+ help_width = self._width - help_position
+ action_width = help_position - self._current_indent - 2
+ action_header = self._format_action_invocation(action)
+
+ # ho nelp; start on same line and add a final newline
+ if not action.help:
+ tup = self._current_indent, '', action_header
+ action_header = '%*s%s\n' % tup
+
+ # short action name; start on the same line and pad two spaces
+ elif len(action_header) <= action_width:
+ tup = self._current_indent, '', action_width, action_header
+ action_header = '%*s%-*s ' % tup
+ indent_first = 0
+
+ # long action name; start on the next line
+ else:
+ tup = self._current_indent, '', action_header
+ action_header = '%*s%s\n' % tup
+ indent_first = help_position
+
+ # collect the pieces of the action help
+ parts = [action_header]
+
+ # if there was help for the action, add lines of help text
+ if action.help:
+ help_text = self._expand_help(action)
+ help_lines = self._split_lines(help_text, help_width)
+ parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
+ for line in help_lines[1:]:
+ parts.append('%*s%s\n' % (help_position, '', line))
+
+ # or add a newline if the description doesn't end with one
+ elif not action_header.endswith('\n'):
+ parts.append('\n')
+
+ # if there are any sub-actions, add their help as well
+ for subaction in self._iter_indented_subactions(action):
+ parts.append(self._format_action(subaction))
+
+ # return a single string
+ return self._join_parts(parts)
+
+ def _format_action_invocation(self, action):
+ if not action.option_strings:
+ metavar, = self._metavar_formatter(action, action.dest)(1)
+ return metavar
+
+ else:
+ parts = []
+
+ # if the Optional doesn't take a value, format is:
+ # -s, --long
+ if action.nargs == 0:
+ parts.extend(action.option_strings)
+
+ # if the Optional takes a value, format is:
+ # -s ARGS, --long ARGS
+ else:
+ default = action.dest.upper()
+ args_string = self._format_args(action, default)
+ for option_string in action.option_strings:
+ parts.append('%s %s' % (option_string, args_string))
+
+ return ', '.join(parts)
+
+ def _metavar_formatter(self, action, default_metavar):
+ if action.metavar is not None:
+ result = action.metavar
+ elif action.choices is not None:
+ choice_strs = [str(choice) for choice in action.choices]
+ result = '{%s}' % ','.join(choice_strs)
+ else:
+ result = default_metavar
+
+ def format(tuple_size):
+ if isinstance(result, tuple):
+ return result
+ else:
+ return (result, ) * tuple_size
+ return format
+
+ def _format_args(self, action, default_metavar):
+ get_metavar = self._metavar_formatter(action, default_metavar)
+ if action.nargs is None:
+ result = '%s' % get_metavar(1)
+ elif action.nargs == OPTIONAL:
+ result = '[%s]' % get_metavar(1)
+ elif action.nargs == ZERO_OR_MORE:
+ result = '[%s [%s ...]]' % get_metavar(2)
+ elif action.nargs == ONE_OR_MORE:
+ result = '%s [%s ...]' % get_metavar(2)
+ elif action.nargs == REMAINDER:
+ result = '...'
+ elif action.nargs == PARSER:
+ result = '%s ...' % get_metavar(1)
+ else:
+ formats = ['%s' for _ in range(action.nargs)]
+ result = ' '.join(formats) % get_metavar(action.nargs)
+ return result
+
+ def _expand_help(self, action):
+ params = dict(vars(action), prog=self._prog)
+ for name in list(params):
+ if params[name] is SUPPRESS:
+ del params[name]
+ for name in list(params):
+ if hasattr(params[name], '__name__'):
+ params[name] = params[name].__name__
+ if params.get('choices') is not None:
+ choices_str = ', '.join([str(c) for c in params['choices']])
+ params['choices'] = choices_str
+ return self._get_help_string(action) % params
+
+ def _iter_indented_subactions(self, action):
+ try:
+ get_subactions = action._get_subactions
+ except AttributeError:
+ pass
+ else:
+ self._indent()
+ for subaction in get_subactions():
+ yield subaction
+ self._dedent()
+
+ def _split_lines(self, text, width):
+ text = self._whitespace_matcher.sub(' ', text).strip()
+ return _textwrap.wrap(text, width)
+
+ def _fill_text(self, text, width, indent):
+ text = self._whitespace_matcher.sub(' ', text).strip()
+ return _textwrap.fill(text, width, initial_indent=indent,
+ subsequent_indent=indent)
+
+ def _get_help_string(self, action):
+ return action.help
+
+
+class RawDescriptionHelpFormatter(HelpFormatter):
+ """Help message formatter which retains any formatting in descriptions.
+
+ Only the name of this class is considered a public API. All the methods
+ provided by the class are considered an implementation detail.
+ """
+
+ def _fill_text(self, text, width, indent):
+ return ''.join([indent + line for line in text.splitlines(True)])
+
+
+class RawTextHelpFormatter(RawDescriptionHelpFormatter):
+ """Help message formatter which retains formatting of all help text.
+
+ Only the name of this class is considered a public API. All the methods
+ provided by the class are considered an implementation detail.
+ """
+
+ def _split_lines(self, text, width):
+ return text.splitlines()
+
+
+class ArgumentDefaultsHelpFormatter(HelpFormatter):
+ """Help message formatter which adds default values to argument help.
+
+ Only the name of this class is considered a public API. All the methods
+ provided by the class are considered an implementation detail.
+ """
+
+ def _get_help_string(self, action):
+ help = action.help
+ if '%(default)' not in action.help:
+ if action.default is not SUPPRESS:
+ defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
+ if action.option_strings or action.nargs in defaulting_nargs:
+ help += ' (default: %(default)s)'
+ return help
+
+
+# =====================
+# Options and Arguments
+# =====================
+
+def _get_action_name(argument):
+ if argument is None:
+ return None
+ elif argument.option_strings:
+ return '/'.join(argument.option_strings)
+ elif argument.metavar not in (None, SUPPRESS):
+ return argument.metavar
+ elif argument.dest not in (None, SUPPRESS):
+ return argument.dest
+ else:
+ return None
+
+
+class ArgumentError(Exception):
+ """An error from creating or using an argument (optional or positional).
+
+ The string value of this exception is the message, augmented with
+ information about the argument that caused it.
+ """
+
+ def __init__(self, argument, message):
+ self.argument_name = _get_action_name(argument)
+ self.message = message
+
+ def __str__(self):
+ if self.argument_name is None:
+ format = '%(message)s'
+ else:
+ format = 'argument %(argument_name)s: %(message)s'
+ return format % dict(message=self.message,
+ argument_name=self.argument_name)
+
+
+class ArgumentTypeError(Exception):
+ """An error from trying to convert a command line string to a type."""
+ pass
+
+
+# ==============
+# Action classes
+# ==============
+
+class Action(_AttributeHolder):
+ """Information about how to convert command line strings to Python objects.
+
+ Action objects are used by an ArgumentParser to represent the information
+ needed to parse a single argument from one or more strings from the
+ command line. The keyword arguments to the Action constructor are also
+ all attributes of Action instances.
+
+ Keyword Arguments:
+
+ - option_strings -- A list of command-line option strings which
+ should be associated with this action.
+
+ - dest -- The name of the attribute to hold the created object(s)
+
+ - nargs -- The number of command-line arguments that should be
+ consumed. By default, one argument will be consumed and a single
+ value will be produced. Other values include:
+ - N (an integer) consumes N arguments (and produces a list)
+ - '?' consumes zero or one arguments
+ - '*' consumes zero or more arguments (and produces a list)
+ - '+' consumes one or more arguments (and produces a list)
+ Note that the difference between the default and nargs=1 is that
+ with the default, a single value will be produced, while with
+ nargs=1, a list containing a single value will be produced.
+
+ - const -- The value to be produced if the option is specified and the
+ option uses an action that takes no values.
+
+ - default -- The value to be produced if the option is not specified.
+
+ - type -- The type which the command-line arguments should be converted
+ to, should be one of 'string', 'int', 'float', 'complex' or a
+ callable object that accepts a single string argument. If None,
+ 'string' is assumed.
+
+ - choices -- A container of values that should be allowed. If not None,
+ after a command-line argument has been converted to the appropriate
+ type, an exception will be raised if it is not a member of this
+ collection.
+
+ - required -- True if the action must always be specified at the
+ command line. This is only meaningful for optional command-line
+ arguments.
+
+ - help -- The help string describing the argument.
+
+ - metavar -- The name to be used for the option's argument with the
+ help string. If None, the 'dest' value will be used as the name.
+ """
+
+ def __init__(self,
+ option_strings,
+ dest,
+ nargs=None,
+ const=None,
+ default=None,
+ type=None,
+ choices=None,
+ required=False,
+ help=None,
+ metavar=None):
+ self.option_strings = option_strings
+ self.dest = dest
+ self.nargs = nargs
+ self.const = const
+ self.default = default
+ self.type = type
+ self.choices = choices
+ self.required = required
+ self.help = help
+ self.metavar = metavar
+
+ def _get_kwargs(self):
+ names = [
+ 'option_strings',
+ 'dest',
+ 'nargs',
+ 'const',
+ 'default',
+ 'type',
+ 'choices',
+ 'help',
+ 'metavar',
+ ]
+ return [(name, getattr(self, name)) for name in names]
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ raise NotImplementedError(_('.__call__() not defined'))
+
+
+class _StoreAction(Action):
+
+ def __init__(self,
+ option_strings,
+ dest,
+ nargs=None,
+ const=None,
+ default=None,
+ type=None,
+ choices=None,
+ required=False,
+ help=None,
+ metavar=None):
+ if nargs == 0:
+ raise ValueError('nargs for store actions must be > 0; if you '
+ 'have nothing to store, actions such as store '
+ 'true or store const may be more appropriate')
+ if const is not None and nargs != OPTIONAL:
+ raise ValueError('nargs must be %r to supply const' % OPTIONAL)
+ super(_StoreAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ nargs=nargs,
+ const=const,
+ default=default,
+ type=type,
+ choices=choices,
+ required=required,
+ help=help,
+ metavar=metavar)
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ setattr(namespace, self.dest, values)
+
+
+class _StoreConstAction(Action):
+
+ def __init__(self,
+ option_strings,
+ dest,
+ const,
+ default=None,
+ required=False,
+ help=None,
+ metavar=None):
+ super(_StoreConstAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ nargs=0,
+ const=const,
+ default=default,
+ required=required,
+ help=help)
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ setattr(namespace, self.dest, self.const)
+
+
+class _StoreTrueAction(_StoreConstAction):
+
+ def __init__(self,
+ option_strings,
+ dest,
+ default=False,
+ required=False,
+ help=None):
+ super(_StoreTrueAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ const=True,
+ default=default,
+ required=required,
+ help=help)
+
+
+class _StoreFalseAction(_StoreConstAction):
+
+ def __init__(self,
+ option_strings,
+ dest,
+ default=True,
+ required=False,
+ help=None):
+ super(_StoreFalseAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ const=False,
+ default=default,
+ required=required,
+ help=help)
+
+
+class _AppendAction(Action):
+
+ def __init__(self,
+ option_strings,
+ dest,
+ nargs=None,
+ const=None,
+ default=None,
+ type=None,
+ choices=None,
+ required=False,
+ help=None,
+ metavar=None):
+ if nargs == 0:
+ raise ValueError('nargs for append actions must be > 0; if arg '
+ 'strings are not supplying the value to append, '
+ 'the append const action may be more appropriate')
+ if const is not None and nargs != OPTIONAL:
+ raise ValueError('nargs must be %r to supply const' % OPTIONAL)
+ super(_AppendAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ nargs=nargs,
+ const=const,
+ default=default,
+ type=type,
+ choices=choices,
+ required=required,
+ help=help,
+ metavar=metavar)
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ items = _copy.copy(_ensure_value(namespace, self.dest, []))
+ items.append(values)
+ setattr(namespace, self.dest, items)
+
+
+class _AppendConstAction(Action):
+
+ def __init__(self,
+ option_strings,
+ dest,
+ const,
+ default=None,
+ required=False,
+ help=None,
+ metavar=None):
+ super(_AppendConstAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ nargs=0,
+ const=const,
+ default=default,
+ required=required,
+ help=help,
+ metavar=metavar)
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ items = _copy.copy(_ensure_value(namespace, self.dest, []))
+ items.append(self.const)
+ setattr(namespace, self.dest, items)
+
+
+class _CountAction(Action):
+
+ def __init__(self,
+ option_strings,
+ dest,
+ default=None,
+ required=False,
+ help=None):
+ super(_CountAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ nargs=0,
+ default=default,
+ required=required,
+ help=help)
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ new_count = _ensure_value(namespace, self.dest, 0) + 1
+ setattr(namespace, self.dest, new_count)
+
+
+class _HelpAction(Action):
+
+ def __init__(self,
+ option_strings,
+ dest=SUPPRESS,
+ default=SUPPRESS,
+ help=None):
+ super(_HelpAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ default=default,
+ nargs=0,
+ help=help)
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ parser.print_help()
+ parser.exit()
+
+
+class _VersionAction(Action):
+
+ def __init__(self,
+ option_strings,
+ version=None,
+ dest=SUPPRESS,
+ default=SUPPRESS,
+ help="show program's version number and exit"):
+ super(_VersionAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ default=default,
+ nargs=0,
+ help=help)
+ self.version = version
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ version = self.version
+ if version is None:
+ version = parser.version
+ formatter = parser._get_formatter()
+ formatter.add_text(version)
+ parser.exit(message=formatter.format_help())
+
+
+class _SubParsersAction(Action):
+
+ class _ChoicesPseudoAction(Action):
+
+ def __init__(self, name, aliases, help):
+ metavar = dest = name
+ if aliases:
+ metavar += ' (%s)' % ', '.join(aliases)
+ sup = super(_SubParsersAction._ChoicesPseudoAction, self)
+ sup.__init__(option_strings=[], dest=dest, help=help,
+ metavar=metavar)
+
+ def __init__(self,
+ option_strings,
+ prog,
+ parser_class,
+ dest=SUPPRESS,
+ help=None,
+ metavar=None):
+
+ self._prog_prefix = prog
+ self._parser_class = parser_class
+ self._name_parser_map = {}
+ self._choices_actions = []
+
+ super(_SubParsersAction, self).__init__(
+ option_strings=option_strings,
+ dest=dest,
+ nargs=PARSER,
+ choices=self._name_parser_map,
+ help=help,
+ metavar=metavar)
+
+ def add_parser(self, name, **kwargs):
+ # set prog from the existing prefix
+ if kwargs.get('prog') is None:
+ kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
+
+ aliases = kwargs.pop('aliases', ())
+
+ # create a pseudo-action to hold the choice help
+ if 'help' in kwargs:
+ help = kwargs.pop('help')
+ choice_action = self._ChoicesPseudoAction(name, aliases, help)
+ self._choices_actions.append(choice_action)
+
+ # create the parser and add it to the map
+ parser = self._parser_class(**kwargs)
+ self._name_parser_map[name] = parser
+
+ # make parser available under aliases also
+ for alias in aliases:
+ self._name_parser_map[alias] = parser
+
+ return parser
+
+ def _get_subactions(self):
+ return self._choices_actions
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ parser_name = values[0]
+ arg_strings = values[1:]
+
+ # set the parser name if requested
+ if self.dest is not SUPPRESS:
+ setattr(namespace, self.dest, parser_name)
+
+ # select the parser
+ try:
+ parser = self._name_parser_map[parser_name]
+ except KeyError:
+ args = {'parser_name': parser_name,
+ 'choices': ', '.join(self._name_parser_map)}
+ msg = _('unknown parser %(parser_name)r (choices: %(choices)s)') % args
+ raise ArgumentError(self, msg)
+
+ # parse all the remaining options into the namespace
+ # store any unrecognized options on the object, so that the top
+ # level parser can decide what to do with them
+ namespace, arg_strings = parser.parse_known_args(arg_strings, namespace)
+ if arg_strings:
+ vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, [])
+ getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)
+
+
+# ==============
+# Type classes
+# ==============
+
+class FileType(object):
+ """Factory for creating file object types
+
+ Instances of FileType are typically passed as type= arguments to the
+ ArgumentParser add_argument() method.
+
+ Keyword Arguments:
+ - mode -- A string indicating how the file is to be opened. Accepts the
+ same values as the builtin open() function.
+ - bufsize -- The file's desired buffer size. Accepts the same values as
+ the builtin open() function.
+ """
+
+ def __init__(self, mode='r', bufsize=-1):
+ self._mode = mode
+ self._bufsize = bufsize
+
+ def __call__(self, string):
+ # the special argument "-" means sys.std{in,out}
+ if string == '-':
+ if 'r' in self._mode:
+ return _sys.stdin
+ elif 'w' in self._mode:
+ return _sys.stdout
+ else:
+ msg = _('argument "-" with mode %r') % self._mode
+ raise ValueError(msg)
+
+ # all other arguments are used as file names
+ try:
+ return open(string, self._mode, self._bufsize)
+ except IOError as e:
+ message = _("can't open '%s': %s")
+ raise ArgumentTypeError(message % (string, e))
+
+ def __repr__(self):
+ args = self._mode, self._bufsize
+ args_str = ', '.join(repr(arg) for arg in args if arg != -1)
+ return '%s(%s)' % (type(self).__name__, args_str)
+
+# ===========================
+# Optional and Positional Parsing
+# ===========================
+
+class Namespace(_AttributeHolder):
+ """Simple object for storing attributes.
+
+ Implements equality by attribute names and values, and provides a simple
+ string representation.
+ """
+
+ def __init__(self, **kwargs):
+ for name in kwargs:
+ setattr(self, name, kwargs[name])
+
+ def __eq__(self, other):
+ return vars(self) == vars(other)
+
+ def __ne__(self, other):
+ return not (self == other)
+
+ def __contains__(self, key):
+ return key in self.__dict__
+
+
+class _ActionsContainer(object):
+
+ def __init__(self,
+ description,
+ prefix_chars,
+ argument_default,
+ conflict_handler):
+ super(_ActionsContainer, self).__init__()
+
+ self.description = description
+ self.argument_default = argument_default
+ self.prefix_chars = prefix_chars
+ self.conflict_handler = conflict_handler
+
+ # set up registries
+ self._registries = {}
+
+ # register actions
+ self.register('action', None, _StoreAction)
+ self.register('action', 'store', _StoreAction)
+ self.register('action', 'store_const', _StoreConstAction)
+ self.register('action', 'store_true', _StoreTrueAction)
+ self.register('action', 'store_false', _StoreFalseAction)
+ self.register('action', 'append', _AppendAction)
+ self.register('action', 'append_const', _AppendConstAction)
+ self.register('action', 'count', _CountAction)
+ self.register('action', 'help', _HelpAction)
+ self.register('action', 'version', _VersionAction)
+ self.register('action', 'parsers', _SubParsersAction)
+
+ # raise an exception if the conflict handler is invalid
+ self._get_handler()
+
+ # action storage
+ self._actions = []
+ self._option_string_actions = {}
+
+ # groups
+ self._action_groups = []
+ self._mutually_exclusive_groups = []
+
+ # defaults storage
+ self._defaults = {}
+
+ # determines whether an "option" looks like a negative number
+ self._negative_number_matcher = _re.compile(r'^-\d+$|^-\d*\.\d+$')
+
+ # whether or not there are any optionals that look like negative
+ # numbers -- uses a list so it can be shared and edited
+ self._has_negative_number_optionals = []
+
+ # ====================
+ # Registration methods
+ # ====================
+ def register(self, registry_name, value, object):
+ registry = self._registries.setdefault(registry_name, {})
+ registry[value] = object
+
+ def _registry_get(self, registry_name, value, default=None):
+ return self._registries[registry_name].get(value, default)
+
+ # ==================================
+ # Namespace default accessor methods
+ # ==================================
+ def set_defaults(self, **kwargs):
+ self._defaults.update(kwargs)
+
+ # if these defaults match any existing arguments, replace
+ # the previous default on the object with the new one
+ for action in self._actions:
+ if action.dest in kwargs:
+ action.default = kwargs[action.dest]
+
+ def get_default(self, dest):
+ for action in self._actions:
+ if action.dest == dest and action.default is not None:
+ return action.default
+ return self._defaults.get(dest, None)
+
+
+ # =======================
+ # Adding argument actions
+ # =======================
+ def add_argument(self, *args, **kwargs):
+ """
+ add_argument(dest, ..., name=value, ...)
+ add_argument(option_string, option_string, ..., name=value, ...)
+ """
+
+ # if no positional args are supplied or only one is supplied and
+ # it doesn't look like an option string, parse a positional
+ # argument
+ chars = self.prefix_chars
+ if not args or len(args) == 1 and args[0][0] not in chars:
+ if args and 'dest' in kwargs:
+ raise ValueError('dest supplied twice for positional argument')
+ kwargs = self._get_positional_kwargs(*args, **kwargs)
+
+ # otherwise, we're adding an optional argument
+ else:
+ kwargs = self._get_optional_kwargs(*args, **kwargs)
+
+ # if no default was supplied, use the parser-level default
+ if 'default' not in kwargs:
+ dest = kwargs['dest']
+ if dest in self._defaults:
+ kwargs['default'] = self._defaults[dest]
+ elif self.argument_default is not None:
+ kwargs['default'] = self.argument_default
+
+ # create the action object, and add it to the parser
+ action_class = self._pop_action_class(kwargs)
+ if not _callable(action_class):
+ raise ValueError('unknown action "%s"' % action_class)
+ action = action_class(**kwargs)
+
+ # raise an error if the action type is not callable
+ type_func = self._registry_get('type', action.type, action.type)
+ if not _callable(type_func):
+ raise ValueError('%r is not callable' % type_func)
+
+ return self._add_action(action)
+
+ def add_argument_group(self, *args, **kwargs):
+ group = _ArgumentGroup(self, *args, **kwargs)
+ self._action_groups.append(group)
+ return group
+
+ def add_mutually_exclusive_group(self, **kwargs):
+ group = _MutuallyExclusiveGroup(self, **kwargs)
+ self._mutually_exclusive_groups.append(group)
+ return group
+
+ def _add_action(self, action):
+ # resolve any conflicts
+ self._check_conflict(action)
+
+ # add to actions list
+ self._actions.append(action)
+ action.container = self
+
+ # index the action by any option strings it has
+ for option_string in action.option_strings:
+ self._option_string_actions[option_string] = action
+
+ # set the flag if any option strings look like negative numbers
+ for option_string in action.option_strings:
+ if self._negative_number_matcher.match(option_string):
+ if not self._has_negative_number_optionals:
+ self._has_negative_number_optionals.append(True)
+
+ # return the created action
+ return action
+
+ def _remove_action(self, action):
+ self._actions.remove(action)
+
+ def _add_container_actions(self, container):
+ # collect groups by titles
+ title_group_map = {}
+ for group in self._action_groups:
+ if group.title in title_group_map:
+ msg = _('cannot merge actions - two groups are named %r')
+ raise ValueError(msg % (group.title))
+ title_group_map[group.title] = group
+
+ # map each action to its group
+ group_map = {}
+ for group in container._action_groups:
+
+ # if a group with the title exists, use that, otherwise
+ # create a new group matching the container's group
+ if group.title not in title_group_map:
+ title_group_map[group.title] = self.add_argument_group(
+ title=group.title,
+ description=group.description,
+ conflict_handler=group.conflict_handler)
+
+ # map the actions to their new group
+ for action in group._group_actions:
+ group_map[action] = title_group_map[group.title]
+
+ # add container's mutually exclusive groups
+ # NOTE: if add_mutually_exclusive_group ever gains title= and
+ # description= then this code will need to be expanded as above
+ for group in container._mutually_exclusive_groups:
+ mutex_group = self.add_mutually_exclusive_group(
+ required=group.required)
+
+ # map the actions to their new mutex group
+ for action in group._group_actions:
+ group_map[action] = mutex_group
+
+ # add all actions to this container or their group
+ for action in container._actions:
+ group_map.get(action, self)._add_action(action)
+
+ def _get_positional_kwargs(self, dest, **kwargs):
+ # make sure required is not specified
+ if 'required' in kwargs:
+ msg = _("'required' is an invalid argument for positionals")
+ raise TypeError(msg)
+
+ # mark positional arguments as required if at least one is
+ # always required
+ if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE]:
+ kwargs['required'] = True
+ if kwargs.get('nargs') == ZERO_OR_MORE and 'default' not in kwargs:
+ kwargs['required'] = True
+
+ # return the keyword arguments with no option strings
+ return dict(kwargs, dest=dest, option_strings=[])
+
+ def _get_optional_kwargs(self, *args, **kwargs):
+ # determine short and long option strings
+ option_strings = []
+ long_option_strings = []
+ for option_string in args:
+ # error on strings that don't start with an appropriate prefix
+ if not option_string[0] in self.prefix_chars:
+ args = {'option': option_string,
+ 'prefix_chars': self.prefix_chars}
+ msg = _('invalid option string %(option)r: '
+ 'must start with a character %(prefix_chars)r')
+ raise ValueError(msg % args)
+
+ # strings starting with two prefix characters are long options
+ option_strings.append(option_string)
+ if option_string[0] in self.prefix_chars:
+ if len(option_string) > 1:
+ if option_string[1] in self.prefix_chars:
+ long_option_strings.append(option_string)
+
+ # infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
+ dest = kwargs.pop('dest', None)
+ if dest is None:
+ if long_option_strings:
+ dest_option_string = long_option_strings[0]
+ else:
+ dest_option_string = option_strings[0]
+ dest = dest_option_string.lstrip(self.prefix_chars)
+ if not dest:
+ msg = _('dest= is required for options like %r')
+ raise ValueError(msg % option_string)
+ dest = dest.replace('-', '_')
+
+ # return the updated keyword arguments
+ return dict(kwargs, dest=dest, option_strings=option_strings)
+
+ def _pop_action_class(self, kwargs, default=None):
+ action = kwargs.pop('action', default)
+ return self._registry_get('action', action, action)
+
+ def _get_handler(self):
+ # determine function from conflict handler string
+ handler_func_name = '_handle_conflict_%s' % self.conflict_handler
+ try:
+ return getattr(self, handler_func_name)
+ except AttributeError:
+ msg = _('invalid conflict_resolution value: %r')
+ raise ValueError(msg % self.conflict_handler)
+
+ def _check_conflict(self, action):
+
+ # find all options that conflict with this option
+ confl_optionals = []
+ for option_string in action.option_strings:
+ if option_string in self._option_string_actions:
+ confl_optional = self._option_string_actions[option_string]
+ confl_optionals.append((option_string, confl_optional))
+
+ # resolve any conflicts
+ if confl_optionals:
+ conflict_handler = self._get_handler()
+ conflict_handler(action, confl_optionals)
+
+ def _handle_conflict_error(self, action, conflicting_actions):
+ message = ngettext('conflicting option string: %s',
+ 'conflicting option strings: %s',
+ len(conflicting_actions))
+ conflict_string = ', '.join([option_string
+ for option_string, action
+ in conflicting_actions])
+ raise ArgumentError(action, message % conflict_string)
+
+ def _handle_conflict_resolve(self, action, conflicting_actions):
+
+ # remove all conflicting options
+ for option_string, action in conflicting_actions:
+
+ # remove the conflicting option
+ action.option_strings.remove(option_string)
+ self._option_string_actions.pop(option_string, None)
+
+ # if the option now has no option string, remove it from the
+ # container holding it
+ if not action.option_strings:
+ action.container._remove_action(action)
+
+
+class _ArgumentGroup(_ActionsContainer):
+
+ def __init__(self, container, title=None, description=None, **kwargs):
+ # add any missing keyword arguments by checking the container
+ update = kwargs.setdefault
+ update('conflict_handler', container.conflict_handler)
+ update('prefix_chars', container.prefix_chars)
+ update('argument_default', container.argument_default)
+ super_init = super(_ArgumentGroup, self).__init__
+ super_init(description=description, **kwargs)
+
+ # group attributes
+ self.title = title
+ self._group_actions = []
+
+ # share most attributes with the container
+ self._registries = container._registries
+ self._actions = container._actions
+ self._option_string_actions = container._option_string_actions
+ self._defaults = container._defaults
+ self._has_negative_number_optionals = \
+ container._has_negative_number_optionals
+ self._mutually_exclusive_groups = container._mutually_exclusive_groups
+
+ def _add_action(self, action):
+ action = super(_ArgumentGroup, self)._add_action(action)
+ self._group_actions.append(action)
+ return action
+
+ def _remove_action(self, action):
+ super(_ArgumentGroup, self)._remove_action(action)
+ self._group_actions.remove(action)
+
+
+class _MutuallyExclusiveGroup(_ArgumentGroup):
+
+ def __init__(self, container, required=False):
+ super(_MutuallyExclusiveGroup, self).__init__(container)
+ self.required = required
+ self._container = container
+
+ def _add_action(self, action):
+ if action.required:
+ msg = _('mutually exclusive arguments must be optional')
+ raise ValueError(msg)
+ action = self._container._add_action(action)
+ self._group_actions.append(action)
+ return action
+
+ def _remove_action(self, action):
+ self._container._remove_action(action)
+ self._group_actions.remove(action)
+
+
+class ArgumentParser(_AttributeHolder, _ActionsContainer):
+ """Object for parsing command line strings into Python objects.
+
+ Keyword Arguments:
+ - prog -- The name of the program (default: sys.argv[0])
+ - usage -- A usage message (default: auto-generated from arguments)
+ - description -- A description of what the program does
+ - epilog -- Text following the argument descriptions
+ - parents -- Parsers whose arguments should be copied into this one
+ - formatter_class -- HelpFormatter class for printing help messages
+ - prefix_chars -- Characters that prefix optional arguments
+ - fromfile_prefix_chars -- Characters that prefix files containing
+ additional arguments
+ - argument_default -- The default value for all arguments
+ - conflict_handler -- String indicating how to handle conflicts
+ - add_help -- Add a -h/-help option
+ """
+
+ def __init__(self,
+ prog=None,
+ usage=None,
+ description=None,
+ epilog=None,
+ version=None,
+ parents=[],
+ formatter_class=HelpFormatter,
+ prefix_chars='-',
+ fromfile_prefix_chars=None,
+ argument_default=None,
+ conflict_handler='error',
+ add_help=True):
+
+ if version is not None:
+ import warnings
+ warnings.warn(
+ """The "version" argument to ArgumentParser is deprecated. """
+ """Please use """
+ """"add_argument(..., action='version', version="N", ...)" """
+ """instead""", DeprecationWarning)
+
+ superinit = super(ArgumentParser, self).__init__
+ superinit(description=description,
+ prefix_chars=prefix_chars,
+ argument_default=argument_default,
+ conflict_handler=conflict_handler)
+
+ # default setting for prog
+ if prog is None:
+ prog = _os.path.basename(_sys.argv[0])
+
+ self.prog = prog
+ self.usage = usage
+ self.epilog = epilog
+ self.version = version
+ self.formatter_class = formatter_class
+ self.fromfile_prefix_chars = fromfile_prefix_chars
+ self.add_help = add_help
+
+ add_group = self.add_argument_group
+ self._positionals = add_group(_('positional arguments'))
+ self._optionals = add_group(_('optional arguments'))
+ self._subparsers = None
+
+ # register types
+ def identity(string):
+ return string
+ self.register('type', None, identity)
+
+ # add help and version arguments if necessary
+ # (using explicit default to override global argument_default)
+ default_prefix = '-' if '-' in prefix_chars else prefix_chars[0]
+ if self.add_help:
+ self.add_argument(
+ default_prefix+'h', default_prefix*2+'help',
+ action='help', default=SUPPRESS,
+ help=_('show this help message and exit'))
+ if self.version:
+ self.add_argument(
+ default_prefix+'v', default_prefix*2+'version',
+ action='version', default=SUPPRESS,
+ version=self.version,
+ help=_("show program's version number and exit"))
+
+ # add parent arguments and defaults
+ for parent in parents:
+ self._add_container_actions(parent)
+ try:
+ defaults = parent._defaults
+ except AttributeError:
+ pass
+ else:
+ self._defaults.update(defaults)
+
+ # =======================
+ # Pretty __repr__ methods
+ # =======================
+ def _get_kwargs(self):
+ names = [
+ 'prog',
+ 'usage',
+ 'description',
+ 'version',
+ 'formatter_class',
+ 'conflict_handler',
+ 'add_help',
+ ]
+ return [(name, getattr(self, name)) for name in names]
+
+ # ==================================
+ # Optional/Positional adding methods
+ # ==================================
+ def add_subparsers(self, **kwargs):
+ if self._subparsers is not None:
+ self.error(_('cannot have multiple subparser arguments'))
+
+ # add the parser class to the arguments if it's not present
+ kwargs.setdefault('parser_class', type(self))
+
+ if 'title' in kwargs or 'description' in kwargs:
+ title = _(kwargs.pop('title', 'subcommands'))
+ description = _(kwargs.pop('description', None))
+ self._subparsers = self.add_argument_group(title, description)
+ else:
+ self._subparsers = self._positionals
+
+ # prog defaults to the usage message of this parser, skipping
+ # optional arguments and with no "usage:" prefix
+ if kwargs.get('prog') is None:
+ formatter = self._get_formatter()
+ positionals = self._get_positional_actions()
+ groups = self._mutually_exclusive_groups
+ formatter.add_usage(self.usage, positionals, groups, '')
+ kwargs['prog'] = formatter.format_help().strip()
+
+ # create the parsers action and add it to the positionals list
+ parsers_class = self._pop_action_class(kwargs, 'parsers')
+ action = parsers_class(option_strings=[], **kwargs)
+ self._subparsers._add_action(action)
+
+ # return the created parsers action
+ return action
+
+ def _add_action(self, action):
+ if action.option_strings:
+ self._optionals._add_action(action)
+ else:
+ self._positionals._add_action(action)
+ return action
+
+ def _get_optional_actions(self):
+ return [action
+ for action in self._actions
+ if action.option_strings]
+
+ def _get_positional_actions(self):
+ return [action
+ for action in self._actions
+ if not action.option_strings]
+
+ # =====================================
+ # Command line argument parsing methods
+ # =====================================
+ def parse_args(self, args=None, namespace=None):
+ args, argv = self.parse_known_args(args, namespace)
+ if argv:
+ msg = _('unrecognized arguments: %s')
+ self.error(msg % ' '.join(argv))
+ return args
+
+ def parse_known_args(self, args=None, namespace=None):
+ # args default to the system args
+ if args is None:
+ args = _sys.argv[1:]
+
+ # default Namespace built from parser defaults
+ if namespace is None:
+ namespace = Namespace()
+
+ # add any action defaults that aren't present
+ for action in self._actions:
+ if action.dest is not SUPPRESS:
+ if not hasattr(namespace, action.dest):
+ if action.default is not SUPPRESS:
+ default = action.default
+ if isinstance(action.default, str):
+ default = self._get_value(action, default)
+ setattr(namespace, action.dest, default)
+
+ # add any parser defaults that aren't present
+ for dest in self._defaults:
+ if not hasattr(namespace, dest):
+ setattr(namespace, dest, self._defaults[dest])
+
+ # parse the arguments and exit if there are any errors
+ try:
+ namespace, args = self._parse_known_args(args, namespace)
+ if hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):
+ args.extend(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR))
+ delattr(namespace, _UNRECOGNIZED_ARGS_ATTR)
+ return namespace, args
+ except ArgumentError:
+ err = _sys.exc_info()[1]
+ self.error(str(err))
+
+ def _parse_known_args(self, arg_strings, namespace):
+ # replace arg strings that are file references
+ if self.fromfile_prefix_chars is not None:
+ arg_strings = self._read_args_from_files(arg_strings)
+
+ # map all mutually exclusive arguments to the other arguments
+ # they can't occur with
+ action_conflicts = {}
+ for mutex_group in self._mutually_exclusive_groups:
+ group_actions = mutex_group._group_actions
+ for i, mutex_action in enumerate(mutex_group._group_actions):
+ conflicts = action_conflicts.setdefault(mutex_action, [])
+ conflicts.extend(group_actions[:i])
+ conflicts.extend(group_actions[i + 1:])
+
+ # find all option indices, and determine the arg_string_pattern
+ # which has an 'O' if there is an option at an index,
+ # an 'A' if there is an argument, or a '-' if there is a '--'
+ option_string_indices = {}
+ arg_string_pattern_parts = []
+ arg_strings_iter = iter(arg_strings)
+ for i, arg_string in enumerate(arg_strings_iter):
+
+ # all args after -- are non-options
+ if arg_string == '--':
+ arg_string_pattern_parts.append('-')
+ for arg_string in arg_strings_iter:
+ arg_string_pattern_parts.append('A')
+
+ # otherwise, add the arg to the arg strings
+ # and note the index if it was an option
+ else:
+ option_tuple = self._parse_optional(arg_string)
+ if option_tuple is None:
+ pattern = 'A'
+ else:
+ option_string_indices[i] = option_tuple
+ pattern = 'O'
+ arg_string_pattern_parts.append(pattern)
+
+ # join the pieces together to form the pattern
+ arg_strings_pattern = ''.join(arg_string_pattern_parts)
+
+ # converts arg strings to the appropriate and then takes the action
+ seen_actions = set()
+ seen_non_default_actions = set()
+
+ def take_action(action, argument_strings, option_string=None):
+ seen_actions.add(action)
+ argument_values = self._get_values(action, argument_strings)
+
+ # error if this argument is not allowed with other previously
+ # seen arguments, assuming that actions that use the default
+ # value don't really count as "present"
+ if argument_values is not action.default:
+ seen_non_default_actions.add(action)
+ for conflict_action in action_conflicts.get(action, []):
+ if conflict_action in seen_non_default_actions:
+ msg = _('not allowed with argument %s')
+ action_name = _get_action_name(conflict_action)
+ raise ArgumentError(action, msg % action_name)
+
+ # take the action if we didn't receive a SUPPRESS value
+ # (e.g. from a default)
+ if argument_values is not SUPPRESS:
+ action(self, namespace, argument_values, option_string)
+
+ # function to convert arg_strings into an optional action
+ def consume_optional(start_index):
+
+ # get the optional identified at this index
+ option_tuple = option_string_indices[start_index]
+ action, option_string, explicit_arg = option_tuple
+
+ # identify additional optionals in the same arg string
+ # (e.g. -xyz is the same as -x -y -z if no args are required)
+ match_argument = self._match_argument
+ action_tuples = []
+ while True:
+
+ # if we found no optional action, skip it
+ if action is None:
+ extras.append(arg_strings[start_index])
+ return start_index + 1
+
+ # if there is an explicit argument, try to match the
+ # optional's string arguments to only this
+ if explicit_arg is not None:
+ arg_count = match_argument(action, 'A')
+
+ # if the action is a single-dash option and takes no
+ # arguments, try to parse more single-dash options out
+ # of the tail of the option string
+ chars = self.prefix_chars
+ if arg_count == 0 and option_string[1] not in chars:
+ action_tuples.append((action, [], option_string))
+ char = option_string[0]
+ option_string = char + explicit_arg[0]
+ new_explicit_arg = explicit_arg[1:] or None
+ optionals_map = self._option_string_actions
+ if option_string in optionals_map:
+ action = optionals_map[option_string]
+ explicit_arg = new_explicit_arg
+ else:
+ msg = _('ignored explicit argument %r')
+ raise ArgumentError(action, msg % explicit_arg)
+
+ # if the action expect exactly one argument, we've
+ # successfully matched the option; exit the loop
+ elif arg_count == 1:
+ stop = start_index + 1
+ args = [explicit_arg]
+ action_tuples.append((action, args, option_string))
+ break
+
+ # error if a double-dash option did not use the
+ # explicit argument
+ else:
+ msg = _('ignored explicit argument %r')
+ raise ArgumentError(action, msg % explicit_arg)
+
+ # if there is no explicit argument, try to match the
+ # optional's string arguments with the following strings
+ # if successful, exit the loop
+ else:
+ start = start_index + 1
+ selected_patterns = arg_strings_pattern[start:]
+ arg_count = match_argument(action, selected_patterns)
+ stop = start + arg_count
+ args = arg_strings[start:stop]
+ action_tuples.append((action, args, option_string))
+ break
+
+ # add the Optional to the list and return the index at which
+ # the Optional's string args stopped
+ assert action_tuples
+ for action, args, option_string in action_tuples:
+ take_action(action, args, option_string)
+ return stop
+
+ # the list of Positionals left to be parsed; this is modified
+ # by consume_positionals()
+ positionals = self._get_positional_actions()
+
+ # function to convert arg_strings into positional actions
+ def consume_positionals(start_index):
+ # match as many Positionals as possible
+ match_partial = self._match_arguments_partial
+ selected_pattern = arg_strings_pattern[start_index:]
+ arg_counts = match_partial(positionals, selected_pattern)
+
+ # slice off the appropriate arg strings for each Positional
+ # and add the Positional and its args to the list
+ for action, arg_count in zip(positionals, arg_counts):
+ args = arg_strings[start_index: start_index + arg_count]
+ start_index += arg_count
+ take_action(action, args)
+
+ # slice off the Positionals that we just parsed and return the
+ # index at which the Positionals' string args stopped
+ positionals[:] = positionals[len(arg_counts):]
+ return start_index
+
+ # consume Positionals and Optionals alternately, until we have
+ # passed the last option string
+ extras = []
+ start_index = 0
+ if option_string_indices:
+ max_option_string_index = max(option_string_indices)
+ else:
+ max_option_string_index = -1
+ while start_index <= max_option_string_index:
+
+ # consume any Positionals preceding the next option
+ next_option_string_index = min([
+ index
+ for index in option_string_indices
+ if index >= start_index])
+ if start_index != next_option_string_index:
+ positionals_end_index = consume_positionals(start_index)
+
+ # only try to parse the next optional if we didn't consume
+ # the option string during the positionals parsing
+ if positionals_end_index > start_index:
+ start_index = positionals_end_index
+ continue
+ else:
+ start_index = positionals_end_index
+
+ # if we consumed all the positionals we could and we're not
+ # at the index of an option string, there were extra arguments
+ if start_index not in option_string_indices:
+ strings = arg_strings[start_index:next_option_string_index]
+ extras.extend(strings)
+ start_index = next_option_string_index
+
+ # consume the next optional and any arguments for it
+ start_index = consume_optional(start_index)
+
+ # consume any positionals following the last Optional
+ stop_index = consume_positionals(start_index)
+
+ # if we didn't consume all the argument strings, there were extras
+ extras.extend(arg_strings[stop_index:])
+
+ # if we didn't use all the Positional objects, there were too few
+ # arg strings supplied.
+ if positionals:
+ self.error(_('too few arguments'))
+
+ # make sure all required actions were present
+ for action in self._actions:
+ if action.required:
+ if action not in seen_actions:
+ name = _get_action_name(action)
+ self.error(_('argument %s is required') % name)
+
+ # make sure all required groups had one option present
+ for group in self._mutually_exclusive_groups:
+ if group.required:
+ for action in group._group_actions:
+ if action in seen_non_default_actions:
+ break
+
+ # if no actions were used, report the error
+ else:
+ names = [_get_action_name(action)
+ for action in group._group_actions
+ if action.help is not SUPPRESS]
+ msg = _('one of the arguments %s is required')
+ self.error(msg % ' '.join(names))
+
+ # return the updated namespace and the extra arguments
+ return namespace, extras
+
+ def _read_args_from_files(self, arg_strings):
+ # expand arguments referencing files
+ new_arg_strings = []
+ for arg_string in arg_strings:
+
+ # for regular arguments, just add them back into the list
+ if arg_string[0] not in self.fromfile_prefix_chars:
+ new_arg_strings.append(arg_string)
+
+ # replace arguments referencing files with the file content
+ else:
+ try:
+ args_file = open(arg_string[1:])
+ try:
+ arg_strings = []
+ for arg_line in args_file.read().splitlines():
+ for arg in self.convert_arg_line_to_args(arg_line):
+ arg_strings.append(arg)
+ arg_strings = self._read_args_from_files(arg_strings)
+ new_arg_strings.extend(arg_strings)
+ finally:
+ args_file.close()
+ except IOError:
+ err = _sys.exc_info()[1]
+ self.error(str(err))
+
+ # return the modified argument list
+ return new_arg_strings
+
+ def convert_arg_line_to_args(self, arg_line):
+ return [arg_line]
+
+ def _match_argument(self, action, arg_strings_pattern):
+ # match the pattern for this action to the arg strings
+ nargs_pattern = self._get_nargs_pattern(action)
+ match = _re.match(nargs_pattern, arg_strings_pattern)
+
+ # raise an exception if we weren't able to find a match
+ if match is None:
+ nargs_errors = {
+ None: _('expected one argument'),
+ OPTIONAL: _('expected at most one argument'),
+ ONE_OR_MORE: _('expected at least one argument'),
+ }
+ default = ngettext('expected %s argument',
+ 'expected %s arguments',
+ action.nargs) % action.nargs
+ msg = nargs_errors.get(action.nargs, default)
+ raise ArgumentError(action, msg)
+
+ # return the number of arguments matched
+ return len(match.group(1))
+
+ def _match_arguments_partial(self, actions, arg_strings_pattern):
+ # progressively shorten the actions list by slicing off the
+ # final actions until we find a match
+ result = []
+ for i in range(len(actions), 0, -1):
+ actions_slice = actions[:i]
+ pattern = ''.join([self._get_nargs_pattern(action)
+ for action in actions_slice])
+ match = _re.match(pattern, arg_strings_pattern)
+ if match is not None:
+ result.extend([len(string) for string in match.groups()])
+ break
+
+ # return the list of arg string counts
+ return result
+
+ def _parse_optional(self, arg_string):
+ # if it's an empty string, it was meant to be a positional
+ if not arg_string:
+ return None
+
+ # if it doesn't start with a prefix, it was meant to be positional
+ if not arg_string[0] in self.prefix_chars:
+ return None
+
+ # if the option string is present in the parser, return the action
+ if arg_string in self._option_string_actions:
+ action = self._option_string_actions[arg_string]
+ return action, arg_string, None
+
+ # if it's just a single character, it was meant to be positional
+ if len(arg_string) == 1:
+ return None
+
+ # if the option string before the "=" is present, return the action
+ if '=' in arg_string:
+ option_string, explicit_arg = arg_string.split('=', 1)
+ if option_string in self._option_string_actions:
+ action = self._option_string_actions[option_string]
+ return action, option_string, explicit_arg
+
+ # search through all possible prefixes of the option string
+ # and all actions in the parser for possible interpretations
+ option_tuples = self._get_option_tuples(arg_string)
+
+ # if multiple actions match, the option string was ambiguous
+ if len(option_tuples) > 1:
+ options = ', '.join([option_string
+ for action, option_string, explicit_arg in option_tuples])
+ args = {'option': arg_string, 'matches': options}
+ msg = _('ambiguous option: %(option)s could match %(matches)s')
+ self.error(msg % args)
+
+ # if exactly one action matched, this segmentation is good,
+ # so return the parsed action
+ elif len(option_tuples) == 1:
+ option_tuple, = option_tuples
+ return option_tuple
+
+ # if it was not found as an option, but it looks like a negative
+ # number, it was meant to be positional
+ # unless there are negative-number-like options
+ if self._negative_number_matcher.match(arg_string):
+ if not self._has_negative_number_optionals:
+ return None
+
+ # if it contains a space, it was meant to be a positional
+ if ' ' in arg_string:
+ return None
+
+ # it was meant to be an optional but there is no such option
+ # in this parser (though it might be a valid option in a subparser)
+ return None, arg_string, None
+
+ def _get_option_tuples(self, option_string):
+ result = []
+
+ # option strings starting with two prefix characters are only
+ # split at the '='
+ chars = self.prefix_chars
+ if option_string[0] in chars and option_string[1] in chars:
+ if '=' in option_string:
+ option_prefix, explicit_arg = option_string.split('=', 1)
+ else:
+ option_prefix = option_string
+ explicit_arg = None
+ for option_string in self._option_string_actions:
+ if option_string.startswith(option_prefix):
+ action = self._option_string_actions[option_string]
+ tup = action, option_string, explicit_arg
+ result.append(tup)
+
+ # single character options can be concatenated with their arguments
+ # but multiple character options always have to have their argument
+ # separate
+ elif option_string[0] in chars and option_string[1] not in chars:
+ option_prefix = option_string
+ explicit_arg = None
+ short_option_prefix = option_string[:2]
+ short_explicit_arg = option_string[2:]
+
+ for option_string in self._option_string_actions:
+ if option_string == short_option_prefix:
+ action = self._option_string_actions[option_string]
+ tup = action, option_string, short_explicit_arg
+ result.append(tup)
+ elif option_string.startswith(option_prefix):
+ action = self._option_string_actions[option_string]
+ tup = action, option_string, explicit_arg
+ result.append(tup)
+
+ # shouldn't ever get here
+ else:
+ self.error(_('unexpected option string: %s') % option_string)
+
+ # return the collected option tuples
+ return result
+
+ def _get_nargs_pattern(self, action):
+ # in all examples below, we have to allow for '--' args
+ # which are represented as '-' in the pattern
+ nargs = action.nargs
+
+ # the default (None) is assumed to be a single argument
+ if nargs is None:
+ nargs_pattern = '(-*A-*)'
+
+ # allow zero or one arguments
+ elif nargs == OPTIONAL:
+ nargs_pattern = '(-*A?-*)'
+
+ # allow zero or more arguments
+ elif nargs == ZERO_OR_MORE:
+ nargs_pattern = '(-*[A-]*)'
+
+ # allow one or more arguments
+ elif nargs == ONE_OR_MORE:
+ nargs_pattern = '(-*A[A-]*)'
+
+ # allow any number of options or arguments
+ elif nargs == REMAINDER:
+ nargs_pattern = '([-AO]*)'
+
+ # allow one argument followed by any number of options or arguments
+ elif nargs == PARSER:
+ nargs_pattern = '(-*A[-AO]*)'
+
+ # all others should be integers
+ else:
+ nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)
+
+ # if this is an optional action, -- is not allowed
+ if action.option_strings:
+ nargs_pattern = nargs_pattern.replace('-*', '')
+ nargs_pattern = nargs_pattern.replace('-', '')
+
+ # return the pattern
+ return nargs_pattern
+
+ # ========================
+ # Value conversion methods
+ # ========================
+ def _get_values(self, action, arg_strings):
+ # for everything but PARSER args, strip out '--'
+ if action.nargs not in [PARSER, REMAINDER]:
+ arg_strings = [s for s in arg_strings if s != '--']
+
+ # optional argument produces a default when not present
+ if not arg_strings and action.nargs == OPTIONAL:
+ if action.option_strings:
+ value = action.const
+ else:
+ value = action.default
+ if isinstance(value, str):
+ value = self._get_value(action, value)
+ self._check_value(action, value)
+
+ # when nargs='*' on a positional, if there were no command-line
+ # args, use the default if it is anything other than None
+ elif (not arg_strings and action.nargs == ZERO_OR_MORE and
+ not action.option_strings):
+ if action.default is not None:
+ value = action.default
+ else:
+ value = arg_strings
+ self._check_value(action, value)
+
+ # single argument or optional argument produces a single value
+ elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:
+ arg_string, = arg_strings
+ value = self._get_value(action, arg_string)
+ self._check_value(action, value)
+
+ # REMAINDER arguments convert all values, checking none
+ elif action.nargs == REMAINDER:
+ value = [self._get_value(action, v) for v in arg_strings]
+
+ # PARSER arguments convert all values, but check only the first
+ elif action.nargs == PARSER:
+ value = [self._get_value(action, v) for v in arg_strings]
+ self._check_value(action, value[0])
+
+ # all other types of nargs produce a list
+ else:
+ value = [self._get_value(action, v) for v in arg_strings]
+ for v in value:
+ self._check_value(action, v)
+
+ # return the converted value
+ return value
+
+ def _get_value(self, action, arg_string):
+ type_func = self._registry_get('type', action.type, action.type)
+ if not _callable(type_func):
+ msg = _('%r is not callable')
+ raise ArgumentError(action, msg % type_func)
+
+ # convert the value to the appropriate type
+ try:
+ result = type_func(arg_string)
+
+ # ArgumentTypeErrors indicate errors
+ except ArgumentTypeError:
+ name = getattr(action.type, '__name__', repr(action.type))
+ msg = str(_sys.exc_info()[1])
+ raise ArgumentError(action, msg)
+
+ # TypeErrors or ValueErrors also indicate errors
+ except (TypeError, ValueError):
+ name = getattr(action.type, '__name__', repr(action.type))
+ args = {'type': name, 'value': arg_string}
+ msg = _('invalid %(type)s value: %(value)r')
+ raise ArgumentError(action, msg % args)
+
+ # return the converted value
+ return result
+
+ def _check_value(self, action, value):
+ # converted value must be one of the choices (if specified)
+ if action.choices is not None and value not in action.choices:
+ args = {'value': value,
+ 'choices': ', '.join(map(repr, action.choices))}
+ msg = _('invalid choice: %(value)r (choose from %(choices)s)')
+ raise ArgumentError(action, msg % args)
+
+ # =======================
+ # Help-formatting methods
+ # =======================
+ def format_usage(self):
+ formatter = self._get_formatter()
+ formatter.add_usage(self.usage, self._actions,
+ self._mutually_exclusive_groups)
+ return formatter.format_help()
+
+ def format_help(self):
+ formatter = self._get_formatter()
+
+ # usage
+ formatter.add_usage(self.usage, self._actions,
+ self._mutually_exclusive_groups)
+
+ # description
+ formatter.add_text(self.description)
+
+ # positionals, optionals and user-defined groups
+ for action_group in self._action_groups:
+ formatter.start_section(action_group.title)
+ formatter.add_text(action_group.description)
+ formatter.add_arguments(action_group._group_actions)
+ formatter.end_section()
+
+ # epilog
+ formatter.add_text(self.epilog)
+
+ # determine help from format above
+ return formatter.format_help()
+
+ def format_version(self):
+ import warnings
+ warnings.warn(
+ 'The format_version method is deprecated -- the "version" '
+ 'argument to ArgumentParser is no longer supported.',
+ DeprecationWarning)
+ formatter = self._get_formatter()
+ formatter.add_text(self.version)
+ return formatter.format_help()
+
+ def _get_formatter(self):
+ return self.formatter_class(prog=self.prog)
+
+ # =====================
+ # Help-printing methods
+ # =====================
+ def print_usage(self, file=None):
+ if file is None:
+ file = _sys.stdout
+ self._print_message(self.format_usage(), file)
+
+ def print_help(self, file=None):
+ if file is None:
+ file = _sys.stdout
+ self._print_message(self.format_help(), file)
+
+ def print_version(self, file=None):
+ import warnings
+ warnings.warn(
+ 'The print_version method is deprecated -- the "version" '
+ 'argument to ArgumentParser is no longer supported.',
+ DeprecationWarning)
+ self._print_message(self.format_version(), file)
+
+ def _print_message(self, message, file=None):
+ if message:
+ if file is None:
+ file = _sys.stderr
+ file.write(message)
+
+ # ===============
+ # Exiting methods
+ # ===============
+ def exit(self, status=0, message=None):
+ if message:
+ self._print_message(message, _sys.stderr)
+ _sys.exit(status)
+
+ def error(self, message):
+ """error(message: string)
+
+ Prints a usage message incorporating the message to stderr and
+ exits.
+
+ If you override this in a subclass, it should not return -- it
+ should either exit or raise an exception.
+ """
+ self.print_usage(_sys.stderr)
+ args = {'prog': self.prog, 'message': message}
+ self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
diff --git a/Lib/ast.py b/Lib/ast.py
index 112c9701f1..72237ed908 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
ast
~~~
@@ -50,7 +49,7 @@ def literal_eval(node_or_string):
if isinstance(node_or_string, Expression):
node_or_string = node_or_string.body
def _convert(node):
- if isinstance(node, Str):
+ if isinstance(node, (Str, Bytes)):
return node.s
elif isinstance(node, Num):
return node.n
@@ -58,25 +57,33 @@ def literal_eval(node_or_string):
return tuple(map(_convert, node.elts))
elif isinstance(node, List):
return list(map(_convert, node.elts))
+ elif isinstance(node, Set):
+ return set(map(_convert, node.elts))
elif isinstance(node, Dict):
return dict((_convert(k), _convert(v)) for k, v
in zip(node.keys, node.values))
elif isinstance(node, Name):
if node.id in _safe_names:
return _safe_names[node.id]
+ elif isinstance(node, UnaryOp) and \
+ isinstance(node.op, (UAdd, USub)) and \
+ isinstance(node.operand, (Num, UnaryOp, BinOp)):
+ operand = _convert(node.operand)
+ if isinstance(node.op, UAdd):
+ return + operand
+ else:
+ return - operand
elif isinstance(node, BinOp) and \
isinstance(node.op, (Add, Sub)) and \
- isinstance(node.right, Num) and \
- isinstance(node.right.n, complex) and \
- isinstance(node.left, Num) and \
- isinstance(node.left.n, (int, float)):
- left = node.left.n
- right = node.right.n
+ isinstance(node.right, (Num, UnaryOp, BinOp)) and \
+ isinstance(node.left, (Num, UnaryOp, BinOp)):
+ left = _convert(node.left)
+ right = _convert(node.right)
if isinstance(node.op, Add):
return left + right
else:
return left - right
- raise ValueError('malformed string')
+ raise ValueError('malformed node or string: ' + repr(node))
return _convert(node_or_string)
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index 00464a9427..5d7bddaf84 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -50,10 +50,12 @@ import select
import socket
import sys
import time
+import warnings
+
import os
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
- ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, EPIPE, \
- EAGAIN, errorcode
+ ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
+ errorcode
_DISCONNECTED = frozenset((ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
EBADF))
@@ -270,6 +272,8 @@ class dispatcher:
status.append(repr(self.addr))
return '<%s at %#x>' % (' '.join(status), id(self))
+ __str__ = __repr__
+
def add_channel(self, map=None):
#self.log_info('adding channel %s' % self)
if map is None:
@@ -367,7 +371,7 @@ class dispatcher:
except socket.error as why:
if why.args[0] == EWOULDBLOCK:
return 0
- elif why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
+ elif why.args[0] in _DISCONNECTED:
self.handle_close()
return 0
else:
@@ -385,7 +389,7 @@ class dispatcher:
return data
except socket.error as why:
# winsock sometimes throws ENOTCONN
- if why.args[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED]:
+ if why.args[0] in _DISCONNECTED:
self.handle_close()
return b''
else:
@@ -405,10 +409,15 @@ class dispatcher:
# references to the underlying socket object.
def __getattr__(self, attr):
try:
- return getattr(self.socket, attr)
+ retattr = getattr(self.socket, attr)
except AttributeError:
raise AttributeError("%s instance has no attribute '%s'"
%(self.__class__.__name__, attr))
+ else:
+ msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s " \
+ "instead" % {'me' : self.__class__.__name__, 'attr' : attr}
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+ return retattr
# log and log_info may be overridden to provide more sophisticated
# logging and warning methods. In general, log is for 'hit' logging
@@ -502,7 +511,13 @@ class dispatcher:
self.log_info('unhandled connect event', 'warning')
def handle_accept(self):
- self.log_info('unhandled accept event', 'warning')
+ pair = self.accept()
+ if pair is not None:
+ self.handle_accepted(*pair)
+
+ def handle_accepted(self, sock, addr):
+ sock.close()
+ self.log_info('unhandled accepted event', 'warning')
def handle_close(self):
self.log_info('unhandled close event', 'warning')
diff --git a/Lib/base64.py b/Lib/base64.py
index f93b3a4f81..895d813f7e 100755
--- a/Lib/base64.py
+++ b/Lib/base64.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""RFC 3548: Base16, Base32, Base64 Data Encodings"""
@@ -65,16 +65,19 @@ def b64encode(s, altchars=None):
return encoded
-def b64decode(s, altchars=None):
+def b64decode(s, altchars=None, validate=False):
"""Decode a Base64 encoded byte string.
s is the byte string to decode. Optional altchars must be a
string of length 2 which specifies the alternative alphabet used
instead of the '+' and '/' characters.
- The decoded byte string is returned. binascii.Error is raised if
- s were incorrectly padded or if there are non-alphabet characters
- present in the string.
+ The decoded string is returned. A binascii.Error is raised if s is
+ incorrectly padded.
+
+ If validate is False (the default), non-base64-alphabet characters are
+ discarded prior to the padding check. If validate is True,
+ non-base64-alphabet characters in the input result in a binascii.Error.
"""
if not isinstance(s, bytes_types):
raise TypeError("expected bytes, not %s" % s.__class__.__name__)
@@ -84,6 +87,8 @@ def b64decode(s, altchars=None):
% altchars.__class__.__name__)
assert len(altchars) == 2, repr(altchars)
s = _translate(s, {chr(altchars[0]): b'+', chr(altchars[1]): b'/'})
+ if validate and not re.match(b'^[A-Za-z0-9+/]*={0,2}$', s):
+ raise binascii.Error('Non-base64 digit found')
return binascii.a2b_base64(s)
@@ -241,7 +246,7 @@ def b32decode(s, casefold=False, map01=None):
acc += _b32rev[c] << shift
shift -= 5
if shift < 0:
- parts.append(binascii.unhexlify('%010x' % acc))
+ parts.append(binascii.unhexlify(bytes('%010x' % acc, "ascii")))
acc = 0
shift = 35
# Process the last, partial quanta
diff --git a/Lib/bdb.py b/Lib/bdb.py
index 3ed25fe101..f711004483 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -3,16 +3,14 @@
import fnmatch
import sys
import os
-import types
-__all__ = ["BdbQuit","Bdb","Breakpoint"]
+__all__ = ["BdbQuit", "Bdb", "Breakpoint"]
class BdbQuit(Exception):
- """Exception to give up completely"""
+ """Exception to give up completely."""
class Bdb:
-
"""Generic Python debugger base class.
This class takes care of details of the trace facility;
@@ -120,14 +118,14 @@ class Bdb:
def break_here(self, frame):
filename = self.canonic(frame.f_code.co_filename)
- if not filename in self.breaks:
+ if filename not in self.breaks:
return False
lineno = frame.f_lineno
- if not lineno in self.breaks[filename]:
+ if lineno not in self.breaks[filename]:
# The line itself has no breakpoint, but maybe the line is the
# first line of a function with breakpoint set by function name.
lineno = frame.f_code.co_firstlineno
- if not lineno in self.breaks[filename]:
+ if lineno not in self.breaks[filename]:
return False
# flag says ok to delete temp. bp
@@ -170,7 +168,7 @@ class Bdb:
def _set_stopinfo(self, stopframe, returnframe, stoplineno=0):
self.stopframe = stopframe
self.returnframe = returnframe
- self.quitting = 0
+ self.quitting = False
# stoplineno >= 0 means: stop at line >= the stoplineno
# stoplineno -1 means: don't stop at all
self.stoplineno = stoplineno
@@ -178,10 +176,13 @@ class Bdb:
# Derived classes and clients can call the following methods
# to affect the stepping state.
- def set_until(self, frame): #the name "until" is borrowed from gdb
+ def set_until(self, frame, lineno=None):
"""Stop when the line with the line no greater than the current one is
reached or when returning from current frame"""
- self._set_stopinfo(frame, frame, frame.f_lineno+1)
+ # the name "until" is borrowed from gdb
+ if lineno is None:
+ lineno = frame.f_lineno + 1
+ self._set_stopinfo(frame, frame, lineno)
def set_step(self):
"""Stop after one line of code."""
@@ -224,7 +225,7 @@ class Bdb:
def set_quit(self):
self.stopframe = self.botframe
self.returnframe = None
- self.quitting = 1
+ self.quitting = True
sys.settrace(None)
# Derived classes and clients can call the following methods
@@ -234,18 +235,15 @@ class Bdb:
# Call self.get_*break*() to see the breakpoints or better
# for bp in Breakpoint.bpbynumber: if bp: bp.bpprint().
- def set_break(self, filename, lineno, temporary=0, cond = None,
+ def set_break(self, filename, lineno, temporary=False, cond=None,
funcname=None):
filename = self.canonic(filename)
import linecache # Import as late as possible
line = linecache.getline(filename, lineno)
if not line:
- return 'Line %s:%d does not exist' % (filename,
- lineno)
- if not filename in self.breaks:
- self.breaks[filename] = []
- list = self.breaks[filename]
- if not lineno in list:
+ return 'Line %s:%d does not exist' % (filename, lineno)
+ list = self.breaks.setdefault(filename, [])
+ if lineno not in list:
list.append(lineno)
bp = Breakpoint(filename, lineno, temporary, cond, funcname)
@@ -257,11 +255,10 @@ class Bdb:
def clear_break(self, filename, lineno):
filename = self.canonic(filename)
- if not filename in self.breaks:
+ if filename not in self.breaks:
return 'There are no breakpoints in %s' % filename
if lineno not in self.breaks[filename]:
- return 'There is no breakpoint at %s:%d' % (filename,
- lineno)
+ return 'There is no breakpoint at %s:%d' % (filename, lineno)
# If there's only one bp in the list for that file,line
# pair, then remove the breaks entry
for bp in Breakpoint.bplist[filename, lineno][:]:
@@ -270,21 +267,15 @@ class Bdb:
def clear_bpbynumber(self, arg):
try:
- number = int(arg)
- except:
- return 'Non-numeric breakpoint number (%s)' % arg
- try:
- bp = Breakpoint.bpbynumber[number]
- except IndexError:
- return 'Breakpoint number (%d) out of range' % number
- if not bp:
- return 'Breakpoint (%d) already deleted' % number
+ bp = self.get_bpbynumber(arg)
+ except ValueError as err:
+ return str(err)
bp.deleteMe()
self._prune_breaks(bp.file, bp.line)
def clear_all_file_breaks(self, filename):
filename = self.canonic(filename)
- if not filename in self.breaks:
+ if filename not in self.breaks:
return 'There are no breakpoints in %s' % filename
for line in self.breaks[filename]:
blist = Breakpoint.bplist[filename, line]
@@ -300,6 +291,21 @@ class Bdb:
bp.deleteMe()
self.breaks = {}
+ def get_bpbynumber(self, arg):
+ if not arg:
+ raise ValueError('Breakpoint number expected')
+ try:
+ number = int(arg)
+ except ValueError:
+ raise ValueError('Non-numeric breakpoint number %s' % arg)
+ try:
+ bp = Breakpoint.bpbynumber[number]
+ except IndexError:
+ raise ValueError('Breakpoint number %d out of range' % number)
+ if bp is None:
+ raise ValueError('Breakpoint %d already deleted' % number)
+ return bp
+
def get_break(self, filename, lineno):
filename = self.canonic(filename)
return filename in self.breaks and \
@@ -342,35 +348,35 @@ class Bdb:
i = max(0, len(stack) - 1)
return stack, i
- #
-
def format_stack_entry(self, frame_lineno, lprefix=': '):
import linecache, reprlib
frame, lineno = frame_lineno
filename = self.canonic(frame.f_code.co_filename)
s = '%s(%r)' % (filename, lineno)
if frame.f_code.co_name:
- s = s + frame.f_code.co_name
+ s += frame.f_code.co_name
else:
- s = s + "<lambda>"
+ s += "<lambda>"
if '__args__' in frame.f_locals:
args = frame.f_locals['__args__']
else:
args = None
if args:
- s = s + reprlib.repr(args)
+ s += reprlib.repr(args)
else:
- s = s + '()'
+ s += '()'
if '__return__' in frame.f_locals:
rv = frame.f_locals['__return__']
- s = s + '->'
- s = s + reprlib.repr(rv)
+ s += '->'
+ s += reprlib.repr(rv)
line = linecache.getline(filename, lineno, frame.f_globals)
- if line: s = s + lprefix + line.strip()
+ if line:
+ s += lprefix + line.strip()
return s
- # The following two methods can be called by clients to use
- # a debugger to debug a statement, given as a string.
+ # The following methods can be called by clients to use
+ # a debugger to debug a statement or an expression.
+ # Both can be given as a string, or a code object.
def run(self, cmd, globals=None, locals=None):
if globals is None:
@@ -379,15 +385,15 @@ class Bdb:
if locals is None:
locals = globals
self.reset()
+ if isinstance(cmd, str):
+ cmd = compile(cmd, "<string>", "exec")
sys.settrace(self.trace_dispatch)
- if not isinstance(cmd, types.CodeType):
- cmd = cmd+'\n'
try:
exec(cmd, globals, locals)
except BdbQuit:
pass
finally:
- self.quitting = 1
+ self.quitting = True
sys.settrace(None)
def runeval(self, expr, globals=None, locals=None):
@@ -398,14 +404,12 @@ class Bdb:
locals = globals
self.reset()
sys.settrace(self.trace_dispatch)
- if not isinstance(expr, types.CodeType):
- expr = expr+'\n'
try:
return eval(expr, globals, locals)
except BdbQuit:
pass
finally:
- self.quitting = 1
+ self.quitting = True
sys.settrace(None)
def runctx(self, cmd, globals, locals):
@@ -423,7 +427,7 @@ class Bdb:
except BdbQuit:
pass
finally:
- self.quitting = 1
+ self.quitting = True
sys.settrace(None)
return res
@@ -433,8 +437,7 @@ def set_trace():
class Breakpoint:
-
- """Breakpoint class
+ """Breakpoint class.
Implements temporary breakpoints, ignore counts, disabling and
(re)-enabling, and conditionals.
@@ -456,7 +459,7 @@ class Breakpoint:
# index 0 is unused, except for marking an
# effective break .... see effective()
- def __init__(self, file, line, temporary=0, cond=None, funcname=None):
+ def __init__(self, file, line, temporary=False, cond=None, funcname=None):
self.funcname = funcname
# Needed if funcname is not None.
self.func_first_executable_line = None
@@ -464,11 +467,11 @@ class Breakpoint:
self.line = line
self.temporary = temporary
self.cond = cond
- self.enabled = 1
+ self.enabled = True
self.ignore = 0
self.hits = 0
self.number = Breakpoint.next
- Breakpoint.next = Breakpoint.next + 1
+ Breakpoint.next += 1
# Build the two lists
self.bpbynumber.append(self)
if (file, line) in self.bplist:
@@ -476,7 +479,6 @@ class Breakpoint:
else:
self.bplist[file, line] = [self]
-
def deleteMe(self):
index = (self.file, self.line)
self.bpbynumber[self.number] = None # No longer in list
@@ -486,14 +488,17 @@ class Breakpoint:
del self.bplist[index]
def enable(self):
- self.enabled = 1
+ self.enabled = True
def disable(self):
- self.enabled = 0
+ self.enabled = False
def bpprint(self, out=None):
if out is None:
out = sys.stdout
+ print(self.bpformat(), file=out)
+
+ def bpformat(self):
if self.temporary:
disp = 'del '
else:
@@ -502,17 +507,22 @@ class Breakpoint:
disp = disp + 'yes '
else:
disp = disp + 'no '
- print('%-4dbreakpoint %s at %s:%d' % (self.number, disp,
- self.file, self.line), file=out)
+ ret = '%-4dbreakpoint %s at %s:%d' % (self.number, disp,
+ self.file, self.line)
if self.cond:
- print('\tstop only if %s' % (self.cond,), file=out)
+ ret += '\n\tstop only if %s' % (self.cond,)
if self.ignore:
- print('\tignore next %d hits' % (self.ignore), file=out)
- if (self.hits):
- if (self.hits > 1): ss = 's'
- else: ss = ''
- print(('\tbreakpoint already hit %d time%s' %
- (self.hits, ss)), file=out)
+ ret += '\n\tignore next %d hits' % (self.ignore,)
+ if self.hits:
+ if self.hits > 1:
+ ss = 's'
+ else:
+ ss = ''
+ ret += '\n\tbreakpoint already hit %d time%s' % (self.hits, ss)
+ return ret
+
+ def __str__(self):
+ return 'breakpoint %s at %s:%s' % (self.number, self.file, self.line)
# -----------end of Breakpoint class----------
@@ -552,49 +562,44 @@ def effective(file, line, frame):
that indicates if it is ok to delete a temporary bp.
"""
- possibles = Breakpoint.bplist[file,line]
- for i in range(0, len(possibles)):
- b = possibles[i]
- if b.enabled == 0:
+ possibles = Breakpoint.bplist[file, line]
+ for b in possibles:
+ if not b.enabled:
continue
if not checkfuncname(b, frame):
continue
# Count every hit when bp is enabled
- b.hits = b.hits + 1
+ b.hits += 1
if not b.cond:
- # If unconditional, and ignoring,
- # go on to next, else break
+ # If unconditional, and ignoring go on to next, else break
if b.ignore > 0:
- b.ignore = b.ignore -1
+ b.ignore -= 1
continue
else:
- # breakpoint and marker that's ok
- # to delete if temporary
- return (b,1)
+ # breakpoint and marker that it's ok to delete if temporary
+ return (b, True)
else:
# Conditional bp.
# Ignore count applies only to those bpt hits where the
# condition evaluates to true.
try:
- val = eval(b.cond, frame.f_globals,
- frame.f_locals)
+ val = eval(b.cond, frame.f_globals, frame.f_locals)
if val:
if b.ignore > 0:
- b.ignore = b.ignore -1
+ b.ignore -= 1
# continue
else:
- return (b,1)
+ return (b, True)
# else:
# continue
except:
- # if eval fails, most conservative
- # thing is to stop on breakpoint
- # regardless of ignore count.
- # Don't delete temporary,
- # as another hint to user.
- return (b,0)
+ # if eval fails, most conservative thing is to stop on
+ # breakpoint regardless of ignore count. Don't delete
+ # temporary, as another hint to user.
+ return (b, False)
return (None, None)
+
# -------------------- testing --------------------
class Tdb(Bdb):
@@ -627,5 +632,3 @@ def bar(a):
def test():
t = Tdb()
t.run('import bdb; bdb.foo(10)')
-
-# end
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index 3e924ba28a..c24d45bab4 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -1,10 +1,10 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Python interface for the 'lsprof' profiler.
Compatible with the 'profile' module.
"""
-__all__ = ["run", "runctx", "help", "Profile"]
+__all__ = ["run", "runctx", "Profile"]
import _lsprof
@@ -56,11 +56,6 @@ def runctx(statement, globals, locals, filename=None, sort=-1):
result = prof.print_stats(sort)
return result
-# Backwards compatibility.
-def help():
- print("Documentation for the profile/cProfile modules can be found ")
- print("in the Python Library Reference, section 'The Python Profiler'.")
-
# ____________________________________________________________
class Profile(_lsprof.Profiler):
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 7da2b23f6e..e198ed8653 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -31,13 +31,15 @@ __version__ = "2.6"
# Imports
# =======
-from operator import attrgetter
-from io import StringIO
+from io import StringIO, BytesIO, TextIOWrapper
import sys
import os
import urllib.parse
-import email.parser
+from email.parser import FeedParser
from warnings import warn
+import html
+import locale
+import tempfile
__all__ = ["MiniFieldStorage", "FieldStorage",
"parse", "parse_qs", "parse_qsl", "parse_multipart",
@@ -109,7 +111,7 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
Arguments, all optional:
- fp : file pointer; default: sys.stdin
+ fp : file pointer; default: sys.stdin.buffer
environ : environment dictionary; default: os.environ
@@ -126,6 +128,18 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
"""
if fp is None:
fp = sys.stdin
+
+ # field keys and values (except for files) are returned as strings
+ # an encoding is required to decode the bytes read from self.fp
+ if hasattr(fp,'encoding'):
+ encoding = fp.encoding
+ else:
+ encoding = 'latin-1'
+
+ # fp.read() must return bytes
+ if isinstance(fp, TextIOWrapper):
+ fp = fp.buffer
+
if not 'REQUEST_METHOD' in environ:
environ['REQUEST_METHOD'] = 'GET' # For testing stand-alone
if environ['REQUEST_METHOD'] == 'POST':
@@ -136,7 +150,7 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
clength = int(environ['CONTENT_LENGTH'])
if maxlen and clength > maxlen:
raise ValueError('Maximum content length exceeded')
- qs = fp.read(clength)
+ qs = fp.read(clength).decode(encoding)
else:
qs = '' # Unknown content-type
if 'QUERY_STRING' in environ:
@@ -154,7 +168,8 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
else:
qs = ""
environ['QUERY_STRING'] = qs # XXX Shouldn't, really
- return urllib.parse.parse_qs(qs, keep_blank_values, strict_parsing)
+ return urllib.parse.parse_qs(qs, keep_blank_values, strict_parsing,
+ encoding=encoding)
# parse query string function called from urlparse,
@@ -236,8 +251,8 @@ def parse_multipart(fp, pdict):
if not line:
terminator = lastpart # End outer loop
break
- if line[:2] == "--":
- terminator = line.strip()
+ if line.startswith("--"):
+ terminator = line.rstrip()
if terminator in (nextpart, lastpart):
break
lines.append(line)
@@ -352,9 +367,10 @@ class FieldStorage:
value: the value as a *string*; for file uploads, this
transparently reads the file every time you request the value
+ and returns *bytes*
- file: the file(-like) object from which you can read the data;
- None if the data is stored a simple string
+ file: the file(-like) object from which you can read the data *as
+ bytes* ; None if the data is stored a simple string
type: the content-type, or None if not specified
@@ -375,15 +391,18 @@ class FieldStorage:
directory and unlinking them as soon as they have been opened.
"""
-
- def __init__(self, fp=None, headers=None, outerboundary="",
- environ=os.environ, keep_blank_values=0, strict_parsing=0):
+ def __init__(self, fp=None, headers=None, outerboundary=b'',
+ environ=os.environ, keep_blank_values=0, strict_parsing=0,
+ limit=None, encoding='utf-8', errors='replace'):
"""Constructor. Read multipart/* until last part.
Arguments, all optional:
- fp : file pointer; default: sys.stdin
+ fp : file pointer; default: sys.stdin.buffer
(not used when the request method is GET)
+ Can be :
+ 1. a TextIOWrapper object
+ 2. an object whose read() and readline() methods return bytes
headers : header dictionary-like object; default:
taken from environ as per CGI spec
@@ -404,6 +423,16 @@ class FieldStorage:
If false (the default), errors are silently ignored.
If true, errors raise a ValueError exception.
+ limit : used internally to read parts of multipart/form-data forms,
+ to exit from the reading loop when reached. It is the difference
+ between the form content-length and the number of bytes already
+ read
+
+ encoding, errors : the encoding and error handler used to decode the
+ binary stream to strings. Must be the same as the charset defined
+ for the page sending the form (content-type : meta http-equiv or
+ header)
+
"""
method = 'GET'
self.keep_blank_values = keep_blank_values
@@ -418,7 +447,8 @@ class FieldStorage:
qs = sys.argv[1]
else:
qs = ""
- fp = StringIO(qs)
+ qs = qs.encode(locale.getpreferredencoding(), 'surrogateescape')
+ fp = BytesIO(qs)
if headers is None:
headers = {'content-type':
"application/x-www-form-urlencoded"}
@@ -433,10 +463,26 @@ class FieldStorage:
self.qs_on_post = environ['QUERY_STRING']
if 'CONTENT_LENGTH' in environ:
headers['content-length'] = environ['CONTENT_LENGTH']
- self.fp = fp or sys.stdin
+ if fp is None:
+ self.fp = sys.stdin.buffer
+ # self.fp.read() must return bytes
+ elif isinstance(fp, TextIOWrapper):
+ self.fp = fp.buffer
+ else:
+ self.fp = fp
+
+ self.encoding = encoding
+ self.errors = errors
+
self.headers = headers
+ if not isinstance(outerboundary, bytes):
+ raise TypeError('outerboundary must be bytes, not %s'
+ % type(outerboundary).__name__)
self.outerboundary = outerboundary
+ self.bytes_read = 0
+ self.limit = limit
+
# Process content-disposition header
cdisp, pdict = "", {}
if 'content-disposition' in self.headers:
@@ -449,6 +495,7 @@ class FieldStorage:
self.filename = None
if 'filename' in pdict:
self.filename = pdict['filename']
+ self._binary_file = self.filename is not None
# Process content-type header
#
@@ -470,9 +517,11 @@ class FieldStorage:
ctype, pdict = 'application/x-www-form-urlencoded', {}
self.type = ctype
self.type_options = pdict
- self.innerboundary = ""
if 'boundary' in pdict:
- self.innerboundary = pdict['boundary']
+ self.innerboundary = pdict['boundary'].encode(self.encoding)
+ else:
+ self.innerboundary = b""
+
clen = -1
if 'content-length' in self.headers:
try:
@@ -482,6 +531,8 @@ class FieldStorage:
if maxlen and clen > maxlen:
raise ValueError('Maximum content length exceeded')
self.length = clen
+ if self.limit is None and clen:
+ self.limit = clen
self.list = self.file = None
self.done = 0
@@ -531,7 +582,7 @@ class FieldStorage:
"""Dictionary style get() method, including 'value' lookup."""
if key in self:
value = self[key]
- if type(value) is type([]):
+ if isinstance(value, list):
return [x.value for x in value]
else:
return value.value
@@ -542,7 +593,7 @@ class FieldStorage:
""" Return the first value received."""
if key in self:
value = self[key]
- if type(value) is type([]):
+ if isinstance(value, list):
return value[0].value
else:
return value.value
@@ -553,7 +604,7 @@ class FieldStorage:
""" Return list of received values."""
if key in self:
value = self[key]
- if type(value) is type([]):
+ if isinstance(value, list):
return [x.value for x in value]
else:
return [value.value]
@@ -582,12 +633,18 @@ class FieldStorage:
def read_urlencoded(self):
"""Internal: read data in query string format."""
qs = self.fp.read(self.length)
+ if not isinstance(qs, bytes):
+ raise ValueError("%s should return bytes, got %s" \
+ % (self.fp, type(qs).__name__))
+ qs = qs.decode(self.encoding, self.errors)
if self.qs_on_post:
qs += '&' + self.qs_on_post
- self.list = list = []
- for key, value in urllib.parse.parse_qsl(qs, self.keep_blank_values,
- self.strict_parsing):
- list.append(MiniFieldStorage(key, value))
+ self.list = []
+ query = urllib.parse.parse_qsl(
+ qs, self.keep_blank_values, self.strict_parsing,
+ encoding=self.encoding, errors=self.errors)
+ for key, value in query:
+ self.list.append(MiniFieldStorage(key, value))
self.skip_lines()
FieldStorageClass = None
@@ -599,24 +656,42 @@ class FieldStorage:
raise ValueError('Invalid boundary in multipart form: %r' % (ib,))
self.list = []
if self.qs_on_post:
- for key, value in urllib.parse.parse_qsl(self.qs_on_post,
- self.keep_blank_values, self.strict_parsing):
+ query = urllib.parse.parse_qsl(
+ self.qs_on_post, self.keep_blank_values, self.strict_parsing,
+ encoding=self.encoding, errors=self.errors)
+ for key, value in query:
self.list.append(MiniFieldStorage(key, value))
FieldStorageClass = None
klass = self.FieldStorageClass or self.__class__
- parser = email.parser.FeedParser()
- # Create bogus content-type header for proper multipart parsing
- parser.feed('Content-Type: %s; boundary=%s\r\n\r\n' % (self.type, ib))
- parser.feed(self.fp.read())
- full_msg = parser.close()
- # Get subparts
- msgs = full_msg.get_payload()
- for msg in msgs:
- fp = StringIO(msg.get_payload())
- part = klass(fp, msg, ib, environ, keep_blank_values,
- strict_parsing)
+ first_line = self.fp.readline() # bytes
+ if not isinstance(first_line, bytes):
+ raise ValueError("%s should return bytes, got %s" \
+ % (self.fp, type(first_line).__name__))
+ self.bytes_read += len(first_line)
+ # first line holds boundary ; ignore it, or check that
+ # b"--" + ib == first_line.strip() ?
+ while True:
+ parser = FeedParser()
+ hdr_text = b""
+ while True:
+ data = self.fp.readline()
+ hdr_text += data
+ if not data.strip():
+ break
+ if not hdr_text:
+ break
+ # parser takes strings, not bytes
+ self.bytes_read += len(hdr_text)
+ parser.feed(hdr_text.decode(self.encoding, self.errors))
+ headers = parser.close()
+ part = klass(self.fp, headers, ib, environ, keep_blank_values,
+ strict_parsing,self.limit-self.bytes_read,
+ self.encoding, self.errors)
+ self.bytes_read += part.bytes_read
self.list.append(part)
+ if self.bytes_read >= self.length:
+ break
self.skip_lines()
def read_single(self):
@@ -636,7 +711,11 @@ class FieldStorage:
todo = self.length
if todo >= 0:
while todo > 0:
- data = self.fp.read(min(todo, self.bufsize))
+ data = self.fp.read(min(todo, self.bufsize)) # bytes
+ if not isinstance(data, bytes):
+ raise ValueError("%s should return bytes, got %s"
+ % (self.fp, type(data).__name__))
+ self.bytes_read += len(data)
if not data:
self.done = -1
break
@@ -645,59 +724,77 @@ class FieldStorage:
def read_lines(self):
"""Internal: read lines until EOF or outerboundary."""
- self.file = self.__file = StringIO()
+ if self._binary_file:
+ self.file = self.__file = BytesIO() # store data as bytes for files
+ else:
+ self.file = self.__file = StringIO() # as strings for other fields
if self.outerboundary:
self.read_lines_to_outerboundary()
else:
self.read_lines_to_eof()
def __write(self, line):
+ """line is always bytes, not string"""
if self.__file is not None:
if self.__file.tell() + len(line) > 1000:
self.file = self.make_file()
data = self.__file.getvalue()
self.file.write(data)
self.__file = None
- self.file.write(line)
+ if self._binary_file:
+ # keep bytes
+ self.file.write(line)
+ else:
+ # decode to string
+ self.file.write(line.decode(self.encoding, self.errors))
def read_lines_to_eof(self):
"""Internal: read lines until EOF."""
while 1:
- line = self.fp.readline(1<<16)
+ line = self.fp.readline(1<<16) # bytes
+ self.bytes_read += len(line)
if not line:
self.done = -1
break
self.__write(line)
def read_lines_to_outerboundary(self):
- """Internal: read lines until outerboundary."""
- next = "--" + self.outerboundary
- last = next + "--"
- delim = ""
+ """Internal: read lines until outerboundary.
+ Data is read as bytes: boundaries and line ends must be converted
+ to bytes for comparisons.
+ """
+ next_boundary = b"--" + self.outerboundary
+ last_boundary = next_boundary + b"--"
+ delim = b""
last_line_lfend = True
+ _read = 0
while 1:
- line = self.fp.readline(1<<16)
+ if _read >= self.limit:
+ break
+ line = self.fp.readline(1<<16) # bytes
+ self.bytes_read += len(line)
+ _read += len(line)
if not line:
self.done = -1
break
- if line[:2] == "--" and last_line_lfend:
- strippedline = line.strip()
- if strippedline == next:
+ if line.startswith(b"--") and last_line_lfend:
+ strippedline = line.rstrip()
+ if strippedline == next_boundary:
break
- if strippedline == last:
+ if strippedline == last_boundary:
self.done = 1
break
odelim = delim
- if line[-2:] == "\r\n":
- delim = "\r\n"
+ if line.endswith(b"\r\n"):
+ delim = b"\r\n"
line = line[:-2]
last_line_lfend = True
- elif line[-1] == "\n":
- delim = "\n"
+ elif line.endswith(b"\n"):
+ delim = b"\n"
line = line[:-1]
last_line_lfend = True
else:
- delim = ""
+ delim = b""
last_line_lfend = False
self.__write(odelim + line)
@@ -705,22 +802,23 @@ class FieldStorage:
"""Internal: skip lines until outer boundary if defined."""
if not self.outerboundary or self.done:
return
- next = "--" + self.outerboundary
- last = next + "--"
+ next_boundary = b"--" + self.outerboundary
+ last_boundary = next_boundary + b"--"
last_line_lfend = True
- while 1:
+ while True:
line = self.fp.readline(1<<16)
+ self.bytes_read += len(line)
if not line:
self.done = -1
break
- if line[:2] == "--" and last_line_lfend:
+ if line.endswith(b"--") and last_line_lfend:
strippedline = line.strip()
- if strippedline == next:
+ if strippedline == next_boundary:
break
- if strippedline == last:
+ if strippedline == last_boundary:
self.done = 1
break
- last_line_lfend = line.endswith('\n')
+ last_line_lfend = line.endswith(b'\n')
def make_file(self):
"""Overridable: return a readable & writable file.
@@ -730,7 +828,8 @@ class FieldStorage:
- seek(0)
- data is read from it
- The file is always opened in text mode.
+ The file is opened in binary mode for files, in text mode
+ for other fields
This version opens a temporary file for reading and writing,
and immediately deletes (unlinks) it. The trick (on Unix!) is
@@ -745,8 +844,11 @@ class FieldStorage:
which unlinks the temporary files you have created.
"""
- import tempfile
- return tempfile.TemporaryFile("w+", encoding="utf-8", newline="\n")
+ if self._binary_file:
+ return tempfile.TemporaryFile("wb+")
+ else:
+ return tempfile.TemporaryFile("w+",
+ encoding=self.encoding, newline = '\n')
# Test/debug code
@@ -800,8 +902,8 @@ def print_exception(type=None, value=None, tb=None, limit=None):
list = traceback.format_tb(tb, limit) + \
traceback.format_exception_only(type, value)
print("<PRE>%s<B>%s</B></PRE>" % (
- escape("".join(list[:-1])),
- escape(list[-1]),
+ html.escape("".join(list[:-1])),
+ html.escape(list[-1]),
))
del tb
@@ -812,7 +914,7 @@ def print_environ(environ=os.environ):
print("<H3>Shell Environment:</H3>")
print("<DL>")
for key in keys:
- print("<DT>", escape(key), "<DD>", escape(environ[key]))
+ print("<DT>", html.escape(key), "<DD>", html.escape(environ[key]))
print("</DL>")
print()
@@ -825,10 +927,10 @@ def print_form(form):
print("<P>No form fields.")
print("<DL>")
for key in keys:
- print("<DT>" + escape(key) + ":", end=' ')
+ print("<DT>" + html.escape(key) + ":", end=' ')
value = form[key]
- print("<i>" + escape(repr(type(value))) + "</i>")
- print("<DD>" + escape(repr(value)))
+ print("<i>" + html.escape(repr(type(value))) + "</i>")
+ print("<DD>" + html.escape(repr(value)))
print("</DL>")
print()
@@ -839,9 +941,9 @@ def print_directory():
try:
pwd = os.getcwd()
except os.error as msg:
- print("os.error:", escape(str(msg)))
+ print("os.error:", html.escape(str(msg)))
else:
- print(escape(pwd))
+ print(html.escape(pwd))
print()
def print_arguments():
@@ -899,9 +1001,9 @@ environment as well. Here are some common variable names:
# =========
def escape(s, quote=None):
- '''Replace special characters "&", "<" and ">" to HTML-safe sequences.
- If the optional flag quote is true, the quotation mark character (")
- is also translated.'''
+ """Deprecated API."""
+ warn("cgi.escape is deprecated, use html.escape instead",
+ PendingDeprecationWarning, stacklevel=2)
s = s.replace("&", "&amp;") # Must be done first!
s = s.replace("<", "&lt;")
s = s.replace(">", "&gt;")
@@ -909,8 +1011,13 @@ def escape(s, quote=None):
s = s.replace('"', "&quot;")
return s
-def valid_boundary(s, _vb_pattern="^[ -~]{0,200}[!-~]$"):
+
+def valid_boundary(s, _vb_pattern=None):
import re
+ if isinstance(s, bytes):
+ _vb_pattern = b"^[ -~]{0,200}[!-~]$"
+ else:
+ _vb_pattern = "^[ -~]{0,200}[!-~]$"
return re.match(_vb_pattern, s)
# Invoke mainline
diff --git a/Lib/cmd.py b/Lib/cmd.py
index 10aa5acf4b..8fa7d019b5 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -84,7 +84,6 @@ class Cmd:
sys.stdin and sys.stdout are used.
"""
- import sys
if stdin is not None:
self.stdin = stdin
else:
@@ -278,21 +277,18 @@ class Cmd:
return None
def get_names(self):
- # Inheritance says we have to look in class and
- # base classes; order is not important.
- names = []
- classes = [self.__class__]
- while classes:
- aclass = classes.pop(0)
- if aclass.__bases__:
- classes = classes + list(aclass.__bases__)
- names = names + dir(aclass)
- return names
+ # This method used to pull in base class attributes
+ # at a time dir() didn't do it yet.
+ return dir(self.__class__)
def complete_help(self, *args):
- return self.completenames(*args)
+ commands = set(self.completenames(*args))
+ topics = set(a[5:] for a in self.get_names()
+ if a.startswith('help_' + args[0]))
+ return list(commands | topics)
def do_help(self, arg):
+ 'List available commands with "help" or detailed help with "help cmd".'
if arg:
# XXX check arg syntax
try:
diff --git a/Lib/code.py b/Lib/code.py
index 8962927d71..605aede5ef 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -287,6 +287,5 @@ def interact(banner=None, readfunc=None, local=None):
console.interact(banner)
-if __name__ == '__main__':
- import pdb
- pdb.run("interact()\n")
+if __name__ == "__main__":
+ interact()
diff --git a/Lib/codecs.py b/Lib/codecs.py
index f6c2448168..b150d64d53 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -396,6 +396,8 @@ class StreamWriter(Codec):
class StreamReader(Codec):
+ charbuffertype = str
+
def __init__(self, stream, errors='strict'):
""" Creates a StreamReader instance.
@@ -417,9 +419,8 @@ class StreamReader(Codec):
self.stream = stream
self.errors = errors
self.bytebuffer = b""
- # For str->str decoding this will stay a str
- # For str->unicode decoding the first read will promote it to unicode
- self.charbuffer = ""
+ self._empty_charbuffer = self.charbuffertype()
+ self.charbuffer = self._empty_charbuffer
self.linebuffer = None
def decode(self, input, errors='strict'):
@@ -455,7 +456,7 @@ class StreamReader(Codec):
"""
# If we have lines cached, first merge them back into characters
if self.linebuffer:
- self.charbuffer = "".join(self.linebuffer)
+ self.charbuffer = self._empty_charbuffer.join(self.linebuffer)
self.linebuffer = None
# read until we get the required number of characters (if available)
@@ -498,7 +499,7 @@ class StreamReader(Codec):
if chars < 0:
# Return everything we've got
result = self.charbuffer
- self.charbuffer = ""
+ self.charbuffer = self._empty_charbuffer
else:
# Return the first chars characters
result = self.charbuffer[:chars]
@@ -529,7 +530,7 @@ class StreamReader(Codec):
return line
readsize = size or 72
- line = ""
+ line = self._empty_charbuffer
# If size is given, we call read() only once
while True:
data = self.read(readsize, firstline=True)
@@ -537,7 +538,8 @@ class StreamReader(Codec):
# If we're at a "\r" read one extra character (which might
# be a "\n") to get a proper line ending. If the stream is
# temporarily exhausted we return the wrong line ending.
- if data.endswith("\r"):
+ if (isinstance(data, str) and data.endswith("\r")) or \
+ (isinstance(data, bytes) and data.endswith(b"\r")):
data += self.read(size=1, chars=1)
line += data
@@ -563,7 +565,8 @@ class StreamReader(Codec):
line0withoutend = lines[0].splitlines(False)[0]
if line0withend != line0withoutend: # We really have a line end
# Put the rest back together and keep it until the next call
- self.charbuffer = "".join(lines[1:]) + self.charbuffer
+ self.charbuffer = self._empty_charbuffer.join(lines[1:]) + \
+ self.charbuffer
if keepends:
line = line0withend
else:
@@ -574,7 +577,7 @@ class StreamReader(Codec):
if line and not keepends:
line = line.splitlines(False)[0]
break
- if readsize<8000:
+ if readsize < 8000:
readsize *= 2
return line
@@ -603,7 +606,7 @@ class StreamReader(Codec):
"""
self.bytebuffer = b""
- self.charbuffer = ""
+ self.charbuffer = self._empty_charbuffer
self.linebuffer = None
def seek(self, offset, whence=0):
diff --git a/Lib/collections.py b/Lib/collections.py
index 27bb5e1268..98c4325753 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -13,6 +13,7 @@ import sys as _sys
import heapq as _heapq
from weakref import proxy as _proxy
from itertools import repeat as _repeat, chain as _chain, starmap as _starmap
+from reprlib import recursive_repr as _recursive_repr
################################################################################
### OrderedDict
@@ -31,6 +32,7 @@ class OrderedDict(dict):
# The internal self.__map dictionary maps keys to links in a doubly linked list.
# The circular doubly linked list starts and ends with a sentinel element.
# The sentinel element never gets deleted (this simplifies the algorithm).
+ # The sentinel is stored in self.__hardroot with a weakref proxy in self.__root.
# The prev/next links are weakref proxies (to prevent circular references).
# Individual links are kept alive by the hard reference in self.__map.
# Those hard references disappear when a key is deleted from an OrderedDict.
@@ -43,42 +45,39 @@ class OrderedDict(dict):
'''
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
- self.__in_repr = False # detects recursive repr
try:
self.__root
except AttributeError:
- self.__root = root = _Link() # sentinel node for the doubly linked list
+ self.__hardroot = _Link()
+ self.__root = root = _proxy(self.__hardroot)
root.prev = root.next = root
self.__map = {}
self.__update(*args, **kwds)
- def clear(self):
- 'od.clear() -> None. Remove all items from od.'
- root = self.__root
- root.prev = root.next = root
- self.__map.clear()
- dict.clear(self)
-
- def __setitem__(self, key, value):
+ def __setitem__(self, key, value,
+ dict_setitem=dict.__setitem__, proxy=_proxy, Link=_Link):
'od.__setitem__(i, y) <==> od[i]=y'
# Setting a new item creates a new link which goes at the end of the linked
# list, and the inherited dictionary is updated with the new key/value pair.
if key not in self:
- self.__map[key] = link = _Link()
+ self.__map[key] = link = Link()
root = self.__root
last = root.prev
link.prev, link.next, link.key = last, root, key
- last.next = root.prev = _proxy(link)
- dict.__setitem__(self, key, value)
+ last.next = link
+ root.prev = proxy(link)
+ dict_setitem(self, key, value)
- def __delitem__(self, key):
+ def __delitem__(self, key, dict_delitem=dict.__delitem__):
'od.__delitem__(y) <==> del od[y]'
# Deleting an existing item uses self.__map to find the link which is
# then removed by updating the links in the predecessor and successor nodes.
- dict.__delitem__(self, key)
+ dict_delitem(self, key)
link = self.__map.pop(key)
- link.prev.next = link.next
- link.next.prev = link.prev
+ link_prev = link.prev
+ link_next = link.next
+ link_prev.next = link_next
+ link_next.prev = link_prev
def __iter__(self):
'od.__iter__() <==> iter(od)'
@@ -98,21 +97,85 @@ class OrderedDict(dict):
yield curr.key
curr = curr.prev
+ def clear(self):
+ 'od.clear() -> None. Remove all items from od.'
+ root = self.__root
+ root.prev = root.next = root
+ self.__map.clear()
+ dict.clear(self)
+
+ def popitem(self, last=True):
+ '''od.popitem() -> (k, v), return and remove a (key, value) pair.
+ Pairs are returned in LIFO order if last is true or FIFO order if false.
+
+ '''
+ if not self:
+ raise KeyError('dictionary is empty')
+ root = self.__root
+ if last:
+ link = root.prev
+ link_prev = link.prev
+ link_prev.next = root
+ root.prev = link_prev
+ else:
+ link = root.next
+ link_next = link.next
+ root.next = link_next
+ link_next.prev = root
+ key = link.key
+ del self.__map[key]
+ value = dict.pop(self, key)
+ return key, value
+
+ def move_to_end(self, key, last=True):
+ '''Move an existing element to the end (or beginning if last==False).
+
+ Raises KeyError if the element does not exist.
+ When last=True, acts like a fast version of self[key]=self.pop(key).
+
+ '''
+ link = self.__map[key]
+ link_prev = link.prev
+ link_next = link.next
+ link_prev.next = link_next
+ link_next.prev = link_prev
+ root = self.__root
+ if last:
+ last = root.prev
+ link.prev = last
+ link.next = root
+ last.next = root.prev = link
+ else:
+ first = root.next
+ link.prev = root
+ link.next = first
+ root.next = first.prev = link
+
def __reduce__(self):
'Return state information for pickling'
items = [[k, self[k]] for k in self]
- tmp = self.__map, self.__root, self.__in_repr
- del self.__map, self.__root, self.__in_repr
+ tmp = self.__map, self.__root, self.__hardroot
+ del self.__map, self.__root, self.__hardroot
inst_dict = vars(self).copy()
- self.__map, self.__root, self.__in_repr = tmp
+ self.__map, self.__root, self.__hardroot = tmp
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
+ def __sizeof__(self):
+ sizeof = _sys.getsizeof
+ n = len(self) + 1 # number of links including root
+ size = sizeof(self.__dict__) # instance dictionary
+ size += sizeof(self.__map) * 2 # internal dict and inherited dict
+ size += sizeof(self.__hardroot) * n # link objects
+ size += sizeof(self.__root) * n # proxy objects
+ return size
+
update = __update = MutableMapping.update
keys = MutableMapping.keys
values = MutableMapping.values
items = MutableMapping.items
+ __ne__ = MutableMapping.__ne__
__marker = object()
@@ -126,35 +189,18 @@ class OrderedDict(dict):
return default
def setdefault(self, key, default=None):
- 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
+ 'OD.setdefault(k[,d]) -> OD.get(k,d), also set OD[k]=d if k not in OD'
if key in self:
return self[key]
self[key] = default
return default
- def popitem(self, last=True):
- '''od.popitem() -> (k, v), return and remove a (key, value) pair.
- Pairs are returned in LIFO order if last is true or FIFO order if false.
-
- '''
- if not self:
- raise KeyError('dictionary is empty')
- key = next(reversed(self) if last else iter(self))
- value = self.pop(key)
- return key, value
-
+ @_recursive_repr()
def __repr__(self):
'od.__repr__() <==> repr(od)'
- if self.__in_repr:
- return '...'
if not self:
return '%s()' % (self.__class__.__name__,)
- self.__in_repr = True
- try:
- result = '%s(%r)' % (self.__class__.__name__, list(self.items()))
- finally:
- self.__in_repr = False
- return result
+ return '%s(%r)' % (self.__class__.__name__, list(self.items()))
def copy(self):
'od.copy() -> a shallow copy of od'
@@ -181,14 +227,6 @@ class OrderedDict(dict):
all(p==q for p, q in zip(self.items(), other.items()))
return dict.__eq__(self, other)
- def __ne__(self, other):
- '''od.__ne__(y) <==> od!=y. Comparison to another OD is order-sensitive
- while comparison to a regular mapping is order-insensitive.
-
- '''
- return not self == other
-
-
################################################################################
### namedtuple
@@ -257,6 +295,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
__slots__ = () \n
_fields = %(field_names)r \n
def __new__(_cls, %(argtxt)s):
+ 'Create new instance of %(typename)s(%(argtxt)s)'
return _tuple.__new__(_cls, (%(argtxt)s)) \n
@classmethod
def _make(cls, iterable, new=tuple.__new__, len=len):
@@ -266,7 +305,8 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result))
return result \n
def __repr__(self):
- return '%(typename)s(%(reprtxt)s)' %% self \n
+ 'Return a nicely formatted representation string'
+ return self.__class__.__name__ + '(%(reprtxt)s)' %% self \n
def _asdict(self):
'Return a new OrderedDict which maps field names to their values'
return OrderedDict(zip(self._fields, self)) \n
@@ -277,9 +317,10 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
raise ValueError('Got unexpected field names: %%r' %% kwds.keys())
return result \n
def __getnewargs__(self):
+ 'Return self as a plain tuple. Used by copy and pickle.'
return tuple(self) \n\n''' % locals()
for i, name in enumerate(field_names):
- template += ' %s = _property(_itemgetter(%d))\n' % (name, i)
+ template += " %s = _property(_itemgetter(%d), doc='Alias for field number %d')\n" % (name, i, i)
if verbose:
print(template)
@@ -290,7 +331,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
try:
exec(template, namespace)
except SyntaxError as e:
- raise SyntaxError(e.msg + ':\n' + template) from e
+ raise SyntaxError(e.msg + ':\n\n' + template)
result = namespace[typename]
# For pickling to work, the __module__ variable needs to be set to the frame
@@ -309,6 +350,17 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
### Counter
########################################################################
+def _count_elements(mapping, iterable):
+ 'Tally elements from the iterable.'
+ mapping_get = mapping.get
+ for elem in iterable:
+ mapping[elem] = mapping_get(elem, 0) + 1
+
+try: # Load C helper function if available
+ from _collections import _count_elements
+except ImportError:
+ pass
+
class Counter(dict):
'''Dict subclass for counting hashable items. Sometimes called a bag
or multiset. Elements are stored as dictionary keys and their counts
@@ -452,12 +504,37 @@ class Counter(dict):
else:
super().update(iterable) # fast path when counter is empty
else:
- self_get = self.get
- for elem in iterable:
- self[elem] = 1 + self_get(elem, 0)
+ _count_elements(self, iterable)
if kwds:
self.update(kwds)
+ def subtract(self, iterable=None, **kwds):
+ '''Like dict.update() but subtracts counts instead of replacing them.
+ Counts can be reduced below zero. Both the inputs and outputs are
+ allowed to contain zero and negative counts.
+
+ Source can be an iterable, a dictionary, or another Counter instance.
+
+ >>> c = Counter('which')
+ >>> c.subtract('witch') # subtract elements from another iterable
+ >>> c.subtract(Counter('watch')) # subtract elements from another counter
+ >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch
+ 0
+ >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch
+ -1
+
+ '''
+ if iterable is not None:
+ self_get = self.get
+ if isinstance(iterable, Mapping):
+ for elem, count in iterable.items():
+ self[elem] = self_get(elem, 0) - count
+ else:
+ for elem in iterable:
+ self[elem] = self_get(elem, 0) - 1
+ if kwds:
+ self.subtract(kwds)
+
def copy(self):
'Like dict.copy() but returns a Counter instance instead of a dict.'
return Counter(self)
@@ -554,6 +631,106 @@ class Counter(dict):
return result
+########################################################################
+### ChainMap (helper for configparser)
+########################################################################
+
+class _ChainMap(MutableMapping):
+ ''' A ChainMap groups multiple dicts (or other mappings) together
+ to create a single, updateable view.
+
+ The underlying mappings are stored in a list. That list is public and can
+ accessed or updated using the *maps* attribute. There is no other state.
+
+ Lookups search the underlying mappings successively until a key is found.
+ In contrast, writes, updates, and deletions only operate on the first
+ mapping.
+
+ '''
+
+ def __init__(self, *maps):
+ '''Initialize a ChainMap by setting *maps* to the given mappings.
+ If no mappings are provided, a single empty dictionary is used.
+
+ '''
+ self.maps = list(maps) or [{}] # always at least one map
+
+ def __missing__(self, key):
+ raise KeyError(key)
+
+ def __getitem__(self, key):
+ for mapping in self.maps:
+ try:
+ return mapping[key] # can't use 'key in mapping' with defaultdict
+ except KeyError:
+ pass
+ return self.__missing__(key) # support subclasses that define __missing__
+
+ def get(self, key, default=None):
+ return self[key] if key in self else default
+
+ def __len__(self):
+ return len(set().union(*self.maps)) # reuses stored hash values if possible
+
+ def __iter__(self):
+ return iter(set().union(*self.maps))
+
+ def __contains__(self, key):
+ return any(key in m for m in self.maps)
+
+ @_recursive_repr()
+ def __repr__(self):
+ return '{0.__class__.__name__}({1})'.format(
+ self, ', '.join(map(repr, self.maps)))
+
+ @classmethod
+ def fromkeys(cls, iterable, *args):
+ 'Create a ChainMap with a single dict created from the iterable.'
+ return cls(dict.fromkeys(iterable, *args))
+
+ def copy(self):
+ 'New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]'
+ return self.__class__(self.maps[0].copy(), *self.maps[1:])
+
+ __copy__ = copy
+
+ def new_child(self): # like Django's Context.push()
+ 'New ChainMap with a new dict followed by all previous maps.'
+ return self.__class__({}, *self.maps)
+
+ @property
+ def parents(self): # like Django's Context.pop()
+ 'New ChainMap from maps[1:].'
+ return self.__class__(*self.maps[1:])
+
+ def __setitem__(self, key, value):
+ self.maps[0][key] = value
+
+ def __delitem__(self, key):
+ try:
+ del self.maps[0][key]
+ except KeyError:
+ raise KeyError('Key not found in the first mapping: {!r}'.format(key))
+
+ def popitem(self):
+ 'Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.'
+ try:
+ return self.maps[0].popitem()
+ except KeyError:
+ raise KeyError('No keys found in the first mapping.')
+
+ def pop(self, key, *args):
+ 'Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].'
+ try:
+ return self.maps[0].pop(key, *args)
+ except KeyError:
+ raise KeyError('Key not found in the first mapping: {!r}'.format(key))
+
+ def clear(self):
+ 'Clear maps[0], leaving maps[1:] intact.'
+ self.maps[0].clear()
+
+
################################################################################
### UserDict
################################################################################
@@ -795,6 +972,8 @@ class UserString(Sequence):
new = new.data
return self.__class__(self.data.replace(old, new, maxsplit))
def rfind(self, sub, start=0, end=_sys.maxsize):
+ if isinstance(sub, UserString):
+ sub = sub.data
return self.data.rfind(sub, start, end)
def rindex(self, sub, start=0, end=_sys.maxsize):
return self.data.rindex(sub, start, end)
diff --git a/Lib/compileall.py b/Lib/compileall.py
index 2432842db5..d79a1bb9a0 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -1,4 +1,4 @@
-"""Module/script to "compile" all .py files to .pyc (or .pyo) file.
+"""Module/script to byte-compile all .py files to .pyc (or .pyo) files.
When called as a script with arguments, this compiles the directories
given as arguments recursively; the -l option prevents it from
@@ -9,29 +9,30 @@ recursing into subdirectories. (Even though it should do so for
packages -- for now, you'll have to deal with packages separately.)
See module py_compile for details of the actual byte-compilation.
-
"""
import os
import sys
+import errno
+import imp
import py_compile
import struct
-import imp
-__all__ = ["compile_dir","compile_path"]
+__all__ = ["compile_dir","compile_file","compile_path"]
-def compile_dir(dir, maxlevels=10, ddir=None,
- force=0, rx=None, quiet=0):
+def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
+ quiet=False, legacy=False, optimize=-1):
"""Byte-compile all modules in the given directory tree.
Arguments (only dir is required):
dir: the directory to byte-compile
maxlevels: maximum recursion level (default 10)
- ddir: if given, purported directory name (this is the
- directory name that will show up in error messages)
- force: if 1, force compilation, even if timestamps are up-to-date
- quiet: if 1, be quiet during compilation
-
+ ddir: the directory that will be prepended to the path to the
+ file as it is compiled into each byte-code file.
+ force: if True, force compilation, even if timestamps are up-to-date
+ quiet: if True, be quiet during compilation
+ legacy: if True, produce legacy pyc paths instead of PEP 3147 paths
+ optimize: optimization level or -1 for level of the interpreter
"""
if not quiet:
print('Listing', dir, '...')
@@ -43,74 +44,110 @@ def compile_dir(dir, maxlevels=10, ddir=None,
names.sort()
success = 1
for name in names:
+ if name == '__pycache__':
+ continue
fullname = os.path.join(dir, name)
if ddir is not None:
dfile = os.path.join(ddir, name)
else:
dfile = None
- if rx is not None:
- mo = rx.search(fullname)
- if mo:
- continue
- if os.path.isfile(fullname):
- head, tail = name[:-3], name[-3:]
- if tail == '.py':
- if not force:
- try:
- mtime = int(os.stat(fullname).st_mtime)
- expect = struct.pack('<4sl', imp.get_magic(), mtime)
- cfile = fullname + (__debug__ and 'c' or 'o')
- with open(cfile, 'rb') as chandle:
- actual = chandle.read(8)
- if expect == actual:
- continue
- except IOError:
- pass
- if not quiet:
- print('Compiling', fullname, '...')
+ if not os.path.isdir(fullname):
+ if not compile_file(fullname, ddir, force, rx, quiet,
+ legacy, optimize):
+ success = 0
+ elif (maxlevels > 0 and name != os.curdir and name != os.pardir and
+ os.path.isdir(fullname) and not os.path.islink(fullname)):
+ if not compile_dir(fullname, maxlevels - 1, dfile, force, rx,
+ quiet, legacy, optimize):
+ success = 0
+ return success
+
+def compile_file(fullname, ddir=None, force=False, rx=None, quiet=False,
+ legacy=False, optimize=-1):
+ """Byte-compile one file.
+
+ Arguments (only fullname is required):
+
+ fullname: the file to byte-compile
+ ddir: if given, the directory name compiled in to the
+ byte-code file.
+ force: if True, force compilation, even if timestamps are up-to-date
+ quiet: if True, be quiet during compilation
+ legacy: if True, produce legacy pyc paths instead of PEP 3147 paths
+ optimize: optimization level or -1 for level of the interpreter
+ """
+ success = 1
+ name = os.path.basename(fullname)
+ if ddir is not None:
+ dfile = os.path.join(ddir, name)
+ else:
+ dfile = None
+ if rx is not None:
+ mo = rx.search(fullname)
+ if mo:
+ return success
+ if os.path.isfile(fullname):
+ if legacy:
+ cfile = fullname + ('c' if __debug__ else 'o')
+ else:
+ if optimize >= 0:
+ cfile = imp.cache_from_source(fullname,
+ debug_override=not optimize)
+ else:
+ cfile = imp.cache_from_source(fullname)
+ cache_dir = os.path.dirname(cfile)
+ head, tail = name[:-3], name[-3:]
+ if tail == '.py':
+ if not force:
try:
- ok = py_compile.compile(fullname, None, dfile, True)
- except KeyboardInterrupt:
- raise KeyboardInterrupt
- except py_compile.PyCompileError as err:
- if quiet:
- print('*** Error compiling', fullname, '...')
- else:
- print('*** ', end='')
- # escape non-printable characters in msg
- msg = err.msg.encode(sys.stdout.encoding, 'backslashreplace')
- msg = msg.decode(sys.stdout.encoding)
- print(msg)
- success = 0
- except (SyntaxError, UnicodeError, IOError) as e:
- if quiet:
- print('*** Error compiling', fullname, '...')
- else:
- print('*** ', end='')
- print(e.__class__.__name__ + ':', e)
- success = 0
+ mtime = int(os.stat(fullname).st_mtime)
+ expect = struct.pack('<4sl', imp.get_magic(), mtime)
+ with open(cfile, 'rb') as chandle:
+ actual = chandle.read(8)
+ if expect == actual:
+ return success
+ except IOError:
+ pass
+ if not quiet:
+ print('Compiling', fullname, '...')
+ try:
+ ok = py_compile.compile(fullname, cfile, dfile, True,
+ optimize=optimize)
+ except py_compile.PyCompileError as err:
+ if quiet:
+ print('*** Error compiling', fullname, '...')
else:
- if ok == 0:
- success = 0
- elif maxlevels > 0 and \
- name != os.curdir and name != os.pardir and \
- os.path.isdir(fullname) and \
- not os.path.islink(fullname):
- if not compile_dir(fullname, maxlevels - 1, dfile, force, rx,
- quiet):
+ print('*** ', end='')
+ # escape non-printable characters in msg
+ msg = err.msg.encode(sys.stdout.encoding,
+ errors='backslashreplace')
+ msg = msg.decode(sys.stdout.encoding)
+ print(msg)
success = 0
+ except (SyntaxError, UnicodeError, IOError) as e:
+ if quiet:
+ print('*** Error compiling', fullname, '...')
+ else:
+ print('*** ', end='')
+ print(e.__class__.__name__ + ':', e)
+ success = 0
+ else:
+ if ok == 0:
+ success = 0
return success
-def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
+def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=False,
+ legacy=False, optimize=-1):
"""Byte-compile all module on sys.path.
Arguments (all optional):
skip_curdir: if true, skip current directory (default true)
maxlevels: max recursion level (default 0)
- force: as for compile_dir() (default 0)
- quiet: as for compile_dir() (default 0)
-
+ force: as for compile_dir() (default False)
+ quiet: as for compile_dir() (default False)
+ legacy: as for compile_dir() (default False)
+ optimize: as for compile_dir() (default -1)
"""
success = 1
for dir in sys.path:
@@ -118,56 +155,85 @@ def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
print('Skipping current directory')
else:
success = success and compile_dir(dir, maxlevels, None,
- force, quiet=quiet)
+ force, quiet=quiet,
+ legacy=legacy, optimize=optimize)
return success
+
def main():
"""Script main program."""
- import getopt
- try:
- opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:')
- except getopt.error as msg:
- print(msg)
- print("usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
- "[-x regexp] [directory ...]")
- print("-l: don't recurse down")
- print("-f: force rebuild even if timestamps are up-to-date")
- print("-q: quiet operation")
- print("-d destdir: purported directory name for error messages")
- print(" if no directory arguments, -l sys.path is assumed")
- print("-x regexp: skip files matching the regular expression regexp")
- print(" the regexp is searched for in the full path of the file")
- sys.exit(2)
- maxlevels = 10
- ddir = None
- force = 0
- quiet = 0
- rx = None
- for o, a in opts:
- if o == '-l': maxlevels = 0
- if o == '-d': ddir = a
- if o == '-f': force = 1
- if o == '-q': quiet = 1
- if o == '-x':
- import re
- rx = re.compile(a)
- if ddir:
- if len(args) != 1:
- print("-d destdir require exactly one directory argument")
- sys.exit(2)
- success = 1
+ import argparse
+
+ parser = argparse.ArgumentParser(
+ description='Utilities to support installing Python libraries.')
+ parser.add_argument('-l', action='store_const', const=0,
+ default=10, dest='maxlevels',
+ help="don't recurse into subdirectories")
+ parser.add_argument('-f', action='store_true', dest='force',
+ help='force rebuild even if timestamps are up to date')
+ parser.add_argument('-q', action='store_true', dest='quiet',
+ help='output only error messages')
+ parser.add_argument('-b', action='store_true', dest='legacy',
+ help='use legacy (pre-PEP3147) compiled file locations')
+ parser.add_argument('-d', metavar='DESTDIR', dest='ddir', default=None,
+ help=('directory to prepend to file paths for use in '
+ 'compile time tracebacks and in runtime '
+ 'tracebacks in cases where the source file is '
+ 'unavailable'))
+ parser.add_argument('-x', metavar='REGEXP', dest='rx', default=None,
+ help=('skip files matching the regular expression. '
+ 'The regexp is searched for in the full path '
+ 'to each file considered for compilation.'))
+ parser.add_argument('-i', metavar='FILE', dest='flist',
+ help=('add all the files and directories listed in '
+ 'FILE to the list considered for compilation. '
+ 'If "-", names are read from stdin.'))
+ parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='*',
+ help=('zero or more file and directory names '
+ 'to compile; if no arguments given, defaults '
+ 'to the equivalent of -l sys.path'))
+ args = parser.parse_args()
+
+ compile_dests = args.compile_dest
+
+ if (args.ddir and (len(compile_dests) != 1
+ or not os.path.isdir(compile_dests[0]))):
+ parser.exit('-d destdir requires exactly one directory argument')
+ if args.rx:
+ import re
+ args.rx = re.compile(args.rx)
+
+ # if flist is provided then load it
+ if args.flist:
+ try:
+ with (sys.stdin if args.flist=='-' else open(args.flist)) as f:
+ for line in f:
+ compile_dests.append(line.strip())
+ except EnvironmentError:
+ print("Error reading file list {}".format(args.flist))
+ return False
+
+ success = True
try:
- if args:
- for dir in args:
- if not compile_dir(dir, maxlevels, ddir,
- force, rx, quiet):
- success = 0
+ if compile_dests:
+ for dest in compile_dests:
+ if os.path.isfile(dest):
+ if not compile_file(dest, args.ddir, args.force, args.rx,
+ args.quiet, args.legacy):
+ success = False
+ else:
+ if not compile_dir(dest, args.maxlevels, args.ddir,
+ args.force, args.rx, args.quiet,
+ args.legacy):
+ success = False
+ return success
else:
- success = compile_path()
+ return compile_path(legacy=args.legacy)
except KeyboardInterrupt:
- print("\n[interrupt]")
- success = 0
- return success
+ print("\n[interrupted]")
+ return False
+ return True
+
if __name__ == '__main__':
exit_status = int(not main())
diff --git a/Lib/concurrent/__init__.py b/Lib/concurrent/__init__.py
new file mode 100644
index 0000000000..196d378857
--- /dev/null
+++ b/Lib/concurrent/__init__.py
@@ -0,0 +1 @@
+# This directory is a Python package.
diff --git a/Lib/concurrent/futures/__init__.py b/Lib/concurrent/futures/__init__.py
new file mode 100644
index 0000000000..b5231f8aab
--- /dev/null
+++ b/Lib/concurrent/futures/__init__.py
@@ -0,0 +1,18 @@
+# Copyright 2009 Brian Quinlan. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+"""Execute computations asynchronously using threads or processes."""
+
+__author__ = 'Brian Quinlan (brian@sweetapp.com)'
+
+from concurrent.futures._base import (FIRST_COMPLETED,
+ FIRST_EXCEPTION,
+ ALL_COMPLETED,
+ CancelledError,
+ TimeoutError,
+ Future,
+ Executor,
+ wait,
+ as_completed)
+from concurrent.futures.process import ProcessPoolExecutor
+from concurrent.futures.thread import ThreadPoolExecutor
diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py
new file mode 100644
index 0000000000..79b91d495f
--- /dev/null
+++ b/Lib/concurrent/futures/_base.py
@@ -0,0 +1,567 @@
+# Copyright 2009 Brian Quinlan. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+__author__ = 'Brian Quinlan (brian@sweetapp.com)'
+
+import collections
+import functools
+import logging
+import threading
+import time
+
+FIRST_COMPLETED = 'FIRST_COMPLETED'
+FIRST_EXCEPTION = 'FIRST_EXCEPTION'
+ALL_COMPLETED = 'ALL_COMPLETED'
+_AS_COMPLETED = '_AS_COMPLETED'
+
+# Possible future states (for internal use by the futures package).
+PENDING = 'PENDING'
+RUNNING = 'RUNNING'
+# The future was cancelled by the user...
+CANCELLED = 'CANCELLED'
+# ...and _Waiter.add_cancelled() was called by a worker.
+CANCELLED_AND_NOTIFIED = 'CANCELLED_AND_NOTIFIED'
+FINISHED = 'FINISHED'
+
+_FUTURE_STATES = [
+ PENDING,
+ RUNNING,
+ CANCELLED,
+ CANCELLED_AND_NOTIFIED,
+ FINISHED
+]
+
+_STATE_TO_DESCRIPTION_MAP = {
+ PENDING: "pending",
+ RUNNING: "running",
+ CANCELLED: "cancelled",
+ CANCELLED_AND_NOTIFIED: "cancelled",
+ FINISHED: "finished"
+}
+
+# Logger for internal use by the futures package.
+LOGGER = logging.getLogger("concurrent.futures")
+
+class Error(Exception):
+ """Base class for all future-related exceptions."""
+ pass
+
+class CancelledError(Error):
+ """The Future was cancelled."""
+ pass
+
+class TimeoutError(Error):
+ """The operation exceeded the given deadline."""
+ pass
+
+class _Waiter(object):
+ """Provides the event that wait() and as_completed() block on."""
+ def __init__(self):
+ self.event = threading.Event()
+ self.finished_futures = []
+
+ def add_result(self, future):
+ self.finished_futures.append(future)
+
+ def add_exception(self, future):
+ self.finished_futures.append(future)
+
+ def add_cancelled(self, future):
+ self.finished_futures.append(future)
+
+class _AsCompletedWaiter(_Waiter):
+ """Used by as_completed()."""
+
+ def __init__(self):
+ super(_AsCompletedWaiter, self).__init__()
+ self.lock = threading.Lock()
+
+ def add_result(self, future):
+ with self.lock:
+ super(_AsCompletedWaiter, self).add_result(future)
+ self.event.set()
+
+ def add_exception(self, future):
+ with self.lock:
+ super(_AsCompletedWaiter, self).add_exception(future)
+ self.event.set()
+
+ def add_cancelled(self, future):
+ with self.lock:
+ super(_AsCompletedWaiter, self).add_cancelled(future)
+ self.event.set()
+
+class _FirstCompletedWaiter(_Waiter):
+ """Used by wait(return_when=FIRST_COMPLETED)."""
+
+ def add_result(self, future):
+ super().add_result(future)
+ self.event.set()
+
+ def add_exception(self, future):
+ super().add_exception(future)
+ self.event.set()
+
+ def add_cancelled(self, future):
+ super().add_cancelled(future)
+ self.event.set()
+
+class _AllCompletedWaiter(_Waiter):
+ """Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED)."""
+
+ def __init__(self, num_pending_calls, stop_on_exception):
+ self.num_pending_calls = num_pending_calls
+ self.stop_on_exception = stop_on_exception
+ super().__init__()
+
+ def _decrement_pending_calls(self):
+ self.num_pending_calls -= 1
+ if not self.num_pending_calls:
+ self.event.set()
+
+ def add_result(self, future):
+ super().add_result(future)
+ self._decrement_pending_calls()
+
+ def add_exception(self, future):
+ super().add_exception(future)
+ if self.stop_on_exception:
+ self.event.set()
+ else:
+ self._decrement_pending_calls()
+
+ def add_cancelled(self, future):
+ super().add_cancelled(future)
+ self._decrement_pending_calls()
+
+class _AcquireFutures(object):
+ """A context manager that does an ordered acquire of Future conditions."""
+
+ def __init__(self, futures):
+ self.futures = sorted(futures, key=id)
+
+ def __enter__(self):
+ for future in self.futures:
+ future._condition.acquire()
+
+ def __exit__(self, *args):
+ for future in self.futures:
+ future._condition.release()
+
+def _create_and_install_waiters(fs, return_when):
+ if return_when == _AS_COMPLETED:
+ waiter = _AsCompletedWaiter()
+ elif return_when == FIRST_COMPLETED:
+ waiter = _FirstCompletedWaiter()
+ else:
+ pending_count = sum(
+ f._state not in [CANCELLED_AND_NOTIFIED, FINISHED] for f in fs)
+
+ if return_when == FIRST_EXCEPTION:
+ waiter = _AllCompletedWaiter(pending_count, stop_on_exception=True)
+ elif return_when == ALL_COMPLETED:
+ waiter = _AllCompletedWaiter(pending_count, stop_on_exception=False)
+ else:
+ raise ValueError("Invalid return condition: %r" % return_when)
+
+ for f in fs:
+ f._waiters.append(waiter)
+
+ return waiter
+
+def as_completed(fs, timeout=None):
+ """An iterator over the given futures that yields each as it completes.
+
+ Args:
+ fs: The sequence of Futures (possibly created by different Executors) to
+ iterate over.
+ timeout: The maximum number of seconds to wait. If None, then there
+ is no limit on the wait time.
+
+ Returns:
+ An iterator that yields the given Futures as they complete (finished or
+ cancelled).
+
+ Raises:
+ TimeoutError: If the entire result iterator could not be generated
+ before the given timeout.
+ """
+ if timeout is not None:
+ end_time = timeout + time.time()
+
+ with _AcquireFutures(fs):
+ finished = set(
+ f for f in fs
+ if f._state in [CANCELLED_AND_NOTIFIED, FINISHED])
+ pending = set(fs) - finished
+ waiter = _create_and_install_waiters(fs, _AS_COMPLETED)
+
+ try:
+ for future in finished:
+ yield future
+
+ while pending:
+ if timeout is None:
+ wait_timeout = None
+ else:
+ wait_timeout = end_time - time.time()
+ if wait_timeout < 0:
+ raise TimeoutError(
+ '%d (of %d) futures unfinished' % (
+ len(pending), len(fs)))
+
+ waiter.event.wait(wait_timeout)
+
+ with waiter.lock:
+ finished = waiter.finished_futures
+ waiter.finished_futures = []
+ waiter.event.clear()
+
+ for future in finished:
+ yield future
+ pending.remove(future)
+
+ finally:
+ for f in fs:
+ f._waiters.remove(waiter)
+
+DoneAndNotDoneFutures = collections.namedtuple(
+ 'DoneAndNotDoneFutures', 'done not_done')
+def wait(fs, timeout=None, return_when=ALL_COMPLETED):
+ """Wait for the futures in the given sequence to complete.
+
+ Args:
+ fs: The sequence of Futures (possibly created by different Executors) to
+ wait upon.
+ timeout: The maximum number of seconds to wait. If None, then there
+ is no limit on the wait time.
+ return_when: Indicates when this function should return. The options
+ are:
+
+ FIRST_COMPLETED - Return when any future finishes or is
+ cancelled.
+ FIRST_EXCEPTION - Return when any future finishes by raising an
+ exception. If no future raises an exception
+ then it is equivalent to ALL_COMPLETED.
+ ALL_COMPLETED - Return when all futures finish or are cancelled.
+
+ Returns:
+ A named 2-tuple of sets. The first set, named 'done', contains the
+ futures that completed (is finished or cancelled) before the wait
+ completed. The second set, named 'not_done', contains uncompleted
+ futures.
+ """
+ with _AcquireFutures(fs):
+ done = set(f for f in fs
+ if f._state in [CANCELLED_AND_NOTIFIED, FINISHED])
+ not_done = set(fs) - done
+
+ if (return_when == FIRST_COMPLETED) and done:
+ return DoneAndNotDoneFutures(done, not_done)
+ elif (return_when == FIRST_EXCEPTION) and done:
+ if any(f for f in done
+ if not f.cancelled() and f.exception() is not None):
+ return DoneAndNotDoneFutures(done, not_done)
+
+ if len(done) == len(fs):
+ return DoneAndNotDoneFutures(done, not_done)
+
+ waiter = _create_and_install_waiters(fs, return_when)
+
+ waiter.event.wait(timeout)
+ for f in fs:
+ f._waiters.remove(waiter)
+
+ done.update(waiter.finished_futures)
+ return DoneAndNotDoneFutures(done, set(fs) - done)
+
+class Future(object):
+ """Represents the result of an asynchronous computation."""
+
+ def __init__(self):
+ """Initializes the future. Should not be called by clients."""
+ self._condition = threading.Condition()
+ self._state = PENDING
+ self._result = None
+ self._exception = None
+ self._waiters = []
+ self._done_callbacks = []
+
+ def _invoke_callbacks(self):
+ for callback in self._done_callbacks:
+ try:
+ callback(self)
+ except Exception:
+ LOGGER.exception('exception calling callback for %r', self)
+
+ def __repr__(self):
+ with self._condition:
+ if self._state == FINISHED:
+ if self._exception:
+ return '<Future at %s state=%s raised %s>' % (
+ hex(id(self)),
+ _STATE_TO_DESCRIPTION_MAP[self._state],
+ self._exception.__class__.__name__)
+ else:
+ return '<Future at %s state=%s returned %s>' % (
+ hex(id(self)),
+ _STATE_TO_DESCRIPTION_MAP[self._state],
+ self._result.__class__.__name__)
+ return '<Future at %s state=%s>' % (
+ hex(id(self)),
+ _STATE_TO_DESCRIPTION_MAP[self._state])
+
+ def cancel(self):
+ """Cancel the future if possible.
+
+ Returns True if the future was cancelled, False otherwise. A future
+ cannot be cancelled if it is running or has already completed.
+ """
+ with self._condition:
+ if self._state in [RUNNING, FINISHED]:
+ return False
+
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ return True
+
+ self._state = CANCELLED
+ self._condition.notify_all()
+
+ self._invoke_callbacks()
+ return True
+
+ def cancelled(self):
+ """Return True if the future has cancelled."""
+ with self._condition:
+ return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]
+
+ def running(self):
+ """Return True if the future is currently executing."""
+ with self._condition:
+ return self._state == RUNNING
+
+ def done(self):
+ """Return True of the future was cancelled or finished executing."""
+ with self._condition:
+ return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]
+
+ def __get_result(self):
+ if self._exception:
+ raise self._exception
+ else:
+ return self._result
+
+ def add_done_callback(self, fn):
+ """Attaches a callable that will be called when the future finishes.
+
+ Args:
+ fn: A callable that will be called with this future as its only
+ argument when the future completes or is cancelled. The callable
+ will always be called by a thread in the same process in which
+ it was added. If the future has already completed or been
+ cancelled then the callable will be called immediately. These
+ callables are called in the order that they were added.
+ """
+ with self._condition:
+ if self._state not in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]:
+ self._done_callbacks.append(fn)
+ return
+ fn(self)
+
+ def result(self, timeout=None):
+ """Return the result of the call that the future represents.
+
+ Args:
+ timeout: The number of seconds to wait for the result if the future
+ isn't done. If None, then there is no limit on the wait time.
+
+ Returns:
+ The result of the call that the future represents.
+
+ Raises:
+ CancelledError: If the future was cancelled.
+ TimeoutError: If the future didn't finish executing before the given
+ timeout.
+ Exception: If the call raised then that exception will be raised.
+ """
+ with self._condition:
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ raise CancelledError()
+ elif self._state == FINISHED:
+ return self.__get_result()
+
+ self._condition.wait(timeout)
+
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ raise CancelledError()
+ elif self._state == FINISHED:
+ return self.__get_result()
+ else:
+ raise TimeoutError()
+
+ def exception(self, timeout=None):
+ """Return the exception raised by the call that the future represents.
+
+ Args:
+ timeout: The number of seconds to wait for the exception if the
+ future isn't done. If None, then there is no limit on the wait
+ time.
+
+ Returns:
+ The exception raised by the call that the future represents or None
+ if the call completed without raising.
+
+ Raises:
+ CancelledError: If the future was cancelled.
+ TimeoutError: If the future didn't finish executing before the given
+ timeout.
+ """
+
+ with self._condition:
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ raise CancelledError()
+ elif self._state == FINISHED:
+ return self._exception
+
+ self._condition.wait(timeout)
+
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ raise CancelledError()
+ elif self._state == FINISHED:
+ return self._exception
+ else:
+ raise TimeoutError()
+
+ # The following methods should only be used by Executors and in tests.
+ def set_running_or_notify_cancel(self):
+ """Mark the future as running or process any cancel notifications.
+
+ Should only be used by Executor implementations and unit tests.
+
+ If the future has been cancelled (cancel() was called and returned
+ True) then any threads waiting on the future completing (though calls
+ to as_completed() or wait()) are notified and False is returned.
+
+ If the future was not cancelled then it is put in the running state
+ (future calls to running() will return True) and True is returned.
+
+ This method should be called by Executor implementations before
+ executing the work associated with this future. If this method returns
+ False then the work should not be executed.
+
+ Returns:
+ False if the Future was cancelled, True otherwise.
+
+ Raises:
+ RuntimeError: if this method was already called or if set_result()
+ or set_exception() was called.
+ """
+ with self._condition:
+ if self._state == CANCELLED:
+ self._state = CANCELLED_AND_NOTIFIED
+ for waiter in self._waiters:
+ waiter.add_cancelled(self)
+ # self._condition.notify_all() is not necessary because
+ # self.cancel() triggers a notification.
+ return False
+ elif self._state == PENDING:
+ self._state = RUNNING
+ return True
+ else:
+ LOGGER.critical('Future %s in unexpected state: %s',
+ id(self.future),
+ self.future._state)
+ raise RuntimeError('Future in unexpected state')
+
+ def set_result(self, result):
+ """Sets the return value of work associated with the future.
+
+ Should only be used by Executor implementations and unit tests.
+ """
+ with self._condition:
+ self._result = result
+ self._state = FINISHED
+ for waiter in self._waiters:
+ waiter.add_result(self)
+ self._condition.notify_all()
+ self._invoke_callbacks()
+
+ def set_exception(self, exception):
+ """Sets the result of the future as being the given exception.
+
+ Should only be used by Executor implementations and unit tests.
+ """
+ with self._condition:
+ self._exception = exception
+ self._state = FINISHED
+ for waiter in self._waiters:
+ waiter.add_exception(self)
+ self._condition.notify_all()
+ self._invoke_callbacks()
+
+class Executor(object):
+ """This is an abstract base class for concrete asynchronous executors."""
+
+ def submit(self, fn, *args, **kwargs):
+ """Submits a callable to be executed with the given arguments.
+
+ Schedules the callable to be executed as fn(*args, **kwargs) and returns
+ a Future instance representing the execution of the callable.
+
+ Returns:
+ A Future representing the given call.
+ """
+ raise NotImplementedError()
+
+ def map(self, fn, *iterables, timeout=None):
+ """Returns a iterator equivalent to map(fn, iter).
+
+ Args:
+ fn: A callable that will take take as many arguments as there are
+ passed iterables.
+ timeout: The maximum number of seconds to wait. If None, then there
+ is no limit on the wait time.
+
+ Returns:
+ An iterator equivalent to: map(func, *iterables) but the calls may
+ be evaluated out-of-order.
+
+ Raises:
+ TimeoutError: If the entire result iterator could not be generated
+ before the given timeout.
+ Exception: If fn(*args) raises for any values.
+ """
+ if timeout is not None:
+ end_time = timeout + time.time()
+
+ fs = [self.submit(fn, *args) for args in zip(*iterables)]
+
+ try:
+ for future in fs:
+ if timeout is None:
+ yield future.result()
+ else:
+ yield future.result(end_time - time.time())
+ finally:
+ for future in fs:
+ future.cancel()
+
+ def shutdown(self, wait=True):
+ """Clean-up the resources associated with the Executor.
+
+ It is safe to call this method several times. Otherwise, no other
+ methods can be called after this one.
+
+ Args:
+ wait: If True then shutdown will not return until all running
+ futures have finished executing and the resources used by the
+ executor have been reclaimed.
+ """
+ pass
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self.shutdown(wait=True)
+ return False
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py
new file mode 100644
index 0000000000..79c60c3d10
--- /dev/null
+++ b/Lib/concurrent/futures/process.py
@@ -0,0 +1,363 @@
+# Copyright 2009 Brian Quinlan. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+"""Implements ProcessPoolExecutor.
+
+The follow diagram and text describe the data-flow through the system:
+
+|======================= In-process =====================|== Out-of-process ==|
+
++----------+ +----------+ +--------+ +-----------+ +---------+
+| | => | Work Ids | => | | => | Call Q | => | |
+| | +----------+ | | +-----------+ | |
+| | | ... | | | | ... | | |
+| | | 6 | | | | 5, call() | | |
+| | | 7 | | | | ... | | |
+| Process | | ... | | Local | +-----------+ | Process |
+| Pool | +----------+ | Worker | | #1..n |
+| Executor | | Thread | | |
+| | +----------- + | | +-----------+ | |
+| | <=> | Work Items | <=> | | <= | Result Q | <= | |
+| | +------------+ | | +-----------+ | |
+| | | 6: call() | | | | ... | | |
+| | | future | | | | 4, result | | |
+| | | ... | | | | 3, except | | |
++----------+ +------------+ +--------+ +-----------+ +---------+
+
+Executor.submit() called:
+- creates a uniquely numbered _WorkItem and adds it to the "Work Items" dict
+- adds the id of the _WorkItem to the "Work Ids" queue
+
+Local worker thread:
+- reads work ids from the "Work Ids" queue and looks up the corresponding
+ WorkItem from the "Work Items" dict: if the work item has been cancelled then
+ it is simply removed from the dict, otherwise it is repackaged as a
+ _CallItem and put in the "Call Q". New _CallItems are put in the "Call Q"
+ until "Call Q" is full. NOTE: the size of the "Call Q" is kept small because
+ calls placed in the "Call Q" can no longer be cancelled with Future.cancel().
+- reads _ResultItems from "Result Q", updates the future stored in the
+ "Work Items" dict and deletes the dict entry
+
+Process #1..n:
+- reads _CallItems from "Call Q", executes the calls, and puts the resulting
+ _ResultItems in "Request Q"
+"""
+
+__author__ = 'Brian Quinlan (brian@sweetapp.com)'
+
+import atexit
+from concurrent.futures import _base
+import queue
+import multiprocessing
+import threading
+import weakref
+
+# Workers are created as daemon threads and processes. This is done to allow the
+# interpreter to exit when there are still idle processes in a
+# ProcessPoolExecutor's process pool (i.e. shutdown() was not called). However,
+# allowing workers to die with the interpreter has two undesirable properties:
+# - The workers would still be running during interpretor shutdown,
+# meaning that they would fail in unpredictable ways.
+# - The workers could be killed while evaluating a work item, which could
+# be bad if the callable being evaluated has external side-effects e.g.
+# writing to a file.
+#
+# To work around this problem, an exit handler is installed which tells the
+# workers to exit when their work queues are empty and then waits until the
+# threads/processes finish.
+
+_thread_references = set()
+_shutdown = False
+
+def _python_exit():
+ global _shutdown
+ _shutdown = True
+ for thread_reference in _thread_references:
+ thread = thread_reference()
+ if thread is not None:
+ thread.join()
+
+def _remove_dead_thread_references():
+ """Remove inactive threads from _thread_references.
+
+ Should be called periodically to prevent memory leaks in scenarios such as:
+ >>> while True:
+ >>> ... t = ThreadPoolExecutor(max_workers=5)
+ >>> ... t.map(int, ['1', '2', '3', '4', '5'])
+ """
+ for thread_reference in set(_thread_references):
+ if thread_reference() is None:
+ _thread_references.discard(thread_reference)
+
+# Controls how many more calls than processes will be queued in the call queue.
+# A smaller number will mean that processes spend more time idle waiting for
+# work while a larger number will make Future.cancel() succeed less frequently
+# (Futures in the call queue cannot be cancelled).
+EXTRA_QUEUED_CALLS = 1
+
+class _WorkItem(object):
+ def __init__(self, future, fn, args, kwargs):
+ self.future = future
+ self.fn = fn
+ self.args = args
+ self.kwargs = kwargs
+
+class _ResultItem(object):
+ def __init__(self, work_id, exception=None, result=None):
+ self.work_id = work_id
+ self.exception = exception
+ self.result = result
+
+class _CallItem(object):
+ def __init__(self, work_id, fn, args, kwargs):
+ self.work_id = work_id
+ self.fn = fn
+ self.args = args
+ self.kwargs = kwargs
+
+def _process_worker(call_queue, result_queue, shutdown):
+ """Evaluates calls from call_queue and places the results in result_queue.
+
+ This worker is run in a separate process.
+
+ Args:
+ call_queue: A multiprocessing.Queue of _CallItems that will be read and
+ evaluated by the worker.
+ result_queue: A multiprocessing.Queue of _ResultItems that will written
+ to by the worker.
+ shutdown: A multiprocessing.Event that will be set as a signal to the
+ worker that it should exit when call_queue is empty.
+ """
+ while True:
+ try:
+ call_item = call_queue.get(block=True, timeout=0.1)
+ except queue.Empty:
+ if shutdown.is_set():
+ return
+ else:
+ try:
+ r = call_item.fn(*call_item.args, **call_item.kwargs)
+ except BaseException as e:
+ result_queue.put(_ResultItem(call_item.work_id,
+ exception=e))
+ else:
+ result_queue.put(_ResultItem(call_item.work_id,
+ result=r))
+
+def _add_call_item_to_queue(pending_work_items,
+ work_ids,
+ call_queue):
+ """Fills call_queue with _WorkItems from pending_work_items.
+
+ This function never blocks.
+
+ Args:
+ pending_work_items: A dict mapping work ids to _WorkItems e.g.
+ {5: <_WorkItem...>, 6: <_WorkItem...>, ...}
+ work_ids: A queue.Queue of work ids e.g. Queue([5, 6, ...]). Work ids
+ are consumed and the corresponding _WorkItems from
+ pending_work_items are transformed into _CallItems and put in
+ call_queue.
+ call_queue: A multiprocessing.Queue that will be filled with _CallItems
+ derived from _WorkItems.
+ """
+ while True:
+ if call_queue.full():
+ return
+ try:
+ work_id = work_ids.get(block=False)
+ except queue.Empty:
+ return
+ else:
+ work_item = pending_work_items[work_id]
+
+ if work_item.future.set_running_or_notify_cancel():
+ call_queue.put(_CallItem(work_id,
+ work_item.fn,
+ work_item.args,
+ work_item.kwargs),
+ block=True)
+ else:
+ del pending_work_items[work_id]
+ continue
+
+def _queue_manangement_worker(executor_reference,
+ processes,
+ pending_work_items,
+ work_ids_queue,
+ call_queue,
+ result_queue,
+ shutdown_process_event):
+ """Manages the communication between this process and the worker processes.
+
+ This function is run in a local thread.
+
+ Args:
+ executor_reference: A weakref.ref to the ProcessPoolExecutor that owns
+ this thread. Used to determine if the ProcessPoolExecutor has been
+ garbage collected and that this function can exit.
+ process: A list of the multiprocessing.Process instances used as
+ workers.
+ pending_work_items: A dict mapping work ids to _WorkItems e.g.
+ {5: <_WorkItem...>, 6: <_WorkItem...>, ...}
+ work_ids_queue: A queue.Queue of work ids e.g. Queue([5, 6, ...]).
+ call_queue: A multiprocessing.Queue that will be filled with _CallItems
+ derived from _WorkItems for processing by the process workers.
+ result_queue: A multiprocessing.Queue of _ResultItems generated by the
+ process workers.
+ shutdown_process_event: A multiprocessing.Event used to signal the
+ process workers that they should exit when their work queue is
+ empty.
+ """
+ while True:
+ _add_call_item_to_queue(pending_work_items,
+ work_ids_queue,
+ call_queue)
+
+ try:
+ result_item = result_queue.get(block=True, timeout=0.1)
+ except queue.Empty:
+ executor = executor_reference()
+ # No more work items can be added if:
+ # - The interpreter is shutting down OR
+ # - The executor that owns this worker has been collected OR
+ # - The executor that owns this worker has been shutdown.
+ if _shutdown or executor is None or executor._shutdown_thread:
+ # Since no new work items can be added, it is safe to shutdown
+ # this thread if there are no pending work items.
+ if not pending_work_items:
+ shutdown_process_event.set()
+
+ # If .join() is not called on the created processes then
+ # some multiprocessing.Queue methods may deadlock on Mac OS
+ # X.
+ for p in processes:
+ p.join()
+ return
+ del executor
+ else:
+ work_item = pending_work_items[result_item.work_id]
+ del pending_work_items[result_item.work_id]
+
+ if result_item.exception:
+ work_item.future.set_exception(result_item.exception)
+ else:
+ work_item.future.set_result(result_item.result)
+
+_system_limits_checked = False
+_system_limited = None
+def _check_system_limits():
+ global _system_limits_checked, _system_limited
+ if _system_limits_checked:
+ if _system_limited:
+ raise NotImplementedError(_system_limited)
+ _system_limits_checked = True
+ try:
+ import os
+ nsems_max = os.sysconf("SC_SEM_NSEMS_MAX")
+ except (AttributeError, ValueError):
+ # sysconf not available or setting not available
+ return
+ if nsems_max == -1:
+ # indetermine limit, assume that limit is determined
+ # by available memory only
+ return
+ if nsems_max >= 256:
+ # minimum number of semaphores available
+ # according to POSIX
+ return
+ _system_limited = "system provides too few semaphores (%d available, 256 necessary)" % nsems_max
+ raise NotImplementedError(_system_limited)
+
+class ProcessPoolExecutor(_base.Executor):
+ def __init__(self, max_workers=None):
+ """Initializes a new ProcessPoolExecutor instance.
+
+ Args:
+ max_workers: The maximum number of processes that can be used to
+ execute the given calls. If None or not given then as many
+ worker processes will be created as the machine has processors.
+ """
+ _check_system_limits()
+ _remove_dead_thread_references()
+
+ if max_workers is None:
+ self._max_workers = multiprocessing.cpu_count()
+ else:
+ self._max_workers = max_workers
+
+ # Make the call queue slightly larger than the number of processes to
+ # prevent the worker processes from idling. But don't make it too big
+ # because futures in the call queue cannot be cancelled.
+ self._call_queue = multiprocessing.Queue(self._max_workers +
+ EXTRA_QUEUED_CALLS)
+ self._result_queue = multiprocessing.Queue()
+ self._work_ids = queue.Queue()
+ self._queue_management_thread = None
+ self._processes = set()
+
+ # Shutdown is a two-step process.
+ self._shutdown_thread = False
+ self._shutdown_process_event = multiprocessing.Event()
+ self._shutdown_lock = threading.Lock()
+ self._queue_count = 0
+ self._pending_work_items = {}
+
+ def _start_queue_management_thread(self):
+ if self._queue_management_thread is None:
+ self._queue_management_thread = threading.Thread(
+ target=_queue_manangement_worker,
+ args=(weakref.ref(self),
+ self._processes,
+ self._pending_work_items,
+ self._work_ids,
+ self._call_queue,
+ self._result_queue,
+ self._shutdown_process_event))
+ self._queue_management_thread.daemon = True
+ self._queue_management_thread.start()
+ _thread_references.add(weakref.ref(self._queue_management_thread))
+
+ def _adjust_process_count(self):
+ for _ in range(len(self._processes), self._max_workers):
+ p = multiprocessing.Process(
+ target=_process_worker,
+ args=(self._call_queue,
+ self._result_queue,
+ self._shutdown_process_event))
+ p.start()
+ self._processes.add(p)
+
+ def submit(self, fn, *args, **kwargs):
+ with self._shutdown_lock:
+ if self._shutdown_thread:
+ raise RuntimeError('cannot schedule new futures after shutdown')
+
+ f = _base.Future()
+ w = _WorkItem(f, fn, args, kwargs)
+
+ self._pending_work_items[self._queue_count] = w
+ self._work_ids.put(self._queue_count)
+ self._queue_count += 1
+
+ self._start_queue_management_thread()
+ self._adjust_process_count()
+ return f
+ submit.__doc__ = _base.Executor.submit.__doc__
+
+ def shutdown(self, wait=True):
+ with self._shutdown_lock:
+ self._shutdown_thread = True
+ if wait:
+ if self._queue_management_thread:
+ self._queue_management_thread.join()
+ # To reduce the risk of openning too many files, remove references to
+ # objects that use file descriptors.
+ self._queue_management_thread = None
+ self._call_queue = None
+ self._result_queue = None
+ self._shutdown_process_event = None
+ self._processes = None
+ shutdown.__doc__ = _base.Executor.shutdown.__doc__
+
+atexit.register(_python_exit)
diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py
new file mode 100644
index 0000000000..15736daa52
--- /dev/null
+++ b/Lib/concurrent/futures/thread.py
@@ -0,0 +1,136 @@
+# Copyright 2009 Brian Quinlan. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+"""Implements ThreadPoolExecutor."""
+
+__author__ = 'Brian Quinlan (brian@sweetapp.com)'
+
+import atexit
+from concurrent.futures import _base
+import queue
+import threading
+import weakref
+
+# Workers are created as daemon threads. This is done to allow the interpreter
+# to exit when there are still idle threads in a ThreadPoolExecutor's thread
+# pool (i.e. shutdown() was not called). However, allowing workers to die with
+# the interpreter has two undesirable properties:
+# - The workers would still be running during interpretor shutdown,
+# meaning that they would fail in unpredictable ways.
+# - The workers could be killed while evaluating a work item, which could
+# be bad if the callable being evaluated has external side-effects e.g.
+# writing to a file.
+#
+# To work around this problem, an exit handler is installed which tells the
+# workers to exit when their work queues are empty and then waits until the
+# threads finish.
+
+_thread_references = set()
+_shutdown = False
+
+def _python_exit():
+ global _shutdown
+ _shutdown = True
+ for thread_reference in _thread_references:
+ thread = thread_reference()
+ if thread is not None:
+ thread.join()
+
+def _remove_dead_thread_references():
+ """Remove inactive threads from _thread_references.
+
+ Should be called periodically to prevent memory leaks in scenarios such as:
+ >>> while True:
+ ... t = ThreadPoolExecutor(max_workers=5)
+ ... t.map(int, ['1', '2', '3', '4', '5'])
+ """
+ for thread_reference in set(_thread_references):
+ if thread_reference() is None:
+ _thread_references.discard(thread_reference)
+
+atexit.register(_python_exit)
+
+class _WorkItem(object):
+ def __init__(self, future, fn, args, kwargs):
+ self.future = future
+ self.fn = fn
+ self.args = args
+ self.kwargs = kwargs
+
+ def run(self):
+ if not self.future.set_running_or_notify_cancel():
+ return
+
+ try:
+ result = self.fn(*self.args, **self.kwargs)
+ except BaseException as e:
+ self.future.set_exception(e)
+ else:
+ self.future.set_result(result)
+
+def _worker(executor_reference, work_queue):
+ try:
+ while True:
+ try:
+ work_item = work_queue.get(block=True, timeout=0.1)
+ except queue.Empty:
+ executor = executor_reference()
+ # Exit if:
+ # - The interpreter is shutting down OR
+ # - The executor that owns the worker has been collected OR
+ # - The executor that owns the worker has been shutdown.
+ if _shutdown or executor is None or executor._shutdown:
+ return
+ del executor
+ else:
+ work_item.run()
+ except BaseException as e:
+ _base.LOGGER.critical('Exception in worker', exc_info=True)
+
+class ThreadPoolExecutor(_base.Executor):
+ def __init__(self, max_workers):
+ """Initializes a new ThreadPoolExecutor instance.
+
+ Args:
+ max_workers: The maximum number of threads that can be used to
+ execute the given calls.
+ """
+ _remove_dead_thread_references()
+
+ self._max_workers = max_workers
+ self._work_queue = queue.Queue()
+ self._threads = set()
+ self._shutdown = False
+ self._shutdown_lock = threading.Lock()
+
+ def submit(self, fn, *args, **kwargs):
+ with self._shutdown_lock:
+ if self._shutdown:
+ raise RuntimeError('cannot schedule new futures after shutdown')
+
+ f = _base.Future()
+ w = _WorkItem(f, fn, args, kwargs)
+
+ self._work_queue.put(w)
+ self._adjust_thread_count()
+ return f
+ submit.__doc__ = _base.Executor.submit.__doc__
+
+ def _adjust_thread_count(self):
+ # TODO(bquinlan): Should avoid creating new threads if there are more
+ # idle threads than items in the work queue.
+ if len(self._threads) < self._max_workers:
+ t = threading.Thread(target=_worker,
+ args=(weakref.ref(self), self._work_queue))
+ t.daemon = True
+ t.start()
+ self._threads.add(t)
+ _thread_references.add(weakref.ref(t))
+
+ def shutdown(self, wait=True):
+ with self._shutdown_lock:
+ self._shutdown = True
+ if wait:
+ for t in self._threads:
+ t.join()
+ shutdown.__doc__ = _base.Executor.shutdown.__doc__
diff --git a/Lib/configparser.py b/Lib/configparser.py
index c7ae270759..1bfdac899c 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -1,102 +1,134 @@
"""Configuration file parser.
-A setup file consists of sections, lead by a "[section]" header,
+A configuration file consists of sections, lead by a "[section]" header,
and followed by "name: value" entries, with continuations and such in
the style of RFC 822.
-The option values can contain format strings which refer to other values in
-the same section, or values in a special [DEFAULT] section.
-
-For example:
-
- something: %(dir)s/whatever
-
-would resolve the "%(dir)s" to the value of dir. All reference
-expansions are done late, on demand.
-
Intrinsic defaults can be specified by passing them into the
ConfigParser constructor as a dictionary.
class:
ConfigParser -- responsible for parsing a list of
- configuration files, and managing the parsed database.
+ configuration files, and managing the parsed database.
methods:
- __init__(defaults=None)
- create the parser and specify a dictionary of intrinsic defaults. The
- keys must be strings, the values must be appropriate for %()s string
- interpolation. Note that `__name__' is always an intrinsic default;
- its value is the section's name.
+ __init__(defaults=None, dict_type=_default_dict, allow_no_value=False,
+ delimiters=('=', ':'), comment_prefixes=('#', ';'),
+ inline_comment_prefixes=None, strict=True,
+ empty_lines_in_values=True):
+ Create the parser. When `defaults' is given, it is initialized into the
+ dictionary or intrinsic defaults. The keys must be strings, the values
+ must be appropriate for %()s string interpolation.
+
+ When `dict_type' is given, it will be used to create the dictionary
+ objects for the list of sections, for the options within a section, and
+ for the default values.
+
+ When `delimiters' is given, it will be used as the set of substrings
+ that divide keys from values.
+
+ When `comment_prefixes' is given, it will be used as the set of
+ substrings that prefix comments in empty lines. Comments can be
+ indented.
+
+ When `inline_comment_prefixes' is given, it will be used as the set of
+ substrings that prefix comments in non-empty lines.
+
+ When `strict` is True, the parser won't allow for any section or option
+ duplicates while reading from a single source (file, string or
+ dictionary). Default is True.
+
+ When `empty_lines_in_values' is False (default: True), each empty line
+ marks the end of an option. Otherwise, internal empty lines of
+ a multiline option are kept as part of the value.
+
+ When `allow_no_value' is True (default: False), options without
+ values are accepted; the value presented for these is None.
sections()
- return all the configuration section names, sans DEFAULT
+ Return all the configuration section names, sans DEFAULT.
has_section(section)
- return whether the given section exists
+ Return whether the given section exists.
has_option(section, option)
- return whether the given option exists in the given section
+ Return whether the given option exists in the given section.
options(section)
- return list of configuration options for the named section
+ Return list of configuration options for the named section.
- read(filenames)
- read and parse the list of named configuration files, given by
+ read(filenames, encoding=None)
+ Read and parse the list of named configuration files, given by
name. A single filename is also allowed. Non-existing files
are ignored. Return list of successfully read files.
- readfp(fp, filename=None)
- read and parse one configuration file, given as a file object.
- The filename defaults to fp.name; it is only used in error
- messages (if fp has no `name' attribute, the string `<???>' is used).
+ read_file(f, filename=None)
+ Read and parse one configuration file, given as a file object.
+ The filename defaults to f.name; it is only used in error
+ messages (if f has no `name' attribute, the string `<???>' is used).
+
+ read_string(string)
+ Read configuration from a given string.
- get(section, option, raw=False, vars=None)
- return a string value for the named option. All % interpolations are
+ read_dict(dictionary)
+ Read configuration from a dictionary. Keys are section names,
+ values are dictionaries with keys and values that should be present
+ in the section. If the used dictionary type preserves order, sections
+ and their keys will be added in order. Values are automatically
+ converted to strings.
+
+ get(section, option, raw=False, vars=None, fallback=_UNSET)
+ Return a string value for the named option. All % interpolations are
expanded in the return values, based on the defaults passed into the
constructor and the DEFAULT section. Additional substitutions may be
provided using the `vars' argument, which must be a dictionary whose
- contents override any pre-existing defaults.
+ contents override any pre-existing defaults. If `option' is a key in
+ `vars', the value from `vars' is used.
- getint(section, options)
- like get(), but convert value to an integer
+ getint(section, options, raw=False, vars=None, fallback=_UNSET)
+ Like get(), but convert value to an integer.
- getfloat(section, options)
- like get(), but convert value to a float
+ getfloat(section, options, raw=False, vars=None, fallback=_UNSET)
+ Like get(), but convert value to a float.
- getboolean(section, options)
- like get(), but convert value to a boolean (currently case
+ getboolean(section, options, raw=False, vars=None, fallback=_UNSET)
+ Like get(), but convert value to a boolean (currently case
insensitively defined as 0, false, no, off for False, and 1, true,
yes, on for True). Returns False or True.
- items(section, raw=False, vars=None)
+ items(section=_UNSET, raw=False, vars=None)
+ If section is given, return a list of tuples with (section_name,
+ section_proxy) for each section, including DEFAULTSECT. Otherwise,
return a list of tuples with (name, value) for each option
in the section.
remove_section(section)
- remove the given file section and all its options
+ Remove the given file section and all its options.
remove_option(section, option)
- remove the given option from the given section
+ Remove the given option from the given section.
set(section, option, value)
- set the given option
+ Set the given option.
- write(fp)
- write the configuration state in .ini format
+ write(fp, space_around_delimiters=True)
+ Write the configuration state in .ini format. If
+ `space_around_delimiters' is True (the default), delimiters
+ between keys and values are surrounded by spaces.
"""
-try:
- from collections import OrderedDict as _default_dict
-except ImportError:
- # fallback for setup.py which hasn't yet built _collections
- _default_dict = dict
-
+from collections import MutableMapping, OrderedDict as _default_dict, _ChainMap
+import functools
+import io
+import itertools
import re
+import sys
+import warnings
-__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
- "InterpolationError", "InterpolationDepthError",
+__all__ = ["NoSectionError", "DuplicateOptionError", "DuplicateSectionError",
+ "NoOptionError", "InterpolationError", "InterpolationDepthError",
"InterpolationSyntaxError", "ParsingError",
"MissingSectionHeaderError",
"ConfigParser", "SafeConfigParser", "RawConfigParser",
@@ -114,12 +146,14 @@ class Error(Exception):
def _get_message(self):
"""Getter for 'message'; needed only to override deprecation in
- BaseException."""
+ BaseException.
+ """
return self.__message
def _set_message(self, value):
"""Setter for 'message'; needed only to override deprecation in
- BaseException."""
+ BaseException.
+ """
self.__message = value
# BaseException.message has been deprecated since Python 2.6. To prevent
@@ -136,19 +170,68 @@ class Error(Exception):
__str__ = __repr__
+
class NoSectionError(Error):
"""Raised when no section matches a requested option."""
def __init__(self, section):
Error.__init__(self, 'No section: %r' % (section,))
self.section = section
+ self.args = (section, )
+
class DuplicateSectionError(Error):
- """Raised when a section is multiply-created."""
+ """Raised when a section is repeated in an input source.
- def __init__(self, section):
- Error.__init__(self, "Section %r already exists" % section)
+ Possible repetitions that raise this exception are: multiple creation
+ using the API or in strict parsers when a section is found more than once
+ in a single input file, string or dictionary.
+ """
+
+ def __init__(self, section, source=None, lineno=None):
+ msg = [repr(section), " already exists"]
+ if source is not None:
+ message = ["While reading from ", source]
+ if lineno is not None:
+ message.append(" [line {0:2d}]".format(lineno))
+ message.append(": section ")
+ message.extend(msg)
+ msg = message
+ else:
+ msg.insert(0, "Section ")
+ Error.__init__(self, "".join(msg))
self.section = section
+ self.source = source
+ self.lineno = lineno
+ self.args = (section, source, lineno)
+
+
+class DuplicateOptionError(Error):
+ """Raised by strict parsers when an option is repeated in an input source.
+
+ Current implementation raises this exception only when an option is found
+ more than once in a single file, string or dictionary.
+ """
+
+ def __init__(self, section, option, source=None, lineno=None):
+ msg = [repr(option), " in section ", repr(section),
+ " already exists"]
+ if source is not None:
+ message = ["While reading from ", source]
+ if lineno is not None:
+ message.append(" [line {0:2d}]".format(lineno))
+ message.append(": option ")
+ message.extend(msg)
+ msg = message
+ else:
+ msg.insert(0, "Option ")
+ Error.__init__(self, "".join(msg))
+ self.section = section
+ self.option = option
+ self.source = source
+ self.lineno = lineno
+ self.args = (section, option, source, lineno)
+
class NoOptionError(Error):
"""A requested option was not found."""
@@ -158,6 +241,8 @@ class NoOptionError(Error):
(option, section))
self.option = option
self.section = section
+ self.args = (option, section)
+
class InterpolationError(Error):
"""Base class for interpolation-related exceptions."""
@@ -166,6 +251,8 @@ class InterpolationError(Error):
Error.__init__(self, msg)
self.option = option
self.section = section
+ self.args = (option, section, msg)
+
class InterpolationMissingOptionError(InterpolationError):
"""A string substitution required a setting which was not available."""
@@ -179,10 +266,16 @@ class InterpolationMissingOptionError(InterpolationError):
% (section, option, reference, rawval))
InterpolationError.__init__(self, option, section, msg)
self.reference = reference
+ self.args = (option, section, rawval, reference)
+
class InterpolationSyntaxError(InterpolationError):
- """Raised when the source text into which substitutions are made
- does not conform to the required syntax."""
+ """Raised when the source text contains invalid syntax.
+
+ Current implementation raises this exception when the source text into
+ which substitutions are made does not conform to the required syntax.
+ """
+
class InterpolationDepthError(InterpolationError):
"""Raised when substitutions are nested too deeply."""
@@ -194,19 +287,52 @@ class InterpolationDepthError(InterpolationError):
"\trawval : %s\n"
% (section, option, rawval))
InterpolationError.__init__(self, option, section, msg)
+ self.args = (option, section, rawval)
+
class ParsingError(Error):
"""Raised when a configuration file does not follow legal syntax."""
- def __init__(self, filename):
- Error.__init__(self, 'File contains parsing errors: %s' % filename)
- self.filename = filename
+ def __init__(self, source=None, filename=None):
+ # Exactly one of `source'/`filename' arguments has to be given.
+ # `filename' kept for compatibility.
+ if filename and source:
+ raise ValueError("Cannot specify both `filename' and `source'. "
+ "Use `source'.")
+ elif not filename and not source:
+ raise ValueError("Required argument `source' not given.")
+ elif filename:
+ source = filename
+ Error.__init__(self, 'Source contains parsing errors: %s' % source)
+ self.source = source
self.errors = []
+ self.args = (source, )
+
+ @property
+ def filename(self):
+ """Deprecated, use `source'."""
+ warnings.warn(
+ "The 'filename' attribute will be removed in future versions. "
+ "Use 'source' instead.",
+ DeprecationWarning, stacklevel=2
+ )
+ return self.source
+
+ @filename.setter
+ def filename(self, value):
+ """Deprecated, user `source'."""
+ warnings.warn(
+ "The 'filename' attribute will be removed in future versions. "
+ "Use 'source' instead.",
+ DeprecationWarning, stacklevel=2
+ )
+ self.source = value
def append(self, lineno, line):
self.errors.append((lineno, line))
self.message += '\n\t[line %2d]: %s' % (lineno, line)
+
class MissingSectionHeaderError(ParsingError):
"""Raised when a key-value pair is found before any section header."""
@@ -215,19 +341,293 @@ class MissingSectionHeaderError(ParsingError):
self,
'File contains no section headers.\nfile: %s, line: %d\n%r' %
(filename, lineno, line))
- self.filename = filename
+ self.source = filename
self.lineno = lineno
self.line = line
+ self.args = (filename, lineno, line)
+
+
+# Used in parser getters to indicate the default behaviour when a specific
+# option is not found it to raise an exception. Created to enable `None' as
+# a valid fallback value.
+_UNSET = object()
+
+
+class Interpolation:
+ """Dummy interpolation that passes the value through with no changes."""
+ def before_get(self, parser, section, option, value, defaults):
+ return value
+
+ def before_set(self, parser, section, option, value):
+ return value
+
+ def before_read(self, parser, section, option, value):
+ return value
+
+ def before_write(self, parser, section, option, value):
+ return value
+
+
+class BasicInterpolation(Interpolation):
+ """Interpolation as implemented in the classic ConfigParser.
+
+ The option values can contain format strings which refer to other values in
+ the same section, or values in the special default section.
+
+ For example:
+
+ something: %(dir)s/whatever
+
+ would resolve the "%(dir)s" to the value of dir. All reference
+ expansions are done late, on demand. If a user needs to use a bare % in
+ a configuration file, she can escape it by writing %%. Other other % usage
+ is considered a user error and raises `InterpolationSyntaxError'."""
+
+ _KEYCRE = re.compile(r"%\(([^)]+)\)s")
+
+ def before_get(self, parser, section, option, value, defaults):
+ L = []
+ self._interpolate_some(parser, option, L, value, section, defaults, 1)
+ return ''.join(L)
+
+ def before_set(self, parser, section, option, value):
+ tmp_value = value.replace('%%', '') # escaped percent signs
+ tmp_value = self._KEYCRE.sub('', tmp_value) # valid syntax
+ if '%' in tmp_value:
+ raise ValueError("invalid interpolation syntax in %r at "
+ "position %d" % (value, tmp_value.find('%')))
+ return value
+
+ def _interpolate_some(self, parser, option, accum, rest, section, map,
+ depth):
+ if depth > MAX_INTERPOLATION_DEPTH:
+ raise InterpolationDepthError(option, section, rest)
+ while rest:
+ p = rest.find("%")
+ if p < 0:
+ accum.append(rest)
+ return
+ if p > 0:
+ accum.append(rest[:p])
+ rest = rest[p:]
+ # p is no longer used
+ c = rest[1:2]
+ if c == "%":
+ accum.append("%")
+ rest = rest[2:]
+ elif c == "(":
+ m = self._KEYCRE.match(rest)
+ if m is None:
+ raise InterpolationSyntaxError(option, section,
+ "bad interpolation variable reference %r" % rest)
+ var = parser.optionxform(m.group(1))
+ rest = rest[m.end():]
+ try:
+ v = map[var]
+ except KeyError:
+ raise InterpolationMissingOptionError(
+ option, section, rest, var)
+ if "%" in v:
+ self._interpolate_some(parser, option, accum, v,
+ section, map, depth + 1)
+ else:
+ accum.append(v)
+ else:
+ raise InterpolationSyntaxError(
+ option, section,
+ "'%%' must be followed by '%%' or '(', "
+ "found: %r" % (rest,))
+
+
+class ExtendedInterpolation(Interpolation):
+ """Advanced variant of interpolation, supports the syntax used by
+ `zc.buildout'. Enables interpolation between sections."""
+
+ _KEYCRE = re.compile(r"\$\{([^}]+)\}")
+
+ def before_get(self, parser, section, option, value, defaults):
+ L = []
+ self._interpolate_some(parser, option, L, value, section, defaults, 1)
+ return ''.join(L)
+
+ def before_set(self, parser, section, option, value):
+ tmp_value = value.replace('$$', '') # escaped dollar signs
+ tmp_value = self._KEYCRE.sub('', tmp_value) # valid syntax
+ if '$' in tmp_value:
+ raise ValueError("invalid interpolation syntax in %r at "
+ "position %d" % (value, tmp_value.find('%')))
+ return value
+
+ def _interpolate_some(self, parser, option, accum, rest, section, map,
+ depth):
+ if depth > MAX_INTERPOLATION_DEPTH:
+ raise InterpolationDepthError(option, section, rest)
+ while rest:
+ p = rest.find("$")
+ if p < 0:
+ accum.append(rest)
+ return
+ if p > 0:
+ accum.append(rest[:p])
+ rest = rest[p:]
+ # p is no longer used
+ c = rest[1:2]
+ if c == "$":
+ accum.append("$")
+ rest = rest[2:]
+ elif c == "{":
+ m = self._KEYCRE.match(rest)
+ if m is None:
+ raise InterpolationSyntaxError(option, section,
+ "bad interpolation variable reference %r" % rest)
+ path = parser.optionxform(m.group(1)).split(':')
+ rest = rest[m.end():]
+ sect = section
+ opt = option
+ try:
+ if len(path) == 1:
+ opt = path[0]
+ v = map[opt]
+ elif len(path) == 2:
+ sect = path[0]
+ opt = path[1]
+ v = parser.get(sect, opt, raw=True)
+ else:
+ raise InterpolationSyntaxError(
+ option, section,
+ "More than one ':' found: %r" % (rest,))
+ except (KeyError, NoSectionError, NoOptionError):
+ raise InterpolationMissingOptionError(
+ option, section, rest, ":".join(path))
+ if "$" in v:
+ self._interpolate_some(parser, opt, accum, v, sect,
+ dict(parser.items(sect, raw=True)),
+ depth + 1)
+ else:
+ accum.append(v)
+ else:
+ raise InterpolationSyntaxError(
+ option, section,
+ "'$' must be followed by '$' or '{', "
+ "found: %r" % (rest,))
+
+
+class LegacyInterpolation(Interpolation):
+ """Deprecated interpolation used in old versions of ConfigParser.
+ Use BasicInterpolation or ExtendedInterpolation instead."""
+
+ _KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
+
+ def before_get(self, parser, section, option, value, vars):
+ rawval = value
+ depth = MAX_INTERPOLATION_DEPTH
+ while depth: # Loop through this until it's done
+ depth -= 1
+ if value and "%(" in value:
+ replace = functools.partial(self._interpolation_replace,
+ parser=parser)
+ value = self._KEYCRE.sub(replace, value)
+ try:
+ value = value % vars
+ except KeyError as e:
+ raise InterpolationMissingOptionError(
+ option, section, rawval, e.args[0])
+ else:
+ break
+ if value and "%(" in value:
+ raise InterpolationDepthError(option, section, rawval)
+ return value
+
+ def before_set(self, parser, section, option, value):
+ return value
+
+ @staticmethod
+ def _interpolation_replace(match, parser):
+ s = match.group(1)
+ if s is None:
+ return match.group()
+ else:
+ return "%%(%s)s" % parser.optionxform(s)
+
+
+class RawConfigParser(MutableMapping):
+ """ConfigParser that does not do interpolation."""
+
+ # Regular expressions for parsing section headers and options
+ _SECT_TMPL = r"""
+ \[ # [
+ (?P<header>[^]]+) # very permissive!
+ \] # ]
+ """
+ _OPT_TMPL = r"""
+ (?P<option>.*?) # very permissive!
+ \s*(?P<vi>{delim})\s* # any number of space/tab,
+ # followed by any of the
+ # allowed delimiters,
+ # followed by any space/tab
+ (?P<value>.*)$ # everything up to eol
+ """
+ _OPT_NV_TMPL = r"""
+ (?P<option>.*?) # very permissive!
+ \s*(?: # any number of space/tab,
+ (?P<vi>{delim})\s* # optionally followed by
+ # any of the allowed
+ # delimiters, followed by any
+ # space/tab
+ (?P<value>.*))?$ # everything up to eol
+ """
+ # Interpolation algorithm to be used if the user does not specify another
+ _DEFAULT_INTERPOLATION = Interpolation()
+ # Compiled regular expression for matching sections
+ SECTCRE = re.compile(_SECT_TMPL, re.VERBOSE)
+ # Compiled regular expression for matching options with typical separators
+ OPTCRE = re.compile(_OPT_TMPL.format(delim="=|:"), re.VERBOSE)
+ # Compiled regular expression for matching options with optional values
+ # delimited using typical separators
+ OPTCRE_NV = re.compile(_OPT_NV_TMPL.format(delim="=|:"), re.VERBOSE)
+ # Compiled regular expression for matching leading whitespace in a line
+ NONSPACECRE = re.compile(r"\S")
+ # Possible boolean values in the configuration.
+ BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True,
+ '0': False, 'no': False, 'false': False, 'off': False}
+
+ def __init__(self, defaults=None, dict_type=_default_dict,
+ allow_no_value=False, *, delimiters=('=', ':'),
+ comment_prefixes=('#', ';'), inline_comment_prefixes=None,
+ strict=True, empty_lines_in_values=True,
+ default_section=DEFAULTSECT,
+ interpolation=_UNSET):
-class RawConfigParser:
- def __init__(self, defaults=None, dict_type=_default_dict):
self._dict = dict_type
self._sections = self._dict()
self._defaults = self._dict()
+ self._proxies = self._dict()
+ self._proxies[default_section] = SectionProxy(self, default_section)
if defaults:
for key, value in defaults.items():
self._defaults[self.optionxform(key)] = value
+ self._delimiters = tuple(delimiters)
+ if delimiters == ('=', ':'):
+ self._optcre = self.OPTCRE_NV if allow_no_value else self.OPTCRE
+ else:
+ d = "|".join(re.escape(d) for d in delimiters)
+ if allow_no_value:
+ self._optcre = re.compile(self._OPT_NV_TMPL.format(delim=d),
+ re.VERBOSE)
+ else:
+ self._optcre = re.compile(self._OPT_TMPL.format(delim=d),
+ re.VERBOSE)
+ self._comment_prefixes = tuple(comment_prefixes or ())
+ self._inline_comment_prefixes = tuple(inline_comment_prefixes or ())
+ self._strict = strict
+ self._allow_no_value = allow_no_value
+ self._empty_lines_in_values = empty_lines_in_values
+ if interpolation is _UNSET:
+ self._interpolation = self._DEFAULT_INTERPOLATION
+ else:
+ self._interpolation = interpolation
+ self.default_section=default_section
def defaults(self):
return self._defaults
@@ -241,15 +641,15 @@ class RawConfigParser:
"""Create a new section in the configuration.
Raise DuplicateSectionError if a section by the specified name
- already exists. Raise ValueError if name is DEFAULT or any of it's
- case-insensitive variants.
+ already exists. Raise ValueError if name is DEFAULT.
"""
- if section.lower() == "default":
- raise ValueError('Invalid section name: %s' % section)
+ if section == self.default_section:
+ raise ValueError('Invalid section name: %r' % section)
if section in self._sections:
raise DuplicateSectionError(section)
self._sections[section] = self._dict()
+ self._proxies[section] = SectionProxy(self, section)
def has_section(self, section):
"""Indicate whether the named section is present in the configuration.
@@ -265,11 +665,9 @@ class RawConfigParser:
except KeyError:
raise NoSectionError(section)
opts.update(self._defaults)
- if '__name__' in opts:
- del opts['__name__']
return list(opts.keys())
- def read(self, filenames):
+ def read(self, filenames, encoding=None):
"""Read and parse a filename or a list of filenames.
Files that cannot be opened are silently ignored; this is
@@ -286,83 +684,181 @@ class RawConfigParser:
read_ok = []
for filename in filenames:
try:
- fp = open(filename)
+ with open(filename, encoding=encoding) as fp:
+ self._read(fp, filename)
except IOError:
continue
- self._read(fp, filename)
- fp.close()
read_ok.append(filename)
return read_ok
- def readfp(self, fp, filename=None):
+ def read_file(self, f, source=None):
"""Like read() but the argument must be a file-like object.
- The `fp' argument must have a `readline' method. Optional
- second argument is the `filename', which if not given, is
- taken from fp.name. If fp has no `name' attribute, `<???>' is
- used.
-
+ The `f' argument must have a `readline' method. Optional second
+ argument is the `source' specifying the name of the file being read. If
+ not given, it is taken from f.name. If `f' has no `name' attribute,
+ `<???>' is used.
"""
- if filename is None:
+ if source is None:
try:
- filename = fp.name
+ source = f.name
except AttributeError:
- filename = '<???>'
- self._read(fp, filename)
+ source = '<???>'
+ self._read(f, source)
- def get(self, section, option):
- opt = self.optionxform(option)
- if section not in self._sections:
- if section != DEFAULTSECT:
- raise NoSectionError(section)
- if opt in self._defaults:
- return self._defaults[opt]
+ def read_string(self, string, source='<string>'):
+ """Read configuration from a given string."""
+ sfile = io.StringIO(string)
+ self.read_file(sfile, source)
+
+ def read_dict(self, dictionary, source='<dict>'):
+ """Read configuration from a dictionary.
+
+ Keys are section names, values are dictionaries with keys and values
+ that should be present in the section. If the used dictionary type
+ preserves order, sections and their keys will be added in order.
+
+ All types held in the dictionary are converted to strings during
+ reading, including section names, option names and keys.
+
+ Optional second argument is the `source' specifying the name of the
+ dictionary being read.
+ """
+ elements_added = set()
+ for section, keys in dictionary.items():
+ section = str(section)
+ try:
+ self.add_section(section)
+ except (DuplicateSectionError, ValueError):
+ if self._strict and section in elements_added:
+ raise
+ elements_added.add(section)
+ for key, value in keys.items():
+ key = self.optionxform(str(key))
+ if value is not None:
+ value = str(value)
+ if self._strict and (section, key) in elements_added:
+ raise DuplicateOptionError(section, key, source)
+ elements_added.add((section, key))
+ self.set(section, key, value)
+
+ def readfp(self, fp, filename=None):
+ """Deprecated, use read_file instead."""
+ warnings.warn(
+ "This method will be removed in future versions. "
+ "Use 'parser.read_file()' instead.",
+ DeprecationWarning, stacklevel=2
+ )
+ self.read_file(fp, source=filename)
+
+ def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
+ """Get an option value for a given section.
+
+ If `vars' is provided, it must be a dictionary. The option is looked up
+ in `vars' (if provided), `section', and in `DEFAULTSECT' in that order.
+ If the key is not found and `fallback' is provided, it is used as
+ a fallback value. `None' can be provided as a `fallback' value.
+
+ If interpolation is enabled and the optional argument `raw' is False,
+ all interpolations are expanded in the return values.
+
+ Arguments `raw', `vars', and `fallback' are keyword only.
+
+ The section DEFAULT is special.
+ """
+ try:
+ d = self._unify_values(section, vars)
+ except NoSectionError:
+ if fallback is _UNSET:
+ raise
else:
+ return fallback
+ option = self.optionxform(option)
+ try:
+ value = d[option]
+ except KeyError:
+ if fallback is _UNSET:
raise NoOptionError(option, section)
- elif opt in self._sections[section]:
- return self._sections[section][opt]
- elif opt in self._defaults:
- return self._defaults[opt]
+ else:
+ return fallback
+
+ if raw or value is None:
+ return value
else:
- raise NoOptionError(option, section)
+ return self._interpolation.before_get(self, section, option, value,
+ d)
- def items(self, section):
+ def _get(self, section, conv, option, **kwargs):
+ return conv(self.get(section, option, **kwargs))
+
+ def getint(self, section, option, *, raw=False, vars=None,
+ fallback=_UNSET):
try:
- d2 = self._sections[section]
- except KeyError:
- if section != DEFAULTSECT:
- raise NoSectionError(section)
- d2 = self._dict()
- d = self._defaults.copy()
- d.update(d2)
- if "__name__" in d:
- del d["__name__"]
- return d.items()
+ return self._get(section, int, option, raw=raw, vars=vars)
+ except (NoSectionError, NoOptionError):
+ if fallback is _UNSET:
+ raise
+ else:
+ return fallback
- def _get(self, section, conv, option):
- return conv(self.get(section, option))
+ def getfloat(self, section, option, *, raw=False, vars=None,
+ fallback=_UNSET):
+ try:
+ return self._get(section, float, option, raw=raw, vars=vars)
+ except (NoSectionError, NoOptionError):
+ if fallback is _UNSET:
+ raise
+ else:
+ return fallback
- def getint(self, section, option):
- return self._get(section, int, option)
+ def getboolean(self, section, option, *, raw=False, vars=None,
+ fallback=_UNSET):
+ try:
+ return self._get(section, self._convert_to_boolean, option,
+ raw=raw, vars=vars)
+ except (NoSectionError, NoOptionError):
+ if fallback is _UNSET:
+ raise
+ else:
+ return fallback
- def getfloat(self, section, option):
- return self._get(section, float, option)
+ def items(self, section=_UNSET, raw=False, vars=None):
+ """Return a list of (name, value) tuples for each option in a section.
- _boolean_states = {'1': True, 'yes': True, 'true': True, 'on': True,
- '0': False, 'no': False, 'false': False, 'off': False}
+ All % interpolations are expanded in the return values, based on the
+ defaults passed into the constructor, unless the optional argument
+ `raw' is true. Additional substitutions may be provided using the
+ `vars' argument, which must be a dictionary whose contents overrides
+ any pre-existing defaults.
- def getboolean(self, section, option):
- v = self.get(section, option)
- if v.lower() not in self._boolean_states:
- raise ValueError('Not a boolean: %s' % v)
- return self._boolean_states[v.lower()]
+ The section DEFAULT is special.
+ """
+ if section is _UNSET:
+ return super().items()
+ d = self._defaults.copy()
+ try:
+ d.update(self._sections[section])
+ except KeyError:
+ if section != self.default_section:
+ raise NoSectionError(section)
+ # Update with the entry specific variables
+ if vars:
+ for key, value in vars.items():
+ d[self.optionxform(key)] = value
+ value_getter = lambda option: self._interpolation.before_get(self,
+ section, option, d[option], d)
+ if raw:
+ value_getter = lambda option: d[option]
+ return [(option, value_getter(option)) for option in d.keys()]
def optionxform(self, optionstr):
return optionstr.lower()
def has_option(self, section, option):
- """Check for the existence of a given option in a given section."""
- if not section or section == DEFAULTSECT:
+ """Check for the existence of a given option in a given section.
+ If the specified `section' is None or an empty string, DEFAULT is
+ assumed. If the specified `section' does not exist, returns False."""
+ if not section or section == self.default_section:
option = self.optionxform(option)
return option in self._defaults
elif section not in self._sections:
@@ -372,9 +868,12 @@ class RawConfigParser:
return (option in self._sections[section]
or option in self._defaults)
- def set(self, section, option, value):
+ def set(self, section, option, value=None):
"""Set an option."""
- if not section or section == DEFAULTSECT:
+ if value:
+ value = self._interpolation.before_set(self, section, option,
+ value)
+ if not section or section == self.default_section:
sectdict = self._defaults
else:
try:
@@ -383,24 +882,39 @@ class RawConfigParser:
raise NoSectionError(section)
sectdict[self.optionxform(option)] = value
- def write(self, fp):
- """Write an .ini-format representation of the configuration state."""
+ def write(self, fp, space_around_delimiters=True):
+ """Write an .ini-format representation of the configuration state.
+
+ If `space_around_delimiters' is True (the default), delimiters
+ between keys and values are surrounded by spaces.
+ """
+ if space_around_delimiters:
+ d = " {} ".format(self._delimiters[0])
+ else:
+ d = self._delimiters[0]
if self._defaults:
- fp.write("[%s]\n" % DEFAULTSECT)
- for (key, value) in self._defaults.items():
- fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
- fp.write("\n")
+ self._write_section(fp, self.default_section,
+ self._defaults.items(), d)
for section in self._sections:
- fp.write("[%s]\n" % section)
- for (key, value) in self._sections[section].items():
- if key != "__name__":
- fp.write("%s = %s\n" %
- (key, str(value).replace('\n', '\n\t')))
- fp.write("\n")
+ self._write_section(fp, section,
+ self._sections[section].items(), d)
+
+ def _write_section(self, fp, section_name, section_items, delimiter):
+ """Write a single section to the specified `fp'."""
+ fp.write("[{}]\n".format(section_name))
+ for key, value in section_items:
+ value = self._interpolation.before_write(self, section_name, key,
+ value)
+ if value is not None or not self._allow_no_value:
+ value = delimiter + str(value).replace('\n', '\n\t')
+ else:
+ value = ""
+ fp.write("{}{}\n".format(key, value))
+ fp.write("\n")
def remove_option(self, section, option):
"""Remove an option."""
- if not section or section == DEFAULTSECT:
+ if not section or section == self.default_section:
sectdict = self._defaults
else:
try:
@@ -418,69 +932,117 @@ class RawConfigParser:
existed = section in self._sections
if existed:
del self._sections[section]
+ del self._proxies[section]
return existed
- #
- # Regular expressions for parsing section headers and options.
- #
- SECTCRE = re.compile(
- r'\[' # [
- r'(?P<header>[^]]+)' # very permissive!
- r'\]' # ]
- )
- OPTCRE = re.compile(
- r'(?P<option>[^:=\s][^:=]*)' # very permissive!
- r'\s*(?P<vi>[:=])\s*' # any number of space/tab,
- # followed by separator
- # (either : or =), followed
- # by any # space/tab
- r'(?P<value>.*)$' # everything up to eol
- )
+ def __getitem__(self, key):
+ if key != self.default_section and not self.has_section(key):
+ raise KeyError(key)
+ return self._proxies[key]
+
+ def __setitem__(self, key, value):
+ # To conform with the mapping protocol, overwrites existing values in
+ # the section.
+
+ # XXX this is not atomic if read_dict fails at any point. Then again,
+ # no update method in configparser is atomic in this implementation.
+ self.remove_section(key)
+ self.read_dict({key: value})
+
+ def __delitem__(self, key):
+ if key == self.default_section:
+ raise ValueError("Cannot remove the default section.")
+ if not self.has_section(key):
+ raise KeyError(key)
+ self.remove_section(key)
+
+ def __contains__(self, key):
+ return key == self.default_section or self.has_section(key)
+
+ def __len__(self):
+ return len(self._sections) + 1 # the default section
+
+ def __iter__(self):
+ # XXX does it break when underlying container state changed?
+ return itertools.chain((self.default_section,), self._sections.keys())
def _read(self, fp, fpname):
- """Parse a sectioned setup file.
-
- The sections in setup file contains a title line at the top,
- indicated by a name in square brackets (`[]'), plus key/value
- options lines, indicated by `name: value' format lines.
- Continuations are represented by an embedded newline then
- leading whitespace. Blank lines, lines beginning with a '#',
- and just about everything else are ignored.
+ """Parse a sectioned configuration file.
+
+ Each section in a configuration file contains a header, indicated by
+ a name in square brackets (`[]'), plus key/value options, indicated by
+ `name' and `value' delimited with a specific substring (`=' or `:' by
+ default).
+
+ Values can span multiple lines, as long as they are indented deeper
+ than the first line of the value. Depending on the parser's mode, blank
+ lines may be treated as parts of multiline values or ignored.
+
+ Configuration files may include comments, prefixed by specific
+ characters (`#' and `;' by default). Comments may appear on their own
+ in an otherwise empty line or may be entered in lines holding values or
+ section names.
"""
- cursect = None # None, or a dictionary
+ elements_added = set()
+ cursect = None # None, or a dictionary
+ sectname = None
optname = None
lineno = 0
- e = None # None, or an exception
- while True:
- line = fp.readline()
- if not line:
- break
- lineno = lineno + 1
- # comment or blank line?
- if line.strip() == '' or line[0] in '#;':
- continue
- if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
- # no leading whitespace
+ indent_level = 0
+ e = None # None, or an exception
+ for lineno, line in enumerate(fp, start=1):
+ comment_start = None
+ # strip inline comments
+ for prefix in self._inline_comment_prefixes:
+ index = line.find(prefix)
+ if index == 0 or (index > 0 and line[index-1].isspace()):
+ comment_start = index
+ break
+ # strip full line comments
+ for prefix in self._comment_prefixes:
+ if line.strip().startswith(prefix):
+ comment_start = 0
+ break
+ value = line[:comment_start].strip()
+ if not value:
+ if self._empty_lines_in_values:
+ # add empty line to the value, but only if there was no
+ # comment on the line
+ if (comment_start is None and
+ cursect is not None and
+ optname and
+ cursect[optname] is not None):
+ cursect[optname].append('') # newlines added at join
+ else:
+ # empty line marks end of value
+ indent_level = sys.maxsize
continue
# continuation line?
- if line[0].isspace() and cursect is not None and optname:
- value = line.strip()
- if value:
- cursect[optname] = "%s\n%s" % (cursect[optname], value)
+ first_nonspace = self.NONSPACECRE.search(line)
+ cur_indent_level = first_nonspace.start() if first_nonspace else 0
+ if (cursect is not None and optname and
+ cur_indent_level > indent_level):
+ cursect[optname].append(value)
# a section header or option header?
else:
+ indent_level = cur_indent_level
# is it a section header?
- mo = self.SECTCRE.match(line)
+ mo = self.SECTCRE.match(value)
if mo:
sectname = mo.group('header')
if sectname in self._sections:
+ if self._strict and sectname in elements_added:
+ raise DuplicateSectionError(sectname, fpname,
+ lineno)
cursect = self._sections[sectname]
- elif sectname == DEFAULTSECT:
+ elements_added.add(sectname)
+ elif sectname == self.default_section:
cursect = self._defaults
else:
cursect = self._dict()
- cursect['__name__'] = sectname
self._sections[sectname] = cursect
+ self._proxies[sectname] = SectionProxy(self, sectname)
+ elements_added.add(sectname)
# So sections can't start with a continuation line
optname = None
# no section header in the file?
@@ -488,253 +1050,197 @@ class RawConfigParser:
raise MissingSectionHeaderError(fpname, lineno, line)
# an option line?
else:
- mo = self.OPTCRE.match(line)
+ mo = self._optcre.match(value)
if mo:
optname, vi, optval = mo.group('option', 'vi', 'value')
- if vi in ('=', ':') and ';' in optval:
- # ';' is a comment delimiter only if it follows
- # a spacing character
- pos = optval.find(';')
- if pos != -1 and optval[pos-1].isspace():
- optval = optval[:pos]
- optval = optval.strip()
- # allow empty values
- if optval == '""':
- optval = ''
+ if not optname:
+ e = self._handle_error(e, fpname, lineno, line)
optname = self.optionxform(optname.rstrip())
- cursect[optname] = optval
+ if (self._strict and
+ (sectname, optname) in elements_added):
+ raise DuplicateOptionError(sectname, optname,
+ fpname, lineno)
+ elements_added.add((sectname, optname))
+ # This check is fine because the OPTCRE cannot
+ # match if it would set optval to None
+ if optval is not None:
+ optval = optval.strip()
+ cursect[optname] = [optval]
+ else:
+ # valueless option handling
+ cursect[optname] = None
else:
- # a non-fatal parsing error occurred. set up the
+ # a non-fatal parsing error occurred. set up the
# exception but keep going. the exception will be
# raised at the end of the file and will contain a
# list of all bogus lines
- if not e:
- e = ParsingError(fpname)
- e.append(lineno, repr(line))
+ e = self._handle_error(e, fpname, lineno, line)
# if any parsing errors occurred, raise an exception
if e:
raise e
+ self._join_multiline_values()
+
+ def _join_multiline_values(self):
+ defaults = self.default_section, self._defaults
+ all_sections = itertools.chain((defaults,),
+ self._sections.items())
+ for section, options in all_sections:
+ for name, val in options.items():
+ if isinstance(val, list):
+ val = '\n'.join(val).rstrip()
+ options[name] = self._interpolation.before_read(self,
+ section,
+ name, val)
+
+ def _handle_error(self, exc, fpname, lineno, line):
+ if not exc:
+ exc = ParsingError(fpname)
+ exc.append(lineno, repr(line))
+ return exc
+
+ def _unify_values(self, section, vars):
+ """Create a sequence of lookups with 'vars' taking priority over
+ the 'section' which takes priority over the DEFAULTSECT.
-class _Chainmap:
- """Combine multiple mappings for successive lookups.
-
- For example, to emulate Python's normal lookup sequence:
-
- import __builtin__
- pylookup = _Chainmap(locals(), globals(), vars(__builtin__))
- """
-
- def __init__(self, *maps):
- self.maps = maps
-
- def __getitem__(self, key):
- for mapping in self.maps:
- try:
- return mapping[key]
- except KeyError:
- pass
- raise KeyError(key)
-
- def __iter__(self):
- seen = set()
- for mapping in self.maps:
- s = set(mapping) - seen
- for elem in s:
- yield elem
- seen.update(s)
-
- def __len__(self):
- s = set()
- s.update(*self.maps)
- return len(s)
-
- def get(self, key, default=None):
+ """
+ sectiondict = {}
try:
- return self[key]
+ sectiondict = self._sections[section]
except KeyError:
- return default
+ if section != self.default_section:
+ raise NoSectionError(section)
+ # Update with the entry specific variables
+ vardict = {}
+ if vars:
+ for key, value in vars.items():
+ if value is not None:
+ value = str(value)
+ vardict[self.optionxform(key)] = value
+ return _ChainMap(vardict, sectiondict, self._defaults)
- def __contains__(self, key):
- try:
- self[key]
- except KeyError:
- return False
- else:
- return True
+ def _convert_to_boolean(self, value):
+ """Return a boolean value translating from other types if necessary.
+ """
+ if value.lower() not in self.BOOLEAN_STATES:
+ raise ValueError('Not a boolean: %s' % value)
+ return self.BOOLEAN_STATES[value.lower()]
+
+ def _validate_value_types(self, *, section="", option="", value=""):
+ """Raises a TypeError for non-string values.
+
+ The only legal non-string value if we allow valueless
+ options is None, so we need to check if the value is a
+ string if:
+ - we do not allow valueless options, or
+ - we allow valueless options but the value is not None
+
+ For compatibility reasons this method is not used in classic set()
+ for RawConfigParsers. It is invoked in every case for mapping protocol
+ access and in ConfigParser.set().
+ """
+ if not isinstance(section, str):
+ raise TypeError("section names must be strings")
+ if not isinstance(option, str):
+ raise TypeError("option keys must be strings")
+ if not self._allow_no_value or value:
+ if not isinstance(value, str):
+ raise TypeError("option values must be strings")
- def keys(self):
- return list(self)
- def items(self):
- return [(k, self[k]) for k in self]
+class ConfigParser(RawConfigParser):
+ """ConfigParser implementing interpolation."""
- def values(self):
- return [self[k] for k in self]
+ _DEFAULT_INTERPOLATION = BasicInterpolation()
- def __eq__(self, other):
- return dict(self.items()) == dict(other.items())
+ def set(self, section, option, value=None):
+ """Set an option. Extends RawConfigParser.set by validating type and
+ interpolation syntax on the value."""
+ self._validate_value_types(option=option, value=value)
+ super().set(section, option, value)
- def __ne__(self, other):
- return not (self == other)
+ def add_section(self, section):
+ """Create a new section in the configuration. Extends
+ RawConfigParser.add_section by validating if the section name is
+ a string."""
+ self._validate_value_types(section=section)
+ super().add_section(section)
-class ConfigParser(RawConfigParser):
+class SafeConfigParser(ConfigParser):
+ """ConfigParser alias for backwards compatibility purposes."""
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ warnings.warn(
+ "The SafeConfigParser class has been renamed to ConfigParser "
+ "in Python 3.2. This alias will be removed in future versions."
+ " Use ConfigParser directly instead.",
+ DeprecationWarning, stacklevel=2
+ )
- def get(self, section, option, raw=False, vars=None):
- """Get an option value for a given section.
- If `vars' is provided, it must be a dictionary. The option is looked up
- in `vars' (if provided), `section', and in `defaults' in that order.
+class SectionProxy(MutableMapping):
+ """A proxy for a single section from a parser."""
- All % interpolations are expanded in the return values, unless the
- optional argument `raw' is true. Values for interpolation keys are
- looked up in the same manner as the option.
+ def __init__(self, parser, name):
+ """Creates a view on a section of the specified `name` in `parser`."""
+ self._parser = parser
+ self._name = name
- The section DEFAULT is special.
- """
- sectiondict = {}
- try:
- sectiondict = self._sections[section]
- except KeyError:
- if section != DEFAULTSECT:
- raise NoSectionError(section)
- # Update with the entry specific variables
- vardict = {}
- if vars:
- for key, value in vars.items():
- vardict[self.optionxform(key)] = value
- d = _Chainmap(vardict, sectiondict, self._defaults)
- option = self.optionxform(option)
- try:
- value = d[option]
- except KeyError:
- raise NoOptionError(option, section)
+ def __repr__(self):
+ return '<Section: {}>'.format(self._name)
- if raw:
- return value
- else:
- return self._interpolate(section, option, value, d)
+ def __getitem__(self, key):
+ if not self._parser.has_option(self._name, key):
+ raise KeyError(key)
+ return self._parser.get(self._name, key)
- def items(self, section, raw=False, vars=None):
- """Return a list of tuples with (name, value) for each option
- in the section.
+ def __setitem__(self, key, value):
+ self._parser._validate_value_types(option=key, value=value)
+ return self._parser.set(self._name, key, value)
- All % interpolations are expanded in the return values, based on the
- defaults passed into the constructor, unless the optional argument
- `raw' is true. Additional substitutions may be provided using the
- `vars' argument, which must be a dictionary whose contents overrides
- any pre-existing defaults.
+ def __delitem__(self, key):
+ if not (self._parser.has_option(self._name, key) and
+ self._parser.remove_option(self._name, key)):
+ raise KeyError(key)
- The section DEFAULT is special.
- """
- d = self._defaults.copy()
- try:
- d.update(self._sections[section])
- except KeyError:
- if section != DEFAULTSECT:
- raise NoSectionError(section)
- # Update with the entry specific variables
- if vars:
- for key, value in vars.items():
- d[self.optionxform(key)] = value
- options = list(d.keys())
- if "__name__" in options:
- options.remove("__name__")
- if raw:
- return [(option, d[option])
- for option in options]
- else:
- return [(option, self._interpolate(section, option, d[option], d))
- for option in options]
+ def __contains__(self, key):
+ return self._parser.has_option(self._name, key)
- def _interpolate(self, section, option, rawval, vars):
- # do the string interpolation
- value = rawval
- depth = MAX_INTERPOLATION_DEPTH
- while depth: # Loop through this until it's done
- depth -= 1
- if "%(" in value:
- value = self._KEYCRE.sub(self._interpolation_replace, value)
- try:
- value = value % vars
- except KeyError as e:
- raise InterpolationMissingOptionError(
- option, section, rawval, e.args[0])
- else:
- break
- if "%(" in value:
- raise InterpolationDepthError(option, section, rawval)
- return value
+ def __len__(self):
+ return len(self._options())
- _KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
+ def __iter__(self):
+ return self._options().__iter__()
- def _interpolation_replace(self, match):
- s = match.group(1)
- if s is None:
- return match.group()
+ def _options(self):
+ if self._name != self._parser.default_section:
+ return self._parser.options(self._name)
else:
- return "%%(%s)s" % self.optionxform(s)
+ return self._parser.defaults()
+ def get(self, option, fallback=None, *, raw=False, vars=None):
+ return self._parser.get(self._name, option, raw=raw, vars=vars,
+ fallback=fallback)
-class SafeConfigParser(ConfigParser):
+ def getint(self, option, fallback=None, *, raw=False, vars=None):
+ return self._parser.getint(self._name, option, raw=raw, vars=vars,
+ fallback=fallback)
- def _interpolate(self, section, option, rawval, vars):
- # do the string interpolation
- L = []
- self._interpolate_some(option, L, rawval, section, vars, 1)
- return ''.join(L)
+ def getfloat(self, option, fallback=None, *, raw=False, vars=None):
+ return self._parser.getfloat(self._name, option, raw=raw, vars=vars,
+ fallback=fallback)
- _interpvar_re = re.compile(r"%\(([^)]+)\)s")
+ def getboolean(self, option, fallback=None, *, raw=False, vars=None):
+ return self._parser.getboolean(self._name, option, raw=raw, vars=vars,
+ fallback=fallback)
- def _interpolate_some(self, option, accum, rest, section, map, depth):
- if depth > MAX_INTERPOLATION_DEPTH:
- raise InterpolationDepthError(option, section, rest)
- while rest:
- p = rest.find("%")
- if p < 0:
- accum.append(rest)
- return
- if p > 0:
- accum.append(rest[:p])
- rest = rest[p:]
- # p is no longer used
- c = rest[1:2]
- if c == "%":
- accum.append("%")
- rest = rest[2:]
- elif c == "(":
- m = self._interpvar_re.match(rest)
- if m is None:
- raise InterpolationSyntaxError(option, section,
- "bad interpolation variable reference %r" % rest)
- var = self.optionxform(m.group(1))
- rest = rest[m.end():]
- try:
- v = map[var]
- except KeyError:
- raise InterpolationMissingOptionError(
- option, section, rest, var)
- if "%" in v:
- self._interpolate_some(option, accum, v,
- section, map, depth + 1)
- else:
- accum.append(v)
- else:
- raise InterpolationSyntaxError(
- option, section,
- "'%%' must be followed by '%%' or '(', found: %r" % (rest,))
-
- def set(self, section, option, value):
- """Set an option. Extend ConfigParser.set: check for string values."""
- if not isinstance(value, str):
- raise TypeError("option values must be strings")
- # check for bad percent signs:
- # first, replace all "good" interpolations
- tmp_value = value.replace('%%', '')
- tmp_value = self._interpvar_re.sub('', tmp_value)
- # then, check if there's a lone percent sign left
- percent_index = tmp_value.find('%')
- if percent_index != -1:
- raise ValueError("invalid interpolation syntax in %r at "
- "position %d" % (value, percent_index))
- ConfigParser.set(self, section, option, value)
+ @property
+ def parser(self):
+ # The parser object of the proxy is read-only.
+ return self._parser
+
+ @property
+ def name(self):
+ # The name of the section on a proxy is read-only.
+ return self._name
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index bffa0c4902..4633cff7a4 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -4,9 +4,20 @@ import sys
from functools import wraps
from warnings import warn
-__all__ = ["contextmanager", "nested", "closing"]
+__all__ = ["contextmanager", "closing", "ContextDecorator"]
-class GeneratorContextManager(object):
+
+class ContextDecorator(object):
+ "A base class or mixin that enables context managers to work as decorators."
+ def __call__(self, func):
+ @wraps(func)
+ def inner(*args, **kwds):
+ with self:
+ return func(*args, **kwds)
+ return inner
+
+
+class _GeneratorContextManager(ContextDecorator):
"""Helper for @contextmanager decorator."""
def __init__(self, gen):
@@ -81,55 +92,10 @@ def contextmanager(func):
"""
@wraps(func)
def helper(*args, **kwds):
- return GeneratorContextManager(func(*args, **kwds))
+ return _GeneratorContextManager(func(*args, **kwds))
return helper
-@contextmanager
-def nested(*managers):
- """Combine multiple context managers into a single nested context manager.
-
- This function has been deprecated in favour of the multiple manager form
- of the with statement.
-
- The one advantage of this function over the multiple manager form of the
- with statement is that argument unpacking allows it to be
- used with a variable number of context managers as follows:
-
- with nested(*managers):
- do_something()
-
- """
- warn("With-statements now directly support multiple context managers",
- DeprecationWarning, 3)
- exits = []
- vars = []
- exc = (None, None, None)
- try:
- for mgr in managers:
- exit = mgr.__exit__
- enter = mgr.__enter__
- vars.append(enter())
- exits.append(exit)
- yield vars
- except:
- exc = sys.exc_info()
- finally:
- while exits:
- exit = exits.pop()
- try:
- if exit(*exc):
- exc = (None, None, None)
- except:
- exc = sys.exc_info()
- if exc != (None, None, None):
- # Don't rely on sys.exc_info() still containing
- # the right information. Another exception may
- # have been raised and caught by an exit method
- # exc[1] already has the __traceback__ attribute populated
- raise exc[1]
-
-
class closing(object):
"""Context to automatically close something at the end of a block.
diff --git a/Lib/copy.py b/Lib/copy.py
index 4b755112d7..089d101c7c 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -239,6 +239,10 @@ d[dict] = _deepcopy_dict
if PyStringMap is not None:
d[PyStringMap] = _deepcopy_dict
+def _deepcopy_method(x, memo): # Copy instance methods
+ return type(x)(x.__func__, deepcopy(x.__self__, memo))
+_deepcopy_dispatch[types.MethodType] = _deepcopy_method
+
def _keep_alive(x, memo):
"""Keeps a reference to the object x in the memo.
diff --git a/Lib/csv.py b/Lib/csv.py
index dbe6db7ead..8dfc77e310 100644
--- a/Lib/csv.py
+++ b/Lib/csv.py
@@ -20,7 +20,7 @@ __all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
"unregister_dialect", "__version__", "DictReader", "DictWriter" ]
class Dialect:
- """Describe an Excel dialect.
+ """Describe a CSV dialect.
This must be subclassed (see csv.excel). Valid attributes are:
delimiter, quotechar, escapechar, doublequote, skipinitialspace,
@@ -65,6 +65,16 @@ class excel_tab(excel):
delimiter = '\t'
register_dialect("excel-tab", excel_tab)
+class unix_dialect(Dialect):
+ """Describe the usual properties of Unix-generated CSV files."""
+ delimiter = ','
+ quotechar = '"'
+ doublequote = True
+ skipinitialspace = False
+ lineterminator = '\n'
+ quoting = QUOTE_ALL
+register_dialect("unix", unix_dialect)
+
class DictReader:
def __init__(self, f, fieldnames=None, restkey=None, restval=None,
@@ -127,6 +137,10 @@ class DictWriter:
self.extrasaction = extrasaction
self.writer = writer(f, dialect, *args, **kwds)
+ def writeheader(self):
+ header = dict(zip(self.fieldnames, self.fieldnames))
+ self.writerow(header)
+
def _dict_to_list(self, rowdict):
if self.extrasaction == "raise":
wrong_fields = [k for k in rowdict if k not in self.fieldnames]
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index 1283f28a6d..71686e7a1b 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -259,41 +259,31 @@ class c_bool(_SimpleCData):
from _ctypes import POINTER, pointer, _pointer_type_cache
-try:
- from _ctypes import set_conversion_mode
-except ImportError:
- pass
-else:
- if _os.name in ("nt", "ce"):
- set_conversion_mode("mbcs", "ignore")
- else:
- set_conversion_mode("ascii", "strict")
+class c_wchar_p(_SimpleCData):
+ _type_ = "Z"
- class c_wchar_p(_SimpleCData):
- _type_ = "Z"
+class c_wchar(_SimpleCData):
+ _type_ = "u"
- class c_wchar(_SimpleCData):
- _type_ = "u"
+POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param
- POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param
-
- def create_unicode_buffer(init, size=None):
- """create_unicode_buffer(aString) -> character array
- create_unicode_buffer(anInteger) -> character array
- create_unicode_buffer(aString, anInteger) -> character array
- """
- if isinstance(init, (str, bytes)):
- if size is None:
- size = len(init)+1
- buftype = c_wchar * size
- buf = buftype()
- buf.value = init
- return buf
- elif isinstance(init, int):
- buftype = c_wchar * init
- buf = buftype()
- return buf
- raise TypeError(init)
+def create_unicode_buffer(init, size=None):
+ """create_unicode_buffer(aString) -> character array
+ create_unicode_buffer(anInteger) -> character array
+ create_unicode_buffer(aString, anInteger) -> character array
+ """
+ if isinstance(init, (str, bytes)):
+ if size is None:
+ size = len(init)+1
+ buftype = c_wchar * size
+ buf = buftype()
+ buf.value = init
+ return buf
+ elif isinstance(init, int):
+ buftype = c_wchar * init
+ buf = buftype()
+ return buf
+ raise TypeError(init)
POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param
@@ -459,10 +449,13 @@ _pointer_type_cache[None] = c_void_p
if sizeof(c_uint) == sizeof(c_void_p):
c_size_t = c_uint
+ c_ssize_t = c_int
elif sizeof(c_ulong) == sizeof(c_void_p):
c_size_t = c_ulong
+ c_ssize_t = c_long
elif sizeof(c_ulonglong) == sizeof(c_void_p):
c_size_t = c_ulonglong
+ c_ssize_t = c_longlong
# functions
diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/ctypes/test/test_arrays.py
index d11de28722..f2a9f078c9 100644
--- a/Lib/ctypes/test/test_arrays.py
+++ b/Lib/ctypes/test/test_arrays.py
@@ -42,7 +42,7 @@ class ArrayTestCase(unittest.TestCase):
CharArray = ARRAY(c_char, 3)
- ca = CharArray("a", "b", "c")
+ ca = CharArray(b"a", b"b", b"c")
# Should this work? It doesn't:
# CharArray("abc")
@@ -89,7 +89,7 @@ class ArrayTestCase(unittest.TestCase):
def test_from_address(self):
# Failed with 0.9.8, reported by JUrner
- p = create_string_buffer("foo")
+ p = create_string_buffer(b"foo")
sz = (c_char * 3).from_address(addressof(p))
self.assertEqual(sz[:], b"foo")
self.assertEqual(sz[::], b"foo")
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py
index 4eb9571f65..9e0825c7ca 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/ctypes/test/test_bitfields.py
@@ -37,14 +37,14 @@ class C_Test(unittest.TestCase):
for name in "ABCDEFGHI":
b = BITS()
setattr(b, name, i)
- self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
+ self.assertEqual(getattr(b, name), func(byref(b), name.encode('ascii')))
def test_shorts(self):
for i in range(256):
for name in "MNOPQRS":
b = BITS()
setattr(b, name, i)
- self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
+ self.assertEqual(getattr(b, name), func(byref(b), name.encode('ascii')))
signed_int_types = (c_byte, c_short, c_int, c_long, c_longlong)
unsigned_int_types = (c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong)
diff --git a/Lib/ctypes/test/test_buffers.py b/Lib/ctypes/test/test_buffers.py
index 3f8a587090..c19c05a300 100644
--- a/Lib/ctypes/test/test_buffers.py
+++ b/Lib/ctypes/test/test_buffers.py
@@ -9,19 +9,7 @@ class StringBufferTestCase(unittest.TestCase):
self.assertEqual(sizeof(b), 32 * sizeof(c_char))
self.assertTrue(type(b[0]) is bytes)
- b = create_string_buffer("abc")
- self.assertEqual(len(b), 4) # trailing nul char
- self.assertEqual(sizeof(b), 4 * sizeof(c_char))
- self.assertTrue(type(b[0]) is bytes)
- self.assertEqual(b[0], b"a")
- self.assertEqual(b[:], b"abc\0")
- self.assertEqual(b[::], b"abc\0")
- self.assertEqual(b[::-1], b"\0cba")
- self.assertEqual(b[::2], b"ac")
- self.assertEqual(b[::5], b"a")
-
- def test_string_conversion(self):
- b = create_string_buffer("abc")
+ b = create_string_buffer(b"abc")
self.assertEqual(len(b), 4) # trailing nul char
self.assertEqual(sizeof(b), 4 * sizeof(c_char))
self.assertTrue(type(b[0]) is bytes)
diff --git a/Lib/ctypes/test/test_bytes.py b/Lib/ctypes/test/test_bytes.py
index 374b2d7751..ee49c456e8 100644
--- a/Lib/ctypes/test/test_bytes.py
+++ b/Lib/ctypes/test/test_bytes.py
@@ -11,34 +11,30 @@ class BytesTest(unittest.TestCase):
(c_char * 3)(b"a", b"b", b"c")
def test_c_wchar(self):
- x = c_wchar(b"x")
- x.value = b"y"
- c_wchar.from_param(b"x")
- (c_wchar * 3)(b"a", b"b", b"c")
+ x = c_wchar("x")
+ x.value = "y"
+ c_wchar.from_param("x")
+ (c_wchar * 3)("a", "b", "c")
def test_c_char_p(self):
- c_char_p("foo bar")
c_char_p(b"foo bar")
def test_c_wchar_p(self):
c_wchar_p("foo bar")
- c_wchar_p(b"foo bar")
def test_struct(self):
class X(Structure):
_fields_ = [("a", c_char * 3)]
- X("abc")
x = X(b"abc")
- self.assertEqual(x.a, "abc")
- self.assertEqual(type(x.a), str)
+ self.assertEqual(x.a, b"abc")
+ self.assertEqual(type(x.a), bytes)
def test_struct_W(self):
class X(Structure):
_fields_ = [("a", c_wchar * 3)]
- X("abc")
- x = X(b"abc")
+ x = X("abc")
self.assertEqual(x.a, "abc")
self.assertEqual(type(x.a), str)
@@ -49,7 +45,6 @@ class BytesTest(unittest.TestCase):
_type_ = "X"
BSTR("abc")
- BSTR(b"abc")
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index dabcde65c8..8801ccd106 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -166,6 +166,40 @@ class SampleCallbacksTestCase(unittest.TestCase):
self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
+ def test_issue_8959_a(self):
+ from ctypes.util import find_library
+ libc_path = find_library("c")
+ if not libc_path:
+ return # cannot test
+ libc = CDLL(libc_path)
+
+ @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
+ def cmp_func(a, b):
+ return a[0] - b[0]
+
+ array = (c_int * 5)(5, 1, 99, 7, 33)
+
+ libc.qsort(array, len(array), sizeof(c_int), cmp_func)
+ self.assertEqual(array[:], [1, 5, 7, 33, 99])
+
+ try:
+ WINFUNCTYPE
+ except NameError:
+ pass
+ else:
+ def test_issue_8959_b(self):
+ from ctypes.wintypes import BOOL, HWND, LPARAM
+ global windowCount
+ windowCount = 0
+
+ @WINFUNCTYPE(BOOL, HWND, LPARAM)
+ def EnumWindowsCallbackFunc(hwnd, lParam):
+ global windowCount
+ windowCount += 1
+ return True #Allow windows to keep enumerating
+
+ windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0)
+
def test_callback_register_int(self):
# Issue #8275: buggy handling of callback args under Win64
# NOTE: should be run on release builds as well
diff --git a/Lib/ctypes/test/test_cast.py b/Lib/ctypes/test/test_cast.py
index 4c4a2e8545..702de3cffa 100644
--- a/Lib/ctypes/test/test_cast.py
+++ b/Lib/ctypes/test/test_cast.py
@@ -33,17 +33,17 @@ class Test(unittest.TestCase):
def test_p2a_objects(self):
array = (c_char_p * 5)()
self.assertEqual(array._objects, None)
- array[0] = "foo bar"
+ array[0] = b"foo bar"
self.assertEqual(array._objects, {'0': b"foo bar"})
p = cast(array, POINTER(c_char_p))
# array and p share a common _objects attribute
self.assertTrue(p._objects is array._objects)
self.assertEqual(array._objects, {'0': b"foo bar", id(array): array})
- p[0] = "spam spam"
+ p[0] = b"spam spam"
self.assertEqual(p._objects, {'0': b"spam spam", id(array): array})
self.assertTrue(array._objects is p._objects)
- p[1] = "foo bar"
+ p[1] = b"foo bar"
self.assertEqual(p._objects, {'1': b'foo bar', '0': b"spam spam", id(array): array})
self.assertTrue(array._objects is p._objects)
@@ -71,7 +71,7 @@ class Test(unittest.TestCase):
def test_char_p(self):
# This didn't work: bad argument to internal function
- s = c_char_p("hiho")
+ s = c_char_p(b"hiho")
self.assertEqual(cast(cast(s, c_void_p), c_char_p).value,
b"hiho")
diff --git a/Lib/ctypes/test/test_cfuncs.py b/Lib/ctypes/test/test_cfuncs.py
index 493cbe979c..f4bd3b16c3 100644
--- a/Lib/ctypes/test/test_cfuncs.py
+++ b/Lib/ctypes/test/test_cfuncs.py
@@ -107,7 +107,7 @@ class CFunctions(unittest.TestCase):
def test_ulong_plus(self):
self._dll.tf_bL.restype = c_ulong
self._dll.tf_bL.argtypes = (c_char, c_ulong)
- self.assertEqual(self._dll.tf_bL(' ', 4294967295), 1431655765)
+ self.assertEqual(self._dll.tf_bL(b' ', 4294967295), 1431655765)
self.assertEqual(self.U(), 4294967295)
def test_longlong(self):
diff --git a/Lib/ctypes/test/test_errno.py b/Lib/ctypes/test/test_errno.py
index 0254c3bcda..4690a0d871 100644
--- a/Lib/ctypes/test/test_errno.py
+++ b/Lib/ctypes/test/test_errno.py
@@ -1,27 +1,31 @@
import unittest, os, errno
from ctypes import *
from ctypes.util import find_library
-import threading
+try:
+ import threading
+except ImportError:
+ threading = None
class Test(unittest.TestCase):
def test_open(self):
libc_name = find_library("c")
- if libc_name is not None:
- libc = CDLL(libc_name, use_errno=True)
- if os.name == "nt":
- libc_open = libc._open
- else:
- libc_open = libc.open
+ if libc_name is None:
+ raise unittest.SkipTest("Unable to find C library")
+ libc = CDLL(libc_name, use_errno=True)
+ if os.name == "nt":
+ libc_open = libc._open
+ else:
+ libc_open = libc.open
- libc_open.argtypes = c_char_p, c_int
+ libc_open.argtypes = c_char_p, c_int
- self.assertEqual(libc_open("", 0), -1)
- self.assertEqual(get_errno(), errno.ENOENT)
-
- self.assertEqual(set_errno(32), errno.ENOENT)
- self.assertEqual(get_errno(), 32)
+ self.assertEqual(libc_open(b"", 0), -1)
+ self.assertEqual(get_errno(), errno.ENOENT)
+ self.assertEqual(set_errno(32), errno.ENOENT)
+ self.assertEqual(get_errno(), 32)
+ if threading:
def _worker():
set_errno(0)
@@ -31,7 +35,7 @@ class Test(unittest.TestCase):
else:
libc_open = libc.open
libc_open.argtypes = c_char_p, c_int
- self.assertEqual(libc_open("", 0), -1)
+ self.assertEqual(libc_open(b"", 0), -1)
self.assertEqual(get_errno(), 0)
t = threading.Thread(target=_worker)
@@ -41,36 +45,35 @@ class Test(unittest.TestCase):
self.assertEqual(get_errno(), 32)
set_errno(0)
- if os.name == "nt":
-
- def test_GetLastError(self):
- dll = WinDLL("kernel32", use_last_error=True)
- GetModuleHandle = dll.GetModuleHandleA
- GetModuleHandle.argtypes = [c_wchar_p]
+ @unittest.skipUnless(os.name == "nt", 'Test specific to Windows')
+ def test_GetLastError(self):
+ dll = WinDLL("kernel32", use_last_error=True)
+ GetModuleHandle = dll.GetModuleHandleA
+ GetModuleHandle.argtypes = [c_wchar_p]
- self.assertEqual(0, GetModuleHandle("foo"))
- self.assertEqual(get_last_error(), 126)
+ self.assertEqual(0, GetModuleHandle("foo"))
+ self.assertEqual(get_last_error(), 126)
- self.assertEqual(set_last_error(32), 126)
- self.assertEqual(get_last_error(), 32)
+ self.assertEqual(set_last_error(32), 126)
+ self.assertEqual(get_last_error(), 32)
- def _worker():
- set_last_error(0)
+ def _worker():
+ set_last_error(0)
- dll = WinDLL("kernel32", use_last_error=False)
- GetModuleHandle = dll.GetModuleHandleW
- GetModuleHandle.argtypes = [c_wchar_p]
- GetModuleHandle("bar")
+ dll = WinDLL("kernel32", use_last_error=False)
+ GetModuleHandle = dll.GetModuleHandleW
+ GetModuleHandle.argtypes = [c_wchar_p]
+ GetModuleHandle("bar")
- self.assertEqual(get_last_error(), 0)
+ self.assertEqual(get_last_error(), 0)
- t = threading.Thread(target=_worker)
- t.start()
- t.join()
+ t = threading.Thread(target=_worker)
+ t.start()
+ t.join()
- self.assertEqual(get_last_error(), 32)
+ self.assertEqual(get_last_error(), 32)
- set_last_error(0)
+ set_last_error(0)
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/ctypes/test/test_internals.py b/Lib/ctypes/test/test_internals.py
index 03d820ec7e..cbf2e0589a 100644
--- a/Lib/ctypes/test/test_internals.py
+++ b/Lib/ctypes/test/test_internals.py
@@ -23,16 +23,16 @@ class ObjectsTestCase(unittest.TestCase):
def test_ints(self):
i = 42000123
- rc = grc(i)
+ refcnt = grc(i)
ci = c_int(i)
- self.assertEqual(rc, grc(i))
+ self.assertEqual(refcnt, grc(i))
self.assertEqual(ci._objects, None)
def test_c_char_p(self):
s = b"Hello, World"
- rc = grc(s)
+ refcnt = grc(s)
cs = c_char_p(s)
- self.assertEqual(rc + 1, grc(s))
+ self.assertEqual(refcnt + 1, grc(s))
self.assertSame(cs._objects, s)
def test_simple_struct(self):
@@ -70,19 +70,17 @@ class ObjectsTestCase(unittest.TestCase):
class Y(Structure):
_fields_ = [("x", X), ("y", X)]
- s1 = "Hello, World"
- s2 = "Hallo, Welt"
+ s1 = b"Hello, World"
+ s2 = b"Hallo, Welt"
x = X()
x.a = s1
x.b = s2
- self.assertEqual(x._objects, {"0": bytes(s1, "ascii"),
- "1": bytes(s2, "ascii")})
+ self.assertEqual(x._objects, {"0": s1, "1": s2})
y = Y()
y.x = x
- self.assertEqual(y._objects, {"0": {"0": bytes(s1, "ascii"),
- "1": bytes(s2, "ascii")}})
+ self.assertEqual(y._objects, {"0": {"0": s1, "1": s2}})
## x = y.x
## del y
## print x._b_base_._objects
diff --git a/Lib/ctypes/test/test_keeprefs.py b/Lib/ctypes/test/test_keeprefs.py
index fafef65d2c..db8adfb4ca 100644
--- a/Lib/ctypes/test/test_keeprefs.py
+++ b/Lib/ctypes/test/test_keeprefs.py
@@ -13,9 +13,9 @@ class SimpleTestCase(unittest.TestCase):
def test_ccharp(self):
x = c_char_p()
self.assertEqual(x._objects, None)
- x.value = "abc"
+ x.value = b"abc"
self.assertEqual(x._objects, b"abc")
- x = c_char_p("spam")
+ x = c_char_p(b"spam")
self.assertEqual(x._objects, b"spam")
class StructureTestCase(unittest.TestCase):
@@ -37,8 +37,8 @@ class StructureTestCase(unittest.TestCase):
x = X()
self.assertEqual(x._objects, None)
- x.a = "spam"
- x.b = "foo"
+ x.a = b"spam"
+ x.b = b"foo"
self.assertEqual(x._objects, {"0": b"spam", "1": b"foo"})
def test_struct_struct(self):
diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
index cce409fa1b..56285b5ff8 100644
--- a/Lib/ctypes/test/test_libc.py
+++ b/Lib/ctypes/test/test_libc.py
@@ -25,7 +25,7 @@ class LibTest(unittest.TestCase):
def sort(a, b):
return three_way_cmp(a[0], b[0])
- chars = create_string_buffer("spam, spam, and spam")
+ chars = create_string_buffer(b"spam, spam, and spam")
lib.my_qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort))
self.assertEqual(chars.raw, b" ,,aaaadmmmnpppsss\x00")
diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py
index 07b69ec201..4029b463bc 100644
--- a/Lib/ctypes/test/test_loading.py
+++ b/Lib/ctypes/test/test_loading.py
@@ -97,7 +97,7 @@ class LoaderTest(unittest.TestCase):
self.assertEqual(0, advapi32.CloseEventLog(None))
windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p
windll.kernel32.GetProcAddress.restype = c_void_p
- proc = windll.kernel32.GetProcAddress(advapi32._handle, "CloseEventLog")
+ proc = windll.kernel32.GetProcAddress(advapi32._handle, b"CloseEventLog")
self.assertTrue(proc)
# This is the real test: call the function via 'call_function'
self.assertEqual(0, call_function(proc, (None,)))
diff --git a/Lib/ctypes/test/test_objects.py b/Lib/ctypes/test/test_objects.py
index 750d9045ce..f075c20893 100644
--- a/Lib/ctypes/test/test_objects.py
+++ b/Lib/ctypes/test/test_objects.py
@@ -20,7 +20,7 @@ None
The memory block stores pointers to strings, and the strings itself
assigned from Python must be kept.
->>> array[4] = 'foo bar'
+>>> array[4] = b'foo bar'
>>> array._objects
{'4': b'foo bar'}
>>> array[4]
@@ -45,7 +45,7 @@ of 'x' ('_b_base_' is either None, or the root object owning the memory block):
<ctypes.test.test_objects.X object at 0x...>
>>>
->>> x.array[0] = 'spam spam spam'
+>>> x.array[0] = b'spam spam spam'
>>> x._objects
{'0:2': b'spam spam spam'}
>>> x.array._b_base_._objects
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
index 6a3f33d19c..e83fd9a6fc 100644
--- a/Lib/ctypes/test/test_parameters.py
+++ b/Lib/ctypes/test/test_parameters.py
@@ -19,7 +19,6 @@ class SimpleTypesTestCase(unittest.TestCase):
else:
set_conversion_mode(*self.prev_conv_mode)
-
def test_subclasses(self):
from ctypes import c_void_p, c_char_p
# ctypes 0.9.5 and before did overwrite from_param in SimpleType_new
@@ -58,14 +57,13 @@ class SimpleTypesTestCase(unittest.TestCase):
self.assertTrue(c_char_p.from_param(s)._obj is s)
# new in 0.9.1: convert (encode) unicode to ascii
- self.assertEqual(c_char_p.from_param("123")._obj, b"123")
- self.assertRaises(UnicodeEncodeError, c_char_p.from_param, "123\377")
-
+ self.assertEqual(c_char_p.from_param(b"123")._obj, b"123")
+ self.assertRaises(TypeError, c_char_p.from_param, "123\377")
self.assertRaises(TypeError, c_char_p.from_param, 42)
# calling c_char_p.from_param with a c_char_p instance
# returns the argument itself:
- a = c_char_p("123")
+ a = c_char_p(b"123")
self.assertTrue(c_char_p.from_param(a) is a)
def test_cw_strings(self):
@@ -82,7 +80,7 @@ class SimpleTypesTestCase(unittest.TestCase):
# new in 0.9.1: convert (decode) ascii to unicode
self.assertEqual(c_wchar_p.from_param("123")._obj, "123")
- self.assertRaises(UnicodeDecodeError, c_wchar_p.from_param, b"123\377")
+ self.assertRaises(TypeError, c_wchar_p.from_param, b"123\377")
pa = c_wchar_p.from_param(c_wchar_p("123"))
self.assertEqual(type(pa), c_wchar_p)
diff --git a/Lib/ctypes/test/test_prototypes.py b/Lib/ctypes/test/test_prototypes.py
index d2e4c0b19d..6ef1b1bcaf 100644
--- a/Lib/ctypes/test/test_prototypes.py
+++ b/Lib/ctypes/test/test_prototypes.py
@@ -127,7 +127,7 @@ class CharPointersTestCase(unittest.TestCase):
self.assertEqual(None, func(c_char_p(None)))
self.assertEqual(b"123", func(c_buffer(b"123")))
- ca = c_char("a")
+ ca = c_char(b"a")
self.assertEqual(ord(b"a"), func(pointer(ca))[0])
self.assertEqual(ord(b"a"), func(byref(ca))[0])
diff --git a/Lib/ctypes/test/test_python_api.py b/Lib/ctypes/test/test_python_api.py
index b74767a4f3..1f4c6039dc 100644
--- a/Lib/ctypes/test/test_python_api.py
+++ b/Lib/ctypes/test/test_python_api.py
@@ -72,10 +72,10 @@ class PythonAPITestCase(unittest.TestCase):
PyOS_snprintf.argtypes = POINTER(c_char), c_size_t, c_char_p
buf = c_buffer(256)
- PyOS_snprintf(buf, sizeof(buf), "Hello from %s", b"ctypes")
+ PyOS_snprintf(buf, sizeof(buf), b"Hello from %s", b"ctypes")
self.assertEqual(buf.value, b"Hello from ctypes")
- PyOS_snprintf(buf, sizeof(buf), "Hello from %s (%d, %d, %d)", b"ctypes", 1, 2, 3)
+ PyOS_snprintf(buf, sizeof(buf), b"Hello from %s (%d, %d, %d)", b"ctypes", 1, 2, 3)
self.assertEqual(buf.value, b"Hello from ctypes (1, 2, 3)")
# not enough arguments
diff --git a/Lib/ctypes/test/test_random_things.py b/Lib/ctypes/test/test_random_things.py
index 7bb9db8049..515acf509a 100644
--- a/Lib/ctypes/test/test_random_things.py
+++ b/Lib/ctypes/test/test_random_things.py
@@ -18,7 +18,7 @@ if sys.platform == "win32":
windll.kernel32.GetProcAddress.restype = c_void_p
hdll = windll.kernel32.LoadLibraryA(b"kernel32")
- funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA")
+ funcaddr = windll.kernel32.GetProcAddress(hdll, b"GetModuleHandleA")
self.assertEqual(call_function(funcaddr, (None,)),
windll.kernel32.GetModuleHandleA(None))
@@ -66,7 +66,7 @@ class CallbackTracbackTestCase(unittest.TestCase):
def test_TypeErrorDivisionError(self):
cb = CFUNCTYPE(c_int, c_char_p)(callback_func)
- out = self.capture_stderr(cb, "spam")
+ out = self.capture_stderr(cb, b"spam")
self.assertEqual(out.splitlines()[-1],
"TypeError: "
"unsupported operand type(s) for /: 'int' and 'bytes'")
diff --git a/Lib/ctypes/test/test_repr.py b/Lib/ctypes/test/test_repr.py
index 9a1e2386e6..60a2c80345 100644
--- a/Lib/ctypes/test/test_repr.py
+++ b/Lib/ctypes/test/test_repr.py
@@ -22,8 +22,8 @@ class ReprTest(unittest.TestCase):
self.assertEqual("<X object at", repr(typ(42))[:12])
def test_char(self):
- self.assertEqual("c_char(b'x')", repr(c_char('x')))
- self.assertEqual("<X object at", repr(X('x'))[:12])
+ self.assertEqual("c_char(b'x')", repr(c_char(b'x')))
+ self.assertEqual("<X object at", repr(X(b'x'))[:12])
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/ctypes/test/test_returnfuncptrs.py b/Lib/ctypes/test/test_returnfuncptrs.py
index 11da07b66a..af1caddaab 100644
--- a/Lib/ctypes/test/test_returnfuncptrs.py
+++ b/Lib/ctypes/test/test_returnfuncptrs.py
@@ -28,10 +28,10 @@ class ReturnFuncPtrTestCase(unittest.TestCase):
# _CFuncPtr instances are now callable with an integer argument
# which denotes a function address:
strchr = CFUNCTYPE(c_char_p, c_char_p, c_char)(addr)
- self.assertTrue(strchr("abcdef", "b"), "bcdef")
- self.assertEqual(strchr("abcdef", "x"), None)
- self.assertRaises(ArgumentError, strchr, "abcdef", 3.0)
- self.assertRaises(TypeError, strchr, "abcdef")
+ self.assertTrue(strchr(b"abcdef", b"b"), "bcdef")
+ self.assertEqual(strchr(b"abcdef", b"x"), None)
+ self.assertRaises(ArgumentError, strchr, b"abcdef", 3.0)
+ self.assertRaises(TypeError, strchr, b"abcdef")
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/ctypes/test/test_sizes.py b/Lib/ctypes/test/test_sizes.py
index 0509cbb680..f9b5e97260 100644
--- a/Lib/ctypes/test/test_sizes.py
+++ b/Lib/ctypes/test/test_sizes.py
@@ -1,8 +1,11 @@
# Test specifically-sized containers.
-import unittest
from ctypes import *
+import sys
+import unittest
+
+
class SizesTestCase(unittest.TestCase):
def test_8(self):
self.assertEqual(1, sizeof(c_int8))
@@ -23,5 +26,9 @@ class SizesTestCase(unittest.TestCase):
def test_size_t(self):
self.assertEqual(sizeof(c_void_p), sizeof(c_size_t))
+ def test_ssize_t(self):
+ self.assertEqual(sizeof(c_void_p), sizeof(c_ssize_t))
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/ctypes/test/test_stringptr.py b/Lib/ctypes/test/test_stringptr.py
index 8b16dcbe75..3d25fa5360 100644
--- a/Lib/ctypes/test/test_stringptr.py
+++ b/Lib/ctypes/test/test_stringptr.py
@@ -14,7 +14,7 @@ class StringPtrTestCase(unittest.TestCase):
# NULL pointer access
self.assertRaises(ValueError, getattr, x.str, "contents")
- b = c_buffer("Hello, World")
+ b = c_buffer(b"Hello, World")
from sys import getrefcount as grc
self.assertEqual(grc(b), 2)
x.str = b
@@ -63,8 +63,8 @@ class StringPtrTestCase(unittest.TestCase):
# So we must keep a reference to buf separately
strchr.restype = POINTER(c_char)
- buf = c_buffer("abcdef")
- r = strchr(buf, "c")
+ buf = c_buffer(b"abcdef")
+ r = strchr(buf, b"c")
x = r[0], r[1], r[2], r[3], r[4]
self.assertEqual(x, (b"c", b"d", b"e", b"f", b"\000"))
del buf
diff --git a/Lib/ctypes/test/test_strings.py b/Lib/ctypes/test/test_strings.py
index 3cd1f84006..1a9bdbc5c0 100644
--- a/Lib/ctypes/test/test_strings.py
+++ b/Lib/ctypes/test/test_strings.py
@@ -5,23 +5,23 @@ class StringArrayTestCase(unittest.TestCase):
def test(self):
BUF = c_char * 4
- buf = BUF("a", "b", "c")
+ buf = BUF(b"a", b"b", b"c")
self.assertEqual(buf.value, b"abc")
self.assertEqual(buf.raw, b"abc\000")
- buf.value = "ABCD"
+ buf.value = b"ABCD"
self.assertEqual(buf.value, b"ABCD")
self.assertEqual(buf.raw, b"ABCD")
- buf.value = "x"
+ buf.value = b"x"
self.assertEqual(buf.value, b"x")
self.assertEqual(buf.raw, b"x\000CD")
- buf[1] = "Z"
+ buf[1] = b"Z"
self.assertEqual(buf.value, b"xZCD")
self.assertEqual(buf.raw, b"xZCD")
- self.assertRaises(ValueError, setattr, buf, "value", "aaaaaaaa")
+ self.assertRaises(ValueError, setattr, buf, "value", b"aaaaaaaa")
self.assertRaises(TypeError, setattr, buf, "value", 42)
def test_c_buffer_value(self):
@@ -74,6 +74,13 @@ else:
buf[1] = "Z"
self.assertEqual(buf.value, "xZCD")
+ @unittest.skipIf(sizeof(c_wchar) < 4,
+ "sizeof(wchar_t) is smaller than 4 bytes")
+ def test_nonbmp(self):
+ u = chr(0x10ffff)
+ w = c_wchar(u)
+ self.assertEqual(w.value, u)
+
class StringTestCase(unittest.TestCase):
def XX_test_basic_strings(self):
cs = c_string("abcdef")
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index c58d94989c..536ea50cd8 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -205,15 +205,15 @@ class StructureTestCase(unittest.TestCase):
("age", c_int)]
self.assertRaises(TypeError, Person, 42)
- self.assertRaises(ValueError, Person, "asldkjaslkdjaslkdj")
+ self.assertRaises(ValueError, Person, b"asldkjaslkdjaslkdj")
self.assertRaises(TypeError, Person, "Name", "HI")
# short enough
- self.assertEqual(Person("12345", 5).name, "12345")
+ self.assertEqual(Person(b"12345", 5).name, b"12345")
# exact fit
- self.assertEqual(Person("123456", 5).name, "123456")
+ self.assertEqual(Person(b"123456", 5).name, b"123456")
# too long
- self.assertRaises(ValueError, Person, "1234567", 5)
+ self.assertRaises(ValueError, Person, b"1234567", 5)
def test_conflicting_initializers(self):
class POINT(Structure):
@@ -267,11 +267,11 @@ class StructureTestCase(unittest.TestCase):
("phone", Phone),
("age", c_int)]
- p = Person("Someone", ("1234", "5678"), 5)
+ p = Person(b"Someone", (b"1234", b"5678"), 5)
- self.assertEqual(p.name, "Someone")
- self.assertEqual(p.phone.areacode, "1234")
- self.assertEqual(p.phone.number, "5678")
+ self.assertEqual(p.name, b"Someone")
+ self.assertEqual(p.phone.areacode, b"1234")
+ self.assertEqual(p.phone.number, b"5678")
self.assertEqual(p.age, 5)
def test_structures_with_wchar(self):
@@ -284,8 +284,8 @@ class StructureTestCase(unittest.TestCase):
_fields_ = [("name", c_wchar * 12),
("age", c_int)]
- p = PersonW("Someone")
- self.assertEqual(p.name, "Someone")
+ p = PersonW("Someone \xe9")
+ self.assertEqual(p.name, "Someone \xe9")
self.assertEqual(PersonW("1234567890").name, "1234567890")
self.assertEqual(PersonW("12345678901").name, "12345678901")
@@ -304,13 +304,13 @@ class StructureTestCase(unittest.TestCase):
("phone", Phone),
("age", c_int)]
- cls, msg = self.get_except(Person, "Someone", (1, 2))
+ cls, msg = self.get_except(Person, b"Someone", (1, 2))
self.assertEqual(cls, RuntimeError)
self.assertEqual(msg,
"(Phone) <class 'TypeError'>: "
"expected string, int found")
- cls, msg = self.get_except(Person, "Someone", ("a", "b", "c"))
+ cls, msg = self.get_except(Person, b"Someone", (b"a", b"b", b"c"))
self.assertEqual(cls, RuntimeError)
if issubclass(Exception, object):
self.assertEqual(msg,
diff --git a/Lib/ctypes/test/test_unicode.py b/Lib/ctypes/test/test_unicode.py
index b4d3df3d77..c3b2d48771 100644
--- a/Lib/ctypes/test/test_unicode.py
+++ b/Lib/ctypes/test/test_unicode.py
@@ -7,122 +7,53 @@ except AttributeError:
pass
else:
import _ctypes_test
- dll = ctypes.CDLL(_ctypes_test.__file__)
- wcslen = dll.my_wcslen
- wcslen.argtypes = [ctypes.c_wchar_p]
-
class UnicodeTestCase(unittest.TestCase):
- def setUp(self):
- self.prev_conv_mode = ctypes.set_conversion_mode("ascii", "strict")
-
- def tearDown(self):
- ctypes.set_conversion_mode(*self.prev_conv_mode)
+ def test_wcslen(self):
+ dll = ctypes.CDLL(_ctypes_test.__file__)
+ wcslen = dll.my_wcslen
+ wcslen.argtypes = [ctypes.c_wchar_p]
- def test_ascii_strict(self):
- ctypes.set_conversion_mode("ascii", "strict")
- # no conversions take place with unicode arguments
self.assertEqual(wcslen("abc"), 3)
self.assertEqual(wcslen("ab\u2070"), 3)
- # string args are converted
- self.assertEqual(wcslen("abc"), 3)
self.assertRaises(ctypes.ArgumentError, wcslen, b"ab\xe4")
- def test_ascii_replace(self):
- ctypes.set_conversion_mode("ascii", "replace")
- self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen("ab\u2070"), 3)
- self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen("ab\xe4"), 3)
-
- def test_ascii_ignore(self):
- ctypes.set_conversion_mode("ascii", "ignore")
- self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen("ab\u2070"), 3)
- # ignore error mode skips non-ascii characters
- self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen(b"\xe4\xf6\xfc\xdf"), 0)
-
- def test_latin1_strict(self):
- ctypes.set_conversion_mode("latin-1", "strict")
- self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen("ab\u2070"), 3)
- self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen("\xe4\xf6\xfc\xdf"), 4)
-
def test_buffers(self):
- ctypes.set_conversion_mode("ascii", "strict")
buf = ctypes.create_unicode_buffer("abc")
self.assertEqual(len(buf), 3+1)
- ctypes.set_conversion_mode("ascii", "replace")
- buf = ctypes.create_unicode_buffer(b"ab\xe4\xf6\xfc")
- self.assertEqual(buf[:], "ab\uFFFD\uFFFD\uFFFD\0")
- self.assertEqual(buf[::], "ab\uFFFD\uFFFD\uFFFD\0")
- self.assertEqual(buf[::-1], "\0\uFFFD\uFFFD\uFFFDba")
- self.assertEqual(buf[::2], "a\uFFFD\uFFFD")
+ buf = ctypes.create_unicode_buffer("ab\xe4\xf6\xfc")
+ self.assertEqual(buf[:], "ab\xe4\xf6\xfc\0")
+ self.assertEqual(buf[::], "ab\xe4\xf6\xfc\0")
+ self.assertEqual(buf[::-1], '\x00\xfc\xf6\xe4ba')
+ self.assertEqual(buf[::2], 'a\xe4\xfc')
self.assertEqual(buf[6:5:-1], "")
- ctypes.set_conversion_mode("ascii", "ignore")
- buf = ctypes.create_unicode_buffer(b"ab\xe4\xf6\xfc")
- # is that correct? not sure. But with 'ignore', you get what you pay for..
- self.assertEqual(buf[:], "ab\0\0\0\0")
- self.assertEqual(buf[::], "ab\0\0\0\0")
- self.assertEqual(buf[::-1], "\0\0\0\0ba")
- self.assertEqual(buf[::2], "a\0\0")
- self.assertEqual(buf[6:5:-1], "")
-
- import _ctypes_test
func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
class StringTestCase(UnicodeTestCase):
def setUp(self):
- self.prev_conv_mode = ctypes.set_conversion_mode("ascii", "strict")
func.argtypes = [ctypes.c_char_p]
func.restype = ctypes.c_char_p
def tearDown(self):
- ctypes.set_conversion_mode(*self.prev_conv_mode)
func.argtypes = None
func.restype = ctypes.c_int
- def test_ascii_replace(self):
- ctypes.set_conversion_mode("ascii", "strict")
- self.assertEqual(func("abc"), "abc")
- self.assertEqual(func("abc"), "abc")
- self.assertRaises(ctypes.ArgumentError, func, "ab\xe4")
-
- def test_ascii_ignore(self):
- ctypes.set_conversion_mode("ascii", "ignore")
- self.assertEqual(func("abc"), b"abc")
- self.assertEqual(func("abc"), b"abc")
- self.assertEqual(func("\xe4\xf6\xfc\xdf"), b"")
-
- def test_ascii_replace(self):
- ctypes.set_conversion_mode("ascii", "replace")
- self.assertEqual(func("abc"), b"abc")
- self.assertEqual(func("abc"), b"abc")
- self.assertEqual(func("\xe4\xf6\xfc\xdf"), b"????")
+ def test_func(self):
+ self.assertEqual(func(b"abc\xe4"), b"abc\xe4")
def test_buffers(self):
- ctypes.set_conversion_mode("ascii", "strict")
- buf = ctypes.create_string_buffer("abc")
+ buf = ctypes.create_string_buffer(b"abc")
self.assertEqual(len(buf), 3+1)
- ctypes.set_conversion_mode("ascii", "replace")
- buf = ctypes.create_string_buffer("ab\xe4\xf6\xfc")
- self.assertEqual(buf[:], b"ab???\0")
- self.assertEqual(buf[::], b"ab???\0")
- self.assertEqual(buf[::-1], b"\0???ba")
- self.assertEqual(buf[::2], b"a??")
+ buf = ctypes.create_string_buffer(b"ab\xe4\xf6\xfc")
+ self.assertEqual(buf[:], b"ab\xe4\xf6\xfc\0")
+ self.assertEqual(buf[::], b"ab\xe4\xf6\xfc\0")
+ self.assertEqual(buf[::-1], b'\x00\xfc\xf6\xe4ba')
+ self.assertEqual(buf[::2], b'a\xe4\xfc')
self.assertEqual(buf[6:5:-1], b"")
- ctypes.set_conversion_mode("ascii", "ignore")
- buf = ctypes.create_string_buffer("ab\xe4\xf6\xfc")
- # is that correct? not sure. But with 'ignore', you get what you pay for..
- self.assertEqual(buf[:], b"ab\0\0\0\0")
- self.assertEqual(buf[::], b"ab\0\0\0\0")
- self.assertEqual(buf[::-1], b"\0\0\0\0ba")
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 52bc29614c..1881e89688 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -1,4 +1,5 @@
import sys, os
+import contextlib
# find_library(name) returns the pathname of a library, or None.
if os.name == "nt":
@@ -117,11 +118,8 @@ elif os.name == "posix":
if not f:
return None
cmd = "/usr/ccs/bin/dump -Lpv 2>/dev/null " + f
- f = os.popen(cmd)
- try:
+ with contextlib.closing(os.popen(cmd)) as f:
data = f.read()
- finally:
- f.close()
res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', data)
if not res:
return None
@@ -138,11 +136,8 @@ elif os.name == "posix":
rv = f.close()
if rv == 10:
raise OSError('objdump command not found')
- f = os.popen(cmd)
- try:
+ with contextlib.closing(os.popen(cmd)) as f:
data = f.read()
- finally:
- f.close()
res = re.search(r'\sSONAME\s+([^\s]+)', data)
if not res:
return None
@@ -166,11 +161,8 @@ elif os.name == "posix":
def find_library(name):
ename = re.escape(name)
expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename)
- f = os.popen('/sbin/ldconfig -r 2>/dev/null')
- try:
+ with contextlib.closing(os.popen('/sbin/ldconfig -r 2>/dev/null')) as f:
data = f.read()
- finally:
- f.close()
res = re.findall(expr, data)
if not res:
return _get_soname(_findLib_gcc(name))
@@ -182,20 +174,14 @@ elif os.name == "posix":
def _findLib_ldconfig(name):
# XXX assuming GLIBC's ldconfig (with option -p)
expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
- f = os.popen('/sbin/ldconfig -p 2>/dev/null')
- try:
+ with contextlib.closing(os.popen('/sbin/ldconfig -p 2>/dev/null')) as f:
data = f.read()
- finally:
- f.close()
res = re.search(expr, data)
if not res:
# Hm, this works only for libs needed by the python executable.
cmd = 'ldd %s 2>/dev/null' % sys.executable
- f = os.popen(cmd)
- try:
+ with contextlib.closing(os.popen(cmd)) as f:
data = f.read()
- finally:
- f.close()
res = re.search(expr, data)
if not res:
return None
@@ -219,11 +205,8 @@ elif os.name == "posix":
# XXX assuming GLIBC's ldconfig (with option -p)
expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \
% (abi_type, re.escape(name))
- f = os.popen('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null')
- try:
+ with contextlib.closing(os.popen('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null')) as f:
data = f.read()
- finally:
- f.close()
res = re.search(expr, data)
if not res:
return None
diff --git a/Lib/ctypes/wintypes.py b/Lib/ctypes/wintypes.py
index e7f569c9b6..c619d27596 100644
--- a/Lib/ctypes/wintypes.py
+++ b/Lib/ctypes/wintypes.py
@@ -1,49 +1,50 @@
# The most useful windows datatypes
-from ctypes import *
+import ctypes
-BYTE = c_byte
-WORD = c_ushort
-DWORD = c_ulong
+BYTE = ctypes.c_byte
+WORD = ctypes.c_ushort
+DWORD = ctypes.c_ulong
-WCHAR = c_wchar
-UINT = c_uint
-INT = c_int
+#UCHAR = ctypes.c_uchar
+CHAR = ctypes.c_char
+WCHAR = ctypes.c_wchar
+UINT = ctypes.c_uint
+INT = ctypes.c_int
-DOUBLE = c_double
-FLOAT = c_float
+DOUBLE = ctypes.c_double
+FLOAT = ctypes.c_float
BOOLEAN = BYTE
-BOOL = c_long
+BOOL = ctypes.c_long
-from ctypes import _SimpleCData
-class VARIANT_BOOL(_SimpleCData):
+class VARIANT_BOOL(ctypes._SimpleCData):
_type_ = "v"
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.value)
-ULONG = c_ulong
-LONG = c_long
+ULONG = ctypes.c_ulong
+LONG = ctypes.c_long
-USHORT = c_ushort
-SHORT = c_short
+USHORT = ctypes.c_ushort
+SHORT = ctypes.c_short
# in the windows header files, these are structures.
-_LARGE_INTEGER = LARGE_INTEGER = c_longlong
-_ULARGE_INTEGER = ULARGE_INTEGER = c_ulonglong
+_LARGE_INTEGER = LARGE_INTEGER = ctypes.c_longlong
+_ULARGE_INTEGER = ULARGE_INTEGER = ctypes.c_ulonglong
-LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p
-LPCWSTR = LPWSTR = c_wchar_p
-LPCSTR = LPSTR = c_char_p
-LPCVOID = LPVOID = c_void_p
+LPCOLESTR = LPOLESTR = OLESTR = ctypes.c_wchar_p
+LPCWSTR = LPWSTR = ctypes.c_wchar_p
+LPCSTR = LPSTR = ctypes.c_char_p
+LPCVOID = LPVOID = ctypes.c_void_p
# WPARAM is defined as UINT_PTR (unsigned type)
# LPARAM is defined as LONG_PTR (signed type)
-if sizeof(c_long) == sizeof(c_void_p):
- WPARAM = c_ulong
- LPARAM = c_long
-elif sizeof(c_longlong) == sizeof(c_void_p):
- WPARAM = c_ulonglong
- LPARAM = c_longlong
+if ctypes.sizeof(ctypes.c_long) == ctypes.sizeof(ctypes.c_void_p):
+ WPARAM = ctypes.c_ulong
+ LPARAM = ctypes.c_long
+elif ctypes.sizeof(ctypes.c_longlong) == ctypes.sizeof(ctypes.c_void_p):
+ WPARAM = ctypes.c_ulonglong
+ LPARAM = ctypes.c_longlong
ATOM = WORD
LANGID = WORD
@@ -56,7 +57,7 @@ LCID = DWORD
################################################################
# HANDLE types
-HANDLE = c_void_p # in the header files: void *
+HANDLE = ctypes.c_void_p # in the header files: void *
HACCEL = HANDLE
HBITMAP = HANDLE
@@ -93,45 +94,45 @@ SERVICE_STATUS_HANDLE = HANDLE
################################################################
# Some important structure definitions
-class RECT(Structure):
- _fields_ = [("left", c_long),
- ("top", c_long),
- ("right", c_long),
- ("bottom", c_long)]
+class RECT(ctypes.Structure):
+ _fields_ = [("left", LONG),
+ ("top", LONG),
+ ("right", LONG),
+ ("bottom", LONG)]
tagRECT = _RECTL = RECTL = RECT
-class _SMALL_RECT(Structure):
- _fields_ = [('Left', c_short),
- ('Top', c_short),
- ('Right', c_short),
- ('Bottom', c_short)]
+class _SMALL_RECT(ctypes.Structure):
+ _fields_ = [('Left', SHORT),
+ ('Top', SHORT),
+ ('Right', SHORT),
+ ('Bottom', SHORT)]
SMALL_RECT = _SMALL_RECT
-class _COORD(Structure):
- _fields_ = [('X', c_short),
- ('Y', c_short)]
+class _COORD(ctypes.Structure):
+ _fields_ = [('X', SHORT),
+ ('Y', SHORT)]
-class POINT(Structure):
- _fields_ = [("x", c_long),
- ("y", c_long)]
+class POINT(ctypes.Structure):
+ _fields_ = [("x", LONG),
+ ("y", LONG)]
tagPOINT = _POINTL = POINTL = POINT
-class SIZE(Structure):
- _fields_ = [("cx", c_long),
- ("cy", c_long)]
+class SIZE(ctypes.Structure):
+ _fields_ = [("cx", LONG),
+ ("cy", LONG)]
tagSIZE = SIZEL = SIZE
def RGB(red, green, blue):
return red + (green << 8) + (blue << 16)
-class FILETIME(Structure):
+class FILETIME(ctypes.Structure):
_fields_ = [("dwLowDateTime", DWORD),
("dwHighDateTime", DWORD)]
_FILETIME = FILETIME
-class MSG(Structure):
+class MSG(ctypes.Structure):
_fields_ = [("hWnd", HWND),
- ("message", c_uint),
+ ("message", UINT),
("wParam", WPARAM),
("lParam", LPARAM),
("time", DWORD),
@@ -139,7 +140,7 @@ class MSG(Structure):
tagMSG = MSG
MAX_PATH = 260
-class WIN32_FIND_DATAA(Structure):
+class WIN32_FIND_DATAA(ctypes.Structure):
_fields_ = [("dwFileAttributes", DWORD),
("ftCreationTime", FILETIME),
("ftLastAccessTime", FILETIME),
@@ -148,10 +149,10 @@ class WIN32_FIND_DATAA(Structure):
("nFileSizeLow", DWORD),
("dwReserved0", DWORD),
("dwReserved1", DWORD),
- ("cFileName", c_char * MAX_PATH),
- ("cAlternateFileName", c_char * 14)]
+ ("cFileName", CHAR * MAX_PATH),
+ ("cAlternateFileName", CHAR * 14)]
-class WIN32_FIND_DATAW(Structure):
+class WIN32_FIND_DATAW(ctypes.Structure):
_fields_ = [("dwFileAttributes", DWORD),
("ftCreationTime", FILETIME),
("ftLastAccessTime", FILETIME),
@@ -160,22 +161,42 @@ class WIN32_FIND_DATAW(Structure):
("nFileSizeLow", DWORD),
("dwReserved0", DWORD),
("dwReserved1", DWORD),
- ("cFileName", c_wchar * MAX_PATH),
- ("cAlternateFileName", c_wchar * 14)]
-
-__all__ = ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'COLORREF', 'DOUBLE', 'DWORD',
- 'FILETIME', 'FLOAT', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH',
- 'HCOLORSPACE', 'HDC', 'HDESK', 'HDWP', 'HENHMETAFILE', 'HFONT',
- 'HGDIOBJ', 'HGLOBAL', 'HHOOK', 'HICON', 'HINSTANCE', 'HKEY',
- 'HKL', 'HLOCAL', 'HMENU', 'HMETAFILE', 'HMODULE', 'HMONITOR',
- 'HPALETTE', 'HPEN', 'HRGN', 'HRSRC', 'HSTR', 'HTASK', 'HWINSTA',
- 'HWND', 'INT', 'LANGID', 'LARGE_INTEGER', 'LCID', 'LCTYPE',
- 'LGRPID', 'LONG', 'LPARAM', 'LPCOLESTR', 'LPCSTR', 'LPCVOID',
- 'LPCWSTR', 'LPOLESTR', 'LPSTR', 'LPVOID', 'LPWSTR', 'MAX_PATH',
- 'MSG', 'OLESTR', 'POINT', 'POINTL', 'RECT', 'RECTL', 'RGB',
- 'SC_HANDLE', 'SERVICE_STATUS_HANDLE', 'SHORT', 'SIZE', 'SIZEL',
- 'SMALL_RECT', 'UINT', 'ULARGE_INTEGER', 'ULONG', 'USHORT',
- 'VARIANT_BOOL', 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW',
- 'WORD', 'WPARAM', '_COORD', '_FILETIME', '_LARGE_INTEGER',
- '_POINTL', '_RECTL', '_SMALL_RECT', '_ULARGE_INTEGER', 'tagMSG',
- 'tagPOINT', 'tagRECT', 'tagSIZE']
+ ("cFileName", WCHAR * MAX_PATH),
+ ("cAlternateFileName", WCHAR * 14)]
+
+################################################################
+# Pointer types
+
+LPBOOL = PBOOL = ctypes.POINTER(BOOL)
+PBOOLEAN = ctypes.POINTER(BOOLEAN)
+LPBYTE = PBYTE = ctypes.POINTER(BYTE)
+PCHAR = ctypes.POINTER(CHAR)
+LPCOLORREF = ctypes.POINTER(COLORREF)
+LPDWORD = PDWORD = ctypes.POINTER(DWORD)
+LPFILETIME = PFILETIME = ctypes.POINTER(FILETIME)
+PFLOAT = ctypes.POINTER(FLOAT)
+LPHANDLE = PHANDLE = ctypes.POINTER(HANDLE)
+PHKEY = ctypes.POINTER(HKEY)
+LPHKL = ctypes.POINTER(HKL)
+LPINT = PINT = ctypes.POINTER(INT)
+PLARGE_INTEGER = ctypes.POINTER(LARGE_INTEGER)
+PLCID = ctypes.POINTER(LCID)
+LPLONG = PLONG = ctypes.POINTER(LONG)
+LPMSG = PMSG = ctypes.POINTER(MSG)
+LPPOINT = PPOINT = ctypes.POINTER(POINT)
+PPOINTL = ctypes.POINTER(POINTL)
+LPRECT = PRECT = ctypes.POINTER(RECT)
+LPRECTL = PRECTL = ctypes.POINTER(RECTL)
+LPSC_HANDLE = ctypes.POINTER(SC_HANDLE)
+PSHORT = ctypes.POINTER(SHORT)
+LPSIZE = PSIZE = ctypes.POINTER(SIZE)
+LPSIZEL = PSIZEL = ctypes.POINTER(SIZEL)
+PSMALL_RECT = ctypes.POINTER(SMALL_RECT)
+LPUINT = PUINT = ctypes.POINTER(UINT)
+PULARGE_INTEGER = ctypes.POINTER(ULARGE_INTEGER)
+PULONG = ctypes.POINTER(ULONG)
+PUSHORT = ctypes.POINTER(USHORT)
+PWCHAR = ctypes.POINTER(WCHAR)
+LPWIN32_FIND_DATAA = PWIN32_FIND_DATAA = ctypes.POINTER(WIN32_FIND_DATAA)
+LPWIN32_FIND_DATAW = PWIN32_FIND_DATAW = ctypes.POINTER(WIN32_FIND_DATAW)
+LPWORD = PWORD = ctypes.POINTER(WORD)
diff --git a/Lib/datetime.py b/Lib/datetime.py
new file mode 100644
index 0000000000..47e54ec235
--- /dev/null
+++ b/Lib/datetime.py
@@ -0,0 +1,2108 @@
+"""Concrete date/time and related types -- prototype implemented in Python.
+
+See http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage
+
+See also http://dir.yahoo.com/Reference/calendars/
+
+For a primer on DST, including many current DST rules, see
+http://webexhibits.org/daylightsaving/
+
+For more about DST than you ever wanted to know, see
+ftp://elsie.nci.nih.gov/pub/
+
+Sources for time zone and DST data: http://www.twinsun.com/tz/tz-link.htm
+
+This was originally copied from the sandbox of the CPython CVS repository.
+Thanks to Tim Peters for suggesting using it.
+"""
+
+import time as _time
+import math as _math
+
+def _cmp(x, y):
+ return 0 if x == y else 1 if x > y else -1
+
+MINYEAR = 1
+MAXYEAR = 9999
+_MAXORDINAL = 3652059 # date.max.toordinal()
+
+# Utility functions, adapted from Python's Demo/classes/Dates.py, which
+# also assumes the current Gregorian calendar indefinitely extended in
+# both directions. Difference: Dates.py calls January 1 of year 0 day
+# number 1. The code here calls January 1 of year 1 day number 1. This is
+# to match the definition of the "proleptic Gregorian" calendar in Dershowitz
+# and Reingold's "Calendrical Calculations", where it's the base calendar
+# for all computations. See the book for algorithms for converting between
+# proleptic Gregorian ordinals and many other calendar systems.
+
+_DAYS_IN_MONTH = [None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+
+_DAYS_BEFORE_MONTH = [None]
+dbm = 0
+for dim in _DAYS_IN_MONTH[1:]:
+ _DAYS_BEFORE_MONTH.append(dbm)
+ dbm += dim
+del dbm, dim
+
+def _is_leap(year):
+ "year -> 1 if leap year, else 0."
+ return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
+
+def _days_before_year(year):
+ "year -> number of days before January 1st of year."
+ y = year - 1
+ return y*365 + y//4 - y//100 + y//400
+
+def _days_in_month(year, month):
+ "year, month -> number of days in that month in that year."
+ assert 1 <= month <= 12, month
+ if month == 2 and _is_leap(year):
+ return 29
+ return _DAYS_IN_MONTH[month]
+
+def _days_before_month(year, month):
+ "year, month -> number of days in year preceeding first day of month."
+ assert 1 <= month <= 12, 'month must be in 1..12'
+ return _DAYS_BEFORE_MONTH[month] + (month > 2 and _is_leap(year))
+
+def _ymd2ord(year, month, day):
+ "year, month, day -> ordinal, considering 01-Jan-0001 as day 1."
+ assert 1 <= month <= 12, 'month must be in 1..12'
+ dim = _days_in_month(year, month)
+ assert 1 <= day <= dim, ('day must be in 1..%d' % dim)
+ return (_days_before_year(year) +
+ _days_before_month(year, month) +
+ day)
+
+_DI400Y = _days_before_year(401) # number of days in 400 years
+_DI100Y = _days_before_year(101) # " " " " 100 "
+_DI4Y = _days_before_year(5) # " " " " 4 "
+
+# A 4-year cycle has an extra leap day over what we'd get from pasting
+# together 4 single years.
+assert _DI4Y == 4 * 365 + 1
+
+# Similarly, a 400-year cycle has an extra leap day over what we'd get from
+# pasting together 4 100-year cycles.
+assert _DI400Y == 4 * _DI100Y + 1
+
+# OTOH, a 100-year cycle has one fewer leap day than we'd get from
+# pasting together 25 4-year cycles.
+assert _DI100Y == 25 * _DI4Y - 1
+
+def _ord2ymd(n):
+ "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1."
+
+ # n is a 1-based index, starting at 1-Jan-1. The pattern of leap years
+ # repeats exactly every 400 years. The basic strategy is to find the
+ # closest 400-year boundary at or before n, then work with the offset
+ # from that boundary to n. Life is much clearer if we subtract 1 from
+ # n first -- then the values of n at 400-year boundaries are exactly
+ # those divisible by _DI400Y:
+ #
+ # D M Y n n-1
+ # -- --- ---- ---------- ----------------
+ # 31 Dec -400 -_DI400Y -_DI400Y -1
+ # 1 Jan -399 -_DI400Y +1 -_DI400Y 400-year boundary
+ # ...
+ # 30 Dec 000 -1 -2
+ # 31 Dec 000 0 -1
+ # 1 Jan 001 1 0 400-year boundary
+ # 2 Jan 001 2 1
+ # 3 Jan 001 3 2
+ # ...
+ # 31 Dec 400 _DI400Y _DI400Y -1
+ # 1 Jan 401 _DI400Y +1 _DI400Y 400-year boundary
+ n -= 1
+ n400, n = divmod(n, _DI400Y)
+ year = n400 * 400 + 1 # ..., -399, 1, 401, ...
+
+ # Now n is the (non-negative) offset, in days, from January 1 of year, to
+ # the desired date. Now compute how many 100-year cycles precede n.
+ # Note that it's possible for n100 to equal 4! In that case 4 full
+ # 100-year cycles precede the desired day, which implies the desired
+ # day is December 31 at the end of a 400-year cycle.
+ n100, n = divmod(n, _DI100Y)
+
+ # Now compute how many 4-year cycles precede it.
+ n4, n = divmod(n, _DI4Y)
+
+ # And now how many single years. Again n1 can be 4, and again meaning
+ # that the desired day is December 31 at the end of the 4-year cycle.
+ n1, n = divmod(n, 365)
+
+ year += n100 * 100 + n4 * 4 + n1
+ if n1 == 4 or n100 == 4:
+ assert n == 0
+ return year-1, 12, 31
+
+ # Now the year is correct, and n is the offset from January 1. We find
+ # the month via an estimate that's either exact or one too large.
+ leapyear = n1 == 3 and (n4 != 24 or n100 == 3)
+ assert leapyear == _is_leap(year)
+ month = (n + 50) >> 5
+ preceding = _DAYS_BEFORE_MONTH[month] + (month > 2 and leapyear)
+ if preceding > n: # estimate is too large
+ month -= 1
+ preceding -= _DAYS_IN_MONTH[month] + (month == 2 and leapyear)
+ n -= preceding
+ assert 0 <= n < _days_in_month(year, month)
+
+ # Now the year and month are correct, and n is the offset from the
+ # start of that month: we're done!
+ return year, month, n+1
+
+# Month and day names. For localized versions, see the calendar module.
+_MONTHNAMES = [None, "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+_DAYNAMES = [None, "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
+
+
+def _build_struct_time(y, m, d, hh, mm, ss, dstflag):
+ wday = (_ymd2ord(y, m, d) + 6) % 7
+ dnum = _days_before_month(y, m) + d
+ return _time.struct_time((y, m, d, hh, mm, ss, wday, dnum, dstflag))
+
+def _format_time(hh, mm, ss, us):
+ # Skip trailing microseconds when us==0.
+ result = "%02d:%02d:%02d" % (hh, mm, ss)
+ if us:
+ result += ".%06d" % us
+ return result
+
+# Correctly substitute for %z and %Z escapes in strftime formats.
+def _wrap_strftime(object, format, timetuple):
+ year = timetuple[0]
+ if year < 1000:
+ raise ValueError("year=%d is before 1000; the datetime strftime() "
+ "methods require year >= 1000" % year)
+ # Don't call utcoffset() or tzname() unless actually needed.
+ freplace = None # the string to use for %f
+ zreplace = None # the string to use for %z
+ Zreplace = None # the string to use for %Z
+
+ # Scan format for %z and %Z escapes, replacing as needed.
+ newformat = []
+ push = newformat.append
+ i, n = 0, len(format)
+ while i < n:
+ ch = format[i]
+ i += 1
+ if ch == '%':
+ if i < n:
+ ch = format[i]
+ i += 1
+ if ch == 'f':
+ if freplace is None:
+ freplace = '%06d' % getattr(object,
+ 'microsecond', 0)
+ newformat.append(freplace)
+ elif ch == 'z':
+ if zreplace is None:
+ zreplace = ""
+ if hasattr(object, "utcoffset"):
+ offset = object.utcoffset()
+ if offset is not None:
+ sign = '+'
+ if offset.days < 0:
+ offset = -offset
+ sign = '-'
+ h, m = divmod(offset, timedelta(hours=1))
+ assert not m % timedelta(minutes=1), "whole minute"
+ m //= timedelta(minutes=1)
+ zreplace = '%c%02d%02d' % (sign, h, m)
+ assert '%' not in zreplace
+ newformat.append(zreplace)
+ elif ch == 'Z':
+ if Zreplace is None:
+ Zreplace = ""
+ if hasattr(object, "tzname"):
+ s = object.tzname()
+ if s is not None:
+ # strftime is going to have at this: escape %
+ Zreplace = s.replace('%', '%%')
+ newformat.append(Zreplace)
+ else:
+ push('%')
+ push(ch)
+ else:
+ push('%')
+ else:
+ push(ch)
+ newformat = "".join(newformat)
+ return _time.strftime(newformat, timetuple)
+
+def _call_tzinfo_method(tzinfo, methname, tzinfoarg):
+ if tzinfo is None:
+ return None
+ return getattr(tzinfo, methname)(tzinfoarg)
+
+# Just raise TypeError if the arg isn't None or a string.
+def _check_tzname(name):
+ if name is not None and not isinstance(name, str):
+ raise TypeError("tzinfo.tzname() must return None or string, "
+ "not '%s'" % type(name))
+
+# name is the offset-producing method, "utcoffset" or "dst".
+# offset is what it returned.
+# If offset isn't None or timedelta, raises TypeError.
+# If offset is None, returns None.
+# Else offset is checked for being in range, and a whole # of minutes.
+# If it is, its integer value is returned. Else ValueError is raised.
+def _check_utc_offset(name, offset):
+ assert name in ("utcoffset", "dst")
+ if offset is None:
+ return
+ if not isinstance(offset, timedelta):
+ raise TypeError("tzinfo.%s() must return None "
+ "or timedelta, not '%s'" % (name, type(offset)))
+ if offset % timedelta(minutes=1) or offset.microseconds:
+ raise ValueError("tzinfo.%s() must return a whole number "
+ "of minutes, got %s" % (name, offset))
+ if not -timedelta(1) < offset < timedelta(1):
+ raise ValueError("%s()=%s, must be must be strictly between"
+ " -timedelta(hours=24) and timedelta(hours=24)"
+ % (name, offset))
+
+def _check_date_fields(year, month, day):
+ if not isinstance(year, int):
+ raise TypeError('int expected')
+ if not MINYEAR <= year <= MAXYEAR:
+ raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), year)
+ if not 1 <= month <= 12:
+ raise ValueError('month must be in 1..12', month)
+ dim = _days_in_month(year, month)
+ if not 1 <= day <= dim:
+ raise ValueError('day must be in 1..%d' % dim, day)
+
+def _check_time_fields(hour, minute, second, microsecond):
+ if not isinstance(hour, int):
+ raise TypeError('int expected')
+ if not 0 <= hour <= 23:
+ raise ValueError('hour must be in 0..23', hour)
+ if not 0 <= minute <= 59:
+ raise ValueError('minute must be in 0..59', minute)
+ if not 0 <= second <= 59:
+ raise ValueError('second must be in 0..59', second)
+ if not 0 <= microsecond <= 999999:
+ raise ValueError('microsecond must be in 0..999999', microsecond)
+
+def _check_tzinfo_arg(tz):
+ if tz is not None and not isinstance(tz, tzinfo):
+ raise TypeError("tzinfo argument must be None or of a tzinfo subclass")
+
+def _cmperror(x, y):
+ raise TypeError("can't compare '%s' to '%s'" % (
+ type(x).__name__, type(y).__name__))
+
+class timedelta:
+ """Represent the difference between two datetime objects.
+
+ Supported operators:
+
+ - add, subtract timedelta
+ - unary plus, minus, abs
+ - compare to timedelta
+ - multiply, divide by int/long
+
+ In addition, datetime supports subtraction of two datetime objects
+ returning a timedelta, and addition or subtraction of a datetime
+ and a timedelta giving a datetime.
+
+ Representation: (days, seconds, microseconds). Why? Because I
+ felt like it.
+ """
+ __slots__ = '_days', '_seconds', '_microseconds'
+
+ def __new__(cls, days=0, seconds=0, microseconds=0,
+ milliseconds=0, minutes=0, hours=0, weeks=0):
+ # Doing this efficiently and accurately in C is going to be difficult
+ # and error-prone, due to ubiquitous overflow possibilities, and that
+ # C double doesn't have enough bits of precision to represent
+ # microseconds over 10K years faithfully. The code here tries to make
+ # explicit where go-fast assumptions can be relied on, in order to
+ # guide the C implementation; it's way more convoluted than speed-
+ # ignoring auto-overflow-to-long idiomatic Python could be.
+
+ # XXX Check that all inputs are ints or floats.
+
+ # Final values, all integer.
+ # s and us fit in 32-bit signed ints; d isn't bounded.
+ d = s = us = 0
+
+ # Normalize everything to days, seconds, microseconds.
+ days += weeks*7
+ seconds += minutes*60 + hours*3600
+ microseconds += milliseconds*1000
+
+ # Get rid of all fractions, and normalize s and us.
+ # Take a deep breath <wink>.
+ if isinstance(days, float):
+ dayfrac, days = _math.modf(days)
+ daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.))
+ assert daysecondswhole == int(daysecondswhole) # can't overflow
+ s = int(daysecondswhole)
+ assert days == int(days)
+ d = int(days)
+ else:
+ daysecondsfrac = 0.0
+ d = days
+ assert isinstance(daysecondsfrac, float)
+ assert abs(daysecondsfrac) <= 1.0
+ assert isinstance(d, int)
+ assert abs(s) <= 24 * 3600
+ # days isn't referenced again before redefinition
+
+ if isinstance(seconds, float):
+ secondsfrac, seconds = _math.modf(seconds)
+ assert seconds == int(seconds)
+ seconds = int(seconds)
+ secondsfrac += daysecondsfrac
+ assert abs(secondsfrac) <= 2.0
+ else:
+ secondsfrac = daysecondsfrac
+ # daysecondsfrac isn't referenced again
+ assert isinstance(secondsfrac, float)
+ assert abs(secondsfrac) <= 2.0
+
+ assert isinstance(seconds, int)
+ days, seconds = divmod(seconds, 24*3600)
+ d += days
+ s += int(seconds) # can't overflow
+ assert isinstance(s, int)
+ assert abs(s) <= 2 * 24 * 3600
+ # seconds isn't referenced again before redefinition
+
+ usdouble = secondsfrac * 1e6
+ assert abs(usdouble) < 2.1e6 # exact value not critical
+ # secondsfrac isn't referenced again
+
+ if isinstance(microseconds, float):
+ microseconds += usdouble
+ microseconds = round(microseconds, 0)
+ seconds, microseconds = divmod(microseconds, 1e6)
+ assert microseconds == int(microseconds)
+ assert seconds == int(seconds)
+ days, seconds = divmod(seconds, 24.*3600.)
+ assert days == int(days)
+ assert seconds == int(seconds)
+ d += int(days)
+ s += int(seconds) # can't overflow
+ assert isinstance(s, int)
+ assert abs(s) <= 3 * 24 * 3600
+ else:
+ seconds, microseconds = divmod(microseconds, 1000000)
+ days, seconds = divmod(seconds, 24*3600)
+ d += days
+ s += int(seconds) # can't overflow
+ assert isinstance(s, int)
+ assert abs(s) <= 3 * 24 * 3600
+ microseconds = float(microseconds)
+ microseconds += usdouble
+ microseconds = round(microseconds, 0)
+ assert abs(s) <= 3 * 24 * 3600
+ assert abs(microseconds) < 3.1e6
+
+ # Just a little bit of carrying possible for microseconds and seconds.
+ assert isinstance(microseconds, float)
+ assert int(microseconds) == microseconds
+ us = int(microseconds)
+ seconds, us = divmod(us, 1000000)
+ s += seconds # cant't overflow
+ assert isinstance(s, int)
+ days, s = divmod(s, 24*3600)
+ d += days
+
+ assert isinstance(d, int)
+ assert isinstance(s, int) and 0 <= s < 24*3600
+ assert isinstance(us, int) and 0 <= us < 1000000
+
+ self = object.__new__(cls)
+
+ self._days = d
+ self._seconds = s
+ self._microseconds = us
+ if abs(d) > 999999999:
+ raise OverflowError("timedelta # of days is too large: %d" % d)
+
+ return self
+
+ def __repr__(self):
+ if self._microseconds:
+ return "%s(%d, %d, %d)" % ('datetime.' + self.__class__.__name__,
+ self._days,
+ self._seconds,
+ self._microseconds)
+ if self._seconds:
+ return "%s(%d, %d)" % ('datetime.' + self.__class__.__name__,
+ self._days,
+ self._seconds)
+ return "%s(%d)" % ('datetime.' + self.__class__.__name__, self._days)
+
+ def __str__(self):
+ mm, ss = divmod(self._seconds, 60)
+ hh, mm = divmod(mm, 60)
+ s = "%d:%02d:%02d" % (hh, mm, ss)
+ if self._days:
+ def plural(n):
+ return n, abs(n) != 1 and "s" or ""
+ s = ("%d day%s, " % plural(self._days)) + s
+ if self._microseconds:
+ s = s + ".%06d" % self._microseconds
+ return s
+
+ def total_seconds(self):
+ """Total seconds in the duration."""
+ return ((self.days * 86400 + self.seconds)*10**6 +
+ self.microseconds) / 10**6
+
+ # Read-only field accessors
+ @property
+ def days(self):
+ """days"""
+ return self._days
+
+ @property
+ def seconds(self):
+ """seconds"""
+ return self._seconds
+
+ @property
+ def microseconds(self):
+ """microseconds"""
+ return self._microseconds
+
+ def __add__(self, other):
+ if isinstance(other, timedelta):
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(self._days + other._days,
+ self._seconds + other._seconds,
+ self._microseconds + other._microseconds)
+ return NotImplemented
+
+ __radd__ = __add__
+
+ def __sub__(self, other):
+ if isinstance(other, timedelta):
+ return self + -other
+ return NotImplemented
+
+ def __rsub__(self, other):
+ if isinstance(other, timedelta):
+ return -self + other
+ return NotImplemented
+
+ def __neg__(self):
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(-self._days,
+ -self._seconds,
+ -self._microseconds)
+
+ def __pos__(self):
+ return self
+
+ def __abs__(self):
+ if self._days < 0:
+ return -self
+ else:
+ return self
+
+ def __mul__(self, other):
+ if isinstance(other, int):
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(self._days * other,
+ self._seconds * other,
+ self._microseconds * other)
+ if isinstance(other, float):
+ a, b = other.as_integer_ratio()
+ return self * a / b
+ return NotImplemented
+
+ __rmul__ = __mul__
+
+ def _to_microseconds(self):
+ return ((self._days * (24*3600) + self._seconds) * 1000000 +
+ self._microseconds)
+
+ def __floordiv__(self, other):
+ if not isinstance(other, (int, timedelta)):
+ return NotImplemented
+ usec = self._to_microseconds()
+ if isinstance(other, timedelta):
+ return usec // other._to_microseconds()
+ if isinstance(other, int):
+ return timedelta(0, 0, usec // other)
+
+ def __truediv__(self, other):
+ if not isinstance(other, (int, float, timedelta)):
+ return NotImplemented
+ usec = self._to_microseconds()
+ if isinstance(other, timedelta):
+ return usec / other._to_microseconds()
+ if isinstance(other, int):
+ return timedelta(0, 0, usec / other)
+ if isinstance(other, float):
+ a, b = other.as_integer_ratio()
+ return timedelta(0, 0, b * usec / a)
+
+ def __mod__(self, other):
+ if isinstance(other, timedelta):
+ r = self._to_microseconds() % other._to_microseconds()
+ return timedelta(0, 0, r)
+ return NotImplemented
+
+ def __divmod__(self, other):
+ if isinstance(other, timedelta):
+ q, r = divmod(self._to_microseconds(),
+ other._to_microseconds())
+ return q, timedelta(0, 0, r)
+ return NotImplemented
+
+ # Comparisons of timedelta objects with other.
+
+ def __eq__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) == 0
+ else:
+ return False
+
+ def __ne__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) != 0
+ else:
+ return True
+
+ def __le__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) <= 0
+ else:
+ _cmperror(self, other)
+
+ def __lt__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) < 0
+ else:
+ _cmperror(self, other)
+
+ def __ge__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) >= 0
+ else:
+ _cmperror(self, other)
+
+ def __gt__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) > 0
+ else:
+ _cmperror(self, other)
+
+ def _cmp(self, other):
+ assert isinstance(other, timedelta)
+ return _cmp(self._getstate(), other._getstate())
+
+ def __hash__(self):
+ return hash(self._getstate())
+
+ def __bool__(self):
+ return (self._days != 0 or
+ self._seconds != 0 or
+ self._microseconds != 0)
+
+ # Pickle support.
+
+ def _getstate(self):
+ return (self._days, self._seconds, self._microseconds)
+
+ def __reduce__(self):
+ return (self.__class__, self._getstate())
+
+timedelta.min = timedelta(-999999999)
+timedelta.max = timedelta(days=999999999, hours=23, minutes=59, seconds=59,
+ microseconds=999999)
+timedelta.resolution = timedelta(microseconds=1)
+
+class date:
+ """Concrete date type.
+
+ Constructors:
+
+ __new__()
+ fromtimestamp()
+ today()
+ fromordinal()
+
+ Operators:
+
+ __repr__, __str__
+ __cmp__, __hash__
+ __add__, __radd__, __sub__ (add/radd only with timedelta arg)
+
+ Methods:
+
+ timetuple()
+ toordinal()
+ weekday()
+ isoweekday(), isocalendar(), isoformat()
+ ctime()
+ strftime()
+
+ Properties (readonly):
+ year, month, day
+ """
+ __slots__ = '_year', '_month', '_day'
+
+ def __new__(cls, year, month=None, day=None):
+ """Constructor.
+
+ Arguments:
+
+ year, month, day (required, base 1)
+ """
+ if (isinstance(year, bytes) and len(year) == 4 and
+ 1 <= year[2] <= 12 and month is None): # Month is sane
+ # Pickle support
+ self = object.__new__(cls)
+ self.__setstate(year)
+ return self
+ _check_date_fields(year, month, day)
+ self = object.__new__(cls)
+ self._year = year
+ self._month = month
+ self._day = day
+ return self
+
+ # Additional constructors
+
+ @classmethod
+ def fromtimestamp(cls, t):
+ "Construct a date from a POSIX timestamp (like time.time())."
+ y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t)
+ return cls(y, m, d)
+
+ @classmethod
+ def today(cls):
+ "Construct a date from time.time()."
+ t = _time.time()
+ return cls.fromtimestamp(t)
+
+ @classmethod
+ def fromordinal(cls, n):
+ """Contruct a date from a proleptic Gregorian ordinal.
+
+ January 1 of year 1 is day 1. Only the year, month and day are
+ non-zero in the result.
+ """
+ y, m, d = _ord2ymd(n)
+ return cls(y, m, d)
+
+ # Conversions to string
+
+ def __repr__(self):
+ """Convert to formal string, for repr().
+
+ >>> dt = datetime(2010, 1, 1)
+ >>> repr(dt)
+ 'datetime.datetime(2010, 1, 1, 0, 0)'
+
+ >>> dt = datetime(2010, 1, 1, tzinfo=timezone.utc)
+ >>> repr(dt)
+ 'datetime.datetime(2010, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)'
+ """
+ return "%s(%d, %d, %d)" % ('datetime.' + self.__class__.__name__,
+ self._year,
+ self._month,
+ self._day)
+ # XXX These shouldn't depend on time.localtime(), because that
+ # clips the usable dates to [1970 .. 2038). At least ctime() is
+ # easily done without using strftime() -- that's better too because
+ # strftime("%c", ...) is locale specific.
+
+
+ def ctime(self):
+ "Return ctime() style string."
+ weekday = self.toordinal() % 7 or 7
+ return "%s %s %2d 00:00:00 %04d" % (
+ _DAYNAMES[weekday],
+ _MONTHNAMES[self._month],
+ self._day, self._year)
+
+ def strftime(self, fmt):
+ "Format using strftime()."
+ return _wrap_strftime(self, fmt, self.timetuple())
+
+ def __format__(self, fmt):
+ if len(fmt) != 0:
+ return self.strftime(fmt)
+ return str(self)
+
+ def isoformat(self):
+ """Return the date formatted according to ISO.
+
+ This is 'YYYY-MM-DD'.
+
+ References:
+ - http://www.w3.org/TR/NOTE-datetime
+ - http://www.cl.cam.ac.uk/~mgk25/iso-time.html
+ """
+ return "%04d-%02d-%02d" % (self._year, self._month, self._day)
+
+ __str__ = isoformat
+
+ # Read-only field accessors
+ @property
+ def year(self):
+ """year (1-9999)"""
+ return self._year
+
+ @property
+ def month(self):
+ """month (1-12)"""
+ return self._month
+
+ @property
+ def day(self):
+ """day (1-31)"""
+ return self._day
+
+ # Standard conversions, __cmp__, __hash__ (and helpers)
+
+ def timetuple(self):
+ "Return local time tuple compatible with time.localtime()."
+ return _build_struct_time(self._year, self._month, self._day,
+ 0, 0, 0, -1)
+
+ def toordinal(self):
+ """Return proleptic Gregorian ordinal for the year, month and day.
+
+ January 1 of year 1 is day 1. Only the year, month and day values
+ contribute to the result.
+ """
+ return _ymd2ord(self._year, self._month, self._day)
+
+ def replace(self, year=None, month=None, day=None):
+ """Return a new date with new values for the specified fields."""
+ if year is None:
+ year = self._year
+ if month is None:
+ month = self._month
+ if day is None:
+ day = self._day
+ _check_date_fields(year, month, day)
+ return date(year, month, day)
+
+ # Comparisons of date objects with other.
+
+ def __eq__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) == 0
+ return NotImplemented
+
+ def __ne__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) != 0
+ return NotImplemented
+
+ def __le__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) <= 0
+ return NotImplemented
+
+ def __lt__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) < 0
+ return NotImplemented
+
+ def __ge__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) >= 0
+ return NotImplemented
+
+ def __gt__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) > 0
+ return NotImplemented
+
+ def _cmp(self, other):
+ assert isinstance(other, date)
+ y, m, d = self._year, self._month, self._day
+ y2, m2, d2 = other._year, other._month, other._day
+ return _cmp((y, m, d), (y2, m2, d2))
+
+ def __hash__(self):
+ "Hash."
+ return hash(self._getstate())
+
+ # Computations
+
+ def __add__(self, other):
+ "Add a date to a timedelta."
+ if isinstance(other, timedelta):
+ o = self.toordinal() + other.days
+ if 0 < o <= _MAXORDINAL:
+ return date.fromordinal(o)
+ raise OverflowError("result out of range")
+ return NotImplemented
+
+ __radd__ = __add__
+
+ def __sub__(self, other):
+ """Subtract two dates, or a date and a timedelta."""
+ if isinstance(other, timedelta):
+ return self + timedelta(-other.days)
+ if isinstance(other, date):
+ days1 = self.toordinal()
+ days2 = other.toordinal()
+ return timedelta(days1 - days2)
+ return NotImplemented
+
+ def weekday(self):
+ "Return day of the week, where Monday == 0 ... Sunday == 6."
+ return (self.toordinal() + 6) % 7
+
+ # Day-of-the-week and week-of-the-year, according to ISO
+
+ def isoweekday(self):
+ "Return day of the week, where Monday == 1 ... Sunday == 7."
+ # 1-Jan-0001 is a Monday
+ return self.toordinal() % 7 or 7
+
+ def isocalendar(self):
+ """Return a 3-tuple containing ISO year, week number, and weekday.
+
+ The first ISO week of the year is the (Mon-Sun) week
+ containing the year's first Thursday; everything else derives
+ from that.
+
+ The first week is 1; Monday is 1 ... Sunday is 7.
+
+ ISO calendar algorithm taken from
+ http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
+ """
+ year = self._year
+ week1monday = _isoweek1monday(year)
+ today = _ymd2ord(self._year, self._month, self._day)
+ # Internally, week and day have origin 0
+ week, day = divmod(today - week1monday, 7)
+ if week < 0:
+ year -= 1
+ week1monday = _isoweek1monday(year)
+ week, day = divmod(today - week1monday, 7)
+ elif week >= 52:
+ if today >= _isoweek1monday(year+1):
+ year += 1
+ week = 0
+ return year, week+1, day+1
+
+ # Pickle support.
+
+ def _getstate(self):
+ yhi, ylo = divmod(self._year, 256)
+ return bytes([yhi, ylo, self._month, self._day]),
+
+ def __setstate(self, string):
+ if len(string) != 4 or not (1 <= string[2] <= 12):
+ raise TypeError("not enough arguments")
+ yhi, ylo, self._month, self._day = string
+ self._year = yhi * 256 + ylo
+
+ def __reduce__(self):
+ return (self.__class__, self._getstate())
+
+_date_class = date # so functions w/ args named "date" can get at the class
+
+date.min = date(1, 1, 1)
+date.max = date(9999, 12, 31)
+date.resolution = timedelta(days=1)
+
+class tzinfo:
+ """Abstract base class for time zone info classes.
+
+ Subclasses must override the name(), utcoffset() and dst() methods.
+ """
+ __slots__ = ()
+ def tzname(self, dt):
+ "datetime -> string name of time zone."
+ raise NotImplementedError("tzinfo subclass must override tzname()")
+
+ def utcoffset(self, dt):
+ "datetime -> minutes east of UTC (negative for west of UTC)"
+ raise NotImplementedError("tzinfo subclass must override utcoffset()")
+
+ def dst(self, dt):
+ """datetime -> DST offset in minutes east of UTC.
+
+ Return 0 if DST not in effect. utcoffset() must include the DST
+ offset.
+ """
+ raise NotImplementedError("tzinfo subclass must override dst()")
+
+ def fromutc(self, dt):
+ "datetime in UTC -> datetime in local time."
+
+ if not isinstance(dt, datetime):
+ raise TypeError("fromutc() requires a datetime argument")
+ if dt.tzinfo is not self:
+ raise ValueError("dt.tzinfo is not self")
+
+ dtoff = dt.utcoffset()
+ if dtoff is None:
+ raise ValueError("fromutc() requires a non-None utcoffset() "
+ "result")
+
+ # See the long comment block at the end of this file for an
+ # explanation of this algorithm.
+ dtdst = dt.dst()
+ if dtdst is None:
+ raise ValueError("fromutc() requires a non-None dst() result")
+ delta = dtoff - dtdst
+ if delta:
+ dt += delta
+ dtdst = dt.dst()
+ if dtdst is None:
+ raise ValueError("fromutc(): dt.dst gave inconsistent "
+ "results; cannot convert")
+ return dt + dtdst
+
+ # Pickle support.
+
+ def __reduce__(self):
+ getinitargs = getattr(self, "__getinitargs__", None)
+ if getinitargs:
+ args = getinitargs()
+ else:
+ args = ()
+ getstate = getattr(self, "__getstate__", None)
+ if getstate:
+ state = getstate()
+ else:
+ state = getattr(self, "__dict__", None) or None
+ if state is None:
+ return (self.__class__, args)
+ else:
+ return (self.__class__, args, state)
+
+_tzinfo_class = tzinfo
+
+class time:
+ """Time with time zone.
+
+ Constructors:
+
+ __new__()
+
+ Operators:
+
+ __repr__, __str__
+ __cmp__, __hash__
+
+ Methods:
+
+ strftime()
+ isoformat()
+ utcoffset()
+ tzname()
+ dst()
+
+ Properties (readonly):
+ hour, minute, second, microsecond, tzinfo
+ """
+
+ def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None):
+ """Constructor.
+
+ Arguments:
+
+ hour, minute (required)
+ second, microsecond (default to zero)
+ tzinfo (default to None)
+ """
+ self = object.__new__(cls)
+ if isinstance(hour, bytes) and len(hour) == 6:
+ # Pickle support
+ self.__setstate(hour, minute or None)
+ return self
+ _check_tzinfo_arg(tzinfo)
+ _check_time_fields(hour, minute, second, microsecond)
+ self._hour = hour
+ self._minute = minute
+ self._second = second
+ self._microsecond = microsecond
+ self._tzinfo = tzinfo
+ return self
+
+ # Read-only field accessors
+ @property
+ def hour(self):
+ """hour (0-23)"""
+ return self._hour
+
+ @property
+ def minute(self):
+ """minute (0-59)"""
+ return self._minute
+
+ @property
+ def second(self):
+ """second (0-59)"""
+ return self._second
+
+ @property
+ def microsecond(self):
+ """microsecond (0-999999)"""
+ return self._microsecond
+
+ @property
+ def tzinfo(self):
+ """timezone info object"""
+ return self._tzinfo
+
+ # Standard conversions, __hash__ (and helpers)
+
+ # Comparisons of time objects with other.
+
+ def __eq__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) == 0
+ else:
+ return False
+
+ def __ne__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) != 0
+ else:
+ return True
+
+ def __le__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) <= 0
+ else:
+ _cmperror(self, other)
+
+ def __lt__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) < 0
+ else:
+ _cmperror(self, other)
+
+ def __ge__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) >= 0
+ else:
+ _cmperror(self, other)
+
+ def __gt__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) > 0
+ else:
+ _cmperror(self, other)
+
+ def _cmp(self, other):
+ assert isinstance(other, time)
+ mytz = self._tzinfo
+ ottz = other._tzinfo
+ myoff = otoff = None
+
+ if mytz is ottz:
+ base_compare = True
+ else:
+ myoff = self.utcoffset()
+ otoff = other.utcoffset()
+ base_compare = myoff == otoff
+
+ if base_compare:
+ return _cmp((self._hour, self._minute, self._second,
+ self._microsecond),
+ (other._hour, other._minute, other._second,
+ other._microsecond))
+ if myoff is None or otoff is None:
+ raise TypeError("cannot compare naive and aware times")
+ myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1)
+ othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1)
+ return _cmp((myhhmm, self._second, self._microsecond),
+ (othhmm, other._second, other._microsecond))
+
+ def __hash__(self):
+ """Hash."""
+ tzoff = self.utcoffset()
+ if not tzoff: # zero or None
+ return hash(self._getstate()[0])
+ h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff,
+ timedelta(hours=1))
+ assert not m % timedelta(minutes=1), "whole minute"
+ m //= timedelta(minutes=1)
+ if 0 <= h < 24:
+ return hash(time(h, m, self.second, self.microsecond))
+ return hash((h, m, self.second, self.microsecond))
+
+ # Conversion to string
+
+ def _tzstr(self, sep=":"):
+ """Return formatted timezone offset (+xx:xx) or None."""
+ off = self.utcoffset()
+ if off is not None:
+ if off.days < 0:
+ sign = "-"
+ off = -off
+ else:
+ sign = "+"
+ hh, mm = divmod(off, timedelta(hours=1))
+ assert not mm % timedelta(minutes=1), "whole minute"
+ mm //= timedelta(minutes=1)
+ assert 0 <= hh < 24
+ off = "%s%02d%s%02d" % (sign, hh, sep, mm)
+ return off
+
+ def __repr__(self):
+ """Convert to formal string, for repr()."""
+ if self._microsecond != 0:
+ s = ", %d, %d" % (self._second, self._microsecond)
+ elif self._second != 0:
+ s = ", %d" % self._second
+ else:
+ s = ""
+ s= "%s(%d, %d%s)" % ('datetime.' + self.__class__.__name__,
+ self._hour, self._minute, s)
+ if self._tzinfo is not None:
+ assert s[-1:] == ")"
+ s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")"
+ return s
+
+ def isoformat(self):
+ """Return the time formatted according to ISO.
+
+ This is 'HH:MM:SS.mmmmmm+zz:zz', or 'HH:MM:SS+zz:zz' if
+ self.microsecond == 0.
+ """
+ s = _format_time(self._hour, self._minute, self._second,
+ self._microsecond)
+ tz = self._tzstr()
+ if tz:
+ s += tz
+ return s
+
+ __str__ = isoformat
+
+ def strftime(self, fmt):
+ """Format using strftime(). The date part of the timestamp passed
+ to underlying strftime should not be used.
+ """
+ # The year must be >= 1000 else Python's strftime implementation
+ # can raise a bogus exception.
+ timetuple = (1900, 1, 1,
+ self._hour, self._minute, self._second,
+ 0, 1, -1)
+ return _wrap_strftime(self, fmt, timetuple)
+
+ def __format__(self, fmt):
+ if len(fmt) != 0:
+ return self.strftime(fmt)
+ return str(self)
+
+ # Timezone functions
+
+ def utcoffset(self):
+ """Return the timezone offset in minutes east of UTC (negative west of
+ UTC)."""
+ if self._tzinfo is None:
+ return None
+ offset = self._tzinfo.utcoffset(None)
+ _check_utc_offset("utcoffset", offset)
+ return offset
+
+ def tzname(self):
+ """Return the timezone name.
+
+ Note that the name is 100% informational -- there's no requirement that
+ it mean anything in particular. For example, "GMT", "UTC", "-500",
+ "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
+ """
+ if self._tzinfo is None:
+ return None
+ name = self._tzinfo.tzname(None)
+ _check_tzname(name)
+ return name
+
+ def dst(self):
+ """Return 0 if DST is not in effect, or the DST offset (in minutes
+ eastward) if DST is in effect.
+
+ This is purely informational; the DST offset has already been added to
+ the UTC offset returned by utcoffset() if applicable, so there's no
+ need to consult dst() unless you're interested in displaying the DST
+ info.
+ """
+ if self._tzinfo is None:
+ return None
+ offset = self._tzinfo.dst(None)
+ _check_utc_offset("dst", offset)
+ return offset
+
+ def replace(self, hour=None, minute=None, second=None, microsecond=None,
+ tzinfo=True):
+ """Return a new time with new values for the specified fields."""
+ if hour is None:
+ hour = self.hour
+ if minute is None:
+ minute = self.minute
+ if second is None:
+ second = self.second
+ if microsecond is None:
+ microsecond = self.microsecond
+ if tzinfo is True:
+ tzinfo = self.tzinfo
+ _check_time_fields(hour, minute, second, microsecond)
+ _check_tzinfo_arg(tzinfo)
+ return time(hour, minute, second, microsecond, tzinfo)
+
+ def __bool__(self):
+ if self.second or self.microsecond:
+ return True
+ offset = self.utcoffset() or timedelta(0)
+ return timedelta(hours=self.hour, minutes=self.minute) != offset
+
+ # Pickle support.
+
+ def _getstate(self):
+ us2, us3 = divmod(self._microsecond, 256)
+ us1, us2 = divmod(us2, 256)
+ basestate = bytes([self._hour, self._minute, self._second,
+ us1, us2, us3])
+ if self._tzinfo is None:
+ return (basestate,)
+ else:
+ return (basestate, self._tzinfo)
+
+ def __setstate(self, string, tzinfo):
+ if len(string) != 6 or string[0] >= 24:
+ raise TypeError("an integer is required")
+ (self._hour, self._minute, self._second,
+ us1, us2, us3) = string
+ self._microsecond = (((us1 << 8) | us2) << 8) | us3
+ if tzinfo is None or isinstance(tzinfo, _tzinfo_class):
+ self._tzinfo = tzinfo
+ else:
+ raise TypeError("bad tzinfo state arg %r" % tzinfo)
+
+ def __reduce__(self):
+ return (time, self._getstate())
+
+_time_class = time # so functions w/ args named "time" can get at the class
+
+time.min = time(0, 0, 0)
+time.max = time(23, 59, 59, 999999)
+time.resolution = timedelta(microseconds=1)
+
+class datetime(date):
+ """datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
+
+ The year, month and day arguments are required. tzinfo may be None, or an
+ instance of a tzinfo subclass. The remaining arguments may be ints or longs.
+ """
+
+ __slots__ = date.__slots__ + (
+ '_hour', '_minute', '_second',
+ '_microsecond', '_tzinfo')
+ def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
+ microsecond=0, tzinfo=None):
+ if isinstance(year, bytes) and len(year) == 10:
+ # Pickle support
+ self = date.__new__(cls, year[:4])
+ self.__setstate(year, month)
+ return self
+ _check_tzinfo_arg(tzinfo)
+ _check_time_fields(hour, minute, second, microsecond)
+ self = date.__new__(cls, year, month, day)
+ self._hour = hour
+ self._minute = minute
+ self._second = second
+ self._microsecond = microsecond
+ self._tzinfo = tzinfo
+ return self
+
+ # Read-only field accessors
+ @property
+ def hour(self):
+ """hour (0-23)"""
+ return self._hour
+
+ @property
+ def minute(self):
+ """minute (0-59)"""
+ return self._minute
+
+ @property
+ def second(self):
+ """second (0-59)"""
+ return self._second
+
+ @property
+ def microsecond(self):
+ """microsecond (0-999999)"""
+ return self._microsecond
+
+ @property
+ def tzinfo(self):
+ """timezone info object"""
+ return self._tzinfo
+
+ @classmethod
+ def fromtimestamp(cls, t, tz=None):
+ """Construct a datetime from a POSIX timestamp (like time.time()).
+
+ A timezone info object may be passed in as well.
+ """
+
+ _check_tzinfo_arg(tz)
+
+ converter = _time.localtime if tz is None else _time.gmtime
+
+ t, frac = divmod(t, 1.0)
+ us = round(frac * 1e6)
+
+ # If timestamp is less than one microsecond smaller than a
+ # full second, us can be rounded up to 1000000. In this case,
+ # roll over to seconds, otherwise, ValueError is raised
+ # by the constructor.
+ if us == 1000000:
+ t += 1
+ us = 0
+ y, m, d, hh, mm, ss, weekday, jday, dst = converter(t)
+ ss = min(ss, 59) # clamp out leap seconds if the platform has them
+ result = cls(y, m, d, hh, mm, ss, us, tz)
+ if tz is not None:
+ result = tz.fromutc(result)
+ return result
+
+ @classmethod
+ def utcfromtimestamp(cls, t):
+ "Construct a UTC datetime from a POSIX timestamp (like time.time())."
+ t, frac = divmod(t, 1.0)
+ us = round(frac * 1e6)
+
+ # If timestamp is less than one microsecond smaller than a
+ # full second, us can be rounded up to 1000000. In this case,
+ # roll over to seconds, otherwise, ValueError is raised
+ # by the constructor.
+ if us == 1000000:
+ t += 1
+ us = 0
+ y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t)
+ ss = min(ss, 59) # clamp out leap seconds if the platform has them
+ return cls(y, m, d, hh, mm, ss, us)
+
+ # XXX This is supposed to do better than we *can* do by using time.time(),
+ # XXX if the platform supports a more accurate way. The C implementation
+ # XXX uses gettimeofday on platforms that have it, but that isn't
+ # XXX available from Python. So now() may return different results
+ # XXX across the implementations.
+ @classmethod
+ def now(cls, tz=None):
+ "Construct a datetime from time.time() and optional time zone info."
+ t = _time.time()
+ return cls.fromtimestamp(t, tz)
+
+ @classmethod
+ def utcnow(cls):
+ "Construct a UTC datetime from time.time()."
+ t = _time.time()
+ return cls.utcfromtimestamp(t)
+
+ @classmethod
+ def combine(cls, date, time):
+ "Construct a datetime from a given date and a given time."
+ if not isinstance(date, _date_class):
+ raise TypeError("date argument must be a date instance")
+ if not isinstance(time, _time_class):
+ raise TypeError("time argument must be a time instance")
+ return cls(date.year, date.month, date.day,
+ time.hour, time.minute, time.second, time.microsecond,
+ time.tzinfo)
+
+ def timetuple(self):
+ "Return local time tuple compatible with time.localtime()."
+ dst = self.dst()
+ if dst is None:
+ dst = -1
+ elif dst:
+ dst = 1
+ else:
+ dst = 0
+ return _build_struct_time(self.year, self.month, self.day,
+ self.hour, self.minute, self.second,
+ dst)
+
+ def utctimetuple(self):
+ "Return UTC time tuple compatible with time.gmtime()."
+ offset = self.utcoffset()
+ if offset:
+ self -= offset
+ y, m, d = self.year, self.month, self.day
+ hh, mm, ss = self.hour, self.minute, self.second
+ return _build_struct_time(y, m, d, hh, mm, ss, 0)
+
+ def date(self):
+ "Return the date part."
+ return date(self._year, self._month, self._day)
+
+ def time(self):
+ "Return the time part, with tzinfo None."
+ return time(self.hour, self.minute, self.second, self.microsecond)
+
+ def timetz(self):
+ "Return the time part, with same tzinfo."
+ return time(self.hour, self.minute, self.second, self.microsecond,
+ self._tzinfo)
+
+ def replace(self, year=None, month=None, day=None, hour=None,
+ minute=None, second=None, microsecond=None, tzinfo=True):
+ """Return a new datetime with new values for the specified fields."""
+ if year is None:
+ year = self.year
+ if month is None:
+ month = self.month
+ if day is None:
+ day = self.day
+ if hour is None:
+ hour = self.hour
+ if minute is None:
+ minute = self.minute
+ if second is None:
+ second = self.second
+ if microsecond is None:
+ microsecond = self.microsecond
+ if tzinfo is True:
+ tzinfo = self.tzinfo
+ _check_date_fields(year, month, day)
+ _check_time_fields(hour, minute, second, microsecond)
+ _check_tzinfo_arg(tzinfo)
+ return datetime(year, month, day, hour, minute, second,
+ microsecond, tzinfo)
+
+ def astimezone(self, tz):
+ if not isinstance(tz, tzinfo):
+ raise TypeError("tz argument must be an instance of tzinfo")
+
+ mytz = self.tzinfo
+ if mytz is None:
+ raise ValueError("astimezone() requires an aware datetime")
+
+ if tz is mytz:
+ return self
+
+ # Convert self to UTC, and attach the new time zone object.
+ myoffset = self.utcoffset()
+ if myoffset is None:
+ raise ValueError("astimezone() requires an aware datetime")
+ utc = (self - myoffset).replace(tzinfo=tz)
+
+ # Convert from UTC to tz's local time.
+ return tz.fromutc(utc)
+
+ # Ways to produce a string.
+
+ def ctime(self):
+ "Return ctime() style string."
+ weekday = self.toordinal() % 7 or 7
+ return "%s %s %2d %02d:%02d:%02d %04d" % (
+ _DAYNAMES[weekday],
+ _MONTHNAMES[self._month],
+ self._day,
+ self._hour, self._minute, self._second,
+ self._year)
+
+ def isoformat(self, sep='T'):
+ """Return the time formatted according to ISO.
+
+ This is 'YYYY-MM-DD HH:MM:SS.mmmmmm', or 'YYYY-MM-DD HH:MM:SS' if
+ self.microsecond == 0.
+
+ If self.tzinfo is not None, the UTC offset is also attached, giving
+ 'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM' or 'YYYY-MM-DD HH:MM:SS+HH:MM'.
+
+ Optional argument sep specifies the separator between date and
+ time, default 'T'.
+ """
+ s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day,
+ sep) +
+ _format_time(self._hour, self._minute, self._second,
+ self._microsecond))
+ off = self.utcoffset()
+ if off is not None:
+ if off.days < 0:
+ sign = "-"
+ off = -off
+ else:
+ sign = "+"
+ hh, mm = divmod(off, timedelta(hours=1))
+ assert not mm % timedelta(minutes=1), "whole minute"
+ mm //= timedelta(minutes=1)
+ s += "%s%02d:%02d" % (sign, hh, mm)
+ return s
+
+ def __repr__(self):
+ """Convert to formal string, for repr()."""
+ L = [self._year, self._month, self._day, # These are never zero
+ self._hour, self._minute, self._second, self._microsecond]
+ if L[-1] == 0:
+ del L[-1]
+ if L[-1] == 0:
+ del L[-1]
+ s = ", ".join(map(str, L))
+ s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s)
+ if self._tzinfo is not None:
+ assert s[-1:] == ")"
+ s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")"
+ return s
+
+ def __str__(self):
+ "Convert to string, for str()."
+ return self.isoformat(sep=' ')
+
+ @classmethod
+ def strptime(cls, date_string, format):
+ 'string, format -> new datetime parsed from a string (like time.strptime()).'
+ import _strptime
+ return _strptime._strptime_datetime(cls, date_string, format)
+
+ def utcoffset(self):
+ """Return the timezone offset in minutes east of UTC (negative west of
+ UTC)."""
+ if self._tzinfo is None:
+ return None
+ offset = self._tzinfo.utcoffset(self)
+ _check_utc_offset("utcoffset", offset)
+ return offset
+
+ def tzname(self):
+ """Return the timezone name.
+
+ Note that the name is 100% informational -- there's no requirement that
+ it mean anything in particular. For example, "GMT", "UTC", "-500",
+ "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
+ """
+ name = _call_tzinfo_method(self._tzinfo, "tzname", self)
+ _check_tzname(name)
+ return name
+
+ def dst(self):
+ """Return 0 if DST is not in effect, or the DST offset (in minutes
+ eastward) if DST is in effect.
+
+ This is purely informational; the DST offset has already been added to
+ the UTC offset returned by utcoffset() if applicable, so there's no
+ need to consult dst() unless you're interested in displaying the DST
+ info.
+ """
+ if self._tzinfo is None:
+ return None
+ offset = self._tzinfo.dst(self)
+ _check_utc_offset("dst", offset)
+ return offset
+
+ # Comparisons of datetime objects with other.
+
+ def __eq__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) == 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ return False
+
+ def __ne__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) != 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ return True
+
+ def __le__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) <= 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ _cmperror(self, other)
+
+ def __lt__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) < 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ _cmperror(self, other)
+
+ def __ge__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) >= 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ _cmperror(self, other)
+
+ def __gt__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) > 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ _cmperror(self, other)
+
+ def _cmp(self, other):
+ assert isinstance(other, datetime)
+ mytz = self._tzinfo
+ ottz = other._tzinfo
+ myoff = otoff = None
+
+ if mytz is ottz:
+ base_compare = True
+ else:
+ if mytz is not None:
+ myoff = self.utcoffset()
+ if ottz is not None:
+ otoff = other.utcoffset()
+ base_compare = myoff == otoff
+
+ if base_compare:
+ return _cmp((self._year, self._month, self._day,
+ self._hour, self._minute, self._second,
+ self._microsecond),
+ (other._year, other._month, other._day,
+ other._hour, other._minute, other._second,
+ other._microsecond))
+ if myoff is None or otoff is None:
+ raise TypeError("cannot compare naive and aware datetimes")
+ # XXX What follows could be done more efficiently...
+ diff = self - other # this will take offsets into account
+ if diff.days < 0:
+ return -1
+ return diff and 1 or 0
+
+ def __add__(self, other):
+ "Add a datetime and a timedelta."
+ if not isinstance(other, timedelta):
+ return NotImplemented
+ delta = timedelta(self.toordinal(),
+ hours=self._hour,
+ minutes=self._minute,
+ seconds=self._second,
+ microseconds=self._microsecond)
+ delta += other
+ hour, rem = divmod(delta.seconds, 3600)
+ minute, second = divmod(rem, 60)
+ if 0 < delta.days <= _MAXORDINAL:
+ return datetime.combine(date.fromordinal(delta.days),
+ time(hour, minute, second,
+ delta.microseconds,
+ tzinfo=self._tzinfo))
+ raise OverflowError("result out of range")
+
+ __radd__ = __add__
+
+ def __sub__(self, other):
+ "Subtract two datetimes, or a datetime and a timedelta."
+ if not isinstance(other, datetime):
+ if isinstance(other, timedelta):
+ return self + -other
+ return NotImplemented
+
+ days1 = self.toordinal()
+ days2 = other.toordinal()
+ secs1 = self._second + self._minute * 60 + self._hour * 3600
+ secs2 = other._second + other._minute * 60 + other._hour * 3600
+ base = timedelta(days1 - days2,
+ secs1 - secs2,
+ self._microsecond - other._microsecond)
+ if self._tzinfo is other._tzinfo:
+ return base
+ myoff = self.utcoffset()
+ otoff = other.utcoffset()
+ if myoff == otoff:
+ return base
+ if myoff is None or otoff is None:
+ raise TypeError("cannot mix naive and timezone-aware time")
+ return base + otoff - myoff
+
+ def __hash__(self):
+ tzoff = self.utcoffset()
+ if tzoff is None:
+ return hash(self._getstate()[0])
+ days = _ymd2ord(self.year, self.month, self.day)
+ seconds = self.hour * 3600 + self.minute * 60 + self.second
+ return hash(timedelta(days, seconds, self.microsecond) - tzoff)
+
+ # Pickle support.
+
+ def _getstate(self):
+ yhi, ylo = divmod(self._year, 256)
+ us2, us3 = divmod(self._microsecond, 256)
+ us1, us2 = divmod(us2, 256)
+ basestate = bytes([yhi, ylo, self._month, self._day,
+ self._hour, self._minute, self._second,
+ us1, us2, us3])
+ if self._tzinfo is None:
+ return (basestate,)
+ else:
+ return (basestate, self._tzinfo)
+
+ def __setstate(self, string, tzinfo):
+ (yhi, ylo, self._month, self._day, self._hour,
+ self._minute, self._second, us1, us2, us3) = string
+ self._year = yhi * 256 + ylo
+ self._microsecond = (((us1 << 8) | us2) << 8) | us3
+ if tzinfo is None or isinstance(tzinfo, _tzinfo_class):
+ self._tzinfo = tzinfo
+ else:
+ raise TypeError("bad tzinfo state arg %r" % tzinfo)
+
+ def __reduce__(self):
+ return (self.__class__, self._getstate())
+
+
+datetime.min = datetime(1, 1, 1)
+datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999)
+datetime.resolution = timedelta(microseconds=1)
+
+
+def _isoweek1monday(year):
+ # Helper to calculate the day number of the Monday starting week 1
+ # XXX This could be done more efficiently
+ THURSDAY = 3
+ firstday = _ymd2ord(year, 1, 1)
+ firstweekday = (firstday + 6) % 7 # See weekday() above
+ week1monday = firstday - firstweekday
+ if firstweekday > THURSDAY:
+ week1monday += 7
+ return week1monday
+
+class timezone(tzinfo):
+ __slots__ = '_offset', '_name'
+
+ # Sentinel value to disallow None
+ _Omitted = object()
+ def __new__(cls, offset, name=_Omitted):
+ if not isinstance(offset, timedelta):
+ raise TypeError("offset must be a timedelta")
+ if name is cls._Omitted:
+ if not offset:
+ return cls.utc
+ name = None
+ elif not isinstance(name, str):
+ raise TypeError("name must be a string")
+ if not cls._minoffset <= offset <= cls._maxoffset:
+ raise ValueError("offset must be a timedelta"
+ " strictly between -timedelta(hours=24) and"
+ " timedelta(hours=24).")
+ if (offset.microseconds != 0 or
+ offset.seconds % 60 != 0):
+ raise ValueError("offset must be a timedelta"
+ " representing a whole number of minutes")
+ return cls._create(offset, name)
+
+ @classmethod
+ def _create(cls, offset, name=None):
+ self = tzinfo.__new__(cls)
+ self._offset = offset
+ self._name = name
+ return self
+
+ def __getinitargs__(self):
+ """pickle support"""
+ if self._name is None:
+ return (self._offset,)
+ return (self._offset, self._name)
+
+ def __eq__(self, other):
+ return self._offset == other._offset
+
+ def __hash__(self):
+ return hash(self._offset)
+
+ def __repr__(self):
+ """Convert to formal string, for repr().
+
+ >>> tz = timezone.utc
+ >>> repr(tz)
+ 'datetime.timezone.utc'
+ >>> tz = timezone(timedelta(hours=-5), 'EST')
+ >>> repr(tz)
+ "datetime.timezone(datetime.timedelta(-1, 68400), 'EST')"
+ """
+ if self is self.utc:
+ return 'datetime.timezone.utc'
+ if self._name is None:
+ return "%s(%r)" % ('datetime.' + self.__class__.__name__,
+ self._offset)
+ return "%s(%r, %r)" % ('datetime.' + self.__class__.__name__,
+ self._offset, self._name)
+
+ def __str__(self):
+ return self.tzname(None)
+
+ def utcoffset(self, dt):
+ if isinstance(dt, datetime) or dt is None:
+ return self._offset
+ raise TypeError("utcoffset() argument must be a datetime instance"
+ " or None")
+
+ def tzname(self, dt):
+ if isinstance(dt, datetime) or dt is None:
+ if self._name is None:
+ return self._name_from_offset(self._offset)
+ return self._name
+ raise TypeError("tzname() argument must be a datetime instance"
+ " or None")
+
+ def dst(self, dt):
+ if isinstance(dt, datetime) or dt is None:
+ return None
+ raise TypeError("dst() argument must be a datetime instance"
+ " or None")
+
+ def fromutc(self, dt):
+ if isinstance(dt, datetime):
+ if dt.tzinfo is not self:
+ raise ValueError("fromutc: dt.tzinfo "
+ "is not self")
+ return dt + self._offset
+ raise TypeError("fromutc() argument must be a datetime instance"
+ " or None")
+
+ _maxoffset = timedelta(hours=23, minutes=59)
+ _minoffset = -_maxoffset
+
+ @staticmethod
+ def _name_from_offset(delta):
+ if delta < timedelta(0):
+ sign = '-'
+ delta = -delta
+ else:
+ sign = '+'
+ hours, rest = divmod(delta, timedelta(hours=1))
+ minutes = rest // timedelta(minutes=1)
+ return 'UTC{}{:02d}:{:02d}'.format(sign, hours, minutes)
+
+timezone.utc = timezone._create(timedelta(0))
+timezone.min = timezone._create(timezone._minoffset)
+timezone.max = timezone._create(timezone._maxoffset)
+
+"""
+Some time zone algebra. For a datetime x, let
+ x.n = x stripped of its timezone -- its naive time.
+ x.o = x.utcoffset(), and assuming that doesn't raise an exception or
+ return None
+ x.d = x.dst(), and assuming that doesn't raise an exception or
+ return None
+ x.s = x's standard offset, x.o - x.d
+
+Now some derived rules, where k is a duration (timedelta).
+
+1. x.o = x.s + x.d
+ This follows from the definition of x.s.
+
+2. If x and y have the same tzinfo member, x.s = y.s.
+ This is actually a requirement, an assumption we need to make about
+ sane tzinfo classes.
+
+3. The naive UTC time corresponding to x is x.n - x.o.
+ This is again a requirement for a sane tzinfo class.
+
+4. (x+k).s = x.s
+ This follows from #2, and that datimetimetz+timedelta preserves tzinfo.
+
+5. (x+k).n = x.n + k
+ Again follows from how arithmetic is defined.
+
+Now we can explain tz.fromutc(x). Let's assume it's an interesting case
+(meaning that the various tzinfo methods exist, and don't blow up or return
+None when called).
+
+The function wants to return a datetime y with timezone tz, equivalent to x.
+x is already in UTC.
+
+By #3, we want
+
+ y.n - y.o = x.n [1]
+
+The algorithm starts by attaching tz to x.n, and calling that y. So
+x.n = y.n at the start. Then it wants to add a duration k to y, so that [1]
+becomes true; in effect, we want to solve [2] for k:
+
+ (y+k).n - (y+k).o = x.n [2]
+
+By #1, this is the same as
+
+ (y+k).n - ((y+k).s + (y+k).d) = x.n [3]
+
+By #5, (y+k).n = y.n + k, which equals x.n + k because x.n=y.n at the start.
+Substituting that into [3],
+
+ x.n + k - (y+k).s - (y+k).d = x.n; the x.n terms cancel, leaving
+ k - (y+k).s - (y+k).d = 0; rearranging,
+ k = (y+k).s - (y+k).d; by #4, (y+k).s == y.s, so
+ k = y.s - (y+k).d
+
+On the RHS, (y+k).d can't be computed directly, but y.s can be, and we
+approximate k by ignoring the (y+k).d term at first. Note that k can't be
+very large, since all offset-returning methods return a duration of magnitude
+less than 24 hours. For that reason, if y is firmly in std time, (y+k).d must
+be 0, so ignoring it has no consequence then.
+
+In any case, the new value is
+
+ z = y + y.s [4]
+
+It's helpful to step back at look at [4] from a higher level: it's simply
+mapping from UTC to tz's standard time.
+
+At this point, if
+
+ z.n - z.o = x.n [5]
+
+we have an equivalent time, and are almost done. The insecurity here is
+at the start of daylight time. Picture US Eastern for concreteness. The wall
+time jumps from 1:59 to 3:00, and wall hours of the form 2:MM don't make good
+sense then. The docs ask that an Eastern tzinfo class consider such a time to
+be EDT (because it's "after 2"), which is a redundant spelling of 1:MM EST
+on the day DST starts. We want to return the 1:MM EST spelling because that's
+the only spelling that makes sense on the local wall clock.
+
+In fact, if [5] holds at this point, we do have the standard-time spelling,
+but that takes a bit of proof. We first prove a stronger result. What's the
+difference between the LHS and RHS of [5]? Let
+
+ diff = x.n - (z.n - z.o) [6]
+
+Now
+ z.n = by [4]
+ (y + y.s).n = by #5
+ y.n + y.s = since y.n = x.n
+ x.n + y.s = since z and y are have the same tzinfo member,
+ y.s = z.s by #2
+ x.n + z.s
+
+Plugging that back into [6] gives
+
+ diff =
+ x.n - ((x.n + z.s) - z.o) = expanding
+ x.n - x.n - z.s + z.o = cancelling
+ - z.s + z.o = by #2
+ z.d
+
+So diff = z.d.
+
+If [5] is true now, diff = 0, so z.d = 0 too, and we have the standard-time
+spelling we wanted in the endcase described above. We're done. Contrarily,
+if z.d = 0, then we have a UTC equivalent, and are also done.
+
+If [5] is not true now, diff = z.d != 0, and z.d is the offset we need to
+add to z (in effect, z is in tz's standard time, and we need to shift the
+local clock into tz's daylight time).
+
+Let
+
+ z' = z + z.d = z + diff [7]
+
+and we can again ask whether
+
+ z'.n - z'.o = x.n [8]
+
+If so, we're done. If not, the tzinfo class is insane, according to the
+assumptions we've made. This also requires a bit of proof. As before, let's
+compute the difference between the LHS and RHS of [8] (and skipping some of
+the justifications for the kinds of substitutions we've done several times
+already):
+
+ diff' = x.n - (z'.n - z'.o) = replacing z'.n via [7]
+ x.n - (z.n + diff - z'.o) = replacing diff via [6]
+ x.n - (z.n + x.n - (z.n - z.o) - z'.o) =
+ x.n - z.n - x.n + z.n - z.o + z'.o = cancel x.n
+ - z.n + z.n - z.o + z'.o = cancel z.n
+ - z.o + z'.o = #1 twice
+ -z.s - z.d + z'.s + z'.d = z and z' have same tzinfo
+ z'.d - z.d
+
+So z' is UTC-equivalent to x iff z'.d = z.d at this point. If they are equal,
+we've found the UTC-equivalent so are done. In fact, we stop with [7] and
+return z', not bothering to compute z'.d.
+
+How could z.d and z'd differ? z' = z + z.d [7], so merely moving z' by
+a dst() offset, and starting *from* a time already in DST (we know z.d != 0),
+would have to change the result dst() returns: we start in DST, and moving
+a little further into it takes us out of DST.
+
+There isn't a sane case where this can happen. The closest it gets is at
+the end of DST, where there's an hour in UTC with no spelling in a hybrid
+tzinfo class. In US Eastern, that's 5:MM UTC = 0:MM EST = 1:MM EDT. During
+that hour, on an Eastern clock 1:MM is taken as being in standard time (6:MM
+UTC) because the docs insist on that, but 0:MM is taken as being in daylight
+time (4:MM UTC). There is no local time mapping to 5:MM UTC. The local
+clock jumps from 1:59 back to 1:00 again, and repeats the 1:MM hour in
+standard time. Since that's what the local clock *does*, we want to map both
+UTC hours 5:MM and 6:MM to 1:MM Eastern. The result is ambiguous
+in local time, but so it goes -- it's the way the local clock works.
+
+When x = 5:MM UTC is the input to this algorithm, x.o=0, y.o=-5 and y.d=0,
+so z=0:MM. z.d=60 (minutes) then, so [5] doesn't hold and we keep going.
+z' = z + z.d = 1:MM then, and z'.d=0, and z'.d - z.d = -60 != 0 so [8]
+(correctly) concludes that z' is not UTC-equivalent to x.
+
+Because we know z.d said z was in daylight time (else [5] would have held and
+we would have stopped then), and we know z.d != z'.d (else [8] would have held
+and we we have stopped then), and there are only 2 possible values dst() can
+return in Eastern, it follows that z'.d must be 0 (which it is in the example,
+but the reasoning doesn't depend on the example -- it depends on there being
+two possible dst() outcomes, one zero and the other non-zero). Therefore
+z' must be in standard time, and is the spelling we want in this case.
+
+Note again that z' is not UTC-equivalent as far as the hybrid tzinfo class is
+concerned (because it takes z' as being in standard time rather than the
+daylight time we intend here), but returning it gives the real-life "local
+clock repeats an hour" behavior when mapping the "unspellable" UTC hour into
+tz.
+
+When the input is 6:MM, z=1:MM and z.d=0, and we stop at once, again with
+the 1:MM standard time spelling we want.
+
+So how can this break? One of the assumptions must be violated. Two
+possibilities:
+
+1) [2] effectively says that y.s is invariant across all y belong to a given
+ time zone. This isn't true if, for political reasons or continental drift,
+ a region decides to change its base offset from UTC.
+
+2) There may be versions of "double daylight" time where the tail end of
+ the analysis gives up a step too early. I haven't thought about that
+ enough to say.
+
+In any case, it's clear that the default fromutc() is strong enough to handle
+"almost all" time zones: so long as the standard offset is invariant, it
+doesn't matter if daylight time transition points change from year to year, or
+if daylight time is skipped in some years; it doesn't matter how large or
+small dst() may get within its bounds; and it doesn't even matter if some
+perverse time zone returns a negative dst()). So a breaking case must be
+pretty bizarre, and a tzinfo subclass can override fromutc() if it is.
+"""
+try:
+ from _datetime import *
+except ImportError:
+ pass
+else:
+ # Clean up unused names
+ del (_DAYNAMES, _DAYS_BEFORE_MONTH, _DAYS_IN_MONTH,
+ _DI100Y, _DI400Y, _DI4Y, _MAXORDINAL, _MONTHNAMES,
+ _build_struct_time, _call_tzinfo_method, _check_date_fields,
+ _check_time_fields, _check_tzinfo_arg, _check_tzname,
+ _check_utc_offset, _cmp, _cmperror, _date_class, _days_before_month,
+ _days_before_year, _days_in_month, _format_time, _is_leap,
+ _isoweek1monday, _math, _ord2ymd, _time, _time_class, _tzinfo_class,
+ _wrap_strftime, _ymd2ord)
+ # XXX Since import * above excludes names that start with _,
+ # docstring does not get overwritten. In the future, it may be
+ # appropriate to maintain a single module level docstring and
+ # remove the following line.
+ from _datetime import __doc__
diff --git a/Lib/dbm/__init__.py b/Lib/dbm/__init__.py
index 99c16379a9..6e890f36aa 100644
--- a/Lib/dbm/__init__.py
+++ b/Lib/dbm/__init__.py
@@ -5,12 +5,11 @@ Use
import dbm
d = dbm.open(file, 'w', 0o666)
-The returned object is a dbm.bsd, dbm.gnu, dbm.ndbm or dbm.dumb
-object, dependent on the type of database being opened (determined by
-the whichdb function) in the case of an existing dbm. If the dbm does
-not exist and the create or new flag ('c' or 'n') was specified, the
-dbm type will be determined by the availability of the modules (tested
-in the above order).
+The returned object is a dbm.gnu, dbm.ndbm or dbm.dumb object, dependent on the
+type of database being opened (determined by the whichdb function) in the case
+of an existing dbm. If the dbm does not exist and the create or new flag ('c'
+or 'n') was specified, the dbm type will be determined by the availability of
+the modules (tested in the above order).
It has the following interface (key and data are strings):
@@ -36,7 +35,7 @@ Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
only if it doesn't exist; and 'n' always creates a new database.
"""
-__all__ = ['open', 'whichdb', 'error', 'error']
+__all__ = ['open', 'whichdb', 'error']
import io
import os
@@ -47,7 +46,7 @@ import sys
class error(Exception):
pass
-_names = ['dbm.bsd', 'dbm.gnu', 'dbm.ndbm', 'dbm.dumb']
+_names = ['dbm.gnu', 'dbm.ndbm', 'dbm.dumb']
_defaultmod = None
_modules = {}
@@ -168,10 +167,6 @@ def whichdb(filename):
if magic == 0x13579ace:
return "dbm.gnu"
- ## Check for old Berkeley db hash file format v2
- #if magic in (0x00061561, 0x61150600):
- # return "bsddb185" # not supported anymore
-
# Later versions of Berkeley db hash file have a 12-byte pad in
# front of the file type
try:
@@ -179,10 +174,6 @@ def whichdb(filename):
except struct.error:
return ""
- ## Check for BSD hash
- #if magic in (0x00061561, 0x61150600):
- # return "dbm.bsd"
-
# Unknown
return ""
diff --git a/Lib/dbm/dumb.py b/Lib/dbm/dumb.py
index 4d804daa0f..cfb912371c 100644
--- a/Lib/dbm/dumb.py
+++ b/Lib/dbm/dumb.py
@@ -203,7 +203,7 @@ class _Database(collections.MutableMapping):
# The blocks used by the associated value are lost.
del self._index[key]
# XXX It's unclear why we do a _commit() here (the code always
- # XXX has, so I'm not changing it). _setitem__ doesn't try to
+ # XXX has, so I'm not changing it). __setitem__ doesn't try to
# XXX keep the directory file in synch. Why should we? Or
# XXX why shouldn't __setitem__?
self._commit()
@@ -232,7 +232,7 @@ class _Database(collections.MutableMapping):
__del__ = close
- def _chmod (self, file):
+ def _chmod(self, file):
if hasattr(self._os, 'chmod'):
self._os.chmod(file, self._mode)
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 5d517ed627..e6b70cad16 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -31,7 +31,8 @@ issues associated with binary floating point. The package is especially
useful for financial applications or for contexts where users have
expectations that are at odds with binary floating point (for instance,
in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead
-of the expected Decimal('0.00') returned by decimal floating point).
+of 0.0; Decimal('1.00') % Decimal('0.1') returns the expected
+Decimal('0.00')).
Here are some examples of using the decimal module:
@@ -131,6 +132,7 @@ __all__ = [
]
__version__ = '1.70' # Highest version of the spec this complies with
+ # See http://speleotrove.com/decimal/
import copy as _copy
import math as _math
@@ -648,8 +650,12 @@ class Decimal(object):
return self
if isinstance(value, float):
- raise TypeError("Cannot convert float in Decimal constructor. "
- "Use from_float class method.")
+ value = Decimal.from_float(value)
+ self._exp = value._exp
+ self._sign = value._sign
+ self._int = value._int
+ self._is_special = value._is_special
+ return self
raise TypeError("Cannot convert %r to Decimal" % value)
@@ -845,8 +851,11 @@ class Decimal(object):
# subject of what should happen for a comparison involving a NaN.
# We take the following approach:
#
- # == comparisons involving a NaN always return False
- # != comparisons involving a NaN always return True
+ # == comparisons involving a quiet NaN always return False
+ # != comparisons involving a quiet NaN always return True
+ # == or != comparisons involving a signaling NaN signal
+ # InvalidOperation, and return False or True as above if the
+ # InvalidOperation is not trapped.
# <, >, <= and >= comparisons involving a (quiet or signaling)
# NaN signal InvalidOperation, and return False if the
# InvalidOperation is not trapped.
@@ -854,25 +863,25 @@ class Decimal(object):
# This behavior is designed to conform as closely as possible to
# that specified by IEEE 754.
- def __eq__(self, other):
- other = _convert_other(other)
+ def __eq__(self, other, context=None):
+ self, other = _convert_for_comparison(self, other, equality_op=True)
if other is NotImplemented:
return other
- if self.is_nan() or other.is_nan():
+ if self._check_nans(other, context):
return False
return self._cmp(other) == 0
- def __ne__(self, other):
- other = _convert_other(other)
+ def __ne__(self, other, context=None):
+ self, other = _convert_for_comparison(self, other, equality_op=True)
if other is NotImplemented:
return other
- if self.is_nan() or other.is_nan():
+ if self._check_nans(other, context):
return True
return self._cmp(other) != 0
def __lt__(self, other, context=None):
- other = _convert_other(other)
+ self, other = _convert_for_comparison(self, other)
if other is NotImplemented:
return other
ans = self._compare_check_nans(other, context)
@@ -881,7 +890,7 @@ class Decimal(object):
return self._cmp(other) < 0
def __le__(self, other, context=None):
- other = _convert_other(other)
+ self, other = _convert_for_comparison(self, other)
if other is NotImplemented:
return other
ans = self._compare_check_nans(other, context)
@@ -890,7 +899,7 @@ class Decimal(object):
return self._cmp(other) <= 0
def __gt__(self, other, context=None):
- other = _convert_other(other)
+ self, other = _convert_for_comparison(self, other)
if other is NotImplemented:
return other
ans = self._compare_check_nans(other, context)
@@ -899,7 +908,7 @@ class Decimal(object):
return self._cmp(other) > 0
def __ge__(self, other, context=None):
- other = _convert_other(other)
+ self, other = _convert_for_comparison(self, other)
if other is NotImplemented:
return other
ans = self._compare_check_nans(other, context)
@@ -928,33 +937,29 @@ class Decimal(object):
def __hash__(self):
"""x.__hash__() <==> hash(x)"""
- # Decimal integers must hash the same as the ints
- #
- # The hash of a nonspecial noninteger Decimal must depend only
- # on the value of that Decimal, and not on its representation.
- # For example: hash(Decimal('100E-1')) == hash(Decimal('10')).
+
+ # In order to make sure that the hash of a Decimal instance
+ # agrees with the hash of a numerically equal integer, float
+ # or Fraction, we follow the rules for numeric hashes outlined
+ # in the documentation. (See library docs, 'Built-in Types').
if self._is_special:
- if self._isnan():
- raise TypeError('Cannot hash a NaN value.')
- return hash(str(self))
- if not self:
- return 0
- if self._isinteger():
- op = _WorkRep(self.to_integral_value())
- # to make computation feasible for Decimals with large
- # exponent, we use the fact that hash(n) == hash(m) for
- # any two nonzero integers n and m such that (i) n and m
- # have the same sign, and (ii) n is congruent to m modulo
- # 2**64-1. So we can replace hash((-1)**s*c*10**e) with
- # hash((-1)**s*c*pow(10, e, 2**64-1).
- return hash((-1)**op.sign*op.int*pow(10, op.exp, 2**64-1))
- # The value of a nonzero nonspecial Decimal instance is
- # faithfully represented by the triple consisting of its sign,
- # its adjusted exponent, and its coefficient with trailing
- # zeros removed.
- return hash((self._sign,
- self._exp+len(self._int),
- self._int.rstrip('0')))
+ if self.is_snan():
+ raise TypeError('Cannot hash a signaling NaN value.')
+ elif self.is_nan():
+ return _PyHASH_NAN
+ else:
+ if self._sign:
+ return -_PyHASH_INF
+ else:
+ return _PyHASH_INF
+
+ if self._exp >= 0:
+ exp_hash = pow(10, self._exp, _PyHASH_MODULUS)
+ else:
+ exp_hash = pow(_PyHASH_10INV, -self._exp, _PyHASH_MODULUS)
+ hash_ = int(self._int) * exp_hash % _PyHASH_MODULUS
+ ans = hash_ if self >= 0 else -hash_
+ return -2 if ans == -1 else ans
def as_tuple(self):
"""Represents the number as a triple tuple.
@@ -1585,9 +1590,9 @@ class Decimal(object):
"""Decapitate the payload of a NaN to fit the context"""
payload = self._int
- # maximum length of payload is precision if _clamp=0,
- # precision-1 if _clamp=1.
- max_payload_len = context.prec - context._clamp
+ # maximum length of payload is precision if clamp=0,
+ # precision-1 if clamp=1.
+ max_payload_len = context.prec - context.clamp
if len(payload) > max_payload_len:
payload = payload[len(payload)-max_payload_len:].lstrip('0')
return _dec_from_triple(self._sign, payload, self._exp, True)
@@ -1612,11 +1617,11 @@ class Decimal(object):
return Decimal(self)
# if self is zero then exponent should be between Etiny and
- # Emax if _clamp==0, and between Etiny and Etop if _clamp==1.
+ # Emax if clamp==0, and between Etiny and Etop if clamp==1.
Etiny = context.Etiny()
Etop = context.Etop()
if not self:
- exp_max = [context.Emax, Etop][context._clamp]
+ exp_max = [context.Emax, Etop][context.clamp]
new_exp = min(max(self._exp, Etiny), exp_max)
if new_exp != self._exp:
context._raise_error(Clamped)
@@ -1676,8 +1681,8 @@ class Decimal(object):
if self_is_subnormal:
context._raise_error(Subnormal)
- # fold down if _clamp == 1 and self has too few digits
- if context._clamp == 1 and self._exp > Etop:
+ # fold down if clamp == 1 and self has too few digits
+ if context.clamp == 1 and self._exp > Etop:
context._raise_error(Clamped)
self_padded = self._int + '0'*(self._exp - Etop)
return _dec_from_triple(self._sign, self_padded, Etop)
@@ -2428,7 +2433,7 @@ class Decimal(object):
if not dup:
return _dec_from_triple(dup._sign, '0', 0)
- exp_max = [context.Emax, context.Etop()][context._clamp]
+ exp_max = [context.Emax, context.Etop()][context.clamp]
end = len(dup._int)
exp = dup._exp
while dup._int[end-1] == '0' and exp < exp_max:
@@ -2942,6 +2947,7 @@ class Decimal(object):
def copy_sign(self, other):
"""Returns self with the sign of other."""
+ other = _convert_other(other, raiseit=True)
return _dec_from_triple(other._sign, self._int,
self._exp, self._is_special)
@@ -3646,12 +3652,12 @@ class Decimal(object):
return (self.__class__, (str(self),))
def __copy__(self):
- if type(self) == Decimal:
+ if type(self) is Decimal:
return self # I'm immutable; therefore I am my own clone
return self.__class__(str(self))
def __deepcopy__(self, memo):
- if type(self) == Decimal:
+ if type(self) is Decimal:
return self # My components are also immutable
return self.__class__(str(self))
@@ -3804,13 +3810,13 @@ class Context(object):
Emax - Maximum exponent
capitals - If 1, 1*10^1 is printed as 1E+1.
If 0, printed as 1e1
- _clamp - If 1, change exponents if too high (Default 0)
+ clamp - If 1, change exponents if too high (Default 0)
"""
def __init__(self, prec=None, rounding=None,
traps=None, flags=None,
Emin=None, Emax=None,
- capitals=None, _clamp=0,
+ capitals=None, clamp=None,
_ignored_flags=None):
# Set defaults; for everything except flags and _ignored_flags,
# inherit from DefaultContext.
@@ -3824,7 +3830,7 @@ class Context(object):
self.Emin = Emin if Emin is not None else dc.Emin
self.Emax = Emax if Emax is not None else dc.Emax
self.capitals = capitals if capitals is not None else dc.capitals
- self._clamp = _clamp if _clamp is not None else dc._clamp
+ self.clamp = clamp if clamp is not None else dc.clamp
if _ignored_flags is None:
self._ignored_flags = []
@@ -3849,7 +3855,8 @@ class Context(object):
"""Show the current context."""
s = []
s.append('Context(prec=%(prec)d, rounding=%(rounding)s, '
- 'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d'
+ 'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, '
+ 'clamp=%(clamp)d'
% vars(self))
names = [f.__name__ for f, v in self.flags.items() if v]
s.append('flags=[' + ', '.join(names) + ']')
@@ -3866,17 +3873,39 @@ class Context(object):
"""Returns a shallow copy from self."""
nc = Context(self.prec, self.rounding, self.traps,
self.flags, self.Emin, self.Emax,
- self.capitals, self._clamp, self._ignored_flags)
+ self.capitals, self.clamp, self._ignored_flags)
return nc
def copy(self):
"""Returns a deep copy from self."""
nc = Context(self.prec, self.rounding, self.traps.copy(),
self.flags.copy(), self.Emin, self.Emax,
- self.capitals, self._clamp, self._ignored_flags)
+ self.capitals, self.clamp, self._ignored_flags)
return nc
__copy__ = copy
+ # _clamp is provided for backwards compatibility with third-party
+ # code. May be removed in Python >= 3.3.
+ def _get_clamp(self):
+ "_clamp mirrors the clamp attribute. Its use is deprecated."
+ import warnings
+ warnings.warn('Use of the _clamp attribute is deprecated. '
+ 'Please use clamp instead.',
+ DeprecationWarning)
+ return self.clamp
+
+ def _set_clamp(self, clamp):
+ "_clamp mirrors the clamp attribute. Its use is deprecated."
+ import warnings
+ warnings.warn('Use of the _clamp attribute is deprecated. '
+ 'Please use clamp instead.',
+ DeprecationWarning)
+ self.clamp = clamp
+
+ # don't bother with _del_clamp; no sane 3rd party code should
+ # be deleting the _clamp attribute
+ _clamp = property(_get_clamp, _set_clamp)
+
def _raise_error(self, condition, explanation = None, *args):
"""Handles an error
@@ -3959,7 +3988,7 @@ class Context(object):
"permitted.")
d = Decimal(num, context=self)
- if d._isnan() and len(d._int) > self.prec - self._clamp:
+ if d._isnan() and len(d._int) > self.prec - self.clamp:
return self._raise_error(ConversionSyntax,
"diagnostic info too long in NaN")
return d._fix(self)
@@ -3997,7 +4026,10 @@ class Context(object):
Decimal('101.5')
>>> ExtendedContext.abs(Decimal('-101.5'))
Decimal('101.5')
+ >>> ExtendedContext.abs(-1)
+ Decimal('1')
"""
+ a = _convert_other(a, raiseit=True)
return a.__abs__(context=self)
def add(self, a, b):
@@ -4007,8 +4039,19 @@ class Context(object):
Decimal('19.00')
>>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4'))
Decimal('1.02E+4')
+ >>> ExtendedContext.add(1, Decimal(2))
+ Decimal('3')
+ >>> ExtendedContext.add(Decimal(8), 5)
+ Decimal('13')
+ >>> ExtendedContext.add(5, 5)
+ Decimal('10')
"""
- return a.__add__(b, context=self)
+ a = _convert_other(a, raiseit=True)
+ r = a.__add__(b, context=self)
+ if r is NotImplemented:
+ raise TypeError("Unable to convert %s to Decimal" % b)
+ else:
+ return r
def _apply(self, a):
return str(a._fix(self))
@@ -4050,7 +4093,14 @@ class Context(object):
Decimal('1')
>>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1'))
Decimal('-1')
+ >>> ExtendedContext.compare(1, 2)
+ Decimal('-1')
+ >>> ExtendedContext.compare(Decimal(1), 2)
+ Decimal('-1')
+ >>> ExtendedContext.compare(1, Decimal(2))
+ Decimal('-1')
"""
+ a = _convert_other(a, raiseit=True)
return a.compare(b, context=self)
def compare_signal(self, a, b):
@@ -4078,7 +4128,14 @@ class Context(object):
Decimal('NaN')
>>> print(c.flags[InvalidOperation])
1
+ >>> c.compare_signal(-1, 2)
+ Decimal('-1')
+ >>> c.compare_signal(Decimal(-1), 2)
+ Decimal('-1')
+ >>> c.compare_signal(-1, Decimal(2))
+ Decimal('-1')
"""
+ a = _convert_other(a, raiseit=True)
return a.compare_signal(b, context=self)
def compare_total(self, a, b):
@@ -4100,7 +4157,14 @@ class Context(object):
Decimal('1')
>>> ExtendedContext.compare_total(Decimal('12.3'), Decimal('NaN'))
Decimal('-1')
+ >>> ExtendedContext.compare_total(1, 2)
+ Decimal('-1')
+ >>> ExtendedContext.compare_total(Decimal(1), 2)
+ Decimal('-1')
+ >>> ExtendedContext.compare_total(1, Decimal(2))
+ Decimal('-1')
"""
+ a = _convert_other(a, raiseit=True)
return a.compare_total(b)
def compare_total_mag(self, a, b):
@@ -4108,6 +4172,7 @@ class Context(object):
Like compare_total, but with operand's sign ignored and assumed to be 0.
"""
+ a = _convert_other(a, raiseit=True)
return a.compare_total_mag(b)
def copy_abs(self, a):
@@ -4117,17 +4182,23 @@ class Context(object):
Decimal('2.1')
>>> ExtendedContext.copy_abs(Decimal('-100'))
Decimal('100')
+ >>> ExtendedContext.copy_abs(-1)
+ Decimal('1')
"""
+ a = _convert_other(a, raiseit=True)
return a.copy_abs()
def copy_decimal(self, a):
- """Returns a copy of the decimal objet.
+ """Returns a copy of the decimal object.
>>> ExtendedContext.copy_decimal(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.copy_decimal(Decimal('-1.00'))
Decimal('-1.00')
+ >>> ExtendedContext.copy_decimal(1)
+ Decimal('1')
"""
+ a = _convert_other(a, raiseit=True)
return Decimal(a)
def copy_negate(self, a):
@@ -4137,7 +4208,10 @@ class Context(object):
Decimal('-101.5')
>>> ExtendedContext.copy_negate(Decimal('-101.5'))
Decimal('101.5')
+ >>> ExtendedContext.copy_negate(1)
+ Decimal('-1')
"""
+ a = _convert_other(a, raiseit=True)
return a.copy_negate()
def copy_sign(self, a, b):
@@ -4154,7 +4228,14 @@ class Context(object):
Decimal('-1.50')
>>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('-7.33'))
Decimal('-1.50')
+ >>> ExtendedContext.copy_sign(1, -2)
+ Decimal('-1')
+ >>> ExtendedContext.copy_sign(Decimal(1), -2)
+ Decimal('-1')
+ >>> ExtendedContext.copy_sign(1, Decimal(-2))
+ Decimal('-1')
"""
+ a = _convert_other(a, raiseit=True)
return a.copy_sign(b)
def divide(self, a, b):
@@ -4180,8 +4261,19 @@ class Context(object):
Decimal('1000')
>>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2'))
Decimal('1.20E+6')
+ >>> ExtendedContext.divide(5, 5)
+ Decimal('1')
+ >>> ExtendedContext.divide(Decimal(5), 5)
+ Decimal('1')
+ >>> ExtendedContext.divide(5, Decimal(5))
+ Decimal('1')
"""
- return a.__truediv__(b, context=self)
+ a = _convert_other(a, raiseit=True)
+ r = a.__truediv__(b, context=self)
+ if r is NotImplemented:
+ raise TypeError("Unable to convert %s to Decimal" % b)
+ else:
+ return r
def divide_int(self, a, b):
"""Divides two numbers and returns the integer part of the result.
@@ -4192,18 +4284,40 @@ class Context(object):
Decimal('3')
>>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3'))
Decimal('3')
+ >>> ExtendedContext.divide_int(10, 3)
+ Decimal('3')
+ >>> ExtendedContext.divide_int(Decimal(10), 3)
+ Decimal('3')
+ >>> ExtendedContext.divide_int(10, Decimal(3))
+ Decimal('3')
"""
- return a.__floordiv__(b, context=self)
+ a = _convert_other(a, raiseit=True)
+ r = a.__floordiv__(b, context=self)
+ if r is NotImplemented:
+ raise TypeError("Unable to convert %s to Decimal" % b)
+ else:
+ return r
def divmod(self, a, b):
- """Return (a // b, a % b)
+ """Return (a // b, a % b).
>>> ExtendedContext.divmod(Decimal(8), Decimal(3))
(Decimal('2'), Decimal('2'))
>>> ExtendedContext.divmod(Decimal(8), Decimal(4))
(Decimal('2'), Decimal('0'))
+ >>> ExtendedContext.divmod(8, 4)
+ (Decimal('2'), Decimal('0'))
+ >>> ExtendedContext.divmod(Decimal(8), 4)
+ (Decimal('2'), Decimal('0'))
+ >>> ExtendedContext.divmod(8, Decimal(4))
+ (Decimal('2'), Decimal('0'))
"""
- return a.__divmod__(b, context=self)
+ a = _convert_other(a, raiseit=True)
+ r = a.__divmod__(b, context=self)
+ if r is NotImplemented:
+ raise TypeError("Unable to convert %s to Decimal" % b)
+ else:
+ return r
def exp(self, a):
"""Returns e ** a.
@@ -4223,7 +4337,10 @@ class Context(object):
Decimal('2.00000000')
>>> c.exp(Decimal('+Infinity'))
Decimal('Infinity')
+ >>> c.exp(10)
+ Decimal('22026.4658')
"""
+ a =_convert_other(a, raiseit=True)
return a.exp(context=self)
def fma(self, a, b, c):
@@ -4239,7 +4356,14 @@ class Context(object):
Decimal('-8')
>>> ExtendedContext.fma(Decimal('888565290'), Decimal('1557.96930'), Decimal('-86087.7578'))
Decimal('1.38435736E+12')
+ >>> ExtendedContext.fma(1, 3, 4)
+ Decimal('7')
+ >>> ExtendedContext.fma(1, Decimal(3), 4)
+ Decimal('7')
+ >>> ExtendedContext.fma(1, 3, Decimal(4))
+ Decimal('7')
"""
+ a = _convert_other(a, raiseit=True)
return a.fma(b, c, context=self)
def is_canonical(self, a):
@@ -4269,7 +4393,10 @@ class Context(object):
False
>>> ExtendedContext.is_finite(Decimal('NaN'))
False
+ >>> ExtendedContext.is_finite(1)
+ True
"""
+ a = _convert_other(a, raiseit=True)
return a.is_finite()
def is_infinite(self, a):
@@ -4281,7 +4408,10 @@ class Context(object):
True
>>> ExtendedContext.is_infinite(Decimal('NaN'))
False
+ >>> ExtendedContext.is_infinite(1)
+ False
"""
+ a = _convert_other(a, raiseit=True)
return a.is_infinite()
def is_nan(self, a):
@@ -4294,7 +4424,10 @@ class Context(object):
True
>>> ExtendedContext.is_nan(Decimal('-sNaN'))
True
+ >>> ExtendedContext.is_nan(1)
+ False
"""
+ a = _convert_other(a, raiseit=True)
return a.is_nan()
def is_normal(self, a):
@@ -4314,7 +4447,10 @@ class Context(object):
False
>>> c.is_normal(Decimal('NaN'))
False
+ >>> c.is_normal(1)
+ True
"""
+ a = _convert_other(a, raiseit=True)
return a.is_normal(context=self)
def is_qnan(self, a):
@@ -4326,7 +4462,10 @@ class Context(object):
True
>>> ExtendedContext.is_qnan(Decimal('sNaN'))
False
+ >>> ExtendedContext.is_qnan(1)
+ False
"""
+ a = _convert_other(a, raiseit=True)
return a.is_qnan()
def is_signed(self, a):
@@ -4338,7 +4477,12 @@ class Context(object):
True
>>> ExtendedContext.is_signed(Decimal('-0'))
True
+ >>> ExtendedContext.is_signed(8)
+ False
+ >>> ExtendedContext.is_signed(-8)
+ True
"""
+ a = _convert_other(a, raiseit=True)
return a.is_signed()
def is_snan(self, a):
@@ -4351,7 +4495,10 @@ class Context(object):
False
>>> ExtendedContext.is_snan(Decimal('sNaN'))
True
+ >>> ExtendedContext.is_snan(1)
+ False
"""
+ a = _convert_other(a, raiseit=True)
return a.is_snan()
def is_subnormal(self, a):
@@ -4370,7 +4517,10 @@ class Context(object):
False
>>> c.is_subnormal(Decimal('NaN'))
False
+ >>> c.is_subnormal(1)
+ False
"""
+ a = _convert_other(a, raiseit=True)
return a.is_subnormal(context=self)
def is_zero(self, a):
@@ -4382,7 +4532,12 @@ class Context(object):
False
>>> ExtendedContext.is_zero(Decimal('-0E+2'))
True
+ >>> ExtendedContext.is_zero(1)
+ False
+ >>> ExtendedContext.is_zero(0)
+ True
"""
+ a = _convert_other(a, raiseit=True)
return a.is_zero()
def ln(self, a):
@@ -4401,7 +4556,10 @@ class Context(object):
Decimal('2.30258509')
>>> c.ln(Decimal('+Infinity'))
Decimal('Infinity')
+ >>> c.ln(1)
+ Decimal('0')
"""
+ a = _convert_other(a, raiseit=True)
return a.ln(context=self)
def log10(self, a):
@@ -4424,7 +4582,12 @@ class Context(object):
Decimal('1.84509804')
>>> c.log10(Decimal('+Infinity'))
Decimal('Infinity')
+ >>> c.log10(0)
+ Decimal('-Infinity')
+ >>> c.log10(1)
+ Decimal('0')
"""
+ a = _convert_other(a, raiseit=True)
return a.log10(context=self)
def logb(self, a):
@@ -4443,7 +4606,14 @@ class Context(object):
Decimal('-2')
>>> ExtendedContext.logb(Decimal('0'))
Decimal('-Infinity')
+ >>> ExtendedContext.logb(1)
+ Decimal('0')
+ >>> ExtendedContext.logb(10)
+ Decimal('1')
+ >>> ExtendedContext.logb(100)
+ Decimal('2')
"""
+ a = _convert_other(a, raiseit=True)
return a.logb(context=self)
def logical_and(self, a, b):
@@ -4463,7 +4633,14 @@ class Context(object):
Decimal('1000')
>>> ExtendedContext.logical_and(Decimal('1111'), Decimal('10'))
Decimal('10')
+ >>> ExtendedContext.logical_and(110, 1101)
+ Decimal('100')
+ >>> ExtendedContext.logical_and(Decimal(110), 1101)
+ Decimal('100')
+ >>> ExtendedContext.logical_and(110, Decimal(1101))
+ Decimal('100')
"""
+ a = _convert_other(a, raiseit=True)
return a.logical_and(b, context=self)
def logical_invert(self, a):
@@ -4479,7 +4656,10 @@ class Context(object):
Decimal('0')
>>> ExtendedContext.logical_invert(Decimal('101010101'))
Decimal('10101010')
+ >>> ExtendedContext.logical_invert(1101)
+ Decimal('111110010')
"""
+ a = _convert_other(a, raiseit=True)
return a.logical_invert(context=self)
def logical_or(self, a, b):
@@ -4499,7 +4679,14 @@ class Context(object):
Decimal('1110')
>>> ExtendedContext.logical_or(Decimal('1110'), Decimal('10'))
Decimal('1110')
+ >>> ExtendedContext.logical_or(110, 1101)
+ Decimal('1111')
+ >>> ExtendedContext.logical_or(Decimal(110), 1101)
+ Decimal('1111')
+ >>> ExtendedContext.logical_or(110, Decimal(1101))
+ Decimal('1111')
"""
+ a = _convert_other(a, raiseit=True)
return a.logical_or(b, context=self)
def logical_xor(self, a, b):
@@ -4519,10 +4706,17 @@ class Context(object):
Decimal('110')
>>> ExtendedContext.logical_xor(Decimal('1111'), Decimal('10'))
Decimal('1101')
+ >>> ExtendedContext.logical_xor(110, 1101)
+ Decimal('1011')
+ >>> ExtendedContext.logical_xor(Decimal(110), 1101)
+ Decimal('1011')
+ >>> ExtendedContext.logical_xor(110, Decimal(1101))
+ Decimal('1011')
"""
+ a = _convert_other(a, raiseit=True)
return a.logical_xor(b, context=self)
- def max(self, a,b):
+ def max(self, a, b):
"""max compares two values numerically and returns the maximum.
If either operand is a NaN then the general rules apply.
@@ -4539,14 +4733,34 @@ class Context(object):
Decimal('1')
>>> ExtendedContext.max(Decimal('7'), Decimal('NaN'))
Decimal('7')
+ >>> ExtendedContext.max(1, 2)
+ Decimal('2')
+ >>> ExtendedContext.max(Decimal(1), 2)
+ Decimal('2')
+ >>> ExtendedContext.max(1, Decimal(2))
+ Decimal('2')
"""
+ a = _convert_other(a, raiseit=True)
return a.max(b, context=self)
def max_mag(self, a, b):
- """Compares the values numerically with their sign ignored."""
+ """Compares the values numerically with their sign ignored.
+
+ >>> ExtendedContext.max_mag(Decimal('7'), Decimal('NaN'))
+ Decimal('7')
+ >>> ExtendedContext.max_mag(Decimal('7'), Decimal('-10'))
+ Decimal('-10')
+ >>> ExtendedContext.max_mag(1, -2)
+ Decimal('-2')
+ >>> ExtendedContext.max_mag(Decimal(1), -2)
+ Decimal('-2')
+ >>> ExtendedContext.max_mag(1, Decimal(-2))
+ Decimal('-2')
+ """
+ a = _convert_other(a, raiseit=True)
return a.max_mag(b, context=self)
- def min(self, a,b):
+ def min(self, a, b):
"""min compares two values numerically and returns the minimum.
If either operand is a NaN then the general rules apply.
@@ -4563,11 +4777,31 @@ class Context(object):
Decimal('1.0')
>>> ExtendedContext.min(Decimal('7'), Decimal('NaN'))
Decimal('7')
+ >>> ExtendedContext.min(1, 2)
+ Decimal('1')
+ >>> ExtendedContext.min(Decimal(1), 2)
+ Decimal('1')
+ >>> ExtendedContext.min(1, Decimal(29))
+ Decimal('1')
"""
+ a = _convert_other(a, raiseit=True)
return a.min(b, context=self)
def min_mag(self, a, b):
- """Compares the values numerically with their sign ignored."""
+ """Compares the values numerically with their sign ignored.
+
+ >>> ExtendedContext.min_mag(Decimal('3'), Decimal('-2'))
+ Decimal('-2')
+ >>> ExtendedContext.min_mag(Decimal('-3'), Decimal('NaN'))
+ Decimal('-3')
+ >>> ExtendedContext.min_mag(1, -2)
+ Decimal('1')
+ >>> ExtendedContext.min_mag(Decimal(1), -2)
+ Decimal('1')
+ >>> ExtendedContext.min_mag(1, Decimal(-2))
+ Decimal('1')
+ """
+ a = _convert_other(a, raiseit=True)
return a.min_mag(b, context=self)
def minus(self, a):
@@ -4581,16 +4815,19 @@ class Context(object):
Decimal('-1.3')
>>> ExtendedContext.minus(Decimal('-1.3'))
Decimal('1.3')
+ >>> ExtendedContext.minus(1)
+ Decimal('-1')
"""
+ a = _convert_other(a, raiseit=True)
return a.__neg__(context=self)
def multiply(self, a, b):
"""multiply multiplies two operands.
If either operand is a special value then the general rules apply.
- Otherwise, the operands are multiplied together ('long multiplication'),
- resulting in a number which may be as long as the sum of the lengths
- of the two operands.
+ Otherwise, the operands are multiplied together
+ ('long multiplication'), resulting in a number which may be as long as
+ the sum of the lengths of the two operands.
>>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
Decimal('3.60')
@@ -4602,8 +4839,19 @@ class Context(object):
Decimal('-0.0')
>>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321'))
Decimal('4.28135971E+11')
+ >>> ExtendedContext.multiply(7, 7)
+ Decimal('49')
+ >>> ExtendedContext.multiply(Decimal(7), 7)
+ Decimal('49')
+ >>> ExtendedContext.multiply(7, Decimal(7))
+ Decimal('49')
"""
- return a.__mul__(b, context=self)
+ a = _convert_other(a, raiseit=True)
+ r = a.__mul__(b, context=self)
+ if r is NotImplemented:
+ raise TypeError("Unable to convert %s to Decimal" % b)
+ else:
+ return r
def next_minus(self, a):
"""Returns the largest representable number smaller than a.
@@ -4619,7 +4867,10 @@ class Context(object):
Decimal('-1.00000004')
>>> c.next_minus(Decimal('Infinity'))
Decimal('9.99999999E+999')
+ >>> c.next_minus(1)
+ Decimal('0.999999999')
"""
+ a = _convert_other(a, raiseit=True)
return a.next_minus(context=self)
def next_plus(self, a):
@@ -4636,7 +4887,10 @@ class Context(object):
Decimal('-1.00000002')
>>> c.next_plus(Decimal('-Infinity'))
Decimal('-9.99999999E+999')
+ >>> c.next_plus(1)
+ Decimal('1.00000001')
"""
+ a = _convert_other(a, raiseit=True)
return a.next_plus(context=self)
def next_toward(self, a, b):
@@ -4664,7 +4918,14 @@ class Context(object):
Decimal('-1.00000004')
>>> c.next_toward(Decimal('0.00'), Decimal('-0.0000'))
Decimal('-0.00')
+ >>> c.next_toward(0, 1)
+ Decimal('1E-1007')
+ >>> c.next_toward(Decimal(0), 1)
+ Decimal('1E-1007')
+ >>> c.next_toward(0, Decimal(1))
+ Decimal('1E-1007')
"""
+ a = _convert_other(a, raiseit=True)
return a.next_toward(b, context=self)
def normalize(self, a):
@@ -4685,7 +4946,10 @@ class Context(object):
Decimal('1.2E+2')
>>> ExtendedContext.normalize(Decimal('0.00'))
Decimal('0')
+ >>> ExtendedContext.normalize(6)
+ Decimal('6')
"""
+ a = _convert_other(a, raiseit=True)
return a.normalize(context=self)
def number_class(self, a):
@@ -4732,7 +4996,10 @@ class Context(object):
'NaN'
>>> c.number_class(Decimal('sNaN'))
'sNaN'
+ >>> c.number_class(123)
+ '+Normal'
"""
+ a = _convert_other(a, raiseit=True)
return a.number_class(context=self)
def plus(self, a):
@@ -4746,7 +5013,10 @@ class Context(object):
Decimal('1.3')
>>> ExtendedContext.plus(Decimal('-1.3'))
Decimal('-1.3')
+ >>> ExtendedContext.plus(-1)
+ Decimal('-1')
"""
+ a = _convert_other(a, raiseit=True)
return a.__pos__(context=self)
def power(self, a, b, modulo=None):
@@ -4815,8 +5085,19 @@ class Context(object):
Decimal('-0')
>>> c.power(Decimal('-23'), Decimal('0'), Decimal('65537'))
Decimal('1')
+ >>> ExtendedContext.power(7, 7)
+ Decimal('823543')
+ >>> ExtendedContext.power(Decimal(7), 7)
+ Decimal('823543')
+ >>> ExtendedContext.power(7, Decimal(7), 2)
+ Decimal('1')
"""
- return a.__pow__(b, modulo, context=self)
+ a = _convert_other(a, raiseit=True)
+ r = a.__pow__(b, modulo, context=self)
+ if r is NotImplemented:
+ raise TypeError("Unable to convert %s to Decimal" % b)
+ else:
+ return r
def quantize(self, a, b):
"""Returns a value equal to 'a' (rounded), having the exponent of 'b'.
@@ -4866,7 +5147,14 @@ class Context(object):
Decimal('2.2E+2')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2'))
Decimal('2E+2')
+ >>> ExtendedContext.quantize(1, 2)
+ Decimal('1')
+ >>> ExtendedContext.quantize(Decimal(1), 2)
+ Decimal('1')
+ >>> ExtendedContext.quantize(1, Decimal(2))
+ Decimal('1')
"""
+ a = _convert_other(a, raiseit=True)
return a.quantize(b, context=self)
def radix(self):
@@ -4901,8 +5189,19 @@ class Context(object):
Decimal('0.1')
>>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3'))
Decimal('1.0')
+ >>> ExtendedContext.remainder(22, 6)
+ Decimal('4')
+ >>> ExtendedContext.remainder(Decimal(22), 6)
+ Decimal('4')
+ >>> ExtendedContext.remainder(22, Decimal(6))
+ Decimal('4')
"""
- return a.__mod__(b, context=self)
+ a = _convert_other(a, raiseit=True)
+ r = a.__mod__(b, context=self)
+ if r is NotImplemented:
+ raise TypeError("Unable to convert %s to Decimal" % b)
+ else:
+ return r
def remainder_near(self, a, b):
"""Returns to be "a - b * n", where n is the integer nearest the exact
@@ -4928,7 +5227,14 @@ class Context(object):
Decimal('0.1')
>>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3'))
Decimal('-0.3')
+ >>> ExtendedContext.remainder_near(3, 11)
+ Decimal('3')
+ >>> ExtendedContext.remainder_near(Decimal(3), 11)
+ Decimal('3')
+ >>> ExtendedContext.remainder_near(3, Decimal(11))
+ Decimal('3')
"""
+ a = _convert_other(a, raiseit=True)
return a.remainder_near(b, context=self)
def rotate(self, a, b):
@@ -4950,7 +5256,14 @@ class Context(object):
Decimal('123456789')
>>> ExtendedContext.rotate(Decimal('123456789'), Decimal('+2'))
Decimal('345678912')
+ >>> ExtendedContext.rotate(1333333, 1)
+ Decimal('13333330')
+ >>> ExtendedContext.rotate(Decimal(1333333), 1)
+ Decimal('13333330')
+ >>> ExtendedContext.rotate(1333333, Decimal(1))
+ Decimal('13333330')
"""
+ a = _convert_other(a, raiseit=True)
return a.rotate(b, context=self)
def same_quantum(self, a, b):
@@ -4967,7 +5280,14 @@ class Context(object):
False
>>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf'))
True
+ >>> ExtendedContext.same_quantum(10000, -1)
+ True
+ >>> ExtendedContext.same_quantum(Decimal(10000), -1)
+ True
+ >>> ExtendedContext.same_quantum(10000, Decimal(-1))
+ True
"""
+ a = _convert_other(a, raiseit=True)
return a.same_quantum(b)
def scaleb (self, a, b):
@@ -4979,8 +5299,15 @@ class Context(object):
Decimal('7.50')
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('3'))
Decimal('7.50E+3')
+ >>> ExtendedContext.scaleb(1, 4)
+ Decimal('1E+4')
+ >>> ExtendedContext.scaleb(Decimal(1), 4)
+ Decimal('1E+4')
+ >>> ExtendedContext.scaleb(1, Decimal(4))
+ Decimal('1E+4')
"""
- return a.scaleb (b, context=self)
+ a = _convert_other(a, raiseit=True)
+ return a.scaleb(b, context=self)
def shift(self, a, b):
"""Returns a shifted copy of a, b times.
@@ -5002,7 +5329,14 @@ class Context(object):
Decimal('123456789')
>>> ExtendedContext.shift(Decimal('123456789'), Decimal('+2'))
Decimal('345678900')
+ >>> ExtendedContext.shift(88888888, 2)
+ Decimal('888888800')
+ >>> ExtendedContext.shift(Decimal(88888888), 2)
+ Decimal('888888800')
+ >>> ExtendedContext.shift(88888888, Decimal(2))
+ Decimal('888888800')
"""
+ a = _convert_other(a, raiseit=True)
return a.shift(b, context=self)
def sqrt(self, a):
@@ -5029,9 +5363,12 @@ class Context(object):
Decimal('2.64575131')
>>> ExtendedContext.sqrt(Decimal('10'))
Decimal('3.16227766')
+ >>> ExtendedContext.sqrt(2)
+ Decimal('1.41421356')
>>> ExtendedContext.prec
9
"""
+ a = _convert_other(a, raiseit=True)
return a.sqrt(context=self)
def subtract(self, a, b):
@@ -5043,14 +5380,26 @@ class Context(object):
Decimal('0.00')
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07'))
Decimal('-0.77')
+ >>> ExtendedContext.subtract(8, 5)
+ Decimal('3')
+ >>> ExtendedContext.subtract(Decimal(8), 5)
+ Decimal('3')
+ >>> ExtendedContext.subtract(8, Decimal(5))
+ Decimal('3')
"""
- return a.__sub__(b, context=self)
+ a = _convert_other(a, raiseit=True)
+ r = a.__sub__(b, context=self)
+ if r is NotImplemented:
+ raise TypeError("Unable to convert %s to Decimal" % b)
+ else:
+ return r
def to_eng_string(self, a):
"""Converts a number to a string, using scientific notation.
The operation is not affected by the context.
"""
+ a = _convert_other(a, raiseit=True)
return a.to_eng_string(context=self)
def to_sci_string(self, a):
@@ -5058,6 +5407,7 @@ class Context(object):
The operation is not affected by the context.
"""
+ a = _convert_other(a, raiseit=True)
return a.__str__(context=self)
def to_integral_exact(self, a):
@@ -5087,6 +5437,7 @@ class Context(object):
>>> ExtendedContext.to_integral_exact(Decimal('-Inf'))
Decimal('-Infinity')
"""
+ a = _convert_other(a, raiseit=True)
return a.to_integral_exact(context=self)
def to_integral_value(self, a):
@@ -5115,6 +5466,7 @@ class Context(object):
>>> ExtendedContext.to_integral_value(Decimal('-Inf'))
Decimal('-Infinity')
"""
+ a = _convert_other(a, raiseit=True)
return a.to_integral_value(context=self)
# the method name changed, but we provide also the old one, for compatibility
@@ -5178,23 +5530,7 @@ def _normalize(op1, op2, prec = 0):
##### Integer arithmetic functions used by ln, log10, exp and __pow__ #####
-# This function from Tim Peters was taken from here:
-# http://mail.python.org/pipermail/python-list/1999-July/007758.html
-# The correction being in the function definition is for speed, and
-# the whole function is not resolved with math.log because of avoiding
-# the use of floats.
-def _nbits(n, correction = {
- '0': 4, '1': 3, '2': 2, '3': 2,
- '4': 1, '5': 1, '6': 1, '7': 1,
- '8': 0, '9': 0, 'a': 0, 'b': 0,
- 'c': 0, 'd': 0, 'e': 0, 'f': 0}):
- """Number of bits in binary representation of the positive integer n,
- or 0 if n == 0.
- """
- if n < 0:
- raise ValueError("The argument to _nbits should be nonnegative.")
- hex_n = "%x" % n
- return 4*len(hex_n) - correction[hex_n[0]]
+_nbits = int.bit_length
def _sqrt_nearest(n, a):
"""Closest integer to the square root of the positive integer n. a is
@@ -5516,19 +5852,56 @@ def _log10_lb(c, correction = {
##### Helper Functions ####################################################
-def _convert_other(other, raiseit=False):
+def _convert_other(other, raiseit=False, allow_float=False):
"""Convert other to Decimal.
Verifies that it's ok to use in an implicit construction.
+ If allow_float is true, allow conversion from float; this
+ is used in the comparison methods (__eq__ and friends).
+
"""
if isinstance(other, Decimal):
return other
if isinstance(other, int):
return Decimal(other)
+ if allow_float and isinstance(other, float):
+ return Decimal.from_float(other)
+
if raiseit:
raise TypeError("Unable to convert %s to Decimal" % other)
return NotImplemented
+def _convert_for_comparison(self, other, equality_op=False):
+ """Given a Decimal instance self and a Python object other, return
+ a pair (s, o) of Decimal instances such that "s op o" is
+ equivalent to "self op other" for any of the 6 comparison
+ operators "op".
+
+ """
+ if isinstance(other, Decimal):
+ return self, other
+
+ # Comparison with a Rational instance (also includes integers):
+ # self op n/d <=> self*d op n (for n and d integers, d positive).
+ # A NaN or infinity can be left unchanged without affecting the
+ # comparison result.
+ if isinstance(other, _numbers.Rational):
+ if not self._is_special:
+ self = _dec_from_triple(self._sign,
+ str(int(self._int) * other.denominator),
+ self._exp)
+ return self, Decimal(other.numerator)
+
+ # Comparisons with float and complex types. == and != comparisons
+ # with complex numbers should succeed, returning either True or False
+ # as appropriate. Other comparisons return NotImplemented.
+ if equality_op and isinstance(other, _numbers.Complex) and other.imag == 0:
+ other = other.real
+ if isinstance(other, float):
+ return self, Decimal.from_float(other)
+ return NotImplemented, NotImplemented
+
+
##### Setup Specific Contexts ############################################
# The default context prototype used by Context()
@@ -5540,7 +5913,8 @@ DefaultContext = Context(
flags=[],
Emax=999999999,
Emin=-999999999,
- capitals=1
+ capitals=1,
+ clamp=0
)
# Pre-made alternate contexts offered by the specification
@@ -5605,7 +5979,7 @@ _exact_half = re.compile('50*$').match
#
# A format specifier for Decimal looks like:
#
-# [[fill]align][sign][0][minimumwidth][,][.precision][type]
+# [[fill]align][sign][#][0][minimumwidth][,][.precision][type]
_parse_format_specifier_regex = re.compile(r"""\A
(?:
@@ -5613,6 +5987,7 @@ _parse_format_specifier_regex = re.compile(r"""\A
(?P<align>[<>=^])
)?
(?P<sign>[-+ ])?
+(?P<alt>\#)?
(?P<zeropad>0)?
(?P<minimumwidth>(?!0)\d+)?
(?P<thousands_sep>,)?
@@ -5670,7 +6045,10 @@ def _parse_format_specifier(format_spec, _localeconv=None):
raise ValueError("Alignment conflicts with '0' in "
"format specifier: " + format_spec)
format_dict['fill'] = fill or ' '
- format_dict['align'] = align or '<'
+ # PEP 3101 originally specified that the default alignment should
+ # be left; it was later agreed that right-aligned makes more sense
+ # for numeric types. See http://bugs.python.org/issue6857.
+ format_dict['align'] = align or '>'
# default sign handling: '-' for negative, '' for positive
if format_dict['sign'] is None:
@@ -5825,7 +6203,7 @@ def _format_number(is_negative, intpart, fracpart, exp, spec):
sign = _format_sign(is_negative, spec)
- if fracpart:
+ if fracpart or spec['alt']:
fracpart = spec['decimal_point'] + fracpart
if exp != 0 or spec['type'] in 'eE':
@@ -5856,8 +6234,19 @@ _NegativeOne = Decimal(-1)
# _SignedInfinity[sign] is infinity w/ that sign
_SignedInfinity = (_Infinity, _NegativeInfinity)
+# Constants related to the hash implementation; hash(x) is based
+# on the reduction of x modulo _PyHASH_MODULUS
+import sys
+_PyHASH_MODULUS = sys.hash_info.modulus
+# hash values to use for positive and negative infinities, and nans
+_PyHASH_INF = sys.hash_info.inf
+_PyHASH_NAN = sys.hash_info.nan
+del sys
+
+# _PyHASH_10INV is the inverse of 10 modulo the prime _PyHASH_MODULUS
+_PyHASH_10INV = pow(10, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
if __name__ == '__main__':
- import doctest, sys
- doctest.testmod(sys.modules[__name__])
+ import doctest, decimal
+ doctest.testmod(decimal)
diff --git a/Lib/difflib.py b/Lib/difflib.py
index 24a58a61c0..003e72e283 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""
Module difflib -- helpers for computing deltas between objects.
@@ -32,6 +32,7 @@ __all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher',
'Differ','IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'context_diff',
'unified_diff', 'HtmlDiff', 'Match']
+import warnings
import heapq
from collections import namedtuple as _namedtuple
@@ -150,7 +151,7 @@ class SequenceMatcher:
Return an upper bound on ratio() very quickly.
"""
- def __init__(self, isjunk=None, a='', b=''):
+ def __init__(self, isjunk=None, a='', b='', autojunk=True):
"""Construct a SequenceMatcher.
Optional arg isjunk is None (the default), or a one-argument
@@ -168,6 +169,10 @@ class SequenceMatcher:
Optional arg b is the second of two sequences to be compared. By
default, an empty string. The elements of b must be hashable. See
also .set_seqs() and .set_seq2().
+
+ Optional arg autojunk should be set to False to disable the
+ "automatic junk heuristic" that treats popular elements as junk
+ (see module documentation for more information).
"""
# Members:
@@ -178,7 +183,7 @@ class SequenceMatcher:
# we need to do to 'a' to change it into 'b'?"
# b2j
# for x in b, b2j[x] is a list of the indices (into b)
- # at which x appears; junk elements do not appear
+ # at which x appears; junk and popular elements do not appear
# fullbcount
# for x in b, fullbcount[x] == the number of times x
# appears in b; only materialized if really needed (used
@@ -200,17 +205,14 @@ class SequenceMatcher:
# subtle but helpful effects on the algorithm, which I'll
# get around to writing up someday <0.9 wink>.
# DON'T USE! Only __chain_b uses this. Use isbjunk.
- # isbjunk
- # for x in b, isbjunk(x) == isjunk(x) but much faster;
- # it's really the __contains__ method of a hidden dict.
- # DOES NOT WORK for x in a!
- # isbpopular
- # for x in b, isbpopular(x) is true iff b is reasonably long
- # (at least 200 elements) and x accounts for more than 1% of
- # its elements. DOES NOT WORK for x in a!
+ # bjunk
+ # the items in b for which isjunk is True.
+ # bpopular
+ # nonjunk items in b treated as junk by the heuristic (if used).
self.isjunk = isjunk
self.a = self.b = None
+ self.autojunk = autojunk
self.set_seqs(a, b)
def set_seqs(self, a, b):
@@ -287,7 +289,7 @@ class SequenceMatcher:
# from starting any matching block at a junk element ...
# also creates the fast isbjunk function ...
# b2j also does not contain entries for "popular" elements, meaning
- # elements that account for more than 1% of the total elements, and
+ # elements that account for more than 1 + 1% of the total elements, and
# when the sequence is reasonably large (>= 200 elements); this can
# be viewed as an adaptive notion of semi-junk, and yields an enormous
# speedup when, e.g., comparing program files with hundreds of
@@ -308,44 +310,46 @@ class SequenceMatcher:
# out the junk later is much cheaper than building b2j "right"
# from the start.
b = self.b
- n = len(b)
self.b2j = b2j = {}
- populardict = {}
- for i, elt in enumerate(b):
- if elt in b2j:
- indices = b2j[elt]
- if n >= 200 and len(indices) * 100 > n:
- populardict[elt] = 1
- del indices[:]
- else:
- indices.append(i)
- else:
- b2j[elt] = [i]
- # Purge leftover indices for popular elements.
- for elt in populardict:
- del b2j[elt]
+ for i, elt in enumerate(b):
+ indices = b2j.setdefault(elt, [])
+ indices.append(i)
- # Now b2j.keys() contains elements uniquely, and especially when
- # the sequence is a string, that's usually a good deal smaller
- # than len(string). The difference is the number of isjunk calls
- # saved.
+ # Purge junk elements
+ self.bjunk = junk = set()
isjunk = self.isjunk
- junkdict = {}
if isjunk:
- for d in populardict, b2j:
- for elt in list(d.keys()):
- if isjunk(elt):
- junkdict[elt] = 1
- del d[elt]
-
- # Now for x in b, isjunk(x) == x in junkdict, but the
- # latter is much faster. Note too that while there may be a
- # lot of junk in the sequence, the number of *unique* junk
- # elements is probably small. So the memory burden of keeping
- # this dict alive is likely trivial compared to the size of b2j.
- self.isbjunk = junkdict.__contains__
- self.isbpopular = populardict.__contains__
+ for elt in b2j.keys():
+ if isjunk(elt):
+ junk.add(elt)
+ for elt in junk: # separate loop avoids separate list of keys
+ del b2j[elt]
+
+ # Purge popular elements that are not junk
+ self.bpopular = popular = set()
+ n = len(b)
+ if self.autojunk and n >= 200:
+ ntest = n // 100 + 1
+ for elt, idxs in b2j.items():
+ if len(idxs) > ntest:
+ popular.add(elt)
+ for elt in popular: # ditto; as fast for 1% deletion
+ del b2j[elt]
+
+ def isbjunk(self, item):
+ "Deprecated; use 'item in SequenceMatcher().bjunk'."
+ warnings.warn("'SequenceMatcher().isbjunk(item)' is deprecated;\n"
+ "use 'item in SMinstance.bjunk' instead.",
+ DeprecationWarning, 2)
+ return item in self.bjunk
+
+ def isbpopular(self, item):
+ "Deprecated; use 'item in SequenceMatcher().bpopular'."
+ warnings.warn("'SequenceMatcher().isbpopular(item)' is deprecated;\n"
+ "use 'item in SMinstance.bpopular' instead.",
+ DeprecationWarning, 2)
+ return item in self.bpopular
def find_longest_match(self, alo, ahi, blo, bhi):
"""Find longest matching block in a[alo:ahi] and b[blo:bhi].
@@ -403,7 +407,7 @@ class SequenceMatcher:
# Windiff ends up at the same place as diff, but by pairing up
# the unique 'b's and then matching the first two 'a's.
- a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.isbjunk
+ a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.bjunk.__contains__
besti, bestj, bestsize = alo, blo, 0
# find longest junk-free match
# during an iteration of the loop, j2len[j] = length of longest
@@ -1160,18 +1164,18 @@ def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
The unidiff format normally has a header for filenames and modification
times. Any or all of these may be specified using strings for
- 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification
- times are normally expressed in the format returned by time.ctime().
+ 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
+ The modification times are normally expressed in the ISO 8601 format.
Example:
>>> for line in unified_diff('one two three four'.split(),
... 'zero one tree four'.split(), 'Original', 'Current',
- ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003',
+ ... '2005-01-26 23:30:50', '2010-04-02 10:20:52',
... lineterm=''):
- ... print(line)
- --- Original Sat Jan 26 23:30:50 1991
- +++ Current Fri Jun 06 10:20:52 2003
+ ... print(line) # doctest: +NORMALIZE_WHITESPACE
+ --- Original 2005-01-26 23:30:50
+ +++ Current 2010-04-02 10:20:52
@@ -1,4 +1,4 @@
+zero
one
@@ -1184,8 +1188,10 @@ def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
started = False
for group in SequenceMatcher(None,a,b).get_grouped_opcodes(n):
if not started:
- yield '--- %s %s%s' % (fromfile, fromfiledate, lineterm)
- yield '+++ %s %s%s' % (tofile, tofiledate, lineterm)
+ fromdate = '\t%s' % fromfiledate if fromfiledate else ''
+ todate = '\t%s' % tofiledate if tofiledate else ''
+ yield '--- %s%s%s' % (fromfile, fromdate, lineterm)
+ yield '+++ %s%s%s' % (tofile, todate, lineterm)
started = True
i1, i2, j1, j2 = group[0][1], group[-1][2], group[0][3], group[-1][4]
yield "@@ -%d,%d +%d,%d @@%s" % (i1+1, i2-i1, j1+1, j2-j1, lineterm)
@@ -1223,17 +1229,16 @@ def context_diff(a, b, fromfile='', tofile='',
The context diff format normally has a header for filenames and
modification times. Any or all of these may be specified using
strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
- The modification times are normally expressed in the format returned
- by time.ctime(). If not specified, the strings default to blanks.
+ The modification times are normally expressed in the ISO 8601 format.
+ If not specified, the strings default to blanks.
Example:
>>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(1),
- ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current',
- ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:22:46 2003')),
+ ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current')),
... end="")
- *** Original Sat Jan 26 23:30:50 1991
- --- Current Fri Jun 06 10:22:46 2003
+ *** Original
+ --- Current
***************
*** 1,4 ****
one
@@ -1251,8 +1256,10 @@ def context_diff(a, b, fromfile='', tofile='',
prefixmap = {'insert':'+ ', 'delete':'- ', 'replace':'! ', 'equal':' '}
for group in SequenceMatcher(None,a,b).get_grouped_opcodes(n):
if not started:
- yield '*** %s %s%s' % (fromfile, fromfiledate, lineterm)
- yield '--- %s %s%s' % (tofile, tofiledate, lineterm)
+ fromdate = '\t%s' % fromfiledate if fromfiledate else ''
+ todate = '\t%s' % tofiledate if tofiledate else ''
+ yield '*** %s%s%s' % (fromfile, fromdate, lineterm)
+ yield '--- %s%s%s' % (tofile, todate, lineterm)
started = True
yield '***************%s' % (lineterm,)
diff --git a/Lib/dis.py b/Lib/dis.py
index 2b400dc88f..f64bae66fb 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -6,10 +6,25 @@ import types
from opcode import *
from opcode import __all__ as _opcodes_all
-__all__ = ["dis", "disassemble", "distb", "disco",
- "findlinestarts", "findlabels"] + _opcodes_all
+__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
+ "findlinestarts", "findlabels", "show_code"] + _opcodes_all
del _opcodes_all
+_have_code = (types.MethodType, types.FunctionType, types.CodeType, type)
+
+def _try_compile(source, name):
+ """Attempts to compile the given source, first as an expression and
+ then as a statement if the first approach fails.
+
+ Utility function to accept strings in functions that otherwise
+ expect code objects
+ """
+ try:
+ c = compile(source, name, 'eval')
+ except SyntaxError:
+ c = compile(source, name, 'exec')
+ return c
+
def dis(x=None):
"""Disassemble classes, methods, functions, or code.
@@ -19,25 +34,26 @@ def dis(x=None):
if x is None:
distb()
return
- if hasattr(x, '__func__'):
+ if hasattr(x, '__func__'): # Method
x = x.__func__
- if hasattr(x, '__code__'):
+ if hasattr(x, '__code__'): # Function
x = x.__code__
- if hasattr(x, '__dict__'):
+ if hasattr(x, '__dict__'): # Class or module
items = sorted(x.__dict__.items())
for name, x1 in items:
- if isinstance(x1, (types.MethodType, types.FunctionType,
- types.CodeType, type)):
+ if isinstance(x1, _have_code):
print("Disassembly of %s:" % name)
try:
dis(x1)
except TypeError as msg:
print("Sorry:", msg)
print()
- elif hasattr(x, 'co_code'):
+ elif hasattr(x, 'co_code'): # Code object
disassemble(x)
- elif isinstance(x, (bytes, bytearray)):
- disassemble_string(x)
+ elif isinstance(x, (bytes, bytearray)): # Raw bytecode
+ _disassemble_bytes(x)
+ elif isinstance(x, str): # Source code
+ _disassemble_str(x)
else:
raise TypeError("don't know how to disassemble %s objects" %
type(x).__name__)
@@ -52,9 +68,10 @@ def distb(tb=None):
while tb.tb_next: tb = tb.tb_next
disassemble(tb.tb_frame.f_code, tb.tb_lasti)
-# XXX This duplicates information from code.h, also duplicated in inspect.py.
-# XXX Maybe this ought to be put in a central location, like opcode.py?
-flag2name = {
+# The inspect module interrogates this dictionary to build its
+# list of CO_* constants. It is also used by pretty_flags to
+# turn the co_flags field into a human readable list.
+COMPILER_FLAG_NAMES = {
1: "OPTIMIZED",
2: "NEWLOCALS",
4: "VARARGS",
@@ -70,7 +87,7 @@ def pretty_flags(flags):
for i in range(32):
flag = 1<<i
if flags & flag:
- names.append(flag2name.get(flag, hex(flag)))
+ names.append(COMPILER_FLAG_NAMES.get(flag, hex(flag)))
flags ^= flag
if not flags:
break
@@ -78,35 +95,54 @@ def pretty_flags(flags):
names.append(hex(flags))
return ", ".join(names)
-def show_code(co):
- """Show details about a code object."""
- print("Name: ", co.co_name)
- print("Filename: ", co.co_filename)
- print("Argument count: ", co.co_argcount)
- print("Kw-only arguments:", co.co_kwonlyargcount)
- print("Number of locals: ", co.co_nlocals)
- print("Stack size: ", co.co_stacksize)
- print("Flags: ", pretty_flags(co.co_flags))
+def code_info(x):
+ """Formatted details of methods, functions, or code."""
+ if hasattr(x, '__func__'): # Method
+ x = x.__func__
+ if hasattr(x, '__code__'): # Function
+ x = x.__code__
+ if isinstance(x, str): # Source code
+ x = _try_compile(x, "<code_info>")
+ if hasattr(x, 'co_code'): # Code object
+ return _format_code_info(x)
+ else:
+ raise TypeError("don't know how to disassemble %s objects" %
+ type(x).__name__)
+
+def _format_code_info(co):
+ lines = []
+ lines.append("Name: %s" % co.co_name)
+ lines.append("Filename: %s" % co.co_filename)
+ lines.append("Argument count: %s" % co.co_argcount)
+ lines.append("Kw-only arguments: %s" % co.co_kwonlyargcount)
+ lines.append("Number of locals: %s" % co.co_nlocals)
+ lines.append("Stack size: %s" % co.co_stacksize)
+ lines.append("Flags: %s" % pretty_flags(co.co_flags))
if co.co_consts:
- print("Constants:")
+ lines.append("Constants:")
for i_c in enumerate(co.co_consts):
- print("%4d: %r" % i_c)
+ lines.append("%4d: %r" % i_c)
if co.co_names:
- print("Names:")
+ lines.append("Names:")
for i_n in enumerate(co.co_names):
- print("%4d: %s" % i_n)
+ lines.append("%4d: %s" % i_n)
if co.co_varnames:
- print("Variable names:")
+ lines.append("Variable names:")
for i_n in enumerate(co.co_varnames):
- print("%4d: %s" % i_n)
+ lines.append("%4d: %s" % i_n)
if co.co_freevars:
- print("Free variables:")
+ lines.append("Free variables:")
for i_n in enumerate(co.co_freevars):
- print("%4d: %s" % i_n)
+ lines.append("%4d: %s" % i_n)
if co.co_cellvars:
- print("Cell variables:")
+ lines.append("Cell variables:")
for i_n in enumerate(co.co_cellvars):
- print("%4d: %s" % i_n)
+ lines.append("%4d: %s" % i_n)
+ return "\n".join(lines)
+
+def show_code(co):
+ """Print details of methods, functions, or code to stdout."""
+ print(code_info(co))
def disassemble(co, lasti=-1):
"""Disassemble a code object."""
@@ -156,7 +192,7 @@ def disassemble(co, lasti=-1):
print('(' + free[oparg] + ')', end=' ')
print()
-def disassemble_string(code, lasti=-1, varnames=None, names=None,
+def _disassemble_bytes(code, lasti=-1, varnames=None, names=None,
constants=None):
labels = findlabels(code)
n = len(code)
@@ -195,6 +231,10 @@ def disassemble_string(code, lasti=-1, varnames=None, names=None,
print('(' + cmp_op[oparg] + ')', end=' ')
print()
+def _disassemble_str(source):
+ """Compile the source string, then disassemble the code object."""
+ disassemble(_try_compile(source, '<dis>'))
+
disco = disassemble # XXX For backwards compatibility
def findlabels(code):
diff --git a/Lib/distutils/__init__.py b/Lib/distutils/__init__.py
index 6f55f016a2..49b6d517f6 100644
--- a/Lib/distutils/__init__.py
+++ b/Lib/distutils/__init__.py
@@ -15,5 +15,5 @@ __revision__ = "$Id$"
# Updated automatically by the Python release process.
#
#--start constants--
-__version__ = "3.1.3"
+__version__ = "3.2"
#--end constants--
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index 8a458d8536..b11957a7dc 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2005, 2006 Martin von Löwis
# Licensed to PSF under a Contributor Agreement.
# The bdist_wininst command proper
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 502b39a82f..fb31648951 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -754,9 +754,9 @@ class build_ext(Command):
else:
from distutils import sysconfig
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
- template = "python%d.%d"
- pythonlib = (template %
- (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+ pythonlib = 'python{}.{}{}'.format(
+ sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff,
+ sys.abiflags)
return ext.libraries + [pythonlib]
else:
return ext.libraries
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index 2a905d92f8..bdc3a09b22 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -48,7 +48,7 @@ INSTALL_SCHEMES = {
'unix_prefix': {
'purelib': '$base/lib/python$py_version_short/site-packages',
'platlib': '$platbase/lib/python$py_version_short/site-packages',
- 'headers': '$base/include/python$py_version_short/$dist_name',
+ 'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
'scripts': '$base/bin',
'data' : '$base',
},
@@ -60,14 +60,6 @@ INSTALL_SCHEMES = {
'data' : '$base',
},
'nt': WINDOWS_SCHEME,
- 'mac': {
- 'purelib': '$base/Lib/site-packages',
- 'platlib': '$base/Lib/site-packages',
- 'headers': '$base/Include/$dist_name',
- 'scripts': '$base/Scripts',
- 'data' : '$base',
- },
-
'os2': {
'purelib': '$base/Lib/site-packages',
'platlib': '$base/Lib/site-packages',
@@ -90,15 +82,8 @@ if HAS_USER_SITE:
INSTALL_SCHEMES['unix_user'] = {
'purelib': '$usersite',
'platlib': '$usersite',
- 'headers': '$userbase/include/python$py_version_short/$dist_name',
- 'scripts': '$userbase/bin',
- 'data' : '$userbase',
- }
-
- INSTALL_SCHEMES['mac_user'] = {
- 'purelib': '$usersite',
- 'platlib': '$usersite',
- 'headers': '$userbase/$py_version_short/include/$dist_name',
+ 'headers':
+ '$userbase/include/python$py_version_short$abiflags/$dist_name',
'scripts': '$userbase/bin',
'data' : '$userbase',
}
@@ -328,6 +313,11 @@ class install(Command):
py_version = sys.version.split()[0]
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
+ try:
+ abiflags = sys.abiflags
+ except AttributeError:
+ # sys.abiflags may not be defined on all platforms.
+ abiflags = ''
self.config_vars = {'dist_name': self.distribution.get_name(),
'dist_version': self.distribution.get_version(),
'dist_fullname': self.distribution.get_fullname(),
@@ -338,6 +328,7 @@ class install(Command):
'prefix': prefix,
'sys_exec_prefix': exec_prefix,
'exec_prefix': exec_prefix,
+ 'abiflags': abiflags,
}
if HAS_USER_SITE:
diff --git a/Lib/distutils/file_util.py b/Lib/distutils/file_util.py
index c36e7128d0..e1eb932926 100644
--- a/Lib/distutils/file_util.py
+++ b/Lib/distutils/file_util.py
@@ -130,15 +130,6 @@ def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
if dry_run:
return (dst, 1)
- # On Mac OS, use the native file copy routine
- if os.name == 'mac':
- import macostools
- try:
- macostools.copy(src, dst, 0, preserve_times)
- except os.error as exc:
- raise DistutilsFileError(
- "could not copy '%s' to '%s': %s" % (src, dst, exc.args[-1]))
-
# If linking (hard or symbolic), use the appropriate system call
# (Unix only, of course, but that's the caller's responsibility)
elif link == 'hard':
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 9842d26c47..897b7d63d6 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -11,7 +11,6 @@ Email: <fdrake@acm.org>
__revision__ = "$Id$"
-import io
import os
import re
import sys
@@ -25,7 +24,7 @@ EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
# Path to the base directory of the project. On Windows the binary may
# live in project/PCBuild9. If we're dealing with an x64 Windows build,
# it'll live in project/PCbuild/amd64.
-project_base = os.path.dirname(os.path.realpath(sys.executable))
+project_base = os.path.dirname(os.path.abspath(sys.executable))
if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
# PC/VS7.1
@@ -49,6 +48,18 @@ def _python_build():
return False
python_build = _python_build()
+# Calculate the build qualifier flags if they are defined. Adding the flags
+# to the include and lib directories only makes sense for an installation, not
+# an in-source build.
+build_flags = ''
+try:
+ if not python_build:
+ build_flags = sys.abiflags
+except AttributeError:
+ # It's not a configure-based build, so the sys module doesn't have
+ # this attribute, which is fine.
+ pass
+
def get_python_version():
"""Return a string containing the major and minor Python version,
leaving off the patchlevel. Sample return values could be '1.5'
@@ -77,20 +88,16 @@ def get_python_inc(plat_specific=0, prefix=None):
# the build directory may not be the source directory, we
# must use "srcdir" from the makefile to find the "Include"
# directory.
- base = os.path.dirname(os.path.realpath(sys.executable))
+ base = os.path.dirname(os.path.abspath(sys.executable))
if plat_specific:
return base
else:
incdir = os.path.join(get_config_var('srcdir'), 'Include')
return os.path.normpath(incdir)
- return os.path.join(prefix, "include", "python" + get_python_version())
+ python_dir = 'python' + get_python_version() + build_flags
+ return os.path.join(prefix, "include", python_dir)
elif os.name == "nt":
return os.path.join(prefix, "include")
- elif os.name == "mac":
- if plat_specific:
- return os.path.join(prefix, "Mac", "Include")
- else:
- return os.path.join(prefix, "Include")
elif os.name == "os2":
return os.path.join(prefix, "Include")
else:
@@ -131,17 +138,6 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
return prefix
else:
return os.path.join(prefix, "Lib", "site-packages")
- elif os.name == "mac":
- if plat_specific:
- if standard_lib:
- return os.path.join(prefix, "Lib", "lib-dynload")
- else:
- return os.path.join(prefix, "Lib", "site-packages")
- else:
- if standard_lib:
- return os.path.join(prefix, "Lib")
- else:
- return os.path.join(prefix, "Lib", "site-packages")
elif os.name == "os2":
if standard_lib:
return os.path.join(prefix, "Lib")
@@ -223,10 +219,10 @@ def get_config_h_filename():
def get_makefile_filename():
"""Return full pathname of installed Makefile from the Python build."""
if python_build:
- return os.path.join(os.path.dirname(os.path.realpath(sys.executable)),
- "Makefile")
+ return os.path.join(os.path.dirname(sys.executable), "Makefile")
lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
- return os.path.join(lib_dir, "config", "Makefile")
+ config_file = 'config-{}{}'.format(get_python_version(), build_flags)
+ return os.path.join(lib_dir, config_file, 'Makefile')
def parse_config_h(fp, g=None):
@@ -272,7 +268,7 @@ def parse_makefile(fn, g=None):
used instead of a new dictionary.
"""
from distutils.text_file import TextFile
- fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1)
+ fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1, errors="surrogateescape")
if g is None:
g = {}
@@ -301,6 +297,12 @@ def parse_makefile(fn, g=None):
else:
done[n] = v
+ # Variables with a 'PY_' prefix in the makefile. These need to
+ # be made available without that prefix through sysconfig.
+ # Special care is needed to ensure that variable expansion works, even
+ # if the expansion uses the name without a prefix.
+ renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS')
+
# do variable interpolation here
while notdone:
for name in list(notdone):
@@ -317,6 +319,16 @@ def parse_makefile(fn, g=None):
elif n in os.environ:
# do it like make: fall back to environment
item = os.environ[n]
+
+ elif n in renamed_variables:
+ if name.startswith('PY_') and name[3:] in renamed_variables:
+ item = ""
+
+ elif 'PY_' + n in notdone:
+ found = False
+
+ else:
+ item = str(done['PY_' + n])
else:
done[n] = item = ""
if found:
@@ -331,12 +343,24 @@ def parse_makefile(fn, g=None):
else:
done[name] = value
del notdone[name]
+
+ if name.startswith('PY_') \
+ and name[3:] in renamed_variables:
+
+ name = name[3:]
+ if name not in done:
+ done[name] = value
else:
# bogus variable reference; just drop it since we can't deal
del notdone[name]
fp.close()
+ # strip spurious spaces
+ for k, v in done.items():
+ if isinstance(v, str):
+ done[k] = v.strip()
+
# save the results in the global dictionary
g.update(done)
return g
@@ -386,7 +410,8 @@ def _init_posix():
# load the installed pyconfig.h:
try:
filename = get_config_h_filename()
- parse_config_h(io.open(filename), g)
+ with open(filename) as file:
+ parse_config_h(file, g)
except IOError as msg:
my_msg = "invalid Python installation: unable to open %s" % filename
if hasattr(msg, "strerror"):
@@ -443,34 +468,8 @@ def _init_nt():
g['SO'] = '.pyd'
g['EXE'] = ".exe"
g['VERSION'] = get_python_version().replace(".", "")
- g['BINDIR'] = os.path.dirname(os.path.realpath(sys.executable))
-
- global _config_vars
- _config_vars = g
-
-
-def _init_mac():
- """Initialize the module as appropriate for Macintosh systems"""
- g = {}
- # set basic install directories
- g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
- g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
-
- # XXX hmmm.. a normal install puts include files here
- g['INCLUDEPY'] = get_python_inc(plat_specific=0)
-
- import MacOS
- if not hasattr(MacOS, 'runtimemodel'):
- g['SO'] = '.ppc.slb'
- else:
- g['SO'] = '.%s.slb' % MacOS.runtimemodel
-
- # XXX are these used anywhere?
- g['install_lib'] = os.path.join(EXEC_PREFIX, "Lib")
- g['install_platlib'] = os.path.join(EXEC_PREFIX, "Mac", "Lib")
+ g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
- # These are used by the extension module build
- g['srcdir'] = ':'
global _config_vars
_config_vars = g
diff --git a/Lib/distutils/tests/test_bdist_msi.py b/Lib/distutils/tests/test_bdist_msi.py
new file mode 100644
index 0000000000..9308c79d91
--- /dev/null
+++ b/Lib/distutils/tests/test_bdist_msi.py
@@ -0,0 +1,25 @@
+"""Tests for distutils.command.bdist_msi."""
+import unittest
+import sys
+
+from test.support import run_unittest
+
+from distutils.tests import support
+
+@unittest.skipUnless(sys.platform=="win32", "These tests are only for win32")
+class BDistMSITestCase(support.TempdirManager,
+ support.LoggingSilencer,
+ unittest.TestCase):
+
+ def test_minimal(self):
+ # minimal test XXX need more tests
+ from distutils.command.bdist_msi import bdist_msi
+ pkg_pth, dist = self.create_dist()
+ cmd = bdist_msi(dist)
+ cmd.ensure_finalized()
+
+def test_suite():
+ return unittest.makeSuite(BDistMSITestCase)
+
+if __name__ == '__main__':
+ run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_build.py b/Lib/distutils/tests/test_build.py
new file mode 100644
index 0000000000..3391f36d4b
--- /dev/null
+++ b/Lib/distutils/tests/test_build.py
@@ -0,0 +1,55 @@
+"""Tests for distutils.command.build."""
+import unittest
+import os
+import sys
+from test.support import run_unittest
+
+from distutils.command.build import build
+from distutils.tests import support
+from sysconfig import get_platform
+
+class BuildTestCase(support.TempdirManager,
+ support.LoggingSilencer,
+ unittest.TestCase):
+
+ def test_finalize_options(self):
+ pkg_dir, dist = self.create_dist()
+ cmd = build(dist)
+ cmd.finalize_options()
+
+ # if not specified, plat_name gets the current platform
+ self.assertEqual(cmd.plat_name, get_platform())
+
+ # build_purelib is build + lib
+ wanted = os.path.join(cmd.build_base, 'lib')
+ self.assertEqual(cmd.build_purelib, wanted)
+
+ # build_platlib is 'build/lib.platform-x.x[-pydebug]'
+ # examples:
+ # build/lib.macosx-10.3-i386-2.7
+ plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3])
+ if hasattr(sys, 'gettotalrefcount'):
+ self.assertTrue(cmd.build_platlib.endswith('-pydebug'))
+ plat_spec += '-pydebug'
+ wanted = os.path.join(cmd.build_base, 'lib' + plat_spec)
+ self.assertEqual(cmd.build_platlib, wanted)
+
+ # by default, build_lib = build_purelib
+ self.assertEqual(cmd.build_lib, cmd.build_purelib)
+
+ # build_temp is build/temp.<plat>
+ wanted = os.path.join(cmd.build_base, 'temp' + plat_spec)
+ self.assertEqual(cmd.build_temp, wanted)
+
+ # build_scripts is build/scripts-x.x
+ wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3])
+ self.assertEqual(cmd.build_scripts, wanted)
+
+ # executable is os.path.normpath(sys.executable)
+ self.assertEqual(cmd.executable, os.path.normpath(sys.executable))
+
+def test_suite():
+ return unittest.makeSuite(BuildTestCase)
+
+if __name__ == "__main__":
+ run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 11844d66d3..dcba75f703 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -1,17 +1,16 @@
import sys
import os
-import tempfile
import shutil
from io import StringIO
-from distutils.core import Extension, Distribution
+from distutils.core import Distribution
from distutils.command.build_ext import build_ext
from distutils import sysconfig
from distutils.tests.support import TempdirManager
from distutils.tests.support import LoggingSilencer
from distutils.extension import Extension
-from distutils.errors import (UnknownFileError, DistutilsSetupError,
- CompileError)
+from distutils.errors import (
+ CompileError, DistutilsSetupError, UnknownFileError)
import unittest
from test import support
@@ -256,7 +255,8 @@ class BuildExtTestCase(TempdirManager,
cmd.finalize_options()
#'extensions' option must be a list of Extension instances
- self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, 'foo')
+ self.assertRaises(DistutilsSetupError,
+ cmd.check_extensions_list, 'foo')
# each element of 'ext_modules' option must be an
# Extension instance or 2-tuple
@@ -318,7 +318,7 @@ class BuildExtTestCase(TempdirManager,
def test_get_outputs(self):
tmp_dir = self.mkdtemp()
c_file = os.path.join(tmp_dir, 'foo.c')
- self.write_file(c_file, 'void PyInit_foo(void) {};\n')
+ self.write_file(c_file, 'void PyInit_foo(void) {}\n')
ext = Extension('foo', [c_file], optional=False)
dist = Distribution({'name': 'xx',
'ext_modules': [ext]})
@@ -345,8 +345,8 @@ class BuildExtTestCase(TempdirManager,
finally:
os.chdir(old_wd)
self.assertTrue(os.path.exists(so_file))
- self.assertEqual(os.path.splitext(so_file)[-1],
- sysconfig.get_config_var('SO'))
+ so_ext = sysconfig.get_config_var('SO')
+ self.assertTrue(so_file.endswith(so_ext))
so_dir = os.path.dirname(so_file)
self.assertEqual(so_dir, other_tmp_dir)
@@ -355,8 +355,7 @@ class BuildExtTestCase(TempdirManager,
cmd.run()
so_file = cmd.get_outputs()[0]
self.assertTrue(os.path.exists(so_file))
- self.assertEqual(os.path.splitext(so_file)[-1],
- sysconfig.get_config_var('SO'))
+ self.assertTrue(so_file.endswith(so_ext))
so_dir = os.path.dirname(so_file)
self.assertEqual(so_dir, cmd.build_lib)
diff --git a/Lib/distutils/tests/test_dep_util.py b/Lib/distutils/tests/test_dep_util.py
new file mode 100644
index 0000000000..3e1c366892
--- /dev/null
+++ b/Lib/distutils/tests/test_dep_util.py
@@ -0,0 +1,81 @@
+"""Tests for distutils.dep_util."""
+import unittest
+import os
+import time
+
+from distutils.dep_util import newer, newer_pairwise, newer_group
+from distutils.errors import DistutilsFileError
+from distutils.tests import support
+from test.support import run_unittest
+
+class DepUtilTestCase(support.TempdirManager, unittest.TestCase):
+
+ def test_newer(self):
+
+ tmpdir = self.mkdtemp()
+ new_file = os.path.join(tmpdir, 'new')
+ old_file = os.path.abspath(__file__)
+
+ # Raise DistutilsFileError if 'new_file' does not exist.
+ self.assertRaises(DistutilsFileError, newer, new_file, old_file)
+
+ # Return true if 'new_file' exists and is more recently modified than
+ # 'old_file', or if 'new_file' exists and 'old_file' doesn't.
+ self.write_file(new_file)
+ self.assertTrue(newer(new_file, 'I_dont_exist'))
+ self.assertTrue(newer(new_file, old_file))
+
+ # Return false if both exist and 'old_file' is the same age or younger
+ # than 'new_file'.
+ self.assertFalse(newer(old_file, new_file))
+
+ def test_newer_pairwise(self):
+ tmpdir = self.mkdtemp()
+ sources = os.path.join(tmpdir, 'sources')
+ targets = os.path.join(tmpdir, 'targets')
+ os.mkdir(sources)
+ os.mkdir(targets)
+ one = os.path.join(sources, 'one')
+ two = os.path.join(sources, 'two')
+ three = os.path.abspath(__file__) # I am the old file
+ four = os.path.join(targets, 'four')
+ self.write_file(one)
+ self.write_file(two)
+ self.write_file(four)
+
+ self.assertEqual(newer_pairwise([one, two], [three, four]),
+ ([one],[three]))
+
+ def test_newer_group(self):
+ tmpdir = self.mkdtemp()
+ sources = os.path.join(tmpdir, 'sources')
+ os.mkdir(sources)
+ one = os.path.join(sources, 'one')
+ two = os.path.join(sources, 'two')
+ three = os.path.join(sources, 'three')
+ old_file = os.path.abspath(__file__)
+
+ # return true if 'old_file' is out-of-date with respect to any file
+ # listed in 'sources'.
+ self.write_file(one)
+ self.write_file(two)
+ self.write_file(three)
+ self.assertTrue(newer_group([one, two, three], old_file))
+ self.assertFalse(newer_group([one, two, old_file], three))
+
+ # missing handling
+ os.remove(one)
+ self.assertRaises(OSError, newer_group, [one, two, old_file], three)
+
+ self.assertFalse(newer_group([one, two, old_file], three,
+ missing='ignore'))
+
+ self.assertTrue(newer_group([one, two, old_file], three,
+ missing='newer'))
+
+
+def test_suite():
+ return unittest.makeSuite(DepUtilTestCase)
+
+if __name__ == "__main__":
+ run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py
index 1624f00e53..a20d6c8ffc 100644
--- a/Lib/distutils/tests/test_dist.py
+++ b/Lib/distutils/tests/test_dist.py
@@ -1,4 +1,3 @@
-# -*- coding: utf8 -*-
"""Tests for distutils.dist."""
import os
import io
diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py
index 41414bb52e..fbe26bf65d 100644
--- a/Lib/distutils/tests/test_sysconfig.py
+++ b/Lib/distutils/tests/test_sysconfig.py
@@ -83,7 +83,7 @@ class SysconfigTestCase(support.EnvironGuard,
fd.close()
d = sysconfig.parse_makefile(self.makefile)
self.assertEqual(d, {'CONFIG_ARGS': "'--arg1=optarg1' 'ENV=LIB'",
- 'OTHER': 'foo'})
+ 'OTHER': 'foo'})
def test_parse_makefile_literal_dollar(self):
self.makefile = TESTFN
@@ -98,6 +98,15 @@ class SysconfigTestCase(support.EnvironGuard,
'OTHER': 'foo'})
+ def test_sysconfig_module(self):
+ import sysconfig as global_sysconfig
+ self.assertEqual(global_sysconfig.get_config_var('CFLAGS'), sysconfig.get_config_var('CFLAGS'))
+ self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'), sysconfig.get_config_var('LDFLAGS'))
+ self.assertEqual(global_sysconfig.get_config_var('LDSHARED'),sysconfig.get_config_var('LDSHARED'))
+ self.assertEqual(global_sysconfig.get_config_var('CC'), sysconfig.get_config_var('CC'))
+
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SysconfigTestCase))
diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py
index 97459fbf73..454725c626 100644
--- a/Lib/distutils/text_file.py
+++ b/Lib/distutils/text_file.py
@@ -58,6 +58,8 @@ class TextFile:
collapse_join [default: false]
strip leading whitespace from lines that are joined to their
predecessor; only matters if (join_lines and not lstrip_ws)
+ errors [default: 'strict']
+ error handler used to decode the file content
Note that since 'rstrip_ws' can strip the trailing newline, the
semantics of 'readline()' must differ from those of the builtin file
@@ -72,6 +74,7 @@ class TextFile:
'rstrip_ws': 1,
'join_lines': 0,
'collapse_join': 0,
+ 'errors': 'strict',
}
def __init__(self, filename=None, file=None, **options):
@@ -111,7 +114,7 @@ class TextFile:
"""Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor."""
self.filename = filename
- self.file = io.open(self.filename, 'r')
+ self.file = io.open(self.filename, 'r', errors=self.errors)
self.current_line = 0
def close(self):
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 3081245b62..ce3cd6ca33 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -235,15 +235,6 @@ def change_root (new_root, pathname):
path = path[1:]
return os.path.join(new_root, path)
- elif os.name == 'mac':
- if not os.path.isabs(pathname):
- return os.path.join(new_root, pathname)
- else:
- # Chop off volume name from start of path
- elements = pathname.split(":", 1)
- pathname = ":" + elements[1]
- return os.path.join(new_root, pathname)
-
else:
raise DistutilsPlatformError("nothing known about platform '%s'" % os.name)
diff --git a/Lib/doctest.py b/Lib/doctest.py
index fae333e4f6..9eba4e0b50 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -318,7 +318,8 @@ class _OutputRedirectingPdb(pdb.Pdb):
def __init__(self, out):
self.__out = out
self.__debugger_used = False
- pdb.Pdb.__init__(self, stdout=out)
+ # do not play signal games in the pdb
+ pdb.Pdb.__init__(self, stdout=out, nosigint=True)
# still use input() to get user input
self.use_rawinput = 1
@@ -1280,9 +1281,9 @@ class DocTestRunner:
# Another chance if they didn't care about the detail.
elif self.optionflags & IGNORE_EXCEPTION_DETAIL:
- m1 = re.match(r'[^:]*:', example.exc_msg)
- m2 = re.match(r'[^:]*:', exc_msg)
- if m1 and m2 and check(m1.group(0), m2.group(0),
+ m1 = re.match(r'(?:[^:]*\.)?([^:]*:)', example.exc_msg)
+ m2 = re.match(r'(?:[^:]*\.)?([^:]*:)', exc_msg)
+ if m1 and m2 and check(m1.group(1), m2.group(1),
self.optionflags):
outcome = SUCCESS
@@ -1320,7 +1321,7 @@ class DocTestRunner:
self.tries += t
__LINECACHE_FILENAME_RE = re.compile(r'<doctest '
- r'(?P<name>[\w\.]+)'
+ r'(?P<name>.+)'
r'\[(?P<examplenum>\d+)\]>$')
def __patched_linecache_getlines(self, filename, module_globals=None):
m = self.__LINECACHE_FILENAME_RE.match(filename)
@@ -2207,6 +2208,19 @@ class DocTestCase(unittest.TestCase):
def shortDescription(self):
return "Doctest: " + self._dt_test.name
+class SkipDocTestCase(DocTestCase):
+ def __init__(self):
+ DocTestCase.__init__(self, None)
+
+ def setUp(self):
+ self.skipTest("DocTestSuite will not work with -O2 and above")
+
+ def test_skip(self):
+ pass
+
+ def shortDescription(self):
+ return "Skipping tests from %s" % module.__name__
+
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
**options):
"""
@@ -2249,13 +2263,20 @@ def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
module = _normalize_module(module)
tests = test_finder.find(module, globs=globs, extraglobs=extraglobs)
- if not tests:
+
+ if not tests and sys.flags.optimize >=2:
+ # Skip doctests when running with -O2
+ suite = unittest.TestSuite()
+ suite.addTest(SkipDocTestCase())
+ return suite
+ elif not tests:
# Why do we want to do this? Because it reveals a bug that might
# otherwise be hidden.
raise ValueError(module, "has no tests")
tests.sort()
suite = unittest.TestSuite()
+
for test in tests:
if len(test.examples) == 0:
continue
@@ -2508,14 +2529,16 @@ def debug_script(src, pm=False, globs=None):
exec(f.read(), globs, globs)
except:
print(sys.exc_info()[1])
- pdb.post_mortem(sys.exc_info()[2])
+ p = pdb.Pdb(nosigint=True)
+ p.reset()
+ p.interaction(None, sys.exc_info()[2])
else:
fp = open(srcfilename)
try:
script = fp.read()
finally:
fp.close()
- pdb.run("exec(%r)" % script, globs, globs)
+ pdb.Pdb(nosigint=True).run("exec(%r)" % script, globs, globs)
finally:
os.remove(srcfilename)
diff --git a/Lib/email/__init__.py b/Lib/email/__init__.py
index 8702212080..bd316fdaf3 100644
--- a/Lib/email/__init__.py
+++ b/Lib/email/__init__.py
@@ -4,7 +4,7 @@
"""A package for parsing, handling, and generating email messages."""
-__version__ = '5.0.0'
+__version__ = '5.1.0'
__all__ = [
'base64mime',
@@ -16,7 +16,9 @@ __all__ = [
'iterators',
'message',
'message_from_file',
+ 'message_from_binary_file',
'message_from_string',
+ 'message_from_bytes',
'mime',
'parser',
'quoprimime',
@@ -36,6 +38,13 @@ def message_from_string(s, *args, **kws):
from email.parser import Parser
return Parser(*args, **kws).parsestr(s)
+def message_from_bytes(s, *args, **kws):
+ """Parse a bytes string into a Message object model.
+
+ Optional _class and strict are passed to the Parser constructor.
+ """
+ from email.parser import BytesParser
+ return BytesParser(*args, **kws).parsebytes(s)
def message_from_file(fp, *args, **kws):
"""Read a file and parse its contents into a Message object model.
@@ -44,3 +53,11 @@ def message_from_file(fp, *args, **kws):
"""
from email.parser import Parser
return Parser(*args, **kws).parse(fp)
+
+def message_from_binary_file(fp, *args, **kws):
+ """Read a binary file and parse its contents into a Message object model.
+
+ Optional _class and strict are passed to the Parser constructor.
+ """
+ from email.parser import BytesParser
+ return BytesParser(*args, **kws).parse(fp)
diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py
index 3bd4ba4403..41694f9b1a 100644
--- a/Lib/email/_parseaddr.py
+++ b/Lib/email/_parseaddr.py
@@ -64,8 +64,10 @@ def parsedate_tz(data):
if len(data) == 4:
s = data[3]
i = s.find('+')
+ if i == -1:
+ i = s.find('-')
if i > 0:
- data[3:] = [s[:i], s[i+1:]]
+ data[3:] = [s[:i], s[i:]]
else:
data.append('') # Dummy tz
if len(data) < 5:
@@ -199,14 +201,18 @@ class AddrlistClass:
self.commentlist = []
def gotonext(self):
- """Parse up to the start of the next address."""
+ """Skip white space and extract comments."""
+ wslist = []
while self.pos < len(self.field):
if self.field[self.pos] in self.LWS + '\n\r':
+ if self.field[self.pos] not in '\n\r':
+ wslist.append(self.field[self.pos])
self.pos += 1
elif self.field[self.pos] == '(':
self.commentlist.append(self.getcomment())
else:
break
+ return EMPTYSTRING.join(wslist)
def getaddrlist(self):
"""Parse all addresses.
@@ -319,16 +325,24 @@ class AddrlistClass:
self.gotonext()
while self.pos < len(self.field):
+ preserve_ws = True
if self.field[self.pos] == '.':
+ if aslist and not aslist[-1].strip():
+ aslist.pop()
aslist.append('.')
self.pos += 1
+ preserve_ws = False
elif self.field[self.pos] == '"':
aslist.append('"%s"' % quote(self.getquote()))
elif self.field[self.pos] in self.atomends:
+ if aslist and not aslist[-1].strip():
+ aslist.pop()
break
else:
aslist.append(self.getatom())
- self.gotonext()
+ ws = self.gotonext()
+ if preserve_ws and ws:
+ aslist.append(ws)
if self.pos >= len(self.field) or self.field[self.pos] != '@':
return EMPTYSTRING.join(aslist)
diff --git a/Lib/email/base64mime.py b/Lib/email/base64mime.py
index 28e2542520..f3bbac1caf 100644
--- a/Lib/email/base64mime.py
+++ b/Lib/email/base64mime.py
@@ -20,7 +20,7 @@ in To:, From:, Cc:, etc. fields, as well as Subject: lines.
This module does not do the line wrapping or end-of-line character conversion
necessary for proper internationalized headers; it only does dumb encoding and
-decoding. To deal with the various line wrapping issues, use the email.Header
+decoding. To deal with the various line wrapping issues, use the email.header
module.
"""
@@ -74,12 +74,12 @@ def header_encode(header_bytes, charset='iso-8859-1'):
def body_encode(s, maxlinelen=76, eol=NL):
- """Encode a string with base64.
+ r"""Encode a string with base64.
Each line will be wrapped at, at most, maxlinelen characters (defaults to
76 characters).
- Each line of encoded text will end with eol, which defaults to "\\n". Set
+ Each line of encoded text will end with eol, which defaults to "\n". Set
this to "\r\n" if you will be using the result of this function directly
in an email.
"""
@@ -104,7 +104,7 @@ def decode(string):
This function does not parse a full MIME header value encoded with
base64 (like =?iso-8895-1?b?bmloISBuaWgh?=) -- please use the high
- level email.Header class for that functionality.
+ level email.header class for that functionality.
"""
if not string:
return bytes()
diff --git a/Lib/email/charset.py b/Lib/email/charset.py
index 898beedb00..f22be2c52c 100644
--- a/Lib/email/charset.py
+++ b/Lib/email/charset.py
@@ -28,6 +28,7 @@ SHORTEST = 3 # the shorter of QP and base64, but only for headers
RFC2047_CHROME_LEN = 7
DEFAULT_CHARSET = 'us-ascii'
+UNKNOWN8BIT = 'unknown-8bit'
EMPTYSTRING = ''
@@ -153,6 +154,16 @@ def add_codec(charset, codecname):
+# Convenience function for encoding strings, taking into account
+# that they might be unknown-8bit (ie: have surrogate-escaped bytes)
+def _encode(string, codec):
+ if codec == UNKNOWN8BIT:
+ return string.encode('ascii', 'surrogateescape')
+ else:
+ return string.encode(codec)
+
+
+
class Charset:
"""Map character sets to their email properties.
@@ -252,7 +263,7 @@ class Charset:
Returns "quoted-printable" if self.body_encoding is QP.
Returns "base64" if self.body_encoding is BASE64.
- Returns "7bit" otherwise.
+ Returns conversion function otherwise.
"""
assert self.body_encoding != SHORTEST
if self.body_encoding == QP:
@@ -282,8 +293,7 @@ class Charset:
:return: The encoded string, with RFC 2047 chrome.
"""
codec = self.output_codec or 'us-ascii'
- charset = self.get_output_charset()
- header_bytes = string.encode(codec)
+ header_bytes = _encode(string, codec)
# 7bit/8bit encodings return the string unchanged (modulo conversions)
encoder_module = self._get_encoder(header_bytes)
if encoder_module is None:
@@ -309,9 +319,9 @@ class Charset:
"""
# See which encoding we should use.
codec = self.output_codec or 'us-ascii'
- header_bytes = string.encode(codec)
+ header_bytes = _encode(string, codec)
encoder_module = self._get_encoder(header_bytes)
- encoder = partial(encoder_module.header_encode, charset=str(self))
+ encoder = partial(encoder_module.header_encode, charset=codec)
# Calculate the number of characters that the RFC 2047 chrome will
# contribute to each line.
charset = self.get_output_charset()
@@ -333,7 +343,7 @@ class Charset:
for character in string:
current_line.append(character)
this_line = EMPTYSTRING.join(current_line)
- length = encoder_module.header_length(this_line.encode(charset))
+ length = encoder_module.header_length(_encode(this_line, charset))
if length > maxlen:
# This last character doesn't fit so pop it off.
current_line.pop()
@@ -343,12 +353,12 @@ class Charset:
else:
separator = (' ' if lines else '')
joined_line = EMPTYSTRING.join(current_line)
- header_bytes = joined_line.encode(codec)
+ header_bytes = _encode(joined_line, codec)
lines.append(encoder(header_bytes))
current_line = [character]
maxlen = next(maxlengths) - extra
joined_line = EMPTYSTRING.join(current_line)
- header_bytes = joined_line.encode(codec)
+ header_bytes = _encode(joined_line, codec)
lines.append(encoder(header_bytes))
return lines
@@ -371,7 +381,10 @@ class Charset:
"""Body-encode a string by converting it first to bytes.
The type of encoding (base64 or quoted-printable) will be based on
- self.body_encoding.
+ self.body_encoding. If body_encoding is None, we assume the
+ output charset is a 7bit encoding, so re-encoding the decoded
+ string using the ascii codec produces the correct string version
+ of the content.
"""
# 7bit/8bit encodings return the string unchanged (module conversions)
if self.body_encoding is BASE64:
@@ -381,4 +394,6 @@ class Charset:
elif self.body_encoding is QP:
return email.quoprimime.body_encode(string)
else:
+ if isinstance(string, str):
+ string = string.encode(self.output_charset).decode('ascii')
return string
diff --git a/Lib/email/encoders.py b/Lib/email/encoders.py
index dfaac58204..e5c099f35a 100644
--- a/Lib/email/encoders.py
+++ b/Lib/email/encoders.py
@@ -54,10 +54,13 @@ def encode_7or8bit(msg):
# There's no payload. For backwards compatibility we use 7bit
msg['Content-Transfer-Encoding'] = '7bit'
return
- # We play a trick to make this go fast. If encoding to ASCII succeeds, we
- # know the data must be 7bit, otherwise treat it as 8bit.
+ # We play a trick to make this go fast. If encoding/decode to ASCII
+ # succeeds, we know the data must be 7bit, otherwise treat it as 8bit.
try:
- orig.encode('ascii')
+ if isinstance(orig, str):
+ orig.encode('ascii')
+ else:
+ orig.decode('ascii')
except UnicodeError:
# iso-2022-* is non-ASCII but still 7-bit
charset = msg.get_charset()
diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py
index 8db70b3c36..de8750dc16 100644
--- a/Lib/email/feedparser.py
+++ b/Lib/email/feedparser.py
@@ -482,3 +482,10 @@ class FeedParser:
if lastheader:
# XXX reconsider the joining of folded lines
self._cur[lastheader] = EMPTYSTRING.join(lastvalue).rstrip('\r\n')
+
+
+class BytesFeedParser(FeedParser):
+ """Like FeedParser, but feed accepts bytes."""
+
+ def feed(self, data):
+ super().feed(data.decode('ascii', 'surrogateescape'))
diff --git a/Lib/email/generator.py b/Lib/email/generator.py
index cc30affad9..f0e7a95477 100644
--- a/Lib/email/generator.py
+++ b/Lib/email/generator.py
@@ -12,11 +12,12 @@ import time
import random
import warnings
-from io import StringIO
+from io import StringIO, BytesIO
from email.header import Header
+from email.message import _has_surrogates
UNDERSCORE = '_'
-NL = '\n'
+NL = '\n' # XXX: no longer used by the code below.
fcre = re.compile(r'^From ', re.MULTILINE)
@@ -57,8 +58,8 @@ class Generator:
# Just delegate to the file object
self._fp.write(s)
- def flatten(self, msg, unixfrom=False):
- """Print the message object tree rooted at msg to the output file
+ def flatten(self, msg, unixfrom=False, linesep='\n'):
+ r"""Print the message object tree rooted at msg to the output file
specified when the Generator instance was created.
unixfrom is a flag that forces the printing of a Unix From_ delimiter
@@ -67,12 +68,26 @@ class Generator:
is False to inhibit the printing of any From_ delimiter.
Note that for subobjects, no From_ line is printed.
+
+ linesep specifies the characters used to indicate a new line in
+ the output. The default value is the most useful for typical
+ Python applications, but it can be set to \r\n to produce RFC-compliant
+ line separators when needed.
+
"""
+ # We use the _XXX constants for operating on data that comes directly
+ # from the msg, and _encoded_XXX constants for operating on data that
+ # has already been converted (to bytes in the BytesGenerator) and
+ # inserted into a temporary buffer.
+ self._NL = linesep
+ self._encoded_NL = self._encode(linesep)
+ self._EMPTY = ''
+ self._encoded_EMTPY = self._encode('')
if unixfrom:
ufrom = msg.get_unixfrom()
if not ufrom:
ufrom = 'From nobody ' + time.ctime(time.time())
- print(ufrom, file=self._fp)
+ self.write(ufrom + self._NL)
self._write(msg)
def clone(self, fp):
@@ -83,6 +98,27 @@ class Generator:
# Protected interface - undocumented ;/
#
+ # Note that we use 'self.write' when what we are writing is coming from
+ # the source, and self._fp.write when what we are writing is coming from a
+ # buffer (because the Bytes subclass has already had a chance to transform
+ # the data in its write method in that case). This is an entirely
+ # pragmatic split determined by experiment; we could be more general by
+ # always using write and having the Bytes subclass write method detect when
+ # it has already transformed the input; but, since this whole thing is a
+ # hack anyway this seems good enough.
+
+ # Similarly, we have _XXX and _encoded_XXX attributes that are used on
+ # source and buffer data, respectively.
+ _encoded_EMPTY = ''
+
+ def _new_buffer(self):
+ # BytesGenerator overrides this to return BytesIO.
+ return StringIO()
+
+ def _encode(self, s):
+ # BytesGenerator overrides this to encode strings to bytes.
+ return s
+
def _write(self, msg):
# We can't write the headers yet because of the following scenario:
# say a multipart message includes the boundary string somewhere in
@@ -91,13 +127,13 @@ class Generator:
# parameter.
#
# The way we do this, so as to make the _handle_*() methods simpler,
- # is to cache any subpart writes into a StringIO. The we write the
- # headers and the StringIO contents. That way, subpart handlers can
+ # is to cache any subpart writes into a buffer. The we write the
+ # headers and the buffer contents. That way, subpart handlers can
# Do The Right Thing, and can still modify the Content-Type: header if
# necessary.
oldfp = self._fp
try:
- self._fp = sfp = StringIO()
+ self._fp = sfp = self._new_buffer()
self._dispatch(msg)
finally:
self._fp = oldfp
@@ -132,16 +168,17 @@ class Generator:
def _write_headers(self, msg):
for h, v in msg.items():
- print('%s:' % h, end=' ', file=self._fp)
+ self.write('%s: ' % h)
if isinstance(v, Header):
- print(v.encode(maxlinelen=self._maxheaderlen), file=self._fp)
+ self.write(v.encode(
+ maxlinelen=self._maxheaderlen, linesep=self._NL)+self._NL)
else:
# Header's got lots of smarts, so use it.
header = Header(v, maxlinelen=self._maxheaderlen,
header_name=h)
- print(header.encode(), file=self._fp)
+ self.write(header.encode(linesep=self._NL)+self._NL)
# A blank line always separates headers from body
- print(file=self._fp)
+ self.write(self._NL)
#
# Handlers for writing types and subtypes
@@ -153,9 +190,15 @@ class Generator:
return
if not isinstance(payload, str):
raise TypeError('string payload expected: %s' % type(payload))
+ if _has_surrogates(msg._payload):
+ charset = msg.get_param('charset')
+ if charset is not None:
+ del msg['content-transfer-encoding']
+ msg.set_payload(payload, charset)
+ payload = msg.get_payload()
if self._mangle_from_:
payload = fcre.sub('>From ', payload)
- self._fp.write(payload)
+ self.write(payload)
# Default body handler
_writeBody = _handle_text
@@ -170,29 +213,29 @@ class Generator:
subparts = []
elif isinstance(subparts, str):
# e.g. a non-strict parse of a message with no starting boundary.
- self._fp.write(subparts)
+ self.write(subparts)
return
elif not isinstance(subparts, list):
# Scalar payload
subparts = [subparts]
for part in subparts:
- s = StringIO()
+ s = self._new_buffer()
g = self.clone(s)
- g.flatten(part, unixfrom=False)
+ g.flatten(part, unixfrom=False, linesep=self._NL)
msgtexts.append(s.getvalue())
# BAW: What about boundaries that are wrapped in double-quotes?
boundary = msg.get_boundary()
if not boundary:
# Create a boundary that doesn't appear in any of the
# message texts.
- alltext = NL.join(msgtexts)
- boundary = _make_boundary(alltext)
+ alltext = self._encoded_NL.join(msgtexts)
+ boundary = self._make_boundary(alltext)
msg.set_boundary(boundary)
# If there's a preamble, write it out, with a trailing CRLF
if msg.preamble is not None:
- print(msg.preamble, file=self._fp)
+ self.write(msg.preamble + self._NL)
# dash-boundary transport-padding CRLF
- print('--' + boundary, file=self._fp)
+ self.write('--' + boundary + self._NL)
# body-part
if msgtexts:
self._fp.write(msgtexts.pop(0))
@@ -201,14 +244,14 @@ class Generator:
# --> CRLF body-part
for body_part in msgtexts:
# delimiter transport-padding CRLF
- print('\n--' + boundary, file=self._fp)
+ self.write(self._NL + '--' + boundary + self._NL)
# body-part
self._fp.write(body_part)
# close-delimiter transport-padding
- self._fp.write('\n--' + boundary + '--')
+ self.write(self._NL + '--' + boundary + '--')
if msg.epilogue is not None:
- print(file=self._fp)
- self._fp.write(msg.epilogue)
+ self.write(self._NL)
+ self.write(msg.epilogue)
def _handle_multipart_signed(self, msg):
# The contents of signed parts has to stay unmodified in order to keep
@@ -227,23 +270,23 @@ class Generator:
# block and the boundary. Sigh.
blocks = []
for part in msg.get_payload():
- s = StringIO()
+ s = self._new_buffer()
g = self.clone(s)
- g.flatten(part, unixfrom=False)
+ g.flatten(part, unixfrom=False, linesep=self._NL)
text = s.getvalue()
- lines = text.split('\n')
+ lines = text.split(self._encoded_NL)
# Strip off the unnecessary trailing empty line
- if lines and lines[-1] == '':
- blocks.append(NL.join(lines[:-1]))
+ if lines and lines[-1] == self._encoded_EMPTY:
+ blocks.append(self._encoded_NL.join(lines[:-1]))
else:
blocks.append(text)
# Now join all the blocks with an empty line. This has the lovely
# effect of separating each block with an empty line, but not adding
# an extra one after the last one.
- self._fp.write(NL.join(blocks))
+ self._fp.write(self._encoded_NL.join(blocks))
def _handle_message(self, msg):
- s = StringIO()
+ s = self._new_buffer()
g = self.clone(s)
# The payload of a message/rfc822 part should be a multipart sequence
# of length 1. The zeroth element of the list should be the Message
@@ -256,10 +299,98 @@ class Generator:
# in that case we just emit the string body.
payload = msg.get_payload()
if isinstance(payload, list):
- g.flatten(msg.get_payload(0), unixfrom=False)
+ g.flatten(msg.get_payload(0), unixfrom=False, linesep=self._NL)
payload = s.getvalue()
self._fp.write(payload)
+ # This used to be a module level function; we use a classmethod for this
+ # and _compile_re so we can continue to provide the module level function
+ # for backward compatibility by doing
+ # _make_boudary = Generator._make_boundary
+ # at the end of the module. It *is* internal, so we could drop that...
+ @classmethod
+ def _make_boundary(cls, text=None):
+ # Craft a random boundary. If text is given, ensure that the chosen
+ # boundary doesn't appear in the text.
+ token = random.randrange(sys.maxsize)
+ boundary = ('=' * 15) + (_fmt % token) + '=='
+ if text is None:
+ return boundary
+ b = boundary
+ counter = 0
+ while True:
+ cre = cls._compile_re('^--' + re.escape(b) + '(--)?$', re.MULTILINE)
+ if not cre.search(text):
+ break
+ b = boundary + '.' + str(counter)
+ counter += 1
+ return b
+
+ @classmethod
+ def _compile_re(cls, s, flags):
+ return re.compile(s, flags)
+
+
+class BytesGenerator(Generator):
+ """Generates a bytes version of a Message object tree.
+
+ Functionally identical to the base Generator except that the output is
+ bytes and not string. When surrogates were used in the input to encode
+ bytes, these are decoded back to bytes for output.
+
+ The outfp object must accept bytes in its write method.
+ """
+
+ # Bytes versions of this constant for use in manipulating data from
+ # the BytesIO buffer.
+ _encoded_EMPTY = b''
+
+ def write(self, s):
+ self._fp.write(s.encode('ascii', 'surrogateescape'))
+
+ def _new_buffer(self):
+ return BytesIO()
+
+ def _encode(self, s):
+ return s.encode('ascii')
+
+ def _write_headers(self, msg):
+ # This is almost the same as the string version, except for handling
+ # strings with 8bit bytes.
+ for h, v in msg._headers:
+ self.write('%s: ' % h)
+ if isinstance(v, Header):
+ self.write(v.encode(maxlinelen=self._maxheaderlen)+NL)
+ elif _has_surrogates(v):
+ # If we have raw 8bit data in a byte string, we have no idea
+ # what the encoding is. There is no safe way to split this
+ # string. If it's ascii-subset, then we could do a normal
+ # ascii split, but if it's multibyte then we could break the
+ # string. There's no way to know so the least harm seems to
+ # be to not split the string and risk it being too long.
+ self.write(v+NL)
+ else:
+ # Header's got lots of smarts and this string is safe...
+ header = Header(v, maxlinelen=self._maxheaderlen,
+ header_name=h)
+ self.write(header.encode(linesep=self._NL)+self._NL)
+ # A blank line always separates headers from body
+ self.write(self._NL)
+
+ def _handle_text(self, msg):
+ # If the string has surrogates the original source was bytes, so
+ # just write it back out.
+ if msg._payload is None:
+ return
+ if _has_surrogates(msg._payload):
+ self.write(msg._payload)
+ else:
+ super(BytesGenerator,self)._handle_text(msg)
+
+ @classmethod
+ def _compile_re(cls, s, flags):
+ return re.compile(s.encode('ascii'), flags)
+
_FMT = '[Non-text (%(type)s) part of message omitted, filename %(filename)s]'
@@ -320,23 +451,9 @@ class DecodedGenerator(Generator):
-# Helper
+# Helper used by Generator._make_boundary
_width = len(repr(sys.maxsize-1))
_fmt = '%%0%dd' % _width
-def _make_boundary(text=None):
- # Craft a random boundary. If text is given, ensure that the chosen
- # boundary doesn't appear in the text.
- token = random.randrange(sys.maxsize)
- boundary = ('=' * 15) + (_fmt % token) + '=='
- if text is None:
- return boundary
- b = boundary
- counter = 0
- while True:
- cre = re.compile('^--' + re.escape(b) + '(--)?$', re.MULTILINE)
- if not cre.search(text):
- break
- b = boundary + '.' + str(counter)
- counter += 1
- return b
+# Backward compatibility
+_make_boundary = Generator._make_boundary
diff --git a/Lib/email/header.py b/Lib/email/header.py
index da739d5892..8c325145aa 100644
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -17,7 +17,8 @@ import email.quoprimime
import email.base64mime
from email.errors import HeaderParseError
-from email.charset import Charset
+from email import charset as _charset
+Charset = _charset.Charset
NL = '\n'
SPACE = ' '
@@ -65,7 +66,7 @@ def decode_header(header):
otherwise a lower-case string containing the name of the character set
specified in the encoded string.
- An email.Errors.HeaderParseError may be raised when certain decoding error
+ An email.errors.HeaderParseError may be raised when certain decoding error
occurs (e.g. a base64 decoding exception).
"""
# If no encoding, just return the header with no charset.
@@ -214,6 +215,9 @@ class Header:
# from a charset to None/us-ascii, or from None/us-ascii to a
# charset. Only do this for the second and subsequent chunks.
nextcs = charset
+ if nextcs == _charset.UNKNOWN8BIT:
+ original_bytes = string.encode('ascii', 'surrogateescape')
+ string = original_bytes.decode('ascii', 'replace')
if uchunks:
if lastcs not in (None, 'us-ascii'):
if nextcs in (None, 'us-ascii'):
@@ -267,11 +271,12 @@ class Header:
# Ensure that the bytes we're storing can be decoded to the output
# character set, otherwise an early error is thrown.
output_charset = charset.output_codec or 'us-ascii'
- s.encode(output_charset, errors)
+ if output_charset != _charset.UNKNOWN8BIT:
+ s.encode(output_charset, errors)
self._chunks.append((s, charset))
- def encode(self, splitchars=';, \t', maxlinelen=None):
- """Encode a message header into an RFC-compliant format.
+ def encode(self, splitchars=';, \t', maxlinelen=None, linesep='\n'):
+ r"""Encode a message header into an RFC-compliant format.
There are many issues involved in converting a given string for use in
an email header. Only certain character sets are readable in most
@@ -291,6 +296,11 @@ class Header:
Optional splitchars is a string containing characters to split long
ASCII lines on, in rough support of RFC 2822's `highest level
syntactic breaks'. This doesn't affect RFC 2047 encoded lines.
+
+ Optional linesep is a string to be used to separate the lines of
+ the value. The default value is the most useful for typical
+ Python applications, but it can be set to \r\n to produce RFC-compliant
+ line separators when needed.
"""
self._normalize()
if maxlinelen is None:
@@ -314,7 +324,7 @@ class Header:
if len(lines) > 1:
formatter.newline()
formatter.add_transition()
- value = str(formatter)
+ value = formatter._str(linesep)
if _embeded_header.search(value):
raise HeaderParseError("header value appears to contain "
"an embedded header: {!r}".format(value))
@@ -349,9 +359,12 @@ class _ValueFormatter:
self._lines = []
self._current_line = _Accumulator(headerlen)
- def __str__(self):
+ def _str(self, linesep):
self.newline()
- return NL.join(self._lines)
+ return linesep.join(self._lines)
+
+ def __str__(self):
+ return self._str(NL)
def newline(self):
end_of_line = self._current_line.pop()
diff --git a/Lib/email/message.py b/Lib/email/message.py
index d30f109a5b..2713bc5d35 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -16,7 +16,9 @@ from io import BytesIO, StringIO
# Intrapackage imports
from email import utils
from email import errors
-from email.charset import Charset
+from email import header
+from email import charset as _charset
+Charset = _charset.Charset
SEMISPACE = '; '
@@ -24,8 +26,25 @@ SEMISPACE = '; '
# existence of which force quoting of the parameter value.
tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]')
+# How to figure out if we are processing strings that come from a byte
+# source with undecodable characters.
+_has_surrogates = re.compile(
+ '([^\ud800-\udbff]|\A)[\udc00-\udfff]([^\udc00-\udfff]|\Z)').search
+
# Helper functions
+def _sanitize_header(name, value):
+ # If the header value contains surrogates, return a Header using
+ # the unknown-8bit charset to encode the bytes as encoded words.
+ if not isinstance(value, str):
+ # Assume it is already a header object
+ return value
+ if _has_surrogates(value):
+ return header.Header(value, charset=_charset.UNKNOWN8BIT,
+ header_name=name)
+ else:
+ return value
+
def _splitparam(param):
# Split header parameters. BAW: this may be too simple. It isn't
# strictly RFC 2045 (section 5.1) compliant, but it catches most headers
@@ -48,17 +67,19 @@ def _formatparam(param, value=None, quote=True):
if value is not None and len(value) > 0:
# A tuple is used for RFC 2231 encoded parameter values where items
# are (charset, language, value). charset is a string, not a Charset
- # instance.
+ # instance. RFC 2231 encoded values are never quoted, per RFC.
if isinstance(value, tuple):
# Encode as per RFC 2231
param += '*'
value = utils.encode_rfc2231(value[2], value[0], value[1])
+ return '%s=%s' % (param, value)
else:
try:
value.encode('ascii')
except UnicodeEncodeError:
param += '*'
value = utils.encode_rfc2231(value, 'utf-8', '')
+ return '%s=%s' % (param, value)
# BAW: Please check this. I think that if quote is set it should
# force quoting even if not necessary.
if quote or tspecials.search(value):
@@ -193,43 +214,72 @@ class Message:
If the message is a multipart and the decode flag is True, then None
is returned.
"""
- if i is None:
- payload = self._payload
- elif not isinstance(self._payload, list):
+ # Here is the logic table for this code, based on the email5.0.0 code:
+ # i decode is_multipart result
+ # ------ ------ ------------ ------------------------------
+ # None True True None
+ # i True True None
+ # None False True _payload (a list)
+ # i False True _payload element i (a Message)
+ # i False False error (not a list)
+ # i True False error (not a list)
+ # None False False _payload
+ # None True False _payload decoded (bytes)
+ # Note that Barry planned to factor out the 'decode' case, but that
+ # isn't so easy now that we handle the 8 bit data, which needs to be
+ # converted in both the decode and non-decode path.
+ if self.is_multipart():
+ if decode:
+ return None
+ if i is None:
+ return self._payload
+ else:
+ return self._payload[i]
+ # For backward compatibility, Use isinstance and this error message
+ # instead of the more logical is_multipart test.
+ if i is not None and not isinstance(self._payload, list):
raise TypeError('Expected list, got %s' % type(self._payload))
- else:
- payload = self._payload[i]
+ payload = self._payload
+ cte = self.get('content-transfer-encoding', '').lower()
+ # payload may be bytes here.
+ if isinstance(payload, str):
+ if _has_surrogates(payload):
+ bpayload = payload.encode('ascii', 'surrogateescape')
+ if not decode:
+ try:
+ payload = bpayload.decode(self.get_param('charset', 'ascii'), 'replace')
+ except LookupError:
+ payload = bpayload.decode('ascii', 'replace')
+ elif decode:
+ try:
+ bpayload = payload.encode('ascii')
+ except UnicodeError:
+ # This won't happen for RFC compliant messages (messages
+ # containing only ASCII codepoints in the unicode input).
+ # If it does happen, turn the string into bytes in a way
+ # guaranteed not to fail.
+ bpayload = payload.encode('raw-unicode-escape')
if not decode:
return payload
- # Decoded payloads always return bytes. XXX split this part out into
- # a new method called .get_decoded_payload().
- if self.is_multipart():
- return None
- cte = self.get('content-transfer-encoding', '').lower()
if cte == 'quoted-printable':
- return utils._qdecode(payload)
+ return utils._qdecode(bpayload)
elif cte == 'base64':
try:
- if isinstance(payload, str):
- payload = payload.encode('raw-unicode-escape')
- return base64.b64decode(payload)
- #return utils._bdecode(payload)
+ return base64.b64decode(bpayload)
except binascii.Error:
# Incorrect padding
- pass
+ return bpayload
elif cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
- in_file = BytesIO(payload.encode('raw-unicode-escape'))
+ in_file = BytesIO(bpayload)
out_file = BytesIO()
try:
uu.decode(in_file, out_file, quiet=True)
return out_file.getvalue()
except uu.Error:
# Some decoding problem
- pass
- # Is there a better way to do this? We can't use the bytes
- # constructor.
+ return bpayload
if isinstance(payload, str):
- return payload.encode('raw-unicode-escape')
+ return bpayload
return payload
def set_payload(self, payload, charset=None):
@@ -348,7 +398,7 @@ class Message:
Any fields deleted and re-inserted are always appended to the header
list.
"""
- return [v for k, v in self._headers]
+ return [_sanitize_header(k, v) for k, v in self._headers]
def items(self):
"""Get all the message's header fields and values.
@@ -358,7 +408,7 @@ class Message:
Any fields deleted and re-inserted are always appended to the header
list.
"""
- return self._headers[:]
+ return [(k, _sanitize_header(k, v)) for k, v in self._headers]
def get(self, name, failobj=None):
"""Get a header value.
@@ -369,7 +419,7 @@ class Message:
name = name.lower()
for k, v in self._headers:
if k.lower() == name:
- return v
+ return _sanitize_header(k, v)
return failobj
#
@@ -389,7 +439,7 @@ class Message:
name = name.lower()
for k, v in self._headers:
if k.lower() == name:
- values.append(v)
+ values.append(_sanitize_header(k, v))
if not values:
return failobj
return values
diff --git a/Lib/email/parser.py b/Lib/email/parser.py
index 06014e2b2e..6caaff53ad 100644
--- a/Lib/email/parser.py
+++ b/Lib/email/parser.py
@@ -7,7 +7,7 @@
__all__ = ['Parser', 'HeaderParser']
import warnings
-from io import StringIO
+from io import StringIO, TextIOWrapper
from email.feedparser import FeedParser
from email.message import Message
@@ -89,3 +89,48 @@ class HeaderParser(Parser):
def parsestr(self, text, headersonly=True):
return Parser.parsestr(self, text, True)
+
+
+class BytesParser:
+
+ def __init__(self, *args, **kw):
+ """Parser of binary RFC 2822 and MIME email messages.
+
+ Creates an in-memory object tree representing the email message, which
+ can then be manipulated and turned over to a Generator to return the
+ textual representation of the message.
+
+ The input must be formatted as a block of RFC 2822 headers and header
+ continuation lines, optionally preceeded by a `Unix-from' header. The
+ header block is terminated either by the end of the input or by a
+ blank line.
+
+ _class is the class to instantiate for new message objects when they
+ must be created. This class must have a constructor that can take
+ zero arguments. Default is Message.Message.
+ """
+ self.parser = Parser(*args, **kw)
+
+ def parse(self, fp, headersonly=False):
+ """Create a message structure from the data in a binary file.
+
+ Reads all the data from the file and returns the root of the message
+ structure. Optional headersonly is a flag specifying whether to stop
+ parsing after reading the headers or not. The default is False,
+ meaning it parses the entire contents of the file.
+ """
+ fp = TextIOWrapper(fp, encoding='ascii', errors='surrogateescape')
+ with fp:
+ return self.parser.parse(fp, headersonly)
+
+
+ def parsebytes(self, text, headersonly=False):
+ """Create a message structure from a byte string.
+
+ Returns the root of the message structure. Optional headersonly is a
+ flag specifying whether to stop parsing after reading the headers or
+ not. The default is False, meaning it parses the entire contents of
+ the file.
+ """
+ text = text.decode('ASCII', errors='surrogateescape')
+ return self.parser.parsestr(text, headersonly)
diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py
index 85efc088aa..168dfffa47 100644
--- a/Lib/email/quoprimime.py
+++ b/Lib/email/quoprimime.py
@@ -11,7 +11,7 @@ character set, but that includes some 8-bit characters that are normally not
allowed in email bodies or headers.
Quoted-printable is very space-inefficient for encoding binary files; use the
-email.base64MIME module for that instead.
+email.base64mime module for that instead.
This module provides an interface to encode and decode both headers and bodies
with quoted-printable encoding.
@@ -23,7 +23,7 @@ in To:/From:/Cc: etc. fields, as well as Subject: lines.
This module does not do the line wrapping or end-of-line character
conversion necessary for proper internationalized headers; it only
does dumb encoding and decoding. To deal with the various line
-wrapping issues, use the email.Header module.
+wrapping issues, use the email.header module.
"""
__all__ = [
@@ -291,7 +291,7 @@ def header_decode(s):
This function does not parse a full MIME header value encoded with
quoted-printable (like =?iso-8895-1?q?Hello_World?=) -- please use
- the high level email.Header class for that functionality.
+ the high level email.header class for that functionality.
"""
s = s.replace('_', ' ')
return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s, re.ASCII)
diff --git a/Lib/email/test/data/msg_10.txt b/Lib/email/test/data/msg_10.txt
index bd30d13ad1..07903960f9 100644
--- a/Lib/email/test/data/msg_10.txt
+++ b/Lib/email/test/data/msg_10.txt
@@ -26,6 +26,13 @@ VGhpcyBpcyBhIEJhc2U2NCBlbmNvZGVkIG1lc3NhZ2Uu
--BOUNDARY
Content-Type: text/plain; charset="iso-8859-1"
+Content-Transfer-Encoding: Base64
+
+VGhpcyBpcyBhIEJhc2U2NCBlbmNvZGVkIG1lc3NhZ2UuCg==
+
+
+--BOUNDARY
+Content-Type: text/plain; charset="iso-8859-1"
This has no Content-Transfer-Encoding: header.
diff --git a/Lib/email/test/data/msg_26.txt b/Lib/email/test/data/msg_26.txt
index 6c71bced9a..58efaa9c9a 100644
--- a/Lib/email/test/data/msg_26.txt
+++ b/Lib/email/test/data/msg_26.txt
@@ -24,7 +24,8 @@ Simple email with attachment.
--1618492860--2051301190--113853680
-Content-Type: application/riscos; name="clock.bmp,69c"; type=BMP; load=&fff69c4b; exec=&355dd4d1; access=&03
+Content-Type: application/riscos; name="clock.bmp,69c"; type=BMP;
+ load=&fff69c4b; exec=&355dd4d1; access=&03
Content-Disposition: attachment; filename="clock.bmp"
Content-Transfer-Encoding: base64
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 4268a25996..dcb2e95493 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -3,6 +3,7 @@
# email package unit tests
import os
+import re
import sys
import time
import base64
@@ -11,7 +12,7 @@ import unittest
import warnings
import textwrap
-from io import StringIO
+from io import StringIO, BytesIO
from itertools import chain
import email
@@ -35,7 +36,7 @@ from email import iterators
from email import base64mime
from email import quoprimime
-from test.support import findfile, run_unittest
+from test.support import findfile, run_unittest, unlink
from email.test import __file__ as landmark
@@ -193,8 +194,8 @@ class TestMessageAPI(TestEmailBase):
def test_message_rfc822_only(self):
# Issue 7970: message/rfc822 not in multipart parsed by
# HeaderParser caused an exception when flattened.
- fp = openfile(findfile('msg_46.txt'))
- msgdata = fp.read()
+ with openfile(findfile('msg_46.txt')) as fp:
+ msgdata = fp.read()
parser = HeaderParser()
msg = parser.parsestr(msgdata)
out = StringIO()
@@ -216,8 +217,12 @@ class TestMessageAPI(TestEmailBase):
# Subpart 3 is base64
eq(msg.get_payload(2).get_payload(decode=True),
b'This is a Base64 encoded message.')
- # Subpart 4 has no Content-Transfer-Encoding: header.
+ # Subpart 4 is base64 with a trailing newline, which
+ # used to be stripped (issue 7143).
eq(msg.get_payload(3).get_payload(decode=True),
+ b'This is a Base64 encoded message.\n')
+ # Subpart 5 has no Content-Transfer-Encoding: header.
+ eq(msg.get_payload(4).get_payload(decode=True),
b'This has no Content-Transfer-Encoding: header.\n')
def test_get_decoded_uu_payload(self):
@@ -529,7 +534,7 @@ class TestMessageAPI(TestEmailBase):
msg.add_header('Content-Disposition', 'attachment',
filename="Fußballer.ppt")
self.assertEqual(
- 'attachment; filename*="utf-8\'\'Fu%C3%9Fballer.ppt"',
+ 'attachment; filename*=utf-8\'\'Fu%C3%9Fballer.ppt',
msg['Content-Disposition'])
def test_nonascii_add_header_via_triple(self):
@@ -537,9 +542,24 @@ class TestMessageAPI(TestEmailBase):
msg.add_header('Content-Disposition', 'attachment',
filename=('iso-8859-1', '', 'Fußballer.ppt'))
self.assertEqual(
- 'attachment; filename*="iso-8859-1\'\'Fu%DFballer.ppt"',
+ 'attachment; filename*=iso-8859-1\'\'Fu%DFballer.ppt',
msg['Content-Disposition'])
+ def test_ascii_add_header_with_tspecial(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename="windows [filename].ppt")
+ self.assertEqual(
+ 'attachment; filename="windows [filename].ppt"',
+ msg['Content-Disposition'])
+
+ def test_nonascii_add_header_with_tspecial(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename="Fußballer [filename].ppt")
+ self.assertEqual(
+ "attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.ppt",
+ msg['Content-Disposition'])
# Issue 5871: reject an attempt to embed a header inside a header value
# (header injection attack).
@@ -714,6 +734,20 @@ wasnipoop; giraffes="very-long-necked-animals";
wasnipoop; giraffes="very-long-necked-animals";
\tspooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')
+ def test_header_encode_with_different_output_charset(self):
+ h = Header('æ–‡', 'euc-jp')
+ self.assertEqual(h.encode(), "=?iso-2022-jp?b?GyRCSjgbKEI=?=")
+
+ def test_long_header_encode_with_different_output_charset(self):
+ h = Header(b'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4'
+ b'\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4'
+ b'\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4'
+ b'\xa4\xa4\xde\xa4\xb9'.decode('euc-jp'), 'euc-jp')
+ res = """\
+=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKMnE8VCROPjUbKEI=?=
+ =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?="""
+ self.assertEqual(h.encode(), res)
+
def test_header_splitter(self):
eq = self.ndiffAssertEqual
msg = MIMEText('')
@@ -2040,17 +2074,20 @@ message 2
# should be identical. Note: that we ignore the Unix-From since that may
# contain a changed date.
class TestIdempotent(TestEmailBase):
+
+ linesep = '\n'
+
def _msgobj(self, filename):
with openfile(filename) as fp:
data = fp.read()
msg = email.message_from_string(data)
return msg, data
- def _idempotent(self, msg, text):
+ def _idempotent(self, msg, text, unixfrom=False):
eq = self.ndiffAssertEqual
s = StringIO()
g = Generator(s, maxheaderlen=0)
- g.flatten(msg)
+ g.flatten(msg, unixfrom=unixfrom)
eq(text, s.getvalue())
def test_parse_text_message(self):
@@ -2137,6 +2174,14 @@ class TestIdempotent(TestEmailBase):
msg, text = self._msgobj('msg_36.txt')
self._idempotent(msg, text)
+ def test_message_delivery_status(self):
+ msg, text = self._msgobj('msg_43.txt')
+ self._idempotent(msg, text, unixfrom=True)
+
+ def test_message_signed_idempotent(self):
+ msg, text = self._msgobj('msg_45.txt')
+ self._idempotent(msg, text)
+
def test_content_type(self):
eq = self.assertEqual
unless = self.assertTrue
@@ -2149,16 +2194,16 @@ class TestIdempotent(TestEmailBase):
params[pk] = pv
eq(params['report-type'], 'delivery-status')
eq(params['boundary'], 'D1690A7AC1.996856090/mail.example.com')
- eq(msg.preamble, 'This is a MIME-encapsulated message.\n')
- eq(msg.epilogue, '\n')
+ eq(msg.preamble, 'This is a MIME-encapsulated message.' + self.linesep)
+ eq(msg.epilogue, self.linesep)
eq(len(msg.get_payload()), 3)
# Make sure the subparts are what we expect
msg1 = msg.get_payload(0)
eq(msg1.get_content_type(), 'text/plain')
- eq(msg1.get_payload(), 'Yadda yadda yadda\n')
+ eq(msg1.get_payload(), 'Yadda yadda yadda' + self.linesep)
msg2 = msg.get_payload(1)
eq(msg2.get_content_type(), 'text/plain')
- eq(msg2.get_payload(), 'Yadda yadda yadda\n')
+ eq(msg2.get_payload(), 'Yadda yadda yadda' + self.linesep)
msg3 = msg.get_payload(2)
eq(msg3.get_content_type(), 'message/rfc822')
self.assertTrue(isinstance(msg3, Message))
@@ -2167,7 +2212,7 @@ class TestIdempotent(TestEmailBase):
eq(len(payload), 1)
msg4 = payload[0]
unless(isinstance(msg4, Message))
- eq(msg4.get_payload(), 'Yadda yadda yadda\n')
+ eq(msg4.get_payload(), 'Yadda yadda yadda' + self.linesep)
def test_parser(self):
eq = self.assertEqual
@@ -2184,7 +2229,7 @@ class TestIdempotent(TestEmailBase):
self.assertTrue(isinstance(msg1, Message))
eq(msg1.get_content_type(), 'text/plain')
self.assertTrue(isinstance(msg1.get_payload(), str))
- eq(msg1.get_payload(), '\n')
+ eq(msg1.get_payload(), self.linesep)
@@ -2253,7 +2298,8 @@ class TestMiscellaneous(TestEmailBase):
all.sort()
self.assertEqual(all, [
'base64mime', 'charset', 'encoders', 'errors', 'generator',
- 'header', 'iterators', 'message', 'message_from_file',
+ 'header', 'iterators', 'message', 'message_from_binary_file',
+ 'message_from_bytes', 'message_from_file',
'message_from_string', 'mime', 'parser',
'quoprimime', 'utils',
])
@@ -2296,6 +2342,16 @@ class TestMiscellaneous(TestEmailBase):
eq(utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
(2003, 2, 5, 13, 47, 26, 0, 1, -1, -28800))
+ def test_parsedate_no_space_before_positive_offset(self):
+ self.assertEqual(utils.parsedate_tz('Wed, 3 Apr 2002 14:58:26+0800'),
+ (2002, 4, 3, 14, 58, 26, 0, 1, -1, 28800))
+
+ def test_parsedate_no_space_before_negative_offset(self):
+ # Issue 1155362: we already handled '+' for this case.
+ self.assertEqual(utils.parsedate_tz('Wed, 3 Apr 2002 14:58:26-0800'),
+ (2002, 4, 3, 14, 58, 26, 0, 1, -1, -28800))
+
+
def test_parsedate_acceptable_to_time_functions(self):
eq = self.assertEqual
timetup = utils.parsedate('5 Feb 2003 13:47:26 -0800')
@@ -2372,6 +2428,24 @@ class TestMiscellaneous(TestEmailBase):
eq(utils.parseaddr('"\\\\"example\\\\" example"@example.com'),
('', '"\\\\"example\\\\" example"@example.com'))
+ def test_parseaddr_preserves_spaces_in_local_part(self):
+ # issue 9286. A normal RFC5322 local part should not contain any
+ # folding white space, but legacy local parts can (they are a sequence
+ # of atoms, not dotatoms). On the other hand we strip whitespace from
+ # before the @ and around dots, on the assumption that the whitespace
+ # around the punctuation is a mistake in what would otherwise be
+ # an RFC5322 local part. Leading whitespace is, usual, stripped as well.
+ self.assertEqual(('', "merwok wok@xample.com"),
+ utils.parseaddr("merwok wok@xample.com"))
+ self.assertEqual(('', "merwok wok@xample.com"),
+ utils.parseaddr("merwok wok@xample.com"))
+ self.assertEqual(('', "merwok wok@xample.com"),
+ utils.parseaddr(" merwok wok @xample.com"))
+ self.assertEqual(('', 'merwok"wok" wok@xample.com'),
+ utils.parseaddr('merwok"wok" wok@xample.com'))
+ self.assertEqual(('', 'merwok.wok.wok@xample.com'),
+ utils.parseaddr('merwok. wok . wok@xample.com'))
+
def test_multiline_from_comment(self):
x = """\
Foo
@@ -2510,6 +2584,10 @@ multipart/report
text/rfc822-headers
""")
+ def test_make_msgid_domain(self):
+ self.assertEqual(
+ email.utils.make_msgid(domain='testdomain-string')[-19:],
+ '@testdomain-string>')
# Test the iterator/generators
@@ -2661,6 +2739,18 @@ Here's the message body
part2 = msg.get_payload(1)
eq(part2.get_content_type(), 'application/riscos')
+ def test_crlf_flatten(self):
+ # Using newline='\n' preserves the crlfs in this input file.
+ with openfile('msg_26.txt', newline='\n') as fp:
+ text = fp.read()
+ msg = email.message_from_string(text)
+ s = StringIO()
+ g = Generator(s)
+ g.flatten(msg, linesep='\r\n')
+ self.assertEqual(s.getvalue(), text)
+
+ maxDiff = None
+
def test_multipart_digest_with_extra_mime_headers(self):
eq = self.assertEqual
neq = self.ndiffAssertEqual
@@ -2754,6 +2844,318 @@ Here's the message body
self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
+class Test8BitBytesHandling(unittest.TestCase):
+ # In Python3 all input is string, but that doesn't work if the actual input
+ # uses an 8bit transfer encoding. To hack around that, in email 5.1 we
+ # decode byte streams using the surrogateescape error handler, and
+ # reconvert to binary at appropriate places if we detect surrogates. This
+ # doesn't allow us to transform headers with 8bit bytes (they get munged),
+ # but it does allow us to parse and preserve them, and to decode body
+ # parts that use an 8bit CTE.
+
+ bodytest_msg = textwrap.dedent("""\
+ From: foo@bar.com
+ To: baz
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset={charset}
+ Content-Transfer-Encoding: {cte}
+
+ {bodyline}
+ """)
+
+ def test_known_8bit_CTE(self):
+ m = self.bodytest_msg.format(charset='utf-8',
+ cte='8bit',
+ bodyline='pöstal').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(), "pöstal\n")
+ self.assertEqual(msg.get_payload(decode=True),
+ "pöstal\n".encode('utf-8'))
+
+ def test_unknown_8bit_CTE(self):
+ m = self.bodytest_msg.format(charset='notavalidcharset',
+ cte='8bit',
+ bodyline='pöstal').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(), "p\uFFFD\uFFFDstal\n")
+ self.assertEqual(msg.get_payload(decode=True),
+ "pöstal\n".encode('utf-8'))
+
+ def test_8bit_in_quopri_body(self):
+ # This is non-RFC compliant data...without 'decode' the library code
+ # decodes the body using the charset from the headers, and because the
+ # source byte really is utf-8 this works. This is likely to fail
+ # against real dirty data (ie: produce mojibake), but the data is
+ # invalid anyway so it is as good a guess as any. But this means that
+ # this test just confirms the current behavior; that behavior is not
+ # necessarily the best possible behavior. With 'decode' it is
+ # returning the raw bytes, so that test should be of correct behavior,
+ # or at least produce the same result that email4 did.
+ m = self.bodytest_msg.format(charset='utf-8',
+ cte='quoted-printable',
+ bodyline='p=C3=B6stál').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(), 'p=C3=B6stál\n')
+ self.assertEqual(msg.get_payload(decode=True),
+ 'pöstál\n'.encode('utf-8'))
+
+ def test_invalid_8bit_in_non_8bit_cte_uses_replace(self):
+ # This is similar to the previous test, but proves that if the 8bit
+ # byte is undecodeable in the specified charset, it gets replaced
+ # by the unicode 'unknown' character. Again, this may or may not
+ # be the ideal behavior. Note that if decode=False none of the
+ # decoders will get involved, so this is the only test we need
+ # for this behavior.
+ m = self.bodytest_msg.format(charset='ascii',
+ cte='quoted-printable',
+ bodyline='p=C3=B6stál').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(), 'p=C3=B6st\uFFFD\uFFFDl\n')
+ self.assertEqual(msg.get_payload(decode=True),
+ 'pöstál\n'.encode('utf-8'))
+
+ def test_8bit_in_base64_body(self):
+ # Sticking an 8bit byte in a base64 block makes it undecodable by
+ # normal means, so the block is returned undecoded, but as bytes.
+ m = self.bodytest_msg.format(charset='utf-8',
+ cte='base64',
+ bodyline='cMO2c3RhbAá=').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(decode=True),
+ 'cMO2c3RhbAá=\n'.encode('utf-8'))
+
+ def test_8bit_in_uuencode_body(self):
+ # Sticking an 8bit byte in a uuencode block makes it undecodable by
+ # normal means, so the block is returned undecoded, but as bytes.
+ m = self.bodytest_msg.format(charset='utf-8',
+ cte='uuencode',
+ bodyline='<,.V<W1A; á ').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(decode=True),
+ '<,.V<W1A; á \n'.encode('utf-8'))
+
+
+ headertest_headers = (
+ ('From: foo@bar.com', ('From', 'foo@bar.com')),
+ ('To: báz', ('To', '=?unknown-8bit?q?b=C3=A1z?=')),
+ ('Subject: Maintenant je vous présente mon collègue, le pouf célèbre\n'
+ '\tJean de Baddie',
+ ('Subject', '=?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_'
+ 'coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=\n'
+ ' =?unknown-8bit?q?_Jean_de_Baddie?=')),
+ ('From: göst', ('From', '=?unknown-8bit?b?Z8O2c3Q=?=')),
+ )
+ headertest_msg = ('\n'.join([src for (src, _) in headertest_headers]) +
+ '\nYes, they are flying.\n').encode('utf-8')
+
+ def test_get_8bit_header(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertEqual(str(msg.get('to')), 'b\uFFFD\uFFFDz')
+ self.assertEqual(str(msg['to']), 'b\uFFFD\uFFFDz')
+
+ def test_print_8bit_headers(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertEqual(str(msg),
+ textwrap.dedent("""\
+ From: {}
+ To: {}
+ Subject: {}
+ From: {}
+
+ Yes, they are flying.
+ """).format(*[expected[1] for (_, expected) in
+ self.headertest_headers]))
+
+ def test_values_with_8bit_headers(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertListEqual([str(x) for x in msg.values()],
+ ['foo@bar.com',
+ 'b\uFFFD\uFFFDz',
+ 'Maintenant je vous pr\uFFFD\uFFFDsente mon '
+ 'coll\uFFFD\uFFFDgue, le pouf '
+ 'c\uFFFD\uFFFDl\uFFFD\uFFFDbre\n'
+ '\tJean de Baddie',
+ "g\uFFFD\uFFFDst"])
+
+ def test_items_with_8bit_headers(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertListEqual([(str(x), str(y)) for (x, y) in msg.items()],
+ [('From', 'foo@bar.com'),
+ ('To', 'b\uFFFD\uFFFDz'),
+ ('Subject', 'Maintenant je vous '
+ 'pr\uFFFD\uFFFDsente '
+ 'mon coll\uFFFD\uFFFDgue, le pouf '
+ 'c\uFFFD\uFFFDl\uFFFD\uFFFDbre\n'
+ '\tJean de Baddie'),
+ ('From', 'g\uFFFD\uFFFDst')])
+
+ def test_get_all_with_8bit_headers(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertListEqual([str(x) for x in msg.get_all('from')],
+ ['foo@bar.com',
+ 'g\uFFFD\uFFFDst'])
+
+ non_latin_bin_msg = textwrap.dedent("""\
+ From: foo@bar.com
+ To: báz
+ Subject: Maintenant je vous présente mon collègue, le pouf célèbre
+ \tJean de Baddie
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="utf-8"
+ Content-Transfer-Encoding: 8bit
+
+ Да, они летÑÑ‚.
+ """).encode('utf-8')
+
+ def test_bytes_generator(self):
+ msg = email.message_from_bytes(self.non_latin_bin_msg)
+ out = BytesIO()
+ email.generator.BytesGenerator(out).flatten(msg)
+ self.assertEqual(out.getvalue(), self.non_latin_bin_msg)
+
+ def test_bytes_generator_handles_None_body(self):
+ #Issue 11019
+ msg = email.message.Message()
+ out = BytesIO()
+ email.generator.BytesGenerator(out).flatten(msg)
+ self.assertEqual(out.getvalue(), b"\n")
+
+ non_latin_bin_msg_as7bit_wrapped = textwrap.dedent("""\
+ From: foo@bar.com
+ To: =?unknown-8bit?q?b=C3=A1z?=
+ Subject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue?=
+ =?unknown-8bit?q?=2C_le_pouf_c=C3=A9l=C3=A8bre?=
+ =?unknown-8bit?q?_Jean_de_Baddie?=
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="utf-8"
+ Content-Transfer-Encoding: base64
+
+ 0JTQsCwg0L7QvdC4INC70LXRgtGP0YIuCg==
+ """)
+
+ def test_generator_handles_8bit(self):
+ msg = email.message_from_bytes(self.non_latin_bin_msg)
+ out = StringIO()
+ email.generator.Generator(out).flatten(msg)
+ self.assertEqual(out.getvalue(), self.non_latin_bin_msg_as7bit_wrapped)
+
+ def test_bytes_generator_with_unix_from(self):
+ # The unixfrom contains a current date, so we can't check it
+ # literally. Just make sure the first word is 'From' and the
+ # rest of the message matches the input.
+ msg = email.message_from_bytes(self.non_latin_bin_msg)
+ out = BytesIO()
+ email.generator.BytesGenerator(out).flatten(msg, unixfrom=True)
+ lines = out.getvalue().split(b'\n')
+ self.assertEqual(lines[0].split()[0], b'From')
+ self.assertEqual(b'\n'.join(lines[1:]), self.non_latin_bin_msg)
+
+ non_latin_bin_msg_as7bit = non_latin_bin_msg_as7bit_wrapped.split('\n')
+ non_latin_bin_msg_as7bit[2:4] = [
+ 'Subject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_'
+ 'coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=']
+ non_latin_bin_msg_as7bit = '\n'.join(non_latin_bin_msg_as7bit)
+
+ def test_message_from_binary_file(self):
+ fn = 'test.msg'
+ self.addCleanup(unlink, fn)
+ with open(fn, 'wb') as testfile:
+ testfile.write(self.non_latin_bin_msg)
+ with open(fn, 'rb') as testfile:
+ m = email.parser.BytesParser().parse(testfile)
+ self.assertEqual(str(m), self.non_latin_bin_msg_as7bit)
+
+ latin_bin_msg = textwrap.dedent("""\
+ From: foo@bar.com
+ To: Dinsdale
+ Subject: Nudge nudge, wink, wink
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="latin-1"
+ Content-Transfer-Encoding: 8bit
+
+ oh là là, know what I mean, know what I mean?
+ """).encode('latin-1')
+
+ latin_bin_msg_as7bit = textwrap.dedent("""\
+ From: foo@bar.com
+ To: Dinsdale
+ Subject: Nudge nudge, wink, wink
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="iso-8859-1"
+ Content-Transfer-Encoding: quoted-printable
+
+ oh l=E0 l=E0, know what I mean, know what I mean?
+ """)
+
+ def test_string_generator_reencodes_to_quopri_when_appropriate(self):
+ m = email.message_from_bytes(self.latin_bin_msg)
+ self.assertEqual(str(m), self.latin_bin_msg_as7bit)
+
+ def test_decoded_generator_emits_unicode_body(self):
+ m = email.message_from_bytes(self.latin_bin_msg)
+ out = StringIO()
+ email.generator.DecodedGenerator(out).flatten(m)
+ #DecodedHeader output contains an extra blank line compared
+ #to the input message. RDM: not sure if this is a bug or not,
+ #but it is not specific to the 8bit->7bit conversion.
+ self.assertEqual(out.getvalue(),
+ self.latin_bin_msg.decode('latin-1')+'\n')
+
+ def test_bytes_feedparser(self):
+ bfp = email.feedparser.BytesFeedParser()
+ for i in range(0, len(self.latin_bin_msg), 10):
+ bfp.feed(self.latin_bin_msg[i:i+10])
+ m = bfp.close()
+ self.assertEqual(str(m), self.latin_bin_msg_as7bit)
+
+ def test_crlf_flatten(self):
+ with openfile('msg_26.txt', 'rb') as fp:
+ text = fp.read()
+ msg = email.message_from_bytes(text)
+ s = BytesIO()
+ g = email.generator.BytesGenerator(s)
+ g.flatten(msg, linesep='\r\n')
+ self.assertEqual(s.getvalue(), text)
+ maxDiff = None
+
+
+class BaseTestBytesGeneratorIdempotent:
+
+ maxDiff = None
+
+ def _msgobj(self, filename):
+ with openfile(filename, 'rb') as fp:
+ data = fp.read()
+ data = self.normalize_linesep_regex.sub(self.blinesep, data)
+ msg = email.message_from_bytes(data)
+ return msg, data
+
+ def _idempotent(self, msg, data, unixfrom=False):
+ b = BytesIO()
+ g = email.generator.BytesGenerator(b, maxheaderlen=0)
+ g.flatten(msg, unixfrom=unixfrom, linesep=self.linesep)
+ self.assertByteStringsEqual(data, b.getvalue())
+
+ def assertByteStringsEqual(self, str1, str2):
+ # Not using self.blinesep here is intentional. This way the output
+ # is more useful when the failure results in mixed line endings.
+ self.assertListEqual(str1.split(b'\n'), str2.split(b'\n'))
+
+
+class TestBytesGeneratorIdempotentNL(BaseTestBytesGeneratorIdempotent,
+ TestIdempotent):
+ linesep = '\n'
+ blinesep = b'\n'
+ normalize_linesep_regex = re.compile(br'\r\n')
+
+
+class TestBytesGeneratorIdempotentCRLF(BaseTestBytesGeneratorIdempotent,
+ TestIdempotent):
+ linesep = '\r\n'
+ blinesep = b'\r\n'
+ normalize_linesep_regex = re.compile(br'(?<!\r)\n')
+
+
class TestBase64(unittest.TestCase):
def test_len(self):
eq = self.assertEqual
@@ -2973,9 +3375,9 @@ class TestCharset(unittest.TestCase):
# built-in encodings where the header encoding is QP but the body
# encoding is not.
from email import charset as CharsetModule
- CharsetModule.add_charset('fake', CharsetModule.QP, None)
+ CharsetModule.add_charset('fake', CharsetModule.QP, None, 'utf-8')
c = Charset('fake')
- eq('hello w\xf6rld', c.body_encode('hello w\xf6rld'))
+ eq('hello world', c.body_encode('hello world'))
def test_unicode_charset_name(self):
charset = Charset('us-ascii')
@@ -3342,7 +3744,7 @@ To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset=us-ascii;
- title*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21"
+ title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21
Hi,
@@ -3372,7 +3774,7 @@ To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset="us-ascii";
- title*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21"
+ title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21
Hi,
@@ -3387,6 +3789,32 @@ Do you like this message?
msg = self._msgobj('msg_32.txt')
eq(msg.get_content_charset(), 'us-ascii')
+ def test_rfc2231_parse_rfc_quoting(self):
+ m = textwrap.dedent('''\
+ Content-Disposition: inline;
+ \tfilename*0*=''This%20is%20even%20more%20;
+ \tfilename*1*=%2A%2A%2Afun%2A%2A%2A%20;
+ \tfilename*2="is it not.pdf"
+
+ ''')
+ msg = email.message_from_string(m)
+ self.assertEqual(msg.get_filename(),
+ 'This is even more ***fun*** is it not.pdf')
+ self.assertEqual(m, msg.as_string())
+
+ def test_rfc2231_parse_extra_quoting(self):
+ m = textwrap.dedent('''\
+ Content-Disposition: inline;
+ \tfilename*0*="''This%20is%20even%20more%20";
+ \tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+ \tfilename*2="is it not.pdf"
+
+ ''')
+ msg = email.message_from_string(m)
+ self.assertEqual(msg.get_filename(),
+ 'This is even more ***fun*** is it not.pdf')
+ self.assertEqual(m, msg.as_string())
+
def test_rfc2231_no_language_or_charset(self):
m = '''\
Content-Transfer-Encoding: 8bit
diff --git a/Lib/email/test/test_email_codecs.py b/Lib/email/test/test_email_codecs.py
index acc19c30f9..ca85f5731e 100644
--- a/Lib/email/test/test_email_codecs.py
+++ b/Lib/email/test/test_email_codecs.py
@@ -13,7 +13,7 @@ from email.message import Message
# We're compatible with Python 2.3, but it doesn't have the built-in Asian
# codecs, so we have to skip all these tests.
try:
- str('foo', 'euc-jp')
+ str(b'foo', 'euc-jp')
except LookupError:
raise unittest.SkipTest
@@ -22,11 +22,14 @@ except LookupError:
class TestEmailAsianCodecs(TestEmailBase):
def test_japanese_codecs(self):
eq = self.ndiffAssertEqual
- j = Charset("euc-jp")
- g = Charset("iso-8859-1")
+ jcode = "euc-jp"
+ gcode = "iso-8859-1"
+ j = Charset(jcode)
+ g = Charset(gcode)
h = Header("Hello World!")
- jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa'
- ghello = 'Gr\xfc\xdf Gott!'
+ jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
+ b'\xa5\xeb\xa5\xc9\xa1\xaa', jcode)
+ ghello = str(b'Gr\xfc\xdf Gott!', gcode)
h.append(jhello, j)
h.append(ghello, g)
# BAW: This used to -- and maybe should -- fold the two iso-8859-1
@@ -36,13 +39,17 @@ class TestEmailAsianCodecs(TestEmailBase):
# encoded word.
eq(h.encode(), """\
Hello World! =?iso-2022-jp?b?GyRCJU8lbSE8JW8hPCVrJUkhKhsoQg==?=
- =?iso-8859-1?q?Gr=FC=DF?= =?iso-8859-1?q?_Gott!?=""")
+ =?iso-8859-1?q?Gr=FC=DF_Gott!?=""")
eq(decode_header(h.encode()),
- [('Hello World!', None),
- ('\x1b$B%O%m!<%o!<%k%I!*\x1b(B', 'iso-2022-jp'),
- ('Gr\xfc\xdf Gott!', 'iso-8859-1')])
- int = 'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9'
- h = Header(int, j, header_name="Subject")
+ [(b'Hello World!', None),
+ (b'\x1b$B%O%m!<%o!<%k%I!*\x1b(B', 'iso-2022-jp'),
+ (b'Gr\xfc\xdf Gott!', gcode)])
+ subject_bytes = (b'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5'
+ b'\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2'
+ b'\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3'
+ b'\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9')
+ subject = str(subject_bytes, jcode)
+ h = Header(subject, j, header_name="Subject")
# test a very long header
enc = h.encode()
# TK: splitting point may differ by codec design and/or Header encoding
@@ -50,15 +57,24 @@ Hello World! =?iso-2022-jp?b?GyRCJU8lbSE8JW8hPCVrJUkhKhsoQg==?=
=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKGyhC?=
=?iso-2022-jp?b?GyRCMnE8VCROPjVHJyRyQlQkQyRGJCQkXiQ5GyhC?=""")
# TK: full decode comparison
- eq(h.__unicode__().encode('euc-jp'), int)
+ eq(str(h).encode(jcode), subject_bytes)
+
+ def test_payload_encoding_utf8(self):
+ jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
+ b'\xa5\xeb\xa5\xc9\xa1\xaa', 'euc-jp')
+ msg = Message()
+ msg.set_payload(jhello, 'utf-8')
+ ustr = msg.get_payload(decode=True).decode(msg.get_content_charset())
+ self.assertEqual(jhello, ustr)
def test_payload_encoding(self):
- jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa'
jcode = 'euc-jp'
+ jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
+ b'\xa5\xeb\xa5\xc9\xa1\xaa', jcode)
msg = Message()
msg.set_payload(jhello, jcode)
- ustr = str(msg.get_payload(), msg.get_content_charset())
- self.assertEqual(jhello, ustr.encode(jcode))
+ ustr = msg.get_payload(decode=True).decode(msg.get_content_charset())
+ self.assertEqual(jhello, ustr)
diff --git a/Lib/email/test/test_email_torture.py b/Lib/email/test/test_email_torture.py
index 57233bfdbb..544b1bbb39 100644
--- a/Lib/email/test/test_email_torture.py
+++ b/Lib/email/test/test_email_torture.py
@@ -13,11 +13,11 @@ from io import StringIO
from types import ListType
from email.test.test_email import TestEmailBase
-from test.support import TestSkipped
+from test.support import TestSkipped, run_unittest
import email
from email import __file__ as testfile
-from email.Iterators import _structure
+from email.iterators import _structure
def openfile(filename):
from os.path import join, dirname, abspath
@@ -128,7 +128,7 @@ def suite():
def test_main():
for testclass in _testclasses():
- support.run_unittest(testclass)
+ run_unittest(testclass)
diff --git a/Lib/email/utils.py b/Lib/email/utils.py
index 5f40bac174..ac4da3705f 100644
--- a/Lib/email/utils.py
+++ b/Lib/email/utils.py
@@ -148,13 +148,15 @@ def formatdate(timeval=None, localtime=False, usegmt=False):
-def make_msgid(idstring=None):
+def make_msgid(idstring=None, domain=None):
"""Returns a string suitable for RFC 2822 compliant Message-ID, e.g:
<20020201195627.33539.96671@nightshade.la.mastaler.com>
Optional idstring if given is a string used to strengthen the
- uniqueness of the message id.
+ uniqueness of the message id. Optional domain if given provides the
+ portion of the message id after the '@'. It defaults to the locally
+ defined hostname.
"""
timeval = time.time()
utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval))
@@ -164,8 +166,9 @@ def make_msgid(idstring=None):
idstring = ''
else:
idstring = '.' + idstring
- idhost = socket.getfqdn()
- msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, idhost)
+ if domain is None:
+ domain = socket.getfqdn()
+ msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, domain)
return msgid
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
index d72eae9328..b189bd9793 100644
--- a/Lib/encodings/__init__.py
+++ b/Lib/encodings/__init__.py
@@ -10,7 +10,7 @@
Each codec module must export the following interface:
* getregentry() -> codecs.CodecInfo object
- The getregentry() API must a CodecInfo object with encoder, decoder,
+ The getregentry() API must return a CodecInfo object with encoder, decoder,
incrementalencoder, incrementaldecoder, streamwriter and streamreader
atttributes which adhere to the Python Codec Interface Standard.
diff --git a/Lib/encodings/aliases.py b/Lib/encodings/aliases.py
index 4c35588c88..235deb5c30 100644
--- a/Lib/encodings/aliases.py
+++ b/Lib/encodings/aliases.py
@@ -146,6 +146,11 @@ aliases = {
'csibm857' : 'cp857',
'ibm857' : 'cp857',
+ # cp858 codec
+ '858' : 'cp858',
+ 'csibm858' : 'cp858',
+ 'ibm858' : 'cp858',
+
# cp860 codec
'860' : 'cp860',
'csibm860' : 'cp860',
@@ -430,6 +435,7 @@ aliases = {
'maclatin2' : 'mac_latin2',
# mac_roman codec
+ 'macintosh' : 'mac_roman',
'macroman' : 'mac_roman',
# mac_turkish codec
@@ -442,7 +448,7 @@ aliases = {
'csptcp154' : 'ptcp154',
'pt154' : 'ptcp154',
'cp154' : 'ptcp154',
- 'cyrillic-asian' : 'ptcp154',
+ 'cyrillic_asian' : 'ptcp154',
## quopri_codec codec
#'quopri' : 'quopri_codec',
diff --git a/Lib/encodings/base64_codec.py b/Lib/encodings/base64_codec.py
new file mode 100644
index 0000000000..321a961782
--- /dev/null
+++ b/Lib/encodings/base64_codec.py
@@ -0,0 +1,55 @@
+"""Python 'base64_codec' Codec - base64 content transfer encoding.
+
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+
+Written by Marc-Andre Lemburg (mal@lemburg.com).
+"""
+
+import codecs
+import base64
+
+### Codec APIs
+
+def base64_encode(input, errors='strict'):
+ assert errors == 'strict'
+ return (base64.encodebytes(input), len(input))
+
+def base64_decode(input, errors='strict'):
+ assert errors == 'strict'
+ return (base64.decodebytes(input), len(input))
+
+class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return base64_encode(input, errors)
+ def decode(self, input, errors='strict'):
+ return base64_decode(input, errors)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ assert self.errors == 'strict'
+ return base64.encodebytes(input)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def decode(self, input, final=False):
+ assert self.errors == 'strict'
+ return base64.decodebytes(input)
+
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
+
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='base64',
+ encode=base64_encode,
+ decode=base64_decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamwriter=StreamWriter,
+ streamreader=StreamReader,
+ )
diff --git a/Lib/encodings/bz2_codec.py b/Lib/encodings/bz2_codec.py
new file mode 100644
index 0000000000..e65d226bfd
--- /dev/null
+++ b/Lib/encodings/bz2_codec.py
@@ -0,0 +1,77 @@
+"""Python 'bz2_codec' Codec - bz2 compression encoding.
+
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+
+Adapted by Raymond Hettinger from zlib_codec.py which was written
+by Marc-Andre Lemburg (mal@lemburg.com).
+"""
+
+import codecs
+import bz2 # this codec needs the optional bz2 module !
+
+### Codec APIs
+
+def bz2_encode(input, errors='strict'):
+ assert errors == 'strict'
+ return (bz2.compress(input), len(input))
+
+def bz2_decode(input, errors='strict'):
+ assert errors == 'strict'
+ return (bz2.decompress(input), len(input))
+
+class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return bz2_encode(input, errors)
+ def decode(self, input, errors='strict'):
+ return bz2_decode(input, errors)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def __init__(self, errors='strict'):
+ assert errors == 'strict'
+ self.errors = errors
+ self.compressobj = bz2.BZ2Compressor()
+
+ def encode(self, input, final=False):
+ if final:
+ c = self.compressobj.compress(input)
+ return c + self.compressobj.flush()
+ else:
+ return self.compressobj.compress(input)
+
+ def reset(self):
+ self.compressobj = bz2.BZ2Compressor()
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def __init__(self, errors='strict'):
+ assert errors == 'strict'
+ self.errors = errors
+ self.decompressobj = bz2.BZ2Decompressor()
+
+ def decode(self, input, final=False):
+ try:
+ return self.decompressobj.decompress(input)
+ except EOFError:
+ return ''
+
+ def reset(self):
+ self.decompressobj = bz2.BZ2Decompressor()
+
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
+
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name="bz2",
+ encode=bz2_encode,
+ decode=bz2_decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamwriter=StreamWriter,
+ streamreader=StreamReader,
+ )
diff --git a/Lib/encodings/cp720.py b/Lib/encodings/cp720.py
new file mode 100644
index 0000000000..96d609616c
--- /dev/null
+++ b/Lib/encodings/cp720.py
@@ -0,0 +1,309 @@
+"""Python Character Mapping Codec cp720 generated on Windows:
+Vista 6.0.6002 SP2 Multiprocessor Free with the command:
+ python Tools/unicode/genwincodec.py 720
+"""#"
+
+
+import codecs
+
+### Codec APIs
+
+class Codec(codecs.Codec):
+
+ def encode(self,input,errors='strict'):
+ return codecs.charmap_encode(input,errors,encoding_table)
+
+ def decode(self,input,errors='strict'):
+ return codecs.charmap_decode(input,errors,decoding_table)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ return codecs.charmap_encode(input,self.errors,encoding_table)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def decode(self, input, final=False):
+ return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
+class StreamWriter(Codec,codecs.StreamWriter):
+ pass
+
+class StreamReader(Codec,codecs.StreamReader):
+ pass
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='cp720',
+ encode=Codec().encode,
+ decode=Codec().decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamreader=StreamReader,
+ streamwriter=StreamWriter,
+ )
+
+
+### Decoding Table
+
+decoding_table = (
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\x80'
+ '\x81'
+ '\xe9' # 0x82 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x83 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\x84'
+ '\xe0' # 0x85 -> LATIN SMALL LETTER A WITH GRAVE
+ '\x86'
+ '\xe7' # 0x87 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x88 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x89 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x8A -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x8B -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x8C -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\x8d'
+ '\x8e'
+ '\x8f'
+ '\x90'
+ '\u0651' # 0x91 -> ARABIC SHADDA
+ '\u0652' # 0x92 -> ARABIC SUKUN
+ '\xf4' # 0x93 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xa4' # 0x94 -> CURRENCY SIGN
+ '\u0640' # 0x95 -> ARABIC TATWEEL
+ '\xfb' # 0x96 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x97 -> LATIN SMALL LETTER U WITH GRAVE
+ '\u0621' # 0x98 -> ARABIC LETTER HAMZA
+ '\u0622' # 0x99 -> ARABIC LETTER ALEF WITH MADDA ABOVE
+ '\u0623' # 0x9A -> ARABIC LETTER ALEF WITH HAMZA ABOVE
+ '\u0624' # 0x9B -> ARABIC LETTER WAW WITH HAMZA ABOVE
+ '\xa3' # 0x9C -> POUND SIGN
+ '\u0625' # 0x9D -> ARABIC LETTER ALEF WITH HAMZA BELOW
+ '\u0626' # 0x9E -> ARABIC LETTER YEH WITH HAMZA ABOVE
+ '\u0627' # 0x9F -> ARABIC LETTER ALEF
+ '\u0628' # 0xA0 -> ARABIC LETTER BEH
+ '\u0629' # 0xA1 -> ARABIC LETTER TEH MARBUTA
+ '\u062a' # 0xA2 -> ARABIC LETTER TEH
+ '\u062b' # 0xA3 -> ARABIC LETTER THEH
+ '\u062c' # 0xA4 -> ARABIC LETTER JEEM
+ '\u062d' # 0xA5 -> ARABIC LETTER HAH
+ '\u062e' # 0xA6 -> ARABIC LETTER KHAH
+ '\u062f' # 0xA7 -> ARABIC LETTER DAL
+ '\u0630' # 0xA8 -> ARABIC LETTER THAL
+ '\u0631' # 0xA9 -> ARABIC LETTER REH
+ '\u0632' # 0xAA -> ARABIC LETTER ZAIN
+ '\u0633' # 0xAB -> ARABIC LETTER SEEN
+ '\u0634' # 0xAC -> ARABIC LETTER SHEEN
+ '\u0635' # 0xAD -> ARABIC LETTER SAD
+ '\xab' # 0xAE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xAF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0xB0 -> LIGHT SHADE
+ '\u2592' # 0xB1 -> MEDIUM SHADE
+ '\u2593' # 0xB2 -> DARK SHADE
+ '\u2502' # 0xB3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0xB4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0xB5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0xB6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0xB7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0xB8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0xB9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0xBA -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0xBB -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0xBC -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0xBD -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0xBE -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0xBF -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0xC0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0xC1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0xC2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0xC3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0xC4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0xC5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0xC6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0xC7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0xC8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0xC9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0xCA -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0xCB -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0xCC -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0xCD -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0xCE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0xCF -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0xD0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0xD1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0xD2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0xD3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0xD4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0xD5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0xD6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0xD7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0xD8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0xD9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0xDA -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0xDB -> FULL BLOCK
+ '\u2584' # 0xDC -> LOWER HALF BLOCK
+ '\u258c' # 0xDD -> LEFT HALF BLOCK
+ '\u2590' # 0xDE -> RIGHT HALF BLOCK
+ '\u2580' # 0xDF -> UPPER HALF BLOCK
+ '\u0636' # 0xE0 -> ARABIC LETTER DAD
+ '\u0637' # 0xE1 -> ARABIC LETTER TAH
+ '\u0638' # 0xE2 -> ARABIC LETTER ZAH
+ '\u0639' # 0xE3 -> ARABIC LETTER AIN
+ '\u063a' # 0xE4 -> ARABIC LETTER GHAIN
+ '\u0641' # 0xE5 -> ARABIC LETTER FEH
+ '\xb5' # 0xE6 -> MICRO SIGN
+ '\u0642' # 0xE7 -> ARABIC LETTER QAF
+ '\u0643' # 0xE8 -> ARABIC LETTER KAF
+ '\u0644' # 0xE9 -> ARABIC LETTER LAM
+ '\u0645' # 0xEA -> ARABIC LETTER MEEM
+ '\u0646' # 0xEB -> ARABIC LETTER NOON
+ '\u0647' # 0xEC -> ARABIC LETTER HEH
+ '\u0648' # 0xED -> ARABIC LETTER WAW
+ '\u0649' # 0xEE -> ARABIC LETTER ALEF MAKSURA
+ '\u064a' # 0xEF -> ARABIC LETTER YEH
+ '\u2261' # 0xF0 -> IDENTICAL TO
+ '\u064b' # 0xF1 -> ARABIC FATHATAN
+ '\u064c' # 0xF2 -> ARABIC DAMMATAN
+ '\u064d' # 0xF3 -> ARABIC KASRATAN
+ '\u064e' # 0xF4 -> ARABIC FATHA
+ '\u064f' # 0xF5 -> ARABIC DAMMA
+ '\u0650' # 0xF6 -> ARABIC KASRA
+ '\u2248' # 0xF7 -> ALMOST EQUAL TO
+ '\xb0' # 0xF8 -> DEGREE SIGN
+ '\u2219' # 0xF9 -> BULLET OPERATOR
+ '\xb7' # 0xFA -> MIDDLE DOT
+ '\u221a' # 0xFB -> SQUARE ROOT
+ '\u207f' # 0xFC -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0xFD -> SUPERSCRIPT TWO
+ '\u25a0' # 0xFE -> BLACK SQUARE
+ '\xa0' # 0xFF -> NO-BREAK SPACE
+)
+
+### Encoding table
+encoding_table=codecs.charmap_build(decoding_table)
diff --git a/Lib/encodings/cp858.py b/Lib/encodings/cp858.py
new file mode 100644
index 0000000000..7579f52538
--- /dev/null
+++ b/Lib/encodings/cp858.py
@@ -0,0 +1,698 @@
+""" Python Character Mapping Codec for CP858, modified from cp850.
+
+"""
+
+import codecs
+
+### Codec APIs
+
+class Codec(codecs.Codec):
+
+ def encode(self,input,errors='strict'):
+ return codecs.charmap_encode(input,errors,encoding_map)
+
+ def decode(self,input,errors='strict'):
+ return codecs.charmap_decode(input,errors,decoding_table)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def decode(self, input, final=False):
+ return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
+class StreamWriter(Codec,codecs.StreamWriter):
+ pass
+
+class StreamReader(Codec,codecs.StreamReader):
+ pass
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='cp858',
+ encode=Codec().encode,
+ decode=Codec().decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamreader=StreamReader,
+ streamwriter=StreamWriter,
+ )
+
+### Decoding Map
+
+decoding_map = codecs.make_identity_dict(range(256))
+decoding_map.update({
+ 0x0080: 0x00c7, # LATIN CAPITAL LETTER C WITH CEDILLA
+ 0x0081: 0x00fc, # LATIN SMALL LETTER U WITH DIAERESIS
+ 0x0082: 0x00e9, # LATIN SMALL LETTER E WITH ACUTE
+ 0x0083: 0x00e2, # LATIN SMALL LETTER A WITH CIRCUMFLEX
+ 0x0084: 0x00e4, # LATIN SMALL LETTER A WITH DIAERESIS
+ 0x0085: 0x00e0, # LATIN SMALL LETTER A WITH GRAVE
+ 0x0086: 0x00e5, # LATIN SMALL LETTER A WITH RING ABOVE
+ 0x0087: 0x00e7, # LATIN SMALL LETTER C WITH CEDILLA
+ 0x0088: 0x00ea, # LATIN SMALL LETTER E WITH CIRCUMFLEX
+ 0x0089: 0x00eb, # LATIN SMALL LETTER E WITH DIAERESIS
+ 0x008a: 0x00e8, # LATIN SMALL LETTER E WITH GRAVE
+ 0x008b: 0x00ef, # LATIN SMALL LETTER I WITH DIAERESIS
+ 0x008c: 0x00ee, # LATIN SMALL LETTER I WITH CIRCUMFLEX
+ 0x008d: 0x00ec, # LATIN SMALL LETTER I WITH GRAVE
+ 0x008e: 0x00c4, # LATIN CAPITAL LETTER A WITH DIAERESIS
+ 0x008f: 0x00c5, # LATIN CAPITAL LETTER A WITH RING ABOVE
+ 0x0090: 0x00c9, # LATIN CAPITAL LETTER E WITH ACUTE
+ 0x0091: 0x00e6, # LATIN SMALL LIGATURE AE
+ 0x0092: 0x00c6, # LATIN CAPITAL LIGATURE AE
+ 0x0093: 0x00f4, # LATIN SMALL LETTER O WITH CIRCUMFLEX
+ 0x0094: 0x00f6, # LATIN SMALL LETTER O WITH DIAERESIS
+ 0x0095: 0x00f2, # LATIN SMALL LETTER O WITH GRAVE
+ 0x0096: 0x00fb, # LATIN SMALL LETTER U WITH CIRCUMFLEX
+ 0x0097: 0x00f9, # LATIN SMALL LETTER U WITH GRAVE
+ 0x0098: 0x00ff, # LATIN SMALL LETTER Y WITH DIAERESIS
+ 0x0099: 0x00d6, # LATIN CAPITAL LETTER O WITH DIAERESIS
+ 0x009a: 0x00dc, # LATIN CAPITAL LETTER U WITH DIAERESIS
+ 0x009b: 0x00f8, # LATIN SMALL LETTER O WITH STROKE
+ 0x009c: 0x00a3, # POUND SIGN
+ 0x009d: 0x00d8, # LATIN CAPITAL LETTER O WITH STROKE
+ 0x009e: 0x00d7, # MULTIPLICATION SIGN
+ 0x009f: 0x0192, # LATIN SMALL LETTER F WITH HOOK
+ 0x00a0: 0x00e1, # LATIN SMALL LETTER A WITH ACUTE
+ 0x00a1: 0x00ed, # LATIN SMALL LETTER I WITH ACUTE
+ 0x00a2: 0x00f3, # LATIN SMALL LETTER O WITH ACUTE
+ 0x00a3: 0x00fa, # LATIN SMALL LETTER U WITH ACUTE
+ 0x00a4: 0x00f1, # LATIN SMALL LETTER N WITH TILDE
+ 0x00a5: 0x00d1, # LATIN CAPITAL LETTER N WITH TILDE
+ 0x00a6: 0x00aa, # FEMININE ORDINAL INDICATOR
+ 0x00a7: 0x00ba, # MASCULINE ORDINAL INDICATOR
+ 0x00a8: 0x00bf, # INVERTED QUESTION MARK
+ 0x00a9: 0x00ae, # REGISTERED SIGN
+ 0x00aa: 0x00ac, # NOT SIGN
+ 0x00ab: 0x00bd, # VULGAR FRACTION ONE HALF
+ 0x00ac: 0x00bc, # VULGAR FRACTION ONE QUARTER
+ 0x00ad: 0x00a1, # INVERTED EXCLAMATION MARK
+ 0x00ae: 0x00ab, # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ 0x00af: 0x00bb, # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ 0x00b0: 0x2591, # LIGHT SHADE
+ 0x00b1: 0x2592, # MEDIUM SHADE
+ 0x00b2: 0x2593, # DARK SHADE
+ 0x00b3: 0x2502, # BOX DRAWINGS LIGHT VERTICAL
+ 0x00b4: 0x2524, # BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ 0x00b5: 0x00c1, # LATIN CAPITAL LETTER A WITH ACUTE
+ 0x00b6: 0x00c2, # LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ 0x00b7: 0x00c0, # LATIN CAPITAL LETTER A WITH GRAVE
+ 0x00b8: 0x00a9, # COPYRIGHT SIGN
+ 0x00b9: 0x2563, # BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ 0x00ba: 0x2551, # BOX DRAWINGS DOUBLE VERTICAL
+ 0x00bb: 0x2557, # BOX DRAWINGS DOUBLE DOWN AND LEFT
+ 0x00bc: 0x255d, # BOX DRAWINGS DOUBLE UP AND LEFT
+ 0x00bd: 0x00a2, # CENT SIGN
+ 0x00be: 0x00a5, # YEN SIGN
+ 0x00bf: 0x2510, # BOX DRAWINGS LIGHT DOWN AND LEFT
+ 0x00c0: 0x2514, # BOX DRAWINGS LIGHT UP AND RIGHT
+ 0x00c1: 0x2534, # BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ 0x00c2: 0x252c, # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ 0x00c3: 0x251c, # BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ 0x00c4: 0x2500, # BOX DRAWINGS LIGHT HORIZONTAL
+ 0x00c5: 0x253c, # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ 0x00c6: 0x00e3, # LATIN SMALL LETTER A WITH TILDE
+ 0x00c7: 0x00c3, # LATIN CAPITAL LETTER A WITH TILDE
+ 0x00c8: 0x255a, # BOX DRAWINGS DOUBLE UP AND RIGHT
+ 0x00c9: 0x2554, # BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ 0x00ca: 0x2569, # BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ 0x00cb: 0x2566, # BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ 0x00cc: 0x2560, # BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ 0x00cd: 0x2550, # BOX DRAWINGS DOUBLE HORIZONTAL
+ 0x00ce: 0x256c, # BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ 0x00cf: 0x00a4, # CURRENCY SIGN
+ 0x00d0: 0x00f0, # LATIN SMALL LETTER ETH
+ 0x00d1: 0x00d0, # LATIN CAPITAL LETTER ETH
+ 0x00d2: 0x00ca, # LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ 0x00d3: 0x00cb, # LATIN CAPITAL LETTER E WITH DIAERESIS
+ 0x00d4: 0x00c8, # LATIN CAPITAL LETTER E WITH GRAVE
+ 0x00d5: 0x20ac, # EURO SIGN
+ 0x00d6: 0x00cd, # LATIN CAPITAL LETTER I WITH ACUTE
+ 0x00d7: 0x00ce, # LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ 0x00d8: 0x00cf, # LATIN CAPITAL LETTER I WITH DIAERESIS
+ 0x00d9: 0x2518, # BOX DRAWINGS LIGHT UP AND LEFT
+ 0x00da: 0x250c, # BOX DRAWINGS LIGHT DOWN AND RIGHT
+ 0x00db: 0x2588, # FULL BLOCK
+ 0x00dc: 0x2584, # LOWER HALF BLOCK
+ 0x00dd: 0x00a6, # BROKEN BAR
+ 0x00de: 0x00cc, # LATIN CAPITAL LETTER I WITH GRAVE
+ 0x00df: 0x2580, # UPPER HALF BLOCK
+ 0x00e0: 0x00d3, # LATIN CAPITAL LETTER O WITH ACUTE
+ 0x00e1: 0x00df, # LATIN SMALL LETTER SHARP S
+ 0x00e2: 0x00d4, # LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ 0x00e3: 0x00d2, # LATIN CAPITAL LETTER O WITH GRAVE
+ 0x00e4: 0x00f5, # LATIN SMALL LETTER O WITH TILDE
+ 0x00e5: 0x00d5, # LATIN CAPITAL LETTER O WITH TILDE
+ 0x00e6: 0x00b5, # MICRO SIGN
+ 0x00e7: 0x00fe, # LATIN SMALL LETTER THORN
+ 0x00e8: 0x00de, # LATIN CAPITAL LETTER THORN
+ 0x00e9: 0x00da, # LATIN CAPITAL LETTER U WITH ACUTE
+ 0x00ea: 0x00db, # LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ 0x00eb: 0x00d9, # LATIN CAPITAL LETTER U WITH GRAVE
+ 0x00ec: 0x00fd, # LATIN SMALL LETTER Y WITH ACUTE
+ 0x00ed: 0x00dd, # LATIN CAPITAL LETTER Y WITH ACUTE
+ 0x00ee: 0x00af, # MACRON
+ 0x00ef: 0x00b4, # ACUTE ACCENT
+ 0x00f0: 0x00ad, # SOFT HYPHEN
+ 0x00f1: 0x00b1, # PLUS-MINUS SIGN
+ 0x00f2: 0x2017, # DOUBLE LOW LINE
+ 0x00f3: 0x00be, # VULGAR FRACTION THREE QUARTERS
+ 0x00f4: 0x00b6, # PILCROW SIGN
+ 0x00f5: 0x00a7, # SECTION SIGN
+ 0x00f6: 0x00f7, # DIVISION SIGN
+ 0x00f7: 0x00b8, # CEDILLA
+ 0x00f8: 0x00b0, # DEGREE SIGN
+ 0x00f9: 0x00a8, # DIAERESIS
+ 0x00fa: 0x00b7, # MIDDLE DOT
+ 0x00fb: 0x00b9, # SUPERSCRIPT ONE
+ 0x00fc: 0x00b3, # SUPERSCRIPT THREE
+ 0x00fd: 0x00b2, # SUPERSCRIPT TWO
+ 0x00fe: 0x25a0, # BLACK SQUARE
+ 0x00ff: 0x00a0, # NO-BREAK SPACE
+})
+
+### Decoding Table
+
+decoding_table = (
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
+ '\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd7' # 0x009e -> MULTIPLICATION SIGN
+ '\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
+ '\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\xae' # 0x00a9 -> REGISTERED SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc0' # 0x00b7 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xa9' # 0x00b8 -> COPYRIGHT SIGN
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\xa2' # 0x00bd -> CENT SIGN
+ '\xa5' # 0x00be -> YEN SIGN
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\xe3' # 0x00c6 -> LATIN SMALL LETTER A WITH TILDE
+ '\xc3' # 0x00c7 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa4' # 0x00cf -> CURRENCY SIGN
+ '\xf0' # 0x00d0 -> LATIN SMALL LETTER ETH
+ '\xd0' # 0x00d1 -> LATIN CAPITAL LETTER ETH
+ '\xca' # 0x00d2 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0x00d4 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\u20ac' # 0x00d5 -> EURO SIGN
+ '\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0x00d8 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\xa6' # 0x00dd -> BROKEN BAR
+ '\xcc' # 0x00de -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd2' # 0x00e3 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
+ '\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\xfe' # 0x00e7 -> LATIN SMALL LETTER THORN
+ '\xde' # 0x00e8 -> LATIN CAPITAL LETTER THORN
+ '\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0x00ea -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0x00eb -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xfd' # 0x00ec -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xdd' # 0x00ed -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xaf' # 0x00ee -> MACRON
+ '\xb4' # 0x00ef -> ACUTE ACCENT
+ '\xad' # 0x00f0 -> SOFT HYPHEN
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2017' # 0x00f2 -> DOUBLE LOW LINE
+ '\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
+ '\xb6' # 0x00f4 -> PILCROW SIGN
+ '\xa7' # 0x00f5 -> SECTION SIGN
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\xb8' # 0x00f7 -> CEDILLA
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\xa8' # 0x00f9 -> DIAERESIS
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\xb9' # 0x00fb -> SUPERSCRIPT ONE
+ '\xb3' # 0x00fc -> SUPERSCRIPT THREE
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
+)
+
+### Encoding Map
+
+encoding_map = {
+ 0x0000: 0x0000, # NULL
+ 0x0001: 0x0001, # START OF HEADING
+ 0x0002: 0x0002, # START OF TEXT
+ 0x0003: 0x0003, # END OF TEXT
+ 0x0004: 0x0004, # END OF TRANSMISSION
+ 0x0005: 0x0005, # ENQUIRY
+ 0x0006: 0x0006, # ACKNOWLEDGE
+ 0x0007: 0x0007, # BELL
+ 0x0008: 0x0008, # BACKSPACE
+ 0x0009: 0x0009, # HORIZONTAL TABULATION
+ 0x000a: 0x000a, # LINE FEED
+ 0x000b: 0x000b, # VERTICAL TABULATION
+ 0x000c: 0x000c, # FORM FEED
+ 0x000d: 0x000d, # CARRIAGE RETURN
+ 0x000e: 0x000e, # SHIFT OUT
+ 0x000f: 0x000f, # SHIFT IN
+ 0x0010: 0x0010, # DATA LINK ESCAPE
+ 0x0011: 0x0011, # DEVICE CONTROL ONE
+ 0x0012: 0x0012, # DEVICE CONTROL TWO
+ 0x0013: 0x0013, # DEVICE CONTROL THREE
+ 0x0014: 0x0014, # DEVICE CONTROL FOUR
+ 0x0015: 0x0015, # NEGATIVE ACKNOWLEDGE
+ 0x0016: 0x0016, # SYNCHRONOUS IDLE
+ 0x0017: 0x0017, # END OF TRANSMISSION BLOCK
+ 0x0018: 0x0018, # CANCEL
+ 0x0019: 0x0019, # END OF MEDIUM
+ 0x001a: 0x001a, # SUBSTITUTE
+ 0x001b: 0x001b, # ESCAPE
+ 0x001c: 0x001c, # FILE SEPARATOR
+ 0x001d: 0x001d, # GROUP SEPARATOR
+ 0x001e: 0x001e, # RECORD SEPARATOR
+ 0x001f: 0x001f, # UNIT SEPARATOR
+ 0x0020: 0x0020, # SPACE
+ 0x0021: 0x0021, # EXCLAMATION MARK
+ 0x0022: 0x0022, # QUOTATION MARK
+ 0x0023: 0x0023, # NUMBER SIGN
+ 0x0024: 0x0024, # DOLLAR SIGN
+ 0x0025: 0x0025, # PERCENT SIGN
+ 0x0026: 0x0026, # AMPERSAND
+ 0x0027: 0x0027, # APOSTROPHE
+ 0x0028: 0x0028, # LEFT PARENTHESIS
+ 0x0029: 0x0029, # RIGHT PARENTHESIS
+ 0x002a: 0x002a, # ASTERISK
+ 0x002b: 0x002b, # PLUS SIGN
+ 0x002c: 0x002c, # COMMA
+ 0x002d: 0x002d, # HYPHEN-MINUS
+ 0x002e: 0x002e, # FULL STOP
+ 0x002f: 0x002f, # SOLIDUS
+ 0x0030: 0x0030, # DIGIT ZERO
+ 0x0031: 0x0031, # DIGIT ONE
+ 0x0032: 0x0032, # DIGIT TWO
+ 0x0033: 0x0033, # DIGIT THREE
+ 0x0034: 0x0034, # DIGIT FOUR
+ 0x0035: 0x0035, # DIGIT FIVE
+ 0x0036: 0x0036, # DIGIT SIX
+ 0x0037: 0x0037, # DIGIT SEVEN
+ 0x0038: 0x0038, # DIGIT EIGHT
+ 0x0039: 0x0039, # DIGIT NINE
+ 0x003a: 0x003a, # COLON
+ 0x003b: 0x003b, # SEMICOLON
+ 0x003c: 0x003c, # LESS-THAN SIGN
+ 0x003d: 0x003d, # EQUALS SIGN
+ 0x003e: 0x003e, # GREATER-THAN SIGN
+ 0x003f: 0x003f, # QUESTION MARK
+ 0x0040: 0x0040, # COMMERCIAL AT
+ 0x0041: 0x0041, # LATIN CAPITAL LETTER A
+ 0x0042: 0x0042, # LATIN CAPITAL LETTER B
+ 0x0043: 0x0043, # LATIN CAPITAL LETTER C
+ 0x0044: 0x0044, # LATIN CAPITAL LETTER D
+ 0x0045: 0x0045, # LATIN CAPITAL LETTER E
+ 0x0046: 0x0046, # LATIN CAPITAL LETTER F
+ 0x0047: 0x0047, # LATIN CAPITAL LETTER G
+ 0x0048: 0x0048, # LATIN CAPITAL LETTER H
+ 0x0049: 0x0049, # LATIN CAPITAL LETTER I
+ 0x004a: 0x004a, # LATIN CAPITAL LETTER J
+ 0x004b: 0x004b, # LATIN CAPITAL LETTER K
+ 0x004c: 0x004c, # LATIN CAPITAL LETTER L
+ 0x004d: 0x004d, # LATIN CAPITAL LETTER M
+ 0x004e: 0x004e, # LATIN CAPITAL LETTER N
+ 0x004f: 0x004f, # LATIN CAPITAL LETTER O
+ 0x0050: 0x0050, # LATIN CAPITAL LETTER P
+ 0x0051: 0x0051, # LATIN CAPITAL LETTER Q
+ 0x0052: 0x0052, # LATIN CAPITAL LETTER R
+ 0x0053: 0x0053, # LATIN CAPITAL LETTER S
+ 0x0054: 0x0054, # LATIN CAPITAL LETTER T
+ 0x0055: 0x0055, # LATIN CAPITAL LETTER U
+ 0x0056: 0x0056, # LATIN CAPITAL LETTER V
+ 0x0057: 0x0057, # LATIN CAPITAL LETTER W
+ 0x0058: 0x0058, # LATIN CAPITAL LETTER X
+ 0x0059: 0x0059, # LATIN CAPITAL LETTER Y
+ 0x005a: 0x005a, # LATIN CAPITAL LETTER Z
+ 0x005b: 0x005b, # LEFT SQUARE BRACKET
+ 0x005c: 0x005c, # REVERSE SOLIDUS
+ 0x005d: 0x005d, # RIGHT SQUARE BRACKET
+ 0x005e: 0x005e, # CIRCUMFLEX ACCENT
+ 0x005f: 0x005f, # LOW LINE
+ 0x0060: 0x0060, # GRAVE ACCENT
+ 0x0061: 0x0061, # LATIN SMALL LETTER A
+ 0x0062: 0x0062, # LATIN SMALL LETTER B
+ 0x0063: 0x0063, # LATIN SMALL LETTER C
+ 0x0064: 0x0064, # LATIN SMALL LETTER D
+ 0x0065: 0x0065, # LATIN SMALL LETTER E
+ 0x0066: 0x0066, # LATIN SMALL LETTER F
+ 0x0067: 0x0067, # LATIN SMALL LETTER G
+ 0x0068: 0x0068, # LATIN SMALL LETTER H
+ 0x0069: 0x0069, # LATIN SMALL LETTER I
+ 0x006a: 0x006a, # LATIN SMALL LETTER J
+ 0x006b: 0x006b, # LATIN SMALL LETTER K
+ 0x006c: 0x006c, # LATIN SMALL LETTER L
+ 0x006d: 0x006d, # LATIN SMALL LETTER M
+ 0x006e: 0x006e, # LATIN SMALL LETTER N
+ 0x006f: 0x006f, # LATIN SMALL LETTER O
+ 0x0070: 0x0070, # LATIN SMALL LETTER P
+ 0x0071: 0x0071, # LATIN SMALL LETTER Q
+ 0x0072: 0x0072, # LATIN SMALL LETTER R
+ 0x0073: 0x0073, # LATIN SMALL LETTER S
+ 0x0074: 0x0074, # LATIN SMALL LETTER T
+ 0x0075: 0x0075, # LATIN SMALL LETTER U
+ 0x0076: 0x0076, # LATIN SMALL LETTER V
+ 0x0077: 0x0077, # LATIN SMALL LETTER W
+ 0x0078: 0x0078, # LATIN SMALL LETTER X
+ 0x0079: 0x0079, # LATIN SMALL LETTER Y
+ 0x007a: 0x007a, # LATIN SMALL LETTER Z
+ 0x007b: 0x007b, # LEFT CURLY BRACKET
+ 0x007c: 0x007c, # VERTICAL LINE
+ 0x007d: 0x007d, # RIGHT CURLY BRACKET
+ 0x007e: 0x007e, # TILDE
+ 0x007f: 0x007f, # DELETE
+ 0x00a0: 0x00ff, # NO-BREAK SPACE
+ 0x00a1: 0x00ad, # INVERTED EXCLAMATION MARK
+ 0x00a2: 0x00bd, # CENT SIGN
+ 0x00a3: 0x009c, # POUND SIGN
+ 0x00a4: 0x00cf, # CURRENCY SIGN
+ 0x00a5: 0x00be, # YEN SIGN
+ 0x00a6: 0x00dd, # BROKEN BAR
+ 0x00a7: 0x00f5, # SECTION SIGN
+ 0x00a8: 0x00f9, # DIAERESIS
+ 0x00a9: 0x00b8, # COPYRIGHT SIGN
+ 0x00aa: 0x00a6, # FEMININE ORDINAL INDICATOR
+ 0x00ab: 0x00ae, # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ 0x00ac: 0x00aa, # NOT SIGN
+ 0x00ad: 0x00f0, # SOFT HYPHEN
+ 0x00ae: 0x00a9, # REGISTERED SIGN
+ 0x00af: 0x00ee, # MACRON
+ 0x00b0: 0x00f8, # DEGREE SIGN
+ 0x00b1: 0x00f1, # PLUS-MINUS SIGN
+ 0x00b2: 0x00fd, # SUPERSCRIPT TWO
+ 0x00b3: 0x00fc, # SUPERSCRIPT THREE
+ 0x00b4: 0x00ef, # ACUTE ACCENT
+ 0x00b5: 0x00e6, # MICRO SIGN
+ 0x00b6: 0x00f4, # PILCROW SIGN
+ 0x00b7: 0x00fa, # MIDDLE DOT
+ 0x00b8: 0x00f7, # CEDILLA
+ 0x00b9: 0x00fb, # SUPERSCRIPT ONE
+ 0x00ba: 0x00a7, # MASCULINE ORDINAL INDICATOR
+ 0x00bb: 0x00af, # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ 0x00bc: 0x00ac, # VULGAR FRACTION ONE QUARTER
+ 0x00bd: 0x00ab, # VULGAR FRACTION ONE HALF
+ 0x00be: 0x00f3, # VULGAR FRACTION THREE QUARTERS
+ 0x00bf: 0x00a8, # INVERTED QUESTION MARK
+ 0x00c0: 0x00b7, # LATIN CAPITAL LETTER A WITH GRAVE
+ 0x00c1: 0x00b5, # LATIN CAPITAL LETTER A WITH ACUTE
+ 0x00c2: 0x00b6, # LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ 0x00c3: 0x00c7, # LATIN CAPITAL LETTER A WITH TILDE
+ 0x00c4: 0x008e, # LATIN CAPITAL LETTER A WITH DIAERESIS
+ 0x00c5: 0x008f, # LATIN CAPITAL LETTER A WITH RING ABOVE
+ 0x00c6: 0x0092, # LATIN CAPITAL LIGATURE AE
+ 0x00c7: 0x0080, # LATIN CAPITAL LETTER C WITH CEDILLA
+ 0x00c8: 0x00d4, # LATIN CAPITAL LETTER E WITH GRAVE
+ 0x00c9: 0x0090, # LATIN CAPITAL LETTER E WITH ACUTE
+ 0x00ca: 0x00d2, # LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ 0x00cb: 0x00d3, # LATIN CAPITAL LETTER E WITH DIAERESIS
+ 0x00cc: 0x00de, # LATIN CAPITAL LETTER I WITH GRAVE
+ 0x00cd: 0x00d6, # LATIN CAPITAL LETTER I WITH ACUTE
+ 0x00ce: 0x00d7, # LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ 0x00cf: 0x00d8, # LATIN CAPITAL LETTER I WITH DIAERESIS
+ 0x00d0: 0x00d1, # LATIN CAPITAL LETTER ETH
+ 0x00d1: 0x00a5, # LATIN CAPITAL LETTER N WITH TILDE
+ 0x00d2: 0x00e3, # LATIN CAPITAL LETTER O WITH GRAVE
+ 0x00d3: 0x00e0, # LATIN CAPITAL LETTER O WITH ACUTE
+ 0x00d4: 0x00e2, # LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ 0x00d5: 0x00e5, # LATIN CAPITAL LETTER O WITH TILDE
+ 0x00d6: 0x0099, # LATIN CAPITAL LETTER O WITH DIAERESIS
+ 0x00d7: 0x009e, # MULTIPLICATION SIGN
+ 0x00d8: 0x009d, # LATIN CAPITAL LETTER O WITH STROKE
+ 0x00d9: 0x00eb, # LATIN CAPITAL LETTER U WITH GRAVE
+ 0x00da: 0x00e9, # LATIN CAPITAL LETTER U WITH ACUTE
+ 0x00db: 0x00ea, # LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ 0x00dc: 0x009a, # LATIN CAPITAL LETTER U WITH DIAERESIS
+ 0x00dd: 0x00ed, # LATIN CAPITAL LETTER Y WITH ACUTE
+ 0x00de: 0x00e8, # LATIN CAPITAL LETTER THORN
+ 0x00df: 0x00e1, # LATIN SMALL LETTER SHARP S
+ 0x00e0: 0x0085, # LATIN SMALL LETTER A WITH GRAVE
+ 0x00e1: 0x00a0, # LATIN SMALL LETTER A WITH ACUTE
+ 0x00e2: 0x0083, # LATIN SMALL LETTER A WITH CIRCUMFLEX
+ 0x00e3: 0x00c6, # LATIN SMALL LETTER A WITH TILDE
+ 0x00e4: 0x0084, # LATIN SMALL LETTER A WITH DIAERESIS
+ 0x00e5: 0x0086, # LATIN SMALL LETTER A WITH RING ABOVE
+ 0x00e6: 0x0091, # LATIN SMALL LIGATURE AE
+ 0x00e7: 0x0087, # LATIN SMALL LETTER C WITH CEDILLA
+ 0x00e8: 0x008a, # LATIN SMALL LETTER E WITH GRAVE
+ 0x00e9: 0x0082, # LATIN SMALL LETTER E WITH ACUTE
+ 0x00ea: 0x0088, # LATIN SMALL LETTER E WITH CIRCUMFLEX
+ 0x00eb: 0x0089, # LATIN SMALL LETTER E WITH DIAERESIS
+ 0x00ec: 0x008d, # LATIN SMALL LETTER I WITH GRAVE
+ 0x00ed: 0x00a1, # LATIN SMALL LETTER I WITH ACUTE
+ 0x00ee: 0x008c, # LATIN SMALL LETTER I WITH CIRCUMFLEX
+ 0x00ef: 0x008b, # LATIN SMALL LETTER I WITH DIAERESIS
+ 0x00f0: 0x00d0, # LATIN SMALL LETTER ETH
+ 0x00f1: 0x00a4, # LATIN SMALL LETTER N WITH TILDE
+ 0x00f2: 0x0095, # LATIN SMALL LETTER O WITH GRAVE
+ 0x00f3: 0x00a2, # LATIN SMALL LETTER O WITH ACUTE
+ 0x00f4: 0x0093, # LATIN SMALL LETTER O WITH CIRCUMFLEX
+ 0x00f5: 0x00e4, # LATIN SMALL LETTER O WITH TILDE
+ 0x00f6: 0x0094, # LATIN SMALL LETTER O WITH DIAERESIS
+ 0x00f7: 0x00f6, # DIVISION SIGN
+ 0x00f8: 0x009b, # LATIN SMALL LETTER O WITH STROKE
+ 0x00f9: 0x0097, # LATIN SMALL LETTER U WITH GRAVE
+ 0x00fa: 0x00a3, # LATIN SMALL LETTER U WITH ACUTE
+ 0x00fb: 0x0096, # LATIN SMALL LETTER U WITH CIRCUMFLEX
+ 0x00fc: 0x0081, # LATIN SMALL LETTER U WITH DIAERESIS
+ 0x00fd: 0x00ec, # LATIN SMALL LETTER Y WITH ACUTE
+ 0x00fe: 0x00e7, # LATIN SMALL LETTER THORN
+ 0x00ff: 0x0098, # LATIN SMALL LETTER Y WITH DIAERESIS
+ 0x20ac: 0x00d5, # EURO SIGN
+ 0x0192: 0x009f, # LATIN SMALL LETTER F WITH HOOK
+ 0x2017: 0x00f2, # DOUBLE LOW LINE
+ 0x2500: 0x00c4, # BOX DRAWINGS LIGHT HORIZONTAL
+ 0x2502: 0x00b3, # BOX DRAWINGS LIGHT VERTICAL
+ 0x250c: 0x00da, # BOX DRAWINGS LIGHT DOWN AND RIGHT
+ 0x2510: 0x00bf, # BOX DRAWINGS LIGHT DOWN AND LEFT
+ 0x2514: 0x00c0, # BOX DRAWINGS LIGHT UP AND RIGHT
+ 0x2518: 0x00d9, # BOX DRAWINGS LIGHT UP AND LEFT
+ 0x251c: 0x00c3, # BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ 0x2524: 0x00b4, # BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ 0x252c: 0x00c2, # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ 0x2534: 0x00c1, # BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ 0x253c: 0x00c5, # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ 0x2550: 0x00cd, # BOX DRAWINGS DOUBLE HORIZONTAL
+ 0x2551: 0x00ba, # BOX DRAWINGS DOUBLE VERTICAL
+ 0x2554: 0x00c9, # BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ 0x2557: 0x00bb, # BOX DRAWINGS DOUBLE DOWN AND LEFT
+ 0x255a: 0x00c8, # BOX DRAWINGS DOUBLE UP AND RIGHT
+ 0x255d: 0x00bc, # BOX DRAWINGS DOUBLE UP AND LEFT
+ 0x2560: 0x00cc, # BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ 0x2563: 0x00b9, # BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ 0x2566: 0x00cb, # BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ 0x2569: 0x00ca, # BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ 0x256c: 0x00ce, # BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ 0x2580: 0x00df, # UPPER HALF BLOCK
+ 0x2584: 0x00dc, # LOWER HALF BLOCK
+ 0x2588: 0x00db, # FULL BLOCK
+ 0x2591: 0x00b0, # LIGHT SHADE
+ 0x2592: 0x00b1, # MEDIUM SHADE
+ 0x2593: 0x00b2, # DARK SHADE
+ 0x25a0: 0x00fe, # BLACK SQUARE
+}
diff --git a/Lib/encodings/hex_codec.py b/Lib/encodings/hex_codec.py
new file mode 100644
index 0000000000..e003fc3ff9
--- /dev/null
+++ b/Lib/encodings/hex_codec.py
@@ -0,0 +1,55 @@
+"""Python 'hex_codec' Codec - 2-digit hex content transfer encoding.
+
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+
+Written by Marc-Andre Lemburg (mal@lemburg.com).
+"""
+
+import codecs
+import binascii
+
+### Codec APIs
+
+def hex_encode(input, errors='strict'):
+ assert errors == 'strict'
+ return (binascii.b2a_hex(input), len(input))
+
+def hex_decode(input, errors='strict'):
+ assert errors == 'strict'
+ return (binascii.a2b_hex(input), len(input))
+
+class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return hex_encode(input, errors)
+ def decode(self, input, errors='strict'):
+ return hex_decode(input, errors)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ assert self.errors == 'strict'
+ return binascii.b2a_hex(input)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def decode(self, input, final=False):
+ assert self.errors == 'strict'
+ return binascii.a2b_hex(input)
+
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
+
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='hex',
+ encode=hex_encode,
+ decode=hex_decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamwriter=StreamWriter,
+ streamreader=StreamReader,
+ )
diff --git a/Lib/encodings/punycode.py b/Lib/encodings/punycode.py
index 8129af2543..66c51013ea 100644
--- a/Lib/encodings/punycode.py
+++ b/Lib/encodings/punycode.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
""" Codec for the Punicode encoding, as specified in RFC 3492
Written by Martin v. Löwis.
diff --git a/Lib/encodings/quopri_codec.py b/Lib/encodings/quopri_codec.py
new file mode 100644
index 0000000000..9243fc443b
--- /dev/null
+++ b/Lib/encodings/quopri_codec.py
@@ -0,0 +1,56 @@
+"""Codec for quoted-printable encoding.
+
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+"""
+
+import codecs
+import quopri
+from io import BytesIO
+
+def quopri_encode(input, errors='strict'):
+ assert errors == 'strict'
+ f = BytesIO(input)
+ g = BytesIO()
+ quopri.encode(f, g, 1)
+ return (g.getvalue(), len(input))
+
+def quopri_decode(input, errors='strict'):
+ assert errors == 'strict'
+ f = BytesIO(input)
+ g = BytesIO()
+ quopri.decode(f, g)
+ return (g.getvalue(), len(input))
+
+class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return quopri_encode(input, errors)
+ def decode(self, input, errors='strict'):
+ return quopri_decode(input, errors)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ return quopri_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def decode(self, input, final=False):
+ return quopri_decode(input, self.errors)[0]
+
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
+
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
+
+# encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='quopri',
+ encode=quopri_encode,
+ decode=quopri_decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamwriter=StreamWriter,
+ streamreader=StreamReader,
+ )
diff --git a/Lib/encodings/rot_13.py b/Lib/encodings/rot_13.py
new file mode 100755
index 0000000000..3140c1432d
--- /dev/null
+++ b/Lib/encodings/rot_13.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python
+""" Python Character Mapping Codec for ROT13.
+
+This codec de/encodes from str to str and is therefore usable with
+str.transform() and str.untransform().
+
+Written by Marc-Andre Lemburg (mal@lemburg.com).
+"""
+
+import codecs
+
+### Codec APIs
+
+class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return (input.translate(rot13_map), len(input))
+
+ def decode(self, input, errors='strict'):
+ return (input.translate(rot13_map), len(input))
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ return input.translate(rot13_map)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def decode(self, input, final=False):
+ return input.translate(rot13_map)
+
+class StreamWriter(Codec,codecs.StreamWriter):
+ pass
+
+class StreamReader(Codec,codecs.StreamReader):
+ pass
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='rot-13',
+ encode=Codec().encode,
+ decode=Codec().decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamwriter=StreamWriter,
+ streamreader=StreamReader,
+ )
+
+### Map
+
+rot13_map = codecs.make_identity_dict(range(256))
+rot13_map.update({
+ 0x0041: 0x004e,
+ 0x0042: 0x004f,
+ 0x0043: 0x0050,
+ 0x0044: 0x0051,
+ 0x0045: 0x0052,
+ 0x0046: 0x0053,
+ 0x0047: 0x0054,
+ 0x0048: 0x0055,
+ 0x0049: 0x0056,
+ 0x004a: 0x0057,
+ 0x004b: 0x0058,
+ 0x004c: 0x0059,
+ 0x004d: 0x005a,
+ 0x004e: 0x0041,
+ 0x004f: 0x0042,
+ 0x0050: 0x0043,
+ 0x0051: 0x0044,
+ 0x0052: 0x0045,
+ 0x0053: 0x0046,
+ 0x0054: 0x0047,
+ 0x0055: 0x0048,
+ 0x0056: 0x0049,
+ 0x0057: 0x004a,
+ 0x0058: 0x004b,
+ 0x0059: 0x004c,
+ 0x005a: 0x004d,
+ 0x0061: 0x006e,
+ 0x0062: 0x006f,
+ 0x0063: 0x0070,
+ 0x0064: 0x0071,
+ 0x0065: 0x0072,
+ 0x0066: 0x0073,
+ 0x0067: 0x0074,
+ 0x0068: 0x0075,
+ 0x0069: 0x0076,
+ 0x006a: 0x0077,
+ 0x006b: 0x0078,
+ 0x006c: 0x0079,
+ 0x006d: 0x007a,
+ 0x006e: 0x0061,
+ 0x006f: 0x0062,
+ 0x0070: 0x0063,
+ 0x0071: 0x0064,
+ 0x0072: 0x0065,
+ 0x0073: 0x0066,
+ 0x0074: 0x0067,
+ 0x0075: 0x0068,
+ 0x0076: 0x0069,
+ 0x0077: 0x006a,
+ 0x0078: 0x006b,
+ 0x0079: 0x006c,
+ 0x007a: 0x006d,
+})
+
+### Filter API
+
+def rot13(infile, outfile):
+ outfile.write(infile.read().encode('rot-13'))
+
+if __name__ == '__main__':
+ import sys
+ rot13(sys.stdin, sys.stdout)
diff --git a/Lib/encodings/uu_codec.py b/Lib/encodings/uu_codec.py
new file mode 100644
index 0000000000..69c6f17c7f
--- /dev/null
+++ b/Lib/encodings/uu_codec.py
@@ -0,0 +1,99 @@
+"""Python 'uu_codec' Codec - UU content transfer encoding.
+
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+
+Written by Marc-Andre Lemburg (mal@lemburg.com). Some details were
+adapted from uu.py which was written by Lance Ellinghouse and
+modified by Jack Jansen and Fredrik Lundh.
+"""
+
+import codecs
+import binascii
+from io import BytesIO
+
+### Codec APIs
+
+def uu_encode(input, errors='strict', filename='<data>', mode=0o666):
+ assert errors == 'strict'
+ infile = BytesIO(input)
+ outfile = BytesIO()
+ read = infile.read
+ write = outfile.write
+
+ # Encode
+ write(('begin %o %s\n' % (mode & 0o777, filename)).encode('ascii'))
+ chunk = read(45)
+ while chunk:
+ write(binascii.b2a_uu(chunk))
+ chunk = read(45)
+ write(b' \nend\n')
+
+ return (outfile.getvalue(), len(input))
+
+def uu_decode(input, errors='strict'):
+ assert errors == 'strict'
+ infile = BytesIO(input)
+ outfile = BytesIO()
+ readline = infile.readline
+ write = outfile.write
+
+ # Find start of encoded data
+ while 1:
+ s = readline()
+ if not s:
+ raise ValueError('Missing "begin" line in input data')
+ if s[:5] == b'begin':
+ break
+
+ # Decode
+ while True:
+ s = readline()
+ if not s or s == b'end\n':
+ break
+ try:
+ data = binascii.a2b_uu(s)
+ except binascii.Error as v:
+ # Workaround for broken uuencoders by /Fredrik Lundh
+ nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3
+ data = binascii.a2b_uu(s[:nbytes])
+ #sys.stderr.write("Warning: %s\n" % str(v))
+ write(data)
+ if not s:
+ raise ValueError('Truncated input data')
+
+ return (outfile.getvalue(), len(input))
+
+class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return uu_encode(input, errors)
+
+ def decode(self, input, errors='strict'):
+ return uu_decode(input, errors)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ return uu_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def decode(self, input, final=False):
+ return uu_decode(input, self.errors)[0]
+
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
+
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='uu',
+ encode=uu_encode,
+ decode=uu_decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamreader=StreamReader,
+ streamwriter=StreamWriter,
+ )
diff --git a/Lib/encodings/zlib_codec.py b/Lib/encodings/zlib_codec.py
new file mode 100644
index 0000000000..e0b9cdadbc
--- /dev/null
+++ b/Lib/encodings/zlib_codec.py
@@ -0,0 +1,77 @@
+"""Python 'zlib_codec' Codec - zlib compression encoding.
+
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+
+Written by Marc-Andre Lemburg (mal@lemburg.com).
+"""
+
+import codecs
+import zlib # this codec needs the optional zlib module !
+
+### Codec APIs
+
+def zlib_encode(input, errors='strict'):
+ assert errors == 'strict'
+ return (zlib.compress(input), len(input))
+
+def zlib_decode(input, errors='strict'):
+ assert errors == 'strict'
+ return (zlib.decompress(input), len(input))
+
+class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return zlib_encode(input, errors)
+ def decode(self, input, errors='strict'):
+ return zlib_decode(input, errors)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def __init__(self, errors='strict'):
+ assert errors == 'strict'
+ self.errors = errors
+ self.compressobj = zlib.compressobj()
+
+ def encode(self, input, final=False):
+ if final:
+ c = self.compressobj.compress(input)
+ return c + self.compressobj.flush()
+ else:
+ return self.compressobj.compress(input)
+
+ def reset(self):
+ self.compressobj = zlib.compressobj()
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def __init__(self, errors='strict'):
+ assert errors == 'strict'
+ self.errors = errors
+ self.decompressobj = zlib.decompressobj()
+
+ def decode(self, input, final=False):
+ if final:
+ c = self.decompressobj.decompress(input)
+ return c + self.decompressobj.flush()
+ else:
+ return self.decompressobj.decompress(input)
+
+ def reset(self):
+ self.decompressobj = zlib.decompressobj()
+
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
+
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='zlib',
+ encode=zlib_encode,
+ decode=zlib_decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamreader=StreamReader,
+ streamwriter=StreamWriter,
+ )
diff --git a/Lib/fileinput.py b/Lib/fileinput.py
index 90a600bf11..a25a021eb3 100644
--- a/Lib/fileinput.py
+++ b/Lib/fileinput.py
@@ -238,6 +238,12 @@ class FileInput:
self.nextfile()
self._files = ()
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.close()
+
def __iter__(self):
return self
diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py
index be1fd1d16c..726fbe556e 100644
--- a/Lib/fnmatch.py
+++ b/Lib/fnmatch.py
@@ -9,20 +9,13 @@ expression. They cache the compiled regular expressions for speed.
The function translate(PATTERN) returns a regular expression
corresponding to PATTERN. (It does not compile it.)
"""
-
+import os
+import posixpath
import re
+import functools
__all__ = ["filter", "fnmatch", "fnmatchcase", "translate"]
-_cache = {} # Maps text patterns to compiled regexen.
-_cacheb = {} # Ditto for bytes patterns.
-_MAXCACHE = 100 # Maximum size of caches
-
-def _purge():
- """Clear the pattern cache"""
- _cache.clear()
- _cacheb.clear()
-
def fnmatch(name, pat):
"""Test whether FILENAME matches PATTERN.
@@ -38,33 +31,25 @@ def fnmatch(name, pat):
if the operating system requires it.
If you don't want this, use fnmatchcase(FILENAME, PATTERN).
"""
-
- import os
name = os.path.normcase(name)
pat = os.path.normcase(pat)
return fnmatchcase(name, pat)
-def _compile_pattern(pat):
- cache = _cacheb if isinstance(pat, bytes) else _cache
- regex = cache.get(pat)
- if regex is None:
- if isinstance(pat, bytes):
- pat_str = str(pat, 'ISO-8859-1')
- res_str = translate(pat_str)
- res = bytes(res_str, 'ISO-8859-1')
- else:
- res = translate(pat)
- if len(cache) >= _MAXCACHE:
- cache.clear()
- cache[pat] = regex = re.compile(res)
- return regex.match
+@functools.lru_cache(maxsize=250)
+def _compile_pattern(pat, is_bytes=False):
+ if is_bytes:
+ pat_str = str(pat, 'ISO-8859-1')
+ res_str = translate(pat_str)
+ res = bytes(res_str, 'ISO-8859-1')
+ else:
+ res = translate(pat)
+ return re.compile(res).match
def filter(names, pat):
- """Return the subset of the list NAMES that match PAT"""
- import os,posixpath
+ """Return the subset of the list NAMES that match PAT."""
result = []
pat = os.path.normcase(pat)
- match = _compile_pattern(pat)
+ match = _compile_pattern(pat, isinstance(pat, bytes))
if os.path is posixpath:
# normcase on posix is NOP. Optimize it away from the loop.
for name in names:
@@ -82,10 +67,10 @@ def fnmatchcase(name, pat):
This is a version of fnmatch() which doesn't case-normalize
its arguments.
"""
-
- match = _compile_pattern(pat)
+ match = _compile_pattern(pat, isinstance(pat, bytes))
return match(name) is not None
+
def translate(pat):
"""Translate a shell PATTERN to a regular expression.
diff --git a/Lib/fractions.py b/Lib/fractions.py
index 27b27f40ff..8be52d2db8 100644
--- a/Lib/fractions.py
+++ b/Lib/fractions.py
@@ -3,10 +3,12 @@
"""Fraction, infinite-precision, real numbers."""
+from decimal import Decimal
import math
import numbers
import operator
import re
+import sys
__all__ = ['Fraction', 'gcd']
@@ -22,6 +24,12 @@ def gcd(a, b):
a, b = b, a%b
return a
+# Constants related to the hash implementation; hash(x) is based
+# on the reduction of x modulo the prime _PyHASH_MODULUS.
+_PyHASH_MODULUS = sys.hash_info.modulus
+# Value to be used for rationals that reduce to infinity modulo
+# _PyHASH_MODULUS.
+_PyHASH_INF = sys.hash_info.inf
_RATIONAL_FORMAT = re.compile(r"""
\A\s* # optional whitespace at the start, then
@@ -41,13 +49,21 @@ _RATIONAL_FORMAT = re.compile(r"""
class Fraction(numbers.Rational):
"""This class implements rational numbers.
- Fraction(8, 6) will produce a rational number equivalent to
- 4/3. Both arguments must be Integral. The numerator defaults to 0
- and the denominator defaults to 1 so that Fraction(3) == 3 and
- Fraction() == 0.
+ In the two-argument form of the constructor, Fraction(8, 6) will
+ produce a rational number equivalent to 4/3. Both arguments must
+ be Rational. The numerator defaults to 0 and the denominator
+ defaults to 1 so that Fraction(3) == 3 and Fraction() == 0.
- Fraction can also be constructed from strings of the form
- '[-+]?[0-9]+((/|.)[0-9]+)?', optionally surrounded by spaces.
+ Fractions can also be constructed from:
+
+ - numeric strings similar to those accepted by the
+ float constructor (for example, '-2.3' or '1e10')
+
+ - strings of the form '123/456'
+
+ - float and Decimal instances
+
+ - other Rational instances (including integers)
"""
@@ -57,8 +73,32 @@ class Fraction(numbers.Rational):
def __new__(cls, numerator=0, denominator=None):
"""Constructs a Rational.
- Takes a string like '3/2' or '1.5', another Rational, or a
- numerator/denominator pair.
+ Takes a string like '3/2' or '1.5', another Rational instance, a
+ numerator/denominator pair, or a float.
+
+ Examples
+ --------
+
+ >>> Fraction(10, -8)
+ Fraction(-5, 4)
+ >>> Fraction(Fraction(1, 7), 5)
+ Fraction(1, 35)
+ >>> Fraction(Fraction(1, 7), Fraction(2, 3))
+ Fraction(3, 14)
+ >>> Fraction('314')
+ Fraction(314, 1)
+ >>> Fraction('-35/4')
+ Fraction(-35, 4)
+ >>> Fraction('3.1415') # conversion from numeric string
+ Fraction(6283, 2000)
+ >>> Fraction('-47e-2') # string may include a decimal exponent
+ Fraction(-47, 100)
+ >>> Fraction(1.47) # direct construction from float (exact conversion)
+ Fraction(6620291452234629, 4503599627370496)
+ >>> Fraction(2.25)
+ Fraction(9, 4)
+ >>> Fraction(Decimal('1.47'))
+ Fraction(147, 100)
"""
self = super(Fraction, cls).__new__(cls)
@@ -69,6 +109,19 @@ class Fraction(numbers.Rational):
self._denominator = numerator.denominator
return self
+ elif isinstance(numerator, float):
+ # Exact conversion from float
+ value = Fraction.from_float(numerator)
+ self._numerator = value._numerator
+ self._denominator = value._denominator
+ return self
+
+ elif isinstance(numerator, Decimal):
+ value = Fraction.from_decimal(numerator)
+ self._numerator = value._numerator
+ self._denominator = value._denominator
+ return self
+
elif isinstance(numerator, str):
# Handle construction from strings.
m = _RATIONAL_FORMAT.match(numerator)
@@ -475,23 +528,26 @@ class Fraction(numbers.Rational):
return Fraction(round(self / shift) * shift)
def __hash__(self):
- """hash(self)
-
- Tricky because values that are exactly representable as a
- float must have the same hash as that float.
+ """hash(self)"""
- """
# XXX since this method is expensive, consider caching the result
- if self._denominator == 1:
- # Get integers right.
- return hash(self._numerator)
- # Expensive check, but definitely correct.
- if self == float(self):
- return hash(float(self))
+
+ # In order to make sure that the hash of a Fraction agrees
+ # with the hash of a numerically equal integer, float or
+ # Decimal instance, we follow the rules for numeric hashes
+ # outlined in the documentation. (See library docs, 'Built-in
+ # Types').
+
+ # dinv is the inverse of self._denominator modulo the prime
+ # _PyHASH_MODULUS, or 0 if self._denominator is divisible by
+ # _PyHASH_MODULUS.
+ dinv = pow(self._denominator, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
+ if not dinv:
+ hash_ = _PyHASH_INF
else:
- # Use tuple's hash to avoid a high collision rate on
- # simple fractions.
- return hash((self._numerator, self._denominator))
+ hash_ = abs(self._numerator) * dinv % _PyHASH_MODULUS
+ result = hash_ if self >= 0 else -hash_
+ return -2 if result == -1 else result
def __eq__(a, b):
"""a == b"""
@@ -526,8 +582,6 @@ class Fraction(numbers.Rational):
if isinstance(other, numbers.Rational):
return op(self._numerator * other.denominator,
self._denominator * other.numerator)
- if isinstance(other, numbers.Complex) and other.imag == 0:
- other = other.real
if isinstance(other, float):
if math.isnan(other) or math.isinf(other):
return op(0.0, other)
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index ea91c1707c..7c398879bc 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -33,17 +33,12 @@ python ftplib.py -d localhost -l -p -l
# Modified by Jack to work on the mac.
# Modified by Siebren to support docstrings and PASV.
# Modified by Phil Schwartz to add storbinary and storlines callbacks.
+# Modified by Giampaolo Rodola' to add TLS support.
#
import os
import sys
-
-# Import SOCKS module if it exists, else standard socket module socket
-try:
- import SOCKS; socket = SOCKS; del SOCKS # import SOCKS as socket
- from socket import getfqdn; socket.getfqdn = getfqdn; del getfqdn
-except ImportError:
- import socket
+import socket
from socket import _GLOBAL_DEFAULT_TIMEOUT
__all__ = ["FTP","Netrc"]
@@ -119,6 +114,20 @@ class FTP:
if user:
self.login(user, passwd, acct)
+ def __enter__(self):
+ return self
+
+ # Context management protocol: try to quit() if active
+ def __exit__(self, *args):
+ if self.sock is not None:
+ try:
+ self.quit()
+ except (socket.error, EOFError):
+ pass
+ finally:
+ if self.sock is not None:
+ self.close()
+
def connect(self, host='', port=0, timeout=-999):
'''Connect to host. Arguments are:
- host: hostname to connect to (string, default previous host)
@@ -162,7 +171,7 @@ class FTP:
def sanitize(self, s):
if s[:5] == 'pass ' or s[:5] == 'PASS ':
i = len(s)
- while i > 5 and s[i-1] in '\r\n':
+ while i > 5 and s[i-1] in {'\r', '\n'}:
i = i-1
s = s[:5] + '*'*(i-5) + s[i:]
return repr(s)
@@ -212,7 +221,7 @@ class FTP:
if self.debugging: print('*resp*', self.sanitize(resp))
self.lastresp = resp[:3]
c = resp[:1]
- if c in ('1', '2', '3'):
+ if c in {'1', '2', '3'}:
return resp
if c == '4':
raise error_temp(resp)
@@ -236,7 +245,7 @@ class FTP:
if self.debugging > 1: print('*put urgent*', self.sanitize(line))
self.sock.sendall(line, MSG_OOB)
resp = self.getmultiline()
- if resp[:3] not in ('426', '225', '226'):
+ if resp[:3] not in {'426', '225', '226'}:
raise error_proto(resp)
def sendcmd(self, cmd):
@@ -352,6 +361,7 @@ class FTP:
conn, sockaddr = sock.accept()
if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
conn.settimeout(self.timeout)
+ sock.close()
if resp[:3] == '150':
# this is conditional in case we received a 125
size = parse150(resp)
@@ -366,7 +376,7 @@ class FTP:
if not user: user = 'anonymous'
if not passwd: passwd = ''
if not acct: acct = ''
- if user == 'anonymous' and passwd in ('', '-'):
+ if user == 'anonymous' and passwd in {'', '-'}:
# If there is no anonymous ftp password specified
# then we'll just use anonymous@
# We don't send any other thing because:
@@ -397,13 +407,12 @@ class FTP:
The response code.
"""
self.voidcmd('TYPE I')
- conn = self.transfercmd(cmd, rest)
- while 1:
- data = conn.recv(blocksize)
- if not data:
- break
- callback(data)
- conn.close()
+ with self.transfercmd(cmd, rest) as conn:
+ while 1:
+ data = conn.recv(blocksize)
+ if not data:
+ break
+ callback(data)
return self.voidresp()
def retrlines(self, cmd, callback = None):
@@ -420,23 +429,21 @@ class FTP:
"""
if callback is None: callback = print_line
resp = self.sendcmd('TYPE A')
- conn = self.transfercmd(cmd)
- fp = conn.makefile('r', encoding=self.encoding)
- while 1:
- line = fp.readline()
- if self.debugging > 2: print('*retr*', repr(line))
- if not line:
- break
- if line[-2:] == CRLF:
- line = line[:-2]
- elif line[-1:] == '\n':
- line = line[:-1]
- callback(line)
- fp.close()
- conn.close()
+ with self.transfercmd(cmd) as conn, \
+ conn.makefile('r', encoding=self.encoding) as fp:
+ while 1:
+ line = fp.readline()
+ if self.debugging > 2: print('*retr*', repr(line))
+ if not line:
+ break
+ if line[-2:] == CRLF:
+ line = line[:-2]
+ elif line[-1:] == '\n':
+ line = line[:-1]
+ callback(line)
return self.voidresp()
- def storbinary(self, cmd, fp, blocksize=8192, callback=None):
+ def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
"""Store a file in binary mode. A new port is created for you.
Args:
@@ -446,18 +453,18 @@ class FTP:
the connection at once. [default: 8192]
callback: An optional single parameter callable that is called on
on each block of data after it is sent. [default: None]
+ rest: Passed to transfercmd(). [default: None]
Returns:
The response code.
"""
self.voidcmd('TYPE I')
- conn = self.transfercmd(cmd)
- while 1:
- buf = fp.read(blocksize)
- if not buf: break
- conn.sendall(buf)
- if callback: callback(buf)
- conn.close()
+ with self.transfercmd(cmd, rest) as conn:
+ while 1:
+ buf = fp.read(blocksize)
+ if not buf: break
+ conn.sendall(buf)
+ if callback: callback(buf)
return self.voidresp()
def storlines(self, cmd, fp, callback=None):
@@ -473,16 +480,15 @@ class FTP:
The response code.
"""
self.voidcmd('TYPE A')
- conn = self.transfercmd(cmd)
- while 1:
- buf = fp.readline()
- if not buf: break
- if buf[-2:] != B_CRLF:
- if buf[-1] in B_CRLF: buf = buf[:-1]
- buf = buf + B_CRLF
- conn.sendall(buf)
- if callback: callback(buf)
- conn.close()
+ with self.transfercmd(cmd) as conn:
+ while 1:
+ buf = fp.readline()
+ if not buf: break
+ if buf[-2:] != B_CRLF:
+ if buf[-1] in B_CRLF: buf = buf[:-1]
+ buf = buf + B_CRLF
+ conn.sendall(buf)
+ if callback: callback(buf)
return self.voidresp()
def acct(self, password):
@@ -524,7 +530,7 @@ class FTP:
def delete(self, filename):
'''Delete a file.'''
resp = self.sendcmd('DELE ' + filename)
- if resp[:3] in ('250', '200'):
+ if resp[:3] in {'250', '200'}:
return resp
else:
raise error_reply(resp)
@@ -555,7 +561,11 @@ class FTP:
def mkd(self, dirname):
'''Make a directory, return its full pathname.'''
- resp = self.sendcmd('MKD ' + dirname)
+ resp = self.voidcmd('MKD ' + dirname)
+ # fix around non-compliant implementations such as IIS shipped
+ # with Windows server 2003
+ if not resp.startswith('257'):
+ return ''
return parse257(resp)
def rmd(self, dirname):
@@ -564,7 +574,11 @@ class FTP:
def pwd(self):
'''Return current working directory.'''
- resp = self.sendcmd('PWD')
+ resp = self.voidcmd('PWD')
+ # fix around non-compliant implementations such as IIS shipped
+ # with Windows server 2003
+ if not resp.startswith('257'):
+ return ''
return parse257(resp)
def quit(self):
@@ -581,6 +595,196 @@ class FTP:
self.file = self.sock = None
+try:
+ import ssl
+except ImportError:
+ pass
+else:
+ class FTP_TLS(FTP):
+ '''A FTP subclass which adds TLS support to FTP as described
+ in RFC-4217.
+
+ Connect as usual to port 21 implicitly securing the FTP control
+ connection before authenticating.
+
+ Securing the data connection requires user to explicitly ask
+ for it by calling prot_p() method.
+
+ Usage example:
+ >>> from ftplib import FTP_TLS
+ >>> ftps = FTP_TLS('ftp.python.org')
+ >>> ftps.login() # login anonymously previously securing control channel
+ '230 Guest login ok, access restrictions apply.'
+ >>> ftps.prot_p() # switch to secure data connection
+ '200 Protection level set to P'
+ >>> ftps.retrlines('LIST') # list directory content securely
+ total 9
+ drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .
+ drwxr-xr-x 8 root wheel 1024 Jan 3 1994 ..
+ drwxr-xr-x 2 root wheel 1024 Jan 3 1994 bin
+ drwxr-xr-x 2 root wheel 1024 Jan 3 1994 etc
+ d-wxrwxr-x 2 ftp wheel 1024 Sep 5 13:43 incoming
+ drwxr-xr-x 2 root wheel 1024 Nov 17 1993 lib
+ drwxr-xr-x 6 1094 wheel 1024 Sep 13 19:07 pub
+ drwxr-xr-x 3 root wheel 1024 Jan 3 1994 usr
+ -rw-r--r-- 1 root root 312 Aug 1 1994 welcome.msg
+ '226 Transfer complete.'
+ >>> ftps.quit()
+ '221 Goodbye.'
+ >>>
+ '''
+ ssl_version = ssl.PROTOCOL_TLSv1
+
+ def __init__(self, host='', user='', passwd='', acct='', keyfile=None,
+ certfile=None, context=None,
+ timeout=_GLOBAL_DEFAULT_TIMEOUT):
+ if context is not None and keyfile is not None:
+ raise ValueError("context and keyfile arguments are mutually "
+ "exclusive")
+ if context is not None and certfile is not None:
+ raise ValueError("context and certfile arguments are mutually "
+ "exclusive")
+ self.keyfile = keyfile
+ self.certfile = certfile
+ self.context = context
+ self._prot_p = False
+ FTP.__init__(self, host, user, passwd, acct, timeout)
+
+ def login(self, user='', passwd='', acct='', secure=True):
+ if secure and not isinstance(self.sock, ssl.SSLSocket):
+ self.auth()
+ return FTP.login(self, user, passwd, acct)
+
+ def auth(self):
+ '''Set up secure control connection by using TLS/SSL.'''
+ if isinstance(self.sock, ssl.SSLSocket):
+ raise ValueError("Already using TLS")
+ if self.ssl_version == ssl.PROTOCOL_TLSv1:
+ resp = self.voidcmd('AUTH TLS')
+ else:
+ resp = self.voidcmd('AUTH SSL')
+ if self.context is not None:
+ self.sock = self.context.wrap_socket(self.sock)
+ else:
+ self.sock = ssl.wrap_socket(self.sock, self.keyfile,
+ self.certfile,
+ ssl_version=self.ssl_version)
+ self.file = self.sock.makefile(mode='r', encoding=self.encoding)
+ return resp
+
+ def prot_p(self):
+ '''Set up secure data connection.'''
+ # PROT defines whether or not the data channel is to be protected.
+ # Though RFC-2228 defines four possible protection levels,
+ # RFC-4217 only recommends two, Clear and Private.
+ # Clear (PROT C) means that no security is to be used on the
+ # data-channel, Private (PROT P) means that the data-channel
+ # should be protected by TLS.
+ # PBSZ command MUST still be issued, but must have a parameter of
+ # '0' to indicate that no buffering is taking place and the data
+ # connection should not be encapsulated.
+ self.voidcmd('PBSZ 0')
+ resp = self.voidcmd('PROT P')
+ self._prot_p = True
+ return resp
+
+ def prot_c(self):
+ '''Set up clear text data connection.'''
+ resp = self.voidcmd('PROT C')
+ self._prot_p = False
+ return resp
+
+ # --- Overridden FTP methods
+
+ def ntransfercmd(self, cmd, rest=None):
+ conn, size = FTP.ntransfercmd(self, cmd, rest)
+ if self._prot_p:
+ if self.context is not None:
+ conn = self.context.wrap_socket(conn)
+ else:
+ conn = ssl.wrap_socket(conn, self.keyfile, self.certfile,
+ ssl_version=self.ssl_version)
+ return conn, size
+
+ def retrbinary(self, cmd, callback, blocksize=8192, rest=None):
+ self.voidcmd('TYPE I')
+ conn = self.transfercmd(cmd, rest)
+ try:
+ while 1:
+ data = conn.recv(blocksize)
+ if not data:
+ break
+ callback(data)
+ # shutdown ssl layer
+ if isinstance(conn, ssl.SSLSocket):
+ conn.unwrap()
+ finally:
+ conn.close()
+ return self.voidresp()
+
+ def retrlines(self, cmd, callback = None):
+ if callback is None: callback = print_line
+ resp = self.sendcmd('TYPE A')
+ conn = self.transfercmd(cmd)
+ fp = conn.makefile('r', encoding=self.encoding)
+ try:
+ while 1:
+ line = fp.readline()
+ if self.debugging > 2: print('*retr*', repr(line))
+ if not line:
+ break
+ if line[-2:] == CRLF:
+ line = line[:-2]
+ elif line[-1:] == '\n':
+ line = line[:-1]
+ callback(line)
+ # shutdown ssl layer
+ if isinstance(conn, ssl.SSLSocket):
+ conn.unwrap()
+ finally:
+ fp.close()
+ conn.close()
+ return self.voidresp()
+
+ def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
+ self.voidcmd('TYPE I')
+ conn = self.transfercmd(cmd, rest)
+ try:
+ while 1:
+ buf = fp.read(blocksize)
+ if not buf: break
+ conn.sendall(buf)
+ if callback: callback(buf)
+ # shutdown ssl layer
+ if isinstance(conn, ssl.SSLSocket):
+ conn.unwrap()
+ finally:
+ conn.close()
+ return self.voidresp()
+
+ def storlines(self, cmd, fp, callback=None):
+ self.voidcmd('TYPE A')
+ conn = self.transfercmd(cmd)
+ try:
+ while 1:
+ buf = fp.readline()
+ if not buf: break
+ if buf[-2:] != B_CRLF:
+ if buf[-1] in B_CRLF: buf = buf[:-1]
+ buf = buf + B_CRLF
+ conn.sendall(buf)
+ if callback: callback(buf)
+ # shutdown ssl layer
+ if isinstance(conn, ssl.SSLSocket):
+ conn.unwrap()
+ finally:
+ conn.close()
+ return self.voidresp()
+
+ __all__.append('FTP_TLS')
+ all_errors = (Error, IOError, EOFError, ssl.SSLError)
+
+
_150_re = None
def parse150(resp):
@@ -689,9 +893,9 @@ def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
# transfer request.
# So: STOR before RETR, because here the target is a "user".
treply = target.sendcmd('STOR ' + targetname)
- if treply[:3] not in ('125', '150'): raise error_proto # RFC 959
+ if treply[:3] not in {'125', '150'}: raise error_proto # RFC 959
sreply = source.sendcmd('RETR ' + sourcename)
- if sreply[:3] not in ('125', '150'): raise error_proto # RFC 959
+ if sreply[:3] not in {'125', '150'}: raise error_proto # RFC 959
source.voidresp()
target.voidresp()
diff --git a/Lib/functools.py b/Lib/functools.py
index 103dd426e3..03de69ae16 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -4,10 +4,19 @@
# to allow utilities written in Python to be added
# to the functools module.
# Written by Nick Coghlan <ncoghlan at gmail.com>
-# Copyright (C) 2006 Python Software Foundation.
+# and Raymond Hettinger <python at rcn.com>
+# Copyright (C) 2006-2010 Python Software Foundation.
# See C source code for _functools credits/copyright
+__all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES',
+ 'total_ordering', 'cmp_to_key', 'lru_cache', 'reduce', 'partial']
+
from _functools import partial, reduce
+from collections import OrderedDict, namedtuple
+try:
+ from _thread import allocate_lock as Lock
+except:
+ from _dummy_thread import allocate_lock as Lock
# update_wrapper() and wraps() are tools to help write
# wrapper functions that can handle naive introspection
@@ -29,9 +38,14 @@ def update_wrapper(wrapper,
are updated with the corresponding attribute from the wrapped
function (defaults to functools.WRAPPER_UPDATES)
"""
+ wrapper.__wrapped__ = wrapped
for attr in assigned:
- if hasattr(wrapped, attr):
- setattr(wrapper, attr, getattr(wrapped, attr))
+ try:
+ value = getattr(wrapped, attr)
+ except AttributeError:
+ pass
+ else:
+ setattr(wrapper, attr, value)
for attr in updated:
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
# Return the wrapper so this can be used as a decorator via partial()
@@ -50,3 +64,141 @@ def wraps(wrapped,
"""
return partial(update_wrapper, wrapped=wrapped,
assigned=assigned, updated=updated)
+
+def total_ordering(cls):
+ """Class decorator that fills in missing ordering methods"""
+ convert = {
+ '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
+ ('__le__', lambda self, other: self < other or self == other),
+ ('__ge__', lambda self, other: not self < other)],
+ '__le__': [('__ge__', lambda self, other: not self <= other or self == other),
+ ('__lt__', lambda self, other: self <= other and not self == other),
+ ('__gt__', lambda self, other: not self <= other)],
+ '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
+ ('__ge__', lambda self, other: self > other or self == other),
+ ('__le__', lambda self, other: not self > other)],
+ '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
+ ('__gt__', lambda self, other: self >= other and not self == other),
+ ('__lt__', lambda self, other: not self >= other)]
+ }
+ # Find user-defined comparisons (not those inherited from object).
+ roots = [op for op in convert if getattr(cls, op, None) is not getattr(object, op, None)]
+ if not roots:
+ raise ValueError('must define at least one ordering operation: < > <= >=')
+ root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
+ for opname, opfunc in convert[root]:
+ if opname not in roots:
+ opfunc.__name__ = opname
+ opfunc.__doc__ = getattr(int, opname).__doc__
+ setattr(cls, opname, opfunc)
+ return cls
+
+def cmp_to_key(mycmp):
+ """Convert a cmp= function into a key= function"""
+ class K(object):
+ def __init__(self, obj, *args):
+ self.obj = obj
+ def __lt__(self, other):
+ return mycmp(self.obj, other.obj) < 0
+ def __gt__(self, other):
+ return mycmp(self.obj, other.obj) > 0
+ def __eq__(self, other):
+ return mycmp(self.obj, other.obj) == 0
+ def __le__(self, other):
+ return mycmp(self.obj, other.obj) <= 0
+ def __ge__(self, other):
+ return mycmp(self.obj, other.obj) >= 0
+ def __ne__(self, other):
+ return mycmp(self.obj, other.obj) != 0
+ def __hash__(self):
+ raise TypeError('hash not implemented')
+ return K
+
+_CacheInfo = namedtuple("CacheInfo", "hits misses maxsize currsize")
+
+def lru_cache(maxsize=100):
+ """Least-recently-used cache decorator.
+
+ If *maxsize* is set to None, the LRU features are disabled and the cache
+ can grow without bound.
+
+ Arguments to the cached function must be hashable.
+
+ View the cache statistics named tuple (hits, misses, maxsize, currsize) with
+ f.cache_info(). Clear the cache and statistics with f.cache_clear().
+ Access the underlying function with f.__wrapped__.
+
+ See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
+
+ """
+ # Users should only access the lru_cache through its public API:
+ # cache_info, cache_clear, and f.__wrapped__
+ # The internals of the lru_cache are encapsulated for thread safety and
+ # to allow the implementation to change (including a possible C version).
+
+ def decorating_function(user_function,
+ tuple=tuple, sorted=sorted, len=len, KeyError=KeyError):
+
+ hits = misses = 0
+ kwd_mark = object() # separates positional and keyword args
+ lock = Lock() # needed because ordereddicts aren't threadsafe
+
+ if maxsize is None:
+ cache = dict() # simple cache without ordering or size limit
+
+ @wraps(user_function)
+ def wrapper(*args, **kwds):
+ nonlocal hits, misses
+ key = args
+ if kwds:
+ key += (kwd_mark,) + tuple(sorted(kwds.items()))
+ try:
+ result = cache[key]
+ hits += 1
+ except KeyError:
+ result = user_function(*args, **kwds)
+ cache[key] = result
+ misses += 1
+ return result
+ else:
+ cache = OrderedDict() # ordered least recent to most recent
+ cache_popitem = cache.popitem
+ cache_renew = cache.move_to_end
+
+ @wraps(user_function)
+ def wrapper(*args, **kwds):
+ nonlocal hits, misses
+ key = args
+ if kwds:
+ key += (kwd_mark,) + tuple(sorted(kwds.items()))
+ try:
+ with lock:
+ result = cache[key]
+ cache_renew(key) # record recent use of this key
+ hits += 1
+ except KeyError:
+ result = user_function(*args, **kwds)
+ with lock:
+ cache[key] = result # record recent use of this key
+ misses += 1
+ if len(cache) > maxsize:
+ cache_popitem(0) # purge least recently used cache entry
+ return result
+
+ def cache_info():
+ """Report cache statistics"""
+ with lock:
+ return _CacheInfo(hits, misses, maxsize, len(cache))
+
+ def cache_clear():
+ """Clear the cache and cache statistics"""
+ nonlocal hits, misses
+ with lock:
+ cache.clear()
+ hits = misses = 0
+
+ wrapper.cache_info = cache_info
+ wrapper.cache_clear = cache_clear
+ return wrapper
+
+ return decorating_function
diff --git a/Lib/genericpath.py b/Lib/genericpath.py
index 41ad234829..2174187a03 100644
--- a/Lib/genericpath.py
+++ b/Lib/genericpath.py
@@ -15,7 +15,7 @@ __all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime',
def exists(path):
"""Test whether a path exists. Returns False for broken symbolic links"""
try:
- st = os.stat(path)
+ os.stat(path)
except os.error:
return False
return True
diff --git a/Lib/getopt.py b/Lib/getopt.py
index ac77126acf..980861d251 100644
--- a/Lib/getopt.py
+++ b/Lib/getopt.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""Parser for command line options.
This module helps scripts to parse the command line arguments in
diff --git a/Lib/gettext.py b/Lib/gettext.py
index d5321b8451..256e331eba 100644
--- a/Lib/gettext.py
+++ b/Lib/gettext.py
@@ -46,7 +46,7 @@ internationalized, to the local language and cultural habits.
# find this format documented anywhere.
-import locale, copy, os, re, struct, sys
+import locale, copy, io, os, re, struct, sys
from errno import ENOENT
@@ -58,28 +58,13 @@ __all__ = ['NullTranslations', 'GNUTranslations', 'Catalog',
_default_localedir = os.path.join(sys.prefix, 'share', 'locale')
-def test(condition, true, false):
- """
- Implements the C expression:
-
- condition ? true : false
-
- Required to correctly interpret plural forms.
- """
- if condition:
- return true
- else:
- return false
-
-
def c2py(plural):
"""Gets a C expression as used in PO files for plural forms and returns a
Python lambda function that implements an equivalent expression.
"""
# Security check, allow only the "n" identifier
- from io import StringIO
import token, tokenize
- tokens = tokenize.generate_tokens(StringIO(plural).readline)
+ tokens = tokenize.generate_tokens(io.StringIO(plural).readline)
try:
danger = [x for x in tokens if x[0] == token.NAME and x[1] != 'n']
except tokenize.TokenError:
@@ -96,11 +81,11 @@ def c2py(plural):
plural = expr.sub(' not \\1', plural)
# Regular expression and replacement function used to transform
- # "a?b:c" to "test(a,b,c)".
+ # "a?b:c" to "b if a else c".
expr = re.compile(r'(.*?)\?(.*?):(.*)')
def repl(x):
- return "test(%s, %s, %s)" % (x.group(1), x.group(2),
- expr.sub(repl, x.group(3)))
+ return "(%s if %s else %s)" % (x.group(2), x.group(1),
+ expr.sub(repl, x.group(3)))
# Code to transform the plural expression, taking care of parentheses
stack = ['']
@@ -123,36 +108,35 @@ def c2py(plural):
-def _expand_lang(locale):
- from locale import normalize
- locale = normalize(locale)
+def _expand_lang(loc):
+ loc = locale.normalize(loc)
COMPONENT_CODESET = 1 << 0
COMPONENT_TERRITORY = 1 << 1
COMPONENT_MODIFIER = 1 << 2
# split up the locale into its base components
mask = 0
- pos = locale.find('@')
+ pos = loc.find('@')
if pos >= 0:
- modifier = locale[pos:]
- locale = locale[:pos]
+ modifier = loc[pos:]
+ loc = loc[:pos]
mask |= COMPONENT_MODIFIER
else:
modifier = ''
- pos = locale.find('.')
+ pos = loc.find('.')
if pos >= 0:
- codeset = locale[pos:]
- locale = locale[:pos]
+ codeset = loc[pos:]
+ loc = loc[:pos]
mask |= COMPONENT_CODESET
else:
codeset = ''
- pos = locale.find('_')
+ pos = loc.find('_')
if pos >= 0:
- territory = locale[pos:]
- locale = locale[:pos]
+ territory = loc[pos:]
+ loc = loc[:pos]
mask |= COMPONENT_TERRITORY
else:
territory = ''
- language = locale
+ language = loc
ret = []
for i in range(mask+1):
if not (i & ~mask): # if all components for this combo exist ...
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 8a2a7184df..ba2149ebf9 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -5,11 +5,12 @@ but random access is not allowed."""
# based on Andrew Kuchling's minigzip.py distributed with the zlib module
-import struct, sys, time
+import struct, sys, time, os
import zlib
import builtins
+import io
-__all__ = ["GzipFile","open"]
+__all__ = ["GzipFile", "open", "compress", "decompress"]
FTEXT, FHCRC, FEXTRA, FNAME, FCOMMENT = 1, 2, 4, 8, 16
@@ -44,7 +45,63 @@ def open(filename, mode="rb", compresslevel=9):
"""
return GzipFile(filename, mode, compresslevel)
-class GzipFile:
+class _PaddedFile:
+ """Minimal read-only file object that prepends a string to the contents
+ of an actual file. Shouldn't be used outside of gzip.py, as it lacks
+ essential functionality."""
+
+ def __init__(self, f, prepend=b''):
+ self._buffer = prepend
+ self._length = len(prepend)
+ self.file = f
+ self._read = 0
+
+ def read(self, size):
+ if self._read is None:
+ return self.file.read(size)
+ if self._read + size <= self._length:
+ read = self._read
+ self._read += size
+ return self._buffer[read:self._read]
+ else:
+ read = self._read
+ self._read = None
+ return self._buffer[read:] + \
+ self.file.read(size-self._length+read)
+
+ def prepend(self, prepend=b'', readprevious=False):
+ if self._read is None:
+ self._buffer = prepend
+ elif readprevious and len(prepend) <= self._read:
+ self._read -= len(prepend)
+ return
+ else:
+ self._buffer = self._buffer[read:] + prepend
+ self._length = len(self._buffer)
+ self._read = 0
+
+ def unused(self):
+ if self._read is None:
+ return b''
+ return self._buffer[self._read:]
+
+ def seek(self, offset, whence=0):
+ # This is only ever called with offset=whence=0
+ if whence == 1 and self._read is not None:
+ if 0 <= offset + self._read <= self._length:
+ self._read += offset
+ return
+ else:
+ offset += self._length - self._read
+ self._read = None
+ self._buffer = None
+ return self.file.seek(offset, whence)
+
+ def __getattr__(self, name):
+ return getattr(self.file, name)
+
+
+class GzipFile(io.BufferedIOBase):
"""The GzipFile class simulates most of the methods of a file object with
the exception of the readinto() and truncate() methods.
@@ -109,11 +166,16 @@ class GzipFile:
self.mode = READ
# Set flag indicating start of a new member
self._new_member = True
+ # Buffer data read from gzip file. extrastart is offset in
+ # stream where buffer starts. extrasize is number of
+ # bytes remaining in buffer from current stream position.
self.extrabuf = b""
self.extrasize = 0
+ self.extrastart = 0
self.name = filename
# Starts small, scales exponentially
self.min_readsize = 100
+ fileobj = _PaddedFile(fileobj)
elif mode[0:1] == 'w' or mode[0:1] == 'a':
self.mode = WRITE
@@ -129,7 +191,6 @@ class GzipFile:
self.fileobj = fileobj
self.offset = 0
self.mtime = mtime
- self.closed = False
if self.mode == WRITE:
self._write_gzip_header()
@@ -143,7 +204,10 @@ class GzipFile:
return self.name
def __repr__(self):
- s = repr(self.fileobj)
+ fileobj = self.fileobj
+ if isinstance(fileobj, _PaddedFile):
+ fileobj = fileobj.file
+ s = repr(fileobj)
return '<gzip ' + s[1:-1] + ' ' + hex(id(self)) + '>'
def _check_closed(self):
@@ -166,7 +230,8 @@ class GzipFile:
try:
# RFC 1952 requires the FNAME field to be Latin-1. Do not
# include filenames that cannot be represented that way.
- fname = self.name.encode('latin-1')
+ fname = os.path.basename(self.name)
+ fname = fname.encode('latin-1')
if fname.endswith(b'.gz'):
fname = fname[:-3]
except UnicodeEncodeError:
@@ -190,6 +255,9 @@ class GzipFile:
def _read_gzip_header(self):
magic = self.fileobj.read(2)
+ if magic == b'':
+ raise EOFError("Reached EOF")
+
if magic != b'\037\213':
raise IOError('Not a gzipped file')
method = ord( self.fileobj.read(1) )
@@ -221,6 +289,10 @@ class GzipFile:
if flag & FHCRC:
self.fileobj.read(2) # Read & discard the 16-bit header CRC
+ unused = self.fileobj.unused()
+ if unused:
+ uncompress = self.decompress.decompress(unused)
+ self._add_read_data(uncompress)
def write(self,data):
self._check_closed()
@@ -230,12 +302,19 @@ class GzipFile:
if self.fileobj is None:
raise ValueError("write() on closed GzipFile object")
+
+ # Convert data type if called by io.BufferedWriter.
+ if isinstance(data, memoryview):
+ data = data.tobytes()
+
if len(data) > 0:
self.size = self.size + len(data)
self.crc = zlib.crc32(data, self.crc) & 0xffffffff
self.fileobj.write( self.compress.compress(data) )
self.offset += len(data)
+ return len(data)
+
def read(self, size=-1):
self._check_closed()
if self.mode != READ:
@@ -262,15 +341,36 @@ class GzipFile:
if size > self.extrasize:
size = self.extrasize
- chunk = self.extrabuf[:size]
- self.extrabuf = self.extrabuf[size:]
+ offset = self.offset - self.extrastart
+ chunk = self.extrabuf[offset: offset + size]
self.extrasize = self.extrasize - size
self.offset += size
return chunk
+ def peek(self, n):
+ if self.mode != READ:
+ import errno
+ raise IOError(errno.EBADF, "peek() on write-only GzipFile object")
+
+ # Do not return ridiculously small buffers, for one common idiom
+ # is to call peek(1) and expect more bytes in return.
+ if n < 100:
+ n = 100
+ if self.extrasize == 0:
+ if self.fileobj is None:
+ return b''
+ try:
+ # 1024 is the same buffering heuristic used in read()
+ self._read(max(n, 1024))
+ except EOFError:
+ pass
+ offset = self.offset - self.extrastart
+ remaining = self.extrasize
+ assert remaining == len(self.extrabuf) - offset
+ return self.extrabuf[offset:offset + n]
+
def _unread(self, buf):
- self.extrabuf = buf + self.extrabuf
self.extrasize = len(buf) + self.extrasize
self.offset -= len(buf)
@@ -281,16 +381,6 @@ class GzipFile:
if self._new_member:
# If the _new_member flag is set, we have to
# jump to the next member, if there is one.
- #
- # First, check if we're at the end of the file;
- # if so, it's time to stop; no more members to read.
- pos = self.fileobj.tell() # Save current position
- self.fileobj.seek(0, 2) # Seek to end of file
- if pos == self.fileobj.tell():
- raise EOFError("Reached EOF")
- else:
- self.fileobj.seek( pos ) # Return to original position
-
self._init_read()
self._read_gzip_header()
self.decompress = zlib.decompressobj(-zlib.MAX_WBITS)
@@ -304,6 +394,9 @@ class GzipFile:
if buf == b"":
uncompress = self.decompress.flush()
+ # Prepend the already read bytes to the fileobj to they can be
+ # seen by _read_eof()
+ self.fileobj.prepend(self.decompress.unused_data, True)
self._read_eof()
self._add_read_data( uncompress )
raise EOFError('Reached EOF')
@@ -315,10 +408,9 @@ class GzipFile:
# Ending case: we've come to the end of a member in the file,
# so seek back to the start of the unused data, finish up
# this member, and read a new gzip header.
- # (The number of bytes to seek back is the length of the unused
- # data, minus 8 because _read_eof() will rewind a further 8 bytes)
- self.fileobj.seek( -len(self.decompress.unused_data)+8, 1)
-
+ # Prepend the already read bytes to the fileobj to they can be
+ # seen by _read_eof() and _read_gzip_header()
+ self.fileobj.prepend(self.decompress.unused_data, True)
# Check the CRC and file size, and set the flag so we read
# a new member on the next call
self._read_eof()
@@ -326,17 +418,17 @@ class GzipFile:
def _add_read_data(self, data):
self.crc = zlib.crc32(data, self.crc) & 0xffffffff
- self.extrabuf = self.extrabuf + data
+ offset = self.offset - self.extrastart
+ self.extrabuf = self.extrabuf[offset:] + data
self.extrasize = self.extrasize + len(data)
+ self.extrastart = self.offset
self.size = self.size + len(data)
def _read_eof(self):
- # We've read to the end of the file, so we have to rewind in order
- # to reread the 8 bytes containing the CRC and the file size.
+ # We've read to the end of the file
# We check the that the computed CRC and size of the
# uncompressed data matches the stored values. Note that the size
# stored is the true file size mod 2**32.
- self.fileobj.seek(-8, 1)
crc32 = read32(self.fileobj)
isize = read32(self.fileobj) # may exceed 2GB
if crc32 != self.crc:
@@ -345,6 +437,19 @@ class GzipFile:
elif isize != (self.size & 0xffffffff):
raise IOError("Incorrect length of data produced")
+ # Gzip files can be padded with zeroes and still have archives.
+ # Consume all zero bytes and set the file position to the first
+ # non-zero byte. See http://www.gzip.org/#faq8
+ c = b"\x00"
+ while c == b"\x00":
+ c = self.fileobj.read(1)
+ if c:
+ self.fileobj.prepend(c, True)
+
+ @property
+ def closed(self):
+ return self.fileobj is None
+
def close(self):
if self.fileobj is None:
return
@@ -359,16 +464,6 @@ class GzipFile:
if self.myfileobj:
self.myfileobj.close()
self.myfileobj = None
- self.closed = True
-
- def __del__(self):
- try:
- if (self.myfileobj is None and
- self.fileobj is None):
- return
- except AttributeError:
- return
- self.close()
def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH):
self._check_closed()
@@ -385,13 +480,6 @@ class GzipFile:
"""
return self.fileobj.fileno()
- def isatty(self):
- return False
-
- def tell(self):
- self._check_closed()
- return self.offset
-
def rewind(self):
'''Return the uncompressed stream file position indicator to the
beginning of the file'''
@@ -401,8 +489,18 @@ class GzipFile:
self._new_member = True
self.extrabuf = b""
self.extrasize = 0
+ self.extrastart = 0
self.offset = 0
+ def readable(self):
+ return self.mode == READ
+
+ def writable(self):
+ return self.mode == WRITE
+
+ def seekable(self):
+ return True
+
def seek(self, offset, whence=0):
if whence:
if whence == 1:
@@ -426,8 +524,18 @@ class GzipFile:
self.read(1024)
self.read(count % 1024)
+ return self.offset
+
def readline(self, size=-1):
if size < 0:
+ # Shortcut common case - newline found in buffer.
+ offset = self.offset - self.extrastart
+ i = self.extrabuf.find(b'\n', offset) + 1
+ if i > 0:
+ self.extrasize -= i - offset
+ self.offset += i - offset
+ return self.extrabuf[offset: i]
+
size = sys.maxsize
readsize = self.min_readsize
else:
@@ -457,41 +565,22 @@ class GzipFile:
self.min_readsize = min(readsize, self.min_readsize * 2, 512)
return b''.join(bufs) # Return resulting line
- def readlines(self, sizehint=0):
- # Negative numbers result in reading all the lines
- if sizehint <= 0:
- sizehint = sys.maxsize
- L = []
- while sizehint > 0:
- line = self.readline()
- if line == b"":
- break
- L.append(line)
- sizehint = sizehint - len(line)
-
- return L
-
- def writelines(self, L):
- for line in L:
- self.write(line)
-
- def __iter__(self):
- return self
- def __next__(self):
- line = self.readline()
- if line:
- return line
- else:
- raise StopIteration
-
- def __enter__(self):
- if self.fileobj is None:
- raise ValueError("I/O operation on closed GzipFile object")
- return self
-
- def __exit__(self, *args):
- self.close()
+def compress(data, compresslevel=9):
+ """Compress data in one shot and return the compressed string.
+ Optional argument is the compression level, in range of 1-9.
+ """
+ buf = io.BytesIO()
+ with GzipFile(fileobj=buf, mode='wb', compresslevel=compresslevel) as f:
+ f.write(data)
+ return buf.getvalue()
+
+def decompress(data):
+ """Decompress a gzip compressed string in one shot.
+ Return the decompressed string.
+ """
+ with GzipFile(fileobj=io.BytesIO(data)) as f:
+ return f.read()
def _test():
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
index 34ed195cd0..0d7e3250d5 100644
--- a/Lib/hashlib.py
+++ b/Lib/hashlib.py
@@ -1,6 +1,4 @@
-# $Id$
-#
-# Copyright (C) 2005-2007 Gregory P. Smith (greg@krypto.org)
+# Copyright (C) 2005-2010 Gregory P. Smith (greg@krypto.org)
# Licensed to PSF under a Contributor Agreement.
#
@@ -15,8 +13,9 @@ than using new(name):
md5(), sha1(), sha224(), sha256(), sha384(), and sha512()
-More algorithms may be available on your platform but the above are
-guaranteed to exist.
+More algorithms may be available on your platform but the above are guaranteed
+to exist. See the algorithms_guaranteed and algorithms_available attributes
+to find out what algorithm names can be passed to new().
NOTE: If you want the adler32 or crc32 hash functions they are available in
the zlib module.
@@ -53,6 +52,16 @@ More condensed:
"""
+# This tuple and __get_builtin_constructor() must be modified if a new
+# always available algorithm is added.
+__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
+
+algorithms_guaranteed = set(__always_supported)
+algorithms_available = set(__always_supported)
+
+__all__ = __always_supported + ('new', 'algorithms_guaranteed',
+ 'algorithms_available')
+
def __get_builtin_constructor(name):
if name in ('SHA1', 'sha1'):
@@ -76,7 +85,19 @@ def __get_builtin_constructor(name):
elif bs == '384':
return _sha512.sha384
- raise ValueError("unsupported hash type")
+ raise ValueError('unsupported hash type %s' % name)
+
+
+def __get_openssl_constructor(name):
+ try:
+ f = getattr(_hashlib, 'openssl_' + name)
+ # Allow the C module to raise ValueError. The function will be
+ # defined but the hash not actually available thanks to OpenSSL.
+ f()
+ # Use the C function directly (very fast)
+ return f
+ except (AttributeError, ValueError):
+ return __get_builtin_constructor(name)
def __py_new(name, data=b''):
@@ -102,39 +123,23 @@ def __hash_new(name, data=b''):
try:
import _hashlib
- # use the wrapper of the C implementation
new = __hash_new
-
- for opensslFuncName in filter(lambda n: n.startswith('openssl_'), dir(_hashlib)):
- funcName = opensslFuncName[len('openssl_'):]
- try:
- # try them all, some may not work due to the OpenSSL
- # version not supporting that algorithm.
- f = getattr(_hashlib, opensslFuncName)
- f()
- # Use the C function directly (very fast)
- exec(funcName + ' = f')
- except ValueError:
- try:
- # Use the builtin implementation directly (fast)
- exec(funcName + ' = __get_builtin_constructor(funcName)')
- except ValueError:
- # this one has no builtin implementation, don't define it
- pass
- # clean up our locals
- del f
- del opensslFuncName
- del funcName
-
+ __get_hash = __get_openssl_constructor
+ algorithms_available = algorithms_available.union(
+ _hashlib.openssl_md_meth_names)
except ImportError:
- # We don't have the _hashlib OpenSSL module?
- # use the built in legacy interfaces via a wrapper function
new = __py_new
+ __get_hash = __get_builtin_constructor
+
+for __func_name in __always_supported:
+ # try them all, some may not work due to the OpenSSL
+ # version not supporting that algorithm.
+ try:
+ globals()[__func_name] = __get_hash(__func_name)
+ except ValueError:
+ import logging
+ logging.exception('code for hash %s was not found.', __func_name)
- # lookup the C function to use directly for the named constructors
- md5 = __get_builtin_constructor('md5')
- sha1 = __get_builtin_constructor('sha1')
- sha224 = __get_builtin_constructor('sha224')
- sha256 = __get_builtin_constructor('sha256')
- sha384 = __get_builtin_constructor('sha384')
- sha512 = __get_builtin_constructor('sha512')
+# Cleanup locals()
+del __always_supported, __func_name, __get_hash
+del __py_new, __hash_new, __get_openssl_constructor
diff --git a/Lib/heapq.py b/Lib/heapq.py
index b74818e2ba..464663a78a 100644
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -1,5 +1,3 @@
-# -*- coding: latin-1 -*-
-
"""Heap queue algorithm (a.k.a. priority queue).
Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for
@@ -34,7 +32,7 @@ maintains the heap invariant!
__about__ = """Heap queues
-[explanation by François Pinard]
+[explanation by François Pinard]
Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for
all k, counting elements from 0. For the sake of comparison,
diff --git a/Lib/hmac.py b/Lib/hmac.py
index 0f59fd4847..e878e1a809 100644
--- a/Lib/hmac.py
+++ b/Lib/hmac.py
@@ -12,10 +12,6 @@ trans_36 = bytes((x ^ 0x36) for x in range(256))
# hashing module used. Use digest_size from the instance of HMAC instead.
digest_size = None
-# A unique object passed by HMAC.copy() to the HMAC constructor, in order
-# that the latter return very quickly. HMAC("") in contrast is quite
-# expensive.
-_secret_backdoor_key = []
class HMAC:
"""RFC 2104 HMAC class. Also complies with RFC 4231.
@@ -36,9 +32,6 @@ class HMAC:
Note: key and msg must be bytes objects.
"""
- if key is _secret_backdoor_key: # cheap
- return
-
if not isinstance(key, bytes):
raise TypeError("expected bytes, but got %r" % type(key).__name__)
@@ -58,8 +51,6 @@ class HMAC:
if hasattr(self.inner, 'block_size'):
blocksize = self.inner.block_size
if blocksize < 16:
- # Very low blocksize, most likely a legacy value like
- # Lib/sha.py and Lib/md5.py have.
_warnings.warn('block_size of %d seems too small; using our '
'default of %d.' % (blocksize, self.blocksize),
RuntimeWarning, 2)
@@ -79,9 +70,6 @@ class HMAC:
if msg is not None:
self.update(msg)
-## def clear(self):
-## raise NotImplementedError, "clear() method not available in HMAC."
-
def update(self, msg):
"""Update this hashing object with the string msg.
"""
@@ -94,7 +82,8 @@ class HMAC:
An update to this copy won't affect the original object.
"""
- other = self.__class__(_secret_backdoor_key)
+ # Call __new__ directly to avoid the expensive __init__.
+ other = self.__class__.__new__(self.__class__)
other.digest_cons = self.digest_cons
other.digest_size = self.digest_size
other.inner = self.inner.copy()
diff --git a/Lib/html/__init__.py b/Lib/html/__init__.py
index 196d378857..335d214828 100644
--- a/Lib/html/__init__.py
+++ b/Lib/html/__init__.py
@@ -1 +1,20 @@
-# This directory is a Python package.
+"""
+General functions for HTML manipulation.
+"""
+
+
+_escape_map = {ord('&'): '&amp;', ord('<'): '&lt;', ord('>'): '&gt;'}
+_escape_map_full = {ord('&'): '&amp;', ord('<'): '&lt;', ord('>'): '&gt;',
+ ord('"'): '&quot;', ord('\''): '&#x27;'}
+
+# NB: this is a candidate for a bytes/string polymorphic interface
+
+def escape(s, quote=True):
+ """
+ Replace special characters "&", "<" and ">" to HTML-safe sequences.
+ If the optional flag quote is true (the default), the quotation mark
+ character (") is also translated.
+ """
+ if quote:
+ return s.translate(_escape_map_full)
+ return s.translate(_escape_map)
diff --git a/Lib/html/parser.py b/Lib/html/parser.py
index 3f68e189c4..21ebbc3eaf 100644
--- a/Lib/html/parser.py
+++ b/Lib/html/parser.py
@@ -24,10 +24,14 @@ starttagopen = re.compile('<[a-zA-Z]')
piclose = re.compile('>')
commentclose = re.compile(r'--\s*>')
tagfind = re.compile('[a-zA-Z][-.a-zA-Z0-9:_]*')
+# Note, the strict one of this pair isn't really strict, but we can't
+# make it correctly strict without breaking backward compatibility.
attrfind = re.compile(
r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*'
r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]*))?')
-
+attrfind_tolerant = re.compile(
+ r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*'
+ r'(\'[^\']*\'|"[^"]*"|[^>\s]*))?')
locatestarttagend = re.compile(r"""
<[a-zA-Z][-.a-zA-Z0-9:_]* # tag name
(?:\s+ # whitespace before attribute name
@@ -42,6 +46,21 @@ locatestarttagend = re.compile(r"""
)*
\s* # trailing whitespace
""", re.VERBOSE)
+locatestarttagend_tolerant = re.compile(r"""
+ <[a-zA-Z][-.a-zA-Z0-9:_]* # tag name
+ (?:\s* # optional whitespace before attribute name
+ (?:[a-zA-Z_][-.:a-zA-Z0-9_]* # attribute name
+ (?:\s*=\s* # value indicator
+ (?:'[^']*' # LITA-enclosed value
+ |\"[^\"]*\" # LIT-enclosed value
+ |[^'\">\s]+ # bare value
+ )
+ (?:\s*,)* # possibly followed by a comma
+ )?
+ )
+ )*
+ \s* # trailing whitespace
+""", re.VERBOSE)
endendtag = re.compile('>')
endtagfind = re.compile('</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')
@@ -86,9 +105,15 @@ class HTMLParser(_markupbase.ParserBase):
CDATA_CONTENT_ELEMENTS = ("script", "style")
+ def __init__(self, strict=True):
+ """Initialize and reset this instance.
- def __init__(self):
- """Initialize and reset this instance."""
+ If strict is set to True (the default), errors are raised when invalid
+ HTML is encountered. If set to False, an attempt is instead made to
+ continue parsing, making "best guesses" about the intended meaning, in
+ a fashion similar to what browsers typically do.
+ """
+ self.strict = strict
self.reset()
def reset(self):
@@ -160,9 +185,18 @@ class HTMLParser(_markupbase.ParserBase):
else:
break
if k < 0:
- if end:
+ if not end:
+ break
+ if self.strict:
self.error("EOF in middle of construct")
- break
+ k = rawdata.find('>', i + 1)
+ if k < 0:
+ k = rawdata.find('<', i + 1)
+ if k < 0:
+ k = i + 1
+ else:
+ k += 1
+ self.handle_data(rawdata[i:k])
i = self.updatepos(i, k)
elif startswith("&#", i):
match = charref.match(rawdata, i)
@@ -193,7 +227,12 @@ class HTMLParser(_markupbase.ParserBase):
if match:
# match.group() will contain at least 2 chars
if end and match.group() == rawdata[i:]:
- self.error("EOF in middle of entity or char ref")
+ if self.strict:
+ self.error("EOF in middle of entity or char ref")
+ else:
+ if k <= i:
+ k = n
+ i = self.updatepos(i, i + 1)
# incomplete
break
elif (i + 1) < n:
@@ -240,7 +279,10 @@ class HTMLParser(_markupbase.ParserBase):
self.lasttag = tag = rawdata[i+1:k].lower()
while k < endpos:
- m = attrfind.match(rawdata, k)
+ if self.strict:
+ m = attrfind.match(rawdata, k)
+ else:
+ m = attrfind_tolerant.search(rawdata, k)
if not m:
break
attrname, rest, attrvalue = m.group(1, 2, 3)
@@ -262,8 +304,11 @@ class HTMLParser(_markupbase.ParserBase):
- self.__starttag_text.rfind("\n")
else:
offset = offset + len(self.__starttag_text)
- self.error("junk characters in start tag: %r"
- % (rawdata[k:endpos][:20],))
+ if self.strict:
+ self.error("junk characters in start tag: %r"
+ % (rawdata[k:endpos][:20],))
+ self.handle_data(rawdata[i:endpos])
+ return endpos
if end.endswith('/>'):
# XHTML-style empty tag: <span attr="value" />
self.handle_startendtag(tag, attrs)
@@ -277,7 +322,10 @@ class HTMLParser(_markupbase.ParserBase):
# or -1 if incomplete.
def check_for_whole_start_tag(self, i):
rawdata = self.rawdata
- m = locatestarttagend.match(rawdata, i)
+ if self.strict:
+ m = locatestarttagend.match(rawdata, i)
+ else:
+ m = locatestarttagend_tolerant.match(rawdata, i)
if m:
j = m.end()
next = rawdata[j:j+1]
@@ -290,8 +338,13 @@ class HTMLParser(_markupbase.ParserBase):
# buffer boundary
return -1
# else bogus input
- self.updatepos(i, j + 1)
- self.error("malformed empty start tag")
+ if self.strict:
+ self.updatepos(i, j + 1)
+ self.error("malformed empty start tag")
+ if j > i:
+ return j
+ else:
+ return i + 1
if next == "":
# end of input
return -1
@@ -300,8 +353,13 @@ class HTMLParser(_markupbase.ParserBase):
# end of input in or before attribute value, or we have the
# '/' from a '/>' ending
return -1
- self.updatepos(i, j)
- self.error("malformed start tag")
+ if self.strict:
+ self.updatepos(i, j)
+ self.error("malformed start tag")
+ if j > i:
+ return j
+ else:
+ return i + 1
raise AssertionError("we should not get here!")
# Internal -- parse endtag, return end or -1 if incomplete
@@ -314,7 +372,15 @@ class HTMLParser(_markupbase.ParserBase):
j = match.end()
match = endtagfind.match(rawdata, i) # </ + tag + >
if not match:
- self.error("bad end tag: %r" % (rawdata[i:j],))
+ if self.strict:
+ self.error("bad end tag: %r" % (rawdata[i:j],))
+ k = rawdata.find('<', i + 1, j)
+ if k > i:
+ j = k
+ if j <= i:
+ j = i + 1
+ self.handle_data(rawdata[i:j])
+ return j
tag = match.group(1)
self.handle_endtag(tag.lower())
self.clear_cdata_mode()
@@ -358,7 +424,8 @@ class HTMLParser(_markupbase.ParserBase):
pass
def unknown_decl(self, data):
- self.error("unknown declaration: %r" % (data,))
+ if self.strict:
+ self.error("unknown declaration: %r" % (data,))
# Internal -- helper to remove special character quoting
entitydefs = None
diff --git a/Lib/http/client.py b/Lib/http/client.py
index 4a65125712..604577cd7b 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -71,6 +71,7 @@ import email.message
import io
import os
import socket
+import collections
from urllib.parse import urlsplit
import warnings
@@ -257,13 +258,10 @@ def parse_headers(fp, _class=HTTPMessage):
hstring = b''.join(headers).decode('iso-8859-1')
return email.parser.Parser(_class=_class).parsestr(hstring)
-class HTTPResponse(io.RawIOBase):
- # strict: If true, raise BadStatusLine if the status line can't be
- # parsed as a valid HTTP/1.0 or 1.1 status line. By default it is
- # false because it prevents clients from talking to HTTP/0.9
- # servers. Note that a response with a sufficiently corrupted
- # status line will look like an HTTP/0.9 response.
+_strict_sentinel = object()
+
+class HTTPResponse(io.RawIOBase):
# See RFC 2616 sec 19.6 and RFC 1945 sec 6 for details.
@@ -272,7 +270,7 @@ class HTTPResponse(io.RawIOBase):
# text following RFC 2047. The basic status line parsing only
# accepts iso-8859-1.
- def __init__(self, sock, debuglevel=0, strict=0, method=None, url=None):
+ def __init__(self, sock, debuglevel=0, strict=_strict_sentinel, method=None, url=None):
# If the response includes a content-length header, we need to
# make sure that the client doesn't read more than the
# specified number of bytes. If it does, it will block until
@@ -282,7 +280,10 @@ class HTTPResponse(io.RawIOBase):
# clients unless they know what they are doing.
self.fp = sock.makefile("rb")
self.debuglevel = debuglevel
- self.strict = strict
+ if strict is not _strict_sentinel:
+ warnings.warn("the 'strict' argument isn't supported anymore; "
+ "http.client now always assumes HTTP/1.x compliant servers.",
+ DeprecationWarning, 2)
self._method = method
# The HTTPResponse object is returned via urllib. The clients
@@ -304,8 +305,9 @@ class HTTPResponse(io.RawIOBase):
self.will_close = _UNKNOWN # conn will close at end of response
def _read_status(self):
- # Initialize with Simple-Response defaults.
- line = str(self.fp.readline(), "iso-8859-1")
+ line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
+ if len(line) > _MAXLINE:
+ raise LineTooLong("status line")
if self.debuglevel > 0:
print("reply:", repr(line))
if not line:
@@ -313,25 +315,17 @@ class HTTPResponse(io.RawIOBase):
# sending a valid response.
raise BadStatusLine(line)
try:
- [version, status, reason] = line.split(None, 2)
+ version, status, reason = line.split(None, 2)
except ValueError:
try:
- [version, status] = line.split(None, 1)
+ version, status = line.split(None, 1)
reason = ""
except ValueError:
- # empty version will cause next test to fail and status
- # will be treated as 0.9 response.
+ # empty version will cause next test to fail.
version = ""
if not version.startswith("HTTP/"):
- if self.strict:
- self.close()
- raise BadStatusLine(line)
- else:
- # Assume it's a Simple-Response from an 0.9 server.
- # We have to convert the first line back to raw bytes
- # because self.fp.readline() needs to return bytes.
- self.fp = LineAndFileWrapper(bytes(line, "ascii"), self.fp)
- return "HTTP/0.9", 200, ""
+ self.close()
+ raise BadStatusLine(line)
# The status code is a three-digit number
try:
@@ -365,22 +359,14 @@ class HTTPResponse(io.RawIOBase):
self.code = self.status = status
self.reason = reason.strip()
- if version == "HTTP/1.0":
+ if version in ("HTTP/1.0", "HTTP/0.9"):
+ # Some servers might still return "0.9", treat it as 1.0 anyway
self.version = 10
elif version.startswith("HTTP/1."):
self.version = 11 # use HTTP/1.1 code for HTTP/1.x where x>=1
- elif version == "HTTP/0.9":
- self.version = 9
else:
raise UnknownProtocol(version)
- if self.version == 9:
- self.length = None
- self.chunked = False
- self.will_close = True
- self.headers = self.msg = email.message_from_string('')
- return
-
self.headers = self.msg = parse_headers(self.fp)
if self.debuglevel > 0:
@@ -651,11 +637,15 @@ class HTTPConnection:
default_port = HTTP_PORT
auto_open = 1
debuglevel = 0
- strict = 0
- def __init__(self, host, port=None, strict=None,
- timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
+ def __init__(self, host, port=None, strict=_strict_sentinel,
+ timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None):
+ if strict is not _strict_sentinel:
+ warnings.warn("the 'strict' argument isn't supported anymore; "
+ "http.client now always assumes HTTP/1.x compliant servers.",
+ DeprecationWarning, 2)
self.timeout = timeout
+ self.source_address = source_address
self.sock = None
self._buffer = []
self.__response = None
@@ -666,10 +656,13 @@ class HTTPConnection:
self._tunnel_headers = {}
self._set_hostport(host, port)
- if strict is not None:
- self.strict = strict
- def _set_tunnel(self, host, port=None, headers=None):
+ def set_tunnel(self, host, port=None, headers=None):
+ """ Sets up the host and the port for the HTTP CONNECT Tunnelling.
+
+ The headers argument should be a mapping of extra HTTP headers
+ to send with the CONNECT request.
+ """
self._tunnel_host = host
self._tunnel_port = port
if headers:
@@ -704,12 +697,11 @@ class HTTPConnection:
self.send(connect_bytes)
for header, value in self._tunnel_headers.items():
header_str = "%s: %s\r\n" % (header, value)
- header_bytes = header_str.encode("ascii")
+ header_bytes = header_str.encode("latin1")
self.send(header_bytes)
self.send(b'\r\n')
- response = self.response_class(self.sock, strict = self.strict,
- method = self._method)
+ response = self.response_class(self.sock, method=self._method)
(version, code, message) = response._read_status()
if code != 200:
@@ -726,7 +718,7 @@ class HTTPConnection:
def connect(self):
"""Connect to the host and port specified in __init__."""
self.sock = socket.create_connection((self.host,self.port),
- self.timeout)
+ self.timeout, self.source_address)
if self._tunnel_host:
self._tunnel()
@@ -741,18 +733,17 @@ class HTTPConnection:
self.__state = _CS_IDLE
def send(self, data):
- """Send `data' to the server."""
+ """Send `data' to the server.
+ ``data`` can be a string object, a bytes object, an array object, a
+ file-like object that supports a .read() method, or an iterable object.
+ """
+
if self.sock is None:
if self.auto_open:
self.connect()
else:
raise NotConnected()
- # send the data to the server. if we get a broken pipe, then close
- # the socket. we want to reconnect when somebody tries to send again.
- #
- # NOTE: we DO propagate the error, though, because we cannot simply
- # ignore the error... the caller will know if they can retry.
if self.debuglevel > 0:
print("send:", repr(data))
blocksize = 8192
@@ -778,8 +769,16 @@ class HTTPConnection:
if encode:
datablock = datablock.encode("iso-8859-1")
self.sock.sendall(datablock)
- else:
+
+ try:
self.sock.sendall(data)
+ except TypeError:
+ if isinstance(data, collections.Iterable):
+ for d in data:
+ self.sock.sendall(d)
+ else:
+ raise TypeError("data should be a bytes-like object\
+ or an iterable, got %r " % type(it))
def _output(self, s):
"""Add a line of output to the current request buffer.
@@ -938,7 +937,7 @@ class HTTPConnection:
values = list(values)
for i, one_value in enumerate(values):
if hasattr(one_value, 'encode'):
- values[i] = one_value.encode('ascii')
+ values[i] = one_value.encode('latin1')
elif isinstance(one_value, int):
values[i] = str(one_value).encode('ascii')
value = b'\r\n\t'.join(values)
@@ -1040,11 +1039,9 @@ class HTTPConnection:
if self.debuglevel > 0:
response = self.response_class(self.sock, self.debuglevel,
- strict=self.strict,
method=self._method)
else:
- response = self.response_class(self.sock, strict=self.strict,
- method=self._method)
+ response = self.response_class(self.sock, method=self._method)
response.begin()
assert response.will_close != _UNKNOWN
@@ -1069,30 +1066,50 @@ else:
default_port = HTTPS_PORT
+ # XXX Should key_file and cert_file be deprecated in favour of context?
+
def __init__(self, host, port=None, key_file=None, cert_file=None,
- strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
- HTTPConnection.__init__(self, host, port, strict, timeout)
+ strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+ source_address=None, *, context=None, check_hostname=None):
+ super(HTTPSConnection, self).__init__(host, port, strict, timeout,
+ source_address)
self.key_file = key_file
self.cert_file = cert_file
+ if context is None:
+ # Some reasonable defaults
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.options |= ssl.OP_NO_SSLv2
+ will_verify = context.verify_mode != ssl.CERT_NONE
+ if check_hostname is None:
+ check_hostname = will_verify
+ elif check_hostname and not will_verify:
+ raise ValueError("check_hostname needs a SSL context with "
+ "either CERT_OPTIONAL or CERT_REQUIRED")
+ if key_file or cert_file:
+ context.load_cert_chain(cert_file, key_file)
+ self._context = context
+ self._check_hostname = check_hostname
def connect(self):
"Connect to a host on a given (SSL) port."
sock = socket.create_connection((self.host, self.port),
- self.timeout)
+ self.timeout, self.source_address)
if self._tunnel_host:
self.sock = sock
self._tunnel()
- self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
-
-
- def FakeSocket (sock, sslobj):
- warnings.warn("FakeSocket is deprecated, and won't be in 3.x. " +
- "Use the result of ssl.wrap_socket() directly instead.",
- DeprecationWarning, stacklevel=2)
- return sslobj
+ server_hostname = self.host if ssl.HAS_SNI else None
+ self.sock = self._context.wrap_socket(sock,
+ server_hostname=server_hostname)
+ try:
+ if self._check_hostname:
+ ssl.match_hostname(self.sock.getpeercert(), self.host)
+ except Exception:
+ self.sock.shutdown(socket.SHUT_RDWR)
+ self.sock.close()
+ raise
__all__.append("HTTPSConnection")
@@ -1146,6 +1163,8 @@ class ResponseNotReady(ImproperConnectionState):
class BadStatusLine(HTTPException):
def __init__(self, line):
+ if not line:
+ line = repr(line)
self.args = line,
self.line = line
@@ -1156,71 +1175,3 @@ class LineTooLong(HTTPException):
# for backwards compatibility
error = HTTPException
-
-class LineAndFileWrapper:
- """A limited file-like object for HTTP/0.9 responses."""
-
- # The status-line parsing code calls readline(), which normally
- # get the HTTP status line. For a 0.9 response, however, this is
- # actually the first line of the body! Clients need to get a
- # readable file object that contains that line.
-
- def __init__(self, line, file):
- self._line = line
- self._file = file
- self._line_consumed = 0
- self._line_offset = 0
- self._line_left = len(line)
-
- def __getattr__(self, attr):
- return getattr(self._file, attr)
-
- def _done(self):
- # called when the last byte is read from the line. After the
- # call, all read methods are delegated to the underlying file
- # object.
- self._line_consumed = 1
- self.read = self._file.read
- self.readline = self._file.readline
- self.readlines = self._file.readlines
-
- def read(self, amt=None):
- if self._line_consumed:
- return self._file.read(amt)
- assert self._line_left
- if amt is None or amt > self._line_left:
- s = self._line[self._line_offset:]
- self._done()
- if amt is None:
- return s + self._file.read()
- else:
- return s + self._file.read(amt - len(s))
- else:
- assert amt <= self._line_left
- i = self._line_offset
- j = i + amt
- s = self._line[i:j]
- self._line_offset = j
- self._line_left -= amt
- if self._line_left == 0:
- self._done()
- return s
-
- def readline(self):
- if self._line_consumed:
- return self._file.readline()
- assert self._line_left
- s = self._line[self._line_offset:]
- self._done()
- return s
-
- def readlines(self, size=None):
- if self._line_consumed:
- return self._file.readlines(size)
- assert self._line_left
- L = [self._line[self._line_offset:]]
- self._done()
- if size is None:
- return L + self._file.readlines()
- else:
- return L + self._file.readlines(size)
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
index 9b0ee8039c..7f7f55b136 100644
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -436,6 +436,13 @@ def join_header_words(lists):
if attr: headers.append("; ".join(attr))
return ", ".join(headers)
+def strip_quotes(text):
+ if text.startswith('"'):
+ text = text[1:]
+ if text.endswith('"'):
+ text = text[:-1]
+ return text
+
def parse_ns_headers(ns_headers):
"""Ad-hoc parser for Netscape protocol cookie-attributes.
@@ -453,7 +460,7 @@ def parse_ns_headers(ns_headers):
"""
known_attrs = ("expires", "domain", "path", "secure",
# RFC 2109 attrs (may turn up in Netscape cookies, too)
- "port", "max-age")
+ "version", "port", "max-age")
result = []
for ns_header in ns_headers:
@@ -473,12 +480,11 @@ def parse_ns_headers(ns_headers):
k = lc
if k == "version":
# This is an RFC 2109 cookie.
+ v = strip_quotes(v)
version_set = True
if k == "expires":
# convert expires date to seconds since epoch
- if v.startswith('"'): v = v[1:]
- if v.endswith('"'): v = v[:-1]
- v = http2time(v) # None if invalid
+ v = http2time(strip_quotes(v)) # None if invalid
pairs.append((k, v))
if pairs:
@@ -1443,7 +1449,11 @@ class CookieJar:
# set the easy defaults
version = standard.get("version", None)
- if version is not None: version = int(version)
+ if version is not None:
+ try:
+ version = int(version)
+ except ValueError:
+ return None # invalid version, ignore cookie
secure = standard.get("secure", False)
# (discard is also set if expires is Absent)
discard = standard.get("discard", False)
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py
index 0d9e6d0e3a..93da62791d 100644
--- a/Lib/http/cookies.py
+++ b/Lib/http/cookies.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
####
@@ -46,7 +46,7 @@ At the moment, this is the only documentation.
The Basics
----------
-Importing is easy..
+Importing is easy...
>>> from http import cookies
@@ -127,19 +127,14 @@ the value to a string, when the values are set dictionary-style.
'Set-Cookie: number=7\r\nSet-Cookie: string=seven'
Finis.
-""" #"
-# ^
-# |----helps out font-lock
+"""
#
# Import our required modules
#
+import re
import string
-from pickle import dumps, loads
-
-import re, warnings
-
__all__ = ["CookieError", "BaseCookie", "SimpleCookie"]
_nulljoin = ''.join
@@ -231,17 +226,16 @@ _Translator = {
}
def _quote(str, LegalChars=_LegalChars):
- #
- # If the string does not need to be double-quoted,
- # then just return the string. Otherwise, surround
- # the string in doublequotes and precede quote (with a \)
- # special characters.
- #
+ r"""Quote a string for use in a cookie header.
+
+ If the string does not need to be double-quoted, then just return the
+ string. Otherwise, surround the string in doublequotes and quote
+ (with a \) special characters.
+ """
if all(c in LegalChars for c in str):
return str
else:
- return '"' + _nulljoin( map(_Translator.get, str, str) ) + '"'
-# end _quote
+ return '"' + _nulljoin(_Translator.get(s, s) for s in str) + '"'
_OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")
@@ -250,7 +244,7 @@ _QuotePatt = re.compile(r"[\\].")
def _unquote(str):
# If there aren't any doublequotes,
# then there can't be any special characters. See RFC 2109.
- if len(str) < 2:
+ if len(str) < 2:
return str
if str[0] != '"' or str[-1] != '"':
return str
@@ -269,32 +263,32 @@ def _unquote(str):
n = len(str)
res = []
while 0 <= i < n:
- Omatch = _OctalPatt.search(str, i)
- Qmatch = _QuotePatt.search(str, i)
- if not Omatch and not Qmatch: # Neither matched
+ o_match = _OctalPatt.search(str, i)
+ q_match = _QuotePatt.search(str, i)
+ if not o_match and not q_match: # Neither matched
res.append(str[i:])
break
# else:
j = k = -1
- if Omatch: j = Omatch.start(0)
- if Qmatch: k = Qmatch.start(0)
- if Qmatch and ( not Omatch or k < j ): # QuotePatt matched
+ if o_match:
+ j = o_match.start(0)
+ if q_match:
+ k = q_match.start(0)
+ if q_match and (not o_match or k < j): # QuotePatt matched
res.append(str[i:k])
res.append(str[k+1])
- i = k+2
+ i = k + 2
else: # OctalPatt matched
res.append(str[i:j])
- res.append( chr( int(str[j+1:j+4], 8) ) )
- i = j+4
+ res.append(chr(int(str[j+1:j+4], 8)))
+ i = j + 4
return _nulljoin(res)
-# end _unquote
-
-# The _getdate() routine is used to set the expiration time in
-# the cookie's HTTP header. By default, _getdate() returns the
-# current time in the appropriate "expires" format for a
-# Set-Cookie header. The one optional argument is an offset from
-# now, in seconds. For example, an offset of -3600 means "one hour ago".
-# The offset may be a floating point number.
+
+# The _getdate() routine is used to set the expiration time in the cookie's HTTP
+# header. By default, _getdate() returns the current time in the appropriate
+# "expires" format for a Set-Cookie header. The one optional argument is an
+# offset from now, in seconds. For example, an offset of -3600 means "one hour
+# ago". The offset may be a floating point number.
#
_weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
@@ -311,18 +305,15 @@ def _getdate(future=0, weekdayname=_weekdayname, monthname=_monthname):
(weekdayname[wd], day, monthname[month], year, hh, mm, ss)
-#
-# A class to hold ONE key,value pair.
-# In a cookie, each such pair may have several attributes.
-# so this class is used to keep the attributes associated
-# with the appropriate key,value pair.
-# This class also includes a coded_value attribute, which
-# is used to hold the network representation of the
-# value. This is most useful when Python objects are
-# pickled for network transit.
-#
-
class Morsel(dict):
+ """A class to hold ONE (key, value) pair.
+
+ In a cookie, each such pair may have several attributes, so this class is
+ used to keep the attributes associated with the appropriate key,value pair.
+ This class also includes a coded_value attribute, which is used to hold
+ the network representation of the value. This is most useful when Python
+ objects are pickled for network transit.
+ """
# RFC 2109 lists these attributes as reserved:
# path comment domain
# max-age secure version
@@ -336,35 +327,33 @@ class Morsel(dict):
# This dictionary provides a mapping from the lowercase
# variant on the left to the appropriate traditional
# formatting on the right.
- _reserved = { "expires" : "expires",
- "path" : "Path",
- "comment" : "Comment",
- "domain" : "Domain",
- "max-age" : "Max-Age",
- "secure" : "secure",
- "httponly" : "httponly",
- "version" : "Version",
- }
+ _reserved = {
+ "expires" : "expires",
+ "path" : "Path",
+ "comment" : "Comment",
+ "domain" : "Domain",
+ "max-age" : "Max-Age",
+ "secure" : "secure",
+ "httponly" : "httponly",
+ "version" : "Version",
+ }
def __init__(self):
# Set defaults
self.key = self.value = self.coded_value = None
# Set default attributes
- for K in self._reserved:
- dict.__setitem__(self, K, "")
- # end __init__
+ for key in self._reserved:
+ dict.__setitem__(self, key, "")
def __setitem__(self, K, V):
K = K.lower()
if not K in self._reserved:
raise CookieError("Invalid Attribute %s" % K)
dict.__setitem__(self, K, V)
- # end __setitem__
def isReservedKey(self, K):
return K.lower() in self._reserved
- # end isReservedKey
def set(self, key, val, coded_val, LegalChars=_LegalChars):
# First we verify that the key isn't a reserved word
@@ -375,19 +364,18 @@ class Morsel(dict):
raise CookieError("Illegal key value: %s" % key)
# It's a good key, so save it.
- self.key = key
- self.value = val
- self.coded_value = coded_val
- # end set
+ self.key = key
+ self.value = val
+ self.coded_value = coded_val
- def output(self, attrs=None, header = "Set-Cookie:"):
- return "%s %s" % ( header, self.OutputString(attrs) )
+ def output(self, attrs=None, header="Set-Cookie:"):
+ return "%s %s" % (header, self.OutputString(attrs))
__str__ = output
def __repr__(self):
return '<%s: %s=%s>' % (self.__class__.__name__,
- self.key, repr(self.value) )
+ self.key, repr(self.value))
def js_output(self, attrs=None):
# Print javascript
@@ -397,41 +385,39 @@ class Morsel(dict):
document.cookie = \"%s\";
// end hiding -->
</script>
- """ % ( self.OutputString(attrs).replace('"',r'\"'))
- # end js_output()
+ """ % (self.OutputString(attrs).replace('"', r'\"'))
def OutputString(self, attrs=None):
# Build up our result
#
result = []
- RA = result.append
+ append = result.append
# First, the key=value pair
- RA("%s=%s" % (self.key, self.coded_value))
+ append("%s=%s" % (self.key, self.coded_value))
# Now add any defined attributes
if attrs is None:
attrs = self._reserved
items = sorted(self.items())
- for K,V in items:
- if V == "": continue
- if K not in attrs: continue
- if K == "expires" and type(V) == type(1):
- RA("%s=%s" % (self._reserved[K], _getdate(V)))
- elif K == "max-age" and type(V) == type(1):
- RA("%s=%d" % (self._reserved[K], V))
- elif K == "secure":
- RA(str(self._reserved[K]))
- elif K == "httponly":
- RA(str(self._reserved[K]))
+ for key, value in items:
+ if value == "":
+ continue
+ if key not in attrs:
+ continue
+ if key == "expires" and isinstance(value, int):
+ append("%s=%s" % (self._reserved[key], _getdate(value)))
+ elif key == "max-age" and isinstance(value, int):
+ append("%s=%d" % (self._reserved[key], value))
+ elif key == "secure":
+ append(str(self._reserved[key]))
+ elif key == "httponly":
+ append(str(self._reserved[key]))
else:
- RA("%s=%s" % (self._reserved[K], V))
+ append("%s=%s" % (self._reserved[key], value))
# Return the result
return _semispacejoin(result)
- # end OutputString
-# end Morsel class
-
#
@@ -461,13 +447,11 @@ _CookiePattern = re.compile(r"""
""", re.ASCII) # May be removed if safe.
-# At long last, here is the cookie class.
-# Using this class is almost just like using a dictionary.
-# See this module's docstring for example usage.
+# At long last, here is the cookie class. Using this class is almost just like
+# using a dictionary. See this module's docstring for example usage.
#
class BaseCookie(dict):
- # A container class for a set of Morsels
- #
+ """A container class for a set of Morsels."""
def value_decode(self, val):
"""real_value, coded_value = value_decode(STRING)
@@ -477,7 +461,6 @@ class BaseCookie(dict):
Override this function to modify the behavior of cookies.
"""
return val, val
- # end value_encode
def value_encode(self, val):
"""real_value, coded_value = value_encode(VALUE)
@@ -487,51 +470,46 @@ class BaseCookie(dict):
"""
strval = str(val)
return strval, strval
- # end value_encode
def __init__(self, input=None):
- if input: self.load(input)
- # end __init__
+ if input:
+ self.load(input)
def __set(self, key, real_value, coded_value):
"""Private method for setting a cookie's value"""
M = self.get(key, Morsel())
M.set(key, real_value, coded_value)
dict.__setitem__(self, key, M)
- # end __set
def __setitem__(self, key, value):
"""Dictionary style assignment."""
rval, cval = self.value_encode(value)
self.__set(key, rval, cval)
- # end __setitem__
def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"):
"""Return a string suitable for HTTP."""
result = []
items = sorted(self.items())
- for K,V in items:
- result.append( V.output(attrs, header) )
+ for key, value in items:
+ result.append(value.output(attrs, header))
return sep.join(result)
- # end output
__str__ = output
def __repr__(self):
- L = []
+ l = []
items = sorted(self.items())
- for K,V in items:
- L.append( '%s=%s' % (K,repr(V.value) ) )
- return '<%s: %s>' % (self.__class__.__name__, _spacejoin(L))
+ for key, value in items:
+ l.append('%s=%s' % (key, repr(value.value)))
+ return '<%s: %s>' % (self.__class__.__name__, _spacejoin(l))
def js_output(self, attrs=None):
"""Return a string suitable for JavaScript."""
result = []
items = sorted(self.items())
- for K,V in items:
- result.append( V.js_output(attrs) )
+ for key, value in items:
+ result.append(value.js_output(attrs))
return _nulljoin(result)
- # end js_output
def load(self, rawdata):
"""Load cookies from a string (presumably HTTP_COOKIE) or
@@ -539,16 +517,15 @@ class BaseCookie(dict):
is equivalent to calling:
map(Cookie.__setitem__, d.keys(), d.values())
"""
- if type(rawdata) == type(""):
- self.__ParseString(rawdata)
+ if isinstance(rawdata, str):
+ self.__parse_string(rawdata)
else:
# self.update() wouldn't call our custom __setitem__
- for k, v in rawdata.items():
- self[k] = v
+ for key, value in rawdata.items():
+ self[key] = value
return
- # end load()
- def __ParseString(self, str, patt=_CookiePattern):
+ def __parse_string(self, str, patt=_CookiePattern):
i = 0 # Our starting point
n = len(str) # Length of string
M = None # current morsel
@@ -556,48 +533,39 @@ class BaseCookie(dict):
while 0 <= i < n:
# Start looking for a cookie
match = patt.search(str, i)
- if not match: break # No more cookies
+ if not match:
+ # No more cookies
+ break
- K,V = match.group("key"), match.group("val")
+ key, value = match.group("key"), match.group("val")
i = match.end(0)
# Parse the key, value in case it's metainfo
- if K[0] == "$":
+ if key[0] == "$":
# We ignore attributes which pertain to the cookie
# mechanism as a whole. See RFC 2109.
# (Does anyone care?)
if M:
- M[ K[1:] ] = V
- elif K.lower() in Morsel._reserved:
+ M[key[1:]] = value
+ elif key.lower() in Morsel._reserved:
if M:
- M[ K ] = _unquote(V)
+ M[key] = _unquote(value)
else:
- rval, cval = self.value_decode(V)
- self.__set(K, rval, cval)
- M = self[K]
- # end __ParseString
-# end BaseCookie class
+ rval, cval = self.value_decode(value)
+ self.__set(key, rval, cval)
+ M = self[key]
+
class SimpleCookie(BaseCookie):
- """SimpleCookie
+ """
SimpleCookie supports strings as cookie values. When setting
the value using the dictionary assignment notation, SimpleCookie
calls the builtin str() to convert the value to a string. Values
received from HTTP are kept as strings.
"""
def value_decode(self, val):
- return _unquote( val ), val
+ return _unquote(val), val
+
def value_encode(self, val):
strval = str(val)
- return strval, _quote( strval )
-# end SimpleCookie
-
-#
-###########################################################
-
-def _test():
- import doctest, http.cookies
- return doctest.testmod(http.cookies)
-
-if __name__ == "__main__":
- _test()
+ return strval, _quote(strval)
diff --git a/Lib/http/server.py b/Lib/http/server.py
index 8de604a739..543abe0c9f 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -84,7 +84,7 @@ __version__ = "0.6"
__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
-import cgi
+import html
import email.message
import email.parser
import http.client
@@ -327,6 +327,30 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
elif (conntype.lower() == 'keep-alive' and
self.protocol_version >= "HTTP/1.1"):
self.close_connection = 0
+ # Examine the headers and look for an Expect directive
+ expect = self.headers.get('Expect', "")
+ if (expect.lower() == "100-continue" and
+ self.protocol_version >= "HTTP/1.1" and
+ self.request_version >= "HTTP/1.1"):
+ if not self.handle_expect_100():
+ return False
+ return True
+
+ def handle_expect_100(self):
+ """Decide what to do with an "Expect: 100-continue" header.
+
+ If the client is expecting a 100 Continue response, we must
+ respond with either a 100 Continue or a final response before
+ waiting for the request body. The default is to always respond
+ with a 100 Continue. You can behave differently (for example,
+ reject unauthorized requests) by overriding this method.
+
+ This method should either return True (possibly after sending
+ a 100 Continue response) or send an error response and return
+ False.
+
+ """
+ self.send_response_only(100)
return True
def handle_one_request(self):
@@ -337,24 +361,32 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
commands such as GET and POST.
"""
- self.raw_requestline = self.rfile.readline(65537)
- if len(self.raw_requestline) > 65536:
- self.requestline = ''
- self.request_version = ''
- self.command = ''
- self.send_error(414)
- return
- if not self.raw_requestline:
+ try:
+ self.raw_requestline = self.rfile.readline(65537)
+ if len(self.raw_requestline) > 65536:
+ self.requestline = ''
+ self.request_version = ''
+ self.command = ''
+ self.send_error(414)
+ return
+ if not self.raw_requestline:
+ self.close_connection = 1
+ return
+ if not self.parse_request():
+ # An error code has been sent, just exit
+ return
+ mname = 'do_' + self.command
+ if not hasattr(self, mname):
+ self.send_error(501, "Unsupported method (%r)" % self.command)
+ return
+ method = getattr(self, mname)
+ method()
+ self.wfile.flush() #actually send the response if not already done.
+ except socket.timeout as e:
+ #a read or a write timed out. Discard this connection
+ self.log_error("Request timed out: %r", e)
self.close_connection = 1
return
- if not self.parse_request(): # An error code has been sent, just exit
- return
- mname = 'do_' + self.command
- if not hasattr(self, mname):
- self.send_error(501, "Unsupported method (%r)" % self.command)
- return
- method = getattr(self, mname)
- method()
def handle(self):
"""Handle multiple requests if necessary."""
@@ -403,6 +435,12 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
"""
self.log_request(code)
+ self.send_response_only(code, message)
+ self.send_header('Server', self.version_string())
+ self.send_header('Date', self.date_time_string())
+
+ def send_response_only(self, code, message=None):
+ """Send the response header only."""
if message is None:
if code in self.responses:
message = self.responses[code][0]
@@ -410,15 +448,15 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
message = ''
if self.request_version != 'HTTP/0.9':
self.wfile.write(("%s %d %s\r\n" %
- (self.protocol_version, code, message)).encode('ASCII', 'strict'))
- # print (self.protocol_version, code, message)
- self.send_header('Server', self.version_string())
- self.send_header('Date', self.date_time_string())
+ (self.protocol_version, code, message)).encode('latin1', 'strict'))
def send_header(self, keyword, value):
"""Send a MIME header."""
if self.request_version != 'HTTP/0.9':
- self.wfile.write(("%s: %s\r\n" % (keyword, value)).encode('ASCII', 'strict'))
+ if not hasattr(self, '_headers_buffer'):
+ self._headers_buffer = []
+ self._headers_buffer.append(
+ ("%s: %s\r\n" % (keyword, value)).encode('latin1', 'strict'))
if keyword.lower() == 'connection':
if value.lower() == 'close':
@@ -429,7 +467,9 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
def end_headers(self):
"""Send the blank line ending the MIME headers."""
if self.request_version != 'HTTP/0.9':
- self.wfile.write(b"\r\n")
+ self._headers_buffer.append(b"\r\n")
+ self.wfile.write(b"".join(self._headers_buffer))
+ self._headers_buffer = []
def log_request(self, code='-', size='-'):
"""Log an accepted request.
@@ -680,7 +720,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
return None
list.sort(key=lambda a: a.lower())
r = []
- displaypath = cgi.escape(urllib.parse.unquote(self.path))
+ displaypath = html.escape(urllib.parse.unquote(self.path))
r.append('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">')
r.append("<html>\n<title>Directory listing for %s</title>\n" % displaypath)
r.append("<body>\n<h2>Directory listing for %s</h2>\n" % displaypath)
@@ -696,7 +736,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
displayname = name + "@"
# Note: a link to a directory displays with @ and links with /
r.append('<li><a href="%s">%s</a>\n'
- % (urllib.parse.quote(linkname), cgi.escape(displayname)))
+ % (urllib.parse.quote(linkname), html.escape(displayname)))
r.append("</ul>\n<hr>\n</body>\n</html>\n")
enc = sys.getfilesystemencoding()
encoded = ''.join(r).encode(enc)
@@ -838,7 +878,7 @@ def nobody_uid():
try:
nobody = pwd.getpwnam('nobody')[2]
except KeyError:
- nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
+ nobody = 1 + max(x[2] for x in pwd.getpwall())
return nobody
diff --git a/Lib/idlelib/Bindings.py b/Lib/idlelib/Bindings.py
index 74a93d3b14..ec2720b0d0 100644
--- a/Lib/idlelib/Bindings.py
+++ b/Lib/idlelib/Bindings.py
@@ -98,14 +98,6 @@ if macosxSupport.runningAsOSXApp():
# menu
del menudefs[-1][1][0:2]
- menudefs.insert(0,
- ('application', [
- ('About IDLE', '<<about-idle>>'),
- None,
- ('_Preferences....', '<<open-config-dialog>>'),
- ]))
-
-
default_keydefs = idleConf.GetCurrentKeySet()
del sys
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index 173fad9eb3..a37cb1d9bc 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -3,7 +3,6 @@ import os
import re
import string
import imp
-from itertools import count
from tkinter import *
import tkinter.simpledialog as tkSimpleDialog
import tkinter.messagebox as tkMessageBox
@@ -388,7 +387,7 @@ class EditorWindow(object):
underline, label = prepstr(label)
menudict[name] = menu = Menu(mbar, name=name)
mbar.add_cascade(label=label, menu=menu, underline=underline)
- if macosxSupport.runningAsOSXApp():
+ if macosxSupport.isCarbonAquaTk(self.root):
# Insert the application menu
menudict['application'] = menu = Menu(mbar, name='apple')
mbar.add_cascade(label='IDLE', menu=menu)
@@ -802,8 +801,8 @@ class EditorWindow(object):
for instance in self.top.instance_dict:
menu = instance.recent_files_menu
menu.delete(1, END) # clear, and rebuild:
- for i, file in zip(count(), rf_list):
- file_name = file[0:-1] # zap \n
+ for i, file_name in enumerate(rf_list):
+ file_name = file_name.rstrip() # zap \n
# make unicode string to display non-ASCII chars correctly
ufile_name = self._filename_to_unicode(file_name)
callback = instance.__recent_file_callback(file_name)
@@ -1547,7 +1546,12 @@ keynames = {
def get_accelerator(keydefs, eventname):
keylist = keydefs.get(eventname)
- if not keylist:
+ # issue10940: temporary workaround to prevent hang with OS X Cocoa Tk 8.5
+ # if not keylist:
+ if (not keylist) or (macosxSupport.runningAsOSXApp() and eventname in {
+ "<<open-module>>",
+ "<<goto-line>>",
+ "<<change-indentwidth>>"}):
return ""
s = keylist[0]
s = re.sub(r"-[a-z]\b", lambda m: m.group().upper(), s)
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 24629c1ede..037b02a3c1 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -1,7 +1,7 @@
-What's New in IDLE 3.1b1?
+What's New in IDLE 3.1?
=========================
-*Release date: XX-XXX-09*
+*Release date: 27-Jun-09*
- Use of 'filter' in keybindingDialog.py was causing custom key assignment to
fail. Patch 5707 amaury.forgeotdarc.
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 0fa3d765aa..06c8bba4d6 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import os
import os.path
@@ -55,20 +55,21 @@ except ImportError:
else:
def idle_showwarning(message, category, filename, lineno,
file=None, line=None):
- file = warning_stream
+ if file is None:
+ file = warning_stream
try:
- file.write(warnings.formatwarning(message, category, filename,\
+ file.write(warnings.formatwarning(message, category, filename,
lineno, file=file, line=line))
except IOError:
pass ## file (probably __stderr__) is invalid, warning dropped.
warnings.showwarning = idle_showwarning
- def idle_formatwarning(message, category, filename, lineno,
- file=None, line=None):
+ def idle_formatwarning(message, category, filename, lineno, line=None):
"""Format warnings the IDLE way"""
s = "\nWarning (from warnings module):\n"
s += ' File \"%s\", line %s\n' % (filename, lineno)
- line = linecache.getline(filename, lineno).strip() \
- if line is None else line
+ if line is None:
+ line = linecache.getline(filename, lineno)
+ line = line.strip()
if line:
s += " %s\n" % line
s += "%s: %s\n>>> " % (category.__name__, message)
@@ -81,18 +82,17 @@ def extended_linecache_checkcache(filename=None,
Rather than repeating the linecache code, patch it to save the
<pyshell#...> entries, call the original linecache.checkcache()
- (which destroys them), and then restore the saved entries.
+ (skipping them), and then restore the saved entries.
orig_checkcache is bound at definition time to the original
method, allowing it to be patched.
-
"""
cache = linecache.cache
save = {}
- for filename in cache:
- if filename[:1] + filename[-1:] == '<>':
- save[filename] = cache[filename]
- orig_checkcache()
+ for key in list(cache):
+ if key[:1] + key[-1:] == '<>':
+ save[key] = cache.pop(key)
+ orig_checkcache(filename)
cache.update(save)
# Patch linecache.checkcache():
@@ -1417,6 +1417,13 @@ def main():
shell.interp.prepend_syspath(script)
shell.interp.execfile(script)
+ # Check for problematic OS X Tk versions and print a warning message
+ # in the IDLE shell window; this is less intrusive than always opening
+ # a separate window.
+ tkversionwarning = macosxSupport.tkVersionWarning(root)
+ if tkversionwarning:
+ shell.interp.runcommand(''.join(("print('", tkversionwarning, "')")))
+
root.mainloop()
root.destroy()
diff --git a/Lib/idlelib/idlever.py b/Lib/idlelib/idlever.py
index 8ee61a2cd3..5b0907e1e1 100644
--- a/Lib/idlelib/idlever.py
+++ b/Lib/idlelib/idlever.py
@@ -1 +1 @@
-IDLE_VERSION = "3.1.3"
+IDLE_VERSION = "3.2"
diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosxSupport.py
index da519f7a0f..f93ef118db 100644
--- a/Lib/idlelib/macosxSupport.py
+++ b/Lib/idlelib/macosxSupport.py
@@ -4,6 +4,10 @@ GUI application (as opposed to an X11 application).
"""
import sys
import tkinter
+from os import path
+
+
+_appbundle = None
def runningAsOSXApp():
"""
@@ -11,7 +15,41 @@ def runningAsOSXApp():
If so, assume that Python was built with Aqua Tcl/Tk rather than
X11 Tcl/Tk.
"""
- return (sys.platform == 'darwin' and '.app' in sys.executable)
+ global _appbundle
+ if _appbundle is None:
+ _appbundle = (sys.platform == 'darwin' and '.app' in sys.executable)
+ return _appbundle
+
+_carbonaquatk = None
+
+def isCarbonAquaTk(root):
+ """
+ Returns True if IDLE is using a Carbon Aqua Tk (instead of the
+ newer Cocoa Aqua Tk).
+ """
+ global _carbonaquatk
+ if _carbonaquatk is None:
+ _carbonaquatk = (runningAsOSXApp() and
+ 'aqua' in root.tk.call('tk', 'windowingsystem') and
+ 'AppKit' not in root.tk.call('winfo', 'server', '.'))
+ return _carbonaquatk
+
+def tkVersionWarning(root):
+ """
+ Returns a string warning message if the Tk version in use appears to
+ be one known to cause problems with IDLE. The Apple Cocoa-based Tk 8.5
+ that was shipped with Mac OS X 10.6.
+ """
+
+ if (runningAsOSXApp() and
+ ('AppKit' in root.tk.call('winfo', 'server', '.')) and
+ (root.tk.call('info', 'patchlevel') == '8.5.7') ):
+ return (r"WARNING: The version of Tcl/Tk (8.5.7) in use may"
+ r" be unstable.\n"
+ r"Visit http://www.python.org/download/mac/tcltk/"
+ r" for current information.")
+ else:
+ return False
def addOpenEventSupport(root, flist):
"""
@@ -73,9 +111,6 @@ def overrideRootMenu(root, flist):
WindowList.add_windows_to_menu(menu)
WindowList.register_callback(postwindowsmenu)
- menudict['application'] = menu = Menu(menubar, name='apple')
- menubar.add_cascade(label='IDLE', menu=menu)
-
def about_dialog(event=None):
from idlelib import aboutDialog
aboutDialog.AboutDialog(root, 'About IDLE')
@@ -91,9 +126,14 @@ def overrideRootMenu(root, flist):
root.instance_dict = flist.inversedict
configDialog.ConfigDialog(root, 'Settings')
+ def help_dialog(event=None):
+ from idlelib import textView
+ fn = path.join(path.abspath(path.dirname(__file__)), 'help.txt')
+ textView.view_file(root, 'Help', fn)
root.bind('<<about-idle>>', about_dialog)
root.bind('<<open-config-dialog>>', config_dialog)
+ root.createcommand('::tk::mac::ShowPreferences', config_dialog)
if flist:
root.bind('<<close-all-windows>>', flist.close_all_callback)
@@ -102,35 +142,29 @@ def overrideRootMenu(root, flist):
# right thing for now.
root.createcommand('exit', flist.close_all_callback)
-
- ###check if Tk version >= 8.4.14; if so, use hard-coded showprefs binding
- tkversion = root.tk.eval('info patchlevel')
- # Note: we cannot check if the string tkversion >= '8.4.14', because
- # the string '8.4.7' is greater than the string '8.4.14'.
- if tuple(map(int, tkversion.split('.'))) >= (8, 4, 14):
- Bindings.menudefs[0] = ('application', [
+ if isCarbonAquaTk(root):
+ # for Carbon AquaTk, replace the default Tk apple menu
+ menudict['application'] = menu = Menu(menubar, name='apple')
+ menubar.add_cascade(label='IDLE', menu=menu)
+ Bindings.menudefs.insert(0,
+ ('application', [
('About IDLE', '<<about-idle>>'),
- None,
- ])
- root.createcommand('::tk::mac::ShowPreferences', config_dialog)
+ None,
+ ]))
+ tkversion = root.tk.eval('info patchlevel')
+ if tuple(map(int, tkversion.split('.'))) < (8, 4, 14):
+ # for earlier AquaTk versions, supply a Preferences menu item
+ Bindings.menudefs[0][1].append(
+ ('_Preferences....', '<<open-config-dialog>>'),
+ )
else:
- for mname, entrylist in Bindings.menudefs:
- menu = menudict.get(mname)
- if not menu:
- continue
- else:
- for entry in entrylist:
- if not entry:
- menu.add_separator()
- else:
- label, eventname = entry
- underline, label = prepstr(label)
- accelerator = get_accelerator(Bindings.default_keydefs,
- eventname)
- def command(text=root, eventname=eventname):
- text.event_generate(eventname)
- menu.add_command(label=label, underline=underline,
- command=command, accelerator=accelerator)
+ # assume Cocoa AquaTk
+ # replace default About dialog with About IDLE one
+ root.createcommand('tkAboutDialog', about_dialog)
+ # replace default "Help" item in Help menu
+ root.createcommand('::tk::mac::ShowHelp', help_dialog)
+ # remove redundant "IDLE Help" from menu
+ del Bindings.menudefs[-1][1][0]
def setupApp(root, flist):
"""
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index fd2cc09042..25338ffaa6 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -25,12 +25,13 @@ except ImportError:
pass
else:
def idle_formatwarning_subproc(message, category, filename, lineno,
- file=None, line=None):
+ line=None):
"""Format warnings the IDLE way"""
s = "\nWarning (from warnings module):\n"
s += ' File \"%s\", line %s\n' % (filename, lineno)
- line = linecache.getline(filename, lineno).strip() \
- if line is None else line
+ if line is None:
+ line = linecache.getline(filename, lineno)
+ line = line.strip()
if line:
s += " %s\n" % line
s += "%s: %s\n" % (category.__name__, message)
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index fc1e20a27d..1022e77c4f 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -24,6 +24,12 @@ __version__ = "2.58"
import binascii, errno, random, re, socket, subprocess, sys, time
+try:
+ import ssl
+ HAVE_SSL = True
+except ImportError:
+ HAVE_SSL = False
+
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple",
"Int2AP", "ParseFlags", "Time2Internaldate"]
@@ -71,6 +77,7 @@ Commands = {
'SETANNOTATION':('AUTH', 'SELECTED'),
'SETQUOTA': ('AUTH', 'SELECTED'),
'SORT': ('SELECTED',),
+ 'STARTTLS': ('NONAUTH',),
'STATUS': ('AUTH', 'SELECTED'),
'STORE': ('SELECTED',),
'SUBSCRIBE': ('AUTH', 'SELECTED'),
@@ -156,11 +163,23 @@ class IMAP4:
self.continuation_response = '' # Last continuation response
self.is_readonly = False # READ-ONLY desired state
self.tagnum = 0
+ self._tls_established = False
# Open socket to server.
self.open(host, port)
+ try:
+ self._connect()
+ except Exception:
+ try:
+ self.shutdown()
+ except socket.error:
+ pass
+ raise
+
+
+ def _connect(self):
# Create unique tag for this session,
# and compile tagged response matcher.
@@ -188,13 +207,7 @@ class IMAP4:
else:
raise self.error(self.welcome)
- typ, dat = self.capability()
- if dat == [None]:
- raise self.error('no CAPABILITY response from server')
- dat = str(dat[-1], "ASCII")
- dat = dat.upper()
- self.capabilities = tuple(dat.split())
-
+ self._get_capabilities()
if __debug__:
if self.debug >= 3:
self._mesg('CAPABILITIES: %r' % (self.capabilities,))
@@ -711,6 +724,30 @@ class IMAP4:
return self._untagged_response(typ, dat, name)
+ def starttls(self, ssl_context=None):
+ name = 'STARTTLS'
+ if not HAVE_SSL:
+ raise self.error('SSL support missing')
+ if self._tls_established:
+ raise self.abort('TLS session already established')
+ if name not in self.capabilities:
+ raise self.abort('TLS not supported by server')
+ # Generate a default SSL context if none was passed.
+ if ssl_context is None:
+ ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ # SSLv2 considered harmful.
+ ssl_context.options |= ssl.OP_NO_SSLv2
+ typ, dat = self._simple_command(name)
+ if typ == 'OK':
+ self.sock = ssl_context.wrap_socket(self.sock)
+ self.file = self.sock.makefile('rb')
+ self._tls_established = True
+ self._get_capabilities()
+ else:
+ raise self.error("Couldn't establish TLS session")
+ return self._untagged_response(typ, dat, name)
+
+
def status(self, mailbox, names):
"""Request named status conditions for mailbox.
@@ -921,6 +958,15 @@ class IMAP4:
return typ, data
+ def _get_capabilities(self):
+ typ, dat = self.capability()
+ if dat == [None]:
+ raise self.error('no CAPABILITY response from server')
+ dat = str(dat[-1], "ASCII")
+ dat = dat.upper()
+ self.capabilities = tuple(dat.split())
+
+
def _get_response(self):
# Read response and store.
@@ -1125,12 +1171,8 @@ class IMAP4:
n -= 1
+if HAVE_SSL:
-try:
- import ssl
-except ImportError:
- pass
-else:
class IMAP4_SSL(IMAP4):
"""IMAP4 client class over SSL connection
@@ -1270,9 +1312,10 @@ Mon2num = {b'Jan': 1, b'Feb': 2, b'Mar': 3, b'Apr': 4, b'May': 5, b'Jun': 6,
b'Jul': 7, b'Aug': 8, b'Sep': 9, b'Oct': 10, b'Nov': 11, b'Dec': 12}
def Internaldate2tuple(resp):
- """Convert IMAP4 INTERNALDATE to UT.
+ """Parse an IMAP4 INTERNALDATE string.
- Returns Python time module tuple.
+ Return corresponding local time. The return value is a
+ time.struct_time tuple or None if the string has wrong format.
"""
mo = InternalDate.match(resp)
@@ -1339,9 +1382,14 @@ def ParseFlags(resp):
def Time2Internaldate(date_time):
- """Convert 'date_time' to IMAP4 INTERNALDATE representation.
+ """Convert date_time to IMAP4 INTERNALDATE representation.
- Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'
+ Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'. The
+ date_time argument can be a number (int or float) represening
+ seconds since epoch (as returned by time.time()), a 9-tuple
+ representing local time (as returned by time.localtime()), or a
+ double-quoted string. In the last case, it is assumed to already
+ be in the correct format.
"""
if isinstance(date_time, (int, float)):
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index 37577ff41d..2baaf93732 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -36,7 +36,7 @@ def _case_ok(directory, check):
"""
if 'PYTHONCASEOK' in os.environ:
return True
- elif check in os.listdir(directory):
+ elif check in os.listdir(directory if directory else os.getcwd()):
return True
return False
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 6f60843d36..425b8bf8c7 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -22,7 +22,7 @@ work. One should use importlib as the public-facing version of this module.
def _path_join(*args):
"""Replacement for os.path.join."""
return path_sep.join(x[:-len(path_sep)] if x.endswith(path_sep) else x
- for x in args)
+ for x in args if x)
def _path_exists(path):
@@ -53,6 +53,8 @@ def _path_isfile(path):
# XXX Could also expose Modules/getpath.c:isdir()
def _path_isdir(path):
"""Replacement for os.path.isdir."""
+ if not path:
+ path = _os.getcwd()
return _path_is_mode_type(path, 0o040000)
@@ -78,20 +80,6 @@ def _path_absolute(path):
return _path_join(_os.getcwd(), path)
-class _closing:
-
- """Simple replacement for contextlib.closing."""
-
- def __init__(self, obj):
- self.obj = obj
-
- def __enter__(self):
- return self.obj
-
- def __exit__(self, *args):
- self.obj.close()
-
-
def _wrap(new, old):
"""Simple substitute for functools.wraps."""
for replace in ['__module__', '__name__', '__doc__']:
@@ -99,6 +87,8 @@ def _wrap(new, old):
new.__dict__.update(old.__dict__)
+code_type = type(_wrap.__code__)
+
# Finder/loader utility code ##################################################
def set_package(fxn):
@@ -138,7 +128,7 @@ def module_for_loader(fxn):
the second argument.
"""
- def decorated(self, fullname):
+ def decorated(self, fullname, *args, **kwargs):
module = sys.modules.get(fullname)
is_reload = bool(module)
if not is_reload:
@@ -148,7 +138,7 @@ def module_for_loader(fxn):
module = imp.new_module(fullname)
sys.modules[fullname] = module
try:
- return fxn(self, module)
+ return fxn(self, module, *args, **kwargs)
except:
if not is_reload:
del sys.modules[fullname]
@@ -301,242 +291,238 @@ class FrozenImporter:
return imp.is_frozen_package(fullname)
-class PyLoader:
+class _LoaderBasics:
- """Loader base class for Python source code.
+ """Base class of common code needed by both SourceLoader and
+ _SourcelessFileLoader."""
- Subclasses need to implement the methods:
+ def is_package(self, fullname):
+ """Concrete implementation of InspectLoader.is_package by checking if
+ the path returned by get_filename has a filename of '__init__.py'."""
+ filename = self.get_filename(fullname).rpartition(path_sep)[2]
+ return filename.rsplit('.', 1)[0] == '__init__'
- - source_path
- - get_data
- - is_package
+ def _bytes_from_bytecode(self, fullname, data, source_mtime):
+ """Return the marshalled bytes from bytecode, verifying the magic
+ number and timestamp along the way.
- """
+ If source_mtime is None then skip the timestamp check.
- @module_for_loader
- def load_module(self, module):
- """Load a source module."""
- return self._load_module(module)
+ """
+ magic = data[:4]
+ raw_timestamp = data[4:8]
+ if len(magic) != 4 or magic != imp.get_magic():
+ raise ImportError("bad magic number in {}".format(fullname))
+ elif len(raw_timestamp) != 4:
+ raise EOFError("bad timestamp in {}".format(fullname))
+ elif source_mtime is not None:
+ if marshal._r_long(raw_timestamp) != source_mtime:
+ raise ImportError("bytecode is stale for {}".format(fullname))
+ # Can't return the code object as errors from marshal loading need to
+ # propagate even when source is available.
+ return data[8:]
- def _load_module(self, module):
- """Initialize a module from source."""
+ @module_for_loader
+ def _load_module(self, module, *, sourceless=False):
+ """Helper for load_module able to handle either source or sourceless
+ loading."""
name = module.__name__
- code_object = self.get_code(module.__name__)
- # __file__ may have been set by the caller, e.g. bytecode path.
- if not hasattr(module, '__file__'):
- module.__file__ = self.source_path(name)
+ code_object = self.get_code(name)
+ module.__file__ = self.get_filename(name)
+ if not sourceless:
+ module.__cached__ = imp.cache_from_source(module.__file__)
+ else:
+ module.__cached__ = module.__file__
+ module.__package__ = name
if self.is_package(name):
- module.__path__ = [module.__file__.rsplit(path_sep, 1)[0]]
- module.__package__ = module.__name__
- if not hasattr(module, '__path__'):
+ module.__path__ = [module.__file__.rsplit(path_sep, 1)[0]]
+ else:
module.__package__ = module.__package__.rpartition('.')[0]
module.__loader__ = self
exec(code_object, module.__dict__)
return module
- def get_code(self, fullname):
- """Get a code object from source."""
- source_path = self.source_path(fullname)
- if source_path is None:
- message = "a source path must exist to load {0}".format(fullname)
- raise ImportError(message)
- source = self.get_data(source_path)
- # Convert to universal newlines.
- line_endings = b'\n'
- for index, c in enumerate(source):
- if c == ord(b'\n'):
- break
- elif c == ord(b'\r'):
- line_endings = b'\r'
- try:
- if source[index+1] == ord(b'\n'):
- line_endings += b'\n'
- except IndexError:
- pass
- break
- if line_endings != b'\n':
- source = source.replace(line_endings, b'\n')
- return compile(source, source_path, 'exec', dont_inherit=True)
- # Never use in implementing import! Imports code within the method.
- def get_source(self, fullname):
- """Return the source code for a module.
+class SourceLoader(_LoaderBasics):
- self.source_path() and self.get_data() are used to implement this
- method.
+ def path_mtime(self, path):
+ """Optional method that returns the modification time (an int) for the
+ specified path, where path is a str.
- """
- path = self.source_path(fullname)
- if path is None:
- return None
- try:
- source_bytes = self.get_data(path)
- except IOError:
- return ImportError("source not available through get_data()")
- import io
- import tokenize
- encoding = tokenize.detect_encoding(io.BytesIO(source_bytes).readline)
- return source_bytes.decode(encoding[0])
+ Implementing this method allows the loader to read bytecode files.
+ """
+ raise NotImplementedError
-class PyPycLoader(PyLoader):
+ def set_data(self, path, data):
+ """Optional method which writes data (bytes) to a file path (a str).
- """Loader base class for Python source and bytecode.
+ Implementing this method allows for the writing of bytecode files.
- Requires implementing the methods needed for PyLoader as well as
- source_mtime, bytecode_path, and write_bytecode.
+ """
+ raise NotImplementedError
- """
- @module_for_loader
- def load_module(self, module):
- """Load a module from source or bytecode."""
- name = module.__name__
- source_path = self.source_path(name)
- bytecode_path = self.bytecode_path(name)
- # get_code can worry about no viable paths existing.
- module.__file__ = source_path or bytecode_path
- return self._load_module(module)
+ def get_source(self, fullname):
+ """Concrete implementation of InspectLoader.get_source."""
+ import tokenize
+ path = self.get_filename(fullname)
+ try:
+ source_bytes = self.get_data(path)
+ except IOError:
+ raise ImportError("source not available through get_data()")
+ encoding = tokenize.detect_encoding(_io.BytesIO(source_bytes).readline)
+ newline_decoder = _io.IncrementalNewlineDecoder(None, True)
+ return newline_decoder.decode(source_bytes.decode(encoding[0]))
def get_code(self, fullname):
- """Get a code object from source or bytecode."""
- # XXX Care enough to make sure this call does not happen if the magic
- # number is bad?
- source_timestamp = self.source_mtime(fullname)
- # Try to use bytecode if it is available.
- bytecode_path = self.bytecode_path(fullname)
- if bytecode_path:
- data = self.get_data(bytecode_path)
+ """Concrete implementation of InspectLoader.get_code.
+
+ Reading of bytecode requires path_mtime to be implemented. To write
+ bytecode, set_data must also be implemented.
+
+ """
+ source_path = self.get_filename(fullname)
+ bytecode_path = imp.cache_from_source(source_path)
+ source_mtime = None
+ if bytecode_path is not None:
try:
- magic = data[:4]
- if len(magic) < 4:
- raise ImportError("bad magic number in {}".format(fullname))
- raw_timestamp = data[4:8]
- if len(raw_timestamp) < 4:
- raise EOFError("bad timestamp in {}".format(fullname))
- pyc_timestamp = marshal._r_long(raw_timestamp)
- bytecode = data[8:]
- # Verify that the magic number is valid.
- if imp.get_magic() != magic:
- raise ImportError("bad magic number in {}".format(fullname))
- # Verify that the bytecode is not stale (only matters when
- # there is source to fall back on.
- if source_timestamp:
- if pyc_timestamp < source_timestamp:
- raise ImportError("bytecode is stale")
- except (ImportError, EOFError):
- # If source is available give it a shot.
- if source_timestamp is not None:
+ source_mtime = self.path_mtime(source_path)
+ except NotImplementedError:
+ pass
+ else:
+ try:
+ data = self.get_data(bytecode_path)
+ except IOError:
pass
else:
- raise
- else:
- # Bytecode seems fine, so try to use it.
- # XXX If the bytecode is ill-formed, would it be beneficial to
- # try for using source if available and issue a warning?
- return marshal.loads(bytecode)
- elif source_timestamp is None:
- raise ImportError("no source or bytecode available to create code "
- "object for {0!r}".format(fullname))
- # Use the source.
- code_object = super().get_code(fullname)
- # Generate bytecode and write it out.
- if not sys.dont_write_bytecode:
+ try:
+ bytes_data = self._bytes_from_bytecode(fullname, data,
+ source_mtime)
+ except (ImportError, EOFError):
+ pass
+ else:
+ found = marshal.loads(bytes_data)
+ if isinstance(found, code_type):
+ return found
+ else:
+ msg = "Non-code object in {}"
+ raise ImportError(msg.format(bytecode_path))
+ source_bytes = self.get_data(source_path)
+ code_object = compile(source_bytes, source_path, 'exec',
+ dont_inherit=True)
+ if (not sys.dont_write_bytecode and bytecode_path is not None and
+ source_mtime is not None):
+ # If e.g. Jython ever implements imp.cache_from_source to have
+ # their own cached file format, this block of code will most likely
+ # throw an exception.
data = bytearray(imp.get_magic())
- data.extend(marshal._w_long(source_timestamp))
+ data.extend(marshal._w_long(source_mtime))
data.extend(marshal.dumps(code_object))
- self.write_bytecode(fullname, data)
+ try:
+ self.set_data(bytecode_path, data)
+ except NotImplementedError:
+ pass
return code_object
+ def load_module(self, fullname):
+ """Concrete implementation of Loader.load_module.
-class _PyFileLoader(PyLoader):
+ Requires ExecutionLoader.get_filename and ResourceLoader.get_data to be
+ implemented to load source code. Use of bytecode is dictated by whether
+ get_code uses/writes bytecode.
- """Load a Python source file."""
+ """
+ return self._load_module(fullname)
- def __init__(self, name, path, is_pkg):
- self._name = name
- self._is_pkg = is_pkg
- # Figure out the base path based on whether it was source or bytecode
- # that was found.
- try:
- self._base_path = _path_without_ext(path, imp.PY_SOURCE)
- except ValueError:
- self._base_path = _path_without_ext(path, imp.PY_COMPILED)
-
- def _find_path(self, ext_type):
- """Find a path from the base path and the specified extension type that
- exists, returning None if one is not found."""
- for suffix in _suffix_list(ext_type):
- path = self._base_path + suffix
- if _path_exists(path):
- return path
- else:
- return None
+
+class _FileLoader:
+
+ """Base file loader class which implements the loader protocol methods that
+ require file system usage."""
+
+ def __init__(self, fullname, path):
+ """Cache the module name and the path to the file found by the
+ finder."""
+ self._name = fullname
+ self._path = path
@_check_name
- def source_path(self, fullname):
- """Return the path to an existing source file for the module, or None
- if one cannot be found."""
- # Not a property so that it is easy to override.
- return self._find_path(imp.PY_SOURCE)
+ def get_filename(self, fullname):
+ """Return the path to the source file as found by the finder."""
+ return self._path
def get_data(self, path):
"""Return the data from path as raw bytes."""
- return _io.FileIO(path, 'r').read() # Assuming bytes.
+ with _io.FileIO(path, 'r') as file:
+ return file.read()
- @_check_name
- def is_package(self, fullname):
- """Return a boolean based on whether the module is a package.
- Raises ImportError (like get_source) if the loader cannot handle the
- package.
+class _SourceFileLoader(_FileLoader, SourceLoader):
- """
- return self._is_pkg
+ """Concrete implementation of SourceLoader using the file system."""
+ def path_mtime(self, path):
+ """Return the modification time for the path."""
+ return int(_os.stat(path).st_mtime)
-class _PyPycFileLoader(PyPycLoader, _PyFileLoader):
+ def set_data(self, path, data):
+ """Write bytes data to a file."""
+ parent, _, filename = path.rpartition(path_sep)
+ path_parts = []
+ # Figure out what directories are missing.
+ while parent and not _path_isdir(parent):
+ parent, _, part = parent.rpartition(path_sep)
+ path_parts.append(part)
+ # Create needed directories.
+ for part in reversed(path_parts):
+ parent = _path_join(parent, part)
+ try:
+ _os.mkdir(parent)
+ except OSError as exc:
+ # Probably another Python process already created the dir.
+ if exc.errno == errno.EEXIST:
+ continue
+ else:
+ raise
+ except IOError as exc:
+ # If can't get proper access, then just forget about writing
+ # the data.
+ if exc.errno == errno.EACCES:
+ return
+ else:
+ raise
+ try:
+ with _io.FileIO(path, 'wb') as file:
+ file.write(data)
+ except IOError as exc:
+ # Don't worry if you can't write bytecode.
+ if exc.errno == errno.EACCES:
+ return
+ else:
+ raise
- """Load a module from a source or bytecode file."""
- @_check_name
- def source_mtime(self, name):
- """Return the modification time of the source for the specified
- module."""
- source_path = self.source_path(name)
- if not source_path:
- return None
- return int(_os.stat(source_path).st_mtime)
+class _SourcelessFileLoader(_FileLoader, _LoaderBasics):
- @_check_name
- def bytecode_path(self, fullname):
- """Return the path to a bytecode file, or None if one does not
- exist."""
- # Not a property for easy overriding.
- return self._find_path(imp.PY_COMPILED)
+ """Loader which handles sourceless file imports."""
- @_check_name
- def write_bytecode(self, name, data):
- """Write out 'data' for the specified module, returning a boolean
- signifying if the write-out actually occurred.
+ def load_module(self, fullname):
+ return self._load_module(fullname, sourceless=True)
- Raises ImportError (just like get_source) if the specified module
- cannot be handled by the loader.
+ def get_code(self, fullname):
+ path = self.get_filename(fullname)
+ data = self.get_data(path)
+ bytes_data = self._bytes_from_bytecode(fullname, data, None)
+ found = marshal.loads(bytes_data)
+ if isinstance(found, code_type):
+ return found
+ else:
+ raise ImportError("Non-code object in {}".format(path))
- """
- bytecode_path = self.bytecode_path(name)
- if not bytecode_path:
- bytecode_path = self._base_path + _suffix_list(imp.PY_COMPILED)[0]
- try:
- # Assuming bytes.
- with _closing(_io.FileIO(bytecode_path, 'w')) as bytecode_file:
- bytecode_file.write(data)
- return True
- except IOError as exc:
- if exc.errno == errno.EACCES:
- return False
- else:
- raise
+ def get_source(self, fullname):
+ """Return None as there is no source code."""
+ return None
class _ExtensionFileLoader:
@@ -547,7 +533,7 @@ class _ExtensionFileLoader:
"""
- def __init__(self, name, path, is_pkg):
+ def __init__(self, name, path):
"""Initialize the loader.
If is_pkg is True then an exception is raised as extension modules
@@ -556,8 +542,6 @@ class _ExtensionFileLoader:
"""
self._name = name
self._path = path
- if is_pkg:
- raise ValueError("extension modules cannot be packages")
@_check_name
@set_package
@@ -655,147 +639,88 @@ class PathFinder:
return None
-class _ChainedFinder:
-
- """Finder that sequentially calls other finders."""
-
- def __init__(self, *finders):
- self._finders = finders
-
- def find_module(self, fullname, path=None):
- for finder in self._finders:
- result = finder.find_module(fullname, path)
- if result:
- return result
- else:
- return None
-
-
class _FileFinder:
- """Base class for file finders.
-
- Subclasses are expected to define the following attributes:
-
- * _suffixes
- Sequence of file suffixes whose order will be followed.
-
- * _possible_package
- True if importer should check for packages.
+ """File-based finder.
- * _loader
- A callable that takes the module name, a file path, and whether
- the path points to a package and returns a loader for the module
- found at that path.
+ Constructor takes a list of objects detailing what file extensions their
+ loader supports along with whether it can be used for a package.
"""
- def __init__(self, path_entry):
- """Initialize an importer for the passed-in sys.path entry (which is
- assumed to have already been verified as an existing directory).
-
- Can be used as an entry on sys.path_hook.
-
- """
- absolute_path = _path_absolute(path_entry)
- if not _path_isdir(absolute_path):
- raise ImportError("only directories are supported")
- self._path_entry = absolute_path
-
- def find_module(self, fullname, path=None):
+ def __init__(self, path, *details):
+ """Initialize with finder details."""
+ packages = []
+ modules = []
+ for detail in details:
+ modules.extend((suffix, detail.loader) for suffix in detail.suffixes)
+ if detail.supports_packages:
+ packages.extend((suffix, detail.loader)
+ for suffix in detail.suffixes)
+ self.packages = packages
+ self.modules = modules
+ self.path = path
+
+ def find_module(self, fullname):
+ """Try to find a loader for the specified module."""
tail_module = fullname.rpartition('.')[2]
- package_directory = None
- if self._possible_package:
- for ext in self._suffixes:
- package_directory = _path_join(self._path_entry, tail_module)
- init_filename = '__init__' + ext
- package_init = _path_join(package_directory, init_filename)
- if (_path_isfile(package_init) and
- _case_ok(self._path_entry, tail_module) and
- _case_ok(package_directory, init_filename)):
- return self._loader(fullname, package_init, True)
- for ext in self._suffixes:
- file_name = tail_module + ext
- file_path = _path_join(self._path_entry, file_name)
- if (_path_isfile(file_path) and
- _case_ok(self._path_entry, file_name)):
- return self._loader(fullname, file_path, False)
- else:
- # Raise a warning if it matches a directory w/o an __init__ file.
- if (package_directory is not None and
- _path_isdir(package_directory) and
- _case_ok(self._path_entry, tail_module)):
- _warnings.warn("Not importing directory %s: missing __init__"
- % package_directory, ImportWarning)
- return None
-
-
-class _PyFileFinder(_FileFinder):
-
- """Importer for source/bytecode files."""
-
- _possible_package = True
- _loader = _PyFileLoader
-
- def __init__(self, path_entry):
- # Lack of imp during class creation means _suffixes is set here.
- # Make sure that Python source files are listed first! Needed for an
- # optimization by the loader.
- self._suffixes = _suffix_list(imp.PY_SOURCE)
- super().__init__(path_entry)
-
-
-class _PyPycFileFinder(_PyFileFinder):
+ base_path = _path_join(self.path, tail_module)
+ if _path_isdir(base_path) and _case_ok(self.path, tail_module):
+ for suffix, loader in self.packages:
+ init_filename = '__init__' + suffix
+ full_path = _path_join(base_path, init_filename)
+ if (_path_isfile(full_path) and
+ _case_ok(base_path, init_filename)):
+ return loader(fullname, full_path)
+ else:
+ msg = "Not importing directory {}: missing __init__"
+ _warnings.warn(msg.format(base_path), ImportWarning)
+ for suffix, loader in self.modules:
+ mod_filename = tail_module + suffix
+ full_path = _path_join(self.path, mod_filename)
+ if _path_isfile(full_path) and _case_ok(self.path, mod_filename):
+ return loader(fullname, full_path)
+ return None
- """Finder for source and bytecode files."""
+class _SourceFinderDetails:
- _loader = _PyPycFileLoader
+ loader = _SourceFileLoader
+ supports_packages = True
- def __init__(self, path_entry):
- super().__init__(path_entry)
- self._suffixes += _suffix_list(imp.PY_COMPILED)
+ def __init__(self):
+ self.suffixes = _suffix_list(imp.PY_SOURCE)
+class _SourcelessFinderDetails:
+ loader = _SourcelessFileLoader
+ supports_packages = True
+ def __init__(self):
+ self.suffixes = _suffix_list(imp.PY_COMPILED)
-class _ExtensionFileFinder(_FileFinder):
- """Importer for extension files."""
+class _ExtensionFinderDetails:
- _possible_package = False
- _loader = _ExtensionFileLoader
+ loader = _ExtensionFileLoader
+ supports_packages = False
- def __init__(self, path_entry):
- # Assigning to _suffixes here instead of at the class level because
- # imp is not imported at the time of class creation.
- self._suffixes = _suffix_list(imp.C_EXTENSION)
- super().__init__(path_entry)
+ def __init__(self):
+ self.suffixes = _suffix_list(imp.C_EXTENSION)
# Import itself ###############################################################
-def _chained_path_hook(*path_hooks):
- """Create a closure which sequentially checks path hooks to see which ones
- (if any) can work with a path."""
- def path_hook(entry):
- """Check to see if 'entry' matches any of the enclosed path hooks."""
- finders = []
- for hook in path_hooks:
- try:
- finder = hook(entry)
- except ImportError:
- continue
- else:
- finders.append(finder)
- if not finders:
- raise ImportError("no finder found")
- else:
- return _ChainedFinder(*finders)
-
- return path_hook
+def _file_path_hook(path):
+ """If the path is a directory, return a file-based finder."""
+ if _path_isdir(path):
+ return _FileFinder(path, _ExtensionFinderDetails(),
+ _SourceFinderDetails(),
+ _SourcelessFinderDetails())
+ else:
+ raise ImportError("only directories are supported")
-_DEFAULT_PATH_HOOK = _chained_path_hook(_ExtensionFileFinder, _PyPycFileFinder)
+_DEFAULT_PATH_HOOK = _file_path_hook
class _DefaultPathFinder(PathFinder):
@@ -833,6 +758,8 @@ class _ImportLockContext:
_IMPLICIT_META_PATH = [BuiltinImporter, FrozenImporter, _DefaultPathFinder]
+_ERR_MSG = 'No module named {}'
+
def _gcd_import(name, package=None, level=0):
"""Import and return the module based on its name, the package the call is
being made from, and the level adjustment.
@@ -880,7 +807,11 @@ def _gcd_import(name, package=None, level=0):
_gcd_import(parent)
# Backwards-compatibility; be nicer to skip the dict lookup.
parent_module = sys.modules[parent]
- path = parent_module.__path__
+ try:
+ path = parent_module.__path__
+ except AttributeError:
+ msg = (_ERR_MSG + '; {} is not a package').format(name, parent)
+ raise ImportError(msg)
meta_path = sys.meta_path + _IMPLICIT_META_PATH
for finder in meta_path:
loader = finder.find_module(name, path)
@@ -888,7 +819,7 @@ def _gcd_import(name, package=None, level=0):
loader.load_module(name)
break
else:
- raise ImportError("No module named {0}".format(name))
+ raise ImportError(_ERR_MSG.format(name))
# Backwards-compatibility; be nicer to skip the dict lookup.
module = sys.modules[name]
if parent:
@@ -918,13 +849,15 @@ def __import__(name, globals={}, locals={}, fromlist=[], level=0):
import (e.g. ``from ..pkg import mod`` would have a 'level' of 2).
"""
+ if not hasattr(name, 'rpartition'):
+ raise TypeError("module name must be str, not {}".format(type(name)))
if level == 0:
module = _gcd_import(name)
else:
- # __package__ is not guaranteed to be defined.
- try:
- package = globals['__package__']
- except KeyError:
+ # __package__ is not guaranteed to be defined or could be set to None
+ # to represent that it's proper value is unknown
+ package = globals.get('__package__')
+ if package is None:
package = globals['__name__']
if '__path__' not in globals:
package = package.rpartition('.')[0]
@@ -944,6 +877,7 @@ def __import__(name, globals={}, locals={}, fromlist=[], level=0):
# If a package was imported, try to import stuff from fromlist.
if hasattr(module, '__path__'):
if '*' in fromlist and hasattr(module, '__all__'):
+ fromlist = list(fromlist)
fromlist.remove('*')
fromlist.extend(module.__all__)
for x in (y for y in fromlist if not hasattr(module,y)):
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
index 7b89d0b4c9..fa343f85a4 100644
--- a/Lib/importlib/abc.py
+++ b/Lib/importlib/abc.py
@@ -1,8 +1,16 @@
"""Abstract base classes related to import."""
from . import _bootstrap
from . import machinery
+from . import util
import abc
+import imp
+import io
+import marshal
+import os.path
+import sys
+import tokenize
import types
+import warnings
class Loader(metaclass=abc.ABCMeta):
@@ -10,8 +18,9 @@ class Loader(metaclass=abc.ABCMeta):
"""Abstract base class for import loaders."""
@abc.abstractmethod
- def load_module(self, fullname:str) -> types.ModuleType:
- """Abstract method which when implemented should load a module."""
+ def load_module(self, fullname):
+ """Abstract method which when implemented should load a module.
+ The fullname is a str."""
raise NotImplementedError
@@ -20,8 +29,11 @@ class Finder(metaclass=abc.ABCMeta):
"""Abstract base class for import finders."""
@abc.abstractmethod
- def find_module(self, fullname:str, path:[str]=None) -> Loader:
- """Abstract method which when implemented should find a module."""
+ def find_module(self, fullname, path=None):
+ """Abstract method which when implemented should find a module.
+ The fullname is a str and the optional path is a str or None.
+ Returns a Loader object.
+ """
raise NotImplementedError
Finder.register(machinery.BuiltinImporter)
@@ -39,9 +51,9 @@ class ResourceLoader(Loader):
"""
@abc.abstractmethod
- def get_data(self, path:str) -> bytes:
+ def get_data(self, path):
"""Abstract method which when implemented should return the bytes for
- the specified path."""
+ the specified path. The path must be a str."""
raise NotImplementedError
@@ -55,68 +67,238 @@ class InspectLoader(Loader):
"""
@abc.abstractmethod
- def is_package(self, fullname:str) -> bool:
+ def is_package(self, fullname):
"""Abstract method which when implemented should return whether the
- module is a package."""
- return NotImplementedError
+ module is a package. The fullname is a str. Returns a bool."""
+ raise NotImplementedError
@abc.abstractmethod
- def get_code(self, fullname:str) -> types.CodeType:
+ def get_code(self, fullname):
"""Abstract method which when implemented should return the code object
- for the module"""
- return NotImplementedError
+ for the module. The fullname is a str. Returns a types.CodeType."""
+ raise NotImplementedError
@abc.abstractmethod
- def get_source(self, fullname:str) -> str:
+ def get_source(self, fullname):
"""Abstract method which should return the source code for the
- module."""
- return NotImplementedError
+ module. The fullname is a str. Returns a str."""
+ raise NotImplementedError
InspectLoader.register(machinery.BuiltinImporter)
InspectLoader.register(machinery.FrozenImporter)
-class PyLoader(_bootstrap.PyLoader, ResourceLoader, InspectLoader):
+class ExecutionLoader(InspectLoader):
- """Abstract base class to assist in loading source code by requiring only
- back-end storage methods to be implemented.
+ """Abstract base class for loaders that wish to support the execution of
+ modules as scripts.
- The methods get_code, get_source, and load_module are implemented for the
- user.
+ This ABC represents one of the optional protocols specified in PEP 302.
+
+ """
+
+ @abc.abstractmethod
+ def get_filename(self, fullname):
+ """Abstract method which should return the value that __file__ is to be
+ set to."""
+ raise NotImplementedError
+
+
+class SourceLoader(_bootstrap.SourceLoader, ResourceLoader, ExecutionLoader):
+
+ """Abstract base class for loading source code (and optionally any
+ corresponding bytecode).
+
+ To support loading from source code, the abstractmethods inherited from
+ ResourceLoader and ExecutionLoader need to be implemented. To also support
+ loading from bytecode, the optional methods specified directly by this ABC
+ is required.
+
+ Inherited abstractmethods not implemented in this ABC:
+
+ * ResourceLoader.get_data
+ * ExecutionLoader.get_filename
+
+ """
+
+ def path_mtime(self, path):
+ """Return the (int) modification time for the path (str)."""
+ raise NotImplementedError
+
+ def set_data(self, path, data):
+ """Write the bytes to the path (if possible).
+
+ Accepts a str path and data as bytes.
+
+ Any needed intermediary directories are to be created. If for some
+ reason the file cannot be written because of permissions, fail
+ silently.
+
+ """
+ raise NotImplementedError
+
+
+class PyLoader(SourceLoader):
+
+ """Implement the deprecated PyLoader ABC in terms of SourceLoader.
+
+ This class has been deprecated! It is slated for removal in Python 3.4.
+ If compatibility with Python 3.1 is not needed then implement the
+ SourceLoader ABC instead of this class. If Python 3.1 compatibility is
+ needed, then use the following idiom to have a single class that is
+ compatible with Python 3.1 onwards::
+
+ try:
+ from importlib.abc import SourceLoader
+ except ImportError:
+ from importlib.abc import PyLoader as SourceLoader
+
+
+ class CustomLoader(SourceLoader):
+ def get_filename(self, fullname):
+ # Implement ...
+
+ def source_path(self, fullname):
+ '''Implement source_path in terms of get_filename.'''
+ try:
+ return self.get_filename(fullname)
+ except ImportError:
+ return None
+
+ def is_package(self, fullname):
+ filename = os.path.basename(self.get_filename(fullname))
+ return os.path.splitext(filename)[0] == '__init__'
"""
@abc.abstractmethod
- def source_path(self, fullname:str) -> object:
- """Abstract method which when implemented should return the path to the
- sourced code for the module."""
+ def is_package(self, fullname):
+ raise NotImplementedError
+
+ @abc.abstractmethod
+ def source_path(self, fullname):
+ """Abstract method. Accepts a str module name and returns the path to
+ the source code for the module."""
raise NotImplementedError
+ def get_filename(self, fullname):
+ """Implement get_filename in terms of source_path.
-class PyPycLoader(_bootstrap.PyPycLoader, PyLoader):
+ As get_filename should only return a source file path there is no
+ chance of the path not existing but loading still being possible, so
+ ImportError should propagate instead of being turned into returning
+ None.
+
+ """
+ warnings.warn("importlib.abc.PyLoader is deprecated and is "
+ "slated for removal in Python 3.4; "
+ "use SourceLoader instead. "
+ "See the importlib documentation on how to be "
+ "compatible with Python 3.1 onwards.",
+ PendingDeprecationWarning)
+ path = self.source_path(fullname)
+ if path is None:
+ raise ImportError
+ else:
+ return path
+
+
+class PyPycLoader(PyLoader):
"""Abstract base class to assist in loading source and bytecode by
requiring only back-end storage methods to be implemented.
+ This class has been deprecated! Removal is slated for Python 3.4. Implement
+ the SourceLoader ABC instead. If Python 3.1 compatibility is needed, see
+ PyLoader.
+
The methods get_code, get_source, and load_module are implemented for the
user.
"""
+ def get_filename(self, fullname):
+ """Return the source or bytecode file path."""
+ path = self.source_path(fullname)
+ if path is not None:
+ return path
+ path = self.bytecode_path(fullname)
+ if path is not None:
+ return path
+ raise ImportError("no source or bytecode path available for "
+ "{0!r}".format(fullname))
+
+ def get_code(self, fullname):
+ """Get a code object from source or bytecode."""
+ warnings.warn("importlib.abc.PyPycLoader is deprecated and slated for "
+ "removal in Python 3.4; use SourceLoader instead. "
+ "If Python 3.1 compatibility is required, see the "
+ "latest documentation for PyLoader.",
+ PendingDeprecationWarning)
+ source_timestamp = self.source_mtime(fullname)
+ # Try to use bytecode if it is available.
+ bytecode_path = self.bytecode_path(fullname)
+ if bytecode_path:
+ data = self.get_data(bytecode_path)
+ try:
+ magic = data[:4]
+ if len(magic) < 4:
+ raise ImportError("bad magic number in {}".format(fullname))
+ raw_timestamp = data[4:8]
+ if len(raw_timestamp) < 4:
+ raise EOFError("bad timestamp in {}".format(fullname))
+ pyc_timestamp = marshal._r_long(raw_timestamp)
+ bytecode = data[8:]
+ # Verify that the magic number is valid.
+ if imp.get_magic() != magic:
+ raise ImportError("bad magic number in {}".format(fullname))
+ # Verify that the bytecode is not stale (only matters when
+ # there is source to fall back on.
+ if source_timestamp:
+ if pyc_timestamp < source_timestamp:
+ raise ImportError("bytecode is stale")
+ except (ImportError, EOFError):
+ # If source is available give it a shot.
+ if source_timestamp is not None:
+ pass
+ else:
+ raise
+ else:
+ # Bytecode seems fine, so try to use it.
+ return marshal.loads(bytecode)
+ elif source_timestamp is None:
+ raise ImportError("no source or bytecode available to create code "
+ "object for {0!r}".format(fullname))
+ # Use the source.
+ source_path = self.source_path(fullname)
+ if source_path is None:
+ message = "a source path must exist to load {0}".format(fullname)
+ raise ImportError(message)
+ source = self.get_data(source_path)
+ code_object = compile(source, source_path, 'exec', dont_inherit=True)
+ # Generate bytecode and write it out.
+ if not sys.dont_write_bytecode:
+ data = bytearray(imp.get_magic())
+ data.extend(marshal._w_long(source_timestamp))
+ data.extend(marshal.dumps(code_object))
+ self.write_bytecode(fullname, data)
+ return code_object
+
@abc.abstractmethod
- def source_mtime(self, fullname:str) -> int:
- """Abstract method which when implemented should return the
+ def source_mtime(self, fullname):
+ """Abstract method. Accepts a str filename and returns an int
modification time for the source of the module."""
raise NotImplementedError
@abc.abstractmethod
- def bytecode_path(self, fullname:str) -> object:
- """Abstract method which when implemented should return the path to the
- bytecode for the module."""
+ def bytecode_path(self, fullname):
+ """Abstract method. Accepts a str filename and returns the str pathname
+ to the bytecode for the module."""
raise NotImplementedError
@abc.abstractmethod
- def write_bytecode(self, fullname:str, bytecode:bytes):
- """Abstract method which when implemented should attempt to write the
- bytecode for the module."""
+ def write_bytecode(self, fullname, bytecode):
+ """Abstract method. Accepts a str filename and bytes object
+ representing the bytecode for the module. Returns a boolean
+ representing whether the bytecode was written or not."""
raise NotImplementedError
diff --git a/Lib/importlib/test/__init__.py b/Lib/importlib/test/__init__.py
index bda33e69fe..e69de29bb2 100644
--- a/Lib/importlib/test/__init__.py
+++ b/Lib/importlib/test/__init__.py
@@ -1,31 +0,0 @@
-import os.path
-import sys
-import unittest
-
-
-def test_suite(package=__package__, directory=os.path.dirname(__file__)):
- suite = unittest.TestSuite()
- for name in os.listdir(directory):
- if name.startswith('.'):
- continue
- path = os.path.join(directory, name)
- if (os.path.isfile(path) and name.startswith('test_') and
- name.endswith('.py')):
- submodule_name = os.path.splitext(name)[0]
- module_name = "{0}.{1}".format(package, submodule_name)
- __import__(module_name, level=0)
- module_tests = unittest.findTestCases(sys.modules[module_name])
- suite.addTest(module_tests)
- elif os.path.isdir(path):
- package_name = "{0}.{1}".format(package, name)
- __import__(package_name, level=0)
- package_tests = getattr(sys.modules[package_name], 'test_suite')()
- suite.addTest(package_tests)
- else:
- continue
- return suite
-
-
-if __name__ == '__main__':
- from test.support import run_unittest
- run_unittest(test_suite('importlib.test'))
diff --git a/Lib/importlib/test/__main__.py b/Lib/importlib/test/__main__.py
new file mode 100644
index 0000000000..decc53d8c5
--- /dev/null
+++ b/Lib/importlib/test/__main__.py
@@ -0,0 +1,29 @@
+"""Run importlib's test suite.
+
+Specifying the ``--builtin`` flag will run tests, where applicable, with
+builtins.__import__ instead of importlib.__import__.
+
+"""
+import importlib
+from importlib.test.import_ import util
+import os.path
+from test.support import run_unittest
+import sys
+import unittest
+
+
+def test_main():
+ if '__pycache__' in __file__:
+ parts = __file__.split(os.path.sep)
+ start_dir = sep.join(parts[:-2])
+ else:
+ start_dir = os.path.dirname(__file__)
+ top_dir = os.path.dirname(os.path.dirname(start_dir))
+ test_loader = unittest.TestLoader()
+ if '--builtin' in sys.argv:
+ util.using___import__ = True
+ run_unittest(test_loader.discover(start_dir, top_level_dir=top_dir))
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/benchmark.py b/Lib/importlib/test/benchmark.py
index f709a3cce9..b5de6c6b01 100644
--- a/Lib/importlib/test/benchmark.py
+++ b/Lib/importlib/test/benchmark.py
@@ -1,69 +1,159 @@
+"""Benchmark some basic import use-cases.
+
+The assumption is made that this benchmark is run in a fresh interpreter and
+thus has no external changes made to import-related attributes in sys.
+
+"""
from . import util
from .source import util as source_util
-import gc
import decimal
import imp
import importlib
+import os
+import py_compile
import sys
import timeit
-def bench_cache(import_, repeat, number):
- """Measure the time it takes to pull from sys.modules."""
+def bench(name, cleanup=lambda: None, *, seconds=1, repeat=3):
+ """Bench the given statement as many times as necessary until total
+ executions take one second."""
+ stmt = "__import__({!r})".format(name)
+ timer = timeit.Timer(stmt)
+ for x in range(repeat):
+ total_time = 0
+ count = 0
+ while total_time < seconds:
+ try:
+ total_time += timer.timeit(1)
+ finally:
+ cleanup()
+ count += 1
+ else:
+ # One execution too far
+ if total_time > seconds:
+ count -= 1
+ yield count // seconds
+
+def from_cache(seconds, repeat):
+ """sys.modules"""
name = '<benchmark import>'
+ module = imp.new_module(name)
+ module.__file__ = '<test>'
+ module.__package__ = ''
with util.uncache(name):
- module = imp.new_module(name)
sys.modules[name] = module
- runs = []
- for x in range(repeat):
- start_time = timeit.default_timer()
- for y in range(number):
- import_(name)
- end_time = timeit.default_timer()
- runs.append(end_time - start_time)
- return min(runs)
+ for result in bench(name, repeat=repeat, seconds=seconds):
+ yield result
-def bench_importing_source(import_, repeat, number, loc=100000):
- """Measure importing source from disk.
+def builtin_mod(seconds, repeat):
+ """Built-in module"""
+ name = 'errno'
+ if name in sys.modules:
+ del sys.modules[name]
+ # Relying on built-in importer being implicit.
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
- For worst-case scenario, the line endings are \\r\\n and thus require
- universal newline translation.
- """
- name = '__benchmark'
- with source_util.create_modules(name) as mapping:
- with open(mapping[name], 'w') as file:
- for x in range(loc):
- file.write("{0}\r\n".format(x))
- with util.import_state(path=[mapping['.root']]):
- runs = []
- for x in range(repeat):
- start_time = timeit.default_timer()
- for y in range(number):
- try:
- import_(name)
- finally:
- del sys.modules[name]
- end_time = timeit.default_timer()
- runs.append(end_time - start_time)
- return min(runs)
+def source_wo_bytecode(seconds, repeat):
+ """Source w/o bytecode: simple"""
+ sys.dont_write_bytecode = True
+ try:
+ name = '__importlib_test_benchmark__'
+ # Clears out sys.modules and puts an entry at the front of sys.path.
+ with source_util.create_modules(name) as mapping:
+ assert not os.path.exists(imp.cache_from_source(mapping[name]))
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
+ finally:
+ sys.dont_write_bytecode = False
-def main(import_):
- args = [('sys.modules', bench_cache, 5, 500000),
- ('source', bench_importing_source, 5, 10000)]
- test_msg = "{test}, {number} times (best of {repeat}):"
- result_msg = "{result:.2f} secs"
- gc.disable()
+def decimal_wo_bytecode(seconds, repeat):
+ """Source w/o bytecode: decimal"""
+ name = 'decimal'
+ decimal_bytecode = imp.cache_from_source(decimal.__file__)
+ if os.path.exists(decimal_bytecode):
+ os.unlink(decimal_bytecode)
+ sys.dont_write_bytecode = True
try:
- for name, meth, repeat, number in args:
- result = meth(import_, repeat, number)
- print(test_msg.format(test=name, repeat=repeat,
- number=number).ljust(40),
- result_msg.format(result=result).rjust(10))
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
finally:
- gc.enable()
+ sys.dont_write_bytecode = False
+
+
+def source_writing_bytecode(seconds, repeat):
+ """Source writing bytecode: simple"""
+ assert not sys.dont_write_bytecode
+ name = '__importlib_test_benchmark__'
+ with source_util.create_modules(name) as mapping:
+ def cleanup():
+ sys.modules.pop(name)
+ os.unlink(imp.cache_from_source(mapping[name]))
+ for result in bench(name, cleanup, repeat=repeat, seconds=seconds):
+ assert not os.path.exists(imp.cache_from_source(mapping[name]))
+ yield result
+
+
+def decimal_writing_bytecode(seconds, repeat):
+ """Source writing bytecode: decimal"""
+ assert not sys.dont_write_bytecode
+ name = 'decimal'
+ def cleanup():
+ sys.modules.pop(name)
+ os.unlink(imp.cache_from_source(decimal.__file__))
+ for result in bench(name, cleanup, repeat=repeat, seconds=seconds):
+ yield result
+
+
+def source_using_bytecode(seconds, repeat):
+ """Bytecode w/ source: simple"""
+ name = '__importlib_test_benchmark__'
+ with source_util.create_modules(name) as mapping:
+ py_compile.compile(mapping[name])
+ assert os.path.exists(imp.cache_from_source(mapping[name]))
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
+
+
+def decimal_using_bytecode(seconds, repeat):
+ """Bytecode w/ source: decimal"""
+ name = 'decimal'
+ py_compile.compile(decimal.__file__)
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
+
+
+def main(import_):
+ __builtins__.__import__ = import_
+ benchmarks = (from_cache, builtin_mod,
+ source_using_bytecode, source_wo_bytecode,
+ source_writing_bytecode,
+ decimal_using_bytecode, decimal_writing_bytecode,
+ decimal_wo_bytecode,)
+ seconds = 1
+ seconds_plural = 's' if seconds > 1 else ''
+ repeat = 3
+ header = "Measuring imports/second over {} second{}, best out of {}\n"
+ print(header.format(seconds, seconds_plural, repeat))
+ for benchmark in benchmarks:
+ print(benchmark.__doc__, "[", end=' ')
+ sys.stdout.flush()
+ results = []
+ for result in benchmark(seconds=seconds, repeat=repeat):
+ results.append(result)
+ print(result, end=' ')
+ sys.stdout.flush()
+ assert not sys.dont_write_bytecode
+ print("]", "best is", format(max(results), ',d'))
if __name__ == '__main__':
@@ -74,7 +164,7 @@ if __name__ == '__main__':
default=False, help="use the built-in __import__")
options, args = parser.parse_args()
if args:
- raise RuntimeError("unrecognized args: {0}".format(args))
+ raise RuntimeError("unrecognized args: {}".format(args))
import_ = __import__
if not options.builtin:
import_ = importlib.__import__
diff --git a/Lib/importlib/test/builtin/test_loader.py b/Lib/importlib/test/builtin/test_loader.py
index dff00ce4bd..1a8539b1e8 100644
--- a/Lib/importlib/test/builtin/test_loader.py
+++ b/Lib/importlib/test/builtin/test_loader.py
@@ -54,13 +54,15 @@ class LoaderTests(abc.LoaderTests):
def test_unloadable(self):
name = 'dssdsdfff'
assert name not in sys.builtin_module_names
- self.assertRaises(ImportError, self.load_module, name)
+ with self.assertRaises(ImportError):
+ self.load_module(name)
def test_already_imported(self):
# Using the name of a module already imported but not a built-in should
# still fail.
assert hasattr(importlib, '__file__') # Not a built-in.
- self.assertRaises(ImportError, self.load_module, 'importlib')
+ with self.assertRaises(ImportError):
+ self.load_module('importlib')
class InspectLoaderTests(unittest.TestCase):
@@ -86,7 +88,8 @@ class InspectLoaderTests(unittest.TestCase):
# Modules not built-in should raise ImportError.
for meth_name in ('get_code', 'get_source', 'is_package'):
method = getattr(machinery.BuiltinImporter, meth_name)
- self.assertRaises(ImportError, method, builtin_util.BAD_NAME)
+ with self.assertRaises(ImportError):
+ method(builtin_util.BAD_NAME)
diff --git a/Lib/importlib/test/extension/test_case_sensitivity.py b/Lib/importlib/test/extension/test_case_sensitivity.py
index 3865539b60..e062fb6597 100644
--- a/Lib/importlib/test/extension/test_case_sensitivity.py
+++ b/Lib/importlib/test/extension/test_case_sensitivity.py
@@ -13,7 +13,8 @@ class ExtensionModuleCaseSensitivityTest(unittest.TestCase):
good_name = ext_util.NAME
bad_name = good_name.upper()
assert good_name != bad_name
- finder = _bootstrap._ExtensionFileFinder(ext_util.PATH)
+ finder = _bootstrap._FileFinder(ext_util.PATH,
+ _bootstrap._ExtensionFinderDetails())
return finder.find_module(bad_name)
def test_case_sensitive(self):
diff --git a/Lib/importlib/test/extension/test_finder.py b/Lib/importlib/test/extension/test_finder.py
index 546a1760e1..ea97483317 100644
--- a/Lib/importlib/test/extension/test_finder.py
+++ b/Lib/importlib/test/extension/test_finder.py
@@ -9,7 +9,8 @@ class FinderTests(abc.FinderTests):
"""Test the finder for extension modules."""
def find_module(self, fullname):
- importer = _bootstrap._ExtensionFileFinder(util.PATH)
+ importer = _bootstrap._FileFinder(util.PATH,
+ _bootstrap._ExtensionFinderDetails())
return importer.find_module(fullname)
def test_module(self):
diff --git a/Lib/importlib/test/extension/test_loader.py b/Lib/importlib/test/extension/test_loader.py
index 71841c64ac..4a783db8a5 100644
--- a/Lib/importlib/test/extension/test_loader.py
+++ b/Lib/importlib/test/extension/test_loader.py
@@ -13,7 +13,7 @@ class LoaderTests(abc.LoaderTests):
def load_module(self, fullname):
loader = _bootstrap._ExtensionFileLoader(ext_util.NAME,
- ext_util.FILEPATH, False)
+ ext_util.FILEPATH)
return loader.load_module(fullname)
def test_module(self):
@@ -46,7 +46,8 @@ class LoaderTests(abc.LoaderTests):
pass
def test_unloadable(self):
- self.assertRaises(ImportError, self.load_module, 'asdfjkl;')
+ with self.assertRaises(ImportError):
+ self.load_module('asdfjkl;')
def test_main():
diff --git a/Lib/importlib/test/extension/test_path_hook.py b/Lib/importlib/test/extension/test_path_hook.py
index bf2f411484..4610420d29 100644
--- a/Lib/importlib/test/extension/test_path_hook.py
+++ b/Lib/importlib/test/extension/test_path_hook.py
@@ -14,7 +14,7 @@ class PathHookTests(unittest.TestCase):
# XXX Should it only work for directories containing an extension module?
def hook(self, entry):
- return _bootstrap._ExtensionFileFinder(entry)
+ return _bootstrap._file_path_hook(entry)
def test_success(self):
# Path hook should handle a directory where a known extension module
diff --git a/Lib/importlib/test/frozen/test_loader.py b/Lib/importlib/test/frozen/test_loader.py
index fa64f30d30..c05e22ce1b 100644
--- a/Lib/importlib/test/frozen/test_loader.py
+++ b/Lib/importlib/test/frozen/test_loader.py
@@ -51,8 +51,8 @@ class LoaderTests(abc.LoaderTests):
def test_unloadable(self):
assert machinery.FrozenImporter.find_module('_not_real') is None
- self.assertRaises(ImportError, machinery.FrozenImporter.load_module,
- '_not_real')
+ with self.assertRaises(ImportError):
+ machinery.FrozenImporter.load_module('_not_real')
class InspectLoaderTests(unittest.TestCase):
@@ -84,7 +84,8 @@ class InspectLoaderTests(unittest.TestCase):
# Raise ImportError for modules that are not frozen.
for meth_name in ('get_code', 'get_source', 'is_package'):
method = getattr(machinery.FrozenImporter, meth_name)
- self.assertRaises(ImportError, method, 'importlib')
+ with self.assertRaises(ImportError):
+ method('importlib')
def test_main():
diff --git a/Lib/importlib/test/import_/test___package__.py b/Lib/importlib/test/import_/test___package__.py
index 4dc6901bdb..5056ae59cc 100644
--- a/Lib/importlib/test/import_/test___package__.py
+++ b/Lib/importlib/test/import_/test___package__.py
@@ -19,8 +19,9 @@ class Using__package__(unittest.TestCase):
base = package.rsplit('.', level)[0]
return '{0}.{1}'.format(base, name)
- But since there is no guarantee that __package__ has been set, there has to
- be a way to calculate the attribute's value [__name__]::
+ But since there is no guarantee that __package__ has been set (or not been
+ set to None [None]), there has to be a way to calculate the attribute's value
+ [__name__]::
def calc_package(caller_name, has___path__):
if has__path__:
@@ -43,28 +44,34 @@ class Using__package__(unittest.TestCase):
fromlist=['attr'], level=2)
self.assertEqual(module.__name__, 'pkg')
- def test_using___name__(self):
+ def test_using___name__(self, package_as_None=False):
# [__name__]
+ globals_ = {'__name__': 'pkg.fake', '__path__': []}
+ if package_as_None:
+ globals_['__package__'] = None
with util.mock_modules('pkg.__init__', 'pkg.fake') as importer:
with util.import_state(meta_path=[importer]):
import_util.import_('pkg.fake')
- module = import_util.import_('',
- globals={'__name__': 'pkg.fake',
- '__path__': []},
- fromlist=['attr'], level=2)
+ module = import_util.import_('', globals= globals_,
+ fromlist=['attr'], level=2)
self.assertEqual(module.__name__, 'pkg')
+ def test_None_as___package__(self):
+ # [None]
+ self.test_using___name__(package_as_None=True)
+
def test_bad__package__(self):
globals = {'__package__': '<not real>'}
- self.assertRaises(SystemError, import_util.import_,'', globals, {},
- ['relimport'], 1)
+ with self.assertRaises(SystemError):
+ import_util.import_('', globals, {}, ['relimport'], 1)
def test_bunk__package__(self):
globals = {'__package__': 42}
- self.assertRaises(ValueError, import_util.import_, '', globals, {},
- ['relimport'], 1)
+ with self.assertRaises(ValueError):
+ import_util.import_('', globals, {}, ['relimport'], 1)
+@import_util.importlib_only
class Setting__package__(unittest.TestCase):
"""Because __package__ is a new feature, it is not always set by a loader.
diff --git a/Lib/importlib/test/import_/test_api.py b/Lib/importlib/test/import_/test_api.py
new file mode 100644
index 0000000000..9075d42759
--- /dev/null
+++ b/Lib/importlib/test/import_/test_api.py
@@ -0,0 +1,22 @@
+from . import util
+import unittest
+
+
+class APITest(unittest.TestCase):
+
+ """Test API-specific details for __import__ (e.g. raising the right
+ exception when passing in an int for the module name)."""
+
+ def test_name_requires_rparition(self):
+ # Raise TypeError if a non-string is passed in for the module name.
+ with self.assertRaises(TypeError):
+ util.import_(42)
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(APITest)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/test_fromlist.py b/Lib/importlib/test/import_/test_fromlist.py
index ddd355ef30..b903e8e611 100644
--- a/Lib/importlib/test/import_/test_fromlist.py
+++ b/Lib/importlib/test/import_/test_fromlist.py
@@ -84,16 +84,23 @@ class HandlingFromlist(unittest.TestCase):
module = import_util.import_('pkg.mod', fromlist=[''])
self.assertEqual(module.__name__, 'pkg.mod')
- def test_using_star(self):
+ def basic_star_test(self, fromlist=['*']):
# [using *]
with util.mock_modules('pkg.__init__', 'pkg.module') as mock:
with util.import_state(meta_path=[mock]):
mock['pkg'].__all__ = ['module']
- module = import_util.import_('pkg', fromlist=['*'])
+ module = import_util.import_('pkg', fromlist=fromlist)
self.assertEqual(module.__name__, 'pkg')
self.assertTrue(hasattr(module, 'module'))
self.assertEqual(module.module.__name__, 'pkg.module')
+ def test_using_star(self):
+ # [using *]
+ self.basic_star_test()
+
+ def test_fromlist_as_tuple(self):
+ self.basic_star_test(('*',))
+
def test_star_with_others(self):
# [using * with others]
context = util.mock_modules('pkg.__init__', 'pkg.module1', 'pkg.module2')
diff --git a/Lib/importlib/test/import_/test_packages.py b/Lib/importlib/test/import_/test_packages.py
index b41c36f5b5..faadc32172 100644
--- a/Lib/importlib/test/import_/test_packages.py
+++ b/Lib/importlib/test/import_/test_packages.py
@@ -18,8 +18,14 @@ class ParentModuleTests(unittest.TestCase):
def test_bad_parent(self):
with util.mock_modules('pkg.module') as mock:
with util.import_state(meta_path=[mock]):
- self.assertRaises(ImportError,
- import_util.import_, 'pkg.module')
+ with self.assertRaises(ImportError):
+ import_util.import_('pkg.module')
+
+ def test_module_not_package(self):
+ # Try to import a submodule from a non-package should raise ImportError.
+ assert not hasattr(sys, '__path__')
+ with self.assertRaises(ImportError):
+ import_util.import_('sys.no_submodules_here')
def test_main():
diff --git a/Lib/importlib/test/import_/test_path.py b/Lib/importlib/test/import_/test_path.py
index 0e055b1352..2faa23174b 100644
--- a/Lib/importlib/test/import_/test_path.py
+++ b/Lib/importlib/test/import_/test_path.py
@@ -2,10 +2,10 @@ from importlib import _bootstrap
from importlib import machinery
from .. import util
from . import util as import_util
-from contextlib import nested
import imp
import os
import sys
+import tempfile
from test import support
from types import MethodType
import unittest
@@ -81,23 +81,28 @@ class DefaultPathFinderTests(unittest.TestCase):
def test_implicit_hooks(self):
# Test that the implicit path hooks are used.
- existing_path = os.path.dirname(support.TESTFN)
bad_path = '<path>'
module = '<module>'
assert not os.path.exists(bad_path)
- with util.import_state():
- nothing = _bootstrap._DefaultPathFinder.find_module(module,
- path=[existing_path])
- self.assertTrue(nothing is None)
- self.assertTrue(existing_path in sys.path_importer_cache)
- self.assertTrue(not isinstance(sys.path_importer_cache[existing_path],
- imp.NullImporter))
- nothing = _bootstrap._DefaultPathFinder.find_module(module,
- path=[bad_path])
- self.assertTrue(nothing is None)
- self.assertTrue(bad_path in sys.path_importer_cache)
- self.assertTrue(isinstance(sys.path_importer_cache[bad_path],
- imp.NullImporter))
+ existing_path = tempfile.mkdtemp()
+ try:
+ with util.import_state():
+ nothing = _bootstrap._DefaultPathFinder.find_module(module,
+ path=[existing_path])
+ self.assertTrue(nothing is None)
+ self.assertTrue(existing_path in sys.path_importer_cache)
+ result = isinstance(sys.path_importer_cache[existing_path],
+ imp.NullImporter)
+ self.assertFalse(result)
+ nothing = _bootstrap._DefaultPathFinder.find_module(module,
+ path=[bad_path])
+ self.assertTrue(nothing is None)
+ self.assertTrue(bad_path in sys.path_importer_cache)
+ self.assertTrue(isinstance(sys.path_importer_cache[bad_path],
+ imp.NullImporter))
+ finally:
+ os.rmdir(existing_path)
+
def test_path_importer_cache_has_None(self):
# Test that the default hook is used when sys.path_importer_cache
diff --git a/Lib/importlib/test/import_/test_relative_imports.py b/Lib/importlib/test/import_/test_relative_imports.py
index 5547d4c6ff..a0f6b2d827 100644
--- a/Lib/importlib/test/import_/test_relative_imports.py
+++ b/Lib/importlib/test/import_/test_relative_imports.py
@@ -154,8 +154,9 @@ class RelativeImports(unittest.TestCase):
{'__name__': 'pkg', '__path__': ['blah']})
def callback(global_):
import_util.import_('pkg')
- self.assertRaises(ValueError, import_util.import_, '', global_,
- fromlist=['top_level'], level=2)
+ with self.assertRaises(ValueError):
+ import_util.import_('', global_, fromlist=['top_level'],
+ level=2)
self.relative_import_test(create, globals_, callback)
def test_too_high_from_module(self):
@@ -164,13 +165,15 @@ class RelativeImports(unittest.TestCase):
globals_ = {'__package__': 'pkg'}, {'__name__': 'pkg.module'}
def callback(global_):
import_util.import_('pkg')
- self.assertRaises(ValueError, import_util.import_, '', global_,
- fromlist=['top_level'], level=2)
+ with self.assertRaises(ValueError):
+ import_util.import_('', global_, fromlist=['top_level'],
+ level=2)
self.relative_import_test(create, globals_, callback)
def test_empty_name_w_level_0(self):
# [empty name]
- self.assertRaises(ValueError, import_util.import_, '')
+ with self.assertRaises(ValueError):
+ import_util.import_('')
def test_import_from_different_package(self):
# Test importing from a different package than the caller.
diff --git a/Lib/importlib/test/import_/util.py b/Lib/importlib/test/import_/util.py
index 5a1b72788d..649c5ed27c 100644
--- a/Lib/importlib/test/import_/util.py
+++ b/Lib/importlib/test/import_/util.py
@@ -1,5 +1,7 @@
import functools
+import importlib
import importlib._bootstrap
+import unittest
using___import__ = False
@@ -10,19 +12,12 @@ def import_(*args, **kwargs):
if using___import__:
return __import__(*args, **kwargs)
else:
- return importlib._bootstrap.__import__(*args, **kwargs)
+ return importlib.__import__(*args, **kwargs)
def importlib_only(fxn):
- """Decorator to mark which tests are not supported by the current
- implementation of __import__()."""
- def inner(*args, **kwargs):
- if using___import__:
- return
- else:
- return fxn(*args, **kwargs)
- functools.update_wrapper(inner, fxn)
- return inner
+ """Decorator to skip a test if using __builtins__.__import__."""
+ return unittest.skipIf(using___import__, "importlib-specific test")(fxn)
def mock_path_hook(*entries, importer):
diff --git a/Lib/importlib/test/regrtest.py b/Lib/importlib/test/regrtest.py
new file mode 100644
index 0000000000..b103ae7d0e
--- /dev/null
+++ b/Lib/importlib/test/regrtest.py
@@ -0,0 +1,35 @@
+"""Run Python's standard test suite using importlib.__import__.
+
+Tests known to fail because of assumptions that importlib (properly)
+invalidates are automatically skipped if the entire test suite is run.
+Otherwise all command-line options valid for test.regrtest are also valid for
+this script.
+
+XXX FAILING
+ * test_import
+ - test_incorrect_code_name
+ file name differing between __file__ and co_filename (r68360 on trunk)
+ - test_import_by_filename
+ exception for trying to import by file name does not match
+
+"""
+import importlib
+import sys
+from test import regrtest
+
+if __name__ == '__main__':
+ __builtins__.__import__ = importlib.__import__
+
+ exclude = ['--exclude',
+ 'test_frozen', # Does not expect __loader__ attribute
+ 'test_pkg', # Does not expect __loader__ attribute
+ 'test_pydoc', # Does not expect __loader__ attribute
+ ]
+
+ # Switching on --exclude implies running all test but the ones listed, so
+ # only use it when one is not running an explicit test
+ if len(sys.argv) == 1:
+ # No programmatic way to specify tests to exclude
+ sys.argv.extend(exclude)
+
+ regrtest.main(quiet=True, verbose2=True)
diff --git a/Lib/importlib/test/source/test_abc_loader.py b/Lib/importlib/test/source/test_abc_loader.py
index 1ce83fb8c3..32459074a0 100644
--- a/Lib/importlib/test/source/test_abc_loader.py
+++ b/Lib/importlib/test/source/test_abc_loader.py
@@ -1,14 +1,68 @@
import importlib
from importlib import abc
+
from .. import abc as testing_abc
from .. import util
from . import util as source_util
+
import imp
+import inspect
+import io
import marshal
import os
import sys
import types
import unittest
+import warnings
+
+
+class SourceOnlyLoaderMock(abc.SourceLoader):
+
+ # Globals that should be defined for all modules.
+ source = (b"_ = '::'.join([__name__, __file__, __cached__, __package__, "
+ b"repr(__loader__)])")
+
+ def __init__(self, path):
+ self.path = path
+
+ def get_data(self, path):
+ assert self.path == path
+ return self.source
+
+ def get_filename(self, fullname):
+ return self.path
+
+
+class SourceLoaderMock(SourceOnlyLoaderMock):
+
+ source_mtime = 1
+
+ def __init__(self, path, magic=imp.get_magic()):
+ super().__init__(path)
+ self.bytecode_path = imp.cache_from_source(self.path)
+ data = bytearray(magic)
+ data.extend(marshal._w_long(self.source_mtime))
+ code_object = compile(self.source, self.path, 'exec',
+ dont_inherit=True)
+ data.extend(marshal.dumps(code_object))
+ self.bytecode = bytes(data)
+ self.written = {}
+
+ def get_data(self, path):
+ if path == self.path:
+ return super().get_data(path)
+ elif path == self.bytecode_path:
+ return self.bytecode
+ else:
+ raise IOError
+
+ def path_mtime(self, path):
+ assert path == self.path
+ return self.source_mtime
+
+ def set_data(self, path, data):
+ self.written[path] = bytes(data)
+ return path == self.bytecode_path
class PyLoaderMock(abc.PyLoader):
@@ -33,17 +87,42 @@ class PyLoaderMock(abc.PyLoader):
return self.source
def is_package(self, name):
+ filename = os.path.basename(self.get_filename(name))
+ return os.path.splitext(filename)[0] == '__init__'
+
+ def source_path(self, name):
try:
- return '__init__' in self.module_paths[name]
+ return self.module_paths[name]
except KeyError:
raise ImportError
- def source_path(self, name):
+ def get_filename(self, name):
+ """Silence deprecation warning."""
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ path = super().get_filename(name)
+ assert len(w) == 1
+ assert issubclass(w[0].category, PendingDeprecationWarning)
+ return path
+
+
+class PyLoaderCompatMock(PyLoaderMock):
+
+ """Mock that matches what is suggested to have a loader that is compatible
+ from Python 3.1 onwards."""
+
+ def get_filename(self, fullname):
try:
- return self.module_paths[name]
+ return self.module_paths[fullname]
except KeyError:
raise ImportError
+ def source_path(self, fullname):
+ try:
+ return self.get_filename(fullname)
+ except ImportError:
+ return None
+
class PyPycLoaderMock(abc.PyPycLoader, PyLoaderMock):
@@ -114,6 +193,13 @@ class PyPycLoaderMock(abc.PyPycLoader, PyLoaderMock):
except TypeError:
return '__init__' in self.bytecode_to_path[name]
+ def get_code(self, name):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ code_object = super().get_code(name)
+ assert len(w) == 1
+ assert issubclass(w[0].category, PendingDeprecationWarning)
+ return code_object
class PyLoaderTests(testing_abc.LoaderTests):
@@ -183,7 +269,8 @@ class PyLoaderTests(testing_abc.LoaderTests):
mock.source = b"1/0"
with util.uncache(name):
sys.modules[name] = module
- self.assertRaises(ZeroDivisionError, mock.load_module, name)
+ with self.assertRaises(ZeroDivisionError):
+ mock.load_module(name)
self.assertTrue(sys.modules[name] is module)
self.assertTrue(hasattr(module, 'blah'))
return mock
@@ -193,11 +280,20 @@ class PyLoaderTests(testing_abc.LoaderTests):
mock = self.mocker({name: os.path.join('path', 'to', 'mod')})
mock.source = b"1/0"
with util.uncache(name):
- self.assertRaises(ZeroDivisionError, mock.load_module, name)
+ with self.assertRaises(ZeroDivisionError):
+ mock.load_module(name)
self.assertTrue(name not in sys.modules)
return mock
+class PyLoaderCompatTests(PyLoaderTests):
+
+ """Test that the suggested code to make a loader that is compatible from
+ Python 3.1 forward works."""
+
+ mocker = PyLoaderCompatMock
+
+
class PyLoaderInterfaceTests(unittest.TestCase):
"""Tests for importlib.abc.PyLoader to make sure that when source_path()
@@ -207,38 +303,29 @@ class PyLoaderInterfaceTests(unittest.TestCase):
# No source path should lead to ImportError.
name = 'mod'
mock = PyLoaderMock({})
- with util.uncache(name):
- self.assertRaises(ImportError, mock.load_module, name)
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
def test_source_path_is_None(self):
name = 'mod'
mock = PyLoaderMock({name: None})
- with util.uncache(name):
- self.assertRaises(ImportError, mock.load_module, name)
-
-
-class PyLoaderGetSourceTests(unittest.TestCase):
-
- """Tests for importlib.abc.PyLoader.get_source()."""
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
- def test_default_encoding(self):
- # Should have no problems with UTF-8 text.
+ def test_get_filename_with_source_path(self):
+ # get_filename() should return what source_path() returns.
name = 'mod'
- mock = PyLoaderMock({name: os.path.join('path', 'to', 'mod')})
- source = 'x = "ü"'
- mock.source = source.encode('utf-8')
- returned_source = mock.get_source(name)
- self.assertEqual(returned_source, source)
+ path = os.path.join('path', 'to', 'source')
+ mock = PyLoaderMock({name: path})
+ with util.uncache(name):
+ self.assertEqual(mock.get_filename(name), path)
- def test_decoded_source(self):
- # Decoding should work.
+ def test_get_filename_no_source_path(self):
+ # get_filename() should raise ImportError if source_path returns None.
name = 'mod'
- mock = PyLoaderMock({name: os.path.join('path', 'to', 'mod')})
- source = "# coding: Latin-1\nx='ü'"
- assert source.encode('latin-1') != source.encode('utf-8')
- mock.source = source.encode('latin-1')
- returned_source = mock.get_source(name)
- self.assertEqual(returned_source, source)
+ mock = PyLoaderMock({name: None})
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.get_filename(name)
class PyPycLoaderTests(PyLoaderTests):
@@ -281,6 +368,38 @@ class PyPycLoaderTests(PyLoaderTests):
super().test_unloadable()
+class PyPycLoaderInterfaceTests(unittest.TestCase):
+
+ """Test for the interface of importlib.abc.PyPycLoader."""
+
+ def get_filename_check(self, src_path, bc_path, expect):
+ name = 'mod'
+ mock = PyPycLoaderMock({name: src_path}, {name: {'path': bc_path}})
+ with util.uncache(name):
+ assert mock.source_path(name) == src_path
+ assert mock.bytecode_path(name) == bc_path
+ self.assertEqual(mock.get_filename(name), expect)
+
+ def test_filename_with_source_bc(self):
+ # When source and bytecode paths present, return the source path.
+ self.get_filename_check('source_path', 'bc_path', 'source_path')
+
+ def test_filename_with_source_no_bc(self):
+ # With source but no bc, return source path.
+ self.get_filename_check('source_path', None, 'source_path')
+
+ def test_filename_with_no_source_bc(self):
+ # With not source but bc, return the bc path.
+ self.get_filename_check(None, 'bc_path', 'bc_path')
+
+ def test_filename_with_no_source_or_bc(self):
+ # With no source or bc, raise ImportError.
+ name = 'mod'
+ mock = PyPycLoaderMock({name: None}, {name: {'path': None}})
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.get_filename(name)
+
+
class SkipWritingBytecodeTests(unittest.TestCase):
"""Test that bytecode is properly handled based on
@@ -346,20 +465,28 @@ class BadBytecodeFailureTests(unittest.TestCase):
# A bad magic number should lead to an ImportError.
name = 'mod'
bad_magic = b'\x00\x00\x00\x00'
- mock = PyPycLoaderMock({name: None},
- {name: {'path': os.path.join('path', 'to', 'mod'),
- 'magic': bad_magic}})
- with util.uncache(name):
- self.assertRaises(ImportError, mock.load_module, name)
+ bc = {name:
+ {'path': os.path.join('path', 'to', 'mod'),
+ 'magic': bad_magic}}
+ mock = PyPycLoaderMock({name: None}, bc)
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
+
+ def test_no_bytecode(self):
+ # Missing code object bytecode should lead to an EOFError.
+ name = 'mod'
+ bc = {name: {'path': os.path.join('path', 'to', 'mod'), 'bc': b''}}
+ mock = PyPycLoaderMock({name: None}, bc)
+ with util.uncache(name), self.assertRaises(EOFError):
+ mock.load_module(name)
def test_bad_bytecode(self):
- # Bad code object bytecode should lead to an ImportError.
+ # Malformed code object bytecode should lead to a ValueError.
name = 'mod'
- mock = PyPycLoaderMock({name: None},
- {name: {'path': os.path.join('path', 'to', 'mod'),
- 'bc': b''}})
- with util.uncache(name):
- self.assertRaises(EOFError, mock.load_module, name)
+ bc = {name: {'path': os.path.join('path', 'to', 'mod'), 'bc': b'1234'}}
+ mock = PyPycLoaderMock({name: None}, bc)
+ with util.uncache(name), self.assertRaises(ValueError):
+ mock.load_module(name)
def raise_ImportError(*args, **kwargs):
@@ -387,16 +514,16 @@ class MissingPathsTests(unittest.TestCase):
# If all *_path methods return None, raise ImportError.
name = 'mod'
mock = PyPycLoaderMock({name: None})
- with util.uncache(name):
- self.assertRaises(ImportError, mock.load_module, name)
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
def test_source_path_ImportError(self):
# An ImportError from source_path should trigger an ImportError.
name = 'mod'
mock = PyPycLoaderMock({}, {name: {'path': os.path.join('path', 'to',
'mod')}})
- with util.uncache(name):
- self.assertRaises(ImportError, mock.load_module, name)
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
def test_bytecode_path_ImportError(self):
# An ImportError from bytecode_path should trigger an ImportError.
@@ -404,16 +531,345 @@ class MissingPathsTests(unittest.TestCase):
mock = PyPycLoaderMock({name: os.path.join('path', 'to', 'mod')})
bad_meth = types.MethodType(raise_ImportError, mock)
mock.bytecode_path = bad_meth
- with util.uncache(name):
- self.assertRaises(ImportError, mock.load_module, name)
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
+
+
+class SourceLoaderTestHarness(unittest.TestCase):
+
+ def setUp(self, *, is_package=True, **kwargs):
+ self.package = 'pkg'
+ if is_package:
+ self.path = os.path.join(self.package, '__init__.py')
+ self.name = self.package
+ else:
+ module_name = 'mod'
+ self.path = os.path.join(self.package, '.'.join(['mod', 'py']))
+ self.name = '.'.join([self.package, module_name])
+ self.cached = imp.cache_from_source(self.path)
+ self.loader = self.loader_mock(self.path, **kwargs)
+
+ def verify_module(self, module):
+ self.assertEqual(module.__name__, self.name)
+ self.assertEqual(module.__file__, self.path)
+ self.assertEqual(module.__cached__, self.cached)
+ self.assertEqual(module.__package__, self.package)
+ self.assertEqual(module.__loader__, self.loader)
+ values = module._.split('::')
+ self.assertEqual(values[0], self.name)
+ self.assertEqual(values[1], self.path)
+ self.assertEqual(values[2], self.cached)
+ self.assertEqual(values[3], self.package)
+ self.assertEqual(values[4], repr(self.loader))
+
+ def verify_code(self, code_object):
+ module = imp.new_module(self.name)
+ module.__file__ = self.path
+ module.__cached__ = self.cached
+ module.__package__ = self.package
+ module.__loader__ = self.loader
+ module.__path__ = []
+ exec(code_object, module.__dict__)
+ self.verify_module(module)
+
+
+class SourceOnlyLoaderTests(SourceLoaderTestHarness):
+
+ """Test importlib.abc.SourceLoader for source-only loading.
+
+ Reload testing is subsumed by the tests for
+ importlib.util.module_for_loader.
+
+ """
+
+ loader_mock = SourceOnlyLoaderMock
+
+ def test_get_source(self):
+ # Verify the source code is returned as a string.
+ # If an IOError is raised by get_data then raise ImportError.
+ expected_source = self.loader.source.decode('utf-8')
+ self.assertEqual(self.loader.get_source(self.name), expected_source)
+ def raise_IOError(path):
+ raise IOError
+ self.loader.get_data = raise_IOError
+ with self.assertRaises(ImportError):
+ self.loader.get_source(self.name)
+
+ def test_is_package(self):
+ # Properly detect when loading a package.
+ self.setUp(is_package=True)
+ self.assertTrue(self.loader.is_package(self.name))
+ self.setUp(is_package=False)
+ self.assertFalse(self.loader.is_package(self.name))
+
+ def test_get_code(self):
+ # Verify the code object is created.
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object)
+
+ def test_load_module(self):
+ # Loading a module should set __name__, __loader__, __package__,
+ # __path__ (for packages), __file__, and __cached__.
+ # The module should also be put into sys.modules.
+ with util.uncache(self.name):
+ module = self.loader.load_module(self.name)
+ self.verify_module(module)
+ self.assertEqual(module.__path__, [os.path.dirname(self.path)])
+ self.assertTrue(self.name in sys.modules)
+
+ def test_package_settings(self):
+ # __package__ needs to be set, while __path__ is set on if the module
+ # is a package.
+ # Testing the values for a package are covered by test_load_module.
+ self.setUp(is_package=False)
+ with util.uncache(self.name):
+ module = self.loader.load_module(self.name)
+ self.verify_module(module)
+ self.assertTrue(not hasattr(module, '__path__'))
+
+ def test_get_source_encoding(self):
+ # Source is considered encoded in UTF-8 by default unless otherwise
+ # specified by an encoding line.
+ source = "_ = 'ü'"
+ self.loader.source = source.encode('utf-8')
+ returned_source = self.loader.get_source(self.name)
+ self.assertEqual(returned_source, source)
+ source = "# coding: latin-1\n_ = ü"
+ self.loader.source = source.encode('latin-1')
+ returned_source = self.loader.get_source(self.name)
+ self.assertEqual(returned_source, source)
+
+
+@unittest.skipIf(sys.dont_write_bytecode, "sys.dont_write_bytecode is true")
+class SourceLoaderBytecodeTests(SourceLoaderTestHarness):
+
+ """Test importlib.abc.SourceLoader's use of bytecode.
+
+ Source-only testing handled by SourceOnlyLoaderTests.
+
+ """
+
+ loader_mock = SourceLoaderMock
+
+ def verify_code(self, code_object, *, bytecode_written=False):
+ super().verify_code(code_object)
+ if bytecode_written:
+ self.assertIn(self.cached, self.loader.written)
+ data = bytearray(imp.get_magic())
+ data.extend(marshal._w_long(self.loader.source_mtime))
+ data.extend(marshal.dumps(code_object))
+ self.assertEqual(self.loader.written[self.cached], bytes(data))
+
+ def test_code_with_everything(self):
+ # When everything should work.
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object)
+
+ def test_no_bytecode(self):
+ # If no bytecode exists then move on to the source.
+ self.loader.bytecode_path = "<does not exist>"
+ # Sanity check
+ with self.assertRaises(IOError):
+ bytecode_path = imp.cache_from_source(self.path)
+ self.loader.get_data(bytecode_path)
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object, bytecode_written=True)
+
+ def test_code_bad_timestamp(self):
+ # Bytecode is only used when the timestamp matches the source EXACTLY.
+ for source_mtime in (0, 2):
+ assert source_mtime != self.loader.source_mtime
+ original = self.loader.source_mtime
+ self.loader.source_mtime = source_mtime
+ # If bytecode is used then EOFError would be raised by marshal.
+ self.loader.bytecode = self.loader.bytecode[8:]
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object, bytecode_written=True)
+ self.loader.source_mtime = original
+
+ def test_code_bad_magic(self):
+ # Skip over bytecode with a bad magic number.
+ self.setUp(magic=b'0000')
+ # If bytecode is used then EOFError would be raised by marshal.
+ self.loader.bytecode = self.loader.bytecode[8:]
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object, bytecode_written=True)
+
+ def test_dont_write_bytecode(self):
+ # Bytecode is not written if sys.dont_write_bytecode is true.
+ # Can assume it is false already thanks to the skipIf class decorator.
+ try:
+ sys.dont_write_bytecode = True
+ self.loader.bytecode_path = "<does not exist>"
+ code_object = self.loader.get_code(self.name)
+ self.assertNotIn(self.cached, self.loader.written)
+ finally:
+ sys.dont_write_bytecode = False
+
+ def test_no_set_data(self):
+ # If set_data is not defined, one can still read bytecode.
+ self.setUp(magic=b'0000')
+ original_set_data = self.loader.__class__.set_data
+ try:
+ del self.loader.__class__.set_data
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object)
+ finally:
+ self.loader.__class__.set_data = original_set_data
+
+ def test_set_data_raises_exceptions(self):
+ # Raising NotImplementedError or IOError is okay for set_data.
+ def raise_exception(exc):
+ def closure(*args, **kwargs):
+ raise exc
+ return closure
+
+ self.setUp(magic=b'0000')
+ self.loader.set_data = raise_exception(NotImplementedError)
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object)
+
+
+class SourceLoaderGetSourceTests(unittest.TestCase):
+
+ """Tests for importlib.abc.SourceLoader.get_source()."""
+
+ def test_default_encoding(self):
+ # Should have no problems with UTF-8 text.
+ name = 'mod'
+ mock = SourceOnlyLoaderMock('mod.file')
+ source = 'x = "ü"'
+ mock.source = source.encode('utf-8')
+ returned_source = mock.get_source(name)
+ self.assertEqual(returned_source, source)
+
+ def test_decoded_source(self):
+ # Decoding should work.
+ name = 'mod'
+ mock = SourceOnlyLoaderMock("mod.file")
+ source = "# coding: Latin-1\nx='ü'"
+ assert source.encode('latin-1') != source.encode('utf-8')
+ mock.source = source.encode('latin-1')
+ returned_source = mock.get_source(name)
+ self.assertEqual(returned_source, source)
+
+ def test_universal_newlines(self):
+ # PEP 302 says universal newlines should be used.
+ name = 'mod'
+ mock = SourceOnlyLoaderMock('mod.file')
+ source = "x = 42\r\ny = -13\r\n"
+ mock.source = source.encode('utf-8')
+ expect = io.IncrementalNewlineDecoder(None, True).decode(source)
+ self.assertEqual(mock.get_source(name), expect)
+
+class AbstractMethodImplTests(unittest.TestCase):
+
+ """Test the concrete abstractmethod implementations."""
+
+ class Loader(abc.Loader):
+ def load_module(self, fullname):
+ super().load_module(fullname)
+
+ class Finder(abc.Finder):
+ def find_module(self, _):
+ super().find_module(_)
+
+ class ResourceLoader(Loader, abc.ResourceLoader):
+ def get_data(self, _):
+ super().get_data(_)
+
+ class InspectLoader(Loader, abc.InspectLoader):
+ def is_package(self, _):
+ super().is_package(_)
+
+ def get_code(self, _):
+ super().get_code(_)
+
+ def get_source(self, _):
+ super().get_source(_)
+
+ class ExecutionLoader(InspectLoader, abc.ExecutionLoader):
+ def get_filename(self, _):
+ super().get_filename(_)
+
+ class SourceLoader(ResourceLoader, ExecutionLoader, abc.SourceLoader):
+ pass
+
+ class PyLoader(ResourceLoader, InspectLoader, abc.PyLoader):
+ def source_path(self, _):
+ super().source_path(_)
+
+ class PyPycLoader(PyLoader, abc.PyPycLoader):
+ def bytecode_path(self, _):
+ super().bytecode_path(_)
+
+ def source_mtime(self, _):
+ super().source_mtime(_)
+
+ def write_bytecode(self, _, _2):
+ super().write_bytecode(_, _2)
+
+ def raises_NotImplementedError(self, ins, *args):
+ for method_name in args:
+ method = getattr(ins, method_name)
+ arg_count = len(inspect.getfullargspec(method)[0]) - 1
+ args = [''] * arg_count
+ try:
+ method(*args)
+ except NotImplementedError:
+ pass
+ else:
+ msg = "{}.{} did not raise NotImplementedError"
+ self.fail(msg.format(ins.__class__.__name__, method_name))
+
+ def test_Loader(self):
+ self.raises_NotImplementedError(self.Loader(), 'load_module')
+
+ # XXX misplaced; should be somewhere else
+ def test_Finder(self):
+ self.raises_NotImplementedError(self.Finder(), 'find_module')
+
+ def test_ResourceLoader(self):
+ self.raises_NotImplementedError(self.ResourceLoader(), 'load_module',
+ 'get_data')
+
+ def test_InspectLoader(self):
+ self.raises_NotImplementedError(self.InspectLoader(), 'load_module',
+ 'is_package', 'get_code', 'get_source')
+
+ def test_ExecutionLoader(self):
+ self.raises_NotImplementedError(self.ExecutionLoader(), 'load_module',
+ 'is_package', 'get_code', 'get_source',
+ 'get_filename')
+
+ def test_SourceLoader(self):
+ ins = self.SourceLoader()
+ # Required abstractmethods.
+ self.raises_NotImplementedError(ins, 'get_filename', 'get_data')
+ # Optional abstractmethods.
+ self.raises_NotImplementedError(ins,'path_mtime', 'set_data')
+
+ def test_PyLoader(self):
+ self.raises_NotImplementedError(self.PyLoader(), 'source_path',
+ 'get_data', 'is_package')
+
+ def test_PyPycLoader(self):
+ self.raises_NotImplementedError(self.PyPycLoader(), 'source_path',
+ 'source_mtime', 'bytecode_path',
+ 'write_bytecode')
def test_main():
from test.support import run_unittest
- run_unittest(PyLoaderTests, PyLoaderInterfaceTests, PyLoaderGetSourceTests,
- PyPycLoaderTests, SkipWritingBytecodeTests,
- RegeneratedBytecodeTests, BadBytecodeFailureTests,
- MissingPathsTests)
+ run_unittest(PyLoaderTests, PyLoaderCompatTests,
+ PyLoaderInterfaceTests,
+ PyPycLoaderTests, PyPycLoaderInterfaceTests,
+ SkipWritingBytecodeTests, RegeneratedBytecodeTests,
+ BadBytecodeFailureTests, MissingPathsTests,
+ SourceOnlyLoaderTests,
+ SourceLoaderBytecodeTests,
+ SourceLoaderGetSourceTests,
+ AbstractMethodImplTests)
if __name__ == '__main__':
diff --git a/Lib/importlib/test/source/test_case_sensitivity.py b/Lib/importlib/test/source/test_case_sensitivity.py
index 6fad881846..73777de4ba 100644
--- a/Lib/importlib/test/source/test_case_sensitivity.py
+++ b/Lib/importlib/test/source/test_case_sensitivity.py
@@ -19,7 +19,9 @@ class CaseSensitivityTest(unittest.TestCase):
assert name != name.lower()
def find(self, path):
- finder = _bootstrap._PyPycFileFinder(path)
+ finder = _bootstrap._FileFinder(path,
+ _bootstrap._SourceFinderDetails(),
+ _bootstrap._SourcelessFinderDetails())
return finder.find_module(self.name)
def sensitivity_test(self):
@@ -27,7 +29,7 @@ class CaseSensitivityTest(unittest.TestCase):
sensitive_pkg = 'sensitive.{0}'.format(self.name)
insensitive_pkg = 'insensitive.{0}'.format(self.name.lower())
context = source_util.create_modules(insensitive_pkg, sensitive_pkg)
- with context as mapping:
+ with context as mapping:
sensitive_path = os.path.join(mapping['.root'], 'sensitive')
insensitive_path = os.path.join(mapping['.root'], 'insensitive')
return self.find(sensitive_path), self.find(insensitive_path)
@@ -37,7 +39,7 @@ class CaseSensitivityTest(unittest.TestCase):
env.unset('PYTHONCASEOK')
sensitive, insensitive = self.sensitivity_test()
self.assertTrue(hasattr(sensitive, 'load_module'))
- self.assertIn(self.name, sensitive._base_path)
+ self.assertIn(self.name, sensitive.get_filename(self.name))
self.assertIsNone(insensitive)
def test_insensitive(self):
@@ -45,9 +47,9 @@ class CaseSensitivityTest(unittest.TestCase):
env.set('PYTHONCASEOK', '1')
sensitive, insensitive = self.sensitivity_test()
self.assertTrue(hasattr(sensitive, 'load_module'))
- self.assertIn(self.name, sensitive._base_path)
+ self.assertIn(self.name, sensitive.get_filename(self.name))
self.assertTrue(hasattr(insensitive, 'load_module'))
- self.assertIn(self.name, insensitive._base_path)
+ self.assertIn(self.name, insensitive.get_filename(self.name))
def test_main():
diff --git a/Lib/importlib/test/source/test_file_loader.py b/Lib/importlib/test/source/test_file_loader.py
index 145d07607b..0ffe78dfa1 100644
--- a/Lib/importlib/test/source/test_file_loader.py
+++ b/Lib/importlib/test/source/test_file_loader.py
@@ -1,15 +1,20 @@
import importlib
from importlib import _bootstrap
from .. import abc
+from .. import util
from . import util as source_util
import imp
+import marshal
import os
import py_compile
+import shutil
import stat
import sys
import unittest
+from test.support import make_legacy_pyc
+
class SimpleTest(unittest.TestCase):
@@ -21,8 +26,7 @@ class SimpleTest(unittest.TestCase):
# [basic]
def test_module(self):
with source_util.create_modules('_temp') as mapping:
- loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'],
- False)
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
module = loader.load_module('_temp')
self.assertTrue('_temp' in sys.modules)
check = {'__name__': '_temp', '__file__': mapping['_temp'],
@@ -32,9 +36,8 @@ class SimpleTest(unittest.TestCase):
def test_package(self):
with source_util.create_modules('_pkg.__init__') as mapping:
- loader = _bootstrap._PyPycFileLoader('_pkg',
- mapping['_pkg.__init__'],
- True)
+ loader = _bootstrap._SourceFileLoader('_pkg',
+ mapping['_pkg.__init__'])
module = loader.load_module('_pkg')
self.assertTrue('_pkg' in sys.modules)
check = {'__name__': '_pkg', '__file__': mapping['_pkg.__init__'],
@@ -46,8 +49,8 @@ class SimpleTest(unittest.TestCase):
def test_lacking_parent(self):
with source_util.create_modules('_pkg.__init__', '_pkg.mod')as mapping:
- loader = _bootstrap._PyPycFileLoader('_pkg.mod',
- mapping['_pkg.mod'], False)
+ loader = _bootstrap._SourceFileLoader('_pkg.mod',
+ mapping['_pkg.mod'])
module = loader.load_module('_pkg.mod')
self.assertTrue('_pkg.mod' in sys.modules)
check = {'__name__': '_pkg.mod', '__file__': mapping['_pkg.mod'],
@@ -61,8 +64,7 @@ class SimpleTest(unittest.TestCase):
def test_module_reuse(self):
with source_util.create_modules('_temp') as mapping:
- loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'],
- False)
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
module = loader.load_module('_temp')
module_id = id(module)
module_dict_id = id(module.__dict__)
@@ -72,7 +74,7 @@ class SimpleTest(unittest.TestCase):
# everything that has happened above can be too fast;
# force an mtime on the source that is guaranteed to be different
# than the original mtime.
- loader.source_mtime = self.fake_mtime(loader.source_mtime)
+ loader.path_mtime = self.fake_mtime(loader.path_mtime)
module = loader.load_module('_temp')
self.assertTrue('testing_var' in module.__dict__,
"'testing_var' not in "
@@ -92,9 +94,9 @@ class SimpleTest(unittest.TestCase):
setattr(orig_module, attr, value)
with open(mapping[name], 'w') as file:
file.write('+++ bad syntax +++')
- loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'],
- False)
- self.assertRaises(SyntaxError, loader.load_module, name)
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
+ with self.assertRaises(SyntaxError):
+ loader.load_module(name)
for attr in attributes:
self.assertEqual(getattr(orig_module, attr), value)
@@ -103,16 +105,34 @@ class SimpleTest(unittest.TestCase):
with source_util.create_modules('_temp') as mapping:
with open(mapping['_temp'], 'w') as file:
file.write('=')
- loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'],
- False)
- self.assertRaises(SyntaxError, loader.load_module, '_temp')
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
+ with self.assertRaises(SyntaxError):
+ loader.load_module('_temp')
self.assertTrue('_temp' not in sys.modules)
+ def test_file_from_empty_string_dir(self):
+ # Loading a module found from an empty string entry on sys.path should
+ # not only work, but keep all attributes relative.
+ file_path = '_temp.py'
+ with open(file_path, 'w') as file:
+ file.write("# test file for importlib")
+ try:
+ with util.uncache('_temp'):
+ loader = _bootstrap._SourceFileLoader('_temp', file_path)
+ mod = loader.load_module('_temp')
+ self.assertEqual(file_path, mod.__file__)
+ self.assertEqual(imp.cache_from_source(file_path),
+ mod.__cached__)
+ finally:
+ os.unlink(file_path)
+ pycache = os.path.dirname(imp.cache_from_source(file_path))
+ shutil.rmtree(pycache)
+
class BadBytecodeTest(unittest.TestCase):
def import_(self, file, module_name):
- loader = _bootstrap._PyPycFileLoader(module_name, file, False)
+ loader = self.loader(module_name, file)
module = loader.load_module(module_name)
self.assertTrue(module_name in sys.modules)
@@ -125,106 +145,162 @@ class BadBytecodeTest(unittest.TestCase):
except KeyError:
pass
py_compile.compile(mapping[name])
- bytecode_path = source_util.bytecode_path(mapping[name])
- with open(bytecode_path, 'rb') as file:
- bc = file.read()
- new_bc = manipulator(bc)
- with open(bytecode_path, 'wb') as file:
- if new_bc:
- file.write(new_bc)
- if del_source:
+ if not del_source:
+ bytecode_path = imp.cache_from_source(mapping[name])
+ else:
os.unlink(mapping[name])
+ bytecode_path = make_legacy_pyc(mapping[name])
+ if manipulator:
+ with open(bytecode_path, 'rb') as file:
+ bc = file.read()
+ new_bc = manipulator(bc)
+ with open(bytecode_path, 'wb') as file:
+ if new_bc is not None:
+ file.write(new_bc)
return bytecode_path
- @source_util.writes_bytecode_files
- def test_empty_file(self):
- # When a .pyc is empty, regenerate it if possible, else raise
- # ImportError.
+ def _test_empty_file(self, test, *, del_source=False):
with source_util.create_modules('_temp') as mapping:
bc_path = self.manipulate_bytecode('_temp', mapping,
- lambda bc: None)
- self.import_(mapping['_temp'], '_temp')
- with open(bc_path, 'rb') as file:
- self.assertGreater(len(file.read()), 8)
- self.manipulate_bytecode('_temp', mapping, lambda bc: None,
- del_source=True)
- with self.assertRaises(ImportError):
- self.import_(mapping['_temp'], '_temp')
+ lambda bc: b'',
+ del_source=del_source)
+ test('_temp', mapping, bc_path)
@source_util.writes_bytecode_files
- def test_partial_magic(self):
+ def _test_partial_magic(self, test, *, del_source=False):
# When their are less than 4 bytes to a .pyc, regenerate it if
# possible, else raise ImportError.
with source_util.create_modules('_temp') as mapping:
bc_path = self.manipulate_bytecode('_temp', mapping,
- lambda bc: bc[:3])
- self.import_(mapping['_temp'], '_temp')
- with open(bc_path, 'rb') as file:
- self.assertGreater(len(file.read()), 8)
- self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:3],
- del_source=True)
+ lambda bc: bc[:3],
+ del_source=del_source)
+ test('_temp', mapping, bc_path)
+
+ def _test_magic_only(self, test, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:4],
+ del_source=del_source)
+ test('_temp', mapping, bc_path)
+
+ def _test_partial_timestamp(self, test, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:7],
+ del_source=del_source)
+ test('_temp', mapping, bc_path)
+
+ def _test_no_marshal(self, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:8],
+ del_source=del_source)
+ file_path = mapping['_temp'] if not del_source else bc_path
+ with self.assertRaises(EOFError):
+ self.import_(file_path, '_temp')
+
+ def _test_non_code_marshal(self, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bytecode_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:8] + marshal.dumps(b'abcd'),
+ del_source=del_source)
+ file_path = mapping['_temp'] if not del_source else bytecode_path
with self.assertRaises(ImportError):
- self.import_(mapping['_temp'], '_temp')
+ self.import_(file_path, '_temp')
+
+ def _test_bad_marshal(self, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bytecode_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:8] + b'<test>',
+ del_source=del_source)
+ file_path = mapping['_temp'] if not del_source else bytecode_path
+ with self.assertRaises(ValueError):
+ self.import_(file_path, '_temp')
+
+ def _test_bad_magic(self, test, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: b'\x00\x00\x00\x00' + bc[4:])
+ test('_temp', mapping, bc_path)
+
+
+class SourceLoaderBadBytecodeTest(BadBytecodeTest):
+
+ loader = _bootstrap._SourceFileLoader
+
+ @source_util.writes_bytecode_files
+ def test_empty_file(self):
+ # When a .pyc is empty, regenerate it if possible, else raise
+ # ImportError.
+ def test(name, mapping, bytecode_path):
+ self.import_(mapping[name], name)
+ with open(bytecode_path, 'rb') as file:
+ self.assertGreater(len(file.read()), 8)
+
+ self._test_empty_file(test)
+
+ def test_partial_magic(self):
+ def test(name, mapping, bytecode_path):
+ self.import_(mapping[name], name)
+ with open(bytecode_path, 'rb') as file:
+ self.assertGreater(len(file.read()), 8)
+
+ self._test_partial_magic(test)
@source_util.writes_bytecode_files
def test_magic_only(self):
# When there is only the magic number, regenerate the .pyc if possible,
# else raise EOFError.
- with source_util.create_modules('_temp') as mapping:
- bc_path = self.manipulate_bytecode('_temp', mapping,
- lambda bc: bc[:4])
- self.import_(mapping['_temp'], '_temp')
- with open(bc_path, 'rb') as file:
+ def test(name, mapping, bytecode_path):
+ self.import_(mapping[name], name)
+ with open(bytecode_path, 'rb') as file:
self.assertGreater(len(file.read()), 8)
- self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:4],
- del_source=True)
- with self.assertRaises(EOFError):
- self.import_(mapping['_temp'], '_temp')
+
+ @source_util.writes_bytecode_files
+ def test_bad_magic(self):
+ # When the magic number is different, the bytecode should be
+ # regenerated.
+ def test(name, mapping, bytecode_path):
+ self.import_(mapping[name], name)
+ with open(bytecode_path, 'rb') as bytecode_file:
+ self.assertEqual(bytecode_file.read(4), imp.get_magic())
+
+ self._test_bad_magic(test)
@source_util.writes_bytecode_files
def test_partial_timestamp(self):
# When the timestamp is partial, regenerate the .pyc, else
# raise EOFError.
- with source_util.create_modules('_temp') as mapping:
- bc_path = self.manipulate_bytecode('_temp', mapping,
- lambda bc: bc[:7])
- self.import_(mapping['_temp'], '_temp')
+ def test(name, mapping, bc_path):
+ self.import_(mapping[name], name)
with open(bc_path, 'rb') as file:
self.assertGreater(len(file.read()), 8)
- self.manipulate_bytecode('_temp', mapping, lambda bc: bc[:7],
- del_source=True)
- with self.assertRaises(EOFError):
- self.import_(mapping['_temp'], '_temp')
@source_util.writes_bytecode_files
def test_no_marshal(self):
# When there is only the magic number and timestamp, raise EOFError.
- with source_util.create_modules('_temp') as mapping:
- bc_path = self.manipulate_bytecode('_temp', mapping,
- lambda bc: bc[:8])
- with self.assertRaises(EOFError):
- self.import_(mapping['_temp'], '_temp')
+ self._test_no_marshal()
@source_util.writes_bytecode_files
- def test_bad_magic(self):
- # When the magic number is different, the bytecode should be
- # regenerated.
- with source_util.create_modules('_temp') as mapping:
- bc_path = self.manipulate_bytecode('_temp', mapping,
- lambda bc: b'\x00\x00\x00\x00' + bc[4:])
- self.import_(mapping['_temp'], '_temp')
- with open(bc_path, 'rb') as bytecode_file:
- self.assertEqual(bytecode_file.read(4), imp.get_magic())
+ def test_non_code_marshal(self):
+ self._test_non_code_marshal()
+ # XXX ImportError when sourceless
+
+ # [bad marshal]
+ @source_util.writes_bytecode_files
+ def test_bad_marshal(self):
+ # Bad marshal data should raise a ValueError.
+ self._test_bad_marshal()
# [bad timestamp]
@source_util.writes_bytecode_files
- def test_bad_bytecode(self):
+ def test_old_timestamp(self):
# When the timestamp is older than the source, bytecode should be
# regenerated.
zeros = b'\x00\x00\x00\x00'
with source_util.create_modules('_temp') as mapping:
py_compile.compile(mapping['_temp'])
- bytecode_path = source_util.bytecode_path(mapping['_temp'])
+ bytecode_path = imp.cache_from_source(mapping['_temp'])
with open(bytecode_path, 'r+b') as bytecode_file:
bytecode_file.seek(4)
bytecode_file.write(zeros)
@@ -235,22 +311,6 @@ class BadBytecodeTest(unittest.TestCase):
bytecode_file.seek(4)
self.assertEqual(bytecode_file.read(4), source_timestamp)
- # [bad marshal]
- @source_util.writes_bytecode_files
- def test_bad_marshal(self):
- # Bad marshal data should raise a ValueError.
- with source_util.create_modules('_temp') as mapping:
- bytecode_path = source_util.bytecode_path(mapping['_temp'])
- source_mtime = os.path.getmtime(mapping['_temp'])
- source_timestamp = importlib._w_long(source_mtime)
- with open(bytecode_path, 'wb') as bytecode_file:
- bytecode_file.write(imp.get_magic())
- bytecode_file.write(source_timestamp)
- bytecode_file.write(b'AAAA')
- self.assertRaises(ValueError, self.import_, mapping['_temp'],
- '_temp')
- self.assertTrue('_temp' not in sys.modules)
-
# [bytecode read-only]
@source_util.writes_bytecode_files
def test_read_only_bytecode(self):
@@ -258,7 +318,7 @@ class BadBytecodeTest(unittest.TestCase):
with source_util.create_modules('_temp') as mapping:
# Create bytecode that will need to be re-created.
py_compile.compile(mapping['_temp'])
- bytecode_path = source_util.bytecode_path(mapping['_temp'])
+ bytecode_path = imp.cache_from_source(mapping['_temp'])
with open(bytecode_path, 'r+b') as bytecode_file:
bytecode_file.seek(0)
bytecode_file.write(b'\x00\x00\x00\x00')
@@ -273,9 +333,57 @@ class BadBytecodeTest(unittest.TestCase):
os.chmod(bytecode_path, stat.S_IWUSR)
+class SourcelessLoaderBadBytecodeTest(BadBytecodeTest):
+
+ loader = _bootstrap._SourcelessFileLoader
+
+ def test_empty_file(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(ImportError):
+ self.import_(bytecode_path, name)
+
+ self._test_empty_file(test, del_source=True)
+
+ def test_partial_magic(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(ImportError):
+ self.import_(bytecode_path, name)
+ self._test_partial_magic(test, del_source=True)
+
+ def test_magic_only(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(EOFError):
+ self.import_(bytecode_path, name)
+
+ self._test_magic_only(test, del_source=True)
+
+ def test_bad_magic(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(ImportError):
+ self.import_(bytecode_path, name)
+
+ self._test_bad_magic(test, del_source=True)
+
+ def test_partial_timestamp(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(EOFError):
+ self.import_(bytecode_path, name)
+
+ self._test_partial_timestamp(test, del_source=True)
+
+ def test_no_marshal(self):
+ self._test_no_marshal(del_source=True)
+
+ def test_non_code_marshal(self):
+ self._test_non_code_marshal(del_source=True)
+
+
def test_main():
from test.support import run_unittest
- run_unittest(SimpleTest, BadBytecodeTest)
+ run_unittest(SimpleTest,
+ SourceLoaderBadBytecodeTest,
+ SourcelessLoaderBadBytecodeTest
+ )
if __name__ == '__main__':
diff --git a/Lib/importlib/test/source/test_finder.py b/Lib/importlib/test/source/test_finder.py
index c495c5a90a..7b9088da0c 100644
--- a/Lib/importlib/test/source/test_finder.py
+++ b/Lib/importlib/test/source/test_finder.py
@@ -1,7 +1,9 @@
from importlib import _bootstrap
from .. import abc
from . import util as source_util
+from test.support import make_legacy_pyc
import os
+import errno
import py_compile
import unittest
import warnings
@@ -32,7 +34,9 @@ class FinderTests(abc.FinderTests):
"""
def import_(self, root, module):
- finder = _bootstrap._PyPycFileFinder(root)
+ finder = _bootstrap._FileFinder(root,
+ _bootstrap._SourceFinderDetails(),
+ _bootstrap._SourcelessFinderDetails())
return finder.find_module(module)
def run_test(self, test, create=None, *, compile_=None, unlink=None):
@@ -52,6 +56,14 @@ class FinderTests(abc.FinderTests):
if unlink:
for name in unlink:
os.unlink(mapping[name])
+ try:
+ make_legacy_pyc(mapping[name])
+ except OSError as error:
+ # Some tests do not set compile_=True so the source
+ # module will not get compiled and there will be no
+ # PEP 3147 pyc file to rename.
+ if error.errno != errno.ENOENT:
+ raise
loader = self.import_(mapping['.root'], test)
self.assertTrue(hasattr(loader, 'load_module'))
return loader
@@ -60,7 +72,8 @@ class FinderTests(abc.FinderTests):
# [top-level source]
self.run_test('top_level')
# [top-level bc]
- self.run_test('top_level', compile_={'top_level'}, unlink={'top_level'})
+ self.run_test('top_level', compile_={'top_level'},
+ unlink={'top_level'})
# [top-level both]
self.run_test('top_level', compile_={'top_level'})
@@ -97,15 +110,14 @@ class FinderTests(abc.FinderTests):
with context as mapping:
os.unlink(mapping['pkg.sub.__init__'])
pkg_dir = os.path.dirname(mapping['pkg.__init__'])
- self.assertRaises(ImportWarning, self.import_, pkg_dir,
- 'pkg.sub')
+ with self.assertRaises(ImportWarning):
+ self.import_(pkg_dir, 'pkg.sub')
# [package over modules]
def test_package_over_module(self):
- # XXX This is not a blackbox test!
name = '_temp'
loader = self.run_test(name, {'{0}.__init__'.format(name), name})
- self.assertTrue('__init__' in loader._base_path)
+ self.assertTrue('__init__' in loader.get_filename(name))
def test_failure(self):
@@ -117,8 +129,19 @@ class FinderTests(abc.FinderTests):
def test_empty_dir(self):
with warnings.catch_warnings():
warnings.simplefilter("error", ImportWarning)
- self.assertRaises(ImportWarning, self.run_test, 'pkg',
- {'pkg.__init__'}, unlink={'pkg.__init__'})
+ with self.assertRaises(ImportWarning):
+ self.run_test('pkg', {'pkg.__init__'}, unlink={'pkg.__init__'})
+
+ def test_empty_string_for_dir(self):
+ # The empty string from sys.path means to search in the cwd.
+ finder = _bootstrap._FileFinder('', _bootstrap._SourceFinderDetails())
+ with open('mod.py', 'w') as file:
+ file.write("# test file for importlib")
+ try:
+ loader = finder.find_module('mod')
+ self.assertTrue(hasattr(loader, 'load_module'))
+ finally:
+ os.unlink('mod.py')
def test_main():
diff --git a/Lib/importlib/test/source/test_path_hook.py b/Lib/importlib/test/source/test_path_hook.py
index 3efb3bea10..374f7b6ad3 100644
--- a/Lib/importlib/test/source/test_path_hook.py
+++ b/Lib/importlib/test/source/test_path_hook.py
@@ -8,11 +8,14 @@ class PathHookTest(unittest.TestCase):
"""Test the path hook for source."""
def test_success(self):
- # XXX Only work on existing directories?
with source_util.create_modules('dummy') as mapping:
- self.assertTrue(hasattr(_bootstrap._FileFinder(mapping['.root']),
+ self.assertTrue(hasattr(_bootstrap._file_path_hook(mapping['.root']),
'find_module'))
+ def test_empty_string(self):
+ # The empty string represents the cwd.
+ self.assertTrue(hasattr(_bootstrap._file_path_hook(''), 'find_module'))
+
def test_main():
from test.support import run_unittest
diff --git a/Lib/importlib/test/source/test_source_encoding.py b/Lib/importlib/test/source/test_source_encoding.py
index 373471284c..794a3df246 100644
--- a/Lib/importlib/test/source/test_source_encoding.py
+++ b/Lib/importlib/test/source/test_source_encoding.py
@@ -33,10 +33,10 @@ class EncodingTest(unittest.TestCase):
def run_test(self, source):
with source_util.create_modules(self.module_name) as mapping:
- with open(mapping[self.module_name], 'wb')as file:
+ with open(mapping[self.module_name], 'wb') as file:
file.write(source)
- loader = _bootstrap._PyPycFileLoader(self.module_name,
- mapping[self.module_name], False)
+ loader = _bootstrap._SourceFileLoader(self.module_name,
+ mapping[self.module_name])
return loader.load_module(self.module_name)
def create_source(self, encoding):
@@ -81,7 +81,8 @@ class EncodingTest(unittest.TestCase):
# [BOM conflict]
def test_bom_conflict(self):
source = codecs.BOM_UTF8 + self.create_source('latin-1')
- self.assertRaises(SyntaxError, self.run_test, source)
+ with self.assertRaises(SyntaxError):
+ self.run_test(source)
class LineEndingTest(unittest.TestCase):
@@ -96,8 +97,8 @@ class LineEndingTest(unittest.TestCase):
with source_util.create_modules(module_name) as mapping:
with open(mapping[module_name], 'wb') as file:
file.write(source)
- loader = _bootstrap._PyPycFileLoader(module_name,
- mapping[module_name], False)
+ loader = _bootstrap._SourceFileLoader(module_name,
+ mapping[module_name])
return loader.load_module(module_name)
# [cr]
diff --git a/Lib/importlib/test/source/util.py b/Lib/importlib/test/source/util.py
index 2b945c5936..ae65663a67 100644
--- a/Lib/importlib/test/source/util.py
+++ b/Lib/importlib/test/source/util.py
@@ -1,5 +1,6 @@
from .. import util
import contextlib
+import errno
import functools
import imp
import os
@@ -26,14 +27,16 @@ def writes_bytecode_files(fxn):
return wrapper
-def bytecode_path(source_path):
- for suffix, _, type_ in imp.get_suffixes():
- if type_ == imp.PY_COMPILED:
- bc_suffix = suffix
- break
- else:
- raise ValueError("no bytecode suffix is defined")
- return os.path.splitext(source_path)[0] + bc_suffix
+def ensure_bytecode_path(bytecode_path):
+ """Ensure that the __pycache__ directory for PEP 3147 pyc file exists.
+
+ :param bytecode_path: File system path to PEP 3147 pyc file.
+ """
+ try:
+ os.mkdir(os.path.dirname(bytecode_path))
+ except OSError as error:
+ if error.errno != errno.EEXIST:
+ raise
@contextlib.contextmanager
diff --git a/Lib/importlib/test/test_abc.py b/Lib/importlib/test/test_abc.py
index 6e09534d8c..0ecbe390ad 100644
--- a/Lib/importlib/test/test_abc.py
+++ b/Lib/importlib/test/test_abc.py
@@ -53,9 +53,20 @@ class InspectLoader(InheritanceTests, unittest.TestCase):
machinery.FrozenImporter]
+class ExecutionLoader(InheritanceTests, unittest.TestCase):
+
+ superclasses = [abc.InspectLoader]
+ subclasses = [abc.PyLoader]
+
+
+class SourceLoader(InheritanceTests, unittest.TestCase):
+
+ superclasses = [abc.ResourceLoader, abc.ExecutionLoader]
+
+
class PyLoader(InheritanceTests, unittest.TestCase):
- superclasses = [abc.Loader, abc.ResourceLoader, abc.InspectLoader]
+ superclasses = [abc.Loader, abc.ResourceLoader, abc.ExecutionLoader]
class PyPycLoader(InheritanceTests, unittest.TestCase):
diff --git a/Lib/importlib/test/test_api.py b/Lib/importlib/test/test_api.py
index 65f8d04797..0ffa3c4d80 100644
--- a/Lib/importlib/test/test_api.py
+++ b/Lib/importlib/test/test_api.py
@@ -27,7 +27,7 @@ class ImportModuleTests(unittest.TestCase):
self.assertEqual(module.__name__, name)
def test_shallow_relative_package_import(self):
- # Test importing a module from a package through a relatve import.
+ # Test importing a module from a package through a relative import.
pkg_name = 'pkg'
pkg_long_name = '{0}.__init__'.format(pkg_name)
module_name = 'mod'
@@ -63,7 +63,8 @@ class ImportModuleTests(unittest.TestCase):
def test_relative_import_wo_package(self):
# Relative imports cannot happen without the 'package' argument being
# set.
- self.assertRaises(TypeError, importlib.import_module, '.support')
+ with self.assertRaises(TypeError):
+ importlib.import_module('.support')
def test_main():
diff --git a/Lib/importlib/test/test_util.py b/Lib/importlib/test/test_util.py
index 406477dd42..602447f09e 100644
--- a/Lib/importlib/test/test_util.py
+++ b/Lib/importlib/test/test_util.py
@@ -40,7 +40,7 @@ class ModuleForLoaderTests(unittest.TestCase):
with test_util.uncache(name):
sys.modules[name] = module
returned_module = self.return_module(name)
- self.assertTrue(sys.modules[name] is returned_module)
+ self.assertIs(returned_module, sys.modules[name])
def test_new_module_failure(self):
# Test that a module is removed from sys.modules if added but an
@@ -57,7 +57,7 @@ class ModuleForLoaderTests(unittest.TestCase):
with test_util.uncache(name):
sys.modules[name] = module
self.raise_exception(name)
- self.assertTrue(sys.modules[name] is module)
+ self.assertIs(module, sys.modules[name])
class SetPackageTests(unittest.TestCase):
diff --git a/Lib/importlib/test/util.py b/Lib/importlib/test/util.py
index 845e380bee..0c0c84c310 100644
--- a/Lib/importlib/test/util.py
+++ b/Lib/importlib/test/util.py
@@ -6,21 +6,22 @@ import unittest
import sys
-def case_insensitive_tests(class_):
+CASE_INSENSITIVE_FS = True
+# Windows is the only OS that is *always* case-insensitive
+# (OS X *can* be case-sensitive).
+if sys.platform not in ('win32', 'cygwin'):
+ changed_name = __file__.upper()
+ if changed_name == __file__:
+ changed_name = __file__.lower()
+ if not os.path.exists(changed_name):
+ CASE_INSENSITIVE_FS = False
+
+
+def case_insensitive_tests(test):
"""Class decorator that nullifies tests requiring a case-insensitive
file system."""
- # Windows is the only OS that is *always* case-insensitive
- # (OS X *can* be case-sensitive).
- if sys.platform not in ('win32', 'cygwin'):
- changed_name = __file__.upper()
- if changed_name == __file__:
- changed_name = __file__.lower()
- if os.path.exists(changed_name):
- return class_
- else:
- return unittest.TestCase
- else:
- return class_
+ return unittest.skipIf(not CASE_INSENSITIVE_FS,
+ "requires a case-insensitive filesystem")(test)
@contextmanager
diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py
index 3abc6a957b..7b44fa1344 100644
--- a/Lib/importlib/util.py
+++ b/Lib/importlib/util.py
@@ -1,4 +1,5 @@
"""Utility code for constructing importers, etc."""
+
from ._bootstrap import module_for_loader
from ._bootstrap import set_loader
from ._bootstrap import set_package
diff --git a/Lib/inspect.py b/Lib/inspect.py
index ffe05b7a2c..aa951d83e2 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1,4 +1,3 @@
-# -*- coding: iso-8859-1 -*-
"""Get useful information from live Python objects.
This module encapsulates the interface provided by the internal special
@@ -17,7 +16,7 @@ Here are some of the useful functions provided by this module:
getmodule() - determine the module that an object came from
getclasstree() - arrange classes so as to represent their hierarchy
- getargspec(), getargvalues() - get info about function arguments
+ getargspec(), getargvalues(), getcallargs() - get info about function arguments
getfullargspec() - same, with support for Python-3000 features
formatargspec(), formatargvalues() - format an argument spec
getouterframes(), getinnerframes() - get info about frames
@@ -33,17 +32,28 @@ __date__ = '1 Jan 2001'
import sys
import os
import types
+import itertools
import string
import re
-import dis
import imp
import tokenize
import linecache
from operator import attrgetter
from collections import namedtuple
-# These constants are from Include/code.h.
-CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 0x1, 0x2, 0x4, 0x8
-CO_NESTED, CO_GENERATOR, CO_NOFREE = 0x10, 0x20, 0x40
+
+# Create constants for the compiler flags in Include/code.h
+# We try to get them from dis to avoid duplication, but fall
+# back to hardcording so the dependency is optional
+try:
+ from dis import COMPILER_FLAG_NAMES as _flag_names
+except ImportError:
+ CO_OPTIMIZED, CO_NEWLOCALS = 0x1, 0x2
+ CO_VARARGS, CO_VARKEYWORDS = 0x4, 0x8
+ CO_NESTED, CO_GENERATOR, CO_NOFREE = 0x10, 0x20, 0x40
+else:
+ mod_dict = globals()
+ for k, v in _flag_names.items():
+ mod_dict["CO_" + v] = k
# See Include/object.h
TPFLAGS_IS_ABSTRACT = 1 << 20
@@ -53,6 +63,7 @@ def ismodule(object):
"""Return true if the object is a module.
Module objects provide these attributes:
+ __cached__ pathname to byte compiled file
__doc__ documentation string
__file__ filename (missing for built-in modules)"""
return isinstance(object, types.ModuleType)
@@ -327,22 +338,10 @@ def classify_class_attrs(cls):
return result
# ----------------------------------------------------------- class helpers
-def _searchbases(cls, accum):
- # Simulate the "classic class" search order.
- if cls in accum:
- return
- accum.append(cls)
- for base in cls.__bases__:
- _searchbases(base, accum)
def getmro(cls):
"Return tuple of base classes (including cls) in method resolution order."
- if hasattr(cls, "__mro__"):
- return cls.__mro__
- else:
- result = []
- _searchbases(cls, result)
- return tuple(result)
+ return cls.__mro__
# -------------------------------------------------- source code extraction
def indentsize(line):
@@ -915,6 +914,71 @@ def formatargvalues(args, varargs, varkw, locals,
specs.append(formatvarkw(varkw) + formatvalue(locals[varkw]))
return '(' + ', '.join(specs) + ')'
+def getcallargs(func, *positional, **named):
+ """Get the mapping of arguments to values.
+
+ A dict is returned, with keys the function argument names (including the
+ names of the * and ** arguments, if any), and values the respective bound
+ values from 'positional' and 'named'."""
+ spec = getfullargspec(func)
+ args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = spec
+ f_name = func.__name__
+ arg2value = {}
+
+ if ismethod(func) and func.__self__ is not None:
+ # implicit 'self' (or 'cls' for classmethods) argument
+ positional = (func.__self__,) + positional
+ num_pos = len(positional)
+ num_total = num_pos + len(named)
+ num_args = len(args)
+ num_defaults = len(defaults) if defaults else 0
+ for arg, value in zip(args, positional):
+ arg2value[arg] = value
+ if varargs:
+ if num_pos > num_args:
+ arg2value[varargs] = positional[-(num_pos-num_args):]
+ else:
+ arg2value[varargs] = ()
+ elif 0 < num_args < num_pos:
+ raise TypeError('%s() takes %s %d positional %s (%d given)' % (
+ f_name, 'at most' if defaults else 'exactly', num_args,
+ 'arguments' if num_args > 1 else 'argument', num_total))
+ elif num_args == 0 and num_total:
+ raise TypeError('%s() takes no arguments (%d given)' %
+ (f_name, num_total))
+
+ for arg in itertools.chain(args, kwonlyargs):
+ if arg in named:
+ if arg in arg2value:
+ raise TypeError("%s() got multiple values for keyword "
+ "argument '%s'" % (f_name, arg))
+ else:
+ arg2value[arg] = named.pop(arg)
+ for kwonlyarg in kwonlyargs:
+ if kwonlyarg not in arg2value:
+ try:
+ arg2value[kwonlyarg] = kwonlydefaults[kwonlyarg]
+ except KeyError:
+ raise TypeError("%s() needs keyword-only argument %s" %
+ (f_name, kwonlyarg))
+ if defaults: # fill in any missing values with the defaults
+ for arg, value in zip(args[-num_defaults:], defaults):
+ if arg not in arg2value:
+ arg2value[arg] = value
+ if varkw:
+ arg2value[varkw] = named
+ elif named:
+ unexpected = next(iter(named))
+ raise TypeError("%s() got an unexpected keyword argument '%s'" %
+ (f_name, unexpected))
+ unassigned = num_args - len([arg for arg in args if arg in arg2value])
+ if unassigned:
+ num_required = num_args - num_defaults
+ raise TypeError('%s() takes %s %d %s (%d given)' % (
+ f_name, 'at least' if defaults else 'exactly', num_required,
+ 'arguments' if num_required > 1 else 'argument', num_total))
+ return arg2value
+
# -------------------------------------------------- stack frame extraction
Traceback = namedtuple('Traceback', 'filename lineno function code_context index')
@@ -979,10 +1043,9 @@ def getinnerframes(tb, context=1):
tb = tb.tb_next
return framelist
-if hasattr(sys, '_getframe'):
- currentframe = sys._getframe
-else:
- currentframe = lambda _=None: None
+def currentframe():
+ """Return the frame of the caller or None if this is not possible."""
+ return sys._getframe(1) if hasattr(sys, "_getframe") else None
def stack(context=1):
"""Return a list of records for the stack above the caller's frame."""
@@ -991,3 +1054,115 @@ def stack(context=1):
def trace(context=1):
"""Return a list of records for the stack below the current exception."""
return getinnerframes(sys.exc_info()[2], context)
+
+
+# ------------------------------------------------ static version of getattr
+
+_sentinel = object()
+
+def _static_getmro(klass):
+ return type.__dict__['__mro__'].__get__(klass)
+
+def _check_instance(obj, attr):
+ instance_dict = {}
+ try:
+ instance_dict = object.__getattribute__(obj, "__dict__")
+ except AttributeError:
+ pass
+ return dict.get(instance_dict, attr, _sentinel)
+
+
+def _check_class(klass, attr):
+ for entry in _static_getmro(klass):
+ if not _shadowed_dict(type(entry)):
+ try:
+ return entry.__dict__[attr]
+ except KeyError:
+ pass
+ return _sentinel
+
+def _is_type(obj):
+ try:
+ _static_getmro(obj)
+ except TypeError:
+ return False
+ return True
+
+def _shadowed_dict(klass):
+ dict_attr = type.__dict__["__dict__"]
+ for entry in _static_getmro(klass):
+ try:
+ class_dict = dict_attr.__get__(entry)["__dict__"]
+ except KeyError:
+ pass
+ else:
+ if not (type(class_dict) is types.GetSetDescriptorType and
+ class_dict.__name__ == "__dict__" and
+ class_dict.__objclass__ is entry):
+ return True
+ return False
+
+def getattr_static(obj, attr, default=_sentinel):
+ """Retrieve attributes without triggering dynamic lookup via the
+ descriptor protocol, __getattr__ or __getattribute__.
+
+ Note: this function may not be able to retrieve all attributes
+ that getattr can fetch (like dynamically created attributes)
+ and may find attributes that getattr can't (like descriptors
+ that raise AttributeError). It can also return descriptor objects
+ instead of instance members in some cases. See the
+ documentation for details.
+ """
+ instance_result = _sentinel
+ if not _is_type(obj):
+ klass = type(obj)
+ if not _shadowed_dict(klass):
+ instance_result = _check_instance(obj, attr)
+ else:
+ klass = obj
+
+ klass_result = _check_class(klass, attr)
+
+ if instance_result is not _sentinel and klass_result is not _sentinel:
+ if (_check_class(type(klass_result), '__get__') is not _sentinel and
+ _check_class(type(klass_result), '__set__') is not _sentinel):
+ return klass_result
+
+ if instance_result is not _sentinel:
+ return instance_result
+ if klass_result is not _sentinel:
+ return klass_result
+
+ if obj is klass:
+ # for types we check the metaclass too
+ for entry in _static_getmro(type(klass)):
+ try:
+ return entry.__dict__[attr]
+ except KeyError:
+ pass
+ if default is not _sentinel:
+ return default
+ raise AttributeError(attr)
+
+
+GEN_CREATED = 'GEN_CREATED'
+GEN_RUNNING = 'GEN_RUNNING'
+GEN_SUSPENDED = 'GEN_SUSPENDED'
+GEN_CLOSED = 'GEN_CLOSED'
+
+def getgeneratorstate(generator):
+ """Get current state of a generator-iterator.
+
+ Possible states are:
+ GEN_CREATED: Waiting to start execution.
+ GEN_RUNNING: Currently being executed by the interpreter.
+ GEN_SUSPENDED: Currently suspended at a yield expression.
+ GEN_CLOSED: Execution has completed.
+ """
+ if generator.gi_running:
+ return GEN_RUNNING
+ if generator.gi_frame is None:
+ return GEN_CLOSED
+ if generator.gi_frame.f_lasti == -1:
+ return GEN_CREATED
+ return GEN_SUSPENDED
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index d606cbd8c0..5747fa669a 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -147,10 +147,14 @@ WHITESPACE_STR = ' \t\n\r'
def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
- _w=WHITESPACE.match, _ws=WHITESPACE_STR):
+ memo=None, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
s, end = s_and_end
pairs = []
pairs_append = pairs.append
+ # Backwards compatibility
+ if memo is None:
+ memo = {}
+ memo_get = memo.setdefault
# Use a slice to prevent IndexError from being raised, the following
# check will raise a more specific ValueError if the string is empty
nextchar = s[end:end + 1]
@@ -167,6 +171,7 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
end += 1
while True:
key, end = scanstring(s, end, strict)
+ key = memo_get(key, key)
# To skip some function call overhead we optimize the fast paths where
# the JSON key separator is ": " or just ":".
if s[end:end + 1] != ':':
@@ -214,7 +219,7 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
pairs = object_hook(pairs)
return pairs, end
-def JSONArray(s_and_end, scan_once, context, _w=WHITESPACE.match):
+def JSONArray(s_and_end, scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
s, end = s_and_end
values = []
nextchar = s[end:end + 1]
@@ -328,6 +333,7 @@ class JSONDecoder(object):
self.parse_object = JSONObject
self.parse_array = JSONArray
self.parse_string = scanstring
+ self.memo = {}
self.scan_once = make_scanner(self)
diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py
index 13359856d2..7475f5a544 100644
--- a/Lib/json/encoder.py
+++ b/Lib/json/encoder.py
@@ -259,6 +259,9 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
tuple=tuple,
):
+ if _indent is not None and not isinstance(_indent, str):
+ _indent = ' ' * _indent
+
def _iterencode_list(lst, _current_indent_level):
if not lst:
yield '[]'
@@ -271,7 +274,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
buf = '['
if _indent is not None:
_current_indent_level += 1
- newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
+ newline_indent = '\n' + _indent * _current_indent_level
separator = _item_separator + newline_indent
buf += newline_indent
else:
@@ -307,7 +310,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield chunk
if newline_indent is not None:
_current_indent_level -= 1
- yield '\n' + (' ' * (_indent * _current_indent_level))
+ yield '\n' + _indent * _current_indent_level
yield ']'
if markers is not None:
del markers[markerid]
@@ -324,7 +327,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield '{'
if _indent is not None:
_current_indent_level += 1
- newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
+ newline_indent = '\n' + _indent * _current_indent_level
item_separator = _item_separator + newline_indent
yield newline_indent
else:
@@ -383,7 +386,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield chunk
if newline_indent is not None:
_current_indent_level -= 1
- yield '\n' + (' ' * (_indent * _current_indent_level))
+ yield '\n' + _indent * _current_indent_level
yield '}'
if markers is not None:
del markers[markerid]
diff --git a/Lib/json/scanner.py b/Lib/json/scanner.py
index b4f356146f..23eef61b94 100644
--- a/Lib/json/scanner.py
+++ b/Lib/json/scanner.py
@@ -22,6 +22,8 @@ def py_make_scanner(context):
parse_int = context.parse_int
parse_constant = context.parse_constant
object_hook = context.object_hook
+ object_pairs_hook = context.object_pairs_hook
+ memo = context.memo
def _scan_once(string, idx):
try:
@@ -33,7 +35,7 @@ def py_make_scanner(context):
return parse_string(string, idx + 1, strict)
elif nextchar == '{':
return parse_object((string, idx + 1), strict,
- _scan_once, object_hook, object_pairs_hook)
+ _scan_once, object_hook, object_pairs_hook, memo)
elif nextchar == '[':
return parse_array((string, idx + 1), _scan_once)
elif nextchar == 'n' and string[idx:idx + 4] == 'null':
@@ -60,6 +62,12 @@ def py_make_scanner(context):
else:
raise StopIteration
+ def scan_once(string, idx):
+ try:
+ return _scan_once(string, idx)
+ finally:
+ memo.clear()
+
return _scan_once
make_scanner = c_make_scanner or py_make_scanner
diff --git a/Lib/keyword.py b/Lib/keyword.py
index a7abe2b419..a3788a6b0b 100755
--- a/Lib/keyword.py
+++ b/Lib/keyword.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Keywords (from "graminit.c")
@@ -61,21 +61,19 @@ def main():
else: optfile = "Lib/keyword.py"
# scan the source file for keywords
- fp = open(iptfile)
- strprog = re.compile('"([^"]+)"')
- lines = []
- for line in fp:
- if '{1, "' in line:
- match = strprog.search(line)
- if match:
- lines.append(" '" + match.group(1) + "',\n")
- fp.close()
+ with open(iptfile) as fp:
+ strprog = re.compile('"([^"]+)"')
+ lines = []
+ for line in fp:
+ if '{1, "' in line:
+ match = strprog.search(line)
+ if match:
+ lines.append(" '" + match.group(1) + "',\n")
lines.sort()
# load the output skeleton from the target
- fp = open(optfile)
- format = fp.readlines()
- fp.close()
+ with open(optfile) as fp:
+ format = fp.readlines()
# insert the lines of keywords
try:
diff --git a/Lib/lib2to3/pgen2/token.py b/Lib/lib2to3/pgen2/token.py
index 1c810651eb..6a6d0b6b65 100755
--- a/Lib/lib2to3/pgen2/token.py
+++ b/Lib/lib2to3/pgen2/token.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Token constants (from "token.h")."""
diff --git a/Lib/lib2to3/tests/pytree_idempotency.py b/Lib/lib2to3/tests/pytree_idempotency.py
index 414eb4d99e..a02bbfe201 100755
--- a/Lib/lib2to3/tests/pytree_idempotency.py
+++ b/Lib/lib2to3/tests/pytree_idempotency.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
diff --git a/Lib/linecache.py b/Lib/linecache.py
index 974b1d965a..c3f2c3fdca 100644
--- a/Lib/linecache.py
+++ b/Lib/linecache.py
@@ -123,9 +123,7 @@ def updatecache(filename, module_globals=None):
else:
return []
try:
- with open(fullname, 'rb') as fp:
- coding, line = tokenize.detect_encoding(fp.readline)
- with open(fullname, 'r', encoding=coding) as fp:
+ with tokenize.open(fullname) as fp:
lines = fp.readlines()
except IOError:
return []
diff --git a/Lib/locale.py b/Lib/locale.py
index 8c44625e05..7b987bed06 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -121,12 +121,15 @@ def localeconv():
# Iterate over grouping intervals
def _grouping_intervals(grouping):
+ last_interval = None
for interval in grouping:
# if grouping is -1, we are done
if interval == CHAR_MAX:
return
# 0: re-use last group ad infinitum
if interval == 0:
+ if last_interval is None:
+ raise ValueError("invalid grouping")
while True:
yield last_interval
yield interval
@@ -715,6 +718,28 @@ locale_encoding_alias = {
# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+#
+# AP 2010-04-12:
+# Updated alias mapping to most recent locale.alias file
+# from X.org distribution using makelocalealias.py.
+#
+# These are the differences compared to the old mapping (Python 2.6.5
+# and older):
+#
+# updated 'ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
+# updated 'ru_ru' -> 'ru_RU.ISO8859-5' to 'ru_RU.UTF-8'
+# updated 'serbocroatian' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
+# updated 'sh' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
+# updated 'sh_yu' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
+# updated 'sr' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
+# updated 'sr@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
+# updated 'sr@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
+# updated 'sr_cs.utf8@latn' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8@latin'
+# updated 'sr_cs@latn' -> 'sr_CS.ISO8859-2' to 'sr_RS.UTF-8@latin'
+# updated 'sr_yu' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8@latin'
+# updated 'sr_yu.utf8@cyrillic' -> 'sr_CS.UTF-8' to 'sr_RS.UTF-8'
+# updated 'sr_yu@cyrillic' -> 'sr_CS.ISO8859-5' to 'sr_RS.UTF-8'
+#
locale_alias = {
'a3': 'a3_AZ.KOI8-C',
@@ -766,13 +791,17 @@ locale_alias = {
'ar_ye.iso88596': 'ar_YE.ISO8859-6',
'arabic': 'ar_AA.ISO8859-6',
'arabic.iso88596': 'ar_AA.ISO8859-6',
+ 'as': 'as_IN.UTF-8',
'az': 'az_AZ.ISO8859-9E',
'az_az': 'az_AZ.ISO8859-9E',
'az_az.iso88599e': 'az_AZ.ISO8859-9E',
'be': 'be_BY.CP1251',
+ 'be@latin': 'be_BY.UTF-8@latin',
'be_by': 'be_BY.CP1251',
'be_by.cp1251': 'be_BY.CP1251',
'be_by.microsoftcp1251': 'be_BY.CP1251',
+ 'be_by.utf8@latin': 'be_BY.UTF-8@latin',
+ 'be_by@latin': 'be_BY.UTF-8@latin',
'bg': 'bg_BG.CP1251',
'bg_bg': 'bg_BG.CP1251',
'bg_bg.cp1251': 'bg_BG.CP1251',
@@ -802,12 +831,30 @@ locale_alias = {
'c_c': 'C',
'c_c.c': 'C',
'ca': 'ca_ES.ISO8859-1',
+ 'ca_ad': 'ca_AD.ISO8859-1',
+ 'ca_ad.iso88591': 'ca_AD.ISO8859-1',
+ 'ca_ad.iso885915': 'ca_AD.ISO8859-15',
+ 'ca_ad.iso885915@euro': 'ca_AD.ISO8859-15',
+ 'ca_ad.utf8@euro': 'ca_AD.UTF-8',
+ 'ca_ad@euro': 'ca_AD.ISO8859-15',
'ca_es': 'ca_ES.ISO8859-1',
'ca_es.iso88591': 'ca_ES.ISO8859-1',
'ca_es.iso885915': 'ca_ES.ISO8859-15',
'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
'ca_es.utf8@euro': 'ca_ES.UTF-8',
'ca_es@euro': 'ca_ES.ISO8859-15',
+ 'ca_fr': 'ca_FR.ISO8859-1',
+ 'ca_fr.iso88591': 'ca_FR.ISO8859-1',
+ 'ca_fr.iso885915': 'ca_FR.ISO8859-15',
+ 'ca_fr.iso885915@euro': 'ca_FR.ISO8859-15',
+ 'ca_fr.utf8@euro': 'ca_FR.UTF-8',
+ 'ca_fr@euro': 'ca_FR.ISO8859-15',
+ 'ca_it': 'ca_IT.ISO8859-1',
+ 'ca_it.iso88591': 'ca_IT.ISO8859-1',
+ 'ca_it.iso885915': 'ca_IT.ISO8859-15',
+ 'ca_it.iso885915@euro': 'ca_IT.ISO8859-15',
+ 'ca_it.utf8@euro': 'ca_IT.UTF-8',
+ 'ca_it@euro': 'ca_IT.ISO8859-15',
'catalan': 'ca_ES.ISO8859-1',
'cextend': 'en_US.ISO8859-1',
'cextend.en': 'en_US.ISO8859-1',
@@ -829,6 +876,7 @@ locale_alias = {
'cz_cz': 'cs_CZ.ISO8859-2',
'czech': 'cs_CZ.ISO8859-2',
'da': 'da_DK.ISO8859-1',
+ 'da.iso885915': 'da_DK.ISO8859-15',
'da_dk': 'da_DK.ISO8859-1',
'da_dk.88591': 'da_DK.ISO8859-1',
'da_dk.885915': 'da_DK.ISO8859-15',
@@ -839,6 +887,7 @@ locale_alias = {
'danish.iso88591': 'da_DK.ISO8859-1',
'dansk': 'da_DK.ISO8859-1',
'de': 'de_DE.ISO8859-1',
+ 'de.iso885915': 'de_DE.ISO8859-15',
'de_at': 'de_AT.ISO8859-1',
'de_at.iso88591': 'de_AT.ISO8859-1',
'de_at.iso885915': 'de_AT.ISO8859-15',
@@ -1020,6 +1069,7 @@ locale_alias = {
'fa_ir': 'fa_IR.UTF-8',
'fa_ir.isiri3342': 'fa_IR.ISIRI-3342',
'fi': 'fi_FI.ISO8859-15',
+ 'fi.iso885915': 'fi_FI.ISO8859-15',
'fi_fi': 'fi_FI.ISO8859-15',
'fi_fi.88591': 'fi_FI.ISO8859-1',
'fi_fi.iso88591': 'fi_FI.ISO8859-1',
@@ -1035,6 +1085,7 @@ locale_alias = {
'fo_fo.iso885915': 'fo_FO.ISO8859-15',
'fo_fo@euro': 'fo_FO.ISO8859-15',
'fr': 'fr_FR.ISO8859-1',
+ 'fr.iso885915': 'fr_FR.ISO8859-15',
'fr_be': 'fr_BE.ISO8859-1',
'fr_be.88591': 'fr_BE.ISO8859-1',
'fr_be.iso88591': 'fr_BE.ISO8859-1',
@@ -1121,6 +1172,7 @@ locale_alias = {
'hi': 'hi_IN.ISCII-DEV',
'hi_in': 'hi_IN.ISCII-DEV',
'hi_in.isciidev': 'hi_IN.ISCII-DEV',
+ 'hne': 'hne_IN.UTF-8',
'hr': 'hr_HR.ISO8859-2',
'hr_hr': 'hr_HR.ISO8859-2',
'hr_hr.iso88592': 'hr_HR.ISO8859-2',
@@ -1147,6 +1199,7 @@ locale_alias = {
'iso_8859_1': 'en_US.ISO8859-1',
'iso_8859_15': 'en_US.ISO8859-15',
'it': 'it_IT.ISO8859-1',
+ 'it.iso885915': 'it_IT.ISO8859-15',
'it_ch': 'it_CH.ISO8859-1',
'it_ch.iso88591': 'it_CH.ISO8859-1',
'it_ch.iso885915': 'it_CH.ISO8859-15',
@@ -1178,6 +1231,7 @@ locale_alias = {
'ja_jp.jis': 'ja_JP.JIS7',
'ja_jp.jis7': 'ja_JP.JIS7',
'ja_jp.mscode': 'ja_JP.SJIS',
+ 'ja_jp.pck': 'ja_JP.SJIS',
'ja_jp.sjis': 'ja_JP.SJIS',
'ja_jp.ujis': 'ja_JP.eucJP',
'japan': 'ja_JP.eucJP',
@@ -1197,6 +1251,7 @@ locale_alias = {
'kl_gl.iso885915': 'kl_GL.ISO8859-15',
'kl_gl@euro': 'kl_GL.ISO8859-15',
'km_kh': 'km_KH.UTF-8',
+ 'kn': 'kn_IN.UTF-8',
'kn_in': 'kn_IN.UTF-8',
'ko': 'ko_KR.eucKR',
'ko_kr': 'ko_KR.eucKR',
@@ -1204,6 +1259,8 @@ locale_alias = {
'ko_kr.euckr': 'ko_KR.eucKR',
'korean': 'ko_KR.eucKR',
'korean.euc': 'ko_KR.eucKR',
+ 'ks': 'ks_IN.UTF-8',
+ 'ks_in@devanagari': 'ks_IN@devanagari.UTF-8',
'kw': 'kw_GB.ISO8859-1',
'kw_gb': 'kw_GB.ISO8859-1',
'kw_gb.iso88591': 'kw_GB.ISO8859-1',
@@ -1226,6 +1283,7 @@ locale_alias = {
'lv_lv': 'lv_LV.ISO8859-13',
'lv_lv.iso885913': 'lv_LV.ISO8859-13',
'lv_lv.iso88594': 'lv_LV.ISO8859-4',
+ 'mai': 'mai_IN.UTF-8',
'mi': 'mi_NZ.ISO8859-1',
'mi_nz': 'mi_NZ.ISO8859-1',
'mi_nz.iso88591': 'mi_NZ.ISO8859-1',
@@ -1234,6 +1292,8 @@ locale_alias = {
'mk_mk.cp1251': 'mk_MK.CP1251',
'mk_mk.iso88595': 'mk_MK.ISO8859-5',
'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
+ 'ml': 'ml_IN.UTF-8',
+ 'mr': 'mr_IN.UTF-8',
'mr_in': 'mr_IN.UTF-8',
'ms': 'ms_MY.ISO8859-1',
'ms_my': 'ms_MY.ISO8859-1',
@@ -1248,6 +1308,7 @@ locale_alias = {
'nb_no.iso885915': 'nb_NO.ISO8859-15',
'nb_no@euro': 'nb_NO.ISO8859-15',
'nl': 'nl_NL.ISO8859-1',
+ 'nl.iso885915': 'nl_NL.ISO8859-15',
'nl_be': 'nl_BE.ISO8859-1',
'nl_be.88591': 'nl_BE.ISO8859-1',
'nl_be.iso88591': 'nl_BE.ISO8859-1',
@@ -1274,6 +1335,8 @@ locale_alias = {
'no_no.88591': 'no_NO.ISO8859-1',
'no_no.iso88591': 'no_NO.ISO8859-1',
'no_no.iso885915': 'no_NO.ISO8859-15',
+ 'no_no.iso88591@bokmal': 'no_NO.ISO8859-1',
+ 'no_no.iso88591@nynorsk': 'no_NO.ISO8859-1',
'no_no@euro': 'no_NO.ISO8859-15',
'norwegian': 'no_NO.ISO8859-1',
'norwegian.iso88591': 'no_NO.ISO8859-1',
@@ -1295,6 +1358,8 @@ locale_alias = {
'oc_fr.iso88591': 'oc_FR.ISO8859-1',
'oc_fr.iso885915': 'oc_FR.ISO8859-15',
'oc_fr@euro': 'oc_FR.ISO8859-15',
+ 'or': 'or_IN.UTF-8',
+ 'pa': 'pa_IN.UTF-8',
'pa_in': 'pa_IN.UTF-8',
'pd': 'pd_US.ISO8859-1',
'pd_de': 'pd_DE.ISO8859-1',
@@ -1322,6 +1387,7 @@ locale_alias = {
'pp_an': 'pp_AN.ISO8859-1',
'pp_an.iso88591': 'pp_AN.ISO8859-1',
'pt': 'pt_PT.ISO8859-1',
+ 'pt.iso885915': 'pt_PT.ISO8859-15',
'pt_br': 'pt_BR.ISO8859-1',
'pt_br.88591': 'pt_BR.ISO8859-1',
'pt_br.iso88591': 'pt_BR.ISO8859-1',
@@ -1338,8 +1404,9 @@ locale_alias = {
'ro_ro': 'ro_RO.ISO8859-2',
'ro_ro.iso88592': 'ro_RO.ISO8859-2',
'romanian': 'ro_RO.ISO8859-2',
- 'ru': 'ru_RU.ISO8859-5',
- 'ru_ru': 'ru_RU.ISO8859-5',
+ 'ru': 'ru_RU.UTF-8',
+ 'ru.koi8r': 'ru_RU.KOI8-R',
+ 'ru_ru': 'ru_RU.UTF-8',
'ru_ru.cp1251': 'ru_RU.CP1251',
'ru_ru.iso88595': 'ru_RU.ISO8859-5',
'ru_ru.koi8r': 'ru_RU.KOI8-R',
@@ -1353,13 +1420,15 @@ locale_alias = {
'rw': 'rw_RW.ISO8859-1',
'rw_rw': 'rw_RW.ISO8859-1',
'rw_rw.iso88591': 'rw_RW.ISO8859-1',
+ 'sd': 'sd_IN@devanagari.UTF-8',
'se_no': 'se_NO.UTF-8',
- 'serbocroatian': 'sr_CS.ISO8859-2',
- 'sh': 'sr_CS.ISO8859-2',
+ 'serbocroatian': 'sr_RS.UTF-8@latin',
+ 'sh': 'sr_RS.UTF-8@latin',
+ 'sh_ba.iso88592@bosnia': 'sr_CS.ISO8859-2',
'sh_hr': 'sh_HR.ISO8859-2',
'sh_hr.iso88592': 'hr_HR.ISO8859-2',
'sh_sp': 'sr_CS.ISO8859-2',
- 'sh_yu': 'sr_CS.ISO8859-2',
+ 'sh_yu': 'sr_RS.UTF-8@latin',
'si': 'si_LK.UTF-8',
'si_lk': 'si_LK.UTF-8',
'sinhala': 'si_LK.UTF-8',
@@ -1382,23 +1451,30 @@ locale_alias = {
'sq': 'sq_AL.ISO8859-2',
'sq_al': 'sq_AL.ISO8859-2',
'sq_al.iso88592': 'sq_AL.ISO8859-2',
- 'sr': 'sr_CS.ISO8859-5',
- 'sr@cyrillic': 'sr_CS.ISO8859-5',
- 'sr@latn': 'sr_CS.ISO8859-2',
+ 'sr': 'sr_RS.UTF-8',
+ 'sr@cyrillic': 'sr_RS.UTF-8',
+ 'sr@latin': 'sr_RS.UTF-8@latin',
+ 'sr@latn': 'sr_RS.UTF-8@latin',
+ 'sr_cs': 'sr_RS.UTF-8',
'sr_cs.iso88592': 'sr_CS.ISO8859-2',
'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
'sr_cs.iso88595': 'sr_CS.ISO8859-5',
- 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
- 'sr_cs@latn': 'sr_CS.ISO8859-2',
+ 'sr_cs.utf8@latn': 'sr_RS.UTF-8@latin',
+ 'sr_cs@latn': 'sr_RS.UTF-8@latin',
+ 'sr_me': 'sr_ME.UTF-8',
+ 'sr_rs': 'sr_RS.UTF-8',
+ 'sr_rs.utf8@latn': 'sr_RS.UTF-8@latin',
+ 'sr_rs@latin': 'sr_RS.UTF-8@latin',
+ 'sr_rs@latn': 'sr_RS.UTF-8@latin',
'sr_sp': 'sr_CS.ISO8859-2',
- 'sr_yu': 'sr_CS.ISO8859-5',
+ 'sr_yu': 'sr_RS.UTF-8@latin',
'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
'sr_yu.iso88592': 'sr_CS.ISO8859-2',
'sr_yu.iso88595': 'sr_CS.ISO8859-5',
'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
- 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
- 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
+ 'sr_yu.utf8@cyrillic': 'sr_RS.UTF-8',
+ 'sr_yu@cyrillic': 'sr_RS.UTF-8',
'ss': 'ss_ZA.ISO8859-1',
'ss_za': 'ss_ZA.ISO8859-1',
'ss_za.iso88591': 'ss_ZA.ISO8859-1',
@@ -1406,6 +1482,7 @@ locale_alias = {
'st_za': 'st_ZA.ISO8859-1',
'st_za.iso88591': 'st_ZA.ISO8859-1',
'sv': 'sv_SE.ISO8859-1',
+ 'sv.iso885915': 'sv_SE.ISO8859-15',
'sv_fi': 'sv_FI.ISO8859-1',
'sv_fi.iso88591': 'sv_FI.ISO8859-1',
'sv_fi.iso885915': 'sv_FI.ISO8859-15',
@@ -1423,6 +1500,7 @@ locale_alias = {
'ta_in': 'ta_IN.TSCII-0',
'ta_in.tscii': 'ta_IN.TSCII-0',
'ta_in.tscii0': 'ta_IN.TSCII-0',
+ 'te': 'te_IN.UTF-8',
'tg': 'tg_TJ.KOI8-C',
'tg_tj': 'tg_TJ.KOI8-C',
'tg_tj.koi8c': 'tg_TJ.KOI8-C',
@@ -1498,6 +1576,7 @@ locale_alias = {
'zh_cn.gbk': 'zh_CN.gbk',
'zh_hk': 'zh_HK.big5hkscs',
'zh_hk.big5': 'zh_HK.big5',
+ 'zh_hk.big5hk': 'zh_HK.big5hkscs',
'zh_hk.big5hkscs': 'zh_HK.big5hkscs',
'zh_tw': 'zh_TW.big5',
'zh_tw.big5': 'zh_TW.big5',
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 685efeb4a8..e4b34a1af7 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
@@ -23,7 +23,8 @@ Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
-import sys, os, time, io, traceback, warnings
+import sys, os, time, io, traceback, warnings, weakref
+from string import Template
__all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler', 'INFO',
@@ -31,7 +32,8 @@ __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
'StreamHandler', 'WARN', 'WARNING', 'addLevelName', 'basicConfig',
'captureWarnings', 'critical', 'debug', 'disable', 'error',
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
- 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning']
+ 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning',
+ 'getLogRecordFactory', 'setLogRecordFactory', 'lastResort']
try:
import codecs
@@ -46,15 +48,13 @@ except ImportError:
__author__ = "Vinay Sajip <vinay_sajip@red-dove.com>"
__status__ = "production"
-__version__ = "0.5.0.7"
-__date__ = "20 January 2009"
+__version__ = "0.5.1.2"
+__date__ = "07 February 2010"
#---------------------------------------------------------------------------
# Miscellaneous module data
#---------------------------------------------------------------------------
-_unicode = 'unicode' in dir(__builtins__)
-
#
# _srcfile is used when walking the stack to check when we've got the first
# caller stack frame.
@@ -176,19 +176,34 @@ def addLevelName(level, levelName):
finally:
_releaseLock()
+def _checkLevel(level):
+ if isinstance(level, int):
+ rv = level
+ elif str(level) == level:
+ if level not in _levelNames:
+ raise ValueError("Unknown level: %r" % level)
+ rv = _levelNames[level]
+ else:
+ raise TypeError("Level not an integer or a valid string: %r" % level)
+ return rv
+
#---------------------------------------------------------------------------
# Thread-related stuff
#---------------------------------------------------------------------------
#
#_lock is used to serialize access to shared data structures in this module.
-#This needs to be an RLock because fileConfig() creates Handlers and so
-#might arbitrary user threads. Since Handler.__init__() updates the shared
-#dictionary _handlers, it needs to acquire the lock. But if configuring,
+#This needs to be an RLock because fileConfig() creates and configures
+#Handlers, and so might arbitrary user threads. Since Handler code updates the
+#shared dictionary _handlers, it needs to acquire the lock. But if configuring,
#the lock would already have been acquired - so we need an RLock.
#The same argument applies to Loggers and Manager.loggerDict.
#
-_lock = None
+if thread:
+ _lock = threading.RLock()
+else:
+ _lock = None
+
def _acquireLock():
"""
@@ -196,9 +211,6 @@ def _acquireLock():
This should be released with _releaseLock().
"""
- global _lock
- if (not _lock) and thread:
- _lock = threading.RLock()
if _lock:
_lock.acquire()
@@ -213,7 +225,7 @@ def _releaseLock():
# The logging record
#---------------------------------------------------------------------------
-class LogRecord:
+class LogRecord(object):
"""
A LogRecord instance represents an event being logged.
@@ -226,7 +238,7 @@ class LogRecord:
information to be logged.
"""
def __init__(self, name, level, pathname, lineno,
- msg, args, exc_info, func=None):
+ msg, args, exc_info, func=None, sinfo=None, **kwargs):
"""
Initialize a logging record with interesting information.
"""
@@ -260,6 +272,7 @@ class LogRecord:
self.module = "Unknown module"
self.exc_info = exc_info
self.exc_text = None # used to cache the traceback text
+ self.stack_info = sinfo
self.lineno = lineno
self.funcName = func
self.created = ct
@@ -274,11 +287,17 @@ class LogRecord:
if not logMultiprocessing:
self.processName = None
else:
- try:
- from multiprocessing import current_process
- self.processName = current_process().name
- except ImportError:
- self.processName = None
+ self.processName = 'MainProcess'
+ mp = sys.modules.get('multiprocessing')
+ if mp is not None:
+ # Errors may occur if multiprocessing has not finished loading
+ # yet - e.g. if a custom import hook causes third-party code
+ # to run when multiprocessing calls import. See issue 8200
+ # for an example
+ try:
+ self.processName = mp.current_process().name
+ except StandardError:
+ pass
if logProcesses and hasattr(os, 'getpid'):
self.process = os.getpid()
else:
@@ -295,19 +314,33 @@ class LogRecord:
Return the message for this LogRecord after merging any user-supplied
arguments with the message.
"""
- if not _unicode: #if no unicode support...
- msg = str(self.msg)
- else:
- msg = self.msg
- if not isinstance(msg, str):
- try:
- msg = str(self.msg)
- except UnicodeError:
- msg = self.msg #Defer encoding till later
+ msg = str(self.msg)
if self.args:
msg = msg % self.args
return msg
+#
+# Determine which class to use when instantiating log records.
+#
+_logRecordFactory = LogRecord
+
+def setLogRecordFactory(factory):
+ """
+ Set the factory to be used when instantiating a log record.
+
+ :param factory: A callable which will be called to instantiate
+ a log record.
+ """
+ global _logRecordFactory
+ _logRecordFactory = factory
+
+def getLogRecordFactory():
+ """
+ Return the factory to be used when instantiating a log record.
+ """
+
+ return _logRecordFactory
+
def makeLogRecord(dict):
"""
Make a LogRecord whose attributes are defined by the specified dictionary,
@@ -315,7 +348,7 @@ def makeLogRecord(dict):
a socket connection (which is sent as a dictionary) into a LogRecord
instance.
"""
- rv = LogRecord(None, None, "", 0, "", (), None, None)
+ rv = _logRecordFactory(None, None, "", 0, "", (), None, None)
rv.__dict__.update(dict)
return rv
@@ -323,7 +356,53 @@ def makeLogRecord(dict):
# Formatter classes and functions
#---------------------------------------------------------------------------
-class Formatter:
+class PercentStyle(object):
+
+ default_format = '%(message)s'
+ asctime_format = '%(asctime)s'
+ asctime_search = '%(asctime)'
+
+ def __init__(self, fmt):
+ self._fmt = fmt or self.default_format
+
+ def usesTime(self):
+ return self._fmt.find(self.asctime_search) >= 0
+
+ def format(self, record):
+ return self._fmt % record.__dict__
+
+class StrFormatStyle(PercentStyle):
+ default_format = '{message}'
+ asctime_format = '{asctime}'
+ asctime_search = '{asctime'
+
+ def format(self, record):
+ return self._fmt.format(**record.__dict__)
+
+
+class StringTemplateStyle(PercentStyle):
+ default_format = '${message}'
+ asctime_format = '${asctime}'
+ asctime_search = '${asctime}'
+
+ def __init__(self, fmt):
+ self._fmt = fmt or self.default_format
+ self._tpl = Template(self._fmt)
+
+ def usesTime(self):
+ fmt = self._fmt
+ return fmt.find('$asctime') >= 0 or fmt.find(self.asctime_format) >= 0
+
+ def format(self, record):
+ return self._tpl.substitute(**record.__dict__)
+
+_STYLES = {
+ '%': PercentStyle,
+ '{': StrFormatStyle,
+ '$': StringTemplateStyle
+}
+
+class Formatter(object):
"""
Formatter instances are used to convert a LogRecord to text.
@@ -331,7 +410,7 @@ class Formatter:
responsible for converting a LogRecord to (usually) a string which can
be interpreted by either a human or an external system. The base Formatter
allows a formatting string to be specified. If none is supplied, the
- default value of "%s(message)\\n" is used.
+ default value of "%s(message)" is used.
The Formatter can be initialized with a format string which makes use of
knowledge of the LogRecord attributes - e.g. the default value mentioned
@@ -367,18 +446,26 @@ class Formatter:
converter = time.localtime
- def __init__(self, fmt=None, datefmt=None):
+ def __init__(self, fmt=None, datefmt=None, style='%'):
"""
Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a
default as described above. Allow for specialized date formatting with
the optional datefmt argument (if omitted, you get the ISO8601 format).
+
+ Use a style parameter of '%', '{' or '$' to specify that you want to
+ use one of %-formatting, :meth:`str.format` (``{}``) formatting or
+ :class:`string.Template` formatting in your format string.
+
+ .. versionchanged: 3.2
+ Added the ``style`` parameter.
"""
- if fmt:
- self._fmt = fmt
- else:
- self._fmt = "%(message)s"
+ if style not in _STYLES:
+ raise ValueError('Style must be one of: %s' % ','.join(
+ _STYLES.keys()))
+ self._style = _STYLES[style](fmt)
+ self._fmt = self._style._fmt
self.datefmt = datefmt
def formatTime(self, record, datefmt=None):
@@ -404,7 +491,7 @@ class Formatter:
s = time.strftime(datefmt, ct)
else:
t = time.strftime("%Y-%m-%d %H:%M:%S", ct)
- s = "%s,%03d" % (t, record.msecs)
+ s = "%s,%03d" % (t, record.msecs) # the use of % here is internal
return s
def formatException(self, ei):
@@ -415,13 +502,39 @@ class Formatter:
traceback.print_exception()
"""
sio = io.StringIO()
- traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
+ tb = ei[2]
+ # See issues #9427, #1553375. Commented out for now.
+ #if getattr(self, 'fullstack', False):
+ # traceback.print_stack(tb.tb_frame.f_back, file=sio)
+ traceback.print_exception(ei[0], ei[1], tb, None, sio)
s = sio.getvalue()
sio.close()
if s[-1:] == "\n":
s = s[:-1]
return s
+ def usesTime(self):
+ """
+ Check if the format uses the creation time of the record.
+ """
+ return self._style.usesTime()
+
+ def formatMessage(self, record):
+ return self._style.format(record)
+
+ def formatStack(self, stack_info):
+ """
+ This method is provided as an extension point for specialized
+ formatting of stack information.
+
+ The input data is a string as returned from a call to
+ :func:`traceback.print_stack`, but with the last trailing newline
+ removed.
+
+ The base implementation just returns the value passed in.
+ """
+ return stack_info
+
def format(self, record):
"""
Format the specified record as text.
@@ -430,15 +543,15 @@ class Formatter:
string formatting operation which yields the returned string.
Before formatting the dictionary, a couple of preparatory steps
are carried out. The message attribute of the record is computed
- using LogRecord.getMessage(). If the formatting string contains
- "%(asctime)", formatTime() is called to format the event time.
- If there is exception information, it is formatted using
- formatException() and appended to the message.
+ using LogRecord.getMessage(). If the formatting string uses the
+ time (as determined by a call to usesTime(), formatTime() is
+ called to format the event time. If there is exception information,
+ it is formatted using formatException() and appended to the message.
"""
record.message = record.getMessage()
- if self._fmt.find("%(asctime)") >= 0:
+ if self.usesTime():
record.asctime = self.formatTime(record, self.datefmt)
- s = self._fmt % record.__dict__
+ s = self.formatMessage(record)
if record.exc_info:
# Cache the traceback text to avoid converting it multiple times
# (it's constant anyway)
@@ -448,6 +561,10 @@ class Formatter:
if s[-1:] != "\n":
s = s + "\n"
s = s + record.exc_text
+ if record.stack_info:
+ if s[-1:] != "\n":
+ s = s + "\n"
+ s = s + self.formatStack(record.stack_info)
return s
#
@@ -455,7 +572,7 @@ class Formatter:
#
_defaultFormatter = Formatter()
-class BufferingFormatter:
+class BufferingFormatter(object):
"""
A formatter suitable for formatting a number of records.
"""
@@ -497,7 +614,7 @@ class BufferingFormatter:
# Filter classes and functions
#---------------------------------------------------------------------------
-class Filter:
+class Filter(object):
"""
Filter instances are used to perform arbitrary filtering of LogRecords.
@@ -534,7 +651,7 @@ class Filter:
return 0
return (record.name[self.nlen] == ".")
-class Filterer:
+class Filterer(object):
"""
A base class for loggers and handlers which allows them to share
common code.
@@ -566,10 +683,18 @@ class Filterer:
The default is to allow the record to be logged; any filter can veto
this and the record is then dropped. Returns a zero value if a record
is to be dropped, else non-zero.
+
+ .. versionchanged: 3.2
+
+ Allow filters to be just callables.
"""
rv = 1
for f in self.filters:
- if not f.filter(record):
+ if hasattr(f, 'filter'):
+ result = f.filter(record)
+ else:
+ result = f(record) # assume callable - will raise if not
+ if not result:
rv = 0
break
return rv
@@ -578,9 +703,34 @@ class Filterer:
# Handler classes and functions
#---------------------------------------------------------------------------
-_handlers = {} #repository of handlers (for flushing when shutdown called)
+_handlers = weakref.WeakValueDictionary() #map of handler names to handlers
_handlerList = [] # added to allow handlers to be removed in reverse of order initialized
+def _removeHandlerRef(wr):
+ """
+ Remove a handler reference from the internal cleanup list.
+ """
+ # This function can be called during module teardown, when globals are
+ # set to None. If _acquireLock is None, assume this is the case and do
+ # nothing.
+ if _acquireLock is not None:
+ _acquireLock()
+ try:
+ if wr in _handlerList:
+ _handlerList.remove(wr)
+ finally:
+ _releaseLock()
+
+def _addHandlerRef(handler):
+ """
+ Add a handler to the internal cleanup list using a weak reference.
+ """
+ _acquireLock()
+ try:
+ _handlerList.append(weakref.ref(handler, _removeHandlerRef))
+ finally:
+ _releaseLock()
+
class Handler(Filterer):
"""
Handler instances dispatch logging events to specific destinations.
@@ -596,16 +746,28 @@ class Handler(Filterer):
and the filter list to empty.
"""
Filterer.__init__(self)
- self.level = level
+ self._name = None
+ self.level = _checkLevel(level)
self.formatter = None
- #get the module data lock, as we're updating a shared structure.
+ # Add the handler to the global _handlerList (for cleanup on shutdown)
+ _addHandlerRef(self)
+ self.createLock()
+
+ def get_name(self):
+ return self._name
+
+ def set_name(self, name):
_acquireLock()
- try: #unlikely to raise an exception, but you never know...
- _handlers[self] = 1
- _handlerList.insert(0, self)
+ try:
+ if self._name in _handlers:
+ del _handlers[self._name]
+ self._name = name
+ if name:
+ _handlers[name] = self
finally:
_releaseLock()
- self.createLock()
+
+ name = property(get_name, set_name)
def createLock(self):
"""
@@ -634,7 +796,7 @@ class Handler(Filterer):
"""
Set the logging level of this handler.
"""
- self.level = level
+ self.level = _checkLevel(level)
def format(self, record):
"""
@@ -696,16 +858,16 @@ class Handler(Filterer):
"""
Tidy up any resources used by the handler.
- This version does removes the handler from an internal list
- of handlers which is closed when shutdown() is called. Subclasses
+ This version removes the handler from an internal map of handlers,
+ _handlers, which is used for handler lookup by name. Subclasses
should ensure that this gets called from overridden close()
methods.
"""
#get the module data lock, as we're updating a shared structure.
_acquireLock()
try: #unlikely to raise an exception, but you never know...
- del _handlers[self]
- _handlerList.remove(self)
+ if self._name and self._name in _handlers:
+ del _handlers[self._name]
finally:
_releaseLock()
@@ -724,7 +886,10 @@ class Handler(Filterer):
if raiseExceptions:
ei = sys.exc_info()
try:
- traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)
+ traceback.print_exception(ei[0], ei[1], ei[2],
+ None, sys.stderr)
+ sys.stderr.write('Logged from file %s, line %s\n' % (
+ record.filename, record.lineno))
except IOError:
pass # see issue 5971
finally:
@@ -737,6 +902,8 @@ class StreamHandler(Handler):
sys.stdout or sys.stderr may be used.
"""
+ terminator = '\n'
+
def __init__(self, stream=None):
"""
Initialize the handler.
@@ -769,28 +936,8 @@ class StreamHandler(Handler):
try:
msg = self.format(record)
stream = self.stream
- fs = "%s\n"
- if not _unicode: #if no unicode support...
- stream.write(fs % msg)
- else:
- try:
- if (isinstance(msg, unicode) and
- getattr(stream, 'encoding', None)):
- fs = fs.decode(stream.encoding)
- try:
- stream.write(fs % msg)
- except UnicodeEncodeError:
- #Printing to terminals sometimes fails. For example,
- #with an encoding of 'cp1251', the above write will
- #work if written to a stream opened or wrapped by
- #the codecs module, but fail when writing to a
- #terminal even when the codepage is set to cp1251.
- #An extra encoding step seems to be needed.
- stream.write((fs % msg).encode(stream.encoding))
- else:
- stream.write(fs % msg)
- except UnicodeError:
- stream.write(fs % msg.encode("UTF-8"))
+ stream.write(msg)
+ stream.write(self.terminator)
self.flush()
except (KeyboardInterrupt, SystemExit):
raise
@@ -853,11 +1000,31 @@ class FileHandler(StreamHandler):
self.stream = self._open()
StreamHandler.emit(self, record)
+class _StderrHandler(StreamHandler):
+ """
+ This class is like a StreamHandler using sys.stderr, but always uses
+ whatever sys.stderr is currently set to rather than the value of
+ sys.stderr at handler construction time.
+ """
+ def __init__(self, level=NOTSET):
+ """
+ Initialize the handler.
+ """
+ Handler.__init__(self, level)
+
+ @property
+ def stream(self):
+ return sys.stderr
+
+
+_defaultLastResort = _StderrHandler(WARNING)
+lastResort = _defaultLastResort
+
#---------------------------------------------------------------------------
# Manager classes and functions
#---------------------------------------------------------------------------
-class PlaceHolder:
+class PlaceHolder(object):
"""
PlaceHolder instances are used in the Manager logger hierarchy to take
the place of nodes for which no loggers have been defined. This class is
@@ -867,16 +1034,13 @@ class PlaceHolder:
"""
Initialize with the specified logger being a child of this placeholder.
"""
- #self.loggers = [alogger]
self.loggerMap = { alogger : None }
def append(self, alogger):
"""
Add the specified logger as a child of this placeholder.
"""
- #if alogger not in self.loggers:
if alogger not in self.loggerMap:
- #self.loggers.append(alogger)
self.loggerMap[alogger] = None
#
@@ -904,7 +1068,7 @@ def getLoggerClass():
return _loggerClass
-class Manager:
+class Manager(object):
"""
There is [under normal circumstances] just one Manager instance, which
holds the hierarchy of loggers.
@@ -915,8 +1079,10 @@ class Manager:
"""
self.root = rootnode
self.disable = 0
- self.emittedNoHandlerWarning = 0
+ self.emittedNoHandlerWarning = False
self.loggerDict = {}
+ self.loggerClass = None
+ self.logRecordFactory = None
def getLogger(self, name):
"""
@@ -936,13 +1102,13 @@ class Manager:
rv = self.loggerDict[name]
if isinstance(rv, PlaceHolder):
ph = rv
- rv = _loggerClass(name)
+ rv = (self.loggerClass or _loggerClass)(name)
rv.manager = self
self.loggerDict[name] = rv
self._fixupChildren(ph, rv)
self._fixupParents(rv)
else:
- rv = _loggerClass(name)
+ rv = (self.loggerClass or _loggerClass)(name)
rv.manager = self
self.loggerDict[name] = rv
self._fixupParents(rv)
@@ -950,6 +1116,23 @@ class Manager:
_releaseLock()
return rv
+ def setLoggerClass(self, klass):
+ """
+ Set the class to be used when instantiating a logger with this Manager.
+ """
+ if klass != Logger:
+ if not issubclass(klass, Logger):
+ raise TypeError("logger not derived from logging.Logger: "
+ + klass.__name__)
+ self.loggerClass = klass
+
+ def setLogRecordFactory(self, factory):
+ """
+ Set the factory to be used when instantiating a log record with this
+ Manager.
+ """
+ self.logRecordFactory = factory
+
def _fixupParents(self, alogger):
"""
Ensure that there are either loggers or placeholders all the way
@@ -1012,7 +1195,7 @@ class Logger(Filterer):
"""
Filterer.__init__(self)
self.name = name
- self.level = level
+ self.level = _checkLevel(level)
self.parent = None
self.propagate = 1
self.handlers = []
@@ -1022,7 +1205,7 @@ class Logger(Filterer):
"""
Set the logging level of this logger.
"""
- self.level = level
+ self.level = _checkLevel(level)
def debug(self, msg, *args, **kwargs):
"""
@@ -1074,11 +1257,12 @@ class Logger(Filterer):
if self.isEnabledFor(ERROR):
self._log(ERROR, msg, args, **kwargs)
- def exception(self, msg, *args):
+ def exception(self, msg, *args, **kwargs):
"""
Convenience method for logging an ERROR with exception information.
"""
- self.error(msg, exc_info=1, *args)
+ kwargs['exc_info'] = True
+ self.error(msg, *args, **kwargs)
def critical(self, msg, *args, **kwargs):
"""
@@ -1111,7 +1295,7 @@ class Logger(Filterer):
if self.isEnabledFor(level):
self._log(level, msg, args, **kwargs)
- def findCaller(self):
+ def findCaller(self, stack_info=False):
"""
Find the stack frame of the caller so that we can note the source
file name, line number and function name.
@@ -1121,23 +1305,34 @@ class Logger(Filterer):
#IronPython isn't run with -X:Frames.
if f is not None:
f = f.f_back
- rv = "(unknown file)", 0, "(unknown function)"
+ rv = "(unknown file)", 0, "(unknown function)", None
while hasattr(f, "f_code"):
co = f.f_code
filename = os.path.normcase(co.co_filename)
if filename == _srcfile:
f = f.f_back
continue
- rv = (filename, f.f_lineno, co.co_name)
+ sinfo = None
+ if stack_info:
+ sio = io.StringIO()
+ sio.write('Stack (most recent call last):\n')
+ traceback.print_stack(f, file=sio)
+ sinfo = sio.getvalue()
+ if sinfo[-1] == '\n':
+ sinfo = sinfo[:-1]
+ sio.close()
+ rv = (co.co_filename, f.f_lineno, co.co_name, sinfo)
break
return rv
- def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):
+ def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
+ func=None, extra=None, sinfo=None):
"""
A factory method which can be overridden in subclasses to create
specialized LogRecords.
"""
- rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
+ rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
+ sinfo)
if extra is not None:
for key in extra:
if (key in ["message", "asctime"]) or (key in rv.__dict__):
@@ -1145,17 +1340,18 @@ class Logger(Filterer):
rv.__dict__[key] = extra[key]
return rv
- def _log(self, level, msg, args, exc_info=None, extra=None):
+ def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False):
"""
Low-level logging routine which creates a LogRecord and then calls
all the handlers of this logger to handle the record.
"""
+ sinfo = None
if _srcfile:
#IronPython doesn't track Python frames, so findCaller throws an
#exception on some versions of IronPython. We trap it here so that
#IronPython can use logging.
try:
- fn, lno, func = self.findCaller()
+ fn, lno, func, sinfo = self.findCaller(stack_info)
except ValueError:
fn, lno, func = "(unknown file)", 0, "(unknown function)"
else:
@@ -1163,7 +1359,8 @@ class Logger(Filterer):
if exc_info:
if not isinstance(exc_info, tuple):
exc_info = sys.exc_info()
- record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
+ record = self.makeRecord(self.name, level, fn, lno, msg, args,
+ exc_info, func, extra, sinfo)
self.handle(record)
def handle(self, record):
@@ -1198,6 +1395,28 @@ class Logger(Filterer):
finally:
_releaseLock()
+ def hasHandlers(self):
+ """
+ See if this logger has any handlers configured.
+
+ Loop through all handlers for this logger and its parents in the
+ logger hierarchy. Return True if a handler was found, else False.
+ Stop searching up the hierarchy whenever a logger with the "propagate"
+ attribute set to zero is found - that will be the last logger which
+ is checked for the existence of handlers.
+ """
+ c = self
+ rv = False
+ while c:
+ if c.handlers:
+ rv = True
+ break
+ if not c.propagate:
+ break
+ else:
+ c = c.parent
+ return rv
+
def callHandlers(self, record):
"""
Pass a record to all relevant handlers.
@@ -1219,10 +1438,13 @@ class Logger(Filterer):
c = None #break out
else:
c = c.parent
- if (found == 0) and raiseExceptions and not self.manager.emittedNoHandlerWarning:
- sys.stderr.write("No handlers could be found for logger"
- " \"%s\"\n" % self.name)
- self.manager.emittedNoHandlerWarning = 1
+ if (found == 0):
+ if lastResort:
+ lastResort.handle(record)
+ elif raiseExceptions and not self.manager.emittedNoHandlerWarning:
+ sys.stderr.write("No handlers could be found for logger"
+ " \"%s\"\n" % self.name)
+ self.manager.emittedNoHandlerWarning = True
def getEffectiveLevel(self):
"""
@@ -1246,6 +1468,25 @@ class Logger(Filterer):
return 0
return level >= self.getEffectiveLevel()
+ def getChild(self, suffix):
+ """
+ Get a logger which is a descendant to this one.
+
+ This is a convenience method, such that
+
+ logging.getLogger('abc').getChild('def.ghi')
+
+ is the same as
+
+ logging.getLogger('abc.def.ghi')
+
+ It's useful, for example, when the parent logger is named using
+ __name__ rather than a literal string.
+ """
+ if self.root is not self:
+ suffix = '.'.join((self.name, suffix))
+ return self.manager.getLogger(suffix)
+
class RootLogger(Logger):
"""
A root logger is not that different to any other logger, except that
@@ -1260,7 +1501,7 @@ class RootLogger(Logger):
_loggerClass = Logger
-class LoggerAdapter:
+class LoggerAdapter(object):
"""
An adapter for loggers which makes it easier to specify contextual
information in logging output.
@@ -1293,62 +1534,82 @@ class LoggerAdapter:
kwargs["extra"] = self.extra
return msg, kwargs
+ #
+ # Boilerplate convenience methods
+ #
def debug(self, msg, *args, **kwargs):
"""
- Delegate a debug call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate a debug call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.debug(msg, *args, **kwargs)
+ self.log(DEBUG, msg, *args, **kwargs)
def info(self, msg, *args, **kwargs):
"""
- Delegate an info call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate an info call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.info(msg, *args, **kwargs)
+ self.log(INFO, msg, *args, **kwargs)
def warning(self, msg, *args, **kwargs):
"""
- Delegate a warning call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate a warning call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.warning(msg, *args, **kwargs)
+ self.log(WARNING, msg, *args, **kwargs)
+
+ warn = warning
def error(self, msg, *args, **kwargs):
"""
- Delegate an error call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate an error call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.error(msg, *args, **kwargs)
+ self.log(ERROR, msg, *args, **kwargs)
def exception(self, msg, *args, **kwargs):
"""
- Delegate an exception call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate an exception call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
kwargs["exc_info"] = 1
- self.logger.error(msg, *args, **kwargs)
+ self.log(ERROR, msg, *args, **kwargs)
def critical(self, msg, *args, **kwargs):
"""
- Delegate a critical call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate a critical call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.critical(msg, *args, **kwargs)
+ self.log(CRITICAL, msg, *args, **kwargs)
def log(self, level, msg, *args, **kwargs):
"""
Delegate a log call to the underlying logger, after adding
contextual information from this adapter instance.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.log(level, msg, *args, **kwargs)
+ if self.isEnabledFor(level):
+ msg, kwargs = self.process(msg, kwargs)
+ self.logger._log(level, msg, args, **kwargs)
+
+ def isEnabledFor(self, level):
+ """
+ Is this logger enabled for level 'level'?
+ """
+ if self.logger.manager.disable >= level:
+ return False
+ return level >= self.getEffectiveLevel()
+
+ def setLevel(self, level):
+ """
+ Set the specified level on the underlying logger.
+ """
+ self.logger.setLevel(level)
+
+ def getEffectiveLevel(self):
+ """
+ Get the effective level for the underlying logger.
+ """
+ return self.logger.getEffectiveLevel()
+
+ def hasHandlers(self):
+ """
+ See if the underlying logger has any handlers.
+ """
+ return self.logger.hasHandlers()
root = RootLogger(WARNING)
Logger.root = root
@@ -1381,6 +1642,10 @@ def basicConfig(**kwargs):
(if filemode is unspecified, it defaults to 'a').
format Use the specified format string for the handler.
datefmt Use the specified date/time format.
+ style If a format string is specified, use this to specify the
+ type of format string (possible values '%', '{', '$', for
+ %-formatting, :meth:`str.format` and :class:`string.Template`
+ - defaults to '%').
level Set the root logger level to the specified level.
stream Use the specified stream to initialize the StreamHandler. Note
that this argument is incompatible with 'filename' - if both
@@ -1391,6 +1656,9 @@ def basicConfig(**kwargs):
remembered that StreamHandler does not close its stream (since it may be
using sys.stdout or sys.stderr), whereas FileHandler closes its stream
when the handler is closed.
+
+ .. versionchanged: 3.2
+ Added the ``style`` parameter.
"""
# Add thread safety in case someone mistakenly calls
# basicConfig() from multiple threads
@@ -1406,7 +1674,8 @@ def basicConfig(**kwargs):
hdlr = StreamHandler(stream)
fs = kwargs.get("format", BASIC_FORMAT)
dfs = kwargs.get("datefmt", None)
- fmt = Formatter(fs, dfs)
+ style = kwargs.get("style", '%')
+ fmt = Formatter(fs, dfs, style)
hdlr.setFormatter(fmt)
root.addHandler(hdlr)
level = kwargs.get("level")
@@ -1433,7 +1702,9 @@ def getLogger(name=None):
def critical(msg, *args, **kwargs):
"""
- Log a message with severity 'CRITICAL' on the root logger.
+ Log a message with severity 'CRITICAL' on the root logger. If the logger
+ has no handlers, call basicConfig() to add a console handler with a
+ pre-defined format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1443,22 +1714,28 @@ fatal = critical
def error(msg, *args, **kwargs):
"""
- Log a message with severity 'ERROR' on the root logger.
+ Log a message with severity 'ERROR' on the root logger. If the logger has
+ no handlers, call basicConfig() to add a console handler with a pre-defined
+ format.
"""
if len(root.handlers) == 0:
basicConfig()
root.error(msg, *args, **kwargs)
-def exception(msg, *args):
+def exception(msg, *args, **kwargs):
"""
- Log a message with severity 'ERROR' on the root logger,
- with exception information.
+ Log a message with severity 'ERROR' on the root logger, with exception
+ information. If the logger has no handlers, basicConfig() is called to add
+ a console handler with a pre-defined format.
"""
- error(msg, exc_info=1, *args)
+ kwargs['exc_info'] = True
+ error(msg, *args, **kwargs)
def warning(msg, *args, **kwargs):
"""
- Log a message with severity 'WARNING' on the root logger.
+ Log a message with severity 'WARNING' on the root logger. If the logger has
+ no handlers, call basicConfig() to add a console handler with a pre-defined
+ format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1468,7 +1745,9 @@ warn = warning
def info(msg, *args, **kwargs):
"""
- Log a message with severity 'INFO' on the root logger.
+ Log a message with severity 'INFO' on the root logger. If the logger has
+ no handlers, call basicConfig() to add a console handler with a pre-defined
+ format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1476,7 +1755,9 @@ def info(msg, *args, **kwargs):
def debug(msg, *args, **kwargs):
"""
- Log a message with severity 'DEBUG' on the root logger.
+ Log a message with severity 'DEBUG' on the root logger. If the logger has
+ no handlers, call basicConfig() to add a console handler with a pre-defined
+ format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1484,7 +1765,9 @@ def debug(msg, *args, **kwargs):
def log(level, msg, *args, **kwargs):
"""
- Log 'msg % args' with the integer severity 'level' on the root logger.
+ Log 'msg % args' with the integer severity 'level' on the root logger. If
+ the logger has no handlers, call basicConfig() to add a console handler
+ with a pre-defined format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1492,7 +1775,7 @@ def log(level, msg, *args, **kwargs):
def disable(level):
"""
- Disable all logging calls less severe than 'level'.
+ Disable all logging calls of severity 'level' and below.
"""
root.manager.disable = level
@@ -1503,32 +1786,32 @@ def shutdown(handlerList=_handlerList):
Should be called at application exit.
"""
- for h in handlerList[:]:
+ for wr in reversed(handlerList[:]):
#errors might occur, for example, if files are locked
#we just ignore them if raiseExceptions is not set
try:
- h.acquire()
- h.flush()
- h.close()
+ h = wr()
+ if h:
+ try:
+ h.acquire()
+ h.flush()
+ h.close()
+ except (IOError, ValueError):
+ # Ignore errors which might be caused
+ # because handlers have been closed but
+ # references to them are still around at
+ # application exit.
+ pass
+ finally:
+ h.release()
except:
if raiseExceptions:
raise
#else, swallow
- finally:
- h.release()
#Let's try and shutdown automatically on application exit...
-try:
- import atexit
- atexit.register(shutdown)
-except ImportError: # for Python versions < 2.0
- def exithook(status, old_exit=sys.exit):
- try:
- shutdown()
- finally:
- old_exit(status)
-
- sys.exit = exithook
+import atexit
+atexit.register(shutdown)
# Null handler
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index 25f34ecd24..c7359cabe9 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
@@ -24,7 +24,8 @@ Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
-import sys, logging, logging.handlers, socket, struct, os, traceback
+import sys, logging, logging.handlers, socket, struct, os, traceback, re
+import types, io
try:
import _thread as thread
@@ -57,16 +58,12 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True):
the ability to select from various pre-canned configurations (if the
developer provides a mechanism to present the choices and load the chosen
configuration).
- In versions of ConfigParser which have the readfp method [typically
- shipped in 2.x versions of Python], you can pass in a file-like object
- rather than a filename, in which case the file-like object will be read
- using readfp.
"""
import configparser
cp = configparser.ConfigParser(defaults)
- if hasattr(cp, 'readfp') and hasattr(fname, 'readline'):
- cp.readfp(fname)
+ if hasattr(fname, 'readline'):
+ cp.read_file(fname)
else:
cp.read(fname)
@@ -101,9 +98,12 @@ def _resolve(name):
def _strip_spaces(alist):
return map(lambda x: x.strip(), alist)
+def _encoded(s):
+ return s if isinstance(s, str) else s.encode('utf-8')
+
def _create_formatters(cp):
"""Create and return formatters"""
- flist = cp.get("formatters", "keys")
+ flist = cp["formatters"]["keys"]
if not len(flist):
return {}
flist = flist.split(",")
@@ -111,20 +111,12 @@ def _create_formatters(cp):
formatters = {}
for form in flist:
sectname = "formatter_%s" % form
- opts = cp.options(sectname)
- if "format" in opts:
- fs = cp.get(sectname, "format", 1)
- else:
- fs = None
- if "datefmt" in opts:
- dfs = cp.get(sectname, "datefmt", 1)
- else:
- dfs = None
+ fs = cp.get(sectname, "format", raw=True, fallback=None)
+ dfs = cp.get(sectname, "datefmt", raw=True, fallback=None)
c = logging.Formatter
- if "class" in opts:
- class_name = cp.get(sectname, "class")
- if class_name:
- c = _resolve(class_name)
+ class_name = cp[sectname].get("class")
+ if class_name:
+ c = _resolve(class_name)
f = c(fs, dfs)
formatters[form] = f
return formatters
@@ -132,7 +124,7 @@ def _create_formatters(cp):
def _install_handlers(cp, formatters):
"""Install and return handlers"""
- hlist = cp.get("handlers", "keys")
+ hlist = cp["handlers"]["keys"]
if not len(hlist):
return {}
hlist = hlist.split(",")
@@ -140,30 +132,23 @@ def _install_handlers(cp, formatters):
handlers = {}
fixups = [] #for inter-handler references
for hand in hlist:
- sectname = "handler_%s" % hand
- klass = cp.get(sectname, "class")
- opts = cp.options(sectname)
- if "formatter" in opts:
- fmt = cp.get(sectname, "formatter")
- else:
- fmt = ""
+ section = cp["handler_%s" % hand]
+ klass = section["class"]
+ fmt = section.get("formatter", "")
try:
klass = eval(klass, vars(logging))
except (AttributeError, NameError):
klass = _resolve(klass)
- args = cp.get(sectname, "args")
+ args = section["args"]
args = eval(args, vars(logging))
h = klass(*args)
- if "level" in opts:
- level = cp.get(sectname, "level")
+ if "level" in section:
+ level = section["level"]
h.setLevel(logging._levelNames[level])
if len(fmt):
h.setFormatter(formatters[fmt])
if issubclass(klass, logging.handlers.MemoryHandler):
- if "target" in opts:
- target = cp.get(sectname,"target")
- else:
- target = ""
+ target = section.get("target", "")
if len(target): #the target handler may not be loaded yet, so keep for later...
fixups.append((h, target))
handlers[hand] = h
@@ -172,25 +157,44 @@ def _install_handlers(cp, formatters):
h.setTarget(handlers[t])
return handlers
+def _handle_existing_loggers(existing, child_loggers, disable_existing):
+ """
+ When (re)configuring logging, handle loggers which were in the previous
+ configuration but are not in the new configuration. There's no point
+ deleting them as other threads may continue to hold references to them;
+ and by disabling them, you stop them doing any logging.
+
+ However, don't disable children of named loggers, as that's probably not
+ what was intended by the user. Also, allow existing loggers to NOT be
+ disabled if disable_existing is false.
+ """
+ root = logging.root
+ for log in existing:
+ logger = root.manager.loggerDict[log]
+ if log in child_loggers:
+ logger.level = logging.NOTSET
+ logger.handlers = []
+ logger.propagate = True
+ elif disable_existing:
+ logger.disabled = True
-def _install_loggers(cp, handlers, disable_existing_loggers):
+def _install_loggers(cp, handlers, disable_existing):
"""Create and install loggers"""
# configure the root first
- llist = cp.get("loggers", "keys")
+ llist = cp["loggers"]["keys"]
llist = llist.split(",")
llist = list(map(lambda x: x.strip(), llist))
llist.remove("root")
- sectname = "logger_root"
+ section = cp["logger_root"]
root = logging.root
log = root
- opts = cp.options(sectname)
- if "level" in opts:
- level = cp.get(sectname, "level")
+ if "level" in section:
+ level = section["level"]
log.setLevel(logging._levelNames[level])
for h in root.handlers[:]:
root.removeHandler(h)
- hlist = cp.get(sectname, "handlers")
+ hlist = section["handlers"]
if len(hlist):
hlist = hlist.split(",")
hlist = _strip_spaces(hlist)
@@ -211,19 +215,15 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
#avoid disabling child loggers of explicitly
#named loggers. With a sorted list it is easier
#to find the child loggers.
- existing.sort()
+ existing.sort(key=_encoded)
#We'll keep the list of existing loggers
#which are children of named loggers here...
child_loggers = []
#now set up the new ones...
for log in llist:
- sectname = "logger_%s" % log
- qn = cp.get(sectname, "qualname")
- opts = cp.options(sectname)
- if "propagate" in opts:
- propagate = cp.getint(sectname, "propagate")
- else:
- propagate = 1
+ section = cp["logger_%s" % log]
+ qn = section["qualname"]
+ propagate = section.getint("propagate", fallback=1)
logger = logging.getLogger(qn)
if qn in existing:
i = existing.index(qn) + 1 # start with the entry after qn
@@ -235,14 +235,14 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
child_loggers.append(existing[i])
i += 1
existing.remove(qn)
- if "level" in opts:
- level = cp.get(sectname, "level")
+ if "level" in section:
+ level = section["level"]
logger.setLevel(logging._levelNames[level])
for h in logger.handlers[:]:
logger.removeHandler(h)
logger.propagate = propagate
logger.disabled = 0
- hlist = cp.get(sectname, "handlers")
+ hlist = section["handlers"]
if len(hlist):
hlist = hlist.split(",")
hlist = _strip_spaces(hlist)
@@ -254,14 +254,526 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
#and by disabling them, you stop them doing any logging.
#However, don't disable children of named loggers, as that's
#probably not what was intended by the user.
- for log in existing:
- logger = root.manager.loggerDict[log]
- if log in child_loggers:
- logger.level = logging.NOTSET
- logger.handlers = []
- logger.propagate = 1
- elif disable_existing_loggers:
- logger.disabled = 1
+ #for log in existing:
+ # logger = root.manager.loggerDict[log]
+ # if log in child_loggers:
+ # logger.level = logging.NOTSET
+ # logger.handlers = []
+ # logger.propagate = 1
+ # elif disable_existing_loggers:
+ # logger.disabled = 1
+ _handle_existing_loggers(existing, child_loggers, disable_existing)
+
+IDENTIFIER = re.compile('^[a-z_][a-z0-9_]*$', re.I)
+
+
+def valid_ident(s):
+ m = IDENTIFIER.match(s)
+ if not m:
+ raise ValueError('Not a valid Python identifier: %r' % s)
+ return True
+
+
+# The ConvertingXXX classes are wrappers around standard Python containers,
+# and they serve to convert any suitable values in the container. The
+# conversion converts base dicts, lists and tuples to their wrapped
+# equivalents, whereas strings which match a conversion format are converted
+# appropriately.
+#
+# Each wrapper should have a configurator attribute holding the actual
+# configurator to use for conversion.
+
+class ConvertingDict(dict):
+ """A converting dictionary wrapper."""
+
+ def __getitem__(self, key):
+ value = dict.__getitem__(self, key)
+ result = self.configurator.convert(value)
+ #If the converted value is different, save for next time
+ if value is not result:
+ self[key] = result
+ if type(result) in (ConvertingDict, ConvertingList,
+ ConvertingTuple):
+ result.parent = self
+ result.key = key
+ return result
+
+ def get(self, key, default=None):
+ value = dict.get(self, key, default)
+ result = self.configurator.convert(value)
+ #If the converted value is different, save for next time
+ if value is not result:
+ self[key] = result
+ if type(result) in (ConvertingDict, ConvertingList,
+ ConvertingTuple):
+ result.parent = self
+ result.key = key
+ return result
+
+ def pop(self, key, default=None):
+ value = dict.pop(self, key, default)
+ result = self.configurator.convert(value)
+ if value is not result:
+ if type(result) in (ConvertingDict, ConvertingList,
+ ConvertingTuple):
+ result.parent = self
+ result.key = key
+ return result
+
+class ConvertingList(list):
+ """A converting list wrapper."""
+ def __getitem__(self, key):
+ value = list.__getitem__(self, key)
+ result = self.configurator.convert(value)
+ #If the converted value is different, save for next time
+ if value is not result:
+ self[key] = result
+ if type(result) in (ConvertingDict, ConvertingList,
+ ConvertingTuple):
+ result.parent = self
+ result.key = key
+ return result
+
+ def pop(self, idx=-1):
+ value = list.pop(self, idx)
+ result = self.configurator.convert(value)
+ if value is not result:
+ if type(result) in (ConvertingDict, ConvertingList,
+ ConvertingTuple):
+ result.parent = self
+ return result
+
+class ConvertingTuple(tuple):
+ """A converting tuple wrapper."""
+ def __getitem__(self, key):
+ value = tuple.__getitem__(self, key)
+ result = self.configurator.convert(value)
+ if value is not result:
+ if type(result) in (ConvertingDict, ConvertingList,
+ ConvertingTuple):
+ result.parent = self
+ result.key = key
+ return result
+
+class BaseConfigurator(object):
+ """
+ The configurator base class which defines some useful defaults.
+ """
+
+ CONVERT_PATTERN = re.compile(r'^(?P<prefix>[a-z]+)://(?P<suffix>.*)$')
+
+ WORD_PATTERN = re.compile(r'^\s*(\w+)\s*')
+ DOT_PATTERN = re.compile(r'^\.\s*(\w+)\s*')
+ INDEX_PATTERN = re.compile(r'^\[\s*(\w+)\s*\]\s*')
+ DIGIT_PATTERN = re.compile(r'^\d+$')
+
+ value_converters = {
+ 'ext' : 'ext_convert',
+ 'cfg' : 'cfg_convert',
+ }
+
+ # We might want to use a different one, e.g. importlib
+ importer = staticmethod(__import__)
+
+ def __init__(self, config):
+ self.config = ConvertingDict(config)
+ self.config.configurator = self
+
+ def resolve(self, s):
+ """
+ Resolve strings to objects using standard import and attribute
+ syntax.
+ """
+ name = s.split('.')
+ used = name.pop(0)
+ try:
+ found = self.importer(used)
+ for frag in name:
+ used += '.' + frag
+ try:
+ found = getattr(found, frag)
+ except AttributeError:
+ self.importer(used)
+ found = getattr(found, frag)
+ return found
+ except ImportError:
+ e, tb = sys.exc_info()[1:]
+ v = ValueError('Cannot resolve %r: %s' % (s, e))
+ v.__cause__, v.__traceback__ = e, tb
+ raise v
+
+ def ext_convert(self, value):
+ """Default converter for the ext:// protocol."""
+ return self.resolve(value)
+
+ def cfg_convert(self, value):
+ """Default converter for the cfg:// protocol."""
+ rest = value
+ m = self.WORD_PATTERN.match(rest)
+ if m is None:
+ raise ValueError("Unable to convert %r" % value)
+ else:
+ rest = rest[m.end():]
+ d = self.config[m.groups()[0]]
+ #print d, rest
+ while rest:
+ m = self.DOT_PATTERN.match(rest)
+ if m:
+ d = d[m.groups()[0]]
+ else:
+ m = self.INDEX_PATTERN.match(rest)
+ if m:
+ idx = m.groups()[0]
+ if not self.DIGIT_PATTERN.match(idx):
+ d = d[idx]
+ else:
+ try:
+ n = int(idx) # try as number first (most likely)
+ d = d[n]
+ except TypeError:
+ d = d[idx]
+ if m:
+ rest = rest[m.end():]
+ else:
+ raise ValueError('Unable to convert '
+ '%r at %r' % (value, rest))
+ #rest should be empty
+ return d
+
+ def convert(self, value):
+ """
+ Convert values to an appropriate type. dicts, lists and tuples are
+ replaced by their converting alternatives. Strings are checked to
+ see if they have a conversion format and are converted if they do.
+ """
+ if not isinstance(value, ConvertingDict) and isinstance(value, dict):
+ value = ConvertingDict(value)
+ value.configurator = self
+ elif not isinstance(value, ConvertingList) and isinstance(value, list):
+ value = ConvertingList(value)
+ value.configurator = self
+ elif not isinstance(value, ConvertingTuple) and\
+ isinstance(value, tuple):
+ value = ConvertingTuple(value)
+ value.configurator = self
+ elif isinstance(value, str): # str for py3k
+ m = self.CONVERT_PATTERN.match(value)
+ if m:
+ d = m.groupdict()
+ prefix = d['prefix']
+ converter = self.value_converters.get(prefix, None)
+ if converter:
+ suffix = d['suffix']
+ converter = getattr(self, converter)
+ value = converter(suffix)
+ return value
+
+ def configure_custom(self, config):
+ """Configure an object with a user-supplied factory."""
+ c = config.pop('()')
+ if not hasattr(c, '__call__'):
+ c = self.resolve(c)
+ props = config.pop('.', None)
+ # Check for valid identifiers
+ kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
+ result = c(**kwargs)
+ if props:
+ for name, value in props.items():
+ setattr(result, name, value)
+ return result
+
+ def as_tuple(self, value):
+ """Utility function which converts lists to tuples."""
+ if isinstance(value, list):
+ value = tuple(value)
+ return value
+
+class DictConfigurator(BaseConfigurator):
+ """
+ Configure logging using a dictionary-like object to describe the
+ configuration.
+ """
+
+ def configure(self):
+ """Do the configuration."""
+
+ config = self.config
+ if 'version' not in config:
+ raise ValueError("dictionary doesn't specify a version")
+ if config['version'] != 1:
+ raise ValueError("Unsupported version: %s" % config['version'])
+ incremental = config.pop('incremental', False)
+ EMPTY_DICT = {}
+ logging._acquireLock()
+ try:
+ if incremental:
+ handlers = config.get('handlers', EMPTY_DICT)
+ for name in handlers:
+ if name not in logging._handlers:
+ raise ValueError('No handler found with '
+ 'name %r' % name)
+ else:
+ try:
+ handler = logging._handlers[name]
+ handler_config = handlers[name]
+ level = handler_config.get('level', None)
+ if level:
+ handler.setLevel(logging._checkLevel(level))
+ except Exception as e:
+ raise ValueError('Unable to configure handler '
+ '%r: %s' % (name, e))
+ loggers = config.get('loggers', EMPTY_DICT)
+ for name in loggers:
+ try:
+ self.configure_logger(name, loggers[name], True)
+ except Exception as e:
+ raise ValueError('Unable to configure logger '
+ '%r: %s' % (name, e))
+ root = config.get('root', None)
+ if root:
+ try:
+ self.configure_root(root, True)
+ except Exception as e:
+ raise ValueError('Unable to configure root '
+ 'logger: %s' % e)
+ else:
+ disable_existing = config.pop('disable_existing_loggers', True)
+
+ logging._handlers.clear()
+ del logging._handlerList[:]
+
+ # Do formatters first - they don't refer to anything else
+ formatters = config.get('formatters', EMPTY_DICT)
+ for name in formatters:
+ try:
+ formatters[name] = self.configure_formatter(
+ formatters[name])
+ except Exception as e:
+ raise ValueError('Unable to configure '
+ 'formatter %r: %s' % (name, e))
+ # Next, do filters - they don't refer to anything else, either
+ filters = config.get('filters', EMPTY_DICT)
+ for name in filters:
+ try:
+ filters[name] = self.configure_filter(filters[name])
+ except Exception as e:
+ raise ValueError('Unable to configure '
+ 'filter %r: %s' % (name, e))
+
+ # Next, do handlers - they refer to formatters and filters
+ # As handlers can refer to other handlers, sort the keys
+ # to allow a deterministic order of configuration
+ handlers = config.get('handlers', EMPTY_DICT)
+ for name in sorted(handlers):
+ try:
+ handler = self.configure_handler(handlers[name])
+ handler.name = name
+ handlers[name] = handler
+ except Exception as e:
+ raise ValueError('Unable to configure handler '
+ '%r: %s' % (name, e))
+ # Next, do loggers - they refer to handlers and filters
+
+ #we don't want to lose the existing loggers,
+ #since other threads may have pointers to them.
+ #existing is set to contain all existing loggers,
+ #and as we go through the new configuration we
+ #remove any which are configured. At the end,
+ #what's left in existing is the set of loggers
+ #which were in the previous configuration but
+ #which are not in the new configuration.
+ root = logging.root
+ existing = list(root.manager.loggerDict.keys())
+ #The list needs to be sorted so that we can
+ #avoid disabling child loggers of explicitly
+ #named loggers. With a sorted list it is easier
+ #to find the child loggers.
+ existing.sort(key=_encoded)
+ #We'll keep the list of existing loggers
+ #which are children of named loggers here...
+ child_loggers = []
+ #now set up the new ones...
+ loggers = config.get('loggers', EMPTY_DICT)
+ for name in loggers:
+ if name in existing:
+ i = existing.index(name) + 1 # look after name
+ prefixed = name + "."
+ pflen = len(prefixed)
+ num_existing = len(existing)
+ while i < num_existing:
+ if existing[i][:pflen] == prefixed:
+ child_loggers.append(existing[i])
+ i += 1
+ existing.remove(name)
+ try:
+ self.configure_logger(name, loggers[name])
+ except Exception as e:
+ raise ValueError('Unable to configure logger '
+ '%r: %s' % (name, e))
+
+ #Disable any old loggers. There's no point deleting
+ #them as other threads may continue to hold references
+ #and by disabling them, you stop them doing any logging.
+ #However, don't disable children of named loggers, as that's
+ #probably not what was intended by the user.
+ #for log in existing:
+ # logger = root.manager.loggerDict[log]
+ # if log in child_loggers:
+ # logger.level = logging.NOTSET
+ # logger.handlers = []
+ # logger.propagate = True
+ # elif disable_existing:
+ # logger.disabled = True
+ _handle_existing_loggers(existing, child_loggers,
+ disable_existing)
+
+ # And finally, do the root logger
+ root = config.get('root', None)
+ if root:
+ try:
+ self.configure_root(root)
+ except Exception as e:
+ raise ValueError('Unable to configure root '
+ 'logger: %s' % e)
+ finally:
+ logging._releaseLock()
+
+ def configure_formatter(self, config):
+ """Configure a formatter from a dictionary."""
+ if '()' in config:
+ factory = config['()'] # for use in exception handler
+ try:
+ result = self.configure_custom(config)
+ except TypeError as te:
+ if "'format'" not in str(te):
+ raise
+ #Name of parameter changed from fmt to format.
+ #Retry with old name.
+ #This is so that code can be used with older Python versions
+ #(e.g. by Django)
+ config['fmt'] = config.pop('format')
+ config['()'] = factory
+ result = self.configure_custom(config)
+ else:
+ fmt = config.get('format', None)
+ dfmt = config.get('datefmt', None)
+ result = logging.Formatter(fmt, dfmt)
+ return result
+
+ def configure_filter(self, config):
+ """Configure a filter from a dictionary."""
+ if '()' in config:
+ result = self.configure_custom(config)
+ else:
+ name = config.get('name', '')
+ result = logging.Filter(name)
+ return result
+
+ def add_filters(self, filterer, filters):
+ """Add filters to a filterer from a list of names."""
+ for f in filters:
+ try:
+ filterer.addFilter(self.config['filters'][f])
+ except Exception as e:
+ raise ValueError('Unable to add filter %r: %s' % (f, e))
+
+ def configure_handler(self, config):
+ """Configure a handler from a dictionary."""
+ formatter = config.pop('formatter', None)
+ if formatter:
+ try:
+ formatter = self.config['formatters'][formatter]
+ except Exception as e:
+ raise ValueError('Unable to set formatter '
+ '%r: %s' % (formatter, e))
+ level = config.pop('level', None)
+ filters = config.pop('filters', None)
+ if '()' in config:
+ c = config.pop('()')
+ if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType:
+ c = self.resolve(c)
+ factory = c
+ else:
+ klass = self.resolve(config.pop('class'))
+ #Special case for handler which refers to another handler
+ if issubclass(klass, logging.handlers.MemoryHandler) and\
+ 'target' in config:
+ try:
+ config['target'] = self.config['handlers'][config['target']]
+ except Exception as e:
+ raise ValueError('Unable to set target handler '
+ '%r: %s' % (config['target'], e))
+ elif issubclass(klass, logging.handlers.SMTPHandler) and\
+ 'mailhost' in config:
+ config['mailhost'] = self.as_tuple(config['mailhost'])
+ elif issubclass(klass, logging.handlers.SysLogHandler) and\
+ 'address' in config:
+ config['address'] = self.as_tuple(config['address'])
+ factory = klass
+ kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
+ try:
+ result = factory(**kwargs)
+ except TypeError as te:
+ if "'stream'" not in str(te):
+ raise
+ #The argument name changed from strm to stream
+ #Retry with old name.
+ #This is so that code can be used with older Python versions
+ #(e.g. by Django)
+ kwargs['strm'] = kwargs.pop('stream')
+ result = factory(**kwargs)
+ if formatter:
+ result.setFormatter(formatter)
+ if level is not None:
+ result.setLevel(logging._checkLevel(level))
+ if filters:
+ self.add_filters(result, filters)
+ return result
+
+ def add_handlers(self, logger, handlers):
+ """Add handlers to a logger from a list of names."""
+ for h in handlers:
+ try:
+ logger.addHandler(self.config['handlers'][h])
+ except Exception as e:
+ raise ValueError('Unable to add handler %r: %s' % (h, e))
+
+ def common_logger_config(self, logger, config, incremental=False):
+ """
+ Perform configuration which is common to root and non-root loggers.
+ """
+ level = config.get('level', None)
+ if level is not None:
+ logger.setLevel(logging._checkLevel(level))
+ if not incremental:
+ #Remove any existing handlers
+ for h in logger.handlers[:]:
+ logger.removeHandler(h)
+ handlers = config.get('handlers', None)
+ if handlers:
+ self.add_handlers(logger, handlers)
+ filters = config.get('filters', None)
+ if filters:
+ self.add_filters(logger, filters)
+
+ def configure_logger(self, name, config, incremental=False):
+ """Configure a non-root logger from a dictionary."""
+ logger = logging.getLogger(name)
+ self.common_logger_config(logger, config, incremental)
+ propagate = config.get('propagate', None)
+ if propagate is not None:
+ logger.propagate = propagate
+
+ def configure_root(self, config, incremental=False):
+ """Configure a root logger from a dictionary."""
+ root = logging.getLogger()
+ self.common_logger_config(root, config, incremental)
+
+dictConfigClass = DictConfigurator
+
+def dictConfig(config):
+ """Configure logging using a dictionary."""
+ dictConfigClass(config).configure()
def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
@@ -301,24 +813,26 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
chunk = self.connection.recv(slen)
while len(chunk) < slen:
chunk = chunk + conn.recv(slen - len(chunk))
- #Apply new configuration. We'd like to be able to
- #create a StringIO and pass that in, but unfortunately
- #1.5.2 ConfigParser does not support reading file
- #objects, only actual files. So we create a temporary
- #file and remove it later.
- file = tempfile.mktemp(".ini")
- f = open(file, "w")
- f.write(chunk)
- f.close()
+ chunk = chunk.decode("utf-8")
try:
- fileConfig(file)
- except (KeyboardInterrupt, SystemExit):
- raise
+ import json
+ d =json.loads(chunk)
+ assert isinstance(d, dict)
+ dictConfig(d)
except:
- traceback.print_exc()
- os.remove(file)
+ #Apply new configuration.
+
+ file = io.StringIO(chunk)
+ try:
+ fileConfig(file)
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except:
+ traceback.print_exc()
+ if self.server.ready:
+ self.server.ready.set()
except socket.error as e:
- if not isinstancetype(e.args, tuple):
+ if not isinstance(e.args, tuple):
raise
else:
errcode = e.args[0]
@@ -333,12 +847,13 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
allow_reuse_address = 1
def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
- handler=None):
+ handler=None, ready=None):
ThreadingTCPServer.__init__(self, (host, port), handler)
logging._acquireLock()
self.abort = 0
logging._releaseLock()
self.timeout = 1
+ self.ready = ready
def serve_until_stopped(self):
import select
@@ -354,17 +869,28 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
logging._releaseLock()
self.socket.close()
- def serve(rcvr, hdlr, port):
- server = rcvr(port=port, handler=hdlr)
- global _listener
- logging._acquireLock()
- _listener = server
- logging._releaseLock()
- server.serve_until_stopped()
+ class Server(threading.Thread):
+
+ def __init__(self, rcvr, hdlr, port):
+ super(Server, self).__init__()
+ self.rcvr = rcvr
+ self.hdlr = hdlr
+ self.port = port
+ self.ready = threading.Event()
+
+ def run(self):
+ server = self.rcvr(port=self.port, handler=self.hdlr,
+ ready=self.ready)
+ if self.port == 0:
+ self.port = server.server_address[1]
+ self.ready.set()
+ global _listener
+ logging._acquireLock()
+ _listener = server
+ logging._releaseLock()
+ server.serve_until_stopped()
- return threading.Thread(target=serve,
- args=(ConfigSocketReceiver,
- ConfigStreamHandler, port))
+ return Server(ConfigSocketReceiver, ConfigStreamHandler, port)
def stopListening():
"""
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index e9dac43f61..96384bd7f7 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
@@ -19,7 +19,7 @@ Additional handlers for the logging package for Python. The core package is
based on PEP 282 and comments thereto in comp.lang.python, and influenced by
Apache's log4j system.
-Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging.handlers' and log away!
"""
@@ -41,6 +41,7 @@ DEFAULT_UDP_LOGGING_PORT = 9021
DEFAULT_HTTP_LOGGING_PORT = 9022
DEFAULT_SOAP_LOGGING_PORT = 9023
SYSLOG_UDP_PORT = 514
+SYSLOG_TCP_PORT = 514
_MIDNIGHT = 24 * 60 * 60 # number of seconds in a day
@@ -102,8 +103,13 @@ class RotatingFileHandler(BaseRotatingHandler):
If maxBytes is zero, rollover never occurs.
"""
+ # If rotation/rollover is wanted, it doesn't make sense to use another
+ # mode. If for example 'w' were specified, then if there were multiple
+ # runs of the calling application, the logs from previous runs would be
+ # lost if the 'w' is respected, because the log file would be truncated
+ # on each run.
if maxBytes > 0:
- mode = 'a' # doesn't make sense otherwise!
+ mode = 'a'
BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
self.maxBytes = maxBytes
self.backupCount = backupCount
@@ -120,7 +126,6 @@ class RotatingFileHandler(BaseRotatingHandler):
sfn = "%s.%d" % (self.baseFilename, i)
dfn = "%s.%d" % (self.baseFilename, i + 1)
if os.path.exists(sfn):
- #print "%s -> %s" % (sfn, dfn)
if os.path.exists(dfn):
os.remove(dfn)
os.rename(sfn, dfn)
@@ -128,7 +133,6 @@ class RotatingFileHandler(BaseRotatingHandler):
if os.path.exists(dfn):
os.remove(dfn)
os.rename(self.baseFilename, dfn)
- #print "%s -> %s" % (self.baseFilename, dfn)
self.mode = 'w'
self.stream = self._open()
@@ -156,7 +160,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
If backupCount is > 0, when rollover is done, no more than backupCount
files are kept - the oldest ones are deleted.
"""
- def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=0, utc=False):
+ def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False):
BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay)
self.when = when.upper()
self.backupCount = backupCount
@@ -278,7 +282,6 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
t = int(time.time())
if t >= self.rolloverAt:
return 1
- #print "No need to rollover: %d, %d" % (t, self.rolloverAt)
return 0
def getFilesToDelete(self):
@@ -326,14 +329,8 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
os.remove(dfn)
os.rename(self.baseFilename, dfn)
if self.backupCount > 0:
- # find the oldest log file and delete it
- #s = glob.glob(self.baseFilename + ".20*")
- #if len(s) > self.backupCount:
- # s.sort()
- # os.remove(s[0])
for s in self.getFilesToDelete():
os.remove(s)
- #print "%s -> %s" % (self.baseFilename, dfn)
self.mode = 'w'
self.stream = self._open()
currentTime = int(time.time())
@@ -634,7 +631,8 @@ class SysLogHandler(logging.Handler):
LOG_NEWS = 7 # network news subsystem
LOG_UUCP = 8 # UUCP subsystem
LOG_CRON = 9 # clock daemon
- LOG_AUTHPRIV = 10 # security/authorization messages (private)
+ LOG_AUTHPRIV = 10 # security/authorization messages (private)
+ LOG_FTP = 11 # FTP daemon
# other codes through 15 reserved for system use
LOG_LOCAL0 = 16 # reserved for local use
@@ -666,6 +664,7 @@ class SysLogHandler(logging.Handler):
"authpriv": LOG_AUTHPRIV,
"cron": LOG_CRON,
"daemon": LOG_DAEMON,
+ "ftp": LOG_FTP,
"kern": LOG_KERN,
"lpr": LOG_LPR,
"mail": LOG_MAIL,
@@ -696,7 +695,8 @@ class SysLogHandler(logging.Handler):
"CRITICAL" : "critical"
}
- def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER):
+ def __init__(self, address=('localhost', SYSLOG_UDP_PORT),
+ facility=LOG_USER, socktype=socket.SOCK_DGRAM):
"""
Initialize a handler.
@@ -708,13 +708,16 @@ class SysLogHandler(logging.Handler):
self.address = address
self.facility = facility
+ self.socktype = socktype
+
if isinstance(address, str):
self.unixsocket = 1
self._connect_unixsocket(address)
else:
self.unixsocket = 0
- self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-
+ self.socket = socket.socket(socket.AF_INET, socktype)
+ if socktype == socket.SOCK_STREAM:
+ self.socket.connect(address)
self.formatter = None
def _connect_unixsocket(self, address):
@@ -727,12 +730,6 @@ class SysLogHandler(logging.Handler):
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.socket.connect(address)
- # curious: when talking to the unix-domain '/dev/log' socket, a
- # zero-terminator seems to be required. this string is placed
- # into a class variable so that it can be overridden if
- # necessary.
- log_format_string = '<%d>%s\000'
-
def encodePriority(self, facility, priority):
"""
Encode the facility and priority. You can pass in strings or
@@ -771,18 +768,19 @@ class SysLogHandler(logging.Handler):
The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server.
"""
- msg = self.format(record)
+ msg = self.format(record) + '\000'
"""
We need to convert record level to lowercase, maybe this will
change in the future.
"""
- msg = self.log_format_string % (
- self.encodePriority(self.facility,
- self.mapPriority(record.levelname)),
- msg)
+ prio = '<%d>' % self.encodePriority(self.facility,
+ self.mapPriority(record.levelname))
+ prio = prio.encode('utf-8')
+ # Message is a string. Convert to bytes as required by RFC 5424
msg = msg.encode('utf-8')
if codecs:
msg = codecs.BOM_UTF8 + msg
+ msg = prio + msg
try:
if self.unixsocket:
try:
@@ -790,8 +788,10 @@ class SysLogHandler(logging.Handler):
except socket.error:
self._connect_unixsocket(self.address)
self.socket.send(msg)
- else:
+ elif self.socktype == socket.SOCK_DGRAM:
self.socket.sendto(msg, self.address)
+ else:
+ self.socket.sendall(msg)
except (KeyboardInterrupt, SystemExit):
raise
except:
@@ -801,7 +801,8 @@ class SMTPHandler(logging.Handler):
"""
A handler class which sends an SMTP email for each logging event.
"""
- def __init__(self, mailhost, fromaddr, toaddrs, subject, credentials=None):
+ def __init__(self, mailhost, fromaddr, toaddrs, subject,
+ credentials=None, secure=None):
"""
Initialize the handler.
@@ -809,7 +810,12 @@ class SMTPHandler(logging.Handler):
line of the email. To specify a non-standard SMTP port, use the
(host, port) tuple format for the mailhost argument. To specify
authentication credentials, supply a (username, password) tuple
- for the credentials argument.
+ for the credentials argument. To specify the use of a secure
+ protocol (TLS), pass in a tuple for the secure argument. This will
+ only be used when authentication credentials are supplied. The tuple
+ will be either an empty tuple, or a single-value tuple with the name
+ of a keyfile, or a 2-value tuple with the names of the keyfile and
+ certificate file. (This tuple is passed to the `starttls` method).
"""
logging.Handler.__init__(self)
if isinstance(mailhost, tuple):
@@ -825,6 +831,7 @@ class SMTPHandler(logging.Handler):
toaddrs = [toaddrs]
self.toaddrs = toaddrs
self.subject = subject
+ self.secure = secure
def getSubject(self, record):
"""
@@ -835,24 +842,6 @@ class SMTPHandler(logging.Handler):
"""
return self.subject
- weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
-
- monthname = [None,
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
-
- def date_time(self):
- """
- Return the current date and time formatted for a MIME header.
- Needed for Python 1.5.2 (no email package available)
- """
- year, month, day, hh, mm, ss, wd, y, z = time.gmtime(time.time())
- s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
- self.weekdayname[wd],
- day, self.monthname[month], year,
- hh, mm, ss)
- return s
-
def emit(self, record):
"""
Emit a record.
@@ -861,10 +850,7 @@ class SMTPHandler(logging.Handler):
"""
try:
import smtplib
- try:
- from email.utils import formatdate
- except ImportError:
- formatdate = self.date_time
+ from email.utils import formatdate
port = self.mailport
if not port:
port = smtplib.SMTP_PORT
@@ -876,6 +862,10 @@ class SMTPHandler(logging.Handler):
self.getSubject(record),
formatdate(), msg)
if self.username:
+ if self.secure is not None:
+ smtp.ehlo()
+ smtp.starttls(*self.secure)
+ smtp.ehlo()
smtp.login(self.username, self.password)
smtp.sendmail(self.fromaddr, self.toaddrs, msg)
smtp.quit()
@@ -989,7 +979,7 @@ class HTTPHandler(logging.Handler):
A class which sends records to a Web server, using either GET or
POST semantics.
"""
- def __init__(self, host, url, method="GET"):
+ def __init__(self, host, url, method="GET", secure=False, credentials=None):
"""
Initialize the instance with the host, the request URL, and the method
("GET" or "POST")
@@ -1001,12 +991,14 @@ class HTTPHandler(logging.Handler):
self.host = host
self.url = url
self.method = method
+ self.secure = secure
+ self.credentials = credentials
def mapLogRecord(self, record):
"""
Default implementation of mapping the log record into a dict
that is sent as the CGI data. Overwrite in your class.
- Contributed by Franz Glasner.
+ Contributed by Franz Glasner.
"""
return record.__dict__
@@ -1019,7 +1011,10 @@ class HTTPHandler(logging.Handler):
try:
import http.client, urllib.parse
host = self.host
- h = http.client.HTTP(host)
+ if self.secure:
+ h = http.client.HTTPSConnection(host)
+ else:
+ h = http.client.HTTPConnection(host)
url = self.url
data = urllib.parse.urlencode(self.mapLogRecord(record))
if self.method == "GET":
@@ -1039,8 +1034,13 @@ class HTTPHandler(logging.Handler):
h.putheader("Content-type",
"application/x-www-form-urlencoded")
h.putheader("Content-length", str(len(data)))
+ if self.credentials:
+ import base64
+ s = ('u%s:%s' % self.credentials).encode('utf-8')
+ s = 'Basic ' + base64.b64encode(s).strip()
+ h.putheader('Authorization', s)
h.endheaders(data if self.method == "POST" else None)
- h.getreply() #can't do anything with the result
+ h.getresponse() #can't do anything with the result
except (KeyboardInterrupt, SystemExit):
raise
except:
@@ -1133,6 +1133,8 @@ class MemoryHandler(BufferingHandler):
For a MemoryHandler, flushing means just sending the buffered
records to the target, if there is one. Override if you want
different behaviour.
+
+ The record buffer is also cleared by this operation.
"""
if self.target:
for record in self.buffer:
@@ -1146,3 +1148,174 @@ class MemoryHandler(BufferingHandler):
self.flush()
self.target = None
BufferingHandler.close(self)
+
+
+class QueueHandler(logging.Handler):
+ """
+ This handler sends events to a queue. Typically, it would be used together
+ with a multiprocessing Queue to centralise logging to file in one process
+ (in a multi-process application), so as to avoid file write contention
+ between processes.
+
+ This code is new in Python 3.2, but this class can be copy pasted into
+ user code for use with earlier Python versions.
+ """
+
+ def __init__(self, queue):
+ """
+ Initialise an instance, using the passed queue.
+ """
+ logging.Handler.__init__(self)
+ self.queue = queue
+
+ def enqueue(self, record):
+ """
+ Enqueue a record.
+
+ The base implementation uses put_nowait. You may want to override
+ this method if you want to use blocking, timeouts or custom queue
+ implementations.
+ """
+ self.queue.put_nowait(record)
+
+ def prepare(self, record):
+ """
+ Prepares a record for queuing. The object returned by this method is
+ enqueued.
+
+ The base implementation formats the record to merge the message
+ and arguments, and removes unpickleable items from the record
+ in-place.
+
+ You might want to override this method if you want to convert
+ the record to a dict or JSON string, or send a modified copy
+ of the record while leaving the original intact.
+ """
+ # The format operation gets traceback text into record.exc_text
+ # (if there's exception data), and also puts the message into
+ # record.message. We can then use this to replace the original
+ # msg + args, as these might be unpickleable. We also zap the
+ # exc_info attribute, as it's no longer needed and, if not None,
+ # will typically not be pickleable.
+ self.format(record)
+ record.msg = record.message
+ record.args = None
+ record.exc_info = None
+ return record
+
+ def emit(self, record):
+ """
+ Emit a record.
+
+ Writes the LogRecord to the queue, preparing it for pickling first.
+ """
+ try:
+ self.enqueue(self.prepare(record))
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except:
+ self.handleError(record)
+
+class QueueListener(object):
+ """
+ This class implements an internal threaded listener which watches for
+ LogRecords being added to a queue, removes them and passes them to a
+ list of handlers for processing.
+ """
+ _sentinel = None
+
+ def __init__(self, queue, *handlers):
+ """
+ Initialise an instance with the specified queue and
+ handlers.
+ """
+ self.queue = queue
+ self.handlers = handlers
+ self._stop = threading.Event()
+ self._thread = None
+
+ def dequeue(self, block):
+ """
+ Dequeue a record and return it, optionally blocking.
+
+ The base implementation uses get. You may want to override this method
+ if you want to use timeouts or work with custom queue implementations.
+ """
+ return self.queue.get(block)
+
+ def start(self):
+ """
+ Start the listener.
+
+ This starts up a background thread to monitor the queue for
+ LogRecords to process.
+ """
+ self._thread = t = threading.Thread(target=self._monitor)
+ t.setDaemon(True)
+ t.start()
+
+ def prepare(self , record):
+ """
+ Prepare a record for handling.
+
+ This method just returns the passed-in record. You may want to
+ override this method if you need to do any custom marshalling or
+ manipulation of the record before passing it to the handlers.
+ """
+ return record
+
+ def handle(self, record):
+ """
+ Handle a record.
+
+ This just loops through the handlers offering them the record
+ to handle.
+ """
+ record = self.prepare(record)
+ for handler in self.handlers:
+ handler.handle(record)
+
+ def _monitor(self):
+ """
+ Monitor the queue for records, and ask the handler
+ to deal with them.
+
+ This method runs on a separate, internal thread.
+ The thread will terminate if it sees a sentinel object in the queue.
+ """
+ q = self.queue
+ has_task_done = hasattr(q, 'task_done')
+ while not self._stop.isSet():
+ try:
+ record = self.dequeue(True)
+ if record is self._sentinel:
+ break
+ self.handle(record)
+ if has_task_done:
+ q.task_done()
+ except queue.Empty:
+ pass
+ # There might still be records in the queue.
+ while True:
+ try:
+ record = self.dequeue(False)
+ if record is self._sentinel:
+ break
+ self.handle(record)
+ if has_task_done:
+ q.task_done()
+ except queue.Empty:
+ break
+
+ def stop(self):
+ """
+ Stop the listener.
+
+ This asks the thread to terminate, and then waits for it to do so.
+ Note that if you don't call this before your application exits, there
+ may be some records still left on the queue, which won't be processed.
+ """
+ self._stop.set()
+ self.queue.put_nowait(self._sentinel)
+ self._thread.join()
+ self._thread = None
diff --git a/Lib/macpath.py b/Lib/macpath.py
index 3b3e4ff071..1615d9122a 100644
--- a/Lib/macpath.py
+++ b/Lib/macpath.py
@@ -32,6 +32,9 @@ def _get_colon(path):
# Normalize the case of a pathname. Dummy in Posix, but <s>.lower() here.
def normcase(path):
+ if not isinstance(path, (bytes, str)):
+ raise TypeError("normcase() argument must be str or bytes, "
+ "not '{}'".format(path.__class__.__name__))
return path.lower()
@@ -199,4 +202,4 @@ def realpath(path):
pass
return path
-supports_unicode_filenames = False
+supports_unicode_filenames = True
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index d9c289b44f..ace17092b8 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes."""
@@ -15,6 +15,7 @@ import calendar
import socket
import errno
import copy
+import warnings
import email
import email.message
import email.generator
@@ -31,6 +32,8 @@ __all__ = [ 'Mailbox', 'Maildir', 'mbox', 'MH', 'Babyl', 'MMDF',
'Message', 'MaildirMessage', 'mboxMessage', 'MHMessage',
'BabylMessage', 'MMDFMessage']
+linesep = os.linesep.encode('ascii')
+
class Mailbox:
"""A group of messages in a particular place."""
@@ -80,7 +83,14 @@ class Mailbox:
raise NotImplementedError('Method must be implemented by subclass')
def get_string(self, key):
- """Return a string representation or raise a KeyError."""
+ """Return a string representation or raise a KeyError.
+
+ Uses email.message.Message to create a 7bit clean string
+ representation of the message."""
+ return email.message_from_bytes(self.get_bytes(key)).as_string()
+
+ def get_bytes(self, key):
+ """Return a byte string representation or raise a KeyError."""
raise NotImplementedError('Method must be implemented by subclass')
def get_file(self, key):
@@ -186,31 +196,55 @@ class Mailbox:
"""Flush and close the mailbox."""
raise NotImplementedError('Method must be implemented by subclass')
+ def _string_to_bytes(self, message):
+ # If a message is not 7bit clean, we refuse to handle it since it
+ # likely came from reading invalid messages in text mode, and that way
+ # lies mojibake.
+ try:
+ return message.encode('ascii')
+ except UnicodeError:
+ raise ValueError("String input must be ASCII-only; "
+ "use bytes or a Message instead")
+
def _dump_message(self, message, target, mangle_from_=False):
- # This assumes the target file is open in *text* mode with the
- # desired encoding and newline setting.
+ # This assumes the target file is open in binary mode.
"""Dump message contents to target file."""
if isinstance(message, email.message.Message):
- buffer = io.StringIO()
- gen = email.generator.Generator(buffer, mangle_from_, 0)
+ buffer = io.BytesIO()
+ gen = email.generator.BytesGenerator(buffer, mangle_from_, 0)
gen.flatten(message)
buffer.seek(0)
data = buffer.read()
- ##data = data.replace('\n', os.linesep)
+ data = data.replace(b'\n', linesep)
target.write(data)
- elif isinstance(message, str):
+ elif isinstance(message, (str, bytes, io.StringIO)):
+ if isinstance(message, io.StringIO):
+ warnings.warn("Use of StringIO input is deprecated, "
+ "use BytesIO instead", DeprecationWarning, 3)
+ message = message.getvalue()
+ if isinstance(message, str):
+ message = self._string_to_bytes(message)
if mangle_from_:
- message = message.replace('\nFrom ', '\n>From ')
- ##message = message.replace('\n', os.linesep)
+ message = message.replace(b'\nFrom ', b'\n>From ')
+ message = message.replace(b'\n', linesep)
target.write(message)
elif hasattr(message, 'read'):
+ if hasattr(message, 'buffer'):
+ warnings.warn("Use of text mode files is deprecated, "
+ "use a binary mode file instead", DeprecationWarning, 3)
+ message = message.buffer
while True:
line = message.readline()
+ # Universal newline support.
+ if line.endswith(b'\r\n'):
+ line = line[:-2] + b'\n'
+ elif line.endswith(b'\r'):
+ line = line[:-1] + b'\n'
if not line:
break
- if mangle_from_ and line.startswith('From '):
- line = '>From ' + line[5:]
- ##line = line.replace('\n', os.linesep)
+ if mangle_from_ and line.startswith(b'From '):
+ line = b'>From ' + line[5:]
+ line = line.replace(b'\n', linesep)
target.write(line)
else:
raise TypeError('Invalid message type: %s' % type(message))
@@ -243,8 +277,11 @@ class Maildir(Mailbox):
tmp_file = self._create_tmp()
try:
self._dump_message(message, tmp_file)
- finally:
- _sync_close(tmp_file)
+ except BaseException:
+ tmp_file.close()
+ os.remove(tmp_file.name)
+ raise
+ _sync_close(tmp_file)
if isinstance(message, MaildirMessage):
subdir = message.get_subdir()
suffix = self.colon + message.get_info()
@@ -319,7 +356,7 @@ class Maildir(Mailbox):
def get_message(self, key):
"""Return a Message representation or raise a KeyError."""
subpath = self._lookup(key)
- f = open(os.path.join(self._path, subpath), 'r', newline='')
+ f = open(os.path.join(self._path, subpath), 'rb')
try:
if self._factory:
msg = self._factory(f)
@@ -334,17 +371,17 @@ class Maildir(Mailbox):
msg.set_date(os.path.getmtime(os.path.join(self._path, subpath)))
return msg
- def get_string(self, key):
- """Return a string representation or raise a KeyError."""
- f = open(os.path.join(self._path, self._lookup(key)), 'r', newline='')
+ def get_bytes(self, key):
+ """Return a bytes representation or raise a KeyError."""
+ f = open(os.path.join(self._path, self._lookup(key)), 'rb')
try:
- return f.read()
+ return f.read().replace(linesep, b'\n')
finally:
f.close()
def get_file(self, key):
"""Return a file-like representation or raise a KeyError."""
- f = open(os.path.join(self._path, self._lookup(key)), 'r', newline='')
+ f = open(os.path.join(self._path, self._lookup(key)), 'rb')
return _ProxyFile(f)
def iterkeys(self):
@@ -469,12 +506,21 @@ class Maildir(Mailbox):
def _refresh(self):
"""Update table of contents mapping."""
- new_mtime = os.path.getmtime(os.path.join(self._path, 'new'))
- cur_mtime = os.path.getmtime(os.path.join(self._path, 'cur'))
+ if self._last_read is not None:
+ for subdir in ('new', 'cur'):
+ mtime = os.path.getmtime(os.path.join(self._path, subdir))
+ if mtime > self._last_read:
+ break
+ else:
+ return
- if (self._last_read is not None and
- new_mtime <= self._last_read and cur_mtime <= self._last_read):
- return
+ # We record the current time - 1sec so that, if _refresh() is called
+ # again in the same second, we will always re-read the mailbox
+ # just in case it's been modified. (os.path.mtime() only has
+ # 1sec resolution.) This results in a few unnecessary re-reads
+ # when _refresh() is called multiple times in the same second,
+ # but once the clock ticks over, we will only re-read as needed.
+ now = time.time() - 1
self._toc = {}
def update_dir (subdir):
@@ -489,14 +535,7 @@ class Maildir(Mailbox):
update_dir('new')
update_dir('cur')
- # We record the current time - 1sec so that, if _refresh() is called
- # again in the same second, we will always re-read the mailbox
- # just in case it's been modified. (os.path.mtime() only has
- # 1sec resolution.) This results in a few unnecessary re-reads
- # when _refresh() is called multiple times in the same second,
- # but once the clock ticks over, we will only re-read as needed.
- now = int(time.time() - 1)
- self._last_read = time.time() - 1
+ self._last_read = now
def _lookup(self, key):
"""Use TOC to return subpath for given key, or raise a KeyError."""
@@ -532,15 +571,15 @@ class _singlefileMailbox(Mailbox):
"""Initialize a single-file mailbox."""
Mailbox.__init__(self, path, factory, create)
try:
- f = open(self._path, 'r+', newline='')
+ f = open(self._path, 'rb+')
except IOError as e:
if e.errno == errno.ENOENT:
if create:
- f = open(self._path, 'w+', newline='')
+ f = open(self._path, 'wb+')
else:
raise NoSuchMailboxError(self._path)
- elif e.errno == errno.EACCES:
- f = open(self._path, 'r', newline='')
+ elif e.errno in (errno.EACCES, errno.EROFS):
+ f = open(self._path, 'rb')
else:
raise
self._file = f
@@ -688,9 +727,14 @@ class _singlefileMailbox(Mailbox):
def _append_message(self, message):
"""Append message to mailbox and return (start, stop) offsets."""
self._file.seek(0, 2)
- self._pre_message_hook(self._file)
- offsets = self._install_message(message)
- self._post_message_hook(self._file)
+ before = self._file.tell()
+ try:
+ self._pre_message_hook(self._file)
+ offsets = self._install_message(message)
+ self._post_message_hook(self._file)
+ except BaseException:
+ self._file.truncate(before)
+ raise
self._file.flush()
self._file_length = self._file.tell() # Record current length of mailbox
return offsets
@@ -706,20 +750,25 @@ class _mboxMMDF(_singlefileMailbox):
"""Return a Message representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
- from_line = self._file.readline().replace(os.linesep, '')
+ from_line = self._file.readline().replace(linesep, b'')
string = self._file.read(stop - self._file.tell())
- msg = self._message_factory(string.replace(os.linesep, '\n'))
- msg.set_from(from_line[5:])
+ msg = self._message_factory(string.replace(linesep, b'\n'))
+ msg.set_from(from_line[5:].decode('ascii'))
return msg
def get_string(self, key, from_=False):
"""Return a string representation or raise a KeyError."""
+ return email.message_from_bytes(
+ self.get_bytes(key)).as_string(unixfrom=from_)
+
+ def get_bytes(self, key, from_=False):
+ """Return a string representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
if not from_:
self._file.readline()
string = self._file.read(stop - self._file.tell())
- return string.replace(os.linesep, '\n')
+ return string.replace(linesep, b'\n')
def get_file(self, key, from_=False):
"""Return a file-like representation or raise a KeyError."""
@@ -732,22 +781,27 @@ class _mboxMMDF(_singlefileMailbox):
def _install_message(self, message):
"""Format a message and blindly write to self._file."""
from_line = None
- if isinstance(message, str) and message.startswith('From '):
- newline = message.find('\n')
+ if isinstance(message, str):
+ message = self._string_to_bytes(message)
+ if isinstance(message, bytes) and message.startswith(b'From '):
+ newline = message.find(b'\n')
if newline != -1:
from_line = message[:newline]
message = message[newline + 1:]
else:
from_line = message
- message = ''
+ message = b''
elif isinstance(message, _mboxMMDFMessage):
- from_line = 'From ' + message.get_from()
+ author = message.get_from().encode('ascii')
+ from_line = b'From ' + author
elif isinstance(message, email.message.Message):
from_line = message.get_unixfrom() # May be None.
+ if from_line is not None:
+ from_line = from_line.encode('ascii')
if from_line is None:
- from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime())
+ from_line = b'From MAILER-DAEMON ' + time.asctime(time.gmtime()).encode()
start = self._file.tell()
- self._file.write(from_line + os.linesep)
+ self._file.write(from_line + linesep)
self._dump_message(message, self._file, self._mangle_from_)
stop = self._file.tell()
return (start, stop)
@@ -766,7 +820,7 @@ class mbox(_mboxMMDF):
def _pre_message_hook(self, f):
"""Called before writing each message to file f."""
if f.tell() != 0:
- f.write(os.linesep)
+ f.write(linesep)
def _generate_toc(self):
"""Generate key-to-(start, stop) table of contents."""
@@ -775,9 +829,9 @@ class mbox(_mboxMMDF):
while True:
line_pos = self._file.tell()
line = self._file.readline()
- if line.startswith('From '):
+ if line.startswith(b'From '):
if len(stops) < len(starts):
- stops.append(line_pos - len(os.linesep))
+ stops.append(line_pos - len(linesep))
starts.append(line_pos)
elif not line:
stops.append(line_pos)
@@ -797,11 +851,11 @@ class MMDF(_mboxMMDF):
def _pre_message_hook(self, f):
"""Called before writing each message to file f."""
- f.write('\001\001\001\001' + os.linesep)
+ f.write(b'\001\001\001\001' + linesep)
def _post_message_hook(self, f):
"""Called after writing each message to file f."""
- f.write(os.linesep + '\001\001\001\001' + os.linesep)
+ f.write(linesep + b'\001\001\001\001' + linesep)
def _generate_toc(self):
"""Generate key-to-(start, stop) table of contents."""
@@ -812,14 +866,14 @@ class MMDF(_mboxMMDF):
line_pos = next_pos
line = self._file.readline()
next_pos = self._file.tell()
- if line.startswith('\001\001\001\001' + os.linesep):
+ if line.startswith(b'\001\001\001\001' + linesep):
starts.append(next_pos)
while True:
line_pos = next_pos
line = self._file.readline()
next_pos = self._file.tell()
- if line == '\001\001\001\001' + os.linesep:
- stops.append(line_pos - len(os.linesep))
+ if line == b'\001\001\001\001' + linesep:
+ stops.append(line_pos - len(linesep))
break
elif not line:
stops.append(line_pos)
@@ -856,18 +910,29 @@ class MH(Mailbox):
new_key = max(keys) + 1
new_path = os.path.join(self._path, str(new_key))
f = _create_carefully(new_path)
+ closed = False
try:
if self._locked:
_lock_file(f)
try:
- self._dump_message(message, f)
+ try:
+ self._dump_message(message, f)
+ except BaseException:
+ # Unlock and close so it can be deleted on Windows
+ if self._locked:
+ _unlock_file(f)
+ _sync_close(f)
+ closed = True
+ os.remove(new_path)
+ raise
if isinstance(message, MHMessage):
self._dump_sequences(message, new_key)
finally:
if self._locked:
_unlock_file(f)
finally:
- _sync_close(f)
+ if not closed:
+ _sync_close(f)
return new_key
def remove(self, key):
@@ -880,23 +945,15 @@ class MH(Mailbox):
raise KeyError('No message with key: %s' % key)
else:
raise
- try:
- if self._locked:
- _lock_file(f)
- try:
- f.close()
- os.remove(os.path.join(self._path, str(key)))
- finally:
- if self._locked:
- _unlock_file(f)
- finally:
+ else:
f.close()
+ os.remove(path)
def __setitem__(self, key, message):
"""Replace the keyed message; raise KeyError if it doesn't exist."""
path = os.path.join(self._path, str(key))
try:
- f = open(path, 'r+', newline='')
+ f = open(path, 'rb+')
except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
@@ -920,9 +977,9 @@ class MH(Mailbox):
"""Return a Message representation or raise a KeyError."""
try:
if self._locked:
- f = open(os.path.join(self._path, str(key)), 'r+', newline='')
+ f = open(os.path.join(self._path, str(key)), 'rb+')
else:
- f = open(os.path.join(self._path, str(key)), 'r', newline='')
+ f = open(os.path.join(self._path, str(key)), 'rb')
except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
@@ -943,13 +1000,13 @@ class MH(Mailbox):
msg.add_sequence(name)
return msg
- def get_string(self, key):
- """Return a string representation or raise a KeyError."""
+ def get_bytes(self, key):
+ """Return a bytes representation or raise a KeyError."""
try:
if self._locked:
- f = open(os.path.join(self._path, str(key)), 'r+', newline='')
+ f = open(os.path.join(self._path, str(key)), 'rb+')
else:
- f = open(os.path.join(self._path, str(key)), 'r', newline='')
+ f = open(os.path.join(self._path, str(key)), 'rb')
except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
@@ -959,7 +1016,7 @@ class MH(Mailbox):
if self._locked:
_lock_file(f)
try:
- return f.read()
+ return f.read().replace(linesep, b'\n')
finally:
if self._locked:
_unlock_file(f)
@@ -969,7 +1026,7 @@ class MH(Mailbox):
def get_file(self, key):
"""Return a file-like representation or raise a KeyError."""
try:
- f = open(os.path.join(self._path, str(key)), 'r', newline='')
+ f = open(os.path.join(self._path, str(key)), 'rb')
except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
@@ -1047,7 +1104,7 @@ class MH(Mailbox):
def get_sequences(self):
"""Return a name-to-key-list dictionary to define each sequence."""
results = {}
- f = open(os.path.join(self._path, '.mh_sequences'), 'r', newline='')
+ f = open(os.path.join(self._path, '.mh_sequences'), 'r')
try:
all_keys = set(self.keys())
for line in f:
@@ -1073,13 +1130,13 @@ class MH(Mailbox):
def set_sequences(self, sequences):
"""Set sequences using the given name-to-key-list dictionary."""
- f = open(os.path.join(self._path, '.mh_sequences'), 'r+', newline='')
+ f = open(os.path.join(self._path, '.mh_sequences'), 'r+')
try:
os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC))
for name, keys in sequences.items():
if len(keys) == 0:
continue
- f.write('%s:' % name)
+ f.write(name + ':')
prev = None
completing = False
for key in sorted(set(keys)):
@@ -1174,50 +1231,55 @@ class Babyl(_singlefileMailbox):
"""Return a Message representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
- self._file.readline() # Skip '1,' line specifying labels.
- original_headers = io.StringIO()
+ self._file.readline() # Skip b'1,' line specifying labels.
+ original_headers = io.BytesIO()
while True:
line = self._file.readline()
- if line == '*** EOOH ***' + os.linesep or not line:
+ if line == b'*** EOOH ***' + linesep or not line:
break
- original_headers.write(line.replace(os.linesep, '\n'))
- visible_headers = io.StringIO()
+ original_headers.write(line.replace(linesep, b'\n'))
+ visible_headers = io.BytesIO()
while True:
line = self._file.readline()
- if line == os.linesep or not line:
+ if line == linesep or not line:
break
- visible_headers.write(line.replace(os.linesep, '\n'))
- body = self._file.read(stop - self._file.tell()).replace(os.linesep,
- '\n')
+ visible_headers.write(line.replace(linesep, b'\n'))
+ # Read up to the stop, or to the end
+ n = stop - self._file.tell()
+ assert n >= 0
+ body = self._file.read(n)
+ body = body.replace(linesep, b'\n')
msg = BabylMessage(original_headers.getvalue() + body)
msg.set_visible(visible_headers.getvalue())
if key in self._labels:
msg.set_labels(self._labels[key])
return msg
- def get_string(self, key):
+ def get_bytes(self, key):
"""Return a string representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
- self._file.readline() # Skip '1,' line specifying labels.
- original_headers = io.StringIO()
+ self._file.readline() # Skip b'1,' line specifying labels.
+ original_headers = io.BytesIO()
while True:
line = self._file.readline()
- if line == '*** EOOH ***' + os.linesep or not line:
+ if line == b'*** EOOH ***' + linesep or not line:
break
- original_headers.write(line.replace(os.linesep, '\n'))
+ original_headers.write(line.replace(linesep, b'\n'))
while True:
line = self._file.readline()
- if line == os.linesep or not line:
+ if line == linesep or not line:
break
- return original_headers.getvalue() + \
- self._file.read(stop - self._file.tell()).replace(os.linesep,
- '\n')
+ headers = original_headers.getvalue()
+ n = stop - self._file.tell()
+ assert n >= 0
+ data = self._file.read(n)
+ data = data.replace(linesep, b'\n')
+ return headers + data
def get_file(self, key):
"""Return a file-like representation or raise a KeyError."""
- return io.StringIO(self.get_string(key).replace('\n',
- os.linesep))
+ return io.BytesIO(self.get_bytes(key).replace(b'\n', linesep))
def get_labels(self):
"""Return a list of user-defined labels in the mailbox."""
@@ -1238,19 +1300,19 @@ class Babyl(_singlefileMailbox):
line_pos = next_pos
line = self._file.readline()
next_pos = self._file.tell()
- if line == '\037\014' + os.linesep:
+ if line == b'\037\014' + linesep:
if len(stops) < len(starts):
- stops.append(line_pos - len(os.linesep))
+ stops.append(line_pos - len(linesep))
starts.append(next_pos)
labels = [label.strip() for label
- in self._file.readline()[1:].split(',')
+ in self._file.readline()[1:].split(b',')
if label.strip()]
label_lists.append(labels)
- elif line == '\037' or line == '\037' + os.linesep:
+ elif line == b'\037' or line == b'\037' + linesep:
if len(stops) < len(starts):
- stops.append(line_pos - len(os.linesep))
+ stops.append(line_pos - len(linesep))
elif not line:
- stops.append(line_pos - len(os.linesep))
+ stops.append(line_pos - len(linesep))
break
self._toc = dict(enumerate(zip(starts, stops)))
self._labels = dict(enumerate(label_lists))
@@ -1260,17 +1322,21 @@ class Babyl(_singlefileMailbox):
def _pre_mailbox_hook(self, f):
"""Called before writing the mailbox to file f."""
- f.write('BABYL OPTIONS:%sVersion: 5%sLabels:%s%s\037' %
- (os.linesep, os.linesep, ','.join(self.get_labels()),
- os.linesep))
+ babyl = b'BABYL OPTIONS:' + linesep
+ babyl += b'Version: 5' + linesep
+ labels = self.get_labels()
+ labels = (label.encode() for label in labels)
+ babyl += b'Labels:' + b','.join(labels) + linesep
+ babyl += b'\037'
+ f.write(babyl)
def _pre_message_hook(self, f):
"""Called before writing each message to file f."""
- f.write('\014' + os.linesep)
+ f.write(b'\014' + linesep)
def _post_message_hook(self, f):
"""Called after writing each message to file f."""
- f.write(os.linesep + '\037')
+ f.write(linesep + b'\037')
def _install_message(self, message):
"""Write message contents and return (start, stop)."""
@@ -1283,68 +1349,80 @@ class Babyl(_singlefileMailbox):
special_labels.append(label)
else:
labels.append(label)
- self._file.write('1')
+ self._file.write(b'1')
for label in special_labels:
- self._file.write(', ' + label)
- self._file.write(',,')
+ self._file.write(b', ' + label.encode())
+ self._file.write(b',,')
for label in labels:
- self._file.write(' ' + label + ',')
- self._file.write(os.linesep)
+ self._file.write(b' ' + label.encode() + b',')
+ self._file.write(linesep)
else:
- self._file.write('1,,' + os.linesep)
+ self._file.write(b'1,,' + linesep)
if isinstance(message, email.message.Message):
- orig_buffer = io.StringIO()
- orig_generator = email.generator.Generator(orig_buffer, False, 0)
+ orig_buffer = io.BytesIO()
+ orig_generator = email.generator.BytesGenerator(orig_buffer, False, 0)
orig_generator.flatten(message)
orig_buffer.seek(0)
while True:
line = orig_buffer.readline()
- self._file.write(line.replace('\n', os.linesep))
- if line == '\n' or not line:
+ self._file.write(line.replace(b'\n', linesep))
+ if line == b'\n' or not line:
break
- self._file.write('*** EOOH ***' + os.linesep)
+ self._file.write(b'*** EOOH ***' + linesep)
if isinstance(message, BabylMessage):
- vis_buffer = io.StringIO()
- vis_generator = email.generator.Generator(vis_buffer, False, 0)
+ vis_buffer = io.BytesIO()
+ vis_generator = email.generator.BytesGenerator(vis_buffer, False, 0)
vis_generator.flatten(message.get_visible())
while True:
line = vis_buffer.readline()
- self._file.write(line.replace('\n', os.linesep))
- if line == '\n' or not line:
+ self._file.write(line.replace(b'\n', linesep))
+ if line == b'\n' or not line:
break
else:
orig_buffer.seek(0)
while True:
line = orig_buffer.readline()
- self._file.write(line.replace('\n', os.linesep))
- if line == '\n' or not line:
+ self._file.write(line.replace(b'\n', linesep))
+ if line == b'\n' or not line:
break
while True:
buffer = orig_buffer.read(4096) # Buffer size is arbitrary.
if not buffer:
break
- self._file.write(buffer.replace('\n', os.linesep))
- elif isinstance(message, str):
- body_start = message.find('\n\n') + 2
+ self._file.write(buffer.replace(b'\n', linesep))
+ elif isinstance(message, (bytes, str, io.StringIO)):
+ if isinstance(message, io.StringIO):
+ warnings.warn("Use of StringIO input is deprecated, "
+ "use BytesIO instead", DeprecationWarning, 3)
+ message = message.getvalue()
+ if isinstance(message, str):
+ message = self._string_to_bytes(message)
+ body_start = message.find(b'\n\n') + 2
if body_start - 2 != -1:
- self._file.write(message[:body_start].replace('\n',
- os.linesep))
- self._file.write('*** EOOH ***' + os.linesep)
- self._file.write(message[:body_start].replace('\n',
- os.linesep))
- self._file.write(message[body_start:].replace('\n',
- os.linesep))
+ self._file.write(message[:body_start].replace(b'\n', linesep))
+ self._file.write(b'*** EOOH ***' + linesep)
+ self._file.write(message[:body_start].replace(b'\n', linesep))
+ self._file.write(message[body_start:].replace(b'\n', linesep))
else:
- self._file.write('*** EOOH ***' + os.linesep + os.linesep)
- self._file.write(message.replace('\n', os.linesep))
+ self._file.write(b'*** EOOH ***' + linesep + linesep)
+ self._file.write(message.replace(b'\n', linesep))
elif hasattr(message, 'readline'):
+ if hasattr(message, 'buffer'):
+ warnings.warn("Use of text mode files is deprecated, "
+ "use a binary mode file instead", DeprecationWarning, 3)
+ message = message.buffer
original_pos = message.tell()
first_pass = True
while True:
line = message.readline()
- self._file.write(line.replace('\n', os.linesep))
- if line == '\n' or not line:
- self._file.write('*** EOOH ***' + os.linesep)
+ # Universal newline support.
+ if line.endswith(b'\r\n'):
+ line = line[:-2] + b'\n'
+ elif line.endswith(b'\r'):
+ line = line[:-1] + b'\n'
+ self._file.write(line.replace(b'\n', linesep))
+ if line == b'\n' or not line:
+ self._file.write(b'*** EOOH ***' + linesep)
if first_pass:
first_pass = False
message.seek(original_pos)
@@ -1354,7 +1432,7 @@ class Babyl(_singlefileMailbox):
buffer = message.read(4096) # Buffer size is arbitrary.
if not buffer:
break
- self._file.write(buffer.replace('\n', os.linesep))
+ self._file.write(buffer.replace(b'\n', linesep))
else:
raise TypeError('Invalid message type: %s' % type(message))
stop = self._file.tell()
@@ -1370,10 +1448,14 @@ class Message(email.message.Message):
self._become_message(copy.deepcopy(message))
if isinstance(message, Message):
message._explain_to(self)
+ elif isinstance(message, bytes):
+ self._become_message(email.message_from_bytes(message))
elif isinstance(message, str):
self._become_message(email.message_from_string(message))
- elif hasattr(message, "read"):
+ elif isinstance(message, io.TextIOWrapper):
self._become_message(email.message_from_file(message))
+ elif hasattr(message, "read"):
+ self._become_message(email.message_from_binary_file(message))
elif message is None:
email.message.Message.__init__(self)
else:
@@ -1637,7 +1719,7 @@ class MHMessage(Message):
if not sequence in self._sequences:
self._sequences.append(sequence)
else:
- raise TypeError('sequence must be a string: %s' % type(sequence))
+ raise TypeError('sequence type must be str: %s' % type(sequence))
def remove_sequence(self, sequence):
"""Remove sequence from the list of sequences including the message."""
@@ -1797,6 +1879,10 @@ class _ProxyFile:
"""Read bytes."""
return self._read(size, self._file.read)
+ def read1(self, size=None):
+ """Read bytes."""
+ return self._read(size, self._file.read1)
+
def readline(self, size=None):
"""Read a line."""
return self._read(size, self._file.readline)
@@ -1833,6 +1919,8 @@ class _ProxyFile:
def close(self):
"""Close the file."""
+ if hasattr(self._file, 'close'):
+ self._file.close()
del self._file
def _read(self, size, read_method):
@@ -1844,6 +1932,29 @@ class _ProxyFile:
self._pos = self._file.tell()
return result
+ def __enter__(self):
+ """Context manager protocol support."""
+ return self
+
+ def __exit__(self, *exc):
+ self.close()
+
+ def readable(self):
+ return self._file.readable()
+
+ def writable(self):
+ return self._file.writable()
+
+ def seekable(self):
+ return self._file.seekable()
+
+ def flush(self):
+ return self._file.flush()
+
+ @property
+ def closed(self):
+ return self._file.closed
+
class _PartialFile(_ProxyFile):
"""A read-only wrapper of part of a file."""
@@ -1872,11 +1983,16 @@ class _PartialFile(_ProxyFile):
"""Read size bytes using read_method, honoring start and stop."""
remaining = self._stop - self._pos
if remaining <= 0:
- return ''
+ return b''
if size is None or size < 0 or size > remaining:
size = remaining
return _ProxyFile._read(self, size, read_method)
+ def close(self):
+ # do *not* close the underlying file object for partial files,
+ # since it's global to the mailbox object
+ del self._file
+
def _lock_file(f, dotlock=True):
"""Lock file f using lockf and dot locking."""
@@ -1886,7 +2002,7 @@ def _lock_file(f, dotlock=True):
try:
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError as e:
- if e.errno in (errno.EAGAIN, errno.EACCES):
+ if e.errno in (errno.EAGAIN, errno.EACCES, errno.EROFS):
raise ExternalClashError('lockf: lock unavailable: %s' %
f.name)
else:
@@ -1896,7 +2012,7 @@ def _lock_file(f, dotlock=True):
pre_lock = _create_temporary(f.name + '.lock')
pre_lock.close()
except IOError as e:
- if e.errno == errno.EACCES:
+ if e.errno in (errno.EACCES, errno.EROFS):
return # Without write access, just skip dotlocking.
else:
raise
@@ -1934,7 +2050,7 @@ def _create_carefully(path):
"""Create a file if it doesn't exist and open for reading and writing."""
fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR, 0o666)
try:
- return open(path, 'r+', newline='')
+ return open(path, 'rb+')
finally:
os.close(fd)
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index 874037e871..2ef71f9482 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -18,13 +18,19 @@ types_map -- dictionary mapping suffixes to types
Functions:
-init([files]) -- parse a list of files, default knownfiles
+init([files]) -- parse a list of files, default knownfiles (on Windows, the
+ default values are taken from the registry)
read_mime_types(file) -- parse one file, return a dictionary or None
"""
import os
+import sys
import posixpath
import urllib.parse
+try:
+ import winreg as _winreg
+except ImportError:
+ _winreg = None
__all__ = [
"guess_type","guess_extension","guess_all_extensions",
@@ -219,6 +225,45 @@ class MimeTypes:
for suff in suffixes:
self.add_type(type, '.' + suff, strict)
+ def read_windows_registry(self, strict=True):
+ """
+ Load the MIME types database from Windows registry.
+
+ If strict is true, information will be added to
+ list of standard types, else to the list of non-standard
+ types.
+ """
+
+ # Windows only
+ if not _winreg:
+ return
+
+ def enum_types(mimedb):
+ i = 0
+ while True:
+ try:
+ ctype = _winreg.EnumKey(mimedb, i)
+ except EnvironmentError:
+ break
+ else:
+ yield ctype
+ i += 1
+
+ default_encoding = sys.getdefaultencoding()
+ with _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
+ r'MIME\Database\Content Type') as mimedb:
+ for ctype in enum_types(mimedb):
+ try:
+ with _winreg.OpenKey(mimedb, ctype) as key:
+ suffix, datatype = _winreg.QueryValueEx(key,
+ 'Extension')
+ except EnvironmentError:
+ continue
+ if datatype != _winreg.REG_SZ:
+ continue
+ self.add_type(ctype, suffix, strict)
+
+
def guess_type(url, strict=True):
"""Guess the type of a file based on its URL.
@@ -298,6 +343,8 @@ def init(files=None):
inited = True # so that MimeTypes.__init__() doesn't call us again
db = MimeTypes()
if files is None:
+ if _winreg:
+ db.read_windows_registry()
files = knownfiles
for file in files:
if os.path.isfile(file):
@@ -327,6 +374,7 @@ def _default_mime_types():
global common_types
suffix_map = {
+ '.svgz': '.svg.gz',
'.tgz': '.tar.gz',
'.taz': '.tar.gz',
'.tz': '.tar.gz',
@@ -340,7 +388,7 @@ def _default_mime_types():
}
# Before adding new types, make sure they are either registered with IANA,
- # at http://www.isi.edu/in-notes/iana/assignments/media-types
+ # at http://www.iana.org/assignments/media-types
# or extensions, i.e. using the x- prefix
# If you add to these, please keep them sorted!
@@ -441,6 +489,7 @@ def _default_mime_types():
'.src' : 'application/x-wais-source',
'.sv4cpio': 'application/x-sv4cpio',
'.sv4crc' : 'application/x-sv4crc',
+ '.svg' : 'image/svg+xml',
'.swf' : 'application/x-shockwave-flash',
'.t' : 'application/x-troff',
'.tar' : 'application/x-tar',
@@ -491,7 +540,6 @@ _default_mime_types()
if __name__ == '__main__':
- import sys
import getopt
USAGE = """\
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
index 478c74912d..646a7852ba 100644
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -105,16 +105,16 @@ class ModuleFinder:
def run_script(self, pathname):
self.msg(2, "run_script", pathname)
- fp = open(pathname, READ_MODE)
- stuff = ("", "r", imp.PY_SOURCE)
- self.load_module('__main__', fp, pathname, stuff)
+ with open(pathname, READ_MODE) as fp:
+ stuff = ("", "r", imp.PY_SOURCE)
+ self.load_module('__main__', fp, pathname, stuff)
def load_file(self, pathname):
dir, name = os.path.split(pathname)
name, ext = os.path.splitext(name)
- fp = open(pathname, READ_MODE)
- stuff = (ext, "r", imp.PY_SOURCE)
- self.load_module(name, fp, pathname, stuff)
+ with open(pathname, READ_MODE) as fp:
+ stuff = (ext, "r", imp.PY_SOURCE)
+ self.load_module(name, fp, pathname, stuff)
def import_hook(self, name, caller=None, fromlist=None, level=-1):
self.msg(3, "import_hook", name, caller, fromlist, level)
@@ -451,9 +451,13 @@ class ModuleFinder:
m.__path__ = m.__path__ + packagePathMap.get(fqname, [])
fp, buf, stuff = self.find_module("__init__", m.__path__)
- self.load_module(fqname, fp, buf, stuff)
- self.msgout(2, "load_package ->", m)
- return m
+ try:
+ self.load_module(fqname, fp, buf, stuff)
+ self.msgout(2, "load_package ->", m)
+ return m
+ finally:
+ if fp:
+ fp.close()
def add_module(self, fqname):
if fqname in self.modules:
diff --git a/Lib/msilib/__init__.py b/Lib/msilib/__init__.py
index 114a1c788c..bd3e1f2900 100644
--- a/Lib/msilib/__init__.py
+++ b/Lib/msilib/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2005 Martin v. Löwis
# Licensed to PSF under a Contributor Agreement.
from _msi import *
diff --git a/Lib/multiprocessing/__init__.py b/Lib/multiprocessing/__init__.py
index fdd012ea4e..deb031c367 100644
--- a/Lib/multiprocessing/__init__.py
+++ b/Lib/multiprocessing/__init__.py
@@ -223,12 +223,12 @@ def JoinableQueue(maxsize=0):
from multiprocessing.queues import JoinableQueue
return JoinableQueue(maxsize)
-def Pool(processes=None, initializer=None, initargs=()):
+def Pool(processes=None, initializer=None, initargs=(), maxtasksperchild=None):
'''
Returns a process pool object
'''
from multiprocessing.pool import Pool
- return Pool(processes, initializer, initargs)
+ return Pool(processes, initializer, initargs, maxtasksperchild)
def RawValue(typecode_or_type, *args):
'''
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
index 846d3964d6..d6c23fb0ec 100644
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -281,25 +281,24 @@ def SocketClient(address):
Return a connection object connected to the socket given by `address`
'''
family = address_type(address)
- s = socket.socket( getattr(socket, family) )
- t = _init_timeout()
+ with socket.socket( getattr(socket, family) ) as s:
+ t = _init_timeout()
- while 1:
- try:
- s.connect(address)
- except socket.error as e:
- if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
- debug('failed to connect to address %s', address)
- raise
- time.sleep(0.01)
+ while 1:
+ try:
+ s.connect(address)
+ except socket.error as e:
+ if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
+ debug('failed to connect to address %s', address)
+ raise
+ time.sleep(0.01)
+ else:
+ break
else:
- break
- else:
- raise
+ raise
- fd = duplicate(s.fileno())
+ fd = duplicate(s.fileno())
conn = _multiprocessing.Connection(fd)
- s.close()
return conn
#
diff --git a/Lib/multiprocessing/forking.py b/Lib/multiprocessing/forking.py
index d2a3208453..8ddddb60b5 100644
--- a/Lib/multiprocessing/forking.py
+++ b/Lib/multiprocessing/forking.py
@@ -459,12 +459,20 @@ def prepare(data):
process.ORIGINAL_DIR = data['orig_dir']
if 'main_path' in data:
+ # XXX (ncoghlan): The following code makes several bogus
+ # assumptions regarding the relationship between __file__
+ # and a module's real name. See PEP 302 and issue #10845
main_path = data['main_path']
main_name = os.path.splitext(os.path.basename(main_path))[0]
if main_name == '__init__':
main_name = os.path.basename(os.path.dirname(main_path))
- if main_name != 'ipython':
+ if main_name == '__main__':
+ main_module = sys.modules['__main__']
+ main_module.__file__ = main_path
+ elif main_name != 'ipython':
+ # Main modules not actually called __main__.py may
+ # contain additional code that should still be executed
import imp
if main_path is None:
diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py
index b77c693806..388bfe3c87 100644
--- a/Lib/multiprocessing/managers.py
+++ b/Lib/multiprocessing/managers.py
@@ -58,7 +58,7 @@ from multiprocessing.util import Finalize, info
#
def reduce_array(a):
- return array.array, (a.typecode, a.tostring())
+ return array.array, (a.typecode, a.tobytes())
ForkingPickler.register(array.array, reduce_array)
view_types = [type(getattr({}, name)()) for name in ('items','keys','values')]
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index fc03a0a66c..ff7c29c85b 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -68,7 +68,25 @@ def mapstar(args):
# Code run by worker processes
#
-def worker(inqueue, outqueue, initializer=None, initargs=()):
+class MaybeEncodingError(Exception):
+ """Wraps possible unpickleable errors, so they can be
+ safely sent through the socket."""
+
+ def __init__(self, exc, value):
+ self.exc = repr(exc)
+ self.value = repr(value)
+ super(MaybeEncodingError, self).__init__(self.exc, self.value)
+
+ def __str__(self):
+ return "Error sending result: '%s'. Reason: '%s'" % (self.value,
+ self.exc)
+
+ def __repr__(self):
+ return "<MaybeEncodingError: %s>" % str(self)
+
+
+def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None):
+ assert maxtasks is None or (type(maxtasks) == int and maxtasks > 0)
put = outqueue.put
get = inqueue.get
if hasattr(inqueue, '_writer'):
@@ -78,7 +96,8 @@ def worker(inqueue, outqueue, initializer=None, initargs=()):
if initializer is not None:
initializer(*initargs)
- while 1:
+ completed = 0
+ while maxtasks is None or (maxtasks and completed < maxtasks):
try:
task = get()
except (EOFError, IOError):
@@ -94,7 +113,15 @@ def worker(inqueue, outqueue, initializer=None, initargs=()):
result = (True, func(*args, **kwds))
except Exception as e:
result = (False, e)
- put((job, i, result))
+ try:
+ put((job, i, result))
+ except Exception as e:
+ wrapped = MaybeEncodingError(e, result[1])
+ debug("Possible encoding error while sending result: %s" % (
+ wrapped))
+ put((job, i, (False, wrapped)))
+ completed += 1
+ debug('worker exiting after %d tasks' % completed)
#
# Class representing a process pool
@@ -106,11 +133,15 @@ class Pool(object):
'''
Process = Process
- def __init__(self, processes=None, initializer=None, initargs=()):
+ def __init__(self, processes=None, initializer=None, initargs=(),
+ maxtasksperchild=None):
self._setup_queues()
self._taskqueue = queue.Queue()
self._cache = {}
self._state = RUN
+ self._maxtasksperchild = maxtasksperchild
+ self._initializer = initializer
+ self._initargs = initargs
if processes is None:
try:
@@ -121,16 +152,18 @@ class Pool(object):
if initializer is not None and not hasattr(initializer, '__call__'):
raise TypeError('initializer must be a callable')
+ self._processes = processes
self._pool = []
- for i in range(processes):
- w = self.Process(
- target=worker,
- args=(self._inqueue, self._outqueue, initializer, initargs)
- )
- self._pool.append(w)
- w.name = w.name.replace('Process', 'PoolWorker')
- w.daemon = True
- w.start()
+ self._repopulate_pool()
+
+ self._worker_handler = threading.Thread(
+ target=Pool._handle_workers,
+ args=(self, )
+ )
+ self._worker_handler.daemon = True
+ self._worker_handler._state = RUN
+ self._worker_handler.start()
+
self._task_handler = threading.Thread(
target=Pool._handle_tasks,
@@ -151,10 +184,48 @@ class Pool(object):
self._terminate = Finalize(
self, self._terminate_pool,
args=(self._taskqueue, self._inqueue, self._outqueue, self._pool,
- self._task_handler, self._result_handler, self._cache),
+ self._worker_handler, self._task_handler,
+ self._result_handler, self._cache),
exitpriority=15
)
+ def _join_exited_workers(self):
+ """Cleanup after any worker processes which have exited due to reaching
+ their specified lifetime. Returns True if any workers were cleaned up.
+ """
+ cleaned = False
+ for i in reversed(range(len(self._pool))):
+ worker = self._pool[i]
+ if worker.exitcode is not None:
+ # worker exited
+ debug('cleaning up worker %d' % i)
+ worker.join()
+ cleaned = True
+ del self._pool[i]
+ return cleaned
+
+ def _repopulate_pool(self):
+ """Bring the number of pool processes up to the specified number,
+ for use after reaping workers which have exited.
+ """
+ for i in range(self._processes - len(self._pool)):
+ w = self.Process(target=worker,
+ args=(self._inqueue, self._outqueue,
+ self._initializer,
+ self._initargs, self._maxtasksperchild)
+ )
+ self._pool.append(w)
+ w.name = w.name.replace('Process', 'PoolWorker')
+ w.daemon = True
+ w.start()
+ debug('added worker')
+
+ def _maintain_pool(self):
+ """Clean up any exited workers and start replacements for them.
+ """
+ if self._join_exited_workers():
+ self._repopulate_pool()
+
def _setup_queues(self):
from .queues import SimpleQueue
self._inqueue = SimpleQueue()
@@ -213,16 +284,18 @@ class Pool(object):
for i, x in enumerate(task_batches)), result._set_length))
return (item for chunk in result for item in chunk)
- def apply_async(self, func, args=(), kwds={}, callback=None):
+ def apply_async(self, func, args=(), kwds={}, callback=None,
+ error_callback=None):
'''
Asynchronous version of `apply()` method.
'''
assert self._state == RUN
- result = ApplyResult(self._cache, callback)
+ result = ApplyResult(self._cache, callback, error_callback)
self._taskqueue.put(([(result._job, None, func, args, kwds)], None))
return result
- def map_async(self, func, iterable, chunksize=None, callback=None):
+ def map_async(self, func, iterable, chunksize=None, callback=None,
+ error_callback=None):
'''
Asynchronous version of `map()` method.
'''
@@ -238,12 +311,20 @@ class Pool(object):
chunksize = 0
task_batches = Pool._get_tasks(func, iterable, chunksize)
- result = MapResult(self._cache, chunksize, len(iterable), callback)
+ result = MapResult(self._cache, chunksize, len(iterable), callback,
+ error_callback=error_callback)
self._taskqueue.put((((result._job, i, mapstar, (x,), {})
for i, x in enumerate(task_batches)), None))
return result
@staticmethod
+ def _handle_workers(pool):
+ while pool._worker_handler._state == RUN and pool._state == RUN:
+ pool._maintain_pool()
+ time.sleep(0.1)
+ debug('worker handler exiting')
+
+ @staticmethod
def _handle_tasks(taskqueue, put, outqueue, pool):
thread = threading.current_thread()
@@ -358,16 +439,19 @@ class Pool(object):
debug('closing pool')
if self._state == RUN:
self._state = CLOSE
+ self._worker_handler._state = CLOSE
self._taskqueue.put(None)
def terminate(self):
debug('terminating pool')
self._state = TERMINATE
+ self._worker_handler._state = TERMINATE
self._terminate()
def join(self):
debug('joining pool')
assert self._state in (CLOSE, TERMINATE)
+ self._worker_handler.join()
self._task_handler.join()
self._result_handler.join()
for p in self._pool:
@@ -384,10 +468,11 @@ class Pool(object):
@classmethod
def _terminate_pool(cls, taskqueue, inqueue, outqueue, pool,
- task_handler, result_handler, cache):
+ worker_handler, task_handler, result_handler, cache):
# this is guaranteed to only be called once
debug('finalizing pool')
+ worker_handler._state = TERMINATE
task_handler._state = TERMINATE
taskqueue.put(None) # sentinel
@@ -399,16 +484,18 @@ class Pool(object):
result_handler._state = TERMINATE
outqueue.put(None) # sentinel
+ # Terminate workers which haven't already finished.
if pool and hasattr(pool[0], 'terminate'):
debug('terminating workers')
for p in pool:
- p.terminate()
+ if p.exitcode is None:
+ p.terminate()
debug('joining task handler')
- task_handler.join(1e100)
+ task_handler.join()
debug('joining result handler')
- result_handler.join(1e100)
+ task_handler.join()
if pool and hasattr(pool[0], 'terminate'):
debug('joining pool workers')
@@ -424,12 +511,13 @@ class Pool(object):
class ApplyResult(object):
- def __init__(self, cache, callback):
+ def __init__(self, cache, callback, error_callback):
self._cond = threading.Condition(threading.Lock())
self._job = next(job_counter)
self._cache = cache
self._ready = False
self._callback = callback
+ self._error_callback = error_callback
cache[self._job] = self
def ready(self):
@@ -460,6 +548,8 @@ class ApplyResult(object):
self._success, self._value = obj
if self._callback and self._success:
self._callback(self._value)
+ if self._error_callback and not self._success:
+ self._error_callback(self._value)
self._cond.acquire()
try:
self._ready = True
@@ -474,8 +564,9 @@ class ApplyResult(object):
class MapResult(ApplyResult):
- def __init__(self, cache, chunksize, length, callback):
- ApplyResult.__init__(self, cache, callback)
+ def __init__(self, cache, chunksize, length, callback, error_callback):
+ ApplyResult.__init__(self, cache, callback,
+ error_callback=error_callback)
self._success = True
self._value = [None] * length
self._chunksize = chunksize
@@ -500,10 +591,11 @@ class MapResult(ApplyResult):
self._cond.notify()
finally:
self._cond.release()
-
else:
self._success = False
self._value = result
+ if self._error_callback:
+ self._error_callback(self._value)
del self._cache[self._job]
self._cond.acquire()
try:
diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py
index 617d0b6868..70ae82569c 100644
--- a/Lib/multiprocessing/synchronize.py
+++ b/Lib/multiprocessing/synchronize.py
@@ -243,7 +243,7 @@ class Condition(object):
try:
# wait for notification or timeout
- self._wait_semaphore.acquire(True, timeout)
+ ret = self._wait_semaphore.acquire(True, timeout)
finally:
# indicate that this thread has woken
self._woken_count.release()
@@ -251,6 +251,7 @@ class Condition(object):
# reacquire lock
for i in range(count):
self._lock.acquire()
+ return ret
def notify(self):
assert self._lock._semlock._is_mine(), 'lock is not owned'
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index 326c62df47..bf66734a52 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -1,4 +1,7 @@
-"""An NNTP client class based on RFC 977: Network News Transfer Protocol.
+"""An NNTP client class based on:
+- RFC 977: Network News Transfer Protocol
+- RFC 2980: Common NNTP Extensions
+- RFC 3977: Network News Transfer Protocol (version 2)
Example:
@@ -27,15 +30,60 @@ are strings, not numbers, since they are rarely used for calculations.
# RFC 977 by Brian Kantor and Phil Lapsley.
# xover, xgtitle, xpath, date methods by Kevan Heydon
+# Incompatible changes from the 2.x nntplib:
+# - all commands are encoded as UTF-8 data (using the "surrogateescape"
+# error handler), except for raw message data (POST, IHAVE)
+# - all responses are decoded as UTF-8 data (using the "surrogateescape"
+# error handler), except for raw message data (ARTICLE, HEAD, BODY)
+# - the `file` argument to various methods is keyword-only
+#
+# - NNTP.date() returns a datetime object
+# - NNTP.newgroups() and NNTP.newnews() take a datetime (or date) object,
+# rather than a pair of (date, time) strings.
+# - NNTP.newgroups() and NNTP.list() return a list of GroupInfo named tuples
+# - NNTP.descriptions() returns a dict mapping group names to descriptions
+# - NNTP.xover() returns a list of dicts mapping field names (header or metadata)
+# to field values; each dict representing a message overview.
+# - NNTP.article(), NNTP.head() and NNTP.body() return a (response, ArticleInfo)
+# tuple.
+# - the "internal" methods have been marked private (they now start with
+# an underscore)
+
+# Other changes from the 2.x/3.1 nntplib:
+# - automatic querying of capabilities at connect
+# - New method NNTP.getcapabilities()
+# - New method NNTP.over()
+# - New helper function decode_header()
+# - NNTP.post() and NNTP.ihave() accept file objects, bytes-like objects and
+# arbitrary iterables yielding lines.
+# - An extensive test suite :-)
+
+# TODO:
+# - return structured data (GroupInfo etc.) everywhere
+# - support HDR
# Imports
import re
import socket
-
-__all__ = ["NNTP","NNTPReplyError","NNTPTemporaryError",
- "NNTPPermanentError","NNTPProtocolError","NNTPDataError",
- "error_reply","error_temp","error_perm","error_proto",
- "error_data",]
+import collections
+import datetime
+import warnings
+
+try:
+ import ssl
+except ImportError:
+ _have_ssl = False
+else:
+ _have_ssl = True
+
+from email.header import decode_header as _email_decode_header
+from socket import _GLOBAL_DEFAULT_TIMEOUT
+
+__all__ = ["NNTP",
+ "NNTPReplyError", "NNTPTemporaryError", "NNTPPermanentError",
+ "NNTPProtocolError", "NNTPDataError",
+ "decode_header",
+ ]
# Exceptions raised when an error or invalid response is received
class NNTPError(Exception):
@@ -67,39 +115,203 @@ class NNTPDataError(NNTPError):
"""Error in response data"""
pass
-# for backwards compatibility
-error_reply = NNTPReplyError
-error_temp = NNTPTemporaryError
-error_perm = NNTPPermanentError
-error_proto = NNTPProtocolError
-error_data = NNTPDataError
-
-
# Standard port used by NNTP servers
NNTP_PORT = 119
-
+NNTP_SSL_PORT = 563
# Response numbers that are followed by additional text (e.g. article)
-LONGRESP = [b'100', b'215', b'220', b'221', b'222', b'224', b'230', b'231', b'282']
-
+_LONGRESP = {
+ '100', # HELP
+ '101', # CAPABILITIES
+ '211', # LISTGROUP (also not multi-line with GROUP)
+ '215', # LIST
+ '220', # ARTICLE
+ '221', # HEAD, XHDR
+ '222', # BODY
+ '224', # OVER, XOVER
+ '225', # HDR
+ '230', # NEWNEWS
+ '231', # NEWGROUPS
+ '282', # XGTITLE
+}
+
+# Default decoded value for LIST OVERVIEW.FMT if not supported
+_DEFAULT_OVERVIEW_FMT = [
+ "subject", "from", "date", "message-id", "references", ":bytes", ":lines"]
+
+# Alternative names allowed in LIST OVERVIEW.FMT response
+_OVERVIEW_FMT_ALTERNATIVES = {
+ 'bytes': ':bytes',
+ 'lines': ':lines',
+}
# Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
-CRLF = b'\r\n'
+_CRLF = b'\r\n'
+GroupInfo = collections.namedtuple('GroupInfo',
+ ['group', 'last', 'first', 'flag'])
+ArticleInfo = collections.namedtuple('ArticleInfo',
+ ['number', 'message_id', 'lines'])
-# The class itself
-class NNTP:
- def __init__(self, host, port=NNTP_PORT, user=None, password=None,
- readermode=None, usenetrc=True):
+
+# Helper function(s)
+def decode_header(header_str):
+ """Takes an unicode string representing a munged header value
+ and decodes it as a (possibly non-ASCII) readable value."""
+ parts = []
+ for v, enc in _email_decode_header(header_str):
+ if isinstance(v, bytes):
+ parts.append(v.decode(enc or 'ascii'))
+ else:
+ parts.append(v)
+ return ' '.join(parts)
+
+def _parse_overview_fmt(lines):
+ """Parse a list of string representing the response to LIST OVERVIEW.FMT
+ and return a list of header/metadata names.
+ Raises NNTPDataError if the response is not compliant
+ (cf. RFC 3977, section 8.4)."""
+ fmt = []
+ for line in lines:
+ if line[0] == ':':
+ # Metadata name (e.g. ":bytes")
+ name, _, suffix = line[1:].partition(':')
+ name = ':' + name
+ else:
+ # Header name (e.g. "Subject:" or "Xref:full")
+ name, _, suffix = line.partition(':')
+ name = name.lower()
+ name = _OVERVIEW_FMT_ALTERNATIVES.get(name, name)
+ # Should we do something with the suffix?
+ fmt.append(name)
+ defaults = _DEFAULT_OVERVIEW_FMT
+ if len(fmt) < len(defaults):
+ raise NNTPDataError("LIST OVERVIEW.FMT response too short")
+ if fmt[:len(defaults)] != defaults:
+ raise NNTPDataError("LIST OVERVIEW.FMT redefines default fields")
+ return fmt
+
+def _parse_overview(lines, fmt, data_process_func=None):
+ """Parse the response to a OVER or XOVER command according to the
+ overview format `fmt`."""
+ n_defaults = len(_DEFAULT_OVERVIEW_FMT)
+ overview = []
+ for line in lines:
+ fields = {}
+ article_number, *tokens = line.split('\t')
+ article_number = int(article_number)
+ for i, token in enumerate(tokens):
+ if i >= len(fmt):
+ # XXX should we raise an error? Some servers might not
+ # support LIST OVERVIEW.FMT and still return additional
+ # headers.
+ continue
+ field_name = fmt[i]
+ is_metadata = field_name.startswith(':')
+ if i >= n_defaults and not is_metadata:
+ # Non-default header names are included in full in the response
+ # (unless the field is totally empty)
+ h = field_name + ": "
+ if token and token[:len(h)].lower() != h:
+ raise NNTPDataError("OVER/XOVER response doesn't include "
+ "names of additional headers")
+ token = token[len(h):] if token else None
+ fields[fmt[i]] = token
+ overview.append((article_number, fields))
+ return overview
+
+def _parse_datetime(date_str, time_str=None):
+ """Parse a pair of (date, time) strings, and return a datetime object.
+ If only the date is given, it is assumed to be date and time
+ concatenated together (e.g. response to the DATE command).
+ """
+ if time_str is None:
+ time_str = date_str[-6:]
+ date_str = date_str[:-6]
+ hours = int(time_str[:2])
+ minutes = int(time_str[2:4])
+ seconds = int(time_str[4:])
+ year = int(date_str[:-4])
+ month = int(date_str[-4:-2])
+ day = int(date_str[-2:])
+ # RFC 3977 doesn't say how to interpret 2-char years. Assume that
+ # there are no dates before 1970 on Usenet.
+ if year < 70:
+ year += 2000
+ elif year < 100:
+ year += 1900
+ return datetime.datetime(year, month, day, hours, minutes, seconds)
+
+def _unparse_datetime(dt, legacy=False):
+ """Format a date or datetime object as a pair of (date, time) strings
+ in the format required by the NEWNEWS and NEWGROUPS commands. If a
+ date object is passed, the time is assumed to be midnight (00h00).
+
+ The returned representation depends on the legacy flag:
+ * if legacy is False (the default):
+ date has the YYYYMMDD format and time the HHMMSS format
+ * if legacy is True:
+ date has the YYMMDD format and time the HHMMSS format.
+ RFC 3977 compliant servers should understand both formats; therefore,
+ legacy is only needed when talking to old servers.
+ """
+ if not isinstance(dt, datetime.datetime):
+ time_str = "000000"
+ else:
+ time_str = "{0.hour:02d}{0.minute:02d}{0.second:02d}".format(dt)
+ y = dt.year
+ if legacy:
+ y = y % 100
+ date_str = "{0:02d}{1.month:02d}{1.day:02d}".format(y, dt)
+ else:
+ date_str = "{0:04d}{1.month:02d}{1.day:02d}".format(y, dt)
+ return date_str, time_str
+
+
+if _have_ssl:
+
+ def _encrypt_on(sock, context):
+ """Wrap a socket in SSL/TLS. Arguments:
+ - sock: Socket to wrap
+ - context: SSL context to use for the encrypted connection
+ Returns:
+ - sock: New, encrypted socket.
+ """
+ # Generate a default SSL context if none was passed.
+ if context is None:
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ # SSLv2 considered harmful.
+ context.options |= ssl.OP_NO_SSLv2
+ return context.wrap_socket(sock)
+
+
+# The classes themselves
+class _NNTPBase:
+ # UTF-8 is the character set for all NNTP commands and responses: they
+ # are automatically encoded (when sending) and decoded (and receiving)
+ # by this class.
+ # However, some multi-line data blocks can contain arbitrary bytes (for
+ # example, latin-1 or utf-16 data in the body of a message). Commands
+ # taking (POST, IHAVE) or returning (HEAD, BODY, ARTICLE) raw message
+ # data will therefore only accept and produce bytes objects.
+ # Furthermore, since there could be non-compliant servers out there,
+ # we use 'surrogateescape' as the error handler for fault tolerance
+ # and easy round-tripping. This could be useful for some applications
+ # (e.g. NNTP gateways).
+
+ encoding = 'utf-8'
+ errors = 'surrogateescape'
+
+ def __init__(self, file, host,
+ readermode=None, timeout=_GLOBAL_DEFAULT_TIMEOUT):
"""Initialize an instance. Arguments:
- - host: hostname to connect to
- - port: port to connect to (default the standard NNTP port)
- - user: username to authenticate with
- - password: password to use with username
+ - file: file-like object (open for read/write in binary mode)
+ - host: hostname of the server
- readermode: if true, send 'mode reader' command after
connecting.
+ - timeout: timeout (in seconds) used for socket connections
readermode is sometimes necessary if you are connecting to an
NNTP server on the local machine and intend to call
@@ -108,65 +320,31 @@ class NNTP:
readermode.
"""
self.host = host
- self.port = port
- self.sock = socket.create_connection((host, port))
- self.file = self.sock.makefile('rb')
+ self.file = file
self.debugging = 0
- self.welcome = self.getresp()
-
- # 'mode reader' is sometimes necessary to enable 'reader' mode.
- # However, the order in which 'mode reader' and 'authinfo' need to
- # arrive differs between some NNTP servers. Try to send
- # 'mode reader', and if it fails with an authorization failed
- # error, try again after sending authinfo.
- readermode_afterauth = 0
+ self.welcome = self._getresp()
+
+ # 'MODE READER' is sometimes necessary to enable 'reader' mode.
+ # However, the order in which 'MODE READER' and 'AUTHINFO' need to
+ # arrive differs between some NNTP servers. If _setreadermode() fails
+ # with an authorization failed error, it will set this to True;
+ # the login() routine will interpret that as a request to try again
+ # after performing its normal function.
+ self.readermode_afterauth = False
if readermode:
- try:
- self.welcome = self.shortcmd('mode reader')
- except NNTPPermanentError:
- # error 500, probably 'not implemented'
- pass
- except NNTPTemporaryError as e:
- if user and e.response.startswith(b'480'):
- # Need authorization before 'mode reader'
- readermode_afterauth = 1
- else:
- raise
- # If no login/password was specified, try to get them from ~/.netrc
- # Presume that if .netc has an entry, NNRP authentication is required.
- try:
- if usenetrc and not user:
- import netrc
- credentials = netrc.netrc()
- auth = credentials.authenticators(host)
- if auth:
- user = auth[0]
- password = auth[2]
- except IOError:
- pass
- # Perform NNRP authentication if needed.
- if user:
- resp = self.shortcmd('authinfo user '+user)
- if resp.startswith(b'381'):
- if not password:
- raise NNTPReplyError(resp)
- else:
- resp = self.shortcmd(
- 'authinfo pass '+password)
- if not resp.startswith(b'281'):
- raise NNTPPermanentError(resp)
- if readermode_afterauth:
- try:
- self.welcome = self.shortcmd('mode reader')
- except NNTPPermanentError:
- # error 500, probably 'not implemented'
- pass
-
-
- # Get the welcome message from the server
- # (this is read and squirreled away by __init__()).
- # If the response code is 200, posting is allowed;
- # if it 201, posting is not allowed
+ self._setreadermode()
+
+ # RFC 4642 2.2.2: Both the client and the server MUST know if there is
+ # a TLS session active. A client MUST NOT attempt to start a TLS
+ # session if a TLS session is already active.
+ self.tls_on = False
+
+ # Inquire about capabilities (RFC 3977).
+ self._caps = None
+ self.getcapabilities()
+
+ # Log in and encryption setup order is left to subclasses.
+ self.authenticated = False
def getwelcome(self):
"""Get the welcome message from the server
@@ -177,6 +355,28 @@ class NNTP:
if self.debugging: print('*welcome*', repr(self.welcome))
return self.welcome
+ def getcapabilities(self):
+ """Get the server capabilities, as read by __init__().
+ If the CAPABILITIES command is not supported, an empty dict is
+ returned."""
+ if self._caps is None:
+ self.nntp_version = 1
+ self.nntp_implementation = None
+ try:
+ resp, caps = self.capabilities()
+ except NNTPPermanentError:
+ # Server doesn't support capabilities
+ self._caps = {}
+ else:
+ self._caps = caps
+ if 'VERSION' in caps:
+ # The server can advertise several supported versions,
+ # choose the highest.
+ self.nntp_version = max(map(int, caps['VERSION']))
+ if 'IMPLEMENTATION' in caps:
+ self.nntp_implementation = ' '.join(caps['IMPLEMENTATION'])
+ return self._caps
+
def set_debuglevel(self, level):
"""Set the debugging level. Argument 'level' means:
0: no debugging output (default)
@@ -186,121 +386,226 @@ class NNTP:
self.debugging = level
debug = set_debuglevel
- def putline(self, line):
- """Internal: send one line to the server, appending CRLF."""
- line = line + CRLF
+ def _putline(self, line):
+ """Internal: send one line to the server, appending CRLF.
+ The `line` must be a bytes-like object."""
+ line = line + _CRLF
if self.debugging > 1: print('*put*', repr(line))
- self.sock.sendall(line)
+ self.file.write(line)
+ self.file.flush()
- def putcmd(self, line):
- """Internal: send one command to the server (through putline())."""
+ def _putcmd(self, line):
+ """Internal: send one command to the server (through _putline()).
+ The `line` must be an unicode string."""
if self.debugging: print('*cmd*', repr(line))
- line = bytes(line, "ASCII")
- self.putline(line)
+ line = line.encode(self.encoding, self.errors)
+ self._putline(line)
- def getline(self):
- """Internal: return one line from the server, stripping CRLF.
- Raise EOFError if the connection is closed."""
+ def _getline(self, strip_crlf=True):
+ """Internal: return one line from the server, stripping _CRLF.
+ Raise EOFError if the connection is closed.
+ Returns a bytes object."""
line = self.file.readline()
if self.debugging > 1:
print('*get*', repr(line))
if not line: raise EOFError
- if line[-2:] == CRLF:
- line = line[:-2]
- elif line[-1:] in CRLF:
- line = line[:-1]
+ if strip_crlf:
+ if line[-2:] == _CRLF:
+ line = line[:-2]
+ elif line[-1:] in _CRLF:
+ line = line[:-1]
return line
- def getresp(self):
+ def _getresp(self):
"""Internal: get a response from the server.
- Raise various errors if the response indicates an error."""
- resp = self.getline()
+ Raise various errors if the response indicates an error.
+ Returns an unicode string."""
+ resp = self._getline()
if self.debugging: print('*resp*', repr(resp))
+ resp = resp.decode(self.encoding, self.errors)
c = resp[:1]
- if c == b'4':
+ if c == '4':
raise NNTPTemporaryError(resp)
- if c == b'5':
+ if c == '5':
raise NNTPPermanentError(resp)
- if c not in b'123':
+ if c not in '123':
raise NNTPProtocolError(resp)
return resp
- def getlongresp(self, file=None):
+ def _getlongresp(self, file=None):
"""Internal: get a response plus following text from the server.
- Raise various errors if the response indicates an error."""
+ Raise various errors if the response indicates an error.
+
+ Returns a (response, lines) tuple where `response` is an unicode
+ string and `lines` is a list of bytes objects.
+ If `file` is a file-like object, it must be open in binary mode.
+ """
openedFile = None
try:
# If a string was passed then open a file with that name
- if isinstance(file, str):
- openedFile = file = open(file, "w")
+ if isinstance(file, (str, bytes)):
+ openedFile = file = open(file, "wb")
- resp = self.getresp()
- if resp[:3] not in LONGRESP:
+ resp = self._getresp()
+ if resp[:3] not in _LONGRESP:
raise NNTPReplyError(resp)
- list = []
- while 1:
- line = self.getline()
- if line == b'.':
- break
- if line.startswith(b'..'):
- line = line[1:]
- if file:
- file.write(line + b'\n')
- else:
- list.append(line)
+
+ lines = []
+ if file is not None:
+ # XXX lines = None instead?
+ terminators = (b'.' + _CRLF, b'.\n')
+ while 1:
+ line = self._getline(False)
+ if line in terminators:
+ break
+ if line.startswith(b'..'):
+ line = line[1:]
+ file.write(line)
+ else:
+ terminator = b'.'
+ while 1:
+ line = self._getline()
+ if line == terminator:
+ break
+ if line.startswith(b'..'):
+ line = line[1:]
+ lines.append(line)
finally:
# If this method created the file, then it must close it
if openedFile:
openedFile.close()
- return resp, list
+ return resp, lines
- def shortcmd(self, line):
- """Internal: send a command and get the response."""
- self.putcmd(line)
- return self.getresp()
+ def _shortcmd(self, line):
+ """Internal: send a command and get the response.
+ Same return value as _getresp()."""
+ self._putcmd(line)
+ return self._getresp()
+
+ def _longcmd(self, line, file=None):
+ """Internal: send a command and get the response plus following text.
+ Same return value as _getlongresp()."""
+ self._putcmd(line)
+ return self._getlongresp(file)
+
+ def _longcmdstring(self, line, file=None):
+ """Internal: send a command and get the response plus following text.
+ Same as _longcmd() and _getlongresp(), except that the returned `lines`
+ are unicode strings rather than bytes objects.
+ """
+ self._putcmd(line)
+ resp, list = self._getlongresp(file)
+ return resp, [line.decode(self.encoding, self.errors)
+ for line in list]
+
+ def _getoverviewfmt(self):
+ """Internal: get the overview format. Queries the server if not
+ already done, else returns the cached value."""
+ try:
+ return self._cachedoverviewfmt
+ except AttributeError:
+ pass
+ try:
+ resp, lines = self._longcmdstring("LIST OVERVIEW.FMT")
+ except NNTPPermanentError:
+ # Not supported by server?
+ fmt = _DEFAULT_OVERVIEW_FMT[:]
+ else:
+ fmt = _parse_overview_fmt(lines)
+ self._cachedoverviewfmt = fmt
+ return fmt
- def longcmd(self, line, file=None):
- """Internal: send a command and get the response plus following text."""
- self.putcmd(line)
- return self.getlongresp(file)
+ def _grouplist(self, lines):
+ # Parse lines into "group last first flag"
+ return [GroupInfo(*line.split()) for line in lines]
- def newgroups(self, date, time, file=None):
- """Process a NEWGROUPS command. Arguments:
- - date: string 'yymmdd' indicating the date
- - time: string 'hhmmss' indicating the time
+ def capabilities(self):
+ """Process a CAPABILITIES command. Not supported by all servers.
Return:
- resp: server response if successful
- - list: list of newsgroup names"""
-
- return self.longcmd('NEWGROUPS ' + date + ' ' + time, file)
+ - caps: a dictionary mapping capability names to lists of tokens
+ (for example {'VERSION': ['2'], 'OVER': [], LIST: ['ACTIVE', 'HEADERS'] })
+ """
+ caps = {}
+ resp, lines = self._longcmdstring("CAPABILITIES")
+ for line in lines:
+ name, *tokens = line.split()
+ caps[name] = tokens
+ return resp, caps
- def newnews(self, group, date, time, file=None):
+ def newgroups(self, date, *, file=None):
+ """Process a NEWGROUPS command. Arguments:
+ - date: a date or datetime object
+ Return:
+ - resp: server response if successful
+ - list: list of newsgroup names
+ """
+ if not isinstance(date, (datetime.date, datetime.date)):
+ raise TypeError(
+ "the date parameter must be a date or datetime object, "
+ "not '{:40}'".format(date.__class__.__name__))
+ date_str, time_str = _unparse_datetime(date, self.nntp_version < 2)
+ cmd = 'NEWGROUPS {0} {1}'.format(date_str, time_str)
+ resp, lines = self._longcmdstring(cmd, file)
+ return resp, self._grouplist(lines)
+
+ def newnews(self, group, date, *, file=None):
"""Process a NEWNEWS command. Arguments:
- group: group name or '*'
- - date: string 'yymmdd' indicating the date
- - time: string 'hhmmss' indicating the time
+ - date: a date or datetime object
Return:
- resp: server response if successful
- - list: list of message ids"""
-
- cmd = 'NEWNEWS ' + group + ' ' + date + ' ' + time
- return self.longcmd(cmd, file)
-
- def list(self, file=None):
- """Process a LIST command. Return:
+ - list: list of message ids
+ """
+ if not isinstance(date, (datetime.date, datetime.date)):
+ raise TypeError(
+ "the date parameter must be a date or datetime object, "
+ "not '{:40}'".format(date.__class__.__name__))
+ date_str, time_str = _unparse_datetime(date, self.nntp_version < 2)
+ cmd = 'NEWNEWS {0} {1} {2}'.format(group, date_str, time_str)
+ return self._longcmdstring(cmd, file)
+
+ def list(self, group_pattern=None, *, file=None):
+ """Process a LIST or LIST ACTIVE command. Arguments:
+ - group_pattern: a pattern indicating which groups to query
+ - file: Filename string or file object to store the result in
+ Returns:
- resp: server response if successful
- - list: list of (group, last, first, flag) (strings)"""
+ - list: list of (group, last, first, flag) (strings)
+ """
+ if group_pattern is not None:
+ command = 'LIST ACTIVE ' + group_pattern
+ else:
+ command = 'LIST'
+ resp, lines = self._longcmdstring(command, file)
+ return resp, self._grouplist(lines)
- resp, list = self.longcmd('LIST', file)
- for i in range(len(list)):
- # Parse lines into "group last first flag"
- list[i] = tuple(list[i].split())
- return resp, list
+ def _getdescriptions(self, group_pattern, return_all):
+ line_pat = re.compile('^(?P<group>[^ \t]+)[ \t]+(.*)$')
+ # Try the more std (acc. to RFC2980) LIST NEWSGROUPS first
+ resp, lines = self._longcmdstring('LIST NEWSGROUPS ' + group_pattern)
+ if not resp.startswith('215'):
+ # Now the deprecated XGTITLE. This either raises an error
+ # or succeeds with the same output structure as LIST
+ # NEWSGROUPS.
+ resp, lines = self._longcmdstring('XGTITLE ' + group_pattern)
+ groups = {}
+ for raw_line in lines:
+ match = line_pat.search(raw_line.strip())
+ if match:
+ name, desc = match.group(1, 2)
+ if not return_all:
+ return desc
+ groups[name] = desc
+ if return_all:
+ return resp, groups
+ else:
+ # Nothing found
+ return ''
def description(self, group):
-
"""Get a description for a single group. If more than one
group matches ('group' is a pattern), return the first. If no
group matches, return an empty string.
@@ -311,42 +616,24 @@ class NNTP:
NOTE: This neither checks for a wildcard in 'group' nor does
it check whether the group actually exists."""
-
- resp, lines = self.descriptions(group)
- if len(lines) == 0:
- return b''
- else:
- return lines[0][1]
+ return self._getdescriptions(group, False)
def descriptions(self, group_pattern):
"""Get descriptions for a range of groups."""
- line_pat = re.compile(b'^(?P<group>[^ \t]+)[ \t]+(.*)$')
- # Try the more std (acc. to RFC2980) LIST NEWSGROUPS first
- resp, raw_lines = self.longcmd('LIST NEWSGROUPS ' + group_pattern)
- if not resp.startswith(b'215'):
- # Now the deprecated XGTITLE. This either raises an error
- # or succeeds with the same output structure as LIST
- # NEWSGROUPS.
- resp, raw_lines = self.longcmd('XGTITLE ' + group_pattern)
- lines = []
- for raw_line in raw_lines:
- match = line_pat.search(raw_line.strip())
- if match:
- lines.append(match.group(1, 2))
- return resp, lines
+ return self._getdescriptions(group_pattern, True)
def group(self, name):
"""Process a GROUP command. Argument:
- group: the group name
Returns:
- resp: server response if successful
- - count: number of articles (string)
- - first: first article number (string)
- - last: last article number (string)
- - name: the group name"""
-
- resp = self.shortcmd('GROUP ' + name)
- if not resp.startswith(b'211'):
+ - count: number of articles
+ - first: first article number
+ - last: last article number
+ - name: the group name
+ """
+ resp = self._shortcmd('GROUP ' + name)
+ if not resp.startswith('211'):
raise NNTPReplyError(resp)
words = resp.split()
count = first = last = 0
@@ -359,151 +646,177 @@ class NNTP:
last = words[3]
if n > 4:
name = words[4].lower()
- return resp, count, first, last, name
+ return resp, int(count), int(first), int(last), name
- def help(self, file=None):
- """Process a HELP command. Returns:
+ def help(self, *, file=None):
+ """Process a HELP command. Argument:
+ - file: Filename string or file object to store the result in
+ Returns:
- resp: server response if successful
- - list: list of strings"""
-
- return self.longcmd('HELP',file)
+ - list: list of strings returned by the server in response to the
+ HELP command
+ """
+ return self._longcmdstring('HELP', file)
- def statparse(self, resp):
- """Internal: parse the response of a STAT, NEXT or LAST command."""
- if not resp.startswith(b'22'):
+ def _statparse(self, resp):
+ """Internal: parse the response line of a STAT, NEXT, LAST,
+ ARTICLE, HEAD or BODY command."""
+ if not resp.startswith('22'):
raise NNTPReplyError(resp)
words = resp.split()
- nr = 0
- id = b''
- n = len(words)
- if n > 1:
- nr = words[1]
- if n > 2:
- id = words[2]
- return resp, nr, id
+ art_num = int(words[1])
+ message_id = words[2]
+ return resp, art_num, message_id
- def statcmd(self, line):
+ def _statcmd(self, line):
"""Internal: process a STAT, NEXT or LAST command."""
- resp = self.shortcmd(line)
- return self.statparse(resp)
+ resp = self._shortcmd(line)
+ return self._statparse(resp)
- def stat(self, id):
+ def stat(self, message_spec=None):
"""Process a STAT command. Argument:
- - id: article number or message id
+ - message_spec: article number or message id (if not specified,
+ the current article is selected)
Returns:
- resp: server response if successful
- - nr: the article number
- - id: the message id"""
-
- return self.statcmd('STAT {0}'.format(id))
+ - art_num: the article number
+ - message_id: the message id
+ """
+ if message_spec:
+ return self._statcmd('STAT {0}'.format(message_spec))
+ else:
+ return self._statcmd('STAT')
def next(self):
"""Process a NEXT command. No arguments. Return as for STAT."""
- return self.statcmd('NEXT')
+ return self._statcmd('NEXT')
def last(self):
"""Process a LAST command. No arguments. Return as for STAT."""
- return self.statcmd('LAST')
+ return self._statcmd('LAST')
- def artcmd(self, line, file=None):
+ def _artcmd(self, line, file=None):
"""Internal: process a HEAD, BODY or ARTICLE command."""
- resp, list = self.longcmd(line, file)
- resp, nr, id = self.statparse(resp)
- return resp, nr, id, list
+ resp, lines = self._longcmd(line, file)
+ resp, art_num, message_id = self._statparse(resp)
+ return resp, ArticleInfo(art_num, message_id, lines)
- def head(self, id):
+ def head(self, message_spec=None, *, file=None):
"""Process a HEAD command. Argument:
- - id: article number or message id
+ - message_spec: article number or message id
+ - file: filename string or file object to store the headers in
Returns:
- resp: server response if successful
- - nr: article number
- - id: message id
- - list: the lines of the article's header"""
-
- return self.artcmd('HEAD {0}'.format(id))
+ - ArticleInfo: (article number, message id, list of header lines)
+ """
+ if message_spec is not None:
+ cmd = 'HEAD {0}'.format(message_spec)
+ else:
+ cmd = 'HEAD'
+ return self._artcmd(cmd, file)
- def body(self, id, file=None):
+ def body(self, message_spec=None, *, file=None):
"""Process a BODY command. Argument:
- - id: article number or message id
- - file: Filename string or file object to store the article in
+ - message_spec: article number or message id
+ - file: filename string or file object to store the body in
Returns:
- resp: server response if successful
- - nr: article number
- - id: message id
- - list: the lines of the article's body or an empty list
- if file was used"""
-
- return self.artcmd('BODY {0}'.format(id), file)
+ - ArticleInfo: (article number, message id, list of body lines)
+ """
+ if message_spec is not None:
+ cmd = 'BODY {0}'.format(message_spec)
+ else:
+ cmd = 'BODY'
+ return self._artcmd(cmd, file)
- def article(self, id):
+ def article(self, message_spec=None, *, file=None):
"""Process an ARTICLE command. Argument:
- - id: article number or message id
+ - message_spec: article number or message id
+ - file: filename string or file object to store the article in
Returns:
- resp: server response if successful
- - nr: article number
- - id: message id
- - list: the lines of the article"""
-
- return self.artcmd('ARTICLE {0}'.format(id))
+ - ArticleInfo: (article number, message id, list of article lines)
+ """
+ if message_spec is not None:
+ cmd = 'ARTICLE {0}'.format(message_spec)
+ else:
+ cmd = 'ARTICLE'
+ return self._artcmd(cmd, file)
def slave(self):
"""Process a SLAVE command. Returns:
- - resp: server response if successful"""
-
- return self.shortcmd('SLAVE')
+ - resp: server response if successful
+ """
+ return self._shortcmd('SLAVE')
- def xhdr(self, hdr, str, file=None):
+ def xhdr(self, hdr, str, *, file=None):
"""Process an XHDR command (optional server extension). Arguments:
- hdr: the header type (e.g. 'subject')
- str: an article nr, a message id, or a range nr1-nr2
+ - file: Filename string or file object to store the result in
Returns:
- resp: server response if successful
- - list: list of (nr, value) strings"""
-
- pat = re.compile(b'^([0-9]+) ?(.*)\n?')
- resp, lines = self.longcmd('XHDR {0} {1}'.format(hdr, str), file)
- for i in range(len(lines)):
- line = lines[i]
+ - list: list of (nr, value) strings
+ """
+ pat = re.compile('^([0-9]+) ?(.*)\n?')
+ resp, lines = self._longcmdstring('XHDR {0} {1}'.format(hdr, str), file)
+ def remove_number(line):
m = pat.match(line)
- if m:
- lines[i] = m.group(1, 2)
- return resp, lines
+ return m.group(1, 2) if m else line
+ return resp, [remove_number(line) for line in lines]
- def xover(self, start, end, file=None):
+ def xover(self, start, end, *, file=None):
"""Process an XOVER command (optional server extension) Arguments:
- start: start of range
- end: end of range
+ - file: Filename string or file object to store the result in
Returns:
- resp: server response if successful
- - list: list of (art-nr, subject, poster, date,
- id, references, size, lines)"""
+ - list: list of dicts containing the response fields
+ """
+ resp, lines = self._longcmdstring('XOVER {0}-{1}'.format(start, end),
+ file)
+ fmt = self._getoverviewfmt()
+ return resp, _parse_overview(lines, fmt)
+
+ def over(self, message_spec, *, file=None):
+ """Process an OVER command. If the command isn't supported, fall
+ back to XOVER. Arguments:
+ - message_spec:
+ - either a message id, indicating the article to fetch
+ information about
+ - or a (start, end) tuple, indicating a range of article numbers;
+ if end is None, information up to the newest message will be
+ retrieved
+ - or None, indicating the current article number must be used
+ - file: Filename string or file object to store the result in
+ Returns:
+ - resp: server response if successful
+ - list: list of dicts containing the response fields
- resp, lines = self.longcmd('XOVER {0}-{1}'.format(start, end), file)
- xover_lines = []
- for line in lines:
- elem = line.split(b'\t')
- try:
- xover_lines.append((elem[0],
- elem[1],
- elem[2],
- elem[3],
- elem[4],
- elem[5].split(),
- elem[6],
- elem[7]))
- except IndexError:
- raise NNTPDataError(line)
- return resp,xover_lines
-
- def xgtitle(self, group, file=None):
+ NOTE: the "message id" form isn't supported by XOVER
+ """
+ cmd = 'OVER' if 'OVER' in self._caps else 'XOVER'
+ if isinstance(message_spec, (tuple, list)):
+ start, end = message_spec
+ cmd += ' {0}-{1}'.format(start, end or '')
+ elif message_spec is not None:
+ cmd = cmd + ' ' + message_spec
+ resp, lines = self._longcmdstring(cmd, file)
+ fmt = self._getoverviewfmt()
+ return resp, _parse_overview(lines, fmt)
+
+ def xgtitle(self, group, *, file=None):
"""Process an XGTITLE command (optional server extension) Arguments:
- group: group name wildcard (i.e. news.*)
Returns:
- resp: server response if successful
- list: list of (name,title) strings"""
-
- line_pat = re.compile(b'^([^ \t]+)[ \t]+(.*)$')
- resp, raw_lines = self.longcmd('XGTITLE ' + group, file)
+ warnings.warn("The XGTITLE extension is not actively used, "
+ "use descriptions() instead",
+ PendingDeprecationWarning, 2)
+ line_pat = re.compile('^([^ \t]+)[ \t]+(.*)$')
+ resp, raw_lines = self._longcmdstring('XGTITLE ' + group, file)
lines = []
for raw_line in raw_lines:
match = line_pat.search(raw_line.strip())
@@ -511,15 +824,18 @@ class NNTP:
lines.append(match.group(1, 2))
return resp, lines
- def xpath(self,id):
+ def xpath(self, id):
"""Process an XPATH command (optional server extension) Arguments:
- id: Message id of article
Returns:
resp: server response if successful
- path: directory path to article"""
+ path: directory path to article
+ """
+ warnings.warn("The XPATH extension is not actively used",
+ PendingDeprecationWarning, 2)
- resp = self.shortcmd('XPATH {0}'.format(id))
- if not resp.startswith(b'223'):
+ resp = self._shortcmd('XPATH {0}'.format(id))
+ if not resp.startswith('223'):
raise NNTPReplyError(resp)
try:
[resp_num, path] = resp.split()
@@ -528,89 +844,258 @@ class NNTP:
else:
return resp, path
- def date (self):
- """Process the DATE command. Arguments:
- None
+ def date(self):
+ """Process the DATE command.
Returns:
- resp: server response if successful
- date: Date suitable for newnews/newgroups commands etc.
- time: Time suitable for newnews/newgroups commands etc."""
-
- resp = self.shortcmd("DATE")
- if not resp.startswith(b'111'):
+ - resp: server response if successful
+ - date: datetime object
+ """
+ resp = self._shortcmd("DATE")
+ if not resp.startswith('111'):
raise NNTPReplyError(resp)
elem = resp.split()
if len(elem) != 2:
raise NNTPDataError(resp)
- date = elem[1][2:8]
- time = elem[1][-6:]
- if len(date) != 6 or len(time) != 6:
+ date = elem[1]
+ if len(date) != 14:
raise NNTPDataError(resp)
- return resp, date, time
+ return resp, _parse_datetime(date, None)
def _post(self, command, f):
- resp = self.shortcmd(command)
- # Raises error_??? if posting is not allowed
- if not resp.startswith(b'3'):
+ resp = self._shortcmd(command)
+ # Raises a specific exception if posting is not allowed
+ if not resp.startswith('3'):
raise NNTPReplyError(resp)
- while 1:
- line = f.readline()
- if not line:
- break
- if line.endswith(b'\n'):
- line = line[:-1]
+ if isinstance(f, (bytes, bytearray)):
+ f = f.splitlines()
+ # We don't use _putline() because:
+ # - we don't want additional CRLF if the file or iterable is already
+ # in the right format
+ # - we don't want a spurious flush() after each line is written
+ for line in f:
+ if not line.endswith(_CRLF):
+ line = line.rstrip(b"\r\n") + _CRLF
if line.startswith(b'.'):
line = b'.' + line
- self.putline(line)
- self.putline(b'.')
- return self.getresp()
+ self.file.write(line)
+ self.file.write(b".\r\n")
+ self.file.flush()
+ return self._getresp()
- def post(self, f):
+ def post(self, data):
"""Process a POST command. Arguments:
- - f: file containing the article
+ - data: bytes object, iterable or file containing the article
Returns:
- resp: server response if successful"""
- return self._post('POST', f)
+ return self._post('POST', data)
- def ihave(self, id, f):
+ def ihave(self, message_id, data):
"""Process an IHAVE command. Arguments:
- - id: message-id of the article
- - f: file containing the article
+ - message_id: message-id of the article
+ - data: file containing the article
Returns:
- resp: server response if successful
Note that if the server refuses the article an exception is raised."""
- return self._post('IHAVE {0}'.format(id), f)
+ return self._post('IHAVE {0}'.format(message_id), data)
+
+ def _close(self):
+ self.file.close()
+ del self.file
def quit(self):
"""Process a QUIT command and close the socket. Returns:
- resp: server response if successful"""
-
- resp = self.shortcmd('QUIT')
- self.file.close()
- self.sock.close()
- del self.file, self.sock
+ try:
+ resp = self._shortcmd('QUIT')
+ finally:
+ self._close()
return resp
+ def login(self, user=None, password=None, usenetrc=True):
+ if self.authenticated:
+ raise ValueError("Already logged in.")
+ if not user and not usenetrc:
+ raise ValueError(
+ "At least one of `user` and `usenetrc` must be specified")
+ # If no login/password was specified but netrc was requested,
+ # try to get them from ~/.netrc
+ # Presume that if .netrc has an entry, NNRP authentication is required.
+ try:
+ if usenetrc and not user:
+ import netrc
+ credentials = netrc.netrc()
+ auth = credentials.authenticators(self.host)
+ if auth:
+ user = auth[0]
+ password = auth[2]
+ except IOError:
+ pass
+ # Perform NNTP authentication if needed.
+ if not user:
+ return
+ resp = self._shortcmd('authinfo user ' + user)
+ if resp.startswith('381'):
+ if not password:
+ raise NNTPReplyError(resp)
+ else:
+ resp = self._shortcmd('authinfo pass ' + password)
+ if not resp.startswith('281'):
+ raise NNTPPermanentError(resp)
+ # Attempt to send mode reader if it was requested after login.
+ if self.readermode_afterauth:
+ self._setreadermode()
+
+ def _setreadermode(self):
+ try:
+ self.welcome = self._shortcmd('mode reader')
+ except NNTPPermanentError:
+ # Error 5xx, probably 'not implemented'
+ pass
+ except NNTPTemporaryError as e:
+ if e.response.startswith('480'):
+ # Need authorization before 'mode reader'
+ self.readermode_afterauth = True
+ else:
+ raise
+
+ if _have_ssl:
+ def starttls(self, context=None):
+ """Process a STARTTLS command. Arguments:
+ - context: SSL context to use for the encrypted connection
+ """
+ # Per RFC 4642, STARTTLS MUST NOT be sent after authentication or if
+ # a TLS session already exists.
+ if self.tls_on:
+ raise ValueError("TLS is already enabled.")
+ if self.authenticated:
+ raise ValueError("TLS cannot be started after authentication.")
+ resp = self._shortcmd('STARTTLS')
+ if resp.startswith('382'):
+ self.file.close()
+ self.sock = _encrypt_on(self.sock, context)
+ self.file = self.sock.makefile("rwb")
+ self.tls_on = True
+ # Capabilities may change after TLS starts up, so ask for them
+ # again.
+ self._caps = None
+ self.getcapabilities()
+ else:
+ raise NNTPError("TLS failed to start.")
+
+
+class NNTP(_NNTPBase):
+
+ def __init__(self, host, port=NNTP_PORT, user=None, password=None,
+ readermode=None, usenetrc=False,
+ timeout=_GLOBAL_DEFAULT_TIMEOUT):
+ """Initialize an instance. Arguments:
+ - host: hostname to connect to
+ - port: port to connect to (default the standard NNTP port)
+ - user: username to authenticate with
+ - password: password to use with username
+ - readermode: if true, send 'mode reader' command after
+ connecting.
+ - usenetrc: allow loading username and password from ~/.netrc file
+ if not specified explicitly
+ - timeout: timeout (in seconds) used for socket connections
+
+ readermode is sometimes necessary if you are connecting to an
+ NNTP server on the local machine and intend to call
+ reader-specific commands, such as `group'. If you get
+ unexpected NNTPPermanentErrors, you might need to set
+ readermode.
+ """
+ self.host = host
+ self.port = port
+ self.sock = socket.create_connection((host, port), timeout)
+ file = self.sock.makefile("rwb")
+ _NNTPBase.__init__(self, file, host,
+ readermode, timeout)
+ if user or usenetrc:
+ self.login(user, password, usenetrc)
+
+ def _close(self):
+ try:
+ _NNTPBase._close(self)
+ finally:
+ self.sock.close()
+
+
+if _have_ssl:
+ class NNTP_SSL(_NNTPBase):
+
+ def __init__(self, host, port=NNTP_SSL_PORT,
+ user=None, password=None, ssl_context=None,
+ readermode=None, usenetrc=False,
+ timeout=_GLOBAL_DEFAULT_TIMEOUT):
+ """This works identically to NNTP.__init__, except for the change
+ in default port and the `ssl_context` argument for SSL connections.
+ """
+ self.sock = socket.create_connection((host, port), timeout)
+ self.sock = _encrypt_on(self.sock, ssl_context)
+ file = self.sock.makefile("rwb")
+ _NNTPBase.__init__(self, file, host,
+ readermode=readermode, timeout=timeout)
+ if user or usenetrc:
+ self.login(user, password, usenetrc)
+
+ def _close(self):
+ try:
+ _NNTPBase._close(self)
+ finally:
+ self.sock.close()
+
+ __all__.append("NNTP_SSL")
+
# Test retrieval when run as a script.
-# Assumption: if there's a local news server, it's called 'news'.
-# Assumption: if user queries a remote news server, it's named
-# in the environment variable NNTPSERVER (used by slrn and kin)
-# and we want readermode off.
if __name__ == '__main__':
- import os
- newshost = 'news' and os.environ["NNTPSERVER"]
- if newshost.find('.') == -1:
- mode = 'readermode'
+ import argparse
+ from email.utils import parsedate
+
+ parser = argparse.ArgumentParser(description="""\
+ nntplib built-in demo - display the latest articles in a newsgroup""")
+ parser.add_argument('-g', '--group', default='gmane.comp.python.general',
+ help='group to fetch messages from (default: %(default)s)')
+ parser.add_argument('-s', '--server', default='news.gmane.org',
+ help='NNTP server hostname (default: %(default)s)')
+ parser.add_argument('-p', '--port', default=-1, type=int,
+ help='NNTP port number (default: %s / %s)' % (NNTP_PORT, NNTP_SSL_PORT))
+ parser.add_argument('-n', '--nb-articles', default=10, type=int,
+ help='number of articles to fetch (default: %(default)s)')
+ parser.add_argument('-S', '--ssl', action='store_true', default=False,
+ help='use NNTP over SSL')
+ args = parser.parse_args()
+
+ port = args.port
+ if not args.ssl:
+ if port == -1:
+ port = NNTP_PORT
+ s = NNTP(host=args.server, port=port)
else:
- mode = None
- s = NNTP(newshost, readermode=mode)
- resp, count, first, last, name = s.group('comp.lang.python')
- print(resp)
+ if port == -1:
+ port = NNTP_SSL_PORT
+ s = NNTP_SSL(host=args.server, port=port)
+
+ caps = s.getcapabilities()
+ if 'STARTTLS' in caps:
+ s.starttls()
+ resp, count, first, last, name = s.group(args.group)
print('Group', name, 'has', count, 'articles, range', first, 'to', last)
- resp, subs = s.xhdr('subject', '{0}-{1}'.format(first, last))
- print(resp)
- for item in subs:
- print("%7s %s" % item)
- resp = s.quit()
- print(resp)
+
+ def cut(s, lim):
+ if len(s) > lim:
+ s = s[:lim - 4] + "..."
+ return s
+
+ first = str(int(last) - args.nb_articles + 1)
+ resp, overviews = s.xover(first, last)
+ for artnum, over in overviews:
+ author = decode_header(over['from']).split('<', 1)[0]
+ subject = decode_header(over['subject'])
+ lines = int(over[':lines'])
+ print("{:7} {:20} {:42} ({})".format(
+ artnum, cut(author, 20), cut(subject, 42), lines)
+ )
+
+ s.quit()
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index ae9dcf2eaf..419342d0c1 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -16,7 +16,8 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"getatime","getctime", "islink","exists","lexists","isdir","isfile",
"ismount", "expanduser","expandvars","normpath","abspath",
"splitunc","curdir","pardir","sep","pathsep","defpath","altsep",
- "extsep","devnull","realpath","supports_unicode_filenames","relpath"]
+ "extsep","devnull","realpath","supports_unicode_filenames","relpath",
+ "samefile", "sameopenfile",]
# strings representing various path-related bits and pieces
# These are primarily for export; internally, they are hardcoded.
@@ -84,6 +85,9 @@ def normcase(s):
"""Normalize case of pathname.
Makes all characters lowercase and all slashes into backslashes."""
+ if not isinstance(s, (bytes, str)):
+ raise TypeError("normcase() argument must be str or bytes, "
+ "not '{}'".format(s.__class__.__name__))
return s.replace(_get_altsep(s), _get_sep(s)).lower()
@@ -239,7 +243,7 @@ def splitunc(p):
"""
import warnings
warnings.warn("ntpath.splitunc is deprecated, use ntpath.splitdrive instead",
- PendingDeprecationWarning)
+ DeprecationWarning)
sep = _get_sep(p)
if not p[1:2]:
return p[:0], p # Drive letter present
@@ -312,16 +316,28 @@ def dirname(p):
return split(p)[0]
# Is a path a symbolic link?
-# This will always return false on systems where posix.lstat doesn't exist.
+# This will always return false on systems where os.lstat doesn't exist.
def islink(path):
- """Test for symbolic link.
- On WindowsNT/95 and OS/2 always returns false
+ """Test whether a path is a symbolic link.
+ This will always return false for Windows prior to 6.0
+ and for OS/2.
"""
- return False
-
-# alias exists to lexists
-lexists = exists
+ try:
+ st = os.lstat(path)
+ except (os.error, AttributeError):
+ return False
+ return stat.S_ISLNK(st.st_mode)
+
+# Being true for dangling symbolic links is also useful.
+
+def lexists(path):
+ """Test whether a path exists. Returns True for broken symbolic links"""
+ try:
+ st = os.lstat(path)
+ except (os.error, WindowsError):
+ return False
+ return True
# Is a path a mount point? Either a root (with or without drive letter)
# or an UNC path with at most a / or \ after the mount point.
@@ -622,3 +638,37 @@ def relpath(path, start=curdir):
if not rel_list:
return _get_dot(path)
return join(*rel_list)
+
+
+# determine if two files are in fact the same file
+try:
+ # GetFinalPathNameByHandle is available starting with Windows 6.0.
+ # Windows XP and non-Windows OS'es will mock _getfinalpathname.
+ if sys.getwindowsversion()[:2] >= (6, 0):
+ from nt import _getfinalpathname
+ else:
+ raise ImportError
+except (AttributeError, ImportError):
+ # On Windows XP and earlier, two files are the same if their absolute
+ # pathnames are the same.
+ # Non-Windows operating systems fake this method with an XP
+ # approximation.
+ def _getfinalpathname(f):
+ return abspath(f)
+
+def samefile(f1, f2):
+ "Test whether two pathnames reference the same actual file"
+ return _getfinalpathname(f1) == _getfinalpathname(f2)
+
+
+try:
+ from nt import _getfileinformation
+except ImportError:
+ # On other operating systems, just return the fd and see that
+ # it compares equal in sameopenfile.
+ def _getfileinformation(fd):
+ return fd
+
+def sameopenfile(f1, f2):
+ """Test whether two file objects reference the same file"""
+ return _getfileinformation(f1) == _getfileinformation(f2)
diff --git a/Lib/numbers.py b/Lib/numbers.py
index 201dc3cc2b..f35704dd39 100644
--- a/Lib/numbers.py
+++ b/Lib/numbers.py
@@ -303,7 +303,7 @@ class Integral(Rational):
raise NotImplementedError
def __index__(self):
- """index(self)"""
+ """someobject[self]"""
return int(self)
@abstractmethod
diff --git a/Lib/opcode.py b/Lib/opcode.py
index 86ebc5c564..8e15d13e98 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -48,7 +48,7 @@ def_op('POP_TOP', 1)
def_op('ROT_TWO', 2)
def_op('ROT_THREE', 3)
def_op('DUP_TOP', 4)
-def_op('ROT_FOUR', 5)
+def_op('DUP_TOP_TWO', 5)
def_op('NOP', 9)
def_op('UNARY_POSITIVE', 10)
@@ -116,7 +116,6 @@ name_op('STORE_ATTR', 95) # Index in name list
name_op('DELETE_ATTR', 96) # ""
name_op('STORE_GLOBAL', 97) # ""
name_op('DELETE_GLOBAL', 98) # ""
-def_op('DUP_TOPX', 99) # number of items to duplicate
def_op('LOAD_CONST', 100) # Index in const list
hasconst.append(100)
name_op('LOAD_NAME', 101) # Index in name list
@@ -162,16 +161,20 @@ def_op('LOAD_DEREF', 136)
hasfree.append(136)
def_op('STORE_DEREF', 137)
hasfree.append(137)
+def_op('DELETE_DEREF', 138)
+hasfree.append(138)
def_op('CALL_FUNCTION_VAR', 140) # #args + (#kwargs << 8)
def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8)
def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8)
-def_op('EXTENDED_ARG', 143)
-EXTENDED_ARG = 143
+
+jrel_op('SETUP_WITH', 143)
def_op('LIST_APPEND', 145)
def_op('SET_ADD', 146)
def_op('MAP_ADD', 147)
+def_op('EXTENDED_ARG', 144)
+EXTENDED_ARG = 144
del def_op, name_op, jrel_op, jabs_op
diff --git a/Lib/os.py b/Lib/os.py
index aa1a40f7a7..3ef3db8ae0 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -114,18 +114,26 @@ SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
+
+def _get_masked_mode(mode):
+ mask = umask(0)
+ umask(mask)
+ return mode & ~mask
+
#'
# Super directory utilities.
# (Inspired by Eric Raymond; the doc strings are mostly his)
-def makedirs(name, mode=0o777):
- """makedirs(path [, mode=0o777])
+def makedirs(name, mode=0o777, exist_ok=False):
+ """makedirs(path [, mode=0o777][, exist_ok=False])
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
- just the rightmost) will be created if it does not exist. This is
- recursive.
+ just the rightmost) will be created if it does not exist. If the
+ target directory with the same mode as we specified already exists,
+ raises an OSError if exist_ok is False, otherwise no exception is
+ raised. This is recursive.
"""
head, tail = path.split(name)
@@ -133,14 +141,20 @@ def makedirs(name, mode=0o777):
head, tail = path.split(head)
if head and tail and not path.exists(head):
try:
- makedirs(head, mode)
+ makedirs(head, mode, exist_ok)
except OSError as e:
# be happy if someone already created the path
if e.errno != errno.EEXIST:
raise
if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists
return
- mkdir(name, mode)
+ try:
+ mkdir(name, mode)
+ except OSError as e:
+ import stat as st
+ if not (e.errno == errno.EEXIST and exist_ok and path.isdir(name) and
+ st.S_IMODE(lstat(name).st_mode) == _get_masked_mode(mode)):
+ raise
def removedirs(name):
"""removedirs(path)
@@ -249,7 +263,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
dirs.remove('CVS') # don't visit CVS directories
"""
- from os.path import join, isdir, islink
+ islink, join, isdir = path.islink, path.join, path.isdir
# We may not have read permission for top, in which case we can't
# get a list of the files the directory contains. os.walk
@@ -275,9 +289,9 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
if topdown:
yield top, dirs, nondirs
for name in dirs:
- path = join(top, name)
- if followlinks or not islink(path):
- for x in walk(path, topdown, onerror, followlinks):
+ new_path = join(top, name)
+ if followlinks or not islink(new_path):
+ for x in walk(new_path, topdown, onerror, followlinks):
yield x
if not topdown:
yield top, dirs, nondirs
@@ -342,28 +356,27 @@ __all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"])
def _execvpe(file, args, env=None):
if env is not None:
- func = execve
+ exec_func = execve
argrest = (args, env)
else:
- func = execv
+ exec_func = execv
argrest = (args,)
env = environ
head, tail = path.split(file)
if head:
- func(file, *argrest)
+ exec_func(file, *argrest)
return
- if 'PATH' in env:
- envpath = env['PATH']
- else:
- envpath = defpath
- PATH = envpath.split(pathsep)
last_exc = saved_exc = None
saved_tb = None
- for dir in PATH:
+ path_list = get_exec_path(env)
+ if name != 'nt':
+ file = fsencode(file)
+ path_list = map(fsencode, path_list)
+ for dir in path_list:
fullname = path.join(dir, file)
try:
- func(fullname, *argrest)
+ exec_func(fullname, *argrest)
except error as e:
last_exc = e
tb = sys.exc_info()[2]
@@ -376,39 +389,89 @@ def _execvpe(file, args, env=None):
raise last_exc.with_traceback(tb)
+def get_exec_path(env=None):
+ """Returns the sequence of directories that will be searched for the
+ named executable (similar to a shell) when launching a process.
+
+ *env* must be an environment variable dict or None. If *env* is None,
+ os.environ will be used.
+ """
+ # Use a local import instead of a global import to limit the number of
+ # modules loaded at startup: the os module is always loaded at startup by
+ # Python. It may also avoid a bootstrap issue.
+ import warnings
+
+ if env is None:
+ env = environ
+
+ # {b'PATH': ...}.get('PATH') and {'PATH': ...}.get(b'PATH') emit a
+ # BytesWarning when using python -b or python -bb: ignore the warning
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", BytesWarning)
+
+ try:
+ path_list = env.get('PATH')
+ except TypeError:
+ path_list = None
+
+ if supports_bytes_environ:
+ try:
+ path_listb = env[b'PATH']
+ except (KeyError, TypeError):
+ pass
+ else:
+ if path_list is not None:
+ raise ValueError(
+ "env cannot contain 'PATH' and b'PATH' keys")
+ path_list = path_listb
+
+ if path_list is not None and isinstance(path_list, bytes):
+ path_list = fsdecode(path_list)
+
+ if path_list is None:
+ path_list = defpath
+ return path_list.split(pathsep)
+
+
# Change environ to automatically call putenv(), unsetenv if they exist.
from _abcoll import MutableMapping # Can't use collections (bootstrap)
class _Environ(MutableMapping):
- def __init__(self, environ, keymap, putenv, unsetenv):
- self.keymap = keymap
+ def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue, putenv, unsetenv):
+ self.encodekey = encodekey
+ self.decodekey = decodekey
+ self.encodevalue = encodevalue
+ self.decodevalue = decodevalue
self.putenv = putenv
self.unsetenv = unsetenv
- self.data = data = {}
- for key, value in environ.items():
- data[keymap(key)] = str(value)
+ self._data = data
def __getitem__(self, key):
- return self.data[self.keymap(key)]
+ value = self._data[self.encodekey(key)]
+ return self.decodevalue(value)
def __setitem__(self, key, value):
- value = str(value)
+ key = self.encodekey(key)
+ value = self.encodevalue(value)
self.putenv(key, value)
- self.data[self.keymap(key)] = value
+ self._data[key] = value
def __delitem__(self, key):
+ key = self.encodekey(key)
self.unsetenv(key)
- del self.data[self.keymap(key)]
+ del self._data[key]
def __iter__(self):
- for key in self.data:
- yield key
+ for key in self._data:
+ yield self.decodekey(key)
def __len__(self):
- return len(self.data)
+ return len(self._data)
def __repr__(self):
- return 'environ({!r})'.format(self.data)
+ return 'environ({{{}}})'.format(', '.join(
+ ('{!r}: {!r}'.format(self.decodekey(key), self.decodevalue(value))
+ for key, value in self._data.items())))
def copy(self):
return dict(self)
@@ -432,21 +495,108 @@ except NameError:
else:
__all__.append("unsetenv")
-if name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE
- _keymap = lambda key: str(key.upper())
-else: # Where Env Var Names Can Be Mixed Case
- _keymap = lambda key: str(key)
-
-environ = _Environ(environ, _keymap, _putenv, _unsetenv)
+def _createenviron():
+ if name in ('os2', 'nt'):
+ # Where Env Var Names Must Be UPPERCASE
+ def check_str(value):
+ if not isinstance(value, str):
+ raise TypeError("str expected, not %s" % type(value).__name__)
+ return value
+ encode = check_str
+ decode = str
+ def encodekey(key):
+ return encode(key).upper()
+ data = {}
+ for key, value in environ.items():
+ data[encodekey(key)] = value
+ else:
+ # Where Env Var Names Can Be Mixed Case
+ encoding = sys.getfilesystemencoding()
+ def encode(value):
+ if not isinstance(value, str):
+ raise TypeError("str expected, not %s" % type(value).__name__)
+ return value.encode(encoding, 'surrogateescape')
+ def decode(value):
+ return value.decode(encoding, 'surrogateescape')
+ encodekey = encode
+ data = environ
+ return _Environ(data,
+ encodekey, decode,
+ encode, decode,
+ _putenv, _unsetenv)
+
+# unicode environ
+environ = _createenviron()
+del _createenviron
def getenv(key, default=None):
"""Get an environment variable, return None if it doesn't exist.
- The optional second argument can specify an alternate default."""
- if isinstance(key, bytes):
- key = key.decode(sys.getfilesystemencoding(), "surrogateescape")
+ The optional second argument can specify an alternate default.
+ key, default and the result are str."""
return environ.get(key, default)
-__all__.append("getenv")
+
+supports_bytes_environ = name not in ('os2', 'nt')
+__all__.extend(("getenv", "supports_bytes_environ"))
+
+if supports_bytes_environ:
+ def _check_bytes(value):
+ if not isinstance(value, bytes):
+ raise TypeError("bytes expected, not %s" % type(value).__name__)
+ return value
+
+ # bytes environ
+ environb = _Environ(environ._data,
+ _check_bytes, bytes,
+ _check_bytes, bytes,
+ _putenv, _unsetenv)
+ del _check_bytes
+
+ def getenvb(key, default=None):
+ """Get an environment variable, return None if it doesn't exist.
+ The optional second argument can specify an alternate default.
+ key, default and the result are bytes."""
+ return environb.get(key, default)
+
+ __all__.extend(("environb", "getenvb"))
+
+def _fscodec():
+ encoding = sys.getfilesystemencoding()
+ if encoding == 'mbcs':
+ errors = 'strict'
+ else:
+ errors = 'surrogateescape'
+
+ def fsencode(filename):
+ """
+ Encode filename to the filesystem encoding with 'surrogateescape' error
+ handler, return bytes unchanged. On Windows, use 'strict' error handler if
+ the file system encoding is 'mbcs' (which is the default encoding).
+ """
+ if isinstance(filename, bytes):
+ return filename
+ elif isinstance(filename, str):
+ return filename.encode(encoding, errors)
+ else:
+ raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
+
+ def fsdecode(filename):
+ """
+ Decode filename from the filesystem encoding with 'surrogateescape' error
+ handler, return str unchanged. On Windows, use 'strict' error handler if
+ the file system encoding is 'mbcs' (which is the default encoding).
+ """
+ if isinstance(filename, str):
+ return filename
+ elif isinstance(filename, bytes):
+ return filename.decode(encoding, errors)
+ else:
+ raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
+
+ return fsencode, fsdecode
+
+fsencode, fsdecode = _fscodec()
+del _fscodec
def _exists(name):
return name in globals()
diff --git a/Lib/os2emxpath.py b/Lib/os2emxpath.py
index 184c9b169a..0ccbf8ae7b 100644
--- a/Lib/os2emxpath.py
+++ b/Lib/os2emxpath.py
@@ -36,6 +36,9 @@ def normcase(s):
"""Normalize case of pathname.
Makes all characters lowercase and all altseps into seps."""
+ if not isinstance(s, (bytes, str)):
+ raise TypeError("normcase() argument must be str or bytes, "
+ "not '{}'".format(s.__class__.__name__))
return s.replace('\\', '/').lower()
diff --git a/Lib/pdb.doc b/Lib/pdb.doc
deleted file mode 100644
index 0d32800ff6..0000000000
--- a/Lib/pdb.doc
+++ /dev/null
@@ -1,202 +0,0 @@
-The Python Debugger Pdb
-=======================
-
-To use the debugger in its simplest form:
-
- >>> import pdb
- >>> pdb.run('<a statement>')
-
-The debugger's prompt is '(Pdb) '. This will stop in the first
-function call in <a statement>.
-
-Alternatively, if a statement terminated with an unhandled exception,
-you can use pdb's post-mortem facility to inspect the contents of the
-traceback:
-
- >>> <a statement>
- <exception traceback>
- >>> import pdb
- >>> pdb.pm()
-
-The commands recognized by the debugger are listed in the next
-section. Most can be abbreviated as indicated; e.g., h(elp) means
-that 'help' can be typed as 'h' or 'help' (but not as 'he' or 'hel',
-nor as 'H' or 'Help' or 'HELP'). Optional arguments are enclosed in
-square brackets.
-
-A blank line repeats the previous command literally, except for
-'list', where it lists the next 11 lines.
-
-Commands that the debugger doesn't recognize are assumed to be Python
-statements and are executed in the context of the program being
-debugged. Python statements can also be prefixed with an exclamation
-point ('!'). This is a powerful way to inspect the program being
-debugged; it is even possible to change variables. When an exception
-occurs in such a statement, the exception name is printed but the
-debugger's state is not changed.
-
-The debugger supports aliases, which can save typing. And aliases can
-have parameters (see the alias help entry) which allows one a certain
-level of adaptability to the context under examination.
-
-Multiple commands may be entered on a single line, separated by the
-pair ';;'. No intelligence is applied to separating the commands; the
-input is split at the first ';;', even if it is in the middle of a
-quoted string.
-
-If a file ".pdbrc" exists in your home directory or in the current
-directory, it is read in and executed as if it had been typed at the
-debugger prompt. This is particularly useful for aliases. If both
-files exist, the one in the home directory is read first and aliases
-defined there can be overriden by the local file.
-
-Aside from aliases, the debugger is not directly programmable; but it
-is implemented as a class from which you can derive your own debugger
-class, which you can make as fancy as you like.
-
-
-Debugger commands
-=================
-
-h(elp)
- Without argument, print the list of available commands. With
- a command name as argument, print help about that command
- (this is currently not implemented).
-
-w(here)
- Print a stack trace, with the most recent frame at the bottom.
- An arrow indicates the "current frame", which determines the
- context of most commands.
-
-d(own)
- Move the current frame one level down in the stack trace
- (to a newer frame).
-
-u(p)
- Move the current frame one level up in the stack trace
- (to an older frame).
-
-b(reak) [ ([filename:]lineno | function) [, condition] ]
- With a filename:line number argument, set a break there. If
- filename is omitted, use the current file. With a function
- name, set a break at the first executable line of that
- function. Without argument, list all breaks. Each breakpoint
- is assigned a number to which all the other breakpoint
- commands refer.
-
- The condition argument, if present, is a string which must
- evaluate to true in order for the breakpoint to be honored.
-
-tbreak [ ([filename:]lineno | function) [, condition] ]
- Temporary breakpoint, which is removed automatically when it
- is first hit. The arguments are the same as break.
-
-cl(ear) [bpnumber [bpnumber ...] ]
- With a space separated list of breakpoint numbers, clear those
- breakpoints. Without argument, clear all breaks (but first
- ask confirmation).
-
-disable bpnumber [bpnumber ...]
- Disables the breakpoints given as a space separated list of
- breakpoint numbers. Disabling a breakpoint means it cannot
- cause the program to stop execution, but unlike clearing a
- breakpoint, it remains in the list of breakpoints and can be
- (re-)enabled.
-
-enable bpnumber [bpnumber ...]
- Enables the breakpoints specified.
-
-ignore bpnumber count
- Sets the ignore count for the given breakpoint number. If
- count is omitted, the ignore count is set to 0. A breakpoint
- becomes active when the ignore count is zero. When non-zero,
- the count is decremented each time the breakpoint is reached
- and the breakpoint is not disabled and any associated
- condition evaluates to true.
-
-condition bpnumber condition
- condition is an expression which must evaluate to true before
- the breakpoint is honored. If condition is absent, any
- existing condition is removed; i.e., the breakpoint is made
- unconditional.
-
-s(tep)
- Execute the current line, stop at the first possible occasion
- (either in a function that is called or in the current function).
-
-n(ext)
- Continue execution until the next line in the current function
- is reached or it returns.
-
-unt(il)
- Continue execution until the line with a number greater than the
- current one is reached or until the current frame returns.
-
-r(eturn)
- Continue execution until the current function returns.
-
-run [args...]
- Restart the debugged python program. If a string is supplied it is
- splitted with "shlex", and the result is used as the new sys.argv.
- History, breakpoints, actions and debugger options are preserved.
- "restart" is an alias for "run".
-
-c(ont(inue))
- Continue execution, only stop when a breakpoint is encountered.
-
-l(ist) [first [,last]]
- List source code for the current file.
- Without arguments, list 11 lines around the current line
- or continue the previous listing.
- With one argument, list 11 lines starting at that line.
- With two arguments, list the given range;
- if the second argument is less than the first, it is a count.
-
-a(rgs)
- Print the argument list of the current function.
-
-p expression
- Print the value of the expression.
-
-(!) statement
- Execute the (one-line) statement in the context of the current
- stack frame. The exclamation point can be omitted unless the
- first word of the statement resembles a debugger command. To
- assign to a global variable you must always prefix the command
- with a 'global' command, e.g.:
- (Pdb) global list_options; list_options = ['-l']
- (Pdb)
-
-
-whatis arg
- Prints the type of the argument.
-
-alias [name [command]]
- Creates an alias called 'name' that executes 'command'. The
- command must *not* be enclosed in quotes. Replaceable
- parameters can be indicated by %1, %2, and so on, while %* is
- replaced by all the parameters. If no command is given, the
- current alias for name is shown. If no name is given, all
- aliases are listed.
-
- Aliases may be nested and can contain anything that can be
- legally typed at the pdb prompt. Note! You *can* override
- internal pdb commands with aliases! Those internal commands
- are then hidden until the alias is removed. Aliasing is
- recursively applied to the first word of the command line; all
- other words in the line are left alone.
-
- As an example, here are two useful aliases (especially when
- placed in the .pdbrc file):
-
- #Print instance variables (usage "pi classInst")
- alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k]
- #Print instance variables in self
- alias ps pi self
-
-unalias name
- Deletes the specified alias.
-
-q(uit)
- Quit from the debugger.
- The program being executed is aborted.
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 1fb5174e0f..6776a3f4cf 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -1,30 +1,89 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
-"""A Python debugger."""
+"""
+The Python Debugger Pdb
+=======================
-# (See pdb.doc for documentation.)
+To use the debugger in its simplest form:
+ >>> import pdb
+ >>> pdb.run('<a statement>')
+
+The debugger's prompt is '(Pdb) '. This will stop in the first
+function call in <a statement>.
+
+Alternatively, if a statement terminated with an unhandled exception,
+you can use pdb's post-mortem facility to inspect the contents of the
+traceback:
+
+ >>> <a statement>
+ <exception traceback>
+ >>> import pdb
+ >>> pdb.pm()
+
+The commands recognized by the debugger are listed in the next
+section. Most can be abbreviated as indicated; e.g., h(elp) means
+that 'help' can be typed as 'h' or 'help' (but not as 'he' or 'hel',
+nor as 'H' or 'Help' or 'HELP'). Optional arguments are enclosed in
+square brackets. Alternatives in the command syntax are separated
+by a vertical bar (|).
+
+A blank line repeats the previous command literally, except for
+'list', where it lists the next 11 lines.
+
+Commands that the debugger doesn't recognize are assumed to be Python
+statements and are executed in the context of the program being
+debugged. Python statements can also be prefixed with an exclamation
+point ('!'). This is a powerful way to inspect the program being
+debugged; it is even possible to change variables or call functions.
+When an exception occurs in such a statement, the exception name is
+printed but the debugger's state is not changed.
+
+The debugger supports aliases, which can save typing. And aliases can
+have parameters (see the alias help entry) which allows one a certain
+level of adaptability to the context under examination.
+
+Multiple commands may be entered on a single line, separated by the
+pair ';;'. No intelligence is applied to separating the commands; the
+input is split at the first ';;', even if it is in the middle of a
+quoted string.
+
+If a file ".pdbrc" exists in your home directory or in the current
+directory, it is read in and executed as if it had been typed at the
+debugger prompt. This is particularly useful for aliases. If both
+files exist, the one in the home directory is read first and aliases
+defined there can be overriden by the local file.
+
+Aside from aliases, the debugger is not directly programmable; but it
+is implemented as a class from which you can derive your own debugger
+class, which you can make as fancy as you like.
+
+
+Debugger commands
+=================
+
+"""
+# NOTE: the actual command documentation is collected from docstrings of the
+# commands and is appended to __doc__ after the class has been defined.
+
+import os
+import re
import sys
-import linecache
import cmd
import bdb
-from reprlib import Repr
-import os
-import re
+import dis
+import code
import pprint
+import signal
+import inspect
import traceback
+import linecache
class Restart(Exception):
"""Causes a debugger to be restarted for the debugged python program."""
pass
-# Create a custom safe Repr instance and increase its maxstring.
-# The default of 30 truncates error messages too easily.
-_repr = Repr()
-_repr.maxstring = 200
-_saferepr = _repr.repr
-
__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace",
"post_mortem", "help"]
@@ -37,17 +96,40 @@ def find_function(funcname, filename):
# consumer of this info expects the first line to be 1
lineno = 1
answer = None
- while 1:
+ while True:
line = fp.readline()
if line == '':
break
if cre.match(line):
answer = funcname, filename, lineno
break
- lineno = lineno + 1
+ lineno += 1
fp.close()
return answer
+def getsourcelines(obj):
+ lines, lineno = inspect.findsource(obj)
+ if inspect.isframe(obj) and obj.f_globals is obj.f_locals:
+ # must be a module frame: do not try to cut a block out of it
+ return lines, 1
+ elif inspect.ismodule(obj):
+ return lines, 1
+ return inspect.getblock(lines[lineno:]), lineno+1
+
+def lasti2lineno(code, lasti):
+ linestarts = list(dis.findlinestarts(code))
+ linestarts.reverse()
+ for i, lineno in linestarts:
+ if lasti >= i:
+ return lineno
+ return 0
+
+
+class _rstr(str):
+ """String that doesn't quote its repr."""
+ def __repr__(self):
+ return self
+
# Interaction prompt line will separate file and call info from code
# text using value of line_prefix string. A newline and arrow may
@@ -58,41 +140,40 @@ line_prefix = '\n-> ' # Probably a better default
class Pdb(bdb.Bdb, cmd.Cmd):
- def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None):
+ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
+ nosigint=False):
bdb.Bdb.__init__(self, skip=skip)
cmd.Cmd.__init__(self, completekey, stdin, stdout)
if stdout:
self.use_rawinput = 0
self.prompt = '(Pdb) '
self.aliases = {}
+ self.displaying = {}
self.mainpyfile = ''
- self._wait_for_mainpyfile = 0
+ self._wait_for_mainpyfile = False
+ self.tb_lineno = {}
# Try to load readline if it exists
try:
import readline
except ImportError:
pass
+ self.allow_kbdint = False
+ self.nosigint = nosigint
# Read $HOME/.pdbrc and ./.pdbrc
self.rcLines = []
if 'HOME' in os.environ:
envHome = os.environ['HOME']
try:
- rcFile = open(os.path.join(envHome, ".pdbrc"))
+ with open(os.path.join(envHome, ".pdbrc")) as rcFile:
+ self.rcLines.extend(rcFile)
except IOError:
pass
- else:
- for line in rcFile.readlines():
- self.rcLines.append(line)
- rcFile.close()
try:
- rcFile = open(".pdbrc")
+ with open(".pdbrc") as rcFile:
+ self.rcLines.extend(rcFile)
except IOError:
pass
- else:
- for line in rcFile.readlines():
- self.rcLines.append(line)
- rcFile.close()
self.commands = {} # associates a command list to breakpoint numbers
self.commands_doprompt = {} # for each bp num, tells if the prompt
@@ -104,6 +185,15 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.commands_bnum = None # The breakpoint number for which we are
# defining a list
+ def sigint_handler(self, signum, frame):
+ if self.allow_kbdint:
+ raise KeyboardInterrupt
+ self.message("\nProgram interrupted. (Use 'cont' to resume).")
+ self.set_step()
+ self.set_trace(frame)
+ # restore previous signal handler
+ signal.signal(signal.SIGINT, self._previous_sigint_handler)
+
def reset(self):
bdb.Bdb.reset(self)
self.forget()
@@ -113,28 +203,43 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.stack = []
self.curindex = 0
self.curframe = None
+ self.tb_lineno.clear()
- def setup(self, f, t):
+ def setup(self, f, tb):
self.forget()
- self.stack, self.curindex = self.get_stack(f, t)
+ self.stack, self.curindex = self.get_stack(f, tb)
+ while tb:
+ # when setting up post-mortem debugging with a traceback, save all
+ # the original line numbers to be displayed along the current line
+ # numbers (which can be different, e.g. due to finally clauses)
+ lineno = lasti2lineno(tb.tb_frame.f_code, tb.tb_lasti)
+ self.tb_lineno[tb.tb_frame] = lineno
+ tb = tb.tb_next
self.curframe = self.stack[self.curindex][0]
# The f_locals dictionary is updated from the actual frame
# locals whenever the .f_locals accessor is called, so we
# cache it here to ensure that modifications are not overwritten.
self.curframe_locals = self.curframe.f_locals
- self.execRcLines()
+ return self.execRcLines()
# Can be executed earlier than 'setup' if desired
def execRcLines(self):
- if self.rcLines:
- # Make local copy because of recursion
- rcLines = self.rcLines
- # executed only once
- self.rcLines = []
- for line in rcLines:
- line = line[:-1]
- if len(line) > 0 and line[0] != '#':
- self.onecmd(line)
+ if not self.rcLines:
+ return
+ # local copy because of recursion
+ rcLines = self.rcLines
+ rcLines.reverse()
+ # execute every line only once
+ self.rcLines = []
+ while rcLines:
+ line = rcLines.pop().strip()
+ if line and line[0] != '#':
+ if self.onecmd(line):
+ # if onecmd returns True, the command wants to exit
+ # from the interaction, save leftover rc lines
+ # to execute before next interaction
+ self.rcLines += reversed(rcLines)
+ return True
# Override Bdb methods
@@ -144,20 +249,20 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if self._wait_for_mainpyfile:
return
if self.stop_here(frame):
- print('--Call--', file=self.stdout)
+ self.message('--Call--')
self.interaction(frame, None)
def user_line(self, frame):
"""This function is called when we stop or break at this line."""
if self._wait_for_mainpyfile:
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
- or frame.f_lineno<= 0):
+ or frame.f_lineno <= 0):
return
- self._wait_for_mainpyfile = 0
+ self._wait_for_mainpyfile = False
if self.bp_commands(frame):
self.interaction(frame, None)
- def bp_commands(self,frame):
+ def bp_commands(self, frame):
"""Call every command that was set for the current active breakpoint
(if there is one).
@@ -176,7 +281,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if not self.commands_silent[currentbp]:
self.print_stack_entry(self.stack[self.curindex])
if self.commands_doprompt[currentbp]:
- self.cmdloop()
+ self._cmdloop()
self.forget()
return
return 1
@@ -186,7 +291,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if self._wait_for_mainpyfile:
return
frame.f_locals['__return__'] = return_value
- print('--Return--', file=self.stdout)
+ self.message('--Return--')
self.interaction(frame, None)
def user_exception(self, frame, exc_info):
@@ -196,16 +301,45 @@ class Pdb(bdb.Bdb, cmd.Cmd):
return
exc_type, exc_value, exc_traceback = exc_info
frame.f_locals['__exception__'] = exc_type, exc_value
- exc_type_name = exc_type.__name__
- print(exc_type_name + ':', _saferepr(exc_value), file=self.stdout)
+ self.message(traceback.format_exception_only(exc_type,
+ exc_value)[-1].strip())
self.interaction(frame, exc_traceback)
# General interaction function
+ def _cmdloop(self):
+ while True:
+ try:
+ # keyboard interrupts allow for an easy way to cancel
+ # the current command, so allow them during interactive input
+ self.allow_kbdint = True
+ self.cmdloop()
+ self.allow_kbdint = False
+ break
+ except KeyboardInterrupt:
+ self.message('--KeyboardInterrupt--')
+
+ # Called before loop, handles display expressions
+ def preloop(self):
+ displaying = self.displaying.get(self.curframe)
+ if displaying:
+ for expr, oldvalue in displaying.items():
+ newvalue = self._getval_except(expr)
+ # check for identity first; this prevents custom __eq__ to
+ # be called at every loop, and also prevents instances whose
+ # fields are changed to be displayed
+ if newvalue is not oldvalue and newvalue != oldvalue:
+ displaying[expr] = newvalue
+ self.message('display %s: %r [old: %r]' %
+ (expr, newvalue, oldvalue))
def interaction(self, frame, traceback):
- self.setup(frame, traceback)
+ if self.setup(frame, traceback):
+ # no interaction desired at this time (happens if .pdbrc contains
+ # a command like "continue")
+ self.forget()
+ return
self.print_stack_entry(self.stack[self.curindex])
- self.cmdloop()
+ self._cmdloop()
self.forget()
def displayhook(self, obj):
@@ -214,7 +348,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
"""
# reproduce the behavior of the standard displayhook, not printing None
if obj is not None:
- print(repr(obj))
+ self.message(repr(obj))
def default(self, line):
if line[:1] == '!': line = line[1:]
@@ -235,11 +369,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
sys.stdin = save_stdin
sys.displayhook = save_displayhook
except:
- t, v = sys.exc_info()[:2]
- if type(t) == type(''):
- exc_type_name = t
- else: exc_type_name = t.__name__
- print('***', exc_type_name + ':', v, file=self.stdout)
+ exc_info = sys.exc_info()[:2]
+ self.error(traceback.format_exception_only(*exc_info)[-1].strip())
def precmd(self, line):
"""Handle alias expansion and ';;' separator."""
@@ -252,7 +383,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
for tmpArg in args[1:]:
line = line.replace("%" + str(ii),
tmpArg)
- ii = ii + 1
+ ii += 1
line = line.replace("%*", ' '.join(args[1:]))
args = line.split()
# split into ';;' separated commands
@@ -278,7 +409,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
else:
return self.handle_command_def(line)
- def handle_command_def(self,line):
+ def handle_command_def(self, line):
"""Handles one command line during command list definition."""
cmd, arg, line = self.parseline(line)
if not cmd:
@@ -306,47 +437,116 @@ class Pdb(bdb.Bdb, cmd.Cmd):
return 1
return
+ # interface abstraction functions
+
+ def message(self, msg):
+ print(msg, file=self.stdout)
+
+ def error(self, msg):
+ print('***', msg, file=self.stdout)
+
# Command definitions, called by cmdloop()
# The argument is the remaining string on the command line
# Return true to exit from the command loop
- do_h = cmd.Cmd.do_help
-
def do_commands(self, arg):
- """Defines a list of commands associated to a breakpoint.
-
- Those commands will be executed whenever the breakpoint causes
- the program to stop execution."""
+ """commands [bpnumber]
+ (com) ...
+ (com) end
+ (Pdb)
+
+ Specify a list of commands for breakpoint number bpnumber.
+ The commands themselves are entered on the following lines.
+ Type a line containing just 'end' to terminate the commands.
+ The commands are executed when the breakpoint is hit.
+
+ To remove all commands from a breakpoint, type commands and
+ follow it immediately with end; that is, give no commands.
+
+ With no bpnumber argument, commands refers to the last
+ breakpoint set.
+
+ You can use breakpoint commands to start your program up
+ again. Simply use the continue command, or step, or any other
+ command that resumes execution.
+
+ Specifying any command resuming execution (currently continue,
+ step, next, return, jump, quit and their abbreviations)
+ terminates the command list (as if that command was
+ immediately followed by end). This is because any time you
+ resume execution (even with a simple next or step), you may
+ encounter another breakpoint -- which could have its own
+ command list, leading to ambiguities about which list to
+ execute.
+
+ If you use the 'silent' command in the command list, the usual
+ message about stopping at a breakpoint is not printed. This
+ may be desirable for breakpoints that are to print a specific
+ message and then continue. If none of the other commands
+ print anything, you will see no sign that the breakpoint was
+ reached.
+ """
if not arg:
- bnum = len(bdb.Breakpoint.bpbynumber)-1
+ bnum = len(bdb.Breakpoint.bpbynumber) - 1
else:
try:
bnum = int(arg)
except:
- print("Usage : commands [bnum]\n ...\n end",
- file=self.stdout)
+ self.error("Usage: commands [bnum]\n ...\n end")
return
self.commands_bnum = bnum
+ # Save old definitions for the case of a keyboard interrupt.
+ if bnum in self.commands:
+ old_command_defs = (self.commands[bnum],
+ self.commands_doprompt[bnum],
+ self.commands_silent[bnum])
+ else:
+ old_command_defs = None
self.commands[bnum] = []
self.commands_doprompt[bnum] = True
self.commands_silent[bnum] = False
+
prompt_back = self.prompt
self.prompt = '(com) '
self.commands_defining = True
try:
self.cmdloop()
+ except KeyboardInterrupt:
+ # Restore old definitions.
+ if old_command_defs:
+ self.commands[bnum] = old_command_defs[0]
+ self.commands_doprompt[bnum] = old_command_defs[1]
+ self.commands_silent[bnum] = old_command_defs[2]
+ else:
+ del self.commands[bnum]
+ del self.commands_doprompt[bnum]
+ del self.commands_silent[bnum]
+ self.error('command definition aborted, old commands restored')
finally:
self.commands_defining = False
self.prompt = prompt_back
def do_break(self, arg, temporary = 0):
- # break [ ([filename:]lineno | function) [, "condition"] ]
+ """b(reak) [ ([filename:]lineno | function) [, condition] ]
+ Without argument, list all breaks.
+
+ With a line number argument, set a break at this line in the
+ current file. With a function name, set a break at the first
+ executable line of that function. If a second argument is
+ present, it is a string specifying an expression which must
+ evaluate to true before the breakpoint is honored.
+
+ The line number may be prefixed with a filename and a colon,
+ to specify a breakpoint in another file (probably one that
+ hasn't been loaded yet). The file is searched for on
+ sys.path; the .py suffix may be omitted.
+ """
if not arg:
if self.breaks: # There's at least one
- print("Num Type Disp Enb Where", file=self.stdout)
+ self.message("Num Type Disp Enb Where")
for bp in bdb.Breakpoint.bpbynumber:
if bp:
- bp.bpprint(self.stdout)
+ self.message(bp.bpformat())
return
# parse arguments; comma has lowest precedence
# and cannot occur in filename
@@ -365,16 +565,15 @@ class Pdb(bdb.Bdb, cmd.Cmd):
filename = arg[:colon].rstrip()
f = self.lookupmodule(filename)
if not f:
- print('*** ', repr(filename), end=' ', file=self.stdout)
- print('not found from sys.path', file=self.stdout)
+ self.error('%r not found from sys.path' % filename)
return
else:
filename = f
arg = arg[colon+1:].lstrip()
try:
lineno = int(arg)
- except ValueError as msg:
- print('*** Bad lineno:', arg, file=self.stdout)
+ except ValueError:
+ self.error('Bad lineno: %s' % arg)
return
else:
# no colon; can be lineno or function
@@ -400,10 +599,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
# last thing to try
(ok, filename, ln) = self.lineinfo(arg)
if not ok:
- print('*** The specified object', end=' ', file=self.stdout)
- print(repr(arg), end=' ', file=self.stdout)
- print('is not a function', file=self.stdout)
- print('or was not found along sys.path.', file=self.stdout)
+ self.error('The specified object %r is not a function '
+ 'or was not found along sys.path.' % arg)
return
funcname = ok # ok contains a function name
lineno = int(ln)
@@ -414,12 +611,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if line:
# now set the break point
err = self.set_break(filename, line, temporary, cond, funcname)
- if err: print('***', err, file=self.stdout)
+ if err:
+ self.error(err, file=self.stdout)
else:
bp = self.get_breaks(filename, line)[-1]
- print("Breakpoint %d at %s:%d" % (bp.number,
- bp.file,
- bp.line), file=self.stdout)
+ self.message("Breakpoint %d at %s:%d" %
+ (bp.number, bp.file, bp.line))
# To be overridden in derived debuggers
def defaultFile(self):
@@ -432,6 +629,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
do_b = do_break
def do_tbreak(self, arg):
+ """tbreak [ ([filename:]lineno | function) [, condition] ]
+ Same arguments as break, but sets a temporary breakpoint: it
+ is automatically deleted when first hit.
+ """
self.do_break(arg, 1)
def lineinfo(self, identifier):
@@ -478,112 +679,110 @@ class Pdb(bdb.Bdb, cmd.Cmd):
globs = self.curframe.f_globals if hasattr(self, 'curframe') else None
line = linecache.getline(filename, lineno, globs)
if not line:
- print('End of file', file=self.stdout)
+ self.message('End of file')
return 0
line = line.strip()
# Don't allow setting breakpoint at a blank line
if (not line or (line[0] == '#') or
(line[:3] == '"""') or line[:3] == "'''"):
- print('*** Blank or comment', file=self.stdout)
+ self.error('Blank or comment')
return 0
return lineno
def do_enable(self, arg):
+ """enable bpnumber [bpnumber ...]
+ Enables the breakpoints given as a space separated list of
+ breakpoint numbers.
+ """
args = arg.split()
for i in args:
try:
- i = int(i)
- except ValueError:
- print('Breakpoint index %r is not a number' % i, file=self.stdout)
- continue
-
- if not (0 <= i < len(bdb.Breakpoint.bpbynumber)):
- print('No breakpoint numbered', i, file=self.stdout)
- continue
-
- bp = bdb.Breakpoint.bpbynumber[i]
- if bp:
+ bp = self.get_bpbynumber(i)
+ except ValueError as err:
+ self.error(err)
+ else:
bp.enable()
+ self.message('Enabled %s' % bp)
def do_disable(self, arg):
+ """disable bpnumber [bpnumber ...]
+ Disables the breakpoints given as a space separated list of
+ breakpoint numbers. Disabling a breakpoint means it cannot
+ cause the program to stop execution, but unlike clearing a
+ breakpoint, it remains in the list of breakpoints and can be
+ (re-)enabled.
+ """
args = arg.split()
for i in args:
try:
- i = int(i)
- except ValueError:
- print('Breakpoint index %r is not a number' % i, file=self.stdout)
- continue
-
- if not (0 <= i < len(bdb.Breakpoint.bpbynumber)):
- print('No breakpoint numbered', i, file=self.stdout)
- continue
-
- bp = bdb.Breakpoint.bpbynumber[i]
- if bp:
+ bp = self.get_bpbynumber(i)
+ except ValueError as err:
+ self.error(err)
+ else:
bp.disable()
+ self.message('Disabled %s' % bp)
def do_condition(self, arg):
- # arg is breakpoint number and condition
+ """condition bpnumber [condition]
+ Set a new condition for the breakpoint, an expression which
+ must evaluate to true before the breakpoint is honored. If
+ condition is absent, any existing condition is removed; i.e.,
+ the breakpoint is made unconditional.
+ """
args = arg.split(' ', 1)
try:
- bpnum = int(args[0].strip())
- except ValueError:
- # something went wrong
- print('Breakpoint index %r is not a number' % args[0], file=self.stdout)
- return
- try:
cond = args[1]
- except:
+ except IndexError:
cond = None
try:
- bp = bdb.Breakpoint.bpbynumber[bpnum]
- except IndexError:
- print('Breakpoint index %r is not valid' % args[0],
- file=self.stdout)
- return
- if bp:
+ bp = self.get_bpbynumber(args[0].strip())
+ except ValueError as err:
+ self.error(err)
+ else:
bp.cond = cond
if not cond:
- print('Breakpoint', bpnum, end=' ', file=self.stdout)
- print('is now unconditional.', file=self.stdout)
-
- def do_ignore(self,arg):
- """arg is bp number followed by ignore count."""
+ self.message('Breakpoint %d is now unconditional.' % bp.number)
+ else:
+ self.message('New condition set for breakpoint %d.' % bp.number)
+
+ def do_ignore(self, arg):
+ """ignore bpnumber [count]
+ Set the ignore count for the given breakpoint number. If
+ count is omitted, the ignore count is set to 0. A breakpoint
+ becomes active when the ignore count is zero. When non-zero,
+ the count is decremented each time the breakpoint is reached
+ and the breakpoint is not disabled and any associated
+ condition evaluates to true.
+ """
args = arg.split()
try:
- bpnum = int(args[0].strip())
- except ValueError:
- # something went wrong
- print('Breakpoint index %r is not a number' % args[0], file=self.stdout)
- return
- try:
count = int(args[1].strip())
except:
count = 0
try:
- bp = bdb.Breakpoint.bpbynumber[bpnum]
- except IndexError:
- print('Breakpoint index %r is not valid' % args[0],
- file=self.stdout)
- return
- if bp:
+ bp = self.get_bpbynumber(args[0].strip())
+ except ValueError as err:
+ self.error(err)
+ else:
bp.ignore = count
if count > 0:
- reply = 'Will ignore next '
if count > 1:
- reply = reply + '%d crossings' % count
+ countstr = '%d crossings' % count
else:
- reply = reply + '1 crossing'
- print(reply + ' of breakpoint %d.' % bpnum, file=self.stdout)
+ countstr = '1 crossing'
+ self.message('Will ignore next %s of breakpoint %d.' %
+ (countstr, bp.number))
else:
- print('Will stop next time breakpoint', end=' ', file=self.stdout)
- print(bpnum, 'is reached.', file=self.stdout)
+ self.message('Will stop next time breakpoint %d is reached.'
+ % bp.number)
def do_clear(self, arg):
- """Three possibilities, tried in this order:
- clear -> clear all breaks, ask for confirmation
- clear file:lineno -> clear all breaks at file:lineno
- clear bpno bpno ... -> clear breakpoints by number"""
+ """cl(ear) filename:lineno\ncl(ear) [bpnumber [bpnumber...]]
+ With a space separated list of breakpoint numbers, clear
+ those breakpoints. Without argument, clear all breaks (but
+ first ask confirmation). With a filename:lineno argument,
+ clear all breaks at that line in that file.
+ """
if not arg:
try:
reply = input('Clear all breaks? ')
@@ -591,7 +790,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
reply = 'no'
reply = reply.strip().lower()
if reply in ('y', 'yes'):
+ bplist = [bp for bp in bdb.Breakpoint.bpbynumber if bp]
self.clear_all_breaks()
+ for bp in bplist:
+ self.message('Deleted %s' % bp)
return
if ':' in arg:
# Make sure it works for "clear C:\foo\bar.py:12"
@@ -603,99 +805,180 @@ class Pdb(bdb.Bdb, cmd.Cmd):
except ValueError:
err = "Invalid line number (%s)" % arg
else:
+ bplist = self.get_breaks(filename, lineno)
err = self.clear_break(filename, lineno)
- if err: print('***', err, file=self.stdout)
+ if err:
+ self.error(err)
+ else:
+ for bp in bplist:
+ self.message('Deleted %s' % bp)
return
numberlist = arg.split()
for i in numberlist:
try:
- i = int(i)
- except ValueError:
- print('Breakpoint index %r is not a number' % i, file=self.stdout)
- continue
-
- if not (0 <= i < len(bdb.Breakpoint.bpbynumber)):
- print('No breakpoint numbered', i, file=self.stdout)
- continue
- err = self.clear_bpbynumber(i)
- if err:
- print('***', err, file=self.stdout)
+ bp = self.get_bpbynumber(i)
+ except ValueError as err:
+ self.error(err)
else:
- print('Deleted breakpoint', i, file=self.stdout)
+ self.clear_bpbynumber(i)
+ self.message('Deleted %s' % bp)
do_cl = do_clear # 'c' is already an abbreviation for 'continue'
def do_where(self, arg):
+ """w(here)
+ Print a stack trace, with the most recent frame at the bottom.
+ An arrow indicates the "current frame", which determines the
+ context of most commands. 'bt' is an alias for this command.
+ """
self.print_stack_trace()
do_w = do_where
do_bt = do_where
+ def _select_frame(self, number):
+ assert 0 <= number < len(self.stack)
+ self.curindex = number
+ self.curframe = self.stack[self.curindex][0]
+ self.curframe_locals = self.curframe.f_locals
+ self.print_stack_entry(self.stack[self.curindex])
+ self.lineno = None
+
def do_up(self, arg):
+ """u(p) [count]
+ Move the current frame count (default one) levels up in the
+ stack trace (to an older frame).
+ """
if self.curindex == 0:
- print('*** Oldest frame', file=self.stdout)
+ self.error('Oldest frame')
+ return
+ try:
+ count = int(arg or 1)
+ except ValueError:
+ self.error('Invalid frame count (%s)' % arg)
+ return
+ if count < 0:
+ newframe = 0
else:
- self.curindex = self.curindex - 1
- self.curframe = self.stack[self.curindex][0]
- self.curframe_locals = self.curframe.f_locals
- self.print_stack_entry(self.stack[self.curindex])
- self.lineno = None
+ newframe = max(0, self.curindex - count)
+ self._select_frame(newframe)
do_u = do_up
def do_down(self, arg):
+ """d(own) [count]
+ Move the current frame count (default one) levels down in the
+ stack trace (to a newer frame).
+ """
if self.curindex + 1 == len(self.stack):
- print('*** Newest frame', file=self.stdout)
+ self.error('Newest frame')
+ return
+ try:
+ count = int(arg or 1)
+ except ValueError:
+ self.error('Invalid frame count (%s)' % arg)
+ return
+ if count < 0:
+ newframe = len(self.stack) - 1
else:
- self.curindex = self.curindex + 1
- self.curframe = self.stack[self.curindex][0]
- self.curframe_locals = self.curframe.f_locals
- self.print_stack_entry(self.stack[self.curindex])
- self.lineno = None
+ newframe = min(len(self.stack) - 1, self.curindex + count)
+ self._select_frame(newframe)
do_d = do_down
def do_until(self, arg):
- self.set_until(self.curframe)
+ """unt(il) [lineno]
+ Without argument, continue execution until the line with a
+ number greater than the current one is reached. With a line
+ number, continue execution until a line with a number greater
+ or equal to that is reached. In both cases, also stop when
+ the current frame returns.
+ """
+ if arg:
+ try:
+ lineno = int(arg)
+ except ValueError:
+ self.error('Error in argument: %r' % arg)
+ return
+ if lineno <= self.curframe.f_lineno:
+ self.error('"until" line number is smaller than current '
+ 'line number')
+ return
+ else:
+ lineno = None
+ self.set_until(self.curframe, lineno)
return 1
do_unt = do_until
def do_step(self, arg):
+ """s(tep)
+ Execute the current line, stop at the first possible occasion
+ (either in a function that is called or in the current
+ function).
+ """
self.set_step()
return 1
do_s = do_step
def do_next(self, arg):
+ """n(ext)
+ Continue execution until the next line in the current function
+ is reached or it returns.
+ """
self.set_next(self.curframe)
return 1
do_n = do_next
def do_run(self, arg):
- """Restart program by raising an exception to be caught in the main
- debugger loop. If arguments were given, set them in sys.argv."""
+ """run [args...]
+ Restart the debugged python program. If a string is supplied
+ it is splitted with "shlex", and the result is used as the new
+ sys.argv. History, breakpoints, actions and debugger options
+ are preserved. "restart" is an alias for "run".
+ """
if arg:
import shlex
argv0 = sys.argv[0:1]
sys.argv = shlex.split(arg)
sys.argv[:0] = argv0
+ # this is caught in the main debugger loop
raise Restart
do_restart = do_run
def do_return(self, arg):
+ """r(eturn)
+ Continue execution until the current function returns.
+ """
self.set_return(self.curframe)
return 1
do_r = do_return
def do_continue(self, arg):
+ """c(ont(inue))
+ Continue execution, only stop when a breakpoint is encountered.
+ """
+ if not self.nosigint:
+ self._previous_sigint_handler = \
+ signal.signal(signal.SIGINT, self.sigint_handler)
self.set_continue()
return 1
do_c = do_cont = do_continue
def do_jump(self, arg):
+ """j(ump) lineno
+ Set the next line that will be executed. Only available in
+ the bottom-most frame. This lets you jump back and execute
+ code again, or jump forward to skip code that you don't want
+ to run.
+
+ It should be noted that not all jumps are allowed -- for
+ instance it is not possible to jump into the middle of a
+ for loop or out of a finally clause.
+ """
if self.curindex + 1 != len(self.stack):
- print("*** You can only jump within the bottom frame", file=self.stdout)
+ self.error('You can only jump within the bottom frame')
return
try:
arg = int(arg)
except ValueError:
- print("*** The 'jump' command requires a line number.", file=self.stdout)
+ self.error("The 'jump' command requires a line number")
else:
try:
# Do the jump, fix up our copy of the stack, and display the
@@ -704,23 +987,31 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.stack[self.curindex] = self.stack[self.curindex][0], arg
self.print_stack_entry(self.stack[self.curindex])
except ValueError as e:
- print('*** Jump failed:', e, file=self.stdout)
+ self.error('Jump failed: %s' % e)
do_j = do_jump
def do_debug(self, arg):
+ """debug code
+ Enter a recursive debugger that steps through the code
+ argument (which is an arbitrary expression or statement to be
+ executed in the current environment).
+ """
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe_locals
p = Pdb(self.completekey, self.stdin, self.stdout)
p.prompt = "(%s) " % self.prompt.strip()
- print("ENTERING RECURSIVE DEBUGGER", file=self.stdout)
+ self.message("ENTERING RECURSIVE DEBUGGER")
sys.call_tracing(p.run, (arg, globals, locals))
- print("LEAVING RECURSIVE DEBUGGER", file=self.stdout)
+ self.message("LEAVING RECURSIVE DEBUGGER")
sys.settrace(self.trace_dispatch)
self.lastcmd = p.lastcmd
def do_quit(self, arg):
- self._user_requested_quit = 1
+ """q(uit)\nexit
+ Quit from the debugger. The program being executed is aborted.
+ """
+ self._user_requested_quit = True
self.set_quit()
return 1
@@ -728,12 +1019,18 @@ class Pdb(bdb.Bdb, cmd.Cmd):
do_exit = do_quit
def do_EOF(self, arg):
- print(file=self.stdout)
- self._user_requested_quit = 1
+ """EOF
+ Handles the receipt of EOF as a command.
+ """
+ self.message('')
+ self._user_requested_quit = True
self.set_quit()
return 1
def do_args(self, arg):
+ """a(rgs)
+ Print the argument list of the current function.
+ """
co = self.curframe.f_code
dict = self.curframe_locals
n = co.co_argcount
@@ -741,62 +1038,94 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if co.co_flags & 8: n = n+1
for i in range(n):
name = co.co_varnames[i]
- print(name, '=', end=' ', file=self.stdout)
- if name in dict: print(dict[name], file=self.stdout)
- else: print("*** undefined ***", file=self.stdout)
+ if name in dict:
+ self.message('%s = %r' % (name, dict[name]))
+ else:
+ self.message('%s = *** undefined ***' % (name,))
do_a = do_args
def do_retval(self, arg):
+ """retval
+ Print the return value for the last return of a function.
+ """
if '__return__' in self.curframe_locals:
- print(self.curframe_locals['__return__'], file=self.stdout)
+ self.message(repr(self.curframe_locals['__return__']))
else:
- print('*** Not yet returned!', file=self.stdout)
+ self.error('Not yet returned!')
do_rv = do_retval
def _getval(self, arg):
try:
return eval(arg, self.curframe.f_globals, self.curframe_locals)
except:
- t, v = sys.exc_info()[:2]
- if isinstance(t, str):
- exc_type_name = t
- else: exc_type_name = t.__name__
- print('***', exc_type_name + ':', repr(v), file=self.stdout)
+ exc_info = sys.exc_info()[:2]
+ self.error(traceback.format_exception_only(*exc_info)[-1].strip())
raise
+ def _getval_except(self, arg, frame=None):
+ try:
+ if frame is None:
+ return eval(arg, self.curframe.f_globals, self.curframe_locals)
+ else:
+ return eval(arg, frame.f_globals, frame.f_locals)
+ except:
+ exc_info = sys.exc_info()[:2]
+ err = traceback.format_exception_only(*exc_info)[-1].strip()
+ return _rstr('** raised %s **' % err)
+
def do_p(self, arg):
+ """p(rint) expression
+ Print the value of the expression.
+ """
try:
- print(repr(self._getval(arg)), file=self.stdout)
+ self.message(repr(self._getval(arg)))
except:
pass
# make "print" an alias of "p" since print isn't a Python statement anymore
do_print = do_p
def do_pp(self, arg):
+ """pp expression
+ Pretty-print the value of the expression.
+ """
try:
- pprint.pprint(self._getval(arg), self.stdout)
+ self.message(pprint.pformat(self._getval(arg)))
except:
pass
def do_list(self, arg):
+ """l(ist) [first [,last] | .]
+
+ List source code for the current file. Without arguments,
+ list 11 lines around the current line or continue the previous
+ listing. With . as argument, list 11 lines around the current
+ line. With one argument, list 11 lines starting at that line.
+ With two arguments, list the given range; if the second
+ argument is less than the first, it is a count.
+
+ The current line in the current frame is indicated by "->".
+ If an exception is being debugged, the line where the
+ exception was originally raised or propagated is indicated by
+ ">>", if it differs from the current line.
+ """
self.lastcmd = 'list'
last = None
- if arg:
+ if arg and arg != '.':
try:
- x = eval(arg, {}, {})
- if type(x) == type(()):
- first, last = x
- first = int(first)
- last = int(last)
+ if ',' in arg:
+ first, last = arg.split(',')
+ first = int(first.strip())
+ last = int(last.strip())
if last < first:
- # Assume it's a count
+ # assume it's a count
last = first + last
else:
- first = max(1, int(x) - 5)
- except:
- print('*** Error in argument:', repr(arg), file=self.stdout)
+ first = int(arg.strip())
+ first = max(1, first - 5)
+ except ValueError:
+ self.error('Error in argument: %r' % arg)
return
- elif self.lineno is None:
+ elif self.lineno is None or arg == '.':
first = max(1, self.curframe.f_lineno - 5)
else:
first = self.lineno + 1
@@ -805,71 +1134,186 @@ class Pdb(bdb.Bdb, cmd.Cmd):
filename = self.curframe.f_code.co_filename
breaklist = self.get_file_breaks(filename)
try:
- for lineno in range(first, last+1):
- line = linecache.getline(filename, lineno,
- self.curframe.f_globals)
- if not line:
- print('[EOF]', file=self.stdout)
- break
- else:
- s = repr(lineno).rjust(3)
- if len(s) < 4: s = s + ' '
- if lineno in breaklist: s = s + 'B'
- else: s = s + ' '
- if lineno == self.curframe.f_lineno:
- s = s + '->'
- print(s + '\t' + line, end='', file=self.stdout)
- self.lineno = lineno
+ lines = linecache.getlines(filename, self.curframe.f_globals)
+ self._print_lines(lines[first-1:last], first, breaklist,
+ self.curframe)
+ self.lineno = min(last, len(lines))
+ if len(lines) < last:
+ self.message('[EOF]')
except KeyboardInterrupt:
pass
do_l = do_list
+ def do_longlist(self, arg):
+ """longlist | ll
+ List the whole source code for the current function or frame.
+ """
+ filename = self.curframe.f_code.co_filename
+ breaklist = self.get_file_breaks(filename)
+ try:
+ lines, lineno = getsourcelines(self.curframe)
+ except IOError as err:
+ self.error(err)
+ return
+ self._print_lines(lines, lineno, breaklist, self.curframe)
+ do_ll = do_longlist
+
+ def do_source(self, arg):
+ """source expression
+ Try to get source code for the given object and display it.
+ """
+ try:
+ obj = self._getval(arg)
+ except:
+ return
+ try:
+ lines, lineno = getsourcelines(obj)
+ except (IOError, TypeError) as err:
+ self.error(err)
+ return
+ self._print_lines(lines, lineno)
+
+ def _print_lines(self, lines, start, breaks=(), frame=None):
+ """Print a range of lines."""
+ if frame:
+ current_lineno = frame.f_lineno
+ exc_lineno = self.tb_lineno.get(frame, -1)
+ else:
+ current_lineno = exc_lineno = -1
+ for lineno, line in enumerate(lines, start):
+ s = str(lineno).rjust(3)
+ if len(s) < 4:
+ s += ' '
+ if lineno in breaks:
+ s += 'B'
+ else:
+ s += ' '
+ if lineno == current_lineno:
+ s += '->'
+ elif lineno == exc_lineno:
+ s += '>>'
+ self.message(s + '\t' + line.rstrip())
+
def do_whatis(self, arg):
+ """whatis arg
+ Print the type of the argument.
+ """
try:
- value = eval(arg, self.curframe.f_globals,
- self.curframe_locals)
+ value = self._getval(arg)
except:
- t, v = sys.exc_info()[:2]
- if type(t) == type(''):
- exc_type_name = t
- else: exc_type_name = t.__name__
- print('***', exc_type_name + ':', repr(v), file=self.stdout)
+ # _getval() already printed the error
return
code = None
# Is it a function?
- try: code = value.__code__
- except: pass
+ try:
+ code = value.__code__
+ except Exception:
+ pass
if code:
- print('Function', code.co_name, file=self.stdout)
+ self.message('Function %s' % code.co_name)
return
# Is it an instance method?
- try: code = value.__func__.__code__
- except: pass
+ try:
+ code = value.__func__.__code__
+ except Exception:
+ pass
if code:
- print('Method', code.co_name, file=self.stdout)
+ self.message('Method %s' % code.co_name)
+ return
+ # Is it a class?
+ if value.__class__ is type:
+ self.message('Class %s.%s' % (value.__module__, value.__name__))
return
# None of the above...
- print(type(value), file=self.stdout)
+ self.message(type(value))
+
+ def do_display(self, arg):
+ """display [expression]
+
+ Display the value of the expression if it changed, each time execution
+ stops in the current frame.
+
+ Without expression, list all display expressions for the current frame.
+ """
+ if not arg:
+ self.message('Currently displaying:')
+ for item in self.displaying.get(self.curframe, {}).items():
+ self.message('%s: %r' % item)
+ else:
+ val = self._getval_except(arg)
+ self.displaying.setdefault(self.curframe, {})[arg] = val
+ self.message('display %s: %r' % (arg, val))
+
+ def do_undisplay(self, arg):
+ """undisplay [expression]
+
+ Do not display the expression any more in the current frame.
+
+ Without expression, clear all display expressions for the current frame.
+ """
+ if arg:
+ try:
+ del self.displaying.get(self.curframe, {})[arg]
+ except KeyError:
+ self.error('not displaying %s' % arg)
+ else:
+ self.displaying.pop(self.curframe, None)
+
+ def do_interact(self, arg):
+ """interact
+
+ Start an interative interpreter whose global namespace
+ contains all the (global and local) names found in the current scope.
+ """
+ ns = self.curframe.f_globals.copy()
+ ns.update(self.curframe_locals)
+ code.interact("*interactive*", local=ns)
def do_alias(self, arg):
+ """alias [name [command [parameter parameter ...] ]]
+ Create an alias called 'name' that executes 'command'. The
+ command must *not* be enclosed in quotes. Replaceable
+ parameters can be indicated by %1, %2, and so on, while %* is
+ replaced by all the parameters. If no command is given, the
+ current alias for name is shown. If no name is given, all
+ aliases are listed.
+
+ Aliases may be nested and can contain anything that can be
+ legally typed at the pdb prompt. Note! You *can* override
+ internal pdb commands with aliases! Those internal commands
+ are then hidden until the alias is removed. Aliasing is
+ recursively applied to the first word of the command line; all
+ other words in the line are left alone.
+
+ As an example, here are two useful aliases (especially when
+ placed in the .pdbrc file):
+
+ # Print instance variables (usage "pi classInst")
+ alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k]
+ # Print instance variables in self
+ alias ps pi self
+ """
args = arg.split()
if len(args) == 0:
keys = sorted(self.aliases.keys())
for alias in keys:
- print("%s = %s" % (alias, self.aliases[alias]), file=self.stdout)
+ self.message("%s = %s" % (alias, self.aliases[alias]))
return
if args[0] in self.aliases and len(args) == 1:
- print("%s = %s" % (args[0], self.aliases[args[0]]), file=self.stdout)
+ self.message("%s = %s" % (args[0], self.aliases[args[0]]))
else:
self.aliases[args[0]] = ' '.join(args[1:])
def do_unalias(self, arg):
+ """unalias name
+ Delete the specified alias.
+ """
args = arg.split()
if len(args) == 0: return
if args[0] in self.aliases:
del self.aliases[args[0]]
- #list of all the commands making the program resume execution.
+ # List of all the commands making the program resume execution.
commands_resuming = ['do_continue', 'do_step', 'do_next', 'do_return',
'do_quit', 'do_jump']
@@ -891,292 +1335,57 @@ class Pdb(bdb.Bdb, cmd.Cmd):
def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix):
frame, lineno = frame_lineno
if frame is self.curframe:
- print('>', end=' ', file=self.stdout)
+ prefix = '> '
else:
- print(' ', end=' ', file=self.stdout)
- print(self.format_stack_entry(frame_lineno,
- prompt_prefix), file=self.stdout)
-
-
- # Help methods (derived from pdb.doc)
-
- def help_help(self):
- self.help_h()
-
- def help_h(self):
- print("""h(elp)
-Without argument, print the list of available commands.
-With a command name as argument, print help about that command
-"help pdb" pipes the full documentation file to the $PAGER
-"help exec" gives help on the ! command""", file=self.stdout)
-
- def help_where(self):
- self.help_w()
-
- def help_w(self):
- print("""w(here)
-Print a stack trace, with the most recent frame at the bottom.
-An arrow indicates the "current frame", which determines the
-context of most commands. 'bt' is an alias for this command.""", file=self.stdout)
-
- help_bt = help_w
-
- def help_down(self):
- self.help_d()
-
- def help_d(self):
- print("""d(own)
-Move the current frame one level down in the stack trace
-(to a newer frame).""", file=self.stdout)
-
- def help_up(self):
- self.help_u()
-
- def help_u(self):
- print("""u(p)
-Move the current frame one level up in the stack trace
-(to an older frame).""", file=self.stdout)
-
- def help_break(self):
- self.help_b()
-
- def help_b(self):
- print("""b(reak) ([file:]lineno | function) [, condition]
-With a line number argument, set a break there in the current
-file. With a function name, set a break at first executable line
-of that function. Without argument, list all breaks. If a second
-argument is present, it is a string specifying an expression
-which must evaluate to true before the breakpoint is honored.
-
-The line number may be prefixed with a filename and a colon,
-to specify a breakpoint in another file (probably one that
-hasn't been loaded yet). The file is searched for on sys.path;
-the .py suffix may be omitted.""", file=self.stdout)
-
- def help_clear(self):
- self.help_cl()
-
- def help_cl(self):
- print("cl(ear) filename:lineno", file=self.stdout)
- print("""cl(ear) [bpnumber [bpnumber...]]
-With a space separated list of breakpoint numbers, clear
-those breakpoints. Without argument, clear all breaks (but
-first ask confirmation). With a filename:lineno argument,
-clear all breaks at that line in that file.""", file=self.stdout)
-
- def help_tbreak(self):
- print("""tbreak same arguments as break, but breakpoint is
-removed when first hit.""", file=self.stdout)
-
- def help_enable(self):
- print("""enable bpnumber [bpnumber ...]
-Enables the breakpoints given as a space separated list of
-bp numbers.""", file=self.stdout)
-
- def help_disable(self):
- print("""disable bpnumber [bpnumber ...]
-Disables the breakpoints given as a space separated list of
-bp numbers.""", file=self.stdout)
-
- def help_ignore(self):
- print("""ignore bpnumber count
-Sets the ignore count for the given breakpoint number. A breakpoint
-becomes active when the ignore count is zero. When non-zero, the
-count is decremented each time the breakpoint is reached and the
-breakpoint is not disabled and any associated condition evaluates
-to true.""", file=self.stdout)
-
- def help_condition(self):
- print("""condition bpnumber str_condition
-str_condition is a string specifying an expression which
-must evaluate to true before the breakpoint is honored.
-If str_condition is absent, any existing condition is removed;
-i.e., the breakpoint is made unconditional.""", file=self.stdout)
-
- def help_step(self):
- self.help_s()
-
- def help_s(self):
- print("""s(tep)
-Execute the current line, stop at the first possible occasion
-(either in a function that is called or in the current function).""", file=self.stdout)
-
- def help_until(self):
- self.help_unt()
-
- def help_unt(self):
- print("""unt(il)
-Continue execution until the line with a number greater than the current
-one is reached or until the current frame returns""")
-
- def help_next(self):
- self.help_n()
-
- def help_n(self):
- print("""n(ext)
-Continue execution until the next line in the current function
-is reached or it returns.""", file=self.stdout)
-
- def help_return(self):
- self.help_r()
-
- def help_r(self):
- print("""r(eturn)
-Continue execution until the current function returns.""", file=self.stdout)
-
- def help_continue(self):
- self.help_c()
-
- def help_cont(self):
- self.help_c()
-
- def help_c(self):
- print("""c(ont(inue))
-Continue execution, only stop when a breakpoint is encountered.""", file=self.stdout)
-
- def help_jump(self):
- self.help_j()
-
- def help_j(self):
- print("""j(ump) lineno
-Set the next line that will be executed.""", file=self.stdout)
-
- def help_debug(self):
- print("""debug code
-Enter a recursive debugger that steps through the code argument
-(which is an arbitrary expression or statement to be executed
-in the current environment).""", file=self.stdout)
-
- def help_list(self):
- self.help_l()
-
- def help_l(self):
- print("""l(ist) [first [,last]]
-List source code for the current file.
-Without arguments, list 11 lines around the current line
-or continue the previous listing.
-With one argument, list 11 lines starting at that line.
-With two arguments, list the given range;
-if the second argument is less than the first, it is a count.""", file=self.stdout)
-
- def help_args(self):
- self.help_a()
-
- def help_a(self):
- print("""a(rgs)
-Print the arguments of the current function.""", file=self.stdout)
-
- def help_p(self):
- print("""p(rint) expression
-Print the value of the expression.""", file=self.stdout)
-
- def help_pp(self):
- print("""pp expression
-Pretty-print the value of the expression.""", file=self.stdout)
+ prefix = ' '
+ self.message(prefix +
+ self.format_stack_entry(frame_lineno, prompt_prefix))
+
+ # Provide help
+
+ def do_help(self, arg):
+ """h(elp)
+ Without argument, print the list of available commands.
+ With a command name as argument, print help about that command.
+ "help pdb" shows the full pdb documentation.
+ "help exec" gives help on the ! command.
+ """
+ if not arg:
+ return cmd.Cmd.do_help(self, arg)
+ try:
+ try:
+ topic = getattr(self, 'help_' + arg)
+ return topic()
+ except AttributeError:
+ command = getattr(self, 'do_' + arg)
+ except AttributeError:
+ self.error('No help for %r' % arg)
+ else:
+ if sys.flags.optimize >= 2:
+ self.error('No help for %r; please do not run Python with -OO '
+ 'if you need command help' % arg)
+ return
+ self.message(command.__doc__.rstrip())
+
+ do_h = do_help
def help_exec(self):
- print("""(!) statement
-Execute the (one-line) statement in the context of
-the current stack frame.
-The exclamation point can be omitted unless the first word
-of the statement resembles a debugger command.
-To assign to a global variable you must always prefix the
-command with a 'global' command, e.g.:
-(Pdb) global list_options; list_options = ['-l']
-(Pdb)""", file=self.stdout)
-
- def help_run(self):
- print("""run [args...]
-Restart the debugged python program. If a string is supplied, it is
-splitted with "shlex" and the result is used as the new sys.argv.
-History, breakpoints, actions and debugger options are preserved.
-"restart" is an alias for "run".""")
-
- help_restart = help_run
-
- def help_quit(self):
- self.help_q()
-
- def help_q(self):
- print("""q(uit) or exit - Quit from the debugger.
-The program being executed is aborted.""", file=self.stdout)
-
- help_exit = help_q
-
- def help_whatis(self):
- print("""whatis arg
-Prints the type of the argument.""", file=self.stdout)
-
- def help_EOF(self):
- print("""EOF
-Handles the receipt of EOF as a command.""", file=self.stdout)
-
- def help_alias(self):
- print("""alias [name [command [parameter parameter ...] ]]
-Creates an alias called 'name' the executes 'command'. The command
-must *not* be enclosed in quotes. Replaceable parameters are
-indicated by %1, %2, and so on, while %* is replaced by all the
-parameters. If no command is given, the current alias for name
-is shown. If no name is given, all aliases are listed.
-
-Aliases may be nested and can contain anything that can be
-legally typed at the pdb prompt. Note! You *can* override
-internal pdb commands with aliases! Those internal commands
-are then hidden until the alias is removed. Aliasing is recursively
-applied to the first word of the command line; all other words
-in the line are left alone.
-
-Some useful aliases (especially when placed in the .pdbrc file) are:
-
-#Print instance variables (usage "pi classInst")
-alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k]
-
-#Print instance variables in self
-alias ps pi self
-""", file=self.stdout)
-
- def help_unalias(self):
- print("""unalias name
-Deletes the specified alias.""", file=self.stdout)
-
- def help_commands(self):
- print("""commands [bpnumber]
-(com) ...
-(com) end
-(Pdb)
-
-Specify a list of commands for breakpoint number bpnumber. The
-commands themselves appear on the following lines. Type a line
-containing just 'end' to terminate the commands.
-
-To remove all commands from a breakpoint, type commands and
-follow it immediately with end; that is, give no commands.
-
-With no bpnumber argument, commands refers to the last
-breakpoint set.
-
-You can use breakpoint commands to start your program up again.
-Simply use the continue command, or step, or any other
-command that resumes execution.
-
-Specifying any command resuming execution (currently continue,
-step, next, return, jump, quit and their abbreviations) terminates
-the command list (as if that command was immediately followed by end).
-This is because any time you resume execution
-(even with a simple next or step), you may encounter
-another breakpoint--which could have its own command list, leading to
-ambiguities about which list to execute.
-
- If you use the 'silent' command in the command list, the
-usual message about stopping at a breakpoint is not printed. This may
-be desirable for breakpoints that are to print a specific message and
-then continue. If none of the other commands print anything, you
-see no sign that the breakpoint was reached.
-""", file=self.stdout)
+ """(!) statement
+ Execute the (one-line) statement in the context of the current
+ stack frame. The exclamation point can be omitted unless the
+ first word of the statement resembles a debugger command. To
+ assign to a global variable you must always prefix the command
+ with a 'global' command, e.g.:
+ (Pdb) global list_options; list_options = ['-l']
+ (Pdb)
+ """
+ self.message((self.help_exec.__doc__ or '').strip())
def help_pdb(self):
help()
+ # other helper functions
+
def lookupmodule(self, filename):
"""Helper function for break/clear parsing -- may be overridden.
@@ -1219,14 +1428,33 @@ see no sign that the breakpoint was reached.
# events depends on python version). So we take special measures to
# avoid stopping before we reach the main script (see user_line and
# user_call for details).
- self._wait_for_mainpyfile = 1
+ self._wait_for_mainpyfile = True
self.mainpyfile = self.canonic(filename)
- self._user_requested_quit = 0
+ self._user_requested_quit = False
with open(filename, "rb") as fp:
statement = "exec(compile(%r, %r, 'exec'))" % \
(fp.read(), self.mainpyfile)
self.run(statement)
+# Collect all command help into docstring, if not run with -OO
+
+if __doc__ is not None:
+ # unfortunately we can't guess this order from the class definition
+ _help_order = [
+ 'help', 'where', 'down', 'up', 'break', 'tbreak', 'clear', 'disable',
+ 'enable', 'ignore', 'condition', 'commands', 'step', 'next', 'until',
+ 'jump', 'return', 'retval', 'run', 'continue', 'list', 'longlist',
+ 'args', 'print', 'pp', 'whatis', 'source', 'display', 'undisplay',
+ 'interact', 'alias', 'unalias', 'debug', 'quit',
+ ]
+
+ for _command in _help_order:
+ __doc__ += getattr(Pdb, 'do_' + _command).__doc__.strip() + '\n\n'
+ __doc__ += Pdb.help_exec.__doc__
+
+ del _help_order, _command
+
+
# Simplified interface
def run(statement, globals=None, locals=None):
@@ -1253,9 +1481,9 @@ def post_mortem(t=None):
# sys.exc_info() returns (type, value, traceback) if an exception is
# being handled, otherwise it returns None
t = sys.exc_info()[2]
- if t is None:
- raise ValueError("A valid traceback must be passed if no "
- "exception is being handled")
+ if t is None:
+ raise ValueError("A valid traceback must be passed if no "
+ "exception is being handled")
p = Pdb()
p.reset()
@@ -1274,27 +1502,45 @@ def test():
# print help
def help():
- for dirname in sys.path:
- fullname = os.path.join(dirname, 'pdb.doc')
- if os.path.exists(fullname):
- sts = os.system('${PAGER-more} '+fullname)
- if sts: print('*** Pager exit status:', sts)
- break
- else:
- print('Sorry, can\'t find the help file "pdb.doc"', end=' ')
- print('along the Python search path')
+ import pydoc
+ pydoc.pager(__doc__)
+
+_usage = """\
+usage: pdb.py [-c command] ... pyfile [arg] ...
+
+Debug the Python program given by pyfile.
+
+Initial commands are read from .pdbrc files in your home directory
+and in the current directory, if they exist. Commands supplied with
+-c are executed after commands from .pdbrc files.
+
+To let the script run until an exception occurs, use "-c continue".
+To let the script run up to a given line X in the debugged file, use
+"-c 'until X'"."""
def main():
- if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
- print("usage: pdb.py scriptfile [arg] ...")
+ import getopt
+
+ opts, args = getopt.getopt(sys.argv[1:], 'hc:', ['--help', '--command='])
+
+ if not args:
+ print(_usage)
sys.exit(2)
- mainpyfile = sys.argv[1] # Get script filename
+ commands = []
+ for opt, optarg in opts:
+ if opt in ['-h', '--help']:
+ print(_usage)
+ sys.exit()
+ elif opt in ['-c', '--command']:
+ commands.append(optarg)
+
+ mainpyfile = args[0] # Get script filename
if not os.path.exists(mainpyfile):
print('Error:', mainpyfile, 'does not exist')
sys.exit(1)
- del sys.argv[0] # Hide "pdb.py" from argument list
+ sys.argv[:] = args # Hide "pdb.py" and pdb options from argument list
# Replace pdb's dir with script's dir in front of module search path.
sys.path[0] = os.path.dirname(mainpyfile)
@@ -1304,6 +1550,7 @@ def main():
# changed by the user from the command line. There is a "restart" command
# which allows explicit specification of command line arguments.
pdb = Pdb()
+ pdb.rcLines.extend(commands)
while True:
try:
pdb._runscript(mainpyfile)
@@ -1312,10 +1559,10 @@ def main():
print("The program finished and will be restarted")
except Restart:
print("Restarting", mainpyfile, "with arguments:")
- print("\t" + " ".join(sys.argv[1:]))
+ print("\t" + " ".join(args))
except SystemExit:
# In most cases SystemExit does not warrant a post-mortem session.
- print("The program exited via sys.exit(). Exit status: ", end=' ')
+ print("The program exited via sys.exit(). Exit status:", end=' ')
print(sys.exc_info()[1])
except:
traceback.print_exc()
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 5275991662..aca8fd183c 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -1235,9 +1235,7 @@ class _Unpickler:
raise _Stop(value)
dispatch[STOP[0]] = load_stop
-# Encode/decode longs in linear time.
-
-import binascii as _binascii
+# Encode/decode longs.
def encode_long(x):
r"""Encode a long to a two's complement little-endian binary string.
@@ -1260,50 +1258,14 @@ def encode_long(x):
b'\x7f'
>>>
"""
-
if x == 0:
return b''
- if x > 0:
- ashex = hex(x)
- assert ashex.startswith("0x")
- njunkchars = 2 + ashex.endswith('L')
- nibbles = len(ashex) - njunkchars
- if nibbles & 1:
- # need an even # of nibbles for unhexlify
- ashex = "0x0" + ashex[2:]
- elif int(ashex[2], 16) >= 8:
- # "looks negative", so need a byte of sign bits
- ashex = "0x00" + ashex[2:]
- else:
- # Build the 256's-complement: (1L << nbytes) + x. The trick is
- # to find the number of bytes in linear time (although that should
- # really be a constant-time task).
- ashex = hex(-x)
- assert ashex.startswith("0x")
- njunkchars = 2 + ashex.endswith('L')
- nibbles = len(ashex) - njunkchars
- if nibbles & 1:
- # Extend to a full byte.
- nibbles += 1
- nbits = nibbles * 4
- x += 1 << nbits
- assert x > 0
- ashex = hex(x)
- njunkchars = 2 + ashex.endswith('L')
- newnibbles = len(ashex) - njunkchars
- if newnibbles < nibbles:
- ashex = "0x" + "0" * (nibbles - newnibbles) + ashex[2:]
- if int(ashex[2], 16) < 8:
- # "looks positive", so need a byte of sign bits
- ashex = "0xff" + ashex[2:]
-
- if ashex.endswith('L'):
- ashex = ashex[2:-1]
- else:
- ashex = ashex[2:]
- assert len(ashex) & 1 == 0, (x, ashex)
- binary = _binascii.unhexlify(ashex)
- return bytes(binary[::-1])
+ nbytes = (x.bit_length() >> 3) + 1
+ result = x.to_bytes(nbytes, byteorder='little', signed=True)
+ if x < 0 and nbytes > 1:
+ if result[-1] == 0xff and (result[-2] & 0x80) != 0:
+ result = result[:-1]
+ return result
def decode_long(data):
r"""Decode a long from a two's complement little-endian binary string.
@@ -1323,21 +1285,7 @@ def decode_long(data):
>>> decode_long(b"\x7f")
127
"""
-
- nbytes = len(data)
- if nbytes == 0:
- return 0
- ashex = _binascii.hexlify(data[::-1])
- n = int(ashex, 16) # quadratic time before Python 2.3; linear now
- if data[-1] >= 0x80:
- n -= 1 << (nbytes * 8)
- return n
-
-# Use the faster _pickle if possible
-try:
- from _pickle import *
-except ImportError:
- Pickler, Unpickler = _Pickler, _Unpickler
+ return int.from_bytes(data, byteorder='little', signed=True)
# Shorthands
@@ -1362,10 +1310,38 @@ def loads(s, *, fix_imports=True, encoding="ASCII", errors="strict"):
return Unpickler(file, fix_imports=fix_imports,
encoding=encoding, errors=errors).load()
+# Use the faster _pickle if possible
+try:
+ from _pickle import *
+except ImportError:
+ Pickler, Unpickler = _Pickler, _Unpickler
+
# Doctest
def _test():
import doctest
return doctest.testmod()
if __name__ == "__main__":
- _test()
+ import sys, argparse
+ parser = argparse.ArgumentParser(
+ description='display contents of the pickle files')
+ parser.add_argument(
+ 'pickle_file', type=argparse.FileType('br'),
+ nargs='*', help='the pickle file')
+ parser.add_argument(
+ '-t', '--test', action='store_true',
+ help='run self-test suite')
+ parser.add_argument(
+ '-v', action='store_true',
+ help='run verbosely; only affects self-test run')
+ args = parser.parse_args()
+ if args.test:
+ _test()
+ else:
+ if not args.pickle_file:
+ parser.print_help()
+ else:
+ import pprint
+ for f in args.pickle_file:
+ obj = load(f)
+ pprint.pprint(obj)
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index 0af2fdba13..3061675c22 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -1907,7 +1907,7 @@ def optimize(p):
##############################################################################
# A symbolic pickle disassembler.
-def dis(pickle, out=None, memo=None, indentlevel=4):
+def dis(pickle, out=None, memo=None, indentlevel=4, annotate=0):
"""Produce a symbolic disassembly of a pickle.
'pickle' is a file-like object, or string, containing a (at least one)
@@ -1923,9 +1923,15 @@ def dis(pickle, out=None, memo=None, indentlevel=4):
to proceed across multiple pickles that were all created by the same
pickler with the same memo. Ordinarily you don't need to worry about this.
- Optional arg indentlevel is the number of blanks by which to indent
+ Optional arg 'indentlevel' is the number of blanks by which to indent
a new MARK level. It defaults to 4.
+ Optional arg 'annotate' if nonzero instructs dis() to add short
+ description of the opcode on each line of disassembled output.
+ The value given to 'annotate' must be an integer and is used as a
+ hint for the column where annotation should start. The default
+ value is 0, meaning no annotations.
+
In addition to printing the disassembly, some sanity checks are made:
+ All embedded opcode arguments "make sense".
@@ -1953,6 +1959,7 @@ def dis(pickle, out=None, memo=None, indentlevel=4):
markstack = [] # bytecode positions of MARK opcodes
indentchunk = ' ' * indentlevel
errormsg = None
+ annocol = annotate # columnt hint for annotations
for opcode, arg, pos in genops(pickle):
if pos is not None:
print("%5d:" % pos, end=' ', file=out)
@@ -2020,6 +2027,13 @@ def dis(pickle, out=None, memo=None, indentlevel=4):
line += ' ' + repr(arg)
if markmsg:
line += ' ' + markmsg
+ if annotate:
+ line += ' ' * (annocol - len(line))
+ # make a mild effort to align annotations
+ annocol = len(line)
+ if annocol > 50:
+ annocol = annotate
+ line += ' ' + opcode.doc.split('\n', 1)[0]
print(line, file=out)
if errormsg:
@@ -2293,6 +2307,22 @@ highest protocol among opcodes = 2
12: h BINGET 1
14: . STOP
highest protocol among opcodes = 2
+
+Try protocol 3 with annotations:
+
+>>> dis(pickle.dumps(T, 3), annotate=1)
+ 0: \x80 PROTO 3 Protocol version indicator.
+ 2: ] EMPTY_LIST Push an empty list.
+ 3: q BINPUT 0 Store the stack top into the memo. The stack is not popped.
+ 5: h BINGET 0 Read an object from the memo and push it on the stack.
+ 7: \x85 TUPLE1 Build a one-tuple out of the topmost item on the stack.
+ 8: q BINPUT 1 Store the stack top into the memo. The stack is not popped.
+ 10: a APPEND Append an object to a list.
+ 11: 0 POP Discard the top stack item, shrinking the stack by one item.
+ 12: h BINGET 1 Read an object from the memo and push it on the stack.
+ 14: . STOP Stop the unpickling machine.
+highest protocol among opcodes = 2
+
"""
_memo_test = r"""
@@ -2333,4 +2363,47 @@ def _test():
return doctest.testmod()
if __name__ == "__main__":
- _test()
+ import sys, argparse
+ parser = argparse.ArgumentParser(
+ description='disassemble one or more pickle files')
+ parser.add_argument(
+ 'pickle_file', type=argparse.FileType('br'),
+ nargs='*', help='the pickle file')
+ parser.add_argument(
+ '-o', '--output', default=sys.stdout, type=argparse.FileType('w'),
+ help='the file where the output should be written')
+ parser.add_argument(
+ '-m', '--memo', action='store_true',
+ help='preserve memo between disassemblies')
+ parser.add_argument(
+ '-l', '--indentlevel', default=4, type=int,
+ help='the number of blanks by which to indent a new MARK level')
+ parser.add_argument(
+ '-a', '--annotate', action='store_true',
+ help='annotate each line with a short opcode description')
+ parser.add_argument(
+ '-p', '--preamble', default="==> {name} <==",
+ help='if more than one pickle file is specified, print this before'
+ ' each disassembly')
+ parser.add_argument(
+ '-t', '--test', action='store_true',
+ help='run self-test suite')
+ parser.add_argument(
+ '-v', action='store_true',
+ help='run verbosely; only affects self-test run')
+ args = parser.parse_args()
+ if args.test:
+ _test()
+ else:
+ annotate = 30 if args.annotate else 0
+ if not args.pickle_file:
+ parser.print_help()
+ elif len(args.pickle_file) == 1:
+ dis(args.pickle_file[0], args.output, None,
+ args.indentlevel, annotate)
+ else:
+ memo = {} if args.memo else None
+ for f in args.pickle_file:
+ preamble = args.preamble.format(name=f.name)
+ args.output.write(preamble + '\n')
+ dis(f, args.output, memo, args.indentlevel, annotate)
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py
index 0ec6ec5265..b48627565c 100644
--- a/Lib/pkgutil.py
+++ b/Lib/pkgutil.py
@@ -241,7 +241,8 @@ class ImpLoader:
return mod
def get_data(self, pathname):
- return open(pathname, "rb").read()
+ with open(pathname, "rb") as file:
+ return file.read()
def _reopen(self):
if self.file and self.file.closed:
diff --git a/Lib/plat-atheos/IN.py b/Lib/plat-atheos/IN.py
deleted file mode 100644
index 9e77efc75c..0000000000
--- a/Lib/plat-atheos/IN.py
+++ /dev/null
@@ -1,944 +0,0 @@
-# Generated by h2py from /include/netinet/in.h
-_NETINET_IN_H = 1
-
-# Included from features.h
-_FEATURES_H = 1
-__USE_ANSI = 1
-__FAVOR_BSD = 1
-_ISOC9X_SOURCE = 1
-_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 199506
-_XOPEN_SOURCE = 500
-_XOPEN_SOURCE_EXTENDED = 1
-_LARGEFILE64_SOURCE = 1
-_BSD_SOURCE = 1
-_SVID_SOURCE = 1
-_BSD_SOURCE = 1
-_SVID_SOURCE = 1
-__USE_ISOC9X = 1
-_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 2
-_POSIX_C_SOURCE = 199506
-__USE_POSIX = 1
-__USE_POSIX2 = 1
-__USE_POSIX199309 = 1
-__USE_POSIX199506 = 1
-__USE_XOPEN = 1
-__USE_XOPEN_EXTENDED = 1
-__USE_UNIX98 = 1
-_LARGEFILE_SOURCE = 1
-__USE_XOPEN_EXTENDED = 1
-__USE_LARGEFILE = 1
-__USE_LARGEFILE64 = 1
-__USE_FILE_OFFSET64 = 1
-__USE_MISC = 1
-__USE_BSD = 1
-__USE_SVID = 1
-__USE_GNU = 1
-__USE_REENTRANT = 1
-__STDC_IEC_559__ = 1
-__STDC_IEC_559_COMPLEX__ = 1
-__GNU_LIBRARY__ = 6
-__GLIBC__ = 2
-__GLIBC_MINOR__ = 1
-
-# Included from sys/cdefs.h
-_SYS_CDEFS_H = 1
-def __PMT(args): return args
-
-def __P(args): return args
-
-def __PMT(args): return args
-
-def __P(args): return ()
-
-def __PMT(args): return ()
-
-def __STRING(x): return #x
-
-def __STRING(x): return "x"
-
-def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
-
-def __attribute__(xyz): return
-
-__USE_EXTERN_INLINES = 1
-
-# Included from gnu/stubs.h
-
-# Included from limits.h
-_LIBC_LIMITS_H_ = 1
-
-# Included from bits/posix1_lim.h
-_BITS_POSIX1_LIM_H = 1
-_POSIX_AIO_LISTIO_MAX = 2
-_POSIX_AIO_MAX = 1
-_POSIX_ARG_MAX = 4096
-_POSIX_CHILD_MAX = 6
-_POSIX_DELAYTIMER_MAX = 32
-_POSIX_LINK_MAX = 8
-_POSIX_MAX_CANON = 255
-_POSIX_MAX_INPUT = 255
-_POSIX_MQ_OPEN_MAX = 8
-_POSIX_MQ_PRIO_MAX = 32
-_POSIX_NGROUPS_MAX = 0
-_POSIX_OPEN_MAX = 16
-_POSIX_FD_SETSIZE = _POSIX_OPEN_MAX
-_POSIX_NAME_MAX = 14
-_POSIX_PATH_MAX = 255
-_POSIX_PIPE_BUF = 512
-_POSIX_RTSIG_MAX = 8
-_POSIX_SEM_NSEMS_MAX = 256
-_POSIX_SEM_VALUE_MAX = 32767
-_POSIX_SIGQUEUE_MAX = 32
-_POSIX_SSIZE_MAX = 32767
-_POSIX_STREAM_MAX = 8
-_POSIX_TZNAME_MAX = 3
-_POSIX_QLIMIT = 1
-_POSIX_HIWAT = _POSIX_PIPE_BUF
-_POSIX_UIO_MAXIOV = 16
-_POSIX_TTY_NAME_MAX = 9
-_POSIX_TIMER_MAX = 32
-_POSIX_LOGIN_NAME_MAX = 9
-_POSIX_CLOCKRES_MIN = 20000000
-
-# Included from bits/local_lim.h
-
-# Included from posix/limits.h
-CHAR_BIT = 8
-CHAR_MAX = 127
-CHAR_MIN = (-128)
-INT_MAX = 2147483647
-INT_MIN = (-2147483647-1)
-LONG_MAX = 2147483647
-LONG_MIN = (-2147483647-1)
-SCHAR_MAX = 127
-SCHAR_MIN = (-128)
-SHRT_MAX = 32767
-SHRT_MIN = (-32768)
-UCHAR_MAX = 255
-USHRT_MAX = 65535
-_POSIX_ARG_MAX = 131072
-_POSIX_CHILD_MAX = 4096
-_POSIX_LINK_MAX = 1
-_POSIX_MAX_CANON = 126
-_POSIX_MAX_INPUT = 126
-_POSIX_NAME_MAX = 256
-_POSIX_NGROUPS_MAX = 32
-_POSIX_OPEN_MAX = 256
-_POSIX_PATH_MAX = 255
-_POSIX_PIPE_BUF = 512
-_POSIX_SSIZE_MAX = 2147483647
-_POSIX_STREAM_MAX = 256
-_POSIX_TZNAME_MAX = 5
-NGROUPS_MAX = 32
-ARG_MAX = 131072
-CHILD_MAX = 4096
-OPEN_MAX = 256
-LINK_MAX = 1
-MAX_CANON = 126
-MAX_INPUT = 126
-NAME_MAX = 255
-PATH_MAX = 4096
-PIPE_BUF = 4096
-SSIZE_MAX = 2147483647
-MAXSYMLINKS = 16
-AIO_PRIO_DELTA_MAX = 20
-SSIZE_MAX = INT_MAX
-NGROUPS_MAX = _POSIX_NGROUPS_MAX
-
-# Included from bits/posix2_lim.h
-_BITS_POSIX2_LIM_H = 1
-_POSIX2_BC_BASE_MAX = 99
-_POSIX2_BC_DIM_MAX = 2048
-_POSIX2_BC_SCALE_MAX = 99
-_POSIX2_BC_STRING_MAX = 1000
-_POSIX2_COLL_WEIGHTS_MAX = 255
-_POSIX2_EQUIV_CLASS_MAX = 255
-_POSIX2_EXPR_NEST_MAX = 32
-_POSIX2_LINE_MAX = 2048
-_POSIX2_RE_DUP_MAX = 255
-_POSIX2_CHARCLASS_NAME_MAX = 2048
-BC_BASE_MAX = _POSIX2_BC_BASE_MAX
-BC_DIM_MAX = _POSIX2_BC_DIM_MAX
-BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX
-BC_STRING_MAX = _POSIX2_BC_STRING_MAX
-COLL_WEIGHTS_MAX = _POSIX2_COLL_WEIGHTS_MAX
-EQUIV_CLASS_MAX = _POSIX2_EQUIV_CLASS_MAX
-EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX
-LINE_MAX = _POSIX2_LINE_MAX
-RE_DUP_MAX = _POSIX2_RE_DUP_MAX
-CHARCLASS_NAME_MAX = _POSIX2_CHARCLASS_NAME_MAX
-
-# Included from bits/xopen_lim.h
-_XOPEN_LIM_H = 1
-
-# Included from bits/stdio_lim.h
-L_tmpnam = 20
-TMP_MAX = 238328
-FILENAME_MAX = 4096
-L_ctermid = 9
-L_cuserid = 9
-FOPEN_MAX = 256
-STREAM_MAX = FOPEN_MAX
-TZNAME_MAX = _POSIX_TZNAME_MAX
-_XOPEN_IOV_MAX = _POSIX_UIO_MAXIOV
-NL_ARGMAX = _POSIX_ARG_MAX
-NL_LANGMAX = _POSIX2_LINE_MAX
-NL_MSGMAX = INT_MAX
-NL_NMAX = INT_MAX
-NL_SETMAX = INT_MAX
-NL_TEXTMAX = INT_MAX
-NZERO = 20
-MB_LEN_MAX = 6
-_LIMITS_H = 1
-CHAR_BIT = 8
-SCHAR_MIN = (-128)
-SCHAR_MAX = 127
-UCHAR_MAX = 255
-CHAR_MIN = 0
-CHAR_MAX = UCHAR_MAX
-CHAR_MIN = SCHAR_MIN
-CHAR_MAX = SCHAR_MAX
-SHRT_MIN = (-32768)
-SHRT_MAX = 32767
-USHRT_MAX = 65535
-INT_MIN = (-INT_MAX - 1)
-INT_MAX = 2147483647
-UINT_MAX = 4294967295
-LONG_MAX = 9223372036854775807
-LONG_MAX = 2147483647
-LONG_MIN = (-LONG_MAX - 1)
-ULONG_MAX = 4294967295
-
-# Included from stdint.h
-_STDINT_H = 1
-
-# Included from bits/wordsize.h
-__WORDSIZE = 32
-def __INT64_C(c): return c ## L
-
-def __UINT64_C(c): return c ## UL
-
-def __INT64_C(c): return c ## LL
-
-def __UINT64_C(c): return c ## ULL
-
-INT8_MIN = (-128)
-INT16_MIN = (-32767-1)
-INT32_MIN = (-2147483647-1)
-INT64_MIN = (-__INT64_C(9223372036854775807)-1)
-INT8_MAX = (127)
-INT16_MAX = (32767)
-INT32_MAX = (2147483647)
-INT64_MAX = (__INT64_C(9223372036854775807))
-UINT64_MAX = (__UINT64_C(18446744073709551615))
-INT_LEAST8_MIN = (-128)
-INT_LEAST16_MIN = (-32767-1)
-INT_LEAST32_MIN = (-2147483647-1)
-INT_LEAST64_MIN = (-__INT64_C(9223372036854775807)-1)
-INT_LEAST8_MAX = (127)
-INT_LEAST16_MAX = (32767)
-INT_LEAST32_MAX = (2147483647)
-INT_LEAST64_MAX = (__INT64_C(9223372036854775807))
-UINT_LEAST64_MAX = (__UINT64_C(18446744073709551615))
-INT_FAST8_MIN = (-128)
-INT_FAST16_MIN = (-9223372036854775807-1)
-INT_FAST32_MIN = (-9223372036854775807-1)
-INT_FAST16_MIN = (-2147483647-1)
-INT_FAST32_MIN = (-2147483647-1)
-INT_FAST64_MIN = (-__INT64_C(9223372036854775807)-1)
-INT_FAST8_MAX = (127)
-INT_FAST16_MAX = (9223372036854775807)
-INT_FAST32_MAX = (9223372036854775807)
-INT_FAST16_MAX = (2147483647)
-INT_FAST32_MAX = (2147483647)
-INT_FAST64_MAX = (__INT64_C(9223372036854775807))
-UINT_FAST64_MAX = (__UINT64_C(18446744073709551615))
-INTPTR_MIN = (-9223372036854775807-1)
-INTPTR_MAX = (9223372036854775807)
-INTPTR_MIN = (-2147483647-1)
-INTPTR_MAX = (2147483647)
-INTMAX_MIN = (-__INT64_C(9223372036854775807)-1)
-INTMAX_MAX = (__INT64_C(9223372036854775807))
-UINTMAX_MAX = (__UINT64_C(18446744073709551615))
-PTRDIFF_MIN = (-9223372036854775807-1)
-PTRDIFF_MAX = (9223372036854775807)
-PTRDIFF_MIN = (-2147483647-1)
-PTRDIFF_MAX = (2147483647)
-SIG_ATOMIC_MIN = (-2147483647-1)
-SIG_ATOMIC_MAX = (2147483647)
-WCHAR_MIN = (-2147483647-1)
-WCHAR_MAX = (2147483647)
-WINT_MIN = (0)
-def INT8_C(c): return c
-
-def INT16_C(c): return c
-
-def INT32_C(c): return c
-
-def INT64_C(c): return c ## L
-
-def INT64_C(c): return c ## LL
-
-def UINT8_C(c): return c ## U
-
-def UINT16_C(c): return c ## U
-
-def UINT32_C(c): return c ## U
-
-def UINT64_C(c): return c ## UL
-
-def UINT64_C(c): return c ## ULL
-
-def INTMAX_C(c): return c ## L
-
-def UINTMAX_C(c): return c ## UL
-
-def INTMAX_C(c): return c ## LL
-
-def UINTMAX_C(c): return c ## ULL
-
-
-# Included from sys/types.h
-_SYS_TYPES_H = 1
-
-# Included from bits/types.h
-_BITS_TYPES_H = 1
-__FD_SETSIZE = 1024
-def __FDELT(d): return ((d) / __NFDBITS)
-
-
-# Included from bits/pthreadtypes.h
-
-# Included from time.h
-_TIME_H = 1
-
-# Included from bits/time.h
-
-# Included from posix/time.h
-
-# Included from posix/types.h
-MAXHOSTNAMELEN = 64
-FD_SETSIZE = 1024
-CLOCKS_PER_SEC = 1000000
-_BITS_TIME_H = 1
-CLOCKS_PER_SEC = 1000000
-CLK_TCK = 100
-_STRUCT_TIMEVAL = 1
-CLK_TCK = CLOCKS_PER_SEC
-__clock_t_defined = 1
-__time_t_defined = 1
-__timespec_defined = 1
-def __isleap(year): return \
-
-__BIT_TYPES_DEFINED__ = 1
-
-# Included from endian.h
-_ENDIAN_H = 1
-__LITTLE_ENDIAN = 1234
-__BIG_ENDIAN = 4321
-__PDP_ENDIAN = 3412
-
-# Included from bits/endian.h
-__BYTE_ORDER = __LITTLE_ENDIAN
-__FLOAT_WORD_ORDER = __BYTE_ORDER
-LITTLE_ENDIAN = __LITTLE_ENDIAN
-BIG_ENDIAN = __BIG_ENDIAN
-PDP_ENDIAN = __PDP_ENDIAN
-BYTE_ORDER = __BYTE_ORDER
-
-# Included from sys/select.h
-_SYS_SELECT_H = 1
-
-# Included from bits/select.h
-def __FD_ZERO(fdsp): return \
-
-def __FD_ZERO(set): return \
-
-
-# Included from bits/sigset.h
-_SIGSET_H_types = 1
-_SIGSET_H_fns = 1
-def __sigmask(sig): return \
-
-def __sigemptyset(set): return \
-
-def __sigfillset(set): return \
-
-def __sigisemptyset(set): return \
-
-FD_SETSIZE = __FD_SETSIZE
-def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp)
-
-
-# Included from sys/sysmacros.h
-_SYS_SYSMACROS_H = 1
-def major(dev): return ( (( (dev) >> 8) & 0xff))
-
-def minor(dev): return ( ((dev) & 0xff))
-
-
-# Included from bits/socket.h
-PF_UNSPEC = 0
-PF_LOCAL = 1
-PF_UNIX = PF_LOCAL
-PF_FILE = PF_LOCAL
-PF_INET = 2
-PF_AX25 = 3
-PF_IPX = 4
-PF_APPLETALK = 5
-PF_NETROM = 6
-PF_BRIDGE = 7
-PF_ATMPVC = 8
-PF_X25 = 9
-PF_INET6 = 10
-PF_ROSE = 11
-PF_DECnet = 12
-PF_NETBEUI = 13
-PF_SECURITY = 14
-PF_KEY = 15
-PF_NETLINK = 16
-PF_ROUTE = PF_NETLINK
-PF_PACKET = 17
-PF_ASH = 18
-PF_ECONET = 19
-PF_ATMSVC = 20
-PF_SNA = 22
-PF_IRDA = 23
-PF_MAX = 32
-AF_UNSPEC = PF_UNSPEC
-AF_LOCAL = PF_LOCAL
-AF_UNIX = PF_UNIX
-AF_FILE = PF_FILE
-AF_INET = PF_INET
-AF_AX25 = PF_AX25
-AF_IPX = PF_IPX
-AF_APPLETALK = PF_APPLETALK
-AF_NETROM = PF_NETROM
-AF_BRIDGE = PF_BRIDGE
-AF_ATMPVC = PF_ATMPVC
-AF_X25 = PF_X25
-AF_INET6 = PF_INET6
-AF_ROSE = PF_ROSE
-AF_DECnet = PF_DECnet
-AF_NETBEUI = PF_NETBEUI
-AF_SECURITY = PF_SECURITY
-AF_KEY = PF_KEY
-AF_NETLINK = PF_NETLINK
-AF_ROUTE = PF_ROUTE
-AF_PACKET = PF_PACKET
-AF_ASH = PF_ASH
-AF_ECONET = PF_ECONET
-AF_ATMSVC = PF_ATMSVC
-AF_SNA = PF_SNA
-AF_IRDA = PF_IRDA
-AF_MAX = PF_MAX
-SOL_RAW = 255
-SOL_DECNET = 261
-SOL_X25 = 262
-SOL_PACKET = 263
-SOL_ATM = 264
-SOL_AAL = 265
-SOL_IRDA = 266
-SOMAXCONN = 128
-
-# Included from bits/sockaddr.h
-_BITS_SOCKADDR_H = 1
-def __SOCKADDR_COMMON(sa_prefix): return \
-
-_SS_SIZE = 128
-def CMSG_FIRSTHDR(mhdr): return \
-
-
-# Included from atheos/socket.h
-
-# Included from atheos/types.h
-OS_NAME_LENGTH = 64
-TRUE = 1
-FALSE = 0
-
-# Included from atheos/filesystem.h
-
-# Included from atheos/atomic.h
-
-# Included from atheos/typedefs.h
-
-# Included from atheos/fs_attribs.h
-
-# Included from atheos/kernel.h
-
-# Included from atheos/kdebug.h
-
-# Included from atheos/threads.h
-TF_DEADLOCK = 0x0001
-DB_PACKET_SIZE = 128
-DB_PORT_COUNT = 16
-DBP_PRINTK = 0
-DBP_DEBUGGER = 2
-
-# Included from atheos/stdlib.h
-
-# Included from atheos/string.h
-def COMMON(x): return \
-
-def COMMON(x): return \
-
-
-# Included from atheos/schedule.h
-
-# Included from atheos/timer.h
-
-# Included from posix/resource.h
-RUSAGE_SELF = 0
-RUSAGE_CHILDREN = -1
-RLIMIT_CPU = 0
-RLIMIT_FSIZE = 1
-RLIMIT_DATA = 2
-RLIMIT_STACK = 3
-RLIMIT_CORE = 4
-RLIMIT_RSS = 5
-RLIMIT_MEMLOCK = 6
-RLIMIT_NPROC = 7
-RLIMIT_NOFILE = 8
-RLIMIT_AS = 9
-RLIM_NLIMITS = 10
-
-# Included from atheos/v86.h
-
-# Included from atheos/areas.h
-MEMF_REAL = 0x00000002
-MEMF_USER = 0x00000004
-MEMF_BUFFER = 0x00000008
-MEMF_KERNEL = 0x00000010
-MEMF_OKTOFAILHACK = 0x00000020
-MEMF_PRI_MASK = 0x000000ff
-MEMF_NOBLOCK = 0x00000100
-MEMF_CLEAR = 0x00010000
-MEMF_LOCKED = 0x10000000
-PAGE_SHIFT = 12
-PGDIR_SHIFT = 22
-def PAGE_ALIGN(addr): return (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
-AREA_NO_LOCK = 0
-AREA_LAZY_LOCK = 1
-AREA_FULL_LOCK = 2
-AREA_CONTIGUOUS = 3
-AREA_READ = 0x00000001
-AREA_WRITE = 0x00000002
-AREA_EXEC = 0x00000004
-AREA_FULL_ACCESS = (AREA_READ | AREA_WRITE | AREA_EXEC)
-AREA_KERNEL = 0x00000008
-AREA_UNMAP_PHYS = 0x00000010
-AREA_ANY_ADDRESS = 0x00000000
-AREA_EXACT_ADDRESS = 0x00000100
-AREA_BASE_ADDRESS = 0x00000200
-AREA_CLONE_ADDRESS = 0x00000300
-AREA_ADDR_SPEC_MASK = 0x00000f00
-AREA_TOP_DOWN = 0x00001000
-AREA_REMAPPED = 0x0020
-AREA_SHARED = 0x0040
-AREA_GROWSDOWN = 0x0080
-AREA_FIRST_KERNEL_ADDRESS = 0x00100000
-AREA_LAST_KERNEL_ADDRESS = 0x7fffffff
-AREA_FIRST_USER_ADDRESS = 0x80000000
-AREA_LAST_USER_ADDRESS = 0xffffffff
-MAX_CPU_COUNT = 16
-def kfree(p): return kassertw( __kfree(p) == 0 )
-
-
-# Included from posix/dirent.h
-MAXNAMLEN = NAME_MAX
-MAXNAMLEN = 255
-
-# Included from dirent.h
-_DIRENT_H = 1
-
-# Included from bits/dirent.h
-def _D_ALLOC_NAMLEN(d): return (_D_EXACT_NAMLEN (d) + 1)
-
-def IFTODT(mode): return (((mode) & 0o170000) >> 12)
-
-def DTTOIF(dirtype): return ((dirtype) << 12)
-
-def dirfd(dirp): return _DIR_dirfd (dirp)
-
-MAXNAMLEN = NAME_MAX
-MAXNAMLEN = 255
-
-# Included from posix/stat.h
-S_IFMT = 0o0170000
-S_IFSOCK = 0o140000
-S_IFLNK = 0o120000
-S_IFREG = 0o100000
-S_IFBLK = 0o060000
-S_IFDIR = 0o040000
-S_IFCHR = 0o020000
-S_IFIFO = 0o010000
-S_ISUID = 0o004000
-S_ISGID = 0o002000
-S_ISVTX = 0o001000
-def S_ISLNK(m): return (((m) & S_IFMT) == S_IFLNK)
-
-def S_ISREG(m): return (((m) & S_IFMT) == S_IFREG)
-
-def S_ISDIR(m): return (((m) & S_IFMT) == S_IFDIR)
-
-def S_ISCHR(m): return (((m) & S_IFMT) == S_IFCHR)
-
-def S_ISBLK(m): return (((m) & S_IFMT) == S_IFBLK)
-
-def S_ISFIFO(m): return (((m) & S_IFMT) == S_IFIFO)
-
-def S_ISSOCK(m): return (((m) & S_IFMT) == S_IFSOCK)
-
-S_IRWXU = 0o0700
-S_IRUSR = 0o0400
-S_IWUSR = 0o0200
-S_IXUSR = 0o0100
-S_IRWXG = 0o0070
-S_IRGRP = 0o0040
-S_IWGRP = 0o0020
-S_IXGRP = 0o0010
-S_IRWXO = 0o0007
-S_IROTH = 0o0004
-S_IWOTH = 0o0002
-S_IXOTH = 0o0001
-S_IRWXUGO = (S_IRWXU|S_IRWXG|S_IRWXO)
-S_IALLUGO = (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
-S_IRUGO = (S_IRUSR|S_IRGRP|S_IROTH)
-S_IWUGO = (S_IWUSR|S_IWGRP|S_IWOTH)
-S_IXUGO = (S_IXUSR|S_IXGRP|S_IXOTH)
-_STAT_VER_KERNEL = 0
-
-# Included from posix/fcntl.h
-O_ACCMODE = 0o003
-O_RWMASK = O_ACCMODE
-O_RDONLY = 00
-O_WRONLY = 0o1
-O_RDWR = 0o2
-O_CREAT = 0o100
-O_EXCL = 0o200
-O_NOCTTY = 0o400
-O_TRUNC = 0o1000
-O_APPEND = 0o2000
-O_NONBLOCK = 0o4000
-O_NDELAY = O_NONBLOCK
-O_SYNC = 0o10000
-O_FSYNC = O_SYNC
-O_ASYNC = 0o20000
-FASYNC = O_ASYNC
-O_DIRECTORY = 0o40000
-O_NOTRAVERSE = 0o100000
-O_NOFOLLOW = O_NOTRAVERSE
-F_DUPFD = 0
-F_GETFD = 1
-F_SETFD = 2
-F_GETFL = 3
-F_SETFL = 4
-F_GETLK = 5
-F_SETLK = 6
-F_SETLKW = 7
-F_SETOWN = 8
-F_GETOWN = 9
-F_SETSIG = 10
-F_GETSIG = 11
-F_COPYFD = 12
-FD_CLOEXEC = 1
-F_RDLCK = 0
-F_WRLCK = 1
-F_UNLCK = 2
-F_EXLCK = 4
-F_SHLCK = 8
-LOCK_SH = 1
-LOCK_EX = 2
-LOCK_NB = 4
-LOCK_UN = 8
-
-# Included from posix/uio.h
-UIO_FASTIOV = 8
-UIO_MAXIOV = 1024
-MNTF_READONLY = 0x0001
-FS_IS_READONLY = 0x00000001
-FS_IS_REMOVABLE = 0x00000002
-FS_IS_PERSISTENT = 0x00000004
-FS_IS_SHARED = 0x00000008
-FS_IS_BLOCKBASED = 0x00000010
-FS_CAN_MOUNT = 0x00000020
-FS_HAS_MIME = 0x00010000
-FS_HAS_ATTR = 0x00020000
-FS_HAS_QUERY = 0x00040000
-FSINFO_VERSION = 1
-WSTAT_MODE = 0x0001
-WSTAT_UID = 0x0002
-WSTAT_GID = 0x0004
-WSTAT_SIZE = 0x0008
-WSTAT_ATIME = 0x0010
-WSTAT_MTIME = 0x0020
-WSTAT_CTIME = 0x0040
-WFSSTAT_NAME = 0x0001
-FSDRIVER_API_VERSION = 1
-
-# Included from net/nettypes.h
-IP_ADR_LEN = 4
-INADDR_ANY = 0x00000000
-INADDR_BROADCAST = 0xffffffff
-INADDR_LOOPBACK = 0x7f000001
-def CMSG_ALIGN(len): return ( ((len)+sizeof(int)-1) & ~(sizeof(int)-1) )
-
-PROT_SOCK = 1024
-SHUTDOWN_MASK = 3
-RCV_SHUTDOWN = 1
-SEND_SHUTDOWN = 2
-SOCK_STREAM = 1
-SOCK_DGRAM = 2
-SOCK_RAW = 3
-SOCK_RDM = 4
-SOCK_SEQPACKET = 5
-SOCK_PACKET = 10
-PF_UNSPEC = 0
-PF_LOCAL = 1
-PF_UNIX = PF_LOCAL
-PF_FILE = PF_LOCAL
-PF_INET = 2
-PF_AX25 = 3
-PF_IPX = 4
-PF_APPLETALK = 5
-PF_NETROM = 6
-PF_BRIDGE = 7
-PF_ATMPVC = 8
-PF_X25 = 9
-PF_INET6 = 10
-PF_ROSE = 11
-PF_DECnet = 12
-PF_NETBEUI = 13
-PF_SECURITY = 14
-PF_KEY = 15
-PF_NETLINK = 16
-PF_ROUTE = PF_NETLINK
-PF_PACKET = 17
-PF_ASH = 18
-PF_ECONET = 19
-PF_ATMSVC = 20
-PF_SNA = 22
-PF_IRDA = 23
-PF_MAX = 32
-AF_UNSPEC = PF_UNSPEC
-AF_LOCAL = PF_LOCAL
-AF_UNIX = PF_UNIX
-AF_FILE = PF_FILE
-AF_INET = PF_INET
-AF_AX25 = PF_AX25
-AF_IPX = PF_IPX
-AF_APPLETALK = PF_APPLETALK
-AF_NETROM = PF_NETROM
-AF_BRIDGE = PF_BRIDGE
-AF_ATMPVC = PF_ATMPVC
-AF_X25 = PF_X25
-AF_INET6 = PF_INET6
-AF_ROSE = PF_ROSE
-AF_DECnet = PF_DECnet
-AF_NETBEUI = PF_NETBEUI
-AF_SECURITY = PF_SECURITY
-AF_KEY = PF_KEY
-AF_NETLINK = PF_NETLINK
-AF_ROUTE = PF_ROUTE
-AF_PACKET = PF_PACKET
-AF_ASH = PF_ASH
-AF_ECONET = PF_ECONET
-AF_ATMSVC = PF_ATMSVC
-AF_SNA = PF_SNA
-AF_IRDA = PF_IRDA
-AF_MAX = PF_MAX
-PF_UNIX = 1
-AF_UNIX = PF_UNIX
-PF_INET = 2
-AF_INET = PF_INET
-SOMAXCONN = 128
-MSG_OOB = 1
-MSG_PEEK = 2
-MSG_DONTROUTE = 4
-MSG_PROXY = 16
-SOL_SOCKET = 1
-SO_DEBUG = 1
-SO_REUSEADDR = 2
-SO_TYPE = 3
-SO_ERROR = 4
-SO_DONTROUTE = 5
-SO_BROADCAST = 6
-SO_SNDBUF = 7
-SO_RCVBUF = 8
-SO_KEEPALIVE = 9
-SO_OOBINLINE = 10
-SO_NO_CHECK = 11
-SO_PRIORITY = 12
-SO_LINGER = 13
-SO_BSDCOMPAT = 14
-SOL_IP = 0
-SOL_IPX = 256
-SOL_AX25 = 257
-SOL_ATALK = 258
-SOL_NETROM = 259
-SOL_TCP = 6
-SOL_UDP = 17
-IP_TOS = 1
-IPTOS_LOWDELAY = 0x10
-IPTOS_THROUGHPUT = 0x08
-IPTOS_RELIABILITY = 0x04
-IPTOS_MINCOST = 0x02
-IP_TTL = 2
-IP_HDRINCL = 3
-IP_OPTIONS = 4
-IP_MULTICAST_IF = 32
-IP_MULTICAST_TTL = 33
-IP_MULTICAST_LOOP = 34
-IP_ADD_MEMBERSHIP = 35
-IP_DROP_MEMBERSHIP = 36
-TCP_NODELAY = 0x01
-TCP_MAXSEG = 0x02
-def IN_CLASSA(a): return ((( (a)) & 0x80000000) == 0)
-
-IN_CLASSA_NET = 0xff000000
-IN_CLASSA_NSHIFT = 24
-IN_CLASSA_HOST = (0xffffffff & ~IN_CLASSA_NET)
-IN_CLASSA_MAX = 128
-def IN_CLASSB(a): return ((( (a)) & 0xc0000000) == 0x80000000)
-
-IN_CLASSB_NET = 0xffff0000
-IN_CLASSB_NSHIFT = 16
-IN_CLASSB_HOST = (0xffffffff & ~IN_CLASSB_NET)
-IN_CLASSB_MAX = 65536
-def IN_CLASSC(a): return ((( (a)) & 0xe0000000) == 0xc0000000)
-
-IN_CLASSC_NET = 0xffffff00
-IN_CLASSC_NSHIFT = 8
-IN_CLASSC_HOST = (0xffffffff & ~IN_CLASSC_NET)
-def IN_CLASSD(a): return ((( (a)) & 0xf0000000) == 0xe0000000)
-
-def IN_MULTICAST(a): return IN_CLASSD(a)
-
-def IN_EXPERIMENTAL(a): return ((( (a)) & 0xe0000000) == 0xe0000000)
-
-def IN_BADCLASS(a): return ((( (a)) & 0xf0000000) == 0xf0000000)
-
-INADDR_ANY = ( 0x00000000)
-INADDR_BROADCAST = ( 0xffffffff)
-INADDR_NONE = ( 0xffffffff)
-IN_LOOPBACKNET = 127
-INADDR_LOOPBACK = ( 0x7f000001)
-INADDR_UNSPEC_GROUP = ( 0xe0000000)
-INADDR_ALLHOSTS_GROUP = ( 0xe0000001)
-INADDR_ALLRTRS_GROUP = ( 0xe0000002)
-INADDR_MAX_LOCAL_GROUP = ( 0xe00000ff)
-INET_ADDRSTRLEN = 16
-INET6_ADDRSTRLEN = 46
-
-# Included from bits/in.h
-IP_TOS = 1
-IP_TTL = 2
-IP_HDRINCL = 3
-IP_OPTIONS = 4
-IP_ROUTER_ALERT = 5
-IP_RECVOPTS = 6
-IP_RETOPTS = 7
-IP_PKTINFO = 8
-IP_PKTOPTIONS = 9
-IP_PMTUDISC = 10
-IP_MTU_DISCOVER = 10
-IP_RECVERR = 11
-IP_RECVTTL = 12
-IP_RECVTOS = 13
-IP_MULTICAST_IF = 32
-IP_MULTICAST_TTL = 33
-IP_MULTICAST_LOOP = 34
-IP_ADD_MEMBERSHIP = 35
-IP_DROP_MEMBERSHIP = 36
-IP_RECVRETOPTS = IP_RETOPTS
-IP_PMTUDISC_DONT = 0
-IP_PMTUDISC_WANT = 1
-IP_PMTUDISC_DO = 2
-SOL_IP = 0
-SOL_SOCKET = 1
-IP_DEFAULT_MULTICAST_TTL = 1
-IP_DEFAULT_MULTICAST_LOOP = 1
-IP_MAX_MEMBERSHIPS = 20
-IPV6_ADDRFORM = 1
-IPV6_PKTINFO = 2
-IPV6_HOPOPTS = 3
-IPV6_DSTOPTS = 4
-IPV6_RXSRCRT = 5
-IPV6_PKTOPTIONS = 6
-IPV6_CHECKSUM = 7
-IPV6_HOPLIMIT = 8
-IPV6_NEXTHOP = 9
-IPV6_AUTHHDR = 10
-IPV6_UNICAST_HOPS = 16
-IPV6_MULTICAST_IF = 17
-IPV6_MULTICAST_HOPS = 18
-IPV6_MULTICAST_LOOP = 19
-IPV6_ADD_MEMBERSHIP = 20
-IPV6_DROP_MEMBERSHIP = 21
-IPV6_ROUTER_ALERT = 22
-SCM_SRCRT = IPV6_RXSRCRT
-IPV6_RXHOPOPTS = IPV6_HOPOPTS
-IPV6_RXDSTOPTS = IPV6_DSTOPTS
-IPV6_PMTUDISC_DONT = 0
-IPV6_PMTUDISC_WANT = 1
-IPV6_PMTUDISC_DO = 2
-SOL_IPV6 = 41
-SOL_ICMPV6 = 58
-
-# Included from bits/byteswap.h
-def __bswap_constant_16(x): return \
-
-def __bswap_16(x): return \
-
-def __bswap_16(x): return __bswap_constant_16 (x)
-
-def __bswap_constant_32(x): return \
-
-def __bswap_32(x): return \
-
-def __bswap_32(x): return \
-
-def __bswap_32(x): return __bswap_constant_32 (x)
-
-def __bswap_64(x): return \
-
-def ntohl(x): return (x)
-
-def ntohs(x): return (x)
-
-def htonl(x): return (x)
-
-def htons(x): return (x)
-
-def ntohl(x): return __bswap_32 (x)
-
-def ntohs(x): return __bswap_16 (x)
-
-def htonl(x): return __bswap_32 (x)
-
-def htons(x): return __bswap_16 (x)
-
-def IN6_IS_ADDR_UNSPECIFIED(a): return \
-
-def IN6_IS_ADDR_LOOPBACK(a): return \
-
-def IN6_IS_ADDR_LINKLOCAL(a): return \
-
-def IN6_IS_ADDR_SITELOCAL(a): return \
-
-def IN6_IS_ADDR_V4MAPPED(a): return \
-
-def IN6_IS_ADDR_V4COMPAT(a): return \
-
-def IN6_IS_ADDR_MC_NODELOCAL(a): return \
-
-def IN6_IS_ADDR_MC_LINKLOCAL(a): return \
-
-def IN6_IS_ADDR_MC_SITELOCAL(a): return \
-
-def IN6_IS_ADDR_MC_ORGLOCAL(a): return \
-
-def IN6_IS_ADDR_MC_GLOBAL(a): return
diff --git a/Lib/plat-atheos/TYPES.py b/Lib/plat-atheos/TYPES.py
deleted file mode 100644
index 9d0be35d29..0000000000
--- a/Lib/plat-atheos/TYPES.py
+++ /dev/null
@@ -1,142 +0,0 @@
-# Generated by h2py from /include/sys/types.h
-_SYS_TYPES_H = 1
-
-# Included from features.h
-_FEATURES_H = 1
-__USE_ANSI = 1
-__FAVOR_BSD = 1
-_ISOC9X_SOURCE = 1
-_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 199506
-_XOPEN_SOURCE = 500
-_XOPEN_SOURCE_EXTENDED = 1
-_LARGEFILE64_SOURCE = 1
-_BSD_SOURCE = 1
-_SVID_SOURCE = 1
-_BSD_SOURCE = 1
-_SVID_SOURCE = 1
-__USE_ISOC9X = 1
-_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 2
-_POSIX_C_SOURCE = 199506
-__USE_POSIX = 1
-__USE_POSIX2 = 1
-__USE_POSIX199309 = 1
-__USE_POSIX199506 = 1
-__USE_XOPEN = 1
-__USE_XOPEN_EXTENDED = 1
-__USE_UNIX98 = 1
-_LARGEFILE_SOURCE = 1
-__USE_XOPEN_EXTENDED = 1
-__USE_LARGEFILE = 1
-__USE_LARGEFILE64 = 1
-__USE_FILE_OFFSET64 = 1
-__USE_MISC = 1
-__USE_BSD = 1
-__USE_SVID = 1
-__USE_GNU = 1
-__USE_REENTRANT = 1
-__STDC_IEC_559__ = 1
-__STDC_IEC_559_COMPLEX__ = 1
-__GNU_LIBRARY__ = 6
-__GLIBC__ = 2
-__GLIBC_MINOR__ = 1
-
-# Included from sys/cdefs.h
-_SYS_CDEFS_H = 1
-def __PMT(args): return args
-
-def __P(args): return args
-
-def __PMT(args): return args
-
-def __P(args): return ()
-
-def __PMT(args): return ()
-
-def __STRING(x): return #x
-
-def __STRING(x): return "x"
-
-def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
-
-def __attribute__(xyz): return
-
-__USE_EXTERN_INLINES = 1
-
-# Included from gnu/stubs.h
-
-# Included from bits/types.h
-_BITS_TYPES_H = 1
-__FD_SETSIZE = 1024
-def __FDELT(d): return ((d) / __NFDBITS)
-
-
-# Included from bits/pthreadtypes.h
-
-# Included from time.h
-_TIME_H = 1
-
-# Included from bits/time.h
-
-# Included from posix/time.h
-
-# Included from posix/types.h
-MAXHOSTNAMELEN = 64
-FD_SETSIZE = 1024
-CLOCKS_PER_SEC = 1000000
-_BITS_TIME_H = 1
-CLOCKS_PER_SEC = 1000000
-CLK_TCK = 100
-_STRUCT_TIMEVAL = 1
-CLK_TCK = CLOCKS_PER_SEC
-__clock_t_defined = 1
-__time_t_defined = 1
-__timespec_defined = 1
-def __isleap(year): return \
-
-__BIT_TYPES_DEFINED__ = 1
-
-# Included from endian.h
-_ENDIAN_H = 1
-__LITTLE_ENDIAN = 1234
-__BIG_ENDIAN = 4321
-__PDP_ENDIAN = 3412
-
-# Included from bits/endian.h
-__BYTE_ORDER = __LITTLE_ENDIAN
-__FLOAT_WORD_ORDER = __BYTE_ORDER
-LITTLE_ENDIAN = __LITTLE_ENDIAN
-BIG_ENDIAN = __BIG_ENDIAN
-PDP_ENDIAN = __PDP_ENDIAN
-BYTE_ORDER = __BYTE_ORDER
-
-# Included from sys/select.h
-_SYS_SELECT_H = 1
-
-# Included from bits/select.h
-def __FD_ZERO(fdsp): return \
-
-def __FD_ZERO(set): return \
-
-
-# Included from bits/sigset.h
-_SIGSET_H_types = 1
-_SIGSET_H_fns = 1
-def __sigmask(sig): return \
-
-def __sigemptyset(set): return \
-
-def __sigfillset(set): return \
-
-def __sigisemptyset(set): return \
-
-FD_SETSIZE = __FD_SETSIZE
-def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp)
-
-
-# Included from sys/sysmacros.h
-_SYS_SYSMACROS_H = 1
-def major(dev): return ( (( (dev) >> 8) & 0xff))
-
-def minor(dev): return ( ((dev) & 0xff))
diff --git a/Lib/plat-atheos/regen b/Lib/plat-atheos/regen
deleted file mode 100644
index 7c002c3674..0000000000
--- a/Lib/plat-atheos/regen
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-set -v
-python$EXE ../../Tools/scripts/h2py.py -i '\(u_long\)' -i '\(uint32_t\)' -i '\(int\)' -i '\(unsigned int\)' /include/netinet/in.h /include/sys/types.h
diff --git a/Lib/platform.py b/Lib/platform.py
index 2294604ea4..b01568ca61 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
""" This module tries to retrieve as much platform-identifying data as
possible. It makes this information available via function APIs.
@@ -32,6 +32,7 @@
#
# <see CVS and SVN checkin messages for history>
#
+# 1.0.7 - added DEV_NULL
# 1.0.6 - added linux_distribution()
# 1.0.5 - fixed Java support to allow running the module on Jython
# 1.0.4 - added IronPython support
@@ -108,10 +109,25 @@ __copyright__ = """
"""
-__version__ = '1.0.6'
+__version__ = '1.0.7'
import sys, os, re
+### Globals & Constants
+
+# Determine the platform's /dev/null device
+try:
+ DEV_NULL = os.devnull
+except AttributeError:
+ # os.devnull was added in Python 2.4, so emulate it for earlier
+ # Python versions
+ if sys.platform in ('dos','win32','win16','os2'):
+ # Use the old CP/M NUL as device name
+ DEV_NULL = 'NUL'
+ else:
+ # Standard Unix uses /dev/null
+ DEV_NULL = '/dev/null'
+
### Platform specific APIs
_libc_search = re.compile(r'(__libc_init)'
@@ -184,9 +200,8 @@ def _dist_try_harder(distname,version,id):
"""
if os.path.exists('/var/adm/inst-log/info'):
# SuSE Linux stores distribution information in that file
- info = open('/var/adm/inst-log/info').readlines()
distname = 'SuSE'
- for line in info:
+ for line in open('/var/adm/inst-log/info'):
tv = line.split()
if len(tv) == 2:
tag,value = tv
@@ -201,8 +216,7 @@ def _dist_try_harder(distname,version,id):
if os.path.exists('/etc/.installed'):
# Caldera OpenLinux has some infos in that file (thanks to Colin Kong)
- info = open('/etc/.installed').readlines()
- for line in info:
+ for line in open('/etc/.installed'):
pkg = line.split('-')
if len(pkg) >= 2 and pkg[0] == 'OpenLinux':
# XXX does Caldera support non Intel platforms ? If yes,
@@ -311,9 +325,8 @@ def linux_distribution(distname='', version='', id='',
return _dist_try_harder(distname,version,id)
# Read the first line
- f = open('/etc/'+file, 'r')
- firstline = f.readline()
- f.close()
+ with open('/etc/'+file, 'r') as f:
+ firstline = f.readline()
_distname, _version, _id = _parse_release_file(firstline)
if _distname and full_distribution_name:
@@ -450,7 +463,16 @@ def _norm_version(version, build=''):
_ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) '
'.*'
- 'Version ([\d.]+))', re.ASCII)
+ '\[.* ([\d.]+)\])')
+
+# Examples of VER command output:
+#
+# Windows 2000: Microsoft Windows 2000 [Version 5.00.2195]
+# Windows XP: Microsoft Windows XP [Version 5.1.2600]
+# Windows Vista: Microsoft Windows [Version 6.0.6002]
+#
+# Note that the "Version" string gets localized on different
+# Windows versions.
def _syscmd_ver(system='', release='', version='',
@@ -589,6 +611,7 @@ def win32_ver(release='',version='',csd='',ptype=''):
else:
if csd[:13] == 'Service Pack ':
csd = 'SP' + csd[13:]
+
if plat == VER_PLATFORM_WIN32_WINDOWS:
regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion'
# Try to guess the release name
@@ -603,6 +626,7 @@ def win32_ver(release='',version='',csd='',ptype=''):
release = 'postMe'
elif maj == 5:
release = '2000'
+
elif plat == VER_PLATFORM_WIN32_NT:
regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion'
if maj <= 4:
@@ -646,6 +670,7 @@ def win32_ver(release='',version='',csd='',ptype=''):
release = '2008ServerR2'
else:
release = 'post2008Server'
+
else:
if not release:
# E.g. Win3.1 with win32s
@@ -947,7 +972,7 @@ def _syscmd_uname(option,default=''):
# XXX Others too ?
return default
try:
- f = os.popen('uname %s 2> /dev/null' % option)
+ f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
except (AttributeError,os.error):
return default
output = f.read().strip()
@@ -962,17 +987,16 @@ def _syscmd_file(target,default=''):
""" Interface to the system's file command.
The function uses the -b option of the file command to have it
- ommit the filename in its output and if possible the -L option
- to have the command follow symlinks. It returns default in
- case the command should fail.
+ omit the filename in its output. Follow the symlinks. It returns
+ default in case the command should fail.
"""
if sys.platform in ('dos','win32','win16','os2'):
# XXX Others too ?
return default
- target = _follow_symlinks(target)
+ target = _follow_symlinks(target).replace('"', '\\"')
try:
- f = os.popen('file "%s" 2> /dev/null' % target)
+ f = os.popen('file -b "%s" 2> %s' % (target, DEV_NULL))
except (AttributeError,os.error):
return default
output = f.read().strip()
@@ -992,8 +1016,6 @@ _default_architecture = {
'dos': ('','MSDOS'),
}
-_architecture_split = re.compile(r'[\s,]').split
-
def architecture(executable=sys.executable,bits='',linkage=''):
""" Queries the given executable (defaults to the Python interpreter
@@ -1028,11 +1050,11 @@ def architecture(executable=sys.executable,bits='',linkage=''):
# Get data from the 'file' system command
if executable:
- output = _syscmd_file(executable, '')
+ fileout = _syscmd_file(executable, '')
else:
- output = ''
+ fileout = ''
- if not output and \
+ if not fileout and \
executable == sys.executable:
# "file" command did not return anything; we'll try to provide
# some sensible defaults then...
@@ -1044,9 +1066,6 @@ def architecture(executable=sys.executable,bits='',linkage=''):
linkage = l
return bits,linkage
- # Split the output into a list of strings omitting the filename
- fileout = _architecture_split(output)[1:]
-
if 'executable' not in fileout:
# Format not supported
return bits,linkage
@@ -1131,7 +1150,11 @@ def uname():
# http://support.microsoft.com/kb/888731 and
# http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
if not machine:
- machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
+ # WOW64 processes mask the native architecture
+ if "PROCESSOR_ARCHITEW6432" in os.environ:
+ machine = os.environ.get("PROCESSOR_ARCHITEW6432", '')
+ else:
+ machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
if not processor:
processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
@@ -1171,10 +1194,6 @@ def uname():
if not version:
version = vendor
- elif os.name == 'mac':
- release,(version,stage,nonrel),machine = mac_ver()
- system = 'MacOS'
-
# System specific extensions
if system == 'OpenVMS':
# OpenVMS seems to have release and version mixed up
diff --git a/Lib/plistlib.py b/Lib/plistlib.py
index fbba791ce5..82d456aec0 100644
--- a/Lib/plistlib.py
+++ b/Lib/plistlib.py
@@ -186,7 +186,7 @@ def _escape(text):
PLISTHEADER = b"""\
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
"""
class PlistWriter(DumbXMLWriter):
diff --git a/Lib/poplib.py b/Lib/poplib.py
index 1a529d0a13..84ea88de46 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -331,16 +331,26 @@ else:
See the methods of the parent class POP3 for more documentation.
"""
- def __init__(self, host, port=POP3_SSL_PORT,
- keyfile=None, certfile=None,
- timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
+ def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None,
+ timeout=socket._GLOBAL_DEFAULT_TIMEOUT, context=None):
+ if context is not None and keyfile is not None:
+ raise ValueError("context and keyfile arguments are mutually "
+ "exclusive")
+ if context is not None and certfile is not None:
+ raise ValueError("context and certfile arguments are mutually "
+ "exclusive")
self.keyfile = keyfile
self.certfile = certfile
+ self.context = context
POP3.__init__(self, host, port, timeout)
def _create_socket(self, timeout):
sock = POP3._create_socket(self, timeout)
- return ssl.wrap_socket(sock, self.keyfile, self.certfile)
+ if self.context is not None:
+ sock = self.context.wrap_socket(sock)
+ else:
+ sock = ssl.wrap_socket(sock, self.keyfile, self.certfile)
+ return sock
__all__.append("POP3_SSL")
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 64fe9dfc5d..c9829e18d0 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -49,6 +49,9 @@ def _get_sep(path):
def normcase(s):
"""Normalize case of pathname. Has no effect under Posix"""
# TODO: on Mac OS X, this should really return s.lower().
+ if not isinstance(s, (bytes, str)):
+ raise TypeError("normcase() argument must be str or bytes, "
+ "not '{}'".format(s.__class__.__name__))
return s
@@ -158,7 +161,7 @@ def islink(path):
def lexists(path):
"""Test whether a path exists. Returns True for broken symbolic links"""
try:
- st = os.lstat(path)
+ os.lstat(path)
except os.error:
return False
return True
@@ -259,7 +262,7 @@ def expanduser(path):
return path
userhome = pwent.pw_dir
if isinstance(path, bytes):
- userhome = userhome.encode(sys.getfilesystemencoding())
+ userhome = os.fsencode(userhome)
root = b'/'
else:
root = '/'
@@ -424,7 +427,7 @@ def _resolve_link(path):
path = normpath(resolved)
return path
-supports_unicode_filenames = False
+supports_unicode_filenames = (sys.platform == 'darwin')
def relpath(path, start=None):
"""Return a relative version of a path"""
diff --git a/Lib/pprint.py b/Lib/pprint.py
index b3a644649e..b8417f5922 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -35,7 +35,7 @@ saferepr()
"""
import sys as _sys
-
+from collections import OrderedDict as _OrderedDict
from io import StringIO as _StringIO
__all__ = ["pprint","pformat","isreadable","isrecursive","saferepr",
@@ -163,7 +163,7 @@ class PrettyPrinter:
if sepLines:
r = getattr(typ, "__repr__", None)
- if issubclass(typ, dict) and r is dict.__repr__:
+ if issubclass(typ, dict):
write('{')
if self._indent_per_level > 1:
write((self._indent_per_level - 1) * ' ')
@@ -171,7 +171,10 @@ class PrettyPrinter:
if length:
context[objid] = 1
indent = indent + self._indent_per_level
- items = sorted(object.items(), key=_safe_tuple)
+ if issubclass(typ, _OrderedDict):
+ items = list(object.items())
+ else:
+ items = sorted(object.items(), key=_safe_tuple)
key, ent = items[0]
rep = self._repr(key, context, level)
write(rep)
diff --git a/Lib/profile.py b/Lib/profile.py
index 3b239d14bf..d6511b7124 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
#
# Class for profiling python code. rev 1.0 6/2/94
#
@@ -39,7 +39,7 @@ import time
import marshal
from optparse import OptionParser
-__all__ = ["run", "runctx", "help", "Profile"]
+__all__ = ["run", "runctx", "Profile"]
# Sample timer for use with
#i_count = 0
@@ -92,16 +92,6 @@ def runctx(statement, globals, locals, filename=None, sort=-1):
else:
return prof.print_stats(sort)
-# Backwards compatibility.
-def help():
- print("Documentation for the profile module can be found ")
- print("in the Python Library Reference, section 'The Python Profiler'.")
-
-if os.name == "mac":
- import MacOS
- def _get_time_mac(timer=MacOS.GetTicks):
- return timer() / 60.0
-
if hasattr(os, "times"):
def _get_time_times(timer=os.times):
t = timer()
@@ -178,10 +168,6 @@ class Profile:
self.timer = resgetrusage
self.dispatcher = self.trace_dispatch
self.get_time = _get_time_resource
- elif os.name == 'mac':
- self.timer = MacOS.GetTicks
- self.dispatcher = self.trace_dispatch_mac
- self.get_time = _get_time_mac
elif hasattr(time, 'clock'):
self.timer = self.get_time = time.clock
self.dispatcher = self.trace_dispatch_i
@@ -588,8 +574,6 @@ class Profile:
return mean
#****************************************************************************
-def Stats(*args):
- print('Report generating functions are in the "pstats" module\a')
def main():
usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
diff --git a/Lib/pstats.py b/Lib/pstats.py
index 566272dcae..f5c592b81b 100644
--- a/Lib/pstats.py
+++ b/Lib/pstats.py
@@ -37,6 +37,7 @@ import os
import time
import marshal
import re
+from functools import cmp_to_key
__all__ = ["Stats"]
@@ -70,20 +71,8 @@ class Stats:
print_stats(5).print_callers(5)
"""
- def __init__(self, *args, **kwds):
- # I can't figure out how to explicitly specify a stream keyword arg
- # with *args:
- # def __init__(self, *args, stream=sys.stdout): ...
- # so I use **kwds and sqauwk if something unexpected is passed in.
- self.stream = sys.stdout
- if "stream" in kwds:
- self.stream = kwds["stream"]
- del kwds["stream"]
- if kwds:
- keys = kwds.keys()
- keys.sort()
- extras = ", ".join(["%s=%s" % (k, kwds[k]) for k in keys])
- raise ValueError("unrecognized keyword args: %s" % extras)
+ def __init__(self, *args, stream=None):
+ self.stream = stream or sys.stdout
if not len(args):
arg = None
else:
@@ -100,22 +89,21 @@ class Stats:
self.total_calls = 0
self.prim_calls = 0
self.max_name_len = 0
- self.top_level = {}
+ self.top_level = set()
self.stats = {}
self.sort_arg_dict = {}
self.load_stats(arg)
- trouble = 1
try:
self.get_top_level_stats()
- trouble = 0
- finally:
- if trouble:
- print("Invalid timing data", end=' ', file=self.stream)
- if self.files: print(self.files[-1], end=' ', file=self.stream)
- print(file=self.stream)
+ except Exception:
+ print("Invalid timing data %s" %
+ (self.files[-1] if self.files else ''), file=self.stream)
+ raise
def load_stats(self, arg):
- if not arg: self.stats = {}
+ if arg is None:
+ self.stats = {}
+ return
elif isinstance(arg, str):
f = open(arg, 'rb')
self.stats = marshal.load(f)
@@ -125,13 +113,13 @@ class Stats:
arg = time.ctime(file_stats.st_mtime) + " " + arg
except: # in case this is not unix
pass
- self.files = [ arg ]
+ self.files = [arg]
elif hasattr(arg, 'create_stats'):
arg.create_stats()
self.stats = arg.stats
arg.stats = {}
if not self.stats:
- raise TypeError("Cannot create or construct a %r object from '%r''"
+ raise TypeError("Cannot create or construct a %r object from %r"
% (self.__class__, arg))
return
@@ -141,34 +129,34 @@ class Stats:
self.prim_calls += cc
self.total_tt += tt
if ("jprofile", 0, "profiler") in callers:
- self.top_level[func] = None
+ self.top_level.add(func)
if len(func_std_string(func)) > self.max_name_len:
self.max_name_len = len(func_std_string(func))
def add(self, *arg_list):
- if not arg_list: return self
- if len(arg_list) > 1: self.add(*arg_list[1:])
- other = arg_list[0]
- if type(self) != type(other):
- other = Stats(other)
- self.files += other.files
- self.total_calls += other.total_calls
- self.prim_calls += other.prim_calls
- self.total_tt += other.total_tt
- for func in other.top_level:
- self.top_level[func] = None
-
- if self.max_name_len < other.max_name_len:
- self.max_name_len = other.max_name_len
-
- self.fcn_list = None
-
- for func, stat in other.stats.items():
- if func in self.stats:
- old_func_stat = self.stats[func]
- else:
- old_func_stat = (0, 0, 0, 0, {},)
- self.stats[func] = add_func_stats(old_func_stat, stat)
+ if not arg_list:
+ return self
+ for item in reversed(arg_list):
+ if type(self) != type(item):
+ item = Stats(item)
+ self.files += item.files
+ self.total_calls += item.total_calls
+ self.prim_calls += item.prim_calls
+ self.total_tt += item.total_tt
+ for func in item.top_level:
+ self.top_level.add(func)
+
+ if self.max_name_len < item.max_name_len:
+ self.max_name_len = item.max_name_len
+
+ self.fcn_list = None
+
+ for func, stat in item.stats.items():
+ if func in self.stats:
+ old_func_stat = self.stats[func]
+ else:
+ old_func_stat = (0, 0, 0, 0, {},)
+ self.stats[func] = add_func_stats(old_func_stat, stat)
return self
def dump_stats(self, filename):
@@ -238,7 +226,7 @@ class Stats:
stats_list.append((cc, nc, tt, ct) + func +
(func_std_string(func), func))
- stats_list.sort(key=CmpToKey(TupleComp(sort_tuple).compare))
+ stats_list.sort(key=cmp_to_key(TupleComp(sort_tuple).compare))
self.fcn_list = fcn_list = []
for tuple in stats_list:
@@ -269,9 +257,9 @@ class Stats:
else:
newstats[newfunc] = (cc, nc, tt, ct, newcallers)
old_top = self.top_level
- self.top_level = new_top = {}
+ self.top_level = new_top = set()
for func in old_top:
- new_top[func_strip_path(func)] = None
+ new_top.add(func_strip_path(func))
self.max_name_len = max_name_len
@@ -280,7 +268,8 @@ class Stats:
return self
def calc_callees(self):
- if self.all_callees: return
+ if self.all_callees:
+ return
self.all_callees = all_callees = {}
for func, (cc, nc, tt, ct, callers) in self.stats.items():
if not func in all_callees:
@@ -350,7 +339,8 @@ class Stats:
def print_stats(self, *amount):
for filename in self.files:
print(filename, file=self.stream)
- if self.files: print(file=self.stream)
+ if self.files:
+ print(file=self.stream)
indent = ' ' * 8
for func in self.top_level:
print(indent, func_get_function_name(func), file=self.stream)
@@ -436,7 +426,7 @@ class Stats:
print(' ncalls tottime percall cumtime percall', end=' ', file=self.stream)
print('filename:lineno(function)', file=self.stream)
- def print_line(self, func): # hack : should print percentages
+ def print_line(self, func): # hack: should print percentages
cc, nc, tt, ct, callers = self.stats[func]
c = str(nc)
if nc != cc:
@@ -475,15 +465,6 @@ class TupleComp:
return direction
return 0
-def CmpToKey(mycmp):
- 'Convert a cmp= function into a key= function'
- class K(object):
- def __init__(self, obj):
- self.obj = obj
- def __lt__(self, other):
- return mycmp(self.obj, other.obj) == -1
- return K
-
#**************************************************************************
# func_name is a triple (file:string, line:int, name:string)
@@ -670,7 +651,7 @@ if __name__ == '__main__':
print("No statistics object is loaded.", file=self.stream)
return
abbrevs = self.stats.get_sort_arg_defs()
- if line and not filter(lambda x,a=abbrevs: x not in a,line.split()):
+ if line and all((x in abbrevs) for x in line.split()):
self.stats.sort_stats(*line.split())
else:
print("Valid sort keys (unique prefixes are accepted):", file=self.stream)
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index cce5ac145a..e0f98cb741 100644
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -4,11 +4,12 @@ This module has intimate knowledge of the format of .pyc files.
"""
import builtins
+import errno
import imp
import marshal
import os
-import re
import sys
+import tokenize
import traceback
MAGIC = imp.get_magic()
@@ -37,16 +38,18 @@ class PyCompileError(Exception):
can be accesses as class variable 'file'
msg: string message to be written as error message
- If no value is given, a default exception message will be given,
- consistent with 'standard' py_compile output.
- message (or default) can be accesses as class variable 'msg'
+ If no value is given, a default exception message will be
+ given, consistent with 'standard' py_compile output.
+ message (or default) can be accesses as class variable
+ 'msg'
"""
def __init__(self, exc_type, exc_value, file, msg=''):
exc_type_name = exc_type.__name__
if exc_type is SyntaxError:
- tbtext = ''.join(traceback.format_exception_only(exc_type, exc_value))
+ tbtext = ''.join(traceback.format_exception_only(
+ exc_type, exc_value))
errmsg = tbtext.replace('File "<string>"', 'File "%s"' % file)
else:
errmsg = "Sorry: %s: %s" % (exc_type_name,exc_value)
@@ -62,54 +65,32 @@ class PyCompileError(Exception):
return self.msg
-# Define an internal helper according to the platform
-if os.name == "mac":
- import MacOS
- def set_creator_type(file):
- MacOS.SetCreatorAndType(file, 'Pyth', 'PYC ')
-else:
- def set_creator_type(file):
- pass
-
def wr_long(f, x):
"""Internal; write a 32-bit int to a file in little-endian order."""
- f.write(bytes([x & 0xff,
+ f.write(bytes([x & 0xff,
(x >> 8) & 0xff,
(x >> 16) & 0xff,
(x >> 24) & 0xff]))
-def read_encoding(file, default):
- """Read the first two lines of the file looking for coding: xyzzy."""
- f = open(file, "rb")
- try:
- for i in range(2):
- line = f.readline()
- if not line:
- break
- m = re.match(br".*\bcoding:\s*(\S+)\b", line)
- if m:
- return m.group(1).decode("ascii")
- return default
- finally:
- f.close()
-
-def compile(file, cfile=None, dfile=None, doraise=False):
+def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1):
"""Byte-compile one Python source file to Python bytecode.
- Arguments:
-
- file: source filename
- cfile: target filename; defaults to source with 'c' or 'o' appended
- ('c' normally, 'o' in optimizing mode, giving .pyc or .pyo)
- dfile: purported filename; defaults to source (this is the filename
- that will show up in error messages)
- doraise: flag indicating whether or not an exception should be
- raised when a compile error is found. If an exception
- occurs and this flag is set to False, a string
- indicating the nature of the exception will be printed,
- and the function will return to the caller. If an
- exception occurs and this flag is set to True, a
- PyCompileError exception will be raised.
+ :param file: The source file name.
+ :param cfile: The target byte compiled file name. When not given, this
+ defaults to the PEP 3147 location.
+ :param dfile: Purported file name, i.e. the file name that shows up in
+ error messages. Defaults to the source file name.
+ :param doraise: Flag indicating whether or not an exception should be
+ raised when a compile error is found. If an exception occurs and this
+ flag is set to False, a string indicating the nature of the exception
+ will be printed, and the function will return to the caller. If an
+ exception occurs and this flag is set to True, a PyCompileError
+ exception will be raised.
+ :param optimize: The optimization level for the compiler. Valid values
+ are -1, 0, 1 and 2. A value of -1 means to use the optimization
+ level of the current interpreter, as given by -O command line options.
+
+ :return: Path to the resulting byte compiled file.
Note that it isn't necessary to byte-compile Python modules for
execution efficiency -- Python itself byte-compiles a module when
@@ -126,20 +107,16 @@ def compile(file, cfile=None, dfile=None, doraise=False):
See compileall.py for a script/module that uses this module to
byte-compile all installed files (or all files in selected
directories).
-
"""
- encoding = read_encoding(file, "utf-8")
- f = open(file, 'U', encoding=encoding)
- try:
- timestamp = int(os.fstat(f.fileno()).st_mtime)
- except AttributeError:
- timestamp = int(os.stat(file).st_mtime)
- codestring = f.read()
- f.close()
- if codestring and codestring[-1] != '\n':
- codestring = codestring + '\n'
+ with tokenize.open(file) as f:
+ try:
+ timestamp = int(os.fstat(f.fileno()).st_mtime)
+ except AttributeError:
+ timestamp = int(os.stat(file).st_mtime)
+ codestring = f.read()
try:
- codeobject = builtins.compile(codestring, dfile or file,'exec')
+ codeobject = builtins.compile(codestring, dfile or file, 'exec',
+ optimize=optimize)
except Exception as err:
py_exc = PyCompileError(err.__class__, err, dfile or file)
if doraise:
@@ -148,16 +125,23 @@ def compile(file, cfile=None, dfile=None, doraise=False):
sys.stderr.write(py_exc.msg + '\n')
return
if cfile is None:
- cfile = file + (__debug__ and 'c' or 'o')
- fc = open(cfile, 'wb')
- fc.write(b'\0\0\0\0')
- wr_long(fc, timestamp)
- marshal.dump(codeobject, fc)
- fc.flush()
- fc.seek(0, 0)
- fc.write(MAGIC)
- fc.close()
- set_creator_type(cfile)
+ if optimize >= 0:
+ cfile = imp.cache_from_source(file, debug_override=not optimize)
+ else:
+ cfile = imp.cache_from_source(file)
+ try:
+ os.makedirs(os.path.dirname(cfile))
+ except OSError as error:
+ if error.errno != errno.EEXIST:
+ raise
+ with open(cfile, 'wb') as fc:
+ fc.write(b'\0\0\0\0')
+ wr_long(fc, timestamp)
+ marshal.dump(codeobject, fc)
+ fc.flush()
+ fc.seek(0, 0)
+ fc.write(MAGIC)
+ return cfile
def main(args=None):
"""Compile several source files.
@@ -166,19 +150,35 @@ def main(args=None):
not specified) are compiled and the resulting bytecode is cached
in the normal manner. This function does not search a directory
structure to locate source files; it only compiles files named
- explicitly.
+ explicitly. If '-' is the only parameter in args, the list of
+ files is taken from standard input.
"""
if args is None:
args = sys.argv[1:]
rv = 0
- for filename in args:
- try:
- compile(filename, doraise=True)
- except PyCompileError as err:
- # return value to indicate at least one failure
- rv = 1
- sys.stderr.write(err.msg)
+ if args == ['-']:
+ while True:
+ filename = sys.stdin.readline()
+ if not filename:
+ break
+ filename = filename.rstrip('\n')
+ try:
+ compile(filename, doraise=True)
+ except PyCompileError as error:
+ rv = 1
+ sys.stderr.write("%s\n" % error.msg)
+ except IOError as error:
+ rv = 1
+ sys.stderr.write("%s\n" % error)
+ else:
+ for filename in args:
+ try:
+ compile(filename, doraise=True)
+ except PyCompileError as error:
+ # return value to indicate at least one failure
+ rv = 1
+ sys.stderr.write(error.msg)
return rv
if __name__ == "__main__":
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 36c6a97f5f..9d3cdd5c9b 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1,5 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: latin-1 -*-
+#!/usr/bin/env python3
"""Generate Python documentation in HTML or text for interactive use.
In the Python interpreter, do "from pydoc import help" to provide online
@@ -16,11 +15,17 @@ backslash on Windows) it is treated as the path to a Python source file.
Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines
of all available modules.
-Run "pydoc -p <port>" to start an HTTP server on a given port on the
-local machine to generate documentation web pages.
+Run "pydoc -p <port>" to start an HTTP server on the given port on the
+local machine. Port number 0 can be used to get an arbitrary unused port.
+
+Run "pydoc -b" to start an HTTP server on an arbitrary unused port and
+open a Web browser to interactively browse documentation. The -p option
+can be used with the -b option to explicitly specify the server port.
For platforms without a command line, "pydoc -g" starts the HTTP server
-and also pops up a little window for controlling it.
+and also pops up a little window for controlling it. This option is
+deprecated, since the server can now be controlled directly from HTTP
+clients.
Run "pydoc -w <name>" to write out the HTML documentation for a module
to a file named "<name>.html".
@@ -52,10 +57,22 @@ Richard Chamberlain, for the first implementation of textdoc.
# the current directory is changed with os.chdir(), an incorrect
# path will be displayed.
-import sys, imp, os, re, inspect, builtins, pkgutil
-from reprlib import Repr
-from traceback import extract_tb as _extract_tb
+import os
+import sys
+import builtins
+import imp
+import io
+import inspect
+import pkgutil
+import platform
+import re
+import time
+import warnings
from collections import deque
+from reprlib import Repr
+from traceback import extract_tb, format_exception_only
+
+
# --------------------------------------------------------- common routines
def pathdirs():
@@ -153,7 +170,8 @@ def visiblename(name, all=None):
# Certain special names are redundant.
_hidden_names = ('__builtins__', '__doc__', '__file__', '__path__',
'__module__', '__name__', '__slots__', '__package__',
- '__author__', '__credits__', '__date__', '__version__')
+ '__cached__', '__author__', '__credits__', '__date__',
+ '__version__')
if name in _hidden_names: return 0
# Private names are hidden, but special names are displayed.
if name.startswith('__') and name.endswith('__'): return 1
@@ -285,7 +303,7 @@ def safeimport(path, forceload=0, cache={}):
elif exc is SyntaxError:
# A SyntaxError occurred before we could execute the module.
raise ErrorDuringImport(value.filename, info)
- elif exc is ImportError and _extract_tb(tb)[-1][2]=='safeimport':
+ elif exc is ImportError and extract_tb(tb)[-1][2]=='safeimport':
# The import error occurred directly in this function,
# which means there is no such module in the path.
return None
@@ -513,6 +531,10 @@ class HTMLDoc(Doc):
text = name
return '<a href="%s">%s</a>' % (url, text)
+ def filelink(self, url, path):
+ """Make a link to source file."""
+ return '<a href="file:%s">%s</a>' % (url, path)
+
def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
"""Mark up some plain text, given a context of symbols to look for.
Each context dictionary maps object names to anchor names."""
@@ -591,7 +613,7 @@ class HTMLDoc(Doc):
if sys.platform == 'win32':
import nturl2path
url = nturl2path.pathname2url(path)
- filelink = '<a href="file:%s">%s</a>' % (url, path)
+ filelink = self.filelink(url, path)
except TypeError:
filelink = '(built-in)'
info = []
@@ -978,7 +1000,7 @@ class TextDoc(Doc):
def bold(self, text):
"""Format a string in bold by overstriking."""
- return ''.join(map(lambda ch: ch + '\b' + ch, text))
+ return ''.join(ch + '\b' + ch for ch in text)
def indent(self, text, prefix=' '):
"""Indent text by prepending a given prefix to each line."""
@@ -1002,7 +1024,7 @@ class TextDoc(Doc):
c, bases = entry
result = result + prefix + classname(c, modname)
if bases and bases != (parent,):
- parents = map(lambda c, m=modname: classname(c, m), bases)
+ parents = (classname(c, modname) for c in bases)
result = result + '(%s)' % ', '.join(parents)
result = result + '\n'
elif type(entry) is type([]):
@@ -1310,6 +1332,11 @@ doubt, consult the module reference at the location listed above.
line += '\n' + self.indent(str(doc))
return line
+class _PlainTextDoc(TextDoc):
+ """Subclass of TextDoc which overrides string styling"""
+ def bold(self, text):
+ return text
+
# --------------------------------------------------------- user interfaces
def pager(text):
@@ -1464,6 +1491,7 @@ def locate(path, forceload=0):
# --------------------------------------- interactive interpreter interface
text = TextDoc()
+plaintext = _PlainTextDoc()
html = HTMLDoc()
def resolve(thing, forceload=0):
@@ -1476,8 +1504,11 @@ def resolve(thing, forceload=0):
else:
return thing, getattr(thing, '__name__', None)
-def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
+def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
+ renderer=None):
"""Render text documentation, given an object or a path to an object."""
+ if renderer is None:
+ renderer = text
object, name = resolve(thing, forceload)
desc = describe(object)
module = inspect.getmodule(object)
@@ -1496,12 +1527,16 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
# document its available methods instead of its value.
object = type(object)
desc += ' object'
- return title % desc + '\n\n' + text.document(object, name)
+ return title % desc + '\n\n' + renderer.document(object, name)
-def doc(thing, title='Python Library Documentation: %s', forceload=0):
+def doc(thing, title='Python Library Documentation: %s', forceload=0,
+ output=None):
"""Display text documentation, given an object or a path to an object."""
try:
- pager(render_doc(thing, title, forceload))
+ if output is None:
+ pager(render_doc(thing, title, forceload))
+ else:
+ output.write(render_doc(thing, title, forceload, plaintext))
except (ImportError, ErrorDuringImport) as value:
print(value)
@@ -1552,12 +1587,13 @@ class Helper:
'finally': 'try',
'for': ('for', 'break continue while'),
'from': 'import',
- 'global': ('global', 'NAMESPACES'),
+ 'global': ('global', 'nonlocal NAMESPACES'),
'if': ('if', 'TRUTHVALUE'),
'import': ('import', 'MODULES'),
'in': ('in', 'SEQUENCEMETHODS'),
'is': 'COMPARISON',
'lambda': ('lambda', 'FUNCTIONS'),
+ 'nonlocal': ('nonlocal', 'global NAMESPACES'),
'not': 'BOOLEAN',
'or': 'BOOLEAN',
'pass': ('pass', ''),
@@ -1652,7 +1688,7 @@ class Helper:
'NUMBERMETHODS': ('numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT '
'SPECIALMETHODS'),
'EXECUTION': ('execmodel', 'NAMESPACES DYNAMICFEATURES EXCEPTIONS'),
- 'NAMESPACES': ('naming', 'global ASSIGNMENT DELETION DYNAMICFEATURES'),
+ 'NAMESPACES': ('naming', 'global nonlocal ASSIGNMENT DELETION DYNAMICFEATURES'),
'DYNAMICFEATURES': ('dynamic-features', ''),
'SCOPING': 'NAMESPACES',
'FRAMES': 'NAMESPACES',
@@ -1754,9 +1790,9 @@ has the same effect as typing a particular string at the help> prompt.
elif request in self.symbols: self.showsymbol(request)
elif request in self.keywords: self.showtopic(request)
elif request in self.topics: self.showtopic(request)
- elif request: doc(request, 'Help on %s:')
+ elif request: doc(request, 'Help on %s:', output=self._output)
elif isinstance(request, Helper): self()
- else: doc(request, 'Help on %s:')
+ else: doc(request, 'Help on %s:', output=self._output)
self.output.write('\n')
def intro(self):
@@ -1837,12 +1873,39 @@ module "pydoc_data.topics" could not be found.
if more_xrefs:
xrefs = (xrefs or '') + ' ' + more_xrefs
if xrefs:
- import io, formatter
+ import formatter
buffer = io.StringIO()
formatter.DumbWriter(buffer).send_flowing_data(
'Related help topics: ' + ', '.join(xrefs.split()) + '\n')
self.output.write('\n%s\n' % buffer.getvalue())
+ def _gettopic(self, topic, more_xrefs=''):
+ """Return unbuffered tuple of (topic, xrefs).
+
+ If an error occurs here, the exception is caught and displayed by
+ the url handler.
+
+ This function duplicates the showtopic method but returns its
+ result directly so it can be formatted for display in an html page.
+ """
+ try:
+ import pydoc_data.topics
+ except ImportError:
+ return('''
+Sorry, topic and keyword documentation is not available because the
+module "pydoc_data.topics" could not be found.
+''' , '')
+ target = self.topics.get(topic, self.keywords.get(topic))
+ if not target:
+ raise ValueError('could not find topic')
+ if isinstance(target, str):
+ return self._gettopic(target, more_xrefs)
+ label, xrefs = target
+ doc = pydoc_data.topics.topics[label]
+ if more_xrefs:
+ xrefs = (xrefs or '') + ' ' + more_xrefs
+ return doc, xrefs
+
def showsymbol(self, symbol):
target = self.symbols[symbol]
topic, _, xrefs = target.partition(' ')
@@ -1924,6 +1987,15 @@ class ModuleScanner:
for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
if self.quit:
break
+
+ # XXX Skipping this file is a workaround for a bug
+ # that causes python to crash with a segfault.
+ # http://bugs.python.org/issue9319
+ #
+ # TODO Remove this once the bug is fixed.
+ if modname in {'test.badsyntax_pep3120', 'badsyntax_pep3120'}:
+ continue
+
if key is None:
callback(None, modname, '')
else:
@@ -1939,7 +2011,6 @@ class ModuleScanner:
if onerror:
onerror(modname)
continue
- import io
desc = source_synopsis(io.StringIO(source)) or ''
if hasattr(loader, 'get_filename'):
path = loader.get_filename(modname)
@@ -1969,16 +2040,18 @@ def apropos(key):
print(modname, desc and '- ' + desc)
def onerror(modname):
pass
- try: import warnings
- except ImportError: pass
- else: warnings.filterwarnings('ignore') # ignore problems during import
- ModuleScanner().run(callback, key, onerror=onerror)
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore') # ignore problems during import
+ ModuleScanner().run(callback, key, onerror=onerror)
-# --------------------------------------------------- web browser interface
+# --------------------------------------------------- Web browser interface
def serve(port, callback=None, completer=None):
import http.server, email.message, select
+ msg = 'the pydoc.serve() function is deprecated'
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
class DocHandler(http.server.BaseHTTPRequestHandler):
def send_document(self, title, contents):
try:
@@ -2026,8 +2099,8 @@ pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font>'''
class DocServer(http.server.HTTPServer):
def __init__(self, port, callback):
- host = (sys.platform == 'mac') and '127.0.0.1' or 'localhost'
- self.address = ('', port)
+ host = 'localhost'
+ self.address = (host, port)
self.url = 'http://%s:%d/' % (host, port)
self.callback = callback
self.base.__init__(self, self.address, self.handler)
@@ -2038,6 +2111,7 @@ pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font>'''
while not self.quit:
rd, wr, ex = select.select([self.socket.fileno()], [], [], 1)
if rd: self.handle_request()
+ self.server_close()
def server_activate(self):
self.base.server_activate(self)
@@ -2057,7 +2131,12 @@ pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font>'''
# ----------------------------------------------------- graphical interface
def gui():
- """Graphical interface (starts web server and pops up a control window)."""
+ """Graphical interface (starts Web server and pops up a control window)."""
+
+ msg = ('the pydoc.gui() function and "pydoc -g" option are deprecated\n',
+ 'use "pydoc.browse() function and "pydoc -b" option instead.')
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
class GUI:
def __init__(self, window, port=7464):
self.window = window
@@ -2137,19 +2216,8 @@ def gui():
def open(self, event=None, url=None):
url = url or self.server.url
- try:
- import webbrowser
- webbrowser.open(url)
- except ImportError: # pre-webbrowser.py compatibility
- if sys.platform == 'win32':
- os.system('start "%s"' % url)
- elif sys.platform == 'mac':
- try: import ic
- except ImportError: pass
- else: ic.launchurl(url)
- else:
- rc = os.system('netscape -remote "openURL(%s)" &' % url)
- if rc: os.system('netscape "%s" &' % url)
+ import webbrowser
+ webbrowser.open(url)
def quit(self, event=None):
if self.server:
@@ -2241,6 +2309,444 @@ def gui():
except KeyboardInterrupt:
pass
+
+# --------------------------------------- enhanced Web browser interface
+
+def _start_server(urlhandler, port):
+ """Start an HTTP server thread on a specific port.
+
+ Start an HTML/text server thread, so HTML or text documents can be
+ browsed dynamically and interactively with a Web browser. Example use:
+
+ >>> import time
+ >>> import pydoc
+
+ Define a URL handler. To determine what the client is asking
+ for, check the URL and content_type.
+
+ Then get or generate some text or HTML code and return it.
+
+ >>> def my_url_handler(url, content_type):
+ ... text = 'the URL sent was: (%s, %s)' % (url, content_type)
+ ... return text
+
+ Start server thread on port 0.
+ If you use port 0, the server will pick a random port number.
+ You can then use serverthread.port to get the port number.
+
+ >>> port = 0
+ >>> serverthread = pydoc._start_server(my_url_handler, port)
+
+ Check that the server is really started. If it is, open browser
+ and get first page. Use serverthread.url as the starting page.
+
+ >>> if serverthread.serving:
+ ... import webbrowser
+
+ The next two lines are commented out so a browser doesn't open if
+ doctest is run on this module.
+
+ #... webbrowser.open(serverthread.url)
+ #True
+
+ Let the server do its thing. We just need to monitor its status.
+ Use time.sleep so the loop doesn't hog the CPU.
+
+ >>> starttime = time.time()
+ >>> timeout = 1 #seconds
+
+ This is a short timeout for testing purposes.
+
+ >>> while serverthread.serving:
+ ... time.sleep(.01)
+ ... if serverthread.serving and time.time() - starttime > timeout:
+ ... serverthread.stop()
+ ... break
+
+ Print any errors that may have occurred.
+
+ >>> print(serverthread.error)
+ None
+ """
+ import http.server
+ import email.message
+ import select
+ import threading
+
+ class DocHandler(http.server.BaseHTTPRequestHandler):
+
+ def do_GET(self):
+ """Process a request from an HTML browser.
+
+ The URL received is in self.path.
+ Get an HTML page from self.urlhandler and send it.
+ """
+ if self.path.endswith('.css'):
+ content_type = 'text/css'
+ else:
+ content_type = 'text/html'
+ self.send_response(200)
+ self.send_header('Content-Type', '%s; charset=UTF-8' % content_type)
+ self.end_headers()
+ self.wfile.write(self.urlhandler(
+ self.path, content_type).encode('utf-8'))
+
+ def log_message(self, *args):
+ # Don't log messages.
+ pass
+
+ class DocServer(http.server.HTTPServer):
+
+ def __init__(self, port, callback):
+ self.host = (sys.platform == 'mac') and '127.0.0.1' or 'localhost'
+ self.address = ('', port)
+ self.callback = callback
+ self.base.__init__(self, self.address, self.handler)
+ self.quit = False
+
+ def serve_until_quit(self):
+ while not self.quit:
+ rd, wr, ex = select.select([self.socket.fileno()], [], [], 1)
+ if rd:
+ self.handle_request()
+ self.server_close()
+
+ def server_activate(self):
+ self.base.server_activate(self)
+ if self.callback:
+ self.callback(self)
+
+ class ServerThread(threading.Thread):
+
+ def __init__(self, urlhandler, port):
+ self.urlhandler = urlhandler
+ self.port = int(port)
+ threading.Thread.__init__(self)
+ self.serving = False
+ self.error = None
+
+ def run(self):
+ """Start the server."""
+ try:
+ DocServer.base = http.server.HTTPServer
+ DocServer.handler = DocHandler
+ DocHandler.MessageClass = email.message.Message
+ DocHandler.urlhandler = staticmethod(self.urlhandler)
+ docsvr = DocServer(self.port, self.ready)
+ self.docserver = docsvr
+ docsvr.serve_until_quit()
+ except Exception as e:
+ self.error = e
+
+ def ready(self, server):
+ self.serving = True
+ self.host = server.host
+ self.port = server.server_port
+ self.url = 'http://%s:%d/' % (self.host, self.port)
+
+ def stop(self):
+ """Stop the server and this thread nicely"""
+ self.docserver.quit = True
+ self.serving = False
+ self.url = None
+
+ thread = ServerThread(urlhandler, port)
+ thread.start()
+ # Wait until thread.serving is True to make sure we are
+ # really up before returning.
+ while not thread.error and not thread.serving:
+ time.sleep(.01)
+ return thread
+
+
+def _url_handler(url, content_type="text/html"):
+ """The pydoc url handler for use with the pydoc server.
+
+ If the content_type is 'text/css', the _pydoc.css style
+ sheet is read and returned if it exits.
+
+ If the content_type is 'text/html', then the result of
+ get_html_page(url) is returned.
+ """
+ class _HTMLDoc(HTMLDoc):
+
+ def page(self, title, contents):
+ """Format an HTML page."""
+ css_path = "pydoc_data/_pydoc.css"
+ css_link = (
+ '<link rel="stylesheet" type="text/css" href="%s">' %
+ css_path)
+ return '''\
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Pydoc: %s</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+%s</head><body bgcolor="#f0f0f8">%s<div style="clear:both;padding-top:.5em;">%s</div>
+</body></html>''' % (title, css_link, html_navbar(), contents)
+
+ def filelink(self, url, path):
+ return '<a href="getfile?key=%s">%s</a>' % (url, path)
+
+
+ html = _HTMLDoc()
+
+ def html_navbar():
+ version = html.escape("%s [%s, %s]" % (platform.python_version(),
+ platform.python_build()[0],
+ platform.python_compiler()))
+ return """
+ <div style='float:left'>
+ Python %s<br>%s
+ </div>
+ <div style='float:right'>
+ <div style='text-align:center'>
+ <a href="index.html">Module Index</a>
+ : <a href="topics.html">Topics</a>
+ : <a href="keywords.html">Keywords</a>
+ </div>
+ <div>
+ <form action="get" style='display:inline;'>
+ <input type=text name=key size=15>
+ <input type=submit value="Get">
+ </form>&nbsp;
+ <form action="search" style='display:inline;'>
+ <input type=text name=key size=15>
+ <input type=submit value="Search">
+ </form>
+ </div>
+ </div>
+ """ % (version, html.escape(platform.platform(terse=True)))
+
+ def html_index():
+ """Module Index page."""
+
+ def bltinlink(name):
+ return '<a href="%s.html">%s</a>' % (name, name)
+
+ heading = html.heading(
+ '<big><big><strong>Index of Modules</strong></big></big>',
+ '#ffffff', '#7799ee')
+ names = [name for name in sys.builtin_module_names
+ if name != '__main__']
+ contents = html.multicolumn(names, bltinlink)
+ contents = [heading, '<p>' + html.bigsection(
+ 'Built-in Modules', '#ffffff', '#ee77aa', contents)]
+
+ seen = {}
+ for dir in sys.path:
+ contents.append(html.index(dir, seen))
+
+ contents.append(
+ '<p align=right><font color="#909090" face="helvetica,'
+ 'arial"><strong>pydoc</strong> by Ka-Ping Yee'
+ '&lt;ping@lfw.org&gt;</font>')
+ return 'Index of Modules', ''.join(contents)
+
+ def html_search(key):
+ """Search results page."""
+ # scan for modules
+ search_result = []
+
+ def callback(path, modname, desc):
+ if modname[-9:] == '.__init__':
+ modname = modname[:-9] + ' (package)'
+ search_result.append((modname, desc and '- ' + desc))
+
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore') # ignore problems during import
+ ModuleScanner().run(callback, key)
+
+ # format page
+ def bltinlink(name):
+ return '<a href="%s.html">%s</a>' % (name, name)
+
+ results = []
+ heading = html.heading(
+ '<big><big><strong>Search Results</strong></big></big>',
+ '#ffffff', '#7799ee')
+ for name, desc in search_result:
+ results.append(bltinlink(name) + desc)
+ contents = heading + html.bigsection(
+ 'key = %s' % key, '#ffffff', '#ee77aa', '<br>'.join(results))
+ return 'Search Results', contents
+
+ def html_getfile(path):
+ """Get and display a source file listing safely."""
+ path = path.replace('%20', ' ')
+ with open(path, 'r') as fp:
+ lines = html.escape(fp.read())
+ body = '<pre>%s</pre>' % lines
+ heading = html.heading(
+ '<big><big><strong>File Listing</strong></big></big>',
+ '#ffffff', '#7799ee')
+ contents = heading + html.bigsection(
+ 'File: %s' % path, '#ffffff', '#ee77aa', body)
+ return 'getfile %s' % path, contents
+
+ def html_topics():
+ """Index of topic texts available."""
+
+ def bltinlink(name):
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
+
+ heading = html.heading(
+ '<big><big><strong>INDEX</strong></big></big>',
+ '#ffffff', '#7799ee')
+ names = sorted(Helper.topics.keys())
+
+ contents = html.multicolumn(names, bltinlink)
+ contents = heading + html.bigsection(
+ 'Topics', '#ffffff', '#ee77aa', contents)
+ return 'Topics', contents
+
+ def html_keywords():
+ """Index of keywords."""
+ heading = html.heading(
+ '<big><big><strong>INDEX</strong></big></big>',
+ '#ffffff', '#7799ee')
+ names = sorted(Helper.keywords.keys())
+
+ def bltinlink(name):
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
+
+ contents = html.multicolumn(names, bltinlink)
+ contents = heading + html.bigsection(
+ 'Keywords', '#ffffff', '#ee77aa', contents)
+ return 'Keywords', contents
+
+ def html_topicpage(topic):
+ """Topic or keyword help page."""
+ buf = io.StringIO()
+ htmlhelp = Helper(buf, buf)
+ contents, xrefs = htmlhelp._gettopic(topic)
+ if topic in htmlhelp.keywords:
+ title = 'KEYWORD'
+ else:
+ title = 'TOPIC'
+ heading = html.heading(
+ '<big><big><strong>%s</strong></big></big>' % title,
+ '#ffffff', '#7799ee')
+ contents = '<pre>%s</pre>' % html.markup(contents)
+ contents = html.bigsection(topic , '#ffffff','#ee77aa', contents)
+ if xrefs:
+ xrefs = sorted(xrefs.split())
+
+ def bltinlink(name):
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
+
+ xrefs = html.multicolumn(xrefs, bltinlink)
+ xrefs = html.section('Related help topics: ',
+ '#ffffff', '#ee77aa', xrefs)
+ return ('%s %s' % (title, topic),
+ ''.join((heading, contents, xrefs)))
+
+ def html_getobj(url):
+ obj = locate(url, forceload=1)
+ if obj is None and url != 'None':
+ raise ValueError('could not find object')
+ title = describe(obj)
+ content = html.document(obj, url)
+ return title, content
+
+ def html_error(url, exc):
+ heading = html.heading(
+ '<big><big><strong>Error</strong></big></big>',
+ '#ffffff', '#7799ee')
+ contents = '<br>'.join(html.escape(line) for line in
+ format_exception_only(type(exc), exc))
+ contents = heading + html.bigsection(url, '#ffffff', '#bb0000',
+ contents)
+ return "Error - %s" % url, contents
+
+ def get_html_page(url):
+ """Generate an HTML page for url."""
+ complete_url = url
+ if url.endswith('.html'):
+ url = url[:-5]
+ try:
+ if url in ("", "index"):
+ title, content = html_index()
+ elif url == "topics":
+ title, content = html_topics()
+ elif url == "keywords":
+ title, content = html_keywords()
+ elif '=' in url:
+ op, _, url = url.partition('=')
+ if op == "search?key":
+ title, content = html_search(url)
+ elif op == "getfile?key":
+ title, content = html_getfile(url)
+ elif op == "topic?key":
+ # try topics first, then objects.
+ try:
+ title, content = html_topicpage(url)
+ except ValueError:
+ title, content = html_getobj(url)
+ elif op == "get?key":
+ # try objects first, then topics.
+ if url in ("", "index"):
+ title, content = html_index()
+ else:
+ try:
+ title, content = html_getobj(url)
+ except ValueError:
+ title, content = html_topicpage(url)
+ else:
+ raise ValueError('bad pydoc url')
+ else:
+ title, content = html_getobj(url)
+ except Exception as exc:
+ # Catch any errors and display them in an error page.
+ title, content = html_error(complete_url, exc)
+ return html.page(title, content)
+
+ if url.startswith('/'):
+ url = url[1:]
+ if content_type == 'text/css':
+ path_here = os.path.dirname(os.path.realpath(__file__))
+ css_path = os.path.join(path_here, url)
+ with open(css_path) as fp:
+ return ''.join(fp.readlines())
+ elif content_type == 'text/html':
+ return get_html_page(url)
+ # Errors outside the url handler are caught by the server.
+ raise TypeError('unknown content type %r for url %s' % (content_type, url))
+
+
+def browse(port=0, *, open_browser=True):
+ """Start the enhanced pydoc Web server and open a Web browser.
+
+ Use port '0' to start the server on an arbitrary port.
+ Set open_browser to False to suppress opening a browser.
+ """
+ import webbrowser
+ serverthread = _start_server(_url_handler, port)
+ if serverthread.error:
+ print(serverthread.error)
+ return
+ if serverthread.serving:
+ server_help_msg = 'Server commands: [b]rowser, [q]uit'
+ if open_browser:
+ webbrowser.open(serverthread.url)
+ try:
+ print('Server ready at', serverthread.url)
+ print(server_help_msg)
+ while serverthread.serving:
+ cmd = input('server> ')
+ cmd = cmd.lower()
+ if cmd == 'q':
+ break
+ elif cmd == 'b':
+ webbrowser.open(serverthread.url)
+ else:
+ print(server_help_msg)
+ except (KeyboardInterrupt, EOFError):
+ print()
+ finally:
+ if serverthread.serving:
+ serverthread.stop()
+ print('Server stopped')
+
+
# -------------------------------------------------- command-line interface
def ispath(x):
@@ -2260,29 +2766,32 @@ def cli():
sys.path.insert(0, '.')
try:
- opts, args = getopt.getopt(sys.argv[1:], 'gk:p:w')
- writing = 0
-
+ opts, args = getopt.getopt(sys.argv[1:], 'bgk:p:w')
+ writing = False
+ start_server = False
+ open_browser = False
+ port = None
for opt, val in opts:
if opt == '-g':
gui()
return
+ if opt == '-b':
+ start_server = True
+ open_browser = True
if opt == '-k':
apropos(val)
return
if opt == '-p':
- try:
- port = int(val)
- except ValueError:
- raise BadUsage
- def ready(server):
- print('pydoc server ready at %s' % server.url)
- def stopped():
- print('pydoc server stopped')
- serve(port, ready, stopped)
- return
+ start_server = True
+ port = val
if opt == '-w':
- writing = 1
+ writing = True
+
+ if start_server == True:
+ if port == None:
+ port = 0
+ browse(port, open_browser=open_browser)
+ return
if not args: raise BadUsage
for arg in args:
@@ -2303,30 +2812,37 @@ def cli():
print(value)
except (getopt.error, BadUsage):
- cmd = os.path.basename(sys.argv[0])
+ cmd = os.path.splitext(os.path.basename(sys.argv[0]))[0]
print("""pydoc - the Python documentation tool
-%s <name> ...
+{cmd} <name> ...
Show text documentation on something. <name> may be the name of a
Python keyword, topic, function, module, or package, or a dotted
reference to a class or function within a module or module in a
- package. If <name> contains a '%s', it is used as the path to a
+ package. If <name> contains a '{sep}', it is used as the path to a
Python source file to document. If name is 'keywords', 'topics',
or 'modules', a listing of these things is displayed.
-%s -k <keyword>
+{cmd} -k <keyword>
Search for a keyword in the synopsis lines of all available modules.
-%s -p <port>
- Start an HTTP server on the given port on the local machine.
+{cmd} -p <port>
+ Start an HTTP server on the given port on the local machine. Port
+ number 0 can be used to get an arbitrary unused port.
+
+{cmd} -b
+ Start an HTTP server on an arbitrary unused port and open a Web browser
+ to interactively browse documentation. The -p option can be used with
+ the -b option to explicitly specify the server port.
-%s -g
- Pop up a graphical interface for finding and serving documentation.
+{cmd} -g
+ Deprecated.
-%s -w <name> ...
+{cmd} -w <name> ...
Write out the HTML documentation for a module to a file in the current
- directory. If <name> contains a '%s', it is treated as a filename; if
+ directory. If <name> contains a '{sep}', it is treated as a filename; if
it names a directory, documentation is written for all the contents.
-""" % (cmd, os.sep, cmd, cmd, cmd, cmd, os.sep))
+""".format(cmd=cmd, sep=os.sep))
-if __name__ == '__main__': cli()
+if __name__ == '__main__':
+ cli()
diff --git a/Lib/pydoc_data/_pydoc.css b/Lib/pydoc_data/_pydoc.css
new file mode 100644
index 0000000000..f036ef37a5
--- /dev/null
+++ b/Lib/pydoc_data/_pydoc.css
@@ -0,0 +1,6 @@
+/*
+ CSS file for pydoc.
+
+ Contents of this file are subject to change without notice.
+
+*/
diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py
index ef112b6b7c..f9b4b5c12b 100644
--- a/Lib/pydoc_data/topics.py
+++ b/Lib/pydoc_data/topics.py
@@ -1,78 +1,78 @@
-# Autogenerated by Sphinx on Fri Jun 26 08:03:32 2009
+# Autogenerated by Sphinx on Sun Feb 20 10:16:17 2011
topics = {'assert': '\nThe ``assert`` statement\n************************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, ``assert expression``, is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, ``assert expression1, expression2``, is equivalent\nto\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that ``__debug__`` and ``AssertionError``\nrefer to the built-in variables with those names. In the current\nimplementation, the built-in variable ``__debug__`` is ``True`` under\nnormal circumstances, ``False`` when optimization is requested\n(command line option -O). The current code generator emits no code\nfor an assert statement when optimization is requested at compile\ntime. Note that it is unnecessary to include the source code for the\nexpression that failed in the error message; it will be displayed as\npart of the stack trace.\n\nAssignments to ``__debug__`` are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n',
- 'assignment': '\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The object\n must be an iterable with the same number of items as there are\n targets in the target list, and the items are assigned, from left to\n right, to the corresponding targets. (This rule is relaxed as of\n Python 1.5; in earlier versions, the object had to be a tuple.\n Since strings are sequences, an assignment like ``a, b = "xy"`` is\n now legal as long as the string has the right length.)\n\n * If the target list contains one target prefixed with an asterisk,\n called a "starred" target: The object must be a sequence with at\n least as many items as there are targets in the target list, minus\n one. The first items of the sequence are assigned, from left to\n right, to the targets before the starred target. The final items\n of the sequence are assigned to the targets after the starred\n target. A list of the remaining items in the sequence is then\n assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of items\n as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a ``global`` or ``nonlocal``\n statement in the current code block: the name is bound to the\n object in the current local namespace.\n\n * Otherwise: the name is bound to the object in the global namespace\n or the outer namespace determined by ``nonlocal``, respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n brackets: The object must be an iterable with the same number of\n items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, ``TypeError`` is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily ``AttributeError``).\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, ``IndexError`` is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the ``__setitem__()`` method is called\n with appropriate arguments.\n\n* If the target is a slicing: The primary expression in the reference\n is evaluated. It should yield a mutable sequence object (such as a\n list). The assigned object should be a sequence object of the same\n type. Next, the lower and upper bound expressions are evaluated,\n insofar they are present; defaults are zero and the sequence\'s\n length. The bounds should evaluate to integers. If either bound is\n negative, the sequence\'s length is added to it. The resulting\n bounds are clipped to lie between zero and the sequence\'s length,\n inclusive. Finally, the sequence object is asked to replace the\n slice with the items of the assigned sequence. The length of the\n slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the object\n allows it.\n\n(In the current implementation, the syntax for targets is taken to be\nthe same as for expressions, and invalid syntax is rejected during the\ncode generation phase, causing less detailed error messages.)\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe! For instance, the\nfollowing program prints ``[0, 2]``:\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2\n print(x)\n\nSee also:\n\n **PEP 3132** - Extended Iterable Unpacking\n The specification for the ``*target`` feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the initial value is\nretrieved with a ``getattr()`` and the result is assigned with a\n``setattr()``. Notice that the two methods do not necessarily refer\nto the same variable. When ``getattr()`` refers to a class variable,\n``setattr()`` still writes to an instance variable. For example:\n\n class A:\n x = 3 # class variable\n a = A()\n a.x += 1 # writes a.x as 4 leaving A.x as 3\n',
+ 'assignment': '\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The object\n must be an iterable with the same number of items as there are\n targets in the target list, and the items are assigned, from left to\n right, to the corresponding targets. (This rule is relaxed as of\n Python 1.5; in earlier versions, the object had to be a tuple.\n Since strings are sequences, an assignment like ``a, b = "xy"`` is\n now legal as long as the string has the right length.)\n\n * If the target list contains one target prefixed with an asterisk,\n called a "starred" target: The object must be a sequence with at\n least as many items as there are targets in the target list, minus\n one. The first items of the sequence are assigned, from left to\n right, to the targets before the starred target. The final items\n of the sequence are assigned to the targets after the starred\n target. A list of the remaining items in the sequence is then\n assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of items\n as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a ``global`` or ``nonlocal``\n statement in the current code block: the name is bound to the\n object in the current local namespace.\n\n * Otherwise: the name is bound to the object in the global namespace\n or the outer namespace determined by ``nonlocal``, respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n brackets: The object must be an iterable with the same number of\n items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, ``TypeError`` is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily ``AttributeError``).\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n ``a.x`` can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target ``a.x`` is\n always set as an instance attribute, creating it if necessary.\n Thus, the two occurrences of ``a.x`` do not necessarily refer to the\n same attribute: if the RHS expression refers to a class attribute,\n the LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with ``property()``.\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, ``IndexError`` is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the ``__setitem__()`` method is called\n with appropriate arguments.\n\n* If the target is a slicing: The primary expression in the reference\n is evaluated. It should yield a mutable sequence object (such as a\n list). The assigned object should be a sequence object of the same\n type. Next, the lower and upper bound expressions are evaluated,\n insofar they are present; defaults are zero and the sequence\'s\n length. The bounds should evaluate to integers. If either bound is\n negative, the sequence\'s length is added to it. The resulting\n bounds are clipped to lie between zero and the sequence\'s length,\n inclusive. Finally, the sequence object is asked to replace the\n slice with the items of the assigned sequence. The length of the\n slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the object\n allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe! For instance, the\nfollowing program prints ``[0, 2]``:\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2\n print(x)\n\nSee also:\n\n **PEP 3132** - Extended Iterable Unpacking\n The specification for the ``*target`` feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n',
'atom-identifiers': '\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a ``NameError`` exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name in front of the name, with leading underscores removed, and\na single underscore inserted in front of the class name. For example,\nthe identifier ``__spam`` occurring in a class named ``Ham`` will be\ntransformed to ``_Ham__spam``. This transformation is independent of\nthe syntactical context in which the identifier is used. If the\ntransformed name is extremely long (longer than 255 characters),\nimplementation defined truncation may happen. If the class name\nconsists only of underscores, no transformation is done.\n',
'atom-literals': "\nLiterals\n********\n\nPython supports string and bytes literals and various numeric\nliterals:\n\n literal ::= stringliteral | bytesliteral\n | integer | floatnumber | imagnumber\n\nEvaluation of a literal yields an object of the given type (string,\nbytes, integer, floating point number, complex number) with the given\nvalue. The value may be approximated in the case of floating point\nand imaginary (complex) literals. See section *Literals* for details.\n\nWith the exception of bytes literals, these all correspond to\nimmutable data types, and hence the object's identity is less\nimportant than its value. Multiple evaluations of literals with the\nsame value (either the same occurrence in the program text or a\ndifferent occurrence) may obtain the same object or a different object\nwith the same value.\n",
- 'attribute-access': '\nCustomizing attribute access\n****************************\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for ``self``). ``name`` is the attribute name.\n This method should return the (computed) attribute value or raise\n an ``AttributeError`` exception.\n\n Note that if the attribute is found through the normal mechanism,\n ``__getattr__()`` is not called. (This is an intentional asymmetry\n between ``__getattr__()`` and ``__setattr__()``.) This is done both\n for efficiency reasons and because otherwise ``__getattr__()``\n would have no way to access other attributes of the instance. Note\n that at least for instance variables, you can fake total control by\n not inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n ``__getattribute__()`` method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines\n ``__getattr__()``, the latter will not be called unless\n ``__getattribute__()`` either calls it explicitly or raises an\n ``AttributeError``. This method should return the (computed)\n attribute value or raise an ``AttributeError`` exception. In order\n to avoid infinite recursion in this method, its implementation\n should always call the base class method with the same name to\n access any attributes it needs, for example,\n ``object.__getattribute__(self, name)``.\n\n Note: This method may still be bypassed when looking up special methods\n as the result of implicit invocation via language syntax or\n builtin functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If ``__setattr__()`` wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n Like ``__setattr__()`` but for attribute deletion instead of\n assignment. This should only be implemented if ``del obj.name`` is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when ``dir()`` is called on the object. A list must be\n returned.\n\n\nImplementing Descriptors\n========================\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in the\nclass dictionary of another class, known as the *owner* class. In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or ``None`` when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an\n ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\n\nInvoking Descriptors\n====================\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: ``x.__get__(a)``.\n\nInstance Binding\n If binding to an object instance, ``a.x`` is transformed into the\n call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n If binding to a class, ``A.x`` is transformed into the call:\n ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n If ``a`` is an instance of ``super``, then the binding ``super(B,\n obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n ``A`` immediately preceding ``B`` and then invokes the descriptor\n with the call: ``A.__dict__[\'m\'].__get__(obj, A)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. Normally, data\ndescriptors define both ``__get__()`` and ``__set__()``, while non-\ndata descriptors have just the ``__get__()`` method. Data descriptors\nalways override a redefinition in an instance dictionary. In\ncontrast, non-data descriptors can be overridden by instances. [2]\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n=========\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. If defined in a\n class, *__slots__* reserves space for the declared variables and\n prevents the automatic creation of *__dict__* and *__weakref__* for\n each instance.\n\n\nNotes on using *__slots__*\n--------------------------\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises ``AttributeError``. If\n dynamic assignment of new variables is desired, then add\n ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes defining\n *__slots__* do not support weak references to its instances. If weak\n reference support is needed, then add ``\'__weakref__\'`` to the\n sequence of strings in the *__slots__* declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* If a class defines a slot also defined in a base class, the instance\n variable defined by the base class slot is inaccessible (except by\n retrieving its descriptor directly from the base class). This\n renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__*.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as ``int``, ``str`` and\n ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n',
+ 'attribute-access': '\nCustomizing attribute access\n****************************\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for ``self``). ``name`` is the attribute name.\n This method should return the (computed) attribute value or raise\n an ``AttributeError`` exception.\n\n Note that if the attribute is found through the normal mechanism,\n ``__getattr__()`` is not called. (This is an intentional asymmetry\n between ``__getattr__()`` and ``__setattr__()``.) This is done both\n for efficiency reasons and because otherwise ``__getattr__()``\n would have no way to access other attributes of the instance. Note\n that at least for instance variables, you can fake total control by\n not inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n ``__getattribute__()`` method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines\n ``__getattr__()``, the latter will not be called unless\n ``__getattribute__()`` either calls it explicitly or raises an\n ``AttributeError``. This method should return the (computed)\n attribute value or raise an ``AttributeError`` exception. In order\n to avoid infinite recursion in this method, its implementation\n should always call the base class method with the same name to\n access any attributes it needs, for example,\n ``object.__getattribute__(self, name)``.\n\n Note: This method may still be bypassed when looking up special methods\n as the result of implicit invocation via language syntax or\n built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If ``__setattr__()`` wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n Like ``__setattr__()`` but for attribute deletion instead of\n assignment. This should only be implemented if ``del obj.name`` is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when ``dir()`` is called on the object. A list must be\n returned.\n\n\nImplementing Descriptors\n========================\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in the\nclass dictionary of another class, known as the *owner* class. In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or ``None`` when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an\n ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\n\nInvoking Descriptors\n====================\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: ``x.__get__(a)``.\n\nInstance Binding\n If binding to an object instance, ``a.x`` is transformed into the\n call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n If binding to a class, ``A.x`` is transformed into the call:\n ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n If ``a`` is an instance of ``super``, then the binding ``super(B,\n obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n ``A`` immediately preceding ``B`` and then invokes the descriptor\n with the call: ``A.__dict__[\'m\'].__get__(obj, A)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of ``__get__()``, ``__set__()`` and ``__delete__()``.\nIf it does not define ``__get__()``, then accessing the attribute will\nreturn the descriptor object itself unless there is a value in the\nobject\'s instance dictionary. If the descriptor defines ``__set__()``\nand/or ``__delete__()``, it is a data descriptor; if it defines\nneither, it is a non-data descriptor. Normally, data descriptors\ndefine both ``__get__()`` and ``__set__()``, while non-data\ndescriptors have just the ``__get__()`` method. Data descriptors with\n``__set__()`` and ``__get__()`` defined always override a redefinition\nin an instance dictionary. In contrast, non-data descriptors can be\noverridden by instances.\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n=========\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. If defined in a\n class, *__slots__* reserves space for the declared variables and\n prevents the automatic creation of *__dict__* and *__weakref__* for\n each instance.\n\n\nNotes on using *__slots__*\n--------------------------\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises ``AttributeError``. If\n dynamic assignment of new variables is desired, then add\n ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes defining\n *__slots__* do not support weak references to its instances. If weak\n reference support is needed, then add ``\'__weakref__\'`` to the\n sequence of strings in the *__slots__* declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the instance\n variable defined by the base class slot is inaccessible (except by\n retrieving its descriptor directly from the base class). This\n renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as ``int``, ``str`` and\n ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n',
'attribute-references': '\nAttribute references\n********************\n\nAn attribute reference is a primary followed by a period and a name:\n\n attributeref ::= primary "." identifier\n\nThe primary must evaluate to an object of a type that supports\nattribute references, which most objects do. This object is then\nasked to produce the attribute whose name is the identifier (which can\nbe customized by overriding the ``__getattr__()`` method). If this\nattribute is not available, the exception ``AttributeError`` is\nraised. Otherwise, the type and value of the object produced is\ndetermined by the object. Multiple evaluations of the same attribute\nreference may yield different objects.\n',
- 'augassign': '\nAugmented assignment statements\n*******************************\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the initial value is\nretrieved with a ``getattr()`` and the result is assigned with a\n``setattr()``. Notice that the two methods do not necessarily refer\nto the same variable. When ``getattr()`` refers to a class variable,\n``setattr()`` still writes to an instance variable. For example:\n\n class A:\n x = 3 # class variable\n a = A()\n a.x += 1 # writes a.x as 4 leaving A.x as 3\n',
+ 'augassign': '\nAugmented assignment statements\n*******************************\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n',
'binary': '\nBinary arithmetic operations\n****************************\n\nThe binary arithmetic operations have the conventional priority\nlevels. Note that some of these operations also apply to certain non-\nnumeric types. Apart from the power operator, there are only two\nlevels, one for multiplicative operators and one for additive\noperators:\n\n m_expr ::= u_expr | m_expr "*" u_expr | m_expr "//" u_expr | m_expr "/" u_expr\n | m_expr "%" u_expr\n a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n\nThe ``*`` (multiplication) operator yields the product of its\narguments. The arguments must either both be numbers, or one argument\nmust be an integer and the other must be a sequence. In the former\ncase, the numbers are converted to a common type and then multiplied\ntogether. In the latter case, sequence repetition is performed; a\nnegative repetition factor yields an empty sequence.\n\nThe ``/`` (division) and ``//`` (floor division) operators yield the\nquotient of their arguments. The numeric arguments are first\nconverted to a common type. Integer division yields a float, while\nfloor division of integers results in an integer; the result is that\nof mathematical division with the \'floor\' function applied to the\nresult. Division by zero raises the ``ZeroDivisionError`` exception.\n\nThe ``%`` (modulo) operator yields the remainder from the division of\nthe first argument by the second. The numeric arguments are first\nconverted to a common type. A zero right argument raises the\n``ZeroDivisionError`` exception. The arguments may be floating point\nnumbers, e.g., ``3.14%0.7`` equals ``0.34`` (since ``3.14`` equals\n``4*0.7 + 0.34``.) The modulo operator always yields a result with\nthe same sign as its second operand (or zero); the absolute value of\nthe result is strictly smaller than the absolute value of the second\noperand [1].\n\nThe floor division and modulo operators are connected by the following\nidentity: ``x == (x//y)*y + (x%y)``. Floor division and modulo are\nalso connected with the built-in function ``divmod()``: ``divmod(x, y)\n== (x//y, x%y)``. [2].\n\nIn addition to performing the modulo operation on numbers, the ``%``\noperator is also overloaded by string objects to perform old-style\nstring formatting (also known as interpolation). The syntax for\nstring formatting is described in the Python Library Reference,\nsection *Old String Formatting Operations*.\n\nThe floor division operator, the modulo operator, and the ``divmod()``\nfunction are not defined for complex numbers. Instead, convert to a\nfloating point number using the ``abs()`` function if appropriate.\n\nThe ``+`` (addition) operator yields the sum of its arguments. The\narguments must either both be numbers or both sequences of the same\ntype. In the former case, the numbers are converted to a common type\nand then added together. In the latter case, the sequences are\nconcatenated.\n\nThe ``-`` (subtraction) operator yields the difference of its\narguments. The numeric arguments are first converted to a common\ntype.\n',
'bitwise': '\nBinary bitwise operations\n*************************\n\nEach of the three bitwise operations has a different priority level:\n\n and_expr ::= shift_expr | and_expr "&" shift_expr\n xor_expr ::= and_expr | xor_expr "^" and_expr\n or_expr ::= xor_expr | or_expr "|" xor_expr\n\nThe ``&`` operator yields the bitwise AND of its arguments, which must\nbe integers.\n\nThe ``^`` operator yields the bitwise XOR (exclusive OR) of its\narguments, which must be integers.\n\nThe ``|`` operator yields the bitwise (inclusive) OR of its arguments,\nwhich must be integers.\n',
'bltin-code-objects': '\nCode Objects\n************\n\nCode objects are used by the implementation to represent "pseudo-\ncompiled" executable Python code such as a function body. They differ\nfrom function objects because they don\'t contain a reference to their\nglobal execution environment. Code objects are returned by the built-\nin ``compile()`` function and can be extracted from function objects\nthrough their ``__code__`` attribute. See also the ``code`` module.\n\nA code object can be executed or evaluated by passing it (instead of a\nsource string) to the ``exec()`` or ``eval()`` built-in functions.\n\nSee *The standard type hierarchy* for more information.\n',
'bltin-ellipsis-object': '\nThe Ellipsis Object\n*******************\n\nThis object is commonly used by slicing (see *Slicings*). It supports\nno special operations. There is exactly one ellipsis object, named\n``Ellipsis`` (a built-in name).\n\nIt is written as ``Ellipsis`` or ``...``.\n',
- 'bltin-file-objects': '\nFile Objects\n************\n\nFile objects are implemented using C\'s ``stdio`` package and can be\ncreated with the built-in ``open()`` function. File objects are also\nreturned by some other built-in functions and methods, such as\n``os.popen()`` and ``os.fdopen()`` and the ``makefile()`` method of\nsocket objects. Temporary files can be created using the ``tempfile``\nmodule, and high-level file operations such as copying, moving, and\ndeleting files and directories can be achieved with the ``shutil``\nmodule.\n\nWhen a file operation fails for an I/O-related reason, the exception\n``IOError`` is raised. This includes situations where the operation\nis not defined for some reason, like ``seek()`` on a tty device or\nwriting a file opened for reading.\n\nFiles have the following methods:\n\nfile.close()\n\n Close the file. A closed file cannot be read or written any more.\n Any operation which requires that the file be open will raise a\n ``ValueError`` after the file has been closed. Calling ``close()``\n more than once is allowed.\n\n You can avoid having to call this method explicitly if you use the\n ``with`` statement. For example, the following code will\n automatically close *f* when the ``with`` block is exited:\n\n from __future__ import with_statement # This isn\'t required in Python 2.6\n\n with open("hello.txt") as f:\n for line in f:\n print(line)\n\n In older versions of Python, you would have needed to do this to\n get the same effect:\n\n f = open("hello.txt")\n try:\n for line in f:\n print(line)\n finally:\n f.close()\n\n Note: Not all "file-like" types in Python support use as a context\n manager for the ``with`` statement. If your code is intended to\n work with any file-like object, you can use the function\n ``contextlib.closing()`` instead of using the object directly.\n\nfile.flush()\n\n Flush the internal buffer, like ``stdio``\'s ``fflush()``. This may\n be a no-op on some file-like objects.\n\n Note: ``flush()`` does not necessarily write the file\'s data to disk.\n Use ``flush()`` followed by ``os.fsync()`` to ensure this\n behavior.\n\nfile.fileno()\n\n Return the integer "file descriptor" that is used by the underlying\n implementation to request I/O operations from the operating system.\n This can be useful for other, lower level interfaces that use file\n descriptors, such as the ``fcntl`` module or ``os.read()`` and\n friends.\n\n Note: File-like objects which do not have a real file descriptor should\n *not* provide this method!\n\nfile.isatty()\n\n Return ``True`` if the file is connected to a tty(-like) device,\n else ``False``.\n\n Note: If a file-like object is not associated with a real file, this\n method should *not* be implemented.\n\nfile.__next__()\n\n A file object is its own iterator, for example ``iter(f)`` returns\n *f* (unless *f* is closed). When a file is used as an iterator,\n typically in a ``for`` loop (for example, ``for line in f:\n print(line)``), the ``__next__()`` method is called repeatedly.\n This method returns the next input line, or raises\n ``StopIteration`` when EOF is hit when the file is open for reading\n (behavior is undefined when the file is open for writing). In\n order to make a ``for`` loop the most efficient way of looping over\n the lines of a file (a very common operation), the ``__next__()``\n method uses a hidden read-ahead buffer. As a consequence of using\n a read-ahead buffer, combining ``__next__()`` with other file\n methods (like ``readline()``) does not work right. However, using\n ``seek()`` to reposition the file to an absolute position will\n flush the read-ahead buffer.\n\nfile.read([size])\n\n Read at most *size* bytes from the file (less if the read hits EOF\n before obtaining *size* bytes). If the *size* argument is negative\n or omitted, read all data until EOF is reached. The bytes are\n returned as a string object. An empty string is returned when EOF\n is encountered immediately. (For certain files, like ttys, it\n makes sense to continue reading after an EOF is hit.) Note that\n this method may call the underlying C function ``fread()`` more\n than once in an effort to acquire as close to *size* bytes as\n possible. Also note that when in non-blocking mode, less data than\n was requested may be returned, even if no *size* parameter was\n given.\n\nfile.readline([size])\n\n Read one entire line from the file. A trailing newline character\n is kept in the string (but may be absent when a file ends with an\n incomplete line). [5] If the *size* argument is present and non-\n negative, it is a maximum byte count (including the trailing\n newline) and an incomplete line may be returned. An empty string is\n returned *only* when EOF is encountered immediately.\n\n Note: Unlike ``stdio``\'s ``fgets()``, the returned string contains null\n characters (``\'\\0\'``) if they occurred in the input.\n\nfile.readlines([sizehint])\n\n Read until EOF using ``readline()`` and return a list containing\n the lines thus read. If the optional *sizehint* argument is\n present, instead of reading up to EOF, whole lines totalling\n approximately *sizehint* bytes (possibly after rounding up to an\n internal buffer size) are read. Objects implementing a file-like\n interface may choose to ignore *sizehint* if it cannot be\n implemented, or cannot be implemented efficiently.\n\nfile.seek(offset[, whence])\n\n Set the file\'s current position, like ``stdio``\'s ``fseek()``. The\n *whence* argument is optional and defaults to ``os.SEEK_SET`` or\n ``0`` (absolute file positioning); other values are ``os.SEEK_CUR``\n or ``1`` (seek relative to the current position) and\n ``os.SEEK_END`` or ``2`` (seek relative to the file\'s end). There\n is no return value.\n\n For example, ``f.seek(2, os.SEEK_CUR)`` advances the position by\n two and ``f.seek(-3, os.SEEK_END)`` sets the position to the third\n to last.\n\n Note that if the file is opened for appending (mode ``\'a\'`` or\n ``\'a+\'``), any ``seek()`` operations will be undone at the next\n write. If the file is only opened for writing in append mode (mode\n ``\'a\'``), this method is essentially a no-op, but it remains useful\n for files opened in append mode with reading enabled (mode\n ``\'a+\'``). If the file is opened in text mode (without ``\'b\'``),\n only offsets returned by ``tell()`` are legal. Use of other\n offsets causes undefined behavior.\n\n Note that not all file objects are seekable.\n\nfile.tell()\n\n Return the file\'s current position, like ``stdio``\'s ``ftell()``.\n\n Note: On Windows, ``tell()`` can return illegal values (after an\n ``fgets()``) when reading files with Unix-style line-endings. Use\n binary mode (``\'rb\'``) to circumvent this problem.\n\nfile.truncate([size])\n\n Truncate the file\'s size. If the optional *size* argument is\n present, the file is truncated to (at most) that size. The size\n defaults to the current position. The current file position is not\n changed. Note that if a specified size exceeds the file\'s current\n size, the result is platform-dependent: possibilities include that\n the file may remain unchanged, increase to the specified size as if\n zero-filled, or increase to the specified size with undefined new\n content. Availability: Windows, many Unix variants.\n\nfile.write(str)\n\n Write a string to the file. Due to buffering, the string may not\n actually show up in the file until the ``flush()`` or ``close()``\n method is called.\n\n The meaning of the return value is not defined for every file-like\n object. Some (mostly low-level) file-like objects may return the\n number of bytes actually written, others return ``None``.\n\nfile.writelines(sequence)\n\n Write a sequence of strings to the file. The sequence can be any\n iterable object producing strings, typically a list of strings.\n There is no return value. (The name is intended to match\n ``readlines()``; ``writelines()`` does not add line separators.)\n\nFiles support the iterator protocol. Each iteration returns the same\nresult as ``file.readline()``, and iteration ends when the\n``readline()`` method returns an empty string.\n\nFile objects also offer a number of other interesting attributes.\nThese are not required for file-like objects, but should be\nimplemented if they make sense for the particular object.\n\nfile.closed\n\n bool indicating the current state of the file object. This is a\n read-only attribute; the ``close()`` method changes the value. It\n may not be available on all file-like objects.\n\nfile.encoding\n\n The encoding that this file uses. When strings are written to a\n file, they will be converted to byte strings using this encoding.\n In addition, when the file is connected to a terminal, the\n attribute gives the encoding that the terminal is likely to use\n (that information might be incorrect if the user has misconfigured\n the terminal). The attribute is read-only and may not be present\n on all file-like objects. It may also be ``None``, in which case\n the file uses the system default encoding for converting strings.\n\nfile.errors\n\n The Unicode error handler used along with the encoding.\n\nfile.mode\n\n The I/O mode for the file. If the file was created using the\n ``open()`` built-in function, this will be the value of the *mode*\n parameter. This is a read-only attribute and may not be present on\n all file-like objects.\n\nfile.name\n\n If the file object was created using ``open()``, the name of the\n file. Otherwise, some string that indicates the source of the file\n object, of the form ``<...>``. This is a read-only attribute and\n may not be present on all file-like objects.\n\nfile.newlines\n\n If Python was built with the *--with-universal-newlines* option to\n **configure** (the default) this read-only attribute exists, and\n for files opened in universal newline read mode it keeps track of\n the types of newlines encountered while reading the file. The\n values it can take are ``\'\\r\'``, ``\'\\n\'``, ``\'\\r\\n\'``, ``None``\n (unknown, no newlines read yet) or a tuple containing all the\n newline types seen, to indicate that multiple newline conventions\n were encountered. For files not opened in universal newline read\n mode the value of this attribute will be ``None``.\n',
'bltin-null-object': "\nThe Null Object\n***************\n\nThis object is returned by functions that don't explicitly return a\nvalue. It supports no special operations. There is exactly one null\nobject, named ``None`` (a built-in name).\n\nIt is written as ``None``.\n",
'bltin-type-objects': "\nType Objects\n************\n\nType objects represent the various object types. An object's type is\naccessed by the built-in function ``type()``. There are no special\noperations on types. The standard module ``types`` defines names for\nall standard built-in types.\n\nTypes are written like this: ``<class 'int'>``.\n",
- 'booleans': '\nBoolean operations\n******************\n\nBoolean operations have the lowest priority of all Python operations:\n\n expression ::= conditional_expression | lambda_form\n expression_nocond ::= or_test | lambda_form_nocond\n conditional_expression ::= or_test ["if" or_test "else" expression]\n or_test ::= and_test | or_test "or" and_test\n and_test ::= not_test | and_test "and" not_test\n not_test ::= comparison | "not" not_test\n\nIn the context of Boolean operations, and also when expressions are\nused by control flow statements, the following values are interpreted\nas false: ``False``, ``None``, numeric zero of all types, and empty\nstrings and containers (including strings, tuples, lists,\ndictionaries, sets and frozensets). All other values are interpreted\nas true. User-defined objects can customize their truth value by\nproviding a ``__bool__()`` method.\n\nThe operator ``not`` yields ``True`` if its argument is false,\n``False`` otherwise.\n\nThe expression ``x if C else y`` first evaluates *C* (*not* *x*); if\n*C* is true, *x* is evaluated and its value is returned; otherwise,\n*y* is evaluated and its value is returned.\n\nThe expression ``x and y`` first evaluates *x*; if *x* is false, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\nThe expression ``x or y`` first evaluates *x*; if *x* is true, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\n(Note that neither ``and`` nor ``or`` restrict the value and type they\nreturn to ``False`` and ``True``, but rather return the last evaluated\nargument. This is sometimes useful, e.g., if ``s`` is a string that\nshould be replaced by a default value if it is empty, the expression\n``s or \'foo\'`` yields the desired value. Because ``not`` has to\ninvent a value anyway, it does not bother to return a value of the\nsame type as its argument, so e.g., ``not \'foo\'`` yields ``False``,\nnot ``\'\'``.)\n',
+ 'booleans': '\nBoolean operations\n******************\n\n or_test ::= and_test | or_test "or" and_test\n and_test ::= not_test | and_test "and" not_test\n not_test ::= comparison | "not" not_test\n\nIn the context of Boolean operations, and also when expressions are\nused by control flow statements, the following values are interpreted\nas false: ``False``, ``None``, numeric zero of all types, and empty\nstrings and containers (including strings, tuples, lists,\ndictionaries, sets and frozensets). All other values are interpreted\nas true. User-defined objects can customize their truth value by\nproviding a ``__bool__()`` method.\n\nThe operator ``not`` yields ``True`` if its argument is false,\n``False`` otherwise.\n\nThe expression ``x and y`` first evaluates *x*; if *x* is false, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\nThe expression ``x or y`` first evaluates *x*; if *x* is true, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\n(Note that neither ``and`` nor ``or`` restrict the value and type they\nreturn to ``False`` and ``True``, but rather return the last evaluated\nargument. This is sometimes useful, e.g., if ``s`` is a string that\nshould be replaced by a default value if it is empty, the expression\n``s or \'foo\'`` yields the desired value. Because ``not`` has to\ninvent a value anyway, it does not bother to return a value of the\nsame type as its argument, so e.g., ``not \'foo\'`` yields ``False``,\nnot ``\'\'``.)\n',
'break': '\nThe ``break`` statement\n***********************\n\n break_stmt ::= "break"\n\n``break`` may only occur syntactically nested in a ``for`` or\n``while`` loop, but not nested in a function or class definition\nwithin that loop.\n\nIt terminates the nearest enclosing loop, skipping the optional\n``else`` clause if the loop has one.\n\nIf a ``for`` loop is terminated by ``break``, the loop control target\nkeeps its current value.\n\nWhen ``break`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nleaving the loop.\n',
'callable-types': '\nEmulating callable objects\n**************************\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n ``x.__call__(arg1, arg2, ...)``.\n',
- 'calls': '\nCalls\n*****\n\nA call calls a callable object (e.g., a function) with a possibly\nempty series of arguments:\n\n call ::= primary "(" [argument_list [","] | comprehension] ")"\n argument_list ::= positional_arguments ["," keyword_arguments]\n ["," "*" expression] ["," keyword_arguments]\n ["," "**" expression]\n | keyword_arguments ["," "*" expression]\n ["," keyword_arguments] ["," "**" expression]\n | "*" expression ["," keyword_arguments] ["," "**" expression]\n | "**" expression\n positional_arguments ::= expression ("," expression)*\n keyword_arguments ::= keyword_item ("," keyword_item)*\n keyword_item ::= identifier "=" expression\n\nA trailing comma may be present after the positional and keyword\narguments but does not affect the semantics.\n\nThe primary must evaluate to a callable object (user-defined\nfunctions, built-in functions, methods of built-in objects, class\nobjects, methods of class instances, and all objects having a\n``__call__()`` method are callable). All argument expressions are\nevaluated before the call is attempted. Please refer to section\n*Function definitions* for the syntax of formal parameter lists.\n\nIf keyword arguments are present, they are first converted to\npositional arguments, as follows. First, a list of unfilled slots is\ncreated for the formal parameters. If there are N positional\narguments, they are placed in the first N slots. Next, for each\nkeyword argument, the identifier is used to determine the\ncorresponding slot (if the identifier is the same as the first formal\nparameter name, the first slot is used, and so on). If the slot is\nalready filled, a ``TypeError`` exception is raised. Otherwise, the\nvalue of the argument is placed in the slot, filling it (even if the\nexpression is ``None``, it fills the slot). When all arguments have\nbeen processed, the slots that are still unfilled are filled with the\ncorresponding default value from the function definition. (Default\nvalues are calculated, once, when the function is defined; thus, a\nmutable object such as a list or dictionary used as default value will\nbe shared by all calls that don\'t specify an argument value for the\ncorresponding slot; this should usually be avoided.) If there are any\nunfilled slots for which no default value is specified, a\n``TypeError`` exception is raised. Otherwise, the list of filled\nslots is used as the argument list for the call.\n\nNote: An implementation may provide builtin functions whose positional\n parameters do not have names, even if they are \'named\' for the\n purpose of documentation, and which therefore cannot be supplied by\n keyword. In CPython, this is the case for functions implemented in\n C that use ``PyArg_ParseTuple()`` to parse their arguments.\n\nIf there are more positional arguments than there are formal parameter\nslots, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``*identifier`` is present; in this case, that formal\nparameter receives a tuple containing the excess positional arguments\n(or an empty tuple if there were no excess positional arguments).\n\nIf any keyword argument does not correspond to a formal parameter\nname, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``**identifier`` is present; in this case, that\nformal parameter receives a dictionary containing the excess keyword\narguments (using the keywords as keys and the argument values as\ncorresponding values), or a (new) empty dictionary if there were no\nexcess keyword arguments.\n\nIf the syntax ``*expression`` appears in the function call,\n``expression`` must evaluate to a sequence. Elements from this\nsequence are treated as if they were additional positional arguments;\nif there are positional arguments *x1*,..., *xN*, and ``expression``\nevaluates to a sequence *y1*, ..., *yM*, this is equivalent to a call\nwith M+N positional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.\n\nA consequence of this is that although the ``*expression`` syntax may\nappear *after* some keyword arguments, it is processed *before* the\nkeyword arguments (and the ``**expression`` argument, if any -- see\nbelow). So:\n\n >>> def f(a, b):\n ... print(a, b)\n ...\n >>> f(b=1, *(2,))\n 2 1\n >>> f(a=1, *(2,))\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n TypeError: f() got multiple values for keyword argument \'a\'\n >>> f(1, *(2,))\n 1 2\n\nIt is unusual for both keyword arguments and the ``*expression``\nsyntax to be used in the same call, so in practice this confusion does\nnot arise.\n\nIf the syntax ``**expression`` appears in the function call,\n``expression`` must evaluate to a mapping, the contents of which are\ntreated as additional keyword arguments. In the case of a keyword\nappearing in both ``expression`` and as an explicit keyword argument,\na ``TypeError`` exception is raised.\n\nFormal parameters using the syntax ``*identifier`` or ``**identifier``\ncannot be used as positional argument slots or as keyword argument\nnames.\n\nA call always returns some value, possibly ``None``, unless it raises\nan exception. How this value is computed depends on the type of the\ncallable object.\n\nIf it is---\n\na user-defined function:\n The code block for the function is executed, passing it the\n argument list. The first thing the code block will do is bind the\n formal parameters to the arguments; this is described in section\n *Function definitions*. When the code block executes a ``return``\n statement, this specifies the return value of the function call.\n\na built-in function or method:\n The result is up to the interpreter; see *Built-in Functions* for\n the descriptions of built-in functions and methods.\n\na class object:\n A new instance of that class is returned.\n\na class instance method:\n The corresponding user-defined function is called, with an argument\n list that is one longer than the argument list of the call: the\n instance becomes the first argument.\n\na class instance:\n The class must define a ``__call__()`` method; the effect is then\n the same as if that method was called.\n',
- 'class': '\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [expression_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. It first evaluates the\ninheritance list, if present. Each item in the inheritance list\nshould evaluate to a class object or class type which allows\nsubclassing. The class\'s suite is then executed in a new execution\nframe (see section *Naming and binding*), using a newly created local\nnamespace and the original global namespace. (Usually, the suite\ncontains only function definitions.) When the class\'s suite finishes\nexecution, its execution frame is discarded but its local namespace is\nsaved. [4] A class object is then created using the inheritance list\nfor the base classes and the saved local namespace for the attribute\ndictionary. The class name is bound to this class object in the\noriginal local namespace.\n\nClasses can also be decorated; as with functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass variables; they are shared by instances. Instance variables can\nbe set in a method with ``self.name = value``. Both class and\ninstance variables are accessible through the notation\n"``self.name``", and an instance variable hides a class variable with\nthe same name when accessed in this way. Class variables can be used\nas defaults for instance variables, but using mutable values there can\nlead to unexpected results. Descriptors can be used to create\ninstance variables with different implementation details.\n\nSee also:\n\n **PEP 3129** - Class Decorators\n\nClass definitions, like function definitions, may be wrapped by one or\nmore *decorator* expressions. The evaluation rules for the decorator\nexpressions are the same as for functions. The result must be a class\nobject, which is then bound to the class name.\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack only if there\n is no ``finally`` clause that negates the exception.\n\n[2] Currently, control "flows off the end" except in the case of an\n exception or the execution of a ``return``, ``continue``, or\n ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n body is transformed into the function\'s ``__doc__`` attribute and\n therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s ``__doc__`` item and\n therefore the class\'s *docstring*.\n',
- 'comparisons': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects. The objects need not have the same type.\nIf both are numbers, they are converted to a common type. Otherwise,\nthe ``==`` and ``!=`` operators *always* consider objects of different\ntypes to be unequal, while the ``<``, ``>``, ``>=`` and ``<=``\noperators raise a ``TypeError`` when comparing objects of different\ntypes that do not implement these operators for the given pair of\ntypes. You can control comparison behavior of objects of non-builtin\ntypes by defining rich comparison methods like ``__gt__()``, described\nin section *Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values ``float(\'NaN\')`` and ``Decimal(\'NaN\')`` are special. The\n are identical to themselves, ``x is x`` but are not equal to\n themselves, ``x != x``. Additionally, comparing any value to a\n not-a-number value will return ``False``. For example, both ``3 <\n float(\'NaN\')`` and ``float(\'NaN\') < 3`` will return ``False``.\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric equivalents\n (the result of the built-in function ``ord()``) of their characters.\n [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison of\n corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, ``[1,2,x] <= [1,2,y]`` has the\n same value as ``x <= y``. If the corresponding element does not\n exist, the shorter sequence is ordered first (for example, ``[1,2] <\n [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if their sorted\n ``(key, value)`` lists compare equal. [4] Outcomes other than\n equality are resolved consistently, but are not otherwise defined.\n [5]\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, ``min()``, ``max()``, and ``sorted()`` produce\n undefined results given a list of sets as inputs.\n\n* Most other objects of builtin types compare unequal unless they are\n the same object; the choice whether one object is considered smaller\n or larger than another one is made arbitrarily but consistently\n within one execution of a program.\n\nComparison of objects of the differing types depends on whether either\nof the types provide explicit support for the comparison. Most\nnumeric types can be compared with one another, but comparisons of\n``float`` and ``Decimal`` are not supported to avoid the inevitable\nconfusion arising from representation issues such as ``float(\'1.1\')``\nbeing inexactly represented and therefore not exactly equal to\n``Decimal(\'1.1\')`` which is. When cross-type comparison is not\nsupported, the comparison method returns ``NotImplemented``. This can\ncreate the illusion of non-transitivity between supported cross-type\ncomparisons and unsupported comparisons. For example, ``Decimal(2) ==\n2`` and *2 == float(2)`* but ``Decimal(2) != float(2)``.\n\nThe operators ``in`` and ``not in`` test for membership. ``x in s``\nevaluates to true if *x* is a member of *s*, and false otherwise. ``x\nnot in s`` returns the negation of ``x in s``. All built-in sequences\nand set types support this as well as dictionary, for which ``in``\ntests whether a the dictionary has a given key. For container types\nsuch as list, tuple, set, frozenset, dict, or collections.deque, the\nexpression ``x in y`` is equivalent to ``any(x is e or x == e for val\ne in y)``.\n\nFor the string and bytes types, ``x in y`` is true if and only if *x*\nis a substring of *y*. An equivalent test is ``y.find(x) != -1``.\nEmpty strings are always considered to be a substring of any other\nstring, so ``"" in "abc"`` will return ``True``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` and do\ndefine ``__getitem__()``, ``x in y`` is true if and only if there is a\nnon-negative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception. (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object. ``x is\nnot y`` yields the inverse truth value. [6]\n',
- 'compound': '\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way. In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe ``if``, ``while`` and ``for`` statements implement traditional\ncontrol flow constructs. ``try`` specifies exception handlers and/or\ncleanup code for a group of statements, while the ``with`` statement\nallows the execution of initialization and finalization code around a\nblock of code. Function and class definitions are also syntactically\ncompound statements.\n\nCompound statements consist of one or more \'clauses.\' A clause\nconsists of a header and a \'suite.\' The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon. A suite is a group of statements controlled by a\nclause. A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines. Only the latter form of suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which ``if`` clause a following ``else`` clause would belong:\n\n if test1: if test2: print(x)\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n``print()`` calls are executed:\n\n if x < y < z: print(x); print(y); print(z)\n\nSummarizing:\n\n compound_stmt ::= if_stmt\n | while_stmt\n | for_stmt\n | try_stmt\n | with_stmt\n | funcdef\n | classdef\n suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n statement ::= stmt_list NEWLINE | compound_stmt\n stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a ``NEWLINE`` possibly followed by\na ``DEDENT``. Also note that optional continuation clauses always\nbegin with a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling ``else``\' problem is solved in Python by\nrequiring nested ``if`` statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe ``if`` statement\n====================\n\nThe ``if`` statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n\n\nThe ``while`` statement\n=======================\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n\n\nThe ``for`` statement\n=====================\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n``expression_list``. The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a ``StopIteration``\nexception), the suite in the ``else`` clause, if present, is executed,\nand the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, it will not have been assigned to at all\nby the loop. Hint: the built-in function ``range()`` returns an\niterator of integers suitable to emulate the effect of Pascal\'s ``for\ni := a to b do``; e.g., ``list(range(3))`` returns the list ``[0, 1,\n2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n\n\nThe ``try`` statement\n=====================\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" target]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started. This search inspects the except\nclauses in turn until one is found that matches the exception. An\nexpression-less except clause, if present, must be last; it matches\nany exception. For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception. An object is\ncompatible with an exception if it is the class or a base class of the\nexception object or a tuple containing an item compatible with the\nexception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the ``as`` keyword in that except clause,\nif present, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using ``as target``, it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n N = None\n del N\n\nThat means that you have to assign the exception to a different name\nif you want to be able to refer to it after the except clause. The\nreason for this is that with the traceback attached to them,\nexceptions will form a reference cycle with the stack frame, keeping\nall locals in that frame alive until the next garbage collection\noccurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the ``sys`` module and can be access via\n``sys.exc_info()``. ``sys.exc_info()`` returns a 3-tuple consisting\nof: ``exc_type``, the exception class; ``exc_value``, the exception\ninstance; ``exc_traceback``, a traceback object (see section *The\nstandard type hierarchy*) identifying the point in the program where\nthe exception occurred. ``sys.exc_info()`` values are restored to\ntheir previous values (before the call) when returning from a function\nthat handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler. The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses. If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted. If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is lost. The exception information is not available to the\nprogram during execution of the ``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe ``with`` statement\n======================\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__enter__()`` method is invoked.\n\n3. If a target was included in the ``with`` statement, the return\n value from ``__enter__()`` is assigned to it.\n\n Note: The ``with`` statement guarantees that if the ``__enter__()``\n method returns without an error, then ``__exit__()`` will always\n be called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 5 below.\n\n4. The suite is executed.\n\n5. The context manager\'s ``__exit__()`` method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to ``__exit__()``. Otherwise,\n three ``None`` arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the ``__exit__()`` method was false, the exception is\n reraised. If the return value was true, the exception is\n suppressed, and execution continues with the statement following\n the ``with`` statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from ``__exit__()`` is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n ( "*" [parameter] ("," defparameter)*\n [, "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the "``*``" must also have a default value ---\nthis is a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that that same "pre-computed" value is\nused for each call. This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended. A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple. If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after "``*``" or "``*identifier``" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "``: expression``"\nfollowing the parameter name. Any parameter may have an annotation\neven those of the form ``*identifier`` or ``**identifier``. Functions\nmay have "return" annotation of the form "``-> expression``" after the\nparameter list. These annotations can be any valid Python expression\nand are evaluated when the function definition is executed.\nAnnotations may be evaluated in a different order than they appear in\nthe source code. The presence of annotations does not change the\nsemantics of a function. The annotation values are available as\nvalues of a dictionary keyed by the parameters\' names in the\n``__annotations__`` attribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda forms,\ndescribed in section *Lambdas*. Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form. The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around. Free variables used in the\nnested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [expression_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. It first evaluates the\ninheritance list, if present. Each item in the inheritance list\nshould evaluate to a class object or class type which allows\nsubclassing. The class\'s suite is then executed in a new execution\nframe (see section *Naming and binding*), using a newly created local\nnamespace and the original global namespace. (Usually, the suite\ncontains only function definitions.) When the class\'s suite finishes\nexecution, its execution frame is discarded but its local namespace is\nsaved. [4] A class object is then created using the inheritance list\nfor the base classes and the saved local namespace for the attribute\ndictionary. The class name is bound to this class object in the\noriginal local namespace.\n\nClasses can also be decorated; as with functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass variables; they are shared by instances. Instance variables can\nbe set in a method with ``self.name = value``. Both class and\ninstance variables are accessible through the notation\n"``self.name``", and an instance variable hides a class variable with\nthe same name when accessed in this way. Class variables can be used\nas defaults for instance variables, but using mutable values there can\nlead to unexpected results. Descriptors can be used to create\ninstance variables with different implementation details.\n\nSee also:\n\n **PEP 3129** - Class Decorators\n\nClass definitions, like function definitions, may be wrapped by one or\nmore *decorator* expressions. The evaluation rules for the decorator\nexpressions are the same as for functions. The result must be a class\nobject, which is then bound to the class name.\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack only if there\n is no ``finally`` clause that negates the exception.\n\n[2] Currently, control "flows off the end" except in the case of an\n exception or the execution of a ``return``, ``continue``, or\n ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n body is transformed into the function\'s ``__doc__`` attribute and\n therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s ``__doc__`` item and\n therefore the class\'s *docstring*.\n',
+ 'calls': '\nCalls\n*****\n\nA call calls a callable object (e.g., a function) with a possibly\nempty series of arguments:\n\n call ::= primary "(" [argument_list [","] | comprehension] ")"\n argument_list ::= positional_arguments ["," keyword_arguments]\n ["," "*" expression] ["," keyword_arguments]\n ["," "**" expression]\n | keyword_arguments ["," "*" expression]\n ["," keyword_arguments] ["," "**" expression]\n | "*" expression ["," keyword_arguments] ["," "**" expression]\n | "**" expression\n positional_arguments ::= expression ("," expression)*\n keyword_arguments ::= keyword_item ("," keyword_item)*\n keyword_item ::= identifier "=" expression\n\nA trailing comma may be present after the positional and keyword\narguments but does not affect the semantics.\n\nThe primary must evaluate to a callable object (user-defined\nfunctions, built-in functions, methods of built-in objects, class\nobjects, methods of class instances, and all objects having a\n``__call__()`` method are callable). All argument expressions are\nevaluated before the call is attempted. Please refer to section\n*Function definitions* for the syntax of formal parameter lists.\n\nIf keyword arguments are present, they are first converted to\npositional arguments, as follows. First, a list of unfilled slots is\ncreated for the formal parameters. If there are N positional\narguments, they are placed in the first N slots. Next, for each\nkeyword argument, the identifier is used to determine the\ncorresponding slot (if the identifier is the same as the first formal\nparameter name, the first slot is used, and so on). If the slot is\nalready filled, a ``TypeError`` exception is raised. Otherwise, the\nvalue of the argument is placed in the slot, filling it (even if the\nexpression is ``None``, it fills the slot). When all arguments have\nbeen processed, the slots that are still unfilled are filled with the\ncorresponding default value from the function definition. (Default\nvalues are calculated, once, when the function is defined; thus, a\nmutable object such as a list or dictionary used as default value will\nbe shared by all calls that don\'t specify an argument value for the\ncorresponding slot; this should usually be avoided.) If there are any\nunfilled slots for which no default value is specified, a\n``TypeError`` exception is raised. Otherwise, the list of filled\nslots is used as the argument list for the call.\n\n**CPython implementation detail:** An implementation may provide\nbuilt-in functions whose positional parameters do not have names, even\nif they are \'named\' for the purpose of documentation, and which\ntherefore cannot be supplied by keyword. In CPython, this is the case\nfor functions implemented in C that use ``PyArg_ParseTuple()`` to\nparse their arguments.\n\nIf there are more positional arguments than there are formal parameter\nslots, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``*identifier`` is present; in this case, that formal\nparameter receives a tuple containing the excess positional arguments\n(or an empty tuple if there were no excess positional arguments).\n\nIf any keyword argument does not correspond to a formal parameter\nname, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``**identifier`` is present; in this case, that\nformal parameter receives a dictionary containing the excess keyword\narguments (using the keywords as keys and the argument values as\ncorresponding values), or a (new) empty dictionary if there were no\nexcess keyword arguments.\n\nIf the syntax ``*expression`` appears in the function call,\n``expression`` must evaluate to a sequence. Elements from this\nsequence are treated as if they were additional positional arguments;\nif there are positional arguments *x1*,..., *xN*, and ``expression``\nevaluates to a sequence *y1*, ..., *yM*, this is equivalent to a call\nwith M+N positional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.\n\nA consequence of this is that although the ``*expression`` syntax may\nappear *after* some keyword arguments, it is processed *before* the\nkeyword arguments (and the ``**expression`` argument, if any -- see\nbelow). So:\n\n >>> def f(a, b):\n ... print(a, b)\n ...\n >>> f(b=1, *(2,))\n 2 1\n >>> f(a=1, *(2,))\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n TypeError: f() got multiple values for keyword argument \'a\'\n >>> f(1, *(2,))\n 1 2\n\nIt is unusual for both keyword arguments and the ``*expression``\nsyntax to be used in the same call, so in practice this confusion does\nnot arise.\n\nIf the syntax ``**expression`` appears in the function call,\n``expression`` must evaluate to a mapping, the contents of which are\ntreated as additional keyword arguments. In the case of a keyword\nappearing in both ``expression`` and as an explicit keyword argument,\na ``TypeError`` exception is raised.\n\nFormal parameters using the syntax ``*identifier`` or ``**identifier``\ncannot be used as positional argument slots or as keyword argument\nnames.\n\nA call always returns some value, possibly ``None``, unless it raises\nan exception. How this value is computed depends on the type of the\ncallable object.\n\nIf it is---\n\na user-defined function:\n The code block for the function is executed, passing it the\n argument list. The first thing the code block will do is bind the\n formal parameters to the arguments; this is described in section\n *Function definitions*. When the code block executes a ``return``\n statement, this specifies the return value of the function call.\n\na built-in function or method:\n The result is up to the interpreter; see *Built-in Functions* for\n the descriptions of built-in functions and methods.\n\na class object:\n A new instance of that class is returned.\n\na class instance method:\n The corresponding user-defined function is called, with an argument\n list that is one longer than the argument list of the call: the\n instance becomes the first argument.\n\na class instance:\n The class must define a ``__call__()`` method; the effect is then\n the same as if that method was called.\n',
+ 'class': '\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [argument_list [","] | comprehension] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class ``object``; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with ``self.name = value``. Both class and\ninstance attributes are accessible through the notation\n"``self.name``", and an instance attribute hides a class attribute\nwith the same name when accessed in this way. Class attributes can be\nused as defaults for instance attributes, but using mutable values\nthere can lead to unexpected results. *Descriptors* can be used to\ncreate instance variables with different implementation details.\n\nSee also:\n\n **PEP 3116** - Metaclasses in Python 3 **PEP 3129** - Class\n Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack only if there\n is no ``finally`` clause that negates the exception.\n\n[2] Currently, control "flows off the end" except in the case of an\n exception or the execution of a ``return``, ``continue``, or\n ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n body is transformed into the function\'s ``__doc__`` attribute and\n therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s ``__doc__`` item and\n therefore the class\'s *docstring*.\n',
+ 'comparisons': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects. The objects need not have the same type.\nIf both are numbers, they are converted to a common type. Otherwise,\nthe ``==`` and ``!=`` operators *always* consider objects of different\ntypes to be unequal, while the ``<``, ``>``, ``>=`` and ``<=``\noperators raise a ``TypeError`` when comparing objects of different\ntypes that do not implement these operators for the given pair of\ntypes. You can control comparison behavior of objects of non-built-in\ntypes by defining rich comparison methods like ``__gt__()``, described\nin section *Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values ``float(\'NaN\')`` and ``Decimal(\'NaN\')`` are special. The\n are identical to themselves, ``x is x`` but are not equal to\n themselves, ``x != x``. Additionally, comparing any value to a\n not-a-number value will return ``False``. For example, both ``3 <\n float(\'NaN\')`` and ``float(\'NaN\') < 3`` will return ``False``.\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric equivalents\n (the result of the built-in function ``ord()``) of their characters.\n [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison of\n corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, ``[1,2,x] <= [1,2,y]`` has the\n same value as ``x <= y``. If the corresponding element does not\n exist, the shorter sequence is ordered first (for example, ``[1,2] <\n [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if they have the\n same ``(key, value)`` pairs. Order comparisons ``(\'<\', \'<=\', \'>=\',\n \'>\')`` raise ``TypeError``.\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, ``min()``, ``max()``, and ``sorted()`` produce\n undefined results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they are\n the same object; the choice whether one object is considered smaller\n or larger than another one is made arbitrarily but consistently\n within one execution of a program.\n\nComparison of objects of the differing types depends on whether either\nof the types provide explicit support for the comparison. Most\nnumeric types can be compared with one another, but comparisons of\n``float`` and ``Decimal`` are not supported to avoid the inevitable\nconfusion arising from representation issues such as ``float(\'1.1\')``\nbeing inexactly represented and therefore not exactly equal to\n``Decimal(\'1.1\')`` which is. When cross-type comparison is not\nsupported, the comparison method returns ``NotImplemented``. This can\ncreate the illusion of non-transitivity between supported cross-type\ncomparisons and unsupported comparisons. For example, ``Decimal(2) ==\n2`` and ``2 == float(2)`` but ``Decimal(2) != float(2)``.\n\nThe operators ``in`` and ``not in`` test for membership. ``x in s``\nevaluates to true if *x* is a member of *s*, and false otherwise. ``x\nnot in s`` returns the negation of ``x in s``. All built-in sequences\nand set types support this as well as dictionary, for which ``in``\ntests whether a the dictionary has a given key. For container types\nsuch as list, tuple, set, frozenset, dict, or collections.deque, the\nexpression ``x in y`` is equivalent to ``any(x is e or x == e for e in\ny)``.\n\nFor the string and bytes types, ``x in y`` is true if and only if *x*\nis a substring of *y*. An equivalent test is ``y.find(x) != -1``.\nEmpty strings are always considered to be a substring of any other\nstring, so ``"" in "abc"`` will return ``True``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` but do\ndefine ``__iter__()``, ``x in y`` is true if some value ``z`` with ``x\n== z`` is produced while iterating over ``y``. If an exception is\nraised during the iteration, it is as if ``in`` raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n``__getitem__()``, ``x in y`` is true if and only if there is a non-\nnegative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception. (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object. ``x is\nnot y`` yields the inverse truth value. [4]\n',
+ 'compound': '\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way. In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe ``if``, ``while`` and ``for`` statements implement traditional\ncontrol flow constructs. ``try`` specifies exception handlers and/or\ncleanup code for a group of statements, while the ``with`` statement\nallows the execution of initialization and finalization code around a\nblock of code. Function and class definitions are also syntactically\ncompound statements.\n\nCompound statements consist of one or more \'clauses.\' A clause\nconsists of a header and a \'suite.\' The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon. A suite is a group of statements controlled by a\nclause. A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines. Only the latter form of suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which ``if`` clause a following ``else`` clause would belong:\n\n if test1: if test2: print(x)\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n``print()`` calls are executed:\n\n if x < y < z: print(x); print(y); print(z)\n\nSummarizing:\n\n compound_stmt ::= if_stmt\n | while_stmt\n | for_stmt\n | try_stmt\n | with_stmt\n | funcdef\n | classdef\n suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n statement ::= stmt_list NEWLINE | compound_stmt\n stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a ``NEWLINE`` possibly followed by\na ``DEDENT``. Also note that optional continuation clauses always\nbegin with a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling ``else``\' problem is solved in Python by\nrequiring nested ``if`` statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe ``if`` statement\n====================\n\nThe ``if`` statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n\n\nThe ``while`` statement\n=======================\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n\n\nThe ``for`` statement\n=====================\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n``expression_list``. The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a ``StopIteration``\nexception), the suite in the ``else`` clause, if present, is executed,\nand the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, it will not have been assigned to at all\nby the loop. Hint: the built-in function ``range()`` returns an\niterator of integers suitable to emulate the effect of Pascal\'s ``for\ni := a to b do``; e.g., ``list(range(3))`` returns the list ``[0, 1,\n2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n\n\nThe ``try`` statement\n=====================\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" target]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started. This search inspects the except\nclauses in turn until one is found that matches the exception. An\nexpression-less except clause, if present, must be last; it matches\nany exception. For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception. An object is\ncompatible with an exception if it is the class or a base class of the\nexception object or a tuple containing an item compatible with the\nexception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the ``as`` keyword in that except clause,\nif present, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using ``as target``, it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the ``sys`` module and can be access via\n``sys.exc_info()``. ``sys.exc_info()`` returns a 3-tuple consisting of\nthe exception class, the exception instance and a traceback object\n(see section *The standard type hierarchy*) identifying the point in\nthe program where the exception occurred. ``sys.exc_info()`` values\nare restored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler. The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses. If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted. If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is lost. The exception information is not available to the\nprogram during execution of the ``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe ``with`` statement\n======================\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the ``with_item``)\n is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__exit__()`` is loaded for later use.\n\n3. The context manager\'s ``__enter__()`` method is invoked.\n\n4. If a target was included in the ``with`` statement, the return\n value from ``__enter__()`` is assigned to it.\n\n Note: The ``with`` statement guarantees that if the ``__enter__()``\n method returns without an error, then ``__exit__()`` will always\n be called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s ``__exit__()`` method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to ``__exit__()``. Otherwise,\n three ``None`` arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the ``__exit__()`` method was false, the exception is\n reraised. If the return value was true, the exception is\n suppressed, and execution continues with the statement following\n the ``with`` statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from ``__exit__()`` is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n ( "*" [parameter] ("," defparameter)*\n [, "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the "``*``" must also have a default value ---\nthis is a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that that same "pre-computed" value is\nused for each call. This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended. A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple. If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after "``*``" or "``*identifier``" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "``: expression``"\nfollowing the parameter name. Any parameter may have an annotation\neven those of the form ``*identifier`` or ``**identifier``. Functions\nmay have "return" annotation of the form "``-> expression``" after the\nparameter list. These annotations can be any valid Python expression\nand are evaluated when the function definition is executed.\nAnnotations may be evaluated in a different order than they appear in\nthe source code. The presence of annotations does not change the\nsemantics of a function. The annotation values are available as\nvalues of a dictionary keyed by the parameters\' names in the\n``__annotations__`` attribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda forms,\ndescribed in section *Lambdas*. Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form. The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around. Free variables used in the\nnested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [argument_list [","] | comprehension] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class ``object``; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with ``self.name = value``. Both class and\ninstance attributes are accessible through the notation\n"``self.name``", and an instance attribute hides a class attribute\nwith the same name when accessed in this way. Class attributes can be\nused as defaults for instance attributes, but using mutable values\nthere can lead to unexpected results. *Descriptors* can be used to\ncreate instance variables with different implementation details.\n\nSee also:\n\n **PEP 3116** - Metaclasses in Python 3 **PEP 3129** - Class\n Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack only if there\n is no ``finally`` clause that negates the exception.\n\n[2] Currently, control "flows off the end" except in the case of an\n exception or the execution of a ``return``, ``continue``, or\n ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n body is transformed into the function\'s ``__doc__`` attribute and\n therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s ``__doc__`` item and\n therefore the class\'s *docstring*.\n',
'context-managers': '\nWith Statement Context Managers\n*******************************\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code. Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The ``with``\n statement will bind this method\'s return value to the target(s)\n specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be ``None``.\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that ``__exit__()`` methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n',
'continue': '\nThe ``continue`` statement\n**************************\n\n continue_stmt ::= "continue"\n\n``continue`` may only occur syntactically nested in a ``for`` or\n``while`` loop, but not nested in a function or class definition or\n``finally`` clause within that loop. It continues with the next cycle\nof the nearest enclosing loop.\n\nWhen ``continue`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nstarting the next loop cycle.\n',
'conversions': '\nArithmetic conversions\n**********************\n\nWhen a description of an arithmetic operator below uses the phrase\n"the numeric arguments are converted to a common type," this means\nthat the operator implementation for built-in types works that way:\n\n* If either argument is a complex number, the other is converted to\n complex;\n\n* otherwise, if either argument is a floating point number, the other\n is converted to floating point;\n\n* otherwise, both must be integers and no conversion is necessary.\n\nSome additional rules apply for certain operators (e.g., a string left\nargument to the \'%\' operator). Extensions must define their own\nconversion behavior.\n',
- 'customization': '\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. ``__new__()`` is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of ``__new__()`` should be the new object instance (usually\n an instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s ``__new__()`` method using\n ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If ``__new__()`` returns an instance of *cls*, then the new\n instance\'s ``__init__()`` method will be invoked like\n ``__init__(self[, ...])``, where *self* is the new instance and the\n remaining arguments are the same as were passed to ``__new__()``.\n\n If ``__new__()`` does not return an instance of *cls*, then the new\n instance\'s ``__init__()`` method will not be invoked.\n\n ``__new__()`` is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called when the instance is created. The arguments are those\n passed to the class constructor expression. If a base class has an\n ``__init__()`` method, the derived class\'s ``__init__()`` method,\n if any, must explicitly call it to ensure proper initialization of\n the base class part of the instance; for example:\n ``BaseClass.__init__(self, [args...])``. As a special constraint\n on constructors, no value may be returned; doing so will cause a\n ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a ``__del__()`` method,\n the derived class\'s ``__del__()`` method, if any, must explicitly\n call it to ensure proper deletion of the base class part of the\n instance. Note that it is possible (though not recommended!) for\n the ``__del__()`` method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n ``__del__()`` methods are called for objects that still exist when\n the interpreter exits.\n\n Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n decrements the reference count for ``x`` by one, and the latter\n is only called when ``x``\'s reference count reaches zero. Some\n common situations that may prevent the reference count of an\n object from going to zero include: circular references between\n objects (e.g., a doubly-linked list or a tree data structure with\n parent and child pointers); a reference to the object on the\n stack frame of a function that caught an exception (the traceback\n stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n a reference to the object on the stack frame that raised an\n unhandled exception in interactive mode (the traceback stored in\n ``sys.last_traceback`` keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the latter two situations can be resolved by storing ``None`` in\n ``sys.last_traceback``. Circular references which are garbage are\n detected when the option cycle detector is enabled (it\'s on by\n default), but can only be cleaned up if there are no Python-\n level ``__del__()`` methods involved. Refer to the documentation\n for the ``gc`` module for more information about how\n ``__del__()`` methods are handled by the cycle detector,\n particularly the description of the ``garbage`` value.\n\n Warning: Due to the precarious circumstances under which ``__del__()``\n methods are invoked, exceptions that occur during their execution\n are ignored, and a warning is printed to ``sys.stderr`` instead.\n Also, when ``__del__()`` is invoked in response to a module being\n deleted (e.g., when execution of the program is done), other\n globals referenced by the ``__del__()`` method may already have\n been deleted or in the process of being torn down (e.g. the\n import machinery shutting down). For this reason, ``__del__()``\n methods should do the absolute minimum needed to maintain\n external invariants. Starting with version 1.5, Python\n guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n Called by the ``repr()`` built-in function to compute the\n "official" string representation of an object. If at all possible,\n this should look like a valid Python expression that could be used\n to recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n ``<...some useful description...>`` should be returned. The return\n value must be a string object. If a class defines ``__repr__()``\n but not ``__str__()``, then ``__repr__()`` is also used when an\n "informal" string representation of instances of that class is\n required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by the ``str()`` built-in function and by the ``print()``\n function to compute the "informal" string representation of an\n object. This differs from ``__repr__()`` in that it does not have\n to be a valid Python expression: a more convenient or concise\n representation may be used instead. The return value must be a\n string object.\n\nobject.__format__(self, format_spec)\n\n Called by the ``format()`` built-in function (and by extension, the\n ``format()`` method of class ``str``) to produce a "formatted"\n string representation of an object. The ``format_spec`` argument is\n a string that contains a description of the formatting options\n desired. The interpretation of the ``format_spec`` argument is up\n to the type implementing ``__format__()``, however most classes\n will either delegate formatting to one of the built-in types, or\n use a similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n ``x.__ge__(y)``.\n\n A rich comparison method may return the singleton\n ``NotImplemented`` if it does not implement the operation for a\n given pair of arguments. By convention, ``False`` and ``True`` are\n returned for a successful comparison. However, these methods can\n return any value, so if the comparison operator is used in a\n Boolean context (e.g., in the condition of an ``if`` statement),\n Python will call ``bool()`` on the value to determine if the result\n is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of ``x==y`` does not imply that ``x!=y`` is false.\n Accordingly, when defining ``__eq__()``, one should also define\n ``__ne__()`` so that the operators will behave as expected. See\n the paragraph on ``__hash__()`` for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n reflection, and ``__eq__()`` and ``__ne__()`` are their own\n reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see the Total Ordering recipe in the ASPN cookbook.\n\nobject.__hash__(self)\n\n Called by built-in function ``hash()`` and for operations on\n members of hashed collections including ``set``, ``frozenset``, and\n ``dict``. ``__hash__()`` should return an integer. The only\n required property is that objects which compare equal have the same\n hash value; it is advised to somehow mix together (e.g. using\n exclusive or) the hash values for the components of the object that\n also play a part in comparison of objects.\n\n If a class does not define an ``__eq__()`` method it should not\n define a ``__hash__()`` operation either; if it defines\n ``__eq__()`` but not ``__hash__()``, its instances will not be\n usable as items in hashable collections. If a class defines\n mutable objects and implements an ``__eq__()`` method, it should\n not implement ``__hash__()``, since the implementation of hashable\n collections requires that a key\'s hash value is immutable (if the\n object\'s hash value changes, it will be in the wrong hash bucket).\n\n User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n by default; with them, all objects compare unequal (except with\n themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n Classes which inherit a ``__hash__()`` method from a parent class\n but change the meaning of ``__eq__()`` such that the hash value\n returned is no longer appropriate (e.g. by switching to a value-\n based concept of equality instead of the default identity based\n equality) can explicitly flag themselves as being unhashable by\n setting ``__hash__ = None`` in the class definition. Doing so means\n that not only will instances of the class raise an appropriate\n ``TypeError`` when a program attempts to retrieve their hash value,\n but they will also be correctly identified as unhashable when\n checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n which define their own ``__hash__()`` to explicitly raise\n ``TypeError``).\n\n If a class that overrides ``__eq__()`` needs to retain the\n implementation of ``__hash__()`` from a parent class, the\n interpreter must be told this explicitly by setting ``__hash__ =\n <ParentClass>.__hash__``. Otherwise the inheritance of\n ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n explicitly set to ``None``.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n ``bool()``; should return ``False`` or ``True``, or their integer\n equivalents ``0`` or ``1``. When this method is not defined,\n ``__len__()`` is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither ``__len__()`` nor ``__bool__()``, all its instances are\n considered true.\n',
- 'debugger': '\n``pdb`` --- The Python Debugger\n*******************************\n\nThe module ``pdb`` defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible --- it is actually defined as the class\n``Pdb``. This is currently undocumented but easily understood by\nreading the source. The extension interface uses the modules ``bdb``\n(undocumented) and ``cmd``.\n\nThe debugger\'s prompt is ``(Pdb)``. Typical usage to run a program\nunder control of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > <string>(0)?()\n (Pdb) continue\n > <string>(1)?()\n (Pdb) continue\n NameError: \'spam\'\n > <string>(1)?()\n (Pdb)\n\n``pdb.py`` can also be invoked as a script to debug other scripts.\nFor example:\n\n python -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout debugger using the ``c`` command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print(spam)\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print(spam)\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement[, globals[, locals]])\n\n Execute the *statement* (given as a string) under debugger control.\n The debugger prompt appears before any code is executed; you can\n set breakpoints and type ``continue``, or you can step through the\n statement using ``step`` or ``next`` (all these commands are\n explained below). The optional *globals* and *locals* arguments\n specify the environment in which the code is executed; by default\n the dictionary of the module ``__main__`` is used. (See the\n explanation of the built-in ``exec()`` or ``eval()`` functions.)\n\npdb.runeval(expression[, globals[, locals]])\n\n Evaluate the *expression* (given as a string) under debugger\n control. When ``runeval()`` returns, it returns the value of the\n expression. Otherwise this function is similar to ``run()``.\n\npdb.runcall(function[, argument, ...])\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When ``runcall()`` returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem([traceback])\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n ``sys.last_traceback``.\n\nThe ``run_*`` functions and ``set_trace()`` are aliases for\ninstantiating the ``Pdb`` class and calling the method of the same\nname. If you want to access further features, you have to do this\nyourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None)\n\n ``Pdb`` is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying ``cmd.Cmd`` class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 3.1: The *skip* argument.\n\n run(statement[, globals[, locals]])\n runeval(expression[, globals[, locals]])\n runcall(function[, argument, ...])\n set_trace()\n\n See the documentation for the functions explained above.\n',
- 'del': '\nThe ``del`` statement\n*********************\n\n del_stmt ::= "del" target_list\n\nDeletion is recursively defined very similar to the way assignment is\ndefined. Rather that spelling it out in full details, here are some\nhints.\n\nDeletion of a target list recursively deletes each target, from left\nto right.\n\nDeletion of a name removes the binding of that name from the local or\nglobal namespace, depending on whether the name occurs in a ``global``\nstatement in the same code block. If the name is unbound, a\n``NameError`` exception will be raised.\n\nIt is illegal to delete a name from the local namespace if it occurs\nas a free variable in a nested block.\n\nDeletion of attribute references, subscriptions and slicings is passed\nto the primary object involved; deletion of a slicing is in general\nequivalent to assignment of an empty slice of the right type (but even\nthis is determined by the sliced object).\n',
+ 'customization': '\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. ``__new__()`` is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of ``__new__()`` should be the new object instance (usually\n an instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s ``__new__()`` method using\n ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If ``__new__()`` returns an instance of *cls*, then the new\n instance\'s ``__init__()`` method will be invoked like\n ``__init__(self[, ...])``, where *self* is the new instance and the\n remaining arguments are the same as were passed to ``__new__()``.\n\n If ``__new__()`` does not return an instance of *cls*, then the new\n instance\'s ``__init__()`` method will not be invoked.\n\n ``__new__()`` is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called when the instance is created. The arguments are those\n passed to the class constructor expression. If a base class has an\n ``__init__()`` method, the derived class\'s ``__init__()`` method,\n if any, must explicitly call it to ensure proper initialization of\n the base class part of the instance; for example:\n ``BaseClass.__init__(self, [args...])``. As a special constraint\n on constructors, no value may be returned; doing so will cause a\n ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a ``__del__()`` method,\n the derived class\'s ``__del__()`` method, if any, must explicitly\n call it to ensure proper deletion of the base class part of the\n instance. Note that it is possible (though not recommended!) for\n the ``__del__()`` method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n ``__del__()`` methods are called for objects that still exist when\n the interpreter exits.\n\n Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n decrements the reference count for ``x`` by one, and the latter\n is only called when ``x``\'s reference count reaches zero. Some\n common situations that may prevent the reference count of an\n object from going to zero include: circular references between\n objects (e.g., a doubly-linked list or a tree data structure with\n parent and child pointers); a reference to the object on the\n stack frame of a function that caught an exception (the traceback\n stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n a reference to the object on the stack frame that raised an\n unhandled exception in interactive mode (the traceback stored in\n ``sys.last_traceback`` keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the latter two situations can be resolved by storing ``None`` in\n ``sys.last_traceback``. Circular references which are garbage are\n detected when the option cycle detector is enabled (it\'s on by\n default), but can only be cleaned up if there are no Python-\n level ``__del__()`` methods involved. Refer to the documentation\n for the ``gc`` module for more information about how\n ``__del__()`` methods are handled by the cycle detector,\n particularly the description of the ``garbage`` value.\n\n Warning: Due to the precarious circumstances under which ``__del__()``\n methods are invoked, exceptions that occur during their execution\n are ignored, and a warning is printed to ``sys.stderr`` instead.\n Also, when ``__del__()`` is invoked in response to a module being\n deleted (e.g., when execution of the program is done), other\n globals referenced by the ``__del__()`` method may already have\n been deleted or in the process of being torn down (e.g. the\n import machinery shutting down). For this reason, ``__del__()``\n methods should do the absolute minimum needed to maintain\n external invariants. Starting with version 1.5, Python\n guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n Called by the ``repr()`` built-in function to compute the\n "official" string representation of an object. If at all possible,\n this should look like a valid Python expression that could be used\n to recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n ``<...some useful description...>`` should be returned. The return\n value must be a string object. If a class defines ``__repr__()``\n but not ``__str__()``, then ``__repr__()`` is also used when an\n "informal" string representation of instances of that class is\n required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by the ``str()`` built-in function and by the ``print()``\n function to compute the "informal" string representation of an\n object. This differs from ``__repr__()`` in that it does not have\n to be a valid Python expression: a more convenient or concise\n representation may be used instead. The return value must be a\n string object.\n\nobject.__format__(self, format_spec)\n\n Called by the ``format()`` built-in function (and by extension, the\n ``format()`` method of class ``str``) to produce a "formatted"\n string representation of an object. The ``format_spec`` argument is\n a string that contains a description of the formatting options\n desired. The interpretation of the ``format_spec`` argument is up\n to the type implementing ``__format__()``, however most classes\n will either delegate formatting to one of the built-in types, or\n use a similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n ``x.__ge__(y)``.\n\n A rich comparison method may return the singleton\n ``NotImplemented`` if it does not implement the operation for a\n given pair of arguments. By convention, ``False`` and ``True`` are\n returned for a successful comparison. However, these methods can\n return any value, so if the comparison operator is used in a\n Boolean context (e.g., in the condition of an ``if`` statement),\n Python will call ``bool()`` on the value to determine if the result\n is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of ``x==y`` does not imply that ``x!=y`` is false.\n Accordingly, when defining ``__eq__()``, one should also define\n ``__ne__()`` so that the operators will behave as expected. See\n the paragraph on ``__hash__()`` for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n reflection, and ``__eq__()`` and ``__ne__()`` are their own\n reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see ``functools.total_ordering()``.\n\nobject.__hash__(self)\n\n Called by built-in function ``hash()`` and for operations on\n members of hashed collections including ``set``, ``frozenset``, and\n ``dict``. ``__hash__()`` should return an integer. The only\n required property is that objects which compare equal have the same\n hash value; it is advised to somehow mix together (e.g. using\n exclusive or) the hash values for the components of the object that\n also play a part in comparison of objects.\n\n If a class does not define an ``__eq__()`` method it should not\n define a ``__hash__()`` operation either; if it defines\n ``__eq__()`` but not ``__hash__()``, its instances will not be\n usable as items in hashable collections. If a class defines\n mutable objects and implements an ``__eq__()`` method, it should\n not implement ``__hash__()``, since the implementation of hashable\n collections requires that a key\'s hash value is immutable (if the\n object\'s hash value changes, it will be in the wrong hash bucket).\n\n User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n by default; with them, all objects compare unequal (except with\n themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n Classes which inherit a ``__hash__()`` method from a parent class\n but change the meaning of ``__eq__()`` such that the hash value\n returned is no longer appropriate (e.g. by switching to a value-\n based concept of equality instead of the default identity based\n equality) can explicitly flag themselves as being unhashable by\n setting ``__hash__ = None`` in the class definition. Doing so means\n that not only will instances of the class raise an appropriate\n ``TypeError`` when a program attempts to retrieve their hash value,\n but they will also be correctly identified as unhashable when\n checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n which define their own ``__hash__()`` to explicitly raise\n ``TypeError``).\n\n If a class that overrides ``__eq__()`` needs to retain the\n implementation of ``__hash__()`` from a parent class, the\n interpreter must be told this explicitly by setting ``__hash__ =\n <ParentClass>.__hash__``. Otherwise the inheritance of\n ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n explicitly set to ``None``.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n ``bool()``; should return ``False`` or ``True``. When this method\n is not defined, ``__len__()`` is called, if it is defined, and the\n object is considered true if its result is nonzero. If a class\n defines neither ``__len__()`` nor ``__bool__()``, all its instances\n are considered true.\n',
+ 'debugger': '\n``pdb`` --- The Python Debugger\n*******************************\n\nThe module ``pdb`` defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n``Pdb``. This is currently undocumented but easily understood by\nreading the source. The extension interface uses the modules ``bdb``\nand ``cmd``.\n\nThe debugger\'s prompt is ``(Pdb)``. Typical usage to run a program\nunder control of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > <string>(0)?()\n (Pdb) continue\n > <string>(1)?()\n (Pdb) continue\n NameError: \'spam\'\n > <string>(1)?()\n (Pdb)\n\n``pdb.py`` can also be invoked as a script to debug other scripts.\nFor example:\n\n python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: ``pdb.py`` now accepts a ``-c`` option that\nexecutes commands as if given in a ``.pdbrc`` file, see *Debugger\nCommands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the ``continue`` command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print(spam)\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print(spam)\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n Execute the *statement* (given as a string or a code object) under\n debugger control. The debugger prompt appears before any code is\n executed; you can set breakpoints and type ``continue``, or you can\n step through the statement using ``step`` or ``next`` (all these\n commands are explained below). The optional *globals* and *locals*\n arguments specify the environment in which the code is executed; by\n default the dictionary of the module ``__main__`` is used. (See\n the explanation of the built-in ``exec()`` or ``eval()``\n functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n Evaluate the *expression* (given as a string or a code object)\n under debugger control. When ``runeval()`` returns, it returns the\n value of the expression. Otherwise this function is similar to\n ``run()``.\n\npdb.runcall(function, *args, **kwds)\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When ``runcall()`` returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem(traceback=None)\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n ``sys.last_traceback``.\n\nThe ``run*`` functions and ``set_trace()`` are aliases for\ninstantiating the ``Pdb`` class and calling the method of the same\nname. If you want to access further features, you have to do this\nyourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None, nosigint=False)\n\n ``Pdb`` is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying ``cmd.Cmd`` class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n By default, Pdb sets a handler for the SIGINT signal (which is sent\n when the user presses Ctrl-C on the console) when you give a\n ``continue`` command. This allows you to break into the debugger\n again by pressing Ctrl-C. If you want Pdb not to touch the SIGINT\n handler, set *nosigint* tot true.\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 3.1: The *skip* argument.\n\n New in version 3.2: The *nosigint* argument. Previously, a SIGINT\n handler was never set by Pdb.\n\n run(statement, globals=None, locals=None)\n runeval(expression, globals=None, locals=None)\n runcall(function, *args, **kwds)\n set_trace()\n\n See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below. Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n``h(elp)`` means that either ``h`` or ``help`` can be used to enter\nthe help command (but not ``he`` or ``hel``, nor ``H`` or ``Help`` or\n``HELP``). Arguments to commands must be separated by whitespace\n(spaces or tabs). Optional arguments are enclosed in square brackets\n(``[]``) in the command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n(``|``).\n\nEntering a blank line repeats the last command entered. Exception: if\nthe last command was a ``list`` command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged. Python statements can also be prefixed with an exclamation\npoint (``!``). This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*. Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by\n``;;``. (A single ``;`` is not used as it is the separator for\nmultiple commands in a line that is passed to the Python parser.) No\nintelligence is applied to separating the commands; the input is split\nat the first ``;;`` pair, even if it is in the middle of a quoted\nstring.\n\nIf a file ``.pdbrc`` exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt. This is particularly useful for aliases. If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ``.pdbrc`` can now contain commands that\ncontinue debugging, such as ``continue`` or ``next``. Previously,\nthese commands had no effect.\n\nh(elp) [command]\n\n Without argument, print the list of available commands. With a\n *command* as argument, print help about that command. ``help pdb``\n displays the full documentation (the docstring of the ``pdb``\n module). Since the *command* argument must be an identifier,\n ``help exec`` must be entered to get help on the ``!`` command.\n\nw(here)\n\n Print a stack trace, with the most recent frame at the bottom. An\n arrow indicates the current frame, which determines the context of\n most commands.\n\nd(own) [count]\n\n Move the current frame *count* (default one) levels down in the\n stack trace (to a newer frame).\n\nu(p) [count]\n\n Move the current frame *count* (default one) levels up in the stack\n trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n With a *lineno* argument, set a break there in the current file.\n With a *function* argument, set a break at the first executable\n statement within that function. The line number may be prefixed\n with a filename and a colon, to specify a breakpoint in another\n file (probably one that hasn\'t been loaded yet). The file is\n searched on ``sys.path``. Note that each breakpoint is assigned a\n number to which all the other breakpoint commands refer.\n\n If a second argument is present, it is an expression which must\n evaluate to true before the breakpoint is honored.\n\n Without argument, list all breaks, including for each breakpoint,\n the number of times that breakpoint has been hit, the current\n ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n Temporary breakpoint, which is removed automatically when it is\n first hit. The arguments are the same as for ``break``.\n\ncl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n\n With a *filename:lineno* argument, clear all the breakpoints at\n this line. With a space separated list of breakpoint numbers, clear\n those breakpoints. Without argument, clear all breaks (but first\n ask confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n Disable the breakpoints given as a space separated list of\n breakpoint numbers. Disabling a breakpoint means it cannot cause\n the program to stop execution, but unlike clearing a breakpoint, it\n remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n Set the ignore count for the given breakpoint number. If count is\n omitted, the ignore count is set to 0. A breakpoint becomes active\n when the ignore count is zero. When non-zero, the count is\n decremented each time the breakpoint is reached and the breakpoint\n is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n Set a new *condition* for the breakpoint, an expression which must\n evaluate to true before the breakpoint is honored. If *condition*\n is absent, any existing condition is removed; i.e., the breakpoint\n is made unconditional.\n\ncommands [bpnumber]\n\n Specify a list of commands for breakpoint number *bpnumber*. The\n commands themselves appear on the following lines. Type a line\n containing just ``end`` to terminate the commands. An example:\n\n (Pdb) commands 1\n (com) print some_variable\n (com) end\n (Pdb)\n\n To remove all commands from a breakpoint, type commands and follow\n it immediately with ``end``; that is, give no commands.\n\n With no *bpnumber* argument, commands refers to the last breakpoint\n set.\n\n You can use breakpoint commands to start your program up again.\n Simply use the continue command, or step, or any other command that\n resumes execution.\n\n Specifying any command resuming execution (currently continue,\n step, next, return, jump, quit and their abbreviations) terminates\n the command list (as if that command was immediately followed by\n end). This is because any time you resume execution (even with a\n simple next or step), you may encounter another breakpoint--which\n could have its own command list, leading to ambiguities about which\n list to execute.\n\n If you use the \'silent\' command in the command list, the usual\n message about stopping at a breakpoint is not printed. This may be\n desirable for breakpoints that are to print a specific message and\n then continue. If none of the other commands print anything, you\n see no sign that the breakpoint was reached.\n\ns(tep)\n\n Execute the current line, stop at the first possible occasion\n (either in a function that is called or on the next line in the\n current function).\n\nn(ext)\n\n Continue execution until the next line in the current function is\n reached or it returns. (The difference between ``next`` and\n ``step`` is that ``step`` stops inside a called function, while\n ``next`` executes called functions at (nearly) full speed, only\n stopping at the next line in the current function.)\n\nunt(il) [lineno]\n\n Without argument, continue execution until the line with a number\n greater than the current one is reached.\n\n With a line number, continue execution until a line with a number\n greater or equal to that is reached. In both cases, also stop when\n the current frame returns.\n\n Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n Continue execution until the current function returns.\n\nc(ont(inue))\n\n Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n Set the next line that will be executed. Only available in the\n bottom-most frame. This lets you jump back and execute code again,\n or jump forward to skip code that you don\'t want to run.\n\n It should be noted that not all jumps are allowed -- for instance\n it is not possible to jump into the middle of a ``for`` loop or out\n of a ``finally`` clause.\n\nl(ist) [first[, last]]\n\n List source code for the current file. Without arguments, list 11\n lines around the current line or continue the previous listing.\n With ``.`` as argument, list 11 lines around the current line.\n With one argument, list 11 lines around at that line. With two\n arguments, list the given range; if the second argument is less\n than the first, it is interpreted as a count.\n\n The current line in the current frame is indicated by ``->``. If\n an exception is being debugged, the line where the exception was\n originally raised or propagated is indicated by ``>>``, if it\n differs from the current line.\n\n New in version 3.2: The ``>>`` marker.\n\nll | longlist\n\n List all source code for the current function or frame.\n Interesting lines are marked as for ``list``.\n\n New in version 3.2.\n\na(rgs)\n\n Print the argument list of the current function.\n\np(rint) expression\n\n Evaluate the *expression* in the current context and print its\n value.\n\npp expression\n\n Like the ``print`` command, except the value of the expression is\n pretty-printed using the ``pprint`` module.\n\nwhatis expression\n\n Print the type of the *expression*.\n\nsource expression\n\n Try to get source code for the given object and display it.\n\n New in version 3.2.\n\ndisplay [expression]\n\n Display the value of the expression if it changed, each time\n execution stops in the current frame.\n\n Without expression, list all display expressions for the current\n frame.\n\n New in version 3.2.\n\nundisplay [expression]\n\n Do not display the expression any more in the current frame.\n Without expression, clear all display expressions for the current\n frame.\n\n New in version 3.2.\n\ninteract\n\n Start an interative interpreter (using the ``code`` module) whose\n global namespace contains all the (global and local) names found in\n the current scope.\n\n New in version 3.2.\n\nalias [name [command]]\n\n Create an alias called *name* that executes *command*. The command\n must *not* be enclosed in quotes. Replaceable parameters can be\n indicated by ``%1``, ``%2``, and so on, while ``%*`` is replaced by\n all the parameters. If no command is given, the current alias for\n *name* is shown. If no arguments are given, all aliases are listed.\n\n Aliases may be nested and can contain anything that can be legally\n typed at the pdb prompt. Note that internal pdb commands *can* be\n overridden by aliases. Such a command is then hidden until the\n alias is removed. Aliasing is recursively applied to the first\n word of the command line; all other words in the line are left\n alone.\n\n As an example, here are two useful aliases (especially when placed\n in the ``.pdbrc`` file):\n\n # Print instance variables (usage "pi classInst")\n alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n # Print instance variables in self\n alias ps pi self\n\nunalias name\n\n Delete the specified alias.\n\n! statement\n\n Execute the (one-line) *statement* in the context of the current\n stack frame. The exclamation point can be omitted unless the first\n word of the statement resembles a debugger command. To set a\n global variable, you can prefix the assignment command with a\n ``global`` statement on the same line, e.g.:\n\n (Pdb) global list_options; list_options = [\'-l\']\n (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n Restart the debugged Python program. If an argument is supplied,\n it is split with ``shlex`` and the result is used as the new\n ``sys.argv``. History, breakpoints, actions and debugger options\n are preserved. ``restart`` is an alias for ``run``.\n\nq(uit)\n\n Quit from the debugger. The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module is\n determined by the ``__name__`` in the frame globals.\n',
+ 'del': '\nThe ``del`` statement\n*********************\n\n del_stmt ::= "del" target_list\n\nDeletion is recursively defined very similar to the way assignment is\ndefined. Rather that spelling it out in full details, here are some\nhints.\n\nDeletion of a target list recursively deletes each target, from left\nto right.\n\nDeletion of a name removes the binding of that name from the local or\nglobal namespace, depending on whether the name occurs in a ``global``\nstatement in the same code block. If the name is unbound, a\n``NameError`` exception will be raised.\n\nDeletion of attribute references, subscriptions and slicings is passed\nto the primary object involved; deletion of a slicing is in general\nequivalent to assignment of an empty slice of the right type (but even\nthis is determined by the sliced object).\n\nChanged in version 3.2.\n',
'dict': '\nDictionary displays\n*******************\n\nA dictionary display is a possibly empty series of key/datum pairs\nenclosed in curly braces:\n\n dict_display ::= "{" [key_datum_list | dict_comprehension] "}"\n key_datum_list ::= key_datum ("," key_datum)* [","]\n key_datum ::= expression ":" expression\n dict_comprehension ::= expression ":" expression comp_for\n\nA dictionary display yields a new dictionary object.\n\nIf a comma-separated sequence of key/datum pairs is given, they are\nevaluated from left to right to define the entries of the dictionary:\neach key object is used as a key into the dictionary to store the\ncorresponding datum. This means that you can specify the same key\nmultiple times in the key/datum list, and the final dictionary\'s value\nfor that key will be the last one given.\n\nA dict comprehension, in contrast to list and set comprehensions,\nneeds two expressions separated with a colon followed by the usual\n"for" and "if" clauses. When the comprehension is run, the resulting\nkey and value elements are inserted in the new dictionary in the order\nthey are produced.\n\nRestrictions on the types of the key values are listed earlier in\nsection *The standard type hierarchy*. (To summarize, the key type\nshould be *hashable*, which excludes all mutable objects.) Clashes\nbetween duplicate keys are not detected; the last datum (textually\nrightmost in the display) stored for a given key value prevails.\n',
'dynamic-features': '\nInteraction with dynamic features\n*********************************\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n',
'else': '\nThe ``if`` statement\n********************\n\nThe ``if`` statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n',
'exceptions': '\nExceptions\n**********\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the ``raise`` statement. Exception\nhandlers are specified with the ``try`` ... ``except`` statement. The\n``finally`` clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n``SystemExit``.\n\nExceptions are identified by class instances. The ``except`` clause\nis selected depending on the class of the instance: it must reference\nthe class of the instance or a base class thereof. The instance can\nbe received by the handler and can carry additional information about\nthe exceptional condition.\n\nNote: Exception messages are not part of the Python API. Their contents\n may change from one version of Python to the next without warning\n and should not be relied on by code which will run under multiple\n versions of the interpreter.\n\nSee also the description of the ``try`` statement in section *The try\nstatement* and ``raise`` statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by these\n operations is not available at the time the module is compiled.\n',
- 'execmodel': '\nExecution model\n***************\n\n\nNaming and binding\n==================\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\non the interpreter command line the first argument) is a code block.\nA script command (a command specified on the interpreter command line\nwith the \'**-c**\' option) is a code block. The string argument passed\nto the built-in functions ``eval()`` and ``exec()`` is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as ``nonlocal``. If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a ``NameError`` exception is raised.\nIf the name refers to a local variable that has not been bound, a\n``UnboundLocalError`` exception is raised. ``UnboundLocalError`` is a\nsubclass of ``NameError``.\n\nThe following constructs bind names: formal parameters to functions,\n``import`` statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, ``for`` loop header, or\nafter ``as`` in a ``with`` statement or :keyword.`except` clause. The\n``import`` statement of the form ``from ... import *`` binds all names\ndefined in the imported module, except those beginning with an\nunderscore. This form may only be used at the module level.\n\nA target occurring in a ``del`` statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name). It\nis illegal to unbind a name that is referenced by an enclosing scope;\nthe compiler will report a ``SyntaxError``.\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the ``global`` statement occurs within a block, all uses of the\nname specified in the statement refer to the binding of that name in\nthe top-level namespace. Names are resolved in the top-level\nnamespace by searching the global namespace, i.e. the namespace of the\nmodule containing the code block, and the builtin namespace, the\nnamespace of the module ``builtins``. The global namespace is\nsearched first. If the name is not found there, the builtin namespace\nis searched. The global statement must precede all uses of the name.\n\nThe built-in namespace associated with the execution of a code block\nis actually found by looking up the name ``__builtins__`` in its\nglobal namespace; this should be a dictionary or a module (in the\nlatter case the module\'s dictionary is used). By default, when in the\n``__main__`` module, ``__builtins__`` is the built-in module\n``builtins``; when in any other module, ``__builtins__`` is an alias\nfor the dictionary of the ``builtins`` module itself.\n``__builtins__`` can be set to a user-created dictionary to create a\nweak form of restricted execution.\n\nNote: Users should not touch ``__builtins__``; it is strictly an\n implementation detail. Users wanting to override values in the\n built-in namespace should ``import`` the ``builtins`` module and\n modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n``__main__``.\n\nThe global statement has the same scope as a name binding operation in\nthe same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n---------------------------------\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the ``raise`` statement. Exception\nhandlers are specified with the ``try`` ... ``except`` statement. The\n``finally`` clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n``SystemExit``.\n\nExceptions are identified by class instances. The ``except`` clause\nis selected depending on the class of the instance: it must reference\nthe class of the instance or a base class thereof. The instance can\nbe received by the handler and can carry additional information about\nthe exceptional condition.\n\nNote: Exception messages are not part of the Python API. Their contents\n may change from one version of Python to the next without warning\n and should not be relied on by code which will run under multiple\n versions of the interpreter.\n\nSee also the description of the ``try`` statement in section *The try\nstatement* and ``raise`` statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by these\n operations is not available at the time the module is compiled.\n',
+ 'execmodel': '\nExecution model\n***************\n\n\nNaming and binding\n==================\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\non the interpreter command line the first argument) is a code block.\nA script command (a command specified on the interpreter command line\nwith the \'**-c**\' option) is a code block. The string argument passed\nto the built-in functions ``eval()`` and ``exec()`` is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as ``nonlocal``. If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a ``NameError`` exception is raised.\nIf the name refers to a local variable that has not been bound, a\n``UnboundLocalError`` exception is raised. ``UnboundLocalError`` is a\nsubclass of ``NameError``.\n\nThe following constructs bind names: formal parameters to functions,\n``import`` statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, ``for`` loop header, or\nafter ``as`` in a ``with`` statement or ``except`` clause. The\n``import`` statement of the form ``from ... import *`` binds all names\ndefined in the imported module, except those beginning with an\nunderscore. This form may only be used at the module level.\n\nA target occurring in a ``del`` statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name). It\nis illegal to unbind a name that is referenced by an enclosing scope;\nthe compiler will report a ``SyntaxError``.\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the ``global`` statement occurs within a block, all uses of the\nname specified in the statement refer to the binding of that name in\nthe top-level namespace. Names are resolved in the top-level\nnamespace by searching the global namespace, i.e. the namespace of the\nmodule containing the code block, and the builtins namespace, the\nnamespace of the module ``builtins``. The global namespace is\nsearched first. If the name is not found there, the builtins\nnamespace is searched. The global statement must precede all uses of\nthe name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name ``__builtins__`` in its\nglobal namespace; this should be a dictionary or a module (in the\nlatter case the module\'s dictionary is used). By default, when in the\n``__main__`` module, ``__builtins__`` is the built-in module\n``builtins``; when in any other module, ``__builtins__`` is an alias\nfor the dictionary of the ``builtins`` module itself.\n``__builtins__`` can be set to a user-created dictionary to create a\nweak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n``__builtins__``; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should ``import``\nthe ``builtins`` module and modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n``__main__``.\n\nThe ``global`` statement has the same scope as a name binding\noperation in the same block. If the nearest enclosing scope for a\nfree variable contains a global statement, the free variable is\ntreated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n---------------------------------\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the ``raise`` statement. Exception\nhandlers are specified with the ``try`` ... ``except`` statement. The\n``finally`` clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n``SystemExit``.\n\nExceptions are identified by class instances. The ``except`` clause\nis selected depending on the class of the instance: it must reference\nthe class of the instance or a base class thereof. The instance can\nbe received by the handler and can carry additional information about\nthe exceptional condition.\n\nNote: Exception messages are not part of the Python API. Their contents\n may change from one version of Python to the next without warning\n and should not be relied on by code which will run under multiple\n versions of the interpreter.\n\nSee also the description of the ``try`` statement in section *The try\nstatement* and ``raise`` statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by these\n operations is not available at the time the module is compiled.\n',
'exprlists': '\nExpression lists\n****************\n\n expression_list ::= expression ( "," expression )* [","]\n\nAn expression list containing at least one comma yields a tuple. The\nlength of the tuple is the number of expressions in the list. The\nexpressions are evaluated from left to right.\n\nThe trailing comma is required only to create a single tuple (a.k.a. a\n*singleton*); it is optional in all other cases. A single expression\nwithout a trailing comma doesn\'t create a tuple, but rather yields the\nvalue of that expression. (To create an empty tuple, use an empty pair\nof parentheses: ``()``.)\n',
'floating': '\nFloating point literals\n***********************\n\nFloating point literals are described by the following lexical\ndefinitions:\n\n floatnumber ::= pointfloat | exponentfloat\n pointfloat ::= [intpart] fraction | intpart "."\n exponentfloat ::= (intpart | pointfloat) exponent\n intpart ::= digit+\n fraction ::= "." digit+\n exponent ::= ("e" | "E") ["+" | "-"] digit+\n\nNote that the integer and exponent parts are always interpreted using\nradix 10. For example, ``077e010`` is legal, and denotes the same\nnumber as ``77e10``. The allowed range of floating point literals is\nimplementation-dependent. Some examples of floating point literals:\n\n 3.14 10. .001 1e100 3.14e-10 0e0\n\nNote that numeric literals do not include a sign; a phrase like ``-1``\nis actually an expression composed of the unary operator ``-`` and the\nliteral ``1``.\n',
'for': '\nThe ``for`` statement\n*********************\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n``expression_list``. The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a ``StopIteration``\nexception), the suite in the ``else`` clause, if present, is executed,\nand the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, it will not have been assigned to at all\nby the loop. Hint: the built-in function ``range()`` returns an\niterator of integers suitable to emulate the effect of Pascal\'s ``for\ni := a to b do``; e.g., ``list(range(3))`` returns the list ``[0, 1,\n2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n',
- 'formatstrings': '\nFormat String Syntax\n********************\n\nThe ``str.format()`` method and the ``Formatter`` class share the same\nsyntax for format strings (although in the case of ``Formatter``,\nsubclasses can define their own format string syntax.)\n\nFormat strings contain "replacement fields" surrounded by curly braces\n``{}``. Anything that is not contained in braces is considered literal\ntext, which is copied unchanged to the output. If you need to include\na brace character in the literal text, it can be escaped by doubling:\n``{{`` and ``}}``.\n\nThe grammar for a replacement field is as follows:\n\n replacement_field ::= "{" field_name ["!" conversion] [":" format_spec] "}"\n field_name ::= arg_name ("." attribute_name | "[" element_index "]")*\n arg_name ::= (identifier | integer)?\n attribute_name ::= identifier\n element_index ::= integer\n conversion ::= "r" | "s" | "a"\n format_spec ::= <described in the next section>\n\nIn less formal terms, the replacement field starts with a *field_name*\nthat specifies the object whose value is to be formatted and inserted\ninto the output instead of the replacement field. The *field_name* is\noptionally followed by a *conversion* field, which is preceded by an\nexclamation point ``\'!\'``, and a *format_spec*, which is preceded by a\ncolon ``\':\'``. These specify a non-default format for the replacement\nvalue.\n\nThe *field_name* itself begins with an *arg_name* that is either\neither a number or a keyword. If it\'s a number, it refers to a\npositional argument, and if it\'s a keyword, it refers to a named\nkeyword argument. If the numerical arg_names in a format string are\n0, 1, 2, ... in sequence, they can all be omitted (not just some) and\nthe numbers 0, 1, 2, ... will be automatically inserted in that order.\nThe *arg_name* can be followed by any number of index or attribute\nexpressions. An expression of the form ``\'.name\'`` selects the named\nattribute using ``getattr()``, while an expression of the form\n``\'[index]\'`` does an index lookup using ``__getitem__()``.\n\nSome simple format string examples:\n\n "First, thou shalt count to {0}" # References first positional argument\n "Bring me a {}" # Implicitly references the first positional argument\n "From {} to {}" # Same as "From {0] to {1}"\n "My quest is {name}" # References keyword argument \'name\'\n "Weight in tons {0.weight}" # \'weight\' attribute of first positional arg\n "Units destroyed: {players[0]}" # First element of keyword argument \'players\'.\n\nThe *conversion* field causes a type coercion before formatting.\nNormally, the job of formatting a value is done by the\n``__format__()`` method of the value itself. However, in some cases\nit is desirable to force a type to be formatted as a string,\noverriding its own definition of formatting. By converting the value\nto a string before calling ``__format__()``, the normal formatting\nlogic is bypassed.\n\nThree conversion flags are currently supported: ``\'!s\'`` which calls\n``str()`` on the value, ``\'!r\'`` which calls ``repr()`` and ``\'!a\'``\nwhich calls ``ascii()``.\n\nSome examples:\n\n "Harold\'s a clever {0!s}" # Calls str() on the argument first\n "Bring out the holy {name!r}" # Calls repr() on the argument first\n\nThe *format_spec* field contains a specification of how the value\nshould be presented, including such details as field width, alignment,\npadding, decimal precision and so on. Each value type can define it\'s\nown "formatting mini-language" or interpretation of the *format_spec*.\n\nMost built-in types support a common formatting mini-language, which\nis described in the next section.\n\nA *format_spec* field can also include nested replacement fields\nwithin it. These nested replacement fields can contain only a field\nname; conversion flags and format specifications are not allowed. The\nreplacement fields within the format_spec are substituted before the\n*format_spec* string is interpreted. This allows the formatting of a\nvalue to be dynamically specified.\n\nFor example, suppose you wanted to have a replacement field whose\nfield width is determined by another variable:\n\n "A man with two {0:{1}}".format("noses", 10)\n\nThis would first evaluate the inner replacement field, making the\nformat string effectively:\n\n "A man with two {0:10}"\n\nThen the outer replacement field would be evaluated, producing:\n\n "noses "\n\nWhich is substituted into the string, yielding:\n\n "A man with two noses "\n\n(The extra space is because we specified a field width of 10, and\nbecause left alignment is the default for strings.)\n\n\nFormat Specification Mini-Language\n==================================\n\n"Format specifications" are used within replacement fields contained\nwithin a format string to define how individual values are presented\n(see *Format String Syntax*.) They can also be passed directly to the\nbuiltin ``format()`` function. Each formattable type may define how\nthe format specification is to be interpreted.\n\nMost built-in types implement the following options for format\nspecifications, although some of the formatting options are only\nsupported by the numeric types.\n\nA general convention is that an empty format string (``""``) produces\nthe same result as if you had called ``str()`` on the value.\n\nThe general form of a *standard format specifier* is:\n\n format_spec ::= [[fill]align][sign][#][0][width][.precision][type]\n fill ::= <a character other than \'}\'>\n align ::= "<" | ">" | "=" | "^"\n sign ::= "+" | "-" | " "\n width ::= integer\n precision ::= integer\n type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "x" | "X" | "%"\n\nThe *fill* character can be any character other than \'}\' (which\nsignifies the end of the field). The presence of a fill character is\nsignaled by the *next* character, which must be one of the alignment\noptions. If the second character of *format_spec* is not a valid\nalignment option, then it is assumed that both the fill character and\nthe alignment option are absent.\n\nThe meaning of the various alignment options is as follows:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | ``\'<\'`` | Forces the field to be left-aligned within the available |\n | | space (This is the default.) |\n +-----------+------------------------------------------------------------+\n | ``\'>\'`` | Forces the field to be right-aligned within the available |\n | | space. |\n +-----------+------------------------------------------------------------+\n | ``\'=\'`` | Forces the padding to be placed after the sign (if any) |\n | | but before the digits. This is used for printing fields |\n | | in the form \'+000000120\'. This alignment option is only |\n | | valid for numeric types. |\n +-----------+------------------------------------------------------------+\n | ``\'^\'`` | Forces the field to be centered within the available |\n | | space. |\n +-----------+------------------------------------------------------------+\n\nNote that unless a minimum field width is defined, the field width\nwill always be the same size as the data to fill it, so that the\nalignment option has no meaning in this case.\n\nThe *sign* option is only valid for number types, and can be one of\nthe following:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | ``\'+\'`` | indicates that a sign should be used for both positive as |\n | | well as negative numbers. |\n +-----------+------------------------------------------------------------+\n | ``\'-\'`` | indicates that a sign should be used only for negative |\n | | numbers (this is the default behavior). |\n +-----------+------------------------------------------------------------+\n | space | indicates that a leading space should be used on positive |\n | | numbers, and a minus sign on negative numbers. |\n +-----------+------------------------------------------------------------+\n\nThe ``\'#\'`` option is only valid for integers, and only for binary,\noctal, or hexadecimal output. If present, it specifies that the\noutput will be prefixed by ``\'0b\'``, ``\'0o\'``, or ``\'0x\'``,\nrespectively.\n\n*width* is a decimal integer defining the minimum field width. If not\nspecified, then the field width will be determined by the content.\n\nIf the *width* field is preceded by a zero (``\'0\'``) character, this\nenables zero-padding. This is equivalent to an *alignment* type of\n``\'=\'`` and a *fill* character of ``\'0\'``.\n\nThe *precision* is a decimal number indicating how many digits should\nbe displayed after the decimal point for a floating point value\nformatted with ``\'f\'`` and ``\'F\'``, or before and after the decimal\npoint for a floating point value formatted with ``\'g\'`` or ``\'G\'``.\nFor non-number types the field indicates the maximum field size - in\nother words, how many characters will be used from the field content.\nThe *precision* is not allowed for integer values.\n\nFinally, the *type* determines how the data should be presented.\n\nThe available integer presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'b\'`` | Binary format. Outputs the number in base 2. |\n +-----------+------------------------------------------------------------+\n | ``\'c\'`` | Character. Converts the integer to the corresponding |\n | | unicode character before printing. |\n +-----------+------------------------------------------------------------+\n | ``\'d\'`` | Decimal Integer. Outputs the number in base 10. |\n +-----------+------------------------------------------------------------+\n | ``\'o\'`` | Octal format. Outputs the number in base 8. |\n +-----------+------------------------------------------------------------+\n | ``\'x\'`` | Hex format. Outputs the number in base 16, using lower- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | ``\'X\'`` | Hex format. Outputs the number in base 16, using upper- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | ``\'n\'`` | Number. This is the same as ``\'d\'``, except that it uses |\n | | the current locale setting to insert the appropriate |\n | | number separator characters. |\n +-----------+------------------------------------------------------------+\n | None | The same as ``\'d\'``. |\n +-----------+------------------------------------------------------------+\n\nThe available presentation types for floating point and decimal values\nare:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'e\'`` | Exponent notation. Prints the number in scientific |\n | | notation using the letter \'e\' to indicate the exponent. |\n +-----------+------------------------------------------------------------+\n | ``\'E\'`` | Exponent notation. Same as ``\'e\'`` except it uses an upper |\n | | case \'E\' as the separator character. |\n +-----------+------------------------------------------------------------+\n | ``\'f\'`` | Fixed point. Displays the number as a fixed-point number. |\n +-----------+------------------------------------------------------------+\n | ``\'F\'`` | Fixed point. Same as ``\'f\'``, but converts ``nan`` to |\n | | ``NAN`` and ``inf`` to ``INF``. |\n +-----------+------------------------------------------------------------+\n | ``\'g\'`` | General format. This prints the number as a fixed-point |\n | | number, unless the number is too large, in which case it |\n | | switches to ``\'e\'`` exponent notation. Infinity and NaN |\n | | values are formatted as ``inf``, ``-inf`` and ``nan``, |\n | | respectively. |\n +-----------+------------------------------------------------------------+\n | ``\'G\'`` | General format. Same as ``\'g\'`` except switches to ``\'E\'`` |\n | | if the number gets to large. The representations of |\n | | infinity and NaN are uppercased, too. |\n +-----------+------------------------------------------------------------+\n | ``\'n\'`` | Number. This is the same as ``\'g\'``, except that it uses |\n | | the current locale setting to insert the appropriate |\n | | number separator characters. |\n +-----------+------------------------------------------------------------+\n | ``\'%\'`` | Percentage. Multiplies the number by 100 and displays in |\n | | fixed (``\'f\'``) format, followed by a percent sign. |\n +-----------+------------------------------------------------------------+\n | None | Similar to ``\'g\'``, except with at least one digit past |\n | | the decimal point and a default precision of 12. This is |\n | | intended to match ``str()``, except you can add the other |\n | | format modifiers. |\n +-----------+------------------------------------------------------------+\n',
+ 'formatstrings': '\nFormat String Syntax\n********************\n\nThe ``str.format()`` method and the ``Formatter`` class share the same\nsyntax for format strings (although in the case of ``Formatter``,\nsubclasses can define their own format string syntax).\n\nFormat strings contain "replacement fields" surrounded by curly braces\n``{}``. Anything that is not contained in braces is considered literal\ntext, which is copied unchanged to the output. If you need to include\na brace character in the literal text, it can be escaped by doubling:\n``{{`` and ``}}``.\n\nThe grammar for a replacement field is as follows:\n\n replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"\n field_name ::= arg_name ("." attribute_name | "[" element_index "]")*\n arg_name ::= [identifier | integer]\n attribute_name ::= identifier\n element_index ::= integer | index_string\n index_string ::= <any source character except "]"> +\n conversion ::= "r" | "s" | "a"\n format_spec ::= <described in the next section>\n\nIn less formal terms, the replacement field can start with a\n*field_name* that specifies the object whose value is to be formatted\nand inserted into the output instead of the replacement field. The\n*field_name* is optionally followed by a *conversion* field, which is\npreceded by an exclamation point ``\'!\'``, and a *format_spec*, which\nis preceded by a colon ``\':\'``. These specify a non-default format\nfor the replacement value.\n\nSee also the *Format Specification Mini-Language* section.\n\nThe *field_name* itself begins with an *arg_name* that is either\neither a number or a keyword. If it\'s a number, it refers to a\npositional argument, and if it\'s a keyword, it refers to a named\nkeyword argument. If the numerical arg_names in a format string are\n0, 1, 2, ... in sequence, they can all be omitted (not just some) and\nthe numbers 0, 1, 2, ... will be automatically inserted in that order.\nThe *arg_name* can be followed by any number of index or attribute\nexpressions. An expression of the form ``\'.name\'`` selects the named\nattribute using ``getattr()``, while an expression of the form\n``\'[index]\'`` does an index lookup using ``__getitem__()``.\n\nChanged in version 3.1: The positional argument specifiers can be\nomitted, so ``\'{} {}\'`` is equivalent to ``\'{0} {1}\'``.\n\nSome simple format string examples:\n\n "First, thou shalt count to {0}" # References first positional argument\n "Bring me a {}" # Implicitly references the first positional argument\n "From {} to {}" # Same as "From {0} to {1}"\n "My quest is {name}" # References keyword argument \'name\'\n "Weight in tons {0.weight}" # \'weight\' attribute of first positional arg\n "Units destroyed: {players[0]}" # First element of keyword argument \'players\'.\n\nThe *conversion* field causes a type coercion before formatting.\nNormally, the job of formatting a value is done by the\n``__format__()`` method of the value itself. However, in some cases\nit is desirable to force a type to be formatted as a string,\noverriding its own definition of formatting. By converting the value\nto a string before calling ``__format__()``, the normal formatting\nlogic is bypassed.\n\nThree conversion flags are currently supported: ``\'!s\'`` which calls\n``str()`` on the value, ``\'!r\'`` which calls ``repr()`` and ``\'!a\'``\nwhich calls ``ascii()``.\n\nSome examples:\n\n "Harold\'s a clever {0!s}" # Calls str() on the argument first\n "Bring out the holy {name!r}" # Calls repr() on the argument first\n "More {!a}" # Calls ascii() on the argument first\n\nThe *format_spec* field contains a specification of how the value\nshould be presented, including such details as field width, alignment,\npadding, decimal precision and so on. Each value type can define its\nown "formatting mini-language" or interpretation of the *format_spec*.\n\nMost built-in types support a common formatting mini-language, which\nis described in the next section.\n\nA *format_spec* field can also include nested replacement fields\nwithin it. These nested replacement fields can contain only a field\nname; conversion flags and format specifications are not allowed. The\nreplacement fields within the format_spec are substituted before the\n*format_spec* string is interpreted. This allows the formatting of a\nvalue to be dynamically specified.\n\nSee the *Format examples* section for some examples.\n\n\nFormat Specification Mini-Language\n==================================\n\n"Format specifications" are used within replacement fields contained\nwithin a format string to define how individual values are presented\n(see *Format String Syntax*). They can also be passed directly to the\nbuilt-in ``format()`` function. Each formattable type may define how\nthe format specification is to be interpreted.\n\nMost built-in types implement the following options for format\nspecifications, although some of the formatting options are only\nsupported by the numeric types.\n\nA general convention is that an empty format string (``""``) produces\nthe same result as if you had called ``str()`` on the value. A non-\nempty format string typically modifies the result.\n\nThe general form of a *standard format specifier* is:\n\n format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]\n fill ::= <a character other than \'}\'>\n align ::= "<" | ">" | "=" | "^"\n sign ::= "+" | "-" | " "\n width ::= integer\n precision ::= integer\n type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n\nThe *fill* character can be any character other than \'{\' or \'}\'. The\npresence of a fill character is signaled by the character following\nit, which must be one of the alignment options. If the second\ncharacter of *format_spec* is not a valid alignment option, then it is\nassumed that both the fill character and the alignment option are\nabsent.\n\nThe meaning of the various alignment options is as follows:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | ``\'<\'`` | Forces the field to be left-aligned within the available |\n | | space (this is the default for most objects). |\n +-----------+------------------------------------------------------------+\n | ``\'>\'`` | Forces the field to be right-aligned within the available |\n | | space (this is the default for numbers). |\n +-----------+------------------------------------------------------------+\n | ``\'=\'`` | Forces the padding to be placed after the sign (if any) |\n | | but before the digits. This is used for printing fields |\n | | in the form \'+000000120\'. This alignment option is only |\n | | valid for numeric types. |\n +-----------+------------------------------------------------------------+\n | ``\'^\'`` | Forces the field to be centered within the available |\n | | space. |\n +-----------+------------------------------------------------------------+\n\nNote that unless a minimum field width is defined, the field width\nwill always be the same size as the data to fill it, so that the\nalignment option has no meaning in this case.\n\nThe *sign* option is only valid for number types, and can be one of\nthe following:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | ``\'+\'`` | indicates that a sign should be used for both positive as |\n | | well as negative numbers. |\n +-----------+------------------------------------------------------------+\n | ``\'-\'`` | indicates that a sign should be used only for negative |\n | | numbers (this is the default behavior). |\n +-----------+------------------------------------------------------------+\n | space | indicates that a leading space should be used on positive |\n | | numbers, and a minus sign on negative numbers. |\n +-----------+------------------------------------------------------------+\n\nThe ``\'#\'`` option causes the "alternate form" to be used for the\nconversion. The alternate form is defined differently for different\ntypes. This option is only valid for integer, float, complex and\nDecimal types. For integers, when binary, octal, or hexadecimal output\nis used, this option adds the prefix respective ``\'0b\'``, ``\'0o\'``, or\n``\'0x\'`` to the output value. For floats, complex and Decimal the\nalternate form causes the result of the conversion to always contain a\ndecimal-point character, even if no digits follow it. Normally, a\ndecimal-point character appears in the result of these conversions\nonly if a digit follows it. In addition, for ``\'g\'`` and ``\'G\'``\nconversions, trailing zeros are not removed from the result.\n\nThe ``\',\'`` option signals the use of a comma for a thousands\nseparator. For a locale aware separator, use the ``\'n\'`` integer\npresentation type instead.\n\nChanged in version 3.1: Added the ``\',\'`` option (see also **PEP\n378**).\n\n*width* is a decimal integer defining the minimum field width. If not\nspecified, then the field width will be determined by the content.\n\nIf the *width* field is preceded by a zero (``\'0\'``) character, this\nenables zero-padding. This is equivalent to an *alignment* type of\n``\'=\'`` and a *fill* character of ``\'0\'``.\n\nThe *precision* is a decimal number indicating how many digits should\nbe displayed after the decimal point for a floating point value\nformatted with ``\'f\'`` and ``\'F\'``, or before and after the decimal\npoint for a floating point value formatted with ``\'g\'`` or ``\'G\'``.\nFor non-number types the field indicates the maximum field size - in\nother words, how many characters will be used from the field content.\nThe *precision* is not allowed for integer values.\n\nFinally, the *type* determines how the data should be presented.\n\nThe available string presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'s\'`` | String format. This is the default type for strings and |\n | | may be omitted. |\n +-----------+------------------------------------------------------------+\n | None | The same as ``\'s\'``. |\n +-----------+------------------------------------------------------------+\n\nThe available integer presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'b\'`` | Binary format. Outputs the number in base 2. |\n +-----------+------------------------------------------------------------+\n | ``\'c\'`` | Character. Converts the integer to the corresponding |\n | | unicode character before printing. |\n +-----------+------------------------------------------------------------+\n | ``\'d\'`` | Decimal Integer. Outputs the number in base 10. |\n +-----------+------------------------------------------------------------+\n | ``\'o\'`` | Octal format. Outputs the number in base 8. |\n +-----------+------------------------------------------------------------+\n | ``\'x\'`` | Hex format. Outputs the number in base 16, using lower- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | ``\'X\'`` | Hex format. Outputs the number in base 16, using upper- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | ``\'n\'`` | Number. This is the same as ``\'d\'``, except that it uses |\n | | the current locale setting to insert the appropriate |\n | | number separator characters. |\n +-----------+------------------------------------------------------------+\n | None | The same as ``\'d\'``. |\n +-----------+------------------------------------------------------------+\n\nIn addition to the above presentation types, integers can be formatted\nwith the floating point presentation types listed below (except\n``\'n\'`` and None). When doing so, ``float()`` is used to convert the\ninteger to a floating point number before formatting.\n\nThe available presentation types for floating point and decimal values\nare:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'e\'`` | Exponent notation. Prints the number in scientific |\n | | notation using the letter \'e\' to indicate the exponent. |\n +-----------+------------------------------------------------------------+\n | ``\'E\'`` | Exponent notation. Same as ``\'e\'`` except it uses an upper |\n | | case \'E\' as the separator character. |\n +-----------+------------------------------------------------------------+\n | ``\'f\'`` | Fixed point. Displays the number as a fixed-point number. |\n +-----------+------------------------------------------------------------+\n | ``\'F\'`` | Fixed point. Same as ``\'f\'``, but converts ``nan`` to |\n | | ``NAN`` and ``inf`` to ``INF``. |\n +-----------+------------------------------------------------------------+\n | ``\'g\'`` | General format. For a given precision ``p >= 1``, this |\n | | rounds the number to ``p`` significant digits and then |\n | | formats the result in either fixed-point format or in |\n | | scientific notation, depending on its magnitude. The |\n | | precise rules are as follows: suppose that the result |\n | | formatted with presentation type ``\'e\'`` and precision |\n | | ``p-1`` would have exponent ``exp``. Then if ``-4 <= exp |\n | | < p``, the number is formatted with presentation type |\n | | ``\'f\'`` and precision ``p-1-exp``. Otherwise, the number |\n | | is formatted with presentation type ``\'e\'`` and precision |\n | | ``p-1``. In both cases insignificant trailing zeros are |\n | | removed from the significand, and the decimal point is |\n | | also removed if there are no remaining digits following |\n | | it. Positive and negative infinity, positive and negative |\n | | zero, and nans, are formatted as ``inf``, ``-inf``, ``0``, |\n | | ``-0`` and ``nan`` respectively, regardless of the |\n | | precision. A precision of ``0`` is treated as equivalent |\n | | to a precision of ``1``. |\n +-----------+------------------------------------------------------------+\n | ``\'G\'`` | General format. Same as ``\'g\'`` except switches to ``\'E\'`` |\n | | if the number gets too large. The representations of |\n | | infinity and NaN are uppercased, too. |\n +-----------+------------------------------------------------------------+\n | ``\'n\'`` | Number. This is the same as ``\'g\'``, except that it uses |\n | | the current locale setting to insert the appropriate |\n | | number separator characters. |\n +-----------+------------------------------------------------------------+\n | ``\'%\'`` | Percentage. Multiplies the number by 100 and displays in |\n | | fixed (``\'f\'``) format, followed by a percent sign. |\n +-----------+------------------------------------------------------------+\n | None | Similar to ``\'g\'``, except with at least one digit past |\n | | the decimal point and a default precision of 12. This is |\n | | intended to match ``str()``, except you can add the other |\n | | format modifiers. |\n +-----------+------------------------------------------------------------+\n\n\nFormat examples\n===============\n\nThis section contains examples of the new format syntax and comparison\nwith the old ``%``-formatting.\n\nIn most of the cases the syntax is similar to the old\n``%``-formatting, with the addition of the ``{}`` and with ``:`` used\ninstead of ``%``. For example, ``\'%03.2f\'`` can be translated to\n``\'{:03.2f}\'``.\n\nThe new format syntax also supports new and different options, shown\nin the follow examples.\n\nAccessing arguments by position:\n\n >>> \'{0}, {1}, {2}\'.format(\'a\', \'b\', \'c\')\n \'a, b, c\'\n >>> \'{}, {}, {}\'.format(\'a\', \'b\', \'c\') # 3.1+ only\n \'a, b, c\'\n >>> \'{2}, {1}, {0}\'.format(\'a\', \'b\', \'c\')\n \'c, b, a\'\n >>> \'{2}, {1}, {0}\'.format(*\'abc\') # unpacking argument sequence\n \'c, b, a\'\n >>> \'{0}{1}{0}\'.format(\'abra\', \'cad\') # arguments\' indices can be repeated\n \'abracadabra\'\n\nAccessing arguments by name:\n\n >>> \'Coordinates: {latitude}, {longitude}\'.format(latitude=\'37.24N\', longitude=\'-115.81W\')\n \'Coordinates: 37.24N, -115.81W\'\n >>> coord = {\'latitude\': \'37.24N\', \'longitude\': \'-115.81W\'}\n >>> \'Coordinates: {latitude}, {longitude}\'.format(**coord)\n \'Coordinates: 37.24N, -115.81W\'\n\nAccessing arguments\' attributes:\n\n >>> c = 3-5j\n >>> (\'The complex number {0} is formed from the real part {0.real} \'\n ... \'and the imaginary part {0.imag}.\').format(c)\n \'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.\'\n >>> class Point:\n ... def __init__(self, x, y):\n ... self.x, self.y = x, y\n ... def __str__(self):\n ... return \'Point({self.x}, {self.y})\'.format(self=self)\n ...\n >>> str(Point(4, 2))\n \'Point(4, 2)\'\n\nAccessing arguments\' items:\n\n >>> coord = (3, 5)\n >>> \'X: {0[0]}; Y: {0[1]}\'.format(coord)\n \'X: 3; Y: 5\'\n\nReplacing ``%s`` and ``%r``:\n\n >>> "repr() shows quotes: {!r}; str() doesn\'t: {!s}".format(\'test1\', \'test2\')\n "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n\nAligning the text and specifying a width:\n\n >>> \'{:<30}\'.format(\'left aligned\')\n \'left aligned \'\n >>> \'{:>30}\'.format(\'right aligned\')\n \' right aligned\'\n >>> \'{:^30}\'.format(\'centered\')\n \' centered \'\n >>> \'{:*^30}\'.format(\'centered\') # use \'*\' as a fill char\n \'***********centered***********\'\n\nReplacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign:\n\n >>> \'{:+f}; {:+f}\'.format(3.14, -3.14) # show it always\n \'+3.140000; -3.140000\'\n >>> \'{: f}; {: f}\'.format(3.14, -3.14) # show a space for positive numbers\n \' 3.140000; -3.140000\'\n >>> \'{:-f}; {:-f}\'.format(3.14, -3.14) # show only the minus -- same as \'{:f}; {:f}\'\n \'3.140000; -3.140000\'\n\nReplacing ``%x`` and ``%o`` and converting the value to different\nbases:\n\n >>> # format also supports binary numbers\n >>> "int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}".format(42)\n \'int: 42; hex: 2a; oct: 52; bin: 101010\'\n >>> # with 0x, 0o, or 0b as prefix:\n >>> "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42)\n \'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010\'\n\nUsing the comma as a thousands separator:\n\n >>> \'{:,}\'.format(1234567890)\n \'1,234,567,890\'\n\nExpressing a percentage:\n\n >>> points = 19\n >>> total = 22\n >>> \'Correct answers: {:.2%}.\'.format(points/total)\n \'Correct answers: 86.36%\'\n\nUsing type-specific formatting:\n\n >>> import datetime\n >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n >>> \'{:%Y-%m-%d %H:%M:%S}\'.format(d)\n \'2010-07-04 12:15:58\'\n\nNesting arguments and more complex examples:\n\n >>> for align, text in zip(\'<^>\', [\'left\', \'center\', \'right\']):\n ... \'{0:{fill}{align}16}\'.format(text, fill=align, align=align)\n ...\n \'left<<<<<<<<<<<<\'\n \'^^^^^center^^^^^\'\n \'>>>>>>>>>>>right\'\n >>>\n >>> octets = [192, 168, 0, 1]\n >>> \'{:02X}{:02X}{:02X}{:02X}\'.format(*octets)\n \'C0A80001\'\n >>> int(_, 16)\n 3232235521\n >>>\n >>> width = 5\n >>> for num in range(5,12):\n ... for base in \'dXob\':\n ... print(\'{0:{width}{base}}\'.format(num, base=base, width=width), end=\' \')\n ... print()\n ...\n 5 5 5 101\n 6 6 6 110\n 7 7 7 111\n 8 8 10 1000\n 9 9 11 1001\n 10 A 12 1010\n 11 B 13 1011\n',
'function': '\nFunction definitions\n********************\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n ( "*" [parameter] ("," defparameter)*\n [, "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the "``*``" must also have a default value ---\nthis is a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that that same "pre-computed" value is\nused for each call. This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended. A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple. If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after "``*``" or "``*identifier``" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "``: expression``"\nfollowing the parameter name. Any parameter may have an annotation\neven those of the form ``*identifier`` or ``**identifier``. Functions\nmay have "return" annotation of the form "``-> expression``" after the\nparameter list. These annotations can be any valid Python expression\nand are evaluated when the function definition is executed.\nAnnotations may be evaluated in a different order than they appear in\nthe source code. The presence of annotations does not change the\nsemantics of a function. The annotation values are available as\nvalues of a dictionary keyed by the parameters\' names in the\n``__annotations__`` attribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda forms,\ndescribed in section *Lambdas*. Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form. The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around. Free variables used in the\nnested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n',
- 'global': '\nThe ``global`` statement\n************************\n\n global_stmt ::= "global" identifier ("," identifier)*\n\nThe ``global`` statement is a declaration which holds for the entire\ncurrent code block. It means that the listed identifiers are to be\ninterpreted as globals. It would be impossible to assign to a global\nvariable without ``global``, although free variables may refer to\nglobals without being declared global.\n\nNames listed in a ``global`` statement must not be used in the same\ncode block textually preceding that ``global`` statement.\n\nNames listed in a ``global`` statement must not be defined as formal\nparameters or in a ``for`` loop control target, ``class`` definition,\nfunction definition, or ``import`` statement.\n\n(The current implementation does not enforce the latter two\nrestrictions, but programs should not abuse this freedom, as future\nimplementations may enforce them or silently change the meaning of the\nprogram.)\n\n**Programmer\'s note:** the ``global`` is a directive to the parser.\nIt applies only to code parsed at the same time as the ``global``\nstatement. In particular, a ``global`` statement contained in a string\nor code object supplied to the builtin ``exec()`` function does not\naffect the code block *containing* the function call, and code\ncontained in such a string is unaffected by ``global`` statements in\nthe code containing the function call. The same applies to the\n``eval()`` and ``compile()`` functions.\n',
- 'id-classes': '\nReserved classes of identifiers\n*******************************\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n Not imported by ``from module import *``. The special identifier\n ``_`` is used in the interactive interpreter to store the result of\n the last evaluation; it is stored in the ``builtins`` module. When\n not in interactive mode, ``_`` has no special meaning and is not\n defined. See section *The import statement*.\n\n Note: The name ``_`` is often used in conjunction with\n internationalization; refer to the documentation for the\n ``gettext`` module for more information on this convention.\n\n``__*__``\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library);\n applications should not expect to define additional names using\n this convention. The set of names of this class defined by Python\n may be extended in future versions. See section *Special method\n names*.\n\n``__*``\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
- 'identifiers': '\nIdentifiers and keywords\n************************\n\nIdentifiers (also referred to as *names*) are described by the\nfollowing lexical definitions.\n\nThe syntax of identifiers in Python is based on the Unicode standard\nannex UAX-31, with elaboration and changes as defined below; see also\n**PEP 3131** for further details.\n\nWithin the ASCII range (U+0001..U+007F), the valid characters for\nidentifiers are the same as in Python 2.x: the uppercase and lowercase\nletters ``A`` through ``Z``, the underscore ``_`` and, except for the\nfirst character, the digits ``0`` through ``9``.\n\nPython 3.0 introduces additional characters from outside the ASCII\nrange (see **PEP 3131**). For these characters, the classification\nuses the version of the Unicode Character Database as included in the\n``unicodedata`` module.\n\nIdentifiers are unlimited in length. Case is significant.\n\n identifier ::= id_start id_continue*\n id_start ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>\n id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>\n\nThe Unicode category codes mentioned above stand for:\n\n* *Lu* - uppercase letters\n\n* *Ll* - lowercase letters\n\n* *Lt* - titlecase letters\n\n* *Lm* - modifier letters\n\n* *Lo* - other letters\n\n* *Nl* - letter numbers\n\n* *Mn* - nonspacing marks\n\n* *Mc* - spacing combining marks\n\n* *Nd* - decimal numbers\n\n* *Pc* - connector punctuations\n\nAll identifiers are converted into the normal form NFC while parsing;\ncomparison of identifiers is based on NFC.\n\nA non-normative HTML file listing all valid identifier characters for\nUnicode 4.1 can be found at http://www.dcl.hpi.uni-\npotsdam.de/home/loewis/table-3131.html.\n\n\nKeywords\n========\n\nThe following identifiers are used as reserved words, or *keywords* of\nthe language, and cannot be used as ordinary identifiers. They must\nbe spelled exactly as written here:\n\n False class finally is return\n None continue for lambda try\n True def from nonlocal while\n and del global not with\n as elif if or yield\n assert else import pass\n break except in raise\n\n\nReserved classes of identifiers\n===============================\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n Not imported by ``from module import *``. The special identifier\n ``_`` is used in the interactive interpreter to store the result of\n the last evaluation; it is stored in the ``builtins`` module. When\n not in interactive mode, ``_`` has no special meaning and is not\n defined. See section *The import statement*.\n\n Note: The name ``_`` is often used in conjunction with\n internationalization; refer to the documentation for the\n ``gettext`` module for more information on this convention.\n\n``__*__``\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library);\n applications should not expect to define additional names using\n this convention. The set of names of this class defined by Python\n may be extended in future versions. See section *Special method\n names*.\n\n``__*``\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
+ 'global': '\nThe ``global`` statement\n************************\n\n global_stmt ::= "global" identifier ("," identifier)*\n\nThe ``global`` statement is a declaration which holds for the entire\ncurrent code block. It means that the listed identifiers are to be\ninterpreted as globals. It would be impossible to assign to a global\nvariable without ``global``, although free variables may refer to\nglobals without being declared global.\n\nNames listed in a ``global`` statement must not be used in the same\ncode block textually preceding that ``global`` statement.\n\nNames listed in a ``global`` statement must not be defined as formal\nparameters or in a ``for`` loop control target, ``class`` definition,\nfunction definition, or ``import`` statement.\n\n**CPython implementation detail:** The current implementation does not\nenforce the latter two restrictions, but programs should not abuse\nthis freedom, as future implementations may enforce them or silently\nchange the meaning of the program.\n\n**Programmer\'s note:** the ``global`` is a directive to the parser.\nIt applies only to code parsed at the same time as the ``global``\nstatement. In particular, a ``global`` statement contained in a string\nor code object supplied to the built-in ``exec()`` function does not\naffect the code block *containing* the function call, and code\ncontained in such a string is unaffected by ``global`` statements in\nthe code containing the function call. The same applies to the\n``eval()`` and ``compile()`` functions.\n',
+ 'id-classes': '\nReserved classes of identifiers\n*******************************\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n Not imported by ``from module import *``. The special identifier\n ``_`` is used in the interactive interpreter to store the result of\n the last evaluation; it is stored in the ``builtins`` module. When\n not in interactive mode, ``_`` has no special meaning and is not\n defined. See section *The import statement*.\n\n Note: The name ``_`` is often used in conjunction with\n internationalization; refer to the documentation for the\n ``gettext`` module for more information on this convention.\n\n``__*__``\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library). Current\n system names are discussed in the *Special method names* section\n and elsewhere. More will likely be defined in future versions of\n Python. *Any* use of ``__*__`` names, in any context, that does\n not follow explicitly documented use, is subject to breakage\n without warning.\n\n``__*``\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
+ 'identifiers': '\nIdentifiers and keywords\n************************\n\nIdentifiers (also referred to as *names*) are described by the\nfollowing lexical definitions.\n\nThe syntax of identifiers in Python is based on the Unicode standard\nannex UAX-31, with elaboration and changes as defined below; see also\n**PEP 3131** for further details.\n\nWithin the ASCII range (U+0001..U+007F), the valid characters for\nidentifiers are the same as in Python 2.x: the uppercase and lowercase\nletters ``A`` through ``Z``, the underscore ``_`` and, except for the\nfirst character, the digits ``0`` through ``9``.\n\nPython 3.0 introduces additional characters from outside the ASCII\nrange (see **PEP 3131**). For these characters, the classification\nuses the version of the Unicode Character Database as included in the\n``unicodedata`` module.\n\nIdentifiers are unlimited in length. Case is significant.\n\n identifier ::= xid_start xid_continue*\n id_start ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>\n id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>\n xid_start ::= <all characters in id_start whose NFKC normalization is in "id_start xid_continue*">\n xid_continue ::= <all characters in id_continue whose NFKC normalization is in "id_continue*">\n\nThe Unicode category codes mentioned above stand for:\n\n* *Lu* - uppercase letters\n\n* *Ll* - lowercase letters\n\n* *Lt* - titlecase letters\n\n* *Lm* - modifier letters\n\n* *Lo* - other letters\n\n* *Nl* - letter numbers\n\n* *Mn* - nonspacing marks\n\n* *Mc* - spacing combining marks\n\n* *Nd* - decimal numbers\n\n* *Pc* - connector punctuations\n\n* *Other_ID_Start* - explicit list of characters in PropList.txt to\n support backwards compatibility\n\n* *Other_ID_Continue* - likewise\n\nAll identifiers are converted into the normal form NFKC while parsing;\ncomparison of identifiers is based on NFKC.\n\nA non-normative HTML file listing all valid identifier characters for\nUnicode 4.1 can be found at http://www.dcl.hpi.uni-\npotsdam.de/home/loewis/table-3131.html.\n\n\nKeywords\n========\n\nThe following identifiers are used as reserved words, or *keywords* of\nthe language, and cannot be used as ordinary identifiers. They must\nbe spelled exactly as written here:\n\n False class finally is return\n None continue for lambda try\n True def from nonlocal while\n and del global not with\n as elif if or yield\n assert else import pass\n break except in raise\n\n\nReserved classes of identifiers\n===============================\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n Not imported by ``from module import *``. The special identifier\n ``_`` is used in the interactive interpreter to store the result of\n the last evaluation; it is stored in the ``builtins`` module. When\n not in interactive mode, ``_`` has no special meaning and is not\n defined. See section *The import statement*.\n\n Note: The name ``_`` is often used in conjunction with\n internationalization; refer to the documentation for the\n ``gettext`` module for more information on this convention.\n\n``__*__``\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library). Current\n system names are discussed in the *Special method names* section\n and elsewhere. More will likely be defined in future versions of\n Python. *Any* use of ``__*__`` names, in any context, that does\n not follow explicitly documented use, is subject to breakage\n without warning.\n\n``__*``\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
'if': '\nThe ``if`` statement\n********************\n\nThe ``if`` statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n',
'imaginary': '\nImaginary literals\n******************\n\nImaginary literals are described by the following lexical definitions:\n\n imagnumber ::= (floatnumber | intpart) ("j" | "J")\n\nAn imaginary literal yields a complex number with a real part of 0.0.\nComplex numbers are represented as a pair of floating point numbers\nand have the same restrictions on their range. To create a complex\nnumber with a nonzero real part, add a floating point number to it,\ne.g., ``(3+4j)``. Some examples of imaginary literals:\n\n 3.14j 10.j 10j .001j 1e100j 3.14e-10j\n',
- 'import': '\nThe ``import`` statement\n************************\n\n import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )*\n | "from" relative_module "import" identifier ["as" name]\n ( "," identifier ["as" name] )*\n | "from" relative_module "import" "(" identifier ["as" name]\n ( "," identifier ["as" name] )* [","] ")"\n | "from" module "import" "*"\n module ::= (identifier ".")* identifier\n relative_module ::= "."* module | "."+\n name ::= identifier\n\nImport statements are executed in two steps: (1) find a module, and\ninitialize it if necessary; (2) define a name or names in the local\nnamespace (of the scope where the ``import`` statement occurs). The\nstatement comes in two forms differing on whether it uses the ``from``\nkeyword. The first form (without ``from``) repeats these steps for\neach identifier in the list. The form with ``from`` performs step (1)\nonce, and then performs step (2) repeatedly. For a reference\nimplementation of step (1), see the ``importlib`` module.\n\nTo understand how step (1) occurs, one must first understand how\nPython handles hierarchical naming of modules. To help organize\nmodules and provide a hierarchy in naming, Python has a concept of\npackages. A package can contain other packages and modules while\nmodules cannot contain other modules or packages. From a file system\nperspective, packages are directories and modules are files. The\noriginal specification for packages is still available to read,\nalthough minor details have changed since the writing of that\ndocument.\n\nOnce the name of the module is known (unless otherwise specified, the\nterm "module" will refer to both packages and modules), searching for\nthe module or package can begin. The first place checked is\n``sys.modules``, the cache of all modules that have been imported\npreviously. If the module is found there then it is used in step (2)\nof import.\n\nIf the module is not found in the cache, then ``sys.meta_path`` is\nsearched (the specification for ``sys.meta_path`` can be found in\n**PEP 302**). The object is a list of *finder* objects which are\nqueried in order as to whether they know how to load the module by\ncalling their ``find_module()`` method with the name of the module. If\nthe module happens to be contained within a package (as denoted by the\nexistence of a dot in the name), then a second argument to\n``find_module()`` is given as the value of the ``__path__`` attribute\nfrom the parent package (everything up to the last dot in the name of\nthe module being imported). If a finder can find the module it returns\na *loader* (discussed later) or returns ``None``.\n\nIf none of the finders on ``sys.meta_path`` are able to find the\nmodule then some implicitly defined finders are queried.\nImplementations of Python vary in what implicit meta path finders are\ndefined. The one they all do define, though, is one that handles\n``sys.path_hooks``, ``sys.path_importer_cache``, and ``sys.path``.\n\nThe implicit finder searches for the requested module in the "paths"\nspecified in one of two places ("paths" do not have to be file system\npaths). If the module being imported is supposed to be contained\nwithin a package then the second argument passed to ``find_module()``,\n``__path__`` on the parent package, is used as the source of paths. If\nthe module is not contained in a package then ``sys.path`` is used as\nthe source of paths.\n\nOnce the source of paths is chosen it is iterated over to find a\nfinder that can handle that path. The dict at\n``sys.path_importer_cache`` caches finders for paths and is checked\nfor a finder. If the path does not have a finder cached then\n``sys.path_hooks`` is searched by calling each object in the list with\na single argument of the path, returning a finder or raises\n``ImportError``. If a finder is returned then it is cached in\n``sys.path_importer_cache`` and then used for that path entry. If no\nfinder can be found but the path exists then a value of ``None`` is\nstored in ``sys.path_importer_cache`` to signify that an implicit,\nfile-based finder that handles modules stored as individual files\nshould be used for that path. If the path does not exist then a finder\nwhich always returns ``None`` is placed in the cache for the path.\n\nIf no finder can find the module then ``ImportError`` is raised.\nOtherwise some finder returned a loader whose ``load_module()`` method\nis called with the name of the module to load (see **PEP 302** for the\noriginal definition of loaders). A loader has several responsibilities\nto perform on a module it loads. First, if the module already exists\nin ``sys.modules`` (a possibility if the loader is called outside of\nthe import machinery) then it is to use that module for initialization\nand not a new module. But if the module does not exist in\n``sys.modules`` then it is to be added to that dict before\ninitialization begins. If an error occurs during loading of the module\nand it was added to ``sys.modules`` it is to be removed from the dict.\nIf an error occurs but the module was already in ``sys.modules`` it is\nleft in the dict.\n\nThe loader must set several attributes on the module. ``__name__`` is\nto be set to the name of the module. ``__file__`` is to be the "path"\nto the file unless the module is built-in (and thus listed in\n``sys.builtin_module_names``) in which case the attribute is not set.\nIf what is being imported is a package then ``__path__`` is to be set\nto a list of paths to be searched when looking for modules and\npackages contained within the package being imported. ``__package__``\nis optional but should be set to the name of package that contains the\nmodule or package (the empty string is used for module not contained\nin a package). ``__loader__`` is also optional but should be set to\nthe loader object that is loading the module.\n\nIf an error occurs during loading then the loader raises\n``ImportError`` if some other exception is not already being\npropagated. Otherwise the loader returns the module that was loaded\nand initialized.\n\nWhen step (1) finishes without raising an exception, step (2) can\nbegin.\n\nThe first form of ``import`` statement binds the module name in the\nlocal namespace to the module object, and then goes on to import the\nnext identifier, if any. If the module name is followed by ``as``,\nthe name following ``as`` is used as the local name for the module.\n\nThe ``from`` form does not bind the module name: it goes through the\nlist of identifiers, looks each one of them up in the module found in\nstep (1), and binds the name in the local namespace to the object thus\nfound. As with the first form of ``import``, an alternate local name\ncan be supplied by specifying "``as`` localname". If a name is not\nfound, ``ImportError`` is raised. If the list of identifiers is\nreplaced by a star (``\'*\'``), all public names defined in the module\nare bound in the local namespace of the ``import`` statement..\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named ``__all__``; if defined, it\nmust be a sequence of strings which are names defined or imported by\nthat module. The names given in ``__all__`` are all considered public\nand are required to exist. If ``__all__`` is not defined, the set of\npublic names includes all names found in the module\'s namespace which\ndo not begin with an underscore character (``\'_\'``). ``__all__``\nshould contain the entire public API. It is intended to avoid\naccidentally exporting items that are not part of the API (such as\nlibrary modules which were imported and used within the module).\n\nThe ``from`` form with ``*`` may only occur in a module scope. The\nwild card form of import --- ``import *`` --- is only allowed at the\nmodule level. Attempting to use it in class for function definitions\nwill raise a ``SyntaxError``.\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after ``from``\nyou can specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n``from . import mod`` from a module in the ``pkg`` package then you\nwill end up importing ``pkg.mod``. If you execute ``from ..subpkg2\nimprt mod`` from within ``pkg.subpkg1`` you will import\n``pkg.subpkg2.mod``. The specification for relative imports is\ncontained within **PEP 328**.\n\n``importlib.import_module()`` is provided to support applications that\ndetermine which modules need to be loaded dynamically.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python. The future\nstatement is intended to ease migration to future versions of Python\nthat introduce incompatible changes to the language. It allows use of\nthe new features on a per-module basis before the release in which the\nfeature becomes standard.\n\n future_statement ::= "from" "__future__" "import" feature ["as" name]\n ("," feature ["as" name])*\n | "from" "__future__" "import" "(" feature ["as" name]\n ("," feature ["as" name])* [","] ")"\n feature ::= identifier\n name ::= identifier\n\nA future statement must appear near the top of the module. The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 3.0 are ``absolute_import``,\n``division``, ``generators``, ``unicode_literals``,\n``print_function``, ``nested_scopes`` and ``with_statement``. They\nare all redundant because they are always enabled, and only kept for\nbackwards compatibility.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code. It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently. Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module ``__future__``, described later, and it\nwill be imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by calls to the builtin functions ``exec()`` and\n``compile()`` that occur in a module ``M`` containing a future\nstatement will, by default, use the new syntax or semantics associated\nwith the future statement. This can be controlled by optional\narguments to ``compile()`` --- see the documentation of that function\nfor details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session. If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also:\n\n **PEP 236** - Back to the __future__\n The original proposal for the __future__ mechanism.\n',
- 'in': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects. The objects need not have the same type.\nIf both are numbers, they are converted to a common type. Otherwise,\nthe ``==`` and ``!=`` operators *always* consider objects of different\ntypes to be unequal, while the ``<``, ``>``, ``>=`` and ``<=``\noperators raise a ``TypeError`` when comparing objects of different\ntypes that do not implement these operators for the given pair of\ntypes. You can control comparison behavior of objects of non-builtin\ntypes by defining rich comparison methods like ``__gt__()``, described\nin section *Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values ``float(\'NaN\')`` and ``Decimal(\'NaN\')`` are special. The\n are identical to themselves, ``x is x`` but are not equal to\n themselves, ``x != x``. Additionally, comparing any value to a\n not-a-number value will return ``False``. For example, both ``3 <\n float(\'NaN\')`` and ``float(\'NaN\') < 3`` will return ``False``.\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric equivalents\n (the result of the built-in function ``ord()``) of their characters.\n [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison of\n corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, ``[1,2,x] <= [1,2,y]`` has the\n same value as ``x <= y``. If the corresponding element does not\n exist, the shorter sequence is ordered first (for example, ``[1,2] <\n [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if their sorted\n ``(key, value)`` lists compare equal. [4] Outcomes other than\n equality are resolved consistently, but are not otherwise defined.\n [5]\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, ``min()``, ``max()``, and ``sorted()`` produce\n undefined results given a list of sets as inputs.\n\n* Most other objects of builtin types compare unequal unless they are\n the same object; the choice whether one object is considered smaller\n or larger than another one is made arbitrarily but consistently\n within one execution of a program.\n\nComparison of objects of the differing types depends on whether either\nof the types provide explicit support for the comparison. Most\nnumeric types can be compared with one another, but comparisons of\n``float`` and ``Decimal`` are not supported to avoid the inevitable\nconfusion arising from representation issues such as ``float(\'1.1\')``\nbeing inexactly represented and therefore not exactly equal to\n``Decimal(\'1.1\')`` which is. When cross-type comparison is not\nsupported, the comparison method returns ``NotImplemented``. This can\ncreate the illusion of non-transitivity between supported cross-type\ncomparisons and unsupported comparisons. For example, ``Decimal(2) ==\n2`` and *2 == float(2)`* but ``Decimal(2) != float(2)``.\n\nThe operators ``in`` and ``not in`` test for membership. ``x in s``\nevaluates to true if *x* is a member of *s*, and false otherwise. ``x\nnot in s`` returns the negation of ``x in s``. All built-in sequences\nand set types support this as well as dictionary, for which ``in``\ntests whether a the dictionary has a given key. For container types\nsuch as list, tuple, set, frozenset, dict, or collections.deque, the\nexpression ``x in y`` is equivalent to ``any(x is e or x == e for val\ne in y)``.\n\nFor the string and bytes types, ``x in y`` is true if and only if *x*\nis a substring of *y*. An equivalent test is ``y.find(x) != -1``.\nEmpty strings are always considered to be a substring of any other\nstring, so ``"" in "abc"`` will return ``True``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` and do\ndefine ``__getitem__()``, ``x in y`` is true if and only if there is a\nnon-negative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception. (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object. ``x is\nnot y`` yields the inverse truth value. [6]\n',
+ 'import': '\nThe ``import`` statement\n************************\n\n import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )*\n | "from" relative_module "import" identifier ["as" name]\n ( "," identifier ["as" name] )*\n | "from" relative_module "import" "(" identifier ["as" name]\n ( "," identifier ["as" name] )* [","] ")"\n | "from" module "import" "*"\n module ::= (identifier ".")* identifier\n relative_module ::= "."* module | "."+\n name ::= identifier\n\nImport statements are executed in two steps: (1) find a module, and\ninitialize it if necessary; (2) define a name or names in the local\nnamespace (of the scope where the ``import`` statement occurs). The\nstatement comes in two forms differing on whether it uses the ``from``\nkeyword. The first form (without ``from``) repeats these steps for\neach identifier in the list. The form with ``from`` performs step (1)\nonce, and then performs step (2) repeatedly. For a reference\nimplementation of step (1), see the ``importlib`` module.\n\nTo understand how step (1) occurs, one must first understand how\nPython handles hierarchical naming of modules. To help organize\nmodules and provide a hierarchy in naming, Python has a concept of\npackages. A package can contain other packages and modules while\nmodules cannot contain other modules or packages. From a file system\nperspective, packages are directories and modules are files. The\noriginal specification for packages is still available to read,\nalthough minor details have changed since the writing of that\ndocument.\n\nOnce the name of the module is known (unless otherwise specified, the\nterm "module" will refer to both packages and modules), searching for\nthe module or package can begin. The first place checked is\n``sys.modules``, the cache of all modules that have been imported\npreviously. If the module is found there then it is used in step (2)\nof import unless ``None`` is found in ``sys.modules``, in which case\n``ImportError`` is raised.\n\nIf the module is not found in the cache, then ``sys.meta_path`` is\nsearched (the specification for ``sys.meta_path`` can be found in\n**PEP 302**). The object is a list of *finder* objects which are\nqueried in order as to whether they know how to load the module by\ncalling their ``find_module()`` method with the name of the module. If\nthe module happens to be contained within a package (as denoted by the\nexistence of a dot in the name), then a second argument to\n``find_module()`` is given as the value of the ``__path__`` attribute\nfrom the parent package (everything up to the last dot in the name of\nthe module being imported). If a finder can find the module it returns\na *loader* (discussed later) or returns ``None``.\n\nIf none of the finders on ``sys.meta_path`` are able to find the\nmodule then some implicitly defined finders are queried.\nImplementations of Python vary in what implicit meta path finders are\ndefined. The one they all do define, though, is one that handles\n``sys.path_hooks``, ``sys.path_importer_cache``, and ``sys.path``.\n\nThe implicit finder searches for the requested module in the "paths"\nspecified in one of two places ("paths" do not have to be file system\npaths). If the module being imported is supposed to be contained\nwithin a package then the second argument passed to ``find_module()``,\n``__path__`` on the parent package, is used as the source of paths. If\nthe module is not contained in a package then ``sys.path`` is used as\nthe source of paths.\n\nOnce the source of paths is chosen it is iterated over to find a\nfinder that can handle that path. The dict at\n``sys.path_importer_cache`` caches finders for paths and is checked\nfor a finder. If the path does not have a finder cached then\n``sys.path_hooks`` is searched by calling each object in the list with\na single argument of the path, returning a finder or raises\n``ImportError``. If a finder is returned then it is cached in\n``sys.path_importer_cache`` and then used for that path entry. If no\nfinder can be found but the path exists then a value of ``None`` is\nstored in ``sys.path_importer_cache`` to signify that an implicit,\nfile-based finder that handles modules stored as individual files\nshould be used for that path. If the path does not exist then a finder\nwhich always returns ``None`` is placed in the cache for the path.\n\nIf no finder can find the module then ``ImportError`` is raised.\nOtherwise some finder returned a loader whose ``load_module()`` method\nis called with the name of the module to load (see **PEP 302** for the\noriginal definition of loaders). A loader has several responsibilities\nto perform on a module it loads. First, if the module already exists\nin ``sys.modules`` (a possibility if the loader is called outside of\nthe import machinery) then it is to use that module for initialization\nand not a new module. But if the module does not exist in\n``sys.modules`` then it is to be added to that dict before\ninitialization begins. If an error occurs during loading of the module\nand it was added to ``sys.modules`` it is to be removed from the dict.\nIf an error occurs but the module was already in ``sys.modules`` it is\nleft in the dict.\n\nThe loader must set several attributes on the module. ``__name__`` is\nto be set to the name of the module. ``__file__`` is to be the "path"\nto the file unless the module is built-in (and thus listed in\n``sys.builtin_module_names``) in which case the attribute is not set.\nIf what is being imported is a package then ``__path__`` is to be set\nto a list of paths to be searched when looking for modules and\npackages contained within the package being imported. ``__package__``\nis optional but should be set to the name of package that contains the\nmodule or package (the empty string is used for module not contained\nin a package). ``__loader__`` is also optional but should be set to\nthe loader object that is loading the module.\n\nIf an error occurs during loading then the loader raises\n``ImportError`` if some other exception is not already being\npropagated. Otherwise the loader returns the module that was loaded\nand initialized.\n\nWhen step (1) finishes without raising an exception, step (2) can\nbegin.\n\nThe first form of ``import`` statement binds the module name in the\nlocal namespace to the module object, and then goes on to import the\nnext identifier, if any. If the module name is followed by ``as``,\nthe name following ``as`` is used as the local name for the module.\n\nThe ``from`` form does not bind the module name: it goes through the\nlist of identifiers, looks each one of them up in the module found in\nstep (1), and binds the name in the local namespace to the object thus\nfound. As with the first form of ``import``, an alternate local name\ncan be supplied by specifying "``as`` localname". If a name is not\nfound, ``ImportError`` is raised. If the list of identifiers is\nreplaced by a star (``\'*\'``), all public names defined in the module\nare bound in the local namespace of the ``import`` statement.\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named ``__all__``; if defined, it\nmust be a sequence of strings which are names defined or imported by\nthat module. The names given in ``__all__`` are all considered public\nand are required to exist. If ``__all__`` is not defined, the set of\npublic names includes all names found in the module\'s namespace which\ndo not begin with an underscore character (``\'_\'``). ``__all__``\nshould contain the entire public API. It is intended to avoid\naccidentally exporting items that are not part of the API (such as\nlibrary modules which were imported and used within the module).\n\nThe ``from`` form with ``*`` may only occur in a module scope. The\nwild card form of import --- ``import *`` --- is only allowed at the\nmodule level. Attempting to use it in class or function definitions\nwill raise a ``SyntaxError``.\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after ``from``\nyou can specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n``from . import mod`` from a module in the ``pkg`` package then you\nwill end up importing ``pkg.mod``. If you execute ``from ..subpkg2\nimport mod`` from within ``pkg.subpkg1`` you will import\n``pkg.subpkg2.mod``. The specification for relative imports is\ncontained within **PEP 328**.\n\n``importlib.import_module()`` is provided to support applications that\ndetermine which modules need to be loaded dynamically.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python. The future\nstatement is intended to ease migration to future versions of Python\nthat introduce incompatible changes to the language. It allows use of\nthe new features on a per-module basis before the release in which the\nfeature becomes standard.\n\n future_statement ::= "from" "__future__" "import" feature ["as" name]\n ("," feature ["as" name])*\n | "from" "__future__" "import" "(" feature ["as" name]\n ("," feature ["as" name])* [","] ")"\n feature ::= identifier\n name ::= identifier\n\nA future statement must appear near the top of the module. The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 3.0 are ``absolute_import``,\n``division``, ``generators``, ``unicode_literals``,\n``print_function``, ``nested_scopes`` and ``with_statement``. They\nare all redundant because they are always enabled, and only kept for\nbackwards compatibility.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code. It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently. Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module ``__future__``, described later, and it\nwill be imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by calls to the built-in functions ``exec()`` and\n``compile()`` that occur in a module ``M`` containing a future\nstatement will, by default, use the new syntax or semantics associated\nwith the future statement. This can be controlled by optional\narguments to ``compile()`` --- see the documentation of that function\nfor details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session. If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also:\n\n **PEP 236** - Back to the __future__\n The original proposal for the __future__ mechanism.\n',
+ 'in': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects. The objects need not have the same type.\nIf both are numbers, they are converted to a common type. Otherwise,\nthe ``==`` and ``!=`` operators *always* consider objects of different\ntypes to be unequal, while the ``<``, ``>``, ``>=`` and ``<=``\noperators raise a ``TypeError`` when comparing objects of different\ntypes that do not implement these operators for the given pair of\ntypes. You can control comparison behavior of objects of non-built-in\ntypes by defining rich comparison methods like ``__gt__()``, described\nin section *Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values ``float(\'NaN\')`` and ``Decimal(\'NaN\')`` are special. The\n are identical to themselves, ``x is x`` but are not equal to\n themselves, ``x != x``. Additionally, comparing any value to a\n not-a-number value will return ``False``. For example, both ``3 <\n float(\'NaN\')`` and ``float(\'NaN\') < 3`` will return ``False``.\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric equivalents\n (the result of the built-in function ``ord()``) of their characters.\n [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison of\n corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, ``[1,2,x] <= [1,2,y]`` has the\n same value as ``x <= y``. If the corresponding element does not\n exist, the shorter sequence is ordered first (for example, ``[1,2] <\n [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if they have the\n same ``(key, value)`` pairs. Order comparisons ``(\'<\', \'<=\', \'>=\',\n \'>\')`` raise ``TypeError``.\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, ``min()``, ``max()``, and ``sorted()`` produce\n undefined results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they are\n the same object; the choice whether one object is considered smaller\n or larger than another one is made arbitrarily but consistently\n within one execution of a program.\n\nComparison of objects of the differing types depends on whether either\nof the types provide explicit support for the comparison. Most\nnumeric types can be compared with one another, but comparisons of\n``float`` and ``Decimal`` are not supported to avoid the inevitable\nconfusion arising from representation issues such as ``float(\'1.1\')``\nbeing inexactly represented and therefore not exactly equal to\n``Decimal(\'1.1\')`` which is. When cross-type comparison is not\nsupported, the comparison method returns ``NotImplemented``. This can\ncreate the illusion of non-transitivity between supported cross-type\ncomparisons and unsupported comparisons. For example, ``Decimal(2) ==\n2`` and ``2 == float(2)`` but ``Decimal(2) != float(2)``.\n\nThe operators ``in`` and ``not in`` test for membership. ``x in s``\nevaluates to true if *x* is a member of *s*, and false otherwise. ``x\nnot in s`` returns the negation of ``x in s``. All built-in sequences\nand set types support this as well as dictionary, for which ``in``\ntests whether a the dictionary has a given key. For container types\nsuch as list, tuple, set, frozenset, dict, or collections.deque, the\nexpression ``x in y`` is equivalent to ``any(x is e or x == e for e in\ny)``.\n\nFor the string and bytes types, ``x in y`` is true if and only if *x*\nis a substring of *y*. An equivalent test is ``y.find(x) != -1``.\nEmpty strings are always considered to be a substring of any other\nstring, so ``"" in "abc"`` will return ``True``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` but do\ndefine ``__iter__()``, ``x in y`` is true if some value ``z`` with ``x\n== z`` is produced while iterating over ``y``. If an exception is\nraised during the iteration, it is as if ``in`` raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n``__getitem__()``, ``x in y`` is true if and only if there is a non-\nnegative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception. (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object. ``x is\nnot y`` yields the inverse truth value. [4]\n',
'integers': '\nInteger literals\n****************\n\nInteger literals are described by the following lexical definitions:\n\n integer ::= decimalinteger | octinteger | hexinteger | bininteger\n decimalinteger ::= nonzerodigit digit* | "0"+\n nonzerodigit ::= "1"..."9"\n digit ::= "0"..."9"\n octinteger ::= "0" ("o" | "O") octdigit+\n hexinteger ::= "0" ("x" | "X") hexdigit+\n bininteger ::= "0" ("b" | "B") bindigit+\n octdigit ::= "0"..."7"\n hexdigit ::= digit | "a"..."f" | "A"..."F"\n bindigit ::= "0" | "1"\n\nThere is no limit for the length of integer literals apart from what\ncan be stored in available memory.\n\nNote that leading zeros in a non-zero decimal number are not allowed.\nThis is for disambiguation with C-style octal literals, which Python\nused before version 3.0.\n\nSome examples of integer literals:\n\n 7 2147483647 0o177 0b100110111\n 3 79228162514264337593543950336 0o377 0x100000000\n 79228162514264337593543950336 0xdeadbeef\n',
'lambda': '\nLambdas\n*******\n\n lambda_form ::= "lambda" [parameter_list]: expression\n lambda_form_nocond ::= "lambda" [parameter_list]: expression_nocond\n\nLambda forms (lambda expressions) have the same syntactic position as\nexpressions. They are a shorthand to create anonymous functions; the\nexpression ``lambda arguments: expression`` yields a function object.\nThe unnamed object behaves like a function object defined with\n\n def <lambda>(arguments):\n return expression\n\nSee section *Function definitions* for the syntax of parameter lists.\nNote that functions created with lambda forms cannot contain\nstatements or annotations.\n',
'lists': '\nList displays\n*************\n\nA list display is a possibly empty series of expressions enclosed in\nsquare brackets:\n\n list_display ::= "[" [expression_list | comprehension] "]"\n\nA list display yields a new list object, the contents being specified\nby either a list of expressions or a comprehension. When a comma-\nseparated list of expressions is supplied, its elements are evaluated\nfrom left to right and placed into the list object in that order.\nWhen a comprehension is supplied, the list is constructed from the\nelements resulting from the comprehension.\n',
- 'naming': "\nNaming and binding\n******************\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\non the interpreter command line the first argument) is a code block.\nA script command (a command specified on the interpreter command line\nwith the '**-c**' option) is a code block. The string argument passed\nto the built-in functions ``eval()`` and ``exec()`` is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block's execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block's *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as ``nonlocal``. If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a ``NameError`` exception is raised.\nIf the name refers to a local variable that has not been bound, a\n``UnboundLocalError`` exception is raised. ``UnboundLocalError`` is a\nsubclass of ``NameError``.\n\nThe following constructs bind names: formal parameters to functions,\n``import`` statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, ``for`` loop header, or\nafter ``as`` in a ``with`` statement or :keyword.`except` clause. The\n``import`` statement of the form ``from ... import *`` binds all names\ndefined in the imported module, except those beginning with an\nunderscore. This form may only be used at the module level.\n\nA target occurring in a ``del`` statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name). It\nis illegal to unbind a name that is referenced by an enclosing scope;\nthe compiler will report a ``SyntaxError``.\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the ``global`` statement occurs within a block, all uses of the\nname specified in the statement refer to the binding of that name in\nthe top-level namespace. Names are resolved in the top-level\nnamespace by searching the global namespace, i.e. the namespace of the\nmodule containing the code block, and the builtin namespace, the\nnamespace of the module ``builtins``. The global namespace is\nsearched first. If the name is not found there, the builtin namespace\nis searched. The global statement must precede all uses of the name.\n\nThe built-in namespace associated with the execution of a code block\nis actually found by looking up the name ``__builtins__`` in its\nglobal namespace; this should be a dictionary or a module (in the\nlatter case the module's dictionary is used). By default, when in the\n``__main__`` module, ``__builtins__`` is the built-in module\n``builtins``; when in any other module, ``__builtins__`` is an alias\nfor the dictionary of the ``builtins`` module itself.\n``__builtins__`` can be set to a user-created dictionary to create a\nweak form of restricted execution.\n\nNote: Users should not touch ``__builtins__``; it is strictly an\n implementation detail. Users wanting to override values in the\n built-in namespace should ``import`` the ``builtins`` module and\n modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n``__main__``.\n\nThe global statement has the same scope as a name binding operation in\nthe same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n=================================\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n",
+ 'naming': "\nNaming and binding\n******************\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\non the interpreter command line the first argument) is a code block.\nA script command (a command specified on the interpreter command line\nwith the '**-c**' option) is a code block. The string argument passed\nto the built-in functions ``eval()`` and ``exec()`` is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block's execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block's *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as ``nonlocal``. If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a ``NameError`` exception is raised.\nIf the name refers to a local variable that has not been bound, a\n``UnboundLocalError`` exception is raised. ``UnboundLocalError`` is a\nsubclass of ``NameError``.\n\nThe following constructs bind names: formal parameters to functions,\n``import`` statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, ``for`` loop header, or\nafter ``as`` in a ``with`` statement or ``except`` clause. The\n``import`` statement of the form ``from ... import *`` binds all names\ndefined in the imported module, except those beginning with an\nunderscore. This form may only be used at the module level.\n\nA target occurring in a ``del`` statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name). It\nis illegal to unbind a name that is referenced by an enclosing scope;\nthe compiler will report a ``SyntaxError``.\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the ``global`` statement occurs within a block, all uses of the\nname specified in the statement refer to the binding of that name in\nthe top-level namespace. Names are resolved in the top-level\nnamespace by searching the global namespace, i.e. the namespace of the\nmodule containing the code block, and the builtins namespace, the\nnamespace of the module ``builtins``. The global namespace is\nsearched first. If the name is not found there, the builtins\nnamespace is searched. The global statement must precede all uses of\nthe name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name ``__builtins__`` in its\nglobal namespace; this should be a dictionary or a module (in the\nlatter case the module's dictionary is used). By default, when in the\n``__main__`` module, ``__builtins__`` is the built-in module\n``builtins``; when in any other module, ``__builtins__`` is an alias\nfor the dictionary of the ``builtins`` module itself.\n``__builtins__`` can be set to a user-created dictionary to create a\nweak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n``__builtins__``; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should ``import``\nthe ``builtins`` module and modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n``__main__``.\n\nThe ``global`` statement has the same scope as a name binding\noperation in the same block. If the nearest enclosing scope for a\nfree variable contains a global statement, the free variable is\ntreated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n=================================\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n",
+ 'nonlocal': '\nThe ``nonlocal`` statement\n**************************\n\n nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*\n\nThe ``nonlocal`` statement causes the listed identifiers to refer to\npreviously bound variables in the nearest enclosing scope. This is\nimportant because the default behavior for binding is to search the\nlocal namespace first. The statement allows encapsulated code to\nrebind variables outside of the local scope besides the global\n(module) scope.\n\nNames listed in a ``nonlocal`` statement, unlike to those listed in a\n``global`` statement, must refer to pre-existing bindings in an\nenclosing scope (the scope in which a new binding should be created\ncannot be determined unambiguously).\n\nNames listed in a ``nonlocal`` statement must not collide with pre-\nexisting bindings in the local scope.\n\nSee also:\n\n **PEP 3104** - Access to Names in Outer Scopes\n The specification for the ``nonlocal`` statement.\n\n-[ Footnotes ]-\n\n[1] It may occur within an ``except`` or ``else`` clause. The\n restriction on occurring in the ``try`` clause is implementor\'s\n laziness and will eventually be lifted.\n',
'numbers': "\nNumeric literals\n****************\n\nThere are three types of numeric literals: integers, floating point\nnumbers, and imaginary numbers. There are no complex literals\n(complex numbers can be formed by adding a real number and an\nimaginary number).\n\nNote that numeric literals do not include a sign; a phrase like ``-1``\nis actually an expression composed of the unary operator '``-``' and\nthe literal ``1``.\n",
- 'numeric-types': "\nEmulating numeric types\n***********************\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``). For instance, to evaluate the expression ``x + y``, where\n *x* is an instance of a class that has an ``__add__()`` method,\n ``x.__add__(y)`` is called. The ``__divmod__()`` method should be\n the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n should not be related to ``__truediv__()``. Note that\n ``__pow__()`` should be defined to accept an optional third\n argument if the ternary version of the built-in ``pow()`` function\n is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``) with reflected (swapped) operands. These functions are only\n called if the left operand does not support the corresponding\n operation and the operands are of different types. [3] For\n instance, to evaluate the expression ``x - y``, where *y* is an\n instance of a class that has an ``__rsub__()`` method,\n ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n *NotImplemented*.\n\n Note that ternary ``pow()`` will not try calling ``__rpow__()``\n (the coercion rules would become too complicated).\n\n Note: If the right operand's type is a subclass of the left operand's\n type and that subclass provides the reflected method for the\n operation, this method will be called before the left operand's\n non-reflected method. This behavior allows subclasses to\n override their ancestors' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``). These methods\n should attempt to do the operation in-place (modifying *self*) and\n return the result (which could be, but does not have to be,\n *self*). If a specific method is not defined, the augmented\n assignment falls back to the normal methods. For instance, to\n execute the statement ``x += y``, where *x* is an instance of a\n class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n called. If *x* is an instance of a class that does not define a\n ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations (``-``, ``+``,\n ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions ``complex()``,\n ``int()``, ``float()`` and ``round()``. Should return a value of\n the appropriate type.\n\nobject.__index__(self)\n\n Called to implement ``operator.index()``. Also called whenever\n Python needs an integer object (such as in slicing, or in the\n built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n an integer.\n",
- 'objects': '\nObjects, values and types\n*************************\n\n*Objects* are Python\'s abstraction for data. All data in a Python\nprogram is represented by objects or by relations between objects. (In\na sense, and in conformance to Von Neumann\'s model of a "stored\nprogram computer," code is also represented by objects.)\n\nEvery object has an identity, a type and a value. An object\'s\n*identity* never changes once it has been created; you may think of it\nas the object\'s address in memory. The \'``is``\' operator compares the\nidentity of two objects; the ``id()`` function returns an integer\nrepresenting its identity (currently implemented as its address). An\nobject\'s *type* is also unchangeable. [1] An object\'s type determines\nthe operations that the object supports (e.g., "does it have a\nlength?") and also defines the possible values for objects of that\ntype. The ``type()`` function returns an object\'s type (which is an\nobject itself). The *value* of some objects can change. Objects\nwhose value can change are said to be *mutable*; objects whose value\nis unchangeable once they are created are called *immutable*. (The\nvalue of an immutable container object that contains a reference to a\nmutable object can change when the latter\'s value is changed; however\nthe container is still considered immutable, because the collection of\nobjects it contains cannot be changed. So, immutability is not\nstrictly the same as having an unchangeable value, it is more subtle.)\nAn object\'s mutability is determined by its type; for instance,\nnumbers, strings and tuples are immutable, while dictionaries and\nlists are mutable.\n\nObjects are never explicitly destroyed; however, when they become\nunreachable they may be garbage-collected. An implementation is\nallowed to postpone garbage collection or omit it altogether --- it is\na matter of implementation quality how garbage collection is\nimplemented, as long as no objects are collected that are still\nreachable. (Implementation note: CPython currently uses a reference-\ncounting scheme with (optional) delayed detection of cyclically linked\ngarbage, which collects most objects as soon as they become\nunreachable, but is not guaranteed to collect garbage containing\ncircular references. See the documentation of the ``gc`` module for\ninformation on controlling the collection of cyclic garbage. Other\nimplementations act differently and CPython may change.)\n\nNote that the use of the implementation\'s tracing or debugging\nfacilities may keep objects alive that would normally be collectable.\nAlso note that catching an exception with a \'``try``...``except``\'\nstatement may keep objects alive.\n\nSome objects contain references to "external" resources such as open\nfiles or windows. It is understood that these resources are freed\nwhen the object is garbage-collected, but since garbage collection is\nnot guaranteed to happen, such objects also provide an explicit way to\nrelease the external resource, usually a ``close()`` method. Programs\nare strongly recommended to explicitly close such objects. The\n\'``try``...``finally``\' statement and the \'``with``\' statement provide\nconvenient ways to do this.\n\nSome objects contain references to other objects; these are called\n*containers*. Examples of containers are tuples, lists and\ndictionaries. The references are part of a container\'s value. In\nmost cases, when we talk about the value of a container, we imply the\nvalues, not the identities of the contained objects; however, when we\ntalk about the mutability of a container, only the identities of the\nimmediately contained objects are implied. So, if an immutable\ncontainer (like a tuple) contains a reference to a mutable object, its\nvalue changes if that mutable object is changed.\n\nTypes affect almost all aspects of object behavior. Even the\nimportance of object identity is affected in some sense: for immutable\ntypes, operations that compute new values may actually return a\nreference to any existing object with the same type and value, while\nfor mutable objects this is not allowed. E.g., after ``a = 1; b =\n1``, ``a`` and ``b`` may or may not refer to the same object with the\nvalue one, depending on the implementation, but after ``c = []; d =\n[]``, ``c`` and ``d`` are guaranteed to refer to two different,\nunique, newly created empty lists. (Note that ``c = d = []`` assigns\nthe same object to both ``c`` and ``d``.)\n',
- 'operator-summary': '\nSummary\n*******\n\nThe following table summarizes the operator precedences in Python,\nfrom lowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for comparisons, including\ntests, which all have the same precedence and chain from left to right\n--- see section *Comparisons* --- and exponentiation, which groups\nfrom right to left).\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| ``lambda`` | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| ``or`` | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| ``and`` | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| ``not`` *x* | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| ``in``, ``not`` ``in``, ``is``, ``is not``, | Comparisons, including membership |\n| ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``==`` | tests and identity tests, |\n+-------------------------------------------------+---------------------------------------+\n| ``|`` | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| ``^`` | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| ``&`` | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| ``<<``, ``>>`` | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| ``+``, ``-`` | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder |\n+-------------------------------------------------+---------------------------------------+\n| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| ``**`` | Exponentiation [7] |\n+-------------------------------------------------+---------------------------------------+\n| ``x[index]``, ``x[index:index]``, | Subscription, slicing, call, |\n| ``x(arguments...)``, ``x.attribute`` | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| ``(expressions...)``, ``[expressions...]``, | Binding or tuple display, list |\n| ``{key:datum...}``, | display, dictionary display, |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While ``abs(x%y) < abs(y)`` is true mathematically, for floats it\n may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that ``-1e-100 % 1e100`` have the same\n sign as ``1e100``, the computed result is ``-1e-100 + 1e100``,\n which is numerically exactly equal to ``1e100``. Function\n ``fmod()`` in the ``math`` module returns a result whose sign\n matches the sign of the first argument instead, and so returns\n ``-1e-100`` in this case. Which approach is more appropriate\n depends on the application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n possible for ``x//y`` to be one larger than ``(x-x%y)//y`` due to\n rounding. In such cases, Python returns the latter result, in\n order to preserve that ``divmod(x,y)[0] * y + x % y`` be very\n close to ``x``.\n\n[3] While comparisons between strings make sense at the byte level,\n they may be counter-intuitive to users. For example, the strings\n ``"\\u00C7"`` and ``"\\u0327\\u0043"`` compare differently, even\n though they both represent the same unicode character (LATIN\n CAPITAL LETTER C WITH CEDILLA). To compare strings in a human\n recognizable way, compare using ``unicodedata.normalize()``.\n\n[4] The implementation computes this efficiently, without constructing\n lists or sorting.\n\n[5] Earlier versions of Python used lexicographic comparison of the\n sorted (key, value) lists, but this was very expensive for the\n common case of comparing for equality. An even earlier version of\n Python compared dictionaries by identity only, but this caused\n surprises because people expected to be able to test a dictionary\n for emptiness by comparing it to ``{}``.\n\n[6] Due to automatic garbage-collection, free lists, and the dynamic\n nature of descriptors, you may notice seemingly unusual behaviour\n in certain uses of the ``is`` operator, like those involving\n comparisons between instance methods, or constants. Check their\n documentation for more info.\n\n[7] The power operator ``**`` binds less tightly than an arithmetic or\n bitwise unary operator on its right, that is, ``2**-1`` is\n ``0.5``.\n',
+ 'numeric-types': "\nEmulating numeric types\n***********************\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``). For instance, to evaluate the expression ``x + y``, where\n *x* is an instance of a class that has an ``__add__()`` method,\n ``x.__add__(y)`` is called. The ``__divmod__()`` method should be\n the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n should not be related to ``__truediv__()``. Note that\n ``__pow__()`` should be defined to accept an optional third\n argument if the ternary version of the built-in ``pow()`` function\n is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``) with reflected (swapped) operands. These functions are only\n called if the left operand does not support the corresponding\n operation and the operands are of different types. [2] For\n instance, to evaluate the expression ``x - y``, where *y* is an\n instance of a class that has an ``__rsub__()`` method,\n ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n *NotImplemented*.\n\n Note that ternary ``pow()`` will not try calling ``__rpow__()``\n (the coercion rules would become too complicated).\n\n Note: If the right operand's type is a subclass of the left operand's\n type and that subclass provides the reflected method for the\n operation, this method will be called before the left operand's\n non-reflected method. This behavior allows subclasses to\n override their ancestors' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``). These methods\n should attempt to do the operation in-place (modifying *self*) and\n return the result (which could be, but does not have to be,\n *self*). If a specific method is not defined, the augmented\n assignment falls back to the normal methods. For instance, to\n execute the statement ``x += y``, where *x* is an instance of a\n class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n called. If *x* is an instance of a class that does not define a\n ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations (``-``, ``+``,\n ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions ``complex()``,\n ``int()``, ``float()`` and ``round()``. Should return a value of\n the appropriate type.\n\nobject.__index__(self)\n\n Called to implement ``operator.index()``. Also called whenever\n Python needs an integer object (such as in slicing, or in the\n built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n an integer.\n",
+ 'objects': '\nObjects, values and types\n*************************\n\n*Objects* are Python\'s abstraction for data. All data in a Python\nprogram is represented by objects or by relations between objects. (In\na sense, and in conformance to Von Neumann\'s model of a "stored\nprogram computer," code is also represented by objects.)\n\nEvery object has an identity, a type and a value. An object\'s\n*identity* never changes once it has been created; you may think of it\nas the object\'s address in memory. The \'``is``\' operator compares the\nidentity of two objects; the ``id()`` function returns an integer\nrepresenting its identity (currently implemented as its address). An\nobject\'s *type* is also unchangeable. [1] An object\'s type determines\nthe operations that the object supports (e.g., "does it have a\nlength?") and also defines the possible values for objects of that\ntype. The ``type()`` function returns an object\'s type (which is an\nobject itself). The *value* of some objects can change. Objects\nwhose value can change are said to be *mutable*; objects whose value\nis unchangeable once they are created are called *immutable*. (The\nvalue of an immutable container object that contains a reference to a\nmutable object can change when the latter\'s value is changed; however\nthe container is still considered immutable, because the collection of\nobjects it contains cannot be changed. So, immutability is not\nstrictly the same as having an unchangeable value, it is more subtle.)\nAn object\'s mutability is determined by its type; for instance,\nnumbers, strings and tuples are immutable, while dictionaries and\nlists are mutable.\n\nObjects are never explicitly destroyed; however, when they become\nunreachable they may be garbage-collected. An implementation is\nallowed to postpone garbage collection or omit it altogether --- it is\na matter of implementation quality how garbage collection is\nimplemented, as long as no objects are collected that are still\nreachable.\n\n**CPython implementation detail:** CPython currently uses a reference-\ncounting scheme with (optional) delayed detection of cyclically linked\ngarbage, which collects most objects as soon as they become\nunreachable, but is not guaranteed to collect garbage containing\ncircular references. See the documentation of the ``gc`` module for\ninformation on controlling the collection of cyclic garbage. Other\nimplementations act differently and CPython may change.\n\nNote that the use of the implementation\'s tracing or debugging\nfacilities may keep objects alive that would normally be collectable.\nAlso note that catching an exception with a \'``try``...``except``\'\nstatement may keep objects alive.\n\nSome objects contain references to "external" resources such as open\nfiles or windows. It is understood that these resources are freed\nwhen the object is garbage-collected, but since garbage collection is\nnot guaranteed to happen, such objects also provide an explicit way to\nrelease the external resource, usually a ``close()`` method. Programs\nare strongly recommended to explicitly close such objects. The\n\'``try``...``finally``\' statement and the \'``with``\' statement provide\nconvenient ways to do this.\n\nSome objects contain references to other objects; these are called\n*containers*. Examples of containers are tuples, lists and\ndictionaries. The references are part of a container\'s value. In\nmost cases, when we talk about the value of a container, we imply the\nvalues, not the identities of the contained objects; however, when we\ntalk about the mutability of a container, only the identities of the\nimmediately contained objects are implied. So, if an immutable\ncontainer (like a tuple) contains a reference to a mutable object, its\nvalue changes if that mutable object is changed.\n\nTypes affect almost all aspects of object behavior. Even the\nimportance of object identity is affected in some sense: for immutable\ntypes, operations that compute new values may actually return a\nreference to any existing object with the same type and value, while\nfor mutable objects this is not allowed. E.g., after ``a = 1; b =\n1``, ``a`` and ``b`` may or may not refer to the same object with the\nvalue one, depending on the implementation, but after ``c = []; d =\n[]``, ``c`` and ``d`` are guaranteed to refer to two different,\nunique, newly created empty lists. (Note that ``c = d = []`` assigns\nthe same object to both ``c`` and ``d``.)\n',
+ 'operator-summary': '\nSummary\n*******\n\nThe following table summarizes the operator precedences in Python,\nfrom lowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for comparisons, including\ntests, which all have the same precedence and chain from left to right\n--- see section *Comparisons* --- and exponentiation, which groups\nfrom right to left).\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| ``lambda`` | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| ``if`` -- ``else`` | Conditional expression |\n+-------------------------------------------------+---------------------------------------+\n| ``or`` | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| ``and`` | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| ``not`` *x* | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| ``in``, ``not`` ``in``, ``is``, ``is not``, | Comparisons, including membership |\n| ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``==`` | tests and identity tests, |\n+-------------------------------------------------+---------------------------------------+\n| ``|`` | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| ``^`` | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| ``&`` | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| ``<<``, ``>>`` | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| ``+``, ``-`` | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder |\n| | [5] |\n+-------------------------------------------------+---------------------------------------+\n| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| ``**`` | Exponentiation [6] |\n+-------------------------------------------------+---------------------------------------+\n| ``x[index]``, ``x[index:index]``, | Subscription, slicing, call, |\n| ``x(arguments...)``, ``x.attribute`` | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| ``(expressions...)``, ``[expressions...]``, | Binding or tuple display, list |\n| ``{key:datum...}``, ``{expressions...}`` | display, dictionary display, set |\n| | display |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While ``abs(x%y) < abs(y)`` is true mathematically, for floats it\n may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that ``-1e-100 % 1e100`` have the same\n sign as ``1e100``, the computed result is ``-1e-100 + 1e100``,\n which is numerically exactly equal to ``1e100``. The function\n ``math.fmod()`` returns a result whose sign matches the sign of\n the first argument instead, and so returns ``-1e-100`` in this\n case. Which approach is more appropriate depends on the\n application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n possible for ``x//y`` to be one larger than ``(x-x%y)//y`` due to\n rounding. In such cases, Python returns the latter result, in\n order to preserve that ``divmod(x,y)[0] * y + x % y`` be very\n close to ``x``.\n\n[3] While comparisons between strings make sense at the byte level,\n they may be counter-intuitive to users. For example, the strings\n ``"\\u00C7"`` and ``"\\u0327\\u0043"`` compare differently, even\n though they both represent the same unicode character (LATIN\n CAPITAL LETTER C WITH CEDILLA). To compare strings in a human\n recognizable way, compare using ``unicodedata.normalize()``.\n\n[4] Due to automatic garbage-collection, free lists, and the dynamic\n nature of descriptors, you may notice seemingly unusual behaviour\n in certain uses of the ``is`` operator, like those involving\n comparisons between instance methods, or constants. Check their\n documentation for more info.\n\n[5] The ``%`` operator is also used for string formatting; the same\n precedence applies.\n\n[6] The power operator ``**`` binds less tightly than an arithmetic or\n bitwise unary operator on its right, that is, ``2**-1`` is\n ``0.5``.\n',
'pass': '\nThe ``pass`` statement\n**********************\n\n pass_stmt ::= "pass"\n\n``pass`` is a null operation --- when it is executed, nothing happens.\nIt is useful as a placeholder when a statement is required\nsyntactically, but no code needs to be executed, for example:\n\n def f(arg): pass # a function that does nothing (yet)\n\n class C: pass # a class with no methods (yet)\n',
'power': '\nThe power operator\n******************\n\nThe power operator binds more tightly than unary operators on its\nleft; it binds less tightly than unary operators on its right. The\nsyntax is:\n\n power ::= primary ["**" u_expr]\n\nThus, in an unparenthesized sequence of power and unary operators, the\noperators are evaluated from right to left (this does not constrain\nthe evaluation order for the operands): ``-1**2`` results in ``-1``.\n\nThe power operator has the same semantics as the built-in ``pow()``\nfunction, when called with two arguments: it yields its left argument\nraised to the power of its right argument. The numeric arguments are\nfirst converted to a common type, and the result is of that type.\n\nFor int operands, the result has the same type as the operands unless\nthe second argument is negative; in that case, all arguments are\nconverted to float and a float result is delivered. For example,\n``10**2`` returns ``100``, but ``10**-2`` returns ``0.01``.\n\nRaising ``0.0`` to a negative power results in a\n``ZeroDivisionError``. Raising a negative number to a fractional power\nresults in a ``complex`` number. (In earlier versions it raised a\n``ValueError``.)\n',
'raise': '\nThe ``raise`` statement\n***********************\n\n raise_stmt ::= "raise" [expression ["from" expression]]\n\nIf no expressions are present, ``raise`` re-raises the last exception\nthat was active in the current scope. If no exception is active in\nthe current scope, a ``TypeError`` exception is raised indicating that\nthis is an error (if running under IDLE, a ``queue.Empty`` exception\nis raised instead).\n\nOtherwise, ``raise`` evaluates the first expression as the exception\nobject. It must be either a subclass or an instance of\n``BaseException``. If it is a class, the exception instance will be\nobtained when needed by instantiating the class with no arguments.\n\nThe *type* of the exception is the exception instance\'s class, the\n*value* is the instance itself.\n\nA traceback object is normally created automatically when an exception\nis raised and attached to it as the ``__traceback__`` attribute, which\nis writable. You can create an exception and set your own traceback in\none step using the ``with_traceback()`` exception method (which\nreturns the same exception instance, with its traceback set to its\nargument), like so:\n\n raise Exception("foo occurred").with_traceback(tracebackobj)\n\nThe ``from`` clause is used for exception chaining: if given, the\nsecond *expression* must be another exception class or instance, which\nwill then be attached to the raised exception as the ``__cause__``\nattribute (which is writable). If the raised exception is not\nhandled, both exceptions will be printed:\n\n >>> try:\n ... print(1 / 0)\n ... except Exception as exc:\n ... raise RuntimeError("Something bad happened") from exc\n ...\n Traceback (most recent call last):\n File "<stdin>", line 2, in <module>\n ZeroDivisionError: int division or modulo by zero\n\n The above exception was the direct cause of the following exception:\n\n Traceback (most recent call last):\n File "<stdin>", line 4, in <module>\n RuntimeError: Something bad happened\n\nA similar mechanism works implicitly if an exception is raised inside\nan exception handler: the previous exception is then attached as the\nnew exception\'s ``__context__`` attribute:\n\n >>> try:\n ... print(1 / 0)\n ... except:\n ... raise RuntimeError("Something bad happened")\n ...\n Traceback (most recent call last):\n File "<stdin>", line 2, in <module>\n ZeroDivisionError: int division or modulo by zero\n\n During handling of the above exception, another exception occurred:\n\n Traceback (most recent call last):\n File "<stdin>", line 4, in <module>\n RuntimeError: Something bad happened\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information about handling exceptions is in section\n*The try statement*.\n',
- 'return': '\nThe ``return`` statement\n************************\n\n return_stmt ::= "return" [expression_list]\n\n``return`` may only occur syntactically nested in a function\ndefinition, not within a nested class definition.\n\nIf an expression list is present, it is evaluated, else ``None`` is\nsubstituted.\n\n``return`` leaves the current function call with the expression list\n(or ``None``) as return value.\n\nWhen ``return`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nleaving the function.\n\nIn a generator function, the ``return`` statement is not allowed to\ninclude an **expression_list**. In that context, a bare ``return``\nindicates that the generator is done and will cause ``StopIteration``\nto be raised.\n',
- 'sequence-types': "\nEmulating container types\n*************************\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items. It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``get()``,\n``clear()``, ``setdefault()``, ``pop()``, ``popitem()``, ``copy()``,\nand ``update()`` behaving similar to those for Python's standard\ndictionary objects. The ``collections`` module provides a\n``MutableMapping`` abstract base class to help create those methods\nfrom a base set of ``__getitem__()``, ``__setitem__()``,\n``__delitem__()``, and ``keys()``. Mutable sequences should provide\nmethods ``append()``, ``count()``, ``index()``, ``extend()``,\n``insert()``, ``pop()``, ``remove()``, ``reverse()`` and ``sort()``,\nlike Python standard list objects. Finally, sequence types should\nimplement addition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods ``__add__()``, ``__radd__()``,\n``__iadd__()``, ``__mul__()``, ``__rmul__()`` and ``__imul__()``\ndescribed below; they should not define other numerical operators. It\nis recommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should search the mapping's keys; for\nsequences, it should search through the values. It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``keys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function ``len()``. Should return\n the length of the object, an integer ``>=`` 0. Also, an object\n that doesn't define a ``__bool__()`` method and whose ``__len__()``\n method returns zero is considered to be false in a Boolean context.\n\nNote: Slicing is done exclusively with the following three methods. A\n call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with\n ``None``.\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of ``self[key]``. For sequence\n types, the accepted keys should be integers and slice objects.\n Note that the special interpretation of negative indexes (if the\n class wishes to emulate a sequence type) is up to the\n ``__getitem__()`` method. If *key* is of an inappropriate type,\n ``TypeError`` may be raised; if of a value outside the set of\n indexes for the sequence (after any special interpretation of\n negative values), ``IndexError`` should be raised. For mapping\n types, if *key* is missing (not in the container), ``KeyError``\n should be raised.\n\n Note: ``for`` loops expect that an ``IndexError`` will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the ``__getitem__()``\n method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container, and should also be made\n available as the method ``keys()``.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the ``reversed()`` builtin to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the ``__reversed__()`` method is not provided, the\n ``reversed()`` builtin will fall back to using the sequence\n protocol (``__len__()`` and ``__getitem__()``). Objects that\n support the sequence protocol should only provide\n ``__reversed__()`` if they can provide an implementation that is\n more efficient than the one provided by ``reversed()``.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n",
- 'shifting': '\nShifting operations\n*******************\n\nThe shifting operations have lower priority than the arithmetic\noperations:\n\n shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n\nThese operators accept integers as arguments. They shift the first\nargument to the left or right by the number of bits given by the\nsecond argument.\n\nA right shift by *n* bits is defined as division by ``pow(2,n)``. A\nleft shift by *n* bits is defined as multiplication with ``pow(2,n)``.\n',
+ 'return': '\nThe ``return`` statement\n************************\n\n return_stmt ::= "return" [expression_list]\n\n``return`` may only occur syntactically nested in a function\ndefinition, not within a nested class definition.\n\nIf an expression list is present, it is evaluated, else ``None`` is\nsubstituted.\n\n``return`` leaves the current function call with the expression list\n(or ``None``) as return value.\n\nWhen ``return`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nleaving the function.\n\nIn a generator function, the ``return`` statement is not allowed to\ninclude an ``expression_list``. In that context, a bare ``return``\nindicates that the generator is done and will cause ``StopIteration``\nto be raised.\n',
+ 'sequence-types': "\nEmulating container types\n*************************\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items. It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``get()``,\n``clear()``, ``setdefault()``, ``pop()``, ``popitem()``, ``copy()``,\nand ``update()`` behaving similar to those for Python's standard\ndictionary objects. The ``collections`` module provides a\n``MutableMapping`` abstract base class to help create those methods\nfrom a base set of ``__getitem__()``, ``__setitem__()``,\n``__delitem__()``, and ``keys()``. Mutable sequences should provide\nmethods ``append()``, ``count()``, ``index()``, ``extend()``,\n``insert()``, ``pop()``, ``remove()``, ``reverse()`` and ``sort()``,\nlike Python standard list objects. Finally, sequence types should\nimplement addition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods ``__add__()``, ``__radd__()``,\n``__iadd__()``, ``__mul__()``, ``__rmul__()`` and ``__imul__()``\ndescribed below; they should not define other numerical operators. It\nis recommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should search the mapping's keys; for\nsequences, it should search through the values. It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``keys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function ``len()``. Should return\n the length of the object, an integer ``>=`` 0. Also, an object\n that doesn't define a ``__bool__()`` method and whose ``__len__()``\n method returns zero is considered to be false in a Boolean context.\n\nNote: Slicing is done exclusively with the following three methods. A\n call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with\n ``None``.\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of ``self[key]``. For sequence\n types, the accepted keys should be integers and slice objects.\n Note that the special interpretation of negative indexes (if the\n class wishes to emulate a sequence type) is up to the\n ``__getitem__()`` method. If *key* is of an inappropriate type,\n ``TypeError`` may be raised; if of a value outside the set of\n indexes for the sequence (after any special interpretation of\n negative values), ``IndexError`` should be raised. For mapping\n types, if *key* is missing (not in the container), ``KeyError``\n should be raised.\n\n Note: ``for`` loops expect that an ``IndexError`` will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the ``__getitem__()``\n method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container, and should also be made\n available as the method ``keys()``.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the ``reversed()`` built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the ``__reversed__()`` method is not provided, the\n ``reversed()`` built-in will fall back to using the sequence\n protocol (``__len__()`` and ``__getitem__()``). Objects that\n support the sequence protocol should only provide\n ``__reversed__()`` if they can provide an implementation that is\n more efficient than the one provided by ``reversed()``.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don't define ``__contains__()``, the membership\n test first tries iteration via ``__iter__()``, then the old\n sequence iteration protocol via ``__getitem__()``, see *this\n section in the language reference*.\n",
+ 'shifting': '\nShifting operations\n*******************\n\nThe shifting operations have lower priority than the arithmetic\noperations:\n\n shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n\nThese operators accept integers as arguments. They shift the first\nargument to the left or right by the number of bits given by the\nsecond argument.\n\nA right shift by *n* bits is defined as division by ``pow(2,n)``. A\nleft shift by *n* bits is defined as multiplication with ``pow(2,n)``.\n\nNote: In the current implementation, the right-hand operand is required to\n be at most ``sys.maxsize``. If the right-hand operand is larger\n than ``sys.maxsize`` an ``OverflowError`` exception is raised.\n',
'slicings': '\nSlicings\n********\n\nA slicing selects a range of items in a sequence object (e.g., a\nstring, tuple or list). Slicings may be used as expressions or as\ntargets in assignment or ``del`` statements. The syntax for a\nslicing:\n\n slicing ::= primary "[" slice_list "]"\n slice_list ::= slice_item ("," slice_item)* [","]\n slice_item ::= expression | proper_slice\n proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]\n lower_bound ::= expression\n upper_bound ::= expression\n stride ::= expression\n\nThere is ambiguity in the formal syntax here: anything that looks like\nan expression list also looks like a slice list, so any subscription\ncan be interpreted as a slicing. Rather than further complicating the\nsyntax, this is disambiguated by defining that in this case the\ninterpretation as a subscription takes priority over the\ninterpretation as a slicing (this is the case if the slice list\ncontains no proper slice).\n\nThe semantics for a slicing are as follows. The primary must evaluate\nto a mapping object, and it is indexed (using the same\n``__getitem__()`` method as normal subscription) with a key that is\nconstructed from the slice list, as follows. If the slice list\ncontains at least one comma, the key is a tuple containing the\nconversion of the slice items; otherwise, the conversion of the lone\nslice item is the key. The conversion of a slice item that is an\nexpression is that expression. The conversion of a proper slice is a\nslice object (see section *The standard type hierarchy*) whose\n``start``, ``stop`` and ``step`` attributes are the values of the\nexpressions given as lower bound, upper bound and stride,\nrespectively, substituting ``None`` for missing expressions.\n',
- 'specialattrs': "\nSpecial Attributes\n******************\n\nThe implementation adds a few special read-only attributes to several\nobject types, where they are relevant. Some of these are not reported\nby the ``dir()`` built-in function.\n\nobject.__dict__\n\n A dictionary or other mapping object used to store an object's\n (writable) attributes.\n\ninstance.__class__\n\n The class to which a class instance belongs.\n\nclass.__bases__\n\n The tuple of base classes of a class object. If there are no base\n classes, this will be an empty tuple.\n\nclass.__name__\n\n The name of the class or type.\n\nThe following attributes are only supported by *new-style class*es.\n\nclass.__mro__\n\n This attribute is a tuple of classes that are considered when\n looking for base classes during method resolution.\n\nclass.mro()\n\n This method can be overridden by a metaclass to customize the\n method resolution order for its instances. It is called at class\n instantiation, and its result is stored in ``__mro__``.\n\nclass.__subclasses__()\n\n Each new-style class keeps a list of weak references to its\n immediate subclasses. This method returns a list of all those\n references still alive. Example:\n\n >>> int.__subclasses__()\n [<type 'bool'>]\n\n-[ Footnotes ]-\n\n[1] Additional information on these special methods may be found in\n the Python Reference Manual (*Basic customization*).\n\n[2] As a consequence, the list ``[1, 2]`` is considered equal to\n ``[1.0, 2.0]``, and similarly for tuples.\n\n[3] They must have since the parser can't tell the type of the\n operands.\n\n[4] To format only a tuple you should therefore provide a singleton\n tuple whose only element is the tuple to be formatted.\n\n[5] The advantage of leaving the newline on is that returning an empty\n string is then an unambiguous EOF indication. It is also possible\n (in cases where it might matter, for example, if you want to make\n an exact copy of a file while scanning its lines) to tell whether\n the last line of a file ended in a newline or not (yes this\n happens!).\n",
- 'specialnames': '\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named ``__getitem__()``, and ``x`` is an instance of this\nclass, then ``x[i]`` is roughly equivalent to ``type(x).__getitem__(x,\ni)``. Except where mentioned, attempts to execute an operation raise\nan exception when no appropriate method is defined (typically\n``AttributeError`` or ``TypeError``).\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n``NodeList`` interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. ``__new__()`` is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of ``__new__()`` should be the new object instance (usually\n an instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s ``__new__()`` method using\n ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If ``__new__()`` returns an instance of *cls*, then the new\n instance\'s ``__init__()`` method will be invoked like\n ``__init__(self[, ...])``, where *self* is the new instance and the\n remaining arguments are the same as were passed to ``__new__()``.\n\n If ``__new__()`` does not return an instance of *cls*, then the new\n instance\'s ``__init__()`` method will not be invoked.\n\n ``__new__()`` is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called when the instance is created. The arguments are those\n passed to the class constructor expression. If a base class has an\n ``__init__()`` method, the derived class\'s ``__init__()`` method,\n if any, must explicitly call it to ensure proper initialization of\n the base class part of the instance; for example:\n ``BaseClass.__init__(self, [args...])``. As a special constraint\n on constructors, no value may be returned; doing so will cause a\n ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a ``__del__()`` method,\n the derived class\'s ``__del__()`` method, if any, must explicitly\n call it to ensure proper deletion of the base class part of the\n instance. Note that it is possible (though not recommended!) for\n the ``__del__()`` method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n ``__del__()`` methods are called for objects that still exist when\n the interpreter exits.\n\n Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n decrements the reference count for ``x`` by one, and the latter\n is only called when ``x``\'s reference count reaches zero. Some\n common situations that may prevent the reference count of an\n object from going to zero include: circular references between\n objects (e.g., a doubly-linked list or a tree data structure with\n parent and child pointers); a reference to the object on the\n stack frame of a function that caught an exception (the traceback\n stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n a reference to the object on the stack frame that raised an\n unhandled exception in interactive mode (the traceback stored in\n ``sys.last_traceback`` keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the latter two situations can be resolved by storing ``None`` in\n ``sys.last_traceback``. Circular references which are garbage are\n detected when the option cycle detector is enabled (it\'s on by\n default), but can only be cleaned up if there are no Python-\n level ``__del__()`` methods involved. Refer to the documentation\n for the ``gc`` module for more information about how\n ``__del__()`` methods are handled by the cycle detector,\n particularly the description of the ``garbage`` value.\n\n Warning: Due to the precarious circumstances under which ``__del__()``\n methods are invoked, exceptions that occur during their execution\n are ignored, and a warning is printed to ``sys.stderr`` instead.\n Also, when ``__del__()`` is invoked in response to a module being\n deleted (e.g., when execution of the program is done), other\n globals referenced by the ``__del__()`` method may already have\n been deleted or in the process of being torn down (e.g. the\n import machinery shutting down). For this reason, ``__del__()``\n methods should do the absolute minimum needed to maintain\n external invariants. Starting with version 1.5, Python\n guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n Called by the ``repr()`` built-in function to compute the\n "official" string representation of an object. If at all possible,\n this should look like a valid Python expression that could be used\n to recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n ``<...some useful description...>`` should be returned. The return\n value must be a string object. If a class defines ``__repr__()``\n but not ``__str__()``, then ``__repr__()`` is also used when an\n "informal" string representation of instances of that class is\n required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by the ``str()`` built-in function and by the ``print()``\n function to compute the "informal" string representation of an\n object. This differs from ``__repr__()`` in that it does not have\n to be a valid Python expression: a more convenient or concise\n representation may be used instead. The return value must be a\n string object.\n\nobject.__format__(self, format_spec)\n\n Called by the ``format()`` built-in function (and by extension, the\n ``format()`` method of class ``str``) to produce a "formatted"\n string representation of an object. The ``format_spec`` argument is\n a string that contains a description of the formatting options\n desired. The interpretation of the ``format_spec`` argument is up\n to the type implementing ``__format__()``, however most classes\n will either delegate formatting to one of the built-in types, or\n use a similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n ``x.__ge__(y)``.\n\n A rich comparison method may return the singleton\n ``NotImplemented`` if it does not implement the operation for a\n given pair of arguments. By convention, ``False`` and ``True`` are\n returned for a successful comparison. However, these methods can\n return any value, so if the comparison operator is used in a\n Boolean context (e.g., in the condition of an ``if`` statement),\n Python will call ``bool()`` on the value to determine if the result\n is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of ``x==y`` does not imply that ``x!=y`` is false.\n Accordingly, when defining ``__eq__()``, one should also define\n ``__ne__()`` so that the operators will behave as expected. See\n the paragraph on ``__hash__()`` for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n reflection, and ``__eq__()`` and ``__ne__()`` are their own\n reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see the Total Ordering recipe in the ASPN cookbook.\n\nobject.__hash__(self)\n\n Called by built-in function ``hash()`` and for operations on\n members of hashed collections including ``set``, ``frozenset``, and\n ``dict``. ``__hash__()`` should return an integer. The only\n required property is that objects which compare equal have the same\n hash value; it is advised to somehow mix together (e.g. using\n exclusive or) the hash values for the components of the object that\n also play a part in comparison of objects.\n\n If a class does not define an ``__eq__()`` method it should not\n define a ``__hash__()`` operation either; if it defines\n ``__eq__()`` but not ``__hash__()``, its instances will not be\n usable as items in hashable collections. If a class defines\n mutable objects and implements an ``__eq__()`` method, it should\n not implement ``__hash__()``, since the implementation of hashable\n collections requires that a key\'s hash value is immutable (if the\n object\'s hash value changes, it will be in the wrong hash bucket).\n\n User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n by default; with them, all objects compare unequal (except with\n themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n Classes which inherit a ``__hash__()`` method from a parent class\n but change the meaning of ``__eq__()`` such that the hash value\n returned is no longer appropriate (e.g. by switching to a value-\n based concept of equality instead of the default identity based\n equality) can explicitly flag themselves as being unhashable by\n setting ``__hash__ = None`` in the class definition. Doing so means\n that not only will instances of the class raise an appropriate\n ``TypeError`` when a program attempts to retrieve their hash value,\n but they will also be correctly identified as unhashable when\n checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n which define their own ``__hash__()`` to explicitly raise\n ``TypeError``).\n\n If a class that overrides ``__eq__()`` needs to retain the\n implementation of ``__hash__()`` from a parent class, the\n interpreter must be told this explicitly by setting ``__hash__ =\n <ParentClass>.__hash__``. Otherwise the inheritance of\n ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n explicitly set to ``None``.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n ``bool()``; should return ``False`` or ``True``, or their integer\n equivalents ``0`` or ``1``. When this method is not defined,\n ``__len__()`` is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither ``__len__()`` nor ``__bool__()``, all its instances are\n considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for ``self``). ``name`` is the attribute name.\n This method should return the (computed) attribute value or raise\n an ``AttributeError`` exception.\n\n Note that if the attribute is found through the normal mechanism,\n ``__getattr__()`` is not called. (This is an intentional asymmetry\n between ``__getattr__()`` and ``__setattr__()``.) This is done both\n for efficiency reasons and because otherwise ``__getattr__()``\n would have no way to access other attributes of the instance. Note\n that at least for instance variables, you can fake total control by\n not inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n ``__getattribute__()`` method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines\n ``__getattr__()``, the latter will not be called unless\n ``__getattribute__()`` either calls it explicitly or raises an\n ``AttributeError``. This method should return the (computed)\n attribute value or raise an ``AttributeError`` exception. In order\n to avoid infinite recursion in this method, its implementation\n should always call the base class method with the same name to\n access any attributes it needs, for example,\n ``object.__getattribute__(self, name)``.\n\n Note: This method may still be bypassed when looking up special methods\n as the result of implicit invocation via language syntax or\n builtin functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If ``__setattr__()`` wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n Like ``__setattr__()`` but for attribute deletion instead of\n assignment. This should only be implemented if ``del obj.name`` is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when ``dir()`` is called on the object. A list must be\n returned.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in the\nclass dictionary of another class, known as the *owner* class. In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or ``None`` when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an\n ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: ``x.__get__(a)``.\n\nInstance Binding\n If binding to an object instance, ``a.x`` is transformed into the\n call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n If binding to a class, ``A.x`` is transformed into the call:\n ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n If ``a`` is an instance of ``super``, then the binding ``super(B,\n obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n ``A`` immediately preceding ``B`` and then invokes the descriptor\n with the call: ``A.__dict__[\'m\'].__get__(obj, A)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. Normally, data\ndescriptors define both ``__get__()`` and ``__set__()``, while non-\ndata descriptors have just the ``__get__()`` method. Data descriptors\nalways override a redefinition in an instance dictionary. In\ncontrast, non-data descriptors can be overridden by instances. [2]\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. If defined in a\n class, *__slots__* reserves space for the declared variables and\n prevents the automatic creation of *__dict__* and *__weakref__* for\n each instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises ``AttributeError``. If\n dynamic assignment of new variables is desired, then add\n ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes defining\n *__slots__* do not support weak references to its instances. If weak\n reference support is needed, then add ``\'__weakref__\'`` to the\n sequence of strings in the *__slots__* declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* If a class defines a slot also defined in a base class, the instance\n variable defined by the base class slot is inaccessible (except by\n retrieving its descriptor directly from the base class). This\n renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__*.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as ``int``, ``str`` and\n ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using ``type()``. A class\ndefinition is read into a separate namespace and the value of class\nname is bound to the result of ``type(name, bases, dict)``.\n\nWhen the class definition is read, if a callable ``metaclass`` keyword\nargument is passed after the bases in the class definition, the\ncallable given will be called instead of ``type()``. If other keyword\narguments are passed, they will also be passed to the metaclass. This\nallows classes or functions to be written which monitor or alter the\nclass creation process:\n\n* Modifying the class dictionary prior to the class being created.\n\n* Returning an instance of another class -- essentially performing the\n role of a factory function.\n\nThese steps will have to be performed in the metaclass\'s ``__new__()``\nmethod -- ``type.__new__()`` can then be called from this method to\ncreate a class with different properties. This example adds a new\nelement to the class dictionary before creating the class:\n\n class metacls(type):\n def __new__(mcs, name, bases, dict):\n dict[\'foo\'] = \'metacls was here\'\n return type.__new__(mcs, name, bases, dict)\n\nYou can of course also override other class methods (or add new\nmethods); for example defining a custom ``__call__()`` method in the\nmetaclass allows custom behavior when the class is called, e.g. not\nalways creating a new instance.\n\nIf the metaclass has a ``__prepare__()`` attribute (usually\nimplemented as a class or static method), it is called before the\nclass body is evaluated with the name of the class and a tuple of its\nbases for arguments. It should return an object that supports the\nmapping interface that will be used to store the namespace of the\nclass. The default is a plain dictionary. This could be used, for\nexample, to keep track of the order that class attributes are declared\nin by returning an ordered dictionary.\n\nThe appropriate metaclass is determined by the following precedence\nrules:\n\n* If the ``metaclass`` keyword argument is based with the bases, it is\n used.\n\n* Otherwise, if there is at least one base class, its metaclass is\n used.\n\n* Otherwise, the default metaclass (``type``) is used.\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored including logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n``collections.OrderedDict`` to remember the order that class members\nwere defined:\n\n class OrderedClass(type):\n\n @classmethod\n def __prepare__(metacls, name, bases, **kwds):\n return collections.OrderedDict()\n\n def __new__(cls, name, bases, classdict):\n result = type.__new__(cls, name, bases, dict(classdict))\n result.members = tuple(classdict)\n return result\n\n class A(metaclass=OrderedClass):\n def one(self): pass\n def two(self): pass\n def three(self): pass\n def four(self): pass\n\n >>> A.members\n (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s ``__prepare__()`` method which returns an\nempty ``collections.OrderedDict``. That mapping records the methods\nand attributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s ``__new__()`` method gets\ninvoked. That method builds the new type and it saves the ordered\ndictionary keys in an attribute called *members*.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n ``x.__call__(arg1, arg2, ...)``.\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items. It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``get()``,\n``clear()``, ``setdefault()``, ``pop()``, ``popitem()``, ``copy()``,\nand ``update()`` behaving similar to those for Python\'s standard\ndictionary objects. The ``collections`` module provides a\n``MutableMapping`` abstract base class to help create those methods\nfrom a base set of ``__getitem__()``, ``__setitem__()``,\n``__delitem__()``, and ``keys()``. Mutable sequences should provide\nmethods ``append()``, ``count()``, ``index()``, ``extend()``,\n``insert()``, ``pop()``, ``remove()``, ``reverse()`` and ``sort()``,\nlike Python standard list objects. Finally, sequence types should\nimplement addition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods ``__add__()``, ``__radd__()``,\n``__iadd__()``, ``__mul__()``, ``__rmul__()`` and ``__imul__()``\ndescribed below; they should not define other numerical operators. It\nis recommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should search the mapping\'s keys; for\nsequences, it should search through the values. It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``keys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function ``len()``. Should return\n the length of the object, an integer ``>=`` 0. Also, an object\n that doesn\'t define a ``__bool__()`` method and whose ``__len__()``\n method returns zero is considered to be false in a Boolean context.\n\nNote: Slicing is done exclusively with the following three methods. A\n call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with\n ``None``.\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of ``self[key]``. For sequence\n types, the accepted keys should be integers and slice objects.\n Note that the special interpretation of negative indexes (if the\n class wishes to emulate a sequence type) is up to the\n ``__getitem__()`` method. If *key* is of an inappropriate type,\n ``TypeError`` may be raised; if of a value outside the set of\n indexes for the sequence (after any special interpretation of\n negative values), ``IndexError`` should be raised. For mapping\n types, if *key* is missing (not in the container), ``KeyError``\n should be raised.\n\n Note: ``for`` loops expect that an ``IndexError`` will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the ``__getitem__()``\n method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container, and should also be made\n available as the method ``keys()``.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the ``reversed()`` builtin to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the ``__reversed__()`` method is not provided, the\n ``reversed()`` builtin will fall back to using the sequence\n protocol (``__len__()`` and ``__getitem__()``). Objects that\n support the sequence protocol should only provide\n ``__reversed__()`` if they can provide an implementation that is\n more efficient than the one provided by ``reversed()``.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``). For instance, to evaluate the expression ``x + y``, where\n *x* is an instance of a class that has an ``__add__()`` method,\n ``x.__add__(y)`` is called. The ``__divmod__()`` method should be\n the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n should not be related to ``__truediv__()``. Note that\n ``__pow__()`` should be defined to accept an optional third\n argument if the ternary version of the built-in ``pow()`` function\n is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``) with reflected (swapped) operands. These functions are only\n called if the left operand does not support the corresponding\n operation and the operands are of different types. [3] For\n instance, to evaluate the expression ``x - y``, where *y* is an\n instance of a class that has an ``__rsub__()`` method,\n ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n *NotImplemented*.\n\n Note that ternary ``pow()`` will not try calling ``__rpow__()``\n (the coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left operand\'s\n type and that subclass provides the reflected method for the\n operation, this method will be called before the left operand\'s\n non-reflected method. This behavior allows subclasses to\n override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``). These methods\n should attempt to do the operation in-place (modifying *self*) and\n return the result (which could be, but does not have to be,\n *self*). If a specific method is not defined, the augmented\n assignment falls back to the normal methods. For instance, to\n execute the statement ``x += y``, where *x* is an instance of a\n class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n called. If *x* is an instance of a class that does not define a\n ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations (``-``, ``+``,\n ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions ``complex()``,\n ``int()``, ``float()`` and ``round()``. Should return a value of\n the appropriate type.\n\nobject.__index__(self)\n\n Called to implement ``operator.index()``. Also called whenever\n Python needs an integer object (such as in slicing, or in the\n built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n an integer.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code. Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The ``with``\n statement will bind this method\'s return value to the target(s)\n specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be ``None``.\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that ``__exit__()`` methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception:\n\n >>> class C(object):\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as ``__hash__()`` and ``__repr__()`` that are implemented\nby all objects, including type objects. If the implicit lookup of\nthese methods used the conventional lookup process, they would fail\nwhen invoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe ``__getattribute__()`` method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print("Metaclass getattribute invoked")\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object, metaclass=Meta):\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print("Class getattribute invoked")\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the ``__getattribute__()`` machinery in this fashion\nprovides significant scope for speed optimisations within the\ninterpreter, at the cost of some flexibility in the handling of\nspecial methods (the special method *must* be set on the class object\nitself in order to be consistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type, under\n certain controlled conditions. It generally isn\'t a good idea\n though, since it can lead to some very strange behaviour if it is\n handled incorrectly.\n\n[2] A descriptor can define any combination of ``__get__()``,\n ``__set__()`` and ``__delete__()``. If it does not define\n ``__get__()``, then accessing the attribute even on an instance\n will return the descriptor object itself. If the descriptor\n defines ``__set__()`` and/or ``__delete__()``, it is a data\n descriptor; if it defines neither, it is a non-data descriptor.\n\n[3] For operands of the same type, it is assumed that if the non-\n reflected method (such as ``__add__()``) fails the operation is\n not supported, which is why the reflected method is not called.\n',
- 'string-methods': '\nString Methods\n**************\n\nString objects support the methods listed below. Note that none of\nthese methods take keyword arguments.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n Return a copy of the string with only its first character\n capitalized.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode([encoding[, errors]])\n\n Return an encoded version of the string as a bytes object. Default\n encoding is the current default string encoding. *errors* may be\n given to set a different error handling scheme. The default for\n *errors* is ``\'strict\'``, meaning that encoding errors raise a\n ``UnicodeError``. Other possible values are ``\'ignore\'``,\n ``\'replace\'``, ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and\n any other name registered via ``codecs.register_error()``, see\n section *Codec Base Classes*. For a list of possible encodings, see\n section *Standard Encodings*.\n\nstr.endswith(suffix[, start[, end]])\n\n Return ``True`` if the string ends with the specified *suffix*,\n otherwise return ``False``. *suffix* can also be a tuple of\n suffixes to look for. With optional *start*, test beginning at\n that position. With optional *end*, stop comparing at that\n position.\n\nstr.expandtabs([tabsize])\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. The column number is reset to zero after each\n newline occurring in the string. If *tabsize* is not given, a tab\n size of ``8`` characters is assumed. This doesn\'t understand other\n non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the range [*start*, *end*].\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` if *sub* is not found.\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The *format_string*\n argument can contain literal text or replacement fields delimited\n by braces ``{}``. Each replacement field contains either the\n numeric index of a positional argument, or the name of a keyword\n argument. Returns a copy of *format_string* where each replacement\n field is replaced with the string value of the corresponding\n argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.index(sub[, start[, end]])\n\n Like ``find()``, but raise ``ValueError`` when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise.\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters include digit characters, and all characters that that\n can be used to form decimal-radix numbers, e.g. U+0660, ARABIC-\n INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n Return true if all cased characters in the string are lowercase and\n there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when ``repr()`` is\n invoked on a string. It has no bearing on the handling of strings\n written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise.\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters in the string are uppercase and\n there is at least one cased character, false otherwise.\n\nstr.join(seq)\n\n Return a string which is the concatenation of the strings in the\n sequence *seq*. A ``TypeError`` will be raised if there are any\n non-string values in *seq*, including ``bytes`` objects. The\n separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than\n ``len(s)``.\n\nstr.lower()\n\n Return a copy of the string converted to lowercase.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n ``str.translate()``.\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within s[start,end]. Optional\n arguments *start* and *end* are interpreted as in slice notation.\n Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n is not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than\n ``len(s)``.\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n ``None``, any whitespace string is a separator. Except for\n splitting from the right, ``rsplit()`` behaves like ``split()``\n which is described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most ``maxsplit+1``\n elements). If *maxsplit* is not specified, then there is no limit\n on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``). The *sep*\n argument may consist of multiple characters (for example,\n ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n an empty string with a specified separator returns ``[\'\']``.\n\n If *sep* is not specified or is ``None``, a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a ``None`` separator returns\n ``[]``.\n\n For example, ``\' 1 2 3 \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n and ``\' 1 2 3 \'.split(None, 1)`` returns ``[\'1\', \'2 3 \']``.\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n Return ``True`` if string starts with the *prefix*, otherwise\n return ``False``. *prefix* can also be a tuple of prefixes to look\n for. With optional *start*, test string beginning at that\n position. With optional *end*, stop comparing string at that\n position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or ``None``, the\n *chars* argument defaults to removing whitespace. The *chars*\n argument is not a prefix or suffix; rather, all combinations of its\n values are stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa.\n\nstr.title()\n\n Return a titlecased version of the string: words start with\n uppercase characters, all remaining cased characters are lowercase.\n\nstr.translate(map)\n\n Return a copy of the *s* where all characters have been mapped\n through the *map* which must be a dictionary of Unicode ordinals\n (integers) to Unicode ordinals, strings or ``None``. Unmapped\n characters are left untouched. Characters mapped to ``None`` are\n deleted.\n\n You can use ``str.maketrans()`` to create a translation map from\n character-to-character mappings in different formats.\n\n Note: An even more flexible approach is to create a custom character\n mapping codec using the ``codecs`` module (see\n ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n Return a copy of the string converted to uppercase.\n\nstr.zfill(width)\n\n Return the numeric string left filled with zeros in a string of\n length *width*. A sign prefix is handled correctly. The original\n string is returned if *width* is less than ``len(s)``.\n',
- 'strings': '\nString and Bytes literals\n*************************\n\nString literals are described by the following lexical definitions:\n\n stringliteral ::= [stringprefix](shortstring | longstring)\n stringprefix ::= "r" | "R"\n shortstring ::= "\'" shortstringitem* "\'" | \'"\' shortstringitem* \'"\'\n longstring ::= "\'\'\'" longstringitem* "\'\'\'" | \'"""\' longstringitem* \'"""\'\n shortstringitem ::= shortstringchar | stringescapeseq\n longstringitem ::= longstringchar | stringescapeseq\n shortstringchar ::= <any source character except "\\" or newline or the quote>\n longstringchar ::= <any source character except "\\">\n stringescapeseq ::= "\\" <any source character>\n\n bytesliteral ::= bytesprefix(shortbytes | longbytes)\n bytesprefix ::= "b" | "B"\n shortbytes ::= "\'" shortbytesitem* "\'" | \'"\' shortbytesitem* \'"\'\n longbytes ::= "\'\'\'" longbytesitem* "\'\'\'" | \'"""\' longbytesitem* \'"""\'\n shortbytesitem ::= shortbyteschar | bytesescapeseq\n longbytesitem ::= longbyteschar | bytesescapeseq\n shortbyteschar ::= <any ASCII character except "\\" or newline or the quote>\n longbyteschar ::= <any ASCII character except "\\">\n bytesescapeseq ::= "\\" <any ASCII character>\n\nOne syntactic restriction not indicated by these productions is that\nwhitespace is not allowed between the **stringprefix** or\n**bytesprefix** and the rest of the literal. The source character set\nis defined by the encoding declaration; it is UTF-8 if no encoding\ndeclaration is given in the source file; see section *Encoding\ndeclarations*.\n\nIn plain English: Both types of literals can be enclosed in matching\nsingle quotes (``\'``) or double quotes (``"``). They can also be\nenclosed in matching groups of three single or double quotes (these\nare generally referred to as *triple-quoted strings*). The backslash\n(``\\``) character is used to escape characters that otherwise have a\nspecial meaning, such as newline, backslash itself, or the quote\ncharacter.\n\nString literals may optionally be prefixed with a letter ``\'r\'`` or\n``\'R\'``; such strings are called *raw strings* and treat backslashes\nas literal characters. As a result, ``\'\\U\'`` and ``\'\\u\'`` escapes in\nraw strings are not treated specially.\n\nBytes literals are always prefixed with ``\'b\'`` or ``\'B\'``; they\nproduce an instance of the ``bytes`` type instead of the ``str`` type.\nThey may only contain ASCII characters; bytes with a numeric value of\n128 or greater must be expressed with escapes.\n\nIn triple-quoted strings, unescaped newlines and quotes are allowed\n(and are retained), except that three unescaped quotes in a row\nterminate the string. (A "quote" is the character used to open the\nstring, i.e. either ``\'`` or ``"``.)\n\nUnless an ``\'r\'`` or ``\'R\'`` prefix is present, escape sequences in\nstrings are interpreted according to rules similar to those used by\nStandard C. The recognized escape sequences are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| ``\\newline`` | Backslash and newline ignored | |\n+-------------------+-----------------------------------+---------+\n| ``\\\\`` | Backslash (``\\``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\\'`` | Single quote (``\'``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\"`` | Double quote (``"``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\a`` | ASCII Bell (BEL) | |\n+-------------------+-----------------------------------+---------+\n| ``\\b`` | ASCII Backspace (BS) | |\n+-------------------+-----------------------------------+---------+\n| ``\\f`` | ASCII Formfeed (FF) | |\n+-------------------+-----------------------------------+---------+\n| ``\\n`` | ASCII Linefeed (LF) | |\n+-------------------+-----------------------------------+---------+\n| ``\\r`` | ASCII Carriage Return (CR) | |\n+-------------------+-----------------------------------+---------+\n| ``\\t`` | ASCII Horizontal Tab (TAB) | |\n+-------------------+-----------------------------------+---------+\n| ``\\v`` | ASCII Vertical Tab (VT) | |\n+-------------------+-----------------------------------+---------+\n| ``\\ooo`` | Character with octal value *ooo* | (1,3) |\n+-------------------+-----------------------------------+---------+\n| ``\\xhh`` | Character with hex value *hh* | (2,3) |\n+-------------------+-----------------------------------+---------+\n\nEscape sequences only recognized in string literals are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| ``\\N{name}`` | Character named *name* in the | |\n| | Unicode database | |\n+-------------------+-----------------------------------+---------+\n| ``\\uxxxx`` | Character with 16-bit hex value | (4) |\n| | *xxxx* | |\n+-------------------+-----------------------------------+---------+\n| ``\\Uxxxxxxxx`` | Character with 32-bit hex value | (5) |\n| | *xxxxxxxx* | |\n+-------------------+-----------------------------------+---------+\n\nNotes:\n\n1. As in Standard C, up to three octal digits are accepted.\n\n2. Unlike in Standard C, at most two hex digits are accepted.\n\n3. In a bytes literal, hexadecimal and octal escapes denote the byte\n with the given value. In a string literal, these escapes denote a\n Unicode character with the given value.\n\n4. Individual code units which form parts of a surrogate pair can be\n encoded using this escape sequence. Unlike in Standard C, exactly\n two hex digits are required.\n\n5. Any Unicode character can be encoded this way, but characters\n outside the Basic Multilingual Plane (BMP) will be encoded using a\n surrogate pair if Python is compiled to use 16-bit code units (the\n default). Individual code units which form parts of a surrogate\n pair can be encoded using this escape sequence.\n\nUnlike Standard C, all unrecognized escape sequences are left in the\nstring unchanged, i.e., *the backslash is left in the string*. (This\nbehavior is useful when debugging: if an escape sequence is mistyped,\nthe resulting output is more easily recognized as broken.) It is also\nimportant to note that the escape sequences only recognized in string\nliterals fall into the category of unrecognized escapes for bytes\nliterals.\n\nEven in a raw string, string quotes can be escaped with a backslash,\nbut the backslash remains in the string; for example, ``r"\\""`` is a\nvalid string literal consisting of two characters: a backslash and a\ndouble quote; ``r"\\"`` is not a valid string literal (even a raw\nstring cannot end in an odd number of backslashes). Specifically, *a\nraw string cannot end in a single backslash* (since the backslash\nwould escape the following quote character). Note also that a single\nbackslash followed by a newline is interpreted as those two characters\nas part of the string, *not* as a line continuation.\n',
- 'subscriptions': '\nSubscriptions\n*************\n\nA subscription selects an item of a sequence (string, tuple or list)\nor mapping (dictionary) object:\n\n subscription ::= primary "[" expression_list "]"\n\nThe primary must evaluate to an object that supports subscription,\ne.g. a list or dictionary. User-defined objects can support\nsubscription by defining a ``__getitem__()`` method.\n\nFor built-in objects, there are two types of objects that support\nsubscription:\n\nIf the primary is a mapping, the expression list must evaluate to an\nobject whose value is one of the keys of the mapping, and the\nsubscription selects the value in the mapping that corresponds to that\nkey. (The expression list is a tuple except if it has exactly one\nitem.)\n\nIf the primary is a sequence, the expression (list) must evaluate to\nan integer. If this value is negative, the length of the sequence is\nadded to it (so that, e.g., ``x[-1]`` selects the last item of ``x``.)\nThe resulting value must be a nonnegative integer less than the number\nof items in the sequence, and the subscription selects the item whose\nindex is that value (counting from zero).\n\nA string\'s items are characters. A character is not a separate data\ntype but a string of exactly one character.\n',
+ 'specialattrs': "\nSpecial Attributes\n******************\n\nThe implementation adds a few special read-only attributes to several\nobject types, where they are relevant. Some of these are not reported\nby the ``dir()`` built-in function.\n\nobject.__dict__\n\n A dictionary or other mapping object used to store an object's\n (writable) attributes.\n\ninstance.__class__\n\n The class to which a class instance belongs.\n\nclass.__bases__\n\n The tuple of base classes of a class object.\n\nclass.__name__\n\n The name of the class or type.\n\nThe following attributes are only supported by *new-style class*es.\n\nclass.__mro__\n\n This attribute is a tuple of classes that are considered when\n looking for base classes during method resolution.\n\nclass.mro()\n\n This method can be overridden by a metaclass to customize the\n method resolution order for its instances. It is called at class\n instantiation, and its result is stored in ``__mro__``.\n\nclass.__subclasses__()\n\n Each new-style class keeps a list of weak references to its\n immediate subclasses. This method returns a list of all those\n references still alive. Example:\n\n >>> int.__subclasses__()\n [<type 'bool'>]\n\n-[ Footnotes ]-\n\n[1] Additional information on these special methods may be found in\n the Python Reference Manual (*Basic customization*).\n\n[2] As a consequence, the list ``[1, 2]`` is considered equal to\n ``[1.0, 2.0]``, and similarly for tuples.\n\n[3] They must have since the parser can't tell the type of the\n operands.\n\n[4] To format only a tuple you should therefore provide a singleton\n tuple whose only element is the tuple to be formatted.\n",
+ 'specialnames': '\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named ``__getitem__()``, and ``x`` is an instance of this\nclass, then ``x[i]`` is roughly equivalent to ``type(x).__getitem__(x,\ni)``. Except where mentioned, attempts to execute an operation raise\nan exception when no appropriate method is defined (typically\n``AttributeError`` or ``TypeError``).\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n``NodeList`` interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. ``__new__()`` is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of ``__new__()`` should be the new object instance (usually\n an instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s ``__new__()`` method using\n ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If ``__new__()`` returns an instance of *cls*, then the new\n instance\'s ``__init__()`` method will be invoked like\n ``__init__(self[, ...])``, where *self* is the new instance and the\n remaining arguments are the same as were passed to ``__new__()``.\n\n If ``__new__()`` does not return an instance of *cls*, then the new\n instance\'s ``__init__()`` method will not be invoked.\n\n ``__new__()`` is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called when the instance is created. The arguments are those\n passed to the class constructor expression. If a base class has an\n ``__init__()`` method, the derived class\'s ``__init__()`` method,\n if any, must explicitly call it to ensure proper initialization of\n the base class part of the instance; for example:\n ``BaseClass.__init__(self, [args...])``. As a special constraint\n on constructors, no value may be returned; doing so will cause a\n ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a ``__del__()`` method,\n the derived class\'s ``__del__()`` method, if any, must explicitly\n call it to ensure proper deletion of the base class part of the\n instance. Note that it is possible (though not recommended!) for\n the ``__del__()`` method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n ``__del__()`` methods are called for objects that still exist when\n the interpreter exits.\n\n Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n decrements the reference count for ``x`` by one, and the latter\n is only called when ``x``\'s reference count reaches zero. Some\n common situations that may prevent the reference count of an\n object from going to zero include: circular references between\n objects (e.g., a doubly-linked list or a tree data structure with\n parent and child pointers); a reference to the object on the\n stack frame of a function that caught an exception (the traceback\n stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n a reference to the object on the stack frame that raised an\n unhandled exception in interactive mode (the traceback stored in\n ``sys.last_traceback`` keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the latter two situations can be resolved by storing ``None`` in\n ``sys.last_traceback``. Circular references which are garbage are\n detected when the option cycle detector is enabled (it\'s on by\n default), but can only be cleaned up if there are no Python-\n level ``__del__()`` methods involved. Refer to the documentation\n for the ``gc`` module for more information about how\n ``__del__()`` methods are handled by the cycle detector,\n particularly the description of the ``garbage`` value.\n\n Warning: Due to the precarious circumstances under which ``__del__()``\n methods are invoked, exceptions that occur during their execution\n are ignored, and a warning is printed to ``sys.stderr`` instead.\n Also, when ``__del__()`` is invoked in response to a module being\n deleted (e.g., when execution of the program is done), other\n globals referenced by the ``__del__()`` method may already have\n been deleted or in the process of being torn down (e.g. the\n import machinery shutting down). For this reason, ``__del__()``\n methods should do the absolute minimum needed to maintain\n external invariants. Starting with version 1.5, Python\n guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n Called by the ``repr()`` built-in function to compute the\n "official" string representation of an object. If at all possible,\n this should look like a valid Python expression that could be used\n to recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n ``<...some useful description...>`` should be returned. The return\n value must be a string object. If a class defines ``__repr__()``\n but not ``__str__()``, then ``__repr__()`` is also used when an\n "informal" string representation of instances of that class is\n required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by the ``str()`` built-in function and by the ``print()``\n function to compute the "informal" string representation of an\n object. This differs from ``__repr__()`` in that it does not have\n to be a valid Python expression: a more convenient or concise\n representation may be used instead. The return value must be a\n string object.\n\nobject.__format__(self, format_spec)\n\n Called by the ``format()`` built-in function (and by extension, the\n ``format()`` method of class ``str``) to produce a "formatted"\n string representation of an object. The ``format_spec`` argument is\n a string that contains a description of the formatting options\n desired. The interpretation of the ``format_spec`` argument is up\n to the type implementing ``__format__()``, however most classes\n will either delegate formatting to one of the built-in types, or\n use a similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n ``x.__ge__(y)``.\n\n A rich comparison method may return the singleton\n ``NotImplemented`` if it does not implement the operation for a\n given pair of arguments. By convention, ``False`` and ``True`` are\n returned for a successful comparison. However, these methods can\n return any value, so if the comparison operator is used in a\n Boolean context (e.g., in the condition of an ``if`` statement),\n Python will call ``bool()`` on the value to determine if the result\n is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of ``x==y`` does not imply that ``x!=y`` is false.\n Accordingly, when defining ``__eq__()``, one should also define\n ``__ne__()`` so that the operators will behave as expected. See\n the paragraph on ``__hash__()`` for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n reflection, and ``__eq__()`` and ``__ne__()`` are their own\n reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see ``functools.total_ordering()``.\n\nobject.__hash__(self)\n\n Called by built-in function ``hash()`` and for operations on\n members of hashed collections including ``set``, ``frozenset``, and\n ``dict``. ``__hash__()`` should return an integer. The only\n required property is that objects which compare equal have the same\n hash value; it is advised to somehow mix together (e.g. using\n exclusive or) the hash values for the components of the object that\n also play a part in comparison of objects.\n\n If a class does not define an ``__eq__()`` method it should not\n define a ``__hash__()`` operation either; if it defines\n ``__eq__()`` but not ``__hash__()``, its instances will not be\n usable as items in hashable collections. If a class defines\n mutable objects and implements an ``__eq__()`` method, it should\n not implement ``__hash__()``, since the implementation of hashable\n collections requires that a key\'s hash value is immutable (if the\n object\'s hash value changes, it will be in the wrong hash bucket).\n\n User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n by default; with them, all objects compare unequal (except with\n themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n Classes which inherit a ``__hash__()`` method from a parent class\n but change the meaning of ``__eq__()`` such that the hash value\n returned is no longer appropriate (e.g. by switching to a value-\n based concept of equality instead of the default identity based\n equality) can explicitly flag themselves as being unhashable by\n setting ``__hash__ = None`` in the class definition. Doing so means\n that not only will instances of the class raise an appropriate\n ``TypeError`` when a program attempts to retrieve their hash value,\n but they will also be correctly identified as unhashable when\n checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n which define their own ``__hash__()`` to explicitly raise\n ``TypeError``).\n\n If a class that overrides ``__eq__()`` needs to retain the\n implementation of ``__hash__()`` from a parent class, the\n interpreter must be told this explicitly by setting ``__hash__ =\n <ParentClass>.__hash__``. Otherwise the inheritance of\n ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n explicitly set to ``None``.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n ``bool()``; should return ``False`` or ``True``. When this method\n is not defined, ``__len__()`` is called, if it is defined, and the\n object is considered true if its result is nonzero. If a class\n defines neither ``__len__()`` nor ``__bool__()``, all its instances\n are considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for ``self``). ``name`` is the attribute name.\n This method should return the (computed) attribute value or raise\n an ``AttributeError`` exception.\n\n Note that if the attribute is found through the normal mechanism,\n ``__getattr__()`` is not called. (This is an intentional asymmetry\n between ``__getattr__()`` and ``__setattr__()``.) This is done both\n for efficiency reasons and because otherwise ``__getattr__()``\n would have no way to access other attributes of the instance. Note\n that at least for instance variables, you can fake total control by\n not inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n ``__getattribute__()`` method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines\n ``__getattr__()``, the latter will not be called unless\n ``__getattribute__()`` either calls it explicitly or raises an\n ``AttributeError``. This method should return the (computed)\n attribute value or raise an ``AttributeError`` exception. In order\n to avoid infinite recursion in this method, its implementation\n should always call the base class method with the same name to\n access any attributes it needs, for example,\n ``object.__getattribute__(self, name)``.\n\n Note: This method may still be bypassed when looking up special methods\n as the result of implicit invocation via language syntax or\n built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If ``__setattr__()`` wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n Like ``__setattr__()`` but for attribute deletion instead of\n assignment. This should only be implemented if ``del obj.name`` is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when ``dir()`` is called on the object. A list must be\n returned.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in the\nclass dictionary of another class, known as the *owner* class. In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or ``None`` when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an\n ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: ``x.__get__(a)``.\n\nInstance Binding\n If binding to an object instance, ``a.x`` is transformed into the\n call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n If binding to a class, ``A.x`` is transformed into the call:\n ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n If ``a`` is an instance of ``super``, then the binding ``super(B,\n obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n ``A`` immediately preceding ``B`` and then invokes the descriptor\n with the call: ``A.__dict__[\'m\'].__get__(obj, A)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of ``__get__()``, ``__set__()`` and ``__delete__()``.\nIf it does not define ``__get__()``, then accessing the attribute will\nreturn the descriptor object itself unless there is a value in the\nobject\'s instance dictionary. If the descriptor defines ``__set__()``\nand/or ``__delete__()``, it is a data descriptor; if it defines\nneither, it is a non-data descriptor. Normally, data descriptors\ndefine both ``__get__()`` and ``__set__()``, while non-data\ndescriptors have just the ``__get__()`` method. Data descriptors with\n``__set__()`` and ``__get__()`` defined always override a redefinition\nin an instance dictionary. In contrast, non-data descriptors can be\noverridden by instances.\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. If defined in a\n class, *__slots__* reserves space for the declared variables and\n prevents the automatic creation of *__dict__* and *__weakref__* for\n each instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises ``AttributeError``. If\n dynamic assignment of new variables is desired, then add\n ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes defining\n *__slots__* do not support weak references to its instances. If weak\n reference support is needed, then add ``\'__weakref__\'`` to the\n sequence of strings in the *__slots__* declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the instance\n variable defined by the base class slot is inaccessible (except by\n retrieving its descriptor directly from the base class). This\n renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as ``int``, ``str`` and\n ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using ``type()``. A class\ndefinition is read into a separate namespace and the value of class\nname is bound to the result of ``type(name, bases, dict)``.\n\nWhen the class definition is read, if a callable ``metaclass`` keyword\nargument is passed after the bases in the class definition, the\ncallable given will be called instead of ``type()``. If other keyword\narguments are passed, they will also be passed to the metaclass. This\nallows classes or functions to be written which monitor or alter the\nclass creation process:\n\n* Modifying the class dictionary prior to the class being created.\n\n* Returning an instance of another class -- essentially performing the\n role of a factory function.\n\nThese steps will have to be performed in the metaclass\'s ``__new__()``\nmethod -- ``type.__new__()`` can then be called from this method to\ncreate a class with different properties. This example adds a new\nelement to the class dictionary before creating the class:\n\n class metacls(type):\n def __new__(mcs, name, bases, dict):\n dict[\'foo\'] = \'metacls was here\'\n return type.__new__(mcs, name, bases, dict)\n\nYou can of course also override other class methods (or add new\nmethods); for example defining a custom ``__call__()`` method in the\nmetaclass allows custom behavior when the class is called, e.g. not\nalways creating a new instance.\n\nIf the metaclass has a ``__prepare__()`` attribute (usually\nimplemented as a class or static method), it is called before the\nclass body is evaluated with the name of the class and a tuple of its\nbases for arguments. It should return an object that supports the\nmapping interface that will be used to store the namespace of the\nclass. The default is a plain dictionary. This could be used, for\nexample, to keep track of the order that class attributes are declared\nin by returning an ordered dictionary.\n\nThe appropriate metaclass is determined by the following precedence\nrules:\n\n* If the ``metaclass`` keyword argument is passed with the bases, it\n is used.\n\n* Otherwise, if there is at least one base class, its metaclass is\n used.\n\n* Otherwise, the default metaclass (``type``) is used.\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored including logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n``collections.OrderedDict`` to remember the order that class members\nwere defined:\n\n class OrderedClass(type):\n\n @classmethod\n def __prepare__(metacls, name, bases, **kwds):\n return collections.OrderedDict()\n\n def __new__(cls, name, bases, classdict):\n result = type.__new__(cls, name, bases, dict(classdict))\n result.members = tuple(classdict)\n return result\n\n class A(metaclass=OrderedClass):\n def one(self): pass\n def two(self): pass\n def three(self): pass\n def four(self): pass\n\n >>> A.members\n (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s ``__prepare__()`` method which returns an\nempty ``collections.OrderedDict``. That mapping records the methods\nand attributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s ``__new__()`` method gets\ninvoked. That method builds the new type and it saves the ordered\ndictionary keys in an attribute called ``members``.\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n``isinstance()`` and ``issubclass()`` built-in functions.\n\nIn particular, the metaclass ``abc.ABCMeta`` implements these methods\nin order to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n Return true if *instance* should be considered a (direct or\n indirect) instance of *class*. If defined, called to implement\n ``isinstance(instance, class)``.\n\nclass.__subclasscheck__(self, subclass)\n\n Return true if *subclass* should be considered a (direct or\n indirect) subclass of *class*. If defined, called to implement\n ``issubclass(subclass, class)``.\n\nNote that these methods are looked up on the type (metaclass) of a\nclass. They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also:\n\n **PEP 3119** - Introducing Abstract Base Classes\n Includes the specification for customizing ``isinstance()`` and\n ``issubclass()`` behavior through ``__instancecheck__()`` and\n ``__subclasscheck__()``, with motivation for this functionality\n in the context of adding Abstract Base Classes (see the ``abc``\n module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n ``x.__call__(arg1, arg2, ...)``.\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items. It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``get()``,\n``clear()``, ``setdefault()``, ``pop()``, ``popitem()``, ``copy()``,\nand ``update()`` behaving similar to those for Python\'s standard\ndictionary objects. The ``collections`` module provides a\n``MutableMapping`` abstract base class to help create those methods\nfrom a base set of ``__getitem__()``, ``__setitem__()``,\n``__delitem__()``, and ``keys()``. Mutable sequences should provide\nmethods ``append()``, ``count()``, ``index()``, ``extend()``,\n``insert()``, ``pop()``, ``remove()``, ``reverse()`` and ``sort()``,\nlike Python standard list objects. Finally, sequence types should\nimplement addition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods ``__add__()``, ``__radd__()``,\n``__iadd__()``, ``__mul__()``, ``__rmul__()`` and ``__imul__()``\ndescribed below; they should not define other numerical operators. It\nis recommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should search the mapping\'s keys; for\nsequences, it should search through the values. It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``keys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function ``len()``. Should return\n the length of the object, an integer ``>=`` 0. Also, an object\n that doesn\'t define a ``__bool__()`` method and whose ``__len__()``\n method returns zero is considered to be false in a Boolean context.\n\nNote: Slicing is done exclusively with the following three methods. A\n call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with\n ``None``.\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of ``self[key]``. For sequence\n types, the accepted keys should be integers and slice objects.\n Note that the special interpretation of negative indexes (if the\n class wishes to emulate a sequence type) is up to the\n ``__getitem__()`` method. If *key* is of an inappropriate type,\n ``TypeError`` may be raised; if of a value outside the set of\n indexes for the sequence (after any special interpretation of\n negative values), ``IndexError`` should be raised. For mapping\n types, if *key* is missing (not in the container), ``KeyError``\n should be raised.\n\n Note: ``for`` loops expect that an ``IndexError`` will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the ``__getitem__()``\n method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container, and should also be made\n available as the method ``keys()``.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the ``reversed()`` built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the ``__reversed__()`` method is not provided, the\n ``reversed()`` built-in will fall back to using the sequence\n protocol (``__len__()`` and ``__getitem__()``). Objects that\n support the sequence protocol should only provide\n ``__reversed__()`` if they can provide an implementation that is\n more efficient than the one provided by ``reversed()``.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define ``__contains__()``, the membership\n test first tries iteration via ``__iter__()``, then the old\n sequence iteration protocol via ``__getitem__()``, see *this\n section in the language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``). For instance, to evaluate the expression ``x + y``, where\n *x* is an instance of a class that has an ``__add__()`` method,\n ``x.__add__(y)`` is called. The ``__divmod__()`` method should be\n the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n should not be related to ``__truediv__()``. Note that\n ``__pow__()`` should be defined to accept an optional third\n argument if the ternary version of the built-in ``pow()`` function\n is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``) with reflected (swapped) operands. These functions are only\n called if the left operand does not support the corresponding\n operation and the operands are of different types. [2] For\n instance, to evaluate the expression ``x - y``, where *y* is an\n instance of a class that has an ``__rsub__()`` method,\n ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n *NotImplemented*.\n\n Note that ternary ``pow()`` will not try calling ``__rpow__()``\n (the coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left operand\'s\n type and that subclass provides the reflected method for the\n operation, this method will be called before the left operand\'s\n non-reflected method. This behavior allows subclasses to\n override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``). These methods\n should attempt to do the operation in-place (modifying *self*) and\n return the result (which could be, but does not have to be,\n *self*). If a specific method is not defined, the augmented\n assignment falls back to the normal methods. For instance, to\n execute the statement ``x += y``, where *x* is an instance of a\n class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n called. If *x* is an instance of a class that does not define a\n ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations (``-``, ``+``,\n ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions ``complex()``,\n ``int()``, ``float()`` and ``round()``. Should return a value of\n the appropriate type.\n\nobject.__index__(self)\n\n Called to implement ``operator.index()``. Also called whenever\n Python needs an integer object (such as in slicing, or in the\n built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n an integer.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code. Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The ``with``\n statement will bind this method\'s return value to the target(s)\n specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be ``None``.\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that ``__exit__()`` methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception:\n\n >>> class C:\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as ``__hash__()`` and ``__repr__()`` that are implemented\nby all objects, including type objects. If the implicit lookup of\nthese methods used the conventional lookup process, they would fail\nwhen invoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe ``__getattribute__()`` method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print("Metaclass getattribute invoked")\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object, metaclass=Meta):\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print("Class getattribute invoked")\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the ``__getattribute__()`` machinery in this fashion\nprovides significant scope for speed optimisations within the\ninterpreter, at the cost of some flexibility in the handling of\nspecial methods (the special method *must* be set on the class object\nitself in order to be consistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type, under\n certain controlled conditions. It generally isn\'t a good idea\n though, since it can lead to some very strange behaviour if it is\n handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n reflected method (such as ``__add__()``) fails the operation is\n not supported, which is why the reflected method is not called.\n',
+ 'string-methods': '\nString Methods\n**************\n\nString objects support the methods listed below.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is ``\'utf-8\'``. *errors* may be given to set a different\n error handling scheme. The default for *errors* is ``\'strict\'``,\n meaning that encoding errors raise a ``UnicodeError``. Other\n possible values are ``\'ignore\'``, ``\'replace\'``,\n ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and any other name\n registered via ``codecs.register_error()``, see section *Codec Base\n Classes*. For a list of possible encodings, see section *Standard\n Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return ``True`` if the string ends with the specified *suffix*,\n otherwise return ``False``. *suffix* can also be a tuple of\n suffixes to look for. With optional *start*, test beginning at\n that position. With optional *end*, stop comparing at that\n position.\n\nstr.expandtabs([tabsize])\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. The column number is reset to zero after each\n newline occurring in the string. If *tabsize* is not given, a tab\n size of ``8`` characters is assumed. This doesn\'t understand other\n non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` if *sub* is not found.\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces ``{}``. Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to ``str.format(**mapping)``, except that ``mapping`` is\n used directly and not copied to a ``dict`` . This is useful if for\n example ``mapping`` is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like ``find()``, but raise ``ValueError`` when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character\n ``c`` is alphanumeric if one of the following returns ``True``:\n ``c.isalpha()``, ``c.isdecimal()``, ``c.isdigit()``, or\n ``c.isnumeric()``.\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that that can be used\n to form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT\n ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n Return true if all cased characters in the string are lowercase and\n there is at least one cased character, false otherwise. Cased\n characters are those with general category property being one of\n "Lu", "Ll", or "Lt" and lowercase characters are those with general\n category property "Ll".\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when ``repr()`` is\n invoked on a string. It has no bearing on the handling of strings\n written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters in the string are uppercase and\n there is at least one cased character, false otherwise. Cased\n characters are those with general category property being one of\n "Lu", "Ll", or "Lt" and uppercase characters are those with general\n category property "Lu".\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A ``TypeError`` will be raised if there are\n any non-string values in *seq*, including ``bytes`` objects. The\n separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than\n ``len(s)``.\n\nstr.lower()\n\n Return a copy of the string converted to lowercase.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n ``str.translate()``.\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n is not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than\n ``len(s)``.\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n ``None``, any whitespace string is a separator. Except for\n splitting from the right, ``rsplit()`` behaves like ``split()``\n which is described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most ``maxsplit+1``\n elements). If *maxsplit* is not specified, then there is no limit\n on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``). The *sep*\n argument may consist of multiple characters (for example,\n ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n an empty string with a specified separator returns ``[\'\']``.\n\n If *sep* is not specified or is ``None``, a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a ``None`` separator returns\n ``[]``.\n\n For example, ``\' 1 2 3 \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n and ``\' 1 2 3 \'.split(None, 1)`` returns ``[\'1\', \'2 3 \']``.\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n Return ``True`` if string starts with the *prefix*, otherwise\n return ``False``. *prefix* can also be a tuple of prefixes to look\n for. With optional *start*, test string beginning at that\n position. With optional *end*, stop comparing string at that\n position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or ``None``, the\n *chars* argument defaults to removing whitespace. The *chars*\n argument is not a prefix or suffix; rather, all combinations of its\n values are stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa.\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n lambda mo: mo.group(0)[0].upper() +\n mo.group(0)[1:].lower(),\n s)\n\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n Return a copy of the *s* where all characters have been mapped\n through the *map* which must be a dictionary of Unicode ordinals\n (integers) to Unicode ordinals, strings or ``None``. Unmapped\n characters are left untouched. Characters mapped to ``None`` are\n deleted.\n\n You can use ``str.maketrans()`` to create a translation map from\n character-to-character mappings in different formats.\n\n Note: An even more flexible approach is to create a custom character\n mapping codec using the ``codecs`` module (see\n ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n Return a copy of the string converted to uppercase.\n\nstr.zfill(width)\n\n Return the numeric string left filled with zeros in a string of\n length *width*. A sign prefix is handled correctly. The original\n string is returned if *width* is less than ``len(s)``.\n',
+ 'strings': '\nString and Bytes literals\n*************************\n\nString literals are described by the following lexical definitions:\n\n stringliteral ::= [stringprefix](shortstring | longstring)\n stringprefix ::= "r" | "R"\n shortstring ::= "\'" shortstringitem* "\'" | \'"\' shortstringitem* \'"\'\n longstring ::= "\'\'\'" longstringitem* "\'\'\'" | \'"""\' longstringitem* \'"""\'\n shortstringitem ::= shortstringchar | stringescapeseq\n longstringitem ::= longstringchar | stringescapeseq\n shortstringchar ::= <any source character except "\\" or newline or the quote>\n longstringchar ::= <any source character except "\\">\n stringescapeseq ::= "\\" <any source character>\n\n bytesliteral ::= bytesprefix(shortbytes | longbytes)\n bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR"\n shortbytes ::= "\'" shortbytesitem* "\'" | \'"\' shortbytesitem* \'"\'\n longbytes ::= "\'\'\'" longbytesitem* "\'\'\'" | \'"""\' longbytesitem* \'"""\'\n shortbytesitem ::= shortbyteschar | bytesescapeseq\n longbytesitem ::= longbyteschar | bytesescapeseq\n shortbyteschar ::= <any ASCII character except "\\" or newline or the quote>\n longbyteschar ::= <any ASCII character except "\\">\n bytesescapeseq ::= "\\" <any ASCII character>\n\nOne syntactic restriction not indicated by these productions is that\nwhitespace is not allowed between the ``stringprefix`` or\n``bytesprefix`` and the rest of the literal. The source character set\nis defined by the encoding declaration; it is UTF-8 if no encoding\ndeclaration is given in the source file; see section *Encoding\ndeclarations*.\n\nIn plain English: Both types of literals can be enclosed in matching\nsingle quotes (``\'``) or double quotes (``"``). They can also be\nenclosed in matching groups of three single or double quotes (these\nare generally referred to as *triple-quoted strings*). The backslash\n(``\\``) character is used to escape characters that otherwise have a\nspecial meaning, such as newline, backslash itself, or the quote\ncharacter.\n\nBytes literals are always prefixed with ``\'b\'`` or ``\'B\'``; they\nproduce an instance of the ``bytes`` type instead of the ``str`` type.\nThey may only contain ASCII characters; bytes with a numeric value of\n128 or greater must be expressed with escapes.\n\nBoth string and bytes literals may optionally be prefixed with a\nletter ``\'r\'`` or ``\'R\'``; such strings are called *raw strings* and\ntreat backslashes as literal characters. As a result, in string\nliterals, ``\'\\U\'`` and ``\'\\u\'`` escapes in raw strings are not treated\nspecially.\n\nIn triple-quoted strings, unescaped newlines and quotes are allowed\n(and are retained), except that three unescaped quotes in a row\nterminate the string. (A "quote" is the character used to open the\nstring, i.e. either ``\'`` or ``"``.)\n\nUnless an ``\'r\'`` or ``\'R\'`` prefix is present, escape sequences in\nstrings are interpreted according to rules similar to those used by\nStandard C. The recognized escape sequences are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| ``\\newline`` | Backslash and newline ignored | |\n+-------------------+-----------------------------------+---------+\n| ``\\\\`` | Backslash (``\\``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\\'`` | Single quote (``\'``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\"`` | Double quote (``"``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\a`` | ASCII Bell (BEL) | |\n+-------------------+-----------------------------------+---------+\n| ``\\b`` | ASCII Backspace (BS) | |\n+-------------------+-----------------------------------+---------+\n| ``\\f`` | ASCII Formfeed (FF) | |\n+-------------------+-----------------------------------+---------+\n| ``\\n`` | ASCII Linefeed (LF) | |\n+-------------------+-----------------------------------+---------+\n| ``\\r`` | ASCII Carriage Return (CR) | |\n+-------------------+-----------------------------------+---------+\n| ``\\t`` | ASCII Horizontal Tab (TAB) | |\n+-------------------+-----------------------------------+---------+\n| ``\\v`` | ASCII Vertical Tab (VT) | |\n+-------------------+-----------------------------------+---------+\n| ``\\ooo`` | Character with octal value *ooo* | (1,3) |\n+-------------------+-----------------------------------+---------+\n| ``\\xhh`` | Character with hex value *hh* | (2,3) |\n+-------------------+-----------------------------------+---------+\n\nEscape sequences only recognized in string literals are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| ``\\N{name}`` | Character named *name* in the | |\n| | Unicode database | |\n+-------------------+-----------------------------------+---------+\n| ``\\uxxxx`` | Character with 16-bit hex value | (4) |\n| | *xxxx* | |\n+-------------------+-----------------------------------+---------+\n| ``\\Uxxxxxxxx`` | Character with 32-bit hex value | (5) |\n| | *xxxxxxxx* | |\n+-------------------+-----------------------------------+---------+\n\nNotes:\n\n1. As in Standard C, up to three octal digits are accepted.\n\n2. Unlike in Standard C, exactly two hex digits are required.\n\n3. In a bytes literal, hexadecimal and octal escapes denote the byte\n with the given value. In a string literal, these escapes denote a\n Unicode character with the given value.\n\n4. Individual code units which form parts of a surrogate pair can be\n encoded using this escape sequence. Exactly four hex digits are\n required.\n\n5. Any Unicode character can be encoded this way, but characters\n outside the Basic Multilingual Plane (BMP) will be encoded using a\n surrogate pair if Python is compiled to use 16-bit code units (the\n default). Exactly eight hex digits are required.\n\nUnlike Standard C, all unrecognized escape sequences are left in the\nstring unchanged, i.e., *the backslash is left in the string*. (This\nbehavior is useful when debugging: if an escape sequence is mistyped,\nthe resulting output is more easily recognized as broken.) It is also\nimportant to note that the escape sequences only recognized in string\nliterals fall into the category of unrecognized escapes for bytes\nliterals.\n\nEven in a raw string, string quotes can be escaped with a backslash,\nbut the backslash remains in the string; for example, ``r"\\""`` is a\nvalid string literal consisting of two characters: a backslash and a\ndouble quote; ``r"\\"`` is not a valid string literal (even a raw\nstring cannot end in an odd number of backslashes). Specifically, *a\nraw string cannot end in a single backslash* (since the backslash\nwould escape the following quote character). Note also that a single\nbackslash followed by a newline is interpreted as those two characters\nas part of the string, *not* as a line continuation.\n',
+ 'subscriptions': '\nSubscriptions\n*************\n\nA subscription selects an item of a sequence (string, tuple or list)\nor mapping (dictionary) object:\n\n subscription ::= primary "[" expression_list "]"\n\nThe primary must evaluate to an object that supports subscription,\ne.g. a list or dictionary. User-defined objects can support\nsubscription by defining a ``__getitem__()`` method.\n\nFor built-in objects, there are two types of objects that support\nsubscription:\n\nIf the primary is a mapping, the expression list must evaluate to an\nobject whose value is one of the keys of the mapping, and the\nsubscription selects the value in the mapping that corresponds to that\nkey. (The expression list is a tuple except if it has exactly one\nitem.)\n\nIf the primary is a sequence, the expression (list) must evaluate to\nan integer or a slice (as discussed in the following section).\n\nThe formal syntax makes no special provision for negative indices in\nsequences; however, built-in sequences all provide a ``__getitem__()``\nmethod that interprets negative indices by adding the length of the\nsequence to the index (so that ``x[-1]`` selects the last item of\n``x``). The resulting value must be a nonnegative integer less than\nthe number of items in the sequence, and the subscription selects the\nitem whose index is that value (counting from zero). Since the support\nfor negative indices and slicing occurs in the object\'s\n``__getitem__()`` method, subclasses overriding this method will need\nto explicitly add that support.\n\nA string\'s items are characters. A character is not a separate data\ntype but a string of exactly one character.\n',
'truth': "\nTruth Value Testing\n*******************\n\nAny object can be tested for truth value, for use in an ``if`` or\n``while`` condition or as operand of the Boolean operations below. The\nfollowing values are considered false:\n\n* ``None``\n\n* ``False``\n\n* zero of any numeric type, for example, ``0``, ``0.0``, ``0j``.\n\n* any empty sequence, for example, ``''``, ``()``, ``[]``.\n\n* any empty mapping, for example, ``{}``.\n\n* instances of user-defined classes, if the class defines a\n ``__bool__()`` or ``__len__()`` method, when that method returns the\n integer zero or ``bool`` value ``False``. [1]\n\nAll other values are considered true --- so objects of many types are\nalways true.\n\nOperations and built-in functions that have a Boolean result always\nreturn ``0`` or ``False`` for false and ``1`` or ``True`` for true,\nunless otherwise stated. (Important exception: the Boolean operations\n``or`` and ``and`` always return one of their operands.)\n",
- 'try': '\nThe ``try`` statement\n*********************\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" target]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started. This search inspects the except\nclauses in turn until one is found that matches the exception. An\nexpression-less except clause, if present, must be last; it matches\nany exception. For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception. An object is\ncompatible with an exception if it is the class or a base class of the\nexception object or a tuple containing an item compatible with the\nexception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the ``as`` keyword in that except clause,\nif present, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using ``as target``, it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n N = None\n del N\n\nThat means that you have to assign the exception to a different name\nif you want to be able to refer to it after the except clause. The\nreason for this is that with the traceback attached to them,\nexceptions will form a reference cycle with the stack frame, keeping\nall locals in that frame alive until the next garbage collection\noccurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the ``sys`` module and can be access via\n``sys.exc_info()``. ``sys.exc_info()`` returns a 3-tuple consisting\nof: ``exc_type``, the exception class; ``exc_value``, the exception\ninstance; ``exc_traceback``, a traceback object (see section *The\nstandard type hierarchy*) identifying the point in the program where\nthe exception occurred. ``sys.exc_info()`` values are restored to\ntheir previous values (before the call) when returning from a function\nthat handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler. The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses. If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted. If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is lost. The exception information is not available to the\nprogram during execution of the ``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n',
- 'types': '\nThe standard type hierarchy\n***************************\n\nBelow is a list of the types that are built into Python. Extension\nmodules (written in C, Java, or other languages, depending on the\nimplementation) can define additional types. Future versions of\nPython may add types to the type hierarchy (e.g., rational numbers,\nefficiently stored arrays of integers, etc.), although such additions\nwill often be provided via the standard library instead.\n\nSome of the type descriptions below contain a paragraph listing\n\'special attributes.\' These are attributes that provide access to the\nimplementation and are not intended for general use. Their definition\nmay change in the future.\n\nNone\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name ``None``.\n It is used to signify the absence of a value in many situations,\n e.g., it is returned from functions that don\'t explicitly return\n anything. Its truth value is false.\n\nNotImplemented\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name\n ``NotImplemented``. Numeric methods and rich comparison methods may\n return this value if they do not implement the operation for the\n operands provided. (The interpreter will then try the reflected\n operation, or some other fallback, depending on the operator.) Its\n truth value is true.\n\nEllipsis\n This type has a single value. There is a single object with this\n value. This object is accessed through the literal ``...`` or the\n built-in name ``Ellipsis``. Its truth value is true.\n\n``numbers.Number``\n These are created by numeric literals and returned as results by\n arithmetic operators and arithmetic built-in functions. Numeric\n objects are immutable; once created their value never changes.\n Python numbers are of course strongly related to mathematical\n numbers, but subject to the limitations of numerical representation\n in computers.\n\n Python distinguishes between integers, floating point numbers, and\n complex numbers:\n\n ``numbers.Integral``\n These represent elements from the mathematical set of integers\n (positive and negative).\n\n There are two types of integers:\n\n Integers (``int``)\n\n These represent numbers in an unlimited range, subject to\n available (virtual) memory only. For the purpose of shift\n and mask operations, a binary representation is assumed, and\n negative numbers are represented in a variant of 2\'s\n complement which gives the illusion of an infinite string of\n sign bits extending to the left.\n\n Booleans (``bool``)\n These represent the truth values False and True. The two\n objects representing the values False and True are the only\n Boolean objects. The Boolean type is a subtype of the integer\n type, and Boolean values behave like the values 0 and 1,\n respectively, in almost all contexts, the exception being\n that when converted to a string, the strings ``"False"`` or\n ``"True"`` are returned, respectively.\n\n The rules for integer representation are intended to give the\n most meaningful interpretation of shift and mask operations\n involving negative integers.\n\n ``numbers.Real`` (``float``)\n These represent machine-level double precision floating point\n numbers. You are at the mercy of the underlying machine\n architecture (and C or Java implementation) for the accepted\n range and handling of overflow. Python does not support single-\n precision floating point numbers; the savings in processor and\n memory usage that are usually the reason for using these is\n dwarfed by the overhead of using objects in Python, so there is\n no reason to complicate the language with two kinds of floating\n point numbers.\n\n ``numbers.Complex`` (``complex``)\n These represent complex numbers as a pair of machine-level\n double precision floating point numbers. The same caveats apply\n as for floating point numbers. The real and imaginary parts of a\n complex number ``z`` can be retrieved through the read-only\n attributes ``z.real`` and ``z.imag``.\n\nSequences\n These represent finite ordered sets indexed by non-negative\n numbers. The built-in function ``len()`` returns the number of\n items of a sequence. When the length of a sequence is *n*, the\n index set contains the numbers 0, 1, ..., *n*-1. Item *i* of\n sequence *a* is selected by ``a[i]``.\n\n Sequences also support slicing: ``a[i:j]`` selects all items with\n index *k* such that *i* ``<=`` *k* ``<`` *j*. When used as an\n expression, a slice is a sequence of the same type. This implies\n that the index set is renumbered so that it starts at 0.\n\n Some sequences also support "extended slicing" with a third "step"\n parameter: ``a[i:j:k]`` selects all items of *a* with index *x*\n where ``x = i + n*k``, *n* ``>=`` ``0`` and *i* ``<=`` *x* ``<``\n *j*.\n\n Sequences are distinguished according to their mutability:\n\n Immutable sequences\n An object of an immutable sequence type cannot change once it is\n created. (If the object contains references to other objects,\n these other objects may be mutable and may be changed; however,\n the collection of objects directly referenced by an immutable\n object cannot change.)\n\n The following types are immutable sequences:\n\n Strings\n The items of a string object are Unicode code units. A\n Unicode code unit is represented by a string object of one\n item and can hold either a 16-bit or 32-bit value\n representing a Unicode ordinal (the maximum value for the\n ordinal is given in ``sys.maxunicode``, and depends on how\n Python is configured at compile time). Surrogate pairs may\n be present in the Unicode object, and will be reported as two\n separate items. The built-in functions ``chr()`` and\n ``ord()`` convert between code units and nonnegative integers\n representing the Unicode ordinals as defined in the Unicode\n Standard 3.0. Conversion from and to other encodings are\n possible through the string method ``encode()``.\n\n Tuples\n The items of a tuple are arbitrary Python objects. Tuples of\n two or more items are formed by comma-separated lists of\n expressions. A tuple of one item (a \'singleton\') can be\n formed by affixing a comma to an expression (an expression by\n itself does not create a tuple, since parentheses must be\n usable for grouping of expressions). An empty tuple can be\n formed by an empty pair of parentheses.\n\n Bytes\n A bytes object is an immutable array. The items are 8-bit\n bytes, represented by integers in the range 0 <= x < 256.\n Bytes literals (like ``b\'abc\'`` and the built-in function\n ``bytes()`` can be used to construct bytes objects. Also,\n bytes objects can be decoded to strings via the ``decode()``\n method.\n\n Mutable sequences\n Mutable sequences can be changed after they are created. The\n subscription and slicing notations can be used as the target of\n assignment and ``del`` (delete) statements.\n\n There are currently two intrinsic mutable sequence types:\n\n Lists\n The items of a list are arbitrary Python objects. Lists are\n formed by placing a comma-separated list of expressions in\n square brackets. (Note that there are no special cases needed\n to form lists of length 0 or 1.)\n\n Byte Arrays\n A bytearray object is a mutable array. They are created by\n the built-in ``bytearray()`` constructor. Aside from being\n mutable (and hence unhashable), byte arrays otherwise provide\n the same interface and functionality as immutable bytes\n objects.\n\n The extension module ``array`` provides an additional example of\n a mutable sequence type, as does the ``collections`` module.\n\nSet types\n These represent unordered, finite sets of unique, immutable\n objects. As such, they cannot be indexed by any subscript. However,\n they can be iterated over, and the built-in function ``len()``\n returns the number of items in a set. Common uses for sets are fast\n membership testing, removing duplicates from a sequence, and\n computing mathematical operations such as intersection, union,\n difference, and symmetric difference.\n\n For set elements, the same immutability rules apply as for\n dictionary keys. Note that numeric types obey the normal rules for\n numeric comparison: if two numbers compare equal (e.g., ``1`` and\n ``1.0``), only one of them can be contained in a set.\n\n There are currently two intrinsic set types:\n\n Sets\n These represent a mutable set. They are created by the built-in\n ``set()`` constructor and can be modified afterwards by several\n methods, such as ``add()``.\n\n Frozen sets\n These represent an immutable set. They are created by the\n built-in ``frozenset()`` constructor. As a frozenset is\n immutable and *hashable*, it can be used again as an element of\n another set, or as a dictionary key.\n\nMappings\n These represent finite sets of objects indexed by arbitrary index\n sets. The subscript notation ``a[k]`` selects the item indexed by\n ``k`` from the mapping ``a``; this can be used in expressions and\n as the target of assignments or ``del`` statements. The built-in\n function ``len()`` returns the number of items in a mapping.\n\n There is currently a single intrinsic mapping type:\n\n Dictionaries\n These represent finite sets of objects indexed by nearly\n arbitrary values. The only types of values not acceptable as\n keys are values containing lists or dictionaries or other\n mutable types that are compared by value rather than by object\n identity, the reason being that the efficient implementation of\n dictionaries requires a key\'s hash value to remain constant.\n Numeric types used for keys obey the normal rules for numeric\n comparison: if two numbers compare equal (e.g., ``1`` and\n ``1.0``) then they can be used interchangeably to index the same\n dictionary entry.\n\n Dictionaries are mutable; they can be created by the ``{...}``\n notation (see section *Dictionary displays*).\n\n The extension modules ``dbm.ndbm`` and ``dbm.gnu`` provide\n additional examples of mapping types, as does the\n ``collections`` module.\n\nCallable types\n These are the types to which the function call operation (see\n section *Calls*) can be applied:\n\n User-defined functions\n A user-defined function object is created by a function\n definition (see section *Function definitions*). It should be\n called with an argument list containing the same number of items\n as the function\'s formal parameter list.\n\n Special attributes:\n\n +---------------------------+---------------------------------+-------------+\n | Attribute | Meaning | |\n +===========================+=================================+=============+\n | ``__doc__`` | The function\'s documentation | Writable |\n | | string, or ``None`` if | |\n | | unavailable | |\n +---------------------------+---------------------------------+-------------+\n | ``__name__`` | The function\'s name | Writable |\n +---------------------------+---------------------------------+-------------+\n | ``__module__`` | The name of the module the | Writable |\n | | function was defined in, or | |\n | | ``None`` if unavailable. | |\n +---------------------------+---------------------------------+-------------+\n | ``__defaults__`` | A tuple containing default | Writable |\n | | argument values for those | |\n | | arguments that have defaults, | |\n | | or ``None`` if no arguments | |\n | | have a default value | |\n +---------------------------+---------------------------------+-------------+\n | ``__code__`` | The code object representing | Writable |\n | | the compiled function body. | |\n +---------------------------+---------------------------------+-------------+\n | ``__globals__`` | A reference to the dictionary | Read-only |\n | | that holds the function\'s | |\n | | global variables --- the global | |\n | | namespace of the module in | |\n | | which the function was defined. | |\n +---------------------------+---------------------------------+-------------+\n | ``__dict__`` | The namespace supporting | Writable |\n | | arbitrary function attributes. | |\n +---------------------------+---------------------------------+-------------+\n | ``__closure__`` | ``None`` or a tuple of cells | Read-only |\n | | that contain bindings for the | |\n | | function\'s free variables. | |\n +---------------------------+---------------------------------+-------------+\n | ``__annotations__`` | A dict containing annotations | Writable |\n | | of parameters. The keys of the | |\n | | dict are the parameter names, | |\n | | or ``\'return\'`` for the return | |\n | | annotation, if provided. | |\n +---------------------------+---------------------------------+-------------+\n | ``__kwdefaults__`` | A dict containing defaults for | Writable |\n | | keyword-only parameters. | |\n +---------------------------+---------------------------------+-------------+\n\n Most of the attributes labelled "Writable" check the type of the\n assigned value.\n\n Function objects also support getting and setting arbitrary\n attributes, which can be used, for example, to attach metadata\n to functions. Regular attribute dot-notation is used to get and\n set such attributes. *Note that the current implementation only\n supports function attributes on user-defined functions. Function\n attributes on built-in functions may be supported in the\n future.*\n\n Additional information about a function\'s definition can be\n retrieved from its code object; see the description of internal\n types below.\n\n Instance methods\n An instance method object combines a class, a class instance and\n any callable object (normally a user-defined function).\n\n Special read-only attributes: ``__self__`` is the class instance\n object, ``__func__`` is the function object; ``__doc__`` is the\n method\'s documentation (same as ``__func__.__doc__``);\n ``__name__`` is the method name (same as ``__func__.__name__``);\n ``__module__`` is the name of the module the method was defined\n in, or ``None`` if unavailable.\n\n Methods also support accessing (but not setting) the arbitrary\n function attributes on the underlying function object.\n\n User-defined method objects may be created when getting an\n attribute of a class (perhaps via an instance of that class), if\n that attribute is a user-defined function object or a class\n method object.\n\n When an instance method object is created by retrieving a user-\n defined function object from a class via one of its instances,\n its ``__self__`` attribute is the instance, and the method\n object is said to be bound. The new method\'s ``__func__``\n attribute is the original function object.\n\n When a user-defined method object is created by retrieving\n another method object from a class or instance, the behaviour is\n the same as for a function object, except that the ``__func__``\n attribute of the new instance is not the original method object\n but its ``__func__`` attribute.\n\n When an instance method object is created by retrieving a class\n method object from a class or instance, its ``__self__``\n attribute is the class itself, and its ``__func__`` attribute is\n the function object underlying the class method.\n\n When an instance method object is called, the underlying\n function (``__func__``) is called, inserting the class instance\n (``__self__``) in front of the argument list. For instance,\n when ``C`` is a class which contains a definition for a function\n ``f()``, and ``x`` is an instance of ``C``, calling ``x.f(1)``\n is equivalent to calling ``C.f(x, 1)``.\n\n When an instance method object is derived from a class method\n object, the "class instance" stored in ``__self__`` will\n actually be the class itself, so that calling either ``x.f(1)``\n or ``C.f(1)`` is equivalent to calling ``f(C,1)`` where ``f`` is\n the underlying function.\n\n Note that the transformation from function object to instance\n method object happens each time the attribute is retrieved from\n the instance. In some cases, a fruitful optimization is to\n assign the attribute to a local variable and call that local\n variable. Also notice that this transformation only happens for\n user-defined functions; other callable objects (and all non-\n callable objects) are retrieved without transformation. It is\n also important to note that user-defined functions which are\n attributes of a class instance are not converted to bound\n methods; this *only* happens when the function is an attribute\n of the class.\n\n Generator functions\n A function or method which uses the ``yield`` statement (see\n section *The yield statement*) is called a *generator function*.\n Such a function, when called, always returns an iterator object\n which can be used to execute the body of the function: calling\n the iterator\'s ``__next__()`` method will cause the function to\n execute until it provides a value using the ``yield`` statement.\n When the function executes a ``return`` statement or falls off\n the end, a ``StopIteration`` exception is raised and the\n iterator will have reached the end of the set of values to be\n returned.\n\n Built-in functions\n A built-in function object is a wrapper around a C function.\n Examples of built-in functions are ``len()`` and ``math.sin()``\n (``math`` is a standard built-in module). The number and type of\n the arguments are determined by the C function. Special read-\n only attributes: ``__doc__`` is the function\'s documentation\n string, or ``None`` if unavailable; ``__name__`` is the\n function\'s name; ``__self__`` is set to ``None`` (but see the\n next item); ``__module__`` is the name of the module the\n function was defined in or ``None`` if unavailable.\n\n Built-in methods\n This is really a different disguise of a built-in function, this\n time containing an object passed to the C function as an\n implicit extra argument. An example of a built-in method is\n ``alist.append()``, assuming *alist* is a list object. In this\n case, the special read-only attribute ``__self__`` is set to the\n object denoted by *list*.\n\n Classes\n Classes are callable. These objects normally act as factories\n for new instances of themselves, but variations are possible for\n class types that override ``__new__()``. The arguments of the\n call are passed to ``__new__()`` and, in the typical case, to\n ``__init__()`` to initialize the new instance.\n\n Class Instances\n Instances of arbitrary classes can be made callable by defining\n a ``__call__()`` method in their class.\n\nModules\n Modules are imported by the ``import`` statement (see section *The\n import statement*). A module object has a namespace implemented by\n a dictionary object (this is the dictionary referenced by the\n __globals__ attribute of functions defined in the module).\n Attribute references are translated to lookups in this dictionary,\n e.g., ``m.x`` is equivalent to ``m.__dict__["x"]``. A module object\n does not contain the code object used to initialize the module\n (since it isn\'t needed once the initialization is done).\n\n Attribute assignment updates the module\'s namespace dictionary,\n e.g., ``m.x = 1`` is equivalent to ``m.__dict__["x"] = 1``.\n\n Special read-only attribute: ``__dict__`` is the module\'s namespace\n as a dictionary object.\n\n Predefined (writable) attributes: ``__name__`` is the module\'s\n name; ``__doc__`` is the module\'s documentation string, or ``None``\n if unavailable; ``__file__`` is the pathname of the file from which\n the module was loaded, if it was loaded from a file. The\n ``__file__`` attribute is not present for C modules that are\n statically linked into the interpreter; for extension modules\n loaded dynamically from a shared library, it is the pathname of the\n shared library file.\n\nCustom classes\n Custon class types are typically created by class definitions (see\n section *Class definitions*). A class has a namespace implemented\n by a dictionary object. Class attribute references are translated\n to lookups in this dictionary, e.g., ``C.x`` is translated to\n ``C.__dict__["x"]`` (although there are a number of hooks which\n allow for other means of locating attributes). When the attribute\n name is not found there, the attribute search continues in the base\n classes. This search of the base classes uses the C3 method\n resolution order which behaves correctly even in the presence of\n \'diamond\' inheritance structures where there are multiple\n inheritance paths leading back to a common ancestor. Additional\n details on the C3 MRO used by Python can be found in the\n documentation accompanying the 2.3 release at\n http://www.python.org/download/releases/2.3/mro/.\n\n When a class attribute reference (for class ``C``, say) would yield\n a class method object, it is transformed into an instance method\n object whose ``__self__`` attributes is ``C``. When it would yield\n a static method object, it is transformed into the object wrapped\n by the static method object. See section *Implementing Descriptors*\n for another way in which attributes retrieved from a class may\n differ from those actually contained in its ``__dict__``.\n\n Class attribute assignments update the class\'s dictionary, never\n the dictionary of a base class.\n\n A class object can be called (see above) to yield a class instance\n (see below).\n\n Special attributes: ``__name__`` is the class name; ``__module__``\n is the module name in which the class was defined; ``__dict__`` is\n the dictionary containing the class\'s namespace; ``__bases__`` is a\n tuple (possibly empty or a singleton) containing the base classes,\n in the order of their occurrence in the base class list;\n ``__doc__`` is the class\'s documentation string, or None if\n undefined.\n\nClass instances\n A class instance is created by calling a class object (see above).\n A class instance has a namespace implemented as a dictionary which\n is the first place in which attribute references are searched.\n When an attribute is not found there, and the instance\'s class has\n an attribute by that name, the search continues with the class\n attributes. If a class attribute is found that is a user-defined\n function object, it is transformed into an instance method object\n whose ``__self__`` attribute is the instance. Static method and\n class method objects are also transformed; see above under\n "Classes". See section *Implementing Descriptors* for another way\n in which attributes of a class retrieved via its instances may\n differ from the objects actually stored in the class\'s\n ``__dict__``. If no class attribute is found, and the object\'s\n class has a ``__getattr__()`` method, that is called to satisfy the\n lookup.\n\n Attribute assignments and deletions update the instance\'s\n dictionary, never a class\'s dictionary. If the class has a\n ``__setattr__()`` or ``__delattr__()`` method, this is called\n instead of updating the instance dictionary directly.\n\n Class instances can pretend to be numbers, sequences, or mappings\n if they have methods with certain special names. See section\n *Special method names*.\n\n Special attributes: ``__dict__`` is the attribute dictionary;\n ``__class__`` is the instance\'s class.\n\nFiles\n A file object represents an open file. File objects are created by\n the ``open()`` built-in function, and also by ``os.popen()``,\n ``os.fdopen()``, and the ``makefile()`` method of socket objects\n (and perhaps by other functions or methods provided by extension\n modules). The objects ``sys.stdin``, ``sys.stdout`` and\n ``sys.stderr`` are initialized to file objects corresponding to the\n interpreter\'s standard input, output and error streams. See *File\n Objects* for complete documentation of file objects.\n\nInternal types\n A few types used internally by the interpreter are exposed to the\n user. Their definitions may change with future versions of the\n interpreter, but they are mentioned here for completeness.\n\n Code objects\n Code objects represent *byte-compiled* executable Python code,\n or *bytecode*. The difference between a code object and a\n function object is that the function object contains an explicit\n reference to the function\'s globals (the module in which it was\n defined), while a code object contains no context; also the\n default argument values are stored in the function object, not\n in the code object (because they represent values calculated at\n run-time). Unlike function objects, code objects are immutable\n and contain no references (directly or indirectly) to mutable\n objects.\n\n Special read-only attributes: ``co_name`` gives the function\n name; ``co_argcount`` is the number of positional arguments\n (including arguments with default values); ``co_nlocals`` is the\n number of local variables used by the function (including\n arguments); ``co_varnames`` is a tuple containing the names of\n the local variables (starting with the argument names);\n ``co_cellvars`` is a tuple containing the names of local\n variables that are referenced by nested functions;\n ``co_freevars`` is a tuple containing the names of free\n variables; ``co_code`` is a string representing the sequence of\n bytecode instructions; ``co_consts`` is a tuple containing the\n literals used by the bytecode; ``co_names`` is a tuple\n containing the names used by the bytecode; ``co_filename`` is\n the filename from which the code was compiled;\n ``co_firstlineno`` is the first line number of the function;\n ``co_lnotab`` is a string encoding the mapping from bytecode\n offsets to line numbers (for details see the source code of the\n interpreter); ``co_stacksize`` is the required stack size\n (including local variables); ``co_flags`` is an integer encoding\n a number of flags for the interpreter.\n\n The following flag bits are defined for ``co_flags``: bit\n ``0x04`` is set if the function uses the ``*arguments`` syntax\n to accept an arbitrary number of positional arguments; bit\n ``0x08`` is set if the function uses the ``**keywords`` syntax\n to accept arbitrary keyword arguments; bit ``0x20`` is set if\n the function is a generator.\n\n Future feature declarations (``from __future__ import\n division``) also use bits in ``co_flags`` to indicate whether a\n code object was compiled with a particular feature enabled: bit\n ``0x2000`` is set if the function was compiled with future\n division enabled; bits ``0x10`` and ``0x1000`` were used in\n earlier versions of Python.\n\n Other bits in ``co_flags`` are reserved for internal use.\n\n If a code object represents a function, the first item in\n ``co_consts`` is the documentation string of the function, or\n ``None`` if undefined.\n\n Frame objects\n Frame objects represent execution frames. They may occur in\n traceback objects (see below).\n\n Special read-only attributes: ``f_back`` is to the previous\n stack frame (towards the caller), or ``None`` if this is the\n bottom stack frame; ``f_code`` is the code object being executed\n in this frame; ``f_locals`` is the dictionary used to look up\n local variables; ``f_globals`` is used for global variables;\n ``f_builtins`` is used for built-in (intrinsic) names;\n ``f_lasti`` gives the precise instruction (this is an index into\n the bytecode string of the code object).\n\n Special writable attributes: ``f_trace``, if not ``None``, is a\n function called at the start of each source code line (this is\n used by the debugger); ``f_lineno`` is the current line number\n of the frame --- writing to this from within a trace function\n jumps to the given line (only for the bottom-most frame). A\n debugger can implement a Jump command (aka Set Next Statement)\n by writing to f_lineno.\n\n Traceback objects\n Traceback objects represent a stack trace of an exception. A\n traceback object is created when an exception occurs. When the\n search for an exception handler unwinds the execution stack, at\n each unwound level a traceback object is inserted in front of\n the current traceback. When an exception handler is entered,\n the stack trace is made available to the program. (See section\n *The try statement*.) It is accessible as the third item of the\n tuple returned by ``sys.exc_info()``. When the program contains\n no suitable handler, the stack trace is written (nicely\n formatted) to the standard error stream; if the interpreter is\n interactive, it is also made available to the user as\n ``sys.last_traceback``.\n\n Special read-only attributes: ``tb_next`` is the next level in\n the stack trace (towards the frame where the exception\n occurred), or ``None`` if there is no next level; ``tb_frame``\n points to the execution frame of the current level;\n ``tb_lineno`` gives the line number where the exception\n occurred; ``tb_lasti`` indicates the precise instruction. The\n line number and last instruction in the traceback may differ\n from the line number of its frame object if the exception\n occurred in a ``try`` statement with no matching except clause\n or with a finally clause.\n\n Slice objects\n Slice objects are used to represent slices for ``__getitem__()``\n methods. They are also created by the built-in ``slice()``\n function.\n\n Special read-only attributes: ``start`` is the lower bound;\n ``stop`` is the upper bound; ``step`` is the step value; each is\n ``None`` if omitted. These attributes can have any type.\n\n Slice objects support one method:\n\n slice.indices(self, length)\n\n This method takes a single integer argument *length* and\n computes information about the slice that the slice object\n would describe if applied to a sequence of *length* items.\n It returns a tuple of three integers; respectively these are\n the *start* and *stop* indices and the *step* or stride\n length of the slice. Missing or out-of-bounds indices are\n handled in a manner consistent with regular slices.\n\n Static method objects\n Static method objects provide a way of defeating the\n transformation of function objects to method objects described\n above. A static method object is a wrapper around any other\n object, usually a user-defined method object. When a static\n method object is retrieved from a class or a class instance, the\n object actually returned is the wrapped object, which is not\n subject to any further transformation. Static method objects are\n not themselves callable, although the objects they wrap usually\n are. Static method objects are created by the built-in\n ``staticmethod()`` constructor.\n\n Class method objects\n A class method object, like a static method object, is a wrapper\n around another object that alters the way in which that object\n is retrieved from classes and class instances. The behaviour of\n class method objects upon such retrieval is described above,\n under "User-defined methods". Class method objects are created\n by the built-in ``classmethod()`` constructor.\n',
+ 'try': '\nThe ``try`` statement\n*********************\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" target]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started. This search inspects the except\nclauses in turn until one is found that matches the exception. An\nexpression-less except clause, if present, must be last; it matches\nany exception. For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception. An object is\ncompatible with an exception if it is the class or a base class of the\nexception object or a tuple containing an item compatible with the\nexception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the ``as`` keyword in that except clause,\nif present, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using ``as target``, it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the ``sys`` module and can be access via\n``sys.exc_info()``. ``sys.exc_info()`` returns a 3-tuple consisting of\nthe exception class, the exception instance and a traceback object\n(see section *The standard type hierarchy*) identifying the point in\nthe program where the exception occurred. ``sys.exc_info()`` values\nare restored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler. The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses. If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted. If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is lost. The exception information is not available to the\nprogram during execution of the ``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n',
+ 'types': '\nThe standard type hierarchy\n***************************\n\nBelow is a list of the types that are built into Python. Extension\nmodules (written in C, Java, or other languages, depending on the\nimplementation) can define additional types. Future versions of\nPython may add types to the type hierarchy (e.g., rational numbers,\nefficiently stored arrays of integers, etc.), although such additions\nwill often be provided via the standard library instead.\n\nSome of the type descriptions below contain a paragraph listing\n\'special attributes.\' These are attributes that provide access to the\nimplementation and are not intended for general use. Their definition\nmay change in the future.\n\nNone\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name ``None``.\n It is used to signify the absence of a value in many situations,\n e.g., it is returned from functions that don\'t explicitly return\n anything. Its truth value is false.\n\nNotImplemented\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name\n ``NotImplemented``. Numeric methods and rich comparison methods may\n return this value if they do not implement the operation for the\n operands provided. (The interpreter will then try the reflected\n operation, or some other fallback, depending on the operator.) Its\n truth value is true.\n\nEllipsis\n This type has a single value. There is a single object with this\n value. This object is accessed through the literal ``...`` or the\n built-in name ``Ellipsis``. Its truth value is true.\n\n``numbers.Number``\n These are created by numeric literals and returned as results by\n arithmetic operators and arithmetic built-in functions. Numeric\n objects are immutable; once created their value never changes.\n Python numbers are of course strongly related to mathematical\n numbers, but subject to the limitations of numerical representation\n in computers.\n\n Python distinguishes between integers, floating point numbers, and\n complex numbers:\n\n ``numbers.Integral``\n These represent elements from the mathematical set of integers\n (positive and negative).\n\n There are two types of integers:\n\n Integers (``int``)\n\n These represent numbers in an unlimited range, subject to\n available (virtual) memory only. For the purpose of shift\n and mask operations, a binary representation is assumed, and\n negative numbers are represented in a variant of 2\'s\n complement which gives the illusion of an infinite string of\n sign bits extending to the left.\n\n Booleans (``bool``)\n These represent the truth values False and True. The two\n objects representing the values False and True are the only\n Boolean objects. The Boolean type is a subtype of the integer\n type, and Boolean values behave like the values 0 and 1,\n respectively, in almost all contexts, the exception being\n that when converted to a string, the strings ``"False"`` or\n ``"True"`` are returned, respectively.\n\n The rules for integer representation are intended to give the\n most meaningful interpretation of shift and mask operations\n involving negative integers.\n\n ``numbers.Real`` (``float``)\n These represent machine-level double precision floating point\n numbers. You are at the mercy of the underlying machine\n architecture (and C or Java implementation) for the accepted\n range and handling of overflow. Python does not support single-\n precision floating point numbers; the savings in processor and\n memory usage that are usually the reason for using these is\n dwarfed by the overhead of using objects in Python, so there is\n no reason to complicate the language with two kinds of floating\n point numbers.\n\n ``numbers.Complex`` (``complex``)\n These represent complex numbers as a pair of machine-level\n double precision floating point numbers. The same caveats apply\n as for floating point numbers. The real and imaginary parts of a\n complex number ``z`` can be retrieved through the read-only\n attributes ``z.real`` and ``z.imag``.\n\nSequences\n These represent finite ordered sets indexed by non-negative\n numbers. The built-in function ``len()`` returns the number of\n items of a sequence. When the length of a sequence is *n*, the\n index set contains the numbers 0, 1, ..., *n*-1. Item *i* of\n sequence *a* is selected by ``a[i]``.\n\n Sequences also support slicing: ``a[i:j]`` selects all items with\n index *k* such that *i* ``<=`` *k* ``<`` *j*. When used as an\n expression, a slice is a sequence of the same type. This implies\n that the index set is renumbered so that it starts at 0.\n\n Some sequences also support "extended slicing" with a third "step"\n parameter: ``a[i:j:k]`` selects all items of *a* with index *x*\n where ``x = i + n*k``, *n* ``>=`` ``0`` and *i* ``<=`` *x* ``<``\n *j*.\n\n Sequences are distinguished according to their mutability:\n\n Immutable sequences\n An object of an immutable sequence type cannot change once it is\n created. (If the object contains references to other objects,\n these other objects may be mutable and may be changed; however,\n the collection of objects directly referenced by an immutable\n object cannot change.)\n\n The following types are immutable sequences:\n\n Strings\n The items of a string object are Unicode code units. A\n Unicode code unit is represented by a string object of one\n item and can hold either a 16-bit or 32-bit value\n representing a Unicode ordinal (the maximum value for the\n ordinal is given in ``sys.maxunicode``, and depends on how\n Python is configured at compile time). Surrogate pairs may\n be present in the Unicode object, and will be reported as two\n separate items. The built-in functions ``chr()`` and\n ``ord()`` convert between code units and nonnegative integers\n representing the Unicode ordinals as defined in the Unicode\n Standard 3.0. Conversion from and to other encodings are\n possible through the string method ``encode()``.\n\n Tuples\n The items of a tuple are arbitrary Python objects. Tuples of\n two or more items are formed by comma-separated lists of\n expressions. A tuple of one item (a \'singleton\') can be\n formed by affixing a comma to an expression (an expression by\n itself does not create a tuple, since parentheses must be\n usable for grouping of expressions). An empty tuple can be\n formed by an empty pair of parentheses.\n\n Bytes\n A bytes object is an immutable array. The items are 8-bit\n bytes, represented by integers in the range 0 <= x < 256.\n Bytes literals (like ``b\'abc\'`` and the built-in function\n ``bytes()`` can be used to construct bytes objects. Also,\n bytes objects can be decoded to strings via the ``decode()``\n method.\n\n Mutable sequences\n Mutable sequences can be changed after they are created. The\n subscription and slicing notations can be used as the target of\n assignment and ``del`` (delete) statements.\n\n There are currently two intrinsic mutable sequence types:\n\n Lists\n The items of a list are arbitrary Python objects. Lists are\n formed by placing a comma-separated list of expressions in\n square brackets. (Note that there are no special cases needed\n to form lists of length 0 or 1.)\n\n Byte Arrays\n A bytearray object is a mutable array. They are created by\n the built-in ``bytearray()`` constructor. Aside from being\n mutable (and hence unhashable), byte arrays otherwise provide\n the same interface and functionality as immutable bytes\n objects.\n\n The extension module ``array`` provides an additional example of\n a mutable sequence type, as does the ``collections`` module.\n\nSet types\n These represent unordered, finite sets of unique, immutable\n objects. As such, they cannot be indexed by any subscript. However,\n they can be iterated over, and the built-in function ``len()``\n returns the number of items in a set. Common uses for sets are fast\n membership testing, removing duplicates from a sequence, and\n computing mathematical operations such as intersection, union,\n difference, and symmetric difference.\n\n For set elements, the same immutability rules apply as for\n dictionary keys. Note that numeric types obey the normal rules for\n numeric comparison: if two numbers compare equal (e.g., ``1`` and\n ``1.0``), only one of them can be contained in a set.\n\n There are currently two intrinsic set types:\n\n Sets\n These represent a mutable set. They are created by the built-in\n ``set()`` constructor and can be modified afterwards by several\n methods, such as ``add()``.\n\n Frozen sets\n These represent an immutable set. They are created by the\n built-in ``frozenset()`` constructor. As a frozenset is\n immutable and *hashable*, it can be used again as an element of\n another set, or as a dictionary key.\n\nMappings\n These represent finite sets of objects indexed by arbitrary index\n sets. The subscript notation ``a[k]`` selects the item indexed by\n ``k`` from the mapping ``a``; this can be used in expressions and\n as the target of assignments or ``del`` statements. The built-in\n function ``len()`` returns the number of items in a mapping.\n\n There is currently a single intrinsic mapping type:\n\n Dictionaries\n These represent finite sets of objects indexed by nearly\n arbitrary values. The only types of values not acceptable as\n keys are values containing lists or dictionaries or other\n mutable types that are compared by value rather than by object\n identity, the reason being that the efficient implementation of\n dictionaries requires a key\'s hash value to remain constant.\n Numeric types used for keys obey the normal rules for numeric\n comparison: if two numbers compare equal (e.g., ``1`` and\n ``1.0``) then they can be used interchangeably to index the same\n dictionary entry.\n\n Dictionaries are mutable; they can be created by the ``{...}``\n notation (see section *Dictionary displays*).\n\n The extension modules ``dbm.ndbm`` and ``dbm.gnu`` provide\n additional examples of mapping types, as does the\n ``collections`` module.\n\nCallable types\n These are the types to which the function call operation (see\n section *Calls*) can be applied:\n\n User-defined functions\n A user-defined function object is created by a function\n definition (see section *Function definitions*). It should be\n called with an argument list containing the same number of items\n as the function\'s formal parameter list.\n\n Special attributes:\n\n +---------------------------+---------------------------------+-------------+\n | Attribute | Meaning | |\n +===========================+=================================+=============+\n | ``__doc__`` | The function\'s documentation | Writable |\n | | string, or ``None`` if | |\n | | unavailable | |\n +---------------------------+---------------------------------+-------------+\n | ``__name__`` | The function\'s name | Writable |\n +---------------------------+---------------------------------+-------------+\n | ``__module__`` | The name of the module the | Writable |\n | | function was defined in, or | |\n | | ``None`` if unavailable. | |\n +---------------------------+---------------------------------+-------------+\n | ``__defaults__`` | A tuple containing default | Writable |\n | | argument values for those | |\n | | arguments that have defaults, | |\n | | or ``None`` if no arguments | |\n | | have a default value | |\n +---------------------------+---------------------------------+-------------+\n | ``__code__`` | The code object representing | Writable |\n | | the compiled function body. | |\n +---------------------------+---------------------------------+-------------+\n | ``__globals__`` | A reference to the dictionary | Read-only |\n | | that holds the function\'s | |\n | | global variables --- the global | |\n | | namespace of the module in | |\n | | which the function was defined. | |\n +---------------------------+---------------------------------+-------------+\n | ``__dict__`` | The namespace supporting | Writable |\n | | arbitrary function attributes. | |\n +---------------------------+---------------------------------+-------------+\n | ``__closure__`` | ``None`` or a tuple of cells | Read-only |\n | | that contain bindings for the | |\n | | function\'s free variables. | |\n +---------------------------+---------------------------------+-------------+\n | ``__annotations__`` | A dict containing annotations | Writable |\n | | of parameters. The keys of the | |\n | | dict are the parameter names, | |\n | | or ``\'return\'`` for the return | |\n | | annotation, if provided. | |\n +---------------------------+---------------------------------+-------------+\n | ``__kwdefaults__`` | A dict containing defaults for | Writable |\n | | keyword-only parameters. | |\n +---------------------------+---------------------------------+-------------+\n\n Most of the attributes labelled "Writable" check the type of the\n assigned value.\n\n Function objects also support getting and setting arbitrary\n attributes, which can be used, for example, to attach metadata\n to functions. Regular attribute dot-notation is used to get and\n set such attributes. *Note that the current implementation only\n supports function attributes on user-defined functions. Function\n attributes on built-in functions may be supported in the\n future.*\n\n Additional information about a function\'s definition can be\n retrieved from its code object; see the description of internal\n types below.\n\n Instance methods\n An instance method object combines a class, a class instance and\n any callable object (normally a user-defined function).\n\n Special read-only attributes: ``__self__`` is the class instance\n object, ``__func__`` is the function object; ``__doc__`` is the\n method\'s documentation (same as ``__func__.__doc__``);\n ``__name__`` is the method name (same as ``__func__.__name__``);\n ``__module__`` is the name of the module the method was defined\n in, or ``None`` if unavailable.\n\n Methods also support accessing (but not setting) the arbitrary\n function attributes on the underlying function object.\n\n User-defined method objects may be created when getting an\n attribute of a class (perhaps via an instance of that class), if\n that attribute is a user-defined function object or a class\n method object.\n\n When an instance method object is created by retrieving a user-\n defined function object from a class via one of its instances,\n its ``__self__`` attribute is the instance, and the method\n object is said to be bound. The new method\'s ``__func__``\n attribute is the original function object.\n\n When a user-defined method object is created by retrieving\n another method object from a class or instance, the behaviour is\n the same as for a function object, except that the ``__func__``\n attribute of the new instance is not the original method object\n but its ``__func__`` attribute.\n\n When an instance method object is created by retrieving a class\n method object from a class or instance, its ``__self__``\n attribute is the class itself, and its ``__func__`` attribute is\n the function object underlying the class method.\n\n When an instance method object is called, the underlying\n function (``__func__``) is called, inserting the class instance\n (``__self__``) in front of the argument list. For instance,\n when ``C`` is a class which contains a definition for a function\n ``f()``, and ``x`` is an instance of ``C``, calling ``x.f(1)``\n is equivalent to calling ``C.f(x, 1)``.\n\n When an instance method object is derived from a class method\n object, the "class instance" stored in ``__self__`` will\n actually be the class itself, so that calling either ``x.f(1)``\n or ``C.f(1)`` is equivalent to calling ``f(C,1)`` where ``f`` is\n the underlying function.\n\n Note that the transformation from function object to instance\n method object happens each time the attribute is retrieved from\n the instance. In some cases, a fruitful optimization is to\n assign the attribute to a local variable and call that local\n variable. Also notice that this transformation only happens for\n user-defined functions; other callable objects (and all non-\n callable objects) are retrieved without transformation. It is\n also important to note that user-defined functions which are\n attributes of a class instance are not converted to bound\n methods; this *only* happens when the function is an attribute\n of the class.\n\n Generator functions\n A function or method which uses the ``yield`` statement (see\n section *The yield statement*) is called a *generator function*.\n Such a function, when called, always returns an iterator object\n which can be used to execute the body of the function: calling\n the iterator\'s ``__next__()`` method will cause the function to\n execute until it provides a value using the ``yield`` statement.\n When the function executes a ``return`` statement or falls off\n the end, a ``StopIteration`` exception is raised and the\n iterator will have reached the end of the set of values to be\n returned.\n\n Built-in functions\n A built-in function object is a wrapper around a C function.\n Examples of built-in functions are ``len()`` and ``math.sin()``\n (``math`` is a standard built-in module). The number and type of\n the arguments are determined by the C function. Special read-\n only attributes: ``__doc__`` is the function\'s documentation\n string, or ``None`` if unavailable; ``__name__`` is the\n function\'s name; ``__self__`` is set to ``None`` (but see the\n next item); ``__module__`` is the name of the module the\n function was defined in or ``None`` if unavailable.\n\n Built-in methods\n This is really a different disguise of a built-in function, this\n time containing an object passed to the C function as an\n implicit extra argument. An example of a built-in method is\n ``alist.append()``, assuming *alist* is a list object. In this\n case, the special read-only attribute ``__self__`` is set to the\n object denoted by *alist*.\n\n Classes\n Classes are callable. These objects normally act as factories\n for new instances of themselves, but variations are possible for\n class types that override ``__new__()``. The arguments of the\n call are passed to ``__new__()`` and, in the typical case, to\n ``__init__()`` to initialize the new instance.\n\n Class Instances\n Instances of arbitrary classes can be made callable by defining\n a ``__call__()`` method in their class.\n\nModules\n Modules are imported by the ``import`` statement (see section *The\n import statement*). A module object has a namespace implemented by\n a dictionary object (this is the dictionary referenced by the\n __globals__ attribute of functions defined in the module).\n Attribute references are translated to lookups in this dictionary,\n e.g., ``m.x`` is equivalent to ``m.__dict__["x"]``. A module object\n does not contain the code object used to initialize the module\n (since it isn\'t needed once the initialization is done).\n\n Attribute assignment updates the module\'s namespace dictionary,\n e.g., ``m.x = 1`` is equivalent to ``m.__dict__["x"] = 1``.\n\n Special read-only attribute: ``__dict__`` is the module\'s namespace\n as a dictionary object.\n\n **CPython implementation detail:** Because of the way CPython\n clears module dictionaries, the module dictionary will be cleared\n when the module falls out of scope even if the dictionary still has\n live references. To avoid this, copy the dictionary or keep the\n module around while using its dictionary directly.\n\n Predefined (writable) attributes: ``__name__`` is the module\'s\n name; ``__doc__`` is the module\'s documentation string, or ``None``\n if unavailable; ``__file__`` is the pathname of the file from which\n the module was loaded, if it was loaded from a file. The\n ``__file__`` attribute is not present for C modules that are\n statically linked into the interpreter; for extension modules\n loaded dynamically from a shared library, it is the pathname of the\n shared library file.\n\nCustom classes\n Custom class types are typically created by class definitions (see\n section *Class definitions*). A class has a namespace implemented\n by a dictionary object. Class attribute references are translated\n to lookups in this dictionary, e.g., ``C.x`` is translated to\n ``C.__dict__["x"]`` (although there are a number of hooks which\n allow for other means of locating attributes). When the attribute\n name is not found there, the attribute search continues in the base\n classes. This search of the base classes uses the C3 method\n resolution order which behaves correctly even in the presence of\n \'diamond\' inheritance structures where there are multiple\n inheritance paths leading back to a common ancestor. Additional\n details on the C3 MRO used by Python can be found in the\n documentation accompanying the 2.3 release at\n http://www.python.org/download/releases/2.3/mro/.\n\n When a class attribute reference (for class ``C``, say) would yield\n a class method object, it is transformed into an instance method\n object whose ``__self__`` attributes is ``C``. When it would yield\n a static method object, it is transformed into the object wrapped\n by the static method object. See section *Implementing Descriptors*\n for another way in which attributes retrieved from a class may\n differ from those actually contained in its ``__dict__``.\n\n Class attribute assignments update the class\'s dictionary, never\n the dictionary of a base class.\n\n A class object can be called (see above) to yield a class instance\n (see below).\n\n Special attributes: ``__name__`` is the class name; ``__module__``\n is the module name in which the class was defined; ``__dict__`` is\n the dictionary containing the class\'s namespace; ``__bases__`` is a\n tuple (possibly empty or a singleton) containing the base classes,\n in the order of their occurrence in the base class list;\n ``__doc__`` is the class\'s documentation string, or None if\n undefined.\n\nClass instances\n A class instance is created by calling a class object (see above).\n A class instance has a namespace implemented as a dictionary which\n is the first place in which attribute references are searched.\n When an attribute is not found there, and the instance\'s class has\n an attribute by that name, the search continues with the class\n attributes. If a class attribute is found that is a user-defined\n function object, it is transformed into an instance method object\n whose ``__self__`` attribute is the instance. Static method and\n class method objects are also transformed; see above under\n "Classes". See section *Implementing Descriptors* for another way\n in which attributes of a class retrieved via its instances may\n differ from the objects actually stored in the class\'s\n ``__dict__``. If no class attribute is found, and the object\'s\n class has a ``__getattr__()`` method, that is called to satisfy the\n lookup.\n\n Attribute assignments and deletions update the instance\'s\n dictionary, never a class\'s dictionary. If the class has a\n ``__setattr__()`` or ``__delattr__()`` method, this is called\n instead of updating the instance dictionary directly.\n\n Class instances can pretend to be numbers, sequences, or mappings\n if they have methods with certain special names. See section\n *Special method names*.\n\n Special attributes: ``__dict__`` is the attribute dictionary;\n ``__class__`` is the instance\'s class.\n\nI/O objects (also known as file objects)\n A *file object* represents an open file. Various shortcuts are\n available to create file objects: the ``open()`` built-in function,\n and also ``os.popen()``, ``os.fdopen()``, and the ``makefile()``\n method of socket objects (and perhaps by other functions or methods\n provided by extension modules).\n\n The objects ``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` are\n initialized to file objects corresponding to the interpreter\'s\n standard input, output and error streams; they are all open in text\n mode and therefore follow the interface defined by the\n ``io.TextIOBase`` abstract class.\n\nInternal types\n A few types used internally by the interpreter are exposed to the\n user. Their definitions may change with future versions of the\n interpreter, but they are mentioned here for completeness.\n\n Code objects\n Code objects represent *byte-compiled* executable Python code,\n or *bytecode*. The difference between a code object and a\n function object is that the function object contains an explicit\n reference to the function\'s globals (the module in which it was\n defined), while a code object contains no context; also the\n default argument values are stored in the function object, not\n in the code object (because they represent values calculated at\n run-time). Unlike function objects, code objects are immutable\n and contain no references (directly or indirectly) to mutable\n objects.\n\n Special read-only attributes: ``co_name`` gives the function\n name; ``co_argcount`` is the number of positional arguments\n (including arguments with default values); ``co_nlocals`` is the\n number of local variables used by the function (including\n arguments); ``co_varnames`` is a tuple containing the names of\n the local variables (starting with the argument names);\n ``co_cellvars`` is a tuple containing the names of local\n variables that are referenced by nested functions;\n ``co_freevars`` is a tuple containing the names of free\n variables; ``co_code`` is a string representing the sequence of\n bytecode instructions; ``co_consts`` is a tuple containing the\n literals used by the bytecode; ``co_names`` is a tuple\n containing the names used by the bytecode; ``co_filename`` is\n the filename from which the code was compiled;\n ``co_firstlineno`` is the first line number of the function;\n ``co_lnotab`` is a string encoding the mapping from bytecode\n offsets to line numbers (for details see the source code of the\n interpreter); ``co_stacksize`` is the required stack size\n (including local variables); ``co_flags`` is an integer encoding\n a number of flags for the interpreter.\n\n The following flag bits are defined for ``co_flags``: bit\n ``0x04`` is set if the function uses the ``*arguments`` syntax\n to accept an arbitrary number of positional arguments; bit\n ``0x08`` is set if the function uses the ``**keywords`` syntax\n to accept arbitrary keyword arguments; bit ``0x20`` is set if\n the function is a generator.\n\n Future feature declarations (``from __future__ import\n division``) also use bits in ``co_flags`` to indicate whether a\n code object was compiled with a particular feature enabled: bit\n ``0x2000`` is set if the function was compiled with future\n division enabled; bits ``0x10`` and ``0x1000`` were used in\n earlier versions of Python.\n\n Other bits in ``co_flags`` are reserved for internal use.\n\n If a code object represents a function, the first item in\n ``co_consts`` is the documentation string of the function, or\n ``None`` if undefined.\n\n Frame objects\n Frame objects represent execution frames. They may occur in\n traceback objects (see below).\n\n Special read-only attributes: ``f_back`` is to the previous\n stack frame (towards the caller), or ``None`` if this is the\n bottom stack frame; ``f_code`` is the code object being executed\n in this frame; ``f_locals`` is the dictionary used to look up\n local variables; ``f_globals`` is used for global variables;\n ``f_builtins`` is used for built-in (intrinsic) names;\n ``f_lasti`` gives the precise instruction (this is an index into\n the bytecode string of the code object).\n\n Special writable attributes: ``f_trace``, if not ``None``, is a\n function called at the start of each source code line (this is\n used by the debugger); ``f_lineno`` is the current line number\n of the frame --- writing to this from within a trace function\n jumps to the given line (only for the bottom-most frame). A\n debugger can implement a Jump command (aka Set Next Statement)\n by writing to f_lineno.\n\n Traceback objects\n Traceback objects represent a stack trace of an exception. A\n traceback object is created when an exception occurs. When the\n search for an exception handler unwinds the execution stack, at\n each unwound level a traceback object is inserted in front of\n the current traceback. When an exception handler is entered,\n the stack trace is made available to the program. (See section\n *The try statement*.) It is accessible as the third item of the\n tuple returned by ``sys.exc_info()``. When the program contains\n no suitable handler, the stack trace is written (nicely\n formatted) to the standard error stream; if the interpreter is\n interactive, it is also made available to the user as\n ``sys.last_traceback``.\n\n Special read-only attributes: ``tb_next`` is the next level in\n the stack trace (towards the frame where the exception\n occurred), or ``None`` if there is no next level; ``tb_frame``\n points to the execution frame of the current level;\n ``tb_lineno`` gives the line number where the exception\n occurred; ``tb_lasti`` indicates the precise instruction. The\n line number and last instruction in the traceback may differ\n from the line number of its frame object if the exception\n occurred in a ``try`` statement with no matching except clause\n or with a finally clause.\n\n Slice objects\n Slice objects are used to represent slices for ``__getitem__()``\n methods. They are also created by the built-in ``slice()``\n function.\n\n Special read-only attributes: ``start`` is the lower bound;\n ``stop`` is the upper bound; ``step`` is the step value; each is\n ``None`` if omitted. These attributes can have any type.\n\n Slice objects support one method:\n\n slice.indices(self, length)\n\n This method takes a single integer argument *length* and\n computes information about the slice that the slice object\n would describe if applied to a sequence of *length* items.\n It returns a tuple of three integers; respectively these are\n the *start* and *stop* indices and the *step* or stride\n length of the slice. Missing or out-of-bounds indices are\n handled in a manner consistent with regular slices.\n\n Static method objects\n Static method objects provide a way of defeating the\n transformation of function objects to method objects described\n above. A static method object is a wrapper around any other\n object, usually a user-defined method object. When a static\n method object is retrieved from a class or a class instance, the\n object actually returned is the wrapped object, which is not\n subject to any further transformation. Static method objects are\n not themselves callable, although the objects they wrap usually\n are. Static method objects are created by the built-in\n ``staticmethod()`` constructor.\n\n Class method objects\n A class method object, like a static method object, is a wrapper\n around another object that alters the way in which that object\n is retrieved from classes and class instances. The behaviour of\n class method objects upon such retrieval is described above,\n under "User-defined methods". Class method objects are created\n by the built-in ``classmethod()`` constructor.\n',
'typesfunctions': '\nFunctions\n*********\n\nFunction objects are created by function definitions. The only\noperation on a function object is to call it: ``func(argument-list)``.\n\nThere are really two flavors of function objects: built-in functions\nand user-defined functions. Both support the same operation (to call\nthe function), but the implementation is different, hence the\ndifferent object types.\n\nSee *Function definitions* for more information.\n',
- 'typesmapping': '\nMapping Types --- ``dict``\n**************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built\nin ``list``, ``set``, and ``tuple`` classes, and the ``collections``\nmodule.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as ``1`` and ``1.0``) then they can be used interchangeably to\nindex the same dictionary entry. (Note however, that since computers\nstore floating-point numbers as approximations it is usually unwise to\nuse them as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of\n``key: value`` pairs within braces, for example: ``{\'jack\': 4098,\n\'sjoerd\': 4127}`` or ``{4098: \'jack\', 4127: \'sjoerd\'}``, or by the\n``dict`` constructor.\n\nclass class dict([arg])\n\n Return a new dictionary initialized from an optional positional\n argument or from a set of keyword arguments. If no arguments are\n given, return a new empty dictionary. If the positional argument\n *arg* is a mapping object, return a dictionary mapping the same\n keys to the same values as does the mapping object. Otherwise the\n positional argument must be a sequence, a container that supports\n iteration, or an iterator object. The elements of the argument\n must each also be of one of those kinds, and each must in turn\n contain exactly two objects. The first is used as a key in the new\n dictionary, and the second as the key\'s value. If a given key is\n seen more than once, the last value associated with it is retained\n in the new dictionary.\n\n If keyword arguments are given, the keywords themselves with their\n associated values are added as items to the dictionary. If a key\n is specified both in the positional argument and as a keyword\n argument, the value associated with the keyword is retained in the\n dictionary. For example, these all return a dictionary equal to\n ``{"one": 2, "two": 3}``:\n\n * ``dict(one=2, two=3)``\n\n * ``dict({\'one\': 2, \'two\': 3})``\n\n * ``dict(zip((\'one\', \'two\'), (2, 3)))``\n\n * ``dict([[\'two\', 3], [\'one\', 2]])``\n\n The first example only works for keys that are valid Python\n identifiers; the others work with any valid keys.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a ``KeyError`` if\n *key* is not in the map.\n\n If a subclass of dict defines a method ``__missing__()``, if the\n key *key* is not present, the ``d[key]`` operation calls that\n method with the key *key* as argument. The ``d[key]`` operation\n then returns or raises whatever is returned or raised by the\n ``__missing__(key)`` call if the key is not present. No other\n operations or methods invoke ``__missing__()``. If\n ``__missing__()`` is not defined, ``KeyError`` is raised.\n ``__missing__()`` must be a method; it cannot be an instance\n variable. For an example, see ``collections.defaultdict``.\n\n d[key] = value\n\n Set ``d[key]`` to *value*.\n\n del d[key]\n\n Remove ``d[key]`` from *d*. Raises a ``KeyError`` if *key* is\n not in the map.\n\n key in d\n\n Return ``True`` if *d* has a key *key*, else ``False``.\n\n key not in d\n\n Equivalent to ``not key in d``.\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for ``iterkeys()``.\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n classmethod fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n ``fromkeys()`` is a class method that returns a new dictionary.\n *value* defaults to ``None``.\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to ``None``,\n so that this method never raises a ``KeyError``.\n\n items()\n\n Return a new view of the dictionary\'s items (``(key, value)``\n pairs). See below for documentation of view objects.\n\n keys()\n\n Return a new view of the dictionary\'s keys. See below for\n documentation of view objects.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a ``KeyError`` is raised.\n\n popitem()\n\n Remove and return an arbitrary ``(key, value)`` pair from the\n dictionary.\n\n ``popitem()`` is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling ``popitem()`` raises a ``KeyError``.\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to ``None``.\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return ``None``.\n\n ``update()`` accepts either another dictionary object or an\n iterable of key/value pairs (as a tuple or other iterable of\n length two). If keyword arguments are specified, the\n dictionary is then is updated with those key/value pairs:\n ``d.update(red=1, blue=2)``.\n\n values()\n\n Return a new view of the dictionary\'s values. See below for\n documentation of view objects.\n\n\nDictionary view objects\n=======================\n\nThe objects returned by ``dict.keys()``, ``dict.values()`` and\n``dict.items()`` are *view objects*. They provide a dynamic view on\nthe dictionary\'s entries, which means that when the dictionary\nchanges, the view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of ``(key, value)``) in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of ``(value, key)`` pairs\n using ``zip()``: ``pairs = zip(d.values(), d.keys())``. Another\n way to create the same list is ``pairs = [(v, k) for (k, v) in\n d.items()]``.\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a ``RuntimeError`` or fail to iterate over all entries.\n\nx in dictview\n\n Return ``True`` if *x* is in the underlying dictionary\'s keys,\n values or items (in the latter case, *x* should be a ``(key,\n value)`` tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that (key, value) pairs are unique and\nhashable, then the items view is also set-like. (Values views are not\ntreated as set-like since the entries are generally not unique.) Then\nthese set operations are available ("other" refers either to another\nview or a set):\n\ndictview & other\n\n Return the intersection of the dictview and the other object as a\n new set.\n\ndictview | other\n\n Return the union of the dictview and the other object as a new set.\n\ndictview - other\n\n Return the difference between the dictview and the other object\n (all elements in *dictview* that aren\'t in *other*) as a new set.\n\ndictview ^ other\n\n Return the symmetric difference (all elements either in *dictview*\n or *other*, but not in both) of the dictview and the other object\n as a new set.\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.keys()\n >>> values = dishes.values()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n',
+ 'typesmapping': '\nMapping Types --- ``dict``\n**************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built\nin ``list``, ``set``, and ``tuple`` classes, and the ``collections``\nmodule.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as ``1`` and ``1.0``) then they can be used interchangeably to\nindex the same dictionary entry. (Note however, that since computers\nstore floating-point numbers as approximations it is usually unwise to\nuse them as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of\n``key: value`` pairs within braces, for example: ``{\'jack\': 4098,\n\'sjoerd\': 4127}`` or ``{4098: \'jack\', 4127: \'sjoerd\'}``, or by the\n``dict`` constructor.\n\nclass class dict([arg])\n\n Return a new dictionary initialized from an optional positional\n argument or from a set of keyword arguments. If no arguments are\n given, return a new empty dictionary. If the positional argument\n *arg* is a mapping object, return a dictionary mapping the same\n keys to the same values as does the mapping object. Otherwise the\n positional argument must be a sequence, a container that supports\n iteration, or an iterator object. The elements of the argument\n must each also be of one of those kinds, and each must in turn\n contain exactly two objects. The first is used as a key in the new\n dictionary, and the second as the key\'s value. If a given key is\n seen more than once, the last value associated with it is retained\n in the new dictionary.\n\n If keyword arguments are given, the keywords themselves with their\n associated values are added as items to the dictionary. If a key\n is specified both in the positional argument and as a keyword\n argument, the value associated with the keyword is retained in the\n dictionary. For example, these all return a dictionary equal to\n ``{"one": 1, "two": 2}``:\n\n * ``dict(one=1, two=2)``\n\n * ``dict({\'one\': 1, \'two\': 2})``\n\n * ``dict(zip((\'one\', \'two\'), (1, 2)))``\n\n * ``dict([[\'two\', 2], [\'one\', 1]])``\n\n The first example only works for keys that are valid Python\n identifiers; the others work with any valid keys.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a ``KeyError`` if\n *key* is not in the map.\n\n If a subclass of dict defines a method ``__missing__()``, if the\n key *key* is not present, the ``d[key]`` operation calls that\n method with the key *key* as argument. The ``d[key]`` operation\n then returns or raises whatever is returned or raised by the\n ``__missing__(key)`` call if the key is not present. No other\n operations or methods invoke ``__missing__()``. If\n ``__missing__()`` is not defined, ``KeyError`` is raised.\n ``__missing__()`` must be a method; it cannot be an instance\n variable:\n\n >>> class Counter(dict):\n ... def __missing__(self, key):\n ... return 0\n >>> c = Counter()\n >>> c[\'red\']\n 0\n >>> c[\'red\'] += 1\n >>> c[\'red\']\n 1\n\n See ``collections.Counter`` for a complete implementation\n including other methods helpful for accumulating and managing\n tallies.\n\n d[key] = value\n\n Set ``d[key]`` to *value*.\n\n del d[key]\n\n Remove ``d[key]`` from *d*. Raises a ``KeyError`` if *key* is\n not in the map.\n\n key in d\n\n Return ``True`` if *d* has a key *key*, else ``False``.\n\n key not in d\n\n Equivalent to ``not key in d``.\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for ``iter(d.keys())``.\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n classmethod fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n ``fromkeys()`` is a class method that returns a new dictionary.\n *value* defaults to ``None``.\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to ``None``,\n so that this method never raises a ``KeyError``.\n\n items()\n\n Return a new view of the dictionary\'s items (``(key, value)``\n pairs). See below for documentation of view objects.\n\n keys()\n\n Return a new view of the dictionary\'s keys. See below for\n documentation of view objects.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a ``KeyError`` is raised.\n\n popitem()\n\n Remove and return an arbitrary ``(key, value)`` pair from the\n dictionary.\n\n ``popitem()`` is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling ``popitem()`` raises a ``KeyError``.\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to ``None``.\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return ``None``.\n\n ``update()`` accepts either another dictionary object or an\n iterable of key/value pairs (as tuples or other iterables of\n length two). If keyword arguments are specified, the dictionary\n is then updated with those key/value pairs: ``d.update(red=1,\n blue=2)``.\n\n values()\n\n Return a new view of the dictionary\'s values. See below for\n documentation of view objects.\n\n\nDictionary view objects\n=======================\n\nThe objects returned by ``dict.keys()``, ``dict.values()`` and\n``dict.items()`` are *view objects*. They provide a dynamic view on\nthe dictionary\'s entries, which means that when the dictionary\nchanges, the view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of ``(key, value)``) in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of ``(value, key)`` pairs\n using ``zip()``: ``pairs = zip(d.values(), d.keys())``. Another\n way to create the same list is ``pairs = [(v, k) for (k, v) in\n d.items()]``.\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a ``RuntimeError`` or fail to iterate over all entries.\n\nx in dictview\n\n Return ``True`` if *x* is in the underlying dictionary\'s keys,\n values or items (in the latter case, *x* should be a ``(key,\n value)`` tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that ``(key, value)`` pairs are unique\nand hashable, then the items view is also set-like. (Values views are\nnot treated as set-like since the entries are generally not unique.)\nFor set-like views, all of the operations defined for the abstract\nbase class ``collections.Set`` are available (for example, ``==``,\n``<``, or ``^``).\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.keys()\n >>> values = dishes.values()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n >>> keys ^ {\'sausage\', \'juice\'}\n {\'juice\', \'eggs\', \'bacon\', \'spam\'}\n',
'typesmethods': "\nMethods\n*******\n\nMethods are functions that are called using the attribute notation.\nThere are two flavors: built-in methods (such as ``append()`` on\nlists) and class instance methods. Built-in methods are described\nwith the types that support them.\n\nIf you access a method (a function defined in a class namespace)\nthrough an instance, you get a special object: a *bound method* (also\ncalled *instance method*) object. When called, it will add the\n``self`` argument to the argument list. Bound methods have two\nspecial read-only attributes: ``m.__self__`` is the object on which\nthe method operates, and ``m.__func__`` is the function implementing\nthe method. Calling ``m(arg-1, arg-2, ..., arg-n)`` is completely\nequivalent to calling ``m.__func__(m.__self__, arg-1, arg-2, ...,\narg-n)``.\n\nLike function objects, bound method objects support getting arbitrary\nattributes. However, since method attributes are actually stored on\nthe underlying function object (``meth.__func__``), setting method\nattributes on bound methods is disallowed. Attempting to set a method\nattribute results in a ``TypeError`` being raised. In order to set a\nmethod attribute, you need to explicitly set it on the underlying\nfunction object:\n\n class C:\n def method(self):\n pass\n\n c = C()\n c.method.__func__.whoami = 'my name is c'\n\nSee *The standard type hierarchy* for more information.\n",
'typesmodules': "\nModules\n*******\n\nThe only special operation on a module is attribute access:\n``m.name``, where *m* is a module and *name* accesses a name defined\nin *m*'s symbol table. Module attributes can be assigned to. (Note\nthat the ``import`` statement is not, strictly speaking, an operation\non a module object; ``import foo`` does not require a module object\nnamed *foo* to exist, rather it requires an (external) *definition*\nfor a module named *foo* somewhere.)\n\nA special member of every module is ``__dict__``. This is the\ndictionary containing the module's symbol table. Modifying this\ndictionary will actually change the module's symbol table, but direct\nassignment to the ``__dict__`` attribute is not possible (you can\nwrite ``m.__dict__['a'] = 1``, which defines ``m.a`` to be ``1``, but\nyou can't write ``m.__dict__ = {}``). Modifying ``__dict__`` directly\nis not recommended.\n\nModules built into the interpreter are written like this: ``<module\n'sys' (built-in)>``. If loaded from a file, they are written as\n``<module 'os' from '/usr/local/lib/pythonX.Y/os.pyc'>``.\n",
- 'typesseq': '\nSequence Types --- ``str``, ``bytes``, ``bytearray``, ``list``, ``tuple``, ``range``\n************************************************************************************\n\nThere are six sequence types: strings, byte sequences (``bytes``\nobjects), byte arrays (``bytearray`` objects), lists, tuples, and\nrange objects. For other containers see the built in ``dict`` and\n``set`` classes, and the ``collections`` module.\n\nStrings contain Unicode characters. Their literals are written in\nsingle or double quotes: ``\'xyzzy\'``, ``"frobozz"``. See *String and\nBytes literals* for more about string literals. In addition to the\nfunctionality described here, there are also string-specific methods\ndescribed in the *String Methods* section.\n\nBytes and bytearray objects contain single bytes -- the former is\nimmutable while the latter is a mutable sequence. Bytes objects can\nbe constructed the constructor, ``bytes()``, and from literals; use a\n``b`` prefix with normal string syntax: ``b\'xyzzy\'``. To construct\nbyte arrays, use the ``bytearray()`` function.\n\nWarning: While string objects are sequences of characters (represented by\n strings of length 1), bytes and bytearray objects are sequences of\n *integers* (between 0 and 255), representing the ASCII value of\n single bytes. That means that for a bytes or bytearray object *b*,\n ``b[0]`` will be an integer, while ``b[0:1]`` will be a bytes or\n bytearray object of length 1. The representation of bytes objects\n uses the literal format (``b\'...\'``) since it is generally more\n useful than e.g. ``bytes([50, 19, 100])``. You can always convert a\n bytes object into a list of integers using ``list(b)``.Also, while\n in previous Python versions, byte strings and Unicode strings could\n be exchanged for each other rather freely (barring encoding issues),\n strings and bytes are now completely separate concepts. There\'s no\n implicit en-/decoding if you pass and object of the wrong type. A\n string always compares unequal to a bytes or bytearray object.\n\nLists are constructed with square brackets, separating items with\ncommas: ``[a, b, c]``. Tuples are constructed by the comma operator\n(not within square brackets), with or without enclosing parentheses,\nbut an empty tuple must have the enclosing parentheses, such as ``a,\nb, c`` or ``()``. A single item tuple must have a trailing comma,\nsuch as ``(d,)``.\n\nObjects of type range are created using the ``range()`` function.\nThey don\'t support slicing, concatenation or repetition, and using\n``in``, ``not in``, ``min()`` or ``max()`` on them is inefficient.\n\nMost sequence types support the following operations. The ``in`` and\n``not in`` operations have the same priorities as the comparison\noperations. The ``+`` and ``*`` operations have the same priority as\nthe corresponding numeric operations. [3] Additional methods are\nprovided for *Mutable Sequence Types*.\n\nThis table lists the sequence operations sorted in ascending priority\n(operations in the same box have the same priority). In the table,\n*s* and *t* are sequences of the same type; *n*, *i* and *j* are\nintegers:\n\n+--------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+====================+==================================+============+\n| ``x in s`` | ``True`` if an item of *s* is | (1) |\n| | equal to *x*, else ``False`` | |\n+--------------------+----------------------------------+------------+\n| ``x not in s`` | ``False`` if an item of *s* is | (1) |\n| | equal to *x*, else ``True`` | |\n+--------------------+----------------------------------+------------+\n| ``s + t`` | the concatenation of *s* and *t* | (6) |\n+--------------------+----------------------------------+------------+\n| ``s * n, n * s`` | *n* shallow copies of *s* | (2) |\n| | concatenated | |\n+--------------------+----------------------------------+------------+\n| ``s[i]`` | *i*\'th item of *s*, origin 0 | (3) |\n+--------------------+----------------------------------+------------+\n| ``s[i:j]`` | slice of *s* from *i* to *j* | (3)(4) |\n+--------------------+----------------------------------+------------+\n| ``s[i:j:k]`` | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+--------------------+----------------------------------+------------+\n| ``len(s)`` | length of *s* | |\n+--------------------+----------------------------------+------------+\n| ``min(s)`` | smallest item of *s* | |\n+--------------------+----------------------------------+------------+\n| ``max(s)`` | largest item of *s* | |\n+--------------------+----------------------------------+------------+\n\nSequence types also support comparisons. In particular, tuples and\nlists are compared lexicographically by comparing corresponding\nelements. This means that to compare equal, every element must\ncompare equal and the two sequences must be of the same type and have\nthe same length. (For full details see *Comparisons* in the language\nreference.)\n\nNotes:\n\n1. When *s* is a string object, the ``in`` and ``not in`` operations\n act like a substring test.\n\n2. Values of *n* less than ``0`` are treated as ``0`` (which yields an\n empty sequence of the same type as *s*). Note also that the copies\n are shallow; nested structures are not copied. This often haunts\n new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that ``[[]]`` is a one-element list containing\n an empty list, so all three elements of ``[[]] * 3`` are (pointers\n to) this single empty list. Modifying any of the elements of\n ``lists`` modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n3. If *i* or *j* is negative, the index is relative to the end of the\n string: ``len(s) + i`` or ``len(s) + j`` is substituted. But note\n that ``-0`` is still ``0``.\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that ``i <= k < j``. If *i* or *j* is\n greater than ``len(s)``, use ``len(s)``. If *i* is omitted or\n ``None``, use ``0``. If *j* is omitted or ``None``, use\n ``len(s)``. If *i* is greater than or equal to *j*, the slice is\n empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index ``x = i + n*k`` such that ``0 <= n <\n (j-i)/k``. In other words, the indices are ``i``, ``i+k``,\n ``i+2*k``, ``i+3*k`` and so on, stopping when *j* is reached (but\n never including *j*). If *i* or *j* is greater than ``len(s)``,\n use ``len(s)``. If *i* or *j* are omitted or ``None``, they become\n "end" values (which end depends on the sign of *k*). Note, *k*\n cannot be zero. If *k* is ``None``, it is treated like ``1``.\n\n6. If *s* and *t* are both strings, some Python implementations such\n as CPython can usually perform an in-place optimization for\n assignments of the form ``s=s+t`` or ``s+=t``. When applicable,\n this optimization makes quadratic run-time much less likely. This\n optimization is both version and implementation dependent. For\n performance sensitive code, it is preferable to use the\n ``str.join()`` method which assures consistent linear concatenation\n performance across versions and implementations.\n\n\nString Methods\n==============\n\nString objects support the methods listed below. Note that none of\nthese methods take keyword arguments.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n Return a copy of the string with only its first character\n capitalized.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode([encoding[, errors]])\n\n Return an encoded version of the string as a bytes object. Default\n encoding is the current default string encoding. *errors* may be\n given to set a different error handling scheme. The default for\n *errors* is ``\'strict\'``, meaning that encoding errors raise a\n ``UnicodeError``. Other possible values are ``\'ignore\'``,\n ``\'replace\'``, ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and\n any other name registered via ``codecs.register_error()``, see\n section *Codec Base Classes*. For a list of possible encodings, see\n section *Standard Encodings*.\n\nstr.endswith(suffix[, start[, end]])\n\n Return ``True`` if the string ends with the specified *suffix*,\n otherwise return ``False``. *suffix* can also be a tuple of\n suffixes to look for. With optional *start*, test beginning at\n that position. With optional *end*, stop comparing at that\n position.\n\nstr.expandtabs([tabsize])\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. The column number is reset to zero after each\n newline occurring in the string. If *tabsize* is not given, a tab\n size of ``8`` characters is assumed. This doesn\'t understand other\n non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the range [*start*, *end*].\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` if *sub* is not found.\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The *format_string*\n argument can contain literal text or replacement fields delimited\n by braces ``{}``. Each replacement field contains either the\n numeric index of a positional argument, or the name of a keyword\n argument. Returns a copy of *format_string* where each replacement\n field is replaced with the string value of the corresponding\n argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.index(sub[, start[, end]])\n\n Like ``find()``, but raise ``ValueError`` when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise.\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters include digit characters, and all characters that that\n can be used to form decimal-radix numbers, e.g. U+0660, ARABIC-\n INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n Return true if all cased characters in the string are lowercase and\n there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when ``repr()`` is\n invoked on a string. It has no bearing on the handling of strings\n written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise.\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters in the string are uppercase and\n there is at least one cased character, false otherwise.\n\nstr.join(seq)\n\n Return a string which is the concatenation of the strings in the\n sequence *seq*. A ``TypeError`` will be raised if there are any\n non-string values in *seq*, including ``bytes`` objects. The\n separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than\n ``len(s)``.\n\nstr.lower()\n\n Return a copy of the string converted to lowercase.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n ``str.translate()``.\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within s[start,end]. Optional\n arguments *start* and *end* are interpreted as in slice notation.\n Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n is not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than\n ``len(s)``.\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n ``None``, any whitespace string is a separator. Except for\n splitting from the right, ``rsplit()`` behaves like ``split()``\n which is described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most ``maxsplit+1``\n elements). If *maxsplit* is not specified, then there is no limit\n on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``). The *sep*\n argument may consist of multiple characters (for example,\n ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n an empty string with a specified separator returns ``[\'\']``.\n\n If *sep* is not specified or is ``None``, a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a ``None`` separator returns\n ``[]``.\n\n For example, ``\' 1 2 3 \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n and ``\' 1 2 3 \'.split(None, 1)`` returns ``[\'1\', \'2 3 \']``.\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n Return ``True`` if string starts with the *prefix*, otherwise\n return ``False``. *prefix* can also be a tuple of prefixes to look\n for. With optional *start*, test string beginning at that\n position. With optional *end*, stop comparing string at that\n position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or ``None``, the\n *chars* argument defaults to removing whitespace. The *chars*\n argument is not a prefix or suffix; rather, all combinations of its\n values are stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa.\n\nstr.title()\n\n Return a titlecased version of the string: words start with\n uppercase characters, all remaining cased characters are lowercase.\n\nstr.translate(map)\n\n Return a copy of the *s* where all characters have been mapped\n through the *map* which must be a dictionary of Unicode ordinals\n (integers) to Unicode ordinals, strings or ``None``. Unmapped\n characters are left untouched. Characters mapped to ``None`` are\n deleted.\n\n You can use ``str.maketrans()`` to create a translation map from\n character-to-character mappings in different formats.\n\n Note: An even more flexible approach is to create a custom character\n mapping codec using the ``codecs`` module (see\n ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n Return a copy of the string converted to uppercase.\n\nstr.zfill(width)\n\n Return the numeric string left filled with zeros in a string of\n length *width*. A sign prefix is handled correctly. The original\n string is returned if *width* is less than ``len(s)``.\n\n\nOld String Formatting Operations\n================================\n\nNote: The formatting operations described here are obsolete and may go\n away in future versions of Python. Use the new *String Formatting*\n in new code.\n\nString objects have one unique built-in operation: the ``%`` operator\n(modulo). This is also known as the string *formatting* or\n*interpolation* operator. Given ``format % values`` (where *format* is\na string), ``%`` conversion specifications in *format* are replaced\nwith zero or more elements of *values*. The effect is similar to the\nusing ``sprintf()`` in the C language.\n\nIf *format* requires a single argument, *values* may be a single non-\ntuple object. [4] Otherwise, *values* must be a tuple with exactly\nthe number of items specified by the format string, or a single\nmapping object (for example, a dictionary).\n\nA conversion specifier contains two or more characters and has the\nfollowing components, which must occur in this order:\n\n1. The ``\'%\'`` character, which marks the start of the specifier.\n\n2. Mapping key (optional), consisting of a parenthesised sequence of\n characters (for example, ``(somename)``).\n\n3. Conversion flags (optional), which affect the result of some\n conversion types.\n\n4. Minimum field width (optional). If specified as an ``\'*\'``\n (asterisk), the actual width is read from the next element of the\n tuple in *values*, and the object to convert comes after the\n minimum field width and optional precision.\n\n5. Precision (optional), given as a ``\'.\'`` (dot) followed by the\n precision. If specified as ``\'*\'`` (an asterisk), the actual width\n is read from the next element of the tuple in *values*, and the\n value to convert comes after the precision.\n\n6. Length modifier (optional).\n\n7. Conversion type.\n\nWhen the right argument is a dictionary (or other mapping type), then\nthe formats in the string *must* include a parenthesised mapping key\ninto that dictionary inserted immediately after the ``\'%\'`` character.\nThe mapping key selects the value to be formatted from the mapping.\nFor example:\n\n>>> print(\'%(language)s has %(#)03d quote types.\' % \\\n... {\'language\': "Python", "#": 2})\nPython has 002 quote types.\n\nIn this case no ``*`` specifiers may occur in a format (since they\nrequire a sequential parameter list).\n\nThe conversion flag characters are:\n\n+-----------+-----------------------------------------------------------------------+\n| Flag | Meaning |\n+===========+=======================================================================+\n| ``\'#\'`` | The value conversion will use the "alternate form" (where defined |\n| | below). |\n+-----------+-----------------------------------------------------------------------+\n| ``\'0\'`` | The conversion will be zero padded for numeric values. |\n+-----------+-----------------------------------------------------------------------+\n| ``\'-\'`` | The converted value is left adjusted (overrides the ``\'0\'`` |\n| | conversion if both are given). |\n+-----------+-----------------------------------------------------------------------+\n| ``\' \'`` | (a space) A blank should be left before a positive number (or empty |\n| | string) produced by a signed conversion. |\n+-----------+-----------------------------------------------------------------------+\n| ``\'+\'`` | A sign character (``\'+\'`` or ``\'-\'``) will precede the conversion |\n| | (overrides a "space" flag). |\n+-----------+-----------------------------------------------------------------------+\n\nA length modifier (``h``, ``l``, or ``L``) may be present, but is\nignored as it is not necessary for Python -- so e.g. ``%ld`` is\nidentical to ``%d``.\n\nThe conversion types are:\n\n+--------------+-------------------------------------------------------+---------+\n| Conversion | Meaning | Notes |\n+==============+=======================================================+=========+\n| ``\'d\'`` | Signed integer decimal. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'i\'`` | Signed integer decimal. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'o\'`` | Signed octal value. | (1) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'u\'`` | Obsolete type -- it is identical to ``\'d\'``. | (7) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'x\'`` | Signed hexadecimal (lowercase). | (2) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'X\'`` | Signed hexadecimal (uppercase). | (2) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'e\'`` | Floating point exponential format (lowercase). | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'E\'`` | Floating point exponential format (uppercase). | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'f\'`` | Floating point decimal format. | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'F\'`` | Floating point decimal format. | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'g\'`` | Floating point format. Uses lowercase exponential | (4) |\n| | format if exponent is less than -4 or not less than | |\n| | precision, decimal format otherwise. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'G\'`` | Floating point format. Uses uppercase exponential | (4) |\n| | format if exponent is less than -4 or not less than | |\n| | precision, decimal format otherwise. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'c\'`` | Single character (accepts integer or single character | |\n| | string). | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'r\'`` | String (converts any python object using ``repr()``). | (5) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'s\'`` | String (converts any python object using ``str()``). | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'%\'`` | No argument is converted, results in a ``\'%\'`` | |\n| | character in the result. | |\n+--------------+-------------------------------------------------------+---------+\n\nNotes:\n\n1. The alternate form causes a leading zero (``\'0\'``) to be inserted\n between left-hand padding and the formatting of the number if the\n leading character of the result is not already a zero.\n\n2. The alternate form causes a leading ``\'0x\'`` or ``\'0X\'`` (depending\n on whether the ``\'x\'`` or ``\'X\'`` format was used) to be inserted\n between left-hand padding and the formatting of the number if the\n leading character of the result is not already a zero.\n\n3. The alternate form causes the result to always contain a decimal\n point, even if no digits follow it.\n\n The precision determines the number of digits after the decimal\n point and defaults to 6.\n\n4. The alternate form causes the result to always contain a decimal\n point, and trailing zeroes are not removed as they would otherwise\n be.\n\n The precision determines the number of significant digits before\n and after the decimal point and defaults to 6.\n\n5. The precision determines the maximal number of characters used.\n\n1. See **PEP 237**.\n\nSince Python strings have an explicit length, ``%s`` conversions do\nnot assume that ``\'\\0\'`` is the end of the string.\n\nChanged in version 3.1: ``%f`` conversions for numbers whose absolute\nvalue is over 1e50 are no longer replaced by ``%g`` conversions.\n\nAdditional string operations are defined in standard modules\n``string`` and ``re``.\n\n\nRange Type\n==========\n\nThe ``range`` type is an immutable sequence which is commonly used for\nlooping. The advantage of the ``range`` type is that an ``range``\nobject will always take the same amount of memory, no matter the size\nof the range it represents. There are no consistent performance\nadvantages.\n\nRange objects have very little behavior: they only support indexing,\niteration, and the ``len()`` function.\n\n\nMutable Sequence Types\n======================\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object. Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| ``s[i] = x`` | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]`` | same as ``s[i:j] = []`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]`` | removes the elements of | |\n| | ``s[i:j:k]`` from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)`` | same as ``s[len(s):len(s)] = | |\n| | [x]`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (2) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)`` | return number of *i*\'s for which | |\n| | ``s[i] == x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (3) |\n| | ``s[k] == x`` and ``i <= k < j`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (4) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (5) |\n| | return x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (3) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()`` | reverses the items of *s* in | (6) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7), (8) |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n index is passed as the second or third parameter to the ``index()``\n method, the sequence length is added, as for slice indices. If it\n is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n ``insert()`` method, the sequence length is added, as for slice\n indices. If it is still negative, it is truncated to zero, as for\n slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n place for economy of space when sorting or reversing a large\n sequence. To remind you that they operate by side effect, they\n don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n comparisons. Each must be specified as a keyword argument.\n\n *key* specifies a function of one argument that is used to extract\n a comparison key from each list element: ``key=str.lower``. The\n default value is ``None``.\n\n *reverse* is a boolean value. If set to ``True``, then the list\n elements are sorted as if each comparison were reversed.\n\n The ``sort()`` method is guaranteed to be stable. A sort is stable\n if it guarantees not to change the relative order of elements that\n compare equal --- this is helpful for sorting in multiple passes\n (for example, sort by department, then by salary grade).\n\n While a list is being sorted, the effect of attempting to mutate,\n or even inspect, the list is undefined. The C implementation makes\n the list appear empty for the duration, and raises ``ValueError``\n if it can detect that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n\n\nBytes and Byte Array Methods\n============================\n\nBytes and bytearray objects, being "strings of bytes", have all\nmethods found on strings, with the exception of ``encode()``,\n``format()`` and ``isidentifier()``, which do not make sense with\nthese types. For converting the objects to strings, they have a\n``decode()`` method.\n\nWherever one of these methods needs to interpret the bytes as\ncharacters (e.g. the ``is...()`` methods), the ASCII character set is\nassumed.\n\nNote: The methods on bytes and bytearray objects don\'t accept strings as\n their arguments, just as the methods on strings don\'t accept bytes\n as their arguments. For example, you have to write\n\n a = "abc"\n b = a.replace("a", "f")\n\n and\n\n a = b"abc"\n b = a.replace(b"a", b"f")\n\nbytes.decode([encoding[, errors]])\nbytearray.decode([encoding[, errors]])\n\n Return a string decoded from the given bytes. Default encoding is\n the current default string encoding. *errors* may be given to set\n a different error handling scheme. The default for *errors* is\n ``\'strict\'``, meaning that encoding errors raise a\n ``UnicodeError``. Other possible values are ``\'ignore\'``,\n ``\'replace\'`` and any other name registered via\n ``codecs.register_error()``, see section *Codec Base Classes*. For\n a list of possible encodings, see section *Standard Encodings*.\n\nThe bytes and bytearray types have an additional class method:\n\nclassmethod bytes.fromhex(string)\nclassmethod bytearray.fromhex(string)\n\n This ``bytes`` class method returns a bytes or bytearray object,\n decoding the given string object. The string must contain two\n hexadecimal digits per byte, spaces are ignored.\n\n >>> bytes.fromhex(\'f0 f1f2 \')\n b\'\\xf0\\xf1\\xf2\'\n\nThe maketrans and translate methods differ in semantics from the\nversions available on strings:\n\nbytes.translate(table[, delete])\nbytearray.translate(table[, delete])\n\n Return a copy of the bytes or bytearray object where all bytes\n occurring in the optional argument *delete* are removed, and the\n remaining bytes have been mapped through the given translation\n table, which must be a bytes object of length 256.\n\n You can use the ``bytes.maketrans()`` method to create a\n translation table.\n\n Set the *table* argument to ``None`` for translations that only\n delete characters:\n\n >>> b\'read this short text\'.translate(None, b\'aeiou\')\n b\'rd ths shrt txt\'\n\nstatic bytes.maketrans(from, to)\nstatic bytearray.maketrans(from, to)\n\n This static method returns a translation table usable for\n ``bytes.translate()`` that will map each character in *from* into\n the character at the same position in *to*; *from* and *to* must be\n bytes objects and have the same length.\n\n New in version 3.1.\n',
- 'typesseq-mutable': '\nMutable Sequence Types\n**********************\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object. Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| ``s[i] = x`` | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]`` | same as ``s[i:j] = []`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]`` | removes the elements of | |\n| | ``s[i:j:k]`` from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)`` | same as ``s[len(s):len(s)] = | |\n| | [x]`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (2) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)`` | return number of *i*\'s for which | |\n| | ``s[i] == x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (3) |\n| | ``s[k] == x`` and ``i <= k < j`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (4) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (5) |\n| | return x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (3) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()`` | reverses the items of *s* in | (6) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7), (8) |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n index is passed as the second or third parameter to the ``index()``\n method, the sequence length is added, as for slice indices. If it\n is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n ``insert()`` method, the sequence length is added, as for slice\n indices. If it is still negative, it is truncated to zero, as for\n slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n place for economy of space when sorting or reversing a large\n sequence. To remind you that they operate by side effect, they\n don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n comparisons. Each must be specified as a keyword argument.\n\n *key* specifies a function of one argument that is used to extract\n a comparison key from each list element: ``key=str.lower``. The\n default value is ``None``.\n\n *reverse* is a boolean value. If set to ``True``, then the list\n elements are sorted as if each comparison were reversed.\n\n The ``sort()`` method is guaranteed to be stable. A sort is stable\n if it guarantees not to change the relative order of elements that\n compare equal --- this is helpful for sorting in multiple passes\n (for example, sort by department, then by salary grade).\n\n While a list is being sorted, the effect of attempting to mutate,\n or even inspect, the list is undefined. The C implementation makes\n the list appear empty for the duration, and raises ``ValueError``\n if it can detect that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n',
+ 'typesseq': '\nSequence Types --- ``str``, ``bytes``, ``bytearray``, ``list``, ``tuple``, ``range``\n************************************************************************************\n\nThere are six sequence types: strings, byte sequences (``bytes``\nobjects), byte arrays (``bytearray`` objects), lists, tuples, and\nrange objects. For other containers see the built in ``dict`` and\n``set`` classes, and the ``collections`` module.\n\nStrings contain Unicode characters. Their literals are written in\nsingle or double quotes: ``\'xyzzy\'``, ``"frobozz"``. See *String and\nBytes literals* for more about string literals. In addition to the\nfunctionality described here, there are also string-specific methods\ndescribed in the *String Methods* section.\n\nBytes and bytearray objects contain single bytes -- the former is\nimmutable while the latter is a mutable sequence. Bytes objects can\nbe constructed the constructor, ``bytes()``, and from literals; use a\n``b`` prefix with normal string syntax: ``b\'xyzzy\'``. To construct\nbyte arrays, use the ``bytearray()`` function.\n\nWhile string objects are sequences of characters (represented by\nstrings of length 1), bytes and bytearray objects are sequences of\n*integers* (between 0 and 255), representing the ASCII value of single\nbytes. That means that for a bytes or bytearray object *b*, ``b[0]``\nwill be an integer, while ``b[0:1]`` will be a bytes or bytearray\nobject of length 1. The representation of bytes objects uses the\nliteral format (``b\'...\'``) since it is generally more useful than\ne.g. ``bytes([50, 19, 100])``. You can always convert a bytes object\ninto a list of integers using ``list(b)``.\n\nAlso, while in previous Python versions, byte strings and Unicode\nstrings could be exchanged for each other rather freely (barring\nencoding issues), strings and bytes are now completely separate\nconcepts. There\'s no implicit en-/decoding if you pass an object of\nthe wrong type. A string always compares unequal to a bytes or\nbytearray object.\n\nLists are constructed with square brackets, separating items with\ncommas: ``[a, b, c]``. Tuples are constructed by the comma operator\n(not within square brackets), with or without enclosing parentheses,\nbut an empty tuple must have the enclosing parentheses, such as ``a,\nb, c`` or ``()``. A single item tuple must have a trailing comma,\nsuch as ``(d,)``.\n\nObjects of type range are created using the ``range()`` function.\nThey don\'t support concatenation or repetition, and using ``min()`` or\n``max()`` on them is inefficient.\n\nMost sequence types support the following operations. The ``in`` and\n``not in`` operations have the same priorities as the comparison\noperations. The ``+`` and ``*`` operations have the same priority as\nthe corresponding numeric operations. [3] Additional methods are\nprovided for *Mutable Sequence Types*.\n\nThis table lists the sequence operations sorted in ascending priority\n(operations in the same box have the same priority). In the table,\n*s* and *t* are sequences of the same type; *n*, *i*, *j* and *k* are\nintegers.\n\n+--------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+====================+==================================+============+\n| ``x in s`` | ``True`` if an item of *s* is | (1) |\n| | equal to *x*, else ``False`` | |\n+--------------------+----------------------------------+------------+\n| ``x not in s`` | ``False`` if an item of *s* is | (1) |\n| | equal to *x*, else ``True`` | |\n+--------------------+----------------------------------+------------+\n| ``s + t`` | the concatenation of *s* and *t* | (6) |\n+--------------------+----------------------------------+------------+\n| ``s * n, n * s`` | *n* shallow copies of *s* | (2) |\n| | concatenated | |\n+--------------------+----------------------------------+------------+\n| ``s[i]`` | *i*\'th item of *s*, origin 0 | (3) |\n+--------------------+----------------------------------+------------+\n| ``s[i:j]`` | slice of *s* from *i* to *j* | (3)(4) |\n+--------------------+----------------------------------+------------+\n| ``s[i:j:k]`` | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+--------------------+----------------------------------+------------+\n| ``len(s)`` | length of *s* | |\n+--------------------+----------------------------------+------------+\n| ``min(s)`` | smallest item of *s* | |\n+--------------------+----------------------------------+------------+\n| ``max(s)`` | largest item of *s* | |\n+--------------------+----------------------------------+------------+\n| ``s.index(i)`` | index of the first occurence of | |\n| | *i* in *s* | |\n+--------------------+----------------------------------+------------+\n| ``s.count(i)`` | total number of occurences of | |\n| | *i* in *s* | |\n+--------------------+----------------------------------+------------+\n\nSequence types also support comparisons. In particular, tuples and\nlists are compared lexicographically by comparing corresponding\nelements. This means that to compare equal, every element must\ncompare equal and the two sequences must be of the same type and have\nthe same length. (For full details see *Comparisons* in the language\nreference.)\n\nNotes:\n\n1. When *s* is a string object, the ``in`` and ``not in`` operations\n act like a substring test.\n\n2. Values of *n* less than ``0`` are treated as ``0`` (which yields an\n empty sequence of the same type as *s*). Note also that the copies\n are shallow; nested structures are not copied. This often haunts\n new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that ``[[]]`` is a one-element list containing\n an empty list, so all three elements of ``[[]] * 3`` are (pointers\n to) this single empty list. Modifying any of the elements of\n ``lists`` modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n3. If *i* or *j* is negative, the index is relative to the end of the\n string: ``len(s) + i`` or ``len(s) + j`` is substituted. But note\n that ``-0`` is still ``0``.\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that ``i <= k < j``. If *i* or *j* is\n greater than ``len(s)``, use ``len(s)``. If *i* is omitted or\n ``None``, use ``0``. If *j* is omitted or ``None``, use\n ``len(s)``. If *i* is greater than or equal to *j*, the slice is\n empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index ``x = i + n*k`` such that ``0 <= n <\n (j-i)/k``. In other words, the indices are ``i``, ``i+k``,\n ``i+2*k``, ``i+3*k`` and so on, stopping when *j* is reached (but\n never including *j*). If *i* or *j* is greater than ``len(s)``,\n use ``len(s)``. If *i* or *j* are omitted or ``None``, they become\n "end" values (which end depends on the sign of *k*). Note, *k*\n cannot be zero. If *k* is ``None``, it is treated like ``1``.\n\n6. **CPython implementation detail:** If *s* and *t* are both strings,\n some Python implementations such as CPython can usually perform an\n in-place optimization for assignments of the form ``s = s + t`` or\n ``s += t``. When applicable, this optimization makes quadratic\n run-time much less likely. This optimization is both version and\n implementation dependent. For performance sensitive code, it is\n preferable to use the ``str.join()`` method which assures\n consistent linear concatenation performance across versions and\n implementations.\n\n\nString Methods\n==============\n\nString objects support the methods listed below.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is ``\'utf-8\'``. *errors* may be given to set a different\n error handling scheme. The default for *errors* is ``\'strict\'``,\n meaning that encoding errors raise a ``UnicodeError``. Other\n possible values are ``\'ignore\'``, ``\'replace\'``,\n ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and any other name\n registered via ``codecs.register_error()``, see section *Codec Base\n Classes*. For a list of possible encodings, see section *Standard\n Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return ``True`` if the string ends with the specified *suffix*,\n otherwise return ``False``. *suffix* can also be a tuple of\n suffixes to look for. With optional *start*, test beginning at\n that position. With optional *end*, stop comparing at that\n position.\n\nstr.expandtabs([tabsize])\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. The column number is reset to zero after each\n newline occurring in the string. If *tabsize* is not given, a tab\n size of ``8`` characters is assumed. This doesn\'t understand other\n non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` if *sub* is not found.\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces ``{}``. Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to ``str.format(**mapping)``, except that ``mapping`` is\n used directly and not copied to a ``dict`` . This is useful if for\n example ``mapping`` is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like ``find()``, but raise ``ValueError`` when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character\n ``c`` is alphanumeric if one of the following returns ``True``:\n ``c.isalpha()``, ``c.isdecimal()``, ``c.isdigit()``, or\n ``c.isnumeric()``.\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that that can be used\n to form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT\n ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n Return true if all cased characters in the string are lowercase and\n there is at least one cased character, false otherwise. Cased\n characters are those with general category property being one of\n "Lu", "Ll", or "Lt" and lowercase characters are those with general\n category property "Ll".\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when ``repr()`` is\n invoked on a string. It has no bearing on the handling of strings\n written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters in the string are uppercase and\n there is at least one cased character, false otherwise. Cased\n characters are those with general category property being one of\n "Lu", "Ll", or "Lt" and uppercase characters are those with general\n category property "Lu".\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A ``TypeError`` will be raised if there are\n any non-string values in *seq*, including ``bytes`` objects. The\n separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than\n ``len(s)``.\n\nstr.lower()\n\n Return a copy of the string converted to lowercase.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n ``str.translate()``.\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n is not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than\n ``len(s)``.\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n ``None``, any whitespace string is a separator. Except for\n splitting from the right, ``rsplit()`` behaves like ``split()``\n which is described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most ``maxsplit+1``\n elements). If *maxsplit* is not specified, then there is no limit\n on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``). The *sep*\n argument may consist of multiple characters (for example,\n ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n an empty string with a specified separator returns ``[\'\']``.\n\n If *sep* is not specified or is ``None``, a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a ``None`` separator returns\n ``[]``.\n\n For example, ``\' 1 2 3 \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n and ``\' 1 2 3 \'.split(None, 1)`` returns ``[\'1\', \'2 3 \']``.\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n Return ``True`` if string starts with the *prefix*, otherwise\n return ``False``. *prefix* can also be a tuple of prefixes to look\n for. With optional *start*, test string beginning at that\n position. With optional *end*, stop comparing string at that\n position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or ``None``, the\n *chars* argument defaults to removing whitespace. The *chars*\n argument is not a prefix or suffix; rather, all combinations of its\n values are stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa.\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n lambda mo: mo.group(0)[0].upper() +\n mo.group(0)[1:].lower(),\n s)\n\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n Return a copy of the *s* where all characters have been mapped\n through the *map* which must be a dictionary of Unicode ordinals\n (integers) to Unicode ordinals, strings or ``None``. Unmapped\n characters are left untouched. Characters mapped to ``None`` are\n deleted.\n\n You can use ``str.maketrans()`` to create a translation map from\n character-to-character mappings in different formats.\n\n Note: An even more flexible approach is to create a custom character\n mapping codec using the ``codecs`` module (see\n ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n Return a copy of the string converted to uppercase.\n\nstr.zfill(width)\n\n Return the numeric string left filled with zeros in a string of\n length *width*. A sign prefix is handled correctly. The original\n string is returned if *width* is less than ``len(s)``.\n\n\nOld String Formatting Operations\n================================\n\nNote: The formatting operations described here are obsolete and may go\n away in future versions of Python. Use the new *String Formatting*\n in new code.\n\nString objects have one unique built-in operation: the ``%`` operator\n(modulo). This is also known as the string *formatting* or\n*interpolation* operator. Given ``format % values`` (where *format* is\na string), ``%`` conversion specifications in *format* are replaced\nwith zero or more elements of *values*. The effect is similar to the\nusing ``sprintf()`` in the C language.\n\nIf *format* requires a single argument, *values* may be a single non-\ntuple object. [4] Otherwise, *values* must be a tuple with exactly\nthe number of items specified by the format string, or a single\nmapping object (for example, a dictionary).\n\nA conversion specifier contains two or more characters and has the\nfollowing components, which must occur in this order:\n\n1. The ``\'%\'`` character, which marks the start of the specifier.\n\n2. Mapping key (optional), consisting of a parenthesised sequence of\n characters (for example, ``(somename)``).\n\n3. Conversion flags (optional), which affect the result of some\n conversion types.\n\n4. Minimum field width (optional). If specified as an ``\'*\'``\n (asterisk), the actual width is read from the next element of the\n tuple in *values*, and the object to convert comes after the\n minimum field width and optional precision.\n\n5. Precision (optional), given as a ``\'.\'`` (dot) followed by the\n precision. If specified as ``\'*\'`` (an asterisk), the actual width\n is read from the next element of the tuple in *values*, and the\n value to convert comes after the precision.\n\n6. Length modifier (optional).\n\n7. Conversion type.\n\nWhen the right argument is a dictionary (or other mapping type), then\nthe formats in the string *must* include a parenthesised mapping key\ninto that dictionary inserted immediately after the ``\'%\'`` character.\nThe mapping key selects the value to be formatted from the mapping.\nFor example:\n\n>>> print(\'%(language)s has %(number)03d quote types.\' %\n... {\'language\': "Python", "number": 2})\nPython has 002 quote types.\n\nIn this case no ``*`` specifiers may occur in a format (since they\nrequire a sequential parameter list).\n\nThe conversion flag characters are:\n\n+-----------+-----------------------------------------------------------------------+\n| Flag | Meaning |\n+===========+=======================================================================+\n| ``\'#\'`` | The value conversion will use the "alternate form" (where defined |\n| | below). |\n+-----------+-----------------------------------------------------------------------+\n| ``\'0\'`` | The conversion will be zero padded for numeric values. |\n+-----------+-----------------------------------------------------------------------+\n| ``\'-\'`` | The converted value is left adjusted (overrides the ``\'0\'`` |\n| | conversion if both are given). |\n+-----------+-----------------------------------------------------------------------+\n| ``\' \'`` | (a space) A blank should be left before a positive number (or empty |\n| | string) produced by a signed conversion. |\n+-----------+-----------------------------------------------------------------------+\n| ``\'+\'`` | A sign character (``\'+\'`` or ``\'-\'``) will precede the conversion |\n| | (overrides a "space" flag). |\n+-----------+-----------------------------------------------------------------------+\n\nA length modifier (``h``, ``l``, or ``L``) may be present, but is\nignored as it is not necessary for Python -- so e.g. ``%ld`` is\nidentical to ``%d``.\n\nThe conversion types are:\n\n+--------------+-------------------------------------------------------+---------+\n| Conversion | Meaning | Notes |\n+==============+=======================================================+=========+\n| ``\'d\'`` | Signed integer decimal. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'i\'`` | Signed integer decimal. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'o\'`` | Signed octal value. | (1) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'u\'`` | Obsolete type -- it is identical to ``\'d\'``. | (7) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'x\'`` | Signed hexadecimal (lowercase). | (2) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'X\'`` | Signed hexadecimal (uppercase). | (2) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'e\'`` | Floating point exponential format (lowercase). | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'E\'`` | Floating point exponential format (uppercase). | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'f\'`` | Floating point decimal format. | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'F\'`` | Floating point decimal format. | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'g\'`` | Floating point format. Uses lowercase exponential | (4) |\n| | format if exponent is less than -4 or not less than | |\n| | precision, decimal format otherwise. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'G\'`` | Floating point format. Uses uppercase exponential | (4) |\n| | format if exponent is less than -4 or not less than | |\n| | precision, decimal format otherwise. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'c\'`` | Single character (accepts integer or single character | |\n| | string). | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'r\'`` | String (converts any Python object using ``repr()``). | (5) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'s\'`` | String (converts any Python object using ``str()``). | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'%\'`` | No argument is converted, results in a ``\'%\'`` | |\n| | character in the result. | |\n+--------------+-------------------------------------------------------+---------+\n\nNotes:\n\n1. The alternate form causes a leading zero (``\'0\'``) to be inserted\n between left-hand padding and the formatting of the number if the\n leading character of the result is not already a zero.\n\n2. The alternate form causes a leading ``\'0x\'`` or ``\'0X\'`` (depending\n on whether the ``\'x\'`` or ``\'X\'`` format was used) to be inserted\n between left-hand padding and the formatting of the number if the\n leading character of the result is not already a zero.\n\n3. The alternate form causes the result to always contain a decimal\n point, even if no digits follow it.\n\n The precision determines the number of digits after the decimal\n point and defaults to 6.\n\n4. The alternate form causes the result to always contain a decimal\n point, and trailing zeroes are not removed as they would otherwise\n be.\n\n The precision determines the number of significant digits before\n and after the decimal point and defaults to 6.\n\n5. The precision determines the maximal number of characters used.\n\n1. See **PEP 237**.\n\nSince Python strings have an explicit length, ``%s`` conversions do\nnot assume that ``\'\\0\'`` is the end of the string.\n\nChanged in version 3.1: ``%f`` conversions for numbers whose absolute\nvalue is over 1e50 are no longer replaced by ``%g`` conversions.\n\nAdditional string operations are defined in standard modules\n``string`` and ``re``.\n\n\nRange Type\n==========\n\nThe ``range`` type is an immutable sequence which is commonly used for\nlooping. The advantage of the ``range`` type is that an ``range``\nobject will always take the same amount of memory, no matter the size\nof the range it represents.\n\nRange objects have relatively little behavior: they support indexing,\ncontains, iteration, the ``len()`` function, and the following\nmethods:\n\nrange.count(x)\n\n Return the number of *i*\'s for which ``s[i] == x``.\n\n New in version 3.2.\n\nrange.index(x)\n\n Return the smallest *i* such that ``s[i] == x``. Raises\n ``ValueError`` when *x* is not in the range.\n\n New in version 3.2.\n\n\nMutable Sequence Types\n======================\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object. Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| ``s[i] = x`` | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]`` | same as ``s[i:j] = []`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]`` | removes the elements of | |\n| | ``s[i:j:k]`` from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)`` | same as ``s[len(s):len(s)] = | |\n| | [x]`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (2) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)`` | return number of *i*\'s for which | |\n| | ``s[i] == x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (3) |\n| | ``s[k] == x`` and ``i <= k < j`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (4) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (5) |\n| | return x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (3) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()`` | reverses the items of *s* in | (6) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7), (8) |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n index is passed as the second or third parameter to the ``index()``\n method, the sequence length is added, as for slice indices. If it\n is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n ``insert()`` method, the sequence length is added, as for slice\n indices. If it is still negative, it is truncated to zero, as for\n slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n place for economy of space when sorting or reversing a large\n sequence. To remind you that they operate by side effect, they\n don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n comparisons. Each must be specified as a keyword argument.\n\n *key* specifies a function of one argument that is used to extract\n a comparison key from each list element: ``key=str.lower``. The\n default value is ``None``. Use ``functools.cmp_to_key()`` to\n convert an old-style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to ``True``, then the list\n elements are sorted as if each comparison were reversed.\n\n The ``sort()`` method is guaranteed to be stable. A sort is stable\n if it guarantees not to change the relative order of elements that\n compare equal --- this is helpful for sorting in multiple passes\n (for example, sort by department, then by salary grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises ``ValueError`` if it can detect\n that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n\n\nBytes and Byte Array Methods\n============================\n\nBytes and bytearray objects, being "strings of bytes", have all\nmethods found on strings, with the exception of ``encode()``,\n``format()`` and ``isidentifier()``, which do not make sense with\nthese types. For converting the objects to strings, they have a\n``decode()`` method.\n\nWherever one of these methods needs to interpret the bytes as\ncharacters (e.g. the ``is...()`` methods), the ASCII character set is\nassumed.\n\nNote: The methods on bytes and bytearray objects don\'t accept strings as\n their arguments, just as the methods on strings don\'t accept bytes\n as their arguments. For example, you have to write\n\n a = "abc"\n b = a.replace("a", "f")\n\n and\n\n a = b"abc"\n b = a.replace(b"a", b"f")\n\nbytes.decode(encoding="utf-8", errors="strict")\nbytearray.decode(encoding="utf-8", errors="strict")\n\n Return a string decoded from the given bytes. Default encoding is\n ``\'utf-8\'``. *errors* may be given to set a different error\n handling scheme. The default for *errors* is ``\'strict\'``, meaning\n that encoding errors raise a ``UnicodeError``. Other possible\n values are ``\'ignore\'``, ``\'replace\'`` and any other name\n registered via ``codecs.register_error()``, see section *Codec Base\n Classes*. For a list of possible encodings, see section *Standard\n Encodings*.\n\n Changed in version 3.1: Added support for keyword arguments.\n\nThe bytes and bytearray types have an additional class method:\n\nclassmethod bytes.fromhex(string)\nclassmethod bytearray.fromhex(string)\n\n This ``bytes`` class method returns a bytes or bytearray object,\n decoding the given string object. The string must contain two\n hexadecimal digits per byte, spaces are ignored.\n\n >>> bytes.fromhex(\'f0 f1f2 \')\n b\'\\xf0\\xf1\\xf2\'\n\nThe maketrans and translate methods differ in semantics from the\nversions available on strings:\n\nbytes.translate(table[, delete])\nbytearray.translate(table[, delete])\n\n Return a copy of the bytes or bytearray object where all bytes\n occurring in the optional argument *delete* are removed, and the\n remaining bytes have been mapped through the given translation\n table, which must be a bytes object of length 256.\n\n You can use the ``bytes.maketrans()`` method to create a\n translation table.\n\n Set the *table* argument to ``None`` for translations that only\n delete characters:\n\n >>> b\'read this short text\'.translate(None, b\'aeiou\')\n b\'rd ths shrt txt\'\n\nstatic bytes.maketrans(from, to)\nstatic bytearray.maketrans(from, to)\n\n This static method returns a translation table usable for\n ``bytes.translate()`` that will map each character in *from* into\n the character at the same position in *to*; *from* and *to* must be\n bytes objects and have the same length.\n\n New in version 3.1.\n',
+ 'typesseq-mutable': '\nMutable Sequence Types\n**********************\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object. Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| ``s[i] = x`` | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]`` | same as ``s[i:j] = []`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]`` | removes the elements of | |\n| | ``s[i:j:k]`` from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)`` | same as ``s[len(s):len(s)] = | |\n| | [x]`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (2) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)`` | return number of *i*\'s for which | |\n| | ``s[i] == x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (3) |\n| | ``s[k] == x`` and ``i <= k < j`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (4) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (5) |\n| | return x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (3) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()`` | reverses the items of *s* in | (6) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7), (8) |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n index is passed as the second or third parameter to the ``index()``\n method, the sequence length is added, as for slice indices. If it\n is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n ``insert()`` method, the sequence length is added, as for slice\n indices. If it is still negative, it is truncated to zero, as for\n slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n place for economy of space when sorting or reversing a large\n sequence. To remind you that they operate by side effect, they\n don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n comparisons. Each must be specified as a keyword argument.\n\n *key* specifies a function of one argument that is used to extract\n a comparison key from each list element: ``key=str.lower``. The\n default value is ``None``. Use ``functools.cmp_to_key()`` to\n convert an old-style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to ``True``, then the list\n elements are sorted as if each comparison were reversed.\n\n The ``sort()`` method is guaranteed to be stable. A sort is stable\n if it guarantees not to change the relative order of elements that\n compare equal --- this is helpful for sorting in multiple passes\n (for example, sort by department, then by salary grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises ``ValueError`` if it can detect\n that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n',
'unary': '\nUnary arithmetic and bitwise operations\n***************************************\n\nAll unary arithmetic and bitwise operations have the same priority:\n\n u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n\nThe unary ``-`` (minus) operator yields the negation of its numeric\nargument.\n\nThe unary ``+`` (plus) operator yields its numeric argument unchanged.\n\nThe unary ``~`` (invert) operator yields the bitwise inversion of its\ninteger argument. The bitwise inversion of ``x`` is defined as\n``-(x+1)``. It only applies to integral numbers.\n\nIn all three cases, if the argument does not have the proper type, a\n``TypeError`` exception is raised.\n',
'while': '\nThe ``while`` statement\n***********************\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n',
- 'with': '\nThe ``with`` statement\n**********************\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__enter__()`` method is invoked.\n\n3. If a target was included in the ``with`` statement, the return\n value from ``__enter__()`` is assigned to it.\n\n Note: The ``with`` statement guarantees that if the ``__enter__()``\n method returns without an error, then ``__exit__()`` will always\n be called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 5 below.\n\n4. The suite is executed.\n\n5. The context manager\'s ``__exit__()`` method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to ``__exit__()``. Otherwise,\n three ``None`` arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the ``__exit__()`` method was false, the exception is\n reraised. If the return value was true, the exception is\n suppressed, and execution continues with the statement following\n the ``with`` statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from ``__exit__()`` is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n',
- 'yield': '\nThe ``yield`` statement\n***********************\n\n yield_stmt ::= yield_expression\n\nThe ``yield`` statement is only used when defining a generator\nfunction, and is only used in the body of the generator function.\nUsing a ``yield`` statement in a function definition is sufficient to\ncause that definition to create a generator function instead of a\nnormal function. When a generator function is called, it returns an\niterator known as a generator iterator, or more commonly, a generator.\nThe body of the generator function is executed by calling the\n``next()`` function on the generator repeatedly until it raises an\nexception.\n\nWhen a ``yield`` statement is executed, the state of the generator is\nfrozen and the value of **expression_list** is returned to\n``next()``\'s caller. By "frozen" we mean that all local state is\nretained, including the current bindings of local variables, the\ninstruction pointer, and the internal evaluation stack: enough\ninformation is saved so that the next time ``next()`` is invoked, the\nfunction can proceed exactly as if the ``yield`` statement were just\nanother external call.\n\nThe ``yield`` statement is allowed in the ``try`` clause of a ``try``\n... ``finally`` construct. If the generator is not resumed before it\nis finalized (by reaching a zero reference count or by being garbage\ncollected), the generator-iterator\'s ``close()`` method will be\ncalled, allowing any pending ``finally`` clauses to execute.\n\nSee also:\n\n **PEP 0255** - Simple Generators\n The proposal for adding generators and the ``yield`` statement\n to Python.\n\n **PEP 0342** - Coroutines via Enhanced Generators\n The proposal that, among other generator enhancements, proposed\n allowing ``yield`` to appear inside a ``try`` ... ``finally``\n block.\n'}
+ 'with': '\nThe ``with`` statement\n**********************\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the ``with_item``)\n is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__exit__()`` is loaded for later use.\n\n3. The context manager\'s ``__enter__()`` method is invoked.\n\n4. If a target was included in the ``with`` statement, the return\n value from ``__enter__()`` is assigned to it.\n\n Note: The ``with`` statement guarantees that if the ``__enter__()``\n method returns without an error, then ``__exit__()`` will always\n be called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s ``__exit__()`` method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to ``__exit__()``. Otherwise,\n three ``None`` arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the ``__exit__()`` method was false, the exception is\n reraised. If the return value was true, the exception is\n suppressed, and execution continues with the statement following\n the ``with`` statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from ``__exit__()`` is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n',
+ 'yield': '\nThe ``yield`` statement\n***********************\n\n yield_stmt ::= yield_expression\n\nThe ``yield`` statement is only used when defining a generator\nfunction, and is only used in the body of the generator function.\nUsing a ``yield`` statement in a function definition is sufficient to\ncause that definition to create a generator function instead of a\nnormal function. When a generator function is called, it returns an\niterator known as a generator iterator, or more commonly, a generator.\nThe body of the generator function is executed by calling the\n``next()`` function on the generator repeatedly until it raises an\nexception.\n\nWhen a ``yield`` statement is executed, the state of the generator is\nfrozen and the value of ``expression_list`` is returned to\n``next()``\'s caller. By "frozen" we mean that all local state is\nretained, including the current bindings of local variables, the\ninstruction pointer, and the internal evaluation stack: enough\ninformation is saved so that the next time ``next()`` is invoked, the\nfunction can proceed exactly as if the ``yield`` statement were just\nanother external call.\n\nThe ``yield`` statement is allowed in the ``try`` clause of a ``try``\n... ``finally`` construct. If the generator is not resumed before it\nis finalized (by reaching a zero reference count or by being garbage\ncollected), the generator-iterator\'s ``close()`` method will be\ncalled, allowing any pending ``finally`` clauses to execute.\n\nSee also:\n\n **PEP 0255** - Simple Generators\n The proposal for adding generators and the ``yield`` statement\n to Python.\n\n **PEP 0342** - Coroutines via Enhanced Generators\n The proposal that, among other generator enhancements, proposed\n allowing ``yield`` to appear inside a ``try`` ... ``finally``\n block.\n'}
diff --git a/Lib/queue.py b/Lib/queue.py
index f051f1c89f..bee7ed4086 100644
--- a/Lib/queue.py
+++ b/Lib/queue.py
@@ -110,14 +110,14 @@ class Queue:
def full(self):
"""Return True if the queue is full, False otherwise (not reliable!).
- This method is likely to be removed at some point. Use qsize() == n
+ This method is likely to be removed at some point. Use qsize() >= n
as a direct substitute, but be aware that either approach risks a race
condition where a queue can shrink before the result of full() or
qsize() can be used.
"""
self.mutex.acquire()
- n = 0 < self.maxsize == self._qsize()
+ n = 0 < self.maxsize <= self._qsize()
self.mutex.release()
return n
@@ -136,16 +136,16 @@ class Queue:
try:
if self.maxsize > 0:
if not block:
- if self._qsize() == self.maxsize:
+ if self._qsize() >= self.maxsize:
raise Full
elif timeout is None:
- while self._qsize() == self.maxsize:
+ while self._qsize() >= self.maxsize:
self.not_full.wait()
elif timeout < 0:
raise ValueError("'timeout' must be a positive number")
else:
endtime = _time() + timeout
- while self._qsize() == self.maxsize:
+ while self._qsize() >= self.maxsize:
remaining = endtime - _time()
if remaining <= 0.0:
raise Full
diff --git a/Lib/quopri.py b/Lib/quopri.py
index 6b3d13eca4..3d0f0ac078 100755
--- a/Lib/quopri.py
+++ b/Lib/quopri.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Conversions to/from quoted-printable transport encoding as per RFC 1521."""
@@ -41,7 +41,7 @@ def quote(c):
-def encode(input, output, quotetabs, header = 0):
+def encode(input, output, quotetabs, header=False):
"""Read 'input', apply quoted-printable encoding, and write to 'output'.
'input' and 'output' are files with readline() and write() methods.
@@ -54,7 +54,7 @@ def encode(input, output, quotetabs, header = 0):
if b2a_qp is not None:
data = input.read()
- odata = b2a_qp(data, quotetabs = quotetabs, header = header)
+ odata = b2a_qp(data, quotetabs=quotetabs, header=header)
output.write(odata)
return
@@ -105,9 +105,9 @@ def encode(input, output, quotetabs, header = 0):
if prevline is not None:
write(prevline, lineEnd=stripped)
-def encodestring(s, quotetabs = 0, header = 0):
+def encodestring(s, quotetabs=False, header=False):
if b2a_qp is not None:
- return b2a_qp(s, quotetabs = quotetabs, header = header)
+ return b2a_qp(s, quotetabs=quotetabs, header=header)
from io import BytesIO
infp = BytesIO(s)
outfp = BytesIO()
@@ -116,14 +116,14 @@ def encodestring(s, quotetabs = 0, header = 0):
-def decode(input, output, header = 0):
+def decode(input, output, header=False):
"""Read 'input', apply quoted-printable decoding, and write to 'output'.
'input' and 'output' are files with readline() and write() methods.
If 'header' is true, decode underscore as space (per RFC 1522)."""
if a2b_qp is not None:
data = input.read()
- odata = a2b_qp(data, header = header)
+ odata = a2b_qp(data, header=header)
output.write(odata)
return
@@ -159,13 +159,13 @@ def decode(input, output, header = 0):
if new:
output.write(new)
-def decodestring(s, header = 0):
+def decodestring(s, header=False):
if a2b_qp is not None:
- return a2b_qp(s, header = header)
+ return a2b_qp(s, header=header)
from io import BytesIO
infp = BytesIO(s)
outfp = BytesIO()
- decode(infp, outfp, header = header)
+ decode(infp, outfp, header=header)
return outfp.getvalue()
diff --git a/Lib/random.py b/Lib/random.py
index 592e4b899a..7f63388f85 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -42,8 +42,8 @@ from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethod
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin
from os import urandom as _urandom
-from binascii import hexlify as _hexlify
import collections as _collections
+from hashlib import sha512 as _sha512
__all__ = ["Random","seed","random","uniform","randint","choice","sample",
"randrange","shuffle","normalvariate","lognormvariate",
@@ -91,22 +91,33 @@ class Random(_random.Random):
self.seed(x)
self.gauss_next = None
- def seed(self, a=None):
+ def seed(self, a=None, version=2):
"""Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
- If a is not None or an int, hash(a) is used instead.
+ For version 2 (the default), all of the bits are used if *a *is a str,
+ bytes, or bytearray. For version 1, the hash() of *a* is used instead.
+
+ If *a* is an int, all bits are used.
+
"""
if a is None:
try:
- a = int(_hexlify(_urandom(16)), 16)
+ a = int.from_bytes(_urandom(32), 'big')
except NotImplementedError:
import time
a = int(time.time() * 256) # use fractional seconds
+ if version == 2:
+ if isinstance(a, (str, bytes, bytearray)):
+ if isinstance(a, str):
+ a = a.encode("utf8")
+ a += _sha512(a).digest()
+ a = int.from_bytes(a, 'big')
+
super().seed(a)
self.gauss_next = None
@@ -127,10 +138,10 @@ class Random(_random.Random):
# really unsigned 32-bit ints, so we convert negative ints from
# version 2 to positive longs for version 3.
try:
- internalstate = tuple( x % (2**32) for x in internalstate )
+ internalstate = tuple(x % (2**32) for x in internalstate)
except ValueError as e:
raise TypeError from e
- super(Random, self).setstate(internalstate)
+ super().setstate(internalstate)
else:
raise ValueError("state with version %s passed to "
"Random.setstate() of version %s" %
@@ -152,13 +163,13 @@ class Random(_random.Random):
## -------------------- integer methods -------------------
- def randrange(self, start, stop=None, step=1, int=int, default=None,
- maxwidth=1<<BPF):
+ def randrange(self, start, stop=None, step=1, int=int):
"""Choose a random item from range(start, stop[, step]).
This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want.
- Do not supply the 'int', 'default', and 'maxwidth' arguments.
+
+ Do not supply the 'int' argument.
"""
# This code is a bit messy to make it fast for the
@@ -166,11 +177,9 @@ class Random(_random.Random):
istart = int(start)
if istart != start:
raise ValueError("non-integer arg 1 for randrange()")
- if stop is default:
+ if stop is None:
if istart > 0:
- if istart >= maxwidth:
- return self._randbelow(istart)
- return int(self.random() * istart)
+ return self._randbelow(istart)
raise ValueError("empty range for randrange()")
# stop argument supplied.
@@ -179,22 +188,7 @@ class Random(_random.Random):
raise ValueError("non-integer stop for randrange()")
width = istop - istart
if step == 1 and width > 0:
- # Note that
- # int(istart + self.random()*width)
- # instead would be incorrect. For example, consider istart
- # = -2 and istop = 0. Then the guts would be in
- # -2.0 to 0.0 exclusive on both ends (ignoring that random()
- # might return 0.0), and because int() truncates toward 0, the
- # final result would be -1 or 0 (instead of -2 or -1).
- # istart + int(self.random()*width)
- # would also be incorrect, for a subtler reason: the RHS
- # can return a long, and then randrange() would also return
- # a long, but we're supposed to return an int (for backward
- # compatibility).
-
- if width >= maxwidth:
- return int(istart + self._randbelow(width))
- return int(istart + int(self.random()*width))
+ return istart + self._randbelow(width)
if step == 1:
raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
@@ -212,9 +206,7 @@ class Random(_random.Random):
if n <= 0:
raise ValueError("empty range for randrange()")
- if n >= maxwidth:
- return istart + istep*self._randbelow(n)
- return istart + istep*int(self.random() * n)
+ return istart + istep*self._randbelow(n)
def randint(self, a, b):
"""Return random integer in range [a, b], including both end points.
@@ -222,38 +214,43 @@ class Random(_random.Random):
return self.randrange(a, b+1)
- def _randbelow(self, n, _log=_log, int=int, _maxwidth=1<<BPF,
- _Method=_MethodType, _BuiltinMethod=_BuiltinMethodType):
- """Return a random int in the range [0,n)
-
- Handles the case where n has more bits than returned
- by a single call to the underlying generator.
- """
-
- try:
- getrandbits = self.getrandbits
- except AttributeError:
- pass
- else:
- # Only call self.getrandbits if the original random() builtin method
- # has not been overridden or if a new getrandbits() was supplied.
- # This assures that the two methods correspond.
- if type(self.random) is _BuiltinMethod or type(getrandbits) is _Method:
- k = int(1.00001 + _log(n-1, 2.0)) # 2**k > n-1 > 2**(k-2)
+ def _randbelow(self, n, int=int, maxsize=1<<BPF, type=type,
+ Method=_MethodType, BuiltinMethod=_BuiltinMethodType):
+ "Return a random int in the range [0,n). Raises ValueError if n==0."
+
+ getrandbits = self.getrandbits
+ # Only call self.getrandbits if the original random() builtin method
+ # has not been overridden or if a new getrandbits() was supplied.
+ if type(self.random) is BuiltinMethod or type(getrandbits) is Method:
+ k = n.bit_length() # don't use (n-1) here because n can be 1
+ r = getrandbits(k) # 0 <= r < 2**k
+ while r >= n:
r = getrandbits(k)
- while r >= n:
- r = getrandbits(k)
- return r
- if n >= _maxwidth:
+ return r
+ # There's an overriden random() method but no new getrandbits() method,
+ # so we can only use random() from here.
+ random = self.random
+ if n >= maxsize:
_warn("Underlying random() generator does not supply \n"
- "enough bits to choose from a population range this large")
- return int(self.random() * n)
+ "enough bits to choose from a population range this large.\n"
+ "To remove the range limitation, add a getrandbits() method.")
+ return int(random() * n)
+ rem = maxsize % n
+ limit = (maxsize - rem) / maxsize # int(limit * maxsize) % n == 0
+ r = random()
+ while r >= limit:
+ r = random()
+ return int(r*maxsize) % n
## -------------------- sequence methods -------------------
def choice(self, seq):
"""Choose a random element from a non-empty sequence."""
- return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
+ try:
+ i = self._randbelow(len(seq))
+ except ValueError:
+ raise IndexError('Cannot choose from an empty sequence')
+ return seq[i]
def shuffle(self, x, random=None, int=int):
"""x, random=random.random -> shuffle list x in place; return None.
@@ -262,11 +259,10 @@ class Random(_random.Random):
float in [0.0, 1.0); by default, the standard random.random.
"""
- if random is None:
- random = self.random
+ randbelow = self._randbelow
for i in reversed(range(1, len(x))):
# pick an element in x[:i+1] with which to exchange x[i]
- j = int(random() * (i+1))
+ j = randbelow(i+1) if random is None else int(random() * (i+1))
x[i], x[j] = x[j], x[i]
def sample(self, population, k):
@@ -301,11 +297,10 @@ class Random(_random.Random):
population = tuple(population)
if not isinstance(population, _collections.Sequence):
raise TypeError("Population must be a sequence or Set. For dicts, use list(d).")
- random = self.random
+ randbelow = self._randbelow
n = len(population)
if not 0 <= k <= n:
raise ValueError("Sample larger than population")
- _int = int
result = [None] * k
setsize = 21 # size of a small set minus size of an empty list
if k > 5:
@@ -314,16 +309,16 @@ class Random(_random.Random):
# An n-length list is smaller than a k-length set
pool = list(population)
for i in range(k): # invariant: non-selected at [0,n-i)
- j = _int(random() * (n-i))
+ j = randbelow(n-i)
result[i] = pool[j]
pool[j] = pool[n-i-1] # move non-selected item into vacancy
else:
selected = set()
selected_add = selected.add
for i in range(k):
- j = _int(random() * n)
+ j = randbelow(n)
while j in selected:
- j = _int(random() * n)
+ j = randbelow(n)
selected_add(j)
result[i] = population[j]
return result
@@ -607,7 +602,7 @@ class Random(_random.Random):
# Jain, pg. 495
u = 1.0 - self.random()
- return 1.0 / pow(u, 1.0/alpha)
+ return 1.0 / u ** (1.0/alpha)
## -------------------- Weibull --------------------
@@ -620,7 +615,7 @@ class Random(_random.Random):
# Jain, pg. 499; bug fix courtesy Bill Arms
u = 1.0 - self.random()
- return alpha * pow(-_log(u), 1.0/beta)
+ return alpha * (-_log(u)) ** (1.0/beta)
## --------------- Operating System Random Source ------------------
@@ -634,7 +629,7 @@ class SystemRandom(Random):
def random(self):
"""Get the next random number in the range [0.0, 1.0)."""
- return (int(_hexlify(_urandom(7)), 16) >> 3) * RECIP_BPF
+ return (int.from_bytes(_urandom(7), 'big') >> 3) * RECIP_BPF
def getrandbits(self, k):
"""getrandbits(k) -> x. Generates a long int with k random bits."""
@@ -642,9 +637,9 @@ class SystemRandom(Random):
raise ValueError('number of bits must be greater than zero')
if k != int(k):
raise TypeError('number of bits should be an integer')
- bytes = (k + 7) // 8 # bits / 8 and rounded up
- x = int(_hexlify(_urandom(bytes)), 16)
- return x >> (bytes * 8 - k) # trim excess bits
+ numbytes = (k + 7) // 8 # bits / 8 and rounded up
+ x = int.from_bytes(_urandom(numbytes), 'big')
+ return x >> (numbytes * 8 - k) # trim excess bits
def seed(self, *args, **kwds):
"Stub method. Not used for a system random number generator."
diff --git a/Lib/re.py b/Lib/re.py
index 9bd913a68d..92e4e4c14b 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -118,6 +118,7 @@ This module also defines an exception 'error'.
import sys
import sre_compile
import sre_parse
+import functools
# public symbols
__all__ = [ "match", "search", "sub", "subn", "split", "findall",
@@ -205,9 +206,9 @@ def compile(pattern, flags=0):
return _compile(pattern, flags)
def purge():
- "Clear the regular expression cache"
- _cache.clear()
- _cache_repl.clear()
+ "Clear the regular expression caches"
+ _compile_typed.cache_clear()
+ _compile_repl.cache_clear()
def template(pattern, flags=0):
"Compile a template pattern, returning a pattern object"
@@ -249,20 +250,14 @@ def escape(pattern):
# --------------------------------------------------------------------
# internals
-_cache = {}
-_cache_repl = {}
-
_pattern_type = type(sre_compile.compile("", 0))
-_MAXCACHE = 100
+def _compile(pattern, flags):
+ return _compile_typed(type(pattern), pattern, flags)
-def _compile(*key):
+@functools.lru_cache(maxsize=500)
+def _compile_typed(text_bytes_type, pattern, flags):
# internal: compile pattern
- cachekey = (type(key[0]),) + key
- p = _cache.get(cachekey)
- if p is not None:
- return p
- pattern, flags = key
if isinstance(pattern, _pattern_type):
if flags:
raise ValueError(
@@ -270,23 +265,12 @@ def _compile(*key):
return pattern
if not sre_compile.isstring(pattern):
raise TypeError("first argument must be string or compiled pattern")
- p = sre_compile.compile(pattern, flags)
- if len(_cache) >= _MAXCACHE:
- _cache.clear()
- _cache[cachekey] = p
- return p
+ return sre_compile.compile(pattern, flags)
-def _compile_repl(*key):
+@functools.lru_cache(maxsize=500)
+def _compile_repl(repl, pattern):
# internal: compile replacement pattern
- p = _cache_repl.get(key)
- if p is not None:
- return p
- repl, pattern = key
- p = sre_parse.parse_template(repl, pattern)
- if len(_cache_repl) >= _MAXCACHE:
- _cache_repl.clear()
- _cache_repl[key] = p
- return p
+ return sre_parse.parse_template(repl, pattern)
def _expand(pattern, match, template):
# internal: match.expand implementation hook
diff --git a/Lib/reprlib.py b/Lib/reprlib.py
index 9893c71cb8..f8033604da 100644
--- a/Lib/reprlib.py
+++ b/Lib/reprlib.py
@@ -1,9 +1,39 @@
"""Redo the builtin repr() (representation) but with limits on most sizes."""
-__all__ = ["Repr","repr"]
+__all__ = ["Repr", "repr", "recursive_repr"]
import builtins
from itertools import islice
+try:
+ from _thread import get_ident
+except ImportError:
+ from _dummy_thread import get_ident
+
+def recursive_repr(fillvalue='...'):
+ 'Decorator to make a repr function return fillvalue for a recursive call'
+
+ def decorating_function(user_function):
+ repr_running = set()
+
+ def wrapper(self):
+ key = id(self), get_ident()
+ if key in repr_running:
+ return fillvalue
+ repr_running.add(key)
+ try:
+ result = user_function(self)
+ finally:
+ repr_running.discard(key)
+ return result
+
+ # Can't use functools.wraps() here because of bootstrap issues
+ wrapper.__module__ = getattr(user_function, '__module__')
+ wrapper.__doc__ = getattr(user_function, '__doc__')
+ wrapper.__name__ = getattr(user_function, '__name__')
+ wrapper.__annotations__ = getattr(user_function, '__annotations__', {})
+ return wrapper
+
+ return decorating_function
class Repr:
diff --git a/Lib/runpy.py b/Lib/runpy.py
index e0aabeb1f2..4738df307a 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -11,24 +11,63 @@ importers when locating support scripts as well as when importing modules.
import sys
import imp
+from pkgutil import read_code
try:
from imp import get_loader
except ImportError:
from pkgutil import get_loader
__all__ = [
- "run_module",
+ "run_module", "run_path",
]
+class _TempModule(object):
+ """Temporarily replace a module in sys.modules with an empty namespace"""
+ def __init__(self, mod_name):
+ self.mod_name = mod_name
+ self.module = imp.new_module(mod_name)
+ self._saved_module = []
+
+ def __enter__(self):
+ mod_name = self.mod_name
+ try:
+ self._saved_module.append(sys.modules[mod_name])
+ except KeyError:
+ pass
+ sys.modules[mod_name] = self.module
+ return self
+
+ def __exit__(self, *args):
+ if self._saved_module:
+ sys.modules[self.mod_name] = self._saved_module[0]
+ else:
+ del sys.modules[self.mod_name]
+ self._saved_module = []
+
+class _ModifiedArgv0(object):
+ def __init__(self, value):
+ self.value = value
+ self._saved_value = self._sentinel = object()
+
+ def __enter__(self):
+ if self._saved_value is not self._sentinel:
+ raise RuntimeError("Already preserving saved value")
+ self._saved_value = sys.argv[0]
+ sys.argv[0] = self.value
+
+ def __exit__(self, *args):
+ self.value = self._sentinel
+ sys.argv[0] = self._saved_value
def _run_code(code, run_globals, init_globals=None,
mod_name=None, mod_fname=None,
mod_loader=None, pkg_name=None):
- """Helper for _run_module_code"""
+ """Helper to run code in nominated namespace"""
if init_globals is not None:
run_globals.update(init_globals)
run_globals.update(__name__ = mod_name,
__file__ = mod_fname,
+ __cached__ = None,
__loader__ = mod_loader,
__package__ = pkg_name)
exec(code, run_globals)
@@ -37,27 +76,11 @@ def _run_code(code, run_globals, init_globals=None,
def _run_module_code(code, init_globals=None,
mod_name=None, mod_fname=None,
mod_loader=None, pkg_name=None):
- """Helper for run_module"""
- # Set up the top level namespace dictionary
- temp_module = imp.new_module(mod_name)
- mod_globals = temp_module.__dict__
- # Modify sys.argv[0] and sys.module[mod_name]
- saved_argv0 = sys.argv[0]
- restore_module = mod_name in sys.modules
- if restore_module:
- saved_module = sys.modules[mod_name]
- sys.argv[0] = mod_fname
- sys.modules[mod_name] = temp_module
- try:
+ """Helper to run code in new namespace with sys modified"""
+ with _TempModule(mod_name) as temp_module, _ModifiedArgv0(mod_fname):
+ mod_globals = temp_module.module.__dict__
_run_code(code, mod_globals, init_globals,
- mod_name, mod_fname,
- mod_loader, pkg_name)
- finally:
- sys.argv[0] = saved_argv0
- if restore_module:
- sys.modules[mod_name] = saved_module
- else:
- del sys.modules[mod_name]
+ mod_name, mod_fname, mod_loader, pkg_name)
# Copy the globals of the temporary module, as they
# may be cleared when the temporary module goes away
return mod_globals.copy()
@@ -81,7 +104,7 @@ def _get_module_details(mod_name):
raise ImportError("No module named %s" % mod_name)
if loader.is_package(mod_name):
if mod_name == "__main__" or mod_name.endswith(".__main__"):
- raise ImportError(("Cannot use package as __main__ module"))
+ raise ImportError("Cannot use package as __main__ module")
try:
pkg_main_name = mod_name + ".__main__"
return _get_module_details(pkg_main_name)
@@ -94,35 +117,44 @@ def _get_module_details(mod_name):
filename = _get_filename(loader, mod_name)
return mod_name, loader, code, filename
-
# XXX ncoghlan: Should this be documented and made public?
# (Current thoughts: don't repeat the mistake that lead to its
# creation when run_module() no longer met the needs of
# mainmodule.c, but couldn't be changed because it was public)
-def _run_module_as_main(mod_name, set_argv0=True):
+def _run_module_as_main(mod_name, alter_argv=True):
"""Runs the designated module in the __main__ namespace
- These __*__ magic variables will be overwritten:
+ Note that the executed module will have full access to the
+ __main__ namespace. If this is not desirable, the run_module()
+ function should be used to run the module code in a fresh namespace.
+
+ At the very least, these variables in __main__ will be overwritten:
+ __name__
__file__
+ __cached__
__loader__
+ __package__
"""
try:
- mod_name, loader, code, fname = _get_module_details(mod_name)
+ if alter_argv or mod_name != "__main__": # i.e. -m switch
+ mod_name, loader, code, fname = _get_module_details(mod_name)
+ else: # i.e. directory or zipfile execution
+ mod_name, loader, code, fname = _get_main_module_details()
except ImportError as exc:
# Try to provide a good error message
# for directories, zip files and the -m switch
- if set_argv0:
+ if alter_argv:
# For -m switch, just display the exception
info = str(exc)
else:
# For directories/zipfiles, let the user
# know what the code was looking for
- info = "can't find '__main__.py' in %r" % sys.argv[0]
+ info = "can't find '__main__' module in %r" % sys.argv[0]
msg = "%s: %s" % (sys.executable, info)
sys.exit(msg)
pkg_name = mod_name.rpartition('.')[0]
main_globals = sys.modules["__main__"].__dict__
- if set_argv0:
+ if alter_argv:
sys.argv[0] = fname
return _run_code(code, main_globals, None,
"__main__", fname, loader, pkg_name)
@@ -145,6 +177,107 @@ def run_module(mod_name, init_globals=None,
return _run_code(code, {}, init_globals, run_name,
fname, loader, pkg_name)
+def _get_main_module_details():
+ # Helper that gives a nicer error message when attempting to
+ # execute a zipfile or directory by invoking __main__.py
+ main_name = "__main__"
+ try:
+ return _get_module_details(main_name)
+ except ImportError as exc:
+ if main_name in str(exc):
+ raise ImportError("can't find %r module in %r" %
+ (main_name, sys.path[0]))
+ raise
+
+
+# XXX (ncoghlan): Perhaps expose the C API function
+# as imp.get_importer instead of reimplementing it in Python?
+def _get_importer(path_name):
+ """Python version of PyImport_GetImporter C API function"""
+ cache = sys.path_importer_cache
+ try:
+ importer = cache[path_name]
+ except KeyError:
+ # Not yet cached. Flag as using the
+ # standard machinery until we finish
+ # checking the hooks
+ cache[path_name] = None
+ for hook in sys.path_hooks:
+ try:
+ importer = hook(path_name)
+ break
+ except ImportError:
+ pass
+ else:
+ # The following check looks a bit odd. The trick is that
+ # NullImporter throws ImportError if the supplied path is a
+ # *valid* directory entry (and hence able to be handled
+ # by the standard import machinery)
+ try:
+ importer = imp.NullImporter(path_name)
+ except ImportError:
+ return None
+ cache[path_name] = importer
+ return importer
+
+def _get_code_from_file(fname):
+ # Check for a compiled file first
+ with open(fname, "rb") as f:
+ code = read_code(f)
+ if code is None:
+ # That didn't work, so try it as normal source code
+ with open(fname, "rU") as f:
+ code = compile(f.read(), fname, 'exec')
+ return code
+
+def run_path(path_name, init_globals=None, run_name=None):
+ """Execute code located at the specified filesystem location
+
+ Returns the resulting top level namespace dictionary
+
+ The file path may refer directly to a Python script (i.e.
+ one that could be directly executed with execfile) or else
+ it may refer to a zipfile or directory containing a top
+ level __main__.py script.
+ """
+ if run_name is None:
+ run_name = "<run_path>"
+ importer = _get_importer(path_name)
+ if isinstance(importer, imp.NullImporter):
+ # Not a valid sys.path entry, so run the code directly
+ # execfile() doesn't help as we want to allow compiled files
+ code = _get_code_from_file(path_name)
+ return _run_module_code(code, init_globals, run_name, path_name)
+ else:
+ # Importer is defined for path, so add it to
+ # the start of sys.path
+ sys.path.insert(0, path_name)
+ try:
+ # Here's where things are a little different from the run_module
+ # case. There, we only had to replace the module in sys while the
+ # code was running and doing so was somewhat optional. Here, we
+ # have no choice and we have to remove it even while we read the
+ # code. If we don't do this, a __loader__ attribute in the
+ # existing __main__ module may prevent location of the new module.
+ main_name = "__main__"
+ saved_main = sys.modules[main_name]
+ del sys.modules[main_name]
+ try:
+ mod_name, loader, code, fname = _get_main_module_details()
+ finally:
+ sys.modules[main_name] = saved_main
+ pkg_name = ""
+ with _TempModule(run_name) as temp_module, \
+ _ModifiedArgv0(path_name):
+ mod_globals = temp_module.module.__dict__
+ return _run_code(code, mod_globals, init_globals,
+ run_name, fname, loader, pkg_name).copy()
+ finally:
+ try:
+ sys.path.remove(path_name)
+ except ValueError:
+ pass
+
if __name__ == "__main__":
# Run the module specified as the next command line argument
diff --git a/Lib/shelve.py b/Lib/shelve.py
index 52e471ac86..cc1815e3eb 100644
--- a/Lib/shelve.py
+++ b/Lib/shelve.py
@@ -73,6 +73,7 @@ class _ClosedDict(collections.MutableMapping):
def __repr__(self):
return '<Closed Dictionary>'
+
class Shelf(collections.MutableMapping):
"""Base class for shelf implementations.
@@ -88,7 +89,7 @@ class Shelf(collections.MutableMapping):
self._protocol = protocol
self.writeback = writeback
self.cache = {}
- self.keyencoding = "utf-8"
+ self.keyencoding = keyencoding
def __iter__(self):
for k in self.dict.keys():
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 4862ae6a13..aafe04e7b1 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -1,4 +1,4 @@
-"""Utility functions for copying files and directory trees.
+"""Utility functions for copying and archiving files and directory trees.
XXX The functions here don't copy the resource fork or other metadata on Mac.
@@ -9,10 +9,32 @@ import sys
import stat
from os.path import abspath
import fnmatch
+import collections
import errno
+import tarfile
-__all__ = ["copyfileobj","copyfile","copymode","copystat","copy","copy2",
- "copytree","move","rmtree","Error", "SpecialFileError"]
+try:
+ import bz2
+ _BZ2_SUPPORTED = True
+except ImportError:
+ _BZ2_SUPPORTED = False
+
+try:
+ from pwd import getpwnam
+except ImportError:
+ getpwnam = None
+
+try:
+ from grp import getgrnam
+except ImportError:
+ getgrnam = None
+
+__all__ = ["copyfileobj", "copyfile", "copymode", "copystat", "copy", "copy2",
+ "copytree", "move", "rmtree", "Error", "SpecialFileError",
+ "ExecError", "make_archive", "get_archive_formats",
+ "register_archive_format", "unregister_archive_format",
+ "get_unpack_formats", "register_unpack_format",
+ "unregister_unpack_format", "unpack_archive"]
class Error(EnvironmentError):
pass
@@ -21,6 +43,17 @@ class SpecialFileError(EnvironmentError):
"""Raised when trying to do a kind of operation (e.g. copying) which is
not supported on a special file (e.g. a named pipe)"""
+class ExecError(EnvironmentError):
+ """Raised when a command could not be executed"""
+
+class ReadError(EnvironmentError):
+ """Raised when an archive cannot be read"""
+
+class RegistryError(Exception):
+ """Raised when a registery operation with the archiving
+ and unpacking registeries fails"""
+
+
try:
WindowsError
except NameError:
@@ -36,7 +69,7 @@ def copyfileobj(fsrc, fdst, length=16*1024):
def _samefile(src, dst):
# Macintosh, Unix.
- if hasattr(os.path,'samefile'):
+ if hasattr(os.path, 'samefile'):
try:
return os.path.samefile(src, dst)
except OSError:
@@ -85,7 +118,8 @@ def copystat(src, dst):
try:
os.chflags(dst, st.st_flags)
except OSError as why:
- if not hasattr(errno, 'EOPNOTSUPP') or why.errno != errno.EOPNOTSUPP:
+ if (not hasattr(errno, 'EOPNOTSUPP') or
+ why.errno != errno.EOPNOTSUPP):
raise
def copy(src, dst):
@@ -122,8 +156,9 @@ def ignore_patterns(*patterns):
return set(ignored_names)
return _ignore_patterns
-def copytree(src, dst, symlinks=False, ignore=None):
- """Recursively copy a directory tree using copy2().
+def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
+ ignore_dangling_symlinks=False):
+ """Recursively copy a directory tree.
The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.
@@ -131,7 +166,13 @@ def copytree(src, dst, symlinks=False, ignore=None):
If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is false, the contents of the files pointed to by symbolic
- links are copied.
+ links are copied. If the file pointed by the symlink doesn't
+ exist, an exception will be added in the list of errors raised in
+ an Error exception at the end of the copy process.
+
+ You can set the optional ignore_dangling_symlinks flag to true if you
+ want to silence this exception. Notice that this has no effect on
+ platforms that don't support os.symlink.
The optional ignore argument is a callable. If given, it
is called with the `src` parameter, which is the directory
@@ -145,7 +186,10 @@ def copytree(src, dst, symlinks=False, ignore=None):
list of names relative to the `src` directory that should
not be copied.
- XXX Consider this example code rather than the ultimate tool.
+ The optional copy_function argument is a callable that will be used
+ to copy each file. It will be called with the source path and the
+ destination path as arguments. By default, copy2() is used, but any
+ function that supports the same signature (like copy()) can be used.
"""
names = os.listdir(src)
@@ -162,14 +206,21 @@ def copytree(src, dst, symlinks=False, ignore=None):
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
try:
- if symlinks and os.path.islink(srcname):
+ if os.path.islink(srcname):
linkto = os.readlink(srcname)
- os.symlink(linkto, dstname)
+ if symlinks:
+ os.symlink(linkto, dstname)
+ else:
+ # ignore dangling symlink if the flag is on
+ if not os.path.exists(linkto) and ignore_dangling_symlinks:
+ continue
+ # otherwise let the copy occurs. copy2 will raise an error
+ copy_function(srcname, dstname)
elif os.path.isdir(srcname):
- copytree(srcname, dstname, symlinks, ignore)
+ copytree(srcname, dstname, symlinks, ignore, copy_function)
else:
# Will raise a SpecialFileError for unsupported file types
- copy2(srcname, dstname)
+ copy_function(srcname, dstname)
# catch the Error from the recursive copytree so that we can
# continue with other files
except Error as err:
@@ -283,3 +334,417 @@ def _destinsrc(src, dst):
if not dst.endswith(os.path.sep):
dst += os.path.sep
return dst.startswith(src)
+
+def _get_gid(name):
+ """Returns a gid, given a group name."""
+ if getgrnam is None or name is None:
+ return None
+ try:
+ result = getgrnam(name)
+ except KeyError:
+ result = None
+ if result is not None:
+ return result[2]
+ return None
+
+def _get_uid(name):
+ """Returns an uid, given a user name."""
+ if getpwnam is None or name is None:
+ return None
+ try:
+ result = getpwnam(name)
+ except KeyError:
+ result = None
+ if result is not None:
+ return result[2]
+ return None
+
+def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
+ owner=None, group=None, logger=None):
+ """Create a (possibly compressed) tar file from all the files under
+ 'base_dir'.
+
+ 'compress' must be "gzip" (the default), "bzip2", or None.
+
+ 'owner' and 'group' can be used to define an owner and a group for the
+ archive that is being built. If not provided, the current owner and group
+ will be used.
+
+ The output tar file will be named 'base_name' + ".tar", possibly plus
+ the appropriate compression extension (".gz", or ".bz2").
+
+ Returns the output filename.
+ """
+ tar_compression = {'gzip': 'gz', None: ''}
+ compress_ext = {'gzip': '.gz'}
+
+ if _BZ2_SUPPORTED:
+ tar_compression['bzip2'] = 'bz2'
+ compress_ext['bzip2'] = '.bz2'
+
+ # flags for compression program, each element of list will be an argument
+ if compress is not None and compress not in compress_ext.keys():
+ raise ValueError("bad value for 'compress', or compression format not "
+ "supported : {0}".format(compress))
+
+ archive_name = base_name + '.tar' + compress_ext.get(compress, '')
+ archive_dir = os.path.dirname(archive_name)
+
+ if not os.path.exists(archive_dir):
+ if logger is not None:
+ logger.info("creating %s" % archive_dir)
+ if not dry_run:
+ os.makedirs(archive_dir)
+
+ # creating the tarball
+ if logger is not None:
+ logger.info('Creating tar archive')
+
+ uid = _get_uid(owner)
+ gid = _get_gid(group)
+
+ def _set_uid_gid(tarinfo):
+ if gid is not None:
+ tarinfo.gid = gid
+ tarinfo.gname = group
+ if uid is not None:
+ tarinfo.uid = uid
+ tarinfo.uname = owner
+ return tarinfo
+
+ if not dry_run:
+ tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress])
+ try:
+ tar.add(base_dir, filter=_set_uid_gid)
+ finally:
+ tar.close()
+
+ return archive_name
+
+def _call_external_zip(base_dir, zip_filename, verbose=False, dry_run=False):
+ # XXX see if we want to keep an external call here
+ if verbose:
+ zipoptions = "-r"
+ else:
+ zipoptions = "-rq"
+ from distutils.errors import DistutilsExecError
+ from distutils.spawn import spawn
+ try:
+ spawn(["zip", zipoptions, zip_filename, base_dir], dry_run=dry_run)
+ except DistutilsExecError:
+ # XXX really should distinguish between "couldn't find
+ # external 'zip' command" and "zip failed".
+ raise ExecError("unable to create zip file '%s': "
+ "could neither import the 'zipfile' module nor "
+ "find a standalone zip utility") % zip_filename
+
+def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
+ """Create a zip file from all the files under 'base_dir'.
+
+ The output zip file will be named 'base_name' + ".zip". Uses either the
+ "zipfile" Python module (if available) or the InfoZIP "zip" utility
+ (if installed and found on the default search path). If neither tool is
+ available, raises ExecError. Returns the name of the output zip
+ file.
+ """
+ zip_filename = base_name + ".zip"
+ archive_dir = os.path.dirname(base_name)
+
+ if not os.path.exists(archive_dir):
+ if logger is not None:
+ logger.info("creating %s", archive_dir)
+ if not dry_run:
+ os.makedirs(archive_dir)
+
+ # If zipfile module is not available, try spawning an external 'zip'
+ # command.
+ try:
+ import zipfile
+ except ImportError:
+ zipfile = None
+
+ if zipfile is None:
+ _call_external_zip(base_dir, zip_filename, verbose, dry_run)
+ else:
+ if logger is not None:
+ logger.info("creating '%s' and adding '%s' to it",
+ zip_filename, base_dir)
+
+ if not dry_run:
+ zip = zipfile.ZipFile(zip_filename, "w",
+ compression=zipfile.ZIP_DEFLATED)
+
+ for dirpath, dirnames, filenames in os.walk(base_dir):
+ for name in filenames:
+ path = os.path.normpath(os.path.join(dirpath, name))
+ if os.path.isfile(path):
+ zip.write(path, path)
+ if logger is not None:
+ logger.info("adding '%s'", path)
+ zip.close()
+
+ return zip_filename
+
+_ARCHIVE_FORMATS = {
+ 'gztar': (_make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
+ 'bztar': (_make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
+ 'tar': (_make_tarball, [('compress', None)], "uncompressed tar file"),
+ 'zip': (_make_zipfile, [],"ZIP file")
+ }
+
+if _BZ2_SUPPORTED:
+ _ARCHIVE_FORMATS['bztar'] = (_make_tarball, [('compress', 'bzip2')],
+ "bzip2'ed tar-file")
+
+def get_archive_formats():
+ """Returns a list of supported formats for archiving and unarchiving.
+
+ Each element of the returned sequence is a tuple (name, description)
+ """
+ formats = [(name, registry[2]) for name, registry in
+ _ARCHIVE_FORMATS.items()]
+ formats.sort()
+ return formats
+
+def register_archive_format(name, function, extra_args=None, description=''):
+ """Registers an archive format.
+
+ name is the name of the format. function is the callable that will be
+ used to create archives. If provided, extra_args is a sequence of
+ (name, value) tuples that will be passed as arguments to the callable.
+ description can be provided to describe the format, and will be returned
+ by the get_archive_formats() function.
+ """
+ if extra_args is None:
+ extra_args = []
+ if not isinstance(function, collections.Callable):
+ raise TypeError('The %s object is not callable' % function)
+ if not isinstance(extra_args, (tuple, list)):
+ raise TypeError('extra_args needs to be a sequence')
+ for element in extra_args:
+ if not isinstance(element, (tuple, list)) or len(element) !=2 :
+ raise TypeError('extra_args elements are : (arg_name, value)')
+
+ _ARCHIVE_FORMATS[name] = (function, extra_args, description)
+
+def unregister_archive_format(name):
+ del _ARCHIVE_FORMATS[name]
+
+def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
+ dry_run=0, owner=None, group=None, logger=None):
+ """Create an archive file (eg. zip or tar).
+
+ 'base_name' is the name of the file to create, minus any format-specific
+ extension; 'format' is the archive format: one of "zip", "tar", "bztar"
+ or "gztar".
+
+ 'root_dir' is a directory that will be the root directory of the
+ archive; ie. we typically chdir into 'root_dir' before creating the
+ archive. 'base_dir' is the directory where we start archiving from;
+ ie. 'base_dir' will be the common prefix of all files and
+ directories in the archive. 'root_dir' and 'base_dir' both default
+ to the current directory. Returns the name of the archive file.
+
+ 'owner' and 'group' are used when creating a tar archive. By default,
+ uses the current owner and group.
+ """
+ save_cwd = os.getcwd()
+ if root_dir is not None:
+ if logger is not None:
+ logger.debug("changing into '%s'", root_dir)
+ base_name = os.path.abspath(base_name)
+ if not dry_run:
+ os.chdir(root_dir)
+
+ if base_dir is None:
+ base_dir = os.curdir
+
+ kwargs = {'dry_run': dry_run, 'logger': logger}
+
+ try:
+ format_info = _ARCHIVE_FORMATS[format]
+ except KeyError:
+ raise ValueError("unknown archive format '%s'" % format)
+
+ func = format_info[0]
+ for arg, val in format_info[1]:
+ kwargs[arg] = val
+
+ if format != 'zip':
+ kwargs['owner'] = owner
+ kwargs['group'] = group
+
+ try:
+ filename = func(base_name, base_dir, **kwargs)
+ finally:
+ if root_dir is not None:
+ if logger is not None:
+ logger.debug("changing back to '%s'", save_cwd)
+ os.chdir(save_cwd)
+
+ return filename
+
+
+def get_unpack_formats():
+ """Returns a list of supported formats for unpacking.
+
+ Each element of the returned sequence is a tuple
+ (name, extensions, description)
+ """
+ formats = [(name, info[0], info[3]) for name, info in
+ _UNPACK_FORMATS.items()]
+ formats.sort()
+ return formats
+
+def _check_unpack_options(extensions, function, extra_args):
+ """Checks what gets registered as an unpacker."""
+ # first make sure no other unpacker is registered for this extension
+ existing_extensions = {}
+ for name, info in _UNPACK_FORMATS.items():
+ for ext in info[0]:
+ existing_extensions[ext] = name
+
+ for extension in extensions:
+ if extension in existing_extensions:
+ msg = '%s is already registered for "%s"'
+ raise RegistryError(msg % (extension,
+ existing_extensions[extension]))
+
+ if not isinstance(function, collections.Callable):
+ raise TypeError('The registered function must be a callable')
+
+
+def register_unpack_format(name, extensions, function, extra_args=None,
+ description=''):
+ """Registers an unpack format.
+
+ `name` is the name of the format. `extensions` is a list of extensions
+ corresponding to the format.
+
+ `function` is the callable that will be
+ used to unpack archives. The callable will receive archives to unpack.
+ If it's unable to handle an archive, it needs to raise a ReadError
+ exception.
+
+ If provided, `extra_args` is a sequence of
+ (name, value) tuples that will be passed as arguments to the callable.
+ description can be provided to describe the format, and will be returned
+ by the get_unpack_formats() function.
+ """
+ if extra_args is None:
+ extra_args = []
+ _check_unpack_options(extensions, function, extra_args)
+ _UNPACK_FORMATS[name] = extensions, function, extra_args, description
+
+def unregister_unpack_format(name):
+ """Removes the pack format from the registery."""
+ del _UNPACK_FORMATS[name]
+
+def _ensure_directory(path):
+ """Ensure that the parent directory of `path` exists"""
+ dirname = os.path.dirname(path)
+ if not os.path.isdir(dirname):
+ os.makedirs(dirname)
+
+def _unpack_zipfile(filename, extract_dir):
+ """Unpack zip `filename` to `extract_dir`
+ """
+ try:
+ import zipfile
+ except ImportError:
+ raise ReadError('zlib not supported, cannot unpack this archive.')
+
+ if not zipfile.is_zipfile(filename):
+ raise ReadError("%s is not a zip file" % filename)
+
+ zip = zipfile.ZipFile(filename)
+ try:
+ for info in zip.infolist():
+ name = info.filename
+
+ # don't extract absolute paths or ones with .. in them
+ if name.startswith('/') or '..' in name:
+ continue
+
+ target = os.path.join(extract_dir, *name.split('/'))
+ if not target:
+ continue
+
+ _ensure_directory(target)
+ if not name.endswith('/'):
+ # file
+ data = zip.read(info.filename)
+ f = open(target,'wb')
+ try:
+ f.write(data)
+ finally:
+ f.close()
+ del data
+ finally:
+ zip.close()
+
+def _unpack_tarfile(filename, extract_dir):
+ """Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
+ """
+ try:
+ tarobj = tarfile.open(filename)
+ except tarfile.TarError:
+ raise ReadError(
+ "%s is not a compressed or uncompressed tar file" % filename)
+ try:
+ tarobj.extractall(extract_dir)
+ finally:
+ tarobj.close()
+
+_UNPACK_FORMATS = {
+ 'gztar': (['.tar.gz', '.tgz'], _unpack_tarfile, [], "gzip'ed tar-file"),
+ 'tar': (['.tar'], _unpack_tarfile, [], "uncompressed tar file"),
+ 'zip': (['.zip'], _unpack_zipfile, [], "ZIP file")
+ }
+
+if _BZ2_SUPPORTED:
+ _UNPACK_FORMATS['bztar'] = (['.bz2'], _unpack_tarfile, [],
+ "bzip2'ed tar-file")
+
+def _find_unpack_format(filename):
+ for name, info in _UNPACK_FORMATS.items():
+ for extension in info[0]:
+ if filename.endswith(extension):
+ return name
+ return None
+
+def unpack_archive(filename, extract_dir=None, format=None):
+ """Unpack an archive.
+
+ `filename` is the name of the archive.
+
+ `extract_dir` is the name of the target directory, where the archive
+ is unpacked. If not provided, the current working directory is used.
+
+ `format` is the archive format: one of "zip", "tar", or "gztar". Or any
+ other registered format. If not provided, unpack_archive will use the
+ filename extension and see if an unpacker was registered for that
+ extension.
+
+ In case none is found, a ValueError is raised.
+ """
+ if extract_dir is None:
+ extract_dir = os.getcwd()
+
+ if format is not None:
+ try:
+ format_info = _UNPACK_FORMATS[format]
+ except KeyError:
+ raise ValueError("Unknown unpack format '{0}'".format(format))
+
+ func = format_info[1]
+ func(filename, extract_dir, **dict(format_info[2]))
+ else:
+ # we need to look at the registered unpackers supported extensions
+ format = _find_unpack_format(filename)
+ if format is None:
+ raise ReadError("Unknown archive format '{0}'".format(filename))
+
+ func = _UNPACK_FORMATS[format][1]
+ kwargs = dict(_UNPACK_FORMATS[format][2])
+ func(filename, extract_dir, **kwargs)
diff --git a/Lib/site.py b/Lib/site.py
index a0489fa461..a2c0becbc1 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -62,7 +62,10 @@ PREFIXES = [sys.prefix, sys.exec_prefix]
# Enable per user site-packages directory
# set it to False to disable the feature or True to force the feature
ENABLE_USER_SITE = None
+
# for distutils.commands.install
+# These values are initialized by the getuserbase() and getusersitepackages()
+# functions, through the main() function when Python starts.
USER_SITE = None
USER_BASE = None
@@ -76,8 +79,8 @@ def makepath(*paths):
return dir, os.path.normcase(dir)
-def abs__file__():
- """Set all module' __file__ attribute to an absolute path"""
+def abs_paths():
+ """Set all module __file__ and __cached__ attributes to an absolute path"""
for m in set(sys.modules.values()):
if hasattr(m, '__loader__'):
continue # don't mess with a PEP 302-supplied __file__
@@ -85,6 +88,10 @@ def abs__file__():
m.__file__ = os.path.abspath(m.__file__)
except (AttributeError, OSError):
pass
+ try:
+ m.__cached__ = os.path.abspath(m.__cached__)
+ except (AttributeError, OSError):
+ pass
def removeduppaths():
@@ -105,18 +112,6 @@ def removeduppaths():
sys.path[:] = L
return known_paths
-# XXX This should not be part of site.py, since it is needed even when
-# using the -S option for Python. See http://www.python.org/sf/586680
-def addbuilddir():
- """Append ./build/lib.<platform> in case we're running in the build dir
- (especially for Guido :-)"""
- from distutils.util import get_platform
- s = "build/lib.%s-%.3s" % (get_platform(), sys.version)
- if hasattr(sys, 'gettotalrefcount'):
- s += '-pydebug'
- s = os.path.join(os.path.dirname(sys.path[-1]), s)
- sys.path.append(s)
-
def _init_pathinfo():
"""Return a set containing all existing directory entries from sys.path"""
@@ -219,86 +214,103 @@ def check_enableusersite():
return True
+def getuserbase():
+ """Returns the `user base` directory path.
+
+ The `user base` directory can be used to store data. If the global
+ variable ``USER_BASE`` is not initialized yet, this function will also set
+ it.
+ """
+ global USER_BASE
+ if USER_BASE is not None:
+ return USER_BASE
+ from sysconfig import get_config_var
+ USER_BASE = get_config_var('userbase')
+ return USER_BASE
+
+def getusersitepackages():
+ """Returns the user-specific site-packages directory path.
+
+ If the global variable ``USER_SITE`` is not initialized yet, this
+ function will also set it.
+ """
+ global USER_SITE
+ user_base = getuserbase() # this will also set USER_BASE
+
+ if USER_SITE is not None:
+ return USER_SITE
+
+ from sysconfig import get_path
+ import os
+
+ if sys.platform == 'darwin':
+ from sysconfig import get_config_var
+ if get_config_var('PYTHONFRAMEWORK'):
+ USER_SITE = get_path('purelib', 'osx_framework_user')
+ return USER_SITE
+
+ USER_SITE = get_path('purelib', '%s_user' % os.name)
+ return USER_SITE
def addusersitepackages(known_paths):
"""Add a per user site-package to sys.path
Each user has its own python directory with site-packages in the
home directory.
-
- USER_BASE is the root directory for all Python versions
-
- USER_SITE is the user specific site-packages directory
-
- USER_SITE/.. can be used for data.
"""
- global USER_BASE, USER_SITE, ENABLE_USER_SITE
- env_base = os.environ.get("PYTHONUSERBASE", None)
-
- def joinuser(*args):
- return os.path.expanduser(os.path.join(*args))
-
- #if sys.platform in ('os2emx', 'riscos'):
- # # Don't know what to put here
- # USER_BASE = ''
- # USER_SITE = ''
- if os.name == "nt":
- base = os.environ.get("APPDATA") or "~"
- USER_BASE = env_base if env_base else joinuser(base, "Python")
- USER_SITE = os.path.join(USER_BASE,
- "Python" + sys.version[0] + sys.version[2],
- "site-packages")
- else:
- USER_BASE = env_base if env_base else joinuser("~", ".local")
- USER_SITE = os.path.join(USER_BASE, "lib",
- "python" + sys.version[:3],
- "site-packages")
+ # get the per user site-package path
+ # this call will also make sure USER_BASE and USER_SITE are set
+ user_site = getusersitepackages()
- if ENABLE_USER_SITE and os.path.isdir(USER_SITE):
- addsitedir(USER_SITE, known_paths)
+ if ENABLE_USER_SITE and os.path.isdir(user_site):
+ addsitedir(user_site, known_paths)
return known_paths
+def getsitepackages():
+ """Returns a list containing all global site-packages directories
+ (and possibly site-python).
-def addsitepackages(known_paths):
- """Add site-packages (and possibly site-python) to sys.path"""
- sitedirs = []
- seen = []
+ For each directory present in the global ``PREFIXES``, this function
+ will find its `site-packages` subdirectory depending on the system
+ environment, and will return a list of full paths.
+ """
+ sitepackages = []
+ seen = set()
for prefix in PREFIXES:
if not prefix or prefix in seen:
continue
- seen.append(prefix)
+ seen.add(prefix)
if sys.platform in ('os2emx', 'riscos'):
- sitedirs.append(os.path.join(prefix, "Lib", "site-packages"))
+ sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
elif os.sep == '/':
- sitedirs.append(os.path.join(prefix, "lib",
+ sitepackages.append(os.path.join(prefix, "lib",
"python" + sys.version[:3],
"site-packages"))
- sitedirs.append(os.path.join(prefix, "lib", "site-python"))
+ sitepackages.append(os.path.join(prefix, "lib", "site-python"))
else:
- sitedirs.append(prefix)
- sitedirs.append(os.path.join(prefix, "lib", "site-packages"))
-
+ sitepackages.append(prefix)
+ sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
if sys.platform == "darwin":
# for framework builds *only* we add the standard Apple
# locations.
- if 'Python.framework' in prefix:
- sitedirs.append(
- os.path.expanduser(
- os.path.join("~", "Library", "Python",
- sys.version[:3], "site-packages")))
- sitedirs.append(
- os.path.join("/Library", "Python",
+ from sysconfig import get_config_var
+ framework = get_config_var("PYTHONFRAMEWORK")
+ if framework:
+ sitepackages.append(
+ os.path.join("/Library", framework,
sys.version[:3], "site-packages"))
+ return sitepackages
- for sitedir in sitedirs:
+def addsitepackages(known_paths):
+ """Add site-packages (and possibly site-python) to sys.path"""
+ for sitedir in getsitepackages():
if os.path.isdir(sitedir):
addsitedir(sitedir, known_paths)
return known_paths
-
def setBEGINLIBPATH():
"""The OS/2 EMX port has optional extension modules that do double duty
as DLLs (and must use the .DLL file extension) for other extensions.
@@ -317,8 +329,10 @@ def setBEGINLIBPATH():
def setquit():
- """Define new built-ins 'quit' and 'exit'.
- These are simply strings that display a hint on how to exit.
+ """Define new builtins 'quit' and 'exit'.
+
+ These are objects which make the interpreter exit when called.
+ The repr of each object contains a hint at how it works.
"""
if os.sep == ':':
@@ -430,7 +444,7 @@ def setcopyright():
class _Helper(object):
- """Define the built-in 'help'.
+ """Define the builtin 'help'.
This is a wrapper around pydoc.help (with a twist).
"""
@@ -460,25 +474,6 @@ def aliasmbcs():
encodings._cache[enc] = encodings._unknown
encodings.aliases.aliases[enc] = 'mbcs'
-def setencoding():
- """Set the string encoding used by the Unicode implementation. The
- default is 'ascii', but if you're willing to experiment, you can
- change this."""
- encoding = "ascii" # Default value set by _PyUnicode_Init()
- if 0:
- # Enable to support locale aware default string encodings.
- import locale
- loc = locale.getdefaultlocale()
- if loc[1]:
- encoding = loc[1]
- if 0:
- # Enable to switch off string to Unicode coercion and implicit
- # Unicode to string conversion.
- encoding = "undefined"
- if encoding != "ascii":
- # On Non-Unicode builds this will raise an AttributeError...
- sys.setdefaultencoding(encoding) # Needs Python Unicode build !
-
def execsitecustomize():
"""Run custom site specific code, if available."""
@@ -515,11 +510,8 @@ def execusercustomize():
def main():
global ENABLE_USER_SITE
- abs__file__()
+ abs_paths()
known_paths = removeduppaths()
- if (os.name == "posix" and sys.path and
- os.path.basename(sys.path[-1]) == "Modules"):
- addbuilddir()
if ENABLE_USER_SITE is None:
ENABLE_USER_SITE = check_enableusersite()
known_paths = addusersitepackages(known_paths)
@@ -530,15 +522,9 @@ def main():
setcopyright()
sethelper()
aliasmbcs()
- setencoding()
execsitecustomize()
if ENABLE_USER_SITE:
execusercustomize()
- # Remove sys.setdefaultencoding() so that users cannot change the
- # encoding after initialization. The test for presence is needed when
- # this module is run as a script, because this code is executed twice.
- if hasattr(sys, "setdefaultencoding"):
- del sys.setdefaultencoding
main()
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index ab3e0e209b..599e79b7ed 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""An RFC 2821 smtp proxy.
Usage: %(program)s [options] [localhost:localport [remotehost:remoteport]]
@@ -59,7 +59,6 @@ and if remoteport is not given, then 25 is used.
# gets forwarded to a real backend smtpd, as with PureProxy. Again, errors
# are not handled correctly yet.
#
-# Please note that this script requires Python 2.0
#
# Author: Barry Warsaw <barry@python.org>
#
@@ -78,6 +77,7 @@ import time
import socket
import asyncore
import asynchat
+from warnings import warn
__all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]
@@ -109,20 +109,24 @@ class SMTPChannel(asynchat.async_chat):
COMMAND = 0
DATA = 1
+ data_size_limit = 33554432
+ command_size_limit = 512
+
def __init__(self, server, conn, addr):
asynchat.async_chat.__init__(self, conn)
- self.__server = server
- self.__conn = conn
- self.__addr = addr
- self.__line = []
- self.__state = self.COMMAND
- self.__greeting = 0
- self.__mailfrom = None
- self.__rcpttos = []
- self.__data = ''
- self.__fqdn = socket.getfqdn()
+ self.smtp_server = server
+ self.conn = conn
+ self.addr = addr
+ self.received_lines = []
+ self.smtp_state = self.COMMAND
+ self.seen_greeting = ''
+ self.mailfrom = None
+ self.rcpttos = []
+ self.received_data = ''
+ self.fqdn = socket.getfqdn()
+ self.num_bytes = 0
try:
- self.__peer = conn.getpeername()
+ self.peer = conn.getpeername()
except socket.error as err:
# a race condition may occur if the other end is closing
# before we can get the peername
@@ -130,24 +134,160 @@ class SMTPChannel(asynchat.async_chat):
if err.args[0] != errno.ENOTCONN:
raise
return
- print('Peer:', repr(self.__peer), file=DEBUGSTREAM)
- self.push('220 %s %s' % (self.__fqdn, __version__))
+ print('Peer:', repr(self.peer), file=DEBUGSTREAM)
+ self.push('220 %s %s' % (self.fqdn, __version__))
self.set_terminator(b'\r\n')
+ # properties for backwards-compatibility
+ @property
+ def __server(self):
+ warn("Access to __server attribute on SMTPChannel is deprecated, "
+ "use 'smtp_server' instead", PendingDeprecationWarning, 2)
+ return self.smtp_server
+ @__server.setter
+ def __server(self, value):
+ warn("Setting __server attribute on SMTPChannel is deprecated, "
+ "set 'smtp_server' instead", PendingDeprecationWarning, 2)
+ self.smtp_server = value
+
+ @property
+ def __line(self):
+ warn("Access to __line attribute on SMTPChannel is deprecated, "
+ "use 'received_lines' instead", PendingDeprecationWarning, 2)
+ return self.received_lines
+ @__line.setter
+ def __line(self, value):
+ warn("Setting __line attribute on SMTPChannel is deprecated, "
+ "set 'received_lines' instead", PendingDeprecationWarning, 2)
+ self.received_lines = value
+
+ @property
+ def __state(self):
+ warn("Access to __state attribute on SMTPChannel is deprecated, "
+ "use 'smtp_state' instead", PendingDeprecationWarning, 2)
+ return self.smtp_state
+ @__state.setter
+ def __state(self, value):
+ warn("Setting __state attribute on SMTPChannel is deprecated, "
+ "set 'smtp_state' instead", PendingDeprecationWarning, 2)
+ self.smtp_state = value
+
+ @property
+ def __greeting(self):
+ warn("Access to __greeting attribute on SMTPChannel is deprecated, "
+ "use 'seen_greeting' instead", PendingDeprecationWarning, 2)
+ return self.seen_greeting
+ @__greeting.setter
+ def __greeting(self, value):
+ warn("Setting __greeting attribute on SMTPChannel is deprecated, "
+ "set 'seen_greeting' instead", PendingDeprecationWarning, 2)
+ self.seen_greeting = value
+
+ @property
+ def __mailfrom(self):
+ warn("Access to __mailfrom attribute on SMTPChannel is deprecated, "
+ "use 'mailfrom' instead", PendingDeprecationWarning, 2)
+ return self.mailfrom
+ @__mailfrom.setter
+ def __mailfrom(self, value):
+ warn("Setting __mailfrom attribute on SMTPChannel is deprecated, "
+ "set 'mailfrom' instead", PendingDeprecationWarning, 2)
+ self.mailfrom = value
+
+ @property
+ def __rcpttos(self):
+ warn("Access to __rcpttos attribute on SMTPChannel is deprecated, "
+ "use 'rcpttos' instead", PendingDeprecationWarning, 2)
+ return self.rcpttos
+ @__rcpttos.setter
+ def __rcpttos(self, value):
+ warn("Setting __rcpttos attribute on SMTPChannel is deprecated, "
+ "set 'rcpttos' instead", PendingDeprecationWarning, 2)
+ self.rcpttos = value
+
+ @property
+ def __data(self):
+ warn("Access to __data attribute on SMTPChannel is deprecated, "
+ "use 'received_data' instead", PendingDeprecationWarning, 2)
+ return self.received_data
+ @__data.setter
+ def __data(self, value):
+ warn("Setting __data attribute on SMTPChannel is deprecated, "
+ "set 'received_data' instead", PendingDeprecationWarning, 2)
+ self.received_data = value
+
+ @property
+ def __fqdn(self):
+ warn("Access to __fqdn attribute on SMTPChannel is deprecated, "
+ "use 'fqdn' instead", PendingDeprecationWarning, 2)
+ return self.fqdn
+ @__fqdn.setter
+ def __fqdn(self, value):
+ warn("Setting __fqdn attribute on SMTPChannel is deprecated, "
+ "set 'fqdn' instead", PendingDeprecationWarning, 2)
+ self.fqdn = value
+
+ @property
+ def __peer(self):
+ warn("Access to __peer attribute on SMTPChannel is deprecated, "
+ "use 'peer' instead", PendingDeprecationWarning, 2)
+ return self.peer
+ @__peer.setter
+ def __peer(self, value):
+ warn("Setting __peer attribute on SMTPChannel is deprecated, "
+ "set 'peer' instead", PendingDeprecationWarning, 2)
+ self.peer = value
+
+ @property
+ def __conn(self):
+ warn("Access to __conn attribute on SMTPChannel is deprecated, "
+ "use 'conn' instead", PendingDeprecationWarning, 2)
+ return self.conn
+ @__conn.setter
+ def __conn(self, value):
+ warn("Setting __conn attribute on SMTPChannel is deprecated, "
+ "set 'conn' instead", PendingDeprecationWarning, 2)
+ self.conn = value
+
+ @property
+ def __addr(self):
+ warn("Access to __addr attribute on SMTPChannel is deprecated, "
+ "use 'addr' instead", PendingDeprecationWarning, 2)
+ return self.addr
+ @__addr.setter
+ def __addr(self, value):
+ warn("Setting __addr attribute on SMTPChannel is deprecated, "
+ "set 'addr' instead", PendingDeprecationWarning, 2)
+ self.addr = value
+
# Overrides base class for convenience
def push(self, msg):
asynchat.async_chat.push(self, bytes(msg + '\r\n', 'ascii'))
# Implementation of base class abstract method
def collect_incoming_data(self, data):
- self.__line.append(str(data, "utf8"))
+ limit = None
+ if self.smtp_state == self.COMMAND:
+ limit = self.command_size_limit
+ elif self.smtp_state == self.DATA:
+ limit = self.data_size_limit
+ if limit and self.num_bytes > limit:
+ return
+ elif limit:
+ self.num_bytes += len(data)
+ self.received_lines.append(str(data, "utf8"))
# Implementation of base class abstract method
def found_terminator(self):
- line = EMPTYSTRING.join(self.__line)
+ line = EMPTYSTRING.join(self.received_lines)
print('Data:', repr(line), file=DEBUGSTREAM)
- self.__line = []
- if self.__state == self.COMMAND:
+ self.received_lines = []
+ if self.smtp_state == self.COMMAND:
+ if self.num_bytes > self.command_size_limit:
+ self.push('500 Error: line too long')
+ self.num_bytes = 0
+ return
+ self.num_bytes = 0
if not line:
self.push('500 Error: bad syntax')
return
@@ -166,8 +306,13 @@ class SMTPChannel(asynchat.async_chat):
method(arg)
return
else:
- if self.__state != self.DATA:
+ if self.smtp_state != self.DATA:
self.push('451 Internal confusion')
+ self.num_bytes = 0
+ return
+ if self.num_bytes > self.data_size_limit:
+ self.push('552 Error: Too much mail data')
+ self.num_bytes = 0
return
# Remove extraneous carriage returns and de-transparency according
# to RFC 821, Section 4.5.2.
@@ -177,14 +322,15 @@ class SMTPChannel(asynchat.async_chat):
data.append(text[1:])
else:
data.append(text)
- self.__data = NEWLINE.join(data)
- status = self.__server.process_message(self.__peer,
- self.__mailfrom,
- self.__rcpttos,
- self.__data)
- self.__rcpttos = []
- self.__mailfrom = None
- self.__state = self.COMMAND
+ self.received_data = NEWLINE.join(data)
+ status = self.smtp_server.process_message(self.peer,
+ self.mailfrom,
+ self.rcpttos,
+ self.received_data)
+ self.rcpttos = []
+ self.mailfrom = None
+ self.smtp_state = self.COMMAND
+ self.num_bytes = 0
self.set_terminator(b'\r\n')
if not status:
self.push('250 Ok')
@@ -196,11 +342,11 @@ class SMTPChannel(asynchat.async_chat):
if not arg:
self.push('501 Syntax: HELO hostname')
return
- if self.__greeting:
+ if self.seen_greeting:
self.push('503 Duplicate HELO/EHLO')
else:
- self.__greeting = arg
- self.push('250 %s' % self.__fqdn)
+ self.seen_greeting = arg
+ self.push('250 %s' % self.fqdn)
def smtp_NOOP(self, arg):
if arg:
@@ -233,24 +379,24 @@ class SMTPChannel(asynchat.async_chat):
if not address:
self.push('501 Syntax: MAIL FROM:<address>')
return
- if self.__mailfrom:
+ if self.mailfrom:
self.push('503 Error: nested MAIL command')
return
- self.__mailfrom = address
- print('sender:', self.__mailfrom, file=DEBUGSTREAM)
+ self.mailfrom = address
+ print('sender:', self.mailfrom, file=DEBUGSTREAM)
self.push('250 Ok')
def smtp_RCPT(self, arg):
print('===> RCPT', arg, file=DEBUGSTREAM)
- if not self.__mailfrom:
+ if not self.mailfrom:
self.push('503 Error: need MAIL command')
return
address = self.__getaddr('TO:', arg) if arg else None
if not address:
self.push('501 Syntax: RCPT TO: <address>')
return
- self.__rcpttos.append(address)
- print('recips:', self.__rcpttos, file=DEBUGSTREAM)
+ self.rcpttos.append(address)
+ print('recips:', self.rcpttos, file=DEBUGSTREAM)
self.push('250 Ok')
def smtp_RSET(self, arg):
@@ -258,26 +404,29 @@ class SMTPChannel(asynchat.async_chat):
self.push('501 Syntax: RSET')
return
# Resets the sender, recipients, and data, but not the greeting
- self.__mailfrom = None
- self.__rcpttos = []
- self.__data = ''
- self.__state = self.COMMAND
+ self.mailfrom = None
+ self.rcpttos = []
+ self.received_data = ''
+ self.smtp_state = self.COMMAND
self.push('250 Ok')
def smtp_DATA(self, arg):
- if not self.__rcpttos:
+ if not self.rcpttos:
self.push('503 Error: need RCPT command')
return
if arg:
self.push('501 Syntax: DATA')
return
- self.__state = self.DATA
+ self.smtp_state = self.DATA
self.set_terminator(b'\r\n.\r\n')
self.push('354 End data with <CR><LF>.<CR><LF>')
class SMTPServer(asyncore.dispatcher):
+ # SMTPChannel class to use for managing client connections
+ channel_class = SMTPChannel
+
def __init__(self, localaddr, remoteaddr):
self._localaddr = localaddr
self._remoteaddr = remoteaddr
@@ -296,12 +445,9 @@ class SMTPServer(asyncore.dispatcher):
self.__class__.__name__, time.ctime(time.time()),
localaddr, remoteaddr), file=DEBUGSTREAM)
- def handle_accept(self):
- pair = self.accept()
- if pair is not None:
- conn, addr = pair
- print('Incoming connection from %s' % repr(addr), file=DEBUGSTREAM)
- channel = SMTPChannel(self, conn, addr)
+ def handle_accepted(self, conn, addr):
+ print('Incoming connection from %s' % repr(addr), file=DEBUGSTREAM)
+ channel = self.channel_class(self, conn, addr)
# API for "doing something useful with the message"
def process_message(self, peer, mailfrom, rcpttos, data):
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index a01a184c9f..14e62504d3 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
'''SMTP/ESMTP client class.
@@ -42,21 +42,25 @@ Example:
# This was modified from the Python 1.5 library HTTP lib.
import socket
+import io
import re
import email.utils
+import email.message
+import email.generator
import base64
import hmac
from email.base64mime import body_encode as encode_base64
from sys import stderr
-__all__ = ["SMTPException","SMTPServerDisconnected","SMTPResponseException",
- "SMTPSenderRefused","SMTPRecipientsRefused","SMTPDataError",
- "SMTPConnectError","SMTPHeloError","SMTPAuthenticationError",
- "quoteaddr","quotedata","SMTP"]
+__all__ = ["SMTPException", "SMTPServerDisconnected", "SMTPResponseException",
+ "SMTPSenderRefused", "SMTPRecipientsRefused", "SMTPDataError",
+ "SMTPConnectError", "SMTPHeloError", "SMTPAuthenticationError",
+ "quoteaddr", "quotedata", "SMTP"]
SMTP_PORT = 25
SMTP_SSL_PORT = 465
-CRLF="\r\n"
+CRLF = "\r\n"
+bCRLF = b"\r\n"
OLDSTYLE_AUTH = re.compile(r"auth=(.*)", re.I)
@@ -109,7 +113,7 @@ class SMTPRecipientsRefused(SMTPException):
def __init__(self, recipients):
self.recipients = recipients
- self.args = ( recipients,)
+ self.args = (recipients,)
class SMTPDataError(SMTPResponseException):
@@ -138,7 +142,7 @@ def quoteaddr(addr):
m = email.utils.parseaddr(addr)[1]
except AttributeError:
pass
- if m == (None, None): # Indicates parse failure or AttributeError
+ if m == (None, None): # Indicates parse failure or AttributeError
# something weird here.. punt -ddm
return "<%s>" % addr
elif m is None:
@@ -147,6 +151,7 @@ def quoteaddr(addr):
else:
return "<%s>" % m
+# Legacy method kept for backward compatibility.
def quotedata(data):
"""Quote data for email.
@@ -156,6 +161,12 @@ def quotedata(data):
return re.sub(r'(?m)^\.', '..',
re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
+def _quote_periods(bindata):
+ return re.sub(br'(?m)^\.', '..', bindata)
+
+def _fix_eols(data):
+ return re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)
+
try:
import ssl
except ImportError:
@@ -174,7 +185,8 @@ else:
chr = None
while chr != b"\n":
chr = self.sslobj.read(1)
- if not chr: break
+ if not chr:
+ break
str += chr
return str
@@ -269,10 +281,11 @@ class SMTP:
def _get_socket(self, host, port, timeout):
# This makes it simpler for SMTP_SSL to use the SMTP connect code
# and just alter the socket connection bit.
- if self.debuglevel > 0: print('connect:', (host, port), file=stderr)
+ if self.debuglevel > 0:
+ print('connect:', (host, port), file=stderr)
return socket.create_connection((host, port), timeout)
- def connect(self, host='localhost', port = 0):
+ def connect(self, host='localhost', port=0):
"""Connect to a host on a given port.
If the hostname ends with a colon (`:') followed by a number, and
@@ -286,20 +299,25 @@ class SMTP:
if not port and (host.find(':') == host.rfind(':')):
i = host.rfind(':')
if i >= 0:
- host, port = host[:i], host[i+1:]
- try: port = int(port)
+ host, port = host[:i], host[i + 1:]
+ try:
+ port = int(port)
except ValueError:
raise socket.error("nonnumeric port")
- if not port: port = self.default_port
- if self.debuglevel > 0: print('connect:', (host, port), file=stderr)
+ if not port:
+ port = self.default_port
+ if self.debuglevel > 0:
+ print('connect:', (host, port), file=stderr)
self.sock = self._get_socket(host, port, self.timeout)
(code, msg) = self.getreply()
- if self.debuglevel > 0: print("connect:", msg, file=stderr)
+ if self.debuglevel > 0:
+ print("connect:", msg, file=stderr)
return (code, msg)
def send(self, s):
"""Send `s' to the server."""
- if self.debuglevel > 0: print('send:', repr(s), file=stderr)
+ if self.debuglevel > 0:
+ print('send:', repr(s), file=stderr)
if hasattr(self, 'sock') and self.sock:
if isinstance(s, str):
s = s.encode("ascii")
@@ -332,7 +350,7 @@ class SMTP:
Raises SMTPServerDisconnected if end-of-file is reached.
"""
- resp=[]
+ resp = []
if self.file is None:
self.file = self.sock.makefile('rb')
while 1:
@@ -343,9 +361,10 @@ class SMTP:
if not line:
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed")
- if self.debuglevel > 0: print('reply:', repr(line), file=stderr)
+ if self.debuglevel > 0:
+ print('reply:', repr(line), file=stderr)
resp.append(line[4:].strip(b' \t\r\n'))
- code=line[:3]
+ code = line[:3]
# Check that the error code is syntactically correct.
# Don't attempt to read a continuation line if it is broken.
try:
@@ -359,12 +378,12 @@ class SMTP:
errmsg = b"\n".join(resp)
if self.debuglevel > 0:
- print('reply: retcode (%s); Msg: %s' % (errcode,errmsg), file=stderr)
+ print('reply: retcode (%s); Msg: %s' % (errcode, errmsg), file=stderr)
return errcode, errmsg
def docmd(self, cmd, args=""):
"""Send a command, and return its response code."""
- self.putcmd(cmd,args)
+ self.putcmd(cmd, args)
return self.getreply()
# std smtp commands
@@ -374,9 +393,9 @@ class SMTP:
host.
"""
self.putcmd("helo", name or self.local_hostname)
- (code,msg)=self.getreply()
- self.helo_resp=msg
- return (code,msg)
+ (code, msg) = self.getreply()
+ self.helo_resp = msg
+ return (code, msg)
def ehlo(self, name=''):
""" SMTP 'ehlo' command.
@@ -385,20 +404,20 @@ class SMTP:
"""
self.esmtp_features = {}
self.putcmd(self.ehlo_msg, name or self.local_hostname)
- (code,msg)=self.getreply()
+ (code, msg) = self.getreply()
# According to RFC1869 some (badly written)
# MTA's will disconnect on an ehlo. Toss an exception if
# that happens -ddm
if code == -1 and len(msg) == 0:
self.close()
raise SMTPServerDisconnected("Server not connected")
- self.ehlo_resp=msg
+ self.ehlo_resp = msg
if code != 250:
- return (code,msg)
- self.does_esmtp=1
+ return (code, msg)
+ self.does_esmtp = 1
#parse the ehlo response -ddm
assert isinstance(self.ehlo_resp, bytes), repr(self.ehlo_resp)
- resp=self.ehlo_resp.decode("latin-1").split('\n')
+ resp = self.ehlo_resp.decode("latin-1").split('\n')
del resp[0]
for each in resp:
# To be able to communicate with as many SMTP servers as possible,
@@ -418,16 +437,16 @@ class SMTP:
# It's actually stricter, in that only spaces are allowed between
# parameters, but were not going to check for that here. Note
# that the space isn't present if there are no parameters.
- m=re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?',each)
+ m = re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?', each)
if m:
- feature=m.group("feature").lower()
- params=m.string[m.end("feature"):].strip()
+ feature = m.group("feature").lower()
+ params = m.string[m.end("feature"):].strip()
if feature == "auth":
self.esmtp_features[feature] = self.esmtp_features.get(feature, "") \
+ " " + params
else:
- self.esmtp_features[feature]=params
- return (code,msg)
+ self.esmtp_features[feature] = params
+ return (code, msg)
def has_extn(self, opt):
"""Does the server support a given SMTP service extension?"""
@@ -447,51 +466,57 @@ class SMTP:
"""SMTP 'noop' command -- doesn't do anything :>"""
return self.docmd("noop")
- def mail(self,sender,options=[]):
+ def mail(self, sender, options=[]):
"""SMTP 'mail' command -- begins mail xfer session."""
optionlist = ''
if options and self.does_esmtp:
optionlist = ' ' + ' '.join(options)
- self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender) ,optionlist))
+ self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender), optionlist))
return self.getreply()
- def rcpt(self,recip,options=[]):
+ def rcpt(self, recip, options=[]):
"""SMTP 'rcpt' command -- indicates 1 recipient for this mail."""
optionlist = ''
if options and self.does_esmtp:
optionlist = ' ' + ' '.join(options)
- self.putcmd("rcpt","TO:%s%s" % (quoteaddr(recip),optionlist))
+ self.putcmd("rcpt", "TO:%s%s" % (quoteaddr(recip), optionlist))
return self.getreply()
- def data(self,msg):
+ def data(self, msg):
"""SMTP 'DATA' command -- sends message data to server.
Automatically quotes lines beginning with a period per rfc821.
Raises SMTPDataError if there is an unexpected reply to the
DATA command; the return value from this method is the final
- response code received when the all data is sent.
+ response code received when the all data is sent. If msg
+ is a string, lone '\r' and '\n' characters are converted to
+ '\r\n' characters. If msg is bytes, it is transmitted as is.
"""
self.putcmd("data")
- (code,repl)=self.getreply()
- if self.debuglevel >0 : print("data:", (code,repl), file=stderr)
+ (code, repl) = self.getreply()
+ if self.debuglevel > 0:
+ print("data:", (code, repl), file=stderr)
if code != 354:
- raise SMTPDataError(code,repl)
+ raise SMTPDataError(code, repl)
else:
- q = quotedata(msg)
- if q[-2:] != CRLF:
- q = q + CRLF
- q = q + "." + CRLF
+ if isinstance(msg, str):
+ msg = _fix_eols(msg).encode('ascii')
+ q = _quote_periods(msg)
+ if q[-2:] != bCRLF:
+ q = q + bCRLF
+ q = q + b"." + bCRLF
self.send(q)
- (code,msg)=self.getreply()
- if self.debuglevel >0 : print("data:", (code,msg), file=stderr)
- return (code,msg)
+ (code, msg) = self.getreply()
+ if self.debuglevel > 0:
+ print("data:", (code, msg), file=stderr)
+ return (code, msg)
def verify(self, address):
"""SMTP 'verify' command -- checks for address validity."""
self.putcmd("vrfy", quoteaddr(address))
return self.getreply()
# a.k.a.
- vrfy=verify
+ vrfy = verify
def expn(self, address):
"""SMTP 'expn' command -- expands a mailing list."""
@@ -549,7 +574,6 @@ class SMTP:
s = "\0%s\0%s" % (user, password)
return encode_base64(s.encode('ascii'), eol='')
-
AUTH_PLAIN = "PLAIN"
AUTH_CRAM_MD5 = "CRAM-MD5"
AUTH_LOGIN = "LOGIN"
@@ -559,45 +583,46 @@ class SMTP:
if not self.has_extn("auth"):
raise SMTPException("SMTP AUTH extension not supported by server.")
- # Authentication methods the server supports:
- authlist = self.esmtp_features["auth"].split()
+ # Authentication methods the server claims to support
+ advertised_authlist = self.esmtp_features["auth"].split()
# List of authentication methods we support: from preferred to
# less preferred methods. Except for the purpose of testing the weaker
# ones, we prefer stronger methods like CRAM-MD5:
preferred_auths = [AUTH_CRAM_MD5, AUTH_PLAIN, AUTH_LOGIN]
- # Determine the authentication method we'll use
- authmethod = None
- for method in preferred_auths:
- if method in authlist:
- authmethod = method
- break
-
- if authmethod == AUTH_CRAM_MD5:
- (code, resp) = self.docmd("AUTH", AUTH_CRAM_MD5)
- if code == 503:
- # 503 == 'Error: already authenticated'
- return (code, resp)
- (code, resp) = self.docmd(encode_cram_md5(resp, user, password))
- elif authmethod == AUTH_PLAIN:
- (code, resp) = self.docmd("AUTH",
- AUTH_PLAIN + " " + encode_plain(user, password))
- elif authmethod == AUTH_LOGIN:
- (code, resp) = self.docmd("AUTH",
- "%s %s" % (AUTH_LOGIN, encode_base64(user.encode('ascii'), eol='')))
- if code != 334:
- raise SMTPAuthenticationError(code, resp)
- (code, resp) = self.docmd(encode_base64(password.encode('ascii'), eol=''))
- elif authmethod is None:
+ # We try the authentication methods the server advertises, but only the
+ # ones *we* support. And in our preferred order.
+ authlist = [auth for auth in preferred_auths if auth in advertised_authlist]
+ if not authlist:
raise SMTPException("No suitable authentication method found.")
- if code not in (235, 503):
+
+ # Some servers advertise authentication methods they don't really
+ # support, so if authentication fails, we continue until we've tried
+ # all methods.
+ for authmethod in authlist:
+ if authmethod == AUTH_CRAM_MD5:
+ (code, resp) = self.docmd("AUTH", AUTH_CRAM_MD5)
+ if code == 334:
+ (code, resp) = self.docmd(encode_cram_md5(resp, user, password))
+ elif authmethod == AUTH_PLAIN:
+ (code, resp) = self.docmd("AUTH",
+ AUTH_PLAIN + " " + encode_plain(user, password))
+ elif authmethod == AUTH_LOGIN:
+ (code, resp) = self.docmd("AUTH",
+ "%s %s" % (AUTH_LOGIN, encode_base64(user.encode('ascii'), eol='')))
+ if code == 334:
+ (code, resp) = self.docmd(encode_base64(password.encode('ascii'), eol=''))
+
# 235 == 'Authentication successful'
# 503 == 'Error: already authenticated'
- raise SMTPAuthenticationError(code, resp)
- return (code, resp)
+ if code in (235, 503):
+ return (code, resp)
- def starttls(self, keyfile = None, certfile = None):
+ # We could not login sucessfully. Return result of last attempt.
+ raise SMTPAuthenticationError(code, resp)
+
+ def starttls(self, keyfile=None, certfile=None):
"""Puts the connection to the SMTP server into TLS mode.
If there has been no previous EHLO or HELO command this session, this
@@ -647,6 +672,10 @@ class SMTP:
- rcpt_options : List of ESMTP options (such as DSN commands) for
all the rcpt commands.
+ msg may be a string containing characters in the ASCII range, or a byte
+ string. A string is encoded to bytes using the ascii codec, and lone
+ \r and \n characters are converted to \r\n characters.
+
If there has been no previous EHLO or HELO command this session, this
method tries ESMTP EHLO first. If the server does ESMTP, message size
and each of the specified options will be passed to it. If EHLO
@@ -692,6 +721,8 @@ class SMTP:
"""
self.ehlo_or_helo_if_needed()
esmtp_opts = []
+ if isinstance(msg, str):
+ msg = _fix_eols(msg).encode('ascii')
if self.does_esmtp:
# Hmmm? what's this? -ddm
# self.esmtp_features['7bit']=""
@@ -699,29 +730,54 @@ class SMTP:
esmtp_opts.append("size=%d" % len(msg))
for option in mail_options:
esmtp_opts.append(option)
-
- (code,resp) = self.mail(from_addr, esmtp_opts)
+ (code, resp) = self.mail(from_addr, esmtp_opts)
if code != 250:
self.rset()
raise SMTPSenderRefused(code, resp, from_addr)
- senderrs={}
+ senderrs = {}
if isinstance(to_addrs, str):
to_addrs = [to_addrs]
for each in to_addrs:
- (code,resp)=self.rcpt(each, rcpt_options)
+ (code, resp) = self.rcpt(each, rcpt_options)
if (code != 250) and (code != 251):
- senderrs[each]=(code,resp)
- if len(senderrs)==len(to_addrs):
+ senderrs[each] = (code, resp)
+ if len(senderrs) == len(to_addrs):
# the server refused all our recipients
self.rset()
raise SMTPRecipientsRefused(senderrs)
- (code,resp) = self.data(msg)
+ (code, resp) = self.data(msg)
if code != 250:
self.rset()
raise SMTPDataError(code, resp)
#if we got here then somebody got our mail
return senderrs
+ def send_message(self, msg, from_addr=None, to_addrs=None,
+ mail_options=[], rcpt_options={}):
+ """Converts message to a bytestring and passes it to sendmail.
+
+ The arguments are as for sendmail, except that msg is an
+ email.message.Message object. If from_addr is None, the from_addr is
+ taken from the 'From' header of the Message. If to_addrs is None, its
+ value is composed from the addresses listed in the 'To', 'CC', and
+ 'Bcc' fields. Regardless of the values of from_addr and to_addr, any
+ Bcc field in the Message object is deleted. The Message object is then
+ serialized using email.generator.BytesGenerator and sendmail is called
+ to transmit the message.
+ """
+ if from_addr is None:
+ from_addr = msg['From']
+ if to_addrs is None:
+ addr_fields = [f for f in (msg['To'], msg['Bcc'], msg['CC'])
+ if f is not None]
+ to_addrs = [a[1] for a in email.utils.getaddresses(addr_fields)]
+ del msg['Bcc']
+ with io.BytesIO() as bytesmsg:
+ g = email.generator.BytesGenerator(bytesmsg)
+ g.flatten(msg, linesep='\r\n')
+ flatmsg = bytesmsg.getvalue()
+ return self.sendmail(from_addr, to_addrs, flatmsg, mail_options,
+ rcpt_options)
def close(self):
"""Close the connection to the SMTP server."""
@@ -732,7 +788,6 @@ class SMTP:
self.sock.close()
self.sock = None
-
def quit(self):
"""Terminate the SMTP session."""
res = self.docmd("quit")
@@ -758,7 +813,8 @@ if _have_ssl:
self.default_port = SMTP_SSL_PORT
def _get_socket(self, host, port, timeout):
- if self.debuglevel > 0: print('connect:', (host, port), file=stderr)
+ if self.debuglevel > 0:
+ print('connect:', (host, port), file=stderr)
new_socket = socket.create_connection((host, port), timeout)
new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile)
self.file = SSLFakeFile(new_socket)
@@ -786,11 +842,11 @@ class LMTP(SMTP):
ehlo_msg = "lhlo"
- def __init__(self, host = '', port = LMTP_PORT, local_hostname = None):
+ def __init__(self, host='', port=LMTP_PORT, local_hostname=None):
"""Initialize a new instance."""
SMTP.__init__(self, host, port, local_hostname)
- def connect(self, host = 'localhost', port = 0):
+ def connect(self, host='localhost', port=0):
"""Connect to the LMTP daemon, on either a Unix or a TCP socket."""
if host[0] != '/':
return SMTP.connect(self, host, port)
@@ -800,13 +856,15 @@ class LMTP(SMTP):
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(host)
except socket.error as msg:
- if self.debuglevel > 0: print('connect fail:', host, file=stderr)
+ if self.debuglevel > 0:
+ print('connect fail:', host, file=stderr)
if self.sock:
self.sock.close()
self.sock = None
raise socket.error(msg)
(code, msg) = self.getreply()
- if self.debuglevel > 0: print('connect:', msg, file=stderr)
+ if self.debuglevel > 0:
+ print('connect:', msg, file=stderr)
return (code, msg)
@@ -820,7 +878,7 @@ if __name__ == '__main__':
return sys.stdin.readline().strip()
fromaddr = prompt("From")
- toaddrs = prompt("To").split(',')
+ toaddrs = prompt("To").split(',')
print("Enter message, end with ^D:")
msg = ''
while 1:
diff --git a/Lib/socket.py b/Lib/socket.py
index d0350617ae..1e285493c4 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -23,7 +23,8 @@ inet_aton() -- convert IP addr string (123.45.67.89) to 32-bit packed format
inet_ntoa() -- convert 32-bit packed format IP to string (123.45.67.89)
socket.getdefaulttimeout() -- get the default timeout value
socket.setdefaulttimeout() -- set the default timeout value
-create_connection() -- connects to an address, with an optional timeout
+create_connection() -- connects to an address, with an optional timeout and
+ optional source address.
[*] not available on all platforms!
@@ -48,9 +49,13 @@ from _socket import *
import os, sys, io
try:
- from errno import EBADF
+ import errno
except ImportError:
- EBADF = 9
+ errno = None
+EBADF = getattr(errno, 'EBADF', 9)
+EINTR = getattr(errno, 'EINTR', 4)
+EAGAIN = getattr(errno, 'EAGAIN', 11)
+EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11)
__all__ = ["getfqdn", "create_connection"]
__all__.extend(os._get_exports_list(_socket))
@@ -90,13 +95,20 @@ class socket(_socket.socket):
self._io_refs = 0
self._closed = False
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *args):
+ if not self._closed:
+ self.close()
+
def __repr__(self):
"""Wrap __repr__() to reveal the real class name."""
s = _socket.socket.__repr__(self)
if s.startswith("<socket object"):
s = "<%s.%s%s%s" % (self.__class__.__module__,
self.__class__.__name__,
- (self._closed and " [closed] ") or "",
+ getattr(self, '_closed', False) and " [closed] " or "",
s[7:])
return s
@@ -118,7 +130,13 @@ class socket(_socket.socket):
For IP sockets, the address info is a pair (hostaddr, port).
"""
fd, addr = self._accept()
- return socket(self.family, self.type, self.proto, fileno=fd), addr
+ sock = socket(self.family, self.type, self.proto, fileno=fd)
+ # Issue #7995: if no default timeout is set and the listening
+ # socket had a (non-zero) timeout, force the new socket in blocking
+ # mode to override platform-specific socket flags inheritance.
+ if getdefaulttimeout() is None and self.gettimeout():
+ sock.setblocking(True)
+ return sock, addr
def makefile(self, mode="r", buffering=None, *,
encoding=None, errors=None, newline=None):
@@ -169,10 +187,12 @@ class socket(_socket.socket):
if self._closed:
self.close()
- def _real_close(self):
- _socket.socket.close(self)
+ def _real_close(self, _ss=_socket.socket):
+ # This function should not reference any globals. See issue #808164.
+ _ss.close(self)
def close(self):
+ # This function should not reference any globals. See issue #808164.
self._closed = True
if self._io_refs <= 0:
self._real_close()
@@ -187,6 +207,29 @@ def fromfd(fd, family, type, proto=0):
return socket(family, type, proto, nfd)
+if hasattr(_socket, "socketpair"):
+
+ def socketpair(family=None, type=SOCK_STREAM, proto=0):
+ """socketpair([family[, type[, proto]]]) -> (socket object, socket object)
+
+ Create a pair of socket objects from the sockets returned by the platform
+ socketpair() function.
+ The arguments are the same as for socket() except the default family is
+ AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
+ """
+ if family is None:
+ try:
+ family = AF_UNIX
+ except NameError:
+ family = AF_INET
+ a, b = _socket.socketpair(family, type, proto)
+ a = socket(family, type, proto, a.detach())
+ b = socket(family, type, proto, b.detach())
+ return a, b
+
+
+_blocking_errnos = { EAGAIN, EWOULDBLOCK }
+
class SocketIO(io.RawIOBase):
"""Raw I/O implementation for stream sockets.
@@ -214,6 +257,7 @@ class SocketIO(io.RawIOBase):
self._mode = mode
self._reading = "r" in mode
self._writing = "w" in mode
+ self._timeout_occurred = False
def readinto(self, b):
"""Read up to len(b) bytes into the writable buffer *b* and return
@@ -225,7 +269,21 @@ class SocketIO(io.RawIOBase):
"""
self._checkClosed()
self._checkReadable()
- return self._sock.recv_into(b)
+ if self._timeout_occurred:
+ raise IOError("cannot read from timed out object")
+ while True:
+ try:
+ return self._sock.recv_into(b)
+ except timeout:
+ self._timeout_occurred = True
+ raise
+ except error as e:
+ n = e.args[0]
+ if n == EINTR:
+ continue
+ if n in _blocking_errnos:
+ return None
+ raise
def write(self, b):
"""Write the given bytes or bytearray object *b* to the socket
@@ -235,7 +293,13 @@ class SocketIO(io.RawIOBase):
"""
self._checkClosed()
self._checkWritable()
- return self._sock.send(b)
+ try:
+ return self._sock.send(b)
+ except error as e:
+ # XXX what about EINTR?
+ if e.args[0] in _blocking_errnos:
+ return None
+ raise
def readable(self):
"""True if the SocketIO is open for reading.
@@ -255,7 +319,10 @@ class SocketIO(io.RawIOBase):
@property
def name(self):
- return self.fileno()
+ if not self.closed:
+ return self.fileno()
+ else:
+ return -1
@property
def mode(self):
@@ -271,10 +338,6 @@ class SocketIO(io.RawIOBase):
self._sock._decref_socketios()
self._sock = None
- def __del__(self):
- if not self.closed:
- self._sock._decref_socketios()
-
def getfqdn(name=''):
"""Get fully qualified domain name from name.
@@ -304,7 +367,8 @@ def getfqdn(name=''):
_GLOBAL_DEFAULT_TIMEOUT = object()
-def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT):
+def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
+ source_address=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
@@ -312,7 +376,9 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT):
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the
global default timeout setting returned by :func:`getdefaulttimeout`
- is used.
+ is used. If *source_address* is set it must be a tuple of (host, port)
+ for the socket to bind as a source address before making the connection.
+ An host of '' or port 0 tells the OS to use the default.
"""
host, port = address
@@ -324,6 +390,8 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT):
sock = socket(af, socktype, proto)
if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
+ if source_address:
+ sock.bind(source_address)
sock.connect(sa)
return sock
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index 3d32c3ea19..089b3bac11 100644
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -168,6 +168,7 @@ class BaseServer:
- verify_request(request, client_address)
- server_close()
- process_request(request, client_address)
+ - shutdown_request(request)
- close_request(request)
- handle_error()
@@ -283,7 +284,7 @@ class BaseServer:
self.process_request(request, client_address)
except:
self.handle_error(request, client_address)
- self.close_request(request)
+ self.shutdown_request(request)
def handle_timeout(self):
"""Called if no new request arrives within self.timeout.
@@ -307,7 +308,7 @@ class BaseServer:
"""
self.finish_request(request, client_address)
- self.close_request(request)
+ self.shutdown_request(request)
def server_close(self):
"""Called to clean-up the server.
@@ -321,6 +322,10 @@ class BaseServer:
"""Finish one request by instantiating RequestHandlerClass."""
self.RequestHandlerClass(request, client_address, self)
+ def shutdown_request(self, request):
+ """Called to shutdown and close an individual request."""
+ self.close_request(request)
+
def close_request(self, request):
"""Called to clean up an individual request."""
pass
@@ -361,6 +366,7 @@ class TCPServer(BaseServer):
- handle_timeout()
- verify_request(request, client_address)
- process_request(request, client_address)
+ - shutdown_request(request)
- close_request(request)
- handle_error()
@@ -445,6 +451,16 @@ class TCPServer(BaseServer):
"""
return self.socket.accept()
+ def shutdown_request(self, request):
+ """Called to shutdown and close an individual request."""
+ try:
+ #explicitly shutdown. socket.close() merely releases
+ #the socket and waits for GC to perform the actual close.
+ request.shutdown(socket.SHUT_WR)
+ except socket.error:
+ pass #some platforms may raise ENOTCONN here
+ self.close_request(request)
+
def close_request(self, request):
"""Called to clean up an individual request."""
request.close()
@@ -468,6 +484,10 @@ class UDPServer(TCPServer):
# No need to call listen() for UDP.
pass
+ def shutdown_request(self, request):
+ # No need to shutdown anything.
+ self.close_request(request)
+
def close_request(self, request):
# No need to close anything.
pass
@@ -535,10 +555,12 @@ class ForkingMixIn:
# This must never return, hence os._exit()!
try:
self.finish_request(request, client_address)
+ self.shutdown_request(request)
os._exit(0)
except:
try:
self.handle_error(request, client_address)
+ self.shutdown_request(request)
finally:
os._exit(1)
@@ -558,10 +580,10 @@ class ThreadingMixIn:
"""
try:
self.finish_request(request, client_address)
- self.close_request(request)
+ self.shutdown_request(request)
except:
self.handle_error(request, client_address)
- self.close_request(request)
+ self.shutdown_request(request)
def process_request(self, request, client_address):
"""Start a new thread to process the request."""
@@ -613,8 +635,10 @@ class BaseRequestHandler:
self.client_address = client_address
self.server = server
self.setup()
- self.handle()
- self.finish()
+ try:
+ self.handle()
+ finally:
+ self.finish()
def setup(self):
pass
@@ -648,8 +672,20 @@ class StreamRequestHandler(BaseRequestHandler):
rbufsize = -1
wbufsize = 0
+ # A timeout to apply to the request socket, if not None.
+ timeout = None
+
+ # Disable nagle algorithm for this socket, if True.
+ # Use only when wbufsize != 0, to avoid small packets.
+ disable_nagle_algorithm = False
+
def setup(self):
self.connection = self.request
+ if self.timeout is not None:
+ self.connection.settimeout(self.timeout)
+ if self.disable_nagle_algorithm:
+ self.connection.setsockopt(socket.IPPROTO_TCP,
+ socket.TCP_NODELAY, True)
self.rfile = self.connection.makefile('rb', self.rbufsize)
self.wfile = self.connection.makefile('wb', self.wbufsize)
diff --git a/Lib/sqlite3/__init__.py b/Lib/sqlite3/__init__.py
index 4b64833e93..6c91df27cc 100644
--- a/Lib/sqlite3/__init__.py
+++ b/Lib/sqlite3/__init__.py
@@ -1,7 +1,6 @@
-#-*- coding: ISO-8859-1 -*-
# pysqlite2/__init__.py: the pysqlite2 package.
#
-# Copyright (C) 2005 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2005 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py
index d051f0432f..6c121a5c06 100644
--- a/Lib/sqlite3/dbapi2.py
+++ b/Lib/sqlite3/dbapi2.py
@@ -1,7 +1,6 @@
-#-*- coding: ISO-8859-1 -*-
# pysqlite2/dbapi2.py: the DB-API 2.0 interface
#
-# Copyright (C) 2004-2005 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2004-2005 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index fbf3072341..518b8ae410 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -1,7 +1,7 @@
#-*- coding: ISO-8859-1 -*-
# pysqlite2/test/dbapi.py: tests for DB-API compliance
#
-# Copyright (C) 2004-2007 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
@@ -22,8 +22,11 @@
# 3. This notice may not be removed or altered from any source distribution.
import unittest
-import threading
import sqlite3 as sqlite
+try:
+ import threading
+except ImportError:
+ threading = None
class ModuleTests(unittest.TestCase):
def CheckAPILevel(self):
@@ -81,6 +84,7 @@ class ModuleTests(unittest.TestCase):
"NotSupportedError is not a subclass of DatabaseError")
class ConnectionTests(unittest.TestCase):
+
def setUp(self):
self.cx = sqlite.connect(":memory:")
cu = self.cx.cursor()
@@ -137,6 +141,28 @@ class ConnectionTests(unittest.TestCase):
self.assertEqual(self.cx.ProgrammingError, sqlite.ProgrammingError)
self.assertEqual(self.cx.NotSupportedError, sqlite.NotSupportedError)
+ def CheckInTransaction(self):
+ # Can't use db from setUp because we want to test initial state.
+ cx = sqlite.connect(":memory:")
+ cu = cx.cursor()
+ self.assertEqual(cx.in_transaction, False)
+ cu.execute("create table transactiontest(id integer primary key, name text)")
+ self.assertEqual(cx.in_transaction, False)
+ cu.execute("insert into transactiontest(name) values (?)", ("foo",))
+ self.assertEqual(cx.in_transaction, True)
+ cu.execute("select name from transactiontest where name=?", ["foo"])
+ row = cu.fetchone()
+ self.assertEqual(cx.in_transaction, True)
+ cx.commit()
+ self.assertEqual(cx.in_transaction, False)
+ cu.execute("select name from transactiontest where name=?", ["foo"])
+ row = cu.fetchone()
+ self.assertEqual(cx.in_transaction, False)
+
+ def CheckInTransactionRO(self):
+ with self.assertRaises(AttributeError):
+ self.cx.in_transaction = True
+
class CursorTests(unittest.TestCase):
def setUp(self):
self.cx = sqlite.connect(":memory:")
@@ -460,6 +486,7 @@ class CursorTests(unittest.TestCase):
except TypeError:
pass
+@unittest.skipUnless(threading, 'This test requires threading.')
class ThreadTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")
@@ -653,13 +680,13 @@ class ExtensionTests(unittest.TestCase):
res = cur.fetchone()[0]
self.assertEqual(res, 5)
- def CheckScriptErrorIncomplete(self):
+ def CheckScriptSyntaxError(self):
con = sqlite.connect(":memory:")
cur = con.cursor()
raised = False
try:
- cur.executescript("create table test(sadfsadfdsa")
- except sqlite.ProgrammingError:
+ cur.executescript("create table test(x); asdf; create table test2(x)")
+ except sqlite.OperationalError:
raised = True
self.assertEqual(raised, True, "should have raised an exception")
@@ -692,7 +719,7 @@ class ExtensionTests(unittest.TestCase):
result = con.execute("select foo from test").fetchone()[0]
self.assertEqual(result, 5, "Basic test of Connection.executescript")
-class ClosedTests(unittest.TestCase):
+class ClosedConTests(unittest.TestCase):
def setUp(self):
pass
@@ -744,7 +771,6 @@ class ClosedTests(unittest.TestCase):
except:
self.fail("Should have raised a ProgrammingError")
-
def CheckClosedCreateFunction(self):
con = sqlite.connect(":memory:")
con.close()
@@ -811,6 +837,36 @@ class ClosedTests(unittest.TestCase):
except:
self.fail("Should have raised a ProgrammingError")
+class ClosedCurTests(unittest.TestCase):
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def CheckClosed(self):
+ con = sqlite.connect(":memory:")
+ cur = con.cursor()
+ cur.close()
+
+ for method_name in ("execute", "executemany", "executescript", "fetchall", "fetchmany", "fetchone"):
+ if method_name in ("execute", "executescript"):
+ params = ("select 4 union select 5",)
+ elif method_name == "executemany":
+ params = ("insert into foo(bar) values (?)", [(3,), (4,)])
+ else:
+ params = []
+
+ try:
+ method = getattr(cur, method_name)
+
+ method(*params)
+ self.fail("Should have raised a ProgrammingError: method " + method_name)
+ except sqlite.ProgrammingError:
+ pass
+ except:
+ self.fail("Should have raised a ProgrammingError: " + method_name)
+
def suite():
module_suite = unittest.makeSuite(ModuleTests, "Check")
connection_suite = unittest.makeSuite(ConnectionTests, "Check")
@@ -818,8 +874,9 @@ def suite():
thread_suite = unittest.makeSuite(ThreadTests, "Check")
constructor_suite = unittest.makeSuite(ConstructorTests, "Check")
ext_suite = unittest.makeSuite(ExtensionTests, "Check")
- closed_suite = unittest.makeSuite(ClosedTests, "Check")
- return unittest.TestSuite((module_suite, connection_suite, cursor_suite, thread_suite, constructor_suite, ext_suite, closed_suite))
+ closed_con_suite = unittest.makeSuite(ClosedConTests, "Check")
+ closed_cur_suite = unittest.makeSuite(ClosedCurTests, "Check")
+ return unittest.TestSuite((module_suite, connection_suite, cursor_suite, thread_suite, constructor_suite, ext_suite, closed_con_suite, closed_cur_suite))
def test():
runner = unittest.TextTestRunner()
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
index 5e315fa0fb..7d0553d8f1 100644
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -1,7 +1,7 @@
#-*- coding: ISO-8859-1 -*-
# pysqlite2/test/regression.py: pysqlite regression tests
#
-# Copyright (C) 2006 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2006-2010 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
@@ -70,16 +70,6 @@ class RegressionTests(unittest.TestCase):
cur.execute('select 1 as "foo baz"')
self.assertEqual(cur.description[0][0], "foo baz")
- def CheckStatementAvailable(self):
- # pysqlite up to 2.3.2 crashed on this, because the active statement handle was not checked
- # before trying to fetch data from it. close() destroys the active statement ...
- con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES)
- cur = con.cursor()
- cur.execute("select 4 union select 5")
- cur.close()
- cur.fetchone()
- cur.fetchone()
-
def CheckStatementFinalizationOnCloseDb(self):
# pysqlite versions <= 2.3.3 only finalized statements in the statement
# cache when closing the database. statements that were still
@@ -169,6 +159,25 @@ class RegressionTests(unittest.TestCase):
con = sqlite.connect(":memory:")
setattr(con, "isolation_level", "\xe9")
+ def CheckCursorConstructorCallCheck(self):
+ """
+ Verifies that cursor methods check wether base class __init__ was called.
+ """
+ class Cursor(sqlite.Cursor):
+ def __init__(self, con):
+ pass
+
+ con = sqlite.connect(":memory:")
+ cur = Cursor(con)
+ try:
+ cur.execute("select 4+5").fetchall()
+ self.fail("should have raised ProgrammingError")
+ except sqlite.ProgrammingError:
+ pass
+ except:
+ self.fail("should have raised ProgrammingError")
+
+
def CheckStrSubclass(self):
"""
The Python 3.0 port of the module didn't cope with values of subclasses of str.
@@ -176,6 +185,88 @@ class RegressionTests(unittest.TestCase):
class MyStr(str): pass
self.con.execute("select ?", (MyStr("abc"),))
+ def CheckConnectionConstructorCallCheck(self):
+ """
+ Verifies that connection methods check wether base class __init__ was called.
+ """
+ class Connection(sqlite.Connection):
+ def __init__(self, name):
+ pass
+
+ con = Connection(":memory:")
+ try:
+ cur = con.cursor()
+ self.fail("should have raised ProgrammingError")
+ except sqlite.ProgrammingError:
+ pass
+ except:
+ self.fail("should have raised ProgrammingError")
+
+ def CheckCursorRegistration(self):
+ """
+ Verifies that subclassed cursor classes are correctly registered with
+ the connection object, too. (fetch-across-rollback problem)
+ """
+ class Connection(sqlite.Connection):
+ def cursor(self):
+ return Cursor(self)
+
+ class Cursor(sqlite.Cursor):
+ def __init__(self, con):
+ sqlite.Cursor.__init__(self, con)
+
+ con = Connection(":memory:")
+ cur = con.cursor()
+ cur.execute("create table foo(x)")
+ cur.executemany("insert into foo(x) values (?)", [(3,), (4,), (5,)])
+ cur.execute("select x from foo")
+ con.rollback()
+ try:
+ cur.fetchall()
+ self.fail("should have raised InterfaceError")
+ except sqlite.InterfaceError:
+ pass
+ except:
+ self.fail("should have raised InterfaceError")
+
+ def CheckAutoCommit(self):
+ """
+ Verifies that creating a connection in autocommit mode works.
+ 2.5.3 introduced a regression so that these could no longer
+ be created.
+ """
+ con = sqlite.connect(":memory:", isolation_level=None)
+
+ def CheckPragmaAutocommit(self):
+ """
+ Verifies that running a PRAGMA statement that does an autocommit does
+ work. This did not work in 2.5.3/2.5.4.
+ """
+ cur = self.con.cursor()
+ cur.execute("create table foo(bar)")
+ cur.execute("insert into foo(bar) values (5)")
+
+ cur.execute("pragma page_size")
+ row = cur.fetchone()
+
+ def CheckSetDict(self):
+ """
+ See http://bugs.python.org/issue7478
+
+ It was possible to successfully register callbacks that could not be
+ hashed. Return codes of PyDict_SetItem were not checked properly.
+ """
+ class NotHashable:
+ def __call__(self, *args, **kw):
+ pass
+ def __hash__(self):
+ raise TypeError()
+ var = NotHashable()
+ self.assertRaises(TypeError, self.con.create_function, var)
+ self.assertRaises(TypeError, self.con.create_aggregate, var)
+ self.assertRaises(TypeError, self.con.set_authorizer, var)
+ self.assertRaises(TypeError, self.con.set_progress_handler, var)
+
def CheckConnectionCall(self):
"""
Call a connection with a non-string SQL request: check error handling
diff --git a/Lib/sqlite3/test/transactions.py b/Lib/sqlite3/test/transactions.py
index c9f6125560..70e96a12ed 100644
--- a/Lib/sqlite3/test/transactions.py
+++ b/Lib/sqlite3/test/transactions.py
@@ -147,6 +147,26 @@ class TransactionTests(unittest.TestCase):
# NO self.con2.rollback() HERE!!!
self.con1.commit()
+ def CheckRollbackCursorConsistency(self):
+ """
+ Checks if cursors on the connection are set into a "reset" state
+ when a rollback is done on the connection.
+ """
+ con = sqlite.connect(":memory:")
+ cur = con.cursor()
+ cur.execute("create table test(x)")
+ cur.execute("insert into test(x) values (5)")
+ cur.execute("select 1 union select 2 union select 3")
+
+ con.rollback()
+ try:
+ cur.fetchall()
+ self.fail("InterfaceError should have been raised")
+ except sqlite.InterfaceError as e:
+ pass
+ except:
+ self.fail("InterfaceError should have been raised")
+
class SpecialCommandTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")
diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py
index 0940e9b28d..29413e14ec 100644
--- a/Lib/sqlite3/test/types.py
+++ b/Lib/sqlite3/test/types.py
@@ -21,9 +21,14 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
-import zlib, datetime
+import datetime
import unittest
import sqlite3 as sqlite
+try:
+ import zlib
+except ImportError:
+ zlib = None
+
class SqliteTypeTests(unittest.TestCase):
def setUp(self):
@@ -312,6 +317,7 @@ class ObjectAdaptationTests(unittest.TestCase):
val = self.cur.fetchone()[0]
self.assertEqual(type(val), float)
+@unittest.skipUnless(zlib, "requires zlib")
class BinaryConverterTests(unittest.TestCase):
def convert(s):
return zlib.decompress(s)
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index 47e1701d2f..f52ea01459 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -343,7 +343,7 @@ def _optimize_unicode(charset, fixup):
else:
code = 'I'
# Convert block indices to byte array of 256 bytes
- mapping = array.array('b', mapping).tostring()
+ mapping = array.array('b', mapping).tobytes()
# Convert byte array to word array
mapping = array.array(code, mapping)
assert mapping.itemsize == _sre.CODESIZE
diff --git a/Lib/ssl.py b/Lib/ssl.py
index f98bd73428..84aa6dc3bf 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -55,13 +55,16 @@ PROTOCOL_TLSv1
"""
import textwrap
+import re
import _ssl # if we can't import it, let the error propagate
-from _ssl import SSLError
+from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
+from _ssl import _SSLContext, SSLError
from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
from _ssl import (PROTOCOL_SSLv2, PROTOCOL_SSLv3, PROTOCOL_SSLv23,
PROTOCOL_TLSv1)
+from _ssl import OP_ALL, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1
from _ssl import RAND_status, RAND_egd, RAND_add
from _ssl import (
SSL_ERROR_ZERO_RETURN,
@@ -74,17 +77,98 @@ from _ssl import (
SSL_ERROR_EOF,
SSL_ERROR_INVALID_ERROR_CODE,
)
+from _ssl import HAS_SNI
from socket import getnameinfo as _getnameinfo
from socket import error as socket_error
-from socket import dup as _dup
from socket import socket, AF_INET, SOCK_STREAM
import base64 # for DER-to-PEM translation
import traceback
import errno
-class SSLSocket(socket):
+class CertificateError(ValueError):
+ pass
+
+
+def _dnsname_to_pat(dn):
+ pats = []
+ for frag in dn.split(r'.'):
+ if frag == '*':
+ # When '*' is a fragment by itself, it matches a non-empty dotless
+ # fragment.
+ pats.append('[^.]+')
+ else:
+ # Otherwise, '*' matches any dotless fragment.
+ frag = re.escape(frag)
+ pats.append(frag.replace(r'\*', '[^.]*'))
+ return re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE)
+
+
+def match_hostname(cert, hostname):
+ """Verify that *cert* (in decoded format as returned by
+ SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 rules
+ are mostly followed, but IP addresses are not accepted for *hostname*.
+
+ CertificateError is raised on failure. On success, the function
+ returns nothing.
+ """
+ if not cert:
+ raise ValueError("empty or no certificate")
+ dnsnames = []
+ san = cert.get('subjectAltName', ())
+ for key, value in san:
+ if key == 'DNS':
+ if _dnsname_to_pat(value).match(hostname):
+ return
+ dnsnames.append(value)
+ if not san:
+ # The subject is only checked when subjectAltName is empty
+ for sub in cert.get('subject', ()):
+ for key, value in sub:
+ # XXX according to RFC 2818, the most specific Common Name
+ # must be used.
+ if key == 'commonName':
+ if _dnsname_to_pat(value).match(hostname):
+ return
+ dnsnames.append(value)
+ if len(dnsnames) > 1:
+ raise CertificateError("hostname %r "
+ "doesn't match either of %s"
+ % (hostname, ', '.join(map(repr, dnsnames))))
+ elif len(dnsnames) == 1:
+ raise CertificateError("hostname %r "
+ "doesn't match %r"
+ % (hostname, dnsnames[0]))
+ else:
+ raise CertificateError("no appropriate commonName or "
+ "subjectAltName fields were found")
+
+
+class SSLContext(_SSLContext):
+ """An SSLContext holds various SSL-related configuration options and
+ data, such as certificates and possibly a private key."""
+
+ __slots__ = ('protocol',)
+
+ def __new__(cls, protocol, *args, **kwargs):
+ return _SSLContext.__new__(cls, protocol)
+
+ def __init__(self, protocol):
+ self.protocol = protocol
+
+ def wrap_socket(self, sock, server_side=False,
+ do_handshake_on_connect=True,
+ suppress_ragged_eofs=True,
+ server_hostname=None):
+ return SSLSocket(sock=sock, server_side=server_side,
+ do_handshake_on_connect=do_handshake_on_connect,
+ suppress_ragged_eofs=suppress_ragged_eofs,
+ server_hostname=server_hostname,
+ _context=self)
+
+
+class SSLSocket(socket):
"""This class implements a subtype of socket.socket that wraps
the underlying OS socket in an SSL context when necessary, and
provides read and write methods over that channel."""
@@ -94,15 +178,48 @@ class SSLSocket(socket):
ssl_version=PROTOCOL_SSLv23, ca_certs=None,
do_handshake_on_connect=True,
family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None,
- suppress_ragged_eofs=True):
+ suppress_ragged_eofs=True, ciphers=None,
+ server_hostname=None,
+ _context=None):
+ if _context:
+ self.context = _context
+ else:
+ if server_side and not certfile:
+ raise ValueError("certfile must be specified for server-side "
+ "operations")
+ if keyfile and not certfile:
+ raise ValueError("certfile must be specified")
+ if certfile and not keyfile:
+ keyfile = certfile
+ self.context = SSLContext(ssl_version)
+ self.context.verify_mode = cert_reqs
+ if ca_certs:
+ self.context.load_verify_locations(ca_certs)
+ if certfile:
+ self.context.load_cert_chain(certfile, keyfile)
+ if ciphers:
+ self.context.set_ciphers(ciphers)
+ self.keyfile = keyfile
+ self.certfile = certfile
+ self.cert_reqs = cert_reqs
+ self.ssl_version = ssl_version
+ self.ca_certs = ca_certs
+ self.ciphers = ciphers
+ if server_side and server_hostname:
+ raise ValueError("server_hostname can only be specified "
+ "in client mode")
+ self.server_side = server_side
+ self.server_hostname = server_hostname
+ self.do_handshake_on_connect = do_handshake_on_connect
+ self.suppress_ragged_eofs = suppress_ragged_eofs
connected = False
if sock is not None:
socket.__init__(self,
family=sock.family,
type=sock.type,
proto=sock.proto,
- fileno=_dup(sock.fileno()))
+ fileno=sock.fileno())
self.settimeout(sock.gettimeout())
# see if it's connected
try:
@@ -112,23 +229,20 @@ class SSLSocket(socket):
raise
else:
connected = True
- sock.close()
+ sock.detach()
elif fileno is not None:
socket.__init__(self, fileno=fileno)
else:
socket.__init__(self, family=family, type=type, proto=proto)
- if certfile and not keyfile:
- keyfile = certfile
-
self._closed = False
self._sslobj = None
+ self._connected = connected
if connected:
# create the SSL object
try:
- self._sslobj = _ssl.sslwrap(self, server_side,
- keyfile, certfile,
- cert_reqs, ssl_version, ca_certs)
+ self._sslobj = self.context._wrap_socket(self, server_side,
+ server_hostname)
if do_handshake_on_connect:
timeout = self.gettimeout()
if timeout == 0.0:
@@ -140,14 +254,6 @@ class SSLSocket(socket):
self.close()
raise x
- self.keyfile = keyfile
- self.certfile = certfile
- self.cert_reqs = cert_reqs
- self.ssl_version = ssl_version
- self.ca_certs = ca_certs
- self.do_handshake_on_connect = do_handshake_on_connect
- self.suppress_ragged_eofs = suppress_ragged_eofs
-
def dup(self):
raise NotImplemented("Can't dup() %s instances" %
self.__class__.__name__)
@@ -234,6 +340,10 @@ class SSLSocket(socket):
def sendall(self, data, flags=0):
self._checkClosed()
if self._sslobj:
+ if flags != 0:
+ raise ValueError(
+ "non-zero flags not allowed in calls to sendall() on %s" %
+ self.__class__)
amount = len(data)
count = 0
while (count < amount):
@@ -321,24 +431,36 @@ class SSLSocket(socket):
finally:
self.settimeout(timeout)
- def connect(self, addr):
- """Connects to remote ADDR, and then wraps the connection in
- an SSL channel."""
-
+ def _real_connect(self, addr, return_errno):
+ if self.server_side:
+ raise ValueError("can't connect in server-side mode")
# Here we assume that the socket is client-side, and not
# connected at the time of the call. We connect it, then wrap it.
- if self._sslobj:
+ if self._connected:
raise ValueError("attempt to connect already-connected SSLSocket!")
- socket.connect(self, addr)
- self._sslobj = _ssl.sslwrap(self, False, self.keyfile, self.certfile,
- self.cert_reqs, self.ssl_version,
- self.ca_certs)
+ self._sslobj = self.context._wrap_socket(self, False, self.server_hostname)
try:
+ socket.connect(self, addr)
if self.do_handshake_on_connect:
self.do_handshake()
- except:
- self._sslobj = None
- raise
+ except socket_error as e:
+ if return_errno:
+ return e.errno
+ else:
+ self._sslobj = None
+ raise e
+ self._connected = True
+ return 0
+
+ def connect(self, addr):
+ """Connects to remote ADDR, and then wraps the connection in
+ an SSL channel."""
+ self._real_connect(addr, False)
+
+ def connect_ex(self, addr):
+ """Connects to remote ADDR, and then wraps the connection in
+ an SSL channel."""
+ return self._real_connect(addr, True)
def accept(self):
"""Accepts a new connection from a remote client, and returns
@@ -352,6 +474,7 @@ class SSLSocket(socket):
cert_reqs=self.cert_reqs,
ssl_version=self.ssl_version,
ca_certs=self.ca_certs,
+ ciphers=self.ciphers,
do_handshake_on_connect=
self.do_handshake_on_connect),
addr)
@@ -365,13 +488,14 @@ def wrap_socket(sock, keyfile=None, certfile=None,
server_side=False, cert_reqs=CERT_NONE,
ssl_version=PROTOCOL_SSLv23, ca_certs=None,
do_handshake_on_connect=True,
- suppress_ragged_eofs=True):
+ suppress_ragged_eofs=True, ciphers=None):
return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile,
server_side=server_side, cert_reqs=cert_reqs,
ssl_version=ssl_version, ca_certs=ca_certs,
do_handshake_on_connect=do_handshake_on_connect,
- suppress_ragged_eofs=suppress_ragged_eofs)
+ suppress_ragged_eofs=suppress_ragged_eofs,
+ ciphers=ciphers)
# some utility functions
diff --git a/Lib/string.py b/Lib/string.py
index a9898e8a06..ef0334c472 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -14,6 +14,8 @@ printable -- a string containing all ASCII characters considered printable
"""
+import _string
+
# Some strings for ctype-style character classification
whitespace = ' \t\n\r\v\f'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
@@ -42,28 +44,6 @@ def capwords(s, sep=None):
return (sep or ' ').join(x.capitalize() for x in s.split(sep))
-# Construct a translation map for bytes.translate
-def maketrans(frm: bytes, to: bytes) -> bytes:
- """maketrans(frm, to) -> bytes
-
- Return a translation table (a bytes object of length 256)
- suitable for use in bytes.translate where each byte in frm is
- mapped to the byte at the same position in to.
- The strings frm and to must be of the same length.
- """
- import warnings
- warnings.warn("string.maketrans is deprecated, use bytes.maketrans instead",
- DeprecationWarning, 2)
- if len(frm) != len(to):
- raise ValueError("maketrans arguments must have same length")
- if not (isinstance(frm, bytes) and isinstance(to, bytes)):
- raise TypeError("maketrans arguments must be bytes objects")
- L = bytearray(range(256))
- for i, c in enumerate(frm):
- L[c] = to[i]
- return bytes(L)
-
-
####################################################################
import re as _re
@@ -103,7 +83,7 @@ class _TemplateMetaclass(type):
'delim' : _re.escape(cls.delimiter),
'id' : cls.idpattern,
}
- cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
+ cls.pattern = _re.compile(pattern, cls.flags | _re.VERBOSE)
class Template(metaclass=_TemplateMetaclass):
@@ -111,6 +91,7 @@ class Template(metaclass=_TemplateMetaclass):
delimiter = '$'
idpattern = r'[_a-z][_a-z0-9]*'
+ flags = _re.IGNORECASE
def __init__(self, template):
self.template = template
@@ -166,24 +147,18 @@ class Template(metaclass=_TemplateMetaclass):
mapping = args[0]
# Helper function for .sub()
def convert(mo):
- named = mo.group('named')
+ named = mo.group('named') or mo.group('braced')
if named is not None:
try:
# We use this idiom instead of str() because the latter
# will fail if val is a Unicode containing non-ASCII
return '%s' % (mapping[named],)
except KeyError:
- return self.delimiter + named
- braced = mo.group('braced')
- if braced is not None:
- try:
- return '%s' % (mapping[braced],)
- except KeyError:
- return self.delimiter + '{' + braced + '}'
+ return mo.group()
if mo.group('escaped') is not None:
return self.delimiter
if mo.group('invalid') is not None:
- return self.delimiter
+ return mo.group()
raise ValueError('Unrecognized named group in pattern',
self.pattern)
return self.pattern.sub(convert, self.template)
@@ -195,10 +170,10 @@ class Template(metaclass=_TemplateMetaclass):
# see PEP 3101 for details and purpose of this class
# The hard parts are reused from the C implementation. They're exposed as "_"
-# prefixed methods of str and unicode.
+# prefixed methods of str.
-# The overall parser is implemented in str._formatter_parser.
-# The field name parser is implemented in str._formatter_field_name_split
+# The overall parser is implemented in _string.formatter_parser.
+# The field name parser is implemented in _string.formatter_field_name_split
class Formatter:
def format(self, format_string, *args, **kwargs):
@@ -267,7 +242,7 @@ class Formatter:
return str(value)
elif conversion is None:
return value
- raise ValueError("Unknown converion specifier {0!s}".format(conversion))
+ raise ValueError("Unknown conversion specifier {0!s}".format(conversion))
# returns an iterable that contains tuples of the form:
@@ -278,7 +253,7 @@ class Formatter:
# if field_name is not None, it is looked up, formatted
# with format_spec and conversion and then used
def parse(self, format_string):
- return format_string._formatter_parser()
+ return _string.formatter_parser(format_string)
# given a field_name, find the object it references.
@@ -287,7 +262,7 @@ class Formatter:
# used_args: a set of which args have been used
# args, kwargs: as passed in to vformat
def get_field(self, field_name, args, kwargs):
- first, rest = field_name._formatter_field_name_split()
+ first, rest = _string.formatter_field_name_split(field_name)
obj = self.get_value(first, args, kwargs)
diff --git a/Lib/struct.py b/Lib/struct.py
index dca15e2ad3..9bfc23f8d5 100644
--- a/Lib/struct.py
+++ b/Lib/struct.py
@@ -1,6 +1,6 @@
__all__ = [
# Functions
- 'calcsize', 'pack', 'unpack', 'unpack', 'unpack_from',
+ 'calcsize', 'pack', 'pack_into', 'unpack', 'unpack_from',
# Classes
'Struct',
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 97792dbe60..477f927821 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -27,9 +27,10 @@ This module defines one class called Popen:
class Popen(args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=False, shell=False,
+ preexec_fn=None, close_fds=True, shell=False,
cwd=None, env=None, universal_newlines=False,
- startupinfo=None, creationflags=0):
+ startupinfo=None, creationflags=0,
+ restore_signals=True, start_new_session=False, pass_fds=()):
Arguments are:
@@ -38,12 +39,12 @@ args should be a string, or a sequence of program arguments. The
program to execute is normally the first item in the args sequence or
string, but can be explicitly set by using the executable argument.
-On UNIX, with shell=False (default): In this case, the Popen class
+On POSIX, with shell=False (default): In this case, the Popen class
uses os.execvp() to execute the child program. args should normally
be a sequence. A string will be treated as a sequence with the string
as the only item (the program to execute).
-On UNIX, with shell=True: If args is a string, it specifies the
+On POSIX, with shell=True: If args is a string, it specifies the
command string to execute through the shell. If args is a sequence,
the first item specifies the command string, and any additional items
will be treated as additional shell arguments.
@@ -72,11 +73,19 @@ parent. Additionally, stderr can be STDOUT, which indicates that the
stderr data from the applications should be captured into the same
file handle as for stdout.
-If preexec_fn is set to a callable object, this object will be called
-in the child process just before the child is executed.
+On POSIX, if preexec_fn is set to a callable object, this object will be
+called in the child process just before the child is executed. The use
+of preexec_fn is not thread safe, using it in the presence of threads
+could lead to a deadlock in the child process before the new executable
+is executed.
If close_fds is true, all file descriptors except 0, 1 and 2 will be
-closed before the child process is executed.
+closed before the child process is executed. The default for close_fds
+varies by platform: Always true on POSIX. True when stdin/stdout/stderr
+are None on Windows, false otherwise.
+
+pass_fds is an optional sequence of file descriptors to keep open between the
+parent and child. Providing any pass_fds implicitly sets close_fds to true.
if shell is true, the specified command will be executed through the
shell.
@@ -84,12 +93,20 @@ shell.
If cwd is not None, the current directory will be changed to cwd
before the child is executed.
+On POSIX, if restore_signals is True all signals that Python sets to
+SIG_IGN are restored to SIG_DFL in the child process before the exec.
+Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals. This
+parameter does nothing on Windows.
+
+On POSIX, if start_new_session is True, the setsid() system call will be made
+in the child process prior to executing the command.
+
If env is not None, it defines the environment variables for the new
process.
If universal_newlines is true, the file objects stdout and stderr are
opened as a text files, but lines may be terminated by any of '\n',
-the Unix end-of-line convention, '\r', the Macintosh convention or
+the Unix end-of-line convention, '\r', the old Macintosh convention or
'\r\n', the Windows convention. All of these external representations
are seen as '\n' by the Python program. Note: This feature is only
available if Python is built with universal newline support (the
@@ -110,7 +127,7 @@ call(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
- >>> retcode = call(["ls", "-l"])
+ >>> retcode = subprocess.call(["ls", "-l"])
check_call(*popenargs, **kwargs):
Run command with arguments. Wait for command to complete. If the
@@ -120,7 +137,7 @@ check_call(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
- >>> check_call(["ls", "-l"])
+ >>> subprocess.check_call(["ls", "-l"])
0
getstatusoutput(cmd):
@@ -230,7 +247,7 @@ pid
returncode
The child return code. A None value indicates that the process
hasn't terminated yet. A negative value -N indicates that the
- child was terminated by signal N (UNIX only).
+ child was terminated by signal N (POSIX only).
Replacing older functions with the subprocess module
@@ -326,6 +343,8 @@ import os
import traceback
import gc
import signal
+import builtins
+import warnings
# Exception classes used by this module.
class CalledProcessError(Exception):
@@ -343,7 +362,6 @@ class CalledProcessError(Exception):
if mswindows:
- from _subprocess import CREATE_NEW_CONSOLE
import threading
import msvcrt
import _subprocess
@@ -362,17 +380,43 @@ else:
import fcntl
import pickle
+ try:
+ import _posixsubprocess
+ except ImportError:
+ _posixsubprocess = None
+ warnings.warn("The _posixsubprocess module is not being used. "
+ "Child process reliability may suffer if your "
+ "program uses threads.", RuntimeWarning)
+
# When select or poll has indicated that the file is writable,
# we can write up to _PIPE_BUF bytes without risk of blocking.
# POSIX defines PIPE_BUF as >= 512.
_PIPE_BUF = getattr(select, 'PIPE_BUF', 512)
+ _FD_CLOEXEC = getattr(fcntl, 'FD_CLOEXEC', 1)
+
+ def _set_cloexec(fd, cloexec):
+ old = fcntl.fcntl(fd, fcntl.F_GETFD)
+ if cloexec:
+ fcntl.fcntl(fd, fcntl.F_SETFD, old | _FD_CLOEXEC)
+ else:
+ fcntl.fcntl(fd, fcntl.F_SETFD, old & ~_FD_CLOEXEC)
+
+ if _posixsubprocess:
+ _create_pipe = _posixsubprocess.cloexec_pipe
+ else:
+ def _create_pipe():
+ fds = os.pipe()
+ _set_cloexec(fds[0], True)
+ _set_cloexec(fds[1], True)
+ return fds
__all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput",
"getoutput", "check_output", "CalledProcessError"]
if mswindows:
- __all__.append("CREATE_NEW_CONSOLE")
+ from _subprocess import CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP
+ __all__.extend(["CREATE_NEW_CONSOLE", "CREATE_NEW_PROCESS_GROUP"])
try:
MAXFD = os.sysconf("SC_OPEN_MAX")
except:
@@ -540,7 +584,7 @@ def list2cmdline(seq):
# Various tools for executing commands and looking at their output and status.
#
-# NB This only works (and is only relevant) for UNIX.
+# NB This only works (and is only relevant) for POSIX.
def getstatusoutput(cmd):
"""Return (status, output) of executing cmd in a shell.
@@ -580,12 +624,17 @@ def getoutput(cmd):
return getstatusoutput(cmd)[1]
+_PLATFORM_DEFAULT_CLOSE_FDS = object()
+
+
class Popen(object):
def __init__(self, args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=False, shell=False,
- cwd=None, env=None, universal_newlines=False,
- startupinfo=None, creationflags=0):
+ preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS,
+ shell=False, cwd=None, env=None, universal_newlines=False,
+ startupinfo=None, creationflags=0,
+ restore_signals=True, start_new_session=False,
+ pass_fds=()):
"""Create new Popen instance."""
_cleanup()
@@ -599,12 +648,24 @@ class Popen(object):
if preexec_fn is not None:
raise ValueError("preexec_fn is not supported on Windows "
"platforms")
- if close_fds and (stdin is not None or stdout is not None or
- stderr is not None):
- raise ValueError("close_fds is not supported on Windows "
- "platforms if you redirect stdin/stdout/stderr")
+ any_stdio_set = (stdin is not None or stdout is not None or
+ stderr is not None)
+ if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
+ if any_stdio_set:
+ close_fds = False
+ else:
+ close_fds = True
+ elif close_fds and any_stdio_set:
+ raise ValueError(
+ "close_fds is not supported on Windows platforms"
+ " if you redirect stdin/stdout/stderr")
else:
# POSIX
+ if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
+ close_fds = True
+ if pass_fds and not close_fds:
+ warnings.warn("pass_fds overriding close_fds.", RuntimeWarning)
+ close_fds = True
if startupinfo is not None:
raise ValueError("startupinfo is only supported on Windows "
"platforms")
@@ -631,48 +692,73 @@ class Popen(object):
# On POSIX, the child objects are file descriptors. On
# Windows, these are Windows file handles. The parent objects
# are file descriptors on both platforms. The parent objects
- # are None when not using PIPEs. The child objects are None
+ # are -1 when not using PIPEs. The child objects are -1
# when not redirecting.
(p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
- self._execute_child(args, executable, preexec_fn, close_fds,
- cwd, env, universal_newlines,
- startupinfo, creationflags, shell,
- p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite)
+ # We wrap OS handles *before* launching the child, otherwise a
+ # quickly terminating child could make our fds unwrappable
+ # (see #8458).
if mswindows:
- if p2cwrite is not None:
+ if p2cwrite != -1:
p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0)
- if c2pread is not None:
+ if c2pread != -1:
c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0)
- if errread is not None:
+ if errread != -1:
errread = msvcrt.open_osfhandle(errread.Detach(), 0)
if bufsize == 0:
bufsize = 1 # Nearly unbuffered (XXX for now)
- if p2cwrite is not None:
+ if p2cwrite != -1:
self.stdin = io.open(p2cwrite, 'wb', bufsize)
if self.universal_newlines:
self.stdin = io.TextIOWrapper(self.stdin)
- if c2pread is not None:
+ if c2pread != -1:
self.stdout = io.open(c2pread, 'rb', bufsize)
if universal_newlines:
self.stdout = io.TextIOWrapper(self.stdout)
- if errread is not None:
+ if errread != -1:
self.stderr = io.open(errread, 'rb', bufsize)
if universal_newlines:
self.stderr = io.TextIOWrapper(self.stderr)
+ try:
+ self._execute_child(args, executable, preexec_fn, close_fds,
+ pass_fds, cwd, env, universal_newlines,
+ startupinfo, creationflags, shell,
+ p2cread, p2cwrite,
+ c2pread, c2pwrite,
+ errread, errwrite,
+ restore_signals, start_new_session)
+ except:
+ # Cleanup if the child failed starting
+ for f in filter(None, [self.stdin, self.stdout, self.stderr]):
+ try:
+ f.close()
+ except EnvironmentError:
+ # Ignore EBADF or other errors
+ pass
+ raise
+
def _translate_newlines(self, data, encoding):
data = data.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
return data.decode(encoding)
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ if self.stdout:
+ self.stdout.close()
+ if self.stderr:
+ self.stderr.close()
+ if self.stdin:
+ self.stdin.close()
def __del__(self, _maxsize=sys.maxsize, _active=_active):
if not self._child_created:
@@ -728,11 +814,11 @@ class Popen(object):
p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
"""
if stdin is None and stdout is None and stderr is None:
- return (None, None, None, None, None, None)
+ return (-1, -1, -1, -1, -1, -1)
- p2cread, p2cwrite = None, None
- c2pread, c2pwrite = None, None
- errread, errwrite = None, None
+ p2cread, p2cwrite = -1, -1
+ c2pread, c2pwrite = -1, -1
+ errread, errwrite = -1, -1
if stdin is None:
p2cread = _subprocess.GetStdHandle(_subprocess.STD_INPUT_HANDLE)
@@ -805,20 +891,23 @@ class Popen(object):
def _execute_child(self, args, executable, preexec_fn, close_fds,
- cwd, env, universal_newlines,
+ pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
- errread, errwrite):
+ errread, errwrite,
+ unused_restore_signals, unused_start_new_session):
"""Execute program (MS Windows version)"""
+ assert not pass_fds, "pass_fds not supported on Windows."
+
if not isinstance(args, str):
args = list2cmdline(args)
# Process startup details
if startupinfo is None:
startupinfo = STARTUPINFO()
- if None not in (p2cread, c2pwrite, errwrite):
+ if -1 not in (p2cread, c2pwrite, errwrite):
startupinfo.dwFlags |= _subprocess.STARTF_USESTDHANDLES
startupinfo.hStdInput = p2cread
startupinfo.hStdOutput = c2pwrite
@@ -868,11 +957,11 @@ class Popen(object):
# output pipe are maintained in this process or else the
# pipe will not close when the child process exits and the
# ReadFile will hang.
- if p2cread is not None:
+ if p2cread != -1:
p2cread.Close()
- if c2pwrite is not None:
+ if c2pwrite != -1:
c2pwrite.Close()
- if errwrite is not None:
+ if errwrite != -1:
errwrite.Close()
# Retain the process handle, but close the thread handle
@@ -910,6 +999,7 @@ class Popen(object):
def _readerthread(self, fh, buffer):
buffer.append(fh.read())
+ fh.close()
def _communicate(self, input):
@@ -953,8 +1043,12 @@ class Popen(object):
"""
if sig == signal.SIGTERM:
self.terminate()
+ elif sig == signal.CTRL_C_EVENT:
+ os.kill(self.pid, signal.CTRL_C_EVENT)
+ elif sig == signal.CTRL_BREAK_EVENT:
+ os.kill(self.pid, signal.CTRL_BREAK_EVENT)
else:
- raise ValueError("Only SIGTERM is supported on Windows")
+ raise ValueError("Unsupported signal: {}".format(sig))
def terminate(self):
"""Terminates the process
@@ -971,14 +1065,14 @@ class Popen(object):
"""Construct and return tuple with IO objects:
p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
"""
- p2cread, p2cwrite = None, None
- c2pread, c2pwrite = None, None
- errread, errwrite = None, None
+ p2cread, p2cwrite = -1, -1
+ c2pread, c2pwrite = -1, -1
+ errread, errwrite = -1, -1
if stdin is None:
pass
elif stdin == PIPE:
- p2cread, p2cwrite = os.pipe()
+ p2cread, p2cwrite = _create_pipe()
elif isinstance(stdin, int):
p2cread = stdin
else:
@@ -988,7 +1082,7 @@ class Popen(object):
if stdout is None:
pass
elif stdout == PIPE:
- c2pread, c2pwrite = os.pipe()
+ c2pread, c2pwrite = _create_pipe()
elif isinstance(stdout, int):
c2pwrite = stdout
else:
@@ -998,7 +1092,7 @@ class Popen(object):
if stderr is None:
pass
elif stderr == PIPE:
- errread, errwrite = os.pipe()
+ errread, errwrite = _create_pipe()
elif stderr == STDOUT:
errwrite = c2pwrite
elif isinstance(stderr, int):
@@ -1012,30 +1106,23 @@ class Popen(object):
errread, errwrite)
- def _set_cloexec_flag(self, fd, cloexec=True):
- try:
- cloexec_flag = fcntl.FD_CLOEXEC
- except AttributeError:
- cloexec_flag = 1
-
- old = fcntl.fcntl(fd, fcntl.F_GETFD)
- if cloexec:
- fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
- else:
- fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag)
-
-
- def _close_fds(self, but):
- os.closerange(3, but)
- os.closerange(but + 1, MAXFD)
+ def _close_fds(self, fds_to_keep):
+ start_fd = 3
+ for fd in sorted(fds_to_keep):
+ if fd >= start_fd:
+ os.closerange(start_fd, fd)
+ start_fd = fd + 1
+ if start_fd <= MAXFD:
+ os.closerange(start_fd, MAXFD)
def _execute_child(self, args, executable, preexec_fn, close_fds,
- cwd, env, universal_newlines,
+ pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
- errread, errwrite):
+ errread, errwrite,
+ restore_signals, start_new_session):
"""Execute program (POSIX version)"""
if isinstance(args, str):
@@ -1051,104 +1138,165 @@ class Popen(object):
if executable is None:
executable = args[0]
- # For transferring possible exec failure from child to parent
- # The first char specifies the exception type: 0 means
- # OSError, 1 means some other error.
- errpipe_read, errpipe_write = os.pipe()
+ # For transferring possible exec failure from child to parent.
+ # Data format: "exception name:hex errno:description"
+ # Pickle is not used; it is complex and involves memory allocation.
+ errpipe_read, errpipe_write = _create_pipe()
try:
try:
- self._set_cloexec_flag(errpipe_write)
-
- gc_was_enabled = gc.isenabled()
- # Disable gc to avoid bug where gc -> file_dealloc ->
- # write to stderr -> hang. http://bugs.python.org/issue1336
- gc.disable()
- try:
- self.pid = os.fork()
- except:
- if gc_was_enabled:
- gc.enable()
- raise
- self._child_created = True
- if self.pid == 0:
- # Child
- try:
- # Close parent's pipe ends
- if p2cwrite is not None:
- os.close(p2cwrite)
- if c2pread is not None:
- os.close(c2pread)
- if errread is not None:
- os.close(errread)
- os.close(errpipe_read)
-
- # Dup fds for child
- def _dup2(a, b):
- # dup2() removes the CLOEXEC flag but
- # we must do it ourselves if dup2()
- # would be a no-op (issue #10806).
- if a == b:
- self._set_cloexec_flag(a, False)
- elif a is not None:
- os.dup2(a, b)
- _dup2(p2cread, 0)
- _dup2(c2pwrite, 1)
- _dup2(errwrite, 2)
-
- # Close pipe fds. Make sure we don't close the
- # same fd more than once, or standard fds.
- closed = { None }
- for fd in [p2cread, c2pwrite, errwrite]:
- if fd not in closed and fd > 2:
- os.close(fd)
- closed.add(fd)
-
- # Close all other fds, if asked for
- if close_fds:
- self._close_fds(but=errpipe_write)
-
- if cwd is not None:
- os.chdir(cwd)
-
- if preexec_fn:
- preexec_fn()
-
- if env is None:
- os.execvp(executable, args)
- else:
- os.execvpe(executable, args, env)
+ if _posixsubprocess:
+ # We must avoid complex work that could involve
+ # malloc or free in the child process to avoid
+ # potential deadlocks, thus we do all this here.
+ # and pass it to fork_exec()
+
+ if env:
+ env_list = [os.fsencode(k) + b'=' + os.fsencode(v)
+ for k, v in env.items()]
+ else:
+ env_list = None # Use execv instead of execve.
+ executable = os.fsencode(executable)
+ if os.path.dirname(executable):
+ executable_list = (executable,)
+ else:
+ # This matches the behavior of os._execvpe().
+ executable_list = tuple(
+ os.path.join(os.fsencode(dir), executable)
+ for dir in os.get_exec_path(env))
+ fds_to_keep = set(pass_fds)
+ fds_to_keep.add(errpipe_write)
+ self.pid = _posixsubprocess.fork_exec(
+ args, executable_list,
+ close_fds, sorted(fds_to_keep), cwd, env_list,
+ p2cread, p2cwrite, c2pread, c2pwrite,
+ errread, errwrite,
+ errpipe_read, errpipe_write,
+ restore_signals, start_new_session, preexec_fn)
+ else:
+ # Pure Python implementation: It is not thread safe.
+ # This implementation may deadlock in the child if your
+ # parent process has any other threads running.
+
+ gc_was_enabled = gc.isenabled()
+ # Disable gc to avoid bug where gc -> file_dealloc ->
+ # write to stderr -> hang. See issue1336
+ gc.disable()
+ try:
+ self.pid = os.fork()
except:
- exc_type, exc_value, tb = sys.exc_info()
- # Save the traceback and attach it to the exception
- # object
- exc_lines = traceback.format_exception(exc_type,
- exc_value,
- tb)
- exc_value.child_traceback = ''.join(exc_lines)
- os.write(errpipe_write, pickle.dumps(exc_value))
-
- # This exitcode won't be reported to applications, so
- # it really doesn't matter what we return.
- os._exit(255)
-
- # Parent
- if gc_was_enabled:
- gc.enable()
+ if gc_was_enabled:
+ gc.enable()
+ raise
+ self._child_created = True
+ if self.pid == 0:
+ # Child
+ try:
+ # Close parent's pipe ends
+ if p2cwrite != -1:
+ os.close(p2cwrite)
+ if c2pread != -1:
+ os.close(c2pread)
+ if errread != -1:
+ os.close(errread)
+ os.close(errpipe_read)
+
+ # Dup fds for child
+ def _dup2(a, b):
+ # dup2() removes the CLOEXEC flag but
+ # we must do it ourselves if dup2()
+ # would be a no-op (issue #10806).
+ if a == b:
+ _set_cloexec(a, False)
+ elif a != -1:
+ os.dup2(a, b)
+ _dup2(p2cread, 0)
+ _dup2(c2pwrite, 1)
+ _dup2(errwrite, 2)
+
+ # Close pipe fds. Make sure we don't close the
+ # same fd more than once, or standard fds.
+ closed = set()
+ for fd in [p2cread, c2pwrite, errwrite]:
+ if fd > 2 and fd not in closed:
+ os.close(fd)
+ closed.add(fd)
+
+ # Close all other fds, if asked for
+ if close_fds:
+ fds_to_keep = set(pass_fds)
+ fds_to_keep.add(errpipe_write)
+ self._close_fds(fds_to_keep)
+
+
+ if cwd is not None:
+ os.chdir(cwd)
+
+ # This is a copy of Python/pythonrun.c
+ # _Py_RestoreSignals(). If that were exposed
+ # as a sys._py_restoresignals func it would be
+ # better.. but this pure python implementation
+ # isn't likely to be used much anymore.
+ if restore_signals:
+ signals = ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ')
+ for sig in signals:
+ if hasattr(signal, sig):
+ signal.signal(getattr(signal, sig),
+ signal.SIG_DFL)
+
+ if start_new_session and hasattr(os, 'setsid'):
+ os.setsid()
+
+ if preexec_fn:
+ preexec_fn()
+
+ if env is None:
+ os.execvp(executable, args)
+ else:
+ os.execvpe(executable, args, env)
+
+ except:
+ try:
+ exc_type, exc_value = sys.exc_info()[:2]
+ if isinstance(exc_value, OSError):
+ errno_num = exc_value.errno
+ else:
+ errno_num = 0
+ message = '%s:%x:%s' % (exc_type.__name__,
+ errno_num, exc_value)
+ message = message.encode(errors="surrogatepass")
+ os.write(errpipe_write, message)
+ except Exception:
+ # We MUST not allow anything odd happening
+ # above to prevent us from exiting below.
+ pass
+
+ # This exitcode won't be reported to applications
+ # so it really doesn't matter what we return.
+ os._exit(255)
+
+ # Parent
+ if gc_was_enabled:
+ gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
- if p2cread is not None and p2cwrite is not None:
+ if p2cread != -1 and p2cwrite != -1:
os.close(p2cread)
- if c2pwrite is not None and c2pread is not None:
+ if c2pwrite != -1 and c2pread != -1:
os.close(c2pwrite)
- if errwrite is not None and errread is not None:
+ if errwrite != -1 and errread != -1:
os.close(errwrite)
# Wait for exec to fail or succeed; possibly raising an
- # exception (limited to 1 MB)
- data = _eintr_retry_call(os.read, errpipe_read, 1048576)
+ # exception (limited in size)
+ data = bytearray()
+ while True:
+ part = _eintr_retry_call(os.read, errpipe_read, 50000)
+ data += part
+ if not part or len(data) > 50000:
+ break
finally:
# be sure the FD is closed no matter what
os.close(errpipe_read)
@@ -1159,11 +1307,28 @@ class Popen(object):
except OSError as e:
if e.errno != errno.ECHILD:
raise
- child_exception = pickle.loads(data)
+ try:
+ exception_name, hex_errno, err_msg = data.split(b':', 2)
+ except ValueError:
+ print('Bad exception data:', repr(data))
+ exception_name = b'RuntimeError'
+ hex_errno = b'0'
+ err_msg = b'Unknown'
+ child_exception_type = getattr(
+ builtins, exception_name.decode('ascii'),
+ RuntimeError)
for fd in (p2cwrite, c2pread, errread):
- if fd is not None:
+ if fd != -1:
os.close(fd)
- raise child_exception
+ err_msg = err_msg.decode(errors="surrogatepass")
+ if issubclass(child_exception_type, OSError) and hex_errno:
+ errno_num = int(hex_errno, 16)
+ if errno_num != 0:
+ err_msg = os.strerror(errno_num)
+ if errno_num == errno.ENOENT:
+ err_msg += ': ' + repr(args[0])
+ raise child_exception_type(errno_num, err_msg)
+ raise child_exception_type(err_msg)
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
diff --git a/Lib/sunau.py b/Lib/sunau.py
index 5f50e8fb9c..6775a53cf7 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -154,6 +154,9 @@ class Au_read:
if type(f) == type(''):
import builtins
f = builtins.open(f, 'rb')
+ self._opened = True
+ else:
+ self._opened = False
self.initfp(f)
def __del__(self):
@@ -275,6 +278,8 @@ class Au_read:
self._soundpos = pos
def close(self):
+ if self._opened and self._file:
+ self._file.close()
self._file = None
class Au_write:
@@ -283,11 +288,15 @@ class Au_write:
if type(f) == type(''):
import builtins
f = builtins.open(f, 'wb')
+ self._opened = True
+ else:
+ self._opened = False
self.initfp(f)
def __del__(self):
if self._file:
self.close()
+ self._file = None
def initfp(self, file):
self._file = file
@@ -401,6 +410,8 @@ class Au_write:
self._datalength != self._datawritten:
self._patchheader()
self._file.flush()
+ if self._opened and self._file:
+ self._file.close()
self._file = None
#
diff --git a/Lib/symbol.py b/Lib/symbol.py
index 4b4c219863..e3fff3422c 100755
--- a/Lib/symbol.py
+++ b/Lib/symbol.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Non-terminal symbols of Python grammar (from "graminit.h")."""
@@ -26,69 +26,69 @@ stmt = 268
simple_stmt = 269
small_stmt = 270
expr_stmt = 271
-augassign = 272
-del_stmt = 273
-pass_stmt = 274
-flow_stmt = 275
-break_stmt = 276
-continue_stmt = 277
-return_stmt = 278
-yield_stmt = 279
-raise_stmt = 280
-import_stmt = 281
-import_name = 282
-import_from = 283
-import_as_name = 284
-dotted_as_name = 285
-import_as_names = 286
-dotted_as_names = 287
-dotted_name = 288
-global_stmt = 289
-nonlocal_stmt = 290
-assert_stmt = 291
-compound_stmt = 292
-if_stmt = 293
-while_stmt = 294
-for_stmt = 295
-try_stmt = 296
-with_stmt = 297
-with_item = 298
-except_clause = 299
-suite = 300
-test = 301
-test_nocond = 302
-lambdef = 303
-lambdef_nocond = 304
-or_test = 305
-and_test = 306
-not_test = 307
-comparison = 308
-comp_op = 309
-star_expr = 310
-expr = 311
-xor_expr = 312
-and_expr = 313
-shift_expr = 314
-arith_expr = 315
-term = 316
-factor = 317
-power = 318
-atom = 319
-testlist_comp = 320
-trailer = 321
-subscriptlist = 322
-subscript = 323
-sliceop = 324
-exprlist = 325
-testlist = 326
-dictorsetmaker = 327
-classdef = 328
-arglist = 329
-argument = 330
-comp_iter = 331
-comp_for = 332
-comp_if = 333
-testlist1 = 334
+testlist_star_expr = 272
+augassign = 273
+del_stmt = 274
+pass_stmt = 275
+flow_stmt = 276
+break_stmt = 277
+continue_stmt = 278
+return_stmt = 279
+yield_stmt = 280
+raise_stmt = 281
+import_stmt = 282
+import_name = 283
+import_from = 284
+import_as_name = 285
+dotted_as_name = 286
+import_as_names = 287
+dotted_as_names = 288
+dotted_name = 289
+global_stmt = 290
+nonlocal_stmt = 291
+assert_stmt = 292
+compound_stmt = 293
+if_stmt = 294
+while_stmt = 295
+for_stmt = 296
+try_stmt = 297
+with_stmt = 298
+with_item = 299
+except_clause = 300
+suite = 301
+test = 302
+test_nocond = 303
+lambdef = 304
+lambdef_nocond = 305
+or_test = 306
+and_test = 307
+not_test = 308
+comparison = 309
+comp_op = 310
+star_expr = 311
+expr = 312
+xor_expr = 313
+and_expr = 314
+shift_expr = 315
+arith_expr = 316
+term = 317
+factor = 318
+power = 319
+atom = 320
+testlist_comp = 321
+trailer = 322
+subscriptlist = 323
+subscript = 324
+sliceop = 325
+exprlist = 326
+testlist = 327
+dictorsetmaker = 328
+classdef = 329
+arglist = 330
+argument = 331
+comp_iter = 332
+comp_for = 333
+comp_if = 334
encoding_decl = 335
yield_expr = 336
#--end constants--
diff --git a/Lib/symtable.py b/Lib/symtable.py
index 7548a7f359..39c1a8014f 100644
--- a/Lib/symtable.py
+++ b/Lib/symtable.py
@@ -2,9 +2,8 @@
import _symtable
from _symtable import (USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM,
- DEF_FREE_GLOBAL, DEF_FREE_CLASS, DEF_IMPORT, DEF_BOUND,
- OPT_IMPORT_STAR, SCOPE_OFF, SCOPE_MASK, FREE,
- GLOBAL_IMPLICIT, GLOBAL_EXPLICIT)
+ DEF_IMPORT, DEF_BOUND, OPT_IMPORT_STAR, SCOPE_OFF, SCOPE_MASK, FREE,
+ LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)
import weakref
@@ -138,7 +137,9 @@ class Function(SymbolTable):
def get_locals(self):
if self.__locals is None:
- self.__locals = self.__idents_matching(lambda x:x & DEF_BOUND)
+ locs = (LOCAL, CELL)
+ test = lambda x: ((x >> SCOPE_OFF) & SCOPE_MASK) in locs
+ self.__locals = self.__idents_matching(test)
return self.__locals
def get_globals(self):
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
new file mode 100644
index 0000000000..685c84ea5e
--- /dev/null
+++ b/Lib/sysconfig.py
@@ -0,0 +1,779 @@
+"""Provide access to Python's configuration information.
+
+"""
+import sys
+import os
+from os.path import pardir, realpath
+
+__all__ = [
+ 'get_config_h_filename',
+ 'get_config_var',
+ 'get_config_vars',
+ 'get_makefile_filename',
+ 'get_path',
+ 'get_path_names',
+ 'get_paths',
+ 'get_platform',
+ 'get_python_version',
+ 'get_scheme_names',
+ 'parse_config_h',
+ ]
+
+_INSTALL_SCHEMES = {
+ 'posix_prefix': {
+ 'stdlib': '{base}/lib/python{py_version_short}',
+ 'platstdlib': '{platbase}/lib/python{py_version_short}',
+ 'purelib': '{base}/lib/python{py_version_short}/site-packages',
+ 'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
+ 'include':
+ '{base}/include/python{py_version_short}{abiflags}',
+ 'platinclude':
+ '{platbase}/include/python{py_version_short}{abiflags}',
+ 'scripts': '{base}/bin',
+ 'data': '{base}',
+ },
+ 'posix_home': {
+ 'stdlib': '{base}/lib/python',
+ 'platstdlib': '{base}/lib/python',
+ 'purelib': '{base}/lib/python',
+ 'platlib': '{base}/lib/python',
+ 'include': '{base}/include/python',
+ 'platinclude': '{base}/include/python',
+ 'scripts': '{base}/bin',
+ 'data' : '{base}',
+ },
+ 'nt': {
+ 'stdlib': '{base}/Lib',
+ 'platstdlib': '{base}/Lib',
+ 'purelib': '{base}/Lib/site-packages',
+ 'platlib': '{base}/Lib/site-packages',
+ 'include': '{base}/Include',
+ 'platinclude': '{base}/Include',
+ 'scripts': '{base}/Scripts',
+ 'data' : '{base}',
+ },
+ 'os2': {
+ 'stdlib': '{base}/Lib',
+ 'platstdlib': '{base}/Lib',
+ 'purelib': '{base}/Lib/site-packages',
+ 'platlib': '{base}/Lib/site-packages',
+ 'include': '{base}/Include',
+ 'platinclude': '{base}/Include',
+ 'scripts': '{base}/Scripts',
+ 'data' : '{base}',
+ },
+ 'os2_home': {
+ 'stdlib': '{userbase}/lib/python{py_version_short}',
+ 'platstdlib': '{userbase}/lib/python{py_version_short}',
+ 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
+ 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
+ 'include': '{userbase}/include/python{py_version_short}',
+ 'scripts': '{userbase}/bin',
+ 'data' : '{userbase}',
+ },
+ 'nt_user': {
+ 'stdlib': '{userbase}/Python{py_version_nodot}',
+ 'platstdlib': '{userbase}/Python{py_version_nodot}',
+ 'purelib': '{userbase}/Python{py_version_nodot}/site-packages',
+ 'platlib': '{userbase}/Python{py_version_nodot}/site-packages',
+ 'include': '{userbase}/Python{py_version_nodot}/Include',
+ 'scripts': '{userbase}/Scripts',
+ 'data' : '{userbase}',
+ },
+ 'posix_user': {
+ 'stdlib': '{userbase}/lib/python{py_version_short}',
+ 'platstdlib': '{userbase}/lib/python{py_version_short}',
+ 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
+ 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
+ 'include': '{userbase}/include/python{py_version_short}',
+ 'scripts': '{userbase}/bin',
+ 'data' : '{userbase}',
+ },
+ 'osx_framework_user': {
+ 'stdlib': '{userbase}/lib/python',
+ 'platstdlib': '{userbase}/lib/python',
+ 'purelib': '{userbase}/lib/python/site-packages',
+ 'platlib': '{userbase}/lib/python/site-packages',
+ 'include': '{userbase}/include',
+ 'scripts': '{userbase}/bin',
+ 'data' : '{userbase}',
+ },
+ }
+
+_SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include',
+ 'scripts', 'data')
+_PY_VERSION = sys.version.split()[0]
+_PY_VERSION_SHORT = sys.version[:3]
+_PY_VERSION_SHORT_NO_DOT = _PY_VERSION[0] + _PY_VERSION[2]
+_PREFIX = os.path.normpath(sys.prefix)
+_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
+_CONFIG_VARS = None
+_USER_BASE = None
+
+def _safe_realpath(path):
+ try:
+ return realpath(path)
+ except OSError:
+ return path
+
+if sys.executable:
+ _PROJECT_BASE = os.path.dirname(_safe_realpath(sys.executable))
+else:
+ # sys.executable can be empty if argv[0] has been changed and Python is
+ # unable to retrieve the real program name
+ _PROJECT_BASE = _safe_realpath(os.getcwd())
+
+if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower():
+ _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir))
+# PC/VS7.1
+if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower():
+ _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
+# PC/AMD64
+if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower():
+ _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
+
+def is_python_build():
+ for fn in ("Setup.dist", "Setup.local"):
+ if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)):
+ return True
+ return False
+
+_PYTHON_BUILD = is_python_build()
+
+if _PYTHON_BUILD:
+ for scheme in ('posix_prefix', 'posix_home'):
+ _INSTALL_SCHEMES[scheme]['include'] = '{srcdir}/Include'
+ _INSTALL_SCHEMES[scheme]['platinclude'] = '{projectbase}/.'
+
+def _subst_vars(s, local_vars):
+ try:
+ return s.format(**local_vars)
+ except KeyError:
+ try:
+ return s.format(**os.environ)
+ except KeyError as var:
+ raise AttributeError('{%s}' % var)
+
+def _extend_dict(target_dict, other_dict):
+ target_keys = target_dict.keys()
+ for key, value in other_dict.items():
+ if key in target_keys:
+ continue
+ target_dict[key] = value
+
+def _expand_vars(scheme, vars):
+ res = {}
+ if vars is None:
+ vars = {}
+ _extend_dict(vars, get_config_vars())
+
+ for key, value in _INSTALL_SCHEMES[scheme].items():
+ if os.name in ('posix', 'nt'):
+ value = os.path.expanduser(value)
+ res[key] = os.path.normpath(_subst_vars(value, vars))
+ return res
+
+def _get_default_scheme():
+ if os.name == 'posix':
+ # the default scheme for posix is posix_prefix
+ return 'posix_prefix'
+ return os.name
+
+def _getuserbase():
+ env_base = os.environ.get("PYTHONUSERBASE", None)
+ def joinuser(*args):
+ return os.path.expanduser(os.path.join(*args))
+
+ # what about 'os2emx', 'riscos' ?
+ if os.name == "nt":
+ base = os.environ.get("APPDATA") or "~"
+ return env_base if env_base else joinuser(base, "Python")
+
+ if sys.platform == "darwin":
+ framework = get_config_var("PYTHONFRAMEWORK")
+ if framework:
+ return env_base if env_base else joinuser("~", "Library", framework, "%d.%d"%(
+ sys.version_info[:2]))
+
+ return env_base if env_base else joinuser("~", ".local")
+
+
+def _parse_makefile(filename, vars=None):
+ """Parse a Makefile-style file.
+
+ A dictionary containing name/value pairs is returned. If an
+ optional dictionary is passed in as the second argument, it is
+ used instead of a new dictionary.
+ """
+ import re
+ # Regexes needed for parsing Makefile (and similar syntaxes,
+ # like old-style Setup files).
+ _variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)")
+ _findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)")
+ _findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}")
+
+ if vars is None:
+ vars = {}
+ done = {}
+ notdone = {}
+
+ with open(filename, errors="surrogateescape") as f:
+ lines = f.readlines()
+
+ for line in lines:
+ if line.startswith('#') or line.strip() == '':
+ continue
+ m = _variable_rx.match(line)
+ if m:
+ n, v = m.group(1, 2)
+ v = v.strip()
+ # `$$' is a literal `$' in make
+ tmpv = v.replace('$$', '')
+
+ if "$" in tmpv:
+ notdone[n] = v
+ else:
+ try:
+ v = int(v)
+ except ValueError:
+ # insert literal `$'
+ done[n] = v.replace('$$', '$')
+ else:
+ done[n] = v
+
+ # do variable interpolation here
+ variables = list(notdone.keys())
+
+ # Variables with a 'PY_' prefix in the makefile. These need to
+ # be made available without that prefix through sysconfig.
+ # Special care is needed to ensure that variable expansion works, even
+ # if the expansion uses the name without a prefix.
+ renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS')
+
+ while len(variables) > 0:
+ for name in tuple(variables):
+ value = notdone[name]
+ m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
+ if m is not None:
+ n = m.group(1)
+ found = True
+ if n in done:
+ item = str(done[n])
+ elif n in notdone:
+ # get it on a subsequent round
+ found = False
+ elif n in os.environ:
+ # do it like make: fall back to environment
+ item = os.environ[n]
+
+ elif n in renamed_variables:
+ if name.startswith('PY_') and name[3:] in renamed_variables:
+ item = ""
+
+ elif 'PY_' + n in notdone:
+ found = False
+
+ else:
+ item = str(done['PY_' + n])
+
+ else:
+ done[n] = item = ""
+
+ if found:
+ after = value[m.end():]
+ value = value[:m.start()] + item + after
+ if "$" in after:
+ notdone[name] = value
+ else:
+ try:
+ value = int(value)
+ except ValueError:
+ done[name] = value.strip()
+ else:
+ done[name] = value
+ variables.remove(name)
+
+ if name.startswith('PY_') \
+ and name[3:] in renamed_variables:
+
+ name = name[3:]
+ if name not in done:
+ done[name] = value
+
+
+ else:
+ # bogus variable reference; just drop it since we can't deal
+ variables.remove(name)
+
+ # strip spurious spaces
+ for k, v in done.items():
+ if isinstance(v, str):
+ done[k] = v.strip()
+
+ # save the results in the global dictionary
+ vars.update(done)
+ return vars
+
+
+def get_makefile_filename():
+ """Return the path of the Makefile."""
+ if _PYTHON_BUILD:
+ return os.path.join(_PROJECT_BASE, "Makefile")
+ return os.path.join(get_path('stdlib'),
+ 'config-{}{}'.format(_PY_VERSION_SHORT, sys.abiflags),
+ 'Makefile')
+
+
+def _init_posix(vars):
+ """Initialize the module as appropriate for POSIX systems."""
+ # load the installed Makefile:
+ makefile = get_makefile_filename()
+ try:
+ _parse_makefile(makefile, vars)
+ except IOError as e:
+ msg = "invalid Python installation: unable to open %s" % makefile
+ if hasattr(e, "strerror"):
+ msg = msg + " (%s)" % e.strerror
+ raise IOError(msg)
+ # load the installed pyconfig.h:
+ config_h = get_config_h_filename()
+ try:
+ with open(config_h) as f:
+ parse_config_h(f, vars)
+ except IOError as e:
+ msg = "invalid Python installation: unable to open %s" % config_h
+ if hasattr(e, "strerror"):
+ msg = msg + " (%s)" % e.strerror
+ raise IOError(msg)
+ # On MacOSX we need to check the setting of the environment variable
+ # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
+ # it needs to be compatible.
+ # If it isn't set we set it to the configure-time value
+ if sys.platform == 'darwin' and 'MACOSX_DEPLOYMENT_TARGET' in vars:
+ cfg_target = vars['MACOSX_DEPLOYMENT_TARGET']
+ cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
+ if cur_target == '':
+ cur_target = cfg_target
+ os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target)
+ elif (list(map(int, cfg_target.split('.'))) >
+ list(map(int, cur_target.split('.')))):
+ msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" '
+ 'during configure' % (cur_target, cfg_target))
+ raise IOError(msg)
+ # On AIX, there are wrong paths to the linker scripts in the Makefile
+ # -- these paths are relative to the Python source, but when installed
+ # the scripts are in another directory.
+ if _PYTHON_BUILD:
+ vars['LDSHARED'] = vars['BLDSHARED']
+
+def _init_non_posix(vars):
+ """Initialize the module as appropriate for NT"""
+ # set basic install directories
+ vars['LIBDEST'] = get_path('stdlib')
+ vars['BINLIBDEST'] = get_path('platstdlib')
+ vars['INCLUDEPY'] = get_path('include')
+ vars['SO'] = '.pyd'
+ vars['EXE'] = '.exe'
+ vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
+ vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
+
+#
+# public APIs
+#
+
+
+def parse_config_h(fp, vars=None):
+ """Parse a config.h-style file.
+
+ A dictionary containing name/value pairs is returned. If an
+ optional dictionary is passed in as the second argument, it is
+ used instead of a new dictionary.
+ """
+ import re
+ if vars is None:
+ vars = {}
+ define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
+ undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
+
+ while True:
+ line = fp.readline()
+ if not line:
+ break
+ m = define_rx.match(line)
+ if m:
+ n, v = m.group(1, 2)
+ try: v = int(v)
+ except ValueError: pass
+ vars[n] = v
+ else:
+ m = undef_rx.match(line)
+ if m:
+ vars[m.group(1)] = 0
+ return vars
+
+def get_config_h_filename():
+ """Return the path of pyconfig.h."""
+ if _PYTHON_BUILD:
+ if os.name == "nt":
+ inc_dir = os.path.join(_PROJECT_BASE, "PC")
+ else:
+ inc_dir = _PROJECT_BASE
+ else:
+ inc_dir = get_path('platinclude')
+ return os.path.join(inc_dir, 'pyconfig.h')
+
+def get_scheme_names():
+ """Return a tuple containing the schemes names."""
+ schemes = list(_INSTALL_SCHEMES.keys())
+ schemes.sort()
+ return tuple(schemes)
+
+def get_path_names():
+ """Return a tuple containing the paths names."""
+ return _SCHEME_KEYS
+
+def get_paths(scheme=_get_default_scheme(), vars=None, expand=True):
+ """Return a mapping containing an install scheme.
+
+ ``scheme`` is the install scheme name. If not provided, it will
+ return the default scheme for the current platform.
+ """
+ if expand:
+ return _expand_vars(scheme, vars)
+ else:
+ return _INSTALL_SCHEMES[scheme]
+
+def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True):
+ """Return a path corresponding to the scheme.
+
+ ``scheme`` is the install scheme name.
+ """
+ return get_paths(scheme, vars, expand)[name]
+
+def get_config_vars(*args):
+ """With no arguments, return a dictionary of all configuration
+ variables relevant for the current platform.
+
+ On Unix, this means every variable defined in Python's installed Makefile;
+ On Windows and Mac OS it's a much smaller set.
+
+ With arguments, return a list of values that result from looking up
+ each argument in the configuration variable dictionary.
+ """
+ import re
+ global _CONFIG_VARS
+ if _CONFIG_VARS is None:
+ _CONFIG_VARS = {}
+ # Normalized versions of prefix and exec_prefix are handy to have;
+ # in fact, these are the standard versions used most places in the
+ # Distutils.
+ _CONFIG_VARS['prefix'] = _PREFIX
+ _CONFIG_VARS['exec_prefix'] = _EXEC_PREFIX
+ _CONFIG_VARS['py_version'] = _PY_VERSION
+ _CONFIG_VARS['py_version_short'] = _PY_VERSION_SHORT
+ _CONFIG_VARS['py_version_nodot'] = _PY_VERSION[0] + _PY_VERSION[2]
+ _CONFIG_VARS['base'] = _PREFIX
+ _CONFIG_VARS['platbase'] = _EXEC_PREFIX
+ _CONFIG_VARS['projectbase'] = _PROJECT_BASE
+ try:
+ _CONFIG_VARS['abiflags'] = sys.abiflags
+ except AttributeError:
+ # sys.abiflags may not be defined on all platforms.
+ _CONFIG_VARS['abiflags'] = ''
+
+ if os.name in ('nt', 'os2'):
+ _init_non_posix(_CONFIG_VARS)
+ if os.name == 'posix':
+ _init_posix(_CONFIG_VARS)
+ # Setting 'userbase' is done below the call to the
+ # init function to enable using 'get_config_var' in
+ # the init-function.
+ _CONFIG_VARS['userbase'] = _getuserbase()
+
+ if 'srcdir' not in _CONFIG_VARS:
+ _CONFIG_VARS['srcdir'] = _PROJECT_BASE
+ else:
+ _CONFIG_VARS['srcdir'] = _safe_realpath(_CONFIG_VARS['srcdir'])
+
+
+ # Convert srcdir into an absolute path if it appears necessary.
+ # Normally it is relative to the build directory. However, during
+ # testing, for example, we might be running a non-installed python
+ # from a different directory.
+ if _PYTHON_BUILD and os.name == "posix":
+ base = _PROJECT_BASE
+ try:
+ cwd = os.getcwd()
+ except OSError:
+ cwd = None
+ if (not os.path.isabs(_CONFIG_VARS['srcdir']) and
+ base != cwd):
+ # srcdir is relative and we are not in the same directory
+ # as the executable. Assume executable is in the build
+ # directory and make srcdir absolute.
+ srcdir = os.path.join(base, _CONFIG_VARS['srcdir'])
+ _CONFIG_VARS['srcdir'] = os.path.normpath(srcdir)
+
+ if sys.platform == 'darwin':
+ kernel_version = os.uname()[2] # Kernel version (8.4.3)
+ major_version = int(kernel_version.split('.')[0])
+
+ if major_version < 8:
+ # On Mac OS X before 10.4, check if -arch and -isysroot
+ # are in CFLAGS or LDFLAGS and remove them if they are.
+ # This is needed when building extensions on a 10.3 system
+ # using a universal build of python.
+ for key in ('LDFLAGS', 'BASECFLAGS',
+ # a number of derived variables. These need to be
+ # patched up as well.
+ 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
+ flags = _CONFIG_VARS[key]
+ flags = re.sub('-arch\s+\w+\s', ' ', flags)
+ flags = re.sub('-isysroot [^ \t]*', ' ', flags)
+ _CONFIG_VARS[key] = flags
+ else:
+ # Allow the user to override the architecture flags using
+ # an environment variable.
+ # NOTE: This name was introduced by Apple in OSX 10.5 and
+ # is used by several scripting languages distributed with
+ # that OS release.
+ if 'ARCHFLAGS' in os.environ:
+ arch = os.environ['ARCHFLAGS']
+ for key in ('LDFLAGS', 'BASECFLAGS',
+ # a number of derived variables. These need to be
+ # patched up as well.
+ 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
+
+ flags = _CONFIG_VARS[key]
+ flags = re.sub('-arch\s+\w+\s', ' ', flags)
+ flags = flags + ' ' + arch
+ _CONFIG_VARS[key] = flags
+
+ # If we're on OSX 10.5 or later and the user tries to
+ # compiles an extension using an SDK that is not present
+ # on the current machine it is better to not use an SDK
+ # than to fail.
+ #
+ # The major usecase for this is users using a Python.org
+ # binary installer on OSX 10.6: that installer uses
+ # the 10.4u SDK, but that SDK is not installed by default
+ # when you install Xcode.
+ #
+ CFLAGS = _CONFIG_VARS.get('CFLAGS', '')
+ m = re.search('-isysroot\s+(\S+)', CFLAGS)
+ if m is not None:
+ sdk = m.group(1)
+ if not os.path.exists(sdk):
+ for key in ('LDFLAGS', 'BASECFLAGS',
+ # a number of derived variables. These need to be
+ # patched up as well.
+ 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
+
+ flags = _CONFIG_VARS[key]
+ flags = re.sub('-isysroot\s+\S+(\s|$)', ' ', flags)
+ _CONFIG_VARS[key] = flags
+
+ if args:
+ vals = []
+ for name in args:
+ vals.append(_CONFIG_VARS.get(name))
+ return vals
+ else:
+ return _CONFIG_VARS
+
+def get_config_var(name):
+ """Return the value of a single variable using the dictionary returned by
+ 'get_config_vars()'.
+
+ Equivalent to get_config_vars().get(name)
+ """
+ return get_config_vars().get(name)
+
+def get_platform():
+ """Return a string that identifies the current platform.
+
+ This is used mainly to distinguish platform-specific build directories and
+ platform-specific built distributions. Typically includes the OS name
+ and version and the architecture (as supplied by 'os.uname()'),
+ although the exact information included depends on the OS; eg. for IRIX
+ the architecture isn't particularly important (IRIX only runs on SGI
+ hardware), but for Linux the kernel version isn't particularly
+ important.
+
+ Examples of returned values:
+ linux-i586
+ linux-alpha (?)
+ solaris-2.6-sun4u
+ irix-5.3
+ irix64-6.2
+
+ Windows will return one of:
+ win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
+ win-ia64 (64bit Windows on Itanium)
+ win32 (all others - specifically, sys.platform is returned)
+
+ For other non-POSIX platforms, currently just returns 'sys.platform'.
+ """
+ import re
+ if os.name == 'nt':
+ # sniff sys.version for architecture.
+ prefix = " bit ("
+ i = sys.version.find(prefix)
+ if i == -1:
+ return sys.platform
+ j = sys.version.find(")", i)
+ look = sys.version[i+len(prefix):j].lower()
+ if look == 'amd64':
+ return 'win-amd64'
+ if look == 'itanium':
+ return 'win-ia64'
+ return sys.platform
+
+ if os.name != "posix" or not hasattr(os, 'uname'):
+ # XXX what about the architecture? NT is Intel or Alpha,
+ # Mac OS is M68k or PPC, etc.
+ return sys.platform
+
+ # Try to distinguish various flavours of Unix
+ osname, host, release, version, machine = os.uname()
+
+ # Convert the OS name to lowercase, remove '/' characters
+ # (to accommodate BSD/OS), and translate spaces (for "Power Macintosh")
+ osname = osname.lower().replace('/', '')
+ machine = machine.replace(' ', '_')
+ machine = machine.replace('/', '-')
+
+ if osname[:5] == "linux":
+ # At least on Linux/Intel, 'machine' is the processor --
+ # i386, etc.
+ # XXX what about Alpha, SPARC, etc?
+ return "%s-%s" % (osname, machine)
+ elif osname[:5] == "sunos":
+ if release[0] >= "5": # SunOS 5 == Solaris 2
+ osname = "solaris"
+ release = "%d.%s" % (int(release[0]) - 3, release[2:])
+ # fall through to standard osname-release-machine representation
+ elif osname[:4] == "irix": # could be "irix64"!
+ return "%s-%s" % (osname, release)
+ elif osname[:3] == "aix":
+ return "%s-%s.%s" % (osname, version, release)
+ elif osname[:6] == "cygwin":
+ osname = "cygwin"
+ rel_re = re.compile (r'[\d.]+')
+ m = rel_re.match(release)
+ if m:
+ release = m.group()
+ elif osname[:6] == "darwin":
+ #
+ # For our purposes, we'll assume that the system version from
+ # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set
+ # to. This makes the compatibility story a bit more sane because the
+ # machine is going to compile and link as if it were
+ # MACOSX_DEPLOYMENT_TARGET.
+ cfgvars = get_config_vars()
+ macver = os.environ.get('MACOSX_DEPLOYMENT_TARGET')
+ if not macver:
+ macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET')
+
+ if 1:
+ # Always calculate the release of the running machine,
+ # needed to determine if we can build fat binaries or not.
+
+ macrelease = macver
+ # Get the system version. Reading this plist is a documented
+ # way to get the system version (see the documentation for
+ # the Gestalt Manager)
+ try:
+ f = open('/System/Library/CoreServices/SystemVersion.plist')
+ except IOError:
+ # We're on a plain darwin box, fall back to the default
+ # behaviour.
+ pass
+ else:
+ try:
+ m = re.search(
+ r'<key>ProductUserVisibleVersion</key>\s*' +
+ r'<string>(.*?)</string>', f.read())
+ f.close()
+ if m is not None:
+ macrelease = '.'.join(m.group(1).split('.')[:2])
+ # else: fall back to the default behaviour
+ finally:
+ f.close()
+
+ if not macver:
+ macver = macrelease
+
+ if macver:
+ release = macver
+ osname = "macosx"
+
+ if (macrelease + '.') >= '10.4.' and \
+ '-arch' in get_config_vars().get('CFLAGS', '').strip():
+ # The universal build will build fat binaries, but not on
+ # systems before 10.4
+ #
+ # Try to detect 4-way universal builds, those have machine-type
+ # 'universal' instead of 'fat'.
+
+ machine = 'fat'
+ cflags = get_config_vars().get('CFLAGS')
+
+ archs = re.findall('-arch\s+(\S+)', cflags)
+ archs = tuple(sorted(set(archs)))
+
+ if len(archs) == 1:
+ machine = archs[0]
+ elif archs == ('i386', 'ppc'):
+ machine = 'fat'
+ elif archs == ('i386', 'x86_64'):
+ machine = 'intel'
+ elif archs == ('i386', 'ppc', 'x86_64'):
+ machine = 'fat3'
+ elif archs == ('ppc64', 'x86_64'):
+ machine = 'fat64'
+ elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'):
+ machine = 'universal'
+ else:
+ raise ValueError(
+ "Don't know machine value for archs=%r"%(archs,))
+
+ elif machine == 'i386':
+ # On OSX the machine type returned by uname is always the
+ # 32-bit variant, even if the executable architecture is
+ # the 64-bit variant
+ if sys.maxsize >= 2**32:
+ machine = 'x86_64'
+
+ elif machine in ('PowerPC', 'Power_Macintosh'):
+ # Pick a sane name for the PPC architecture.
+ # See 'i386' case
+ if sys.maxsize >= 2**32:
+ machine = 'ppc64'
+ else:
+ machine = 'ppc'
+
+ return "%s-%s-%s" % (osname, release, machine)
+
+
+def get_python_version():
+ return _PY_VERSION_SHORT
+
+def _print_dict(title, data):
+ for index, (key, value) in enumerate(sorted(data.items())):
+ if index == 0:
+ print('{0}: '.format(title))
+ print('\t{0} = "{1}"'.format(key, value))
+
+def _main():
+ """Display all information sysconfig detains."""
+ print('Platform: "{0}"'.format(get_platform()))
+ print('Python version: "{0}"'.format(get_python_version()))
+ print('Current installation scheme: "{0}"'.format(_get_default_scheme()))
+ print('')
+ _print_dict('Paths', get_paths())
+ print('')
+ _print_dict('Variables', get_config_vars())
+
+if __name__ == '__main__':
+ _main()
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py
index 3a8cd373be..46f8163e5f 100755
--- a/Lib/tabnanny.py
+++ b/Lib/tabnanny.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""The Tab Nanny despises ambiguous indentation. She knows no mercy.
@@ -93,11 +93,8 @@ def check(file):
check(fullname)
return
- with open(file, 'rb') as f:
- encoding, lines = tokenize.detect_encoding(f.readline)
-
try:
- f = open(file, encoding=encoding)
+ f = tokenize.open(file)
except IOError as msg:
errprint("%r: I/O Error: %s" % (file, msg))
return
@@ -267,7 +264,7 @@ class Whitespace:
return a
def format_witnesses(w):
- firsts = map(lambda tup: str(tup[0]), w)
+ firsts = (str(tup[0]) for tup in w)
prefix = "at tab size"
if len(w) > 1:
prefix = prefix + "s"
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index beb4135724..0f9d1dade1 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#-------------------------------------------------------------------
# tarfile.py
#-------------------------------------------------------------------
@@ -50,18 +50,20 @@ import struct
import copy
import re
-if sys.platform == 'mac':
- # This module needs work for MacOS9, especially in the area of pathname
- # handling. In many places it is assumed a simple substitution of / by the
- # local os.path.sep is good enough to convert pathnames, but this does not
- # work with the mac rooted:path:name versus :nonrooted:path:name syntax
- raise ImportError("tarfile does not work for platform==mac")
-
try:
import grp, pwd
except ImportError:
grp = pwd = None
+# os.symlink on Windows prior to 6.0 raises NotImplementedError
+symlink_exception = (AttributeError, NotImplementedError)
+try:
+ # WindowsError (1314) will be raised if the caller does not hold the
+ # SeCreateSymbolicLinkPrivilege privilege
+ symlink_exception += (WindowsError,)
+except NameError:
+ pass
+
# from tarfile import *
__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]
@@ -125,6 +127,9 @@ GNU_TYPES = (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK,
PAX_FIELDS = ("path", "linkpath", "size", "mtime",
"uid", "gid", "uname", "gname")
+# Fields from a pax header that are affected by hdrcharset.
+PAX_NAME_FIELDS = {"path", "linkpath", "uname", "gname"}
+
# Fields in a pax header that are numbers, all other fields
# are treated as strings.
PAX_NUMBER_FIELDS = {
@@ -163,9 +168,10 @@ TOEXEC = 0o001 # execute/search by other
#---------------------------------------------------------
# initialization
#---------------------------------------------------------
-ENCODING = sys.getfilesystemencoding()
-if ENCODING is None:
- ENCODING = "ascii"
+if os.name in ("nt", "ce"):
+ ENCODING = "utf-8"
+else:
+ ENCODING = sys.getfilesystemencoding()
#---------------------------------------------------------
# Some useful functions
@@ -194,7 +200,7 @@ def nti(s):
try:
n = int(nts(s, "ascii", "strict") or "0", 8)
except ValueError:
- raise HeaderError("invalid header")
+ raise InvalidHeaderError("invalid header")
else:
n = 0
for i in range(len(s) - 1):
@@ -309,11 +315,6 @@ def filemode(mode):
perm.append("-")
return "".join(perm)
-if os.sep != "/":
- normpath = lambda path: os.path.normpath(path).replace(os.sep, "/")
-else:
- normpath = os.path.normpath
-
class TarError(Exception):
"""Base exception."""
pass
@@ -330,8 +331,23 @@ class StreamError(TarError):
"""Exception for unsupported operations on stream-like TarFiles."""
pass
class HeaderError(TarError):
+ """Base exception for header errors."""
+ pass
+class EmptyHeaderError(HeaderError):
+ """Exception for empty headers."""
+ pass
+class TruncatedHeaderError(HeaderError):
+ """Exception for truncated headers."""
+ pass
+class EOFHeaderError(HeaderError):
+ """Exception for end of file headers."""
+ pass
+class InvalidHeaderError(HeaderError):
"""Exception for invalid headers."""
pass
+class SubsequentHeaderError(HeaderError):
+ """Exception for missing and invalid extended headers."""
+ pass
#---------------------------
# internal stream interface
@@ -394,28 +410,34 @@ class _Stream:
self.pos = 0
self.closed = False
- if comptype == "gz":
- try:
- import zlib
- except ImportError:
- raise CompressionError("zlib module is not available")
- self.zlib = zlib
- self.crc = zlib.crc32(b"")
- if mode == "r":
- self._init_read_gz()
- else:
- self._init_write_gz()
+ try:
+ if comptype == "gz":
+ try:
+ import zlib
+ except ImportError:
+ raise CompressionError("zlib module is not available")
+ self.zlib = zlib
+ self.crc = zlib.crc32(b"")
+ if mode == "r":
+ self._init_read_gz()
+ else:
+ self._init_write_gz()
- if comptype == "bz2":
- try:
- import bz2
- except ImportError:
- raise CompressionError("bz2 module is not available")
- if mode == "r":
- self.dbuf = b""
- self.cmp = bz2.BZ2Decompressor()
- else:
- self.cmp = bz2.BZ2Compressor()
+ if comptype == "bz2":
+ try:
+ import bz2
+ except ImportError:
+ raise CompressionError("bz2 module is not available")
+ if mode == "r":
+ self.dbuf = b""
+ self.cmp = bz2.BZ2Decompressor()
+ else:
+ self.cmp = bz2.BZ2Compressor()
+ except:
+ if not self._extfileobj:
+ self.fileobj.close()
+ self.closed = True
+ raise
def __del__(self):
if hasattr(self, "closed") and not self.closed:
@@ -679,13 +701,29 @@ class _FileInFile(object):
object.
"""
- def __init__(self, fileobj, offset, size, sparse=None):
+ def __init__(self, fileobj, offset, size, blockinfo=None):
self.fileobj = fileobj
self.offset = offset
self.size = size
- self.sparse = sparse
self.position = 0
+ if blockinfo is None:
+ blockinfo = [(0, size)]
+
+ # Construct a map with data and zero blocks.
+ self.map_index = 0
+ self.map = []
+ lastpos = 0
+ realpos = self.offset
+ for offset, size in blockinfo:
+ if offset > lastpos:
+ self.map.append((False, lastpos, offset, None))
+ self.map.append((True, offset, offset + size, realpos))
+ realpos += size
+ lastpos = offset + size
+ if lastpos < self.size:
+ self.map.append((False, lastpos, self.size, None))
+
def seekable(self):
if not hasattr(self.fileobj, "seekable"):
# XXX gzip.GzipFile and bz2.BZ2File
@@ -710,48 +748,25 @@ class _FileInFile(object):
else:
size = min(size, self.size - self.position)
- if self.sparse is None:
- return self.readnormal(size)
- else:
- return self.readsparse(size)
-
- def readnormal(self, size):
- """Read operation for regular files.
- """
- self.fileobj.seek(self.offset + self.position)
- self.position += size
- return self.fileobj.read(size)
-
- def readsparse(self, size):
- """Read operation for sparse files.
- """
- data = b""
+ buf = b""
while size > 0:
- buf = self.readsparsesection(size)
- if not buf:
- break
- size -= len(buf)
- data += buf
- return data
-
- def readsparsesection(self, size):
- """Read a single section of a sparse file.
- """
- section = self.sparse.find(self.position)
-
- if section is None:
- return b""
-
- size = min(size, section.offset + section.size - self.position)
-
- if isinstance(section, _data):
- realpos = section.realpos + self.position - section.offset
- self.fileobj.seek(self.offset + realpos)
- self.position += size
- return self.fileobj.read(size)
- else:
- self.position += size
- return NUL * size
+ while True:
+ data, start, stop, offset = self.map[self.map_index]
+ if start <= self.position < stop:
+ break
+ else:
+ self.map_index += 1
+ if self.map_index == len(self.map):
+ self.map_index = 0
+ length = min(size, stop - self.position)
+ if data:
+ self.fileobj.seek(offset + (self.position - start))
+ buf += self.fileobj.read(length)
+ else:
+ buf += NUL * length
+ size -= length
+ self.position += length
+ return buf
#class _FileInFile
@@ -955,7 +970,7 @@ class TarInfo(object):
"""Return the TarInfo's attributes as a dictionary.
"""
info = {
- "name": normpath(self.name),
+ "name": self.name,
"mode": self.mode & 0o7777,
"uid": self.uid,
"gid": self.gid,
@@ -963,7 +978,7 @@ class TarInfo(object):
"mtime": self.mtime,
"chksum": self.chksum,
"type": self.type,
- "linkname": normpath(self.linkname) if self.linkname else "",
+ "linkname": self.linkname,
"uname": self.uname,
"gname": self.gname,
"devmajor": self.devmajor,
@@ -975,7 +990,7 @@ class TarInfo(object):
return info
- def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="strict"):
+ def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"):
"""Return a tar header as a string of 512 byte blocks.
"""
info = self.get_info()
@@ -985,7 +1000,7 @@ class TarInfo(object):
elif format == GNU_FORMAT:
return self.create_gnu_header(info, encoding, errors)
elif format == PAX_FORMAT:
- return self.create_pax_header(info)
+ return self.create_pax_header(info, encoding)
else:
raise ValueError("invalid format")
@@ -1016,7 +1031,7 @@ class TarInfo(object):
return buf + self._create_header(info, GNU_FORMAT, encoding, errors)
- def create_pax_header(self, info):
+ def create_pax_header(self, info, encoding):
"""Return the object as a ustar header block. If it cannot be
represented this way, prepend a pax extended header sequence
with supplement information.
@@ -1059,7 +1074,7 @@ class TarInfo(object):
# Create a pax extended header if necessary.
if pax_headers:
- buf = self._create_pax_generic_header(pax_headers, XHDTYPE)
+ buf = self._create_pax_generic_header(pax_headers, XHDTYPE, encoding)
else:
buf = b""
@@ -1069,7 +1084,7 @@ class TarInfo(object):
def create_pax_global_header(cls, pax_headers):
"""Return the object as a pax global header block sequence.
"""
- return cls._create_pax_generic_header(pax_headers, XGLTYPE)
+ return cls._create_pax_generic_header(pax_headers, XGLTYPE, "utf8")
def _posix_split_name(self, name):
"""Split a name longer than 100 chars into a prefix
@@ -1142,15 +1157,35 @@ class TarInfo(object):
cls._create_payload(name)
@classmethod
- def _create_pax_generic_header(cls, pax_headers, type):
- """Return a POSIX.1-2001 extended or global header sequence
+ def _create_pax_generic_header(cls, pax_headers, type, encoding):
+ """Return a POSIX.1-2008 extended or global header sequence
that contains a list of keyword, value pairs. The values
must be strings.
"""
+ # Check if one of the fields contains surrogate characters and thereby
+ # forces hdrcharset=BINARY, see _proc_pax() for more information.
+ binary = False
+ for keyword, value in pax_headers.items():
+ try:
+ value.encode("utf8", "strict")
+ except UnicodeEncodeError:
+ binary = True
+ break
+
records = b""
+ if binary:
+ # Put the hdrcharset field at the beginning of the header.
+ records += b"21 hdrcharset=BINARY\n"
+
for keyword, value in pax_headers.items():
keyword = keyword.encode("utf8")
- value = value.encode("utf8")
+ if binary:
+ # Try to restore the original byte representation of `value'.
+ # Needless to say, that the encoding must match the string.
+ value = value.encode(encoding, "surrogateescape")
+ else:
+ value = value.encode("utf8")
+
l = len(keyword) + len(value) + 3 # ' ' + '=' + '\n'
n = p = 0
while True:
@@ -1176,14 +1211,16 @@ class TarInfo(object):
def frombuf(cls, buf, encoding, errors):
"""Construct a TarInfo object from a 512 byte bytes object.
"""
+ if len(buf) == 0:
+ raise EmptyHeaderError("empty header")
if len(buf) != BLOCKSIZE:
- raise HeaderError("truncated header")
+ raise TruncatedHeaderError("truncated header")
if buf.count(NUL) == BLOCKSIZE:
- raise HeaderError("empty header")
+ raise EOFHeaderError("end of file header")
chksum = nti(buf[148:156])
if chksum not in calc_chksums(buf):
- raise HeaderError("bad checksum")
+ raise InvalidHeaderError("bad checksum")
obj = cls()
obj.name = nts(buf[0:100], encoding, errors)
@@ -1239,8 +1276,6 @@ class TarInfo(object):
tarfile.
"""
buf = tarfile.fileobj.read(BLOCKSIZE)
- if not buf:
- return
obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
obj.offset = tarfile.fileobj.tell() - BLOCKSIZE
return obj._proc_member(tarfile)
@@ -1293,9 +1328,10 @@ class TarInfo(object):
buf = tarfile.fileobj.read(self._block(self.size))
# Fetch the next header and process it.
- next = self.fromtarfile(tarfile)
- if next is None:
- raise HeaderError("missing subsequent header")
+ try:
+ next = self.fromtarfile(tarfile)
+ except HeaderError:
+ raise SubsequentHeaderError("missing or bad subsequent header")
# Patch the TarInfo object from the next header with
# the longname information.
@@ -1324,33 +1360,20 @@ class TarInfo(object):
numbytes = nti(buf[pos + 12:pos + 24])
except ValueError:
break
- structs.append((offset, numbytes))
+ if offset and numbytes:
+ structs.append((offset, numbytes))
pos += 24
isextended = bool(buf[504])
-
- # Transform the sparse structures to something we can use
- # in ExFileObject.
- self.sparse = _ringbuffer()
- lastpos = 0
- realpos = 0
- for offset, numbytes in structs:
- if offset > lastpos:
- self.sparse.append(_hole(lastpos, offset - lastpos))
- self.sparse.append(_data(offset, numbytes, realpos))
- realpos += numbytes
- lastpos = offset + numbytes
- if lastpos < origsize:
- self.sparse.append(_hole(lastpos, origsize - lastpos))
+ self.sparse = structs
self.offset_data = tarfile.fileobj.tell()
tarfile.offset = self.offset_data + self._block(self.size)
self.size = origsize
-
return self
def _proc_pax(self, tarfile):
"""Process an extended or global header as described in
- POSIX.1-2001.
+ POSIX.1-2008.
"""
# Read the header information.
buf = tarfile.fileobj.read(self._block(self.size))
@@ -1363,6 +1386,24 @@ class TarInfo(object):
else:
pax_headers = tarfile.pax_headers.copy()
+ # Check if the pax header contains a hdrcharset field. This tells us
+ # the encoding of the path, linkpath, uname and gname fields. Normally,
+ # these fields are UTF-8 encoded but since POSIX.1-2008 tar
+ # implementations are allowed to store them as raw binary strings if
+ # the translation to UTF-8 fails.
+ match = re.search(br"\d+ hdrcharset=([^\n]+)\n", buf)
+ if match is not None:
+ pax_headers["hdrcharset"] = match.group(1).decode("utf8")
+
+ # For the time being, we don't care about anything other than "BINARY".
+ # The only other value that is currently allowed by the standard is
+ # "ISO-IR 10646 2000 UTF-8" in other words UTF-8.
+ hdrcharset = pax_headers.get("hdrcharset")
+ if hdrcharset == "BINARY":
+ encoding = tarfile.encoding
+ else:
+ encoding = "utf8"
+
# Parse pax header information. A record looks like that:
# "%d %s=%s\n" % (length, keyword, value). length is the size
# of the complete record including the length field itself and
@@ -1378,19 +1419,45 @@ class TarInfo(object):
length = int(length)
value = buf[match.end(2) + 1:match.start(1) + length - 1]
- keyword = keyword.decode("utf8")
- value = value.decode("utf8")
+ # Normally, we could just use "utf8" as the encoding and "strict"
+ # as the error handler, but we better not take the risk. For
+ # example, GNU tar <= 1.23 is known to store filenames it cannot
+ # translate to UTF-8 as raw strings (unfortunately without a
+ # hdrcharset=BINARY header).
+ # We first try the strict standard encoding, and if that fails we
+ # fall back on the user's encoding and error handler.
+ keyword = self._decode_pax_field(keyword, "utf8", "utf8",
+ tarfile.errors)
+ if keyword in PAX_NAME_FIELDS:
+ value = self._decode_pax_field(value, encoding, tarfile.encoding,
+ tarfile.errors)
+ else:
+ value = self._decode_pax_field(value, "utf8", "utf8",
+ tarfile.errors)
pax_headers[keyword] = value
pos += length
# Fetch the next header.
- next = self.fromtarfile(tarfile)
+ try:
+ next = self.fromtarfile(tarfile)
+ except HeaderError:
+ raise SubsequentHeaderError("missing or bad subsequent header")
- if self.type in (XHDTYPE, SOLARIS_XHDTYPE):
- if next is None:
- raise HeaderError("missing subsequent header")
+ # Process GNU sparse information.
+ if "GNU.sparse.map" in pax_headers:
+ # GNU extended sparse format version 0.1.
+ self._proc_gnusparse_01(next, pax_headers)
+ elif "GNU.sparse.size" in pax_headers:
+ # GNU extended sparse format version 0.0.
+ self._proc_gnusparse_00(next, pax_headers, buf)
+
+ elif pax_headers.get("GNU.sparse.major") == "1" and pax_headers.get("GNU.sparse.minor") == "0":
+ # GNU extended sparse format version 1.0.
+ self._proc_gnusparse_10(next, pax_headers, tarfile)
+
+ if self.type in (XHDTYPE, SOLARIS_XHDTYPE):
# Patch the TarInfo object with the extended header info.
next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
next.offset = self.offset
@@ -1406,27 +1473,70 @@ class TarInfo(object):
return next
+ def _proc_gnusparse_00(self, next, pax_headers, buf):
+ """Process a GNU tar extended sparse header, version 0.0.
+ """
+ offsets = []
+ for match in re.finditer(br"\d+ GNU.sparse.offset=(\d+)\n", buf):
+ offsets.append(int(match.group(1)))
+ numbytes = []
+ for match in re.finditer(br"\d+ GNU.sparse.numbytes=(\d+)\n", buf):
+ numbytes.append(int(match.group(1)))
+ next.sparse = list(zip(offsets, numbytes))
+
+ def _proc_gnusparse_01(self, next, pax_headers):
+ """Process a GNU tar extended sparse header, version 0.1.
+ """
+ sparse = [int(x) for x in pax_headers["GNU.sparse.map"].split(",")]
+ next.sparse = list(zip(sparse[::2], sparse[1::2]))
+
+ def _proc_gnusparse_10(self, next, pax_headers, tarfile):
+ """Process a GNU tar extended sparse header, version 1.0.
+ """
+ fields = None
+ sparse = []
+ buf = tarfile.fileobj.read(BLOCKSIZE)
+ fields, buf = buf.split(b"\n", 1)
+ fields = int(fields)
+ while len(sparse) < fields * 2:
+ if b"\n" not in buf:
+ buf += tarfile.fileobj.read(BLOCKSIZE)
+ number, buf = buf.split(b"\n", 1)
+ sparse.append(int(number))
+ next.offset_data = tarfile.fileobj.tell()
+ next.sparse = list(zip(sparse[::2], sparse[1::2]))
+
def _apply_pax_info(self, pax_headers, encoding, errors):
"""Replace fields with supplemental information from a previous
pax extended or global header.
"""
for keyword, value in pax_headers.items():
- if keyword not in PAX_FIELDS:
- continue
-
- if keyword == "path":
- value = value.rstrip("/")
-
- if keyword in PAX_NUMBER_FIELDS:
- try:
- value = PAX_NUMBER_FIELDS[keyword](value)
- except ValueError:
- value = 0
-
- setattr(self, keyword, value)
+ if keyword == "GNU.sparse.name":
+ setattr(self, "path", value)
+ elif keyword == "GNU.sparse.size":
+ setattr(self, "size", int(value))
+ elif keyword == "GNU.sparse.realsize":
+ setattr(self, "size", int(value))
+ elif keyword in PAX_FIELDS:
+ if keyword in PAX_NUMBER_FIELDS:
+ try:
+ value = PAX_NUMBER_FIELDS[keyword](value)
+ except ValueError:
+ value = 0
+ if keyword == "path":
+ value = value.rstrip("/")
+ setattr(self, keyword, value)
self.pax_headers = pax_headers.copy()
+ def _decode_pax_field(self, value, encoding, fallback_encoding, fallback_errors):
+ """Decode a single field from a pax record.
+ """
+ try:
+ return value.decode(encoding, "strict")
+ except UnicodeDecodeError:
+ return value.decode(fallback_encoding, fallback_errors)
+
def _block(self, count):
"""Round up a byte count by BLOCKSIZE and return it,
e.g. _block(834) => 1024.
@@ -1453,7 +1563,7 @@ class TarInfo(object):
def isfifo(self):
return self.type == FIFOTYPE
def issparse(self):
- return self.type == GNUTYPE_SPARSE
+ return self.sparse is not None
def isdev(self):
return self.type in (CHRTYPE, BLKTYPE, FIFOTYPE)
# class TarInfo
@@ -1470,7 +1580,7 @@ class TarFile(object):
ignore_zeros = False # If true, skips empty or invalid blocks and
# continues processing.
- errorlevel = 0 # If 0, fatal errors only appear in debug
+ errorlevel = 1 # If 0, fatal errors only appear in debug
# messages (if debug >= 0). If > 0, errors
# are passed to the caller as exceptions.
@@ -1486,7 +1596,7 @@ class TarFile(object):
def __init__(self, name=None, mode="r", fileobj=None, format=None,
tarinfo=None, dereference=None, ignore_zeros=None, encoding=None,
- errors=None, pax_headers=None, debug=None, errorlevel=None):
+ errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None):
"""Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
read from an existing archive, 'a' to append data to an existing
file or 'w' to create a new file overwriting an existing one. `mode'
@@ -1527,13 +1637,7 @@ class TarFile(object):
self.ignore_zeros = ignore_zeros
if encoding is not None:
self.encoding = encoding
-
- if errors is not None:
- self.errors = errors
- elif mode == "r":
- self.errors = "replace"
- else:
- self.errors = "strict"
+ self.errors = errors
if pax_headers is not None and self.format == PAX_FORMAT:
self.pax_headers = pax_headers
@@ -1562,12 +1666,16 @@ class TarFile(object):
if self.mode == "a":
# Move to the end of the archive,
# before the first empty block.
- self.firstmember = None
while True:
- if self.next() is None:
- if self.offset > 0:
- self.fileobj.seek(self.fileobj.tell() - BLOCKSIZE)
+ self.fileobj.seek(self.offset)
+ try:
+ tarinfo = self.tarinfo.fromtarfile(self)
+ self.members.append(tarinfo)
+ except EOFHeaderError:
+ self.fileobj.seek(self.offset)
break
+ except HeaderError as e:
+ raise ReadError(str(e))
if self.mode in "aw":
self._loaded = True
@@ -1655,9 +1763,12 @@ class TarFile(object):
if filemode not in "rw":
raise ValueError("mode must be 'r' or 'w'")
- t = cls(name, filemode,
- _Stream(name, filemode, comptype, fileobj, bufsize),
- **kwargs)
+ stream = _Stream(name, filemode, comptype, fileobj, bufsize)
+ try:
+ t = cls(name, filemode, stream, **kwargs)
+ except:
+ stream.close()
+ raise
t._extfileobj = False
return t
@@ -1688,16 +1799,19 @@ class TarFile(object):
except (ImportError, AttributeError):
raise CompressionError("gzip module is not available")
- if fileobj is None:
- fileobj = bltn_open(name, mode + "b")
-
+ extfileobj = fileobj is not None
try:
- t = cls.taropen(name, mode,
- gzip.GzipFile(name, mode, compresslevel, fileobj),
- **kwargs)
+ fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
+ t = cls.taropen(name, mode, fileobj, **kwargs)
except IOError:
+ if not extfileobj:
+ fileobj.close()
raise ReadError("not a gzip file")
- t._extfileobj = False
+ except:
+ if not extfileobj:
+ fileobj.close()
+ raise
+ t._extfileobj = extfileobj
return t
@classmethod
@@ -1720,7 +1834,8 @@ class TarFile(object):
try:
t = cls.taropen(name, mode, fileobj, **kwargs)
- except IOError:
+ except (IOError, EOFError):
+ fileobj.close()
raise ReadError("not a bzip2 file")
t._extfileobj = False
return t
@@ -1801,10 +1916,9 @@ class TarFile(object):
# Absolute paths are turned to relative paths.
if arcname is None:
arcname = name
- arcname = normpath(arcname)
drv, arcname = os.path.splitdrive(arcname)
- while arcname[0:1] == "/":
- arcname = arcname[1:]
+ arcname = arcname.replace(os.sep, "/")
+ arcname = arcname.lstrip("/")
# Now, fill the TarInfo object with
# information specific for the file.
@@ -1910,13 +2024,16 @@ class TarFile(object):
print("link to", tarinfo.linkname, end=' ')
print()
- def add(self, name, arcname=None, recursive=True, exclude=None):
+ def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None):
"""Add the file `name' to the archive. `name' may be any type of file
(directory, fifo, symbolic link, etc.). If given, `arcname'
specifies an alternative name for the file in the archive.
Directories are added recursively by default. This can be avoided by
setting `recursive' to False. `exclude' is a function that should
- return True for each filename to be excluded.
+ return True for each filename to be excluded. `filter' is a function
+ that expects a TarInfo object argument and returns the changed
+ TarInfo object, if it returns None the TarInfo object will be
+ excluded from the archive.
"""
self._check("aw")
@@ -1924,25 +2041,19 @@ class TarFile(object):
arcname = name
# Exclude pathnames.
- if exclude is not None and exclude(name):
- self._dbg(2, "tarfile: Excluded %r" % name)
- return
+ if exclude is not None:
+ import warnings
+ warnings.warn("use the filter argument instead",
+ DeprecationWarning, 2)
+ if exclude(name):
+ self._dbg(2, "tarfile: Excluded %r" % name)
+ return
# Skip if somebody tries to archive the archive...
if self.name is not None and os.path.abspath(name) == self.name:
self._dbg(2, "tarfile: Skipped %r" % name)
return
- # Special case: The user wants to add the current
- # working directory.
- if name == ".":
- if recursive:
- if arcname == ".":
- arcname = ""
- for f in os.listdir(name):
- self.add(f, os.path.join(arcname, f), recursive, exclude)
- return
-
self._dbg(1, name)
# Create a TarInfo object from the file.
@@ -1952,6 +2063,13 @@ class TarFile(object):
self._dbg(1, "tarfile: Unsupported type %r" % name)
return
+ # Change or exclude the TarInfo object.
+ if filter is not None:
+ tarinfo = filter(tarinfo)
+ if tarinfo is None:
+ self._dbg(2, "tarfile: Excluded %r" % name)
+ return
+
# Append the tar header and data to the archive.
if tarinfo.isreg():
f = bltn_open(name, "rb")
@@ -1962,7 +2080,8 @@ class TarFile(object):
self.addfile(tarinfo)
if recursive:
for f in os.listdir(name):
- self.add(os.path.join(name, f), os.path.join(arcname, f), recursive, exclude)
+ self.add(os.path.join(name, f), os.path.join(arcname, f),
+ recursive, exclude, filter=filter)
else:
self.addfile(tarinfo)
@@ -2011,7 +2130,8 @@ class TarFile(object):
directories.append(tarinfo)
tarinfo = copy.copy(tarinfo)
tarinfo.mode = 0o700
- self.extract(tarinfo, path)
+ # Do not set_attrs directories, as we will do that further down
+ self.extract(tarinfo, path, set_attrs=not tarinfo.isdir())
# Reverse sort directories.
directories.sort(key=lambda a: a.name)
@@ -2030,11 +2150,12 @@ class TarFile(object):
else:
self._dbg(1, "tarfile: %s" % e)
- def extract(self, member, path=""):
+ def extract(self, member, path="", set_attrs=True):
"""Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a TarInfo object. You can
- specify a different directory using `path'.
+ specify a different directory using `path'. File attributes (owner,
+ mtime, mode) are set unless `set_attrs' is False.
"""
self._check("r")
@@ -2048,7 +2169,8 @@ class TarFile(object):
tarinfo._link_target = os.path.join(path, tarinfo.linkname)
try:
- self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
+ self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
+ set_attrs=set_attrs)
except EnvironmentError as e:
if self.errorlevel > 0:
raise
@@ -2095,23 +2217,21 @@ class TarFile(object):
raise StreamError("cannot extract (sym)link as file object")
else:
# A (sym)link's file object is its target's file object.
- return self.extractfile(self._getmember(tarinfo.linkname,
- tarinfo))
+ return self.extractfile(self._find_link_target(tarinfo))
else:
# If there's no data associated with the member (directory, chrdev,
# blkdev, etc.), return None instead of a file object.
return None
- def _extract_member(self, tarinfo, targetpath):
+ def _extract_member(self, tarinfo, targetpath, set_attrs=True):
"""Extract the TarInfo object tarinfo to a physical
file called targetpath.
"""
# Fetch the TarInfo object for the given name
# and build the destination pathname, replacing
# forward slashes to platform specific separators.
- if targetpath[-1:] == "/":
- targetpath = targetpath[:-1]
- targetpath = os.path.normpath(targetpath)
+ targetpath = targetpath.rstrip("/")
+ targetpath = targetpath.replace("/", os.sep)
# Create all upper directories.
upperdirs = os.path.dirname(targetpath)
@@ -2140,10 +2260,11 @@ class TarFile(object):
else:
self.makefile(tarinfo, targetpath)
- self.chown(tarinfo, targetpath)
- if not tarinfo.issym():
- self.chmod(tarinfo, targetpath)
- self.utime(tarinfo, targetpath)
+ if set_attrs:
+ self.chown(tarinfo, targetpath)
+ if not tarinfo.issym():
+ self.chmod(tarinfo, targetpath)
+ self.utime(tarinfo, targetpath)
#--------------------------------------------------------------------------
# Below are the different file methods. They are called via
@@ -2164,10 +2285,17 @@ class TarFile(object):
def makefile(self, tarinfo, targetpath):
"""Make a file called targetpath.
"""
- source = self.extractfile(tarinfo)
+ source = self.fileobj
+ source.seek(tarinfo.offset_data)
target = bltn_open(targetpath, "wb")
- copyfileobj(source, target)
- source.close()
+ if tarinfo.sparse is not None:
+ for offset, size in tarinfo.sparse:
+ target.seek(offset)
+ copyfileobj(source, target, size)
+ else:
+ copyfileobj(source, target, tarinfo.size)
+ target.seek(tarinfo.size)
+ target.truncate()
target.close()
def makeunknown(self, tarinfo, targetpath):
@@ -2206,27 +2334,29 @@ class TarFile(object):
(platform limitation), we try to make a copy of the referenced file
instead of a link.
"""
- linkpath = tarinfo.linkname
try:
+ # For systems that support symbolic and hard links.
if tarinfo.issym():
- os.symlink(linkpath, targetpath)
+ os.symlink(tarinfo.linkname, targetpath)
else:
# See extract().
- os.link(tarinfo._link_target, targetpath)
- except AttributeError:
+ if os.path.exists(tarinfo._link_target):
+ os.link(tarinfo._link_target, targetpath)
+ else:
+ self._extract_member(self._find_link_target(tarinfo),
+ targetpath)
+ except symlink_exception:
if tarinfo.issym():
linkpath = os.path.join(os.path.dirname(tarinfo.name),
- linkpath)
- linkpath = normpath(linkpath)
-
+ tarinfo.linkname)
+ else:
+ linkpath = tarinfo.linkname
+ else:
try:
- self._extract_member(self.getmember(linkpath), targetpath)
- except (EnvironmentError, KeyError) as e:
- linkpath = os.path.normpath(linkpath)
- try:
- shutil.copy2(linkpath, targetpath)
- except EnvironmentError as e:
- raise IOError("link could not be created")
+ self._extract_member(self._find_link_target(tarinfo),
+ targetpath)
+ except KeyError:
+ raise ExtractError("unable to resolve link inside archive")
def chown(self, tarinfo, targetpath):
"""Set owner of targetpath according to tarinfo.
@@ -2289,44 +2419,64 @@ class TarFile(object):
# Read the next block.
self.fileobj.seek(self.offset)
+ tarinfo = None
while True:
try:
tarinfo = self.tarinfo.fromtarfile(self)
- if tarinfo is None:
- return
- self.members.append(tarinfo)
-
- except HeaderError as e:
+ except EOFHeaderError as e:
if self.ignore_zeros:
self._dbg(2, "0x%X: %s" % (self.offset, e))
self.offset += BLOCKSIZE
continue
- else:
- if self.offset == 0:
- raise ReadError(str(e))
- return None
+ except InvalidHeaderError as e:
+ if self.ignore_zeros:
+ self._dbg(2, "0x%X: %s" % (self.offset, e))
+ self.offset += BLOCKSIZE
+ continue
+ elif self.offset == 0:
+ raise ReadError(str(e))
+ except EmptyHeaderError:
+ if self.offset == 0:
+ raise ReadError("empty file")
+ except TruncatedHeaderError as e:
+ if self.offset == 0:
+ raise ReadError(str(e))
+ except SubsequentHeaderError as e:
+ raise ReadError(str(e))
break
+ if tarinfo is not None:
+ self.members.append(tarinfo)
+ else:
+ self._loaded = True
+
return tarinfo
#--------------------------------------------------------------------------
# Little helper methods:
- def _getmember(self, name, tarinfo=None):
+ def _getmember(self, name, tarinfo=None, normalize=False):
"""Find an archive member by name from bottom to top.
If tarinfo is given, it is used as the starting point.
"""
# Ensure that all members have been loaded.
members = self.getmembers()
- if tarinfo is None:
- end = len(members)
- else:
- end = members.index(tarinfo)
+ # Limit the member search list up to tarinfo.
+ if tarinfo is not None:
+ members = members[:members.index(tarinfo)]
- for i in range(end - 1, -1, -1):
- if name == members[i].name:
- return members[i]
+ if normalize:
+ name = os.path.normpath(name)
+
+ for member in reversed(members):
+ if normalize:
+ member_name = os.path.normpath(member.name)
+ else:
+ member_name = member.name
+
+ if name == member_name:
+ return member
def _load(self):
"""Read through the entire archive file and look for readable
@@ -2347,6 +2497,25 @@ class TarFile(object):
if mode is not None and self.mode not in mode:
raise IOError("bad operation for mode %r" % self.mode)
+ def _find_link_target(self, tarinfo):
+ """Find the target member of a symlink or hardlink member in the
+ archive.
+ """
+ if tarinfo.issym():
+ # Always search the entire archive.
+ linkname = os.path.dirname(tarinfo.name) + "/" + tarinfo.linkname
+ limit = None
+ else:
+ # Search the archive before the link, because a hard link is
+ # just a reference to an already archived file.
+ linkname = tarinfo.linkname
+ limit = tarinfo
+
+ member = self._getmember(linkname, tarinfo=limit, normalize=True)
+ if member is None:
+ raise KeyError("linkname %r not found" % linkname)
+ return member
+
def __iter__(self):
"""Provide an iterator object.
"""
@@ -2360,6 +2529,20 @@ class TarFile(object):
"""
if level <= self.debug:
print(msg, file=sys.stderr)
+
+ def __enter__(self):
+ self._check()
+ return self
+
+ def __exit__(self, type, value, traceback):
+ if type is None:
+ self.close()
+ else:
+ # An exception occurred. We must not call close() because
+ # it would try to write end-of-archive blocks and padding.
+ if not self._extfileobj:
+ self.fileobj.close()
+ self.closed = True
# class TarFile
class TarIter:
@@ -2398,49 +2581,6 @@ class TarIter:
self.index += 1
return tarinfo
-# Helper classes for sparse file support
-class _section:
- """Base class for _data and _hole.
- """
- def __init__(self, offset, size):
- self.offset = offset
- self.size = size
- def __contains__(self, offset):
- return self.offset <= offset < self.offset + self.size
-
-class _data(_section):
- """Represent a data section in a sparse file.
- """
- def __init__(self, offset, size, realpos):
- _section.__init__(self, offset, size)
- self.realpos = realpos
-
-class _hole(_section):
- """Represent a hole section in a sparse file.
- """
- pass
-
-class _ringbuffer(list):
- """Ringbuffer class which increases performance
- over a regular list.
- """
- def __init__(self):
- self.idx = 0
- def find(self, offset):
- idx = self.idx
- while True:
- item = self[idx]
- if offset in item:
- break
- idx += 1
- if idx == len(self):
- idx = 0
- if idx == self.idx:
- # End of File
- return None
- self.idx = idx
- return item
-
#--------------------
# exported functions
#--------------------
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 049cdaa2c2..b28d91f87e 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -19,7 +19,7 @@ This module also provides some data items to the user:
__all__ = [
"NamedTemporaryFile", "TemporaryFile", # high level safe interfaces
- "SpooledTemporaryFile",
+ "SpooledTemporaryFile", "TemporaryDirectory",
"mkstemp", "mkdtemp", # low level safe interfaces
"mktemp", # deprecated unsafe interface
"TMP_MAX", "gettempprefix", # constants
@@ -29,6 +29,8 @@ __all__ = [
# Imports.
+import warnings as _warnings
+import sys as _sys
import io as _io
import os as _os
import errno as _errno
@@ -108,30 +110,19 @@ class _RandomNameSequence:
_RandomNameSequence is an iterator."""
- characters = ("abcdefghijklmnopqrstuvwxyz" +
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
- "0123456789_")
+ characters = "abcdefghijklmnopqrstuvwxyz0123456789_"
def __init__(self):
- self.mutex = _allocate_lock()
self.rng = _Random()
- self.normcase = _os.path.normcase
def __iter__(self):
return self
def __next__(self):
- m = self.mutex
c = self.characters
choose = self.rng.choice
-
- m.acquire()
- try:
- letters = [choose(c) for dummy in "123456"]
- finally:
- m.release()
-
- return self.normcase(''.join(letters))
+ letters = [choose(c) for dummy in "123456"]
+ return ''.join(letters)
def _candidate_tempdir_list():
"""Generate a list of candidate temporary directories which
@@ -613,3 +604,85 @@ class SpooledTemporaryFile:
def xreadlines(self, *args):
return self._file.xreadlines(*args)
+
+
+class TemporaryDirectory(object):
+ """Create and return a temporary directory. This has the same
+ behavior as mkdtemp but can be used as a context manager. For
+ example:
+
+ with TemporaryDirectory() as tmpdir:
+ ...
+
+ Upon exiting the context, the directory and everthing contained
+ in it are removed.
+ """
+
+ def __init__(self, suffix="", prefix=template, dir=None):
+ self._closed = False
+ self.name = None # Handle mkdtemp throwing an exception
+ self.name = mkdtemp(suffix, prefix, dir)
+
+ def __repr__(self):
+ return "<{} {!r}>".format(self.__class__.__name__, self.name)
+
+ def __enter__(self):
+ return self.name
+
+ def cleanup(self, _warn=False):
+ if self.name and not self._closed:
+ try:
+ self._rmtree(self.name)
+ except (TypeError, AttributeError) as ex:
+ # Issue #10188: Emit a warning on stderr
+ # if the directory could not be cleaned
+ # up due to missing globals
+ if "None" not in str(ex):
+ raise
+ print("ERROR: {!r} while cleaning up {!r}".format(ex, self,),
+ file=_sys.stderr)
+ return
+ self._closed = True
+ if _warn:
+ self._warn("Implicitly cleaning up {!r}".format(self),
+ ResourceWarning)
+
+ def __exit__(self, exc, value, tb):
+ self.cleanup()
+
+ def __del__(self):
+ # Issue a ResourceWarning if implicit cleanup needed
+ self.cleanup(_warn=True)
+
+ # XXX (ncoghlan): The following code attempts to make
+ # this class tolerant of the module nulling out process
+ # that happens during CPython interpreter shutdown
+ # Alas, it doesn't actually manage it. See issue #10188
+ _listdir = staticmethod(_os.listdir)
+ _path_join = staticmethod(_os.path.join)
+ _isdir = staticmethod(_os.path.isdir)
+ _remove = staticmethod(_os.remove)
+ _rmdir = staticmethod(_os.rmdir)
+ _os_error = _os.error
+ _warn = _warnings.warn
+
+ def _rmtree(self, path):
+ # Essentially a stripped down version of shutil.rmtree. We can't
+ # use globals because they may be None'ed out at shutdown.
+ for name in self._listdir(path):
+ fullname = self._path_join(path, name)
+ try:
+ isdir = self._isdir(fullname)
+ except self._os_error:
+ isdir = False
+ if isdir:
+ self._rmtree(fullname)
+ else:
+ try:
+ self._remove(fullname)
+ except self._os_error:
+ pass
+ try:
+ self._rmdir(path)
+ except self._os_error:
+ pass
diff --git a/Lib/test/__main__.py b/Lib/test/__main__.py
new file mode 100644
index 0000000000..ce5615b889
--- /dev/null
+++ b/Lib/test/__main__.py
@@ -0,0 +1,13 @@
+from test import regrtest, support
+
+
+TEMPDIR, TESTCWD = regrtest._make_temp_dir_for_build(regrtest.TEMPDIR)
+regrtest.TEMPDIR = TEMPDIR
+regrtest.TESTCWD = TESTCWD
+
+# Run the tests in a context manager that temporary changes the CWD to a
+# temporary and writable directory. If it's not possible to create or
+# change the CWD, the original CWD will be used. The original CWD is
+# available from support.SAVEDCWD.
+with support.temp_cwd(TESTCWD, quiet=True):
+ regrtest.main()
diff --git a/Lib/test/badsyntax_nocaret.py b/Lib/test/badsyntax_nocaret.py
deleted file mode 100644
index 01ec9ea5f0..0000000000
--- a/Lib/test/badsyntax_nocaret.py
+++ /dev/null
@@ -1,2 +0,0 @@
-def f(x):
- [x for x in x] = x
diff --git a/Lib/test/capath/4e1295a3.0 b/Lib/test/capath/4e1295a3.0
new file mode 100644
index 0000000000..9d7ac238d8
--- /dev/null
+++ b/Lib/test/capath/4e1295a3.0
@@ -0,0 +1,14 @@
+-----BEGIN CERTIFICATE-----
+MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD
+VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv
+bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy
+dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X
+DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw
+EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l
+dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT
+EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp
+MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw
+L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN
+BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX
+9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4=
+-----END CERTIFICATE-----
diff --git a/Lib/test/capath/5ed36f99.0 b/Lib/test/capath/5ed36f99.0
new file mode 100644
index 0000000000..e7dfc82947
--- /dev/null
+++ b/Lib/test/capath/5ed36f99.0
@@ -0,0 +1,41 @@
+-----BEGIN CERTIFICATE-----
+MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290
+IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB
+IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA
+Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO
+BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi
+MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ
+ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC
+CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ
+8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6
+zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y
+fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7
+w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc
+G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k
+epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q
+laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ
+QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU
+fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826
+YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w
+ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY
+gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe
+MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0
+IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy
+dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw
+czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0
+dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl
+aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC
+AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg
+b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB
+ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc
+nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg
+18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c
+gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl
+Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY
+sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T
+SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF
+CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum
+GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk
+zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW
+omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD
+-----END CERTIFICATE-----
diff --git a/Lib/test/capath/6e88d7b8.0 b/Lib/test/capath/6e88d7b8.0
new file mode 100644
index 0000000000..9d7ac238d8
--- /dev/null
+++ b/Lib/test/capath/6e88d7b8.0
@@ -0,0 +1,14 @@
+-----BEGIN CERTIFICATE-----
+MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD
+VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv
+bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy
+dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X
+DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw
+EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l
+dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT
+EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp
+MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw
+L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN
+BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX
+9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4=
+-----END CERTIFICATE-----
diff --git a/Lib/test/capath/99d0fa06.0 b/Lib/test/capath/99d0fa06.0
new file mode 100644
index 0000000000..e7dfc82947
--- /dev/null
+++ b/Lib/test/capath/99d0fa06.0
@@ -0,0 +1,41 @@
+-----BEGIN CERTIFICATE-----
+MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290
+IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB
+IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA
+Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO
+BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi
+MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ
+ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC
+CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ
+8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6
+zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y
+fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7
+w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc
+G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k
+epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q
+laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ
+QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU
+fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826
+YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w
+ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY
+gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe
+MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0
+IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy
+dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw
+czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0
+dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl
+aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC
+AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg
+b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB
+ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc
+nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg
+18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c
+gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl
+Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY
+sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T
+SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF
+CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum
+GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk
+zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW
+omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD
+-----END CERTIFICATE-----
diff --git a/Lib/test/cfgparser.2 b/Lib/test/cfgparser.2
new file mode 100644
index 0000000000..19a420a9a5
--- /dev/null
+++ b/Lib/test/cfgparser.2
@@ -0,0 +1,537 @@
+# This is the main Samba configuration file. You should read the
+# smb.conf(5) manual page in order to understand the options listed
+# here. Samba has a huge number of configurable options (perhaps too
+# many!) most of which are not shown in this example
+#
+# Any line which starts with a ; (semi-colon) or a # (hash)
+# is a comment and is ignored. In this example we will use a #
+# for commentry and a ; for parts of the config file that you
+# may wish to enable
+#
+# NOTE: Whenever you modify this file you should run the command #"testparm" # to check that you have not made any basic syntactic #errors.
+#
+#======================= Global Settings =====================================
+[global]
+
+# 1. Server Naming Options:
+# workgroup = NT-Domain-Name or Workgroup-Name
+
+ workgroup = MDKGROUP
+
+# netbios name is the name you will see in "Network Neighbourhood",
+# but defaults to your hostname
+
+; netbios name = <name_of_this_server>
+
+# server string is the equivalent of the NT Description field
+
+ server string = Samba Server %v
+
+# Message command is run by samba when a "popup" message is sent to it.
+# The example below is for use with LinPopUp:
+; message command = /usr/bin/linpopup "%f" "%m" %s; rm %s
+
+# 2. Printing Options:
+# CHANGES TO ENABLE PRINTING ON ALL CUPS PRINTERS IN THE NETWORK
+# (as cups is now used in linux-mandrake 7.2 by default)
+# if you want to automatically load your printer list rather
+# than setting them up individually then you'll need this
+
+ printcap name = lpstat
+ load printers = yes
+
+# It should not be necessary to spell out the print system type unless
+# yours is non-standard. Currently supported print systems include:
+# bsd, sysv, plp, lprng, aix, hpux, qnx, cups
+
+ printing = cups
+
+# Samba 2.2 supports the Windows NT-style point-and-print feature. To
+# use this, you need to be able to upload print drivers to the samba
+# server. The printer admins (or root) may install drivers onto samba.
+# Note that this feature uses the print$ share, so you will need to
+# enable it below.
+# This parameter works like domain admin group:
+# printer admin = @<group> <user>
+; printer admin = @adm
+# This should work well for winbind:
+; printer admin = @"Domain Admins"
+
+# 3. Logging Options:
+# this tells Samba to use a separate log file for each machine
+# that connects
+
+ log file = /var/log/samba/log.%m
+
+# Put a capping on the size of the log files (in Kb).
+ max log size = 50
+
+# Set the log (verbosity) level (0 <= log level <= 10)
+; log level = 3
+
+# 4. Security and Domain Membership Options:
+# This option is important for security. It allows you to restrict
+# connections to machines which are on your local network. The
+# following example restricts access to two C class networks and
+# the "loopback" interface. For more examples of the syntax see
+# the smb.conf man page. Do not enable this if (tcp/ip) name resolution #does
+# not work for all the hosts in your network.
+; hosts allow = 192.168.1. 192.168.2. 127.
+
+ hosts allow = 127. //note this is only my private IP address
+
+# Uncomment this if you want a guest account, you must add this to
+# /etc/passwd
+# otherwise the user "nobody" is used
+; guest account = pcguest
+
+# Security mode. Most people will want user level security. See
+# security_level.txt for details.
+
+ security = user
+
+# Use password server option only with security = server or security = # domain
+# When using security = domain, you should use password server = *
+; password server =
+; password server = *
+
+# Password Level allows matching of _n_ characters of the password for
+# all combinations of upper and lower case.
+
+ password level = 8
+
+; username level = 8
+
+# You may wish to use password encryption. Please read
+# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.
+# Do not enable this option unless you have read those documents
+# Encrypted passwords are required for any use of samba in a Windows NT #domain
+# The smbpasswd file is only required by a server doing authentication, #thus members of a domain do not need one.
+
+ encrypt passwords = yes
+ smb passwd file = /etc/samba/smbpasswd
+
+# The following are needed to allow password changing from Windows to
+# also update the Linux system password.
+# NOTE: Use these with 'encrypt passwords' and 'smb passwd file' above.
+# NOTE2: You do NOT need these to allow workstations to change only
+# the encrypted SMB passwords. They allow the Unix password
+# to be kept in sync with the SMB password.
+; unix password sync = Yes
+# You either need to setup a passwd program and passwd chat, or
+# enable pam password change
+; pam password change = yes
+; passwd program = /usr/bin/passwd %u
+; passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password*
+# %n\n
+;*passwd:*all*authentication*tokens*updated*successfully*
+
+# Unix users can map to different SMB User names
+; username map = /etc/samba/smbusers
+
+# Using the following line enables you to customise your configuration
+# on a per machine basis. The %m gets replaced with the netbios name
+# of the machine that is connecting
+; include = /etc/samba/smb.conf.%m
+
+# Options for using winbind. Winbind allows you to do all account and
+# authentication from a Windows or samba domain controller, creating
+# accounts on the fly, and maintaining a mapping of Windows RIDs to
+# unix uid's
+# and gid's. winbind uid and winbind gid are the only required
+# parameters.
+#
+# winbind uid is the range of uid's winbind can use when mapping RIDs #to uid's
+; winbind uid = 10000-20000
+#
+# winbind gid is the range of uid's winbind can use when mapping RIDs
+# to gid's
+; winbind gid = 10000-20000
+#
+# winbind separator is the character a user must use between their
+# domain name and username, defaults to "\"
+; winbind separator = +
+#
+# winbind use default domain allows you to have winbind return
+# usernames in the form user instead of DOMAIN+user for the domain
+# listed in the workgroup parameter.
+; winbind use default domain = yes
+#
+# template homedir determines the home directory for winbind users,
+# with %D expanding to their domain name and %U expanding to their
+# username:
+; template homedir = /home/%D/%U
+
+# When using winbind, you may want to have samba create home
+# directories on the fly for authenticated users. Ensure that
+# /etc/pam.d/samba is using 'service=system-auth-winbind' in pam_stack
+# modules, and then enable obedience of pam restrictions below:
+; obey pam restrictions = yes
+
+#
+# template shell determines the shell users authenticated by winbind #get
+; template shell = /bin/bash
+
+# 5. Browser Control and Networking Options:
+# Most people will find that this option gives better performance.
+# See speed.txt and the manual pages for details
+
+ socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
+
+# Configure Samba to use multiple interfaces
+# If you have multiple network interfaces then you must list them
+# here. See the man page for details.
+; interfaces = 192.168.12.2/24 192.168.13.2/24
+
+# Configure remote browse list synchronisation here
+# request announcement to, or browse list sync from:
+# a specific host or from / to a whole subnet (see below)
+; remote browse sync = 192.168.3.25 192.168.5.255
+# Cause this host to announce itself to local subnets here
+; remote announce = 192.168.1.255 192.168.2.44
+
+# set local master to no if you don't want Samba to become a master
+# browser on your network. Otherwise the normal election rules apply
+; local master = no
+
+# OS Level determines the precedence of this server in master browser
+# elections. The default value should be reasonable
+; os level = 33
+
+# Domain Master specifies Samba to be the Domain Master Browser. This
+# allows Samba to collate browse lists between subnets. Don't use this
+# if you already have a Windows NT domain controller doing this job
+; domain master = yes
+
+# Preferred Master causes Samba to force a local browser election on
+# startup and gives it a slightly higher chance of winning the election
+; preferred master = yes
+
+# 6. Domain Control Options:
+# Enable this if you want Samba to be a domain logon server for
+# Windows95 workstations or Primary Domain Controller for WinNT and
+# Win2k
+
+; domain logons = yes
+
+
+# if you enable domain logons then you may want a per-machine or
+# per user logon script
+# run a specific logon batch file per workstation (machine)
+; logon script = %m.bat
+# run a specific logon batch file per username
+; logon script = %U.bat
+
+# Where to store roaming profiles for WinNT and Win2k
+# %L substitutes for this servers netbios name, %U is username
+# You must uncomment the [Profiles] share below
+; logon path = \\%L\Profiles\%U
+
+# Where to store roaming profiles for Win9x. Be careful with this as it
+# also impacts where Win2k finds it's /HOME share
+; logon home = \\%L\%U\.profile
+
+# The add user script is used by a domain member to add local user
+# accounts that have been authenticated by the domain controller, or by
+# the domain controller to add local machine accounts when adding
+# machines to the domain.
+# The script must work from the command line when replacing the macros,
+# or the operation will fail. Check that groups exist if forcing a
+# group.
+# Script for domain controller for adding machines:
+; add user script = /usr/sbin/useradd -d /dev/null -g machines –c
+# 'Machine Account' -s /bin/false -M %u
+# Script for domain controller with LDAP backend for adding machines
+#(please
+# configure in /etc/samba/smbldap_conf.pm first):
+; add user script = /usr/share/samba/scripts/smbldap-useradd.pl -w –d
+# /dev/null -g machines -c 'Machine Account' -s /bin/false %u
+# Script for domain member for adding local accounts for authenticated
+# users:
+; add user script = /usr/sbin/useradd -s /bin/false %u
+
+# Domain groups:
+# domain admin group is a list of unix users or groups who are made
+# members
+# of the Domain Admin group
+; domain admin group = root @wheel
+#
+# domain guest groups is a list of unix users or groups who are made
+# members
+# of the Domain Guests group
+; domain guest group = nobody @guest
+
+# LDAP configuration for Domain Controlling:
+# The account (dn) that samba uses to access the LDAP server
+# This account needs to have write access to the LDAP tree
+# You will need to give samba the password for this dn, by
+# running 'smbpasswd -w mypassword'
+; ldap admin dn = cn=root,dc=mydomain,dc=com
+; ldap ssl = start_tls
+# start_tls should run on 389, but samba defaults incorrectly to 636
+; ldap port = 389
+; ldap suffix = dc=mydomain,dc=com
+; ldap server = ldap.mydomain.com
+
+
+# 7. Name Resolution Options:
+# All NetBIOS names must be resolved to IP Addresses
+# 'Name Resolve Order' allows the named resolution mechanism to be
+# specified the default order is "host lmhosts wins bcast". "host"
+# means use the unix system gethostbyname() function call that will use
+# either /etc/hosts OR DNS or NIS depending on the settings of
+# /etc/host.config, /etc/nsswitch.conf
+# and the /etc/resolv.conf file. "host" therefore is system
+# configuration dependant. This parameter is most often of use to
+# prevent DNS lookups
+# in order to resolve NetBIOS names to IP Addresses. Use with care!
+# The example below excludes use of name resolution for machines that
+# are NOT on the local network segment - OR - are not deliberately to
+# be known via lmhosts or via WINS.
+; name resolve order = wins lmhosts bcast
+
+# Windows Internet Name Serving Support Section:
+# WINS Support - Tells the NMBD component of Samba to enable it's WINS
+# Server
+; wins support = yes
+
+# WINS Server - Tells the NMBD components of Samba to be a WINS Client
+# Note: Samba can be either a WINS Server, or a WINS Client, but
+# NOT both
+; wins server = w.x.y.z
+
+# WINS Proxy - Tells Samba to answer name resolution queries on
+# behalf of a non WINS capable client, for this to work there must be
+# at least one WINS Server on the network. The default is NO.
+; wins proxy = yes
+
+# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS
+# names via DNS nslookups. The built-in default for versions 1.9.17 is
+# yes, this has been changed in version 1.9.18 to no.
+
+ dns proxy = no
+
+# 8. File Naming Options:
+# Case Preservation can be handy - system default is _no_
+# NOTE: These can be set on a per share basis
+; preserve case = no
+; short preserve case = no
+# Default case is normally upper case for all DOS files
+; default case = lower
+# Be very careful with case sensitivity - it can break things!
+; case sensitive = no
+
+# Enabling internationalization:
+# you can match a Windows code page with a UNIX character set.
+# Windows: 437 (US), 737 (GREEK), 850 (Latin1 - Western European),
+# 852 (Eastern Eu.), 861 (Icelandic), 932 (Cyrillic - Russian),
+# 936 (Japanese - Shift-JIS), 936 (Simpl. Chinese), 949 (Korean
+# Hangul),
+# 950 (Trad. Chin.).
+# UNIX: ISO8859-1 (Western European), ISO8859-2 (Eastern Eu.),
+# ISO8859-5 (Russian Cyrillic), KOI8-R (Alt-Russ. Cyril.)
+# This is an example for french users:
+; client code page = 850
+; character set = ISO8859-1
+
+#============================ Share Definitions ==============================
+
+[homes]
+ comment = Home Directories
+ browseable = no
+ writable = yes
+
+# You can enable VFS recycle bin on a per share basis:
+# Uncomment the next 2 lines (make sure you create a
+# .recycle folder in the base of the share and ensure
+# all users will have write access to it. See
+# examples/VFS/recycle/REAME in samba-doc for details
+; vfs object = /usr/lib/samba/vfs/recycle.so
+; vfs options= /etc/samba/recycle.conf
+
+# Un-comment the following and create the netlogon directory for Domain
+# Logons
+; [netlogon]
+; comment = Network Logon Service
+; path = /var/lib/samba/netlogon
+; guest ok = yes
+; writable = no
+
+#Uncomment the following 2 lines if you would like your login scripts
+# to be created dynamically by ntlogon (check that you have it in the
+# correct location (the default of the ntlogon rpm available in
+# contribs)
+
+;root preexec = /usr/bin/ntlogon -u %U -g %G -o %a -d /var/lib/samba/netlogon
+;root postexec = rm -f /var/lib/samba/netlogon/%U.bat
+
+# Un-comment the following to provide a specific roving profile share
+# the default is to use the user's home directory
+;[Profiles]
+; path = /var/lib/samba/profiles
+; browseable = no
+; guest ok = yes
+
+
+# NOTE: If you have a CUPS print system there is no need to
+# specifically define each individual printer.
+# You must configure the samba printers with the appropriate Windows
+# drivers on your Windows clients. On the Samba server no filtering is
+# done. If you wish that the server provides the driver and the clients
+# send PostScript ("Generic PostScript Printer" under Windows), you
+# have to swap the 'print command' line below with the commented one.
+
+[printers]
+ comment = All Printers
+ path = /var/spool/samba
+ browseable = no
+# to allow user 'guest account' to print.
+ guest ok = yes
+ writable = no
+ printable = yes
+ create mode = 0700
+
+# =====================================
+# print command: see above for details.
+# =====================================
+
+ print command = lpr-cups -P %p -o raw %s -r
+# using client side printer drivers.
+; print command = lpr-cups -P %p %s
+# using cups own drivers (use generic PostScript on clients).
+# The following two commands are the samba defaults for printing=cups
+# change them only if you need different options:
+; lpq command = lpq -P %p
+; lprm command = cancel %p-%j
+
+# This share is used for Windows NT-style point-and-print support.
+# To be able to install drivers, you need to be either root, or listed
+# in the printer admin parameter above. Note that you also need write
+# access to the directory and share definition to be able to upload the
+# drivers.
+# For more information on this, please see the Printing Support Section
+# of /usr/share/doc/samba-/docs/Samba-HOWTO-Collection.pdf
+
+[print$]
+ path = /var/lib/samba/printers
+ browseable = yes
+ read only = yes
+ write list = @adm root
+
+# A useful application of samba is to make a PDF-generation service
+# To streamline this, install windows postscript drivers (preferably
+# colour)on the samba server, so that clients can automatically install
+# them.
+
+[pdf-generator]
+ path = /var/tmp
+ guest ok = No
+ printable = Yes
+ comment = PDF Generator (only valid users)
+ #print command = /usr/share/samba/scripts/print-pdf file path win_path recipient IP &
+ print command = /usr/share/samba/scripts/print-pdf %s ~%u \\\\\\\\%L\\\\%u %m %I &
+
+# This one is useful for people to share files
+[tmp]
+ comment = Temporary file space
+ path = /tmp
+ read only = no
+ public = yes
+ echo command = cat %s; rm %s
+
+# A publicly accessible directory, but read only, except for people in
+# the "staff" group
+
+
+
+
+;[public]
+; comment = Public Stuff
+; path = /home/samba/public
+; public = yes
+; writable = no
+; write list = @staff
+# Audited directory through experimental VFS audit.so module:
+# Uncomment next line.
+; vfs object = /usr/lib/samba/vfs/audit.so
+
+# Other examples.
+#
+# A private printer, usable only by Fred. Spool data will be placed in
+# Fred's
+# home directory. Note that fred must have write access to the spool
+# directory,
+# wherever it is.
+;[fredsprn]
+; comment = Fred's Printer
+; valid users = fred
+; path = /homes/fred
+; printer = freds_printer
+; public = no
+; writable = no
+; printable = yes
+
+
+-----------------------------------------------------------
+# A private directory, usable only by Fred. Note that Fred requires
+# write access to the directory.
+
+;[fredsdir]
+
+ [Agustin]
+; comment = Fred's Service
+ comment = Agustin Private Files
+; path = /usr/somewhere/private
+ path = /home/agustin/Documents
+; valid users = fred
+ valid users = agustin
+; public = no
+; writable = yes
+ writable = yes
+; printable = no
+
+
+-----------------------------------------------------------
+
+# a service which has a different directory for each machine that
+# connects this allows you to tailor configurations to incoming
+# machines. You could also use the %u option to tailor it by user name.
+# The %m gets replaced with the machine name that is connecting.
+;[pchome]
+; comment = PC Directories
+; path = /usr/pc/%m
+; public = no
+; writable = yes
+
+
+-----------------------------------------------------------
+# A publicly accessible directory, read/write to all users. Note that
+# all files created in the directory by users will be owned by the
+# default user, so any user with access can delete any other user's
+# files. Obviously this directory must be writable by the default user.
+# Another user could of course be specified, in which case all files
+# would be owned by that user instead.
+
+;[public]
+; path = /usr/somewhere/else/public
+; public = yes
+; only guest = yes
+; writable = yes
+; printable = no
+
+-----------------------------------------------------------
+
+# The following two entries demonstrate how to share a directory so
+# that two users can place files there that will be owned by the
+# specific users. In this setup, the directory should be writable by
+# both users and should have the sticky bit set on it to prevent abuse.
+# Obviously this could be extended to as many users as required.
+
+;[myshare]
+; comment = Mary's and Fred's stuff
+; path = /usr/somewhere/shared
+; valid users = mary fred
+; public = no
+; writable = yes
+; printable = no
+; create mask = 0765
diff --git a/Lib/test/cfgparser.3 b/Lib/test/cfgparser.3
new file mode 100644
index 0000000000..c182cd739c
--- /dev/null
+++ b/Lib/test/cfgparser.3
@@ -0,0 +1,69 @@
+ # INI with as many tricky parts as possible
+ # Most of them could not be used before 3.2
+
+ # This will be parsed with the following options
+ # delimiters = {'='}
+ # comment_prefixes = {'#'}
+ # allow_no_value = True
+
+[DEFAULT]
+go = %(interpolate)s
+
+[strange]
+ values = that are indented # and end with hash comments
+ other = that do continue
+ in # and still have
+ other # comments mixed
+ lines # with the values
+
+
+
+
+
+[corruption]
+ value = that is
+
+
+ actually still here
+
+
+ and holds all these weird newlines
+
+
+ # but not for the lines that are comments
+ nor the indentation
+
+ another value = # empty string
+ yet another # None!
+
+ [yeah, sections can be indented as well]
+ and that does not mean = anything
+ are they subsections = False
+ if you want subsections = use XML
+ lets use some Unicode = 片仮å
+
+ [another one!]
+ even if values are indented like this = seriously
+yes, this still applies to = section "another one!"
+this too = are there people with configurations broken as this?
+ beware, this is going to be a continuation
+ of the value for
+ key "this too"
+ even if it has a = character
+ this is still the continuation
+ your editor probably highlights it wrong
+ but that's life
+# let's set this value so there is no error
+# when getting all items for this section:
+interpolate = anything will do
+
+[no values here]
+# but there's this `go` in DEFAULT
+
+ [tricky interpolation]
+ interpolate = do this
+ lets = %(go)s
+
+ [more interpolation]
+ interpolate = go shopping
+ lets = %(go)s
diff --git a/Lib/test/cmath_testcases.txt b/Lib/test/cmath_testcases.txt
index e159380507..9b0865302e 100644
--- a/Lib/test/cmath_testcases.txt
+++ b/Lib/test/cmath_testcases.txt
@@ -733,10 +733,11 @@ asinh1036 asinh -inf inf -> -inf 0.78539816339744828
---------------------------
-- zeros
-atan0000 atan 0.0 0.0 -> 0.0 0.0
-atan0001 atan 0.0 -0.0 -> 0.0 -0.0
-atan0002 atan -0.0 0.0 -> -0.0 0.0
-atan0003 atan -0.0 -0.0 -> -0.0 -0.0
+-- These are tested in testAtanSign in test_cmath.py
+-- atan0000 atan 0.0 0.0 -> 0.0 0.0
+-- atan0001 atan 0.0 -0.0 -> 0.0 -0.0
+-- atan0002 atan -0.0 0.0 -> -0.0 0.0
+-- atan0003 atan -0.0 -0.0 -> -0.0 -0.0
-- values along both sides of imaginary axis
atan0010 atan 0.0 -9.8813129168249309e-324 -> 0.0 -9.8813129168249309e-324
@@ -896,10 +897,11 @@ atan1040 atan -inf -inf -> -1.5707963267948966 -0.0
---------------------------------------
-- zeros
-atanh0000 atanh 0.0 0.0 -> 0.0 0.0
-atanh0001 atanh 0.0 -0.0 -> 0.0 -0.0
-atanh0002 atanh -0.0 0.0 -> -0.0 0.0
-atanh0003 atanh -0.0 -0.0 -> -0.0 -0.0
+-- These are tested in testAtanhSign in test_cmath.py
+-- atanh0000 atanh 0.0 0.0 -> 0.0 0.0
+-- atanh0001 atanh 0.0 -0.0 -> 0.0 -0.0
+-- atanh0002 atanh -0.0 0.0 -> -0.0 0.0
+-- atanh0003 atanh -0.0 -0.0 -> -0.0 -0.0
-- values along both sides of real axis
atanh0010 atanh -9.8813129168249309e-324 0.0 -> -9.8813129168249309e-324 0.0
@@ -1858,11 +1860,14 @@ sinh1052 sinh -inf inf -> inf nan invalid ignore-real-sign
-- tanh: Hyperbolic Tangent --
------------------------------
--- zeros
-tanh0000 tanh 0.0 0.0 -> 0.0 0.0
-tanh0001 tanh 0.0 -0.0 -> 0.0 -0.0
-tanh0002 tanh -0.0 0.0 -> -0.0 0.0
-tanh0003 tanh -0.0 -0.0 -> -0.0 -0.0
+-- Disabled test: replaced by test_math.testTanhSign()
+-- and test_cmath.testTanhSign()
+
+-- -- zeros
+-- tanh0000 tanh 0.0 0.0 -> 0.0 0.0
+-- tanh0001 tanh 0.0 -0.0 -> 0.0 -0.0
+-- tanh0002 tanh -0.0 0.0 -> -0.0 0.0
+-- tanh0003 tanh -0.0 -0.0 -> -0.0 -0.0
-- random inputs
tanh0004 tanh -21.200500450664993 -1.6970729480342996 -> -1.0 1.9241352344849399e-19
diff --git a/Lib/test/crashers/recursive_call.py b/Lib/test/crashers/recursive_call.py
index 31c8963303..2d160a7de5 100644
--- a/Lib/test/crashers/recursive_call.py
+++ b/Lib/test/crashers/recursive_call.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# No bug report AFAIK, mail on python-dev on 2006-01-10
diff --git a/Lib/test/crashers/underlying_dict.py b/Lib/test/crashers/underlying_dict.py
new file mode 100644
index 0000000000..a4b7993743
--- /dev/null
+++ b/Lib/test/crashers/underlying_dict.py
@@ -0,0 +1,20 @@
+import gc
+
+thingy = object()
+class A(object):
+ def f(self):
+ return 1
+ x = thingy
+
+r = gc.get_referrers(thingy)
+if "__module__" in r[0]:
+ dct = r[0]
+else:
+ dct = r[1]
+
+a = A()
+for i in range(10):
+ a.f()
+dct["f"] = lambda self: 2
+
+print(a.f()) # should print 1
diff --git a/Lib/test/curses_tests.py b/Lib/test/curses_tests.py
index 7dedbbc937..40e832dec2 100644
--- a/Lib/test/curses_tests.py
+++ b/Lib/test/curses_tests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# $Id: ncurses.py 36559 2004-07-18 05:56:09Z tim_one $
#
diff --git a/Lib/test/data/README b/Lib/test/data/README
new file mode 100644
index 0000000000..8bf8c9b31e
--- /dev/null
+++ b/Lib/test/data/README
@@ -0,0 +1,2 @@
+This empty directory serves as destination for temporary files
+created by some tests.
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
new file mode 100644
index 0000000000..e9ceee6d96
--- /dev/null
+++ b/Lib/test/datetimetester.py
@@ -0,0 +1,3679 @@
+"""Test date/time type.
+
+See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
+"""
+
+import sys
+import pickle
+import unittest
+
+from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod
+
+from test import support
+
+import datetime as datetime_module
+from datetime import MINYEAR, MAXYEAR
+from datetime import timedelta
+from datetime import tzinfo
+from datetime import time
+from datetime import timezone
+from datetime import date, datetime
+import time as _time
+
+# Needed by test_datetime
+import _strptime
+#
+
+
+pickle_choices = [(pickle, pickle, proto)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1)]
+assert len(pickle_choices) == pickle.HIGHEST_PROTOCOL + 1
+
+# An arbitrary collection of objects of non-datetime types, for testing
+# mixed-type comparisons.
+OTHERSTUFF = (10, 34.5, "abc", {}, [], ())
+
+
+# XXX Copied from test_float.
+INF = float("inf")
+NAN = float("nan")
+
+
+#############################################################################
+# module tests
+
+class TestModule(unittest.TestCase):
+
+ def test_constants(self):
+ datetime = datetime_module
+ self.assertEqual(datetime.MINYEAR, 1)
+ self.assertEqual(datetime.MAXYEAR, 9999)
+
+#############################################################################
+# tzinfo tests
+
+class FixedOffset(tzinfo):
+
+ def __init__(self, offset, name, dstoffset=42):
+ if isinstance(offset, int):
+ offset = timedelta(minutes=offset)
+ if isinstance(dstoffset, int):
+ dstoffset = timedelta(minutes=dstoffset)
+ self.__offset = offset
+ self.__name = name
+ self.__dstoffset = dstoffset
+ def __repr__(self):
+ return self.__name.lower()
+ def utcoffset(self, dt):
+ return self.__offset
+ def tzname(self, dt):
+ return self.__name
+ def dst(self, dt):
+ return self.__dstoffset
+
+class PicklableFixedOffset(FixedOffset):
+
+ def __init__(self, offset=None, name=None, dstoffset=None):
+ FixedOffset.__init__(self, offset, name, dstoffset)
+
+class TestTZInfo(unittest.TestCase):
+
+ def test_non_abstractness(self):
+ # In order to allow subclasses to get pickled, the C implementation
+ # wasn't able to get away with having __init__ raise
+ # NotImplementedError.
+ useless = tzinfo()
+ dt = datetime.max
+ self.assertRaises(NotImplementedError, useless.tzname, dt)
+ self.assertRaises(NotImplementedError, useless.utcoffset, dt)
+ self.assertRaises(NotImplementedError, useless.dst, dt)
+
+ def test_subclass_must_override(self):
+ class NotEnough(tzinfo):
+ def __init__(self, offset, name):
+ self.__offset = offset
+ self.__name = name
+ self.assertTrue(issubclass(NotEnough, tzinfo))
+ ne = NotEnough(3, "NotByALongShot")
+ self.assertIsInstance(ne, tzinfo)
+
+ dt = datetime.now()
+ self.assertRaises(NotImplementedError, ne.tzname, dt)
+ self.assertRaises(NotImplementedError, ne.utcoffset, dt)
+ self.assertRaises(NotImplementedError, ne.dst, dt)
+
+ def test_normal(self):
+ fo = FixedOffset(3, "Three")
+ self.assertIsInstance(fo, tzinfo)
+ for dt in datetime.now(), None:
+ self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
+ self.assertEqual(fo.tzname(dt), "Three")
+ self.assertEqual(fo.dst(dt), timedelta(minutes=42))
+
+ def test_pickling_base(self):
+ # There's no point to pickling tzinfo objects on their own (they
+ # carry no data), but they need to be picklable anyway else
+ # concrete subclasses can't be pickled.
+ orig = tzinfo.__new__(tzinfo)
+ self.assertTrue(type(orig) is tzinfo)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertTrue(type(derived) is tzinfo)
+
+ def test_pickling_subclass(self):
+ # Make sure we can pickle/unpickle an instance of a subclass.
+ offset = timedelta(minutes=-300)
+ for otype, args in [
+ (PicklableFixedOffset, (offset, 'cookie')),
+ (timezone, (offset,)),
+ (timezone, (offset, "EST"))]:
+ orig = otype(*args)
+ oname = orig.tzname(None)
+ self.assertIsInstance(orig, tzinfo)
+ self.assertIs(type(orig), otype)
+ self.assertEqual(orig.utcoffset(None), offset)
+ self.assertEqual(orig.tzname(None), oname)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertIsInstance(derived, tzinfo)
+ self.assertIs(type(derived), otype)
+ self.assertEqual(derived.utcoffset(None), offset)
+ self.assertEqual(derived.tzname(None), oname)
+
+class TestTimeZone(unittest.TestCase):
+
+ def setUp(self):
+ self.ACDT = timezone(timedelta(hours=9.5), 'ACDT')
+ self.EST = timezone(-timedelta(hours=5), 'EST')
+ self.DT = datetime(2010, 1, 1)
+
+ def test_str(self):
+ for tz in [self.ACDT, self.EST, timezone.utc,
+ timezone.min, timezone.max]:
+ self.assertEqual(str(tz), tz.tzname(None))
+
+ def test_repr(self):
+ datetime = datetime_module
+ for tz in [self.ACDT, self.EST, timezone.utc,
+ timezone.min, timezone.max]:
+ # test round-trip
+ tzrep = repr(tz)
+ self.assertEqual(tz, eval(tzrep))
+
+
+ def test_class_members(self):
+ limit = timedelta(hours=23, minutes=59)
+ self.assertEqual(timezone.utc.utcoffset(None), ZERO)
+ self.assertEqual(timezone.min.utcoffset(None), -limit)
+ self.assertEqual(timezone.max.utcoffset(None), limit)
+
+
+ def test_constructor(self):
+ self.assertIs(timezone.utc, timezone(timedelta(0)))
+ self.assertIsNot(timezone.utc, timezone(timedelta(0), 'UTC'))
+ self.assertEqual(timezone.utc, timezone(timedelta(0), 'UTC'))
+ # invalid offsets
+ for invalid in [timedelta(microseconds=1), timedelta(1, 1),
+ timedelta(seconds=1), timedelta(1), -timedelta(1)]:
+ self.assertRaises(ValueError, timezone, invalid)
+ self.assertRaises(ValueError, timezone, -invalid)
+
+ with self.assertRaises(TypeError): timezone(None)
+ with self.assertRaises(TypeError): timezone(42)
+ with self.assertRaises(TypeError): timezone(ZERO, None)
+ with self.assertRaises(TypeError): timezone(ZERO, 42)
+ with self.assertRaises(TypeError): timezone(ZERO, 'ABC', 'extra')
+
+ def test_inheritance(self):
+ self.assertIsInstance(timezone.utc, tzinfo)
+ self.assertIsInstance(self.EST, tzinfo)
+
+ def test_utcoffset(self):
+ dummy = self.DT
+ for h in [0, 1.5, 12]:
+ offset = h * HOUR
+ self.assertEqual(offset, timezone(offset).utcoffset(dummy))
+ self.assertEqual(-offset, timezone(-offset).utcoffset(dummy))
+
+ with self.assertRaises(TypeError): self.EST.utcoffset('')
+ with self.assertRaises(TypeError): self.EST.utcoffset(5)
+
+
+ def test_dst(self):
+ self.assertIsNone(timezone.utc.dst(self.DT))
+
+ with self.assertRaises(TypeError): self.EST.dst('')
+ with self.assertRaises(TypeError): self.EST.dst(5)
+
+ def test_tzname(self):
+ self.assertEqual('UTC+00:00', timezone(ZERO).tzname(None))
+ self.assertEqual('UTC-05:00', timezone(-5 * HOUR).tzname(None))
+ self.assertEqual('UTC+09:30', timezone(9.5 * HOUR).tzname(None))
+ self.assertEqual('UTC-00:01', timezone(timedelta(minutes=-1)).tzname(None))
+ self.assertEqual('XYZ', timezone(-5 * HOUR, 'XYZ').tzname(None))
+
+ with self.assertRaises(TypeError): self.EST.tzname('')
+ with self.assertRaises(TypeError): self.EST.tzname(5)
+
+ def test_fromutc(self):
+ with self.assertRaises(ValueError):
+ timezone.utc.fromutc(self.DT)
+ with self.assertRaises(TypeError):
+ timezone.utc.fromutc('not datetime')
+ for tz in [self.EST, self.ACDT, Eastern]:
+ utctime = self.DT.replace(tzinfo=tz)
+ local = tz.fromutc(utctime)
+ self.assertEqual(local - utctime, tz.utcoffset(local))
+ self.assertEqual(local,
+ self.DT.replace(tzinfo=timezone.utc))
+
+ def test_comparison(self):
+ self.assertNotEqual(timezone(ZERO), timezone(HOUR))
+ self.assertEqual(timezone(HOUR), timezone(HOUR))
+ self.assertEqual(timezone(-5 * HOUR), timezone(-5 * HOUR, 'EST'))
+ with self.assertRaises(TypeError): timezone(ZERO) < timezone(ZERO)
+ self.assertIn(timezone(ZERO), {timezone(ZERO)})
+
+ def test_aware_datetime(self):
+ # test that timezone instances can be used by datetime
+ t = datetime(1, 1, 1)
+ for tz in [timezone.min, timezone.max, timezone.utc]:
+ self.assertEqual(tz.tzname(t),
+ t.replace(tzinfo=tz).tzname())
+ self.assertEqual(tz.utcoffset(t),
+ t.replace(tzinfo=tz).utcoffset())
+ self.assertEqual(tz.dst(t),
+ t.replace(tzinfo=tz).dst())
+
+#############################################################################
+# Base clase for testing a particular aspect of timedelta, time, date and
+# datetime comparisons.
+
+class HarmlessMixedComparison:
+ # Test that __eq__ and __ne__ don't complain for mixed-type comparisons.
+
+ # Subclasses must define 'theclass', and theclass(1, 1, 1) must be a
+ # legit constructor.
+
+ def test_harmless_mixed_comparison(self):
+ me = self.theclass(1, 1, 1)
+
+ self.assertFalse(me == ())
+ self.assertTrue(me != ())
+ self.assertFalse(() == me)
+ self.assertTrue(() != me)
+
+ self.assertIn(me, [1, 20, [], me])
+ self.assertIn([], [me, 1, 20, []])
+
+ def test_harmful_mixed_comparison(self):
+ me = self.theclass(1, 1, 1)
+
+ self.assertRaises(TypeError, lambda: me < ())
+ self.assertRaises(TypeError, lambda: me <= ())
+ self.assertRaises(TypeError, lambda: me > ())
+ self.assertRaises(TypeError, lambda: me >= ())
+
+ self.assertRaises(TypeError, lambda: () < me)
+ self.assertRaises(TypeError, lambda: () <= me)
+ self.assertRaises(TypeError, lambda: () > me)
+ self.assertRaises(TypeError, lambda: () >= me)
+
+#############################################################################
+# timedelta tests
+
+class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
+
+ theclass = timedelta
+
+ def test_constructor(self):
+ eq = self.assertEqual
+ td = timedelta
+
+ # Check keyword args to constructor
+ eq(td(), td(weeks=0, days=0, hours=0, minutes=0, seconds=0,
+ milliseconds=0, microseconds=0))
+ eq(td(1), td(days=1))
+ eq(td(0, 1), td(seconds=1))
+ eq(td(0, 0, 1), td(microseconds=1))
+ eq(td(weeks=1), td(days=7))
+ eq(td(days=1), td(hours=24))
+ eq(td(hours=1), td(minutes=60))
+ eq(td(minutes=1), td(seconds=60))
+ eq(td(seconds=1), td(milliseconds=1000))
+ eq(td(milliseconds=1), td(microseconds=1000))
+
+ # Check float args to constructor
+ eq(td(weeks=1.0/7), td(days=1))
+ eq(td(days=1.0/24), td(hours=1))
+ eq(td(hours=1.0/60), td(minutes=1))
+ eq(td(minutes=1.0/60), td(seconds=1))
+ eq(td(seconds=0.001), td(milliseconds=1))
+ eq(td(milliseconds=0.001), td(microseconds=1))
+
+ def test_computations(self):
+ eq = self.assertEqual
+ td = timedelta
+
+ a = td(7) # One week
+ b = td(0, 60) # One minute
+ c = td(0, 0, 1000) # One millisecond
+ eq(a+b+c, td(7, 60, 1000))
+ eq(a-b, td(6, 24*3600 - 60))
+ eq(b.__rsub__(a), td(6, 24*3600 - 60))
+ eq(-a, td(-7))
+ eq(+a, td(7))
+ eq(-b, td(-1, 24*3600 - 60))
+ eq(-c, td(-1, 24*3600 - 1, 999000))
+ eq(abs(a), a)
+ eq(abs(-a), a)
+ eq(td(6, 24*3600), a)
+ eq(td(0, 0, 60*1000000), b)
+ eq(a*10, td(70))
+ eq(a*10, 10*a)
+ eq(a*10, 10*a)
+ eq(b*10, td(0, 600))
+ eq(10*b, td(0, 600))
+ eq(b*10, td(0, 600))
+ eq(c*10, td(0, 0, 10000))
+ eq(10*c, td(0, 0, 10000))
+ eq(c*10, td(0, 0, 10000))
+ eq(a*-1, -a)
+ eq(b*-2, -b-b)
+ eq(c*-2, -c+-c)
+ eq(b*(60*24), (b*60)*24)
+ eq(b*(60*24), (60*b)*24)
+ eq(c*1000, td(0, 1))
+ eq(1000*c, td(0, 1))
+ eq(a//7, td(1))
+ eq(b//10, td(0, 6))
+ eq(c//1000, td(0, 0, 1))
+ eq(a//10, td(0, 7*24*360))
+ eq(a//3600000, td(0, 0, 7*24*1000))
+ eq(a/0.5, td(14))
+ eq(b/0.5, td(0, 120))
+ eq(a/7, td(1))
+ eq(b/10, td(0, 6))
+ eq(c/1000, td(0, 0, 1))
+ eq(a/10, td(0, 7*24*360))
+ eq(a/3600000, td(0, 0, 7*24*1000))
+
+ # Multiplication by float
+ us = td(microseconds=1)
+ eq((3*us) * 0.5, 2*us)
+ eq((5*us) * 0.5, 2*us)
+ eq(0.5 * (3*us), 2*us)
+ eq(0.5 * (5*us), 2*us)
+ eq((-3*us) * 0.5, -2*us)
+ eq((-5*us) * 0.5, -2*us)
+
+ # Division by int and float
+ eq((3*us) / 2, 2*us)
+ eq((5*us) / 2, 2*us)
+ eq((-3*us) / 2.0, -2*us)
+ eq((-5*us) / 2.0, -2*us)
+ eq((3*us) / -2, -2*us)
+ eq((5*us) / -2, -2*us)
+ eq((3*us) / -2.0, -2*us)
+ eq((5*us) / -2.0, -2*us)
+ for i in range(-10, 10):
+ eq((i*us/3)//us, round(i/3))
+ for i in range(-10, 10):
+ eq((i*us/-3)//us, round(i/-3))
+
+ def test_disallowed_computations(self):
+ a = timedelta(42)
+
+ # Add/sub ints or floats should be illegal
+ for i in 1, 1.0:
+ self.assertRaises(TypeError, lambda: a+i)
+ self.assertRaises(TypeError, lambda: a-i)
+ self.assertRaises(TypeError, lambda: i+a)
+ self.assertRaises(TypeError, lambda: i-a)
+
+ # Division of int by timedelta doesn't make sense.
+ # Division by zero doesn't make sense.
+ zero = 0
+ self.assertRaises(TypeError, lambda: zero // a)
+ self.assertRaises(ZeroDivisionError, lambda: a // zero)
+ self.assertRaises(ZeroDivisionError, lambda: a / zero)
+ self.assertRaises(ZeroDivisionError, lambda: a / 0.0)
+ self.assertRaises(TypeError, lambda: a / '')
+
+ @support.requires_IEEE_754
+ def test_disallowed_special(self):
+ a = timedelta(42)
+ self.assertRaises(ValueError, a.__mul__, NAN)
+ self.assertRaises(ValueError, a.__truediv__, NAN)
+
+ def test_basic_attributes(self):
+ days, seconds, us = 1, 7, 31
+ td = timedelta(days, seconds, us)
+ self.assertEqual(td.days, days)
+ self.assertEqual(td.seconds, seconds)
+ self.assertEqual(td.microseconds, us)
+
+ def test_total_seconds(self):
+ td = timedelta(days=365)
+ self.assertEqual(td.total_seconds(), 31536000.0)
+ for total_seconds in [123456.789012, -123456.789012, 0.123456, 0, 1e6]:
+ td = timedelta(seconds=total_seconds)
+ self.assertEqual(td.total_seconds(), total_seconds)
+ # Issue8644: Test that td.total_seconds() has the same
+ # accuracy as td / timedelta(seconds=1).
+ for ms in [-1, -2, -123]:
+ td = timedelta(microseconds=ms)
+ self.assertEqual(td.total_seconds(), td / timedelta(seconds=1))
+
+ def test_carries(self):
+ t1 = timedelta(days=100,
+ weeks=-7,
+ hours=-24*(100-49),
+ minutes=-3,
+ seconds=12,
+ microseconds=(3*60 - 12) * 1e6 + 1)
+ t2 = timedelta(microseconds=1)
+ self.assertEqual(t1, t2)
+
+ def test_hash_equality(self):
+ t1 = timedelta(days=100,
+ weeks=-7,
+ hours=-24*(100-49),
+ minutes=-3,
+ seconds=12,
+ microseconds=(3*60 - 12) * 1000000)
+ t2 = timedelta()
+ self.assertEqual(hash(t1), hash(t2))
+
+ t1 += timedelta(weeks=7)
+ t2 += timedelta(days=7*7)
+ self.assertEqual(t1, t2)
+ self.assertEqual(hash(t1), hash(t2))
+
+ d = {t1: 1}
+ d[t2] = 2
+ self.assertEqual(len(d), 1)
+ self.assertEqual(d[t1], 2)
+
+ def test_pickling(self):
+ args = 12, 34, 56
+ orig = timedelta(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_compare(self):
+ t1 = timedelta(2, 3, 4)
+ t2 = timedelta(2, 3, 4)
+ self.assertEqual(t1, t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
+
+ for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
+ t2 = timedelta(*args) # this is larger than t1
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
+
+ for badarg in OTHERSTUFF:
+ self.assertEqual(t1 == badarg, False)
+ self.assertEqual(t1 != badarg, True)
+ self.assertEqual(badarg == t1, False)
+ self.assertEqual(badarg != t1, True)
+
+ self.assertRaises(TypeError, lambda: t1 <= badarg)
+ self.assertRaises(TypeError, lambda: t1 < badarg)
+ self.assertRaises(TypeError, lambda: t1 > badarg)
+ self.assertRaises(TypeError, lambda: t1 >= badarg)
+ self.assertRaises(TypeError, lambda: badarg <= t1)
+ self.assertRaises(TypeError, lambda: badarg < t1)
+ self.assertRaises(TypeError, lambda: badarg > t1)
+ self.assertRaises(TypeError, lambda: badarg >= t1)
+
+ def test_str(self):
+ td = timedelta
+ eq = self.assertEqual
+
+ eq(str(td(1)), "1 day, 0:00:00")
+ eq(str(td(-1)), "-1 day, 0:00:00")
+ eq(str(td(2)), "2 days, 0:00:00")
+ eq(str(td(-2)), "-2 days, 0:00:00")
+
+ eq(str(td(hours=12, minutes=58, seconds=59)), "12:58:59")
+ eq(str(td(hours=2, minutes=3, seconds=4)), "2:03:04")
+ eq(str(td(weeks=-30, hours=23, minutes=12, seconds=34)),
+ "-210 days, 23:12:34")
+
+ eq(str(td(milliseconds=1)), "0:00:00.001000")
+ eq(str(td(microseconds=3)), "0:00:00.000003")
+
+ eq(str(td(days=999999999, hours=23, minutes=59, seconds=59,
+ microseconds=999999)),
+ "999999999 days, 23:59:59.999999")
+
+ def test_repr(self):
+ name = 'datetime.' + self.theclass.__name__
+ self.assertEqual(repr(self.theclass(1)),
+ "%s(1)" % name)
+ self.assertEqual(repr(self.theclass(10, 2)),
+ "%s(10, 2)" % name)
+ self.assertEqual(repr(self.theclass(-10, 2, 400000)),
+ "%s(-10, 2, 400000)" % name)
+
+ def test_roundtrip(self):
+ for td in (timedelta(days=999999999, hours=23, minutes=59,
+ seconds=59, microseconds=999999),
+ timedelta(days=-999999999),
+ timedelta(days=-999999999, seconds=1),
+ timedelta(days=1, seconds=2, microseconds=3)):
+
+ # Verify td -> string -> td identity.
+ s = repr(td)
+ self.assertTrue(s.startswith('datetime.'))
+ s = s[9:]
+ td2 = eval(s)
+ self.assertEqual(td, td2)
+
+ # Verify identity via reconstructing from pieces.
+ td2 = timedelta(td.days, td.seconds, td.microseconds)
+ self.assertEqual(td, td2)
+
+ def test_resolution_info(self):
+ self.assertIsInstance(timedelta.min, timedelta)
+ self.assertIsInstance(timedelta.max, timedelta)
+ self.assertIsInstance(timedelta.resolution, timedelta)
+ self.assertTrue(timedelta.max > timedelta.min)
+ self.assertEqual(timedelta.min, timedelta(-999999999))
+ self.assertEqual(timedelta.max, timedelta(999999999, 24*3600-1, 1e6-1))
+ self.assertEqual(timedelta.resolution, timedelta(0, 0, 1))
+
+ def test_overflow(self):
+ tiny = timedelta.resolution
+
+ td = timedelta.min + tiny
+ td -= tiny # no problem
+ self.assertRaises(OverflowError, td.__sub__, tiny)
+ self.assertRaises(OverflowError, td.__add__, -tiny)
+
+ td = timedelta.max - tiny
+ td += tiny # no problem
+ self.assertRaises(OverflowError, td.__add__, tiny)
+ self.assertRaises(OverflowError, td.__sub__, -tiny)
+
+ self.assertRaises(OverflowError, lambda: -timedelta.max)
+
+ day = timedelta(1)
+ self.assertRaises(OverflowError, day.__mul__, 10**9)
+ self.assertRaises(OverflowError, day.__mul__, 1e9)
+ self.assertRaises(OverflowError, day.__truediv__, 1e-20)
+ self.assertRaises(OverflowError, day.__truediv__, 1e-10)
+ self.assertRaises(OverflowError, day.__truediv__, 9e-10)
+
+ @support.requires_IEEE_754
+ def _test_overflow_special(self):
+ day = timedelta(1)
+ self.assertRaises(OverflowError, day.__mul__, INF)
+ self.assertRaises(OverflowError, day.__mul__, -INF)
+
+ def test_microsecond_rounding(self):
+ td = timedelta
+ eq = self.assertEqual
+
+ # Single-field rounding.
+ eq(td(milliseconds=0.4/1000), td(0)) # rounds to 0
+ eq(td(milliseconds=-0.4/1000), td(0)) # rounds to 0
+ eq(td(milliseconds=0.6/1000), td(microseconds=1))
+ eq(td(milliseconds=-0.6/1000), td(microseconds=-1))
+
+ # Rounding due to contributions from more than one field.
+ us_per_hour = 3600e6
+ us_per_day = us_per_hour * 24
+ eq(td(days=.4/us_per_day), td(0))
+ eq(td(hours=.2/us_per_hour), td(0))
+ eq(td(days=.4/us_per_day, hours=.2/us_per_hour), td(microseconds=1))
+
+ eq(td(days=-.4/us_per_day), td(0))
+ eq(td(hours=-.2/us_per_hour), td(0))
+ eq(td(days=-.4/us_per_day, hours=-.2/us_per_hour), td(microseconds=-1))
+
+ def test_massive_normalization(self):
+ td = timedelta(microseconds=-1)
+ self.assertEqual((td.days, td.seconds, td.microseconds),
+ (-1, 24*3600-1, 999999))
+
+ def test_bool(self):
+ self.assertTrue(timedelta(1))
+ self.assertTrue(timedelta(0, 1))
+ self.assertTrue(timedelta(0, 0, 1))
+ self.assertTrue(timedelta(microseconds=1))
+ self.assertTrue(not timedelta(0))
+
+ def test_subclass_timedelta(self):
+
+ class T(timedelta):
+ @staticmethod
+ def from_td(td):
+ return T(td.days, td.seconds, td.microseconds)
+
+ def as_hours(self):
+ sum = (self.days * 24 +
+ self.seconds / 3600.0 +
+ self.microseconds / 3600e6)
+ return round(sum)
+
+ t1 = T(days=1)
+ self.assertTrue(type(t1) is T)
+ self.assertEqual(t1.as_hours(), 24)
+
+ t2 = T(days=-1, seconds=-3600)
+ self.assertTrue(type(t2) is T)
+ self.assertEqual(t2.as_hours(), -25)
+
+ t3 = t1 + t2
+ self.assertTrue(type(t3) is timedelta)
+ t4 = T.from_td(t3)
+ self.assertTrue(type(t4) is T)
+ self.assertEqual(t3.days, t4.days)
+ self.assertEqual(t3.seconds, t4.seconds)
+ self.assertEqual(t3.microseconds, t4.microseconds)
+ self.assertEqual(str(t3), str(t4))
+ self.assertEqual(t4.as_hours(), -1)
+
+ def test_division(self):
+ t = timedelta(hours=1, minutes=24, seconds=19)
+ second = timedelta(seconds=1)
+ self.assertEqual(t / second, 5059.0)
+ self.assertEqual(t // second, 5059)
+
+ t = timedelta(minutes=2, seconds=30)
+ minute = timedelta(minutes=1)
+ self.assertEqual(t / minute, 2.5)
+ self.assertEqual(t // minute, 2)
+
+ zerotd = timedelta(0)
+ self.assertRaises(ZeroDivisionError, truediv, t, zerotd)
+ self.assertRaises(ZeroDivisionError, floordiv, t, zerotd)
+
+ # self.assertRaises(TypeError, truediv, t, 2)
+ # note: floor division of a timedelta by an integer *is*
+ # currently permitted.
+
+ def test_remainder(self):
+ t = timedelta(minutes=2, seconds=30)
+ minute = timedelta(minutes=1)
+ r = t % minute
+ self.assertEqual(r, timedelta(seconds=30))
+
+ t = timedelta(minutes=-2, seconds=30)
+ r = t % minute
+ self.assertEqual(r, timedelta(seconds=30))
+
+ zerotd = timedelta(0)
+ self.assertRaises(ZeroDivisionError, mod, t, zerotd)
+
+ self.assertRaises(TypeError, mod, t, 10)
+
+ def test_divmod(self):
+ t = timedelta(minutes=2, seconds=30)
+ minute = timedelta(minutes=1)
+ q, r = divmod(t, minute)
+ self.assertEqual(q, 2)
+ self.assertEqual(r, timedelta(seconds=30))
+
+ t = timedelta(minutes=-2, seconds=30)
+ q, r = divmod(t, minute)
+ self.assertEqual(q, -2)
+ self.assertEqual(r, timedelta(seconds=30))
+
+ zerotd = timedelta(0)
+ self.assertRaises(ZeroDivisionError, divmod, t, zerotd)
+
+ self.assertRaises(TypeError, divmod, t, 10)
+
+
+#############################################################################
+# date tests
+
+class TestDateOnly(unittest.TestCase):
+ # Tests here won't pass if also run on datetime objects, so don't
+ # subclass this to test datetimes too.
+
+ def test_delta_non_days_ignored(self):
+ dt = date(2000, 1, 2)
+ delta = timedelta(days=1, hours=2, minutes=3, seconds=4,
+ microseconds=5)
+ days = timedelta(delta.days)
+ self.assertEqual(days, timedelta(1))
+
+ dt2 = dt + delta
+ self.assertEqual(dt2, dt + days)
+
+ dt2 = delta + dt
+ self.assertEqual(dt2, dt + days)
+
+ dt2 = dt - delta
+ self.assertEqual(dt2, dt - days)
+
+ delta = -delta
+ days = timedelta(delta.days)
+ self.assertEqual(days, timedelta(-2))
+
+ dt2 = dt + delta
+ self.assertEqual(dt2, dt + days)
+
+ dt2 = delta + dt
+ self.assertEqual(dt2, dt + days)
+
+ dt2 = dt - delta
+ self.assertEqual(dt2, dt - days)
+
+class SubclassDate(date):
+ sub_var = 1
+
+class TestDate(HarmlessMixedComparison, unittest.TestCase):
+ # Tests here should pass for both dates and datetimes, except for a
+ # few tests that TestDateTime overrides.
+
+ theclass = date
+
+ def test_basic_attributes(self):
+ dt = self.theclass(2002, 3, 1)
+ self.assertEqual(dt.year, 2002)
+ self.assertEqual(dt.month, 3)
+ self.assertEqual(dt.day, 1)
+
+ def test_roundtrip(self):
+ for dt in (self.theclass(1, 2, 3),
+ self.theclass.today()):
+ # Verify dt -> string -> date identity.
+ s = repr(dt)
+ self.assertTrue(s.startswith('datetime.'))
+ s = s[9:]
+ dt2 = eval(s)
+ self.assertEqual(dt, dt2)
+
+ # Verify identity via reconstructing from pieces.
+ dt2 = self.theclass(dt.year, dt.month, dt.day)
+ self.assertEqual(dt, dt2)
+
+ def test_ordinal_conversions(self):
+ # Check some fixed values.
+ for y, m, d, n in [(1, 1, 1, 1), # calendar origin
+ (1, 12, 31, 365),
+ (2, 1, 1, 366),
+ # first example from "Calendrical Calculations"
+ (1945, 11, 12, 710347)]:
+ d = self.theclass(y, m, d)
+ self.assertEqual(n, d.toordinal())
+ fromord = self.theclass.fromordinal(n)
+ self.assertEqual(d, fromord)
+ if hasattr(fromord, "hour"):
+ # if we're checking something fancier than a date, verify
+ # the extra fields have been zeroed out
+ self.assertEqual(fromord.hour, 0)
+ self.assertEqual(fromord.minute, 0)
+ self.assertEqual(fromord.second, 0)
+ self.assertEqual(fromord.microsecond, 0)
+
+ # Check first and last days of year spottily across the whole
+ # range of years supported.
+ for year in range(MINYEAR, MAXYEAR+1, 7):
+ # Verify (year, 1, 1) -> ordinal -> y, m, d is identity.
+ d = self.theclass(year, 1, 1)
+ n = d.toordinal()
+ d2 = self.theclass.fromordinal(n)
+ self.assertEqual(d, d2)
+ # Verify that moving back a day gets to the end of year-1.
+ if year > 1:
+ d = self.theclass.fromordinal(n-1)
+ d2 = self.theclass(year-1, 12, 31)
+ self.assertEqual(d, d2)
+ self.assertEqual(d2.toordinal(), n-1)
+
+ # Test every day in a leap-year and a non-leap year.
+ dim = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+ for year, isleap in (2000, True), (2002, False):
+ n = self.theclass(year, 1, 1).toordinal()
+ for month, maxday in zip(range(1, 13), dim):
+ if month == 2 and isleap:
+ maxday += 1
+ for day in range(1, maxday+1):
+ d = self.theclass(year, month, day)
+ self.assertEqual(d.toordinal(), n)
+ self.assertEqual(d, self.theclass.fromordinal(n))
+ n += 1
+
+ def test_extreme_ordinals(self):
+ a = self.theclass.min
+ a = self.theclass(a.year, a.month, a.day) # get rid of time parts
+ aord = a.toordinal()
+ b = a.fromordinal(aord)
+ self.assertEqual(a, b)
+
+ self.assertRaises(ValueError, lambda: a.fromordinal(aord - 1))
+
+ b = a + timedelta(days=1)
+ self.assertEqual(b.toordinal(), aord + 1)
+ self.assertEqual(b, self.theclass.fromordinal(aord + 1))
+
+ a = self.theclass.max
+ a = self.theclass(a.year, a.month, a.day) # get rid of time parts
+ aord = a.toordinal()
+ b = a.fromordinal(aord)
+ self.assertEqual(a, b)
+
+ self.assertRaises(ValueError, lambda: a.fromordinal(aord + 1))
+
+ b = a - timedelta(days=1)
+ self.assertEqual(b.toordinal(), aord - 1)
+ self.assertEqual(b, self.theclass.fromordinal(aord - 1))
+
+ def test_bad_constructor_arguments(self):
+ # bad years
+ self.theclass(MINYEAR, 1, 1) # no exception
+ self.theclass(MAXYEAR, 1, 1) # no exception
+ self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
+ self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
+ # bad months
+ self.theclass(2000, 1, 1) # no exception
+ self.theclass(2000, 12, 1) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
+ self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
+ # bad days
+ self.theclass(2000, 2, 29) # no exception
+ self.theclass(2004, 2, 29) # no exception
+ self.theclass(2400, 2, 29) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
+ self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 32)
+
+ def test_hash_equality(self):
+ d = self.theclass(2000, 12, 31)
+ # same thing
+ e = self.theclass(2000, 12, 31)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ d = self.theclass(2001, 1, 1)
+ # same thing
+ e = self.theclass(2001, 1, 1)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ def test_computations(self):
+ a = self.theclass(2002, 1, 31)
+ b = self.theclass(1956, 1, 31)
+ c = self.theclass(2001,2,1)
+
+ diff = a-b
+ self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4)))
+ self.assertEqual(diff.seconds, 0)
+ self.assertEqual(diff.microseconds, 0)
+
+ day = timedelta(1)
+ week = timedelta(7)
+ a = self.theclass(2002, 3, 2)
+ self.assertEqual(a + day, self.theclass(2002, 3, 3))
+ self.assertEqual(day + a, self.theclass(2002, 3, 3))
+ self.assertEqual(a - day, self.theclass(2002, 3, 1))
+ self.assertEqual(-day + a, self.theclass(2002, 3, 1))
+ self.assertEqual(a + week, self.theclass(2002, 3, 9))
+ self.assertEqual(a - week, self.theclass(2002, 2, 23))
+ self.assertEqual(a + 52*week, self.theclass(2003, 3, 1))
+ self.assertEqual(a - 52*week, self.theclass(2001, 3, 3))
+ self.assertEqual((a + week) - a, week)
+ self.assertEqual((a + day) - a, day)
+ self.assertEqual((a - week) - a, -week)
+ self.assertEqual((a - day) - a, -day)
+ self.assertEqual(a - (a + week), -week)
+ self.assertEqual(a - (a + day), -day)
+ self.assertEqual(a - (a - week), week)
+ self.assertEqual(a - (a - day), day)
+ self.assertEqual(c - (c - day), day)
+
+ # Add/sub ints or floats should be illegal
+ for i in 1, 1.0:
+ self.assertRaises(TypeError, lambda: a+i)
+ self.assertRaises(TypeError, lambda: a-i)
+ self.assertRaises(TypeError, lambda: i+a)
+ self.assertRaises(TypeError, lambda: i-a)
+
+ # delta - date is senseless.
+ self.assertRaises(TypeError, lambda: day - a)
+ # mixing date and (delta or date) via * or // is senseless
+ self.assertRaises(TypeError, lambda: day * a)
+ self.assertRaises(TypeError, lambda: a * day)
+ self.assertRaises(TypeError, lambda: day // a)
+ self.assertRaises(TypeError, lambda: a // day)
+ self.assertRaises(TypeError, lambda: a * a)
+ self.assertRaises(TypeError, lambda: a // a)
+ # date + date is senseless
+ self.assertRaises(TypeError, lambda: a + a)
+
+ def test_overflow(self):
+ tiny = self.theclass.resolution
+
+ for delta in [tiny, timedelta(1), timedelta(2)]:
+ dt = self.theclass.min + delta
+ dt -= delta # no problem
+ self.assertRaises(OverflowError, dt.__sub__, delta)
+ self.assertRaises(OverflowError, dt.__add__, -delta)
+
+ dt = self.theclass.max - delta
+ dt += delta # no problem
+ self.assertRaises(OverflowError, dt.__add__, delta)
+ self.assertRaises(OverflowError, dt.__sub__, -delta)
+
+ def test_fromtimestamp(self):
+ import time
+
+ # Try an arbitrary fixed value.
+ year, month, day = 1999, 9, 19
+ ts = time.mktime((year, month, day, 0, 0, 0, 0, 0, -1))
+ d = self.theclass.fromtimestamp(ts)
+ self.assertEqual(d.year, year)
+ self.assertEqual(d.month, month)
+ self.assertEqual(d.day, day)
+
+ def test_insane_fromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.fromtimestamp,
+ insane)
+
+ def test_today(self):
+ import time
+
+ # We claim that today() is like fromtimestamp(time.time()), so
+ # prove it.
+ for dummy in range(3):
+ today = self.theclass.today()
+ ts = time.time()
+ todayagain = self.theclass.fromtimestamp(ts)
+ if today == todayagain:
+ break
+ # There are several legit reasons that could fail:
+ # 1. It recently became midnight, between the today() and the
+ # time() calls.
+ # 2. The platform time() has such fine resolution that we'll
+ # never get the same value twice.
+ # 3. The platform time() has poor resolution, and we just
+ # happened to call today() right before a resolution quantum
+ # boundary.
+ # 4. The system clock got fiddled between calls.
+ # In any case, wait a little while and try again.
+ time.sleep(0.1)
+
+ # It worked or it didn't. If it didn't, assume it's reason #2, and
+ # let the test pass if they're within half a second of each other.
+ self.assertTrue(today == todayagain or
+ abs(todayagain - today) < timedelta(seconds=0.5))
+
+ def test_weekday(self):
+ for i in range(7):
+ # March 4, 2002 is a Monday
+ self.assertEqual(self.theclass(2002, 3, 4+i).weekday(), i)
+ self.assertEqual(self.theclass(2002, 3, 4+i).isoweekday(), i+1)
+ # January 2, 1956 is a Monday
+ self.assertEqual(self.theclass(1956, 1, 2+i).weekday(), i)
+ self.assertEqual(self.theclass(1956, 1, 2+i).isoweekday(), i+1)
+
+ def test_isocalendar(self):
+ # Check examples from
+ # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
+ for i in range(7):
+ d = self.theclass(2003, 12, 22+i)
+ self.assertEqual(d.isocalendar(), (2003, 52, i+1))
+ d = self.theclass(2003, 12, 29) + timedelta(i)
+ self.assertEqual(d.isocalendar(), (2004, 1, i+1))
+ d = self.theclass(2004, 1, 5+i)
+ self.assertEqual(d.isocalendar(), (2004, 2, i+1))
+ d = self.theclass(2009, 12, 21+i)
+ self.assertEqual(d.isocalendar(), (2009, 52, i+1))
+ d = self.theclass(2009, 12, 28) + timedelta(i)
+ self.assertEqual(d.isocalendar(), (2009, 53, i+1))
+ d = self.theclass(2010, 1, 4+i)
+ self.assertEqual(d.isocalendar(), (2010, 1, i+1))
+
+ def test_iso_long_years(self):
+ # Calculate long ISO years and compare to table from
+ # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
+ ISO_LONG_YEARS_TABLE = """
+ 4 32 60 88
+ 9 37 65 93
+ 15 43 71 99
+ 20 48 76
+ 26 54 82
+
+ 105 133 161 189
+ 111 139 167 195
+ 116 144 172
+ 122 150 178
+ 128 156 184
+
+ 201 229 257 285
+ 207 235 263 291
+ 212 240 268 296
+ 218 246 274
+ 224 252 280
+
+ 303 331 359 387
+ 308 336 364 392
+ 314 342 370 398
+ 320 348 376
+ 325 353 381
+ """
+ iso_long_years = sorted(map(int, ISO_LONG_YEARS_TABLE.split()))
+ L = []
+ for i in range(400):
+ d = self.theclass(2000+i, 12, 31)
+ d1 = self.theclass(1600+i, 12, 31)
+ self.assertEqual(d.isocalendar()[1:], d1.isocalendar()[1:])
+ if d.isocalendar()[1] == 53:
+ L.append(i)
+ self.assertEqual(L, iso_long_years)
+
+ def test_isoformat(self):
+ t = self.theclass(2, 3, 2)
+ self.assertEqual(t.isoformat(), "0002-03-02")
+
+ def test_ctime(self):
+ t = self.theclass(2002, 3, 2)
+ self.assertEqual(t.ctime(), "Sat Mar 2 00:00:00 2002")
+
+ def test_strftime(self):
+ t = self.theclass(2005, 3, 2)
+ self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05")
+ self.assertEqual(t.strftime(""), "") # SF bug #761337
+ self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784
+
+ self.assertRaises(TypeError, t.strftime) # needs an arg
+ self.assertRaises(TypeError, t.strftime, "one", "two") # too many args
+ self.assertRaises(TypeError, t.strftime, 42) # arg wrong type
+
+ # test that unicode input is allowed (issue 2782)
+ self.assertEqual(t.strftime("%m"), "03")
+
+ # A naive object replaces %z and %Z w/ empty strings.
+ self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
+
+ #make sure that invalid format specifiers are handled correctly
+ #self.assertRaises(ValueError, t.strftime, "%e")
+ #self.assertRaises(ValueError, t.strftime, "%")
+ #self.assertRaises(ValueError, t.strftime, "%#")
+
+ #oh well, some systems just ignore those invalid ones.
+ #at least, excercise them to make sure that no crashes
+ #are generated
+ for f in ["%e", "%", "%#"]:
+ try:
+ t.strftime(f)
+ except ValueError:
+ pass
+
+ #check that this standard extension works
+ t.strftime("%f")
+
+
+ def test_format(self):
+ dt = self.theclass(2007, 9, 10)
+ self.assertEqual(dt.__format__(''), str(dt))
+
+ # check that a derived class's __str__() gets called
+ class A(self.theclass):
+ def __str__(self):
+ return 'A'
+ a = A(2007, 9, 10)
+ self.assertEqual(a.__format__(''), 'A')
+
+ # check that a derived class's strftime gets called
+ class B(self.theclass):
+ def strftime(self, format_spec):
+ return 'B'
+ b = B(2007, 9, 10)
+ self.assertEqual(b.__format__(''), str(dt))
+
+ for fmt in ["m:%m d:%d y:%y",
+ "m:%m d:%d y:%y H:%H M:%M S:%S",
+ "%z %Z",
+ ]:
+ self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
+ self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
+ self.assertEqual(b.__format__(fmt), 'B')
+
+ def test_resolution_info(self):
+ # XXX: Should min and max respect subclassing?
+ if issubclass(self.theclass, datetime):
+ expected_class = datetime
+ else:
+ expected_class = date
+ self.assertIsInstance(self.theclass.min, expected_class)
+ self.assertIsInstance(self.theclass.max, expected_class)
+ self.assertIsInstance(self.theclass.resolution, timedelta)
+ self.assertTrue(self.theclass.max > self.theclass.min)
+
+ def test_extreme_timedelta(self):
+ big = self.theclass.max - self.theclass.min
+ # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds
+ n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds
+ # n == 315537897599999999 ~= 2**58.13
+ justasbig = timedelta(0, 0, n)
+ self.assertEqual(big, justasbig)
+ self.assertEqual(self.theclass.min + big, self.theclass.max)
+ self.assertEqual(self.theclass.max - big, self.theclass.min)
+
+ def test_timetuple(self):
+ for i in range(7):
+ # January 2, 1956 is a Monday (0)
+ d = self.theclass(1956, 1, 2+i)
+ t = d.timetuple()
+ self.assertEqual(t, (1956, 1, 2+i, 0, 0, 0, i, 2+i, -1))
+ # February 1, 1956 is a Wednesday (2)
+ d = self.theclass(1956, 2, 1+i)
+ t = d.timetuple()
+ self.assertEqual(t, (1956, 2, 1+i, 0, 0, 0, (2+i)%7, 32+i, -1))
+ # March 1, 1956 is a Thursday (3), and is the 31+29+1 = 61st day
+ # of the year.
+ d = self.theclass(1956, 3, 1+i)
+ t = d.timetuple()
+ self.assertEqual(t, (1956, 3, 1+i, 0, 0, 0, (3+i)%7, 61+i, -1))
+ self.assertEqual(t.tm_year, 1956)
+ self.assertEqual(t.tm_mon, 3)
+ self.assertEqual(t.tm_mday, 1+i)
+ self.assertEqual(t.tm_hour, 0)
+ self.assertEqual(t.tm_min, 0)
+ self.assertEqual(t.tm_sec, 0)
+ self.assertEqual(t.tm_wday, (3+i)%7)
+ self.assertEqual(t.tm_yday, 61+i)
+ self.assertEqual(t.tm_isdst, -1)
+
+ def test_pickling(self):
+ args = 6, 7, 23
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_compare(self):
+ t1 = self.theclass(2, 3, 4)
+ t2 = self.theclass(2, 3, 4)
+ self.assertEqual(t1, t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
+
+ for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
+ t2 = self.theclass(*args) # this is larger than t1
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
+
+ for badarg in OTHERSTUFF:
+ self.assertEqual(t1 == badarg, False)
+ self.assertEqual(t1 != badarg, True)
+ self.assertEqual(badarg == t1, False)
+ self.assertEqual(badarg != t1, True)
+
+ self.assertRaises(TypeError, lambda: t1 < badarg)
+ self.assertRaises(TypeError, lambda: t1 > badarg)
+ self.assertRaises(TypeError, lambda: t1 >= badarg)
+ self.assertRaises(TypeError, lambda: badarg <= t1)
+ self.assertRaises(TypeError, lambda: badarg < t1)
+ self.assertRaises(TypeError, lambda: badarg > t1)
+ self.assertRaises(TypeError, lambda: badarg >= t1)
+
+ def test_mixed_compare(self):
+ our = self.theclass(2000, 4, 5)
+
+ # Our class can be compared for equality to other classes
+ self.assertEqual(our == 1, False)
+ self.assertEqual(1 == our, False)
+ self.assertEqual(our != 1, True)
+ self.assertEqual(1 != our, True)
+
+ # But the ordering is undefined
+ self.assertRaises(TypeError, lambda: our < 1)
+ self.assertRaises(TypeError, lambda: 1 < our)
+
+ # Repeat those tests with a different class
+
+ class SomeClass:
+ pass
+
+ their = SomeClass()
+ self.assertEqual(our == their, False)
+ self.assertEqual(their == our, False)
+ self.assertEqual(our != their, True)
+ self.assertEqual(their != our, True)
+ self.assertRaises(TypeError, lambda: our < their)
+ self.assertRaises(TypeError, lambda: their < our)
+
+ # However, if the other class explicitly defines ordering
+ # relative to our class, it is allowed to do so
+
+ class LargerThanAnything:
+ def __lt__(self, other):
+ return False
+ def __le__(self, other):
+ return isinstance(other, LargerThanAnything)
+ def __eq__(self, other):
+ return isinstance(other, LargerThanAnything)
+ def __ne__(self, other):
+ return not isinstance(other, LargerThanAnything)
+ def __gt__(self, other):
+ return not isinstance(other, LargerThanAnything)
+ def __ge__(self, other):
+ return True
+
+ their = LargerThanAnything()
+ self.assertEqual(our == their, False)
+ self.assertEqual(their == our, False)
+ self.assertEqual(our != their, True)
+ self.assertEqual(their != our, True)
+ self.assertEqual(our < their, True)
+ self.assertEqual(their < our, False)
+
+ def test_bool(self):
+ # All dates are considered true.
+ self.assertTrue(self.theclass.min)
+ self.assertTrue(self.theclass.max)
+
+ def test_strftime_out_of_range(self):
+ # For nasty technical reasons, we can't handle years before 1000.
+ cls = self.theclass
+ self.assertEqual(cls(1000, 1, 1).strftime("%Y"), "1000")
+ for y in 1, 49, 51, 99, 100, 999:
+ self.assertRaises(ValueError, cls(y, 1, 1).strftime, "%Y")
+
+ def test_replace(self):
+ cls = self.theclass
+ args = [1, 2, 3]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("year", 2),
+ ("month", 3),
+ ("day", 4)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Out of bounds.
+ base = cls(2000, 2, 29)
+ self.assertRaises(ValueError, base.replace, year=2001)
+
+ def test_subclass_date(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.year + self.month
+
+ args = 2003, 4, 14
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.toordinal(), dt2.toordinal())
+ self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month - 7)
+
+ def test_pickling_subclass_date(self):
+
+ args = 6, 7, 23
+ orig = SubclassDate(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_backdoor_resistance(self):
+ # For fast unpickling, the constructor accepts a pickle byte string.
+ # This is a low-overhead backdoor. A user can (by intent or
+ # mistake) pass a string directly, which (if it's the right length)
+ # will get treated like a pickle, and bypass the normal sanity
+ # checks in the constructor. This can create insane objects.
+ # The constructor doesn't want to burn the time to validate all
+ # fields, but does check the month field. This stops, e.g.,
+ # datetime.datetime('1995-03-25') from yielding an insane object.
+ base = b'1995-03-25'
+ if not issubclass(self.theclass, datetime):
+ base = base[:4]
+ for month_byte in b'9', b'\0', b'\r', b'\xff':
+ self.assertRaises(TypeError, self.theclass,
+ base[:2] + month_byte + base[3:])
+ # Good bytes, but bad tzinfo:
+ self.assertRaises(TypeError, self.theclass,
+ bytes([1] * len(base)), 'EST')
+
+ for ord_byte in range(1, 13):
+ # This shouldn't blow up because of the month byte alone. If
+ # the implementation changes to do more-careful checking, it may
+ # blow up because other fields are insane.
+ self.theclass(base[:2] + bytes([ord_byte]) + base[3:])
+
+#############################################################################
+# datetime tests
+
+class SubclassDatetime(datetime):
+ sub_var = 1
+
+class TestDateTime(TestDate):
+
+ theclass = datetime
+
+ def test_basic_attributes(self):
+ dt = self.theclass(2002, 3, 1, 12, 0)
+ self.assertEqual(dt.year, 2002)
+ self.assertEqual(dt.month, 3)
+ self.assertEqual(dt.day, 1)
+ self.assertEqual(dt.hour, 12)
+ self.assertEqual(dt.minute, 0)
+ self.assertEqual(dt.second, 0)
+ self.assertEqual(dt.microsecond, 0)
+
+ def test_basic_attributes_nonzero(self):
+ # Make sure all attributes are non-zero so bugs in
+ # bit-shifting access show up.
+ dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000)
+ self.assertEqual(dt.year, 2002)
+ self.assertEqual(dt.month, 3)
+ self.assertEqual(dt.day, 1)
+ self.assertEqual(dt.hour, 12)
+ self.assertEqual(dt.minute, 59)
+ self.assertEqual(dt.second, 59)
+ self.assertEqual(dt.microsecond, 8000)
+
+ def test_roundtrip(self):
+ for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7),
+ self.theclass.now()):
+ # Verify dt -> string -> datetime identity.
+ s = repr(dt)
+ self.assertTrue(s.startswith('datetime.'))
+ s = s[9:]
+ dt2 = eval(s)
+ self.assertEqual(dt, dt2)
+
+ # Verify identity via reconstructing from pieces.
+ dt2 = self.theclass(dt.year, dt.month, dt.day,
+ dt.hour, dt.minute, dt.second,
+ dt.microsecond)
+ self.assertEqual(dt, dt2)
+
+ def test_isoformat(self):
+ t = self.theclass(2, 3, 2, 4, 5, 1, 123)
+ self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123")
+ self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
+ self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
+ self.assertEqual(t.isoformat('\x00'), "0002-03-02\x0004:05:01.000123")
+ # str is ISO format with the separator forced to a blank.
+ self.assertEqual(str(t), "0002-03-02 04:05:01.000123")
+
+ t = self.theclass(2, 3, 2)
+ self.assertEqual(t.isoformat(), "0002-03-02T00:00:00")
+ self.assertEqual(t.isoformat('T'), "0002-03-02T00:00:00")
+ self.assertEqual(t.isoformat(' '), "0002-03-02 00:00:00")
+ # str is ISO format with the separator forced to a blank.
+ self.assertEqual(str(t), "0002-03-02 00:00:00")
+
+ def test_format(self):
+ dt = self.theclass(2007, 9, 10, 4, 5, 1, 123)
+ self.assertEqual(dt.__format__(''), str(dt))
+
+ # check that a derived class's __str__() gets called
+ class A(self.theclass):
+ def __str__(self):
+ return 'A'
+ a = A(2007, 9, 10, 4, 5, 1, 123)
+ self.assertEqual(a.__format__(''), 'A')
+
+ # check that a derived class's strftime gets called
+ class B(self.theclass):
+ def strftime(self, format_spec):
+ return 'B'
+ b = B(2007, 9, 10, 4, 5, 1, 123)
+ self.assertEqual(b.__format__(''), str(dt))
+
+ for fmt in ["m:%m d:%d y:%y",
+ "m:%m d:%d y:%y H:%H M:%M S:%S",
+ "%z %Z",
+ ]:
+ self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
+ self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
+ self.assertEqual(b.__format__(fmt), 'B')
+
+ def test_more_ctime(self):
+ # Test fields that TestDate doesn't touch.
+ import time
+
+ t = self.theclass(2002, 3, 2, 18, 3, 5, 123)
+ self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002")
+ # Oops! The next line fails on Win2K under MSVC 6, so it's commented
+ # out. The difference is that t.ctime() produces " 2" for the day,
+ # but platform ctime() produces "02" for the day. According to
+ # C99, t.ctime() is correct here.
+ # self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
+
+ # So test a case where that difference doesn't matter.
+ t = self.theclass(2002, 3, 22, 18, 3, 5, 123)
+ self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
+
+ def test_tz_independent_comparing(self):
+ dt1 = self.theclass(2002, 3, 1, 9, 0, 0)
+ dt2 = self.theclass(2002, 3, 1, 10, 0, 0)
+ dt3 = self.theclass(2002, 3, 1, 9, 0, 0)
+ self.assertEqual(dt1, dt3)
+ self.assertTrue(dt2 > dt3)
+
+ # Make sure comparison doesn't forget microseconds, and isn't done
+ # via comparing a float timestamp (an IEEE double doesn't have enough
+ # precision to span microsecond resolution across years 1 thru 9999,
+ # so comparing via timestamp necessarily calls some distinct values
+ # equal).
+ dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998)
+ us = timedelta(microseconds=1)
+ dt2 = dt1 + us
+ self.assertEqual(dt2 - dt1, us)
+ self.assertTrue(dt1 < dt2)
+
+ def test_strftime_with_bad_tzname_replace(self):
+ # verify ok if tzinfo.tzname().replace() returns a non-string
+ class MyTzInfo(FixedOffset):
+ def tzname(self, dt):
+ class MyStr(str):
+ def replace(self, *args):
+ return None
+ return MyStr('name')
+ t = self.theclass(2005, 3, 2, 0, 0, 0, 0, MyTzInfo(3, 'name'))
+ self.assertRaises(TypeError, t.strftime, '%Z')
+
+ def test_bad_constructor_arguments(self):
+ # bad years
+ self.theclass(MINYEAR, 1, 1) # no exception
+ self.theclass(MAXYEAR, 1, 1) # no exception
+ self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
+ self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
+ # bad months
+ self.theclass(2000, 1, 1) # no exception
+ self.theclass(2000, 12, 1) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
+ self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
+ # bad days
+ self.theclass(2000, 2, 29) # no exception
+ self.theclass(2004, 2, 29) # no exception
+ self.theclass(2400, 2, 29) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
+ self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 32)
+ # bad hours
+ self.theclass(2000, 1, 31, 0) # no exception
+ self.theclass(2000, 1, 31, 23) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, -1)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 24)
+ # bad minutes
+ self.theclass(2000, 1, 31, 23, 0) # no exception
+ self.theclass(2000, 1, 31, 23, 59) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, -1)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 60)
+ # bad seconds
+ self.theclass(2000, 1, 31, 23, 59, 0) # no exception
+ self.theclass(2000, 1, 31, 23, 59, 59) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, -1)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, 60)
+ # bad microseconds
+ self.theclass(2000, 1, 31, 23, 59, 59, 0) # no exception
+ self.theclass(2000, 1, 31, 23, 59, 59, 999999) # no exception
+ self.assertRaises(ValueError, self.theclass,
+ 2000, 1, 31, 23, 59, 59, -1)
+ self.assertRaises(ValueError, self.theclass,
+ 2000, 1, 31, 23, 59, 59,
+ 1000000)
+
+ def test_hash_equality(self):
+ d = self.theclass(2000, 12, 31, 23, 30, 17)
+ e = self.theclass(2000, 12, 31, 23, 30, 17)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ d = self.theclass(2001, 1, 1, 0, 5, 17)
+ e = self.theclass(2001, 1, 1, 0, 5, 17)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ def test_computations(self):
+ a = self.theclass(2002, 1, 31)
+ b = self.theclass(1956, 1, 31)
+ diff = a-b
+ self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4)))
+ self.assertEqual(diff.seconds, 0)
+ self.assertEqual(diff.microseconds, 0)
+ a = self.theclass(2002, 3, 2, 17, 6)
+ millisec = timedelta(0, 0, 1000)
+ hour = timedelta(0, 3600)
+ day = timedelta(1)
+ week = timedelta(7)
+ self.assertEqual(a + hour, self.theclass(2002, 3, 2, 18, 6))
+ self.assertEqual(hour + a, self.theclass(2002, 3, 2, 18, 6))
+ self.assertEqual(a + 10*hour, self.theclass(2002, 3, 3, 3, 6))
+ self.assertEqual(a - hour, self.theclass(2002, 3, 2, 16, 6))
+ self.assertEqual(-hour + a, self.theclass(2002, 3, 2, 16, 6))
+ self.assertEqual(a - hour, a + -hour)
+ self.assertEqual(a - 20*hour, self.theclass(2002, 3, 1, 21, 6))
+ self.assertEqual(a + day, self.theclass(2002, 3, 3, 17, 6))
+ self.assertEqual(a - day, self.theclass(2002, 3, 1, 17, 6))
+ self.assertEqual(a + week, self.theclass(2002, 3, 9, 17, 6))
+ self.assertEqual(a - week, self.theclass(2002, 2, 23, 17, 6))
+ self.assertEqual(a + 52*week, self.theclass(2003, 3, 1, 17, 6))
+ self.assertEqual(a - 52*week, self.theclass(2001, 3, 3, 17, 6))
+ self.assertEqual((a + week) - a, week)
+ self.assertEqual((a + day) - a, day)
+ self.assertEqual((a + hour) - a, hour)
+ self.assertEqual((a + millisec) - a, millisec)
+ self.assertEqual((a - week) - a, -week)
+ self.assertEqual((a - day) - a, -day)
+ self.assertEqual((a - hour) - a, -hour)
+ self.assertEqual((a - millisec) - a, -millisec)
+ self.assertEqual(a - (a + week), -week)
+ self.assertEqual(a - (a + day), -day)
+ self.assertEqual(a - (a + hour), -hour)
+ self.assertEqual(a - (a + millisec), -millisec)
+ self.assertEqual(a - (a - week), week)
+ self.assertEqual(a - (a - day), day)
+ self.assertEqual(a - (a - hour), hour)
+ self.assertEqual(a - (a - millisec), millisec)
+ self.assertEqual(a + (week + day + hour + millisec),
+ self.theclass(2002, 3, 10, 18, 6, 0, 1000))
+ self.assertEqual(a + (week + day + hour + millisec),
+ (((a + week) + day) + hour) + millisec)
+ self.assertEqual(a - (week + day + hour + millisec),
+ self.theclass(2002, 2, 22, 16, 5, 59, 999000))
+ self.assertEqual(a - (week + day + hour + millisec),
+ (((a - week) - day) - hour) - millisec)
+ # Add/sub ints or floats should be illegal
+ for i in 1, 1.0:
+ self.assertRaises(TypeError, lambda: a+i)
+ self.assertRaises(TypeError, lambda: a-i)
+ self.assertRaises(TypeError, lambda: i+a)
+ self.assertRaises(TypeError, lambda: i-a)
+
+ # delta - datetime is senseless.
+ self.assertRaises(TypeError, lambda: day - a)
+ # mixing datetime and (delta or datetime) via * or // is senseless
+ self.assertRaises(TypeError, lambda: day * a)
+ self.assertRaises(TypeError, lambda: a * day)
+ self.assertRaises(TypeError, lambda: day // a)
+ self.assertRaises(TypeError, lambda: a // day)
+ self.assertRaises(TypeError, lambda: a * a)
+ self.assertRaises(TypeError, lambda: a // a)
+ # datetime + datetime is senseless
+ self.assertRaises(TypeError, lambda: a + a)
+
+ def test_pickling(self):
+ args = 6, 7, 23, 20, 59, 1, 64**2
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_more_pickling(self):
+ a = self.theclass(2003, 2, 7, 16, 48, 37, 444116)
+ s = pickle.dumps(a)
+ b = pickle.loads(s)
+ self.assertEqual(b.year, 2003)
+ self.assertEqual(b.month, 2)
+ self.assertEqual(b.day, 7)
+
+ def test_pickling_subclass_datetime(self):
+ args = 6, 7, 23, 20, 59, 1, 64**2
+ orig = SubclassDatetime(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_more_compare(self):
+ # The test_compare() inherited from TestDate covers the error cases.
+ # We just want to test lexicographic ordering on the members datetime
+ # has that date lacks.
+ args = [2000, 11, 29, 20, 58, 16, 999998]
+ t1 = self.theclass(*args)
+ t2 = self.theclass(*args)
+ self.assertEqual(t1, t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
+
+ for i in range(len(args)):
+ newargs = args[:]
+ newargs[i] = args[i] + 1
+ t2 = self.theclass(*newargs) # this is larger than t1
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
+
+
+ # A helper for timestamp constructor tests.
+ def verify_field_equality(self, expected, got):
+ self.assertEqual(expected.tm_year, got.year)
+ self.assertEqual(expected.tm_mon, got.month)
+ self.assertEqual(expected.tm_mday, got.day)
+ self.assertEqual(expected.tm_hour, got.hour)
+ self.assertEqual(expected.tm_min, got.minute)
+ self.assertEqual(expected.tm_sec, got.second)
+
+ def test_fromtimestamp(self):
+ import time
+
+ ts = time.time()
+ expected = time.localtime(ts)
+ got = self.theclass.fromtimestamp(ts)
+ self.verify_field_equality(expected, got)
+
+ def test_utcfromtimestamp(self):
+ import time
+
+ ts = time.time()
+ expected = time.gmtime(ts)
+ got = self.theclass.utcfromtimestamp(ts)
+ self.verify_field_equality(expected, got)
+
+ def test_microsecond_rounding(self):
+ # Test whether fromtimestamp "rounds up" floats that are less
+ # than 1/2 microsecond smaller than an integer.
+ for fts in [self.theclass.fromtimestamp,
+ self.theclass.utcfromtimestamp]:
+ self.assertEqual(fts(0.9999999), fts(1))
+ self.assertEqual(fts(0.99999949).microsecond, 999999)
+
+ def test_insane_fromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.fromtimestamp,
+ insane)
+
+ def test_insane_utcfromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.utcfromtimestamp,
+ insane)
+ @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
+ def test_negative_float_fromtimestamp(self):
+ # The result is tz-dependent; at least test that this doesn't
+ # fail (like it did before bug 1646728 was fixed).
+ self.theclass.fromtimestamp(-1.05)
+
+ @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
+ def test_negative_float_utcfromtimestamp(self):
+ d = self.theclass.utcfromtimestamp(-1.05)
+ self.assertEqual(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000))
+
+ def test_utcnow(self):
+ import time
+
+ # Call it a success if utcnow() and utcfromtimestamp() are within
+ # a second of each other.
+ tolerance = timedelta(seconds=1)
+ for dummy in range(3):
+ from_now = self.theclass.utcnow()
+ from_timestamp = self.theclass.utcfromtimestamp(time.time())
+ if abs(from_timestamp - from_now) <= tolerance:
+ break
+ # Else try again a few times.
+ self.assertTrue(abs(from_timestamp - from_now) <= tolerance)
+
+ def test_strptime(self):
+ import _strptime
+
+ string = '2004-12-01 13:02:47.197'
+ format = '%Y-%m-%d %H:%M:%S.%f'
+ expected = _strptime._strptime_datetime(self.theclass, string, format)
+ got = self.theclass.strptime(string, format)
+ self.assertEqual(expected, got)
+ self.assertIs(type(expected), self.theclass)
+ self.assertIs(type(got), self.theclass)
+
+ strptime = self.theclass.strptime
+ self.assertEqual(strptime("+0002", "%z").utcoffset(), 2 * MINUTE)
+ self.assertEqual(strptime("-0002", "%z").utcoffset(), -2 * MINUTE)
+ # Only local timezone and UTC are supported
+ for tzseconds, tzname in ((0, 'UTC'), (0, 'GMT'),
+ (-_time.timezone, _time.tzname[0])):
+ if tzseconds < 0:
+ sign = '-'
+ seconds = -tzseconds
+ else:
+ sign ='+'
+ seconds = tzseconds
+ hours, minutes = divmod(seconds//60, 60)
+ dtstr = "{}{:02d}{:02d} {}".format(sign, hours, minutes, tzname)
+ dt = strptime(dtstr, "%z %Z")
+ self.assertEqual(dt.utcoffset(), timedelta(seconds=tzseconds))
+ self.assertEqual(dt.tzname(), tzname)
+ # Can produce inconsistent datetime
+ dtstr, fmt = "+1234 UTC", "%z %Z"
+ dt = strptime(dtstr, fmt)
+ self.assertEqual(dt.utcoffset(), 12 * HOUR + 34 * MINUTE)
+ self.assertEqual(dt.tzname(), 'UTC')
+ # yet will roundtrip
+ self.assertEqual(dt.strftime(fmt), dtstr)
+
+ # Produce naive datetime if no %z is provided
+ self.assertEqual(strptime("UTC", "%Z").tzinfo, None)
+
+ with self.assertRaises(ValueError): strptime("-2400", "%z")
+ with self.assertRaises(ValueError): strptime("-000", "%z")
+
+ def test_more_timetuple(self):
+ # This tests fields beyond those tested by the TestDate.test_timetuple.
+ t = self.theclass(2004, 12, 31, 6, 22, 33)
+ self.assertEqual(t.timetuple(), (2004, 12, 31, 6, 22, 33, 4, 366, -1))
+ self.assertEqual(t.timetuple(),
+ (t.year, t.month, t.day,
+ t.hour, t.minute, t.second,
+ t.weekday(),
+ t.toordinal() - date(t.year, 1, 1).toordinal() + 1,
+ -1))
+ tt = t.timetuple()
+ self.assertEqual(tt.tm_year, t.year)
+ self.assertEqual(tt.tm_mon, t.month)
+ self.assertEqual(tt.tm_mday, t.day)
+ self.assertEqual(tt.tm_hour, t.hour)
+ self.assertEqual(tt.tm_min, t.minute)
+ self.assertEqual(tt.tm_sec, t.second)
+ self.assertEqual(tt.tm_wday, t.weekday())
+ self.assertEqual(tt.tm_yday, t.toordinal() -
+ date(t.year, 1, 1).toordinal() + 1)
+ self.assertEqual(tt.tm_isdst, -1)
+
+ def test_more_strftime(self):
+ # This tests fields beyond those tested by the TestDate.test_strftime.
+ t = self.theclass(2004, 12, 31, 6, 22, 33, 47)
+ self.assertEqual(t.strftime("%m %d %y %f %S %M %H %j"),
+ "12 31 04 000047 33 22 06 366")
+
+ def test_extract(self):
+ dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
+ self.assertEqual(dt.date(), date(2002, 3, 4))
+ self.assertEqual(dt.time(), time(18, 45, 3, 1234))
+
+ def test_combine(self):
+ d = date(2002, 3, 4)
+ t = time(18, 45, 3, 1234)
+ expected = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
+ combine = self.theclass.combine
+ dt = combine(d, t)
+ self.assertEqual(dt, expected)
+
+ dt = combine(time=t, date=d)
+ self.assertEqual(dt, expected)
+
+ self.assertEqual(d, dt.date())
+ self.assertEqual(t, dt.time())
+ self.assertEqual(dt, combine(dt.date(), dt.time()))
+
+ self.assertRaises(TypeError, combine) # need an arg
+ self.assertRaises(TypeError, combine, d) # need two args
+ self.assertRaises(TypeError, combine, t, d) # args reversed
+ self.assertRaises(TypeError, combine, d, t, 1) # too many args
+ self.assertRaises(TypeError, combine, "date", "time") # wrong types
+ self.assertRaises(TypeError, combine, d, "time") # wrong type
+ self.assertRaises(TypeError, combine, "date", t) # wrong type
+
+ def test_replace(self):
+ cls = self.theclass
+ args = [1, 2, 3, 4, 5, 6, 7]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("year", 2),
+ ("month", 3),
+ ("day", 4),
+ ("hour", 5),
+ ("minute", 6),
+ ("second", 7),
+ ("microsecond", 8)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Out of bounds.
+ base = cls(2000, 2, 29)
+ self.assertRaises(ValueError, base.replace, year=2001)
+
+ def test_astimezone(self):
+ # Pretty boring! The TZ test is more interesting here. astimezone()
+ # simply can't be applied to a naive object.
+ dt = self.theclass.now()
+ f = FixedOffset(44, "")
+ self.assertRaises(TypeError, dt.astimezone) # not enough args
+ self.assertRaises(TypeError, dt.astimezone, f, f) # too many args
+ self.assertRaises(TypeError, dt.astimezone, dt) # arg wrong type
+ self.assertRaises(ValueError, dt.astimezone, f) # naive
+ self.assertRaises(ValueError, dt.astimezone, tz=f) # naive
+
+ class Bogus(tzinfo):
+ def utcoffset(self, dt): return None
+ def dst(self, dt): return timedelta(0)
+ bog = Bogus()
+ self.assertRaises(ValueError, dt.astimezone, bog) # naive
+ self.assertRaises(ValueError,
+ dt.replace(tzinfo=bog).astimezone, f)
+
+ class AlsoBogus(tzinfo):
+ def utcoffset(self, dt): return timedelta(0)
+ def dst(self, dt): return None
+ alsobog = AlsoBogus()
+ self.assertRaises(ValueError, dt.astimezone, alsobog) # also naive
+
+ def test_subclass_datetime(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.year + self.month + self.second
+
+ args = 2003, 4, 14, 12, 13, 41
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.toordinal(), dt2.toordinal())
+ self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month +
+ dt1.second - 7)
+
+class TestSubclassDateTime(TestDateTime):
+ theclass = SubclassDatetime
+ # Override tests not designed for subclass
+ def test_roundtrip(self):
+ pass
+
+class SubclassTime(time):
+ sub_var = 1
+
+class TestTime(HarmlessMixedComparison, unittest.TestCase):
+
+ theclass = time
+
+ def test_basic_attributes(self):
+ t = self.theclass(12, 0)
+ self.assertEqual(t.hour, 12)
+ self.assertEqual(t.minute, 0)
+ self.assertEqual(t.second, 0)
+ self.assertEqual(t.microsecond, 0)
+
+ def test_basic_attributes_nonzero(self):
+ # Make sure all attributes are non-zero so bugs in
+ # bit-shifting access show up.
+ t = self.theclass(12, 59, 59, 8000)
+ self.assertEqual(t.hour, 12)
+ self.assertEqual(t.minute, 59)
+ self.assertEqual(t.second, 59)
+ self.assertEqual(t.microsecond, 8000)
+
+ def test_roundtrip(self):
+ t = self.theclass(1, 2, 3, 4)
+
+ # Verify t -> string -> time identity.
+ s = repr(t)
+ self.assertTrue(s.startswith('datetime.'))
+ s = s[9:]
+ t2 = eval(s)
+ self.assertEqual(t, t2)
+
+ # Verify identity via reconstructing from pieces.
+ t2 = self.theclass(t.hour, t.minute, t.second,
+ t.microsecond)
+ self.assertEqual(t, t2)
+
+ def test_comparing(self):
+ args = [1, 2, 3, 4]
+ t1 = self.theclass(*args)
+ t2 = self.theclass(*args)
+ self.assertEqual(t1, t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
+
+ for i in range(len(args)):
+ newargs = args[:]
+ newargs[i] = args[i] + 1
+ t2 = self.theclass(*newargs) # this is larger than t1
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
+
+ for badarg in OTHERSTUFF:
+ self.assertEqual(t1 == badarg, False)
+ self.assertEqual(t1 != badarg, True)
+ self.assertEqual(badarg == t1, False)
+ self.assertEqual(badarg != t1, True)
+
+ self.assertRaises(TypeError, lambda: t1 <= badarg)
+ self.assertRaises(TypeError, lambda: t1 < badarg)
+ self.assertRaises(TypeError, lambda: t1 > badarg)
+ self.assertRaises(TypeError, lambda: t1 >= badarg)
+ self.assertRaises(TypeError, lambda: badarg <= t1)
+ self.assertRaises(TypeError, lambda: badarg < t1)
+ self.assertRaises(TypeError, lambda: badarg > t1)
+ self.assertRaises(TypeError, lambda: badarg >= t1)
+
+ def test_bad_constructor_arguments(self):
+ # bad hours
+ self.theclass(0, 0) # no exception
+ self.theclass(23, 0) # no exception
+ self.assertRaises(ValueError, self.theclass, -1, 0)
+ self.assertRaises(ValueError, self.theclass, 24, 0)
+ # bad minutes
+ self.theclass(23, 0) # no exception
+ self.theclass(23, 59) # no exception
+ self.assertRaises(ValueError, self.theclass, 23, -1)
+ self.assertRaises(ValueError, self.theclass, 23, 60)
+ # bad seconds
+ self.theclass(23, 59, 0) # no exception
+ self.theclass(23, 59, 59) # no exception
+ self.assertRaises(ValueError, self.theclass, 23, 59, -1)
+ self.assertRaises(ValueError, self.theclass, 23, 59, 60)
+ # bad microseconds
+ self.theclass(23, 59, 59, 0) # no exception
+ self.theclass(23, 59, 59, 999999) # no exception
+ self.assertRaises(ValueError, self.theclass, 23, 59, 59, -1)
+ self.assertRaises(ValueError, self.theclass, 23, 59, 59, 1000000)
+
+ def test_hash_equality(self):
+ d = self.theclass(23, 30, 17)
+ e = self.theclass(23, 30, 17)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ d = self.theclass(0, 5, 17)
+ e = self.theclass(0, 5, 17)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ def test_isoformat(self):
+ t = self.theclass(4, 5, 1, 123)
+ self.assertEqual(t.isoformat(), "04:05:01.000123")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass()
+ self.assertEqual(t.isoformat(), "00:00:00")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=1)
+ self.assertEqual(t.isoformat(), "00:00:00.000001")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=10)
+ self.assertEqual(t.isoformat(), "00:00:00.000010")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=100)
+ self.assertEqual(t.isoformat(), "00:00:00.000100")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=1000)
+ self.assertEqual(t.isoformat(), "00:00:00.001000")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=10000)
+ self.assertEqual(t.isoformat(), "00:00:00.010000")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=100000)
+ self.assertEqual(t.isoformat(), "00:00:00.100000")
+ self.assertEqual(t.isoformat(), str(t))
+
+ def test_1653736(self):
+ # verify it doesn't accept extra keyword arguments
+ t = self.theclass(second=1)
+ self.assertRaises(TypeError, t.isoformat, foo=3)
+
+ def test_strftime(self):
+ t = self.theclass(1, 2, 3, 4)
+ self.assertEqual(t.strftime('%H %M %S %f'), "01 02 03 000004")
+ # A naive object replaces %z and %Z with empty strings.
+ self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
+
+ def test_format(self):
+ t = self.theclass(1, 2, 3, 4)
+ self.assertEqual(t.__format__(''), str(t))
+
+ # check that a derived class's __str__() gets called
+ class A(self.theclass):
+ def __str__(self):
+ return 'A'
+ a = A(1, 2, 3, 4)
+ self.assertEqual(a.__format__(''), 'A')
+
+ # check that a derived class's strftime gets called
+ class B(self.theclass):
+ def strftime(self, format_spec):
+ return 'B'
+ b = B(1, 2, 3, 4)
+ self.assertEqual(b.__format__(''), str(t))
+
+ for fmt in ['%H %M %S',
+ ]:
+ self.assertEqual(t.__format__(fmt), t.strftime(fmt))
+ self.assertEqual(a.__format__(fmt), t.strftime(fmt))
+ self.assertEqual(b.__format__(fmt), 'B')
+
+ def test_str(self):
+ self.assertEqual(str(self.theclass(1, 2, 3, 4)), "01:02:03.000004")
+ self.assertEqual(str(self.theclass(10, 2, 3, 4000)), "10:02:03.004000")
+ self.assertEqual(str(self.theclass(0, 2, 3, 400000)), "00:02:03.400000")
+ self.assertEqual(str(self.theclass(12, 2, 3, 0)), "12:02:03")
+ self.assertEqual(str(self.theclass(23, 15, 0, 0)), "23:15:00")
+
+ def test_repr(self):
+ name = 'datetime.' + self.theclass.__name__
+ self.assertEqual(repr(self.theclass(1, 2, 3, 4)),
+ "%s(1, 2, 3, 4)" % name)
+ self.assertEqual(repr(self.theclass(10, 2, 3, 4000)),
+ "%s(10, 2, 3, 4000)" % name)
+ self.assertEqual(repr(self.theclass(0, 2, 3, 400000)),
+ "%s(0, 2, 3, 400000)" % name)
+ self.assertEqual(repr(self.theclass(12, 2, 3, 0)),
+ "%s(12, 2, 3)" % name)
+ self.assertEqual(repr(self.theclass(23, 15, 0, 0)),
+ "%s(23, 15)" % name)
+
+ def test_resolution_info(self):
+ self.assertIsInstance(self.theclass.min, self.theclass)
+ self.assertIsInstance(self.theclass.max, self.theclass)
+ self.assertIsInstance(self.theclass.resolution, timedelta)
+ self.assertTrue(self.theclass.max > self.theclass.min)
+
+ def test_pickling(self):
+ args = 20, 59, 16, 64**2
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_pickling_subclass_time(self):
+ args = 20, 59, 16, 64**2
+ orig = SubclassTime(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_bool(self):
+ cls = self.theclass
+ self.assertTrue(cls(1))
+ self.assertTrue(cls(0, 1))
+ self.assertTrue(cls(0, 0, 1))
+ self.assertTrue(cls(0, 0, 0, 1))
+ self.assertTrue(not cls(0))
+ self.assertTrue(not cls())
+
+ def test_replace(self):
+ cls = self.theclass
+ args = [1, 2, 3, 4]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("hour", 5),
+ ("minute", 6),
+ ("second", 7),
+ ("microsecond", 8)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Out of bounds.
+ base = cls(1)
+ self.assertRaises(ValueError, base.replace, hour=24)
+ self.assertRaises(ValueError, base.replace, minute=-1)
+ self.assertRaises(ValueError, base.replace, second=100)
+ self.assertRaises(ValueError, base.replace, microsecond=1000000)
+
+ def test_subclass_time(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.hour + self.second
+
+ args = 4, 5, 6
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.isoformat(), dt2.isoformat())
+ self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
+
+ def test_backdoor_resistance(self):
+ # see TestDate.test_backdoor_resistance().
+ base = '2:59.0'
+ for hour_byte in ' ', '9', chr(24), '\xff':
+ self.assertRaises(TypeError, self.theclass,
+ hour_byte + base[1:])
+
+# A mixin for classes with a tzinfo= argument. Subclasses must define
+# theclass as a class atribute, and theclass(1, 1, 1, tzinfo=whatever)
+# must be legit (which is true for time and datetime).
+class TZInfoBase:
+
+ def test_argument_passing(self):
+ cls = self.theclass
+ # A datetime passes itself on, a time passes None.
+ class introspective(tzinfo):
+ def tzname(self, dt): return dt and "real" or "none"
+ def utcoffset(self, dt):
+ return timedelta(minutes = dt and 42 or -42)
+ dst = utcoffset
+
+ obj = cls(1, 2, 3, tzinfo=introspective())
+
+ expected = cls is time and "none" or "real"
+ self.assertEqual(obj.tzname(), expected)
+
+ expected = timedelta(minutes=(cls is time and -42 or 42))
+ self.assertEqual(obj.utcoffset(), expected)
+ self.assertEqual(obj.dst(), expected)
+
+ def test_bad_tzinfo_classes(self):
+ cls = self.theclass
+ self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=12)
+
+ class NiceTry(object):
+ def __init__(self): pass
+ def utcoffset(self, dt): pass
+ self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=NiceTry)
+
+ class BetterTry(tzinfo):
+ def __init__(self): pass
+ def utcoffset(self, dt): pass
+ b = BetterTry()
+ t = cls(1, 1, 1, tzinfo=b)
+ self.assertTrue(t.tzinfo is b)
+
+ def test_utc_offset_out_of_bounds(self):
+ class Edgy(tzinfo):
+ def __init__(self, offset):
+ self.offset = timedelta(minutes=offset)
+ def utcoffset(self, dt):
+ return self.offset
+
+ cls = self.theclass
+ for offset, legit in ((-1440, False),
+ (-1439, True),
+ (1439, True),
+ (1440, False)):
+ if cls is time:
+ t = cls(1, 2, 3, tzinfo=Edgy(offset))
+ elif cls is datetime:
+ t = cls(6, 6, 6, 1, 2, 3, tzinfo=Edgy(offset))
+ else:
+ assert 0, "impossible"
+ if legit:
+ aofs = abs(offset)
+ h, m = divmod(aofs, 60)
+ tag = "%c%02d:%02d" % (offset < 0 and '-' or '+', h, m)
+ if isinstance(t, datetime):
+ t = t.timetz()
+ self.assertEqual(str(t), "01:02:03" + tag)
+ else:
+ self.assertRaises(ValueError, str, t)
+
+ def test_tzinfo_classes(self):
+ cls = self.theclass
+ class C1(tzinfo):
+ def utcoffset(self, dt): return None
+ def dst(self, dt): return None
+ def tzname(self, dt): return None
+ for t in (cls(1, 1, 1),
+ cls(1, 1, 1, tzinfo=None),
+ cls(1, 1, 1, tzinfo=C1())):
+ self.assertTrue(t.utcoffset() is None)
+ self.assertTrue(t.dst() is None)
+ self.assertTrue(t.tzname() is None)
+
+ class C3(tzinfo):
+ def utcoffset(self, dt): return timedelta(minutes=-1439)
+ def dst(self, dt): return timedelta(minutes=1439)
+ def tzname(self, dt): return "aname"
+ t = cls(1, 1, 1, tzinfo=C3())
+ self.assertEqual(t.utcoffset(), timedelta(minutes=-1439))
+ self.assertEqual(t.dst(), timedelta(minutes=1439))
+ self.assertEqual(t.tzname(), "aname")
+
+ # Wrong types.
+ class C4(tzinfo):
+ def utcoffset(self, dt): return "aname"
+ def dst(self, dt): return 7
+ def tzname(self, dt): return 0
+ t = cls(1, 1, 1, tzinfo=C4())
+ self.assertRaises(TypeError, t.utcoffset)
+ self.assertRaises(TypeError, t.dst)
+ self.assertRaises(TypeError, t.tzname)
+
+ # Offset out of range.
+ class C6(tzinfo):
+ def utcoffset(self, dt): return timedelta(hours=-24)
+ def dst(self, dt): return timedelta(hours=24)
+ t = cls(1, 1, 1, tzinfo=C6())
+ self.assertRaises(ValueError, t.utcoffset)
+ self.assertRaises(ValueError, t.dst)
+
+ # Not a whole number of minutes.
+ class C7(tzinfo):
+ def utcoffset(self, dt): return timedelta(seconds=61)
+ def dst(self, dt): return timedelta(microseconds=-81)
+ t = cls(1, 1, 1, tzinfo=C7())
+ self.assertRaises(ValueError, t.utcoffset)
+ self.assertRaises(ValueError, t.dst)
+
+ def test_aware_compare(self):
+ cls = self.theclass
+
+ # Ensure that utcoffset() gets ignored if the comparands have
+ # the same tzinfo member.
+ class OperandDependentOffset(tzinfo):
+ def utcoffset(self, t):
+ if t.minute < 10:
+ # d0 and d1 equal after adjustment
+ return timedelta(minutes=t.minute)
+ else:
+ # d2 off in the weeds
+ return timedelta(minutes=59)
+
+ base = cls(8, 9, 10, tzinfo=OperandDependentOffset())
+ d0 = base.replace(minute=3)
+ d1 = base.replace(minute=9)
+ d2 = base.replace(minute=11)
+ for x in d0, d1, d2:
+ for y in d0, d1, d2:
+ for op in lt, le, gt, ge, eq, ne:
+ got = op(x, y)
+ expected = op(x.minute, y.minute)
+ self.assertEqual(got, expected)
+
+ # However, if they're different members, uctoffset is not ignored.
+ # Note that a time can't actually have an operand-depedent offset,
+ # though (and time.utcoffset() passes None to tzinfo.utcoffset()),
+ # so skip this test for time.
+ if cls is not time:
+ d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
+ d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
+ d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
+ for x in d0, d1, d2:
+ for y in d0, d1, d2:
+ got = (x > y) - (x < y)
+ if (x is d0 or x is d1) and (y is d0 or y is d1):
+ expected = 0
+ elif x is y is d2:
+ expected = 0
+ elif x is d2:
+ expected = -1
+ else:
+ assert y is d2
+ expected = 1
+ self.assertEqual(got, expected)
+
+
+# Testing time objects with a non-None tzinfo.
+class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
+ theclass = time
+
+ def test_empty(self):
+ t = self.theclass()
+ self.assertEqual(t.hour, 0)
+ self.assertEqual(t.minute, 0)
+ self.assertEqual(t.second, 0)
+ self.assertEqual(t.microsecond, 0)
+ self.assertTrue(t.tzinfo is None)
+
+ def test_zones(self):
+ est = FixedOffset(-300, "EST", 1)
+ utc = FixedOffset(0, "UTC", -2)
+ met = FixedOffset(60, "MET", 3)
+ t1 = time( 7, 47, tzinfo=est)
+ t2 = time(12, 47, tzinfo=utc)
+ t3 = time(13, 47, tzinfo=met)
+ t4 = time(microsecond=40)
+ t5 = time(microsecond=40, tzinfo=utc)
+
+ self.assertEqual(t1.tzinfo, est)
+ self.assertEqual(t2.tzinfo, utc)
+ self.assertEqual(t3.tzinfo, met)
+ self.assertTrue(t4.tzinfo is None)
+ self.assertEqual(t5.tzinfo, utc)
+
+ self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
+ self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
+ self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
+ self.assertTrue(t4.utcoffset() is None)
+ self.assertRaises(TypeError, t1.utcoffset, "no args")
+
+ self.assertEqual(t1.tzname(), "EST")
+ self.assertEqual(t2.tzname(), "UTC")
+ self.assertEqual(t3.tzname(), "MET")
+ self.assertTrue(t4.tzname() is None)
+ self.assertRaises(TypeError, t1.tzname, "no args")
+
+ self.assertEqual(t1.dst(), timedelta(minutes=1))
+ self.assertEqual(t2.dst(), timedelta(minutes=-2))
+ self.assertEqual(t3.dst(), timedelta(minutes=3))
+ self.assertTrue(t4.dst() is None)
+ self.assertRaises(TypeError, t1.dst, "no args")
+
+ self.assertEqual(hash(t1), hash(t2))
+ self.assertEqual(hash(t1), hash(t3))
+ self.assertEqual(hash(t2), hash(t3))
+
+ self.assertEqual(t1, t2)
+ self.assertEqual(t1, t3)
+ self.assertEqual(t2, t3)
+ self.assertRaises(TypeError, lambda: t4 == t5) # mixed tz-aware & naive
+ self.assertRaises(TypeError, lambda: t4 < t5) # mixed tz-aware & naive
+ self.assertRaises(TypeError, lambda: t5 < t4) # mixed tz-aware & naive
+
+ self.assertEqual(str(t1), "07:47:00-05:00")
+ self.assertEqual(str(t2), "12:47:00+00:00")
+ self.assertEqual(str(t3), "13:47:00+01:00")
+ self.assertEqual(str(t4), "00:00:00.000040")
+ self.assertEqual(str(t5), "00:00:00.000040+00:00")
+
+ self.assertEqual(t1.isoformat(), "07:47:00-05:00")
+ self.assertEqual(t2.isoformat(), "12:47:00+00:00")
+ self.assertEqual(t3.isoformat(), "13:47:00+01:00")
+ self.assertEqual(t4.isoformat(), "00:00:00.000040")
+ self.assertEqual(t5.isoformat(), "00:00:00.000040+00:00")
+
+ d = 'datetime.time'
+ self.assertEqual(repr(t1), d + "(7, 47, tzinfo=est)")
+ self.assertEqual(repr(t2), d + "(12, 47, tzinfo=utc)")
+ self.assertEqual(repr(t3), d + "(13, 47, tzinfo=met)")
+ self.assertEqual(repr(t4), d + "(0, 0, 0, 40)")
+ self.assertEqual(repr(t5), d + "(0, 0, 0, 40, tzinfo=utc)")
+
+ self.assertEqual(t1.strftime("%H:%M:%S %%Z=%Z %%z=%z"),
+ "07:47:00 %Z=EST %z=-0500")
+ self.assertEqual(t2.strftime("%H:%M:%S %Z %z"), "12:47:00 UTC +0000")
+ self.assertEqual(t3.strftime("%H:%M:%S %Z %z"), "13:47:00 MET +0100")
+
+ yuck = FixedOffset(-1439, "%z %Z %%z%%Z")
+ t1 = time(23, 59, tzinfo=yuck)
+ self.assertEqual(t1.strftime("%H:%M %%Z='%Z' %%z='%z'"),
+ "23:59 %Z='%z %Z %%z%%Z' %z='-2359'")
+
+ # Check that an invalid tzname result raises an exception.
+ class Badtzname(tzinfo):
+ tz = 42
+ def tzname(self, dt): return self.tz
+ t = time(2, 3, 4, tzinfo=Badtzname())
+ self.assertEqual(t.strftime("%H:%M:%S"), "02:03:04")
+ self.assertRaises(TypeError, t.strftime, "%Z")
+
+ # Issue #6697:
+ if '_Fast' in str(type(self)):
+ Badtzname.tz = '\ud800'
+ self.assertRaises(ValueError, t.strftime, "%Z")
+
+ def test_hash_edge_cases(self):
+ # Offsets that overflow a basic time.
+ t1 = self.theclass(0, 1, 2, 3, tzinfo=FixedOffset(1439, ""))
+ t2 = self.theclass(0, 0, 2, 3, tzinfo=FixedOffset(1438, ""))
+ self.assertEqual(hash(t1), hash(t2))
+
+ t1 = self.theclass(23, 58, 6, 100, tzinfo=FixedOffset(-1000, ""))
+ t2 = self.theclass(23, 48, 6, 100, tzinfo=FixedOffset(-1010, ""))
+ self.assertEqual(hash(t1), hash(t2))
+
+ def test_pickling(self):
+ # Try one without a tzinfo.
+ args = 20, 59, 16, 64**2
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ # Try one with a tzinfo.
+ tinfo = PicklableFixedOffset(-300, 'cookie')
+ orig = self.theclass(5, 6, 7, tzinfo=tinfo)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+ self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
+ self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
+ self.assertEqual(derived.tzname(), 'cookie')
+
+ def test_more_bool(self):
+ # Test cases with non-None tzinfo.
+ cls = self.theclass
+
+ t = cls(0, tzinfo=FixedOffset(-300, ""))
+ self.assertTrue(t)
+
+ t = cls(5, tzinfo=FixedOffset(-300, ""))
+ self.assertTrue(t)
+
+ t = cls(5, tzinfo=FixedOffset(300, ""))
+ self.assertTrue(not t)
+
+ t = cls(23, 59, tzinfo=FixedOffset(23*60 + 59, ""))
+ self.assertTrue(not t)
+
+ # Mostly ensuring this doesn't overflow internally.
+ t = cls(0, tzinfo=FixedOffset(23*60 + 59, ""))
+ self.assertTrue(t)
+
+ # But this should yield a value error -- the utcoffset is bogus.
+ t = cls(0, tzinfo=FixedOffset(24*60, ""))
+ self.assertRaises(ValueError, lambda: bool(t))
+
+ # Likewise.
+ t = cls(0, tzinfo=FixedOffset(-24*60, ""))
+ self.assertRaises(ValueError, lambda: bool(t))
+
+ def test_replace(self):
+ cls = self.theclass
+ z100 = FixedOffset(100, "+100")
+ zm200 = FixedOffset(timedelta(minutes=-200), "-200")
+ args = [1, 2, 3, 4, z100]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("hour", 5),
+ ("minute", 6),
+ ("second", 7),
+ ("microsecond", 8),
+ ("tzinfo", zm200)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Ensure we can get rid of a tzinfo.
+ self.assertEqual(base.tzname(), "+100")
+ base2 = base.replace(tzinfo=None)
+ self.assertTrue(base2.tzinfo is None)
+ self.assertTrue(base2.tzname() is None)
+
+ # Ensure we can add one.
+ base3 = base2.replace(tzinfo=z100)
+ self.assertEqual(base, base3)
+ self.assertTrue(base.tzinfo is base3.tzinfo)
+
+ # Out of bounds.
+ base = cls(1)
+ self.assertRaises(ValueError, base.replace, hour=24)
+ self.assertRaises(ValueError, base.replace, minute=-1)
+ self.assertRaises(ValueError, base.replace, second=100)
+ self.assertRaises(ValueError, base.replace, microsecond=1000000)
+
+ def test_mixed_compare(self):
+ t1 = time(1, 2, 3)
+ t2 = time(1, 2, 3)
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=None)
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=FixedOffset(None, ""))
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=FixedOffset(0, ""))
+ self.assertRaises(TypeError, lambda: t1 == t2)
+
+ # In time w/ identical tzinfo objects, utcoffset is ignored.
+ class Varies(tzinfo):
+ def __init__(self):
+ self.offset = timedelta(minutes=22)
+ def utcoffset(self, t):
+ self.offset += timedelta(minutes=1)
+ return self.offset
+
+ v = Varies()
+ t1 = t2.replace(tzinfo=v)
+ t2 = t2.replace(tzinfo=v)
+ self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
+ self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
+ self.assertEqual(t1, t2)
+
+ # But if they're not identical, it isn't ignored.
+ t2 = t2.replace(tzinfo=Varies())
+ self.assertTrue(t1 < t2) # t1's offset counter still going up
+
+ def test_subclass_timetz(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.hour + self.second
+
+ args = 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
+ self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
+
+
+# Testing datetime objects with a non-None tzinfo.
+
+class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
+ theclass = datetime
+
+ def test_trivial(self):
+ dt = self.theclass(1, 2, 3, 4, 5, 6, 7)
+ self.assertEqual(dt.year, 1)
+ self.assertEqual(dt.month, 2)
+ self.assertEqual(dt.day, 3)
+ self.assertEqual(dt.hour, 4)
+ self.assertEqual(dt.minute, 5)
+ self.assertEqual(dt.second, 6)
+ self.assertEqual(dt.microsecond, 7)
+ self.assertEqual(dt.tzinfo, None)
+
+ def test_even_more_compare(self):
+ # The test_compare() and test_more_compare() inherited from TestDate
+ # and TestDateTime covered non-tzinfo cases.
+
+ # Smallest possible after UTC adjustment.
+ t1 = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
+ # Largest possible after UTC adjustment.
+ t2 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
+ tzinfo=FixedOffset(-1439, ""))
+
+ # Make sure those compare correctly, and w/o overflow.
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 > t1)
+
+ self.assertEqual(t1, t1)
+ self.assertEqual(t2, t2)
+
+ # Equal afer adjustment.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""))
+ t2 = self.theclass(2, 1, 1, 3, 13, tzinfo=FixedOffset(3*60+13+2, ""))
+ self.assertEqual(t1, t2)
+
+ # Change t1 not to subtract a minute, and t1 should be larger.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(0, ""))
+ self.assertTrue(t1 > t2)
+
+ # Change t1 to subtract 2 minutes, and t1 should be smaller.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(2, ""))
+ self.assertTrue(t1 < t2)
+
+ # Back to the original t1, but make seconds resolve it.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
+ second=1)
+ self.assertTrue(t1 > t2)
+
+ # Likewise, but make microseconds resolve it.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
+ microsecond=1)
+ self.assertTrue(t1 > t2)
+
+ # Make t2 naive and it should fail.
+ t2 = self.theclass.min
+ self.assertRaises(TypeError, lambda: t1 == t2)
+ self.assertEqual(t2, t2)
+
+ # It's also naive if it has tzinfo but tzinfo.utcoffset() is None.
+ class Naive(tzinfo):
+ def utcoffset(self, dt): return None
+ t2 = self.theclass(5, 6, 7, tzinfo=Naive())
+ self.assertRaises(TypeError, lambda: t1 == t2)
+ self.assertEqual(t2, t2)
+
+ # OTOH, it's OK to compare two of these mixing the two ways of being
+ # naive.
+ t1 = self.theclass(5, 6, 7)
+ self.assertEqual(t1, t2)
+
+ # Try a bogus uctoffset.
+ class Bogus(tzinfo):
+ def utcoffset(self, dt):
+ return timedelta(minutes=1440) # out of bounds
+ t1 = self.theclass(2, 2, 2, tzinfo=Bogus())
+ t2 = self.theclass(2, 2, 2, tzinfo=FixedOffset(0, ""))
+ self.assertRaises(ValueError, lambda: t1 == t2)
+
+ def test_pickling(self):
+ # Try one without a tzinfo.
+ args = 6, 7, 23, 20, 59, 1, 64**2
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ # Try one with a tzinfo.
+ tinfo = PicklableFixedOffset(-300, 'cookie')
+ orig = self.theclass(*args, **{'tzinfo': tinfo})
+ derived = self.theclass(1, 1, 1, tzinfo=FixedOffset(0, "", 0))
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+ self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
+ self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
+ self.assertEqual(derived.tzname(), 'cookie')
+
+ def test_extreme_hashes(self):
+ # If an attempt is made to hash these via subtracting the offset
+ # then hashing a datetime object, OverflowError results. The
+ # Python implementation used to blow up here.
+ t = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
+ hash(t)
+ t = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
+ tzinfo=FixedOffset(-1439, ""))
+ hash(t)
+
+ # OTOH, an OOB offset should blow up.
+ t = self.theclass(5, 5, 5, tzinfo=FixedOffset(-1440, ""))
+ self.assertRaises(ValueError, hash, t)
+
+ def test_zones(self):
+ est = FixedOffset(-300, "EST")
+ utc = FixedOffset(0, "UTC")
+ met = FixedOffset(60, "MET")
+ t1 = datetime(2002, 3, 19, 7, 47, tzinfo=est)
+ t2 = datetime(2002, 3, 19, 12, 47, tzinfo=utc)
+ t3 = datetime(2002, 3, 19, 13, 47, tzinfo=met)
+ self.assertEqual(t1.tzinfo, est)
+ self.assertEqual(t2.tzinfo, utc)
+ self.assertEqual(t3.tzinfo, met)
+ self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
+ self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
+ self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
+ self.assertEqual(t1.tzname(), "EST")
+ self.assertEqual(t2.tzname(), "UTC")
+ self.assertEqual(t3.tzname(), "MET")
+ self.assertEqual(hash(t1), hash(t2))
+ self.assertEqual(hash(t1), hash(t3))
+ self.assertEqual(hash(t2), hash(t3))
+ self.assertEqual(t1, t2)
+ self.assertEqual(t1, t3)
+ self.assertEqual(t2, t3)
+ self.assertEqual(str(t1), "2002-03-19 07:47:00-05:00")
+ self.assertEqual(str(t2), "2002-03-19 12:47:00+00:00")
+ self.assertEqual(str(t3), "2002-03-19 13:47:00+01:00")
+ d = 'datetime.datetime(2002, 3, 19, '
+ self.assertEqual(repr(t1), d + "7, 47, tzinfo=est)")
+ self.assertEqual(repr(t2), d + "12, 47, tzinfo=utc)")
+ self.assertEqual(repr(t3), d + "13, 47, tzinfo=met)")
+
+ def test_combine(self):
+ met = FixedOffset(60, "MET")
+ d = date(2002, 3, 4)
+ tz = time(18, 45, 3, 1234, tzinfo=met)
+ dt = datetime.combine(d, tz)
+ self.assertEqual(dt, datetime(2002, 3, 4, 18, 45, 3, 1234,
+ tzinfo=met))
+
+ def test_extract(self):
+ met = FixedOffset(60, "MET")
+ dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234, tzinfo=met)
+ self.assertEqual(dt.date(), date(2002, 3, 4))
+ self.assertEqual(dt.time(), time(18, 45, 3, 1234))
+ self.assertEqual(dt.timetz(), time(18, 45, 3, 1234, tzinfo=met))
+
+ def test_tz_aware_arithmetic(self):
+ import random
+
+ now = self.theclass.now()
+ tz55 = FixedOffset(-330, "west 5:30")
+ timeaware = now.time().replace(tzinfo=tz55)
+ nowaware = self.theclass.combine(now.date(), timeaware)
+ self.assertTrue(nowaware.tzinfo is tz55)
+ self.assertEqual(nowaware.timetz(), timeaware)
+
+ # Can't mix aware and non-aware.
+ self.assertRaises(TypeError, lambda: now - nowaware)
+ self.assertRaises(TypeError, lambda: nowaware - now)
+
+ # And adding datetime's doesn't make sense, aware or not.
+ self.assertRaises(TypeError, lambda: now + nowaware)
+ self.assertRaises(TypeError, lambda: nowaware + now)
+ self.assertRaises(TypeError, lambda: nowaware + nowaware)
+
+ # Subtracting should yield 0.
+ self.assertEqual(now - now, timedelta(0))
+ self.assertEqual(nowaware - nowaware, timedelta(0))
+
+ # Adding a delta should preserve tzinfo.
+ delta = timedelta(weeks=1, minutes=12, microseconds=5678)
+ nowawareplus = nowaware + delta
+ self.assertTrue(nowaware.tzinfo is tz55)
+ nowawareplus2 = delta + nowaware
+ self.assertTrue(nowawareplus2.tzinfo is tz55)
+ self.assertEqual(nowawareplus, nowawareplus2)
+
+ # that - delta should be what we started with, and that - what we
+ # started with should be delta.
+ diff = nowawareplus - delta
+ self.assertTrue(diff.tzinfo is tz55)
+ self.assertEqual(nowaware, diff)
+ self.assertRaises(TypeError, lambda: delta - nowawareplus)
+ self.assertEqual(nowawareplus - nowaware, delta)
+
+ # Make up a random timezone.
+ tzr = FixedOffset(random.randrange(-1439, 1440), "randomtimezone")
+ # Attach it to nowawareplus.
+ nowawareplus = nowawareplus.replace(tzinfo=tzr)
+ self.assertTrue(nowawareplus.tzinfo is tzr)
+ # Make sure the difference takes the timezone adjustments into account.
+ got = nowaware - nowawareplus
+ # Expected: (nowaware base - nowaware offset) -
+ # (nowawareplus base - nowawareplus offset) =
+ # (nowaware base - nowawareplus base) +
+ # (nowawareplus offset - nowaware offset) =
+ # -delta + nowawareplus offset - nowaware offset
+ expected = nowawareplus.utcoffset() - nowaware.utcoffset() - delta
+ self.assertEqual(got, expected)
+
+ # Try max possible difference.
+ min = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, "min"))
+ max = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
+ tzinfo=FixedOffset(-1439, "max"))
+ maxdiff = max - min
+ self.assertEqual(maxdiff, self.theclass.max - self.theclass.min +
+ timedelta(minutes=2*1439))
+ # Different tzinfo, but the same offset
+ tza = timezone(HOUR, 'A')
+ tzb = timezone(HOUR, 'B')
+ delta = min.replace(tzinfo=tza) - max.replace(tzinfo=tzb)
+ self.assertEqual(delta, self.theclass.min - self.theclass.max)
+
+ def test_tzinfo_now(self):
+ meth = self.theclass.now
+ # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
+ base = meth()
+ # Try with and without naming the keyword.
+ off42 = FixedOffset(42, "42")
+ another = meth(off42)
+ again = meth(tz=off42)
+ self.assertTrue(another.tzinfo is again.tzinfo)
+ self.assertEqual(another.utcoffset(), timedelta(minutes=42))
+ # Bad argument with and w/o naming the keyword.
+ self.assertRaises(TypeError, meth, 16)
+ self.assertRaises(TypeError, meth, tzinfo=16)
+ # Bad keyword name.
+ self.assertRaises(TypeError, meth, tinfo=off42)
+ # Too many args.
+ self.assertRaises(TypeError, meth, off42, off42)
+
+ # We don't know which time zone we're in, and don't have a tzinfo
+ # class to represent it, so seeing whether a tz argument actually
+ # does a conversion is tricky.
+ utc = FixedOffset(0, "utc", 0)
+ for weirdtz in [FixedOffset(timedelta(hours=15, minutes=58), "weirdtz", 0),
+ timezone(timedelta(hours=15, minutes=58), "weirdtz"),]:
+ for dummy in range(3):
+ now = datetime.now(weirdtz)
+ self.assertTrue(now.tzinfo is weirdtz)
+ utcnow = datetime.utcnow().replace(tzinfo=utc)
+ now2 = utcnow.astimezone(weirdtz)
+ if abs(now - now2) < timedelta(seconds=30):
+ break
+ # Else the code is broken, or more than 30 seconds passed between
+ # calls; assuming the latter, just try again.
+ else:
+ # Three strikes and we're out.
+ self.fail("utcnow(), now(tz), or astimezone() may be broken")
+
+ def test_tzinfo_fromtimestamp(self):
+ import time
+ meth = self.theclass.fromtimestamp
+ ts = time.time()
+ # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
+ base = meth(ts)
+ # Try with and without naming the keyword.
+ off42 = FixedOffset(42, "42")
+ another = meth(ts, off42)
+ again = meth(ts, tz=off42)
+ self.assertTrue(another.tzinfo is again.tzinfo)
+ self.assertEqual(another.utcoffset(), timedelta(minutes=42))
+ # Bad argument with and w/o naming the keyword.
+ self.assertRaises(TypeError, meth, ts, 16)
+ self.assertRaises(TypeError, meth, ts, tzinfo=16)
+ # Bad keyword name.
+ self.assertRaises(TypeError, meth, ts, tinfo=off42)
+ # Too many args.
+ self.assertRaises(TypeError, meth, ts, off42, off42)
+ # Too few args.
+ self.assertRaises(TypeError, meth)
+
+ # Try to make sure tz= actually does some conversion.
+ timestamp = 1000000000
+ utcdatetime = datetime.utcfromtimestamp(timestamp)
+ # In POSIX (epoch 1970), that's 2001-09-09 01:46:40 UTC, give or take.
+ # But on some flavor of Mac, it's nowhere near that. So we can't have
+ # any idea here what time that actually is, we can only test that
+ # relative changes match.
+ utcoffset = timedelta(hours=-15, minutes=39) # arbitrary, but not zero
+ tz = FixedOffset(utcoffset, "tz", 0)
+ expected = utcdatetime + utcoffset
+ got = datetime.fromtimestamp(timestamp, tz)
+ self.assertEqual(expected, got.replace(tzinfo=None))
+
+ def test_tzinfo_utcnow(self):
+ meth = self.theclass.utcnow
+ # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
+ base = meth()
+ # Try with and without naming the keyword; for whatever reason,
+ # utcnow() doesn't accept a tzinfo argument.
+ off42 = FixedOffset(42, "42")
+ self.assertRaises(TypeError, meth, off42)
+ self.assertRaises(TypeError, meth, tzinfo=off42)
+
+ def test_tzinfo_utcfromtimestamp(self):
+ import time
+ meth = self.theclass.utcfromtimestamp
+ ts = time.time()
+ # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
+ base = meth(ts)
+ # Try with and without naming the keyword; for whatever reason,
+ # utcfromtimestamp() doesn't accept a tzinfo argument.
+ off42 = FixedOffset(42, "42")
+ self.assertRaises(TypeError, meth, ts, off42)
+ self.assertRaises(TypeError, meth, ts, tzinfo=off42)
+
+ def test_tzinfo_timetuple(self):
+ # TestDateTime tested most of this. datetime adds a twist to the
+ # DST flag.
+ class DST(tzinfo):
+ def __init__(self, dstvalue):
+ if isinstance(dstvalue, int):
+ dstvalue = timedelta(minutes=dstvalue)
+ self.dstvalue = dstvalue
+ def dst(self, dt):
+ return self.dstvalue
+
+ cls = self.theclass
+ for dstvalue, flag in (-33, 1), (33, 1), (0, 0), (None, -1):
+ d = cls(1, 1, 1, 10, 20, 30, 40, tzinfo=DST(dstvalue))
+ t = d.timetuple()
+ self.assertEqual(1, t.tm_year)
+ self.assertEqual(1, t.tm_mon)
+ self.assertEqual(1, t.tm_mday)
+ self.assertEqual(10, t.tm_hour)
+ self.assertEqual(20, t.tm_min)
+ self.assertEqual(30, t.tm_sec)
+ self.assertEqual(0, t.tm_wday)
+ self.assertEqual(1, t.tm_yday)
+ self.assertEqual(flag, t.tm_isdst)
+
+ # dst() returns wrong type.
+ self.assertRaises(TypeError, cls(1, 1, 1, tzinfo=DST("x")).timetuple)
+
+ # dst() at the edge.
+ self.assertEqual(cls(1,1,1, tzinfo=DST(1439)).timetuple().tm_isdst, 1)
+ self.assertEqual(cls(1,1,1, tzinfo=DST(-1439)).timetuple().tm_isdst, 1)
+
+ # dst() out of range.
+ self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(1440)).timetuple)
+ self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(-1440)).timetuple)
+
+ def test_utctimetuple(self):
+ class DST(tzinfo):
+ def __init__(self, dstvalue=0):
+ if isinstance(dstvalue, int):
+ dstvalue = timedelta(minutes=dstvalue)
+ self.dstvalue = dstvalue
+ def dst(self, dt):
+ return self.dstvalue
+
+ cls = self.theclass
+ # This can't work: DST didn't implement utcoffset.
+ self.assertRaises(NotImplementedError,
+ cls(1, 1, 1, tzinfo=DST(0)).utcoffset)
+
+ class UOFS(DST):
+ def __init__(self, uofs, dofs=None):
+ DST.__init__(self, dofs)
+ self.uofs = timedelta(minutes=uofs)
+ def utcoffset(self, dt):
+ return self.uofs
+
+ for dstvalue in -33, 33, 0, None:
+ d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=UOFS(-53, dstvalue))
+ t = d.utctimetuple()
+ self.assertEqual(d.year, t.tm_year)
+ self.assertEqual(d.month, t.tm_mon)
+ self.assertEqual(d.day, t.tm_mday)
+ self.assertEqual(11, t.tm_hour) # 20mm + 53mm = 1hn + 13mm
+ self.assertEqual(13, t.tm_min)
+ self.assertEqual(d.second, t.tm_sec)
+ self.assertEqual(d.weekday(), t.tm_wday)
+ self.assertEqual(d.toordinal() - date(1, 1, 1).toordinal() + 1,
+ t.tm_yday)
+ # Ensure tm_isdst is 0 regardless of what dst() says: DST
+ # is never in effect for a UTC time.
+ self.assertEqual(0, t.tm_isdst)
+
+ # For naive datetime, utctimetuple == timetuple except for isdst
+ d = cls(1, 2, 3, 10, 20, 30, 40)
+ t = d.utctimetuple()
+ self.assertEqual(t[:-1], d.timetuple()[:-1])
+ self.assertEqual(0, t.tm_isdst)
+ # Same if utcoffset is None
+ class NOFS(DST):
+ def utcoffset(self, dt):
+ return None
+ d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=NOFS())
+ t = d.utctimetuple()
+ self.assertEqual(t[:-1], d.timetuple()[:-1])
+ self.assertEqual(0, t.tm_isdst)
+ # Check that bad tzinfo is detected
+ class BOFS(DST):
+ def utcoffset(self, dt):
+ return "EST"
+ d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=BOFS())
+ self.assertRaises(TypeError, d.utctimetuple)
+
+ # Check that utctimetuple() is the same as
+ # astimezone(utc).timetuple()
+ d = cls(2010, 11, 13, 14, 15, 16, 171819)
+ for tz in [timezone.min, timezone.utc, timezone.max]:
+ dtz = d.replace(tzinfo=tz)
+ self.assertEqual(dtz.utctimetuple()[:-1],
+ dtz.astimezone(timezone.utc).timetuple()[:-1])
+ # At the edges, UTC adjustment can produce years out-of-range
+ # for a datetime object. Ensure that an OverflowError is
+ # raised.
+ tiny = cls(MINYEAR, 1, 1, 0, 0, 37, tzinfo=UOFS(1439))
+ # That goes back 1 minute less than a full day.
+ self.assertRaises(OverflowError, tiny.utctimetuple)
+
+ huge = cls(MAXYEAR, 12, 31, 23, 59, 37, 999999, tzinfo=UOFS(-1439))
+ # That goes forward 1 minute less than a full day.
+ self.assertRaises(OverflowError, huge.utctimetuple)
+ # More overflow cases
+ tiny = cls.min.replace(tzinfo=timezone(MINUTE))
+ self.assertRaises(OverflowError, tiny.utctimetuple)
+ huge = cls.max.replace(tzinfo=timezone(-MINUTE))
+ self.assertRaises(OverflowError, huge.utctimetuple)
+
+ def test_tzinfo_isoformat(self):
+ zero = FixedOffset(0, "+00:00")
+ plus = FixedOffset(220, "+03:40")
+ minus = FixedOffset(-231, "-03:51")
+ unknown = FixedOffset(None, "")
+
+ cls = self.theclass
+ datestr = '0001-02-03'
+ for ofs in None, zero, plus, minus, unknown:
+ for us in 0, 987001:
+ d = cls(1, 2, 3, 4, 5, 59, us, tzinfo=ofs)
+ timestr = '04:05:59' + (us and '.987001' or '')
+ ofsstr = ofs is not None and d.tzname() or ''
+ tailstr = timestr + ofsstr
+ iso = d.isoformat()
+ self.assertEqual(iso, datestr + 'T' + tailstr)
+ self.assertEqual(iso, d.isoformat('T'))
+ self.assertEqual(d.isoformat('k'), datestr + 'k' + tailstr)
+ self.assertEqual(d.isoformat('\u1234'), datestr + '\u1234' + tailstr)
+ self.assertEqual(str(d), datestr + ' ' + tailstr)
+
+ def test_replace(self):
+ cls = self.theclass
+ z100 = FixedOffset(100, "+100")
+ zm200 = FixedOffset(timedelta(minutes=-200), "-200")
+ args = [1, 2, 3, 4, 5, 6, 7, z100]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("year", 2),
+ ("month", 3),
+ ("day", 4),
+ ("hour", 5),
+ ("minute", 6),
+ ("second", 7),
+ ("microsecond", 8),
+ ("tzinfo", zm200)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Ensure we can get rid of a tzinfo.
+ self.assertEqual(base.tzname(), "+100")
+ base2 = base.replace(tzinfo=None)
+ self.assertTrue(base2.tzinfo is None)
+ self.assertTrue(base2.tzname() is None)
+
+ # Ensure we can add one.
+ base3 = base2.replace(tzinfo=z100)
+ self.assertEqual(base, base3)
+ self.assertTrue(base.tzinfo is base3.tzinfo)
+
+ # Out of bounds.
+ base = cls(2000, 2, 29)
+ self.assertRaises(ValueError, base.replace, year=2001)
+
+ def test_more_astimezone(self):
+ # The inherited test_astimezone covered some trivial and error cases.
+ fnone = FixedOffset(None, "None")
+ f44m = FixedOffset(44, "44")
+ fm5h = FixedOffset(-timedelta(hours=5), "m300")
+
+ dt = self.theclass.now(tz=f44m)
+ self.assertTrue(dt.tzinfo is f44m)
+ # Replacing with degenerate tzinfo raises an exception.
+ self.assertRaises(ValueError, dt.astimezone, fnone)
+ # Ditto with None tz.
+ self.assertRaises(TypeError, dt.astimezone, None)
+ # Replacing with same tzinfo makes no change.
+ x = dt.astimezone(dt.tzinfo)
+ self.assertTrue(x.tzinfo is f44m)
+ self.assertEqual(x.date(), dt.date())
+ self.assertEqual(x.time(), dt.time())
+
+ # Replacing with different tzinfo does adjust.
+ got = dt.astimezone(fm5h)
+ self.assertTrue(got.tzinfo is fm5h)
+ self.assertEqual(got.utcoffset(), timedelta(hours=-5))
+ expected = dt - dt.utcoffset() # in effect, convert to UTC
+ expected += fm5h.utcoffset(dt) # and from there to local time
+ expected = expected.replace(tzinfo=fm5h) # and attach new tzinfo
+ self.assertEqual(got.date(), expected.date())
+ self.assertEqual(got.time(), expected.time())
+ self.assertEqual(got.timetz(), expected.timetz())
+ self.assertTrue(got.tzinfo is expected.tzinfo)
+ self.assertEqual(got, expected)
+
+ def test_aware_subtract(self):
+ cls = self.theclass
+
+ # Ensure that utcoffset() is ignored when the operands have the
+ # same tzinfo member.
+ class OperandDependentOffset(tzinfo):
+ def utcoffset(self, t):
+ if t.minute < 10:
+ # d0 and d1 equal after adjustment
+ return timedelta(minutes=t.minute)
+ else:
+ # d2 off in the weeds
+ return timedelta(minutes=59)
+
+ base = cls(8, 9, 10, 11, 12, 13, 14, tzinfo=OperandDependentOffset())
+ d0 = base.replace(minute=3)
+ d1 = base.replace(minute=9)
+ d2 = base.replace(minute=11)
+ for x in d0, d1, d2:
+ for y in d0, d1, d2:
+ got = x - y
+ expected = timedelta(minutes=x.minute - y.minute)
+ self.assertEqual(got, expected)
+
+ # OTOH, if the tzinfo members are distinct, utcoffsets aren't
+ # ignored.
+ base = cls(8, 9, 10, 11, 12, 13, 14)
+ d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
+ d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
+ d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
+ for x in d0, d1, d2:
+ for y in d0, d1, d2:
+ got = x - y
+ if (x is d0 or x is d1) and (y is d0 or y is d1):
+ expected = timedelta(0)
+ elif x is y is d2:
+ expected = timedelta(0)
+ elif x is d2:
+ expected = timedelta(minutes=(11-59)-0)
+ else:
+ assert y is d2
+ expected = timedelta(minutes=0-(11-59))
+ self.assertEqual(got, expected)
+
+ def test_mixed_compare(self):
+ t1 = datetime(1, 2, 3, 4, 5, 6, 7)
+ t2 = datetime(1, 2, 3, 4, 5, 6, 7)
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=None)
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=FixedOffset(None, ""))
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=FixedOffset(0, ""))
+ self.assertRaises(TypeError, lambda: t1 == t2)
+
+ # In datetime w/ identical tzinfo objects, utcoffset is ignored.
+ class Varies(tzinfo):
+ def __init__(self):
+ self.offset = timedelta(minutes=22)
+ def utcoffset(self, t):
+ self.offset += timedelta(minutes=1)
+ return self.offset
+
+ v = Varies()
+ t1 = t2.replace(tzinfo=v)
+ t2 = t2.replace(tzinfo=v)
+ self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
+ self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
+ self.assertEqual(t1, t2)
+
+ # But if they're not identical, it isn't ignored.
+ t2 = t2.replace(tzinfo=Varies())
+ self.assertTrue(t1 < t2) # t1's offset counter still going up
+
+ def test_subclass_datetimetz(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.hour + self.year
+
+ args = 2002, 12, 31, 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
+ self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.year - 7)
+
+# Pain to set up DST-aware tzinfo classes.
+
+def first_sunday_on_or_after(dt):
+ days_to_go = 6 - dt.weekday()
+ if days_to_go:
+ dt += timedelta(days_to_go)
+ return dt
+
+ZERO = timedelta(0)
+MINUTE = timedelta(minutes=1)
+HOUR = timedelta(hours=1)
+DAY = timedelta(days=1)
+# In the US, DST starts at 2am (standard time) on the first Sunday in April.
+DSTSTART = datetime(1, 4, 1, 2)
+# and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct,
+# which is the first Sunday on or after Oct 25. Because we view 1:MM as
+# being standard time on that day, there is no spelling in local time of
+# the last hour of DST (that's 1:MM DST, but 1:MM is taken as standard time).
+DSTEND = datetime(1, 10, 25, 1)
+
+class USTimeZone(tzinfo):
+
+ def __init__(self, hours, reprname, stdname, dstname):
+ self.stdoffset = timedelta(hours=hours)
+ self.reprname = reprname
+ self.stdname = stdname
+ self.dstname = dstname
+
+ def __repr__(self):
+ return self.reprname
+
+ def tzname(self, dt):
+ if self.dst(dt):
+ return self.dstname
+ else:
+ return self.stdname
+
+ def utcoffset(self, dt):
+ return self.stdoffset + self.dst(dt)
+
+ def dst(self, dt):
+ if dt is None or dt.tzinfo is None:
+ # An exception instead may be sensible here, in one or more of
+ # the cases.
+ return ZERO
+ assert dt.tzinfo is self
+
+ # Find first Sunday in April.
+ start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
+ assert start.weekday() == 6 and start.month == 4 and start.day <= 7
+
+ # Find last Sunday in October.
+ end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
+ assert end.weekday() == 6 and end.month == 10 and end.day >= 25
+
+ # Can't compare naive to aware objects, so strip the timezone from
+ # dt first.
+ if start <= dt.replace(tzinfo=None) < end:
+ return HOUR
+ else:
+ return ZERO
+
+Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
+Central = USTimeZone(-6, "Central", "CST", "CDT")
+Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
+Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")
+utc_real = FixedOffset(0, "UTC", 0)
+# For better test coverage, we want another flavor of UTC that's west of
+# the Eastern and Pacific timezones.
+utc_fake = FixedOffset(-12*60, "UTCfake", 0)
+
+class TestTimezoneConversions(unittest.TestCase):
+ # The DST switch times for 2002, in std time.
+ dston = datetime(2002, 4, 7, 2)
+ dstoff = datetime(2002, 10, 27, 1)
+
+ theclass = datetime
+
+ # Check a time that's inside DST.
+ def checkinside(self, dt, tz, utc, dston, dstoff):
+ self.assertEqual(dt.dst(), HOUR)
+
+ # Conversion to our own timezone is always an identity.
+ self.assertEqual(dt.astimezone(tz), dt)
+
+ asutc = dt.astimezone(utc)
+ there_and_back = asutc.astimezone(tz)
+
+ # Conversion to UTC and back isn't always an identity here,
+ # because there are redundant spellings (in local time) of
+ # UTC time when DST begins: the clock jumps from 1:59:59
+ # to 3:00:00, and a local time of 2:MM:SS doesn't really
+ # make sense then. The classes above treat 2:MM:SS as
+ # daylight time then (it's "after 2am"), really an alias
+ # for 1:MM:SS standard time. The latter form is what
+ # conversion back from UTC produces.
+ if dt.date() == dston.date() and dt.hour == 2:
+ # We're in the redundant hour, and coming back from
+ # UTC gives the 1:MM:SS standard-time spelling.
+ self.assertEqual(there_and_back + HOUR, dt)
+ # Although during was considered to be in daylight
+ # time, there_and_back is not.
+ self.assertEqual(there_and_back.dst(), ZERO)
+ # They're the same times in UTC.
+ self.assertEqual(there_and_back.astimezone(utc),
+ dt.astimezone(utc))
+ else:
+ # We're not in the redundant hour.
+ self.assertEqual(dt, there_and_back)
+
+ # Because we have a redundant spelling when DST begins, there is
+ # (unfortunately) an hour when DST ends that can't be spelled at all in
+ # local time. When DST ends, the clock jumps from 1:59 back to 1:00
+ # again. The hour 1:MM DST has no spelling then: 1:MM is taken to be
+ # standard time. 1:MM DST == 0:MM EST, but 0:MM is taken to be
+ # daylight time. The hour 1:MM daylight == 0:MM standard can't be
+ # expressed in local time. Nevertheless, we want conversion back
+ # from UTC to mimic the local clock's "repeat an hour" behavior.
+ nexthour_utc = asutc + HOUR
+ nexthour_tz = nexthour_utc.astimezone(tz)
+ if dt.date() == dstoff.date() and dt.hour == 0:
+ # We're in the hour before the last DST hour. The last DST hour
+ # is ineffable. We want the conversion back to repeat 1:MM.
+ self.assertEqual(nexthour_tz, dt.replace(hour=1))
+ nexthour_utc += HOUR
+ nexthour_tz = nexthour_utc.astimezone(tz)
+ self.assertEqual(nexthour_tz, dt.replace(hour=1))
+ else:
+ self.assertEqual(nexthour_tz - dt, HOUR)
+
+ # Check a time that's outside DST.
+ def checkoutside(self, dt, tz, utc):
+ self.assertEqual(dt.dst(), ZERO)
+
+ # Conversion to our own timezone is always an identity.
+ self.assertEqual(dt.astimezone(tz), dt)
+
+ # Converting to UTC and back is an identity too.
+ asutc = dt.astimezone(utc)
+ there_and_back = asutc.astimezone(tz)
+ self.assertEqual(dt, there_and_back)
+
+ def convert_between_tz_and_utc(self, tz, utc):
+ dston = self.dston.replace(tzinfo=tz)
+ # Because 1:MM on the day DST ends is taken as being standard time,
+ # there is no spelling in tz for the last hour of daylight time.
+ # For purposes of the test, the last hour of DST is 0:MM, which is
+ # taken as being daylight time (and 1:MM is taken as being standard
+ # time).
+ dstoff = self.dstoff.replace(tzinfo=tz)
+ for delta in (timedelta(weeks=13),
+ DAY,
+ HOUR,
+ timedelta(minutes=1),
+ timedelta(microseconds=1)):
+
+ self.checkinside(dston, tz, utc, dston, dstoff)
+ for during in dston + delta, dstoff - delta:
+ self.checkinside(during, tz, utc, dston, dstoff)
+
+ self.checkoutside(dstoff, tz, utc)
+ for outside in dston - delta, dstoff + delta:
+ self.checkoutside(outside, tz, utc)
+
+ def test_easy(self):
+ # Despite the name of this test, the endcases are excruciating.
+ self.convert_between_tz_and_utc(Eastern, utc_real)
+ self.convert_between_tz_and_utc(Pacific, utc_real)
+ self.convert_between_tz_and_utc(Eastern, utc_fake)
+ self.convert_between_tz_and_utc(Pacific, utc_fake)
+ # The next is really dancing near the edge. It works because
+ # Pacific and Eastern are far enough apart that their "problem
+ # hours" don't overlap.
+ self.convert_between_tz_and_utc(Eastern, Pacific)
+ self.convert_between_tz_and_utc(Pacific, Eastern)
+ # OTOH, these fail! Don't enable them. The difficulty is that
+ # the edge case tests assume that every hour is representable in
+ # the "utc" class. This is always true for a fixed-offset tzinfo
+ # class (lke utc_real and utc_fake), but not for Eastern or Central.
+ # For these adjacent DST-aware time zones, the range of time offsets
+ # tested ends up creating hours in the one that aren't representable
+ # in the other. For the same reason, we would see failures in the
+ # Eastern vs Pacific tests too if we added 3*HOUR to the list of
+ # offset deltas in convert_between_tz_and_utc().
+ #
+ # self.convert_between_tz_and_utc(Eastern, Central) # can't work
+ # self.convert_between_tz_and_utc(Central, Eastern) # can't work
+
+ def test_tricky(self):
+ # 22:00 on day before daylight starts.
+ fourback = self.dston - timedelta(hours=4)
+ ninewest = FixedOffset(-9*60, "-0900", 0)
+ fourback = fourback.replace(tzinfo=ninewest)
+ # 22:00-0900 is 7:00 UTC == 2:00 EST == 3:00 DST. Since it's "after
+ # 2", we should get the 3 spelling.
+ # If we plug 22:00 the day before into Eastern, it "looks like std
+ # time", so its offset is returned as -5, and -5 - -9 = 4. Adding 4
+ # to 22:00 lands on 2:00, which makes no sense in local time (the
+ # local clock jumps from 1 to 3). The point here is to make sure we
+ # get the 3 spelling.
+ expected = self.dston.replace(hour=3)
+ got = fourback.astimezone(Eastern).replace(tzinfo=None)
+ self.assertEqual(expected, got)
+
+ # Similar, but map to 6:00 UTC == 1:00 EST == 2:00 DST. In that
+ # case we want the 1:00 spelling.
+ sixutc = self.dston.replace(hour=6, tzinfo=utc_real)
+ # Now 6:00 "looks like daylight", so the offset wrt Eastern is -4,
+ # and adding -4-0 == -4 gives the 2:00 spelling. We want the 1:00 EST
+ # spelling.
+ expected = self.dston.replace(hour=1)
+ got = sixutc.astimezone(Eastern).replace(tzinfo=None)
+ self.assertEqual(expected, got)
+
+ # Now on the day DST ends, we want "repeat an hour" behavior.
+ # UTC 4:MM 5:MM 6:MM 7:MM checking these
+ # EST 23:MM 0:MM 1:MM 2:MM
+ # EDT 0:MM 1:MM 2:MM 3:MM
+ # wall 0:MM 1:MM 1:MM 2:MM against these
+ for utc in utc_real, utc_fake:
+ for tz in Eastern, Pacific:
+ first_std_hour = self.dstoff - timedelta(hours=2) # 23:MM
+ # Convert that to UTC.
+ first_std_hour -= tz.utcoffset(None)
+ # Adjust for possibly fake UTC.
+ asutc = first_std_hour + utc.utcoffset(None)
+ # First UTC hour to convert; this is 4:00 when utc=utc_real &
+ # tz=Eastern.
+ asutcbase = asutc.replace(tzinfo=utc)
+ for tzhour in (0, 1, 1, 2):
+ expectedbase = self.dstoff.replace(hour=tzhour)
+ for minute in 0, 30, 59:
+ expected = expectedbase.replace(minute=minute)
+ asutc = asutcbase.replace(minute=minute)
+ astz = asutc.astimezone(tz)
+ self.assertEqual(astz.replace(tzinfo=None), expected)
+ asutcbase += HOUR
+
+
+ def test_bogus_dst(self):
+ class ok(tzinfo):
+ def utcoffset(self, dt): return HOUR
+ def dst(self, dt): return HOUR
+
+ now = self.theclass.now().replace(tzinfo=utc_real)
+ # Doesn't blow up.
+ now.astimezone(ok())
+
+ # Does blow up.
+ class notok(ok):
+ def dst(self, dt): return None
+ self.assertRaises(ValueError, now.astimezone, notok())
+
+ # Sometimes blow up. In the following, tzinfo.dst()
+ # implementation may return None or not None depending on
+ # whether DST is assumed to be in effect. In this situation,
+ # a ValueError should be raised by astimezone().
+ class tricky_notok(ok):
+ def dst(self, dt):
+ if dt.year == 2000:
+ return None
+ else:
+ return 10*HOUR
+ dt = self.theclass(2001, 1, 1).replace(tzinfo=utc_real)
+ self.assertRaises(ValueError, dt.astimezone, tricky_notok())
+
+ def test_fromutc(self):
+ self.assertRaises(TypeError, Eastern.fromutc) # not enough args
+ now = datetime.utcnow().replace(tzinfo=utc_real)
+ self.assertRaises(ValueError, Eastern.fromutc, now) # wrong tzinfo
+ now = now.replace(tzinfo=Eastern) # insert correct tzinfo
+ enow = Eastern.fromutc(now) # doesn't blow up
+ self.assertEqual(enow.tzinfo, Eastern) # has right tzinfo member
+ self.assertRaises(TypeError, Eastern.fromutc, now, now) # too many args
+ self.assertRaises(TypeError, Eastern.fromutc, date.today()) # wrong type
+
+ # Always converts UTC to standard time.
+ class FauxUSTimeZone(USTimeZone):
+ def fromutc(self, dt):
+ return dt + self.stdoffset
+ FEastern = FauxUSTimeZone(-5, "FEastern", "FEST", "FEDT")
+
+ # UTC 4:MM 5:MM 6:MM 7:MM 8:MM 9:MM
+ # EST 23:MM 0:MM 1:MM 2:MM 3:MM 4:MM
+ # EDT 0:MM 1:MM 2:MM 3:MM 4:MM 5:MM
+
+ # Check around DST start.
+ start = self.dston.replace(hour=4, tzinfo=Eastern)
+ fstart = start.replace(tzinfo=FEastern)
+ for wall in 23, 0, 1, 3, 4, 5:
+ expected = start.replace(hour=wall)
+ if wall == 23:
+ expected -= timedelta(days=1)
+ got = Eastern.fromutc(start)
+ self.assertEqual(expected, got)
+
+ expected = fstart + FEastern.stdoffset
+ got = FEastern.fromutc(fstart)
+ self.assertEqual(expected, got)
+
+ # Ensure astimezone() calls fromutc() too.
+ got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
+ self.assertEqual(expected, got)
+
+ start += HOUR
+ fstart += HOUR
+
+ # Check around DST end.
+ start = self.dstoff.replace(hour=4, tzinfo=Eastern)
+ fstart = start.replace(tzinfo=FEastern)
+ for wall in 0, 1, 1, 2, 3, 4:
+ expected = start.replace(hour=wall)
+ got = Eastern.fromutc(start)
+ self.assertEqual(expected, got)
+
+ expected = fstart + FEastern.stdoffset
+ got = FEastern.fromutc(fstart)
+ self.assertEqual(expected, got)
+
+ # Ensure astimezone() calls fromutc() too.
+ got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
+ self.assertEqual(expected, got)
+
+ start += HOUR
+ fstart += HOUR
+
+
+#############################################################################
+# oddballs
+
+class Oddballs(unittest.TestCase):
+
+ def test_bug_1028306(self):
+ # Trying to compare a date to a datetime should act like a mixed-
+ # type comparison, despite that datetime is a subclass of date.
+ as_date = date.today()
+ as_datetime = datetime.combine(as_date, time())
+ self.assertTrue(as_date != as_datetime)
+ self.assertTrue(as_datetime != as_date)
+ self.assertTrue(not as_date == as_datetime)
+ self.assertTrue(not as_datetime == as_date)
+ self.assertRaises(TypeError, lambda: as_date < as_datetime)
+ self.assertRaises(TypeError, lambda: as_datetime < as_date)
+ self.assertRaises(TypeError, lambda: as_date <= as_datetime)
+ self.assertRaises(TypeError, lambda: as_datetime <= as_date)
+ self.assertRaises(TypeError, lambda: as_date > as_datetime)
+ self.assertRaises(TypeError, lambda: as_datetime > as_date)
+ self.assertRaises(TypeError, lambda: as_date >= as_datetime)
+ self.assertRaises(TypeError, lambda: as_datetime >= as_date)
+
+ # Neverthelss, comparison should work with the base-class (date)
+ # projection if use of a date method is forced.
+ self.assertEqual(as_date.__eq__(as_datetime), True)
+ different_day = (as_date.day + 1) % 20 + 1
+ as_different = as_datetime.replace(day= different_day)
+ self.assertEqual(as_date.__eq__(as_different), False)
+
+ # And date should compare with other subclasses of date. If a
+ # subclass wants to stop this, it's up to the subclass to do so.
+ date_sc = SubclassDate(as_date.year, as_date.month, as_date.day)
+ self.assertEqual(as_date, date_sc)
+ self.assertEqual(date_sc, as_date)
+
+ # Ditto for datetimes.
+ datetime_sc = SubclassDatetime(as_datetime.year, as_datetime.month,
+ as_date.day, 0, 0, 0)
+ self.assertEqual(as_datetime, datetime_sc)
+ self.assertEqual(datetime_sc, as_datetime)
+
+def test_main():
+ support.run_unittest(__name__)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/decimaltestdata/and.decTest b/Lib/test/decimaltestdata/and.decTest
index a0cc786516..e912394877 100644
--- a/Lib/test/decimaltestdata/and.decTest
+++ b/Lib/test/decimaltestdata/and.decTest
@@ -1,338 +1,338 @@
-------------------------------------------------------------------------
--- and.decTest -- digitwise logical AND --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check (truth table)
-andx001 and 0 0 -> 0
-andx002 and 0 1 -> 0
-andx003 and 1 0 -> 0
-andx004 and 1 1 -> 1
-andx005 and 1100 1010 -> 1000
-andx006 and 1111 10 -> 10
-andx007 and 1111 1010 -> 1010
-
--- and at msd and msd-1
-andx010 and 000000000 000000000 -> 0
-andx011 and 000000000 100000000 -> 0
-andx012 and 100000000 000000000 -> 0
-andx013 and 100000000 100000000 -> 100000000
-andx014 and 000000000 000000000 -> 0
-andx015 and 000000000 010000000 -> 0
-andx016 and 010000000 000000000 -> 0
-andx017 and 010000000 010000000 -> 10000000
-
--- Various lengths
--- 123456789 123456789 123456789
-andx021 and 111111111 111111111 -> 111111111
-andx022 and 111111111111 111111111 -> 111111111
-andx023 and 111111111111 11111111 -> 11111111
-andx024 and 111111111 11111111 -> 11111111
-andx025 and 111111111 1111111 -> 1111111
-andx026 and 111111111111 111111 -> 111111
-andx027 and 111111111111 11111 -> 11111
-andx028 and 111111111111 1111 -> 1111
-andx029 and 111111111111 111 -> 111
-andx031 and 111111111111 11 -> 11
-andx032 and 111111111111 1 -> 1
-andx033 and 111111111111 1111111111 -> 111111111
-andx034 and 11111111111 11111111111 -> 111111111
-andx035 and 1111111111 111111111111 -> 111111111
-andx036 and 111111111 1111111111111 -> 111111111
-
-andx040 and 111111111 111111111111 -> 111111111
-andx041 and 11111111 111111111111 -> 11111111
-andx042 and 11111111 111111111 -> 11111111
-andx043 and 1111111 111111111 -> 1111111
-andx044 and 111111 111111111 -> 111111
-andx045 and 11111 111111111 -> 11111
-andx046 and 1111 111111111 -> 1111
-andx047 and 111 111111111 -> 111
-andx048 and 11 111111111 -> 11
-andx049 and 1 111111111 -> 1
-
-andx050 and 1111111111 1 -> 1
-andx051 and 111111111 1 -> 1
-andx052 and 11111111 1 -> 1
-andx053 and 1111111 1 -> 1
-andx054 and 111111 1 -> 1
-andx055 and 11111 1 -> 1
-andx056 and 1111 1 -> 1
-andx057 and 111 1 -> 1
-andx058 and 11 1 -> 1
-andx059 and 1 1 -> 1
-
-andx060 and 1111111111 0 -> 0
-andx061 and 111111111 0 -> 0
-andx062 and 11111111 0 -> 0
-andx063 and 1111111 0 -> 0
-andx064 and 111111 0 -> 0
-andx065 and 11111 0 -> 0
-andx066 and 1111 0 -> 0
-andx067 and 111 0 -> 0
-andx068 and 11 0 -> 0
-andx069 and 1 0 -> 0
-
-andx070 and 1 1111111111 -> 1
-andx071 and 1 111111111 -> 1
-andx072 and 1 11111111 -> 1
-andx073 and 1 1111111 -> 1
-andx074 and 1 111111 -> 1
-andx075 and 1 11111 -> 1
-andx076 and 1 1111 -> 1
-andx077 and 1 111 -> 1
-andx078 and 1 11 -> 1
-andx079 and 1 1 -> 1
-
-andx080 and 0 1111111111 -> 0
-andx081 and 0 111111111 -> 0
-andx082 and 0 11111111 -> 0
-andx083 and 0 1111111 -> 0
-andx084 and 0 111111 -> 0
-andx085 and 0 11111 -> 0
-andx086 and 0 1111 -> 0
-andx087 and 0 111 -> 0
-andx088 and 0 11 -> 0
-andx089 and 0 1 -> 0
-
-andx090 and 011111111 111111111 -> 11111111
-andx091 and 101111111 111111111 -> 101111111
-andx092 and 110111111 111111111 -> 110111111
-andx093 and 111011111 111111111 -> 111011111
-andx094 and 111101111 111111111 -> 111101111
-andx095 and 111110111 111111111 -> 111110111
-andx096 and 111111011 111111111 -> 111111011
-andx097 and 111111101 111111111 -> 111111101
-andx098 and 111111110 111111111 -> 111111110
-
-andx100 and 111111111 011111111 -> 11111111
-andx101 and 111111111 101111111 -> 101111111
-andx102 and 111111111 110111111 -> 110111111
-andx103 and 111111111 111011111 -> 111011111
-andx104 and 111111111 111101111 -> 111101111
-andx105 and 111111111 111110111 -> 111110111
-andx106 and 111111111 111111011 -> 111111011
-andx107 and 111111111 111111101 -> 111111101
-andx108 and 111111111 111111110 -> 111111110
-
--- non-0/1 should not be accepted, nor should signs
-andx220 and 111111112 111111111 -> NaN Invalid_operation
-andx221 and 333333333 333333333 -> NaN Invalid_operation
-andx222 and 555555555 555555555 -> NaN Invalid_operation
-andx223 and 777777777 777777777 -> NaN Invalid_operation
-andx224 and 999999999 999999999 -> NaN Invalid_operation
-andx225 and 222222222 999999999 -> NaN Invalid_operation
-andx226 and 444444444 999999999 -> NaN Invalid_operation
-andx227 and 666666666 999999999 -> NaN Invalid_operation
-andx228 and 888888888 999999999 -> NaN Invalid_operation
-andx229 and 999999999 222222222 -> NaN Invalid_operation
-andx230 and 999999999 444444444 -> NaN Invalid_operation
-andx231 and 999999999 666666666 -> NaN Invalid_operation
-andx232 and 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-andx240 and 567468689 -934981942 -> NaN Invalid_operation
-andx241 and 567367689 934981942 -> NaN Invalid_operation
-andx242 and -631917772 -706014634 -> NaN Invalid_operation
-andx243 and -756253257 138579234 -> NaN Invalid_operation
-andx244 and 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-andx250 and 200000000 100000000 -> NaN Invalid_operation
-andx251 and 700000000 100000000 -> NaN Invalid_operation
-andx252 and 800000000 100000000 -> NaN Invalid_operation
-andx253 and 900000000 100000000 -> NaN Invalid_operation
-andx254 and 200000000 000000000 -> NaN Invalid_operation
-andx255 and 700000000 000000000 -> NaN Invalid_operation
-andx256 and 800000000 000000000 -> NaN Invalid_operation
-andx257 and 900000000 000000000 -> NaN Invalid_operation
-andx258 and 100000000 200000000 -> NaN Invalid_operation
-andx259 and 100000000 700000000 -> NaN Invalid_operation
-andx260 and 100000000 800000000 -> NaN Invalid_operation
-andx261 and 100000000 900000000 -> NaN Invalid_operation
-andx262 and 000000000 200000000 -> NaN Invalid_operation
-andx263 and 000000000 700000000 -> NaN Invalid_operation
-andx264 and 000000000 800000000 -> NaN Invalid_operation
-andx265 and 000000000 900000000 -> NaN Invalid_operation
--- test MSD-1
-andx270 and 020000000 100000000 -> NaN Invalid_operation
-andx271 and 070100000 100000000 -> NaN Invalid_operation
-andx272 and 080010000 100000001 -> NaN Invalid_operation
-andx273 and 090001000 100000010 -> NaN Invalid_operation
-andx274 and 100000100 020010100 -> NaN Invalid_operation
-andx275 and 100000000 070001000 -> NaN Invalid_operation
-andx276 and 100000010 080010100 -> NaN Invalid_operation
-andx277 and 100000000 090000010 -> NaN Invalid_operation
--- test LSD
-andx280 and 001000002 100000000 -> NaN Invalid_operation
-andx281 and 000000007 100000000 -> NaN Invalid_operation
-andx282 and 000000008 100000000 -> NaN Invalid_operation
-andx283 and 000000009 100000000 -> NaN Invalid_operation
-andx284 and 100000000 000100002 -> NaN Invalid_operation
-andx285 and 100100000 001000007 -> NaN Invalid_operation
-andx286 and 100010000 010000008 -> NaN Invalid_operation
-andx287 and 100001000 100000009 -> NaN Invalid_operation
--- test Middie
-andx288 and 001020000 100000000 -> NaN Invalid_operation
-andx289 and 000070001 100000000 -> NaN Invalid_operation
-andx290 and 000080000 100010000 -> NaN Invalid_operation
-andx291 and 000090000 100001000 -> NaN Invalid_operation
-andx292 and 100000010 000020100 -> NaN Invalid_operation
-andx293 and 100100000 000070010 -> NaN Invalid_operation
-andx294 and 100010100 000080001 -> NaN Invalid_operation
-andx295 and 100001000 000090000 -> NaN Invalid_operation
--- signs
-andx296 and -100001000 -000000000 -> NaN Invalid_operation
-andx297 and -100001000 000010000 -> NaN Invalid_operation
-andx298 and 100001000 -000000000 -> NaN Invalid_operation
-andx299 and 100001000 000011000 -> 1000
-
--- Nmax, Nmin, Ntiny
-andx331 and 2 9.99999999E+999 -> NaN Invalid_operation
-andx332 and 3 1E-999 -> NaN Invalid_operation
-andx333 and 4 1.00000000E-999 -> NaN Invalid_operation
-andx334 and 5 1E-1007 -> NaN Invalid_operation
-andx335 and 6 -1E-1007 -> NaN Invalid_operation
-andx336 and 7 -1.00000000E-999 -> NaN Invalid_operation
-andx337 and 8 -1E-999 -> NaN Invalid_operation
-andx338 and 9 -9.99999999E+999 -> NaN Invalid_operation
-andx341 and 9.99999999E+999 -18 -> NaN Invalid_operation
-andx342 and 1E-999 01 -> NaN Invalid_operation
-andx343 and 1.00000000E-999 -18 -> NaN Invalid_operation
-andx344 and 1E-1007 18 -> NaN Invalid_operation
-andx345 and -1E-1007 -10 -> NaN Invalid_operation
-andx346 and -1.00000000E-999 18 -> NaN Invalid_operation
-andx347 and -1E-999 10 -> NaN Invalid_operation
-andx348 and -9.99999999E+999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-andx361 and 1.0 1 -> NaN Invalid_operation
-andx362 and 1E+1 1 -> NaN Invalid_operation
-andx363 and 0.0 1 -> NaN Invalid_operation
-andx364 and 0E+1 1 -> NaN Invalid_operation
-andx365 and 9.9 1 -> NaN Invalid_operation
-andx366 and 9E+1 1 -> NaN Invalid_operation
-andx371 and 0 1.0 -> NaN Invalid_operation
-andx372 and 0 1E+1 -> NaN Invalid_operation
-andx373 and 0 0.0 -> NaN Invalid_operation
-andx374 and 0 0E+1 -> NaN Invalid_operation
-andx375 and 0 9.9 -> NaN Invalid_operation
-andx376 and 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-andx780 and -Inf -Inf -> NaN Invalid_operation
-andx781 and -Inf -1000 -> NaN Invalid_operation
-andx782 and -Inf -1 -> NaN Invalid_operation
-andx783 and -Inf -0 -> NaN Invalid_operation
-andx784 and -Inf 0 -> NaN Invalid_operation
-andx785 and -Inf 1 -> NaN Invalid_operation
-andx786 and -Inf 1000 -> NaN Invalid_operation
-andx787 and -1000 -Inf -> NaN Invalid_operation
-andx788 and -Inf -Inf -> NaN Invalid_operation
-andx789 and -1 -Inf -> NaN Invalid_operation
-andx790 and -0 -Inf -> NaN Invalid_operation
-andx791 and 0 -Inf -> NaN Invalid_operation
-andx792 and 1 -Inf -> NaN Invalid_operation
-andx793 and 1000 -Inf -> NaN Invalid_operation
-andx794 and Inf -Inf -> NaN Invalid_operation
-
-andx800 and Inf -Inf -> NaN Invalid_operation
-andx801 and Inf -1000 -> NaN Invalid_operation
-andx802 and Inf -1 -> NaN Invalid_operation
-andx803 and Inf -0 -> NaN Invalid_operation
-andx804 and Inf 0 -> NaN Invalid_operation
-andx805 and Inf 1 -> NaN Invalid_operation
-andx806 and Inf 1000 -> NaN Invalid_operation
-andx807 and Inf Inf -> NaN Invalid_operation
-andx808 and -1000 Inf -> NaN Invalid_operation
-andx809 and -Inf Inf -> NaN Invalid_operation
-andx810 and -1 Inf -> NaN Invalid_operation
-andx811 and -0 Inf -> NaN Invalid_operation
-andx812 and 0 Inf -> NaN Invalid_operation
-andx813 and 1 Inf -> NaN Invalid_operation
-andx814 and 1000 Inf -> NaN Invalid_operation
-andx815 and Inf Inf -> NaN Invalid_operation
-
-andx821 and NaN -Inf -> NaN Invalid_operation
-andx822 and NaN -1000 -> NaN Invalid_operation
-andx823 and NaN -1 -> NaN Invalid_operation
-andx824 and NaN -0 -> NaN Invalid_operation
-andx825 and NaN 0 -> NaN Invalid_operation
-andx826 and NaN 1 -> NaN Invalid_operation
-andx827 and NaN 1000 -> NaN Invalid_operation
-andx828 and NaN Inf -> NaN Invalid_operation
-andx829 and NaN NaN -> NaN Invalid_operation
-andx830 and -Inf NaN -> NaN Invalid_operation
-andx831 and -1000 NaN -> NaN Invalid_operation
-andx832 and -1 NaN -> NaN Invalid_operation
-andx833 and -0 NaN -> NaN Invalid_operation
-andx834 and 0 NaN -> NaN Invalid_operation
-andx835 and 1 NaN -> NaN Invalid_operation
-andx836 and 1000 NaN -> NaN Invalid_operation
-andx837 and Inf NaN -> NaN Invalid_operation
-
-andx841 and sNaN -Inf -> NaN Invalid_operation
-andx842 and sNaN -1000 -> NaN Invalid_operation
-andx843 and sNaN -1 -> NaN Invalid_operation
-andx844 and sNaN -0 -> NaN Invalid_operation
-andx845 and sNaN 0 -> NaN Invalid_operation
-andx846 and sNaN 1 -> NaN Invalid_operation
-andx847 and sNaN 1000 -> NaN Invalid_operation
-andx848 and sNaN NaN -> NaN Invalid_operation
-andx849 and sNaN sNaN -> NaN Invalid_operation
-andx850 and NaN sNaN -> NaN Invalid_operation
-andx851 and -Inf sNaN -> NaN Invalid_operation
-andx852 and -1000 sNaN -> NaN Invalid_operation
-andx853 and -1 sNaN -> NaN Invalid_operation
-andx854 and -0 sNaN -> NaN Invalid_operation
-andx855 and 0 sNaN -> NaN Invalid_operation
-andx856 and 1 sNaN -> NaN Invalid_operation
-andx857 and 1000 sNaN -> NaN Invalid_operation
-andx858 and Inf sNaN -> NaN Invalid_operation
-andx859 and NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-andx861 and NaN1 -Inf -> NaN Invalid_operation
-andx862 and +NaN2 -1000 -> NaN Invalid_operation
-andx863 and NaN3 1000 -> NaN Invalid_operation
-andx864 and NaN4 Inf -> NaN Invalid_operation
-andx865 and NaN5 +NaN6 -> NaN Invalid_operation
-andx866 and -Inf NaN7 -> NaN Invalid_operation
-andx867 and -1000 NaN8 -> NaN Invalid_operation
-andx868 and 1000 NaN9 -> NaN Invalid_operation
-andx869 and Inf +NaN10 -> NaN Invalid_operation
-andx871 and sNaN11 -Inf -> NaN Invalid_operation
-andx872 and sNaN12 -1000 -> NaN Invalid_operation
-andx873 and sNaN13 1000 -> NaN Invalid_operation
-andx874 and sNaN14 NaN17 -> NaN Invalid_operation
-andx875 and sNaN15 sNaN18 -> NaN Invalid_operation
-andx876 and NaN16 sNaN19 -> NaN Invalid_operation
-andx877 and -Inf +sNaN20 -> NaN Invalid_operation
-andx878 and -1000 sNaN21 -> NaN Invalid_operation
-andx879 and 1000 sNaN22 -> NaN Invalid_operation
-andx880 and Inf sNaN23 -> NaN Invalid_operation
-andx881 and +NaN25 +sNaN24 -> NaN Invalid_operation
-andx882 and -NaN26 NaN28 -> NaN Invalid_operation
-andx883 and -sNaN27 sNaN29 -> NaN Invalid_operation
-andx884 and 1000 -NaN30 -> NaN Invalid_operation
-andx885 and 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- and.decTest -- digitwise logical AND --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check (truth table)
+andx001 and 0 0 -> 0
+andx002 and 0 1 -> 0
+andx003 and 1 0 -> 0
+andx004 and 1 1 -> 1
+andx005 and 1100 1010 -> 1000
+andx006 and 1111 10 -> 10
+andx007 and 1111 1010 -> 1010
+
+-- and at msd and msd-1
+andx010 and 000000000 000000000 -> 0
+andx011 and 000000000 100000000 -> 0
+andx012 and 100000000 000000000 -> 0
+andx013 and 100000000 100000000 -> 100000000
+andx014 and 000000000 000000000 -> 0
+andx015 and 000000000 010000000 -> 0
+andx016 and 010000000 000000000 -> 0
+andx017 and 010000000 010000000 -> 10000000
+
+-- Various lengths
+-- 123456789 123456789 123456789
+andx021 and 111111111 111111111 -> 111111111
+andx022 and 111111111111 111111111 -> 111111111
+andx023 and 111111111111 11111111 -> 11111111
+andx024 and 111111111 11111111 -> 11111111
+andx025 and 111111111 1111111 -> 1111111
+andx026 and 111111111111 111111 -> 111111
+andx027 and 111111111111 11111 -> 11111
+andx028 and 111111111111 1111 -> 1111
+andx029 and 111111111111 111 -> 111
+andx031 and 111111111111 11 -> 11
+andx032 and 111111111111 1 -> 1
+andx033 and 111111111111 1111111111 -> 111111111
+andx034 and 11111111111 11111111111 -> 111111111
+andx035 and 1111111111 111111111111 -> 111111111
+andx036 and 111111111 1111111111111 -> 111111111
+
+andx040 and 111111111 111111111111 -> 111111111
+andx041 and 11111111 111111111111 -> 11111111
+andx042 and 11111111 111111111 -> 11111111
+andx043 and 1111111 111111111 -> 1111111
+andx044 and 111111 111111111 -> 111111
+andx045 and 11111 111111111 -> 11111
+andx046 and 1111 111111111 -> 1111
+andx047 and 111 111111111 -> 111
+andx048 and 11 111111111 -> 11
+andx049 and 1 111111111 -> 1
+
+andx050 and 1111111111 1 -> 1
+andx051 and 111111111 1 -> 1
+andx052 and 11111111 1 -> 1
+andx053 and 1111111 1 -> 1
+andx054 and 111111 1 -> 1
+andx055 and 11111 1 -> 1
+andx056 and 1111 1 -> 1
+andx057 and 111 1 -> 1
+andx058 and 11 1 -> 1
+andx059 and 1 1 -> 1
+
+andx060 and 1111111111 0 -> 0
+andx061 and 111111111 0 -> 0
+andx062 and 11111111 0 -> 0
+andx063 and 1111111 0 -> 0
+andx064 and 111111 0 -> 0
+andx065 and 11111 0 -> 0
+andx066 and 1111 0 -> 0
+andx067 and 111 0 -> 0
+andx068 and 11 0 -> 0
+andx069 and 1 0 -> 0
+
+andx070 and 1 1111111111 -> 1
+andx071 and 1 111111111 -> 1
+andx072 and 1 11111111 -> 1
+andx073 and 1 1111111 -> 1
+andx074 and 1 111111 -> 1
+andx075 and 1 11111 -> 1
+andx076 and 1 1111 -> 1
+andx077 and 1 111 -> 1
+andx078 and 1 11 -> 1
+andx079 and 1 1 -> 1
+
+andx080 and 0 1111111111 -> 0
+andx081 and 0 111111111 -> 0
+andx082 and 0 11111111 -> 0
+andx083 and 0 1111111 -> 0
+andx084 and 0 111111 -> 0
+andx085 and 0 11111 -> 0
+andx086 and 0 1111 -> 0
+andx087 and 0 111 -> 0
+andx088 and 0 11 -> 0
+andx089 and 0 1 -> 0
+
+andx090 and 011111111 111111111 -> 11111111
+andx091 and 101111111 111111111 -> 101111111
+andx092 and 110111111 111111111 -> 110111111
+andx093 and 111011111 111111111 -> 111011111
+andx094 and 111101111 111111111 -> 111101111
+andx095 and 111110111 111111111 -> 111110111
+andx096 and 111111011 111111111 -> 111111011
+andx097 and 111111101 111111111 -> 111111101
+andx098 and 111111110 111111111 -> 111111110
+
+andx100 and 111111111 011111111 -> 11111111
+andx101 and 111111111 101111111 -> 101111111
+andx102 and 111111111 110111111 -> 110111111
+andx103 and 111111111 111011111 -> 111011111
+andx104 and 111111111 111101111 -> 111101111
+andx105 and 111111111 111110111 -> 111110111
+andx106 and 111111111 111111011 -> 111111011
+andx107 and 111111111 111111101 -> 111111101
+andx108 and 111111111 111111110 -> 111111110
+
+-- non-0/1 should not be accepted, nor should signs
+andx220 and 111111112 111111111 -> NaN Invalid_operation
+andx221 and 333333333 333333333 -> NaN Invalid_operation
+andx222 and 555555555 555555555 -> NaN Invalid_operation
+andx223 and 777777777 777777777 -> NaN Invalid_operation
+andx224 and 999999999 999999999 -> NaN Invalid_operation
+andx225 and 222222222 999999999 -> NaN Invalid_operation
+andx226 and 444444444 999999999 -> NaN Invalid_operation
+andx227 and 666666666 999999999 -> NaN Invalid_operation
+andx228 and 888888888 999999999 -> NaN Invalid_operation
+andx229 and 999999999 222222222 -> NaN Invalid_operation
+andx230 and 999999999 444444444 -> NaN Invalid_operation
+andx231 and 999999999 666666666 -> NaN Invalid_operation
+andx232 and 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+andx240 and 567468689 -934981942 -> NaN Invalid_operation
+andx241 and 567367689 934981942 -> NaN Invalid_operation
+andx242 and -631917772 -706014634 -> NaN Invalid_operation
+andx243 and -756253257 138579234 -> NaN Invalid_operation
+andx244 and 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+andx250 and 200000000 100000000 -> NaN Invalid_operation
+andx251 and 700000000 100000000 -> NaN Invalid_operation
+andx252 and 800000000 100000000 -> NaN Invalid_operation
+andx253 and 900000000 100000000 -> NaN Invalid_operation
+andx254 and 200000000 000000000 -> NaN Invalid_operation
+andx255 and 700000000 000000000 -> NaN Invalid_operation
+andx256 and 800000000 000000000 -> NaN Invalid_operation
+andx257 and 900000000 000000000 -> NaN Invalid_operation
+andx258 and 100000000 200000000 -> NaN Invalid_operation
+andx259 and 100000000 700000000 -> NaN Invalid_operation
+andx260 and 100000000 800000000 -> NaN Invalid_operation
+andx261 and 100000000 900000000 -> NaN Invalid_operation
+andx262 and 000000000 200000000 -> NaN Invalid_operation
+andx263 and 000000000 700000000 -> NaN Invalid_operation
+andx264 and 000000000 800000000 -> NaN Invalid_operation
+andx265 and 000000000 900000000 -> NaN Invalid_operation
+-- test MSD-1
+andx270 and 020000000 100000000 -> NaN Invalid_operation
+andx271 and 070100000 100000000 -> NaN Invalid_operation
+andx272 and 080010000 100000001 -> NaN Invalid_operation
+andx273 and 090001000 100000010 -> NaN Invalid_operation
+andx274 and 100000100 020010100 -> NaN Invalid_operation
+andx275 and 100000000 070001000 -> NaN Invalid_operation
+andx276 and 100000010 080010100 -> NaN Invalid_operation
+andx277 and 100000000 090000010 -> NaN Invalid_operation
+-- test LSD
+andx280 and 001000002 100000000 -> NaN Invalid_operation
+andx281 and 000000007 100000000 -> NaN Invalid_operation
+andx282 and 000000008 100000000 -> NaN Invalid_operation
+andx283 and 000000009 100000000 -> NaN Invalid_operation
+andx284 and 100000000 000100002 -> NaN Invalid_operation
+andx285 and 100100000 001000007 -> NaN Invalid_operation
+andx286 and 100010000 010000008 -> NaN Invalid_operation
+andx287 and 100001000 100000009 -> NaN Invalid_operation
+-- test Middie
+andx288 and 001020000 100000000 -> NaN Invalid_operation
+andx289 and 000070001 100000000 -> NaN Invalid_operation
+andx290 and 000080000 100010000 -> NaN Invalid_operation
+andx291 and 000090000 100001000 -> NaN Invalid_operation
+andx292 and 100000010 000020100 -> NaN Invalid_operation
+andx293 and 100100000 000070010 -> NaN Invalid_operation
+andx294 and 100010100 000080001 -> NaN Invalid_operation
+andx295 and 100001000 000090000 -> NaN Invalid_operation
+-- signs
+andx296 and -100001000 -000000000 -> NaN Invalid_operation
+andx297 and -100001000 000010000 -> NaN Invalid_operation
+andx298 and 100001000 -000000000 -> NaN Invalid_operation
+andx299 and 100001000 000011000 -> 1000
+
+-- Nmax, Nmin, Ntiny
+andx331 and 2 9.99999999E+999 -> NaN Invalid_operation
+andx332 and 3 1E-999 -> NaN Invalid_operation
+andx333 and 4 1.00000000E-999 -> NaN Invalid_operation
+andx334 and 5 1E-1007 -> NaN Invalid_operation
+andx335 and 6 -1E-1007 -> NaN Invalid_operation
+andx336 and 7 -1.00000000E-999 -> NaN Invalid_operation
+andx337 and 8 -1E-999 -> NaN Invalid_operation
+andx338 and 9 -9.99999999E+999 -> NaN Invalid_operation
+andx341 and 9.99999999E+999 -18 -> NaN Invalid_operation
+andx342 and 1E-999 01 -> NaN Invalid_operation
+andx343 and 1.00000000E-999 -18 -> NaN Invalid_operation
+andx344 and 1E-1007 18 -> NaN Invalid_operation
+andx345 and -1E-1007 -10 -> NaN Invalid_operation
+andx346 and -1.00000000E-999 18 -> NaN Invalid_operation
+andx347 and -1E-999 10 -> NaN Invalid_operation
+andx348 and -9.99999999E+999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+andx361 and 1.0 1 -> NaN Invalid_operation
+andx362 and 1E+1 1 -> NaN Invalid_operation
+andx363 and 0.0 1 -> NaN Invalid_operation
+andx364 and 0E+1 1 -> NaN Invalid_operation
+andx365 and 9.9 1 -> NaN Invalid_operation
+andx366 and 9E+1 1 -> NaN Invalid_operation
+andx371 and 0 1.0 -> NaN Invalid_operation
+andx372 and 0 1E+1 -> NaN Invalid_operation
+andx373 and 0 0.0 -> NaN Invalid_operation
+andx374 and 0 0E+1 -> NaN Invalid_operation
+andx375 and 0 9.9 -> NaN Invalid_operation
+andx376 and 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+andx780 and -Inf -Inf -> NaN Invalid_operation
+andx781 and -Inf -1000 -> NaN Invalid_operation
+andx782 and -Inf -1 -> NaN Invalid_operation
+andx783 and -Inf -0 -> NaN Invalid_operation
+andx784 and -Inf 0 -> NaN Invalid_operation
+andx785 and -Inf 1 -> NaN Invalid_operation
+andx786 and -Inf 1000 -> NaN Invalid_operation
+andx787 and -1000 -Inf -> NaN Invalid_operation
+andx788 and -Inf -Inf -> NaN Invalid_operation
+andx789 and -1 -Inf -> NaN Invalid_operation
+andx790 and -0 -Inf -> NaN Invalid_operation
+andx791 and 0 -Inf -> NaN Invalid_operation
+andx792 and 1 -Inf -> NaN Invalid_operation
+andx793 and 1000 -Inf -> NaN Invalid_operation
+andx794 and Inf -Inf -> NaN Invalid_operation
+
+andx800 and Inf -Inf -> NaN Invalid_operation
+andx801 and Inf -1000 -> NaN Invalid_operation
+andx802 and Inf -1 -> NaN Invalid_operation
+andx803 and Inf -0 -> NaN Invalid_operation
+andx804 and Inf 0 -> NaN Invalid_operation
+andx805 and Inf 1 -> NaN Invalid_operation
+andx806 and Inf 1000 -> NaN Invalid_operation
+andx807 and Inf Inf -> NaN Invalid_operation
+andx808 and -1000 Inf -> NaN Invalid_operation
+andx809 and -Inf Inf -> NaN Invalid_operation
+andx810 and -1 Inf -> NaN Invalid_operation
+andx811 and -0 Inf -> NaN Invalid_operation
+andx812 and 0 Inf -> NaN Invalid_operation
+andx813 and 1 Inf -> NaN Invalid_operation
+andx814 and 1000 Inf -> NaN Invalid_operation
+andx815 and Inf Inf -> NaN Invalid_operation
+
+andx821 and NaN -Inf -> NaN Invalid_operation
+andx822 and NaN -1000 -> NaN Invalid_operation
+andx823 and NaN -1 -> NaN Invalid_operation
+andx824 and NaN -0 -> NaN Invalid_operation
+andx825 and NaN 0 -> NaN Invalid_operation
+andx826 and NaN 1 -> NaN Invalid_operation
+andx827 and NaN 1000 -> NaN Invalid_operation
+andx828 and NaN Inf -> NaN Invalid_operation
+andx829 and NaN NaN -> NaN Invalid_operation
+andx830 and -Inf NaN -> NaN Invalid_operation
+andx831 and -1000 NaN -> NaN Invalid_operation
+andx832 and -1 NaN -> NaN Invalid_operation
+andx833 and -0 NaN -> NaN Invalid_operation
+andx834 and 0 NaN -> NaN Invalid_operation
+andx835 and 1 NaN -> NaN Invalid_operation
+andx836 and 1000 NaN -> NaN Invalid_operation
+andx837 and Inf NaN -> NaN Invalid_operation
+
+andx841 and sNaN -Inf -> NaN Invalid_operation
+andx842 and sNaN -1000 -> NaN Invalid_operation
+andx843 and sNaN -1 -> NaN Invalid_operation
+andx844 and sNaN -0 -> NaN Invalid_operation
+andx845 and sNaN 0 -> NaN Invalid_operation
+andx846 and sNaN 1 -> NaN Invalid_operation
+andx847 and sNaN 1000 -> NaN Invalid_operation
+andx848 and sNaN NaN -> NaN Invalid_operation
+andx849 and sNaN sNaN -> NaN Invalid_operation
+andx850 and NaN sNaN -> NaN Invalid_operation
+andx851 and -Inf sNaN -> NaN Invalid_operation
+andx852 and -1000 sNaN -> NaN Invalid_operation
+andx853 and -1 sNaN -> NaN Invalid_operation
+andx854 and -0 sNaN -> NaN Invalid_operation
+andx855 and 0 sNaN -> NaN Invalid_operation
+andx856 and 1 sNaN -> NaN Invalid_operation
+andx857 and 1000 sNaN -> NaN Invalid_operation
+andx858 and Inf sNaN -> NaN Invalid_operation
+andx859 and NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+andx861 and NaN1 -Inf -> NaN Invalid_operation
+andx862 and +NaN2 -1000 -> NaN Invalid_operation
+andx863 and NaN3 1000 -> NaN Invalid_operation
+andx864 and NaN4 Inf -> NaN Invalid_operation
+andx865 and NaN5 +NaN6 -> NaN Invalid_operation
+andx866 and -Inf NaN7 -> NaN Invalid_operation
+andx867 and -1000 NaN8 -> NaN Invalid_operation
+andx868 and 1000 NaN9 -> NaN Invalid_operation
+andx869 and Inf +NaN10 -> NaN Invalid_operation
+andx871 and sNaN11 -Inf -> NaN Invalid_operation
+andx872 and sNaN12 -1000 -> NaN Invalid_operation
+andx873 and sNaN13 1000 -> NaN Invalid_operation
+andx874 and sNaN14 NaN17 -> NaN Invalid_operation
+andx875 and sNaN15 sNaN18 -> NaN Invalid_operation
+andx876 and NaN16 sNaN19 -> NaN Invalid_operation
+andx877 and -Inf +sNaN20 -> NaN Invalid_operation
+andx878 and -1000 sNaN21 -> NaN Invalid_operation
+andx879 and 1000 sNaN22 -> NaN Invalid_operation
+andx880 and Inf sNaN23 -> NaN Invalid_operation
+andx881 and +NaN25 +sNaN24 -> NaN Invalid_operation
+andx882 and -NaN26 NaN28 -> NaN Invalid_operation
+andx883 and -sNaN27 sNaN29 -> NaN Invalid_operation
+andx884 and 1000 -NaN30 -> NaN Invalid_operation
+andx885 and 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/class.decTest b/Lib/test/decimaltestdata/class.decTest
index fa5bc3a12f..62d2fa472f 100644
--- a/Lib/test/decimaltestdata/class.decTest
+++ b/Lib/test/decimaltestdata/class.decTest
@@ -1,131 +1,131 @@
-------------------------------------------------------------------------
--- class.decTest -- Class operations --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- [New 2006.11.27]
-
-precision: 9
-maxExponent: 999
-minExponent: -999
-extended: 1
-clamp: 1
-rounding: half_even
-
-clasx001 class 0 -> +Zero
-clasx002 class 0.00 -> +Zero
-clasx003 class 0E+5 -> +Zero
-clasx004 class 1E-1007 -> +Subnormal
-clasx005 class 0.1E-999 -> +Subnormal
-clasx006 class 0.99999999E-999 -> +Subnormal
-clasx007 class 1.00000000E-999 -> +Normal
-clasx008 class 1E-999 -> +Normal
-clasx009 class 1E-100 -> +Normal
-clasx010 class 1E-10 -> +Normal
-clasx012 class 1E-1 -> +Normal
-clasx013 class 1 -> +Normal
-clasx014 class 2.50 -> +Normal
-clasx015 class 100.100 -> +Normal
-clasx016 class 1E+30 -> +Normal
-clasx017 class 1E+999 -> +Normal
-clasx018 class 9.99999999E+999 -> +Normal
-clasx019 class Inf -> +Infinity
-
-clasx021 class -0 -> -Zero
-clasx022 class -0.00 -> -Zero
-clasx023 class -0E+5 -> -Zero
-clasx024 class -1E-1007 -> -Subnormal
-clasx025 class -0.1E-999 -> -Subnormal
-clasx026 class -0.99999999E-999 -> -Subnormal
-clasx027 class -1.00000000E-999 -> -Normal
-clasx028 class -1E-999 -> -Normal
-clasx029 class -1E-100 -> -Normal
-clasx030 class -1E-10 -> -Normal
-clasx032 class -1E-1 -> -Normal
-clasx033 class -1 -> -Normal
-clasx034 class -2.50 -> -Normal
-clasx035 class -100.100 -> -Normal
-clasx036 class -1E+30 -> -Normal
-clasx037 class -1E+999 -> -Normal
-clasx038 class -9.99999999E+999 -> -Normal
-clasx039 class -Inf -> -Infinity
-
-clasx041 class NaN -> NaN
-clasx042 class -NaN -> NaN
-clasx043 class +NaN12345 -> NaN
-clasx044 class sNaN -> sNaN
-clasx045 class -sNaN -> sNaN
-clasx046 class +sNaN12345 -> sNaN
-
-
--- decimal64 bounds
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-clamp: 1
-rounding: half_even
-
-clasx201 class 0 -> +Zero
-clasx202 class 0.00 -> +Zero
-clasx203 class 0E+5 -> +Zero
-clasx204 class 1E-396 -> +Subnormal
-clasx205 class 0.1E-383 -> +Subnormal
-clasx206 class 0.999999999999999E-383 -> +Subnormal
-clasx207 class 1.000000000000000E-383 -> +Normal
-clasx208 class 1E-383 -> +Normal
-clasx209 class 1E-100 -> +Normal
-clasx210 class 1E-10 -> +Normal
-clasx212 class 1E-1 -> +Normal
-clasx213 class 1 -> +Normal
-clasx214 class 2.50 -> +Normal
-clasx215 class 100.100 -> +Normal
-clasx216 class 1E+30 -> +Normal
-clasx217 class 1E+384 -> +Normal
-clasx218 class 9.999999999999999E+384 -> +Normal
-clasx219 class Inf -> +Infinity
-
-clasx221 class -0 -> -Zero
-clasx222 class -0.00 -> -Zero
-clasx223 class -0E+5 -> -Zero
-clasx224 class -1E-396 -> -Subnormal
-clasx225 class -0.1E-383 -> -Subnormal
-clasx226 class -0.999999999999999E-383 -> -Subnormal
-clasx227 class -1.000000000000000E-383 -> -Normal
-clasx228 class -1E-383 -> -Normal
-clasx229 class -1E-100 -> -Normal
-clasx230 class -1E-10 -> -Normal
-clasx232 class -1E-1 -> -Normal
-clasx233 class -1 -> -Normal
-clasx234 class -2.50 -> -Normal
-clasx235 class -100.100 -> -Normal
-clasx236 class -1E+30 -> -Normal
-clasx237 class -1E+384 -> -Normal
-clasx238 class -9.999999999999999E+384 -> -Normal
-clasx239 class -Inf -> -Infinity
-
-clasx241 class NaN -> NaN
-clasx242 class -NaN -> NaN
-clasx243 class +NaN12345 -> NaN
-clasx244 class sNaN -> sNaN
-clasx245 class -sNaN -> sNaN
-clasx246 class +sNaN12345 -> sNaN
-
-
-
+------------------------------------------------------------------------
+-- class.decTest -- Class operations --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- [New 2006.11.27]
+
+precision: 9
+maxExponent: 999
+minExponent: -999
+extended: 1
+clamp: 1
+rounding: half_even
+
+clasx001 class 0 -> +Zero
+clasx002 class 0.00 -> +Zero
+clasx003 class 0E+5 -> +Zero
+clasx004 class 1E-1007 -> +Subnormal
+clasx005 class 0.1E-999 -> +Subnormal
+clasx006 class 0.99999999E-999 -> +Subnormal
+clasx007 class 1.00000000E-999 -> +Normal
+clasx008 class 1E-999 -> +Normal
+clasx009 class 1E-100 -> +Normal
+clasx010 class 1E-10 -> +Normal
+clasx012 class 1E-1 -> +Normal
+clasx013 class 1 -> +Normal
+clasx014 class 2.50 -> +Normal
+clasx015 class 100.100 -> +Normal
+clasx016 class 1E+30 -> +Normal
+clasx017 class 1E+999 -> +Normal
+clasx018 class 9.99999999E+999 -> +Normal
+clasx019 class Inf -> +Infinity
+
+clasx021 class -0 -> -Zero
+clasx022 class -0.00 -> -Zero
+clasx023 class -0E+5 -> -Zero
+clasx024 class -1E-1007 -> -Subnormal
+clasx025 class -0.1E-999 -> -Subnormal
+clasx026 class -0.99999999E-999 -> -Subnormal
+clasx027 class -1.00000000E-999 -> -Normal
+clasx028 class -1E-999 -> -Normal
+clasx029 class -1E-100 -> -Normal
+clasx030 class -1E-10 -> -Normal
+clasx032 class -1E-1 -> -Normal
+clasx033 class -1 -> -Normal
+clasx034 class -2.50 -> -Normal
+clasx035 class -100.100 -> -Normal
+clasx036 class -1E+30 -> -Normal
+clasx037 class -1E+999 -> -Normal
+clasx038 class -9.99999999E+999 -> -Normal
+clasx039 class -Inf -> -Infinity
+
+clasx041 class NaN -> NaN
+clasx042 class -NaN -> NaN
+clasx043 class +NaN12345 -> NaN
+clasx044 class sNaN -> sNaN
+clasx045 class -sNaN -> sNaN
+clasx046 class +sNaN12345 -> sNaN
+
+
+-- decimal64 bounds
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+clamp: 1
+rounding: half_even
+
+clasx201 class 0 -> +Zero
+clasx202 class 0.00 -> +Zero
+clasx203 class 0E+5 -> +Zero
+clasx204 class 1E-396 -> +Subnormal
+clasx205 class 0.1E-383 -> +Subnormal
+clasx206 class 0.999999999999999E-383 -> +Subnormal
+clasx207 class 1.000000000000000E-383 -> +Normal
+clasx208 class 1E-383 -> +Normal
+clasx209 class 1E-100 -> +Normal
+clasx210 class 1E-10 -> +Normal
+clasx212 class 1E-1 -> +Normal
+clasx213 class 1 -> +Normal
+clasx214 class 2.50 -> +Normal
+clasx215 class 100.100 -> +Normal
+clasx216 class 1E+30 -> +Normal
+clasx217 class 1E+384 -> +Normal
+clasx218 class 9.999999999999999E+384 -> +Normal
+clasx219 class Inf -> +Infinity
+
+clasx221 class -0 -> -Zero
+clasx222 class -0.00 -> -Zero
+clasx223 class -0E+5 -> -Zero
+clasx224 class -1E-396 -> -Subnormal
+clasx225 class -0.1E-383 -> -Subnormal
+clasx226 class -0.999999999999999E-383 -> -Subnormal
+clasx227 class -1.000000000000000E-383 -> -Normal
+clasx228 class -1E-383 -> -Normal
+clasx229 class -1E-100 -> -Normal
+clasx230 class -1E-10 -> -Normal
+clasx232 class -1E-1 -> -Normal
+clasx233 class -1 -> -Normal
+clasx234 class -2.50 -> -Normal
+clasx235 class -100.100 -> -Normal
+clasx236 class -1E+30 -> -Normal
+clasx237 class -1E+384 -> -Normal
+clasx238 class -9.999999999999999E+384 -> -Normal
+clasx239 class -Inf -> -Infinity
+
+clasx241 class NaN -> NaN
+clasx242 class -NaN -> NaN
+clasx243 class +NaN12345 -> NaN
+clasx244 class sNaN -> sNaN
+clasx245 class -sNaN -> sNaN
+clasx246 class +sNaN12345 -> sNaN
+
+
+
diff --git a/Lib/test/decimaltestdata/comparetotal.decTest b/Lib/test/decimaltestdata/comparetotal.decTest
index 252c49fb61..ad87b4ce29 100644
--- a/Lib/test/decimaltestdata/comparetotal.decTest
+++ b/Lib/test/decimaltestdata/comparetotal.decTest
@@ -1,798 +1,798 @@
-------------------------------------------------------------------------
--- comparetotal.decTest -- decimal comparison using total ordering --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
-extended: 1
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
--- sanity checks
-cotx001 comparetotal -2 -2 -> 0
-cotx002 comparetotal -2 -1 -> -1
-cotx003 comparetotal -2 0 -> -1
-cotx004 comparetotal -2 1 -> -1
-cotx005 comparetotal -2 2 -> -1
-cotx006 comparetotal -1 -2 -> 1
-cotx007 comparetotal -1 -1 -> 0
-cotx008 comparetotal -1 0 -> -1
-cotx009 comparetotal -1 1 -> -1
-cotx010 comparetotal -1 2 -> -1
-cotx011 comparetotal 0 -2 -> 1
-cotx012 comparetotal 0 -1 -> 1
-cotx013 comparetotal 0 0 -> 0
-cotx014 comparetotal 0 1 -> -1
-cotx015 comparetotal 0 2 -> -1
-cotx016 comparetotal 1 -2 -> 1
-cotx017 comparetotal 1 -1 -> 1
-cotx018 comparetotal 1 0 -> 1
-cotx019 comparetotal 1 1 -> 0
-cotx020 comparetotal 1 2 -> -1
-cotx021 comparetotal 2 -2 -> 1
-cotx022 comparetotal 2 -1 -> 1
-cotx023 comparetotal 2 0 -> 1
-cotx025 comparetotal 2 1 -> 1
-cotx026 comparetotal 2 2 -> 0
-
-cotx031 comparetotal -20 -20 -> 0
-cotx032 comparetotal -20 -10 -> -1
-cotx033 comparetotal -20 00 -> -1
-cotx034 comparetotal -20 10 -> -1
-cotx035 comparetotal -20 20 -> -1
-cotx036 comparetotal -10 -20 -> 1
-cotx037 comparetotal -10 -10 -> 0
-cotx038 comparetotal -10 00 -> -1
-cotx039 comparetotal -10 10 -> -1
-cotx040 comparetotal -10 20 -> -1
-cotx041 comparetotal 00 -20 -> 1
-cotx042 comparetotal 00 -10 -> 1
-cotx043 comparetotal 00 00 -> 0
-cotx044 comparetotal 00 10 -> -1
-cotx045 comparetotal 00 20 -> -1
-cotx046 comparetotal 10 -20 -> 1
-cotx047 comparetotal 10 -10 -> 1
-cotx048 comparetotal 10 00 -> 1
-cotx049 comparetotal 10 10 -> 0
-cotx050 comparetotal 10 20 -> -1
-cotx051 comparetotal 20 -20 -> 1
-cotx052 comparetotal 20 -10 -> 1
-cotx053 comparetotal 20 00 -> 1
-cotx055 comparetotal 20 10 -> 1
-cotx056 comparetotal 20 20 -> 0
-
-cotx061 comparetotal -2.0 -2.0 -> 0
-cotx062 comparetotal -2.0 -1.0 -> -1
-cotx063 comparetotal -2.0 0.0 -> -1
-cotx064 comparetotal -2.0 1.0 -> -1
-cotx065 comparetotal -2.0 2.0 -> -1
-cotx066 comparetotal -1.0 -2.0 -> 1
-cotx067 comparetotal -1.0 -1.0 -> 0
-cotx068 comparetotal -1.0 0.0 -> -1
-cotx069 comparetotal -1.0 1.0 -> -1
-cotx070 comparetotal -1.0 2.0 -> -1
-cotx071 comparetotal 0.0 -2.0 -> 1
-cotx072 comparetotal 0.0 -1.0 -> 1
-cotx073 comparetotal 0.0 0.0 -> 0
-cotx074 comparetotal 0.0 1.0 -> -1
-cotx075 comparetotal 0.0 2.0 -> -1
-cotx076 comparetotal 1.0 -2.0 -> 1
-cotx077 comparetotal 1.0 -1.0 -> 1
-cotx078 comparetotal 1.0 0.0 -> 1
-cotx079 comparetotal 1.0 1.0 -> 0
-cotx080 comparetotal 1.0 2.0 -> -1
-cotx081 comparetotal 2.0 -2.0 -> 1
-cotx082 comparetotal 2.0 -1.0 -> 1
-cotx083 comparetotal 2.0 0.0 -> 1
-cotx085 comparetotal 2.0 1.0 -> 1
-cotx086 comparetotal 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-maxexponent: 999999999
-minexponent: -999999999
-cotx090 comparetotal 9.99999999E+999999999 9.99999999E+999999999 -> 0
-cotx091 comparetotal -9.99999999E+999999999 9.99999999E+999999999 -> -1
-cotx092 comparetotal 9.99999999E+999999999 -9.99999999E+999999999 -> 1
-cotx093 comparetotal -9.99999999E+999999999 -9.99999999E+999999999 -> 0
-
--- Examples
-cotx094 comparetotal 12.73 127.9 -> -1
-cotx095 comparetotal -127 12 -> -1
-cotx096 comparetotal 12.30 12.3 -> -1
-cotx097 comparetotal 12.30 12.30 -> 0
-cotx098 comparetotal 12.3 12.300 -> 1
-cotx099 comparetotal 12.3 NaN -> -1
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-cotx100 comparetotal 7.0 7.0 -> 0
-cotx101 comparetotal 7.0 7 -> -1
-cotx102 comparetotal 7 7.0 -> 1
-cotx103 comparetotal 7E+0 7.0 -> 1
-cotx104 comparetotal 70E-1 7.0 -> 0
-cotx105 comparetotal 0.7E+1 7 -> 0
-cotx106 comparetotal 70E-1 7 -> -1
-cotx107 comparetotal 7.0 7E+0 -> -1
-cotx108 comparetotal 7.0 70E-1 -> 0
-cotx109 comparetotal 7 0.7E+1 -> 0
-cotx110 comparetotal 7 70E-1 -> 1
-
-cotx120 comparetotal 8.0 7.0 -> 1
-cotx121 comparetotal 8.0 7 -> 1
-cotx122 comparetotal 8 7.0 -> 1
-cotx123 comparetotal 8E+0 7.0 -> 1
-cotx124 comparetotal 80E-1 7.0 -> 1
-cotx125 comparetotal 0.8E+1 7 -> 1
-cotx126 comparetotal 80E-1 7 -> 1
-cotx127 comparetotal 8.0 7E+0 -> 1
-cotx128 comparetotal 8.0 70E-1 -> 1
-cotx129 comparetotal 8 0.7E+1 -> 1
-cotx130 comparetotal 8 70E-1 -> 1
-
-cotx140 comparetotal 8.0 9.0 -> -1
-cotx141 comparetotal 8.0 9 -> -1
-cotx142 comparetotal 8 9.0 -> -1
-cotx143 comparetotal 8E+0 9.0 -> -1
-cotx144 comparetotal 80E-1 9.0 -> -1
-cotx145 comparetotal 0.8E+1 9 -> -1
-cotx146 comparetotal 80E-1 9 -> -1
-cotx147 comparetotal 8.0 9E+0 -> -1
-cotx148 comparetotal 8.0 90E-1 -> -1
-cotx149 comparetotal 8 0.9E+1 -> -1
-cotx150 comparetotal 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-cotx200 comparetotal -7.0 7.0 -> -1
-cotx201 comparetotal -7.0 7 -> -1
-cotx202 comparetotal -7 7.0 -> -1
-cotx203 comparetotal -7E+0 7.0 -> -1
-cotx204 comparetotal -70E-1 7.0 -> -1
-cotx205 comparetotal -0.7E+1 7 -> -1
-cotx206 comparetotal -70E-1 7 -> -1
-cotx207 comparetotal -7.0 7E+0 -> -1
-cotx208 comparetotal -7.0 70E-1 -> -1
-cotx209 comparetotal -7 0.7E+1 -> -1
-cotx210 comparetotal -7 70E-1 -> -1
-
-cotx220 comparetotal -8.0 7.0 -> -1
-cotx221 comparetotal -8.0 7 -> -1
-cotx222 comparetotal -8 7.0 -> -1
-cotx223 comparetotal -8E+0 7.0 -> -1
-cotx224 comparetotal -80E-1 7.0 -> -1
-cotx225 comparetotal -0.8E+1 7 -> -1
-cotx226 comparetotal -80E-1 7 -> -1
-cotx227 comparetotal -8.0 7E+0 -> -1
-cotx228 comparetotal -8.0 70E-1 -> -1
-cotx229 comparetotal -8 0.7E+1 -> -1
-cotx230 comparetotal -8 70E-1 -> -1
-
-cotx240 comparetotal -8.0 9.0 -> -1
-cotx241 comparetotal -8.0 9 -> -1
-cotx242 comparetotal -8 9.0 -> -1
-cotx243 comparetotal -8E+0 9.0 -> -1
-cotx244 comparetotal -80E-1 9.0 -> -1
-cotx245 comparetotal -0.8E+1 9 -> -1
-cotx246 comparetotal -80E-1 9 -> -1
-cotx247 comparetotal -8.0 9E+0 -> -1
-cotx248 comparetotal -8.0 90E-1 -> -1
-cotx249 comparetotal -8 0.9E+1 -> -1
-cotx250 comparetotal -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-cotx300 comparetotal 7.0 -7.0 -> 1
-cotx301 comparetotal 7.0 -7 -> 1
-cotx302 comparetotal 7 -7.0 -> 1
-cotx303 comparetotal 7E+0 -7.0 -> 1
-cotx304 comparetotal 70E-1 -7.0 -> 1
-cotx305 comparetotal .7E+1 -7 -> 1
-cotx306 comparetotal 70E-1 -7 -> 1
-cotx307 comparetotal 7.0 -7E+0 -> 1
-cotx308 comparetotal 7.0 -70E-1 -> 1
-cotx309 comparetotal 7 -.7E+1 -> 1
-cotx310 comparetotal 7 -70E-1 -> 1
-
-cotx320 comparetotal 8.0 -7.0 -> 1
-cotx321 comparetotal 8.0 -7 -> 1
-cotx322 comparetotal 8 -7.0 -> 1
-cotx323 comparetotal 8E+0 -7.0 -> 1
-cotx324 comparetotal 80E-1 -7.0 -> 1
-cotx325 comparetotal .8E+1 -7 -> 1
-cotx326 comparetotal 80E-1 -7 -> 1
-cotx327 comparetotal 8.0 -7E+0 -> 1
-cotx328 comparetotal 8.0 -70E-1 -> 1
-cotx329 comparetotal 8 -.7E+1 -> 1
-cotx330 comparetotal 8 -70E-1 -> 1
-
-cotx340 comparetotal 8.0 -9.0 -> 1
-cotx341 comparetotal 8.0 -9 -> 1
-cotx342 comparetotal 8 -9.0 -> 1
-cotx343 comparetotal 8E+0 -9.0 -> 1
-cotx344 comparetotal 80E-1 -9.0 -> 1
-cotx345 comparetotal .8E+1 -9 -> 1
-cotx346 comparetotal 80E-1 -9 -> 1
-cotx347 comparetotal 8.0 -9E+0 -> 1
-cotx348 comparetotal 8.0 -90E-1 -> 1
-cotx349 comparetotal 8 -.9E+1 -> 1
-cotx350 comparetotal 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-cotx400 comparetotal -7.0 -7.0 -> 0
-cotx401 comparetotal -7.0 -7 -> 1
-cotx402 comparetotal -7 -7.0 -> -1
-cotx403 comparetotal -7E+0 -7.0 -> -1
-cotx404 comparetotal -70E-1 -7.0 -> 0
-cotx405 comparetotal -.7E+1 -7 -> 0
-cotx406 comparetotal -70E-1 -7 -> 1
-cotx407 comparetotal -7.0 -7E+0 -> 1
-cotx408 comparetotal -7.0 -70E-1 -> 0
-cotx409 comparetotal -7 -.7E+1 -> 0
-cotx410 comparetotal -7 -70E-1 -> -1
-
-cotx420 comparetotal -8.0 -7.0 -> -1
-cotx421 comparetotal -8.0 -7 -> -1
-cotx422 comparetotal -8 -7.0 -> -1
-cotx423 comparetotal -8E+0 -7.0 -> -1
-cotx424 comparetotal -80E-1 -7.0 -> -1
-cotx425 comparetotal -.8E+1 -7 -> -1
-cotx426 comparetotal -80E-1 -7 -> -1
-cotx427 comparetotal -8.0 -7E+0 -> -1
-cotx428 comparetotal -8.0 -70E-1 -> -1
-cotx429 comparetotal -8 -.7E+1 -> -1
-cotx430 comparetotal -8 -70E-1 -> -1
-
-cotx440 comparetotal -8.0 -9.0 -> 1
-cotx441 comparetotal -8.0 -9 -> 1
-cotx442 comparetotal -8 -9.0 -> 1
-cotx443 comparetotal -8E+0 -9.0 -> 1
-cotx444 comparetotal -80E-1 -9.0 -> 1
-cotx445 comparetotal -.8E+1 -9 -> 1
-cotx446 comparetotal -80E-1 -9 -> 1
-cotx447 comparetotal -8.0 -9E+0 -> 1
-cotx448 comparetotal -8.0 -90E-1 -> 1
-cotx449 comparetotal -8 -.9E+1 -> 1
-cotx450 comparetotal -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-precision: 40
-cotx470 comparetotal 123.4560000000000000E789 123.456E789 -> -1
-cotx471 comparetotal 123.456000000000000E-89 123.456E-89 -> -1
-cotx472 comparetotal 123.45600000000000E789 123.456E789 -> -1
-cotx473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
-cotx474 comparetotal 123.456000000000E789 123.456E789 -> -1
-cotx475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
-cotx476 comparetotal 123.4560000000E789 123.456E789 -> -1
-cotx477 comparetotal 123.456000000E-89 123.456E-89 -> -1
-cotx478 comparetotal 123.45600000E789 123.456E789 -> -1
-cotx479 comparetotal 123.4560000E-89 123.456E-89 -> -1
-cotx480 comparetotal 123.456000E789 123.456E789 -> -1
-cotx481 comparetotal 123.45600E-89 123.456E-89 -> -1
-cotx482 comparetotal 123.4560E789 123.456E789 -> -1
-cotx483 comparetotal 123.456E-89 123.456E-89 -> 0
-cotx484 comparetotal 123.456E-89 123.4560000000000000E-89 -> 1
-cotx485 comparetotal 123.456E789 123.456000000000000E789 -> 1
-cotx486 comparetotal 123.456E-89 123.45600000000000E-89 -> 1
-cotx487 comparetotal 123.456E789 123.4560000000000E789 -> 1
-cotx488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
-cotx489 comparetotal 123.456E789 123.45600000000E789 -> 1
-cotx490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
-cotx491 comparetotal 123.456E789 123.456000000E789 -> 1
-cotx492 comparetotal 123.456E-89 123.45600000E-89 -> 1
-cotx493 comparetotal 123.456E789 123.4560000E789 -> 1
-cotx494 comparetotal 123.456E-89 123.456000E-89 -> 1
-cotx495 comparetotal 123.456E789 123.45600E789 -> 1
-cotx496 comparetotal 123.456E-89 123.4560E-89 -> 1
-cotx497 comparetotal 123.456E789 123.456E789 -> 0
-
--- wide-ranging, around precision; signs equal
-precision: 9
-cotx500 comparetotal 1 1E-15 -> 1
-cotx501 comparetotal 1 1E-14 -> 1
-cotx502 comparetotal 1 1E-13 -> 1
-cotx503 comparetotal 1 1E-12 -> 1
-cotx504 comparetotal 1 1E-11 -> 1
-cotx505 comparetotal 1 1E-10 -> 1
-cotx506 comparetotal 1 1E-9 -> 1
-cotx507 comparetotal 1 1E-8 -> 1
-cotx508 comparetotal 1 1E-7 -> 1
-cotx509 comparetotal 1 1E-6 -> 1
-cotx510 comparetotal 1 1E-5 -> 1
-cotx511 comparetotal 1 1E-4 -> 1
-cotx512 comparetotal 1 1E-3 -> 1
-cotx513 comparetotal 1 1E-2 -> 1
-cotx514 comparetotal 1 1E-1 -> 1
-cotx515 comparetotal 1 1E-0 -> 0
-cotx516 comparetotal 1 1E+1 -> -1
-cotx517 comparetotal 1 1E+2 -> -1
-cotx518 comparetotal 1 1E+3 -> -1
-cotx519 comparetotal 1 1E+4 -> -1
-cotx521 comparetotal 1 1E+5 -> -1
-cotx522 comparetotal 1 1E+6 -> -1
-cotx523 comparetotal 1 1E+7 -> -1
-cotx524 comparetotal 1 1E+8 -> -1
-cotx525 comparetotal 1 1E+9 -> -1
-cotx526 comparetotal 1 1E+10 -> -1
-cotx527 comparetotal 1 1E+11 -> -1
-cotx528 comparetotal 1 1E+12 -> -1
-cotx529 comparetotal 1 1E+13 -> -1
-cotx530 comparetotal 1 1E+14 -> -1
-cotx531 comparetotal 1 1E+15 -> -1
--- LR swap
-cotx540 comparetotal 1E-15 1 -> -1
-cotx541 comparetotal 1E-14 1 -> -1
-cotx542 comparetotal 1E-13 1 -> -1
-cotx543 comparetotal 1E-12 1 -> -1
-cotx544 comparetotal 1E-11 1 -> -1
-cotx545 comparetotal 1E-10 1 -> -1
-cotx546 comparetotal 1E-9 1 -> -1
-cotx547 comparetotal 1E-8 1 -> -1
-cotx548 comparetotal 1E-7 1 -> -1
-cotx549 comparetotal 1E-6 1 -> -1
-cotx550 comparetotal 1E-5 1 -> -1
-cotx551 comparetotal 1E-4 1 -> -1
-cotx552 comparetotal 1E-3 1 -> -1
-cotx553 comparetotal 1E-2 1 -> -1
-cotx554 comparetotal 1E-1 1 -> -1
-cotx555 comparetotal 1E-0 1 -> 0
-cotx556 comparetotal 1E+1 1 -> 1
-cotx557 comparetotal 1E+2 1 -> 1
-cotx558 comparetotal 1E+3 1 -> 1
-cotx559 comparetotal 1E+4 1 -> 1
-cotx561 comparetotal 1E+5 1 -> 1
-cotx562 comparetotal 1E+6 1 -> 1
-cotx563 comparetotal 1E+7 1 -> 1
-cotx564 comparetotal 1E+8 1 -> 1
-cotx565 comparetotal 1E+9 1 -> 1
-cotx566 comparetotal 1E+10 1 -> 1
-cotx567 comparetotal 1E+11 1 -> 1
-cotx568 comparetotal 1E+12 1 -> 1
-cotx569 comparetotal 1E+13 1 -> 1
-cotx570 comparetotal 1E+14 1 -> 1
-cotx571 comparetotal 1E+15 1 -> 1
--- similar with an useful coefficient, one side only
-cotx580 comparetotal 0.000000987654321 1E-15 -> 1
-cotx581 comparetotal 0.000000987654321 1E-14 -> 1
-cotx582 comparetotal 0.000000987654321 1E-13 -> 1
-cotx583 comparetotal 0.000000987654321 1E-12 -> 1
-cotx584 comparetotal 0.000000987654321 1E-11 -> 1
-cotx585 comparetotal 0.000000987654321 1E-10 -> 1
-cotx586 comparetotal 0.000000987654321 1E-9 -> 1
-cotx587 comparetotal 0.000000987654321 1E-8 -> 1
-cotx588 comparetotal 0.000000987654321 1E-7 -> 1
-cotx589 comparetotal 0.000000987654321 1E-6 -> -1
-cotx590 comparetotal 0.000000987654321 1E-5 -> -1
-cotx591 comparetotal 0.000000987654321 1E-4 -> -1
-cotx592 comparetotal 0.000000987654321 1E-3 -> -1
-cotx593 comparetotal 0.000000987654321 1E-2 -> -1
-cotx594 comparetotal 0.000000987654321 1E-1 -> -1
-cotx595 comparetotal 0.000000987654321 1E-0 -> -1
-cotx596 comparetotal 0.000000987654321 1E+1 -> -1
-cotx597 comparetotal 0.000000987654321 1E+2 -> -1
-cotx598 comparetotal 0.000000987654321 1E+3 -> -1
-cotx599 comparetotal 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-precision: 20
-cotx600 comparetotal 12 12.2345 -> -1
-cotx601 comparetotal 12.0 12.2345 -> -1
-cotx602 comparetotal 12.00 12.2345 -> -1
-cotx603 comparetotal 12.000 12.2345 -> -1
-cotx604 comparetotal 12.0000 12.2345 -> -1
-cotx605 comparetotal 12.00000 12.2345 -> -1
-cotx606 comparetotal 12.000000 12.2345 -> -1
-cotx607 comparetotal 12.0000000 12.2345 -> -1
-cotx608 comparetotal 12.00000000 12.2345 -> -1
-cotx609 comparetotal 12.000000000 12.2345 -> -1
-cotx610 comparetotal 12.1234 12 -> 1
-cotx611 comparetotal 12.1234 12.0 -> 1
-cotx612 comparetotal 12.1234 12.00 -> 1
-cotx613 comparetotal 12.1234 12.000 -> 1
-cotx614 comparetotal 12.1234 12.0000 -> 1
-cotx615 comparetotal 12.1234 12.00000 -> 1
-cotx616 comparetotal 12.1234 12.000000 -> 1
-cotx617 comparetotal 12.1234 12.0000000 -> 1
-cotx618 comparetotal 12.1234 12.00000000 -> 1
-cotx619 comparetotal 12.1234 12.000000000 -> 1
-cotx620 comparetotal -12 -12.2345 -> 1
-cotx621 comparetotal -12.0 -12.2345 -> 1
-cotx622 comparetotal -12.00 -12.2345 -> 1
-cotx623 comparetotal -12.000 -12.2345 -> 1
-cotx624 comparetotal -12.0000 -12.2345 -> 1
-cotx625 comparetotal -12.00000 -12.2345 -> 1
-cotx626 comparetotal -12.000000 -12.2345 -> 1
-cotx627 comparetotal -12.0000000 -12.2345 -> 1
-cotx628 comparetotal -12.00000000 -12.2345 -> 1
-cotx629 comparetotal -12.000000000 -12.2345 -> 1
-cotx630 comparetotal -12.1234 -12 -> -1
-cotx631 comparetotal -12.1234 -12.0 -> -1
-cotx632 comparetotal -12.1234 -12.00 -> -1
-cotx633 comparetotal -12.1234 -12.000 -> -1
-cotx634 comparetotal -12.1234 -12.0000 -> -1
-cotx635 comparetotal -12.1234 -12.00000 -> -1
-cotx636 comparetotal -12.1234 -12.000000 -> -1
-cotx637 comparetotal -12.1234 -12.0000000 -> -1
-cotx638 comparetotal -12.1234 -12.00000000 -> -1
-cotx639 comparetotal -12.1234 -12.000000000 -> -1
-precision: 9
-
--- extended zeros
-cotx640 comparetotal 0 0 -> 0
-cotx641 comparetotal 0 -0 -> 1
-cotx642 comparetotal 0 -0.0 -> 1
-cotx643 comparetotal 0 0.0 -> 1
-cotx644 comparetotal -0 0 -> -1
-cotx645 comparetotal -0 -0 -> 0
-cotx646 comparetotal -0 -0.0 -> -1
-cotx647 comparetotal -0 0.0 -> -1
-cotx648 comparetotal 0.0 0 -> -1
-cotx649 comparetotal 0.0 -0 -> 1
-cotx650 comparetotal 0.0 -0.0 -> 1
-cotx651 comparetotal 0.0 0.0 -> 0
-cotx652 comparetotal -0.0 0 -> -1
-cotx653 comparetotal -0.0 -0 -> 1
-cotx654 comparetotal -0.0 -0.0 -> 0
-cotx655 comparetotal -0.0 0.0 -> -1
-
-cotx656 comparetotal -0E1 0.0 -> -1
-cotx657 comparetotal -0E2 0.0 -> -1
-cotx658 comparetotal 0E1 0.0 -> 1
-cotx659 comparetotal 0E2 0.0 -> 1
-cotx660 comparetotal -0E1 0 -> -1
-cotx661 comparetotal -0E2 0 -> -1
-cotx662 comparetotal 0E1 0 -> 1
-cotx663 comparetotal 0E2 0 -> 1
-cotx664 comparetotal -0E1 -0E1 -> 0
-cotx665 comparetotal -0E2 -0E1 -> -1
-cotx666 comparetotal 0E1 -0E1 -> 1
-cotx667 comparetotal 0E2 -0E1 -> 1
-cotx668 comparetotal -0E1 -0E2 -> 1
-cotx669 comparetotal -0E2 -0E2 -> 0
-cotx670 comparetotal 0E1 -0E2 -> 1
-cotx671 comparetotal 0E2 -0E2 -> 1
-cotx672 comparetotal -0E1 0E1 -> -1
-cotx673 comparetotal -0E2 0E1 -> -1
-cotx674 comparetotal 0E1 0E1 -> 0
-cotx675 comparetotal 0E2 0E1 -> 1
-cotx676 comparetotal -0E1 0E2 -> -1
-cotx677 comparetotal -0E2 0E2 -> -1
-cotx678 comparetotal 0E1 0E2 -> -1
-cotx679 comparetotal 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-precision: 20
-cotx680 comparetotal 12 12 -> 0
-cotx681 comparetotal 12 12.0 -> 1
-cotx682 comparetotal 12 12.00 -> 1
-cotx683 comparetotal 12 12.000 -> 1
-cotx684 comparetotal 12 12.0000 -> 1
-cotx685 comparetotal 12 12.00000 -> 1
-cotx686 comparetotal 12 12.000000 -> 1
-cotx687 comparetotal 12 12.0000000 -> 1
-cotx688 comparetotal 12 12.00000000 -> 1
-cotx689 comparetotal 12 12.000000000 -> 1
-cotx690 comparetotal 12 12 -> 0
-cotx691 comparetotal 12.0 12 -> -1
-cotx692 comparetotal 12.00 12 -> -1
-cotx693 comparetotal 12.000 12 -> -1
-cotx694 comparetotal 12.0000 12 -> -1
-cotx695 comparetotal 12.00000 12 -> -1
-cotx696 comparetotal 12.000000 12 -> -1
-cotx697 comparetotal 12.0000000 12 -> -1
-cotx698 comparetotal 12.00000000 12 -> -1
-cotx699 comparetotal 12.000000000 12 -> -1
-
--- long operand checks
-maxexponent: 999
-minexponent: -999
-precision: 9
-cotx701 comparetotal 12345678000 1 -> 1
-cotx702 comparetotal 1 12345678000 -> -1
-cotx703 comparetotal 1234567800 1 -> 1
-cotx704 comparetotal 1 1234567800 -> -1
-cotx705 comparetotal 1234567890 1 -> 1
-cotx706 comparetotal 1 1234567890 -> -1
-cotx707 comparetotal 1234567891 1 -> 1
-cotx708 comparetotal 1 1234567891 -> -1
-cotx709 comparetotal 12345678901 1 -> 1
-cotx710 comparetotal 1 12345678901 -> -1
-cotx711 comparetotal 1234567896 1 -> 1
-cotx712 comparetotal 1 1234567896 -> -1
-cotx713 comparetotal -1234567891 1 -> -1
-cotx714 comparetotal 1 -1234567891 -> 1
-cotx715 comparetotal -12345678901 1 -> -1
-cotx716 comparetotal 1 -12345678901 -> 1
-cotx717 comparetotal -1234567896 1 -> -1
-cotx718 comparetotal 1 -1234567896 -> 1
-
-precision: 15
--- same with plenty of precision
-cotx721 comparetotal 12345678000 1 -> 1
-cotx722 comparetotal 1 12345678000 -> -1
-cotx723 comparetotal 1234567800 1 -> 1
-cotx724 comparetotal 1 1234567800 -> -1
-cotx725 comparetotal 1234567890 1 -> 1
-cotx726 comparetotal 1 1234567890 -> -1
-cotx727 comparetotal 1234567891 1 -> 1
-cotx728 comparetotal 1 1234567891 -> -1
-cotx729 comparetotal 12345678901 1 -> 1
-cotx730 comparetotal 1 12345678901 -> -1
-cotx731 comparetotal 1234567896 1 -> 1
-cotx732 comparetotal 1 1234567896 -> -1
-
--- residue cases
-precision: 5
-cotx740 comparetotal 1 0.9999999 -> 1
-cotx741 comparetotal 1 0.999999 -> 1
-cotx742 comparetotal 1 0.99999 -> 1
-cotx743 comparetotal 1 1.0000 -> 1
-cotx744 comparetotal 1 1.00001 -> -1
-cotx745 comparetotal 1 1.000001 -> -1
-cotx746 comparetotal 1 1.0000001 -> -1
-cotx750 comparetotal 0.9999999 1 -> -1
-cotx751 comparetotal 0.999999 1 -> -1
-cotx752 comparetotal 0.99999 1 -> -1
-cotx753 comparetotal 1.0000 1 -> -1
-cotx754 comparetotal 1.00001 1 -> 1
-cotx755 comparetotal 1.000001 1 -> 1
-cotx756 comparetotal 1.0000001 1 -> 1
-
--- a selection of longies
-cotx760 comparetotal -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1
-cotx761 comparetotal -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
-cotx762 comparetotal -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1
-cotx763 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
--- precisions above or below the difference should have no effect
-precision: 11
-cotx764 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 10
-cotx765 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 9
-cotx766 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 8
-cotx767 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 7
-cotx768 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 6
-cotx769 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 5
-cotx770 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 4
-cotx771 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 3
-cotx772 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 2
-cotx773 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 1
-cotx774 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-
--- Specials
-precision: 9
-cotx780 comparetotal Inf -Inf -> 1
-cotx781 comparetotal Inf -1000 -> 1
-cotx782 comparetotal Inf -1 -> 1
-cotx783 comparetotal Inf -0 -> 1
-cotx784 comparetotal Inf 0 -> 1
-cotx785 comparetotal Inf 1 -> 1
-cotx786 comparetotal Inf 1000 -> 1
-cotx787 comparetotal Inf Inf -> 0
-cotx788 comparetotal -1000 Inf -> -1
-cotx789 comparetotal -Inf Inf -> -1
-cotx790 comparetotal -1 Inf -> -1
-cotx791 comparetotal -0 Inf -> -1
-cotx792 comparetotal 0 Inf -> -1
-cotx793 comparetotal 1 Inf -> -1
-cotx794 comparetotal 1000 Inf -> -1
-cotx795 comparetotal Inf Inf -> 0
-
-cotx800 comparetotal -Inf -Inf -> 0
-cotx801 comparetotal -Inf -1000 -> -1
-cotx802 comparetotal -Inf -1 -> -1
-cotx803 comparetotal -Inf -0 -> -1
-cotx804 comparetotal -Inf 0 -> -1
-cotx805 comparetotal -Inf 1 -> -1
-cotx806 comparetotal -Inf 1000 -> -1
-cotx807 comparetotal -Inf Inf -> -1
-cotx808 comparetotal -Inf -Inf -> 0
-cotx809 comparetotal -1000 -Inf -> 1
-cotx810 comparetotal -1 -Inf -> 1
-cotx811 comparetotal -0 -Inf -> 1
-cotx812 comparetotal 0 -Inf -> 1
-cotx813 comparetotal 1 -Inf -> 1
-cotx814 comparetotal 1000 -Inf -> 1
-cotx815 comparetotal Inf -Inf -> 1
-
-cotx821 comparetotal NaN -Inf -> 1
-cotx822 comparetotal NaN -1000 -> 1
-cotx823 comparetotal NaN -1 -> 1
-cotx824 comparetotal NaN -0 -> 1
-cotx825 comparetotal NaN 0 -> 1
-cotx826 comparetotal NaN 1 -> 1
-cotx827 comparetotal NaN 1000 -> 1
-cotx828 comparetotal NaN Inf -> 1
-cotx829 comparetotal NaN NaN -> 0
-cotx830 comparetotal -Inf NaN -> -1
-cotx831 comparetotal -1000 NaN -> -1
-cotx832 comparetotal -1 NaN -> -1
-cotx833 comparetotal -0 NaN -> -1
-cotx834 comparetotal 0 NaN -> -1
-cotx835 comparetotal 1 NaN -> -1
-cotx836 comparetotal 1000 NaN -> -1
-cotx837 comparetotal Inf NaN -> -1
-cotx838 comparetotal -NaN -NaN -> 0
-cotx839 comparetotal +NaN -NaN -> 1
-cotx840 comparetotal -NaN +NaN -> -1
-
-cotx841 comparetotal sNaN -sNaN -> 1
-cotx842 comparetotal sNaN -NaN -> 1
-cotx843 comparetotal sNaN -Inf -> 1
-cotx844 comparetotal sNaN -1000 -> 1
-cotx845 comparetotal sNaN -1 -> 1
-cotx846 comparetotal sNaN -0 -> 1
-cotx847 comparetotal sNaN 0 -> 1
-cotx848 comparetotal sNaN 1 -> 1
-cotx849 comparetotal sNaN 1000 -> 1
-cotx850 comparetotal sNaN NaN -> -1
-cotx851 comparetotal sNaN sNaN -> 0
-
-cotx852 comparetotal -sNaN sNaN -> -1
-cotx853 comparetotal -NaN sNaN -> -1
-cotx854 comparetotal -Inf sNaN -> -1
-cotx855 comparetotal -1000 sNaN -> -1
-cotx856 comparetotal -1 sNaN -> -1
-cotx857 comparetotal -0 sNaN -> -1
-cotx858 comparetotal 0 sNaN -> -1
-cotx859 comparetotal 1 sNaN -> -1
-cotx860 comparetotal 1000 sNaN -> -1
-cotx861 comparetotal Inf sNaN -> -1
-cotx862 comparetotal NaN sNaN -> 1
-cotx863 comparetotal sNaN sNaN -> 0
-
-cotx871 comparetotal -sNaN -sNaN -> 0
-cotx872 comparetotal -sNaN -NaN -> 1
-cotx873 comparetotal -sNaN -Inf -> -1
-cotx874 comparetotal -sNaN -1000 -> -1
-cotx875 comparetotal -sNaN -1 -> -1
-cotx876 comparetotal -sNaN -0 -> -1
-cotx877 comparetotal -sNaN 0 -> -1
-cotx878 comparetotal -sNaN 1 -> -1
-cotx879 comparetotal -sNaN 1000 -> -1
-cotx880 comparetotal -sNaN NaN -> -1
-cotx881 comparetotal -sNaN sNaN -> -1
-
-cotx882 comparetotal -sNaN -sNaN -> 0
-cotx883 comparetotal -NaN -sNaN -> -1
-cotx884 comparetotal -Inf -sNaN -> 1
-cotx885 comparetotal -1000 -sNaN -> 1
-cotx886 comparetotal -1 -sNaN -> 1
-cotx887 comparetotal -0 -sNaN -> 1
-cotx888 comparetotal 0 -sNaN -> 1
-cotx889 comparetotal 1 -sNaN -> 1
-cotx890 comparetotal 1000 -sNaN -> 1
-cotx891 comparetotal Inf -sNaN -> 1
-cotx892 comparetotal NaN -sNaN -> 1
-cotx893 comparetotal sNaN -sNaN -> 1
-
--- NaNs with payload
-cotx960 comparetotal NaN9 -Inf -> 1
-cotx961 comparetotal NaN8 999 -> 1
-cotx962 comparetotal NaN77 Inf -> 1
-cotx963 comparetotal -NaN67 NaN5 -> -1
-cotx964 comparetotal -Inf -NaN4 -> 1
-cotx965 comparetotal -999 -NaN33 -> 1
-cotx966 comparetotal Inf NaN2 -> -1
-
-cotx970 comparetotal -NaN41 -NaN42 -> 1
-cotx971 comparetotal +NaN41 -NaN42 -> 1
-cotx972 comparetotal -NaN41 +NaN42 -> -1
-cotx973 comparetotal +NaN41 +NaN42 -> -1
-cotx974 comparetotal -NaN42 -NaN01 -> -1
-cotx975 comparetotal +NaN42 -NaN01 -> 1
-cotx976 comparetotal -NaN42 +NaN01 -> -1
-cotx977 comparetotal +NaN42 +NaN01 -> 1
-
-cotx980 comparetotal -sNaN771 -sNaN772 -> 1
-cotx981 comparetotal +sNaN771 -sNaN772 -> 1
-cotx982 comparetotal -sNaN771 +sNaN772 -> -1
-cotx983 comparetotal +sNaN771 +sNaN772 -> -1
-cotx984 comparetotal -sNaN772 -sNaN771 -> -1
-cotx985 comparetotal +sNaN772 -sNaN771 -> 1
-cotx986 comparetotal -sNaN772 +sNaN771 -> -1
-cotx987 comparetotal +sNaN772 +sNaN771 -> 1
-
-cotx991 comparetotal -sNaN99 -Inf -> -1
-cotx992 comparetotal sNaN98 -11 -> 1
-cotx993 comparetotal sNaN97 NaN -> -1
-cotx994 comparetotal sNaN16 sNaN94 -> -1
-cotx995 comparetotal NaN85 sNaN83 -> 1
-cotx996 comparetotal -Inf sNaN92 -> -1
-cotx997 comparetotal 088 sNaN81 -> -1
-cotx998 comparetotal Inf sNaN90 -> -1
-cotx999 comparetotal NaN -sNaN89 -> 1
-
--- overflow and underflow tests .. subnormal results now allowed
-maxExponent: 999999999
-minexponent: -999999999
-cotx1080 comparetotal +1.23456789012345E-0 9E+999999999 -> -1
-cotx1081 comparetotal 9E+999999999 +1.23456789012345E-0 -> 1
-cotx1082 comparetotal +0.100 9E-999999999 -> 1
-cotx1083 comparetotal 9E-999999999 +0.100 -> -1
-cotx1085 comparetotal -1.23456789012345E-0 9E+999999999 -> -1
-cotx1086 comparetotal 9E+999999999 -1.23456789012345E-0 -> 1
-cotx1087 comparetotal -0.100 9E-999999999 -> -1
-cotx1088 comparetotal 9E-999999999 -0.100 -> 1
-
-cotx1089 comparetotal 1e-599999999 1e-400000001 -> -1
-cotx1090 comparetotal 1e-599999999 1e-400000000 -> -1
-cotx1091 comparetotal 1e-600000000 1e-400000000 -> -1
-cotx1092 comparetotal 9e-999999998 0.01 -> -1
-cotx1093 comparetotal 9e-999999998 0.1 -> -1
-cotx1094 comparetotal 0.01 9e-999999998 -> 1
-cotx1095 comparetotal 1e599999999 1e400000001 -> 1
-cotx1096 comparetotal 1e599999999 1e400000000 -> 1
-cotx1097 comparetotal 1e600000000 1e400000000 -> 1
-cotx1098 comparetotal 9e999999998 100 -> 1
-cotx1099 comparetotal 9e999999998 10 -> 1
-cotx1100 comparetotal 100 9e999999998 -> -1
--- signs
-cotx1101 comparetotal 1e+777777777 1e+411111111 -> 1
-cotx1102 comparetotal 1e+777777777 -1e+411111111 -> 1
-cotx1103 comparetotal -1e+777777777 1e+411111111 -> -1
-cotx1104 comparetotal -1e+777777777 -1e+411111111 -> -1
-cotx1105 comparetotal 1e-777777777 1e-411111111 -> -1
-cotx1106 comparetotal 1e-777777777 -1e-411111111 -> 1
-cotx1107 comparetotal -1e-777777777 1e-411111111 -> -1
-cotx1108 comparetotal -1e-777777777 -1e-411111111 -> 1
-
--- spread zeros
-cotx1110 comparetotal 0E-383 0 -> -1
-cotx1111 comparetotal 0E-383 -0 -> 1
-cotx1112 comparetotal -0E-383 0 -> -1
-cotx1113 comparetotal -0E-383 -0 -> 1
-cotx1114 comparetotal 0E-383 0E+384 -> -1
-cotx1115 comparetotal 0E-383 -0E+384 -> 1
-cotx1116 comparetotal -0E-383 0E+384 -> -1
-cotx1117 comparetotal -0E-383 -0E+384 -> 1
-cotx1118 comparetotal 0 0E+384 -> -1
-cotx1119 comparetotal 0 -0E+384 -> 1
-cotx1120 comparetotal -0 0E+384 -> -1
-cotx1121 comparetotal -0 -0E+384 -> 1
-
-cotx1130 comparetotal 0E+384 0 -> 1
-cotx1131 comparetotal 0E+384 -0 -> 1
-cotx1132 comparetotal -0E+384 0 -> -1
-cotx1133 comparetotal -0E+384 -0 -> -1
-cotx1134 comparetotal 0E+384 0E-383 -> 1
-cotx1135 comparetotal 0E+384 -0E-383 -> 1
-cotx1136 comparetotal -0E+384 0E-383 -> -1
-cotx1137 comparetotal -0E+384 -0E-383 -> -1
-cotx1138 comparetotal 0 0E-383 -> 1
-cotx1139 comparetotal 0 -0E-383 -> 1
-cotx1140 comparetotal -0 0E-383 -> -1
-cotx1141 comparetotal -0 -0E-383 -> -1
-
--- Null tests
-cotx9990 comparetotal 10 # -> NaN Invalid_operation
-cotx9991 comparetotal # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- comparetotal.decTest -- decimal comparison using total ordering --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+extended: 1
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+-- sanity checks
+cotx001 comparetotal -2 -2 -> 0
+cotx002 comparetotal -2 -1 -> -1
+cotx003 comparetotal -2 0 -> -1
+cotx004 comparetotal -2 1 -> -1
+cotx005 comparetotal -2 2 -> -1
+cotx006 comparetotal -1 -2 -> 1
+cotx007 comparetotal -1 -1 -> 0
+cotx008 comparetotal -1 0 -> -1
+cotx009 comparetotal -1 1 -> -1
+cotx010 comparetotal -1 2 -> -1
+cotx011 comparetotal 0 -2 -> 1
+cotx012 comparetotal 0 -1 -> 1
+cotx013 comparetotal 0 0 -> 0
+cotx014 comparetotal 0 1 -> -1
+cotx015 comparetotal 0 2 -> -1
+cotx016 comparetotal 1 -2 -> 1
+cotx017 comparetotal 1 -1 -> 1
+cotx018 comparetotal 1 0 -> 1
+cotx019 comparetotal 1 1 -> 0
+cotx020 comparetotal 1 2 -> -1
+cotx021 comparetotal 2 -2 -> 1
+cotx022 comparetotal 2 -1 -> 1
+cotx023 comparetotal 2 0 -> 1
+cotx025 comparetotal 2 1 -> 1
+cotx026 comparetotal 2 2 -> 0
+
+cotx031 comparetotal -20 -20 -> 0
+cotx032 comparetotal -20 -10 -> -1
+cotx033 comparetotal -20 00 -> -1
+cotx034 comparetotal -20 10 -> -1
+cotx035 comparetotal -20 20 -> -1
+cotx036 comparetotal -10 -20 -> 1
+cotx037 comparetotal -10 -10 -> 0
+cotx038 comparetotal -10 00 -> -1
+cotx039 comparetotal -10 10 -> -1
+cotx040 comparetotal -10 20 -> -1
+cotx041 comparetotal 00 -20 -> 1
+cotx042 comparetotal 00 -10 -> 1
+cotx043 comparetotal 00 00 -> 0
+cotx044 comparetotal 00 10 -> -1
+cotx045 comparetotal 00 20 -> -1
+cotx046 comparetotal 10 -20 -> 1
+cotx047 comparetotal 10 -10 -> 1
+cotx048 comparetotal 10 00 -> 1
+cotx049 comparetotal 10 10 -> 0
+cotx050 comparetotal 10 20 -> -1
+cotx051 comparetotal 20 -20 -> 1
+cotx052 comparetotal 20 -10 -> 1
+cotx053 comparetotal 20 00 -> 1
+cotx055 comparetotal 20 10 -> 1
+cotx056 comparetotal 20 20 -> 0
+
+cotx061 comparetotal -2.0 -2.0 -> 0
+cotx062 comparetotal -2.0 -1.0 -> -1
+cotx063 comparetotal -2.0 0.0 -> -1
+cotx064 comparetotal -2.0 1.0 -> -1
+cotx065 comparetotal -2.0 2.0 -> -1
+cotx066 comparetotal -1.0 -2.0 -> 1
+cotx067 comparetotal -1.0 -1.0 -> 0
+cotx068 comparetotal -1.0 0.0 -> -1
+cotx069 comparetotal -1.0 1.0 -> -1
+cotx070 comparetotal -1.0 2.0 -> -1
+cotx071 comparetotal 0.0 -2.0 -> 1
+cotx072 comparetotal 0.0 -1.0 -> 1
+cotx073 comparetotal 0.0 0.0 -> 0
+cotx074 comparetotal 0.0 1.0 -> -1
+cotx075 comparetotal 0.0 2.0 -> -1
+cotx076 comparetotal 1.0 -2.0 -> 1
+cotx077 comparetotal 1.0 -1.0 -> 1
+cotx078 comparetotal 1.0 0.0 -> 1
+cotx079 comparetotal 1.0 1.0 -> 0
+cotx080 comparetotal 1.0 2.0 -> -1
+cotx081 comparetotal 2.0 -2.0 -> 1
+cotx082 comparetotal 2.0 -1.0 -> 1
+cotx083 comparetotal 2.0 0.0 -> 1
+cotx085 comparetotal 2.0 1.0 -> 1
+cotx086 comparetotal 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+maxexponent: 999999999
+minexponent: -999999999
+cotx090 comparetotal 9.99999999E+999999999 9.99999999E+999999999 -> 0
+cotx091 comparetotal -9.99999999E+999999999 9.99999999E+999999999 -> -1
+cotx092 comparetotal 9.99999999E+999999999 -9.99999999E+999999999 -> 1
+cotx093 comparetotal -9.99999999E+999999999 -9.99999999E+999999999 -> 0
+
+-- Examples
+cotx094 comparetotal 12.73 127.9 -> -1
+cotx095 comparetotal -127 12 -> -1
+cotx096 comparetotal 12.30 12.3 -> -1
+cotx097 comparetotal 12.30 12.30 -> 0
+cotx098 comparetotal 12.3 12.300 -> 1
+cotx099 comparetotal 12.3 NaN -> -1
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+cotx100 comparetotal 7.0 7.0 -> 0
+cotx101 comparetotal 7.0 7 -> -1
+cotx102 comparetotal 7 7.0 -> 1
+cotx103 comparetotal 7E+0 7.0 -> 1
+cotx104 comparetotal 70E-1 7.0 -> 0
+cotx105 comparetotal 0.7E+1 7 -> 0
+cotx106 comparetotal 70E-1 7 -> -1
+cotx107 comparetotal 7.0 7E+0 -> -1
+cotx108 comparetotal 7.0 70E-1 -> 0
+cotx109 comparetotal 7 0.7E+1 -> 0
+cotx110 comparetotal 7 70E-1 -> 1
+
+cotx120 comparetotal 8.0 7.0 -> 1
+cotx121 comparetotal 8.0 7 -> 1
+cotx122 comparetotal 8 7.0 -> 1
+cotx123 comparetotal 8E+0 7.0 -> 1
+cotx124 comparetotal 80E-1 7.0 -> 1
+cotx125 comparetotal 0.8E+1 7 -> 1
+cotx126 comparetotal 80E-1 7 -> 1
+cotx127 comparetotal 8.0 7E+0 -> 1
+cotx128 comparetotal 8.0 70E-1 -> 1
+cotx129 comparetotal 8 0.7E+1 -> 1
+cotx130 comparetotal 8 70E-1 -> 1
+
+cotx140 comparetotal 8.0 9.0 -> -1
+cotx141 comparetotal 8.0 9 -> -1
+cotx142 comparetotal 8 9.0 -> -1
+cotx143 comparetotal 8E+0 9.0 -> -1
+cotx144 comparetotal 80E-1 9.0 -> -1
+cotx145 comparetotal 0.8E+1 9 -> -1
+cotx146 comparetotal 80E-1 9 -> -1
+cotx147 comparetotal 8.0 9E+0 -> -1
+cotx148 comparetotal 8.0 90E-1 -> -1
+cotx149 comparetotal 8 0.9E+1 -> -1
+cotx150 comparetotal 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+cotx200 comparetotal -7.0 7.0 -> -1
+cotx201 comparetotal -7.0 7 -> -1
+cotx202 comparetotal -7 7.0 -> -1
+cotx203 comparetotal -7E+0 7.0 -> -1
+cotx204 comparetotal -70E-1 7.0 -> -1
+cotx205 comparetotal -0.7E+1 7 -> -1
+cotx206 comparetotal -70E-1 7 -> -1
+cotx207 comparetotal -7.0 7E+0 -> -1
+cotx208 comparetotal -7.0 70E-1 -> -1
+cotx209 comparetotal -7 0.7E+1 -> -1
+cotx210 comparetotal -7 70E-1 -> -1
+
+cotx220 comparetotal -8.0 7.0 -> -1
+cotx221 comparetotal -8.0 7 -> -1
+cotx222 comparetotal -8 7.0 -> -1
+cotx223 comparetotal -8E+0 7.0 -> -1
+cotx224 comparetotal -80E-1 7.0 -> -1
+cotx225 comparetotal -0.8E+1 7 -> -1
+cotx226 comparetotal -80E-1 7 -> -1
+cotx227 comparetotal -8.0 7E+0 -> -1
+cotx228 comparetotal -8.0 70E-1 -> -1
+cotx229 comparetotal -8 0.7E+1 -> -1
+cotx230 comparetotal -8 70E-1 -> -1
+
+cotx240 comparetotal -8.0 9.0 -> -1
+cotx241 comparetotal -8.0 9 -> -1
+cotx242 comparetotal -8 9.0 -> -1
+cotx243 comparetotal -8E+0 9.0 -> -1
+cotx244 comparetotal -80E-1 9.0 -> -1
+cotx245 comparetotal -0.8E+1 9 -> -1
+cotx246 comparetotal -80E-1 9 -> -1
+cotx247 comparetotal -8.0 9E+0 -> -1
+cotx248 comparetotal -8.0 90E-1 -> -1
+cotx249 comparetotal -8 0.9E+1 -> -1
+cotx250 comparetotal -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+cotx300 comparetotal 7.0 -7.0 -> 1
+cotx301 comparetotal 7.0 -7 -> 1
+cotx302 comparetotal 7 -7.0 -> 1
+cotx303 comparetotal 7E+0 -7.0 -> 1
+cotx304 comparetotal 70E-1 -7.0 -> 1
+cotx305 comparetotal .7E+1 -7 -> 1
+cotx306 comparetotal 70E-1 -7 -> 1
+cotx307 comparetotal 7.0 -7E+0 -> 1
+cotx308 comparetotal 7.0 -70E-1 -> 1
+cotx309 comparetotal 7 -.7E+1 -> 1
+cotx310 comparetotal 7 -70E-1 -> 1
+
+cotx320 comparetotal 8.0 -7.0 -> 1
+cotx321 comparetotal 8.0 -7 -> 1
+cotx322 comparetotal 8 -7.0 -> 1
+cotx323 comparetotal 8E+0 -7.0 -> 1
+cotx324 comparetotal 80E-1 -7.0 -> 1
+cotx325 comparetotal .8E+1 -7 -> 1
+cotx326 comparetotal 80E-1 -7 -> 1
+cotx327 comparetotal 8.0 -7E+0 -> 1
+cotx328 comparetotal 8.0 -70E-1 -> 1
+cotx329 comparetotal 8 -.7E+1 -> 1
+cotx330 comparetotal 8 -70E-1 -> 1
+
+cotx340 comparetotal 8.0 -9.0 -> 1
+cotx341 comparetotal 8.0 -9 -> 1
+cotx342 comparetotal 8 -9.0 -> 1
+cotx343 comparetotal 8E+0 -9.0 -> 1
+cotx344 comparetotal 80E-1 -9.0 -> 1
+cotx345 comparetotal .8E+1 -9 -> 1
+cotx346 comparetotal 80E-1 -9 -> 1
+cotx347 comparetotal 8.0 -9E+0 -> 1
+cotx348 comparetotal 8.0 -90E-1 -> 1
+cotx349 comparetotal 8 -.9E+1 -> 1
+cotx350 comparetotal 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+cotx400 comparetotal -7.0 -7.0 -> 0
+cotx401 comparetotal -7.0 -7 -> 1
+cotx402 comparetotal -7 -7.0 -> -1
+cotx403 comparetotal -7E+0 -7.0 -> -1
+cotx404 comparetotal -70E-1 -7.0 -> 0
+cotx405 comparetotal -.7E+1 -7 -> 0
+cotx406 comparetotal -70E-1 -7 -> 1
+cotx407 comparetotal -7.0 -7E+0 -> 1
+cotx408 comparetotal -7.0 -70E-1 -> 0
+cotx409 comparetotal -7 -.7E+1 -> 0
+cotx410 comparetotal -7 -70E-1 -> -1
+
+cotx420 comparetotal -8.0 -7.0 -> -1
+cotx421 comparetotal -8.0 -7 -> -1
+cotx422 comparetotal -8 -7.0 -> -1
+cotx423 comparetotal -8E+0 -7.0 -> -1
+cotx424 comparetotal -80E-1 -7.0 -> -1
+cotx425 comparetotal -.8E+1 -7 -> -1
+cotx426 comparetotal -80E-1 -7 -> -1
+cotx427 comparetotal -8.0 -7E+0 -> -1
+cotx428 comparetotal -8.0 -70E-1 -> -1
+cotx429 comparetotal -8 -.7E+1 -> -1
+cotx430 comparetotal -8 -70E-1 -> -1
+
+cotx440 comparetotal -8.0 -9.0 -> 1
+cotx441 comparetotal -8.0 -9 -> 1
+cotx442 comparetotal -8 -9.0 -> 1
+cotx443 comparetotal -8E+0 -9.0 -> 1
+cotx444 comparetotal -80E-1 -9.0 -> 1
+cotx445 comparetotal -.8E+1 -9 -> 1
+cotx446 comparetotal -80E-1 -9 -> 1
+cotx447 comparetotal -8.0 -9E+0 -> 1
+cotx448 comparetotal -8.0 -90E-1 -> 1
+cotx449 comparetotal -8 -.9E+1 -> 1
+cotx450 comparetotal -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+precision: 40
+cotx470 comparetotal 123.4560000000000000E789 123.456E789 -> -1
+cotx471 comparetotal 123.456000000000000E-89 123.456E-89 -> -1
+cotx472 comparetotal 123.45600000000000E789 123.456E789 -> -1
+cotx473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
+cotx474 comparetotal 123.456000000000E789 123.456E789 -> -1
+cotx475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
+cotx476 comparetotal 123.4560000000E789 123.456E789 -> -1
+cotx477 comparetotal 123.456000000E-89 123.456E-89 -> -1
+cotx478 comparetotal 123.45600000E789 123.456E789 -> -1
+cotx479 comparetotal 123.4560000E-89 123.456E-89 -> -1
+cotx480 comparetotal 123.456000E789 123.456E789 -> -1
+cotx481 comparetotal 123.45600E-89 123.456E-89 -> -1
+cotx482 comparetotal 123.4560E789 123.456E789 -> -1
+cotx483 comparetotal 123.456E-89 123.456E-89 -> 0
+cotx484 comparetotal 123.456E-89 123.4560000000000000E-89 -> 1
+cotx485 comparetotal 123.456E789 123.456000000000000E789 -> 1
+cotx486 comparetotal 123.456E-89 123.45600000000000E-89 -> 1
+cotx487 comparetotal 123.456E789 123.4560000000000E789 -> 1
+cotx488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
+cotx489 comparetotal 123.456E789 123.45600000000E789 -> 1
+cotx490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
+cotx491 comparetotal 123.456E789 123.456000000E789 -> 1
+cotx492 comparetotal 123.456E-89 123.45600000E-89 -> 1
+cotx493 comparetotal 123.456E789 123.4560000E789 -> 1
+cotx494 comparetotal 123.456E-89 123.456000E-89 -> 1
+cotx495 comparetotal 123.456E789 123.45600E789 -> 1
+cotx496 comparetotal 123.456E-89 123.4560E-89 -> 1
+cotx497 comparetotal 123.456E789 123.456E789 -> 0
+
+-- wide-ranging, around precision; signs equal
+precision: 9
+cotx500 comparetotal 1 1E-15 -> 1
+cotx501 comparetotal 1 1E-14 -> 1
+cotx502 comparetotal 1 1E-13 -> 1
+cotx503 comparetotal 1 1E-12 -> 1
+cotx504 comparetotal 1 1E-11 -> 1
+cotx505 comparetotal 1 1E-10 -> 1
+cotx506 comparetotal 1 1E-9 -> 1
+cotx507 comparetotal 1 1E-8 -> 1
+cotx508 comparetotal 1 1E-7 -> 1
+cotx509 comparetotal 1 1E-6 -> 1
+cotx510 comparetotal 1 1E-5 -> 1
+cotx511 comparetotal 1 1E-4 -> 1
+cotx512 comparetotal 1 1E-3 -> 1
+cotx513 comparetotal 1 1E-2 -> 1
+cotx514 comparetotal 1 1E-1 -> 1
+cotx515 comparetotal 1 1E-0 -> 0
+cotx516 comparetotal 1 1E+1 -> -1
+cotx517 comparetotal 1 1E+2 -> -1
+cotx518 comparetotal 1 1E+3 -> -1
+cotx519 comparetotal 1 1E+4 -> -1
+cotx521 comparetotal 1 1E+5 -> -1
+cotx522 comparetotal 1 1E+6 -> -1
+cotx523 comparetotal 1 1E+7 -> -1
+cotx524 comparetotal 1 1E+8 -> -1
+cotx525 comparetotal 1 1E+9 -> -1
+cotx526 comparetotal 1 1E+10 -> -1
+cotx527 comparetotal 1 1E+11 -> -1
+cotx528 comparetotal 1 1E+12 -> -1
+cotx529 comparetotal 1 1E+13 -> -1
+cotx530 comparetotal 1 1E+14 -> -1
+cotx531 comparetotal 1 1E+15 -> -1
+-- LR swap
+cotx540 comparetotal 1E-15 1 -> -1
+cotx541 comparetotal 1E-14 1 -> -1
+cotx542 comparetotal 1E-13 1 -> -1
+cotx543 comparetotal 1E-12 1 -> -1
+cotx544 comparetotal 1E-11 1 -> -1
+cotx545 comparetotal 1E-10 1 -> -1
+cotx546 comparetotal 1E-9 1 -> -1
+cotx547 comparetotal 1E-8 1 -> -1
+cotx548 comparetotal 1E-7 1 -> -1
+cotx549 comparetotal 1E-6 1 -> -1
+cotx550 comparetotal 1E-5 1 -> -1
+cotx551 comparetotal 1E-4 1 -> -1
+cotx552 comparetotal 1E-3 1 -> -1
+cotx553 comparetotal 1E-2 1 -> -1
+cotx554 comparetotal 1E-1 1 -> -1
+cotx555 comparetotal 1E-0 1 -> 0
+cotx556 comparetotal 1E+1 1 -> 1
+cotx557 comparetotal 1E+2 1 -> 1
+cotx558 comparetotal 1E+3 1 -> 1
+cotx559 comparetotal 1E+4 1 -> 1
+cotx561 comparetotal 1E+5 1 -> 1
+cotx562 comparetotal 1E+6 1 -> 1
+cotx563 comparetotal 1E+7 1 -> 1
+cotx564 comparetotal 1E+8 1 -> 1
+cotx565 comparetotal 1E+9 1 -> 1
+cotx566 comparetotal 1E+10 1 -> 1
+cotx567 comparetotal 1E+11 1 -> 1
+cotx568 comparetotal 1E+12 1 -> 1
+cotx569 comparetotal 1E+13 1 -> 1
+cotx570 comparetotal 1E+14 1 -> 1
+cotx571 comparetotal 1E+15 1 -> 1
+-- similar with an useful coefficient, one side only
+cotx580 comparetotal 0.000000987654321 1E-15 -> 1
+cotx581 comparetotal 0.000000987654321 1E-14 -> 1
+cotx582 comparetotal 0.000000987654321 1E-13 -> 1
+cotx583 comparetotal 0.000000987654321 1E-12 -> 1
+cotx584 comparetotal 0.000000987654321 1E-11 -> 1
+cotx585 comparetotal 0.000000987654321 1E-10 -> 1
+cotx586 comparetotal 0.000000987654321 1E-9 -> 1
+cotx587 comparetotal 0.000000987654321 1E-8 -> 1
+cotx588 comparetotal 0.000000987654321 1E-7 -> 1
+cotx589 comparetotal 0.000000987654321 1E-6 -> -1
+cotx590 comparetotal 0.000000987654321 1E-5 -> -1
+cotx591 comparetotal 0.000000987654321 1E-4 -> -1
+cotx592 comparetotal 0.000000987654321 1E-3 -> -1
+cotx593 comparetotal 0.000000987654321 1E-2 -> -1
+cotx594 comparetotal 0.000000987654321 1E-1 -> -1
+cotx595 comparetotal 0.000000987654321 1E-0 -> -1
+cotx596 comparetotal 0.000000987654321 1E+1 -> -1
+cotx597 comparetotal 0.000000987654321 1E+2 -> -1
+cotx598 comparetotal 0.000000987654321 1E+3 -> -1
+cotx599 comparetotal 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+precision: 20
+cotx600 comparetotal 12 12.2345 -> -1
+cotx601 comparetotal 12.0 12.2345 -> -1
+cotx602 comparetotal 12.00 12.2345 -> -1
+cotx603 comparetotal 12.000 12.2345 -> -1
+cotx604 comparetotal 12.0000 12.2345 -> -1
+cotx605 comparetotal 12.00000 12.2345 -> -1
+cotx606 comparetotal 12.000000 12.2345 -> -1
+cotx607 comparetotal 12.0000000 12.2345 -> -1
+cotx608 comparetotal 12.00000000 12.2345 -> -1
+cotx609 comparetotal 12.000000000 12.2345 -> -1
+cotx610 comparetotal 12.1234 12 -> 1
+cotx611 comparetotal 12.1234 12.0 -> 1
+cotx612 comparetotal 12.1234 12.00 -> 1
+cotx613 comparetotal 12.1234 12.000 -> 1
+cotx614 comparetotal 12.1234 12.0000 -> 1
+cotx615 comparetotal 12.1234 12.00000 -> 1
+cotx616 comparetotal 12.1234 12.000000 -> 1
+cotx617 comparetotal 12.1234 12.0000000 -> 1
+cotx618 comparetotal 12.1234 12.00000000 -> 1
+cotx619 comparetotal 12.1234 12.000000000 -> 1
+cotx620 comparetotal -12 -12.2345 -> 1
+cotx621 comparetotal -12.0 -12.2345 -> 1
+cotx622 comparetotal -12.00 -12.2345 -> 1
+cotx623 comparetotal -12.000 -12.2345 -> 1
+cotx624 comparetotal -12.0000 -12.2345 -> 1
+cotx625 comparetotal -12.00000 -12.2345 -> 1
+cotx626 comparetotal -12.000000 -12.2345 -> 1
+cotx627 comparetotal -12.0000000 -12.2345 -> 1
+cotx628 comparetotal -12.00000000 -12.2345 -> 1
+cotx629 comparetotal -12.000000000 -12.2345 -> 1
+cotx630 comparetotal -12.1234 -12 -> -1
+cotx631 comparetotal -12.1234 -12.0 -> -1
+cotx632 comparetotal -12.1234 -12.00 -> -1
+cotx633 comparetotal -12.1234 -12.000 -> -1
+cotx634 comparetotal -12.1234 -12.0000 -> -1
+cotx635 comparetotal -12.1234 -12.00000 -> -1
+cotx636 comparetotal -12.1234 -12.000000 -> -1
+cotx637 comparetotal -12.1234 -12.0000000 -> -1
+cotx638 comparetotal -12.1234 -12.00000000 -> -1
+cotx639 comparetotal -12.1234 -12.000000000 -> -1
+precision: 9
+
+-- extended zeros
+cotx640 comparetotal 0 0 -> 0
+cotx641 comparetotal 0 -0 -> 1
+cotx642 comparetotal 0 -0.0 -> 1
+cotx643 comparetotal 0 0.0 -> 1
+cotx644 comparetotal -0 0 -> -1
+cotx645 comparetotal -0 -0 -> 0
+cotx646 comparetotal -0 -0.0 -> -1
+cotx647 comparetotal -0 0.0 -> -1
+cotx648 comparetotal 0.0 0 -> -1
+cotx649 comparetotal 0.0 -0 -> 1
+cotx650 comparetotal 0.0 -0.0 -> 1
+cotx651 comparetotal 0.0 0.0 -> 0
+cotx652 comparetotal -0.0 0 -> -1
+cotx653 comparetotal -0.0 -0 -> 1
+cotx654 comparetotal -0.0 -0.0 -> 0
+cotx655 comparetotal -0.0 0.0 -> -1
+
+cotx656 comparetotal -0E1 0.0 -> -1
+cotx657 comparetotal -0E2 0.0 -> -1
+cotx658 comparetotal 0E1 0.0 -> 1
+cotx659 comparetotal 0E2 0.0 -> 1
+cotx660 comparetotal -0E1 0 -> -1
+cotx661 comparetotal -0E2 0 -> -1
+cotx662 comparetotal 0E1 0 -> 1
+cotx663 comparetotal 0E2 0 -> 1
+cotx664 comparetotal -0E1 -0E1 -> 0
+cotx665 comparetotal -0E2 -0E1 -> -1
+cotx666 comparetotal 0E1 -0E1 -> 1
+cotx667 comparetotal 0E2 -0E1 -> 1
+cotx668 comparetotal -0E1 -0E2 -> 1
+cotx669 comparetotal -0E2 -0E2 -> 0
+cotx670 comparetotal 0E1 -0E2 -> 1
+cotx671 comparetotal 0E2 -0E2 -> 1
+cotx672 comparetotal -0E1 0E1 -> -1
+cotx673 comparetotal -0E2 0E1 -> -1
+cotx674 comparetotal 0E1 0E1 -> 0
+cotx675 comparetotal 0E2 0E1 -> 1
+cotx676 comparetotal -0E1 0E2 -> -1
+cotx677 comparetotal -0E2 0E2 -> -1
+cotx678 comparetotal 0E1 0E2 -> -1
+cotx679 comparetotal 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+precision: 20
+cotx680 comparetotal 12 12 -> 0
+cotx681 comparetotal 12 12.0 -> 1
+cotx682 comparetotal 12 12.00 -> 1
+cotx683 comparetotal 12 12.000 -> 1
+cotx684 comparetotal 12 12.0000 -> 1
+cotx685 comparetotal 12 12.00000 -> 1
+cotx686 comparetotal 12 12.000000 -> 1
+cotx687 comparetotal 12 12.0000000 -> 1
+cotx688 comparetotal 12 12.00000000 -> 1
+cotx689 comparetotal 12 12.000000000 -> 1
+cotx690 comparetotal 12 12 -> 0
+cotx691 comparetotal 12.0 12 -> -1
+cotx692 comparetotal 12.00 12 -> -1
+cotx693 comparetotal 12.000 12 -> -1
+cotx694 comparetotal 12.0000 12 -> -1
+cotx695 comparetotal 12.00000 12 -> -1
+cotx696 comparetotal 12.000000 12 -> -1
+cotx697 comparetotal 12.0000000 12 -> -1
+cotx698 comparetotal 12.00000000 12 -> -1
+cotx699 comparetotal 12.000000000 12 -> -1
+
+-- long operand checks
+maxexponent: 999
+minexponent: -999
+precision: 9
+cotx701 comparetotal 12345678000 1 -> 1
+cotx702 comparetotal 1 12345678000 -> -1
+cotx703 comparetotal 1234567800 1 -> 1
+cotx704 comparetotal 1 1234567800 -> -1
+cotx705 comparetotal 1234567890 1 -> 1
+cotx706 comparetotal 1 1234567890 -> -1
+cotx707 comparetotal 1234567891 1 -> 1
+cotx708 comparetotal 1 1234567891 -> -1
+cotx709 comparetotal 12345678901 1 -> 1
+cotx710 comparetotal 1 12345678901 -> -1
+cotx711 comparetotal 1234567896 1 -> 1
+cotx712 comparetotal 1 1234567896 -> -1
+cotx713 comparetotal -1234567891 1 -> -1
+cotx714 comparetotal 1 -1234567891 -> 1
+cotx715 comparetotal -12345678901 1 -> -1
+cotx716 comparetotal 1 -12345678901 -> 1
+cotx717 comparetotal -1234567896 1 -> -1
+cotx718 comparetotal 1 -1234567896 -> 1
+
+precision: 15
+-- same with plenty of precision
+cotx721 comparetotal 12345678000 1 -> 1
+cotx722 comparetotal 1 12345678000 -> -1
+cotx723 comparetotal 1234567800 1 -> 1
+cotx724 comparetotal 1 1234567800 -> -1
+cotx725 comparetotal 1234567890 1 -> 1
+cotx726 comparetotal 1 1234567890 -> -1
+cotx727 comparetotal 1234567891 1 -> 1
+cotx728 comparetotal 1 1234567891 -> -1
+cotx729 comparetotal 12345678901 1 -> 1
+cotx730 comparetotal 1 12345678901 -> -1
+cotx731 comparetotal 1234567896 1 -> 1
+cotx732 comparetotal 1 1234567896 -> -1
+
+-- residue cases
+precision: 5
+cotx740 comparetotal 1 0.9999999 -> 1
+cotx741 comparetotal 1 0.999999 -> 1
+cotx742 comparetotal 1 0.99999 -> 1
+cotx743 comparetotal 1 1.0000 -> 1
+cotx744 comparetotal 1 1.00001 -> -1
+cotx745 comparetotal 1 1.000001 -> -1
+cotx746 comparetotal 1 1.0000001 -> -1
+cotx750 comparetotal 0.9999999 1 -> -1
+cotx751 comparetotal 0.999999 1 -> -1
+cotx752 comparetotal 0.99999 1 -> -1
+cotx753 comparetotal 1.0000 1 -> -1
+cotx754 comparetotal 1.00001 1 -> 1
+cotx755 comparetotal 1.000001 1 -> 1
+cotx756 comparetotal 1.0000001 1 -> 1
+
+-- a selection of longies
+cotx760 comparetotal -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1
+cotx761 comparetotal -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
+cotx762 comparetotal -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1
+cotx763 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+-- precisions above or below the difference should have no effect
+precision: 11
+cotx764 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 10
+cotx765 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 9
+cotx766 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 8
+cotx767 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 7
+cotx768 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 6
+cotx769 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 5
+cotx770 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 4
+cotx771 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 3
+cotx772 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 2
+cotx773 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 1
+cotx774 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+
+-- Specials
+precision: 9
+cotx780 comparetotal Inf -Inf -> 1
+cotx781 comparetotal Inf -1000 -> 1
+cotx782 comparetotal Inf -1 -> 1
+cotx783 comparetotal Inf -0 -> 1
+cotx784 comparetotal Inf 0 -> 1
+cotx785 comparetotal Inf 1 -> 1
+cotx786 comparetotal Inf 1000 -> 1
+cotx787 comparetotal Inf Inf -> 0
+cotx788 comparetotal -1000 Inf -> -1
+cotx789 comparetotal -Inf Inf -> -1
+cotx790 comparetotal -1 Inf -> -1
+cotx791 comparetotal -0 Inf -> -1
+cotx792 comparetotal 0 Inf -> -1
+cotx793 comparetotal 1 Inf -> -1
+cotx794 comparetotal 1000 Inf -> -1
+cotx795 comparetotal Inf Inf -> 0
+
+cotx800 comparetotal -Inf -Inf -> 0
+cotx801 comparetotal -Inf -1000 -> -1
+cotx802 comparetotal -Inf -1 -> -1
+cotx803 comparetotal -Inf -0 -> -1
+cotx804 comparetotal -Inf 0 -> -1
+cotx805 comparetotal -Inf 1 -> -1
+cotx806 comparetotal -Inf 1000 -> -1
+cotx807 comparetotal -Inf Inf -> -1
+cotx808 comparetotal -Inf -Inf -> 0
+cotx809 comparetotal -1000 -Inf -> 1
+cotx810 comparetotal -1 -Inf -> 1
+cotx811 comparetotal -0 -Inf -> 1
+cotx812 comparetotal 0 -Inf -> 1
+cotx813 comparetotal 1 -Inf -> 1
+cotx814 comparetotal 1000 -Inf -> 1
+cotx815 comparetotal Inf -Inf -> 1
+
+cotx821 comparetotal NaN -Inf -> 1
+cotx822 comparetotal NaN -1000 -> 1
+cotx823 comparetotal NaN -1 -> 1
+cotx824 comparetotal NaN -0 -> 1
+cotx825 comparetotal NaN 0 -> 1
+cotx826 comparetotal NaN 1 -> 1
+cotx827 comparetotal NaN 1000 -> 1
+cotx828 comparetotal NaN Inf -> 1
+cotx829 comparetotal NaN NaN -> 0
+cotx830 comparetotal -Inf NaN -> -1
+cotx831 comparetotal -1000 NaN -> -1
+cotx832 comparetotal -1 NaN -> -1
+cotx833 comparetotal -0 NaN -> -1
+cotx834 comparetotal 0 NaN -> -1
+cotx835 comparetotal 1 NaN -> -1
+cotx836 comparetotal 1000 NaN -> -1
+cotx837 comparetotal Inf NaN -> -1
+cotx838 comparetotal -NaN -NaN -> 0
+cotx839 comparetotal +NaN -NaN -> 1
+cotx840 comparetotal -NaN +NaN -> -1
+
+cotx841 comparetotal sNaN -sNaN -> 1
+cotx842 comparetotal sNaN -NaN -> 1
+cotx843 comparetotal sNaN -Inf -> 1
+cotx844 comparetotal sNaN -1000 -> 1
+cotx845 comparetotal sNaN -1 -> 1
+cotx846 comparetotal sNaN -0 -> 1
+cotx847 comparetotal sNaN 0 -> 1
+cotx848 comparetotal sNaN 1 -> 1
+cotx849 comparetotal sNaN 1000 -> 1
+cotx850 comparetotal sNaN NaN -> -1
+cotx851 comparetotal sNaN sNaN -> 0
+
+cotx852 comparetotal -sNaN sNaN -> -1
+cotx853 comparetotal -NaN sNaN -> -1
+cotx854 comparetotal -Inf sNaN -> -1
+cotx855 comparetotal -1000 sNaN -> -1
+cotx856 comparetotal -1 sNaN -> -1
+cotx857 comparetotal -0 sNaN -> -1
+cotx858 comparetotal 0 sNaN -> -1
+cotx859 comparetotal 1 sNaN -> -1
+cotx860 comparetotal 1000 sNaN -> -1
+cotx861 comparetotal Inf sNaN -> -1
+cotx862 comparetotal NaN sNaN -> 1
+cotx863 comparetotal sNaN sNaN -> 0
+
+cotx871 comparetotal -sNaN -sNaN -> 0
+cotx872 comparetotal -sNaN -NaN -> 1
+cotx873 comparetotal -sNaN -Inf -> -1
+cotx874 comparetotal -sNaN -1000 -> -1
+cotx875 comparetotal -sNaN -1 -> -1
+cotx876 comparetotal -sNaN -0 -> -1
+cotx877 comparetotal -sNaN 0 -> -1
+cotx878 comparetotal -sNaN 1 -> -1
+cotx879 comparetotal -sNaN 1000 -> -1
+cotx880 comparetotal -sNaN NaN -> -1
+cotx881 comparetotal -sNaN sNaN -> -1
+
+cotx882 comparetotal -sNaN -sNaN -> 0
+cotx883 comparetotal -NaN -sNaN -> -1
+cotx884 comparetotal -Inf -sNaN -> 1
+cotx885 comparetotal -1000 -sNaN -> 1
+cotx886 comparetotal -1 -sNaN -> 1
+cotx887 comparetotal -0 -sNaN -> 1
+cotx888 comparetotal 0 -sNaN -> 1
+cotx889 comparetotal 1 -sNaN -> 1
+cotx890 comparetotal 1000 -sNaN -> 1
+cotx891 comparetotal Inf -sNaN -> 1
+cotx892 comparetotal NaN -sNaN -> 1
+cotx893 comparetotal sNaN -sNaN -> 1
+
+-- NaNs with payload
+cotx960 comparetotal NaN9 -Inf -> 1
+cotx961 comparetotal NaN8 999 -> 1
+cotx962 comparetotal NaN77 Inf -> 1
+cotx963 comparetotal -NaN67 NaN5 -> -1
+cotx964 comparetotal -Inf -NaN4 -> 1
+cotx965 comparetotal -999 -NaN33 -> 1
+cotx966 comparetotal Inf NaN2 -> -1
+
+cotx970 comparetotal -NaN41 -NaN42 -> 1
+cotx971 comparetotal +NaN41 -NaN42 -> 1
+cotx972 comparetotal -NaN41 +NaN42 -> -1
+cotx973 comparetotal +NaN41 +NaN42 -> -1
+cotx974 comparetotal -NaN42 -NaN01 -> -1
+cotx975 comparetotal +NaN42 -NaN01 -> 1
+cotx976 comparetotal -NaN42 +NaN01 -> -1
+cotx977 comparetotal +NaN42 +NaN01 -> 1
+
+cotx980 comparetotal -sNaN771 -sNaN772 -> 1
+cotx981 comparetotal +sNaN771 -sNaN772 -> 1
+cotx982 comparetotal -sNaN771 +sNaN772 -> -1
+cotx983 comparetotal +sNaN771 +sNaN772 -> -1
+cotx984 comparetotal -sNaN772 -sNaN771 -> -1
+cotx985 comparetotal +sNaN772 -sNaN771 -> 1
+cotx986 comparetotal -sNaN772 +sNaN771 -> -1
+cotx987 comparetotal +sNaN772 +sNaN771 -> 1
+
+cotx991 comparetotal -sNaN99 -Inf -> -1
+cotx992 comparetotal sNaN98 -11 -> 1
+cotx993 comparetotal sNaN97 NaN -> -1
+cotx994 comparetotal sNaN16 sNaN94 -> -1
+cotx995 comparetotal NaN85 sNaN83 -> 1
+cotx996 comparetotal -Inf sNaN92 -> -1
+cotx997 comparetotal 088 sNaN81 -> -1
+cotx998 comparetotal Inf sNaN90 -> -1
+cotx999 comparetotal NaN -sNaN89 -> 1
+
+-- overflow and underflow tests .. subnormal results now allowed
+maxExponent: 999999999
+minexponent: -999999999
+cotx1080 comparetotal +1.23456789012345E-0 9E+999999999 -> -1
+cotx1081 comparetotal 9E+999999999 +1.23456789012345E-0 -> 1
+cotx1082 comparetotal +0.100 9E-999999999 -> 1
+cotx1083 comparetotal 9E-999999999 +0.100 -> -1
+cotx1085 comparetotal -1.23456789012345E-0 9E+999999999 -> -1
+cotx1086 comparetotal 9E+999999999 -1.23456789012345E-0 -> 1
+cotx1087 comparetotal -0.100 9E-999999999 -> -1
+cotx1088 comparetotal 9E-999999999 -0.100 -> 1
+
+cotx1089 comparetotal 1e-599999999 1e-400000001 -> -1
+cotx1090 comparetotal 1e-599999999 1e-400000000 -> -1
+cotx1091 comparetotal 1e-600000000 1e-400000000 -> -1
+cotx1092 comparetotal 9e-999999998 0.01 -> -1
+cotx1093 comparetotal 9e-999999998 0.1 -> -1
+cotx1094 comparetotal 0.01 9e-999999998 -> 1
+cotx1095 comparetotal 1e599999999 1e400000001 -> 1
+cotx1096 comparetotal 1e599999999 1e400000000 -> 1
+cotx1097 comparetotal 1e600000000 1e400000000 -> 1
+cotx1098 comparetotal 9e999999998 100 -> 1
+cotx1099 comparetotal 9e999999998 10 -> 1
+cotx1100 comparetotal 100 9e999999998 -> -1
+-- signs
+cotx1101 comparetotal 1e+777777777 1e+411111111 -> 1
+cotx1102 comparetotal 1e+777777777 -1e+411111111 -> 1
+cotx1103 comparetotal -1e+777777777 1e+411111111 -> -1
+cotx1104 comparetotal -1e+777777777 -1e+411111111 -> -1
+cotx1105 comparetotal 1e-777777777 1e-411111111 -> -1
+cotx1106 comparetotal 1e-777777777 -1e-411111111 -> 1
+cotx1107 comparetotal -1e-777777777 1e-411111111 -> -1
+cotx1108 comparetotal -1e-777777777 -1e-411111111 -> 1
+
+-- spread zeros
+cotx1110 comparetotal 0E-383 0 -> -1
+cotx1111 comparetotal 0E-383 -0 -> 1
+cotx1112 comparetotal -0E-383 0 -> -1
+cotx1113 comparetotal -0E-383 -0 -> 1
+cotx1114 comparetotal 0E-383 0E+384 -> -1
+cotx1115 comparetotal 0E-383 -0E+384 -> 1
+cotx1116 comparetotal -0E-383 0E+384 -> -1
+cotx1117 comparetotal -0E-383 -0E+384 -> 1
+cotx1118 comparetotal 0 0E+384 -> -1
+cotx1119 comparetotal 0 -0E+384 -> 1
+cotx1120 comparetotal -0 0E+384 -> -1
+cotx1121 comparetotal -0 -0E+384 -> 1
+
+cotx1130 comparetotal 0E+384 0 -> 1
+cotx1131 comparetotal 0E+384 -0 -> 1
+cotx1132 comparetotal -0E+384 0 -> -1
+cotx1133 comparetotal -0E+384 -0 -> -1
+cotx1134 comparetotal 0E+384 0E-383 -> 1
+cotx1135 comparetotal 0E+384 -0E-383 -> 1
+cotx1136 comparetotal -0E+384 0E-383 -> -1
+cotx1137 comparetotal -0E+384 -0E-383 -> -1
+cotx1138 comparetotal 0 0E-383 -> 1
+cotx1139 comparetotal 0 -0E-383 -> 1
+cotx1140 comparetotal -0 0E-383 -> -1
+cotx1141 comparetotal -0 -0E-383 -> -1
+
+-- Null tests
+cotx9990 comparetotal 10 # -> NaN Invalid_operation
+cotx9991 comparetotal # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/comparetotmag.decTest b/Lib/test/decimaltestdata/comparetotmag.decTest
index cedfdf8843..e87c9f2dbf 100644
--- a/Lib/test/decimaltestdata/comparetotmag.decTest
+++ b/Lib/test/decimaltestdata/comparetotmag.decTest
@@ -1,790 +1,790 @@
-------------------------------------------------------------------------
--- comparetotmag.decTest -- decimal comparison, abs. total ordering --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that it cannot be assumed that add/subtract tests cover paths
--- for this operation adequately, here, because the code might be
--- quite different (comparison cannot overflow or underflow, so
--- actual subtractions are not necessary). Similarly, comparetotal
--- will have some radically different paths than compare.
-
-extended: 1
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
--- sanity checks
-ctmx001 comparetotmag -2 -2 -> 0
-ctmx002 comparetotmag -2 -1 -> 1
-ctmx003 comparetotmag -2 0 -> 1
-ctmx004 comparetotmag -2 1 -> 1
-ctmx005 comparetotmag -2 2 -> 0
-ctmx006 comparetotmag -1 -2 -> -1
-ctmx007 comparetotmag -1 -1 -> 0
-ctmx008 comparetotmag -1 0 -> 1
-ctmx009 comparetotmag -1 1 -> 0
-ctmx010 comparetotmag -1 2 -> -1
-ctmx011 comparetotmag 0 -2 -> -1
-ctmx012 comparetotmag 0 -1 -> -1
-ctmx013 comparetotmag 0 0 -> 0
-ctmx014 comparetotmag 0 1 -> -1
-ctmx015 comparetotmag 0 2 -> -1
-ctmx016 comparetotmag 1 -2 -> -1
-ctmx017 comparetotmag 1 -1 -> 0
-ctmx018 comparetotmag 1 0 -> 1
-ctmx019 comparetotmag 1 1 -> 0
-ctmx020 comparetotmag 1 2 -> -1
-ctmx021 comparetotmag 2 -2 -> 0
-ctmx022 comparetotmag 2 -1 -> 1
-ctmx023 comparetotmag 2 0 -> 1
-ctmx025 comparetotmag 2 1 -> 1
-ctmx026 comparetotmag 2 2 -> 0
-
-ctmx031 comparetotmag -20 -20 -> 0
-ctmx032 comparetotmag -20 -10 -> 1
-ctmx033 comparetotmag -20 00 -> 1
-ctmx034 comparetotmag -20 10 -> 1
-ctmx035 comparetotmag -20 20 -> 0
-ctmx036 comparetotmag -10 -20 -> -1
-ctmx037 comparetotmag -10 -10 -> 0
-ctmx038 comparetotmag -10 00 -> 1
-ctmx039 comparetotmag -10 10 -> 0
-ctmx040 comparetotmag -10 20 -> -1
-ctmx041 comparetotmag 00 -20 -> -1
-ctmx042 comparetotmag 00 -10 -> -1
-ctmx043 comparetotmag 00 00 -> 0
-ctmx044 comparetotmag 00 10 -> -1
-ctmx045 comparetotmag 00 20 -> -1
-ctmx046 comparetotmag 10 -20 -> -1
-ctmx047 comparetotmag 10 -10 -> 0
-ctmx048 comparetotmag 10 00 -> 1
-ctmx049 comparetotmag 10 10 -> 0
-ctmx050 comparetotmag 10 20 -> -1
-ctmx051 comparetotmag 20 -20 -> 0
-ctmx052 comparetotmag 20 -10 -> 1
-ctmx053 comparetotmag 20 00 -> 1
-ctmx055 comparetotmag 20 10 -> 1
-ctmx056 comparetotmag 20 20 -> 0
-
-ctmx061 comparetotmag -2.0 -2.0 -> 0
-ctmx062 comparetotmag -2.0 -1.0 -> 1
-ctmx063 comparetotmag -2.0 0.0 -> 1
-ctmx064 comparetotmag -2.0 1.0 -> 1
-ctmx065 comparetotmag -2.0 2.0 -> 0
-ctmx066 comparetotmag -1.0 -2.0 -> -1
-ctmx067 comparetotmag -1.0 -1.0 -> 0
-ctmx068 comparetotmag -1.0 0.0 -> 1
-ctmx069 comparetotmag -1.0 1.0 -> 0
-ctmx070 comparetotmag -1.0 2.0 -> -1
-ctmx071 comparetotmag 0.0 -2.0 -> -1
-ctmx072 comparetotmag 0.0 -1.0 -> -1
-ctmx073 comparetotmag 0.0 0.0 -> 0
-ctmx074 comparetotmag 0.0 1.0 -> -1
-ctmx075 comparetotmag 0.0 2.0 -> -1
-ctmx076 comparetotmag 1.0 -2.0 -> -1
-ctmx077 comparetotmag 1.0 -1.0 -> 0
-ctmx078 comparetotmag 1.0 0.0 -> 1
-ctmx079 comparetotmag 1.0 1.0 -> 0
-ctmx080 comparetotmag 1.0 2.0 -> -1
-ctmx081 comparetotmag 2.0 -2.0 -> 0
-ctmx082 comparetotmag 2.0 -1.0 -> 1
-ctmx083 comparetotmag 2.0 0.0 -> 1
-ctmx085 comparetotmag 2.0 1.0 -> 1
-ctmx086 comparetotmag 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-maxexponent: 999999999
-minexponent: -999999999
-ctmx090 comparetotmag 9.99999999E+999999999 9.99999999E+999999999 -> 0
-ctmx091 comparetotmag -9.99999999E+999999999 9.99999999E+999999999 -> 0
-ctmx092 comparetotmag 9.99999999E+999999999 -9.99999999E+999999999 -> 0
-ctmx093 comparetotmag -9.99999999E+999999999 -9.99999999E+999999999 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-ctmx100 comparetotmag 7.0 7.0 -> 0
-ctmx101 comparetotmag 7.0 7 -> -1
-ctmx102 comparetotmag 7 7.0 -> 1
-ctmx103 comparetotmag 7E+0 7.0 -> 1
-ctmx104 comparetotmag 70E-1 7.0 -> 0
-ctmx105 comparetotmag 0.7E+1 7 -> 0
-ctmx106 comparetotmag 70E-1 7 -> -1
-ctmx107 comparetotmag 7.0 7E+0 -> -1
-ctmx108 comparetotmag 7.0 70E-1 -> 0
-ctmx109 comparetotmag 7 0.7E+1 -> 0
-ctmx110 comparetotmag 7 70E-1 -> 1
-
-ctmx120 comparetotmag 8.0 7.0 -> 1
-ctmx121 comparetotmag 8.0 7 -> 1
-ctmx122 comparetotmag 8 7.0 -> 1
-ctmx123 comparetotmag 8E+0 7.0 -> 1
-ctmx124 comparetotmag 80E-1 7.0 -> 1
-ctmx125 comparetotmag 0.8E+1 7 -> 1
-ctmx126 comparetotmag 80E-1 7 -> 1
-ctmx127 comparetotmag 8.0 7E+0 -> 1
-ctmx128 comparetotmag 8.0 70E-1 -> 1
-ctmx129 comparetotmag 8 0.7E+1 -> 1
-ctmx130 comparetotmag 8 70E-1 -> 1
-
-ctmx140 comparetotmag 8.0 9.0 -> -1
-ctmx141 comparetotmag 8.0 9 -> -1
-ctmx142 comparetotmag 8 9.0 -> -1
-ctmx143 comparetotmag 8E+0 9.0 -> -1
-ctmx144 comparetotmag 80E-1 9.0 -> -1
-ctmx145 comparetotmag 0.8E+1 9 -> -1
-ctmx146 comparetotmag 80E-1 9 -> -1
-ctmx147 comparetotmag 8.0 9E+0 -> -1
-ctmx148 comparetotmag 8.0 90E-1 -> -1
-ctmx149 comparetotmag 8 0.9E+1 -> -1
-ctmx150 comparetotmag 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ctmx200 comparetotmag -7.0 7.0 -> 0
-ctmx201 comparetotmag -7.0 7 -> -1
-ctmx202 comparetotmag -7 7.0 -> 1
-ctmx203 comparetotmag -7E+0 7.0 -> 1
-ctmx204 comparetotmag -70E-1 7.0 -> 0
-ctmx205 comparetotmag -0.7E+1 7 -> 0
-ctmx206 comparetotmag -70E-1 7 -> -1
-ctmx207 comparetotmag -7.0 7E+0 -> -1
-ctmx208 comparetotmag -7.0 70E-1 -> 0
-ctmx209 comparetotmag -7 0.7E+1 -> 0
-ctmx210 comparetotmag -7 70E-1 -> 1
-
-ctmx220 comparetotmag -8.0 7.0 -> 1
-ctmx221 comparetotmag -8.0 7 -> 1
-ctmx222 comparetotmag -8 7.0 -> 1
-ctmx223 comparetotmag -8E+0 7.0 -> 1
-ctmx224 comparetotmag -80E-1 7.0 -> 1
-ctmx225 comparetotmag -0.8E+1 7 -> 1
-ctmx226 comparetotmag -80E-1 7 -> 1
-ctmx227 comparetotmag -8.0 7E+0 -> 1
-ctmx228 comparetotmag -8.0 70E-1 -> 1
-ctmx229 comparetotmag -8 0.7E+1 -> 1
-ctmx230 comparetotmag -8 70E-1 -> 1
-
-ctmx240 comparetotmag -8.0 9.0 -> -1
-ctmx241 comparetotmag -8.0 9 -> -1
-ctmx242 comparetotmag -8 9.0 -> -1
-ctmx243 comparetotmag -8E+0 9.0 -> -1
-ctmx244 comparetotmag -80E-1 9.0 -> -1
-ctmx245 comparetotmag -0.8E+1 9 -> -1
-ctmx246 comparetotmag -80E-1 9 -> -1
-ctmx247 comparetotmag -8.0 9E+0 -> -1
-ctmx248 comparetotmag -8.0 90E-1 -> -1
-ctmx249 comparetotmag -8 0.9E+1 -> -1
-ctmx250 comparetotmag -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ctmx300 comparetotmag 7.0 -7.0 -> 0
-ctmx301 comparetotmag 7.0 -7 -> -1
-ctmx302 comparetotmag 7 -7.0 -> 1
-ctmx303 comparetotmag 7E+0 -7.0 -> 1
-ctmx304 comparetotmag 70E-1 -7.0 -> 0
-ctmx305 comparetotmag .7E+1 -7 -> 0
-ctmx306 comparetotmag 70E-1 -7 -> -1
-ctmx307 comparetotmag 7.0 -7E+0 -> -1
-ctmx308 comparetotmag 7.0 -70E-1 -> 0
-ctmx309 comparetotmag 7 -.7E+1 -> 0
-ctmx310 comparetotmag 7 -70E-1 -> 1
-
-ctmx320 comparetotmag 8.0 -7.0 -> 1
-ctmx321 comparetotmag 8.0 -7 -> 1
-ctmx322 comparetotmag 8 -7.0 -> 1
-ctmx323 comparetotmag 8E+0 -7.0 -> 1
-ctmx324 comparetotmag 80E-1 -7.0 -> 1
-ctmx325 comparetotmag .8E+1 -7 -> 1
-ctmx326 comparetotmag 80E-1 -7 -> 1
-ctmx327 comparetotmag 8.0 -7E+0 -> 1
-ctmx328 comparetotmag 8.0 -70E-1 -> 1
-ctmx329 comparetotmag 8 -.7E+1 -> 1
-ctmx330 comparetotmag 8 -70E-1 -> 1
-
-ctmx340 comparetotmag 8.0 -9.0 -> -1
-ctmx341 comparetotmag 8.0 -9 -> -1
-ctmx342 comparetotmag 8 -9.0 -> -1
-ctmx343 comparetotmag 8E+0 -9.0 -> -1
-ctmx344 comparetotmag 80E-1 -9.0 -> -1
-ctmx345 comparetotmag .8E+1 -9 -> -1
-ctmx346 comparetotmag 80E-1 -9 -> -1
-ctmx347 comparetotmag 8.0 -9E+0 -> -1
-ctmx348 comparetotmag 8.0 -90E-1 -> -1
-ctmx349 comparetotmag 8 -.9E+1 -> -1
-ctmx350 comparetotmag 8 -90E-1 -> -1
-
--- and again, with sign changes -- ..
-ctmx400 comparetotmag -7.0 -7.0 -> 0
-ctmx401 comparetotmag -7.0 -7 -> -1
-ctmx402 comparetotmag -7 -7.0 -> 1
-ctmx403 comparetotmag -7E+0 -7.0 -> 1
-ctmx404 comparetotmag -70E-1 -7.0 -> 0
-ctmx405 comparetotmag -.7E+1 -7 -> 0
-ctmx406 comparetotmag -70E-1 -7 -> -1
-ctmx407 comparetotmag -7.0 -7E+0 -> -1
-ctmx408 comparetotmag -7.0 -70E-1 -> 0
-ctmx409 comparetotmag -7 -.7E+1 -> 0
-ctmx410 comparetotmag -7 -70E-1 -> 1
-
-ctmx420 comparetotmag -8.0 -7.0 -> 1
-ctmx421 comparetotmag -8.0 -7 -> 1
-ctmx422 comparetotmag -8 -7.0 -> 1
-ctmx423 comparetotmag -8E+0 -7.0 -> 1
-ctmx424 comparetotmag -80E-1 -7.0 -> 1
-ctmx425 comparetotmag -.8E+1 -7 -> 1
-ctmx426 comparetotmag -80E-1 -7 -> 1
-ctmx427 comparetotmag -8.0 -7E+0 -> 1
-ctmx428 comparetotmag -8.0 -70E-1 -> 1
-ctmx429 comparetotmag -8 -.7E+1 -> 1
-ctmx430 comparetotmag -8 -70E-1 -> 1
-
-ctmx440 comparetotmag -8.0 -9.0 -> -1
-ctmx441 comparetotmag -8.0 -9 -> -1
-ctmx442 comparetotmag -8 -9.0 -> -1
-ctmx443 comparetotmag -8E+0 -9.0 -> -1
-ctmx444 comparetotmag -80E-1 -9.0 -> -1
-ctmx445 comparetotmag -.8E+1 -9 -> -1
-ctmx446 comparetotmag -80E-1 -9 -> -1
-ctmx447 comparetotmag -8.0 -9E+0 -> -1
-ctmx448 comparetotmag -8.0 -90E-1 -> -1
-ctmx449 comparetotmag -8 -.9E+1 -> -1
-ctmx450 comparetotmag -8 -90E-1 -> -1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-precision: 40
-ctmx470 comparetotmag 123.4560000000000000E789 123.456E789 -> -1
-ctmx471 comparetotmag 123.456000000000000E-89 123.456E-89 -> -1
-ctmx472 comparetotmag 123.45600000000000E789 123.456E789 -> -1
-ctmx473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
-ctmx474 comparetotmag 123.456000000000E789 123.456E789 -> -1
-ctmx475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
-ctmx476 comparetotmag 123.4560000000E789 123.456E789 -> -1
-ctmx477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
-ctmx478 comparetotmag 123.45600000E789 123.456E789 -> -1
-ctmx479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
-ctmx480 comparetotmag 123.456000E789 123.456E789 -> -1
-ctmx481 comparetotmag 123.45600E-89 123.456E-89 -> -1
-ctmx482 comparetotmag 123.4560E789 123.456E789 -> -1
-ctmx483 comparetotmag 123.456E-89 123.456E-89 -> 0
-ctmx484 comparetotmag 123.456E-89 123.4560000000000000E-89 -> 1
-ctmx485 comparetotmag 123.456E789 123.456000000000000E789 -> 1
-ctmx486 comparetotmag 123.456E-89 123.45600000000000E-89 -> 1
-ctmx487 comparetotmag 123.456E789 123.4560000000000E789 -> 1
-ctmx488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
-ctmx489 comparetotmag 123.456E789 123.45600000000E789 -> 1
-ctmx490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
-ctmx491 comparetotmag 123.456E789 123.456000000E789 -> 1
-ctmx492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
-ctmx493 comparetotmag 123.456E789 123.4560000E789 -> 1
-ctmx494 comparetotmag 123.456E-89 123.456000E-89 -> 1
-ctmx495 comparetotmag 123.456E789 123.45600E789 -> 1
-ctmx496 comparetotmag 123.456E-89 123.4560E-89 -> 1
-ctmx497 comparetotmag 123.456E789 123.456E789 -> 0
-
--- wide-ranging, around precision; signs equal
-precision: 9
-ctmx500 comparetotmag 1 1E-15 -> 1
-ctmx501 comparetotmag 1 1E-14 -> 1
-ctmx502 comparetotmag 1 1E-13 -> 1
-ctmx503 comparetotmag 1 1E-12 -> 1
-ctmx504 comparetotmag 1 1E-11 -> 1
-ctmx505 comparetotmag 1 1E-10 -> 1
-ctmx506 comparetotmag 1 1E-9 -> 1
-ctmx507 comparetotmag 1 1E-8 -> 1
-ctmx508 comparetotmag 1 1E-7 -> 1
-ctmx509 comparetotmag 1 1E-6 -> 1
-ctmx510 comparetotmag 1 1E-5 -> 1
-ctmx511 comparetotmag 1 1E-4 -> 1
-ctmx512 comparetotmag 1 1E-3 -> 1
-ctmx513 comparetotmag 1 1E-2 -> 1
-ctmx514 comparetotmag 1 1E-1 -> 1
-ctmx515 comparetotmag 1 1E-0 -> 0
-ctmx516 comparetotmag 1 1E+1 -> -1
-ctmx517 comparetotmag 1 1E+2 -> -1
-ctmx518 comparetotmag 1 1E+3 -> -1
-ctmx519 comparetotmag 1 1E+4 -> -1
-ctmx521 comparetotmag 1 1E+5 -> -1
-ctmx522 comparetotmag 1 1E+6 -> -1
-ctmx523 comparetotmag 1 1E+7 -> -1
-ctmx524 comparetotmag 1 1E+8 -> -1
-ctmx525 comparetotmag 1 1E+9 -> -1
-ctmx526 comparetotmag 1 1E+10 -> -1
-ctmx527 comparetotmag 1 1E+11 -> -1
-ctmx528 comparetotmag 1 1E+12 -> -1
-ctmx529 comparetotmag 1 1E+13 -> -1
-ctmx530 comparetotmag 1 1E+14 -> -1
-ctmx531 comparetotmag 1 1E+15 -> -1
--- LR swap
-ctmx540 comparetotmag 1E-15 1 -> -1
-ctmx541 comparetotmag 1E-14 1 -> -1
-ctmx542 comparetotmag 1E-13 1 -> -1
-ctmx543 comparetotmag 1E-12 1 -> -1
-ctmx544 comparetotmag 1E-11 1 -> -1
-ctmx545 comparetotmag 1E-10 1 -> -1
-ctmx546 comparetotmag 1E-9 1 -> -1
-ctmx547 comparetotmag 1E-8 1 -> -1
-ctmx548 comparetotmag 1E-7 1 -> -1
-ctmx549 comparetotmag 1E-6 1 -> -1
-ctmx550 comparetotmag 1E-5 1 -> -1
-ctmx551 comparetotmag 1E-4 1 -> -1
-ctmx552 comparetotmag 1E-3 1 -> -1
-ctmx553 comparetotmag 1E-2 1 -> -1
-ctmx554 comparetotmag 1E-1 1 -> -1
-ctmx555 comparetotmag 1E-0 1 -> 0
-ctmx556 comparetotmag 1E+1 1 -> 1
-ctmx557 comparetotmag 1E+2 1 -> 1
-ctmx558 comparetotmag 1E+3 1 -> 1
-ctmx559 comparetotmag 1E+4 1 -> 1
-ctmx561 comparetotmag 1E+5 1 -> 1
-ctmx562 comparetotmag 1E+6 1 -> 1
-ctmx563 comparetotmag 1E+7 1 -> 1
-ctmx564 comparetotmag 1E+8 1 -> 1
-ctmx565 comparetotmag 1E+9 1 -> 1
-ctmx566 comparetotmag 1E+10 1 -> 1
-ctmx567 comparetotmag 1E+11 1 -> 1
-ctmx568 comparetotmag 1E+12 1 -> 1
-ctmx569 comparetotmag 1E+13 1 -> 1
-ctmx570 comparetotmag 1E+14 1 -> 1
-ctmx571 comparetotmag 1E+15 1 -> 1
--- similar with an useful coefficient, one side only
-ctmx580 comparetotmag 0.000000987654321 1E-15 -> 1
-ctmx581 comparetotmag 0.000000987654321 1E-14 -> 1
-ctmx582 comparetotmag 0.000000987654321 1E-13 -> 1
-ctmx583 comparetotmag 0.000000987654321 1E-12 -> 1
-ctmx584 comparetotmag 0.000000987654321 1E-11 -> 1
-ctmx585 comparetotmag 0.000000987654321 1E-10 -> 1
-ctmx586 comparetotmag 0.000000987654321 1E-9 -> 1
-ctmx587 comparetotmag 0.000000987654321 1E-8 -> 1
-ctmx588 comparetotmag 0.000000987654321 1E-7 -> 1
-ctmx589 comparetotmag 0.000000987654321 1E-6 -> -1
-ctmx590 comparetotmag 0.000000987654321 1E-5 -> -1
-ctmx591 comparetotmag 0.000000987654321 1E-4 -> -1
-ctmx592 comparetotmag 0.000000987654321 1E-3 -> -1
-ctmx593 comparetotmag 0.000000987654321 1E-2 -> -1
-ctmx594 comparetotmag 0.000000987654321 1E-1 -> -1
-ctmx595 comparetotmag 0.000000987654321 1E-0 -> -1
-ctmx596 comparetotmag 0.000000987654321 1E+1 -> -1
-ctmx597 comparetotmag 0.000000987654321 1E+2 -> -1
-ctmx598 comparetotmag 0.000000987654321 1E+3 -> -1
-ctmx599 comparetotmag 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-precision: 20
-ctmx600 comparetotmag 12 12.2345 -> -1
-ctmx601 comparetotmag 12.0 12.2345 -> -1
-ctmx602 comparetotmag 12.00 12.2345 -> -1
-ctmx603 comparetotmag 12.000 12.2345 -> -1
-ctmx604 comparetotmag 12.0000 12.2345 -> -1
-ctmx605 comparetotmag 12.00000 12.2345 -> -1
-ctmx606 comparetotmag 12.000000 12.2345 -> -1
-ctmx607 comparetotmag 12.0000000 12.2345 -> -1
-ctmx608 comparetotmag 12.00000000 12.2345 -> -1
-ctmx609 comparetotmag 12.000000000 12.2345 -> -1
-ctmx610 comparetotmag 12.1234 12 -> 1
-ctmx611 comparetotmag 12.1234 12.0 -> 1
-ctmx612 comparetotmag 12.1234 12.00 -> 1
-ctmx613 comparetotmag 12.1234 12.000 -> 1
-ctmx614 comparetotmag 12.1234 12.0000 -> 1
-ctmx615 comparetotmag 12.1234 12.00000 -> 1
-ctmx616 comparetotmag 12.1234 12.000000 -> 1
-ctmx617 comparetotmag 12.1234 12.0000000 -> 1
-ctmx618 comparetotmag 12.1234 12.00000000 -> 1
-ctmx619 comparetotmag 12.1234 12.000000000 -> 1
-ctmx620 comparetotmag -12 -12.2345 -> -1
-ctmx621 comparetotmag -12.0 -12.2345 -> -1
-ctmx622 comparetotmag -12.00 -12.2345 -> -1
-ctmx623 comparetotmag -12.000 -12.2345 -> -1
-ctmx624 comparetotmag -12.0000 -12.2345 -> -1
-ctmx625 comparetotmag -12.00000 -12.2345 -> -1
-ctmx626 comparetotmag -12.000000 -12.2345 -> -1
-ctmx627 comparetotmag -12.0000000 -12.2345 -> -1
-ctmx628 comparetotmag -12.00000000 -12.2345 -> -1
-ctmx629 comparetotmag -12.000000000 -12.2345 -> -1
-ctmx630 comparetotmag -12.1234 -12 -> 1
-ctmx631 comparetotmag -12.1234 -12.0 -> 1
-ctmx632 comparetotmag -12.1234 -12.00 -> 1
-ctmx633 comparetotmag -12.1234 -12.000 -> 1
-ctmx634 comparetotmag -12.1234 -12.0000 -> 1
-ctmx635 comparetotmag -12.1234 -12.00000 -> 1
-ctmx636 comparetotmag -12.1234 -12.000000 -> 1
-ctmx637 comparetotmag -12.1234 -12.0000000 -> 1
-ctmx638 comparetotmag -12.1234 -12.00000000 -> 1
-ctmx639 comparetotmag -12.1234 -12.000000000 -> 1
-precision: 9
-
--- extended zeros
-ctmx640 comparetotmag 0 0 -> 0
-ctmx641 comparetotmag 0 -0 -> 0
-ctmx642 comparetotmag 0 -0.0 -> 1
-ctmx643 comparetotmag 0 0.0 -> 1
-ctmx644 comparetotmag -0 0 -> 0
-ctmx645 comparetotmag -0 -0 -> 0
-ctmx646 comparetotmag -0 -0.0 -> 1
-ctmx647 comparetotmag -0 0.0 -> 1
-ctmx648 comparetotmag 0.0 0 -> -1
-ctmx649 comparetotmag 0.0 -0 -> -1
-ctmx650 comparetotmag 0.0 -0.0 -> 0
-ctmx651 comparetotmag 0.0 0.0 -> 0
-ctmx652 comparetotmag -0.0 0 -> -1
-ctmx653 comparetotmag -0.0 -0 -> -1
-ctmx654 comparetotmag -0.0 -0.0 -> 0
-ctmx655 comparetotmag -0.0 0.0 -> 0
-
-ctmx656 comparetotmag -0E1 0.0 -> 1
-ctmx657 comparetotmag -0E2 0.0 -> 1
-ctmx658 comparetotmag 0E1 0.0 -> 1
-ctmx659 comparetotmag 0E2 0.0 -> 1
-ctmx660 comparetotmag -0E1 0 -> 1
-ctmx661 comparetotmag -0E2 0 -> 1
-ctmx662 comparetotmag 0E1 0 -> 1
-ctmx663 comparetotmag 0E2 0 -> 1
-ctmx664 comparetotmag -0E1 -0E1 -> 0
-ctmx665 comparetotmag -0E2 -0E1 -> 1
-ctmx666 comparetotmag 0E1 -0E1 -> 0
-ctmx667 comparetotmag 0E2 -0E1 -> 1
-ctmx668 comparetotmag -0E1 -0E2 -> -1
-ctmx669 comparetotmag -0E2 -0E2 -> 0
-ctmx670 comparetotmag 0E1 -0E2 -> -1
-ctmx671 comparetotmag 0E2 -0E2 -> 0
-ctmx672 comparetotmag -0E1 0E1 -> 0
-ctmx673 comparetotmag -0E2 0E1 -> 1
-ctmx674 comparetotmag 0E1 0E1 -> 0
-ctmx675 comparetotmag 0E2 0E1 -> 1
-ctmx676 comparetotmag -0E1 0E2 -> -1
-ctmx677 comparetotmag -0E2 0E2 -> 0
-ctmx678 comparetotmag 0E1 0E2 -> -1
-ctmx679 comparetotmag 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-precision: 20
-ctmx680 comparetotmag 12 12 -> 0
-ctmx681 comparetotmag 12 12.0 -> 1
-ctmx682 comparetotmag 12 12.00 -> 1
-ctmx683 comparetotmag 12 12.000 -> 1
-ctmx684 comparetotmag 12 12.0000 -> 1
-ctmx685 comparetotmag 12 12.00000 -> 1
-ctmx686 comparetotmag 12 12.000000 -> 1
-ctmx687 comparetotmag 12 12.0000000 -> 1
-ctmx688 comparetotmag 12 12.00000000 -> 1
-ctmx689 comparetotmag 12 12.000000000 -> 1
-ctmx690 comparetotmag 12 12 -> 0
-ctmx691 comparetotmag 12.0 12 -> -1
-ctmx692 comparetotmag 12.00 12 -> -1
-ctmx693 comparetotmag 12.000 12 -> -1
-ctmx694 comparetotmag 12.0000 12 -> -1
-ctmx695 comparetotmag 12.00000 12 -> -1
-ctmx696 comparetotmag 12.000000 12 -> -1
-ctmx697 comparetotmag 12.0000000 12 -> -1
-ctmx698 comparetotmag 12.00000000 12 -> -1
-ctmx699 comparetotmag 12.000000000 12 -> -1
-
--- long operand checks
-maxexponent: 999
-minexponent: -999
-precision: 9
-ctmx701 comparetotmag 12345678000 1 -> 1
-ctmx702 comparetotmag 1 12345678000 -> -1
-ctmx703 comparetotmag 1234567800 1 -> 1
-ctmx704 comparetotmag 1 1234567800 -> -1
-ctmx705 comparetotmag 1234567890 1 -> 1
-ctmx706 comparetotmag 1 1234567890 -> -1
-ctmx707 comparetotmag 1234567891 1 -> 1
-ctmx708 comparetotmag 1 1234567891 -> -1
-ctmx709 comparetotmag 12345678901 1 -> 1
-ctmx710 comparetotmag 1 12345678901 -> -1
-ctmx711 comparetotmag 1234567896 1 -> 1
-ctmx712 comparetotmag 1 1234567896 -> -1
-ctmx713 comparetotmag -1234567891 1 -> 1
-ctmx714 comparetotmag 1 -1234567891 -> -1
-ctmx715 comparetotmag -12345678901 1 -> 1
-ctmx716 comparetotmag 1 -12345678901 -> -1
-ctmx717 comparetotmag -1234567896 1 -> 1
-ctmx718 comparetotmag 1 -1234567896 -> -1
-
-precision: 15
--- same with plenty of precision
-ctmx721 comparetotmag 12345678000 1 -> 1
-ctmx722 comparetotmag 1 12345678000 -> -1
-ctmx723 comparetotmag 1234567800 1 -> 1
-ctmx724 comparetotmag 1 1234567800 -> -1
-ctmx725 comparetotmag 1234567890 1 -> 1
-ctmx726 comparetotmag 1 1234567890 -> -1
-ctmx727 comparetotmag 1234567891 1 -> 1
-ctmx728 comparetotmag 1 1234567891 -> -1
-ctmx729 comparetotmag 12345678901 1 -> 1
-ctmx730 comparetotmag 1 12345678901 -> -1
-ctmx731 comparetotmag 1234567896 1 -> 1
-ctmx732 comparetotmag 1 1234567896 -> -1
-
--- residue cases
-precision: 5
-ctmx740 comparetotmag 1 0.9999999 -> 1
-ctmx741 comparetotmag 1 0.999999 -> 1
-ctmx742 comparetotmag 1 0.99999 -> 1
-ctmx743 comparetotmag 1 1.0000 -> 1
-ctmx744 comparetotmag 1 1.00001 -> -1
-ctmx745 comparetotmag 1 1.000001 -> -1
-ctmx746 comparetotmag 1 1.0000001 -> -1
-ctmx750 comparetotmag 0.9999999 1 -> -1
-ctmx751 comparetotmag 0.999999 1 -> -1
-ctmx752 comparetotmag 0.99999 1 -> -1
-ctmx753 comparetotmag 1.0000 1 -> -1
-ctmx754 comparetotmag 1.00001 1 -> 1
-ctmx755 comparetotmag 1.000001 1 -> 1
-ctmx756 comparetotmag 1.0000001 1 -> 1
-
--- a selection of longies
-ctmx760 comparetotmag -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> 1
-ctmx761 comparetotmag -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
-ctmx762 comparetotmag -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> 1
-ctmx763 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
--- precisions above or below the difference should have no effect
-precision: 11
-ctmx764 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 10
-ctmx765 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 9
-ctmx766 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 8
-ctmx767 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 7
-ctmx768 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 6
-ctmx769 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 5
-ctmx770 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 4
-ctmx771 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 3
-ctmx772 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 2
-ctmx773 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 1
-ctmx774 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-
--- Specials
-precision: 9
-ctmx780 comparetotmag Inf -Inf -> 0
-ctmx781 comparetotmag Inf -1000 -> 1
-ctmx782 comparetotmag Inf -1 -> 1
-ctmx783 comparetotmag Inf -0 -> 1
-ctmx784 comparetotmag Inf 0 -> 1
-ctmx785 comparetotmag Inf 1 -> 1
-ctmx786 comparetotmag Inf 1000 -> 1
-ctmx787 comparetotmag Inf Inf -> 0
-ctmx788 comparetotmag -1000 Inf -> -1
-ctmx789 comparetotmag -Inf Inf -> 0
-ctmx790 comparetotmag -1 Inf -> -1
-ctmx791 comparetotmag -0 Inf -> -1
-ctmx792 comparetotmag 0 Inf -> -1
-ctmx793 comparetotmag 1 Inf -> -1
-ctmx794 comparetotmag 1000 Inf -> -1
-ctmx795 comparetotmag Inf Inf -> 0
-
-ctmx800 comparetotmag -Inf -Inf -> 0
-ctmx801 comparetotmag -Inf -1000 -> 1
-ctmx802 comparetotmag -Inf -1 -> 1
-ctmx803 comparetotmag -Inf -0 -> 1
-ctmx804 comparetotmag -Inf 0 -> 1
-ctmx805 comparetotmag -Inf 1 -> 1
-ctmx806 comparetotmag -Inf 1000 -> 1
-ctmx807 comparetotmag -Inf Inf -> 0
-ctmx808 comparetotmag -Inf -Inf -> 0
-ctmx809 comparetotmag -1000 -Inf -> -1
-ctmx810 comparetotmag -1 -Inf -> -1
-ctmx811 comparetotmag -0 -Inf -> -1
-ctmx812 comparetotmag 0 -Inf -> -1
-ctmx813 comparetotmag 1 -Inf -> -1
-ctmx814 comparetotmag 1000 -Inf -> -1
-ctmx815 comparetotmag Inf -Inf -> 0
-
-ctmx821 comparetotmag NaN -Inf -> 1
-ctmx822 comparetotmag NaN -1000 -> 1
-ctmx823 comparetotmag NaN -1 -> 1
-ctmx824 comparetotmag NaN -0 -> 1
-ctmx825 comparetotmag NaN 0 -> 1
-ctmx826 comparetotmag NaN 1 -> 1
-ctmx827 comparetotmag NaN 1000 -> 1
-ctmx828 comparetotmag NaN Inf -> 1
-ctmx829 comparetotmag NaN NaN -> 0
-ctmx830 comparetotmag -Inf NaN -> -1
-ctmx831 comparetotmag -1000 NaN -> -1
-ctmx832 comparetotmag -1 NaN -> -1
-ctmx833 comparetotmag -0 NaN -> -1
-ctmx834 comparetotmag 0 NaN -> -1
-ctmx835 comparetotmag 1 NaN -> -1
-ctmx836 comparetotmag 1000 NaN -> -1
-ctmx837 comparetotmag Inf NaN -> -1
-ctmx838 comparetotmag -NaN -NaN -> 0
-ctmx839 comparetotmag +NaN -NaN -> 0
-ctmx840 comparetotmag -NaN +NaN -> 0
-
-ctmx841 comparetotmag sNaN -sNaN -> 0
-ctmx842 comparetotmag sNaN -NaN -> -1
-ctmx843 comparetotmag sNaN -Inf -> 1
-ctmx844 comparetotmag sNaN -1000 -> 1
-ctmx845 comparetotmag sNaN -1 -> 1
-ctmx846 comparetotmag sNaN -0 -> 1
-ctmx847 comparetotmag sNaN 0 -> 1
-ctmx848 comparetotmag sNaN 1 -> 1
-ctmx849 comparetotmag sNaN 1000 -> 1
-ctmx850 comparetotmag sNaN NaN -> -1
-ctmx851 comparetotmag sNaN sNaN -> 0
-
-ctmx852 comparetotmag -sNaN sNaN -> 0
-ctmx853 comparetotmag -NaN sNaN -> 1
-ctmx854 comparetotmag -Inf sNaN -> -1
-ctmx855 comparetotmag -1000 sNaN -> -1
-ctmx856 comparetotmag -1 sNaN -> -1
-ctmx857 comparetotmag -0 sNaN -> -1
-ctmx858 comparetotmag 0 sNaN -> -1
-ctmx859 comparetotmag 1 sNaN -> -1
-ctmx860 comparetotmag 1000 sNaN -> -1
-ctmx861 comparetotmag Inf sNaN -> -1
-ctmx862 comparetotmag NaN sNaN -> 1
-ctmx863 comparetotmag sNaN sNaN -> 0
-
-ctmx871 comparetotmag -sNaN -sNaN -> 0
-ctmx872 comparetotmag -sNaN -NaN -> -1
-ctmx873 comparetotmag -sNaN -Inf -> 1
-ctmx874 comparetotmag -sNaN -1000 -> 1
-ctmx875 comparetotmag -sNaN -1 -> 1
-ctmx876 comparetotmag -sNaN -0 -> 1
-ctmx877 comparetotmag -sNaN 0 -> 1
-ctmx878 comparetotmag -sNaN 1 -> 1
-ctmx879 comparetotmag -sNaN 1000 -> 1
-ctmx880 comparetotmag -sNaN NaN -> -1
-ctmx881 comparetotmag -sNaN sNaN -> 0
-
-ctmx882 comparetotmag -sNaN -sNaN -> 0
-ctmx883 comparetotmag -NaN -sNaN -> 1
-ctmx884 comparetotmag -Inf -sNaN -> -1
-ctmx885 comparetotmag -1000 -sNaN -> -1
-ctmx886 comparetotmag -1 -sNaN -> -1
-ctmx887 comparetotmag -0 -sNaN -> -1
-ctmx888 comparetotmag 0 -sNaN -> -1
-ctmx889 comparetotmag 1 -sNaN -> -1
-ctmx890 comparetotmag 1000 -sNaN -> -1
-ctmx891 comparetotmag Inf -sNaN -> -1
-ctmx892 comparetotmag NaN -sNaN -> 1
-ctmx893 comparetotmag sNaN -sNaN -> 0
-
--- NaNs with payload
-ctmx960 comparetotmag NaN9 -Inf -> 1
-ctmx961 comparetotmag NaN8 999 -> 1
-ctmx962 comparetotmag NaN77 Inf -> 1
-ctmx963 comparetotmag -NaN67 NaN5 -> 1
-ctmx964 comparetotmag -Inf -NaN4 -> -1
-ctmx965 comparetotmag -999 -NaN33 -> -1
-ctmx966 comparetotmag Inf NaN2 -> -1
-
-ctmx970 comparetotmag -NaN41 -NaN42 -> -1
-ctmx971 comparetotmag +NaN41 -NaN42 -> -1
-ctmx972 comparetotmag -NaN41 +NaN42 -> -1
-ctmx973 comparetotmag +NaN41 +NaN42 -> -1
-ctmx974 comparetotmag -NaN42 -NaN01 -> 1
-ctmx975 comparetotmag +NaN42 -NaN01 -> 1
-ctmx976 comparetotmag -NaN42 +NaN01 -> 1
-ctmx977 comparetotmag +NaN42 +NaN01 -> 1
-
-ctmx980 comparetotmag -sNaN771 -sNaN772 -> -1
-ctmx981 comparetotmag +sNaN771 -sNaN772 -> -1
-ctmx982 comparetotmag -sNaN771 +sNaN772 -> -1
-ctmx983 comparetotmag +sNaN771 +sNaN772 -> -1
-ctmx984 comparetotmag -sNaN772 -sNaN771 -> 1
-ctmx985 comparetotmag +sNaN772 -sNaN771 -> 1
-ctmx986 comparetotmag -sNaN772 +sNaN771 -> 1
-ctmx987 comparetotmag +sNaN772 +sNaN771 -> 1
-
-ctmx991 comparetotmag -sNaN99 -Inf -> 1
-ctmx992 comparetotmag sNaN98 -11 -> 1
-ctmx993 comparetotmag sNaN97 NaN -> -1
-ctmx994 comparetotmag sNaN16 sNaN94 -> -1
-ctmx995 comparetotmag NaN85 sNaN83 -> 1
-ctmx996 comparetotmag -Inf sNaN92 -> -1
-ctmx997 comparetotmag 088 sNaN81 -> -1
-ctmx998 comparetotmag Inf sNaN90 -> -1
-ctmx999 comparetotmag NaN -sNaN89 -> 1
-
--- overflow and underflow tests .. subnormal results now allowed
-maxExponent: 999999999
-minexponent: -999999999
-ctmx1080 comparetotmag +1.23456789012345E-0 9E+999999999 -> -1
-ctmx1081 comparetotmag 9E+999999999 +1.23456789012345E-0 -> 1
-ctmx1082 comparetotmag +0.100 9E-999999999 -> 1
-ctmx1083 comparetotmag 9E-999999999 +0.100 -> -1
-ctmx1085 comparetotmag -1.23456789012345E-0 9E+999999999 -> -1
-ctmx1086 comparetotmag 9E+999999999 -1.23456789012345E-0 -> 1
-ctmx1087 comparetotmag -0.100 9E-999999999 -> 1
-ctmx1088 comparetotmag 9E-999999999 -0.100 -> -1
-
-ctmx1089 comparetotmag 1e-599999999 1e-400000001 -> -1
-ctmx1090 comparetotmag 1e-599999999 1e-400000000 -> -1
-ctmx1091 comparetotmag 1e-600000000 1e-400000000 -> -1
-ctmx1092 comparetotmag 9e-999999998 0.01 -> -1
-ctmx1093 comparetotmag 9e-999999998 0.1 -> -1
-ctmx1094 comparetotmag 0.01 9e-999999998 -> 1
-ctmx1095 comparetotmag 1e599999999 1e400000001 -> 1
-ctmx1096 comparetotmag 1e599999999 1e400000000 -> 1
-ctmx1097 comparetotmag 1e600000000 1e400000000 -> 1
-ctmx1098 comparetotmag 9e999999998 100 -> 1
-ctmx1099 comparetotmag 9e999999998 10 -> 1
-ctmx1100 comparetotmag 100 9e999999998 -> -1
--- signs
-ctmx1101 comparetotmag 1e+777777777 1e+411111111 -> 1
-ctmx1102 comparetotmag 1e+777777777 -1e+411111111 -> 1
-ctmx1103 comparetotmag -1e+777777777 1e+411111111 -> 1
-ctmx1104 comparetotmag -1e+777777777 -1e+411111111 -> 1
-ctmx1105 comparetotmag 1e-777777777 1e-411111111 -> -1
-ctmx1106 comparetotmag 1e-777777777 -1e-411111111 -> -1
-ctmx1107 comparetotmag -1e-777777777 1e-411111111 -> -1
-ctmx1108 comparetotmag -1e-777777777 -1e-411111111 -> -1
-
--- spread zeros
-ctmx1110 comparetotmag 0E-383 0 -> -1
-ctmx1111 comparetotmag 0E-383 -0 -> -1
-ctmx1112 comparetotmag -0E-383 0 -> -1
-ctmx1113 comparetotmag -0E-383 -0 -> -1
-ctmx1114 comparetotmag 0E-383 0E+384 -> -1
-ctmx1115 comparetotmag 0E-383 -0E+384 -> -1
-ctmx1116 comparetotmag -0E-383 0E+384 -> -1
-ctmx1117 comparetotmag -0E-383 -0E+384 -> -1
-ctmx1118 comparetotmag 0 0E+384 -> -1
-ctmx1119 comparetotmag 0 -0E+384 -> -1
-ctmx1120 comparetotmag -0 0E+384 -> -1
-ctmx1121 comparetotmag -0 -0E+384 -> -1
-
-ctmx1130 comparetotmag 0E+384 0 -> 1
-ctmx1131 comparetotmag 0E+384 -0 -> 1
-ctmx1132 comparetotmag -0E+384 0 -> 1
-ctmx1133 comparetotmag -0E+384 -0 -> 1
-ctmx1134 comparetotmag 0E+384 0E-383 -> 1
-ctmx1135 comparetotmag 0E+384 -0E-383 -> 1
-ctmx1136 comparetotmag -0E+384 0E-383 -> 1
-ctmx1137 comparetotmag -0E+384 -0E-383 -> 1
-ctmx1138 comparetotmag 0 0E-383 -> 1
-ctmx1139 comparetotmag 0 -0E-383 -> 1
-ctmx1140 comparetotmag -0 0E-383 -> 1
-ctmx1141 comparetotmag -0 -0E-383 -> 1
-
--- Null tests
-ctmx9990 comparetotmag 10 # -> NaN Invalid_operation
-ctmx9991 comparetotmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- comparetotmag.decTest -- decimal comparison, abs. total ordering --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that it cannot be assumed that add/subtract tests cover paths
+-- for this operation adequately, here, because the code might be
+-- quite different (comparison cannot overflow or underflow, so
+-- actual subtractions are not necessary). Similarly, comparetotal
+-- will have some radically different paths than compare.
+
+extended: 1
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+-- sanity checks
+ctmx001 comparetotmag -2 -2 -> 0
+ctmx002 comparetotmag -2 -1 -> 1
+ctmx003 comparetotmag -2 0 -> 1
+ctmx004 comparetotmag -2 1 -> 1
+ctmx005 comparetotmag -2 2 -> 0
+ctmx006 comparetotmag -1 -2 -> -1
+ctmx007 comparetotmag -1 -1 -> 0
+ctmx008 comparetotmag -1 0 -> 1
+ctmx009 comparetotmag -1 1 -> 0
+ctmx010 comparetotmag -1 2 -> -1
+ctmx011 comparetotmag 0 -2 -> -1
+ctmx012 comparetotmag 0 -1 -> -1
+ctmx013 comparetotmag 0 0 -> 0
+ctmx014 comparetotmag 0 1 -> -1
+ctmx015 comparetotmag 0 2 -> -1
+ctmx016 comparetotmag 1 -2 -> -1
+ctmx017 comparetotmag 1 -1 -> 0
+ctmx018 comparetotmag 1 0 -> 1
+ctmx019 comparetotmag 1 1 -> 0
+ctmx020 comparetotmag 1 2 -> -1
+ctmx021 comparetotmag 2 -2 -> 0
+ctmx022 comparetotmag 2 -1 -> 1
+ctmx023 comparetotmag 2 0 -> 1
+ctmx025 comparetotmag 2 1 -> 1
+ctmx026 comparetotmag 2 2 -> 0
+
+ctmx031 comparetotmag -20 -20 -> 0
+ctmx032 comparetotmag -20 -10 -> 1
+ctmx033 comparetotmag -20 00 -> 1
+ctmx034 comparetotmag -20 10 -> 1
+ctmx035 comparetotmag -20 20 -> 0
+ctmx036 comparetotmag -10 -20 -> -1
+ctmx037 comparetotmag -10 -10 -> 0
+ctmx038 comparetotmag -10 00 -> 1
+ctmx039 comparetotmag -10 10 -> 0
+ctmx040 comparetotmag -10 20 -> -1
+ctmx041 comparetotmag 00 -20 -> -1
+ctmx042 comparetotmag 00 -10 -> -1
+ctmx043 comparetotmag 00 00 -> 0
+ctmx044 comparetotmag 00 10 -> -1
+ctmx045 comparetotmag 00 20 -> -1
+ctmx046 comparetotmag 10 -20 -> -1
+ctmx047 comparetotmag 10 -10 -> 0
+ctmx048 comparetotmag 10 00 -> 1
+ctmx049 comparetotmag 10 10 -> 0
+ctmx050 comparetotmag 10 20 -> -1
+ctmx051 comparetotmag 20 -20 -> 0
+ctmx052 comparetotmag 20 -10 -> 1
+ctmx053 comparetotmag 20 00 -> 1
+ctmx055 comparetotmag 20 10 -> 1
+ctmx056 comparetotmag 20 20 -> 0
+
+ctmx061 comparetotmag -2.0 -2.0 -> 0
+ctmx062 comparetotmag -2.0 -1.0 -> 1
+ctmx063 comparetotmag -2.0 0.0 -> 1
+ctmx064 comparetotmag -2.0 1.0 -> 1
+ctmx065 comparetotmag -2.0 2.0 -> 0
+ctmx066 comparetotmag -1.0 -2.0 -> -1
+ctmx067 comparetotmag -1.0 -1.0 -> 0
+ctmx068 comparetotmag -1.0 0.0 -> 1
+ctmx069 comparetotmag -1.0 1.0 -> 0
+ctmx070 comparetotmag -1.0 2.0 -> -1
+ctmx071 comparetotmag 0.0 -2.0 -> -1
+ctmx072 comparetotmag 0.0 -1.0 -> -1
+ctmx073 comparetotmag 0.0 0.0 -> 0
+ctmx074 comparetotmag 0.0 1.0 -> -1
+ctmx075 comparetotmag 0.0 2.0 -> -1
+ctmx076 comparetotmag 1.0 -2.0 -> -1
+ctmx077 comparetotmag 1.0 -1.0 -> 0
+ctmx078 comparetotmag 1.0 0.0 -> 1
+ctmx079 comparetotmag 1.0 1.0 -> 0
+ctmx080 comparetotmag 1.0 2.0 -> -1
+ctmx081 comparetotmag 2.0 -2.0 -> 0
+ctmx082 comparetotmag 2.0 -1.0 -> 1
+ctmx083 comparetotmag 2.0 0.0 -> 1
+ctmx085 comparetotmag 2.0 1.0 -> 1
+ctmx086 comparetotmag 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+maxexponent: 999999999
+minexponent: -999999999
+ctmx090 comparetotmag 9.99999999E+999999999 9.99999999E+999999999 -> 0
+ctmx091 comparetotmag -9.99999999E+999999999 9.99999999E+999999999 -> 0
+ctmx092 comparetotmag 9.99999999E+999999999 -9.99999999E+999999999 -> 0
+ctmx093 comparetotmag -9.99999999E+999999999 -9.99999999E+999999999 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+ctmx100 comparetotmag 7.0 7.0 -> 0
+ctmx101 comparetotmag 7.0 7 -> -1
+ctmx102 comparetotmag 7 7.0 -> 1
+ctmx103 comparetotmag 7E+0 7.0 -> 1
+ctmx104 comparetotmag 70E-1 7.0 -> 0
+ctmx105 comparetotmag 0.7E+1 7 -> 0
+ctmx106 comparetotmag 70E-1 7 -> -1
+ctmx107 comparetotmag 7.0 7E+0 -> -1
+ctmx108 comparetotmag 7.0 70E-1 -> 0
+ctmx109 comparetotmag 7 0.7E+1 -> 0
+ctmx110 comparetotmag 7 70E-1 -> 1
+
+ctmx120 comparetotmag 8.0 7.0 -> 1
+ctmx121 comparetotmag 8.0 7 -> 1
+ctmx122 comparetotmag 8 7.0 -> 1
+ctmx123 comparetotmag 8E+0 7.0 -> 1
+ctmx124 comparetotmag 80E-1 7.0 -> 1
+ctmx125 comparetotmag 0.8E+1 7 -> 1
+ctmx126 comparetotmag 80E-1 7 -> 1
+ctmx127 comparetotmag 8.0 7E+0 -> 1
+ctmx128 comparetotmag 8.0 70E-1 -> 1
+ctmx129 comparetotmag 8 0.7E+1 -> 1
+ctmx130 comparetotmag 8 70E-1 -> 1
+
+ctmx140 comparetotmag 8.0 9.0 -> -1
+ctmx141 comparetotmag 8.0 9 -> -1
+ctmx142 comparetotmag 8 9.0 -> -1
+ctmx143 comparetotmag 8E+0 9.0 -> -1
+ctmx144 comparetotmag 80E-1 9.0 -> -1
+ctmx145 comparetotmag 0.8E+1 9 -> -1
+ctmx146 comparetotmag 80E-1 9 -> -1
+ctmx147 comparetotmag 8.0 9E+0 -> -1
+ctmx148 comparetotmag 8.0 90E-1 -> -1
+ctmx149 comparetotmag 8 0.9E+1 -> -1
+ctmx150 comparetotmag 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ctmx200 comparetotmag -7.0 7.0 -> 0
+ctmx201 comparetotmag -7.0 7 -> -1
+ctmx202 comparetotmag -7 7.0 -> 1
+ctmx203 comparetotmag -7E+0 7.0 -> 1
+ctmx204 comparetotmag -70E-1 7.0 -> 0
+ctmx205 comparetotmag -0.7E+1 7 -> 0
+ctmx206 comparetotmag -70E-1 7 -> -1
+ctmx207 comparetotmag -7.0 7E+0 -> -1
+ctmx208 comparetotmag -7.0 70E-1 -> 0
+ctmx209 comparetotmag -7 0.7E+1 -> 0
+ctmx210 comparetotmag -7 70E-1 -> 1
+
+ctmx220 comparetotmag -8.0 7.0 -> 1
+ctmx221 comparetotmag -8.0 7 -> 1
+ctmx222 comparetotmag -8 7.0 -> 1
+ctmx223 comparetotmag -8E+0 7.0 -> 1
+ctmx224 comparetotmag -80E-1 7.0 -> 1
+ctmx225 comparetotmag -0.8E+1 7 -> 1
+ctmx226 comparetotmag -80E-1 7 -> 1
+ctmx227 comparetotmag -8.0 7E+0 -> 1
+ctmx228 comparetotmag -8.0 70E-1 -> 1
+ctmx229 comparetotmag -8 0.7E+1 -> 1
+ctmx230 comparetotmag -8 70E-1 -> 1
+
+ctmx240 comparetotmag -8.0 9.0 -> -1
+ctmx241 comparetotmag -8.0 9 -> -1
+ctmx242 comparetotmag -8 9.0 -> -1
+ctmx243 comparetotmag -8E+0 9.0 -> -1
+ctmx244 comparetotmag -80E-1 9.0 -> -1
+ctmx245 comparetotmag -0.8E+1 9 -> -1
+ctmx246 comparetotmag -80E-1 9 -> -1
+ctmx247 comparetotmag -8.0 9E+0 -> -1
+ctmx248 comparetotmag -8.0 90E-1 -> -1
+ctmx249 comparetotmag -8 0.9E+1 -> -1
+ctmx250 comparetotmag -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ctmx300 comparetotmag 7.0 -7.0 -> 0
+ctmx301 comparetotmag 7.0 -7 -> -1
+ctmx302 comparetotmag 7 -7.0 -> 1
+ctmx303 comparetotmag 7E+0 -7.0 -> 1
+ctmx304 comparetotmag 70E-1 -7.0 -> 0
+ctmx305 comparetotmag .7E+1 -7 -> 0
+ctmx306 comparetotmag 70E-1 -7 -> -1
+ctmx307 comparetotmag 7.0 -7E+0 -> -1
+ctmx308 comparetotmag 7.0 -70E-1 -> 0
+ctmx309 comparetotmag 7 -.7E+1 -> 0
+ctmx310 comparetotmag 7 -70E-1 -> 1
+
+ctmx320 comparetotmag 8.0 -7.0 -> 1
+ctmx321 comparetotmag 8.0 -7 -> 1
+ctmx322 comparetotmag 8 -7.0 -> 1
+ctmx323 comparetotmag 8E+0 -7.0 -> 1
+ctmx324 comparetotmag 80E-1 -7.0 -> 1
+ctmx325 comparetotmag .8E+1 -7 -> 1
+ctmx326 comparetotmag 80E-1 -7 -> 1
+ctmx327 comparetotmag 8.0 -7E+0 -> 1
+ctmx328 comparetotmag 8.0 -70E-1 -> 1
+ctmx329 comparetotmag 8 -.7E+1 -> 1
+ctmx330 comparetotmag 8 -70E-1 -> 1
+
+ctmx340 comparetotmag 8.0 -9.0 -> -1
+ctmx341 comparetotmag 8.0 -9 -> -1
+ctmx342 comparetotmag 8 -9.0 -> -1
+ctmx343 comparetotmag 8E+0 -9.0 -> -1
+ctmx344 comparetotmag 80E-1 -9.0 -> -1
+ctmx345 comparetotmag .8E+1 -9 -> -1
+ctmx346 comparetotmag 80E-1 -9 -> -1
+ctmx347 comparetotmag 8.0 -9E+0 -> -1
+ctmx348 comparetotmag 8.0 -90E-1 -> -1
+ctmx349 comparetotmag 8 -.9E+1 -> -1
+ctmx350 comparetotmag 8 -90E-1 -> -1
+
+-- and again, with sign changes -- ..
+ctmx400 comparetotmag -7.0 -7.0 -> 0
+ctmx401 comparetotmag -7.0 -7 -> -1
+ctmx402 comparetotmag -7 -7.0 -> 1
+ctmx403 comparetotmag -7E+0 -7.0 -> 1
+ctmx404 comparetotmag -70E-1 -7.0 -> 0
+ctmx405 comparetotmag -.7E+1 -7 -> 0
+ctmx406 comparetotmag -70E-1 -7 -> -1
+ctmx407 comparetotmag -7.0 -7E+0 -> -1
+ctmx408 comparetotmag -7.0 -70E-1 -> 0
+ctmx409 comparetotmag -7 -.7E+1 -> 0
+ctmx410 comparetotmag -7 -70E-1 -> 1
+
+ctmx420 comparetotmag -8.0 -7.0 -> 1
+ctmx421 comparetotmag -8.0 -7 -> 1
+ctmx422 comparetotmag -8 -7.0 -> 1
+ctmx423 comparetotmag -8E+0 -7.0 -> 1
+ctmx424 comparetotmag -80E-1 -7.0 -> 1
+ctmx425 comparetotmag -.8E+1 -7 -> 1
+ctmx426 comparetotmag -80E-1 -7 -> 1
+ctmx427 comparetotmag -8.0 -7E+0 -> 1
+ctmx428 comparetotmag -8.0 -70E-1 -> 1
+ctmx429 comparetotmag -8 -.7E+1 -> 1
+ctmx430 comparetotmag -8 -70E-1 -> 1
+
+ctmx440 comparetotmag -8.0 -9.0 -> -1
+ctmx441 comparetotmag -8.0 -9 -> -1
+ctmx442 comparetotmag -8 -9.0 -> -1
+ctmx443 comparetotmag -8E+0 -9.0 -> -1
+ctmx444 comparetotmag -80E-1 -9.0 -> -1
+ctmx445 comparetotmag -.8E+1 -9 -> -1
+ctmx446 comparetotmag -80E-1 -9 -> -1
+ctmx447 comparetotmag -8.0 -9E+0 -> -1
+ctmx448 comparetotmag -8.0 -90E-1 -> -1
+ctmx449 comparetotmag -8 -.9E+1 -> -1
+ctmx450 comparetotmag -8 -90E-1 -> -1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+precision: 40
+ctmx470 comparetotmag 123.4560000000000000E789 123.456E789 -> -1
+ctmx471 comparetotmag 123.456000000000000E-89 123.456E-89 -> -1
+ctmx472 comparetotmag 123.45600000000000E789 123.456E789 -> -1
+ctmx473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
+ctmx474 comparetotmag 123.456000000000E789 123.456E789 -> -1
+ctmx475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
+ctmx476 comparetotmag 123.4560000000E789 123.456E789 -> -1
+ctmx477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
+ctmx478 comparetotmag 123.45600000E789 123.456E789 -> -1
+ctmx479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
+ctmx480 comparetotmag 123.456000E789 123.456E789 -> -1
+ctmx481 comparetotmag 123.45600E-89 123.456E-89 -> -1
+ctmx482 comparetotmag 123.4560E789 123.456E789 -> -1
+ctmx483 comparetotmag 123.456E-89 123.456E-89 -> 0
+ctmx484 comparetotmag 123.456E-89 123.4560000000000000E-89 -> 1
+ctmx485 comparetotmag 123.456E789 123.456000000000000E789 -> 1
+ctmx486 comparetotmag 123.456E-89 123.45600000000000E-89 -> 1
+ctmx487 comparetotmag 123.456E789 123.4560000000000E789 -> 1
+ctmx488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
+ctmx489 comparetotmag 123.456E789 123.45600000000E789 -> 1
+ctmx490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
+ctmx491 comparetotmag 123.456E789 123.456000000E789 -> 1
+ctmx492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
+ctmx493 comparetotmag 123.456E789 123.4560000E789 -> 1
+ctmx494 comparetotmag 123.456E-89 123.456000E-89 -> 1
+ctmx495 comparetotmag 123.456E789 123.45600E789 -> 1
+ctmx496 comparetotmag 123.456E-89 123.4560E-89 -> 1
+ctmx497 comparetotmag 123.456E789 123.456E789 -> 0
+
+-- wide-ranging, around precision; signs equal
+precision: 9
+ctmx500 comparetotmag 1 1E-15 -> 1
+ctmx501 comparetotmag 1 1E-14 -> 1
+ctmx502 comparetotmag 1 1E-13 -> 1
+ctmx503 comparetotmag 1 1E-12 -> 1
+ctmx504 comparetotmag 1 1E-11 -> 1
+ctmx505 comparetotmag 1 1E-10 -> 1
+ctmx506 comparetotmag 1 1E-9 -> 1
+ctmx507 comparetotmag 1 1E-8 -> 1
+ctmx508 comparetotmag 1 1E-7 -> 1
+ctmx509 comparetotmag 1 1E-6 -> 1
+ctmx510 comparetotmag 1 1E-5 -> 1
+ctmx511 comparetotmag 1 1E-4 -> 1
+ctmx512 comparetotmag 1 1E-3 -> 1
+ctmx513 comparetotmag 1 1E-2 -> 1
+ctmx514 comparetotmag 1 1E-1 -> 1
+ctmx515 comparetotmag 1 1E-0 -> 0
+ctmx516 comparetotmag 1 1E+1 -> -1
+ctmx517 comparetotmag 1 1E+2 -> -1
+ctmx518 comparetotmag 1 1E+3 -> -1
+ctmx519 comparetotmag 1 1E+4 -> -1
+ctmx521 comparetotmag 1 1E+5 -> -1
+ctmx522 comparetotmag 1 1E+6 -> -1
+ctmx523 comparetotmag 1 1E+7 -> -1
+ctmx524 comparetotmag 1 1E+8 -> -1
+ctmx525 comparetotmag 1 1E+9 -> -1
+ctmx526 comparetotmag 1 1E+10 -> -1
+ctmx527 comparetotmag 1 1E+11 -> -1
+ctmx528 comparetotmag 1 1E+12 -> -1
+ctmx529 comparetotmag 1 1E+13 -> -1
+ctmx530 comparetotmag 1 1E+14 -> -1
+ctmx531 comparetotmag 1 1E+15 -> -1
+-- LR swap
+ctmx540 comparetotmag 1E-15 1 -> -1
+ctmx541 comparetotmag 1E-14 1 -> -1
+ctmx542 comparetotmag 1E-13 1 -> -1
+ctmx543 comparetotmag 1E-12 1 -> -1
+ctmx544 comparetotmag 1E-11 1 -> -1
+ctmx545 comparetotmag 1E-10 1 -> -1
+ctmx546 comparetotmag 1E-9 1 -> -1
+ctmx547 comparetotmag 1E-8 1 -> -1
+ctmx548 comparetotmag 1E-7 1 -> -1
+ctmx549 comparetotmag 1E-6 1 -> -1
+ctmx550 comparetotmag 1E-5 1 -> -1
+ctmx551 comparetotmag 1E-4 1 -> -1
+ctmx552 comparetotmag 1E-3 1 -> -1
+ctmx553 comparetotmag 1E-2 1 -> -1
+ctmx554 comparetotmag 1E-1 1 -> -1
+ctmx555 comparetotmag 1E-0 1 -> 0
+ctmx556 comparetotmag 1E+1 1 -> 1
+ctmx557 comparetotmag 1E+2 1 -> 1
+ctmx558 comparetotmag 1E+3 1 -> 1
+ctmx559 comparetotmag 1E+4 1 -> 1
+ctmx561 comparetotmag 1E+5 1 -> 1
+ctmx562 comparetotmag 1E+6 1 -> 1
+ctmx563 comparetotmag 1E+7 1 -> 1
+ctmx564 comparetotmag 1E+8 1 -> 1
+ctmx565 comparetotmag 1E+9 1 -> 1
+ctmx566 comparetotmag 1E+10 1 -> 1
+ctmx567 comparetotmag 1E+11 1 -> 1
+ctmx568 comparetotmag 1E+12 1 -> 1
+ctmx569 comparetotmag 1E+13 1 -> 1
+ctmx570 comparetotmag 1E+14 1 -> 1
+ctmx571 comparetotmag 1E+15 1 -> 1
+-- similar with an useful coefficient, one side only
+ctmx580 comparetotmag 0.000000987654321 1E-15 -> 1
+ctmx581 comparetotmag 0.000000987654321 1E-14 -> 1
+ctmx582 comparetotmag 0.000000987654321 1E-13 -> 1
+ctmx583 comparetotmag 0.000000987654321 1E-12 -> 1
+ctmx584 comparetotmag 0.000000987654321 1E-11 -> 1
+ctmx585 comparetotmag 0.000000987654321 1E-10 -> 1
+ctmx586 comparetotmag 0.000000987654321 1E-9 -> 1
+ctmx587 comparetotmag 0.000000987654321 1E-8 -> 1
+ctmx588 comparetotmag 0.000000987654321 1E-7 -> 1
+ctmx589 comparetotmag 0.000000987654321 1E-6 -> -1
+ctmx590 comparetotmag 0.000000987654321 1E-5 -> -1
+ctmx591 comparetotmag 0.000000987654321 1E-4 -> -1
+ctmx592 comparetotmag 0.000000987654321 1E-3 -> -1
+ctmx593 comparetotmag 0.000000987654321 1E-2 -> -1
+ctmx594 comparetotmag 0.000000987654321 1E-1 -> -1
+ctmx595 comparetotmag 0.000000987654321 1E-0 -> -1
+ctmx596 comparetotmag 0.000000987654321 1E+1 -> -1
+ctmx597 comparetotmag 0.000000987654321 1E+2 -> -1
+ctmx598 comparetotmag 0.000000987654321 1E+3 -> -1
+ctmx599 comparetotmag 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+precision: 20
+ctmx600 comparetotmag 12 12.2345 -> -1
+ctmx601 comparetotmag 12.0 12.2345 -> -1
+ctmx602 comparetotmag 12.00 12.2345 -> -1
+ctmx603 comparetotmag 12.000 12.2345 -> -1
+ctmx604 comparetotmag 12.0000 12.2345 -> -1
+ctmx605 comparetotmag 12.00000 12.2345 -> -1
+ctmx606 comparetotmag 12.000000 12.2345 -> -1
+ctmx607 comparetotmag 12.0000000 12.2345 -> -1
+ctmx608 comparetotmag 12.00000000 12.2345 -> -1
+ctmx609 comparetotmag 12.000000000 12.2345 -> -1
+ctmx610 comparetotmag 12.1234 12 -> 1
+ctmx611 comparetotmag 12.1234 12.0 -> 1
+ctmx612 comparetotmag 12.1234 12.00 -> 1
+ctmx613 comparetotmag 12.1234 12.000 -> 1
+ctmx614 comparetotmag 12.1234 12.0000 -> 1
+ctmx615 comparetotmag 12.1234 12.00000 -> 1
+ctmx616 comparetotmag 12.1234 12.000000 -> 1
+ctmx617 comparetotmag 12.1234 12.0000000 -> 1
+ctmx618 comparetotmag 12.1234 12.00000000 -> 1
+ctmx619 comparetotmag 12.1234 12.000000000 -> 1
+ctmx620 comparetotmag -12 -12.2345 -> -1
+ctmx621 comparetotmag -12.0 -12.2345 -> -1
+ctmx622 comparetotmag -12.00 -12.2345 -> -1
+ctmx623 comparetotmag -12.000 -12.2345 -> -1
+ctmx624 comparetotmag -12.0000 -12.2345 -> -1
+ctmx625 comparetotmag -12.00000 -12.2345 -> -1
+ctmx626 comparetotmag -12.000000 -12.2345 -> -1
+ctmx627 comparetotmag -12.0000000 -12.2345 -> -1
+ctmx628 comparetotmag -12.00000000 -12.2345 -> -1
+ctmx629 comparetotmag -12.000000000 -12.2345 -> -1
+ctmx630 comparetotmag -12.1234 -12 -> 1
+ctmx631 comparetotmag -12.1234 -12.0 -> 1
+ctmx632 comparetotmag -12.1234 -12.00 -> 1
+ctmx633 comparetotmag -12.1234 -12.000 -> 1
+ctmx634 comparetotmag -12.1234 -12.0000 -> 1
+ctmx635 comparetotmag -12.1234 -12.00000 -> 1
+ctmx636 comparetotmag -12.1234 -12.000000 -> 1
+ctmx637 comparetotmag -12.1234 -12.0000000 -> 1
+ctmx638 comparetotmag -12.1234 -12.00000000 -> 1
+ctmx639 comparetotmag -12.1234 -12.000000000 -> 1
+precision: 9
+
+-- extended zeros
+ctmx640 comparetotmag 0 0 -> 0
+ctmx641 comparetotmag 0 -0 -> 0
+ctmx642 comparetotmag 0 -0.0 -> 1
+ctmx643 comparetotmag 0 0.0 -> 1
+ctmx644 comparetotmag -0 0 -> 0
+ctmx645 comparetotmag -0 -0 -> 0
+ctmx646 comparetotmag -0 -0.0 -> 1
+ctmx647 comparetotmag -0 0.0 -> 1
+ctmx648 comparetotmag 0.0 0 -> -1
+ctmx649 comparetotmag 0.0 -0 -> -1
+ctmx650 comparetotmag 0.0 -0.0 -> 0
+ctmx651 comparetotmag 0.0 0.0 -> 0
+ctmx652 comparetotmag -0.0 0 -> -1
+ctmx653 comparetotmag -0.0 -0 -> -1
+ctmx654 comparetotmag -0.0 -0.0 -> 0
+ctmx655 comparetotmag -0.0 0.0 -> 0
+
+ctmx656 comparetotmag -0E1 0.0 -> 1
+ctmx657 comparetotmag -0E2 0.0 -> 1
+ctmx658 comparetotmag 0E1 0.0 -> 1
+ctmx659 comparetotmag 0E2 0.0 -> 1
+ctmx660 comparetotmag -0E1 0 -> 1
+ctmx661 comparetotmag -0E2 0 -> 1
+ctmx662 comparetotmag 0E1 0 -> 1
+ctmx663 comparetotmag 0E2 0 -> 1
+ctmx664 comparetotmag -0E1 -0E1 -> 0
+ctmx665 comparetotmag -0E2 -0E1 -> 1
+ctmx666 comparetotmag 0E1 -0E1 -> 0
+ctmx667 comparetotmag 0E2 -0E1 -> 1
+ctmx668 comparetotmag -0E1 -0E2 -> -1
+ctmx669 comparetotmag -0E2 -0E2 -> 0
+ctmx670 comparetotmag 0E1 -0E2 -> -1
+ctmx671 comparetotmag 0E2 -0E2 -> 0
+ctmx672 comparetotmag -0E1 0E1 -> 0
+ctmx673 comparetotmag -0E2 0E1 -> 1
+ctmx674 comparetotmag 0E1 0E1 -> 0
+ctmx675 comparetotmag 0E2 0E1 -> 1
+ctmx676 comparetotmag -0E1 0E2 -> -1
+ctmx677 comparetotmag -0E2 0E2 -> 0
+ctmx678 comparetotmag 0E1 0E2 -> -1
+ctmx679 comparetotmag 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+precision: 20
+ctmx680 comparetotmag 12 12 -> 0
+ctmx681 comparetotmag 12 12.0 -> 1
+ctmx682 comparetotmag 12 12.00 -> 1
+ctmx683 comparetotmag 12 12.000 -> 1
+ctmx684 comparetotmag 12 12.0000 -> 1
+ctmx685 comparetotmag 12 12.00000 -> 1
+ctmx686 comparetotmag 12 12.000000 -> 1
+ctmx687 comparetotmag 12 12.0000000 -> 1
+ctmx688 comparetotmag 12 12.00000000 -> 1
+ctmx689 comparetotmag 12 12.000000000 -> 1
+ctmx690 comparetotmag 12 12 -> 0
+ctmx691 comparetotmag 12.0 12 -> -1
+ctmx692 comparetotmag 12.00 12 -> -1
+ctmx693 comparetotmag 12.000 12 -> -1
+ctmx694 comparetotmag 12.0000 12 -> -1
+ctmx695 comparetotmag 12.00000 12 -> -1
+ctmx696 comparetotmag 12.000000 12 -> -1
+ctmx697 comparetotmag 12.0000000 12 -> -1
+ctmx698 comparetotmag 12.00000000 12 -> -1
+ctmx699 comparetotmag 12.000000000 12 -> -1
+
+-- long operand checks
+maxexponent: 999
+minexponent: -999
+precision: 9
+ctmx701 comparetotmag 12345678000 1 -> 1
+ctmx702 comparetotmag 1 12345678000 -> -1
+ctmx703 comparetotmag 1234567800 1 -> 1
+ctmx704 comparetotmag 1 1234567800 -> -1
+ctmx705 comparetotmag 1234567890 1 -> 1
+ctmx706 comparetotmag 1 1234567890 -> -1
+ctmx707 comparetotmag 1234567891 1 -> 1
+ctmx708 comparetotmag 1 1234567891 -> -1
+ctmx709 comparetotmag 12345678901 1 -> 1
+ctmx710 comparetotmag 1 12345678901 -> -1
+ctmx711 comparetotmag 1234567896 1 -> 1
+ctmx712 comparetotmag 1 1234567896 -> -1
+ctmx713 comparetotmag -1234567891 1 -> 1
+ctmx714 comparetotmag 1 -1234567891 -> -1
+ctmx715 comparetotmag -12345678901 1 -> 1
+ctmx716 comparetotmag 1 -12345678901 -> -1
+ctmx717 comparetotmag -1234567896 1 -> 1
+ctmx718 comparetotmag 1 -1234567896 -> -1
+
+precision: 15
+-- same with plenty of precision
+ctmx721 comparetotmag 12345678000 1 -> 1
+ctmx722 comparetotmag 1 12345678000 -> -1
+ctmx723 comparetotmag 1234567800 1 -> 1
+ctmx724 comparetotmag 1 1234567800 -> -1
+ctmx725 comparetotmag 1234567890 1 -> 1
+ctmx726 comparetotmag 1 1234567890 -> -1
+ctmx727 comparetotmag 1234567891 1 -> 1
+ctmx728 comparetotmag 1 1234567891 -> -1
+ctmx729 comparetotmag 12345678901 1 -> 1
+ctmx730 comparetotmag 1 12345678901 -> -1
+ctmx731 comparetotmag 1234567896 1 -> 1
+ctmx732 comparetotmag 1 1234567896 -> -1
+
+-- residue cases
+precision: 5
+ctmx740 comparetotmag 1 0.9999999 -> 1
+ctmx741 comparetotmag 1 0.999999 -> 1
+ctmx742 comparetotmag 1 0.99999 -> 1
+ctmx743 comparetotmag 1 1.0000 -> 1
+ctmx744 comparetotmag 1 1.00001 -> -1
+ctmx745 comparetotmag 1 1.000001 -> -1
+ctmx746 comparetotmag 1 1.0000001 -> -1
+ctmx750 comparetotmag 0.9999999 1 -> -1
+ctmx751 comparetotmag 0.999999 1 -> -1
+ctmx752 comparetotmag 0.99999 1 -> -1
+ctmx753 comparetotmag 1.0000 1 -> -1
+ctmx754 comparetotmag 1.00001 1 -> 1
+ctmx755 comparetotmag 1.000001 1 -> 1
+ctmx756 comparetotmag 1.0000001 1 -> 1
+
+-- a selection of longies
+ctmx760 comparetotmag -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> 1
+ctmx761 comparetotmag -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
+ctmx762 comparetotmag -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> 1
+ctmx763 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+-- precisions above or below the difference should have no effect
+precision: 11
+ctmx764 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 10
+ctmx765 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 9
+ctmx766 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 8
+ctmx767 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 7
+ctmx768 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 6
+ctmx769 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 5
+ctmx770 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 4
+ctmx771 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 3
+ctmx772 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 2
+ctmx773 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 1
+ctmx774 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+
+-- Specials
+precision: 9
+ctmx780 comparetotmag Inf -Inf -> 0
+ctmx781 comparetotmag Inf -1000 -> 1
+ctmx782 comparetotmag Inf -1 -> 1
+ctmx783 comparetotmag Inf -0 -> 1
+ctmx784 comparetotmag Inf 0 -> 1
+ctmx785 comparetotmag Inf 1 -> 1
+ctmx786 comparetotmag Inf 1000 -> 1
+ctmx787 comparetotmag Inf Inf -> 0
+ctmx788 comparetotmag -1000 Inf -> -1
+ctmx789 comparetotmag -Inf Inf -> 0
+ctmx790 comparetotmag -1 Inf -> -1
+ctmx791 comparetotmag -0 Inf -> -1
+ctmx792 comparetotmag 0 Inf -> -1
+ctmx793 comparetotmag 1 Inf -> -1
+ctmx794 comparetotmag 1000 Inf -> -1
+ctmx795 comparetotmag Inf Inf -> 0
+
+ctmx800 comparetotmag -Inf -Inf -> 0
+ctmx801 comparetotmag -Inf -1000 -> 1
+ctmx802 comparetotmag -Inf -1 -> 1
+ctmx803 comparetotmag -Inf -0 -> 1
+ctmx804 comparetotmag -Inf 0 -> 1
+ctmx805 comparetotmag -Inf 1 -> 1
+ctmx806 comparetotmag -Inf 1000 -> 1
+ctmx807 comparetotmag -Inf Inf -> 0
+ctmx808 comparetotmag -Inf -Inf -> 0
+ctmx809 comparetotmag -1000 -Inf -> -1
+ctmx810 comparetotmag -1 -Inf -> -1
+ctmx811 comparetotmag -0 -Inf -> -1
+ctmx812 comparetotmag 0 -Inf -> -1
+ctmx813 comparetotmag 1 -Inf -> -1
+ctmx814 comparetotmag 1000 -Inf -> -1
+ctmx815 comparetotmag Inf -Inf -> 0
+
+ctmx821 comparetotmag NaN -Inf -> 1
+ctmx822 comparetotmag NaN -1000 -> 1
+ctmx823 comparetotmag NaN -1 -> 1
+ctmx824 comparetotmag NaN -0 -> 1
+ctmx825 comparetotmag NaN 0 -> 1
+ctmx826 comparetotmag NaN 1 -> 1
+ctmx827 comparetotmag NaN 1000 -> 1
+ctmx828 comparetotmag NaN Inf -> 1
+ctmx829 comparetotmag NaN NaN -> 0
+ctmx830 comparetotmag -Inf NaN -> -1
+ctmx831 comparetotmag -1000 NaN -> -1
+ctmx832 comparetotmag -1 NaN -> -1
+ctmx833 comparetotmag -0 NaN -> -1
+ctmx834 comparetotmag 0 NaN -> -1
+ctmx835 comparetotmag 1 NaN -> -1
+ctmx836 comparetotmag 1000 NaN -> -1
+ctmx837 comparetotmag Inf NaN -> -1
+ctmx838 comparetotmag -NaN -NaN -> 0
+ctmx839 comparetotmag +NaN -NaN -> 0
+ctmx840 comparetotmag -NaN +NaN -> 0
+
+ctmx841 comparetotmag sNaN -sNaN -> 0
+ctmx842 comparetotmag sNaN -NaN -> -1
+ctmx843 comparetotmag sNaN -Inf -> 1
+ctmx844 comparetotmag sNaN -1000 -> 1
+ctmx845 comparetotmag sNaN -1 -> 1
+ctmx846 comparetotmag sNaN -0 -> 1
+ctmx847 comparetotmag sNaN 0 -> 1
+ctmx848 comparetotmag sNaN 1 -> 1
+ctmx849 comparetotmag sNaN 1000 -> 1
+ctmx850 comparetotmag sNaN NaN -> -1
+ctmx851 comparetotmag sNaN sNaN -> 0
+
+ctmx852 comparetotmag -sNaN sNaN -> 0
+ctmx853 comparetotmag -NaN sNaN -> 1
+ctmx854 comparetotmag -Inf sNaN -> -1
+ctmx855 comparetotmag -1000 sNaN -> -1
+ctmx856 comparetotmag -1 sNaN -> -1
+ctmx857 comparetotmag -0 sNaN -> -1
+ctmx858 comparetotmag 0 sNaN -> -1
+ctmx859 comparetotmag 1 sNaN -> -1
+ctmx860 comparetotmag 1000 sNaN -> -1
+ctmx861 comparetotmag Inf sNaN -> -1
+ctmx862 comparetotmag NaN sNaN -> 1
+ctmx863 comparetotmag sNaN sNaN -> 0
+
+ctmx871 comparetotmag -sNaN -sNaN -> 0
+ctmx872 comparetotmag -sNaN -NaN -> -1
+ctmx873 comparetotmag -sNaN -Inf -> 1
+ctmx874 comparetotmag -sNaN -1000 -> 1
+ctmx875 comparetotmag -sNaN -1 -> 1
+ctmx876 comparetotmag -sNaN -0 -> 1
+ctmx877 comparetotmag -sNaN 0 -> 1
+ctmx878 comparetotmag -sNaN 1 -> 1
+ctmx879 comparetotmag -sNaN 1000 -> 1
+ctmx880 comparetotmag -sNaN NaN -> -1
+ctmx881 comparetotmag -sNaN sNaN -> 0
+
+ctmx882 comparetotmag -sNaN -sNaN -> 0
+ctmx883 comparetotmag -NaN -sNaN -> 1
+ctmx884 comparetotmag -Inf -sNaN -> -1
+ctmx885 comparetotmag -1000 -sNaN -> -1
+ctmx886 comparetotmag -1 -sNaN -> -1
+ctmx887 comparetotmag -0 -sNaN -> -1
+ctmx888 comparetotmag 0 -sNaN -> -1
+ctmx889 comparetotmag 1 -sNaN -> -1
+ctmx890 comparetotmag 1000 -sNaN -> -1
+ctmx891 comparetotmag Inf -sNaN -> -1
+ctmx892 comparetotmag NaN -sNaN -> 1
+ctmx893 comparetotmag sNaN -sNaN -> 0
+
+-- NaNs with payload
+ctmx960 comparetotmag NaN9 -Inf -> 1
+ctmx961 comparetotmag NaN8 999 -> 1
+ctmx962 comparetotmag NaN77 Inf -> 1
+ctmx963 comparetotmag -NaN67 NaN5 -> 1
+ctmx964 comparetotmag -Inf -NaN4 -> -1
+ctmx965 comparetotmag -999 -NaN33 -> -1
+ctmx966 comparetotmag Inf NaN2 -> -1
+
+ctmx970 comparetotmag -NaN41 -NaN42 -> -1
+ctmx971 comparetotmag +NaN41 -NaN42 -> -1
+ctmx972 comparetotmag -NaN41 +NaN42 -> -1
+ctmx973 comparetotmag +NaN41 +NaN42 -> -1
+ctmx974 comparetotmag -NaN42 -NaN01 -> 1
+ctmx975 comparetotmag +NaN42 -NaN01 -> 1
+ctmx976 comparetotmag -NaN42 +NaN01 -> 1
+ctmx977 comparetotmag +NaN42 +NaN01 -> 1
+
+ctmx980 comparetotmag -sNaN771 -sNaN772 -> -1
+ctmx981 comparetotmag +sNaN771 -sNaN772 -> -1
+ctmx982 comparetotmag -sNaN771 +sNaN772 -> -1
+ctmx983 comparetotmag +sNaN771 +sNaN772 -> -1
+ctmx984 comparetotmag -sNaN772 -sNaN771 -> 1
+ctmx985 comparetotmag +sNaN772 -sNaN771 -> 1
+ctmx986 comparetotmag -sNaN772 +sNaN771 -> 1
+ctmx987 comparetotmag +sNaN772 +sNaN771 -> 1
+
+ctmx991 comparetotmag -sNaN99 -Inf -> 1
+ctmx992 comparetotmag sNaN98 -11 -> 1
+ctmx993 comparetotmag sNaN97 NaN -> -1
+ctmx994 comparetotmag sNaN16 sNaN94 -> -1
+ctmx995 comparetotmag NaN85 sNaN83 -> 1
+ctmx996 comparetotmag -Inf sNaN92 -> -1
+ctmx997 comparetotmag 088 sNaN81 -> -1
+ctmx998 comparetotmag Inf sNaN90 -> -1
+ctmx999 comparetotmag NaN -sNaN89 -> 1
+
+-- overflow and underflow tests .. subnormal results now allowed
+maxExponent: 999999999
+minexponent: -999999999
+ctmx1080 comparetotmag +1.23456789012345E-0 9E+999999999 -> -1
+ctmx1081 comparetotmag 9E+999999999 +1.23456789012345E-0 -> 1
+ctmx1082 comparetotmag +0.100 9E-999999999 -> 1
+ctmx1083 comparetotmag 9E-999999999 +0.100 -> -1
+ctmx1085 comparetotmag -1.23456789012345E-0 9E+999999999 -> -1
+ctmx1086 comparetotmag 9E+999999999 -1.23456789012345E-0 -> 1
+ctmx1087 comparetotmag -0.100 9E-999999999 -> 1
+ctmx1088 comparetotmag 9E-999999999 -0.100 -> -1
+
+ctmx1089 comparetotmag 1e-599999999 1e-400000001 -> -1
+ctmx1090 comparetotmag 1e-599999999 1e-400000000 -> -1
+ctmx1091 comparetotmag 1e-600000000 1e-400000000 -> -1
+ctmx1092 comparetotmag 9e-999999998 0.01 -> -1
+ctmx1093 comparetotmag 9e-999999998 0.1 -> -1
+ctmx1094 comparetotmag 0.01 9e-999999998 -> 1
+ctmx1095 comparetotmag 1e599999999 1e400000001 -> 1
+ctmx1096 comparetotmag 1e599999999 1e400000000 -> 1
+ctmx1097 comparetotmag 1e600000000 1e400000000 -> 1
+ctmx1098 comparetotmag 9e999999998 100 -> 1
+ctmx1099 comparetotmag 9e999999998 10 -> 1
+ctmx1100 comparetotmag 100 9e999999998 -> -1
+-- signs
+ctmx1101 comparetotmag 1e+777777777 1e+411111111 -> 1
+ctmx1102 comparetotmag 1e+777777777 -1e+411111111 -> 1
+ctmx1103 comparetotmag -1e+777777777 1e+411111111 -> 1
+ctmx1104 comparetotmag -1e+777777777 -1e+411111111 -> 1
+ctmx1105 comparetotmag 1e-777777777 1e-411111111 -> -1
+ctmx1106 comparetotmag 1e-777777777 -1e-411111111 -> -1
+ctmx1107 comparetotmag -1e-777777777 1e-411111111 -> -1
+ctmx1108 comparetotmag -1e-777777777 -1e-411111111 -> -1
+
+-- spread zeros
+ctmx1110 comparetotmag 0E-383 0 -> -1
+ctmx1111 comparetotmag 0E-383 -0 -> -1
+ctmx1112 comparetotmag -0E-383 0 -> -1
+ctmx1113 comparetotmag -0E-383 -0 -> -1
+ctmx1114 comparetotmag 0E-383 0E+384 -> -1
+ctmx1115 comparetotmag 0E-383 -0E+384 -> -1
+ctmx1116 comparetotmag -0E-383 0E+384 -> -1
+ctmx1117 comparetotmag -0E-383 -0E+384 -> -1
+ctmx1118 comparetotmag 0 0E+384 -> -1
+ctmx1119 comparetotmag 0 -0E+384 -> -1
+ctmx1120 comparetotmag -0 0E+384 -> -1
+ctmx1121 comparetotmag -0 -0E+384 -> -1
+
+ctmx1130 comparetotmag 0E+384 0 -> 1
+ctmx1131 comparetotmag 0E+384 -0 -> 1
+ctmx1132 comparetotmag -0E+384 0 -> 1
+ctmx1133 comparetotmag -0E+384 -0 -> 1
+ctmx1134 comparetotmag 0E+384 0E-383 -> 1
+ctmx1135 comparetotmag 0E+384 -0E-383 -> 1
+ctmx1136 comparetotmag -0E+384 0E-383 -> 1
+ctmx1137 comparetotmag -0E+384 -0E-383 -> 1
+ctmx1138 comparetotmag 0 0E-383 -> 1
+ctmx1139 comparetotmag 0 -0E-383 -> 1
+ctmx1140 comparetotmag -0 0E-383 -> 1
+ctmx1141 comparetotmag -0 -0E-383 -> 1
+
+-- Null tests
+ctmx9990 comparetotmag 10 # -> NaN Invalid_operation
+ctmx9991 comparetotmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/copy.decTest b/Lib/test/decimaltestdata/copy.decTest
index d9f299e227..b47e499a7b 100644
--- a/Lib/test/decimaltestdata/copy.decTest
+++ b/Lib/test/decimaltestdata/copy.decTest
@@ -1,86 +1,86 @@
-------------------------------------------------------------------------
--- copy.decTest -- quiet copy --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-cpyx001 copy +7.50 -> 7.50
-
--- Infinities
-cpyx011 copy Infinity -> Infinity
-cpyx012 copy -Infinity -> -Infinity
-
--- NaNs, 0 payload
-cpyx021 copy NaN -> NaN
-cpyx022 copy -NaN -> -NaN
-cpyx023 copy sNaN -> sNaN
-cpyx024 copy -sNaN -> -sNaN
-
--- NaNs, non-0 payload
-cpyx031 copy NaN10 -> NaN10
-cpyx032 copy -NaN10 -> -NaN10
-cpyx033 copy sNaN10 -> sNaN10
-cpyx034 copy -sNaN10 -> -sNaN10
-cpyx035 copy NaN7 -> NaN7
-cpyx036 copy -NaN7 -> -NaN7
-cpyx037 copy sNaN101 -> sNaN101
-cpyx038 copy -sNaN101 -> -sNaN101
-
--- finites
-cpyx101 copy 7 -> 7
-cpyx102 copy -7 -> -7
-cpyx103 copy 75 -> 75
-cpyx104 copy -75 -> -75
-cpyx105 copy 7.50 -> 7.50
-cpyx106 copy -7.50 -> -7.50
-cpyx107 copy 7.500 -> 7.500
-cpyx108 copy -7.500 -> -7.500
-
--- zeros
-cpyx111 copy 0 -> 0
-cpyx112 copy -0 -> -0
-cpyx113 copy 0E+4 -> 0E+4
-cpyx114 copy -0E+4 -> -0E+4
-cpyx115 copy 0.0000 -> 0.0000
-cpyx116 copy -0.0000 -> -0.0000
-cpyx117 copy 0E-141 -> 0E-141
-cpyx118 copy -0E-141 -> -0E-141
-
--- full coefficients, alternating bits
-cpyx121 copy 268268268 -> 268268268
-cpyx122 copy -268268268 -> -268268268
-cpyx123 copy 134134134 -> 134134134
-cpyx124 copy -134134134 -> -134134134
-
--- Nmax, Nmin, Ntiny
-cpyx131 copy 9.99999999E+999 -> 9.99999999E+999
-cpyx132 copy 1E-999 -> 1E-999
-cpyx133 copy 1.00000000E-999 -> 1.00000000E-999
-cpyx134 copy 1E-1007 -> 1E-1007
-
-cpyx135 copy -1E-1007 -> -1E-1007
-cpyx136 copy -1.00000000E-999 -> -1.00000000E-999
-cpyx137 copy -1E-999 -> -1E-999
-cpyx138 copy -9.99999999E+999 -> -9.99999999E+999
+------------------------------------------------------------------------
+-- copy.decTest -- quiet copy --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+cpyx001 copy +7.50 -> 7.50
+
+-- Infinities
+cpyx011 copy Infinity -> Infinity
+cpyx012 copy -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+cpyx021 copy NaN -> NaN
+cpyx022 copy -NaN -> -NaN
+cpyx023 copy sNaN -> sNaN
+cpyx024 copy -sNaN -> -sNaN
+
+-- NaNs, non-0 payload
+cpyx031 copy NaN10 -> NaN10
+cpyx032 copy -NaN10 -> -NaN10
+cpyx033 copy sNaN10 -> sNaN10
+cpyx034 copy -sNaN10 -> -sNaN10
+cpyx035 copy NaN7 -> NaN7
+cpyx036 copy -NaN7 -> -NaN7
+cpyx037 copy sNaN101 -> sNaN101
+cpyx038 copy -sNaN101 -> -sNaN101
+
+-- finites
+cpyx101 copy 7 -> 7
+cpyx102 copy -7 -> -7
+cpyx103 copy 75 -> 75
+cpyx104 copy -75 -> -75
+cpyx105 copy 7.50 -> 7.50
+cpyx106 copy -7.50 -> -7.50
+cpyx107 copy 7.500 -> 7.500
+cpyx108 copy -7.500 -> -7.500
+
+-- zeros
+cpyx111 copy 0 -> 0
+cpyx112 copy -0 -> -0
+cpyx113 copy 0E+4 -> 0E+4
+cpyx114 copy -0E+4 -> -0E+4
+cpyx115 copy 0.0000 -> 0.0000
+cpyx116 copy -0.0000 -> -0.0000
+cpyx117 copy 0E-141 -> 0E-141
+cpyx118 copy -0E-141 -> -0E-141
+
+-- full coefficients, alternating bits
+cpyx121 copy 268268268 -> 268268268
+cpyx122 copy -268268268 -> -268268268
+cpyx123 copy 134134134 -> 134134134
+cpyx124 copy -134134134 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+cpyx131 copy 9.99999999E+999 -> 9.99999999E+999
+cpyx132 copy 1E-999 -> 1E-999
+cpyx133 copy 1.00000000E-999 -> 1.00000000E-999
+cpyx134 copy 1E-1007 -> 1E-1007
+
+cpyx135 copy -1E-1007 -> -1E-1007
+cpyx136 copy -1.00000000E-999 -> -1.00000000E-999
+cpyx137 copy -1E-999 -> -1E-999
+cpyx138 copy -9.99999999E+999 -> -9.99999999E+999
diff --git a/Lib/test/decimaltestdata/copyabs.decTest b/Lib/test/decimaltestdata/copyabs.decTest
index 52002dc431..f7d0f86458 100644
--- a/Lib/test/decimaltestdata/copyabs.decTest
+++ b/Lib/test/decimaltestdata/copyabs.decTest
@@ -1,86 +1,86 @@
-------------------------------------------------------------------------
--- copyAbs.decTest -- quiet copy and set sign to zero --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-cpax001 copyabs +7.50 -> 7.50
-
--- Infinities
-cpax011 copyabs Infinity -> Infinity
-cpax012 copyabs -Infinity -> Infinity
-
--- NaNs, 0 payload
-cpax021 copyabs NaN -> NaN
-cpax022 copyabs -NaN -> NaN
-cpax023 copyabs sNaN -> sNaN
-cpax024 copyabs -sNaN -> sNaN
-
--- NaNs, non-0 payload
-cpax031 copyabs NaN10 -> NaN10
-cpax032 copyabs -NaN15 -> NaN15
-cpax033 copyabs sNaN15 -> sNaN15
-cpax034 copyabs -sNaN10 -> sNaN10
-cpax035 copyabs NaN7 -> NaN7
-cpax036 copyabs -NaN7 -> NaN7
-cpax037 copyabs sNaN101 -> sNaN101
-cpax038 copyabs -sNaN101 -> sNaN101
-
--- finites
-cpax101 copyabs 7 -> 7
-cpax102 copyabs -7 -> 7
-cpax103 copyabs 75 -> 75
-cpax104 copyabs -75 -> 75
-cpax105 copyabs 7.10 -> 7.10
-cpax106 copyabs -7.10 -> 7.10
-cpax107 copyabs 7.500 -> 7.500
-cpax108 copyabs -7.500 -> 7.500
-
--- zeros
-cpax111 copyabs 0 -> 0
-cpax112 copyabs -0 -> 0
-cpax113 copyabs 0E+6 -> 0E+6
-cpax114 copyabs -0E+6 -> 0E+6
-cpax115 copyabs 0.0000 -> 0.0000
-cpax116 copyabs -0.0000 -> 0.0000
-cpax117 copyabs 0E-141 -> 0E-141
-cpax118 copyabs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-cpax121 copyabs 268268268 -> 268268268
-cpax122 copyabs -268268268 -> 268268268
-cpax123 copyabs 134134134 -> 134134134
-cpax124 copyabs -134134134 -> 134134134
-
--- Nmax, Nmin, Ntiny
-cpax131 copyabs 9.99999999E+999 -> 9.99999999E+999
-cpax132 copyabs 1E-999 -> 1E-999
-cpax133 copyabs 1.00000000E-999 -> 1.00000000E-999
-cpax134 copyabs 1E-1007 -> 1E-1007
-
-cpax135 copyabs -1E-1007 -> 1E-1007
-cpax136 copyabs -1.00000000E-999 -> 1.00000000E-999
-cpax137 copyabs -1E-999 -> 1E-999
-cpax199 copyabs -9.99999999E+999 -> 9.99999999E+999
+------------------------------------------------------------------------
+-- copyAbs.decTest -- quiet copy and set sign to zero --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+cpax001 copyabs +7.50 -> 7.50
+
+-- Infinities
+cpax011 copyabs Infinity -> Infinity
+cpax012 copyabs -Infinity -> Infinity
+
+-- NaNs, 0 payload
+cpax021 copyabs NaN -> NaN
+cpax022 copyabs -NaN -> NaN
+cpax023 copyabs sNaN -> sNaN
+cpax024 copyabs -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+cpax031 copyabs NaN10 -> NaN10
+cpax032 copyabs -NaN15 -> NaN15
+cpax033 copyabs sNaN15 -> sNaN15
+cpax034 copyabs -sNaN10 -> sNaN10
+cpax035 copyabs NaN7 -> NaN7
+cpax036 copyabs -NaN7 -> NaN7
+cpax037 copyabs sNaN101 -> sNaN101
+cpax038 copyabs -sNaN101 -> sNaN101
+
+-- finites
+cpax101 copyabs 7 -> 7
+cpax102 copyabs -7 -> 7
+cpax103 copyabs 75 -> 75
+cpax104 copyabs -75 -> 75
+cpax105 copyabs 7.10 -> 7.10
+cpax106 copyabs -7.10 -> 7.10
+cpax107 copyabs 7.500 -> 7.500
+cpax108 copyabs -7.500 -> 7.500
+
+-- zeros
+cpax111 copyabs 0 -> 0
+cpax112 copyabs -0 -> 0
+cpax113 copyabs 0E+6 -> 0E+6
+cpax114 copyabs -0E+6 -> 0E+6
+cpax115 copyabs 0.0000 -> 0.0000
+cpax116 copyabs -0.0000 -> 0.0000
+cpax117 copyabs 0E-141 -> 0E-141
+cpax118 copyabs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+cpax121 copyabs 268268268 -> 268268268
+cpax122 copyabs -268268268 -> 268268268
+cpax123 copyabs 134134134 -> 134134134
+cpax124 copyabs -134134134 -> 134134134
+
+-- Nmax, Nmin, Ntiny
+cpax131 copyabs 9.99999999E+999 -> 9.99999999E+999
+cpax132 copyabs 1E-999 -> 1E-999
+cpax133 copyabs 1.00000000E-999 -> 1.00000000E-999
+cpax134 copyabs 1E-1007 -> 1E-1007
+
+cpax135 copyabs -1E-1007 -> 1E-1007
+cpax136 copyabs -1.00000000E-999 -> 1.00000000E-999
+cpax137 copyabs -1E-999 -> 1E-999
+cpax199 copyabs -9.99999999E+999 -> 9.99999999E+999
diff --git a/Lib/test/decimaltestdata/copynegate.decTest b/Lib/test/decimaltestdata/copynegate.decTest
index 7f8de9d932..38235b60f9 100644
--- a/Lib/test/decimaltestdata/copynegate.decTest
+++ b/Lib/test/decimaltestdata/copynegate.decTest
@@ -1,86 +1,86 @@
-------------------------------------------------------------------------
--- copyNegate.decTest -- quiet copy and negate --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-cpnx001 copynegate +7.50 -> -7.50
-
--- Infinities
-cpnx011 copynegate Infinity -> -Infinity
-cpnx012 copynegate -Infinity -> Infinity
-
--- NaNs, 0 payload
-cpnx021 copynegate NaN -> -NaN
-cpnx022 copynegate -NaN -> NaN
-cpnx023 copynegate sNaN -> -sNaN
-cpnx024 copynegate -sNaN -> sNaN
-
--- NaNs, non-0 payload
-cpnx031 copynegate NaN13 -> -NaN13
-cpnx032 copynegate -NaN13 -> NaN13
-cpnx033 copynegate sNaN13 -> -sNaN13
-cpnx034 copynegate -sNaN13 -> sNaN13
-cpnx035 copynegate NaN70 -> -NaN70
-cpnx036 copynegate -NaN70 -> NaN70
-cpnx037 copynegate sNaN101 -> -sNaN101
-cpnx038 copynegate -sNaN101 -> sNaN101
-
--- finites
-cpnx101 copynegate 7 -> -7
-cpnx102 copynegate -7 -> 7
-cpnx103 copynegate 75 -> -75
-cpnx104 copynegate -75 -> 75
-cpnx105 copynegate 7.50 -> -7.50
-cpnx106 copynegate -7.50 -> 7.50
-cpnx107 copynegate 7.500 -> -7.500
-cpnx108 copynegate -7.500 -> 7.500
-
--- zeros
-cpnx111 copynegate 0 -> -0
-cpnx112 copynegate -0 -> 0
-cpnx113 copynegate 0E+4 -> -0E+4
-cpnx114 copynegate -0E+4 -> 0E+4
-cpnx115 copynegate 0.0000 -> -0.0000
-cpnx116 copynegate -0.0000 -> 0.0000
-cpnx117 copynegate 0E-141 -> -0E-141
-cpnx118 copynegate -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-cpnx121 copynegate 268268268 -> -268268268
-cpnx122 copynegate -268268268 -> 268268268
-cpnx123 copynegate 134134134 -> -134134134
-cpnx124 copynegate -134134134 -> 134134134
-
--- Nmax, Nmin, Ntiny
-cpnx131 copynegate 9.99999999E+999 -> -9.99999999E+999
-cpnx132 copynegate 1E-999 -> -1E-999
-cpnx133 copynegate 1.00000000E-999 -> -1.00000000E-999
-cpnx134 copynegate 1E-1007 -> -1E-1007
-
-cpnx135 copynegate -1E-1007 -> 1E-1007
-cpnx136 copynegate -1.00000000E-999 -> 1.00000000E-999
-cpnx137 copynegate -1E-999 -> 1E-999
-cpnx138 copynegate -9.99999999E+999 -> 9.99999999E+999
+------------------------------------------------------------------------
+-- copyNegate.decTest -- quiet copy and negate --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+cpnx001 copynegate +7.50 -> -7.50
+
+-- Infinities
+cpnx011 copynegate Infinity -> -Infinity
+cpnx012 copynegate -Infinity -> Infinity
+
+-- NaNs, 0 payload
+cpnx021 copynegate NaN -> -NaN
+cpnx022 copynegate -NaN -> NaN
+cpnx023 copynegate sNaN -> -sNaN
+cpnx024 copynegate -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+cpnx031 copynegate NaN13 -> -NaN13
+cpnx032 copynegate -NaN13 -> NaN13
+cpnx033 copynegate sNaN13 -> -sNaN13
+cpnx034 copynegate -sNaN13 -> sNaN13
+cpnx035 copynegate NaN70 -> -NaN70
+cpnx036 copynegate -NaN70 -> NaN70
+cpnx037 copynegate sNaN101 -> -sNaN101
+cpnx038 copynegate -sNaN101 -> sNaN101
+
+-- finites
+cpnx101 copynegate 7 -> -7
+cpnx102 copynegate -7 -> 7
+cpnx103 copynegate 75 -> -75
+cpnx104 copynegate -75 -> 75
+cpnx105 copynegate 7.50 -> -7.50
+cpnx106 copynegate -7.50 -> 7.50
+cpnx107 copynegate 7.500 -> -7.500
+cpnx108 copynegate -7.500 -> 7.500
+
+-- zeros
+cpnx111 copynegate 0 -> -0
+cpnx112 copynegate -0 -> 0
+cpnx113 copynegate 0E+4 -> -0E+4
+cpnx114 copynegate -0E+4 -> 0E+4
+cpnx115 copynegate 0.0000 -> -0.0000
+cpnx116 copynegate -0.0000 -> 0.0000
+cpnx117 copynegate 0E-141 -> -0E-141
+cpnx118 copynegate -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+cpnx121 copynegate 268268268 -> -268268268
+cpnx122 copynegate -268268268 -> 268268268
+cpnx123 copynegate 134134134 -> -134134134
+cpnx124 copynegate -134134134 -> 134134134
+
+-- Nmax, Nmin, Ntiny
+cpnx131 copynegate 9.99999999E+999 -> -9.99999999E+999
+cpnx132 copynegate 1E-999 -> -1E-999
+cpnx133 copynegate 1.00000000E-999 -> -1.00000000E-999
+cpnx134 copynegate 1E-1007 -> -1E-1007
+
+cpnx135 copynegate -1E-1007 -> 1E-1007
+cpnx136 copynegate -1.00000000E-999 -> 1.00000000E-999
+cpnx137 copynegate -1E-999 -> 1E-999
+cpnx138 copynegate -9.99999999E+999 -> 9.99999999E+999
diff --git a/Lib/test/decimaltestdata/copysign.decTest b/Lib/test/decimaltestdata/copysign.decTest
index afdd670d3c..8061a4219c 100644
--- a/Lib/test/decimaltestdata/copysign.decTest
+++ b/Lib/test/decimaltestdata/copysign.decTest
@@ -1,177 +1,177 @@
-------------------------------------------------------------------------
--- copysign.decTest -- quiet copy with sign from rhs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check, and examples from decArith
-cpsx001 copysign +7.50 11 -> 7.50
-cpsx002 copysign '1.50' '7.33' -> 1.50
-cpsx003 copysign '-1.50' '7.33' -> 1.50
-cpsx004 copysign '1.50' '-7.33' -> -1.50
-cpsx005 copysign '-1.50' '-7.33' -> -1.50
-
--- Infinities
-cpsx011 copysign Infinity 11 -> Infinity
-cpsx012 copysign -Infinity 11 -> Infinity
-
--- NaNs, 0 payload
-cpsx021 copysign NaN 11 -> NaN
-cpsx022 copysign -NaN 11 -> NaN
-cpsx023 copysign sNaN 11 -> sNaN
-cpsx024 copysign -sNaN 11 -> sNaN
-
--- NaNs, non-0 payload
-cpsx031 copysign NaN10 11 -> NaN10
-cpsx032 copysign -NaN10 11 -> NaN10
-cpsx033 copysign sNaN10 11 -> sNaN10
-cpsx034 copysign -sNaN10 11 -> sNaN10
-cpsx035 copysign NaN7 11 -> NaN7
-cpsx036 copysign -NaN7 11 -> NaN7
-cpsx037 copysign sNaN101 11 -> sNaN101
-cpsx038 copysign -sNaN101 11 -> sNaN101
-
--- finites
-cpsx101 copysign 7 11 -> 7
-cpsx102 copysign -7 11 -> 7
-cpsx103 copysign 75 11 -> 75
-cpsx104 copysign -75 11 -> 75
-cpsx105 copysign 7.50 11 -> 7.50
-cpsx106 copysign -7.50 11 -> 7.50
-cpsx107 copysign 7.500 11 -> 7.500
-cpsx108 copysign -7.500 11 -> 7.500
-
--- zeros
-cpsx111 copysign 0 11 -> 0
-cpsx112 copysign -0 11 -> 0
-cpsx113 copysign 0E+4 11 -> 0E+4
-cpsx114 copysign -0E+4 11 -> 0E+4
-cpsx115 copysign 0.0000 11 -> 0.0000
-cpsx116 copysign -0.0000 11 -> 0.0000
-cpsx117 copysign 0E-141 11 -> 0E-141
-cpsx118 copysign -0E-141 11 -> 0E-141
-
--- full coefficients, alternating bits
-cpsx121 copysign 268268268 11 -> 268268268
-cpsx122 copysign -268268268 11 -> 268268268
-cpsx123 copysign 134134134 11 -> 134134134
-cpsx124 copysign -134134134 11 -> 134134134
-
--- Nmax, Nmin, Ntiny
-cpsx131 copysign 9.99999999E+999 11 -> 9.99999999E+999
-cpsx132 copysign 1E-999 11 -> 1E-999
-cpsx133 copysign 1.00000000E-999 11 -> 1.00000000E-999
-cpsx134 copysign 1E-1007 11 -> 1E-1007
-
-cpsx135 copysign -1E-1007 11 -> 1E-1007
-cpsx136 copysign -1.00000000E-999 11 -> 1.00000000E-999
-cpsx137 copysign -1E-999 11 -> 1E-999
-cpsx138 copysign -9.99999999E+999 11 -> 9.99999999E+999
-
--- repeat with negative RHS
-
--- Infinities
-cpsx211 copysign Infinity -34 -> -Infinity
-cpsx212 copysign -Infinity -34 -> -Infinity
-
--- NaNs, 0 payload
-cpsx221 copysign NaN -34 -> -NaN
-cpsx222 copysign -NaN -34 -> -NaN
-cpsx223 copysign sNaN -34 -> -sNaN
-cpsx224 copysign -sNaN -34 -> -sNaN
-
--- NaNs, non-0 payload
-cpsx231 copysign NaN10 -34 -> -NaN10
-cpsx232 copysign -NaN10 -34 -> -NaN10
-cpsx233 copysign sNaN10 -34 -> -sNaN10
-cpsx234 copysign -sNaN10 -34 -> -sNaN10
-cpsx235 copysign NaN7 -34 -> -NaN7
-cpsx236 copysign -NaN7 -34 -> -NaN7
-cpsx237 copysign sNaN101 -34 -> -sNaN101
-cpsx238 copysign -sNaN101 -34 -> -sNaN101
-
--- finites
-cpsx301 copysign 7 -34 -> -7
-cpsx302 copysign -7 -34 -> -7
-cpsx303 copysign 75 -34 -> -75
-cpsx304 copysign -75 -34 -> -75
-cpsx305 copysign 7.50 -34 -> -7.50
-cpsx306 copysign -7.50 -34 -> -7.50
-cpsx307 copysign 7.500 -34 -> -7.500
-cpsx308 copysign -7.500 -34 -> -7.500
-
--- zeros
-cpsx311 copysign 0 -34 -> -0
-cpsx312 copysign -0 -34 -> -0
-cpsx313 copysign 0E+4 -34 -> -0E+4
-cpsx314 copysign -0E+4 -34 -> -0E+4
-cpsx315 copysign 0.0000 -34 -> -0.0000
-cpsx316 copysign -0.0000 -34 -> -0.0000
-cpsx317 copysign 0E-141 -34 -> -0E-141
-cpsx318 copysign -0E-141 -34 -> -0E-141
-
--- full coefficients, alternating bits
-cpsx321 copysign 268268268 -18 -> -268268268
-cpsx322 copysign -268268268 -18 -> -268268268
-cpsx323 copysign 134134134 -18 -> -134134134
-cpsx324 copysign -134134134 -18 -> -134134134
-
--- Nmax, Nmin, Ntiny
-cpsx331 copysign 9.99999999E+999 -18 -> -9.99999999E+999
-cpsx332 copysign 1E-999 -18 -> -1E-999
-cpsx333 copysign 1.00000000E-999 -18 -> -1.00000000E-999
-cpsx334 copysign 1E-1007 -18 -> -1E-1007
-
-cpsx335 copysign -1E-1007 -18 -> -1E-1007
-cpsx336 copysign -1.00000000E-999 -18 -> -1.00000000E-999
-cpsx337 copysign -1E-999 -18 -> -1E-999
-cpsx338 copysign -9.99999999E+999 -18 -> -9.99999999E+999
-
--- Other kinds of RHS
-cpsx401 copysign 701 -34 -> -701
-cpsx402 copysign -720 -34 -> -720
-cpsx403 copysign 701 -0 -> -701
-cpsx404 copysign -720 -0 -> -720
-cpsx405 copysign 701 +0 -> 701
-cpsx406 copysign -720 +0 -> 720
-cpsx407 copysign 701 +34 -> 701
-cpsx408 copysign -720 +34 -> 720
-
-cpsx413 copysign 701 -Inf -> -701
-cpsx414 copysign -720 -Inf -> -720
-cpsx415 copysign 701 +Inf -> 701
-cpsx416 copysign -720 +Inf -> 720
-
-cpsx420 copysign 701 -NaN -> -701
-cpsx421 copysign -720 -NaN -> -720
-cpsx422 copysign 701 +NaN -> 701
-cpsx423 copysign -720 +NaN -> 720
-cpsx425 copysign -720 +NaN8 -> 720
-
-cpsx426 copysign 701 -sNaN -> -701
-cpsx427 copysign -720 -sNaN -> -720
-cpsx428 copysign 701 +sNaN -> 701
-cpsx429 copysign -720 +sNaN -> 720
-cpsx430 copysign -720 +sNaN3 -> 720
-
+------------------------------------------------------------------------
+-- copysign.decTest -- quiet copy with sign from rhs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check, and examples from decArith
+cpsx001 copysign +7.50 11 -> 7.50
+cpsx002 copysign '1.50' '7.33' -> 1.50
+cpsx003 copysign '-1.50' '7.33' -> 1.50
+cpsx004 copysign '1.50' '-7.33' -> -1.50
+cpsx005 copysign '-1.50' '-7.33' -> -1.50
+
+-- Infinities
+cpsx011 copysign Infinity 11 -> Infinity
+cpsx012 copysign -Infinity 11 -> Infinity
+
+-- NaNs, 0 payload
+cpsx021 copysign NaN 11 -> NaN
+cpsx022 copysign -NaN 11 -> NaN
+cpsx023 copysign sNaN 11 -> sNaN
+cpsx024 copysign -sNaN 11 -> sNaN
+
+-- NaNs, non-0 payload
+cpsx031 copysign NaN10 11 -> NaN10
+cpsx032 copysign -NaN10 11 -> NaN10
+cpsx033 copysign sNaN10 11 -> sNaN10
+cpsx034 copysign -sNaN10 11 -> sNaN10
+cpsx035 copysign NaN7 11 -> NaN7
+cpsx036 copysign -NaN7 11 -> NaN7
+cpsx037 copysign sNaN101 11 -> sNaN101
+cpsx038 copysign -sNaN101 11 -> sNaN101
+
+-- finites
+cpsx101 copysign 7 11 -> 7
+cpsx102 copysign -7 11 -> 7
+cpsx103 copysign 75 11 -> 75
+cpsx104 copysign -75 11 -> 75
+cpsx105 copysign 7.50 11 -> 7.50
+cpsx106 copysign -7.50 11 -> 7.50
+cpsx107 copysign 7.500 11 -> 7.500
+cpsx108 copysign -7.500 11 -> 7.500
+
+-- zeros
+cpsx111 copysign 0 11 -> 0
+cpsx112 copysign -0 11 -> 0
+cpsx113 copysign 0E+4 11 -> 0E+4
+cpsx114 copysign -0E+4 11 -> 0E+4
+cpsx115 copysign 0.0000 11 -> 0.0000
+cpsx116 copysign -0.0000 11 -> 0.0000
+cpsx117 copysign 0E-141 11 -> 0E-141
+cpsx118 copysign -0E-141 11 -> 0E-141
+
+-- full coefficients, alternating bits
+cpsx121 copysign 268268268 11 -> 268268268
+cpsx122 copysign -268268268 11 -> 268268268
+cpsx123 copysign 134134134 11 -> 134134134
+cpsx124 copysign -134134134 11 -> 134134134
+
+-- Nmax, Nmin, Ntiny
+cpsx131 copysign 9.99999999E+999 11 -> 9.99999999E+999
+cpsx132 copysign 1E-999 11 -> 1E-999
+cpsx133 copysign 1.00000000E-999 11 -> 1.00000000E-999
+cpsx134 copysign 1E-1007 11 -> 1E-1007
+
+cpsx135 copysign -1E-1007 11 -> 1E-1007
+cpsx136 copysign -1.00000000E-999 11 -> 1.00000000E-999
+cpsx137 copysign -1E-999 11 -> 1E-999
+cpsx138 copysign -9.99999999E+999 11 -> 9.99999999E+999
+
+-- repeat with negative RHS
+
+-- Infinities
+cpsx211 copysign Infinity -34 -> -Infinity
+cpsx212 copysign -Infinity -34 -> -Infinity
+
+-- NaNs, 0 payload
+cpsx221 copysign NaN -34 -> -NaN
+cpsx222 copysign -NaN -34 -> -NaN
+cpsx223 copysign sNaN -34 -> -sNaN
+cpsx224 copysign -sNaN -34 -> -sNaN
+
+-- NaNs, non-0 payload
+cpsx231 copysign NaN10 -34 -> -NaN10
+cpsx232 copysign -NaN10 -34 -> -NaN10
+cpsx233 copysign sNaN10 -34 -> -sNaN10
+cpsx234 copysign -sNaN10 -34 -> -sNaN10
+cpsx235 copysign NaN7 -34 -> -NaN7
+cpsx236 copysign -NaN7 -34 -> -NaN7
+cpsx237 copysign sNaN101 -34 -> -sNaN101
+cpsx238 copysign -sNaN101 -34 -> -sNaN101
+
+-- finites
+cpsx301 copysign 7 -34 -> -7
+cpsx302 copysign -7 -34 -> -7
+cpsx303 copysign 75 -34 -> -75
+cpsx304 copysign -75 -34 -> -75
+cpsx305 copysign 7.50 -34 -> -7.50
+cpsx306 copysign -7.50 -34 -> -7.50
+cpsx307 copysign 7.500 -34 -> -7.500
+cpsx308 copysign -7.500 -34 -> -7.500
+
+-- zeros
+cpsx311 copysign 0 -34 -> -0
+cpsx312 copysign -0 -34 -> -0
+cpsx313 copysign 0E+4 -34 -> -0E+4
+cpsx314 copysign -0E+4 -34 -> -0E+4
+cpsx315 copysign 0.0000 -34 -> -0.0000
+cpsx316 copysign -0.0000 -34 -> -0.0000
+cpsx317 copysign 0E-141 -34 -> -0E-141
+cpsx318 copysign -0E-141 -34 -> -0E-141
+
+-- full coefficients, alternating bits
+cpsx321 copysign 268268268 -18 -> -268268268
+cpsx322 copysign -268268268 -18 -> -268268268
+cpsx323 copysign 134134134 -18 -> -134134134
+cpsx324 copysign -134134134 -18 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+cpsx331 copysign 9.99999999E+999 -18 -> -9.99999999E+999
+cpsx332 copysign 1E-999 -18 -> -1E-999
+cpsx333 copysign 1.00000000E-999 -18 -> -1.00000000E-999
+cpsx334 copysign 1E-1007 -18 -> -1E-1007
+
+cpsx335 copysign -1E-1007 -18 -> -1E-1007
+cpsx336 copysign -1.00000000E-999 -18 -> -1.00000000E-999
+cpsx337 copysign -1E-999 -18 -> -1E-999
+cpsx338 copysign -9.99999999E+999 -18 -> -9.99999999E+999
+
+-- Other kinds of RHS
+cpsx401 copysign 701 -34 -> -701
+cpsx402 copysign -720 -34 -> -720
+cpsx403 copysign 701 -0 -> -701
+cpsx404 copysign -720 -0 -> -720
+cpsx405 copysign 701 +0 -> 701
+cpsx406 copysign -720 +0 -> 720
+cpsx407 copysign 701 +34 -> 701
+cpsx408 copysign -720 +34 -> 720
+
+cpsx413 copysign 701 -Inf -> -701
+cpsx414 copysign -720 -Inf -> -720
+cpsx415 copysign 701 +Inf -> 701
+cpsx416 copysign -720 +Inf -> 720
+
+cpsx420 copysign 701 -NaN -> -701
+cpsx421 copysign -720 -NaN -> -720
+cpsx422 copysign 701 +NaN -> 701
+cpsx423 copysign -720 +NaN -> 720
+cpsx425 copysign -720 +NaN8 -> 720
+
+cpsx426 copysign 701 -sNaN -> -701
+cpsx427 copysign -720 -sNaN -> -720
+cpsx428 copysign 701 +sNaN -> 701
+cpsx429 copysign -720 +sNaN -> 720
+cpsx430 copysign -720 +sNaN3 -> 720
+
diff --git a/Lib/test/decimaltestdata/ddAbs.decTest b/Lib/test/decimaltestdata/ddAbs.decTest
index b98d64a11a..c6f5a7cda3 100644
--- a/Lib/test/decimaltestdata/ddAbs.decTest
+++ b/Lib/test/decimaltestdata/ddAbs.decTest
@@ -1,126 +1,126 @@
-------------------------------------------------------------------------
--- ddAbs.decTest -- decDouble absolute value, heeding sNaN --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddabs001 abs '1' -> '1'
-ddabs002 abs '-1' -> '1'
-ddabs003 abs '1.00' -> '1.00'
-ddabs004 abs '-1.00' -> '1.00'
-ddabs005 abs '0' -> '0'
-ddabs006 abs '0.00' -> '0.00'
-ddabs007 abs '00.0' -> '0.0'
-ddabs008 abs '00.00' -> '0.00'
-ddabs009 abs '00' -> '0'
-
-ddabs010 abs '-2' -> '2'
-ddabs011 abs '2' -> '2'
-ddabs012 abs '-2.00' -> '2.00'
-ddabs013 abs '2.00' -> '2.00'
-ddabs014 abs '-0' -> '0'
-ddabs015 abs '-0.00' -> '0.00'
-ddabs016 abs '-00.0' -> '0.0'
-ddabs017 abs '-00.00' -> '0.00'
-ddabs018 abs '-00' -> '0'
-
-ddabs020 abs '-2000000' -> '2000000'
-ddabs021 abs '2000000' -> '2000000'
-
-ddabs030 abs '+0.1' -> '0.1'
-ddabs031 abs '-0.1' -> '0.1'
-ddabs032 abs '+0.01' -> '0.01'
-ddabs033 abs '-0.01' -> '0.01'
-ddabs034 abs '+0.001' -> '0.001'
-ddabs035 abs '-0.001' -> '0.001'
-ddabs036 abs '+0.000001' -> '0.000001'
-ddabs037 abs '-0.000001' -> '0.000001'
-ddabs038 abs '+0.000000000001' -> '1E-12'
-ddabs039 abs '-0.000000000001' -> '1E-12'
-
--- examples from decArith
-ddabs040 abs '2.1' -> '2.1'
-ddabs041 abs '-100' -> '100'
-ddabs042 abs '101.5' -> '101.5'
-ddabs043 abs '-101.5' -> '101.5'
-
--- more fixed, potential LHS swaps/overlays if done by subtract 0
-ddabs060 abs '-56267E-10' -> '0.0000056267'
-ddabs061 abs '-56267E-5' -> '0.56267'
-ddabs062 abs '-56267E-2' -> '562.67'
-ddabs063 abs '-56267E-1' -> '5626.7'
-ddabs065 abs '-56267E-0' -> '56267'
-
--- subnormals and underflow
-
--- long operand tests
-ddabs321 abs 1234567890123456 -> 1234567890123456
-ddabs322 abs 12345678000 -> 12345678000
-ddabs323 abs 1234567800 -> 1234567800
-ddabs324 abs 1234567890 -> 1234567890
-ddabs325 abs 1234567891 -> 1234567891
-ddabs326 abs 12345678901 -> 12345678901
-ddabs327 abs 1234567896 -> 1234567896
-
--- zeros
-ddabs111 abs 0 -> 0
-ddabs112 abs -0 -> 0
-ddabs113 abs 0E+6 -> 0E+6
-ddabs114 abs -0E+6 -> 0E+6
-ddabs115 abs 0.0000 -> 0.0000
-ddabs116 abs -0.0000 -> 0.0000
-ddabs117 abs 0E-141 -> 0E-141
-ddabs118 abs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddabs121 abs 2682682682682682 -> 2682682682682682
-ddabs122 abs -2682682682682682 -> 2682682682682682
-ddabs123 abs 1341341341341341 -> 1341341341341341
-ddabs124 abs -1341341341341341 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddabs131 abs 9.999999999999999E+384 -> 9.999999999999999E+384
-ddabs132 abs 1E-383 -> 1E-383
-ddabs133 abs 1.000000000000000E-383 -> 1.000000000000000E-383
-ddabs134 abs 1E-398 -> 1E-398 Subnormal
-
-ddabs135 abs -1E-398 -> 1E-398 Subnormal
-ddabs136 abs -1.000000000000000E-383 -> 1.000000000000000E-383
-ddabs137 abs -1E-383 -> 1E-383
-ddabs138 abs -9.999999999999999E+384 -> 9.999999999999999E+384
-
--- specials
-ddabs520 abs 'Inf' -> 'Infinity'
-ddabs521 abs '-Inf' -> 'Infinity'
-ddabs522 abs NaN -> NaN
-ddabs523 abs sNaN -> NaN Invalid_operation
-ddabs524 abs NaN22 -> NaN22
-ddabs525 abs sNaN33 -> NaN33 Invalid_operation
-ddabs526 abs -NaN22 -> -NaN22
-ddabs527 abs -sNaN33 -> -NaN33 Invalid_operation
-
--- Null tests
-ddabs900 abs # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddAbs.decTest -- decDouble absolute value, heeding sNaN --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddabs001 abs '1' -> '1'
+ddabs002 abs '-1' -> '1'
+ddabs003 abs '1.00' -> '1.00'
+ddabs004 abs '-1.00' -> '1.00'
+ddabs005 abs '0' -> '0'
+ddabs006 abs '0.00' -> '0.00'
+ddabs007 abs '00.0' -> '0.0'
+ddabs008 abs '00.00' -> '0.00'
+ddabs009 abs '00' -> '0'
+
+ddabs010 abs '-2' -> '2'
+ddabs011 abs '2' -> '2'
+ddabs012 abs '-2.00' -> '2.00'
+ddabs013 abs '2.00' -> '2.00'
+ddabs014 abs '-0' -> '0'
+ddabs015 abs '-0.00' -> '0.00'
+ddabs016 abs '-00.0' -> '0.0'
+ddabs017 abs '-00.00' -> '0.00'
+ddabs018 abs '-00' -> '0'
+
+ddabs020 abs '-2000000' -> '2000000'
+ddabs021 abs '2000000' -> '2000000'
+
+ddabs030 abs '+0.1' -> '0.1'
+ddabs031 abs '-0.1' -> '0.1'
+ddabs032 abs '+0.01' -> '0.01'
+ddabs033 abs '-0.01' -> '0.01'
+ddabs034 abs '+0.001' -> '0.001'
+ddabs035 abs '-0.001' -> '0.001'
+ddabs036 abs '+0.000001' -> '0.000001'
+ddabs037 abs '-0.000001' -> '0.000001'
+ddabs038 abs '+0.000000000001' -> '1E-12'
+ddabs039 abs '-0.000000000001' -> '1E-12'
+
+-- examples from decArith
+ddabs040 abs '2.1' -> '2.1'
+ddabs041 abs '-100' -> '100'
+ddabs042 abs '101.5' -> '101.5'
+ddabs043 abs '-101.5' -> '101.5'
+
+-- more fixed, potential LHS swaps/overlays if done by subtract 0
+ddabs060 abs '-56267E-10' -> '0.0000056267'
+ddabs061 abs '-56267E-5' -> '0.56267'
+ddabs062 abs '-56267E-2' -> '562.67'
+ddabs063 abs '-56267E-1' -> '5626.7'
+ddabs065 abs '-56267E-0' -> '56267'
+
+-- subnormals and underflow
+
+-- long operand tests
+ddabs321 abs 1234567890123456 -> 1234567890123456
+ddabs322 abs 12345678000 -> 12345678000
+ddabs323 abs 1234567800 -> 1234567800
+ddabs324 abs 1234567890 -> 1234567890
+ddabs325 abs 1234567891 -> 1234567891
+ddabs326 abs 12345678901 -> 12345678901
+ddabs327 abs 1234567896 -> 1234567896
+
+-- zeros
+ddabs111 abs 0 -> 0
+ddabs112 abs -0 -> 0
+ddabs113 abs 0E+6 -> 0E+6
+ddabs114 abs -0E+6 -> 0E+6
+ddabs115 abs 0.0000 -> 0.0000
+ddabs116 abs -0.0000 -> 0.0000
+ddabs117 abs 0E-141 -> 0E-141
+ddabs118 abs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddabs121 abs 2682682682682682 -> 2682682682682682
+ddabs122 abs -2682682682682682 -> 2682682682682682
+ddabs123 abs 1341341341341341 -> 1341341341341341
+ddabs124 abs -1341341341341341 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddabs131 abs 9.999999999999999E+384 -> 9.999999999999999E+384
+ddabs132 abs 1E-383 -> 1E-383
+ddabs133 abs 1.000000000000000E-383 -> 1.000000000000000E-383
+ddabs134 abs 1E-398 -> 1E-398 Subnormal
+
+ddabs135 abs -1E-398 -> 1E-398 Subnormal
+ddabs136 abs -1.000000000000000E-383 -> 1.000000000000000E-383
+ddabs137 abs -1E-383 -> 1E-383
+ddabs138 abs -9.999999999999999E+384 -> 9.999999999999999E+384
+
+-- specials
+ddabs520 abs 'Inf' -> 'Infinity'
+ddabs521 abs '-Inf' -> 'Infinity'
+ddabs522 abs NaN -> NaN
+ddabs523 abs sNaN -> NaN Invalid_operation
+ddabs524 abs NaN22 -> NaN22
+ddabs525 abs sNaN33 -> NaN33 Invalid_operation
+ddabs526 abs -NaN22 -> -NaN22
+ddabs527 abs -sNaN33 -> -NaN33 Invalid_operation
+
+-- Null tests
+ddabs900 abs # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddAdd.decTest b/Lib/test/decimaltestdata/ddAdd.decTest
index 0f12ce4445..c0a25b3413 100644
--- a/Lib/test/decimaltestdata/ddAdd.decTest
+++ b/Lib/test/decimaltestdata/ddAdd.decTest
@@ -1,1328 +1,1328 @@
-------------------------------------------------------------------------
--- ddAdd.decTest -- decDouble addition --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decDoubles only; all arguments are
--- representable in a decDouble
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- [first group are 'quick confidence check']
-ddadd001 add 1 1 -> 2
-ddadd002 add 2 3 -> 5
-ddadd003 add '5.75' '3.3' -> 9.05
-ddadd004 add '5' '-3' -> 2
-ddadd005 add '-5' '-3' -> -8
-ddadd006 add '-7' '2.5' -> -4.5
-ddadd007 add '0.7' '0.3' -> 1.0
-ddadd008 add '1.25' '1.25' -> 2.50
-ddadd009 add '1.23456789' '1.00000000' -> '2.23456789'
-ddadd010 add '1.23456789' '1.00000011' -> '2.23456800'
-
--- 1234567890123456 1234567890123456
-ddadd011 add '0.4444444444444446' '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
-ddadd012 add '0.4444444444444445' '0.5555555555555555' -> '1.000000000000000' Rounded
-ddadd013 add '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
-ddadd014 add '4444444444444444' '0.49' -> '4444444444444444' Inexact Rounded
-ddadd015 add '4444444444444444' '0.499' -> '4444444444444444' Inexact Rounded
-ddadd016 add '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
-ddadd017 add '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
-ddadd018 add '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
-ddadd019 add '4444444444444444' '0.501' -> '4444444444444445' Inexact Rounded
-ddadd020 add '4444444444444444' '0.51' -> '4444444444444445' Inexact Rounded
-
-ddadd021 add 0 1 -> 1
-ddadd022 add 1 1 -> 2
-ddadd023 add 2 1 -> 3
-ddadd024 add 3 1 -> 4
-ddadd025 add 4 1 -> 5
-ddadd026 add 5 1 -> 6
-ddadd027 add 6 1 -> 7
-ddadd028 add 7 1 -> 8
-ddadd029 add 8 1 -> 9
-ddadd030 add 9 1 -> 10
-
--- some carrying effects
-ddadd031 add '0.9998' '0.0000' -> '0.9998'
-ddadd032 add '0.9998' '0.0001' -> '0.9999'
-ddadd033 add '0.9998' '0.0002' -> '1.0000'
-ddadd034 add '0.9998' '0.0003' -> '1.0001'
-
-ddadd035 add '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddadd036 add '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddadd037 add '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddadd038 add '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
-ddadd039 add '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
-
--- symmetry:
-ddadd040 add '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
-ddadd041 add '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
-ddadd042 add '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
-ddadd044 add '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
-ddadd045 add '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
-
--- same, without rounding
-ddadd046 add '10000e+9' '7' -> '10000000000007'
-ddadd047 add '10000e+9' '70' -> '10000000000070'
-ddadd048 add '10000e+9' '700' -> '10000000000700'
-ddadd049 add '10000e+9' '7000' -> '10000000007000'
-ddadd050 add '10000e+9' '70000' -> '10000000070000'
-ddadd051 add '10000e+9' '700000' -> '10000000700000'
-ddadd052 add '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-ddadd053 add '12' '7.00' -> '19.00'
-ddadd054 add '1.3' '-1.07' -> '0.23'
-ddadd055 add '1.3' '-1.30' -> '0.00'
-ddadd056 add '1.3' '-2.07' -> '-0.77'
-ddadd057 add '1E+2' '1E+4' -> '1.01E+4'
-
--- leading zero preservation
-ddadd061 add 1 '0.0001' -> '1.0001'
-ddadd062 add 1 '0.00001' -> '1.00001'
-ddadd063 add 1 '0.000001' -> '1.000001'
-ddadd064 add 1 '0.0000001' -> '1.0000001'
-ddadd065 add 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-ddadd070 add 1 0 -> 1
-ddadd071 add 1 0. -> 1
-ddadd072 add 1 .0 -> 1.0
-ddadd073 add 1 0.0 -> 1.0
-ddadd074 add 1 0.00 -> 1.00
-ddadd075 add 0 1 -> 1
-ddadd076 add 0. 1 -> 1
-ddadd077 add .0 1 -> 1.0
-ddadd078 add 0.0 1 -> 1.0
-ddadd079 add 0.00 1 -> 1.00
-
--- some carries
-ddadd080 add 999999998 1 -> 999999999
-ddadd081 add 999999999 1 -> 1000000000
-ddadd082 add 99999999 1 -> 100000000
-ddadd083 add 9999999 1 -> 10000000
-ddadd084 add 999999 1 -> 1000000
-ddadd085 add 99999 1 -> 100000
-ddadd086 add 9999 1 -> 10000
-ddadd087 add 999 1 -> 1000
-ddadd088 add 99 1 -> 100
-ddadd089 add 9 1 -> 10
-
-
--- more LHS swaps
-ddadd090 add '-56267E-10' 0 -> '-0.0000056267'
-ddadd091 add '-56267E-6' 0 -> '-0.056267'
-ddadd092 add '-56267E-5' 0 -> '-0.56267'
-ddadd093 add '-56267E-4' 0 -> '-5.6267'
-ddadd094 add '-56267E-3' 0 -> '-56.267'
-ddadd095 add '-56267E-2' 0 -> '-562.67'
-ddadd096 add '-56267E-1' 0 -> '-5626.7'
-ddadd097 add '-56267E-0' 0 -> '-56267'
-ddadd098 add '-5E-10' 0 -> '-5E-10'
-ddadd099 add '-5E-7' 0 -> '-5E-7'
-ddadd100 add '-5E-6' 0 -> '-0.000005'
-ddadd101 add '-5E-5' 0 -> '-0.00005'
-ddadd102 add '-5E-4' 0 -> '-0.0005'
-ddadd103 add '-5E-1' 0 -> '-0.5'
-ddadd104 add '-5E0' 0 -> '-5'
-ddadd105 add '-5E1' 0 -> '-50'
-ddadd106 add '-5E5' 0 -> '-500000'
-ddadd107 add '-5E15' 0 -> '-5000000000000000'
-ddadd108 add '-5E16' 0 -> '-5.000000000000000E+16' Rounded
-ddadd109 add '-5E17' 0 -> '-5.000000000000000E+17' Rounded
-ddadd110 add '-5E18' 0 -> '-5.000000000000000E+18' Rounded
-ddadd111 add '-5E100' 0 -> '-5.000000000000000E+100' Rounded
-
--- more RHS swaps
-ddadd113 add 0 '-56267E-10' -> '-0.0000056267'
-ddadd114 add 0 '-56267E-6' -> '-0.056267'
-ddadd116 add 0 '-56267E-5' -> '-0.56267'
-ddadd117 add 0 '-56267E-4' -> '-5.6267'
-ddadd119 add 0 '-56267E-3' -> '-56.267'
-ddadd120 add 0 '-56267E-2' -> '-562.67'
-ddadd121 add 0 '-56267E-1' -> '-5626.7'
-ddadd122 add 0 '-56267E-0' -> '-56267'
-ddadd123 add 0 '-5E-10' -> '-5E-10'
-ddadd124 add 0 '-5E-7' -> '-5E-7'
-ddadd125 add 0 '-5E-6' -> '-0.000005'
-ddadd126 add 0 '-5E-5' -> '-0.00005'
-ddadd127 add 0 '-5E-4' -> '-0.0005'
-ddadd128 add 0 '-5E-1' -> '-0.5'
-ddadd129 add 0 '-5E0' -> '-5'
-ddadd130 add 0 '-5E1' -> '-50'
-ddadd131 add 0 '-5E5' -> '-500000'
-ddadd132 add 0 '-5E15' -> '-5000000000000000'
-ddadd133 add 0 '-5E16' -> '-5.000000000000000E+16' Rounded
-ddadd134 add 0 '-5E17' -> '-5.000000000000000E+17' Rounded
-ddadd135 add 0 '-5E18' -> '-5.000000000000000E+18' Rounded
-ddadd136 add 0 '-5E100' -> '-5.000000000000000E+100' Rounded
-
--- related
-ddadd137 add 1 '0E-19' -> '1.000000000000000' Rounded
-ddadd138 add -1 '0E-19' -> '-1.000000000000000' Rounded
-ddadd139 add '0E-19' 1 -> '1.000000000000000' Rounded
-ddadd140 add '0E-19' -1 -> '-1.000000000000000' Rounded
-ddadd141 add 1E+11 0.0000 -> '100000000000.0000'
-ddadd142 add 1E+11 0.00000 -> '100000000000.0000' Rounded
-ddadd143 add 0.000 1E+12 -> '1000000000000.000'
-ddadd144 add 0.0000 1E+12 -> '1000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-ddadd146 add '00.0' 0 -> '0.0'
-ddadd147 add '0.00' 0 -> '0.00'
-ddadd148 add 0 '0.00' -> '0.00'
-ddadd149 add 0 '00.0' -> '0.0'
-ddadd150 add '00.0' '0.00' -> '0.00'
-ddadd151 add '0.00' '00.0' -> '0.00'
-ddadd152 add '3' '.3' -> '3.3'
-ddadd153 add '3.' '.3' -> '3.3'
-ddadd154 add '3.0' '.3' -> '3.3'
-ddadd155 add '3.00' '.3' -> '3.30'
-ddadd156 add '3' '3' -> '6'
-ddadd157 add '3' '+3' -> '6'
-ddadd158 add '3' '-3' -> '0'
-ddadd159 add '0.3' '-0.3' -> '0.0'
-ddadd160 add '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-ddadd161 add '1E+12' '-1' -> '999999999999'
-ddadd162 add '1E+12' '1.11' -> '1000000000001.11'
-ddadd163 add '1.11' '1E+12' -> '1000000000001.11'
-ddadd164 add '-1' '1E+12' -> '999999999999'
-ddadd165 add '7E+12' '-1' -> '6999999999999'
-ddadd166 add '7E+12' '1.11' -> '7000000000001.11'
-ddadd167 add '1.11' '7E+12' -> '7000000000001.11'
-ddadd168 add '-1' '7E+12' -> '6999999999999'
-
-rounding: half_up
--- 1.234567890123456 1234567890123456 1 234567890123456
-ddadd170 add '4.444444444444444' '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
-ddadd171 add '4.444444444444444' '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
-ddadd172 add '4.444444444444444' '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
-ddadd173 add '4.444444444444444' '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
-ddadd174 add '4.444444444444444' '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
-ddadd175 add '4.444444444444444' '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
-ddadd176 add '4.444444444444444' '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
-ddadd177 add '4.444444444444444' '0.5555555555555550' -> '4.999999999999999' Rounded
-ddadd178 add '4.444444444444444' '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
-ddadd179 add '4.444444444444444' '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
-ddadd180 add '4.444444444444444' '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
-ddadd181 add '4.444444444444444' '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
-ddadd182 add '4.444444444444444' '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
-ddadd183 add '4.444444444444444' '0.5555555555555540' -> '4.999999999999998' Rounded
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-ddadd200 add '1234560123456789' 0 -> '1234560123456789'
-ddadd201 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddadd202 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddadd203 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddadd204 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddadd205 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddadd206 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddadd207 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddadd208 add '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
-ddadd209 add '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
-ddadd210 add '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
-ddadd211 add '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
-ddadd212 add '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
-ddadd213 add '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
-ddadd214 add '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
-ddadd215 add '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
-ddadd216 add '1234560123456789' 1 -> '1234560123456790'
-ddadd217 add '1234560123456789' 1.000000001 -> '1234560123456790' Inexact Rounded
-ddadd218 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddadd219 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
-
-rounding: half_even
-ddadd220 add '1234560123456789' 0 -> '1234560123456789'
-ddadd221 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddadd222 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddadd223 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddadd224 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddadd225 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddadd226 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddadd227 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddadd228 add '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
-ddadd229 add '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
-ddadd230 add '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
-ddadd231 add '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
-ddadd232 add '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
-ddadd233 add '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
-ddadd234 add '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
-ddadd235 add '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
-ddadd236 add '1234560123456789' 1 -> '1234560123456790'
-ddadd237 add '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
-ddadd238 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddadd239 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
--- critical few with even bottom digit...
-ddadd240 add '1234560123456788' 0.499999999 -> '1234560123456788' Inexact Rounded
-ddadd241 add '1234560123456788' 0.5 -> '1234560123456788' Inexact Rounded
-ddadd242 add '1234560123456788' 0.500000001 -> '1234560123456789' Inexact Rounded
-
-rounding: down
-ddadd250 add '1234560123456789' 0 -> '1234560123456789'
-ddadd251 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddadd252 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddadd253 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddadd254 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddadd255 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddadd256 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddadd257 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddadd258 add '1234560123456789' 0.5 -> '1234560123456789' Inexact Rounded
-ddadd259 add '1234560123456789' 0.500000001 -> '1234560123456789' Inexact Rounded
-ddadd260 add '1234560123456789' 0.500001 -> '1234560123456789' Inexact Rounded
-ddadd261 add '1234560123456789' 0.51 -> '1234560123456789' Inexact Rounded
-ddadd262 add '1234560123456789' 0.6 -> '1234560123456789' Inexact Rounded
-ddadd263 add '1234560123456789' 0.9 -> '1234560123456789' Inexact Rounded
-ddadd264 add '1234560123456789' 0.99999 -> '1234560123456789' Inexact Rounded
-ddadd265 add '1234560123456789' 0.999999999 -> '1234560123456789' Inexact Rounded
-ddadd266 add '1234560123456789' 1 -> '1234560123456790'
-ddadd267 add '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
-ddadd268 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddadd269 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-ddadd301 add -1 1 -> 0
-ddadd302 add 0 1 -> 1
-ddadd303 add 1 1 -> 2
-ddadd304 add 12 1 -> 13
-ddadd305 add 98 1 -> 99
-ddadd306 add 99 1 -> 100
-ddadd307 add 100 1 -> 101
-ddadd308 add 101 1 -> 102
-ddadd309 add -1 -1 -> -2
-ddadd310 add 0 -1 -> -1
-ddadd311 add 1 -1 -> 0
-ddadd312 add 12 -1 -> 11
-ddadd313 add 98 -1 -> 97
-ddadd314 add 99 -1 -> 98
-ddadd315 add 100 -1 -> 99
-ddadd316 add 101 -1 -> 100
-
-ddadd321 add -0.01 0.01 -> 0.00
-ddadd322 add 0.00 0.01 -> 0.01
-ddadd323 add 0.01 0.01 -> 0.02
-ddadd324 add 0.12 0.01 -> 0.13
-ddadd325 add 0.98 0.01 -> 0.99
-ddadd326 add 0.99 0.01 -> 1.00
-ddadd327 add 1.00 0.01 -> 1.01
-ddadd328 add 1.01 0.01 -> 1.02
-ddadd329 add -0.01 -0.01 -> -0.02
-ddadd330 add 0.00 -0.01 -> -0.01
-ddadd331 add 0.01 -0.01 -> 0.00
-ddadd332 add 0.12 -0.01 -> 0.11
-ddadd333 add 0.98 -0.01 -> 0.97
-ddadd334 add 0.99 -0.01 -> 0.98
-ddadd335 add 1.00 -0.01 -> 0.99
-ddadd336 add 1.01 -0.01 -> 1.00
-
--- some more cases where adding 0 affects the coefficient
-ddadd340 add 1E+3 0 -> 1000
-ddadd341 add 1E+15 0 -> 1000000000000000
-ddadd342 add 1E+16 0 -> 1.000000000000000E+16 Rounded
-ddadd343 add 1E+20 0 -> 1.000000000000000E+20 Rounded
--- which simply follow from these cases ...
-ddadd344 add 1E+3 1 -> 1001
-ddadd345 add 1E+15 1 -> 1000000000000001
-ddadd346 add 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
-ddadd347 add 1E+20 1 -> 1.000000000000000E+20 Inexact Rounded
-ddadd348 add 1E+3 7 -> 1007
-ddadd349 add 1E+15 7 -> 1000000000000007
-ddadd350 add 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
-ddadd351 add 1E+20 7 -> 1.000000000000000E+20 Inexact Rounded
-
--- tryzeros cases
-rounding: half_up
-ddadd360 add 0E+50 10000E+1 -> 1.0000E+5
-ddadd361 add 0E-50 10000E+1 -> 100000.0000000000 Rounded
-ddadd362 add 10000E+1 0E-50 -> 100000.0000000000 Rounded
-ddadd363 add 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
-ddadd364 add 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-ddadd370 add 999999999999999 815 -> 1000000000000814
-ddadd371 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-rounding: half_up
-ddadd372 add 999999999999999 815 -> 1000000000000814
-ddadd373 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-rounding: half_even
-ddadd374 add 999999999999999 815 -> 1000000000000814
-ddadd375 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-
--- operands folded
-ddadd380 add 1E+384 1E+384 -> 2.000000000000000E+384 Clamped
-ddadd381 add 1E+380 1E+380 -> 2.00000000000E+380 Clamped
-ddadd382 add 1E+376 1E+376 -> 2.0000000E+376 Clamped
-ddadd383 add 1E+372 1E+372 -> 2.000E+372 Clamped
-ddadd384 add 1E+370 1E+370 -> 2.0E+370 Clamped
-ddadd385 add 1E+369 1E+369 -> 2E+369
-ddadd386 add 1E+368 1E+368 -> 2E+368
-
--- ulp replacement tests
-ddadd400 add 1 77e-14 -> 1.00000000000077
-ddadd401 add 1 77e-15 -> 1.000000000000077
-ddadd402 add 1 77e-16 -> 1.000000000000008 Inexact Rounded
-ddadd403 add 1 77e-17 -> 1.000000000000001 Inexact Rounded
-ddadd404 add 1 77e-18 -> 1.000000000000000 Inexact Rounded
-ddadd405 add 1 77e-19 -> 1.000000000000000 Inexact Rounded
-ddadd406 add 1 77e-299 -> 1.000000000000000 Inexact Rounded
-
-ddadd410 add 10 77e-14 -> 10.00000000000077
-ddadd411 add 10 77e-15 -> 10.00000000000008 Inexact Rounded
-ddadd412 add 10 77e-16 -> 10.00000000000001 Inexact Rounded
-ddadd413 add 10 77e-17 -> 10.00000000000000 Inexact Rounded
-ddadd414 add 10 77e-18 -> 10.00000000000000 Inexact Rounded
-ddadd415 add 10 77e-19 -> 10.00000000000000 Inexact Rounded
-ddadd416 add 10 77e-299 -> 10.00000000000000 Inexact Rounded
-
-ddadd420 add 77e-14 1 -> 1.00000000000077
-ddadd421 add 77e-15 1 -> 1.000000000000077
-ddadd422 add 77e-16 1 -> 1.000000000000008 Inexact Rounded
-ddadd423 add 77e-17 1 -> 1.000000000000001 Inexact Rounded
-ddadd424 add 77e-18 1 -> 1.000000000000000 Inexact Rounded
-ddadd425 add 77e-19 1 -> 1.000000000000000 Inexact Rounded
-ddadd426 add 77e-299 1 -> 1.000000000000000 Inexact Rounded
-
-ddadd430 add 77e-14 10 -> 10.00000000000077
-ddadd431 add 77e-15 10 -> 10.00000000000008 Inexact Rounded
-ddadd432 add 77e-16 10 -> 10.00000000000001 Inexact Rounded
-ddadd433 add 77e-17 10 -> 10.00000000000000 Inexact Rounded
-ddadd434 add 77e-18 10 -> 10.00000000000000 Inexact Rounded
-ddadd435 add 77e-19 10 -> 10.00000000000000 Inexact Rounded
-ddadd436 add 77e-299 10 -> 10.00000000000000 Inexact Rounded
-
--- fastpath boundary (more in dqadd)
--- 1234567890123456
-ddadd539 add '4444444444444444' '3333333333333333' -> '7777777777777777'
-ddadd540 add '4444444444444444' '4444444444444444' -> '8888888888888888'
-ddadd541 add '4444444444444444' '5555555555555555' -> '9999999999999999'
-ddadd542 add '3333333333333333' '4444444444444444' -> '7777777777777777'
-ddadd543 add '4444444444444444' '4444444444444444' -> '8888888888888888'
-ddadd544 add '5555555555555555' '4444444444444444' -> '9999999999999999'
-ddadd545 add '3000004000000000' '3000000000000040' -> '6000004000000040'
-ddadd546 add '3000000400000000' '4000000000000400' -> '7000000400000400'
-ddadd547 add '3000000040000000' '5000000000004000' -> '8000000040004000'
-ddadd548 add '4000000004000000' '3000000000040000' -> '7000000004040000'
-ddadd549 add '4000000000400000' '4000000000400000' -> '8000000000800000'
-ddadd550 add '4000000000040000' '5000000004000000' -> '9000000004040000'
-ddadd551 add '5000000000004000' '3000000040000000' -> '8000000040004000'
-ddadd552 add '5000000000000400' '4000000400000000' -> '9000000400000400'
-ddadd553 add '5000000000000040' '5000004000000000' -> 1.000000400000004E+16 Rounded
--- check propagation
-ddadd554 add '8999999999999999' '0000000000000001' -> 9000000000000000
-ddadd555 add '0000000000000001' '8999999999999999' -> 9000000000000000
-ddadd556 add '0999999999999999' '0000000000000001' -> 1000000000000000
-ddadd557 add '0000000000000001' '0999999999999999' -> 1000000000000000
-ddadd558 add '4444444444444444' '4555555555555556' -> 9000000000000000
-ddadd559 add '4555555555555556' '4444444444444444' -> 9000000000000000
-
--- negative ulps
-ddadd6440 add 1 -77e-14 -> 0.99999999999923
-ddadd6441 add 1 -77e-15 -> 0.999999999999923
-ddadd6442 add 1 -77e-16 -> 0.9999999999999923
-ddadd6443 add 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
-ddadd6444 add 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
-ddadd6445 add 1 -77e-19 -> 1.000000000000000 Inexact Rounded
-ddadd6446 add 1 -77e-99 -> 1.000000000000000 Inexact Rounded
-
-ddadd6450 add 10 -77e-14 -> 9.99999999999923
-ddadd6451 add 10 -77e-15 -> 9.999999999999923
-ddadd6452 add 10 -77e-16 -> 9.999999999999992 Inexact Rounded
-ddadd6453 add 10 -77e-17 -> 9.999999999999999 Inexact Rounded
-ddadd6454 add 10 -77e-18 -> 10.00000000000000 Inexact Rounded
-ddadd6455 add 10 -77e-19 -> 10.00000000000000 Inexact Rounded
-ddadd6456 add 10 -77e-99 -> 10.00000000000000 Inexact Rounded
-
-ddadd6460 add -77e-14 1 -> 0.99999999999923
-ddadd6461 add -77e-15 1 -> 0.999999999999923
-ddadd6462 add -77e-16 1 -> 0.9999999999999923
-ddadd6463 add -77e-17 1 -> 0.9999999999999992 Inexact Rounded
-ddadd6464 add -77e-18 1 -> 0.9999999999999999 Inexact Rounded
-ddadd6465 add -77e-19 1 -> 1.000000000000000 Inexact Rounded
-ddadd6466 add -77e-99 1 -> 1.000000000000000 Inexact Rounded
-
-ddadd6470 add -77e-14 10 -> 9.99999999999923
-ddadd6471 add -77e-15 10 -> 9.999999999999923
-ddadd6472 add -77e-16 10 -> 9.999999999999992 Inexact Rounded
-ddadd6473 add -77e-17 10 -> 9.999999999999999 Inexact Rounded
-ddadd6474 add -77e-18 10 -> 10.00000000000000 Inexact Rounded
-ddadd6475 add -77e-19 10 -> 10.00000000000000 Inexact Rounded
-ddadd6476 add -77e-99 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-ddadd6480 add -1 77e-14 -> -0.99999999999923
-ddadd6481 add -1 77e-15 -> -0.999999999999923
-ddadd6482 add -1 77e-16 -> -0.9999999999999923
-ddadd6483 add -1 77e-17 -> -0.9999999999999992 Inexact Rounded
-ddadd6484 add -1 77e-18 -> -0.9999999999999999 Inexact Rounded
-ddadd6485 add -1 77e-19 -> -1.000000000000000 Inexact Rounded
-ddadd6486 add -1 77e-99 -> -1.000000000000000 Inexact Rounded
-
-ddadd6490 add -10 77e-14 -> -9.99999999999923
-ddadd6491 add -10 77e-15 -> -9.999999999999923
-ddadd6492 add -10 77e-16 -> -9.999999999999992 Inexact Rounded
-ddadd6493 add -10 77e-17 -> -9.999999999999999 Inexact Rounded
-ddadd6494 add -10 77e-18 -> -10.00000000000000 Inexact Rounded
-ddadd6495 add -10 77e-19 -> -10.00000000000000 Inexact Rounded
-ddadd6496 add -10 77e-99 -> -10.00000000000000 Inexact Rounded
-
-ddadd6500 add 77e-14 -1 -> -0.99999999999923
-ddadd6501 add 77e-15 -1 -> -0.999999999999923
-ddadd6502 add 77e-16 -1 -> -0.9999999999999923
-ddadd6503 add 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
-ddadd6504 add 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
-ddadd6505 add 77e-19 -1 -> -1.000000000000000 Inexact Rounded
-ddadd6506 add 77e-99 -1 -> -1.000000000000000 Inexact Rounded
-
-ddadd6510 add 77e-14 -10 -> -9.99999999999923
-ddadd6511 add 77e-15 -10 -> -9.999999999999923
-ddadd6512 add 77e-16 -10 -> -9.999999999999992 Inexact Rounded
-ddadd6513 add 77e-17 -10 -> -9.999999999999999 Inexact Rounded
-ddadd6514 add 77e-18 -10 -> -10.00000000000000 Inexact Rounded
-ddadd6515 add 77e-19 -10 -> -10.00000000000000 Inexact Rounded
-ddadd6516 add 77e-99 -10 -> -10.00000000000000 Inexact Rounded
-
--- and some more residue effects and different roundings
-rounding: half_up
-ddadd6540 add '6543210123456789' 0 -> '6543210123456789'
-ddadd6541 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddadd6542 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddadd6543 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddadd6544 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddadd6545 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddadd6546 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddadd6547 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddadd6548 add '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-ddadd6549 add '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-ddadd6550 add '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-ddadd6551 add '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-ddadd6552 add '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-ddadd6553 add '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-ddadd6554 add '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-ddadd6555 add '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
-ddadd6556 add '6543210123456789' 1 -> '6543210123456790'
-ddadd6557 add '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
-ddadd6558 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddadd6559 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
-rounding: half_even
-ddadd6560 add '6543210123456789' 0 -> '6543210123456789'
-ddadd6561 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddadd6562 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddadd6563 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddadd6564 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddadd6565 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddadd6566 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddadd6567 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddadd6568 add '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-ddadd6569 add '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-ddadd6570 add '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-ddadd6571 add '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-ddadd6572 add '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-ddadd6573 add '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-ddadd6574 add '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-ddadd6575 add '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
-ddadd6576 add '6543210123456789' 1 -> '6543210123456790'
-ddadd6577 add '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-ddadd6578 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddadd6579 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
--- critical few with even bottom digit...
-ddadd7540 add '6543210123456788' 0.499999999 -> '6543210123456788' Inexact Rounded
-ddadd7541 add '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
-ddadd7542 add '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
-
-rounding: down
-ddadd7550 add '6543210123456789' 0 -> '6543210123456789'
-ddadd7551 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddadd7552 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddadd7553 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddadd7554 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddadd7555 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddadd7556 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddadd7557 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddadd7558 add '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
-ddadd7559 add '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
-ddadd7560 add '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
-ddadd7561 add '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
-ddadd7562 add '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
-ddadd7563 add '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
-ddadd7564 add '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
-ddadd7565 add '6543210123456789' 0.999999999 -> '6543210123456789' Inexact Rounded
-ddadd7566 add '6543210123456789' 1 -> '6543210123456790'
-ddadd7567 add '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-ddadd7568 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddadd7569 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
--- verify a query
-rounding: down
-ddadd7661 add 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
-ddadd7662 add 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
-ddadd7663 add 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
-ddadd7664 add 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-ddadd7701 add 5.00 1.00E-3 -> 5.00100
-ddadd7702 add 00.00 0.000 -> 0.000
-ddadd7703 add 00.00 0E-3 -> 0.000
-ddadd7704 add 0E-3 00.00 -> 0.000
-
-ddadd7710 add 0E+3 00.00 -> 0.00
-ddadd7711 add 0E+3 00.0 -> 0.0
-ddadd7712 add 0E+3 00. -> 0
-ddadd7713 add 0E+3 00.E+1 -> 0E+1
-ddadd7714 add 0E+3 00.E+2 -> 0E+2
-ddadd7715 add 0E+3 00.E+3 -> 0E+3
-ddadd7716 add 0E+3 00.E+4 -> 0E+3
-ddadd7717 add 0E+3 00.E+5 -> 0E+3
-ddadd7718 add 0E+3 -00.0 -> 0.0
-ddadd7719 add 0E+3 -00. -> 0
-ddadd7731 add 0E+3 -00.E+1 -> 0E+1
-
-ddadd7720 add 00.00 0E+3 -> 0.00
-ddadd7721 add 00.0 0E+3 -> 0.0
-ddadd7722 add 00. 0E+3 -> 0
-ddadd7723 add 00.E+1 0E+3 -> 0E+1
-ddadd7724 add 00.E+2 0E+3 -> 0E+2
-ddadd7725 add 00.E+3 0E+3 -> 0E+3
-ddadd7726 add 00.E+4 0E+3 -> 0E+3
-ddadd7727 add 00.E+5 0E+3 -> 0E+3
-ddadd7728 add -00.00 0E+3 -> 0.00
-ddadd7729 add -00.0 0E+3 -> 0.0
-ddadd7730 add -00. 0E+3 -> 0
-
-ddadd7732 add 0 0 -> 0
-ddadd7733 add 0 -0 -> 0
-ddadd7734 add -0 0 -> 0
-ddadd7735 add -0 -0 -> -0 -- IEEE 854 special case
-
-ddadd7736 add 1 -1 -> 0
-ddadd7737 add -1 -1 -> -2
-ddadd7738 add 1 1 -> 2
-ddadd7739 add -1 1 -> 0
-
-ddadd7741 add 0 -1 -> -1
-ddadd7742 add -0 -1 -> -1
-ddadd7743 add 0 1 -> 1
-ddadd7744 add -0 1 -> 1
-ddadd7745 add -1 0 -> -1
-ddadd7746 add -1 -0 -> -1
-ddadd7747 add 1 0 -> 1
-ddadd7748 add 1 -0 -> 1
-
-ddadd7751 add 0.0 -1 -> -1.0
-ddadd7752 add -0.0 -1 -> -1.0
-ddadd7753 add 0.0 1 -> 1.0
-ddadd7754 add -0.0 1 -> 1.0
-ddadd7755 add -1.0 0 -> -1.0
-ddadd7756 add -1.0 -0 -> -1.0
-ddadd7757 add 1.0 0 -> 1.0
-ddadd7758 add 1.0 -0 -> 1.0
-
-ddadd7761 add 0 -1.0 -> -1.0
-ddadd7762 add -0 -1.0 -> -1.0
-ddadd7763 add 0 1.0 -> 1.0
-ddadd7764 add -0 1.0 -> 1.0
-ddadd7765 add -1 0.0 -> -1.0
-ddadd7766 add -1 -0.0 -> -1.0
-ddadd7767 add 1 0.0 -> 1.0
-ddadd7768 add 1 -0.0 -> 1.0
-
-ddadd7771 add 0.0 -1.0 -> -1.0
-ddadd7772 add -0.0 -1.0 -> -1.0
-ddadd7773 add 0.0 1.0 -> 1.0
-ddadd7774 add -0.0 1.0 -> 1.0
-ddadd7775 add -1.0 0.0 -> -1.0
-ddadd7776 add -1.0 -0.0 -> -1.0
-ddadd7777 add 1.0 0.0 -> 1.0
-ddadd7778 add 1.0 -0.0 -> 1.0
-
--- Specials
-ddadd7780 add -Inf -Inf -> -Infinity
-ddadd7781 add -Inf -1000 -> -Infinity
-ddadd7782 add -Inf -1 -> -Infinity
-ddadd7783 add -Inf -0 -> -Infinity
-ddadd7784 add -Inf 0 -> -Infinity
-ddadd7785 add -Inf 1 -> -Infinity
-ddadd7786 add -Inf 1000 -> -Infinity
-ddadd7787 add -1000 -Inf -> -Infinity
-ddadd7788 add -Inf -Inf -> -Infinity
-ddadd7789 add -1 -Inf -> -Infinity
-ddadd7790 add -0 -Inf -> -Infinity
-ddadd7791 add 0 -Inf -> -Infinity
-ddadd7792 add 1 -Inf -> -Infinity
-ddadd7793 add 1000 -Inf -> -Infinity
-ddadd7794 add Inf -Inf -> NaN Invalid_operation
-
-ddadd7800 add Inf -Inf -> NaN Invalid_operation
-ddadd7801 add Inf -1000 -> Infinity
-ddadd7802 add Inf -1 -> Infinity
-ddadd7803 add Inf -0 -> Infinity
-ddadd7804 add Inf 0 -> Infinity
-ddadd7805 add Inf 1 -> Infinity
-ddadd7806 add Inf 1000 -> Infinity
-ddadd7807 add Inf Inf -> Infinity
-ddadd7808 add -1000 Inf -> Infinity
-ddadd7809 add -Inf Inf -> NaN Invalid_operation
-ddadd7810 add -1 Inf -> Infinity
-ddadd7811 add -0 Inf -> Infinity
-ddadd7812 add 0 Inf -> Infinity
-ddadd7813 add 1 Inf -> Infinity
-ddadd7814 add 1000 Inf -> Infinity
-ddadd7815 add Inf Inf -> Infinity
-
-ddadd7821 add NaN -Inf -> NaN
-ddadd7822 add NaN -1000 -> NaN
-ddadd7823 add NaN -1 -> NaN
-ddadd7824 add NaN -0 -> NaN
-ddadd7825 add NaN 0 -> NaN
-ddadd7826 add NaN 1 -> NaN
-ddadd7827 add NaN 1000 -> NaN
-ddadd7828 add NaN Inf -> NaN
-ddadd7829 add NaN NaN -> NaN
-ddadd7830 add -Inf NaN -> NaN
-ddadd7831 add -1000 NaN -> NaN
-ddadd7832 add -1 NaN -> NaN
-ddadd7833 add -0 NaN -> NaN
-ddadd7834 add 0 NaN -> NaN
-ddadd7835 add 1 NaN -> NaN
-ddadd7836 add 1000 NaN -> NaN
-ddadd7837 add Inf NaN -> NaN
-
-ddadd7841 add sNaN -Inf -> NaN Invalid_operation
-ddadd7842 add sNaN -1000 -> NaN Invalid_operation
-ddadd7843 add sNaN -1 -> NaN Invalid_operation
-ddadd7844 add sNaN -0 -> NaN Invalid_operation
-ddadd7845 add sNaN 0 -> NaN Invalid_operation
-ddadd7846 add sNaN 1 -> NaN Invalid_operation
-ddadd7847 add sNaN 1000 -> NaN Invalid_operation
-ddadd7848 add sNaN NaN -> NaN Invalid_operation
-ddadd7849 add sNaN sNaN -> NaN Invalid_operation
-ddadd7850 add NaN sNaN -> NaN Invalid_operation
-ddadd7851 add -Inf sNaN -> NaN Invalid_operation
-ddadd7852 add -1000 sNaN -> NaN Invalid_operation
-ddadd7853 add -1 sNaN -> NaN Invalid_operation
-ddadd7854 add -0 sNaN -> NaN Invalid_operation
-ddadd7855 add 0 sNaN -> NaN Invalid_operation
-ddadd7856 add 1 sNaN -> NaN Invalid_operation
-ddadd7857 add 1000 sNaN -> NaN Invalid_operation
-ddadd7858 add Inf sNaN -> NaN Invalid_operation
-ddadd7859 add NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddadd7861 add NaN1 -Inf -> NaN1
-ddadd7862 add +NaN2 -1000 -> NaN2
-ddadd7863 add NaN3 1000 -> NaN3
-ddadd7864 add NaN4 Inf -> NaN4
-ddadd7865 add NaN5 +NaN6 -> NaN5
-ddadd7866 add -Inf NaN7 -> NaN7
-ddadd7867 add -1000 NaN8 -> NaN8
-ddadd7868 add 1000 NaN9 -> NaN9
-ddadd7869 add Inf +NaN10 -> NaN10
-ddadd7871 add sNaN11 -Inf -> NaN11 Invalid_operation
-ddadd7872 add sNaN12 -1000 -> NaN12 Invalid_operation
-ddadd7873 add sNaN13 1000 -> NaN13 Invalid_operation
-ddadd7874 add sNaN14 NaN17 -> NaN14 Invalid_operation
-ddadd7875 add sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddadd7876 add NaN16 sNaN19 -> NaN19 Invalid_operation
-ddadd7877 add -Inf +sNaN20 -> NaN20 Invalid_operation
-ddadd7878 add -1000 sNaN21 -> NaN21 Invalid_operation
-ddadd7879 add 1000 sNaN22 -> NaN22 Invalid_operation
-ddadd7880 add Inf sNaN23 -> NaN23 Invalid_operation
-ddadd7881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddadd7882 add -NaN26 NaN28 -> -NaN26
-ddadd7883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddadd7884 add 1000 -NaN30 -> -NaN30
-ddadd7885 add 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Here we explore near the boundary of rounding a subnormal to Nmin
-ddadd7575 add 1E-383 -1E-398 -> 9.99999999999999E-384 Subnormal
-ddadd7576 add -1E-383 +1E-398 -> -9.99999999999999E-384 Subnormal
-
--- and another curious case
-ddadd7577 add 7.000000000000E-385 -1.00000E-391 -> 6.999999000000E-385 Subnormal
-
--- check overflow edge case
--- 1234567890123456
-ddadd7972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
-ddadd7973 add 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7974 add 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7975 add 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
-ddadd7976 add 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
-ddadd7977 add 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
-ddadd7978 add 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
-ddadd7979 add 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
-ddadd7980 add 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
-ddadd7981 add 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7982 add 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7983 add 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7984 add 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
-
-ddadd7985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
-ddadd7986 add -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7987 add -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7988 add -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
-ddadd7989 add -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7990 add -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7991 add -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7992 add -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7993 add -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7994 add -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7995 add -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7996 add -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7997 add -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-ddadd71100 add 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
-ddadd71101 add 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
-ddadd71103 add +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
-ddadd71104 add 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
-ddadd71105 add 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
-ddadd71106 add 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
-ddadd71107 add 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
-ddadd71108 add 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
-ddadd71109 add 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-ddadd71110 add -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
-ddadd71111 add -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
-ddadd71113 add -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
-ddadd71114 add -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
-ddadd71115 add -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
-ddadd71116 add -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
-ddadd71117 add -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
-ddadd71118 add -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
-ddadd71119 add -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-ddadd71300 add 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71310 add 1E16 -0.51 -> 9999999999999999 Inexact Rounded
-ddadd71311 add 1E16 -0.501 -> 9999999999999999 Inexact Rounded
-ddadd71312 add 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
-ddadd71313 add 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
-ddadd71314 add 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
-ddadd71315 add 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
-ddadd71316 add 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
-ddadd71317 add 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
-ddadd71318 add 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
-ddadd71319 add 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
-ddadd71320 add 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
-ddadd71321 add 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
-ddadd71322 add 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
-ddadd71323 add 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
-ddadd71324 add 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
-ddadd71325 add 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71326 add 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71327 add 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71328 add 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71329 add 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71330 add 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71331 add 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71332 add 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71333 add 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71334 add 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71335 add 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71336 add 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71337 add 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71338 add 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71339 add 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
-
-ddadd71340 add 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
-ddadd71341 add 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
-
-ddadd71349 add 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
-ddadd71350 add 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
-ddadd71351 add 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
-ddadd71352 add 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
-ddadd71353 add 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
-ddadd71354 add 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
-ddadd71355 add 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
-ddadd71356 add 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
-ddadd71357 add 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
-ddadd71358 add 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
-ddadd71359 add 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
-ddadd71360 add 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
-ddadd71361 add 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
-ddadd71362 add 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
-ddadd71363 add 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
-ddadd71364 add 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
-ddadd71365 add 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71367 add 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71368 add 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71369 add 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71370 add 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71371 add 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71372 add 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71373 add 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71374 add 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71375 add 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71376 add 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71377 add 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71378 add 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71379 add 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71380 add 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71381 add 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71382 add 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71383 add 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71384 add 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71385 add 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71386 add 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71387 add 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71388 add 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71389 add 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71390 add 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71391 add 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71392 add 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71393 add 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71394 add 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71395 add 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71396 add 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-ddadd71420 add 0 1.123456789012345 -> 1.123456789012345
-ddadd71421 add 0 1.123456789012345E-1 -> 0.1123456789012345
-ddadd71422 add 0 1.123456789012345E-2 -> 0.01123456789012345
-ddadd71423 add 0 1.123456789012345E-3 -> 0.001123456789012345
-ddadd71424 add 0 1.123456789012345E-4 -> 0.0001123456789012345
-ddadd71425 add 0 1.123456789012345E-5 -> 0.00001123456789012345
-ddadd71426 add 0 1.123456789012345E-6 -> 0.000001123456789012345
-ddadd71427 add 0 1.123456789012345E-7 -> 1.123456789012345E-7
-ddadd71428 add 0 1.123456789012345E-8 -> 1.123456789012345E-8
-ddadd71429 add 0 1.123456789012345E-9 -> 1.123456789012345E-9
-ddadd71430 add 0 1.123456789012345E-10 -> 1.123456789012345E-10
-ddadd71431 add 0 1.123456789012345E-11 -> 1.123456789012345E-11
-ddadd71432 add 0 1.123456789012345E-12 -> 1.123456789012345E-12
-ddadd71433 add 0 1.123456789012345E-13 -> 1.123456789012345E-13
-ddadd71434 add 0 1.123456789012345E-14 -> 1.123456789012345E-14
-ddadd71435 add 0 1.123456789012345E-15 -> 1.123456789012345E-15
-ddadd71436 add 0 1.123456789012345E-16 -> 1.123456789012345E-16
-ddadd71437 add 0 1.123456789012345E-17 -> 1.123456789012345E-17
-ddadd71438 add 0 1.123456789012345E-18 -> 1.123456789012345E-18
-ddadd71439 add 0 1.123456789012345E-19 -> 1.123456789012345E-19
-
--- same, reversed 0
-ddadd71440 add 1.123456789012345 0 -> 1.123456789012345
-ddadd71441 add 1.123456789012345E-1 0 -> 0.1123456789012345
-ddadd71442 add 1.123456789012345E-2 0 -> 0.01123456789012345
-ddadd71443 add 1.123456789012345E-3 0 -> 0.001123456789012345
-ddadd71444 add 1.123456789012345E-4 0 -> 0.0001123456789012345
-ddadd71445 add 1.123456789012345E-5 0 -> 0.00001123456789012345
-ddadd71446 add 1.123456789012345E-6 0 -> 0.000001123456789012345
-ddadd71447 add 1.123456789012345E-7 0 -> 1.123456789012345E-7
-ddadd71448 add 1.123456789012345E-8 0 -> 1.123456789012345E-8
-ddadd71449 add 1.123456789012345E-9 0 -> 1.123456789012345E-9
-ddadd71450 add 1.123456789012345E-10 0 -> 1.123456789012345E-10
-ddadd71451 add 1.123456789012345E-11 0 -> 1.123456789012345E-11
-ddadd71452 add 1.123456789012345E-12 0 -> 1.123456789012345E-12
-ddadd71453 add 1.123456789012345E-13 0 -> 1.123456789012345E-13
-ddadd71454 add 1.123456789012345E-14 0 -> 1.123456789012345E-14
-ddadd71455 add 1.123456789012345E-15 0 -> 1.123456789012345E-15
-ddadd71456 add 1.123456789012345E-16 0 -> 1.123456789012345E-16
-ddadd71457 add 1.123456789012345E-17 0 -> 1.123456789012345E-17
-ddadd71458 add 1.123456789012345E-18 0 -> 1.123456789012345E-18
-ddadd71459 add 1.123456789012345E-19 0 -> 1.123456789012345E-19
-
--- same, Es on the 0
-ddadd71460 add 1.123456789012345 0E-0 -> 1.123456789012345
-ddadd71461 add 1.123456789012345 0E-1 -> 1.123456789012345
-ddadd71462 add 1.123456789012345 0E-2 -> 1.123456789012345
-ddadd71463 add 1.123456789012345 0E-3 -> 1.123456789012345
-ddadd71464 add 1.123456789012345 0E-4 -> 1.123456789012345
-ddadd71465 add 1.123456789012345 0E-5 -> 1.123456789012345
-ddadd71466 add 1.123456789012345 0E-6 -> 1.123456789012345
-ddadd71467 add 1.123456789012345 0E-7 -> 1.123456789012345
-ddadd71468 add 1.123456789012345 0E-8 -> 1.123456789012345
-ddadd71469 add 1.123456789012345 0E-9 -> 1.123456789012345
-ddadd71470 add 1.123456789012345 0E-10 -> 1.123456789012345
-ddadd71471 add 1.123456789012345 0E-11 -> 1.123456789012345
-ddadd71472 add 1.123456789012345 0E-12 -> 1.123456789012345
-ddadd71473 add 1.123456789012345 0E-13 -> 1.123456789012345
-ddadd71474 add 1.123456789012345 0E-14 -> 1.123456789012345
-ddadd71475 add 1.123456789012345 0E-15 -> 1.123456789012345
--- next four flag Rounded because the 0 extends the result
-ddadd71476 add 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
-ddadd71477 add 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
-ddadd71478 add 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
-ddadd71479 add 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-ddadd71500 add 0 0E-19 -> 0E-19
-ddadd71501 add -0 0E-19 -> 0E-19
-ddadd71502 add 0 -0E-19 -> 0E-19
-ddadd71503 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71511 add -11 11 -> 0
-ddadd71512 add 11 -11 -> 0
-
-rounding: half_down
--- exact zeros from zeros
-ddadd71520 add 0 0E-19 -> 0E-19
-ddadd71521 add -0 0E-19 -> 0E-19
-ddadd71522 add 0 -0E-19 -> 0E-19
-ddadd71523 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71531 add -11 11 -> 0
-ddadd71532 add 11 -11 -> 0
-
-rounding: half_even
--- exact zeros from zeros
-ddadd71540 add 0 0E-19 -> 0E-19
-ddadd71541 add -0 0E-19 -> 0E-19
-ddadd71542 add 0 -0E-19 -> 0E-19
-ddadd71543 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71551 add -11 11 -> 0
-ddadd71552 add 11 -11 -> 0
-
-rounding: up
--- exact zeros from zeros
-ddadd71560 add 0 0E-19 -> 0E-19
-ddadd71561 add -0 0E-19 -> 0E-19
-ddadd71562 add 0 -0E-19 -> 0E-19
-ddadd71563 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71571 add -11 11 -> 0
-ddadd71572 add 11 -11 -> 0
-
-rounding: down
--- exact zeros from zeros
-ddadd71580 add 0 0E-19 -> 0E-19
-ddadd71581 add -0 0E-19 -> 0E-19
-ddadd71582 add 0 -0E-19 -> 0E-19
-ddadd71583 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71591 add -11 11 -> 0
-ddadd71592 add 11 -11 -> 0
-
-rounding: ceiling
--- exact zeros from zeros
-ddadd71600 add 0 0E-19 -> 0E-19
-ddadd71601 add -0 0E-19 -> 0E-19
-ddadd71602 add 0 -0E-19 -> 0E-19
-ddadd71603 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71611 add -11 11 -> 0
-ddadd71612 add 11 -11 -> 0
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-ddadd71620 add 0 0E-19 -> 0E-19
-ddadd71621 add -0 0E-19 -> -0E-19 -- *
-ddadd71622 add 0 -0E-19 -> -0E-19 -- *
-ddadd71623 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71631 add -11 11 -> -0 -- *
-ddadd71632 add 11 -11 -> -0 -- *
-
--- Examples from SQL proposal (Krishna Kulkarni)
-ddadd71701 add 130E-2 120E-2 -> 2.50
-ddadd71702 add 130E-2 12E-1 -> 2.50
-ddadd71703 add 130E-2 1E0 -> 2.30
-ddadd71704 add 1E2 1E4 -> 1.01E+4
-ddadd71705 add 130E-2 -120E-2 -> 0.10
-ddadd71706 add 130E-2 -12E-1 -> 0.10
-ddadd71707 add 130E-2 -1E0 -> 0.30
-ddadd71708 add 1E2 -1E4 -> -9.9E+3
-
--- query from Vincent Kulandaisamy
-rounding: ceiling
-ddadd71801 add 7.8822773805862E+277 -5.1757503820663E-21 -> 7.882277380586200E+277 Inexact Rounded
-ddadd71802 add 7.882277380586200E+277 12.341 -> 7.882277380586201E+277 Inexact Rounded
-ddadd71803 add 7.882277380586201E+277 2.7270545046613E-31 -> 7.882277380586202E+277 Inexact Rounded
-
-ddadd71811 add 12.341 -5.1757503820663E-21 -> 12.34100000000000 Inexact Rounded
-ddadd71812 add 12.34100000000000 2.7270545046613E-31 -> 12.34100000000001 Inexact Rounded
-ddadd71813 add 12.34100000000001 7.8822773805862E+277 -> 7.882277380586201E+277 Inexact Rounded
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-ddadd75001 add 1234567890123456 1 -> 1234567890123457
-ddadd75002 add 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
-ddadd75003 add 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
-ddadd75004 add 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
-ddadd75005 add 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
-ddadd75006 add 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
-ddadd75007 add 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
-ddadd75008 add 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
-ddadd75009 add 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
-ddadd75010 add 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
-ddadd75011 add 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
-ddadd75012 add 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
-ddadd75013 add 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
-ddadd75014 add 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
-ddadd75015 add 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
-ddadd75016 add 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
-ddadd75017 add 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
-ddadd75018 add 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
-ddadd75019 add 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
-ddadd75020 add 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
-ddadd75021 add 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
-
--- widening second argument at gap
-ddadd75030 add 12345678 1 -> 12345679
-ddadd75031 add 12345678 0.1 -> 12345678.1
-ddadd75032 add 12345678 0.12 -> 12345678.12
-ddadd75033 add 12345678 0.123 -> 12345678.123
-ddadd75034 add 12345678 0.1234 -> 12345678.1234
-ddadd75035 add 12345678 0.12345 -> 12345678.12345
-ddadd75036 add 12345678 0.123456 -> 12345678.123456
-ddadd75037 add 12345678 0.1234567 -> 12345678.1234567
-ddadd75038 add 12345678 0.12345678 -> 12345678.12345678
-ddadd75039 add 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
-ddadd75040 add 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
-ddadd75041 add 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
-ddadd75042 add 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
-ddadd75043 add 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
-ddadd75044 add 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
-ddadd75045 add 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
-ddadd75046 add 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
-ddadd75047 add 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
-ddadd75048 add 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
-ddadd75049 add 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-ddadd75050 add 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
-ddadd75051 add 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
-ddadd75052 add 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
-ddadd75053 add 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
-ddadd75054 add 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
-ddadd75055 add 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
-ddadd75056 add 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
-ddadd75057 add 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
-ddadd75060 add 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
-ddadd75061 add 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
-ddadd75062 add 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
-ddadd75063 add 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
-ddadd75064 add 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
-ddadd75065 add 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
-ddadd75066 add 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
-ddadd75067 add 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-ddadd75070 add 12345678 1E-8 -> 12345678.00000001
-ddadd75071 add 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
-ddadd75072 add 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
-ddadd75073 add 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
-ddadd75074 add 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
-ddadd75075 add 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
-ddadd75076 add 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
-ddadd75077 add 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
-ddadd75078 add 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
-ddadd75079 add 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
-ddadd75080 add 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
-ddadd75081 add 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
-ddadd75082 add 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
-ddadd75083 add 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
-ddadd75084 add 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
-ddadd75085 add 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
-ddadd75086 add 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
-ddadd75087 add 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
-ddadd75088 add 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
-ddadd75089 add 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
-
--- Punit's
-ddadd75100 add 1.000 -200.000 -> -199.000
-
--- Rounding swathe
-rounding: half_even
-ddadd81100 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81101 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81102 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81103 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81104 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81105 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81106 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81107 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81108 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81109 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81120 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81121 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: half_up
-ddadd81200 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81201 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81202 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81203 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81204 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81205 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81206 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81207 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81208 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81209 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81220 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81221 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: half_down
-ddadd81300 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81301 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81302 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81303 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81304 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81305 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81306 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81307 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81308 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81309 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81320 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81321 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: up
-ddadd81400 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81401 add .2301 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81402 add .2310 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81403 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81404 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81405 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81406 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81407 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81408 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81409 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81411 add -.2399 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
-ddadd81420 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81421 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: down
-ddadd81500 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81501 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81502 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81503 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81504 add .2351 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81505 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81506 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81507 add .2360 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81508 add .2370 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81509 add .2399 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81511 add -.2399 -12345678901234.00 -> -12345678901234.23 Inexact Rounded
-ddadd81520 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddadd81521 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
-
-rounding: ceiling
-ddadd81600 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81601 add .2301 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81602 add .2310 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81603 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81604 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81605 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81606 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81607 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81608 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81609 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81611 add -.2399 -12345678901234.00 -> -12345678901234.23 Inexact Rounded
-ddadd81620 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81621 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
-
-rounding: floor
-ddadd81700 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81701 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81702 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81703 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81704 add .2351 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81705 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81706 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81707 add .2360 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81708 add .2370 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81709 add .2399 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81711 add -.2399 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
-ddadd81720 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddadd81721 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: 05up
-ddadd81800 add .2000 12345678901234.00 -> 12345678901234.20 Rounded
-ddadd81801 add .2001 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81802 add .2010 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81803 add .2050 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81804 add .2051 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81807 add .2060 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81808 add .2070 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81809 add .2099 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81811 add -.2099 -12345678901234.00 -> -12345678901234.21 Inexact Rounded
-ddadd81820 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddadd81821 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
-
-ddadd81900 add .2100 12345678901234.00 -> 12345678901234.21 Rounded
-ddadd81901 add .2101 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81902 add .2110 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81903 add .2150 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81904 add .2151 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81907 add .2160 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81908 add .2170 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81909 add .2199 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81911 add -.2199 -12345678901234.00 -> -12345678901234.21 Inexact Rounded
-
-ddadd82000 add .2400 12345678901234.00 -> 12345678901234.24 Rounded
-ddadd82001 add .2401 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82002 add .2410 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82003 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82004 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82007 add .2460 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82008 add .2470 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82009 add .2499 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82011 add -.2499 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
-
-ddadd82100 add .2500 12345678901234.00 -> 12345678901234.25 Rounded
-ddadd82101 add .2501 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82102 add .2510 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82103 add .2550 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82104 add .2551 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82107 add .2560 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82108 add .2570 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82109 add .2599 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82111 add -.2599 -12345678901234.00 -> -12345678901234.26 Inexact Rounded
-
-ddadd82200 add .2600 12345678901234.00 -> 12345678901234.26 Rounded
-ddadd82201 add .2601 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82202 add .2610 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82203 add .2650 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82204 add .2651 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82207 add .2660 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82208 add .2670 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82209 add .2699 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82211 add -.2699 -12345678901234.00 -> -12345678901234.26 Inexact Rounded
-
-ddadd82300 add .2900 12345678901234.00 -> 12345678901234.29 Rounded
-ddadd82301 add .2901 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82302 add .2910 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82303 add .2950 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82304 add .2951 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82307 add .2960 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82308 add .2970 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82309 add .2999 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82311 add -.2999 -12345678901234.00 -> -12345678901234.29 Inexact Rounded
-
--- Null tests
-ddadd9990 add 10 # -> NaN Invalid_operation
-ddadd9991 add # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddAdd.decTest -- decDouble addition --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decDoubles only; all arguments are
+-- representable in a decDouble
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+ddadd001 add 1 1 -> 2
+ddadd002 add 2 3 -> 5
+ddadd003 add '5.75' '3.3' -> 9.05
+ddadd004 add '5' '-3' -> 2
+ddadd005 add '-5' '-3' -> -8
+ddadd006 add '-7' '2.5' -> -4.5
+ddadd007 add '0.7' '0.3' -> 1.0
+ddadd008 add '1.25' '1.25' -> 2.50
+ddadd009 add '1.23456789' '1.00000000' -> '2.23456789'
+ddadd010 add '1.23456789' '1.00000011' -> '2.23456800'
+
+-- 1234567890123456 1234567890123456
+ddadd011 add '0.4444444444444446' '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
+ddadd012 add '0.4444444444444445' '0.5555555555555555' -> '1.000000000000000' Rounded
+ddadd013 add '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
+ddadd014 add '4444444444444444' '0.49' -> '4444444444444444' Inexact Rounded
+ddadd015 add '4444444444444444' '0.499' -> '4444444444444444' Inexact Rounded
+ddadd016 add '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
+ddadd017 add '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
+ddadd018 add '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
+ddadd019 add '4444444444444444' '0.501' -> '4444444444444445' Inexact Rounded
+ddadd020 add '4444444444444444' '0.51' -> '4444444444444445' Inexact Rounded
+
+ddadd021 add 0 1 -> 1
+ddadd022 add 1 1 -> 2
+ddadd023 add 2 1 -> 3
+ddadd024 add 3 1 -> 4
+ddadd025 add 4 1 -> 5
+ddadd026 add 5 1 -> 6
+ddadd027 add 6 1 -> 7
+ddadd028 add 7 1 -> 8
+ddadd029 add 8 1 -> 9
+ddadd030 add 9 1 -> 10
+
+-- some carrying effects
+ddadd031 add '0.9998' '0.0000' -> '0.9998'
+ddadd032 add '0.9998' '0.0001' -> '0.9999'
+ddadd033 add '0.9998' '0.0002' -> '1.0000'
+ddadd034 add '0.9998' '0.0003' -> '1.0001'
+
+ddadd035 add '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddadd036 add '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddadd037 add '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddadd038 add '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
+ddadd039 add '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
+
+-- symmetry:
+ddadd040 add '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
+ddadd041 add '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
+ddadd042 add '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
+ddadd044 add '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
+ddadd045 add '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
+
+-- same, without rounding
+ddadd046 add '10000e+9' '7' -> '10000000000007'
+ddadd047 add '10000e+9' '70' -> '10000000000070'
+ddadd048 add '10000e+9' '700' -> '10000000000700'
+ddadd049 add '10000e+9' '7000' -> '10000000007000'
+ddadd050 add '10000e+9' '70000' -> '10000000070000'
+ddadd051 add '10000e+9' '700000' -> '10000000700000'
+ddadd052 add '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+ddadd053 add '12' '7.00' -> '19.00'
+ddadd054 add '1.3' '-1.07' -> '0.23'
+ddadd055 add '1.3' '-1.30' -> '0.00'
+ddadd056 add '1.3' '-2.07' -> '-0.77'
+ddadd057 add '1E+2' '1E+4' -> '1.01E+4'
+
+-- leading zero preservation
+ddadd061 add 1 '0.0001' -> '1.0001'
+ddadd062 add 1 '0.00001' -> '1.00001'
+ddadd063 add 1 '0.000001' -> '1.000001'
+ddadd064 add 1 '0.0000001' -> '1.0000001'
+ddadd065 add 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+ddadd070 add 1 0 -> 1
+ddadd071 add 1 0. -> 1
+ddadd072 add 1 .0 -> 1.0
+ddadd073 add 1 0.0 -> 1.0
+ddadd074 add 1 0.00 -> 1.00
+ddadd075 add 0 1 -> 1
+ddadd076 add 0. 1 -> 1
+ddadd077 add .0 1 -> 1.0
+ddadd078 add 0.0 1 -> 1.0
+ddadd079 add 0.00 1 -> 1.00
+
+-- some carries
+ddadd080 add 999999998 1 -> 999999999
+ddadd081 add 999999999 1 -> 1000000000
+ddadd082 add 99999999 1 -> 100000000
+ddadd083 add 9999999 1 -> 10000000
+ddadd084 add 999999 1 -> 1000000
+ddadd085 add 99999 1 -> 100000
+ddadd086 add 9999 1 -> 10000
+ddadd087 add 999 1 -> 1000
+ddadd088 add 99 1 -> 100
+ddadd089 add 9 1 -> 10
+
+
+-- more LHS swaps
+ddadd090 add '-56267E-10' 0 -> '-0.0000056267'
+ddadd091 add '-56267E-6' 0 -> '-0.056267'
+ddadd092 add '-56267E-5' 0 -> '-0.56267'
+ddadd093 add '-56267E-4' 0 -> '-5.6267'
+ddadd094 add '-56267E-3' 0 -> '-56.267'
+ddadd095 add '-56267E-2' 0 -> '-562.67'
+ddadd096 add '-56267E-1' 0 -> '-5626.7'
+ddadd097 add '-56267E-0' 0 -> '-56267'
+ddadd098 add '-5E-10' 0 -> '-5E-10'
+ddadd099 add '-5E-7' 0 -> '-5E-7'
+ddadd100 add '-5E-6' 0 -> '-0.000005'
+ddadd101 add '-5E-5' 0 -> '-0.00005'
+ddadd102 add '-5E-4' 0 -> '-0.0005'
+ddadd103 add '-5E-1' 0 -> '-0.5'
+ddadd104 add '-5E0' 0 -> '-5'
+ddadd105 add '-5E1' 0 -> '-50'
+ddadd106 add '-5E5' 0 -> '-500000'
+ddadd107 add '-5E15' 0 -> '-5000000000000000'
+ddadd108 add '-5E16' 0 -> '-5.000000000000000E+16' Rounded
+ddadd109 add '-5E17' 0 -> '-5.000000000000000E+17' Rounded
+ddadd110 add '-5E18' 0 -> '-5.000000000000000E+18' Rounded
+ddadd111 add '-5E100' 0 -> '-5.000000000000000E+100' Rounded
+
+-- more RHS swaps
+ddadd113 add 0 '-56267E-10' -> '-0.0000056267'
+ddadd114 add 0 '-56267E-6' -> '-0.056267'
+ddadd116 add 0 '-56267E-5' -> '-0.56267'
+ddadd117 add 0 '-56267E-4' -> '-5.6267'
+ddadd119 add 0 '-56267E-3' -> '-56.267'
+ddadd120 add 0 '-56267E-2' -> '-562.67'
+ddadd121 add 0 '-56267E-1' -> '-5626.7'
+ddadd122 add 0 '-56267E-0' -> '-56267'
+ddadd123 add 0 '-5E-10' -> '-5E-10'
+ddadd124 add 0 '-5E-7' -> '-5E-7'
+ddadd125 add 0 '-5E-6' -> '-0.000005'
+ddadd126 add 0 '-5E-5' -> '-0.00005'
+ddadd127 add 0 '-5E-4' -> '-0.0005'
+ddadd128 add 0 '-5E-1' -> '-0.5'
+ddadd129 add 0 '-5E0' -> '-5'
+ddadd130 add 0 '-5E1' -> '-50'
+ddadd131 add 0 '-5E5' -> '-500000'
+ddadd132 add 0 '-5E15' -> '-5000000000000000'
+ddadd133 add 0 '-5E16' -> '-5.000000000000000E+16' Rounded
+ddadd134 add 0 '-5E17' -> '-5.000000000000000E+17' Rounded
+ddadd135 add 0 '-5E18' -> '-5.000000000000000E+18' Rounded
+ddadd136 add 0 '-5E100' -> '-5.000000000000000E+100' Rounded
+
+-- related
+ddadd137 add 1 '0E-19' -> '1.000000000000000' Rounded
+ddadd138 add -1 '0E-19' -> '-1.000000000000000' Rounded
+ddadd139 add '0E-19' 1 -> '1.000000000000000' Rounded
+ddadd140 add '0E-19' -1 -> '-1.000000000000000' Rounded
+ddadd141 add 1E+11 0.0000 -> '100000000000.0000'
+ddadd142 add 1E+11 0.00000 -> '100000000000.0000' Rounded
+ddadd143 add 0.000 1E+12 -> '1000000000000.000'
+ddadd144 add 0.0000 1E+12 -> '1000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+ddadd146 add '00.0' 0 -> '0.0'
+ddadd147 add '0.00' 0 -> '0.00'
+ddadd148 add 0 '0.00' -> '0.00'
+ddadd149 add 0 '00.0' -> '0.0'
+ddadd150 add '00.0' '0.00' -> '0.00'
+ddadd151 add '0.00' '00.0' -> '0.00'
+ddadd152 add '3' '.3' -> '3.3'
+ddadd153 add '3.' '.3' -> '3.3'
+ddadd154 add '3.0' '.3' -> '3.3'
+ddadd155 add '3.00' '.3' -> '3.30'
+ddadd156 add '3' '3' -> '6'
+ddadd157 add '3' '+3' -> '6'
+ddadd158 add '3' '-3' -> '0'
+ddadd159 add '0.3' '-0.3' -> '0.0'
+ddadd160 add '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+ddadd161 add '1E+12' '-1' -> '999999999999'
+ddadd162 add '1E+12' '1.11' -> '1000000000001.11'
+ddadd163 add '1.11' '1E+12' -> '1000000000001.11'
+ddadd164 add '-1' '1E+12' -> '999999999999'
+ddadd165 add '7E+12' '-1' -> '6999999999999'
+ddadd166 add '7E+12' '1.11' -> '7000000000001.11'
+ddadd167 add '1.11' '7E+12' -> '7000000000001.11'
+ddadd168 add '-1' '7E+12' -> '6999999999999'
+
+rounding: half_up
+-- 1.234567890123456 1234567890123456 1 234567890123456
+ddadd170 add '4.444444444444444' '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
+ddadd171 add '4.444444444444444' '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
+ddadd172 add '4.444444444444444' '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
+ddadd173 add '4.444444444444444' '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
+ddadd174 add '4.444444444444444' '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
+ddadd175 add '4.444444444444444' '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
+ddadd176 add '4.444444444444444' '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
+ddadd177 add '4.444444444444444' '0.5555555555555550' -> '4.999999999999999' Rounded
+ddadd178 add '4.444444444444444' '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
+ddadd179 add '4.444444444444444' '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
+ddadd180 add '4.444444444444444' '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
+ddadd181 add '4.444444444444444' '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
+ddadd182 add '4.444444444444444' '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
+ddadd183 add '4.444444444444444' '0.5555555555555540' -> '4.999999999999998' Rounded
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+ddadd200 add '1234560123456789' 0 -> '1234560123456789'
+ddadd201 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddadd202 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddadd203 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddadd204 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddadd205 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddadd206 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddadd207 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddadd208 add '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
+ddadd209 add '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
+ddadd210 add '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
+ddadd211 add '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
+ddadd212 add '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
+ddadd213 add '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
+ddadd214 add '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
+ddadd215 add '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
+ddadd216 add '1234560123456789' 1 -> '1234560123456790'
+ddadd217 add '1234560123456789' 1.000000001 -> '1234560123456790' Inexact Rounded
+ddadd218 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddadd219 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+
+rounding: half_even
+ddadd220 add '1234560123456789' 0 -> '1234560123456789'
+ddadd221 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddadd222 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddadd223 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddadd224 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddadd225 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddadd226 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddadd227 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddadd228 add '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
+ddadd229 add '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
+ddadd230 add '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
+ddadd231 add '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
+ddadd232 add '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
+ddadd233 add '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
+ddadd234 add '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
+ddadd235 add '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
+ddadd236 add '1234560123456789' 1 -> '1234560123456790'
+ddadd237 add '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
+ddadd238 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddadd239 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+-- critical few with even bottom digit...
+ddadd240 add '1234560123456788' 0.499999999 -> '1234560123456788' Inexact Rounded
+ddadd241 add '1234560123456788' 0.5 -> '1234560123456788' Inexact Rounded
+ddadd242 add '1234560123456788' 0.500000001 -> '1234560123456789' Inexact Rounded
+
+rounding: down
+ddadd250 add '1234560123456789' 0 -> '1234560123456789'
+ddadd251 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddadd252 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddadd253 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddadd254 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddadd255 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddadd256 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddadd257 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddadd258 add '1234560123456789' 0.5 -> '1234560123456789' Inexact Rounded
+ddadd259 add '1234560123456789' 0.500000001 -> '1234560123456789' Inexact Rounded
+ddadd260 add '1234560123456789' 0.500001 -> '1234560123456789' Inexact Rounded
+ddadd261 add '1234560123456789' 0.51 -> '1234560123456789' Inexact Rounded
+ddadd262 add '1234560123456789' 0.6 -> '1234560123456789' Inexact Rounded
+ddadd263 add '1234560123456789' 0.9 -> '1234560123456789' Inexact Rounded
+ddadd264 add '1234560123456789' 0.99999 -> '1234560123456789' Inexact Rounded
+ddadd265 add '1234560123456789' 0.999999999 -> '1234560123456789' Inexact Rounded
+ddadd266 add '1234560123456789' 1 -> '1234560123456790'
+ddadd267 add '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
+ddadd268 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddadd269 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+ddadd301 add -1 1 -> 0
+ddadd302 add 0 1 -> 1
+ddadd303 add 1 1 -> 2
+ddadd304 add 12 1 -> 13
+ddadd305 add 98 1 -> 99
+ddadd306 add 99 1 -> 100
+ddadd307 add 100 1 -> 101
+ddadd308 add 101 1 -> 102
+ddadd309 add -1 -1 -> -2
+ddadd310 add 0 -1 -> -1
+ddadd311 add 1 -1 -> 0
+ddadd312 add 12 -1 -> 11
+ddadd313 add 98 -1 -> 97
+ddadd314 add 99 -1 -> 98
+ddadd315 add 100 -1 -> 99
+ddadd316 add 101 -1 -> 100
+
+ddadd321 add -0.01 0.01 -> 0.00
+ddadd322 add 0.00 0.01 -> 0.01
+ddadd323 add 0.01 0.01 -> 0.02
+ddadd324 add 0.12 0.01 -> 0.13
+ddadd325 add 0.98 0.01 -> 0.99
+ddadd326 add 0.99 0.01 -> 1.00
+ddadd327 add 1.00 0.01 -> 1.01
+ddadd328 add 1.01 0.01 -> 1.02
+ddadd329 add -0.01 -0.01 -> -0.02
+ddadd330 add 0.00 -0.01 -> -0.01
+ddadd331 add 0.01 -0.01 -> 0.00
+ddadd332 add 0.12 -0.01 -> 0.11
+ddadd333 add 0.98 -0.01 -> 0.97
+ddadd334 add 0.99 -0.01 -> 0.98
+ddadd335 add 1.00 -0.01 -> 0.99
+ddadd336 add 1.01 -0.01 -> 1.00
+
+-- some more cases where adding 0 affects the coefficient
+ddadd340 add 1E+3 0 -> 1000
+ddadd341 add 1E+15 0 -> 1000000000000000
+ddadd342 add 1E+16 0 -> 1.000000000000000E+16 Rounded
+ddadd343 add 1E+20 0 -> 1.000000000000000E+20 Rounded
+-- which simply follow from these cases ...
+ddadd344 add 1E+3 1 -> 1001
+ddadd345 add 1E+15 1 -> 1000000000000001
+ddadd346 add 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
+ddadd347 add 1E+20 1 -> 1.000000000000000E+20 Inexact Rounded
+ddadd348 add 1E+3 7 -> 1007
+ddadd349 add 1E+15 7 -> 1000000000000007
+ddadd350 add 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
+ddadd351 add 1E+20 7 -> 1.000000000000000E+20 Inexact Rounded
+
+-- tryzeros cases
+rounding: half_up
+ddadd360 add 0E+50 10000E+1 -> 1.0000E+5
+ddadd361 add 0E-50 10000E+1 -> 100000.0000000000 Rounded
+ddadd362 add 10000E+1 0E-50 -> 100000.0000000000 Rounded
+ddadd363 add 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
+ddadd364 add 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+ddadd370 add 999999999999999 815 -> 1000000000000814
+ddadd371 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+rounding: half_up
+ddadd372 add 999999999999999 815 -> 1000000000000814
+ddadd373 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+rounding: half_even
+ddadd374 add 999999999999999 815 -> 1000000000000814
+ddadd375 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+
+-- operands folded
+ddadd380 add 1E+384 1E+384 -> 2.000000000000000E+384 Clamped
+ddadd381 add 1E+380 1E+380 -> 2.00000000000E+380 Clamped
+ddadd382 add 1E+376 1E+376 -> 2.0000000E+376 Clamped
+ddadd383 add 1E+372 1E+372 -> 2.000E+372 Clamped
+ddadd384 add 1E+370 1E+370 -> 2.0E+370 Clamped
+ddadd385 add 1E+369 1E+369 -> 2E+369
+ddadd386 add 1E+368 1E+368 -> 2E+368
+
+-- ulp replacement tests
+ddadd400 add 1 77e-14 -> 1.00000000000077
+ddadd401 add 1 77e-15 -> 1.000000000000077
+ddadd402 add 1 77e-16 -> 1.000000000000008 Inexact Rounded
+ddadd403 add 1 77e-17 -> 1.000000000000001 Inexact Rounded
+ddadd404 add 1 77e-18 -> 1.000000000000000 Inexact Rounded
+ddadd405 add 1 77e-19 -> 1.000000000000000 Inexact Rounded
+ddadd406 add 1 77e-299 -> 1.000000000000000 Inexact Rounded
+
+ddadd410 add 10 77e-14 -> 10.00000000000077
+ddadd411 add 10 77e-15 -> 10.00000000000008 Inexact Rounded
+ddadd412 add 10 77e-16 -> 10.00000000000001 Inexact Rounded
+ddadd413 add 10 77e-17 -> 10.00000000000000 Inexact Rounded
+ddadd414 add 10 77e-18 -> 10.00000000000000 Inexact Rounded
+ddadd415 add 10 77e-19 -> 10.00000000000000 Inexact Rounded
+ddadd416 add 10 77e-299 -> 10.00000000000000 Inexact Rounded
+
+ddadd420 add 77e-14 1 -> 1.00000000000077
+ddadd421 add 77e-15 1 -> 1.000000000000077
+ddadd422 add 77e-16 1 -> 1.000000000000008 Inexact Rounded
+ddadd423 add 77e-17 1 -> 1.000000000000001 Inexact Rounded
+ddadd424 add 77e-18 1 -> 1.000000000000000 Inexact Rounded
+ddadd425 add 77e-19 1 -> 1.000000000000000 Inexact Rounded
+ddadd426 add 77e-299 1 -> 1.000000000000000 Inexact Rounded
+
+ddadd430 add 77e-14 10 -> 10.00000000000077
+ddadd431 add 77e-15 10 -> 10.00000000000008 Inexact Rounded
+ddadd432 add 77e-16 10 -> 10.00000000000001 Inexact Rounded
+ddadd433 add 77e-17 10 -> 10.00000000000000 Inexact Rounded
+ddadd434 add 77e-18 10 -> 10.00000000000000 Inexact Rounded
+ddadd435 add 77e-19 10 -> 10.00000000000000 Inexact Rounded
+ddadd436 add 77e-299 10 -> 10.00000000000000 Inexact Rounded
+
+-- fastpath boundary (more in dqadd)
+-- 1234567890123456
+ddadd539 add '4444444444444444' '3333333333333333' -> '7777777777777777'
+ddadd540 add '4444444444444444' '4444444444444444' -> '8888888888888888'
+ddadd541 add '4444444444444444' '5555555555555555' -> '9999999999999999'
+ddadd542 add '3333333333333333' '4444444444444444' -> '7777777777777777'
+ddadd543 add '4444444444444444' '4444444444444444' -> '8888888888888888'
+ddadd544 add '5555555555555555' '4444444444444444' -> '9999999999999999'
+ddadd545 add '3000004000000000' '3000000000000040' -> '6000004000000040'
+ddadd546 add '3000000400000000' '4000000000000400' -> '7000000400000400'
+ddadd547 add '3000000040000000' '5000000000004000' -> '8000000040004000'
+ddadd548 add '4000000004000000' '3000000000040000' -> '7000000004040000'
+ddadd549 add '4000000000400000' '4000000000400000' -> '8000000000800000'
+ddadd550 add '4000000000040000' '5000000004000000' -> '9000000004040000'
+ddadd551 add '5000000000004000' '3000000040000000' -> '8000000040004000'
+ddadd552 add '5000000000000400' '4000000400000000' -> '9000000400000400'
+ddadd553 add '5000000000000040' '5000004000000000' -> 1.000000400000004E+16 Rounded
+-- check propagation
+ddadd554 add '8999999999999999' '0000000000000001' -> 9000000000000000
+ddadd555 add '0000000000000001' '8999999999999999' -> 9000000000000000
+ddadd556 add '0999999999999999' '0000000000000001' -> 1000000000000000
+ddadd557 add '0000000000000001' '0999999999999999' -> 1000000000000000
+ddadd558 add '4444444444444444' '4555555555555556' -> 9000000000000000
+ddadd559 add '4555555555555556' '4444444444444444' -> 9000000000000000
+
+-- negative ulps
+ddadd6440 add 1 -77e-14 -> 0.99999999999923
+ddadd6441 add 1 -77e-15 -> 0.999999999999923
+ddadd6442 add 1 -77e-16 -> 0.9999999999999923
+ddadd6443 add 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
+ddadd6444 add 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
+ddadd6445 add 1 -77e-19 -> 1.000000000000000 Inexact Rounded
+ddadd6446 add 1 -77e-99 -> 1.000000000000000 Inexact Rounded
+
+ddadd6450 add 10 -77e-14 -> 9.99999999999923
+ddadd6451 add 10 -77e-15 -> 9.999999999999923
+ddadd6452 add 10 -77e-16 -> 9.999999999999992 Inexact Rounded
+ddadd6453 add 10 -77e-17 -> 9.999999999999999 Inexact Rounded
+ddadd6454 add 10 -77e-18 -> 10.00000000000000 Inexact Rounded
+ddadd6455 add 10 -77e-19 -> 10.00000000000000 Inexact Rounded
+ddadd6456 add 10 -77e-99 -> 10.00000000000000 Inexact Rounded
+
+ddadd6460 add -77e-14 1 -> 0.99999999999923
+ddadd6461 add -77e-15 1 -> 0.999999999999923
+ddadd6462 add -77e-16 1 -> 0.9999999999999923
+ddadd6463 add -77e-17 1 -> 0.9999999999999992 Inexact Rounded
+ddadd6464 add -77e-18 1 -> 0.9999999999999999 Inexact Rounded
+ddadd6465 add -77e-19 1 -> 1.000000000000000 Inexact Rounded
+ddadd6466 add -77e-99 1 -> 1.000000000000000 Inexact Rounded
+
+ddadd6470 add -77e-14 10 -> 9.99999999999923
+ddadd6471 add -77e-15 10 -> 9.999999999999923
+ddadd6472 add -77e-16 10 -> 9.999999999999992 Inexact Rounded
+ddadd6473 add -77e-17 10 -> 9.999999999999999 Inexact Rounded
+ddadd6474 add -77e-18 10 -> 10.00000000000000 Inexact Rounded
+ddadd6475 add -77e-19 10 -> 10.00000000000000 Inexact Rounded
+ddadd6476 add -77e-99 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+ddadd6480 add -1 77e-14 -> -0.99999999999923
+ddadd6481 add -1 77e-15 -> -0.999999999999923
+ddadd6482 add -1 77e-16 -> -0.9999999999999923
+ddadd6483 add -1 77e-17 -> -0.9999999999999992 Inexact Rounded
+ddadd6484 add -1 77e-18 -> -0.9999999999999999 Inexact Rounded
+ddadd6485 add -1 77e-19 -> -1.000000000000000 Inexact Rounded
+ddadd6486 add -1 77e-99 -> -1.000000000000000 Inexact Rounded
+
+ddadd6490 add -10 77e-14 -> -9.99999999999923
+ddadd6491 add -10 77e-15 -> -9.999999999999923
+ddadd6492 add -10 77e-16 -> -9.999999999999992 Inexact Rounded
+ddadd6493 add -10 77e-17 -> -9.999999999999999 Inexact Rounded
+ddadd6494 add -10 77e-18 -> -10.00000000000000 Inexact Rounded
+ddadd6495 add -10 77e-19 -> -10.00000000000000 Inexact Rounded
+ddadd6496 add -10 77e-99 -> -10.00000000000000 Inexact Rounded
+
+ddadd6500 add 77e-14 -1 -> -0.99999999999923
+ddadd6501 add 77e-15 -1 -> -0.999999999999923
+ddadd6502 add 77e-16 -1 -> -0.9999999999999923
+ddadd6503 add 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
+ddadd6504 add 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
+ddadd6505 add 77e-19 -1 -> -1.000000000000000 Inexact Rounded
+ddadd6506 add 77e-99 -1 -> -1.000000000000000 Inexact Rounded
+
+ddadd6510 add 77e-14 -10 -> -9.99999999999923
+ddadd6511 add 77e-15 -10 -> -9.999999999999923
+ddadd6512 add 77e-16 -10 -> -9.999999999999992 Inexact Rounded
+ddadd6513 add 77e-17 -10 -> -9.999999999999999 Inexact Rounded
+ddadd6514 add 77e-18 -10 -> -10.00000000000000 Inexact Rounded
+ddadd6515 add 77e-19 -10 -> -10.00000000000000 Inexact Rounded
+ddadd6516 add 77e-99 -10 -> -10.00000000000000 Inexact Rounded
+
+-- and some more residue effects and different roundings
+rounding: half_up
+ddadd6540 add '6543210123456789' 0 -> '6543210123456789'
+ddadd6541 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddadd6542 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddadd6543 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddadd6544 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddadd6545 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddadd6546 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddadd6547 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddadd6548 add '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+ddadd6549 add '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+ddadd6550 add '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+ddadd6551 add '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+ddadd6552 add '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+ddadd6553 add '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+ddadd6554 add '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+ddadd6555 add '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
+ddadd6556 add '6543210123456789' 1 -> '6543210123456790'
+ddadd6557 add '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
+ddadd6558 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddadd6559 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+rounding: half_even
+ddadd6560 add '6543210123456789' 0 -> '6543210123456789'
+ddadd6561 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddadd6562 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddadd6563 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddadd6564 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddadd6565 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddadd6566 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddadd6567 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddadd6568 add '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+ddadd6569 add '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+ddadd6570 add '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+ddadd6571 add '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+ddadd6572 add '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+ddadd6573 add '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+ddadd6574 add '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+ddadd6575 add '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
+ddadd6576 add '6543210123456789' 1 -> '6543210123456790'
+ddadd6577 add '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+ddadd6578 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddadd6579 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+-- critical few with even bottom digit...
+ddadd7540 add '6543210123456788' 0.499999999 -> '6543210123456788' Inexact Rounded
+ddadd7541 add '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
+ddadd7542 add '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
+
+rounding: down
+ddadd7550 add '6543210123456789' 0 -> '6543210123456789'
+ddadd7551 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddadd7552 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddadd7553 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddadd7554 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddadd7555 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddadd7556 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddadd7557 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddadd7558 add '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
+ddadd7559 add '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
+ddadd7560 add '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
+ddadd7561 add '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
+ddadd7562 add '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
+ddadd7563 add '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
+ddadd7564 add '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
+ddadd7565 add '6543210123456789' 0.999999999 -> '6543210123456789' Inexact Rounded
+ddadd7566 add '6543210123456789' 1 -> '6543210123456790'
+ddadd7567 add '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+ddadd7568 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddadd7569 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+-- verify a query
+rounding: down
+ddadd7661 add 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
+ddadd7662 add 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
+ddadd7663 add 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
+ddadd7664 add 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+ddadd7701 add 5.00 1.00E-3 -> 5.00100
+ddadd7702 add 00.00 0.000 -> 0.000
+ddadd7703 add 00.00 0E-3 -> 0.000
+ddadd7704 add 0E-3 00.00 -> 0.000
+
+ddadd7710 add 0E+3 00.00 -> 0.00
+ddadd7711 add 0E+3 00.0 -> 0.0
+ddadd7712 add 0E+3 00. -> 0
+ddadd7713 add 0E+3 00.E+1 -> 0E+1
+ddadd7714 add 0E+3 00.E+2 -> 0E+2
+ddadd7715 add 0E+3 00.E+3 -> 0E+3
+ddadd7716 add 0E+3 00.E+4 -> 0E+3
+ddadd7717 add 0E+3 00.E+5 -> 0E+3
+ddadd7718 add 0E+3 -00.0 -> 0.0
+ddadd7719 add 0E+3 -00. -> 0
+ddadd7731 add 0E+3 -00.E+1 -> 0E+1
+
+ddadd7720 add 00.00 0E+3 -> 0.00
+ddadd7721 add 00.0 0E+3 -> 0.0
+ddadd7722 add 00. 0E+3 -> 0
+ddadd7723 add 00.E+1 0E+3 -> 0E+1
+ddadd7724 add 00.E+2 0E+3 -> 0E+2
+ddadd7725 add 00.E+3 0E+3 -> 0E+3
+ddadd7726 add 00.E+4 0E+3 -> 0E+3
+ddadd7727 add 00.E+5 0E+3 -> 0E+3
+ddadd7728 add -00.00 0E+3 -> 0.00
+ddadd7729 add -00.0 0E+3 -> 0.0
+ddadd7730 add -00. 0E+3 -> 0
+
+ddadd7732 add 0 0 -> 0
+ddadd7733 add 0 -0 -> 0
+ddadd7734 add -0 0 -> 0
+ddadd7735 add -0 -0 -> -0 -- IEEE 854 special case
+
+ddadd7736 add 1 -1 -> 0
+ddadd7737 add -1 -1 -> -2
+ddadd7738 add 1 1 -> 2
+ddadd7739 add -1 1 -> 0
+
+ddadd7741 add 0 -1 -> -1
+ddadd7742 add -0 -1 -> -1
+ddadd7743 add 0 1 -> 1
+ddadd7744 add -0 1 -> 1
+ddadd7745 add -1 0 -> -1
+ddadd7746 add -1 -0 -> -1
+ddadd7747 add 1 0 -> 1
+ddadd7748 add 1 -0 -> 1
+
+ddadd7751 add 0.0 -1 -> -1.0
+ddadd7752 add -0.0 -1 -> -1.0
+ddadd7753 add 0.0 1 -> 1.0
+ddadd7754 add -0.0 1 -> 1.0
+ddadd7755 add -1.0 0 -> -1.0
+ddadd7756 add -1.0 -0 -> -1.0
+ddadd7757 add 1.0 0 -> 1.0
+ddadd7758 add 1.0 -0 -> 1.0
+
+ddadd7761 add 0 -1.0 -> -1.0
+ddadd7762 add -0 -1.0 -> -1.0
+ddadd7763 add 0 1.0 -> 1.0
+ddadd7764 add -0 1.0 -> 1.0
+ddadd7765 add -1 0.0 -> -1.0
+ddadd7766 add -1 -0.0 -> -1.0
+ddadd7767 add 1 0.0 -> 1.0
+ddadd7768 add 1 -0.0 -> 1.0
+
+ddadd7771 add 0.0 -1.0 -> -1.0
+ddadd7772 add -0.0 -1.0 -> -1.0
+ddadd7773 add 0.0 1.0 -> 1.0
+ddadd7774 add -0.0 1.0 -> 1.0
+ddadd7775 add -1.0 0.0 -> -1.0
+ddadd7776 add -1.0 -0.0 -> -1.0
+ddadd7777 add 1.0 0.0 -> 1.0
+ddadd7778 add 1.0 -0.0 -> 1.0
+
+-- Specials
+ddadd7780 add -Inf -Inf -> -Infinity
+ddadd7781 add -Inf -1000 -> -Infinity
+ddadd7782 add -Inf -1 -> -Infinity
+ddadd7783 add -Inf -0 -> -Infinity
+ddadd7784 add -Inf 0 -> -Infinity
+ddadd7785 add -Inf 1 -> -Infinity
+ddadd7786 add -Inf 1000 -> -Infinity
+ddadd7787 add -1000 -Inf -> -Infinity
+ddadd7788 add -Inf -Inf -> -Infinity
+ddadd7789 add -1 -Inf -> -Infinity
+ddadd7790 add -0 -Inf -> -Infinity
+ddadd7791 add 0 -Inf -> -Infinity
+ddadd7792 add 1 -Inf -> -Infinity
+ddadd7793 add 1000 -Inf -> -Infinity
+ddadd7794 add Inf -Inf -> NaN Invalid_operation
+
+ddadd7800 add Inf -Inf -> NaN Invalid_operation
+ddadd7801 add Inf -1000 -> Infinity
+ddadd7802 add Inf -1 -> Infinity
+ddadd7803 add Inf -0 -> Infinity
+ddadd7804 add Inf 0 -> Infinity
+ddadd7805 add Inf 1 -> Infinity
+ddadd7806 add Inf 1000 -> Infinity
+ddadd7807 add Inf Inf -> Infinity
+ddadd7808 add -1000 Inf -> Infinity
+ddadd7809 add -Inf Inf -> NaN Invalid_operation
+ddadd7810 add -1 Inf -> Infinity
+ddadd7811 add -0 Inf -> Infinity
+ddadd7812 add 0 Inf -> Infinity
+ddadd7813 add 1 Inf -> Infinity
+ddadd7814 add 1000 Inf -> Infinity
+ddadd7815 add Inf Inf -> Infinity
+
+ddadd7821 add NaN -Inf -> NaN
+ddadd7822 add NaN -1000 -> NaN
+ddadd7823 add NaN -1 -> NaN
+ddadd7824 add NaN -0 -> NaN
+ddadd7825 add NaN 0 -> NaN
+ddadd7826 add NaN 1 -> NaN
+ddadd7827 add NaN 1000 -> NaN
+ddadd7828 add NaN Inf -> NaN
+ddadd7829 add NaN NaN -> NaN
+ddadd7830 add -Inf NaN -> NaN
+ddadd7831 add -1000 NaN -> NaN
+ddadd7832 add -1 NaN -> NaN
+ddadd7833 add -0 NaN -> NaN
+ddadd7834 add 0 NaN -> NaN
+ddadd7835 add 1 NaN -> NaN
+ddadd7836 add 1000 NaN -> NaN
+ddadd7837 add Inf NaN -> NaN
+
+ddadd7841 add sNaN -Inf -> NaN Invalid_operation
+ddadd7842 add sNaN -1000 -> NaN Invalid_operation
+ddadd7843 add sNaN -1 -> NaN Invalid_operation
+ddadd7844 add sNaN -0 -> NaN Invalid_operation
+ddadd7845 add sNaN 0 -> NaN Invalid_operation
+ddadd7846 add sNaN 1 -> NaN Invalid_operation
+ddadd7847 add sNaN 1000 -> NaN Invalid_operation
+ddadd7848 add sNaN NaN -> NaN Invalid_operation
+ddadd7849 add sNaN sNaN -> NaN Invalid_operation
+ddadd7850 add NaN sNaN -> NaN Invalid_operation
+ddadd7851 add -Inf sNaN -> NaN Invalid_operation
+ddadd7852 add -1000 sNaN -> NaN Invalid_operation
+ddadd7853 add -1 sNaN -> NaN Invalid_operation
+ddadd7854 add -0 sNaN -> NaN Invalid_operation
+ddadd7855 add 0 sNaN -> NaN Invalid_operation
+ddadd7856 add 1 sNaN -> NaN Invalid_operation
+ddadd7857 add 1000 sNaN -> NaN Invalid_operation
+ddadd7858 add Inf sNaN -> NaN Invalid_operation
+ddadd7859 add NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddadd7861 add NaN1 -Inf -> NaN1
+ddadd7862 add +NaN2 -1000 -> NaN2
+ddadd7863 add NaN3 1000 -> NaN3
+ddadd7864 add NaN4 Inf -> NaN4
+ddadd7865 add NaN5 +NaN6 -> NaN5
+ddadd7866 add -Inf NaN7 -> NaN7
+ddadd7867 add -1000 NaN8 -> NaN8
+ddadd7868 add 1000 NaN9 -> NaN9
+ddadd7869 add Inf +NaN10 -> NaN10
+ddadd7871 add sNaN11 -Inf -> NaN11 Invalid_operation
+ddadd7872 add sNaN12 -1000 -> NaN12 Invalid_operation
+ddadd7873 add sNaN13 1000 -> NaN13 Invalid_operation
+ddadd7874 add sNaN14 NaN17 -> NaN14 Invalid_operation
+ddadd7875 add sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddadd7876 add NaN16 sNaN19 -> NaN19 Invalid_operation
+ddadd7877 add -Inf +sNaN20 -> NaN20 Invalid_operation
+ddadd7878 add -1000 sNaN21 -> NaN21 Invalid_operation
+ddadd7879 add 1000 sNaN22 -> NaN22 Invalid_operation
+ddadd7880 add Inf sNaN23 -> NaN23 Invalid_operation
+ddadd7881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddadd7882 add -NaN26 NaN28 -> -NaN26
+ddadd7883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddadd7884 add 1000 -NaN30 -> -NaN30
+ddadd7885 add 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Here we explore near the boundary of rounding a subnormal to Nmin
+ddadd7575 add 1E-383 -1E-398 -> 9.99999999999999E-384 Subnormal
+ddadd7576 add -1E-383 +1E-398 -> -9.99999999999999E-384 Subnormal
+
+-- and another curious case
+ddadd7577 add 7.000000000000E-385 -1.00000E-391 -> 6.999999000000E-385 Subnormal
+
+-- check overflow edge case
+-- 1234567890123456
+ddadd7972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
+ddadd7973 add 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7974 add 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7975 add 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
+ddadd7976 add 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
+ddadd7977 add 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
+ddadd7978 add 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
+ddadd7979 add 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
+ddadd7980 add 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
+ddadd7981 add 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7982 add 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7983 add 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7984 add 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
+
+ddadd7985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
+ddadd7986 add -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7987 add -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7988 add -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
+ddadd7989 add -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7990 add -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7991 add -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7992 add -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7993 add -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7994 add -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7995 add -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7996 add -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7997 add -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+ddadd71100 add 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
+ddadd71101 add 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
+ddadd71103 add +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
+ddadd71104 add 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
+ddadd71105 add 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
+ddadd71106 add 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
+ddadd71107 add 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
+ddadd71108 add 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
+ddadd71109 add 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+ddadd71110 add -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
+ddadd71111 add -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
+ddadd71113 add -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
+ddadd71114 add -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
+ddadd71115 add -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
+ddadd71116 add -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
+ddadd71117 add -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
+ddadd71118 add -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
+ddadd71119 add -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+ddadd71300 add 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71310 add 1E16 -0.51 -> 9999999999999999 Inexact Rounded
+ddadd71311 add 1E16 -0.501 -> 9999999999999999 Inexact Rounded
+ddadd71312 add 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
+ddadd71313 add 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
+ddadd71314 add 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
+ddadd71315 add 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
+ddadd71316 add 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
+ddadd71317 add 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
+ddadd71318 add 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
+ddadd71319 add 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
+ddadd71320 add 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
+ddadd71321 add 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
+ddadd71322 add 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
+ddadd71323 add 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
+ddadd71324 add 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
+ddadd71325 add 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71326 add 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71327 add 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71328 add 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71329 add 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71330 add 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71331 add 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71332 add 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71333 add 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71334 add 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71335 add 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71336 add 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71337 add 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71338 add 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71339 add 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
+
+ddadd71340 add 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
+ddadd71341 add 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
+
+ddadd71349 add 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
+ddadd71350 add 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
+ddadd71351 add 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
+ddadd71352 add 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
+ddadd71353 add 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
+ddadd71354 add 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
+ddadd71355 add 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
+ddadd71356 add 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
+ddadd71357 add 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
+ddadd71358 add 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
+ddadd71359 add 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
+ddadd71360 add 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
+ddadd71361 add 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
+ddadd71362 add 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
+ddadd71363 add 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
+ddadd71364 add 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
+ddadd71365 add 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71367 add 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71368 add 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71369 add 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71370 add 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71371 add 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71372 add 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71373 add 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71374 add 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71375 add 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71376 add 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71377 add 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71378 add 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71379 add 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71380 add 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71381 add 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71382 add 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71383 add 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71384 add 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71385 add 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71386 add 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71387 add 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71388 add 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71389 add 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71390 add 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71391 add 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71392 add 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71393 add 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71394 add 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71395 add 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71396 add 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+ddadd71420 add 0 1.123456789012345 -> 1.123456789012345
+ddadd71421 add 0 1.123456789012345E-1 -> 0.1123456789012345
+ddadd71422 add 0 1.123456789012345E-2 -> 0.01123456789012345
+ddadd71423 add 0 1.123456789012345E-3 -> 0.001123456789012345
+ddadd71424 add 0 1.123456789012345E-4 -> 0.0001123456789012345
+ddadd71425 add 0 1.123456789012345E-5 -> 0.00001123456789012345
+ddadd71426 add 0 1.123456789012345E-6 -> 0.000001123456789012345
+ddadd71427 add 0 1.123456789012345E-7 -> 1.123456789012345E-7
+ddadd71428 add 0 1.123456789012345E-8 -> 1.123456789012345E-8
+ddadd71429 add 0 1.123456789012345E-9 -> 1.123456789012345E-9
+ddadd71430 add 0 1.123456789012345E-10 -> 1.123456789012345E-10
+ddadd71431 add 0 1.123456789012345E-11 -> 1.123456789012345E-11
+ddadd71432 add 0 1.123456789012345E-12 -> 1.123456789012345E-12
+ddadd71433 add 0 1.123456789012345E-13 -> 1.123456789012345E-13
+ddadd71434 add 0 1.123456789012345E-14 -> 1.123456789012345E-14
+ddadd71435 add 0 1.123456789012345E-15 -> 1.123456789012345E-15
+ddadd71436 add 0 1.123456789012345E-16 -> 1.123456789012345E-16
+ddadd71437 add 0 1.123456789012345E-17 -> 1.123456789012345E-17
+ddadd71438 add 0 1.123456789012345E-18 -> 1.123456789012345E-18
+ddadd71439 add 0 1.123456789012345E-19 -> 1.123456789012345E-19
+
+-- same, reversed 0
+ddadd71440 add 1.123456789012345 0 -> 1.123456789012345
+ddadd71441 add 1.123456789012345E-1 0 -> 0.1123456789012345
+ddadd71442 add 1.123456789012345E-2 0 -> 0.01123456789012345
+ddadd71443 add 1.123456789012345E-3 0 -> 0.001123456789012345
+ddadd71444 add 1.123456789012345E-4 0 -> 0.0001123456789012345
+ddadd71445 add 1.123456789012345E-5 0 -> 0.00001123456789012345
+ddadd71446 add 1.123456789012345E-6 0 -> 0.000001123456789012345
+ddadd71447 add 1.123456789012345E-7 0 -> 1.123456789012345E-7
+ddadd71448 add 1.123456789012345E-8 0 -> 1.123456789012345E-8
+ddadd71449 add 1.123456789012345E-9 0 -> 1.123456789012345E-9
+ddadd71450 add 1.123456789012345E-10 0 -> 1.123456789012345E-10
+ddadd71451 add 1.123456789012345E-11 0 -> 1.123456789012345E-11
+ddadd71452 add 1.123456789012345E-12 0 -> 1.123456789012345E-12
+ddadd71453 add 1.123456789012345E-13 0 -> 1.123456789012345E-13
+ddadd71454 add 1.123456789012345E-14 0 -> 1.123456789012345E-14
+ddadd71455 add 1.123456789012345E-15 0 -> 1.123456789012345E-15
+ddadd71456 add 1.123456789012345E-16 0 -> 1.123456789012345E-16
+ddadd71457 add 1.123456789012345E-17 0 -> 1.123456789012345E-17
+ddadd71458 add 1.123456789012345E-18 0 -> 1.123456789012345E-18
+ddadd71459 add 1.123456789012345E-19 0 -> 1.123456789012345E-19
+
+-- same, Es on the 0
+ddadd71460 add 1.123456789012345 0E-0 -> 1.123456789012345
+ddadd71461 add 1.123456789012345 0E-1 -> 1.123456789012345
+ddadd71462 add 1.123456789012345 0E-2 -> 1.123456789012345
+ddadd71463 add 1.123456789012345 0E-3 -> 1.123456789012345
+ddadd71464 add 1.123456789012345 0E-4 -> 1.123456789012345
+ddadd71465 add 1.123456789012345 0E-5 -> 1.123456789012345
+ddadd71466 add 1.123456789012345 0E-6 -> 1.123456789012345
+ddadd71467 add 1.123456789012345 0E-7 -> 1.123456789012345
+ddadd71468 add 1.123456789012345 0E-8 -> 1.123456789012345
+ddadd71469 add 1.123456789012345 0E-9 -> 1.123456789012345
+ddadd71470 add 1.123456789012345 0E-10 -> 1.123456789012345
+ddadd71471 add 1.123456789012345 0E-11 -> 1.123456789012345
+ddadd71472 add 1.123456789012345 0E-12 -> 1.123456789012345
+ddadd71473 add 1.123456789012345 0E-13 -> 1.123456789012345
+ddadd71474 add 1.123456789012345 0E-14 -> 1.123456789012345
+ddadd71475 add 1.123456789012345 0E-15 -> 1.123456789012345
+-- next four flag Rounded because the 0 extends the result
+ddadd71476 add 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
+ddadd71477 add 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
+ddadd71478 add 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
+ddadd71479 add 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+ddadd71500 add 0 0E-19 -> 0E-19
+ddadd71501 add -0 0E-19 -> 0E-19
+ddadd71502 add 0 -0E-19 -> 0E-19
+ddadd71503 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71511 add -11 11 -> 0
+ddadd71512 add 11 -11 -> 0
+
+rounding: half_down
+-- exact zeros from zeros
+ddadd71520 add 0 0E-19 -> 0E-19
+ddadd71521 add -0 0E-19 -> 0E-19
+ddadd71522 add 0 -0E-19 -> 0E-19
+ddadd71523 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71531 add -11 11 -> 0
+ddadd71532 add 11 -11 -> 0
+
+rounding: half_even
+-- exact zeros from zeros
+ddadd71540 add 0 0E-19 -> 0E-19
+ddadd71541 add -0 0E-19 -> 0E-19
+ddadd71542 add 0 -0E-19 -> 0E-19
+ddadd71543 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71551 add -11 11 -> 0
+ddadd71552 add 11 -11 -> 0
+
+rounding: up
+-- exact zeros from zeros
+ddadd71560 add 0 0E-19 -> 0E-19
+ddadd71561 add -0 0E-19 -> 0E-19
+ddadd71562 add 0 -0E-19 -> 0E-19
+ddadd71563 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71571 add -11 11 -> 0
+ddadd71572 add 11 -11 -> 0
+
+rounding: down
+-- exact zeros from zeros
+ddadd71580 add 0 0E-19 -> 0E-19
+ddadd71581 add -0 0E-19 -> 0E-19
+ddadd71582 add 0 -0E-19 -> 0E-19
+ddadd71583 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71591 add -11 11 -> 0
+ddadd71592 add 11 -11 -> 0
+
+rounding: ceiling
+-- exact zeros from zeros
+ddadd71600 add 0 0E-19 -> 0E-19
+ddadd71601 add -0 0E-19 -> 0E-19
+ddadd71602 add 0 -0E-19 -> 0E-19
+ddadd71603 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71611 add -11 11 -> 0
+ddadd71612 add 11 -11 -> 0
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+ddadd71620 add 0 0E-19 -> 0E-19
+ddadd71621 add -0 0E-19 -> -0E-19 -- *
+ddadd71622 add 0 -0E-19 -> -0E-19 -- *
+ddadd71623 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71631 add -11 11 -> -0 -- *
+ddadd71632 add 11 -11 -> -0 -- *
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+ddadd71701 add 130E-2 120E-2 -> 2.50
+ddadd71702 add 130E-2 12E-1 -> 2.50
+ddadd71703 add 130E-2 1E0 -> 2.30
+ddadd71704 add 1E2 1E4 -> 1.01E+4
+ddadd71705 add 130E-2 -120E-2 -> 0.10
+ddadd71706 add 130E-2 -12E-1 -> 0.10
+ddadd71707 add 130E-2 -1E0 -> 0.30
+ddadd71708 add 1E2 -1E4 -> -9.9E+3
+
+-- query from Vincent Kulandaisamy
+rounding: ceiling
+ddadd71801 add 7.8822773805862E+277 -5.1757503820663E-21 -> 7.882277380586200E+277 Inexact Rounded
+ddadd71802 add 7.882277380586200E+277 12.341 -> 7.882277380586201E+277 Inexact Rounded
+ddadd71803 add 7.882277380586201E+277 2.7270545046613E-31 -> 7.882277380586202E+277 Inexact Rounded
+
+ddadd71811 add 12.341 -5.1757503820663E-21 -> 12.34100000000000 Inexact Rounded
+ddadd71812 add 12.34100000000000 2.7270545046613E-31 -> 12.34100000000001 Inexact Rounded
+ddadd71813 add 12.34100000000001 7.8822773805862E+277 -> 7.882277380586201E+277 Inexact Rounded
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+ddadd75001 add 1234567890123456 1 -> 1234567890123457
+ddadd75002 add 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
+ddadd75003 add 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
+ddadd75004 add 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
+ddadd75005 add 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
+ddadd75006 add 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
+ddadd75007 add 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
+ddadd75008 add 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
+ddadd75009 add 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
+ddadd75010 add 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
+ddadd75011 add 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
+ddadd75012 add 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
+ddadd75013 add 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
+ddadd75014 add 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
+ddadd75015 add 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
+ddadd75016 add 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
+ddadd75017 add 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
+ddadd75018 add 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
+ddadd75019 add 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
+ddadd75020 add 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
+ddadd75021 add 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
+
+-- widening second argument at gap
+ddadd75030 add 12345678 1 -> 12345679
+ddadd75031 add 12345678 0.1 -> 12345678.1
+ddadd75032 add 12345678 0.12 -> 12345678.12
+ddadd75033 add 12345678 0.123 -> 12345678.123
+ddadd75034 add 12345678 0.1234 -> 12345678.1234
+ddadd75035 add 12345678 0.12345 -> 12345678.12345
+ddadd75036 add 12345678 0.123456 -> 12345678.123456
+ddadd75037 add 12345678 0.1234567 -> 12345678.1234567
+ddadd75038 add 12345678 0.12345678 -> 12345678.12345678
+ddadd75039 add 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
+ddadd75040 add 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
+ddadd75041 add 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
+ddadd75042 add 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
+ddadd75043 add 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
+ddadd75044 add 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
+ddadd75045 add 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
+ddadd75046 add 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
+ddadd75047 add 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
+ddadd75048 add 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
+ddadd75049 add 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+ddadd75050 add 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
+ddadd75051 add 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
+ddadd75052 add 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
+ddadd75053 add 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
+ddadd75054 add 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
+ddadd75055 add 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
+ddadd75056 add 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
+ddadd75057 add 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
+ddadd75060 add 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
+ddadd75061 add 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
+ddadd75062 add 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
+ddadd75063 add 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
+ddadd75064 add 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
+ddadd75065 add 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
+ddadd75066 add 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
+ddadd75067 add 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+ddadd75070 add 12345678 1E-8 -> 12345678.00000001
+ddadd75071 add 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
+ddadd75072 add 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
+ddadd75073 add 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
+ddadd75074 add 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
+ddadd75075 add 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
+ddadd75076 add 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
+ddadd75077 add 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
+ddadd75078 add 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
+ddadd75079 add 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
+ddadd75080 add 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
+ddadd75081 add 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
+ddadd75082 add 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
+ddadd75083 add 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
+ddadd75084 add 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
+ddadd75085 add 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
+ddadd75086 add 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
+ddadd75087 add 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
+ddadd75088 add 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
+ddadd75089 add 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
+
+-- Punit's
+ddadd75100 add 1.000 -200.000 -> -199.000
+
+-- Rounding swathe
+rounding: half_even
+ddadd81100 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81101 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81102 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81103 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81104 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81105 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81106 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81107 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81108 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81109 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81120 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81121 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: half_up
+ddadd81200 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81201 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81202 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81203 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81204 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81205 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81206 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81207 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81208 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81209 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81220 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81221 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: half_down
+ddadd81300 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81301 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81302 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81303 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81304 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81305 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81306 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81307 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81308 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81309 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81320 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81321 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: up
+ddadd81400 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81401 add .2301 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81402 add .2310 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81403 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81404 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81405 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81406 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81407 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81408 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81409 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81411 add -.2399 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
+ddadd81420 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81421 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: down
+ddadd81500 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81501 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81502 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81503 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81504 add .2351 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81505 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81506 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81507 add .2360 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81508 add .2370 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81509 add .2399 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81511 add -.2399 -12345678901234.00 -> -12345678901234.23 Inexact Rounded
+ddadd81520 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddadd81521 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
+
+rounding: ceiling
+ddadd81600 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81601 add .2301 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81602 add .2310 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81603 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81604 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81605 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81606 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81607 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81608 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81609 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81611 add -.2399 -12345678901234.00 -> -12345678901234.23 Inexact Rounded
+ddadd81620 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81621 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
+
+rounding: floor
+ddadd81700 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81701 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81702 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81703 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81704 add .2351 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81705 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81706 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81707 add .2360 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81708 add .2370 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81709 add .2399 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81711 add -.2399 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
+ddadd81720 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddadd81721 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: 05up
+ddadd81800 add .2000 12345678901234.00 -> 12345678901234.20 Rounded
+ddadd81801 add .2001 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81802 add .2010 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81803 add .2050 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81804 add .2051 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81807 add .2060 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81808 add .2070 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81809 add .2099 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81811 add -.2099 -12345678901234.00 -> -12345678901234.21 Inexact Rounded
+ddadd81820 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddadd81821 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
+
+ddadd81900 add .2100 12345678901234.00 -> 12345678901234.21 Rounded
+ddadd81901 add .2101 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81902 add .2110 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81903 add .2150 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81904 add .2151 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81907 add .2160 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81908 add .2170 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81909 add .2199 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81911 add -.2199 -12345678901234.00 -> -12345678901234.21 Inexact Rounded
+
+ddadd82000 add .2400 12345678901234.00 -> 12345678901234.24 Rounded
+ddadd82001 add .2401 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82002 add .2410 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82003 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82004 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82007 add .2460 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82008 add .2470 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82009 add .2499 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82011 add -.2499 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
+
+ddadd82100 add .2500 12345678901234.00 -> 12345678901234.25 Rounded
+ddadd82101 add .2501 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82102 add .2510 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82103 add .2550 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82104 add .2551 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82107 add .2560 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82108 add .2570 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82109 add .2599 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82111 add -.2599 -12345678901234.00 -> -12345678901234.26 Inexact Rounded
+
+ddadd82200 add .2600 12345678901234.00 -> 12345678901234.26 Rounded
+ddadd82201 add .2601 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82202 add .2610 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82203 add .2650 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82204 add .2651 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82207 add .2660 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82208 add .2670 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82209 add .2699 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82211 add -.2699 -12345678901234.00 -> -12345678901234.26 Inexact Rounded
+
+ddadd82300 add .2900 12345678901234.00 -> 12345678901234.29 Rounded
+ddadd82301 add .2901 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82302 add .2910 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82303 add .2950 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82304 add .2951 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82307 add .2960 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82308 add .2970 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82309 add .2999 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82311 add -.2999 -12345678901234.00 -> -12345678901234.29 Inexact Rounded
+
+-- Null tests
+ddadd9990 add 10 # -> NaN Invalid_operation
+ddadd9991 add # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddAnd.decTest b/Lib/test/decimaltestdata/ddAnd.decTest
index 64a9f92df9..676517548c 100644
--- a/Lib/test/decimaltestdata/ddAnd.decTest
+++ b/Lib/test/decimaltestdata/ddAnd.decTest
@@ -1,347 +1,347 @@
-------------------------------------------------------------------------
--- ddAnd.decTest -- digitwise logical AND for decDoubles --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check (truth table)
-ddand001 and 0 0 -> 0
-ddand002 and 0 1 -> 0
-ddand003 and 1 0 -> 0
-ddand004 and 1 1 -> 1
-ddand005 and 1100 1010 -> 1000
--- and at msd and msd-1
--- 1234567890123456 1234567890123456 1234567890123456
-ddand006 and 0000000000000000 0000000000000000 -> 0
-ddand007 and 0000000000000000 1000000000000000 -> 0
-ddand008 and 1000000000000000 0000000000000000 -> 0
-ddand009 and 1000000000000000 1000000000000000 -> 1000000000000000
-ddand010 and 0000000000000000 0000000000000000 -> 0
-ddand011 and 0000000000000000 0100000000000000 -> 0
-ddand012 and 0100000000000000 0000000000000000 -> 0
-ddand013 and 0100000000000000 0100000000000000 -> 100000000000000
-
--- Various lengths
--- 1234567890123456 1234567890123456 1234567890123456
-ddand021 and 1111111111111111 1111111111111111 -> 1111111111111111
-ddand024 and 1111111111111111 111111111111111 -> 111111111111111
-ddand025 and 1111111111111111 11111111111111 -> 11111111111111
-ddand026 and 1111111111111111 1111111111111 -> 1111111111111
-ddand027 and 1111111111111111 111111111111 -> 111111111111
-ddand028 and 1111111111111111 11111111111 -> 11111111111
-ddand029 and 1111111111111111 1111111111 -> 1111111111
-ddand030 and 1111111111111111 111111111 -> 111111111
-ddand031 and 1111111111111111 11111111 -> 11111111
-ddand032 and 1111111111111111 1111111 -> 1111111
-ddand033 and 1111111111111111 111111 -> 111111
-ddand034 and 1111111111111111 11111 -> 11111
-ddand035 and 1111111111111111 1111 -> 1111
-ddand036 and 1111111111111111 111 -> 111
-ddand037 and 1111111111111111 11 -> 11
-ddand038 and 1111111111111111 1 -> 1
-ddand039 and 1111111111111111 0 -> 0
-
-ddand040 and 1111111111111111 1111111111111111 -> 1111111111111111
-ddand041 and 111111111111111 1111111111111111 -> 111111111111111
-ddand042 and 111111111111111 1111111111111111 -> 111111111111111
-ddand043 and 11111111111111 1111111111111111 -> 11111111111111
-ddand044 and 1111111111111 1111111111111111 -> 1111111111111
-ddand045 and 111111111111 1111111111111111 -> 111111111111
-ddand046 and 11111111111 1111111111111111 -> 11111111111
-ddand047 and 1111111111 1111111111111111 -> 1111111111
-ddand048 and 111111111 1111111111111111 -> 111111111
-ddand049 and 11111111 1111111111111111 -> 11111111
-ddand050 and 1111111 1111111111111111 -> 1111111
-ddand051 and 111111 1111111111111111 -> 111111
-ddand052 and 11111 1111111111111111 -> 11111
-ddand053 and 1111 1111111111111111 -> 1111
-ddand054 and 111 1111111111111111 -> 111
-ddand055 and 11 1111111111111111 -> 11
-ddand056 and 1 1111111111111111 -> 1
-ddand057 and 0 1111111111111111 -> 0
-
-ddand150 and 1111111111 1 -> 1
-ddand151 and 111111111 1 -> 1
-ddand152 and 11111111 1 -> 1
-ddand153 and 1111111 1 -> 1
-ddand154 and 111111 1 -> 1
-ddand155 and 11111 1 -> 1
-ddand156 and 1111 1 -> 1
-ddand157 and 111 1 -> 1
-ddand158 and 11 1 -> 1
-ddand159 and 1 1 -> 1
-
-ddand160 and 1111111111 0 -> 0
-ddand161 and 111111111 0 -> 0
-ddand162 and 11111111 0 -> 0
-ddand163 and 1111111 0 -> 0
-ddand164 and 111111 0 -> 0
-ddand165 and 11111 0 -> 0
-ddand166 and 1111 0 -> 0
-ddand167 and 111 0 -> 0
-ddand168 and 11 0 -> 0
-ddand169 and 1 0 -> 0
-
-ddand170 and 1 1111111111 -> 1
-ddand171 and 1 111111111 -> 1
-ddand172 and 1 11111111 -> 1
-ddand173 and 1 1111111 -> 1
-ddand174 and 1 111111 -> 1
-ddand175 and 1 11111 -> 1
-ddand176 and 1 1111 -> 1
-ddand177 and 1 111 -> 1
-ddand178 and 1 11 -> 1
-ddand179 and 1 1 -> 1
-
-ddand180 and 0 1111111111 -> 0
-ddand181 and 0 111111111 -> 0
-ddand182 and 0 11111111 -> 0
-ddand183 and 0 1111111 -> 0
-ddand184 and 0 111111 -> 0
-ddand185 and 0 11111 -> 0
-ddand186 and 0 1111 -> 0
-ddand187 and 0 111 -> 0
-ddand188 and 0 11 -> 0
-ddand189 and 0 1 -> 0
-
-ddand090 and 011111111 111111111 -> 11111111
-ddand091 and 101111111 111111111 -> 101111111
-ddand092 and 110111111 111111111 -> 110111111
-ddand093 and 111011111 111111111 -> 111011111
-ddand094 and 111101111 111111111 -> 111101111
-ddand095 and 111110111 111111111 -> 111110111
-ddand096 and 111111011 111111111 -> 111111011
-ddand097 and 111111101 111111111 -> 111111101
-ddand098 and 111111110 111111111 -> 111111110
-
-ddand100 and 111111111 011111111 -> 11111111
-ddand101 and 111111111 101111111 -> 101111111
-ddand102 and 111111111 110111111 -> 110111111
-ddand103 and 111111111 111011111 -> 111011111
-ddand104 and 111111111 111101111 -> 111101111
-ddand105 and 111111111 111110111 -> 111110111
-ddand106 and 111111111 111111011 -> 111111011
-ddand107 and 111111111 111111101 -> 111111101
-ddand108 and 111111111 111111110 -> 111111110
-
--- non-0/1 should not be accepted, nor should signs
-ddand220 and 111111112 111111111 -> NaN Invalid_operation
-ddand221 and 333333333 333333333 -> NaN Invalid_operation
-ddand222 and 555555555 555555555 -> NaN Invalid_operation
-ddand223 and 777777777 777777777 -> NaN Invalid_operation
-ddand224 and 999999999 999999999 -> NaN Invalid_operation
-ddand225 and 222222222 999999999 -> NaN Invalid_operation
-ddand226 and 444444444 999999999 -> NaN Invalid_operation
-ddand227 and 666666666 999999999 -> NaN Invalid_operation
-ddand228 and 888888888 999999999 -> NaN Invalid_operation
-ddand229 and 999999999 222222222 -> NaN Invalid_operation
-ddand230 and 999999999 444444444 -> NaN Invalid_operation
-ddand231 and 999999999 666666666 -> NaN Invalid_operation
-ddand232 and 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-ddand240 and 567468689 -934981942 -> NaN Invalid_operation
-ddand241 and 567367689 934981942 -> NaN Invalid_operation
-ddand242 and -631917772 -706014634 -> NaN Invalid_operation
-ddand243 and -756253257 138579234 -> NaN Invalid_operation
-ddand244 and 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-ddand250 and 2000000000000000 1000000000000000 -> NaN Invalid_operation
-ddand251 and 7000000000000000 1000000000000000 -> NaN Invalid_operation
-ddand252 and 8000000000000000 1000000000000000 -> NaN Invalid_operation
-ddand253 and 9000000000000000 1000000000000000 -> NaN Invalid_operation
-ddand254 and 2000000000000000 0000000000000000 -> NaN Invalid_operation
-ddand255 and 7000000000000000 0000000000000000 -> NaN Invalid_operation
-ddand256 and 8000000000000000 0000000000000000 -> NaN Invalid_operation
-ddand257 and 9000000000000000 0000000000000000 -> NaN Invalid_operation
-ddand258 and 1000000000000000 2000000000000000 -> NaN Invalid_operation
-ddand259 and 1000000000000000 7000000000000000 -> NaN Invalid_operation
-ddand260 and 1000000000000000 8000000000000000 -> NaN Invalid_operation
-ddand261 and 1000000000000000 9000000000000000 -> NaN Invalid_operation
-ddand262 and 0000000000000000 2000000000000000 -> NaN Invalid_operation
-ddand263 and 0000000000000000 7000000000000000 -> NaN Invalid_operation
-ddand264 and 0000000000000000 8000000000000000 -> NaN Invalid_operation
-ddand265 and 0000000000000000 9000000000000000 -> NaN Invalid_operation
--- test MSD-1
-ddand270 and 0200001000000000 1000100000000010 -> NaN Invalid_operation
-ddand271 and 0700000100000000 1000010000000100 -> NaN Invalid_operation
-ddand272 and 0800000010000000 1000001000001000 -> NaN Invalid_operation
-ddand273 and 0900000001000000 1000000100010000 -> NaN Invalid_operation
-ddand274 and 1000000000100000 0200000010100000 -> NaN Invalid_operation
-ddand275 and 1000000000010000 0700000001000000 -> NaN Invalid_operation
-ddand276 and 1000000000001000 0800000010100000 -> NaN Invalid_operation
-ddand277 and 1000000000000100 0900000000010000 -> NaN Invalid_operation
--- test LSD
-ddand280 and 0010000000000002 1000000100000001 -> NaN Invalid_operation
-ddand281 and 0001000000000007 1000001000000011 -> NaN Invalid_operation
-ddand282 and 0000100000000008 1000010000000001 -> NaN Invalid_operation
-ddand283 and 0000010000000009 1000100000000001 -> NaN Invalid_operation
-ddand284 and 1000001000000000 0001000000000002 -> NaN Invalid_operation
-ddand285 and 1000000100000000 0010000000000007 -> NaN Invalid_operation
-ddand286 and 1000000010000000 0100000000000008 -> NaN Invalid_operation
-ddand287 and 1000000001000000 1000000000000009 -> NaN Invalid_operation
--- test Middie
-ddand288 and 0010000020000000 1000001000000000 -> NaN Invalid_operation
-ddand289 and 0001000070000001 1000000100000000 -> NaN Invalid_operation
-ddand290 and 0000100080000010 1000000010000000 -> NaN Invalid_operation
-ddand291 and 0000010090000100 1000000001000000 -> NaN Invalid_operation
-ddand292 and 1000001000001000 0000000020100000 -> NaN Invalid_operation
-ddand293 and 1000000100010000 0000000070010000 -> NaN Invalid_operation
-ddand294 and 1000000010100000 0000000080001000 -> NaN Invalid_operation
-ddand295 and 1000000001000000 0000000090000100 -> NaN Invalid_operation
--- signs
-ddand296 and -1000000001000000 -0000010000000100 -> NaN Invalid_operation
-ddand297 and -1000000001000000 0000000010000100 -> NaN Invalid_operation
-ddand298 and 1000000001000000 -0000001000000100 -> NaN Invalid_operation
-ddand299 and 1000000001000000 0000000011000100 -> 1000000
-
--- Nmax, Nmin, Ntiny-like
-ddand331 and 2 9.99999999E+199 -> NaN Invalid_operation
-ddand332 and 3 1E-199 -> NaN Invalid_operation
-ddand333 and 4 1.00000000E-199 -> NaN Invalid_operation
-ddand334 and 5 1E-100 -> NaN Invalid_operation
-ddand335 and 6 -1E-100 -> NaN Invalid_operation
-ddand336 and 7 -1.00000000E-199 -> NaN Invalid_operation
-ddand337 and 8 -1E-199 -> NaN Invalid_operation
-ddand338 and 9 -9.99999999E+199 -> NaN Invalid_operation
-ddand341 and 9.99999999E+199 -18 -> NaN Invalid_operation
-ddand342 and 1E-199 01 -> NaN Invalid_operation
-ddand343 and 1.00000000E-199 -18 -> NaN Invalid_operation
-ddand344 and 1E-100 18 -> NaN Invalid_operation
-ddand345 and -1E-100 -10 -> NaN Invalid_operation
-ddand346 and -1.00000000E-199 18 -> NaN Invalid_operation
-ddand347 and -1E-199 10 -> NaN Invalid_operation
-ddand348 and -9.99999999E+199 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-ddand361 and 1.0 1 -> NaN Invalid_operation
-ddand362 and 1E+1 1 -> NaN Invalid_operation
-ddand363 and 0.0 1 -> NaN Invalid_operation
-ddand364 and 0E+1 1 -> NaN Invalid_operation
-ddand365 and 9.9 1 -> NaN Invalid_operation
-ddand366 and 9E+1 1 -> NaN Invalid_operation
-ddand371 and 0 1.0 -> NaN Invalid_operation
-ddand372 and 0 1E+1 -> NaN Invalid_operation
-ddand373 and 0 0.0 -> NaN Invalid_operation
-ddand374 and 0 0E+1 -> NaN Invalid_operation
-ddand375 and 0 9.9 -> NaN Invalid_operation
-ddand376 and 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-ddand780 and -Inf -Inf -> NaN Invalid_operation
-ddand781 and -Inf -1000 -> NaN Invalid_operation
-ddand782 and -Inf -1 -> NaN Invalid_operation
-ddand783 and -Inf -0 -> NaN Invalid_operation
-ddand784 and -Inf 0 -> NaN Invalid_operation
-ddand785 and -Inf 1 -> NaN Invalid_operation
-ddand786 and -Inf 1000 -> NaN Invalid_operation
-ddand787 and -1000 -Inf -> NaN Invalid_operation
-ddand788 and -Inf -Inf -> NaN Invalid_operation
-ddand789 and -1 -Inf -> NaN Invalid_operation
-ddand790 and -0 -Inf -> NaN Invalid_operation
-ddand791 and 0 -Inf -> NaN Invalid_operation
-ddand792 and 1 -Inf -> NaN Invalid_operation
-ddand793 and 1000 -Inf -> NaN Invalid_operation
-ddand794 and Inf -Inf -> NaN Invalid_operation
-
-ddand800 and Inf -Inf -> NaN Invalid_operation
-ddand801 and Inf -1000 -> NaN Invalid_operation
-ddand802 and Inf -1 -> NaN Invalid_operation
-ddand803 and Inf -0 -> NaN Invalid_operation
-ddand804 and Inf 0 -> NaN Invalid_operation
-ddand805 and Inf 1 -> NaN Invalid_operation
-ddand806 and Inf 1000 -> NaN Invalid_operation
-ddand807 and Inf Inf -> NaN Invalid_operation
-ddand808 and -1000 Inf -> NaN Invalid_operation
-ddand809 and -Inf Inf -> NaN Invalid_operation
-ddand810 and -1 Inf -> NaN Invalid_operation
-ddand811 and -0 Inf -> NaN Invalid_operation
-ddand812 and 0 Inf -> NaN Invalid_operation
-ddand813 and 1 Inf -> NaN Invalid_operation
-ddand814 and 1000 Inf -> NaN Invalid_operation
-ddand815 and Inf Inf -> NaN Invalid_operation
-
-ddand821 and NaN -Inf -> NaN Invalid_operation
-ddand822 and NaN -1000 -> NaN Invalid_operation
-ddand823 and NaN -1 -> NaN Invalid_operation
-ddand824 and NaN -0 -> NaN Invalid_operation
-ddand825 and NaN 0 -> NaN Invalid_operation
-ddand826 and NaN 1 -> NaN Invalid_operation
-ddand827 and NaN 1000 -> NaN Invalid_operation
-ddand828 and NaN Inf -> NaN Invalid_operation
-ddand829 and NaN NaN -> NaN Invalid_operation
-ddand830 and -Inf NaN -> NaN Invalid_operation
-ddand831 and -1000 NaN -> NaN Invalid_operation
-ddand832 and -1 NaN -> NaN Invalid_operation
-ddand833 and -0 NaN -> NaN Invalid_operation
-ddand834 and 0 NaN -> NaN Invalid_operation
-ddand835 and 1 NaN -> NaN Invalid_operation
-ddand836 and 1000 NaN -> NaN Invalid_operation
-ddand837 and Inf NaN -> NaN Invalid_operation
-
-ddand841 and sNaN -Inf -> NaN Invalid_operation
-ddand842 and sNaN -1000 -> NaN Invalid_operation
-ddand843 and sNaN -1 -> NaN Invalid_operation
-ddand844 and sNaN -0 -> NaN Invalid_operation
-ddand845 and sNaN 0 -> NaN Invalid_operation
-ddand846 and sNaN 1 -> NaN Invalid_operation
-ddand847 and sNaN 1000 -> NaN Invalid_operation
-ddand848 and sNaN NaN -> NaN Invalid_operation
-ddand849 and sNaN sNaN -> NaN Invalid_operation
-ddand850 and NaN sNaN -> NaN Invalid_operation
-ddand851 and -Inf sNaN -> NaN Invalid_operation
-ddand852 and -1000 sNaN -> NaN Invalid_operation
-ddand853 and -1 sNaN -> NaN Invalid_operation
-ddand854 and -0 sNaN -> NaN Invalid_operation
-ddand855 and 0 sNaN -> NaN Invalid_operation
-ddand856 and 1 sNaN -> NaN Invalid_operation
-ddand857 and 1000 sNaN -> NaN Invalid_operation
-ddand858 and Inf sNaN -> NaN Invalid_operation
-ddand859 and NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddand861 and NaN1 -Inf -> NaN Invalid_operation
-ddand862 and +NaN2 -1000 -> NaN Invalid_operation
-ddand863 and NaN3 1000 -> NaN Invalid_operation
-ddand864 and NaN4 Inf -> NaN Invalid_operation
-ddand865 and NaN5 +NaN6 -> NaN Invalid_operation
-ddand866 and -Inf NaN7 -> NaN Invalid_operation
-ddand867 and -1000 NaN8 -> NaN Invalid_operation
-ddand868 and 1000 NaN9 -> NaN Invalid_operation
-ddand869 and Inf +NaN10 -> NaN Invalid_operation
-ddand871 and sNaN11 -Inf -> NaN Invalid_operation
-ddand872 and sNaN12 -1000 -> NaN Invalid_operation
-ddand873 and sNaN13 1000 -> NaN Invalid_operation
-ddand874 and sNaN14 NaN17 -> NaN Invalid_operation
-ddand875 and sNaN15 sNaN18 -> NaN Invalid_operation
-ddand876 and NaN16 sNaN19 -> NaN Invalid_operation
-ddand877 and -Inf +sNaN20 -> NaN Invalid_operation
-ddand878 and -1000 sNaN21 -> NaN Invalid_operation
-ddand879 and 1000 sNaN22 -> NaN Invalid_operation
-ddand880 and Inf sNaN23 -> NaN Invalid_operation
-ddand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
-ddand882 and -NaN26 NaN28 -> NaN Invalid_operation
-ddand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
-ddand884 and 1000 -NaN30 -> NaN Invalid_operation
-ddand885 and 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddAnd.decTest -- digitwise logical AND for decDoubles --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check (truth table)
+ddand001 and 0 0 -> 0
+ddand002 and 0 1 -> 0
+ddand003 and 1 0 -> 0
+ddand004 and 1 1 -> 1
+ddand005 and 1100 1010 -> 1000
+-- and at msd and msd-1
+-- 1234567890123456 1234567890123456 1234567890123456
+ddand006 and 0000000000000000 0000000000000000 -> 0
+ddand007 and 0000000000000000 1000000000000000 -> 0
+ddand008 and 1000000000000000 0000000000000000 -> 0
+ddand009 and 1000000000000000 1000000000000000 -> 1000000000000000
+ddand010 and 0000000000000000 0000000000000000 -> 0
+ddand011 and 0000000000000000 0100000000000000 -> 0
+ddand012 and 0100000000000000 0000000000000000 -> 0
+ddand013 and 0100000000000000 0100000000000000 -> 100000000000000
+
+-- Various lengths
+-- 1234567890123456 1234567890123456 1234567890123456
+ddand021 and 1111111111111111 1111111111111111 -> 1111111111111111
+ddand024 and 1111111111111111 111111111111111 -> 111111111111111
+ddand025 and 1111111111111111 11111111111111 -> 11111111111111
+ddand026 and 1111111111111111 1111111111111 -> 1111111111111
+ddand027 and 1111111111111111 111111111111 -> 111111111111
+ddand028 and 1111111111111111 11111111111 -> 11111111111
+ddand029 and 1111111111111111 1111111111 -> 1111111111
+ddand030 and 1111111111111111 111111111 -> 111111111
+ddand031 and 1111111111111111 11111111 -> 11111111
+ddand032 and 1111111111111111 1111111 -> 1111111
+ddand033 and 1111111111111111 111111 -> 111111
+ddand034 and 1111111111111111 11111 -> 11111
+ddand035 and 1111111111111111 1111 -> 1111
+ddand036 and 1111111111111111 111 -> 111
+ddand037 and 1111111111111111 11 -> 11
+ddand038 and 1111111111111111 1 -> 1
+ddand039 and 1111111111111111 0 -> 0
+
+ddand040 and 1111111111111111 1111111111111111 -> 1111111111111111
+ddand041 and 111111111111111 1111111111111111 -> 111111111111111
+ddand042 and 111111111111111 1111111111111111 -> 111111111111111
+ddand043 and 11111111111111 1111111111111111 -> 11111111111111
+ddand044 and 1111111111111 1111111111111111 -> 1111111111111
+ddand045 and 111111111111 1111111111111111 -> 111111111111
+ddand046 and 11111111111 1111111111111111 -> 11111111111
+ddand047 and 1111111111 1111111111111111 -> 1111111111
+ddand048 and 111111111 1111111111111111 -> 111111111
+ddand049 and 11111111 1111111111111111 -> 11111111
+ddand050 and 1111111 1111111111111111 -> 1111111
+ddand051 and 111111 1111111111111111 -> 111111
+ddand052 and 11111 1111111111111111 -> 11111
+ddand053 and 1111 1111111111111111 -> 1111
+ddand054 and 111 1111111111111111 -> 111
+ddand055 and 11 1111111111111111 -> 11
+ddand056 and 1 1111111111111111 -> 1
+ddand057 and 0 1111111111111111 -> 0
+
+ddand150 and 1111111111 1 -> 1
+ddand151 and 111111111 1 -> 1
+ddand152 and 11111111 1 -> 1
+ddand153 and 1111111 1 -> 1
+ddand154 and 111111 1 -> 1
+ddand155 and 11111 1 -> 1
+ddand156 and 1111 1 -> 1
+ddand157 and 111 1 -> 1
+ddand158 and 11 1 -> 1
+ddand159 and 1 1 -> 1
+
+ddand160 and 1111111111 0 -> 0
+ddand161 and 111111111 0 -> 0
+ddand162 and 11111111 0 -> 0
+ddand163 and 1111111 0 -> 0
+ddand164 and 111111 0 -> 0
+ddand165 and 11111 0 -> 0
+ddand166 and 1111 0 -> 0
+ddand167 and 111 0 -> 0
+ddand168 and 11 0 -> 0
+ddand169 and 1 0 -> 0
+
+ddand170 and 1 1111111111 -> 1
+ddand171 and 1 111111111 -> 1
+ddand172 and 1 11111111 -> 1
+ddand173 and 1 1111111 -> 1
+ddand174 and 1 111111 -> 1
+ddand175 and 1 11111 -> 1
+ddand176 and 1 1111 -> 1
+ddand177 and 1 111 -> 1
+ddand178 and 1 11 -> 1
+ddand179 and 1 1 -> 1
+
+ddand180 and 0 1111111111 -> 0
+ddand181 and 0 111111111 -> 0
+ddand182 and 0 11111111 -> 0
+ddand183 and 0 1111111 -> 0
+ddand184 and 0 111111 -> 0
+ddand185 and 0 11111 -> 0
+ddand186 and 0 1111 -> 0
+ddand187 and 0 111 -> 0
+ddand188 and 0 11 -> 0
+ddand189 and 0 1 -> 0
+
+ddand090 and 011111111 111111111 -> 11111111
+ddand091 and 101111111 111111111 -> 101111111
+ddand092 and 110111111 111111111 -> 110111111
+ddand093 and 111011111 111111111 -> 111011111
+ddand094 and 111101111 111111111 -> 111101111
+ddand095 and 111110111 111111111 -> 111110111
+ddand096 and 111111011 111111111 -> 111111011
+ddand097 and 111111101 111111111 -> 111111101
+ddand098 and 111111110 111111111 -> 111111110
+
+ddand100 and 111111111 011111111 -> 11111111
+ddand101 and 111111111 101111111 -> 101111111
+ddand102 and 111111111 110111111 -> 110111111
+ddand103 and 111111111 111011111 -> 111011111
+ddand104 and 111111111 111101111 -> 111101111
+ddand105 and 111111111 111110111 -> 111110111
+ddand106 and 111111111 111111011 -> 111111011
+ddand107 and 111111111 111111101 -> 111111101
+ddand108 and 111111111 111111110 -> 111111110
+
+-- non-0/1 should not be accepted, nor should signs
+ddand220 and 111111112 111111111 -> NaN Invalid_operation
+ddand221 and 333333333 333333333 -> NaN Invalid_operation
+ddand222 and 555555555 555555555 -> NaN Invalid_operation
+ddand223 and 777777777 777777777 -> NaN Invalid_operation
+ddand224 and 999999999 999999999 -> NaN Invalid_operation
+ddand225 and 222222222 999999999 -> NaN Invalid_operation
+ddand226 and 444444444 999999999 -> NaN Invalid_operation
+ddand227 and 666666666 999999999 -> NaN Invalid_operation
+ddand228 and 888888888 999999999 -> NaN Invalid_operation
+ddand229 and 999999999 222222222 -> NaN Invalid_operation
+ddand230 and 999999999 444444444 -> NaN Invalid_operation
+ddand231 and 999999999 666666666 -> NaN Invalid_operation
+ddand232 and 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+ddand240 and 567468689 -934981942 -> NaN Invalid_operation
+ddand241 and 567367689 934981942 -> NaN Invalid_operation
+ddand242 and -631917772 -706014634 -> NaN Invalid_operation
+ddand243 and -756253257 138579234 -> NaN Invalid_operation
+ddand244 and 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+ddand250 and 2000000000000000 1000000000000000 -> NaN Invalid_operation
+ddand251 and 7000000000000000 1000000000000000 -> NaN Invalid_operation
+ddand252 and 8000000000000000 1000000000000000 -> NaN Invalid_operation
+ddand253 and 9000000000000000 1000000000000000 -> NaN Invalid_operation
+ddand254 and 2000000000000000 0000000000000000 -> NaN Invalid_operation
+ddand255 and 7000000000000000 0000000000000000 -> NaN Invalid_operation
+ddand256 and 8000000000000000 0000000000000000 -> NaN Invalid_operation
+ddand257 and 9000000000000000 0000000000000000 -> NaN Invalid_operation
+ddand258 and 1000000000000000 2000000000000000 -> NaN Invalid_operation
+ddand259 and 1000000000000000 7000000000000000 -> NaN Invalid_operation
+ddand260 and 1000000000000000 8000000000000000 -> NaN Invalid_operation
+ddand261 and 1000000000000000 9000000000000000 -> NaN Invalid_operation
+ddand262 and 0000000000000000 2000000000000000 -> NaN Invalid_operation
+ddand263 and 0000000000000000 7000000000000000 -> NaN Invalid_operation
+ddand264 and 0000000000000000 8000000000000000 -> NaN Invalid_operation
+ddand265 and 0000000000000000 9000000000000000 -> NaN Invalid_operation
+-- test MSD-1
+ddand270 and 0200001000000000 1000100000000010 -> NaN Invalid_operation
+ddand271 and 0700000100000000 1000010000000100 -> NaN Invalid_operation
+ddand272 and 0800000010000000 1000001000001000 -> NaN Invalid_operation
+ddand273 and 0900000001000000 1000000100010000 -> NaN Invalid_operation
+ddand274 and 1000000000100000 0200000010100000 -> NaN Invalid_operation
+ddand275 and 1000000000010000 0700000001000000 -> NaN Invalid_operation
+ddand276 and 1000000000001000 0800000010100000 -> NaN Invalid_operation
+ddand277 and 1000000000000100 0900000000010000 -> NaN Invalid_operation
+-- test LSD
+ddand280 and 0010000000000002 1000000100000001 -> NaN Invalid_operation
+ddand281 and 0001000000000007 1000001000000011 -> NaN Invalid_operation
+ddand282 and 0000100000000008 1000010000000001 -> NaN Invalid_operation
+ddand283 and 0000010000000009 1000100000000001 -> NaN Invalid_operation
+ddand284 and 1000001000000000 0001000000000002 -> NaN Invalid_operation
+ddand285 and 1000000100000000 0010000000000007 -> NaN Invalid_operation
+ddand286 and 1000000010000000 0100000000000008 -> NaN Invalid_operation
+ddand287 and 1000000001000000 1000000000000009 -> NaN Invalid_operation
+-- test Middie
+ddand288 and 0010000020000000 1000001000000000 -> NaN Invalid_operation
+ddand289 and 0001000070000001 1000000100000000 -> NaN Invalid_operation
+ddand290 and 0000100080000010 1000000010000000 -> NaN Invalid_operation
+ddand291 and 0000010090000100 1000000001000000 -> NaN Invalid_operation
+ddand292 and 1000001000001000 0000000020100000 -> NaN Invalid_operation
+ddand293 and 1000000100010000 0000000070010000 -> NaN Invalid_operation
+ddand294 and 1000000010100000 0000000080001000 -> NaN Invalid_operation
+ddand295 and 1000000001000000 0000000090000100 -> NaN Invalid_operation
+-- signs
+ddand296 and -1000000001000000 -0000010000000100 -> NaN Invalid_operation
+ddand297 and -1000000001000000 0000000010000100 -> NaN Invalid_operation
+ddand298 and 1000000001000000 -0000001000000100 -> NaN Invalid_operation
+ddand299 and 1000000001000000 0000000011000100 -> 1000000
+
+-- Nmax, Nmin, Ntiny-like
+ddand331 and 2 9.99999999E+199 -> NaN Invalid_operation
+ddand332 and 3 1E-199 -> NaN Invalid_operation
+ddand333 and 4 1.00000000E-199 -> NaN Invalid_operation
+ddand334 and 5 1E-100 -> NaN Invalid_operation
+ddand335 and 6 -1E-100 -> NaN Invalid_operation
+ddand336 and 7 -1.00000000E-199 -> NaN Invalid_operation
+ddand337 and 8 -1E-199 -> NaN Invalid_operation
+ddand338 and 9 -9.99999999E+199 -> NaN Invalid_operation
+ddand341 and 9.99999999E+199 -18 -> NaN Invalid_operation
+ddand342 and 1E-199 01 -> NaN Invalid_operation
+ddand343 and 1.00000000E-199 -18 -> NaN Invalid_operation
+ddand344 and 1E-100 18 -> NaN Invalid_operation
+ddand345 and -1E-100 -10 -> NaN Invalid_operation
+ddand346 and -1.00000000E-199 18 -> NaN Invalid_operation
+ddand347 and -1E-199 10 -> NaN Invalid_operation
+ddand348 and -9.99999999E+199 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+ddand361 and 1.0 1 -> NaN Invalid_operation
+ddand362 and 1E+1 1 -> NaN Invalid_operation
+ddand363 and 0.0 1 -> NaN Invalid_operation
+ddand364 and 0E+1 1 -> NaN Invalid_operation
+ddand365 and 9.9 1 -> NaN Invalid_operation
+ddand366 and 9E+1 1 -> NaN Invalid_operation
+ddand371 and 0 1.0 -> NaN Invalid_operation
+ddand372 and 0 1E+1 -> NaN Invalid_operation
+ddand373 and 0 0.0 -> NaN Invalid_operation
+ddand374 and 0 0E+1 -> NaN Invalid_operation
+ddand375 and 0 9.9 -> NaN Invalid_operation
+ddand376 and 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+ddand780 and -Inf -Inf -> NaN Invalid_operation
+ddand781 and -Inf -1000 -> NaN Invalid_operation
+ddand782 and -Inf -1 -> NaN Invalid_operation
+ddand783 and -Inf -0 -> NaN Invalid_operation
+ddand784 and -Inf 0 -> NaN Invalid_operation
+ddand785 and -Inf 1 -> NaN Invalid_operation
+ddand786 and -Inf 1000 -> NaN Invalid_operation
+ddand787 and -1000 -Inf -> NaN Invalid_operation
+ddand788 and -Inf -Inf -> NaN Invalid_operation
+ddand789 and -1 -Inf -> NaN Invalid_operation
+ddand790 and -0 -Inf -> NaN Invalid_operation
+ddand791 and 0 -Inf -> NaN Invalid_operation
+ddand792 and 1 -Inf -> NaN Invalid_operation
+ddand793 and 1000 -Inf -> NaN Invalid_operation
+ddand794 and Inf -Inf -> NaN Invalid_operation
+
+ddand800 and Inf -Inf -> NaN Invalid_operation
+ddand801 and Inf -1000 -> NaN Invalid_operation
+ddand802 and Inf -1 -> NaN Invalid_operation
+ddand803 and Inf -0 -> NaN Invalid_operation
+ddand804 and Inf 0 -> NaN Invalid_operation
+ddand805 and Inf 1 -> NaN Invalid_operation
+ddand806 and Inf 1000 -> NaN Invalid_operation
+ddand807 and Inf Inf -> NaN Invalid_operation
+ddand808 and -1000 Inf -> NaN Invalid_operation
+ddand809 and -Inf Inf -> NaN Invalid_operation
+ddand810 and -1 Inf -> NaN Invalid_operation
+ddand811 and -0 Inf -> NaN Invalid_operation
+ddand812 and 0 Inf -> NaN Invalid_operation
+ddand813 and 1 Inf -> NaN Invalid_operation
+ddand814 and 1000 Inf -> NaN Invalid_operation
+ddand815 and Inf Inf -> NaN Invalid_operation
+
+ddand821 and NaN -Inf -> NaN Invalid_operation
+ddand822 and NaN -1000 -> NaN Invalid_operation
+ddand823 and NaN -1 -> NaN Invalid_operation
+ddand824 and NaN -0 -> NaN Invalid_operation
+ddand825 and NaN 0 -> NaN Invalid_operation
+ddand826 and NaN 1 -> NaN Invalid_operation
+ddand827 and NaN 1000 -> NaN Invalid_operation
+ddand828 and NaN Inf -> NaN Invalid_operation
+ddand829 and NaN NaN -> NaN Invalid_operation
+ddand830 and -Inf NaN -> NaN Invalid_operation
+ddand831 and -1000 NaN -> NaN Invalid_operation
+ddand832 and -1 NaN -> NaN Invalid_operation
+ddand833 and -0 NaN -> NaN Invalid_operation
+ddand834 and 0 NaN -> NaN Invalid_operation
+ddand835 and 1 NaN -> NaN Invalid_operation
+ddand836 and 1000 NaN -> NaN Invalid_operation
+ddand837 and Inf NaN -> NaN Invalid_operation
+
+ddand841 and sNaN -Inf -> NaN Invalid_operation
+ddand842 and sNaN -1000 -> NaN Invalid_operation
+ddand843 and sNaN -1 -> NaN Invalid_operation
+ddand844 and sNaN -0 -> NaN Invalid_operation
+ddand845 and sNaN 0 -> NaN Invalid_operation
+ddand846 and sNaN 1 -> NaN Invalid_operation
+ddand847 and sNaN 1000 -> NaN Invalid_operation
+ddand848 and sNaN NaN -> NaN Invalid_operation
+ddand849 and sNaN sNaN -> NaN Invalid_operation
+ddand850 and NaN sNaN -> NaN Invalid_operation
+ddand851 and -Inf sNaN -> NaN Invalid_operation
+ddand852 and -1000 sNaN -> NaN Invalid_operation
+ddand853 and -1 sNaN -> NaN Invalid_operation
+ddand854 and -0 sNaN -> NaN Invalid_operation
+ddand855 and 0 sNaN -> NaN Invalid_operation
+ddand856 and 1 sNaN -> NaN Invalid_operation
+ddand857 and 1000 sNaN -> NaN Invalid_operation
+ddand858 and Inf sNaN -> NaN Invalid_operation
+ddand859 and NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddand861 and NaN1 -Inf -> NaN Invalid_operation
+ddand862 and +NaN2 -1000 -> NaN Invalid_operation
+ddand863 and NaN3 1000 -> NaN Invalid_operation
+ddand864 and NaN4 Inf -> NaN Invalid_operation
+ddand865 and NaN5 +NaN6 -> NaN Invalid_operation
+ddand866 and -Inf NaN7 -> NaN Invalid_operation
+ddand867 and -1000 NaN8 -> NaN Invalid_operation
+ddand868 and 1000 NaN9 -> NaN Invalid_operation
+ddand869 and Inf +NaN10 -> NaN Invalid_operation
+ddand871 and sNaN11 -Inf -> NaN Invalid_operation
+ddand872 and sNaN12 -1000 -> NaN Invalid_operation
+ddand873 and sNaN13 1000 -> NaN Invalid_operation
+ddand874 and sNaN14 NaN17 -> NaN Invalid_operation
+ddand875 and sNaN15 sNaN18 -> NaN Invalid_operation
+ddand876 and NaN16 sNaN19 -> NaN Invalid_operation
+ddand877 and -Inf +sNaN20 -> NaN Invalid_operation
+ddand878 and -1000 sNaN21 -> NaN Invalid_operation
+ddand879 and 1000 sNaN22 -> NaN Invalid_operation
+ddand880 and Inf sNaN23 -> NaN Invalid_operation
+ddand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
+ddand882 and -NaN26 NaN28 -> NaN Invalid_operation
+ddand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
+ddand884 and 1000 -NaN30 -> NaN Invalid_operation
+ddand885 and 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddBase.decTest b/Lib/test/decimaltestdata/ddBase.decTest
index 40febf86c5..fbd6ccd94d 100644
--- a/Lib/test/decimaltestdata/ddBase.decTest
+++ b/Lib/test/decimaltestdata/ddBase.decTest
@@ -1,1104 +1,1104 @@
-------------------------------------------------------------------------
--- ddBase.decTest -- base decDouble <--> string conversions --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests base conversions from string to a decimal number
--- and back to a string (in Scientific form)
-
--- Note that unlike other operations the operand is subject to rounding
--- to conform to emax and precision settings (that is, numbers will
--- conform to rules and exponent will be in permitted range). The
--- 'left hand side', therefore, may have numbers that cannot be
--- represented in a decDouble. Some testcases go to the limit of the
--- next-wider format, and hence these testcases may also be used to
--- test narrowing and widening operations.
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddbas001 toSci 0 -> 0
-ddbas002 toSci 1 -> 1
-ddbas003 toSci 1.0 -> 1.0
-ddbas004 toSci 1.00 -> 1.00
-ddbas005 toSci 10 -> 10
-ddbas006 toSci 1000 -> 1000
-ddbas007 toSci 10.0 -> 10.0
-ddbas008 toSci 10.1 -> 10.1
-ddbas009 toSci 10.4 -> 10.4
-ddbas010 toSci 10.5 -> 10.5
-ddbas011 toSci 10.6 -> 10.6
-ddbas012 toSci 10.9 -> 10.9
-ddbas013 toSci 11.0 -> 11.0
-ddbas014 toSci 1.234 -> 1.234
-ddbas015 toSci 0.123 -> 0.123
-ddbas016 toSci 0.012 -> 0.012
-ddbas017 toSci -0 -> -0
-ddbas018 toSci -0.0 -> -0.0
-ddbas019 toSci -00.00 -> -0.00
-
-ddbas021 toSci -1 -> -1
-ddbas022 toSci -1.0 -> -1.0
-ddbas023 toSci -0.1 -> -0.1
-ddbas024 toSci -9.1 -> -9.1
-ddbas025 toSci -9.11 -> -9.11
-ddbas026 toSci -9.119 -> -9.119
-ddbas027 toSci -9.999 -> -9.999
-
-ddbas030 toSci '123456789.123456' -> '123456789.123456'
-ddbas031 toSci '123456789.000000' -> '123456789.000000'
-ddbas032 toSci '123456789123456' -> '123456789123456'
-ddbas033 toSci '0.0000123456789' -> '0.0000123456789'
-ddbas034 toSci '0.00000123456789' -> '0.00000123456789'
-ddbas035 toSci '0.000000123456789' -> '1.23456789E-7'
-ddbas036 toSci '0.0000000123456789' -> '1.23456789E-8'
-
-ddbas037 toSci '0.123456789012344' -> '0.123456789012344'
-ddbas038 toSci '0.123456789012345' -> '0.123456789012345'
-
--- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
-ddbsn001 toSci -9.999999999999999E+384 -> -9.999999999999999E+384
-ddbsn002 toSci -1E-383 -> -1E-383
-ddbsn003 toSci -1E-398 -> -1E-398 Subnormal
-ddbsn004 toSci -0 -> -0
-ddbsn005 toSci +0 -> 0
-ddbsn006 toSci +1E-398 -> 1E-398 Subnormal
-ddbsn007 toSci +1E-383 -> 1E-383
-ddbsn008 toSci +9.999999999999999E+384 -> 9.999999999999999E+384
-
--- String [many more examples are implicitly tested elsewhere]
--- strings without E cannot generate E in result
-ddbas040 toSci "12" -> '12'
-ddbas041 toSci "-76" -> '-76'
-ddbas042 toSci "12.76" -> '12.76'
-ddbas043 toSci "+12.76" -> '12.76'
-ddbas044 toSci "012.76" -> '12.76'
-ddbas045 toSci "+0.003" -> '0.003'
-ddbas046 toSci "17." -> '17'
-ddbas047 toSci ".5" -> '0.5'
-ddbas048 toSci "044" -> '44'
-ddbas049 toSci "0044" -> '44'
-ddbas050 toSci "0.0005" -> '0.0005'
-ddbas051 toSci "00.00005" -> '0.00005'
-ddbas052 toSci "0.000005" -> '0.000005'
-ddbas053 toSci "0.0000050" -> '0.0000050'
-ddbas054 toSci "0.0000005" -> '5E-7'
-ddbas055 toSci "0.00000005" -> '5E-8'
-ddbas056 toSci "12345678.543210" -> '12345678.543210'
-ddbas057 toSci "2345678.543210" -> '2345678.543210'
-ddbas058 toSci "345678.543210" -> '345678.543210'
-ddbas059 toSci "0345678.54321" -> '345678.54321'
-ddbas060 toSci "345678.5432" -> '345678.5432'
-ddbas061 toSci "+345678.5432" -> '345678.5432'
-ddbas062 toSci "+0345678.5432" -> '345678.5432'
-ddbas063 toSci "+00345678.5432" -> '345678.5432'
-ddbas064 toSci "-345678.5432" -> '-345678.5432'
-ddbas065 toSci "-0345678.5432" -> '-345678.5432'
-ddbas066 toSci "-00345678.5432" -> '-345678.5432'
--- examples
-ddbas067 toSci "5E-6" -> '0.000005'
-ddbas068 toSci "50E-7" -> '0.0000050'
-ddbas069 toSci "5E-7" -> '5E-7'
-
--- [No exotics as no Unicode]
-
--- rounded with dots in all (including edge) places
-ddbas071 toSci .1234567890123456123 -> 0.1234567890123456 Inexact Rounded
-ddbas072 toSci 1.234567890123456123 -> 1.234567890123456 Inexact Rounded
-ddbas073 toSci 12.34567890123456123 -> 12.34567890123456 Inexact Rounded
-ddbas074 toSci 123.4567890123456123 -> 123.4567890123456 Inexact Rounded
-ddbas075 toSci 1234.567890123456123 -> 1234.567890123456 Inexact Rounded
-ddbas076 toSci 12345.67890123456123 -> 12345.67890123456 Inexact Rounded
-ddbas077 toSci 123456.7890123456123 -> 123456.7890123456 Inexact Rounded
-ddbas078 toSci 1234567.890123456123 -> 1234567.890123456 Inexact Rounded
-ddbas079 toSci 12345678.90123456123 -> 12345678.90123456 Inexact Rounded
-ddbas080 toSci 123456789.0123456123 -> 123456789.0123456 Inexact Rounded
-ddbas081 toSci 1234567890.123456123 -> 1234567890.123456 Inexact Rounded
-ddbas082 toSci 12345678901.23456123 -> 12345678901.23456 Inexact Rounded
-ddbas083 toSci 123456789012.3456123 -> 123456789012.3456 Inexact Rounded
-ddbas084 toSci 1234567890123.456123 -> 1234567890123.456 Inexact Rounded
-ddbas085 toSci 12345678901234.56123 -> 12345678901234.56 Inexact Rounded
-ddbas086 toSci 123456789012345.6123 -> 123456789012345.6 Inexact Rounded
-ddbas087 toSci 1234567890123456.123 -> 1234567890123456 Inexact Rounded
-ddbas088 toSci 12345678901234561.23 -> 1.234567890123456E+16 Inexact Rounded
-ddbas089 toSci 123456789012345612.3 -> 1.234567890123456E+17 Inexact Rounded
-ddbas090 toSci 1234567890123456123. -> 1.234567890123456E+18 Inexact Rounded
-
-
--- Numbers with E
-ddbas130 toSci "0.000E-1" -> '0.0000'
-ddbas131 toSci "0.000E-2" -> '0.00000'
-ddbas132 toSci "0.000E-3" -> '0.000000'
-ddbas133 toSci "0.000E-4" -> '0E-7'
-ddbas134 toSci "0.00E-2" -> '0.0000'
-ddbas135 toSci "0.00E-3" -> '0.00000'
-ddbas136 toSci "0.00E-4" -> '0.000000'
-ddbas137 toSci "0.00E-5" -> '0E-7'
-ddbas138 toSci "+0E+9" -> '0E+9'
-ddbas139 toSci "-0E+9" -> '-0E+9'
-ddbas140 toSci "1E+9" -> '1E+9'
-ddbas141 toSci "1e+09" -> '1E+9'
-ddbas142 toSci "1E+90" -> '1E+90'
-ddbas143 toSci "+1E+009" -> '1E+9'
-ddbas144 toSci "0E+9" -> '0E+9'
-ddbas145 toSci "1E+9" -> '1E+9'
-ddbas146 toSci "1E+09" -> '1E+9'
-ddbas147 toSci "1e+90" -> '1E+90'
-ddbas148 toSci "1E+009" -> '1E+9'
-ddbas149 toSci "000E+9" -> '0E+9'
-ddbas150 toSci "1E9" -> '1E+9'
-ddbas151 toSci "1e09" -> '1E+9'
-ddbas152 toSci "1E90" -> '1E+90'
-ddbas153 toSci "1E009" -> '1E+9'
-ddbas154 toSci "0E9" -> '0E+9'
-ddbas155 toSci "0.000e+0" -> '0.000'
-ddbas156 toSci "0.000E-1" -> '0.0000'
-ddbas157 toSci "4E+9" -> '4E+9'
-ddbas158 toSci "44E+9" -> '4.4E+10'
-ddbas159 toSci "0.73e-7" -> '7.3E-8'
-ddbas160 toSci "00E+9" -> '0E+9'
-ddbas161 toSci "00E-9" -> '0E-9'
-ddbas162 toSci "10E+9" -> '1.0E+10'
-ddbas163 toSci "10E+09" -> '1.0E+10'
-ddbas164 toSci "10e+90" -> '1.0E+91'
-ddbas165 toSci "10E+009" -> '1.0E+10'
-ddbas166 toSci "100e+9" -> '1.00E+11'
-ddbas167 toSci "100e+09" -> '1.00E+11'
-ddbas168 toSci "100E+90" -> '1.00E+92'
-ddbas169 toSci "100e+009" -> '1.00E+11'
-
-ddbas170 toSci "1.265" -> '1.265'
-ddbas171 toSci "1.265E-20" -> '1.265E-20'
-ddbas172 toSci "1.265E-8" -> '1.265E-8'
-ddbas173 toSci "1.265E-4" -> '0.0001265'
-ddbas174 toSci "1.265E-3" -> '0.001265'
-ddbas175 toSci "1.265E-2" -> '0.01265'
-ddbas176 toSci "1.265E-1" -> '0.1265'
-ddbas177 toSci "1.265E-0" -> '1.265'
-ddbas178 toSci "1.265E+1" -> '12.65'
-ddbas179 toSci "1.265E+2" -> '126.5'
-ddbas180 toSci "1.265E+3" -> '1265'
-ddbas181 toSci "1.265E+4" -> '1.265E+4'
-ddbas182 toSci "1.265E+8" -> '1.265E+8'
-ddbas183 toSci "1.265E+20" -> '1.265E+20'
-
-ddbas190 toSci "12.65" -> '12.65'
-ddbas191 toSci "12.65E-20" -> '1.265E-19'
-ddbas192 toSci "12.65E-8" -> '1.265E-7'
-ddbas193 toSci "12.65E-4" -> '0.001265'
-ddbas194 toSci "12.65E-3" -> '0.01265'
-ddbas195 toSci "12.65E-2" -> '0.1265'
-ddbas196 toSci "12.65E-1" -> '1.265'
-ddbas197 toSci "12.65E-0" -> '12.65'
-ddbas198 toSci "12.65E+1" -> '126.5'
-ddbas199 toSci "12.65E+2" -> '1265'
-ddbas200 toSci "12.65E+3" -> '1.265E+4'
-ddbas201 toSci "12.65E+4" -> '1.265E+5'
-ddbas202 toSci "12.65E+8" -> '1.265E+9'
-ddbas203 toSci "12.65E+20" -> '1.265E+21'
-
-ddbas210 toSci "126.5" -> '126.5'
-ddbas211 toSci "126.5E-20" -> '1.265E-18'
-ddbas212 toSci "126.5E-8" -> '0.000001265'
-ddbas213 toSci "126.5E-4" -> '0.01265'
-ddbas214 toSci "126.5E-3" -> '0.1265'
-ddbas215 toSci "126.5E-2" -> '1.265'
-ddbas216 toSci "126.5E-1" -> '12.65'
-ddbas217 toSci "126.5E-0" -> '126.5'
-ddbas218 toSci "126.5E+1" -> '1265'
-ddbas219 toSci "126.5E+2" -> '1.265E+4'
-ddbas220 toSci "126.5E+3" -> '1.265E+5'
-ddbas221 toSci "126.5E+4" -> '1.265E+6'
-ddbas222 toSci "126.5E+8" -> '1.265E+10'
-ddbas223 toSci "126.5E+20" -> '1.265E+22'
-
-ddbas230 toSci "1265" -> '1265'
-ddbas231 toSci "1265E-20" -> '1.265E-17'
-ddbas232 toSci "1265E-8" -> '0.00001265'
-ddbas233 toSci "1265E-4" -> '0.1265'
-ddbas234 toSci "1265E-3" -> '1.265'
-ddbas235 toSci "1265E-2" -> '12.65'
-ddbas236 toSci "1265E-1" -> '126.5'
-ddbas237 toSci "1265E-0" -> '1265'
-ddbas238 toSci "1265E+1" -> '1.265E+4'
-ddbas239 toSci "1265E+2" -> '1.265E+5'
-ddbas240 toSci "1265E+3" -> '1.265E+6'
-ddbas241 toSci "1265E+4" -> '1.265E+7'
-ddbas242 toSci "1265E+8" -> '1.265E+11'
-ddbas243 toSci "1265E+20" -> '1.265E+23'
-ddbas244 toSci "1265E-9" -> '0.000001265'
-ddbas245 toSci "1265E-10" -> '1.265E-7'
-ddbas246 toSci "1265E-11" -> '1.265E-8'
-ddbas247 toSci "1265E-12" -> '1.265E-9'
-
-ddbas250 toSci "0.1265" -> '0.1265'
-ddbas251 toSci "0.1265E-20" -> '1.265E-21'
-ddbas252 toSci "0.1265E-8" -> '1.265E-9'
-ddbas253 toSci "0.1265E-4" -> '0.00001265'
-ddbas254 toSci "0.1265E-3" -> '0.0001265'
-ddbas255 toSci "0.1265E-2" -> '0.001265'
-ddbas256 toSci "0.1265E-1" -> '0.01265'
-ddbas257 toSci "0.1265E-0" -> '0.1265'
-ddbas258 toSci "0.1265E+1" -> '1.265'
-ddbas259 toSci "0.1265E+2" -> '12.65'
-ddbas260 toSci "0.1265E+3" -> '126.5'
-ddbas261 toSci "0.1265E+4" -> '1265'
-ddbas262 toSci "0.1265E+8" -> '1.265E+7'
-ddbas263 toSci "0.1265E+20" -> '1.265E+19'
-
--- some more negative zeros [systematic tests below]
-ddbas290 toSci "-0.000E-1" -> '-0.0000'
-ddbas291 toSci "-0.000E-2" -> '-0.00000'
-ddbas292 toSci "-0.000E-3" -> '-0.000000'
-ddbas293 toSci "-0.000E-4" -> '-0E-7'
-ddbas294 toSci "-0.00E-2" -> '-0.0000'
-ddbas295 toSci "-0.00E-3" -> '-0.00000'
-ddbas296 toSci "-0.0E-2" -> '-0.000'
-ddbas297 toSci "-0.0E-3" -> '-0.0000'
-ddbas298 toSci "-0E-2" -> '-0.00'
-ddbas299 toSci "-0E-3" -> '-0.000'
-
--- Engineering notation tests
-ddbas301 toSci 10e12 -> 1.0E+13
-ddbas302 toEng 10e12 -> 10E+12
-ddbas303 toSci 10e11 -> 1.0E+12
-ddbas304 toEng 10e11 -> 1.0E+12
-ddbas305 toSci 10e10 -> 1.0E+11
-ddbas306 toEng 10e10 -> 100E+9
-ddbas307 toSci 10e9 -> 1.0E+10
-ddbas308 toEng 10e9 -> 10E+9
-ddbas309 toSci 10e8 -> 1.0E+9
-ddbas310 toEng 10e8 -> 1.0E+9
-ddbas311 toSci 10e7 -> 1.0E+8
-ddbas312 toEng 10e7 -> 100E+6
-ddbas313 toSci 10e6 -> 1.0E+7
-ddbas314 toEng 10e6 -> 10E+6
-ddbas315 toSci 10e5 -> 1.0E+6
-ddbas316 toEng 10e5 -> 1.0E+6
-ddbas317 toSci 10e4 -> 1.0E+5
-ddbas318 toEng 10e4 -> 100E+3
-ddbas319 toSci 10e3 -> 1.0E+4
-ddbas320 toEng 10e3 -> 10E+3
-ddbas321 toSci 10e2 -> 1.0E+3
-ddbas322 toEng 10e2 -> 1.0E+3
-ddbas323 toSci 10e1 -> 1.0E+2
-ddbas324 toEng 10e1 -> 100
-ddbas325 toSci 10e0 -> 10
-ddbas326 toEng 10e0 -> 10
-ddbas327 toSci 10e-1 -> 1.0
-ddbas328 toEng 10e-1 -> 1.0
-ddbas329 toSci 10e-2 -> 0.10
-ddbas330 toEng 10e-2 -> 0.10
-ddbas331 toSci 10e-3 -> 0.010
-ddbas332 toEng 10e-3 -> 0.010
-ddbas333 toSci 10e-4 -> 0.0010
-ddbas334 toEng 10e-4 -> 0.0010
-ddbas335 toSci 10e-5 -> 0.00010
-ddbas336 toEng 10e-5 -> 0.00010
-ddbas337 toSci 10e-6 -> 0.000010
-ddbas338 toEng 10e-6 -> 0.000010
-ddbas339 toSci 10e-7 -> 0.0000010
-ddbas340 toEng 10e-7 -> 0.0000010
-ddbas341 toSci 10e-8 -> 1.0E-7
-ddbas342 toEng 10e-8 -> 100E-9
-ddbas343 toSci 10e-9 -> 1.0E-8
-ddbas344 toEng 10e-9 -> 10E-9
-ddbas345 toSci 10e-10 -> 1.0E-9
-ddbas346 toEng 10e-10 -> 1.0E-9
-ddbas347 toSci 10e-11 -> 1.0E-10
-ddbas348 toEng 10e-11 -> 100E-12
-ddbas349 toSci 10e-12 -> 1.0E-11
-ddbas350 toEng 10e-12 -> 10E-12
-ddbas351 toSci 10e-13 -> 1.0E-12
-ddbas352 toEng 10e-13 -> 1.0E-12
-
-ddbas361 toSci 7E12 -> 7E+12
-ddbas362 toEng 7E12 -> 7E+12
-ddbas363 toSci 7E11 -> 7E+11
-ddbas364 toEng 7E11 -> 700E+9
-ddbas365 toSci 7E10 -> 7E+10
-ddbas366 toEng 7E10 -> 70E+9
-ddbas367 toSci 7E9 -> 7E+9
-ddbas368 toEng 7E9 -> 7E+9
-ddbas369 toSci 7E8 -> 7E+8
-ddbas370 toEng 7E8 -> 700E+6
-ddbas371 toSci 7E7 -> 7E+7
-ddbas372 toEng 7E7 -> 70E+6
-ddbas373 toSci 7E6 -> 7E+6
-ddbas374 toEng 7E6 -> 7E+6
-ddbas375 toSci 7E5 -> 7E+5
-ddbas376 toEng 7E5 -> 700E+3
-ddbas377 toSci 7E4 -> 7E+4
-ddbas378 toEng 7E4 -> 70E+3
-ddbas379 toSci 7E3 -> 7E+3
-ddbas380 toEng 7E3 -> 7E+3
-ddbas381 toSci 7E2 -> 7E+2
-ddbas382 toEng 7E2 -> 700
-ddbas383 toSci 7E1 -> 7E+1
-ddbas384 toEng 7E1 -> 70
-ddbas385 toSci 7E0 -> 7
-ddbas386 toEng 7E0 -> 7
-ddbas387 toSci 7E-1 -> 0.7
-ddbas388 toEng 7E-1 -> 0.7
-ddbas389 toSci 7E-2 -> 0.07
-ddbas390 toEng 7E-2 -> 0.07
-ddbas391 toSci 7E-3 -> 0.007
-ddbas392 toEng 7E-3 -> 0.007
-ddbas393 toSci 7E-4 -> 0.0007
-ddbas394 toEng 7E-4 -> 0.0007
-ddbas395 toSci 7E-5 -> 0.00007
-ddbas396 toEng 7E-5 -> 0.00007
-ddbas397 toSci 7E-6 -> 0.000007
-ddbas398 toEng 7E-6 -> 0.000007
-ddbas399 toSci 7E-7 -> 7E-7
-ddbas400 toEng 7E-7 -> 700E-9
-ddbas401 toSci 7E-8 -> 7E-8
-ddbas402 toEng 7E-8 -> 70E-9
-ddbas403 toSci 7E-9 -> 7E-9
-ddbas404 toEng 7E-9 -> 7E-9
-ddbas405 toSci 7E-10 -> 7E-10
-ddbas406 toEng 7E-10 -> 700E-12
-ddbas407 toSci 7E-11 -> 7E-11
-ddbas408 toEng 7E-11 -> 70E-12
-ddbas409 toSci 7E-12 -> 7E-12
-ddbas410 toEng 7E-12 -> 7E-12
-ddbas411 toSci 7E-13 -> 7E-13
-ddbas412 toEng 7E-13 -> 700E-15
-
--- Exacts remain exact up to precision ..
-rounding: half_up
-ddbas420 toSci 100 -> 100
-ddbas421 toEng 100 -> 100
-ddbas422 toSci 1000 -> 1000
-ddbas423 toEng 1000 -> 1000
-ddbas424 toSci 999.9 -> 999.9
-ddbas425 toEng 999.9 -> 999.9
-ddbas426 toSci 1000.0 -> 1000.0
-ddbas427 toEng 1000.0 -> 1000.0
-ddbas428 toSci 1000.1 -> 1000.1
-ddbas429 toEng 1000.1 -> 1000.1
-ddbas430 toSci 10000 -> 10000
-ddbas431 toEng 10000 -> 10000
-ddbas432 toSci 100000 -> 100000
-ddbas433 toEng 100000 -> 100000
-ddbas434 toSci 1000000 -> 1000000
-ddbas435 toEng 1000000 -> 1000000
-ddbas436 toSci 10000000 -> 10000000
-ddbas437 toEng 10000000 -> 10000000
-ddbas438 toSci 100000000 -> 100000000
-ddbas439 toEng 1000000000000000 -> 1000000000000000
-ddbas440 toSci 10000000000000000 -> 1.000000000000000E+16 Rounded
-ddbas441 toEng 10000000000000000 -> 10.00000000000000E+15 Rounded
-ddbas442 toSci 10000000000000001 -> 1.000000000000000E+16 Rounded Inexact
-ddbas443 toEng 10000000000000001 -> 10.00000000000000E+15 Rounded Inexact
-ddbas444 toSci 10000000000000003 -> 1.000000000000000E+16 Rounded Inexact
-ddbas445 toEng 10000000000000003 -> 10.00000000000000E+15 Rounded Inexact
-ddbas446 toSci 10000000000000005 -> 1.000000000000001E+16 Rounded Inexact
-ddbas447 toEng 10000000000000005 -> 10.00000000000001E+15 Rounded Inexact
-ddbas448 toSci 100000000000000050 -> 1.000000000000001E+17 Rounded Inexact
-ddbas449 toEng 100000000000000050 -> 100.0000000000001E+15 Rounded Inexact
-ddbas450 toSci 10000000000000009 -> 1.000000000000001E+16 Rounded Inexact
-ddbas451 toEng 10000000000000009 -> 10.00000000000001E+15 Rounded Inexact
-ddbas452 toSci 100000000000000000 -> 1.000000000000000E+17 Rounded
-ddbas453 toEng 100000000000000000 -> 100.0000000000000E+15 Rounded
-ddbas454 toSci 100000000000000003 -> 1.000000000000000E+17 Rounded Inexact
-ddbas455 toEng 100000000000000003 -> 100.0000000000000E+15 Rounded Inexact
-ddbas456 toSci 100000000000000005 -> 1.000000000000000E+17 Rounded Inexact
-ddbas457 toEng 100000000000000005 -> 100.0000000000000E+15 Rounded Inexact
-ddbas458 toSci 100000000000000009 -> 1.000000000000000E+17 Rounded Inexact
-ddbas459 toEng 100000000000000009 -> 100.0000000000000E+15 Rounded Inexact
-ddbas460 toSci 1000000000000000000 -> 1.000000000000000E+18 Rounded
-ddbas461 toEng 1000000000000000000 -> 1.000000000000000E+18 Rounded
-ddbas462 toSci 1000000000000000300 -> 1.000000000000000E+18 Rounded Inexact
-ddbas463 toEng 1000000000000000300 -> 1.000000000000000E+18 Rounded Inexact
-ddbas464 toSci 1000000000000000500 -> 1.000000000000001E+18 Rounded Inexact
-ddbas465 toEng 1000000000000000500 -> 1.000000000000001E+18 Rounded Inexact
-ddbas466 toSci 1000000000000000900 -> 1.000000000000001E+18 Rounded Inexact
-ddbas467 toEng 1000000000000000900 -> 1.000000000000001E+18 Rounded Inexact
-ddbas468 toSci 10000000000000000000 -> 1.000000000000000E+19 Rounded
-ddbas469 toEng 10000000000000000000 -> 10.00000000000000E+18 Rounded
-ddbas470 toSci 10000000000000003000 -> 1.000000000000000E+19 Rounded Inexact
-ddbas471 toEng 10000000000000003000 -> 10.00000000000000E+18 Rounded Inexact
-ddbas472 toSci 10000000000000005000 -> 1.000000000000001E+19 Rounded Inexact
-ddbas473 toEng 10000000000000005000 -> 10.00000000000001E+18 Rounded Inexact
-ddbas474 toSci 10000000000000009000 -> 1.000000000000001E+19 Rounded Inexact
-ddbas475 toEng 10000000000000009000 -> 10.00000000000001E+18 Rounded Inexact
-
--- check rounding modes heeded
-rounding: ceiling
-ddbsr401 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr402 toSci 1.11111111111234549 -> 1.111111111112346 Rounded Inexact
-ddbsr403 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
-ddbsr404 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
-rounding: up
-ddbsr405 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr406 toSci 1.11111111111234549 -> 1.111111111112346 Rounded Inexact
-ddbsr407 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
-ddbsr408 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
-rounding: floor
-ddbsr410 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr411 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr412 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
-ddbsr413 toSci 1.11111111111234551 -> 1.111111111112345 Rounded Inexact
-rounding: half_down
-ddbsr415 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr416 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr417 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
-ddbsr418 toSci 1.11111111111234650 -> 1.111111111112346 Rounded Inexact
-ddbsr419 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
-rounding: half_even
-ddbsr421 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr422 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr423 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
-ddbsr424 toSci 1.11111111111234650 -> 1.111111111112346 Rounded Inexact
-ddbsr425 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
-rounding: down
-ddbsr426 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr427 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr428 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
-ddbsr429 toSci 1.11111111111234551 -> 1.111111111112345 Rounded Inexact
-rounding: half_up
-ddbsr431 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr432 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr433 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
-ddbsr434 toSci 1.11111111111234650 -> 1.111111111112347 Rounded Inexact
-ddbsr435 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
--- negatives
-rounding: ceiling
-ddbsr501 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr502 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr503 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
-ddbsr504 toSci -1.11111111111234551 -> -1.111111111112345 Rounded Inexact
-rounding: up
-ddbsr505 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr506 toSci -1.11111111111234549 -> -1.111111111112346 Rounded Inexact
-ddbsr507 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
-ddbsr508 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-rounding: floor
-ddbsr510 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr511 toSci -1.11111111111234549 -> -1.111111111112346 Rounded Inexact
-ddbsr512 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
-ddbsr513 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-rounding: half_down
-ddbsr515 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr516 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr517 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
-ddbsr518 toSci -1.11111111111234650 -> -1.111111111112346 Rounded Inexact
-ddbsr519 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-rounding: half_even
-ddbsr521 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr522 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr523 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
-ddbsr524 toSci -1.11111111111234650 -> -1.111111111112346 Rounded Inexact
-ddbsr525 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-rounding: down
-ddbsr526 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr527 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr528 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
-ddbsr529 toSci -1.11111111111234551 -> -1.111111111112345 Rounded Inexact
-rounding: half_up
-ddbsr531 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr532 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr533 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
-ddbsr534 toSci -1.11111111111234650 -> -1.111111111112347 Rounded Inexact
-ddbsr535 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-
-rounding: half_even
-
--- The 'baddies' tests from DiagBigDecimal, plus some new ones
-ddbas500 toSci '1..2' -> NaN Conversion_syntax
-ddbas501 toSci '.' -> NaN Conversion_syntax
-ddbas502 toSci '..' -> NaN Conversion_syntax
-ddbas503 toSci '++1' -> NaN Conversion_syntax
-ddbas504 toSci '--1' -> NaN Conversion_syntax
-ddbas505 toSci '-+1' -> NaN Conversion_syntax
-ddbas506 toSci '+-1' -> NaN Conversion_syntax
-ddbas507 toSci '12e' -> NaN Conversion_syntax
-ddbas508 toSci '12e++' -> NaN Conversion_syntax
-ddbas509 toSci '12f4' -> NaN Conversion_syntax
-ddbas510 toSci ' +1' -> NaN Conversion_syntax
-ddbas511 toSci '+ 1' -> NaN Conversion_syntax
-ddbas512 toSci '12 ' -> NaN Conversion_syntax
-ddbas513 toSci ' + 1' -> NaN Conversion_syntax
-ddbas514 toSci ' - 1 ' -> NaN Conversion_syntax
-ddbas515 toSci 'x' -> NaN Conversion_syntax
-ddbas516 toSci '-1-' -> NaN Conversion_syntax
-ddbas517 toSci '12-' -> NaN Conversion_syntax
-ddbas518 toSci '3+' -> NaN Conversion_syntax
-ddbas519 toSci '' -> NaN Conversion_syntax
-ddbas520 toSci '1e-' -> NaN Conversion_syntax
-ddbas521 toSci '7e99999a' -> NaN Conversion_syntax
-ddbas522 toSci '7e123567890x' -> NaN Conversion_syntax
-ddbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
-ddbas524 toSci '' -> NaN Conversion_syntax
-ddbas525 toSci 'e100' -> NaN Conversion_syntax
-ddbas526 toSci '\u0e5a' -> NaN Conversion_syntax
-ddbas527 toSci '\u0b65' -> NaN Conversion_syntax
-ddbas528 toSci '123,65' -> NaN Conversion_syntax
-ddbas529 toSci '1.34.5' -> NaN Conversion_syntax
-ddbas530 toSci '.123.5' -> NaN Conversion_syntax
-ddbas531 toSci '01.35.' -> NaN Conversion_syntax
-ddbas532 toSci '01.35-' -> NaN Conversion_syntax
-ddbas533 toSci '0000..' -> NaN Conversion_syntax
-ddbas534 toSci '.0000.' -> NaN Conversion_syntax
-ddbas535 toSci '00..00' -> NaN Conversion_syntax
-ddbas536 toSci '111e*123' -> NaN Conversion_syntax
-ddbas537 toSci '111e123-' -> NaN Conversion_syntax
-ddbas538 toSci '111e+12+' -> NaN Conversion_syntax
-ddbas539 toSci '111e1-3-' -> NaN Conversion_syntax
-ddbas540 toSci '111e1*23' -> NaN Conversion_syntax
-ddbas541 toSci '111e1e+3' -> NaN Conversion_syntax
-ddbas542 toSci '1e1.0' -> NaN Conversion_syntax
-ddbas543 toSci '1e123e' -> NaN Conversion_syntax
-ddbas544 toSci 'ten' -> NaN Conversion_syntax
-ddbas545 toSci 'ONE' -> NaN Conversion_syntax
-ddbas546 toSci '1e.1' -> NaN Conversion_syntax
-ddbas547 toSci '1e1.' -> NaN Conversion_syntax
-ddbas548 toSci '1ee' -> NaN Conversion_syntax
-ddbas549 toSci 'e+1' -> NaN Conversion_syntax
-ddbas550 toSci '1.23.4' -> NaN Conversion_syntax
-ddbas551 toSci '1.2.1' -> NaN Conversion_syntax
-ddbas552 toSci '1E+1.2' -> NaN Conversion_syntax
-ddbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
-ddbas554 toSci '1E++1' -> NaN Conversion_syntax
-ddbas555 toSci '1E--1' -> NaN Conversion_syntax
-ddbas556 toSci '1E+-1' -> NaN Conversion_syntax
-ddbas557 toSci '1E-+1' -> NaN Conversion_syntax
-ddbas558 toSci '1E''1' -> NaN Conversion_syntax
-ddbas559 toSci "1E""1" -> NaN Conversion_syntax
-ddbas560 toSci "1E""""" -> NaN Conversion_syntax
--- Near-specials
-ddbas561 toSci "qNaN" -> NaN Conversion_syntax
-ddbas562 toSci "NaNq" -> NaN Conversion_syntax
-ddbas563 toSci "NaNs" -> NaN Conversion_syntax
-ddbas564 toSci "Infi" -> NaN Conversion_syntax
-ddbas565 toSci "Infin" -> NaN Conversion_syntax
-ddbas566 toSci "Infini" -> NaN Conversion_syntax
-ddbas567 toSci "Infinit" -> NaN Conversion_syntax
-ddbas568 toSci "-Infinit" -> NaN Conversion_syntax
-ddbas569 toSci "0Inf" -> NaN Conversion_syntax
-ddbas570 toSci "9Inf" -> NaN Conversion_syntax
-ddbas571 toSci "-0Inf" -> NaN Conversion_syntax
-ddbas572 toSci "-9Inf" -> NaN Conversion_syntax
-ddbas573 toSci "-sNa" -> NaN Conversion_syntax
-ddbas574 toSci "xNaN" -> NaN Conversion_syntax
-ddbas575 toSci "0sNaN" -> NaN Conversion_syntax
-
--- some baddies with dots and Es and dots and specials
-ddbas576 toSci 'e+1' -> NaN Conversion_syntax
-ddbas577 toSci '.e+1' -> NaN Conversion_syntax
-ddbas578 toSci '+.e+1' -> NaN Conversion_syntax
-ddbas579 toSci '-.e+' -> NaN Conversion_syntax
-ddbas580 toSci '-.e' -> NaN Conversion_syntax
-ddbas581 toSci 'E+1' -> NaN Conversion_syntax
-ddbas582 toSci '.E+1' -> NaN Conversion_syntax
-ddbas583 toSci '+.E+1' -> NaN Conversion_syntax
-ddbas584 toSci '-.E+' -> NaN Conversion_syntax
-ddbas585 toSci '-.E' -> NaN Conversion_syntax
-
-ddbas586 toSci '.NaN' -> NaN Conversion_syntax
-ddbas587 toSci '-.NaN' -> NaN Conversion_syntax
-ddbas588 toSci '+.sNaN' -> NaN Conversion_syntax
-ddbas589 toSci '+.Inf' -> NaN Conversion_syntax
-ddbas590 toSci '.Infinity' -> NaN Conversion_syntax
-
--- Zeros
-ddbas601 toSci 0.000000000 -> 0E-9
-ddbas602 toSci 0.00000000 -> 0E-8
-ddbas603 toSci 0.0000000 -> 0E-7
-ddbas604 toSci 0.000000 -> 0.000000
-ddbas605 toSci 0.00000 -> 0.00000
-ddbas606 toSci 0.0000 -> 0.0000
-ddbas607 toSci 0.000 -> 0.000
-ddbas608 toSci 0.00 -> 0.00
-ddbas609 toSci 0.0 -> 0.0
-ddbas610 toSci .0 -> 0.0
-ddbas611 toSci 0. -> 0
-ddbas612 toSci -.0 -> -0.0
-ddbas613 toSci -0. -> -0
-ddbas614 toSci -0.0 -> -0.0
-ddbas615 toSci -0.00 -> -0.00
-ddbas616 toSci -0.000 -> -0.000
-ddbas617 toSci -0.0000 -> -0.0000
-ddbas618 toSci -0.00000 -> -0.00000
-ddbas619 toSci -0.000000 -> -0.000000
-ddbas620 toSci -0.0000000 -> -0E-7
-ddbas621 toSci -0.00000000 -> -0E-8
-ddbas622 toSci -0.000000000 -> -0E-9
-
-ddbas630 toSci 0.00E+0 -> 0.00
-ddbas631 toSci 0.00E+1 -> 0.0
-ddbas632 toSci 0.00E+2 -> 0
-ddbas633 toSci 0.00E+3 -> 0E+1
-ddbas634 toSci 0.00E+4 -> 0E+2
-ddbas635 toSci 0.00E+5 -> 0E+3
-ddbas636 toSci 0.00E+6 -> 0E+4
-ddbas637 toSci 0.00E+7 -> 0E+5
-ddbas638 toSci 0.00E+8 -> 0E+6
-ddbas639 toSci 0.00E+9 -> 0E+7
-
-ddbas640 toSci 0.0E+0 -> 0.0
-ddbas641 toSci 0.0E+1 -> 0
-ddbas642 toSci 0.0E+2 -> 0E+1
-ddbas643 toSci 0.0E+3 -> 0E+2
-ddbas644 toSci 0.0E+4 -> 0E+3
-ddbas645 toSci 0.0E+5 -> 0E+4
-ddbas646 toSci 0.0E+6 -> 0E+5
-ddbas647 toSci 0.0E+7 -> 0E+6
-ddbas648 toSci 0.0E+8 -> 0E+7
-ddbas649 toSci 0.0E+9 -> 0E+8
-
-ddbas650 toSci 0E+0 -> 0
-ddbas651 toSci 0E+1 -> 0E+1
-ddbas652 toSci 0E+2 -> 0E+2
-ddbas653 toSci 0E+3 -> 0E+3
-ddbas654 toSci 0E+4 -> 0E+4
-ddbas655 toSci 0E+5 -> 0E+5
-ddbas656 toSci 0E+6 -> 0E+6
-ddbas657 toSci 0E+7 -> 0E+7
-ddbas658 toSci 0E+8 -> 0E+8
-ddbas659 toSci 0E+9 -> 0E+9
-
-ddbas660 toSci 0.0E-0 -> 0.0
-ddbas661 toSci 0.0E-1 -> 0.00
-ddbas662 toSci 0.0E-2 -> 0.000
-ddbas663 toSci 0.0E-3 -> 0.0000
-ddbas664 toSci 0.0E-4 -> 0.00000
-ddbas665 toSci 0.0E-5 -> 0.000000
-ddbas666 toSci 0.0E-6 -> 0E-7
-ddbas667 toSci 0.0E-7 -> 0E-8
-ddbas668 toSci 0.0E-8 -> 0E-9
-ddbas669 toSci 0.0E-9 -> 0E-10
-
-ddbas670 toSci 0.00E-0 -> 0.00
-ddbas671 toSci 0.00E-1 -> 0.000
-ddbas672 toSci 0.00E-2 -> 0.0000
-ddbas673 toSci 0.00E-3 -> 0.00000
-ddbas674 toSci 0.00E-4 -> 0.000000
-ddbas675 toSci 0.00E-5 -> 0E-7
-ddbas676 toSci 0.00E-6 -> 0E-8
-ddbas677 toSci 0.00E-7 -> 0E-9
-ddbas678 toSci 0.00E-8 -> 0E-10
-ddbas679 toSci 0.00E-9 -> 0E-11
-
-ddbas680 toSci 000000. -> 0
-ddbas681 toSci 00000. -> 0
-ddbas682 toSci 0000. -> 0
-ddbas683 toSci 000. -> 0
-ddbas684 toSci 00. -> 0
-ddbas685 toSci 0. -> 0
-ddbas686 toSci +00000. -> 0
-ddbas687 toSci -00000. -> -0
-ddbas688 toSci +0. -> 0
-ddbas689 toSci -0. -> -0
-
--- Specials
-ddbas700 toSci "NaN" -> NaN
-ddbas701 toSci "nan" -> NaN
-ddbas702 toSci "nAn" -> NaN
-ddbas703 toSci "NAN" -> NaN
-ddbas704 toSci "+NaN" -> NaN
-ddbas705 toSci "+nan" -> NaN
-ddbas706 toSci "+nAn" -> NaN
-ddbas707 toSci "+NAN" -> NaN
-ddbas708 toSci "-NaN" -> -NaN
-ddbas709 toSci "-nan" -> -NaN
-ddbas710 toSci "-nAn" -> -NaN
-ddbas711 toSci "-NAN" -> -NaN
-ddbas712 toSci 'NaN0' -> NaN
-ddbas713 toSci 'NaN1' -> NaN1
-ddbas714 toSci 'NaN12' -> NaN12
-ddbas715 toSci 'NaN123' -> NaN123
-ddbas716 toSci 'NaN1234' -> NaN1234
-ddbas717 toSci 'NaN01' -> NaN1
-ddbas718 toSci 'NaN012' -> NaN12
-ddbas719 toSci 'NaN0123' -> NaN123
-ddbas720 toSci 'NaN01234' -> NaN1234
-ddbas721 toSci 'NaN001' -> NaN1
-ddbas722 toSci 'NaN0012' -> NaN12
-ddbas723 toSci 'NaN00123' -> NaN123
-ddbas724 toSci 'NaN001234' -> NaN1234
-ddbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
-ddbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
-ddbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
-ddbas728 toSci 'NaN-12' -> NaN Conversion_syntax
-ddbas729 toSci 'NaN+12' -> NaN Conversion_syntax
-
-ddbas730 toSci "sNaN" -> sNaN
-ddbas731 toSci "snan" -> sNaN
-ddbas732 toSci "SnAn" -> sNaN
-ddbas733 toSci "SNAN" -> sNaN
-ddbas734 toSci "+sNaN" -> sNaN
-ddbas735 toSci "+snan" -> sNaN
-ddbas736 toSci "+SnAn" -> sNaN
-ddbas737 toSci "+SNAN" -> sNaN
-ddbas738 toSci "-sNaN" -> -sNaN
-ddbas739 toSci "-snan" -> -sNaN
-ddbas740 toSci "-SnAn" -> -sNaN
-ddbas741 toSci "-SNAN" -> -sNaN
-ddbas742 toSci 'sNaN0000' -> sNaN
-ddbas743 toSci 'sNaN7' -> sNaN7
-ddbas744 toSci 'sNaN007234' -> sNaN7234
-ddbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
-ddbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
-ddbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
-
-ddbas748 toSci "Inf" -> Infinity
-ddbas749 toSci "inf" -> Infinity
-ddbas750 toSci "iNf" -> Infinity
-ddbas751 toSci "INF" -> Infinity
-ddbas752 toSci "+Inf" -> Infinity
-ddbas753 toSci "+inf" -> Infinity
-ddbas754 toSci "+iNf" -> Infinity
-ddbas755 toSci "+INF" -> Infinity
-ddbas756 toSci "-Inf" -> -Infinity
-ddbas757 toSci "-inf" -> -Infinity
-ddbas758 toSci "-iNf" -> -Infinity
-ddbas759 toSci "-INF" -> -Infinity
-
-ddbas760 toSci "Infinity" -> Infinity
-ddbas761 toSci "infinity" -> Infinity
-ddbas762 toSci "iNfInItY" -> Infinity
-ddbas763 toSci "INFINITY" -> Infinity
-ddbas764 toSci "+Infinity" -> Infinity
-ddbas765 toSci "+infinity" -> Infinity
-ddbas766 toSci "+iNfInItY" -> Infinity
-ddbas767 toSci "+INFINITY" -> Infinity
-ddbas768 toSci "-Infinity" -> -Infinity
-ddbas769 toSci "-infinity" -> -Infinity
-ddbas770 toSci "-iNfInItY" -> -Infinity
-ddbas771 toSci "-INFINITY" -> -Infinity
-
--- Specials and zeros for toEng
-ddbast772 toEng "NaN" -> NaN
-ddbast773 toEng "-Infinity" -> -Infinity
-ddbast774 toEng "-sNaN" -> -sNaN
-ddbast775 toEng "-NaN" -> -NaN
-ddbast776 toEng "+Infinity" -> Infinity
-ddbast778 toEng "+sNaN" -> sNaN
-ddbast779 toEng "+NaN" -> NaN
-ddbast780 toEng "INFINITY" -> Infinity
-ddbast781 toEng "SNAN" -> sNaN
-ddbast782 toEng "NAN" -> NaN
-ddbast783 toEng "infinity" -> Infinity
-ddbast784 toEng "snan" -> sNaN
-ddbast785 toEng "nan" -> NaN
-ddbast786 toEng "InFINITY" -> Infinity
-ddbast787 toEng "SnAN" -> sNaN
-ddbast788 toEng "nAN" -> NaN
-ddbast789 toEng "iNfinity" -> Infinity
-ddbast790 toEng "sNan" -> sNaN
-ddbast791 toEng "Nan" -> NaN
-ddbast792 toEng "Infinity" -> Infinity
-ddbast793 toEng "sNaN" -> sNaN
-
--- Zero toEng, etc.
-ddbast800 toEng 0e+1 -> "0.00E+3" -- doc example
-
-ddbast801 toEng 0.000000000 -> 0E-9
-ddbast802 toEng 0.00000000 -> 0.00E-6
-ddbast803 toEng 0.0000000 -> 0.0E-6
-ddbast804 toEng 0.000000 -> 0.000000
-ddbast805 toEng 0.00000 -> 0.00000
-ddbast806 toEng 0.0000 -> 0.0000
-ddbast807 toEng 0.000 -> 0.000
-ddbast808 toEng 0.00 -> 0.00
-ddbast809 toEng 0.0 -> 0.0
-ddbast810 toEng .0 -> 0.0
-ddbast811 toEng 0. -> 0
-ddbast812 toEng -.0 -> -0.0
-ddbast813 toEng -0. -> -0
-ddbast814 toEng -0.0 -> -0.0
-ddbast815 toEng -0.00 -> -0.00
-ddbast816 toEng -0.000 -> -0.000
-ddbast817 toEng -0.0000 -> -0.0000
-ddbast818 toEng -0.00000 -> -0.00000
-ddbast819 toEng -0.000000 -> -0.000000
-ddbast820 toEng -0.0000000 -> -0.0E-6
-ddbast821 toEng -0.00000000 -> -0.00E-6
-ddbast822 toEng -0.000000000 -> -0E-9
-
-ddbast830 toEng 0.00E+0 -> 0.00
-ddbast831 toEng 0.00E+1 -> 0.0
-ddbast832 toEng 0.00E+2 -> 0
-ddbast833 toEng 0.00E+3 -> 0.00E+3
-ddbast834 toEng 0.00E+4 -> 0.0E+3
-ddbast835 toEng 0.00E+5 -> 0E+3
-ddbast836 toEng 0.00E+6 -> 0.00E+6
-ddbast837 toEng 0.00E+7 -> 0.0E+6
-ddbast838 toEng 0.00E+8 -> 0E+6
-ddbast839 toEng 0.00E+9 -> 0.00E+9
-
-ddbast840 toEng 0.0E+0 -> 0.0
-ddbast841 toEng 0.0E+1 -> 0
-ddbast842 toEng 0.0E+2 -> 0.00E+3
-ddbast843 toEng 0.0E+3 -> 0.0E+3
-ddbast844 toEng 0.0E+4 -> 0E+3
-ddbast845 toEng 0.0E+5 -> 0.00E+6
-ddbast846 toEng 0.0E+6 -> 0.0E+6
-ddbast847 toEng 0.0E+7 -> 0E+6
-ddbast848 toEng 0.0E+8 -> 0.00E+9
-ddbast849 toEng 0.0E+9 -> 0.0E+9
-
-ddbast850 toEng 0E+0 -> 0
-ddbast851 toEng 0E+1 -> 0.00E+3
-ddbast852 toEng 0E+2 -> 0.0E+3
-ddbast853 toEng 0E+3 -> 0E+3
-ddbast854 toEng 0E+4 -> 0.00E+6
-ddbast855 toEng 0E+5 -> 0.0E+6
-ddbast856 toEng 0E+6 -> 0E+6
-ddbast857 toEng 0E+7 -> 0.00E+9
-ddbast858 toEng 0E+8 -> 0.0E+9
-ddbast859 toEng 0E+9 -> 0E+9
-
-ddbast860 toEng 0.0E-0 -> 0.0
-ddbast861 toEng 0.0E-1 -> 0.00
-ddbast862 toEng 0.0E-2 -> 0.000
-ddbast863 toEng 0.0E-3 -> 0.0000
-ddbast864 toEng 0.0E-4 -> 0.00000
-ddbast865 toEng 0.0E-5 -> 0.000000
-ddbast866 toEng 0.0E-6 -> 0.0E-6
-ddbast867 toEng 0.0E-7 -> 0.00E-6
-ddbast868 toEng 0.0E-8 -> 0E-9
-ddbast869 toEng 0.0E-9 -> 0.0E-9
-
-ddbast870 toEng 0.00E-0 -> 0.00
-ddbast871 toEng 0.00E-1 -> 0.000
-ddbast872 toEng 0.00E-2 -> 0.0000
-ddbast873 toEng 0.00E-3 -> 0.00000
-ddbast874 toEng 0.00E-4 -> 0.000000
-ddbast875 toEng 0.00E-5 -> 0.0E-6
-ddbast876 toEng 0.00E-6 -> 0.00E-6
-ddbast877 toEng 0.00E-7 -> 0E-9
-ddbast878 toEng 0.00E-8 -> 0.0E-9
-ddbast879 toEng 0.00E-9 -> 0.00E-9
-
--- long input strings
-ddbas801 tosci '01234567890123456' -> 1234567890123456
-ddbas802 tosci '001234567890123456' -> 1234567890123456
-ddbas803 tosci '0001234567890123456' -> 1234567890123456
-ddbas804 tosci '00001234567890123456' -> 1234567890123456
-ddbas805 tosci '000001234567890123456' -> 1234567890123456
-ddbas806 tosci '0000001234567890123456' -> 1234567890123456
-ddbas807 tosci '00000001234567890123456' -> 1234567890123456
-ddbas808 tosci '000000001234567890123456' -> 1234567890123456
-ddbas809 tosci '0000000001234567890123456' -> 1234567890123456
-ddbas810 tosci '00000000001234567890123456' -> 1234567890123456
-
-ddbas811 tosci '0.1234567890123456' -> 0.1234567890123456
-ddbas812 tosci '0.01234567890123456' -> 0.01234567890123456
-ddbas813 tosci '0.001234567890123456' -> 0.001234567890123456
-ddbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
-ddbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
-ddbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
-ddbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
-ddbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
-ddbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
-ddbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10
-
-ddbas821 tosci '12345678901234567890' -> 1.234567890123457E+19 Inexact Rounded
-ddbas822 tosci '123456789012345678901' -> 1.234567890123457E+20 Inexact Rounded
-ddbas823 tosci '1234567890123456789012' -> 1.234567890123457E+21 Inexact Rounded
-ddbas824 tosci '12345678901234567890123' -> 1.234567890123457E+22 Inexact Rounded
-ddbas825 tosci '123456789012345678901234' -> 1.234567890123457E+23 Inexact Rounded
-ddbas826 tosci '1234567890123456789012345' -> 1.234567890123457E+24 Inexact Rounded
-ddbas827 tosci '12345678901234567890123456' -> 1.234567890123457E+25 Inexact Rounded
-ddbas828 tosci '123456789012345678901234567' -> 1.234567890123457E+26 Inexact Rounded
-ddbas829 tosci '1234567890123456789012345678' -> 1.234567890123457E+27 Inexact Rounded
-
--- subnormals and overflows
-ddbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
-ddbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
-ddbas908 toSci '0.9e-999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas909 toSci '0.09e-999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
-ddbas911 toSci '10e-1000000000' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
-ddbas913 toSci '99e-9999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
-ddbas915 toSci '1111e-9999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas916 toSci '1111e-99999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
--- negatives the same
-ddbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
-ddbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
-ddbas920 toSci '-0.9e-999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas921 toSci '-0.09e-999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
-ddbas923 toSci '-10e-1000000000' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
-ddbas925 toSci '-99e-9999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
-ddbas927 toSci '-1111e-9999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas928 toSci '-1111e-99999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
-
--- overflow results at different rounding modes
-rounding: ceiling
-ddbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas931 toSci '-7e10000' -> -9.999999999999999E+384 Overflow Inexact Rounded
-rounding: up
-ddbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: down
-ddbas934 toSci '7e10000' -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddbas935 toSci '-7e10000' -> -9.999999999999999E+384 Overflow Inexact Rounded
-rounding: floor
-ddbas936 toSci '7e10000' -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_up
-ddbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_even
-ddbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_down
-ddbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_even
-
--- Now check 854/754r some subnormals and underflow to 0
-ddbem400 toSci 1.0000E-383 -> 1.0000E-383
-ddbem401 toSci 0.1E-394 -> 1E-395 Subnormal
-ddbem402 toSci 0.1000E-394 -> 1.000E-395 Subnormal
-ddbem403 toSci 0.0100E-394 -> 1.00E-396 Subnormal
-ddbem404 toSci 0.0010E-394 -> 1.0E-397 Subnormal
-ddbem405 toSci 0.0001E-394 -> 1E-398 Subnormal
-ddbem406 toSci 0.00010E-394 -> 1E-398 Subnormal Rounded
-ddbem407 toSci 0.00013E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddbem408 toSci 0.00015E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem409 toSci 0.00017E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem410 toSci 0.00023E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem411 toSci 0.00025E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem412 toSci 0.00027E-394 -> 3E-398 Underflow Subnormal Inexact Rounded
-ddbem413 toSci 0.000149E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddbem414 toSci 0.000150E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem415 toSci 0.000151E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem416 toSci 0.000249E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem417 toSci 0.000250E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem418 toSci 0.000251E-394 -> 3E-398 Underflow Subnormal Inexact Rounded
-ddbem419 toSci 0.00009E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddbem420 toSci 0.00005E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem421 toSci 0.00003E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem422 toSci 0.000009E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem423 toSci 0.000005E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem424 toSci 0.000003E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-ddbem425 toSci 0.001049E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
-ddbem426 toSci 0.001050E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
-ddbem427 toSci 0.001051E-394 -> 1.1E-397 Underflow Subnormal Inexact Rounded
-ddbem428 toSci 0.001149E-394 -> 1.1E-397 Underflow Subnormal Inexact Rounded
-ddbem429 toSci 0.001150E-394 -> 1.2E-397 Underflow Subnormal Inexact Rounded
-ddbem430 toSci 0.001151E-394 -> 1.2E-397 Underflow Subnormal Inexact Rounded
-
-ddbem432 toSci 0.010049E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
-ddbem433 toSci 0.010050E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
-ddbem434 toSci 0.010051E-394 -> 1.01E-396 Underflow Subnormal Inexact Rounded
-ddbem435 toSci 0.010149E-394 -> 1.01E-396 Underflow Subnormal Inexact Rounded
-ddbem436 toSci 0.010150E-394 -> 1.02E-396 Underflow Subnormal Inexact Rounded
-ddbem437 toSci 0.010151E-394 -> 1.02E-396 Underflow Subnormal Inexact Rounded
-
-ddbem440 toSci 0.10103E-394 -> 1.010E-395 Underflow Subnormal Inexact Rounded
-ddbem441 toSci 0.10105E-394 -> 1.010E-395 Underflow Subnormal Inexact Rounded
-ddbem442 toSci 0.10107E-394 -> 1.011E-395 Underflow Subnormal Inexact Rounded
-ddbem443 toSci 0.10113E-394 -> 1.011E-395 Underflow Subnormal Inexact Rounded
-ddbem444 toSci 0.10115E-394 -> 1.012E-395 Underflow Subnormal Inexact Rounded
-ddbem445 toSci 0.10117E-394 -> 1.012E-395 Underflow Subnormal Inexact Rounded
-
-ddbem450 toSci 1.10730E-395 -> 1.107E-395 Underflow Subnormal Inexact Rounded
-ddbem451 toSci 1.10750E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
-ddbem452 toSci 1.10770E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
-ddbem453 toSci 1.10830E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
-ddbem454 toSci 1.10850E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
-ddbem455 toSci 1.10870E-395 -> 1.109E-395 Underflow Subnormal Inexact Rounded
-
--- make sure sign OK
-ddbem456 toSci -0.10103E-394 -> -1.010E-395 Underflow Subnormal Inexact Rounded
-ddbem457 toSci -0.10105E-394 -> -1.010E-395 Underflow Subnormal Inexact Rounded
-ddbem458 toSci -0.10107E-394 -> -1.011E-395 Underflow Subnormal Inexact Rounded
-ddbem459 toSci -0.10113E-394 -> -1.011E-395 Underflow Subnormal Inexact Rounded
-ddbem460 toSci -0.10115E-394 -> -1.012E-395 Underflow Subnormal Inexact Rounded
-ddbem461 toSci -0.10117E-394 -> -1.012E-395 Underflow Subnormal Inexact Rounded
-
--- '999s' cases
-ddbem464 toSci 999999E-395 -> 9.99999E-390 Subnormal
-ddbem465 toSci 99999.0E-394 -> 9.99990E-390 Subnormal
-ddbem466 toSci 99999.E-394 -> 9.9999E-390 Subnormal
-ddbem467 toSci 9999.9E-394 -> 9.9999E-391 Subnormal
-ddbem468 toSci 999.99E-394 -> 9.9999E-392 Subnormal
-ddbem469 toSci 99.999E-394 -> 9.9999E-393 Subnormal
-ddbem470 toSci 9.9999E-394 -> 9.9999E-394 Subnormal
-ddbem471 toSci 0.99999E-394 -> 1.0000E-394 Underflow Subnormal Inexact Rounded
-ddbem472 toSci 0.099999E-394 -> 1.000E-395 Underflow Subnormal Inexact Rounded
-ddbem473 toSci 0.0099999E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
-ddbem474 toSci 0.00099999E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
-ddbem475 toSci 0.000099999E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddbem476 toSci 0.0000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem477 toSci 0.00000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem478 toSci 0.000000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- Exponents with insignificant leading zeros
-ddbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
-ddbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
-ddbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
-ddbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
-ddbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
-ddbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
-ddbas1007 toSci 1e-999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1008 toSci 1e-0999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1009 toSci 1e-00999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1010 toSci 1e-000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1011 toSci 1e-000000000000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1012 toSci 1e-000000000001000000007 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- check for double-rounded subnormals
-ddbas1041 toSci 1.1111111111152444E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
-ddbas1042 toSci 1.1111111111152445E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
-ddbas1043 toSci 1.1111111111152446E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
-
--- clamped large normals
-ddbas1070 toSci 1E+369 -> 1E+369
-ddbas1071 toSci 1E+370 -> 1.0E+370 Clamped
-ddbas1072 toSci 1E+378 -> 1.000000000E+378 Clamped
-ddbas1073 toSci 1E+384 -> 1.000000000000000E+384 Clamped
-ddbas1074 toSci 1E+385 -> Infinity Overflow Inexact Rounded
-
-
--- clamped zeros [see also clamp.decTest]
-ddbas1075 toSci 0e+10000 -> 0E+369 Clamped
-ddbas1076 toSci 0e-10000 -> 0E-398 Clamped
-ddbas1077 toSci -0e+10000 -> -0E+369 Clamped
-ddbas1078 toSci -0e-10000 -> -0E-398 Clamped
-
--- extreme values from next-wider
-ddbas1101 toSci -9.99999999999999999999999999999999E+6144 -> -Infinity Overflow Inexact Rounded
-ddbas1102 toSci -1E-6143 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
-ddbas1103 toSci -1E-6176 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
-ddbas1104 toSci -0 -> -0
-ddbas1105 toSci +0 -> 0
-ddbas1106 toSci +1E-6176 -> 0E-398 Inexact Rounded Subnormal Underflow Clamped
-ddbas1107 toSci +1E-6173 -> 0E-398 Inexact Rounded Subnormal Underflow Clamped
-ddbas1108 toSci +9.99999999999999999999999999999999E+6144 -> Infinity Overflow Inexact Rounded
-
+------------------------------------------------------------------------
+-- ddBase.decTest -- base decDouble <--> string conversions --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests base conversions from string to a decimal number
+-- and back to a string (in Scientific form)
+
+-- Note that unlike other operations the operand is subject to rounding
+-- to conform to emax and precision settings (that is, numbers will
+-- conform to rules and exponent will be in permitted range). The
+-- 'left hand side', therefore, may have numbers that cannot be
+-- represented in a decDouble. Some testcases go to the limit of the
+-- next-wider format, and hence these testcases may also be used to
+-- test narrowing and widening operations.
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddbas001 toSci 0 -> 0
+ddbas002 toSci 1 -> 1
+ddbas003 toSci 1.0 -> 1.0
+ddbas004 toSci 1.00 -> 1.00
+ddbas005 toSci 10 -> 10
+ddbas006 toSci 1000 -> 1000
+ddbas007 toSci 10.0 -> 10.0
+ddbas008 toSci 10.1 -> 10.1
+ddbas009 toSci 10.4 -> 10.4
+ddbas010 toSci 10.5 -> 10.5
+ddbas011 toSci 10.6 -> 10.6
+ddbas012 toSci 10.9 -> 10.9
+ddbas013 toSci 11.0 -> 11.0
+ddbas014 toSci 1.234 -> 1.234
+ddbas015 toSci 0.123 -> 0.123
+ddbas016 toSci 0.012 -> 0.012
+ddbas017 toSci -0 -> -0
+ddbas018 toSci -0.0 -> -0.0
+ddbas019 toSci -00.00 -> -0.00
+
+ddbas021 toSci -1 -> -1
+ddbas022 toSci -1.0 -> -1.0
+ddbas023 toSci -0.1 -> -0.1
+ddbas024 toSci -9.1 -> -9.1
+ddbas025 toSci -9.11 -> -9.11
+ddbas026 toSci -9.119 -> -9.119
+ddbas027 toSci -9.999 -> -9.999
+
+ddbas030 toSci '123456789.123456' -> '123456789.123456'
+ddbas031 toSci '123456789.000000' -> '123456789.000000'
+ddbas032 toSci '123456789123456' -> '123456789123456'
+ddbas033 toSci '0.0000123456789' -> '0.0000123456789'
+ddbas034 toSci '0.00000123456789' -> '0.00000123456789'
+ddbas035 toSci '0.000000123456789' -> '1.23456789E-7'
+ddbas036 toSci '0.0000000123456789' -> '1.23456789E-8'
+
+ddbas037 toSci '0.123456789012344' -> '0.123456789012344'
+ddbas038 toSci '0.123456789012345' -> '0.123456789012345'
+
+-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
+ddbsn001 toSci -9.999999999999999E+384 -> -9.999999999999999E+384
+ddbsn002 toSci -1E-383 -> -1E-383
+ddbsn003 toSci -1E-398 -> -1E-398 Subnormal
+ddbsn004 toSci -0 -> -0
+ddbsn005 toSci +0 -> 0
+ddbsn006 toSci +1E-398 -> 1E-398 Subnormal
+ddbsn007 toSci +1E-383 -> 1E-383
+ddbsn008 toSci +9.999999999999999E+384 -> 9.999999999999999E+384
+
+-- String [many more examples are implicitly tested elsewhere]
+-- strings without E cannot generate E in result
+ddbas040 toSci "12" -> '12'
+ddbas041 toSci "-76" -> '-76'
+ddbas042 toSci "12.76" -> '12.76'
+ddbas043 toSci "+12.76" -> '12.76'
+ddbas044 toSci "012.76" -> '12.76'
+ddbas045 toSci "+0.003" -> '0.003'
+ddbas046 toSci "17." -> '17'
+ddbas047 toSci ".5" -> '0.5'
+ddbas048 toSci "044" -> '44'
+ddbas049 toSci "0044" -> '44'
+ddbas050 toSci "0.0005" -> '0.0005'
+ddbas051 toSci "00.00005" -> '0.00005'
+ddbas052 toSci "0.000005" -> '0.000005'
+ddbas053 toSci "0.0000050" -> '0.0000050'
+ddbas054 toSci "0.0000005" -> '5E-7'
+ddbas055 toSci "0.00000005" -> '5E-8'
+ddbas056 toSci "12345678.543210" -> '12345678.543210'
+ddbas057 toSci "2345678.543210" -> '2345678.543210'
+ddbas058 toSci "345678.543210" -> '345678.543210'
+ddbas059 toSci "0345678.54321" -> '345678.54321'
+ddbas060 toSci "345678.5432" -> '345678.5432'
+ddbas061 toSci "+345678.5432" -> '345678.5432'
+ddbas062 toSci "+0345678.5432" -> '345678.5432'
+ddbas063 toSci "+00345678.5432" -> '345678.5432'
+ddbas064 toSci "-345678.5432" -> '-345678.5432'
+ddbas065 toSci "-0345678.5432" -> '-345678.5432'
+ddbas066 toSci "-00345678.5432" -> '-345678.5432'
+-- examples
+ddbas067 toSci "5E-6" -> '0.000005'
+ddbas068 toSci "50E-7" -> '0.0000050'
+ddbas069 toSci "5E-7" -> '5E-7'
+
+-- [No exotics as no Unicode]
+
+-- rounded with dots in all (including edge) places
+ddbas071 toSci .1234567890123456123 -> 0.1234567890123456 Inexact Rounded
+ddbas072 toSci 1.234567890123456123 -> 1.234567890123456 Inexact Rounded
+ddbas073 toSci 12.34567890123456123 -> 12.34567890123456 Inexact Rounded
+ddbas074 toSci 123.4567890123456123 -> 123.4567890123456 Inexact Rounded
+ddbas075 toSci 1234.567890123456123 -> 1234.567890123456 Inexact Rounded
+ddbas076 toSci 12345.67890123456123 -> 12345.67890123456 Inexact Rounded
+ddbas077 toSci 123456.7890123456123 -> 123456.7890123456 Inexact Rounded
+ddbas078 toSci 1234567.890123456123 -> 1234567.890123456 Inexact Rounded
+ddbas079 toSci 12345678.90123456123 -> 12345678.90123456 Inexact Rounded
+ddbas080 toSci 123456789.0123456123 -> 123456789.0123456 Inexact Rounded
+ddbas081 toSci 1234567890.123456123 -> 1234567890.123456 Inexact Rounded
+ddbas082 toSci 12345678901.23456123 -> 12345678901.23456 Inexact Rounded
+ddbas083 toSci 123456789012.3456123 -> 123456789012.3456 Inexact Rounded
+ddbas084 toSci 1234567890123.456123 -> 1234567890123.456 Inexact Rounded
+ddbas085 toSci 12345678901234.56123 -> 12345678901234.56 Inexact Rounded
+ddbas086 toSci 123456789012345.6123 -> 123456789012345.6 Inexact Rounded
+ddbas087 toSci 1234567890123456.123 -> 1234567890123456 Inexact Rounded
+ddbas088 toSci 12345678901234561.23 -> 1.234567890123456E+16 Inexact Rounded
+ddbas089 toSci 123456789012345612.3 -> 1.234567890123456E+17 Inexact Rounded
+ddbas090 toSci 1234567890123456123. -> 1.234567890123456E+18 Inexact Rounded
+
+
+-- Numbers with E
+ddbas130 toSci "0.000E-1" -> '0.0000'
+ddbas131 toSci "0.000E-2" -> '0.00000'
+ddbas132 toSci "0.000E-3" -> '0.000000'
+ddbas133 toSci "0.000E-4" -> '0E-7'
+ddbas134 toSci "0.00E-2" -> '0.0000'
+ddbas135 toSci "0.00E-3" -> '0.00000'
+ddbas136 toSci "0.00E-4" -> '0.000000'
+ddbas137 toSci "0.00E-5" -> '0E-7'
+ddbas138 toSci "+0E+9" -> '0E+9'
+ddbas139 toSci "-0E+9" -> '-0E+9'
+ddbas140 toSci "1E+9" -> '1E+9'
+ddbas141 toSci "1e+09" -> '1E+9'
+ddbas142 toSci "1E+90" -> '1E+90'
+ddbas143 toSci "+1E+009" -> '1E+9'
+ddbas144 toSci "0E+9" -> '0E+9'
+ddbas145 toSci "1E+9" -> '1E+9'
+ddbas146 toSci "1E+09" -> '1E+9'
+ddbas147 toSci "1e+90" -> '1E+90'
+ddbas148 toSci "1E+009" -> '1E+9'
+ddbas149 toSci "000E+9" -> '0E+9'
+ddbas150 toSci "1E9" -> '1E+9'
+ddbas151 toSci "1e09" -> '1E+9'
+ddbas152 toSci "1E90" -> '1E+90'
+ddbas153 toSci "1E009" -> '1E+9'
+ddbas154 toSci "0E9" -> '0E+9'
+ddbas155 toSci "0.000e+0" -> '0.000'
+ddbas156 toSci "0.000E-1" -> '0.0000'
+ddbas157 toSci "4E+9" -> '4E+9'
+ddbas158 toSci "44E+9" -> '4.4E+10'
+ddbas159 toSci "0.73e-7" -> '7.3E-8'
+ddbas160 toSci "00E+9" -> '0E+9'
+ddbas161 toSci "00E-9" -> '0E-9'
+ddbas162 toSci "10E+9" -> '1.0E+10'
+ddbas163 toSci "10E+09" -> '1.0E+10'
+ddbas164 toSci "10e+90" -> '1.0E+91'
+ddbas165 toSci "10E+009" -> '1.0E+10'
+ddbas166 toSci "100e+9" -> '1.00E+11'
+ddbas167 toSci "100e+09" -> '1.00E+11'
+ddbas168 toSci "100E+90" -> '1.00E+92'
+ddbas169 toSci "100e+009" -> '1.00E+11'
+
+ddbas170 toSci "1.265" -> '1.265'
+ddbas171 toSci "1.265E-20" -> '1.265E-20'
+ddbas172 toSci "1.265E-8" -> '1.265E-8'
+ddbas173 toSci "1.265E-4" -> '0.0001265'
+ddbas174 toSci "1.265E-3" -> '0.001265'
+ddbas175 toSci "1.265E-2" -> '0.01265'
+ddbas176 toSci "1.265E-1" -> '0.1265'
+ddbas177 toSci "1.265E-0" -> '1.265'
+ddbas178 toSci "1.265E+1" -> '12.65'
+ddbas179 toSci "1.265E+2" -> '126.5'
+ddbas180 toSci "1.265E+3" -> '1265'
+ddbas181 toSci "1.265E+4" -> '1.265E+4'
+ddbas182 toSci "1.265E+8" -> '1.265E+8'
+ddbas183 toSci "1.265E+20" -> '1.265E+20'
+
+ddbas190 toSci "12.65" -> '12.65'
+ddbas191 toSci "12.65E-20" -> '1.265E-19'
+ddbas192 toSci "12.65E-8" -> '1.265E-7'
+ddbas193 toSci "12.65E-4" -> '0.001265'
+ddbas194 toSci "12.65E-3" -> '0.01265'
+ddbas195 toSci "12.65E-2" -> '0.1265'
+ddbas196 toSci "12.65E-1" -> '1.265'
+ddbas197 toSci "12.65E-0" -> '12.65'
+ddbas198 toSci "12.65E+1" -> '126.5'
+ddbas199 toSci "12.65E+2" -> '1265'
+ddbas200 toSci "12.65E+3" -> '1.265E+4'
+ddbas201 toSci "12.65E+4" -> '1.265E+5'
+ddbas202 toSci "12.65E+8" -> '1.265E+9'
+ddbas203 toSci "12.65E+20" -> '1.265E+21'
+
+ddbas210 toSci "126.5" -> '126.5'
+ddbas211 toSci "126.5E-20" -> '1.265E-18'
+ddbas212 toSci "126.5E-8" -> '0.000001265'
+ddbas213 toSci "126.5E-4" -> '0.01265'
+ddbas214 toSci "126.5E-3" -> '0.1265'
+ddbas215 toSci "126.5E-2" -> '1.265'
+ddbas216 toSci "126.5E-1" -> '12.65'
+ddbas217 toSci "126.5E-0" -> '126.5'
+ddbas218 toSci "126.5E+1" -> '1265'
+ddbas219 toSci "126.5E+2" -> '1.265E+4'
+ddbas220 toSci "126.5E+3" -> '1.265E+5'
+ddbas221 toSci "126.5E+4" -> '1.265E+6'
+ddbas222 toSci "126.5E+8" -> '1.265E+10'
+ddbas223 toSci "126.5E+20" -> '1.265E+22'
+
+ddbas230 toSci "1265" -> '1265'
+ddbas231 toSci "1265E-20" -> '1.265E-17'
+ddbas232 toSci "1265E-8" -> '0.00001265'
+ddbas233 toSci "1265E-4" -> '0.1265'
+ddbas234 toSci "1265E-3" -> '1.265'
+ddbas235 toSci "1265E-2" -> '12.65'
+ddbas236 toSci "1265E-1" -> '126.5'
+ddbas237 toSci "1265E-0" -> '1265'
+ddbas238 toSci "1265E+1" -> '1.265E+4'
+ddbas239 toSci "1265E+2" -> '1.265E+5'
+ddbas240 toSci "1265E+3" -> '1.265E+6'
+ddbas241 toSci "1265E+4" -> '1.265E+7'
+ddbas242 toSci "1265E+8" -> '1.265E+11'
+ddbas243 toSci "1265E+20" -> '1.265E+23'
+ddbas244 toSci "1265E-9" -> '0.000001265'
+ddbas245 toSci "1265E-10" -> '1.265E-7'
+ddbas246 toSci "1265E-11" -> '1.265E-8'
+ddbas247 toSci "1265E-12" -> '1.265E-9'
+
+ddbas250 toSci "0.1265" -> '0.1265'
+ddbas251 toSci "0.1265E-20" -> '1.265E-21'
+ddbas252 toSci "0.1265E-8" -> '1.265E-9'
+ddbas253 toSci "0.1265E-4" -> '0.00001265'
+ddbas254 toSci "0.1265E-3" -> '0.0001265'
+ddbas255 toSci "0.1265E-2" -> '0.001265'
+ddbas256 toSci "0.1265E-1" -> '0.01265'
+ddbas257 toSci "0.1265E-0" -> '0.1265'
+ddbas258 toSci "0.1265E+1" -> '1.265'
+ddbas259 toSci "0.1265E+2" -> '12.65'
+ddbas260 toSci "0.1265E+3" -> '126.5'
+ddbas261 toSci "0.1265E+4" -> '1265'
+ddbas262 toSci "0.1265E+8" -> '1.265E+7'
+ddbas263 toSci "0.1265E+20" -> '1.265E+19'
+
+-- some more negative zeros [systematic tests below]
+ddbas290 toSci "-0.000E-1" -> '-0.0000'
+ddbas291 toSci "-0.000E-2" -> '-0.00000'
+ddbas292 toSci "-0.000E-3" -> '-0.000000'
+ddbas293 toSci "-0.000E-4" -> '-0E-7'
+ddbas294 toSci "-0.00E-2" -> '-0.0000'
+ddbas295 toSci "-0.00E-3" -> '-0.00000'
+ddbas296 toSci "-0.0E-2" -> '-0.000'
+ddbas297 toSci "-0.0E-3" -> '-0.0000'
+ddbas298 toSci "-0E-2" -> '-0.00'
+ddbas299 toSci "-0E-3" -> '-0.000'
+
+-- Engineering notation tests
+ddbas301 toSci 10e12 -> 1.0E+13
+ddbas302 toEng 10e12 -> 10E+12
+ddbas303 toSci 10e11 -> 1.0E+12
+ddbas304 toEng 10e11 -> 1.0E+12
+ddbas305 toSci 10e10 -> 1.0E+11
+ddbas306 toEng 10e10 -> 100E+9
+ddbas307 toSci 10e9 -> 1.0E+10
+ddbas308 toEng 10e9 -> 10E+9
+ddbas309 toSci 10e8 -> 1.0E+9
+ddbas310 toEng 10e8 -> 1.0E+9
+ddbas311 toSci 10e7 -> 1.0E+8
+ddbas312 toEng 10e7 -> 100E+6
+ddbas313 toSci 10e6 -> 1.0E+7
+ddbas314 toEng 10e6 -> 10E+6
+ddbas315 toSci 10e5 -> 1.0E+6
+ddbas316 toEng 10e5 -> 1.0E+6
+ddbas317 toSci 10e4 -> 1.0E+5
+ddbas318 toEng 10e4 -> 100E+3
+ddbas319 toSci 10e3 -> 1.0E+4
+ddbas320 toEng 10e3 -> 10E+3
+ddbas321 toSci 10e2 -> 1.0E+3
+ddbas322 toEng 10e2 -> 1.0E+3
+ddbas323 toSci 10e1 -> 1.0E+2
+ddbas324 toEng 10e1 -> 100
+ddbas325 toSci 10e0 -> 10
+ddbas326 toEng 10e0 -> 10
+ddbas327 toSci 10e-1 -> 1.0
+ddbas328 toEng 10e-1 -> 1.0
+ddbas329 toSci 10e-2 -> 0.10
+ddbas330 toEng 10e-2 -> 0.10
+ddbas331 toSci 10e-3 -> 0.010
+ddbas332 toEng 10e-3 -> 0.010
+ddbas333 toSci 10e-4 -> 0.0010
+ddbas334 toEng 10e-4 -> 0.0010
+ddbas335 toSci 10e-5 -> 0.00010
+ddbas336 toEng 10e-5 -> 0.00010
+ddbas337 toSci 10e-6 -> 0.000010
+ddbas338 toEng 10e-6 -> 0.000010
+ddbas339 toSci 10e-7 -> 0.0000010
+ddbas340 toEng 10e-7 -> 0.0000010
+ddbas341 toSci 10e-8 -> 1.0E-7
+ddbas342 toEng 10e-8 -> 100E-9
+ddbas343 toSci 10e-9 -> 1.0E-8
+ddbas344 toEng 10e-9 -> 10E-9
+ddbas345 toSci 10e-10 -> 1.0E-9
+ddbas346 toEng 10e-10 -> 1.0E-9
+ddbas347 toSci 10e-11 -> 1.0E-10
+ddbas348 toEng 10e-11 -> 100E-12
+ddbas349 toSci 10e-12 -> 1.0E-11
+ddbas350 toEng 10e-12 -> 10E-12
+ddbas351 toSci 10e-13 -> 1.0E-12
+ddbas352 toEng 10e-13 -> 1.0E-12
+
+ddbas361 toSci 7E12 -> 7E+12
+ddbas362 toEng 7E12 -> 7E+12
+ddbas363 toSci 7E11 -> 7E+11
+ddbas364 toEng 7E11 -> 700E+9
+ddbas365 toSci 7E10 -> 7E+10
+ddbas366 toEng 7E10 -> 70E+9
+ddbas367 toSci 7E9 -> 7E+9
+ddbas368 toEng 7E9 -> 7E+9
+ddbas369 toSci 7E8 -> 7E+8
+ddbas370 toEng 7E8 -> 700E+6
+ddbas371 toSci 7E7 -> 7E+7
+ddbas372 toEng 7E7 -> 70E+6
+ddbas373 toSci 7E6 -> 7E+6
+ddbas374 toEng 7E6 -> 7E+6
+ddbas375 toSci 7E5 -> 7E+5
+ddbas376 toEng 7E5 -> 700E+3
+ddbas377 toSci 7E4 -> 7E+4
+ddbas378 toEng 7E4 -> 70E+3
+ddbas379 toSci 7E3 -> 7E+3
+ddbas380 toEng 7E3 -> 7E+3
+ddbas381 toSci 7E2 -> 7E+2
+ddbas382 toEng 7E2 -> 700
+ddbas383 toSci 7E1 -> 7E+1
+ddbas384 toEng 7E1 -> 70
+ddbas385 toSci 7E0 -> 7
+ddbas386 toEng 7E0 -> 7
+ddbas387 toSci 7E-1 -> 0.7
+ddbas388 toEng 7E-1 -> 0.7
+ddbas389 toSci 7E-2 -> 0.07
+ddbas390 toEng 7E-2 -> 0.07
+ddbas391 toSci 7E-3 -> 0.007
+ddbas392 toEng 7E-3 -> 0.007
+ddbas393 toSci 7E-4 -> 0.0007
+ddbas394 toEng 7E-4 -> 0.0007
+ddbas395 toSci 7E-5 -> 0.00007
+ddbas396 toEng 7E-5 -> 0.00007
+ddbas397 toSci 7E-6 -> 0.000007
+ddbas398 toEng 7E-6 -> 0.000007
+ddbas399 toSci 7E-7 -> 7E-7
+ddbas400 toEng 7E-7 -> 700E-9
+ddbas401 toSci 7E-8 -> 7E-8
+ddbas402 toEng 7E-8 -> 70E-9
+ddbas403 toSci 7E-9 -> 7E-9
+ddbas404 toEng 7E-9 -> 7E-9
+ddbas405 toSci 7E-10 -> 7E-10
+ddbas406 toEng 7E-10 -> 700E-12
+ddbas407 toSci 7E-11 -> 7E-11
+ddbas408 toEng 7E-11 -> 70E-12
+ddbas409 toSci 7E-12 -> 7E-12
+ddbas410 toEng 7E-12 -> 7E-12
+ddbas411 toSci 7E-13 -> 7E-13
+ddbas412 toEng 7E-13 -> 700E-15
+
+-- Exacts remain exact up to precision ..
+rounding: half_up
+ddbas420 toSci 100 -> 100
+ddbas421 toEng 100 -> 100
+ddbas422 toSci 1000 -> 1000
+ddbas423 toEng 1000 -> 1000
+ddbas424 toSci 999.9 -> 999.9
+ddbas425 toEng 999.9 -> 999.9
+ddbas426 toSci 1000.0 -> 1000.0
+ddbas427 toEng 1000.0 -> 1000.0
+ddbas428 toSci 1000.1 -> 1000.1
+ddbas429 toEng 1000.1 -> 1000.1
+ddbas430 toSci 10000 -> 10000
+ddbas431 toEng 10000 -> 10000
+ddbas432 toSci 100000 -> 100000
+ddbas433 toEng 100000 -> 100000
+ddbas434 toSci 1000000 -> 1000000
+ddbas435 toEng 1000000 -> 1000000
+ddbas436 toSci 10000000 -> 10000000
+ddbas437 toEng 10000000 -> 10000000
+ddbas438 toSci 100000000 -> 100000000
+ddbas439 toEng 1000000000000000 -> 1000000000000000
+ddbas440 toSci 10000000000000000 -> 1.000000000000000E+16 Rounded
+ddbas441 toEng 10000000000000000 -> 10.00000000000000E+15 Rounded
+ddbas442 toSci 10000000000000001 -> 1.000000000000000E+16 Rounded Inexact
+ddbas443 toEng 10000000000000001 -> 10.00000000000000E+15 Rounded Inexact
+ddbas444 toSci 10000000000000003 -> 1.000000000000000E+16 Rounded Inexact
+ddbas445 toEng 10000000000000003 -> 10.00000000000000E+15 Rounded Inexact
+ddbas446 toSci 10000000000000005 -> 1.000000000000001E+16 Rounded Inexact
+ddbas447 toEng 10000000000000005 -> 10.00000000000001E+15 Rounded Inexact
+ddbas448 toSci 100000000000000050 -> 1.000000000000001E+17 Rounded Inexact
+ddbas449 toEng 100000000000000050 -> 100.0000000000001E+15 Rounded Inexact
+ddbas450 toSci 10000000000000009 -> 1.000000000000001E+16 Rounded Inexact
+ddbas451 toEng 10000000000000009 -> 10.00000000000001E+15 Rounded Inexact
+ddbas452 toSci 100000000000000000 -> 1.000000000000000E+17 Rounded
+ddbas453 toEng 100000000000000000 -> 100.0000000000000E+15 Rounded
+ddbas454 toSci 100000000000000003 -> 1.000000000000000E+17 Rounded Inexact
+ddbas455 toEng 100000000000000003 -> 100.0000000000000E+15 Rounded Inexact
+ddbas456 toSci 100000000000000005 -> 1.000000000000000E+17 Rounded Inexact
+ddbas457 toEng 100000000000000005 -> 100.0000000000000E+15 Rounded Inexact
+ddbas458 toSci 100000000000000009 -> 1.000000000000000E+17 Rounded Inexact
+ddbas459 toEng 100000000000000009 -> 100.0000000000000E+15 Rounded Inexact
+ddbas460 toSci 1000000000000000000 -> 1.000000000000000E+18 Rounded
+ddbas461 toEng 1000000000000000000 -> 1.000000000000000E+18 Rounded
+ddbas462 toSci 1000000000000000300 -> 1.000000000000000E+18 Rounded Inexact
+ddbas463 toEng 1000000000000000300 -> 1.000000000000000E+18 Rounded Inexact
+ddbas464 toSci 1000000000000000500 -> 1.000000000000001E+18 Rounded Inexact
+ddbas465 toEng 1000000000000000500 -> 1.000000000000001E+18 Rounded Inexact
+ddbas466 toSci 1000000000000000900 -> 1.000000000000001E+18 Rounded Inexact
+ddbas467 toEng 1000000000000000900 -> 1.000000000000001E+18 Rounded Inexact
+ddbas468 toSci 10000000000000000000 -> 1.000000000000000E+19 Rounded
+ddbas469 toEng 10000000000000000000 -> 10.00000000000000E+18 Rounded
+ddbas470 toSci 10000000000000003000 -> 1.000000000000000E+19 Rounded Inexact
+ddbas471 toEng 10000000000000003000 -> 10.00000000000000E+18 Rounded Inexact
+ddbas472 toSci 10000000000000005000 -> 1.000000000000001E+19 Rounded Inexact
+ddbas473 toEng 10000000000000005000 -> 10.00000000000001E+18 Rounded Inexact
+ddbas474 toSci 10000000000000009000 -> 1.000000000000001E+19 Rounded Inexact
+ddbas475 toEng 10000000000000009000 -> 10.00000000000001E+18 Rounded Inexact
+
+-- check rounding modes heeded
+rounding: ceiling
+ddbsr401 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr402 toSci 1.11111111111234549 -> 1.111111111112346 Rounded Inexact
+ddbsr403 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
+ddbsr404 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+rounding: up
+ddbsr405 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr406 toSci 1.11111111111234549 -> 1.111111111112346 Rounded Inexact
+ddbsr407 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
+ddbsr408 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+rounding: floor
+ddbsr410 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr411 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr412 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
+ddbsr413 toSci 1.11111111111234551 -> 1.111111111112345 Rounded Inexact
+rounding: half_down
+ddbsr415 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr416 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr417 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
+ddbsr418 toSci 1.11111111111234650 -> 1.111111111112346 Rounded Inexact
+ddbsr419 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+rounding: half_even
+ddbsr421 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr422 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr423 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
+ddbsr424 toSci 1.11111111111234650 -> 1.111111111112346 Rounded Inexact
+ddbsr425 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+rounding: down
+ddbsr426 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr427 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr428 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
+ddbsr429 toSci 1.11111111111234551 -> 1.111111111112345 Rounded Inexact
+rounding: half_up
+ddbsr431 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr432 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr433 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
+ddbsr434 toSci 1.11111111111234650 -> 1.111111111112347 Rounded Inexact
+ddbsr435 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+-- negatives
+rounding: ceiling
+ddbsr501 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr502 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr503 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
+ddbsr504 toSci -1.11111111111234551 -> -1.111111111112345 Rounded Inexact
+rounding: up
+ddbsr505 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr506 toSci -1.11111111111234549 -> -1.111111111112346 Rounded Inexact
+ddbsr507 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
+ddbsr508 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+rounding: floor
+ddbsr510 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr511 toSci -1.11111111111234549 -> -1.111111111112346 Rounded Inexact
+ddbsr512 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
+ddbsr513 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+rounding: half_down
+ddbsr515 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr516 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr517 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
+ddbsr518 toSci -1.11111111111234650 -> -1.111111111112346 Rounded Inexact
+ddbsr519 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+rounding: half_even
+ddbsr521 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr522 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr523 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
+ddbsr524 toSci -1.11111111111234650 -> -1.111111111112346 Rounded Inexact
+ddbsr525 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+rounding: down
+ddbsr526 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr527 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr528 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
+ddbsr529 toSci -1.11111111111234551 -> -1.111111111112345 Rounded Inexact
+rounding: half_up
+ddbsr531 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr532 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr533 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
+ddbsr534 toSci -1.11111111111234650 -> -1.111111111112347 Rounded Inexact
+ddbsr535 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+
+rounding: half_even
+
+-- The 'baddies' tests from DiagBigDecimal, plus some new ones
+ddbas500 toSci '1..2' -> NaN Conversion_syntax
+ddbas501 toSci '.' -> NaN Conversion_syntax
+ddbas502 toSci '..' -> NaN Conversion_syntax
+ddbas503 toSci '++1' -> NaN Conversion_syntax
+ddbas504 toSci '--1' -> NaN Conversion_syntax
+ddbas505 toSci '-+1' -> NaN Conversion_syntax
+ddbas506 toSci '+-1' -> NaN Conversion_syntax
+ddbas507 toSci '12e' -> NaN Conversion_syntax
+ddbas508 toSci '12e++' -> NaN Conversion_syntax
+ddbas509 toSci '12f4' -> NaN Conversion_syntax
+ddbas510 toSci ' +1' -> NaN Conversion_syntax
+ddbas511 toSci '+ 1' -> NaN Conversion_syntax
+ddbas512 toSci '12 ' -> NaN Conversion_syntax
+ddbas513 toSci ' + 1' -> NaN Conversion_syntax
+ddbas514 toSci ' - 1 ' -> NaN Conversion_syntax
+ddbas515 toSci 'x' -> NaN Conversion_syntax
+ddbas516 toSci '-1-' -> NaN Conversion_syntax
+ddbas517 toSci '12-' -> NaN Conversion_syntax
+ddbas518 toSci '3+' -> NaN Conversion_syntax
+ddbas519 toSci '' -> NaN Conversion_syntax
+ddbas520 toSci '1e-' -> NaN Conversion_syntax
+ddbas521 toSci '7e99999a' -> NaN Conversion_syntax
+ddbas522 toSci '7e123567890x' -> NaN Conversion_syntax
+ddbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
+ddbas524 toSci '' -> NaN Conversion_syntax
+ddbas525 toSci 'e100' -> NaN Conversion_syntax
+ddbas526 toSci '\u0e5a' -> NaN Conversion_syntax
+ddbas527 toSci '\u0b65' -> NaN Conversion_syntax
+ddbas528 toSci '123,65' -> NaN Conversion_syntax
+ddbas529 toSci '1.34.5' -> NaN Conversion_syntax
+ddbas530 toSci '.123.5' -> NaN Conversion_syntax
+ddbas531 toSci '01.35.' -> NaN Conversion_syntax
+ddbas532 toSci '01.35-' -> NaN Conversion_syntax
+ddbas533 toSci '0000..' -> NaN Conversion_syntax
+ddbas534 toSci '.0000.' -> NaN Conversion_syntax
+ddbas535 toSci '00..00' -> NaN Conversion_syntax
+ddbas536 toSci '111e*123' -> NaN Conversion_syntax
+ddbas537 toSci '111e123-' -> NaN Conversion_syntax
+ddbas538 toSci '111e+12+' -> NaN Conversion_syntax
+ddbas539 toSci '111e1-3-' -> NaN Conversion_syntax
+ddbas540 toSci '111e1*23' -> NaN Conversion_syntax
+ddbas541 toSci '111e1e+3' -> NaN Conversion_syntax
+ddbas542 toSci '1e1.0' -> NaN Conversion_syntax
+ddbas543 toSci '1e123e' -> NaN Conversion_syntax
+ddbas544 toSci 'ten' -> NaN Conversion_syntax
+ddbas545 toSci 'ONE' -> NaN Conversion_syntax
+ddbas546 toSci '1e.1' -> NaN Conversion_syntax
+ddbas547 toSci '1e1.' -> NaN Conversion_syntax
+ddbas548 toSci '1ee' -> NaN Conversion_syntax
+ddbas549 toSci 'e+1' -> NaN Conversion_syntax
+ddbas550 toSci '1.23.4' -> NaN Conversion_syntax
+ddbas551 toSci '1.2.1' -> NaN Conversion_syntax
+ddbas552 toSci '1E+1.2' -> NaN Conversion_syntax
+ddbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
+ddbas554 toSci '1E++1' -> NaN Conversion_syntax
+ddbas555 toSci '1E--1' -> NaN Conversion_syntax
+ddbas556 toSci '1E+-1' -> NaN Conversion_syntax
+ddbas557 toSci '1E-+1' -> NaN Conversion_syntax
+ddbas558 toSci '1E''1' -> NaN Conversion_syntax
+ddbas559 toSci "1E""1" -> NaN Conversion_syntax
+ddbas560 toSci "1E""""" -> NaN Conversion_syntax
+-- Near-specials
+ddbas561 toSci "qNaN" -> NaN Conversion_syntax
+ddbas562 toSci "NaNq" -> NaN Conversion_syntax
+ddbas563 toSci "NaNs" -> NaN Conversion_syntax
+ddbas564 toSci "Infi" -> NaN Conversion_syntax
+ddbas565 toSci "Infin" -> NaN Conversion_syntax
+ddbas566 toSci "Infini" -> NaN Conversion_syntax
+ddbas567 toSci "Infinit" -> NaN Conversion_syntax
+ddbas568 toSci "-Infinit" -> NaN Conversion_syntax
+ddbas569 toSci "0Inf" -> NaN Conversion_syntax
+ddbas570 toSci "9Inf" -> NaN Conversion_syntax
+ddbas571 toSci "-0Inf" -> NaN Conversion_syntax
+ddbas572 toSci "-9Inf" -> NaN Conversion_syntax
+ddbas573 toSci "-sNa" -> NaN Conversion_syntax
+ddbas574 toSci "xNaN" -> NaN Conversion_syntax
+ddbas575 toSci "0sNaN" -> NaN Conversion_syntax
+
+-- some baddies with dots and Es and dots and specials
+ddbas576 toSci 'e+1' -> NaN Conversion_syntax
+ddbas577 toSci '.e+1' -> NaN Conversion_syntax
+ddbas578 toSci '+.e+1' -> NaN Conversion_syntax
+ddbas579 toSci '-.e+' -> NaN Conversion_syntax
+ddbas580 toSci '-.e' -> NaN Conversion_syntax
+ddbas581 toSci 'E+1' -> NaN Conversion_syntax
+ddbas582 toSci '.E+1' -> NaN Conversion_syntax
+ddbas583 toSci '+.E+1' -> NaN Conversion_syntax
+ddbas584 toSci '-.E+' -> NaN Conversion_syntax
+ddbas585 toSci '-.E' -> NaN Conversion_syntax
+
+ddbas586 toSci '.NaN' -> NaN Conversion_syntax
+ddbas587 toSci '-.NaN' -> NaN Conversion_syntax
+ddbas588 toSci '+.sNaN' -> NaN Conversion_syntax
+ddbas589 toSci '+.Inf' -> NaN Conversion_syntax
+ddbas590 toSci '.Infinity' -> NaN Conversion_syntax
+
+-- Zeros
+ddbas601 toSci 0.000000000 -> 0E-9
+ddbas602 toSci 0.00000000 -> 0E-8
+ddbas603 toSci 0.0000000 -> 0E-7
+ddbas604 toSci 0.000000 -> 0.000000
+ddbas605 toSci 0.00000 -> 0.00000
+ddbas606 toSci 0.0000 -> 0.0000
+ddbas607 toSci 0.000 -> 0.000
+ddbas608 toSci 0.00 -> 0.00
+ddbas609 toSci 0.0 -> 0.0
+ddbas610 toSci .0 -> 0.0
+ddbas611 toSci 0. -> 0
+ddbas612 toSci -.0 -> -0.0
+ddbas613 toSci -0. -> -0
+ddbas614 toSci -0.0 -> -0.0
+ddbas615 toSci -0.00 -> -0.00
+ddbas616 toSci -0.000 -> -0.000
+ddbas617 toSci -0.0000 -> -0.0000
+ddbas618 toSci -0.00000 -> -0.00000
+ddbas619 toSci -0.000000 -> -0.000000
+ddbas620 toSci -0.0000000 -> -0E-7
+ddbas621 toSci -0.00000000 -> -0E-8
+ddbas622 toSci -0.000000000 -> -0E-9
+
+ddbas630 toSci 0.00E+0 -> 0.00
+ddbas631 toSci 0.00E+1 -> 0.0
+ddbas632 toSci 0.00E+2 -> 0
+ddbas633 toSci 0.00E+3 -> 0E+1
+ddbas634 toSci 0.00E+4 -> 0E+2
+ddbas635 toSci 0.00E+5 -> 0E+3
+ddbas636 toSci 0.00E+6 -> 0E+4
+ddbas637 toSci 0.00E+7 -> 0E+5
+ddbas638 toSci 0.00E+8 -> 0E+6
+ddbas639 toSci 0.00E+9 -> 0E+7
+
+ddbas640 toSci 0.0E+0 -> 0.0
+ddbas641 toSci 0.0E+1 -> 0
+ddbas642 toSci 0.0E+2 -> 0E+1
+ddbas643 toSci 0.0E+3 -> 0E+2
+ddbas644 toSci 0.0E+4 -> 0E+3
+ddbas645 toSci 0.0E+5 -> 0E+4
+ddbas646 toSci 0.0E+6 -> 0E+5
+ddbas647 toSci 0.0E+7 -> 0E+6
+ddbas648 toSci 0.0E+8 -> 0E+7
+ddbas649 toSci 0.0E+9 -> 0E+8
+
+ddbas650 toSci 0E+0 -> 0
+ddbas651 toSci 0E+1 -> 0E+1
+ddbas652 toSci 0E+2 -> 0E+2
+ddbas653 toSci 0E+3 -> 0E+3
+ddbas654 toSci 0E+4 -> 0E+4
+ddbas655 toSci 0E+5 -> 0E+5
+ddbas656 toSci 0E+6 -> 0E+6
+ddbas657 toSci 0E+7 -> 0E+7
+ddbas658 toSci 0E+8 -> 0E+8
+ddbas659 toSci 0E+9 -> 0E+9
+
+ddbas660 toSci 0.0E-0 -> 0.0
+ddbas661 toSci 0.0E-1 -> 0.00
+ddbas662 toSci 0.0E-2 -> 0.000
+ddbas663 toSci 0.0E-3 -> 0.0000
+ddbas664 toSci 0.0E-4 -> 0.00000
+ddbas665 toSci 0.0E-5 -> 0.000000
+ddbas666 toSci 0.0E-6 -> 0E-7
+ddbas667 toSci 0.0E-7 -> 0E-8
+ddbas668 toSci 0.0E-8 -> 0E-9
+ddbas669 toSci 0.0E-9 -> 0E-10
+
+ddbas670 toSci 0.00E-0 -> 0.00
+ddbas671 toSci 0.00E-1 -> 0.000
+ddbas672 toSci 0.00E-2 -> 0.0000
+ddbas673 toSci 0.00E-3 -> 0.00000
+ddbas674 toSci 0.00E-4 -> 0.000000
+ddbas675 toSci 0.00E-5 -> 0E-7
+ddbas676 toSci 0.00E-6 -> 0E-8
+ddbas677 toSci 0.00E-7 -> 0E-9
+ddbas678 toSci 0.00E-8 -> 0E-10
+ddbas679 toSci 0.00E-9 -> 0E-11
+
+ddbas680 toSci 000000. -> 0
+ddbas681 toSci 00000. -> 0
+ddbas682 toSci 0000. -> 0
+ddbas683 toSci 000. -> 0
+ddbas684 toSci 00. -> 0
+ddbas685 toSci 0. -> 0
+ddbas686 toSci +00000. -> 0
+ddbas687 toSci -00000. -> -0
+ddbas688 toSci +0. -> 0
+ddbas689 toSci -0. -> -0
+
+-- Specials
+ddbas700 toSci "NaN" -> NaN
+ddbas701 toSci "nan" -> NaN
+ddbas702 toSci "nAn" -> NaN
+ddbas703 toSci "NAN" -> NaN
+ddbas704 toSci "+NaN" -> NaN
+ddbas705 toSci "+nan" -> NaN
+ddbas706 toSci "+nAn" -> NaN
+ddbas707 toSci "+NAN" -> NaN
+ddbas708 toSci "-NaN" -> -NaN
+ddbas709 toSci "-nan" -> -NaN
+ddbas710 toSci "-nAn" -> -NaN
+ddbas711 toSci "-NAN" -> -NaN
+ddbas712 toSci 'NaN0' -> NaN
+ddbas713 toSci 'NaN1' -> NaN1
+ddbas714 toSci 'NaN12' -> NaN12
+ddbas715 toSci 'NaN123' -> NaN123
+ddbas716 toSci 'NaN1234' -> NaN1234
+ddbas717 toSci 'NaN01' -> NaN1
+ddbas718 toSci 'NaN012' -> NaN12
+ddbas719 toSci 'NaN0123' -> NaN123
+ddbas720 toSci 'NaN01234' -> NaN1234
+ddbas721 toSci 'NaN001' -> NaN1
+ddbas722 toSci 'NaN0012' -> NaN12
+ddbas723 toSci 'NaN00123' -> NaN123
+ddbas724 toSci 'NaN001234' -> NaN1234
+ddbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
+ddbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
+ddbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
+ddbas728 toSci 'NaN-12' -> NaN Conversion_syntax
+ddbas729 toSci 'NaN+12' -> NaN Conversion_syntax
+
+ddbas730 toSci "sNaN" -> sNaN
+ddbas731 toSci "snan" -> sNaN
+ddbas732 toSci "SnAn" -> sNaN
+ddbas733 toSci "SNAN" -> sNaN
+ddbas734 toSci "+sNaN" -> sNaN
+ddbas735 toSci "+snan" -> sNaN
+ddbas736 toSci "+SnAn" -> sNaN
+ddbas737 toSci "+SNAN" -> sNaN
+ddbas738 toSci "-sNaN" -> -sNaN
+ddbas739 toSci "-snan" -> -sNaN
+ddbas740 toSci "-SnAn" -> -sNaN
+ddbas741 toSci "-SNAN" -> -sNaN
+ddbas742 toSci 'sNaN0000' -> sNaN
+ddbas743 toSci 'sNaN7' -> sNaN7
+ddbas744 toSci 'sNaN007234' -> sNaN7234
+ddbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
+ddbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
+ddbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
+
+ddbas748 toSci "Inf" -> Infinity
+ddbas749 toSci "inf" -> Infinity
+ddbas750 toSci "iNf" -> Infinity
+ddbas751 toSci "INF" -> Infinity
+ddbas752 toSci "+Inf" -> Infinity
+ddbas753 toSci "+inf" -> Infinity
+ddbas754 toSci "+iNf" -> Infinity
+ddbas755 toSci "+INF" -> Infinity
+ddbas756 toSci "-Inf" -> -Infinity
+ddbas757 toSci "-inf" -> -Infinity
+ddbas758 toSci "-iNf" -> -Infinity
+ddbas759 toSci "-INF" -> -Infinity
+
+ddbas760 toSci "Infinity" -> Infinity
+ddbas761 toSci "infinity" -> Infinity
+ddbas762 toSci "iNfInItY" -> Infinity
+ddbas763 toSci "INFINITY" -> Infinity
+ddbas764 toSci "+Infinity" -> Infinity
+ddbas765 toSci "+infinity" -> Infinity
+ddbas766 toSci "+iNfInItY" -> Infinity
+ddbas767 toSci "+INFINITY" -> Infinity
+ddbas768 toSci "-Infinity" -> -Infinity
+ddbas769 toSci "-infinity" -> -Infinity
+ddbas770 toSci "-iNfInItY" -> -Infinity
+ddbas771 toSci "-INFINITY" -> -Infinity
+
+-- Specials and zeros for toEng
+ddbast772 toEng "NaN" -> NaN
+ddbast773 toEng "-Infinity" -> -Infinity
+ddbast774 toEng "-sNaN" -> -sNaN
+ddbast775 toEng "-NaN" -> -NaN
+ddbast776 toEng "+Infinity" -> Infinity
+ddbast778 toEng "+sNaN" -> sNaN
+ddbast779 toEng "+NaN" -> NaN
+ddbast780 toEng "INFINITY" -> Infinity
+ddbast781 toEng "SNAN" -> sNaN
+ddbast782 toEng "NAN" -> NaN
+ddbast783 toEng "infinity" -> Infinity
+ddbast784 toEng "snan" -> sNaN
+ddbast785 toEng "nan" -> NaN
+ddbast786 toEng "InFINITY" -> Infinity
+ddbast787 toEng "SnAN" -> sNaN
+ddbast788 toEng "nAN" -> NaN
+ddbast789 toEng "iNfinity" -> Infinity
+ddbast790 toEng "sNan" -> sNaN
+ddbast791 toEng "Nan" -> NaN
+ddbast792 toEng "Infinity" -> Infinity
+ddbast793 toEng "sNaN" -> sNaN
+
+-- Zero toEng, etc.
+ddbast800 toEng 0e+1 -> "0.00E+3" -- doc example
+
+ddbast801 toEng 0.000000000 -> 0E-9
+ddbast802 toEng 0.00000000 -> 0.00E-6
+ddbast803 toEng 0.0000000 -> 0.0E-6
+ddbast804 toEng 0.000000 -> 0.000000
+ddbast805 toEng 0.00000 -> 0.00000
+ddbast806 toEng 0.0000 -> 0.0000
+ddbast807 toEng 0.000 -> 0.000
+ddbast808 toEng 0.00 -> 0.00
+ddbast809 toEng 0.0 -> 0.0
+ddbast810 toEng .0 -> 0.0
+ddbast811 toEng 0. -> 0
+ddbast812 toEng -.0 -> -0.0
+ddbast813 toEng -0. -> -0
+ddbast814 toEng -0.0 -> -0.0
+ddbast815 toEng -0.00 -> -0.00
+ddbast816 toEng -0.000 -> -0.000
+ddbast817 toEng -0.0000 -> -0.0000
+ddbast818 toEng -0.00000 -> -0.00000
+ddbast819 toEng -0.000000 -> -0.000000
+ddbast820 toEng -0.0000000 -> -0.0E-6
+ddbast821 toEng -0.00000000 -> -0.00E-6
+ddbast822 toEng -0.000000000 -> -0E-9
+
+ddbast830 toEng 0.00E+0 -> 0.00
+ddbast831 toEng 0.00E+1 -> 0.0
+ddbast832 toEng 0.00E+2 -> 0
+ddbast833 toEng 0.00E+3 -> 0.00E+3
+ddbast834 toEng 0.00E+4 -> 0.0E+3
+ddbast835 toEng 0.00E+5 -> 0E+3
+ddbast836 toEng 0.00E+6 -> 0.00E+6
+ddbast837 toEng 0.00E+7 -> 0.0E+6
+ddbast838 toEng 0.00E+8 -> 0E+6
+ddbast839 toEng 0.00E+9 -> 0.00E+9
+
+ddbast840 toEng 0.0E+0 -> 0.0
+ddbast841 toEng 0.0E+1 -> 0
+ddbast842 toEng 0.0E+2 -> 0.00E+3
+ddbast843 toEng 0.0E+3 -> 0.0E+3
+ddbast844 toEng 0.0E+4 -> 0E+3
+ddbast845 toEng 0.0E+5 -> 0.00E+6
+ddbast846 toEng 0.0E+6 -> 0.0E+6
+ddbast847 toEng 0.0E+7 -> 0E+6
+ddbast848 toEng 0.0E+8 -> 0.00E+9
+ddbast849 toEng 0.0E+9 -> 0.0E+9
+
+ddbast850 toEng 0E+0 -> 0
+ddbast851 toEng 0E+1 -> 0.00E+3
+ddbast852 toEng 0E+2 -> 0.0E+3
+ddbast853 toEng 0E+3 -> 0E+3
+ddbast854 toEng 0E+4 -> 0.00E+6
+ddbast855 toEng 0E+5 -> 0.0E+6
+ddbast856 toEng 0E+6 -> 0E+6
+ddbast857 toEng 0E+7 -> 0.00E+9
+ddbast858 toEng 0E+8 -> 0.0E+9
+ddbast859 toEng 0E+9 -> 0E+9
+
+ddbast860 toEng 0.0E-0 -> 0.0
+ddbast861 toEng 0.0E-1 -> 0.00
+ddbast862 toEng 0.0E-2 -> 0.000
+ddbast863 toEng 0.0E-3 -> 0.0000
+ddbast864 toEng 0.0E-4 -> 0.00000
+ddbast865 toEng 0.0E-5 -> 0.000000
+ddbast866 toEng 0.0E-6 -> 0.0E-6
+ddbast867 toEng 0.0E-7 -> 0.00E-6
+ddbast868 toEng 0.0E-8 -> 0E-9
+ddbast869 toEng 0.0E-9 -> 0.0E-9
+
+ddbast870 toEng 0.00E-0 -> 0.00
+ddbast871 toEng 0.00E-1 -> 0.000
+ddbast872 toEng 0.00E-2 -> 0.0000
+ddbast873 toEng 0.00E-3 -> 0.00000
+ddbast874 toEng 0.00E-4 -> 0.000000
+ddbast875 toEng 0.00E-5 -> 0.0E-6
+ddbast876 toEng 0.00E-6 -> 0.00E-6
+ddbast877 toEng 0.00E-7 -> 0E-9
+ddbast878 toEng 0.00E-8 -> 0.0E-9
+ddbast879 toEng 0.00E-9 -> 0.00E-9
+
+-- long input strings
+ddbas801 tosci '01234567890123456' -> 1234567890123456
+ddbas802 tosci '001234567890123456' -> 1234567890123456
+ddbas803 tosci '0001234567890123456' -> 1234567890123456
+ddbas804 tosci '00001234567890123456' -> 1234567890123456
+ddbas805 tosci '000001234567890123456' -> 1234567890123456
+ddbas806 tosci '0000001234567890123456' -> 1234567890123456
+ddbas807 tosci '00000001234567890123456' -> 1234567890123456
+ddbas808 tosci '000000001234567890123456' -> 1234567890123456
+ddbas809 tosci '0000000001234567890123456' -> 1234567890123456
+ddbas810 tosci '00000000001234567890123456' -> 1234567890123456
+
+ddbas811 tosci '0.1234567890123456' -> 0.1234567890123456
+ddbas812 tosci '0.01234567890123456' -> 0.01234567890123456
+ddbas813 tosci '0.001234567890123456' -> 0.001234567890123456
+ddbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
+ddbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
+ddbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
+ddbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
+ddbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
+ddbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
+ddbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10
+
+ddbas821 tosci '12345678901234567890' -> 1.234567890123457E+19 Inexact Rounded
+ddbas822 tosci '123456789012345678901' -> 1.234567890123457E+20 Inexact Rounded
+ddbas823 tosci '1234567890123456789012' -> 1.234567890123457E+21 Inexact Rounded
+ddbas824 tosci '12345678901234567890123' -> 1.234567890123457E+22 Inexact Rounded
+ddbas825 tosci '123456789012345678901234' -> 1.234567890123457E+23 Inexact Rounded
+ddbas826 tosci '1234567890123456789012345' -> 1.234567890123457E+24 Inexact Rounded
+ddbas827 tosci '12345678901234567890123456' -> 1.234567890123457E+25 Inexact Rounded
+ddbas828 tosci '123456789012345678901234567' -> 1.234567890123457E+26 Inexact Rounded
+ddbas829 tosci '1234567890123456789012345678' -> 1.234567890123457E+27 Inexact Rounded
+
+-- subnormals and overflows
+ddbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
+ddbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
+ddbas908 toSci '0.9e-999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas909 toSci '0.09e-999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
+ddbas911 toSci '10e-1000000000' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
+ddbas913 toSci '99e-9999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
+ddbas915 toSci '1111e-9999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas916 toSci '1111e-99999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
+-- negatives the same
+ddbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
+ddbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
+ddbas920 toSci '-0.9e-999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas921 toSci '-0.09e-999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
+ddbas923 toSci '-10e-1000000000' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
+ddbas925 toSci '-99e-9999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
+ddbas927 toSci '-1111e-9999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas928 toSci '-1111e-99999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
+
+-- overflow results at different rounding modes
+rounding: ceiling
+ddbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas931 toSci '-7e10000' -> -9.999999999999999E+384 Overflow Inexact Rounded
+rounding: up
+ddbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: down
+ddbas934 toSci '7e10000' -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddbas935 toSci '-7e10000' -> -9.999999999999999E+384 Overflow Inexact Rounded
+rounding: floor
+ddbas936 toSci '7e10000' -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_up
+ddbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_even
+ddbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_down
+ddbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_even
+
+-- Now check 854/754r some subnormals and underflow to 0
+ddbem400 toSci 1.0000E-383 -> 1.0000E-383
+ddbem401 toSci 0.1E-394 -> 1E-395 Subnormal
+ddbem402 toSci 0.1000E-394 -> 1.000E-395 Subnormal
+ddbem403 toSci 0.0100E-394 -> 1.00E-396 Subnormal
+ddbem404 toSci 0.0010E-394 -> 1.0E-397 Subnormal
+ddbem405 toSci 0.0001E-394 -> 1E-398 Subnormal
+ddbem406 toSci 0.00010E-394 -> 1E-398 Subnormal Rounded
+ddbem407 toSci 0.00013E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddbem408 toSci 0.00015E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem409 toSci 0.00017E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem410 toSci 0.00023E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem411 toSci 0.00025E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem412 toSci 0.00027E-394 -> 3E-398 Underflow Subnormal Inexact Rounded
+ddbem413 toSci 0.000149E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddbem414 toSci 0.000150E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem415 toSci 0.000151E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem416 toSci 0.000249E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem417 toSci 0.000250E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem418 toSci 0.000251E-394 -> 3E-398 Underflow Subnormal Inexact Rounded
+ddbem419 toSci 0.00009E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddbem420 toSci 0.00005E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem421 toSci 0.00003E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem422 toSci 0.000009E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem423 toSci 0.000005E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem424 toSci 0.000003E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+ddbem425 toSci 0.001049E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
+ddbem426 toSci 0.001050E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
+ddbem427 toSci 0.001051E-394 -> 1.1E-397 Underflow Subnormal Inexact Rounded
+ddbem428 toSci 0.001149E-394 -> 1.1E-397 Underflow Subnormal Inexact Rounded
+ddbem429 toSci 0.001150E-394 -> 1.2E-397 Underflow Subnormal Inexact Rounded
+ddbem430 toSci 0.001151E-394 -> 1.2E-397 Underflow Subnormal Inexact Rounded
+
+ddbem432 toSci 0.010049E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
+ddbem433 toSci 0.010050E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
+ddbem434 toSci 0.010051E-394 -> 1.01E-396 Underflow Subnormal Inexact Rounded
+ddbem435 toSci 0.010149E-394 -> 1.01E-396 Underflow Subnormal Inexact Rounded
+ddbem436 toSci 0.010150E-394 -> 1.02E-396 Underflow Subnormal Inexact Rounded
+ddbem437 toSci 0.010151E-394 -> 1.02E-396 Underflow Subnormal Inexact Rounded
+
+ddbem440 toSci 0.10103E-394 -> 1.010E-395 Underflow Subnormal Inexact Rounded
+ddbem441 toSci 0.10105E-394 -> 1.010E-395 Underflow Subnormal Inexact Rounded
+ddbem442 toSci 0.10107E-394 -> 1.011E-395 Underflow Subnormal Inexact Rounded
+ddbem443 toSci 0.10113E-394 -> 1.011E-395 Underflow Subnormal Inexact Rounded
+ddbem444 toSci 0.10115E-394 -> 1.012E-395 Underflow Subnormal Inexact Rounded
+ddbem445 toSci 0.10117E-394 -> 1.012E-395 Underflow Subnormal Inexact Rounded
+
+ddbem450 toSci 1.10730E-395 -> 1.107E-395 Underflow Subnormal Inexact Rounded
+ddbem451 toSci 1.10750E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
+ddbem452 toSci 1.10770E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
+ddbem453 toSci 1.10830E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
+ddbem454 toSci 1.10850E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
+ddbem455 toSci 1.10870E-395 -> 1.109E-395 Underflow Subnormal Inexact Rounded
+
+-- make sure sign OK
+ddbem456 toSci -0.10103E-394 -> -1.010E-395 Underflow Subnormal Inexact Rounded
+ddbem457 toSci -0.10105E-394 -> -1.010E-395 Underflow Subnormal Inexact Rounded
+ddbem458 toSci -0.10107E-394 -> -1.011E-395 Underflow Subnormal Inexact Rounded
+ddbem459 toSci -0.10113E-394 -> -1.011E-395 Underflow Subnormal Inexact Rounded
+ddbem460 toSci -0.10115E-394 -> -1.012E-395 Underflow Subnormal Inexact Rounded
+ddbem461 toSci -0.10117E-394 -> -1.012E-395 Underflow Subnormal Inexact Rounded
+
+-- '999s' cases
+ddbem464 toSci 999999E-395 -> 9.99999E-390 Subnormal
+ddbem465 toSci 99999.0E-394 -> 9.99990E-390 Subnormal
+ddbem466 toSci 99999.E-394 -> 9.9999E-390 Subnormal
+ddbem467 toSci 9999.9E-394 -> 9.9999E-391 Subnormal
+ddbem468 toSci 999.99E-394 -> 9.9999E-392 Subnormal
+ddbem469 toSci 99.999E-394 -> 9.9999E-393 Subnormal
+ddbem470 toSci 9.9999E-394 -> 9.9999E-394 Subnormal
+ddbem471 toSci 0.99999E-394 -> 1.0000E-394 Underflow Subnormal Inexact Rounded
+ddbem472 toSci 0.099999E-394 -> 1.000E-395 Underflow Subnormal Inexact Rounded
+ddbem473 toSci 0.0099999E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
+ddbem474 toSci 0.00099999E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
+ddbem475 toSci 0.000099999E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddbem476 toSci 0.0000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem477 toSci 0.00000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem478 toSci 0.000000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- Exponents with insignificant leading zeros
+ddbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
+ddbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
+ddbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
+ddbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
+ddbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
+ddbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
+ddbas1007 toSci 1e-999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1008 toSci 1e-0999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1009 toSci 1e-00999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1010 toSci 1e-000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1011 toSci 1e-000000000000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1012 toSci 1e-000000000001000000007 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- check for double-rounded subnormals
+ddbas1041 toSci 1.1111111111152444E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
+ddbas1042 toSci 1.1111111111152445E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
+ddbas1043 toSci 1.1111111111152446E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
+
+-- clamped large normals
+ddbas1070 toSci 1E+369 -> 1E+369
+ddbas1071 toSci 1E+370 -> 1.0E+370 Clamped
+ddbas1072 toSci 1E+378 -> 1.000000000E+378 Clamped
+ddbas1073 toSci 1E+384 -> 1.000000000000000E+384 Clamped
+ddbas1074 toSci 1E+385 -> Infinity Overflow Inexact Rounded
+
+
+-- clamped zeros [see also clamp.decTest]
+ddbas1075 toSci 0e+10000 -> 0E+369 Clamped
+ddbas1076 toSci 0e-10000 -> 0E-398 Clamped
+ddbas1077 toSci -0e+10000 -> -0E+369 Clamped
+ddbas1078 toSci -0e-10000 -> -0E-398 Clamped
+
+-- extreme values from next-wider
+ddbas1101 toSci -9.99999999999999999999999999999999E+6144 -> -Infinity Overflow Inexact Rounded
+ddbas1102 toSci -1E-6143 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
+ddbas1103 toSci -1E-6176 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
+ddbas1104 toSci -0 -> -0
+ddbas1105 toSci +0 -> 0
+ddbas1106 toSci +1E-6176 -> 0E-398 Inexact Rounded Subnormal Underflow Clamped
+ddbas1107 toSci +1E-6173 -> 0E-398 Inexact Rounded Subnormal Underflow Clamped
+ddbas1108 toSci +9.99999999999999999999999999999999E+6144 -> Infinity Overflow Inexact Rounded
+
diff --git a/Lib/test/decimaltestdata/ddCanonical.decTest b/Lib/test/decimaltestdata/ddCanonical.decTest
index b4f9e32c98..824de83aba 100644
--- a/Lib/test/decimaltestdata/ddCanonical.decTest
+++ b/Lib/test/decimaltestdata/ddCanonical.decTest
@@ -1,357 +1,357 @@
-------------------------------------------------------------------------
--- ddCanonical.decTest -- test decDouble canonical results --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests that copy operations leave uncanonical operands
--- unchanged, and vice versa
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Uncanonical declets are: abc, where:
--- a=1,2,3
--- b=6,7,e,f
--- c=e,f
-
--- assert some standard (canonical) values; this tests that FromString
--- produces canonical results (many more in decimalNN)
-ddcan001 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
-ddcan002 apply 0 -> #2238000000000000
-ddcan003 apply 1 -> #2238000000000001
-ddcan004 apply -1 -> #a238000000000001
-ddcan005 apply Infinity -> #7800000000000000
-ddcan006 apply -Infinity -> #f800000000000000
-ddcan007 apply -NaN -> #fc00000000000000
-ddcan008 apply -sNaN -> #fe00000000000000
-ddcan009 apply NaN999999999999999 -> #7c00ff3fcff3fcff
-ddcan010 apply sNaN999999999999999 -> #7e00ff3fcff3fcff
-decan011 apply 9999999999999999 -> #6e38ff3fcff3fcff
-ddcan012 apply 7.50 -> #22300000000003d0
-ddcan013 apply 9.99 -> #22300000000000ff
-
--- Base tests for canonical encodings (individual operator
--- propagation is tested later)
-
--- Finites: declets in coefficient
-ddcan021 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan022 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan023 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan024 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan025 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
-ddcan026 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
-ddcan027 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
-ddcan028 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
-ddcan030 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
-ddcan031 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
-ddcan032 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
-ddcan033 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
-ddcan035 canonical #77fcff3fdff3fcff -> #77fcff3fcff3fcff
-ddcan036 canonical #77fcff3feff3fcff -> #77fcff3fcff3fcff
-
--- NaN: declets in payload
-ddcan100 canonical NaN999999999999999 -> #7c00ff3fcff3fcff
-ddcan101 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan102 canonical #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan103 canonical #7c00ffffcff3fcff -> #7c00ff3fcff3fcff
-ddcan104 canonical #7c00ff3ffff3fcff -> #7c00ff3fcff3fcff
-ddcan105 canonical #7c00ff3fcffffcff -> #7c00ff3fcff3fcff
-ddcan106 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
-ddcan107 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-ddcan110 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan112 canonical #7d00ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan113 canonical #7c80ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan114 canonical #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan115 canonical #7c20ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan116 canonical #7c10ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan117 canonical #7c08ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan118 canonical #7c04ff3fcff3fcff -> #7c00ff3fcff3fcff
-
--- sNaN: declets in payload
-ddcan120 canonical sNaN999999999999999 -> #7e00ff3fcff3fcff
-ddcan121 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan122 canonical #7e03ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan123 canonical #7e00ffffcff3fcff -> #7e00ff3fcff3fcff
-ddcan124 canonical #7e00ff3ffff3fcff -> #7e00ff3fcff3fcff
-ddcan125 canonical #7e00ff3fcffffcff -> #7e00ff3fcff3fcff
-ddcan126 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
-ddcan127 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
--- sNaN: exponent continuation bits [excluding sNaN selector]
-ddcan130 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan132 canonical #7f00ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan133 canonical #7e80ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan134 canonical #7e40ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan135 canonical #7e20ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan136 canonical #7e10ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan137 canonical #7e08ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan138 canonical #7e04ff3fcff3fcff -> #7e00ff3fcff3fcff
-
--- Inf: exponent continuation bits
-ddcan140 canonical #7800000000000000 -> #7800000000000000
-ddcan141 canonical #7900000000000000 -> #7800000000000000
-ddcan142 canonical #7a00000000000000 -> #7800000000000000
-ddcan143 canonical #7880000000000000 -> #7800000000000000
-ddcan144 canonical #7840000000000000 -> #7800000000000000
-ddcan145 canonical #7820000000000000 -> #7800000000000000
-ddcan146 canonical #7810000000000000 -> #7800000000000000
-ddcan147 canonical #7808000000000000 -> #7800000000000000
-ddcan148 canonical #7804000000000000 -> #7800000000000000
-
--- Inf: coefficient continuation bits (first, last, and a few others)
-ddcan150 canonical #7800000000000000 -> #7800000000000000
-ddcan151 canonical #7802000000000000 -> #7800000000000000
-ddcan152 canonical #7800000000000001 -> #7800000000000000
-ddcan153 canonical #7801000000000000 -> #7800000000000000
-ddcan154 canonical #7800200000000000 -> #7800000000000000
-ddcan155 canonical #7800080000000000 -> #7800000000000000
-ddcan156 canonical #7800002000000000 -> #7800000000000000
-ddcan157 canonical #7800000400000000 -> #7800000000000000
-ddcan158 canonical #7800000040000000 -> #7800000000000000
-ddcan159 canonical #7800000008000000 -> #7800000000000000
-ddcan160 canonical #7800000000400000 -> #7800000000000000
-ddcan161 canonical #7800000000020000 -> #7800000000000000
-ddcan162 canonical #7800000000008000 -> #7800000000000000
-ddcan163 canonical #7800000000000200 -> #7800000000000000
-ddcan164 canonical #7800000000000040 -> #7800000000000000
-ddcan165 canonical #7800000000000008 -> #7800000000000000
-
-
--- Now the operators -- trying to check paths that might fail to
--- canonicalize propagated operands
-
------ Add:
--- Finites: neutral 0
-ddcan202 add 0E+384 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan203 add #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
--- tiny zero
-ddcan204 add 0E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Rounded
-ddcan205 add #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
--- tiny non zero
-ddcan206 add -1E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Inexact Rounded
-ddcan207 add #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
--- NaN: declets in payload
-ddcan211 add 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan212 add #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-ddcan213 add 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan214 add #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
--- sNaN: declets in payload
-ddcan215 add 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan216 add #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-ddcan217 add 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan218 add #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-ddcan220 add 0 #7880000000000000 -> #7800000000000000
-ddcan221 add #7880000000000000 0 -> #7800000000000000
--- Inf: coefficient continuation bits
-ddcan222 add 0 #7802000000000000 -> #7800000000000000
-ddcan223 add #7802000000000000 0 -> #7800000000000000
-ddcan224 add 0 #7800000000000001 -> #7800000000000000
-ddcan225 add #7800000000000001 0 -> #7800000000000000
-ddcan226 add 0 #7800002000000000 -> #7800000000000000
-ddcan227 add #7800002000000000 0 -> #7800000000000000
-
------ Class: [does not return encoded]
-
------ Compare:
-ddcan231 compare -Inf 1 -> #a238000000000001
-ddcan232 compare -Inf -Inf -> #2238000000000000
-ddcan233 compare 1 -Inf -> #2238000000000001
-ddcan234 compare #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff
-ddcan235 compare #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
-
------ CompareSig:
-ddcan241 comparesig -Inf 1 -> #a238000000000001
-ddcan242 comparesig -Inf -Inf -> #2238000000000000
-ddcan243 comparesig 1 -Inf -> #2238000000000001
-ddcan244 comparesig #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
-ddcan245 comparesig #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
-
------ Copy: [does not usually canonicalize]
--- finites
-ddcan250 copy #77ffff3fcff3fcff -> #77ffff3fcff3fcff
-ddcan251 copy #77fcff3fdff3fcff -> #77fcff3fdff3fcff
--- NaNs
-ddcan252 copy #7c03ff3fcff3fcff -> #7c03ff3fcff3fcff
-ddcan253 copy #7c00ff3fcff3ffff -> #7c00ff3fcff3ffff
-ddcan254 copy #7d00ff3fcff3fcff -> #7d00ff3fcff3fcff
-ddcan255 copy #7c04ff3fcff3fcff -> #7c04ff3fcff3fcff
--- sNaN
-ddcan256 copy #7e00ff3fcffffcff -> #7e00ff3fcffffcff
-ddcan257 copy #7e40ff3fcff3fcff -> #7e40ff3fcff3fcff
--- Inf
-ddcan258 copy #7a00000000000000 -> #7a00000000000000
-ddcan259 copy #7800200000000000 -> #7800200000000000
-
------ CopyAbs: [does not usually canonicalize]
--- finites
-ddcan260 copyabs #f7ffff3fcff3fcff -> #77ffff3fcff3fcff
-ddcan261 copyabs #f7fcff3fdff3fcff -> #77fcff3fdff3fcff
--- NaNs
-ddcan262 copyabs #fc03ff3fcff3fcff -> #7c03ff3fcff3fcff
-ddcan263 copyabs #fc00ff3fcff3ffff -> #7c00ff3fcff3ffff
-ddcan264 copyabs #fd00ff3fcff3fcff -> #7d00ff3fcff3fcff
-ddcan265 copyabs #fc04ff3fcff3fcff -> #7c04ff3fcff3fcff
--- sNaN
-ddcan266 copyabs #fe00ff3fcffffcff -> #7e00ff3fcffffcff
-ddcan267 copyabs #fe40ff3fcff3fcff -> #7e40ff3fcff3fcff
--- Inf
-ddcan268 copyabs #fa00000000000000 -> #7a00000000000000
-ddcan269 copyabs #f800200000000000 -> #7800200000000000
-
------ CopyNegate: [does not usually canonicalize]
--- finites
-ddcan270 copynegate #77ffff3fcff3fcff -> #f7ffff3fcff3fcff
-ddcan271 copynegate #77fcff3fdff3fcff -> #f7fcff3fdff3fcff
--- NaNs
-ddcan272 copynegate #7c03ff3fcff3fcff -> #fc03ff3fcff3fcff
-ddcan273 copynegate #7c00ff3fcff3ffff -> #fc00ff3fcff3ffff
-ddcan274 copynegate #7d00ff3fcff3fcff -> #fd00ff3fcff3fcff
-ddcan275 copynegate #7c04ff3fcff3fcff -> #fc04ff3fcff3fcff
--- sNaN
-ddcan276 copynegate #7e00ff3fcffffcff -> #fe00ff3fcffffcff
-ddcan277 copynegate #7e40ff3fcff3fcff -> #fe40ff3fcff3fcff
--- Inf
-ddcan278 copynegate #7a00000000000000 -> #fa00000000000000
-ddcan279 copynegate #7800200000000000 -> #f800200000000000
-
------ CopySign: [does not usually canonicalize]
--- finites
-ddcan280 copysign #77ffff3fcff3fcff -1 -> #f7ffff3fcff3fcff
-ddcan281 copysign #77fcff3fdff3fcff 1 -> #77fcff3fdff3fcff
--- NaNs
-ddcan282 copysign #7c03ff3fcff3fcff -1 -> #fc03ff3fcff3fcff
-ddcan283 copysign #7c00ff3fcff3ffff 1 -> #7c00ff3fcff3ffff
-ddcan284 copysign #7d00ff3fcff3fcff -1 -> #fd00ff3fcff3fcff
-ddcan285 copysign #7c04ff3fcff3fcff 1 -> #7c04ff3fcff3fcff
--- sNaN
-ddcan286 copysign #7e00ff3fcffffcff -1 -> #fe00ff3fcffffcff
-ddcan287 copysign #7e40ff3fcff3fcff 1 -> #7e40ff3fcff3fcff
--- Inf
-ddcan288 copysign #7a00000000000000 -1 -> #fa00000000000000
-ddcan289 copysign #7800200000000000 1 -> #7800200000000000
-
------ Multiply:
--- Finites: neutral 0
-ddcan302 multiply 1 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan303 multiply #77fcffffcff3fcff 1 -> #77fcff3fcff3fcff
--- negative
-ddcan306 multiply -1 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
-ddcan307 multiply #77fcffffcff3fcff -1 -> #f7fcff3fcff3fcff
--- NaN: declets in payload
-ddcan311 multiply 1 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan312 multiply #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-ddcan313 multiply 1 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan314 multiply #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
--- sNaN: declets in payload
-ddcan315 multiply 1 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan316 multiply #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-ddcan317 multiply 1 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan318 multiply #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-ddcan320 multiply 1 #7880000000000000 -> #7800000000000000
-ddcan321 multiply #7880000000000000 1 -> #7800000000000000
--- Inf: coefficient continuation bits
-ddcan322 multiply 1 #7802000000000000 -> #7800000000000000
-ddcan323 multiply #7802000000000000 1 -> #7800000000000000
-ddcan324 multiply 1 #7800000000000001 -> #7800000000000000
-ddcan325 multiply #7800000000000001 1 -> #7800000000000000
-ddcan326 multiply 1 #7800002000000000 -> #7800000000000000
-ddcan327 multiply #7800002000000000 1 -> #7800000000000000
-
------ Quantize:
-ddcan401 quantize #6e38ff3ffff3fcff 1 -> #6e38ff3fcff3fcff
-ddcan402 quantize #6e38ff3fcff3fdff 0 -> #6e38ff3fcff3fcff
-ddcan403 quantize #7880000000000000 Inf -> #7800000000000000
-ddcan404 quantize #7802000000000000 -Inf -> #7800000000000000
-ddcan410 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
-ddcan411 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
-ddcan412 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
-ddcan413 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
-ddcan414 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
-ddcan415 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
-ddcan416 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
-ddcan417 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
-
------ Subtract:
--- Finites: neutral 0
-ddcan502 subtract 0E+384 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
-ddcan503 subtract #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
--- tiny zero
-ddcan504 subtract 0E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Rounded
-ddcan505 subtract #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
--- tiny non zero
-ddcan506 subtract -1E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Inexact Rounded
-ddcan507 subtract #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
--- NaN: declets in payload
-ddcan511 subtract 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan512 subtract #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-ddcan513 subtract 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan514 subtract #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
--- sNaN: declets in payload
-ddcan515 subtract 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan516 subtract #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-ddcan517 subtract 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan518 subtract #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-ddcan520 subtract 0 #7880000000000000 -> #f800000000000000
-ddcan521 subtract #7880000000000000 0 -> #7800000000000000
--- Inf: coefficient continuation bits
-ddcan522 subtract 0 #7802000000000000 -> #f800000000000000
-ddcan523 subtract #7802000000000000 0 -> #7800000000000000
-ddcan524 subtract 0 #7800000000000001 -> #f800000000000000
-ddcan525 subtract #7800000000000001 0 -> #7800000000000000
-ddcan526 subtract 0 #7800002000000000 -> #f800000000000000
-ddcan527 subtract #7800002000000000 0 -> #7800000000000000
-
------ ToIntegral:
-ddcan601 tointegralx #6e38ff3ffff3fcff -> #6e38ff3fcff3fcff
-ddcan602 tointegralx #6e38ff3fcff3fdff -> #6e38ff3fcff3fcff
-ddcan603 tointegralx #7880000000000000 -> #7800000000000000
-ddcan604 tointegralx #7802000000000000 -> #7800000000000000
-ddcan610 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan611 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan612 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan613 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan614 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan615 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan616 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan617 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
--- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
-ddcan618 tointegralx #2238000000000fff -> #2238000000000cff
-ddcan619 tointegralx #2230000000000fff -> #2238000000000040 Inexact Rounded
-ddcan620 tointegralx #222c000000000fff -> #2238000000000004 Inexact Rounded
-ddcan621 tointegralx #2228000000000fff -> #2238000000000000 Inexact Rounded
-ddcan622 tointegralx #a238000000000fff -> #a238000000000cff
-ddcan623 tointegralx #a230000000000fff -> #a238000000000040 Inexact Rounded
-ddcan624 tointegralx #a22c000000000fff -> #a238000000000004 Inexact Rounded
-ddcan625 tointegralx #a228000000000fff -> #a238000000000000 Inexact Rounded
-
-
-
+------------------------------------------------------------------------
+-- ddCanonical.decTest -- test decDouble canonical results --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests that copy operations leave uncanonical operands
+-- unchanged, and vice versa
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Uncanonical declets are: abc, where:
+-- a=1,2,3
+-- b=6,7,e,f
+-- c=e,f
+
+-- assert some standard (canonical) values; this tests that FromString
+-- produces canonical results (many more in decimalNN)
+ddcan001 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
+ddcan002 apply 0 -> #2238000000000000
+ddcan003 apply 1 -> #2238000000000001
+ddcan004 apply -1 -> #a238000000000001
+ddcan005 apply Infinity -> #7800000000000000
+ddcan006 apply -Infinity -> #f800000000000000
+ddcan007 apply -NaN -> #fc00000000000000
+ddcan008 apply -sNaN -> #fe00000000000000
+ddcan009 apply NaN999999999999999 -> #7c00ff3fcff3fcff
+ddcan010 apply sNaN999999999999999 -> #7e00ff3fcff3fcff
+decan011 apply 9999999999999999 -> #6e38ff3fcff3fcff
+ddcan012 apply 7.50 -> #22300000000003d0
+ddcan013 apply 9.99 -> #22300000000000ff
+
+-- Base tests for canonical encodings (individual operator
+-- propagation is tested later)
+
+-- Finites: declets in coefficient
+ddcan021 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan022 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan023 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan024 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan025 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
+ddcan026 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
+ddcan027 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
+ddcan028 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
+ddcan030 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
+ddcan031 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
+ddcan032 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
+ddcan033 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
+ddcan035 canonical #77fcff3fdff3fcff -> #77fcff3fcff3fcff
+ddcan036 canonical #77fcff3feff3fcff -> #77fcff3fcff3fcff
+
+-- NaN: declets in payload
+ddcan100 canonical NaN999999999999999 -> #7c00ff3fcff3fcff
+ddcan101 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan102 canonical #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan103 canonical #7c00ffffcff3fcff -> #7c00ff3fcff3fcff
+ddcan104 canonical #7c00ff3ffff3fcff -> #7c00ff3fcff3fcff
+ddcan105 canonical #7c00ff3fcffffcff -> #7c00ff3fcff3fcff
+ddcan106 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
+ddcan107 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+ddcan110 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan112 canonical #7d00ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan113 canonical #7c80ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan114 canonical #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan115 canonical #7c20ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan116 canonical #7c10ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan117 canonical #7c08ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan118 canonical #7c04ff3fcff3fcff -> #7c00ff3fcff3fcff
+
+-- sNaN: declets in payload
+ddcan120 canonical sNaN999999999999999 -> #7e00ff3fcff3fcff
+ddcan121 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan122 canonical #7e03ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan123 canonical #7e00ffffcff3fcff -> #7e00ff3fcff3fcff
+ddcan124 canonical #7e00ff3ffff3fcff -> #7e00ff3fcff3fcff
+ddcan125 canonical #7e00ff3fcffffcff -> #7e00ff3fcff3fcff
+ddcan126 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
+ddcan127 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+ddcan130 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan132 canonical #7f00ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan133 canonical #7e80ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan134 canonical #7e40ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan135 canonical #7e20ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan136 canonical #7e10ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan137 canonical #7e08ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan138 canonical #7e04ff3fcff3fcff -> #7e00ff3fcff3fcff
+
+-- Inf: exponent continuation bits
+ddcan140 canonical #7800000000000000 -> #7800000000000000
+ddcan141 canonical #7900000000000000 -> #7800000000000000
+ddcan142 canonical #7a00000000000000 -> #7800000000000000
+ddcan143 canonical #7880000000000000 -> #7800000000000000
+ddcan144 canonical #7840000000000000 -> #7800000000000000
+ddcan145 canonical #7820000000000000 -> #7800000000000000
+ddcan146 canonical #7810000000000000 -> #7800000000000000
+ddcan147 canonical #7808000000000000 -> #7800000000000000
+ddcan148 canonical #7804000000000000 -> #7800000000000000
+
+-- Inf: coefficient continuation bits (first, last, and a few others)
+ddcan150 canonical #7800000000000000 -> #7800000000000000
+ddcan151 canonical #7802000000000000 -> #7800000000000000
+ddcan152 canonical #7800000000000001 -> #7800000000000000
+ddcan153 canonical #7801000000000000 -> #7800000000000000
+ddcan154 canonical #7800200000000000 -> #7800000000000000
+ddcan155 canonical #7800080000000000 -> #7800000000000000
+ddcan156 canonical #7800002000000000 -> #7800000000000000
+ddcan157 canonical #7800000400000000 -> #7800000000000000
+ddcan158 canonical #7800000040000000 -> #7800000000000000
+ddcan159 canonical #7800000008000000 -> #7800000000000000
+ddcan160 canonical #7800000000400000 -> #7800000000000000
+ddcan161 canonical #7800000000020000 -> #7800000000000000
+ddcan162 canonical #7800000000008000 -> #7800000000000000
+ddcan163 canonical #7800000000000200 -> #7800000000000000
+ddcan164 canonical #7800000000000040 -> #7800000000000000
+ddcan165 canonical #7800000000000008 -> #7800000000000000
+
+
+-- Now the operators -- trying to check paths that might fail to
+-- canonicalize propagated operands
+
+----- Add:
+-- Finites: neutral 0
+ddcan202 add 0E+384 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan203 add #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
+-- tiny zero
+ddcan204 add 0E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Rounded
+ddcan205 add #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
+-- tiny non zero
+ddcan206 add -1E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Inexact Rounded
+ddcan207 add #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
+-- NaN: declets in payload
+ddcan211 add 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan212 add #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+ddcan213 add 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan214 add #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
+-- sNaN: declets in payload
+ddcan215 add 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan216 add #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+ddcan217 add 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan218 add #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+ddcan220 add 0 #7880000000000000 -> #7800000000000000
+ddcan221 add #7880000000000000 0 -> #7800000000000000
+-- Inf: coefficient continuation bits
+ddcan222 add 0 #7802000000000000 -> #7800000000000000
+ddcan223 add #7802000000000000 0 -> #7800000000000000
+ddcan224 add 0 #7800000000000001 -> #7800000000000000
+ddcan225 add #7800000000000001 0 -> #7800000000000000
+ddcan226 add 0 #7800002000000000 -> #7800000000000000
+ddcan227 add #7800002000000000 0 -> #7800000000000000
+
+----- Class: [does not return encoded]
+
+----- Compare:
+ddcan231 compare -Inf 1 -> #a238000000000001
+ddcan232 compare -Inf -Inf -> #2238000000000000
+ddcan233 compare 1 -Inf -> #2238000000000001
+ddcan234 compare #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff
+ddcan235 compare #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
+
+----- CompareSig:
+ddcan241 comparesig -Inf 1 -> #a238000000000001
+ddcan242 comparesig -Inf -Inf -> #2238000000000000
+ddcan243 comparesig 1 -Inf -> #2238000000000001
+ddcan244 comparesig #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
+ddcan245 comparesig #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
+
+----- Copy: [does not usually canonicalize]
+-- finites
+ddcan250 copy #77ffff3fcff3fcff -> #77ffff3fcff3fcff
+ddcan251 copy #77fcff3fdff3fcff -> #77fcff3fdff3fcff
+-- NaNs
+ddcan252 copy #7c03ff3fcff3fcff -> #7c03ff3fcff3fcff
+ddcan253 copy #7c00ff3fcff3ffff -> #7c00ff3fcff3ffff
+ddcan254 copy #7d00ff3fcff3fcff -> #7d00ff3fcff3fcff
+ddcan255 copy #7c04ff3fcff3fcff -> #7c04ff3fcff3fcff
+-- sNaN
+ddcan256 copy #7e00ff3fcffffcff -> #7e00ff3fcffffcff
+ddcan257 copy #7e40ff3fcff3fcff -> #7e40ff3fcff3fcff
+-- Inf
+ddcan258 copy #7a00000000000000 -> #7a00000000000000
+ddcan259 copy #7800200000000000 -> #7800200000000000
+
+----- CopyAbs: [does not usually canonicalize]
+-- finites
+ddcan260 copyabs #f7ffff3fcff3fcff -> #77ffff3fcff3fcff
+ddcan261 copyabs #f7fcff3fdff3fcff -> #77fcff3fdff3fcff
+-- NaNs
+ddcan262 copyabs #fc03ff3fcff3fcff -> #7c03ff3fcff3fcff
+ddcan263 copyabs #fc00ff3fcff3ffff -> #7c00ff3fcff3ffff
+ddcan264 copyabs #fd00ff3fcff3fcff -> #7d00ff3fcff3fcff
+ddcan265 copyabs #fc04ff3fcff3fcff -> #7c04ff3fcff3fcff
+-- sNaN
+ddcan266 copyabs #fe00ff3fcffffcff -> #7e00ff3fcffffcff
+ddcan267 copyabs #fe40ff3fcff3fcff -> #7e40ff3fcff3fcff
+-- Inf
+ddcan268 copyabs #fa00000000000000 -> #7a00000000000000
+ddcan269 copyabs #f800200000000000 -> #7800200000000000
+
+----- CopyNegate: [does not usually canonicalize]
+-- finites
+ddcan270 copynegate #77ffff3fcff3fcff -> #f7ffff3fcff3fcff
+ddcan271 copynegate #77fcff3fdff3fcff -> #f7fcff3fdff3fcff
+-- NaNs
+ddcan272 copynegate #7c03ff3fcff3fcff -> #fc03ff3fcff3fcff
+ddcan273 copynegate #7c00ff3fcff3ffff -> #fc00ff3fcff3ffff
+ddcan274 copynegate #7d00ff3fcff3fcff -> #fd00ff3fcff3fcff
+ddcan275 copynegate #7c04ff3fcff3fcff -> #fc04ff3fcff3fcff
+-- sNaN
+ddcan276 copynegate #7e00ff3fcffffcff -> #fe00ff3fcffffcff
+ddcan277 copynegate #7e40ff3fcff3fcff -> #fe40ff3fcff3fcff
+-- Inf
+ddcan278 copynegate #7a00000000000000 -> #fa00000000000000
+ddcan279 copynegate #7800200000000000 -> #f800200000000000
+
+----- CopySign: [does not usually canonicalize]
+-- finites
+ddcan280 copysign #77ffff3fcff3fcff -1 -> #f7ffff3fcff3fcff
+ddcan281 copysign #77fcff3fdff3fcff 1 -> #77fcff3fdff3fcff
+-- NaNs
+ddcan282 copysign #7c03ff3fcff3fcff -1 -> #fc03ff3fcff3fcff
+ddcan283 copysign #7c00ff3fcff3ffff 1 -> #7c00ff3fcff3ffff
+ddcan284 copysign #7d00ff3fcff3fcff -1 -> #fd00ff3fcff3fcff
+ddcan285 copysign #7c04ff3fcff3fcff 1 -> #7c04ff3fcff3fcff
+-- sNaN
+ddcan286 copysign #7e00ff3fcffffcff -1 -> #fe00ff3fcffffcff
+ddcan287 copysign #7e40ff3fcff3fcff 1 -> #7e40ff3fcff3fcff
+-- Inf
+ddcan288 copysign #7a00000000000000 -1 -> #fa00000000000000
+ddcan289 copysign #7800200000000000 1 -> #7800200000000000
+
+----- Multiply:
+-- Finites: neutral 0
+ddcan302 multiply 1 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan303 multiply #77fcffffcff3fcff 1 -> #77fcff3fcff3fcff
+-- negative
+ddcan306 multiply -1 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
+ddcan307 multiply #77fcffffcff3fcff -1 -> #f7fcff3fcff3fcff
+-- NaN: declets in payload
+ddcan311 multiply 1 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan312 multiply #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+ddcan313 multiply 1 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan314 multiply #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+-- sNaN: declets in payload
+ddcan315 multiply 1 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan316 multiply #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+ddcan317 multiply 1 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan318 multiply #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+ddcan320 multiply 1 #7880000000000000 -> #7800000000000000
+ddcan321 multiply #7880000000000000 1 -> #7800000000000000
+-- Inf: coefficient continuation bits
+ddcan322 multiply 1 #7802000000000000 -> #7800000000000000
+ddcan323 multiply #7802000000000000 1 -> #7800000000000000
+ddcan324 multiply 1 #7800000000000001 -> #7800000000000000
+ddcan325 multiply #7800000000000001 1 -> #7800000000000000
+ddcan326 multiply 1 #7800002000000000 -> #7800000000000000
+ddcan327 multiply #7800002000000000 1 -> #7800000000000000
+
+----- Quantize:
+ddcan401 quantize #6e38ff3ffff3fcff 1 -> #6e38ff3fcff3fcff
+ddcan402 quantize #6e38ff3fcff3fdff 0 -> #6e38ff3fcff3fcff
+ddcan403 quantize #7880000000000000 Inf -> #7800000000000000
+ddcan404 quantize #7802000000000000 -Inf -> #7800000000000000
+ddcan410 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+ddcan411 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+ddcan412 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+ddcan413 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+ddcan414 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+ddcan415 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+ddcan416 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+ddcan417 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+
+----- Subtract:
+-- Finites: neutral 0
+ddcan502 subtract 0E+384 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
+ddcan503 subtract #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
+-- tiny zero
+ddcan504 subtract 0E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Rounded
+ddcan505 subtract #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
+-- tiny non zero
+ddcan506 subtract -1E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Inexact Rounded
+ddcan507 subtract #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
+-- NaN: declets in payload
+ddcan511 subtract 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan512 subtract #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+ddcan513 subtract 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan514 subtract #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
+-- sNaN: declets in payload
+ddcan515 subtract 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan516 subtract #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+ddcan517 subtract 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan518 subtract #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+ddcan520 subtract 0 #7880000000000000 -> #f800000000000000
+ddcan521 subtract #7880000000000000 0 -> #7800000000000000
+-- Inf: coefficient continuation bits
+ddcan522 subtract 0 #7802000000000000 -> #f800000000000000
+ddcan523 subtract #7802000000000000 0 -> #7800000000000000
+ddcan524 subtract 0 #7800000000000001 -> #f800000000000000
+ddcan525 subtract #7800000000000001 0 -> #7800000000000000
+ddcan526 subtract 0 #7800002000000000 -> #f800000000000000
+ddcan527 subtract #7800002000000000 0 -> #7800000000000000
+
+----- ToIntegral:
+ddcan601 tointegralx #6e38ff3ffff3fcff -> #6e38ff3fcff3fcff
+ddcan602 tointegralx #6e38ff3fcff3fdff -> #6e38ff3fcff3fcff
+ddcan603 tointegralx #7880000000000000 -> #7800000000000000
+ddcan604 tointegralx #7802000000000000 -> #7800000000000000
+ddcan610 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan611 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan612 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan613 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan614 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan615 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan616 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan617 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+-- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
+ddcan618 tointegralx #2238000000000fff -> #2238000000000cff
+ddcan619 tointegralx #2230000000000fff -> #2238000000000040 Inexact Rounded
+ddcan620 tointegralx #222c000000000fff -> #2238000000000004 Inexact Rounded
+ddcan621 tointegralx #2228000000000fff -> #2238000000000000 Inexact Rounded
+ddcan622 tointegralx #a238000000000fff -> #a238000000000cff
+ddcan623 tointegralx #a230000000000fff -> #a238000000000040 Inexact Rounded
+ddcan624 tointegralx #a22c000000000fff -> #a238000000000004 Inexact Rounded
+ddcan625 tointegralx #a228000000000fff -> #a238000000000000 Inexact Rounded
+
+
+
diff --git a/Lib/test/decimaltestdata/ddClass.decTest b/Lib/test/decimaltestdata/ddClass.decTest
index bb34c42d4a..a1d233b86d 100644
--- a/Lib/test/decimaltestdata/ddClass.decTest
+++ b/Lib/test/decimaltestdata/ddClass.decTest
@@ -1,76 +1,76 @@
-------------------------------------------------------------------------
--- ddClass.decTest -- decDouble Class operations --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- [New 2006.11.27]
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddcla001 class 0 -> +Zero
-ddcla002 class 0.00 -> +Zero
-ddcla003 class 0E+5 -> +Zero
-ddcla004 class 1E-396 -> +Subnormal
-ddcla005 class 0.1E-383 -> +Subnormal
-ddcla006 class 0.999999999999999E-383 -> +Subnormal
-ddcla007 class 1.000000000000000E-383 -> +Normal
-ddcla008 class 1E-383 -> +Normal
-ddcla009 class 1E-100 -> +Normal
-ddcla010 class 1E-10 -> +Normal
-ddcla012 class 1E-1 -> +Normal
-ddcla013 class 1 -> +Normal
-ddcla014 class 2.50 -> +Normal
-ddcla015 class 100.100 -> +Normal
-ddcla016 class 1E+30 -> +Normal
-ddcla017 class 1E+384 -> +Normal
-ddcla018 class 9.999999999999999E+384 -> +Normal
-ddcla019 class Inf -> +Infinity
-
-ddcla021 class -0 -> -Zero
-ddcla022 class -0.00 -> -Zero
-ddcla023 class -0E+5 -> -Zero
-ddcla024 class -1E-396 -> -Subnormal
-ddcla025 class -0.1E-383 -> -Subnormal
-ddcla026 class -0.999999999999999E-383 -> -Subnormal
-ddcla027 class -1.000000000000000E-383 -> -Normal
-ddcla028 class -1E-383 -> -Normal
-ddcla029 class -1E-100 -> -Normal
-ddcla030 class -1E-10 -> -Normal
-ddcla032 class -1E-1 -> -Normal
-ddcla033 class -1 -> -Normal
-ddcla034 class -2.50 -> -Normal
-ddcla035 class -100.100 -> -Normal
-ddcla036 class -1E+30 -> -Normal
-ddcla037 class -1E+384 -> -Normal
-ddcla038 class -9.999999999999999E+384 -> -Normal
-ddcla039 class -Inf -> -Infinity
-
-ddcla041 class NaN -> NaN
-ddcla042 class -NaN -> NaN
-ddcla043 class +NaN12345 -> NaN
-ddcla044 class sNaN -> sNaN
-ddcla045 class -sNaN -> sNaN
-ddcla046 class +sNaN12345 -> sNaN
-
-
-
+------------------------------------------------------------------------
+-- ddClass.decTest -- decDouble Class operations --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- [New 2006.11.27]
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddcla001 class 0 -> +Zero
+ddcla002 class 0.00 -> +Zero
+ddcla003 class 0E+5 -> +Zero
+ddcla004 class 1E-396 -> +Subnormal
+ddcla005 class 0.1E-383 -> +Subnormal
+ddcla006 class 0.999999999999999E-383 -> +Subnormal
+ddcla007 class 1.000000000000000E-383 -> +Normal
+ddcla008 class 1E-383 -> +Normal
+ddcla009 class 1E-100 -> +Normal
+ddcla010 class 1E-10 -> +Normal
+ddcla012 class 1E-1 -> +Normal
+ddcla013 class 1 -> +Normal
+ddcla014 class 2.50 -> +Normal
+ddcla015 class 100.100 -> +Normal
+ddcla016 class 1E+30 -> +Normal
+ddcla017 class 1E+384 -> +Normal
+ddcla018 class 9.999999999999999E+384 -> +Normal
+ddcla019 class Inf -> +Infinity
+
+ddcla021 class -0 -> -Zero
+ddcla022 class -0.00 -> -Zero
+ddcla023 class -0E+5 -> -Zero
+ddcla024 class -1E-396 -> -Subnormal
+ddcla025 class -0.1E-383 -> -Subnormal
+ddcla026 class -0.999999999999999E-383 -> -Subnormal
+ddcla027 class -1.000000000000000E-383 -> -Normal
+ddcla028 class -1E-383 -> -Normal
+ddcla029 class -1E-100 -> -Normal
+ddcla030 class -1E-10 -> -Normal
+ddcla032 class -1E-1 -> -Normal
+ddcla033 class -1 -> -Normal
+ddcla034 class -2.50 -> -Normal
+ddcla035 class -100.100 -> -Normal
+ddcla036 class -1E+30 -> -Normal
+ddcla037 class -1E+384 -> -Normal
+ddcla038 class -9.999999999999999E+384 -> -Normal
+ddcla039 class -Inf -> -Infinity
+
+ddcla041 class NaN -> NaN
+ddcla042 class -NaN -> NaN
+ddcla043 class +NaN12345 -> NaN
+ddcla044 class sNaN -> sNaN
+ddcla045 class -sNaN -> sNaN
+ddcla046 class +sNaN12345 -> sNaN
+
+
+
diff --git a/Lib/test/decimaltestdata/ddCompare.decTest b/Lib/test/decimaltestdata/ddCompare.decTest
index 6debfc7a13..a20ae210cc 100644
--- a/Lib/test/decimaltestdata/ddCompare.decTest
+++ b/Lib/test/decimaltestdata/ddCompare.decTest
@@ -1,744 +1,744 @@
-------------------------------------------------------------------------
--- ddCompare.decTest -- decDouble comparison that allows quiet NaNs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddcom001 compare -2 -2 -> 0
-ddcom002 compare -2 -1 -> -1
-ddcom003 compare -2 0 -> -1
-ddcom004 compare -2 1 -> -1
-ddcom005 compare -2 2 -> -1
-ddcom006 compare -1 -2 -> 1
-ddcom007 compare -1 -1 -> 0
-ddcom008 compare -1 0 -> -1
-ddcom009 compare -1 1 -> -1
-ddcom010 compare -1 2 -> -1
-ddcom011 compare 0 -2 -> 1
-ddcom012 compare 0 -1 -> 1
-ddcom013 compare 0 0 -> 0
-ddcom014 compare 0 1 -> -1
-ddcom015 compare 0 2 -> -1
-ddcom016 compare 1 -2 -> 1
-ddcom017 compare 1 -1 -> 1
-ddcom018 compare 1 0 -> 1
-ddcom019 compare 1 1 -> 0
-ddcom020 compare 1 2 -> -1
-ddcom021 compare 2 -2 -> 1
-ddcom022 compare 2 -1 -> 1
-ddcom023 compare 2 0 -> 1
-ddcom025 compare 2 1 -> 1
-ddcom026 compare 2 2 -> 0
-
-ddcom031 compare -20 -20 -> 0
-ddcom032 compare -20 -10 -> -1
-ddcom033 compare -20 00 -> -1
-ddcom034 compare -20 10 -> -1
-ddcom035 compare -20 20 -> -1
-ddcom036 compare -10 -20 -> 1
-ddcom037 compare -10 -10 -> 0
-ddcom038 compare -10 00 -> -1
-ddcom039 compare -10 10 -> -1
-ddcom040 compare -10 20 -> -1
-ddcom041 compare 00 -20 -> 1
-ddcom042 compare 00 -10 -> 1
-ddcom043 compare 00 00 -> 0
-ddcom044 compare 00 10 -> -1
-ddcom045 compare 00 20 -> -1
-ddcom046 compare 10 -20 -> 1
-ddcom047 compare 10 -10 -> 1
-ddcom048 compare 10 00 -> 1
-ddcom049 compare 10 10 -> 0
-ddcom050 compare 10 20 -> -1
-ddcom051 compare 20 -20 -> 1
-ddcom052 compare 20 -10 -> 1
-ddcom053 compare 20 00 -> 1
-ddcom055 compare 20 10 -> 1
-ddcom056 compare 20 20 -> 0
-
-ddcom061 compare -2.0 -2.0 -> 0
-ddcom062 compare -2.0 -1.0 -> -1
-ddcom063 compare -2.0 0.0 -> -1
-ddcom064 compare -2.0 1.0 -> -1
-ddcom065 compare -2.0 2.0 -> -1
-ddcom066 compare -1.0 -2.0 -> 1
-ddcom067 compare -1.0 -1.0 -> 0
-ddcom068 compare -1.0 0.0 -> -1
-ddcom069 compare -1.0 1.0 -> -1
-ddcom070 compare -1.0 2.0 -> -1
-ddcom071 compare 0.0 -2.0 -> 1
-ddcom072 compare 0.0 -1.0 -> 1
-ddcom073 compare 0.0 0.0 -> 0
-ddcom074 compare 0.0 1.0 -> -1
-ddcom075 compare 0.0 2.0 -> -1
-ddcom076 compare 1.0 -2.0 -> 1
-ddcom077 compare 1.0 -1.0 -> 1
-ddcom078 compare 1.0 0.0 -> 1
-ddcom079 compare 1.0 1.0 -> 0
-ddcom080 compare 1.0 2.0 -> -1
-ddcom081 compare 2.0 -2.0 -> 1
-ddcom082 compare 2.0 -1.0 -> 1
-ddcom083 compare 2.0 0.0 -> 1
-ddcom085 compare 2.0 1.0 -> 1
-ddcom086 compare 2.0 2.0 -> 0
-ddcom087 compare 1.0 0.1 -> 1
-ddcom088 compare 0.1 1.0 -> -1
-
--- now some cases which might overflow if subtract were used
-ddcom095 compare 9.999999999999999E+384 9.999999999999999E+384 -> 0
-ddcom096 compare -9.999999999999999E+384 9.999999999999999E+384 -> -1
-ddcom097 compare 9.999999999999999E+384 -9.999999999999999E+384 -> 1
-ddcom098 compare -9.999999999999999E+384 -9.999999999999999E+384 -> 0
-
--- some differing length/exponent cases
-ddcom100 compare 7.0 7.0 -> 0
-ddcom101 compare 7.0 7 -> 0
-ddcom102 compare 7 7.0 -> 0
-ddcom103 compare 7E+0 7.0 -> 0
-ddcom104 compare 70E-1 7.0 -> 0
-ddcom105 compare 0.7E+1 7 -> 0
-ddcom106 compare 70E-1 7 -> 0
-ddcom107 compare 7.0 7E+0 -> 0
-ddcom108 compare 7.0 70E-1 -> 0
-ddcom109 compare 7 0.7E+1 -> 0
-ddcom110 compare 7 70E-1 -> 0
-
-ddcom120 compare 8.0 7.0 -> 1
-ddcom121 compare 8.0 7 -> 1
-ddcom122 compare 8 7.0 -> 1
-ddcom123 compare 8E+0 7.0 -> 1
-ddcom124 compare 80E-1 7.0 -> 1
-ddcom125 compare 0.8E+1 7 -> 1
-ddcom126 compare 80E-1 7 -> 1
-ddcom127 compare 8.0 7E+0 -> 1
-ddcom128 compare 8.0 70E-1 -> 1
-ddcom129 compare 8 0.7E+1 -> 1
-ddcom130 compare 8 70E-1 -> 1
-
-ddcom140 compare 8.0 9.0 -> -1
-ddcom141 compare 8.0 9 -> -1
-ddcom142 compare 8 9.0 -> -1
-ddcom143 compare 8E+0 9.0 -> -1
-ddcom144 compare 80E-1 9.0 -> -1
-ddcom145 compare 0.8E+1 9 -> -1
-ddcom146 compare 80E-1 9 -> -1
-ddcom147 compare 8.0 9E+0 -> -1
-ddcom148 compare 8.0 90E-1 -> -1
-ddcom149 compare 8 0.9E+1 -> -1
-ddcom150 compare 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ddcom200 compare -7.0 7.0 -> -1
-ddcom201 compare -7.0 7 -> -1
-ddcom202 compare -7 7.0 -> -1
-ddcom203 compare -7E+0 7.0 -> -1
-ddcom204 compare -70E-1 7.0 -> -1
-ddcom205 compare -0.7E+1 7 -> -1
-ddcom206 compare -70E-1 7 -> -1
-ddcom207 compare -7.0 7E+0 -> -1
-ddcom208 compare -7.0 70E-1 -> -1
-ddcom209 compare -7 0.7E+1 -> -1
-ddcom210 compare -7 70E-1 -> -1
-
-ddcom220 compare -8.0 7.0 -> -1
-ddcom221 compare -8.0 7 -> -1
-ddcom222 compare -8 7.0 -> -1
-ddcom223 compare -8E+0 7.0 -> -1
-ddcom224 compare -80E-1 7.0 -> -1
-ddcom225 compare -0.8E+1 7 -> -1
-ddcom226 compare -80E-1 7 -> -1
-ddcom227 compare -8.0 7E+0 -> -1
-ddcom228 compare -8.0 70E-1 -> -1
-ddcom229 compare -8 0.7E+1 -> -1
-ddcom230 compare -8 70E-1 -> -1
-
-ddcom240 compare -8.0 9.0 -> -1
-ddcom241 compare -8.0 9 -> -1
-ddcom242 compare -8 9.0 -> -1
-ddcom243 compare -8E+0 9.0 -> -1
-ddcom244 compare -80E-1 9.0 -> -1
-ddcom245 compare -0.8E+1 9 -> -1
-ddcom246 compare -80E-1 9 -> -1
-ddcom247 compare -8.0 9E+0 -> -1
-ddcom248 compare -8.0 90E-1 -> -1
-ddcom249 compare -8 0.9E+1 -> -1
-ddcom250 compare -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ddcom300 compare 7.0 -7.0 -> 1
-ddcom301 compare 7.0 -7 -> 1
-ddcom302 compare 7 -7.0 -> 1
-ddcom303 compare 7E+0 -7.0 -> 1
-ddcom304 compare 70E-1 -7.0 -> 1
-ddcom305 compare .7E+1 -7 -> 1
-ddcom306 compare 70E-1 -7 -> 1
-ddcom307 compare 7.0 -7E+0 -> 1
-ddcom308 compare 7.0 -70E-1 -> 1
-ddcom309 compare 7 -.7E+1 -> 1
-ddcom310 compare 7 -70E-1 -> 1
-
-ddcom320 compare 8.0 -7.0 -> 1
-ddcom321 compare 8.0 -7 -> 1
-ddcom322 compare 8 -7.0 -> 1
-ddcom323 compare 8E+0 -7.0 -> 1
-ddcom324 compare 80E-1 -7.0 -> 1
-ddcom325 compare .8E+1 -7 -> 1
-ddcom326 compare 80E-1 -7 -> 1
-ddcom327 compare 8.0 -7E+0 -> 1
-ddcom328 compare 8.0 -70E-1 -> 1
-ddcom329 compare 8 -.7E+1 -> 1
-ddcom330 compare 8 -70E-1 -> 1
-
-ddcom340 compare 8.0 -9.0 -> 1
-ddcom341 compare 8.0 -9 -> 1
-ddcom342 compare 8 -9.0 -> 1
-ddcom343 compare 8E+0 -9.0 -> 1
-ddcom344 compare 80E-1 -9.0 -> 1
-ddcom345 compare .8E+1 -9 -> 1
-ddcom346 compare 80E-1 -9 -> 1
-ddcom347 compare 8.0 -9E+0 -> 1
-ddcom348 compare 8.0 -90E-1 -> 1
-ddcom349 compare 8 -.9E+1 -> 1
-ddcom350 compare 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-ddcom400 compare -7.0 -7.0 -> 0
-ddcom401 compare -7.0 -7 -> 0
-ddcom402 compare -7 -7.0 -> 0
-ddcom403 compare -7E+0 -7.0 -> 0
-ddcom404 compare -70E-1 -7.0 -> 0
-ddcom405 compare -.7E+1 -7 -> 0
-ddcom406 compare -70E-1 -7 -> 0
-ddcom407 compare -7.0 -7E+0 -> 0
-ddcom408 compare -7.0 -70E-1 -> 0
-ddcom409 compare -7 -.7E+1 -> 0
-ddcom410 compare -7 -70E-1 -> 0
-
-ddcom420 compare -8.0 -7.0 -> -1
-ddcom421 compare -8.0 -7 -> -1
-ddcom422 compare -8 -7.0 -> -1
-ddcom423 compare -8E+0 -7.0 -> -1
-ddcom424 compare -80E-1 -7.0 -> -1
-ddcom425 compare -.8E+1 -7 -> -1
-ddcom426 compare -80E-1 -7 -> -1
-ddcom427 compare -8.0 -7E+0 -> -1
-ddcom428 compare -8.0 -70E-1 -> -1
-ddcom429 compare -8 -.7E+1 -> -1
-ddcom430 compare -8 -70E-1 -> -1
-
-ddcom440 compare -8.0 -9.0 -> 1
-ddcom441 compare -8.0 -9 -> 1
-ddcom442 compare -8 -9.0 -> 1
-ddcom443 compare -8E+0 -9.0 -> 1
-ddcom444 compare -80E-1 -9.0 -> 1
-ddcom445 compare -.8E+1 -9 -> 1
-ddcom446 compare -80E-1 -9 -> 1
-ddcom447 compare -8.0 -9E+0 -> 1
-ddcom448 compare -8.0 -90E-1 -> 1
-ddcom449 compare -8 -.9E+1 -> 1
-ddcom450 compare -8 -90E-1 -> 1
-
--- misalignment traps for little-endian
-ddcom451 compare 1.0 0.1 -> 1
-ddcom452 compare 0.1 1.0 -> -1
-ddcom453 compare 10.0 0.1 -> 1
-ddcom454 compare 0.1 10.0 -> -1
-ddcom455 compare 100 1.0 -> 1
-ddcom456 compare 1.0 100 -> -1
-ddcom457 compare 1000 10.0 -> 1
-ddcom458 compare 10.0 1000 -> -1
-ddcom459 compare 10000 100.0 -> 1
-ddcom460 compare 100.0 10000 -> -1
-ddcom461 compare 100000 1000.0 -> 1
-ddcom462 compare 1000.0 100000 -> -1
-ddcom463 compare 1000000 10000.0 -> 1
-ddcom464 compare 10000.0 1000000 -> -1
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-ddcom473 compare 123.4560000000000E-89 123.456E-89 -> 0
-ddcom474 compare 123.456000000000E+89 123.456E+89 -> 0
-ddcom475 compare 123.45600000000E-89 123.456E-89 -> 0
-ddcom476 compare 123.4560000000E+89 123.456E+89 -> 0
-ddcom477 compare 123.456000000E-89 123.456E-89 -> 0
-ddcom478 compare 123.45600000E+89 123.456E+89 -> 0
-ddcom479 compare 123.4560000E-89 123.456E-89 -> 0
-ddcom480 compare 123.456000E+89 123.456E+89 -> 0
-ddcom481 compare 123.45600E-89 123.456E-89 -> 0
-ddcom482 compare 123.4560E+89 123.456E+89 -> 0
-ddcom483 compare 123.456E-89 123.456E-89 -> 0
-ddcom487 compare 123.456E+89 123.4560000000000E+89 -> 0
-ddcom488 compare 123.456E-89 123.456000000000E-89 -> 0
-ddcom489 compare 123.456E+89 123.45600000000E+89 -> 0
-ddcom490 compare 123.456E-89 123.4560000000E-89 -> 0
-ddcom491 compare 123.456E+89 123.456000000E+89 -> 0
-ddcom492 compare 123.456E-89 123.45600000E-89 -> 0
-ddcom493 compare 123.456E+89 123.4560000E+89 -> 0
-ddcom494 compare 123.456E-89 123.456000E-89 -> 0
-ddcom495 compare 123.456E+89 123.45600E+89 -> 0
-ddcom496 compare 123.456E-89 123.4560E-89 -> 0
-ddcom497 compare 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-ddcom500 compare 1 1E-15 -> 1
-ddcom501 compare 1 1E-14 -> 1
-ddcom502 compare 1 1E-13 -> 1
-ddcom503 compare 1 1E-12 -> 1
-ddcom504 compare 1 1E-11 -> 1
-ddcom505 compare 1 1E-10 -> 1
-ddcom506 compare 1 1E-9 -> 1
-ddcom507 compare 1 1E-8 -> 1
-ddcom508 compare 1 1E-7 -> 1
-ddcom509 compare 1 1E-6 -> 1
-ddcom510 compare 1 1E-5 -> 1
-ddcom511 compare 1 1E-4 -> 1
-ddcom512 compare 1 1E-3 -> 1
-ddcom513 compare 1 1E-2 -> 1
-ddcom514 compare 1 1E-1 -> 1
-ddcom515 compare 1 1E-0 -> 0
-ddcom516 compare 1 1E+1 -> -1
-ddcom517 compare 1 1E+2 -> -1
-ddcom518 compare 1 1E+3 -> -1
-ddcom519 compare 1 1E+4 -> -1
-ddcom521 compare 1 1E+5 -> -1
-ddcom522 compare 1 1E+6 -> -1
-ddcom523 compare 1 1E+7 -> -1
-ddcom524 compare 1 1E+8 -> -1
-ddcom525 compare 1 1E+9 -> -1
-ddcom526 compare 1 1E+10 -> -1
-ddcom527 compare 1 1E+11 -> -1
-ddcom528 compare 1 1E+12 -> -1
-ddcom529 compare 1 1E+13 -> -1
-ddcom530 compare 1 1E+14 -> -1
-ddcom531 compare 1 1E+15 -> -1
--- LR swap
-ddcom540 compare 1E-15 1 -> -1
-ddcom541 compare 1E-14 1 -> -1
-ddcom542 compare 1E-13 1 -> -1
-ddcom543 compare 1E-12 1 -> -1
-ddcom544 compare 1E-11 1 -> -1
-ddcom545 compare 1E-10 1 -> -1
-ddcom546 compare 1E-9 1 -> -1
-ddcom547 compare 1E-8 1 -> -1
-ddcom548 compare 1E-7 1 -> -1
-ddcom549 compare 1E-6 1 -> -1
-ddcom550 compare 1E-5 1 -> -1
-ddcom551 compare 1E-4 1 -> -1
-ddcom552 compare 1E-3 1 -> -1
-ddcom553 compare 1E-2 1 -> -1
-ddcom554 compare 1E-1 1 -> -1
-ddcom555 compare 1E-0 1 -> 0
-ddcom556 compare 1E+1 1 -> 1
-ddcom557 compare 1E+2 1 -> 1
-ddcom558 compare 1E+3 1 -> 1
-ddcom559 compare 1E+4 1 -> 1
-ddcom561 compare 1E+5 1 -> 1
-ddcom562 compare 1E+6 1 -> 1
-ddcom563 compare 1E+7 1 -> 1
-ddcom564 compare 1E+8 1 -> 1
-ddcom565 compare 1E+9 1 -> 1
-ddcom566 compare 1E+10 1 -> 1
-ddcom567 compare 1E+11 1 -> 1
-ddcom568 compare 1E+12 1 -> 1
-ddcom569 compare 1E+13 1 -> 1
-ddcom570 compare 1E+14 1 -> 1
-ddcom571 compare 1E+15 1 -> 1
--- similar with a useful coefficient, one side only
-ddcom580 compare 0.000000987654321 1E-15 -> 1
-ddcom581 compare 0.000000987654321 1E-14 -> 1
-ddcom582 compare 0.000000987654321 1E-13 -> 1
-ddcom583 compare 0.000000987654321 1E-12 -> 1
-ddcom584 compare 0.000000987654321 1E-11 -> 1
-ddcom585 compare 0.000000987654321 1E-10 -> 1
-ddcom586 compare 0.000000987654321 1E-9 -> 1
-ddcom587 compare 0.000000987654321 1E-8 -> 1
-ddcom588 compare 0.000000987654321 1E-7 -> 1
-ddcom589 compare 0.000000987654321 1E-6 -> -1
-ddcom590 compare 0.000000987654321 1E-5 -> -1
-ddcom591 compare 0.000000987654321 1E-4 -> -1
-ddcom592 compare 0.000000987654321 1E-3 -> -1
-ddcom593 compare 0.000000987654321 1E-2 -> -1
-ddcom594 compare 0.000000987654321 1E-1 -> -1
-ddcom595 compare 0.000000987654321 1E-0 -> -1
-ddcom596 compare 0.000000987654321 1E+1 -> -1
-ddcom597 compare 0.000000987654321 1E+2 -> -1
-ddcom598 compare 0.000000987654321 1E+3 -> -1
-ddcom599 compare 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-ddcom600 compare 12 12.2345 -> -1
-ddcom601 compare 12.0 12.2345 -> -1
-ddcom602 compare 12.00 12.2345 -> -1
-ddcom603 compare 12.000 12.2345 -> -1
-ddcom604 compare 12.0000 12.2345 -> -1
-ddcom605 compare 12.00000 12.2345 -> -1
-ddcom606 compare 12.000000 12.2345 -> -1
-ddcom607 compare 12.0000000 12.2345 -> -1
-ddcom608 compare 12.00000000 12.2345 -> -1
-ddcom609 compare 12.000000000 12.2345 -> -1
-ddcom610 compare 12.1234 12 -> 1
-ddcom611 compare 12.1234 12.0 -> 1
-ddcom612 compare 12.1234 12.00 -> 1
-ddcom613 compare 12.1234 12.000 -> 1
-ddcom614 compare 12.1234 12.0000 -> 1
-ddcom615 compare 12.1234 12.00000 -> 1
-ddcom616 compare 12.1234 12.000000 -> 1
-ddcom617 compare 12.1234 12.0000000 -> 1
-ddcom618 compare 12.1234 12.00000000 -> 1
-ddcom619 compare 12.1234 12.000000000 -> 1
-ddcom620 compare -12 -12.2345 -> 1
-ddcom621 compare -12.0 -12.2345 -> 1
-ddcom622 compare -12.00 -12.2345 -> 1
-ddcom623 compare -12.000 -12.2345 -> 1
-ddcom624 compare -12.0000 -12.2345 -> 1
-ddcom625 compare -12.00000 -12.2345 -> 1
-ddcom626 compare -12.000000 -12.2345 -> 1
-ddcom627 compare -12.0000000 -12.2345 -> 1
-ddcom628 compare -12.00000000 -12.2345 -> 1
-ddcom629 compare -12.000000000 -12.2345 -> 1
-ddcom630 compare -12.1234 -12 -> -1
-ddcom631 compare -12.1234 -12.0 -> -1
-ddcom632 compare -12.1234 -12.00 -> -1
-ddcom633 compare -12.1234 -12.000 -> -1
-ddcom634 compare -12.1234 -12.0000 -> -1
-ddcom635 compare -12.1234 -12.00000 -> -1
-ddcom636 compare -12.1234 -12.000000 -> -1
-ddcom637 compare -12.1234 -12.0000000 -> -1
-ddcom638 compare -12.1234 -12.00000000 -> -1
-ddcom639 compare -12.1234 -12.000000000 -> -1
-
--- extended zeros
-ddcom640 compare 0 0 -> 0
-ddcom641 compare 0 -0 -> 0
-ddcom642 compare 0 -0.0 -> 0
-ddcom643 compare 0 0.0 -> 0
-ddcom644 compare -0 0 -> 0
-ddcom645 compare -0 -0 -> 0
-ddcom646 compare -0 -0.0 -> 0
-ddcom647 compare -0 0.0 -> 0
-ddcom648 compare 0.0 0 -> 0
-ddcom649 compare 0.0 -0 -> 0
-ddcom650 compare 0.0 -0.0 -> 0
-ddcom651 compare 0.0 0.0 -> 0
-ddcom652 compare -0.0 0 -> 0
-ddcom653 compare -0.0 -0 -> 0
-ddcom654 compare -0.0 -0.0 -> 0
-ddcom655 compare -0.0 0.0 -> 0
-
-ddcom656 compare -0E1 0.0 -> 0
-ddcom657 compare -0E2 0.0 -> 0
-ddcom658 compare 0E1 0.0 -> 0
-ddcom659 compare 0E2 0.0 -> 0
-ddcom660 compare -0E1 0 -> 0
-ddcom661 compare -0E2 0 -> 0
-ddcom662 compare 0E1 0 -> 0
-ddcom663 compare 0E2 0 -> 0
-ddcom664 compare -0E1 -0E1 -> 0
-ddcom665 compare -0E2 -0E1 -> 0
-ddcom666 compare 0E1 -0E1 -> 0
-ddcom667 compare 0E2 -0E1 -> 0
-ddcom668 compare -0E1 -0E2 -> 0
-ddcom669 compare -0E2 -0E2 -> 0
-ddcom670 compare 0E1 -0E2 -> 0
-ddcom671 compare 0E2 -0E2 -> 0
-ddcom672 compare -0E1 0E1 -> 0
-ddcom673 compare -0E2 0E1 -> 0
-ddcom674 compare 0E1 0E1 -> 0
-ddcom675 compare 0E2 0E1 -> 0
-ddcom676 compare -0E1 0E2 -> 0
-ddcom677 compare -0E2 0E2 -> 0
-ddcom678 compare 0E1 0E2 -> 0
-ddcom679 compare 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-ddcom680 compare 12 12 -> 0
-ddcom681 compare 12 12.0 -> 0
-ddcom682 compare 12 12.00 -> 0
-ddcom683 compare 12 12.000 -> 0
-ddcom684 compare 12 12.0000 -> 0
-ddcom685 compare 12 12.00000 -> 0
-ddcom686 compare 12 12.000000 -> 0
-ddcom687 compare 12 12.0000000 -> 0
-ddcom688 compare 12 12.00000000 -> 0
-ddcom689 compare 12 12.000000000 -> 0
-ddcom690 compare 12 12 -> 0
-ddcom691 compare 12.0 12 -> 0
-ddcom692 compare 12.00 12 -> 0
-ddcom693 compare 12.000 12 -> 0
-ddcom694 compare 12.0000 12 -> 0
-ddcom695 compare 12.00000 12 -> 0
-ddcom696 compare 12.000000 12 -> 0
-ddcom697 compare 12.0000000 12 -> 0
-ddcom698 compare 12.00000000 12 -> 0
-ddcom699 compare 12.000000000 12 -> 0
-
--- first, second, & last digit
-ddcom700 compare 1234567890123456 1234567890123455 -> 1
-ddcom701 compare 1234567890123456 1234567890123456 -> 0
-ddcom702 compare 1234567890123456 1234567890123457 -> -1
-ddcom703 compare 1234567890123456 0234567890123456 -> 1
-ddcom704 compare 1234567890123456 1234567890123456 -> 0
-ddcom705 compare 1234567890123456 2234567890123456 -> -1
-ddcom706 compare 1134567890123456 1034567890123456 -> 1
-ddcom707 compare 1134567890123456 1134567890123456 -> 0
-ddcom708 compare 1134567890123456 1234567890123456 -> -1
-
--- miscellaneous
-ddcom721 compare 12345678000 1 -> 1
-ddcom722 compare 1 12345678000 -> -1
-ddcom723 compare 1234567800 1 -> 1
-ddcom724 compare 1 1234567800 -> -1
-ddcom725 compare 1234567890 1 -> 1
-ddcom726 compare 1 1234567890 -> -1
-ddcom727 compare 1234567891 1 -> 1
-ddcom728 compare 1 1234567891 -> -1
-ddcom729 compare 12345678901 1 -> 1
-ddcom730 compare 1 12345678901 -> -1
-ddcom731 compare 1234567896 1 -> 1
-ddcom732 compare 1 1234567896 -> -1
-
--- residue cases at lower precision
-ddcom740 compare 1 0.9999999 -> 1
-ddcom741 compare 1 0.999999 -> 1
-ddcom742 compare 1 0.99999 -> 1
-ddcom743 compare 1 1.0000 -> 0
-ddcom744 compare 1 1.00001 -> -1
-ddcom745 compare 1 1.000001 -> -1
-ddcom746 compare 1 1.0000001 -> -1
-ddcom750 compare 0.9999999 1 -> -1
-ddcom751 compare 0.999999 1 -> -1
-ddcom752 compare 0.99999 1 -> -1
-ddcom753 compare 1.0000 1 -> 0
-ddcom754 compare 1.00001 1 -> 1
-ddcom755 compare 1.000001 1 -> 1
-ddcom756 compare 1.0000001 1 -> 1
-
--- Specials
-ddcom780 compare Inf -Inf -> 1
-ddcom781 compare Inf -1000 -> 1
-ddcom782 compare Inf -1 -> 1
-ddcom783 compare Inf -0 -> 1
-ddcom784 compare Inf 0 -> 1
-ddcom785 compare Inf 1 -> 1
-ddcom786 compare Inf 1000 -> 1
-ddcom787 compare Inf Inf -> 0
-ddcom788 compare -1000 Inf -> -1
-ddcom789 compare -Inf Inf -> -1
-ddcom790 compare -1 Inf -> -1
-ddcom791 compare -0 Inf -> -1
-ddcom792 compare 0 Inf -> -1
-ddcom793 compare 1 Inf -> -1
-ddcom794 compare 1000 Inf -> -1
-ddcom795 compare Inf Inf -> 0
-
-ddcom800 compare -Inf -Inf -> 0
-ddcom801 compare -Inf -1000 -> -1
-ddcom802 compare -Inf -1 -> -1
-ddcom803 compare -Inf -0 -> -1
-ddcom804 compare -Inf 0 -> -1
-ddcom805 compare -Inf 1 -> -1
-ddcom806 compare -Inf 1000 -> -1
-ddcom807 compare -Inf Inf -> -1
-ddcom808 compare -Inf -Inf -> 0
-ddcom809 compare -1000 -Inf -> 1
-ddcom810 compare -1 -Inf -> 1
-ddcom811 compare -0 -Inf -> 1
-ddcom812 compare 0 -Inf -> 1
-ddcom813 compare 1 -Inf -> 1
-ddcom814 compare 1000 -Inf -> 1
-ddcom815 compare Inf -Inf -> 1
-
-ddcom821 compare NaN -Inf -> NaN
-ddcom822 compare NaN -1000 -> NaN
-ddcom823 compare NaN -1 -> NaN
-ddcom824 compare NaN -0 -> NaN
-ddcom825 compare NaN 0 -> NaN
-ddcom826 compare NaN 1 -> NaN
-ddcom827 compare NaN 1000 -> NaN
-ddcom828 compare NaN Inf -> NaN
-ddcom829 compare NaN NaN -> NaN
-ddcom830 compare -Inf NaN -> NaN
-ddcom831 compare -1000 NaN -> NaN
-ddcom832 compare -1 NaN -> NaN
-ddcom833 compare -0 NaN -> NaN
-ddcom834 compare 0 NaN -> NaN
-ddcom835 compare 1 NaN -> NaN
-ddcom836 compare 1000 NaN -> NaN
-ddcom837 compare Inf NaN -> NaN
-ddcom838 compare -NaN -NaN -> -NaN
-ddcom839 compare +NaN -NaN -> NaN
-ddcom840 compare -NaN +NaN -> -NaN
-
-ddcom841 compare sNaN -Inf -> NaN Invalid_operation
-ddcom842 compare sNaN -1000 -> NaN Invalid_operation
-ddcom843 compare sNaN -1 -> NaN Invalid_operation
-ddcom844 compare sNaN -0 -> NaN Invalid_operation
-ddcom845 compare sNaN 0 -> NaN Invalid_operation
-ddcom846 compare sNaN 1 -> NaN Invalid_operation
-ddcom847 compare sNaN 1000 -> NaN Invalid_operation
-ddcom848 compare sNaN NaN -> NaN Invalid_operation
-ddcom849 compare sNaN sNaN -> NaN Invalid_operation
-ddcom850 compare NaN sNaN -> NaN Invalid_operation
-ddcom851 compare -Inf sNaN -> NaN Invalid_operation
-ddcom852 compare -1000 sNaN -> NaN Invalid_operation
-ddcom853 compare -1 sNaN -> NaN Invalid_operation
-ddcom854 compare -0 sNaN -> NaN Invalid_operation
-ddcom855 compare 0 sNaN -> NaN Invalid_operation
-ddcom856 compare 1 sNaN -> NaN Invalid_operation
-ddcom857 compare 1000 sNaN -> NaN Invalid_operation
-ddcom858 compare Inf sNaN -> NaN Invalid_operation
-ddcom859 compare NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddcom860 compare NaN9 -Inf -> NaN9
-ddcom861 compare NaN8 999 -> NaN8
-ddcom862 compare NaN77 Inf -> NaN77
-ddcom863 compare -NaN67 NaN5 -> -NaN67
-ddcom864 compare -Inf -NaN4 -> -NaN4
-ddcom865 compare -999 -NaN33 -> -NaN33
-ddcom866 compare Inf NaN2 -> NaN2
-ddcom867 compare -NaN41 -NaN42 -> -NaN41
-ddcom868 compare +NaN41 -NaN42 -> NaN41
-ddcom869 compare -NaN41 +NaN42 -> -NaN41
-ddcom870 compare +NaN41 +NaN42 -> NaN41
-
-ddcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
-ddcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
-ddcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
-ddcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
-ddcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
-ddcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
-ddcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
-ddcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
-ddcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- wide range
-ddcom880 compare +1.23456789012345E-0 9E+384 -> -1
-ddcom881 compare 9E+384 +1.23456789012345E-0 -> 1
-ddcom882 compare +0.100 9E-383 -> 1
-ddcom883 compare 9E-383 +0.100 -> -1
-ddcom885 compare -1.23456789012345E-0 9E+384 -> -1
-ddcom886 compare 9E+384 -1.23456789012345E-0 -> 1
-ddcom887 compare -0.100 9E-383 -> -1
-ddcom888 compare 9E-383 -0.100 -> 1
-
--- spread zeros
-ddcom900 compare 0E-383 0 -> 0
-ddcom901 compare 0E-383 -0 -> 0
-ddcom902 compare -0E-383 0 -> 0
-ddcom903 compare -0E-383 -0 -> 0
-ddcom904 compare 0E-383 0E+384 -> 0
-ddcom905 compare 0E-383 -0E+384 -> 0
-ddcom906 compare -0E-383 0E+384 -> 0
-ddcom907 compare -0E-383 -0E+384 -> 0
-ddcom908 compare 0 0E+384 -> 0
-ddcom909 compare 0 -0E+384 -> 0
-ddcom910 compare -0 0E+384 -> 0
-ddcom911 compare -0 -0E+384 -> 0
-ddcom930 compare 0E+384 0 -> 0
-ddcom931 compare 0E+384 -0 -> 0
-ddcom932 compare -0E+384 0 -> 0
-ddcom933 compare -0E+384 -0 -> 0
-ddcom934 compare 0E+384 0E-383 -> 0
-ddcom935 compare 0E+384 -0E-383 -> 0
-ddcom936 compare -0E+384 0E-383 -> 0
-ddcom937 compare -0E+384 -0E-383 -> 0
-ddcom938 compare 0 0E-383 -> 0
-ddcom939 compare 0 -0E-383 -> 0
-ddcom940 compare -0 0E-383 -> 0
-ddcom941 compare -0 -0E-383 -> 0
-
--- signs
-ddcom961 compare 1e+77 1e+11 -> 1
-ddcom962 compare 1e+77 -1e+11 -> 1
-ddcom963 compare -1e+77 1e+11 -> -1
-ddcom964 compare -1e+77 -1e+11 -> -1
-ddcom965 compare 1e-77 1e-11 -> -1
-ddcom966 compare 1e-77 -1e-11 -> 1
-ddcom967 compare -1e-77 1e-11 -> -1
-ddcom968 compare -1e-77 -1e-11 -> 1
-
--- full alignment range, both ways
-ddcomp1001 compare 1 1.000000000000000 -> 0
-ddcomp1002 compare 1 1.00000000000000 -> 0
-ddcomp1003 compare 1 1.0000000000000 -> 0
-ddcomp1004 compare 1 1.000000000000 -> 0
-ddcomp1005 compare 1 1.00000000000 -> 0
-ddcomp1006 compare 1 1.0000000000 -> 0
-ddcomp1007 compare 1 1.000000000 -> 0
-ddcomp1008 compare 1 1.00000000 -> 0
-ddcomp1009 compare 1 1.0000000 -> 0
-ddcomp1010 compare 1 1.000000 -> 0
-ddcomp1011 compare 1 1.00000 -> 0
-ddcomp1012 compare 1 1.0000 -> 0
-ddcomp1013 compare 1 1.000 -> 0
-ddcomp1014 compare 1 1.00 -> 0
-ddcomp1015 compare 1 1.0 -> 0
-ddcomp1021 compare 1.000000000000000 1 -> 0
-ddcomp1022 compare 1.00000000000000 1 -> 0
-ddcomp1023 compare 1.0000000000000 1 -> 0
-ddcomp1024 compare 1.000000000000 1 -> 0
-ddcomp1025 compare 1.00000000000 1 -> 0
-ddcomp1026 compare 1.0000000000 1 -> 0
-ddcomp1027 compare 1.000000000 1 -> 0
-ddcomp1028 compare 1.00000000 1 -> 0
-ddcomp1029 compare 1.0000000 1 -> 0
-ddcomp1030 compare 1.000000 1 -> 0
-ddcomp1031 compare 1.00000 1 -> 0
-ddcomp1032 compare 1.0000 1 -> 0
-ddcomp1033 compare 1.000 1 -> 0
-ddcomp1034 compare 1.00 1 -> 0
-ddcomp1035 compare 1.0 1 -> 0
-
--- check MSD always detected non-zero
-ddcomp1040 compare 0 0.000000000000000 -> 0
-ddcomp1041 compare 0 1.000000000000000 -> -1
-ddcomp1042 compare 0 2.000000000000000 -> -1
-ddcomp1043 compare 0 3.000000000000000 -> -1
-ddcomp1044 compare 0 4.000000000000000 -> -1
-ddcomp1045 compare 0 5.000000000000000 -> -1
-ddcomp1046 compare 0 6.000000000000000 -> -1
-ddcomp1047 compare 0 7.000000000000000 -> -1
-ddcomp1048 compare 0 8.000000000000000 -> -1
-ddcomp1049 compare 0 9.000000000000000 -> -1
-ddcomp1050 compare 0.000000000000000 0 -> 0
-ddcomp1051 compare 1.000000000000000 0 -> 1
-ddcomp1052 compare 2.000000000000000 0 -> 1
-ddcomp1053 compare 3.000000000000000 0 -> 1
-ddcomp1054 compare 4.000000000000000 0 -> 1
-ddcomp1055 compare 5.000000000000000 0 -> 1
-ddcomp1056 compare 6.000000000000000 0 -> 1
-ddcomp1057 compare 7.000000000000000 0 -> 1
-ddcomp1058 compare 8.000000000000000 0 -> 1
-ddcomp1059 compare 9.000000000000000 0 -> 1
-
--- Null tests
-ddcom9990 compare 10 # -> NaN Invalid_operation
-ddcom9991 compare # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddCompare.decTest -- decDouble comparison that allows quiet NaNs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddcom001 compare -2 -2 -> 0
+ddcom002 compare -2 -1 -> -1
+ddcom003 compare -2 0 -> -1
+ddcom004 compare -2 1 -> -1
+ddcom005 compare -2 2 -> -1
+ddcom006 compare -1 -2 -> 1
+ddcom007 compare -1 -1 -> 0
+ddcom008 compare -1 0 -> -1
+ddcom009 compare -1 1 -> -1
+ddcom010 compare -1 2 -> -1
+ddcom011 compare 0 -2 -> 1
+ddcom012 compare 0 -1 -> 1
+ddcom013 compare 0 0 -> 0
+ddcom014 compare 0 1 -> -1
+ddcom015 compare 0 2 -> -1
+ddcom016 compare 1 -2 -> 1
+ddcom017 compare 1 -1 -> 1
+ddcom018 compare 1 0 -> 1
+ddcom019 compare 1 1 -> 0
+ddcom020 compare 1 2 -> -1
+ddcom021 compare 2 -2 -> 1
+ddcom022 compare 2 -1 -> 1
+ddcom023 compare 2 0 -> 1
+ddcom025 compare 2 1 -> 1
+ddcom026 compare 2 2 -> 0
+
+ddcom031 compare -20 -20 -> 0
+ddcom032 compare -20 -10 -> -1
+ddcom033 compare -20 00 -> -1
+ddcom034 compare -20 10 -> -1
+ddcom035 compare -20 20 -> -1
+ddcom036 compare -10 -20 -> 1
+ddcom037 compare -10 -10 -> 0
+ddcom038 compare -10 00 -> -1
+ddcom039 compare -10 10 -> -1
+ddcom040 compare -10 20 -> -1
+ddcom041 compare 00 -20 -> 1
+ddcom042 compare 00 -10 -> 1
+ddcom043 compare 00 00 -> 0
+ddcom044 compare 00 10 -> -1
+ddcom045 compare 00 20 -> -1
+ddcom046 compare 10 -20 -> 1
+ddcom047 compare 10 -10 -> 1
+ddcom048 compare 10 00 -> 1
+ddcom049 compare 10 10 -> 0
+ddcom050 compare 10 20 -> -1
+ddcom051 compare 20 -20 -> 1
+ddcom052 compare 20 -10 -> 1
+ddcom053 compare 20 00 -> 1
+ddcom055 compare 20 10 -> 1
+ddcom056 compare 20 20 -> 0
+
+ddcom061 compare -2.0 -2.0 -> 0
+ddcom062 compare -2.0 -1.0 -> -1
+ddcom063 compare -2.0 0.0 -> -1
+ddcom064 compare -2.0 1.0 -> -1
+ddcom065 compare -2.0 2.0 -> -1
+ddcom066 compare -1.0 -2.0 -> 1
+ddcom067 compare -1.0 -1.0 -> 0
+ddcom068 compare -1.0 0.0 -> -1
+ddcom069 compare -1.0 1.0 -> -1
+ddcom070 compare -1.0 2.0 -> -1
+ddcom071 compare 0.0 -2.0 -> 1
+ddcom072 compare 0.0 -1.0 -> 1
+ddcom073 compare 0.0 0.0 -> 0
+ddcom074 compare 0.0 1.0 -> -1
+ddcom075 compare 0.0 2.0 -> -1
+ddcom076 compare 1.0 -2.0 -> 1
+ddcom077 compare 1.0 -1.0 -> 1
+ddcom078 compare 1.0 0.0 -> 1
+ddcom079 compare 1.0 1.0 -> 0
+ddcom080 compare 1.0 2.0 -> -1
+ddcom081 compare 2.0 -2.0 -> 1
+ddcom082 compare 2.0 -1.0 -> 1
+ddcom083 compare 2.0 0.0 -> 1
+ddcom085 compare 2.0 1.0 -> 1
+ddcom086 compare 2.0 2.0 -> 0
+ddcom087 compare 1.0 0.1 -> 1
+ddcom088 compare 0.1 1.0 -> -1
+
+-- now some cases which might overflow if subtract were used
+ddcom095 compare 9.999999999999999E+384 9.999999999999999E+384 -> 0
+ddcom096 compare -9.999999999999999E+384 9.999999999999999E+384 -> -1
+ddcom097 compare 9.999999999999999E+384 -9.999999999999999E+384 -> 1
+ddcom098 compare -9.999999999999999E+384 -9.999999999999999E+384 -> 0
+
+-- some differing length/exponent cases
+ddcom100 compare 7.0 7.0 -> 0
+ddcom101 compare 7.0 7 -> 0
+ddcom102 compare 7 7.0 -> 0
+ddcom103 compare 7E+0 7.0 -> 0
+ddcom104 compare 70E-1 7.0 -> 0
+ddcom105 compare 0.7E+1 7 -> 0
+ddcom106 compare 70E-1 7 -> 0
+ddcom107 compare 7.0 7E+0 -> 0
+ddcom108 compare 7.0 70E-1 -> 0
+ddcom109 compare 7 0.7E+1 -> 0
+ddcom110 compare 7 70E-1 -> 0
+
+ddcom120 compare 8.0 7.0 -> 1
+ddcom121 compare 8.0 7 -> 1
+ddcom122 compare 8 7.0 -> 1
+ddcom123 compare 8E+0 7.0 -> 1
+ddcom124 compare 80E-1 7.0 -> 1
+ddcom125 compare 0.8E+1 7 -> 1
+ddcom126 compare 80E-1 7 -> 1
+ddcom127 compare 8.0 7E+0 -> 1
+ddcom128 compare 8.0 70E-1 -> 1
+ddcom129 compare 8 0.7E+1 -> 1
+ddcom130 compare 8 70E-1 -> 1
+
+ddcom140 compare 8.0 9.0 -> -1
+ddcom141 compare 8.0 9 -> -1
+ddcom142 compare 8 9.0 -> -1
+ddcom143 compare 8E+0 9.0 -> -1
+ddcom144 compare 80E-1 9.0 -> -1
+ddcom145 compare 0.8E+1 9 -> -1
+ddcom146 compare 80E-1 9 -> -1
+ddcom147 compare 8.0 9E+0 -> -1
+ddcom148 compare 8.0 90E-1 -> -1
+ddcom149 compare 8 0.9E+1 -> -1
+ddcom150 compare 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ddcom200 compare -7.0 7.0 -> -1
+ddcom201 compare -7.0 7 -> -1
+ddcom202 compare -7 7.0 -> -1
+ddcom203 compare -7E+0 7.0 -> -1
+ddcom204 compare -70E-1 7.0 -> -1
+ddcom205 compare -0.7E+1 7 -> -1
+ddcom206 compare -70E-1 7 -> -1
+ddcom207 compare -7.0 7E+0 -> -1
+ddcom208 compare -7.0 70E-1 -> -1
+ddcom209 compare -7 0.7E+1 -> -1
+ddcom210 compare -7 70E-1 -> -1
+
+ddcom220 compare -8.0 7.0 -> -1
+ddcom221 compare -8.0 7 -> -1
+ddcom222 compare -8 7.0 -> -1
+ddcom223 compare -8E+0 7.0 -> -1
+ddcom224 compare -80E-1 7.0 -> -1
+ddcom225 compare -0.8E+1 7 -> -1
+ddcom226 compare -80E-1 7 -> -1
+ddcom227 compare -8.0 7E+0 -> -1
+ddcom228 compare -8.0 70E-1 -> -1
+ddcom229 compare -8 0.7E+1 -> -1
+ddcom230 compare -8 70E-1 -> -1
+
+ddcom240 compare -8.0 9.0 -> -1
+ddcom241 compare -8.0 9 -> -1
+ddcom242 compare -8 9.0 -> -1
+ddcom243 compare -8E+0 9.0 -> -1
+ddcom244 compare -80E-1 9.0 -> -1
+ddcom245 compare -0.8E+1 9 -> -1
+ddcom246 compare -80E-1 9 -> -1
+ddcom247 compare -8.0 9E+0 -> -1
+ddcom248 compare -8.0 90E-1 -> -1
+ddcom249 compare -8 0.9E+1 -> -1
+ddcom250 compare -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ddcom300 compare 7.0 -7.0 -> 1
+ddcom301 compare 7.0 -7 -> 1
+ddcom302 compare 7 -7.0 -> 1
+ddcom303 compare 7E+0 -7.0 -> 1
+ddcom304 compare 70E-1 -7.0 -> 1
+ddcom305 compare .7E+1 -7 -> 1
+ddcom306 compare 70E-1 -7 -> 1
+ddcom307 compare 7.0 -7E+0 -> 1
+ddcom308 compare 7.0 -70E-1 -> 1
+ddcom309 compare 7 -.7E+1 -> 1
+ddcom310 compare 7 -70E-1 -> 1
+
+ddcom320 compare 8.0 -7.0 -> 1
+ddcom321 compare 8.0 -7 -> 1
+ddcom322 compare 8 -7.0 -> 1
+ddcom323 compare 8E+0 -7.0 -> 1
+ddcom324 compare 80E-1 -7.0 -> 1
+ddcom325 compare .8E+1 -7 -> 1
+ddcom326 compare 80E-1 -7 -> 1
+ddcom327 compare 8.0 -7E+0 -> 1
+ddcom328 compare 8.0 -70E-1 -> 1
+ddcom329 compare 8 -.7E+1 -> 1
+ddcom330 compare 8 -70E-1 -> 1
+
+ddcom340 compare 8.0 -9.0 -> 1
+ddcom341 compare 8.0 -9 -> 1
+ddcom342 compare 8 -9.0 -> 1
+ddcom343 compare 8E+0 -9.0 -> 1
+ddcom344 compare 80E-1 -9.0 -> 1
+ddcom345 compare .8E+1 -9 -> 1
+ddcom346 compare 80E-1 -9 -> 1
+ddcom347 compare 8.0 -9E+0 -> 1
+ddcom348 compare 8.0 -90E-1 -> 1
+ddcom349 compare 8 -.9E+1 -> 1
+ddcom350 compare 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+ddcom400 compare -7.0 -7.0 -> 0
+ddcom401 compare -7.0 -7 -> 0
+ddcom402 compare -7 -7.0 -> 0
+ddcom403 compare -7E+0 -7.0 -> 0
+ddcom404 compare -70E-1 -7.0 -> 0
+ddcom405 compare -.7E+1 -7 -> 0
+ddcom406 compare -70E-1 -7 -> 0
+ddcom407 compare -7.0 -7E+0 -> 0
+ddcom408 compare -7.0 -70E-1 -> 0
+ddcom409 compare -7 -.7E+1 -> 0
+ddcom410 compare -7 -70E-1 -> 0
+
+ddcom420 compare -8.0 -7.0 -> -1
+ddcom421 compare -8.0 -7 -> -1
+ddcom422 compare -8 -7.0 -> -1
+ddcom423 compare -8E+0 -7.0 -> -1
+ddcom424 compare -80E-1 -7.0 -> -1
+ddcom425 compare -.8E+1 -7 -> -1
+ddcom426 compare -80E-1 -7 -> -1
+ddcom427 compare -8.0 -7E+0 -> -1
+ddcom428 compare -8.0 -70E-1 -> -1
+ddcom429 compare -8 -.7E+1 -> -1
+ddcom430 compare -8 -70E-1 -> -1
+
+ddcom440 compare -8.0 -9.0 -> 1
+ddcom441 compare -8.0 -9 -> 1
+ddcom442 compare -8 -9.0 -> 1
+ddcom443 compare -8E+0 -9.0 -> 1
+ddcom444 compare -80E-1 -9.0 -> 1
+ddcom445 compare -.8E+1 -9 -> 1
+ddcom446 compare -80E-1 -9 -> 1
+ddcom447 compare -8.0 -9E+0 -> 1
+ddcom448 compare -8.0 -90E-1 -> 1
+ddcom449 compare -8 -.9E+1 -> 1
+ddcom450 compare -8 -90E-1 -> 1
+
+-- misalignment traps for little-endian
+ddcom451 compare 1.0 0.1 -> 1
+ddcom452 compare 0.1 1.0 -> -1
+ddcom453 compare 10.0 0.1 -> 1
+ddcom454 compare 0.1 10.0 -> -1
+ddcom455 compare 100 1.0 -> 1
+ddcom456 compare 1.0 100 -> -1
+ddcom457 compare 1000 10.0 -> 1
+ddcom458 compare 10.0 1000 -> -1
+ddcom459 compare 10000 100.0 -> 1
+ddcom460 compare 100.0 10000 -> -1
+ddcom461 compare 100000 1000.0 -> 1
+ddcom462 compare 1000.0 100000 -> -1
+ddcom463 compare 1000000 10000.0 -> 1
+ddcom464 compare 10000.0 1000000 -> -1
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+ddcom473 compare 123.4560000000000E-89 123.456E-89 -> 0
+ddcom474 compare 123.456000000000E+89 123.456E+89 -> 0
+ddcom475 compare 123.45600000000E-89 123.456E-89 -> 0
+ddcom476 compare 123.4560000000E+89 123.456E+89 -> 0
+ddcom477 compare 123.456000000E-89 123.456E-89 -> 0
+ddcom478 compare 123.45600000E+89 123.456E+89 -> 0
+ddcom479 compare 123.4560000E-89 123.456E-89 -> 0
+ddcom480 compare 123.456000E+89 123.456E+89 -> 0
+ddcom481 compare 123.45600E-89 123.456E-89 -> 0
+ddcom482 compare 123.4560E+89 123.456E+89 -> 0
+ddcom483 compare 123.456E-89 123.456E-89 -> 0
+ddcom487 compare 123.456E+89 123.4560000000000E+89 -> 0
+ddcom488 compare 123.456E-89 123.456000000000E-89 -> 0
+ddcom489 compare 123.456E+89 123.45600000000E+89 -> 0
+ddcom490 compare 123.456E-89 123.4560000000E-89 -> 0
+ddcom491 compare 123.456E+89 123.456000000E+89 -> 0
+ddcom492 compare 123.456E-89 123.45600000E-89 -> 0
+ddcom493 compare 123.456E+89 123.4560000E+89 -> 0
+ddcom494 compare 123.456E-89 123.456000E-89 -> 0
+ddcom495 compare 123.456E+89 123.45600E+89 -> 0
+ddcom496 compare 123.456E-89 123.4560E-89 -> 0
+ddcom497 compare 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+ddcom500 compare 1 1E-15 -> 1
+ddcom501 compare 1 1E-14 -> 1
+ddcom502 compare 1 1E-13 -> 1
+ddcom503 compare 1 1E-12 -> 1
+ddcom504 compare 1 1E-11 -> 1
+ddcom505 compare 1 1E-10 -> 1
+ddcom506 compare 1 1E-9 -> 1
+ddcom507 compare 1 1E-8 -> 1
+ddcom508 compare 1 1E-7 -> 1
+ddcom509 compare 1 1E-6 -> 1
+ddcom510 compare 1 1E-5 -> 1
+ddcom511 compare 1 1E-4 -> 1
+ddcom512 compare 1 1E-3 -> 1
+ddcom513 compare 1 1E-2 -> 1
+ddcom514 compare 1 1E-1 -> 1
+ddcom515 compare 1 1E-0 -> 0
+ddcom516 compare 1 1E+1 -> -1
+ddcom517 compare 1 1E+2 -> -1
+ddcom518 compare 1 1E+3 -> -1
+ddcom519 compare 1 1E+4 -> -1
+ddcom521 compare 1 1E+5 -> -1
+ddcom522 compare 1 1E+6 -> -1
+ddcom523 compare 1 1E+7 -> -1
+ddcom524 compare 1 1E+8 -> -1
+ddcom525 compare 1 1E+9 -> -1
+ddcom526 compare 1 1E+10 -> -1
+ddcom527 compare 1 1E+11 -> -1
+ddcom528 compare 1 1E+12 -> -1
+ddcom529 compare 1 1E+13 -> -1
+ddcom530 compare 1 1E+14 -> -1
+ddcom531 compare 1 1E+15 -> -1
+-- LR swap
+ddcom540 compare 1E-15 1 -> -1
+ddcom541 compare 1E-14 1 -> -1
+ddcom542 compare 1E-13 1 -> -1
+ddcom543 compare 1E-12 1 -> -1
+ddcom544 compare 1E-11 1 -> -1
+ddcom545 compare 1E-10 1 -> -1
+ddcom546 compare 1E-9 1 -> -1
+ddcom547 compare 1E-8 1 -> -1
+ddcom548 compare 1E-7 1 -> -1
+ddcom549 compare 1E-6 1 -> -1
+ddcom550 compare 1E-5 1 -> -1
+ddcom551 compare 1E-4 1 -> -1
+ddcom552 compare 1E-3 1 -> -1
+ddcom553 compare 1E-2 1 -> -1
+ddcom554 compare 1E-1 1 -> -1
+ddcom555 compare 1E-0 1 -> 0
+ddcom556 compare 1E+1 1 -> 1
+ddcom557 compare 1E+2 1 -> 1
+ddcom558 compare 1E+3 1 -> 1
+ddcom559 compare 1E+4 1 -> 1
+ddcom561 compare 1E+5 1 -> 1
+ddcom562 compare 1E+6 1 -> 1
+ddcom563 compare 1E+7 1 -> 1
+ddcom564 compare 1E+8 1 -> 1
+ddcom565 compare 1E+9 1 -> 1
+ddcom566 compare 1E+10 1 -> 1
+ddcom567 compare 1E+11 1 -> 1
+ddcom568 compare 1E+12 1 -> 1
+ddcom569 compare 1E+13 1 -> 1
+ddcom570 compare 1E+14 1 -> 1
+ddcom571 compare 1E+15 1 -> 1
+-- similar with a useful coefficient, one side only
+ddcom580 compare 0.000000987654321 1E-15 -> 1
+ddcom581 compare 0.000000987654321 1E-14 -> 1
+ddcom582 compare 0.000000987654321 1E-13 -> 1
+ddcom583 compare 0.000000987654321 1E-12 -> 1
+ddcom584 compare 0.000000987654321 1E-11 -> 1
+ddcom585 compare 0.000000987654321 1E-10 -> 1
+ddcom586 compare 0.000000987654321 1E-9 -> 1
+ddcom587 compare 0.000000987654321 1E-8 -> 1
+ddcom588 compare 0.000000987654321 1E-7 -> 1
+ddcom589 compare 0.000000987654321 1E-6 -> -1
+ddcom590 compare 0.000000987654321 1E-5 -> -1
+ddcom591 compare 0.000000987654321 1E-4 -> -1
+ddcom592 compare 0.000000987654321 1E-3 -> -1
+ddcom593 compare 0.000000987654321 1E-2 -> -1
+ddcom594 compare 0.000000987654321 1E-1 -> -1
+ddcom595 compare 0.000000987654321 1E-0 -> -1
+ddcom596 compare 0.000000987654321 1E+1 -> -1
+ddcom597 compare 0.000000987654321 1E+2 -> -1
+ddcom598 compare 0.000000987654321 1E+3 -> -1
+ddcom599 compare 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+ddcom600 compare 12 12.2345 -> -1
+ddcom601 compare 12.0 12.2345 -> -1
+ddcom602 compare 12.00 12.2345 -> -1
+ddcom603 compare 12.000 12.2345 -> -1
+ddcom604 compare 12.0000 12.2345 -> -1
+ddcom605 compare 12.00000 12.2345 -> -1
+ddcom606 compare 12.000000 12.2345 -> -1
+ddcom607 compare 12.0000000 12.2345 -> -1
+ddcom608 compare 12.00000000 12.2345 -> -1
+ddcom609 compare 12.000000000 12.2345 -> -1
+ddcom610 compare 12.1234 12 -> 1
+ddcom611 compare 12.1234 12.0 -> 1
+ddcom612 compare 12.1234 12.00 -> 1
+ddcom613 compare 12.1234 12.000 -> 1
+ddcom614 compare 12.1234 12.0000 -> 1
+ddcom615 compare 12.1234 12.00000 -> 1
+ddcom616 compare 12.1234 12.000000 -> 1
+ddcom617 compare 12.1234 12.0000000 -> 1
+ddcom618 compare 12.1234 12.00000000 -> 1
+ddcom619 compare 12.1234 12.000000000 -> 1
+ddcom620 compare -12 -12.2345 -> 1
+ddcom621 compare -12.0 -12.2345 -> 1
+ddcom622 compare -12.00 -12.2345 -> 1
+ddcom623 compare -12.000 -12.2345 -> 1
+ddcom624 compare -12.0000 -12.2345 -> 1
+ddcom625 compare -12.00000 -12.2345 -> 1
+ddcom626 compare -12.000000 -12.2345 -> 1
+ddcom627 compare -12.0000000 -12.2345 -> 1
+ddcom628 compare -12.00000000 -12.2345 -> 1
+ddcom629 compare -12.000000000 -12.2345 -> 1
+ddcom630 compare -12.1234 -12 -> -1
+ddcom631 compare -12.1234 -12.0 -> -1
+ddcom632 compare -12.1234 -12.00 -> -1
+ddcom633 compare -12.1234 -12.000 -> -1
+ddcom634 compare -12.1234 -12.0000 -> -1
+ddcom635 compare -12.1234 -12.00000 -> -1
+ddcom636 compare -12.1234 -12.000000 -> -1
+ddcom637 compare -12.1234 -12.0000000 -> -1
+ddcom638 compare -12.1234 -12.00000000 -> -1
+ddcom639 compare -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+ddcom640 compare 0 0 -> 0
+ddcom641 compare 0 -0 -> 0
+ddcom642 compare 0 -0.0 -> 0
+ddcom643 compare 0 0.0 -> 0
+ddcom644 compare -0 0 -> 0
+ddcom645 compare -0 -0 -> 0
+ddcom646 compare -0 -0.0 -> 0
+ddcom647 compare -0 0.0 -> 0
+ddcom648 compare 0.0 0 -> 0
+ddcom649 compare 0.0 -0 -> 0
+ddcom650 compare 0.0 -0.0 -> 0
+ddcom651 compare 0.0 0.0 -> 0
+ddcom652 compare -0.0 0 -> 0
+ddcom653 compare -0.0 -0 -> 0
+ddcom654 compare -0.0 -0.0 -> 0
+ddcom655 compare -0.0 0.0 -> 0
+
+ddcom656 compare -0E1 0.0 -> 0
+ddcom657 compare -0E2 0.0 -> 0
+ddcom658 compare 0E1 0.0 -> 0
+ddcom659 compare 0E2 0.0 -> 0
+ddcom660 compare -0E1 0 -> 0
+ddcom661 compare -0E2 0 -> 0
+ddcom662 compare 0E1 0 -> 0
+ddcom663 compare 0E2 0 -> 0
+ddcom664 compare -0E1 -0E1 -> 0
+ddcom665 compare -0E2 -0E1 -> 0
+ddcom666 compare 0E1 -0E1 -> 0
+ddcom667 compare 0E2 -0E1 -> 0
+ddcom668 compare -0E1 -0E2 -> 0
+ddcom669 compare -0E2 -0E2 -> 0
+ddcom670 compare 0E1 -0E2 -> 0
+ddcom671 compare 0E2 -0E2 -> 0
+ddcom672 compare -0E1 0E1 -> 0
+ddcom673 compare -0E2 0E1 -> 0
+ddcom674 compare 0E1 0E1 -> 0
+ddcom675 compare 0E2 0E1 -> 0
+ddcom676 compare -0E1 0E2 -> 0
+ddcom677 compare -0E2 0E2 -> 0
+ddcom678 compare 0E1 0E2 -> 0
+ddcom679 compare 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+ddcom680 compare 12 12 -> 0
+ddcom681 compare 12 12.0 -> 0
+ddcom682 compare 12 12.00 -> 0
+ddcom683 compare 12 12.000 -> 0
+ddcom684 compare 12 12.0000 -> 0
+ddcom685 compare 12 12.00000 -> 0
+ddcom686 compare 12 12.000000 -> 0
+ddcom687 compare 12 12.0000000 -> 0
+ddcom688 compare 12 12.00000000 -> 0
+ddcom689 compare 12 12.000000000 -> 0
+ddcom690 compare 12 12 -> 0
+ddcom691 compare 12.0 12 -> 0
+ddcom692 compare 12.00 12 -> 0
+ddcom693 compare 12.000 12 -> 0
+ddcom694 compare 12.0000 12 -> 0
+ddcom695 compare 12.00000 12 -> 0
+ddcom696 compare 12.000000 12 -> 0
+ddcom697 compare 12.0000000 12 -> 0
+ddcom698 compare 12.00000000 12 -> 0
+ddcom699 compare 12.000000000 12 -> 0
+
+-- first, second, & last digit
+ddcom700 compare 1234567890123456 1234567890123455 -> 1
+ddcom701 compare 1234567890123456 1234567890123456 -> 0
+ddcom702 compare 1234567890123456 1234567890123457 -> -1
+ddcom703 compare 1234567890123456 0234567890123456 -> 1
+ddcom704 compare 1234567890123456 1234567890123456 -> 0
+ddcom705 compare 1234567890123456 2234567890123456 -> -1
+ddcom706 compare 1134567890123456 1034567890123456 -> 1
+ddcom707 compare 1134567890123456 1134567890123456 -> 0
+ddcom708 compare 1134567890123456 1234567890123456 -> -1
+
+-- miscellaneous
+ddcom721 compare 12345678000 1 -> 1
+ddcom722 compare 1 12345678000 -> -1
+ddcom723 compare 1234567800 1 -> 1
+ddcom724 compare 1 1234567800 -> -1
+ddcom725 compare 1234567890 1 -> 1
+ddcom726 compare 1 1234567890 -> -1
+ddcom727 compare 1234567891 1 -> 1
+ddcom728 compare 1 1234567891 -> -1
+ddcom729 compare 12345678901 1 -> 1
+ddcom730 compare 1 12345678901 -> -1
+ddcom731 compare 1234567896 1 -> 1
+ddcom732 compare 1 1234567896 -> -1
+
+-- residue cases at lower precision
+ddcom740 compare 1 0.9999999 -> 1
+ddcom741 compare 1 0.999999 -> 1
+ddcom742 compare 1 0.99999 -> 1
+ddcom743 compare 1 1.0000 -> 0
+ddcom744 compare 1 1.00001 -> -1
+ddcom745 compare 1 1.000001 -> -1
+ddcom746 compare 1 1.0000001 -> -1
+ddcom750 compare 0.9999999 1 -> -1
+ddcom751 compare 0.999999 1 -> -1
+ddcom752 compare 0.99999 1 -> -1
+ddcom753 compare 1.0000 1 -> 0
+ddcom754 compare 1.00001 1 -> 1
+ddcom755 compare 1.000001 1 -> 1
+ddcom756 compare 1.0000001 1 -> 1
+
+-- Specials
+ddcom780 compare Inf -Inf -> 1
+ddcom781 compare Inf -1000 -> 1
+ddcom782 compare Inf -1 -> 1
+ddcom783 compare Inf -0 -> 1
+ddcom784 compare Inf 0 -> 1
+ddcom785 compare Inf 1 -> 1
+ddcom786 compare Inf 1000 -> 1
+ddcom787 compare Inf Inf -> 0
+ddcom788 compare -1000 Inf -> -1
+ddcom789 compare -Inf Inf -> -1
+ddcom790 compare -1 Inf -> -1
+ddcom791 compare -0 Inf -> -1
+ddcom792 compare 0 Inf -> -1
+ddcom793 compare 1 Inf -> -1
+ddcom794 compare 1000 Inf -> -1
+ddcom795 compare Inf Inf -> 0
+
+ddcom800 compare -Inf -Inf -> 0
+ddcom801 compare -Inf -1000 -> -1
+ddcom802 compare -Inf -1 -> -1
+ddcom803 compare -Inf -0 -> -1
+ddcom804 compare -Inf 0 -> -1
+ddcom805 compare -Inf 1 -> -1
+ddcom806 compare -Inf 1000 -> -1
+ddcom807 compare -Inf Inf -> -1
+ddcom808 compare -Inf -Inf -> 0
+ddcom809 compare -1000 -Inf -> 1
+ddcom810 compare -1 -Inf -> 1
+ddcom811 compare -0 -Inf -> 1
+ddcom812 compare 0 -Inf -> 1
+ddcom813 compare 1 -Inf -> 1
+ddcom814 compare 1000 -Inf -> 1
+ddcom815 compare Inf -Inf -> 1
+
+ddcom821 compare NaN -Inf -> NaN
+ddcom822 compare NaN -1000 -> NaN
+ddcom823 compare NaN -1 -> NaN
+ddcom824 compare NaN -0 -> NaN
+ddcom825 compare NaN 0 -> NaN
+ddcom826 compare NaN 1 -> NaN
+ddcom827 compare NaN 1000 -> NaN
+ddcom828 compare NaN Inf -> NaN
+ddcom829 compare NaN NaN -> NaN
+ddcom830 compare -Inf NaN -> NaN
+ddcom831 compare -1000 NaN -> NaN
+ddcom832 compare -1 NaN -> NaN
+ddcom833 compare -0 NaN -> NaN
+ddcom834 compare 0 NaN -> NaN
+ddcom835 compare 1 NaN -> NaN
+ddcom836 compare 1000 NaN -> NaN
+ddcom837 compare Inf NaN -> NaN
+ddcom838 compare -NaN -NaN -> -NaN
+ddcom839 compare +NaN -NaN -> NaN
+ddcom840 compare -NaN +NaN -> -NaN
+
+ddcom841 compare sNaN -Inf -> NaN Invalid_operation
+ddcom842 compare sNaN -1000 -> NaN Invalid_operation
+ddcom843 compare sNaN -1 -> NaN Invalid_operation
+ddcom844 compare sNaN -0 -> NaN Invalid_operation
+ddcom845 compare sNaN 0 -> NaN Invalid_operation
+ddcom846 compare sNaN 1 -> NaN Invalid_operation
+ddcom847 compare sNaN 1000 -> NaN Invalid_operation
+ddcom848 compare sNaN NaN -> NaN Invalid_operation
+ddcom849 compare sNaN sNaN -> NaN Invalid_operation
+ddcom850 compare NaN sNaN -> NaN Invalid_operation
+ddcom851 compare -Inf sNaN -> NaN Invalid_operation
+ddcom852 compare -1000 sNaN -> NaN Invalid_operation
+ddcom853 compare -1 sNaN -> NaN Invalid_operation
+ddcom854 compare -0 sNaN -> NaN Invalid_operation
+ddcom855 compare 0 sNaN -> NaN Invalid_operation
+ddcom856 compare 1 sNaN -> NaN Invalid_operation
+ddcom857 compare 1000 sNaN -> NaN Invalid_operation
+ddcom858 compare Inf sNaN -> NaN Invalid_operation
+ddcom859 compare NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddcom860 compare NaN9 -Inf -> NaN9
+ddcom861 compare NaN8 999 -> NaN8
+ddcom862 compare NaN77 Inf -> NaN77
+ddcom863 compare -NaN67 NaN5 -> -NaN67
+ddcom864 compare -Inf -NaN4 -> -NaN4
+ddcom865 compare -999 -NaN33 -> -NaN33
+ddcom866 compare Inf NaN2 -> NaN2
+ddcom867 compare -NaN41 -NaN42 -> -NaN41
+ddcom868 compare +NaN41 -NaN42 -> NaN41
+ddcom869 compare -NaN41 +NaN42 -> -NaN41
+ddcom870 compare +NaN41 +NaN42 -> NaN41
+
+ddcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
+ddcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
+ddcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
+ddcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
+ddcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
+ddcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
+ddcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
+ddcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
+ddcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- wide range
+ddcom880 compare +1.23456789012345E-0 9E+384 -> -1
+ddcom881 compare 9E+384 +1.23456789012345E-0 -> 1
+ddcom882 compare +0.100 9E-383 -> 1
+ddcom883 compare 9E-383 +0.100 -> -1
+ddcom885 compare -1.23456789012345E-0 9E+384 -> -1
+ddcom886 compare 9E+384 -1.23456789012345E-0 -> 1
+ddcom887 compare -0.100 9E-383 -> -1
+ddcom888 compare 9E-383 -0.100 -> 1
+
+-- spread zeros
+ddcom900 compare 0E-383 0 -> 0
+ddcom901 compare 0E-383 -0 -> 0
+ddcom902 compare -0E-383 0 -> 0
+ddcom903 compare -0E-383 -0 -> 0
+ddcom904 compare 0E-383 0E+384 -> 0
+ddcom905 compare 0E-383 -0E+384 -> 0
+ddcom906 compare -0E-383 0E+384 -> 0
+ddcom907 compare -0E-383 -0E+384 -> 0
+ddcom908 compare 0 0E+384 -> 0
+ddcom909 compare 0 -0E+384 -> 0
+ddcom910 compare -0 0E+384 -> 0
+ddcom911 compare -0 -0E+384 -> 0
+ddcom930 compare 0E+384 0 -> 0
+ddcom931 compare 0E+384 -0 -> 0
+ddcom932 compare -0E+384 0 -> 0
+ddcom933 compare -0E+384 -0 -> 0
+ddcom934 compare 0E+384 0E-383 -> 0
+ddcom935 compare 0E+384 -0E-383 -> 0
+ddcom936 compare -0E+384 0E-383 -> 0
+ddcom937 compare -0E+384 -0E-383 -> 0
+ddcom938 compare 0 0E-383 -> 0
+ddcom939 compare 0 -0E-383 -> 0
+ddcom940 compare -0 0E-383 -> 0
+ddcom941 compare -0 -0E-383 -> 0
+
+-- signs
+ddcom961 compare 1e+77 1e+11 -> 1
+ddcom962 compare 1e+77 -1e+11 -> 1
+ddcom963 compare -1e+77 1e+11 -> -1
+ddcom964 compare -1e+77 -1e+11 -> -1
+ddcom965 compare 1e-77 1e-11 -> -1
+ddcom966 compare 1e-77 -1e-11 -> 1
+ddcom967 compare -1e-77 1e-11 -> -1
+ddcom968 compare -1e-77 -1e-11 -> 1
+
+-- full alignment range, both ways
+ddcomp1001 compare 1 1.000000000000000 -> 0
+ddcomp1002 compare 1 1.00000000000000 -> 0
+ddcomp1003 compare 1 1.0000000000000 -> 0
+ddcomp1004 compare 1 1.000000000000 -> 0
+ddcomp1005 compare 1 1.00000000000 -> 0
+ddcomp1006 compare 1 1.0000000000 -> 0
+ddcomp1007 compare 1 1.000000000 -> 0
+ddcomp1008 compare 1 1.00000000 -> 0
+ddcomp1009 compare 1 1.0000000 -> 0
+ddcomp1010 compare 1 1.000000 -> 0
+ddcomp1011 compare 1 1.00000 -> 0
+ddcomp1012 compare 1 1.0000 -> 0
+ddcomp1013 compare 1 1.000 -> 0
+ddcomp1014 compare 1 1.00 -> 0
+ddcomp1015 compare 1 1.0 -> 0
+ddcomp1021 compare 1.000000000000000 1 -> 0
+ddcomp1022 compare 1.00000000000000 1 -> 0
+ddcomp1023 compare 1.0000000000000 1 -> 0
+ddcomp1024 compare 1.000000000000 1 -> 0
+ddcomp1025 compare 1.00000000000 1 -> 0
+ddcomp1026 compare 1.0000000000 1 -> 0
+ddcomp1027 compare 1.000000000 1 -> 0
+ddcomp1028 compare 1.00000000 1 -> 0
+ddcomp1029 compare 1.0000000 1 -> 0
+ddcomp1030 compare 1.000000 1 -> 0
+ddcomp1031 compare 1.00000 1 -> 0
+ddcomp1032 compare 1.0000 1 -> 0
+ddcomp1033 compare 1.000 1 -> 0
+ddcomp1034 compare 1.00 1 -> 0
+ddcomp1035 compare 1.0 1 -> 0
+
+-- check MSD always detected non-zero
+ddcomp1040 compare 0 0.000000000000000 -> 0
+ddcomp1041 compare 0 1.000000000000000 -> -1
+ddcomp1042 compare 0 2.000000000000000 -> -1
+ddcomp1043 compare 0 3.000000000000000 -> -1
+ddcomp1044 compare 0 4.000000000000000 -> -1
+ddcomp1045 compare 0 5.000000000000000 -> -1
+ddcomp1046 compare 0 6.000000000000000 -> -1
+ddcomp1047 compare 0 7.000000000000000 -> -1
+ddcomp1048 compare 0 8.000000000000000 -> -1
+ddcomp1049 compare 0 9.000000000000000 -> -1
+ddcomp1050 compare 0.000000000000000 0 -> 0
+ddcomp1051 compare 1.000000000000000 0 -> 1
+ddcomp1052 compare 2.000000000000000 0 -> 1
+ddcomp1053 compare 3.000000000000000 0 -> 1
+ddcomp1054 compare 4.000000000000000 0 -> 1
+ddcomp1055 compare 5.000000000000000 0 -> 1
+ddcomp1056 compare 6.000000000000000 0 -> 1
+ddcomp1057 compare 7.000000000000000 0 -> 1
+ddcomp1058 compare 8.000000000000000 0 -> 1
+ddcomp1059 compare 9.000000000000000 0 -> 1
+
+-- Null tests
+ddcom9990 compare 10 # -> NaN Invalid_operation
+ddcom9991 compare # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddCompareSig.decTest b/Lib/test/decimaltestdata/ddCompareSig.decTest
index c82ec45517..8d3fce08c7 100644
--- a/Lib/test/decimaltestdata/ddCompareSig.decTest
+++ b/Lib/test/decimaltestdata/ddCompareSig.decTest
@@ -1,647 +1,647 @@
-------------------------------------------------------------------------
--- ddCompareSig.decTest -- decDouble comparison; all NaNs signal --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddcms001 comparesig -2 -2 -> 0
-ddcms002 comparesig -2 -1 -> -1
-ddcms003 comparesig -2 0 -> -1
-ddcms004 comparesig -2 1 -> -1
-ddcms005 comparesig -2 2 -> -1
-ddcms006 comparesig -1 -2 -> 1
-ddcms007 comparesig -1 -1 -> 0
-ddcms008 comparesig -1 0 -> -1
-ddcms009 comparesig -1 1 -> -1
-ddcms010 comparesig -1 2 -> -1
-ddcms011 comparesig 0 -2 -> 1
-ddcms012 comparesig 0 -1 -> 1
-ddcms013 comparesig 0 0 -> 0
-ddcms014 comparesig 0 1 -> -1
-ddcms015 comparesig 0 2 -> -1
-ddcms016 comparesig 1 -2 -> 1
-ddcms017 comparesig 1 -1 -> 1
-ddcms018 comparesig 1 0 -> 1
-ddcms019 comparesig 1 1 -> 0
-ddcms020 comparesig 1 2 -> -1
-ddcms021 comparesig 2 -2 -> 1
-ddcms022 comparesig 2 -1 -> 1
-ddcms023 comparesig 2 0 -> 1
-ddcms025 comparesig 2 1 -> 1
-ddcms026 comparesig 2 2 -> 0
-
-ddcms031 comparesig -20 -20 -> 0
-ddcms032 comparesig -20 -10 -> -1
-ddcms033 comparesig -20 00 -> -1
-ddcms034 comparesig -20 10 -> -1
-ddcms035 comparesig -20 20 -> -1
-ddcms036 comparesig -10 -20 -> 1
-ddcms037 comparesig -10 -10 -> 0
-ddcms038 comparesig -10 00 -> -1
-ddcms039 comparesig -10 10 -> -1
-ddcms040 comparesig -10 20 -> -1
-ddcms041 comparesig 00 -20 -> 1
-ddcms042 comparesig 00 -10 -> 1
-ddcms043 comparesig 00 00 -> 0
-ddcms044 comparesig 00 10 -> -1
-ddcms045 comparesig 00 20 -> -1
-ddcms046 comparesig 10 -20 -> 1
-ddcms047 comparesig 10 -10 -> 1
-ddcms048 comparesig 10 00 -> 1
-ddcms049 comparesig 10 10 -> 0
-ddcms050 comparesig 10 20 -> -1
-ddcms051 comparesig 20 -20 -> 1
-ddcms052 comparesig 20 -10 -> 1
-ddcms053 comparesig 20 00 -> 1
-ddcms055 comparesig 20 10 -> 1
-ddcms056 comparesig 20 20 -> 0
-
-ddcms061 comparesig -2.0 -2.0 -> 0
-ddcms062 comparesig -2.0 -1.0 -> -1
-ddcms063 comparesig -2.0 0.0 -> -1
-ddcms064 comparesig -2.0 1.0 -> -1
-ddcms065 comparesig -2.0 2.0 -> -1
-ddcms066 comparesig -1.0 -2.0 -> 1
-ddcms067 comparesig -1.0 -1.0 -> 0
-ddcms068 comparesig -1.0 0.0 -> -1
-ddcms069 comparesig -1.0 1.0 -> -1
-ddcms070 comparesig -1.0 2.0 -> -1
-ddcms071 comparesig 0.0 -2.0 -> 1
-ddcms072 comparesig 0.0 -1.0 -> 1
-ddcms073 comparesig 0.0 0.0 -> 0
-ddcms074 comparesig 0.0 1.0 -> -1
-ddcms075 comparesig 0.0 2.0 -> -1
-ddcms076 comparesig 1.0 -2.0 -> 1
-ddcms077 comparesig 1.0 -1.0 -> 1
-ddcms078 comparesig 1.0 0.0 -> 1
-ddcms079 comparesig 1.0 1.0 -> 0
-ddcms080 comparesig 1.0 2.0 -> -1
-ddcms081 comparesig 2.0 -2.0 -> 1
-ddcms082 comparesig 2.0 -1.0 -> 1
-ddcms083 comparesig 2.0 0.0 -> 1
-ddcms085 comparesig 2.0 1.0 -> 1
-ddcms086 comparesig 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-ddcms090 comparesig 9.999999999999999E+384 9.999999999999999E+384 -> 0
-ddcms091 comparesig -9.999999999999999E+384 9.999999999999999E+384 -> -1
-ddcms092 comparesig 9.999999999999999E+384 -9.999999999999999E+384 -> 1
-ddcms093 comparesig -9.999999999999999E+384 -9.999999999999999E+384 -> 0
-
--- some differing length/exponent cases
-ddcms100 comparesig 7.0 7.0 -> 0
-ddcms101 comparesig 7.0 7 -> 0
-ddcms102 comparesig 7 7.0 -> 0
-ddcms103 comparesig 7E+0 7.0 -> 0
-ddcms104 comparesig 70E-1 7.0 -> 0
-ddcms105 comparesig 0.7E+1 7 -> 0
-ddcms106 comparesig 70E-1 7 -> 0
-ddcms107 comparesig 7.0 7E+0 -> 0
-ddcms108 comparesig 7.0 70E-1 -> 0
-ddcms109 comparesig 7 0.7E+1 -> 0
-ddcms110 comparesig 7 70E-1 -> 0
-
-ddcms120 comparesig 8.0 7.0 -> 1
-ddcms121 comparesig 8.0 7 -> 1
-ddcms122 comparesig 8 7.0 -> 1
-ddcms123 comparesig 8E+0 7.0 -> 1
-ddcms124 comparesig 80E-1 7.0 -> 1
-ddcms125 comparesig 0.8E+1 7 -> 1
-ddcms126 comparesig 80E-1 7 -> 1
-ddcms127 comparesig 8.0 7E+0 -> 1
-ddcms128 comparesig 8.0 70E-1 -> 1
-ddcms129 comparesig 8 0.7E+1 -> 1
-ddcms130 comparesig 8 70E-1 -> 1
-
-ddcms140 comparesig 8.0 9.0 -> -1
-ddcms141 comparesig 8.0 9 -> -1
-ddcms142 comparesig 8 9.0 -> -1
-ddcms143 comparesig 8E+0 9.0 -> -1
-ddcms144 comparesig 80E-1 9.0 -> -1
-ddcms145 comparesig 0.8E+1 9 -> -1
-ddcms146 comparesig 80E-1 9 -> -1
-ddcms147 comparesig 8.0 9E+0 -> -1
-ddcms148 comparesig 8.0 90E-1 -> -1
-ddcms149 comparesig 8 0.9E+1 -> -1
-ddcms150 comparesig 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ddcms200 comparesig -7.0 7.0 -> -1
-ddcms201 comparesig -7.0 7 -> -1
-ddcms202 comparesig -7 7.0 -> -1
-ddcms203 comparesig -7E+0 7.0 -> -1
-ddcms204 comparesig -70E-1 7.0 -> -1
-ddcms205 comparesig -0.7E+1 7 -> -1
-ddcms206 comparesig -70E-1 7 -> -1
-ddcms207 comparesig -7.0 7E+0 -> -1
-ddcms208 comparesig -7.0 70E-1 -> -1
-ddcms209 comparesig -7 0.7E+1 -> -1
-ddcms210 comparesig -7 70E-1 -> -1
-
-ddcms220 comparesig -8.0 7.0 -> -1
-ddcms221 comparesig -8.0 7 -> -1
-ddcms222 comparesig -8 7.0 -> -1
-ddcms223 comparesig -8E+0 7.0 -> -1
-ddcms224 comparesig -80E-1 7.0 -> -1
-ddcms225 comparesig -0.8E+1 7 -> -1
-ddcms226 comparesig -80E-1 7 -> -1
-ddcms227 comparesig -8.0 7E+0 -> -1
-ddcms228 comparesig -8.0 70E-1 -> -1
-ddcms229 comparesig -8 0.7E+1 -> -1
-ddcms230 comparesig -8 70E-1 -> -1
-
-ddcms240 comparesig -8.0 9.0 -> -1
-ddcms241 comparesig -8.0 9 -> -1
-ddcms242 comparesig -8 9.0 -> -1
-ddcms243 comparesig -8E+0 9.0 -> -1
-ddcms244 comparesig -80E-1 9.0 -> -1
-ddcms245 comparesig -0.8E+1 9 -> -1
-ddcms246 comparesig -80E-1 9 -> -1
-ddcms247 comparesig -8.0 9E+0 -> -1
-ddcms248 comparesig -8.0 90E-1 -> -1
-ddcms249 comparesig -8 0.9E+1 -> -1
-ddcms250 comparesig -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ddcms300 comparesig 7.0 -7.0 -> 1
-ddcms301 comparesig 7.0 -7 -> 1
-ddcms302 comparesig 7 -7.0 -> 1
-ddcms303 comparesig 7E+0 -7.0 -> 1
-ddcms304 comparesig 70E-1 -7.0 -> 1
-ddcms305 comparesig .7E+1 -7 -> 1
-ddcms306 comparesig 70E-1 -7 -> 1
-ddcms307 comparesig 7.0 -7E+0 -> 1
-ddcms308 comparesig 7.0 -70E-1 -> 1
-ddcms309 comparesig 7 -.7E+1 -> 1
-ddcms310 comparesig 7 -70E-1 -> 1
-
-ddcms320 comparesig 8.0 -7.0 -> 1
-ddcms321 comparesig 8.0 -7 -> 1
-ddcms322 comparesig 8 -7.0 -> 1
-ddcms323 comparesig 8E+0 -7.0 -> 1
-ddcms324 comparesig 80E-1 -7.0 -> 1
-ddcms325 comparesig .8E+1 -7 -> 1
-ddcms326 comparesig 80E-1 -7 -> 1
-ddcms327 comparesig 8.0 -7E+0 -> 1
-ddcms328 comparesig 8.0 -70E-1 -> 1
-ddcms329 comparesig 8 -.7E+1 -> 1
-ddcms330 comparesig 8 -70E-1 -> 1
-
-ddcms340 comparesig 8.0 -9.0 -> 1
-ddcms341 comparesig 8.0 -9 -> 1
-ddcms342 comparesig 8 -9.0 -> 1
-ddcms343 comparesig 8E+0 -9.0 -> 1
-ddcms344 comparesig 80E-1 -9.0 -> 1
-ddcms345 comparesig .8E+1 -9 -> 1
-ddcms346 comparesig 80E-1 -9 -> 1
-ddcms347 comparesig 8.0 -9E+0 -> 1
-ddcms348 comparesig 8.0 -90E-1 -> 1
-ddcms349 comparesig 8 -.9E+1 -> 1
-ddcms350 comparesig 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-ddcms400 comparesig -7.0 -7.0 -> 0
-ddcms401 comparesig -7.0 -7 -> 0
-ddcms402 comparesig -7 -7.0 -> 0
-ddcms403 comparesig -7E+0 -7.0 -> 0
-ddcms404 comparesig -70E-1 -7.0 -> 0
-ddcms405 comparesig -.7E+1 -7 -> 0
-ddcms406 comparesig -70E-1 -7 -> 0
-ddcms407 comparesig -7.0 -7E+0 -> 0
-ddcms408 comparesig -7.0 -70E-1 -> 0
-ddcms409 comparesig -7 -.7E+1 -> 0
-ddcms410 comparesig -7 -70E-1 -> 0
-
-ddcms420 comparesig -8.0 -7.0 -> -1
-ddcms421 comparesig -8.0 -7 -> -1
-ddcms422 comparesig -8 -7.0 -> -1
-ddcms423 comparesig -8E+0 -7.0 -> -1
-ddcms424 comparesig -80E-1 -7.0 -> -1
-ddcms425 comparesig -.8E+1 -7 -> -1
-ddcms426 comparesig -80E-1 -7 -> -1
-ddcms427 comparesig -8.0 -7E+0 -> -1
-ddcms428 comparesig -8.0 -70E-1 -> -1
-ddcms429 comparesig -8 -.7E+1 -> -1
-ddcms430 comparesig -8 -70E-1 -> -1
-
-ddcms440 comparesig -8.0 -9.0 -> 1
-ddcms441 comparesig -8.0 -9 -> 1
-ddcms442 comparesig -8 -9.0 -> 1
-ddcms443 comparesig -8E+0 -9.0 -> 1
-ddcms444 comparesig -80E-1 -9.0 -> 1
-ddcms445 comparesig -.8E+1 -9 -> 1
-ddcms446 comparesig -80E-1 -9 -> 1
-ddcms447 comparesig -8.0 -9E+0 -> 1
-ddcms448 comparesig -8.0 -90E-1 -> 1
-ddcms449 comparesig -8 -.9E+1 -> 1
-ddcms450 comparesig -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-ddcms473 comparesig 123.4560000000000E-89 123.456E-89 -> 0
-ddcms474 comparesig 123.456000000000E+89 123.456E+89 -> 0
-ddcms475 comparesig 123.45600000000E-89 123.456E-89 -> 0
-ddcms476 comparesig 123.4560000000E+89 123.456E+89 -> 0
-ddcms477 comparesig 123.456000000E-89 123.456E-89 -> 0
-ddcms478 comparesig 123.45600000E+89 123.456E+89 -> 0
-ddcms479 comparesig 123.4560000E-89 123.456E-89 -> 0
-ddcms480 comparesig 123.456000E+89 123.456E+89 -> 0
-ddcms481 comparesig 123.45600E-89 123.456E-89 -> 0
-ddcms482 comparesig 123.4560E+89 123.456E+89 -> 0
-ddcms483 comparesig 123.456E-89 123.456E-89 -> 0
-ddcms487 comparesig 123.456E+89 123.4560000000000E+89 -> 0
-ddcms488 comparesig 123.456E-89 123.456000000000E-89 -> 0
-ddcms489 comparesig 123.456E+89 123.45600000000E+89 -> 0
-ddcms490 comparesig 123.456E-89 123.4560000000E-89 -> 0
-ddcms491 comparesig 123.456E+89 123.456000000E+89 -> 0
-ddcms492 comparesig 123.456E-89 123.45600000E-89 -> 0
-ddcms493 comparesig 123.456E+89 123.4560000E+89 -> 0
-ddcms494 comparesig 123.456E-89 123.456000E-89 -> 0
-ddcms495 comparesig 123.456E+89 123.45600E+89 -> 0
-ddcms496 comparesig 123.456E-89 123.4560E-89 -> 0
-ddcms497 comparesig 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-ddcms500 comparesig 1 1E-15 -> 1
-ddcms501 comparesig 1 1E-14 -> 1
-ddcms502 comparesig 1 1E-13 -> 1
-ddcms503 comparesig 1 1E-12 -> 1
-ddcms504 comparesig 1 1E-11 -> 1
-ddcms505 comparesig 1 1E-10 -> 1
-ddcms506 comparesig 1 1E-9 -> 1
-ddcms507 comparesig 1 1E-8 -> 1
-ddcms508 comparesig 1 1E-7 -> 1
-ddcms509 comparesig 1 1E-6 -> 1
-ddcms510 comparesig 1 1E-5 -> 1
-ddcms511 comparesig 1 1E-4 -> 1
-ddcms512 comparesig 1 1E-3 -> 1
-ddcms513 comparesig 1 1E-2 -> 1
-ddcms514 comparesig 1 1E-1 -> 1
-ddcms515 comparesig 1 1E-0 -> 0
-ddcms516 comparesig 1 1E+1 -> -1
-ddcms517 comparesig 1 1E+2 -> -1
-ddcms518 comparesig 1 1E+3 -> -1
-ddcms519 comparesig 1 1E+4 -> -1
-ddcms521 comparesig 1 1E+5 -> -1
-ddcms522 comparesig 1 1E+6 -> -1
-ddcms523 comparesig 1 1E+7 -> -1
-ddcms524 comparesig 1 1E+8 -> -1
-ddcms525 comparesig 1 1E+9 -> -1
-ddcms526 comparesig 1 1E+10 -> -1
-ddcms527 comparesig 1 1E+11 -> -1
-ddcms528 comparesig 1 1E+12 -> -1
-ddcms529 comparesig 1 1E+13 -> -1
-ddcms530 comparesig 1 1E+14 -> -1
-ddcms531 comparesig 1 1E+15 -> -1
--- LR swap
-ddcms540 comparesig 1E-15 1 -> -1
-ddcms541 comparesig 1E-14 1 -> -1
-ddcms542 comparesig 1E-13 1 -> -1
-ddcms543 comparesig 1E-12 1 -> -1
-ddcms544 comparesig 1E-11 1 -> -1
-ddcms545 comparesig 1E-10 1 -> -1
-ddcms546 comparesig 1E-9 1 -> -1
-ddcms547 comparesig 1E-8 1 -> -1
-ddcms548 comparesig 1E-7 1 -> -1
-ddcms549 comparesig 1E-6 1 -> -1
-ddcms550 comparesig 1E-5 1 -> -1
-ddcms551 comparesig 1E-4 1 -> -1
-ddcms552 comparesig 1E-3 1 -> -1
-ddcms553 comparesig 1E-2 1 -> -1
-ddcms554 comparesig 1E-1 1 -> -1
-ddcms555 comparesig 1E-0 1 -> 0
-ddcms556 comparesig 1E+1 1 -> 1
-ddcms557 comparesig 1E+2 1 -> 1
-ddcms558 comparesig 1E+3 1 -> 1
-ddcms559 comparesig 1E+4 1 -> 1
-ddcms561 comparesig 1E+5 1 -> 1
-ddcms562 comparesig 1E+6 1 -> 1
-ddcms563 comparesig 1E+7 1 -> 1
-ddcms564 comparesig 1E+8 1 -> 1
-ddcms565 comparesig 1E+9 1 -> 1
-ddcms566 comparesig 1E+10 1 -> 1
-ddcms567 comparesig 1E+11 1 -> 1
-ddcms568 comparesig 1E+12 1 -> 1
-ddcms569 comparesig 1E+13 1 -> 1
-ddcms570 comparesig 1E+14 1 -> 1
-ddcms571 comparesig 1E+15 1 -> 1
--- similar with a useful coefficient, one side only
-ddcms580 comparesig 0.000000987654321 1E-15 -> 1
-ddcms581 comparesig 0.000000987654321 1E-14 -> 1
-ddcms582 comparesig 0.000000987654321 1E-13 -> 1
-ddcms583 comparesig 0.000000987654321 1E-12 -> 1
-ddcms584 comparesig 0.000000987654321 1E-11 -> 1
-ddcms585 comparesig 0.000000987654321 1E-10 -> 1
-ddcms586 comparesig 0.000000987654321 1E-9 -> 1
-ddcms587 comparesig 0.000000987654321 1E-8 -> 1
-ddcms588 comparesig 0.000000987654321 1E-7 -> 1
-ddcms589 comparesig 0.000000987654321 1E-6 -> -1
-ddcms590 comparesig 0.000000987654321 1E-5 -> -1
-ddcms591 comparesig 0.000000987654321 1E-4 -> -1
-ddcms592 comparesig 0.000000987654321 1E-3 -> -1
-ddcms593 comparesig 0.000000987654321 1E-2 -> -1
-ddcms594 comparesig 0.000000987654321 1E-1 -> -1
-ddcms595 comparesig 0.000000987654321 1E-0 -> -1
-ddcms596 comparesig 0.000000987654321 1E+1 -> -1
-ddcms597 comparesig 0.000000987654321 1E+2 -> -1
-ddcms598 comparesig 0.000000987654321 1E+3 -> -1
-ddcms599 comparesig 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-ddcms600 comparesig 12 12.2345 -> -1
-ddcms601 comparesig 12.0 12.2345 -> -1
-ddcms602 comparesig 12.00 12.2345 -> -1
-ddcms603 comparesig 12.000 12.2345 -> -1
-ddcms604 comparesig 12.0000 12.2345 -> -1
-ddcms605 comparesig 12.00000 12.2345 -> -1
-ddcms606 comparesig 12.000000 12.2345 -> -1
-ddcms607 comparesig 12.0000000 12.2345 -> -1
-ddcms608 comparesig 12.00000000 12.2345 -> -1
-ddcms609 comparesig 12.000000000 12.2345 -> -1
-ddcms610 comparesig 12.1234 12 -> 1
-ddcms611 comparesig 12.1234 12.0 -> 1
-ddcms612 comparesig 12.1234 12.00 -> 1
-ddcms613 comparesig 12.1234 12.000 -> 1
-ddcms614 comparesig 12.1234 12.0000 -> 1
-ddcms615 comparesig 12.1234 12.00000 -> 1
-ddcms616 comparesig 12.1234 12.000000 -> 1
-ddcms617 comparesig 12.1234 12.0000000 -> 1
-ddcms618 comparesig 12.1234 12.00000000 -> 1
-ddcms619 comparesig 12.1234 12.000000000 -> 1
-ddcms620 comparesig -12 -12.2345 -> 1
-ddcms621 comparesig -12.0 -12.2345 -> 1
-ddcms622 comparesig -12.00 -12.2345 -> 1
-ddcms623 comparesig -12.000 -12.2345 -> 1
-ddcms624 comparesig -12.0000 -12.2345 -> 1
-ddcms625 comparesig -12.00000 -12.2345 -> 1
-ddcms626 comparesig -12.000000 -12.2345 -> 1
-ddcms627 comparesig -12.0000000 -12.2345 -> 1
-ddcms628 comparesig -12.00000000 -12.2345 -> 1
-ddcms629 comparesig -12.000000000 -12.2345 -> 1
-ddcms630 comparesig -12.1234 -12 -> -1
-ddcms631 comparesig -12.1234 -12.0 -> -1
-ddcms632 comparesig -12.1234 -12.00 -> -1
-ddcms633 comparesig -12.1234 -12.000 -> -1
-ddcms634 comparesig -12.1234 -12.0000 -> -1
-ddcms635 comparesig -12.1234 -12.00000 -> -1
-ddcms636 comparesig -12.1234 -12.000000 -> -1
-ddcms637 comparesig -12.1234 -12.0000000 -> -1
-ddcms638 comparesig -12.1234 -12.00000000 -> -1
-ddcms639 comparesig -12.1234 -12.000000000 -> -1
-
--- extended zeros
-ddcms640 comparesig 0 0 -> 0
-ddcms641 comparesig 0 -0 -> 0
-ddcms642 comparesig 0 -0.0 -> 0
-ddcms643 comparesig 0 0.0 -> 0
-ddcms644 comparesig -0 0 -> 0
-ddcms645 comparesig -0 -0 -> 0
-ddcms646 comparesig -0 -0.0 -> 0
-ddcms647 comparesig -0 0.0 -> 0
-ddcms648 comparesig 0.0 0 -> 0
-ddcms649 comparesig 0.0 -0 -> 0
-ddcms650 comparesig 0.0 -0.0 -> 0
-ddcms651 comparesig 0.0 0.0 -> 0
-ddcms652 comparesig -0.0 0 -> 0
-ddcms653 comparesig -0.0 -0 -> 0
-ddcms654 comparesig -0.0 -0.0 -> 0
-ddcms655 comparesig -0.0 0.0 -> 0
-
-ddcms656 comparesig -0E1 0.0 -> 0
-ddcms657 comparesig -0E2 0.0 -> 0
-ddcms658 comparesig 0E1 0.0 -> 0
-ddcms659 comparesig 0E2 0.0 -> 0
-ddcms660 comparesig -0E1 0 -> 0
-ddcms661 comparesig -0E2 0 -> 0
-ddcms662 comparesig 0E1 0 -> 0
-ddcms663 comparesig 0E2 0 -> 0
-ddcms664 comparesig -0E1 -0E1 -> 0
-ddcms665 comparesig -0E2 -0E1 -> 0
-ddcms666 comparesig 0E1 -0E1 -> 0
-ddcms667 comparesig 0E2 -0E1 -> 0
-ddcms668 comparesig -0E1 -0E2 -> 0
-ddcms669 comparesig -0E2 -0E2 -> 0
-ddcms670 comparesig 0E1 -0E2 -> 0
-ddcms671 comparesig 0E2 -0E2 -> 0
-ddcms672 comparesig -0E1 0E1 -> 0
-ddcms673 comparesig -0E2 0E1 -> 0
-ddcms674 comparesig 0E1 0E1 -> 0
-ddcms675 comparesig 0E2 0E1 -> 0
-ddcms676 comparesig -0E1 0E2 -> 0
-ddcms677 comparesig -0E2 0E2 -> 0
-ddcms678 comparesig 0E1 0E2 -> 0
-ddcms679 comparesig 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-ddcms680 comparesig 12 12 -> 0
-ddcms681 comparesig 12 12.0 -> 0
-ddcms682 comparesig 12 12.00 -> 0
-ddcms683 comparesig 12 12.000 -> 0
-ddcms684 comparesig 12 12.0000 -> 0
-ddcms685 comparesig 12 12.00000 -> 0
-ddcms686 comparesig 12 12.000000 -> 0
-ddcms687 comparesig 12 12.0000000 -> 0
-ddcms688 comparesig 12 12.00000000 -> 0
-ddcms689 comparesig 12 12.000000000 -> 0
-ddcms690 comparesig 12 12 -> 0
-ddcms691 comparesig 12.0 12 -> 0
-ddcms692 comparesig 12.00 12 -> 0
-ddcms693 comparesig 12.000 12 -> 0
-ddcms694 comparesig 12.0000 12 -> 0
-ddcms695 comparesig 12.00000 12 -> 0
-ddcms696 comparesig 12.000000 12 -> 0
-ddcms697 comparesig 12.0000000 12 -> 0
-ddcms698 comparesig 12.00000000 12 -> 0
-ddcms699 comparesig 12.000000000 12 -> 0
-
--- first, second, & last digit
-ddcms700 comparesig 1234567890123456 1234567890123455 -> 1
-ddcms701 comparesig 1234567890123456 1234567890123456 -> 0
-ddcms702 comparesig 1234567890123456 1234567890123457 -> -1
-ddcms703 comparesig 1234567890123456 0234567890123456 -> 1
-ddcms704 comparesig 1234567890123456 1234567890123456 -> 0
-ddcms705 comparesig 1234567890123456 2234567890123456 -> -1
-ddcms706 comparesig 1134567890123456 1034567890123456 -> 1
-ddcms707 comparesig 1134567890123456 1134567890123456 -> 0
-ddcms708 comparesig 1134567890123456 1234567890123456 -> -1
-
--- miscellaneous
-ddcms721 comparesig 12345678000 1 -> 1
-ddcms722 comparesig 1 12345678000 -> -1
-ddcms723 comparesig 1234567800 1 -> 1
-ddcms724 comparesig 1 1234567800 -> -1
-ddcms725 comparesig 1234567890 1 -> 1
-ddcms726 comparesig 1 1234567890 -> -1
-ddcms727 comparesig 1234567891 1 -> 1
-ddcms728 comparesig 1 1234567891 -> -1
-ddcms729 comparesig 12345678901 1 -> 1
-ddcms730 comparesig 1 12345678901 -> -1
-ddcms731 comparesig 1234567896 1 -> 1
-ddcms732 comparesig 1 1234567896 -> -1
-
--- residue cases at lower precision
-ddcms740 comparesig 1 0.9999999 -> 1
-ddcms741 comparesig 1 0.999999 -> 1
-ddcms742 comparesig 1 0.99999 -> 1
-ddcms743 comparesig 1 1.0000 -> 0
-ddcms744 comparesig 1 1.00001 -> -1
-ddcms745 comparesig 1 1.000001 -> -1
-ddcms746 comparesig 1 1.0000001 -> -1
-ddcms750 comparesig 0.9999999 1 -> -1
-ddcms751 comparesig 0.999999 1 -> -1
-ddcms752 comparesig 0.99999 1 -> -1
-ddcms753 comparesig 1.0000 1 -> 0
-ddcms754 comparesig 1.00001 1 -> 1
-ddcms755 comparesig 1.000001 1 -> 1
-ddcms756 comparesig 1.0000001 1 -> 1
-
--- Specials
-ddcms780 comparesig Inf -Inf -> 1
-ddcms781 comparesig Inf -1000 -> 1
-ddcms782 comparesig Inf -1 -> 1
-ddcms783 comparesig Inf -0 -> 1
-ddcms784 comparesig Inf 0 -> 1
-ddcms785 comparesig Inf 1 -> 1
-ddcms786 comparesig Inf 1000 -> 1
-ddcms787 comparesig Inf Inf -> 0
-ddcms788 comparesig -1000 Inf -> -1
-ddcms789 comparesig -Inf Inf -> -1
-ddcms790 comparesig -1 Inf -> -1
-ddcms791 comparesig -0 Inf -> -1
-ddcms792 comparesig 0 Inf -> -1
-ddcms793 comparesig 1 Inf -> -1
-ddcms794 comparesig 1000 Inf -> -1
-ddcms795 comparesig Inf Inf -> 0
-
-ddcms800 comparesig -Inf -Inf -> 0
-ddcms801 comparesig -Inf -1000 -> -1
-ddcms802 comparesig -Inf -1 -> -1
-ddcms803 comparesig -Inf -0 -> -1
-ddcms804 comparesig -Inf 0 -> -1
-ddcms805 comparesig -Inf 1 -> -1
-ddcms806 comparesig -Inf 1000 -> -1
-ddcms807 comparesig -Inf Inf -> -1
-ddcms808 comparesig -Inf -Inf -> 0
-ddcms809 comparesig -1000 -Inf -> 1
-ddcms810 comparesig -1 -Inf -> 1
-ddcms811 comparesig -0 -Inf -> 1
-ddcms812 comparesig 0 -Inf -> 1
-ddcms813 comparesig 1 -Inf -> 1
-ddcms814 comparesig 1000 -Inf -> 1
-ddcms815 comparesig Inf -Inf -> 1
-
-ddcms821 comparesig NaN -Inf -> NaN Invalid_operation
-ddcms822 comparesig NaN -1000 -> NaN Invalid_operation
-ddcms823 comparesig NaN -1 -> NaN Invalid_operation
-ddcms824 comparesig NaN -0 -> NaN Invalid_operation
-ddcms825 comparesig NaN 0 -> NaN Invalid_operation
-ddcms826 comparesig NaN 1 -> NaN Invalid_operation
-ddcms827 comparesig NaN 1000 -> NaN Invalid_operation
-ddcms828 comparesig NaN Inf -> NaN Invalid_operation
-ddcms829 comparesig NaN NaN -> NaN Invalid_operation
-ddcms830 comparesig -Inf NaN -> NaN Invalid_operation
-ddcms831 comparesig -1000 NaN -> NaN Invalid_operation
-ddcms832 comparesig -1 NaN -> NaN Invalid_operation
-ddcms833 comparesig -0 NaN -> NaN Invalid_operation
-ddcms834 comparesig 0 NaN -> NaN Invalid_operation
-ddcms835 comparesig 1 NaN -> NaN Invalid_operation
-ddcms836 comparesig 1000 NaN -> NaN Invalid_operation
-ddcms837 comparesig Inf NaN -> NaN Invalid_operation
-ddcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
-ddcms839 comparesig +NaN -NaN -> NaN Invalid_operation
-ddcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
-
-ddcms841 comparesig sNaN -Inf -> NaN Invalid_operation
-ddcms842 comparesig sNaN -1000 -> NaN Invalid_operation
-ddcms843 comparesig sNaN -1 -> NaN Invalid_operation
-ddcms844 comparesig sNaN -0 -> NaN Invalid_operation
-ddcms845 comparesig sNaN 0 -> NaN Invalid_operation
-ddcms846 comparesig sNaN 1 -> NaN Invalid_operation
-ddcms847 comparesig sNaN 1000 -> NaN Invalid_operation
-ddcms848 comparesig sNaN NaN -> NaN Invalid_operation
-ddcms849 comparesig sNaN sNaN -> NaN Invalid_operation
-ddcms850 comparesig NaN sNaN -> NaN Invalid_operation
-ddcms851 comparesig -Inf sNaN -> NaN Invalid_operation
-ddcms852 comparesig -1000 sNaN -> NaN Invalid_operation
-ddcms853 comparesig -1 sNaN -> NaN Invalid_operation
-ddcms854 comparesig -0 sNaN -> NaN Invalid_operation
-ddcms855 comparesig 0 sNaN -> NaN Invalid_operation
-ddcms856 comparesig 1 sNaN -> NaN Invalid_operation
-ddcms857 comparesig 1000 sNaN -> NaN Invalid_operation
-ddcms858 comparesig Inf sNaN -> NaN Invalid_operation
-ddcms859 comparesig NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
-ddcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
-ddcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
-ddcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
-ddcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
-ddcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
-ddcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
-ddcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
-ddcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
-ddcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
-ddcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
-
-ddcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
-ddcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
-ddcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
-ddcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
-ddcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
-ddcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
-ddcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
-ddcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
-ddcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- wide range
-ddcms880 comparesig +1.23456789012345E-0 9E+384 -> -1
-ddcms881 comparesig 9E+384 +1.23456789012345E-0 -> 1
-ddcms882 comparesig +0.100 9E-383 -> 1
-ddcms883 comparesig 9E-383 +0.100 -> -1
-ddcms885 comparesig -1.23456789012345E-0 9E+384 -> -1
-ddcms886 comparesig 9E+384 -1.23456789012345E-0 -> 1
-ddcms887 comparesig -0.100 9E-383 -> -1
-ddcms888 comparesig 9E-383 -0.100 -> 1
-
--- signs
-ddcms901 comparesig 1e+77 1e+11 -> 1
-ddcms902 comparesig 1e+77 -1e+11 -> 1
-ddcms903 comparesig -1e+77 1e+11 -> -1
-ddcms904 comparesig -1e+77 -1e+11 -> -1
-ddcms905 comparesig 1e-77 1e-11 -> -1
-ddcms906 comparesig 1e-77 -1e-11 -> 1
-ddcms907 comparesig -1e-77 1e-11 -> -1
-ddcms908 comparesig -1e-77 -1e-11 -> 1
-
--- Null tests
-ddcms990 comparesig 10 # -> NaN Invalid_operation
-ddcms991 comparesig # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddCompareSig.decTest -- decDouble comparison; all NaNs signal --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddcms001 comparesig -2 -2 -> 0
+ddcms002 comparesig -2 -1 -> -1
+ddcms003 comparesig -2 0 -> -1
+ddcms004 comparesig -2 1 -> -1
+ddcms005 comparesig -2 2 -> -1
+ddcms006 comparesig -1 -2 -> 1
+ddcms007 comparesig -1 -1 -> 0
+ddcms008 comparesig -1 0 -> -1
+ddcms009 comparesig -1 1 -> -1
+ddcms010 comparesig -1 2 -> -1
+ddcms011 comparesig 0 -2 -> 1
+ddcms012 comparesig 0 -1 -> 1
+ddcms013 comparesig 0 0 -> 0
+ddcms014 comparesig 0 1 -> -1
+ddcms015 comparesig 0 2 -> -1
+ddcms016 comparesig 1 -2 -> 1
+ddcms017 comparesig 1 -1 -> 1
+ddcms018 comparesig 1 0 -> 1
+ddcms019 comparesig 1 1 -> 0
+ddcms020 comparesig 1 2 -> -1
+ddcms021 comparesig 2 -2 -> 1
+ddcms022 comparesig 2 -1 -> 1
+ddcms023 comparesig 2 0 -> 1
+ddcms025 comparesig 2 1 -> 1
+ddcms026 comparesig 2 2 -> 0
+
+ddcms031 comparesig -20 -20 -> 0
+ddcms032 comparesig -20 -10 -> -1
+ddcms033 comparesig -20 00 -> -1
+ddcms034 comparesig -20 10 -> -1
+ddcms035 comparesig -20 20 -> -1
+ddcms036 comparesig -10 -20 -> 1
+ddcms037 comparesig -10 -10 -> 0
+ddcms038 comparesig -10 00 -> -1
+ddcms039 comparesig -10 10 -> -1
+ddcms040 comparesig -10 20 -> -1
+ddcms041 comparesig 00 -20 -> 1
+ddcms042 comparesig 00 -10 -> 1
+ddcms043 comparesig 00 00 -> 0
+ddcms044 comparesig 00 10 -> -1
+ddcms045 comparesig 00 20 -> -1
+ddcms046 comparesig 10 -20 -> 1
+ddcms047 comparesig 10 -10 -> 1
+ddcms048 comparesig 10 00 -> 1
+ddcms049 comparesig 10 10 -> 0
+ddcms050 comparesig 10 20 -> -1
+ddcms051 comparesig 20 -20 -> 1
+ddcms052 comparesig 20 -10 -> 1
+ddcms053 comparesig 20 00 -> 1
+ddcms055 comparesig 20 10 -> 1
+ddcms056 comparesig 20 20 -> 0
+
+ddcms061 comparesig -2.0 -2.0 -> 0
+ddcms062 comparesig -2.0 -1.0 -> -1
+ddcms063 comparesig -2.0 0.0 -> -1
+ddcms064 comparesig -2.0 1.0 -> -1
+ddcms065 comparesig -2.0 2.0 -> -1
+ddcms066 comparesig -1.0 -2.0 -> 1
+ddcms067 comparesig -1.0 -1.0 -> 0
+ddcms068 comparesig -1.0 0.0 -> -1
+ddcms069 comparesig -1.0 1.0 -> -1
+ddcms070 comparesig -1.0 2.0 -> -1
+ddcms071 comparesig 0.0 -2.0 -> 1
+ddcms072 comparesig 0.0 -1.0 -> 1
+ddcms073 comparesig 0.0 0.0 -> 0
+ddcms074 comparesig 0.0 1.0 -> -1
+ddcms075 comparesig 0.0 2.0 -> -1
+ddcms076 comparesig 1.0 -2.0 -> 1
+ddcms077 comparesig 1.0 -1.0 -> 1
+ddcms078 comparesig 1.0 0.0 -> 1
+ddcms079 comparesig 1.0 1.0 -> 0
+ddcms080 comparesig 1.0 2.0 -> -1
+ddcms081 comparesig 2.0 -2.0 -> 1
+ddcms082 comparesig 2.0 -1.0 -> 1
+ddcms083 comparesig 2.0 0.0 -> 1
+ddcms085 comparesig 2.0 1.0 -> 1
+ddcms086 comparesig 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+ddcms090 comparesig 9.999999999999999E+384 9.999999999999999E+384 -> 0
+ddcms091 comparesig -9.999999999999999E+384 9.999999999999999E+384 -> -1
+ddcms092 comparesig 9.999999999999999E+384 -9.999999999999999E+384 -> 1
+ddcms093 comparesig -9.999999999999999E+384 -9.999999999999999E+384 -> 0
+
+-- some differing length/exponent cases
+ddcms100 comparesig 7.0 7.0 -> 0
+ddcms101 comparesig 7.0 7 -> 0
+ddcms102 comparesig 7 7.0 -> 0
+ddcms103 comparesig 7E+0 7.0 -> 0
+ddcms104 comparesig 70E-1 7.0 -> 0
+ddcms105 comparesig 0.7E+1 7 -> 0
+ddcms106 comparesig 70E-1 7 -> 0
+ddcms107 comparesig 7.0 7E+0 -> 0
+ddcms108 comparesig 7.0 70E-1 -> 0
+ddcms109 comparesig 7 0.7E+1 -> 0
+ddcms110 comparesig 7 70E-1 -> 0
+
+ddcms120 comparesig 8.0 7.0 -> 1
+ddcms121 comparesig 8.0 7 -> 1
+ddcms122 comparesig 8 7.0 -> 1
+ddcms123 comparesig 8E+0 7.0 -> 1
+ddcms124 comparesig 80E-1 7.0 -> 1
+ddcms125 comparesig 0.8E+1 7 -> 1
+ddcms126 comparesig 80E-1 7 -> 1
+ddcms127 comparesig 8.0 7E+0 -> 1
+ddcms128 comparesig 8.0 70E-1 -> 1
+ddcms129 comparesig 8 0.7E+1 -> 1
+ddcms130 comparesig 8 70E-1 -> 1
+
+ddcms140 comparesig 8.0 9.0 -> -1
+ddcms141 comparesig 8.0 9 -> -1
+ddcms142 comparesig 8 9.0 -> -1
+ddcms143 comparesig 8E+0 9.0 -> -1
+ddcms144 comparesig 80E-1 9.0 -> -1
+ddcms145 comparesig 0.8E+1 9 -> -1
+ddcms146 comparesig 80E-1 9 -> -1
+ddcms147 comparesig 8.0 9E+0 -> -1
+ddcms148 comparesig 8.0 90E-1 -> -1
+ddcms149 comparesig 8 0.9E+1 -> -1
+ddcms150 comparesig 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ddcms200 comparesig -7.0 7.0 -> -1
+ddcms201 comparesig -7.0 7 -> -1
+ddcms202 comparesig -7 7.0 -> -1
+ddcms203 comparesig -7E+0 7.0 -> -1
+ddcms204 comparesig -70E-1 7.0 -> -1
+ddcms205 comparesig -0.7E+1 7 -> -1
+ddcms206 comparesig -70E-1 7 -> -1
+ddcms207 comparesig -7.0 7E+0 -> -1
+ddcms208 comparesig -7.0 70E-1 -> -1
+ddcms209 comparesig -7 0.7E+1 -> -1
+ddcms210 comparesig -7 70E-1 -> -1
+
+ddcms220 comparesig -8.0 7.0 -> -1
+ddcms221 comparesig -8.0 7 -> -1
+ddcms222 comparesig -8 7.0 -> -1
+ddcms223 comparesig -8E+0 7.0 -> -1
+ddcms224 comparesig -80E-1 7.0 -> -1
+ddcms225 comparesig -0.8E+1 7 -> -1
+ddcms226 comparesig -80E-1 7 -> -1
+ddcms227 comparesig -8.0 7E+0 -> -1
+ddcms228 comparesig -8.0 70E-1 -> -1
+ddcms229 comparesig -8 0.7E+1 -> -1
+ddcms230 comparesig -8 70E-1 -> -1
+
+ddcms240 comparesig -8.0 9.0 -> -1
+ddcms241 comparesig -8.0 9 -> -1
+ddcms242 comparesig -8 9.0 -> -1
+ddcms243 comparesig -8E+0 9.0 -> -1
+ddcms244 comparesig -80E-1 9.0 -> -1
+ddcms245 comparesig -0.8E+1 9 -> -1
+ddcms246 comparesig -80E-1 9 -> -1
+ddcms247 comparesig -8.0 9E+0 -> -1
+ddcms248 comparesig -8.0 90E-1 -> -1
+ddcms249 comparesig -8 0.9E+1 -> -1
+ddcms250 comparesig -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ddcms300 comparesig 7.0 -7.0 -> 1
+ddcms301 comparesig 7.0 -7 -> 1
+ddcms302 comparesig 7 -7.0 -> 1
+ddcms303 comparesig 7E+0 -7.0 -> 1
+ddcms304 comparesig 70E-1 -7.0 -> 1
+ddcms305 comparesig .7E+1 -7 -> 1
+ddcms306 comparesig 70E-1 -7 -> 1
+ddcms307 comparesig 7.0 -7E+0 -> 1
+ddcms308 comparesig 7.0 -70E-1 -> 1
+ddcms309 comparesig 7 -.7E+1 -> 1
+ddcms310 comparesig 7 -70E-1 -> 1
+
+ddcms320 comparesig 8.0 -7.0 -> 1
+ddcms321 comparesig 8.0 -7 -> 1
+ddcms322 comparesig 8 -7.0 -> 1
+ddcms323 comparesig 8E+0 -7.0 -> 1
+ddcms324 comparesig 80E-1 -7.0 -> 1
+ddcms325 comparesig .8E+1 -7 -> 1
+ddcms326 comparesig 80E-1 -7 -> 1
+ddcms327 comparesig 8.0 -7E+0 -> 1
+ddcms328 comparesig 8.0 -70E-1 -> 1
+ddcms329 comparesig 8 -.7E+1 -> 1
+ddcms330 comparesig 8 -70E-1 -> 1
+
+ddcms340 comparesig 8.0 -9.0 -> 1
+ddcms341 comparesig 8.0 -9 -> 1
+ddcms342 comparesig 8 -9.0 -> 1
+ddcms343 comparesig 8E+0 -9.0 -> 1
+ddcms344 comparesig 80E-1 -9.0 -> 1
+ddcms345 comparesig .8E+1 -9 -> 1
+ddcms346 comparesig 80E-1 -9 -> 1
+ddcms347 comparesig 8.0 -9E+0 -> 1
+ddcms348 comparesig 8.0 -90E-1 -> 1
+ddcms349 comparesig 8 -.9E+1 -> 1
+ddcms350 comparesig 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+ddcms400 comparesig -7.0 -7.0 -> 0
+ddcms401 comparesig -7.0 -7 -> 0
+ddcms402 comparesig -7 -7.0 -> 0
+ddcms403 comparesig -7E+0 -7.0 -> 0
+ddcms404 comparesig -70E-1 -7.0 -> 0
+ddcms405 comparesig -.7E+1 -7 -> 0
+ddcms406 comparesig -70E-1 -7 -> 0
+ddcms407 comparesig -7.0 -7E+0 -> 0
+ddcms408 comparesig -7.0 -70E-1 -> 0
+ddcms409 comparesig -7 -.7E+1 -> 0
+ddcms410 comparesig -7 -70E-1 -> 0
+
+ddcms420 comparesig -8.0 -7.0 -> -1
+ddcms421 comparesig -8.0 -7 -> -1
+ddcms422 comparesig -8 -7.0 -> -1
+ddcms423 comparesig -8E+0 -7.0 -> -1
+ddcms424 comparesig -80E-1 -7.0 -> -1
+ddcms425 comparesig -.8E+1 -7 -> -1
+ddcms426 comparesig -80E-1 -7 -> -1
+ddcms427 comparesig -8.0 -7E+0 -> -1
+ddcms428 comparesig -8.0 -70E-1 -> -1
+ddcms429 comparesig -8 -.7E+1 -> -1
+ddcms430 comparesig -8 -70E-1 -> -1
+
+ddcms440 comparesig -8.0 -9.0 -> 1
+ddcms441 comparesig -8.0 -9 -> 1
+ddcms442 comparesig -8 -9.0 -> 1
+ddcms443 comparesig -8E+0 -9.0 -> 1
+ddcms444 comparesig -80E-1 -9.0 -> 1
+ddcms445 comparesig -.8E+1 -9 -> 1
+ddcms446 comparesig -80E-1 -9 -> 1
+ddcms447 comparesig -8.0 -9E+0 -> 1
+ddcms448 comparesig -8.0 -90E-1 -> 1
+ddcms449 comparesig -8 -.9E+1 -> 1
+ddcms450 comparesig -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+ddcms473 comparesig 123.4560000000000E-89 123.456E-89 -> 0
+ddcms474 comparesig 123.456000000000E+89 123.456E+89 -> 0
+ddcms475 comparesig 123.45600000000E-89 123.456E-89 -> 0
+ddcms476 comparesig 123.4560000000E+89 123.456E+89 -> 0
+ddcms477 comparesig 123.456000000E-89 123.456E-89 -> 0
+ddcms478 comparesig 123.45600000E+89 123.456E+89 -> 0
+ddcms479 comparesig 123.4560000E-89 123.456E-89 -> 0
+ddcms480 comparesig 123.456000E+89 123.456E+89 -> 0
+ddcms481 comparesig 123.45600E-89 123.456E-89 -> 0
+ddcms482 comparesig 123.4560E+89 123.456E+89 -> 0
+ddcms483 comparesig 123.456E-89 123.456E-89 -> 0
+ddcms487 comparesig 123.456E+89 123.4560000000000E+89 -> 0
+ddcms488 comparesig 123.456E-89 123.456000000000E-89 -> 0
+ddcms489 comparesig 123.456E+89 123.45600000000E+89 -> 0
+ddcms490 comparesig 123.456E-89 123.4560000000E-89 -> 0
+ddcms491 comparesig 123.456E+89 123.456000000E+89 -> 0
+ddcms492 comparesig 123.456E-89 123.45600000E-89 -> 0
+ddcms493 comparesig 123.456E+89 123.4560000E+89 -> 0
+ddcms494 comparesig 123.456E-89 123.456000E-89 -> 0
+ddcms495 comparesig 123.456E+89 123.45600E+89 -> 0
+ddcms496 comparesig 123.456E-89 123.4560E-89 -> 0
+ddcms497 comparesig 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+ddcms500 comparesig 1 1E-15 -> 1
+ddcms501 comparesig 1 1E-14 -> 1
+ddcms502 comparesig 1 1E-13 -> 1
+ddcms503 comparesig 1 1E-12 -> 1
+ddcms504 comparesig 1 1E-11 -> 1
+ddcms505 comparesig 1 1E-10 -> 1
+ddcms506 comparesig 1 1E-9 -> 1
+ddcms507 comparesig 1 1E-8 -> 1
+ddcms508 comparesig 1 1E-7 -> 1
+ddcms509 comparesig 1 1E-6 -> 1
+ddcms510 comparesig 1 1E-5 -> 1
+ddcms511 comparesig 1 1E-4 -> 1
+ddcms512 comparesig 1 1E-3 -> 1
+ddcms513 comparesig 1 1E-2 -> 1
+ddcms514 comparesig 1 1E-1 -> 1
+ddcms515 comparesig 1 1E-0 -> 0
+ddcms516 comparesig 1 1E+1 -> -1
+ddcms517 comparesig 1 1E+2 -> -1
+ddcms518 comparesig 1 1E+3 -> -1
+ddcms519 comparesig 1 1E+4 -> -1
+ddcms521 comparesig 1 1E+5 -> -1
+ddcms522 comparesig 1 1E+6 -> -1
+ddcms523 comparesig 1 1E+7 -> -1
+ddcms524 comparesig 1 1E+8 -> -1
+ddcms525 comparesig 1 1E+9 -> -1
+ddcms526 comparesig 1 1E+10 -> -1
+ddcms527 comparesig 1 1E+11 -> -1
+ddcms528 comparesig 1 1E+12 -> -1
+ddcms529 comparesig 1 1E+13 -> -1
+ddcms530 comparesig 1 1E+14 -> -1
+ddcms531 comparesig 1 1E+15 -> -1
+-- LR swap
+ddcms540 comparesig 1E-15 1 -> -1
+ddcms541 comparesig 1E-14 1 -> -1
+ddcms542 comparesig 1E-13 1 -> -1
+ddcms543 comparesig 1E-12 1 -> -1
+ddcms544 comparesig 1E-11 1 -> -1
+ddcms545 comparesig 1E-10 1 -> -1
+ddcms546 comparesig 1E-9 1 -> -1
+ddcms547 comparesig 1E-8 1 -> -1
+ddcms548 comparesig 1E-7 1 -> -1
+ddcms549 comparesig 1E-6 1 -> -1
+ddcms550 comparesig 1E-5 1 -> -1
+ddcms551 comparesig 1E-4 1 -> -1
+ddcms552 comparesig 1E-3 1 -> -1
+ddcms553 comparesig 1E-2 1 -> -1
+ddcms554 comparesig 1E-1 1 -> -1
+ddcms555 comparesig 1E-0 1 -> 0
+ddcms556 comparesig 1E+1 1 -> 1
+ddcms557 comparesig 1E+2 1 -> 1
+ddcms558 comparesig 1E+3 1 -> 1
+ddcms559 comparesig 1E+4 1 -> 1
+ddcms561 comparesig 1E+5 1 -> 1
+ddcms562 comparesig 1E+6 1 -> 1
+ddcms563 comparesig 1E+7 1 -> 1
+ddcms564 comparesig 1E+8 1 -> 1
+ddcms565 comparesig 1E+9 1 -> 1
+ddcms566 comparesig 1E+10 1 -> 1
+ddcms567 comparesig 1E+11 1 -> 1
+ddcms568 comparesig 1E+12 1 -> 1
+ddcms569 comparesig 1E+13 1 -> 1
+ddcms570 comparesig 1E+14 1 -> 1
+ddcms571 comparesig 1E+15 1 -> 1
+-- similar with a useful coefficient, one side only
+ddcms580 comparesig 0.000000987654321 1E-15 -> 1
+ddcms581 comparesig 0.000000987654321 1E-14 -> 1
+ddcms582 comparesig 0.000000987654321 1E-13 -> 1
+ddcms583 comparesig 0.000000987654321 1E-12 -> 1
+ddcms584 comparesig 0.000000987654321 1E-11 -> 1
+ddcms585 comparesig 0.000000987654321 1E-10 -> 1
+ddcms586 comparesig 0.000000987654321 1E-9 -> 1
+ddcms587 comparesig 0.000000987654321 1E-8 -> 1
+ddcms588 comparesig 0.000000987654321 1E-7 -> 1
+ddcms589 comparesig 0.000000987654321 1E-6 -> -1
+ddcms590 comparesig 0.000000987654321 1E-5 -> -1
+ddcms591 comparesig 0.000000987654321 1E-4 -> -1
+ddcms592 comparesig 0.000000987654321 1E-3 -> -1
+ddcms593 comparesig 0.000000987654321 1E-2 -> -1
+ddcms594 comparesig 0.000000987654321 1E-1 -> -1
+ddcms595 comparesig 0.000000987654321 1E-0 -> -1
+ddcms596 comparesig 0.000000987654321 1E+1 -> -1
+ddcms597 comparesig 0.000000987654321 1E+2 -> -1
+ddcms598 comparesig 0.000000987654321 1E+3 -> -1
+ddcms599 comparesig 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+ddcms600 comparesig 12 12.2345 -> -1
+ddcms601 comparesig 12.0 12.2345 -> -1
+ddcms602 comparesig 12.00 12.2345 -> -1
+ddcms603 comparesig 12.000 12.2345 -> -1
+ddcms604 comparesig 12.0000 12.2345 -> -1
+ddcms605 comparesig 12.00000 12.2345 -> -1
+ddcms606 comparesig 12.000000 12.2345 -> -1
+ddcms607 comparesig 12.0000000 12.2345 -> -1
+ddcms608 comparesig 12.00000000 12.2345 -> -1
+ddcms609 comparesig 12.000000000 12.2345 -> -1
+ddcms610 comparesig 12.1234 12 -> 1
+ddcms611 comparesig 12.1234 12.0 -> 1
+ddcms612 comparesig 12.1234 12.00 -> 1
+ddcms613 comparesig 12.1234 12.000 -> 1
+ddcms614 comparesig 12.1234 12.0000 -> 1
+ddcms615 comparesig 12.1234 12.00000 -> 1
+ddcms616 comparesig 12.1234 12.000000 -> 1
+ddcms617 comparesig 12.1234 12.0000000 -> 1
+ddcms618 comparesig 12.1234 12.00000000 -> 1
+ddcms619 comparesig 12.1234 12.000000000 -> 1
+ddcms620 comparesig -12 -12.2345 -> 1
+ddcms621 comparesig -12.0 -12.2345 -> 1
+ddcms622 comparesig -12.00 -12.2345 -> 1
+ddcms623 comparesig -12.000 -12.2345 -> 1
+ddcms624 comparesig -12.0000 -12.2345 -> 1
+ddcms625 comparesig -12.00000 -12.2345 -> 1
+ddcms626 comparesig -12.000000 -12.2345 -> 1
+ddcms627 comparesig -12.0000000 -12.2345 -> 1
+ddcms628 comparesig -12.00000000 -12.2345 -> 1
+ddcms629 comparesig -12.000000000 -12.2345 -> 1
+ddcms630 comparesig -12.1234 -12 -> -1
+ddcms631 comparesig -12.1234 -12.0 -> -1
+ddcms632 comparesig -12.1234 -12.00 -> -1
+ddcms633 comparesig -12.1234 -12.000 -> -1
+ddcms634 comparesig -12.1234 -12.0000 -> -1
+ddcms635 comparesig -12.1234 -12.00000 -> -1
+ddcms636 comparesig -12.1234 -12.000000 -> -1
+ddcms637 comparesig -12.1234 -12.0000000 -> -1
+ddcms638 comparesig -12.1234 -12.00000000 -> -1
+ddcms639 comparesig -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+ddcms640 comparesig 0 0 -> 0
+ddcms641 comparesig 0 -0 -> 0
+ddcms642 comparesig 0 -0.0 -> 0
+ddcms643 comparesig 0 0.0 -> 0
+ddcms644 comparesig -0 0 -> 0
+ddcms645 comparesig -0 -0 -> 0
+ddcms646 comparesig -0 -0.0 -> 0
+ddcms647 comparesig -0 0.0 -> 0
+ddcms648 comparesig 0.0 0 -> 0
+ddcms649 comparesig 0.0 -0 -> 0
+ddcms650 comparesig 0.0 -0.0 -> 0
+ddcms651 comparesig 0.0 0.0 -> 0
+ddcms652 comparesig -0.0 0 -> 0
+ddcms653 comparesig -0.0 -0 -> 0
+ddcms654 comparesig -0.0 -0.0 -> 0
+ddcms655 comparesig -0.0 0.0 -> 0
+
+ddcms656 comparesig -0E1 0.0 -> 0
+ddcms657 comparesig -0E2 0.0 -> 0
+ddcms658 comparesig 0E1 0.0 -> 0
+ddcms659 comparesig 0E2 0.0 -> 0
+ddcms660 comparesig -0E1 0 -> 0
+ddcms661 comparesig -0E2 0 -> 0
+ddcms662 comparesig 0E1 0 -> 0
+ddcms663 comparesig 0E2 0 -> 0
+ddcms664 comparesig -0E1 -0E1 -> 0
+ddcms665 comparesig -0E2 -0E1 -> 0
+ddcms666 comparesig 0E1 -0E1 -> 0
+ddcms667 comparesig 0E2 -0E1 -> 0
+ddcms668 comparesig -0E1 -0E2 -> 0
+ddcms669 comparesig -0E2 -0E2 -> 0
+ddcms670 comparesig 0E1 -0E2 -> 0
+ddcms671 comparesig 0E2 -0E2 -> 0
+ddcms672 comparesig -0E1 0E1 -> 0
+ddcms673 comparesig -0E2 0E1 -> 0
+ddcms674 comparesig 0E1 0E1 -> 0
+ddcms675 comparesig 0E2 0E1 -> 0
+ddcms676 comparesig -0E1 0E2 -> 0
+ddcms677 comparesig -0E2 0E2 -> 0
+ddcms678 comparesig 0E1 0E2 -> 0
+ddcms679 comparesig 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+ddcms680 comparesig 12 12 -> 0
+ddcms681 comparesig 12 12.0 -> 0
+ddcms682 comparesig 12 12.00 -> 0
+ddcms683 comparesig 12 12.000 -> 0
+ddcms684 comparesig 12 12.0000 -> 0
+ddcms685 comparesig 12 12.00000 -> 0
+ddcms686 comparesig 12 12.000000 -> 0
+ddcms687 comparesig 12 12.0000000 -> 0
+ddcms688 comparesig 12 12.00000000 -> 0
+ddcms689 comparesig 12 12.000000000 -> 0
+ddcms690 comparesig 12 12 -> 0
+ddcms691 comparesig 12.0 12 -> 0
+ddcms692 comparesig 12.00 12 -> 0
+ddcms693 comparesig 12.000 12 -> 0
+ddcms694 comparesig 12.0000 12 -> 0
+ddcms695 comparesig 12.00000 12 -> 0
+ddcms696 comparesig 12.000000 12 -> 0
+ddcms697 comparesig 12.0000000 12 -> 0
+ddcms698 comparesig 12.00000000 12 -> 0
+ddcms699 comparesig 12.000000000 12 -> 0
+
+-- first, second, & last digit
+ddcms700 comparesig 1234567890123456 1234567890123455 -> 1
+ddcms701 comparesig 1234567890123456 1234567890123456 -> 0
+ddcms702 comparesig 1234567890123456 1234567890123457 -> -1
+ddcms703 comparesig 1234567890123456 0234567890123456 -> 1
+ddcms704 comparesig 1234567890123456 1234567890123456 -> 0
+ddcms705 comparesig 1234567890123456 2234567890123456 -> -1
+ddcms706 comparesig 1134567890123456 1034567890123456 -> 1
+ddcms707 comparesig 1134567890123456 1134567890123456 -> 0
+ddcms708 comparesig 1134567890123456 1234567890123456 -> -1
+
+-- miscellaneous
+ddcms721 comparesig 12345678000 1 -> 1
+ddcms722 comparesig 1 12345678000 -> -1
+ddcms723 comparesig 1234567800 1 -> 1
+ddcms724 comparesig 1 1234567800 -> -1
+ddcms725 comparesig 1234567890 1 -> 1
+ddcms726 comparesig 1 1234567890 -> -1
+ddcms727 comparesig 1234567891 1 -> 1
+ddcms728 comparesig 1 1234567891 -> -1
+ddcms729 comparesig 12345678901 1 -> 1
+ddcms730 comparesig 1 12345678901 -> -1
+ddcms731 comparesig 1234567896 1 -> 1
+ddcms732 comparesig 1 1234567896 -> -1
+
+-- residue cases at lower precision
+ddcms740 comparesig 1 0.9999999 -> 1
+ddcms741 comparesig 1 0.999999 -> 1
+ddcms742 comparesig 1 0.99999 -> 1
+ddcms743 comparesig 1 1.0000 -> 0
+ddcms744 comparesig 1 1.00001 -> -1
+ddcms745 comparesig 1 1.000001 -> -1
+ddcms746 comparesig 1 1.0000001 -> -1
+ddcms750 comparesig 0.9999999 1 -> -1
+ddcms751 comparesig 0.999999 1 -> -1
+ddcms752 comparesig 0.99999 1 -> -1
+ddcms753 comparesig 1.0000 1 -> 0
+ddcms754 comparesig 1.00001 1 -> 1
+ddcms755 comparesig 1.000001 1 -> 1
+ddcms756 comparesig 1.0000001 1 -> 1
+
+-- Specials
+ddcms780 comparesig Inf -Inf -> 1
+ddcms781 comparesig Inf -1000 -> 1
+ddcms782 comparesig Inf -1 -> 1
+ddcms783 comparesig Inf -0 -> 1
+ddcms784 comparesig Inf 0 -> 1
+ddcms785 comparesig Inf 1 -> 1
+ddcms786 comparesig Inf 1000 -> 1
+ddcms787 comparesig Inf Inf -> 0
+ddcms788 comparesig -1000 Inf -> -1
+ddcms789 comparesig -Inf Inf -> -1
+ddcms790 comparesig -1 Inf -> -1
+ddcms791 comparesig -0 Inf -> -1
+ddcms792 comparesig 0 Inf -> -1
+ddcms793 comparesig 1 Inf -> -1
+ddcms794 comparesig 1000 Inf -> -1
+ddcms795 comparesig Inf Inf -> 0
+
+ddcms800 comparesig -Inf -Inf -> 0
+ddcms801 comparesig -Inf -1000 -> -1
+ddcms802 comparesig -Inf -1 -> -1
+ddcms803 comparesig -Inf -0 -> -1
+ddcms804 comparesig -Inf 0 -> -1
+ddcms805 comparesig -Inf 1 -> -1
+ddcms806 comparesig -Inf 1000 -> -1
+ddcms807 comparesig -Inf Inf -> -1
+ddcms808 comparesig -Inf -Inf -> 0
+ddcms809 comparesig -1000 -Inf -> 1
+ddcms810 comparesig -1 -Inf -> 1
+ddcms811 comparesig -0 -Inf -> 1
+ddcms812 comparesig 0 -Inf -> 1
+ddcms813 comparesig 1 -Inf -> 1
+ddcms814 comparesig 1000 -Inf -> 1
+ddcms815 comparesig Inf -Inf -> 1
+
+ddcms821 comparesig NaN -Inf -> NaN Invalid_operation
+ddcms822 comparesig NaN -1000 -> NaN Invalid_operation
+ddcms823 comparesig NaN -1 -> NaN Invalid_operation
+ddcms824 comparesig NaN -0 -> NaN Invalid_operation
+ddcms825 comparesig NaN 0 -> NaN Invalid_operation
+ddcms826 comparesig NaN 1 -> NaN Invalid_operation
+ddcms827 comparesig NaN 1000 -> NaN Invalid_operation
+ddcms828 comparesig NaN Inf -> NaN Invalid_operation
+ddcms829 comparesig NaN NaN -> NaN Invalid_operation
+ddcms830 comparesig -Inf NaN -> NaN Invalid_operation
+ddcms831 comparesig -1000 NaN -> NaN Invalid_operation
+ddcms832 comparesig -1 NaN -> NaN Invalid_operation
+ddcms833 comparesig -0 NaN -> NaN Invalid_operation
+ddcms834 comparesig 0 NaN -> NaN Invalid_operation
+ddcms835 comparesig 1 NaN -> NaN Invalid_operation
+ddcms836 comparesig 1000 NaN -> NaN Invalid_operation
+ddcms837 comparesig Inf NaN -> NaN Invalid_operation
+ddcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
+ddcms839 comparesig +NaN -NaN -> NaN Invalid_operation
+ddcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
+
+ddcms841 comparesig sNaN -Inf -> NaN Invalid_operation
+ddcms842 comparesig sNaN -1000 -> NaN Invalid_operation
+ddcms843 comparesig sNaN -1 -> NaN Invalid_operation
+ddcms844 comparesig sNaN -0 -> NaN Invalid_operation
+ddcms845 comparesig sNaN 0 -> NaN Invalid_operation
+ddcms846 comparesig sNaN 1 -> NaN Invalid_operation
+ddcms847 comparesig sNaN 1000 -> NaN Invalid_operation
+ddcms848 comparesig sNaN NaN -> NaN Invalid_operation
+ddcms849 comparesig sNaN sNaN -> NaN Invalid_operation
+ddcms850 comparesig NaN sNaN -> NaN Invalid_operation
+ddcms851 comparesig -Inf sNaN -> NaN Invalid_operation
+ddcms852 comparesig -1000 sNaN -> NaN Invalid_operation
+ddcms853 comparesig -1 sNaN -> NaN Invalid_operation
+ddcms854 comparesig -0 sNaN -> NaN Invalid_operation
+ddcms855 comparesig 0 sNaN -> NaN Invalid_operation
+ddcms856 comparesig 1 sNaN -> NaN Invalid_operation
+ddcms857 comparesig 1000 sNaN -> NaN Invalid_operation
+ddcms858 comparesig Inf sNaN -> NaN Invalid_operation
+ddcms859 comparesig NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
+ddcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
+ddcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
+ddcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
+ddcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
+ddcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
+ddcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
+ddcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
+ddcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
+ddcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
+ddcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
+
+ddcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
+ddcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
+ddcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
+ddcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
+ddcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
+ddcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
+ddcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
+ddcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
+ddcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- wide range
+ddcms880 comparesig +1.23456789012345E-0 9E+384 -> -1
+ddcms881 comparesig 9E+384 +1.23456789012345E-0 -> 1
+ddcms882 comparesig +0.100 9E-383 -> 1
+ddcms883 comparesig 9E-383 +0.100 -> -1
+ddcms885 comparesig -1.23456789012345E-0 9E+384 -> -1
+ddcms886 comparesig 9E+384 -1.23456789012345E-0 -> 1
+ddcms887 comparesig -0.100 9E-383 -> -1
+ddcms888 comparesig 9E-383 -0.100 -> 1
+
+-- signs
+ddcms901 comparesig 1e+77 1e+11 -> 1
+ddcms902 comparesig 1e+77 -1e+11 -> 1
+ddcms903 comparesig -1e+77 1e+11 -> -1
+ddcms904 comparesig -1e+77 -1e+11 -> -1
+ddcms905 comparesig 1e-77 1e-11 -> -1
+ddcms906 comparesig 1e-77 -1e-11 -> 1
+ddcms907 comparesig -1e-77 1e-11 -> -1
+ddcms908 comparesig -1e-77 -1e-11 -> 1
+
+-- Null tests
+ddcms990 comparesig 10 # -> NaN Invalid_operation
+ddcms991 comparesig # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddCompareTotal.decTest b/Lib/test/decimaltestdata/ddCompareTotal.decTest
index 10c984c7ff..76beed5681 100644
--- a/Lib/test/decimaltestdata/ddCompareTotal.decTest
+++ b/Lib/test/decimaltestdata/ddCompareTotal.decTest
@@ -1,706 +1,706 @@
-------------------------------------------------------------------------
--- ddCompareTotal.decTest -- decDouble comparison using total ordering--
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddcot001 comparetotal -2 -2 -> 0
-ddcot002 comparetotal -2 -1 -> -1
-ddcot003 comparetotal -2 0 -> -1
-ddcot004 comparetotal -2 1 -> -1
-ddcot005 comparetotal -2 2 -> -1
-ddcot006 comparetotal -1 -2 -> 1
-ddcot007 comparetotal -1 -1 -> 0
-ddcot008 comparetotal -1 0 -> -1
-ddcot009 comparetotal -1 1 -> -1
-ddcot010 comparetotal -1 2 -> -1
-ddcot011 comparetotal 0 -2 -> 1
-ddcot012 comparetotal 0 -1 -> 1
-ddcot013 comparetotal 0 0 -> 0
-ddcot014 comparetotal 0 1 -> -1
-ddcot015 comparetotal 0 2 -> -1
-ddcot016 comparetotal 1 -2 -> 1
-ddcot017 comparetotal 1 -1 -> 1
-ddcot018 comparetotal 1 0 -> 1
-ddcot019 comparetotal 1 1 -> 0
-ddcot020 comparetotal 1 2 -> -1
-ddcot021 comparetotal 2 -2 -> 1
-ddcot022 comparetotal 2 -1 -> 1
-ddcot023 comparetotal 2 0 -> 1
-ddcot025 comparetotal 2 1 -> 1
-ddcot026 comparetotal 2 2 -> 0
-
-ddcot031 comparetotal -20 -20 -> 0
-ddcot032 comparetotal -20 -10 -> -1
-ddcot033 comparetotal -20 00 -> -1
-ddcot034 comparetotal -20 10 -> -1
-ddcot035 comparetotal -20 20 -> -1
-ddcot036 comparetotal -10 -20 -> 1
-ddcot037 comparetotal -10 -10 -> 0
-ddcot038 comparetotal -10 00 -> -1
-ddcot039 comparetotal -10 10 -> -1
-ddcot040 comparetotal -10 20 -> -1
-ddcot041 comparetotal 00 -20 -> 1
-ddcot042 comparetotal 00 -10 -> 1
-ddcot043 comparetotal 00 00 -> 0
-ddcot044 comparetotal 00 10 -> -1
-ddcot045 comparetotal 00 20 -> -1
-ddcot046 comparetotal 10 -20 -> 1
-ddcot047 comparetotal 10 -10 -> 1
-ddcot048 comparetotal 10 00 -> 1
-ddcot049 comparetotal 10 10 -> 0
-ddcot050 comparetotal 10 20 -> -1
-ddcot051 comparetotal 20 -20 -> 1
-ddcot052 comparetotal 20 -10 -> 1
-ddcot053 comparetotal 20 00 -> 1
-ddcot055 comparetotal 20 10 -> 1
-ddcot056 comparetotal 20 20 -> 0
-
-ddcot061 comparetotal -2.0 -2.0 -> 0
-ddcot062 comparetotal -2.0 -1.0 -> -1
-ddcot063 comparetotal -2.0 0.0 -> -1
-ddcot064 comparetotal -2.0 1.0 -> -1
-ddcot065 comparetotal -2.0 2.0 -> -1
-ddcot066 comparetotal -1.0 -2.0 -> 1
-ddcot067 comparetotal -1.0 -1.0 -> 0
-ddcot068 comparetotal -1.0 0.0 -> -1
-ddcot069 comparetotal -1.0 1.0 -> -1
-ddcot070 comparetotal -1.0 2.0 -> -1
-ddcot071 comparetotal 0.0 -2.0 -> 1
-ddcot072 comparetotal 0.0 -1.0 -> 1
-ddcot073 comparetotal 0.0 0.0 -> 0
-ddcot074 comparetotal 0.0 1.0 -> -1
-ddcot075 comparetotal 0.0 2.0 -> -1
-ddcot076 comparetotal 1.0 -2.0 -> 1
-ddcot077 comparetotal 1.0 -1.0 -> 1
-ddcot078 comparetotal 1.0 0.0 -> 1
-ddcot079 comparetotal 1.0 1.0 -> 0
-ddcot080 comparetotal 1.0 2.0 -> -1
-ddcot081 comparetotal 2.0 -2.0 -> 1
-ddcot082 comparetotal 2.0 -1.0 -> 1
-ddcot083 comparetotal 2.0 0.0 -> 1
-ddcot085 comparetotal 2.0 1.0 -> 1
-ddcot086 comparetotal 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-ddcot090 comparetotal 9.99999999E+384 9.99999999E+384 -> 0
-ddcot091 comparetotal -9.99999999E+384 9.99999999E+384 -> -1
-ddcot092 comparetotal 9.99999999E+384 -9.99999999E+384 -> 1
-ddcot093 comparetotal -9.99999999E+384 -9.99999999E+384 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-ddcot100 comparetotal 7.0 7.0 -> 0
-ddcot101 comparetotal 7.0 7 -> -1
-ddcot102 comparetotal 7 7.0 -> 1
-ddcot103 comparetotal 7E+0 7.0 -> 1
-ddcot104 comparetotal 70E-1 7.0 -> 0
-ddcot105 comparetotal 0.7E+1 7 -> 0
-ddcot106 comparetotal 70E-1 7 -> -1
-ddcot107 comparetotal 7.0 7E+0 -> -1
-ddcot108 comparetotal 7.0 70E-1 -> 0
-ddcot109 comparetotal 7 0.7E+1 -> 0
-ddcot110 comparetotal 7 70E-1 -> 1
-
-ddcot120 comparetotal 8.0 7.0 -> 1
-ddcot121 comparetotal 8.0 7 -> 1
-ddcot122 comparetotal 8 7.0 -> 1
-ddcot123 comparetotal 8E+0 7.0 -> 1
-ddcot124 comparetotal 80E-1 7.0 -> 1
-ddcot125 comparetotal 0.8E+1 7 -> 1
-ddcot126 comparetotal 80E-1 7 -> 1
-ddcot127 comparetotal 8.0 7E+0 -> 1
-ddcot128 comparetotal 8.0 70E-1 -> 1
-ddcot129 comparetotal 8 0.7E+1 -> 1
-ddcot130 comparetotal 8 70E-1 -> 1
-
-ddcot140 comparetotal 8.0 9.0 -> -1
-ddcot141 comparetotal 8.0 9 -> -1
-ddcot142 comparetotal 8 9.0 -> -1
-ddcot143 comparetotal 8E+0 9.0 -> -1
-ddcot144 comparetotal 80E-1 9.0 -> -1
-ddcot145 comparetotal 0.8E+1 9 -> -1
-ddcot146 comparetotal 80E-1 9 -> -1
-ddcot147 comparetotal 8.0 9E+0 -> -1
-ddcot148 comparetotal 8.0 90E-1 -> -1
-ddcot149 comparetotal 8 0.9E+1 -> -1
-ddcot150 comparetotal 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ddcot200 comparetotal -7.0 7.0 -> -1
-ddcot201 comparetotal -7.0 7 -> -1
-ddcot202 comparetotal -7 7.0 -> -1
-ddcot203 comparetotal -7E+0 7.0 -> -1
-ddcot204 comparetotal -70E-1 7.0 -> -1
-ddcot205 comparetotal -0.7E+1 7 -> -1
-ddcot206 comparetotal -70E-1 7 -> -1
-ddcot207 comparetotal -7.0 7E+0 -> -1
-ddcot208 comparetotal -7.0 70E-1 -> -1
-ddcot209 comparetotal -7 0.7E+1 -> -1
-ddcot210 comparetotal -7 70E-1 -> -1
-
-ddcot220 comparetotal -8.0 7.0 -> -1
-ddcot221 comparetotal -8.0 7 -> -1
-ddcot222 comparetotal -8 7.0 -> -1
-ddcot223 comparetotal -8E+0 7.0 -> -1
-ddcot224 comparetotal -80E-1 7.0 -> -1
-ddcot225 comparetotal -0.8E+1 7 -> -1
-ddcot226 comparetotal -80E-1 7 -> -1
-ddcot227 comparetotal -8.0 7E+0 -> -1
-ddcot228 comparetotal -8.0 70E-1 -> -1
-ddcot229 comparetotal -8 0.7E+1 -> -1
-ddcot230 comparetotal -8 70E-1 -> -1
-
-ddcot240 comparetotal -8.0 9.0 -> -1
-ddcot241 comparetotal -8.0 9 -> -1
-ddcot242 comparetotal -8 9.0 -> -1
-ddcot243 comparetotal -8E+0 9.0 -> -1
-ddcot244 comparetotal -80E-1 9.0 -> -1
-ddcot245 comparetotal -0.8E+1 9 -> -1
-ddcot246 comparetotal -80E-1 9 -> -1
-ddcot247 comparetotal -8.0 9E+0 -> -1
-ddcot248 comparetotal -8.0 90E-1 -> -1
-ddcot249 comparetotal -8 0.9E+1 -> -1
-ddcot250 comparetotal -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ddcot300 comparetotal 7.0 -7.0 -> 1
-ddcot301 comparetotal 7.0 -7 -> 1
-ddcot302 comparetotal 7 -7.0 -> 1
-ddcot303 comparetotal 7E+0 -7.0 -> 1
-ddcot304 comparetotal 70E-1 -7.0 -> 1
-ddcot305 comparetotal .7E+1 -7 -> 1
-ddcot306 comparetotal 70E-1 -7 -> 1
-ddcot307 comparetotal 7.0 -7E+0 -> 1
-ddcot308 comparetotal 7.0 -70E-1 -> 1
-ddcot309 comparetotal 7 -.7E+1 -> 1
-ddcot310 comparetotal 7 -70E-1 -> 1
-
-ddcot320 comparetotal 8.0 -7.0 -> 1
-ddcot321 comparetotal 8.0 -7 -> 1
-ddcot322 comparetotal 8 -7.0 -> 1
-ddcot323 comparetotal 8E+0 -7.0 -> 1
-ddcot324 comparetotal 80E-1 -7.0 -> 1
-ddcot325 comparetotal .8E+1 -7 -> 1
-ddcot326 comparetotal 80E-1 -7 -> 1
-ddcot327 comparetotal 8.0 -7E+0 -> 1
-ddcot328 comparetotal 8.0 -70E-1 -> 1
-ddcot329 comparetotal 8 -.7E+1 -> 1
-ddcot330 comparetotal 8 -70E-1 -> 1
-
-ddcot340 comparetotal 8.0 -9.0 -> 1
-ddcot341 comparetotal 8.0 -9 -> 1
-ddcot342 comparetotal 8 -9.0 -> 1
-ddcot343 comparetotal 8E+0 -9.0 -> 1
-ddcot344 comparetotal 80E-1 -9.0 -> 1
-ddcot345 comparetotal .8E+1 -9 -> 1
-ddcot346 comparetotal 80E-1 -9 -> 1
-ddcot347 comparetotal 8.0 -9E+0 -> 1
-ddcot348 comparetotal 8.0 -90E-1 -> 1
-ddcot349 comparetotal 8 -.9E+1 -> 1
-ddcot350 comparetotal 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-ddcot400 comparetotal -7.0 -7.0 -> 0
-ddcot401 comparetotal -7.0 -7 -> 1
-ddcot402 comparetotal -7 -7.0 -> -1
-ddcot403 comparetotal -7E+0 -7.0 -> -1
-ddcot404 comparetotal -70E-1 -7.0 -> 0
-ddcot405 comparetotal -.7E+1 -7 -> 0
-ddcot406 comparetotal -70E-1 -7 -> 1
-ddcot407 comparetotal -7.0 -7E+0 -> 1
-ddcot408 comparetotal -7.0 -70E-1 -> 0
-ddcot409 comparetotal -7 -.7E+1 -> 0
-ddcot410 comparetotal -7 -70E-1 -> -1
-
-ddcot420 comparetotal -8.0 -7.0 -> -1
-ddcot421 comparetotal -8.0 -7 -> -1
-ddcot422 comparetotal -8 -7.0 -> -1
-ddcot423 comparetotal -8E+0 -7.0 -> -1
-ddcot424 comparetotal -80E-1 -7.0 -> -1
-ddcot425 comparetotal -.8E+1 -7 -> -1
-ddcot426 comparetotal -80E-1 -7 -> -1
-ddcot427 comparetotal -8.0 -7E+0 -> -1
-ddcot428 comparetotal -8.0 -70E-1 -> -1
-ddcot429 comparetotal -8 -.7E+1 -> -1
-ddcot430 comparetotal -8 -70E-1 -> -1
-
-ddcot440 comparetotal -8.0 -9.0 -> 1
-ddcot441 comparetotal -8.0 -9 -> 1
-ddcot442 comparetotal -8 -9.0 -> 1
-ddcot443 comparetotal -8E+0 -9.0 -> 1
-ddcot444 comparetotal -80E-1 -9.0 -> 1
-ddcot445 comparetotal -.8E+1 -9 -> 1
-ddcot446 comparetotal -80E-1 -9 -> 1
-ddcot447 comparetotal -8.0 -9E+0 -> 1
-ddcot448 comparetotal -8.0 -90E-1 -> 1
-ddcot449 comparetotal -8 -.9E+1 -> 1
-ddcot450 comparetotal -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-ddcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
-ddcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
-ddcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
-ddcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
-ddcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
-ddcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
-ddcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
-ddcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
-ddcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
-ddcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
-ddcot483 comparetotal 123.456E-89 123.456E-89 -> 0
-ddcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
-ddcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
-ddcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
-ddcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
-ddcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
-ddcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
-ddcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
-ddcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
-ddcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
-ddcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
-ddcot497 comparetotal 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-ddcot498 comparetotal 1 1E-17 -> 1
-ddcot499 comparetotal 1 1E-16 -> 1
-ddcot500 comparetotal 1 1E-15 -> 1
-ddcot501 comparetotal 1 1E-14 -> 1
-ddcot502 comparetotal 1 1E-13 -> 1
-ddcot503 comparetotal 1 1E-12 -> 1
-ddcot504 comparetotal 1 1E-11 -> 1
-ddcot505 comparetotal 1 1E-10 -> 1
-ddcot506 comparetotal 1 1E-9 -> 1
-ddcot507 comparetotal 1 1E-8 -> 1
-ddcot508 comparetotal 1 1E-7 -> 1
-ddcot509 comparetotal 1 1E-6 -> 1
-ddcot510 comparetotal 1 1E-5 -> 1
-ddcot511 comparetotal 1 1E-4 -> 1
-ddcot512 comparetotal 1 1E-3 -> 1
-ddcot513 comparetotal 1 1E-2 -> 1
-ddcot514 comparetotal 1 1E-1 -> 1
-ddcot515 comparetotal 1 1E-0 -> 0
-ddcot516 comparetotal 1 1E+1 -> -1
-ddcot517 comparetotal 1 1E+2 -> -1
-ddcot518 comparetotal 1 1E+3 -> -1
-ddcot519 comparetotal 1 1E+4 -> -1
-ddcot521 comparetotal 1 1E+5 -> -1
-ddcot522 comparetotal 1 1E+6 -> -1
-ddcot523 comparetotal 1 1E+7 -> -1
-ddcot524 comparetotal 1 1E+8 -> -1
-ddcot525 comparetotal 1 1E+9 -> -1
-ddcot526 comparetotal 1 1E+10 -> -1
-ddcot527 comparetotal 1 1E+11 -> -1
-ddcot528 comparetotal 1 1E+12 -> -1
-ddcot529 comparetotal 1 1E+13 -> -1
-ddcot530 comparetotal 1 1E+14 -> -1
-ddcot531 comparetotal 1 1E+15 -> -1
-ddcot532 comparetotal 1 1E+16 -> -1
-ddcot533 comparetotal 1 1E+17 -> -1
--- LR swap
-ddcot538 comparetotal 1E-17 1 -> -1
-ddcot539 comparetotal 1E-16 1 -> -1
-ddcot540 comparetotal 1E-15 1 -> -1
-ddcot541 comparetotal 1E-14 1 -> -1
-ddcot542 comparetotal 1E-13 1 -> -1
-ddcot543 comparetotal 1E-12 1 -> -1
-ddcot544 comparetotal 1E-11 1 -> -1
-ddcot545 comparetotal 1E-10 1 -> -1
-ddcot546 comparetotal 1E-9 1 -> -1
-ddcot547 comparetotal 1E-8 1 -> -1
-ddcot548 comparetotal 1E-7 1 -> -1
-ddcot549 comparetotal 1E-6 1 -> -1
-ddcot550 comparetotal 1E-5 1 -> -1
-ddcot551 comparetotal 1E-4 1 -> -1
-ddcot552 comparetotal 1E-3 1 -> -1
-ddcot553 comparetotal 1E-2 1 -> -1
-ddcot554 comparetotal 1E-1 1 -> -1
-ddcot555 comparetotal 1E-0 1 -> 0
-ddcot556 comparetotal 1E+1 1 -> 1
-ddcot557 comparetotal 1E+2 1 -> 1
-ddcot558 comparetotal 1E+3 1 -> 1
-ddcot559 comparetotal 1E+4 1 -> 1
-ddcot561 comparetotal 1E+5 1 -> 1
-ddcot562 comparetotal 1E+6 1 -> 1
-ddcot563 comparetotal 1E+7 1 -> 1
-ddcot564 comparetotal 1E+8 1 -> 1
-ddcot565 comparetotal 1E+9 1 -> 1
-ddcot566 comparetotal 1E+10 1 -> 1
-ddcot567 comparetotal 1E+11 1 -> 1
-ddcot568 comparetotal 1E+12 1 -> 1
-ddcot569 comparetotal 1E+13 1 -> 1
-ddcot570 comparetotal 1E+14 1 -> 1
-ddcot571 comparetotal 1E+15 1 -> 1
-ddcot572 comparetotal 1E+16 1 -> 1
-ddcot573 comparetotal 1E+17 1 -> 1
--- similar with a useful coefficient, one side only
-ddcot578 comparetotal 0.000000987654321 1E-17 -> 1
-ddcot579 comparetotal 0.000000987654321 1E-16 -> 1
-ddcot580 comparetotal 0.000000987654321 1E-15 -> 1
-ddcot581 comparetotal 0.000000987654321 1E-14 -> 1
-ddcot582 comparetotal 0.000000987654321 1E-13 -> 1
-ddcot583 comparetotal 0.000000987654321 1E-12 -> 1
-ddcot584 comparetotal 0.000000987654321 1E-11 -> 1
-ddcot585 comparetotal 0.000000987654321 1E-10 -> 1
-ddcot586 comparetotal 0.000000987654321 1E-9 -> 1
-ddcot587 comparetotal 0.000000987654321 1E-8 -> 1
-ddcot588 comparetotal 0.000000987654321 1E-7 -> 1
-ddcot589 comparetotal 0.000000987654321 1E-6 -> -1
-ddcot590 comparetotal 0.000000987654321 1E-5 -> -1
-ddcot591 comparetotal 0.000000987654321 1E-4 -> -1
-ddcot592 comparetotal 0.000000987654321 1E-3 -> -1
-ddcot593 comparetotal 0.000000987654321 1E-2 -> -1
-ddcot594 comparetotal 0.000000987654321 1E-1 -> -1
-ddcot595 comparetotal 0.000000987654321 1E-0 -> -1
-ddcot596 comparetotal 0.000000987654321 1E+1 -> -1
-ddcot597 comparetotal 0.000000987654321 1E+2 -> -1
-ddcot598 comparetotal 0.000000987654321 1E+3 -> -1
-ddcot599 comparetotal 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-ddcot600 comparetotal 12 12.2345 -> -1
-ddcot601 comparetotal 12.0 12.2345 -> -1
-ddcot602 comparetotal 12.00 12.2345 -> -1
-ddcot603 comparetotal 12.000 12.2345 -> -1
-ddcot604 comparetotal 12.0000 12.2345 -> -1
-ddcot605 comparetotal 12.00000 12.2345 -> -1
-ddcot606 comparetotal 12.000000 12.2345 -> -1
-ddcot607 comparetotal 12.0000000 12.2345 -> -1
-ddcot608 comparetotal 12.00000000 12.2345 -> -1
-ddcot609 comparetotal 12.000000000 12.2345 -> -1
-ddcot610 comparetotal 12.1234 12 -> 1
-ddcot611 comparetotal 12.1234 12.0 -> 1
-ddcot612 comparetotal 12.1234 12.00 -> 1
-ddcot613 comparetotal 12.1234 12.000 -> 1
-ddcot614 comparetotal 12.1234 12.0000 -> 1
-ddcot615 comparetotal 12.1234 12.00000 -> 1
-ddcot616 comparetotal 12.1234 12.000000 -> 1
-ddcot617 comparetotal 12.1234 12.0000000 -> 1
-ddcot618 comparetotal 12.1234 12.00000000 -> 1
-ddcot619 comparetotal 12.1234 12.000000000 -> 1
-ddcot620 comparetotal -12 -12.2345 -> 1
-ddcot621 comparetotal -12.0 -12.2345 -> 1
-ddcot622 comparetotal -12.00 -12.2345 -> 1
-ddcot623 comparetotal -12.000 -12.2345 -> 1
-ddcot624 comparetotal -12.0000 -12.2345 -> 1
-ddcot625 comparetotal -12.00000 -12.2345 -> 1
-ddcot626 comparetotal -12.000000 -12.2345 -> 1
-ddcot627 comparetotal -12.0000000 -12.2345 -> 1
-ddcot628 comparetotal -12.00000000 -12.2345 -> 1
-ddcot629 comparetotal -12.000000000 -12.2345 -> 1
-ddcot630 comparetotal -12.1234 -12 -> -1
-ddcot631 comparetotal -12.1234 -12.0 -> -1
-ddcot632 comparetotal -12.1234 -12.00 -> -1
-ddcot633 comparetotal -12.1234 -12.000 -> -1
-ddcot634 comparetotal -12.1234 -12.0000 -> -1
-ddcot635 comparetotal -12.1234 -12.00000 -> -1
-ddcot636 comparetotal -12.1234 -12.000000 -> -1
-ddcot637 comparetotal -12.1234 -12.0000000 -> -1
-ddcot638 comparetotal -12.1234 -12.00000000 -> -1
-ddcot639 comparetotal -12.1234 -12.000000000 -> -1
-
--- extended zeros
-ddcot640 comparetotal 0 0 -> 0
-ddcot641 comparetotal 0 -0 -> 1
-ddcot642 comparetotal 0 -0.0 -> 1
-ddcot643 comparetotal 0 0.0 -> 1
-ddcot644 comparetotal -0 0 -> -1
-ddcot645 comparetotal -0 -0 -> 0
-ddcot646 comparetotal -0 -0.0 -> -1
-ddcot647 comparetotal -0 0.0 -> -1
-ddcot648 comparetotal 0.0 0 -> -1
-ddcot649 comparetotal 0.0 -0 -> 1
-ddcot650 comparetotal 0.0 -0.0 -> 1
-ddcot651 comparetotal 0.0 0.0 -> 0
-ddcot652 comparetotal -0.0 0 -> -1
-ddcot653 comparetotal -0.0 -0 -> 1
-ddcot654 comparetotal -0.0 -0.0 -> 0
-ddcot655 comparetotal -0.0 0.0 -> -1
-
-ddcot656 comparetotal -0E1 0.0 -> -1
-ddcot657 comparetotal -0E2 0.0 -> -1
-ddcot658 comparetotal 0E1 0.0 -> 1
-ddcot659 comparetotal 0E2 0.0 -> 1
-ddcot660 comparetotal -0E1 0 -> -1
-ddcot661 comparetotal -0E2 0 -> -1
-ddcot662 comparetotal 0E1 0 -> 1
-ddcot663 comparetotal 0E2 0 -> 1
-ddcot664 comparetotal -0E1 -0E1 -> 0
-ddcot665 comparetotal -0E2 -0E1 -> -1
-ddcot666 comparetotal 0E1 -0E1 -> 1
-ddcot667 comparetotal 0E2 -0E1 -> 1
-ddcot668 comparetotal -0E1 -0E2 -> 1
-ddcot669 comparetotal -0E2 -0E2 -> 0
-ddcot670 comparetotal 0E1 -0E2 -> 1
-ddcot671 comparetotal 0E2 -0E2 -> 1
-ddcot672 comparetotal -0E1 0E1 -> -1
-ddcot673 comparetotal -0E2 0E1 -> -1
-ddcot674 comparetotal 0E1 0E1 -> 0
-ddcot675 comparetotal 0E2 0E1 -> 1
-ddcot676 comparetotal -0E1 0E2 -> -1
-ddcot677 comparetotal -0E2 0E2 -> -1
-ddcot678 comparetotal 0E1 0E2 -> -1
-ddcot679 comparetotal 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-ddcot680 comparetotal 12 12 -> 0
-ddcot681 comparetotal 12 12.0 -> 1
-ddcot682 comparetotal 12 12.00 -> 1
-ddcot683 comparetotal 12 12.000 -> 1
-ddcot684 comparetotal 12 12.0000 -> 1
-ddcot685 comparetotal 12 12.00000 -> 1
-ddcot686 comparetotal 12 12.000000 -> 1
-ddcot687 comparetotal 12 12.0000000 -> 1
-ddcot688 comparetotal 12 12.00000000 -> 1
-ddcot689 comparetotal 12 12.000000000 -> 1
-ddcot690 comparetotal 12 12 -> 0
-ddcot691 comparetotal 12.0 12 -> -1
-ddcot692 comparetotal 12.00 12 -> -1
-ddcot693 comparetotal 12.000 12 -> -1
-ddcot694 comparetotal 12.0000 12 -> -1
-ddcot695 comparetotal 12.00000 12 -> -1
-ddcot696 comparetotal 12.000000 12 -> -1
-ddcot697 comparetotal 12.0000000 12 -> -1
-ddcot698 comparetotal 12.00000000 12 -> -1
-ddcot699 comparetotal 12.000000000 12 -> -1
-
--- old long operand checks
-ddcot701 comparetotal 12345678000 1 -> 1
-ddcot702 comparetotal 1 12345678000 -> -1
-ddcot703 comparetotal 1234567800 1 -> 1
-ddcot704 comparetotal 1 1234567800 -> -1
-ddcot705 comparetotal 1234567890 1 -> 1
-ddcot706 comparetotal 1 1234567890 -> -1
-ddcot707 comparetotal 1234567891 1 -> 1
-ddcot708 comparetotal 1 1234567891 -> -1
-ddcot709 comparetotal 12345678901 1 -> 1
-ddcot710 comparetotal 1 12345678901 -> -1
-ddcot711 comparetotal 1234567896 1 -> 1
-ddcot712 comparetotal 1 1234567896 -> -1
-ddcot713 comparetotal -1234567891 1 -> -1
-ddcot714 comparetotal 1 -1234567891 -> 1
-ddcot715 comparetotal -12345678901 1 -> -1
-ddcot716 comparetotal 1 -12345678901 -> 1
-ddcot717 comparetotal -1234567896 1 -> -1
-ddcot718 comparetotal 1 -1234567896 -> 1
-
--- old residue cases
-ddcot740 comparetotal 1 0.9999999 -> 1
-ddcot741 comparetotal 1 0.999999 -> 1
-ddcot742 comparetotal 1 0.99999 -> 1
-ddcot743 comparetotal 1 1.0000 -> 1
-ddcot744 comparetotal 1 1.00001 -> -1
-ddcot745 comparetotal 1 1.000001 -> -1
-ddcot746 comparetotal 1 1.0000001 -> -1
-ddcot750 comparetotal 0.9999999 1 -> -1
-ddcot751 comparetotal 0.999999 1 -> -1
-ddcot752 comparetotal 0.99999 1 -> -1
-ddcot753 comparetotal 1.0000 1 -> -1
-ddcot754 comparetotal 1.00001 1 -> 1
-ddcot755 comparetotal 1.000001 1 -> 1
-ddcot756 comparetotal 1.0000001 1 -> 1
-
--- Specials
-ddcot780 comparetotal Inf -Inf -> 1
-ddcot781 comparetotal Inf -1000 -> 1
-ddcot782 comparetotal Inf -1 -> 1
-ddcot783 comparetotal Inf -0 -> 1
-ddcot784 comparetotal Inf 0 -> 1
-ddcot785 comparetotal Inf 1 -> 1
-ddcot786 comparetotal Inf 1000 -> 1
-ddcot787 comparetotal Inf Inf -> 0
-ddcot788 comparetotal -1000 Inf -> -1
-ddcot789 comparetotal -Inf Inf -> -1
-ddcot790 comparetotal -1 Inf -> -1
-ddcot791 comparetotal -0 Inf -> -1
-ddcot792 comparetotal 0 Inf -> -1
-ddcot793 comparetotal 1 Inf -> -1
-ddcot794 comparetotal 1000 Inf -> -1
-ddcot795 comparetotal Inf Inf -> 0
-
-ddcot800 comparetotal -Inf -Inf -> 0
-ddcot801 comparetotal -Inf -1000 -> -1
-ddcot802 comparetotal -Inf -1 -> -1
-ddcot803 comparetotal -Inf -0 -> -1
-ddcot804 comparetotal -Inf 0 -> -1
-ddcot805 comparetotal -Inf 1 -> -1
-ddcot806 comparetotal -Inf 1000 -> -1
-ddcot807 comparetotal -Inf Inf -> -1
-ddcot808 comparetotal -Inf -Inf -> 0
-ddcot809 comparetotal -1000 -Inf -> 1
-ddcot810 comparetotal -1 -Inf -> 1
-ddcot811 comparetotal -0 -Inf -> 1
-ddcot812 comparetotal 0 -Inf -> 1
-ddcot813 comparetotal 1 -Inf -> 1
-ddcot814 comparetotal 1000 -Inf -> 1
-ddcot815 comparetotal Inf -Inf -> 1
-
-ddcot821 comparetotal NaN -Inf -> 1
-ddcot822 comparetotal NaN -1000 -> 1
-ddcot823 comparetotal NaN -1 -> 1
-ddcot824 comparetotal NaN -0 -> 1
-ddcot825 comparetotal NaN 0 -> 1
-ddcot826 comparetotal NaN 1 -> 1
-ddcot827 comparetotal NaN 1000 -> 1
-ddcot828 comparetotal NaN Inf -> 1
-ddcot829 comparetotal NaN NaN -> 0
-ddcot830 comparetotal -Inf NaN -> -1
-ddcot831 comparetotal -1000 NaN -> -1
-ddcot832 comparetotal -1 NaN -> -1
-ddcot833 comparetotal -0 NaN -> -1
-ddcot834 comparetotal 0 NaN -> -1
-ddcot835 comparetotal 1 NaN -> -1
-ddcot836 comparetotal 1000 NaN -> -1
-ddcot837 comparetotal Inf NaN -> -1
-ddcot838 comparetotal -NaN -NaN -> 0
-ddcot839 comparetotal +NaN -NaN -> 1
-ddcot840 comparetotal -NaN +NaN -> -1
-
-ddcot841 comparetotal sNaN -sNaN -> 1
-ddcot842 comparetotal sNaN -NaN -> 1
-ddcot843 comparetotal sNaN -Inf -> 1
-ddcot844 comparetotal sNaN -1000 -> 1
-ddcot845 comparetotal sNaN -1 -> 1
-ddcot846 comparetotal sNaN -0 -> 1
-ddcot847 comparetotal sNaN 0 -> 1
-ddcot848 comparetotal sNaN 1 -> 1
-ddcot849 comparetotal sNaN 1000 -> 1
-ddcot850 comparetotal sNaN NaN -> -1
-ddcot851 comparetotal sNaN sNaN -> 0
-
-ddcot852 comparetotal -sNaN sNaN -> -1
-ddcot853 comparetotal -NaN sNaN -> -1
-ddcot854 comparetotal -Inf sNaN -> -1
-ddcot855 comparetotal -1000 sNaN -> -1
-ddcot856 comparetotal -1 sNaN -> -1
-ddcot857 comparetotal -0 sNaN -> -1
-ddcot858 comparetotal 0 sNaN -> -1
-ddcot859 comparetotal 1 sNaN -> -1
-ddcot860 comparetotal 1000 sNaN -> -1
-ddcot861 comparetotal Inf sNaN -> -1
-ddcot862 comparetotal NaN sNaN -> 1
-ddcot863 comparetotal sNaN sNaN -> 0
-
-ddcot871 comparetotal -sNaN -sNaN -> 0
-ddcot872 comparetotal -sNaN -NaN -> 1
-ddcot873 comparetotal -sNaN -Inf -> -1
-ddcot874 comparetotal -sNaN -1000 -> -1
-ddcot875 comparetotal -sNaN -1 -> -1
-ddcot876 comparetotal -sNaN -0 -> -1
-ddcot877 comparetotal -sNaN 0 -> -1
-ddcot878 comparetotal -sNaN 1 -> -1
-ddcot879 comparetotal -sNaN 1000 -> -1
-ddcot880 comparetotal -sNaN NaN -> -1
-ddcot881 comparetotal -sNaN sNaN -> -1
-
-ddcot882 comparetotal -sNaN -sNaN -> 0
-ddcot883 comparetotal -NaN -sNaN -> -1
-ddcot884 comparetotal -Inf -sNaN -> 1
-ddcot885 comparetotal -1000 -sNaN -> 1
-ddcot886 comparetotal -1 -sNaN -> 1
-ddcot887 comparetotal -0 -sNaN -> 1
-ddcot888 comparetotal 0 -sNaN -> 1
-ddcot889 comparetotal 1 -sNaN -> 1
-ddcot890 comparetotal 1000 -sNaN -> 1
-ddcot891 comparetotal Inf -sNaN -> 1
-ddcot892 comparetotal NaN -sNaN -> 1
-ddcot893 comparetotal sNaN -sNaN -> 1
-
--- NaNs with payload
-ddcot960 comparetotal NaN9 -Inf -> 1
-ddcot961 comparetotal NaN8 999 -> 1
-ddcot962 comparetotal NaN77 Inf -> 1
-ddcot963 comparetotal -NaN67 NaN5 -> -1
-ddcot964 comparetotal -Inf -NaN4 -> 1
-ddcot965 comparetotal -999 -NaN33 -> 1
-ddcot966 comparetotal Inf NaN2 -> -1
-
-ddcot970 comparetotal -NaN41 -NaN42 -> 1
-ddcot971 comparetotal +NaN41 -NaN42 -> 1
-ddcot972 comparetotal -NaN41 +NaN42 -> -1
-ddcot973 comparetotal +NaN41 +NaN42 -> -1
-ddcot974 comparetotal -NaN42 -NaN01 -> -1
-ddcot975 comparetotal +NaN42 -NaN01 -> 1
-ddcot976 comparetotal -NaN42 +NaN01 -> -1
-ddcot977 comparetotal +NaN42 +NaN01 -> 1
-
-ddcot980 comparetotal -sNaN771 -sNaN772 -> 1
-ddcot981 comparetotal +sNaN771 -sNaN772 -> 1
-ddcot982 comparetotal -sNaN771 +sNaN772 -> -1
-ddcot983 comparetotal +sNaN771 +sNaN772 -> -1
-ddcot984 comparetotal -sNaN772 -sNaN771 -> -1
-ddcot985 comparetotal +sNaN772 -sNaN771 -> 1
-ddcot986 comparetotal -sNaN772 +sNaN771 -> -1
-ddcot987 comparetotal +sNaN772 +sNaN771 -> 1
-
-ddcot991 comparetotal -sNaN99 -Inf -> -1
-ddcot992 comparetotal sNaN98 -11 -> 1
-ddcot993 comparetotal sNaN97 NaN -> -1
-ddcot994 comparetotal sNaN16 sNaN94 -> -1
-ddcot995 comparetotal NaN85 sNaN83 -> 1
-ddcot996 comparetotal -Inf sNaN92 -> -1
-ddcot997 comparetotal 088 sNaN81 -> -1
-ddcot998 comparetotal Inf sNaN90 -> -1
-ddcot999 comparetotal NaN -sNaN89 -> 1
-
--- spread zeros
-ddcot1110 comparetotal 0E-383 0 -> -1
-ddcot1111 comparetotal 0E-383 -0 -> 1
-ddcot1112 comparetotal -0E-383 0 -> -1
-ddcot1113 comparetotal -0E-383 -0 -> 1
-ddcot1114 comparetotal 0E-383 0E+384 -> -1
-ddcot1115 comparetotal 0E-383 -0E+384 -> 1
-ddcot1116 comparetotal -0E-383 0E+384 -> -1
-ddcot1117 comparetotal -0E-383 -0E+384 -> 1
-ddcot1118 comparetotal 0 0E+384 -> -1
-ddcot1119 comparetotal 0 -0E+384 -> 1
-ddcot1120 comparetotal -0 0E+384 -> -1
-ddcot1121 comparetotal -0 -0E+384 -> 1
-
-ddcot1130 comparetotal 0E+384 0 -> 1
-ddcot1131 comparetotal 0E+384 -0 -> 1
-ddcot1132 comparetotal -0E+384 0 -> -1
-ddcot1133 comparetotal -0E+384 -0 -> -1
-ddcot1134 comparetotal 0E+384 0E-383 -> 1
-ddcot1135 comparetotal 0E+384 -0E-383 -> 1
-ddcot1136 comparetotal -0E+384 0E-383 -> -1
-ddcot1137 comparetotal -0E+384 -0E-383 -> -1
-ddcot1138 comparetotal 0 0E-383 -> 1
-ddcot1139 comparetotal 0 -0E-383 -> 1
-ddcot1140 comparetotal -0 0E-383 -> -1
-ddcot1141 comparetotal -0 -0E-383 -> -1
-
--- Null tests
-ddcot9990 comparetotal 10 # -> NaN Invalid_operation
-ddcot9991 comparetotal # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddCompareTotal.decTest -- decDouble comparison using total ordering--
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddcot001 comparetotal -2 -2 -> 0
+ddcot002 comparetotal -2 -1 -> -1
+ddcot003 comparetotal -2 0 -> -1
+ddcot004 comparetotal -2 1 -> -1
+ddcot005 comparetotal -2 2 -> -1
+ddcot006 comparetotal -1 -2 -> 1
+ddcot007 comparetotal -1 -1 -> 0
+ddcot008 comparetotal -1 0 -> -1
+ddcot009 comparetotal -1 1 -> -1
+ddcot010 comparetotal -1 2 -> -1
+ddcot011 comparetotal 0 -2 -> 1
+ddcot012 comparetotal 0 -1 -> 1
+ddcot013 comparetotal 0 0 -> 0
+ddcot014 comparetotal 0 1 -> -1
+ddcot015 comparetotal 0 2 -> -1
+ddcot016 comparetotal 1 -2 -> 1
+ddcot017 comparetotal 1 -1 -> 1
+ddcot018 comparetotal 1 0 -> 1
+ddcot019 comparetotal 1 1 -> 0
+ddcot020 comparetotal 1 2 -> -1
+ddcot021 comparetotal 2 -2 -> 1
+ddcot022 comparetotal 2 -1 -> 1
+ddcot023 comparetotal 2 0 -> 1
+ddcot025 comparetotal 2 1 -> 1
+ddcot026 comparetotal 2 2 -> 0
+
+ddcot031 comparetotal -20 -20 -> 0
+ddcot032 comparetotal -20 -10 -> -1
+ddcot033 comparetotal -20 00 -> -1
+ddcot034 comparetotal -20 10 -> -1
+ddcot035 comparetotal -20 20 -> -1
+ddcot036 comparetotal -10 -20 -> 1
+ddcot037 comparetotal -10 -10 -> 0
+ddcot038 comparetotal -10 00 -> -1
+ddcot039 comparetotal -10 10 -> -1
+ddcot040 comparetotal -10 20 -> -1
+ddcot041 comparetotal 00 -20 -> 1
+ddcot042 comparetotal 00 -10 -> 1
+ddcot043 comparetotal 00 00 -> 0
+ddcot044 comparetotal 00 10 -> -1
+ddcot045 comparetotal 00 20 -> -1
+ddcot046 comparetotal 10 -20 -> 1
+ddcot047 comparetotal 10 -10 -> 1
+ddcot048 comparetotal 10 00 -> 1
+ddcot049 comparetotal 10 10 -> 0
+ddcot050 comparetotal 10 20 -> -1
+ddcot051 comparetotal 20 -20 -> 1
+ddcot052 comparetotal 20 -10 -> 1
+ddcot053 comparetotal 20 00 -> 1
+ddcot055 comparetotal 20 10 -> 1
+ddcot056 comparetotal 20 20 -> 0
+
+ddcot061 comparetotal -2.0 -2.0 -> 0
+ddcot062 comparetotal -2.0 -1.0 -> -1
+ddcot063 comparetotal -2.0 0.0 -> -1
+ddcot064 comparetotal -2.0 1.0 -> -1
+ddcot065 comparetotal -2.0 2.0 -> -1
+ddcot066 comparetotal -1.0 -2.0 -> 1
+ddcot067 comparetotal -1.0 -1.0 -> 0
+ddcot068 comparetotal -1.0 0.0 -> -1
+ddcot069 comparetotal -1.0 1.0 -> -1
+ddcot070 comparetotal -1.0 2.0 -> -1
+ddcot071 comparetotal 0.0 -2.0 -> 1
+ddcot072 comparetotal 0.0 -1.0 -> 1
+ddcot073 comparetotal 0.0 0.0 -> 0
+ddcot074 comparetotal 0.0 1.0 -> -1
+ddcot075 comparetotal 0.0 2.0 -> -1
+ddcot076 comparetotal 1.0 -2.0 -> 1
+ddcot077 comparetotal 1.0 -1.0 -> 1
+ddcot078 comparetotal 1.0 0.0 -> 1
+ddcot079 comparetotal 1.0 1.0 -> 0
+ddcot080 comparetotal 1.0 2.0 -> -1
+ddcot081 comparetotal 2.0 -2.0 -> 1
+ddcot082 comparetotal 2.0 -1.0 -> 1
+ddcot083 comparetotal 2.0 0.0 -> 1
+ddcot085 comparetotal 2.0 1.0 -> 1
+ddcot086 comparetotal 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+ddcot090 comparetotal 9.99999999E+384 9.99999999E+384 -> 0
+ddcot091 comparetotal -9.99999999E+384 9.99999999E+384 -> -1
+ddcot092 comparetotal 9.99999999E+384 -9.99999999E+384 -> 1
+ddcot093 comparetotal -9.99999999E+384 -9.99999999E+384 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+ddcot100 comparetotal 7.0 7.0 -> 0
+ddcot101 comparetotal 7.0 7 -> -1
+ddcot102 comparetotal 7 7.0 -> 1
+ddcot103 comparetotal 7E+0 7.0 -> 1
+ddcot104 comparetotal 70E-1 7.0 -> 0
+ddcot105 comparetotal 0.7E+1 7 -> 0
+ddcot106 comparetotal 70E-1 7 -> -1
+ddcot107 comparetotal 7.0 7E+0 -> -1
+ddcot108 comparetotal 7.0 70E-1 -> 0
+ddcot109 comparetotal 7 0.7E+1 -> 0
+ddcot110 comparetotal 7 70E-1 -> 1
+
+ddcot120 comparetotal 8.0 7.0 -> 1
+ddcot121 comparetotal 8.0 7 -> 1
+ddcot122 comparetotal 8 7.0 -> 1
+ddcot123 comparetotal 8E+0 7.0 -> 1
+ddcot124 comparetotal 80E-1 7.0 -> 1
+ddcot125 comparetotal 0.8E+1 7 -> 1
+ddcot126 comparetotal 80E-1 7 -> 1
+ddcot127 comparetotal 8.0 7E+0 -> 1
+ddcot128 comparetotal 8.0 70E-1 -> 1
+ddcot129 comparetotal 8 0.7E+1 -> 1
+ddcot130 comparetotal 8 70E-1 -> 1
+
+ddcot140 comparetotal 8.0 9.0 -> -1
+ddcot141 comparetotal 8.0 9 -> -1
+ddcot142 comparetotal 8 9.0 -> -1
+ddcot143 comparetotal 8E+0 9.0 -> -1
+ddcot144 comparetotal 80E-1 9.0 -> -1
+ddcot145 comparetotal 0.8E+1 9 -> -1
+ddcot146 comparetotal 80E-1 9 -> -1
+ddcot147 comparetotal 8.0 9E+0 -> -1
+ddcot148 comparetotal 8.0 90E-1 -> -1
+ddcot149 comparetotal 8 0.9E+1 -> -1
+ddcot150 comparetotal 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ddcot200 comparetotal -7.0 7.0 -> -1
+ddcot201 comparetotal -7.0 7 -> -1
+ddcot202 comparetotal -7 7.0 -> -1
+ddcot203 comparetotal -7E+0 7.0 -> -1
+ddcot204 comparetotal -70E-1 7.0 -> -1
+ddcot205 comparetotal -0.7E+1 7 -> -1
+ddcot206 comparetotal -70E-1 7 -> -1
+ddcot207 comparetotal -7.0 7E+0 -> -1
+ddcot208 comparetotal -7.0 70E-1 -> -1
+ddcot209 comparetotal -7 0.7E+1 -> -1
+ddcot210 comparetotal -7 70E-1 -> -1
+
+ddcot220 comparetotal -8.0 7.0 -> -1
+ddcot221 comparetotal -8.0 7 -> -1
+ddcot222 comparetotal -8 7.0 -> -1
+ddcot223 comparetotal -8E+0 7.0 -> -1
+ddcot224 comparetotal -80E-1 7.0 -> -1
+ddcot225 comparetotal -0.8E+1 7 -> -1
+ddcot226 comparetotal -80E-1 7 -> -1
+ddcot227 comparetotal -8.0 7E+0 -> -1
+ddcot228 comparetotal -8.0 70E-1 -> -1
+ddcot229 comparetotal -8 0.7E+1 -> -1
+ddcot230 comparetotal -8 70E-1 -> -1
+
+ddcot240 comparetotal -8.0 9.0 -> -1
+ddcot241 comparetotal -8.0 9 -> -1
+ddcot242 comparetotal -8 9.0 -> -1
+ddcot243 comparetotal -8E+0 9.0 -> -1
+ddcot244 comparetotal -80E-1 9.0 -> -1
+ddcot245 comparetotal -0.8E+1 9 -> -1
+ddcot246 comparetotal -80E-1 9 -> -1
+ddcot247 comparetotal -8.0 9E+0 -> -1
+ddcot248 comparetotal -8.0 90E-1 -> -1
+ddcot249 comparetotal -8 0.9E+1 -> -1
+ddcot250 comparetotal -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ddcot300 comparetotal 7.0 -7.0 -> 1
+ddcot301 comparetotal 7.0 -7 -> 1
+ddcot302 comparetotal 7 -7.0 -> 1
+ddcot303 comparetotal 7E+0 -7.0 -> 1
+ddcot304 comparetotal 70E-1 -7.0 -> 1
+ddcot305 comparetotal .7E+1 -7 -> 1
+ddcot306 comparetotal 70E-1 -7 -> 1
+ddcot307 comparetotal 7.0 -7E+0 -> 1
+ddcot308 comparetotal 7.0 -70E-1 -> 1
+ddcot309 comparetotal 7 -.7E+1 -> 1
+ddcot310 comparetotal 7 -70E-1 -> 1
+
+ddcot320 comparetotal 8.0 -7.0 -> 1
+ddcot321 comparetotal 8.0 -7 -> 1
+ddcot322 comparetotal 8 -7.0 -> 1
+ddcot323 comparetotal 8E+0 -7.0 -> 1
+ddcot324 comparetotal 80E-1 -7.0 -> 1
+ddcot325 comparetotal .8E+1 -7 -> 1
+ddcot326 comparetotal 80E-1 -7 -> 1
+ddcot327 comparetotal 8.0 -7E+0 -> 1
+ddcot328 comparetotal 8.0 -70E-1 -> 1
+ddcot329 comparetotal 8 -.7E+1 -> 1
+ddcot330 comparetotal 8 -70E-1 -> 1
+
+ddcot340 comparetotal 8.0 -9.0 -> 1
+ddcot341 comparetotal 8.0 -9 -> 1
+ddcot342 comparetotal 8 -9.0 -> 1
+ddcot343 comparetotal 8E+0 -9.0 -> 1
+ddcot344 comparetotal 80E-1 -9.0 -> 1
+ddcot345 comparetotal .8E+1 -9 -> 1
+ddcot346 comparetotal 80E-1 -9 -> 1
+ddcot347 comparetotal 8.0 -9E+0 -> 1
+ddcot348 comparetotal 8.0 -90E-1 -> 1
+ddcot349 comparetotal 8 -.9E+1 -> 1
+ddcot350 comparetotal 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+ddcot400 comparetotal -7.0 -7.0 -> 0
+ddcot401 comparetotal -7.0 -7 -> 1
+ddcot402 comparetotal -7 -7.0 -> -1
+ddcot403 comparetotal -7E+0 -7.0 -> -1
+ddcot404 comparetotal -70E-1 -7.0 -> 0
+ddcot405 comparetotal -.7E+1 -7 -> 0
+ddcot406 comparetotal -70E-1 -7 -> 1
+ddcot407 comparetotal -7.0 -7E+0 -> 1
+ddcot408 comparetotal -7.0 -70E-1 -> 0
+ddcot409 comparetotal -7 -.7E+1 -> 0
+ddcot410 comparetotal -7 -70E-1 -> -1
+
+ddcot420 comparetotal -8.0 -7.0 -> -1
+ddcot421 comparetotal -8.0 -7 -> -1
+ddcot422 comparetotal -8 -7.0 -> -1
+ddcot423 comparetotal -8E+0 -7.0 -> -1
+ddcot424 comparetotal -80E-1 -7.0 -> -1
+ddcot425 comparetotal -.8E+1 -7 -> -1
+ddcot426 comparetotal -80E-1 -7 -> -1
+ddcot427 comparetotal -8.0 -7E+0 -> -1
+ddcot428 comparetotal -8.0 -70E-1 -> -1
+ddcot429 comparetotal -8 -.7E+1 -> -1
+ddcot430 comparetotal -8 -70E-1 -> -1
+
+ddcot440 comparetotal -8.0 -9.0 -> 1
+ddcot441 comparetotal -8.0 -9 -> 1
+ddcot442 comparetotal -8 -9.0 -> 1
+ddcot443 comparetotal -8E+0 -9.0 -> 1
+ddcot444 comparetotal -80E-1 -9.0 -> 1
+ddcot445 comparetotal -.8E+1 -9 -> 1
+ddcot446 comparetotal -80E-1 -9 -> 1
+ddcot447 comparetotal -8.0 -9E+0 -> 1
+ddcot448 comparetotal -8.0 -90E-1 -> 1
+ddcot449 comparetotal -8 -.9E+1 -> 1
+ddcot450 comparetotal -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+ddcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
+ddcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
+ddcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
+ddcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
+ddcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
+ddcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
+ddcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
+ddcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
+ddcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
+ddcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
+ddcot483 comparetotal 123.456E-89 123.456E-89 -> 0
+ddcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
+ddcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
+ddcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
+ddcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
+ddcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
+ddcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
+ddcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
+ddcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
+ddcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
+ddcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
+ddcot497 comparetotal 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+ddcot498 comparetotal 1 1E-17 -> 1
+ddcot499 comparetotal 1 1E-16 -> 1
+ddcot500 comparetotal 1 1E-15 -> 1
+ddcot501 comparetotal 1 1E-14 -> 1
+ddcot502 comparetotal 1 1E-13 -> 1
+ddcot503 comparetotal 1 1E-12 -> 1
+ddcot504 comparetotal 1 1E-11 -> 1
+ddcot505 comparetotal 1 1E-10 -> 1
+ddcot506 comparetotal 1 1E-9 -> 1
+ddcot507 comparetotal 1 1E-8 -> 1
+ddcot508 comparetotal 1 1E-7 -> 1
+ddcot509 comparetotal 1 1E-6 -> 1
+ddcot510 comparetotal 1 1E-5 -> 1
+ddcot511 comparetotal 1 1E-4 -> 1
+ddcot512 comparetotal 1 1E-3 -> 1
+ddcot513 comparetotal 1 1E-2 -> 1
+ddcot514 comparetotal 1 1E-1 -> 1
+ddcot515 comparetotal 1 1E-0 -> 0
+ddcot516 comparetotal 1 1E+1 -> -1
+ddcot517 comparetotal 1 1E+2 -> -1
+ddcot518 comparetotal 1 1E+3 -> -1
+ddcot519 comparetotal 1 1E+4 -> -1
+ddcot521 comparetotal 1 1E+5 -> -1
+ddcot522 comparetotal 1 1E+6 -> -1
+ddcot523 comparetotal 1 1E+7 -> -1
+ddcot524 comparetotal 1 1E+8 -> -1
+ddcot525 comparetotal 1 1E+9 -> -1
+ddcot526 comparetotal 1 1E+10 -> -1
+ddcot527 comparetotal 1 1E+11 -> -1
+ddcot528 comparetotal 1 1E+12 -> -1
+ddcot529 comparetotal 1 1E+13 -> -1
+ddcot530 comparetotal 1 1E+14 -> -1
+ddcot531 comparetotal 1 1E+15 -> -1
+ddcot532 comparetotal 1 1E+16 -> -1
+ddcot533 comparetotal 1 1E+17 -> -1
+-- LR swap
+ddcot538 comparetotal 1E-17 1 -> -1
+ddcot539 comparetotal 1E-16 1 -> -1
+ddcot540 comparetotal 1E-15 1 -> -1
+ddcot541 comparetotal 1E-14 1 -> -1
+ddcot542 comparetotal 1E-13 1 -> -1
+ddcot543 comparetotal 1E-12 1 -> -1
+ddcot544 comparetotal 1E-11 1 -> -1
+ddcot545 comparetotal 1E-10 1 -> -1
+ddcot546 comparetotal 1E-9 1 -> -1
+ddcot547 comparetotal 1E-8 1 -> -1
+ddcot548 comparetotal 1E-7 1 -> -1
+ddcot549 comparetotal 1E-6 1 -> -1
+ddcot550 comparetotal 1E-5 1 -> -1
+ddcot551 comparetotal 1E-4 1 -> -1
+ddcot552 comparetotal 1E-3 1 -> -1
+ddcot553 comparetotal 1E-2 1 -> -1
+ddcot554 comparetotal 1E-1 1 -> -1
+ddcot555 comparetotal 1E-0 1 -> 0
+ddcot556 comparetotal 1E+1 1 -> 1
+ddcot557 comparetotal 1E+2 1 -> 1
+ddcot558 comparetotal 1E+3 1 -> 1
+ddcot559 comparetotal 1E+4 1 -> 1
+ddcot561 comparetotal 1E+5 1 -> 1
+ddcot562 comparetotal 1E+6 1 -> 1
+ddcot563 comparetotal 1E+7 1 -> 1
+ddcot564 comparetotal 1E+8 1 -> 1
+ddcot565 comparetotal 1E+9 1 -> 1
+ddcot566 comparetotal 1E+10 1 -> 1
+ddcot567 comparetotal 1E+11 1 -> 1
+ddcot568 comparetotal 1E+12 1 -> 1
+ddcot569 comparetotal 1E+13 1 -> 1
+ddcot570 comparetotal 1E+14 1 -> 1
+ddcot571 comparetotal 1E+15 1 -> 1
+ddcot572 comparetotal 1E+16 1 -> 1
+ddcot573 comparetotal 1E+17 1 -> 1
+-- similar with a useful coefficient, one side only
+ddcot578 comparetotal 0.000000987654321 1E-17 -> 1
+ddcot579 comparetotal 0.000000987654321 1E-16 -> 1
+ddcot580 comparetotal 0.000000987654321 1E-15 -> 1
+ddcot581 comparetotal 0.000000987654321 1E-14 -> 1
+ddcot582 comparetotal 0.000000987654321 1E-13 -> 1
+ddcot583 comparetotal 0.000000987654321 1E-12 -> 1
+ddcot584 comparetotal 0.000000987654321 1E-11 -> 1
+ddcot585 comparetotal 0.000000987654321 1E-10 -> 1
+ddcot586 comparetotal 0.000000987654321 1E-9 -> 1
+ddcot587 comparetotal 0.000000987654321 1E-8 -> 1
+ddcot588 comparetotal 0.000000987654321 1E-7 -> 1
+ddcot589 comparetotal 0.000000987654321 1E-6 -> -1
+ddcot590 comparetotal 0.000000987654321 1E-5 -> -1
+ddcot591 comparetotal 0.000000987654321 1E-4 -> -1
+ddcot592 comparetotal 0.000000987654321 1E-3 -> -1
+ddcot593 comparetotal 0.000000987654321 1E-2 -> -1
+ddcot594 comparetotal 0.000000987654321 1E-1 -> -1
+ddcot595 comparetotal 0.000000987654321 1E-0 -> -1
+ddcot596 comparetotal 0.000000987654321 1E+1 -> -1
+ddcot597 comparetotal 0.000000987654321 1E+2 -> -1
+ddcot598 comparetotal 0.000000987654321 1E+3 -> -1
+ddcot599 comparetotal 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+ddcot600 comparetotal 12 12.2345 -> -1
+ddcot601 comparetotal 12.0 12.2345 -> -1
+ddcot602 comparetotal 12.00 12.2345 -> -1
+ddcot603 comparetotal 12.000 12.2345 -> -1
+ddcot604 comparetotal 12.0000 12.2345 -> -1
+ddcot605 comparetotal 12.00000 12.2345 -> -1
+ddcot606 comparetotal 12.000000 12.2345 -> -1
+ddcot607 comparetotal 12.0000000 12.2345 -> -1
+ddcot608 comparetotal 12.00000000 12.2345 -> -1
+ddcot609 comparetotal 12.000000000 12.2345 -> -1
+ddcot610 comparetotal 12.1234 12 -> 1
+ddcot611 comparetotal 12.1234 12.0 -> 1
+ddcot612 comparetotal 12.1234 12.00 -> 1
+ddcot613 comparetotal 12.1234 12.000 -> 1
+ddcot614 comparetotal 12.1234 12.0000 -> 1
+ddcot615 comparetotal 12.1234 12.00000 -> 1
+ddcot616 comparetotal 12.1234 12.000000 -> 1
+ddcot617 comparetotal 12.1234 12.0000000 -> 1
+ddcot618 comparetotal 12.1234 12.00000000 -> 1
+ddcot619 comparetotal 12.1234 12.000000000 -> 1
+ddcot620 comparetotal -12 -12.2345 -> 1
+ddcot621 comparetotal -12.0 -12.2345 -> 1
+ddcot622 comparetotal -12.00 -12.2345 -> 1
+ddcot623 comparetotal -12.000 -12.2345 -> 1
+ddcot624 comparetotal -12.0000 -12.2345 -> 1
+ddcot625 comparetotal -12.00000 -12.2345 -> 1
+ddcot626 comparetotal -12.000000 -12.2345 -> 1
+ddcot627 comparetotal -12.0000000 -12.2345 -> 1
+ddcot628 comparetotal -12.00000000 -12.2345 -> 1
+ddcot629 comparetotal -12.000000000 -12.2345 -> 1
+ddcot630 comparetotal -12.1234 -12 -> -1
+ddcot631 comparetotal -12.1234 -12.0 -> -1
+ddcot632 comparetotal -12.1234 -12.00 -> -1
+ddcot633 comparetotal -12.1234 -12.000 -> -1
+ddcot634 comparetotal -12.1234 -12.0000 -> -1
+ddcot635 comparetotal -12.1234 -12.00000 -> -1
+ddcot636 comparetotal -12.1234 -12.000000 -> -1
+ddcot637 comparetotal -12.1234 -12.0000000 -> -1
+ddcot638 comparetotal -12.1234 -12.00000000 -> -1
+ddcot639 comparetotal -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+ddcot640 comparetotal 0 0 -> 0
+ddcot641 comparetotal 0 -0 -> 1
+ddcot642 comparetotal 0 -0.0 -> 1
+ddcot643 comparetotal 0 0.0 -> 1
+ddcot644 comparetotal -0 0 -> -1
+ddcot645 comparetotal -0 -0 -> 0
+ddcot646 comparetotal -0 -0.0 -> -1
+ddcot647 comparetotal -0 0.0 -> -1
+ddcot648 comparetotal 0.0 0 -> -1
+ddcot649 comparetotal 0.0 -0 -> 1
+ddcot650 comparetotal 0.0 -0.0 -> 1
+ddcot651 comparetotal 0.0 0.0 -> 0
+ddcot652 comparetotal -0.0 0 -> -1
+ddcot653 comparetotal -0.0 -0 -> 1
+ddcot654 comparetotal -0.0 -0.0 -> 0
+ddcot655 comparetotal -0.0 0.0 -> -1
+
+ddcot656 comparetotal -0E1 0.0 -> -1
+ddcot657 comparetotal -0E2 0.0 -> -1
+ddcot658 comparetotal 0E1 0.0 -> 1
+ddcot659 comparetotal 0E2 0.0 -> 1
+ddcot660 comparetotal -0E1 0 -> -1
+ddcot661 comparetotal -0E2 0 -> -1
+ddcot662 comparetotal 0E1 0 -> 1
+ddcot663 comparetotal 0E2 0 -> 1
+ddcot664 comparetotal -0E1 -0E1 -> 0
+ddcot665 comparetotal -0E2 -0E1 -> -1
+ddcot666 comparetotal 0E1 -0E1 -> 1
+ddcot667 comparetotal 0E2 -0E1 -> 1
+ddcot668 comparetotal -0E1 -0E2 -> 1
+ddcot669 comparetotal -0E2 -0E2 -> 0
+ddcot670 comparetotal 0E1 -0E2 -> 1
+ddcot671 comparetotal 0E2 -0E2 -> 1
+ddcot672 comparetotal -0E1 0E1 -> -1
+ddcot673 comparetotal -0E2 0E1 -> -1
+ddcot674 comparetotal 0E1 0E1 -> 0
+ddcot675 comparetotal 0E2 0E1 -> 1
+ddcot676 comparetotal -0E1 0E2 -> -1
+ddcot677 comparetotal -0E2 0E2 -> -1
+ddcot678 comparetotal 0E1 0E2 -> -1
+ddcot679 comparetotal 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+ddcot680 comparetotal 12 12 -> 0
+ddcot681 comparetotal 12 12.0 -> 1
+ddcot682 comparetotal 12 12.00 -> 1
+ddcot683 comparetotal 12 12.000 -> 1
+ddcot684 comparetotal 12 12.0000 -> 1
+ddcot685 comparetotal 12 12.00000 -> 1
+ddcot686 comparetotal 12 12.000000 -> 1
+ddcot687 comparetotal 12 12.0000000 -> 1
+ddcot688 comparetotal 12 12.00000000 -> 1
+ddcot689 comparetotal 12 12.000000000 -> 1
+ddcot690 comparetotal 12 12 -> 0
+ddcot691 comparetotal 12.0 12 -> -1
+ddcot692 comparetotal 12.00 12 -> -1
+ddcot693 comparetotal 12.000 12 -> -1
+ddcot694 comparetotal 12.0000 12 -> -1
+ddcot695 comparetotal 12.00000 12 -> -1
+ddcot696 comparetotal 12.000000 12 -> -1
+ddcot697 comparetotal 12.0000000 12 -> -1
+ddcot698 comparetotal 12.00000000 12 -> -1
+ddcot699 comparetotal 12.000000000 12 -> -1
+
+-- old long operand checks
+ddcot701 comparetotal 12345678000 1 -> 1
+ddcot702 comparetotal 1 12345678000 -> -1
+ddcot703 comparetotal 1234567800 1 -> 1
+ddcot704 comparetotal 1 1234567800 -> -1
+ddcot705 comparetotal 1234567890 1 -> 1
+ddcot706 comparetotal 1 1234567890 -> -1
+ddcot707 comparetotal 1234567891 1 -> 1
+ddcot708 comparetotal 1 1234567891 -> -1
+ddcot709 comparetotal 12345678901 1 -> 1
+ddcot710 comparetotal 1 12345678901 -> -1
+ddcot711 comparetotal 1234567896 1 -> 1
+ddcot712 comparetotal 1 1234567896 -> -1
+ddcot713 comparetotal -1234567891 1 -> -1
+ddcot714 comparetotal 1 -1234567891 -> 1
+ddcot715 comparetotal -12345678901 1 -> -1
+ddcot716 comparetotal 1 -12345678901 -> 1
+ddcot717 comparetotal -1234567896 1 -> -1
+ddcot718 comparetotal 1 -1234567896 -> 1
+
+-- old residue cases
+ddcot740 comparetotal 1 0.9999999 -> 1
+ddcot741 comparetotal 1 0.999999 -> 1
+ddcot742 comparetotal 1 0.99999 -> 1
+ddcot743 comparetotal 1 1.0000 -> 1
+ddcot744 comparetotal 1 1.00001 -> -1
+ddcot745 comparetotal 1 1.000001 -> -1
+ddcot746 comparetotal 1 1.0000001 -> -1
+ddcot750 comparetotal 0.9999999 1 -> -1
+ddcot751 comparetotal 0.999999 1 -> -1
+ddcot752 comparetotal 0.99999 1 -> -1
+ddcot753 comparetotal 1.0000 1 -> -1
+ddcot754 comparetotal 1.00001 1 -> 1
+ddcot755 comparetotal 1.000001 1 -> 1
+ddcot756 comparetotal 1.0000001 1 -> 1
+
+-- Specials
+ddcot780 comparetotal Inf -Inf -> 1
+ddcot781 comparetotal Inf -1000 -> 1
+ddcot782 comparetotal Inf -1 -> 1
+ddcot783 comparetotal Inf -0 -> 1
+ddcot784 comparetotal Inf 0 -> 1
+ddcot785 comparetotal Inf 1 -> 1
+ddcot786 comparetotal Inf 1000 -> 1
+ddcot787 comparetotal Inf Inf -> 0
+ddcot788 comparetotal -1000 Inf -> -1
+ddcot789 comparetotal -Inf Inf -> -1
+ddcot790 comparetotal -1 Inf -> -1
+ddcot791 comparetotal -0 Inf -> -1
+ddcot792 comparetotal 0 Inf -> -1
+ddcot793 comparetotal 1 Inf -> -1
+ddcot794 comparetotal 1000 Inf -> -1
+ddcot795 comparetotal Inf Inf -> 0
+
+ddcot800 comparetotal -Inf -Inf -> 0
+ddcot801 comparetotal -Inf -1000 -> -1
+ddcot802 comparetotal -Inf -1 -> -1
+ddcot803 comparetotal -Inf -0 -> -1
+ddcot804 comparetotal -Inf 0 -> -1
+ddcot805 comparetotal -Inf 1 -> -1
+ddcot806 comparetotal -Inf 1000 -> -1
+ddcot807 comparetotal -Inf Inf -> -1
+ddcot808 comparetotal -Inf -Inf -> 0
+ddcot809 comparetotal -1000 -Inf -> 1
+ddcot810 comparetotal -1 -Inf -> 1
+ddcot811 comparetotal -0 -Inf -> 1
+ddcot812 comparetotal 0 -Inf -> 1
+ddcot813 comparetotal 1 -Inf -> 1
+ddcot814 comparetotal 1000 -Inf -> 1
+ddcot815 comparetotal Inf -Inf -> 1
+
+ddcot821 comparetotal NaN -Inf -> 1
+ddcot822 comparetotal NaN -1000 -> 1
+ddcot823 comparetotal NaN -1 -> 1
+ddcot824 comparetotal NaN -0 -> 1
+ddcot825 comparetotal NaN 0 -> 1
+ddcot826 comparetotal NaN 1 -> 1
+ddcot827 comparetotal NaN 1000 -> 1
+ddcot828 comparetotal NaN Inf -> 1
+ddcot829 comparetotal NaN NaN -> 0
+ddcot830 comparetotal -Inf NaN -> -1
+ddcot831 comparetotal -1000 NaN -> -1
+ddcot832 comparetotal -1 NaN -> -1
+ddcot833 comparetotal -0 NaN -> -1
+ddcot834 comparetotal 0 NaN -> -1
+ddcot835 comparetotal 1 NaN -> -1
+ddcot836 comparetotal 1000 NaN -> -1
+ddcot837 comparetotal Inf NaN -> -1
+ddcot838 comparetotal -NaN -NaN -> 0
+ddcot839 comparetotal +NaN -NaN -> 1
+ddcot840 comparetotal -NaN +NaN -> -1
+
+ddcot841 comparetotal sNaN -sNaN -> 1
+ddcot842 comparetotal sNaN -NaN -> 1
+ddcot843 comparetotal sNaN -Inf -> 1
+ddcot844 comparetotal sNaN -1000 -> 1
+ddcot845 comparetotal sNaN -1 -> 1
+ddcot846 comparetotal sNaN -0 -> 1
+ddcot847 comparetotal sNaN 0 -> 1
+ddcot848 comparetotal sNaN 1 -> 1
+ddcot849 comparetotal sNaN 1000 -> 1
+ddcot850 comparetotal sNaN NaN -> -1
+ddcot851 comparetotal sNaN sNaN -> 0
+
+ddcot852 comparetotal -sNaN sNaN -> -1
+ddcot853 comparetotal -NaN sNaN -> -1
+ddcot854 comparetotal -Inf sNaN -> -1
+ddcot855 comparetotal -1000 sNaN -> -1
+ddcot856 comparetotal -1 sNaN -> -1
+ddcot857 comparetotal -0 sNaN -> -1
+ddcot858 comparetotal 0 sNaN -> -1
+ddcot859 comparetotal 1 sNaN -> -1
+ddcot860 comparetotal 1000 sNaN -> -1
+ddcot861 comparetotal Inf sNaN -> -1
+ddcot862 comparetotal NaN sNaN -> 1
+ddcot863 comparetotal sNaN sNaN -> 0
+
+ddcot871 comparetotal -sNaN -sNaN -> 0
+ddcot872 comparetotal -sNaN -NaN -> 1
+ddcot873 comparetotal -sNaN -Inf -> -1
+ddcot874 comparetotal -sNaN -1000 -> -1
+ddcot875 comparetotal -sNaN -1 -> -1
+ddcot876 comparetotal -sNaN -0 -> -1
+ddcot877 comparetotal -sNaN 0 -> -1
+ddcot878 comparetotal -sNaN 1 -> -1
+ddcot879 comparetotal -sNaN 1000 -> -1
+ddcot880 comparetotal -sNaN NaN -> -1
+ddcot881 comparetotal -sNaN sNaN -> -1
+
+ddcot882 comparetotal -sNaN -sNaN -> 0
+ddcot883 comparetotal -NaN -sNaN -> -1
+ddcot884 comparetotal -Inf -sNaN -> 1
+ddcot885 comparetotal -1000 -sNaN -> 1
+ddcot886 comparetotal -1 -sNaN -> 1
+ddcot887 comparetotal -0 -sNaN -> 1
+ddcot888 comparetotal 0 -sNaN -> 1
+ddcot889 comparetotal 1 -sNaN -> 1
+ddcot890 comparetotal 1000 -sNaN -> 1
+ddcot891 comparetotal Inf -sNaN -> 1
+ddcot892 comparetotal NaN -sNaN -> 1
+ddcot893 comparetotal sNaN -sNaN -> 1
+
+-- NaNs with payload
+ddcot960 comparetotal NaN9 -Inf -> 1
+ddcot961 comparetotal NaN8 999 -> 1
+ddcot962 comparetotal NaN77 Inf -> 1
+ddcot963 comparetotal -NaN67 NaN5 -> -1
+ddcot964 comparetotal -Inf -NaN4 -> 1
+ddcot965 comparetotal -999 -NaN33 -> 1
+ddcot966 comparetotal Inf NaN2 -> -1
+
+ddcot970 comparetotal -NaN41 -NaN42 -> 1
+ddcot971 comparetotal +NaN41 -NaN42 -> 1
+ddcot972 comparetotal -NaN41 +NaN42 -> -1
+ddcot973 comparetotal +NaN41 +NaN42 -> -1
+ddcot974 comparetotal -NaN42 -NaN01 -> -1
+ddcot975 comparetotal +NaN42 -NaN01 -> 1
+ddcot976 comparetotal -NaN42 +NaN01 -> -1
+ddcot977 comparetotal +NaN42 +NaN01 -> 1
+
+ddcot980 comparetotal -sNaN771 -sNaN772 -> 1
+ddcot981 comparetotal +sNaN771 -sNaN772 -> 1
+ddcot982 comparetotal -sNaN771 +sNaN772 -> -1
+ddcot983 comparetotal +sNaN771 +sNaN772 -> -1
+ddcot984 comparetotal -sNaN772 -sNaN771 -> -1
+ddcot985 comparetotal +sNaN772 -sNaN771 -> 1
+ddcot986 comparetotal -sNaN772 +sNaN771 -> -1
+ddcot987 comparetotal +sNaN772 +sNaN771 -> 1
+
+ddcot991 comparetotal -sNaN99 -Inf -> -1
+ddcot992 comparetotal sNaN98 -11 -> 1
+ddcot993 comparetotal sNaN97 NaN -> -1
+ddcot994 comparetotal sNaN16 sNaN94 -> -1
+ddcot995 comparetotal NaN85 sNaN83 -> 1
+ddcot996 comparetotal -Inf sNaN92 -> -1
+ddcot997 comparetotal 088 sNaN81 -> -1
+ddcot998 comparetotal Inf sNaN90 -> -1
+ddcot999 comparetotal NaN -sNaN89 -> 1
+
+-- spread zeros
+ddcot1110 comparetotal 0E-383 0 -> -1
+ddcot1111 comparetotal 0E-383 -0 -> 1
+ddcot1112 comparetotal -0E-383 0 -> -1
+ddcot1113 comparetotal -0E-383 -0 -> 1
+ddcot1114 comparetotal 0E-383 0E+384 -> -1
+ddcot1115 comparetotal 0E-383 -0E+384 -> 1
+ddcot1116 comparetotal -0E-383 0E+384 -> -1
+ddcot1117 comparetotal -0E-383 -0E+384 -> 1
+ddcot1118 comparetotal 0 0E+384 -> -1
+ddcot1119 comparetotal 0 -0E+384 -> 1
+ddcot1120 comparetotal -0 0E+384 -> -1
+ddcot1121 comparetotal -0 -0E+384 -> 1
+
+ddcot1130 comparetotal 0E+384 0 -> 1
+ddcot1131 comparetotal 0E+384 -0 -> 1
+ddcot1132 comparetotal -0E+384 0 -> -1
+ddcot1133 comparetotal -0E+384 -0 -> -1
+ddcot1134 comparetotal 0E+384 0E-383 -> 1
+ddcot1135 comparetotal 0E+384 -0E-383 -> 1
+ddcot1136 comparetotal -0E+384 0E-383 -> -1
+ddcot1137 comparetotal -0E+384 -0E-383 -> -1
+ddcot1138 comparetotal 0 0E-383 -> 1
+ddcot1139 comparetotal 0 -0E-383 -> 1
+ddcot1140 comparetotal -0 0E-383 -> -1
+ddcot1141 comparetotal -0 -0E-383 -> -1
+
+-- Null tests
+ddcot9990 comparetotal 10 # -> NaN Invalid_operation
+ddcot9991 comparetotal # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddCompareTotalMag.decTest b/Lib/test/decimaltestdata/ddCompareTotalMag.decTest
index 087a092f0b..f16537a35d 100644
--- a/Lib/test/decimaltestdata/ddCompareTotalMag.decTest
+++ b/Lib/test/decimaltestdata/ddCompareTotalMag.decTest
@@ -1,706 +1,706 @@
-------------------------------------------------------------------------
--- ddCompareTotalMag.decTest -- decDouble comparison; abs. total order--
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddctm001 comparetotmag -2 -2 -> 0
-ddctm002 comparetotmag -2 -1 -> 1
-ddctm003 comparetotmag -2 0 -> 1
-ddctm004 comparetotmag -2 1 -> 1
-ddctm005 comparetotmag -2 2 -> 0
-ddctm006 comparetotmag -1 -2 -> -1
-ddctm007 comparetotmag -1 -1 -> 0
-ddctm008 comparetotmag -1 0 -> 1
-ddctm009 comparetotmag -1 1 -> 0
-ddctm010 comparetotmag -1 2 -> -1
-ddctm011 comparetotmag 0 -2 -> -1
-ddctm012 comparetotmag 0 -1 -> -1
-ddctm013 comparetotmag 0 0 -> 0
-ddctm014 comparetotmag 0 1 -> -1
-ddctm015 comparetotmag 0 2 -> -1
-ddctm016 comparetotmag 1 -2 -> -1
-ddctm017 comparetotmag 1 -1 -> 0
-ddctm018 comparetotmag 1 0 -> 1
-ddctm019 comparetotmag 1 1 -> 0
-ddctm020 comparetotmag 1 2 -> -1
-ddctm021 comparetotmag 2 -2 -> 0
-ddctm022 comparetotmag 2 -1 -> 1
-ddctm023 comparetotmag 2 0 -> 1
-ddctm025 comparetotmag 2 1 -> 1
-ddctm026 comparetotmag 2 2 -> 0
-
-ddctm031 comparetotmag -20 -20 -> 0
-ddctm032 comparetotmag -20 -10 -> 1
-ddctm033 comparetotmag -20 00 -> 1
-ddctm034 comparetotmag -20 10 -> 1
-ddctm035 comparetotmag -20 20 -> 0
-ddctm036 comparetotmag -10 -20 -> -1
-ddctm037 comparetotmag -10 -10 -> 0
-ddctm038 comparetotmag -10 00 -> 1
-ddctm039 comparetotmag -10 10 -> 0
-ddctm040 comparetotmag -10 20 -> -1
-ddctm041 comparetotmag 00 -20 -> -1
-ddctm042 comparetotmag 00 -10 -> -1
-ddctm043 comparetotmag 00 00 -> 0
-ddctm044 comparetotmag 00 10 -> -1
-ddctm045 comparetotmag 00 20 -> -1
-ddctm046 comparetotmag 10 -20 -> -1
-ddctm047 comparetotmag 10 -10 -> 0
-ddctm048 comparetotmag 10 00 -> 1
-ddctm049 comparetotmag 10 10 -> 0
-ddctm050 comparetotmag 10 20 -> -1
-ddctm051 comparetotmag 20 -20 -> 0
-ddctm052 comparetotmag 20 -10 -> 1
-ddctm053 comparetotmag 20 00 -> 1
-ddctm055 comparetotmag 20 10 -> 1
-ddctm056 comparetotmag 20 20 -> 0
-
-ddctm061 comparetotmag -2.0 -2.0 -> 0
-ddctm062 comparetotmag -2.0 -1.0 -> 1
-ddctm063 comparetotmag -2.0 0.0 -> 1
-ddctm064 comparetotmag -2.0 1.0 -> 1
-ddctm065 comparetotmag -2.0 2.0 -> 0
-ddctm066 comparetotmag -1.0 -2.0 -> -1
-ddctm067 comparetotmag -1.0 -1.0 -> 0
-ddctm068 comparetotmag -1.0 0.0 -> 1
-ddctm069 comparetotmag -1.0 1.0 -> 0
-ddctm070 comparetotmag -1.0 2.0 -> -1
-ddctm071 comparetotmag 0.0 -2.0 -> -1
-ddctm072 comparetotmag 0.0 -1.0 -> -1
-ddctm073 comparetotmag 0.0 0.0 -> 0
-ddctm074 comparetotmag 0.0 1.0 -> -1
-ddctm075 comparetotmag 0.0 2.0 -> -1
-ddctm076 comparetotmag 1.0 -2.0 -> -1
-ddctm077 comparetotmag 1.0 -1.0 -> 0
-ddctm078 comparetotmag 1.0 0.0 -> 1
-ddctm079 comparetotmag 1.0 1.0 -> 0
-ddctm080 comparetotmag 1.0 2.0 -> -1
-ddctm081 comparetotmag 2.0 -2.0 -> 0
-ddctm082 comparetotmag 2.0 -1.0 -> 1
-ddctm083 comparetotmag 2.0 0.0 -> 1
-ddctm085 comparetotmag 2.0 1.0 -> 1
-ddctm086 comparetotmag 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-ddctm090 comparetotmag 9.99999999E+384 9.99999999E+384 -> 0
-ddctm091 comparetotmag -9.99999999E+384 9.99999999E+384 -> 0
-ddctm092 comparetotmag 9.99999999E+384 -9.99999999E+384 -> 0
-ddctm093 comparetotmag -9.99999999E+384 -9.99999999E+384 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-ddctm100 comparetotmag 7.0 7.0 -> 0
-ddctm101 comparetotmag 7.0 7 -> -1
-ddctm102 comparetotmag 7 7.0 -> 1
-ddctm103 comparetotmag 7E+0 7.0 -> 1
-ddctm104 comparetotmag 70E-1 7.0 -> 0
-ddctm105 comparetotmag 0.7E+1 7 -> 0
-ddctm106 comparetotmag 70E-1 7 -> -1
-ddctm107 comparetotmag 7.0 7E+0 -> -1
-ddctm108 comparetotmag 7.0 70E-1 -> 0
-ddctm109 comparetotmag 7 0.7E+1 -> 0
-ddctm110 comparetotmag 7 70E-1 -> 1
-
-ddctm120 comparetotmag 8.0 7.0 -> 1
-ddctm121 comparetotmag 8.0 7 -> 1
-ddctm122 comparetotmag 8 7.0 -> 1
-ddctm123 comparetotmag 8E+0 7.0 -> 1
-ddctm124 comparetotmag 80E-1 7.0 -> 1
-ddctm125 comparetotmag 0.8E+1 7 -> 1
-ddctm126 comparetotmag 80E-1 7 -> 1
-ddctm127 comparetotmag 8.0 7E+0 -> 1
-ddctm128 comparetotmag 8.0 70E-1 -> 1
-ddctm129 comparetotmag 8 0.7E+1 -> 1
-ddctm130 comparetotmag 8 70E-1 -> 1
-
-ddctm140 comparetotmag 8.0 9.0 -> -1
-ddctm141 comparetotmag 8.0 9 -> -1
-ddctm142 comparetotmag 8 9.0 -> -1
-ddctm143 comparetotmag 8E+0 9.0 -> -1
-ddctm144 comparetotmag 80E-1 9.0 -> -1
-ddctm145 comparetotmag 0.8E+1 9 -> -1
-ddctm146 comparetotmag 80E-1 9 -> -1
-ddctm147 comparetotmag 8.0 9E+0 -> -1
-ddctm148 comparetotmag 8.0 90E-1 -> -1
-ddctm149 comparetotmag 8 0.9E+1 -> -1
-ddctm150 comparetotmag 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ddctm200 comparetotmag -7.0 7.0 -> 0
-ddctm201 comparetotmag -7.0 7 -> -1
-ddctm202 comparetotmag -7 7.0 -> 1
-ddctm203 comparetotmag -7E+0 7.0 -> 1
-ddctm204 comparetotmag -70E-1 7.0 -> 0
-ddctm205 comparetotmag -0.7E+1 7 -> 0
-ddctm206 comparetotmag -70E-1 7 -> -1
-ddctm207 comparetotmag -7.0 7E+0 -> -1
-ddctm208 comparetotmag -7.0 70E-1 -> 0
-ddctm209 comparetotmag -7 0.7E+1 -> 0
-ddctm210 comparetotmag -7 70E-1 -> 1
-
-ddctm220 comparetotmag -8.0 7.0 -> 1
-ddctm221 comparetotmag -8.0 7 -> 1
-ddctm222 comparetotmag -8 7.0 -> 1
-ddctm223 comparetotmag -8E+0 7.0 -> 1
-ddctm224 comparetotmag -80E-1 7.0 -> 1
-ddctm225 comparetotmag -0.8E+1 7 -> 1
-ddctm226 comparetotmag -80E-1 7 -> 1
-ddctm227 comparetotmag -8.0 7E+0 -> 1
-ddctm228 comparetotmag -8.0 70E-1 -> 1
-ddctm229 comparetotmag -8 0.7E+1 -> 1
-ddctm230 comparetotmag -8 70E-1 -> 1
-
-ddctm240 comparetotmag -8.0 9.0 -> -1
-ddctm241 comparetotmag -8.0 9 -> -1
-ddctm242 comparetotmag -8 9.0 -> -1
-ddctm243 comparetotmag -8E+0 9.0 -> -1
-ddctm244 comparetotmag -80E-1 9.0 -> -1
-ddctm245 comparetotmag -0.8E+1 9 -> -1
-ddctm246 comparetotmag -80E-1 9 -> -1
-ddctm247 comparetotmag -8.0 9E+0 -> -1
-ddctm248 comparetotmag -8.0 90E-1 -> -1
-ddctm249 comparetotmag -8 0.9E+1 -> -1
-ddctm250 comparetotmag -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ddctm300 comparetotmag 7.0 -7.0 -> 0
-ddctm301 comparetotmag 7.0 -7 -> -1
-ddctm302 comparetotmag 7 -7.0 -> 1
-ddctm303 comparetotmag 7E+0 -7.0 -> 1
-ddctm304 comparetotmag 70E-1 -7.0 -> 0
-ddctm305 comparetotmag .7E+1 -7 -> 0
-ddctm306 comparetotmag 70E-1 -7 -> -1
-ddctm307 comparetotmag 7.0 -7E+0 -> -1
-ddctm308 comparetotmag 7.0 -70E-1 -> 0
-ddctm309 comparetotmag 7 -.7E+1 -> 0
-ddctm310 comparetotmag 7 -70E-1 -> 1
-
-ddctm320 comparetotmag 8.0 -7.0 -> 1
-ddctm321 comparetotmag 8.0 -7 -> 1
-ddctm322 comparetotmag 8 -7.0 -> 1
-ddctm323 comparetotmag 8E+0 -7.0 -> 1
-ddctm324 comparetotmag 80E-1 -7.0 -> 1
-ddctm325 comparetotmag .8E+1 -7 -> 1
-ddctm326 comparetotmag 80E-1 -7 -> 1
-ddctm327 comparetotmag 8.0 -7E+0 -> 1
-ddctm328 comparetotmag 8.0 -70E-1 -> 1
-ddctm329 comparetotmag 8 -.7E+1 -> 1
-ddctm330 comparetotmag 8 -70E-1 -> 1
-
-ddctm340 comparetotmag 8.0 -9.0 -> -1
-ddctm341 comparetotmag 8.0 -9 -> -1
-ddctm342 comparetotmag 8 -9.0 -> -1
-ddctm343 comparetotmag 8E+0 -9.0 -> -1
-ddctm344 comparetotmag 80E-1 -9.0 -> -1
-ddctm345 comparetotmag .8E+1 -9 -> -1
-ddctm346 comparetotmag 80E-1 -9 -> -1
-ddctm347 comparetotmag 8.0 -9E+0 -> -1
-ddctm348 comparetotmag 8.0 -90E-1 -> -1
-ddctm349 comparetotmag 8 -.9E+1 -> -1
-ddctm350 comparetotmag 8 -90E-1 -> -1
-
--- and again, with sign changes -- ..
-ddctm400 comparetotmag -7.0 -7.0 -> 0
-ddctm401 comparetotmag -7.0 -7 -> -1
-ddctm402 comparetotmag -7 -7.0 -> 1
-ddctm403 comparetotmag -7E+0 -7.0 -> 1
-ddctm404 comparetotmag -70E-1 -7.0 -> 0
-ddctm405 comparetotmag -.7E+1 -7 -> 0
-ddctm406 comparetotmag -70E-1 -7 -> -1
-ddctm407 comparetotmag -7.0 -7E+0 -> -1
-ddctm408 comparetotmag -7.0 -70E-1 -> 0
-ddctm409 comparetotmag -7 -.7E+1 -> 0
-ddctm410 comparetotmag -7 -70E-1 -> 1
-
-ddctm420 comparetotmag -8.0 -7.0 -> 1
-ddctm421 comparetotmag -8.0 -7 -> 1
-ddctm422 comparetotmag -8 -7.0 -> 1
-ddctm423 comparetotmag -8E+0 -7.0 -> 1
-ddctm424 comparetotmag -80E-1 -7.0 -> 1
-ddctm425 comparetotmag -.8E+1 -7 -> 1
-ddctm426 comparetotmag -80E-1 -7 -> 1
-ddctm427 comparetotmag -8.0 -7E+0 -> 1
-ddctm428 comparetotmag -8.0 -70E-1 -> 1
-ddctm429 comparetotmag -8 -.7E+1 -> 1
-ddctm430 comparetotmag -8 -70E-1 -> 1
-
-ddctm440 comparetotmag -8.0 -9.0 -> -1
-ddctm441 comparetotmag -8.0 -9 -> -1
-ddctm442 comparetotmag -8 -9.0 -> -1
-ddctm443 comparetotmag -8E+0 -9.0 -> -1
-ddctm444 comparetotmag -80E-1 -9.0 -> -1
-ddctm445 comparetotmag -.8E+1 -9 -> -1
-ddctm446 comparetotmag -80E-1 -9 -> -1
-ddctm447 comparetotmag -8.0 -9E+0 -> -1
-ddctm448 comparetotmag -8.0 -90E-1 -> -1
-ddctm449 comparetotmag -8 -.9E+1 -> -1
-ddctm450 comparetotmag -8 -90E-1 -> -1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-ddctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
-ddctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
-ddctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
-ddctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
-ddctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
-ddctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
-ddctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
-ddctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
-ddctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
-ddctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
-ddctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
-ddctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
-ddctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
-ddctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
-ddctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
-ddctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
-ddctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
-ddctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
-ddctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
-ddctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
-ddctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
-ddctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-ddctm498 comparetotmag 1 1E-17 -> 1
-ddctm499 comparetotmag 1 1E-16 -> 1
-ddctm500 comparetotmag 1 1E-15 -> 1
-ddctm501 comparetotmag 1 1E-14 -> 1
-ddctm502 comparetotmag 1 1E-13 -> 1
-ddctm503 comparetotmag 1 1E-12 -> 1
-ddctm504 comparetotmag 1 1E-11 -> 1
-ddctm505 comparetotmag 1 1E-10 -> 1
-ddctm506 comparetotmag 1 1E-9 -> 1
-ddctm507 comparetotmag 1 1E-8 -> 1
-ddctm508 comparetotmag 1 1E-7 -> 1
-ddctm509 comparetotmag 1 1E-6 -> 1
-ddctm510 comparetotmag 1 1E-5 -> 1
-ddctm511 comparetotmag 1 1E-4 -> 1
-ddctm512 comparetotmag 1 1E-3 -> 1
-ddctm513 comparetotmag 1 1E-2 -> 1
-ddctm514 comparetotmag 1 1E-1 -> 1
-ddctm515 comparetotmag 1 1E-0 -> 0
-ddctm516 comparetotmag 1 1E+1 -> -1
-ddctm517 comparetotmag 1 1E+2 -> -1
-ddctm518 comparetotmag 1 1E+3 -> -1
-ddctm519 comparetotmag 1 1E+4 -> -1
-ddctm521 comparetotmag 1 1E+5 -> -1
-ddctm522 comparetotmag 1 1E+6 -> -1
-ddctm523 comparetotmag 1 1E+7 -> -1
-ddctm524 comparetotmag 1 1E+8 -> -1
-ddctm525 comparetotmag 1 1E+9 -> -1
-ddctm526 comparetotmag 1 1E+10 -> -1
-ddctm527 comparetotmag 1 1E+11 -> -1
-ddctm528 comparetotmag 1 1E+12 -> -1
-ddctm529 comparetotmag 1 1E+13 -> -1
-ddctm530 comparetotmag 1 1E+14 -> -1
-ddctm531 comparetotmag 1 1E+15 -> -1
-ddctm532 comparetotmag 1 1E+16 -> -1
-ddctm533 comparetotmag 1 1E+17 -> -1
--- LR swap
-ddctm538 comparetotmag 1E-17 1 -> -1
-ddctm539 comparetotmag 1E-16 1 -> -1
-ddctm540 comparetotmag 1E-15 1 -> -1
-ddctm541 comparetotmag 1E-14 1 -> -1
-ddctm542 comparetotmag 1E-13 1 -> -1
-ddctm543 comparetotmag 1E-12 1 -> -1
-ddctm544 comparetotmag 1E-11 1 -> -1
-ddctm545 comparetotmag 1E-10 1 -> -1
-ddctm546 comparetotmag 1E-9 1 -> -1
-ddctm547 comparetotmag 1E-8 1 -> -1
-ddctm548 comparetotmag 1E-7 1 -> -1
-ddctm549 comparetotmag 1E-6 1 -> -1
-ddctm550 comparetotmag 1E-5 1 -> -1
-ddctm551 comparetotmag 1E-4 1 -> -1
-ddctm552 comparetotmag 1E-3 1 -> -1
-ddctm553 comparetotmag 1E-2 1 -> -1
-ddctm554 comparetotmag 1E-1 1 -> -1
-ddctm555 comparetotmag 1E-0 1 -> 0
-ddctm556 comparetotmag 1E+1 1 -> 1
-ddctm557 comparetotmag 1E+2 1 -> 1
-ddctm558 comparetotmag 1E+3 1 -> 1
-ddctm559 comparetotmag 1E+4 1 -> 1
-ddctm561 comparetotmag 1E+5 1 -> 1
-ddctm562 comparetotmag 1E+6 1 -> 1
-ddctm563 comparetotmag 1E+7 1 -> 1
-ddctm564 comparetotmag 1E+8 1 -> 1
-ddctm565 comparetotmag 1E+9 1 -> 1
-ddctm566 comparetotmag 1E+10 1 -> 1
-ddctm567 comparetotmag 1E+11 1 -> 1
-ddctm568 comparetotmag 1E+12 1 -> 1
-ddctm569 comparetotmag 1E+13 1 -> 1
-ddctm570 comparetotmag 1E+14 1 -> 1
-ddctm571 comparetotmag 1E+15 1 -> 1
-ddctm572 comparetotmag 1E+16 1 -> 1
-ddctm573 comparetotmag 1E+17 1 -> 1
--- similar with a useful coefficient, one side only
-ddctm578 comparetotmag 0.000000987654321 1E-17 -> 1
-ddctm579 comparetotmag 0.000000987654321 1E-16 -> 1
-ddctm580 comparetotmag 0.000000987654321 1E-15 -> 1
-ddctm581 comparetotmag 0.000000987654321 1E-14 -> 1
-ddctm582 comparetotmag 0.000000987654321 1E-13 -> 1
-ddctm583 comparetotmag 0.000000987654321 1E-12 -> 1
-ddctm584 comparetotmag 0.000000987654321 1E-11 -> 1
-ddctm585 comparetotmag 0.000000987654321 1E-10 -> 1
-ddctm586 comparetotmag 0.000000987654321 1E-9 -> 1
-ddctm587 comparetotmag 0.000000987654321 1E-8 -> 1
-ddctm588 comparetotmag 0.000000987654321 1E-7 -> 1
-ddctm589 comparetotmag 0.000000987654321 1E-6 -> -1
-ddctm590 comparetotmag 0.000000987654321 1E-5 -> -1
-ddctm591 comparetotmag 0.000000987654321 1E-4 -> -1
-ddctm592 comparetotmag 0.000000987654321 1E-3 -> -1
-ddctm593 comparetotmag 0.000000987654321 1E-2 -> -1
-ddctm594 comparetotmag 0.000000987654321 1E-1 -> -1
-ddctm595 comparetotmag 0.000000987654321 1E-0 -> -1
-ddctm596 comparetotmag 0.000000987654321 1E+1 -> -1
-ddctm597 comparetotmag 0.000000987654321 1E+2 -> -1
-ddctm598 comparetotmag 0.000000987654321 1E+3 -> -1
-ddctm599 comparetotmag 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-ddctm600 comparetotmag 12 12.2345 -> -1
-ddctm601 comparetotmag 12.0 12.2345 -> -1
-ddctm602 comparetotmag 12.00 12.2345 -> -1
-ddctm603 comparetotmag 12.000 12.2345 -> -1
-ddctm604 comparetotmag 12.0000 12.2345 -> -1
-ddctm605 comparetotmag 12.00000 12.2345 -> -1
-ddctm606 comparetotmag 12.000000 12.2345 -> -1
-ddctm607 comparetotmag 12.0000000 12.2345 -> -1
-ddctm608 comparetotmag 12.00000000 12.2345 -> -1
-ddctm609 comparetotmag 12.000000000 12.2345 -> -1
-ddctm610 comparetotmag 12.1234 12 -> 1
-ddctm611 comparetotmag 12.1234 12.0 -> 1
-ddctm612 comparetotmag 12.1234 12.00 -> 1
-ddctm613 comparetotmag 12.1234 12.000 -> 1
-ddctm614 comparetotmag 12.1234 12.0000 -> 1
-ddctm615 comparetotmag 12.1234 12.00000 -> 1
-ddctm616 comparetotmag 12.1234 12.000000 -> 1
-ddctm617 comparetotmag 12.1234 12.0000000 -> 1
-ddctm618 comparetotmag 12.1234 12.00000000 -> 1
-ddctm619 comparetotmag 12.1234 12.000000000 -> 1
-ddctm620 comparetotmag -12 -12.2345 -> -1
-ddctm621 comparetotmag -12.0 -12.2345 -> -1
-ddctm622 comparetotmag -12.00 -12.2345 -> -1
-ddctm623 comparetotmag -12.000 -12.2345 -> -1
-ddctm624 comparetotmag -12.0000 -12.2345 -> -1
-ddctm625 comparetotmag -12.00000 -12.2345 -> -1
-ddctm626 comparetotmag -12.000000 -12.2345 -> -1
-ddctm627 comparetotmag -12.0000000 -12.2345 -> -1
-ddctm628 comparetotmag -12.00000000 -12.2345 -> -1
-ddctm629 comparetotmag -12.000000000 -12.2345 -> -1
-ddctm630 comparetotmag -12.1234 -12 -> 1
-ddctm631 comparetotmag -12.1234 -12.0 -> 1
-ddctm632 comparetotmag -12.1234 -12.00 -> 1
-ddctm633 comparetotmag -12.1234 -12.000 -> 1
-ddctm634 comparetotmag -12.1234 -12.0000 -> 1
-ddctm635 comparetotmag -12.1234 -12.00000 -> 1
-ddctm636 comparetotmag -12.1234 -12.000000 -> 1
-ddctm637 comparetotmag -12.1234 -12.0000000 -> 1
-ddctm638 comparetotmag -12.1234 -12.00000000 -> 1
-ddctm639 comparetotmag -12.1234 -12.000000000 -> 1
-
--- extended zeros
-ddctm640 comparetotmag 0 0 -> 0
-ddctm641 comparetotmag 0 -0 -> 0
-ddctm642 comparetotmag 0 -0.0 -> 1
-ddctm643 comparetotmag 0 0.0 -> 1
-ddctm644 comparetotmag -0 0 -> 0
-ddctm645 comparetotmag -0 -0 -> 0
-ddctm646 comparetotmag -0 -0.0 -> 1
-ddctm647 comparetotmag -0 0.0 -> 1
-ddctm648 comparetotmag 0.0 0 -> -1
-ddctm649 comparetotmag 0.0 -0 -> -1
-ddctm650 comparetotmag 0.0 -0.0 -> 0
-ddctm651 comparetotmag 0.0 0.0 -> 0
-ddctm652 comparetotmag -0.0 0 -> -1
-ddctm653 comparetotmag -0.0 -0 -> -1
-ddctm654 comparetotmag -0.0 -0.0 -> 0
-ddctm655 comparetotmag -0.0 0.0 -> 0
-
-ddctm656 comparetotmag -0E1 0.0 -> 1
-ddctm657 comparetotmag -0E2 0.0 -> 1
-ddctm658 comparetotmag 0E1 0.0 -> 1
-ddctm659 comparetotmag 0E2 0.0 -> 1
-ddctm660 comparetotmag -0E1 0 -> 1
-ddctm661 comparetotmag -0E2 0 -> 1
-ddctm662 comparetotmag 0E1 0 -> 1
-ddctm663 comparetotmag 0E2 0 -> 1
-ddctm664 comparetotmag -0E1 -0E1 -> 0
-ddctm665 comparetotmag -0E2 -0E1 -> 1
-ddctm666 comparetotmag 0E1 -0E1 -> 0
-ddctm667 comparetotmag 0E2 -0E1 -> 1
-ddctm668 comparetotmag -0E1 -0E2 -> -1
-ddctm669 comparetotmag -0E2 -0E2 -> 0
-ddctm670 comparetotmag 0E1 -0E2 -> -1
-ddctm671 comparetotmag 0E2 -0E2 -> 0
-ddctm672 comparetotmag -0E1 0E1 -> 0
-ddctm673 comparetotmag -0E2 0E1 -> 1
-ddctm674 comparetotmag 0E1 0E1 -> 0
-ddctm675 comparetotmag 0E2 0E1 -> 1
-ddctm676 comparetotmag -0E1 0E2 -> -1
-ddctm677 comparetotmag -0E2 0E2 -> 0
-ddctm678 comparetotmag 0E1 0E2 -> -1
-ddctm679 comparetotmag 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-ddctm680 comparetotmag 12 12 -> 0
-ddctm681 comparetotmag 12 12.0 -> 1
-ddctm682 comparetotmag 12 12.00 -> 1
-ddctm683 comparetotmag 12 12.000 -> 1
-ddctm684 comparetotmag 12 12.0000 -> 1
-ddctm685 comparetotmag 12 12.00000 -> 1
-ddctm686 comparetotmag 12 12.000000 -> 1
-ddctm687 comparetotmag 12 12.0000000 -> 1
-ddctm688 comparetotmag 12 12.00000000 -> 1
-ddctm689 comparetotmag 12 12.000000000 -> 1
-ddctm690 comparetotmag 12 12 -> 0
-ddctm691 comparetotmag 12.0 12 -> -1
-ddctm692 comparetotmag 12.00 12 -> -1
-ddctm693 comparetotmag 12.000 12 -> -1
-ddctm694 comparetotmag 12.0000 12 -> -1
-ddctm695 comparetotmag 12.00000 12 -> -1
-ddctm696 comparetotmag 12.000000 12 -> -1
-ddctm697 comparetotmag 12.0000000 12 -> -1
-ddctm698 comparetotmag 12.00000000 12 -> -1
-ddctm699 comparetotmag 12.000000000 12 -> -1
-
--- old long operand checks
-ddctm701 comparetotmag 12345678000 1 -> 1
-ddctm702 comparetotmag 1 12345678000 -> -1
-ddctm703 comparetotmag 1234567800 1 -> 1
-ddctm704 comparetotmag 1 1234567800 -> -1
-ddctm705 comparetotmag 1234567890 1 -> 1
-ddctm706 comparetotmag 1 1234567890 -> -1
-ddctm707 comparetotmag 1234567891 1 -> 1
-ddctm708 comparetotmag 1 1234567891 -> -1
-ddctm709 comparetotmag 12345678901 1 -> 1
-ddctm710 comparetotmag 1 12345678901 -> -1
-ddctm711 comparetotmag 1234567896 1 -> 1
-ddctm712 comparetotmag 1 1234567896 -> -1
-ddctm713 comparetotmag -1234567891 1 -> 1
-ddctm714 comparetotmag 1 -1234567891 -> -1
-ddctm715 comparetotmag -12345678901 1 -> 1
-ddctm716 comparetotmag 1 -12345678901 -> -1
-ddctm717 comparetotmag -1234567896 1 -> 1
-ddctm718 comparetotmag 1 -1234567896 -> -1
-
--- old residue cases
-ddctm740 comparetotmag 1 0.9999999 -> 1
-ddctm741 comparetotmag 1 0.999999 -> 1
-ddctm742 comparetotmag 1 0.99999 -> 1
-ddctm743 comparetotmag 1 1.0000 -> 1
-ddctm744 comparetotmag 1 1.00001 -> -1
-ddctm745 comparetotmag 1 1.000001 -> -1
-ddctm746 comparetotmag 1 1.0000001 -> -1
-ddctm750 comparetotmag 0.9999999 1 -> -1
-ddctm751 comparetotmag 0.999999 1 -> -1
-ddctm752 comparetotmag 0.99999 1 -> -1
-ddctm753 comparetotmag 1.0000 1 -> -1
-ddctm754 comparetotmag 1.00001 1 -> 1
-ddctm755 comparetotmag 1.000001 1 -> 1
-ddctm756 comparetotmag 1.0000001 1 -> 1
-
--- Specials
-ddctm780 comparetotmag Inf -Inf -> 0
-ddctm781 comparetotmag Inf -1000 -> 1
-ddctm782 comparetotmag Inf -1 -> 1
-ddctm783 comparetotmag Inf -0 -> 1
-ddctm784 comparetotmag Inf 0 -> 1
-ddctm785 comparetotmag Inf 1 -> 1
-ddctm786 comparetotmag Inf 1000 -> 1
-ddctm787 comparetotmag Inf Inf -> 0
-ddctm788 comparetotmag -1000 Inf -> -1
-ddctm789 comparetotmag -Inf Inf -> 0
-ddctm790 comparetotmag -1 Inf -> -1
-ddctm791 comparetotmag -0 Inf -> -1
-ddctm792 comparetotmag 0 Inf -> -1
-ddctm793 comparetotmag 1 Inf -> -1
-ddctm794 comparetotmag 1000 Inf -> -1
-ddctm795 comparetotmag Inf Inf -> 0
-
-ddctm800 comparetotmag -Inf -Inf -> 0
-ddctm801 comparetotmag -Inf -1000 -> 1
-ddctm802 comparetotmag -Inf -1 -> 1
-ddctm803 comparetotmag -Inf -0 -> 1
-ddctm804 comparetotmag -Inf 0 -> 1
-ddctm805 comparetotmag -Inf 1 -> 1
-ddctm806 comparetotmag -Inf 1000 -> 1
-ddctm807 comparetotmag -Inf Inf -> 0
-ddctm808 comparetotmag -Inf -Inf -> 0
-ddctm809 comparetotmag -1000 -Inf -> -1
-ddctm810 comparetotmag -1 -Inf -> -1
-ddctm811 comparetotmag -0 -Inf -> -1
-ddctm812 comparetotmag 0 -Inf -> -1
-ddctm813 comparetotmag 1 -Inf -> -1
-ddctm814 comparetotmag 1000 -Inf -> -1
-ddctm815 comparetotmag Inf -Inf -> 0
-
-ddctm821 comparetotmag NaN -Inf -> 1
-ddctm822 comparetotmag NaN -1000 -> 1
-ddctm823 comparetotmag NaN -1 -> 1
-ddctm824 comparetotmag NaN -0 -> 1
-ddctm825 comparetotmag NaN 0 -> 1
-ddctm826 comparetotmag NaN 1 -> 1
-ddctm827 comparetotmag NaN 1000 -> 1
-ddctm828 comparetotmag NaN Inf -> 1
-ddctm829 comparetotmag NaN NaN -> 0
-ddctm830 comparetotmag -Inf NaN -> -1
-ddctm831 comparetotmag -1000 NaN -> -1
-ddctm832 comparetotmag -1 NaN -> -1
-ddctm833 comparetotmag -0 NaN -> -1
-ddctm834 comparetotmag 0 NaN -> -1
-ddctm835 comparetotmag 1 NaN -> -1
-ddctm836 comparetotmag 1000 NaN -> -1
-ddctm837 comparetotmag Inf NaN -> -1
-ddctm838 comparetotmag -NaN -NaN -> 0
-ddctm839 comparetotmag +NaN -NaN -> 0
-ddctm840 comparetotmag -NaN +NaN -> 0
-
-ddctm841 comparetotmag sNaN -sNaN -> 0
-ddctm842 comparetotmag sNaN -NaN -> -1
-ddctm843 comparetotmag sNaN -Inf -> 1
-ddctm844 comparetotmag sNaN -1000 -> 1
-ddctm845 comparetotmag sNaN -1 -> 1
-ddctm846 comparetotmag sNaN -0 -> 1
-ddctm847 comparetotmag sNaN 0 -> 1
-ddctm848 comparetotmag sNaN 1 -> 1
-ddctm849 comparetotmag sNaN 1000 -> 1
-ddctm850 comparetotmag sNaN NaN -> -1
-ddctm851 comparetotmag sNaN sNaN -> 0
-
-ddctm852 comparetotmag -sNaN sNaN -> 0
-ddctm853 comparetotmag -NaN sNaN -> 1
-ddctm854 comparetotmag -Inf sNaN -> -1
-ddctm855 comparetotmag -1000 sNaN -> -1
-ddctm856 comparetotmag -1 sNaN -> -1
-ddctm857 comparetotmag -0 sNaN -> -1
-ddctm858 comparetotmag 0 sNaN -> -1
-ddctm859 comparetotmag 1 sNaN -> -1
-ddctm860 comparetotmag 1000 sNaN -> -1
-ddctm861 comparetotmag Inf sNaN -> -1
-ddctm862 comparetotmag NaN sNaN -> 1
-ddctm863 comparetotmag sNaN sNaN -> 0
-
-ddctm871 comparetotmag -sNaN -sNaN -> 0
-ddctm872 comparetotmag -sNaN -NaN -> -1
-ddctm873 comparetotmag -sNaN -Inf -> 1
-ddctm874 comparetotmag -sNaN -1000 -> 1
-ddctm875 comparetotmag -sNaN -1 -> 1
-ddctm876 comparetotmag -sNaN -0 -> 1
-ddctm877 comparetotmag -sNaN 0 -> 1
-ddctm878 comparetotmag -sNaN 1 -> 1
-ddctm879 comparetotmag -sNaN 1000 -> 1
-ddctm880 comparetotmag -sNaN NaN -> -1
-ddctm881 comparetotmag -sNaN sNaN -> 0
-
-ddctm882 comparetotmag -sNaN -sNaN -> 0
-ddctm883 comparetotmag -NaN -sNaN -> 1
-ddctm884 comparetotmag -Inf -sNaN -> -1
-ddctm885 comparetotmag -1000 -sNaN -> -1
-ddctm886 comparetotmag -1 -sNaN -> -1
-ddctm887 comparetotmag -0 -sNaN -> -1
-ddctm888 comparetotmag 0 -sNaN -> -1
-ddctm889 comparetotmag 1 -sNaN -> -1
-ddctm890 comparetotmag 1000 -sNaN -> -1
-ddctm891 comparetotmag Inf -sNaN -> -1
-ddctm892 comparetotmag NaN -sNaN -> 1
-ddctm893 comparetotmag sNaN -sNaN -> 0
-
--- NaNs with payload
-ddctm960 comparetotmag NaN9 -Inf -> 1
-ddctm961 comparetotmag NaN8 999 -> 1
-ddctm962 comparetotmag NaN77 Inf -> 1
-ddctm963 comparetotmag -NaN67 NaN5 -> 1
-ddctm964 comparetotmag -Inf -NaN4 -> -1
-ddctm965 comparetotmag -999 -NaN33 -> -1
-ddctm966 comparetotmag Inf NaN2 -> -1
-
-ddctm970 comparetotmag -NaN41 -NaN42 -> -1
-ddctm971 comparetotmag +NaN41 -NaN42 -> -1
-ddctm972 comparetotmag -NaN41 +NaN42 -> -1
-ddctm973 comparetotmag +NaN41 +NaN42 -> -1
-ddctm974 comparetotmag -NaN42 -NaN01 -> 1
-ddctm975 comparetotmag +NaN42 -NaN01 -> 1
-ddctm976 comparetotmag -NaN42 +NaN01 -> 1
-ddctm977 comparetotmag +NaN42 +NaN01 -> 1
-
-ddctm980 comparetotmag -sNaN771 -sNaN772 -> -1
-ddctm981 comparetotmag +sNaN771 -sNaN772 -> -1
-ddctm982 comparetotmag -sNaN771 +sNaN772 -> -1
-ddctm983 comparetotmag +sNaN771 +sNaN772 -> -1
-ddctm984 comparetotmag -sNaN772 -sNaN771 -> 1
-ddctm985 comparetotmag +sNaN772 -sNaN771 -> 1
-ddctm986 comparetotmag -sNaN772 +sNaN771 -> 1
-ddctm987 comparetotmag +sNaN772 +sNaN771 -> 1
-
-ddctm991 comparetotmag -sNaN99 -Inf -> 1
-ddctm992 comparetotmag sNaN98 -11 -> 1
-ddctm993 comparetotmag sNaN97 NaN -> -1
-ddctm994 comparetotmag sNaN16 sNaN94 -> -1
-ddctm995 comparetotmag NaN85 sNaN83 -> 1
-ddctm996 comparetotmag -Inf sNaN92 -> -1
-ddctm997 comparetotmag 088 sNaN81 -> -1
-ddctm998 comparetotmag Inf sNaN90 -> -1
-ddctm999 comparetotmag NaN -sNaN89 -> 1
-
--- spread zeros
-ddctm1110 comparetotmag 0E-383 0 -> -1
-ddctm1111 comparetotmag 0E-383 -0 -> -1
-ddctm1112 comparetotmag -0E-383 0 -> -1
-ddctm1113 comparetotmag -0E-383 -0 -> -1
-ddctm1114 comparetotmag 0E-383 0E+384 -> -1
-ddctm1115 comparetotmag 0E-383 -0E+384 -> -1
-ddctm1116 comparetotmag -0E-383 0E+384 -> -1
-ddctm1117 comparetotmag -0E-383 -0E+384 -> -1
-ddctm1118 comparetotmag 0 0E+384 -> -1
-ddctm1119 comparetotmag 0 -0E+384 -> -1
-ddctm1120 comparetotmag -0 0E+384 -> -1
-ddctm1121 comparetotmag -0 -0E+384 -> -1
-
-ddctm1130 comparetotmag 0E+384 0 -> 1
-ddctm1131 comparetotmag 0E+384 -0 -> 1
-ddctm1132 comparetotmag -0E+384 0 -> 1
-ddctm1133 comparetotmag -0E+384 -0 -> 1
-ddctm1134 comparetotmag 0E+384 0E-383 -> 1
-ddctm1135 comparetotmag 0E+384 -0E-383 -> 1
-ddctm1136 comparetotmag -0E+384 0E-383 -> 1
-ddctm1137 comparetotmag -0E+384 -0E-383 -> 1
-ddctm1138 comparetotmag 0 0E-383 -> 1
-ddctm1139 comparetotmag 0 -0E-383 -> 1
-ddctm1140 comparetotmag -0 0E-383 -> 1
-ddctm1141 comparetotmag -0 -0E-383 -> 1
-
--- Null tests
-ddctm9990 comparetotmag 10 # -> NaN Invalid_operation
-ddctm9991 comparetotmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddCompareTotalMag.decTest -- decDouble comparison; abs. total order--
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddctm001 comparetotmag -2 -2 -> 0
+ddctm002 comparetotmag -2 -1 -> 1
+ddctm003 comparetotmag -2 0 -> 1
+ddctm004 comparetotmag -2 1 -> 1
+ddctm005 comparetotmag -2 2 -> 0
+ddctm006 comparetotmag -1 -2 -> -1
+ddctm007 comparetotmag -1 -1 -> 0
+ddctm008 comparetotmag -1 0 -> 1
+ddctm009 comparetotmag -1 1 -> 0
+ddctm010 comparetotmag -1 2 -> -1
+ddctm011 comparetotmag 0 -2 -> -1
+ddctm012 comparetotmag 0 -1 -> -1
+ddctm013 comparetotmag 0 0 -> 0
+ddctm014 comparetotmag 0 1 -> -1
+ddctm015 comparetotmag 0 2 -> -1
+ddctm016 comparetotmag 1 -2 -> -1
+ddctm017 comparetotmag 1 -1 -> 0
+ddctm018 comparetotmag 1 0 -> 1
+ddctm019 comparetotmag 1 1 -> 0
+ddctm020 comparetotmag 1 2 -> -1
+ddctm021 comparetotmag 2 -2 -> 0
+ddctm022 comparetotmag 2 -1 -> 1
+ddctm023 comparetotmag 2 0 -> 1
+ddctm025 comparetotmag 2 1 -> 1
+ddctm026 comparetotmag 2 2 -> 0
+
+ddctm031 comparetotmag -20 -20 -> 0
+ddctm032 comparetotmag -20 -10 -> 1
+ddctm033 comparetotmag -20 00 -> 1
+ddctm034 comparetotmag -20 10 -> 1
+ddctm035 comparetotmag -20 20 -> 0
+ddctm036 comparetotmag -10 -20 -> -1
+ddctm037 comparetotmag -10 -10 -> 0
+ddctm038 comparetotmag -10 00 -> 1
+ddctm039 comparetotmag -10 10 -> 0
+ddctm040 comparetotmag -10 20 -> -1
+ddctm041 comparetotmag 00 -20 -> -1
+ddctm042 comparetotmag 00 -10 -> -1
+ddctm043 comparetotmag 00 00 -> 0
+ddctm044 comparetotmag 00 10 -> -1
+ddctm045 comparetotmag 00 20 -> -1
+ddctm046 comparetotmag 10 -20 -> -1
+ddctm047 comparetotmag 10 -10 -> 0
+ddctm048 comparetotmag 10 00 -> 1
+ddctm049 comparetotmag 10 10 -> 0
+ddctm050 comparetotmag 10 20 -> -1
+ddctm051 comparetotmag 20 -20 -> 0
+ddctm052 comparetotmag 20 -10 -> 1
+ddctm053 comparetotmag 20 00 -> 1
+ddctm055 comparetotmag 20 10 -> 1
+ddctm056 comparetotmag 20 20 -> 0
+
+ddctm061 comparetotmag -2.0 -2.0 -> 0
+ddctm062 comparetotmag -2.0 -1.0 -> 1
+ddctm063 comparetotmag -2.0 0.0 -> 1
+ddctm064 comparetotmag -2.0 1.0 -> 1
+ddctm065 comparetotmag -2.0 2.0 -> 0
+ddctm066 comparetotmag -1.0 -2.0 -> -1
+ddctm067 comparetotmag -1.0 -1.0 -> 0
+ddctm068 comparetotmag -1.0 0.0 -> 1
+ddctm069 comparetotmag -1.0 1.0 -> 0
+ddctm070 comparetotmag -1.0 2.0 -> -1
+ddctm071 comparetotmag 0.0 -2.0 -> -1
+ddctm072 comparetotmag 0.0 -1.0 -> -1
+ddctm073 comparetotmag 0.0 0.0 -> 0
+ddctm074 comparetotmag 0.0 1.0 -> -1
+ddctm075 comparetotmag 0.0 2.0 -> -1
+ddctm076 comparetotmag 1.0 -2.0 -> -1
+ddctm077 comparetotmag 1.0 -1.0 -> 0
+ddctm078 comparetotmag 1.0 0.0 -> 1
+ddctm079 comparetotmag 1.0 1.0 -> 0
+ddctm080 comparetotmag 1.0 2.0 -> -1
+ddctm081 comparetotmag 2.0 -2.0 -> 0
+ddctm082 comparetotmag 2.0 -1.0 -> 1
+ddctm083 comparetotmag 2.0 0.0 -> 1
+ddctm085 comparetotmag 2.0 1.0 -> 1
+ddctm086 comparetotmag 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+ddctm090 comparetotmag 9.99999999E+384 9.99999999E+384 -> 0
+ddctm091 comparetotmag -9.99999999E+384 9.99999999E+384 -> 0
+ddctm092 comparetotmag 9.99999999E+384 -9.99999999E+384 -> 0
+ddctm093 comparetotmag -9.99999999E+384 -9.99999999E+384 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+ddctm100 comparetotmag 7.0 7.0 -> 0
+ddctm101 comparetotmag 7.0 7 -> -1
+ddctm102 comparetotmag 7 7.0 -> 1
+ddctm103 comparetotmag 7E+0 7.0 -> 1
+ddctm104 comparetotmag 70E-1 7.0 -> 0
+ddctm105 comparetotmag 0.7E+1 7 -> 0
+ddctm106 comparetotmag 70E-1 7 -> -1
+ddctm107 comparetotmag 7.0 7E+0 -> -1
+ddctm108 comparetotmag 7.0 70E-1 -> 0
+ddctm109 comparetotmag 7 0.7E+1 -> 0
+ddctm110 comparetotmag 7 70E-1 -> 1
+
+ddctm120 comparetotmag 8.0 7.0 -> 1
+ddctm121 comparetotmag 8.0 7 -> 1
+ddctm122 comparetotmag 8 7.0 -> 1
+ddctm123 comparetotmag 8E+0 7.0 -> 1
+ddctm124 comparetotmag 80E-1 7.0 -> 1
+ddctm125 comparetotmag 0.8E+1 7 -> 1
+ddctm126 comparetotmag 80E-1 7 -> 1
+ddctm127 comparetotmag 8.0 7E+0 -> 1
+ddctm128 comparetotmag 8.0 70E-1 -> 1
+ddctm129 comparetotmag 8 0.7E+1 -> 1
+ddctm130 comparetotmag 8 70E-1 -> 1
+
+ddctm140 comparetotmag 8.0 9.0 -> -1
+ddctm141 comparetotmag 8.0 9 -> -1
+ddctm142 comparetotmag 8 9.0 -> -1
+ddctm143 comparetotmag 8E+0 9.0 -> -1
+ddctm144 comparetotmag 80E-1 9.0 -> -1
+ddctm145 comparetotmag 0.8E+1 9 -> -1
+ddctm146 comparetotmag 80E-1 9 -> -1
+ddctm147 comparetotmag 8.0 9E+0 -> -1
+ddctm148 comparetotmag 8.0 90E-1 -> -1
+ddctm149 comparetotmag 8 0.9E+1 -> -1
+ddctm150 comparetotmag 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ddctm200 comparetotmag -7.0 7.0 -> 0
+ddctm201 comparetotmag -7.0 7 -> -1
+ddctm202 comparetotmag -7 7.0 -> 1
+ddctm203 comparetotmag -7E+0 7.0 -> 1
+ddctm204 comparetotmag -70E-1 7.0 -> 0
+ddctm205 comparetotmag -0.7E+1 7 -> 0
+ddctm206 comparetotmag -70E-1 7 -> -1
+ddctm207 comparetotmag -7.0 7E+0 -> -1
+ddctm208 comparetotmag -7.0 70E-1 -> 0
+ddctm209 comparetotmag -7 0.7E+1 -> 0
+ddctm210 comparetotmag -7 70E-1 -> 1
+
+ddctm220 comparetotmag -8.0 7.0 -> 1
+ddctm221 comparetotmag -8.0 7 -> 1
+ddctm222 comparetotmag -8 7.0 -> 1
+ddctm223 comparetotmag -8E+0 7.0 -> 1
+ddctm224 comparetotmag -80E-1 7.0 -> 1
+ddctm225 comparetotmag -0.8E+1 7 -> 1
+ddctm226 comparetotmag -80E-1 7 -> 1
+ddctm227 comparetotmag -8.0 7E+0 -> 1
+ddctm228 comparetotmag -8.0 70E-1 -> 1
+ddctm229 comparetotmag -8 0.7E+1 -> 1
+ddctm230 comparetotmag -8 70E-1 -> 1
+
+ddctm240 comparetotmag -8.0 9.0 -> -1
+ddctm241 comparetotmag -8.0 9 -> -1
+ddctm242 comparetotmag -8 9.0 -> -1
+ddctm243 comparetotmag -8E+0 9.0 -> -1
+ddctm244 comparetotmag -80E-1 9.0 -> -1
+ddctm245 comparetotmag -0.8E+1 9 -> -1
+ddctm246 comparetotmag -80E-1 9 -> -1
+ddctm247 comparetotmag -8.0 9E+0 -> -1
+ddctm248 comparetotmag -8.0 90E-1 -> -1
+ddctm249 comparetotmag -8 0.9E+1 -> -1
+ddctm250 comparetotmag -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ddctm300 comparetotmag 7.0 -7.0 -> 0
+ddctm301 comparetotmag 7.0 -7 -> -1
+ddctm302 comparetotmag 7 -7.0 -> 1
+ddctm303 comparetotmag 7E+0 -7.0 -> 1
+ddctm304 comparetotmag 70E-1 -7.0 -> 0
+ddctm305 comparetotmag .7E+1 -7 -> 0
+ddctm306 comparetotmag 70E-1 -7 -> -1
+ddctm307 comparetotmag 7.0 -7E+0 -> -1
+ddctm308 comparetotmag 7.0 -70E-1 -> 0
+ddctm309 comparetotmag 7 -.7E+1 -> 0
+ddctm310 comparetotmag 7 -70E-1 -> 1
+
+ddctm320 comparetotmag 8.0 -7.0 -> 1
+ddctm321 comparetotmag 8.0 -7 -> 1
+ddctm322 comparetotmag 8 -7.0 -> 1
+ddctm323 comparetotmag 8E+0 -7.0 -> 1
+ddctm324 comparetotmag 80E-1 -7.0 -> 1
+ddctm325 comparetotmag .8E+1 -7 -> 1
+ddctm326 comparetotmag 80E-1 -7 -> 1
+ddctm327 comparetotmag 8.0 -7E+0 -> 1
+ddctm328 comparetotmag 8.0 -70E-1 -> 1
+ddctm329 comparetotmag 8 -.7E+1 -> 1
+ddctm330 comparetotmag 8 -70E-1 -> 1
+
+ddctm340 comparetotmag 8.0 -9.0 -> -1
+ddctm341 comparetotmag 8.0 -9 -> -1
+ddctm342 comparetotmag 8 -9.0 -> -1
+ddctm343 comparetotmag 8E+0 -9.0 -> -1
+ddctm344 comparetotmag 80E-1 -9.0 -> -1
+ddctm345 comparetotmag .8E+1 -9 -> -1
+ddctm346 comparetotmag 80E-1 -9 -> -1
+ddctm347 comparetotmag 8.0 -9E+0 -> -1
+ddctm348 comparetotmag 8.0 -90E-1 -> -1
+ddctm349 comparetotmag 8 -.9E+1 -> -1
+ddctm350 comparetotmag 8 -90E-1 -> -1
+
+-- and again, with sign changes -- ..
+ddctm400 comparetotmag -7.0 -7.0 -> 0
+ddctm401 comparetotmag -7.0 -7 -> -1
+ddctm402 comparetotmag -7 -7.0 -> 1
+ddctm403 comparetotmag -7E+0 -7.0 -> 1
+ddctm404 comparetotmag -70E-1 -7.0 -> 0
+ddctm405 comparetotmag -.7E+1 -7 -> 0
+ddctm406 comparetotmag -70E-1 -7 -> -1
+ddctm407 comparetotmag -7.0 -7E+0 -> -1
+ddctm408 comparetotmag -7.0 -70E-1 -> 0
+ddctm409 comparetotmag -7 -.7E+1 -> 0
+ddctm410 comparetotmag -7 -70E-1 -> 1
+
+ddctm420 comparetotmag -8.0 -7.0 -> 1
+ddctm421 comparetotmag -8.0 -7 -> 1
+ddctm422 comparetotmag -8 -7.0 -> 1
+ddctm423 comparetotmag -8E+0 -7.0 -> 1
+ddctm424 comparetotmag -80E-1 -7.0 -> 1
+ddctm425 comparetotmag -.8E+1 -7 -> 1
+ddctm426 comparetotmag -80E-1 -7 -> 1
+ddctm427 comparetotmag -8.0 -7E+0 -> 1
+ddctm428 comparetotmag -8.0 -70E-1 -> 1
+ddctm429 comparetotmag -8 -.7E+1 -> 1
+ddctm430 comparetotmag -8 -70E-1 -> 1
+
+ddctm440 comparetotmag -8.0 -9.0 -> -1
+ddctm441 comparetotmag -8.0 -9 -> -1
+ddctm442 comparetotmag -8 -9.0 -> -1
+ddctm443 comparetotmag -8E+0 -9.0 -> -1
+ddctm444 comparetotmag -80E-1 -9.0 -> -1
+ddctm445 comparetotmag -.8E+1 -9 -> -1
+ddctm446 comparetotmag -80E-1 -9 -> -1
+ddctm447 comparetotmag -8.0 -9E+0 -> -1
+ddctm448 comparetotmag -8.0 -90E-1 -> -1
+ddctm449 comparetotmag -8 -.9E+1 -> -1
+ddctm450 comparetotmag -8 -90E-1 -> -1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+ddctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
+ddctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
+ddctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
+ddctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
+ddctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
+ddctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
+ddctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
+ddctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
+ddctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
+ddctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
+ddctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
+ddctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
+ddctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
+ddctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
+ddctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
+ddctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
+ddctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
+ddctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
+ddctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
+ddctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
+ddctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
+ddctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+ddctm498 comparetotmag 1 1E-17 -> 1
+ddctm499 comparetotmag 1 1E-16 -> 1
+ddctm500 comparetotmag 1 1E-15 -> 1
+ddctm501 comparetotmag 1 1E-14 -> 1
+ddctm502 comparetotmag 1 1E-13 -> 1
+ddctm503 comparetotmag 1 1E-12 -> 1
+ddctm504 comparetotmag 1 1E-11 -> 1
+ddctm505 comparetotmag 1 1E-10 -> 1
+ddctm506 comparetotmag 1 1E-9 -> 1
+ddctm507 comparetotmag 1 1E-8 -> 1
+ddctm508 comparetotmag 1 1E-7 -> 1
+ddctm509 comparetotmag 1 1E-6 -> 1
+ddctm510 comparetotmag 1 1E-5 -> 1
+ddctm511 comparetotmag 1 1E-4 -> 1
+ddctm512 comparetotmag 1 1E-3 -> 1
+ddctm513 comparetotmag 1 1E-2 -> 1
+ddctm514 comparetotmag 1 1E-1 -> 1
+ddctm515 comparetotmag 1 1E-0 -> 0
+ddctm516 comparetotmag 1 1E+1 -> -1
+ddctm517 comparetotmag 1 1E+2 -> -1
+ddctm518 comparetotmag 1 1E+3 -> -1
+ddctm519 comparetotmag 1 1E+4 -> -1
+ddctm521 comparetotmag 1 1E+5 -> -1
+ddctm522 comparetotmag 1 1E+6 -> -1
+ddctm523 comparetotmag 1 1E+7 -> -1
+ddctm524 comparetotmag 1 1E+8 -> -1
+ddctm525 comparetotmag 1 1E+9 -> -1
+ddctm526 comparetotmag 1 1E+10 -> -1
+ddctm527 comparetotmag 1 1E+11 -> -1
+ddctm528 comparetotmag 1 1E+12 -> -1
+ddctm529 comparetotmag 1 1E+13 -> -1
+ddctm530 comparetotmag 1 1E+14 -> -1
+ddctm531 comparetotmag 1 1E+15 -> -1
+ddctm532 comparetotmag 1 1E+16 -> -1
+ddctm533 comparetotmag 1 1E+17 -> -1
+-- LR swap
+ddctm538 comparetotmag 1E-17 1 -> -1
+ddctm539 comparetotmag 1E-16 1 -> -1
+ddctm540 comparetotmag 1E-15 1 -> -1
+ddctm541 comparetotmag 1E-14 1 -> -1
+ddctm542 comparetotmag 1E-13 1 -> -1
+ddctm543 comparetotmag 1E-12 1 -> -1
+ddctm544 comparetotmag 1E-11 1 -> -1
+ddctm545 comparetotmag 1E-10 1 -> -1
+ddctm546 comparetotmag 1E-9 1 -> -1
+ddctm547 comparetotmag 1E-8 1 -> -1
+ddctm548 comparetotmag 1E-7 1 -> -1
+ddctm549 comparetotmag 1E-6 1 -> -1
+ddctm550 comparetotmag 1E-5 1 -> -1
+ddctm551 comparetotmag 1E-4 1 -> -1
+ddctm552 comparetotmag 1E-3 1 -> -1
+ddctm553 comparetotmag 1E-2 1 -> -1
+ddctm554 comparetotmag 1E-1 1 -> -1
+ddctm555 comparetotmag 1E-0 1 -> 0
+ddctm556 comparetotmag 1E+1 1 -> 1
+ddctm557 comparetotmag 1E+2 1 -> 1
+ddctm558 comparetotmag 1E+3 1 -> 1
+ddctm559 comparetotmag 1E+4 1 -> 1
+ddctm561 comparetotmag 1E+5 1 -> 1
+ddctm562 comparetotmag 1E+6 1 -> 1
+ddctm563 comparetotmag 1E+7 1 -> 1
+ddctm564 comparetotmag 1E+8 1 -> 1
+ddctm565 comparetotmag 1E+9 1 -> 1
+ddctm566 comparetotmag 1E+10 1 -> 1
+ddctm567 comparetotmag 1E+11 1 -> 1
+ddctm568 comparetotmag 1E+12 1 -> 1
+ddctm569 comparetotmag 1E+13 1 -> 1
+ddctm570 comparetotmag 1E+14 1 -> 1
+ddctm571 comparetotmag 1E+15 1 -> 1
+ddctm572 comparetotmag 1E+16 1 -> 1
+ddctm573 comparetotmag 1E+17 1 -> 1
+-- similar with a useful coefficient, one side only
+ddctm578 comparetotmag 0.000000987654321 1E-17 -> 1
+ddctm579 comparetotmag 0.000000987654321 1E-16 -> 1
+ddctm580 comparetotmag 0.000000987654321 1E-15 -> 1
+ddctm581 comparetotmag 0.000000987654321 1E-14 -> 1
+ddctm582 comparetotmag 0.000000987654321 1E-13 -> 1
+ddctm583 comparetotmag 0.000000987654321 1E-12 -> 1
+ddctm584 comparetotmag 0.000000987654321 1E-11 -> 1
+ddctm585 comparetotmag 0.000000987654321 1E-10 -> 1
+ddctm586 comparetotmag 0.000000987654321 1E-9 -> 1
+ddctm587 comparetotmag 0.000000987654321 1E-8 -> 1
+ddctm588 comparetotmag 0.000000987654321 1E-7 -> 1
+ddctm589 comparetotmag 0.000000987654321 1E-6 -> -1
+ddctm590 comparetotmag 0.000000987654321 1E-5 -> -1
+ddctm591 comparetotmag 0.000000987654321 1E-4 -> -1
+ddctm592 comparetotmag 0.000000987654321 1E-3 -> -1
+ddctm593 comparetotmag 0.000000987654321 1E-2 -> -1
+ddctm594 comparetotmag 0.000000987654321 1E-1 -> -1
+ddctm595 comparetotmag 0.000000987654321 1E-0 -> -1
+ddctm596 comparetotmag 0.000000987654321 1E+1 -> -1
+ddctm597 comparetotmag 0.000000987654321 1E+2 -> -1
+ddctm598 comparetotmag 0.000000987654321 1E+3 -> -1
+ddctm599 comparetotmag 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+ddctm600 comparetotmag 12 12.2345 -> -1
+ddctm601 comparetotmag 12.0 12.2345 -> -1
+ddctm602 comparetotmag 12.00 12.2345 -> -1
+ddctm603 comparetotmag 12.000 12.2345 -> -1
+ddctm604 comparetotmag 12.0000 12.2345 -> -1
+ddctm605 comparetotmag 12.00000 12.2345 -> -1
+ddctm606 comparetotmag 12.000000 12.2345 -> -1
+ddctm607 comparetotmag 12.0000000 12.2345 -> -1
+ddctm608 comparetotmag 12.00000000 12.2345 -> -1
+ddctm609 comparetotmag 12.000000000 12.2345 -> -1
+ddctm610 comparetotmag 12.1234 12 -> 1
+ddctm611 comparetotmag 12.1234 12.0 -> 1
+ddctm612 comparetotmag 12.1234 12.00 -> 1
+ddctm613 comparetotmag 12.1234 12.000 -> 1
+ddctm614 comparetotmag 12.1234 12.0000 -> 1
+ddctm615 comparetotmag 12.1234 12.00000 -> 1
+ddctm616 comparetotmag 12.1234 12.000000 -> 1
+ddctm617 comparetotmag 12.1234 12.0000000 -> 1
+ddctm618 comparetotmag 12.1234 12.00000000 -> 1
+ddctm619 comparetotmag 12.1234 12.000000000 -> 1
+ddctm620 comparetotmag -12 -12.2345 -> -1
+ddctm621 comparetotmag -12.0 -12.2345 -> -1
+ddctm622 comparetotmag -12.00 -12.2345 -> -1
+ddctm623 comparetotmag -12.000 -12.2345 -> -1
+ddctm624 comparetotmag -12.0000 -12.2345 -> -1
+ddctm625 comparetotmag -12.00000 -12.2345 -> -1
+ddctm626 comparetotmag -12.000000 -12.2345 -> -1
+ddctm627 comparetotmag -12.0000000 -12.2345 -> -1
+ddctm628 comparetotmag -12.00000000 -12.2345 -> -1
+ddctm629 comparetotmag -12.000000000 -12.2345 -> -1
+ddctm630 comparetotmag -12.1234 -12 -> 1
+ddctm631 comparetotmag -12.1234 -12.0 -> 1
+ddctm632 comparetotmag -12.1234 -12.00 -> 1
+ddctm633 comparetotmag -12.1234 -12.000 -> 1
+ddctm634 comparetotmag -12.1234 -12.0000 -> 1
+ddctm635 comparetotmag -12.1234 -12.00000 -> 1
+ddctm636 comparetotmag -12.1234 -12.000000 -> 1
+ddctm637 comparetotmag -12.1234 -12.0000000 -> 1
+ddctm638 comparetotmag -12.1234 -12.00000000 -> 1
+ddctm639 comparetotmag -12.1234 -12.000000000 -> 1
+
+-- extended zeros
+ddctm640 comparetotmag 0 0 -> 0
+ddctm641 comparetotmag 0 -0 -> 0
+ddctm642 comparetotmag 0 -0.0 -> 1
+ddctm643 comparetotmag 0 0.0 -> 1
+ddctm644 comparetotmag -0 0 -> 0
+ddctm645 comparetotmag -0 -0 -> 0
+ddctm646 comparetotmag -0 -0.0 -> 1
+ddctm647 comparetotmag -0 0.0 -> 1
+ddctm648 comparetotmag 0.0 0 -> -1
+ddctm649 comparetotmag 0.0 -0 -> -1
+ddctm650 comparetotmag 0.0 -0.0 -> 0
+ddctm651 comparetotmag 0.0 0.0 -> 0
+ddctm652 comparetotmag -0.0 0 -> -1
+ddctm653 comparetotmag -0.0 -0 -> -1
+ddctm654 comparetotmag -0.0 -0.0 -> 0
+ddctm655 comparetotmag -0.0 0.0 -> 0
+
+ddctm656 comparetotmag -0E1 0.0 -> 1
+ddctm657 comparetotmag -0E2 0.0 -> 1
+ddctm658 comparetotmag 0E1 0.0 -> 1
+ddctm659 comparetotmag 0E2 0.0 -> 1
+ddctm660 comparetotmag -0E1 0 -> 1
+ddctm661 comparetotmag -0E2 0 -> 1
+ddctm662 comparetotmag 0E1 0 -> 1
+ddctm663 comparetotmag 0E2 0 -> 1
+ddctm664 comparetotmag -0E1 -0E1 -> 0
+ddctm665 comparetotmag -0E2 -0E1 -> 1
+ddctm666 comparetotmag 0E1 -0E1 -> 0
+ddctm667 comparetotmag 0E2 -0E1 -> 1
+ddctm668 comparetotmag -0E1 -0E2 -> -1
+ddctm669 comparetotmag -0E2 -0E2 -> 0
+ddctm670 comparetotmag 0E1 -0E2 -> -1
+ddctm671 comparetotmag 0E2 -0E2 -> 0
+ddctm672 comparetotmag -0E1 0E1 -> 0
+ddctm673 comparetotmag -0E2 0E1 -> 1
+ddctm674 comparetotmag 0E1 0E1 -> 0
+ddctm675 comparetotmag 0E2 0E1 -> 1
+ddctm676 comparetotmag -0E1 0E2 -> -1
+ddctm677 comparetotmag -0E2 0E2 -> 0
+ddctm678 comparetotmag 0E1 0E2 -> -1
+ddctm679 comparetotmag 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+ddctm680 comparetotmag 12 12 -> 0
+ddctm681 comparetotmag 12 12.0 -> 1
+ddctm682 comparetotmag 12 12.00 -> 1
+ddctm683 comparetotmag 12 12.000 -> 1
+ddctm684 comparetotmag 12 12.0000 -> 1
+ddctm685 comparetotmag 12 12.00000 -> 1
+ddctm686 comparetotmag 12 12.000000 -> 1
+ddctm687 comparetotmag 12 12.0000000 -> 1
+ddctm688 comparetotmag 12 12.00000000 -> 1
+ddctm689 comparetotmag 12 12.000000000 -> 1
+ddctm690 comparetotmag 12 12 -> 0
+ddctm691 comparetotmag 12.0 12 -> -1
+ddctm692 comparetotmag 12.00 12 -> -1
+ddctm693 comparetotmag 12.000 12 -> -1
+ddctm694 comparetotmag 12.0000 12 -> -1
+ddctm695 comparetotmag 12.00000 12 -> -1
+ddctm696 comparetotmag 12.000000 12 -> -1
+ddctm697 comparetotmag 12.0000000 12 -> -1
+ddctm698 comparetotmag 12.00000000 12 -> -1
+ddctm699 comparetotmag 12.000000000 12 -> -1
+
+-- old long operand checks
+ddctm701 comparetotmag 12345678000 1 -> 1
+ddctm702 comparetotmag 1 12345678000 -> -1
+ddctm703 comparetotmag 1234567800 1 -> 1
+ddctm704 comparetotmag 1 1234567800 -> -1
+ddctm705 comparetotmag 1234567890 1 -> 1
+ddctm706 comparetotmag 1 1234567890 -> -1
+ddctm707 comparetotmag 1234567891 1 -> 1
+ddctm708 comparetotmag 1 1234567891 -> -1
+ddctm709 comparetotmag 12345678901 1 -> 1
+ddctm710 comparetotmag 1 12345678901 -> -1
+ddctm711 comparetotmag 1234567896 1 -> 1
+ddctm712 comparetotmag 1 1234567896 -> -1
+ddctm713 comparetotmag -1234567891 1 -> 1
+ddctm714 comparetotmag 1 -1234567891 -> -1
+ddctm715 comparetotmag -12345678901 1 -> 1
+ddctm716 comparetotmag 1 -12345678901 -> -1
+ddctm717 comparetotmag -1234567896 1 -> 1
+ddctm718 comparetotmag 1 -1234567896 -> -1
+
+-- old residue cases
+ddctm740 comparetotmag 1 0.9999999 -> 1
+ddctm741 comparetotmag 1 0.999999 -> 1
+ddctm742 comparetotmag 1 0.99999 -> 1
+ddctm743 comparetotmag 1 1.0000 -> 1
+ddctm744 comparetotmag 1 1.00001 -> -1
+ddctm745 comparetotmag 1 1.000001 -> -1
+ddctm746 comparetotmag 1 1.0000001 -> -1
+ddctm750 comparetotmag 0.9999999 1 -> -1
+ddctm751 comparetotmag 0.999999 1 -> -1
+ddctm752 comparetotmag 0.99999 1 -> -1
+ddctm753 comparetotmag 1.0000 1 -> -1
+ddctm754 comparetotmag 1.00001 1 -> 1
+ddctm755 comparetotmag 1.000001 1 -> 1
+ddctm756 comparetotmag 1.0000001 1 -> 1
+
+-- Specials
+ddctm780 comparetotmag Inf -Inf -> 0
+ddctm781 comparetotmag Inf -1000 -> 1
+ddctm782 comparetotmag Inf -1 -> 1
+ddctm783 comparetotmag Inf -0 -> 1
+ddctm784 comparetotmag Inf 0 -> 1
+ddctm785 comparetotmag Inf 1 -> 1
+ddctm786 comparetotmag Inf 1000 -> 1
+ddctm787 comparetotmag Inf Inf -> 0
+ddctm788 comparetotmag -1000 Inf -> -1
+ddctm789 comparetotmag -Inf Inf -> 0
+ddctm790 comparetotmag -1 Inf -> -1
+ddctm791 comparetotmag -0 Inf -> -1
+ddctm792 comparetotmag 0 Inf -> -1
+ddctm793 comparetotmag 1 Inf -> -1
+ddctm794 comparetotmag 1000 Inf -> -1
+ddctm795 comparetotmag Inf Inf -> 0
+
+ddctm800 comparetotmag -Inf -Inf -> 0
+ddctm801 comparetotmag -Inf -1000 -> 1
+ddctm802 comparetotmag -Inf -1 -> 1
+ddctm803 comparetotmag -Inf -0 -> 1
+ddctm804 comparetotmag -Inf 0 -> 1
+ddctm805 comparetotmag -Inf 1 -> 1
+ddctm806 comparetotmag -Inf 1000 -> 1
+ddctm807 comparetotmag -Inf Inf -> 0
+ddctm808 comparetotmag -Inf -Inf -> 0
+ddctm809 comparetotmag -1000 -Inf -> -1
+ddctm810 comparetotmag -1 -Inf -> -1
+ddctm811 comparetotmag -0 -Inf -> -1
+ddctm812 comparetotmag 0 -Inf -> -1
+ddctm813 comparetotmag 1 -Inf -> -1
+ddctm814 comparetotmag 1000 -Inf -> -1
+ddctm815 comparetotmag Inf -Inf -> 0
+
+ddctm821 comparetotmag NaN -Inf -> 1
+ddctm822 comparetotmag NaN -1000 -> 1
+ddctm823 comparetotmag NaN -1 -> 1
+ddctm824 comparetotmag NaN -0 -> 1
+ddctm825 comparetotmag NaN 0 -> 1
+ddctm826 comparetotmag NaN 1 -> 1
+ddctm827 comparetotmag NaN 1000 -> 1
+ddctm828 comparetotmag NaN Inf -> 1
+ddctm829 comparetotmag NaN NaN -> 0
+ddctm830 comparetotmag -Inf NaN -> -1
+ddctm831 comparetotmag -1000 NaN -> -1
+ddctm832 comparetotmag -1 NaN -> -1
+ddctm833 comparetotmag -0 NaN -> -1
+ddctm834 comparetotmag 0 NaN -> -1
+ddctm835 comparetotmag 1 NaN -> -1
+ddctm836 comparetotmag 1000 NaN -> -1
+ddctm837 comparetotmag Inf NaN -> -1
+ddctm838 comparetotmag -NaN -NaN -> 0
+ddctm839 comparetotmag +NaN -NaN -> 0
+ddctm840 comparetotmag -NaN +NaN -> 0
+
+ddctm841 comparetotmag sNaN -sNaN -> 0
+ddctm842 comparetotmag sNaN -NaN -> -1
+ddctm843 comparetotmag sNaN -Inf -> 1
+ddctm844 comparetotmag sNaN -1000 -> 1
+ddctm845 comparetotmag sNaN -1 -> 1
+ddctm846 comparetotmag sNaN -0 -> 1
+ddctm847 comparetotmag sNaN 0 -> 1
+ddctm848 comparetotmag sNaN 1 -> 1
+ddctm849 comparetotmag sNaN 1000 -> 1
+ddctm850 comparetotmag sNaN NaN -> -1
+ddctm851 comparetotmag sNaN sNaN -> 0
+
+ddctm852 comparetotmag -sNaN sNaN -> 0
+ddctm853 comparetotmag -NaN sNaN -> 1
+ddctm854 comparetotmag -Inf sNaN -> -1
+ddctm855 comparetotmag -1000 sNaN -> -1
+ddctm856 comparetotmag -1 sNaN -> -1
+ddctm857 comparetotmag -0 sNaN -> -1
+ddctm858 comparetotmag 0 sNaN -> -1
+ddctm859 comparetotmag 1 sNaN -> -1
+ddctm860 comparetotmag 1000 sNaN -> -1
+ddctm861 comparetotmag Inf sNaN -> -1
+ddctm862 comparetotmag NaN sNaN -> 1
+ddctm863 comparetotmag sNaN sNaN -> 0
+
+ddctm871 comparetotmag -sNaN -sNaN -> 0
+ddctm872 comparetotmag -sNaN -NaN -> -1
+ddctm873 comparetotmag -sNaN -Inf -> 1
+ddctm874 comparetotmag -sNaN -1000 -> 1
+ddctm875 comparetotmag -sNaN -1 -> 1
+ddctm876 comparetotmag -sNaN -0 -> 1
+ddctm877 comparetotmag -sNaN 0 -> 1
+ddctm878 comparetotmag -sNaN 1 -> 1
+ddctm879 comparetotmag -sNaN 1000 -> 1
+ddctm880 comparetotmag -sNaN NaN -> -1
+ddctm881 comparetotmag -sNaN sNaN -> 0
+
+ddctm882 comparetotmag -sNaN -sNaN -> 0
+ddctm883 comparetotmag -NaN -sNaN -> 1
+ddctm884 comparetotmag -Inf -sNaN -> -1
+ddctm885 comparetotmag -1000 -sNaN -> -1
+ddctm886 comparetotmag -1 -sNaN -> -1
+ddctm887 comparetotmag -0 -sNaN -> -1
+ddctm888 comparetotmag 0 -sNaN -> -1
+ddctm889 comparetotmag 1 -sNaN -> -1
+ddctm890 comparetotmag 1000 -sNaN -> -1
+ddctm891 comparetotmag Inf -sNaN -> -1
+ddctm892 comparetotmag NaN -sNaN -> 1
+ddctm893 comparetotmag sNaN -sNaN -> 0
+
+-- NaNs with payload
+ddctm960 comparetotmag NaN9 -Inf -> 1
+ddctm961 comparetotmag NaN8 999 -> 1
+ddctm962 comparetotmag NaN77 Inf -> 1
+ddctm963 comparetotmag -NaN67 NaN5 -> 1
+ddctm964 comparetotmag -Inf -NaN4 -> -1
+ddctm965 comparetotmag -999 -NaN33 -> -1
+ddctm966 comparetotmag Inf NaN2 -> -1
+
+ddctm970 comparetotmag -NaN41 -NaN42 -> -1
+ddctm971 comparetotmag +NaN41 -NaN42 -> -1
+ddctm972 comparetotmag -NaN41 +NaN42 -> -1
+ddctm973 comparetotmag +NaN41 +NaN42 -> -1
+ddctm974 comparetotmag -NaN42 -NaN01 -> 1
+ddctm975 comparetotmag +NaN42 -NaN01 -> 1
+ddctm976 comparetotmag -NaN42 +NaN01 -> 1
+ddctm977 comparetotmag +NaN42 +NaN01 -> 1
+
+ddctm980 comparetotmag -sNaN771 -sNaN772 -> -1
+ddctm981 comparetotmag +sNaN771 -sNaN772 -> -1
+ddctm982 comparetotmag -sNaN771 +sNaN772 -> -1
+ddctm983 comparetotmag +sNaN771 +sNaN772 -> -1
+ddctm984 comparetotmag -sNaN772 -sNaN771 -> 1
+ddctm985 comparetotmag +sNaN772 -sNaN771 -> 1
+ddctm986 comparetotmag -sNaN772 +sNaN771 -> 1
+ddctm987 comparetotmag +sNaN772 +sNaN771 -> 1
+
+ddctm991 comparetotmag -sNaN99 -Inf -> 1
+ddctm992 comparetotmag sNaN98 -11 -> 1
+ddctm993 comparetotmag sNaN97 NaN -> -1
+ddctm994 comparetotmag sNaN16 sNaN94 -> -1
+ddctm995 comparetotmag NaN85 sNaN83 -> 1
+ddctm996 comparetotmag -Inf sNaN92 -> -1
+ddctm997 comparetotmag 088 sNaN81 -> -1
+ddctm998 comparetotmag Inf sNaN90 -> -1
+ddctm999 comparetotmag NaN -sNaN89 -> 1
+
+-- spread zeros
+ddctm1110 comparetotmag 0E-383 0 -> -1
+ddctm1111 comparetotmag 0E-383 -0 -> -1
+ddctm1112 comparetotmag -0E-383 0 -> -1
+ddctm1113 comparetotmag -0E-383 -0 -> -1
+ddctm1114 comparetotmag 0E-383 0E+384 -> -1
+ddctm1115 comparetotmag 0E-383 -0E+384 -> -1
+ddctm1116 comparetotmag -0E-383 0E+384 -> -1
+ddctm1117 comparetotmag -0E-383 -0E+384 -> -1
+ddctm1118 comparetotmag 0 0E+384 -> -1
+ddctm1119 comparetotmag 0 -0E+384 -> -1
+ddctm1120 comparetotmag -0 0E+384 -> -1
+ddctm1121 comparetotmag -0 -0E+384 -> -1
+
+ddctm1130 comparetotmag 0E+384 0 -> 1
+ddctm1131 comparetotmag 0E+384 -0 -> 1
+ddctm1132 comparetotmag -0E+384 0 -> 1
+ddctm1133 comparetotmag -0E+384 -0 -> 1
+ddctm1134 comparetotmag 0E+384 0E-383 -> 1
+ddctm1135 comparetotmag 0E+384 -0E-383 -> 1
+ddctm1136 comparetotmag -0E+384 0E-383 -> 1
+ddctm1137 comparetotmag -0E+384 -0E-383 -> 1
+ddctm1138 comparetotmag 0 0E-383 -> 1
+ddctm1139 comparetotmag 0 -0E-383 -> 1
+ddctm1140 comparetotmag -0 0E-383 -> 1
+ddctm1141 comparetotmag -0 -0E-383 -> 1
+
+-- Null tests
+ddctm9990 comparetotmag 10 # -> NaN Invalid_operation
+ddctm9991 comparetotmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddCopy.decTest b/Lib/test/decimaltestdata/ddCopy.decTest
index 9a175c5ea7..f99d86a426 100644
--- a/Lib/test/decimaltestdata/ddCopy.decTest
+++ b/Lib/test/decimaltestdata/ddCopy.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddCopy.decTest -- quiet decDouble copy --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddcpy001 copy +7.50 -> 7.50
-
--- Infinities
-ddcpy011 copy Infinity -> Infinity
-ddcpy012 copy -Infinity -> -Infinity
-
--- NaNs, 0 payload
-ddcpy021 copy NaN -> NaN
-ddcpy022 copy -NaN -> -NaN
-ddcpy023 copy sNaN -> sNaN
-ddcpy024 copy -sNaN -> -sNaN
-
--- NaNs, non-0 payload
-ddcpy031 copy NaN10 -> NaN10
-ddcpy032 copy -NaN10 -> -NaN10
-ddcpy033 copy sNaN10 -> sNaN10
-ddcpy034 copy -sNaN10 -> -sNaN10
-ddcpy035 copy NaN7 -> NaN7
-ddcpy036 copy -NaN7 -> -NaN7
-ddcpy037 copy sNaN101 -> sNaN101
-ddcpy038 copy -sNaN101 -> -sNaN101
-
--- finites
-ddcpy101 copy 7 -> 7
-ddcpy102 copy -7 -> -7
-ddcpy103 copy 75 -> 75
-ddcpy104 copy -75 -> -75
-ddcpy105 copy 7.50 -> 7.50
-ddcpy106 copy -7.50 -> -7.50
-ddcpy107 copy 7.500 -> 7.500
-ddcpy108 copy -7.500 -> -7.500
-
--- zeros
-ddcpy111 copy 0 -> 0
-ddcpy112 copy -0 -> -0
-ddcpy113 copy 0E+4 -> 0E+4
-ddcpy114 copy -0E+4 -> -0E+4
-ddcpy115 copy 0.0000 -> 0.0000
-ddcpy116 copy -0.0000 -> -0.0000
-ddcpy117 copy 0E-141 -> 0E-141
-ddcpy118 copy -0E-141 -> -0E-141
-
--- full coefficients, alternating bits
-ddcpy121 copy 2682682682682682 -> 2682682682682682
-ddcpy122 copy -2682682682682682 -> -2682682682682682
-ddcpy123 copy 1341341341341341 -> 1341341341341341
-ddcpy124 copy -1341341341341341 -> -1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcpy131 copy 9.999999999999999E+384 -> 9.999999999999999E+384
-ddcpy132 copy 1E-383 -> 1E-383
-ddcpy133 copy 1.000000000000000E-383 -> 1.000000000000000E-383
-ddcpy134 copy 1E-398 -> 1E-398
-
-ddcpy135 copy -1E-398 -> -1E-398
-ddcpy136 copy -1.000000000000000E-383 -> -1.000000000000000E-383
-ddcpy137 copy -1E-383 -> -1E-383
-ddcpy138 copy -9.999999999999999E+384 -> -9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddCopy.decTest -- quiet decDouble copy --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddcpy001 copy +7.50 -> 7.50
+
+-- Infinities
+ddcpy011 copy Infinity -> Infinity
+ddcpy012 copy -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+ddcpy021 copy NaN -> NaN
+ddcpy022 copy -NaN -> -NaN
+ddcpy023 copy sNaN -> sNaN
+ddcpy024 copy -sNaN -> -sNaN
+
+-- NaNs, non-0 payload
+ddcpy031 copy NaN10 -> NaN10
+ddcpy032 copy -NaN10 -> -NaN10
+ddcpy033 copy sNaN10 -> sNaN10
+ddcpy034 copy -sNaN10 -> -sNaN10
+ddcpy035 copy NaN7 -> NaN7
+ddcpy036 copy -NaN7 -> -NaN7
+ddcpy037 copy sNaN101 -> sNaN101
+ddcpy038 copy -sNaN101 -> -sNaN101
+
+-- finites
+ddcpy101 copy 7 -> 7
+ddcpy102 copy -7 -> -7
+ddcpy103 copy 75 -> 75
+ddcpy104 copy -75 -> -75
+ddcpy105 copy 7.50 -> 7.50
+ddcpy106 copy -7.50 -> -7.50
+ddcpy107 copy 7.500 -> 7.500
+ddcpy108 copy -7.500 -> -7.500
+
+-- zeros
+ddcpy111 copy 0 -> 0
+ddcpy112 copy -0 -> -0
+ddcpy113 copy 0E+4 -> 0E+4
+ddcpy114 copy -0E+4 -> -0E+4
+ddcpy115 copy 0.0000 -> 0.0000
+ddcpy116 copy -0.0000 -> -0.0000
+ddcpy117 copy 0E-141 -> 0E-141
+ddcpy118 copy -0E-141 -> -0E-141
+
+-- full coefficients, alternating bits
+ddcpy121 copy 2682682682682682 -> 2682682682682682
+ddcpy122 copy -2682682682682682 -> -2682682682682682
+ddcpy123 copy 1341341341341341 -> 1341341341341341
+ddcpy124 copy -1341341341341341 -> -1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcpy131 copy 9.999999999999999E+384 -> 9.999999999999999E+384
+ddcpy132 copy 1E-383 -> 1E-383
+ddcpy133 copy 1.000000000000000E-383 -> 1.000000000000000E-383
+ddcpy134 copy 1E-398 -> 1E-398
+
+ddcpy135 copy -1E-398 -> -1E-398
+ddcpy136 copy -1.000000000000000E-383 -> -1.000000000000000E-383
+ddcpy137 copy -1E-383 -> -1E-383
+ddcpy138 copy -9.999999999999999E+384 -> -9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddCopyAbs.decTest b/Lib/test/decimaltestdata/ddCopyAbs.decTest
index 4823cf2d77..d436a1940c 100644
--- a/Lib/test/decimaltestdata/ddCopyAbs.decTest
+++ b/Lib/test/decimaltestdata/ddCopyAbs.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddCopyAbs.decTest -- quiet decDouble copy and set sign to zero --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddcpa001 copyabs +7.50 -> 7.50
-
--- Infinities
-ddcpa011 copyabs Infinity -> Infinity
-ddcpa012 copyabs -Infinity -> Infinity
-
--- NaNs, 0 payload
-ddcpa021 copyabs NaN -> NaN
-ddcpa022 copyabs -NaN -> NaN
-ddcpa023 copyabs sNaN -> sNaN
-ddcpa024 copyabs -sNaN -> sNaN
-
--- NaNs, non-0 payload
-ddcpa031 copyabs NaN10 -> NaN10
-ddcpa032 copyabs -NaN15 -> NaN15
-ddcpa033 copyabs sNaN15 -> sNaN15
-ddcpa034 copyabs -sNaN10 -> sNaN10
-ddcpa035 copyabs NaN7 -> NaN7
-ddcpa036 copyabs -NaN7 -> NaN7
-ddcpa037 copyabs sNaN101 -> sNaN101
-ddcpa038 copyabs -sNaN101 -> sNaN101
-
--- finites
-ddcpa101 copyabs 7 -> 7
-ddcpa102 copyabs -7 -> 7
-ddcpa103 copyabs 75 -> 75
-ddcpa104 copyabs -75 -> 75
-ddcpa105 copyabs 7.10 -> 7.10
-ddcpa106 copyabs -7.10 -> 7.10
-ddcpa107 copyabs 7.500 -> 7.500
-ddcpa108 copyabs -7.500 -> 7.500
-
--- zeros
-ddcpa111 copyabs 0 -> 0
-ddcpa112 copyabs -0 -> 0
-ddcpa113 copyabs 0E+6 -> 0E+6
-ddcpa114 copyabs -0E+6 -> 0E+6
-ddcpa115 copyabs 0.0000 -> 0.0000
-ddcpa116 copyabs -0.0000 -> 0.0000
-ddcpa117 copyabs 0E-141 -> 0E-141
-ddcpa118 copyabs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddcpa121 copyabs 2682682682682682 -> 2682682682682682
-ddcpa122 copyabs -2682682682682682 -> 2682682682682682
-ddcpa123 copyabs 1341341341341341 -> 1341341341341341
-ddcpa124 copyabs -1341341341341341 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcpa131 copyabs 9.999999999999999E+384 -> 9.999999999999999E+384
-ddcpa132 copyabs 1E-383 -> 1E-383
-ddcpa133 copyabs 1.000000000000000E-383 -> 1.000000000000000E-383
-ddcpa134 copyabs 1E-398 -> 1E-398
-
-ddcpa135 copyabs -1E-398 -> 1E-398
-ddcpa136 copyabs -1.000000000000000E-383 -> 1.000000000000000E-383
-ddcpa137 copyabs -1E-383 -> 1E-383
-ddcpa138 copyabs -9.999999999999999E+384 -> 9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddCopyAbs.decTest -- quiet decDouble copy and set sign to zero --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddcpa001 copyabs +7.50 -> 7.50
+
+-- Infinities
+ddcpa011 copyabs Infinity -> Infinity
+ddcpa012 copyabs -Infinity -> Infinity
+
+-- NaNs, 0 payload
+ddcpa021 copyabs NaN -> NaN
+ddcpa022 copyabs -NaN -> NaN
+ddcpa023 copyabs sNaN -> sNaN
+ddcpa024 copyabs -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+ddcpa031 copyabs NaN10 -> NaN10
+ddcpa032 copyabs -NaN15 -> NaN15
+ddcpa033 copyabs sNaN15 -> sNaN15
+ddcpa034 copyabs -sNaN10 -> sNaN10
+ddcpa035 copyabs NaN7 -> NaN7
+ddcpa036 copyabs -NaN7 -> NaN7
+ddcpa037 copyabs sNaN101 -> sNaN101
+ddcpa038 copyabs -sNaN101 -> sNaN101
+
+-- finites
+ddcpa101 copyabs 7 -> 7
+ddcpa102 copyabs -7 -> 7
+ddcpa103 copyabs 75 -> 75
+ddcpa104 copyabs -75 -> 75
+ddcpa105 copyabs 7.10 -> 7.10
+ddcpa106 copyabs -7.10 -> 7.10
+ddcpa107 copyabs 7.500 -> 7.500
+ddcpa108 copyabs -7.500 -> 7.500
+
+-- zeros
+ddcpa111 copyabs 0 -> 0
+ddcpa112 copyabs -0 -> 0
+ddcpa113 copyabs 0E+6 -> 0E+6
+ddcpa114 copyabs -0E+6 -> 0E+6
+ddcpa115 copyabs 0.0000 -> 0.0000
+ddcpa116 copyabs -0.0000 -> 0.0000
+ddcpa117 copyabs 0E-141 -> 0E-141
+ddcpa118 copyabs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddcpa121 copyabs 2682682682682682 -> 2682682682682682
+ddcpa122 copyabs -2682682682682682 -> 2682682682682682
+ddcpa123 copyabs 1341341341341341 -> 1341341341341341
+ddcpa124 copyabs -1341341341341341 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcpa131 copyabs 9.999999999999999E+384 -> 9.999999999999999E+384
+ddcpa132 copyabs 1E-383 -> 1E-383
+ddcpa133 copyabs 1.000000000000000E-383 -> 1.000000000000000E-383
+ddcpa134 copyabs 1E-398 -> 1E-398
+
+ddcpa135 copyabs -1E-398 -> 1E-398
+ddcpa136 copyabs -1.000000000000000E-383 -> 1.000000000000000E-383
+ddcpa137 copyabs -1E-383 -> 1E-383
+ddcpa138 copyabs -9.999999999999999E+384 -> 9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddCopyNegate.decTest b/Lib/test/decimaltestdata/ddCopyNegate.decTest
index 121945c755..a4c4274372 100644
--- a/Lib/test/decimaltestdata/ddCopyNegate.decTest
+++ b/Lib/test/decimaltestdata/ddCopyNegate.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddCopyNegate.decTest -- quiet decDouble copy and negate --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddcpn001 copynegate +7.50 -> -7.50
-
--- Infinities
-ddcpn011 copynegate Infinity -> -Infinity
-ddcpn012 copynegate -Infinity -> Infinity
-
--- NaNs, 0 payload
-ddcpn021 copynegate NaN -> -NaN
-ddcpn022 copynegate -NaN -> NaN
-ddcpn023 copynegate sNaN -> -sNaN
-ddcpn024 copynegate -sNaN -> sNaN
-
--- NaNs, non-0 payload
-ddcpn031 copynegate NaN13 -> -NaN13
-ddcpn032 copynegate -NaN13 -> NaN13
-ddcpn033 copynegate sNaN13 -> -sNaN13
-ddcpn034 copynegate -sNaN13 -> sNaN13
-ddcpn035 copynegate NaN70 -> -NaN70
-ddcpn036 copynegate -NaN70 -> NaN70
-ddcpn037 copynegate sNaN101 -> -sNaN101
-ddcpn038 copynegate -sNaN101 -> sNaN101
-
--- finites
-ddcpn101 copynegate 7 -> -7
-ddcpn102 copynegate -7 -> 7
-ddcpn103 copynegate 75 -> -75
-ddcpn104 copynegate -75 -> 75
-ddcpn105 copynegate 7.50 -> -7.50
-ddcpn106 copynegate -7.50 -> 7.50
-ddcpn107 copynegate 7.500 -> -7.500
-ddcpn108 copynegate -7.500 -> 7.500
-
--- zeros
-ddcpn111 copynegate 0 -> -0
-ddcpn112 copynegate -0 -> 0
-ddcpn113 copynegate 0E+4 -> -0E+4
-ddcpn114 copynegate -0E+4 -> 0E+4
-ddcpn115 copynegate 0.0000 -> -0.0000
-ddcpn116 copynegate -0.0000 -> 0.0000
-ddcpn117 copynegate 0E-141 -> -0E-141
-ddcpn118 copynegate -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddcpn121 copynegate 2682682682682682 -> -2682682682682682
-ddcpn122 copynegate -2682682682682682 -> 2682682682682682
-ddcpn123 copynegate 1341341341341341 -> -1341341341341341
-ddcpn124 copynegate -1341341341341341 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcpn131 copynegate 9.999999999999999E+384 -> -9.999999999999999E+384
-ddcpn132 copynegate 1E-383 -> -1E-383
-ddcpn133 copynegate 1.000000000000000E-383 -> -1.000000000000000E-383
-ddcpn134 copynegate 1E-398 -> -1E-398
-
-ddcpn135 copynegate -1E-398 -> 1E-398
-ddcpn136 copynegate -1.000000000000000E-383 -> 1.000000000000000E-383
-ddcpn137 copynegate -1E-383 -> 1E-383
-ddcpn138 copynegate -9.999999999999999E+384 -> 9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddCopyNegate.decTest -- quiet decDouble copy and negate --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddcpn001 copynegate +7.50 -> -7.50
+
+-- Infinities
+ddcpn011 copynegate Infinity -> -Infinity
+ddcpn012 copynegate -Infinity -> Infinity
+
+-- NaNs, 0 payload
+ddcpn021 copynegate NaN -> -NaN
+ddcpn022 copynegate -NaN -> NaN
+ddcpn023 copynegate sNaN -> -sNaN
+ddcpn024 copynegate -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+ddcpn031 copynegate NaN13 -> -NaN13
+ddcpn032 copynegate -NaN13 -> NaN13
+ddcpn033 copynegate sNaN13 -> -sNaN13
+ddcpn034 copynegate -sNaN13 -> sNaN13
+ddcpn035 copynegate NaN70 -> -NaN70
+ddcpn036 copynegate -NaN70 -> NaN70
+ddcpn037 copynegate sNaN101 -> -sNaN101
+ddcpn038 copynegate -sNaN101 -> sNaN101
+
+-- finites
+ddcpn101 copynegate 7 -> -7
+ddcpn102 copynegate -7 -> 7
+ddcpn103 copynegate 75 -> -75
+ddcpn104 copynegate -75 -> 75
+ddcpn105 copynegate 7.50 -> -7.50
+ddcpn106 copynegate -7.50 -> 7.50
+ddcpn107 copynegate 7.500 -> -7.500
+ddcpn108 copynegate -7.500 -> 7.500
+
+-- zeros
+ddcpn111 copynegate 0 -> -0
+ddcpn112 copynegate -0 -> 0
+ddcpn113 copynegate 0E+4 -> -0E+4
+ddcpn114 copynegate -0E+4 -> 0E+4
+ddcpn115 copynegate 0.0000 -> -0.0000
+ddcpn116 copynegate -0.0000 -> 0.0000
+ddcpn117 copynegate 0E-141 -> -0E-141
+ddcpn118 copynegate -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddcpn121 copynegate 2682682682682682 -> -2682682682682682
+ddcpn122 copynegate -2682682682682682 -> 2682682682682682
+ddcpn123 copynegate 1341341341341341 -> -1341341341341341
+ddcpn124 copynegate -1341341341341341 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcpn131 copynegate 9.999999999999999E+384 -> -9.999999999999999E+384
+ddcpn132 copynegate 1E-383 -> -1E-383
+ddcpn133 copynegate 1.000000000000000E-383 -> -1.000000000000000E-383
+ddcpn134 copynegate 1E-398 -> -1E-398
+
+ddcpn135 copynegate -1E-398 -> 1E-398
+ddcpn136 copynegate -1.000000000000000E-383 -> 1.000000000000000E-383
+ddcpn137 copynegate -1E-383 -> 1E-383
+ddcpn138 copynegate -9.999999999999999E+384 -> 9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddCopySign.decTest b/Lib/test/decimaltestdata/ddCopySign.decTest
index c99544d9ab..6a78083ad5 100644
--- a/Lib/test/decimaltestdata/ddCopySign.decTest
+++ b/Lib/test/decimaltestdata/ddCopySign.decTest
@@ -1,175 +1,175 @@
-------------------------------------------------------------------------
--- ddCopySign.decTest -- quiet decDouble copy with sign from rhs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddcps001 copysign +7.50 11 -> 7.50
-
--- Infinities
-ddcps011 copysign Infinity 11 -> Infinity
-ddcps012 copysign -Infinity 11 -> Infinity
-
--- NaNs, 0 payload
-ddcps021 copysign NaN 11 -> NaN
-ddcps022 copysign -NaN 11 -> NaN
-ddcps023 copysign sNaN 11 -> sNaN
-ddcps024 copysign -sNaN 11 -> sNaN
-
--- NaNs, non-0 payload
-ddcps031 copysign NaN10 11 -> NaN10
-ddcps032 copysign -NaN10 11 -> NaN10
-ddcps033 copysign sNaN10 11 -> sNaN10
-ddcps034 copysign -sNaN10 11 -> sNaN10
-ddcps035 copysign NaN7 11 -> NaN7
-ddcps036 copysign -NaN7 11 -> NaN7
-ddcps037 copysign sNaN101 11 -> sNaN101
-ddcps038 copysign -sNaN101 11 -> sNaN101
-
--- finites
-ddcps101 copysign 7 11 -> 7
-ddcps102 copysign -7 11 -> 7
-ddcps103 copysign 75 11 -> 75
-ddcps104 copysign -75 11 -> 75
-ddcps105 copysign 7.50 11 -> 7.50
-ddcps106 copysign -7.50 11 -> 7.50
-ddcps107 copysign 7.500 11 -> 7.500
-ddcps108 copysign -7.500 11 -> 7.500
-
--- zeros
-ddcps111 copysign 0 11 -> 0
-ddcps112 copysign -0 11 -> 0
-ddcps113 copysign 0E+4 11 -> 0E+4
-ddcps114 copysign -0E+4 11 -> 0E+4
-ddcps115 copysign 0.0000 11 -> 0.0000
-ddcps116 copysign -0.0000 11 -> 0.0000
-ddcps117 copysign 0E-141 11 -> 0E-141
-ddcps118 copysign -0E-141 11 -> 0E-141
-
--- full coefficients, alternating bits
-ddcps121 copysign 2682682682682682 11 -> 2682682682682682
-ddcps122 copysign -2682682682682682 11 -> 2682682682682682
-ddcps123 copysign 1341341341341341 11 -> 1341341341341341
-ddcps124 copysign -1341341341341341 11 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcps131 copysign 9.999999999999999E+384 11 -> 9.999999999999999E+384
-ddcps132 copysign 1E-383 11 -> 1E-383
-ddcps133 copysign 1.000000000000000E-383 11 -> 1.000000000000000E-383
-ddcps134 copysign 1E-398 11 -> 1E-398
-
-ddcps135 copysign -1E-398 11 -> 1E-398
-ddcps136 copysign -1.000000000000000E-383 11 -> 1.000000000000000E-383
-ddcps137 copysign -1E-383 11 -> 1E-383
-ddcps138 copysign -9.999999999999999E+384 11 -> 9.999999999999999E+384
-
--- repeat with negative RHS
-
--- Infinities
-ddcps211 copysign Infinity -34 -> -Infinity
-ddcps212 copysign -Infinity -34 -> -Infinity
-
--- NaNs, 0 payload
-ddcps221 copysign NaN -34 -> -NaN
-ddcps222 copysign -NaN -34 -> -NaN
-ddcps223 copysign sNaN -34 -> -sNaN
-ddcps224 copysign -sNaN -34 -> -sNaN
-
--- NaNs, non-0 payload
-ddcps231 copysign NaN10 -34 -> -NaN10
-ddcps232 copysign -NaN10 -34 -> -NaN10
-ddcps233 copysign sNaN10 -34 -> -sNaN10
-ddcps234 copysign -sNaN10 -34 -> -sNaN10
-ddcps235 copysign NaN7 -34 -> -NaN7
-ddcps236 copysign -NaN7 -34 -> -NaN7
-ddcps237 copysign sNaN101 -34 -> -sNaN101
-ddcps238 copysign -sNaN101 -34 -> -sNaN101
-
--- finites
-ddcps301 copysign 7 -34 -> -7
-ddcps302 copysign -7 -34 -> -7
-ddcps303 copysign 75 -34 -> -75
-ddcps304 copysign -75 -34 -> -75
-ddcps305 copysign 7.50 -34 -> -7.50
-ddcps306 copysign -7.50 -34 -> -7.50
-ddcps307 copysign 7.500 -34 -> -7.500
-ddcps308 copysign -7.500 -34 -> -7.500
-
--- zeros
-ddcps311 copysign 0 -34 -> -0
-ddcps312 copysign -0 -34 -> -0
-ddcps313 copysign 0E+4 -34 -> -0E+4
-ddcps314 copysign -0E+4 -34 -> -0E+4
-ddcps315 copysign 0.0000 -34 -> -0.0000
-ddcps316 copysign -0.0000 -34 -> -0.0000
-ddcps317 copysign 0E-141 -34 -> -0E-141
-ddcps318 copysign -0E-141 -34 -> -0E-141
-
--- full coefficients, alternating bits
-ddcps321 copysign 2682682682682682 -34 -> -2682682682682682
-ddcps322 copysign -2682682682682682 -34 -> -2682682682682682
-ddcps323 copysign 1341341341341341 -34 -> -1341341341341341
-ddcps324 copysign -1341341341341341 -34 -> -1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcps331 copysign 9.999999999999999E+384 -34 -> -9.999999999999999E+384
-ddcps332 copysign 1E-383 -34 -> -1E-383
-ddcps333 copysign 1.000000000000000E-383 -34 -> -1.000000000000000E-383
-ddcps334 copysign 1E-398 -34 -> -1E-398
-
-ddcps335 copysign -1E-398 -34 -> -1E-398
-ddcps336 copysign -1.000000000000000E-383 -34 -> -1.000000000000000E-383
-ddcps337 copysign -1E-383 -34 -> -1E-383
-ddcps338 copysign -9.999999999999999E+384 -34 -> -9.999999999999999E+384
-
--- Other kinds of RHS
-ddcps401 copysign 701 -34 -> -701
-ddcps402 copysign -720 -34 -> -720
-ddcps403 copysign 701 -0 -> -701
-ddcps404 copysign -720 -0 -> -720
-ddcps405 copysign 701 +0 -> 701
-ddcps406 copysign -720 +0 -> 720
-ddcps407 copysign 701 +34 -> 701
-ddcps408 copysign -720 +34 -> 720
-
-ddcps413 copysign 701 -Inf -> -701
-ddcps414 copysign -720 -Inf -> -720
-ddcps415 copysign 701 +Inf -> 701
-ddcps416 copysign -720 +Inf -> 720
-
-ddcps420 copysign 701 -NaN -> -701
-ddcps421 copysign -720 -NaN -> -720
-ddcps422 copysign 701 +NaN -> 701
-ddcps423 copysign -720 +NaN -> 720
-ddcps425 copysign -720 +NaN8 -> 720
-
-ddcps426 copysign 701 -sNaN -> -701
-ddcps427 copysign -720 -sNaN -> -720
-ddcps428 copysign 701 +sNaN -> 701
-ddcps429 copysign -720 +sNaN -> 720
-ddcps430 copysign -720 +sNaN3 -> 720
-
+------------------------------------------------------------------------
+-- ddCopySign.decTest -- quiet decDouble copy with sign from rhs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddcps001 copysign +7.50 11 -> 7.50
+
+-- Infinities
+ddcps011 copysign Infinity 11 -> Infinity
+ddcps012 copysign -Infinity 11 -> Infinity
+
+-- NaNs, 0 payload
+ddcps021 copysign NaN 11 -> NaN
+ddcps022 copysign -NaN 11 -> NaN
+ddcps023 copysign sNaN 11 -> sNaN
+ddcps024 copysign -sNaN 11 -> sNaN
+
+-- NaNs, non-0 payload
+ddcps031 copysign NaN10 11 -> NaN10
+ddcps032 copysign -NaN10 11 -> NaN10
+ddcps033 copysign sNaN10 11 -> sNaN10
+ddcps034 copysign -sNaN10 11 -> sNaN10
+ddcps035 copysign NaN7 11 -> NaN7
+ddcps036 copysign -NaN7 11 -> NaN7
+ddcps037 copysign sNaN101 11 -> sNaN101
+ddcps038 copysign -sNaN101 11 -> sNaN101
+
+-- finites
+ddcps101 copysign 7 11 -> 7
+ddcps102 copysign -7 11 -> 7
+ddcps103 copysign 75 11 -> 75
+ddcps104 copysign -75 11 -> 75
+ddcps105 copysign 7.50 11 -> 7.50
+ddcps106 copysign -7.50 11 -> 7.50
+ddcps107 copysign 7.500 11 -> 7.500
+ddcps108 copysign -7.500 11 -> 7.500
+
+-- zeros
+ddcps111 copysign 0 11 -> 0
+ddcps112 copysign -0 11 -> 0
+ddcps113 copysign 0E+4 11 -> 0E+4
+ddcps114 copysign -0E+4 11 -> 0E+4
+ddcps115 copysign 0.0000 11 -> 0.0000
+ddcps116 copysign -0.0000 11 -> 0.0000
+ddcps117 copysign 0E-141 11 -> 0E-141
+ddcps118 copysign -0E-141 11 -> 0E-141
+
+-- full coefficients, alternating bits
+ddcps121 copysign 2682682682682682 11 -> 2682682682682682
+ddcps122 copysign -2682682682682682 11 -> 2682682682682682
+ddcps123 copysign 1341341341341341 11 -> 1341341341341341
+ddcps124 copysign -1341341341341341 11 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcps131 copysign 9.999999999999999E+384 11 -> 9.999999999999999E+384
+ddcps132 copysign 1E-383 11 -> 1E-383
+ddcps133 copysign 1.000000000000000E-383 11 -> 1.000000000000000E-383
+ddcps134 copysign 1E-398 11 -> 1E-398
+
+ddcps135 copysign -1E-398 11 -> 1E-398
+ddcps136 copysign -1.000000000000000E-383 11 -> 1.000000000000000E-383
+ddcps137 copysign -1E-383 11 -> 1E-383
+ddcps138 copysign -9.999999999999999E+384 11 -> 9.999999999999999E+384
+
+-- repeat with negative RHS
+
+-- Infinities
+ddcps211 copysign Infinity -34 -> -Infinity
+ddcps212 copysign -Infinity -34 -> -Infinity
+
+-- NaNs, 0 payload
+ddcps221 copysign NaN -34 -> -NaN
+ddcps222 copysign -NaN -34 -> -NaN
+ddcps223 copysign sNaN -34 -> -sNaN
+ddcps224 copysign -sNaN -34 -> -sNaN
+
+-- NaNs, non-0 payload
+ddcps231 copysign NaN10 -34 -> -NaN10
+ddcps232 copysign -NaN10 -34 -> -NaN10
+ddcps233 copysign sNaN10 -34 -> -sNaN10
+ddcps234 copysign -sNaN10 -34 -> -sNaN10
+ddcps235 copysign NaN7 -34 -> -NaN7
+ddcps236 copysign -NaN7 -34 -> -NaN7
+ddcps237 copysign sNaN101 -34 -> -sNaN101
+ddcps238 copysign -sNaN101 -34 -> -sNaN101
+
+-- finites
+ddcps301 copysign 7 -34 -> -7
+ddcps302 copysign -7 -34 -> -7
+ddcps303 copysign 75 -34 -> -75
+ddcps304 copysign -75 -34 -> -75
+ddcps305 copysign 7.50 -34 -> -7.50
+ddcps306 copysign -7.50 -34 -> -7.50
+ddcps307 copysign 7.500 -34 -> -7.500
+ddcps308 copysign -7.500 -34 -> -7.500
+
+-- zeros
+ddcps311 copysign 0 -34 -> -0
+ddcps312 copysign -0 -34 -> -0
+ddcps313 copysign 0E+4 -34 -> -0E+4
+ddcps314 copysign -0E+4 -34 -> -0E+4
+ddcps315 copysign 0.0000 -34 -> -0.0000
+ddcps316 copysign -0.0000 -34 -> -0.0000
+ddcps317 copysign 0E-141 -34 -> -0E-141
+ddcps318 copysign -0E-141 -34 -> -0E-141
+
+-- full coefficients, alternating bits
+ddcps321 copysign 2682682682682682 -34 -> -2682682682682682
+ddcps322 copysign -2682682682682682 -34 -> -2682682682682682
+ddcps323 copysign 1341341341341341 -34 -> -1341341341341341
+ddcps324 copysign -1341341341341341 -34 -> -1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcps331 copysign 9.999999999999999E+384 -34 -> -9.999999999999999E+384
+ddcps332 copysign 1E-383 -34 -> -1E-383
+ddcps333 copysign 1.000000000000000E-383 -34 -> -1.000000000000000E-383
+ddcps334 copysign 1E-398 -34 -> -1E-398
+
+ddcps335 copysign -1E-398 -34 -> -1E-398
+ddcps336 copysign -1.000000000000000E-383 -34 -> -1.000000000000000E-383
+ddcps337 copysign -1E-383 -34 -> -1E-383
+ddcps338 copysign -9.999999999999999E+384 -34 -> -9.999999999999999E+384
+
+-- Other kinds of RHS
+ddcps401 copysign 701 -34 -> -701
+ddcps402 copysign -720 -34 -> -720
+ddcps403 copysign 701 -0 -> -701
+ddcps404 copysign -720 -0 -> -720
+ddcps405 copysign 701 +0 -> 701
+ddcps406 copysign -720 +0 -> 720
+ddcps407 copysign 701 +34 -> 701
+ddcps408 copysign -720 +34 -> 720
+
+ddcps413 copysign 701 -Inf -> -701
+ddcps414 copysign -720 -Inf -> -720
+ddcps415 copysign 701 +Inf -> 701
+ddcps416 copysign -720 +Inf -> 720
+
+ddcps420 copysign 701 -NaN -> -701
+ddcps421 copysign -720 -NaN -> -720
+ddcps422 copysign 701 +NaN -> 701
+ddcps423 copysign -720 +NaN -> 720
+ddcps425 copysign -720 +NaN8 -> 720
+
+ddcps426 copysign 701 -sNaN -> -701
+ddcps427 copysign -720 -sNaN -> -720
+ddcps428 copysign 701 +sNaN -> 701
+ddcps429 copysign -720 +sNaN -> 720
+ddcps430 copysign -720 +sNaN3 -> 720
+
diff --git a/Lib/test/decimaltestdata/ddDivide.decTest b/Lib/test/decimaltestdata/ddDivide.decTest
index 019db228d4..5531d0e031 100644
--- a/Lib/test/decimaltestdata/ddDivide.decTest
+++ b/Lib/test/decimaltestdata/ddDivide.decTest
@@ -1,863 +1,863 @@
-------------------------------------------------------------------------
--- ddDivide.decTest -- decDouble division --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-dddiv001 divide 1 1 -> 1
-dddiv002 divide 2 1 -> 2
-dddiv003 divide 1 2 -> 0.5
-dddiv004 divide 2 2 -> 1
-dddiv005 divide 0 1 -> 0
-dddiv006 divide 0 2 -> 0
-dddiv007 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv008 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv009 divide 3 3 -> 1
-
-dddiv010 divide 2.4 1 -> 2.4
-dddiv011 divide 2.4 -1 -> -2.4
-dddiv012 divide -2.4 1 -> -2.4
-dddiv013 divide -2.4 -1 -> 2.4
-dddiv014 divide 2.40 1 -> 2.40
-dddiv015 divide 2.400 1 -> 2.400
-dddiv016 divide 2.4 2 -> 1.2
-dddiv017 divide 2.400 2 -> 1.200
-dddiv018 divide 2. 2 -> 1
-dddiv019 divide 20 20 -> 1
-
-dddiv020 divide 187 187 -> 1
-dddiv021 divide 5 2 -> 2.5
-dddiv022 divide 50 20 -> 2.5
-dddiv023 divide 500 200 -> 2.5
-dddiv024 divide 50.0 20.0 -> 2.5
-dddiv025 divide 5.00 2.00 -> 2.5
-dddiv026 divide 5 2.0 -> 2.5
-dddiv027 divide 5 2.000 -> 2.5
-dddiv028 divide 5 0.20 -> 25
-dddiv029 divide 5 0.200 -> 25
-dddiv030 divide 10 1 -> 10
-dddiv031 divide 100 1 -> 100
-dddiv032 divide 1000 1 -> 1000
-dddiv033 divide 1000 100 -> 10
-
-dddiv035 divide 1 2 -> 0.5
-dddiv036 divide 1 4 -> 0.25
-dddiv037 divide 1 8 -> 0.125
-dddiv038 divide 1 16 -> 0.0625
-dddiv039 divide 1 32 -> 0.03125
-dddiv040 divide 1 64 -> 0.015625
-dddiv041 divide 1 -2 -> -0.5
-dddiv042 divide 1 -4 -> -0.25
-dddiv043 divide 1 -8 -> -0.125
-dddiv044 divide 1 -16 -> -0.0625
-dddiv045 divide 1 -32 -> -0.03125
-dddiv046 divide 1 -64 -> -0.015625
-dddiv047 divide -1 2 -> -0.5
-dddiv048 divide -1 4 -> -0.25
-dddiv049 divide -1 8 -> -0.125
-dddiv050 divide -1 16 -> -0.0625
-dddiv051 divide -1 32 -> -0.03125
-dddiv052 divide -1 64 -> -0.015625
-dddiv053 divide -1 -2 -> 0.5
-dddiv054 divide -1 -4 -> 0.25
-dddiv055 divide -1 -8 -> 0.125
-dddiv056 divide -1 -16 -> 0.0625
-dddiv057 divide -1 -32 -> 0.03125
-dddiv058 divide -1 -64 -> 0.015625
-
--- bcdTime
-dddiv060 divide 1 7 -> 0.1428571428571429 Inexact Rounded
-dddiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717 Inexact Rounded
-
--- 1234567890123456
-dddiv071 divide 9999999999999999 1 -> 9999999999999999
-dddiv072 divide 999999999999999 1 -> 999999999999999
-dddiv073 divide 99999999999999 1 -> 99999999999999
-dddiv074 divide 9999999999999 1 -> 9999999999999
-dddiv075 divide 999999999999 1 -> 999999999999
-dddiv076 divide 99999999999 1 -> 99999999999
-dddiv077 divide 9999999999 1 -> 9999999999
-dddiv078 divide 999999999 1 -> 999999999
-dddiv079 divide 99999999 1 -> 99999999
-dddiv080 divide 9999999 1 -> 9999999
-dddiv081 divide 999999 1 -> 999999
-dddiv082 divide 99999 1 -> 99999
-dddiv083 divide 9999 1 -> 9999
-dddiv084 divide 999 1 -> 999
-dddiv085 divide 99 1 -> 99
-dddiv086 divide 9 1 -> 9
-
-dddiv090 divide 0. 1 -> 0
-dddiv091 divide .0 1 -> 0.0
-dddiv092 divide 0.00 1 -> 0.00
-dddiv093 divide 0.00E+9 1 -> 0E+7
-dddiv094 divide 0.0000E-50 1 -> 0E-54
-
-dddiv095 divide 1 1E-8 -> 1E+8
-dddiv096 divide 1 1E-9 -> 1E+9
-dddiv097 divide 1 1E-10 -> 1E+10
-dddiv098 divide 1 1E-11 -> 1E+11
-dddiv099 divide 1 1E-12 -> 1E+12
-
-dddiv100 divide 1 1 -> 1
-dddiv101 divide 1 2 -> 0.5
-dddiv102 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv103 divide 1 4 -> 0.25
-dddiv104 divide 1 5 -> 0.2
-dddiv105 divide 1 6 -> 0.1666666666666667 Inexact Rounded
-dddiv106 divide 1 7 -> 0.1428571428571429 Inexact Rounded
-dddiv107 divide 1 8 -> 0.125
-dddiv108 divide 1 9 -> 0.1111111111111111 Inexact Rounded
-dddiv109 divide 1 10 -> 0.1
-dddiv110 divide 1 1 -> 1
-dddiv111 divide 2 1 -> 2
-dddiv112 divide 3 1 -> 3
-dddiv113 divide 4 1 -> 4
-dddiv114 divide 5 1 -> 5
-dddiv115 divide 6 1 -> 6
-dddiv116 divide 7 1 -> 7
-dddiv117 divide 8 1 -> 8
-dddiv118 divide 9 1 -> 9
-dddiv119 divide 10 1 -> 10
-
-dddiv120 divide 3E+1 0.001 -> 3E+4
-dddiv121 divide 2.200 2 -> 1.100
-
-dddiv130 divide 12345 4.999 -> 2469.493898779756 Inexact Rounded
-dddiv131 divide 12345 4.99 -> 2473.947895791583 Inexact Rounded
-dddiv132 divide 12345 4.9 -> 2519.387755102041 Inexact Rounded
-dddiv133 divide 12345 5 -> 2469
-dddiv134 divide 12345 5.1 -> 2420.588235294118 Inexact Rounded
-dddiv135 divide 12345 5.01 -> 2464.071856287425 Inexact Rounded
-dddiv136 divide 12345 5.001 -> 2468.506298740252 Inexact Rounded
-
--- test possibly imprecise results
-dddiv220 divide 391 597 -> 0.6549413735343384 Inexact Rounded
-dddiv221 divide 391 -597 -> -0.6549413735343384 Inexact Rounded
-dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded
-dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded
-
--- test some cases that are close to exponent overflow, some with coefficient padding
-dddiv270 divide 1 1e384 -> 1E-384 Subnormal
-dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow
-dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow
-dddiv273 divide 1 0.9999999999999999e384 -> 1.00000000000000E-384 Rounded Inexact Subnormal Underflow
-dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped
-dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped
-dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped
-dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped
-dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped
-dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384
-
-dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped
-dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded
-dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped
-dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded
-dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped
-
-
--- Divide into 0 tests
-dddiv301 divide 0 7 -> 0
-dddiv302 divide 0 7E-5 -> 0E+5
-dddiv303 divide 0 7E-1 -> 0E+1
-dddiv304 divide 0 7E+1 -> 0.0
-dddiv305 divide 0 7E+5 -> 0.00000
-dddiv306 divide 0 7E+6 -> 0.000000
-dddiv307 divide 0 7E+7 -> 0E-7
-dddiv308 divide 0 70E-5 -> 0E+5
-dddiv309 divide 0 70E-1 -> 0E+1
-dddiv310 divide 0 70E+0 -> 0
-dddiv311 divide 0 70E+1 -> 0.0
-dddiv312 divide 0 70E+5 -> 0.00000
-dddiv313 divide 0 70E+6 -> 0.000000
-dddiv314 divide 0 70E+7 -> 0E-7
-dddiv315 divide 0 700E-5 -> 0E+5
-dddiv316 divide 0 700E-1 -> 0E+1
-dddiv317 divide 0 700E+0 -> 0
-dddiv318 divide 0 700E+1 -> 0.0
-dddiv319 divide 0 700E+5 -> 0.00000
-dddiv320 divide 0 700E+6 -> 0.000000
-dddiv321 divide 0 700E+7 -> 0E-7
-dddiv322 divide 0 700E+77 -> 0E-77
-
-dddiv331 divide 0E-3 7E-5 -> 0E+2
-dddiv332 divide 0E-3 7E-1 -> 0.00
-dddiv333 divide 0E-3 7E+1 -> 0.0000
-dddiv334 divide 0E-3 7E+5 -> 0E-8
-dddiv335 divide 0E-1 7E-5 -> 0E+4
-dddiv336 divide 0E-1 7E-1 -> 0
-dddiv337 divide 0E-1 7E+1 -> 0.00
-dddiv338 divide 0E-1 7E+5 -> 0.000000
-dddiv339 divide 0E+1 7E-5 -> 0E+6
-dddiv340 divide 0E+1 7E-1 -> 0E+2
-dddiv341 divide 0E+1 7E+1 -> 0
-dddiv342 divide 0E+1 7E+5 -> 0.0000
-dddiv343 divide 0E+3 7E-5 -> 0E+8
-dddiv344 divide 0E+3 7E-1 -> 0E+4
-dddiv345 divide 0E+3 7E+1 -> 0E+2
-dddiv346 divide 0E+3 7E+5 -> 0.00
-
--- These were 'input rounding'
-dddiv441 divide 12345678000 1 -> 12345678000
-dddiv442 divide 1 12345678000 -> 8.100000664200054E-11 Inexact Rounded
-dddiv443 divide 1234567800 1 -> 1234567800
-dddiv444 divide 1 1234567800 -> 8.100000664200054E-10 Inexact Rounded
-dddiv445 divide 1234567890 1 -> 1234567890
-dddiv446 divide 1 1234567890 -> 8.100000073710001E-10 Inexact Rounded
-dddiv447 divide 1234567891 1 -> 1234567891
-dddiv448 divide 1 1234567891 -> 8.100000067149001E-10 Inexact Rounded
-dddiv449 divide 12345678901 1 -> 12345678901
-dddiv450 divide 1 12345678901 -> 8.100000073053901E-11 Inexact Rounded
-dddiv451 divide 1234567896 1 -> 1234567896
-dddiv452 divide 1 1234567896 -> 8.100000034344000E-10 Inexact Rounded
-
--- high-lows
-dddiv453 divide 1e+1 1 -> 1E+1
-dddiv454 divide 1e+1 1.0 -> 1E+1
-dddiv455 divide 1e+1 1.00 -> 1E+1
-dddiv456 divide 1e+2 2 -> 5E+1
-dddiv457 divide 1e+2 2.0 -> 5E+1
-dddiv458 divide 1e+2 2.00 -> 5E+1
-
--- some from IEEE discussions
-dddiv460 divide 3e0 2e0 -> 1.5
-dddiv461 divide 30e-1 2e0 -> 1.5
-dddiv462 divide 300e-2 2e0 -> 1.50
-dddiv464 divide 3000e-3 2e0 -> 1.500
-dddiv465 divide 3e0 20e-1 -> 1.5
-dddiv466 divide 30e-1 20e-1 -> 1.5
-dddiv467 divide 300e-2 20e-1 -> 1.5
-dddiv468 divide 3000e-3 20e-1 -> 1.50
-dddiv469 divide 3e0 200e-2 -> 1.5
-dddiv470 divide 30e-1 200e-2 -> 1.5
-dddiv471 divide 300e-2 200e-2 -> 1.5
-dddiv472 divide 3000e-3 200e-2 -> 1.5
-dddiv473 divide 3e0 2000e-3 -> 1.5
-dddiv474 divide 30e-1 2000e-3 -> 1.5
-dddiv475 divide 300e-2 2000e-3 -> 1.5
-dddiv476 divide 3000e-3 2000e-3 -> 1.5
-
--- some reciprocals
-dddiv480 divide 1 1.0E+33 -> 1E-33
-dddiv481 divide 1 10E+33 -> 1E-34
-dddiv482 divide 1 1.0E-33 -> 1E+33
-dddiv483 divide 1 10E-33 -> 1E+32
-
--- RMS discussion table
-dddiv484 divide 0e5 1e3 -> 0E+2
-dddiv485 divide 0e5 2e3 -> 0E+2
-dddiv486 divide 0e5 10e2 -> 0E+3
-dddiv487 divide 0e5 20e2 -> 0E+3
-dddiv488 divide 0e5 100e1 -> 0E+4
-dddiv489 divide 0e5 200e1 -> 0E+4
-
-dddiv491 divide 1e5 1e3 -> 1E+2
-dddiv492 divide 1e5 2e3 -> 5E+1
-dddiv493 divide 1e5 10e2 -> 1E+2
-dddiv494 divide 1e5 20e2 -> 5E+1
-dddiv495 divide 1e5 100e1 -> 1E+2
-dddiv496 divide 1e5 200e1 -> 5E+1
-
--- tryzeros cases
-rounding: half_up
-dddiv497 divide 0E+380 1000E-13 -> 0E+369 Clamped
-dddiv498 divide 0E-390 1000E+13 -> 0E-398 Clamped
-
-rounding: half_up
-
--- focus on trailing zeros issues
-dddiv500 divide 1 9.9 -> 0.1010101010101010 Inexact Rounded
-dddiv501 divide 1 9.09 -> 0.1100110011001100 Inexact Rounded
-dddiv502 divide 1 9.009 -> 0.1110001110001110 Inexact Rounded
-
-dddiv511 divide 1 2 -> 0.5
-dddiv512 divide 1.0 2 -> 0.5
-dddiv513 divide 1.00 2 -> 0.50
-dddiv514 divide 1.000 2 -> 0.500
-dddiv515 divide 1.0000 2 -> 0.5000
-dddiv516 divide 1.00000 2 -> 0.50000
-dddiv517 divide 1.000000 2 -> 0.500000
-dddiv518 divide 1.0000000 2 -> 0.5000000
-dddiv519 divide 1.00 2.00 -> 0.5
-
-dddiv521 divide 2 1 -> 2
-dddiv522 divide 2 1.0 -> 2
-dddiv523 divide 2 1.00 -> 2
-dddiv524 divide 2 1.000 -> 2
-dddiv525 divide 2 1.0000 -> 2
-dddiv526 divide 2 1.00000 -> 2
-dddiv527 divide 2 1.000000 -> 2
-dddiv528 divide 2 1.0000000 -> 2
-dddiv529 divide 2.00 1.00 -> 2
-
-dddiv530 divide 2.40 2 -> 1.20
-dddiv531 divide 2.40 4 -> 0.60
-dddiv532 divide 2.40 10 -> 0.24
-dddiv533 divide 2.40 2.0 -> 1.2
-dddiv534 divide 2.40 4.0 -> 0.6
-dddiv535 divide 2.40 10.0 -> 0.24
-dddiv536 divide 2.40 2.00 -> 1.2
-dddiv537 divide 2.40 4.00 -> 0.6
-dddiv538 divide 2.40 10.00 -> 0.24
-dddiv539 divide 0.9 0.1 -> 9
-dddiv540 divide 0.9 0.01 -> 9E+1
-dddiv541 divide 0.9 0.001 -> 9E+2
-dddiv542 divide 5 2 -> 2.5
-dddiv543 divide 5 2.0 -> 2.5
-dddiv544 divide 5 2.00 -> 2.5
-dddiv545 divide 5 20 -> 0.25
-dddiv546 divide 5 20.0 -> 0.25
-dddiv547 divide 2.400 2 -> 1.200
-dddiv548 divide 2.400 2.0 -> 1.20
-dddiv549 divide 2.400 2.400 -> 1
-
-dddiv550 divide 240 1 -> 240
-dddiv551 divide 240 10 -> 24
-dddiv552 divide 240 100 -> 2.4
-dddiv553 divide 240 1000 -> 0.24
-dddiv554 divide 2400 1 -> 2400
-dddiv555 divide 2400 10 -> 240
-dddiv556 divide 2400 100 -> 24
-dddiv557 divide 2400 1000 -> 2.4
-
--- +ve exponent
-dddiv600 divide 2.4E+9 2 -> 1.2E+9
-dddiv601 divide 2.40E+9 2 -> 1.20E+9
-dddiv602 divide 2.400E+9 2 -> 1.200E+9
-dddiv603 divide 2.4000E+9 2 -> 1.2000E+9
-dddiv604 divide 24E+8 2 -> 1.2E+9
-dddiv605 divide 240E+7 2 -> 1.20E+9
-dddiv606 divide 2400E+6 2 -> 1.200E+9
-dddiv607 divide 24000E+5 2 -> 1.2000E+9
-
--- more zeros, etc.
-dddiv731 divide 5.00 1E-3 -> 5.00E+3
-dddiv732 divide 00.00 0.000 -> NaN Division_undefined
-dddiv733 divide 00.00 0E-3 -> NaN Division_undefined
-dddiv734 divide 0 -0 -> NaN Division_undefined
-dddiv735 divide -0 0 -> NaN Division_undefined
-dddiv736 divide -0 -0 -> NaN Division_undefined
-
-dddiv741 divide 0 -1 -> -0
-dddiv742 divide -0 -1 -> 0
-dddiv743 divide 0 1 -> 0
-dddiv744 divide -0 1 -> -0
-dddiv745 divide -1 0 -> -Infinity Division_by_zero
-dddiv746 divide -1 -0 -> Infinity Division_by_zero
-dddiv747 divide 1 0 -> Infinity Division_by_zero
-dddiv748 divide 1 -0 -> -Infinity Division_by_zero
-
-dddiv751 divide 0.0 -1 -> -0.0
-dddiv752 divide -0.0 -1 -> 0.0
-dddiv753 divide 0.0 1 -> 0.0
-dddiv754 divide -0.0 1 -> -0.0
-dddiv755 divide -1.0 0 -> -Infinity Division_by_zero
-dddiv756 divide -1.0 -0 -> Infinity Division_by_zero
-dddiv757 divide 1.0 0 -> Infinity Division_by_zero
-dddiv758 divide 1.0 -0 -> -Infinity Division_by_zero
-
-dddiv761 divide 0 -1.0 -> -0E+1
-dddiv762 divide -0 -1.0 -> 0E+1
-dddiv763 divide 0 1.0 -> 0E+1
-dddiv764 divide -0 1.0 -> -0E+1
-dddiv765 divide -1 0.0 -> -Infinity Division_by_zero
-dddiv766 divide -1 -0.0 -> Infinity Division_by_zero
-dddiv767 divide 1 0.0 -> Infinity Division_by_zero
-dddiv768 divide 1 -0.0 -> -Infinity Division_by_zero
-
-dddiv771 divide 0.0 -1.0 -> -0
-dddiv772 divide -0.0 -1.0 -> 0
-dddiv773 divide 0.0 1.0 -> 0
-dddiv774 divide -0.0 1.0 -> -0
-dddiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
-dddiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
-dddiv777 divide 1.0 0.0 -> Infinity Division_by_zero
-dddiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
-
--- Specials
-dddiv780 divide Inf -Inf -> NaN Invalid_operation
-dddiv781 divide Inf -1000 -> -Infinity
-dddiv782 divide Inf -1 -> -Infinity
-dddiv783 divide Inf -0 -> -Infinity
-dddiv784 divide Inf 0 -> Infinity
-dddiv785 divide Inf 1 -> Infinity
-dddiv786 divide Inf 1000 -> Infinity
-dddiv787 divide Inf Inf -> NaN Invalid_operation
-dddiv788 divide -1000 Inf -> -0E-398 Clamped
-dddiv789 divide -Inf Inf -> NaN Invalid_operation
-dddiv790 divide -1 Inf -> -0E-398 Clamped
-dddiv791 divide -0 Inf -> -0E-398 Clamped
-dddiv792 divide 0 Inf -> 0E-398 Clamped
-dddiv793 divide 1 Inf -> 0E-398 Clamped
-dddiv794 divide 1000 Inf -> 0E-398 Clamped
-dddiv795 divide Inf Inf -> NaN Invalid_operation
-
-dddiv800 divide -Inf -Inf -> NaN Invalid_operation
-dddiv801 divide -Inf -1000 -> Infinity
-dddiv802 divide -Inf -1 -> Infinity
-dddiv803 divide -Inf -0 -> Infinity
-dddiv804 divide -Inf 0 -> -Infinity
-dddiv805 divide -Inf 1 -> -Infinity
-dddiv806 divide -Inf 1000 -> -Infinity
-dddiv807 divide -Inf Inf -> NaN Invalid_operation
-dddiv808 divide -1000 Inf -> -0E-398 Clamped
-dddiv809 divide -Inf -Inf -> NaN Invalid_operation
-dddiv810 divide -1 -Inf -> 0E-398 Clamped
-dddiv811 divide -0 -Inf -> 0E-398 Clamped
-dddiv812 divide 0 -Inf -> -0E-398 Clamped
-dddiv813 divide 1 -Inf -> -0E-398 Clamped
-dddiv814 divide 1000 -Inf -> -0E-398 Clamped
-dddiv815 divide Inf -Inf -> NaN Invalid_operation
-
-dddiv821 divide NaN -Inf -> NaN
-dddiv822 divide NaN -1000 -> NaN
-dddiv823 divide NaN -1 -> NaN
-dddiv824 divide NaN -0 -> NaN
-dddiv825 divide NaN 0 -> NaN
-dddiv826 divide NaN 1 -> NaN
-dddiv827 divide NaN 1000 -> NaN
-dddiv828 divide NaN Inf -> NaN
-dddiv829 divide NaN NaN -> NaN
-dddiv830 divide -Inf NaN -> NaN
-dddiv831 divide -1000 NaN -> NaN
-dddiv832 divide -1 NaN -> NaN
-dddiv833 divide -0 NaN -> NaN
-dddiv834 divide 0 NaN -> NaN
-dddiv835 divide 1 NaN -> NaN
-dddiv836 divide 1000 NaN -> NaN
-dddiv837 divide Inf NaN -> NaN
-
-dddiv841 divide sNaN -Inf -> NaN Invalid_operation
-dddiv842 divide sNaN -1000 -> NaN Invalid_operation
-dddiv843 divide sNaN -1 -> NaN Invalid_operation
-dddiv844 divide sNaN -0 -> NaN Invalid_operation
-dddiv845 divide sNaN 0 -> NaN Invalid_operation
-dddiv846 divide sNaN 1 -> NaN Invalid_operation
-dddiv847 divide sNaN 1000 -> NaN Invalid_operation
-dddiv848 divide sNaN NaN -> NaN Invalid_operation
-dddiv849 divide sNaN sNaN -> NaN Invalid_operation
-dddiv850 divide NaN sNaN -> NaN Invalid_operation
-dddiv851 divide -Inf sNaN -> NaN Invalid_operation
-dddiv852 divide -1000 sNaN -> NaN Invalid_operation
-dddiv853 divide -1 sNaN -> NaN Invalid_operation
-dddiv854 divide -0 sNaN -> NaN Invalid_operation
-dddiv855 divide 0 sNaN -> NaN Invalid_operation
-dddiv856 divide 1 sNaN -> NaN Invalid_operation
-dddiv857 divide 1000 sNaN -> NaN Invalid_operation
-dddiv858 divide Inf sNaN -> NaN Invalid_operation
-dddiv859 divide NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dddiv861 divide NaN9 -Inf -> NaN9
-dddiv862 divide NaN8 1000 -> NaN8
-dddiv863 divide NaN7 Inf -> NaN7
-dddiv864 divide NaN6 NaN5 -> NaN6
-dddiv865 divide -Inf NaN4 -> NaN4
-dddiv866 divide -1000 NaN3 -> NaN3
-dddiv867 divide Inf NaN2 -> NaN2
-
-dddiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
-dddiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
-dddiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
-dddiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
-dddiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
-dddiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
-dddiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
-dddiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
-dddiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
-
-dddiv881 divide -NaN9 -Inf -> -NaN9
-dddiv882 divide -NaN8 1000 -> -NaN8
-dddiv883 divide -NaN7 Inf -> -NaN7
-dddiv884 divide -NaN6 -NaN5 -> -NaN6
-dddiv885 divide -Inf -NaN4 -> -NaN4
-dddiv886 divide -1000 -NaN3 -> -NaN3
-dddiv887 divide Inf -NaN2 -> -NaN2
-
-dddiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
-dddiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
-dddiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
-dddiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
-dddiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-dddiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
-dddiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
-dddiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
-dddiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- Various flavours of divide by 0
-dddiv901 divide 0 0 -> NaN Division_undefined
-dddiv902 divide 0.0E5 0 -> NaN Division_undefined
-dddiv903 divide 0.000 0 -> NaN Division_undefined
-dddiv904 divide 0.0001 0 -> Infinity Division_by_zero
-dddiv905 divide 0.01 0 -> Infinity Division_by_zero
-dddiv906 divide 0.1 0 -> Infinity Division_by_zero
-dddiv907 divide 1 0 -> Infinity Division_by_zero
-dddiv908 divide 1 0.0 -> Infinity Division_by_zero
-dddiv909 divide 10 0.0 -> Infinity Division_by_zero
-dddiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
-dddiv911 divide 1E+100 0 -> Infinity Division_by_zero
-
-dddiv921 divide -0.0001 0 -> -Infinity Division_by_zero
-dddiv922 divide -0.01 0 -> -Infinity Division_by_zero
-dddiv923 divide -0.1 0 -> -Infinity Division_by_zero
-dddiv924 divide -1 0 -> -Infinity Division_by_zero
-dddiv925 divide -1 0.0 -> -Infinity Division_by_zero
-dddiv926 divide -10 0.0 -> -Infinity Division_by_zero
-dddiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
-dddiv928 divide -1E+100 0 -> -Infinity Division_by_zero
-
-dddiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
-dddiv932 divide 0.01 -0 -> -Infinity Division_by_zero
-dddiv933 divide 0.1 -0 -> -Infinity Division_by_zero
-dddiv934 divide 1 -0 -> -Infinity Division_by_zero
-dddiv935 divide 1 -0.0 -> -Infinity Division_by_zero
-dddiv936 divide 10 -0.0 -> -Infinity Division_by_zero
-dddiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
-dddiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
-
-dddiv941 divide -0.0001 -0 -> Infinity Division_by_zero
-dddiv942 divide -0.01 -0 -> Infinity Division_by_zero
-dddiv943 divide -0.1 -0 -> Infinity Division_by_zero
-dddiv944 divide -1 -0 -> Infinity Division_by_zero
-dddiv945 divide -1 -0.0 -> Infinity Division_by_zero
-dddiv946 divide -10 -0.0 -> Infinity Division_by_zero
-dddiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
-dddiv948 divide -1E+100 -0 -> Infinity Division_by_zero
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dddiv1021 divide 1E0 1E0 -> 1
-dddiv1022 divide 1E0 2E0 -> 0.5
-dddiv1023 divide 1E0 3E0 -> 0.3333333333333333 Inexact Rounded
-dddiv1024 divide 100E-2 1000E-3 -> 1
-dddiv1025 divide 24E-1 2E0 -> 1.2
-dddiv1026 divide 2400E-3 2E0 -> 1.200
-dddiv1027 divide 5E0 2E0 -> 2.5
-dddiv1028 divide 5E0 20E-1 -> 2.5
-dddiv1029 divide 5E0 2000E-3 -> 2.5
-dddiv1030 divide 5E0 2E-1 -> 25
-dddiv1031 divide 5E0 20E-2 -> 25
-dddiv1032 divide 480E-2 3E0 -> 1.60
-dddiv1033 divide 47E-1 2E0 -> 2.35
-
--- ECMAScript bad examples
-rounding: half_down
-dddiv1040 divide 5 9 -> 0.5555555555555556 Inexact Rounded
-rounding: half_even
-dddiv1041 divide 6 11 -> 0.5454545454545455 Inexact Rounded
-
--- overflow and underflow tests .. note subnormal results
--- signs
-dddiv1051 divide 1e+277 1e-311 -> Infinity Overflow Inexact Rounded
-dddiv1052 divide 1e+277 -1e-311 -> -Infinity Overflow Inexact Rounded
-dddiv1053 divide -1e+277 1e-311 -> -Infinity Overflow Inexact Rounded
-dddiv1054 divide -1e+277 -1e-311 -> Infinity Overflow Inexact Rounded
-dddiv1055 divide 1e-277 1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1056 divide 1e-277 -1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1057 divide -1e-277 1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1058 divide -1e-277 -1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dddiv1060 divide 1e-291 1e+101 -> 1E-392 Subnormal
-dddiv1061 divide 1e-291 1e+102 -> 1E-393 Subnormal
-dddiv1062 divide 1e-291 1e+103 -> 1E-394 Subnormal
-dddiv1063 divide 1e-291 1e+104 -> 1E-395 Subnormal
-dddiv1064 divide 1e-291 1e+105 -> 1E-396 Subnormal
-dddiv1065 divide 1e-291 1e+106 -> 1E-397 Subnormal
-dddiv1066 divide 1e-291 1e+107 -> 1E-398 Subnormal
-dddiv1067 divide 1e-291 1e+108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1068 divide 1e-291 1e+109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1069 divide 1e-291 1e+110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-dddiv1070 divide 1e+60 1e-321 -> 1.000000000000E+381 Clamped
-dddiv1071 divide 1e+60 1e-322 -> 1.0000000000000E+382 Clamped
-dddiv1072 divide 1e+60 1e-323 -> 1.00000000000000E+383 Clamped
-dddiv1073 divide 1e+60 1e-324 -> 1.000000000000000E+384 Clamped
-dddiv1074 divide 1e+60 1e-325 -> Infinity Overflow Inexact Rounded
-dddiv1075 divide 1e+60 1e-326 -> Infinity Overflow Inexact Rounded
-dddiv1076 divide 1e+60 1e-327 -> Infinity Overflow Inexact Rounded
-dddiv1077 divide 1e+60 1e-328 -> Infinity Overflow Inexact Rounded
-dddiv1078 divide 1e+60 1e-329 -> Infinity Overflow Inexact Rounded
-dddiv1079 divide 1e+60 1e-330 -> Infinity Overflow Inexact Rounded
-
-dddiv1101 divide 1.0000E-394 1 -> 1.0000E-394 Subnormal
-dddiv1102 divide 1.000E-394 1e+1 -> 1.000E-395 Subnormal
-dddiv1103 divide 1.00E-394 1e+2 -> 1.00E-396 Subnormal
-dddiv1104 divide 1.0E-394 1e+3 -> 1.0E-397 Subnormal
-dddiv1105 divide 1.0E-394 1e+4 -> 1E-398 Subnormal Rounded
-dddiv1106 divide 1.3E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
-dddiv1107 divide 1.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1108 divide 1.7E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1109 divide 2.3E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1110 divide 2.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1111 divide 2.7E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
-dddiv1112 divide 1.49E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
-dddiv1113 divide 1.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1114 divide 1.51E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1115 divide 2.49E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1116 divide 2.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1117 divide 2.51E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
-
-dddiv1118 divide 1E-394 1e+4 -> 1E-398 Subnormal
-dddiv1119 divide 3E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1120 divide 5E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1121 divide 7E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
-dddiv1122 divide 9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
-dddiv1123 divide 9.9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
-
-dddiv1124 divide 1E-394 -1e+4 -> -1E-398 Subnormal
-dddiv1125 divide 3E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1126 divide -5E-394 1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1127 divide 7E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
-dddiv1128 divide -9E-394 1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
-dddiv1129 divide 9.9E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
-dddiv1130 divide 3.0E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-dddiv1131 divide 1.0E-199 1e+200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1132 divide 1.0E-199 1e+199 -> 1E-398 Subnormal Rounded
-dddiv1133 divide 1.0E-199 1e+198 -> 1.0E-397 Subnormal
-dddiv1134 divide 2.0E-199 2e+198 -> 1.0E-397 Subnormal
-dddiv1135 divide 4.0E-199 4e+198 -> 1.0E-397 Subnormal
-dddiv1136 divide 10.0E-199 10e+198 -> 1.0E-397 Subnormal
-dddiv1137 divide 30.0E-199 30e+198 -> 1.0E-397 Subnormal
-
--- randoms
-dddiv2010 divide -3.303226714900711E-35 8.796578842713183E+73 -> -3.755126594058783E-109 Inexact Rounded
-dddiv2011 divide 933153327821073.6 68782181090246.25 -> 13.56678885475763 Inexact Rounded
-dddiv2012 divide 5.04752436057906E-72 -8.179481771238642E+64 -> -6.170958627632835E-137 Inexact Rounded
-dddiv2013 divide -3707613309582318 3394911196503.048 -> -1092.109070010836 Inexact Rounded
-dddiv2014 divide 99689.0555190461 -4.735208553891464 -> -21052.72753765411 Inexact Rounded
-dddiv2015 divide -1447915775613329 269750797.8184875 -> -5367605.164925653 Inexact Rounded
-dddiv2016 divide -9.394881304225258E-19 -830585.0252671636 -> 1.131116143251358E-24 Inexact Rounded
-dddiv2017 divide -1.056283432738934 88.58754555124013 -> -0.01192361100159352 Inexact Rounded
-dddiv2018 divide 5763220933343.081 689089567025052.1 -> 0.008363529516524456 Inexact Rounded
-dddiv2019 divide 873819.122103216 9.740612494523300E-49 -> 8.970884763093948E+53 Inexact Rounded
-dddiv2020 divide 8022914.838533576 6178.566801742713 -> 1298.507420243583 Inexact Rounded
-dddiv2021 divide 203982.7605650363 -2158.283639053435 -> -94.51156320422168 Inexact Rounded
-dddiv2022 divide 803.6310547013030 7101143795399.238 -> 1.131692411611166E-10 Inexact Rounded
-dddiv2023 divide 9.251697842123399E-82 -1.342350220606119E-7 -> -6.892163982321936E-75 Inexact Rounded
-dddiv2024 divide -1.980600645637992E-53 -5.474262753214457E+77 -> 3.618022617703168E-131 Inexact Rounded
-dddiv2025 divide -210.0322996351690 -8.580951835872843E+80 -> 2.447657365434971E-79 Inexact Rounded
-dddiv2026 divide -1.821980314020370E+85 -3.018915267138165 -> 6.035215144503042E+84 Inexact Rounded
-dddiv2027 divide -772264503601.1047 5.158258271408988E-86 -> -1.497141986630614E+97 Inexact Rounded
-dddiv2028 divide -767.0532415847106 2.700027228028939E-59 -> -2.840909282772941E+61 Inexact Rounded
-dddiv2029 divide 496724.8548250093 7.32700588163100E+66 -> 6.779370220929013E-62 Inexact Rounded
-dddiv2030 divide -304232651447703.9 -108.9730808657440 -> 2791814721862.565 Inexact Rounded
-dddiv2031 divide -7.233817192699405E+42 -5711302004.149411 -> 1.266579352211430E+33 Inexact Rounded
-dddiv2032 divide -9.999221444912745E+96 4010569406446197 -> -2.493217404202250E+81 Inexact Rounded
-dddiv2033 divide -1837272.061937622 8.356322838066762 -> -219866.0939196882 Inexact Rounded
-dddiv2034 divide 2168.517555606529 209.1910258615061 -> 10.36620737756784 Inexact Rounded
-dddiv2035 divide -1.884389790576371E+88 2.95181953870583E+20 -> -6.383824505079828E+67 Inexact Rounded
-dddiv2036 divide 732263.6037438196 961222.3634446889 -> 0.7618045850698269 Inexact Rounded
-dddiv2037 divide -813461419.0348336 5.376293753809143E+84 -> -1.513052404285927E-76 Inexact Rounded
-dddiv2038 divide -45562133508108.50 -9.776843494690107E+51 -> 4.660208945029519E-39 Inexact Rounded
-dddiv2039 divide -6.489393172441016E+80 -9101965.097852113 -> 7.129661674897421E+73 Inexact Rounded
-dddiv2040 divide 3.694576237117349E+93 6683512.012622003 -> 5.527896456443912E+86 Inexact Rounded
-dddiv2041 divide -2.252877726403272E+19 -7451913256.181367 -> 3023220546.125531 Inexact Rounded
-dddiv2042 divide 518303.1989111842 50.01587020474133 -> 10362.77479107123 Inexact Rounded
-dddiv2043 divide 2.902087881880103E+24 33.32400992305702 -> 8.708699488989578E+22 Inexact Rounded
-dddiv2044 divide 549619.4559510557 1660824845196338 -> 3.309316196351104E-10 Inexact Rounded
-dddiv2045 divide -6775670774684043 8292152023.077262 -> -817118.4941891062 Inexact Rounded
-dddiv2046 divide -77.50923921524079 -5.636882655425815E+74 -> 1.375037302588405E-73 Inexact Rounded
-dddiv2047 divide -2.984889459605149E-10 -88106156784122.99 -> 3.387833005721384E-24 Inexact Rounded
-dddiv2048 divide 0.949517293997085 44767115.96450998 -> 2.121015110175589E-8 Inexact Rounded
-dddiv2049 divide -2760937211.084521 -1087015876975408 -> 0.000002539923537057024 Inexact Rounded
-dddiv2050 divide 28438351.85030536 -4.209397904088624E-47 -> -6.755919135770688E+53 Inexact Rounded
-dddiv2051 divide -85562731.6820956 -7.166045442530185E+45 -> 1.194002080621542E-38 Inexact Rounded
-dddiv2052 divide 2533802852165.25 7154.119606235955 -> 354173957.3317501 Inexact Rounded
-dddiv2053 divide -8858831346851.474 97.59734208801716 -> -90769186509.83577 Inexact Rounded
-dddiv2054 divide 176783629801387.5 840073263.3109817 -> 210438.3480848206 Inexact Rounded
-dddiv2055 divide -493506471796175.6 79733894790822.03 -> -6.189418854940746 Inexact Rounded
-dddiv2056 divide 790.1682542103445 829.9449370367435 -> 0.9520731062371214 Inexact Rounded
-dddiv2057 divide -8920459838.583164 -4767.889187899214 -> 1870945.294035581 Inexact Rounded
-dddiv2058 divide 53536687164422.1 53137.5007032689 -> 1007512330.385698 Inexact Rounded
-dddiv2059 divide 4.051532311146561E-74 -2.343089768972261E+94 -> -1.729140882606332E-168 Inexact Rounded
-dddiv2060 divide -14847758778636.88 3.062543516383807E-43 -> -4.848178874587497E+55 Inexact Rounded
-
--- Division probably has pre-rounding, so need to test rounding
--- explicitly rather than assume included through other tests;
--- tests include simple rounding and also the tricky cases of sticky
--- bits following two zeros
---
--- 1/99999 gives 0.0000100001000010000100001000010000100001
--- 1234567890123456
---
--- 1/999999 gives 0.000001000001000001000001000001000001000001
--- 1234567890123456
-
-rounding: ceiling
-dddiv3001 divide 1 3 -> 0.3333333333333334 Inexact Rounded
-dddiv3002 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3003 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
-dddiv3004 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
-
-rounding: floor
-dddiv3011 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3012 divide 2 3 -> 0.6666666666666666 Inexact Rounded
-dddiv3013 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3014 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: up
-dddiv3021 divide 1 3 -> 0.3333333333333334 Inexact Rounded
-dddiv3022 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3023 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
-dddiv3024 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
-
-rounding: down
-dddiv3031 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3032 divide 2 3 -> 0.6666666666666666 Inexact Rounded
-dddiv3033 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3034 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: half_up
-dddiv3041 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3042 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3043 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3044 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: half_down
-dddiv3051 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3052 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3053 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3054 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: half_even
-dddiv3061 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3062 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3063 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3064 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: 05up
-dddiv3071 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3072 divide 2 3 -> 0.6666666666666666 Inexact Rounded
-dddiv3073 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3074 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
-
--- random divide tests with result near 1
-rounding: half_even
-dddiv4001 divide 3195385192916917 3195385192946695 -> 0.9999999999906809 Inexact Rounded
-dddiv4002 divide 1393723067526993 1393723067519475 -> 1.000000000005394 Inexact Rounded
-dddiv4003 divide 759985543702302 759985543674015 -> 1.000000000037220 Inexact Rounded
-dddiv4004 divide 9579158456027302 9579158456036864 -> 0.9999999999990018 Inexact Rounded
-dddiv4005 divide 7079398299143569 7079398299156904 -> 0.9999999999981164 Inexact Rounded
-dddiv4006 divide 6636169255366598 6636169255336386 -> 1.000000000004553 Inexact Rounded
-dddiv4007 divide 6964813971340090 6964813971321554 -> 1.000000000002661 Inexact Rounded
-dddiv4008 divide 4182275225480784 4182275225454009 -> 1.000000000006402 Inexact Rounded
-dddiv4009 divide 9228325124938029 9228325124918730 -> 1.000000000002091 Inexact Rounded
-dddiv4010 divide 3428346338630192 3428346338609843 -> 1.000000000005936 Inexact Rounded
-dddiv4011 divide 2143511550722893 2143511550751754 -> 0.9999999999865356 Inexact Rounded
-dddiv4012 divide 1672732924396785 1672732924401811 -> 0.9999999999969953 Inexact Rounded
-dddiv4013 divide 4190714611948216 4190714611948664 -> 0.9999999999998931 Inexact Rounded
-dddiv4014 divide 3942254800848877 3942254800814556 -> 1.000000000008706 Inexact Rounded
-dddiv4015 divide 2854459826952334 2854459826960762 -> 0.9999999999970474 Inexact Rounded
-dddiv4016 divide 2853258953664731 2853258953684471 -> 0.9999999999930816 Inexact Rounded
-dddiv4017 divide 9453512638125978 9453512638146425 -> 0.9999999999978371 Inexact Rounded
-dddiv4018 divide 339476633940369 339476633912887 -> 1.000000000080954 Inexact Rounded
-dddiv4019 divide 4542181492688467 4542181492697735 -> 0.9999999999979596 Inexact Rounded
-dddiv4020 divide 7312600192399197 7312600192395424 -> 1.000000000000516 Inexact Rounded
-dddiv4021 divide 1811674985570111 1811674985603935 -> 0.9999999999813300 Inexact Rounded
-dddiv4022 divide 1706462639003481 1706462639017740 -> 0.9999999999916441 Inexact Rounded
-dddiv4023 divide 6697052654940368 6697052654934110 -> 1.000000000000934 Inexact Rounded
-dddiv4024 divide 5015283664277539 5015283664310719 -> 0.9999999999933842 Inexact Rounded
-dddiv4025 divide 2359501561537464 2359501561502464 -> 1.000000000014834 Inexact Rounded
-dddiv4026 divide 2669850227909157 2669850227901548 -> 1.000000000002850 Inexact Rounded
-dddiv4027 divide 9329725546974648 9329725547002445 -> 0.9999999999970206 Inexact Rounded
-dddiv4028 divide 3228562867071248 3228562867106206 -> 0.9999999999891723 Inexact Rounded
-dddiv4029 divide 4862226644921175 4862226644909380 -> 1.000000000002426 Inexact Rounded
-dddiv4030 divide 1022267997054529 1022267997071329 -> 0.9999999999835660 Inexact Rounded
-dddiv4031 divide 1048777482023719 1048777482000948 -> 1.000000000021712 Inexact Rounded
-dddiv4032 divide 9980113777337098 9980113777330539 -> 1.000000000000657 Inexact Rounded
-dddiv4033 divide 7506839167963908 7506839167942901 -> 1.000000000002798 Inexact Rounded
-dddiv4034 divide 231119751977860 231119751962453 -> 1.000000000066662 Inexact Rounded
-dddiv4035 divide 4034903664762962 4034903664795526 -> 0.9999999999919294 Inexact Rounded
-dddiv4036 divide 5700122152274696 5700122152251386 -> 1.000000000004089 Inexact Rounded
-dddiv4037 divide 6869599590293110 6869599590293495 -> 0.9999999999999440 Inexact Rounded
-dddiv4038 divide 5576281960092797 5576281960105579 -> 0.9999999999977078 Inexact Rounded
-dddiv4039 divide 2304844888381318 2304844888353073 -> 1.000000000012255 Inexact Rounded
-dddiv4040 divide 3265933651656452 3265933651682779 -> 0.9999999999919389 Inexact Rounded
-dddiv4041 divide 5235714985079914 5235714985066131 -> 1.000000000002632 Inexact Rounded
-dddiv4042 divide 5578481572827551 5578481572822945 -> 1.000000000000826 Inexact Rounded
-dddiv4043 divide 4909616081396134 4909616081373076 -> 1.000000000004696 Inexact Rounded
-dddiv4044 divide 636447224349537 636447224338757 -> 1.000000000016938 Inexact Rounded
-dddiv4045 divide 1539373428396640 1539373428364727 -> 1.000000000020731 Inexact Rounded
-dddiv4046 divide 2028786707377893 2028786707378866 -> 0.9999999999995204 Inexact Rounded
-dddiv4047 divide 137643260486222 137643260487419 -> 0.9999999999913036 Inexact Rounded
-dddiv4048 divide 247451519746765 247451519752267 -> 0.9999999999777653 Inexact Rounded
-dddiv4049 divide 7877858475022054 7877858474999794 -> 1.000000000002826 Inexact Rounded
-dddiv4050 divide 7333242694766258 7333242694744628 -> 1.000000000002950 Inexact Rounded
-dddiv4051 divide 124051503698592 124051503699397 -> 0.9999999999935108 Inexact Rounded
-dddiv4052 divide 8944737432385188 8944737432406860 -> 0.9999999999975771 Inexact Rounded
-dddiv4053 divide 9883948923406874 9883948923424843 -> 0.9999999999981820 Inexact Rounded
-dddiv4054 divide 6829178741654284 6829178741671973 -> 0.9999999999974098 Inexact Rounded
-dddiv4055 divide 7342752479768122 7342752479793385 -> 0.9999999999965595 Inexact Rounded
-dddiv4056 divide 8066426579008783 8066426578977563 -> 1.000000000003870 Inexact Rounded
-dddiv4057 divide 8992775071383295 8992775071352712 -> 1.000000000003401 Inexact Rounded
-dddiv4058 divide 5485011755545641 5485011755543611 -> 1.000000000000370 Inexact Rounded
-dddiv4059 divide 5779983054353918 5779983054365300 -> 0.9999999999980308 Inexact Rounded
-dddiv4060 divide 9502265102713774 9502265102735208 -> 0.9999999999977443 Inexact Rounded
-dddiv4061 divide 2109558399130981 2109558399116281 -> 1.000000000006968 Inexact Rounded
-dddiv4062 divide 5296182636350471 5296182636351521 -> 0.9999999999998017 Inexact Rounded
-dddiv4063 divide 1440019225591883 1440019225601844 -> 0.9999999999930827 Inexact Rounded
-dddiv4064 divide 8182110791881341 8182110791847174 -> 1.000000000004176 Inexact Rounded
-dddiv4065 divide 489098235512060 489098235534516 -> 0.9999999999540869 Inexact Rounded
-dddiv4066 divide 6475687084782038 6475687084756089 -> 1.000000000004007 Inexact Rounded
-dddiv4067 divide 8094348555736948 8094348555759236 -> 0.9999999999972465 Inexact Rounded
-dddiv4068 divide 1982766816291543 1982766816309463 -> 0.9999999999909621 Inexact Rounded
-dddiv4069 divide 9277314300113251 9277314300084467 -> 1.000000000003103 Inexact Rounded
-dddiv4070 divide 4335532959318934 4335532959293167 -> 1.000000000005943 Inexact Rounded
-dddiv4071 divide 7767113032981348 7767113032968132 -> 1.000000000001702 Inexact Rounded
-dddiv4072 divide 1578548053342868 1578548053370448 -> 0.9999999999825282 Inexact Rounded
-dddiv4073 divide 3790420686666898 3790420686636315 -> 1.000000000008068 Inexact Rounded
-dddiv4074 divide 871682421955147 871682421976441 -> 0.9999999999755714 Inexact Rounded
-dddiv4075 divide 744141054479940 744141054512329 -> 0.9999999999564746 Inexact Rounded
-dddiv4076 divide 8956824183670735 8956824183641741 -> 1.000000000003237 Inexact Rounded
-dddiv4077 divide 8337291694485682 8337291694451193 -> 1.000000000004137 Inexact Rounded
-dddiv4078 divide 4107775944683669 4107775944657097 -> 1.000000000006469 Inexact Rounded
-dddiv4079 divide 8691900057964648 8691900057997555 -> 0.9999999999962141 Inexact Rounded
-dddiv4080 divide 2229528520536462 2229528520502337 -> 1.000000000015306 Inexact Rounded
-dddiv4081 divide 398442083774322 398442083746273 -> 1.000000000070397 Inexact Rounded
-dddiv4082 divide 5319819776808759 5319819776838313 -> 0.9999999999944445 Inexact Rounded
-dddiv4083 divide 7710491299066855 7710491299041858 -> 1.000000000003242 Inexact Rounded
-dddiv4084 divide 9083231296087266 9083231296058160 -> 1.000000000003204 Inexact Rounded
-dddiv4085 divide 3566873574904559 3566873574890328 -> 1.000000000003990 Inexact Rounded
-dddiv4086 divide 596343290550525 596343290555614 -> 0.9999999999914663 Inexact Rounded
-dddiv4087 divide 278227925093192 278227925068104 -> 1.000000000090171 Inexact Rounded
-dddiv4088 divide 3292902958490649 3292902958519881 -> 0.9999999999911227 Inexact Rounded
-dddiv4089 divide 5521871364245881 5521871364229536 -> 1.000000000002960 Inexact Rounded
-dddiv4090 divide 2406505602883617 2406505602857997 -> 1.000000000010646 Inexact Rounded
-dddiv4091 divide 7741146984869208 7741146984867255 -> 1.000000000000252 Inexact Rounded
-dddiv4092 divide 4576041832414909 4576041832405102 -> 1.000000000002143 Inexact Rounded
-dddiv4093 divide 9183756982878057 9183756982901934 -> 0.9999999999974001 Inexact Rounded
-dddiv4094 divide 6215736513855159 6215736513870342 -> 0.9999999999975573 Inexact Rounded
-dddiv4095 divide 248554968534533 248554968551417 -> 0.9999999999320714 Inexact Rounded
-dddiv4096 divide 376314165668645 376314165659755 -> 1.000000000023624 Inexact Rounded
-dddiv4097 divide 5513569249809718 5513569249808906 -> 1.000000000000147 Inexact Rounded
-dddiv4098 divide 3367992242167904 3367992242156228 -> 1.000000000003467 Inexact Rounded
-dddiv4099 divide 6134869538966967 6134869538985986 -> 0.9999999999968999 Inexact Rounded
-
--- Null tests
-dddiv9998 divide 10 # -> NaN Invalid_operation
-dddiv9999 divide # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddDivide.decTest -- decDouble division --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+dddiv001 divide 1 1 -> 1
+dddiv002 divide 2 1 -> 2
+dddiv003 divide 1 2 -> 0.5
+dddiv004 divide 2 2 -> 1
+dddiv005 divide 0 1 -> 0
+dddiv006 divide 0 2 -> 0
+dddiv007 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv008 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv009 divide 3 3 -> 1
+
+dddiv010 divide 2.4 1 -> 2.4
+dddiv011 divide 2.4 -1 -> -2.4
+dddiv012 divide -2.4 1 -> -2.4
+dddiv013 divide -2.4 -1 -> 2.4
+dddiv014 divide 2.40 1 -> 2.40
+dddiv015 divide 2.400 1 -> 2.400
+dddiv016 divide 2.4 2 -> 1.2
+dddiv017 divide 2.400 2 -> 1.200
+dddiv018 divide 2. 2 -> 1
+dddiv019 divide 20 20 -> 1
+
+dddiv020 divide 187 187 -> 1
+dddiv021 divide 5 2 -> 2.5
+dddiv022 divide 50 20 -> 2.5
+dddiv023 divide 500 200 -> 2.5
+dddiv024 divide 50.0 20.0 -> 2.5
+dddiv025 divide 5.00 2.00 -> 2.5
+dddiv026 divide 5 2.0 -> 2.5
+dddiv027 divide 5 2.000 -> 2.5
+dddiv028 divide 5 0.20 -> 25
+dddiv029 divide 5 0.200 -> 25
+dddiv030 divide 10 1 -> 10
+dddiv031 divide 100 1 -> 100
+dddiv032 divide 1000 1 -> 1000
+dddiv033 divide 1000 100 -> 10
+
+dddiv035 divide 1 2 -> 0.5
+dddiv036 divide 1 4 -> 0.25
+dddiv037 divide 1 8 -> 0.125
+dddiv038 divide 1 16 -> 0.0625
+dddiv039 divide 1 32 -> 0.03125
+dddiv040 divide 1 64 -> 0.015625
+dddiv041 divide 1 -2 -> -0.5
+dddiv042 divide 1 -4 -> -0.25
+dddiv043 divide 1 -8 -> -0.125
+dddiv044 divide 1 -16 -> -0.0625
+dddiv045 divide 1 -32 -> -0.03125
+dddiv046 divide 1 -64 -> -0.015625
+dddiv047 divide -1 2 -> -0.5
+dddiv048 divide -1 4 -> -0.25
+dddiv049 divide -1 8 -> -0.125
+dddiv050 divide -1 16 -> -0.0625
+dddiv051 divide -1 32 -> -0.03125
+dddiv052 divide -1 64 -> -0.015625
+dddiv053 divide -1 -2 -> 0.5
+dddiv054 divide -1 -4 -> 0.25
+dddiv055 divide -1 -8 -> 0.125
+dddiv056 divide -1 -16 -> 0.0625
+dddiv057 divide -1 -32 -> 0.03125
+dddiv058 divide -1 -64 -> 0.015625
+
+-- bcdTime
+dddiv060 divide 1 7 -> 0.1428571428571429 Inexact Rounded
+dddiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717 Inexact Rounded
+
+-- 1234567890123456
+dddiv071 divide 9999999999999999 1 -> 9999999999999999
+dddiv072 divide 999999999999999 1 -> 999999999999999
+dddiv073 divide 99999999999999 1 -> 99999999999999
+dddiv074 divide 9999999999999 1 -> 9999999999999
+dddiv075 divide 999999999999 1 -> 999999999999
+dddiv076 divide 99999999999 1 -> 99999999999
+dddiv077 divide 9999999999 1 -> 9999999999
+dddiv078 divide 999999999 1 -> 999999999
+dddiv079 divide 99999999 1 -> 99999999
+dddiv080 divide 9999999 1 -> 9999999
+dddiv081 divide 999999 1 -> 999999
+dddiv082 divide 99999 1 -> 99999
+dddiv083 divide 9999 1 -> 9999
+dddiv084 divide 999 1 -> 999
+dddiv085 divide 99 1 -> 99
+dddiv086 divide 9 1 -> 9
+
+dddiv090 divide 0. 1 -> 0
+dddiv091 divide .0 1 -> 0.0
+dddiv092 divide 0.00 1 -> 0.00
+dddiv093 divide 0.00E+9 1 -> 0E+7
+dddiv094 divide 0.0000E-50 1 -> 0E-54
+
+dddiv095 divide 1 1E-8 -> 1E+8
+dddiv096 divide 1 1E-9 -> 1E+9
+dddiv097 divide 1 1E-10 -> 1E+10
+dddiv098 divide 1 1E-11 -> 1E+11
+dddiv099 divide 1 1E-12 -> 1E+12
+
+dddiv100 divide 1 1 -> 1
+dddiv101 divide 1 2 -> 0.5
+dddiv102 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv103 divide 1 4 -> 0.25
+dddiv104 divide 1 5 -> 0.2
+dddiv105 divide 1 6 -> 0.1666666666666667 Inexact Rounded
+dddiv106 divide 1 7 -> 0.1428571428571429 Inexact Rounded
+dddiv107 divide 1 8 -> 0.125
+dddiv108 divide 1 9 -> 0.1111111111111111 Inexact Rounded
+dddiv109 divide 1 10 -> 0.1
+dddiv110 divide 1 1 -> 1
+dddiv111 divide 2 1 -> 2
+dddiv112 divide 3 1 -> 3
+dddiv113 divide 4 1 -> 4
+dddiv114 divide 5 1 -> 5
+dddiv115 divide 6 1 -> 6
+dddiv116 divide 7 1 -> 7
+dddiv117 divide 8 1 -> 8
+dddiv118 divide 9 1 -> 9
+dddiv119 divide 10 1 -> 10
+
+dddiv120 divide 3E+1 0.001 -> 3E+4
+dddiv121 divide 2.200 2 -> 1.100
+
+dddiv130 divide 12345 4.999 -> 2469.493898779756 Inexact Rounded
+dddiv131 divide 12345 4.99 -> 2473.947895791583 Inexact Rounded
+dddiv132 divide 12345 4.9 -> 2519.387755102041 Inexact Rounded
+dddiv133 divide 12345 5 -> 2469
+dddiv134 divide 12345 5.1 -> 2420.588235294118 Inexact Rounded
+dddiv135 divide 12345 5.01 -> 2464.071856287425 Inexact Rounded
+dddiv136 divide 12345 5.001 -> 2468.506298740252 Inexact Rounded
+
+-- test possibly imprecise results
+dddiv220 divide 391 597 -> 0.6549413735343384 Inexact Rounded
+dddiv221 divide 391 -597 -> -0.6549413735343384 Inexact Rounded
+dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded
+dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded
+
+-- test some cases that are close to exponent overflow, some with coefficient padding
+dddiv270 divide 1 1e384 -> 1E-384 Subnormal
+dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow
+dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow
+dddiv273 divide 1 0.9999999999999999e384 -> 1.00000000000000E-384 Rounded Inexact Subnormal Underflow
+dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped
+dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped
+dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped
+dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped
+dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped
+dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384
+
+dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped
+dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded
+dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped
+dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded
+dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped
+
+
+-- Divide into 0 tests
+dddiv301 divide 0 7 -> 0
+dddiv302 divide 0 7E-5 -> 0E+5
+dddiv303 divide 0 7E-1 -> 0E+1
+dddiv304 divide 0 7E+1 -> 0.0
+dddiv305 divide 0 7E+5 -> 0.00000
+dddiv306 divide 0 7E+6 -> 0.000000
+dddiv307 divide 0 7E+7 -> 0E-7
+dddiv308 divide 0 70E-5 -> 0E+5
+dddiv309 divide 0 70E-1 -> 0E+1
+dddiv310 divide 0 70E+0 -> 0
+dddiv311 divide 0 70E+1 -> 0.0
+dddiv312 divide 0 70E+5 -> 0.00000
+dddiv313 divide 0 70E+6 -> 0.000000
+dddiv314 divide 0 70E+7 -> 0E-7
+dddiv315 divide 0 700E-5 -> 0E+5
+dddiv316 divide 0 700E-1 -> 0E+1
+dddiv317 divide 0 700E+0 -> 0
+dddiv318 divide 0 700E+1 -> 0.0
+dddiv319 divide 0 700E+5 -> 0.00000
+dddiv320 divide 0 700E+6 -> 0.000000
+dddiv321 divide 0 700E+7 -> 0E-7
+dddiv322 divide 0 700E+77 -> 0E-77
+
+dddiv331 divide 0E-3 7E-5 -> 0E+2
+dddiv332 divide 0E-3 7E-1 -> 0.00
+dddiv333 divide 0E-3 7E+1 -> 0.0000
+dddiv334 divide 0E-3 7E+5 -> 0E-8
+dddiv335 divide 0E-1 7E-5 -> 0E+4
+dddiv336 divide 0E-1 7E-1 -> 0
+dddiv337 divide 0E-1 7E+1 -> 0.00
+dddiv338 divide 0E-1 7E+5 -> 0.000000
+dddiv339 divide 0E+1 7E-5 -> 0E+6
+dddiv340 divide 0E+1 7E-1 -> 0E+2
+dddiv341 divide 0E+1 7E+1 -> 0
+dddiv342 divide 0E+1 7E+5 -> 0.0000
+dddiv343 divide 0E+3 7E-5 -> 0E+8
+dddiv344 divide 0E+3 7E-1 -> 0E+4
+dddiv345 divide 0E+3 7E+1 -> 0E+2
+dddiv346 divide 0E+3 7E+5 -> 0.00
+
+-- These were 'input rounding'
+dddiv441 divide 12345678000 1 -> 12345678000
+dddiv442 divide 1 12345678000 -> 8.100000664200054E-11 Inexact Rounded
+dddiv443 divide 1234567800 1 -> 1234567800
+dddiv444 divide 1 1234567800 -> 8.100000664200054E-10 Inexact Rounded
+dddiv445 divide 1234567890 1 -> 1234567890
+dddiv446 divide 1 1234567890 -> 8.100000073710001E-10 Inexact Rounded
+dddiv447 divide 1234567891 1 -> 1234567891
+dddiv448 divide 1 1234567891 -> 8.100000067149001E-10 Inexact Rounded
+dddiv449 divide 12345678901 1 -> 12345678901
+dddiv450 divide 1 12345678901 -> 8.100000073053901E-11 Inexact Rounded
+dddiv451 divide 1234567896 1 -> 1234567896
+dddiv452 divide 1 1234567896 -> 8.100000034344000E-10 Inexact Rounded
+
+-- high-lows
+dddiv453 divide 1e+1 1 -> 1E+1
+dddiv454 divide 1e+1 1.0 -> 1E+1
+dddiv455 divide 1e+1 1.00 -> 1E+1
+dddiv456 divide 1e+2 2 -> 5E+1
+dddiv457 divide 1e+2 2.0 -> 5E+1
+dddiv458 divide 1e+2 2.00 -> 5E+1
+
+-- some from IEEE discussions
+dddiv460 divide 3e0 2e0 -> 1.5
+dddiv461 divide 30e-1 2e0 -> 1.5
+dddiv462 divide 300e-2 2e0 -> 1.50
+dddiv464 divide 3000e-3 2e0 -> 1.500
+dddiv465 divide 3e0 20e-1 -> 1.5
+dddiv466 divide 30e-1 20e-1 -> 1.5
+dddiv467 divide 300e-2 20e-1 -> 1.5
+dddiv468 divide 3000e-3 20e-1 -> 1.50
+dddiv469 divide 3e0 200e-2 -> 1.5
+dddiv470 divide 30e-1 200e-2 -> 1.5
+dddiv471 divide 300e-2 200e-2 -> 1.5
+dddiv472 divide 3000e-3 200e-2 -> 1.5
+dddiv473 divide 3e0 2000e-3 -> 1.5
+dddiv474 divide 30e-1 2000e-3 -> 1.5
+dddiv475 divide 300e-2 2000e-3 -> 1.5
+dddiv476 divide 3000e-3 2000e-3 -> 1.5
+
+-- some reciprocals
+dddiv480 divide 1 1.0E+33 -> 1E-33
+dddiv481 divide 1 10E+33 -> 1E-34
+dddiv482 divide 1 1.0E-33 -> 1E+33
+dddiv483 divide 1 10E-33 -> 1E+32
+
+-- RMS discussion table
+dddiv484 divide 0e5 1e3 -> 0E+2
+dddiv485 divide 0e5 2e3 -> 0E+2
+dddiv486 divide 0e5 10e2 -> 0E+3
+dddiv487 divide 0e5 20e2 -> 0E+3
+dddiv488 divide 0e5 100e1 -> 0E+4
+dddiv489 divide 0e5 200e1 -> 0E+4
+
+dddiv491 divide 1e5 1e3 -> 1E+2
+dddiv492 divide 1e5 2e3 -> 5E+1
+dddiv493 divide 1e5 10e2 -> 1E+2
+dddiv494 divide 1e5 20e2 -> 5E+1
+dddiv495 divide 1e5 100e1 -> 1E+2
+dddiv496 divide 1e5 200e1 -> 5E+1
+
+-- tryzeros cases
+rounding: half_up
+dddiv497 divide 0E+380 1000E-13 -> 0E+369 Clamped
+dddiv498 divide 0E-390 1000E+13 -> 0E-398 Clamped
+
+rounding: half_up
+
+-- focus on trailing zeros issues
+dddiv500 divide 1 9.9 -> 0.1010101010101010 Inexact Rounded
+dddiv501 divide 1 9.09 -> 0.1100110011001100 Inexact Rounded
+dddiv502 divide 1 9.009 -> 0.1110001110001110 Inexact Rounded
+
+dddiv511 divide 1 2 -> 0.5
+dddiv512 divide 1.0 2 -> 0.5
+dddiv513 divide 1.00 2 -> 0.50
+dddiv514 divide 1.000 2 -> 0.500
+dddiv515 divide 1.0000 2 -> 0.5000
+dddiv516 divide 1.00000 2 -> 0.50000
+dddiv517 divide 1.000000 2 -> 0.500000
+dddiv518 divide 1.0000000 2 -> 0.5000000
+dddiv519 divide 1.00 2.00 -> 0.5
+
+dddiv521 divide 2 1 -> 2
+dddiv522 divide 2 1.0 -> 2
+dddiv523 divide 2 1.00 -> 2
+dddiv524 divide 2 1.000 -> 2
+dddiv525 divide 2 1.0000 -> 2
+dddiv526 divide 2 1.00000 -> 2
+dddiv527 divide 2 1.000000 -> 2
+dddiv528 divide 2 1.0000000 -> 2
+dddiv529 divide 2.00 1.00 -> 2
+
+dddiv530 divide 2.40 2 -> 1.20
+dddiv531 divide 2.40 4 -> 0.60
+dddiv532 divide 2.40 10 -> 0.24
+dddiv533 divide 2.40 2.0 -> 1.2
+dddiv534 divide 2.40 4.0 -> 0.6
+dddiv535 divide 2.40 10.0 -> 0.24
+dddiv536 divide 2.40 2.00 -> 1.2
+dddiv537 divide 2.40 4.00 -> 0.6
+dddiv538 divide 2.40 10.00 -> 0.24
+dddiv539 divide 0.9 0.1 -> 9
+dddiv540 divide 0.9 0.01 -> 9E+1
+dddiv541 divide 0.9 0.001 -> 9E+2
+dddiv542 divide 5 2 -> 2.5
+dddiv543 divide 5 2.0 -> 2.5
+dddiv544 divide 5 2.00 -> 2.5
+dddiv545 divide 5 20 -> 0.25
+dddiv546 divide 5 20.0 -> 0.25
+dddiv547 divide 2.400 2 -> 1.200
+dddiv548 divide 2.400 2.0 -> 1.20
+dddiv549 divide 2.400 2.400 -> 1
+
+dddiv550 divide 240 1 -> 240
+dddiv551 divide 240 10 -> 24
+dddiv552 divide 240 100 -> 2.4
+dddiv553 divide 240 1000 -> 0.24
+dddiv554 divide 2400 1 -> 2400
+dddiv555 divide 2400 10 -> 240
+dddiv556 divide 2400 100 -> 24
+dddiv557 divide 2400 1000 -> 2.4
+
+-- +ve exponent
+dddiv600 divide 2.4E+9 2 -> 1.2E+9
+dddiv601 divide 2.40E+9 2 -> 1.20E+9
+dddiv602 divide 2.400E+9 2 -> 1.200E+9
+dddiv603 divide 2.4000E+9 2 -> 1.2000E+9
+dddiv604 divide 24E+8 2 -> 1.2E+9
+dddiv605 divide 240E+7 2 -> 1.20E+9
+dddiv606 divide 2400E+6 2 -> 1.200E+9
+dddiv607 divide 24000E+5 2 -> 1.2000E+9
+
+-- more zeros, etc.
+dddiv731 divide 5.00 1E-3 -> 5.00E+3
+dddiv732 divide 00.00 0.000 -> NaN Division_undefined
+dddiv733 divide 00.00 0E-3 -> NaN Division_undefined
+dddiv734 divide 0 -0 -> NaN Division_undefined
+dddiv735 divide -0 0 -> NaN Division_undefined
+dddiv736 divide -0 -0 -> NaN Division_undefined
+
+dddiv741 divide 0 -1 -> -0
+dddiv742 divide -0 -1 -> 0
+dddiv743 divide 0 1 -> 0
+dddiv744 divide -0 1 -> -0
+dddiv745 divide -1 0 -> -Infinity Division_by_zero
+dddiv746 divide -1 -0 -> Infinity Division_by_zero
+dddiv747 divide 1 0 -> Infinity Division_by_zero
+dddiv748 divide 1 -0 -> -Infinity Division_by_zero
+
+dddiv751 divide 0.0 -1 -> -0.0
+dddiv752 divide -0.0 -1 -> 0.0
+dddiv753 divide 0.0 1 -> 0.0
+dddiv754 divide -0.0 1 -> -0.0
+dddiv755 divide -1.0 0 -> -Infinity Division_by_zero
+dddiv756 divide -1.0 -0 -> Infinity Division_by_zero
+dddiv757 divide 1.0 0 -> Infinity Division_by_zero
+dddiv758 divide 1.0 -0 -> -Infinity Division_by_zero
+
+dddiv761 divide 0 -1.0 -> -0E+1
+dddiv762 divide -0 -1.0 -> 0E+1
+dddiv763 divide 0 1.0 -> 0E+1
+dddiv764 divide -0 1.0 -> -0E+1
+dddiv765 divide -1 0.0 -> -Infinity Division_by_zero
+dddiv766 divide -1 -0.0 -> Infinity Division_by_zero
+dddiv767 divide 1 0.0 -> Infinity Division_by_zero
+dddiv768 divide 1 -0.0 -> -Infinity Division_by_zero
+
+dddiv771 divide 0.0 -1.0 -> -0
+dddiv772 divide -0.0 -1.0 -> 0
+dddiv773 divide 0.0 1.0 -> 0
+dddiv774 divide -0.0 1.0 -> -0
+dddiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
+dddiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
+dddiv777 divide 1.0 0.0 -> Infinity Division_by_zero
+dddiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
+
+-- Specials
+dddiv780 divide Inf -Inf -> NaN Invalid_operation
+dddiv781 divide Inf -1000 -> -Infinity
+dddiv782 divide Inf -1 -> -Infinity
+dddiv783 divide Inf -0 -> -Infinity
+dddiv784 divide Inf 0 -> Infinity
+dddiv785 divide Inf 1 -> Infinity
+dddiv786 divide Inf 1000 -> Infinity
+dddiv787 divide Inf Inf -> NaN Invalid_operation
+dddiv788 divide -1000 Inf -> -0E-398 Clamped
+dddiv789 divide -Inf Inf -> NaN Invalid_operation
+dddiv790 divide -1 Inf -> -0E-398 Clamped
+dddiv791 divide -0 Inf -> -0E-398 Clamped
+dddiv792 divide 0 Inf -> 0E-398 Clamped
+dddiv793 divide 1 Inf -> 0E-398 Clamped
+dddiv794 divide 1000 Inf -> 0E-398 Clamped
+dddiv795 divide Inf Inf -> NaN Invalid_operation
+
+dddiv800 divide -Inf -Inf -> NaN Invalid_operation
+dddiv801 divide -Inf -1000 -> Infinity
+dddiv802 divide -Inf -1 -> Infinity
+dddiv803 divide -Inf -0 -> Infinity
+dddiv804 divide -Inf 0 -> -Infinity
+dddiv805 divide -Inf 1 -> -Infinity
+dddiv806 divide -Inf 1000 -> -Infinity
+dddiv807 divide -Inf Inf -> NaN Invalid_operation
+dddiv808 divide -1000 Inf -> -0E-398 Clamped
+dddiv809 divide -Inf -Inf -> NaN Invalid_operation
+dddiv810 divide -1 -Inf -> 0E-398 Clamped
+dddiv811 divide -0 -Inf -> 0E-398 Clamped
+dddiv812 divide 0 -Inf -> -0E-398 Clamped
+dddiv813 divide 1 -Inf -> -0E-398 Clamped
+dddiv814 divide 1000 -Inf -> -0E-398 Clamped
+dddiv815 divide Inf -Inf -> NaN Invalid_operation
+
+dddiv821 divide NaN -Inf -> NaN
+dddiv822 divide NaN -1000 -> NaN
+dddiv823 divide NaN -1 -> NaN
+dddiv824 divide NaN -0 -> NaN
+dddiv825 divide NaN 0 -> NaN
+dddiv826 divide NaN 1 -> NaN
+dddiv827 divide NaN 1000 -> NaN
+dddiv828 divide NaN Inf -> NaN
+dddiv829 divide NaN NaN -> NaN
+dddiv830 divide -Inf NaN -> NaN
+dddiv831 divide -1000 NaN -> NaN
+dddiv832 divide -1 NaN -> NaN
+dddiv833 divide -0 NaN -> NaN
+dddiv834 divide 0 NaN -> NaN
+dddiv835 divide 1 NaN -> NaN
+dddiv836 divide 1000 NaN -> NaN
+dddiv837 divide Inf NaN -> NaN
+
+dddiv841 divide sNaN -Inf -> NaN Invalid_operation
+dddiv842 divide sNaN -1000 -> NaN Invalid_operation
+dddiv843 divide sNaN -1 -> NaN Invalid_operation
+dddiv844 divide sNaN -0 -> NaN Invalid_operation
+dddiv845 divide sNaN 0 -> NaN Invalid_operation
+dddiv846 divide sNaN 1 -> NaN Invalid_operation
+dddiv847 divide sNaN 1000 -> NaN Invalid_operation
+dddiv848 divide sNaN NaN -> NaN Invalid_operation
+dddiv849 divide sNaN sNaN -> NaN Invalid_operation
+dddiv850 divide NaN sNaN -> NaN Invalid_operation
+dddiv851 divide -Inf sNaN -> NaN Invalid_operation
+dddiv852 divide -1000 sNaN -> NaN Invalid_operation
+dddiv853 divide -1 sNaN -> NaN Invalid_operation
+dddiv854 divide -0 sNaN -> NaN Invalid_operation
+dddiv855 divide 0 sNaN -> NaN Invalid_operation
+dddiv856 divide 1 sNaN -> NaN Invalid_operation
+dddiv857 divide 1000 sNaN -> NaN Invalid_operation
+dddiv858 divide Inf sNaN -> NaN Invalid_operation
+dddiv859 divide NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dddiv861 divide NaN9 -Inf -> NaN9
+dddiv862 divide NaN8 1000 -> NaN8
+dddiv863 divide NaN7 Inf -> NaN7
+dddiv864 divide NaN6 NaN5 -> NaN6
+dddiv865 divide -Inf NaN4 -> NaN4
+dddiv866 divide -1000 NaN3 -> NaN3
+dddiv867 divide Inf NaN2 -> NaN2
+
+dddiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
+dddiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
+dddiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
+dddiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
+dddiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
+dddiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
+dddiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
+dddiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
+dddiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
+
+dddiv881 divide -NaN9 -Inf -> -NaN9
+dddiv882 divide -NaN8 1000 -> -NaN8
+dddiv883 divide -NaN7 Inf -> -NaN7
+dddiv884 divide -NaN6 -NaN5 -> -NaN6
+dddiv885 divide -Inf -NaN4 -> -NaN4
+dddiv886 divide -1000 -NaN3 -> -NaN3
+dddiv887 divide Inf -NaN2 -> -NaN2
+
+dddiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
+dddiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
+dddiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
+dddiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
+dddiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+dddiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
+dddiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
+dddiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
+dddiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- Various flavours of divide by 0
+dddiv901 divide 0 0 -> NaN Division_undefined
+dddiv902 divide 0.0E5 0 -> NaN Division_undefined
+dddiv903 divide 0.000 0 -> NaN Division_undefined
+dddiv904 divide 0.0001 0 -> Infinity Division_by_zero
+dddiv905 divide 0.01 0 -> Infinity Division_by_zero
+dddiv906 divide 0.1 0 -> Infinity Division_by_zero
+dddiv907 divide 1 0 -> Infinity Division_by_zero
+dddiv908 divide 1 0.0 -> Infinity Division_by_zero
+dddiv909 divide 10 0.0 -> Infinity Division_by_zero
+dddiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
+dddiv911 divide 1E+100 0 -> Infinity Division_by_zero
+
+dddiv921 divide -0.0001 0 -> -Infinity Division_by_zero
+dddiv922 divide -0.01 0 -> -Infinity Division_by_zero
+dddiv923 divide -0.1 0 -> -Infinity Division_by_zero
+dddiv924 divide -1 0 -> -Infinity Division_by_zero
+dddiv925 divide -1 0.0 -> -Infinity Division_by_zero
+dddiv926 divide -10 0.0 -> -Infinity Division_by_zero
+dddiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
+dddiv928 divide -1E+100 0 -> -Infinity Division_by_zero
+
+dddiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
+dddiv932 divide 0.01 -0 -> -Infinity Division_by_zero
+dddiv933 divide 0.1 -0 -> -Infinity Division_by_zero
+dddiv934 divide 1 -0 -> -Infinity Division_by_zero
+dddiv935 divide 1 -0.0 -> -Infinity Division_by_zero
+dddiv936 divide 10 -0.0 -> -Infinity Division_by_zero
+dddiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
+dddiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
+
+dddiv941 divide -0.0001 -0 -> Infinity Division_by_zero
+dddiv942 divide -0.01 -0 -> Infinity Division_by_zero
+dddiv943 divide -0.1 -0 -> Infinity Division_by_zero
+dddiv944 divide -1 -0 -> Infinity Division_by_zero
+dddiv945 divide -1 -0.0 -> Infinity Division_by_zero
+dddiv946 divide -10 -0.0 -> Infinity Division_by_zero
+dddiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
+dddiv948 divide -1E+100 -0 -> Infinity Division_by_zero
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dddiv1021 divide 1E0 1E0 -> 1
+dddiv1022 divide 1E0 2E0 -> 0.5
+dddiv1023 divide 1E0 3E0 -> 0.3333333333333333 Inexact Rounded
+dddiv1024 divide 100E-2 1000E-3 -> 1
+dddiv1025 divide 24E-1 2E0 -> 1.2
+dddiv1026 divide 2400E-3 2E0 -> 1.200
+dddiv1027 divide 5E0 2E0 -> 2.5
+dddiv1028 divide 5E0 20E-1 -> 2.5
+dddiv1029 divide 5E0 2000E-3 -> 2.5
+dddiv1030 divide 5E0 2E-1 -> 25
+dddiv1031 divide 5E0 20E-2 -> 25
+dddiv1032 divide 480E-2 3E0 -> 1.60
+dddiv1033 divide 47E-1 2E0 -> 2.35
+
+-- ECMAScript bad examples
+rounding: half_down
+dddiv1040 divide 5 9 -> 0.5555555555555556 Inexact Rounded
+rounding: half_even
+dddiv1041 divide 6 11 -> 0.5454545454545455 Inexact Rounded
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+dddiv1051 divide 1e+277 1e-311 -> Infinity Overflow Inexact Rounded
+dddiv1052 divide 1e+277 -1e-311 -> -Infinity Overflow Inexact Rounded
+dddiv1053 divide -1e+277 1e-311 -> -Infinity Overflow Inexact Rounded
+dddiv1054 divide -1e+277 -1e-311 -> Infinity Overflow Inexact Rounded
+dddiv1055 divide 1e-277 1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1056 divide 1e-277 -1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1057 divide -1e-277 1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1058 divide -1e-277 -1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dddiv1060 divide 1e-291 1e+101 -> 1E-392 Subnormal
+dddiv1061 divide 1e-291 1e+102 -> 1E-393 Subnormal
+dddiv1062 divide 1e-291 1e+103 -> 1E-394 Subnormal
+dddiv1063 divide 1e-291 1e+104 -> 1E-395 Subnormal
+dddiv1064 divide 1e-291 1e+105 -> 1E-396 Subnormal
+dddiv1065 divide 1e-291 1e+106 -> 1E-397 Subnormal
+dddiv1066 divide 1e-291 1e+107 -> 1E-398 Subnormal
+dddiv1067 divide 1e-291 1e+108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1068 divide 1e-291 1e+109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1069 divide 1e-291 1e+110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+dddiv1070 divide 1e+60 1e-321 -> 1.000000000000E+381 Clamped
+dddiv1071 divide 1e+60 1e-322 -> 1.0000000000000E+382 Clamped
+dddiv1072 divide 1e+60 1e-323 -> 1.00000000000000E+383 Clamped
+dddiv1073 divide 1e+60 1e-324 -> 1.000000000000000E+384 Clamped
+dddiv1074 divide 1e+60 1e-325 -> Infinity Overflow Inexact Rounded
+dddiv1075 divide 1e+60 1e-326 -> Infinity Overflow Inexact Rounded
+dddiv1076 divide 1e+60 1e-327 -> Infinity Overflow Inexact Rounded
+dddiv1077 divide 1e+60 1e-328 -> Infinity Overflow Inexact Rounded
+dddiv1078 divide 1e+60 1e-329 -> Infinity Overflow Inexact Rounded
+dddiv1079 divide 1e+60 1e-330 -> Infinity Overflow Inexact Rounded
+
+dddiv1101 divide 1.0000E-394 1 -> 1.0000E-394 Subnormal
+dddiv1102 divide 1.000E-394 1e+1 -> 1.000E-395 Subnormal
+dddiv1103 divide 1.00E-394 1e+2 -> 1.00E-396 Subnormal
+dddiv1104 divide 1.0E-394 1e+3 -> 1.0E-397 Subnormal
+dddiv1105 divide 1.0E-394 1e+4 -> 1E-398 Subnormal Rounded
+dddiv1106 divide 1.3E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
+dddiv1107 divide 1.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1108 divide 1.7E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1109 divide 2.3E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1110 divide 2.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1111 divide 2.7E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
+dddiv1112 divide 1.49E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
+dddiv1113 divide 1.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1114 divide 1.51E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1115 divide 2.49E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1116 divide 2.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1117 divide 2.51E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
+
+dddiv1118 divide 1E-394 1e+4 -> 1E-398 Subnormal
+dddiv1119 divide 3E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1120 divide 5E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1121 divide 7E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
+dddiv1122 divide 9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
+dddiv1123 divide 9.9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
+
+dddiv1124 divide 1E-394 -1e+4 -> -1E-398 Subnormal
+dddiv1125 divide 3E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1126 divide -5E-394 1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1127 divide 7E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
+dddiv1128 divide -9E-394 1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
+dddiv1129 divide 9.9E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
+dddiv1130 divide 3.0E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+dddiv1131 divide 1.0E-199 1e+200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1132 divide 1.0E-199 1e+199 -> 1E-398 Subnormal Rounded
+dddiv1133 divide 1.0E-199 1e+198 -> 1.0E-397 Subnormal
+dddiv1134 divide 2.0E-199 2e+198 -> 1.0E-397 Subnormal
+dddiv1135 divide 4.0E-199 4e+198 -> 1.0E-397 Subnormal
+dddiv1136 divide 10.0E-199 10e+198 -> 1.0E-397 Subnormal
+dddiv1137 divide 30.0E-199 30e+198 -> 1.0E-397 Subnormal
+
+-- randoms
+dddiv2010 divide -3.303226714900711E-35 8.796578842713183E+73 -> -3.755126594058783E-109 Inexact Rounded
+dddiv2011 divide 933153327821073.6 68782181090246.25 -> 13.56678885475763 Inexact Rounded
+dddiv2012 divide 5.04752436057906E-72 -8.179481771238642E+64 -> -6.170958627632835E-137 Inexact Rounded
+dddiv2013 divide -3707613309582318 3394911196503.048 -> -1092.109070010836 Inexact Rounded
+dddiv2014 divide 99689.0555190461 -4.735208553891464 -> -21052.72753765411 Inexact Rounded
+dddiv2015 divide -1447915775613329 269750797.8184875 -> -5367605.164925653 Inexact Rounded
+dddiv2016 divide -9.394881304225258E-19 -830585.0252671636 -> 1.131116143251358E-24 Inexact Rounded
+dddiv2017 divide -1.056283432738934 88.58754555124013 -> -0.01192361100159352 Inexact Rounded
+dddiv2018 divide 5763220933343.081 689089567025052.1 -> 0.008363529516524456 Inexact Rounded
+dddiv2019 divide 873819.122103216 9.740612494523300E-49 -> 8.970884763093948E+53 Inexact Rounded
+dddiv2020 divide 8022914.838533576 6178.566801742713 -> 1298.507420243583 Inexact Rounded
+dddiv2021 divide 203982.7605650363 -2158.283639053435 -> -94.51156320422168 Inexact Rounded
+dddiv2022 divide 803.6310547013030 7101143795399.238 -> 1.131692411611166E-10 Inexact Rounded
+dddiv2023 divide 9.251697842123399E-82 -1.342350220606119E-7 -> -6.892163982321936E-75 Inexact Rounded
+dddiv2024 divide -1.980600645637992E-53 -5.474262753214457E+77 -> 3.618022617703168E-131 Inexact Rounded
+dddiv2025 divide -210.0322996351690 -8.580951835872843E+80 -> 2.447657365434971E-79 Inexact Rounded
+dddiv2026 divide -1.821980314020370E+85 -3.018915267138165 -> 6.035215144503042E+84 Inexact Rounded
+dddiv2027 divide -772264503601.1047 5.158258271408988E-86 -> -1.497141986630614E+97 Inexact Rounded
+dddiv2028 divide -767.0532415847106 2.700027228028939E-59 -> -2.840909282772941E+61 Inexact Rounded
+dddiv2029 divide 496724.8548250093 7.32700588163100E+66 -> 6.779370220929013E-62 Inexact Rounded
+dddiv2030 divide -304232651447703.9 -108.9730808657440 -> 2791814721862.565 Inexact Rounded
+dddiv2031 divide -7.233817192699405E+42 -5711302004.149411 -> 1.266579352211430E+33 Inexact Rounded
+dddiv2032 divide -9.999221444912745E+96 4010569406446197 -> -2.493217404202250E+81 Inexact Rounded
+dddiv2033 divide -1837272.061937622 8.356322838066762 -> -219866.0939196882 Inexact Rounded
+dddiv2034 divide 2168.517555606529 209.1910258615061 -> 10.36620737756784 Inexact Rounded
+dddiv2035 divide -1.884389790576371E+88 2.95181953870583E+20 -> -6.383824505079828E+67 Inexact Rounded
+dddiv2036 divide 732263.6037438196 961222.3634446889 -> 0.7618045850698269 Inexact Rounded
+dddiv2037 divide -813461419.0348336 5.376293753809143E+84 -> -1.513052404285927E-76 Inexact Rounded
+dddiv2038 divide -45562133508108.50 -9.776843494690107E+51 -> 4.660208945029519E-39 Inexact Rounded
+dddiv2039 divide -6.489393172441016E+80 -9101965.097852113 -> 7.129661674897421E+73 Inexact Rounded
+dddiv2040 divide 3.694576237117349E+93 6683512.012622003 -> 5.527896456443912E+86 Inexact Rounded
+dddiv2041 divide -2.252877726403272E+19 -7451913256.181367 -> 3023220546.125531 Inexact Rounded
+dddiv2042 divide 518303.1989111842 50.01587020474133 -> 10362.77479107123 Inexact Rounded
+dddiv2043 divide 2.902087881880103E+24 33.32400992305702 -> 8.708699488989578E+22 Inexact Rounded
+dddiv2044 divide 549619.4559510557 1660824845196338 -> 3.309316196351104E-10 Inexact Rounded
+dddiv2045 divide -6775670774684043 8292152023.077262 -> -817118.4941891062 Inexact Rounded
+dddiv2046 divide -77.50923921524079 -5.636882655425815E+74 -> 1.375037302588405E-73 Inexact Rounded
+dddiv2047 divide -2.984889459605149E-10 -88106156784122.99 -> 3.387833005721384E-24 Inexact Rounded
+dddiv2048 divide 0.949517293997085 44767115.96450998 -> 2.121015110175589E-8 Inexact Rounded
+dddiv2049 divide -2760937211.084521 -1087015876975408 -> 0.000002539923537057024 Inexact Rounded
+dddiv2050 divide 28438351.85030536 -4.209397904088624E-47 -> -6.755919135770688E+53 Inexact Rounded
+dddiv2051 divide -85562731.6820956 -7.166045442530185E+45 -> 1.194002080621542E-38 Inexact Rounded
+dddiv2052 divide 2533802852165.25 7154.119606235955 -> 354173957.3317501 Inexact Rounded
+dddiv2053 divide -8858831346851.474 97.59734208801716 -> -90769186509.83577 Inexact Rounded
+dddiv2054 divide 176783629801387.5 840073263.3109817 -> 210438.3480848206 Inexact Rounded
+dddiv2055 divide -493506471796175.6 79733894790822.03 -> -6.189418854940746 Inexact Rounded
+dddiv2056 divide 790.1682542103445 829.9449370367435 -> 0.9520731062371214 Inexact Rounded
+dddiv2057 divide -8920459838.583164 -4767.889187899214 -> 1870945.294035581 Inexact Rounded
+dddiv2058 divide 53536687164422.1 53137.5007032689 -> 1007512330.385698 Inexact Rounded
+dddiv2059 divide 4.051532311146561E-74 -2.343089768972261E+94 -> -1.729140882606332E-168 Inexact Rounded
+dddiv2060 divide -14847758778636.88 3.062543516383807E-43 -> -4.848178874587497E+55 Inexact Rounded
+
+-- Division probably has pre-rounding, so need to test rounding
+-- explicitly rather than assume included through other tests;
+-- tests include simple rounding and also the tricky cases of sticky
+-- bits following two zeros
+--
+-- 1/99999 gives 0.0000100001000010000100001000010000100001
+-- 1234567890123456
+--
+-- 1/999999 gives 0.000001000001000001000001000001000001000001
+-- 1234567890123456
+
+rounding: ceiling
+dddiv3001 divide 1 3 -> 0.3333333333333334 Inexact Rounded
+dddiv3002 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3003 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
+dddiv3004 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
+
+rounding: floor
+dddiv3011 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3012 divide 2 3 -> 0.6666666666666666 Inexact Rounded
+dddiv3013 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3014 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: up
+dddiv3021 divide 1 3 -> 0.3333333333333334 Inexact Rounded
+dddiv3022 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3023 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
+dddiv3024 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
+
+rounding: down
+dddiv3031 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3032 divide 2 3 -> 0.6666666666666666 Inexact Rounded
+dddiv3033 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3034 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: half_up
+dddiv3041 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3042 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3043 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3044 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: half_down
+dddiv3051 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3052 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3053 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3054 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: half_even
+dddiv3061 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3062 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3063 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3064 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: 05up
+dddiv3071 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3072 divide 2 3 -> 0.6666666666666666 Inexact Rounded
+dddiv3073 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3074 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
+
+-- random divide tests with result near 1
+rounding: half_even
+dddiv4001 divide 3195385192916917 3195385192946695 -> 0.9999999999906809 Inexact Rounded
+dddiv4002 divide 1393723067526993 1393723067519475 -> 1.000000000005394 Inexact Rounded
+dddiv4003 divide 759985543702302 759985543674015 -> 1.000000000037220 Inexact Rounded
+dddiv4004 divide 9579158456027302 9579158456036864 -> 0.9999999999990018 Inexact Rounded
+dddiv4005 divide 7079398299143569 7079398299156904 -> 0.9999999999981164 Inexact Rounded
+dddiv4006 divide 6636169255366598 6636169255336386 -> 1.000000000004553 Inexact Rounded
+dddiv4007 divide 6964813971340090 6964813971321554 -> 1.000000000002661 Inexact Rounded
+dddiv4008 divide 4182275225480784 4182275225454009 -> 1.000000000006402 Inexact Rounded
+dddiv4009 divide 9228325124938029 9228325124918730 -> 1.000000000002091 Inexact Rounded
+dddiv4010 divide 3428346338630192 3428346338609843 -> 1.000000000005936 Inexact Rounded
+dddiv4011 divide 2143511550722893 2143511550751754 -> 0.9999999999865356 Inexact Rounded
+dddiv4012 divide 1672732924396785 1672732924401811 -> 0.9999999999969953 Inexact Rounded
+dddiv4013 divide 4190714611948216 4190714611948664 -> 0.9999999999998931 Inexact Rounded
+dddiv4014 divide 3942254800848877 3942254800814556 -> 1.000000000008706 Inexact Rounded
+dddiv4015 divide 2854459826952334 2854459826960762 -> 0.9999999999970474 Inexact Rounded
+dddiv4016 divide 2853258953664731 2853258953684471 -> 0.9999999999930816 Inexact Rounded
+dddiv4017 divide 9453512638125978 9453512638146425 -> 0.9999999999978371 Inexact Rounded
+dddiv4018 divide 339476633940369 339476633912887 -> 1.000000000080954 Inexact Rounded
+dddiv4019 divide 4542181492688467 4542181492697735 -> 0.9999999999979596 Inexact Rounded
+dddiv4020 divide 7312600192399197 7312600192395424 -> 1.000000000000516 Inexact Rounded
+dddiv4021 divide 1811674985570111 1811674985603935 -> 0.9999999999813300 Inexact Rounded
+dddiv4022 divide 1706462639003481 1706462639017740 -> 0.9999999999916441 Inexact Rounded
+dddiv4023 divide 6697052654940368 6697052654934110 -> 1.000000000000934 Inexact Rounded
+dddiv4024 divide 5015283664277539 5015283664310719 -> 0.9999999999933842 Inexact Rounded
+dddiv4025 divide 2359501561537464 2359501561502464 -> 1.000000000014834 Inexact Rounded
+dddiv4026 divide 2669850227909157 2669850227901548 -> 1.000000000002850 Inexact Rounded
+dddiv4027 divide 9329725546974648 9329725547002445 -> 0.9999999999970206 Inexact Rounded
+dddiv4028 divide 3228562867071248 3228562867106206 -> 0.9999999999891723 Inexact Rounded
+dddiv4029 divide 4862226644921175 4862226644909380 -> 1.000000000002426 Inexact Rounded
+dddiv4030 divide 1022267997054529 1022267997071329 -> 0.9999999999835660 Inexact Rounded
+dddiv4031 divide 1048777482023719 1048777482000948 -> 1.000000000021712 Inexact Rounded
+dddiv4032 divide 9980113777337098 9980113777330539 -> 1.000000000000657 Inexact Rounded
+dddiv4033 divide 7506839167963908 7506839167942901 -> 1.000000000002798 Inexact Rounded
+dddiv4034 divide 231119751977860 231119751962453 -> 1.000000000066662 Inexact Rounded
+dddiv4035 divide 4034903664762962 4034903664795526 -> 0.9999999999919294 Inexact Rounded
+dddiv4036 divide 5700122152274696 5700122152251386 -> 1.000000000004089 Inexact Rounded
+dddiv4037 divide 6869599590293110 6869599590293495 -> 0.9999999999999440 Inexact Rounded
+dddiv4038 divide 5576281960092797 5576281960105579 -> 0.9999999999977078 Inexact Rounded
+dddiv4039 divide 2304844888381318 2304844888353073 -> 1.000000000012255 Inexact Rounded
+dddiv4040 divide 3265933651656452 3265933651682779 -> 0.9999999999919389 Inexact Rounded
+dddiv4041 divide 5235714985079914 5235714985066131 -> 1.000000000002632 Inexact Rounded
+dddiv4042 divide 5578481572827551 5578481572822945 -> 1.000000000000826 Inexact Rounded
+dddiv4043 divide 4909616081396134 4909616081373076 -> 1.000000000004696 Inexact Rounded
+dddiv4044 divide 636447224349537 636447224338757 -> 1.000000000016938 Inexact Rounded
+dddiv4045 divide 1539373428396640 1539373428364727 -> 1.000000000020731 Inexact Rounded
+dddiv4046 divide 2028786707377893 2028786707378866 -> 0.9999999999995204 Inexact Rounded
+dddiv4047 divide 137643260486222 137643260487419 -> 0.9999999999913036 Inexact Rounded
+dddiv4048 divide 247451519746765 247451519752267 -> 0.9999999999777653 Inexact Rounded
+dddiv4049 divide 7877858475022054 7877858474999794 -> 1.000000000002826 Inexact Rounded
+dddiv4050 divide 7333242694766258 7333242694744628 -> 1.000000000002950 Inexact Rounded
+dddiv4051 divide 124051503698592 124051503699397 -> 0.9999999999935108 Inexact Rounded
+dddiv4052 divide 8944737432385188 8944737432406860 -> 0.9999999999975771 Inexact Rounded
+dddiv4053 divide 9883948923406874 9883948923424843 -> 0.9999999999981820 Inexact Rounded
+dddiv4054 divide 6829178741654284 6829178741671973 -> 0.9999999999974098 Inexact Rounded
+dddiv4055 divide 7342752479768122 7342752479793385 -> 0.9999999999965595 Inexact Rounded
+dddiv4056 divide 8066426579008783 8066426578977563 -> 1.000000000003870 Inexact Rounded
+dddiv4057 divide 8992775071383295 8992775071352712 -> 1.000000000003401 Inexact Rounded
+dddiv4058 divide 5485011755545641 5485011755543611 -> 1.000000000000370 Inexact Rounded
+dddiv4059 divide 5779983054353918 5779983054365300 -> 0.9999999999980308 Inexact Rounded
+dddiv4060 divide 9502265102713774 9502265102735208 -> 0.9999999999977443 Inexact Rounded
+dddiv4061 divide 2109558399130981 2109558399116281 -> 1.000000000006968 Inexact Rounded
+dddiv4062 divide 5296182636350471 5296182636351521 -> 0.9999999999998017 Inexact Rounded
+dddiv4063 divide 1440019225591883 1440019225601844 -> 0.9999999999930827 Inexact Rounded
+dddiv4064 divide 8182110791881341 8182110791847174 -> 1.000000000004176 Inexact Rounded
+dddiv4065 divide 489098235512060 489098235534516 -> 0.9999999999540869 Inexact Rounded
+dddiv4066 divide 6475687084782038 6475687084756089 -> 1.000000000004007 Inexact Rounded
+dddiv4067 divide 8094348555736948 8094348555759236 -> 0.9999999999972465 Inexact Rounded
+dddiv4068 divide 1982766816291543 1982766816309463 -> 0.9999999999909621 Inexact Rounded
+dddiv4069 divide 9277314300113251 9277314300084467 -> 1.000000000003103 Inexact Rounded
+dddiv4070 divide 4335532959318934 4335532959293167 -> 1.000000000005943 Inexact Rounded
+dddiv4071 divide 7767113032981348 7767113032968132 -> 1.000000000001702 Inexact Rounded
+dddiv4072 divide 1578548053342868 1578548053370448 -> 0.9999999999825282 Inexact Rounded
+dddiv4073 divide 3790420686666898 3790420686636315 -> 1.000000000008068 Inexact Rounded
+dddiv4074 divide 871682421955147 871682421976441 -> 0.9999999999755714 Inexact Rounded
+dddiv4075 divide 744141054479940 744141054512329 -> 0.9999999999564746 Inexact Rounded
+dddiv4076 divide 8956824183670735 8956824183641741 -> 1.000000000003237 Inexact Rounded
+dddiv4077 divide 8337291694485682 8337291694451193 -> 1.000000000004137 Inexact Rounded
+dddiv4078 divide 4107775944683669 4107775944657097 -> 1.000000000006469 Inexact Rounded
+dddiv4079 divide 8691900057964648 8691900057997555 -> 0.9999999999962141 Inexact Rounded
+dddiv4080 divide 2229528520536462 2229528520502337 -> 1.000000000015306 Inexact Rounded
+dddiv4081 divide 398442083774322 398442083746273 -> 1.000000000070397 Inexact Rounded
+dddiv4082 divide 5319819776808759 5319819776838313 -> 0.9999999999944445 Inexact Rounded
+dddiv4083 divide 7710491299066855 7710491299041858 -> 1.000000000003242 Inexact Rounded
+dddiv4084 divide 9083231296087266 9083231296058160 -> 1.000000000003204 Inexact Rounded
+dddiv4085 divide 3566873574904559 3566873574890328 -> 1.000000000003990 Inexact Rounded
+dddiv4086 divide 596343290550525 596343290555614 -> 0.9999999999914663 Inexact Rounded
+dddiv4087 divide 278227925093192 278227925068104 -> 1.000000000090171 Inexact Rounded
+dddiv4088 divide 3292902958490649 3292902958519881 -> 0.9999999999911227 Inexact Rounded
+dddiv4089 divide 5521871364245881 5521871364229536 -> 1.000000000002960 Inexact Rounded
+dddiv4090 divide 2406505602883617 2406505602857997 -> 1.000000000010646 Inexact Rounded
+dddiv4091 divide 7741146984869208 7741146984867255 -> 1.000000000000252 Inexact Rounded
+dddiv4092 divide 4576041832414909 4576041832405102 -> 1.000000000002143 Inexact Rounded
+dddiv4093 divide 9183756982878057 9183756982901934 -> 0.9999999999974001 Inexact Rounded
+dddiv4094 divide 6215736513855159 6215736513870342 -> 0.9999999999975573 Inexact Rounded
+dddiv4095 divide 248554968534533 248554968551417 -> 0.9999999999320714 Inexact Rounded
+dddiv4096 divide 376314165668645 376314165659755 -> 1.000000000023624 Inexact Rounded
+dddiv4097 divide 5513569249809718 5513569249808906 -> 1.000000000000147 Inexact Rounded
+dddiv4098 divide 3367992242167904 3367992242156228 -> 1.000000000003467 Inexact Rounded
+dddiv4099 divide 6134869538966967 6134869538985986 -> 0.9999999999968999 Inexact Rounded
+
+-- Null tests
+dddiv9998 divide 10 # -> NaN Invalid_operation
+dddiv9999 divide # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddDivideInt.decTest b/Lib/test/decimaltestdata/ddDivideInt.decTest
index bec567986f..1555b4217d 100644
--- a/Lib/test/decimaltestdata/ddDivideInt.decTest
+++ b/Lib/test/decimaltestdata/ddDivideInt.decTest
@@ -1,449 +1,449 @@
-------------------------------------------------------------------------
--- ddDivideInt.decTest -- decDouble integer division --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-dddvi001 divideint 1 1 -> 1
-dddvi002 divideint 2 1 -> 2
-dddvi003 divideint 1 2 -> 0
-dddvi004 divideint 2 2 -> 1
-dddvi005 divideint 0 1 -> 0
-dddvi006 divideint 0 2 -> 0
-dddvi007 divideint 1 3 -> 0
-dddvi008 divideint 2 3 -> 0
-dddvi009 divideint 3 3 -> 1
-
-dddvi010 divideint 2.4 1 -> 2
-dddvi011 divideint 2.4 -1 -> -2
-dddvi012 divideint -2.4 1 -> -2
-dddvi013 divideint -2.4 -1 -> 2
-dddvi014 divideint 2.40 1 -> 2
-dddvi015 divideint 2.400 1 -> 2
-dddvi016 divideint 2.4 2 -> 1
-dddvi017 divideint 2.400 2 -> 1
-dddvi018 divideint 2. 2 -> 1
-dddvi019 divideint 20 20 -> 1
-
-dddvi020 divideint 187 187 -> 1
-dddvi021 divideint 5 2 -> 2
-dddvi022 divideint 5 2.0 -> 2
-dddvi023 divideint 5 2.000 -> 2
-dddvi024 divideint 5 0.200 -> 25
-dddvi025 divideint 5 0.200 -> 25
-
-dddvi030 divideint 1 2 -> 0
-dddvi031 divideint 1 4 -> 0
-dddvi032 divideint 1 8 -> 0
-dddvi033 divideint 1 16 -> 0
-dddvi034 divideint 1 32 -> 0
-dddvi035 divideint 1 64 -> 0
-dddvi040 divideint 1 -2 -> -0
-dddvi041 divideint 1 -4 -> -0
-dddvi042 divideint 1 -8 -> -0
-dddvi043 divideint 1 -16 -> -0
-dddvi044 divideint 1 -32 -> -0
-dddvi045 divideint 1 -64 -> -0
-dddvi050 divideint -1 2 -> -0
-dddvi051 divideint -1 4 -> -0
-dddvi052 divideint -1 8 -> -0
-dddvi053 divideint -1 16 -> -0
-dddvi054 divideint -1 32 -> -0
-dddvi055 divideint -1 64 -> -0
-dddvi060 divideint -1 -2 -> 0
-dddvi061 divideint -1 -4 -> 0
-dddvi062 divideint -1 -8 -> 0
-dddvi063 divideint -1 -16 -> 0
-dddvi064 divideint -1 -32 -> 0
-dddvi065 divideint -1 -64 -> 0
-
--- similar with powers of ten
-dddvi160 divideint 1 1 -> 1
-dddvi161 divideint 1 10 -> 0
-dddvi162 divideint 1 100 -> 0
-dddvi163 divideint 1 1000 -> 0
-dddvi164 divideint 1 10000 -> 0
-dddvi165 divideint 1 100000 -> 0
-dddvi166 divideint 1 1000000 -> 0
-dddvi167 divideint 1 10000000 -> 0
-dddvi168 divideint 1 100000000 -> 0
-dddvi170 divideint 1 -1 -> -1
-dddvi171 divideint 1 -10 -> -0
-dddvi172 divideint 1 -100 -> -0
-dddvi173 divideint 1 -1000 -> -0
-dddvi174 divideint 1 -10000 -> -0
-dddvi175 divideint 1 -100000 -> -0
-dddvi176 divideint 1 -1000000 -> -0
-dddvi177 divideint 1 -10000000 -> -0
-dddvi178 divideint 1 -100000000 -> -0
-dddvi180 divideint -1 1 -> -1
-dddvi181 divideint -1 10 -> -0
-dddvi182 divideint -1 100 -> -0
-dddvi183 divideint -1 1000 -> -0
-dddvi184 divideint -1 10000 -> -0
-dddvi185 divideint -1 100000 -> -0
-dddvi186 divideint -1 1000000 -> -0
-dddvi187 divideint -1 10000000 -> -0
-dddvi188 divideint -1 100000000 -> -0
-dddvi190 divideint -1 -1 -> 1
-dddvi191 divideint -1 -10 -> 0
-dddvi192 divideint -1 -100 -> 0
-dddvi193 divideint -1 -1000 -> 0
-dddvi194 divideint -1 -10000 -> 0
-dddvi195 divideint -1 -100000 -> 0
-dddvi196 divideint -1 -1000000 -> 0
-dddvi197 divideint -1 -10000000 -> 0
-dddvi198 divideint -1 -100000000 -> 0
-
--- some long operand (at p=9) cases
-dddvi070 divideint 999999999 1 -> 999999999
-dddvi071 divideint 999999999.4 1 -> 999999999
-dddvi072 divideint 999999999.5 1 -> 999999999
-dddvi073 divideint 999999999.9 1 -> 999999999
-dddvi074 divideint 999999999.999 1 -> 999999999
-
-dddvi090 divideint 0. 1 -> 0
-dddvi091 divideint .0 1 -> 0
-dddvi092 divideint 0.00 1 -> 0
-dddvi093 divideint 0.00E+9 1 -> 0
-dddvi094 divideint 0.0000E-50 1 -> 0
-
-dddvi100 divideint 1 1 -> 1
-dddvi101 divideint 1 2 -> 0
-dddvi102 divideint 1 3 -> 0
-dddvi103 divideint 1 4 -> 0
-dddvi104 divideint 1 5 -> 0
-dddvi105 divideint 1 6 -> 0
-dddvi106 divideint 1 7 -> 0
-dddvi107 divideint 1 8 -> 0
-dddvi108 divideint 1 9 -> 0
-dddvi109 divideint 1 10 -> 0
-dddvi110 divideint 1 1 -> 1
-dddvi111 divideint 2 1 -> 2
-dddvi112 divideint 3 1 -> 3
-dddvi113 divideint 4 1 -> 4
-dddvi114 divideint 5 1 -> 5
-dddvi115 divideint 6 1 -> 6
-dddvi116 divideint 7 1 -> 7
-dddvi117 divideint 8 1 -> 8
-dddvi118 divideint 9 1 -> 9
-dddvi119 divideint 10 1 -> 10
-
--- from DiagBigDecimal
-dddvi131 divideint 101.3 1 -> 101
-dddvi132 divideint 101.0 1 -> 101
-dddvi133 divideint 101.3 3 -> 33
-dddvi134 divideint 101.0 3 -> 33
-dddvi135 divideint 2.4 1 -> 2
-dddvi136 divideint 2.400 1 -> 2
-dddvi137 divideint 18 18 -> 1
-dddvi138 divideint 1120 1000 -> 1
-dddvi139 divideint 2.4 2 -> 1
-dddvi140 divideint 2.400 2 -> 1
-dddvi141 divideint 0.5 2.000 -> 0
-dddvi142 divideint 8.005 7 -> 1
-dddvi143 divideint 5 2 -> 2
-dddvi144 divideint 0 2 -> 0
-dddvi145 divideint 0.00 2 -> 0
-
--- Others
-dddvi150 divideint 12345 4.999 -> 2469
-dddvi151 divideint 12345 4.99 -> 2473
-dddvi152 divideint 12345 4.9 -> 2519
-dddvi153 divideint 12345 5 -> 2469
-dddvi154 divideint 12345 5.1 -> 2420
-dddvi155 divideint 12345 5.01 -> 2464
-dddvi156 divideint 12345 5.001 -> 2468
-dddvi157 divideint 101 7.6 -> 13
-
--- Various flavours of divideint by 0
-dddvi201 divideint 0 0 -> NaN Division_undefined
-dddvi202 divideint 0.0E5 0 -> NaN Division_undefined
-dddvi203 divideint 0.000 0 -> NaN Division_undefined
-dddvi204 divideint 0.0001 0 -> Infinity Division_by_zero
-dddvi205 divideint 0.01 0 -> Infinity Division_by_zero
-dddvi206 divideint 0.1 0 -> Infinity Division_by_zero
-dddvi207 divideint 1 0 -> Infinity Division_by_zero
-dddvi208 divideint 1 0.0 -> Infinity Division_by_zero
-dddvi209 divideint 10 0.0 -> Infinity Division_by_zero
-dddvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
-dddvi211 divideint 1E+380 0 -> Infinity Division_by_zero
-dddvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
-dddvi215 divideint -0.01 0 -> -Infinity Division_by_zero
-dddvi216 divideint -0.1 0 -> -Infinity Division_by_zero
-dddvi217 divideint -1 0 -> -Infinity Division_by_zero
-dddvi218 divideint -1 0.0 -> -Infinity Division_by_zero
-dddvi219 divideint -10 0.0 -> -Infinity Division_by_zero
-dddvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
-dddvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
-
--- test some cases that are close to exponent overflow
-dddvi270 divideint 1 1e384 -> 0
-dddvi271 divideint 1 0.9e384 -> 0
-dddvi272 divideint 1 0.99e384 -> 0
-dddvi273 divideint 1 0.9999999999999999e384 -> 0
-dddvi274 divideint 9e384 1 -> NaN Division_impossible
-dddvi275 divideint 9.9e384 1 -> NaN Division_impossible
-dddvi276 divideint 9.99e384 1 -> NaN Division_impossible
-dddvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
-
-dddvi280 divideint 0.1 9e-383 -> NaN Division_impossible
-dddvi281 divideint 0.1 99e-383 -> NaN Division_impossible
-dddvi282 divideint 0.1 999e-383 -> NaN Division_impossible
-dddvi283 divideint 0.1 9e-382 -> NaN Division_impossible
-dddvi284 divideint 0.1 99e-382 -> NaN Division_impossible
-
--- GD edge cases: lhs smaller than rhs but more digits
-dddvi301 divideint 0.9 2 -> 0
-dddvi302 divideint 0.9 2.0 -> 0
-dddvi303 divideint 0.9 2.1 -> 0
-dddvi304 divideint 0.9 2.00 -> 0
-dddvi305 divideint 0.9 2.01 -> 0
-dddvi306 divideint 0.12 1 -> 0
-dddvi307 divideint 0.12 1.0 -> 0
-dddvi308 divideint 0.12 1.00 -> 0
-dddvi309 divideint 0.12 1.0 -> 0
-dddvi310 divideint 0.12 1.00 -> 0
-dddvi311 divideint 0.12 2 -> 0
-dddvi312 divideint 0.12 2.0 -> 0
-dddvi313 divideint 0.12 2.1 -> 0
-dddvi314 divideint 0.12 2.00 -> 0
-dddvi315 divideint 0.12 2.01 -> 0
-
--- edge cases of impossible
-dddvi330 divideint 1234567890123456 10 -> 123456789012345
-dddvi331 divideint 1234567890123456 1 -> 1234567890123456
-dddvi332 divideint 1234567890123456 0.1 -> NaN Division_impossible
-dddvi333 divideint 1234567890123456 0.01 -> NaN Division_impossible
-
--- overflow and underflow tests [from divide]
-dddvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
-dddvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
-dddvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
-dddvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
-dddvi1055 divideint 1e-277 1e+311 -> 0
-dddvi1056 divideint 1e-277 -1e+311 -> -0
-dddvi1057 divideint -1e-277 1e+311 -> -0
-dddvi1058 divideint -1e-277 -1e+311 -> 0
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dddvi1060 divideint 1e-291 1e+101 -> 0
-dddvi1061 divideint 1e-291 1e+102 -> 0
-dddvi1062 divideint 1e-291 1e+103 -> 0
-dddvi1063 divideint 1e-291 1e+104 -> 0
-dddvi1064 divideint 1e-291 1e+105 -> 0
-dddvi1065 divideint 1e-291 1e+106 -> 0
-dddvi1066 divideint 1e-291 1e+107 -> 0
-dddvi1067 divideint 1e-291 1e+108 -> 0
-dddvi1068 divideint 1e-291 1e+109 -> 0
-dddvi1069 divideint 1e-291 1e+110 -> 0
-
-dddvi1101 divideint 1.0000E-394 1 -> 0
-dddvi1102 divideint 1.000E-394 1e+1 -> 0
-dddvi1103 divideint 1.00E-394 1e+2 -> 0
-
-dddvi1118 divideint 1E-394 1e+4 -> 0
-dddvi1119 divideint 3E-394 -1e+5 -> -0
-dddvi1120 divideint 5E-394 1e+5 -> 0
-
-dddvi1124 divideint 1E-394 -1e+4 -> -0
-dddvi1130 divideint 3.0E-394 -1e+5 -> -0
-
-dddvi1131 divideint 1.0E-199 1e+200 -> 0
-dddvi1132 divideint 1.0E-199 1e+199 -> 0
-dddvi1133 divideint 1.0E-199 1e+198 -> 0
-dddvi1134 divideint 2.0E-199 2e+198 -> 0
-dddvi1135 divideint 4.0E-199 4e+198 -> 0
-
--- long operand checks
-dddvi401 divideint 12345678000 100 -> 123456780
-dddvi402 divideint 1 12345678000 -> 0
-dddvi403 divideint 1234567800 10 -> 123456780
-dddvi404 divideint 1 1234567800 -> 0
-dddvi405 divideint 1234567890 10 -> 123456789
-dddvi406 divideint 1 1234567890 -> 0
-dddvi407 divideint 1234567891 10 -> 123456789
-dddvi408 divideint 1 1234567891 -> 0
-dddvi409 divideint 12345678901 100 -> 123456789
-dddvi410 divideint 1 12345678901 -> 0
-dddvi411 divideint 1234567896 10 -> 123456789
-dddvi412 divideint 1 1234567896 -> 0
-dddvi413 divideint 12345678948 100 -> 123456789
-dddvi414 divideint 12345678949 100 -> 123456789
-dddvi415 divideint 12345678950 100 -> 123456789
-dddvi416 divideint 12345678951 100 -> 123456789
-dddvi417 divideint 12345678999 100 -> 123456789
-dddvi441 divideint 12345678000 1 -> 12345678000
-dddvi442 divideint 1 12345678000 -> 0
-dddvi443 divideint 1234567800 1 -> 1234567800
-dddvi444 divideint 1 1234567800 -> 0
-dddvi445 divideint 1234567890 1 -> 1234567890
-dddvi446 divideint 1 1234567890 -> 0
-dddvi447 divideint 1234567891 1 -> 1234567891
-dddvi448 divideint 1 1234567891 -> 0
-dddvi449 divideint 12345678901 1 -> 12345678901
-dddvi450 divideint 1 12345678901 -> 0
-dddvi451 divideint 1234567896 1 -> 1234567896
-dddvi452 divideint 1 1234567896 -> 0
-
--- more zeros, etc.
-dddvi531 divideint 5.00 1E-3 -> 5000
-dddvi532 divideint 00.00 0.000 -> NaN Division_undefined
-dddvi533 divideint 00.00 0E-3 -> NaN Division_undefined
-dddvi534 divideint 0 -0 -> NaN Division_undefined
-dddvi535 divideint -0 0 -> NaN Division_undefined
-dddvi536 divideint -0 -0 -> NaN Division_undefined
-
-dddvi541 divideint 0 -1 -> -0
-dddvi542 divideint -0 -1 -> 0
-dddvi543 divideint 0 1 -> 0
-dddvi544 divideint -0 1 -> -0
-dddvi545 divideint -1 0 -> -Infinity Division_by_zero
-dddvi546 divideint -1 -0 -> Infinity Division_by_zero
-dddvi547 divideint 1 0 -> Infinity Division_by_zero
-dddvi548 divideint 1 -0 -> -Infinity Division_by_zero
-
-dddvi551 divideint 0.0 -1 -> -0
-dddvi552 divideint -0.0 -1 -> 0
-dddvi553 divideint 0.0 1 -> 0
-dddvi554 divideint -0.0 1 -> -0
-dddvi555 divideint -1.0 0 -> -Infinity Division_by_zero
-dddvi556 divideint -1.0 -0 -> Infinity Division_by_zero
-dddvi557 divideint 1.0 0 -> Infinity Division_by_zero
-dddvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
-
-dddvi561 divideint 0 -1.0 -> -0
-dddvi562 divideint -0 -1.0 -> 0
-dddvi563 divideint 0 1.0 -> 0
-dddvi564 divideint -0 1.0 -> -0
-dddvi565 divideint -1 0.0 -> -Infinity Division_by_zero
-dddvi566 divideint -1 -0.0 -> Infinity Division_by_zero
-dddvi567 divideint 1 0.0 -> Infinity Division_by_zero
-dddvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
-
-dddvi571 divideint 0.0 -1.0 -> -0
-dddvi572 divideint -0.0 -1.0 -> 0
-dddvi573 divideint 0.0 1.0 -> 0
-dddvi574 divideint -0.0 1.0 -> -0
-dddvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
-dddvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
-dddvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
-dddvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
-
--- Specials
-dddvi580 divideint Inf -Inf -> NaN Invalid_operation
-dddvi581 divideint Inf -1000 -> -Infinity
-dddvi582 divideint Inf -1 -> -Infinity
-dddvi583 divideint Inf -0 -> -Infinity
-dddvi584 divideint Inf 0 -> Infinity
-dddvi585 divideint Inf 1 -> Infinity
-dddvi586 divideint Inf 1000 -> Infinity
-dddvi587 divideint Inf Inf -> NaN Invalid_operation
-dddvi588 divideint -1000 Inf -> -0
-dddvi589 divideint -Inf Inf -> NaN Invalid_operation
-dddvi590 divideint -1 Inf -> -0
-dddvi591 divideint -0 Inf -> -0
-dddvi592 divideint 0 Inf -> 0
-dddvi593 divideint 1 Inf -> 0
-dddvi594 divideint 1000 Inf -> 0
-dddvi595 divideint Inf Inf -> NaN Invalid_operation
-
-dddvi600 divideint -Inf -Inf -> NaN Invalid_operation
-dddvi601 divideint -Inf -1000 -> Infinity
-dddvi602 divideint -Inf -1 -> Infinity
-dddvi603 divideint -Inf -0 -> Infinity
-dddvi604 divideint -Inf 0 -> -Infinity
-dddvi605 divideint -Inf 1 -> -Infinity
-dddvi606 divideint -Inf 1000 -> -Infinity
-dddvi607 divideint -Inf Inf -> NaN Invalid_operation
-dddvi608 divideint -1000 Inf -> -0
-dddvi609 divideint -Inf -Inf -> NaN Invalid_operation
-dddvi610 divideint -1 -Inf -> 0
-dddvi611 divideint -0 -Inf -> 0
-dddvi612 divideint 0 -Inf -> -0
-dddvi613 divideint 1 -Inf -> -0
-dddvi614 divideint 1000 -Inf -> -0
-dddvi615 divideint Inf -Inf -> NaN Invalid_operation
-
-dddvi621 divideint NaN -Inf -> NaN
-dddvi622 divideint NaN -1000 -> NaN
-dddvi623 divideint NaN -1 -> NaN
-dddvi624 divideint NaN -0 -> NaN
-dddvi625 divideint NaN 0 -> NaN
-dddvi626 divideint NaN 1 -> NaN
-dddvi627 divideint NaN 1000 -> NaN
-dddvi628 divideint NaN Inf -> NaN
-dddvi629 divideint NaN NaN -> NaN
-dddvi630 divideint -Inf NaN -> NaN
-dddvi631 divideint -1000 NaN -> NaN
-dddvi632 divideint -1 NaN -> NaN
-dddvi633 divideint -0 NaN -> NaN
-dddvi634 divideint 0 NaN -> NaN
-dddvi635 divideint 1 NaN -> NaN
-dddvi636 divideint 1000 NaN -> NaN
-dddvi637 divideint Inf NaN -> NaN
-
-dddvi641 divideint sNaN -Inf -> NaN Invalid_operation
-dddvi642 divideint sNaN -1000 -> NaN Invalid_operation
-dddvi643 divideint sNaN -1 -> NaN Invalid_operation
-dddvi644 divideint sNaN -0 -> NaN Invalid_operation
-dddvi645 divideint sNaN 0 -> NaN Invalid_operation
-dddvi646 divideint sNaN 1 -> NaN Invalid_operation
-dddvi647 divideint sNaN 1000 -> NaN Invalid_operation
-dddvi648 divideint sNaN NaN -> NaN Invalid_operation
-dddvi649 divideint sNaN sNaN -> NaN Invalid_operation
-dddvi650 divideint NaN sNaN -> NaN Invalid_operation
-dddvi651 divideint -Inf sNaN -> NaN Invalid_operation
-dddvi652 divideint -1000 sNaN -> NaN Invalid_operation
-dddvi653 divideint -1 sNaN -> NaN Invalid_operation
-dddvi654 divideint -0 sNaN -> NaN Invalid_operation
-dddvi655 divideint 0 sNaN -> NaN Invalid_operation
-dddvi656 divideint 1 sNaN -> NaN Invalid_operation
-dddvi657 divideint 1000 sNaN -> NaN Invalid_operation
-dddvi658 divideint Inf sNaN -> NaN Invalid_operation
-dddvi659 divideint NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dddvi661 divideint NaN9 -Inf -> NaN9
-dddvi662 divideint NaN8 1000 -> NaN8
-dddvi663 divideint NaN7 Inf -> NaN7
-dddvi664 divideint -NaN6 NaN5 -> -NaN6
-dddvi665 divideint -Inf NaN4 -> NaN4
-dddvi666 divideint -1000 NaN3 -> NaN3
-dddvi667 divideint Inf -NaN2 -> -NaN2
-
-dddvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
-dddvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
-dddvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
-dddvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
-dddvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
-dddvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
-dddvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
-dddvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
-dddvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
-
--- Null tests
-dddvi900 divideint 10 # -> NaN Invalid_operation
-dddvi901 divideint # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddDivideInt.decTest -- decDouble integer division --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+dddvi001 divideint 1 1 -> 1
+dddvi002 divideint 2 1 -> 2
+dddvi003 divideint 1 2 -> 0
+dddvi004 divideint 2 2 -> 1
+dddvi005 divideint 0 1 -> 0
+dddvi006 divideint 0 2 -> 0
+dddvi007 divideint 1 3 -> 0
+dddvi008 divideint 2 3 -> 0
+dddvi009 divideint 3 3 -> 1
+
+dddvi010 divideint 2.4 1 -> 2
+dddvi011 divideint 2.4 -1 -> -2
+dddvi012 divideint -2.4 1 -> -2
+dddvi013 divideint -2.4 -1 -> 2
+dddvi014 divideint 2.40 1 -> 2
+dddvi015 divideint 2.400 1 -> 2
+dddvi016 divideint 2.4 2 -> 1
+dddvi017 divideint 2.400 2 -> 1
+dddvi018 divideint 2. 2 -> 1
+dddvi019 divideint 20 20 -> 1
+
+dddvi020 divideint 187 187 -> 1
+dddvi021 divideint 5 2 -> 2
+dddvi022 divideint 5 2.0 -> 2
+dddvi023 divideint 5 2.000 -> 2
+dddvi024 divideint 5 0.200 -> 25
+dddvi025 divideint 5 0.200 -> 25
+
+dddvi030 divideint 1 2 -> 0
+dddvi031 divideint 1 4 -> 0
+dddvi032 divideint 1 8 -> 0
+dddvi033 divideint 1 16 -> 0
+dddvi034 divideint 1 32 -> 0
+dddvi035 divideint 1 64 -> 0
+dddvi040 divideint 1 -2 -> -0
+dddvi041 divideint 1 -4 -> -0
+dddvi042 divideint 1 -8 -> -0
+dddvi043 divideint 1 -16 -> -0
+dddvi044 divideint 1 -32 -> -0
+dddvi045 divideint 1 -64 -> -0
+dddvi050 divideint -1 2 -> -0
+dddvi051 divideint -1 4 -> -0
+dddvi052 divideint -1 8 -> -0
+dddvi053 divideint -1 16 -> -0
+dddvi054 divideint -1 32 -> -0
+dddvi055 divideint -1 64 -> -0
+dddvi060 divideint -1 -2 -> 0
+dddvi061 divideint -1 -4 -> 0
+dddvi062 divideint -1 -8 -> 0
+dddvi063 divideint -1 -16 -> 0
+dddvi064 divideint -1 -32 -> 0
+dddvi065 divideint -1 -64 -> 0
+
+-- similar with powers of ten
+dddvi160 divideint 1 1 -> 1
+dddvi161 divideint 1 10 -> 0
+dddvi162 divideint 1 100 -> 0
+dddvi163 divideint 1 1000 -> 0
+dddvi164 divideint 1 10000 -> 0
+dddvi165 divideint 1 100000 -> 0
+dddvi166 divideint 1 1000000 -> 0
+dddvi167 divideint 1 10000000 -> 0
+dddvi168 divideint 1 100000000 -> 0
+dddvi170 divideint 1 -1 -> -1
+dddvi171 divideint 1 -10 -> -0
+dddvi172 divideint 1 -100 -> -0
+dddvi173 divideint 1 -1000 -> -0
+dddvi174 divideint 1 -10000 -> -0
+dddvi175 divideint 1 -100000 -> -0
+dddvi176 divideint 1 -1000000 -> -0
+dddvi177 divideint 1 -10000000 -> -0
+dddvi178 divideint 1 -100000000 -> -0
+dddvi180 divideint -1 1 -> -1
+dddvi181 divideint -1 10 -> -0
+dddvi182 divideint -1 100 -> -0
+dddvi183 divideint -1 1000 -> -0
+dddvi184 divideint -1 10000 -> -0
+dddvi185 divideint -1 100000 -> -0
+dddvi186 divideint -1 1000000 -> -0
+dddvi187 divideint -1 10000000 -> -0
+dddvi188 divideint -1 100000000 -> -0
+dddvi190 divideint -1 -1 -> 1
+dddvi191 divideint -1 -10 -> 0
+dddvi192 divideint -1 -100 -> 0
+dddvi193 divideint -1 -1000 -> 0
+dddvi194 divideint -1 -10000 -> 0
+dddvi195 divideint -1 -100000 -> 0
+dddvi196 divideint -1 -1000000 -> 0
+dddvi197 divideint -1 -10000000 -> 0
+dddvi198 divideint -1 -100000000 -> 0
+
+-- some long operand (at p=9) cases
+dddvi070 divideint 999999999 1 -> 999999999
+dddvi071 divideint 999999999.4 1 -> 999999999
+dddvi072 divideint 999999999.5 1 -> 999999999
+dddvi073 divideint 999999999.9 1 -> 999999999
+dddvi074 divideint 999999999.999 1 -> 999999999
+
+dddvi090 divideint 0. 1 -> 0
+dddvi091 divideint .0 1 -> 0
+dddvi092 divideint 0.00 1 -> 0
+dddvi093 divideint 0.00E+9 1 -> 0
+dddvi094 divideint 0.0000E-50 1 -> 0
+
+dddvi100 divideint 1 1 -> 1
+dddvi101 divideint 1 2 -> 0
+dddvi102 divideint 1 3 -> 0
+dddvi103 divideint 1 4 -> 0
+dddvi104 divideint 1 5 -> 0
+dddvi105 divideint 1 6 -> 0
+dddvi106 divideint 1 7 -> 0
+dddvi107 divideint 1 8 -> 0
+dddvi108 divideint 1 9 -> 0
+dddvi109 divideint 1 10 -> 0
+dddvi110 divideint 1 1 -> 1
+dddvi111 divideint 2 1 -> 2
+dddvi112 divideint 3 1 -> 3
+dddvi113 divideint 4 1 -> 4
+dddvi114 divideint 5 1 -> 5
+dddvi115 divideint 6 1 -> 6
+dddvi116 divideint 7 1 -> 7
+dddvi117 divideint 8 1 -> 8
+dddvi118 divideint 9 1 -> 9
+dddvi119 divideint 10 1 -> 10
+
+-- from DiagBigDecimal
+dddvi131 divideint 101.3 1 -> 101
+dddvi132 divideint 101.0 1 -> 101
+dddvi133 divideint 101.3 3 -> 33
+dddvi134 divideint 101.0 3 -> 33
+dddvi135 divideint 2.4 1 -> 2
+dddvi136 divideint 2.400 1 -> 2
+dddvi137 divideint 18 18 -> 1
+dddvi138 divideint 1120 1000 -> 1
+dddvi139 divideint 2.4 2 -> 1
+dddvi140 divideint 2.400 2 -> 1
+dddvi141 divideint 0.5 2.000 -> 0
+dddvi142 divideint 8.005 7 -> 1
+dddvi143 divideint 5 2 -> 2
+dddvi144 divideint 0 2 -> 0
+dddvi145 divideint 0.00 2 -> 0
+
+-- Others
+dddvi150 divideint 12345 4.999 -> 2469
+dddvi151 divideint 12345 4.99 -> 2473
+dddvi152 divideint 12345 4.9 -> 2519
+dddvi153 divideint 12345 5 -> 2469
+dddvi154 divideint 12345 5.1 -> 2420
+dddvi155 divideint 12345 5.01 -> 2464
+dddvi156 divideint 12345 5.001 -> 2468
+dddvi157 divideint 101 7.6 -> 13
+
+-- Various flavours of divideint by 0
+dddvi201 divideint 0 0 -> NaN Division_undefined
+dddvi202 divideint 0.0E5 0 -> NaN Division_undefined
+dddvi203 divideint 0.000 0 -> NaN Division_undefined
+dddvi204 divideint 0.0001 0 -> Infinity Division_by_zero
+dddvi205 divideint 0.01 0 -> Infinity Division_by_zero
+dddvi206 divideint 0.1 0 -> Infinity Division_by_zero
+dddvi207 divideint 1 0 -> Infinity Division_by_zero
+dddvi208 divideint 1 0.0 -> Infinity Division_by_zero
+dddvi209 divideint 10 0.0 -> Infinity Division_by_zero
+dddvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
+dddvi211 divideint 1E+380 0 -> Infinity Division_by_zero
+dddvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
+dddvi215 divideint -0.01 0 -> -Infinity Division_by_zero
+dddvi216 divideint -0.1 0 -> -Infinity Division_by_zero
+dddvi217 divideint -1 0 -> -Infinity Division_by_zero
+dddvi218 divideint -1 0.0 -> -Infinity Division_by_zero
+dddvi219 divideint -10 0.0 -> -Infinity Division_by_zero
+dddvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
+dddvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
+
+-- test some cases that are close to exponent overflow
+dddvi270 divideint 1 1e384 -> 0
+dddvi271 divideint 1 0.9e384 -> 0
+dddvi272 divideint 1 0.99e384 -> 0
+dddvi273 divideint 1 0.9999999999999999e384 -> 0
+dddvi274 divideint 9e384 1 -> NaN Division_impossible
+dddvi275 divideint 9.9e384 1 -> NaN Division_impossible
+dddvi276 divideint 9.99e384 1 -> NaN Division_impossible
+dddvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
+
+dddvi280 divideint 0.1 9e-383 -> NaN Division_impossible
+dddvi281 divideint 0.1 99e-383 -> NaN Division_impossible
+dddvi282 divideint 0.1 999e-383 -> NaN Division_impossible
+dddvi283 divideint 0.1 9e-382 -> NaN Division_impossible
+dddvi284 divideint 0.1 99e-382 -> NaN Division_impossible
+
+-- GD edge cases: lhs smaller than rhs but more digits
+dddvi301 divideint 0.9 2 -> 0
+dddvi302 divideint 0.9 2.0 -> 0
+dddvi303 divideint 0.9 2.1 -> 0
+dddvi304 divideint 0.9 2.00 -> 0
+dddvi305 divideint 0.9 2.01 -> 0
+dddvi306 divideint 0.12 1 -> 0
+dddvi307 divideint 0.12 1.0 -> 0
+dddvi308 divideint 0.12 1.00 -> 0
+dddvi309 divideint 0.12 1.0 -> 0
+dddvi310 divideint 0.12 1.00 -> 0
+dddvi311 divideint 0.12 2 -> 0
+dddvi312 divideint 0.12 2.0 -> 0
+dddvi313 divideint 0.12 2.1 -> 0
+dddvi314 divideint 0.12 2.00 -> 0
+dddvi315 divideint 0.12 2.01 -> 0
+
+-- edge cases of impossible
+dddvi330 divideint 1234567890123456 10 -> 123456789012345
+dddvi331 divideint 1234567890123456 1 -> 1234567890123456
+dddvi332 divideint 1234567890123456 0.1 -> NaN Division_impossible
+dddvi333 divideint 1234567890123456 0.01 -> NaN Division_impossible
+
+-- overflow and underflow tests [from divide]
+dddvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
+dddvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
+dddvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
+dddvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
+dddvi1055 divideint 1e-277 1e+311 -> 0
+dddvi1056 divideint 1e-277 -1e+311 -> -0
+dddvi1057 divideint -1e-277 1e+311 -> -0
+dddvi1058 divideint -1e-277 -1e+311 -> 0
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dddvi1060 divideint 1e-291 1e+101 -> 0
+dddvi1061 divideint 1e-291 1e+102 -> 0
+dddvi1062 divideint 1e-291 1e+103 -> 0
+dddvi1063 divideint 1e-291 1e+104 -> 0
+dddvi1064 divideint 1e-291 1e+105 -> 0
+dddvi1065 divideint 1e-291 1e+106 -> 0
+dddvi1066 divideint 1e-291 1e+107 -> 0
+dddvi1067 divideint 1e-291 1e+108 -> 0
+dddvi1068 divideint 1e-291 1e+109 -> 0
+dddvi1069 divideint 1e-291 1e+110 -> 0
+
+dddvi1101 divideint 1.0000E-394 1 -> 0
+dddvi1102 divideint 1.000E-394 1e+1 -> 0
+dddvi1103 divideint 1.00E-394 1e+2 -> 0
+
+dddvi1118 divideint 1E-394 1e+4 -> 0
+dddvi1119 divideint 3E-394 -1e+5 -> -0
+dddvi1120 divideint 5E-394 1e+5 -> 0
+
+dddvi1124 divideint 1E-394 -1e+4 -> -0
+dddvi1130 divideint 3.0E-394 -1e+5 -> -0
+
+dddvi1131 divideint 1.0E-199 1e+200 -> 0
+dddvi1132 divideint 1.0E-199 1e+199 -> 0
+dddvi1133 divideint 1.0E-199 1e+198 -> 0
+dddvi1134 divideint 2.0E-199 2e+198 -> 0
+dddvi1135 divideint 4.0E-199 4e+198 -> 0
+
+-- long operand checks
+dddvi401 divideint 12345678000 100 -> 123456780
+dddvi402 divideint 1 12345678000 -> 0
+dddvi403 divideint 1234567800 10 -> 123456780
+dddvi404 divideint 1 1234567800 -> 0
+dddvi405 divideint 1234567890 10 -> 123456789
+dddvi406 divideint 1 1234567890 -> 0
+dddvi407 divideint 1234567891 10 -> 123456789
+dddvi408 divideint 1 1234567891 -> 0
+dddvi409 divideint 12345678901 100 -> 123456789
+dddvi410 divideint 1 12345678901 -> 0
+dddvi411 divideint 1234567896 10 -> 123456789
+dddvi412 divideint 1 1234567896 -> 0
+dddvi413 divideint 12345678948 100 -> 123456789
+dddvi414 divideint 12345678949 100 -> 123456789
+dddvi415 divideint 12345678950 100 -> 123456789
+dddvi416 divideint 12345678951 100 -> 123456789
+dddvi417 divideint 12345678999 100 -> 123456789
+dddvi441 divideint 12345678000 1 -> 12345678000
+dddvi442 divideint 1 12345678000 -> 0
+dddvi443 divideint 1234567800 1 -> 1234567800
+dddvi444 divideint 1 1234567800 -> 0
+dddvi445 divideint 1234567890 1 -> 1234567890
+dddvi446 divideint 1 1234567890 -> 0
+dddvi447 divideint 1234567891 1 -> 1234567891
+dddvi448 divideint 1 1234567891 -> 0
+dddvi449 divideint 12345678901 1 -> 12345678901
+dddvi450 divideint 1 12345678901 -> 0
+dddvi451 divideint 1234567896 1 -> 1234567896
+dddvi452 divideint 1 1234567896 -> 0
+
+-- more zeros, etc.
+dddvi531 divideint 5.00 1E-3 -> 5000
+dddvi532 divideint 00.00 0.000 -> NaN Division_undefined
+dddvi533 divideint 00.00 0E-3 -> NaN Division_undefined
+dddvi534 divideint 0 -0 -> NaN Division_undefined
+dddvi535 divideint -0 0 -> NaN Division_undefined
+dddvi536 divideint -0 -0 -> NaN Division_undefined
+
+dddvi541 divideint 0 -1 -> -0
+dddvi542 divideint -0 -1 -> 0
+dddvi543 divideint 0 1 -> 0
+dddvi544 divideint -0 1 -> -0
+dddvi545 divideint -1 0 -> -Infinity Division_by_zero
+dddvi546 divideint -1 -0 -> Infinity Division_by_zero
+dddvi547 divideint 1 0 -> Infinity Division_by_zero
+dddvi548 divideint 1 -0 -> -Infinity Division_by_zero
+
+dddvi551 divideint 0.0 -1 -> -0
+dddvi552 divideint -0.0 -1 -> 0
+dddvi553 divideint 0.0 1 -> 0
+dddvi554 divideint -0.0 1 -> -0
+dddvi555 divideint -1.0 0 -> -Infinity Division_by_zero
+dddvi556 divideint -1.0 -0 -> Infinity Division_by_zero
+dddvi557 divideint 1.0 0 -> Infinity Division_by_zero
+dddvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
+
+dddvi561 divideint 0 -1.0 -> -0
+dddvi562 divideint -0 -1.0 -> 0
+dddvi563 divideint 0 1.0 -> 0
+dddvi564 divideint -0 1.0 -> -0
+dddvi565 divideint -1 0.0 -> -Infinity Division_by_zero
+dddvi566 divideint -1 -0.0 -> Infinity Division_by_zero
+dddvi567 divideint 1 0.0 -> Infinity Division_by_zero
+dddvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
+
+dddvi571 divideint 0.0 -1.0 -> -0
+dddvi572 divideint -0.0 -1.0 -> 0
+dddvi573 divideint 0.0 1.0 -> 0
+dddvi574 divideint -0.0 1.0 -> -0
+dddvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
+dddvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
+dddvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
+dddvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
+
+-- Specials
+dddvi580 divideint Inf -Inf -> NaN Invalid_operation
+dddvi581 divideint Inf -1000 -> -Infinity
+dddvi582 divideint Inf -1 -> -Infinity
+dddvi583 divideint Inf -0 -> -Infinity
+dddvi584 divideint Inf 0 -> Infinity
+dddvi585 divideint Inf 1 -> Infinity
+dddvi586 divideint Inf 1000 -> Infinity
+dddvi587 divideint Inf Inf -> NaN Invalid_operation
+dddvi588 divideint -1000 Inf -> -0
+dddvi589 divideint -Inf Inf -> NaN Invalid_operation
+dddvi590 divideint -1 Inf -> -0
+dddvi591 divideint -0 Inf -> -0
+dddvi592 divideint 0 Inf -> 0
+dddvi593 divideint 1 Inf -> 0
+dddvi594 divideint 1000 Inf -> 0
+dddvi595 divideint Inf Inf -> NaN Invalid_operation
+
+dddvi600 divideint -Inf -Inf -> NaN Invalid_operation
+dddvi601 divideint -Inf -1000 -> Infinity
+dddvi602 divideint -Inf -1 -> Infinity
+dddvi603 divideint -Inf -0 -> Infinity
+dddvi604 divideint -Inf 0 -> -Infinity
+dddvi605 divideint -Inf 1 -> -Infinity
+dddvi606 divideint -Inf 1000 -> -Infinity
+dddvi607 divideint -Inf Inf -> NaN Invalid_operation
+dddvi608 divideint -1000 Inf -> -0
+dddvi609 divideint -Inf -Inf -> NaN Invalid_operation
+dddvi610 divideint -1 -Inf -> 0
+dddvi611 divideint -0 -Inf -> 0
+dddvi612 divideint 0 -Inf -> -0
+dddvi613 divideint 1 -Inf -> -0
+dddvi614 divideint 1000 -Inf -> -0
+dddvi615 divideint Inf -Inf -> NaN Invalid_operation
+
+dddvi621 divideint NaN -Inf -> NaN
+dddvi622 divideint NaN -1000 -> NaN
+dddvi623 divideint NaN -1 -> NaN
+dddvi624 divideint NaN -0 -> NaN
+dddvi625 divideint NaN 0 -> NaN
+dddvi626 divideint NaN 1 -> NaN
+dddvi627 divideint NaN 1000 -> NaN
+dddvi628 divideint NaN Inf -> NaN
+dddvi629 divideint NaN NaN -> NaN
+dddvi630 divideint -Inf NaN -> NaN
+dddvi631 divideint -1000 NaN -> NaN
+dddvi632 divideint -1 NaN -> NaN
+dddvi633 divideint -0 NaN -> NaN
+dddvi634 divideint 0 NaN -> NaN
+dddvi635 divideint 1 NaN -> NaN
+dddvi636 divideint 1000 NaN -> NaN
+dddvi637 divideint Inf NaN -> NaN
+
+dddvi641 divideint sNaN -Inf -> NaN Invalid_operation
+dddvi642 divideint sNaN -1000 -> NaN Invalid_operation
+dddvi643 divideint sNaN -1 -> NaN Invalid_operation
+dddvi644 divideint sNaN -0 -> NaN Invalid_operation
+dddvi645 divideint sNaN 0 -> NaN Invalid_operation
+dddvi646 divideint sNaN 1 -> NaN Invalid_operation
+dddvi647 divideint sNaN 1000 -> NaN Invalid_operation
+dddvi648 divideint sNaN NaN -> NaN Invalid_operation
+dddvi649 divideint sNaN sNaN -> NaN Invalid_operation
+dddvi650 divideint NaN sNaN -> NaN Invalid_operation
+dddvi651 divideint -Inf sNaN -> NaN Invalid_operation
+dddvi652 divideint -1000 sNaN -> NaN Invalid_operation
+dddvi653 divideint -1 sNaN -> NaN Invalid_operation
+dddvi654 divideint -0 sNaN -> NaN Invalid_operation
+dddvi655 divideint 0 sNaN -> NaN Invalid_operation
+dddvi656 divideint 1 sNaN -> NaN Invalid_operation
+dddvi657 divideint 1000 sNaN -> NaN Invalid_operation
+dddvi658 divideint Inf sNaN -> NaN Invalid_operation
+dddvi659 divideint NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dddvi661 divideint NaN9 -Inf -> NaN9
+dddvi662 divideint NaN8 1000 -> NaN8
+dddvi663 divideint NaN7 Inf -> NaN7
+dddvi664 divideint -NaN6 NaN5 -> -NaN6
+dddvi665 divideint -Inf NaN4 -> NaN4
+dddvi666 divideint -1000 NaN3 -> NaN3
+dddvi667 divideint Inf -NaN2 -> -NaN2
+
+dddvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
+dddvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
+dddvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
+dddvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
+dddvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
+dddvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
+dddvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
+dddvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
+dddvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
+
+-- Null tests
+dddvi900 divideint 10 # -> NaN Invalid_operation
+dddvi901 divideint # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddEncode.decTest b/Lib/test/decimaltestdata/ddEncode.decTest
index de9d31c0a6..e91ec6143c 100644
--- a/Lib/test/decimaltestdata/ddEncode.decTest
+++ b/Lib/test/decimaltestdata/ddEncode.decTest
@@ -1,495 +1,495 @@
-------------------------------------------------------------------------
--- ddEncode.decTest -- decimal eight-byte format testcases --
--- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
--- [Previously called decimal64.decTest]
-version: 2.59
-
--- This set of tests is for the eight-byte concrete representation.
--- Its characteristics are:
---
--- 1 bit sign
--- 5 bits combination field
--- 8 bits exponent continuation
--- 50 bits coefficient continuation
---
--- Total exponent length 10 bits
--- Total coefficient length 54 bits (16 digits)
---
--- Elimit = 767 (maximum encoded exponent)
--- Emax = 384 (largest exponent value)
--- Emin = -383 (smallest exponent value)
--- bias = 398 (subtracted from encoded exponent) = -Etiny
-
--- The testcases here have only exactly representable data on the
--- 'left-hand-side'; rounding from strings is tested in 'base'
--- testcase groups.
-
-extended: 1
-clamp: 1
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
--- General testcases
--- (mostly derived from the Strawman 4 document and examples)
-dece001 apply #A2300000000003D0 -> -7.50
-dece002 apply -7.50 -> #A2300000000003D0
--- derivative canonical plain strings
-dece003 apply #A23c0000000003D0 -> -7.50E+3
-dece004 apply -7.50E+3 -> #A23c0000000003D0
-dece005 apply #A2380000000003D0 -> -750
-dece006 apply -750 -> #A2380000000003D0
-dece007 apply #A2340000000003D0 -> -75.0
-dece008 apply -75.0 -> #A2340000000003D0
-dece009 apply #A22c0000000003D0 -> -0.750
-dece010 apply -0.750 -> #A22c0000000003D0
-dece011 apply #A2280000000003D0 -> -0.0750
-dece012 apply -0.0750 -> #A2280000000003D0
-dece013 apply #A2200000000003D0 -> -0.000750
-dece014 apply -0.000750 -> #A2200000000003D0
-dece015 apply #A2180000000003D0 -> -0.00000750
-dece016 apply -0.00000750 -> #A2180000000003D0
-dece017 apply #A2140000000003D0 -> -7.50E-7
-dece018 apply -7.50E-7 -> #A2140000000003D0
-
--- Normality
-dece020 apply 1234567890123456 -> #263934b9c1e28e56
-dece021 apply -1234567890123456 -> #a63934b9c1e28e56
-dece022 apply 1234.567890123456 -> #260934b9c1e28e56
-dece023 apply #260934b9c1e28e56 -> 1234.567890123456
-dece024 apply 1111111111111111 -> #2638912449124491
-dece025 apply 9999999999999999 -> #6e38ff3fcff3fcff
-
--- Nmax and similar
-dece031 apply 9999999999999999E+369 -> #77fcff3fcff3fcff
-dece032 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
-dece033 apply #77fcff3fcff3fcff -> 9.999999999999999E+384
-dece034 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56
-dece035 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384
--- fold-downs (more below)
-dece036 apply 1.23E+384 -> #47fd300000000000 Clamped
-dece037 apply #47fd300000000000 -> 1.230000000000000E+384
-decd038 apply 1E+384 -> #47fc000000000000 Clamped
-decd039 apply #47fc000000000000 -> 1.000000000000000E+384
-
-decd051 apply 12345 -> #22380000000049c5
-decd052 apply #22380000000049c5 -> 12345
-decd053 apply 1234 -> #2238000000000534
-decd054 apply #2238000000000534 -> 1234
-decd055 apply 123 -> #22380000000000a3
-decd056 apply #22380000000000a3 -> 123
-decd057 apply 12 -> #2238000000000012
-decd058 apply #2238000000000012 -> 12
-decd059 apply 1 -> #2238000000000001
-decd060 apply #2238000000000001 -> 1
-decd061 apply 1.23 -> #22300000000000a3
-decd062 apply #22300000000000a3 -> 1.23
-decd063 apply 123.45 -> #22300000000049c5
-decd064 apply #22300000000049c5 -> 123.45
-
--- Nmin and below
-decd071 apply 1E-383 -> #003c000000000001
-decd072 apply #003c000000000001 -> 1E-383
-decd073 apply 1.000000000000000E-383 -> #0400000000000000
-decd074 apply #0400000000000000 -> 1.000000000000000E-383
-decd075 apply 1.000000000000001E-383 -> #0400000000000001
-decd076 apply #0400000000000001 -> 1.000000000000001E-383
-
-decd077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal
-decd078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal
-decd079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal
-decd080 apply #0000000000000010 -> 1.0E-397 Subnormal
-decd081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal
-decd082 apply #0004000000000001 -> 1E-397 Subnormal
-decd083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal
-decd084 apply #0000000000000001 -> 1E-398 Subnormal
--- next is smallest all-nines
-decd085 apply 9999999999999999E-398 -> #6400ff3fcff3fcff
-decd086 apply #6400ff3fcff3fcff -> 9.999999999999999E-383
--- and a problematic divide result
-decd088 apply 1.111111111111111E-383 -> #0400912449124491
-decd089 apply #0400912449124491 -> 1.111111111111111E-383
-
--- forties
-decd090 apply 40 -> #2238000000000040
-decd091 apply 39.99 -> #2230000000000cff
-
--- underflows cannot be tested as all LHS exact
-
--- Same again, negatives
--- Nmax and similar
-decd122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff
-decd123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384
-decd124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56
-decd125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384
--- fold-downs (more below)
-decd130 apply -1.23E+384 -> #c7fd300000000000 Clamped
-decd131 apply #c7fd300000000000 -> -1.230000000000000E+384
-decd132 apply -1E+384 -> #c7fc000000000000 Clamped
-decd133 apply #c7fc000000000000 -> -1.000000000000000E+384
-
--- overflows
-decd151 apply -12345 -> #a2380000000049c5
-decd152 apply #a2380000000049c5 -> -12345
-decd153 apply -1234 -> #a238000000000534
-decd154 apply #a238000000000534 -> -1234
-decd155 apply -123 -> #a2380000000000a3
-decd156 apply #a2380000000000a3 -> -123
-decd157 apply -12 -> #a238000000000012
-decd158 apply #a238000000000012 -> -12
-decd159 apply -1 -> #a238000000000001
-decd160 apply #a238000000000001 -> -1
-decd161 apply -1.23 -> #a2300000000000a3
-decd162 apply #a2300000000000a3 -> -1.23
-decd163 apply -123.45 -> #a2300000000049c5
-decd164 apply #a2300000000049c5 -> -123.45
-
--- Nmin and below
-decd171 apply -1E-383 -> #803c000000000001
-decd172 apply #803c000000000001 -> -1E-383
-decd173 apply -1.000000000000000E-383 -> #8400000000000000
-decd174 apply #8400000000000000 -> -1.000000000000000E-383
-decd175 apply -1.000000000000001E-383 -> #8400000000000001
-decd176 apply #8400000000000001 -> -1.000000000000001E-383
-
-decd177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal
-decd178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal
-decd179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal
-decd180 apply #8000000000000010 -> -1.0E-397 Subnormal
-decd181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal
-decd182 apply #8004000000000001 -> -1E-397 Subnormal
-decd183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal
-decd184 apply #8000000000000001 -> -1E-398 Subnormal
--- next is smallest all-nines
-decd185 apply -9999999999999999E-398 -> #e400ff3fcff3fcff
-decd186 apply #e400ff3fcff3fcff -> -9.999999999999999E-383
--- and a tricky subnormal
-decd187 apply 1.11111111111524E-384 -> #00009124491246a4 Subnormal
-decd188 apply #00009124491246a4 -> 1.11111111111524E-384 Subnormal
-
--- near-underflows
-decd189 apply -1e-398 -> #8000000000000001 Subnormal
-decd190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded
-
--- zeros
-decd401 apply 0E-500 -> #0000000000000000 Clamped
-decd402 apply 0E-400 -> #0000000000000000 Clamped
-decd403 apply 0E-398 -> #0000000000000000
-decd404 apply #0000000000000000 -> 0E-398
-decd405 apply 0.000000000000000E-383 -> #0000000000000000
-decd406 apply #0000000000000000 -> 0E-398
-decd407 apply 0E-2 -> #2230000000000000
-decd408 apply #2230000000000000 -> 0.00
-decd409 apply 0 -> #2238000000000000
-decd410 apply #2238000000000000 -> 0
-decd411 apply 0E+3 -> #2244000000000000
-decd412 apply #2244000000000000 -> 0E+3
-decd413 apply 0E+369 -> #43fc000000000000
-decd414 apply #43fc000000000000 -> 0E+369
--- clamped zeros...
-decd415 apply 0E+370 -> #43fc000000000000 Clamped
-decd416 apply #43fc000000000000 -> 0E+369
-decd417 apply 0E+384 -> #43fc000000000000 Clamped
-decd418 apply #43fc000000000000 -> 0E+369
-decd419 apply 0E+400 -> #43fc000000000000 Clamped
-decd420 apply #43fc000000000000 -> 0E+369
-decd421 apply 0E+500 -> #43fc000000000000 Clamped
-decd422 apply #43fc000000000000 -> 0E+369
-
--- negative zeros
-decd431 apply -0E-400 -> #8000000000000000 Clamped
-decd432 apply -0E-400 -> #8000000000000000 Clamped
-decd433 apply -0E-398 -> #8000000000000000
-decd434 apply #8000000000000000 -> -0E-398
-decd435 apply -0.000000000000000E-383 -> #8000000000000000
-decd436 apply #8000000000000000 -> -0E-398
-decd437 apply -0E-2 -> #a230000000000000
-decd438 apply #a230000000000000 -> -0.00
-decd439 apply -0 -> #a238000000000000
-decd440 apply #a238000000000000 -> -0
-decd441 apply -0E+3 -> #a244000000000000
-decd442 apply #a244000000000000 -> -0E+3
-decd443 apply -0E+369 -> #c3fc000000000000
-decd444 apply #c3fc000000000000 -> -0E+369
--- clamped zeros...
-decd445 apply -0E+370 -> #c3fc000000000000 Clamped
-decd446 apply #c3fc000000000000 -> -0E+369
-decd447 apply -0E+384 -> #c3fc000000000000 Clamped
-decd448 apply #c3fc000000000000 -> -0E+369
-decd449 apply -0E+400 -> #c3fc000000000000 Clamped
-decd450 apply #c3fc000000000000 -> -0E+369
-decd451 apply -0E+500 -> #c3fc000000000000 Clamped
-decd452 apply #c3fc000000000000 -> -0E+369
-
--- exponents
-decd460 apply #225c000000000007 -> 7E+9
-decd461 apply 7E+9 -> #225c000000000007
-decd462 apply #23c4000000000007 -> 7E+99
-decd463 apply 7E+99 -> #23c4000000000007
-
--- Specials
-decd500 apply Infinity -> #7800000000000000
-decd501 apply #7878787878787878 -> #7800000000000000
-decd502 apply #7800000000000000 -> Infinity
-decd503 apply #7979797979797979 -> #7800000000000000
-decd504 apply #7900000000000000 -> Infinity
-decd505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000
-decd506 apply #7a00000000000000 -> Infinity
-decd507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000
-decd508 apply #7b00000000000000 -> Infinity
-
-decd509 apply NaN -> #7c00000000000000
-decd510 apply #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c
-decd511 apply #7c00000000000000 -> NaN
-decd512 apply #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d
-decd513 apply #7d00000000000000 -> NaN
-decd514 apply #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e
-decd515 apply #7e00000000000000 -> sNaN
-decd516 apply #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f
-decd517 apply #7f00000000000000 -> sNaN
-decd518 apply #7fffffffffffffff -> sNaN999999999999999
-decd519 apply #7fffffffffffffff -> #7e00ff3fcff3fcff
-
-decd520 apply -Infinity -> #f800000000000000
-decd521 apply #f878787878787878 -> #f800000000000000
-decd522 apply #f800000000000000 -> -Infinity
-decd523 apply #f979797979797979 -> #f800000000000000
-decd524 apply #f900000000000000 -> -Infinity
-decd525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000
-decd526 apply #fa00000000000000 -> -Infinity
-decd527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000
-decd528 apply #fb00000000000000 -> -Infinity
-
-decd529 apply -NaN -> #fc00000000000000
-decd530 apply #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c
-decd531 apply #fc00000000000000 -> -NaN
-decd532 apply #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d
-decd533 apply #fd00000000000000 -> -NaN
-decd534 apply #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e
-decd535 apply #fe00000000000000 -> -sNaN
-decd536 apply #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f
-decd537 apply #ff00000000000000 -> -sNaN
-decd538 apply #ffffffffffffffff -> -sNaN999999999999999
-decd539 apply #ffffffffffffffff -> #fe00ff3fcff3fcff
-
--- diagnostic NaNs
-decd540 apply NaN -> #7c00000000000000
-decd541 apply NaN0 -> #7c00000000000000
-decd542 apply NaN1 -> #7c00000000000001
-decd543 apply NaN12 -> #7c00000000000012
-decd544 apply NaN79 -> #7c00000000000079
-decd545 apply NaN12345 -> #7c000000000049c5
-decd546 apply NaN123456 -> #7c00000000028e56
-decd547 apply NaN799799 -> #7c000000000f7fdf
-decd548 apply NaN799799799799799 -> #7c03dff7fdff7fdf
-decd549 apply NaN999999999999999 -> #7c00ff3fcff3fcff
--- too many digits
-
--- fold-down full sequence
-decd601 apply 1E+384 -> #47fc000000000000 Clamped
-decd602 apply #47fc000000000000 -> 1.000000000000000E+384
-decd603 apply 1E+383 -> #43fc800000000000 Clamped
-decd604 apply #43fc800000000000 -> 1.00000000000000E+383
-decd605 apply 1E+382 -> #43fc100000000000 Clamped
-decd606 apply #43fc100000000000 -> 1.0000000000000E+382
-decd607 apply 1E+381 -> #43fc010000000000 Clamped
-decd608 apply #43fc010000000000 -> 1.000000000000E+381
-decd609 apply 1E+380 -> #43fc002000000000 Clamped
-decd610 apply #43fc002000000000 -> 1.00000000000E+380
-decd611 apply 1E+379 -> #43fc000400000000 Clamped
-decd612 apply #43fc000400000000 -> 1.0000000000E+379
-decd613 apply 1E+378 -> #43fc000040000000 Clamped
-decd614 apply #43fc000040000000 -> 1.000000000E+378
-decd615 apply 1E+377 -> #43fc000008000000 Clamped
-decd616 apply #43fc000008000000 -> 1.00000000E+377
-decd617 apply 1E+376 -> #43fc000001000000 Clamped
-decd618 apply #43fc000001000000 -> 1.0000000E+376
-decd619 apply 1E+375 -> #43fc000000100000 Clamped
-decd620 apply #43fc000000100000 -> 1.000000E+375
-decd621 apply 1E+374 -> #43fc000000020000 Clamped
-decd622 apply #43fc000000020000 -> 1.00000E+374
-decd623 apply 1E+373 -> #43fc000000004000 Clamped
-decd624 apply #43fc000000004000 -> 1.0000E+373
-decd625 apply 1E+372 -> #43fc000000000400 Clamped
-decd626 apply #43fc000000000400 -> 1.000E+372
-decd627 apply 1E+371 -> #43fc000000000080 Clamped
-decd628 apply #43fc000000000080 -> 1.00E+371
-decd629 apply 1E+370 -> #43fc000000000010 Clamped
-decd630 apply #43fc000000000010 -> 1.0E+370
-decd631 apply 1E+369 -> #43fc000000000001
-decd632 apply #43fc000000000001 -> 1E+369
-decd633 apply 1E+368 -> #43f8000000000001
-decd634 apply #43f8000000000001 -> 1E+368
--- same with 9s
-decd641 apply 9E+384 -> #77fc000000000000 Clamped
-decd642 apply #77fc000000000000 -> 9.000000000000000E+384
-decd643 apply 9E+383 -> #43fc8c0000000000 Clamped
-decd644 apply #43fc8c0000000000 -> 9.00000000000000E+383
-decd645 apply 9E+382 -> #43fc1a0000000000 Clamped
-decd646 apply #43fc1a0000000000 -> 9.0000000000000E+382
-decd647 apply 9E+381 -> #43fc090000000000 Clamped
-decd648 apply #43fc090000000000 -> 9.000000000000E+381
-decd649 apply 9E+380 -> #43fc002300000000 Clamped
-decd650 apply #43fc002300000000 -> 9.00000000000E+380
-decd651 apply 9E+379 -> #43fc000680000000 Clamped
-decd652 apply #43fc000680000000 -> 9.0000000000E+379
-decd653 apply 9E+378 -> #43fc000240000000 Clamped
-decd654 apply #43fc000240000000 -> 9.000000000E+378
-decd655 apply 9E+377 -> #43fc000008c00000 Clamped
-decd656 apply #43fc000008c00000 -> 9.00000000E+377
-decd657 apply 9E+376 -> #43fc000001a00000 Clamped
-decd658 apply #43fc000001a00000 -> 9.0000000E+376
-decd659 apply 9E+375 -> #43fc000000900000 Clamped
-decd660 apply #43fc000000900000 -> 9.000000E+375
-decd661 apply 9E+374 -> #43fc000000023000 Clamped
-decd662 apply #43fc000000023000 -> 9.00000E+374
-decd663 apply 9E+373 -> #43fc000000006800 Clamped
-decd664 apply #43fc000000006800 -> 9.0000E+373
-decd665 apply 9E+372 -> #43fc000000002400 Clamped
-decd666 apply #43fc000000002400 -> 9.000E+372
-decd667 apply 9E+371 -> #43fc00000000008c Clamped
-decd668 apply #43fc00000000008c -> 9.00E+371
-decd669 apply 9E+370 -> #43fc00000000001a Clamped
-decd670 apply #43fc00000000001a -> 9.0E+370
-decd671 apply 9E+369 -> #43fc000000000009
-decd672 apply #43fc000000000009 -> 9E+369
-decd673 apply 9E+368 -> #43f8000000000009
-decd674 apply #43f8000000000009 -> 9E+368
-
-
--- Selected DPD codes
-decd700 apply #2238000000000000 -> 0
-decd701 apply #2238000000000009 -> 9
-decd702 apply #2238000000000010 -> 10
-decd703 apply #2238000000000019 -> 19
-decd704 apply #2238000000000020 -> 20
-decd705 apply #2238000000000029 -> 29
-decd706 apply #2238000000000030 -> 30
-decd707 apply #2238000000000039 -> 39
-decd708 apply #2238000000000040 -> 40
-decd709 apply #2238000000000049 -> 49
-decd710 apply #2238000000000050 -> 50
-decd711 apply #2238000000000059 -> 59
-decd712 apply #2238000000000060 -> 60
-decd713 apply #2238000000000069 -> 69
-decd714 apply #2238000000000070 -> 70
-decd715 apply #2238000000000071 -> 71
-decd716 apply #2238000000000072 -> 72
-decd717 apply #2238000000000073 -> 73
-decd718 apply #2238000000000074 -> 74
-decd719 apply #2238000000000075 -> 75
-decd720 apply #2238000000000076 -> 76
-decd721 apply #2238000000000077 -> 77
-decd722 apply #2238000000000078 -> 78
-decd723 apply #2238000000000079 -> 79
-
-decd725 apply #223800000000029e -> 994
-decd726 apply #223800000000029f -> 995
-decd727 apply #22380000000002a0 -> 520
-decd728 apply #22380000000002a1 -> 521
--- from telco test data
-decd730 apply #2238000000000188 -> 308
-decd731 apply #22380000000001a3 -> 323
-decd732 apply #223800000000002a -> 82
-decd733 apply #22380000000001a9 -> 329
-decd734 apply #2238000000000081 -> 101
-decd735 apply #22380000000002a2 -> 522
-
--- DPD: one of each of the huffman groups
-decd740 apply #22380000000003f7 -> 777
-decd741 apply #22380000000003f8 -> 778
-decd742 apply #22380000000003eb -> 787
-decd743 apply #223800000000037d -> 877
-decd744 apply #223800000000039f -> 997
-decd745 apply #22380000000003bf -> 979
-decd746 apply #22380000000003df -> 799
-decd747 apply #223800000000006e -> 888
-
--- DPD all-highs cases (includes the 24 redundant codes)
-decd750 apply #223800000000006e -> 888
-decd751 apply #223800000000016e -> 888
-decd752 apply #223800000000026e -> 888
-decd753 apply #223800000000036e -> 888
-decd754 apply #223800000000006f -> 889
-decd755 apply #223800000000016f -> 889
-decd756 apply #223800000000026f -> 889
-decd757 apply #223800000000036f -> 889
-
-decd760 apply #223800000000007e -> 898
-decd761 apply #223800000000017e -> 898
-decd762 apply #223800000000027e -> 898
-decd763 apply #223800000000037e -> 898
-decd764 apply #223800000000007f -> 899
-decd765 apply #223800000000017f -> 899
-decd766 apply #223800000000027f -> 899
-decd767 apply #223800000000037f -> 899
-
-decd770 apply #22380000000000ee -> 988
-decd771 apply #22380000000001ee -> 988
-decd772 apply #22380000000002ee -> 988
-decd773 apply #22380000000003ee -> 988
-decd774 apply #22380000000000ef -> 989
-decd775 apply #22380000000001ef -> 989
-decd776 apply #22380000000002ef -> 989
-decd777 apply #22380000000003ef -> 989
-
-decd780 apply #22380000000000fe -> 998
-decd781 apply #22380000000001fe -> 998
-decd782 apply #22380000000002fe -> 998
-decd783 apply #22380000000003fe -> 998
-decd784 apply #22380000000000ff -> 999
-decd785 apply #22380000000001ff -> 999
-decd786 apply #22380000000002ff -> 999
-decd787 apply #22380000000003ff -> 999
-
--- values around [u]int32 edges (zeros done earlier)
-decd800 apply -2147483646 -> #a23800008c78af46
-decd801 apply -2147483647 -> #a23800008c78af47
-decd802 apply -2147483648 -> #a23800008c78af48
-decd803 apply -2147483649 -> #a23800008c78af49
-decd804 apply 2147483646 -> #223800008c78af46
-decd805 apply 2147483647 -> #223800008c78af47
-decd806 apply 2147483648 -> #223800008c78af48
-decd807 apply 2147483649 -> #223800008c78af49
-decd808 apply 4294967294 -> #2238000115afb55a
-decd809 apply 4294967295 -> #2238000115afb55b
-decd810 apply 4294967296 -> #2238000115afb57a
-decd811 apply 4294967297 -> #2238000115afb57b
-
-decd820 apply #a23800008c78af46 -> -2147483646
-decd821 apply #a23800008c78af47 -> -2147483647
-decd822 apply #a23800008c78af48 -> -2147483648
-decd823 apply #a23800008c78af49 -> -2147483649
-decd824 apply #223800008c78af46 -> 2147483646
-decd825 apply #223800008c78af47 -> 2147483647
-decd826 apply #223800008c78af48 -> 2147483648
-decd827 apply #223800008c78af49 -> 2147483649
-decd828 apply #2238000115afb55a -> 4294967294
-decd829 apply #2238000115afb55b -> 4294967295
-decd830 apply #2238000115afb57a -> 4294967296
-decd831 apply #2238000115afb57b -> 4294967297
-
--- for narrowing
-decd840 apply #2870000000000000 -> 2.000000000000000E-99
-
--- some miscellaneous
-decd850 apply #0004070000000000 -> 7.000000000000E-385 Subnormal
-decd851 apply #0008000000020000 -> 1.00000E-391 Subnormal
-
+------------------------------------------------------------------------
+-- ddEncode.decTest -- decimal eight-byte format testcases --
+-- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+-- [Previously called decimal64.decTest]
+version: 2.59
+
+-- This set of tests is for the eight-byte concrete representation.
+-- Its characteristics are:
+--
+-- 1 bit sign
+-- 5 bits combination field
+-- 8 bits exponent continuation
+-- 50 bits coefficient continuation
+--
+-- Total exponent length 10 bits
+-- Total coefficient length 54 bits (16 digits)
+--
+-- Elimit = 767 (maximum encoded exponent)
+-- Emax = 384 (largest exponent value)
+-- Emin = -383 (smallest exponent value)
+-- bias = 398 (subtracted from encoded exponent) = -Etiny
+
+-- The testcases here have only exactly representable data on the
+-- 'left-hand-side'; rounding from strings is tested in 'base'
+-- testcase groups.
+
+extended: 1
+clamp: 1
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+-- General testcases
+-- (mostly derived from the Strawman 4 document and examples)
+dece001 apply #A2300000000003D0 -> -7.50
+dece002 apply -7.50 -> #A2300000000003D0
+-- derivative canonical plain strings
+dece003 apply #A23c0000000003D0 -> -7.50E+3
+dece004 apply -7.50E+3 -> #A23c0000000003D0
+dece005 apply #A2380000000003D0 -> -750
+dece006 apply -750 -> #A2380000000003D0
+dece007 apply #A2340000000003D0 -> -75.0
+dece008 apply -75.0 -> #A2340000000003D0
+dece009 apply #A22c0000000003D0 -> -0.750
+dece010 apply -0.750 -> #A22c0000000003D0
+dece011 apply #A2280000000003D0 -> -0.0750
+dece012 apply -0.0750 -> #A2280000000003D0
+dece013 apply #A2200000000003D0 -> -0.000750
+dece014 apply -0.000750 -> #A2200000000003D0
+dece015 apply #A2180000000003D0 -> -0.00000750
+dece016 apply -0.00000750 -> #A2180000000003D0
+dece017 apply #A2140000000003D0 -> -7.50E-7
+dece018 apply -7.50E-7 -> #A2140000000003D0
+
+-- Normality
+dece020 apply 1234567890123456 -> #263934b9c1e28e56
+dece021 apply -1234567890123456 -> #a63934b9c1e28e56
+dece022 apply 1234.567890123456 -> #260934b9c1e28e56
+dece023 apply #260934b9c1e28e56 -> 1234.567890123456
+dece024 apply 1111111111111111 -> #2638912449124491
+dece025 apply 9999999999999999 -> #6e38ff3fcff3fcff
+
+-- Nmax and similar
+dece031 apply 9999999999999999E+369 -> #77fcff3fcff3fcff
+dece032 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
+dece033 apply #77fcff3fcff3fcff -> 9.999999999999999E+384
+dece034 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56
+dece035 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384
+-- fold-downs (more below)
+dece036 apply 1.23E+384 -> #47fd300000000000 Clamped
+dece037 apply #47fd300000000000 -> 1.230000000000000E+384
+decd038 apply 1E+384 -> #47fc000000000000 Clamped
+decd039 apply #47fc000000000000 -> 1.000000000000000E+384
+
+decd051 apply 12345 -> #22380000000049c5
+decd052 apply #22380000000049c5 -> 12345
+decd053 apply 1234 -> #2238000000000534
+decd054 apply #2238000000000534 -> 1234
+decd055 apply 123 -> #22380000000000a3
+decd056 apply #22380000000000a3 -> 123
+decd057 apply 12 -> #2238000000000012
+decd058 apply #2238000000000012 -> 12
+decd059 apply 1 -> #2238000000000001
+decd060 apply #2238000000000001 -> 1
+decd061 apply 1.23 -> #22300000000000a3
+decd062 apply #22300000000000a3 -> 1.23
+decd063 apply 123.45 -> #22300000000049c5
+decd064 apply #22300000000049c5 -> 123.45
+
+-- Nmin and below
+decd071 apply 1E-383 -> #003c000000000001
+decd072 apply #003c000000000001 -> 1E-383
+decd073 apply 1.000000000000000E-383 -> #0400000000000000
+decd074 apply #0400000000000000 -> 1.000000000000000E-383
+decd075 apply 1.000000000000001E-383 -> #0400000000000001
+decd076 apply #0400000000000001 -> 1.000000000000001E-383
+
+decd077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal
+decd078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal
+decd079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal
+decd080 apply #0000000000000010 -> 1.0E-397 Subnormal
+decd081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal
+decd082 apply #0004000000000001 -> 1E-397 Subnormal
+decd083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal
+decd084 apply #0000000000000001 -> 1E-398 Subnormal
+-- next is smallest all-nines
+decd085 apply 9999999999999999E-398 -> #6400ff3fcff3fcff
+decd086 apply #6400ff3fcff3fcff -> 9.999999999999999E-383
+-- and a problematic divide result
+decd088 apply 1.111111111111111E-383 -> #0400912449124491
+decd089 apply #0400912449124491 -> 1.111111111111111E-383
+
+-- forties
+decd090 apply 40 -> #2238000000000040
+decd091 apply 39.99 -> #2230000000000cff
+
+-- underflows cannot be tested as all LHS exact
+
+-- Same again, negatives
+-- Nmax and similar
+decd122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff
+decd123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384
+decd124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56
+decd125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384
+-- fold-downs (more below)
+decd130 apply -1.23E+384 -> #c7fd300000000000 Clamped
+decd131 apply #c7fd300000000000 -> -1.230000000000000E+384
+decd132 apply -1E+384 -> #c7fc000000000000 Clamped
+decd133 apply #c7fc000000000000 -> -1.000000000000000E+384
+
+-- overflows
+decd151 apply -12345 -> #a2380000000049c5
+decd152 apply #a2380000000049c5 -> -12345
+decd153 apply -1234 -> #a238000000000534
+decd154 apply #a238000000000534 -> -1234
+decd155 apply -123 -> #a2380000000000a3
+decd156 apply #a2380000000000a3 -> -123
+decd157 apply -12 -> #a238000000000012
+decd158 apply #a238000000000012 -> -12
+decd159 apply -1 -> #a238000000000001
+decd160 apply #a238000000000001 -> -1
+decd161 apply -1.23 -> #a2300000000000a3
+decd162 apply #a2300000000000a3 -> -1.23
+decd163 apply -123.45 -> #a2300000000049c5
+decd164 apply #a2300000000049c5 -> -123.45
+
+-- Nmin and below
+decd171 apply -1E-383 -> #803c000000000001
+decd172 apply #803c000000000001 -> -1E-383
+decd173 apply -1.000000000000000E-383 -> #8400000000000000
+decd174 apply #8400000000000000 -> -1.000000000000000E-383
+decd175 apply -1.000000000000001E-383 -> #8400000000000001
+decd176 apply #8400000000000001 -> -1.000000000000001E-383
+
+decd177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal
+decd178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal
+decd179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal
+decd180 apply #8000000000000010 -> -1.0E-397 Subnormal
+decd181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal
+decd182 apply #8004000000000001 -> -1E-397 Subnormal
+decd183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal
+decd184 apply #8000000000000001 -> -1E-398 Subnormal
+-- next is smallest all-nines
+decd185 apply -9999999999999999E-398 -> #e400ff3fcff3fcff
+decd186 apply #e400ff3fcff3fcff -> -9.999999999999999E-383
+-- and a tricky subnormal
+decd187 apply 1.11111111111524E-384 -> #00009124491246a4 Subnormal
+decd188 apply #00009124491246a4 -> 1.11111111111524E-384 Subnormal
+
+-- near-underflows
+decd189 apply -1e-398 -> #8000000000000001 Subnormal
+decd190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded
+
+-- zeros
+decd401 apply 0E-500 -> #0000000000000000 Clamped
+decd402 apply 0E-400 -> #0000000000000000 Clamped
+decd403 apply 0E-398 -> #0000000000000000
+decd404 apply #0000000000000000 -> 0E-398
+decd405 apply 0.000000000000000E-383 -> #0000000000000000
+decd406 apply #0000000000000000 -> 0E-398
+decd407 apply 0E-2 -> #2230000000000000
+decd408 apply #2230000000000000 -> 0.00
+decd409 apply 0 -> #2238000000000000
+decd410 apply #2238000000000000 -> 0
+decd411 apply 0E+3 -> #2244000000000000
+decd412 apply #2244000000000000 -> 0E+3
+decd413 apply 0E+369 -> #43fc000000000000
+decd414 apply #43fc000000000000 -> 0E+369
+-- clamped zeros...
+decd415 apply 0E+370 -> #43fc000000000000 Clamped
+decd416 apply #43fc000000000000 -> 0E+369
+decd417 apply 0E+384 -> #43fc000000000000 Clamped
+decd418 apply #43fc000000000000 -> 0E+369
+decd419 apply 0E+400 -> #43fc000000000000 Clamped
+decd420 apply #43fc000000000000 -> 0E+369
+decd421 apply 0E+500 -> #43fc000000000000 Clamped
+decd422 apply #43fc000000000000 -> 0E+369
+
+-- negative zeros
+decd431 apply -0E-400 -> #8000000000000000 Clamped
+decd432 apply -0E-400 -> #8000000000000000 Clamped
+decd433 apply -0E-398 -> #8000000000000000
+decd434 apply #8000000000000000 -> -0E-398
+decd435 apply -0.000000000000000E-383 -> #8000000000000000
+decd436 apply #8000000000000000 -> -0E-398
+decd437 apply -0E-2 -> #a230000000000000
+decd438 apply #a230000000000000 -> -0.00
+decd439 apply -0 -> #a238000000000000
+decd440 apply #a238000000000000 -> -0
+decd441 apply -0E+3 -> #a244000000000000
+decd442 apply #a244000000000000 -> -0E+3
+decd443 apply -0E+369 -> #c3fc000000000000
+decd444 apply #c3fc000000000000 -> -0E+369
+-- clamped zeros...
+decd445 apply -0E+370 -> #c3fc000000000000 Clamped
+decd446 apply #c3fc000000000000 -> -0E+369
+decd447 apply -0E+384 -> #c3fc000000000000 Clamped
+decd448 apply #c3fc000000000000 -> -0E+369
+decd449 apply -0E+400 -> #c3fc000000000000 Clamped
+decd450 apply #c3fc000000000000 -> -0E+369
+decd451 apply -0E+500 -> #c3fc000000000000 Clamped
+decd452 apply #c3fc000000000000 -> -0E+369
+
+-- exponents
+decd460 apply #225c000000000007 -> 7E+9
+decd461 apply 7E+9 -> #225c000000000007
+decd462 apply #23c4000000000007 -> 7E+99
+decd463 apply 7E+99 -> #23c4000000000007
+
+-- Specials
+decd500 apply Infinity -> #7800000000000000
+decd501 apply #7878787878787878 -> #7800000000000000
+decd502 apply #7800000000000000 -> Infinity
+decd503 apply #7979797979797979 -> #7800000000000000
+decd504 apply #7900000000000000 -> Infinity
+decd505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000
+decd506 apply #7a00000000000000 -> Infinity
+decd507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000
+decd508 apply #7b00000000000000 -> Infinity
+
+decd509 apply NaN -> #7c00000000000000
+decd510 apply #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c
+decd511 apply #7c00000000000000 -> NaN
+decd512 apply #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d
+decd513 apply #7d00000000000000 -> NaN
+decd514 apply #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e
+decd515 apply #7e00000000000000 -> sNaN
+decd516 apply #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f
+decd517 apply #7f00000000000000 -> sNaN
+decd518 apply #7fffffffffffffff -> sNaN999999999999999
+decd519 apply #7fffffffffffffff -> #7e00ff3fcff3fcff
+
+decd520 apply -Infinity -> #f800000000000000
+decd521 apply #f878787878787878 -> #f800000000000000
+decd522 apply #f800000000000000 -> -Infinity
+decd523 apply #f979797979797979 -> #f800000000000000
+decd524 apply #f900000000000000 -> -Infinity
+decd525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000
+decd526 apply #fa00000000000000 -> -Infinity
+decd527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000
+decd528 apply #fb00000000000000 -> -Infinity
+
+decd529 apply -NaN -> #fc00000000000000
+decd530 apply #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c
+decd531 apply #fc00000000000000 -> -NaN
+decd532 apply #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d
+decd533 apply #fd00000000000000 -> -NaN
+decd534 apply #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e
+decd535 apply #fe00000000000000 -> -sNaN
+decd536 apply #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f
+decd537 apply #ff00000000000000 -> -sNaN
+decd538 apply #ffffffffffffffff -> -sNaN999999999999999
+decd539 apply #ffffffffffffffff -> #fe00ff3fcff3fcff
+
+-- diagnostic NaNs
+decd540 apply NaN -> #7c00000000000000
+decd541 apply NaN0 -> #7c00000000000000
+decd542 apply NaN1 -> #7c00000000000001
+decd543 apply NaN12 -> #7c00000000000012
+decd544 apply NaN79 -> #7c00000000000079
+decd545 apply NaN12345 -> #7c000000000049c5
+decd546 apply NaN123456 -> #7c00000000028e56
+decd547 apply NaN799799 -> #7c000000000f7fdf
+decd548 apply NaN799799799799799 -> #7c03dff7fdff7fdf
+decd549 apply NaN999999999999999 -> #7c00ff3fcff3fcff
+-- too many digits
+
+-- fold-down full sequence
+decd601 apply 1E+384 -> #47fc000000000000 Clamped
+decd602 apply #47fc000000000000 -> 1.000000000000000E+384
+decd603 apply 1E+383 -> #43fc800000000000 Clamped
+decd604 apply #43fc800000000000 -> 1.00000000000000E+383
+decd605 apply 1E+382 -> #43fc100000000000 Clamped
+decd606 apply #43fc100000000000 -> 1.0000000000000E+382
+decd607 apply 1E+381 -> #43fc010000000000 Clamped
+decd608 apply #43fc010000000000 -> 1.000000000000E+381
+decd609 apply 1E+380 -> #43fc002000000000 Clamped
+decd610 apply #43fc002000000000 -> 1.00000000000E+380
+decd611 apply 1E+379 -> #43fc000400000000 Clamped
+decd612 apply #43fc000400000000 -> 1.0000000000E+379
+decd613 apply 1E+378 -> #43fc000040000000 Clamped
+decd614 apply #43fc000040000000 -> 1.000000000E+378
+decd615 apply 1E+377 -> #43fc000008000000 Clamped
+decd616 apply #43fc000008000000 -> 1.00000000E+377
+decd617 apply 1E+376 -> #43fc000001000000 Clamped
+decd618 apply #43fc000001000000 -> 1.0000000E+376
+decd619 apply 1E+375 -> #43fc000000100000 Clamped
+decd620 apply #43fc000000100000 -> 1.000000E+375
+decd621 apply 1E+374 -> #43fc000000020000 Clamped
+decd622 apply #43fc000000020000 -> 1.00000E+374
+decd623 apply 1E+373 -> #43fc000000004000 Clamped
+decd624 apply #43fc000000004000 -> 1.0000E+373
+decd625 apply 1E+372 -> #43fc000000000400 Clamped
+decd626 apply #43fc000000000400 -> 1.000E+372
+decd627 apply 1E+371 -> #43fc000000000080 Clamped
+decd628 apply #43fc000000000080 -> 1.00E+371
+decd629 apply 1E+370 -> #43fc000000000010 Clamped
+decd630 apply #43fc000000000010 -> 1.0E+370
+decd631 apply 1E+369 -> #43fc000000000001
+decd632 apply #43fc000000000001 -> 1E+369
+decd633 apply 1E+368 -> #43f8000000000001
+decd634 apply #43f8000000000001 -> 1E+368
+-- same with 9s
+decd641 apply 9E+384 -> #77fc000000000000 Clamped
+decd642 apply #77fc000000000000 -> 9.000000000000000E+384
+decd643 apply 9E+383 -> #43fc8c0000000000 Clamped
+decd644 apply #43fc8c0000000000 -> 9.00000000000000E+383
+decd645 apply 9E+382 -> #43fc1a0000000000 Clamped
+decd646 apply #43fc1a0000000000 -> 9.0000000000000E+382
+decd647 apply 9E+381 -> #43fc090000000000 Clamped
+decd648 apply #43fc090000000000 -> 9.000000000000E+381
+decd649 apply 9E+380 -> #43fc002300000000 Clamped
+decd650 apply #43fc002300000000 -> 9.00000000000E+380
+decd651 apply 9E+379 -> #43fc000680000000 Clamped
+decd652 apply #43fc000680000000 -> 9.0000000000E+379
+decd653 apply 9E+378 -> #43fc000240000000 Clamped
+decd654 apply #43fc000240000000 -> 9.000000000E+378
+decd655 apply 9E+377 -> #43fc000008c00000 Clamped
+decd656 apply #43fc000008c00000 -> 9.00000000E+377
+decd657 apply 9E+376 -> #43fc000001a00000 Clamped
+decd658 apply #43fc000001a00000 -> 9.0000000E+376
+decd659 apply 9E+375 -> #43fc000000900000 Clamped
+decd660 apply #43fc000000900000 -> 9.000000E+375
+decd661 apply 9E+374 -> #43fc000000023000 Clamped
+decd662 apply #43fc000000023000 -> 9.00000E+374
+decd663 apply 9E+373 -> #43fc000000006800 Clamped
+decd664 apply #43fc000000006800 -> 9.0000E+373
+decd665 apply 9E+372 -> #43fc000000002400 Clamped
+decd666 apply #43fc000000002400 -> 9.000E+372
+decd667 apply 9E+371 -> #43fc00000000008c Clamped
+decd668 apply #43fc00000000008c -> 9.00E+371
+decd669 apply 9E+370 -> #43fc00000000001a Clamped
+decd670 apply #43fc00000000001a -> 9.0E+370
+decd671 apply 9E+369 -> #43fc000000000009
+decd672 apply #43fc000000000009 -> 9E+369
+decd673 apply 9E+368 -> #43f8000000000009
+decd674 apply #43f8000000000009 -> 9E+368
+
+
+-- Selected DPD codes
+decd700 apply #2238000000000000 -> 0
+decd701 apply #2238000000000009 -> 9
+decd702 apply #2238000000000010 -> 10
+decd703 apply #2238000000000019 -> 19
+decd704 apply #2238000000000020 -> 20
+decd705 apply #2238000000000029 -> 29
+decd706 apply #2238000000000030 -> 30
+decd707 apply #2238000000000039 -> 39
+decd708 apply #2238000000000040 -> 40
+decd709 apply #2238000000000049 -> 49
+decd710 apply #2238000000000050 -> 50
+decd711 apply #2238000000000059 -> 59
+decd712 apply #2238000000000060 -> 60
+decd713 apply #2238000000000069 -> 69
+decd714 apply #2238000000000070 -> 70
+decd715 apply #2238000000000071 -> 71
+decd716 apply #2238000000000072 -> 72
+decd717 apply #2238000000000073 -> 73
+decd718 apply #2238000000000074 -> 74
+decd719 apply #2238000000000075 -> 75
+decd720 apply #2238000000000076 -> 76
+decd721 apply #2238000000000077 -> 77
+decd722 apply #2238000000000078 -> 78
+decd723 apply #2238000000000079 -> 79
+
+decd725 apply #223800000000029e -> 994
+decd726 apply #223800000000029f -> 995
+decd727 apply #22380000000002a0 -> 520
+decd728 apply #22380000000002a1 -> 521
+-- from telco test data
+decd730 apply #2238000000000188 -> 308
+decd731 apply #22380000000001a3 -> 323
+decd732 apply #223800000000002a -> 82
+decd733 apply #22380000000001a9 -> 329
+decd734 apply #2238000000000081 -> 101
+decd735 apply #22380000000002a2 -> 522
+
+-- DPD: one of each of the huffman groups
+decd740 apply #22380000000003f7 -> 777
+decd741 apply #22380000000003f8 -> 778
+decd742 apply #22380000000003eb -> 787
+decd743 apply #223800000000037d -> 877
+decd744 apply #223800000000039f -> 997
+decd745 apply #22380000000003bf -> 979
+decd746 apply #22380000000003df -> 799
+decd747 apply #223800000000006e -> 888
+
+-- DPD all-highs cases (includes the 24 redundant codes)
+decd750 apply #223800000000006e -> 888
+decd751 apply #223800000000016e -> 888
+decd752 apply #223800000000026e -> 888
+decd753 apply #223800000000036e -> 888
+decd754 apply #223800000000006f -> 889
+decd755 apply #223800000000016f -> 889
+decd756 apply #223800000000026f -> 889
+decd757 apply #223800000000036f -> 889
+
+decd760 apply #223800000000007e -> 898
+decd761 apply #223800000000017e -> 898
+decd762 apply #223800000000027e -> 898
+decd763 apply #223800000000037e -> 898
+decd764 apply #223800000000007f -> 899
+decd765 apply #223800000000017f -> 899
+decd766 apply #223800000000027f -> 899
+decd767 apply #223800000000037f -> 899
+
+decd770 apply #22380000000000ee -> 988
+decd771 apply #22380000000001ee -> 988
+decd772 apply #22380000000002ee -> 988
+decd773 apply #22380000000003ee -> 988
+decd774 apply #22380000000000ef -> 989
+decd775 apply #22380000000001ef -> 989
+decd776 apply #22380000000002ef -> 989
+decd777 apply #22380000000003ef -> 989
+
+decd780 apply #22380000000000fe -> 998
+decd781 apply #22380000000001fe -> 998
+decd782 apply #22380000000002fe -> 998
+decd783 apply #22380000000003fe -> 998
+decd784 apply #22380000000000ff -> 999
+decd785 apply #22380000000001ff -> 999
+decd786 apply #22380000000002ff -> 999
+decd787 apply #22380000000003ff -> 999
+
+-- values around [u]int32 edges (zeros done earlier)
+decd800 apply -2147483646 -> #a23800008c78af46
+decd801 apply -2147483647 -> #a23800008c78af47
+decd802 apply -2147483648 -> #a23800008c78af48
+decd803 apply -2147483649 -> #a23800008c78af49
+decd804 apply 2147483646 -> #223800008c78af46
+decd805 apply 2147483647 -> #223800008c78af47
+decd806 apply 2147483648 -> #223800008c78af48
+decd807 apply 2147483649 -> #223800008c78af49
+decd808 apply 4294967294 -> #2238000115afb55a
+decd809 apply 4294967295 -> #2238000115afb55b
+decd810 apply 4294967296 -> #2238000115afb57a
+decd811 apply 4294967297 -> #2238000115afb57b
+
+decd820 apply #a23800008c78af46 -> -2147483646
+decd821 apply #a23800008c78af47 -> -2147483647
+decd822 apply #a23800008c78af48 -> -2147483648
+decd823 apply #a23800008c78af49 -> -2147483649
+decd824 apply #223800008c78af46 -> 2147483646
+decd825 apply #223800008c78af47 -> 2147483647
+decd826 apply #223800008c78af48 -> 2147483648
+decd827 apply #223800008c78af49 -> 2147483649
+decd828 apply #2238000115afb55a -> 4294967294
+decd829 apply #2238000115afb55b -> 4294967295
+decd830 apply #2238000115afb57a -> 4294967296
+decd831 apply #2238000115afb57b -> 4294967297
+
+-- for narrowing
+decd840 apply #2870000000000000 -> 2.000000000000000E-99
+
+-- some miscellaneous
+decd850 apply #0004070000000000 -> 7.000000000000E-385 Subnormal
+decd851 apply #0008000000020000 -> 1.00000E-391 Subnormal
+
diff --git a/Lib/test/decimaltestdata/ddFMA.decTest b/Lib/test/decimaltestdata/ddFMA.decTest
index 8ae92a7f9a..f0acfc74d5 100644
--- a/Lib/test/decimaltestdata/ddFMA.decTest
+++ b/Lib/test/decimaltestdata/ddFMA.decTest
@@ -1,1698 +1,1698 @@
-------------------------------------------------------------------------
--- ddFMA.decTest -- decDouble Fused Multiply Add --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- These tests comprese three parts:
--- 1. Sanity checks and other three-operand tests (especially those
--- where the fused operation makes a difference)
--- 2. Multiply tests (third operand is neutral zero [0E+emax])
--- 3. Addition tests (first operand is 1)
--- The multiply and addition tests are extensive because FMA may have
--- its own dedicated multiplication or addition routine(s), and they
--- also inherently check the left-to-right properties.
-
--- Sanity checks
-ddfma0001 fma 1 1 1 -> 2
-ddfma0002 fma 1 1 2 -> 3
-ddfma0003 fma 2 2 3 -> 7
-ddfma0004 fma 9 9 9 -> 90
-ddfma0005 fma -1 1 1 -> 0
-ddfma0006 fma -1 1 2 -> 1
-ddfma0007 fma -2 2 3 -> -1
-ddfma0008 fma -9 9 9 -> -72
-ddfma0011 fma 1 -1 1 -> 0
-ddfma0012 fma 1 -1 2 -> 1
-ddfma0013 fma 2 -2 3 -> -1
-ddfma0014 fma 9 -9 9 -> -72
-ddfma0015 fma 1 1 -1 -> 0
-ddfma0016 fma 1 1 -2 -> -1
-ddfma0017 fma 2 2 -3 -> 1
-ddfma0018 fma 9 9 -9 -> 72
-
--- non-integer exacts
-ddfma0100 fma 25.2 63.6 -438 -> 1164.72
-ddfma0101 fma 0.301 0.380 334 -> 334.114380
-ddfma0102 fma 49.2 -4.8 23.3 -> -212.86
-ddfma0103 fma 4.22 0.079 -94.6 -> -94.26662
-ddfma0104 fma 903 0.797 0.887 -> 720.578
-ddfma0105 fma 6.13 -161 65.9 -> -921.03
-ddfma0106 fma 28.2 727 5.45 -> 20506.85
-ddfma0107 fma 4 605 688 -> 3108
-ddfma0108 fma 93.3 0.19 0.226 -> 17.953
-ddfma0109 fma 0.169 -341 5.61 -> -52.019
-ddfma0110 fma -72.2 30 -51.2 -> -2217.2
-ddfma0111 fma -0.409 13 20.4 -> 15.083
-ddfma0112 fma 317 77.0 19.0 -> 24428.0
-ddfma0113 fma 47 6.58 1.62 -> 310.88
-ddfma0114 fma 1.36 0.984 0.493 -> 1.83124
-ddfma0115 fma 72.7 274 1.56 -> 19921.36
-ddfma0116 fma 335 847 83 -> 283828
-ddfma0117 fma 666 0.247 25.4 -> 189.902
-ddfma0118 fma -3.87 3.06 78.0 -> 66.1578
-ddfma0119 fma 0.742 192 35.6 -> 178.064
-ddfma0120 fma -91.6 5.29 0.153 -> -484.411
-
--- cases where result is different from separate multiply + add; each
--- is preceded by the result of unfused multiply and add
--- [this is about 20% of all similar cases in general]
--- -> 7.123356429257969E+16
-ddfma0201 fma 27583489.6645 2582471078.04 2593183.42371 -> 7.123356429257970E+16 Inexact Rounded
--- -> 22813275328.80506
-ddfma0208 fma 24280.355566 939577.397653 2032.013252 -> 22813275328.80507 Inexact Rounded
--- -> -2.030397734278062E+16
-ddfma0209 fma 7848976432 -2586831.2281 137903.517909 -> -2.030397734278061E+16 Inexact Rounded
--- -> 2040774094814.077
-ddfma0217 fma 56890.388731 35872030.4255 339337.123410 -> 2040774094814.078 Inexact Rounded
--- -> 2.714469575205049E+18
-ddfma0220 fma 7533543.57445 360317763928 5073392.31638 -> 2.714469575205050E+18 Inexact Rounded
--- -> 1.011676297716716E+19
-ddfma0223 fma 739945255.563 13672312784.1 -994381.53572 -> 1.011676297716715E+19 Inexact Rounded
--- -> -2.914135721455315E+23
-ddfma0224 fma -413510957218 704729988550 9234162614.0 -> -2.914135721455314E+23 Inexact Rounded
--- -> 2.620119863365786E+17
-ddfma0226 fma 437484.00601 598906432790 894450638.442 -> 2.620119863365787E+17 Inexact Rounded
--- -> 1.272647995808178E+19
-ddfma0253 fma 73287556929 173651305.784 -358312568.389 -> 1.272647995808177E+19 Inexact Rounded
--- -> -1.753769320861851E+18
-ddfma0257 fma 203258304486 -8628278.8066 153127.446727 -> -1.753769320861850E+18 Inexact Rounded
--- -> -1.550737835263346E+17
-ddfma0260 fma 42560533.1774 -3643605282.86 178277.96377 -> -1.550737835263347E+17 Inexact Rounded
--- -> 2.897624620576005E+22
-ddfma0269 fma 142656587375 203118879670 604576103991 -> 2.897624620576004E+22 Inexact Rounded
-
--- Cases where multiply would overflow or underflow if separate
-fma0300 fma 9e+384 10 0 -> Infinity Overflow Inexact Rounded
-fma0301 fma 1e+384 10 0 -> Infinity Overflow Inexact Rounded
-fma0302 fma 1e+384 10 -1e+384 -> 9.000000000000000E+384 Clamped
-fma0303 fma 1e+384 10 -9e+384 -> 1.000000000000000E+384 Clamped
--- subnormal etc.
-fma0305 fma 1e-398 0.1 0 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-fma0306 fma 1e-398 0.1 1 -> 1.000000000000000 Inexact Rounded
-fma0307 fma 1e-398 0.1 1e-398 -> 1E-398 Underflow Subnormal Inexact Rounded
-
--- Infinite combinations
-ddfma0800 fma Inf Inf Inf -> Infinity
-ddfma0801 fma Inf Inf -Inf -> NaN Invalid_operation
-ddfma0802 fma Inf -Inf Inf -> NaN Invalid_operation
-ddfma0803 fma Inf -Inf -Inf -> -Infinity
-ddfma0804 fma -Inf Inf Inf -> NaN Invalid_operation
-ddfma0805 fma -Inf Inf -Inf -> -Infinity
-ddfma0806 fma -Inf -Inf Inf -> Infinity
-ddfma0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
-
--- Triple NaN propagation
-ddfma0900 fma NaN2 NaN3 NaN5 -> NaN2
-ddfma0901 fma 0 NaN3 NaN5 -> NaN3
-ddfma0902 fma 0 0 NaN5 -> NaN5
--- first sNaN wins (consider qNaN from earlier sNaN being
--- overridden by an sNaN in third operand)
-ddfma0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-ddfma0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
-ddfma0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
-ddfma0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-ddfma0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
-ddfma0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
-
--- MULTIPLICATION TESTS ------------------------------------------------
-
--- sanity checks
-ddfma2000 fma 2 2 0e+384 -> 4
-ddfma2001 fma 2 3 0e+384 -> 6
-ddfma2002 fma 5 1 0e+384 -> 5
-ddfma2003 fma 5 2 0e+384 -> 10
-ddfma2004 fma 1.20 2 0e+384 -> 2.40
-ddfma2005 fma 1.20 0 0e+384 -> 0.00
-ddfma2006 fma 1.20 -2 0e+384 -> -2.40
-ddfma2007 fma -1.20 2 0e+384 -> -2.40
-ddfma2008 fma -1.20 0 0e+384 -> 0.00
-ddfma2009 fma -1.20 -2 0e+384 -> 2.40
-ddfma2010 fma 5.09 7.1 0e+384 -> 36.139
-ddfma2011 fma 2.5 4 0e+384 -> 10.0
-ddfma2012 fma 2.50 4 0e+384 -> 10.00
-ddfma2013 fma 1.23456789 1.00000000 0e+384 -> 1.234567890000000 Rounded
-ddfma2015 fma 2.50 4 0e+384 -> 10.00
-ddfma2016 fma 9.999999999 9.999999999 0e+384 -> 99.99999998000000 Inexact Rounded
-ddfma2017 fma 9.999999999 -9.999999999 0e+384 -> -99.99999998000000 Inexact Rounded
-ddfma2018 fma -9.999999999 9.999999999 0e+384 -> -99.99999998000000 Inexact Rounded
-ddfma2019 fma -9.999999999 -9.999999999 0e+384 -> 99.99999998000000 Inexact Rounded
-
--- zeros, etc.
-ddfma2021 fma 0 0 0e+384 -> 0
-ddfma2022 fma 0 -0 0e+384 -> 0
-ddfma2023 fma -0 0 0e+384 -> 0
-ddfma2024 fma -0 -0 0e+384 -> 0
-ddfma2025 fma -0.0 -0.0 0e+384 -> 0.00
-ddfma2026 fma -0.0 -0.0 0e+384 -> 0.00
-ddfma2027 fma -0.0 -0.0 0e+384 -> 0.00
-ddfma2028 fma -0.0 -0.0 0e+384 -> 0.00
-ddfma2030 fma 5.00 1E-3 0e+384 -> 0.00500
-ddfma2031 fma 00.00 0.000 0e+384 -> 0.00000
-ddfma2032 fma 00.00 0E-3 0e+384 -> 0.00000 -- rhs is 0
-ddfma2033 fma 0E-3 00.00 0e+384 -> 0.00000 -- lhs is 0
-ddfma2034 fma -5.00 1E-3 0e+384 -> -0.00500
-ddfma2035 fma -00.00 0.000 0e+384 -> 0.00000
-ddfma2036 fma -00.00 0E-3 0e+384 -> 0.00000 -- rhs is 0
-ddfma2037 fma -0E-3 00.00 0e+384 -> 0.00000 -- lhs is 0
-ddfma2038 fma 5.00 -1E-3 0e+384 -> -0.00500
-ddfma2039 fma 00.00 -0.000 0e+384 -> 0.00000
-ddfma2040 fma 00.00 -0E-3 0e+384 -> 0.00000 -- rhs is 0
-ddfma2041 fma 0E-3 -00.00 0e+384 -> 0.00000 -- lhs is 0
-ddfma2042 fma -5.00 -1E-3 0e+384 -> 0.00500
-ddfma2043 fma -00.00 -0.000 0e+384 -> 0.00000
-ddfma2044 fma -00.00 -0E-3 0e+384 -> 0.00000 -- rhs is 0
-ddfma2045 fma -0E-3 -00.00 -0e+384 -> 0.00000 -- lhs is 0
-ddfma2046 fma -0E-3 00.00 -0e+384 -> -0.00000
-ddfma2047 fma 0E-3 -00.00 -0e+384 -> -0.00000
-ddfma2048 fma 0E-3 00.00 -0e+384 -> 0.00000
-
--- examples from decarith
-ddfma2050 fma 1.20 3 0e+384 -> 3.60
-ddfma2051 fma 7 3 0e+384 -> 21
-ddfma2052 fma 0.9 0.8 0e+384 -> 0.72
-ddfma2053 fma 0.9 -0 0e+384 -> 0.0
-ddfma2054 fma 654321 654321 0e+384 -> 428135971041
-
-ddfma2060 fma 123.45 1e7 0e+384 -> 1.2345E+9
-ddfma2061 fma 123.45 1e8 0e+384 -> 1.2345E+10
-ddfma2062 fma 123.45 1e+9 0e+384 -> 1.2345E+11
-ddfma2063 fma 123.45 1e10 0e+384 -> 1.2345E+12
-ddfma2064 fma 123.45 1e11 0e+384 -> 1.2345E+13
-ddfma2065 fma 123.45 1e12 0e+384 -> 1.2345E+14
-ddfma2066 fma 123.45 1e13 0e+384 -> 1.2345E+15
-
-
--- test some intermediate lengths
--- 1234567890123456
-ddfma2080 fma 0.1 1230123456456789 0e+384 -> 123012345645678.9
-ddfma2084 fma 0.1 1230123456456789 0e+384 -> 123012345645678.9
-ddfma2090 fma 1230123456456789 0.1 0e+384 -> 123012345645678.9
-ddfma2094 fma 1230123456456789 0.1 0e+384 -> 123012345645678.9
-
--- test some more edge cases and carries
-ddfma2101 fma 9 9 0e+384 -> 81
-ddfma2102 fma 9 90 0e+384 -> 810
-ddfma2103 fma 9 900 0e+384 -> 8100
-ddfma2104 fma 9 9000 0e+384 -> 81000
-ddfma2105 fma 9 90000 0e+384 -> 810000
-ddfma2106 fma 9 900000 0e+384 -> 8100000
-ddfma2107 fma 9 9000000 0e+384 -> 81000000
-ddfma2108 fma 9 90000000 0e+384 -> 810000000
-ddfma2109 fma 9 900000000 0e+384 -> 8100000000
-ddfma2110 fma 9 9000000000 0e+384 -> 81000000000
-ddfma2111 fma 9 90000000000 0e+384 -> 810000000000
-ddfma2112 fma 9 900000000000 0e+384 -> 8100000000000
-ddfma2113 fma 9 9000000000000 0e+384 -> 81000000000000
-ddfma2114 fma 9 90000000000000 0e+384 -> 810000000000000
-ddfma2115 fma 9 900000000000000 0e+384 -> 8100000000000000
---ddfma2116 fma 9 9000000000000000 0e+384 -> 81000000000000000
---ddfma2117 fma 9 90000000000000000 0e+384 -> 810000000000000000
---ddfma2118 fma 9 900000000000000000 0e+384 -> 8100000000000000000
---ddfma2119 fma 9 9000000000000000000 0e+384 -> 81000000000000000000
---ddfma2120 fma 9 90000000000000000000 0e+384 -> 810000000000000000000
---ddfma2121 fma 9 900000000000000000000 0e+384 -> 8100000000000000000000
---ddfma2122 fma 9 9000000000000000000000 0e+384 -> 81000000000000000000000
---ddfma2123 fma 9 90000000000000000000000 0e+384 -> 810000000000000000000000
--- test some more edge cases without carries
-ddfma2131 fma 3 3 0e+384 -> 9
-ddfma2132 fma 3 30 0e+384 -> 90
-ddfma2133 fma 3 300 0e+384 -> 900
-ddfma2134 fma 3 3000 0e+384 -> 9000
-ddfma2135 fma 3 30000 0e+384 -> 90000
-ddfma2136 fma 3 300000 0e+384 -> 900000
-ddfma2137 fma 3 3000000 0e+384 -> 9000000
-ddfma2138 fma 3 30000000 0e+384 -> 90000000
-ddfma2139 fma 3 300000000 0e+384 -> 900000000
-ddfma2140 fma 3 3000000000 0e+384 -> 9000000000
-ddfma2141 fma 3 30000000000 0e+384 -> 90000000000
-ddfma2142 fma 3 300000000000 0e+384 -> 900000000000
-ddfma2143 fma 3 3000000000000 0e+384 -> 9000000000000
-ddfma2144 fma 3 30000000000000 0e+384 -> 90000000000000
-ddfma2145 fma 3 300000000000000 0e+384 -> 900000000000000
-
--- test some edge cases with exact rounding
-ddfma2301 fma 9 9 0e+384 -> 81
-ddfma2302 fma 9 90 0e+384 -> 810
-ddfma2303 fma 9 900 0e+384 -> 8100
-ddfma2304 fma 9 9000 0e+384 -> 81000
-ddfma2305 fma 9 90000 0e+384 -> 810000
-ddfma2306 fma 9 900000 0e+384 -> 8100000
-ddfma2307 fma 9 9000000 0e+384 -> 81000000
-ddfma2308 fma 9 90000000 0e+384 -> 810000000
-ddfma2309 fma 9 900000000 0e+384 -> 8100000000
-ddfma2310 fma 9 9000000000 0e+384 -> 81000000000
-ddfma2311 fma 9 90000000000 0e+384 -> 810000000000
-ddfma2312 fma 9 900000000000 0e+384 -> 8100000000000
-ddfma2313 fma 9 9000000000000 0e+384 -> 81000000000000
-ddfma2314 fma 9 90000000000000 0e+384 -> 810000000000000
-ddfma2315 fma 9 900000000000000 0e+384 -> 8100000000000000
-ddfma2316 fma 9 9000000000000000 0e+384 -> 8.100000000000000E+16 Rounded
-ddfma2317 fma 90 9000000000000000 0e+384 -> 8.100000000000000E+17 Rounded
-ddfma2318 fma 900 9000000000000000 0e+384 -> 8.100000000000000E+18 Rounded
-ddfma2319 fma 9000 9000000000000000 0e+384 -> 8.100000000000000E+19 Rounded
-ddfma2320 fma 90000 9000000000000000 0e+384 -> 8.100000000000000E+20 Rounded
-ddfma2321 fma 900000 9000000000000000 0e+384 -> 8.100000000000000E+21 Rounded
-ddfma2322 fma 9000000 9000000000000000 0e+384 -> 8.100000000000000E+22 Rounded
-ddfma2323 fma 90000000 9000000000000000 0e+384 -> 8.100000000000000E+23 Rounded
-
--- tryzeros cases
-ddfma2504 fma 0E-260 1000E-260 0e+384 -> 0E-398 Clamped
-ddfma2505 fma 100E+260 0E+260 0e+384 -> 0E+369 Clamped
-
--- mixed with zeros
-ddfma2541 fma 0 -1 0e+384 -> 0
-ddfma2542 fma -0 -1 0e+384 -> 0
-ddfma2543 fma 0 1 0e+384 -> 0
-ddfma2544 fma -0 1 0e+384 -> 0
-ddfma2545 fma -1 0 0e+384 -> 0
-ddfma2546 fma -1 -0 0e+384 -> 0
-ddfma2547 fma 1 0 0e+384 -> 0
-ddfma2548 fma 1 -0 0e+384 -> 0
-
-ddfma2551 fma 0.0 -1 0e+384 -> 0.0
-ddfma2552 fma -0.0 -1 0e+384 -> 0.0
-ddfma2553 fma 0.0 1 0e+384 -> 0.0
-ddfma2554 fma -0.0 1 0e+384 -> 0.0
-ddfma2555 fma -1.0 0 0e+384 -> 0.0
-ddfma2556 fma -1.0 -0 0e+384 -> 0.0
-ddfma2557 fma 1.0 0 0e+384 -> 0.0
-ddfma2558 fma 1.0 -0 0e+384 -> 0.0
-
-ddfma2561 fma 0 -1.0 0e+384 -> 0.0
-ddfma2562 fma -0 -1.0 0e+384 -> 0.0
-ddfma2563 fma 0 1.0 0e+384 -> 0.0
-ddfma2564 fma -0 1.0 0e+384 -> 0.0
-ddfma2565 fma -1 0.0 0e+384 -> 0.0
-ddfma2566 fma -1 -0.0 0e+384 -> 0.0
-ddfma2567 fma 1 0.0 0e+384 -> 0.0
-ddfma2568 fma 1 -0.0 0e+384 -> 0.0
-
-ddfma2571 fma 0.0 -1.0 0e+384 -> 0.00
-ddfma2572 fma -0.0 -1.0 0e+384 -> 0.00
-ddfma2573 fma 0.0 1.0 0e+384 -> 0.00
-ddfma2574 fma -0.0 1.0 0e+384 -> 0.00
-ddfma2575 fma -1.0 0.0 0e+384 -> 0.00
-ddfma2576 fma -1.0 -0.0 0e+384 -> 0.00
-ddfma2577 fma 1.0 0.0 0e+384 -> 0.00
-ddfma2578 fma 1.0 -0.0 0e+384 -> 0.00
-
--- Specials
-ddfma2580 fma Inf -Inf 0e+384 -> -Infinity
-ddfma2581 fma Inf -1000 0e+384 -> -Infinity
-ddfma2582 fma Inf -1 0e+384 -> -Infinity
-ddfma2583 fma Inf -0 0e+384 -> NaN Invalid_operation
-ddfma2584 fma Inf 0 0e+384 -> NaN Invalid_operation
-ddfma2585 fma Inf 1 0e+384 -> Infinity
-ddfma2586 fma Inf 1000 0e+384 -> Infinity
-ddfma2587 fma Inf Inf 0e+384 -> Infinity
-ddfma2588 fma -1000 Inf 0e+384 -> -Infinity
-ddfma2589 fma -Inf Inf 0e+384 -> -Infinity
-ddfma2590 fma -1 Inf 0e+384 -> -Infinity
-ddfma2591 fma -0 Inf 0e+384 -> NaN Invalid_operation
-ddfma2592 fma 0 Inf 0e+384 -> NaN Invalid_operation
-ddfma2593 fma 1 Inf 0e+384 -> Infinity
-ddfma2594 fma 1000 Inf 0e+384 -> Infinity
-ddfma2595 fma Inf Inf 0e+384 -> Infinity
-
-ddfma2600 fma -Inf -Inf 0e+384 -> Infinity
-ddfma2601 fma -Inf -1000 0e+384 -> Infinity
-ddfma2602 fma -Inf -1 0e+384 -> Infinity
-ddfma2603 fma -Inf -0 0e+384 -> NaN Invalid_operation
-ddfma2604 fma -Inf 0 0e+384 -> NaN Invalid_operation
-ddfma2605 fma -Inf 1 0e+384 -> -Infinity
-ddfma2606 fma -Inf 1000 0e+384 -> -Infinity
-ddfma2607 fma -Inf Inf 0e+384 -> -Infinity
-ddfma2608 fma -1000 Inf 0e+384 -> -Infinity
-ddfma2609 fma -Inf -Inf 0e+384 -> Infinity
-ddfma2610 fma -1 -Inf 0e+384 -> Infinity
-ddfma2611 fma -0 -Inf 0e+384 -> NaN Invalid_operation
-ddfma2612 fma 0 -Inf 0e+384 -> NaN Invalid_operation
-ddfma2613 fma 1 -Inf 0e+384 -> -Infinity
-ddfma2614 fma 1000 -Inf 0e+384 -> -Infinity
-ddfma2615 fma Inf -Inf 0e+384 -> -Infinity
-
-ddfma2621 fma NaN -Inf 0e+384 -> NaN
-ddfma2622 fma NaN -1000 0e+384 -> NaN
-ddfma2623 fma NaN -1 0e+384 -> NaN
-ddfma2624 fma NaN -0 0e+384 -> NaN
-ddfma2625 fma NaN 0 0e+384 -> NaN
-ddfma2626 fma NaN 1 0e+384 -> NaN
-ddfma2627 fma NaN 1000 0e+384 -> NaN
-ddfma2628 fma NaN Inf 0e+384 -> NaN
-ddfma2629 fma NaN NaN 0e+384 -> NaN
-ddfma2630 fma -Inf NaN 0e+384 -> NaN
-ddfma2631 fma -1000 NaN 0e+384 -> NaN
-ddfma2632 fma -1 NaN 0e+384 -> NaN
-ddfma2633 fma -0 NaN 0e+384 -> NaN
-ddfma2634 fma 0 NaN 0e+384 -> NaN
-ddfma2635 fma 1 NaN 0e+384 -> NaN
-ddfma2636 fma 1000 NaN 0e+384 -> NaN
-ddfma2637 fma Inf NaN 0e+384 -> NaN
-
-ddfma2641 fma sNaN -Inf 0e+384 -> NaN Invalid_operation
-ddfma2642 fma sNaN -1000 0e+384 -> NaN Invalid_operation
-ddfma2643 fma sNaN -1 0e+384 -> NaN Invalid_operation
-ddfma2644 fma sNaN -0 0e+384 -> NaN Invalid_operation
-ddfma2645 fma sNaN 0 0e+384 -> NaN Invalid_operation
-ddfma2646 fma sNaN 1 0e+384 -> NaN Invalid_operation
-ddfma2647 fma sNaN 1000 0e+384 -> NaN Invalid_operation
-ddfma2648 fma sNaN NaN 0e+384 -> NaN Invalid_operation
-ddfma2649 fma sNaN sNaN 0e+384 -> NaN Invalid_operation
-ddfma2650 fma NaN sNaN 0e+384 -> NaN Invalid_operation
-ddfma2651 fma -Inf sNaN 0e+384 -> NaN Invalid_operation
-ddfma2652 fma -1000 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2653 fma -1 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2654 fma -0 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2655 fma 0 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2656 fma 1 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2657 fma 1000 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2658 fma Inf sNaN 0e+384 -> NaN Invalid_operation
-ddfma2659 fma NaN sNaN 0e+384 -> NaN Invalid_operation
-
--- propagating NaNs
-ddfma2661 fma NaN9 -Inf 0e+384 -> NaN9
-ddfma2662 fma NaN8 999 0e+384 -> NaN8
-ddfma2663 fma NaN71 Inf 0e+384 -> NaN71
-ddfma2664 fma NaN6 NaN5 0e+384 -> NaN6
-ddfma2665 fma -Inf NaN4 0e+384 -> NaN4
-ddfma2666 fma -999 NaN33 0e+384 -> NaN33
-ddfma2667 fma Inf NaN2 0e+384 -> NaN2
-
-ddfma2671 fma sNaN99 -Inf 0e+384 -> NaN99 Invalid_operation
-ddfma2672 fma sNaN98 -11 0e+384 -> NaN98 Invalid_operation
-ddfma2673 fma sNaN97 NaN 0e+384 -> NaN97 Invalid_operation
-ddfma2674 fma sNaN16 sNaN94 0e+384 -> NaN16 Invalid_operation
-ddfma2675 fma NaN95 sNaN93 0e+384 -> NaN93 Invalid_operation
-ddfma2676 fma -Inf sNaN92 0e+384 -> NaN92 Invalid_operation
-ddfma2677 fma 088 sNaN91 0e+384 -> NaN91 Invalid_operation
-ddfma2678 fma Inf sNaN90 0e+384 -> NaN90 Invalid_operation
-ddfma2679 fma NaN sNaN89 0e+384 -> NaN89 Invalid_operation
-
-ddfma2681 fma -NaN9 -Inf 0e+384 -> -NaN9
-ddfma2682 fma -NaN8 999 0e+384 -> -NaN8
-ddfma2683 fma -NaN71 Inf 0e+384 -> -NaN71
-ddfma2684 fma -NaN6 -NaN5 0e+384 -> -NaN6
-ddfma2685 fma -Inf -NaN4 0e+384 -> -NaN4
-ddfma2686 fma -999 -NaN33 0e+384 -> -NaN33
-ddfma2687 fma Inf -NaN2 0e+384 -> -NaN2
-
-ddfma2691 fma -sNaN99 -Inf 0e+384 -> -NaN99 Invalid_operation
-ddfma2692 fma -sNaN98 -11 0e+384 -> -NaN98 Invalid_operation
-ddfma2693 fma -sNaN97 NaN 0e+384 -> -NaN97 Invalid_operation
-ddfma2694 fma -sNaN16 -sNaN94 0e+384 -> -NaN16 Invalid_operation
-ddfma2695 fma -NaN95 -sNaN93 0e+384 -> -NaN93 Invalid_operation
-ddfma2696 fma -Inf -sNaN92 0e+384 -> -NaN92 Invalid_operation
-ddfma2697 fma 088 -sNaN91 0e+384 -> -NaN91 Invalid_operation
-ddfma2698 fma Inf -sNaN90 0e+384 -> -NaN90 Invalid_operation
-ddfma2699 fma -NaN -sNaN89 0e+384 -> -NaN89 Invalid_operation
-
-ddfma2701 fma -NaN -Inf 0e+384 -> -NaN
-ddfma2702 fma -NaN 999 0e+384 -> -NaN
-ddfma2703 fma -NaN Inf 0e+384 -> -NaN
-ddfma2704 fma -NaN -NaN 0e+384 -> -NaN
-ddfma2705 fma -Inf -NaN0 0e+384 -> -NaN
-ddfma2706 fma -999 -NaN 0e+384 -> -NaN
-ddfma2707 fma Inf -NaN 0e+384 -> -NaN
-
-ddfma2711 fma -sNaN -Inf 0e+384 -> -NaN Invalid_operation
-ddfma2712 fma -sNaN -11 0e+384 -> -NaN Invalid_operation
-ddfma2713 fma -sNaN00 NaN 0e+384 -> -NaN Invalid_operation
-ddfma2714 fma -sNaN -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2715 fma -NaN -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2716 fma -Inf -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2717 fma 088 -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2718 fma Inf -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2719 fma -NaN -sNaN 0e+384 -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
--- signs
-ddfma2751 fma 1e+277 1e+311 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2752 fma 1e+277 -1e+311 0e+384 -> -Infinity Overflow Inexact Rounded
-ddfma2753 fma -1e+277 1e+311 0e+384 -> -Infinity Overflow Inexact Rounded
-ddfma2754 fma -1e+277 -1e+311 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2755 fma 1e-277 1e-311 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2756 fma 1e-277 -1e-311 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2757 fma -1e-277 1e-311 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2758 fma -1e-277 -1e-311 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-ddfma2760 fma 1e-291 1e-101 0e+384 -> 1E-392 Subnormal
-ddfma2761 fma 1e-291 1e-102 0e+384 -> 1E-393 Subnormal
-ddfma2762 fma 1e-291 1e-103 0e+384 -> 1E-394 Subnormal
-ddfma2763 fma 1e-291 1e-104 0e+384 -> 1E-395 Subnormal
-ddfma2764 fma 1e-291 1e-105 0e+384 -> 1E-396 Subnormal
-ddfma2765 fma 1e-291 1e-106 0e+384 -> 1E-397 Subnormal
-ddfma2766 fma 1e-291 1e-107 0e+384 -> 1E-398 Subnormal
-ddfma2767 fma 1e-291 1e-108 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2768 fma 1e-291 1e-109 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2769 fma 1e-291 1e-110 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-ddfma2770 fma 1e+60 1e+321 0e+384 -> 1.000000000000E+381 Clamped
-ddfma2771 fma 1e+60 1e+322 0e+384 -> 1.0000000000000E+382 Clamped
-ddfma2772 fma 1e+60 1e+323 0e+384 -> 1.00000000000000E+383 Clamped
-ddfma2773 fma 1e+60 1e+324 0e+384 -> 1.000000000000000E+384 Clamped
-ddfma2774 fma 1e+60 1e+325 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2775 fma 1e+60 1e+326 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2776 fma 1e+60 1e+327 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2777 fma 1e+60 1e+328 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2778 fma 1e+60 1e+329 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2779 fma 1e+60 1e+330 0e+384 -> Infinity Overflow Inexact Rounded
-
-ddfma2801 fma 1.0000E-394 1 0e+384 -> 1.0000E-394 Subnormal
-ddfma2802 fma 1.000E-394 1e-1 0e+384 -> 1.000E-395 Subnormal
-ddfma2803 fma 1.00E-394 1e-2 0e+384 -> 1.00E-396 Subnormal
-ddfma2804 fma 1.0E-394 1e-3 0e+384 -> 1.0E-397 Subnormal
-ddfma2805 fma 1.0E-394 1e-4 0e+384 -> 1E-398 Subnormal Rounded
-ddfma2806 fma 1.3E-394 1e-4 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddfma2807 fma 1.5E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2808 fma 1.7E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2809 fma 2.3E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2810 fma 2.5E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2811 fma 2.7E-394 1e-4 0e+384 -> 3E-398 Underflow Subnormal Inexact Rounded
-ddfma2812 fma 1.49E-394 1e-4 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddfma2813 fma 1.50E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2814 fma 1.51E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2815 fma 2.49E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2816 fma 2.50E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2817 fma 2.51E-394 1e-4 0e+384 -> 3E-398 Underflow Subnormal Inexact Rounded
-
-ddfma2818 fma 1E-394 1e-4 0e+384 -> 1E-398 Subnormal
-ddfma2819 fma 3E-394 1e-5 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2820 fma 5E-394 1e-5 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2821 fma 7E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddfma2822 fma 9E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddfma2823 fma 9.9E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-
-ddfma2824 fma 1E-394 -1e-4 0e+384 -> -1E-398 Subnormal
-ddfma2825 fma 3E-394 -1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2826 fma -5E-394 1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2827 fma 7E-394 -1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddfma2828 fma -9E-394 1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddfma2829 fma 9.9E-394 -1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddfma2830 fma 3.0E-394 -1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-ddfma2831 fma 1.0E-199 1e-200 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2832 fma 1.0E-199 1e-199 0e+384 -> 1E-398 Subnormal Rounded
-ddfma2833 fma 1.0E-199 1e-198 0e+384 -> 1.0E-397 Subnormal
-ddfma2834 fma 2.0E-199 2e-198 0e+384 -> 4.0E-397 Subnormal
-ddfma2835 fma 4.0E-199 4e-198 0e+384 -> 1.60E-396 Subnormal
-ddfma2836 fma 10.0E-199 10e-198 0e+384 -> 1.000E-395 Subnormal
-ddfma2837 fma 30.0E-199 30e-198 0e+384 -> 9.000E-395 Subnormal
-ddfma2838 fma 40.0E-199 40e-188 0e+384 -> 1.6000E-384 Subnormal
-ddfma2839 fma 40.0E-199 40e-187 0e+384 -> 1.6000E-383
-ddfma2840 fma 40.0E-199 40e-186 0e+384 -> 1.6000E-382
-
--- Long operand overflow may be a different path
-ddfma2870 fma 100 9.999E+383 0e+384 -> Infinity Inexact Overflow Rounded
-ddfma2871 fma 100 -9.999E+383 0e+384 -> -Infinity Inexact Overflow Rounded
-ddfma2872 fma 9.999E+383 100 0e+384 -> Infinity Inexact Overflow Rounded
-ddfma2873 fma -9.999E+383 100 0e+384 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-ddfma2881 fma 1.2347E-355 1.2347E-40 0e+384 -> 1.524E-395 Inexact Rounded Subnormal Underflow
-ddfma2882 fma 1.234E-355 1.234E-40 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddfma2883 fma 1.23E-355 1.23E-40 0e+384 -> 1.513E-395 Inexact Rounded Subnormal Underflow
-ddfma2884 fma 1.2E-355 1.2E-40 0e+384 -> 1.44E-395 Subnormal
-ddfma2885 fma 1.2E-355 1.2E-41 0e+384 -> 1.44E-396 Subnormal
-ddfma2886 fma 1.2E-355 1.2E-42 0e+384 -> 1.4E-397 Subnormal Inexact Rounded Underflow
-ddfma2887 fma 1.2E-355 1.3E-42 0e+384 -> 1.6E-397 Subnormal Inexact Rounded Underflow
-ddfma2888 fma 1.3E-355 1.3E-42 0e+384 -> 1.7E-397 Subnormal Inexact Rounded Underflow
-ddfma2889 fma 1.3E-355 1.3E-43 0e+384 -> 2E-398 Subnormal Inexact Rounded Underflow
-ddfma2890 fma 1.3E-356 1.3E-43 0e+384 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
-
-ddfma2891 fma 1.2345E-39 1.234E-355 0e+384 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
-ddfma2892 fma 1.23456E-39 1.234E-355 0e+384 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
-ddfma2893 fma 1.2345E-40 1.234E-355 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddfma2894 fma 1.23456E-40 1.234E-355 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddfma2895 fma 1.2345E-41 1.234E-355 0e+384 -> 1.52E-396 Inexact Rounded Subnormal Underflow
-ddfma2896 fma 1.23456E-41 1.234E-355 0e+384 -> 1.52E-396 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
-ddfma2900 fma 0.3000000000E-191 0.3000000000E-191 0e+384 -> 9.00000000000000E-384 Subnormal Rounded
-ddfma2901 fma 0.3000000001E-191 0.3000000001E-191 0e+384 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
-ddfma2902 fma 9.999999999999999E-383 0.0999999999999 0e+384 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
-ddfma2903 fma 9.999999999999999E-383 0.09999999999999 0e+384 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
-ddfma2904 fma 9.999999999999999E-383 0.099999999999999 0e+384 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
-ddfma2905 fma 9.999999999999999E-383 0.0999999999999999 0e+384 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
--- prove operands are exact
-ddfma2906 fma 9.999999999999999E-383 1 0e+384 -> 9.999999999999999E-383
-ddfma2907 fma 1 0.09999999999999999 0e+384 -> 0.09999999999999999
--- the next rounds to Nmin
-ddfma2908 fma 9.999999999999999E-383 0.09999999999999999 0e+384 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-
--- hugest
-ddfma2909 fma 9999999999999999 9999999999999999 0e+384 -> 9.999999999999998E+31 Inexact Rounded
-
--- Null tests
-ddfma2990 fma 10 # 0e+384 -> NaN Invalid_operation
-ddfma2991 fma # 10 0e+384 -> NaN Invalid_operation
-
-
--- ADDITION TESTS ------------------------------------------------------
-
--- [first group are 'quick confidence check']
-ddfma3001 fma 1 1 1 -> 2
-ddfma3002 fma 1 2 3 -> 5
-ddfma3003 fma 1 '5.75' '3.3' -> 9.05
-ddfma3004 fma 1 '5' '-3' -> 2
-ddfma3005 fma 1 '-5' '-3' -> -8
-ddfma3006 fma 1 '-7' '2.5' -> -4.5
-ddfma3007 fma 1 '0.7' '0.3' -> 1.0
-ddfma3008 fma 1 '1.25' '1.25' -> 2.50
-ddfma3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
-ddfma3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
-
--- 1234567890123456 1234567890123456
-ddfma3011 fma 1 '0.4444444444444446' '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
-ddfma3012 fma 1 '0.4444444444444445' '0.5555555555555555' -> '1.000000000000000' Rounded
-ddfma3013 fma 1 '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
-ddfma3014 fma 1 '4444444444444444' '0.49' -> '4444444444444444' Inexact Rounded
-ddfma3015 fma 1 '4444444444444444' '0.499' -> '4444444444444444' Inexact Rounded
-ddfma3016 fma 1 '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
-ddfma3017 fma 1 '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
-ddfma3018 fma 1 '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
-ddfma3019 fma 1 '4444444444444444' '0.501' -> '4444444444444445' Inexact Rounded
-ddfma3020 fma 1 '4444444444444444' '0.51' -> '4444444444444445' Inexact Rounded
-
-ddfma3021 fma 1 0 1 -> 1
-ddfma3022 fma 1 1 1 -> 2
-ddfma3023 fma 1 2 1 -> 3
-ddfma3024 fma 1 3 1 -> 4
-ddfma3025 fma 1 4 1 -> 5
-ddfma3026 fma 1 5 1 -> 6
-ddfma3027 fma 1 6 1 -> 7
-ddfma3028 fma 1 7 1 -> 8
-ddfma3029 fma 1 8 1 -> 9
-ddfma3030 fma 1 9 1 -> 10
-
--- some carrying effects
-ddfma3031 fma 1 '0.9998' '0.0000' -> '0.9998'
-ddfma3032 fma 1 '0.9998' '0.0001' -> '0.9999'
-ddfma3033 fma 1 '0.9998' '0.0002' -> '1.0000'
-ddfma3034 fma 1 '0.9998' '0.0003' -> '1.0001'
-
-ddfma3035 fma 1 '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3036 fma 1 '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3037 fma 1 '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3038 fma 1 '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
-ddfma3039 fma 1 '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
-
--- symmetry:
-ddfma3040 fma 1 '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3041 fma 1 '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3042 fma 1 '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3044 fma 1 '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
-ddfma3045 fma 1 '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
-
--- same, without rounding
-ddfma3046 fma 1 '10000e+9' '7' -> '10000000000007'
-ddfma3047 fma 1 '10000e+9' '70' -> '10000000000070'
-ddfma3048 fma 1 '10000e+9' '700' -> '10000000000700'
-ddfma3049 fma 1 '10000e+9' '7000' -> '10000000007000'
-ddfma3050 fma 1 '10000e+9' '70000' -> '10000000070000'
-ddfma3051 fma 1 '10000e+9' '700000' -> '10000000700000'
-ddfma3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-ddfma3053 fma 1 '12' '7.00' -> '19.00'
-ddfma3054 fma 1 '1.3' '-1.07' -> '0.23'
-ddfma3055 fma 1 '1.3' '-1.30' -> '0.00'
-ddfma3056 fma 1 '1.3' '-2.07' -> '-0.77'
-ddfma3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
-
--- leading zero preservation
-ddfma3061 fma 1 1 '0.0001' -> '1.0001'
-ddfma3062 fma 1 1 '0.00001' -> '1.00001'
-ddfma3063 fma 1 1 '0.000001' -> '1.000001'
-ddfma3064 fma 1 1 '0.0000001' -> '1.0000001'
-ddfma3065 fma 1 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-ddfma3070 fma 1 1 0 -> 1
-ddfma3071 fma 1 1 0. -> 1
-ddfma3072 fma 1 1 .0 -> 1.0
-ddfma3073 fma 1 1 0.0 -> 1.0
-ddfma3074 fma 1 1 0.00 -> 1.00
-ddfma3075 fma 1 0 1 -> 1
-ddfma3076 fma 1 0. 1 -> 1
-ddfma3077 fma 1 .0 1 -> 1.0
-ddfma3078 fma 1 0.0 1 -> 1.0
-ddfma3079 fma 1 0.00 1 -> 1.00
-
--- some carries
-ddfma3080 fma 1 999999998 1 -> 999999999
-ddfma3081 fma 1 999999999 1 -> 1000000000
-ddfma3082 fma 1 99999999 1 -> 100000000
-ddfma3083 fma 1 9999999 1 -> 10000000
-ddfma3084 fma 1 999999 1 -> 1000000
-ddfma3085 fma 1 99999 1 -> 100000
-ddfma3086 fma 1 9999 1 -> 10000
-ddfma3087 fma 1 999 1 -> 1000
-ddfma3088 fma 1 99 1 -> 100
-ddfma3089 fma 1 9 1 -> 10
-
-
--- more LHS swaps
-ddfma3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
-ddfma3091 fma 1 '-56267E-6' 0 -> '-0.056267'
-ddfma3092 fma 1 '-56267E-5' 0 -> '-0.56267'
-ddfma3093 fma 1 '-56267E-4' 0 -> '-5.6267'
-ddfma3094 fma 1 '-56267E-3' 0 -> '-56.267'
-ddfma3095 fma 1 '-56267E-2' 0 -> '-562.67'
-ddfma3096 fma 1 '-56267E-1' 0 -> '-5626.7'
-ddfma3097 fma 1 '-56267E-0' 0 -> '-56267'
-ddfma3098 fma 1 '-5E-10' 0 -> '-5E-10'
-ddfma3099 fma 1 '-5E-7' 0 -> '-5E-7'
-ddfma3100 fma 1 '-5E-6' 0 -> '-0.000005'
-ddfma3101 fma 1 '-5E-5' 0 -> '-0.00005'
-ddfma3102 fma 1 '-5E-4' 0 -> '-0.0005'
-ddfma3103 fma 1 '-5E-1' 0 -> '-0.5'
-ddfma3104 fma 1 '-5E0' 0 -> '-5'
-ddfma3105 fma 1 '-5E1' 0 -> '-50'
-ddfma3106 fma 1 '-5E5' 0 -> '-500000'
-ddfma3107 fma 1 '-5E15' 0 -> '-5000000000000000'
-ddfma3108 fma 1 '-5E16' 0 -> '-5.000000000000000E+16' Rounded
-ddfma3109 fma 1 '-5E17' 0 -> '-5.000000000000000E+17' Rounded
-ddfma3110 fma 1 '-5E18' 0 -> '-5.000000000000000E+18' Rounded
-ddfma3111 fma 1 '-5E100' 0 -> '-5.000000000000000E+100' Rounded
-
--- more RHS swaps
-ddfma3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
-ddfma3114 fma 1 0 '-56267E-6' -> '-0.056267'
-ddfma3116 fma 1 0 '-56267E-5' -> '-0.56267'
-ddfma3117 fma 1 0 '-56267E-4' -> '-5.6267'
-ddfma3119 fma 1 0 '-56267E-3' -> '-56.267'
-ddfma3120 fma 1 0 '-56267E-2' -> '-562.67'
-ddfma3121 fma 1 0 '-56267E-1' -> '-5626.7'
-ddfma3122 fma 1 0 '-56267E-0' -> '-56267'
-ddfma3123 fma 1 0 '-5E-10' -> '-5E-10'
-ddfma3124 fma 1 0 '-5E-7' -> '-5E-7'
-ddfma3125 fma 1 0 '-5E-6' -> '-0.000005'
-ddfma3126 fma 1 0 '-5E-5' -> '-0.00005'
-ddfma3127 fma 1 0 '-5E-4' -> '-0.0005'
-ddfma3128 fma 1 0 '-5E-1' -> '-0.5'
-ddfma3129 fma 1 0 '-5E0' -> '-5'
-ddfma3130 fma 1 0 '-5E1' -> '-50'
-ddfma3131 fma 1 0 '-5E5' -> '-500000'
-ddfma3132 fma 1 0 '-5E15' -> '-5000000000000000'
-ddfma3133 fma 1 0 '-5E16' -> '-5.000000000000000E+16' Rounded
-ddfma3134 fma 1 0 '-5E17' -> '-5.000000000000000E+17' Rounded
-ddfma3135 fma 1 0 '-5E18' -> '-5.000000000000000E+18' Rounded
-ddfma3136 fma 1 0 '-5E100' -> '-5.000000000000000E+100' Rounded
-
--- related
-ddfma3137 fma 1 1 '0E-19' -> '1.000000000000000' Rounded
-ddfma3138 fma 1 -1 '0E-19' -> '-1.000000000000000' Rounded
-ddfma3139 fma 1 '0E-19' 1 -> '1.000000000000000' Rounded
-ddfma3140 fma 1 '0E-19' -1 -> '-1.000000000000000' Rounded
-ddfma3141 fma 1 1E+11 0.0000 -> '100000000000.0000'
-ddfma3142 fma 1 1E+11 0.00000 -> '100000000000.0000' Rounded
-ddfma3143 fma 1 0.000 1E+12 -> '1000000000000.000'
-ddfma3144 fma 1 0.0000 1E+12 -> '1000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-ddfma3146 fma 1 '00.0' 0 -> '0.0'
-ddfma3147 fma 1 '0.00' 0 -> '0.00'
-ddfma3148 fma 1 0 '0.00' -> '0.00'
-ddfma3149 fma 1 0 '00.0' -> '0.0'
-ddfma3150 fma 1 '00.0' '0.00' -> '0.00'
-ddfma3151 fma 1 '0.00' '00.0' -> '0.00'
-ddfma3152 fma 1 '3' '.3' -> '3.3'
-ddfma3153 fma 1 '3.' '.3' -> '3.3'
-ddfma3154 fma 1 '3.0' '.3' -> '3.3'
-ddfma3155 fma 1 '3.00' '.3' -> '3.30'
-ddfma3156 fma 1 '3' '3' -> '6'
-ddfma3157 fma 1 '3' '+3' -> '6'
-ddfma3158 fma 1 '3' '-3' -> '0'
-ddfma3159 fma 1 '0.3' '-0.3' -> '0.0'
-ddfma3160 fma 1 '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-ddfma3161 fma 1 '1E+12' '-1' -> '999999999999'
-ddfma3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
-ddfma3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
-ddfma3164 fma 1 '-1' '1E+12' -> '999999999999'
-ddfma3165 fma 1 '7E+12' '-1' -> '6999999999999'
-ddfma3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
-ddfma3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
-ddfma3168 fma 1 '-1' '7E+12' -> '6999999999999'
-
-rounding: half_up
--- 1.234567890123456 1234567890123456 1 234567890123456
-ddfma3170 fma 1 '4.444444444444444' '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
-ddfma3171 fma 1 '4.444444444444444' '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
-ddfma3172 fma 1 '4.444444444444444' '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
-ddfma3173 fma 1 '4.444444444444444' '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
-ddfma3174 fma 1 '4.444444444444444' '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
-ddfma3175 fma 1 '4.444444444444444' '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
-ddfma3176 fma 1 '4.444444444444444' '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
-ddfma3177 fma 1 '4.444444444444444' '0.5555555555555550' -> '4.999999999999999' Rounded
-ddfma3178 fma 1 '4.444444444444444' '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
-ddfma3179 fma 1 '4.444444444444444' '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
-ddfma3180 fma 1 '4.444444444444444' '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
-ddfma3181 fma 1 '4.444444444444444' '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
-ddfma3182 fma 1 '4.444444444444444' '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
-ddfma3183 fma 1 '4.444444444444444' '0.5555555555555540' -> '4.999999999999998' Rounded
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-ddfma3200 fma 1 '1234560123456789' 0 -> '1234560123456789'
-ddfma3201 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddfma3202 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddfma3203 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddfma3204 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddfma3205 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddfma3206 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddfma3207 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddfma3208 fma 1 '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
-ddfma3209 fma 1 '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
-ddfma3210 fma 1 '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
-ddfma3211 fma 1 '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
-ddfma3212 fma 1 '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
-ddfma3213 fma 1 '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
-ddfma3214 fma 1 '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
-ddfma3215 fma 1 '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
-ddfma3216 fma 1 '1234560123456789' 1 -> '1234560123456790'
-ddfma3217 fma 1 '1234560123456789' 1.000000001 -> '1234560123456790' Inexact Rounded
-ddfma3218 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddfma3219 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
-
-rounding: half_even
-ddfma3220 fma 1 '1234560123456789' 0 -> '1234560123456789'
-ddfma3221 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddfma3222 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddfma3223 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddfma3224 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddfma3225 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddfma3226 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddfma3227 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddfma3228 fma 1 '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
-ddfma3229 fma 1 '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
-ddfma3230 fma 1 '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
-ddfma3231 fma 1 '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
-ddfma3232 fma 1 '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
-ddfma3233 fma 1 '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
-ddfma3234 fma 1 '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
-ddfma3235 fma 1 '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
-ddfma3236 fma 1 '1234560123456789' 1 -> '1234560123456790'
-ddfma3237 fma 1 '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
-ddfma3238 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddfma3239 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
--- critical few with even bottom digit...
-ddfma3240 fma 1 '1234560123456788' 0.499999999 -> '1234560123456788' Inexact Rounded
-ddfma3241 fma 1 '1234560123456788' 0.5 -> '1234560123456788' Inexact Rounded
-ddfma3242 fma 1 '1234560123456788' 0.500000001 -> '1234560123456789' Inexact Rounded
-
-rounding: down
-ddfma3250 fma 1 '1234560123456789' 0 -> '1234560123456789'
-ddfma3251 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddfma3252 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddfma3253 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddfma3254 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddfma3255 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddfma3256 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddfma3257 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddfma3258 fma 1 '1234560123456789' 0.5 -> '1234560123456789' Inexact Rounded
-ddfma3259 fma 1 '1234560123456789' 0.500000001 -> '1234560123456789' Inexact Rounded
-ddfma3260 fma 1 '1234560123456789' 0.500001 -> '1234560123456789' Inexact Rounded
-ddfma3261 fma 1 '1234560123456789' 0.51 -> '1234560123456789' Inexact Rounded
-ddfma3262 fma 1 '1234560123456789' 0.6 -> '1234560123456789' Inexact Rounded
-ddfma3263 fma 1 '1234560123456789' 0.9 -> '1234560123456789' Inexact Rounded
-ddfma3264 fma 1 '1234560123456789' 0.99999 -> '1234560123456789' Inexact Rounded
-ddfma3265 fma 1 '1234560123456789' 0.999999999 -> '1234560123456789' Inexact Rounded
-ddfma3266 fma 1 '1234560123456789' 1 -> '1234560123456790'
-ddfma3267 fma 1 '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
-ddfma3268 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddfma3269 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-ddfma3301 fma 1 -1 1 -> 0
-ddfma3302 fma 1 0 1 -> 1
-ddfma3303 fma 1 1 1 -> 2
-ddfma3304 fma 1 12 1 -> 13
-ddfma3305 fma 1 98 1 -> 99
-ddfma3306 fma 1 99 1 -> 100
-ddfma3307 fma 1 100 1 -> 101
-ddfma3308 fma 1 101 1 -> 102
-ddfma3309 fma 1 -1 -1 -> -2
-ddfma3310 fma 1 0 -1 -> -1
-ddfma3311 fma 1 1 -1 -> 0
-ddfma3312 fma 1 12 -1 -> 11
-ddfma3313 fma 1 98 -1 -> 97
-ddfma3314 fma 1 99 -1 -> 98
-ddfma3315 fma 1 100 -1 -> 99
-ddfma3316 fma 1 101 -1 -> 100
-
-ddfma3321 fma 1 -0.01 0.01 -> 0.00
-ddfma3322 fma 1 0.00 0.01 -> 0.01
-ddfma3323 fma 1 0.01 0.01 -> 0.02
-ddfma3324 fma 1 0.12 0.01 -> 0.13
-ddfma3325 fma 1 0.98 0.01 -> 0.99
-ddfma3326 fma 1 0.99 0.01 -> 1.00
-ddfma3327 fma 1 1.00 0.01 -> 1.01
-ddfma3328 fma 1 1.01 0.01 -> 1.02
-ddfma3329 fma 1 -0.01 -0.01 -> -0.02
-ddfma3330 fma 1 0.00 -0.01 -> -0.01
-ddfma3331 fma 1 0.01 -0.01 -> 0.00
-ddfma3332 fma 1 0.12 -0.01 -> 0.11
-ddfma3333 fma 1 0.98 -0.01 -> 0.97
-ddfma3334 fma 1 0.99 -0.01 -> 0.98
-ddfma3335 fma 1 1.00 -0.01 -> 0.99
-ddfma3336 fma 1 1.01 -0.01 -> 1.00
-
--- some more cases where adding 0 affects the coefficient
-ddfma3340 fma 1 1E+3 0 -> 1000
-ddfma3341 fma 1 1E+15 0 -> 1000000000000000
-ddfma3342 fma 1 1E+16 0 -> 1.000000000000000E+16 Rounded
-ddfma3343 fma 1 1E+20 0 -> 1.000000000000000E+20 Rounded
--- which simply follow from these cases ...
-ddfma3344 fma 1 1E+3 1 -> 1001
-ddfma3345 fma 1 1E+15 1 -> 1000000000000001
-ddfma3346 fma 1 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
-ddfma3347 fma 1 1E+20 1 -> 1.000000000000000E+20 Inexact Rounded
-ddfma3348 fma 1 1E+3 7 -> 1007
-ddfma3349 fma 1 1E+15 7 -> 1000000000000007
-ddfma3350 fma 1 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
-ddfma3351 fma 1 1E+20 7 -> 1.000000000000000E+20 Inexact Rounded
-
--- tryzeros cases
-rounding: half_up
-ddfma3360 fma 1 0E+50 10000E+1 -> 1.0000E+5
-ddfma3361 fma 1 0E-50 10000E+1 -> 100000.0000000000 Rounded
-ddfma3362 fma 1 10000E+1 0E-50 -> 100000.0000000000 Rounded
-ddfma3363 fma 1 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
-ddfma3364 fma 1 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-ddfma3370 fma 1 999999999999999 815 -> 1000000000000814
-ddfma3371 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-rounding: half_up
-ddfma3372 fma 1 999999999999999 815 -> 1000000000000814
-ddfma3373 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-rounding: half_even
-ddfma3374 fma 1 999999999999999 815 -> 1000000000000814
-ddfma3375 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-
--- ulp replacement tests
-ddfma3400 fma 1 1 77e-14 -> 1.00000000000077
-ddfma3401 fma 1 1 77e-15 -> 1.000000000000077
-ddfma3402 fma 1 1 77e-16 -> 1.000000000000008 Inexact Rounded
-ddfma3403 fma 1 1 77e-17 -> 1.000000000000001 Inexact Rounded
-ddfma3404 fma 1 1 77e-18 -> 1.000000000000000 Inexact Rounded
-ddfma3405 fma 1 1 77e-19 -> 1.000000000000000 Inexact Rounded
-ddfma3406 fma 1 1 77e-299 -> 1.000000000000000 Inexact Rounded
-
-ddfma3410 fma 1 10 77e-14 -> 10.00000000000077
-ddfma3411 fma 1 10 77e-15 -> 10.00000000000008 Inexact Rounded
-ddfma3412 fma 1 10 77e-16 -> 10.00000000000001 Inexact Rounded
-ddfma3413 fma 1 10 77e-17 -> 10.00000000000000 Inexact Rounded
-ddfma3414 fma 1 10 77e-18 -> 10.00000000000000 Inexact Rounded
-ddfma3415 fma 1 10 77e-19 -> 10.00000000000000 Inexact Rounded
-ddfma3416 fma 1 10 77e-299 -> 10.00000000000000 Inexact Rounded
-
-ddfma3420 fma 1 77e-14 1 -> 1.00000000000077
-ddfma3421 fma 1 77e-15 1 -> 1.000000000000077
-ddfma3422 fma 1 77e-16 1 -> 1.000000000000008 Inexact Rounded
-ddfma3423 fma 1 77e-17 1 -> 1.000000000000001 Inexact Rounded
-ddfma3424 fma 1 77e-18 1 -> 1.000000000000000 Inexact Rounded
-ddfma3425 fma 1 77e-19 1 -> 1.000000000000000 Inexact Rounded
-ddfma3426 fma 1 77e-299 1 -> 1.000000000000000 Inexact Rounded
-
-ddfma3430 fma 1 77e-14 10 -> 10.00000000000077
-ddfma3431 fma 1 77e-15 10 -> 10.00000000000008 Inexact Rounded
-ddfma3432 fma 1 77e-16 10 -> 10.00000000000001 Inexact Rounded
-ddfma3433 fma 1 77e-17 10 -> 10.00000000000000 Inexact Rounded
-ddfma3434 fma 1 77e-18 10 -> 10.00000000000000 Inexact Rounded
-ddfma3435 fma 1 77e-19 10 -> 10.00000000000000 Inexact Rounded
-ddfma3436 fma 1 77e-299 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-ddfma36440 fma 1 1 -77e-14 -> 0.99999999999923
-ddfma36441 fma 1 1 -77e-15 -> 0.999999999999923
-ddfma36442 fma 1 1 -77e-16 -> 0.9999999999999923
-ddfma36443 fma 1 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
-ddfma36444 fma 1 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
-ddfma36445 fma 1 1 -77e-19 -> 1.000000000000000 Inexact Rounded
-ddfma36446 fma 1 1 -77e-99 -> 1.000000000000000 Inexact Rounded
-
-ddfma36450 fma 1 10 -77e-14 -> 9.99999999999923
-ddfma36451 fma 1 10 -77e-15 -> 9.999999999999923
-ddfma36452 fma 1 10 -77e-16 -> 9.999999999999992 Inexact Rounded
-ddfma36453 fma 1 10 -77e-17 -> 9.999999999999999 Inexact Rounded
-ddfma36454 fma 1 10 -77e-18 -> 10.00000000000000 Inexact Rounded
-ddfma36455 fma 1 10 -77e-19 -> 10.00000000000000 Inexact Rounded
-ddfma36456 fma 1 10 -77e-99 -> 10.00000000000000 Inexact Rounded
-
-ddfma36460 fma 1 -77e-14 1 -> 0.99999999999923
-ddfma36461 fma 1 -77e-15 1 -> 0.999999999999923
-ddfma36462 fma 1 -77e-16 1 -> 0.9999999999999923
-ddfma36463 fma 1 -77e-17 1 -> 0.9999999999999992 Inexact Rounded
-ddfma36464 fma 1 -77e-18 1 -> 0.9999999999999999 Inexact Rounded
-ddfma36465 fma 1 -77e-19 1 -> 1.000000000000000 Inexact Rounded
-ddfma36466 fma 1 -77e-99 1 -> 1.000000000000000 Inexact Rounded
-
-ddfma36470 fma 1 -77e-14 10 -> 9.99999999999923
-ddfma36471 fma 1 -77e-15 10 -> 9.999999999999923
-ddfma36472 fma 1 -77e-16 10 -> 9.999999999999992 Inexact Rounded
-ddfma36473 fma 1 -77e-17 10 -> 9.999999999999999 Inexact Rounded
-ddfma36474 fma 1 -77e-18 10 -> 10.00000000000000 Inexact Rounded
-ddfma36475 fma 1 -77e-19 10 -> 10.00000000000000 Inexact Rounded
-ddfma36476 fma 1 -77e-99 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-ddfma36480 fma 1 -1 77e-14 -> -0.99999999999923
-ddfma36481 fma 1 -1 77e-15 -> -0.999999999999923
-ddfma36482 fma 1 -1 77e-16 -> -0.9999999999999923
-ddfma36483 fma 1 -1 77e-17 -> -0.9999999999999992 Inexact Rounded
-ddfma36484 fma 1 -1 77e-18 -> -0.9999999999999999 Inexact Rounded
-ddfma36485 fma 1 -1 77e-19 -> -1.000000000000000 Inexact Rounded
-ddfma36486 fma 1 -1 77e-99 -> -1.000000000000000 Inexact Rounded
-
-ddfma36490 fma 1 -10 77e-14 -> -9.99999999999923
-ddfma36491 fma 1 -10 77e-15 -> -9.999999999999923
-ddfma36492 fma 1 -10 77e-16 -> -9.999999999999992 Inexact Rounded
-ddfma36493 fma 1 -10 77e-17 -> -9.999999999999999 Inexact Rounded
-ddfma36494 fma 1 -10 77e-18 -> -10.00000000000000 Inexact Rounded
-ddfma36495 fma 1 -10 77e-19 -> -10.00000000000000 Inexact Rounded
-ddfma36496 fma 1 -10 77e-99 -> -10.00000000000000 Inexact Rounded
-
-ddfma36500 fma 1 77e-14 -1 -> -0.99999999999923
-ddfma36501 fma 1 77e-15 -1 -> -0.999999999999923
-ddfma36502 fma 1 77e-16 -1 -> -0.9999999999999923
-ddfma36503 fma 1 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
-ddfma36504 fma 1 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
-ddfma36505 fma 1 77e-19 -1 -> -1.000000000000000 Inexact Rounded
-ddfma36506 fma 1 77e-99 -1 -> -1.000000000000000 Inexact Rounded
-
-ddfma36510 fma 1 77e-14 -10 -> -9.99999999999923
-ddfma36511 fma 1 77e-15 -10 -> -9.999999999999923
-ddfma36512 fma 1 77e-16 -10 -> -9.999999999999992 Inexact Rounded
-ddfma36513 fma 1 77e-17 -10 -> -9.999999999999999 Inexact Rounded
-ddfma36514 fma 1 77e-18 -10 -> -10.00000000000000 Inexact Rounded
-ddfma36515 fma 1 77e-19 -10 -> -10.00000000000000 Inexact Rounded
-ddfma36516 fma 1 77e-99 -10 -> -10.00000000000000 Inexact Rounded
-
--- and a couple more with longer RHS
-ddfma36520 fma 1 1 -7777e-16 -> 0.9999999999992223
-ddfma36521 fma 1 1 -7777e-17 -> 0.9999999999999222 Inexact Rounded
-ddfma36522 fma 1 1 -7777e-18 -> 0.9999999999999922 Inexact Rounded
-ddfma36523 fma 1 1 -7777e-19 -> 0.9999999999999992 Inexact Rounded
-ddfma36524 fma 1 1 -7777e-20 -> 0.9999999999999999 Inexact Rounded
-ddfma36525 fma 1 1 -7777e-21 -> 1.000000000000000 Inexact Rounded
-ddfma36526 fma 1 1 -7777e-22 -> 1.000000000000000 Inexact Rounded
-
-
--- and some more residue effects and different roundings
-rounding: half_up
-ddfma36540 fma 1 '6543210123456789' 0 -> '6543210123456789'
-ddfma36541 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddfma36542 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddfma36543 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddfma36544 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddfma36545 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddfma36546 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddfma36547 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddfma36548 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-ddfma36549 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-ddfma36550 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-ddfma36551 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-ddfma36552 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-ddfma36553 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-ddfma36554 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-ddfma36555 fma 1 '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
-ddfma36556 fma 1 '6543210123456789' 1 -> '6543210123456790'
-ddfma36557 fma 1 '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
-ddfma36558 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddfma36559 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
-rounding: half_even
-ddfma36560 fma 1 '6543210123456789' 0 -> '6543210123456789'
-ddfma36561 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddfma36562 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddfma36563 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddfma36564 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddfma36565 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddfma36566 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddfma36567 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddfma36568 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-ddfma36569 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-ddfma36570 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-ddfma36571 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-ddfma36572 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-ddfma36573 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-ddfma36574 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-ddfma36575 fma 1 '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
-ddfma36576 fma 1 '6543210123456789' 1 -> '6543210123456790'
-ddfma36577 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-ddfma36578 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddfma36579 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
--- critical few with even bottom digit...
-ddfma37540 fma 1 '6543210123456788' 0.499999999 -> '6543210123456788' Inexact Rounded
-ddfma37541 fma 1 '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
-ddfma37542 fma 1 '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
-
-rounding: down
-ddfma37550 fma 1 '6543210123456789' 0 -> '6543210123456789'
-ddfma37551 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddfma37552 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddfma37553 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddfma37554 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddfma37555 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddfma37556 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddfma37557 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddfma37558 fma 1 '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
-ddfma37559 fma 1 '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
-ddfma37560 fma 1 '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
-ddfma37561 fma 1 '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
-ddfma37562 fma 1 '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
-ddfma37563 fma 1 '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
-ddfma37564 fma 1 '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
-ddfma37565 fma 1 '6543210123456789' 0.999999999 -> '6543210123456789' Inexact Rounded
-ddfma37566 fma 1 '6543210123456789' 1 -> '6543210123456790'
-ddfma37567 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-ddfma37568 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddfma37569 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
-
--- verify a query
-rounding: down
-ddfma37661 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
-ddfma37662 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
-ddfma37663 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
-ddfma37664 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-ddfma37701 fma 1 5.00 1.00E-3 -> 5.00100
-ddfma37702 fma 1 00.00 0.000 -> 0.000
-ddfma37703 fma 1 00.00 0E-3 -> 0.000
-ddfma37704 fma 1 0E-3 00.00 -> 0.000
-
-ddfma37710 fma 1 0E+3 00.00 -> 0.00
-ddfma37711 fma 1 0E+3 00.0 -> 0.0
-ddfma37712 fma 1 0E+3 00. -> 0
-ddfma37713 fma 1 0E+3 00.E+1 -> 0E+1
-ddfma37714 fma 1 0E+3 00.E+2 -> 0E+2
-ddfma37715 fma 1 0E+3 00.E+3 -> 0E+3
-ddfma37716 fma 1 0E+3 00.E+4 -> 0E+3
-ddfma37717 fma 1 0E+3 00.E+5 -> 0E+3
-ddfma37718 fma 1 0E+3 -00.0 -> 0.0
-ddfma37719 fma 1 0E+3 -00. -> 0
-ddfma37731 fma 1 0E+3 -00.E+1 -> 0E+1
-
-ddfma37720 fma 1 00.00 0E+3 -> 0.00
-ddfma37721 fma 1 00.0 0E+3 -> 0.0
-ddfma37722 fma 1 00. 0E+3 -> 0
-ddfma37723 fma 1 00.E+1 0E+3 -> 0E+1
-ddfma37724 fma 1 00.E+2 0E+3 -> 0E+2
-ddfma37725 fma 1 00.E+3 0E+3 -> 0E+3
-ddfma37726 fma 1 00.E+4 0E+3 -> 0E+3
-ddfma37727 fma 1 00.E+5 0E+3 -> 0E+3
-ddfma37728 fma 1 -00.00 0E+3 -> 0.00
-ddfma37729 fma 1 -00.0 0E+3 -> 0.0
-ddfma37730 fma 1 -00. 0E+3 -> 0
-
-ddfma37732 fma 1 0 0 -> 0
-ddfma37733 fma 1 0 -0 -> 0
-ddfma37734 fma 1 -0 0 -> 0
-ddfma37735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
-
-ddfma37736 fma 1 1 -1 -> 0
-ddfma37737 fma 1 -1 -1 -> -2
-ddfma37738 fma 1 1 1 -> 2
-ddfma37739 fma 1 -1 1 -> 0
-
-ddfma37741 fma 1 0 -1 -> -1
-ddfma37742 fma 1 -0 -1 -> -1
-ddfma37743 fma 1 0 1 -> 1
-ddfma37744 fma 1 -0 1 -> 1
-ddfma37745 fma 1 -1 0 -> -1
-ddfma37746 fma 1 -1 -0 -> -1
-ddfma37747 fma 1 1 0 -> 1
-ddfma37748 fma 1 1 -0 -> 1
-
-ddfma37751 fma 1 0.0 -1 -> -1.0
-ddfma37752 fma 1 -0.0 -1 -> -1.0
-ddfma37753 fma 1 0.0 1 -> 1.0
-ddfma37754 fma 1 -0.0 1 -> 1.0
-ddfma37755 fma 1 -1.0 0 -> -1.0
-ddfma37756 fma 1 -1.0 -0 -> -1.0
-ddfma37757 fma 1 1.0 0 -> 1.0
-ddfma37758 fma 1 1.0 -0 -> 1.0
-
-ddfma37761 fma 1 0 -1.0 -> -1.0
-ddfma37762 fma 1 -0 -1.0 -> -1.0
-ddfma37763 fma 1 0 1.0 -> 1.0
-ddfma37764 fma 1 -0 1.0 -> 1.0
-ddfma37765 fma 1 -1 0.0 -> -1.0
-ddfma37766 fma 1 -1 -0.0 -> -1.0
-ddfma37767 fma 1 1 0.0 -> 1.0
-ddfma37768 fma 1 1 -0.0 -> 1.0
-
-ddfma37771 fma 1 0.0 -1.0 -> -1.0
-ddfma37772 fma 1 -0.0 -1.0 -> -1.0
-ddfma37773 fma 1 0.0 1.0 -> 1.0
-ddfma37774 fma 1 -0.0 1.0 -> 1.0
-ddfma37775 fma 1 -1.0 0.0 -> -1.0
-ddfma37776 fma 1 -1.0 -0.0 -> -1.0
-ddfma37777 fma 1 1.0 0.0 -> 1.0
-ddfma37778 fma 1 1.0 -0.0 -> 1.0
-
--- Specials
-ddfma37780 fma 1 -Inf -Inf -> -Infinity
-ddfma37781 fma 1 -Inf -1000 -> -Infinity
-ddfma37782 fma 1 -Inf -1 -> -Infinity
-ddfma37783 fma 1 -Inf -0 -> -Infinity
-ddfma37784 fma 1 -Inf 0 -> -Infinity
-ddfma37785 fma 1 -Inf 1 -> -Infinity
-ddfma37786 fma 1 -Inf 1000 -> -Infinity
-ddfma37787 fma 1 -1000 -Inf -> -Infinity
-ddfma37788 fma 1 -Inf -Inf -> -Infinity
-ddfma37789 fma 1 -1 -Inf -> -Infinity
-ddfma37790 fma 1 -0 -Inf -> -Infinity
-ddfma37791 fma 1 0 -Inf -> -Infinity
-ddfma37792 fma 1 1 -Inf -> -Infinity
-ddfma37793 fma 1 1000 -Inf -> -Infinity
-ddfma37794 fma 1 Inf -Inf -> NaN Invalid_operation
-
-ddfma37800 fma 1 Inf -Inf -> NaN Invalid_operation
-ddfma37801 fma 1 Inf -1000 -> Infinity
-ddfma37802 fma 1 Inf -1 -> Infinity
-ddfma37803 fma 1 Inf -0 -> Infinity
-ddfma37804 fma 1 Inf 0 -> Infinity
-ddfma37805 fma 1 Inf 1 -> Infinity
-ddfma37806 fma 1 Inf 1000 -> Infinity
-ddfma37807 fma 1 Inf Inf -> Infinity
-ddfma37808 fma 1 -1000 Inf -> Infinity
-ddfma37809 fma 1 -Inf Inf -> NaN Invalid_operation
-ddfma37810 fma 1 -1 Inf -> Infinity
-ddfma37811 fma 1 -0 Inf -> Infinity
-ddfma37812 fma 1 0 Inf -> Infinity
-ddfma37813 fma 1 1 Inf -> Infinity
-ddfma37814 fma 1 1000 Inf -> Infinity
-ddfma37815 fma 1 Inf Inf -> Infinity
-
-ddfma37821 fma 1 NaN -Inf -> NaN
-ddfma37822 fma 1 NaN -1000 -> NaN
-ddfma37823 fma 1 NaN -1 -> NaN
-ddfma37824 fma 1 NaN -0 -> NaN
-ddfma37825 fma 1 NaN 0 -> NaN
-ddfma37826 fma 1 NaN 1 -> NaN
-ddfma37827 fma 1 NaN 1000 -> NaN
-ddfma37828 fma 1 NaN Inf -> NaN
-ddfma37829 fma 1 NaN NaN -> NaN
-ddfma37830 fma 1 -Inf NaN -> NaN
-ddfma37831 fma 1 -1000 NaN -> NaN
-ddfma37832 fma 1 -1 NaN -> NaN
-ddfma37833 fma 1 -0 NaN -> NaN
-ddfma37834 fma 1 0 NaN -> NaN
-ddfma37835 fma 1 1 NaN -> NaN
-ddfma37836 fma 1 1000 NaN -> NaN
-ddfma37837 fma 1 Inf NaN -> NaN
-
-ddfma37841 fma 1 sNaN -Inf -> NaN Invalid_operation
-ddfma37842 fma 1 sNaN -1000 -> NaN Invalid_operation
-ddfma37843 fma 1 sNaN -1 -> NaN Invalid_operation
-ddfma37844 fma 1 sNaN -0 -> NaN Invalid_operation
-ddfma37845 fma 1 sNaN 0 -> NaN Invalid_operation
-ddfma37846 fma 1 sNaN 1 -> NaN Invalid_operation
-ddfma37847 fma 1 sNaN 1000 -> NaN Invalid_operation
-ddfma37848 fma 1 sNaN NaN -> NaN Invalid_operation
-ddfma37849 fma 1 sNaN sNaN -> NaN Invalid_operation
-ddfma37850 fma 1 NaN sNaN -> NaN Invalid_operation
-ddfma37851 fma 1 -Inf sNaN -> NaN Invalid_operation
-ddfma37852 fma 1 -1000 sNaN -> NaN Invalid_operation
-ddfma37853 fma 1 -1 sNaN -> NaN Invalid_operation
-ddfma37854 fma 1 -0 sNaN -> NaN Invalid_operation
-ddfma37855 fma 1 0 sNaN -> NaN Invalid_operation
-ddfma37856 fma 1 1 sNaN -> NaN Invalid_operation
-ddfma37857 fma 1 1000 sNaN -> NaN Invalid_operation
-ddfma37858 fma 1 Inf sNaN -> NaN Invalid_operation
-ddfma37859 fma 1 NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddfma37861 fma 1 NaN1 -Inf -> NaN1
-ddfma37862 fma 1 +NaN2 -1000 -> NaN2
-ddfma37863 fma 1 NaN3 1000 -> NaN3
-ddfma37864 fma 1 NaN4 Inf -> NaN4
-ddfma37865 fma 1 NaN5 +NaN6 -> NaN5
-ddfma37866 fma 1 -Inf NaN7 -> NaN7
-ddfma37867 fma 1 -1000 NaN8 -> NaN8
-ddfma37868 fma 1 1000 NaN9 -> NaN9
-ddfma37869 fma 1 Inf +NaN10 -> NaN10
-ddfma37871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
-ddfma37872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
-ddfma37873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
-ddfma37874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
-ddfma37875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddfma37876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
-ddfma37877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
-ddfma37878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
-ddfma37879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
-ddfma37880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
-ddfma37881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddfma37882 fma 1 -NaN26 NaN28 -> -NaN26
-ddfma37883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddfma37884 fma 1 1000 -NaN30 -> -NaN30
-ddfma37885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Here we explore near the boundary of rounding a subnormal to Nmin
-ddfma37575 fma 1 1E-383 -1E-398 -> 9.99999999999999E-384 Subnormal
-ddfma37576 fma 1 -1E-383 +1E-398 -> -9.99999999999999E-384 Subnormal
-
--- check overflow edge case
--- 1234567890123456
-ddfma37972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
-ddfma37973 fma 1 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37974 fma 1 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37975 fma 1 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
-ddfma37976 fma 1 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
-ddfma37977 fma 1 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
-ddfma37978 fma 1 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
-ddfma37979 fma 1 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
-ddfma37980 fma 1 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
-ddfma37981 fma 1 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37982 fma 1 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37983 fma 1 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37984 fma 1 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
-
-ddfma37985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
-ddfma37986 fma 1 -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37987 fma 1 -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37988 fma 1 -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
-ddfma37989 fma 1 -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37990 fma 1 -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37991 fma 1 -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37992 fma 1 -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37993 fma 1 -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37994 fma 1 -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37995 fma 1 -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37996 fma 1 -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37997 fma 1 -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-ddfma371100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
-ddfma371101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
-ddfma371103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
-ddfma371104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
-ddfma371105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
-ddfma371106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
-ddfma371107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
-ddfma371108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
-ddfma371109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-ddfma371110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
-ddfma371111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
-ddfma371113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
-ddfma371114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
-ddfma371115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
-ddfma371116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
-ddfma371117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
-ddfma371118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
-ddfma371119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-ddfma371300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
-ddfma371311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
-ddfma371312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
-ddfma371313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
-ddfma371314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
-ddfma371315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
-ddfma371316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
-ddfma371317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
-ddfma371318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
-ddfma371319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
-ddfma371320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
-ddfma371321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
-ddfma371322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
-ddfma371323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
-ddfma371324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
-ddfma371325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
-
-ddfma371340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
-ddfma371341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
-
-ddfma371349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
-ddfma371350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
-ddfma371351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
-ddfma371352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
-ddfma371353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
-ddfma371354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
-ddfma371355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
-ddfma371356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
-ddfma371357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
-ddfma371358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
-ddfma371359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
-ddfma371360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
-ddfma371361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
-ddfma371362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
-ddfma371363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
-ddfma371364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
-ddfma371365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-ddfma371420 fma 1 0 1.123456789012345 -> 1.123456789012345
-ddfma371421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
-ddfma371422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
-ddfma371423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
-ddfma371424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
-ddfma371425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
-ddfma371426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
-ddfma371427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
-ddfma371428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
-ddfma371429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
-ddfma371430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
-ddfma371431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
-ddfma371432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
-ddfma371433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
-ddfma371434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
-ddfma371435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
-ddfma371436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
-ddfma371437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
-ddfma371438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
-ddfma371439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
-
--- same, reversed 0
-ddfma371440 fma 1 1.123456789012345 0 -> 1.123456789012345
-ddfma371441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
-ddfma371442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
-ddfma371443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
-ddfma371444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
-ddfma371445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
-ddfma371446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
-ddfma371447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
-ddfma371448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
-ddfma371449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
-ddfma371450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
-ddfma371451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
-ddfma371452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
-ddfma371453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
-ddfma371454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
-ddfma371455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
-ddfma371456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
-ddfma371457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
-ddfma371458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
-ddfma371459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
-
--- same, Es on the 0
-ddfma371460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
-ddfma371461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
-ddfma371462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
-ddfma371463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
-ddfma371464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
-ddfma371465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
-ddfma371466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
-ddfma371467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
-ddfma371468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
-ddfma371469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
-ddfma371470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
-ddfma371471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
-ddfma371472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
-ddfma371473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
-ddfma371474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
-ddfma371475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
--- next four flag Rounded because the 0 extends the result
-ddfma371476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
-ddfma371477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
-ddfma371478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
-ddfma371479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-ddfma371500 fma 1 0 0E-19 -> 0E-19
-ddfma371501 fma 1 -0 0E-19 -> 0E-19
-ddfma371502 fma 1 0 -0E-19 -> 0E-19
-ddfma371503 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371511 fma 1 -11 11 -> 0
-ddfma371512 fma 1 11 -11 -> 0
-
-rounding: half_down
--- exact zeros from zeros
-ddfma371520 fma 1 0 0E-19 -> 0E-19
-ddfma371521 fma 1 -0 0E-19 -> 0E-19
-ddfma371522 fma 1 0 -0E-19 -> 0E-19
-ddfma371523 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371531 fma 1 -11 11 -> 0
-ddfma371532 fma 1 11 -11 -> 0
-
-rounding: half_even
--- exact zeros from zeros
-ddfma371540 fma 1 0 0E-19 -> 0E-19
-ddfma371541 fma 1 -0 0E-19 -> 0E-19
-ddfma371542 fma 1 0 -0E-19 -> 0E-19
-ddfma371543 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371551 fma 1 -11 11 -> 0
-ddfma371552 fma 1 11 -11 -> 0
-
-rounding: up
--- exact zeros from zeros
-ddfma371560 fma 1 0 0E-19 -> 0E-19
-ddfma371561 fma 1 -0 0E-19 -> 0E-19
-ddfma371562 fma 1 0 -0E-19 -> 0E-19
-ddfma371563 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371571 fma 1 -11 11 -> 0
-ddfma371572 fma 1 11 -11 -> 0
-
-rounding: down
--- exact zeros from zeros
-ddfma371580 fma 1 0 0E-19 -> 0E-19
-ddfma371581 fma 1 -0 0E-19 -> 0E-19
-ddfma371582 fma 1 0 -0E-19 -> 0E-19
-ddfma371583 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371591 fma 1 -11 11 -> 0
-ddfma371592 fma 1 11 -11 -> 0
-
-rounding: ceiling
--- exact zeros from zeros
-ddfma371600 fma 1 0 0E-19 -> 0E-19
-ddfma371601 fma 1 -0 0E-19 -> 0E-19
-ddfma371602 fma 1 0 -0E-19 -> 0E-19
-ddfma371603 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371611 fma 1 -11 11 -> 0
-ddfma371612 fma 1 11 -11 -> 0
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-ddfma371620 fma 1 0 0E-19 -> 0E-19
-ddfma371621 fma 1 -0 0E-19 -> -0E-19 -- *
-ddfma371622 fma 1 0 -0E-19 -> -0E-19 -- *
-ddfma371623 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371631 fma 1 -11 11 -> -0 -- *
-ddfma371632 fma 1 11 -11 -> -0 -- *
-
--- Examples from SQL proposal (Krishna Kulkarni)
-ddfma371701 fma 1 130E-2 120E-2 -> 2.50
-ddfma371702 fma 1 130E-2 12E-1 -> 2.50
-ddfma371703 fma 1 130E-2 1E0 -> 2.30
-ddfma371704 fma 1 1E2 1E4 -> 1.01E+4
-ddfma371705 fma 1 130E-2 -120E-2 -> 0.10
-ddfma371706 fma 1 130E-2 -12E-1 -> 0.10
-ddfma371707 fma 1 130E-2 -1E0 -> 0.30
-ddfma371708 fma 1 1E2 -1E4 -> -9.9E+3
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-ddfma375001 fma 1 1234567890123456 1 -> 1234567890123457
-ddfma375002 fma 1 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
-ddfma375003 fma 1 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
-ddfma375004 fma 1 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
-ddfma375005 fma 1 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
-ddfma375006 fma 1 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
-ddfma375007 fma 1 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
-ddfma375008 fma 1 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
-ddfma375009 fma 1 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
-ddfma375010 fma 1 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
-ddfma375011 fma 1 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
-ddfma375012 fma 1 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
-ddfma375013 fma 1 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
-ddfma375014 fma 1 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
-ddfma375015 fma 1 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
-ddfma375016 fma 1 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
-ddfma375017 fma 1 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
-ddfma375018 fma 1 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
-ddfma375019 fma 1 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
-ddfma375020 fma 1 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
-ddfma375021 fma 1 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
-
--- widening second argument at gap
-ddfma375030 fma 1 12345678 1 -> 12345679
-ddfma375031 fma 1 12345678 0.1 -> 12345678.1
-ddfma375032 fma 1 12345678 0.12 -> 12345678.12
-ddfma375033 fma 1 12345678 0.123 -> 12345678.123
-ddfma375034 fma 1 12345678 0.1234 -> 12345678.1234
-ddfma375035 fma 1 12345678 0.12345 -> 12345678.12345
-ddfma375036 fma 1 12345678 0.123456 -> 12345678.123456
-ddfma375037 fma 1 12345678 0.1234567 -> 12345678.1234567
-ddfma375038 fma 1 12345678 0.12345678 -> 12345678.12345678
-ddfma375039 fma 1 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
-ddfma375040 fma 1 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
-ddfma375041 fma 1 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
-ddfma375042 fma 1 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
-ddfma375043 fma 1 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
-ddfma375044 fma 1 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
-ddfma375045 fma 1 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
-ddfma375046 fma 1 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
-ddfma375047 fma 1 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
-ddfma375048 fma 1 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
-ddfma375049 fma 1 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-ddfma375050 fma 1 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
-ddfma375051 fma 1 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
-ddfma375052 fma 1 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
-ddfma375053 fma 1 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
-ddfma375054 fma 1 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
-ddfma375055 fma 1 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
-ddfma375056 fma 1 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
-ddfma375057 fma 1 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
-ddfma375060 fma 1 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
-ddfma375061 fma 1 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
-ddfma375062 fma 1 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
-ddfma375063 fma 1 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
-ddfma375064 fma 1 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
-ddfma375065 fma 1 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
-ddfma375066 fma 1 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
-ddfma375067 fma 1 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-ddfma375070 fma 1 12345678 1E-8 -> 12345678.00000001
-ddfma375071 fma 1 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
-ddfma375072 fma 1 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
-ddfma375073 fma 1 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
-ddfma375074 fma 1 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
-ddfma375075 fma 1 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
-ddfma375076 fma 1 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
-ddfma375077 fma 1 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
-ddfma375078 fma 1 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
-ddfma375079 fma 1 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
-ddfma375080 fma 1 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
-ddfma375081 fma 1 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
-ddfma375082 fma 1 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
-ddfma375083 fma 1 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
-ddfma375084 fma 1 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
-ddfma375085 fma 1 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
-ddfma375086 fma 1 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
-ddfma375087 fma 1 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
-ddfma375088 fma 1 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
-ddfma375089 fma 1 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
-
--- desctructive subtraction (from remainder tests)
-
--- +++ some of these will be off-by-one remainder vs remainderNear
-
-ddfma4000 fma -1234567890123454 1.000000000000001 1234567890123456 -> 0.765432109876546
-ddfma4001 fma -1234567890123443 1.00000000000001 1234567890123456 -> 0.65432109876557
-ddfma4002 fma -1234567890123332 1.0000000000001 1234567890123456 -> 0.5432109876668
-ddfma4003 fma -308641972530863 4.000000000000001 1234567890123455 -> 2.691358027469137
-ddfma4004 fma -308641972530863 4.000000000000001 1234567890123456 -> 3.691358027469137
-ddfma4005 fma -246913578024696 4.9999999999999 1234567890123456 -> 0.6913578024696
-ddfma4006 fma -246913578024691 4.99999999999999 1234567890123456 -> 3.46913578024691
-ddfma4007 fma -246913578024691 4.999999999999999 1234567890123456 -> 1.246913578024691
-ddfma4008 fma -246913578024691 5.000000000000001 1234567890123456 -> 0.753086421975309
-ddfma4009 fma -246913578024690 5.00000000000001 1234567890123456 -> 3.53086421975310
-ddfma4010 fma -246913578024686 5.0000000000001 1234567890123456 -> 1.3086421975314
-ddfma4011 fma -1234567890123455 1.000000000000001 1234567890123456 -> -0.234567890123455
-ddfma4012 fma -1234567890123444 1.00000000000001 1234567890123456 -> -0.34567890123444
-ddfma4013 fma -1234567890123333 1.0000000000001 1234567890123456 -> -0.4567890123333
-ddfma4014 fma -308641972530864 4.000000000000001 1234567890123455 -> -1.308641972530864
-ddfma4015 fma -308641972530864 4.000000000000001 1234567890123456 -> -0.308641972530864
-ddfma4016 fma -246913578024696 4.9999999999999 1234567890123456 -> 0.6913578024696
-ddfma4017 fma -246913578024692 4.99999999999999 1234567890123456 -> -1.53086421975308
-ddfma4018 fma -246913578024691 4.999999999999999 1234567890123456 -> 1.246913578024691
-ddfma4019 fma -246913578024691 5.000000000000001 1234567890123456 -> 0.753086421975309
-ddfma4020 fma -246913578024691 5.00000000000001 1234567890123456 -> -1.46913578024691
-ddfma4021 fma -246913578024686 5.0000000000001 1234567890123456 -> 1.3086421975314
-
-
--- Null tests
-ddfma39990 fma 1 10 # -> NaN Invalid_operation
-ddfma39991 fma 1 # 10 -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- ddFMA.decTest -- decDouble Fused Multiply Add --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- These tests comprese three parts:
+-- 1. Sanity checks and other three-operand tests (especially those
+-- where the fused operation makes a difference)
+-- 2. Multiply tests (third operand is neutral zero [0E+emax])
+-- 3. Addition tests (first operand is 1)
+-- The multiply and addition tests are extensive because FMA may have
+-- its own dedicated multiplication or addition routine(s), and they
+-- also inherently check the left-to-right properties.
+
+-- Sanity checks
+ddfma0001 fma 1 1 1 -> 2
+ddfma0002 fma 1 1 2 -> 3
+ddfma0003 fma 2 2 3 -> 7
+ddfma0004 fma 9 9 9 -> 90
+ddfma0005 fma -1 1 1 -> 0
+ddfma0006 fma -1 1 2 -> 1
+ddfma0007 fma -2 2 3 -> -1
+ddfma0008 fma -9 9 9 -> -72
+ddfma0011 fma 1 -1 1 -> 0
+ddfma0012 fma 1 -1 2 -> 1
+ddfma0013 fma 2 -2 3 -> -1
+ddfma0014 fma 9 -9 9 -> -72
+ddfma0015 fma 1 1 -1 -> 0
+ddfma0016 fma 1 1 -2 -> -1
+ddfma0017 fma 2 2 -3 -> 1
+ddfma0018 fma 9 9 -9 -> 72
+
+-- non-integer exacts
+ddfma0100 fma 25.2 63.6 -438 -> 1164.72
+ddfma0101 fma 0.301 0.380 334 -> 334.114380
+ddfma0102 fma 49.2 -4.8 23.3 -> -212.86
+ddfma0103 fma 4.22 0.079 -94.6 -> -94.26662
+ddfma0104 fma 903 0.797 0.887 -> 720.578
+ddfma0105 fma 6.13 -161 65.9 -> -921.03
+ddfma0106 fma 28.2 727 5.45 -> 20506.85
+ddfma0107 fma 4 605 688 -> 3108
+ddfma0108 fma 93.3 0.19 0.226 -> 17.953
+ddfma0109 fma 0.169 -341 5.61 -> -52.019
+ddfma0110 fma -72.2 30 -51.2 -> -2217.2
+ddfma0111 fma -0.409 13 20.4 -> 15.083
+ddfma0112 fma 317 77.0 19.0 -> 24428.0
+ddfma0113 fma 47 6.58 1.62 -> 310.88
+ddfma0114 fma 1.36 0.984 0.493 -> 1.83124
+ddfma0115 fma 72.7 274 1.56 -> 19921.36
+ddfma0116 fma 335 847 83 -> 283828
+ddfma0117 fma 666 0.247 25.4 -> 189.902
+ddfma0118 fma -3.87 3.06 78.0 -> 66.1578
+ddfma0119 fma 0.742 192 35.6 -> 178.064
+ddfma0120 fma -91.6 5.29 0.153 -> -484.411
+
+-- cases where result is different from separate multiply + add; each
+-- is preceded by the result of unfused multiply and add
+-- [this is about 20% of all similar cases in general]
+-- -> 7.123356429257969E+16
+ddfma0201 fma 27583489.6645 2582471078.04 2593183.42371 -> 7.123356429257970E+16 Inexact Rounded
+-- -> 22813275328.80506
+ddfma0208 fma 24280.355566 939577.397653 2032.013252 -> 22813275328.80507 Inexact Rounded
+-- -> -2.030397734278062E+16
+ddfma0209 fma 7848976432 -2586831.2281 137903.517909 -> -2.030397734278061E+16 Inexact Rounded
+-- -> 2040774094814.077
+ddfma0217 fma 56890.388731 35872030.4255 339337.123410 -> 2040774094814.078 Inexact Rounded
+-- -> 2.714469575205049E+18
+ddfma0220 fma 7533543.57445 360317763928 5073392.31638 -> 2.714469575205050E+18 Inexact Rounded
+-- -> 1.011676297716716E+19
+ddfma0223 fma 739945255.563 13672312784.1 -994381.53572 -> 1.011676297716715E+19 Inexact Rounded
+-- -> -2.914135721455315E+23
+ddfma0224 fma -413510957218 704729988550 9234162614.0 -> -2.914135721455314E+23 Inexact Rounded
+-- -> 2.620119863365786E+17
+ddfma0226 fma 437484.00601 598906432790 894450638.442 -> 2.620119863365787E+17 Inexact Rounded
+-- -> 1.272647995808178E+19
+ddfma0253 fma 73287556929 173651305.784 -358312568.389 -> 1.272647995808177E+19 Inexact Rounded
+-- -> -1.753769320861851E+18
+ddfma0257 fma 203258304486 -8628278.8066 153127.446727 -> -1.753769320861850E+18 Inexact Rounded
+-- -> -1.550737835263346E+17
+ddfma0260 fma 42560533.1774 -3643605282.86 178277.96377 -> -1.550737835263347E+17 Inexact Rounded
+-- -> 2.897624620576005E+22
+ddfma0269 fma 142656587375 203118879670 604576103991 -> 2.897624620576004E+22 Inexact Rounded
+
+-- Cases where multiply would overflow or underflow if separate
+fma0300 fma 9e+384 10 0 -> Infinity Overflow Inexact Rounded
+fma0301 fma 1e+384 10 0 -> Infinity Overflow Inexact Rounded
+fma0302 fma 1e+384 10 -1e+384 -> 9.000000000000000E+384 Clamped
+fma0303 fma 1e+384 10 -9e+384 -> 1.000000000000000E+384 Clamped
+-- subnormal etc.
+fma0305 fma 1e-398 0.1 0 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+fma0306 fma 1e-398 0.1 1 -> 1.000000000000000 Inexact Rounded
+fma0307 fma 1e-398 0.1 1e-398 -> 1E-398 Underflow Subnormal Inexact Rounded
+
+-- Infinite combinations
+ddfma0800 fma Inf Inf Inf -> Infinity
+ddfma0801 fma Inf Inf -Inf -> NaN Invalid_operation
+ddfma0802 fma Inf -Inf Inf -> NaN Invalid_operation
+ddfma0803 fma Inf -Inf -Inf -> -Infinity
+ddfma0804 fma -Inf Inf Inf -> NaN Invalid_operation
+ddfma0805 fma -Inf Inf -Inf -> -Infinity
+ddfma0806 fma -Inf -Inf Inf -> Infinity
+ddfma0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
+
+-- Triple NaN propagation
+ddfma0900 fma NaN2 NaN3 NaN5 -> NaN2
+ddfma0901 fma 0 NaN3 NaN5 -> NaN3
+ddfma0902 fma 0 0 NaN5 -> NaN5
+-- first sNaN wins (consider qNaN from earlier sNaN being
+-- overridden by an sNaN in third operand)
+ddfma0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+ddfma0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
+ddfma0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
+ddfma0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+ddfma0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
+ddfma0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
+
+-- MULTIPLICATION TESTS ------------------------------------------------
+
+-- sanity checks
+ddfma2000 fma 2 2 0e+384 -> 4
+ddfma2001 fma 2 3 0e+384 -> 6
+ddfma2002 fma 5 1 0e+384 -> 5
+ddfma2003 fma 5 2 0e+384 -> 10
+ddfma2004 fma 1.20 2 0e+384 -> 2.40
+ddfma2005 fma 1.20 0 0e+384 -> 0.00
+ddfma2006 fma 1.20 -2 0e+384 -> -2.40
+ddfma2007 fma -1.20 2 0e+384 -> -2.40
+ddfma2008 fma -1.20 0 0e+384 -> 0.00
+ddfma2009 fma -1.20 -2 0e+384 -> 2.40
+ddfma2010 fma 5.09 7.1 0e+384 -> 36.139
+ddfma2011 fma 2.5 4 0e+384 -> 10.0
+ddfma2012 fma 2.50 4 0e+384 -> 10.00
+ddfma2013 fma 1.23456789 1.00000000 0e+384 -> 1.234567890000000 Rounded
+ddfma2015 fma 2.50 4 0e+384 -> 10.00
+ddfma2016 fma 9.999999999 9.999999999 0e+384 -> 99.99999998000000 Inexact Rounded
+ddfma2017 fma 9.999999999 -9.999999999 0e+384 -> -99.99999998000000 Inexact Rounded
+ddfma2018 fma -9.999999999 9.999999999 0e+384 -> -99.99999998000000 Inexact Rounded
+ddfma2019 fma -9.999999999 -9.999999999 0e+384 -> 99.99999998000000 Inexact Rounded
+
+-- zeros, etc.
+ddfma2021 fma 0 0 0e+384 -> 0
+ddfma2022 fma 0 -0 0e+384 -> 0
+ddfma2023 fma -0 0 0e+384 -> 0
+ddfma2024 fma -0 -0 0e+384 -> 0
+ddfma2025 fma -0.0 -0.0 0e+384 -> 0.00
+ddfma2026 fma -0.0 -0.0 0e+384 -> 0.00
+ddfma2027 fma -0.0 -0.0 0e+384 -> 0.00
+ddfma2028 fma -0.0 -0.0 0e+384 -> 0.00
+ddfma2030 fma 5.00 1E-3 0e+384 -> 0.00500
+ddfma2031 fma 00.00 0.000 0e+384 -> 0.00000
+ddfma2032 fma 00.00 0E-3 0e+384 -> 0.00000 -- rhs is 0
+ddfma2033 fma 0E-3 00.00 0e+384 -> 0.00000 -- lhs is 0
+ddfma2034 fma -5.00 1E-3 0e+384 -> -0.00500
+ddfma2035 fma -00.00 0.000 0e+384 -> 0.00000
+ddfma2036 fma -00.00 0E-3 0e+384 -> 0.00000 -- rhs is 0
+ddfma2037 fma -0E-3 00.00 0e+384 -> 0.00000 -- lhs is 0
+ddfma2038 fma 5.00 -1E-3 0e+384 -> -0.00500
+ddfma2039 fma 00.00 -0.000 0e+384 -> 0.00000
+ddfma2040 fma 00.00 -0E-3 0e+384 -> 0.00000 -- rhs is 0
+ddfma2041 fma 0E-3 -00.00 0e+384 -> 0.00000 -- lhs is 0
+ddfma2042 fma -5.00 -1E-3 0e+384 -> 0.00500
+ddfma2043 fma -00.00 -0.000 0e+384 -> 0.00000
+ddfma2044 fma -00.00 -0E-3 0e+384 -> 0.00000 -- rhs is 0
+ddfma2045 fma -0E-3 -00.00 -0e+384 -> 0.00000 -- lhs is 0
+ddfma2046 fma -0E-3 00.00 -0e+384 -> -0.00000
+ddfma2047 fma 0E-3 -00.00 -0e+384 -> -0.00000
+ddfma2048 fma 0E-3 00.00 -0e+384 -> 0.00000
+
+-- examples from decarith
+ddfma2050 fma 1.20 3 0e+384 -> 3.60
+ddfma2051 fma 7 3 0e+384 -> 21
+ddfma2052 fma 0.9 0.8 0e+384 -> 0.72
+ddfma2053 fma 0.9 -0 0e+384 -> 0.0
+ddfma2054 fma 654321 654321 0e+384 -> 428135971041
+
+ddfma2060 fma 123.45 1e7 0e+384 -> 1.2345E+9
+ddfma2061 fma 123.45 1e8 0e+384 -> 1.2345E+10
+ddfma2062 fma 123.45 1e+9 0e+384 -> 1.2345E+11
+ddfma2063 fma 123.45 1e10 0e+384 -> 1.2345E+12
+ddfma2064 fma 123.45 1e11 0e+384 -> 1.2345E+13
+ddfma2065 fma 123.45 1e12 0e+384 -> 1.2345E+14
+ddfma2066 fma 123.45 1e13 0e+384 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+-- 1234567890123456
+ddfma2080 fma 0.1 1230123456456789 0e+384 -> 123012345645678.9
+ddfma2084 fma 0.1 1230123456456789 0e+384 -> 123012345645678.9
+ddfma2090 fma 1230123456456789 0.1 0e+384 -> 123012345645678.9
+ddfma2094 fma 1230123456456789 0.1 0e+384 -> 123012345645678.9
+
+-- test some more edge cases and carries
+ddfma2101 fma 9 9 0e+384 -> 81
+ddfma2102 fma 9 90 0e+384 -> 810
+ddfma2103 fma 9 900 0e+384 -> 8100
+ddfma2104 fma 9 9000 0e+384 -> 81000
+ddfma2105 fma 9 90000 0e+384 -> 810000
+ddfma2106 fma 9 900000 0e+384 -> 8100000
+ddfma2107 fma 9 9000000 0e+384 -> 81000000
+ddfma2108 fma 9 90000000 0e+384 -> 810000000
+ddfma2109 fma 9 900000000 0e+384 -> 8100000000
+ddfma2110 fma 9 9000000000 0e+384 -> 81000000000
+ddfma2111 fma 9 90000000000 0e+384 -> 810000000000
+ddfma2112 fma 9 900000000000 0e+384 -> 8100000000000
+ddfma2113 fma 9 9000000000000 0e+384 -> 81000000000000
+ddfma2114 fma 9 90000000000000 0e+384 -> 810000000000000
+ddfma2115 fma 9 900000000000000 0e+384 -> 8100000000000000
+--ddfma2116 fma 9 9000000000000000 0e+384 -> 81000000000000000
+--ddfma2117 fma 9 90000000000000000 0e+384 -> 810000000000000000
+--ddfma2118 fma 9 900000000000000000 0e+384 -> 8100000000000000000
+--ddfma2119 fma 9 9000000000000000000 0e+384 -> 81000000000000000000
+--ddfma2120 fma 9 90000000000000000000 0e+384 -> 810000000000000000000
+--ddfma2121 fma 9 900000000000000000000 0e+384 -> 8100000000000000000000
+--ddfma2122 fma 9 9000000000000000000000 0e+384 -> 81000000000000000000000
+--ddfma2123 fma 9 90000000000000000000000 0e+384 -> 810000000000000000000000
+-- test some more edge cases without carries
+ddfma2131 fma 3 3 0e+384 -> 9
+ddfma2132 fma 3 30 0e+384 -> 90
+ddfma2133 fma 3 300 0e+384 -> 900
+ddfma2134 fma 3 3000 0e+384 -> 9000
+ddfma2135 fma 3 30000 0e+384 -> 90000
+ddfma2136 fma 3 300000 0e+384 -> 900000
+ddfma2137 fma 3 3000000 0e+384 -> 9000000
+ddfma2138 fma 3 30000000 0e+384 -> 90000000
+ddfma2139 fma 3 300000000 0e+384 -> 900000000
+ddfma2140 fma 3 3000000000 0e+384 -> 9000000000
+ddfma2141 fma 3 30000000000 0e+384 -> 90000000000
+ddfma2142 fma 3 300000000000 0e+384 -> 900000000000
+ddfma2143 fma 3 3000000000000 0e+384 -> 9000000000000
+ddfma2144 fma 3 30000000000000 0e+384 -> 90000000000000
+ddfma2145 fma 3 300000000000000 0e+384 -> 900000000000000
+
+-- test some edge cases with exact rounding
+ddfma2301 fma 9 9 0e+384 -> 81
+ddfma2302 fma 9 90 0e+384 -> 810
+ddfma2303 fma 9 900 0e+384 -> 8100
+ddfma2304 fma 9 9000 0e+384 -> 81000
+ddfma2305 fma 9 90000 0e+384 -> 810000
+ddfma2306 fma 9 900000 0e+384 -> 8100000
+ddfma2307 fma 9 9000000 0e+384 -> 81000000
+ddfma2308 fma 9 90000000 0e+384 -> 810000000
+ddfma2309 fma 9 900000000 0e+384 -> 8100000000
+ddfma2310 fma 9 9000000000 0e+384 -> 81000000000
+ddfma2311 fma 9 90000000000 0e+384 -> 810000000000
+ddfma2312 fma 9 900000000000 0e+384 -> 8100000000000
+ddfma2313 fma 9 9000000000000 0e+384 -> 81000000000000
+ddfma2314 fma 9 90000000000000 0e+384 -> 810000000000000
+ddfma2315 fma 9 900000000000000 0e+384 -> 8100000000000000
+ddfma2316 fma 9 9000000000000000 0e+384 -> 8.100000000000000E+16 Rounded
+ddfma2317 fma 90 9000000000000000 0e+384 -> 8.100000000000000E+17 Rounded
+ddfma2318 fma 900 9000000000000000 0e+384 -> 8.100000000000000E+18 Rounded
+ddfma2319 fma 9000 9000000000000000 0e+384 -> 8.100000000000000E+19 Rounded
+ddfma2320 fma 90000 9000000000000000 0e+384 -> 8.100000000000000E+20 Rounded
+ddfma2321 fma 900000 9000000000000000 0e+384 -> 8.100000000000000E+21 Rounded
+ddfma2322 fma 9000000 9000000000000000 0e+384 -> 8.100000000000000E+22 Rounded
+ddfma2323 fma 90000000 9000000000000000 0e+384 -> 8.100000000000000E+23 Rounded
+
+-- tryzeros cases
+ddfma2504 fma 0E-260 1000E-260 0e+384 -> 0E-398 Clamped
+ddfma2505 fma 100E+260 0E+260 0e+384 -> 0E+369 Clamped
+
+-- mixed with zeros
+ddfma2541 fma 0 -1 0e+384 -> 0
+ddfma2542 fma -0 -1 0e+384 -> 0
+ddfma2543 fma 0 1 0e+384 -> 0
+ddfma2544 fma -0 1 0e+384 -> 0
+ddfma2545 fma -1 0 0e+384 -> 0
+ddfma2546 fma -1 -0 0e+384 -> 0
+ddfma2547 fma 1 0 0e+384 -> 0
+ddfma2548 fma 1 -0 0e+384 -> 0
+
+ddfma2551 fma 0.0 -1 0e+384 -> 0.0
+ddfma2552 fma -0.0 -1 0e+384 -> 0.0
+ddfma2553 fma 0.0 1 0e+384 -> 0.0
+ddfma2554 fma -0.0 1 0e+384 -> 0.0
+ddfma2555 fma -1.0 0 0e+384 -> 0.0
+ddfma2556 fma -1.0 -0 0e+384 -> 0.0
+ddfma2557 fma 1.0 0 0e+384 -> 0.0
+ddfma2558 fma 1.0 -0 0e+384 -> 0.0
+
+ddfma2561 fma 0 -1.0 0e+384 -> 0.0
+ddfma2562 fma -0 -1.0 0e+384 -> 0.0
+ddfma2563 fma 0 1.0 0e+384 -> 0.0
+ddfma2564 fma -0 1.0 0e+384 -> 0.0
+ddfma2565 fma -1 0.0 0e+384 -> 0.0
+ddfma2566 fma -1 -0.0 0e+384 -> 0.0
+ddfma2567 fma 1 0.0 0e+384 -> 0.0
+ddfma2568 fma 1 -0.0 0e+384 -> 0.0
+
+ddfma2571 fma 0.0 -1.0 0e+384 -> 0.00
+ddfma2572 fma -0.0 -1.0 0e+384 -> 0.00
+ddfma2573 fma 0.0 1.0 0e+384 -> 0.00
+ddfma2574 fma -0.0 1.0 0e+384 -> 0.00
+ddfma2575 fma -1.0 0.0 0e+384 -> 0.00
+ddfma2576 fma -1.0 -0.0 0e+384 -> 0.00
+ddfma2577 fma 1.0 0.0 0e+384 -> 0.00
+ddfma2578 fma 1.0 -0.0 0e+384 -> 0.00
+
+-- Specials
+ddfma2580 fma Inf -Inf 0e+384 -> -Infinity
+ddfma2581 fma Inf -1000 0e+384 -> -Infinity
+ddfma2582 fma Inf -1 0e+384 -> -Infinity
+ddfma2583 fma Inf -0 0e+384 -> NaN Invalid_operation
+ddfma2584 fma Inf 0 0e+384 -> NaN Invalid_operation
+ddfma2585 fma Inf 1 0e+384 -> Infinity
+ddfma2586 fma Inf 1000 0e+384 -> Infinity
+ddfma2587 fma Inf Inf 0e+384 -> Infinity
+ddfma2588 fma -1000 Inf 0e+384 -> -Infinity
+ddfma2589 fma -Inf Inf 0e+384 -> -Infinity
+ddfma2590 fma -1 Inf 0e+384 -> -Infinity
+ddfma2591 fma -0 Inf 0e+384 -> NaN Invalid_operation
+ddfma2592 fma 0 Inf 0e+384 -> NaN Invalid_operation
+ddfma2593 fma 1 Inf 0e+384 -> Infinity
+ddfma2594 fma 1000 Inf 0e+384 -> Infinity
+ddfma2595 fma Inf Inf 0e+384 -> Infinity
+
+ddfma2600 fma -Inf -Inf 0e+384 -> Infinity
+ddfma2601 fma -Inf -1000 0e+384 -> Infinity
+ddfma2602 fma -Inf -1 0e+384 -> Infinity
+ddfma2603 fma -Inf -0 0e+384 -> NaN Invalid_operation
+ddfma2604 fma -Inf 0 0e+384 -> NaN Invalid_operation
+ddfma2605 fma -Inf 1 0e+384 -> -Infinity
+ddfma2606 fma -Inf 1000 0e+384 -> -Infinity
+ddfma2607 fma -Inf Inf 0e+384 -> -Infinity
+ddfma2608 fma -1000 Inf 0e+384 -> -Infinity
+ddfma2609 fma -Inf -Inf 0e+384 -> Infinity
+ddfma2610 fma -1 -Inf 0e+384 -> Infinity
+ddfma2611 fma -0 -Inf 0e+384 -> NaN Invalid_operation
+ddfma2612 fma 0 -Inf 0e+384 -> NaN Invalid_operation
+ddfma2613 fma 1 -Inf 0e+384 -> -Infinity
+ddfma2614 fma 1000 -Inf 0e+384 -> -Infinity
+ddfma2615 fma Inf -Inf 0e+384 -> -Infinity
+
+ddfma2621 fma NaN -Inf 0e+384 -> NaN
+ddfma2622 fma NaN -1000 0e+384 -> NaN
+ddfma2623 fma NaN -1 0e+384 -> NaN
+ddfma2624 fma NaN -0 0e+384 -> NaN
+ddfma2625 fma NaN 0 0e+384 -> NaN
+ddfma2626 fma NaN 1 0e+384 -> NaN
+ddfma2627 fma NaN 1000 0e+384 -> NaN
+ddfma2628 fma NaN Inf 0e+384 -> NaN
+ddfma2629 fma NaN NaN 0e+384 -> NaN
+ddfma2630 fma -Inf NaN 0e+384 -> NaN
+ddfma2631 fma -1000 NaN 0e+384 -> NaN
+ddfma2632 fma -1 NaN 0e+384 -> NaN
+ddfma2633 fma -0 NaN 0e+384 -> NaN
+ddfma2634 fma 0 NaN 0e+384 -> NaN
+ddfma2635 fma 1 NaN 0e+384 -> NaN
+ddfma2636 fma 1000 NaN 0e+384 -> NaN
+ddfma2637 fma Inf NaN 0e+384 -> NaN
+
+ddfma2641 fma sNaN -Inf 0e+384 -> NaN Invalid_operation
+ddfma2642 fma sNaN -1000 0e+384 -> NaN Invalid_operation
+ddfma2643 fma sNaN -1 0e+384 -> NaN Invalid_operation
+ddfma2644 fma sNaN -0 0e+384 -> NaN Invalid_operation
+ddfma2645 fma sNaN 0 0e+384 -> NaN Invalid_operation
+ddfma2646 fma sNaN 1 0e+384 -> NaN Invalid_operation
+ddfma2647 fma sNaN 1000 0e+384 -> NaN Invalid_operation
+ddfma2648 fma sNaN NaN 0e+384 -> NaN Invalid_operation
+ddfma2649 fma sNaN sNaN 0e+384 -> NaN Invalid_operation
+ddfma2650 fma NaN sNaN 0e+384 -> NaN Invalid_operation
+ddfma2651 fma -Inf sNaN 0e+384 -> NaN Invalid_operation
+ddfma2652 fma -1000 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2653 fma -1 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2654 fma -0 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2655 fma 0 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2656 fma 1 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2657 fma 1000 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2658 fma Inf sNaN 0e+384 -> NaN Invalid_operation
+ddfma2659 fma NaN sNaN 0e+384 -> NaN Invalid_operation
+
+-- propagating NaNs
+ddfma2661 fma NaN9 -Inf 0e+384 -> NaN9
+ddfma2662 fma NaN8 999 0e+384 -> NaN8
+ddfma2663 fma NaN71 Inf 0e+384 -> NaN71
+ddfma2664 fma NaN6 NaN5 0e+384 -> NaN6
+ddfma2665 fma -Inf NaN4 0e+384 -> NaN4
+ddfma2666 fma -999 NaN33 0e+384 -> NaN33
+ddfma2667 fma Inf NaN2 0e+384 -> NaN2
+
+ddfma2671 fma sNaN99 -Inf 0e+384 -> NaN99 Invalid_operation
+ddfma2672 fma sNaN98 -11 0e+384 -> NaN98 Invalid_operation
+ddfma2673 fma sNaN97 NaN 0e+384 -> NaN97 Invalid_operation
+ddfma2674 fma sNaN16 sNaN94 0e+384 -> NaN16 Invalid_operation
+ddfma2675 fma NaN95 sNaN93 0e+384 -> NaN93 Invalid_operation
+ddfma2676 fma -Inf sNaN92 0e+384 -> NaN92 Invalid_operation
+ddfma2677 fma 088 sNaN91 0e+384 -> NaN91 Invalid_operation
+ddfma2678 fma Inf sNaN90 0e+384 -> NaN90 Invalid_operation
+ddfma2679 fma NaN sNaN89 0e+384 -> NaN89 Invalid_operation
+
+ddfma2681 fma -NaN9 -Inf 0e+384 -> -NaN9
+ddfma2682 fma -NaN8 999 0e+384 -> -NaN8
+ddfma2683 fma -NaN71 Inf 0e+384 -> -NaN71
+ddfma2684 fma -NaN6 -NaN5 0e+384 -> -NaN6
+ddfma2685 fma -Inf -NaN4 0e+384 -> -NaN4
+ddfma2686 fma -999 -NaN33 0e+384 -> -NaN33
+ddfma2687 fma Inf -NaN2 0e+384 -> -NaN2
+
+ddfma2691 fma -sNaN99 -Inf 0e+384 -> -NaN99 Invalid_operation
+ddfma2692 fma -sNaN98 -11 0e+384 -> -NaN98 Invalid_operation
+ddfma2693 fma -sNaN97 NaN 0e+384 -> -NaN97 Invalid_operation
+ddfma2694 fma -sNaN16 -sNaN94 0e+384 -> -NaN16 Invalid_operation
+ddfma2695 fma -NaN95 -sNaN93 0e+384 -> -NaN93 Invalid_operation
+ddfma2696 fma -Inf -sNaN92 0e+384 -> -NaN92 Invalid_operation
+ddfma2697 fma 088 -sNaN91 0e+384 -> -NaN91 Invalid_operation
+ddfma2698 fma Inf -sNaN90 0e+384 -> -NaN90 Invalid_operation
+ddfma2699 fma -NaN -sNaN89 0e+384 -> -NaN89 Invalid_operation
+
+ddfma2701 fma -NaN -Inf 0e+384 -> -NaN
+ddfma2702 fma -NaN 999 0e+384 -> -NaN
+ddfma2703 fma -NaN Inf 0e+384 -> -NaN
+ddfma2704 fma -NaN -NaN 0e+384 -> -NaN
+ddfma2705 fma -Inf -NaN0 0e+384 -> -NaN
+ddfma2706 fma -999 -NaN 0e+384 -> -NaN
+ddfma2707 fma Inf -NaN 0e+384 -> -NaN
+
+ddfma2711 fma -sNaN -Inf 0e+384 -> -NaN Invalid_operation
+ddfma2712 fma -sNaN -11 0e+384 -> -NaN Invalid_operation
+ddfma2713 fma -sNaN00 NaN 0e+384 -> -NaN Invalid_operation
+ddfma2714 fma -sNaN -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2715 fma -NaN -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2716 fma -Inf -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2717 fma 088 -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2718 fma Inf -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2719 fma -NaN -sNaN 0e+384 -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+ddfma2751 fma 1e+277 1e+311 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2752 fma 1e+277 -1e+311 0e+384 -> -Infinity Overflow Inexact Rounded
+ddfma2753 fma -1e+277 1e+311 0e+384 -> -Infinity Overflow Inexact Rounded
+ddfma2754 fma -1e+277 -1e+311 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2755 fma 1e-277 1e-311 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2756 fma 1e-277 -1e-311 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2757 fma -1e-277 1e-311 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2758 fma -1e-277 -1e-311 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+ddfma2760 fma 1e-291 1e-101 0e+384 -> 1E-392 Subnormal
+ddfma2761 fma 1e-291 1e-102 0e+384 -> 1E-393 Subnormal
+ddfma2762 fma 1e-291 1e-103 0e+384 -> 1E-394 Subnormal
+ddfma2763 fma 1e-291 1e-104 0e+384 -> 1E-395 Subnormal
+ddfma2764 fma 1e-291 1e-105 0e+384 -> 1E-396 Subnormal
+ddfma2765 fma 1e-291 1e-106 0e+384 -> 1E-397 Subnormal
+ddfma2766 fma 1e-291 1e-107 0e+384 -> 1E-398 Subnormal
+ddfma2767 fma 1e-291 1e-108 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2768 fma 1e-291 1e-109 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2769 fma 1e-291 1e-110 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+ddfma2770 fma 1e+60 1e+321 0e+384 -> 1.000000000000E+381 Clamped
+ddfma2771 fma 1e+60 1e+322 0e+384 -> 1.0000000000000E+382 Clamped
+ddfma2772 fma 1e+60 1e+323 0e+384 -> 1.00000000000000E+383 Clamped
+ddfma2773 fma 1e+60 1e+324 0e+384 -> 1.000000000000000E+384 Clamped
+ddfma2774 fma 1e+60 1e+325 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2775 fma 1e+60 1e+326 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2776 fma 1e+60 1e+327 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2777 fma 1e+60 1e+328 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2778 fma 1e+60 1e+329 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2779 fma 1e+60 1e+330 0e+384 -> Infinity Overflow Inexact Rounded
+
+ddfma2801 fma 1.0000E-394 1 0e+384 -> 1.0000E-394 Subnormal
+ddfma2802 fma 1.000E-394 1e-1 0e+384 -> 1.000E-395 Subnormal
+ddfma2803 fma 1.00E-394 1e-2 0e+384 -> 1.00E-396 Subnormal
+ddfma2804 fma 1.0E-394 1e-3 0e+384 -> 1.0E-397 Subnormal
+ddfma2805 fma 1.0E-394 1e-4 0e+384 -> 1E-398 Subnormal Rounded
+ddfma2806 fma 1.3E-394 1e-4 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddfma2807 fma 1.5E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2808 fma 1.7E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2809 fma 2.3E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2810 fma 2.5E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2811 fma 2.7E-394 1e-4 0e+384 -> 3E-398 Underflow Subnormal Inexact Rounded
+ddfma2812 fma 1.49E-394 1e-4 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddfma2813 fma 1.50E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2814 fma 1.51E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2815 fma 2.49E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2816 fma 2.50E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2817 fma 2.51E-394 1e-4 0e+384 -> 3E-398 Underflow Subnormal Inexact Rounded
+
+ddfma2818 fma 1E-394 1e-4 0e+384 -> 1E-398 Subnormal
+ddfma2819 fma 3E-394 1e-5 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2820 fma 5E-394 1e-5 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2821 fma 7E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddfma2822 fma 9E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddfma2823 fma 9.9E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+
+ddfma2824 fma 1E-394 -1e-4 0e+384 -> -1E-398 Subnormal
+ddfma2825 fma 3E-394 -1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2826 fma -5E-394 1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2827 fma 7E-394 -1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddfma2828 fma -9E-394 1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddfma2829 fma 9.9E-394 -1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddfma2830 fma 3.0E-394 -1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+ddfma2831 fma 1.0E-199 1e-200 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2832 fma 1.0E-199 1e-199 0e+384 -> 1E-398 Subnormal Rounded
+ddfma2833 fma 1.0E-199 1e-198 0e+384 -> 1.0E-397 Subnormal
+ddfma2834 fma 2.0E-199 2e-198 0e+384 -> 4.0E-397 Subnormal
+ddfma2835 fma 4.0E-199 4e-198 0e+384 -> 1.60E-396 Subnormal
+ddfma2836 fma 10.0E-199 10e-198 0e+384 -> 1.000E-395 Subnormal
+ddfma2837 fma 30.0E-199 30e-198 0e+384 -> 9.000E-395 Subnormal
+ddfma2838 fma 40.0E-199 40e-188 0e+384 -> 1.6000E-384 Subnormal
+ddfma2839 fma 40.0E-199 40e-187 0e+384 -> 1.6000E-383
+ddfma2840 fma 40.0E-199 40e-186 0e+384 -> 1.6000E-382
+
+-- Long operand overflow may be a different path
+ddfma2870 fma 100 9.999E+383 0e+384 -> Infinity Inexact Overflow Rounded
+ddfma2871 fma 100 -9.999E+383 0e+384 -> -Infinity Inexact Overflow Rounded
+ddfma2872 fma 9.999E+383 100 0e+384 -> Infinity Inexact Overflow Rounded
+ddfma2873 fma -9.999E+383 100 0e+384 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+ddfma2881 fma 1.2347E-355 1.2347E-40 0e+384 -> 1.524E-395 Inexact Rounded Subnormal Underflow
+ddfma2882 fma 1.234E-355 1.234E-40 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddfma2883 fma 1.23E-355 1.23E-40 0e+384 -> 1.513E-395 Inexact Rounded Subnormal Underflow
+ddfma2884 fma 1.2E-355 1.2E-40 0e+384 -> 1.44E-395 Subnormal
+ddfma2885 fma 1.2E-355 1.2E-41 0e+384 -> 1.44E-396 Subnormal
+ddfma2886 fma 1.2E-355 1.2E-42 0e+384 -> 1.4E-397 Subnormal Inexact Rounded Underflow
+ddfma2887 fma 1.2E-355 1.3E-42 0e+384 -> 1.6E-397 Subnormal Inexact Rounded Underflow
+ddfma2888 fma 1.3E-355 1.3E-42 0e+384 -> 1.7E-397 Subnormal Inexact Rounded Underflow
+ddfma2889 fma 1.3E-355 1.3E-43 0e+384 -> 2E-398 Subnormal Inexact Rounded Underflow
+ddfma2890 fma 1.3E-356 1.3E-43 0e+384 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
+
+ddfma2891 fma 1.2345E-39 1.234E-355 0e+384 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
+ddfma2892 fma 1.23456E-39 1.234E-355 0e+384 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
+ddfma2893 fma 1.2345E-40 1.234E-355 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddfma2894 fma 1.23456E-40 1.234E-355 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddfma2895 fma 1.2345E-41 1.234E-355 0e+384 -> 1.52E-396 Inexact Rounded Subnormal Underflow
+ddfma2896 fma 1.23456E-41 1.234E-355 0e+384 -> 1.52E-396 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+ddfma2900 fma 0.3000000000E-191 0.3000000000E-191 0e+384 -> 9.00000000000000E-384 Subnormal Rounded
+ddfma2901 fma 0.3000000001E-191 0.3000000001E-191 0e+384 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
+ddfma2902 fma 9.999999999999999E-383 0.0999999999999 0e+384 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
+ddfma2903 fma 9.999999999999999E-383 0.09999999999999 0e+384 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
+ddfma2904 fma 9.999999999999999E-383 0.099999999999999 0e+384 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
+ddfma2905 fma 9.999999999999999E-383 0.0999999999999999 0e+384 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
+-- prove operands are exact
+ddfma2906 fma 9.999999999999999E-383 1 0e+384 -> 9.999999999999999E-383
+ddfma2907 fma 1 0.09999999999999999 0e+384 -> 0.09999999999999999
+-- the next rounds to Nmin
+ddfma2908 fma 9.999999999999999E-383 0.09999999999999999 0e+384 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+
+-- hugest
+ddfma2909 fma 9999999999999999 9999999999999999 0e+384 -> 9.999999999999998E+31 Inexact Rounded
+
+-- Null tests
+ddfma2990 fma 10 # 0e+384 -> NaN Invalid_operation
+ddfma2991 fma # 10 0e+384 -> NaN Invalid_operation
+
+
+-- ADDITION TESTS ------------------------------------------------------
+
+-- [first group are 'quick confidence check']
+ddfma3001 fma 1 1 1 -> 2
+ddfma3002 fma 1 2 3 -> 5
+ddfma3003 fma 1 '5.75' '3.3' -> 9.05
+ddfma3004 fma 1 '5' '-3' -> 2
+ddfma3005 fma 1 '-5' '-3' -> -8
+ddfma3006 fma 1 '-7' '2.5' -> -4.5
+ddfma3007 fma 1 '0.7' '0.3' -> 1.0
+ddfma3008 fma 1 '1.25' '1.25' -> 2.50
+ddfma3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
+ddfma3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
+
+-- 1234567890123456 1234567890123456
+ddfma3011 fma 1 '0.4444444444444446' '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
+ddfma3012 fma 1 '0.4444444444444445' '0.5555555555555555' -> '1.000000000000000' Rounded
+ddfma3013 fma 1 '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
+ddfma3014 fma 1 '4444444444444444' '0.49' -> '4444444444444444' Inexact Rounded
+ddfma3015 fma 1 '4444444444444444' '0.499' -> '4444444444444444' Inexact Rounded
+ddfma3016 fma 1 '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
+ddfma3017 fma 1 '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
+ddfma3018 fma 1 '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
+ddfma3019 fma 1 '4444444444444444' '0.501' -> '4444444444444445' Inexact Rounded
+ddfma3020 fma 1 '4444444444444444' '0.51' -> '4444444444444445' Inexact Rounded
+
+ddfma3021 fma 1 0 1 -> 1
+ddfma3022 fma 1 1 1 -> 2
+ddfma3023 fma 1 2 1 -> 3
+ddfma3024 fma 1 3 1 -> 4
+ddfma3025 fma 1 4 1 -> 5
+ddfma3026 fma 1 5 1 -> 6
+ddfma3027 fma 1 6 1 -> 7
+ddfma3028 fma 1 7 1 -> 8
+ddfma3029 fma 1 8 1 -> 9
+ddfma3030 fma 1 9 1 -> 10
+
+-- some carrying effects
+ddfma3031 fma 1 '0.9998' '0.0000' -> '0.9998'
+ddfma3032 fma 1 '0.9998' '0.0001' -> '0.9999'
+ddfma3033 fma 1 '0.9998' '0.0002' -> '1.0000'
+ddfma3034 fma 1 '0.9998' '0.0003' -> '1.0001'
+
+ddfma3035 fma 1 '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3036 fma 1 '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3037 fma 1 '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3038 fma 1 '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
+ddfma3039 fma 1 '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
+
+-- symmetry:
+ddfma3040 fma 1 '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3041 fma 1 '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3042 fma 1 '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3044 fma 1 '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
+ddfma3045 fma 1 '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
+
+-- same, without rounding
+ddfma3046 fma 1 '10000e+9' '7' -> '10000000000007'
+ddfma3047 fma 1 '10000e+9' '70' -> '10000000000070'
+ddfma3048 fma 1 '10000e+9' '700' -> '10000000000700'
+ddfma3049 fma 1 '10000e+9' '7000' -> '10000000007000'
+ddfma3050 fma 1 '10000e+9' '70000' -> '10000000070000'
+ddfma3051 fma 1 '10000e+9' '700000' -> '10000000700000'
+ddfma3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+ddfma3053 fma 1 '12' '7.00' -> '19.00'
+ddfma3054 fma 1 '1.3' '-1.07' -> '0.23'
+ddfma3055 fma 1 '1.3' '-1.30' -> '0.00'
+ddfma3056 fma 1 '1.3' '-2.07' -> '-0.77'
+ddfma3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
+
+-- leading zero preservation
+ddfma3061 fma 1 1 '0.0001' -> '1.0001'
+ddfma3062 fma 1 1 '0.00001' -> '1.00001'
+ddfma3063 fma 1 1 '0.000001' -> '1.000001'
+ddfma3064 fma 1 1 '0.0000001' -> '1.0000001'
+ddfma3065 fma 1 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+ddfma3070 fma 1 1 0 -> 1
+ddfma3071 fma 1 1 0. -> 1
+ddfma3072 fma 1 1 .0 -> 1.0
+ddfma3073 fma 1 1 0.0 -> 1.0
+ddfma3074 fma 1 1 0.00 -> 1.00
+ddfma3075 fma 1 0 1 -> 1
+ddfma3076 fma 1 0. 1 -> 1
+ddfma3077 fma 1 .0 1 -> 1.0
+ddfma3078 fma 1 0.0 1 -> 1.0
+ddfma3079 fma 1 0.00 1 -> 1.00
+
+-- some carries
+ddfma3080 fma 1 999999998 1 -> 999999999
+ddfma3081 fma 1 999999999 1 -> 1000000000
+ddfma3082 fma 1 99999999 1 -> 100000000
+ddfma3083 fma 1 9999999 1 -> 10000000
+ddfma3084 fma 1 999999 1 -> 1000000
+ddfma3085 fma 1 99999 1 -> 100000
+ddfma3086 fma 1 9999 1 -> 10000
+ddfma3087 fma 1 999 1 -> 1000
+ddfma3088 fma 1 99 1 -> 100
+ddfma3089 fma 1 9 1 -> 10
+
+
+-- more LHS swaps
+ddfma3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
+ddfma3091 fma 1 '-56267E-6' 0 -> '-0.056267'
+ddfma3092 fma 1 '-56267E-5' 0 -> '-0.56267'
+ddfma3093 fma 1 '-56267E-4' 0 -> '-5.6267'
+ddfma3094 fma 1 '-56267E-3' 0 -> '-56.267'
+ddfma3095 fma 1 '-56267E-2' 0 -> '-562.67'
+ddfma3096 fma 1 '-56267E-1' 0 -> '-5626.7'
+ddfma3097 fma 1 '-56267E-0' 0 -> '-56267'
+ddfma3098 fma 1 '-5E-10' 0 -> '-5E-10'
+ddfma3099 fma 1 '-5E-7' 0 -> '-5E-7'
+ddfma3100 fma 1 '-5E-6' 0 -> '-0.000005'
+ddfma3101 fma 1 '-5E-5' 0 -> '-0.00005'
+ddfma3102 fma 1 '-5E-4' 0 -> '-0.0005'
+ddfma3103 fma 1 '-5E-1' 0 -> '-0.5'
+ddfma3104 fma 1 '-5E0' 0 -> '-5'
+ddfma3105 fma 1 '-5E1' 0 -> '-50'
+ddfma3106 fma 1 '-5E5' 0 -> '-500000'
+ddfma3107 fma 1 '-5E15' 0 -> '-5000000000000000'
+ddfma3108 fma 1 '-5E16' 0 -> '-5.000000000000000E+16' Rounded
+ddfma3109 fma 1 '-5E17' 0 -> '-5.000000000000000E+17' Rounded
+ddfma3110 fma 1 '-5E18' 0 -> '-5.000000000000000E+18' Rounded
+ddfma3111 fma 1 '-5E100' 0 -> '-5.000000000000000E+100' Rounded
+
+-- more RHS swaps
+ddfma3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
+ddfma3114 fma 1 0 '-56267E-6' -> '-0.056267'
+ddfma3116 fma 1 0 '-56267E-5' -> '-0.56267'
+ddfma3117 fma 1 0 '-56267E-4' -> '-5.6267'
+ddfma3119 fma 1 0 '-56267E-3' -> '-56.267'
+ddfma3120 fma 1 0 '-56267E-2' -> '-562.67'
+ddfma3121 fma 1 0 '-56267E-1' -> '-5626.7'
+ddfma3122 fma 1 0 '-56267E-0' -> '-56267'
+ddfma3123 fma 1 0 '-5E-10' -> '-5E-10'
+ddfma3124 fma 1 0 '-5E-7' -> '-5E-7'
+ddfma3125 fma 1 0 '-5E-6' -> '-0.000005'
+ddfma3126 fma 1 0 '-5E-5' -> '-0.00005'
+ddfma3127 fma 1 0 '-5E-4' -> '-0.0005'
+ddfma3128 fma 1 0 '-5E-1' -> '-0.5'
+ddfma3129 fma 1 0 '-5E0' -> '-5'
+ddfma3130 fma 1 0 '-5E1' -> '-50'
+ddfma3131 fma 1 0 '-5E5' -> '-500000'
+ddfma3132 fma 1 0 '-5E15' -> '-5000000000000000'
+ddfma3133 fma 1 0 '-5E16' -> '-5.000000000000000E+16' Rounded
+ddfma3134 fma 1 0 '-5E17' -> '-5.000000000000000E+17' Rounded
+ddfma3135 fma 1 0 '-5E18' -> '-5.000000000000000E+18' Rounded
+ddfma3136 fma 1 0 '-5E100' -> '-5.000000000000000E+100' Rounded
+
+-- related
+ddfma3137 fma 1 1 '0E-19' -> '1.000000000000000' Rounded
+ddfma3138 fma 1 -1 '0E-19' -> '-1.000000000000000' Rounded
+ddfma3139 fma 1 '0E-19' 1 -> '1.000000000000000' Rounded
+ddfma3140 fma 1 '0E-19' -1 -> '-1.000000000000000' Rounded
+ddfma3141 fma 1 1E+11 0.0000 -> '100000000000.0000'
+ddfma3142 fma 1 1E+11 0.00000 -> '100000000000.0000' Rounded
+ddfma3143 fma 1 0.000 1E+12 -> '1000000000000.000'
+ddfma3144 fma 1 0.0000 1E+12 -> '1000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+ddfma3146 fma 1 '00.0' 0 -> '0.0'
+ddfma3147 fma 1 '0.00' 0 -> '0.00'
+ddfma3148 fma 1 0 '0.00' -> '0.00'
+ddfma3149 fma 1 0 '00.0' -> '0.0'
+ddfma3150 fma 1 '00.0' '0.00' -> '0.00'
+ddfma3151 fma 1 '0.00' '00.0' -> '0.00'
+ddfma3152 fma 1 '3' '.3' -> '3.3'
+ddfma3153 fma 1 '3.' '.3' -> '3.3'
+ddfma3154 fma 1 '3.0' '.3' -> '3.3'
+ddfma3155 fma 1 '3.00' '.3' -> '3.30'
+ddfma3156 fma 1 '3' '3' -> '6'
+ddfma3157 fma 1 '3' '+3' -> '6'
+ddfma3158 fma 1 '3' '-3' -> '0'
+ddfma3159 fma 1 '0.3' '-0.3' -> '0.0'
+ddfma3160 fma 1 '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+ddfma3161 fma 1 '1E+12' '-1' -> '999999999999'
+ddfma3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
+ddfma3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
+ddfma3164 fma 1 '-1' '1E+12' -> '999999999999'
+ddfma3165 fma 1 '7E+12' '-1' -> '6999999999999'
+ddfma3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
+ddfma3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
+ddfma3168 fma 1 '-1' '7E+12' -> '6999999999999'
+
+rounding: half_up
+-- 1.234567890123456 1234567890123456 1 234567890123456
+ddfma3170 fma 1 '4.444444444444444' '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
+ddfma3171 fma 1 '4.444444444444444' '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
+ddfma3172 fma 1 '4.444444444444444' '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
+ddfma3173 fma 1 '4.444444444444444' '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
+ddfma3174 fma 1 '4.444444444444444' '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
+ddfma3175 fma 1 '4.444444444444444' '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
+ddfma3176 fma 1 '4.444444444444444' '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
+ddfma3177 fma 1 '4.444444444444444' '0.5555555555555550' -> '4.999999999999999' Rounded
+ddfma3178 fma 1 '4.444444444444444' '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
+ddfma3179 fma 1 '4.444444444444444' '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
+ddfma3180 fma 1 '4.444444444444444' '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
+ddfma3181 fma 1 '4.444444444444444' '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
+ddfma3182 fma 1 '4.444444444444444' '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
+ddfma3183 fma 1 '4.444444444444444' '0.5555555555555540' -> '4.999999999999998' Rounded
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+ddfma3200 fma 1 '1234560123456789' 0 -> '1234560123456789'
+ddfma3201 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddfma3202 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddfma3203 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddfma3204 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddfma3205 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddfma3206 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddfma3207 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddfma3208 fma 1 '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
+ddfma3209 fma 1 '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
+ddfma3210 fma 1 '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
+ddfma3211 fma 1 '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
+ddfma3212 fma 1 '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
+ddfma3213 fma 1 '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
+ddfma3214 fma 1 '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
+ddfma3215 fma 1 '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
+ddfma3216 fma 1 '1234560123456789' 1 -> '1234560123456790'
+ddfma3217 fma 1 '1234560123456789' 1.000000001 -> '1234560123456790' Inexact Rounded
+ddfma3218 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddfma3219 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+
+rounding: half_even
+ddfma3220 fma 1 '1234560123456789' 0 -> '1234560123456789'
+ddfma3221 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddfma3222 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddfma3223 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddfma3224 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddfma3225 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddfma3226 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddfma3227 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddfma3228 fma 1 '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
+ddfma3229 fma 1 '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
+ddfma3230 fma 1 '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
+ddfma3231 fma 1 '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
+ddfma3232 fma 1 '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
+ddfma3233 fma 1 '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
+ddfma3234 fma 1 '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
+ddfma3235 fma 1 '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
+ddfma3236 fma 1 '1234560123456789' 1 -> '1234560123456790'
+ddfma3237 fma 1 '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
+ddfma3238 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddfma3239 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+-- critical few with even bottom digit...
+ddfma3240 fma 1 '1234560123456788' 0.499999999 -> '1234560123456788' Inexact Rounded
+ddfma3241 fma 1 '1234560123456788' 0.5 -> '1234560123456788' Inexact Rounded
+ddfma3242 fma 1 '1234560123456788' 0.500000001 -> '1234560123456789' Inexact Rounded
+
+rounding: down
+ddfma3250 fma 1 '1234560123456789' 0 -> '1234560123456789'
+ddfma3251 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddfma3252 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddfma3253 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddfma3254 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddfma3255 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddfma3256 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddfma3257 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddfma3258 fma 1 '1234560123456789' 0.5 -> '1234560123456789' Inexact Rounded
+ddfma3259 fma 1 '1234560123456789' 0.500000001 -> '1234560123456789' Inexact Rounded
+ddfma3260 fma 1 '1234560123456789' 0.500001 -> '1234560123456789' Inexact Rounded
+ddfma3261 fma 1 '1234560123456789' 0.51 -> '1234560123456789' Inexact Rounded
+ddfma3262 fma 1 '1234560123456789' 0.6 -> '1234560123456789' Inexact Rounded
+ddfma3263 fma 1 '1234560123456789' 0.9 -> '1234560123456789' Inexact Rounded
+ddfma3264 fma 1 '1234560123456789' 0.99999 -> '1234560123456789' Inexact Rounded
+ddfma3265 fma 1 '1234560123456789' 0.999999999 -> '1234560123456789' Inexact Rounded
+ddfma3266 fma 1 '1234560123456789' 1 -> '1234560123456790'
+ddfma3267 fma 1 '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
+ddfma3268 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddfma3269 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+ddfma3301 fma 1 -1 1 -> 0
+ddfma3302 fma 1 0 1 -> 1
+ddfma3303 fma 1 1 1 -> 2
+ddfma3304 fma 1 12 1 -> 13
+ddfma3305 fma 1 98 1 -> 99
+ddfma3306 fma 1 99 1 -> 100
+ddfma3307 fma 1 100 1 -> 101
+ddfma3308 fma 1 101 1 -> 102
+ddfma3309 fma 1 -1 -1 -> -2
+ddfma3310 fma 1 0 -1 -> -1
+ddfma3311 fma 1 1 -1 -> 0
+ddfma3312 fma 1 12 -1 -> 11
+ddfma3313 fma 1 98 -1 -> 97
+ddfma3314 fma 1 99 -1 -> 98
+ddfma3315 fma 1 100 -1 -> 99
+ddfma3316 fma 1 101 -1 -> 100
+
+ddfma3321 fma 1 -0.01 0.01 -> 0.00
+ddfma3322 fma 1 0.00 0.01 -> 0.01
+ddfma3323 fma 1 0.01 0.01 -> 0.02
+ddfma3324 fma 1 0.12 0.01 -> 0.13
+ddfma3325 fma 1 0.98 0.01 -> 0.99
+ddfma3326 fma 1 0.99 0.01 -> 1.00
+ddfma3327 fma 1 1.00 0.01 -> 1.01
+ddfma3328 fma 1 1.01 0.01 -> 1.02
+ddfma3329 fma 1 -0.01 -0.01 -> -0.02
+ddfma3330 fma 1 0.00 -0.01 -> -0.01
+ddfma3331 fma 1 0.01 -0.01 -> 0.00
+ddfma3332 fma 1 0.12 -0.01 -> 0.11
+ddfma3333 fma 1 0.98 -0.01 -> 0.97
+ddfma3334 fma 1 0.99 -0.01 -> 0.98
+ddfma3335 fma 1 1.00 -0.01 -> 0.99
+ddfma3336 fma 1 1.01 -0.01 -> 1.00
+
+-- some more cases where adding 0 affects the coefficient
+ddfma3340 fma 1 1E+3 0 -> 1000
+ddfma3341 fma 1 1E+15 0 -> 1000000000000000
+ddfma3342 fma 1 1E+16 0 -> 1.000000000000000E+16 Rounded
+ddfma3343 fma 1 1E+20 0 -> 1.000000000000000E+20 Rounded
+-- which simply follow from these cases ...
+ddfma3344 fma 1 1E+3 1 -> 1001
+ddfma3345 fma 1 1E+15 1 -> 1000000000000001
+ddfma3346 fma 1 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
+ddfma3347 fma 1 1E+20 1 -> 1.000000000000000E+20 Inexact Rounded
+ddfma3348 fma 1 1E+3 7 -> 1007
+ddfma3349 fma 1 1E+15 7 -> 1000000000000007
+ddfma3350 fma 1 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
+ddfma3351 fma 1 1E+20 7 -> 1.000000000000000E+20 Inexact Rounded
+
+-- tryzeros cases
+rounding: half_up
+ddfma3360 fma 1 0E+50 10000E+1 -> 1.0000E+5
+ddfma3361 fma 1 0E-50 10000E+1 -> 100000.0000000000 Rounded
+ddfma3362 fma 1 10000E+1 0E-50 -> 100000.0000000000 Rounded
+ddfma3363 fma 1 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
+ddfma3364 fma 1 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+ddfma3370 fma 1 999999999999999 815 -> 1000000000000814
+ddfma3371 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+rounding: half_up
+ddfma3372 fma 1 999999999999999 815 -> 1000000000000814
+ddfma3373 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+rounding: half_even
+ddfma3374 fma 1 999999999999999 815 -> 1000000000000814
+ddfma3375 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+
+-- ulp replacement tests
+ddfma3400 fma 1 1 77e-14 -> 1.00000000000077
+ddfma3401 fma 1 1 77e-15 -> 1.000000000000077
+ddfma3402 fma 1 1 77e-16 -> 1.000000000000008 Inexact Rounded
+ddfma3403 fma 1 1 77e-17 -> 1.000000000000001 Inexact Rounded
+ddfma3404 fma 1 1 77e-18 -> 1.000000000000000 Inexact Rounded
+ddfma3405 fma 1 1 77e-19 -> 1.000000000000000 Inexact Rounded
+ddfma3406 fma 1 1 77e-299 -> 1.000000000000000 Inexact Rounded
+
+ddfma3410 fma 1 10 77e-14 -> 10.00000000000077
+ddfma3411 fma 1 10 77e-15 -> 10.00000000000008 Inexact Rounded
+ddfma3412 fma 1 10 77e-16 -> 10.00000000000001 Inexact Rounded
+ddfma3413 fma 1 10 77e-17 -> 10.00000000000000 Inexact Rounded
+ddfma3414 fma 1 10 77e-18 -> 10.00000000000000 Inexact Rounded
+ddfma3415 fma 1 10 77e-19 -> 10.00000000000000 Inexact Rounded
+ddfma3416 fma 1 10 77e-299 -> 10.00000000000000 Inexact Rounded
+
+ddfma3420 fma 1 77e-14 1 -> 1.00000000000077
+ddfma3421 fma 1 77e-15 1 -> 1.000000000000077
+ddfma3422 fma 1 77e-16 1 -> 1.000000000000008 Inexact Rounded
+ddfma3423 fma 1 77e-17 1 -> 1.000000000000001 Inexact Rounded
+ddfma3424 fma 1 77e-18 1 -> 1.000000000000000 Inexact Rounded
+ddfma3425 fma 1 77e-19 1 -> 1.000000000000000 Inexact Rounded
+ddfma3426 fma 1 77e-299 1 -> 1.000000000000000 Inexact Rounded
+
+ddfma3430 fma 1 77e-14 10 -> 10.00000000000077
+ddfma3431 fma 1 77e-15 10 -> 10.00000000000008 Inexact Rounded
+ddfma3432 fma 1 77e-16 10 -> 10.00000000000001 Inexact Rounded
+ddfma3433 fma 1 77e-17 10 -> 10.00000000000000 Inexact Rounded
+ddfma3434 fma 1 77e-18 10 -> 10.00000000000000 Inexact Rounded
+ddfma3435 fma 1 77e-19 10 -> 10.00000000000000 Inexact Rounded
+ddfma3436 fma 1 77e-299 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+ddfma36440 fma 1 1 -77e-14 -> 0.99999999999923
+ddfma36441 fma 1 1 -77e-15 -> 0.999999999999923
+ddfma36442 fma 1 1 -77e-16 -> 0.9999999999999923
+ddfma36443 fma 1 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
+ddfma36444 fma 1 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
+ddfma36445 fma 1 1 -77e-19 -> 1.000000000000000 Inexact Rounded
+ddfma36446 fma 1 1 -77e-99 -> 1.000000000000000 Inexact Rounded
+
+ddfma36450 fma 1 10 -77e-14 -> 9.99999999999923
+ddfma36451 fma 1 10 -77e-15 -> 9.999999999999923
+ddfma36452 fma 1 10 -77e-16 -> 9.999999999999992 Inexact Rounded
+ddfma36453 fma 1 10 -77e-17 -> 9.999999999999999 Inexact Rounded
+ddfma36454 fma 1 10 -77e-18 -> 10.00000000000000 Inexact Rounded
+ddfma36455 fma 1 10 -77e-19 -> 10.00000000000000 Inexact Rounded
+ddfma36456 fma 1 10 -77e-99 -> 10.00000000000000 Inexact Rounded
+
+ddfma36460 fma 1 -77e-14 1 -> 0.99999999999923
+ddfma36461 fma 1 -77e-15 1 -> 0.999999999999923
+ddfma36462 fma 1 -77e-16 1 -> 0.9999999999999923
+ddfma36463 fma 1 -77e-17 1 -> 0.9999999999999992 Inexact Rounded
+ddfma36464 fma 1 -77e-18 1 -> 0.9999999999999999 Inexact Rounded
+ddfma36465 fma 1 -77e-19 1 -> 1.000000000000000 Inexact Rounded
+ddfma36466 fma 1 -77e-99 1 -> 1.000000000000000 Inexact Rounded
+
+ddfma36470 fma 1 -77e-14 10 -> 9.99999999999923
+ddfma36471 fma 1 -77e-15 10 -> 9.999999999999923
+ddfma36472 fma 1 -77e-16 10 -> 9.999999999999992 Inexact Rounded
+ddfma36473 fma 1 -77e-17 10 -> 9.999999999999999 Inexact Rounded
+ddfma36474 fma 1 -77e-18 10 -> 10.00000000000000 Inexact Rounded
+ddfma36475 fma 1 -77e-19 10 -> 10.00000000000000 Inexact Rounded
+ddfma36476 fma 1 -77e-99 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+ddfma36480 fma 1 -1 77e-14 -> -0.99999999999923
+ddfma36481 fma 1 -1 77e-15 -> -0.999999999999923
+ddfma36482 fma 1 -1 77e-16 -> -0.9999999999999923
+ddfma36483 fma 1 -1 77e-17 -> -0.9999999999999992 Inexact Rounded
+ddfma36484 fma 1 -1 77e-18 -> -0.9999999999999999 Inexact Rounded
+ddfma36485 fma 1 -1 77e-19 -> -1.000000000000000 Inexact Rounded
+ddfma36486 fma 1 -1 77e-99 -> -1.000000000000000 Inexact Rounded
+
+ddfma36490 fma 1 -10 77e-14 -> -9.99999999999923
+ddfma36491 fma 1 -10 77e-15 -> -9.999999999999923
+ddfma36492 fma 1 -10 77e-16 -> -9.999999999999992 Inexact Rounded
+ddfma36493 fma 1 -10 77e-17 -> -9.999999999999999 Inexact Rounded
+ddfma36494 fma 1 -10 77e-18 -> -10.00000000000000 Inexact Rounded
+ddfma36495 fma 1 -10 77e-19 -> -10.00000000000000 Inexact Rounded
+ddfma36496 fma 1 -10 77e-99 -> -10.00000000000000 Inexact Rounded
+
+ddfma36500 fma 1 77e-14 -1 -> -0.99999999999923
+ddfma36501 fma 1 77e-15 -1 -> -0.999999999999923
+ddfma36502 fma 1 77e-16 -1 -> -0.9999999999999923
+ddfma36503 fma 1 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
+ddfma36504 fma 1 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
+ddfma36505 fma 1 77e-19 -1 -> -1.000000000000000 Inexact Rounded
+ddfma36506 fma 1 77e-99 -1 -> -1.000000000000000 Inexact Rounded
+
+ddfma36510 fma 1 77e-14 -10 -> -9.99999999999923
+ddfma36511 fma 1 77e-15 -10 -> -9.999999999999923
+ddfma36512 fma 1 77e-16 -10 -> -9.999999999999992 Inexact Rounded
+ddfma36513 fma 1 77e-17 -10 -> -9.999999999999999 Inexact Rounded
+ddfma36514 fma 1 77e-18 -10 -> -10.00000000000000 Inexact Rounded
+ddfma36515 fma 1 77e-19 -10 -> -10.00000000000000 Inexact Rounded
+ddfma36516 fma 1 77e-99 -10 -> -10.00000000000000 Inexact Rounded
+
+-- and a couple more with longer RHS
+ddfma36520 fma 1 1 -7777e-16 -> 0.9999999999992223
+ddfma36521 fma 1 1 -7777e-17 -> 0.9999999999999222 Inexact Rounded
+ddfma36522 fma 1 1 -7777e-18 -> 0.9999999999999922 Inexact Rounded
+ddfma36523 fma 1 1 -7777e-19 -> 0.9999999999999992 Inexact Rounded
+ddfma36524 fma 1 1 -7777e-20 -> 0.9999999999999999 Inexact Rounded
+ddfma36525 fma 1 1 -7777e-21 -> 1.000000000000000 Inexact Rounded
+ddfma36526 fma 1 1 -7777e-22 -> 1.000000000000000 Inexact Rounded
+
+
+-- and some more residue effects and different roundings
+rounding: half_up
+ddfma36540 fma 1 '6543210123456789' 0 -> '6543210123456789'
+ddfma36541 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddfma36542 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddfma36543 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddfma36544 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddfma36545 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddfma36546 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddfma36547 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddfma36548 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+ddfma36549 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+ddfma36550 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+ddfma36551 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+ddfma36552 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+ddfma36553 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+ddfma36554 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+ddfma36555 fma 1 '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
+ddfma36556 fma 1 '6543210123456789' 1 -> '6543210123456790'
+ddfma36557 fma 1 '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
+ddfma36558 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddfma36559 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+rounding: half_even
+ddfma36560 fma 1 '6543210123456789' 0 -> '6543210123456789'
+ddfma36561 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddfma36562 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddfma36563 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddfma36564 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddfma36565 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddfma36566 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddfma36567 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddfma36568 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+ddfma36569 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+ddfma36570 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+ddfma36571 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+ddfma36572 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+ddfma36573 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+ddfma36574 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+ddfma36575 fma 1 '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
+ddfma36576 fma 1 '6543210123456789' 1 -> '6543210123456790'
+ddfma36577 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+ddfma36578 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddfma36579 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+-- critical few with even bottom digit...
+ddfma37540 fma 1 '6543210123456788' 0.499999999 -> '6543210123456788' Inexact Rounded
+ddfma37541 fma 1 '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
+ddfma37542 fma 1 '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
+
+rounding: down
+ddfma37550 fma 1 '6543210123456789' 0 -> '6543210123456789'
+ddfma37551 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddfma37552 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddfma37553 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddfma37554 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddfma37555 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddfma37556 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddfma37557 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddfma37558 fma 1 '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
+ddfma37559 fma 1 '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
+ddfma37560 fma 1 '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
+ddfma37561 fma 1 '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
+ddfma37562 fma 1 '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
+ddfma37563 fma 1 '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
+ddfma37564 fma 1 '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
+ddfma37565 fma 1 '6543210123456789' 0.999999999 -> '6543210123456789' Inexact Rounded
+ddfma37566 fma 1 '6543210123456789' 1 -> '6543210123456790'
+ddfma37567 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+ddfma37568 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddfma37569 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+
+-- verify a query
+rounding: down
+ddfma37661 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
+ddfma37662 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
+ddfma37663 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
+ddfma37664 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+ddfma37701 fma 1 5.00 1.00E-3 -> 5.00100
+ddfma37702 fma 1 00.00 0.000 -> 0.000
+ddfma37703 fma 1 00.00 0E-3 -> 0.000
+ddfma37704 fma 1 0E-3 00.00 -> 0.000
+
+ddfma37710 fma 1 0E+3 00.00 -> 0.00
+ddfma37711 fma 1 0E+3 00.0 -> 0.0
+ddfma37712 fma 1 0E+3 00. -> 0
+ddfma37713 fma 1 0E+3 00.E+1 -> 0E+1
+ddfma37714 fma 1 0E+3 00.E+2 -> 0E+2
+ddfma37715 fma 1 0E+3 00.E+3 -> 0E+3
+ddfma37716 fma 1 0E+3 00.E+4 -> 0E+3
+ddfma37717 fma 1 0E+3 00.E+5 -> 0E+3
+ddfma37718 fma 1 0E+3 -00.0 -> 0.0
+ddfma37719 fma 1 0E+3 -00. -> 0
+ddfma37731 fma 1 0E+3 -00.E+1 -> 0E+1
+
+ddfma37720 fma 1 00.00 0E+3 -> 0.00
+ddfma37721 fma 1 00.0 0E+3 -> 0.0
+ddfma37722 fma 1 00. 0E+3 -> 0
+ddfma37723 fma 1 00.E+1 0E+3 -> 0E+1
+ddfma37724 fma 1 00.E+2 0E+3 -> 0E+2
+ddfma37725 fma 1 00.E+3 0E+3 -> 0E+3
+ddfma37726 fma 1 00.E+4 0E+3 -> 0E+3
+ddfma37727 fma 1 00.E+5 0E+3 -> 0E+3
+ddfma37728 fma 1 -00.00 0E+3 -> 0.00
+ddfma37729 fma 1 -00.0 0E+3 -> 0.0
+ddfma37730 fma 1 -00. 0E+3 -> 0
+
+ddfma37732 fma 1 0 0 -> 0
+ddfma37733 fma 1 0 -0 -> 0
+ddfma37734 fma 1 -0 0 -> 0
+ddfma37735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
+
+ddfma37736 fma 1 1 -1 -> 0
+ddfma37737 fma 1 -1 -1 -> -2
+ddfma37738 fma 1 1 1 -> 2
+ddfma37739 fma 1 -1 1 -> 0
+
+ddfma37741 fma 1 0 -1 -> -1
+ddfma37742 fma 1 -0 -1 -> -1
+ddfma37743 fma 1 0 1 -> 1
+ddfma37744 fma 1 -0 1 -> 1
+ddfma37745 fma 1 -1 0 -> -1
+ddfma37746 fma 1 -1 -0 -> -1
+ddfma37747 fma 1 1 0 -> 1
+ddfma37748 fma 1 1 -0 -> 1
+
+ddfma37751 fma 1 0.0 -1 -> -1.0
+ddfma37752 fma 1 -0.0 -1 -> -1.0
+ddfma37753 fma 1 0.0 1 -> 1.0
+ddfma37754 fma 1 -0.0 1 -> 1.0
+ddfma37755 fma 1 -1.0 0 -> -1.0
+ddfma37756 fma 1 -1.0 -0 -> -1.0
+ddfma37757 fma 1 1.0 0 -> 1.0
+ddfma37758 fma 1 1.0 -0 -> 1.0
+
+ddfma37761 fma 1 0 -1.0 -> -1.0
+ddfma37762 fma 1 -0 -1.0 -> -1.0
+ddfma37763 fma 1 0 1.0 -> 1.0
+ddfma37764 fma 1 -0 1.0 -> 1.0
+ddfma37765 fma 1 -1 0.0 -> -1.0
+ddfma37766 fma 1 -1 -0.0 -> -1.0
+ddfma37767 fma 1 1 0.0 -> 1.0
+ddfma37768 fma 1 1 -0.0 -> 1.0
+
+ddfma37771 fma 1 0.0 -1.0 -> -1.0
+ddfma37772 fma 1 -0.0 -1.0 -> -1.0
+ddfma37773 fma 1 0.0 1.0 -> 1.0
+ddfma37774 fma 1 -0.0 1.0 -> 1.0
+ddfma37775 fma 1 -1.0 0.0 -> -1.0
+ddfma37776 fma 1 -1.0 -0.0 -> -1.0
+ddfma37777 fma 1 1.0 0.0 -> 1.0
+ddfma37778 fma 1 1.0 -0.0 -> 1.0
+
+-- Specials
+ddfma37780 fma 1 -Inf -Inf -> -Infinity
+ddfma37781 fma 1 -Inf -1000 -> -Infinity
+ddfma37782 fma 1 -Inf -1 -> -Infinity
+ddfma37783 fma 1 -Inf -0 -> -Infinity
+ddfma37784 fma 1 -Inf 0 -> -Infinity
+ddfma37785 fma 1 -Inf 1 -> -Infinity
+ddfma37786 fma 1 -Inf 1000 -> -Infinity
+ddfma37787 fma 1 -1000 -Inf -> -Infinity
+ddfma37788 fma 1 -Inf -Inf -> -Infinity
+ddfma37789 fma 1 -1 -Inf -> -Infinity
+ddfma37790 fma 1 -0 -Inf -> -Infinity
+ddfma37791 fma 1 0 -Inf -> -Infinity
+ddfma37792 fma 1 1 -Inf -> -Infinity
+ddfma37793 fma 1 1000 -Inf -> -Infinity
+ddfma37794 fma 1 Inf -Inf -> NaN Invalid_operation
+
+ddfma37800 fma 1 Inf -Inf -> NaN Invalid_operation
+ddfma37801 fma 1 Inf -1000 -> Infinity
+ddfma37802 fma 1 Inf -1 -> Infinity
+ddfma37803 fma 1 Inf -0 -> Infinity
+ddfma37804 fma 1 Inf 0 -> Infinity
+ddfma37805 fma 1 Inf 1 -> Infinity
+ddfma37806 fma 1 Inf 1000 -> Infinity
+ddfma37807 fma 1 Inf Inf -> Infinity
+ddfma37808 fma 1 -1000 Inf -> Infinity
+ddfma37809 fma 1 -Inf Inf -> NaN Invalid_operation
+ddfma37810 fma 1 -1 Inf -> Infinity
+ddfma37811 fma 1 -0 Inf -> Infinity
+ddfma37812 fma 1 0 Inf -> Infinity
+ddfma37813 fma 1 1 Inf -> Infinity
+ddfma37814 fma 1 1000 Inf -> Infinity
+ddfma37815 fma 1 Inf Inf -> Infinity
+
+ddfma37821 fma 1 NaN -Inf -> NaN
+ddfma37822 fma 1 NaN -1000 -> NaN
+ddfma37823 fma 1 NaN -1 -> NaN
+ddfma37824 fma 1 NaN -0 -> NaN
+ddfma37825 fma 1 NaN 0 -> NaN
+ddfma37826 fma 1 NaN 1 -> NaN
+ddfma37827 fma 1 NaN 1000 -> NaN
+ddfma37828 fma 1 NaN Inf -> NaN
+ddfma37829 fma 1 NaN NaN -> NaN
+ddfma37830 fma 1 -Inf NaN -> NaN
+ddfma37831 fma 1 -1000 NaN -> NaN
+ddfma37832 fma 1 -1 NaN -> NaN
+ddfma37833 fma 1 -0 NaN -> NaN
+ddfma37834 fma 1 0 NaN -> NaN
+ddfma37835 fma 1 1 NaN -> NaN
+ddfma37836 fma 1 1000 NaN -> NaN
+ddfma37837 fma 1 Inf NaN -> NaN
+
+ddfma37841 fma 1 sNaN -Inf -> NaN Invalid_operation
+ddfma37842 fma 1 sNaN -1000 -> NaN Invalid_operation
+ddfma37843 fma 1 sNaN -1 -> NaN Invalid_operation
+ddfma37844 fma 1 sNaN -0 -> NaN Invalid_operation
+ddfma37845 fma 1 sNaN 0 -> NaN Invalid_operation
+ddfma37846 fma 1 sNaN 1 -> NaN Invalid_operation
+ddfma37847 fma 1 sNaN 1000 -> NaN Invalid_operation
+ddfma37848 fma 1 sNaN NaN -> NaN Invalid_operation
+ddfma37849 fma 1 sNaN sNaN -> NaN Invalid_operation
+ddfma37850 fma 1 NaN sNaN -> NaN Invalid_operation
+ddfma37851 fma 1 -Inf sNaN -> NaN Invalid_operation
+ddfma37852 fma 1 -1000 sNaN -> NaN Invalid_operation
+ddfma37853 fma 1 -1 sNaN -> NaN Invalid_operation
+ddfma37854 fma 1 -0 sNaN -> NaN Invalid_operation
+ddfma37855 fma 1 0 sNaN -> NaN Invalid_operation
+ddfma37856 fma 1 1 sNaN -> NaN Invalid_operation
+ddfma37857 fma 1 1000 sNaN -> NaN Invalid_operation
+ddfma37858 fma 1 Inf sNaN -> NaN Invalid_operation
+ddfma37859 fma 1 NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddfma37861 fma 1 NaN1 -Inf -> NaN1
+ddfma37862 fma 1 +NaN2 -1000 -> NaN2
+ddfma37863 fma 1 NaN3 1000 -> NaN3
+ddfma37864 fma 1 NaN4 Inf -> NaN4
+ddfma37865 fma 1 NaN5 +NaN6 -> NaN5
+ddfma37866 fma 1 -Inf NaN7 -> NaN7
+ddfma37867 fma 1 -1000 NaN8 -> NaN8
+ddfma37868 fma 1 1000 NaN9 -> NaN9
+ddfma37869 fma 1 Inf +NaN10 -> NaN10
+ddfma37871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
+ddfma37872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
+ddfma37873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
+ddfma37874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
+ddfma37875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddfma37876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
+ddfma37877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
+ddfma37878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
+ddfma37879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
+ddfma37880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
+ddfma37881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddfma37882 fma 1 -NaN26 NaN28 -> -NaN26
+ddfma37883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddfma37884 fma 1 1000 -NaN30 -> -NaN30
+ddfma37885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Here we explore near the boundary of rounding a subnormal to Nmin
+ddfma37575 fma 1 1E-383 -1E-398 -> 9.99999999999999E-384 Subnormal
+ddfma37576 fma 1 -1E-383 +1E-398 -> -9.99999999999999E-384 Subnormal
+
+-- check overflow edge case
+-- 1234567890123456
+ddfma37972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
+ddfma37973 fma 1 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37974 fma 1 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37975 fma 1 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
+ddfma37976 fma 1 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
+ddfma37977 fma 1 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
+ddfma37978 fma 1 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
+ddfma37979 fma 1 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
+ddfma37980 fma 1 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
+ddfma37981 fma 1 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37982 fma 1 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37983 fma 1 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37984 fma 1 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
+
+ddfma37985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
+ddfma37986 fma 1 -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37987 fma 1 -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37988 fma 1 -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
+ddfma37989 fma 1 -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37990 fma 1 -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37991 fma 1 -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37992 fma 1 -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37993 fma 1 -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37994 fma 1 -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37995 fma 1 -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37996 fma 1 -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37997 fma 1 -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+ddfma371100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
+ddfma371101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
+ddfma371103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
+ddfma371104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
+ddfma371105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
+ddfma371106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
+ddfma371107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
+ddfma371108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
+ddfma371109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+ddfma371110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
+ddfma371111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
+ddfma371113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
+ddfma371114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
+ddfma371115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
+ddfma371116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
+ddfma371117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
+ddfma371118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
+ddfma371119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+ddfma371300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
+ddfma371311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
+ddfma371312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
+ddfma371313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
+ddfma371314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
+ddfma371315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
+ddfma371316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
+ddfma371317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
+ddfma371318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
+ddfma371319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
+ddfma371320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
+ddfma371321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
+ddfma371322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
+ddfma371323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
+ddfma371324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
+ddfma371325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
+
+ddfma371340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
+ddfma371341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
+
+ddfma371349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
+ddfma371350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
+ddfma371351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
+ddfma371352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
+ddfma371353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
+ddfma371354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
+ddfma371355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
+ddfma371356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
+ddfma371357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
+ddfma371358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
+ddfma371359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
+ddfma371360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
+ddfma371361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
+ddfma371362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
+ddfma371363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
+ddfma371364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
+ddfma371365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+ddfma371420 fma 1 0 1.123456789012345 -> 1.123456789012345
+ddfma371421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
+ddfma371422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
+ddfma371423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
+ddfma371424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
+ddfma371425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
+ddfma371426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
+ddfma371427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
+ddfma371428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
+ddfma371429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
+ddfma371430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
+ddfma371431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
+ddfma371432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
+ddfma371433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
+ddfma371434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
+ddfma371435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
+ddfma371436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
+ddfma371437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
+ddfma371438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
+ddfma371439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
+
+-- same, reversed 0
+ddfma371440 fma 1 1.123456789012345 0 -> 1.123456789012345
+ddfma371441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
+ddfma371442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
+ddfma371443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
+ddfma371444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
+ddfma371445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
+ddfma371446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
+ddfma371447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
+ddfma371448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
+ddfma371449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
+ddfma371450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
+ddfma371451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
+ddfma371452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
+ddfma371453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
+ddfma371454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
+ddfma371455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
+ddfma371456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
+ddfma371457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
+ddfma371458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
+ddfma371459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
+
+-- same, Es on the 0
+ddfma371460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
+ddfma371461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
+ddfma371462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
+ddfma371463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
+ddfma371464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
+ddfma371465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
+ddfma371466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
+ddfma371467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
+ddfma371468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
+ddfma371469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
+ddfma371470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
+ddfma371471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
+ddfma371472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
+ddfma371473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
+ddfma371474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
+ddfma371475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
+-- next four flag Rounded because the 0 extends the result
+ddfma371476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
+ddfma371477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
+ddfma371478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
+ddfma371479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+ddfma371500 fma 1 0 0E-19 -> 0E-19
+ddfma371501 fma 1 -0 0E-19 -> 0E-19
+ddfma371502 fma 1 0 -0E-19 -> 0E-19
+ddfma371503 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371511 fma 1 -11 11 -> 0
+ddfma371512 fma 1 11 -11 -> 0
+
+rounding: half_down
+-- exact zeros from zeros
+ddfma371520 fma 1 0 0E-19 -> 0E-19
+ddfma371521 fma 1 -0 0E-19 -> 0E-19
+ddfma371522 fma 1 0 -0E-19 -> 0E-19
+ddfma371523 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371531 fma 1 -11 11 -> 0
+ddfma371532 fma 1 11 -11 -> 0
+
+rounding: half_even
+-- exact zeros from zeros
+ddfma371540 fma 1 0 0E-19 -> 0E-19
+ddfma371541 fma 1 -0 0E-19 -> 0E-19
+ddfma371542 fma 1 0 -0E-19 -> 0E-19
+ddfma371543 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371551 fma 1 -11 11 -> 0
+ddfma371552 fma 1 11 -11 -> 0
+
+rounding: up
+-- exact zeros from zeros
+ddfma371560 fma 1 0 0E-19 -> 0E-19
+ddfma371561 fma 1 -0 0E-19 -> 0E-19
+ddfma371562 fma 1 0 -0E-19 -> 0E-19
+ddfma371563 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371571 fma 1 -11 11 -> 0
+ddfma371572 fma 1 11 -11 -> 0
+
+rounding: down
+-- exact zeros from zeros
+ddfma371580 fma 1 0 0E-19 -> 0E-19
+ddfma371581 fma 1 -0 0E-19 -> 0E-19
+ddfma371582 fma 1 0 -0E-19 -> 0E-19
+ddfma371583 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371591 fma 1 -11 11 -> 0
+ddfma371592 fma 1 11 -11 -> 0
+
+rounding: ceiling
+-- exact zeros from zeros
+ddfma371600 fma 1 0 0E-19 -> 0E-19
+ddfma371601 fma 1 -0 0E-19 -> 0E-19
+ddfma371602 fma 1 0 -0E-19 -> 0E-19
+ddfma371603 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371611 fma 1 -11 11 -> 0
+ddfma371612 fma 1 11 -11 -> 0
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+ddfma371620 fma 1 0 0E-19 -> 0E-19
+ddfma371621 fma 1 -0 0E-19 -> -0E-19 -- *
+ddfma371622 fma 1 0 -0E-19 -> -0E-19 -- *
+ddfma371623 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371631 fma 1 -11 11 -> -0 -- *
+ddfma371632 fma 1 11 -11 -> -0 -- *
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+ddfma371701 fma 1 130E-2 120E-2 -> 2.50
+ddfma371702 fma 1 130E-2 12E-1 -> 2.50
+ddfma371703 fma 1 130E-2 1E0 -> 2.30
+ddfma371704 fma 1 1E2 1E4 -> 1.01E+4
+ddfma371705 fma 1 130E-2 -120E-2 -> 0.10
+ddfma371706 fma 1 130E-2 -12E-1 -> 0.10
+ddfma371707 fma 1 130E-2 -1E0 -> 0.30
+ddfma371708 fma 1 1E2 -1E4 -> -9.9E+3
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+ddfma375001 fma 1 1234567890123456 1 -> 1234567890123457
+ddfma375002 fma 1 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
+ddfma375003 fma 1 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
+ddfma375004 fma 1 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
+ddfma375005 fma 1 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
+ddfma375006 fma 1 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
+ddfma375007 fma 1 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
+ddfma375008 fma 1 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
+ddfma375009 fma 1 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
+ddfma375010 fma 1 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
+ddfma375011 fma 1 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
+ddfma375012 fma 1 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
+ddfma375013 fma 1 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
+ddfma375014 fma 1 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
+ddfma375015 fma 1 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
+ddfma375016 fma 1 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
+ddfma375017 fma 1 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
+ddfma375018 fma 1 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
+ddfma375019 fma 1 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
+ddfma375020 fma 1 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
+ddfma375021 fma 1 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
+
+-- widening second argument at gap
+ddfma375030 fma 1 12345678 1 -> 12345679
+ddfma375031 fma 1 12345678 0.1 -> 12345678.1
+ddfma375032 fma 1 12345678 0.12 -> 12345678.12
+ddfma375033 fma 1 12345678 0.123 -> 12345678.123
+ddfma375034 fma 1 12345678 0.1234 -> 12345678.1234
+ddfma375035 fma 1 12345678 0.12345 -> 12345678.12345
+ddfma375036 fma 1 12345678 0.123456 -> 12345678.123456
+ddfma375037 fma 1 12345678 0.1234567 -> 12345678.1234567
+ddfma375038 fma 1 12345678 0.12345678 -> 12345678.12345678
+ddfma375039 fma 1 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
+ddfma375040 fma 1 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
+ddfma375041 fma 1 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
+ddfma375042 fma 1 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
+ddfma375043 fma 1 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
+ddfma375044 fma 1 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
+ddfma375045 fma 1 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
+ddfma375046 fma 1 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
+ddfma375047 fma 1 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
+ddfma375048 fma 1 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
+ddfma375049 fma 1 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+ddfma375050 fma 1 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
+ddfma375051 fma 1 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
+ddfma375052 fma 1 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
+ddfma375053 fma 1 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
+ddfma375054 fma 1 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
+ddfma375055 fma 1 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
+ddfma375056 fma 1 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
+ddfma375057 fma 1 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
+ddfma375060 fma 1 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
+ddfma375061 fma 1 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
+ddfma375062 fma 1 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
+ddfma375063 fma 1 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
+ddfma375064 fma 1 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
+ddfma375065 fma 1 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
+ddfma375066 fma 1 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
+ddfma375067 fma 1 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+ddfma375070 fma 1 12345678 1E-8 -> 12345678.00000001
+ddfma375071 fma 1 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
+ddfma375072 fma 1 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
+ddfma375073 fma 1 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
+ddfma375074 fma 1 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
+ddfma375075 fma 1 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
+ddfma375076 fma 1 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
+ddfma375077 fma 1 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
+ddfma375078 fma 1 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
+ddfma375079 fma 1 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
+ddfma375080 fma 1 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
+ddfma375081 fma 1 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
+ddfma375082 fma 1 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
+ddfma375083 fma 1 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
+ddfma375084 fma 1 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
+ddfma375085 fma 1 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
+ddfma375086 fma 1 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
+ddfma375087 fma 1 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
+ddfma375088 fma 1 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
+ddfma375089 fma 1 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
+
+-- desctructive subtraction (from remainder tests)
+
+-- +++ some of these will be off-by-one remainder vs remainderNear
+
+ddfma4000 fma -1234567890123454 1.000000000000001 1234567890123456 -> 0.765432109876546
+ddfma4001 fma -1234567890123443 1.00000000000001 1234567890123456 -> 0.65432109876557
+ddfma4002 fma -1234567890123332 1.0000000000001 1234567890123456 -> 0.5432109876668
+ddfma4003 fma -308641972530863 4.000000000000001 1234567890123455 -> 2.691358027469137
+ddfma4004 fma -308641972530863 4.000000000000001 1234567890123456 -> 3.691358027469137
+ddfma4005 fma -246913578024696 4.9999999999999 1234567890123456 -> 0.6913578024696
+ddfma4006 fma -246913578024691 4.99999999999999 1234567890123456 -> 3.46913578024691
+ddfma4007 fma -246913578024691 4.999999999999999 1234567890123456 -> 1.246913578024691
+ddfma4008 fma -246913578024691 5.000000000000001 1234567890123456 -> 0.753086421975309
+ddfma4009 fma -246913578024690 5.00000000000001 1234567890123456 -> 3.53086421975310
+ddfma4010 fma -246913578024686 5.0000000000001 1234567890123456 -> 1.3086421975314
+ddfma4011 fma -1234567890123455 1.000000000000001 1234567890123456 -> -0.234567890123455
+ddfma4012 fma -1234567890123444 1.00000000000001 1234567890123456 -> -0.34567890123444
+ddfma4013 fma -1234567890123333 1.0000000000001 1234567890123456 -> -0.4567890123333
+ddfma4014 fma -308641972530864 4.000000000000001 1234567890123455 -> -1.308641972530864
+ddfma4015 fma -308641972530864 4.000000000000001 1234567890123456 -> -0.308641972530864
+ddfma4016 fma -246913578024696 4.9999999999999 1234567890123456 -> 0.6913578024696
+ddfma4017 fma -246913578024692 4.99999999999999 1234567890123456 -> -1.53086421975308
+ddfma4018 fma -246913578024691 4.999999999999999 1234567890123456 -> 1.246913578024691
+ddfma4019 fma -246913578024691 5.000000000000001 1234567890123456 -> 0.753086421975309
+ddfma4020 fma -246913578024691 5.00000000000001 1234567890123456 -> -1.46913578024691
+ddfma4021 fma -246913578024686 5.0000000000001 1234567890123456 -> 1.3086421975314
+
+
+-- Null tests
+ddfma39990 fma 1 10 # -> NaN Invalid_operation
+ddfma39991 fma 1 # 10 -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/ddInvert.decTest b/Lib/test/decimaltestdata/ddInvert.decTest
index 5d19fba829..321e4e9ee9 100644
--- a/Lib/test/decimaltestdata/ddInvert.decTest
+++ b/Lib/test/decimaltestdata/ddInvert.decTest
@@ -1,202 +1,202 @@
-------------------------------------------------------------------------
--- ddInvert.decTest -- digitwise logical INVERT for decDoubles --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check (truth table)
-ddinv001 invert 0 -> 1111111111111111
-ddinv002 invert 1 -> 1111111111111110
-ddinv003 invert 10 -> 1111111111111101
-ddinv004 invert 111111111 -> 1111111000000000
-ddinv005 invert 000000000 -> 1111111111111111
--- and at msd and msd-1
-ddinv007 invert 0000000000000000 -> 1111111111111111
-ddinv008 invert 1000000000000000 -> 111111111111111
-ddinv009 invert 0000000000000000 -> 1111111111111111
-ddinv010 invert 0100000000000000 -> 1011111111111111
-ddinv011 invert 0111111111111111 -> 1000000000000000
-ddinv012 invert 1111111111111111 -> 0
-ddinv013 invert 0011111111111111 -> 1100000000000000
-ddinv014 invert 0111111111111111 -> 1000000000000000
-
--- Various lengths
--- 123456789 1234567890123456
-ddinv021 invert 111111111 -> 1111111000000000
-ddinv022 invert 111111111111 -> 1111000000000000
-ddinv023 invert 11111111 -> 1111111100000000
-ddinv025 invert 1111111 -> 1111111110000000
-ddinv026 invert 111111 -> 1111111111000000
-ddinv027 invert 11111 -> 1111111111100000
-ddinv028 invert 1111 -> 1111111111110000
-ddinv029 invert 111 -> 1111111111111000
-ddinv031 invert 11 -> 1111111111111100
-ddinv032 invert 1 -> 1111111111111110
-ddinv033 invert 111111111111 -> 1111000000000000
-ddinv034 invert 11111111111 -> 1111100000000000
-ddinv035 invert 1111111111 -> 1111110000000000
-ddinv036 invert 111111111 -> 1111111000000000
-
-ddinv040 invert 011111111 -> 1111111100000000
-ddinv041 invert 101111111 -> 1111111010000000
-ddinv042 invert 110111111 -> 1111111001000000
-ddinv043 invert 111011111 -> 1111111000100000
-ddinv044 invert 111101111 -> 1111111000010000
-ddinv045 invert 111110111 -> 1111111000001000
-ddinv046 invert 111111011 -> 1111111000000100
-ddinv047 invert 111111101 -> 1111111000000010
-ddinv048 invert 111111110 -> 1111111000000001
-ddinv049 invert 011111011 -> 1111111100000100
-ddinv050 invert 101111101 -> 1111111010000010
-ddinv051 invert 110111110 -> 1111111001000001
-ddinv052 invert 111011101 -> 1111111000100010
-ddinv053 invert 111101011 -> 1111111000010100
-ddinv054 invert 111110111 -> 1111111000001000
-ddinv055 invert 111101011 -> 1111111000010100
-ddinv056 invert 111011101 -> 1111111000100010
-ddinv057 invert 110111110 -> 1111111001000001
-ddinv058 invert 101111101 -> 1111111010000010
-ddinv059 invert 011111011 -> 1111111100000100
-
-ddinv080 invert 1000000011111111 -> 111111100000000
-ddinv081 invert 0100000101111111 -> 1011111010000000
-ddinv082 invert 0010000110111111 -> 1101111001000000
-ddinv083 invert 0001000111011111 -> 1110111000100000
-ddinv084 invert 0000100111101111 -> 1111011000010000
-ddinv085 invert 0000010111110111 -> 1111101000001000
-ddinv086 invert 0000001111111011 -> 1111110000000100
-ddinv087 invert 0000010111111101 -> 1111101000000010
-ddinv088 invert 0000100111111110 -> 1111011000000001
-ddinv089 invert 0001000011111011 -> 1110111100000100
-ddinv090 invert 0010000101111101 -> 1101111010000010
-ddinv091 invert 0100000110111110 -> 1011111001000001
-ddinv092 invert 1000000111011101 -> 111111000100010
-ddinv093 invert 0100000111101011 -> 1011111000010100
-ddinv094 invert 0010000111110111 -> 1101111000001000
-ddinv095 invert 0001000111101011 -> 1110111000010100
-ddinv096 invert 0000100111011101 -> 1111011000100010
-ddinv097 invert 0000010110111110 -> 1111101001000001
-ddinv098 invert 0000001101111101 -> 1111110010000010
-ddinv099 invert 0000010011111011 -> 1111101100000100
-
--- non-0/1 should not be accepted, nor should signs
-ddinv220 invert 111111112 -> NaN Invalid_operation
-ddinv221 invert 333333333 -> NaN Invalid_operation
-ddinv222 invert 555555555 -> NaN Invalid_operation
-ddinv223 invert 777777777 -> NaN Invalid_operation
-ddinv224 invert 999999999 -> NaN Invalid_operation
-ddinv225 invert 222222222 -> NaN Invalid_operation
-ddinv226 invert 444444444 -> NaN Invalid_operation
-ddinv227 invert 666666666 -> NaN Invalid_operation
-ddinv228 invert 888888888 -> NaN Invalid_operation
-ddinv229 invert 999999999 -> NaN Invalid_operation
-ddinv230 invert 999999999 -> NaN Invalid_operation
-ddinv231 invert 999999999 -> NaN Invalid_operation
-ddinv232 invert 999999999 -> NaN Invalid_operation
--- a few randoms
-ddinv240 invert 567468689 -> NaN Invalid_operation
-ddinv241 invert 567367689 -> NaN Invalid_operation
-ddinv242 invert -631917772 -> NaN Invalid_operation
-ddinv243 invert -756253257 -> NaN Invalid_operation
-ddinv244 invert 835590149 -> NaN Invalid_operation
--- test MSD
-ddinv250 invert 2000000000000000 -> NaN Invalid_operation
-ddinv251 invert 3000000000000000 -> NaN Invalid_operation
-ddinv252 invert 4000000000000000 -> NaN Invalid_operation
-ddinv253 invert 5000000000000000 -> NaN Invalid_operation
-ddinv254 invert 6000000000000000 -> NaN Invalid_operation
-ddinv255 invert 7000000000000000 -> NaN Invalid_operation
-ddinv256 invert 8000000000000000 -> NaN Invalid_operation
-ddinv257 invert 9000000000000000 -> NaN Invalid_operation
--- test MSD-1
-ddinv270 invert 0200001000000000 -> NaN Invalid_operation
-ddinv271 invert 0300000100000000 -> NaN Invalid_operation
-ddinv272 invert 0400000010000000 -> NaN Invalid_operation
-ddinv273 invert 0500000001000000 -> NaN Invalid_operation
-ddinv274 invert 1600000000100000 -> NaN Invalid_operation
-ddinv275 invert 1700000000010000 -> NaN Invalid_operation
-ddinv276 invert 1800000000001000 -> NaN Invalid_operation
-ddinv277 invert 1900000000000100 -> NaN Invalid_operation
--- test LSD
-ddinv280 invert 0010000000000002 -> NaN Invalid_operation
-ddinv281 invert 0001000000000003 -> NaN Invalid_operation
-ddinv282 invert 0000100000000004 -> NaN Invalid_operation
-ddinv283 invert 0000010000000005 -> NaN Invalid_operation
-ddinv284 invert 1000001000000006 -> NaN Invalid_operation
-ddinv285 invert 1000000100000007 -> NaN Invalid_operation
-ddinv286 invert 1000000010000008 -> NaN Invalid_operation
-ddinv287 invert 1000000001000009 -> NaN Invalid_operation
--- test Middie
-ddinv288 invert 0010000020000000 -> NaN Invalid_operation
-ddinv289 invert 0001000030000001 -> NaN Invalid_operation
-ddinv290 invert 0000100040000010 -> NaN Invalid_operation
-ddinv291 invert 0000010050000100 -> NaN Invalid_operation
-ddinv292 invert 1000001060001000 -> NaN Invalid_operation
-ddinv293 invert 1000000170010000 -> NaN Invalid_operation
-ddinv294 invert 1000000080100000 -> NaN Invalid_operation
-ddinv295 invert 1000000091000000 -> NaN Invalid_operation
--- sign
-ddinv296 invert -1000000001000000 -> NaN Invalid_operation
-ddinv299 invert 1000000001000000 -> 111111110111111
-
-
--- Nmax, Nmin, Ntiny-like
-ddinv341 invert 9.99999999E+299 -> NaN Invalid_operation
-ddinv342 invert 1E-299 -> NaN Invalid_operation
-ddinv343 invert 1.00000000E-299 -> NaN Invalid_operation
-ddinv344 invert 1E-207 -> NaN Invalid_operation
-ddinv345 invert -1E-207 -> NaN Invalid_operation
-ddinv346 invert -1.00000000E-299 -> NaN Invalid_operation
-ddinv347 invert -1E-299 -> NaN Invalid_operation
-ddinv348 invert -9.99999999E+299 -> NaN Invalid_operation
-
--- A few other non-integers
-ddinv361 invert 1.0 -> NaN Invalid_operation
-ddinv362 invert 1E+1 -> NaN Invalid_operation
-ddinv363 invert 0.0 -> NaN Invalid_operation
-ddinv364 invert 0E+1 -> NaN Invalid_operation
-ddinv365 invert 9.9 -> NaN Invalid_operation
-ddinv366 invert 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-ddinv788 invert -Inf -> NaN Invalid_operation
-ddinv794 invert Inf -> NaN Invalid_operation
-ddinv821 invert NaN -> NaN Invalid_operation
-ddinv841 invert sNaN -> NaN Invalid_operation
--- propagating NaNs
-ddinv861 invert NaN1 -> NaN Invalid_operation
-ddinv862 invert +NaN2 -> NaN Invalid_operation
-ddinv863 invert NaN3 -> NaN Invalid_operation
-ddinv864 invert NaN4 -> NaN Invalid_operation
-ddinv865 invert NaN5 -> NaN Invalid_operation
-ddinv871 invert sNaN11 -> NaN Invalid_operation
-ddinv872 invert sNaN12 -> NaN Invalid_operation
-ddinv873 invert sNaN13 -> NaN Invalid_operation
-ddinv874 invert sNaN14 -> NaN Invalid_operation
-ddinv875 invert sNaN15 -> NaN Invalid_operation
-ddinv876 invert NaN16 -> NaN Invalid_operation
-ddinv881 invert +NaN25 -> NaN Invalid_operation
-ddinv882 invert -NaN26 -> NaN Invalid_operation
-ddinv883 invert -sNaN27 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddInvert.decTest -- digitwise logical INVERT for decDoubles --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check (truth table)
+ddinv001 invert 0 -> 1111111111111111
+ddinv002 invert 1 -> 1111111111111110
+ddinv003 invert 10 -> 1111111111111101
+ddinv004 invert 111111111 -> 1111111000000000
+ddinv005 invert 000000000 -> 1111111111111111
+-- and at msd and msd-1
+ddinv007 invert 0000000000000000 -> 1111111111111111
+ddinv008 invert 1000000000000000 -> 111111111111111
+ddinv009 invert 0000000000000000 -> 1111111111111111
+ddinv010 invert 0100000000000000 -> 1011111111111111
+ddinv011 invert 0111111111111111 -> 1000000000000000
+ddinv012 invert 1111111111111111 -> 0
+ddinv013 invert 0011111111111111 -> 1100000000000000
+ddinv014 invert 0111111111111111 -> 1000000000000000
+
+-- Various lengths
+-- 123456789 1234567890123456
+ddinv021 invert 111111111 -> 1111111000000000
+ddinv022 invert 111111111111 -> 1111000000000000
+ddinv023 invert 11111111 -> 1111111100000000
+ddinv025 invert 1111111 -> 1111111110000000
+ddinv026 invert 111111 -> 1111111111000000
+ddinv027 invert 11111 -> 1111111111100000
+ddinv028 invert 1111 -> 1111111111110000
+ddinv029 invert 111 -> 1111111111111000
+ddinv031 invert 11 -> 1111111111111100
+ddinv032 invert 1 -> 1111111111111110
+ddinv033 invert 111111111111 -> 1111000000000000
+ddinv034 invert 11111111111 -> 1111100000000000
+ddinv035 invert 1111111111 -> 1111110000000000
+ddinv036 invert 111111111 -> 1111111000000000
+
+ddinv040 invert 011111111 -> 1111111100000000
+ddinv041 invert 101111111 -> 1111111010000000
+ddinv042 invert 110111111 -> 1111111001000000
+ddinv043 invert 111011111 -> 1111111000100000
+ddinv044 invert 111101111 -> 1111111000010000
+ddinv045 invert 111110111 -> 1111111000001000
+ddinv046 invert 111111011 -> 1111111000000100
+ddinv047 invert 111111101 -> 1111111000000010
+ddinv048 invert 111111110 -> 1111111000000001
+ddinv049 invert 011111011 -> 1111111100000100
+ddinv050 invert 101111101 -> 1111111010000010
+ddinv051 invert 110111110 -> 1111111001000001
+ddinv052 invert 111011101 -> 1111111000100010
+ddinv053 invert 111101011 -> 1111111000010100
+ddinv054 invert 111110111 -> 1111111000001000
+ddinv055 invert 111101011 -> 1111111000010100
+ddinv056 invert 111011101 -> 1111111000100010
+ddinv057 invert 110111110 -> 1111111001000001
+ddinv058 invert 101111101 -> 1111111010000010
+ddinv059 invert 011111011 -> 1111111100000100
+
+ddinv080 invert 1000000011111111 -> 111111100000000
+ddinv081 invert 0100000101111111 -> 1011111010000000
+ddinv082 invert 0010000110111111 -> 1101111001000000
+ddinv083 invert 0001000111011111 -> 1110111000100000
+ddinv084 invert 0000100111101111 -> 1111011000010000
+ddinv085 invert 0000010111110111 -> 1111101000001000
+ddinv086 invert 0000001111111011 -> 1111110000000100
+ddinv087 invert 0000010111111101 -> 1111101000000010
+ddinv088 invert 0000100111111110 -> 1111011000000001
+ddinv089 invert 0001000011111011 -> 1110111100000100
+ddinv090 invert 0010000101111101 -> 1101111010000010
+ddinv091 invert 0100000110111110 -> 1011111001000001
+ddinv092 invert 1000000111011101 -> 111111000100010
+ddinv093 invert 0100000111101011 -> 1011111000010100
+ddinv094 invert 0010000111110111 -> 1101111000001000
+ddinv095 invert 0001000111101011 -> 1110111000010100
+ddinv096 invert 0000100111011101 -> 1111011000100010
+ddinv097 invert 0000010110111110 -> 1111101001000001
+ddinv098 invert 0000001101111101 -> 1111110010000010
+ddinv099 invert 0000010011111011 -> 1111101100000100
+
+-- non-0/1 should not be accepted, nor should signs
+ddinv220 invert 111111112 -> NaN Invalid_operation
+ddinv221 invert 333333333 -> NaN Invalid_operation
+ddinv222 invert 555555555 -> NaN Invalid_operation
+ddinv223 invert 777777777 -> NaN Invalid_operation
+ddinv224 invert 999999999 -> NaN Invalid_operation
+ddinv225 invert 222222222 -> NaN Invalid_operation
+ddinv226 invert 444444444 -> NaN Invalid_operation
+ddinv227 invert 666666666 -> NaN Invalid_operation
+ddinv228 invert 888888888 -> NaN Invalid_operation
+ddinv229 invert 999999999 -> NaN Invalid_operation
+ddinv230 invert 999999999 -> NaN Invalid_operation
+ddinv231 invert 999999999 -> NaN Invalid_operation
+ddinv232 invert 999999999 -> NaN Invalid_operation
+-- a few randoms
+ddinv240 invert 567468689 -> NaN Invalid_operation
+ddinv241 invert 567367689 -> NaN Invalid_operation
+ddinv242 invert -631917772 -> NaN Invalid_operation
+ddinv243 invert -756253257 -> NaN Invalid_operation
+ddinv244 invert 835590149 -> NaN Invalid_operation
+-- test MSD
+ddinv250 invert 2000000000000000 -> NaN Invalid_operation
+ddinv251 invert 3000000000000000 -> NaN Invalid_operation
+ddinv252 invert 4000000000000000 -> NaN Invalid_operation
+ddinv253 invert 5000000000000000 -> NaN Invalid_operation
+ddinv254 invert 6000000000000000 -> NaN Invalid_operation
+ddinv255 invert 7000000000000000 -> NaN Invalid_operation
+ddinv256 invert 8000000000000000 -> NaN Invalid_operation
+ddinv257 invert 9000000000000000 -> NaN Invalid_operation
+-- test MSD-1
+ddinv270 invert 0200001000000000 -> NaN Invalid_operation
+ddinv271 invert 0300000100000000 -> NaN Invalid_operation
+ddinv272 invert 0400000010000000 -> NaN Invalid_operation
+ddinv273 invert 0500000001000000 -> NaN Invalid_operation
+ddinv274 invert 1600000000100000 -> NaN Invalid_operation
+ddinv275 invert 1700000000010000 -> NaN Invalid_operation
+ddinv276 invert 1800000000001000 -> NaN Invalid_operation
+ddinv277 invert 1900000000000100 -> NaN Invalid_operation
+-- test LSD
+ddinv280 invert 0010000000000002 -> NaN Invalid_operation
+ddinv281 invert 0001000000000003 -> NaN Invalid_operation
+ddinv282 invert 0000100000000004 -> NaN Invalid_operation
+ddinv283 invert 0000010000000005 -> NaN Invalid_operation
+ddinv284 invert 1000001000000006 -> NaN Invalid_operation
+ddinv285 invert 1000000100000007 -> NaN Invalid_operation
+ddinv286 invert 1000000010000008 -> NaN Invalid_operation
+ddinv287 invert 1000000001000009 -> NaN Invalid_operation
+-- test Middie
+ddinv288 invert 0010000020000000 -> NaN Invalid_operation
+ddinv289 invert 0001000030000001 -> NaN Invalid_operation
+ddinv290 invert 0000100040000010 -> NaN Invalid_operation
+ddinv291 invert 0000010050000100 -> NaN Invalid_operation
+ddinv292 invert 1000001060001000 -> NaN Invalid_operation
+ddinv293 invert 1000000170010000 -> NaN Invalid_operation
+ddinv294 invert 1000000080100000 -> NaN Invalid_operation
+ddinv295 invert 1000000091000000 -> NaN Invalid_operation
+-- sign
+ddinv296 invert -1000000001000000 -> NaN Invalid_operation
+ddinv299 invert 1000000001000000 -> 111111110111111
+
+
+-- Nmax, Nmin, Ntiny-like
+ddinv341 invert 9.99999999E+299 -> NaN Invalid_operation
+ddinv342 invert 1E-299 -> NaN Invalid_operation
+ddinv343 invert 1.00000000E-299 -> NaN Invalid_operation
+ddinv344 invert 1E-207 -> NaN Invalid_operation
+ddinv345 invert -1E-207 -> NaN Invalid_operation
+ddinv346 invert -1.00000000E-299 -> NaN Invalid_operation
+ddinv347 invert -1E-299 -> NaN Invalid_operation
+ddinv348 invert -9.99999999E+299 -> NaN Invalid_operation
+
+-- A few other non-integers
+ddinv361 invert 1.0 -> NaN Invalid_operation
+ddinv362 invert 1E+1 -> NaN Invalid_operation
+ddinv363 invert 0.0 -> NaN Invalid_operation
+ddinv364 invert 0E+1 -> NaN Invalid_operation
+ddinv365 invert 9.9 -> NaN Invalid_operation
+ddinv366 invert 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+ddinv788 invert -Inf -> NaN Invalid_operation
+ddinv794 invert Inf -> NaN Invalid_operation
+ddinv821 invert NaN -> NaN Invalid_operation
+ddinv841 invert sNaN -> NaN Invalid_operation
+-- propagating NaNs
+ddinv861 invert NaN1 -> NaN Invalid_operation
+ddinv862 invert +NaN2 -> NaN Invalid_operation
+ddinv863 invert NaN3 -> NaN Invalid_operation
+ddinv864 invert NaN4 -> NaN Invalid_operation
+ddinv865 invert NaN5 -> NaN Invalid_operation
+ddinv871 invert sNaN11 -> NaN Invalid_operation
+ddinv872 invert sNaN12 -> NaN Invalid_operation
+ddinv873 invert sNaN13 -> NaN Invalid_operation
+ddinv874 invert sNaN14 -> NaN Invalid_operation
+ddinv875 invert sNaN15 -> NaN Invalid_operation
+ddinv876 invert NaN16 -> NaN Invalid_operation
+ddinv881 invert +NaN25 -> NaN Invalid_operation
+ddinv882 invert -NaN26 -> NaN Invalid_operation
+ddinv883 invert -sNaN27 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddLogB.decTest b/Lib/test/decimaltestdata/ddLogB.decTest
index de728e5968..00589b60c3 100644
--- a/Lib/test/decimaltestdata/ddLogB.decTest
+++ b/Lib/test/decimaltestdata/ddLogB.decTest
@@ -1,159 +1,159 @@
-------------------------------------------------------------------------
--- ddLogB.decTest -- integral 754r adjusted exponent, for decDoubles --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- basics
-ddlogb000 logb 0 -> -Infinity Division_by_zero
-ddlogb001 logb 1E-398 -> -398
-ddlogb002 logb 1E-383 -> -383
-ddlogb003 logb 0.001 -> -3
-ddlogb004 logb 0.03 -> -2
-ddlogb005 logb 1 -> 0
-ddlogb006 logb 2 -> 0
-ddlogb007 logb 2.5 -> 0
-ddlogb008 logb 2.500 -> 0
-ddlogb009 logb 10 -> 1
-ddlogb010 logb 70 -> 1
-ddlogb011 logb 100 -> 2
-ddlogb012 logb 333 -> 2
-ddlogb013 logb 9E+384 -> 384
-ddlogb014 logb +Infinity -> Infinity
-
--- negatives appear to be treated as positives
-ddlogb021 logb -0 -> -Infinity Division_by_zero
-ddlogb022 logb -1E-398 -> -398
-ddlogb023 logb -9E-383 -> -383
-ddlogb024 logb -0.001 -> -3
-ddlogb025 logb -1 -> 0
-ddlogb026 logb -2 -> 0
-ddlogb027 logb -10 -> 1
-ddlogb028 logb -70 -> 1
-ddlogb029 logb -100 -> 2
-ddlogb030 logb -9E+384 -> 384
-ddlogb031 logb -Infinity -> Infinity
-
--- zeros
-ddlogb111 logb 0 -> -Infinity Division_by_zero
-ddlogb112 logb -0 -> -Infinity Division_by_zero
-ddlogb113 logb 0E+4 -> -Infinity Division_by_zero
-ddlogb114 logb -0E+4 -> -Infinity Division_by_zero
-ddlogb115 logb 0.0000 -> -Infinity Division_by_zero
-ddlogb116 logb -0.0000 -> -Infinity Division_by_zero
-ddlogb117 logb 0E-141 -> -Infinity Division_by_zero
-ddlogb118 logb -0E-141 -> -Infinity Division_by_zero
-
--- full coefficients, alternating bits
-ddlogb121 logb 268268268 -> 8
-ddlogb122 logb -268268268 -> 8
-ddlogb123 logb 134134134 -> 8
-ddlogb124 logb -134134134 -> 8
-
--- Nmax, Nmin, Ntiny
-ddlogb131 logb 9.999999999999999E+384 -> 384
-ddlogb132 logb 1E-383 -> -383
-ddlogb133 logb 1.000000000000000E-383 -> -383
-ddlogb134 logb 1E-398 -> -398
-
-ddlogb135 logb -1E-398 -> -398
-ddlogb136 logb -1.000000000000000E-383 -> -383
-ddlogb137 logb -1E-383 -> -383
-ddlogb138 logb -9.999999999999999E+384 -> 384
-
--- ones
-ddlogb0061 logb 1 -> 0
-ddlogb0062 logb 1.0 -> 0
-ddlogb0063 logb 1.000000000000000 -> 0
-
--- notable cases -- exact powers of 10
-ddlogb1100 logb 1 -> 0
-ddlogb1101 logb 10 -> 1
-ddlogb1102 logb 100 -> 2
-ddlogb1103 logb 1000 -> 3
-ddlogb1104 logb 10000 -> 4
-ddlogb1105 logb 100000 -> 5
-ddlogb1106 logb 1000000 -> 6
-ddlogb1107 logb 10000000 -> 7
-ddlogb1108 logb 100000000 -> 8
-ddlogb1109 logb 1000000000 -> 9
-ddlogb1110 logb 10000000000 -> 10
-ddlogb1111 logb 100000000000 -> 11
-ddlogb1112 logb 1000000000000 -> 12
-ddlogb1113 logb 0.00000000001 -> -11
-ddlogb1114 logb 0.0000000001 -> -10
-ddlogb1115 logb 0.000000001 -> -9
-ddlogb1116 logb 0.00000001 -> -8
-ddlogb1117 logb 0.0000001 -> -7
-ddlogb1118 logb 0.000001 -> -6
-ddlogb1119 logb 0.00001 -> -5
-ddlogb1120 logb 0.0001 -> -4
-ddlogb1121 logb 0.001 -> -3
-ddlogb1122 logb 0.01 -> -2
-ddlogb1123 logb 0.1 -> -1
-ddlogb1124 logb 1E-99 -> -99
-ddlogb1125 logb 1E-100 -> -100
-ddlogb1127 logb 1E-299 -> -299
-ddlogb1126 logb 1E-383 -> -383
-
--- suggestions from Ilan Nehama
-ddlogb1400 logb 10E-3 -> -2
-ddlogb1401 logb 10E-2 -> -1
-ddlogb1402 logb 100E-2 -> 0
-ddlogb1403 logb 1000E-2 -> 1
-ddlogb1404 logb 10000E-2 -> 2
-ddlogb1405 logb 10E-1 -> 0
-ddlogb1406 logb 100E-1 -> 1
-ddlogb1407 logb 1000E-1 -> 2
-ddlogb1408 logb 10000E-1 -> 3
-ddlogb1409 logb 10E0 -> 1
-ddlogb1410 logb 100E0 -> 2
-ddlogb1411 logb 1000E0 -> 3
-ddlogb1412 logb 10000E0 -> 4
-ddlogb1413 logb 10E1 -> 2
-ddlogb1414 logb 100E1 -> 3
-ddlogb1415 logb 1000E1 -> 4
-ddlogb1416 logb 10000E1 -> 5
-ddlogb1417 logb 10E2 -> 3
-ddlogb1418 logb 100E2 -> 4
-ddlogb1419 logb 1000E2 -> 5
-ddlogb1420 logb 10000E2 -> 6
-
--- special values
-ddlogb820 logb Infinity -> Infinity
-ddlogb821 logb 0 -> -Infinity Division_by_zero
-ddlogb822 logb NaN -> NaN
-ddlogb823 logb sNaN -> NaN Invalid_operation
--- propagating NaNs
-ddlogb824 logb sNaN123 -> NaN123 Invalid_operation
-ddlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
-ddlogb826 logb NaN456 -> NaN456
-ddlogb827 logb -NaN654 -> -NaN654
-ddlogb828 logb NaN1 -> NaN1
-
--- Null test
-ddlogb900 logb # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- ddLogB.decTest -- integral 754r adjusted exponent, for decDoubles --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- basics
+ddlogb000 logb 0 -> -Infinity Division_by_zero
+ddlogb001 logb 1E-398 -> -398
+ddlogb002 logb 1E-383 -> -383
+ddlogb003 logb 0.001 -> -3
+ddlogb004 logb 0.03 -> -2
+ddlogb005 logb 1 -> 0
+ddlogb006 logb 2 -> 0
+ddlogb007 logb 2.5 -> 0
+ddlogb008 logb 2.500 -> 0
+ddlogb009 logb 10 -> 1
+ddlogb010 logb 70 -> 1
+ddlogb011 logb 100 -> 2
+ddlogb012 logb 333 -> 2
+ddlogb013 logb 9E+384 -> 384
+ddlogb014 logb +Infinity -> Infinity
+
+-- negatives appear to be treated as positives
+ddlogb021 logb -0 -> -Infinity Division_by_zero
+ddlogb022 logb -1E-398 -> -398
+ddlogb023 logb -9E-383 -> -383
+ddlogb024 logb -0.001 -> -3
+ddlogb025 logb -1 -> 0
+ddlogb026 logb -2 -> 0
+ddlogb027 logb -10 -> 1
+ddlogb028 logb -70 -> 1
+ddlogb029 logb -100 -> 2
+ddlogb030 logb -9E+384 -> 384
+ddlogb031 logb -Infinity -> Infinity
+
+-- zeros
+ddlogb111 logb 0 -> -Infinity Division_by_zero
+ddlogb112 logb -0 -> -Infinity Division_by_zero
+ddlogb113 logb 0E+4 -> -Infinity Division_by_zero
+ddlogb114 logb -0E+4 -> -Infinity Division_by_zero
+ddlogb115 logb 0.0000 -> -Infinity Division_by_zero
+ddlogb116 logb -0.0000 -> -Infinity Division_by_zero
+ddlogb117 logb 0E-141 -> -Infinity Division_by_zero
+ddlogb118 logb -0E-141 -> -Infinity Division_by_zero
+
+-- full coefficients, alternating bits
+ddlogb121 logb 268268268 -> 8
+ddlogb122 logb -268268268 -> 8
+ddlogb123 logb 134134134 -> 8
+ddlogb124 logb -134134134 -> 8
+
+-- Nmax, Nmin, Ntiny
+ddlogb131 logb 9.999999999999999E+384 -> 384
+ddlogb132 logb 1E-383 -> -383
+ddlogb133 logb 1.000000000000000E-383 -> -383
+ddlogb134 logb 1E-398 -> -398
+
+ddlogb135 logb -1E-398 -> -398
+ddlogb136 logb -1.000000000000000E-383 -> -383
+ddlogb137 logb -1E-383 -> -383
+ddlogb138 logb -9.999999999999999E+384 -> 384
+
+-- ones
+ddlogb0061 logb 1 -> 0
+ddlogb0062 logb 1.0 -> 0
+ddlogb0063 logb 1.000000000000000 -> 0
+
+-- notable cases -- exact powers of 10
+ddlogb1100 logb 1 -> 0
+ddlogb1101 logb 10 -> 1
+ddlogb1102 logb 100 -> 2
+ddlogb1103 logb 1000 -> 3
+ddlogb1104 logb 10000 -> 4
+ddlogb1105 logb 100000 -> 5
+ddlogb1106 logb 1000000 -> 6
+ddlogb1107 logb 10000000 -> 7
+ddlogb1108 logb 100000000 -> 8
+ddlogb1109 logb 1000000000 -> 9
+ddlogb1110 logb 10000000000 -> 10
+ddlogb1111 logb 100000000000 -> 11
+ddlogb1112 logb 1000000000000 -> 12
+ddlogb1113 logb 0.00000000001 -> -11
+ddlogb1114 logb 0.0000000001 -> -10
+ddlogb1115 logb 0.000000001 -> -9
+ddlogb1116 logb 0.00000001 -> -8
+ddlogb1117 logb 0.0000001 -> -7
+ddlogb1118 logb 0.000001 -> -6
+ddlogb1119 logb 0.00001 -> -5
+ddlogb1120 logb 0.0001 -> -4
+ddlogb1121 logb 0.001 -> -3
+ddlogb1122 logb 0.01 -> -2
+ddlogb1123 logb 0.1 -> -1
+ddlogb1124 logb 1E-99 -> -99
+ddlogb1125 logb 1E-100 -> -100
+ddlogb1127 logb 1E-299 -> -299
+ddlogb1126 logb 1E-383 -> -383
+
+-- suggestions from Ilan Nehama
+ddlogb1400 logb 10E-3 -> -2
+ddlogb1401 logb 10E-2 -> -1
+ddlogb1402 logb 100E-2 -> 0
+ddlogb1403 logb 1000E-2 -> 1
+ddlogb1404 logb 10000E-2 -> 2
+ddlogb1405 logb 10E-1 -> 0
+ddlogb1406 logb 100E-1 -> 1
+ddlogb1407 logb 1000E-1 -> 2
+ddlogb1408 logb 10000E-1 -> 3
+ddlogb1409 logb 10E0 -> 1
+ddlogb1410 logb 100E0 -> 2
+ddlogb1411 logb 1000E0 -> 3
+ddlogb1412 logb 10000E0 -> 4
+ddlogb1413 logb 10E1 -> 2
+ddlogb1414 logb 100E1 -> 3
+ddlogb1415 logb 1000E1 -> 4
+ddlogb1416 logb 10000E1 -> 5
+ddlogb1417 logb 10E2 -> 3
+ddlogb1418 logb 100E2 -> 4
+ddlogb1419 logb 1000E2 -> 5
+ddlogb1420 logb 10000E2 -> 6
+
+-- special values
+ddlogb820 logb Infinity -> Infinity
+ddlogb821 logb 0 -> -Infinity Division_by_zero
+ddlogb822 logb NaN -> NaN
+ddlogb823 logb sNaN -> NaN Invalid_operation
+-- propagating NaNs
+ddlogb824 logb sNaN123 -> NaN123 Invalid_operation
+ddlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
+ddlogb826 logb NaN456 -> NaN456
+ddlogb827 logb -NaN654 -> -NaN654
+ddlogb828 logb NaN1 -> NaN1
+
+-- Null test
+ddlogb900 logb # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/ddMax.decTest b/Lib/test/decimaltestdata/ddMax.decTest
index 1ac63958b8..45ea9b4c93 100644
--- a/Lib/test/decimaltestdata/ddMax.decTest
+++ b/Lib/test/decimaltestdata/ddMax.decTest
@@ -1,322 +1,322 @@
-------------------------------------------------------------------------
--- ddMax.decTest -- decDouble maxnum --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmax001 max -2 -2 -> -2
-ddmax002 max -2 -1 -> -1
-ddmax003 max -2 0 -> 0
-ddmax004 max -2 1 -> 1
-ddmax005 max -2 2 -> 2
-ddmax006 max -1 -2 -> -1
-ddmax007 max -1 -1 -> -1
-ddmax008 max -1 0 -> 0
-ddmax009 max -1 1 -> 1
-ddmax010 max -1 2 -> 2
-ddmax011 max 0 -2 -> 0
-ddmax012 max 0 -1 -> 0
-ddmax013 max 0 0 -> 0
-ddmax014 max 0 1 -> 1
-ddmax015 max 0 2 -> 2
-ddmax016 max 1 -2 -> 1
-ddmax017 max 1 -1 -> 1
-ddmax018 max 1 0 -> 1
-ddmax019 max 1 1 -> 1
-ddmax020 max 1 2 -> 2
-ddmax021 max 2 -2 -> 2
-ddmax022 max 2 -1 -> 2
-ddmax023 max 2 0 -> 2
-ddmax025 max 2 1 -> 2
-ddmax026 max 2 2 -> 2
-
--- extended zeros
-ddmax030 max 0 0 -> 0
-ddmax031 max 0 -0 -> 0
-ddmax032 max 0 -0.0 -> 0
-ddmax033 max 0 0.0 -> 0
-ddmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-ddmax035 max -0 -0 -> -0
-ddmax036 max -0 -0.0 -> -0.0
-ddmax037 max -0 0.0 -> 0.0
-ddmax038 max 0.0 0 -> 0
-ddmax039 max 0.0 -0 -> 0.0
-ddmax040 max 0.0 -0.0 -> 0.0
-ddmax041 max 0.0 0.0 -> 0.0
-ddmax042 max -0.0 0 -> 0
-ddmax043 max -0.0 -0 -> -0.0
-ddmax044 max -0.0 -0.0 -> -0.0
-ddmax045 max -0.0 0.0 -> 0.0
-
-ddmax050 max -0E1 0E1 -> 0E+1
-ddmax051 max -0E2 0E2 -> 0E+2
-ddmax052 max -0E2 0E1 -> 0E+1
-ddmax053 max -0E1 0E2 -> 0E+2
-ddmax054 max 0E1 -0E1 -> 0E+1
-ddmax055 max 0E2 -0E2 -> 0E+2
-ddmax056 max 0E2 -0E1 -> 0E+2
-ddmax057 max 0E1 -0E2 -> 0E+1
-
-ddmax058 max 0E1 0E1 -> 0E+1
-ddmax059 max 0E2 0E2 -> 0E+2
-ddmax060 max 0E2 0E1 -> 0E+2
-ddmax061 max 0E1 0E2 -> 0E+2
-ddmax062 max -0E1 -0E1 -> -0E+1
-ddmax063 max -0E2 -0E2 -> -0E+2
-ddmax064 max -0E2 -0E1 -> -0E+1
-ddmax065 max -0E1 -0E2 -> -0E+1
-
--- Specials
-ddmax090 max Inf -Inf -> Infinity
-ddmax091 max Inf -1000 -> Infinity
-ddmax092 max Inf -1 -> Infinity
-ddmax093 max Inf -0 -> Infinity
-ddmax094 max Inf 0 -> Infinity
-ddmax095 max Inf 1 -> Infinity
-ddmax096 max Inf 1000 -> Infinity
-ddmax097 max Inf Inf -> Infinity
-ddmax098 max -1000 Inf -> Infinity
-ddmax099 max -Inf Inf -> Infinity
-ddmax100 max -1 Inf -> Infinity
-ddmax101 max -0 Inf -> Infinity
-ddmax102 max 0 Inf -> Infinity
-ddmax103 max 1 Inf -> Infinity
-ddmax104 max 1000 Inf -> Infinity
-ddmax105 max Inf Inf -> Infinity
-
-ddmax120 max -Inf -Inf -> -Infinity
-ddmax121 max -Inf -1000 -> -1000
-ddmax122 max -Inf -1 -> -1
-ddmax123 max -Inf -0 -> -0
-ddmax124 max -Inf 0 -> 0
-ddmax125 max -Inf 1 -> 1
-ddmax126 max -Inf 1000 -> 1000
-ddmax127 max -Inf Inf -> Infinity
-ddmax128 max -Inf -Inf -> -Infinity
-ddmax129 max -1000 -Inf -> -1000
-ddmax130 max -1 -Inf -> -1
-ddmax131 max -0 -Inf -> -0
-ddmax132 max 0 -Inf -> 0
-ddmax133 max 1 -Inf -> 1
-ddmax134 max 1000 -Inf -> 1000
-ddmax135 max Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-ddmax141 max NaN -Inf -> -Infinity
-ddmax142 max NaN -1000 -> -1000
-ddmax143 max NaN -1 -> -1
-ddmax144 max NaN -0 -> -0
-ddmax145 max NaN 0 -> 0
-ddmax146 max NaN 1 -> 1
-ddmax147 max NaN 1000 -> 1000
-ddmax148 max NaN Inf -> Infinity
-ddmax149 max NaN NaN -> NaN
-ddmax150 max -Inf NaN -> -Infinity
-ddmax151 max -1000 NaN -> -1000
-ddmax152 max -1 NaN -> -1
-ddmax153 max -0 NaN -> -0
-ddmax154 max 0 NaN -> 0
-ddmax155 max 1 NaN -> 1
-ddmax156 max 1000 NaN -> 1000
-ddmax157 max Inf NaN -> Infinity
-
-ddmax161 max sNaN -Inf -> NaN Invalid_operation
-ddmax162 max sNaN -1000 -> NaN Invalid_operation
-ddmax163 max sNaN -1 -> NaN Invalid_operation
-ddmax164 max sNaN -0 -> NaN Invalid_operation
-ddmax165 max sNaN 0 -> NaN Invalid_operation
-ddmax166 max sNaN 1 -> NaN Invalid_operation
-ddmax167 max sNaN 1000 -> NaN Invalid_operation
-ddmax168 max sNaN NaN -> NaN Invalid_operation
-ddmax169 max sNaN sNaN -> NaN Invalid_operation
-ddmax170 max NaN sNaN -> NaN Invalid_operation
-ddmax171 max -Inf sNaN -> NaN Invalid_operation
-ddmax172 max -1000 sNaN -> NaN Invalid_operation
-ddmax173 max -1 sNaN -> NaN Invalid_operation
-ddmax174 max -0 sNaN -> NaN Invalid_operation
-ddmax175 max 0 sNaN -> NaN Invalid_operation
-ddmax176 max 1 sNaN -> NaN Invalid_operation
-ddmax177 max 1000 sNaN -> NaN Invalid_operation
-ddmax178 max Inf sNaN -> NaN Invalid_operation
-ddmax179 max NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmax181 max NaN9 -Inf -> -Infinity
-ddmax182 max NaN8 9 -> 9
-ddmax183 max -NaN7 Inf -> Infinity
-
-ddmax184 max -NaN1 NaN11 -> -NaN1
-ddmax185 max NaN2 NaN12 -> NaN2
-ddmax186 max -NaN13 -NaN7 -> -NaN13
-ddmax187 max NaN14 -NaN5 -> NaN14
-
-ddmax188 max -Inf NaN4 -> -Infinity
-ddmax189 max -9 -NaN3 -> -9
-ddmax190 max Inf NaN2 -> Infinity
-
-ddmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
-ddmax192 max sNaN98 -1 -> NaN98 Invalid_operation
-ddmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
-ddmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
-ddmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
-ddmax197 max 0 sNaN91 -> NaN91 Invalid_operation
-ddmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmax199 max NaN sNaN89 -> NaN89 Invalid_operation
-
--- old rounding checks
-ddmax221 max 12345678000 1 -> 12345678000
-ddmax222 max 1 12345678000 -> 12345678000
-ddmax223 max 1234567800 1 -> 1234567800
-ddmax224 max 1 1234567800 -> 1234567800
-ddmax225 max 1234567890 1 -> 1234567890
-ddmax226 max 1 1234567890 -> 1234567890
-ddmax227 max 1234567891 1 -> 1234567891
-ddmax228 max 1 1234567891 -> 1234567891
-ddmax229 max 12345678901 1 -> 12345678901
-ddmax230 max 1 12345678901 -> 12345678901
-ddmax231 max 1234567896 1 -> 1234567896
-ddmax232 max 1 1234567896 -> 1234567896
-ddmax233 max -1234567891 1 -> 1
-ddmax234 max 1 -1234567891 -> 1
-ddmax235 max -12345678901 1 -> 1
-ddmax236 max 1 -12345678901 -> 1
-ddmax237 max -1234567896 1 -> 1
-ddmax238 max 1 -1234567896 -> 1
-
--- from examples
-ddmax280 max '3' '2' -> '3'
-ddmax281 max '-10' '3' -> '3'
-ddmax282 max '1.0' '1' -> '1'
-ddmax283 max '1' '1.0' -> '1'
-ddmax284 max '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-ddmax401 max Inf 1.1 -> Infinity
-ddmax402 max 1.1 1 -> 1.1
-ddmax403 max 1 1.0 -> 1
-ddmax404 max 1.0 0.1 -> 1.0
-ddmax405 max 0.1 0.10 -> 0.1
-ddmax406 max 0.10 0.100 -> 0.10
-ddmax407 max 0.10 0 -> 0.10
-ddmax408 max 0 0.0 -> 0
-ddmax409 max 0.0 -0 -> 0.0
-ddmax410 max 0.0 -0.0 -> 0.0
-ddmax411 max 0.00 -0.0 -> 0.00
-ddmax412 max 0.0 -0.00 -> 0.0
-ddmax413 max 0 -0.0 -> 0
-ddmax414 max 0 -0 -> 0
-ddmax415 max -0.0 -0 -> -0.0
-ddmax416 max -0 -0.100 -> -0
-ddmax417 max -0.100 -0.10 -> -0.100
-ddmax418 max -0.10 -0.1 -> -0.10
-ddmax419 max -0.1 -1.0 -> -0.1
-ddmax420 max -1.0 -1 -> -1.0
-ddmax421 max -1 -1.1 -> -1
-ddmax423 max -1.1 -Inf -> -1.1
--- same with operands reversed
-ddmax431 max 1.1 Inf -> Infinity
-ddmax432 max 1 1.1 -> 1.1
-ddmax433 max 1.0 1 -> 1
-ddmax434 max 0.1 1.0 -> 1.0
-ddmax435 max 0.10 0.1 -> 0.1
-ddmax436 max 0.100 0.10 -> 0.10
-ddmax437 max 0 0.10 -> 0.10
-ddmax438 max 0.0 0 -> 0
-ddmax439 max -0 0.0 -> 0.0
-ddmax440 max -0.0 0.0 -> 0.0
-ddmax441 max -0.0 0.00 -> 0.00
-ddmax442 max -0.00 0.0 -> 0.0
-ddmax443 max -0.0 0 -> 0
-ddmax444 max -0 0 -> 0
-ddmax445 max -0 -0.0 -> -0.0
-ddmax446 max -0.100 -0 -> -0
-ddmax447 max -0.10 -0.100 -> -0.100
-ddmax448 max -0.1 -0.10 -> -0.10
-ddmax449 max -1.0 -0.1 -> -0.1
-ddmax450 max -1 -1.0 -> -1.0
-ddmax451 max -1.1 -1 -> -1
-ddmax453 max -Inf -1.1 -> -1.1
--- largies
-ddmax460 max 1000 1E+3 -> 1E+3
-ddmax461 max 1E+3 1000 -> 1E+3
-ddmax462 max 1000 -1E+3 -> 1000
-ddmax463 max 1E+3 -1000 -> 1E+3
-ddmax464 max -1000 1E+3 -> 1E+3
-ddmax465 max -1E+3 1000 -> 1000
-ddmax466 max -1000 -1E+3 -> -1000
-ddmax467 max -1E+3 -1000 -> -1000
-
--- misalignment traps for little-endian
-ddmax471 max 1.0 0.1 -> 1.0
-ddmax472 max 0.1 1.0 -> 1.0
-ddmax473 max 10.0 0.1 -> 10.0
-ddmax474 max 0.1 10.0 -> 10.0
-ddmax475 max 100 1.0 -> 100
-ddmax476 max 1.0 100 -> 100
-ddmax477 max 1000 10.0 -> 1000
-ddmax478 max 10.0 1000 -> 1000
-ddmax479 max 10000 100.0 -> 10000
-ddmax480 max 100.0 10000 -> 10000
-ddmax481 max 100000 1000.0 -> 100000
-ddmax482 max 1000.0 100000 -> 100000
-ddmax483 max 1000000 10000.0 -> 1000000
-ddmax484 max 10000.0 1000000 -> 1000000
-
--- subnormals
-ddmax510 max 1.00E-383 0 -> 1.00E-383
-ddmax511 max 0.1E-383 0 -> 1E-384 Subnormal
-ddmax512 max 0.10E-383 0 -> 1.0E-384 Subnormal
-ddmax513 max 0.100E-383 0 -> 1.00E-384 Subnormal
-ddmax514 max 0.01E-383 0 -> 1E-385 Subnormal
-ddmax515 max 0.999E-383 0 -> 9.99E-384 Subnormal
-ddmax516 max 0.099E-383 0 -> 9.9E-385 Subnormal
-ddmax517 max 0.009E-383 0 -> 9E-386 Subnormal
-ddmax518 max 0.001E-383 0 -> 1E-386 Subnormal
-ddmax519 max 0.0009E-383 0 -> 9E-387 Subnormal
-ddmax520 max 0.0001E-383 0 -> 1E-387 Subnormal
-
-ddmax530 max -1.00E-383 0 -> 0
-ddmax531 max -0.1E-383 0 -> 0
-ddmax532 max -0.10E-383 0 -> 0
-ddmax533 max -0.100E-383 0 -> 0
-ddmax534 max -0.01E-383 0 -> 0
-ddmax535 max -0.999E-383 0 -> 0
-ddmax536 max -0.099E-383 0 -> 0
-ddmax537 max -0.009E-383 0 -> 0
-ddmax538 max -0.001E-383 0 -> 0
-ddmax539 max -0.0009E-383 0 -> 0
-ddmax540 max -0.0001E-383 0 -> 0
-
--- Null tests
-ddmax900 max 10 # -> NaN Invalid_operation
-ddmax901 max # 10 -> NaN Invalid_operation
-
-
-
+------------------------------------------------------------------------
+-- ddMax.decTest -- decDouble maxnum --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmax001 max -2 -2 -> -2
+ddmax002 max -2 -1 -> -1
+ddmax003 max -2 0 -> 0
+ddmax004 max -2 1 -> 1
+ddmax005 max -2 2 -> 2
+ddmax006 max -1 -2 -> -1
+ddmax007 max -1 -1 -> -1
+ddmax008 max -1 0 -> 0
+ddmax009 max -1 1 -> 1
+ddmax010 max -1 2 -> 2
+ddmax011 max 0 -2 -> 0
+ddmax012 max 0 -1 -> 0
+ddmax013 max 0 0 -> 0
+ddmax014 max 0 1 -> 1
+ddmax015 max 0 2 -> 2
+ddmax016 max 1 -2 -> 1
+ddmax017 max 1 -1 -> 1
+ddmax018 max 1 0 -> 1
+ddmax019 max 1 1 -> 1
+ddmax020 max 1 2 -> 2
+ddmax021 max 2 -2 -> 2
+ddmax022 max 2 -1 -> 2
+ddmax023 max 2 0 -> 2
+ddmax025 max 2 1 -> 2
+ddmax026 max 2 2 -> 2
+
+-- extended zeros
+ddmax030 max 0 0 -> 0
+ddmax031 max 0 -0 -> 0
+ddmax032 max 0 -0.0 -> 0
+ddmax033 max 0 0.0 -> 0
+ddmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+ddmax035 max -0 -0 -> -0
+ddmax036 max -0 -0.0 -> -0.0
+ddmax037 max -0 0.0 -> 0.0
+ddmax038 max 0.0 0 -> 0
+ddmax039 max 0.0 -0 -> 0.0
+ddmax040 max 0.0 -0.0 -> 0.0
+ddmax041 max 0.0 0.0 -> 0.0
+ddmax042 max -0.0 0 -> 0
+ddmax043 max -0.0 -0 -> -0.0
+ddmax044 max -0.0 -0.0 -> -0.0
+ddmax045 max -0.0 0.0 -> 0.0
+
+ddmax050 max -0E1 0E1 -> 0E+1
+ddmax051 max -0E2 0E2 -> 0E+2
+ddmax052 max -0E2 0E1 -> 0E+1
+ddmax053 max -0E1 0E2 -> 0E+2
+ddmax054 max 0E1 -0E1 -> 0E+1
+ddmax055 max 0E2 -0E2 -> 0E+2
+ddmax056 max 0E2 -0E1 -> 0E+2
+ddmax057 max 0E1 -0E2 -> 0E+1
+
+ddmax058 max 0E1 0E1 -> 0E+1
+ddmax059 max 0E2 0E2 -> 0E+2
+ddmax060 max 0E2 0E1 -> 0E+2
+ddmax061 max 0E1 0E2 -> 0E+2
+ddmax062 max -0E1 -0E1 -> -0E+1
+ddmax063 max -0E2 -0E2 -> -0E+2
+ddmax064 max -0E2 -0E1 -> -0E+1
+ddmax065 max -0E1 -0E2 -> -0E+1
+
+-- Specials
+ddmax090 max Inf -Inf -> Infinity
+ddmax091 max Inf -1000 -> Infinity
+ddmax092 max Inf -1 -> Infinity
+ddmax093 max Inf -0 -> Infinity
+ddmax094 max Inf 0 -> Infinity
+ddmax095 max Inf 1 -> Infinity
+ddmax096 max Inf 1000 -> Infinity
+ddmax097 max Inf Inf -> Infinity
+ddmax098 max -1000 Inf -> Infinity
+ddmax099 max -Inf Inf -> Infinity
+ddmax100 max -1 Inf -> Infinity
+ddmax101 max -0 Inf -> Infinity
+ddmax102 max 0 Inf -> Infinity
+ddmax103 max 1 Inf -> Infinity
+ddmax104 max 1000 Inf -> Infinity
+ddmax105 max Inf Inf -> Infinity
+
+ddmax120 max -Inf -Inf -> -Infinity
+ddmax121 max -Inf -1000 -> -1000
+ddmax122 max -Inf -1 -> -1
+ddmax123 max -Inf -0 -> -0
+ddmax124 max -Inf 0 -> 0
+ddmax125 max -Inf 1 -> 1
+ddmax126 max -Inf 1000 -> 1000
+ddmax127 max -Inf Inf -> Infinity
+ddmax128 max -Inf -Inf -> -Infinity
+ddmax129 max -1000 -Inf -> -1000
+ddmax130 max -1 -Inf -> -1
+ddmax131 max -0 -Inf -> -0
+ddmax132 max 0 -Inf -> 0
+ddmax133 max 1 -Inf -> 1
+ddmax134 max 1000 -Inf -> 1000
+ddmax135 max Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+ddmax141 max NaN -Inf -> -Infinity
+ddmax142 max NaN -1000 -> -1000
+ddmax143 max NaN -1 -> -1
+ddmax144 max NaN -0 -> -0
+ddmax145 max NaN 0 -> 0
+ddmax146 max NaN 1 -> 1
+ddmax147 max NaN 1000 -> 1000
+ddmax148 max NaN Inf -> Infinity
+ddmax149 max NaN NaN -> NaN
+ddmax150 max -Inf NaN -> -Infinity
+ddmax151 max -1000 NaN -> -1000
+ddmax152 max -1 NaN -> -1
+ddmax153 max -0 NaN -> -0
+ddmax154 max 0 NaN -> 0
+ddmax155 max 1 NaN -> 1
+ddmax156 max 1000 NaN -> 1000
+ddmax157 max Inf NaN -> Infinity
+
+ddmax161 max sNaN -Inf -> NaN Invalid_operation
+ddmax162 max sNaN -1000 -> NaN Invalid_operation
+ddmax163 max sNaN -1 -> NaN Invalid_operation
+ddmax164 max sNaN -0 -> NaN Invalid_operation
+ddmax165 max sNaN 0 -> NaN Invalid_operation
+ddmax166 max sNaN 1 -> NaN Invalid_operation
+ddmax167 max sNaN 1000 -> NaN Invalid_operation
+ddmax168 max sNaN NaN -> NaN Invalid_operation
+ddmax169 max sNaN sNaN -> NaN Invalid_operation
+ddmax170 max NaN sNaN -> NaN Invalid_operation
+ddmax171 max -Inf sNaN -> NaN Invalid_operation
+ddmax172 max -1000 sNaN -> NaN Invalid_operation
+ddmax173 max -1 sNaN -> NaN Invalid_operation
+ddmax174 max -0 sNaN -> NaN Invalid_operation
+ddmax175 max 0 sNaN -> NaN Invalid_operation
+ddmax176 max 1 sNaN -> NaN Invalid_operation
+ddmax177 max 1000 sNaN -> NaN Invalid_operation
+ddmax178 max Inf sNaN -> NaN Invalid_operation
+ddmax179 max NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmax181 max NaN9 -Inf -> -Infinity
+ddmax182 max NaN8 9 -> 9
+ddmax183 max -NaN7 Inf -> Infinity
+
+ddmax184 max -NaN1 NaN11 -> -NaN1
+ddmax185 max NaN2 NaN12 -> NaN2
+ddmax186 max -NaN13 -NaN7 -> -NaN13
+ddmax187 max NaN14 -NaN5 -> NaN14
+
+ddmax188 max -Inf NaN4 -> -Infinity
+ddmax189 max -9 -NaN3 -> -9
+ddmax190 max Inf NaN2 -> Infinity
+
+ddmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
+ddmax192 max sNaN98 -1 -> NaN98 Invalid_operation
+ddmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
+ddmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
+ddmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
+ddmax197 max 0 sNaN91 -> NaN91 Invalid_operation
+ddmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmax199 max NaN sNaN89 -> NaN89 Invalid_operation
+
+-- old rounding checks
+ddmax221 max 12345678000 1 -> 12345678000
+ddmax222 max 1 12345678000 -> 12345678000
+ddmax223 max 1234567800 1 -> 1234567800
+ddmax224 max 1 1234567800 -> 1234567800
+ddmax225 max 1234567890 1 -> 1234567890
+ddmax226 max 1 1234567890 -> 1234567890
+ddmax227 max 1234567891 1 -> 1234567891
+ddmax228 max 1 1234567891 -> 1234567891
+ddmax229 max 12345678901 1 -> 12345678901
+ddmax230 max 1 12345678901 -> 12345678901
+ddmax231 max 1234567896 1 -> 1234567896
+ddmax232 max 1 1234567896 -> 1234567896
+ddmax233 max -1234567891 1 -> 1
+ddmax234 max 1 -1234567891 -> 1
+ddmax235 max -12345678901 1 -> 1
+ddmax236 max 1 -12345678901 -> 1
+ddmax237 max -1234567896 1 -> 1
+ddmax238 max 1 -1234567896 -> 1
+
+-- from examples
+ddmax280 max '3' '2' -> '3'
+ddmax281 max '-10' '3' -> '3'
+ddmax282 max '1.0' '1' -> '1'
+ddmax283 max '1' '1.0' -> '1'
+ddmax284 max '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+ddmax401 max Inf 1.1 -> Infinity
+ddmax402 max 1.1 1 -> 1.1
+ddmax403 max 1 1.0 -> 1
+ddmax404 max 1.0 0.1 -> 1.0
+ddmax405 max 0.1 0.10 -> 0.1
+ddmax406 max 0.10 0.100 -> 0.10
+ddmax407 max 0.10 0 -> 0.10
+ddmax408 max 0 0.0 -> 0
+ddmax409 max 0.0 -0 -> 0.0
+ddmax410 max 0.0 -0.0 -> 0.0
+ddmax411 max 0.00 -0.0 -> 0.00
+ddmax412 max 0.0 -0.00 -> 0.0
+ddmax413 max 0 -0.0 -> 0
+ddmax414 max 0 -0 -> 0
+ddmax415 max -0.0 -0 -> -0.0
+ddmax416 max -0 -0.100 -> -0
+ddmax417 max -0.100 -0.10 -> -0.100
+ddmax418 max -0.10 -0.1 -> -0.10
+ddmax419 max -0.1 -1.0 -> -0.1
+ddmax420 max -1.0 -1 -> -1.0
+ddmax421 max -1 -1.1 -> -1
+ddmax423 max -1.1 -Inf -> -1.1
+-- same with operands reversed
+ddmax431 max 1.1 Inf -> Infinity
+ddmax432 max 1 1.1 -> 1.1
+ddmax433 max 1.0 1 -> 1
+ddmax434 max 0.1 1.0 -> 1.0
+ddmax435 max 0.10 0.1 -> 0.1
+ddmax436 max 0.100 0.10 -> 0.10
+ddmax437 max 0 0.10 -> 0.10
+ddmax438 max 0.0 0 -> 0
+ddmax439 max -0 0.0 -> 0.0
+ddmax440 max -0.0 0.0 -> 0.0
+ddmax441 max -0.0 0.00 -> 0.00
+ddmax442 max -0.00 0.0 -> 0.0
+ddmax443 max -0.0 0 -> 0
+ddmax444 max -0 0 -> 0
+ddmax445 max -0 -0.0 -> -0.0
+ddmax446 max -0.100 -0 -> -0
+ddmax447 max -0.10 -0.100 -> -0.100
+ddmax448 max -0.1 -0.10 -> -0.10
+ddmax449 max -1.0 -0.1 -> -0.1
+ddmax450 max -1 -1.0 -> -1.0
+ddmax451 max -1.1 -1 -> -1
+ddmax453 max -Inf -1.1 -> -1.1
+-- largies
+ddmax460 max 1000 1E+3 -> 1E+3
+ddmax461 max 1E+3 1000 -> 1E+3
+ddmax462 max 1000 -1E+3 -> 1000
+ddmax463 max 1E+3 -1000 -> 1E+3
+ddmax464 max -1000 1E+3 -> 1E+3
+ddmax465 max -1E+3 1000 -> 1000
+ddmax466 max -1000 -1E+3 -> -1000
+ddmax467 max -1E+3 -1000 -> -1000
+
+-- misalignment traps for little-endian
+ddmax471 max 1.0 0.1 -> 1.0
+ddmax472 max 0.1 1.0 -> 1.0
+ddmax473 max 10.0 0.1 -> 10.0
+ddmax474 max 0.1 10.0 -> 10.0
+ddmax475 max 100 1.0 -> 100
+ddmax476 max 1.0 100 -> 100
+ddmax477 max 1000 10.0 -> 1000
+ddmax478 max 10.0 1000 -> 1000
+ddmax479 max 10000 100.0 -> 10000
+ddmax480 max 100.0 10000 -> 10000
+ddmax481 max 100000 1000.0 -> 100000
+ddmax482 max 1000.0 100000 -> 100000
+ddmax483 max 1000000 10000.0 -> 1000000
+ddmax484 max 10000.0 1000000 -> 1000000
+
+-- subnormals
+ddmax510 max 1.00E-383 0 -> 1.00E-383
+ddmax511 max 0.1E-383 0 -> 1E-384 Subnormal
+ddmax512 max 0.10E-383 0 -> 1.0E-384 Subnormal
+ddmax513 max 0.100E-383 0 -> 1.00E-384 Subnormal
+ddmax514 max 0.01E-383 0 -> 1E-385 Subnormal
+ddmax515 max 0.999E-383 0 -> 9.99E-384 Subnormal
+ddmax516 max 0.099E-383 0 -> 9.9E-385 Subnormal
+ddmax517 max 0.009E-383 0 -> 9E-386 Subnormal
+ddmax518 max 0.001E-383 0 -> 1E-386 Subnormal
+ddmax519 max 0.0009E-383 0 -> 9E-387 Subnormal
+ddmax520 max 0.0001E-383 0 -> 1E-387 Subnormal
+
+ddmax530 max -1.00E-383 0 -> 0
+ddmax531 max -0.1E-383 0 -> 0
+ddmax532 max -0.10E-383 0 -> 0
+ddmax533 max -0.100E-383 0 -> 0
+ddmax534 max -0.01E-383 0 -> 0
+ddmax535 max -0.999E-383 0 -> 0
+ddmax536 max -0.099E-383 0 -> 0
+ddmax537 max -0.009E-383 0 -> 0
+ddmax538 max -0.001E-383 0 -> 0
+ddmax539 max -0.0009E-383 0 -> 0
+ddmax540 max -0.0001E-383 0 -> 0
+
+-- Null tests
+ddmax900 max 10 # -> NaN Invalid_operation
+ddmax901 max # 10 -> NaN Invalid_operation
+
+
+
diff --git a/Lib/test/decimaltestdata/ddMaxMag.decTest b/Lib/test/decimaltestdata/ddMaxMag.decTest
index 19c3e9085c..ec2b830541 100644
--- a/Lib/test/decimaltestdata/ddMaxMag.decTest
+++ b/Lib/test/decimaltestdata/ddMaxMag.decTest
@@ -1,304 +1,304 @@
-------------------------------------------------------------------------
--- ddMaxMag.decTest -- decDouble maxnummag --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmxg001 maxmag -2 -2 -> -2
-ddmxg002 maxmag -2 -1 -> -2
-ddmxg003 maxmag -2 0 -> -2
-ddmxg004 maxmag -2 1 -> -2
-ddmxg005 maxmag -2 2 -> 2
-ddmxg006 maxmag -1 -2 -> -2
-ddmxg007 maxmag -1 -1 -> -1
-ddmxg008 maxmag -1 0 -> -1
-ddmxg009 maxmag -1 1 -> 1
-ddmxg010 maxmag -1 2 -> 2
-ddmxg011 maxmag 0 -2 -> -2
-ddmxg012 maxmag 0 -1 -> -1
-ddmxg013 maxmag 0 0 -> 0
-ddmxg014 maxmag 0 1 -> 1
-ddmxg015 maxmag 0 2 -> 2
-ddmxg016 maxmag 1 -2 -> -2
-ddmxg017 maxmag 1 -1 -> 1
-ddmxg018 maxmag 1 0 -> 1
-ddmxg019 maxmag 1 1 -> 1
-ddmxg020 maxmag 1 2 -> 2
-ddmxg021 maxmag 2 -2 -> 2
-ddmxg022 maxmag 2 -1 -> 2
-ddmxg023 maxmag 2 0 -> 2
-ddmxg025 maxmag 2 1 -> 2
-ddmxg026 maxmag 2 2 -> 2
-
--- extended zeros
-ddmxg030 maxmag 0 0 -> 0
-ddmxg031 maxmag 0 -0 -> 0
-ddmxg032 maxmag 0 -0.0 -> 0
-ddmxg033 maxmag 0 0.0 -> 0
-ddmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-ddmxg035 maxmag -0 -0 -> -0
-ddmxg036 maxmag -0 -0.0 -> -0.0
-ddmxg037 maxmag -0 0.0 -> 0.0
-ddmxg038 maxmag 0.0 0 -> 0
-ddmxg039 maxmag 0.0 -0 -> 0.0
-ddmxg040 maxmag 0.0 -0.0 -> 0.0
-ddmxg041 maxmag 0.0 0.0 -> 0.0
-ddmxg042 maxmag -0.0 0 -> 0
-ddmxg043 maxmag -0.0 -0 -> -0.0
-ddmxg044 maxmag -0.0 -0.0 -> -0.0
-ddmxg045 maxmag -0.0 0.0 -> 0.0
-
-ddmxg050 maxmag -0E1 0E1 -> 0E+1
-ddmxg051 maxmag -0E2 0E2 -> 0E+2
-ddmxg052 maxmag -0E2 0E1 -> 0E+1
-ddmxg053 maxmag -0E1 0E2 -> 0E+2
-ddmxg054 maxmag 0E1 -0E1 -> 0E+1
-ddmxg055 maxmag 0E2 -0E2 -> 0E+2
-ddmxg056 maxmag 0E2 -0E1 -> 0E+2
-ddmxg057 maxmag 0E1 -0E2 -> 0E+1
-
-ddmxg058 maxmag 0E1 0E1 -> 0E+1
-ddmxg059 maxmag 0E2 0E2 -> 0E+2
-ddmxg060 maxmag 0E2 0E1 -> 0E+2
-ddmxg061 maxmag 0E1 0E2 -> 0E+2
-ddmxg062 maxmag -0E1 -0E1 -> -0E+1
-ddmxg063 maxmag -0E2 -0E2 -> -0E+2
-ddmxg064 maxmag -0E2 -0E1 -> -0E+1
-ddmxg065 maxmag -0E1 -0E2 -> -0E+1
-
--- Specials
-ddmxg090 maxmag Inf -Inf -> Infinity
-ddmxg091 maxmag Inf -1000 -> Infinity
-ddmxg092 maxmag Inf -1 -> Infinity
-ddmxg093 maxmag Inf -0 -> Infinity
-ddmxg094 maxmag Inf 0 -> Infinity
-ddmxg095 maxmag Inf 1 -> Infinity
-ddmxg096 maxmag Inf 1000 -> Infinity
-ddmxg097 maxmag Inf Inf -> Infinity
-ddmxg098 maxmag -1000 Inf -> Infinity
-ddmxg099 maxmag -Inf Inf -> Infinity
-ddmxg100 maxmag -1 Inf -> Infinity
-ddmxg101 maxmag -0 Inf -> Infinity
-ddmxg102 maxmag 0 Inf -> Infinity
-ddmxg103 maxmag 1 Inf -> Infinity
-ddmxg104 maxmag 1000 Inf -> Infinity
-ddmxg105 maxmag Inf Inf -> Infinity
-
-ddmxg120 maxmag -Inf -Inf -> -Infinity
-ddmxg121 maxmag -Inf -1000 -> -Infinity
-ddmxg122 maxmag -Inf -1 -> -Infinity
-ddmxg123 maxmag -Inf -0 -> -Infinity
-ddmxg124 maxmag -Inf 0 -> -Infinity
-ddmxg125 maxmag -Inf 1 -> -Infinity
-ddmxg126 maxmag -Inf 1000 -> -Infinity
-ddmxg127 maxmag -Inf Inf -> Infinity
-ddmxg128 maxmag -Inf -Inf -> -Infinity
-ddmxg129 maxmag -1000 -Inf -> -Infinity
-ddmxg130 maxmag -1 -Inf -> -Infinity
-ddmxg131 maxmag -0 -Inf -> -Infinity
-ddmxg132 maxmag 0 -Inf -> -Infinity
-ddmxg133 maxmag 1 -Inf -> -Infinity
-ddmxg134 maxmag 1000 -Inf -> -Infinity
-ddmxg135 maxmag Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-ddmxg141 maxmag NaN -Inf -> -Infinity
-ddmxg142 maxmag NaN -1000 -> -1000
-ddmxg143 maxmag NaN -1 -> -1
-ddmxg144 maxmag NaN -0 -> -0
-ddmxg145 maxmag NaN 0 -> 0
-ddmxg146 maxmag NaN 1 -> 1
-ddmxg147 maxmag NaN 1000 -> 1000
-ddmxg148 maxmag NaN Inf -> Infinity
-ddmxg149 maxmag NaN NaN -> NaN
-ddmxg150 maxmag -Inf NaN -> -Infinity
-ddmxg151 maxmag -1000 NaN -> -1000
-ddmxg152 maxmag -1 NaN -> -1
-ddmxg153 maxmag -0 NaN -> -0
-ddmxg154 maxmag 0 NaN -> 0
-ddmxg155 maxmag 1 NaN -> 1
-ddmxg156 maxmag 1000 NaN -> 1000
-ddmxg157 maxmag Inf NaN -> Infinity
-
-ddmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
-ddmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
-ddmxg163 maxmag sNaN -1 -> NaN Invalid_operation
-ddmxg164 maxmag sNaN -0 -> NaN Invalid_operation
-ddmxg165 maxmag sNaN 0 -> NaN Invalid_operation
-ddmxg166 maxmag sNaN 1 -> NaN Invalid_operation
-ddmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
-ddmxg168 maxmag sNaN NaN -> NaN Invalid_operation
-ddmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
-ddmxg170 maxmag NaN sNaN -> NaN Invalid_operation
-ddmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
-ddmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
-ddmxg173 maxmag -1 sNaN -> NaN Invalid_operation
-ddmxg174 maxmag -0 sNaN -> NaN Invalid_operation
-ddmxg175 maxmag 0 sNaN -> NaN Invalid_operation
-ddmxg176 maxmag 1 sNaN -> NaN Invalid_operation
-ddmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
-ddmxg178 maxmag Inf sNaN -> NaN Invalid_operation
-ddmxg179 maxmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmxg181 maxmag NaN9 -Inf -> -Infinity
-ddmxg182 maxmag NaN8 9 -> 9
-ddmxg183 maxmag -NaN7 Inf -> Infinity
-
-ddmxg184 maxmag -NaN1 NaN11 -> -NaN1
-ddmxg185 maxmag NaN2 NaN12 -> NaN2
-ddmxg186 maxmag -NaN13 -NaN7 -> -NaN13
-ddmxg187 maxmag NaN14 -NaN5 -> NaN14
-
-ddmxg188 maxmag -Inf NaN4 -> -Infinity
-ddmxg189 maxmag -9 -NaN3 -> -9
-ddmxg190 maxmag Inf NaN2 -> Infinity
-
-ddmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
-ddmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
-ddmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
-ddmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
-ddmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
-ddmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
-ddmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
-
--- old rounding checks
-ddmxg221 maxmag 12345678000 1 -> 12345678000
-ddmxg222 maxmag 1 12345678000 -> 12345678000
-ddmxg223 maxmag 1234567800 1 -> 1234567800
-ddmxg224 maxmag 1 1234567800 -> 1234567800
-ddmxg225 maxmag 1234567890 1 -> 1234567890
-ddmxg226 maxmag 1 1234567890 -> 1234567890
-ddmxg227 maxmag 1234567891 1 -> 1234567891
-ddmxg228 maxmag 1 1234567891 -> 1234567891
-ddmxg229 maxmag 12345678901 1 -> 12345678901
-ddmxg230 maxmag 1 12345678901 -> 12345678901
-ddmxg231 maxmag 1234567896 1 -> 1234567896
-ddmxg232 maxmag 1 1234567896 -> 1234567896
-ddmxg233 maxmag -1234567891 1 -> -1234567891
-ddmxg234 maxmag 1 -1234567891 -> -1234567891
-ddmxg235 maxmag -12345678901 1 -> -12345678901
-ddmxg236 maxmag 1 -12345678901 -> -12345678901
-ddmxg237 maxmag -1234567896 1 -> -1234567896
-ddmxg238 maxmag 1 -1234567896 -> -1234567896
-
--- from examples
-ddmxg280 maxmag '3' '2' -> '3'
-ddmxg281 maxmag '-10' '3' -> '-10'
-ddmxg282 maxmag '1.0' '1' -> '1'
-ddmxg283 maxmag '1' '1.0' -> '1'
-ddmxg284 maxmag '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-ddmxg401 maxmag Inf 1.1 -> Infinity
-ddmxg402 maxmag 1.1 1 -> 1.1
-ddmxg403 maxmag 1 1.0 -> 1
-ddmxg404 maxmag 1.0 0.1 -> 1.0
-ddmxg405 maxmag 0.1 0.10 -> 0.1
-ddmxg406 maxmag 0.10 0.100 -> 0.10
-ddmxg407 maxmag 0.10 0 -> 0.10
-ddmxg408 maxmag 0 0.0 -> 0
-ddmxg409 maxmag 0.0 -0 -> 0.0
-ddmxg410 maxmag 0.0 -0.0 -> 0.0
-ddmxg411 maxmag 0.00 -0.0 -> 0.00
-ddmxg412 maxmag 0.0 -0.00 -> 0.0
-ddmxg413 maxmag 0 -0.0 -> 0
-ddmxg414 maxmag 0 -0 -> 0
-ddmxg415 maxmag -0.0 -0 -> -0.0
-ddmxg416 maxmag -0 -0.100 -> -0.100
-ddmxg417 maxmag -0.100 -0.10 -> -0.100
-ddmxg418 maxmag -0.10 -0.1 -> -0.10
-ddmxg419 maxmag -0.1 -1.0 -> -1.0
-ddmxg420 maxmag -1.0 -1 -> -1.0
-ddmxg421 maxmag -1 -1.1 -> -1.1
-ddmxg423 maxmag -1.1 -Inf -> -Infinity
--- same with operands reversed
-ddmxg431 maxmag 1.1 Inf -> Infinity
-ddmxg432 maxmag 1 1.1 -> 1.1
-ddmxg433 maxmag 1.0 1 -> 1
-ddmxg434 maxmag 0.1 1.0 -> 1.0
-ddmxg435 maxmag 0.10 0.1 -> 0.1
-ddmxg436 maxmag 0.100 0.10 -> 0.10
-ddmxg437 maxmag 0 0.10 -> 0.10
-ddmxg438 maxmag 0.0 0 -> 0
-ddmxg439 maxmag -0 0.0 -> 0.0
-ddmxg440 maxmag -0.0 0.0 -> 0.0
-ddmxg441 maxmag -0.0 0.00 -> 0.00
-ddmxg442 maxmag -0.00 0.0 -> 0.0
-ddmxg443 maxmag -0.0 0 -> 0
-ddmxg444 maxmag -0 0 -> 0
-ddmxg445 maxmag -0 -0.0 -> -0.0
-ddmxg446 maxmag -0.100 -0 -> -0.100
-ddmxg447 maxmag -0.10 -0.100 -> -0.100
-ddmxg448 maxmag -0.1 -0.10 -> -0.10
-ddmxg449 maxmag -1.0 -0.1 -> -1.0
-ddmxg450 maxmag -1 -1.0 -> -1.0
-ddmxg451 maxmag -1.1 -1 -> -1.1
-ddmxg453 maxmag -Inf -1.1 -> -Infinity
--- largies
-ddmxg460 maxmag 1000 1E+3 -> 1E+3
-ddmxg461 maxmag 1E+3 1000 -> 1E+3
-ddmxg462 maxmag 1000 -1E+3 -> 1000
-ddmxg463 maxmag 1E+3 -1000 -> 1E+3
-ddmxg464 maxmag -1000 1E+3 -> 1E+3
-ddmxg465 maxmag -1E+3 1000 -> 1000
-ddmxg466 maxmag -1000 -1E+3 -> -1000
-ddmxg467 maxmag -1E+3 -1000 -> -1000
-
--- subnormals
-ddmxg510 maxmag 1.00E-383 0 -> 1.00E-383
-ddmxg511 maxmag 0.1E-383 0 -> 1E-384 Subnormal
-ddmxg512 maxmag 0.10E-383 0 -> 1.0E-384 Subnormal
-ddmxg513 maxmag 0.100E-383 0 -> 1.00E-384 Subnormal
-ddmxg514 maxmag 0.01E-383 0 -> 1E-385 Subnormal
-ddmxg515 maxmag 0.999E-383 0 -> 9.99E-384 Subnormal
-ddmxg516 maxmag 0.099E-383 0 -> 9.9E-385 Subnormal
-ddmxg517 maxmag 0.009E-383 0 -> 9E-386 Subnormal
-ddmxg518 maxmag 0.001E-383 0 -> 1E-386 Subnormal
-ddmxg519 maxmag 0.0009E-383 0 -> 9E-387 Subnormal
-ddmxg520 maxmag 0.0001E-383 0 -> 1E-387 Subnormal
-
-ddmxg530 maxmag -1.00E-383 0 -> -1.00E-383
-ddmxg531 maxmag -0.1E-383 0 -> -1E-384 Subnormal
-ddmxg532 maxmag -0.10E-383 0 -> -1.0E-384 Subnormal
-ddmxg533 maxmag -0.100E-383 0 -> -1.00E-384 Subnormal
-ddmxg534 maxmag -0.01E-383 0 -> -1E-385 Subnormal
-ddmxg535 maxmag -0.999E-383 0 -> -9.99E-384 Subnormal
-ddmxg536 maxmag -0.099E-383 0 -> -9.9E-385 Subnormal
-ddmxg537 maxmag -0.009E-383 0 -> -9E-386 Subnormal
-ddmxg538 maxmag -0.001E-383 0 -> -1E-386 Subnormal
-ddmxg539 maxmag -0.0009E-383 0 -> -9E-387 Subnormal
-ddmxg540 maxmag -0.0001E-383 0 -> -1E-387 Subnormal
-
--- Null tests
-ddmxg900 maxmag 10 # -> NaN Invalid_operation
-ddmxg901 maxmag # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddMaxMag.decTest -- decDouble maxnummag --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmxg001 maxmag -2 -2 -> -2
+ddmxg002 maxmag -2 -1 -> -2
+ddmxg003 maxmag -2 0 -> -2
+ddmxg004 maxmag -2 1 -> -2
+ddmxg005 maxmag -2 2 -> 2
+ddmxg006 maxmag -1 -2 -> -2
+ddmxg007 maxmag -1 -1 -> -1
+ddmxg008 maxmag -1 0 -> -1
+ddmxg009 maxmag -1 1 -> 1
+ddmxg010 maxmag -1 2 -> 2
+ddmxg011 maxmag 0 -2 -> -2
+ddmxg012 maxmag 0 -1 -> -1
+ddmxg013 maxmag 0 0 -> 0
+ddmxg014 maxmag 0 1 -> 1
+ddmxg015 maxmag 0 2 -> 2
+ddmxg016 maxmag 1 -2 -> -2
+ddmxg017 maxmag 1 -1 -> 1
+ddmxg018 maxmag 1 0 -> 1
+ddmxg019 maxmag 1 1 -> 1
+ddmxg020 maxmag 1 2 -> 2
+ddmxg021 maxmag 2 -2 -> 2
+ddmxg022 maxmag 2 -1 -> 2
+ddmxg023 maxmag 2 0 -> 2
+ddmxg025 maxmag 2 1 -> 2
+ddmxg026 maxmag 2 2 -> 2
+
+-- extended zeros
+ddmxg030 maxmag 0 0 -> 0
+ddmxg031 maxmag 0 -0 -> 0
+ddmxg032 maxmag 0 -0.0 -> 0
+ddmxg033 maxmag 0 0.0 -> 0
+ddmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+ddmxg035 maxmag -0 -0 -> -0
+ddmxg036 maxmag -0 -0.0 -> -0.0
+ddmxg037 maxmag -0 0.0 -> 0.0
+ddmxg038 maxmag 0.0 0 -> 0
+ddmxg039 maxmag 0.0 -0 -> 0.0
+ddmxg040 maxmag 0.0 -0.0 -> 0.0
+ddmxg041 maxmag 0.0 0.0 -> 0.0
+ddmxg042 maxmag -0.0 0 -> 0
+ddmxg043 maxmag -0.0 -0 -> -0.0
+ddmxg044 maxmag -0.0 -0.0 -> -0.0
+ddmxg045 maxmag -0.0 0.0 -> 0.0
+
+ddmxg050 maxmag -0E1 0E1 -> 0E+1
+ddmxg051 maxmag -0E2 0E2 -> 0E+2
+ddmxg052 maxmag -0E2 0E1 -> 0E+1
+ddmxg053 maxmag -0E1 0E2 -> 0E+2
+ddmxg054 maxmag 0E1 -0E1 -> 0E+1
+ddmxg055 maxmag 0E2 -0E2 -> 0E+2
+ddmxg056 maxmag 0E2 -0E1 -> 0E+2
+ddmxg057 maxmag 0E1 -0E2 -> 0E+1
+
+ddmxg058 maxmag 0E1 0E1 -> 0E+1
+ddmxg059 maxmag 0E2 0E2 -> 0E+2
+ddmxg060 maxmag 0E2 0E1 -> 0E+2
+ddmxg061 maxmag 0E1 0E2 -> 0E+2
+ddmxg062 maxmag -0E1 -0E1 -> -0E+1
+ddmxg063 maxmag -0E2 -0E2 -> -0E+2
+ddmxg064 maxmag -0E2 -0E1 -> -0E+1
+ddmxg065 maxmag -0E1 -0E2 -> -0E+1
+
+-- Specials
+ddmxg090 maxmag Inf -Inf -> Infinity
+ddmxg091 maxmag Inf -1000 -> Infinity
+ddmxg092 maxmag Inf -1 -> Infinity
+ddmxg093 maxmag Inf -0 -> Infinity
+ddmxg094 maxmag Inf 0 -> Infinity
+ddmxg095 maxmag Inf 1 -> Infinity
+ddmxg096 maxmag Inf 1000 -> Infinity
+ddmxg097 maxmag Inf Inf -> Infinity
+ddmxg098 maxmag -1000 Inf -> Infinity
+ddmxg099 maxmag -Inf Inf -> Infinity
+ddmxg100 maxmag -1 Inf -> Infinity
+ddmxg101 maxmag -0 Inf -> Infinity
+ddmxg102 maxmag 0 Inf -> Infinity
+ddmxg103 maxmag 1 Inf -> Infinity
+ddmxg104 maxmag 1000 Inf -> Infinity
+ddmxg105 maxmag Inf Inf -> Infinity
+
+ddmxg120 maxmag -Inf -Inf -> -Infinity
+ddmxg121 maxmag -Inf -1000 -> -Infinity
+ddmxg122 maxmag -Inf -1 -> -Infinity
+ddmxg123 maxmag -Inf -0 -> -Infinity
+ddmxg124 maxmag -Inf 0 -> -Infinity
+ddmxg125 maxmag -Inf 1 -> -Infinity
+ddmxg126 maxmag -Inf 1000 -> -Infinity
+ddmxg127 maxmag -Inf Inf -> Infinity
+ddmxg128 maxmag -Inf -Inf -> -Infinity
+ddmxg129 maxmag -1000 -Inf -> -Infinity
+ddmxg130 maxmag -1 -Inf -> -Infinity
+ddmxg131 maxmag -0 -Inf -> -Infinity
+ddmxg132 maxmag 0 -Inf -> -Infinity
+ddmxg133 maxmag 1 -Inf -> -Infinity
+ddmxg134 maxmag 1000 -Inf -> -Infinity
+ddmxg135 maxmag Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+ddmxg141 maxmag NaN -Inf -> -Infinity
+ddmxg142 maxmag NaN -1000 -> -1000
+ddmxg143 maxmag NaN -1 -> -1
+ddmxg144 maxmag NaN -0 -> -0
+ddmxg145 maxmag NaN 0 -> 0
+ddmxg146 maxmag NaN 1 -> 1
+ddmxg147 maxmag NaN 1000 -> 1000
+ddmxg148 maxmag NaN Inf -> Infinity
+ddmxg149 maxmag NaN NaN -> NaN
+ddmxg150 maxmag -Inf NaN -> -Infinity
+ddmxg151 maxmag -1000 NaN -> -1000
+ddmxg152 maxmag -1 NaN -> -1
+ddmxg153 maxmag -0 NaN -> -0
+ddmxg154 maxmag 0 NaN -> 0
+ddmxg155 maxmag 1 NaN -> 1
+ddmxg156 maxmag 1000 NaN -> 1000
+ddmxg157 maxmag Inf NaN -> Infinity
+
+ddmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
+ddmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
+ddmxg163 maxmag sNaN -1 -> NaN Invalid_operation
+ddmxg164 maxmag sNaN -0 -> NaN Invalid_operation
+ddmxg165 maxmag sNaN 0 -> NaN Invalid_operation
+ddmxg166 maxmag sNaN 1 -> NaN Invalid_operation
+ddmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
+ddmxg168 maxmag sNaN NaN -> NaN Invalid_operation
+ddmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
+ddmxg170 maxmag NaN sNaN -> NaN Invalid_operation
+ddmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
+ddmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
+ddmxg173 maxmag -1 sNaN -> NaN Invalid_operation
+ddmxg174 maxmag -0 sNaN -> NaN Invalid_operation
+ddmxg175 maxmag 0 sNaN -> NaN Invalid_operation
+ddmxg176 maxmag 1 sNaN -> NaN Invalid_operation
+ddmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
+ddmxg178 maxmag Inf sNaN -> NaN Invalid_operation
+ddmxg179 maxmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmxg181 maxmag NaN9 -Inf -> -Infinity
+ddmxg182 maxmag NaN8 9 -> 9
+ddmxg183 maxmag -NaN7 Inf -> Infinity
+
+ddmxg184 maxmag -NaN1 NaN11 -> -NaN1
+ddmxg185 maxmag NaN2 NaN12 -> NaN2
+ddmxg186 maxmag -NaN13 -NaN7 -> -NaN13
+ddmxg187 maxmag NaN14 -NaN5 -> NaN14
+
+ddmxg188 maxmag -Inf NaN4 -> -Infinity
+ddmxg189 maxmag -9 -NaN3 -> -9
+ddmxg190 maxmag Inf NaN2 -> Infinity
+
+ddmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
+ddmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
+ddmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
+ddmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
+ddmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
+ddmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
+ddmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
+
+-- old rounding checks
+ddmxg221 maxmag 12345678000 1 -> 12345678000
+ddmxg222 maxmag 1 12345678000 -> 12345678000
+ddmxg223 maxmag 1234567800 1 -> 1234567800
+ddmxg224 maxmag 1 1234567800 -> 1234567800
+ddmxg225 maxmag 1234567890 1 -> 1234567890
+ddmxg226 maxmag 1 1234567890 -> 1234567890
+ddmxg227 maxmag 1234567891 1 -> 1234567891
+ddmxg228 maxmag 1 1234567891 -> 1234567891
+ddmxg229 maxmag 12345678901 1 -> 12345678901
+ddmxg230 maxmag 1 12345678901 -> 12345678901
+ddmxg231 maxmag 1234567896 1 -> 1234567896
+ddmxg232 maxmag 1 1234567896 -> 1234567896
+ddmxg233 maxmag -1234567891 1 -> -1234567891
+ddmxg234 maxmag 1 -1234567891 -> -1234567891
+ddmxg235 maxmag -12345678901 1 -> -12345678901
+ddmxg236 maxmag 1 -12345678901 -> -12345678901
+ddmxg237 maxmag -1234567896 1 -> -1234567896
+ddmxg238 maxmag 1 -1234567896 -> -1234567896
+
+-- from examples
+ddmxg280 maxmag '3' '2' -> '3'
+ddmxg281 maxmag '-10' '3' -> '-10'
+ddmxg282 maxmag '1.0' '1' -> '1'
+ddmxg283 maxmag '1' '1.0' -> '1'
+ddmxg284 maxmag '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+ddmxg401 maxmag Inf 1.1 -> Infinity
+ddmxg402 maxmag 1.1 1 -> 1.1
+ddmxg403 maxmag 1 1.0 -> 1
+ddmxg404 maxmag 1.0 0.1 -> 1.0
+ddmxg405 maxmag 0.1 0.10 -> 0.1
+ddmxg406 maxmag 0.10 0.100 -> 0.10
+ddmxg407 maxmag 0.10 0 -> 0.10
+ddmxg408 maxmag 0 0.0 -> 0
+ddmxg409 maxmag 0.0 -0 -> 0.0
+ddmxg410 maxmag 0.0 -0.0 -> 0.0
+ddmxg411 maxmag 0.00 -0.0 -> 0.00
+ddmxg412 maxmag 0.0 -0.00 -> 0.0
+ddmxg413 maxmag 0 -0.0 -> 0
+ddmxg414 maxmag 0 -0 -> 0
+ddmxg415 maxmag -0.0 -0 -> -0.0
+ddmxg416 maxmag -0 -0.100 -> -0.100
+ddmxg417 maxmag -0.100 -0.10 -> -0.100
+ddmxg418 maxmag -0.10 -0.1 -> -0.10
+ddmxg419 maxmag -0.1 -1.0 -> -1.0
+ddmxg420 maxmag -1.0 -1 -> -1.0
+ddmxg421 maxmag -1 -1.1 -> -1.1
+ddmxg423 maxmag -1.1 -Inf -> -Infinity
+-- same with operands reversed
+ddmxg431 maxmag 1.1 Inf -> Infinity
+ddmxg432 maxmag 1 1.1 -> 1.1
+ddmxg433 maxmag 1.0 1 -> 1
+ddmxg434 maxmag 0.1 1.0 -> 1.0
+ddmxg435 maxmag 0.10 0.1 -> 0.1
+ddmxg436 maxmag 0.100 0.10 -> 0.10
+ddmxg437 maxmag 0 0.10 -> 0.10
+ddmxg438 maxmag 0.0 0 -> 0
+ddmxg439 maxmag -0 0.0 -> 0.0
+ddmxg440 maxmag -0.0 0.0 -> 0.0
+ddmxg441 maxmag -0.0 0.00 -> 0.00
+ddmxg442 maxmag -0.00 0.0 -> 0.0
+ddmxg443 maxmag -0.0 0 -> 0
+ddmxg444 maxmag -0 0 -> 0
+ddmxg445 maxmag -0 -0.0 -> -0.0
+ddmxg446 maxmag -0.100 -0 -> -0.100
+ddmxg447 maxmag -0.10 -0.100 -> -0.100
+ddmxg448 maxmag -0.1 -0.10 -> -0.10
+ddmxg449 maxmag -1.0 -0.1 -> -1.0
+ddmxg450 maxmag -1 -1.0 -> -1.0
+ddmxg451 maxmag -1.1 -1 -> -1.1
+ddmxg453 maxmag -Inf -1.1 -> -Infinity
+-- largies
+ddmxg460 maxmag 1000 1E+3 -> 1E+3
+ddmxg461 maxmag 1E+3 1000 -> 1E+3
+ddmxg462 maxmag 1000 -1E+3 -> 1000
+ddmxg463 maxmag 1E+3 -1000 -> 1E+3
+ddmxg464 maxmag -1000 1E+3 -> 1E+3
+ddmxg465 maxmag -1E+3 1000 -> 1000
+ddmxg466 maxmag -1000 -1E+3 -> -1000
+ddmxg467 maxmag -1E+3 -1000 -> -1000
+
+-- subnormals
+ddmxg510 maxmag 1.00E-383 0 -> 1.00E-383
+ddmxg511 maxmag 0.1E-383 0 -> 1E-384 Subnormal
+ddmxg512 maxmag 0.10E-383 0 -> 1.0E-384 Subnormal
+ddmxg513 maxmag 0.100E-383 0 -> 1.00E-384 Subnormal
+ddmxg514 maxmag 0.01E-383 0 -> 1E-385 Subnormal
+ddmxg515 maxmag 0.999E-383 0 -> 9.99E-384 Subnormal
+ddmxg516 maxmag 0.099E-383 0 -> 9.9E-385 Subnormal
+ddmxg517 maxmag 0.009E-383 0 -> 9E-386 Subnormal
+ddmxg518 maxmag 0.001E-383 0 -> 1E-386 Subnormal
+ddmxg519 maxmag 0.0009E-383 0 -> 9E-387 Subnormal
+ddmxg520 maxmag 0.0001E-383 0 -> 1E-387 Subnormal
+
+ddmxg530 maxmag -1.00E-383 0 -> -1.00E-383
+ddmxg531 maxmag -0.1E-383 0 -> -1E-384 Subnormal
+ddmxg532 maxmag -0.10E-383 0 -> -1.0E-384 Subnormal
+ddmxg533 maxmag -0.100E-383 0 -> -1.00E-384 Subnormal
+ddmxg534 maxmag -0.01E-383 0 -> -1E-385 Subnormal
+ddmxg535 maxmag -0.999E-383 0 -> -9.99E-384 Subnormal
+ddmxg536 maxmag -0.099E-383 0 -> -9.9E-385 Subnormal
+ddmxg537 maxmag -0.009E-383 0 -> -9E-386 Subnormal
+ddmxg538 maxmag -0.001E-383 0 -> -1E-386 Subnormal
+ddmxg539 maxmag -0.0009E-383 0 -> -9E-387 Subnormal
+ddmxg540 maxmag -0.0001E-383 0 -> -1E-387 Subnormal
+
+-- Null tests
+ddmxg900 maxmag 10 # -> NaN Invalid_operation
+ddmxg901 maxmag # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddMin.decTest b/Lib/test/decimaltestdata/ddMin.decTest
index eb942ff159..9ce4282463 100644
--- a/Lib/test/decimaltestdata/ddMin.decTest
+++ b/Lib/test/decimaltestdata/ddMin.decTest
@@ -1,309 +1,309 @@
-------------------------------------------------------------------------
--- ddMin.decTest -- decDouble minnum --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmin001 min -2 -2 -> -2
-ddmin002 min -2 -1 -> -2
-ddmin003 min -2 0 -> -2
-ddmin004 min -2 1 -> -2
-ddmin005 min -2 2 -> -2
-ddmin006 min -1 -2 -> -2
-ddmin007 min -1 -1 -> -1
-ddmin008 min -1 0 -> -1
-ddmin009 min -1 1 -> -1
-ddmin010 min -1 2 -> -1
-ddmin011 min 0 -2 -> -2
-ddmin012 min 0 -1 -> -1
-ddmin013 min 0 0 -> 0
-ddmin014 min 0 1 -> 0
-ddmin015 min 0 2 -> 0
-ddmin016 min 1 -2 -> -2
-ddmin017 min 1 -1 -> -1
-ddmin018 min 1 0 -> 0
-ddmin019 min 1 1 -> 1
-ddmin020 min 1 2 -> 1
-ddmin021 min 2 -2 -> -2
-ddmin022 min 2 -1 -> -1
-ddmin023 min 2 0 -> 0
-ddmin025 min 2 1 -> 1
-ddmin026 min 2 2 -> 2
-
--- extended zeros
-ddmin030 min 0 0 -> 0
-ddmin031 min 0 -0 -> -0
-ddmin032 min 0 -0.0 -> -0.0
-ddmin033 min 0 0.0 -> 0.0
-ddmin034 min -0 0 -> -0
-ddmin035 min -0 -0 -> -0
-ddmin036 min -0 -0.0 -> -0
-ddmin037 min -0 0.0 -> -0
-ddmin038 min 0.0 0 -> 0.0
-ddmin039 min 0.0 -0 -> -0
-ddmin040 min 0.0 -0.0 -> -0.0
-ddmin041 min 0.0 0.0 -> 0.0
-ddmin042 min -0.0 0 -> -0.0
-ddmin043 min -0.0 -0 -> -0
-ddmin044 min -0.0 -0.0 -> -0.0
-ddmin045 min -0.0 0.0 -> -0.0
-
-ddmin046 min 0E1 -0E1 -> -0E+1
-ddmin047 min -0E1 0E2 -> -0E+1
-ddmin048 min 0E2 0E1 -> 0E+1
-ddmin049 min 0E1 0E2 -> 0E+1
-ddmin050 min -0E3 -0E2 -> -0E+3
-ddmin051 min -0E2 -0E3 -> -0E+3
-
--- Specials
-ddmin090 min Inf -Inf -> -Infinity
-ddmin091 min Inf -1000 -> -1000
-ddmin092 min Inf -1 -> -1
-ddmin093 min Inf -0 -> -0
-ddmin094 min Inf 0 -> 0
-ddmin095 min Inf 1 -> 1
-ddmin096 min Inf 1000 -> 1000
-ddmin097 min Inf Inf -> Infinity
-ddmin098 min -1000 Inf -> -1000
-ddmin099 min -Inf Inf -> -Infinity
-ddmin100 min -1 Inf -> -1
-ddmin101 min -0 Inf -> -0
-ddmin102 min 0 Inf -> 0
-ddmin103 min 1 Inf -> 1
-ddmin104 min 1000 Inf -> 1000
-ddmin105 min Inf Inf -> Infinity
-
-ddmin120 min -Inf -Inf -> -Infinity
-ddmin121 min -Inf -1000 -> -Infinity
-ddmin122 min -Inf -1 -> -Infinity
-ddmin123 min -Inf -0 -> -Infinity
-ddmin124 min -Inf 0 -> -Infinity
-ddmin125 min -Inf 1 -> -Infinity
-ddmin126 min -Inf 1000 -> -Infinity
-ddmin127 min -Inf Inf -> -Infinity
-ddmin128 min -Inf -Inf -> -Infinity
-ddmin129 min -1000 -Inf -> -Infinity
-ddmin130 min -1 -Inf -> -Infinity
-ddmin131 min -0 -Inf -> -Infinity
-ddmin132 min 0 -Inf -> -Infinity
-ddmin133 min 1 -Inf -> -Infinity
-ddmin134 min 1000 -Inf -> -Infinity
-ddmin135 min Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-ddmin141 min NaN -Inf -> -Infinity
-ddmin142 min NaN -1000 -> -1000
-ddmin143 min NaN -1 -> -1
-ddmin144 min NaN -0 -> -0
-ddmin145 min NaN 0 -> 0
-ddmin146 min NaN 1 -> 1
-ddmin147 min NaN 1000 -> 1000
-ddmin148 min NaN Inf -> Infinity
-ddmin149 min NaN NaN -> NaN
-ddmin150 min -Inf NaN -> -Infinity
-ddmin151 min -1000 NaN -> -1000
-ddmin152 min -1 -NaN -> -1
-ddmin153 min -0 NaN -> -0
-ddmin154 min 0 -NaN -> 0
-ddmin155 min 1 NaN -> 1
-ddmin156 min 1000 NaN -> 1000
-ddmin157 min Inf NaN -> Infinity
-
-ddmin161 min sNaN -Inf -> NaN Invalid_operation
-ddmin162 min sNaN -1000 -> NaN Invalid_operation
-ddmin163 min sNaN -1 -> NaN Invalid_operation
-ddmin164 min sNaN -0 -> NaN Invalid_operation
-ddmin165 min -sNaN 0 -> -NaN Invalid_operation
-ddmin166 min -sNaN 1 -> -NaN Invalid_operation
-ddmin167 min sNaN 1000 -> NaN Invalid_operation
-ddmin168 min sNaN NaN -> NaN Invalid_operation
-ddmin169 min sNaN sNaN -> NaN Invalid_operation
-ddmin170 min NaN sNaN -> NaN Invalid_operation
-ddmin171 min -Inf sNaN -> NaN Invalid_operation
-ddmin172 min -1000 sNaN -> NaN Invalid_operation
-ddmin173 min -1 sNaN -> NaN Invalid_operation
-ddmin174 min -0 sNaN -> NaN Invalid_operation
-ddmin175 min 0 sNaN -> NaN Invalid_operation
-ddmin176 min 1 sNaN -> NaN Invalid_operation
-ddmin177 min 1000 sNaN -> NaN Invalid_operation
-ddmin178 min Inf sNaN -> NaN Invalid_operation
-ddmin179 min NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmin181 min NaN9 -Inf -> -Infinity
-ddmin182 min -NaN8 9990 -> 9990
-ddmin183 min NaN71 Inf -> Infinity
-
-ddmin184 min NaN1 NaN54 -> NaN1
-ddmin185 min NaN22 -NaN53 -> NaN22
-ddmin186 min -NaN3 NaN6 -> -NaN3
-ddmin187 min -NaN44 NaN7 -> -NaN44
-
-ddmin188 min -Inf NaN41 -> -Infinity
-ddmin189 min -9999 -NaN33 -> -9999
-ddmin190 min Inf NaN2 -> Infinity
-
-ddmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
-ddmin192 min sNaN98 -11 -> NaN98 Invalid_operation
-ddmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
-ddmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
-ddmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
-ddmin197 min 088 sNaN91 -> NaN91 Invalid_operation
-ddmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmin199 min NaN sNaN86 -> NaN86 Invalid_operation
-
--- old rounding checks
-ddmin221 min -12345678000 1 -> -12345678000
-ddmin222 min 1 -12345678000 -> -12345678000
-ddmin223 min -1234567800 1 -> -1234567800
-ddmin224 min 1 -1234567800 -> -1234567800
-ddmin225 min -1234567890 1 -> -1234567890
-ddmin226 min 1 -1234567890 -> -1234567890
-ddmin227 min -1234567891 1 -> -1234567891
-ddmin228 min 1 -1234567891 -> -1234567891
-ddmin229 min -12345678901 1 -> -12345678901
-ddmin230 min 1 -12345678901 -> -12345678901
-ddmin231 min -1234567896 1 -> -1234567896
-ddmin232 min 1 -1234567896 -> -1234567896
-ddmin233 min 1234567891 1 -> 1
-ddmin234 min 1 1234567891 -> 1
-ddmin235 min 12345678901 1 -> 1
-ddmin236 min 1 12345678901 -> 1
-ddmin237 min 1234567896 1 -> 1
-ddmin238 min 1 1234567896 -> 1
-
--- from examples
-ddmin280 min '3' '2' -> '2'
-ddmin281 min '-10' '3' -> '-10'
-ddmin282 min '1.0' '1' -> '1.0'
-ddmin283 min '1' '1.0' -> '1.0'
-ddmin284 min '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-ddmin401 min Inf 1.1 -> 1.1
-ddmin402 min 1.1 1 -> 1
-ddmin403 min 1 1.0 -> 1.0
-ddmin404 min 1.0 0.1 -> 0.1
-ddmin405 min 0.1 0.10 -> 0.10
-ddmin406 min 0.10 0.100 -> 0.100
-ddmin407 min 0.10 0 -> 0
-ddmin408 min 0 0.0 -> 0.0
-ddmin409 min 0.0 -0 -> -0
-ddmin410 min 0.0 -0.0 -> -0.0
-ddmin411 min 0.00 -0.0 -> -0.0
-ddmin412 min 0.0 -0.00 -> -0.00
-ddmin413 min 0 -0.0 -> -0.0
-ddmin414 min 0 -0 -> -0
-ddmin415 min -0.0 -0 -> -0
-ddmin416 min -0 -0.100 -> -0.100
-ddmin417 min -0.100 -0.10 -> -0.10
-ddmin418 min -0.10 -0.1 -> -0.1
-ddmin419 min -0.1 -1.0 -> -1.0
-ddmin420 min -1.0 -1 -> -1
-ddmin421 min -1 -1.1 -> -1.1
-ddmin423 min -1.1 -Inf -> -Infinity
--- same with operands reversed
-ddmin431 min 1.1 Inf -> 1.1
-ddmin432 min 1 1.1 -> 1
-ddmin433 min 1.0 1 -> 1.0
-ddmin434 min 0.1 1.0 -> 0.1
-ddmin435 min 0.10 0.1 -> 0.10
-ddmin436 min 0.100 0.10 -> 0.100
-ddmin437 min 0 0.10 -> 0
-ddmin438 min 0.0 0 -> 0.0
-ddmin439 min -0 0.0 -> -0
-ddmin440 min -0.0 0.0 -> -0.0
-ddmin441 min -0.0 0.00 -> -0.0
-ddmin442 min -0.00 0.0 -> -0.00
-ddmin443 min -0.0 0 -> -0.0
-ddmin444 min -0 0 -> -0
-ddmin445 min -0 -0.0 -> -0
-ddmin446 min -0.100 -0 -> -0.100
-ddmin447 min -0.10 -0.100 -> -0.10
-ddmin448 min -0.1 -0.10 -> -0.1
-ddmin449 min -1.0 -0.1 -> -1.0
-ddmin450 min -1 -1.0 -> -1
-ddmin451 min -1.1 -1 -> -1.1
-ddmin453 min -Inf -1.1 -> -Infinity
--- largies
-ddmin460 min 1000 1E+3 -> 1000
-ddmin461 min 1E+3 1000 -> 1000
-ddmin462 min 1000 -1E+3 -> -1E+3
-ddmin463 min 1E+3 -384 -> -384
-ddmin464 min -384 1E+3 -> -384
-ddmin465 min -1E+3 1000 -> -1E+3
-ddmin466 min -384 -1E+3 -> -1E+3
-ddmin467 min -1E+3 -384 -> -1E+3
-
--- misalignment traps for little-endian
-ddmin471 min 1.0 0.1 -> 0.1
-ddmin472 min 0.1 1.0 -> 0.1
-ddmin473 min 10.0 0.1 -> 0.1
-ddmin474 min 0.1 10.0 -> 0.1
-ddmin475 min 100 1.0 -> 1.0
-ddmin476 min 1.0 100 -> 1.0
-ddmin477 min 1000 10.0 -> 10.0
-ddmin478 min 10.0 1000 -> 10.0
-ddmin479 min 10000 100.0 -> 100.0
-ddmin480 min 100.0 10000 -> 100.0
-ddmin481 min 100000 1000.0 -> 1000.0
-ddmin482 min 1000.0 100000 -> 1000.0
-ddmin483 min 1000000 10000.0 -> 10000.0
-ddmin484 min 10000.0 1000000 -> 10000.0
-
--- subnormals
-ddmin510 min 1.00E-383 0 -> 0
-ddmin511 min 0.1E-383 0 -> 0
-ddmin512 min 0.10E-383 0 -> 0
-ddmin513 min 0.100E-383 0 -> 0
-ddmin514 min 0.01E-383 0 -> 0
-ddmin515 min 0.999E-383 0 -> 0
-ddmin516 min 0.099E-383 0 -> 0
-ddmin517 min 0.009E-383 0 -> 0
-ddmin518 min 0.001E-383 0 -> 0
-ddmin519 min 0.0009E-383 0 -> 0
-ddmin520 min 0.0001E-383 0 -> 0
-
-ddmin530 min -1.00E-383 0 -> -1.00E-383
-ddmin531 min -0.1E-383 0 -> -1E-384 Subnormal
-ddmin532 min -0.10E-383 0 -> -1.0E-384 Subnormal
-ddmin533 min -0.100E-383 0 -> -1.00E-384 Subnormal
-ddmin534 min -0.01E-383 0 -> -1E-385 Subnormal
-ddmin535 min -0.999E-383 0 -> -9.99E-384 Subnormal
-ddmin536 min -0.099E-383 0 -> -9.9E-385 Subnormal
-ddmin537 min -0.009E-383 0 -> -9E-386 Subnormal
-ddmin538 min -0.001E-383 0 -> -1E-386 Subnormal
-ddmin539 min -0.0009E-383 0 -> -9E-387 Subnormal
-ddmin540 min -0.0001E-383 0 -> -1E-387 Subnormal
-
-
--- Null tests
-ddmin900 min 10 # -> NaN Invalid_operation
-ddmin901 min # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddMin.decTest -- decDouble minnum --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmin001 min -2 -2 -> -2
+ddmin002 min -2 -1 -> -2
+ddmin003 min -2 0 -> -2
+ddmin004 min -2 1 -> -2
+ddmin005 min -2 2 -> -2
+ddmin006 min -1 -2 -> -2
+ddmin007 min -1 -1 -> -1
+ddmin008 min -1 0 -> -1
+ddmin009 min -1 1 -> -1
+ddmin010 min -1 2 -> -1
+ddmin011 min 0 -2 -> -2
+ddmin012 min 0 -1 -> -1
+ddmin013 min 0 0 -> 0
+ddmin014 min 0 1 -> 0
+ddmin015 min 0 2 -> 0
+ddmin016 min 1 -2 -> -2
+ddmin017 min 1 -1 -> -1
+ddmin018 min 1 0 -> 0
+ddmin019 min 1 1 -> 1
+ddmin020 min 1 2 -> 1
+ddmin021 min 2 -2 -> -2
+ddmin022 min 2 -1 -> -1
+ddmin023 min 2 0 -> 0
+ddmin025 min 2 1 -> 1
+ddmin026 min 2 2 -> 2
+
+-- extended zeros
+ddmin030 min 0 0 -> 0
+ddmin031 min 0 -0 -> -0
+ddmin032 min 0 -0.0 -> -0.0
+ddmin033 min 0 0.0 -> 0.0
+ddmin034 min -0 0 -> -0
+ddmin035 min -0 -0 -> -0
+ddmin036 min -0 -0.0 -> -0
+ddmin037 min -0 0.0 -> -0
+ddmin038 min 0.0 0 -> 0.0
+ddmin039 min 0.0 -0 -> -0
+ddmin040 min 0.0 -0.0 -> -0.0
+ddmin041 min 0.0 0.0 -> 0.0
+ddmin042 min -0.0 0 -> -0.0
+ddmin043 min -0.0 -0 -> -0
+ddmin044 min -0.0 -0.0 -> -0.0
+ddmin045 min -0.0 0.0 -> -0.0
+
+ddmin046 min 0E1 -0E1 -> -0E+1
+ddmin047 min -0E1 0E2 -> -0E+1
+ddmin048 min 0E2 0E1 -> 0E+1
+ddmin049 min 0E1 0E2 -> 0E+1
+ddmin050 min -0E3 -0E2 -> -0E+3
+ddmin051 min -0E2 -0E3 -> -0E+3
+
+-- Specials
+ddmin090 min Inf -Inf -> -Infinity
+ddmin091 min Inf -1000 -> -1000
+ddmin092 min Inf -1 -> -1
+ddmin093 min Inf -0 -> -0
+ddmin094 min Inf 0 -> 0
+ddmin095 min Inf 1 -> 1
+ddmin096 min Inf 1000 -> 1000
+ddmin097 min Inf Inf -> Infinity
+ddmin098 min -1000 Inf -> -1000
+ddmin099 min -Inf Inf -> -Infinity
+ddmin100 min -1 Inf -> -1
+ddmin101 min -0 Inf -> -0
+ddmin102 min 0 Inf -> 0
+ddmin103 min 1 Inf -> 1
+ddmin104 min 1000 Inf -> 1000
+ddmin105 min Inf Inf -> Infinity
+
+ddmin120 min -Inf -Inf -> -Infinity
+ddmin121 min -Inf -1000 -> -Infinity
+ddmin122 min -Inf -1 -> -Infinity
+ddmin123 min -Inf -0 -> -Infinity
+ddmin124 min -Inf 0 -> -Infinity
+ddmin125 min -Inf 1 -> -Infinity
+ddmin126 min -Inf 1000 -> -Infinity
+ddmin127 min -Inf Inf -> -Infinity
+ddmin128 min -Inf -Inf -> -Infinity
+ddmin129 min -1000 -Inf -> -Infinity
+ddmin130 min -1 -Inf -> -Infinity
+ddmin131 min -0 -Inf -> -Infinity
+ddmin132 min 0 -Inf -> -Infinity
+ddmin133 min 1 -Inf -> -Infinity
+ddmin134 min 1000 -Inf -> -Infinity
+ddmin135 min Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+ddmin141 min NaN -Inf -> -Infinity
+ddmin142 min NaN -1000 -> -1000
+ddmin143 min NaN -1 -> -1
+ddmin144 min NaN -0 -> -0
+ddmin145 min NaN 0 -> 0
+ddmin146 min NaN 1 -> 1
+ddmin147 min NaN 1000 -> 1000
+ddmin148 min NaN Inf -> Infinity
+ddmin149 min NaN NaN -> NaN
+ddmin150 min -Inf NaN -> -Infinity
+ddmin151 min -1000 NaN -> -1000
+ddmin152 min -1 -NaN -> -1
+ddmin153 min -0 NaN -> -0
+ddmin154 min 0 -NaN -> 0
+ddmin155 min 1 NaN -> 1
+ddmin156 min 1000 NaN -> 1000
+ddmin157 min Inf NaN -> Infinity
+
+ddmin161 min sNaN -Inf -> NaN Invalid_operation
+ddmin162 min sNaN -1000 -> NaN Invalid_operation
+ddmin163 min sNaN -1 -> NaN Invalid_operation
+ddmin164 min sNaN -0 -> NaN Invalid_operation
+ddmin165 min -sNaN 0 -> -NaN Invalid_operation
+ddmin166 min -sNaN 1 -> -NaN Invalid_operation
+ddmin167 min sNaN 1000 -> NaN Invalid_operation
+ddmin168 min sNaN NaN -> NaN Invalid_operation
+ddmin169 min sNaN sNaN -> NaN Invalid_operation
+ddmin170 min NaN sNaN -> NaN Invalid_operation
+ddmin171 min -Inf sNaN -> NaN Invalid_operation
+ddmin172 min -1000 sNaN -> NaN Invalid_operation
+ddmin173 min -1 sNaN -> NaN Invalid_operation
+ddmin174 min -0 sNaN -> NaN Invalid_operation
+ddmin175 min 0 sNaN -> NaN Invalid_operation
+ddmin176 min 1 sNaN -> NaN Invalid_operation
+ddmin177 min 1000 sNaN -> NaN Invalid_operation
+ddmin178 min Inf sNaN -> NaN Invalid_operation
+ddmin179 min NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmin181 min NaN9 -Inf -> -Infinity
+ddmin182 min -NaN8 9990 -> 9990
+ddmin183 min NaN71 Inf -> Infinity
+
+ddmin184 min NaN1 NaN54 -> NaN1
+ddmin185 min NaN22 -NaN53 -> NaN22
+ddmin186 min -NaN3 NaN6 -> -NaN3
+ddmin187 min -NaN44 NaN7 -> -NaN44
+
+ddmin188 min -Inf NaN41 -> -Infinity
+ddmin189 min -9999 -NaN33 -> -9999
+ddmin190 min Inf NaN2 -> Infinity
+
+ddmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
+ddmin192 min sNaN98 -11 -> NaN98 Invalid_operation
+ddmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
+ddmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
+ddmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
+ddmin197 min 088 sNaN91 -> NaN91 Invalid_operation
+ddmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmin199 min NaN sNaN86 -> NaN86 Invalid_operation
+
+-- old rounding checks
+ddmin221 min -12345678000 1 -> -12345678000
+ddmin222 min 1 -12345678000 -> -12345678000
+ddmin223 min -1234567800 1 -> -1234567800
+ddmin224 min 1 -1234567800 -> -1234567800
+ddmin225 min -1234567890 1 -> -1234567890
+ddmin226 min 1 -1234567890 -> -1234567890
+ddmin227 min -1234567891 1 -> -1234567891
+ddmin228 min 1 -1234567891 -> -1234567891
+ddmin229 min -12345678901 1 -> -12345678901
+ddmin230 min 1 -12345678901 -> -12345678901
+ddmin231 min -1234567896 1 -> -1234567896
+ddmin232 min 1 -1234567896 -> -1234567896
+ddmin233 min 1234567891 1 -> 1
+ddmin234 min 1 1234567891 -> 1
+ddmin235 min 12345678901 1 -> 1
+ddmin236 min 1 12345678901 -> 1
+ddmin237 min 1234567896 1 -> 1
+ddmin238 min 1 1234567896 -> 1
+
+-- from examples
+ddmin280 min '3' '2' -> '2'
+ddmin281 min '-10' '3' -> '-10'
+ddmin282 min '1.0' '1' -> '1.0'
+ddmin283 min '1' '1.0' -> '1.0'
+ddmin284 min '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+ddmin401 min Inf 1.1 -> 1.1
+ddmin402 min 1.1 1 -> 1
+ddmin403 min 1 1.0 -> 1.0
+ddmin404 min 1.0 0.1 -> 0.1
+ddmin405 min 0.1 0.10 -> 0.10
+ddmin406 min 0.10 0.100 -> 0.100
+ddmin407 min 0.10 0 -> 0
+ddmin408 min 0 0.0 -> 0.0
+ddmin409 min 0.0 -0 -> -0
+ddmin410 min 0.0 -0.0 -> -0.0
+ddmin411 min 0.00 -0.0 -> -0.0
+ddmin412 min 0.0 -0.00 -> -0.00
+ddmin413 min 0 -0.0 -> -0.0
+ddmin414 min 0 -0 -> -0
+ddmin415 min -0.0 -0 -> -0
+ddmin416 min -0 -0.100 -> -0.100
+ddmin417 min -0.100 -0.10 -> -0.10
+ddmin418 min -0.10 -0.1 -> -0.1
+ddmin419 min -0.1 -1.0 -> -1.0
+ddmin420 min -1.0 -1 -> -1
+ddmin421 min -1 -1.1 -> -1.1
+ddmin423 min -1.1 -Inf -> -Infinity
+-- same with operands reversed
+ddmin431 min 1.1 Inf -> 1.1
+ddmin432 min 1 1.1 -> 1
+ddmin433 min 1.0 1 -> 1.0
+ddmin434 min 0.1 1.0 -> 0.1
+ddmin435 min 0.10 0.1 -> 0.10
+ddmin436 min 0.100 0.10 -> 0.100
+ddmin437 min 0 0.10 -> 0
+ddmin438 min 0.0 0 -> 0.0
+ddmin439 min -0 0.0 -> -0
+ddmin440 min -0.0 0.0 -> -0.0
+ddmin441 min -0.0 0.00 -> -0.0
+ddmin442 min -0.00 0.0 -> -0.00
+ddmin443 min -0.0 0 -> -0.0
+ddmin444 min -0 0 -> -0
+ddmin445 min -0 -0.0 -> -0
+ddmin446 min -0.100 -0 -> -0.100
+ddmin447 min -0.10 -0.100 -> -0.10
+ddmin448 min -0.1 -0.10 -> -0.1
+ddmin449 min -1.0 -0.1 -> -1.0
+ddmin450 min -1 -1.0 -> -1
+ddmin451 min -1.1 -1 -> -1.1
+ddmin453 min -Inf -1.1 -> -Infinity
+-- largies
+ddmin460 min 1000 1E+3 -> 1000
+ddmin461 min 1E+3 1000 -> 1000
+ddmin462 min 1000 -1E+3 -> -1E+3
+ddmin463 min 1E+3 -384 -> -384
+ddmin464 min -384 1E+3 -> -384
+ddmin465 min -1E+3 1000 -> -1E+3
+ddmin466 min -384 -1E+3 -> -1E+3
+ddmin467 min -1E+3 -384 -> -1E+3
+
+-- misalignment traps for little-endian
+ddmin471 min 1.0 0.1 -> 0.1
+ddmin472 min 0.1 1.0 -> 0.1
+ddmin473 min 10.0 0.1 -> 0.1
+ddmin474 min 0.1 10.0 -> 0.1
+ddmin475 min 100 1.0 -> 1.0
+ddmin476 min 1.0 100 -> 1.0
+ddmin477 min 1000 10.0 -> 10.0
+ddmin478 min 10.0 1000 -> 10.0
+ddmin479 min 10000 100.0 -> 100.0
+ddmin480 min 100.0 10000 -> 100.0
+ddmin481 min 100000 1000.0 -> 1000.0
+ddmin482 min 1000.0 100000 -> 1000.0
+ddmin483 min 1000000 10000.0 -> 10000.0
+ddmin484 min 10000.0 1000000 -> 10000.0
+
+-- subnormals
+ddmin510 min 1.00E-383 0 -> 0
+ddmin511 min 0.1E-383 0 -> 0
+ddmin512 min 0.10E-383 0 -> 0
+ddmin513 min 0.100E-383 0 -> 0
+ddmin514 min 0.01E-383 0 -> 0
+ddmin515 min 0.999E-383 0 -> 0
+ddmin516 min 0.099E-383 0 -> 0
+ddmin517 min 0.009E-383 0 -> 0
+ddmin518 min 0.001E-383 0 -> 0
+ddmin519 min 0.0009E-383 0 -> 0
+ddmin520 min 0.0001E-383 0 -> 0
+
+ddmin530 min -1.00E-383 0 -> -1.00E-383
+ddmin531 min -0.1E-383 0 -> -1E-384 Subnormal
+ddmin532 min -0.10E-383 0 -> -1.0E-384 Subnormal
+ddmin533 min -0.100E-383 0 -> -1.00E-384 Subnormal
+ddmin534 min -0.01E-383 0 -> -1E-385 Subnormal
+ddmin535 min -0.999E-383 0 -> -9.99E-384 Subnormal
+ddmin536 min -0.099E-383 0 -> -9.9E-385 Subnormal
+ddmin537 min -0.009E-383 0 -> -9E-386 Subnormal
+ddmin538 min -0.001E-383 0 -> -1E-386 Subnormal
+ddmin539 min -0.0009E-383 0 -> -9E-387 Subnormal
+ddmin540 min -0.0001E-383 0 -> -1E-387 Subnormal
+
+
+-- Null tests
+ddmin900 min 10 # -> NaN Invalid_operation
+ddmin901 min # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddMinMag.decTest b/Lib/test/decimaltestdata/ddMinMag.decTest
index 1012f1ec81..5537cc8a7e 100644
--- a/Lib/test/decimaltestdata/ddMinMag.decTest
+++ b/Lib/test/decimaltestdata/ddMinMag.decTest
@@ -1,293 +1,293 @@
-------------------------------------------------------------------------
--- ddMinMag.decTest -- decDouble minnummag --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmng001 minmag -2 -2 -> -2
-ddmng002 minmag -2 -1 -> -1
-ddmng003 minmag -2 0 -> 0
-ddmng004 minmag -2 1 -> 1
-ddmng005 minmag -2 2 -> -2
-ddmng006 minmag -1 -2 -> -1
-ddmng007 minmag -1 -1 -> -1
-ddmng008 minmag -1 0 -> 0
-ddmng009 minmag -1 1 -> -1
-ddmng010 minmag -1 2 -> -1
-ddmng011 minmag 0 -2 -> 0
-ddmng012 minmag 0 -1 -> 0
-ddmng013 minmag 0 0 -> 0
-ddmng014 minmag 0 1 -> 0
-ddmng015 minmag 0 2 -> 0
-ddmng016 minmag 1 -2 -> 1
-ddmng017 minmag 1 -1 -> -1
-ddmng018 minmag 1 0 -> 0
-ddmng019 minmag 1 1 -> 1
-ddmng020 minmag 1 2 -> 1
-ddmng021 minmag 2 -2 -> -2
-ddmng022 minmag 2 -1 -> -1
-ddmng023 minmag 2 0 -> 0
-ddmng025 minmag 2 1 -> 1
-ddmng026 minmag 2 2 -> 2
-
--- extended zeros
-ddmng030 minmag 0 0 -> 0
-ddmng031 minmag 0 -0 -> -0
-ddmng032 minmag 0 -0.0 -> -0.0
-ddmng033 minmag 0 0.0 -> 0.0
-ddmng034 minmag -0 0 -> -0
-ddmng035 minmag -0 -0 -> -0
-ddmng036 minmag -0 -0.0 -> -0
-ddmng037 minmag -0 0.0 -> -0
-ddmng038 minmag 0.0 0 -> 0.0
-ddmng039 minmag 0.0 -0 -> -0
-ddmng040 minmag 0.0 -0.0 -> -0.0
-ddmng041 minmag 0.0 0.0 -> 0.0
-ddmng042 minmag -0.0 0 -> -0.0
-ddmng043 minmag -0.0 -0 -> -0
-ddmng044 minmag -0.0 -0.0 -> -0.0
-ddmng045 minmag -0.0 0.0 -> -0.0
-
-ddmng046 minmag 0E1 -0E1 -> -0E+1
-ddmng047 minmag -0E1 0E2 -> -0E+1
-ddmng048 minmag 0E2 0E1 -> 0E+1
-ddmng049 minmag 0E1 0E2 -> 0E+1
-ddmng050 minmag -0E3 -0E2 -> -0E+3
-ddmng051 minmag -0E2 -0E3 -> -0E+3
-
--- Specials
-ddmng090 minmag Inf -Inf -> -Infinity
-ddmng091 minmag Inf -1000 -> -1000
-ddmng092 minmag Inf -1 -> -1
-ddmng093 minmag Inf -0 -> -0
-ddmng094 minmag Inf 0 -> 0
-ddmng095 minmag Inf 1 -> 1
-ddmng096 minmag Inf 1000 -> 1000
-ddmng097 minmag Inf Inf -> Infinity
-ddmng098 minmag -1000 Inf -> -1000
-ddmng099 minmag -Inf Inf -> -Infinity
-ddmng100 minmag -1 Inf -> -1
-ddmng101 minmag -0 Inf -> -0
-ddmng102 minmag 0 Inf -> 0
-ddmng103 minmag 1 Inf -> 1
-ddmng104 minmag 1000 Inf -> 1000
-ddmng105 minmag Inf Inf -> Infinity
-
-ddmng120 minmag -Inf -Inf -> -Infinity
-ddmng121 minmag -Inf -1000 -> -1000
-ddmng122 minmag -Inf -1 -> -1
-ddmng123 minmag -Inf -0 -> -0
-ddmng124 minmag -Inf 0 -> 0
-ddmng125 minmag -Inf 1 -> 1
-ddmng126 minmag -Inf 1000 -> 1000
-ddmng127 minmag -Inf Inf -> -Infinity
-ddmng128 minmag -Inf -Inf -> -Infinity
-ddmng129 minmag -1000 -Inf -> -1000
-ddmng130 minmag -1 -Inf -> -1
-ddmng131 minmag -0 -Inf -> -0
-ddmng132 minmag 0 -Inf -> 0
-ddmng133 minmag 1 -Inf -> 1
-ddmng134 minmag 1000 -Inf -> 1000
-ddmng135 minmag Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-ddmng141 minmag NaN -Inf -> -Infinity
-ddmng142 minmag NaN -1000 -> -1000
-ddmng143 minmag NaN -1 -> -1
-ddmng144 minmag NaN -0 -> -0
-ddmng145 minmag NaN 0 -> 0
-ddmng146 minmag NaN 1 -> 1
-ddmng147 minmag NaN 1000 -> 1000
-ddmng148 minmag NaN Inf -> Infinity
-ddmng149 minmag NaN NaN -> NaN
-ddmng150 minmag -Inf NaN -> -Infinity
-ddmng151 minmag -1000 NaN -> -1000
-ddmng152 minmag -1 -NaN -> -1
-ddmng153 minmag -0 NaN -> -0
-ddmng154 minmag 0 -NaN -> 0
-ddmng155 minmag 1 NaN -> 1
-ddmng156 minmag 1000 NaN -> 1000
-ddmng157 minmag Inf NaN -> Infinity
-
-ddmng161 minmag sNaN -Inf -> NaN Invalid_operation
-ddmng162 minmag sNaN -1000 -> NaN Invalid_operation
-ddmng163 minmag sNaN -1 -> NaN Invalid_operation
-ddmng164 minmag sNaN -0 -> NaN Invalid_operation
-ddmng165 minmag -sNaN 0 -> -NaN Invalid_operation
-ddmng166 minmag -sNaN 1 -> -NaN Invalid_operation
-ddmng167 minmag sNaN 1000 -> NaN Invalid_operation
-ddmng168 minmag sNaN NaN -> NaN Invalid_operation
-ddmng169 minmag sNaN sNaN -> NaN Invalid_operation
-ddmng170 minmag NaN sNaN -> NaN Invalid_operation
-ddmng171 minmag -Inf sNaN -> NaN Invalid_operation
-ddmng172 minmag -1000 sNaN -> NaN Invalid_operation
-ddmng173 minmag -1 sNaN -> NaN Invalid_operation
-ddmng174 minmag -0 sNaN -> NaN Invalid_operation
-ddmng175 minmag 0 sNaN -> NaN Invalid_operation
-ddmng176 minmag 1 sNaN -> NaN Invalid_operation
-ddmng177 minmag 1000 sNaN -> NaN Invalid_operation
-ddmng178 minmag Inf sNaN -> NaN Invalid_operation
-ddmng179 minmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmng181 minmag NaN9 -Inf -> -Infinity
-ddmng182 minmag -NaN8 9990 -> 9990
-ddmng183 minmag NaN71 Inf -> Infinity
-
-ddmng184 minmag NaN1 NaN54 -> NaN1
-ddmng185 minmag NaN22 -NaN53 -> NaN22
-ddmng186 minmag -NaN3 NaN6 -> -NaN3
-ddmng187 minmag -NaN44 NaN7 -> -NaN44
-
-ddmng188 minmag -Inf NaN41 -> -Infinity
-ddmng189 minmag -9999 -NaN33 -> -9999
-ddmng190 minmag Inf NaN2 -> Infinity
-
-ddmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
-ddmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
-ddmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
-ddmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
-ddmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
-ddmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
-ddmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
-
--- old rounding checks
-ddmng221 minmag -12345678000 1 -> 1
-ddmng222 minmag 1 -12345678000 -> 1
-ddmng223 minmag -1234567800 1 -> 1
-ddmng224 minmag 1 -1234567800 -> 1
-ddmng225 minmag -1234567890 1 -> 1
-ddmng226 minmag 1 -1234567890 -> 1
-ddmng227 minmag -1234567891 1 -> 1
-ddmng228 minmag 1 -1234567891 -> 1
-ddmng229 minmag -12345678901 1 -> 1
-ddmng230 minmag 1 -12345678901 -> 1
-ddmng231 minmag -1234567896 1 -> 1
-ddmng232 minmag 1 -1234567896 -> 1
-ddmng233 minmag 1234567891 1 -> 1
-ddmng234 minmag 1 1234567891 -> 1
-ddmng235 minmag 12345678901 1 -> 1
-ddmng236 minmag 1 12345678901 -> 1
-ddmng237 minmag 1234567896 1 -> 1
-ddmng238 minmag 1 1234567896 -> 1
-
--- from examples
-ddmng280 minmag '3' '2' -> '2'
-ddmng281 minmag '-10' '3' -> '3'
-ddmng282 minmag '1.0' '1' -> '1.0'
-ddmng283 minmag '1' '1.0' -> '1.0'
-ddmng284 minmag '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-ddmng401 minmag Inf 1.1 -> 1.1
-ddmng402 minmag 1.1 1 -> 1
-ddmng403 minmag 1 1.0 -> 1.0
-ddmng404 minmag 1.0 0.1 -> 0.1
-ddmng405 minmag 0.1 0.10 -> 0.10
-ddmng406 minmag 0.10 0.100 -> 0.100
-ddmng407 minmag 0.10 0 -> 0
-ddmng408 minmag 0 0.0 -> 0.0
-ddmng409 minmag 0.0 -0 -> -0
-ddmng410 minmag 0.0 -0.0 -> -0.0
-ddmng411 minmag 0.00 -0.0 -> -0.0
-ddmng412 minmag 0.0 -0.00 -> -0.00
-ddmng413 minmag 0 -0.0 -> -0.0
-ddmng414 minmag 0 -0 -> -0
-ddmng415 minmag -0.0 -0 -> -0
-ddmng416 minmag -0 -0.100 -> -0
-ddmng417 minmag -0.100 -0.10 -> -0.10
-ddmng418 minmag -0.10 -0.1 -> -0.1
-ddmng419 minmag -0.1 -1.0 -> -0.1
-ddmng420 minmag -1.0 -1 -> -1
-ddmng421 minmag -1 -1.1 -> -1
-ddmng423 minmag -1.1 -Inf -> -1.1
--- same with operands reversed
-ddmng431 minmag 1.1 Inf -> 1.1
-ddmng432 minmag 1 1.1 -> 1
-ddmng433 minmag 1.0 1 -> 1.0
-ddmng434 minmag 0.1 1.0 -> 0.1
-ddmng435 minmag 0.10 0.1 -> 0.10
-ddmng436 minmag 0.100 0.10 -> 0.100
-ddmng437 minmag 0 0.10 -> 0
-ddmng438 minmag 0.0 0 -> 0.0
-ddmng439 minmag -0 0.0 -> -0
-ddmng440 minmag -0.0 0.0 -> -0.0
-ddmng441 minmag -0.0 0.00 -> -0.0
-ddmng442 minmag -0.00 0.0 -> -0.00
-ddmng443 minmag -0.0 0 -> -0.0
-ddmng444 minmag -0 0 -> -0
-ddmng445 minmag -0 -0.0 -> -0
-ddmng446 minmag -0.100 -0 -> -0
-ddmng447 minmag -0.10 -0.100 -> -0.10
-ddmng448 minmag -0.1 -0.10 -> -0.1
-ddmng449 minmag -1.0 -0.1 -> -0.1
-ddmng450 minmag -1 -1.0 -> -1
-ddmng451 minmag -1.1 -1 -> -1
-ddmng453 minmag -Inf -1.1 -> -1.1
--- largies
-ddmng460 minmag 1000 1E+3 -> 1000
-ddmng461 minmag 1E+3 1000 -> 1000
-ddmng462 minmag 1000 -1E+3 -> -1E+3
-ddmng463 minmag 1E+3 -384 -> -384
-ddmng464 minmag -384 1E+3 -> -384
-ddmng465 minmag -1E+3 1000 -> -1E+3
-ddmng466 minmag -384 -1E+3 -> -384
-ddmng467 minmag -1E+3 -384 -> -384
-
--- subnormals
-ddmng510 minmag 1.00E-383 0 -> 0
-ddmng511 minmag 0.1E-383 0 -> 0
-ddmng512 minmag 0.10E-383 0 -> 0
-ddmng513 minmag 0.100E-383 0 -> 0
-ddmng514 minmag 0.01E-383 0 -> 0
-ddmng515 minmag 0.999E-383 0 -> 0
-ddmng516 minmag 0.099E-383 0 -> 0
-ddmng517 minmag 0.009E-383 0 -> 0
-ddmng518 minmag 0.001E-383 0 -> 0
-ddmng519 minmag 0.0009E-383 0 -> 0
-ddmng520 minmag 0.0001E-383 0 -> 0
-
-ddmng530 minmag -1.00E-383 0 -> 0
-ddmng531 minmag -0.1E-383 0 -> 0
-ddmng532 minmag -0.10E-383 0 -> 0
-ddmng533 minmag -0.100E-383 0 -> 0
-ddmng534 minmag -0.01E-383 0 -> 0
-ddmng535 minmag -0.999E-383 0 -> 0
-ddmng536 minmag -0.099E-383 0 -> 0
-ddmng537 minmag -0.009E-383 0 -> 0
-ddmng538 minmag -0.001E-383 0 -> 0
-ddmng539 minmag -0.0009E-383 0 -> 0
-ddmng540 minmag -0.0001E-383 0 -> 0
-
-
--- Null tests
-ddmng900 minmag 10 # -> NaN Invalid_operation
-ddmng901 minmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddMinMag.decTest -- decDouble minnummag --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmng001 minmag -2 -2 -> -2
+ddmng002 minmag -2 -1 -> -1
+ddmng003 minmag -2 0 -> 0
+ddmng004 minmag -2 1 -> 1
+ddmng005 minmag -2 2 -> -2
+ddmng006 minmag -1 -2 -> -1
+ddmng007 minmag -1 -1 -> -1
+ddmng008 minmag -1 0 -> 0
+ddmng009 minmag -1 1 -> -1
+ddmng010 minmag -1 2 -> -1
+ddmng011 minmag 0 -2 -> 0
+ddmng012 minmag 0 -1 -> 0
+ddmng013 minmag 0 0 -> 0
+ddmng014 minmag 0 1 -> 0
+ddmng015 minmag 0 2 -> 0
+ddmng016 minmag 1 -2 -> 1
+ddmng017 minmag 1 -1 -> -1
+ddmng018 minmag 1 0 -> 0
+ddmng019 minmag 1 1 -> 1
+ddmng020 minmag 1 2 -> 1
+ddmng021 minmag 2 -2 -> -2
+ddmng022 minmag 2 -1 -> -1
+ddmng023 minmag 2 0 -> 0
+ddmng025 minmag 2 1 -> 1
+ddmng026 minmag 2 2 -> 2
+
+-- extended zeros
+ddmng030 minmag 0 0 -> 0
+ddmng031 minmag 0 -0 -> -0
+ddmng032 minmag 0 -0.0 -> -0.0
+ddmng033 minmag 0 0.0 -> 0.0
+ddmng034 minmag -0 0 -> -0
+ddmng035 minmag -0 -0 -> -0
+ddmng036 minmag -0 -0.0 -> -0
+ddmng037 minmag -0 0.0 -> -0
+ddmng038 minmag 0.0 0 -> 0.0
+ddmng039 minmag 0.0 -0 -> -0
+ddmng040 minmag 0.0 -0.0 -> -0.0
+ddmng041 minmag 0.0 0.0 -> 0.0
+ddmng042 minmag -0.0 0 -> -0.0
+ddmng043 minmag -0.0 -0 -> -0
+ddmng044 minmag -0.0 -0.0 -> -0.0
+ddmng045 minmag -0.0 0.0 -> -0.0
+
+ddmng046 minmag 0E1 -0E1 -> -0E+1
+ddmng047 minmag -0E1 0E2 -> -0E+1
+ddmng048 minmag 0E2 0E1 -> 0E+1
+ddmng049 minmag 0E1 0E2 -> 0E+1
+ddmng050 minmag -0E3 -0E2 -> -0E+3
+ddmng051 minmag -0E2 -0E3 -> -0E+3
+
+-- Specials
+ddmng090 minmag Inf -Inf -> -Infinity
+ddmng091 minmag Inf -1000 -> -1000
+ddmng092 minmag Inf -1 -> -1
+ddmng093 minmag Inf -0 -> -0
+ddmng094 minmag Inf 0 -> 0
+ddmng095 minmag Inf 1 -> 1
+ddmng096 minmag Inf 1000 -> 1000
+ddmng097 minmag Inf Inf -> Infinity
+ddmng098 minmag -1000 Inf -> -1000
+ddmng099 minmag -Inf Inf -> -Infinity
+ddmng100 minmag -1 Inf -> -1
+ddmng101 minmag -0 Inf -> -0
+ddmng102 minmag 0 Inf -> 0
+ddmng103 minmag 1 Inf -> 1
+ddmng104 minmag 1000 Inf -> 1000
+ddmng105 minmag Inf Inf -> Infinity
+
+ddmng120 minmag -Inf -Inf -> -Infinity
+ddmng121 minmag -Inf -1000 -> -1000
+ddmng122 minmag -Inf -1 -> -1
+ddmng123 minmag -Inf -0 -> -0
+ddmng124 minmag -Inf 0 -> 0
+ddmng125 minmag -Inf 1 -> 1
+ddmng126 minmag -Inf 1000 -> 1000
+ddmng127 minmag -Inf Inf -> -Infinity
+ddmng128 minmag -Inf -Inf -> -Infinity
+ddmng129 minmag -1000 -Inf -> -1000
+ddmng130 minmag -1 -Inf -> -1
+ddmng131 minmag -0 -Inf -> -0
+ddmng132 minmag 0 -Inf -> 0
+ddmng133 minmag 1 -Inf -> 1
+ddmng134 minmag 1000 -Inf -> 1000
+ddmng135 minmag Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+ddmng141 minmag NaN -Inf -> -Infinity
+ddmng142 minmag NaN -1000 -> -1000
+ddmng143 minmag NaN -1 -> -1
+ddmng144 minmag NaN -0 -> -0
+ddmng145 minmag NaN 0 -> 0
+ddmng146 minmag NaN 1 -> 1
+ddmng147 minmag NaN 1000 -> 1000
+ddmng148 minmag NaN Inf -> Infinity
+ddmng149 minmag NaN NaN -> NaN
+ddmng150 minmag -Inf NaN -> -Infinity
+ddmng151 minmag -1000 NaN -> -1000
+ddmng152 minmag -1 -NaN -> -1
+ddmng153 minmag -0 NaN -> -0
+ddmng154 minmag 0 -NaN -> 0
+ddmng155 minmag 1 NaN -> 1
+ddmng156 minmag 1000 NaN -> 1000
+ddmng157 minmag Inf NaN -> Infinity
+
+ddmng161 minmag sNaN -Inf -> NaN Invalid_operation
+ddmng162 minmag sNaN -1000 -> NaN Invalid_operation
+ddmng163 minmag sNaN -1 -> NaN Invalid_operation
+ddmng164 minmag sNaN -0 -> NaN Invalid_operation
+ddmng165 minmag -sNaN 0 -> -NaN Invalid_operation
+ddmng166 minmag -sNaN 1 -> -NaN Invalid_operation
+ddmng167 minmag sNaN 1000 -> NaN Invalid_operation
+ddmng168 minmag sNaN NaN -> NaN Invalid_operation
+ddmng169 minmag sNaN sNaN -> NaN Invalid_operation
+ddmng170 minmag NaN sNaN -> NaN Invalid_operation
+ddmng171 minmag -Inf sNaN -> NaN Invalid_operation
+ddmng172 minmag -1000 sNaN -> NaN Invalid_operation
+ddmng173 minmag -1 sNaN -> NaN Invalid_operation
+ddmng174 minmag -0 sNaN -> NaN Invalid_operation
+ddmng175 minmag 0 sNaN -> NaN Invalid_operation
+ddmng176 minmag 1 sNaN -> NaN Invalid_operation
+ddmng177 minmag 1000 sNaN -> NaN Invalid_operation
+ddmng178 minmag Inf sNaN -> NaN Invalid_operation
+ddmng179 minmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmng181 minmag NaN9 -Inf -> -Infinity
+ddmng182 minmag -NaN8 9990 -> 9990
+ddmng183 minmag NaN71 Inf -> Infinity
+
+ddmng184 minmag NaN1 NaN54 -> NaN1
+ddmng185 minmag NaN22 -NaN53 -> NaN22
+ddmng186 minmag -NaN3 NaN6 -> -NaN3
+ddmng187 minmag -NaN44 NaN7 -> -NaN44
+
+ddmng188 minmag -Inf NaN41 -> -Infinity
+ddmng189 minmag -9999 -NaN33 -> -9999
+ddmng190 minmag Inf NaN2 -> Infinity
+
+ddmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
+ddmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
+ddmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
+ddmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
+ddmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
+ddmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
+ddmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
+
+-- old rounding checks
+ddmng221 minmag -12345678000 1 -> 1
+ddmng222 minmag 1 -12345678000 -> 1
+ddmng223 minmag -1234567800 1 -> 1
+ddmng224 minmag 1 -1234567800 -> 1
+ddmng225 minmag -1234567890 1 -> 1
+ddmng226 minmag 1 -1234567890 -> 1
+ddmng227 minmag -1234567891 1 -> 1
+ddmng228 minmag 1 -1234567891 -> 1
+ddmng229 minmag -12345678901 1 -> 1
+ddmng230 minmag 1 -12345678901 -> 1
+ddmng231 minmag -1234567896 1 -> 1
+ddmng232 minmag 1 -1234567896 -> 1
+ddmng233 minmag 1234567891 1 -> 1
+ddmng234 minmag 1 1234567891 -> 1
+ddmng235 minmag 12345678901 1 -> 1
+ddmng236 minmag 1 12345678901 -> 1
+ddmng237 minmag 1234567896 1 -> 1
+ddmng238 minmag 1 1234567896 -> 1
+
+-- from examples
+ddmng280 minmag '3' '2' -> '2'
+ddmng281 minmag '-10' '3' -> '3'
+ddmng282 minmag '1.0' '1' -> '1.0'
+ddmng283 minmag '1' '1.0' -> '1.0'
+ddmng284 minmag '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+ddmng401 minmag Inf 1.1 -> 1.1
+ddmng402 minmag 1.1 1 -> 1
+ddmng403 minmag 1 1.0 -> 1.0
+ddmng404 minmag 1.0 0.1 -> 0.1
+ddmng405 minmag 0.1 0.10 -> 0.10
+ddmng406 minmag 0.10 0.100 -> 0.100
+ddmng407 minmag 0.10 0 -> 0
+ddmng408 minmag 0 0.0 -> 0.0
+ddmng409 minmag 0.0 -0 -> -0
+ddmng410 minmag 0.0 -0.0 -> -0.0
+ddmng411 minmag 0.00 -0.0 -> -0.0
+ddmng412 minmag 0.0 -0.00 -> -0.00
+ddmng413 minmag 0 -0.0 -> -0.0
+ddmng414 minmag 0 -0 -> -0
+ddmng415 minmag -0.0 -0 -> -0
+ddmng416 minmag -0 -0.100 -> -0
+ddmng417 minmag -0.100 -0.10 -> -0.10
+ddmng418 minmag -0.10 -0.1 -> -0.1
+ddmng419 minmag -0.1 -1.0 -> -0.1
+ddmng420 minmag -1.0 -1 -> -1
+ddmng421 minmag -1 -1.1 -> -1
+ddmng423 minmag -1.1 -Inf -> -1.1
+-- same with operands reversed
+ddmng431 minmag 1.1 Inf -> 1.1
+ddmng432 minmag 1 1.1 -> 1
+ddmng433 minmag 1.0 1 -> 1.0
+ddmng434 minmag 0.1 1.0 -> 0.1
+ddmng435 minmag 0.10 0.1 -> 0.10
+ddmng436 minmag 0.100 0.10 -> 0.100
+ddmng437 minmag 0 0.10 -> 0
+ddmng438 minmag 0.0 0 -> 0.0
+ddmng439 minmag -0 0.0 -> -0
+ddmng440 minmag -0.0 0.0 -> -0.0
+ddmng441 minmag -0.0 0.00 -> -0.0
+ddmng442 minmag -0.00 0.0 -> -0.00
+ddmng443 minmag -0.0 0 -> -0.0
+ddmng444 minmag -0 0 -> -0
+ddmng445 minmag -0 -0.0 -> -0
+ddmng446 minmag -0.100 -0 -> -0
+ddmng447 minmag -0.10 -0.100 -> -0.10
+ddmng448 minmag -0.1 -0.10 -> -0.1
+ddmng449 minmag -1.0 -0.1 -> -0.1
+ddmng450 minmag -1 -1.0 -> -1
+ddmng451 minmag -1.1 -1 -> -1
+ddmng453 minmag -Inf -1.1 -> -1.1
+-- largies
+ddmng460 minmag 1000 1E+3 -> 1000
+ddmng461 minmag 1E+3 1000 -> 1000
+ddmng462 minmag 1000 -1E+3 -> -1E+3
+ddmng463 minmag 1E+3 -384 -> -384
+ddmng464 minmag -384 1E+3 -> -384
+ddmng465 minmag -1E+3 1000 -> -1E+3
+ddmng466 minmag -384 -1E+3 -> -384
+ddmng467 minmag -1E+3 -384 -> -384
+
+-- subnormals
+ddmng510 minmag 1.00E-383 0 -> 0
+ddmng511 minmag 0.1E-383 0 -> 0
+ddmng512 minmag 0.10E-383 0 -> 0
+ddmng513 minmag 0.100E-383 0 -> 0
+ddmng514 minmag 0.01E-383 0 -> 0
+ddmng515 minmag 0.999E-383 0 -> 0
+ddmng516 minmag 0.099E-383 0 -> 0
+ddmng517 minmag 0.009E-383 0 -> 0
+ddmng518 minmag 0.001E-383 0 -> 0
+ddmng519 minmag 0.0009E-383 0 -> 0
+ddmng520 minmag 0.0001E-383 0 -> 0
+
+ddmng530 minmag -1.00E-383 0 -> 0
+ddmng531 minmag -0.1E-383 0 -> 0
+ddmng532 minmag -0.10E-383 0 -> 0
+ddmng533 minmag -0.100E-383 0 -> 0
+ddmng534 minmag -0.01E-383 0 -> 0
+ddmng535 minmag -0.999E-383 0 -> 0
+ddmng536 minmag -0.099E-383 0 -> 0
+ddmng537 minmag -0.009E-383 0 -> 0
+ddmng538 minmag -0.001E-383 0 -> 0
+ddmng539 minmag -0.0009E-383 0 -> 0
+ddmng540 minmag -0.0001E-383 0 -> 0
+
+
+-- Null tests
+ddmng900 minmag 10 # -> NaN Invalid_operation
+ddmng901 minmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddMinus.decTest b/Lib/test/decimaltestdata/ddMinus.decTest
index b7ffff7d89..2705e79ea2 100644
--- a/Lib/test/decimaltestdata/ddMinus.decTest
+++ b/Lib/test/decimaltestdata/ddMinus.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddMinus.decTest -- decDouble 0-x --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddmns001 minus +7.50 -> -7.50
-
--- Infinities
-ddmns011 minus Infinity -> -Infinity
-ddmns012 minus -Infinity -> Infinity
-
--- NaNs, 0 payload
-ddmns021 minus NaN -> NaN
-ddmns022 minus -NaN -> -NaN
-ddmns023 minus sNaN -> NaN Invalid_operation
-ddmns024 minus -sNaN -> -NaN Invalid_operation
-
--- NaNs, non-0 payload
-ddmns031 minus NaN13 -> NaN13
-ddmns032 minus -NaN13 -> -NaN13
-ddmns033 minus sNaN13 -> NaN13 Invalid_operation
-ddmns034 minus -sNaN13 -> -NaN13 Invalid_operation
-ddmns035 minus NaN70 -> NaN70
-ddmns036 minus -NaN70 -> -NaN70
-ddmns037 minus sNaN101 -> NaN101 Invalid_operation
-ddmns038 minus -sNaN101 -> -NaN101 Invalid_operation
-
--- finites
-ddmns101 minus 7 -> -7
-ddmns102 minus -7 -> 7
-ddmns103 minus 75 -> -75
-ddmns104 minus -75 -> 75
-ddmns105 minus 7.50 -> -7.50
-ddmns106 minus -7.50 -> 7.50
-ddmns107 minus 7.500 -> -7.500
-ddmns108 minus -7.500 -> 7.500
-
--- zeros
-ddmns111 minus 0 -> 0
-ddmns112 minus -0 -> 0
-ddmns113 minus 0E+4 -> 0E+4
-ddmns114 minus -0E+4 -> 0E+4
-ddmns115 minus 0.0000 -> 0.0000
-ddmns116 minus -0.0000 -> 0.0000
-ddmns117 minus 0E-141 -> 0E-141
-ddmns118 minus -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddmns121 minus 2682682682682682 -> -2682682682682682
-ddmns122 minus -2682682682682682 -> 2682682682682682
-ddmns123 minus 1341341341341341 -> -1341341341341341
-ddmns124 minus -1341341341341341 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddmns131 minus 9.999999999999999E+384 -> -9.999999999999999E+384
-ddmns132 minus 1E-383 -> -1E-383
-ddmns133 minus 1.000000000000000E-383 -> -1.000000000000000E-383
-ddmns134 minus 1E-398 -> -1E-398 Subnormal
-
-ddmns135 minus -1E-398 -> 1E-398 Subnormal
-ddmns136 minus -1.000000000000000E-383 -> 1.000000000000000E-383
-ddmns137 minus -1E-383 -> 1E-383
-ddmns138 minus -9.999999999999999E+384 -> 9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddMinus.decTest -- decDouble 0-x --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddmns001 minus +7.50 -> -7.50
+
+-- Infinities
+ddmns011 minus Infinity -> -Infinity
+ddmns012 minus -Infinity -> Infinity
+
+-- NaNs, 0 payload
+ddmns021 minus NaN -> NaN
+ddmns022 minus -NaN -> -NaN
+ddmns023 minus sNaN -> NaN Invalid_operation
+ddmns024 minus -sNaN -> -NaN Invalid_operation
+
+-- NaNs, non-0 payload
+ddmns031 minus NaN13 -> NaN13
+ddmns032 minus -NaN13 -> -NaN13
+ddmns033 minus sNaN13 -> NaN13 Invalid_operation
+ddmns034 minus -sNaN13 -> -NaN13 Invalid_operation
+ddmns035 minus NaN70 -> NaN70
+ddmns036 minus -NaN70 -> -NaN70
+ddmns037 minus sNaN101 -> NaN101 Invalid_operation
+ddmns038 minus -sNaN101 -> -NaN101 Invalid_operation
+
+-- finites
+ddmns101 minus 7 -> -7
+ddmns102 minus -7 -> 7
+ddmns103 minus 75 -> -75
+ddmns104 minus -75 -> 75
+ddmns105 minus 7.50 -> -7.50
+ddmns106 minus -7.50 -> 7.50
+ddmns107 minus 7.500 -> -7.500
+ddmns108 minus -7.500 -> 7.500
+
+-- zeros
+ddmns111 minus 0 -> 0
+ddmns112 minus -0 -> 0
+ddmns113 minus 0E+4 -> 0E+4
+ddmns114 minus -0E+4 -> 0E+4
+ddmns115 minus 0.0000 -> 0.0000
+ddmns116 minus -0.0000 -> 0.0000
+ddmns117 minus 0E-141 -> 0E-141
+ddmns118 minus -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddmns121 minus 2682682682682682 -> -2682682682682682
+ddmns122 minus -2682682682682682 -> 2682682682682682
+ddmns123 minus 1341341341341341 -> -1341341341341341
+ddmns124 minus -1341341341341341 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddmns131 minus 9.999999999999999E+384 -> -9.999999999999999E+384
+ddmns132 minus 1E-383 -> -1E-383
+ddmns133 minus 1.000000000000000E-383 -> -1.000000000000000E-383
+ddmns134 minus 1E-398 -> -1E-398 Subnormal
+
+ddmns135 minus -1E-398 -> 1E-398 Subnormal
+ddmns136 minus -1.000000000000000E-383 -> 1.000000000000000E-383
+ddmns137 minus -1E-383 -> 1E-383
+ddmns138 minus -9.999999999999999E+384 -> 9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddMultiply.decTest b/Lib/test/decimaltestdata/ddMultiply.decTest
index 5873f80345..45a381dc61 100644
--- a/Lib/test/decimaltestdata/ddMultiply.decTest
+++ b/Lib/test/decimaltestdata/ddMultiply.decTest
@@ -1,553 +1,553 @@
-------------------------------------------------------------------------
--- ddMultiply.decTest -- decDouble multiplication --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decDoubles only; all arguments are
--- representable in a decDouble
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmul000 multiply 2 2 -> 4
-ddmul001 multiply 2 3 -> 6
-ddmul002 multiply 5 1 -> 5
-ddmul003 multiply 5 2 -> 10
-ddmul004 multiply 1.20 2 -> 2.40
-ddmul005 multiply 1.20 0 -> 0.00
-ddmul006 multiply 1.20 -2 -> -2.40
-ddmul007 multiply -1.20 2 -> -2.40
-ddmul008 multiply -1.20 0 -> -0.00
-ddmul009 multiply -1.20 -2 -> 2.40
-ddmul010 multiply 5.09 7.1 -> 36.139
-ddmul011 multiply 2.5 4 -> 10.0
-ddmul012 multiply 2.50 4 -> 10.00
-ddmul013 multiply 1.23456789 1.00000000 -> 1.234567890000000 Rounded
-ddmul015 multiply 2.50 4 -> 10.00
-ddmul016 multiply 9.999999999 9.999999999 -> 99.99999998000000 Inexact Rounded
-ddmul017 multiply 9.999999999 -9.999999999 -> -99.99999998000000 Inexact Rounded
-ddmul018 multiply -9.999999999 9.999999999 -> -99.99999998000000 Inexact Rounded
-ddmul019 multiply -9.999999999 -9.999999999 -> 99.99999998000000 Inexact Rounded
-
--- zeros, etc.
-ddmul021 multiply 0 0 -> 0
-ddmul022 multiply 0 -0 -> -0
-ddmul023 multiply -0 0 -> -0
-ddmul024 multiply -0 -0 -> 0
-ddmul025 multiply -0.0 -0.0 -> 0.00
-ddmul026 multiply -0.0 -0.0 -> 0.00
-ddmul027 multiply -0.0 -0.0 -> 0.00
-ddmul028 multiply -0.0 -0.0 -> 0.00
-ddmul030 multiply 5.00 1E-3 -> 0.00500
-ddmul031 multiply 00.00 0.000 -> 0.00000
-ddmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
-ddmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
-ddmul034 multiply -5.00 1E-3 -> -0.00500
-ddmul035 multiply -00.00 0.000 -> -0.00000
-ddmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
-ddmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
-ddmul038 multiply 5.00 -1E-3 -> -0.00500
-ddmul039 multiply 00.00 -0.000 -> -0.00000
-ddmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
-ddmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
-ddmul042 multiply -5.00 -1E-3 -> 0.00500
-ddmul043 multiply -00.00 -0.000 -> 0.00000
-ddmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
-ddmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
-
--- examples from decarith
-ddmul050 multiply 1.20 3 -> 3.60
-ddmul051 multiply 7 3 -> 21
-ddmul052 multiply 0.9 0.8 -> 0.72
-ddmul053 multiply 0.9 -0 -> -0.0
-ddmul054 multiply 654321 654321 -> 428135971041
-
-ddmul060 multiply 123.45 1e7 -> 1.2345E+9
-ddmul061 multiply 123.45 1e8 -> 1.2345E+10
-ddmul062 multiply 123.45 1e+9 -> 1.2345E+11
-ddmul063 multiply 123.45 1e10 -> 1.2345E+12
-ddmul064 multiply 123.45 1e11 -> 1.2345E+13
-ddmul065 multiply 123.45 1e12 -> 1.2345E+14
-ddmul066 multiply 123.45 1e13 -> 1.2345E+15
-
-
--- test some intermediate lengths
--- 1234567890123456
-ddmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
-ddmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
-ddmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
-ddmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
-
--- test some more edge cases and carries
-ddmul101 multiply 9 9 -> 81
-ddmul102 multiply 9 90 -> 810
-ddmul103 multiply 9 900 -> 8100
-ddmul104 multiply 9 9000 -> 81000
-ddmul105 multiply 9 90000 -> 810000
-ddmul106 multiply 9 900000 -> 8100000
-ddmul107 multiply 9 9000000 -> 81000000
-ddmul108 multiply 9 90000000 -> 810000000
-ddmul109 multiply 9 900000000 -> 8100000000
-ddmul110 multiply 9 9000000000 -> 81000000000
-ddmul111 multiply 9 90000000000 -> 810000000000
-ddmul112 multiply 9 900000000000 -> 8100000000000
-ddmul113 multiply 9 9000000000000 -> 81000000000000
-ddmul114 multiply 9 90000000000000 -> 810000000000000
-ddmul115 multiply 9 900000000000000 -> 8100000000000000
---ddmul116 multiply 9 9000000000000000 -> 81000000000000000
---ddmul117 multiply 9 90000000000000000 -> 810000000000000000
---ddmul118 multiply 9 900000000000000000 -> 8100000000000000000
---ddmul119 multiply 9 9000000000000000000 -> 81000000000000000000
---ddmul120 multiply 9 90000000000000000000 -> 810000000000000000000
---ddmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
---ddmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
---ddmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
--- test some more edge cases without carries
-ddmul131 multiply 3 3 -> 9
-ddmul132 multiply 3 30 -> 90
-ddmul133 multiply 3 300 -> 900
-ddmul134 multiply 3 3000 -> 9000
-ddmul135 multiply 3 30000 -> 90000
-ddmul136 multiply 3 300000 -> 900000
-ddmul137 multiply 3 3000000 -> 9000000
-ddmul138 multiply 3 30000000 -> 90000000
-ddmul139 multiply 3 300000000 -> 900000000
-ddmul140 multiply 3 3000000000 -> 9000000000
-ddmul141 multiply 3 30000000000 -> 90000000000
-ddmul142 multiply 3 300000000000 -> 900000000000
-ddmul143 multiply 3 3000000000000 -> 9000000000000
-ddmul144 multiply 3 30000000000000 -> 90000000000000
-ddmul145 multiply 3 300000000000000 -> 900000000000000
-
--- test some edge cases with exact rounding
-ddmul301 multiply 9 9 -> 81
-ddmul302 multiply 9 90 -> 810
-ddmul303 multiply 9 900 -> 8100
-ddmul304 multiply 9 9000 -> 81000
-ddmul305 multiply 9 90000 -> 810000
-ddmul306 multiply 9 900000 -> 8100000
-ddmul307 multiply 9 9000000 -> 81000000
-ddmul308 multiply 9 90000000 -> 810000000
-ddmul309 multiply 9 900000000 -> 8100000000
-ddmul310 multiply 9 9000000000 -> 81000000000
-ddmul311 multiply 9 90000000000 -> 810000000000
-ddmul312 multiply 9 900000000000 -> 8100000000000
-ddmul313 multiply 9 9000000000000 -> 81000000000000
-ddmul314 multiply 9 90000000000000 -> 810000000000000
-ddmul315 multiply 9 900000000000000 -> 8100000000000000
-ddmul316 multiply 9 9000000000000000 -> 8.100000000000000E+16 Rounded
-ddmul317 multiply 90 9000000000000000 -> 8.100000000000000E+17 Rounded
-ddmul318 multiply 900 9000000000000000 -> 8.100000000000000E+18 Rounded
-ddmul319 multiply 9000 9000000000000000 -> 8.100000000000000E+19 Rounded
-ddmul320 multiply 90000 9000000000000000 -> 8.100000000000000E+20 Rounded
-ddmul321 multiply 900000 9000000000000000 -> 8.100000000000000E+21 Rounded
-ddmul322 multiply 9000000 9000000000000000 -> 8.100000000000000E+22 Rounded
-ddmul323 multiply 90000000 9000000000000000 -> 8.100000000000000E+23 Rounded
-
--- tryzeros cases
-ddmul504 multiply 0E-260 1000E-260 -> 0E-398 Clamped
-ddmul505 multiply 100E+260 0E+260 -> 0E+369 Clamped
--- 65K-1 case
-ddmul506 multiply 77.1 850 -> 65535.0
-
--- mixed with zeros
-ddmul541 multiply 0 -1 -> -0
-ddmul542 multiply -0 -1 -> 0
-ddmul543 multiply 0 1 -> 0
-ddmul544 multiply -0 1 -> -0
-ddmul545 multiply -1 0 -> -0
-ddmul546 multiply -1 -0 -> 0
-ddmul547 multiply 1 0 -> 0
-ddmul548 multiply 1 -0 -> -0
-
-ddmul551 multiply 0.0 -1 -> -0.0
-ddmul552 multiply -0.0 -1 -> 0.0
-ddmul553 multiply 0.0 1 -> 0.0
-ddmul554 multiply -0.0 1 -> -0.0
-ddmul555 multiply -1.0 0 -> -0.0
-ddmul556 multiply -1.0 -0 -> 0.0
-ddmul557 multiply 1.0 0 -> 0.0
-ddmul558 multiply 1.0 -0 -> -0.0
-
-ddmul561 multiply 0 -1.0 -> -0.0
-ddmul562 multiply -0 -1.0 -> 0.0
-ddmul563 multiply 0 1.0 -> 0.0
-ddmul564 multiply -0 1.0 -> -0.0
-ddmul565 multiply -1 0.0 -> -0.0
-ddmul566 multiply -1 -0.0 -> 0.0
-ddmul567 multiply 1 0.0 -> 0.0
-ddmul568 multiply 1 -0.0 -> -0.0
-
-ddmul571 multiply 0.0 -1.0 -> -0.00
-ddmul572 multiply -0.0 -1.0 -> 0.00
-ddmul573 multiply 0.0 1.0 -> 0.00
-ddmul574 multiply -0.0 1.0 -> -0.00
-ddmul575 multiply -1.0 0.0 -> -0.00
-ddmul576 multiply -1.0 -0.0 -> 0.00
-ddmul577 multiply 1.0 0.0 -> 0.00
-ddmul578 multiply 1.0 -0.0 -> -0.00
-
-
--- Specials
-ddmul580 multiply Inf -Inf -> -Infinity
-ddmul581 multiply Inf -1000 -> -Infinity
-ddmul582 multiply Inf -1 -> -Infinity
-ddmul583 multiply Inf -0 -> NaN Invalid_operation
-ddmul584 multiply Inf 0 -> NaN Invalid_operation
-ddmul585 multiply Inf 1 -> Infinity
-ddmul586 multiply Inf 1000 -> Infinity
-ddmul587 multiply Inf Inf -> Infinity
-ddmul588 multiply -1000 Inf -> -Infinity
-ddmul589 multiply -Inf Inf -> -Infinity
-ddmul590 multiply -1 Inf -> -Infinity
-ddmul591 multiply -0 Inf -> NaN Invalid_operation
-ddmul592 multiply 0 Inf -> NaN Invalid_operation
-ddmul593 multiply 1 Inf -> Infinity
-ddmul594 multiply 1000 Inf -> Infinity
-ddmul595 multiply Inf Inf -> Infinity
-
-ddmul600 multiply -Inf -Inf -> Infinity
-ddmul601 multiply -Inf -1000 -> Infinity
-ddmul602 multiply -Inf -1 -> Infinity
-ddmul603 multiply -Inf -0 -> NaN Invalid_operation
-ddmul604 multiply -Inf 0 -> NaN Invalid_operation
-ddmul605 multiply -Inf 1 -> -Infinity
-ddmul606 multiply -Inf 1000 -> -Infinity
-ddmul607 multiply -Inf Inf -> -Infinity
-ddmul608 multiply -1000 Inf -> -Infinity
-ddmul609 multiply -Inf -Inf -> Infinity
-ddmul610 multiply -1 -Inf -> Infinity
-ddmul611 multiply -0 -Inf -> NaN Invalid_operation
-ddmul612 multiply 0 -Inf -> NaN Invalid_operation
-ddmul613 multiply 1 -Inf -> -Infinity
-ddmul614 multiply 1000 -Inf -> -Infinity
-ddmul615 multiply Inf -Inf -> -Infinity
-
-ddmul621 multiply NaN -Inf -> NaN
-ddmul622 multiply NaN -1000 -> NaN
-ddmul623 multiply NaN -1 -> NaN
-ddmul624 multiply NaN -0 -> NaN
-ddmul625 multiply NaN 0 -> NaN
-ddmul626 multiply NaN 1 -> NaN
-ddmul627 multiply NaN 1000 -> NaN
-ddmul628 multiply NaN Inf -> NaN
-ddmul629 multiply NaN NaN -> NaN
-ddmul630 multiply -Inf NaN -> NaN
-ddmul631 multiply -1000 NaN -> NaN
-ddmul632 multiply -1 NaN -> NaN
-ddmul633 multiply -0 NaN -> NaN
-ddmul634 multiply 0 NaN -> NaN
-ddmul635 multiply 1 NaN -> NaN
-ddmul636 multiply 1000 NaN -> NaN
-ddmul637 multiply Inf NaN -> NaN
-
-ddmul641 multiply sNaN -Inf -> NaN Invalid_operation
-ddmul642 multiply sNaN -1000 -> NaN Invalid_operation
-ddmul643 multiply sNaN -1 -> NaN Invalid_operation
-ddmul644 multiply sNaN -0 -> NaN Invalid_operation
-ddmul645 multiply sNaN 0 -> NaN Invalid_operation
-ddmul646 multiply sNaN 1 -> NaN Invalid_operation
-ddmul647 multiply sNaN 1000 -> NaN Invalid_operation
-ddmul648 multiply sNaN NaN -> NaN Invalid_operation
-ddmul649 multiply sNaN sNaN -> NaN Invalid_operation
-ddmul650 multiply NaN sNaN -> NaN Invalid_operation
-ddmul651 multiply -Inf sNaN -> NaN Invalid_operation
-ddmul652 multiply -1000 sNaN -> NaN Invalid_operation
-ddmul653 multiply -1 sNaN -> NaN Invalid_operation
-ddmul654 multiply -0 sNaN -> NaN Invalid_operation
-ddmul655 multiply 0 sNaN -> NaN Invalid_operation
-ddmul656 multiply 1 sNaN -> NaN Invalid_operation
-ddmul657 multiply 1000 sNaN -> NaN Invalid_operation
-ddmul658 multiply Inf sNaN -> NaN Invalid_operation
-ddmul659 multiply NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmul661 multiply NaN9 -Inf -> NaN9
-ddmul662 multiply NaN8 999 -> NaN8
-ddmul663 multiply NaN71 Inf -> NaN71
-ddmul664 multiply NaN6 NaN5 -> NaN6
-ddmul665 multiply -Inf NaN4 -> NaN4
-ddmul666 multiply -999 NaN33 -> NaN33
-ddmul667 multiply Inf NaN2 -> NaN2
-
-ddmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
-ddmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
-ddmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
-ddmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
-ddmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
-ddmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
-ddmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
-ddmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
-
-ddmul681 multiply -NaN9 -Inf -> -NaN9
-ddmul682 multiply -NaN8 999 -> -NaN8
-ddmul683 multiply -NaN71 Inf -> -NaN71
-ddmul684 multiply -NaN6 -NaN5 -> -NaN6
-ddmul685 multiply -Inf -NaN4 -> -NaN4
-ddmul686 multiply -999 -NaN33 -> -NaN33
-ddmul687 multiply Inf -NaN2 -> -NaN2
-
-ddmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
-ddmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
-ddmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
-ddmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
-ddmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-ddmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
-ddmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
-ddmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
-
-ddmul701 multiply -NaN -Inf -> -NaN
-ddmul702 multiply -NaN 999 -> -NaN
-ddmul703 multiply -NaN Inf -> -NaN
-ddmul704 multiply -NaN -NaN -> -NaN
-ddmul705 multiply -Inf -NaN0 -> -NaN
-ddmul706 multiply -999 -NaN -> -NaN
-ddmul707 multiply Inf -NaN -> -NaN
-
-ddmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
-ddmul712 multiply -sNaN -11 -> -NaN Invalid_operation
-ddmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
-ddmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
-ddmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
-ddmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
-ddmul717 multiply 088 -sNaN -> -NaN Invalid_operation
-ddmul718 multiply Inf -sNaN -> -NaN Invalid_operation
-ddmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
--- signs
-ddmul751 multiply 1e+277 1e+311 -> Infinity Overflow Inexact Rounded
-ddmul752 multiply 1e+277 -1e+311 -> -Infinity Overflow Inexact Rounded
-ddmul753 multiply -1e+277 1e+311 -> -Infinity Overflow Inexact Rounded
-ddmul754 multiply -1e+277 -1e+311 -> Infinity Overflow Inexact Rounded
-ddmul755 multiply 1e-277 1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul756 multiply 1e-277 -1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul757 multiply -1e-277 1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul758 multiply -1e-277 -1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-ddmul760 multiply 1e-291 1e-101 -> 1E-392 Subnormal
-ddmul761 multiply 1e-291 1e-102 -> 1E-393 Subnormal
-ddmul762 multiply 1e-291 1e-103 -> 1E-394 Subnormal
-ddmul763 multiply 1e-291 1e-104 -> 1E-395 Subnormal
-ddmul764 multiply 1e-291 1e-105 -> 1E-396 Subnormal
-ddmul765 multiply 1e-291 1e-106 -> 1E-397 Subnormal
-ddmul766 multiply 1e-291 1e-107 -> 1E-398 Subnormal
-ddmul767 multiply 1e-291 1e-108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul768 multiply 1e-291 1e-109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul769 multiply 1e-291 1e-110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-ddmul770 multiply 1e+60 1e+321 -> 1.000000000000E+381 Clamped
-ddmul771 multiply 1e+60 1e+322 -> 1.0000000000000E+382 Clamped
-ddmul772 multiply 1e+60 1e+323 -> 1.00000000000000E+383 Clamped
-ddmul773 multiply 1e+60 1e+324 -> 1.000000000000000E+384 Clamped
-ddmul774 multiply 1e+60 1e+325 -> Infinity Overflow Inexact Rounded
-ddmul775 multiply 1e+60 1e+326 -> Infinity Overflow Inexact Rounded
-ddmul776 multiply 1e+60 1e+327 -> Infinity Overflow Inexact Rounded
-ddmul777 multiply 1e+60 1e+328 -> Infinity Overflow Inexact Rounded
-ddmul778 multiply 1e+60 1e+329 -> Infinity Overflow Inexact Rounded
-ddmul779 multiply 1e+60 1e+330 -> Infinity Overflow Inexact Rounded
-
-ddmul801 multiply 1.0000E-394 1 -> 1.0000E-394 Subnormal
-ddmul802 multiply 1.000E-394 1e-1 -> 1.000E-395 Subnormal
-ddmul803 multiply 1.00E-394 1e-2 -> 1.00E-396 Subnormal
-ddmul804 multiply 1.0E-394 1e-3 -> 1.0E-397 Subnormal
-ddmul805 multiply 1.0E-394 1e-4 -> 1E-398 Subnormal Rounded
-ddmul806 multiply 1.3E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddmul807 multiply 1.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul808 multiply 1.7E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul809 multiply 2.3E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul810 multiply 2.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul811 multiply 2.7E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
-ddmul812 multiply 1.49E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddmul813 multiply 1.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul814 multiply 1.51E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul815 multiply 2.49E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul816 multiply 2.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul817 multiply 2.51E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
-
-ddmul818 multiply 1E-394 1e-4 -> 1E-398 Subnormal
-ddmul819 multiply 3E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul820 multiply 5E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul821 multiply 7E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddmul822 multiply 9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddmul823 multiply 9.9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
-
-ddmul824 multiply 1E-394 -1e-4 -> -1E-398 Subnormal
-ddmul825 multiply 3E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul826 multiply -5E-394 1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul827 multiply 7E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddmul828 multiply -9E-394 1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddmul829 multiply 9.9E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddmul830 multiply 3.0E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-ddmul831 multiply 1.0E-199 1e-200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul832 multiply 1.0E-199 1e-199 -> 1E-398 Subnormal Rounded
-ddmul833 multiply 1.0E-199 1e-198 -> 1.0E-397 Subnormal
-ddmul834 multiply 2.0E-199 2e-198 -> 4.0E-397 Subnormal
-ddmul835 multiply 4.0E-199 4e-198 -> 1.60E-396 Subnormal
-ddmul836 multiply 10.0E-199 10e-198 -> 1.000E-395 Subnormal
-ddmul837 multiply 30.0E-199 30e-198 -> 9.000E-395 Subnormal
-ddmul838 multiply 40.0E-199 40e-188 -> 1.6000E-384 Subnormal
-ddmul839 multiply 40.0E-199 40e-187 -> 1.6000E-383
-ddmul840 multiply 40.0E-199 40e-186 -> 1.6000E-382
-
--- Long operand overflow may be a different path
-ddmul870 multiply 100 9.999E+383 -> Infinity Inexact Overflow Rounded
-ddmul871 multiply 100 -9.999E+383 -> -Infinity Inexact Overflow Rounded
-ddmul872 multiply 9.999E+383 100 -> Infinity Inexact Overflow Rounded
-ddmul873 multiply -9.999E+383 100 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-ddmul881 multiply 1.2347E-355 1.2347E-40 -> 1.524E-395 Inexact Rounded Subnormal Underflow
-ddmul882 multiply 1.234E-355 1.234E-40 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddmul883 multiply 1.23E-355 1.23E-40 -> 1.513E-395 Inexact Rounded Subnormal Underflow
-ddmul884 multiply 1.2E-355 1.2E-40 -> 1.44E-395 Subnormal
-ddmul885 multiply 1.2E-355 1.2E-41 -> 1.44E-396 Subnormal
-ddmul886 multiply 1.2E-355 1.2E-42 -> 1.4E-397 Subnormal Inexact Rounded Underflow
-ddmul887 multiply 1.2E-355 1.3E-42 -> 1.6E-397 Subnormal Inexact Rounded Underflow
-ddmul888 multiply 1.3E-355 1.3E-42 -> 1.7E-397 Subnormal Inexact Rounded Underflow
-ddmul889 multiply 1.3E-355 1.3E-43 -> 2E-398 Subnormal Inexact Rounded Underflow
-ddmul890 multiply 1.3E-356 1.3E-43 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
-
-ddmul891 multiply 1.2345E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
-ddmul892 multiply 1.23456E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
-ddmul893 multiply 1.2345E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddmul894 multiply 1.23456E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddmul895 multiply 1.2345E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
-ddmul896 multiply 1.23456E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
--- 1 234567890123456
-ddmul900 multiply 0.3000000000E-191 0.3000000000E-191 -> 9.00000000000000E-384 Subnormal Rounded
-ddmul901 multiply 0.3000000001E-191 0.3000000001E-191 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
-ddmul902 multiply 9.999999999999999E-383 0.0999999999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
-ddmul903 multiply 9.999999999999999E-383 0.09999999999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
-ddmul904 multiply 9.999999999999999E-383 0.099999999999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
-ddmul905 multiply 9.999999999999999E-383 0.0999999999999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
--- The next rounds to Nmin (b**emin); this is the distinguishing case
--- for detecting tininess (before or after rounding) -- if after
--- rounding then the result would be the same, but the Underflow flag
--- would not be set
-ddmul906 multiply 9.999999999999999E-383 0.09999999999999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
--- prove those operands were exact
-ddmul907 multiply 9.999999999999999E-383 1 -> 9.999999999999999E-383
-ddmul908 multiply 1 0.09999999999999999 -> 0.09999999999999999
-
--- reducing tiniest
-ddmul910 multiply 1e-398 0.99 -> 1E-398 Subnormal Inexact Rounded Underflow
-ddmul911 multiply 1e-398 0.75 -> 1E-398 Subnormal Inexact Rounded Underflow
-ddmul912 multiply 1e-398 0.5 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-ddmul913 multiply 1e-398 0.25 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-ddmul914 multiply 1e-398 0.01 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-
--- hugest
-ddmul920 multiply 9999999999999999 9999999999999999 -> 9.999999999999998E+31 Inexact Rounded
-
--- power-of-ten edge cases
-ddmul1001 multiply 1 10 -> 10
-ddmul1002 multiply 1 100 -> 100
-ddmul1003 multiply 1 1000 -> 1000
-ddmul1004 multiply 1 10000 -> 10000
-ddmul1005 multiply 1 100000 -> 100000
-ddmul1006 multiply 1 1000000 -> 1000000
-ddmul1007 multiply 1 10000000 -> 10000000
-ddmul1008 multiply 1 100000000 -> 100000000
-ddmul1009 multiply 1 1000000000 -> 1000000000
-ddmul1010 multiply 1 10000000000 -> 10000000000
-ddmul1011 multiply 1 100000000000 -> 100000000000
-ddmul1012 multiply 1 1000000000000 -> 1000000000000
-ddmul1013 multiply 1 10000000000000 -> 10000000000000
-ddmul1014 multiply 1 100000000000000 -> 100000000000000
-ddmul1015 multiply 1 1000000000000000 -> 1000000000000000
-ddmul1021 multiply 10 1 -> 10
-ddmul1022 multiply 10 10 -> 100
-ddmul1023 multiply 10 100 -> 1000
-ddmul1024 multiply 10 1000 -> 10000
-ddmul1025 multiply 10 10000 -> 100000
-ddmul1026 multiply 10 100000 -> 1000000
-ddmul1027 multiply 10 1000000 -> 10000000
-ddmul1028 multiply 10 10000000 -> 100000000
-ddmul1029 multiply 10 100000000 -> 1000000000
-ddmul1030 multiply 10 1000000000 -> 10000000000
-ddmul1031 multiply 10 10000000000 -> 100000000000
-ddmul1032 multiply 10 100000000000 -> 1000000000000
-ddmul1033 multiply 10 1000000000000 -> 10000000000000
-ddmul1034 multiply 10 10000000000000 -> 100000000000000
-ddmul1035 multiply 10 100000000000000 -> 1000000000000000
-ddmul1041 multiply 100 0.1 -> 10.0
-ddmul1042 multiply 100 1 -> 100
-ddmul1043 multiply 100 10 -> 1000
-ddmul1044 multiply 100 100 -> 10000
-ddmul1045 multiply 100 1000 -> 100000
-ddmul1046 multiply 100 10000 -> 1000000
-ddmul1047 multiply 100 100000 -> 10000000
-ddmul1048 multiply 100 1000000 -> 100000000
-ddmul1049 multiply 100 10000000 -> 1000000000
-ddmul1050 multiply 100 100000000 -> 10000000000
-ddmul1051 multiply 100 1000000000 -> 100000000000
-ddmul1052 multiply 100 10000000000 -> 1000000000000
-ddmul1053 multiply 100 100000000000 -> 10000000000000
-ddmul1054 multiply 100 1000000000000 -> 100000000000000
-ddmul1055 multiply 100 10000000000000 -> 1000000000000000
-ddmul1061 multiply 1000 0.01 -> 10.00
-ddmul1062 multiply 1000 0.1 -> 100.0
-ddmul1063 multiply 1000 1 -> 1000
-ddmul1064 multiply 1000 10 -> 10000
-ddmul1065 multiply 1000 100 -> 100000
-ddmul1066 multiply 1000 1000 -> 1000000
-ddmul1067 multiply 1000 10000 -> 10000000
-ddmul1068 multiply 1000 100000 -> 100000000
-ddmul1069 multiply 1000 1000000 -> 1000000000
-ddmul1070 multiply 1000 10000000 -> 10000000000
-ddmul1071 multiply 1000 100000000 -> 100000000000
-ddmul1072 multiply 1000 1000000000 -> 1000000000000
-ddmul1073 multiply 1000 10000000000 -> 10000000000000
-ddmul1074 multiply 1000 100000000000 -> 100000000000000
-ddmul1075 multiply 1000 1000000000000 -> 1000000000000000
-ddmul1081 multiply 10000 0.001 -> 10.000
-ddmul1082 multiply 10000 0.01 -> 100.00
-ddmul1083 multiply 10000 0.1 -> 1000.0
-ddmul1084 multiply 10000 1 -> 10000
-ddmul1085 multiply 10000 10 -> 100000
-ddmul1086 multiply 10000 100 -> 1000000
-ddmul1087 multiply 10000 1000 -> 10000000
-ddmul1088 multiply 10000 10000 -> 100000000
-ddmul1089 multiply 10000 100000 -> 1000000000
-ddmul1090 multiply 10000 1000000 -> 10000000000
-ddmul1091 multiply 10000 10000000 -> 100000000000
-ddmul1092 multiply 10000 100000000 -> 1000000000000
-ddmul1093 multiply 10000 1000000000 -> 10000000000000
-ddmul1094 multiply 10000 10000000000 -> 100000000000000
-ddmul1095 multiply 10000 100000000000 -> 1000000000000000
-
-ddmul1097 multiply 10000 99999999999 -> 999999999990000
-ddmul1098 multiply 10000 99999999999 -> 999999999990000
-
-
--- Null tests
-ddmul9990 multiply 10 # -> NaN Invalid_operation
-ddmul9991 multiply # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddMultiply.decTest -- decDouble multiplication --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decDoubles only; all arguments are
+-- representable in a decDouble
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmul000 multiply 2 2 -> 4
+ddmul001 multiply 2 3 -> 6
+ddmul002 multiply 5 1 -> 5
+ddmul003 multiply 5 2 -> 10
+ddmul004 multiply 1.20 2 -> 2.40
+ddmul005 multiply 1.20 0 -> 0.00
+ddmul006 multiply 1.20 -2 -> -2.40
+ddmul007 multiply -1.20 2 -> -2.40
+ddmul008 multiply -1.20 0 -> -0.00
+ddmul009 multiply -1.20 -2 -> 2.40
+ddmul010 multiply 5.09 7.1 -> 36.139
+ddmul011 multiply 2.5 4 -> 10.0
+ddmul012 multiply 2.50 4 -> 10.00
+ddmul013 multiply 1.23456789 1.00000000 -> 1.234567890000000 Rounded
+ddmul015 multiply 2.50 4 -> 10.00
+ddmul016 multiply 9.999999999 9.999999999 -> 99.99999998000000 Inexact Rounded
+ddmul017 multiply 9.999999999 -9.999999999 -> -99.99999998000000 Inexact Rounded
+ddmul018 multiply -9.999999999 9.999999999 -> -99.99999998000000 Inexact Rounded
+ddmul019 multiply -9.999999999 -9.999999999 -> 99.99999998000000 Inexact Rounded
+
+-- zeros, etc.
+ddmul021 multiply 0 0 -> 0
+ddmul022 multiply 0 -0 -> -0
+ddmul023 multiply -0 0 -> -0
+ddmul024 multiply -0 -0 -> 0
+ddmul025 multiply -0.0 -0.0 -> 0.00
+ddmul026 multiply -0.0 -0.0 -> 0.00
+ddmul027 multiply -0.0 -0.0 -> 0.00
+ddmul028 multiply -0.0 -0.0 -> 0.00
+ddmul030 multiply 5.00 1E-3 -> 0.00500
+ddmul031 multiply 00.00 0.000 -> 0.00000
+ddmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
+ddmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
+ddmul034 multiply -5.00 1E-3 -> -0.00500
+ddmul035 multiply -00.00 0.000 -> -0.00000
+ddmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
+ddmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
+ddmul038 multiply 5.00 -1E-3 -> -0.00500
+ddmul039 multiply 00.00 -0.000 -> -0.00000
+ddmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
+ddmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
+ddmul042 multiply -5.00 -1E-3 -> 0.00500
+ddmul043 multiply -00.00 -0.000 -> 0.00000
+ddmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
+ddmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
+
+-- examples from decarith
+ddmul050 multiply 1.20 3 -> 3.60
+ddmul051 multiply 7 3 -> 21
+ddmul052 multiply 0.9 0.8 -> 0.72
+ddmul053 multiply 0.9 -0 -> -0.0
+ddmul054 multiply 654321 654321 -> 428135971041
+
+ddmul060 multiply 123.45 1e7 -> 1.2345E+9
+ddmul061 multiply 123.45 1e8 -> 1.2345E+10
+ddmul062 multiply 123.45 1e+9 -> 1.2345E+11
+ddmul063 multiply 123.45 1e10 -> 1.2345E+12
+ddmul064 multiply 123.45 1e11 -> 1.2345E+13
+ddmul065 multiply 123.45 1e12 -> 1.2345E+14
+ddmul066 multiply 123.45 1e13 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+-- 1234567890123456
+ddmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
+ddmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
+ddmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
+ddmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
+
+-- test some more edge cases and carries
+ddmul101 multiply 9 9 -> 81
+ddmul102 multiply 9 90 -> 810
+ddmul103 multiply 9 900 -> 8100
+ddmul104 multiply 9 9000 -> 81000
+ddmul105 multiply 9 90000 -> 810000
+ddmul106 multiply 9 900000 -> 8100000
+ddmul107 multiply 9 9000000 -> 81000000
+ddmul108 multiply 9 90000000 -> 810000000
+ddmul109 multiply 9 900000000 -> 8100000000
+ddmul110 multiply 9 9000000000 -> 81000000000
+ddmul111 multiply 9 90000000000 -> 810000000000
+ddmul112 multiply 9 900000000000 -> 8100000000000
+ddmul113 multiply 9 9000000000000 -> 81000000000000
+ddmul114 multiply 9 90000000000000 -> 810000000000000
+ddmul115 multiply 9 900000000000000 -> 8100000000000000
+--ddmul116 multiply 9 9000000000000000 -> 81000000000000000
+--ddmul117 multiply 9 90000000000000000 -> 810000000000000000
+--ddmul118 multiply 9 900000000000000000 -> 8100000000000000000
+--ddmul119 multiply 9 9000000000000000000 -> 81000000000000000000
+--ddmul120 multiply 9 90000000000000000000 -> 810000000000000000000
+--ddmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
+--ddmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
+--ddmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
+-- test some more edge cases without carries
+ddmul131 multiply 3 3 -> 9
+ddmul132 multiply 3 30 -> 90
+ddmul133 multiply 3 300 -> 900
+ddmul134 multiply 3 3000 -> 9000
+ddmul135 multiply 3 30000 -> 90000
+ddmul136 multiply 3 300000 -> 900000
+ddmul137 multiply 3 3000000 -> 9000000
+ddmul138 multiply 3 30000000 -> 90000000
+ddmul139 multiply 3 300000000 -> 900000000
+ddmul140 multiply 3 3000000000 -> 9000000000
+ddmul141 multiply 3 30000000000 -> 90000000000
+ddmul142 multiply 3 300000000000 -> 900000000000
+ddmul143 multiply 3 3000000000000 -> 9000000000000
+ddmul144 multiply 3 30000000000000 -> 90000000000000
+ddmul145 multiply 3 300000000000000 -> 900000000000000
+
+-- test some edge cases with exact rounding
+ddmul301 multiply 9 9 -> 81
+ddmul302 multiply 9 90 -> 810
+ddmul303 multiply 9 900 -> 8100
+ddmul304 multiply 9 9000 -> 81000
+ddmul305 multiply 9 90000 -> 810000
+ddmul306 multiply 9 900000 -> 8100000
+ddmul307 multiply 9 9000000 -> 81000000
+ddmul308 multiply 9 90000000 -> 810000000
+ddmul309 multiply 9 900000000 -> 8100000000
+ddmul310 multiply 9 9000000000 -> 81000000000
+ddmul311 multiply 9 90000000000 -> 810000000000
+ddmul312 multiply 9 900000000000 -> 8100000000000
+ddmul313 multiply 9 9000000000000 -> 81000000000000
+ddmul314 multiply 9 90000000000000 -> 810000000000000
+ddmul315 multiply 9 900000000000000 -> 8100000000000000
+ddmul316 multiply 9 9000000000000000 -> 8.100000000000000E+16 Rounded
+ddmul317 multiply 90 9000000000000000 -> 8.100000000000000E+17 Rounded
+ddmul318 multiply 900 9000000000000000 -> 8.100000000000000E+18 Rounded
+ddmul319 multiply 9000 9000000000000000 -> 8.100000000000000E+19 Rounded
+ddmul320 multiply 90000 9000000000000000 -> 8.100000000000000E+20 Rounded
+ddmul321 multiply 900000 9000000000000000 -> 8.100000000000000E+21 Rounded
+ddmul322 multiply 9000000 9000000000000000 -> 8.100000000000000E+22 Rounded
+ddmul323 multiply 90000000 9000000000000000 -> 8.100000000000000E+23 Rounded
+
+-- tryzeros cases
+ddmul504 multiply 0E-260 1000E-260 -> 0E-398 Clamped
+ddmul505 multiply 100E+260 0E+260 -> 0E+369 Clamped
+-- 65K-1 case
+ddmul506 multiply 77.1 850 -> 65535.0
+
+-- mixed with zeros
+ddmul541 multiply 0 -1 -> -0
+ddmul542 multiply -0 -1 -> 0
+ddmul543 multiply 0 1 -> 0
+ddmul544 multiply -0 1 -> -0
+ddmul545 multiply -1 0 -> -0
+ddmul546 multiply -1 -0 -> 0
+ddmul547 multiply 1 0 -> 0
+ddmul548 multiply 1 -0 -> -0
+
+ddmul551 multiply 0.0 -1 -> -0.0
+ddmul552 multiply -0.0 -1 -> 0.0
+ddmul553 multiply 0.0 1 -> 0.0
+ddmul554 multiply -0.0 1 -> -0.0
+ddmul555 multiply -1.0 0 -> -0.0
+ddmul556 multiply -1.0 -0 -> 0.0
+ddmul557 multiply 1.0 0 -> 0.0
+ddmul558 multiply 1.0 -0 -> -0.0
+
+ddmul561 multiply 0 -1.0 -> -0.0
+ddmul562 multiply -0 -1.0 -> 0.0
+ddmul563 multiply 0 1.0 -> 0.0
+ddmul564 multiply -0 1.0 -> -0.0
+ddmul565 multiply -1 0.0 -> -0.0
+ddmul566 multiply -1 -0.0 -> 0.0
+ddmul567 multiply 1 0.0 -> 0.0
+ddmul568 multiply 1 -0.0 -> -0.0
+
+ddmul571 multiply 0.0 -1.0 -> -0.00
+ddmul572 multiply -0.0 -1.0 -> 0.00
+ddmul573 multiply 0.0 1.0 -> 0.00
+ddmul574 multiply -0.0 1.0 -> -0.00
+ddmul575 multiply -1.0 0.0 -> -0.00
+ddmul576 multiply -1.0 -0.0 -> 0.00
+ddmul577 multiply 1.0 0.0 -> 0.00
+ddmul578 multiply 1.0 -0.0 -> -0.00
+
+
+-- Specials
+ddmul580 multiply Inf -Inf -> -Infinity
+ddmul581 multiply Inf -1000 -> -Infinity
+ddmul582 multiply Inf -1 -> -Infinity
+ddmul583 multiply Inf -0 -> NaN Invalid_operation
+ddmul584 multiply Inf 0 -> NaN Invalid_operation
+ddmul585 multiply Inf 1 -> Infinity
+ddmul586 multiply Inf 1000 -> Infinity
+ddmul587 multiply Inf Inf -> Infinity
+ddmul588 multiply -1000 Inf -> -Infinity
+ddmul589 multiply -Inf Inf -> -Infinity
+ddmul590 multiply -1 Inf -> -Infinity
+ddmul591 multiply -0 Inf -> NaN Invalid_operation
+ddmul592 multiply 0 Inf -> NaN Invalid_operation
+ddmul593 multiply 1 Inf -> Infinity
+ddmul594 multiply 1000 Inf -> Infinity
+ddmul595 multiply Inf Inf -> Infinity
+
+ddmul600 multiply -Inf -Inf -> Infinity
+ddmul601 multiply -Inf -1000 -> Infinity
+ddmul602 multiply -Inf -1 -> Infinity
+ddmul603 multiply -Inf -0 -> NaN Invalid_operation
+ddmul604 multiply -Inf 0 -> NaN Invalid_operation
+ddmul605 multiply -Inf 1 -> -Infinity
+ddmul606 multiply -Inf 1000 -> -Infinity
+ddmul607 multiply -Inf Inf -> -Infinity
+ddmul608 multiply -1000 Inf -> -Infinity
+ddmul609 multiply -Inf -Inf -> Infinity
+ddmul610 multiply -1 -Inf -> Infinity
+ddmul611 multiply -0 -Inf -> NaN Invalid_operation
+ddmul612 multiply 0 -Inf -> NaN Invalid_operation
+ddmul613 multiply 1 -Inf -> -Infinity
+ddmul614 multiply 1000 -Inf -> -Infinity
+ddmul615 multiply Inf -Inf -> -Infinity
+
+ddmul621 multiply NaN -Inf -> NaN
+ddmul622 multiply NaN -1000 -> NaN
+ddmul623 multiply NaN -1 -> NaN
+ddmul624 multiply NaN -0 -> NaN
+ddmul625 multiply NaN 0 -> NaN
+ddmul626 multiply NaN 1 -> NaN
+ddmul627 multiply NaN 1000 -> NaN
+ddmul628 multiply NaN Inf -> NaN
+ddmul629 multiply NaN NaN -> NaN
+ddmul630 multiply -Inf NaN -> NaN
+ddmul631 multiply -1000 NaN -> NaN
+ddmul632 multiply -1 NaN -> NaN
+ddmul633 multiply -0 NaN -> NaN
+ddmul634 multiply 0 NaN -> NaN
+ddmul635 multiply 1 NaN -> NaN
+ddmul636 multiply 1000 NaN -> NaN
+ddmul637 multiply Inf NaN -> NaN
+
+ddmul641 multiply sNaN -Inf -> NaN Invalid_operation
+ddmul642 multiply sNaN -1000 -> NaN Invalid_operation
+ddmul643 multiply sNaN -1 -> NaN Invalid_operation
+ddmul644 multiply sNaN -0 -> NaN Invalid_operation
+ddmul645 multiply sNaN 0 -> NaN Invalid_operation
+ddmul646 multiply sNaN 1 -> NaN Invalid_operation
+ddmul647 multiply sNaN 1000 -> NaN Invalid_operation
+ddmul648 multiply sNaN NaN -> NaN Invalid_operation
+ddmul649 multiply sNaN sNaN -> NaN Invalid_operation
+ddmul650 multiply NaN sNaN -> NaN Invalid_operation
+ddmul651 multiply -Inf sNaN -> NaN Invalid_operation
+ddmul652 multiply -1000 sNaN -> NaN Invalid_operation
+ddmul653 multiply -1 sNaN -> NaN Invalid_operation
+ddmul654 multiply -0 sNaN -> NaN Invalid_operation
+ddmul655 multiply 0 sNaN -> NaN Invalid_operation
+ddmul656 multiply 1 sNaN -> NaN Invalid_operation
+ddmul657 multiply 1000 sNaN -> NaN Invalid_operation
+ddmul658 multiply Inf sNaN -> NaN Invalid_operation
+ddmul659 multiply NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmul661 multiply NaN9 -Inf -> NaN9
+ddmul662 multiply NaN8 999 -> NaN8
+ddmul663 multiply NaN71 Inf -> NaN71
+ddmul664 multiply NaN6 NaN5 -> NaN6
+ddmul665 multiply -Inf NaN4 -> NaN4
+ddmul666 multiply -999 NaN33 -> NaN33
+ddmul667 multiply Inf NaN2 -> NaN2
+
+ddmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
+ddmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
+ddmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
+ddmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
+ddmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
+ddmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
+ddmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
+ddmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
+
+ddmul681 multiply -NaN9 -Inf -> -NaN9
+ddmul682 multiply -NaN8 999 -> -NaN8
+ddmul683 multiply -NaN71 Inf -> -NaN71
+ddmul684 multiply -NaN6 -NaN5 -> -NaN6
+ddmul685 multiply -Inf -NaN4 -> -NaN4
+ddmul686 multiply -999 -NaN33 -> -NaN33
+ddmul687 multiply Inf -NaN2 -> -NaN2
+
+ddmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
+ddmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
+ddmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
+ddmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
+ddmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+ddmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
+ddmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
+ddmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
+
+ddmul701 multiply -NaN -Inf -> -NaN
+ddmul702 multiply -NaN 999 -> -NaN
+ddmul703 multiply -NaN Inf -> -NaN
+ddmul704 multiply -NaN -NaN -> -NaN
+ddmul705 multiply -Inf -NaN0 -> -NaN
+ddmul706 multiply -999 -NaN -> -NaN
+ddmul707 multiply Inf -NaN -> -NaN
+
+ddmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
+ddmul712 multiply -sNaN -11 -> -NaN Invalid_operation
+ddmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
+ddmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
+ddmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
+ddmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
+ddmul717 multiply 088 -sNaN -> -NaN Invalid_operation
+ddmul718 multiply Inf -sNaN -> -NaN Invalid_operation
+ddmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+ddmul751 multiply 1e+277 1e+311 -> Infinity Overflow Inexact Rounded
+ddmul752 multiply 1e+277 -1e+311 -> -Infinity Overflow Inexact Rounded
+ddmul753 multiply -1e+277 1e+311 -> -Infinity Overflow Inexact Rounded
+ddmul754 multiply -1e+277 -1e+311 -> Infinity Overflow Inexact Rounded
+ddmul755 multiply 1e-277 1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul756 multiply 1e-277 -1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul757 multiply -1e-277 1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul758 multiply -1e-277 -1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+ddmul760 multiply 1e-291 1e-101 -> 1E-392 Subnormal
+ddmul761 multiply 1e-291 1e-102 -> 1E-393 Subnormal
+ddmul762 multiply 1e-291 1e-103 -> 1E-394 Subnormal
+ddmul763 multiply 1e-291 1e-104 -> 1E-395 Subnormal
+ddmul764 multiply 1e-291 1e-105 -> 1E-396 Subnormal
+ddmul765 multiply 1e-291 1e-106 -> 1E-397 Subnormal
+ddmul766 multiply 1e-291 1e-107 -> 1E-398 Subnormal
+ddmul767 multiply 1e-291 1e-108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul768 multiply 1e-291 1e-109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul769 multiply 1e-291 1e-110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+ddmul770 multiply 1e+60 1e+321 -> 1.000000000000E+381 Clamped
+ddmul771 multiply 1e+60 1e+322 -> 1.0000000000000E+382 Clamped
+ddmul772 multiply 1e+60 1e+323 -> 1.00000000000000E+383 Clamped
+ddmul773 multiply 1e+60 1e+324 -> 1.000000000000000E+384 Clamped
+ddmul774 multiply 1e+60 1e+325 -> Infinity Overflow Inexact Rounded
+ddmul775 multiply 1e+60 1e+326 -> Infinity Overflow Inexact Rounded
+ddmul776 multiply 1e+60 1e+327 -> Infinity Overflow Inexact Rounded
+ddmul777 multiply 1e+60 1e+328 -> Infinity Overflow Inexact Rounded
+ddmul778 multiply 1e+60 1e+329 -> Infinity Overflow Inexact Rounded
+ddmul779 multiply 1e+60 1e+330 -> Infinity Overflow Inexact Rounded
+
+ddmul801 multiply 1.0000E-394 1 -> 1.0000E-394 Subnormal
+ddmul802 multiply 1.000E-394 1e-1 -> 1.000E-395 Subnormal
+ddmul803 multiply 1.00E-394 1e-2 -> 1.00E-396 Subnormal
+ddmul804 multiply 1.0E-394 1e-3 -> 1.0E-397 Subnormal
+ddmul805 multiply 1.0E-394 1e-4 -> 1E-398 Subnormal Rounded
+ddmul806 multiply 1.3E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddmul807 multiply 1.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul808 multiply 1.7E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul809 multiply 2.3E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul810 multiply 2.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul811 multiply 2.7E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
+ddmul812 multiply 1.49E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddmul813 multiply 1.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul814 multiply 1.51E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul815 multiply 2.49E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul816 multiply 2.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul817 multiply 2.51E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
+
+ddmul818 multiply 1E-394 1e-4 -> 1E-398 Subnormal
+ddmul819 multiply 3E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul820 multiply 5E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul821 multiply 7E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddmul822 multiply 9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddmul823 multiply 9.9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
+
+ddmul824 multiply 1E-394 -1e-4 -> -1E-398 Subnormal
+ddmul825 multiply 3E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul826 multiply -5E-394 1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul827 multiply 7E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddmul828 multiply -9E-394 1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddmul829 multiply 9.9E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddmul830 multiply 3.0E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+ddmul831 multiply 1.0E-199 1e-200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul832 multiply 1.0E-199 1e-199 -> 1E-398 Subnormal Rounded
+ddmul833 multiply 1.0E-199 1e-198 -> 1.0E-397 Subnormal
+ddmul834 multiply 2.0E-199 2e-198 -> 4.0E-397 Subnormal
+ddmul835 multiply 4.0E-199 4e-198 -> 1.60E-396 Subnormal
+ddmul836 multiply 10.0E-199 10e-198 -> 1.000E-395 Subnormal
+ddmul837 multiply 30.0E-199 30e-198 -> 9.000E-395 Subnormal
+ddmul838 multiply 40.0E-199 40e-188 -> 1.6000E-384 Subnormal
+ddmul839 multiply 40.0E-199 40e-187 -> 1.6000E-383
+ddmul840 multiply 40.0E-199 40e-186 -> 1.6000E-382
+
+-- Long operand overflow may be a different path
+ddmul870 multiply 100 9.999E+383 -> Infinity Inexact Overflow Rounded
+ddmul871 multiply 100 -9.999E+383 -> -Infinity Inexact Overflow Rounded
+ddmul872 multiply 9.999E+383 100 -> Infinity Inexact Overflow Rounded
+ddmul873 multiply -9.999E+383 100 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+ddmul881 multiply 1.2347E-355 1.2347E-40 -> 1.524E-395 Inexact Rounded Subnormal Underflow
+ddmul882 multiply 1.234E-355 1.234E-40 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddmul883 multiply 1.23E-355 1.23E-40 -> 1.513E-395 Inexact Rounded Subnormal Underflow
+ddmul884 multiply 1.2E-355 1.2E-40 -> 1.44E-395 Subnormal
+ddmul885 multiply 1.2E-355 1.2E-41 -> 1.44E-396 Subnormal
+ddmul886 multiply 1.2E-355 1.2E-42 -> 1.4E-397 Subnormal Inexact Rounded Underflow
+ddmul887 multiply 1.2E-355 1.3E-42 -> 1.6E-397 Subnormal Inexact Rounded Underflow
+ddmul888 multiply 1.3E-355 1.3E-42 -> 1.7E-397 Subnormal Inexact Rounded Underflow
+ddmul889 multiply 1.3E-355 1.3E-43 -> 2E-398 Subnormal Inexact Rounded Underflow
+ddmul890 multiply 1.3E-356 1.3E-43 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
+
+ddmul891 multiply 1.2345E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
+ddmul892 multiply 1.23456E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
+ddmul893 multiply 1.2345E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddmul894 multiply 1.23456E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddmul895 multiply 1.2345E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
+ddmul896 multiply 1.23456E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+-- 1 234567890123456
+ddmul900 multiply 0.3000000000E-191 0.3000000000E-191 -> 9.00000000000000E-384 Subnormal Rounded
+ddmul901 multiply 0.3000000001E-191 0.3000000001E-191 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
+ddmul902 multiply 9.999999999999999E-383 0.0999999999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
+ddmul903 multiply 9.999999999999999E-383 0.09999999999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
+ddmul904 multiply 9.999999999999999E-383 0.099999999999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
+ddmul905 multiply 9.999999999999999E-383 0.0999999999999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
+-- The next rounds to Nmin (b**emin); this is the distinguishing case
+-- for detecting tininess (before or after rounding) -- if after
+-- rounding then the result would be the same, but the Underflow flag
+-- would not be set
+ddmul906 multiply 9.999999999999999E-383 0.09999999999999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+-- prove those operands were exact
+ddmul907 multiply 9.999999999999999E-383 1 -> 9.999999999999999E-383
+ddmul908 multiply 1 0.09999999999999999 -> 0.09999999999999999
+
+-- reducing tiniest
+ddmul910 multiply 1e-398 0.99 -> 1E-398 Subnormal Inexact Rounded Underflow
+ddmul911 multiply 1e-398 0.75 -> 1E-398 Subnormal Inexact Rounded Underflow
+ddmul912 multiply 1e-398 0.5 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+ddmul913 multiply 1e-398 0.25 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+ddmul914 multiply 1e-398 0.01 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+-- hugest
+ddmul920 multiply 9999999999999999 9999999999999999 -> 9.999999999999998E+31 Inexact Rounded
+
+-- power-of-ten edge cases
+ddmul1001 multiply 1 10 -> 10
+ddmul1002 multiply 1 100 -> 100
+ddmul1003 multiply 1 1000 -> 1000
+ddmul1004 multiply 1 10000 -> 10000
+ddmul1005 multiply 1 100000 -> 100000
+ddmul1006 multiply 1 1000000 -> 1000000
+ddmul1007 multiply 1 10000000 -> 10000000
+ddmul1008 multiply 1 100000000 -> 100000000
+ddmul1009 multiply 1 1000000000 -> 1000000000
+ddmul1010 multiply 1 10000000000 -> 10000000000
+ddmul1011 multiply 1 100000000000 -> 100000000000
+ddmul1012 multiply 1 1000000000000 -> 1000000000000
+ddmul1013 multiply 1 10000000000000 -> 10000000000000
+ddmul1014 multiply 1 100000000000000 -> 100000000000000
+ddmul1015 multiply 1 1000000000000000 -> 1000000000000000
+ddmul1021 multiply 10 1 -> 10
+ddmul1022 multiply 10 10 -> 100
+ddmul1023 multiply 10 100 -> 1000
+ddmul1024 multiply 10 1000 -> 10000
+ddmul1025 multiply 10 10000 -> 100000
+ddmul1026 multiply 10 100000 -> 1000000
+ddmul1027 multiply 10 1000000 -> 10000000
+ddmul1028 multiply 10 10000000 -> 100000000
+ddmul1029 multiply 10 100000000 -> 1000000000
+ddmul1030 multiply 10 1000000000 -> 10000000000
+ddmul1031 multiply 10 10000000000 -> 100000000000
+ddmul1032 multiply 10 100000000000 -> 1000000000000
+ddmul1033 multiply 10 1000000000000 -> 10000000000000
+ddmul1034 multiply 10 10000000000000 -> 100000000000000
+ddmul1035 multiply 10 100000000000000 -> 1000000000000000
+ddmul1041 multiply 100 0.1 -> 10.0
+ddmul1042 multiply 100 1 -> 100
+ddmul1043 multiply 100 10 -> 1000
+ddmul1044 multiply 100 100 -> 10000
+ddmul1045 multiply 100 1000 -> 100000
+ddmul1046 multiply 100 10000 -> 1000000
+ddmul1047 multiply 100 100000 -> 10000000
+ddmul1048 multiply 100 1000000 -> 100000000
+ddmul1049 multiply 100 10000000 -> 1000000000
+ddmul1050 multiply 100 100000000 -> 10000000000
+ddmul1051 multiply 100 1000000000 -> 100000000000
+ddmul1052 multiply 100 10000000000 -> 1000000000000
+ddmul1053 multiply 100 100000000000 -> 10000000000000
+ddmul1054 multiply 100 1000000000000 -> 100000000000000
+ddmul1055 multiply 100 10000000000000 -> 1000000000000000
+ddmul1061 multiply 1000 0.01 -> 10.00
+ddmul1062 multiply 1000 0.1 -> 100.0
+ddmul1063 multiply 1000 1 -> 1000
+ddmul1064 multiply 1000 10 -> 10000
+ddmul1065 multiply 1000 100 -> 100000
+ddmul1066 multiply 1000 1000 -> 1000000
+ddmul1067 multiply 1000 10000 -> 10000000
+ddmul1068 multiply 1000 100000 -> 100000000
+ddmul1069 multiply 1000 1000000 -> 1000000000
+ddmul1070 multiply 1000 10000000 -> 10000000000
+ddmul1071 multiply 1000 100000000 -> 100000000000
+ddmul1072 multiply 1000 1000000000 -> 1000000000000
+ddmul1073 multiply 1000 10000000000 -> 10000000000000
+ddmul1074 multiply 1000 100000000000 -> 100000000000000
+ddmul1075 multiply 1000 1000000000000 -> 1000000000000000
+ddmul1081 multiply 10000 0.001 -> 10.000
+ddmul1082 multiply 10000 0.01 -> 100.00
+ddmul1083 multiply 10000 0.1 -> 1000.0
+ddmul1084 multiply 10000 1 -> 10000
+ddmul1085 multiply 10000 10 -> 100000
+ddmul1086 multiply 10000 100 -> 1000000
+ddmul1087 multiply 10000 1000 -> 10000000
+ddmul1088 multiply 10000 10000 -> 100000000
+ddmul1089 multiply 10000 100000 -> 1000000000
+ddmul1090 multiply 10000 1000000 -> 10000000000
+ddmul1091 multiply 10000 10000000 -> 100000000000
+ddmul1092 multiply 10000 100000000 -> 1000000000000
+ddmul1093 multiply 10000 1000000000 -> 10000000000000
+ddmul1094 multiply 10000 10000000000 -> 100000000000000
+ddmul1095 multiply 10000 100000000000 -> 1000000000000000
+
+ddmul1097 multiply 10000 99999999999 -> 999999999990000
+ddmul1098 multiply 10000 99999999999 -> 999999999990000
+
+
+-- Null tests
+ddmul9990 multiply 10 # -> NaN Invalid_operation
+ddmul9991 multiply # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddNextMinus.decTest b/Lib/test/decimaltestdata/ddNextMinus.decTest
index 39f58c14a4..f8a3c0eb32 100644
--- a/Lib/test/decimaltestdata/ddNextMinus.decTest
+++ b/Lib/test/decimaltestdata/ddNextMinus.decTest
@@ -1,126 +1,126 @@
-------------------------------------------------------------------------
--- ddNextMinus.decTest -- decDouble next that is less [754r nextdown] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddnextm001 nextminus 0.9999999999999995 -> 0.9999999999999994
-ddnextm002 nextminus 0.9999999999999996 -> 0.9999999999999995
-ddnextm003 nextminus 0.9999999999999997 -> 0.9999999999999996
-ddnextm004 nextminus 0.9999999999999998 -> 0.9999999999999997
-ddnextm005 nextminus 0.9999999999999999 -> 0.9999999999999998
-ddnextm006 nextminus 1.000000000000000 -> 0.9999999999999999
-ddnextm007 nextminus 1.0 -> 0.9999999999999999
-ddnextm008 nextminus 1 -> 0.9999999999999999
-ddnextm009 nextminus 1.000000000000001 -> 1.000000000000000
-ddnextm010 nextminus 1.000000000000002 -> 1.000000000000001
-ddnextm011 nextminus 1.000000000000003 -> 1.000000000000002
-ddnextm012 nextminus 1.000000000000004 -> 1.000000000000003
-ddnextm013 nextminus 1.000000000000005 -> 1.000000000000004
-ddnextm014 nextminus 1.000000000000006 -> 1.000000000000005
-ddnextm015 nextminus 1.000000000000007 -> 1.000000000000006
-ddnextm016 nextminus 1.000000000000008 -> 1.000000000000007
-ddnextm017 nextminus 1.000000000000009 -> 1.000000000000008
-ddnextm018 nextminus 1.000000000000010 -> 1.000000000000009
-ddnextm019 nextminus 1.000000000000011 -> 1.000000000000010
-ddnextm020 nextminus 1.000000000000012 -> 1.000000000000011
-
-ddnextm021 nextminus -0.9999999999999995 -> -0.9999999999999996
-ddnextm022 nextminus -0.9999999999999996 -> -0.9999999999999997
-ddnextm023 nextminus -0.9999999999999997 -> -0.9999999999999998
-ddnextm024 nextminus -0.9999999999999998 -> -0.9999999999999999
-ddnextm025 nextminus -0.9999999999999999 -> -1.000000000000000
-ddnextm026 nextminus -1.000000000000000 -> -1.000000000000001
-ddnextm027 nextminus -1.0 -> -1.000000000000001
-ddnextm028 nextminus -1 -> -1.000000000000001
-ddnextm029 nextminus -1.000000000000001 -> -1.000000000000002
-ddnextm030 nextminus -1.000000000000002 -> -1.000000000000003
-ddnextm031 nextminus -1.000000000000003 -> -1.000000000000004
-ddnextm032 nextminus -1.000000000000004 -> -1.000000000000005
-ddnextm033 nextminus -1.000000000000005 -> -1.000000000000006
-ddnextm034 nextminus -1.000000000000006 -> -1.000000000000007
-ddnextm035 nextminus -1.000000000000007 -> -1.000000000000008
-ddnextm036 nextminus -1.000000000000008 -> -1.000000000000009
-ddnextm037 nextminus -1.000000000000009 -> -1.000000000000010
-ddnextm038 nextminus -1.000000000000010 -> -1.000000000000011
-ddnextm039 nextminus -1.000000000000011 -> -1.000000000000012
-
--- ultra-tiny inputs
-ddnextm062 nextminus 1E-398 -> 0E-398
-ddnextm065 nextminus -1E-398 -> -2E-398
-
--- Zeros
-ddnextm100 nextminus -0 -> -1E-398
-ddnextm101 nextminus 0 -> -1E-398
-ddnextm102 nextminus 0.00 -> -1E-398
-ddnextm103 nextminus -0.00 -> -1E-398
-ddnextm104 nextminus 0E-300 -> -1E-398
-ddnextm105 nextminus 0E+300 -> -1E-398
-ddnextm106 nextminus 0E+30000 -> -1E-398
-ddnextm107 nextminus -0E+30000 -> -1E-398
-
--- specials
-ddnextm150 nextminus Inf -> 9.999999999999999E+384
-ddnextm151 nextminus -Inf -> -Infinity
-ddnextm152 nextminus NaN -> NaN
-ddnextm153 nextminus sNaN -> NaN Invalid_operation
-ddnextm154 nextminus NaN77 -> NaN77
-ddnextm155 nextminus sNaN88 -> NaN88 Invalid_operation
-ddnextm156 nextminus -NaN -> -NaN
-ddnextm157 nextminus -sNaN -> -NaN Invalid_operation
-ddnextm158 nextminus -NaN77 -> -NaN77
-ddnextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-ddnextm170 nextminus 9.999999999999999E+384 -> 9.999999999999998E+384
-ddnextm171 nextminus 9.999999999999998E+384 -> 9.999999999999997E+384
-ddnextm172 nextminus 1E-383 -> 9.99999999999999E-384
-ddnextm173 nextminus 1.000000000000000E-383 -> 9.99999999999999E-384
-ddnextm174 nextminus 9E-398 -> 8E-398
-ddnextm175 nextminus 9.9E-397 -> 9.8E-397
-ddnextm176 nextminus 9.99999999999E-387 -> 9.99999999998E-387
-ddnextm177 nextminus 9.99999999999999E-384 -> 9.99999999999998E-384
-ddnextm178 nextminus 9.99999999999998E-384 -> 9.99999999999997E-384
-ddnextm179 nextminus 9.99999999999997E-384 -> 9.99999999999996E-384
-ddnextm180 nextminus 0E-398 -> -1E-398
-ddnextm181 nextminus 1E-398 -> 0E-398
-ddnextm182 nextminus 2E-398 -> 1E-398
-
-ddnextm183 nextminus -0E-398 -> -1E-398
-ddnextm184 nextminus -1E-398 -> -2E-398
-ddnextm185 nextminus -2E-398 -> -3E-398
-ddnextm186 nextminus -10E-398 -> -1.1E-397
-ddnextm187 nextminus -100E-398 -> -1.01E-396
-ddnextm188 nextminus -100000E-398 -> -1.00001E-393
-ddnextm189 nextminus -1.00000000000E-383 -> -1.000000000000001E-383
-ddnextm190 nextminus -1.000000000000000E-383 -> -1.000000000000001E-383
-ddnextm191 nextminus -1E-383 -> -1.000000000000001E-383
-ddnextm192 nextminus -9.999999999999998E+384 -> -9.999999999999999E+384
-ddnextm193 nextminus -9.999999999999999E+384 -> -Infinity
-
--- Null tests
-ddnextm900 nextminus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddNextMinus.decTest -- decDouble next that is less [754r nextdown] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddnextm001 nextminus 0.9999999999999995 -> 0.9999999999999994
+ddnextm002 nextminus 0.9999999999999996 -> 0.9999999999999995
+ddnextm003 nextminus 0.9999999999999997 -> 0.9999999999999996
+ddnextm004 nextminus 0.9999999999999998 -> 0.9999999999999997
+ddnextm005 nextminus 0.9999999999999999 -> 0.9999999999999998
+ddnextm006 nextminus 1.000000000000000 -> 0.9999999999999999
+ddnextm007 nextminus 1.0 -> 0.9999999999999999
+ddnextm008 nextminus 1 -> 0.9999999999999999
+ddnextm009 nextminus 1.000000000000001 -> 1.000000000000000
+ddnextm010 nextminus 1.000000000000002 -> 1.000000000000001
+ddnextm011 nextminus 1.000000000000003 -> 1.000000000000002
+ddnextm012 nextminus 1.000000000000004 -> 1.000000000000003
+ddnextm013 nextminus 1.000000000000005 -> 1.000000000000004
+ddnextm014 nextminus 1.000000000000006 -> 1.000000000000005
+ddnextm015 nextminus 1.000000000000007 -> 1.000000000000006
+ddnextm016 nextminus 1.000000000000008 -> 1.000000000000007
+ddnextm017 nextminus 1.000000000000009 -> 1.000000000000008
+ddnextm018 nextminus 1.000000000000010 -> 1.000000000000009
+ddnextm019 nextminus 1.000000000000011 -> 1.000000000000010
+ddnextm020 nextminus 1.000000000000012 -> 1.000000000000011
+
+ddnextm021 nextminus -0.9999999999999995 -> -0.9999999999999996
+ddnextm022 nextminus -0.9999999999999996 -> -0.9999999999999997
+ddnextm023 nextminus -0.9999999999999997 -> -0.9999999999999998
+ddnextm024 nextminus -0.9999999999999998 -> -0.9999999999999999
+ddnextm025 nextminus -0.9999999999999999 -> -1.000000000000000
+ddnextm026 nextminus -1.000000000000000 -> -1.000000000000001
+ddnextm027 nextminus -1.0 -> -1.000000000000001
+ddnextm028 nextminus -1 -> -1.000000000000001
+ddnextm029 nextminus -1.000000000000001 -> -1.000000000000002
+ddnextm030 nextminus -1.000000000000002 -> -1.000000000000003
+ddnextm031 nextminus -1.000000000000003 -> -1.000000000000004
+ddnextm032 nextminus -1.000000000000004 -> -1.000000000000005
+ddnextm033 nextminus -1.000000000000005 -> -1.000000000000006
+ddnextm034 nextminus -1.000000000000006 -> -1.000000000000007
+ddnextm035 nextminus -1.000000000000007 -> -1.000000000000008
+ddnextm036 nextminus -1.000000000000008 -> -1.000000000000009
+ddnextm037 nextminus -1.000000000000009 -> -1.000000000000010
+ddnextm038 nextminus -1.000000000000010 -> -1.000000000000011
+ddnextm039 nextminus -1.000000000000011 -> -1.000000000000012
+
+-- ultra-tiny inputs
+ddnextm062 nextminus 1E-398 -> 0E-398
+ddnextm065 nextminus -1E-398 -> -2E-398
+
+-- Zeros
+ddnextm100 nextminus -0 -> -1E-398
+ddnextm101 nextminus 0 -> -1E-398
+ddnextm102 nextminus 0.00 -> -1E-398
+ddnextm103 nextminus -0.00 -> -1E-398
+ddnextm104 nextminus 0E-300 -> -1E-398
+ddnextm105 nextminus 0E+300 -> -1E-398
+ddnextm106 nextminus 0E+30000 -> -1E-398
+ddnextm107 nextminus -0E+30000 -> -1E-398
+
+-- specials
+ddnextm150 nextminus Inf -> 9.999999999999999E+384
+ddnextm151 nextminus -Inf -> -Infinity
+ddnextm152 nextminus NaN -> NaN
+ddnextm153 nextminus sNaN -> NaN Invalid_operation
+ddnextm154 nextminus NaN77 -> NaN77
+ddnextm155 nextminus sNaN88 -> NaN88 Invalid_operation
+ddnextm156 nextminus -NaN -> -NaN
+ddnextm157 nextminus -sNaN -> -NaN Invalid_operation
+ddnextm158 nextminus -NaN77 -> -NaN77
+ddnextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+ddnextm170 nextminus 9.999999999999999E+384 -> 9.999999999999998E+384
+ddnextm171 nextminus 9.999999999999998E+384 -> 9.999999999999997E+384
+ddnextm172 nextminus 1E-383 -> 9.99999999999999E-384
+ddnextm173 nextminus 1.000000000000000E-383 -> 9.99999999999999E-384
+ddnextm174 nextminus 9E-398 -> 8E-398
+ddnextm175 nextminus 9.9E-397 -> 9.8E-397
+ddnextm176 nextminus 9.99999999999E-387 -> 9.99999999998E-387
+ddnextm177 nextminus 9.99999999999999E-384 -> 9.99999999999998E-384
+ddnextm178 nextminus 9.99999999999998E-384 -> 9.99999999999997E-384
+ddnextm179 nextminus 9.99999999999997E-384 -> 9.99999999999996E-384
+ddnextm180 nextminus 0E-398 -> -1E-398
+ddnextm181 nextminus 1E-398 -> 0E-398
+ddnextm182 nextminus 2E-398 -> 1E-398
+
+ddnextm183 nextminus -0E-398 -> -1E-398
+ddnextm184 nextminus -1E-398 -> -2E-398
+ddnextm185 nextminus -2E-398 -> -3E-398
+ddnextm186 nextminus -10E-398 -> -1.1E-397
+ddnextm187 nextminus -100E-398 -> -1.01E-396
+ddnextm188 nextminus -100000E-398 -> -1.00001E-393
+ddnextm189 nextminus -1.00000000000E-383 -> -1.000000000000001E-383
+ddnextm190 nextminus -1.000000000000000E-383 -> -1.000000000000001E-383
+ddnextm191 nextminus -1E-383 -> -1.000000000000001E-383
+ddnextm192 nextminus -9.999999999999998E+384 -> -9.999999999999999E+384
+ddnextm193 nextminus -9.999999999999999E+384 -> -Infinity
+
+-- Null tests
+ddnextm900 nextminus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddNextPlus.decTest b/Lib/test/decimaltestdata/ddNextPlus.decTest
index d41dfbab3f..4a749a18c9 100644
--- a/Lib/test/decimaltestdata/ddNextPlus.decTest
+++ b/Lib/test/decimaltestdata/ddNextPlus.decTest
@@ -1,124 +1,124 @@
-------------------------------------------------------------------------
--- ddNextPlus.decTest -- decDouble next that is greater [754r nextup] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddnextp001 nextplus 0.9999999999999995 -> 0.9999999999999996
-ddnextp002 nextplus 0.9999999999999996 -> 0.9999999999999997
-ddnextp003 nextplus 0.9999999999999997 -> 0.9999999999999998
-ddnextp004 nextplus 0.9999999999999998 -> 0.9999999999999999
-ddnextp005 nextplus 0.9999999999999999 -> 1.000000000000000
-ddnextp006 nextplus 1.000000000000000 -> 1.000000000000001
-ddnextp007 nextplus 1.0 -> 1.000000000000001
-ddnextp008 nextplus 1 -> 1.000000000000001
-ddnextp009 nextplus 1.000000000000001 -> 1.000000000000002
-ddnextp010 nextplus 1.000000000000002 -> 1.000000000000003
-ddnextp011 nextplus 1.000000000000003 -> 1.000000000000004
-ddnextp012 nextplus 1.000000000000004 -> 1.000000000000005
-ddnextp013 nextplus 1.000000000000005 -> 1.000000000000006
-ddnextp014 nextplus 1.000000000000006 -> 1.000000000000007
-ddnextp015 nextplus 1.000000000000007 -> 1.000000000000008
-ddnextp016 nextplus 1.000000000000008 -> 1.000000000000009
-ddnextp017 nextplus 1.000000000000009 -> 1.000000000000010
-ddnextp018 nextplus 1.000000000000010 -> 1.000000000000011
-ddnextp019 nextplus 1.000000000000011 -> 1.000000000000012
-
-ddnextp021 nextplus -0.9999999999999995 -> -0.9999999999999994
-ddnextp022 nextplus -0.9999999999999996 -> -0.9999999999999995
-ddnextp023 nextplus -0.9999999999999997 -> -0.9999999999999996
-ddnextp024 nextplus -0.9999999999999998 -> -0.9999999999999997
-ddnextp025 nextplus -0.9999999999999999 -> -0.9999999999999998
-ddnextp026 nextplus -1.000000000000000 -> -0.9999999999999999
-ddnextp027 nextplus -1.0 -> -0.9999999999999999
-ddnextp028 nextplus -1 -> -0.9999999999999999
-ddnextp029 nextplus -1.000000000000001 -> -1.000000000000000
-ddnextp030 nextplus -1.000000000000002 -> -1.000000000000001
-ddnextp031 nextplus -1.000000000000003 -> -1.000000000000002
-ddnextp032 nextplus -1.000000000000004 -> -1.000000000000003
-ddnextp033 nextplus -1.000000000000005 -> -1.000000000000004
-ddnextp034 nextplus -1.000000000000006 -> -1.000000000000005
-ddnextp035 nextplus -1.000000000000007 -> -1.000000000000006
-ddnextp036 nextplus -1.000000000000008 -> -1.000000000000007
-ddnextp037 nextplus -1.000000000000009 -> -1.000000000000008
-ddnextp038 nextplus -1.000000000000010 -> -1.000000000000009
-ddnextp039 nextplus -1.000000000000011 -> -1.000000000000010
-ddnextp040 nextplus -1.000000000000012 -> -1.000000000000011
-
--- Zeros
-ddnextp100 nextplus 0 -> 1E-398
-ddnextp101 nextplus 0.00 -> 1E-398
-ddnextp102 nextplus 0E-300 -> 1E-398
-ddnextp103 nextplus 0E+300 -> 1E-398
-ddnextp104 nextplus 0E+30000 -> 1E-398
-ddnextp105 nextplus -0 -> 1E-398
-ddnextp106 nextplus -0.00 -> 1E-398
-ddnextp107 nextplus -0E-300 -> 1E-398
-ddnextp108 nextplus -0E+300 -> 1E-398
-ddnextp109 nextplus -0E+30000 -> 1E-398
-
--- specials
-ddnextp150 nextplus Inf -> Infinity
-ddnextp151 nextplus -Inf -> -9.999999999999999E+384
-ddnextp152 nextplus NaN -> NaN
-ddnextp153 nextplus sNaN -> NaN Invalid_operation
-ddnextp154 nextplus NaN77 -> NaN77
-ddnextp155 nextplus sNaN88 -> NaN88 Invalid_operation
-ddnextp156 nextplus -NaN -> -NaN
-ddnextp157 nextplus -sNaN -> -NaN Invalid_operation
-ddnextp158 nextplus -NaN77 -> -NaN77
-ddnextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-ddnextp170 nextplus -9.999999999999999E+384 -> -9.999999999999998E+384
-ddnextp171 nextplus -9.999999999999998E+384 -> -9.999999999999997E+384
-ddnextp172 nextplus -1E-383 -> -9.99999999999999E-384
-ddnextp173 nextplus -1.000000000000000E-383 -> -9.99999999999999E-384
-ddnextp174 nextplus -9E-398 -> -8E-398
-ddnextp175 nextplus -9.9E-397 -> -9.8E-397
-ddnextp176 nextplus -9.99999999999E-387 -> -9.99999999998E-387
-ddnextp177 nextplus -9.99999999999999E-384 -> -9.99999999999998E-384
-ddnextp178 nextplus -9.99999999999998E-384 -> -9.99999999999997E-384
-ddnextp179 nextplus -9.99999999999997E-384 -> -9.99999999999996E-384
-ddnextp180 nextplus -0E-398 -> 1E-398
-ddnextp181 nextplus -1E-398 -> -0E-398
-ddnextp182 nextplus -2E-398 -> -1E-398
-
-ddnextp183 nextplus 0E-398 -> 1E-398
-ddnextp184 nextplus 1E-398 -> 2E-398
-ddnextp185 nextplus 2E-398 -> 3E-398
-ddnextp186 nextplus 10E-398 -> 1.1E-397
-ddnextp187 nextplus 100E-398 -> 1.01E-396
-ddnextp188 nextplus 100000E-398 -> 1.00001E-393
-ddnextp189 nextplus 1.00000000000E-383 -> 1.000000000000001E-383
-ddnextp190 nextplus 1.000000000000000E-383 -> 1.000000000000001E-383
-ddnextp191 nextplus 1E-383 -> 1.000000000000001E-383
-ddnextp192 nextplus 9.999999999999998E+384 -> 9.999999999999999E+384
-ddnextp193 nextplus 9.999999999999999E+384 -> Infinity
-
--- Null tests
-ddnextp900 nextplus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddNextPlus.decTest -- decDouble next that is greater [754r nextup] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddnextp001 nextplus 0.9999999999999995 -> 0.9999999999999996
+ddnextp002 nextplus 0.9999999999999996 -> 0.9999999999999997
+ddnextp003 nextplus 0.9999999999999997 -> 0.9999999999999998
+ddnextp004 nextplus 0.9999999999999998 -> 0.9999999999999999
+ddnextp005 nextplus 0.9999999999999999 -> 1.000000000000000
+ddnextp006 nextplus 1.000000000000000 -> 1.000000000000001
+ddnextp007 nextplus 1.0 -> 1.000000000000001
+ddnextp008 nextplus 1 -> 1.000000000000001
+ddnextp009 nextplus 1.000000000000001 -> 1.000000000000002
+ddnextp010 nextplus 1.000000000000002 -> 1.000000000000003
+ddnextp011 nextplus 1.000000000000003 -> 1.000000000000004
+ddnextp012 nextplus 1.000000000000004 -> 1.000000000000005
+ddnextp013 nextplus 1.000000000000005 -> 1.000000000000006
+ddnextp014 nextplus 1.000000000000006 -> 1.000000000000007
+ddnextp015 nextplus 1.000000000000007 -> 1.000000000000008
+ddnextp016 nextplus 1.000000000000008 -> 1.000000000000009
+ddnextp017 nextplus 1.000000000000009 -> 1.000000000000010
+ddnextp018 nextplus 1.000000000000010 -> 1.000000000000011
+ddnextp019 nextplus 1.000000000000011 -> 1.000000000000012
+
+ddnextp021 nextplus -0.9999999999999995 -> -0.9999999999999994
+ddnextp022 nextplus -0.9999999999999996 -> -0.9999999999999995
+ddnextp023 nextplus -0.9999999999999997 -> -0.9999999999999996
+ddnextp024 nextplus -0.9999999999999998 -> -0.9999999999999997
+ddnextp025 nextplus -0.9999999999999999 -> -0.9999999999999998
+ddnextp026 nextplus -1.000000000000000 -> -0.9999999999999999
+ddnextp027 nextplus -1.0 -> -0.9999999999999999
+ddnextp028 nextplus -1 -> -0.9999999999999999
+ddnextp029 nextplus -1.000000000000001 -> -1.000000000000000
+ddnextp030 nextplus -1.000000000000002 -> -1.000000000000001
+ddnextp031 nextplus -1.000000000000003 -> -1.000000000000002
+ddnextp032 nextplus -1.000000000000004 -> -1.000000000000003
+ddnextp033 nextplus -1.000000000000005 -> -1.000000000000004
+ddnextp034 nextplus -1.000000000000006 -> -1.000000000000005
+ddnextp035 nextplus -1.000000000000007 -> -1.000000000000006
+ddnextp036 nextplus -1.000000000000008 -> -1.000000000000007
+ddnextp037 nextplus -1.000000000000009 -> -1.000000000000008
+ddnextp038 nextplus -1.000000000000010 -> -1.000000000000009
+ddnextp039 nextplus -1.000000000000011 -> -1.000000000000010
+ddnextp040 nextplus -1.000000000000012 -> -1.000000000000011
+
+-- Zeros
+ddnextp100 nextplus 0 -> 1E-398
+ddnextp101 nextplus 0.00 -> 1E-398
+ddnextp102 nextplus 0E-300 -> 1E-398
+ddnextp103 nextplus 0E+300 -> 1E-398
+ddnextp104 nextplus 0E+30000 -> 1E-398
+ddnextp105 nextplus -0 -> 1E-398
+ddnextp106 nextplus -0.00 -> 1E-398
+ddnextp107 nextplus -0E-300 -> 1E-398
+ddnextp108 nextplus -0E+300 -> 1E-398
+ddnextp109 nextplus -0E+30000 -> 1E-398
+
+-- specials
+ddnextp150 nextplus Inf -> Infinity
+ddnextp151 nextplus -Inf -> -9.999999999999999E+384
+ddnextp152 nextplus NaN -> NaN
+ddnextp153 nextplus sNaN -> NaN Invalid_operation
+ddnextp154 nextplus NaN77 -> NaN77
+ddnextp155 nextplus sNaN88 -> NaN88 Invalid_operation
+ddnextp156 nextplus -NaN -> -NaN
+ddnextp157 nextplus -sNaN -> -NaN Invalid_operation
+ddnextp158 nextplus -NaN77 -> -NaN77
+ddnextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+ddnextp170 nextplus -9.999999999999999E+384 -> -9.999999999999998E+384
+ddnextp171 nextplus -9.999999999999998E+384 -> -9.999999999999997E+384
+ddnextp172 nextplus -1E-383 -> -9.99999999999999E-384
+ddnextp173 nextplus -1.000000000000000E-383 -> -9.99999999999999E-384
+ddnextp174 nextplus -9E-398 -> -8E-398
+ddnextp175 nextplus -9.9E-397 -> -9.8E-397
+ddnextp176 nextplus -9.99999999999E-387 -> -9.99999999998E-387
+ddnextp177 nextplus -9.99999999999999E-384 -> -9.99999999999998E-384
+ddnextp178 nextplus -9.99999999999998E-384 -> -9.99999999999997E-384
+ddnextp179 nextplus -9.99999999999997E-384 -> -9.99999999999996E-384
+ddnextp180 nextplus -0E-398 -> 1E-398
+ddnextp181 nextplus -1E-398 -> -0E-398
+ddnextp182 nextplus -2E-398 -> -1E-398
+
+ddnextp183 nextplus 0E-398 -> 1E-398
+ddnextp184 nextplus 1E-398 -> 2E-398
+ddnextp185 nextplus 2E-398 -> 3E-398
+ddnextp186 nextplus 10E-398 -> 1.1E-397
+ddnextp187 nextplus 100E-398 -> 1.01E-396
+ddnextp188 nextplus 100000E-398 -> 1.00001E-393
+ddnextp189 nextplus 1.00000000000E-383 -> 1.000000000000001E-383
+ddnextp190 nextplus 1.000000000000000E-383 -> 1.000000000000001E-383
+ddnextp191 nextplus 1E-383 -> 1.000000000000001E-383
+ddnextp192 nextplus 9.999999999999998E+384 -> 9.999999999999999E+384
+ddnextp193 nextplus 9.999999999999999E+384 -> Infinity
+
+-- Null tests
+ddnextp900 nextplus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddNextToward.decTest b/Lib/test/decimaltestdata/ddNextToward.decTest
index f9e474d70f..75386add31 100644
--- a/Lib/test/decimaltestdata/ddNextToward.decTest
+++ b/Lib/test/decimaltestdata/ddNextToward.decTest
@@ -1,374 +1,374 @@
-------------------------------------------------------------------------
--- ddNextToward.decTest -- decDouble next toward rhs [754r nextafter] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check with a scattering of numerics
-ddnextt001 nexttoward 10 10 -> 10
-ddnextt002 nexttoward -10 -10 -> -10
-ddnextt003 nexttoward 1 10 -> 1.000000000000001
-ddnextt004 nexttoward 1 -10 -> 0.9999999999999999
-ddnextt005 nexttoward -1 10 -> -0.9999999999999999
-ddnextt006 nexttoward -1 -10 -> -1.000000000000001
-ddnextt007 nexttoward 0 10 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt008 nexttoward 0 -10 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt009 nexttoward 9.999999999999999E+384 +Infinity -> Infinity Overflow Inexact Rounded
-ddnextt010 nexttoward -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
-ddnextt011 nexttoward 9.999999999999999 10 -> 10.00000000000000
-ddnextt012 nexttoward 10 9.999999999999999 -> 9.999999999999999
-ddnextt013 nexttoward -9.999999999999999 -10 -> -10.00000000000000
-ddnextt014 nexttoward -10 -9.999999999999999 -> -9.999999999999999
-ddnextt015 nexttoward 9.999999999999998 10 -> 9.999999999999999
-ddnextt016 nexttoward 10 9.999999999999998 -> 9.999999999999999
-ddnextt017 nexttoward -9.999999999999998 -10 -> -9.999999999999999
-ddnextt018 nexttoward -10 -9.999999999999998 -> -9.999999999999999
-
-------- lhs=rhs
--- finites
-ddnextt101 nexttoward 7 7 -> 7
-ddnextt102 nexttoward -7 -7 -> -7
-ddnextt103 nexttoward 75 75 -> 75
-ddnextt104 nexttoward -75 -75 -> -75
-ddnextt105 nexttoward 7.50 7.5 -> 7.50
-ddnextt106 nexttoward -7.50 -7.50 -> -7.50
-ddnextt107 nexttoward 7.500 7.5000 -> 7.500
-ddnextt108 nexttoward -7.500 -7.5 -> -7.500
-
--- zeros
-ddnextt111 nexttoward 0 0 -> 0
-ddnextt112 nexttoward -0 -0 -> -0
-ddnextt113 nexttoward 0E+4 0 -> 0E+4
-ddnextt114 nexttoward -0E+4 -0 -> -0E+4
-ddnextt115 nexttoward 0.00000000000 0.000000000000 -> 0E-11
-ddnextt116 nexttoward -0.00000000000 -0.00 -> -0E-11
-ddnextt117 nexttoward 0E-141 0 -> 0E-141
-ddnextt118 nexttoward -0E-141 -000 -> -0E-141
-
--- full coefficients, alternating bits
-ddnextt121 nexttoward 268268268 268268268 -> 268268268
-ddnextt122 nexttoward -268268268 -268268268 -> -268268268
-ddnextt123 nexttoward 134134134 134134134 -> 134134134
-ddnextt124 nexttoward -134134134 -134134134 -> -134134134
-
--- Nmax, Nmin, Ntiny
-ddnextt131 nexttoward 9.999999999999999E+384 9.999999999999999E+384 -> 9.999999999999999E+384
-ddnextt132 nexttoward 1E-383 1E-383 -> 1E-383
-ddnextt133 nexttoward 1.000000000000000E-383 1.000000000000000E-383 -> 1.000000000000000E-383
-ddnextt134 nexttoward 1E-398 1E-398 -> 1E-398
-
-ddnextt135 nexttoward -1E-398 -1E-398 -> -1E-398
-ddnextt136 nexttoward -1.000000000000000E-383 -1.000000000000000E-383 -> -1.000000000000000E-383
-ddnextt137 nexttoward -1E-383 -1E-383 -> -1E-383
-ddnextt138 nexttoward -9.999999999999999E+384 -9.999999999999999E+384 -> -9.999999999999999E+384
-
-------- lhs<rhs
-ddnextt201 nexttoward 0.9999999999999995 Infinity -> 0.9999999999999996
-ddnextt202 nexttoward 0.9999999999999996 Infinity -> 0.9999999999999997
-ddnextt203 nexttoward 0.9999999999999997 Infinity -> 0.9999999999999998
-ddnextt204 nexttoward 0.9999999999999998 Infinity -> 0.9999999999999999
-ddnextt205 nexttoward 0.9999999999999999 Infinity -> 1.000000000000000
-ddnextt206 nexttoward 1.000000000000000 Infinity -> 1.000000000000001
-ddnextt207 nexttoward 1.0 Infinity -> 1.000000000000001
-ddnextt208 nexttoward 1 Infinity -> 1.000000000000001
-ddnextt209 nexttoward 1.000000000000001 Infinity -> 1.000000000000002
-ddnextt210 nexttoward 1.000000000000002 Infinity -> 1.000000000000003
-ddnextt211 nexttoward 1.000000000000003 Infinity -> 1.000000000000004
-ddnextt212 nexttoward 1.000000000000004 Infinity -> 1.000000000000005
-ddnextt213 nexttoward 1.000000000000005 Infinity -> 1.000000000000006
-ddnextt214 nexttoward 1.000000000000006 Infinity -> 1.000000000000007
-ddnextt215 nexttoward 1.000000000000007 Infinity -> 1.000000000000008
-ddnextt216 nexttoward 1.000000000000008 Infinity -> 1.000000000000009
-ddnextt217 nexttoward 1.000000000000009 Infinity -> 1.000000000000010
-ddnextt218 nexttoward 1.000000000000010 Infinity -> 1.000000000000011
-ddnextt219 nexttoward 1.000000000000011 Infinity -> 1.000000000000012
-
-ddnextt221 nexttoward -0.9999999999999995 Infinity -> -0.9999999999999994
-ddnextt222 nexttoward -0.9999999999999996 Infinity -> -0.9999999999999995
-ddnextt223 nexttoward -0.9999999999999997 Infinity -> -0.9999999999999996
-ddnextt224 nexttoward -0.9999999999999998 Infinity -> -0.9999999999999997
-ddnextt225 nexttoward -0.9999999999999999 Infinity -> -0.9999999999999998
-ddnextt226 nexttoward -1.000000000000000 Infinity -> -0.9999999999999999
-ddnextt227 nexttoward -1.0 Infinity -> -0.9999999999999999
-ddnextt228 nexttoward -1 Infinity -> -0.9999999999999999
-ddnextt229 nexttoward -1.000000000000001 Infinity -> -1.000000000000000
-ddnextt230 nexttoward -1.000000000000002 Infinity -> -1.000000000000001
-ddnextt231 nexttoward -1.000000000000003 Infinity -> -1.000000000000002
-ddnextt232 nexttoward -1.000000000000004 Infinity -> -1.000000000000003
-ddnextt233 nexttoward -1.000000000000005 Infinity -> -1.000000000000004
-ddnextt234 nexttoward -1.000000000000006 Infinity -> -1.000000000000005
-ddnextt235 nexttoward -1.000000000000007 Infinity -> -1.000000000000006
-ddnextt236 nexttoward -1.000000000000008 Infinity -> -1.000000000000007
-ddnextt237 nexttoward -1.000000000000009 Infinity -> -1.000000000000008
-ddnextt238 nexttoward -1.000000000000010 Infinity -> -1.000000000000009
-ddnextt239 nexttoward -1.000000000000011 Infinity -> -1.000000000000010
-ddnextt240 nexttoward -1.000000000000012 Infinity -> -1.000000000000011
-
--- Zeros
-ddnextt300 nexttoward 0 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt301 nexttoward 0.00 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt302 nexttoward 0E-300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt303 nexttoward 0E+300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt304 nexttoward 0E+30000 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt305 nexttoward -0 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt306 nexttoward -0.00 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt307 nexttoward -0E-300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt308 nexttoward -0E+300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt309 nexttoward -0E+30000 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-
--- specials
-ddnextt350 nexttoward Inf Infinity -> Infinity
-ddnextt351 nexttoward -Inf Infinity -> -9.999999999999999E+384
-ddnextt352 nexttoward NaN Infinity -> NaN
-ddnextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
-ddnextt354 nexttoward NaN77 Infinity -> NaN77
-ddnextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
-ddnextt356 nexttoward -NaN Infinity -> -NaN
-ddnextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
-ddnextt358 nexttoward -NaN77 Infinity -> -NaN77
-ddnextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-ddnextt370 nexttoward -9.999999999999999E+384 Infinity -> -9.999999999999998E+384
-ddnextt371 nexttoward -9.999999999999998E+384 Infinity -> -9.999999999999997E+384
-ddnextt372 nexttoward -1E-383 Infinity -> -9.99999999999999E-384 Underflow Subnormal Inexact Rounded
-ddnextt373 nexttoward -1.000000000000000E-383 Infinity -> -9.99999999999999E-384 Underflow Subnormal Inexact Rounded
-ddnextt374 nexttoward -9E-398 Infinity -> -8E-398 Underflow Subnormal Inexact Rounded
-ddnextt375 nexttoward -9.9E-397 Infinity -> -9.8E-397 Underflow Subnormal Inexact Rounded
-ddnextt376 nexttoward -9.99999999999E-387 Infinity -> -9.99999999998E-387 Underflow Subnormal Inexact Rounded
-ddnextt377 nexttoward -9.99999999999999E-384 Infinity -> -9.99999999999998E-384 Underflow Subnormal Inexact Rounded
-ddnextt378 nexttoward -9.99999999999998E-384 Infinity -> -9.99999999999997E-384 Underflow Subnormal Inexact Rounded
-ddnextt379 nexttoward -9.99999999999997E-384 Infinity -> -9.99999999999996E-384 Underflow Subnormal Inexact Rounded
-ddnextt380 nexttoward -0E-398 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt381 nexttoward -1E-398 Infinity -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddnextt382 nexttoward -2E-398 Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-
-ddnextt383 nexttoward 0E-398 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt384 nexttoward 1E-398 Infinity -> 2E-398 Underflow Subnormal Inexact Rounded
-ddnextt385 nexttoward 2E-398 Infinity -> 3E-398 Underflow Subnormal Inexact Rounded
-ddnextt386 nexttoward 10E-398 Infinity -> 1.1E-397 Underflow Subnormal Inexact Rounded
-ddnextt387 nexttoward 100E-398 Infinity -> 1.01E-396 Underflow Subnormal Inexact Rounded
-ddnextt388 nexttoward 100000E-398 Infinity -> 1.00001E-393 Underflow Subnormal Inexact Rounded
-ddnextt389 nexttoward 1.00000000000E-383 Infinity -> 1.000000000000001E-383
-ddnextt390 nexttoward 1.000000000000000E-383 Infinity -> 1.000000000000001E-383
-ddnextt391 nexttoward 1E-383 Infinity -> 1.000000000000001E-383
-ddnextt392 nexttoward 9.999999999999997E+384 Infinity -> 9.999999999999998E+384
-ddnextt393 nexttoward 9.999999999999998E+384 Infinity -> 9.999999999999999E+384
-ddnextt394 nexttoward 9.999999999999999E+384 Infinity -> Infinity Overflow Inexact Rounded
-
-------- lhs>rhs
-ddnextt401 nexttoward 0.9999999999999995 -Infinity -> 0.9999999999999994
-ddnextt402 nexttoward 0.9999999999999996 -Infinity -> 0.9999999999999995
-ddnextt403 nexttoward 0.9999999999999997 -Infinity -> 0.9999999999999996
-ddnextt404 nexttoward 0.9999999999999998 -Infinity -> 0.9999999999999997
-ddnextt405 nexttoward 0.9999999999999999 -Infinity -> 0.9999999999999998
-ddnextt406 nexttoward 1.000000000000000 -Infinity -> 0.9999999999999999
-ddnextt407 nexttoward 1.0 -Infinity -> 0.9999999999999999
-ddnextt408 nexttoward 1 -Infinity -> 0.9999999999999999
-ddnextt409 nexttoward 1.000000000000001 -Infinity -> 1.000000000000000
-ddnextt410 nexttoward 1.000000000000002 -Infinity -> 1.000000000000001
-ddnextt411 nexttoward 1.000000000000003 -Infinity -> 1.000000000000002
-ddnextt412 nexttoward 1.000000000000004 -Infinity -> 1.000000000000003
-ddnextt413 nexttoward 1.000000000000005 -Infinity -> 1.000000000000004
-ddnextt414 nexttoward 1.000000000000006 -Infinity -> 1.000000000000005
-ddnextt415 nexttoward 1.000000000000007 -Infinity -> 1.000000000000006
-ddnextt416 nexttoward 1.000000000000008 -Infinity -> 1.000000000000007
-ddnextt417 nexttoward 1.000000000000009 -Infinity -> 1.000000000000008
-ddnextt418 nexttoward 1.000000000000010 -Infinity -> 1.000000000000009
-ddnextt419 nexttoward 1.000000000000011 -Infinity -> 1.000000000000010
-ddnextt420 nexttoward 1.000000000000012 -Infinity -> 1.000000000000011
-
-ddnextt421 nexttoward -0.9999999999999995 -Infinity -> -0.9999999999999996
-ddnextt422 nexttoward -0.9999999999999996 -Infinity -> -0.9999999999999997
-ddnextt423 nexttoward -0.9999999999999997 -Infinity -> -0.9999999999999998
-ddnextt424 nexttoward -0.9999999999999998 -Infinity -> -0.9999999999999999
-ddnextt425 nexttoward -0.9999999999999999 -Infinity -> -1.000000000000000
-ddnextt426 nexttoward -1.000000000000000 -Infinity -> -1.000000000000001
-ddnextt427 nexttoward -1.0 -Infinity -> -1.000000000000001
-ddnextt428 nexttoward -1 -Infinity -> -1.000000000000001
-ddnextt429 nexttoward -1.000000000000001 -Infinity -> -1.000000000000002
-ddnextt430 nexttoward -1.000000000000002 -Infinity -> -1.000000000000003
-ddnextt431 nexttoward -1.000000000000003 -Infinity -> -1.000000000000004
-ddnextt432 nexttoward -1.000000000000004 -Infinity -> -1.000000000000005
-ddnextt433 nexttoward -1.000000000000005 -Infinity -> -1.000000000000006
-ddnextt434 nexttoward -1.000000000000006 -Infinity -> -1.000000000000007
-ddnextt435 nexttoward -1.000000000000007 -Infinity -> -1.000000000000008
-ddnextt436 nexttoward -1.000000000000008 -Infinity -> -1.000000000000009
-ddnextt437 nexttoward -1.000000000000009 -Infinity -> -1.000000000000010
-ddnextt438 nexttoward -1.000000000000010 -Infinity -> -1.000000000000011
-ddnextt439 nexttoward -1.000000000000011 -Infinity -> -1.000000000000012
-
--- Zeros
-ddnextt500 nexttoward -0 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt501 nexttoward 0 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt502 nexttoward 0.00 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt503 nexttoward -0.00 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt504 nexttoward 0E-300 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt505 nexttoward 0E+300 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt506 nexttoward 0E+30000 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt507 nexttoward -0E+30000 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-
--- specials
-ddnextt550 nexttoward Inf -Infinity -> 9.999999999999999E+384
-ddnextt551 nexttoward -Inf -Infinity -> -Infinity
-ddnextt552 nexttoward NaN -Infinity -> NaN
-ddnextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
-ddnextt554 nexttoward NaN77 -Infinity -> NaN77
-ddnextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
-ddnextt556 nexttoward -NaN -Infinity -> -NaN
-ddnextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
-ddnextt558 nexttoward -NaN77 -Infinity -> -NaN77
-ddnextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-ddnextt670 nexttoward 9.999999999999999E+384 -Infinity -> 9.999999999999998E+384
-ddnextt671 nexttoward 9.999999999999998E+384 -Infinity -> 9.999999999999997E+384
-ddnextt672 nexttoward 1E-383 -Infinity -> 9.99999999999999E-384 Underflow Subnormal Inexact Rounded
-ddnextt673 nexttoward 1.000000000000000E-383 -Infinity -> 9.99999999999999E-384 Underflow Subnormal Inexact Rounded
-ddnextt674 nexttoward 9E-398 -Infinity -> 8E-398 Underflow Subnormal Inexact Rounded
-ddnextt675 nexttoward 9.9E-397 -Infinity -> 9.8E-397 Underflow Subnormal Inexact Rounded
-ddnextt676 nexttoward 9.99999999999E-387 -Infinity -> 9.99999999998E-387 Underflow Subnormal Inexact Rounded
-ddnextt677 nexttoward 9.99999999999999E-384 -Infinity -> 9.99999999999998E-384 Underflow Subnormal Inexact Rounded
-ddnextt678 nexttoward 9.99999999999998E-384 -Infinity -> 9.99999999999997E-384 Underflow Subnormal Inexact Rounded
-ddnextt679 nexttoward 9.99999999999997E-384 -Infinity -> 9.99999999999996E-384 Underflow Subnormal Inexact Rounded
-ddnextt680 nexttoward 0E-398 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt681 nexttoward 1E-398 -Infinity -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddnextt682 nexttoward 2E-398 -Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-
-ddnextt683 nexttoward -0E-398 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt684 nexttoward -1E-398 -Infinity -> -2E-398 Underflow Subnormal Inexact Rounded
-ddnextt685 nexttoward -2E-398 -Infinity -> -3E-398 Underflow Subnormal Inexact Rounded
-ddnextt686 nexttoward -10E-398 -Infinity -> -1.1E-397 Underflow Subnormal Inexact Rounded
-ddnextt687 nexttoward -100E-398 -Infinity -> -1.01E-396 Underflow Subnormal Inexact Rounded
-ddnextt688 nexttoward -100000E-398 -Infinity -> -1.00001E-393 Underflow Subnormal Inexact Rounded
-ddnextt689 nexttoward -1.00000000000E-383 -Infinity -> -1.000000000000001E-383
-ddnextt690 nexttoward -1.000000000000000E-383 -Infinity -> -1.000000000000001E-383
-ddnextt691 nexttoward -1E-383 -Infinity -> -1.000000000000001E-383
-ddnextt692 nexttoward -9.999999999999998E+384 -Infinity -> -9.999999999999999E+384
-ddnextt693 nexttoward -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
-
-------- Specials
-ddnextt780 nexttoward -Inf -Inf -> -Infinity
-ddnextt781 nexttoward -Inf -1000 -> -9.999999999999999E+384
-ddnextt782 nexttoward -Inf -1 -> -9.999999999999999E+384
-ddnextt783 nexttoward -Inf -0 -> -9.999999999999999E+384
-ddnextt784 nexttoward -Inf 0 -> -9.999999999999999E+384
-ddnextt785 nexttoward -Inf 1 -> -9.999999999999999E+384
-ddnextt786 nexttoward -Inf 1000 -> -9.999999999999999E+384
-ddnextt787 nexttoward -1000 -Inf -> -1000.000000000001
-ddnextt788 nexttoward -Inf -Inf -> -Infinity
-ddnextt789 nexttoward -1 -Inf -> -1.000000000000001
-ddnextt790 nexttoward -0 -Inf -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt791 nexttoward 0 -Inf -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt792 nexttoward 1 -Inf -> 0.9999999999999999
-ddnextt793 nexttoward 1000 -Inf -> 999.9999999999999
-ddnextt794 nexttoward Inf -Inf -> 9.999999999999999E+384
-
-ddnextt800 nexttoward Inf -Inf -> 9.999999999999999E+384
-ddnextt801 nexttoward Inf -1000 -> 9.999999999999999E+384
-ddnextt802 nexttoward Inf -1 -> 9.999999999999999E+384
-ddnextt803 nexttoward Inf -0 -> 9.999999999999999E+384
-ddnextt804 nexttoward Inf 0 -> 9.999999999999999E+384
-ddnextt805 nexttoward Inf 1 -> 9.999999999999999E+384
-ddnextt806 nexttoward Inf 1000 -> 9.999999999999999E+384
-ddnextt807 nexttoward Inf Inf -> Infinity
-ddnextt808 nexttoward -1000 Inf -> -999.9999999999999
-ddnextt809 nexttoward -Inf Inf -> -9.999999999999999E+384
-ddnextt810 nexttoward -1 Inf -> -0.9999999999999999
-ddnextt811 nexttoward -0 Inf -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt812 nexttoward 0 Inf -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt813 nexttoward 1 Inf -> 1.000000000000001
-ddnextt814 nexttoward 1000 Inf -> 1000.000000000001
-ddnextt815 nexttoward Inf Inf -> Infinity
-
-ddnextt821 nexttoward NaN -Inf -> NaN
-ddnextt822 nexttoward NaN -1000 -> NaN
-ddnextt823 nexttoward NaN -1 -> NaN
-ddnextt824 nexttoward NaN -0 -> NaN
-ddnextt825 nexttoward NaN 0 -> NaN
-ddnextt826 nexttoward NaN 1 -> NaN
-ddnextt827 nexttoward NaN 1000 -> NaN
-ddnextt828 nexttoward NaN Inf -> NaN
-ddnextt829 nexttoward NaN NaN -> NaN
-ddnextt830 nexttoward -Inf NaN -> NaN
-ddnextt831 nexttoward -1000 NaN -> NaN
-ddnextt832 nexttoward -1 NaN -> NaN
-ddnextt833 nexttoward -0 NaN -> NaN
-ddnextt834 nexttoward 0 NaN -> NaN
-ddnextt835 nexttoward 1 NaN -> NaN
-ddnextt836 nexttoward 1000 NaN -> NaN
-ddnextt837 nexttoward Inf NaN -> NaN
-
-ddnextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
-ddnextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
-ddnextt843 nexttoward sNaN -1 -> NaN Invalid_operation
-ddnextt844 nexttoward sNaN -0 -> NaN Invalid_operation
-ddnextt845 nexttoward sNaN 0 -> NaN Invalid_operation
-ddnextt846 nexttoward sNaN 1 -> NaN Invalid_operation
-ddnextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
-ddnextt848 nexttoward sNaN NaN -> NaN Invalid_operation
-ddnextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
-ddnextt850 nexttoward NaN sNaN -> NaN Invalid_operation
-ddnextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
-ddnextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
-ddnextt853 nexttoward -1 sNaN -> NaN Invalid_operation
-ddnextt854 nexttoward -0 sNaN -> NaN Invalid_operation
-ddnextt855 nexttoward 0 sNaN -> NaN Invalid_operation
-ddnextt856 nexttoward 1 sNaN -> NaN Invalid_operation
-ddnextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
-ddnextt858 nexttoward Inf sNaN -> NaN Invalid_operation
-ddnextt859 nexttoward NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddnextt861 nexttoward NaN1 -Inf -> NaN1
-ddnextt862 nexttoward +NaN2 -1000 -> NaN2
-ddnextt863 nexttoward NaN3 1000 -> NaN3
-ddnextt864 nexttoward NaN4 Inf -> NaN4
-ddnextt865 nexttoward NaN5 +NaN6 -> NaN5
-ddnextt866 nexttoward -Inf NaN7 -> NaN7
-ddnextt867 nexttoward -1000 NaN8 -> NaN8
-ddnextt868 nexttoward 1000 NaN9 -> NaN9
-ddnextt869 nexttoward Inf +NaN10 -> NaN10
-ddnextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
-ddnextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
-ddnextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
-ddnextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
-ddnextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddnextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
-ddnextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
-ddnextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
-ddnextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
-ddnextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
-ddnextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddnextt882 nexttoward -NaN26 NaN28 -> -NaN26
-ddnextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddnextt884 nexttoward 1000 -NaN30 -> -NaN30
-ddnextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Null tests
-ddnextt900 nexttoward 1 # -> NaN Invalid_operation
-ddnextt901 nexttoward # 1 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddNextToward.decTest -- decDouble next toward rhs [754r nextafter] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check with a scattering of numerics
+ddnextt001 nexttoward 10 10 -> 10
+ddnextt002 nexttoward -10 -10 -> -10
+ddnextt003 nexttoward 1 10 -> 1.000000000000001
+ddnextt004 nexttoward 1 -10 -> 0.9999999999999999
+ddnextt005 nexttoward -1 10 -> -0.9999999999999999
+ddnextt006 nexttoward -1 -10 -> -1.000000000000001
+ddnextt007 nexttoward 0 10 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt008 nexttoward 0 -10 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt009 nexttoward 9.999999999999999E+384 +Infinity -> Infinity Overflow Inexact Rounded
+ddnextt010 nexttoward -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
+ddnextt011 nexttoward 9.999999999999999 10 -> 10.00000000000000
+ddnextt012 nexttoward 10 9.999999999999999 -> 9.999999999999999
+ddnextt013 nexttoward -9.999999999999999 -10 -> -10.00000000000000
+ddnextt014 nexttoward -10 -9.999999999999999 -> -9.999999999999999
+ddnextt015 nexttoward 9.999999999999998 10 -> 9.999999999999999
+ddnextt016 nexttoward 10 9.999999999999998 -> 9.999999999999999
+ddnextt017 nexttoward -9.999999999999998 -10 -> -9.999999999999999
+ddnextt018 nexttoward -10 -9.999999999999998 -> -9.999999999999999
+
+------- lhs=rhs
+-- finites
+ddnextt101 nexttoward 7 7 -> 7
+ddnextt102 nexttoward -7 -7 -> -7
+ddnextt103 nexttoward 75 75 -> 75
+ddnextt104 nexttoward -75 -75 -> -75
+ddnextt105 nexttoward 7.50 7.5 -> 7.50
+ddnextt106 nexttoward -7.50 -7.50 -> -7.50
+ddnextt107 nexttoward 7.500 7.5000 -> 7.500
+ddnextt108 nexttoward -7.500 -7.5 -> -7.500
+
+-- zeros
+ddnextt111 nexttoward 0 0 -> 0
+ddnextt112 nexttoward -0 -0 -> -0
+ddnextt113 nexttoward 0E+4 0 -> 0E+4
+ddnextt114 nexttoward -0E+4 -0 -> -0E+4
+ddnextt115 nexttoward 0.00000000000 0.000000000000 -> 0E-11
+ddnextt116 nexttoward -0.00000000000 -0.00 -> -0E-11
+ddnextt117 nexttoward 0E-141 0 -> 0E-141
+ddnextt118 nexttoward -0E-141 -000 -> -0E-141
+
+-- full coefficients, alternating bits
+ddnextt121 nexttoward 268268268 268268268 -> 268268268
+ddnextt122 nexttoward -268268268 -268268268 -> -268268268
+ddnextt123 nexttoward 134134134 134134134 -> 134134134
+ddnextt124 nexttoward -134134134 -134134134 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+ddnextt131 nexttoward 9.999999999999999E+384 9.999999999999999E+384 -> 9.999999999999999E+384
+ddnextt132 nexttoward 1E-383 1E-383 -> 1E-383
+ddnextt133 nexttoward 1.000000000000000E-383 1.000000000000000E-383 -> 1.000000000000000E-383
+ddnextt134 nexttoward 1E-398 1E-398 -> 1E-398
+
+ddnextt135 nexttoward -1E-398 -1E-398 -> -1E-398
+ddnextt136 nexttoward -1.000000000000000E-383 -1.000000000000000E-383 -> -1.000000000000000E-383
+ddnextt137 nexttoward -1E-383 -1E-383 -> -1E-383
+ddnextt138 nexttoward -9.999999999999999E+384 -9.999999999999999E+384 -> -9.999999999999999E+384
+
+------- lhs<rhs
+ddnextt201 nexttoward 0.9999999999999995 Infinity -> 0.9999999999999996
+ddnextt202 nexttoward 0.9999999999999996 Infinity -> 0.9999999999999997
+ddnextt203 nexttoward 0.9999999999999997 Infinity -> 0.9999999999999998
+ddnextt204 nexttoward 0.9999999999999998 Infinity -> 0.9999999999999999
+ddnextt205 nexttoward 0.9999999999999999 Infinity -> 1.000000000000000
+ddnextt206 nexttoward 1.000000000000000 Infinity -> 1.000000000000001
+ddnextt207 nexttoward 1.0 Infinity -> 1.000000000000001
+ddnextt208 nexttoward 1 Infinity -> 1.000000000000001
+ddnextt209 nexttoward 1.000000000000001 Infinity -> 1.000000000000002
+ddnextt210 nexttoward 1.000000000000002 Infinity -> 1.000000000000003
+ddnextt211 nexttoward 1.000000000000003 Infinity -> 1.000000000000004
+ddnextt212 nexttoward 1.000000000000004 Infinity -> 1.000000000000005
+ddnextt213 nexttoward 1.000000000000005 Infinity -> 1.000000000000006
+ddnextt214 nexttoward 1.000000000000006 Infinity -> 1.000000000000007
+ddnextt215 nexttoward 1.000000000000007 Infinity -> 1.000000000000008
+ddnextt216 nexttoward 1.000000000000008 Infinity -> 1.000000000000009
+ddnextt217 nexttoward 1.000000000000009 Infinity -> 1.000000000000010
+ddnextt218 nexttoward 1.000000000000010 Infinity -> 1.000000000000011
+ddnextt219 nexttoward 1.000000000000011 Infinity -> 1.000000000000012
+
+ddnextt221 nexttoward -0.9999999999999995 Infinity -> -0.9999999999999994
+ddnextt222 nexttoward -0.9999999999999996 Infinity -> -0.9999999999999995
+ddnextt223 nexttoward -0.9999999999999997 Infinity -> -0.9999999999999996
+ddnextt224 nexttoward -0.9999999999999998 Infinity -> -0.9999999999999997
+ddnextt225 nexttoward -0.9999999999999999 Infinity -> -0.9999999999999998
+ddnextt226 nexttoward -1.000000000000000 Infinity -> -0.9999999999999999
+ddnextt227 nexttoward -1.0 Infinity -> -0.9999999999999999
+ddnextt228 nexttoward -1 Infinity -> -0.9999999999999999
+ddnextt229 nexttoward -1.000000000000001 Infinity -> -1.000000000000000
+ddnextt230 nexttoward -1.000000000000002 Infinity -> -1.000000000000001
+ddnextt231 nexttoward -1.000000000000003 Infinity -> -1.000000000000002
+ddnextt232 nexttoward -1.000000000000004 Infinity -> -1.000000000000003
+ddnextt233 nexttoward -1.000000000000005 Infinity -> -1.000000000000004
+ddnextt234 nexttoward -1.000000000000006 Infinity -> -1.000000000000005
+ddnextt235 nexttoward -1.000000000000007 Infinity -> -1.000000000000006
+ddnextt236 nexttoward -1.000000000000008 Infinity -> -1.000000000000007
+ddnextt237 nexttoward -1.000000000000009 Infinity -> -1.000000000000008
+ddnextt238 nexttoward -1.000000000000010 Infinity -> -1.000000000000009
+ddnextt239 nexttoward -1.000000000000011 Infinity -> -1.000000000000010
+ddnextt240 nexttoward -1.000000000000012 Infinity -> -1.000000000000011
+
+-- Zeros
+ddnextt300 nexttoward 0 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt301 nexttoward 0.00 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt302 nexttoward 0E-300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt303 nexttoward 0E+300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt304 nexttoward 0E+30000 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt305 nexttoward -0 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt306 nexttoward -0.00 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt307 nexttoward -0E-300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt308 nexttoward -0E+300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt309 nexttoward -0E+30000 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+
+-- specials
+ddnextt350 nexttoward Inf Infinity -> Infinity
+ddnextt351 nexttoward -Inf Infinity -> -9.999999999999999E+384
+ddnextt352 nexttoward NaN Infinity -> NaN
+ddnextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
+ddnextt354 nexttoward NaN77 Infinity -> NaN77
+ddnextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
+ddnextt356 nexttoward -NaN Infinity -> -NaN
+ddnextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
+ddnextt358 nexttoward -NaN77 Infinity -> -NaN77
+ddnextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+ddnextt370 nexttoward -9.999999999999999E+384 Infinity -> -9.999999999999998E+384
+ddnextt371 nexttoward -9.999999999999998E+384 Infinity -> -9.999999999999997E+384
+ddnextt372 nexttoward -1E-383 Infinity -> -9.99999999999999E-384 Underflow Subnormal Inexact Rounded
+ddnextt373 nexttoward -1.000000000000000E-383 Infinity -> -9.99999999999999E-384 Underflow Subnormal Inexact Rounded
+ddnextt374 nexttoward -9E-398 Infinity -> -8E-398 Underflow Subnormal Inexact Rounded
+ddnextt375 nexttoward -9.9E-397 Infinity -> -9.8E-397 Underflow Subnormal Inexact Rounded
+ddnextt376 nexttoward -9.99999999999E-387 Infinity -> -9.99999999998E-387 Underflow Subnormal Inexact Rounded
+ddnextt377 nexttoward -9.99999999999999E-384 Infinity -> -9.99999999999998E-384 Underflow Subnormal Inexact Rounded
+ddnextt378 nexttoward -9.99999999999998E-384 Infinity -> -9.99999999999997E-384 Underflow Subnormal Inexact Rounded
+ddnextt379 nexttoward -9.99999999999997E-384 Infinity -> -9.99999999999996E-384 Underflow Subnormal Inexact Rounded
+ddnextt380 nexttoward -0E-398 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt381 nexttoward -1E-398 Infinity -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddnextt382 nexttoward -2E-398 Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+
+ddnextt383 nexttoward 0E-398 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt384 nexttoward 1E-398 Infinity -> 2E-398 Underflow Subnormal Inexact Rounded
+ddnextt385 nexttoward 2E-398 Infinity -> 3E-398 Underflow Subnormal Inexact Rounded
+ddnextt386 nexttoward 10E-398 Infinity -> 1.1E-397 Underflow Subnormal Inexact Rounded
+ddnextt387 nexttoward 100E-398 Infinity -> 1.01E-396 Underflow Subnormal Inexact Rounded
+ddnextt388 nexttoward 100000E-398 Infinity -> 1.00001E-393 Underflow Subnormal Inexact Rounded
+ddnextt389 nexttoward 1.00000000000E-383 Infinity -> 1.000000000000001E-383
+ddnextt390 nexttoward 1.000000000000000E-383 Infinity -> 1.000000000000001E-383
+ddnextt391 nexttoward 1E-383 Infinity -> 1.000000000000001E-383
+ddnextt392 nexttoward 9.999999999999997E+384 Infinity -> 9.999999999999998E+384
+ddnextt393 nexttoward 9.999999999999998E+384 Infinity -> 9.999999999999999E+384
+ddnextt394 nexttoward 9.999999999999999E+384 Infinity -> Infinity Overflow Inexact Rounded
+
+------- lhs>rhs
+ddnextt401 nexttoward 0.9999999999999995 -Infinity -> 0.9999999999999994
+ddnextt402 nexttoward 0.9999999999999996 -Infinity -> 0.9999999999999995
+ddnextt403 nexttoward 0.9999999999999997 -Infinity -> 0.9999999999999996
+ddnextt404 nexttoward 0.9999999999999998 -Infinity -> 0.9999999999999997
+ddnextt405 nexttoward 0.9999999999999999 -Infinity -> 0.9999999999999998
+ddnextt406 nexttoward 1.000000000000000 -Infinity -> 0.9999999999999999
+ddnextt407 nexttoward 1.0 -Infinity -> 0.9999999999999999
+ddnextt408 nexttoward 1 -Infinity -> 0.9999999999999999
+ddnextt409 nexttoward 1.000000000000001 -Infinity -> 1.000000000000000
+ddnextt410 nexttoward 1.000000000000002 -Infinity -> 1.000000000000001
+ddnextt411 nexttoward 1.000000000000003 -Infinity -> 1.000000000000002
+ddnextt412 nexttoward 1.000000000000004 -Infinity -> 1.000000000000003
+ddnextt413 nexttoward 1.000000000000005 -Infinity -> 1.000000000000004
+ddnextt414 nexttoward 1.000000000000006 -Infinity -> 1.000000000000005
+ddnextt415 nexttoward 1.000000000000007 -Infinity -> 1.000000000000006
+ddnextt416 nexttoward 1.000000000000008 -Infinity -> 1.000000000000007
+ddnextt417 nexttoward 1.000000000000009 -Infinity -> 1.000000000000008
+ddnextt418 nexttoward 1.000000000000010 -Infinity -> 1.000000000000009
+ddnextt419 nexttoward 1.000000000000011 -Infinity -> 1.000000000000010
+ddnextt420 nexttoward 1.000000000000012 -Infinity -> 1.000000000000011
+
+ddnextt421 nexttoward -0.9999999999999995 -Infinity -> -0.9999999999999996
+ddnextt422 nexttoward -0.9999999999999996 -Infinity -> -0.9999999999999997
+ddnextt423 nexttoward -0.9999999999999997 -Infinity -> -0.9999999999999998
+ddnextt424 nexttoward -0.9999999999999998 -Infinity -> -0.9999999999999999
+ddnextt425 nexttoward -0.9999999999999999 -Infinity -> -1.000000000000000
+ddnextt426 nexttoward -1.000000000000000 -Infinity -> -1.000000000000001
+ddnextt427 nexttoward -1.0 -Infinity -> -1.000000000000001
+ddnextt428 nexttoward -1 -Infinity -> -1.000000000000001
+ddnextt429 nexttoward -1.000000000000001 -Infinity -> -1.000000000000002
+ddnextt430 nexttoward -1.000000000000002 -Infinity -> -1.000000000000003
+ddnextt431 nexttoward -1.000000000000003 -Infinity -> -1.000000000000004
+ddnextt432 nexttoward -1.000000000000004 -Infinity -> -1.000000000000005
+ddnextt433 nexttoward -1.000000000000005 -Infinity -> -1.000000000000006
+ddnextt434 nexttoward -1.000000000000006 -Infinity -> -1.000000000000007
+ddnextt435 nexttoward -1.000000000000007 -Infinity -> -1.000000000000008
+ddnextt436 nexttoward -1.000000000000008 -Infinity -> -1.000000000000009
+ddnextt437 nexttoward -1.000000000000009 -Infinity -> -1.000000000000010
+ddnextt438 nexttoward -1.000000000000010 -Infinity -> -1.000000000000011
+ddnextt439 nexttoward -1.000000000000011 -Infinity -> -1.000000000000012
+
+-- Zeros
+ddnextt500 nexttoward -0 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt501 nexttoward 0 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt502 nexttoward 0.00 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt503 nexttoward -0.00 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt504 nexttoward 0E-300 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt505 nexttoward 0E+300 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt506 nexttoward 0E+30000 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt507 nexttoward -0E+30000 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+
+-- specials
+ddnextt550 nexttoward Inf -Infinity -> 9.999999999999999E+384
+ddnextt551 nexttoward -Inf -Infinity -> -Infinity
+ddnextt552 nexttoward NaN -Infinity -> NaN
+ddnextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
+ddnextt554 nexttoward NaN77 -Infinity -> NaN77
+ddnextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
+ddnextt556 nexttoward -NaN -Infinity -> -NaN
+ddnextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
+ddnextt558 nexttoward -NaN77 -Infinity -> -NaN77
+ddnextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+ddnextt670 nexttoward 9.999999999999999E+384 -Infinity -> 9.999999999999998E+384
+ddnextt671 nexttoward 9.999999999999998E+384 -Infinity -> 9.999999999999997E+384
+ddnextt672 nexttoward 1E-383 -Infinity -> 9.99999999999999E-384 Underflow Subnormal Inexact Rounded
+ddnextt673 nexttoward 1.000000000000000E-383 -Infinity -> 9.99999999999999E-384 Underflow Subnormal Inexact Rounded
+ddnextt674 nexttoward 9E-398 -Infinity -> 8E-398 Underflow Subnormal Inexact Rounded
+ddnextt675 nexttoward 9.9E-397 -Infinity -> 9.8E-397 Underflow Subnormal Inexact Rounded
+ddnextt676 nexttoward 9.99999999999E-387 -Infinity -> 9.99999999998E-387 Underflow Subnormal Inexact Rounded
+ddnextt677 nexttoward 9.99999999999999E-384 -Infinity -> 9.99999999999998E-384 Underflow Subnormal Inexact Rounded
+ddnextt678 nexttoward 9.99999999999998E-384 -Infinity -> 9.99999999999997E-384 Underflow Subnormal Inexact Rounded
+ddnextt679 nexttoward 9.99999999999997E-384 -Infinity -> 9.99999999999996E-384 Underflow Subnormal Inexact Rounded
+ddnextt680 nexttoward 0E-398 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt681 nexttoward 1E-398 -Infinity -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddnextt682 nexttoward 2E-398 -Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+
+ddnextt683 nexttoward -0E-398 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt684 nexttoward -1E-398 -Infinity -> -2E-398 Underflow Subnormal Inexact Rounded
+ddnextt685 nexttoward -2E-398 -Infinity -> -3E-398 Underflow Subnormal Inexact Rounded
+ddnextt686 nexttoward -10E-398 -Infinity -> -1.1E-397 Underflow Subnormal Inexact Rounded
+ddnextt687 nexttoward -100E-398 -Infinity -> -1.01E-396 Underflow Subnormal Inexact Rounded
+ddnextt688 nexttoward -100000E-398 -Infinity -> -1.00001E-393 Underflow Subnormal Inexact Rounded
+ddnextt689 nexttoward -1.00000000000E-383 -Infinity -> -1.000000000000001E-383
+ddnextt690 nexttoward -1.000000000000000E-383 -Infinity -> -1.000000000000001E-383
+ddnextt691 nexttoward -1E-383 -Infinity -> -1.000000000000001E-383
+ddnextt692 nexttoward -9.999999999999998E+384 -Infinity -> -9.999999999999999E+384
+ddnextt693 nexttoward -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
+
+------- Specials
+ddnextt780 nexttoward -Inf -Inf -> -Infinity
+ddnextt781 nexttoward -Inf -1000 -> -9.999999999999999E+384
+ddnextt782 nexttoward -Inf -1 -> -9.999999999999999E+384
+ddnextt783 nexttoward -Inf -0 -> -9.999999999999999E+384
+ddnextt784 nexttoward -Inf 0 -> -9.999999999999999E+384
+ddnextt785 nexttoward -Inf 1 -> -9.999999999999999E+384
+ddnextt786 nexttoward -Inf 1000 -> -9.999999999999999E+384
+ddnextt787 nexttoward -1000 -Inf -> -1000.000000000001
+ddnextt788 nexttoward -Inf -Inf -> -Infinity
+ddnextt789 nexttoward -1 -Inf -> -1.000000000000001
+ddnextt790 nexttoward -0 -Inf -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt791 nexttoward 0 -Inf -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt792 nexttoward 1 -Inf -> 0.9999999999999999
+ddnextt793 nexttoward 1000 -Inf -> 999.9999999999999
+ddnextt794 nexttoward Inf -Inf -> 9.999999999999999E+384
+
+ddnextt800 nexttoward Inf -Inf -> 9.999999999999999E+384
+ddnextt801 nexttoward Inf -1000 -> 9.999999999999999E+384
+ddnextt802 nexttoward Inf -1 -> 9.999999999999999E+384
+ddnextt803 nexttoward Inf -0 -> 9.999999999999999E+384
+ddnextt804 nexttoward Inf 0 -> 9.999999999999999E+384
+ddnextt805 nexttoward Inf 1 -> 9.999999999999999E+384
+ddnextt806 nexttoward Inf 1000 -> 9.999999999999999E+384
+ddnextt807 nexttoward Inf Inf -> Infinity
+ddnextt808 nexttoward -1000 Inf -> -999.9999999999999
+ddnextt809 nexttoward -Inf Inf -> -9.999999999999999E+384
+ddnextt810 nexttoward -1 Inf -> -0.9999999999999999
+ddnextt811 nexttoward -0 Inf -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt812 nexttoward 0 Inf -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt813 nexttoward 1 Inf -> 1.000000000000001
+ddnextt814 nexttoward 1000 Inf -> 1000.000000000001
+ddnextt815 nexttoward Inf Inf -> Infinity
+
+ddnextt821 nexttoward NaN -Inf -> NaN
+ddnextt822 nexttoward NaN -1000 -> NaN
+ddnextt823 nexttoward NaN -1 -> NaN
+ddnextt824 nexttoward NaN -0 -> NaN
+ddnextt825 nexttoward NaN 0 -> NaN
+ddnextt826 nexttoward NaN 1 -> NaN
+ddnextt827 nexttoward NaN 1000 -> NaN
+ddnextt828 nexttoward NaN Inf -> NaN
+ddnextt829 nexttoward NaN NaN -> NaN
+ddnextt830 nexttoward -Inf NaN -> NaN
+ddnextt831 nexttoward -1000 NaN -> NaN
+ddnextt832 nexttoward -1 NaN -> NaN
+ddnextt833 nexttoward -0 NaN -> NaN
+ddnextt834 nexttoward 0 NaN -> NaN
+ddnextt835 nexttoward 1 NaN -> NaN
+ddnextt836 nexttoward 1000 NaN -> NaN
+ddnextt837 nexttoward Inf NaN -> NaN
+
+ddnextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
+ddnextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
+ddnextt843 nexttoward sNaN -1 -> NaN Invalid_operation
+ddnextt844 nexttoward sNaN -0 -> NaN Invalid_operation
+ddnextt845 nexttoward sNaN 0 -> NaN Invalid_operation
+ddnextt846 nexttoward sNaN 1 -> NaN Invalid_operation
+ddnextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
+ddnextt848 nexttoward sNaN NaN -> NaN Invalid_operation
+ddnextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
+ddnextt850 nexttoward NaN sNaN -> NaN Invalid_operation
+ddnextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
+ddnextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
+ddnextt853 nexttoward -1 sNaN -> NaN Invalid_operation
+ddnextt854 nexttoward -0 sNaN -> NaN Invalid_operation
+ddnextt855 nexttoward 0 sNaN -> NaN Invalid_operation
+ddnextt856 nexttoward 1 sNaN -> NaN Invalid_operation
+ddnextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
+ddnextt858 nexttoward Inf sNaN -> NaN Invalid_operation
+ddnextt859 nexttoward NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddnextt861 nexttoward NaN1 -Inf -> NaN1
+ddnextt862 nexttoward +NaN2 -1000 -> NaN2
+ddnextt863 nexttoward NaN3 1000 -> NaN3
+ddnextt864 nexttoward NaN4 Inf -> NaN4
+ddnextt865 nexttoward NaN5 +NaN6 -> NaN5
+ddnextt866 nexttoward -Inf NaN7 -> NaN7
+ddnextt867 nexttoward -1000 NaN8 -> NaN8
+ddnextt868 nexttoward 1000 NaN9 -> NaN9
+ddnextt869 nexttoward Inf +NaN10 -> NaN10
+ddnextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
+ddnextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
+ddnextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
+ddnextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
+ddnextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddnextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
+ddnextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
+ddnextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
+ddnextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
+ddnextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
+ddnextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddnextt882 nexttoward -NaN26 NaN28 -> -NaN26
+ddnextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddnextt884 nexttoward 1000 -NaN30 -> -NaN30
+ddnextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Null tests
+ddnextt900 nexttoward 1 # -> NaN Invalid_operation
+ddnextt901 nexttoward # 1 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddOr.decTest b/Lib/test/decimaltestdata/ddOr.decTest
index f3a702b0ef..d36580bf66 100644
--- a/Lib/test/decimaltestdata/ddOr.decTest
+++ b/Lib/test/decimaltestdata/ddOr.decTest
@@ -1,292 +1,292 @@
-------------------------------------------------------------------------
--- ddOr.decTest -- digitwise logical OR for decDoubles --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check (truth table)
-ddor001 or 0 0 -> 0
-ddor002 or 0 1 -> 1
-ddor003 or 1 0 -> 1
-ddor004 or 1 1 -> 1
-ddor005 or 1100 1010 -> 1110
--- and at msd and msd-1
-ddor006 or 0000000000000000 0000000000000000 -> 0
-ddor007 or 0000000000000000 1000000000000000 -> 1000000000000000
-ddor008 or 1000000000000000 0000000000000000 -> 1000000000000000
-ddor009 or 1000000000000000 1000000000000000 -> 1000000000000000
-ddor010 or 0000000000000000 0000000000000000 -> 0
-ddor011 or 0000000000000000 0100000000000000 -> 100000000000000
-ddor012 or 0100000000000000 0000000000000000 -> 100000000000000
-ddor013 or 0100000000000000 0100000000000000 -> 100000000000000
-
--- Various lengths
--- 1234567890123456 1234567890123456 1234567890123456
-ddor020 or 1111111111111111 1111111111111111 -> 1111111111111111
-ddor021 or 111111111111111 111111111111111 -> 111111111111111
-ddor022 or 11111111111111 11111111111111 -> 11111111111111
-ddor023 or 1111111111111 1111111111111 -> 1111111111111
-ddor024 or 111111111111 111111111111 -> 111111111111
-ddor025 or 11111111111 11111111111 -> 11111111111
-ddor026 or 1111111111 1111111111 -> 1111111111
-ddor027 or 111111111 111111111 -> 111111111
-ddor028 or 11111111 11111111 -> 11111111
-ddor029 or 1111111 1111111 -> 1111111
-ddor030 or 111111 111111 -> 111111
-ddor031 or 11111 11111 -> 11111
-ddor032 or 1111 1111 -> 1111
-ddor033 or 111 111 -> 111
-ddor034 or 11 11 -> 11
-ddor035 or 1 1 -> 1
-ddor036 or 0 0 -> 0
-
-ddor042 or 111111110000000 1111111110000000 -> 1111111110000000
-ddor043 or 11111110000000 1000000100000000 -> 1011111110000000
-ddor044 or 1111110000000 1000001000000000 -> 1001111110000000
-ddor045 or 111110000000 1000010000000000 -> 1000111110000000
-ddor046 or 11110000000 1000100000000000 -> 1000111110000000
-ddor047 or 1110000000 1001000000000000 -> 1001001110000000
-ddor048 or 110000000 1010000000000000 -> 1010000110000000
-ddor049 or 10000000 1100000000000000 -> 1100000010000000
-
-ddor090 or 011111111 111101111 -> 111111111
-ddor091 or 101111111 111101111 -> 111111111
-ddor092 or 110111111 111101111 -> 111111111
-ddor093 or 111011111 111101111 -> 111111111
-ddor094 or 111101111 111101111 -> 111101111
-ddor095 or 111110111 111101111 -> 111111111
-ddor096 or 111111011 111101111 -> 111111111
-ddor097 or 111111101 111101111 -> 111111111
-ddor098 or 111111110 111101111 -> 111111111
-
-ddor100 or 111101111 011111111 -> 111111111
-ddor101 or 111101111 101111111 -> 111111111
-ddor102 or 111101111 110111111 -> 111111111
-ddor103 or 111101111 111011111 -> 111111111
-ddor104 or 111101111 111101111 -> 111101111
-ddor105 or 111101111 111110111 -> 111111111
-ddor106 or 111101111 111111011 -> 111111111
-ddor107 or 111101111 111111101 -> 111111111
-ddor108 or 111101111 111111110 -> 111111111
-
--- non-0/1 should not be accepted, nor should signs
-ddor220 or 111111112 111111111 -> NaN Invalid_operation
-ddor221 or 333333333 333333333 -> NaN Invalid_operation
-ddor222 or 555555555 555555555 -> NaN Invalid_operation
-ddor223 or 777777777 777777777 -> NaN Invalid_operation
-ddor224 or 999999999 999999999 -> NaN Invalid_operation
-ddor225 or 222222222 999999999 -> NaN Invalid_operation
-ddor226 or 444444444 999999999 -> NaN Invalid_operation
-ddor227 or 666666666 999999999 -> NaN Invalid_operation
-ddor228 or 888888888 999999999 -> NaN Invalid_operation
-ddor229 or 999999999 222222222 -> NaN Invalid_operation
-ddor230 or 999999999 444444444 -> NaN Invalid_operation
-ddor231 or 999999999 666666666 -> NaN Invalid_operation
-ddor232 or 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-ddor240 or 567468689 -934981942 -> NaN Invalid_operation
-ddor241 or 567367689 934981942 -> NaN Invalid_operation
-ddor242 or -631917772 -706014634 -> NaN Invalid_operation
-ddor243 or -756253257 138579234 -> NaN Invalid_operation
-ddor244 or 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-ddor250 or 2000000000000000 1000000000000000 -> NaN Invalid_operation
-ddor251 or 7000000000000000 1000000000000000 -> NaN Invalid_operation
-ddor252 or 8000000000000000 1000000000000000 -> NaN Invalid_operation
-ddor253 or 9000000000000000 1000000000000000 -> NaN Invalid_operation
-ddor254 or 2000000000000000 0000000000000000 -> NaN Invalid_operation
-ddor255 or 7000000000000000 0000000000000000 -> NaN Invalid_operation
-ddor256 or 8000000000000000 0000000000000000 -> NaN Invalid_operation
-ddor257 or 9000000000000000 0000000000000000 -> NaN Invalid_operation
-ddor258 or 1000000000000000 2000000000000000 -> NaN Invalid_operation
-ddor259 or 1000000000000000 7000000000000000 -> NaN Invalid_operation
-ddor260 or 1000000000000000 8000000000000000 -> NaN Invalid_operation
-ddor261 or 1000000000000000 9000000000000000 -> NaN Invalid_operation
-ddor262 or 0000000000000000 2000000000000000 -> NaN Invalid_operation
-ddor263 or 0000000000000000 7000000000000000 -> NaN Invalid_operation
-ddor264 or 0000000000000000 8000000000000000 -> NaN Invalid_operation
-ddor265 or 0000000000000000 9000000000000000 -> NaN Invalid_operation
--- test MSD-1
-ddor270 or 0200001000000000 1000100000000010 -> NaN Invalid_operation
-ddor271 or 0700000100000000 1000010000000100 -> NaN Invalid_operation
-ddor272 or 0800000010000000 1000001000001000 -> NaN Invalid_operation
-ddor273 or 0900000001000000 1000000100010000 -> NaN Invalid_operation
-ddor274 or 1000000000100000 0200000010100000 -> NaN Invalid_operation
-ddor275 or 1000000000010000 0700000001000000 -> NaN Invalid_operation
-ddor276 or 1000000000001000 0800000010100000 -> NaN Invalid_operation
-ddor277 or 1000000000000100 0900000000010000 -> NaN Invalid_operation
--- test LSD
-ddor280 or 0010000000000002 1000000100000001 -> NaN Invalid_operation
-ddor281 or 0001000000000007 1000001000000011 -> NaN Invalid_operation
-ddor282 or 0000100000000008 1000010000000001 -> NaN Invalid_operation
-ddor283 or 0000010000000009 1000100000000001 -> NaN Invalid_operation
-ddor284 or 1000001000000000 0001000000000002 -> NaN Invalid_operation
-ddor285 or 1000000100000000 0010000000000007 -> NaN Invalid_operation
-ddor286 or 1000000010000000 0100000000000008 -> NaN Invalid_operation
-ddor287 or 1000000001000000 1000000000000009 -> NaN Invalid_operation
--- test Middie
-ddor288 or 0010000020000000 1000001000000000 -> NaN Invalid_operation
-ddor289 or 0001000070000001 1000000100000000 -> NaN Invalid_operation
-ddor290 or 0000100080000010 1000000010000000 -> NaN Invalid_operation
-ddor291 or 0000010090000100 1000000001000000 -> NaN Invalid_operation
-ddor292 or 1000001000001000 0000000020100000 -> NaN Invalid_operation
-ddor293 or 1000000100010000 0000000070010000 -> NaN Invalid_operation
-ddor294 or 1000000010100000 0000000080001000 -> NaN Invalid_operation
-ddor295 or 1000000001000000 0000000090000100 -> NaN Invalid_operation
--- signs
-ddor296 or -1000000001000000 -0000010000000100 -> NaN Invalid_operation
-ddor297 or -1000000001000000 0000000010000100 -> NaN Invalid_operation
-ddor298 or 1000000001000000 -0000001000000100 -> NaN Invalid_operation
-ddor299 or 1000000001000000 0000000011000100 -> 1000000011000100
-
--- Nmax, Nmin, Ntiny-like
-ddor331 or 2 9.99999999E+199 -> NaN Invalid_operation
-ddor332 or 3 1E-199 -> NaN Invalid_operation
-ddor333 or 4 1.00000000E-199 -> NaN Invalid_operation
-ddor334 or 5 1E-100 -> NaN Invalid_operation
-ddor335 or 6 -1E-100 -> NaN Invalid_operation
-ddor336 or 7 -1.00000000E-199 -> NaN Invalid_operation
-ddor337 or 8 -1E-199 -> NaN Invalid_operation
-ddor338 or 9 -9.99999999E+199 -> NaN Invalid_operation
-ddor341 or 9.99999999E+299 -18 -> NaN Invalid_operation
-ddor342 or 1E-299 01 -> NaN Invalid_operation
-ddor343 or 1.00000000E-299 -18 -> NaN Invalid_operation
-ddor344 or 1E-100 18 -> NaN Invalid_operation
-ddor345 or -1E-100 -10 -> NaN Invalid_operation
-ddor346 or -1.00000000E-299 18 -> NaN Invalid_operation
-ddor347 or -1E-299 10 -> NaN Invalid_operation
-ddor348 or -9.99999999E+299 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-ddor361 or 1.0 1 -> NaN Invalid_operation
-ddor362 or 1E+1 1 -> NaN Invalid_operation
-ddor363 or 0.0 1 -> NaN Invalid_operation
-ddor364 or 0E+1 1 -> NaN Invalid_operation
-ddor365 or 9.9 1 -> NaN Invalid_operation
-ddor366 or 9E+1 1 -> NaN Invalid_operation
-ddor371 or 0 1.0 -> NaN Invalid_operation
-ddor372 or 0 1E+1 -> NaN Invalid_operation
-ddor373 or 0 0.0 -> NaN Invalid_operation
-ddor374 or 0 0E+1 -> NaN Invalid_operation
-ddor375 or 0 9.9 -> NaN Invalid_operation
-ddor376 or 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-ddor780 or -Inf -Inf -> NaN Invalid_operation
-ddor781 or -Inf -1000 -> NaN Invalid_operation
-ddor782 or -Inf -1 -> NaN Invalid_operation
-ddor783 or -Inf -0 -> NaN Invalid_operation
-ddor784 or -Inf 0 -> NaN Invalid_operation
-ddor785 or -Inf 1 -> NaN Invalid_operation
-ddor786 or -Inf 1000 -> NaN Invalid_operation
-ddor787 or -1000 -Inf -> NaN Invalid_operation
-ddor788 or -Inf -Inf -> NaN Invalid_operation
-ddor789 or -1 -Inf -> NaN Invalid_operation
-ddor790 or -0 -Inf -> NaN Invalid_operation
-ddor791 or 0 -Inf -> NaN Invalid_operation
-ddor792 or 1 -Inf -> NaN Invalid_operation
-ddor793 or 1000 -Inf -> NaN Invalid_operation
-ddor794 or Inf -Inf -> NaN Invalid_operation
-
-ddor800 or Inf -Inf -> NaN Invalid_operation
-ddor801 or Inf -1000 -> NaN Invalid_operation
-ddor802 or Inf -1 -> NaN Invalid_operation
-ddor803 or Inf -0 -> NaN Invalid_operation
-ddor804 or Inf 0 -> NaN Invalid_operation
-ddor805 or Inf 1 -> NaN Invalid_operation
-ddor806 or Inf 1000 -> NaN Invalid_operation
-ddor807 or Inf Inf -> NaN Invalid_operation
-ddor808 or -1000 Inf -> NaN Invalid_operation
-ddor809 or -Inf Inf -> NaN Invalid_operation
-ddor810 or -1 Inf -> NaN Invalid_operation
-ddor811 or -0 Inf -> NaN Invalid_operation
-ddor812 or 0 Inf -> NaN Invalid_operation
-ddor813 or 1 Inf -> NaN Invalid_operation
-ddor814 or 1000 Inf -> NaN Invalid_operation
-ddor815 or Inf Inf -> NaN Invalid_operation
-
-ddor821 or NaN -Inf -> NaN Invalid_operation
-ddor822 or NaN -1000 -> NaN Invalid_operation
-ddor823 or NaN -1 -> NaN Invalid_operation
-ddor824 or NaN -0 -> NaN Invalid_operation
-ddor825 or NaN 0 -> NaN Invalid_operation
-ddor826 or NaN 1 -> NaN Invalid_operation
-ddor827 or NaN 1000 -> NaN Invalid_operation
-ddor828 or NaN Inf -> NaN Invalid_operation
-ddor829 or NaN NaN -> NaN Invalid_operation
-ddor830 or -Inf NaN -> NaN Invalid_operation
-ddor831 or -1000 NaN -> NaN Invalid_operation
-ddor832 or -1 NaN -> NaN Invalid_operation
-ddor833 or -0 NaN -> NaN Invalid_operation
-ddor834 or 0 NaN -> NaN Invalid_operation
-ddor835 or 1 NaN -> NaN Invalid_operation
-ddor836 or 1000 NaN -> NaN Invalid_operation
-ddor837 or Inf NaN -> NaN Invalid_operation
-
-ddor841 or sNaN -Inf -> NaN Invalid_operation
-ddor842 or sNaN -1000 -> NaN Invalid_operation
-ddor843 or sNaN -1 -> NaN Invalid_operation
-ddor844 or sNaN -0 -> NaN Invalid_operation
-ddor845 or sNaN 0 -> NaN Invalid_operation
-ddor846 or sNaN 1 -> NaN Invalid_operation
-ddor847 or sNaN 1000 -> NaN Invalid_operation
-ddor848 or sNaN NaN -> NaN Invalid_operation
-ddor849 or sNaN sNaN -> NaN Invalid_operation
-ddor850 or NaN sNaN -> NaN Invalid_operation
-ddor851 or -Inf sNaN -> NaN Invalid_operation
-ddor852 or -1000 sNaN -> NaN Invalid_operation
-ddor853 or -1 sNaN -> NaN Invalid_operation
-ddor854 or -0 sNaN -> NaN Invalid_operation
-ddor855 or 0 sNaN -> NaN Invalid_operation
-ddor856 or 1 sNaN -> NaN Invalid_operation
-ddor857 or 1000 sNaN -> NaN Invalid_operation
-ddor858 or Inf sNaN -> NaN Invalid_operation
-ddor859 or NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddor861 or NaN1 -Inf -> NaN Invalid_operation
-ddor862 or +NaN2 -1000 -> NaN Invalid_operation
-ddor863 or NaN3 1000 -> NaN Invalid_operation
-ddor864 or NaN4 Inf -> NaN Invalid_operation
-ddor865 or NaN5 +NaN6 -> NaN Invalid_operation
-ddor866 or -Inf NaN7 -> NaN Invalid_operation
-ddor867 or -1000 NaN8 -> NaN Invalid_operation
-ddor868 or 1000 NaN9 -> NaN Invalid_operation
-ddor869 or Inf +NaN10 -> NaN Invalid_operation
-ddor871 or sNaN11 -Inf -> NaN Invalid_operation
-ddor872 or sNaN12 -1000 -> NaN Invalid_operation
-ddor873 or sNaN13 1000 -> NaN Invalid_operation
-ddor874 or sNaN14 NaN17 -> NaN Invalid_operation
-ddor875 or sNaN15 sNaN18 -> NaN Invalid_operation
-ddor876 or NaN16 sNaN19 -> NaN Invalid_operation
-ddor877 or -Inf +sNaN20 -> NaN Invalid_operation
-ddor878 or -1000 sNaN21 -> NaN Invalid_operation
-ddor879 or 1000 sNaN22 -> NaN Invalid_operation
-ddor880 or Inf sNaN23 -> NaN Invalid_operation
-ddor881 or +NaN25 +sNaN24 -> NaN Invalid_operation
-ddor882 or -NaN26 NaN28 -> NaN Invalid_operation
-ddor883 or -sNaN27 sNaN29 -> NaN Invalid_operation
-ddor884 or 1000 -NaN30 -> NaN Invalid_operation
-ddor885 or 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddOr.decTest -- digitwise logical OR for decDoubles --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check (truth table)
+ddor001 or 0 0 -> 0
+ddor002 or 0 1 -> 1
+ddor003 or 1 0 -> 1
+ddor004 or 1 1 -> 1
+ddor005 or 1100 1010 -> 1110
+-- and at msd and msd-1
+ddor006 or 0000000000000000 0000000000000000 -> 0
+ddor007 or 0000000000000000 1000000000000000 -> 1000000000000000
+ddor008 or 1000000000000000 0000000000000000 -> 1000000000000000
+ddor009 or 1000000000000000 1000000000000000 -> 1000000000000000
+ddor010 or 0000000000000000 0000000000000000 -> 0
+ddor011 or 0000000000000000 0100000000000000 -> 100000000000000
+ddor012 or 0100000000000000 0000000000000000 -> 100000000000000
+ddor013 or 0100000000000000 0100000000000000 -> 100000000000000
+
+-- Various lengths
+-- 1234567890123456 1234567890123456 1234567890123456
+ddor020 or 1111111111111111 1111111111111111 -> 1111111111111111
+ddor021 or 111111111111111 111111111111111 -> 111111111111111
+ddor022 or 11111111111111 11111111111111 -> 11111111111111
+ddor023 or 1111111111111 1111111111111 -> 1111111111111
+ddor024 or 111111111111 111111111111 -> 111111111111
+ddor025 or 11111111111 11111111111 -> 11111111111
+ddor026 or 1111111111 1111111111 -> 1111111111
+ddor027 or 111111111 111111111 -> 111111111
+ddor028 or 11111111 11111111 -> 11111111
+ddor029 or 1111111 1111111 -> 1111111
+ddor030 or 111111 111111 -> 111111
+ddor031 or 11111 11111 -> 11111
+ddor032 or 1111 1111 -> 1111
+ddor033 or 111 111 -> 111
+ddor034 or 11 11 -> 11
+ddor035 or 1 1 -> 1
+ddor036 or 0 0 -> 0
+
+ddor042 or 111111110000000 1111111110000000 -> 1111111110000000
+ddor043 or 11111110000000 1000000100000000 -> 1011111110000000
+ddor044 or 1111110000000 1000001000000000 -> 1001111110000000
+ddor045 or 111110000000 1000010000000000 -> 1000111110000000
+ddor046 or 11110000000 1000100000000000 -> 1000111110000000
+ddor047 or 1110000000 1001000000000000 -> 1001001110000000
+ddor048 or 110000000 1010000000000000 -> 1010000110000000
+ddor049 or 10000000 1100000000000000 -> 1100000010000000
+
+ddor090 or 011111111 111101111 -> 111111111
+ddor091 or 101111111 111101111 -> 111111111
+ddor092 or 110111111 111101111 -> 111111111
+ddor093 or 111011111 111101111 -> 111111111
+ddor094 or 111101111 111101111 -> 111101111
+ddor095 or 111110111 111101111 -> 111111111
+ddor096 or 111111011 111101111 -> 111111111
+ddor097 or 111111101 111101111 -> 111111111
+ddor098 or 111111110 111101111 -> 111111111
+
+ddor100 or 111101111 011111111 -> 111111111
+ddor101 or 111101111 101111111 -> 111111111
+ddor102 or 111101111 110111111 -> 111111111
+ddor103 or 111101111 111011111 -> 111111111
+ddor104 or 111101111 111101111 -> 111101111
+ddor105 or 111101111 111110111 -> 111111111
+ddor106 or 111101111 111111011 -> 111111111
+ddor107 or 111101111 111111101 -> 111111111
+ddor108 or 111101111 111111110 -> 111111111
+
+-- non-0/1 should not be accepted, nor should signs
+ddor220 or 111111112 111111111 -> NaN Invalid_operation
+ddor221 or 333333333 333333333 -> NaN Invalid_operation
+ddor222 or 555555555 555555555 -> NaN Invalid_operation
+ddor223 or 777777777 777777777 -> NaN Invalid_operation
+ddor224 or 999999999 999999999 -> NaN Invalid_operation
+ddor225 or 222222222 999999999 -> NaN Invalid_operation
+ddor226 or 444444444 999999999 -> NaN Invalid_operation
+ddor227 or 666666666 999999999 -> NaN Invalid_operation
+ddor228 or 888888888 999999999 -> NaN Invalid_operation
+ddor229 or 999999999 222222222 -> NaN Invalid_operation
+ddor230 or 999999999 444444444 -> NaN Invalid_operation
+ddor231 or 999999999 666666666 -> NaN Invalid_operation
+ddor232 or 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+ddor240 or 567468689 -934981942 -> NaN Invalid_operation
+ddor241 or 567367689 934981942 -> NaN Invalid_operation
+ddor242 or -631917772 -706014634 -> NaN Invalid_operation
+ddor243 or -756253257 138579234 -> NaN Invalid_operation
+ddor244 or 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+ddor250 or 2000000000000000 1000000000000000 -> NaN Invalid_operation
+ddor251 or 7000000000000000 1000000000000000 -> NaN Invalid_operation
+ddor252 or 8000000000000000 1000000000000000 -> NaN Invalid_operation
+ddor253 or 9000000000000000 1000000000000000 -> NaN Invalid_operation
+ddor254 or 2000000000000000 0000000000000000 -> NaN Invalid_operation
+ddor255 or 7000000000000000 0000000000000000 -> NaN Invalid_operation
+ddor256 or 8000000000000000 0000000000000000 -> NaN Invalid_operation
+ddor257 or 9000000000000000 0000000000000000 -> NaN Invalid_operation
+ddor258 or 1000000000000000 2000000000000000 -> NaN Invalid_operation
+ddor259 or 1000000000000000 7000000000000000 -> NaN Invalid_operation
+ddor260 or 1000000000000000 8000000000000000 -> NaN Invalid_operation
+ddor261 or 1000000000000000 9000000000000000 -> NaN Invalid_operation
+ddor262 or 0000000000000000 2000000000000000 -> NaN Invalid_operation
+ddor263 or 0000000000000000 7000000000000000 -> NaN Invalid_operation
+ddor264 or 0000000000000000 8000000000000000 -> NaN Invalid_operation
+ddor265 or 0000000000000000 9000000000000000 -> NaN Invalid_operation
+-- test MSD-1
+ddor270 or 0200001000000000 1000100000000010 -> NaN Invalid_operation
+ddor271 or 0700000100000000 1000010000000100 -> NaN Invalid_operation
+ddor272 or 0800000010000000 1000001000001000 -> NaN Invalid_operation
+ddor273 or 0900000001000000 1000000100010000 -> NaN Invalid_operation
+ddor274 or 1000000000100000 0200000010100000 -> NaN Invalid_operation
+ddor275 or 1000000000010000 0700000001000000 -> NaN Invalid_operation
+ddor276 or 1000000000001000 0800000010100000 -> NaN Invalid_operation
+ddor277 or 1000000000000100 0900000000010000 -> NaN Invalid_operation
+-- test LSD
+ddor280 or 0010000000000002 1000000100000001 -> NaN Invalid_operation
+ddor281 or 0001000000000007 1000001000000011 -> NaN Invalid_operation
+ddor282 or 0000100000000008 1000010000000001 -> NaN Invalid_operation
+ddor283 or 0000010000000009 1000100000000001 -> NaN Invalid_operation
+ddor284 or 1000001000000000 0001000000000002 -> NaN Invalid_operation
+ddor285 or 1000000100000000 0010000000000007 -> NaN Invalid_operation
+ddor286 or 1000000010000000 0100000000000008 -> NaN Invalid_operation
+ddor287 or 1000000001000000 1000000000000009 -> NaN Invalid_operation
+-- test Middie
+ddor288 or 0010000020000000 1000001000000000 -> NaN Invalid_operation
+ddor289 or 0001000070000001 1000000100000000 -> NaN Invalid_operation
+ddor290 or 0000100080000010 1000000010000000 -> NaN Invalid_operation
+ddor291 or 0000010090000100 1000000001000000 -> NaN Invalid_operation
+ddor292 or 1000001000001000 0000000020100000 -> NaN Invalid_operation
+ddor293 or 1000000100010000 0000000070010000 -> NaN Invalid_operation
+ddor294 or 1000000010100000 0000000080001000 -> NaN Invalid_operation
+ddor295 or 1000000001000000 0000000090000100 -> NaN Invalid_operation
+-- signs
+ddor296 or -1000000001000000 -0000010000000100 -> NaN Invalid_operation
+ddor297 or -1000000001000000 0000000010000100 -> NaN Invalid_operation
+ddor298 or 1000000001000000 -0000001000000100 -> NaN Invalid_operation
+ddor299 or 1000000001000000 0000000011000100 -> 1000000011000100
+
+-- Nmax, Nmin, Ntiny-like
+ddor331 or 2 9.99999999E+199 -> NaN Invalid_operation
+ddor332 or 3 1E-199 -> NaN Invalid_operation
+ddor333 or 4 1.00000000E-199 -> NaN Invalid_operation
+ddor334 or 5 1E-100 -> NaN Invalid_operation
+ddor335 or 6 -1E-100 -> NaN Invalid_operation
+ddor336 or 7 -1.00000000E-199 -> NaN Invalid_operation
+ddor337 or 8 -1E-199 -> NaN Invalid_operation
+ddor338 or 9 -9.99999999E+199 -> NaN Invalid_operation
+ddor341 or 9.99999999E+299 -18 -> NaN Invalid_operation
+ddor342 or 1E-299 01 -> NaN Invalid_operation
+ddor343 or 1.00000000E-299 -18 -> NaN Invalid_operation
+ddor344 or 1E-100 18 -> NaN Invalid_operation
+ddor345 or -1E-100 -10 -> NaN Invalid_operation
+ddor346 or -1.00000000E-299 18 -> NaN Invalid_operation
+ddor347 or -1E-299 10 -> NaN Invalid_operation
+ddor348 or -9.99999999E+299 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+ddor361 or 1.0 1 -> NaN Invalid_operation
+ddor362 or 1E+1 1 -> NaN Invalid_operation
+ddor363 or 0.0 1 -> NaN Invalid_operation
+ddor364 or 0E+1 1 -> NaN Invalid_operation
+ddor365 or 9.9 1 -> NaN Invalid_operation
+ddor366 or 9E+1 1 -> NaN Invalid_operation
+ddor371 or 0 1.0 -> NaN Invalid_operation
+ddor372 or 0 1E+1 -> NaN Invalid_operation
+ddor373 or 0 0.0 -> NaN Invalid_operation
+ddor374 or 0 0E+1 -> NaN Invalid_operation
+ddor375 or 0 9.9 -> NaN Invalid_operation
+ddor376 or 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+ddor780 or -Inf -Inf -> NaN Invalid_operation
+ddor781 or -Inf -1000 -> NaN Invalid_operation
+ddor782 or -Inf -1 -> NaN Invalid_operation
+ddor783 or -Inf -0 -> NaN Invalid_operation
+ddor784 or -Inf 0 -> NaN Invalid_operation
+ddor785 or -Inf 1 -> NaN Invalid_operation
+ddor786 or -Inf 1000 -> NaN Invalid_operation
+ddor787 or -1000 -Inf -> NaN Invalid_operation
+ddor788 or -Inf -Inf -> NaN Invalid_operation
+ddor789 or -1 -Inf -> NaN Invalid_operation
+ddor790 or -0 -Inf -> NaN Invalid_operation
+ddor791 or 0 -Inf -> NaN Invalid_operation
+ddor792 or 1 -Inf -> NaN Invalid_operation
+ddor793 or 1000 -Inf -> NaN Invalid_operation
+ddor794 or Inf -Inf -> NaN Invalid_operation
+
+ddor800 or Inf -Inf -> NaN Invalid_operation
+ddor801 or Inf -1000 -> NaN Invalid_operation
+ddor802 or Inf -1 -> NaN Invalid_operation
+ddor803 or Inf -0 -> NaN Invalid_operation
+ddor804 or Inf 0 -> NaN Invalid_operation
+ddor805 or Inf 1 -> NaN Invalid_operation
+ddor806 or Inf 1000 -> NaN Invalid_operation
+ddor807 or Inf Inf -> NaN Invalid_operation
+ddor808 or -1000 Inf -> NaN Invalid_operation
+ddor809 or -Inf Inf -> NaN Invalid_operation
+ddor810 or -1 Inf -> NaN Invalid_operation
+ddor811 or -0 Inf -> NaN Invalid_operation
+ddor812 or 0 Inf -> NaN Invalid_operation
+ddor813 or 1 Inf -> NaN Invalid_operation
+ddor814 or 1000 Inf -> NaN Invalid_operation
+ddor815 or Inf Inf -> NaN Invalid_operation
+
+ddor821 or NaN -Inf -> NaN Invalid_operation
+ddor822 or NaN -1000 -> NaN Invalid_operation
+ddor823 or NaN -1 -> NaN Invalid_operation
+ddor824 or NaN -0 -> NaN Invalid_operation
+ddor825 or NaN 0 -> NaN Invalid_operation
+ddor826 or NaN 1 -> NaN Invalid_operation
+ddor827 or NaN 1000 -> NaN Invalid_operation
+ddor828 or NaN Inf -> NaN Invalid_operation
+ddor829 or NaN NaN -> NaN Invalid_operation
+ddor830 or -Inf NaN -> NaN Invalid_operation
+ddor831 or -1000 NaN -> NaN Invalid_operation
+ddor832 or -1 NaN -> NaN Invalid_operation
+ddor833 or -0 NaN -> NaN Invalid_operation
+ddor834 or 0 NaN -> NaN Invalid_operation
+ddor835 or 1 NaN -> NaN Invalid_operation
+ddor836 or 1000 NaN -> NaN Invalid_operation
+ddor837 or Inf NaN -> NaN Invalid_operation
+
+ddor841 or sNaN -Inf -> NaN Invalid_operation
+ddor842 or sNaN -1000 -> NaN Invalid_operation
+ddor843 or sNaN -1 -> NaN Invalid_operation
+ddor844 or sNaN -0 -> NaN Invalid_operation
+ddor845 or sNaN 0 -> NaN Invalid_operation
+ddor846 or sNaN 1 -> NaN Invalid_operation
+ddor847 or sNaN 1000 -> NaN Invalid_operation
+ddor848 or sNaN NaN -> NaN Invalid_operation
+ddor849 or sNaN sNaN -> NaN Invalid_operation
+ddor850 or NaN sNaN -> NaN Invalid_operation
+ddor851 or -Inf sNaN -> NaN Invalid_operation
+ddor852 or -1000 sNaN -> NaN Invalid_operation
+ddor853 or -1 sNaN -> NaN Invalid_operation
+ddor854 or -0 sNaN -> NaN Invalid_operation
+ddor855 or 0 sNaN -> NaN Invalid_operation
+ddor856 or 1 sNaN -> NaN Invalid_operation
+ddor857 or 1000 sNaN -> NaN Invalid_operation
+ddor858 or Inf sNaN -> NaN Invalid_operation
+ddor859 or NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddor861 or NaN1 -Inf -> NaN Invalid_operation
+ddor862 or +NaN2 -1000 -> NaN Invalid_operation
+ddor863 or NaN3 1000 -> NaN Invalid_operation
+ddor864 or NaN4 Inf -> NaN Invalid_operation
+ddor865 or NaN5 +NaN6 -> NaN Invalid_operation
+ddor866 or -Inf NaN7 -> NaN Invalid_operation
+ddor867 or -1000 NaN8 -> NaN Invalid_operation
+ddor868 or 1000 NaN9 -> NaN Invalid_operation
+ddor869 or Inf +NaN10 -> NaN Invalid_operation
+ddor871 or sNaN11 -Inf -> NaN Invalid_operation
+ddor872 or sNaN12 -1000 -> NaN Invalid_operation
+ddor873 or sNaN13 1000 -> NaN Invalid_operation
+ddor874 or sNaN14 NaN17 -> NaN Invalid_operation
+ddor875 or sNaN15 sNaN18 -> NaN Invalid_operation
+ddor876 or NaN16 sNaN19 -> NaN Invalid_operation
+ddor877 or -Inf +sNaN20 -> NaN Invalid_operation
+ddor878 or -1000 sNaN21 -> NaN Invalid_operation
+ddor879 or 1000 sNaN22 -> NaN Invalid_operation
+ddor880 or Inf sNaN23 -> NaN Invalid_operation
+ddor881 or +NaN25 +sNaN24 -> NaN Invalid_operation
+ddor882 or -NaN26 NaN28 -> NaN Invalid_operation
+ddor883 or -sNaN27 sNaN29 -> NaN Invalid_operation
+ddor884 or 1000 -NaN30 -> NaN Invalid_operation
+ddor885 or 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddPlus.decTest b/Lib/test/decimaltestdata/ddPlus.decTest
index 17aa08af9f..5191239bf7 100644
--- a/Lib/test/decimaltestdata/ddPlus.decTest
+++ b/Lib/test/decimaltestdata/ddPlus.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddPlus.decTest -- decDouble 0+x --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddpls001 plus +7.50 -> 7.50
-
--- Infinities
-ddpls011 plus Infinity -> Infinity
-ddpls012 plus -Infinity -> -Infinity
-
--- NaNs, 0 payload
-ddpls021 plus NaN -> NaN
-ddpls022 plus -NaN -> -NaN
-ddpls023 plus sNaN -> NaN Invalid_operation
-ddpls024 plus -sNaN -> -NaN Invalid_operation
-
--- NaNs, non-0 payload
-ddpls031 plus NaN13 -> NaN13
-ddpls032 plus -NaN13 -> -NaN13
-ddpls033 plus sNaN13 -> NaN13 Invalid_operation
-ddpls034 plus -sNaN13 -> -NaN13 Invalid_operation
-ddpls035 plus NaN70 -> NaN70
-ddpls036 plus -NaN70 -> -NaN70
-ddpls037 plus sNaN101 -> NaN101 Invalid_operation
-ddpls038 plus -sNaN101 -> -NaN101 Invalid_operation
-
--- finites
-ddpls101 plus 7 -> 7
-ddpls102 plus -7 -> -7
-ddpls103 plus 75 -> 75
-ddpls104 plus -75 -> -75
-ddpls105 plus 7.50 -> 7.50
-ddpls106 plus -7.50 -> -7.50
-ddpls107 plus 7.500 -> 7.500
-ddpls108 plus -7.500 -> -7.500
-
--- zeros
-ddpls111 plus 0 -> 0
-ddpls112 plus -0 -> 0
-ddpls113 plus 0E+4 -> 0E+4
-ddpls114 plus -0E+4 -> 0E+4
-ddpls115 plus 0.0000 -> 0.0000
-ddpls116 plus -0.0000 -> 0.0000
-ddpls117 plus 0E-141 -> 0E-141
-ddpls118 plus -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddpls121 plus 2682682682682682 -> 2682682682682682
-ddpls122 plus -2682682682682682 -> -2682682682682682
-ddpls123 plus 1341341341341341 -> 1341341341341341
-ddpls124 plus -1341341341341341 -> -1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddpls131 plus 9.999999999999999E+384 -> 9.999999999999999E+384
-ddpls132 plus 1E-383 -> 1E-383
-ddpls133 plus 1.000000000000000E-383 -> 1.000000000000000E-383
-ddpls134 plus 1E-398 -> 1E-398 Subnormal
-
-ddpls135 plus -1E-398 -> -1E-398 Subnormal
-ddpls136 plus -1.000000000000000E-383 -> -1.000000000000000E-383
-ddpls137 plus -1E-383 -> -1E-383
-ddpls138 plus -9.999999999999999E+384 -> -9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddPlus.decTest -- decDouble 0+x --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddpls001 plus +7.50 -> 7.50
+
+-- Infinities
+ddpls011 plus Infinity -> Infinity
+ddpls012 plus -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+ddpls021 plus NaN -> NaN
+ddpls022 plus -NaN -> -NaN
+ddpls023 plus sNaN -> NaN Invalid_operation
+ddpls024 plus -sNaN -> -NaN Invalid_operation
+
+-- NaNs, non-0 payload
+ddpls031 plus NaN13 -> NaN13
+ddpls032 plus -NaN13 -> -NaN13
+ddpls033 plus sNaN13 -> NaN13 Invalid_operation
+ddpls034 plus -sNaN13 -> -NaN13 Invalid_operation
+ddpls035 plus NaN70 -> NaN70
+ddpls036 plus -NaN70 -> -NaN70
+ddpls037 plus sNaN101 -> NaN101 Invalid_operation
+ddpls038 plus -sNaN101 -> -NaN101 Invalid_operation
+
+-- finites
+ddpls101 plus 7 -> 7
+ddpls102 plus -7 -> -7
+ddpls103 plus 75 -> 75
+ddpls104 plus -75 -> -75
+ddpls105 plus 7.50 -> 7.50
+ddpls106 plus -7.50 -> -7.50
+ddpls107 plus 7.500 -> 7.500
+ddpls108 plus -7.500 -> -7.500
+
+-- zeros
+ddpls111 plus 0 -> 0
+ddpls112 plus -0 -> 0
+ddpls113 plus 0E+4 -> 0E+4
+ddpls114 plus -0E+4 -> 0E+4
+ddpls115 plus 0.0000 -> 0.0000
+ddpls116 plus -0.0000 -> 0.0000
+ddpls117 plus 0E-141 -> 0E-141
+ddpls118 plus -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddpls121 plus 2682682682682682 -> 2682682682682682
+ddpls122 plus -2682682682682682 -> -2682682682682682
+ddpls123 plus 1341341341341341 -> 1341341341341341
+ddpls124 plus -1341341341341341 -> -1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddpls131 plus 9.999999999999999E+384 -> 9.999999999999999E+384
+ddpls132 plus 1E-383 -> 1E-383
+ddpls133 plus 1.000000000000000E-383 -> 1.000000000000000E-383
+ddpls134 plus 1E-398 -> 1E-398 Subnormal
+
+ddpls135 plus -1E-398 -> -1E-398 Subnormal
+ddpls136 plus -1.000000000000000E-383 -> -1.000000000000000E-383
+ddpls137 plus -1E-383 -> -1E-383
+ddpls138 plus -9.999999999999999E+384 -> -9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddQuantize.decTest b/Lib/test/decimaltestdata/ddQuantize.decTest
index 0d19c9dcec..9177620169 100644
--- a/Lib/test/decimaltestdata/ddQuantize.decTest
+++ b/Lib/test/decimaltestdata/ddQuantize.decTest
@@ -1,833 +1,833 @@
-------------------------------------------------------------------------
--- ddQuantize.decTest -- decDouble quantize operation --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Most of the tests here assume a "regular pattern", where the
--- sign and coefficient are +1.
--- 2004.03.15 Underflow for quantize is suppressed
--- 2005.06.08 More extensive tests for 'does not fit'
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddqua001 quantize 0 1e0 -> 0
-ddqua002 quantize 1 1e0 -> 1
-ddqua003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded
-ddqua005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded
-ddqua006 quantize 0.1 1e0 -> 0 Inexact Rounded
-ddqua007 quantize 0.1 1e-1 -> 0.1
-ddqua008 quantize 0.1 1e-2 -> 0.10
-ddqua009 quantize 0.1 1e-3 -> 0.100
-ddqua010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded
-ddqua011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded
-ddqua012 quantize 0.9 1e+0 -> 1 Inexact Rounded
-ddqua013 quantize 0.9 1e-1 -> 0.9
-ddqua014 quantize 0.9 1e-2 -> 0.90
-ddqua015 quantize 0.9 1e-3 -> 0.900
--- negatives
-ddqua021 quantize -0 1e0 -> -0
-ddqua022 quantize -1 1e0 -> -1
-ddqua023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded
-ddqua025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded
-ddqua026 quantize -0.1 1e0 -> -0 Inexact Rounded
-ddqua027 quantize -0.1 1e-1 -> -0.1
-ddqua028 quantize -0.1 1e-2 -> -0.10
-ddqua029 quantize -0.1 1e-3 -> -0.100
-ddqua030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
-ddqua031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
-ddqua032 quantize -0.9 1e+0 -> -1 Inexact Rounded
-ddqua033 quantize -0.9 1e-1 -> -0.9
-ddqua034 quantize -0.9 1e-2 -> -0.90
-ddqua035 quantize -0.9 1e-3 -> -0.900
-ddqua036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded
-ddqua037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded
-ddqua038 quantize -0.5 1e+0 -> -0 Inexact Rounded
-ddqua039 quantize -0.5 1e-1 -> -0.5
-ddqua040 quantize -0.5 1e-2 -> -0.50
-ddqua041 quantize -0.5 1e-3 -> -0.500
-ddqua042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
-ddqua043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
-ddqua044 quantize -0.9 1e+0 -> -1 Inexact Rounded
-ddqua045 quantize -0.9 1e-1 -> -0.9
-ddqua046 quantize -0.9 1e-2 -> -0.90
-ddqua047 quantize -0.9 1e-3 -> -0.900
-
--- examples from Specification
-ddqua060 quantize 2.17 0.001 -> 2.170
-ddqua061 quantize 2.17 0.01 -> 2.17
-ddqua062 quantize 2.17 0.1 -> 2.2 Inexact Rounded
-ddqua063 quantize 2.17 1e+0 -> 2 Inexact Rounded
-ddqua064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded
-ddqua065 quantize -Inf Inf -> -Infinity
-ddqua066 quantize 2 Inf -> NaN Invalid_operation
-ddqua067 quantize -0.1 1 -> -0 Inexact Rounded
-ddqua068 quantize -0 1e+5 -> -0E+5
-ddqua069 quantize +123456789012345.6 1e-2 -> NaN Invalid_operation
-ddqua070 quantize -987654335236450.6 1e-2 -> NaN Invalid_operation
-ddqua071 quantize 217 1e-1 -> 217.0
-ddqua072 quantize 217 1e+0 -> 217
-ddqua073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded
-ddqua074 quantize 217 1e+2 -> 2E+2 Inexact Rounded
-
--- general tests ..
-ddqua089 quantize 12 1e+4 -> 0E+4 Inexact Rounded
-ddqua090 quantize 12 1e+3 -> 0E+3 Inexact Rounded
-ddqua091 quantize 12 1e+2 -> 0E+2 Inexact Rounded
-ddqua092 quantize 12 1e+1 -> 1E+1 Inexact Rounded
-ddqua093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded
-ddqua094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded
-ddqua095 quantize 1.2345 1e-6 -> 1.234500
-ddqua096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded
-ddqua097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded
-ddqua098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded
-ddqua099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded
-ddqua100 quantize 92 1e+2 -> 1E+2 Inexact Rounded
-
-ddqua101 quantize -1 1e0 -> -1
-ddqua102 quantize -1 1e-1 -> -1.0
-ddqua103 quantize -1 1e-2 -> -1.00
-ddqua104 quantize 0 1e0 -> 0
-ddqua105 quantize 0 1e-1 -> 0.0
-ddqua106 quantize 0 1e-2 -> 0.00
-ddqua107 quantize 0.00 1e0 -> 0
-ddqua108 quantize 0 1e+1 -> 0E+1
-ddqua109 quantize 0 1e+2 -> 0E+2
-ddqua110 quantize +1 1e0 -> 1
-ddqua111 quantize +1 1e-1 -> 1.0
-ddqua112 quantize +1 1e-2 -> 1.00
-
-ddqua120 quantize 1.04 1e-3 -> 1.040
-ddqua121 quantize 1.04 1e-2 -> 1.04
-ddqua122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded
-ddqua123 quantize 1.04 1e0 -> 1 Inexact Rounded
-ddqua124 quantize 1.05 1e-3 -> 1.050
-ddqua125 quantize 1.05 1e-2 -> 1.05
-ddqua126 quantize 1.05 1e-1 -> 1.0 Inexact Rounded
-ddqua131 quantize 1.05 1e0 -> 1 Inexact Rounded
-ddqua132 quantize 1.06 1e-3 -> 1.060
-ddqua133 quantize 1.06 1e-2 -> 1.06
-ddqua134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded
-ddqua135 quantize 1.06 1e0 -> 1 Inexact Rounded
-
-ddqua140 quantize -10 1e-2 -> -10.00
-ddqua141 quantize +1 1e-2 -> 1.00
-ddqua142 quantize +10 1e-2 -> 10.00
-ddqua143 quantize 1E+17 1e-2 -> NaN Invalid_operation
-ddqua144 quantize 1E-17 1e-2 -> 0.00 Inexact Rounded
-ddqua145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded
-ddqua146 quantize 1E-2 1e-2 -> 0.01
-ddqua147 quantize 1E-1 1e-2 -> 0.10
-ddqua148 quantize 0E-17 1e-2 -> 0.00
-
-ddqua150 quantize 1.0600 1e-5 -> 1.06000
-ddqua151 quantize 1.0600 1e-4 -> 1.0600
-ddqua152 quantize 1.0600 1e-3 -> 1.060 Rounded
-ddqua153 quantize 1.0600 1e-2 -> 1.06 Rounded
-ddqua154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded
-ddqua155 quantize 1.0600 1e0 -> 1 Inexact Rounded
-
--- a couple where rounding was different in base tests
-rounding: half_up
-ddqua157 quantize -0.5 1e+0 -> -1 Inexact Rounded
-ddqua158 quantize 1.05 1e-1 -> 1.1 Inexact Rounded
-ddqua159 quantize 1.06 1e0 -> 1 Inexact Rounded
-rounding: half_even
-
--- base tests with non-1 coefficients
-ddqua161 quantize 0 -9e0 -> 0
-ddqua162 quantize 1 -7e0 -> 1
-ddqua163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded
-ddqua165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded
-ddqua166 quantize 0.1 2e0 -> 0 Inexact Rounded
-ddqua167 quantize 0.1 3e-1 -> 0.1
-ddqua168 quantize 0.1 44e-2 -> 0.10
-ddqua169 quantize 0.1 555e-3 -> 0.100
-ddqua170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded
-ddqua171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded
-ddqua172 quantize 0.9 -88e+0 -> 1 Inexact Rounded
-ddqua173 quantize 0.9 -9e-1 -> 0.9
-ddqua174 quantize 0.9 0e-2 -> 0.90
-ddqua175 quantize 0.9 1.1e-3 -> 0.9000
--- negatives
-ddqua181 quantize -0 1.1e0 -> -0.0
-ddqua182 quantize -1 -1e0 -> -1
-ddqua183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded
-ddqua185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded
-ddqua186 quantize -0.1 71e0 -> -0 Inexact Rounded
-ddqua187 quantize -0.1 -91e-1 -> -0.1
-ddqua188 quantize -0.1 -.1e-2 -> -0.100
-ddqua189 quantize -0.1 -1e-3 -> -0.100
-ddqua190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded
-ddqua191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded
-ddqua192 quantize -0.9 -10e+0 -> -1 Inexact Rounded
-ddqua193 quantize -0.9 100e-1 -> -0.9
-ddqua194 quantize -0.9 999e-2 -> -0.90
-
--- +ve exponents ..
-ddqua201 quantize -1 1e+0 -> -1
-ddqua202 quantize -1 1e+1 -> -0E+1 Inexact Rounded
-ddqua203 quantize -1 1e+2 -> -0E+2 Inexact Rounded
-ddqua204 quantize 0 1e+0 -> 0
-ddqua205 quantize 0 1e+1 -> 0E+1
-ddqua206 quantize 0 1e+2 -> 0E+2
-ddqua207 quantize +1 1e+0 -> 1
-ddqua208 quantize +1 1e+1 -> 0E+1 Inexact Rounded
-ddqua209 quantize +1 1e+2 -> 0E+2 Inexact Rounded
-
-ddqua220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded
-ddqua221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded
-ddqua222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded
-ddqua223 quantize 1.04 1e+0 -> 1 Inexact Rounded
-ddqua224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
-ddqua225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
-ddqua226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
-ddqua227 quantize 1.05 1e+0 -> 1 Inexact Rounded
-ddqua228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
-ddqua229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
-ddqua230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
-ddqua231 quantize 1.05 1e+0 -> 1 Inexact Rounded
-ddqua232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded
-ddqua233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded
-ddqua234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded
-ddqua235 quantize 1.06 1e+0 -> 1 Inexact Rounded
-
-ddqua240 quantize -10 1e+1 -> -1E+1 Rounded
-ddqua241 quantize +1 1e+1 -> 0E+1 Inexact Rounded
-ddqua242 quantize +10 1e+1 -> 1E+1 Rounded
-ddqua243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1
-ddqua244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1
-ddqua245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1
-ddqua246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1
-ddqua247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1
-ddqua248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1
-ddqua249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1
-ddqua250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1
-ddqua251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1
--- next one tries to add 9 zeros
-ddqua252 quantize 1E+17 1e+1 -> NaN Invalid_operation
-ddqua253 quantize 1E-17 1e+1 -> 0E+1 Inexact Rounded
-ddqua254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded
-ddqua255 quantize 0E-17 1e+1 -> 0E+1
-ddqua256 quantize -0E-17 1e+1 -> -0E+1
-ddqua257 quantize -0E-1 1e+1 -> -0E+1
-ddqua258 quantize -0 1e+1 -> -0E+1
-ddqua259 quantize -0E+1 1e+1 -> -0E+1
-
-ddqua260 quantize -10 1e+2 -> -0E+2 Inexact Rounded
-ddqua261 quantize +1 1e+2 -> 0E+2 Inexact Rounded
-ddqua262 quantize +10 1e+2 -> 0E+2 Inexact Rounded
-ddqua263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded
-ddqua264 quantize 1E+2 1e+2 -> 1E+2
-ddqua265 quantize 1E+3 1e+2 -> 1.0E+3
-ddqua266 quantize 1E+4 1e+2 -> 1.00E+4
-ddqua267 quantize 1E+5 1e+2 -> 1.000E+5
-ddqua268 quantize 1E+6 1e+2 -> 1.0000E+6
-ddqua269 quantize 1E+7 1e+2 -> 1.00000E+7
-ddqua270 quantize 1E+8 1e+2 -> 1.000000E+8
-ddqua271 quantize 1E+9 1e+2 -> 1.0000000E+9
-ddqua272 quantize 1E+10 1e+2 -> 1.00000000E+10
-ddqua273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded
-ddqua274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded
-ddqua275 quantize 0E-10 1e+2 -> 0E+2
-
-ddqua280 quantize -10 1e+3 -> -0E+3 Inexact Rounded
-ddqua281 quantize +1 1e+3 -> 0E+3 Inexact Rounded
-ddqua282 quantize +10 1e+3 -> 0E+3 Inexact Rounded
-ddqua283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded
-ddqua284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded
-ddqua285 quantize 1E+3 1e+3 -> 1E+3
-ddqua286 quantize 1E+4 1e+3 -> 1.0E+4
-ddqua287 quantize 1E+5 1e+3 -> 1.00E+5
-ddqua288 quantize 1E+6 1e+3 -> 1.000E+6
-ddqua289 quantize 1E+7 1e+3 -> 1.0000E+7
-ddqua290 quantize 1E+8 1e+3 -> 1.00000E+8
-ddqua291 quantize 1E+9 1e+3 -> 1.000000E+9
-ddqua292 quantize 1E+10 1e+3 -> 1.0000000E+10
-ddqua293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded
-ddqua294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded
-ddqua295 quantize 0E-10 1e+3 -> 0E+3
-
--- round up from below [sign wrong in JIT compiler once]
-ddqua300 quantize 0.0078 1e-5 -> 0.00780
-ddqua301 quantize 0.0078 1e-4 -> 0.0078
-ddqua302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded
-ddqua303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded
-ddqua304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded
-ddqua305 quantize 0.0078 1e0 -> 0 Inexact Rounded
-ddqua306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded
-ddqua307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded
-
-ddqua310 quantize -0.0078 1e-5 -> -0.00780
-ddqua311 quantize -0.0078 1e-4 -> -0.0078
-ddqua312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded
-ddqua313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded
-ddqua314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded
-ddqua315 quantize -0.0078 1e0 -> -0 Inexact Rounded
-ddqua316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded
-ddqua317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded
-
-ddqua320 quantize 0.078 1e-5 -> 0.07800
-ddqua321 quantize 0.078 1e-4 -> 0.0780
-ddqua322 quantize 0.078 1e-3 -> 0.078
-ddqua323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded
-ddqua324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded
-ddqua325 quantize 0.078 1e0 -> 0 Inexact Rounded
-ddqua326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded
-ddqua327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded
-
-ddqua330 quantize -0.078 1e-5 -> -0.07800
-ddqua331 quantize -0.078 1e-4 -> -0.0780
-ddqua332 quantize -0.078 1e-3 -> -0.078
-ddqua333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded
-ddqua334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded
-ddqua335 quantize -0.078 1e0 -> -0 Inexact Rounded
-ddqua336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded
-ddqua337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded
-
-ddqua340 quantize 0.78 1e-5 -> 0.78000
-ddqua341 quantize 0.78 1e-4 -> 0.7800
-ddqua342 quantize 0.78 1e-3 -> 0.780
-ddqua343 quantize 0.78 1e-2 -> 0.78
-ddqua344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded
-ddqua345 quantize 0.78 1e0 -> 1 Inexact Rounded
-ddqua346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded
-ddqua347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded
-
-ddqua350 quantize -0.78 1e-5 -> -0.78000
-ddqua351 quantize -0.78 1e-4 -> -0.7800
-ddqua352 quantize -0.78 1e-3 -> -0.780
-ddqua353 quantize -0.78 1e-2 -> -0.78
-ddqua354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded
-ddqua355 quantize -0.78 1e0 -> -1 Inexact Rounded
-ddqua356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded
-ddqua357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded
-
-ddqua360 quantize 7.8 1e-5 -> 7.80000
-ddqua361 quantize 7.8 1e-4 -> 7.8000
-ddqua362 quantize 7.8 1e-3 -> 7.800
-ddqua363 quantize 7.8 1e-2 -> 7.80
-ddqua364 quantize 7.8 1e-1 -> 7.8
-ddqua365 quantize 7.8 1e0 -> 8 Inexact Rounded
-ddqua366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded
-ddqua367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded
-ddqua368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded
-
-ddqua370 quantize -7.8 1e-5 -> -7.80000
-ddqua371 quantize -7.8 1e-4 -> -7.8000
-ddqua372 quantize -7.8 1e-3 -> -7.800
-ddqua373 quantize -7.8 1e-2 -> -7.80
-ddqua374 quantize -7.8 1e-1 -> -7.8
-ddqua375 quantize -7.8 1e0 -> -8 Inexact Rounded
-ddqua376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded
-ddqua377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded
-ddqua378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded
-
--- some individuals
-ddqua380 quantize 1234567352364.506 1e-2 -> 1234567352364.51 Inexact Rounded
-ddqua381 quantize 12345673523645.06 1e-2 -> 12345673523645.06
-ddqua382 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
-ddqua383 quantize 1234567352364506 1e-2 -> NaN Invalid_operation
-ddqua384 quantize -1234567352364.506 1e-2 -> -1234567352364.51 Inexact Rounded
-ddqua385 quantize -12345673523645.06 1e-2 -> -12345673523645.06
-ddqua386 quantize -123456735236450.6 1e-2 -> NaN Invalid_operation
-ddqua387 quantize -1234567352364506 1e-2 -> NaN Invalid_operation
-
-rounding: down
-ddqua389 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
--- ? should that one instead have been:
--- ddqua389 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
-rounding: half_up
-
--- and a few more from e-mail discussions
-ddqua391 quantize 12345678912.34567 1e-3 -> 12345678912.346 Inexact Rounded
-ddqua392 quantize 123456789123.4567 1e-3 -> 123456789123.457 Inexact Rounded
-ddqua393 quantize 1234567891234.567 1e-3 -> 1234567891234.567
-ddqua394 quantize 12345678912345.67 1e-3 -> NaN Invalid_operation
-ddqua395 quantize 123456789123456.7 1e-3 -> NaN Invalid_operation
-ddqua396 quantize 1234567891234567. 1e-3 -> NaN Invalid_operation
-
--- some 9999 round-up cases
-ddqua400 quantize 9.999 1e-5 -> 9.99900
-ddqua401 quantize 9.999 1e-4 -> 9.9990
-ddqua402 quantize 9.999 1e-3 -> 9.999
-ddqua403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded
-ddqua404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded
-ddqua405 quantize 9.999 1e0 -> 10 Inexact Rounded
-ddqua406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded
-ddqua407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded
-
-ddqua410 quantize 0.999 1e-5 -> 0.99900
-ddqua411 quantize 0.999 1e-4 -> 0.9990
-ddqua412 quantize 0.999 1e-3 -> 0.999
-ddqua413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded
-ddqua414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded
-ddqua415 quantize 0.999 1e0 -> 1 Inexact Rounded
-ddqua416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded
-
-ddqua420 quantize 0.0999 1e-5 -> 0.09990
-ddqua421 quantize 0.0999 1e-4 -> 0.0999
-ddqua422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded
-ddqua423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded
-ddqua424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded
-ddqua425 quantize 0.0999 1e0 -> 0 Inexact Rounded
-ddqua426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded
-
-ddqua430 quantize 0.00999 1e-5 -> 0.00999
-ddqua431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded
-ddqua432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded
-ddqua433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded
-ddqua434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded
-ddqua435 quantize 0.00999 1e0 -> 0 Inexact Rounded
-ddqua436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded
-
-ddqua440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded
-ddqua441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded
-ddqua442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded
-ddqua443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded
-ddqua444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded
-ddqua445 quantize 0.000999 1e0 -> 0 Inexact Rounded
-ddqua446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded
-
-ddqua1001 quantize 0.000 0.001 -> 0.000
-ddqua1002 quantize 0.001 0.001 -> 0.001
-ddqua1003 quantize 0.0012 0.001 -> 0.001 Inexact Rounded
-ddqua1004 quantize 0.0018 0.001 -> 0.002 Inexact Rounded
-ddqua1005 quantize 0.501 0.001 -> 0.501
-ddqua1006 quantize 0.5012 0.001 -> 0.501 Inexact Rounded
-ddqua1007 quantize 0.5018 0.001 -> 0.502 Inexact Rounded
-ddqua1008 quantize 0.999 0.001 -> 0.999
-
-ddqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
-ddqua482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
-ddqua483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
-ddqua484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
-ddqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
-ddqua486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
--- a potential double-round
-ddqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
-ddqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
-
-ddqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
-ddqua492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
-ddqua493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
-ddqua494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
-ddqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
-ddqua496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
-ddqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
-ddqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
-
--- Zeros
-ddqua500 quantize 0 1e1 -> 0E+1
-ddqua501 quantize 0 1e0 -> 0
-ddqua502 quantize 0 1e-1 -> 0.0
-ddqua503 quantize 0.0 1e-1 -> 0.0
-ddqua504 quantize 0.0 1e0 -> 0
-ddqua505 quantize 0.0 1e+1 -> 0E+1
-ddqua506 quantize 0E+1 1e-1 -> 0.0
-ddqua507 quantize 0E+1 1e0 -> 0
-ddqua508 quantize 0E+1 1e+1 -> 0E+1
-ddqua509 quantize -0 1e1 -> -0E+1
-ddqua510 quantize -0 1e0 -> -0
-ddqua511 quantize -0 1e-1 -> -0.0
-ddqua512 quantize -0.0 1e-1 -> -0.0
-ddqua513 quantize -0.0 1e0 -> -0
-ddqua514 quantize -0.0 1e+1 -> -0E+1
-ddqua515 quantize -0E+1 1e-1 -> -0.0
-ddqua516 quantize -0E+1 1e0 -> -0
-ddqua517 quantize -0E+1 1e+1 -> -0E+1
-
--- Suspicious RHS values
-ddqua520 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
-ddqua521 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
-ddqua522 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
-ddqua523 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
--- next four are "won't fit" overfl
-ddqua526 quantize 1.234 1e-299 -> NaN Invalid_operation
-ddqua527 quantize 123.456 1e-299 -> NaN Invalid_operation
-ddqua528 quantize 1.234 1e-299 -> NaN Invalid_operation
-ddqua529 quantize 123.456 1e-299 -> NaN Invalid_operation
-
-ddqua532 quantize 1.234E+299 1e299 -> 1E+299 Inexact Rounded
-ddqua533 quantize 1.234E+298 1e299 -> 0E+299 Inexact Rounded
-ddqua534 quantize 1.234 1e299 -> 0E+299 Inexact Rounded
-ddqua537 quantize 0 1e-299 -> 0E-299
--- next two are "won't fit" overflows
-ddqua538 quantize 1.234 1e-299 -> NaN Invalid_operation
-ddqua539 quantize 1.234 1e-300 -> NaN Invalid_operation
--- [more below]
-
--- Specials
-ddqua580 quantize Inf -Inf -> Infinity
-ddqua581 quantize Inf 1e-299 -> NaN Invalid_operation
-ddqua582 quantize Inf 1e-1 -> NaN Invalid_operation
-ddqua583 quantize Inf 1e0 -> NaN Invalid_operation
-ddqua584 quantize Inf 1e1 -> NaN Invalid_operation
-ddqua585 quantize Inf 1e299 -> NaN Invalid_operation
-ddqua586 quantize Inf Inf -> Infinity
-ddqua587 quantize -1000 Inf -> NaN Invalid_operation
-ddqua588 quantize -Inf Inf -> -Infinity
-ddqua589 quantize -1 Inf -> NaN Invalid_operation
-ddqua590 quantize 0 Inf -> NaN Invalid_operation
-ddqua591 quantize 1 Inf -> NaN Invalid_operation
-ddqua592 quantize 1000 Inf -> NaN Invalid_operation
-ddqua593 quantize Inf Inf -> Infinity
-ddqua594 quantize Inf 1e-0 -> NaN Invalid_operation
-ddqua595 quantize -0 Inf -> NaN Invalid_operation
-
-ddqua600 quantize -Inf -Inf -> -Infinity
-ddqua601 quantize -Inf 1e-299 -> NaN Invalid_operation
-ddqua602 quantize -Inf 1e-1 -> NaN Invalid_operation
-ddqua603 quantize -Inf 1e0 -> NaN Invalid_operation
-ddqua604 quantize -Inf 1e1 -> NaN Invalid_operation
-ddqua605 quantize -Inf 1e299 -> NaN Invalid_operation
-ddqua606 quantize -Inf Inf -> -Infinity
-ddqua607 quantize -1000 Inf -> NaN Invalid_operation
-ddqua608 quantize -Inf -Inf -> -Infinity
-ddqua609 quantize -1 -Inf -> NaN Invalid_operation
-ddqua610 quantize 0 -Inf -> NaN Invalid_operation
-ddqua611 quantize 1 -Inf -> NaN Invalid_operation
-ddqua612 quantize 1000 -Inf -> NaN Invalid_operation
-ddqua613 quantize Inf -Inf -> Infinity
-ddqua614 quantize -Inf 1e-0 -> NaN Invalid_operation
-ddqua615 quantize -0 -Inf -> NaN Invalid_operation
-
-ddqua621 quantize NaN -Inf -> NaN
-ddqua622 quantize NaN 1e-299 -> NaN
-ddqua623 quantize NaN 1e-1 -> NaN
-ddqua624 quantize NaN 1e0 -> NaN
-ddqua625 quantize NaN 1e1 -> NaN
-ddqua626 quantize NaN 1e299 -> NaN
-ddqua627 quantize NaN Inf -> NaN
-ddqua628 quantize NaN NaN -> NaN
-ddqua629 quantize -Inf NaN -> NaN
-ddqua630 quantize -1000 NaN -> NaN
-ddqua631 quantize -1 NaN -> NaN
-ddqua632 quantize 0 NaN -> NaN
-ddqua633 quantize 1 NaN -> NaN
-ddqua634 quantize 1000 NaN -> NaN
-ddqua635 quantize Inf NaN -> NaN
-ddqua636 quantize NaN 1e-0 -> NaN
-ddqua637 quantize -0 NaN -> NaN
-
-ddqua641 quantize sNaN -Inf -> NaN Invalid_operation
-ddqua642 quantize sNaN 1e-299 -> NaN Invalid_operation
-ddqua643 quantize sNaN 1e-1 -> NaN Invalid_operation
-ddqua644 quantize sNaN 1e0 -> NaN Invalid_operation
-ddqua645 quantize sNaN 1e1 -> NaN Invalid_operation
-ddqua646 quantize sNaN 1e299 -> NaN Invalid_operation
-ddqua647 quantize sNaN NaN -> NaN Invalid_operation
-ddqua648 quantize sNaN sNaN -> NaN Invalid_operation
-ddqua649 quantize NaN sNaN -> NaN Invalid_operation
-ddqua650 quantize -Inf sNaN -> NaN Invalid_operation
-ddqua651 quantize -1000 sNaN -> NaN Invalid_operation
-ddqua652 quantize -1 sNaN -> NaN Invalid_operation
-ddqua653 quantize 0 sNaN -> NaN Invalid_operation
-ddqua654 quantize 1 sNaN -> NaN Invalid_operation
-ddqua655 quantize 1000 sNaN -> NaN Invalid_operation
-ddqua656 quantize Inf sNaN -> NaN Invalid_operation
-ddqua657 quantize NaN sNaN -> NaN Invalid_operation
-ddqua658 quantize sNaN 1e-0 -> NaN Invalid_operation
-ddqua659 quantize -0 sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddqua661 quantize NaN9 -Inf -> NaN9
-ddqua662 quantize NaN8 919 -> NaN8
-ddqua663 quantize NaN71 Inf -> NaN71
-ddqua664 quantize NaN6 NaN5 -> NaN6
-ddqua665 quantize -Inf NaN4 -> NaN4
-ddqua666 quantize -919 NaN31 -> NaN31
-ddqua667 quantize Inf NaN2 -> NaN2
-
-ddqua671 quantize sNaN99 -Inf -> NaN99 Invalid_operation
-ddqua672 quantize sNaN98 -11 -> NaN98 Invalid_operation
-ddqua673 quantize sNaN97 NaN -> NaN97 Invalid_operation
-ddqua674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation
-ddqua675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation
-ddqua676 quantize -Inf sNaN92 -> NaN92 Invalid_operation
-ddqua677 quantize 088 sNaN91 -> NaN91 Invalid_operation
-ddqua678 quantize Inf sNaN90 -> NaN90 Invalid_operation
-ddqua679 quantize NaN sNaN88 -> NaN88 Invalid_operation
-
-ddqua681 quantize -NaN9 -Inf -> -NaN9
-ddqua682 quantize -NaN8 919 -> -NaN8
-ddqua683 quantize -NaN71 Inf -> -NaN71
-ddqua684 quantize -NaN6 -NaN5 -> -NaN6
-ddqua685 quantize -Inf -NaN4 -> -NaN4
-ddqua686 quantize -919 -NaN31 -> -NaN31
-ddqua687 quantize Inf -NaN2 -> -NaN2
-
-ddqua691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation
-ddqua692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation
-ddqua693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation
-ddqua694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation
-ddqua695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-ddqua696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation
-ddqua697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation
-ddqua698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation
-ddqua699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation
-
--- subnormals and underflow
-ddqua710 quantize 1.00E-383 1e-383 -> 1E-383 Rounded
-ddqua711 quantize 0.1E-383 2e-384 -> 1E-384 Subnormal
-ddqua712 quantize 0.10E-383 3e-384 -> 1E-384 Subnormal Rounded
-ddqua713 quantize 0.100E-383 4e-384 -> 1E-384 Subnormal Rounded
-ddqua714 quantize 0.01E-383 5e-385 -> 1E-385 Subnormal
--- next is rounded to Emin
-ddqua715 quantize 0.999E-383 1e-383 -> 1E-383 Inexact Rounded
-ddqua716 quantize 0.099E-383 10e-384 -> 1E-384 Inexact Rounded Subnormal
-
-ddqua717 quantize 0.009E-383 1e-385 -> 1E-385 Inexact Rounded Subnormal
-ddqua718 quantize 0.001E-383 1e-385 -> 0E-385 Inexact Rounded
-ddqua719 quantize 0.0009E-383 1e-385 -> 0E-385 Inexact Rounded
-ddqua720 quantize 0.0001E-383 1e-385 -> 0E-385 Inexact Rounded
-
-ddqua730 quantize -1.00E-383 1e-383 -> -1E-383 Rounded
-ddqua731 quantize -0.1E-383 1e-383 -> -0E-383 Rounded Inexact
-ddqua732 quantize -0.10E-383 1e-383 -> -0E-383 Rounded Inexact
-ddqua733 quantize -0.100E-383 1e-383 -> -0E-383 Rounded Inexact
-ddqua734 quantize -0.01E-383 1e-383 -> -0E-383 Inexact Rounded
--- next is rounded to Emin
-ddqua735 quantize -0.999E-383 90e-383 -> -1E-383 Inexact Rounded
-ddqua736 quantize -0.099E-383 -1e-383 -> -0E-383 Inexact Rounded
-ddqua737 quantize -0.009E-383 -1e-383 -> -0E-383 Inexact Rounded
-ddqua738 quantize -0.001E-383 -0e-383 -> -0E-383 Inexact Rounded
-ddqua739 quantize -0.0001E-383 0e-383 -> -0E-383 Inexact Rounded
-
-ddqua740 quantize -1.00E-383 1e-384 -> -1.0E-383 Rounded
-ddqua741 quantize -0.1E-383 1e-384 -> -1E-384 Subnormal
-ddqua742 quantize -0.10E-383 1e-384 -> -1E-384 Subnormal Rounded
-ddqua743 quantize -0.100E-383 1e-384 -> -1E-384 Subnormal Rounded
-ddqua744 quantize -0.01E-383 1e-384 -> -0E-384 Inexact Rounded
--- next is rounded to Emin
-ddqua745 quantize -0.999E-383 1e-384 -> -1.0E-383 Inexact Rounded
-ddqua746 quantize -0.099E-383 1e-384 -> -1E-384 Inexact Rounded Subnormal
-ddqua747 quantize -0.009E-383 1e-384 -> -0E-384 Inexact Rounded
-ddqua748 quantize -0.001E-383 1e-384 -> -0E-384 Inexact Rounded
-ddqua749 quantize -0.0001E-383 1e-384 -> -0E-384 Inexact Rounded
-
-ddqua750 quantize -1.00E-383 1e-385 -> -1.00E-383
-ddqua751 quantize -0.1E-383 1e-385 -> -1.0E-384 Subnormal
-ddqua752 quantize -0.10E-383 1e-385 -> -1.0E-384 Subnormal
-ddqua753 quantize -0.100E-383 1e-385 -> -1.0E-384 Subnormal Rounded
-ddqua754 quantize -0.01E-383 1e-385 -> -1E-385 Subnormal
--- next is rounded to Emin
-ddqua755 quantize -0.999E-383 1e-385 -> -1.00E-383 Inexact Rounded
-ddqua756 quantize -0.099E-383 1e-385 -> -1.0E-384 Inexact Rounded Subnormal
-ddqua757 quantize -0.009E-383 1e-385 -> -1E-385 Inexact Rounded Subnormal
-ddqua758 quantize -0.001E-383 1e-385 -> -0E-385 Inexact Rounded
-ddqua759 quantize -0.0001E-383 1e-385 -> -0E-385 Inexact Rounded
-
-ddqua760 quantize -1.00E-383 1e-386 -> -1.000E-383
-ddqua761 quantize -0.1E-383 1e-386 -> -1.00E-384 Subnormal
-ddqua762 quantize -0.10E-383 1e-386 -> -1.00E-384 Subnormal
-ddqua763 quantize -0.100E-383 1e-386 -> -1.00E-384 Subnormal
-ddqua764 quantize -0.01E-383 1e-386 -> -1.0E-385 Subnormal
-ddqua765 quantize -0.999E-383 1e-386 -> -9.99E-384 Subnormal
-ddqua766 quantize -0.099E-383 1e-386 -> -9.9E-385 Subnormal
-ddqua767 quantize -0.009E-383 1e-386 -> -9E-386 Subnormal
-ddqua768 quantize -0.001E-383 1e-386 -> -1E-386 Subnormal
-ddqua769 quantize -0.0001E-383 1e-386 -> -0E-386 Inexact Rounded
-
--- More from Fung Lee
-ddqua1021 quantize 8.666666666666000E+384 1.000000000000000E+384 -> 8.666666666666000E+384
-ddqua1022 quantize -8.666666666666000E+384 1.000000000000000E+384 -> -8.666666666666000E+384
-ddqua1027 quantize 8.666666666666000E+323 1E+31 -> NaN Invalid_operation
-ddqua1029 quantize 8.66666666E+3 1E+3 -> 9E+3 Inexact Rounded
-
-
---ddqua1030 quantize 8.666666666666000E+384 1E+384 -> 9.000000000000000E+384 Rounded Inexact
---ddqua1031 quantize 8.666666666666000E+384 1E+384 -> 8.666666666666000E+384 Rounded
---ddqua1032 quantize 8.666666666666000E+384 1E+383 -> 8.666666666666000E+384 Rounded
---ddqua1033 quantize 8.666666666666000E+384 1E+382 -> 8.666666666666000E+384 Rounded
---ddqua1034 quantize 8.666666666666000E+384 1E+381 -> 8.666666666666000E+384 Rounded
---ddqua1035 quantize 8.666666666666000E+384 1E+380 -> 8.666666666666000E+384 Rounded
-
--- Int and uInt32 edge values for testing conversions
-ddqua1040 quantize -2147483646 0 -> -2147483646
-ddqua1041 quantize -2147483647 0 -> -2147483647
-ddqua1042 quantize -2147483648 0 -> -2147483648
-ddqua1043 quantize -2147483649 0 -> -2147483649
-ddqua1044 quantize 2147483646 0 -> 2147483646
-ddqua1045 quantize 2147483647 0 -> 2147483647
-ddqua1046 quantize 2147483648 0 -> 2147483648
-ddqua1047 quantize 2147483649 0 -> 2147483649
-ddqua1048 quantize 4294967294 0 -> 4294967294
-ddqua1049 quantize 4294967295 0 -> 4294967295
-ddqua1050 quantize 4294967296 0 -> 4294967296
-ddqua1051 quantize 4294967297 0 -> 4294967297
-
--- Rounding swathe
-rounding: half_even
-ddqua1100 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1101 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1102 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1103 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-ddqua1104 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1105 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua1106 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1107 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1108 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1109 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: half_up
-ddqua1200 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1201 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1202 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1203 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-ddqua1204 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1205 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-ddqua1206 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1207 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1208 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1209 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: half_down
-ddqua1300 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1301 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1302 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1303 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-ddqua1304 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1305 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua1306 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1307 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1308 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1309 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: up
-ddqua1400 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1401 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
-ddqua1402 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
-ddqua1403 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-ddqua1404 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1405 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-ddqua1406 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1407 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1408 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1409 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-ddqua1411 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
-
-rounding: down
-ddqua1500 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1501 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1502 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1503 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-ddqua1504 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
-ddqua1505 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua1506 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-ddqua1507 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
-ddqua1508 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
-ddqua1509 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
-ddqua1511 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
-
-rounding: ceiling
-ddqua1600 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1601 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
-ddqua1602 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
-ddqua1603 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-ddqua1604 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1605 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-ddqua1606 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1607 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1608 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1609 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-ddqua1611 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
-
-rounding: floor
-ddqua1700 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1701 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1702 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1703 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-ddqua1704 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
-ddqua1705 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua1706 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-ddqua1707 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
-ddqua1708 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
-ddqua1709 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
-ddqua1711 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
-
-rounding: 05up
-ddqua1800 quantize 1.2000 1.00 -> 1.20 Rounded
-ddqua1801 quantize 1.2001 1.00 -> 1.21 Inexact Rounded
-ddqua1802 quantize 1.2010 1.00 -> 1.21 Inexact Rounded
-ddqua1803 quantize 1.2050 1.00 -> 1.21 Inexact Rounded
-ddqua1804 quantize 1.2051 1.00 -> 1.21 Inexact Rounded
-ddqua1807 quantize 1.2060 1.00 -> 1.21 Inexact Rounded
-ddqua1808 quantize 1.2070 1.00 -> 1.21 Inexact Rounded
-ddqua1809 quantize 1.2099 1.00 -> 1.21 Inexact Rounded
-ddqua1811 quantize -1.2099 1.00 -> -1.21 Inexact Rounded
-
-ddqua1900 quantize 1.2100 1.00 -> 1.21 Rounded
-ddqua1901 quantize 1.2101 1.00 -> 1.21 Inexact Rounded
-ddqua1902 quantize 1.2110 1.00 -> 1.21 Inexact Rounded
-ddqua1903 quantize 1.2150 1.00 -> 1.21 Inexact Rounded
-ddqua1904 quantize 1.2151 1.00 -> 1.21 Inexact Rounded
-ddqua1907 quantize 1.2160 1.00 -> 1.21 Inexact Rounded
-ddqua1908 quantize 1.2170 1.00 -> 1.21 Inexact Rounded
-ddqua1909 quantize 1.2199 1.00 -> 1.21 Inexact Rounded
-ddqua1911 quantize -1.2199 1.00 -> -1.21 Inexact Rounded
-
-ddqua2000 quantize 1.2400 1.00 -> 1.24 Rounded
-ddqua2001 quantize 1.2401 1.00 -> 1.24 Inexact Rounded
-ddqua2002 quantize 1.2410 1.00 -> 1.24 Inexact Rounded
-ddqua2003 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua2004 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-ddqua2007 quantize 1.2460 1.00 -> 1.24 Inexact Rounded
-ddqua2008 quantize 1.2470 1.00 -> 1.24 Inexact Rounded
-ddqua2009 quantize 1.2499 1.00 -> 1.24 Inexact Rounded
-ddqua2011 quantize -1.2499 1.00 -> -1.24 Inexact Rounded
-
-ddqua2100 quantize 1.2500 1.00 -> 1.25 Rounded
-ddqua2101 quantize 1.2501 1.00 -> 1.26 Inexact Rounded
-ddqua2102 quantize 1.2510 1.00 -> 1.26 Inexact Rounded
-ddqua2103 quantize 1.2550 1.00 -> 1.26 Inexact Rounded
-ddqua2104 quantize 1.2551 1.00 -> 1.26 Inexact Rounded
-ddqua2107 quantize 1.2560 1.00 -> 1.26 Inexact Rounded
-ddqua2108 quantize 1.2570 1.00 -> 1.26 Inexact Rounded
-ddqua2109 quantize 1.2599 1.00 -> 1.26 Inexact Rounded
-ddqua2111 quantize -1.2599 1.00 -> -1.26 Inexact Rounded
-
-ddqua2200 quantize 1.2600 1.00 -> 1.26 Rounded
-ddqua2201 quantize 1.2601 1.00 -> 1.26 Inexact Rounded
-ddqua2202 quantize 1.2610 1.00 -> 1.26 Inexact Rounded
-ddqua2203 quantize 1.2650 1.00 -> 1.26 Inexact Rounded
-ddqua2204 quantize 1.2651 1.00 -> 1.26 Inexact Rounded
-ddqua2207 quantize 1.2660 1.00 -> 1.26 Inexact Rounded
-ddqua2208 quantize 1.2670 1.00 -> 1.26 Inexact Rounded
-ddqua2209 quantize 1.2699 1.00 -> 1.26 Inexact Rounded
-ddqua2211 quantize -1.2699 1.00 -> -1.26 Inexact Rounded
-
-ddqua2300 quantize 1.2900 1.00 -> 1.29 Rounded
-ddqua2301 quantize 1.2901 1.00 -> 1.29 Inexact Rounded
-ddqua2302 quantize 1.2910 1.00 -> 1.29 Inexact Rounded
-ddqua2303 quantize 1.2950 1.00 -> 1.29 Inexact Rounded
-ddqua2304 quantize 1.2951 1.00 -> 1.29 Inexact Rounded
-ddqua2307 quantize 1.2960 1.00 -> 1.29 Inexact Rounded
-ddqua2308 quantize 1.2970 1.00 -> 1.29 Inexact Rounded
-ddqua2309 quantize 1.2999 1.00 -> 1.29 Inexact Rounded
-ddqua2311 quantize -1.2999 1.00 -> -1.29 Inexact Rounded
-
--- Null tests
-rounding: half_even
-ddqua998 quantize 10 # -> NaN Invalid_operation
-ddqua999 quantize # 1e10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddQuantize.decTest -- decDouble quantize operation --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Most of the tests here assume a "regular pattern", where the
+-- sign and coefficient are +1.
+-- 2004.03.15 Underflow for quantize is suppressed
+-- 2005.06.08 More extensive tests for 'does not fit'
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddqua001 quantize 0 1e0 -> 0
+ddqua002 quantize 1 1e0 -> 1
+ddqua003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded
+ddqua005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded
+ddqua006 quantize 0.1 1e0 -> 0 Inexact Rounded
+ddqua007 quantize 0.1 1e-1 -> 0.1
+ddqua008 quantize 0.1 1e-2 -> 0.10
+ddqua009 quantize 0.1 1e-3 -> 0.100
+ddqua010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded
+ddqua011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded
+ddqua012 quantize 0.9 1e+0 -> 1 Inexact Rounded
+ddqua013 quantize 0.9 1e-1 -> 0.9
+ddqua014 quantize 0.9 1e-2 -> 0.90
+ddqua015 quantize 0.9 1e-3 -> 0.900
+-- negatives
+ddqua021 quantize -0 1e0 -> -0
+ddqua022 quantize -1 1e0 -> -1
+ddqua023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded
+ddqua025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded
+ddqua026 quantize -0.1 1e0 -> -0 Inexact Rounded
+ddqua027 quantize -0.1 1e-1 -> -0.1
+ddqua028 quantize -0.1 1e-2 -> -0.10
+ddqua029 quantize -0.1 1e-3 -> -0.100
+ddqua030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
+ddqua031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
+ddqua032 quantize -0.9 1e+0 -> -1 Inexact Rounded
+ddqua033 quantize -0.9 1e-1 -> -0.9
+ddqua034 quantize -0.9 1e-2 -> -0.90
+ddqua035 quantize -0.9 1e-3 -> -0.900
+ddqua036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded
+ddqua037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded
+ddqua038 quantize -0.5 1e+0 -> -0 Inexact Rounded
+ddqua039 quantize -0.5 1e-1 -> -0.5
+ddqua040 quantize -0.5 1e-2 -> -0.50
+ddqua041 quantize -0.5 1e-3 -> -0.500
+ddqua042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
+ddqua043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
+ddqua044 quantize -0.9 1e+0 -> -1 Inexact Rounded
+ddqua045 quantize -0.9 1e-1 -> -0.9
+ddqua046 quantize -0.9 1e-2 -> -0.90
+ddqua047 quantize -0.9 1e-3 -> -0.900
+
+-- examples from Specification
+ddqua060 quantize 2.17 0.001 -> 2.170
+ddqua061 quantize 2.17 0.01 -> 2.17
+ddqua062 quantize 2.17 0.1 -> 2.2 Inexact Rounded
+ddqua063 quantize 2.17 1e+0 -> 2 Inexact Rounded
+ddqua064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded
+ddqua065 quantize -Inf Inf -> -Infinity
+ddqua066 quantize 2 Inf -> NaN Invalid_operation
+ddqua067 quantize -0.1 1 -> -0 Inexact Rounded
+ddqua068 quantize -0 1e+5 -> -0E+5
+ddqua069 quantize +123456789012345.6 1e-2 -> NaN Invalid_operation
+ddqua070 quantize -987654335236450.6 1e-2 -> NaN Invalid_operation
+ddqua071 quantize 217 1e-1 -> 217.0
+ddqua072 quantize 217 1e+0 -> 217
+ddqua073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded
+ddqua074 quantize 217 1e+2 -> 2E+2 Inexact Rounded
+
+-- general tests ..
+ddqua089 quantize 12 1e+4 -> 0E+4 Inexact Rounded
+ddqua090 quantize 12 1e+3 -> 0E+3 Inexact Rounded
+ddqua091 quantize 12 1e+2 -> 0E+2 Inexact Rounded
+ddqua092 quantize 12 1e+1 -> 1E+1 Inexact Rounded
+ddqua093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded
+ddqua094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded
+ddqua095 quantize 1.2345 1e-6 -> 1.234500
+ddqua096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded
+ddqua097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded
+ddqua098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded
+ddqua099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded
+ddqua100 quantize 92 1e+2 -> 1E+2 Inexact Rounded
+
+ddqua101 quantize -1 1e0 -> -1
+ddqua102 quantize -1 1e-1 -> -1.0
+ddqua103 quantize -1 1e-2 -> -1.00
+ddqua104 quantize 0 1e0 -> 0
+ddqua105 quantize 0 1e-1 -> 0.0
+ddqua106 quantize 0 1e-2 -> 0.00
+ddqua107 quantize 0.00 1e0 -> 0
+ddqua108 quantize 0 1e+1 -> 0E+1
+ddqua109 quantize 0 1e+2 -> 0E+2
+ddqua110 quantize +1 1e0 -> 1
+ddqua111 quantize +1 1e-1 -> 1.0
+ddqua112 quantize +1 1e-2 -> 1.00
+
+ddqua120 quantize 1.04 1e-3 -> 1.040
+ddqua121 quantize 1.04 1e-2 -> 1.04
+ddqua122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded
+ddqua123 quantize 1.04 1e0 -> 1 Inexact Rounded
+ddqua124 quantize 1.05 1e-3 -> 1.050
+ddqua125 quantize 1.05 1e-2 -> 1.05
+ddqua126 quantize 1.05 1e-1 -> 1.0 Inexact Rounded
+ddqua131 quantize 1.05 1e0 -> 1 Inexact Rounded
+ddqua132 quantize 1.06 1e-3 -> 1.060
+ddqua133 quantize 1.06 1e-2 -> 1.06
+ddqua134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded
+ddqua135 quantize 1.06 1e0 -> 1 Inexact Rounded
+
+ddqua140 quantize -10 1e-2 -> -10.00
+ddqua141 quantize +1 1e-2 -> 1.00
+ddqua142 quantize +10 1e-2 -> 10.00
+ddqua143 quantize 1E+17 1e-2 -> NaN Invalid_operation
+ddqua144 quantize 1E-17 1e-2 -> 0.00 Inexact Rounded
+ddqua145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded
+ddqua146 quantize 1E-2 1e-2 -> 0.01
+ddqua147 quantize 1E-1 1e-2 -> 0.10
+ddqua148 quantize 0E-17 1e-2 -> 0.00
+
+ddqua150 quantize 1.0600 1e-5 -> 1.06000
+ddqua151 quantize 1.0600 1e-4 -> 1.0600
+ddqua152 quantize 1.0600 1e-3 -> 1.060 Rounded
+ddqua153 quantize 1.0600 1e-2 -> 1.06 Rounded
+ddqua154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded
+ddqua155 quantize 1.0600 1e0 -> 1 Inexact Rounded
+
+-- a couple where rounding was different in base tests
+rounding: half_up
+ddqua157 quantize -0.5 1e+0 -> -1 Inexact Rounded
+ddqua158 quantize 1.05 1e-1 -> 1.1 Inexact Rounded
+ddqua159 quantize 1.06 1e0 -> 1 Inexact Rounded
+rounding: half_even
+
+-- base tests with non-1 coefficients
+ddqua161 quantize 0 -9e0 -> 0
+ddqua162 quantize 1 -7e0 -> 1
+ddqua163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded
+ddqua165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded
+ddqua166 quantize 0.1 2e0 -> 0 Inexact Rounded
+ddqua167 quantize 0.1 3e-1 -> 0.1
+ddqua168 quantize 0.1 44e-2 -> 0.10
+ddqua169 quantize 0.1 555e-3 -> 0.100
+ddqua170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded
+ddqua171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded
+ddqua172 quantize 0.9 -88e+0 -> 1 Inexact Rounded
+ddqua173 quantize 0.9 -9e-1 -> 0.9
+ddqua174 quantize 0.9 0e-2 -> 0.90
+ddqua175 quantize 0.9 1.1e-3 -> 0.9000
+-- negatives
+ddqua181 quantize -0 1.1e0 -> -0.0
+ddqua182 quantize -1 -1e0 -> -1
+ddqua183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded
+ddqua185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded
+ddqua186 quantize -0.1 71e0 -> -0 Inexact Rounded
+ddqua187 quantize -0.1 -91e-1 -> -0.1
+ddqua188 quantize -0.1 -.1e-2 -> -0.100
+ddqua189 quantize -0.1 -1e-3 -> -0.100
+ddqua190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded
+ddqua191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded
+ddqua192 quantize -0.9 -10e+0 -> -1 Inexact Rounded
+ddqua193 quantize -0.9 100e-1 -> -0.9
+ddqua194 quantize -0.9 999e-2 -> -0.90
+
+-- +ve exponents ..
+ddqua201 quantize -1 1e+0 -> -1
+ddqua202 quantize -1 1e+1 -> -0E+1 Inexact Rounded
+ddqua203 quantize -1 1e+2 -> -0E+2 Inexact Rounded
+ddqua204 quantize 0 1e+0 -> 0
+ddqua205 quantize 0 1e+1 -> 0E+1
+ddqua206 quantize 0 1e+2 -> 0E+2
+ddqua207 quantize +1 1e+0 -> 1
+ddqua208 quantize +1 1e+1 -> 0E+1 Inexact Rounded
+ddqua209 quantize +1 1e+2 -> 0E+2 Inexact Rounded
+
+ddqua220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded
+ddqua221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded
+ddqua222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded
+ddqua223 quantize 1.04 1e+0 -> 1 Inexact Rounded
+ddqua224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
+ddqua225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
+ddqua226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
+ddqua227 quantize 1.05 1e+0 -> 1 Inexact Rounded
+ddqua228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
+ddqua229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
+ddqua230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
+ddqua231 quantize 1.05 1e+0 -> 1 Inexact Rounded
+ddqua232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded
+ddqua233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded
+ddqua234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded
+ddqua235 quantize 1.06 1e+0 -> 1 Inexact Rounded
+
+ddqua240 quantize -10 1e+1 -> -1E+1 Rounded
+ddqua241 quantize +1 1e+1 -> 0E+1 Inexact Rounded
+ddqua242 quantize +10 1e+1 -> 1E+1 Rounded
+ddqua243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1
+ddqua244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1
+ddqua245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1
+ddqua246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1
+ddqua247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1
+ddqua248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1
+ddqua249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1
+ddqua250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1
+ddqua251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1
+-- next one tries to add 9 zeros
+ddqua252 quantize 1E+17 1e+1 -> NaN Invalid_operation
+ddqua253 quantize 1E-17 1e+1 -> 0E+1 Inexact Rounded
+ddqua254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded
+ddqua255 quantize 0E-17 1e+1 -> 0E+1
+ddqua256 quantize -0E-17 1e+1 -> -0E+1
+ddqua257 quantize -0E-1 1e+1 -> -0E+1
+ddqua258 quantize -0 1e+1 -> -0E+1
+ddqua259 quantize -0E+1 1e+1 -> -0E+1
+
+ddqua260 quantize -10 1e+2 -> -0E+2 Inexact Rounded
+ddqua261 quantize +1 1e+2 -> 0E+2 Inexact Rounded
+ddqua262 quantize +10 1e+2 -> 0E+2 Inexact Rounded
+ddqua263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded
+ddqua264 quantize 1E+2 1e+2 -> 1E+2
+ddqua265 quantize 1E+3 1e+2 -> 1.0E+3
+ddqua266 quantize 1E+4 1e+2 -> 1.00E+4
+ddqua267 quantize 1E+5 1e+2 -> 1.000E+5
+ddqua268 quantize 1E+6 1e+2 -> 1.0000E+6
+ddqua269 quantize 1E+7 1e+2 -> 1.00000E+7
+ddqua270 quantize 1E+8 1e+2 -> 1.000000E+8
+ddqua271 quantize 1E+9 1e+2 -> 1.0000000E+9
+ddqua272 quantize 1E+10 1e+2 -> 1.00000000E+10
+ddqua273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded
+ddqua274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded
+ddqua275 quantize 0E-10 1e+2 -> 0E+2
+
+ddqua280 quantize -10 1e+3 -> -0E+3 Inexact Rounded
+ddqua281 quantize +1 1e+3 -> 0E+3 Inexact Rounded
+ddqua282 quantize +10 1e+3 -> 0E+3 Inexact Rounded
+ddqua283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded
+ddqua284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded
+ddqua285 quantize 1E+3 1e+3 -> 1E+3
+ddqua286 quantize 1E+4 1e+3 -> 1.0E+4
+ddqua287 quantize 1E+5 1e+3 -> 1.00E+5
+ddqua288 quantize 1E+6 1e+3 -> 1.000E+6
+ddqua289 quantize 1E+7 1e+3 -> 1.0000E+7
+ddqua290 quantize 1E+8 1e+3 -> 1.00000E+8
+ddqua291 quantize 1E+9 1e+3 -> 1.000000E+9
+ddqua292 quantize 1E+10 1e+3 -> 1.0000000E+10
+ddqua293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded
+ddqua294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded
+ddqua295 quantize 0E-10 1e+3 -> 0E+3
+
+-- round up from below [sign wrong in JIT compiler once]
+ddqua300 quantize 0.0078 1e-5 -> 0.00780
+ddqua301 quantize 0.0078 1e-4 -> 0.0078
+ddqua302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded
+ddqua303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded
+ddqua304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded
+ddqua305 quantize 0.0078 1e0 -> 0 Inexact Rounded
+ddqua306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded
+ddqua307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded
+
+ddqua310 quantize -0.0078 1e-5 -> -0.00780
+ddqua311 quantize -0.0078 1e-4 -> -0.0078
+ddqua312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded
+ddqua313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded
+ddqua314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded
+ddqua315 quantize -0.0078 1e0 -> -0 Inexact Rounded
+ddqua316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded
+ddqua317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded
+
+ddqua320 quantize 0.078 1e-5 -> 0.07800
+ddqua321 quantize 0.078 1e-4 -> 0.0780
+ddqua322 quantize 0.078 1e-3 -> 0.078
+ddqua323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded
+ddqua324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded
+ddqua325 quantize 0.078 1e0 -> 0 Inexact Rounded
+ddqua326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded
+ddqua327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded
+
+ddqua330 quantize -0.078 1e-5 -> -0.07800
+ddqua331 quantize -0.078 1e-4 -> -0.0780
+ddqua332 quantize -0.078 1e-3 -> -0.078
+ddqua333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded
+ddqua334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded
+ddqua335 quantize -0.078 1e0 -> -0 Inexact Rounded
+ddqua336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded
+ddqua337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded
+
+ddqua340 quantize 0.78 1e-5 -> 0.78000
+ddqua341 quantize 0.78 1e-4 -> 0.7800
+ddqua342 quantize 0.78 1e-3 -> 0.780
+ddqua343 quantize 0.78 1e-2 -> 0.78
+ddqua344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded
+ddqua345 quantize 0.78 1e0 -> 1 Inexact Rounded
+ddqua346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded
+ddqua347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded
+
+ddqua350 quantize -0.78 1e-5 -> -0.78000
+ddqua351 quantize -0.78 1e-4 -> -0.7800
+ddqua352 quantize -0.78 1e-3 -> -0.780
+ddqua353 quantize -0.78 1e-2 -> -0.78
+ddqua354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded
+ddqua355 quantize -0.78 1e0 -> -1 Inexact Rounded
+ddqua356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded
+ddqua357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded
+
+ddqua360 quantize 7.8 1e-5 -> 7.80000
+ddqua361 quantize 7.8 1e-4 -> 7.8000
+ddqua362 quantize 7.8 1e-3 -> 7.800
+ddqua363 quantize 7.8 1e-2 -> 7.80
+ddqua364 quantize 7.8 1e-1 -> 7.8
+ddqua365 quantize 7.8 1e0 -> 8 Inexact Rounded
+ddqua366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded
+ddqua367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded
+ddqua368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded
+
+ddqua370 quantize -7.8 1e-5 -> -7.80000
+ddqua371 quantize -7.8 1e-4 -> -7.8000
+ddqua372 quantize -7.8 1e-3 -> -7.800
+ddqua373 quantize -7.8 1e-2 -> -7.80
+ddqua374 quantize -7.8 1e-1 -> -7.8
+ddqua375 quantize -7.8 1e0 -> -8 Inexact Rounded
+ddqua376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded
+ddqua377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded
+ddqua378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded
+
+-- some individuals
+ddqua380 quantize 1234567352364.506 1e-2 -> 1234567352364.51 Inexact Rounded
+ddqua381 quantize 12345673523645.06 1e-2 -> 12345673523645.06
+ddqua382 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
+ddqua383 quantize 1234567352364506 1e-2 -> NaN Invalid_operation
+ddqua384 quantize -1234567352364.506 1e-2 -> -1234567352364.51 Inexact Rounded
+ddqua385 quantize -12345673523645.06 1e-2 -> -12345673523645.06
+ddqua386 quantize -123456735236450.6 1e-2 -> NaN Invalid_operation
+ddqua387 quantize -1234567352364506 1e-2 -> NaN Invalid_operation
+
+rounding: down
+ddqua389 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
+-- ? should that one instead have been:
+-- ddqua389 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
+rounding: half_up
+
+-- and a few more from e-mail discussions
+ddqua391 quantize 12345678912.34567 1e-3 -> 12345678912.346 Inexact Rounded
+ddqua392 quantize 123456789123.4567 1e-3 -> 123456789123.457 Inexact Rounded
+ddqua393 quantize 1234567891234.567 1e-3 -> 1234567891234.567
+ddqua394 quantize 12345678912345.67 1e-3 -> NaN Invalid_operation
+ddqua395 quantize 123456789123456.7 1e-3 -> NaN Invalid_operation
+ddqua396 quantize 1234567891234567. 1e-3 -> NaN Invalid_operation
+
+-- some 9999 round-up cases
+ddqua400 quantize 9.999 1e-5 -> 9.99900
+ddqua401 quantize 9.999 1e-4 -> 9.9990
+ddqua402 quantize 9.999 1e-3 -> 9.999
+ddqua403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded
+ddqua404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded
+ddqua405 quantize 9.999 1e0 -> 10 Inexact Rounded
+ddqua406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded
+ddqua407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded
+
+ddqua410 quantize 0.999 1e-5 -> 0.99900
+ddqua411 quantize 0.999 1e-4 -> 0.9990
+ddqua412 quantize 0.999 1e-3 -> 0.999
+ddqua413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded
+ddqua414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded
+ddqua415 quantize 0.999 1e0 -> 1 Inexact Rounded
+ddqua416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded
+
+ddqua420 quantize 0.0999 1e-5 -> 0.09990
+ddqua421 quantize 0.0999 1e-4 -> 0.0999
+ddqua422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded
+ddqua423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded
+ddqua424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded
+ddqua425 quantize 0.0999 1e0 -> 0 Inexact Rounded
+ddqua426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded
+
+ddqua430 quantize 0.00999 1e-5 -> 0.00999
+ddqua431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded
+ddqua432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded
+ddqua433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded
+ddqua434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded
+ddqua435 quantize 0.00999 1e0 -> 0 Inexact Rounded
+ddqua436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded
+
+ddqua440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded
+ddqua441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded
+ddqua442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded
+ddqua443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded
+ddqua444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded
+ddqua445 quantize 0.000999 1e0 -> 0 Inexact Rounded
+ddqua446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded
+
+ddqua1001 quantize 0.000 0.001 -> 0.000
+ddqua1002 quantize 0.001 0.001 -> 0.001
+ddqua1003 quantize 0.0012 0.001 -> 0.001 Inexact Rounded
+ddqua1004 quantize 0.0018 0.001 -> 0.002 Inexact Rounded
+ddqua1005 quantize 0.501 0.001 -> 0.501
+ddqua1006 quantize 0.5012 0.001 -> 0.501 Inexact Rounded
+ddqua1007 quantize 0.5018 0.001 -> 0.502 Inexact Rounded
+ddqua1008 quantize 0.999 0.001 -> 0.999
+
+ddqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
+ddqua482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
+ddqua483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
+ddqua484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
+ddqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
+ddqua486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
+-- a potential double-round
+ddqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
+ddqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
+
+ddqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
+ddqua492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
+ddqua493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
+ddqua494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
+ddqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
+ddqua496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
+ddqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
+ddqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
+
+-- Zeros
+ddqua500 quantize 0 1e1 -> 0E+1
+ddqua501 quantize 0 1e0 -> 0
+ddqua502 quantize 0 1e-1 -> 0.0
+ddqua503 quantize 0.0 1e-1 -> 0.0
+ddqua504 quantize 0.0 1e0 -> 0
+ddqua505 quantize 0.0 1e+1 -> 0E+1
+ddqua506 quantize 0E+1 1e-1 -> 0.0
+ddqua507 quantize 0E+1 1e0 -> 0
+ddqua508 quantize 0E+1 1e+1 -> 0E+1
+ddqua509 quantize -0 1e1 -> -0E+1
+ddqua510 quantize -0 1e0 -> -0
+ddqua511 quantize -0 1e-1 -> -0.0
+ddqua512 quantize -0.0 1e-1 -> -0.0
+ddqua513 quantize -0.0 1e0 -> -0
+ddqua514 quantize -0.0 1e+1 -> -0E+1
+ddqua515 quantize -0E+1 1e-1 -> -0.0
+ddqua516 quantize -0E+1 1e0 -> -0
+ddqua517 quantize -0E+1 1e+1 -> -0E+1
+
+-- Suspicious RHS values
+ddqua520 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
+ddqua521 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
+ddqua522 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
+ddqua523 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
+-- next four are "won't fit" overfl
+ddqua526 quantize 1.234 1e-299 -> NaN Invalid_operation
+ddqua527 quantize 123.456 1e-299 -> NaN Invalid_operation
+ddqua528 quantize 1.234 1e-299 -> NaN Invalid_operation
+ddqua529 quantize 123.456 1e-299 -> NaN Invalid_operation
+
+ddqua532 quantize 1.234E+299 1e299 -> 1E+299 Inexact Rounded
+ddqua533 quantize 1.234E+298 1e299 -> 0E+299 Inexact Rounded
+ddqua534 quantize 1.234 1e299 -> 0E+299 Inexact Rounded
+ddqua537 quantize 0 1e-299 -> 0E-299
+-- next two are "won't fit" overflows
+ddqua538 quantize 1.234 1e-299 -> NaN Invalid_operation
+ddqua539 quantize 1.234 1e-300 -> NaN Invalid_operation
+-- [more below]
+
+-- Specials
+ddqua580 quantize Inf -Inf -> Infinity
+ddqua581 quantize Inf 1e-299 -> NaN Invalid_operation
+ddqua582 quantize Inf 1e-1 -> NaN Invalid_operation
+ddqua583 quantize Inf 1e0 -> NaN Invalid_operation
+ddqua584 quantize Inf 1e1 -> NaN Invalid_operation
+ddqua585 quantize Inf 1e299 -> NaN Invalid_operation
+ddqua586 quantize Inf Inf -> Infinity
+ddqua587 quantize -1000 Inf -> NaN Invalid_operation
+ddqua588 quantize -Inf Inf -> -Infinity
+ddqua589 quantize -1 Inf -> NaN Invalid_operation
+ddqua590 quantize 0 Inf -> NaN Invalid_operation
+ddqua591 quantize 1 Inf -> NaN Invalid_operation
+ddqua592 quantize 1000 Inf -> NaN Invalid_operation
+ddqua593 quantize Inf Inf -> Infinity
+ddqua594 quantize Inf 1e-0 -> NaN Invalid_operation
+ddqua595 quantize -0 Inf -> NaN Invalid_operation
+
+ddqua600 quantize -Inf -Inf -> -Infinity
+ddqua601 quantize -Inf 1e-299 -> NaN Invalid_operation
+ddqua602 quantize -Inf 1e-1 -> NaN Invalid_operation
+ddqua603 quantize -Inf 1e0 -> NaN Invalid_operation
+ddqua604 quantize -Inf 1e1 -> NaN Invalid_operation
+ddqua605 quantize -Inf 1e299 -> NaN Invalid_operation
+ddqua606 quantize -Inf Inf -> -Infinity
+ddqua607 quantize -1000 Inf -> NaN Invalid_operation
+ddqua608 quantize -Inf -Inf -> -Infinity
+ddqua609 quantize -1 -Inf -> NaN Invalid_operation
+ddqua610 quantize 0 -Inf -> NaN Invalid_operation
+ddqua611 quantize 1 -Inf -> NaN Invalid_operation
+ddqua612 quantize 1000 -Inf -> NaN Invalid_operation
+ddqua613 quantize Inf -Inf -> Infinity
+ddqua614 quantize -Inf 1e-0 -> NaN Invalid_operation
+ddqua615 quantize -0 -Inf -> NaN Invalid_operation
+
+ddqua621 quantize NaN -Inf -> NaN
+ddqua622 quantize NaN 1e-299 -> NaN
+ddqua623 quantize NaN 1e-1 -> NaN
+ddqua624 quantize NaN 1e0 -> NaN
+ddqua625 quantize NaN 1e1 -> NaN
+ddqua626 quantize NaN 1e299 -> NaN
+ddqua627 quantize NaN Inf -> NaN
+ddqua628 quantize NaN NaN -> NaN
+ddqua629 quantize -Inf NaN -> NaN
+ddqua630 quantize -1000 NaN -> NaN
+ddqua631 quantize -1 NaN -> NaN
+ddqua632 quantize 0 NaN -> NaN
+ddqua633 quantize 1 NaN -> NaN
+ddqua634 quantize 1000 NaN -> NaN
+ddqua635 quantize Inf NaN -> NaN
+ddqua636 quantize NaN 1e-0 -> NaN
+ddqua637 quantize -0 NaN -> NaN
+
+ddqua641 quantize sNaN -Inf -> NaN Invalid_operation
+ddqua642 quantize sNaN 1e-299 -> NaN Invalid_operation
+ddqua643 quantize sNaN 1e-1 -> NaN Invalid_operation
+ddqua644 quantize sNaN 1e0 -> NaN Invalid_operation
+ddqua645 quantize sNaN 1e1 -> NaN Invalid_operation
+ddqua646 quantize sNaN 1e299 -> NaN Invalid_operation
+ddqua647 quantize sNaN NaN -> NaN Invalid_operation
+ddqua648 quantize sNaN sNaN -> NaN Invalid_operation
+ddqua649 quantize NaN sNaN -> NaN Invalid_operation
+ddqua650 quantize -Inf sNaN -> NaN Invalid_operation
+ddqua651 quantize -1000 sNaN -> NaN Invalid_operation
+ddqua652 quantize -1 sNaN -> NaN Invalid_operation
+ddqua653 quantize 0 sNaN -> NaN Invalid_operation
+ddqua654 quantize 1 sNaN -> NaN Invalid_operation
+ddqua655 quantize 1000 sNaN -> NaN Invalid_operation
+ddqua656 quantize Inf sNaN -> NaN Invalid_operation
+ddqua657 quantize NaN sNaN -> NaN Invalid_operation
+ddqua658 quantize sNaN 1e-0 -> NaN Invalid_operation
+ddqua659 quantize -0 sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddqua661 quantize NaN9 -Inf -> NaN9
+ddqua662 quantize NaN8 919 -> NaN8
+ddqua663 quantize NaN71 Inf -> NaN71
+ddqua664 quantize NaN6 NaN5 -> NaN6
+ddqua665 quantize -Inf NaN4 -> NaN4
+ddqua666 quantize -919 NaN31 -> NaN31
+ddqua667 quantize Inf NaN2 -> NaN2
+
+ddqua671 quantize sNaN99 -Inf -> NaN99 Invalid_operation
+ddqua672 quantize sNaN98 -11 -> NaN98 Invalid_operation
+ddqua673 quantize sNaN97 NaN -> NaN97 Invalid_operation
+ddqua674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation
+ddqua675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation
+ddqua676 quantize -Inf sNaN92 -> NaN92 Invalid_operation
+ddqua677 quantize 088 sNaN91 -> NaN91 Invalid_operation
+ddqua678 quantize Inf sNaN90 -> NaN90 Invalid_operation
+ddqua679 quantize NaN sNaN88 -> NaN88 Invalid_operation
+
+ddqua681 quantize -NaN9 -Inf -> -NaN9
+ddqua682 quantize -NaN8 919 -> -NaN8
+ddqua683 quantize -NaN71 Inf -> -NaN71
+ddqua684 quantize -NaN6 -NaN5 -> -NaN6
+ddqua685 quantize -Inf -NaN4 -> -NaN4
+ddqua686 quantize -919 -NaN31 -> -NaN31
+ddqua687 quantize Inf -NaN2 -> -NaN2
+
+ddqua691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation
+ddqua692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation
+ddqua693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation
+ddqua694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation
+ddqua695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+ddqua696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation
+ddqua697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation
+ddqua698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation
+ddqua699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation
+
+-- subnormals and underflow
+ddqua710 quantize 1.00E-383 1e-383 -> 1E-383 Rounded
+ddqua711 quantize 0.1E-383 2e-384 -> 1E-384 Subnormal
+ddqua712 quantize 0.10E-383 3e-384 -> 1E-384 Subnormal Rounded
+ddqua713 quantize 0.100E-383 4e-384 -> 1E-384 Subnormal Rounded
+ddqua714 quantize 0.01E-383 5e-385 -> 1E-385 Subnormal
+-- next is rounded to Emin
+ddqua715 quantize 0.999E-383 1e-383 -> 1E-383 Inexact Rounded
+ddqua716 quantize 0.099E-383 10e-384 -> 1E-384 Inexact Rounded Subnormal
+
+ddqua717 quantize 0.009E-383 1e-385 -> 1E-385 Inexact Rounded Subnormal
+ddqua718 quantize 0.001E-383 1e-385 -> 0E-385 Inexact Rounded
+ddqua719 quantize 0.0009E-383 1e-385 -> 0E-385 Inexact Rounded
+ddqua720 quantize 0.0001E-383 1e-385 -> 0E-385 Inexact Rounded
+
+ddqua730 quantize -1.00E-383 1e-383 -> -1E-383 Rounded
+ddqua731 quantize -0.1E-383 1e-383 -> -0E-383 Rounded Inexact
+ddqua732 quantize -0.10E-383 1e-383 -> -0E-383 Rounded Inexact
+ddqua733 quantize -0.100E-383 1e-383 -> -0E-383 Rounded Inexact
+ddqua734 quantize -0.01E-383 1e-383 -> -0E-383 Inexact Rounded
+-- next is rounded to Emin
+ddqua735 quantize -0.999E-383 90e-383 -> -1E-383 Inexact Rounded
+ddqua736 quantize -0.099E-383 -1e-383 -> -0E-383 Inexact Rounded
+ddqua737 quantize -0.009E-383 -1e-383 -> -0E-383 Inexact Rounded
+ddqua738 quantize -0.001E-383 -0e-383 -> -0E-383 Inexact Rounded
+ddqua739 quantize -0.0001E-383 0e-383 -> -0E-383 Inexact Rounded
+
+ddqua740 quantize -1.00E-383 1e-384 -> -1.0E-383 Rounded
+ddqua741 quantize -0.1E-383 1e-384 -> -1E-384 Subnormal
+ddqua742 quantize -0.10E-383 1e-384 -> -1E-384 Subnormal Rounded
+ddqua743 quantize -0.100E-383 1e-384 -> -1E-384 Subnormal Rounded
+ddqua744 quantize -0.01E-383 1e-384 -> -0E-384 Inexact Rounded
+-- next is rounded to Emin
+ddqua745 quantize -0.999E-383 1e-384 -> -1.0E-383 Inexact Rounded
+ddqua746 quantize -0.099E-383 1e-384 -> -1E-384 Inexact Rounded Subnormal
+ddqua747 quantize -0.009E-383 1e-384 -> -0E-384 Inexact Rounded
+ddqua748 quantize -0.001E-383 1e-384 -> -0E-384 Inexact Rounded
+ddqua749 quantize -0.0001E-383 1e-384 -> -0E-384 Inexact Rounded
+
+ddqua750 quantize -1.00E-383 1e-385 -> -1.00E-383
+ddqua751 quantize -0.1E-383 1e-385 -> -1.0E-384 Subnormal
+ddqua752 quantize -0.10E-383 1e-385 -> -1.0E-384 Subnormal
+ddqua753 quantize -0.100E-383 1e-385 -> -1.0E-384 Subnormal Rounded
+ddqua754 quantize -0.01E-383 1e-385 -> -1E-385 Subnormal
+-- next is rounded to Emin
+ddqua755 quantize -0.999E-383 1e-385 -> -1.00E-383 Inexact Rounded
+ddqua756 quantize -0.099E-383 1e-385 -> -1.0E-384 Inexact Rounded Subnormal
+ddqua757 quantize -0.009E-383 1e-385 -> -1E-385 Inexact Rounded Subnormal
+ddqua758 quantize -0.001E-383 1e-385 -> -0E-385 Inexact Rounded
+ddqua759 quantize -0.0001E-383 1e-385 -> -0E-385 Inexact Rounded
+
+ddqua760 quantize -1.00E-383 1e-386 -> -1.000E-383
+ddqua761 quantize -0.1E-383 1e-386 -> -1.00E-384 Subnormal
+ddqua762 quantize -0.10E-383 1e-386 -> -1.00E-384 Subnormal
+ddqua763 quantize -0.100E-383 1e-386 -> -1.00E-384 Subnormal
+ddqua764 quantize -0.01E-383 1e-386 -> -1.0E-385 Subnormal
+ddqua765 quantize -0.999E-383 1e-386 -> -9.99E-384 Subnormal
+ddqua766 quantize -0.099E-383 1e-386 -> -9.9E-385 Subnormal
+ddqua767 quantize -0.009E-383 1e-386 -> -9E-386 Subnormal
+ddqua768 quantize -0.001E-383 1e-386 -> -1E-386 Subnormal
+ddqua769 quantize -0.0001E-383 1e-386 -> -0E-386 Inexact Rounded
+
+-- More from Fung Lee
+ddqua1021 quantize 8.666666666666000E+384 1.000000000000000E+384 -> 8.666666666666000E+384
+ddqua1022 quantize -8.666666666666000E+384 1.000000000000000E+384 -> -8.666666666666000E+384
+ddqua1027 quantize 8.666666666666000E+323 1E+31 -> NaN Invalid_operation
+ddqua1029 quantize 8.66666666E+3 1E+3 -> 9E+3 Inexact Rounded
+
+
+--ddqua1030 quantize 8.666666666666000E+384 1E+384 -> 9.000000000000000E+384 Rounded Inexact
+--ddqua1031 quantize 8.666666666666000E+384 1E+384 -> 8.666666666666000E+384 Rounded
+--ddqua1032 quantize 8.666666666666000E+384 1E+383 -> 8.666666666666000E+384 Rounded
+--ddqua1033 quantize 8.666666666666000E+384 1E+382 -> 8.666666666666000E+384 Rounded
+--ddqua1034 quantize 8.666666666666000E+384 1E+381 -> 8.666666666666000E+384 Rounded
+--ddqua1035 quantize 8.666666666666000E+384 1E+380 -> 8.666666666666000E+384 Rounded
+
+-- Int and uInt32 edge values for testing conversions
+ddqua1040 quantize -2147483646 0 -> -2147483646
+ddqua1041 quantize -2147483647 0 -> -2147483647
+ddqua1042 quantize -2147483648 0 -> -2147483648
+ddqua1043 quantize -2147483649 0 -> -2147483649
+ddqua1044 quantize 2147483646 0 -> 2147483646
+ddqua1045 quantize 2147483647 0 -> 2147483647
+ddqua1046 quantize 2147483648 0 -> 2147483648
+ddqua1047 quantize 2147483649 0 -> 2147483649
+ddqua1048 quantize 4294967294 0 -> 4294967294
+ddqua1049 quantize 4294967295 0 -> 4294967295
+ddqua1050 quantize 4294967296 0 -> 4294967296
+ddqua1051 quantize 4294967297 0 -> 4294967297
+
+-- Rounding swathe
+rounding: half_even
+ddqua1100 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1101 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1102 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1103 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+ddqua1104 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1105 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua1106 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1107 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1108 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1109 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: half_up
+ddqua1200 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1201 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1202 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1203 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+ddqua1204 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1205 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+ddqua1206 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1207 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1208 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1209 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: half_down
+ddqua1300 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1301 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1302 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1303 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+ddqua1304 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1305 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua1306 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1307 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1308 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1309 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: up
+ddqua1400 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1401 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
+ddqua1402 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
+ddqua1403 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+ddqua1404 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1405 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+ddqua1406 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1407 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1408 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1409 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+ddqua1411 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
+
+rounding: down
+ddqua1500 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1501 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1502 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1503 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+ddqua1504 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
+ddqua1505 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua1506 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+ddqua1507 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
+ddqua1508 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
+ddqua1509 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
+ddqua1511 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
+
+rounding: ceiling
+ddqua1600 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1601 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
+ddqua1602 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
+ddqua1603 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+ddqua1604 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1605 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+ddqua1606 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1607 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1608 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1609 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+ddqua1611 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
+
+rounding: floor
+ddqua1700 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1701 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1702 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1703 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+ddqua1704 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
+ddqua1705 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua1706 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+ddqua1707 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
+ddqua1708 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
+ddqua1709 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
+ddqua1711 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
+
+rounding: 05up
+ddqua1800 quantize 1.2000 1.00 -> 1.20 Rounded
+ddqua1801 quantize 1.2001 1.00 -> 1.21 Inexact Rounded
+ddqua1802 quantize 1.2010 1.00 -> 1.21 Inexact Rounded
+ddqua1803 quantize 1.2050 1.00 -> 1.21 Inexact Rounded
+ddqua1804 quantize 1.2051 1.00 -> 1.21 Inexact Rounded
+ddqua1807 quantize 1.2060 1.00 -> 1.21 Inexact Rounded
+ddqua1808 quantize 1.2070 1.00 -> 1.21 Inexact Rounded
+ddqua1809 quantize 1.2099 1.00 -> 1.21 Inexact Rounded
+ddqua1811 quantize -1.2099 1.00 -> -1.21 Inexact Rounded
+
+ddqua1900 quantize 1.2100 1.00 -> 1.21 Rounded
+ddqua1901 quantize 1.2101 1.00 -> 1.21 Inexact Rounded
+ddqua1902 quantize 1.2110 1.00 -> 1.21 Inexact Rounded
+ddqua1903 quantize 1.2150 1.00 -> 1.21 Inexact Rounded
+ddqua1904 quantize 1.2151 1.00 -> 1.21 Inexact Rounded
+ddqua1907 quantize 1.2160 1.00 -> 1.21 Inexact Rounded
+ddqua1908 quantize 1.2170 1.00 -> 1.21 Inexact Rounded
+ddqua1909 quantize 1.2199 1.00 -> 1.21 Inexact Rounded
+ddqua1911 quantize -1.2199 1.00 -> -1.21 Inexact Rounded
+
+ddqua2000 quantize 1.2400 1.00 -> 1.24 Rounded
+ddqua2001 quantize 1.2401 1.00 -> 1.24 Inexact Rounded
+ddqua2002 quantize 1.2410 1.00 -> 1.24 Inexact Rounded
+ddqua2003 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua2004 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+ddqua2007 quantize 1.2460 1.00 -> 1.24 Inexact Rounded
+ddqua2008 quantize 1.2470 1.00 -> 1.24 Inexact Rounded
+ddqua2009 quantize 1.2499 1.00 -> 1.24 Inexact Rounded
+ddqua2011 quantize -1.2499 1.00 -> -1.24 Inexact Rounded
+
+ddqua2100 quantize 1.2500 1.00 -> 1.25 Rounded
+ddqua2101 quantize 1.2501 1.00 -> 1.26 Inexact Rounded
+ddqua2102 quantize 1.2510 1.00 -> 1.26 Inexact Rounded
+ddqua2103 quantize 1.2550 1.00 -> 1.26 Inexact Rounded
+ddqua2104 quantize 1.2551 1.00 -> 1.26 Inexact Rounded
+ddqua2107 quantize 1.2560 1.00 -> 1.26 Inexact Rounded
+ddqua2108 quantize 1.2570 1.00 -> 1.26 Inexact Rounded
+ddqua2109 quantize 1.2599 1.00 -> 1.26 Inexact Rounded
+ddqua2111 quantize -1.2599 1.00 -> -1.26 Inexact Rounded
+
+ddqua2200 quantize 1.2600 1.00 -> 1.26 Rounded
+ddqua2201 quantize 1.2601 1.00 -> 1.26 Inexact Rounded
+ddqua2202 quantize 1.2610 1.00 -> 1.26 Inexact Rounded
+ddqua2203 quantize 1.2650 1.00 -> 1.26 Inexact Rounded
+ddqua2204 quantize 1.2651 1.00 -> 1.26 Inexact Rounded
+ddqua2207 quantize 1.2660 1.00 -> 1.26 Inexact Rounded
+ddqua2208 quantize 1.2670 1.00 -> 1.26 Inexact Rounded
+ddqua2209 quantize 1.2699 1.00 -> 1.26 Inexact Rounded
+ddqua2211 quantize -1.2699 1.00 -> -1.26 Inexact Rounded
+
+ddqua2300 quantize 1.2900 1.00 -> 1.29 Rounded
+ddqua2301 quantize 1.2901 1.00 -> 1.29 Inexact Rounded
+ddqua2302 quantize 1.2910 1.00 -> 1.29 Inexact Rounded
+ddqua2303 quantize 1.2950 1.00 -> 1.29 Inexact Rounded
+ddqua2304 quantize 1.2951 1.00 -> 1.29 Inexact Rounded
+ddqua2307 quantize 1.2960 1.00 -> 1.29 Inexact Rounded
+ddqua2308 quantize 1.2970 1.00 -> 1.29 Inexact Rounded
+ddqua2309 quantize 1.2999 1.00 -> 1.29 Inexact Rounded
+ddqua2311 quantize -1.2999 1.00 -> -1.29 Inexact Rounded
+
+-- Null tests
+rounding: half_even
+ddqua998 quantize 10 # -> NaN Invalid_operation
+ddqua999 quantize # 1e10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddReduce.decTest b/Lib/test/decimaltestdata/ddReduce.decTest
index 9529e50a75..bdfd060492 100644
--- a/Lib/test/decimaltestdata/ddReduce.decTest
+++ b/Lib/test/decimaltestdata/ddReduce.decTest
@@ -1,182 +1,182 @@
-------------------------------------------------------------------------
--- ddReduce.decTest -- remove trailing zeros from a decDouble --
--- Copyright (c) IBM Corporation, 2003, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddred001 reduce '1' -> '1'
-ddred002 reduce '-1' -> '-1'
-ddred003 reduce '1.00' -> '1'
-ddred004 reduce '-1.00' -> '-1'
-ddred005 reduce '0' -> '0'
-ddred006 reduce '0.00' -> '0'
-ddred007 reduce '00.0' -> '0'
-ddred008 reduce '00.00' -> '0'
-ddred009 reduce '00' -> '0'
-ddred010 reduce '0E+1' -> '0'
-ddred011 reduce '0E+5' -> '0'
-
-ddred012 reduce '-2' -> '-2'
-ddred013 reduce '2' -> '2'
-ddred014 reduce '-2.00' -> '-2'
-ddred015 reduce '2.00' -> '2'
-ddred016 reduce '-0' -> '-0'
-ddred017 reduce '-0.00' -> '-0'
-ddred018 reduce '-00.0' -> '-0'
-ddred019 reduce '-00.00' -> '-0'
-ddred020 reduce '-00' -> '-0'
-ddred021 reduce '-0E+5' -> '-0'
-ddred022 reduce '-0E+1' -> '-0'
-
-ddred030 reduce '+0.1' -> '0.1'
-ddred031 reduce '-0.1' -> '-0.1'
-ddred032 reduce '+0.01' -> '0.01'
-ddred033 reduce '-0.01' -> '-0.01'
-ddred034 reduce '+0.001' -> '0.001'
-ddred035 reduce '-0.001' -> '-0.001'
-ddred036 reduce '+0.000001' -> '0.000001'
-ddred037 reduce '-0.000001' -> '-0.000001'
-ddred038 reduce '+0.000000000001' -> '1E-12'
-ddred039 reduce '-0.000000000001' -> '-1E-12'
-
-ddred041 reduce 1.1 -> 1.1
-ddred042 reduce 1.10 -> 1.1
-ddred043 reduce 1.100 -> 1.1
-ddred044 reduce 1.110 -> 1.11
-ddred045 reduce -1.1 -> -1.1
-ddred046 reduce -1.10 -> -1.1
-ddred047 reduce -1.100 -> -1.1
-ddred048 reduce -1.110 -> -1.11
-ddred049 reduce 9.9 -> 9.9
-ddred050 reduce 9.90 -> 9.9
-ddred051 reduce 9.900 -> 9.9
-ddred052 reduce 9.990 -> 9.99
-ddred053 reduce -9.9 -> -9.9
-ddred054 reduce -9.90 -> -9.9
-ddred055 reduce -9.900 -> -9.9
-ddred056 reduce -9.990 -> -9.99
-
--- some trailing fractional zeros with zeros in units
-ddred060 reduce 10.0 -> 1E+1
-ddred061 reduce 10.00 -> 1E+1
-ddred062 reduce 100.0 -> 1E+2
-ddred063 reduce 100.00 -> 1E+2
-ddred064 reduce 1.1000E+3 -> 1.1E+3
-ddred065 reduce 1.10000E+3 -> 1.1E+3
-ddred066 reduce -10.0 -> -1E+1
-ddred067 reduce -10.00 -> -1E+1
-ddred068 reduce -100.0 -> -1E+2
-ddred069 reduce -100.00 -> -1E+2
-ddred070 reduce -1.1000E+3 -> -1.1E+3
-ddred071 reduce -1.10000E+3 -> -1.1E+3
-
--- some insignificant trailing zeros with positive exponent
-ddred080 reduce 10E+1 -> 1E+2
-ddred081 reduce 100E+1 -> 1E+3
-ddred082 reduce 1.0E+2 -> 1E+2
-ddred083 reduce 1.0E+3 -> 1E+3
-ddred084 reduce 1.1E+3 -> 1.1E+3
-ddred085 reduce 1.00E+3 -> 1E+3
-ddred086 reduce 1.10E+3 -> 1.1E+3
-ddred087 reduce -10E+1 -> -1E+2
-ddred088 reduce -100E+1 -> -1E+3
-ddred089 reduce -1.0E+2 -> -1E+2
-ddred090 reduce -1.0E+3 -> -1E+3
-ddred091 reduce -1.1E+3 -> -1.1E+3
-ddred092 reduce -1.00E+3 -> -1E+3
-ddred093 reduce -1.10E+3 -> -1.1E+3
-
--- some significant trailing zeros, were we to be trimming
-ddred100 reduce 11 -> 11
-ddred101 reduce 10 -> 1E+1
-ddred102 reduce 10. -> 1E+1
-ddred103 reduce 1.1E+1 -> 11
-ddred104 reduce 1.0E+1 -> 1E+1
-ddred105 reduce 1.10E+2 -> 1.1E+2
-ddred106 reduce 1.00E+2 -> 1E+2
-ddred107 reduce 1.100E+3 -> 1.1E+3
-ddred108 reduce 1.000E+3 -> 1E+3
-ddred109 reduce 1.000000E+6 -> 1E+6
-ddred110 reduce -11 -> -11
-ddred111 reduce -10 -> -1E+1
-ddred112 reduce -10. -> -1E+1
-ddred113 reduce -1.1E+1 -> -11
-ddred114 reduce -1.0E+1 -> -1E+1
-ddred115 reduce -1.10E+2 -> -1.1E+2
-ddred116 reduce -1.00E+2 -> -1E+2
-ddred117 reduce -1.100E+3 -> -1.1E+3
-ddred118 reduce -1.000E+3 -> -1E+3
-ddred119 reduce -1.00000E+5 -> -1E+5
-ddred120 reduce -1.000000E+6 -> -1E+6
-ddred121 reduce -10.00000E+6 -> -1E+7
-ddred122 reduce -100.0000E+6 -> -1E+8
-ddred123 reduce -1000.000E+6 -> -1E+9
-ddred124 reduce -10000.00E+6 -> -1E+10
-ddred125 reduce -100000.0E+6 -> -1E+11
-ddred126 reduce -1000000.E+6 -> -1E+12
-
--- examples from decArith
-ddred140 reduce '2.1' -> '2.1'
-ddred141 reduce '-2.0' -> '-2'
-ddred142 reduce '1.200' -> '1.2'
-ddred143 reduce '-120' -> '-1.2E+2'
-ddred144 reduce '120.00' -> '1.2E+2'
-ddred145 reduce '0.00' -> '0'
-
--- Nmax, Nmin, Ntiny
--- note origami effect on some of these
-ddred151 reduce 9.999999999999999E+384 -> 9.999999999999999E+384
-ddred152 reduce 9.999999000000000E+380 -> 9.99999900000E+380
-ddred153 reduce 9.999999999990000E+384 -> 9.999999999990000E+384
-ddred154 reduce 1E-383 -> 1E-383
-ddred155 reduce 1.000000000000000E-383 -> 1E-383
-ddred156 reduce 2.000E-395 -> 2E-395 Subnormal
-ddred157 reduce 1E-398 -> 1E-398 Subnormal
-
-ddred161 reduce -1E-398 -> -1E-398 Subnormal
-ddred162 reduce -2.000E-395 -> -2E-395 Subnormal
-ddred163 reduce -1.000000000000000E-383 -> -1E-383
-ddred164 reduce -1E-383 -> -1E-383
-ddred165 reduce -9.999999000000000E+380 -> -9.99999900000E+380
-ddred166 reduce -9.999999999990000E+384 -> -9.999999999990000E+384
-ddred167 reduce -9.999999999999990E+384 -> -9.999999999999990E+384
-ddred168 reduce -9.999999999999999E+384 -> -9.999999999999999E+384
-ddred169 reduce -9.999999999999990E+384 -> -9.999999999999990E+384
-
-
--- specials (reduce does not affect payload)
-ddred820 reduce 'Inf' -> 'Infinity'
-ddred821 reduce '-Inf' -> '-Infinity'
-ddred822 reduce NaN -> NaN
-ddred823 reduce sNaN -> NaN Invalid_operation
-ddred824 reduce NaN101 -> NaN101
-ddred825 reduce sNaN010 -> NaN10 Invalid_operation
-ddred827 reduce -NaN -> -NaN
-ddred828 reduce -sNaN -> -NaN Invalid_operation
-ddred829 reduce -NaN101 -> -NaN101
-ddred830 reduce -sNaN010 -> -NaN10 Invalid_operation
-
--- Null test
-ddred900 reduce # -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddReduce.decTest -- remove trailing zeros from a decDouble --
+-- Copyright (c) IBM Corporation, 2003, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddred001 reduce '1' -> '1'
+ddred002 reduce '-1' -> '-1'
+ddred003 reduce '1.00' -> '1'
+ddred004 reduce '-1.00' -> '-1'
+ddred005 reduce '0' -> '0'
+ddred006 reduce '0.00' -> '0'
+ddred007 reduce '00.0' -> '0'
+ddred008 reduce '00.00' -> '0'
+ddred009 reduce '00' -> '0'
+ddred010 reduce '0E+1' -> '0'
+ddred011 reduce '0E+5' -> '0'
+
+ddred012 reduce '-2' -> '-2'
+ddred013 reduce '2' -> '2'
+ddred014 reduce '-2.00' -> '-2'
+ddred015 reduce '2.00' -> '2'
+ddred016 reduce '-0' -> '-0'
+ddred017 reduce '-0.00' -> '-0'
+ddred018 reduce '-00.0' -> '-0'
+ddred019 reduce '-00.00' -> '-0'
+ddred020 reduce '-00' -> '-0'
+ddred021 reduce '-0E+5' -> '-0'
+ddred022 reduce '-0E+1' -> '-0'
+
+ddred030 reduce '+0.1' -> '0.1'
+ddred031 reduce '-0.1' -> '-0.1'
+ddred032 reduce '+0.01' -> '0.01'
+ddred033 reduce '-0.01' -> '-0.01'
+ddred034 reduce '+0.001' -> '0.001'
+ddred035 reduce '-0.001' -> '-0.001'
+ddred036 reduce '+0.000001' -> '0.000001'
+ddred037 reduce '-0.000001' -> '-0.000001'
+ddred038 reduce '+0.000000000001' -> '1E-12'
+ddred039 reduce '-0.000000000001' -> '-1E-12'
+
+ddred041 reduce 1.1 -> 1.1
+ddred042 reduce 1.10 -> 1.1
+ddred043 reduce 1.100 -> 1.1
+ddred044 reduce 1.110 -> 1.11
+ddred045 reduce -1.1 -> -1.1
+ddred046 reduce -1.10 -> -1.1
+ddred047 reduce -1.100 -> -1.1
+ddred048 reduce -1.110 -> -1.11
+ddred049 reduce 9.9 -> 9.9
+ddred050 reduce 9.90 -> 9.9
+ddred051 reduce 9.900 -> 9.9
+ddred052 reduce 9.990 -> 9.99
+ddred053 reduce -9.9 -> -9.9
+ddred054 reduce -9.90 -> -9.9
+ddred055 reduce -9.900 -> -9.9
+ddred056 reduce -9.990 -> -9.99
+
+-- some trailing fractional zeros with zeros in units
+ddred060 reduce 10.0 -> 1E+1
+ddred061 reduce 10.00 -> 1E+1
+ddred062 reduce 100.0 -> 1E+2
+ddred063 reduce 100.00 -> 1E+2
+ddred064 reduce 1.1000E+3 -> 1.1E+3
+ddred065 reduce 1.10000E+3 -> 1.1E+3
+ddred066 reduce -10.0 -> -1E+1
+ddred067 reduce -10.00 -> -1E+1
+ddred068 reduce -100.0 -> -1E+2
+ddred069 reduce -100.00 -> -1E+2
+ddred070 reduce -1.1000E+3 -> -1.1E+3
+ddred071 reduce -1.10000E+3 -> -1.1E+3
+
+-- some insignificant trailing zeros with positive exponent
+ddred080 reduce 10E+1 -> 1E+2
+ddred081 reduce 100E+1 -> 1E+3
+ddred082 reduce 1.0E+2 -> 1E+2
+ddred083 reduce 1.0E+3 -> 1E+3
+ddred084 reduce 1.1E+3 -> 1.1E+3
+ddred085 reduce 1.00E+3 -> 1E+3
+ddred086 reduce 1.10E+3 -> 1.1E+3
+ddred087 reduce -10E+1 -> -1E+2
+ddred088 reduce -100E+1 -> -1E+3
+ddred089 reduce -1.0E+2 -> -1E+2
+ddred090 reduce -1.0E+3 -> -1E+3
+ddred091 reduce -1.1E+3 -> -1.1E+3
+ddred092 reduce -1.00E+3 -> -1E+3
+ddred093 reduce -1.10E+3 -> -1.1E+3
+
+-- some significant trailing zeros, were we to be trimming
+ddred100 reduce 11 -> 11
+ddred101 reduce 10 -> 1E+1
+ddred102 reduce 10. -> 1E+1
+ddred103 reduce 1.1E+1 -> 11
+ddred104 reduce 1.0E+1 -> 1E+1
+ddred105 reduce 1.10E+2 -> 1.1E+2
+ddred106 reduce 1.00E+2 -> 1E+2
+ddred107 reduce 1.100E+3 -> 1.1E+3
+ddred108 reduce 1.000E+3 -> 1E+3
+ddred109 reduce 1.000000E+6 -> 1E+6
+ddred110 reduce -11 -> -11
+ddred111 reduce -10 -> -1E+1
+ddred112 reduce -10. -> -1E+1
+ddred113 reduce -1.1E+1 -> -11
+ddred114 reduce -1.0E+1 -> -1E+1
+ddred115 reduce -1.10E+2 -> -1.1E+2
+ddred116 reduce -1.00E+2 -> -1E+2
+ddred117 reduce -1.100E+3 -> -1.1E+3
+ddred118 reduce -1.000E+3 -> -1E+3
+ddred119 reduce -1.00000E+5 -> -1E+5
+ddred120 reduce -1.000000E+6 -> -1E+6
+ddred121 reduce -10.00000E+6 -> -1E+7
+ddred122 reduce -100.0000E+6 -> -1E+8
+ddred123 reduce -1000.000E+6 -> -1E+9
+ddred124 reduce -10000.00E+6 -> -1E+10
+ddred125 reduce -100000.0E+6 -> -1E+11
+ddred126 reduce -1000000.E+6 -> -1E+12
+
+-- examples from decArith
+ddred140 reduce '2.1' -> '2.1'
+ddred141 reduce '-2.0' -> '-2'
+ddred142 reduce '1.200' -> '1.2'
+ddred143 reduce '-120' -> '-1.2E+2'
+ddred144 reduce '120.00' -> '1.2E+2'
+ddred145 reduce '0.00' -> '0'
+
+-- Nmax, Nmin, Ntiny
+-- note origami effect on some of these
+ddred151 reduce 9.999999999999999E+384 -> 9.999999999999999E+384
+ddred152 reduce 9.999999000000000E+380 -> 9.99999900000E+380
+ddred153 reduce 9.999999999990000E+384 -> 9.999999999990000E+384
+ddred154 reduce 1E-383 -> 1E-383
+ddred155 reduce 1.000000000000000E-383 -> 1E-383
+ddred156 reduce 2.000E-395 -> 2E-395 Subnormal
+ddred157 reduce 1E-398 -> 1E-398 Subnormal
+
+ddred161 reduce -1E-398 -> -1E-398 Subnormal
+ddred162 reduce -2.000E-395 -> -2E-395 Subnormal
+ddred163 reduce -1.000000000000000E-383 -> -1E-383
+ddred164 reduce -1E-383 -> -1E-383
+ddred165 reduce -9.999999000000000E+380 -> -9.99999900000E+380
+ddred166 reduce -9.999999999990000E+384 -> -9.999999999990000E+384
+ddred167 reduce -9.999999999999990E+384 -> -9.999999999999990E+384
+ddred168 reduce -9.999999999999999E+384 -> -9.999999999999999E+384
+ddred169 reduce -9.999999999999990E+384 -> -9.999999999999990E+384
+
+
+-- specials (reduce does not affect payload)
+ddred820 reduce 'Inf' -> 'Infinity'
+ddred821 reduce '-Inf' -> '-Infinity'
+ddred822 reduce NaN -> NaN
+ddred823 reduce sNaN -> NaN Invalid_operation
+ddred824 reduce NaN101 -> NaN101
+ddred825 reduce sNaN010 -> NaN10 Invalid_operation
+ddred827 reduce -NaN -> -NaN
+ddred828 reduce -sNaN -> -NaN Invalid_operation
+ddred829 reduce -NaN101 -> -NaN101
+ddred830 reduce -sNaN010 -> -NaN10 Invalid_operation
+
+-- Null test
+ddred900 reduce # -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddRemainder.decTest b/Lib/test/decimaltestdata/ddRemainder.decTest
index 85d86f9457..5bd1e32d01 100644
--- a/Lib/test/decimaltestdata/ddRemainder.decTest
+++ b/Lib/test/decimaltestdata/ddRemainder.decTest
@@ -1,600 +1,600 @@
-------------------------------------------------------------------------
--- ddRemainder.decTest -- decDouble remainder --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks (as base, above)
-ddrem001 remainder 1 1 -> 0
-ddrem002 remainder 2 1 -> 0
-ddrem003 remainder 1 2 -> 1
-ddrem004 remainder 2 2 -> 0
-ddrem005 remainder 0 1 -> 0
-ddrem006 remainder 0 2 -> 0
-ddrem007 remainder 1 3 -> 1
-ddrem008 remainder 2 3 -> 2
-ddrem009 remainder 3 3 -> 0
-
-ddrem010 remainder 2.4 1 -> 0.4
-ddrem011 remainder 2.4 -1 -> 0.4
-ddrem012 remainder -2.4 1 -> -0.4
-ddrem013 remainder -2.4 -1 -> -0.4
-ddrem014 remainder 2.40 1 -> 0.40
-ddrem015 remainder 2.400 1 -> 0.400
-ddrem016 remainder 2.4 2 -> 0.4
-ddrem017 remainder 2.400 2 -> 0.400
-ddrem018 remainder 2. 2 -> 0
-ddrem019 remainder 20 20 -> 0
-
-ddrem020 remainder 187 187 -> 0
-ddrem021 remainder 5 2 -> 1
-ddrem022 remainder 5 2.0 -> 1.0
-ddrem023 remainder 5 2.000 -> 1.000
-ddrem024 remainder 5 0.200 -> 0.000
-ddrem025 remainder 5 0.200 -> 0.000
-
-ddrem030 remainder 1 2 -> 1
-ddrem031 remainder 1 4 -> 1
-ddrem032 remainder 1 8 -> 1
-
-ddrem033 remainder 1 16 -> 1
-ddrem034 remainder 1 32 -> 1
-ddrem035 remainder 1 64 -> 1
-ddrem040 remainder 1 -2 -> 1
-ddrem041 remainder 1 -4 -> 1
-ddrem042 remainder 1 -8 -> 1
-ddrem043 remainder 1 -16 -> 1
-ddrem044 remainder 1 -32 -> 1
-ddrem045 remainder 1 -64 -> 1
-ddrem050 remainder -1 2 -> -1
-ddrem051 remainder -1 4 -> -1
-ddrem052 remainder -1 8 -> -1
-ddrem053 remainder -1 16 -> -1
-ddrem054 remainder -1 32 -> -1
-ddrem055 remainder -1 64 -> -1
-ddrem060 remainder -1 -2 -> -1
-ddrem061 remainder -1 -4 -> -1
-ddrem062 remainder -1 -8 -> -1
-ddrem063 remainder -1 -16 -> -1
-ddrem064 remainder -1 -32 -> -1
-ddrem065 remainder -1 -64 -> -1
-
-ddrem066 remainder 999999999 1 -> 0
-ddrem067 remainder 999999999.4 1 -> 0.4
-ddrem068 remainder 999999999.5 1 -> 0.5
-ddrem069 remainder 999999999.9 1 -> 0.9
-ddrem070 remainder 999999999.999 1 -> 0.999
-ddrem071 remainder 999999.999999 1 -> 0.999999
-ddrem072 remainder 9 1 -> 0
-ddrem073 remainder 9999999999999999 1 -> 0
-ddrem074 remainder 9999999999999999 2 -> 1
-ddrem075 remainder 9999999999999999 3 -> 0
-ddrem076 remainder 9999999999999999 4 -> 3
-
-ddrem080 remainder 0. 1 -> 0
-ddrem081 remainder .0 1 -> 0.0
-ddrem082 remainder 0.00 1 -> 0.00
-ddrem083 remainder 0.00E+9 1 -> 0
-ddrem084 remainder 0.00E+3 1 -> 0
-ddrem085 remainder 0.00E+2 1 -> 0
-ddrem086 remainder 0.00E+1 1 -> 0.0
-ddrem087 remainder 0.00E+0 1 -> 0.00
-ddrem088 remainder 0.00E-0 1 -> 0.00
-ddrem089 remainder 0.00E-1 1 -> 0.000
-ddrem090 remainder 0.00E-2 1 -> 0.0000
-ddrem091 remainder 0.00E-3 1 -> 0.00000
-ddrem092 remainder 0.00E-4 1 -> 0.000000
-ddrem093 remainder 0.00E-5 1 -> 0E-7
-ddrem094 remainder 0.00E-6 1 -> 0E-8
-ddrem095 remainder 0.0000E-50 1 -> 0E-54
-
--- Various flavours of remainder by 0
-ddrem101 remainder 0 0 -> NaN Division_undefined
-ddrem102 remainder 0 -0 -> NaN Division_undefined
-ddrem103 remainder -0 0 -> NaN Division_undefined
-ddrem104 remainder -0 -0 -> NaN Division_undefined
-ddrem105 remainder 0.0E5 0 -> NaN Division_undefined
-ddrem106 remainder 0.000 0 -> NaN Division_undefined
--- [Some think this next group should be Division_by_zero exception, but
--- IEEE 854 is explicit that it is Invalid operation .. for
--- remainder-near, anyway]
-ddrem107 remainder 0.0001 0 -> NaN Invalid_operation
-ddrem108 remainder 0.01 0 -> NaN Invalid_operation
-ddrem109 remainder 0.1 0 -> NaN Invalid_operation
-ddrem110 remainder 1 0 -> NaN Invalid_operation
-ddrem111 remainder 1 0.0 -> NaN Invalid_operation
-ddrem112 remainder 10 0.0 -> NaN Invalid_operation
-ddrem113 remainder 1E+100 0.0 -> NaN Invalid_operation
-ddrem114 remainder 1E+380 0 -> NaN Invalid_operation
-ddrem115 remainder 0.0001 -0 -> NaN Invalid_operation
-ddrem116 remainder 0.01 -0 -> NaN Invalid_operation
-ddrem119 remainder 0.1 -0 -> NaN Invalid_operation
-ddrem120 remainder 1 -0 -> NaN Invalid_operation
-ddrem121 remainder 1 -0.0 -> NaN Invalid_operation
-ddrem122 remainder 10 -0.0 -> NaN Invalid_operation
-ddrem123 remainder 1E+100 -0.0 -> NaN Invalid_operation
-ddrem124 remainder 1E+384 -0 -> NaN Invalid_operation
--- and zeros on left
-ddrem130 remainder 0 1 -> 0
-ddrem131 remainder 0 -1 -> 0
-ddrem132 remainder 0.0 1 -> 0.0
-ddrem133 remainder 0.0 -1 -> 0.0
-ddrem134 remainder -0 1 -> -0
-ddrem135 remainder -0 -1 -> -0
-ddrem136 remainder -0.0 1 -> -0.0
-ddrem137 remainder -0.0 -1 -> -0.0
-
--- 0.5ers
-ddrem143 remainder 0.5 2 -> 0.5
-ddrem144 remainder 0.5 2.1 -> 0.5
-ddrem145 remainder 0.5 2.01 -> 0.50
-ddrem146 remainder 0.5 2.001 -> 0.500
-ddrem147 remainder 0.50 2 -> 0.50
-ddrem148 remainder 0.50 2.01 -> 0.50
-ddrem149 remainder 0.50 2.001 -> 0.500
-
--- steadies
-ddrem150 remainder 1 1 -> 0
-ddrem151 remainder 1 2 -> 1
-ddrem152 remainder 1 3 -> 1
-ddrem153 remainder 1 4 -> 1
-ddrem154 remainder 1 5 -> 1
-ddrem155 remainder 1 6 -> 1
-ddrem156 remainder 1 7 -> 1
-ddrem157 remainder 1 8 -> 1
-ddrem158 remainder 1 9 -> 1
-ddrem159 remainder 1 10 -> 1
-ddrem160 remainder 1 1 -> 0
-ddrem161 remainder 2 1 -> 0
-ddrem162 remainder 3 1 -> 0
-ddrem163 remainder 4 1 -> 0
-ddrem164 remainder 5 1 -> 0
-ddrem165 remainder 6 1 -> 0
-ddrem166 remainder 7 1 -> 0
-ddrem167 remainder 8 1 -> 0
-ddrem168 remainder 9 1 -> 0
-ddrem169 remainder 10 1 -> 0
-
--- some differences from remainderNear
-ddrem171 remainder 0.4 1.020 -> 0.400
-ddrem172 remainder 0.50 1.020 -> 0.500
-ddrem173 remainder 0.51 1.020 -> 0.510
-ddrem174 remainder 0.52 1.020 -> 0.520
-ddrem175 remainder 0.6 1.020 -> 0.600
-
--- More flavours of remainder by 0
-ddrem201 remainder 0 0 -> NaN Division_undefined
-ddrem202 remainder 0.0E5 0 -> NaN Division_undefined
-ddrem203 remainder 0.000 0 -> NaN Division_undefined
-ddrem204 remainder 0.0001 0 -> NaN Invalid_operation
-ddrem205 remainder 0.01 0 -> NaN Invalid_operation
-ddrem206 remainder 0.1 0 -> NaN Invalid_operation
-ddrem207 remainder 1 0 -> NaN Invalid_operation
-ddrem208 remainder 1 0.0 -> NaN Invalid_operation
-ddrem209 remainder 10 0.0 -> NaN Invalid_operation
-ddrem210 remainder 1E+100 0.0 -> NaN Invalid_operation
-ddrem211 remainder 1E+380 0 -> NaN Invalid_operation
-
--- some differences from remainderNear
-ddrem231 remainder -0.4 1.020 -> -0.400
-ddrem232 remainder -0.50 1.020 -> -0.500
-ddrem233 remainder -0.51 1.020 -> -0.510
-ddrem234 remainder -0.52 1.020 -> -0.520
-ddrem235 remainder -0.6 1.020 -> -0.600
-
--- high Xs
-ddrem240 remainder 1E+2 1.00 -> 0.00
-
--- ddrem3xx are from DiagBigDecimal
-ddrem301 remainder 1 3 -> 1
-ddrem302 remainder 5 5 -> 0
-ddrem303 remainder 13 10 -> 3
-ddrem304 remainder 13 50 -> 13
-ddrem305 remainder 13 100 -> 13
-ddrem306 remainder 13 1000 -> 13
-ddrem307 remainder .13 1 -> 0.13
-ddrem308 remainder 0.133 1 -> 0.133
-ddrem309 remainder 0.1033 1 -> 0.1033
-ddrem310 remainder 1.033 1 -> 0.033
-ddrem311 remainder 10.33 1 -> 0.33
-ddrem312 remainder 10.33 10 -> 0.33
-ddrem313 remainder 103.3 1 -> 0.3
-ddrem314 remainder 133 10 -> 3
-ddrem315 remainder 1033 10 -> 3
-ddrem316 remainder 1033 50 -> 33
-ddrem317 remainder 101.0 3 -> 2.0
-ddrem318 remainder 102.0 3 -> 0.0
-ddrem319 remainder 103.0 3 -> 1.0
-ddrem320 remainder 2.40 1 -> 0.40
-ddrem321 remainder 2.400 1 -> 0.400
-ddrem322 remainder 2.4 1 -> 0.4
-ddrem323 remainder 2.4 2 -> 0.4
-ddrem324 remainder 2.400 2 -> 0.400
-ddrem325 remainder 1 0.3 -> 0.1
-ddrem326 remainder 1 0.30 -> 0.10
-ddrem327 remainder 1 0.300 -> 0.100
-ddrem328 remainder 1 0.3000 -> 0.1000
-ddrem329 remainder 1.0 0.3 -> 0.1
-ddrem330 remainder 1.00 0.3 -> 0.10
-ddrem331 remainder 1.000 0.3 -> 0.100
-ddrem332 remainder 1.0000 0.3 -> 0.1000
-ddrem333 remainder 0.5 2 -> 0.5
-ddrem334 remainder 0.5 2.1 -> 0.5
-ddrem335 remainder 0.5 2.01 -> 0.50
-ddrem336 remainder 0.5 2.001 -> 0.500
-ddrem337 remainder 0.50 2 -> 0.50
-ddrem338 remainder 0.50 2.01 -> 0.50
-ddrem339 remainder 0.50 2.001 -> 0.500
-
-ddrem340 remainder 0.5 0.5000001 -> 0.5000000
-ddrem341 remainder 0.5 0.50000001 -> 0.50000000
-ddrem342 remainder 0.5 0.500000001 -> 0.500000000
-ddrem343 remainder 0.5 0.5000000001 -> 0.5000000000
-ddrem344 remainder 0.5 0.50000000001 -> 0.50000000000
-ddrem345 remainder 0.5 0.4999999 -> 1E-7
-ddrem346 remainder 0.5 0.49999999 -> 1E-8
-ddrem347 remainder 0.5 0.499999999 -> 1E-9
-ddrem348 remainder 0.5 0.4999999999 -> 1E-10
-ddrem349 remainder 0.5 0.49999999999 -> 1E-11
-ddrem350 remainder 0.5 0.499999999999 -> 1E-12
-
-ddrem351 remainder 0.03 7 -> 0.03
-ddrem352 remainder 5 2 -> 1
-ddrem353 remainder 4.1 2 -> 0.1
-ddrem354 remainder 4.01 2 -> 0.01
-ddrem355 remainder 4.001 2 -> 0.001
-ddrem356 remainder 4.0001 2 -> 0.0001
-ddrem357 remainder 4.00001 2 -> 0.00001
-ddrem358 remainder 4.000001 2 -> 0.000001
-ddrem359 remainder 4.0000001 2 -> 1E-7
-
-ddrem360 remainder 1.2 0.7345 -> 0.4655
-ddrem361 remainder 0.8 12 -> 0.8
-ddrem362 remainder 0.8 0.2 -> 0.0
-ddrem363 remainder 0.8 0.3 -> 0.2
-ddrem364 remainder 0.800 12 -> 0.800
-ddrem365 remainder 0.800 1.7 -> 0.800
-ddrem366 remainder 2.400 2 -> 0.400
-
-ddrem371 remainder 2.400 2 -> 0.400
-
-ddrem381 remainder 12345 1 -> 0
-ddrem382 remainder 12345 1.0001 -> 0.7657
-ddrem383 remainder 12345 1.001 -> 0.668
-ddrem384 remainder 12345 1.01 -> 0.78
-ddrem385 remainder 12345 1.1 -> 0.8
-ddrem386 remainder 12355 4 -> 3
-ddrem387 remainder 12345 4 -> 1
-ddrem388 remainder 12355 4.0001 -> 2.6912
-ddrem389 remainder 12345 4.0001 -> 0.6914
-ddrem390 remainder 12345 4.9 -> 1.9
-ddrem391 remainder 12345 4.99 -> 4.73
-ddrem392 remainder 12345 4.999 -> 2.469
-ddrem393 remainder 12345 4.9999 -> 0.2469
-ddrem394 remainder 12345 5 -> 0
-ddrem395 remainder 12345 5.0001 -> 4.7532
-ddrem396 remainder 12345 5.001 -> 2.532
-ddrem397 remainder 12345 5.01 -> 0.36
-ddrem398 remainder 12345 5.1 -> 3.0
-
--- the nasty division-by-1 cases
-ddrem401 remainder 0.5 1 -> 0.5
-ddrem402 remainder 0.55 1 -> 0.55
-ddrem403 remainder 0.555 1 -> 0.555
-ddrem404 remainder 0.5555 1 -> 0.5555
-ddrem405 remainder 0.55555 1 -> 0.55555
-ddrem406 remainder 0.555555 1 -> 0.555555
-ddrem407 remainder 0.5555555 1 -> 0.5555555
-ddrem408 remainder 0.55555555 1 -> 0.55555555
-ddrem409 remainder 0.555555555 1 -> 0.555555555
-
--- folddowns
-ddrem421 remainder 1E+384 1 -> NaN Division_impossible
-ddrem422 remainder 1E+384 1E+383 -> 0E+369 Clamped
-ddrem423 remainder 1E+384 2E+383 -> 0E+369 Clamped
-ddrem424 remainder 1E+384 3E+383 -> 1.00000000000000E+383 Clamped
-ddrem425 remainder 1E+384 4E+383 -> 2.00000000000000E+383 Clamped
-ddrem426 remainder 1E+384 5E+383 -> 0E+369 Clamped
-ddrem427 remainder 1E+384 6E+383 -> 4.00000000000000E+383 Clamped
-ddrem428 remainder 1E+384 7E+383 -> 3.00000000000000E+383 Clamped
-ddrem429 remainder 1E+384 8E+383 -> 2.00000000000000E+383 Clamped
-ddrem430 remainder 1E+384 9E+383 -> 1.00000000000000E+383 Clamped
--- tinies
-ddrem431 remainder 1E-397 1E-398 -> 0E-398
-ddrem432 remainder 1E-397 2E-398 -> 0E-398
-ddrem433 remainder 1E-397 3E-398 -> 1E-398 Subnormal
-ddrem434 remainder 1E-397 4E-398 -> 2E-398 Subnormal
-ddrem435 remainder 1E-397 5E-398 -> 0E-398
-ddrem436 remainder 1E-397 6E-398 -> 4E-398 Subnormal
-ddrem437 remainder 1E-397 7E-398 -> 3E-398 Subnormal
-ddrem438 remainder 1E-397 8E-398 -> 2E-398 Subnormal
-ddrem439 remainder 1E-397 9E-398 -> 1E-398 Subnormal
-ddrem440 remainder 1E-397 10E-398 -> 0E-398
-ddrem441 remainder 1E-397 11E-398 -> 1.0E-397 Subnormal
-ddrem442 remainder 100E-397 11E-398 -> 1.0E-397 Subnormal
-ddrem443 remainder 100E-397 20E-398 -> 0E-398
-ddrem444 remainder 100E-397 21E-398 -> 1.3E-397 Subnormal
-ddrem445 remainder 100E-397 30E-398 -> 1.0E-397 Subnormal
-
--- zero signs
-ddrem650 remainder 1 1 -> 0
-ddrem651 remainder -1 1 -> -0
-ddrem652 remainder 1 -1 -> 0
-ddrem653 remainder -1 -1 -> -0
-ddrem654 remainder 0 1 -> 0
-ddrem655 remainder -0 1 -> -0
-ddrem656 remainder 0 -1 -> 0
-ddrem657 remainder -0 -1 -> -0
-ddrem658 remainder 0.00 1 -> 0.00
-ddrem659 remainder -0.00 1 -> -0.00
-
--- Specials
-ddrem680 remainder Inf -Inf -> NaN Invalid_operation
-ddrem681 remainder Inf -1000 -> NaN Invalid_operation
-ddrem682 remainder Inf -1 -> NaN Invalid_operation
-ddrem683 remainder Inf 0 -> NaN Invalid_operation
-ddrem684 remainder Inf -0 -> NaN Invalid_operation
-ddrem685 remainder Inf 1 -> NaN Invalid_operation
-ddrem686 remainder Inf 1000 -> NaN Invalid_operation
-ddrem687 remainder Inf Inf -> NaN Invalid_operation
-ddrem688 remainder -1000 Inf -> -1000
-ddrem689 remainder -Inf Inf -> NaN Invalid_operation
-ddrem691 remainder -1 Inf -> -1
-ddrem692 remainder 0 Inf -> 0
-ddrem693 remainder -0 Inf -> -0
-ddrem694 remainder 1 Inf -> 1
-ddrem695 remainder 1000 Inf -> 1000
-ddrem696 remainder Inf Inf -> NaN Invalid_operation
-
-ddrem700 remainder -Inf -Inf -> NaN Invalid_operation
-ddrem701 remainder -Inf -1000 -> NaN Invalid_operation
-ddrem702 remainder -Inf -1 -> NaN Invalid_operation
-ddrem703 remainder -Inf -0 -> NaN Invalid_operation
-ddrem704 remainder -Inf 0 -> NaN Invalid_operation
-ddrem705 remainder -Inf 1 -> NaN Invalid_operation
-ddrem706 remainder -Inf 1000 -> NaN Invalid_operation
-ddrem707 remainder -Inf Inf -> NaN Invalid_operation
-ddrem708 remainder -Inf -Inf -> NaN Invalid_operation
-ddrem709 remainder -1000 Inf -> -1000
-ddrem710 remainder -1 -Inf -> -1
-ddrem711 remainder -0 -Inf -> -0
-ddrem712 remainder 0 -Inf -> 0
-ddrem713 remainder 1 -Inf -> 1
-ddrem714 remainder 1000 -Inf -> 1000
-ddrem715 remainder Inf -Inf -> NaN Invalid_operation
-
-ddrem721 remainder NaN -Inf -> NaN
-ddrem722 remainder NaN -1000 -> NaN
-ddrem723 remainder NaN -1 -> NaN
-ddrem724 remainder NaN -0 -> NaN
-ddrem725 remainder -NaN 0 -> -NaN
-ddrem726 remainder NaN 1 -> NaN
-ddrem727 remainder NaN 1000 -> NaN
-ddrem728 remainder NaN Inf -> NaN
-ddrem729 remainder NaN -NaN -> NaN
-ddrem730 remainder -Inf NaN -> NaN
-ddrem731 remainder -1000 NaN -> NaN
-ddrem732 remainder -1 NaN -> NaN
-ddrem733 remainder -0 -NaN -> -NaN
-ddrem734 remainder 0 NaN -> NaN
-ddrem735 remainder 1 -NaN -> -NaN
-ddrem736 remainder 1000 NaN -> NaN
-ddrem737 remainder Inf NaN -> NaN
-
-ddrem741 remainder sNaN -Inf -> NaN Invalid_operation
-ddrem742 remainder sNaN -1000 -> NaN Invalid_operation
-ddrem743 remainder -sNaN -1 -> -NaN Invalid_operation
-ddrem744 remainder sNaN -0 -> NaN Invalid_operation
-ddrem745 remainder sNaN 0 -> NaN Invalid_operation
-ddrem746 remainder sNaN 1 -> NaN Invalid_operation
-ddrem747 remainder sNaN 1000 -> NaN Invalid_operation
-ddrem749 remainder sNaN NaN -> NaN Invalid_operation
-ddrem750 remainder sNaN sNaN -> NaN Invalid_operation
-ddrem751 remainder NaN sNaN -> NaN Invalid_operation
-ddrem752 remainder -Inf sNaN -> NaN Invalid_operation
-ddrem753 remainder -1000 sNaN -> NaN Invalid_operation
-ddrem754 remainder -1 sNaN -> NaN Invalid_operation
-ddrem755 remainder -0 sNaN -> NaN Invalid_operation
-ddrem756 remainder 0 sNaN -> NaN Invalid_operation
-ddrem757 remainder 1 sNaN -> NaN Invalid_operation
-ddrem758 remainder 1000 sNaN -> NaN Invalid_operation
-ddrem759 remainder Inf -sNaN -> -NaN Invalid_operation
-
--- propaging NaNs
-ddrem760 remainder NaN1 NaN7 -> NaN1
-ddrem761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation
-ddrem762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation
-ddrem763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation
-ddrem764 remainder 15 NaN11 -> NaN11
-ddrem765 remainder NaN6 NaN12 -> NaN6
-ddrem766 remainder Inf NaN13 -> NaN13
-ddrem767 remainder NaN14 -Inf -> NaN14
-ddrem768 remainder 0 NaN15 -> NaN15
-ddrem769 remainder NaN16 -0 -> NaN16
-
--- edge cases of impossible
-ddrem770 remainder 1234567890123456 10 -> 6
-ddrem771 remainder 1234567890123456 1 -> 0
-ddrem772 remainder 1234567890123456 0.1 -> NaN Division_impossible
-ddrem773 remainder 1234567890123456 0.01 -> NaN Division_impossible
-
--- long operand checks
-ddrem801 remainder 12345678000 100 -> 0
-ddrem802 remainder 1 12345678000 -> 1
-ddrem803 remainder 1234567800 10 -> 0
-ddrem804 remainder 1 1234567800 -> 1
-ddrem805 remainder 1234567890 10 -> 0
-ddrem806 remainder 1 1234567890 -> 1
-ddrem807 remainder 1234567891 10 -> 1
-ddrem808 remainder 1 1234567891 -> 1
-ddrem809 remainder 12345678901 100 -> 1
-ddrem810 remainder 1 12345678901 -> 1
-ddrem811 remainder 1234567896 10 -> 6
-ddrem812 remainder 1 1234567896 -> 1
-
-ddrem821 remainder 12345678000 100 -> 0
-ddrem822 remainder 1 12345678000 -> 1
-ddrem823 remainder 1234567800 10 -> 0
-ddrem824 remainder 1 1234567800 -> 1
-ddrem825 remainder 1234567890 10 -> 0
-ddrem826 remainder 1 1234567890 -> 1
-ddrem827 remainder 1234567891 10 -> 1
-ddrem828 remainder 1 1234567891 -> 1
-ddrem829 remainder 12345678901 100 -> 1
-ddrem830 remainder 1 12345678901 -> 1
-ddrem831 remainder 1234567896 10 -> 6
-ddrem832 remainder 1 1234567896 -> 1
-
--- from divideint
-ddrem840 remainder 100000000.0 1 -> 0.0
-ddrem841 remainder 100000000.4 1 -> 0.4
-ddrem842 remainder 100000000.5 1 -> 0.5
-ddrem843 remainder 100000000.9 1 -> 0.9
-ddrem844 remainder 100000000.999 1 -> 0.999
-ddrem850 remainder 100000003 5 -> 3
-ddrem851 remainder 10000003 5 -> 3
-ddrem852 remainder 1000003 5 -> 3
-ddrem853 remainder 100003 5 -> 3
-ddrem854 remainder 10003 5 -> 3
-ddrem855 remainder 1003 5 -> 3
-ddrem856 remainder 103 5 -> 3
-ddrem857 remainder 13 5 -> 3
-ddrem858 remainder 1 5 -> 1
-
--- Vladimir's cases 1234567890123456
-ddrem860 remainder 123.0e1 1000000000000000 -> 1230
-ddrem861 remainder 1230 1000000000000000 -> 1230
-ddrem862 remainder 12.3e2 1000000000000000 -> 1230
-ddrem863 remainder 1.23e3 1000000000000000 -> 1230
-ddrem864 remainder 123e1 1000000000000000 -> 1230
-ddrem870 remainder 123e1 1000000000000000 -> 1230
-ddrem871 remainder 123e1 100000000000000 -> 1230
-ddrem872 remainder 123e1 10000000000000 -> 1230
-ddrem873 remainder 123e1 1000000000000 -> 1230
-ddrem874 remainder 123e1 100000000000 -> 1230
-ddrem875 remainder 123e1 10000000000 -> 1230
-ddrem876 remainder 123e1 1000000000 -> 1230
-ddrem877 remainder 123e1 100000000 -> 1230
-ddrem878 remainder 1230 100000000 -> 1230
-ddrem879 remainder 123e1 10000000 -> 1230
-ddrem880 remainder 123e1 1000000 -> 1230
-ddrem881 remainder 123e1 100000 -> 1230
-ddrem882 remainder 123e1 10000 -> 1230
-ddrem883 remainder 123e1 1000 -> 230
-ddrem884 remainder 123e1 100 -> 30
-ddrem885 remainder 123e1 10 -> 0
-ddrem886 remainder 123e1 1 -> 0
-
-ddrem890 remainder 123e1 2000000000000000 -> 1230
-ddrem891 remainder 123e1 200000000000000 -> 1230
-ddrem892 remainder 123e1 20000000000000 -> 1230
-ddrem893 remainder 123e1 2000000000000 -> 1230
-ddrem894 remainder 123e1 200000000000 -> 1230
-ddrem895 remainder 123e1 20000000000 -> 1230
-ddrem896 remainder 123e1 2000000000 -> 1230
-ddrem897 remainder 123e1 200000000 -> 1230
-ddrem899 remainder 123e1 20000000 -> 1230
-ddrem900 remainder 123e1 2000000 -> 1230
-ddrem901 remainder 123e1 200000 -> 1230
-ddrem902 remainder 123e1 20000 -> 1230
-ddrem903 remainder 123e1 2000 -> 1230
-ddrem904 remainder 123e1 200 -> 30
-ddrem905 remainder 123e1 20 -> 10
-ddrem906 remainder 123e1 2 -> 0
-
-ddrem910 remainder 123e1 5000000000000000 -> 1230
-ddrem911 remainder 123e1 500000000000000 -> 1230
-ddrem912 remainder 123e1 50000000000000 -> 1230
-ddrem913 remainder 123e1 5000000000000 -> 1230
-ddrem914 remainder 123e1 500000000000 -> 1230
-ddrem915 remainder 123e1 50000000000 -> 1230
-ddrem916 remainder 123e1 5000000000 -> 1230
-ddrem917 remainder 123e1 500000000 -> 1230
-ddrem919 remainder 123e1 50000000 -> 1230
-ddrem920 remainder 123e1 5000000 -> 1230
-ddrem921 remainder 123e1 500000 -> 1230
-ddrem922 remainder 123e1 50000 -> 1230
-ddrem923 remainder 123e1 5000 -> 1230
-ddrem924 remainder 123e1 500 -> 230
-ddrem925 remainder 123e1 50 -> 30
-ddrem926 remainder 123e1 5 -> 0
-
-ddrem930 remainder 123e1 9000000000000000 -> 1230
-ddrem931 remainder 123e1 900000000000000 -> 1230
-ddrem932 remainder 123e1 90000000000000 -> 1230
-ddrem933 remainder 123e1 9000000000000 -> 1230
-ddrem934 remainder 123e1 900000000000 -> 1230
-ddrem935 remainder 123e1 90000000000 -> 1230
-ddrem936 remainder 123e1 9000000000 -> 1230
-ddrem937 remainder 123e1 900000000 -> 1230
-ddrem939 remainder 123e1 90000000 -> 1230
-ddrem940 remainder 123e1 9000000 -> 1230
-ddrem941 remainder 123e1 900000 -> 1230
-ddrem942 remainder 123e1 90000 -> 1230
-ddrem943 remainder 123e1 9000 -> 1230
-ddrem944 remainder 123e1 900 -> 330
-ddrem945 remainder 123e1 90 -> 60
-ddrem946 remainder 123e1 9 -> 6
-
-ddrem950 remainder 123e1 1000000000000000 -> 1230
-ddrem961 remainder 123e1 2999999999999999 -> 1230
-ddrem962 remainder 123e1 3999999999999999 -> 1230
-ddrem963 remainder 123e1 4999999999999999 -> 1230
-ddrem964 remainder 123e1 5999999999999999 -> 1230
-ddrem965 remainder 123e1 6999999999999999 -> 1230
-ddrem966 remainder 123e1 7999999999999999 -> 1230
-ddrem967 remainder 123e1 8999999999999999 -> 1230
-ddrem968 remainder 123e1 9999999999999999 -> 1230
-ddrem969 remainder 123e1 9876543210987654 -> 1230
-
-ddrem980 remainder 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
-
--- overflow and underflow tests [from divide]
-ddrem1051 remainder 1e+277 1e-311 -> NaN Division_impossible
-ddrem1052 remainder 1e+277 -1e-311 -> NaN Division_impossible
-ddrem1053 remainder -1e+277 1e-311 -> NaN Division_impossible
-ddrem1054 remainder -1e+277 -1e-311 -> NaN Division_impossible
-ddrem1055 remainder 1e-277 1e+311 -> 1E-277
-ddrem1056 remainder 1e-277 -1e+311 -> 1E-277
-ddrem1057 remainder -1e-277 1e+311 -> -1E-277
-ddrem1058 remainder -1e-277 -1e+311 -> -1E-277
-
--- destructive subtract
-ddrem1101 remainder 1234567890123456 1.000000000000001 -> 0.765432109876546
-ddrem1102 remainder 1234567890123456 1.00000000000001 -> 0.65432109876557
-ddrem1103 remainder 1234567890123456 1.0000000000001 -> 0.5432109876668
-ddrem1104 remainder 1234567890123455 4.000000000000001 -> 2.691358027469137
-ddrem1105 remainder 1234567890123456 4.000000000000001 -> 3.691358027469137
-ddrem1106 remainder 1234567890123456 4.9999999999999 -> 0.6913578024696
-ddrem1107 remainder 1234567890123456 4.99999999999999 -> 3.46913578024691
-ddrem1108 remainder 1234567890123456 4.999999999999999 -> 1.246913578024691
-ddrem1109 remainder 1234567890123456 5.000000000000001 -> 0.753086421975309
-ddrem1110 remainder 1234567890123456 5.00000000000001 -> 3.53086421975310
-ddrem1111 remainder 1234567890123456 5.0000000000001 -> 1.3086421975314
-
--- Null tests
-ddrem1000 remainder 10 # -> NaN Invalid_operation
-ddrem1001 remainder # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddRemainder.decTest -- decDouble remainder --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks (as base, above)
+ddrem001 remainder 1 1 -> 0
+ddrem002 remainder 2 1 -> 0
+ddrem003 remainder 1 2 -> 1
+ddrem004 remainder 2 2 -> 0
+ddrem005 remainder 0 1 -> 0
+ddrem006 remainder 0 2 -> 0
+ddrem007 remainder 1 3 -> 1
+ddrem008 remainder 2 3 -> 2
+ddrem009 remainder 3 3 -> 0
+
+ddrem010 remainder 2.4 1 -> 0.4
+ddrem011 remainder 2.4 -1 -> 0.4
+ddrem012 remainder -2.4 1 -> -0.4
+ddrem013 remainder -2.4 -1 -> -0.4
+ddrem014 remainder 2.40 1 -> 0.40
+ddrem015 remainder 2.400 1 -> 0.400
+ddrem016 remainder 2.4 2 -> 0.4
+ddrem017 remainder 2.400 2 -> 0.400
+ddrem018 remainder 2. 2 -> 0
+ddrem019 remainder 20 20 -> 0
+
+ddrem020 remainder 187 187 -> 0
+ddrem021 remainder 5 2 -> 1
+ddrem022 remainder 5 2.0 -> 1.0
+ddrem023 remainder 5 2.000 -> 1.000
+ddrem024 remainder 5 0.200 -> 0.000
+ddrem025 remainder 5 0.200 -> 0.000
+
+ddrem030 remainder 1 2 -> 1
+ddrem031 remainder 1 4 -> 1
+ddrem032 remainder 1 8 -> 1
+
+ddrem033 remainder 1 16 -> 1
+ddrem034 remainder 1 32 -> 1
+ddrem035 remainder 1 64 -> 1
+ddrem040 remainder 1 -2 -> 1
+ddrem041 remainder 1 -4 -> 1
+ddrem042 remainder 1 -8 -> 1
+ddrem043 remainder 1 -16 -> 1
+ddrem044 remainder 1 -32 -> 1
+ddrem045 remainder 1 -64 -> 1
+ddrem050 remainder -1 2 -> -1
+ddrem051 remainder -1 4 -> -1
+ddrem052 remainder -1 8 -> -1
+ddrem053 remainder -1 16 -> -1
+ddrem054 remainder -1 32 -> -1
+ddrem055 remainder -1 64 -> -1
+ddrem060 remainder -1 -2 -> -1
+ddrem061 remainder -1 -4 -> -1
+ddrem062 remainder -1 -8 -> -1
+ddrem063 remainder -1 -16 -> -1
+ddrem064 remainder -1 -32 -> -1
+ddrem065 remainder -1 -64 -> -1
+
+ddrem066 remainder 999999999 1 -> 0
+ddrem067 remainder 999999999.4 1 -> 0.4
+ddrem068 remainder 999999999.5 1 -> 0.5
+ddrem069 remainder 999999999.9 1 -> 0.9
+ddrem070 remainder 999999999.999 1 -> 0.999
+ddrem071 remainder 999999.999999 1 -> 0.999999
+ddrem072 remainder 9 1 -> 0
+ddrem073 remainder 9999999999999999 1 -> 0
+ddrem074 remainder 9999999999999999 2 -> 1
+ddrem075 remainder 9999999999999999 3 -> 0
+ddrem076 remainder 9999999999999999 4 -> 3
+
+ddrem080 remainder 0. 1 -> 0
+ddrem081 remainder .0 1 -> 0.0
+ddrem082 remainder 0.00 1 -> 0.00
+ddrem083 remainder 0.00E+9 1 -> 0
+ddrem084 remainder 0.00E+3 1 -> 0
+ddrem085 remainder 0.00E+2 1 -> 0
+ddrem086 remainder 0.00E+1 1 -> 0.0
+ddrem087 remainder 0.00E+0 1 -> 0.00
+ddrem088 remainder 0.00E-0 1 -> 0.00
+ddrem089 remainder 0.00E-1 1 -> 0.000
+ddrem090 remainder 0.00E-2 1 -> 0.0000
+ddrem091 remainder 0.00E-3 1 -> 0.00000
+ddrem092 remainder 0.00E-4 1 -> 0.000000
+ddrem093 remainder 0.00E-5 1 -> 0E-7
+ddrem094 remainder 0.00E-6 1 -> 0E-8
+ddrem095 remainder 0.0000E-50 1 -> 0E-54
+
+-- Various flavours of remainder by 0
+ddrem101 remainder 0 0 -> NaN Division_undefined
+ddrem102 remainder 0 -0 -> NaN Division_undefined
+ddrem103 remainder -0 0 -> NaN Division_undefined
+ddrem104 remainder -0 -0 -> NaN Division_undefined
+ddrem105 remainder 0.0E5 0 -> NaN Division_undefined
+ddrem106 remainder 0.000 0 -> NaN Division_undefined
+-- [Some think this next group should be Division_by_zero exception, but
+-- IEEE 854 is explicit that it is Invalid operation .. for
+-- remainder-near, anyway]
+ddrem107 remainder 0.0001 0 -> NaN Invalid_operation
+ddrem108 remainder 0.01 0 -> NaN Invalid_operation
+ddrem109 remainder 0.1 0 -> NaN Invalid_operation
+ddrem110 remainder 1 0 -> NaN Invalid_operation
+ddrem111 remainder 1 0.0 -> NaN Invalid_operation
+ddrem112 remainder 10 0.0 -> NaN Invalid_operation
+ddrem113 remainder 1E+100 0.0 -> NaN Invalid_operation
+ddrem114 remainder 1E+380 0 -> NaN Invalid_operation
+ddrem115 remainder 0.0001 -0 -> NaN Invalid_operation
+ddrem116 remainder 0.01 -0 -> NaN Invalid_operation
+ddrem119 remainder 0.1 -0 -> NaN Invalid_operation
+ddrem120 remainder 1 -0 -> NaN Invalid_operation
+ddrem121 remainder 1 -0.0 -> NaN Invalid_operation
+ddrem122 remainder 10 -0.0 -> NaN Invalid_operation
+ddrem123 remainder 1E+100 -0.0 -> NaN Invalid_operation
+ddrem124 remainder 1E+384 -0 -> NaN Invalid_operation
+-- and zeros on left
+ddrem130 remainder 0 1 -> 0
+ddrem131 remainder 0 -1 -> 0
+ddrem132 remainder 0.0 1 -> 0.0
+ddrem133 remainder 0.0 -1 -> 0.0
+ddrem134 remainder -0 1 -> -0
+ddrem135 remainder -0 -1 -> -0
+ddrem136 remainder -0.0 1 -> -0.0
+ddrem137 remainder -0.0 -1 -> -0.0
+
+-- 0.5ers
+ddrem143 remainder 0.5 2 -> 0.5
+ddrem144 remainder 0.5 2.1 -> 0.5
+ddrem145 remainder 0.5 2.01 -> 0.50
+ddrem146 remainder 0.5 2.001 -> 0.500
+ddrem147 remainder 0.50 2 -> 0.50
+ddrem148 remainder 0.50 2.01 -> 0.50
+ddrem149 remainder 0.50 2.001 -> 0.500
+
+-- steadies
+ddrem150 remainder 1 1 -> 0
+ddrem151 remainder 1 2 -> 1
+ddrem152 remainder 1 3 -> 1
+ddrem153 remainder 1 4 -> 1
+ddrem154 remainder 1 5 -> 1
+ddrem155 remainder 1 6 -> 1
+ddrem156 remainder 1 7 -> 1
+ddrem157 remainder 1 8 -> 1
+ddrem158 remainder 1 9 -> 1
+ddrem159 remainder 1 10 -> 1
+ddrem160 remainder 1 1 -> 0
+ddrem161 remainder 2 1 -> 0
+ddrem162 remainder 3 1 -> 0
+ddrem163 remainder 4 1 -> 0
+ddrem164 remainder 5 1 -> 0
+ddrem165 remainder 6 1 -> 0
+ddrem166 remainder 7 1 -> 0
+ddrem167 remainder 8 1 -> 0
+ddrem168 remainder 9 1 -> 0
+ddrem169 remainder 10 1 -> 0
+
+-- some differences from remainderNear
+ddrem171 remainder 0.4 1.020 -> 0.400
+ddrem172 remainder 0.50 1.020 -> 0.500
+ddrem173 remainder 0.51 1.020 -> 0.510
+ddrem174 remainder 0.52 1.020 -> 0.520
+ddrem175 remainder 0.6 1.020 -> 0.600
+
+-- More flavours of remainder by 0
+ddrem201 remainder 0 0 -> NaN Division_undefined
+ddrem202 remainder 0.0E5 0 -> NaN Division_undefined
+ddrem203 remainder 0.000 0 -> NaN Division_undefined
+ddrem204 remainder 0.0001 0 -> NaN Invalid_operation
+ddrem205 remainder 0.01 0 -> NaN Invalid_operation
+ddrem206 remainder 0.1 0 -> NaN Invalid_operation
+ddrem207 remainder 1 0 -> NaN Invalid_operation
+ddrem208 remainder 1 0.0 -> NaN Invalid_operation
+ddrem209 remainder 10 0.0 -> NaN Invalid_operation
+ddrem210 remainder 1E+100 0.0 -> NaN Invalid_operation
+ddrem211 remainder 1E+380 0 -> NaN Invalid_operation
+
+-- some differences from remainderNear
+ddrem231 remainder -0.4 1.020 -> -0.400
+ddrem232 remainder -0.50 1.020 -> -0.500
+ddrem233 remainder -0.51 1.020 -> -0.510
+ddrem234 remainder -0.52 1.020 -> -0.520
+ddrem235 remainder -0.6 1.020 -> -0.600
+
+-- high Xs
+ddrem240 remainder 1E+2 1.00 -> 0.00
+
+-- ddrem3xx are from DiagBigDecimal
+ddrem301 remainder 1 3 -> 1
+ddrem302 remainder 5 5 -> 0
+ddrem303 remainder 13 10 -> 3
+ddrem304 remainder 13 50 -> 13
+ddrem305 remainder 13 100 -> 13
+ddrem306 remainder 13 1000 -> 13
+ddrem307 remainder .13 1 -> 0.13
+ddrem308 remainder 0.133 1 -> 0.133
+ddrem309 remainder 0.1033 1 -> 0.1033
+ddrem310 remainder 1.033 1 -> 0.033
+ddrem311 remainder 10.33 1 -> 0.33
+ddrem312 remainder 10.33 10 -> 0.33
+ddrem313 remainder 103.3 1 -> 0.3
+ddrem314 remainder 133 10 -> 3
+ddrem315 remainder 1033 10 -> 3
+ddrem316 remainder 1033 50 -> 33
+ddrem317 remainder 101.0 3 -> 2.0
+ddrem318 remainder 102.0 3 -> 0.0
+ddrem319 remainder 103.0 3 -> 1.0
+ddrem320 remainder 2.40 1 -> 0.40
+ddrem321 remainder 2.400 1 -> 0.400
+ddrem322 remainder 2.4 1 -> 0.4
+ddrem323 remainder 2.4 2 -> 0.4
+ddrem324 remainder 2.400 2 -> 0.400
+ddrem325 remainder 1 0.3 -> 0.1
+ddrem326 remainder 1 0.30 -> 0.10
+ddrem327 remainder 1 0.300 -> 0.100
+ddrem328 remainder 1 0.3000 -> 0.1000
+ddrem329 remainder 1.0 0.3 -> 0.1
+ddrem330 remainder 1.00 0.3 -> 0.10
+ddrem331 remainder 1.000 0.3 -> 0.100
+ddrem332 remainder 1.0000 0.3 -> 0.1000
+ddrem333 remainder 0.5 2 -> 0.5
+ddrem334 remainder 0.5 2.1 -> 0.5
+ddrem335 remainder 0.5 2.01 -> 0.50
+ddrem336 remainder 0.5 2.001 -> 0.500
+ddrem337 remainder 0.50 2 -> 0.50
+ddrem338 remainder 0.50 2.01 -> 0.50
+ddrem339 remainder 0.50 2.001 -> 0.500
+
+ddrem340 remainder 0.5 0.5000001 -> 0.5000000
+ddrem341 remainder 0.5 0.50000001 -> 0.50000000
+ddrem342 remainder 0.5 0.500000001 -> 0.500000000
+ddrem343 remainder 0.5 0.5000000001 -> 0.5000000000
+ddrem344 remainder 0.5 0.50000000001 -> 0.50000000000
+ddrem345 remainder 0.5 0.4999999 -> 1E-7
+ddrem346 remainder 0.5 0.49999999 -> 1E-8
+ddrem347 remainder 0.5 0.499999999 -> 1E-9
+ddrem348 remainder 0.5 0.4999999999 -> 1E-10
+ddrem349 remainder 0.5 0.49999999999 -> 1E-11
+ddrem350 remainder 0.5 0.499999999999 -> 1E-12
+
+ddrem351 remainder 0.03 7 -> 0.03
+ddrem352 remainder 5 2 -> 1
+ddrem353 remainder 4.1 2 -> 0.1
+ddrem354 remainder 4.01 2 -> 0.01
+ddrem355 remainder 4.001 2 -> 0.001
+ddrem356 remainder 4.0001 2 -> 0.0001
+ddrem357 remainder 4.00001 2 -> 0.00001
+ddrem358 remainder 4.000001 2 -> 0.000001
+ddrem359 remainder 4.0000001 2 -> 1E-7
+
+ddrem360 remainder 1.2 0.7345 -> 0.4655
+ddrem361 remainder 0.8 12 -> 0.8
+ddrem362 remainder 0.8 0.2 -> 0.0
+ddrem363 remainder 0.8 0.3 -> 0.2
+ddrem364 remainder 0.800 12 -> 0.800
+ddrem365 remainder 0.800 1.7 -> 0.800
+ddrem366 remainder 2.400 2 -> 0.400
+
+ddrem371 remainder 2.400 2 -> 0.400
+
+ddrem381 remainder 12345 1 -> 0
+ddrem382 remainder 12345 1.0001 -> 0.7657
+ddrem383 remainder 12345 1.001 -> 0.668
+ddrem384 remainder 12345 1.01 -> 0.78
+ddrem385 remainder 12345 1.1 -> 0.8
+ddrem386 remainder 12355 4 -> 3
+ddrem387 remainder 12345 4 -> 1
+ddrem388 remainder 12355 4.0001 -> 2.6912
+ddrem389 remainder 12345 4.0001 -> 0.6914
+ddrem390 remainder 12345 4.9 -> 1.9
+ddrem391 remainder 12345 4.99 -> 4.73
+ddrem392 remainder 12345 4.999 -> 2.469
+ddrem393 remainder 12345 4.9999 -> 0.2469
+ddrem394 remainder 12345 5 -> 0
+ddrem395 remainder 12345 5.0001 -> 4.7532
+ddrem396 remainder 12345 5.001 -> 2.532
+ddrem397 remainder 12345 5.01 -> 0.36
+ddrem398 remainder 12345 5.1 -> 3.0
+
+-- the nasty division-by-1 cases
+ddrem401 remainder 0.5 1 -> 0.5
+ddrem402 remainder 0.55 1 -> 0.55
+ddrem403 remainder 0.555 1 -> 0.555
+ddrem404 remainder 0.5555 1 -> 0.5555
+ddrem405 remainder 0.55555 1 -> 0.55555
+ddrem406 remainder 0.555555 1 -> 0.555555
+ddrem407 remainder 0.5555555 1 -> 0.5555555
+ddrem408 remainder 0.55555555 1 -> 0.55555555
+ddrem409 remainder 0.555555555 1 -> 0.555555555
+
+-- folddowns
+ddrem421 remainder 1E+384 1 -> NaN Division_impossible
+ddrem422 remainder 1E+384 1E+383 -> 0E+369 Clamped
+ddrem423 remainder 1E+384 2E+383 -> 0E+369 Clamped
+ddrem424 remainder 1E+384 3E+383 -> 1.00000000000000E+383 Clamped
+ddrem425 remainder 1E+384 4E+383 -> 2.00000000000000E+383 Clamped
+ddrem426 remainder 1E+384 5E+383 -> 0E+369 Clamped
+ddrem427 remainder 1E+384 6E+383 -> 4.00000000000000E+383 Clamped
+ddrem428 remainder 1E+384 7E+383 -> 3.00000000000000E+383 Clamped
+ddrem429 remainder 1E+384 8E+383 -> 2.00000000000000E+383 Clamped
+ddrem430 remainder 1E+384 9E+383 -> 1.00000000000000E+383 Clamped
+-- tinies
+ddrem431 remainder 1E-397 1E-398 -> 0E-398
+ddrem432 remainder 1E-397 2E-398 -> 0E-398
+ddrem433 remainder 1E-397 3E-398 -> 1E-398 Subnormal
+ddrem434 remainder 1E-397 4E-398 -> 2E-398 Subnormal
+ddrem435 remainder 1E-397 5E-398 -> 0E-398
+ddrem436 remainder 1E-397 6E-398 -> 4E-398 Subnormal
+ddrem437 remainder 1E-397 7E-398 -> 3E-398 Subnormal
+ddrem438 remainder 1E-397 8E-398 -> 2E-398 Subnormal
+ddrem439 remainder 1E-397 9E-398 -> 1E-398 Subnormal
+ddrem440 remainder 1E-397 10E-398 -> 0E-398
+ddrem441 remainder 1E-397 11E-398 -> 1.0E-397 Subnormal
+ddrem442 remainder 100E-397 11E-398 -> 1.0E-397 Subnormal
+ddrem443 remainder 100E-397 20E-398 -> 0E-398
+ddrem444 remainder 100E-397 21E-398 -> 1.3E-397 Subnormal
+ddrem445 remainder 100E-397 30E-398 -> 1.0E-397 Subnormal
+
+-- zero signs
+ddrem650 remainder 1 1 -> 0
+ddrem651 remainder -1 1 -> -0
+ddrem652 remainder 1 -1 -> 0
+ddrem653 remainder -1 -1 -> -0
+ddrem654 remainder 0 1 -> 0
+ddrem655 remainder -0 1 -> -0
+ddrem656 remainder 0 -1 -> 0
+ddrem657 remainder -0 -1 -> -0
+ddrem658 remainder 0.00 1 -> 0.00
+ddrem659 remainder -0.00 1 -> -0.00
+
+-- Specials
+ddrem680 remainder Inf -Inf -> NaN Invalid_operation
+ddrem681 remainder Inf -1000 -> NaN Invalid_operation
+ddrem682 remainder Inf -1 -> NaN Invalid_operation
+ddrem683 remainder Inf 0 -> NaN Invalid_operation
+ddrem684 remainder Inf -0 -> NaN Invalid_operation
+ddrem685 remainder Inf 1 -> NaN Invalid_operation
+ddrem686 remainder Inf 1000 -> NaN Invalid_operation
+ddrem687 remainder Inf Inf -> NaN Invalid_operation
+ddrem688 remainder -1000 Inf -> -1000
+ddrem689 remainder -Inf Inf -> NaN Invalid_operation
+ddrem691 remainder -1 Inf -> -1
+ddrem692 remainder 0 Inf -> 0
+ddrem693 remainder -0 Inf -> -0
+ddrem694 remainder 1 Inf -> 1
+ddrem695 remainder 1000 Inf -> 1000
+ddrem696 remainder Inf Inf -> NaN Invalid_operation
+
+ddrem700 remainder -Inf -Inf -> NaN Invalid_operation
+ddrem701 remainder -Inf -1000 -> NaN Invalid_operation
+ddrem702 remainder -Inf -1 -> NaN Invalid_operation
+ddrem703 remainder -Inf -0 -> NaN Invalid_operation
+ddrem704 remainder -Inf 0 -> NaN Invalid_operation
+ddrem705 remainder -Inf 1 -> NaN Invalid_operation
+ddrem706 remainder -Inf 1000 -> NaN Invalid_operation
+ddrem707 remainder -Inf Inf -> NaN Invalid_operation
+ddrem708 remainder -Inf -Inf -> NaN Invalid_operation
+ddrem709 remainder -1000 Inf -> -1000
+ddrem710 remainder -1 -Inf -> -1
+ddrem711 remainder -0 -Inf -> -0
+ddrem712 remainder 0 -Inf -> 0
+ddrem713 remainder 1 -Inf -> 1
+ddrem714 remainder 1000 -Inf -> 1000
+ddrem715 remainder Inf -Inf -> NaN Invalid_operation
+
+ddrem721 remainder NaN -Inf -> NaN
+ddrem722 remainder NaN -1000 -> NaN
+ddrem723 remainder NaN -1 -> NaN
+ddrem724 remainder NaN -0 -> NaN
+ddrem725 remainder -NaN 0 -> -NaN
+ddrem726 remainder NaN 1 -> NaN
+ddrem727 remainder NaN 1000 -> NaN
+ddrem728 remainder NaN Inf -> NaN
+ddrem729 remainder NaN -NaN -> NaN
+ddrem730 remainder -Inf NaN -> NaN
+ddrem731 remainder -1000 NaN -> NaN
+ddrem732 remainder -1 NaN -> NaN
+ddrem733 remainder -0 -NaN -> -NaN
+ddrem734 remainder 0 NaN -> NaN
+ddrem735 remainder 1 -NaN -> -NaN
+ddrem736 remainder 1000 NaN -> NaN
+ddrem737 remainder Inf NaN -> NaN
+
+ddrem741 remainder sNaN -Inf -> NaN Invalid_operation
+ddrem742 remainder sNaN -1000 -> NaN Invalid_operation
+ddrem743 remainder -sNaN -1 -> -NaN Invalid_operation
+ddrem744 remainder sNaN -0 -> NaN Invalid_operation
+ddrem745 remainder sNaN 0 -> NaN Invalid_operation
+ddrem746 remainder sNaN 1 -> NaN Invalid_operation
+ddrem747 remainder sNaN 1000 -> NaN Invalid_operation
+ddrem749 remainder sNaN NaN -> NaN Invalid_operation
+ddrem750 remainder sNaN sNaN -> NaN Invalid_operation
+ddrem751 remainder NaN sNaN -> NaN Invalid_operation
+ddrem752 remainder -Inf sNaN -> NaN Invalid_operation
+ddrem753 remainder -1000 sNaN -> NaN Invalid_operation
+ddrem754 remainder -1 sNaN -> NaN Invalid_operation
+ddrem755 remainder -0 sNaN -> NaN Invalid_operation
+ddrem756 remainder 0 sNaN -> NaN Invalid_operation
+ddrem757 remainder 1 sNaN -> NaN Invalid_operation
+ddrem758 remainder 1000 sNaN -> NaN Invalid_operation
+ddrem759 remainder Inf -sNaN -> -NaN Invalid_operation
+
+-- propaging NaNs
+ddrem760 remainder NaN1 NaN7 -> NaN1
+ddrem761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation
+ddrem762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation
+ddrem763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation
+ddrem764 remainder 15 NaN11 -> NaN11
+ddrem765 remainder NaN6 NaN12 -> NaN6
+ddrem766 remainder Inf NaN13 -> NaN13
+ddrem767 remainder NaN14 -Inf -> NaN14
+ddrem768 remainder 0 NaN15 -> NaN15
+ddrem769 remainder NaN16 -0 -> NaN16
+
+-- edge cases of impossible
+ddrem770 remainder 1234567890123456 10 -> 6
+ddrem771 remainder 1234567890123456 1 -> 0
+ddrem772 remainder 1234567890123456 0.1 -> NaN Division_impossible
+ddrem773 remainder 1234567890123456 0.01 -> NaN Division_impossible
+
+-- long operand checks
+ddrem801 remainder 12345678000 100 -> 0
+ddrem802 remainder 1 12345678000 -> 1
+ddrem803 remainder 1234567800 10 -> 0
+ddrem804 remainder 1 1234567800 -> 1
+ddrem805 remainder 1234567890 10 -> 0
+ddrem806 remainder 1 1234567890 -> 1
+ddrem807 remainder 1234567891 10 -> 1
+ddrem808 remainder 1 1234567891 -> 1
+ddrem809 remainder 12345678901 100 -> 1
+ddrem810 remainder 1 12345678901 -> 1
+ddrem811 remainder 1234567896 10 -> 6
+ddrem812 remainder 1 1234567896 -> 1
+
+ddrem821 remainder 12345678000 100 -> 0
+ddrem822 remainder 1 12345678000 -> 1
+ddrem823 remainder 1234567800 10 -> 0
+ddrem824 remainder 1 1234567800 -> 1
+ddrem825 remainder 1234567890 10 -> 0
+ddrem826 remainder 1 1234567890 -> 1
+ddrem827 remainder 1234567891 10 -> 1
+ddrem828 remainder 1 1234567891 -> 1
+ddrem829 remainder 12345678901 100 -> 1
+ddrem830 remainder 1 12345678901 -> 1
+ddrem831 remainder 1234567896 10 -> 6
+ddrem832 remainder 1 1234567896 -> 1
+
+-- from divideint
+ddrem840 remainder 100000000.0 1 -> 0.0
+ddrem841 remainder 100000000.4 1 -> 0.4
+ddrem842 remainder 100000000.5 1 -> 0.5
+ddrem843 remainder 100000000.9 1 -> 0.9
+ddrem844 remainder 100000000.999 1 -> 0.999
+ddrem850 remainder 100000003 5 -> 3
+ddrem851 remainder 10000003 5 -> 3
+ddrem852 remainder 1000003 5 -> 3
+ddrem853 remainder 100003 5 -> 3
+ddrem854 remainder 10003 5 -> 3
+ddrem855 remainder 1003 5 -> 3
+ddrem856 remainder 103 5 -> 3
+ddrem857 remainder 13 5 -> 3
+ddrem858 remainder 1 5 -> 1
+
+-- Vladimir's cases 1234567890123456
+ddrem860 remainder 123.0e1 1000000000000000 -> 1230
+ddrem861 remainder 1230 1000000000000000 -> 1230
+ddrem862 remainder 12.3e2 1000000000000000 -> 1230
+ddrem863 remainder 1.23e3 1000000000000000 -> 1230
+ddrem864 remainder 123e1 1000000000000000 -> 1230
+ddrem870 remainder 123e1 1000000000000000 -> 1230
+ddrem871 remainder 123e1 100000000000000 -> 1230
+ddrem872 remainder 123e1 10000000000000 -> 1230
+ddrem873 remainder 123e1 1000000000000 -> 1230
+ddrem874 remainder 123e1 100000000000 -> 1230
+ddrem875 remainder 123e1 10000000000 -> 1230
+ddrem876 remainder 123e1 1000000000 -> 1230
+ddrem877 remainder 123e1 100000000 -> 1230
+ddrem878 remainder 1230 100000000 -> 1230
+ddrem879 remainder 123e1 10000000 -> 1230
+ddrem880 remainder 123e1 1000000 -> 1230
+ddrem881 remainder 123e1 100000 -> 1230
+ddrem882 remainder 123e1 10000 -> 1230
+ddrem883 remainder 123e1 1000 -> 230
+ddrem884 remainder 123e1 100 -> 30
+ddrem885 remainder 123e1 10 -> 0
+ddrem886 remainder 123e1 1 -> 0
+
+ddrem890 remainder 123e1 2000000000000000 -> 1230
+ddrem891 remainder 123e1 200000000000000 -> 1230
+ddrem892 remainder 123e1 20000000000000 -> 1230
+ddrem893 remainder 123e1 2000000000000 -> 1230
+ddrem894 remainder 123e1 200000000000 -> 1230
+ddrem895 remainder 123e1 20000000000 -> 1230
+ddrem896 remainder 123e1 2000000000 -> 1230
+ddrem897 remainder 123e1 200000000 -> 1230
+ddrem899 remainder 123e1 20000000 -> 1230
+ddrem900 remainder 123e1 2000000 -> 1230
+ddrem901 remainder 123e1 200000 -> 1230
+ddrem902 remainder 123e1 20000 -> 1230
+ddrem903 remainder 123e1 2000 -> 1230
+ddrem904 remainder 123e1 200 -> 30
+ddrem905 remainder 123e1 20 -> 10
+ddrem906 remainder 123e1 2 -> 0
+
+ddrem910 remainder 123e1 5000000000000000 -> 1230
+ddrem911 remainder 123e1 500000000000000 -> 1230
+ddrem912 remainder 123e1 50000000000000 -> 1230
+ddrem913 remainder 123e1 5000000000000 -> 1230
+ddrem914 remainder 123e1 500000000000 -> 1230
+ddrem915 remainder 123e1 50000000000 -> 1230
+ddrem916 remainder 123e1 5000000000 -> 1230
+ddrem917 remainder 123e1 500000000 -> 1230
+ddrem919 remainder 123e1 50000000 -> 1230
+ddrem920 remainder 123e1 5000000 -> 1230
+ddrem921 remainder 123e1 500000 -> 1230
+ddrem922 remainder 123e1 50000 -> 1230
+ddrem923 remainder 123e1 5000 -> 1230
+ddrem924 remainder 123e1 500 -> 230
+ddrem925 remainder 123e1 50 -> 30
+ddrem926 remainder 123e1 5 -> 0
+
+ddrem930 remainder 123e1 9000000000000000 -> 1230
+ddrem931 remainder 123e1 900000000000000 -> 1230
+ddrem932 remainder 123e1 90000000000000 -> 1230
+ddrem933 remainder 123e1 9000000000000 -> 1230
+ddrem934 remainder 123e1 900000000000 -> 1230
+ddrem935 remainder 123e1 90000000000 -> 1230
+ddrem936 remainder 123e1 9000000000 -> 1230
+ddrem937 remainder 123e1 900000000 -> 1230
+ddrem939 remainder 123e1 90000000 -> 1230
+ddrem940 remainder 123e1 9000000 -> 1230
+ddrem941 remainder 123e1 900000 -> 1230
+ddrem942 remainder 123e1 90000 -> 1230
+ddrem943 remainder 123e1 9000 -> 1230
+ddrem944 remainder 123e1 900 -> 330
+ddrem945 remainder 123e1 90 -> 60
+ddrem946 remainder 123e1 9 -> 6
+
+ddrem950 remainder 123e1 1000000000000000 -> 1230
+ddrem961 remainder 123e1 2999999999999999 -> 1230
+ddrem962 remainder 123e1 3999999999999999 -> 1230
+ddrem963 remainder 123e1 4999999999999999 -> 1230
+ddrem964 remainder 123e1 5999999999999999 -> 1230
+ddrem965 remainder 123e1 6999999999999999 -> 1230
+ddrem966 remainder 123e1 7999999999999999 -> 1230
+ddrem967 remainder 123e1 8999999999999999 -> 1230
+ddrem968 remainder 123e1 9999999999999999 -> 1230
+ddrem969 remainder 123e1 9876543210987654 -> 1230
+
+ddrem980 remainder 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
+
+-- overflow and underflow tests [from divide]
+ddrem1051 remainder 1e+277 1e-311 -> NaN Division_impossible
+ddrem1052 remainder 1e+277 -1e-311 -> NaN Division_impossible
+ddrem1053 remainder -1e+277 1e-311 -> NaN Division_impossible
+ddrem1054 remainder -1e+277 -1e-311 -> NaN Division_impossible
+ddrem1055 remainder 1e-277 1e+311 -> 1E-277
+ddrem1056 remainder 1e-277 -1e+311 -> 1E-277
+ddrem1057 remainder -1e-277 1e+311 -> -1E-277
+ddrem1058 remainder -1e-277 -1e+311 -> -1E-277
+
+-- destructive subtract
+ddrem1101 remainder 1234567890123456 1.000000000000001 -> 0.765432109876546
+ddrem1102 remainder 1234567890123456 1.00000000000001 -> 0.65432109876557
+ddrem1103 remainder 1234567890123456 1.0000000000001 -> 0.5432109876668
+ddrem1104 remainder 1234567890123455 4.000000000000001 -> 2.691358027469137
+ddrem1105 remainder 1234567890123456 4.000000000000001 -> 3.691358027469137
+ddrem1106 remainder 1234567890123456 4.9999999999999 -> 0.6913578024696
+ddrem1107 remainder 1234567890123456 4.99999999999999 -> 3.46913578024691
+ddrem1108 remainder 1234567890123456 4.999999999999999 -> 1.246913578024691
+ddrem1109 remainder 1234567890123456 5.000000000000001 -> 0.753086421975309
+ddrem1110 remainder 1234567890123456 5.00000000000001 -> 3.53086421975310
+ddrem1111 remainder 1234567890123456 5.0000000000001 -> 1.3086421975314
+
+-- Null tests
+ddrem1000 remainder 10 # -> NaN Invalid_operation
+ddrem1001 remainder # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddRemainderNear.decTest b/Lib/test/decimaltestdata/ddRemainderNear.decTest
index 8da9afc4c3..6ba64ebafe 100644
--- a/Lib/test/decimaltestdata/ddRemainderNear.decTest
+++ b/Lib/test/decimaltestdata/ddRemainderNear.decTest
@@ -1,629 +1,629 @@
-------------------------------------------------------------------------
--- ddRemainderNear.decTest -- decDouble remainder-near --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks (as base, above)
-ddrmn001 remaindernear 1 1 -> 0
-ddrmn002 remaindernear 2 1 -> 0
-ddrmn003 remaindernear 1 2 -> 1
-ddrmn004 remaindernear 2 2 -> 0
-ddrmn005 remaindernear 0 1 -> 0
-ddrmn006 remaindernear 0 2 -> 0
-ddrmn007 remaindernear 1 3 -> 1
-ddrmn008 remaindernear 2 3 -> -1
-ddrmn009 remaindernear 3 3 -> 0
-
-ddrmn010 remaindernear 2.4 1 -> 0.4
-ddrmn011 remaindernear 2.4 -1 -> 0.4
-ddrmn012 remaindernear -2.4 1 -> -0.4
-ddrmn013 remaindernear -2.4 -1 -> -0.4
-ddrmn014 remaindernear 2.40 1 -> 0.40
-ddrmn015 remaindernear 2.400 1 -> 0.400
-ddrmn016 remaindernear 2.4 2 -> 0.4
-ddrmn017 remaindernear 2.400 2 -> 0.400
-ddrmn018 remaindernear 2. 2 -> 0
-ddrmn019 remaindernear 20 20 -> 0
-
-ddrmn020 remaindernear 187 187 -> 0
-ddrmn021 remaindernear 5 2 -> 1
-ddrmn022 remaindernear 5 2.0 -> 1.0
-ddrmn023 remaindernear 5 2.000 -> 1.000
-ddrmn024 remaindernear 5 0.200 -> 0.000
-ddrmn025 remaindernear 5 0.200 -> 0.000
-
-ddrmn030 remaindernear 1 2 -> 1
-ddrmn031 remaindernear 1 4 -> 1
-ddrmn032 remaindernear 1 8 -> 1
-
-ddrmn033 remaindernear 1 16 -> 1
-ddrmn034 remaindernear 1 32 -> 1
-ddrmn035 remaindernear 1 64 -> 1
-ddrmn040 remaindernear 1 -2 -> 1
-ddrmn041 remaindernear 1 -4 -> 1
-ddrmn042 remaindernear 1 -8 -> 1
-ddrmn043 remaindernear 1 -16 -> 1
-ddrmn044 remaindernear 1 -32 -> 1
-ddrmn045 remaindernear 1 -64 -> 1
-ddrmn050 remaindernear -1 2 -> -1
-ddrmn051 remaindernear -1 4 -> -1
-ddrmn052 remaindernear -1 8 -> -1
-ddrmn053 remaindernear -1 16 -> -1
-ddrmn054 remaindernear -1 32 -> -1
-ddrmn055 remaindernear -1 64 -> -1
-ddrmn060 remaindernear -1 -2 -> -1
-ddrmn061 remaindernear -1 -4 -> -1
-ddrmn062 remaindernear -1 -8 -> -1
-ddrmn063 remaindernear -1 -16 -> -1
-ddrmn064 remaindernear -1 -32 -> -1
-ddrmn065 remaindernear -1 -64 -> -1
-
-ddrmn066 remaindernear 9.9 1 -> -0.1
-ddrmn067 remaindernear 99.7 1 -> -0.3
-ddrmn068 remaindernear 999999999 1 -> 0
-ddrmn069 remaindernear 999999999.4 1 -> 0.4
-ddrmn070 remaindernear 999999999.5 1 -> -0.5
-ddrmn071 remaindernear 999999999.9 1 -> -0.1
-ddrmn072 remaindernear 999999999.999 1 -> -0.001
-ddrmn073 remaindernear 999999.999999 1 -> -0.000001
-ddrmn074 remaindernear 9 1 -> 0
-ddrmn075 remaindernear 9999999999999999 1 -> 0
-ddrmn076 remaindernear 9999999999999999 2 -> -1
-ddrmn077 remaindernear 9999999999999999 3 -> 0
-ddrmn078 remaindernear 9999999999999999 4 -> -1
-
-ddrmn080 remaindernear 0. 1 -> 0
-ddrmn081 remaindernear .0 1 -> 0.0
-ddrmn082 remaindernear 0.00 1 -> 0.00
-ddrmn083 remaindernear 0.00E+9 1 -> 0
-ddrmn084 remaindernear 0.00E+3 1 -> 0
-ddrmn085 remaindernear 0.00E+2 1 -> 0
-ddrmn086 remaindernear 0.00E+1 1 -> 0.0
-ddrmn087 remaindernear 0.00E+0 1 -> 0.00
-ddrmn088 remaindernear 0.00E-0 1 -> 0.00
-ddrmn089 remaindernear 0.00E-1 1 -> 0.000
-ddrmn090 remaindernear 0.00E-2 1 -> 0.0000
-ddrmn091 remaindernear 0.00E-3 1 -> 0.00000
-ddrmn092 remaindernear 0.00E-4 1 -> 0.000000
-ddrmn093 remaindernear 0.00E-5 1 -> 0E-7
-ddrmn094 remaindernear 0.00E-6 1 -> 0E-8
-ddrmn095 remaindernear 0.0000E-50 1 -> 0E-54
-
--- Various flavours of remaindernear by 0
-ddrmn101 remaindernear 0 0 -> NaN Division_undefined
-ddrmn102 remaindernear 0 -0 -> NaN Division_undefined
-ddrmn103 remaindernear -0 0 -> NaN Division_undefined
-ddrmn104 remaindernear -0 -0 -> NaN Division_undefined
-ddrmn105 remaindernear 0.0E5 0 -> NaN Division_undefined
-ddrmn106 remaindernear 0.000 0 -> NaN Division_undefined
--- [Some think this next group should be Division_by_zero exception, but
--- IEEE 854 is explicit that it is Invalid operation .. for
--- remainder-near, anyway]
-ddrmn107 remaindernear 0.0001 0 -> NaN Invalid_operation
-ddrmn108 remaindernear 0.01 0 -> NaN Invalid_operation
-ddrmn109 remaindernear 0.1 0 -> NaN Invalid_operation
-ddrmn110 remaindernear 1 0 -> NaN Invalid_operation
-ddrmn111 remaindernear 1 0.0 -> NaN Invalid_operation
-ddrmn112 remaindernear 10 0.0 -> NaN Invalid_operation
-ddrmn113 remaindernear 1E+100 0.0 -> NaN Invalid_operation
-ddrmn114 remaindernear 1E+380 0 -> NaN Invalid_operation
-ddrmn115 remaindernear 0.0001 -0 -> NaN Invalid_operation
-ddrmn116 remaindernear 0.01 -0 -> NaN Invalid_operation
-ddrmn119 remaindernear 0.1 -0 -> NaN Invalid_operation
-ddrmn120 remaindernear 1 -0 -> NaN Invalid_operation
-ddrmn121 remaindernear 1 -0.0 -> NaN Invalid_operation
-ddrmn122 remaindernear 10 -0.0 -> NaN Invalid_operation
-ddrmn123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation
-ddrmn124 remaindernear 1E+384 -0 -> NaN Invalid_operation
--- and zeros on left
-ddrmn130 remaindernear 0 1 -> 0
-ddrmn131 remaindernear 0 -1 -> 0
-ddrmn132 remaindernear 0.0 1 -> 0.0
-ddrmn133 remaindernear 0.0 -1 -> 0.0
-ddrmn134 remaindernear -0 1 -> -0
-ddrmn135 remaindernear -0 -1 -> -0
-ddrmn136 remaindernear -0.0 1 -> -0.0
-ddrmn137 remaindernear -0.0 -1 -> -0.0
-
--- 0.5ers
-ddrmn143 remaindernear 0.5 2 -> 0.5
-ddrmn144 remaindernear 0.5 2.1 -> 0.5
-ddrmn145 remaindernear 0.5 2.01 -> 0.50
-ddrmn146 remaindernear 0.5 2.001 -> 0.500
-ddrmn147 remaindernear 0.50 2 -> 0.50
-ddrmn148 remaindernear 0.50 2.01 -> 0.50
-ddrmn149 remaindernear 0.50 2.001 -> 0.500
-
--- steadies
-ddrmn150 remaindernear 1 1 -> 0
-ddrmn151 remaindernear 1 2 -> 1
-ddrmn152 remaindernear 1 3 -> 1
-ddrmn153 remaindernear 1 4 -> 1
-ddrmn154 remaindernear 1 5 -> 1
-ddrmn155 remaindernear 1 6 -> 1
-ddrmn156 remaindernear 1 7 -> 1
-ddrmn157 remaindernear 1 8 -> 1
-ddrmn158 remaindernear 1 9 -> 1
-ddrmn159 remaindernear 1 10 -> 1
-ddrmn160 remaindernear 1 1 -> 0
-ddrmn161 remaindernear 2 1 -> 0
-ddrmn162 remaindernear 3 1 -> 0
-ddrmn163 remaindernear 4 1 -> 0
-ddrmn164 remaindernear 5 1 -> 0
-ddrmn165 remaindernear 6 1 -> 0
-ddrmn166 remaindernear 7 1 -> 0
-ddrmn167 remaindernear 8 1 -> 0
-ddrmn168 remaindernear 9 1 -> 0
-ddrmn169 remaindernear 10 1 -> 0
-
--- some differences from remainder
-ddrmn171 remaindernear 0.4 1.020 -> 0.400
-ddrmn172 remaindernear 0.50 1.020 -> 0.500
-ddrmn173 remaindernear 0.51 1.020 -> 0.510
-ddrmn174 remaindernear 0.52 1.020 -> -0.500
-ddrmn175 remaindernear 0.6 1.020 -> -0.420
-
--- More flavours of remaindernear by 0
-ddrmn201 remaindernear 0 0 -> NaN Division_undefined
-ddrmn202 remaindernear 0.0E5 0 -> NaN Division_undefined
-ddrmn203 remaindernear 0.000 0 -> NaN Division_undefined
-ddrmn204 remaindernear 0.0001 0 -> NaN Invalid_operation
-ddrmn205 remaindernear 0.01 0 -> NaN Invalid_operation
-ddrmn206 remaindernear 0.1 0 -> NaN Invalid_operation
-ddrmn207 remaindernear 1 0 -> NaN Invalid_operation
-ddrmn208 remaindernear 1 0.0 -> NaN Invalid_operation
-ddrmn209 remaindernear 10 0.0 -> NaN Invalid_operation
-ddrmn210 remaindernear 1E+100 0.0 -> NaN Invalid_operation
-ddrmn211 remaindernear 1E+380 0 -> NaN Invalid_operation
-
--- tests from the extended specification
-ddrmn221 remaindernear 2.1 3 -> -0.9
-ddrmn222 remaindernear 10 6 -> -2
-ddrmn223 remaindernear 10 3 -> 1
-ddrmn224 remaindernear -10 3 -> -1
-ddrmn225 remaindernear 10.2 1 -> 0.2
-ddrmn226 remaindernear 10 0.3 -> 0.1
-ddrmn227 remaindernear 3.6 1.3 -> -0.3
-
--- some differences from remainder
-ddrmn231 remaindernear -0.4 1.020 -> -0.400
-ddrmn232 remaindernear -0.50 1.020 -> -0.500
-ddrmn233 remaindernear -0.51 1.020 -> -0.510
-ddrmn234 remaindernear -0.52 1.020 -> 0.500
-ddrmn235 remaindernear -0.6 1.020 -> 0.420
-
--- high Xs
-ddrmn240 remaindernear 1E+2 1.00 -> 0.00
-
--- ddrmn3xx are from DiagBigDecimal
-ddrmn301 remaindernear 1 3 -> 1
-ddrmn302 remaindernear 5 5 -> 0
-ddrmn303 remaindernear 13 10 -> 3
-ddrmn304 remaindernear 13 50 -> 13
-ddrmn305 remaindernear 13 100 -> 13
-ddrmn306 remaindernear 13 1000 -> 13
-ddrmn307 remaindernear .13 1 -> 0.13
-ddrmn308 remaindernear 0.133 1 -> 0.133
-ddrmn309 remaindernear 0.1033 1 -> 0.1033
-ddrmn310 remaindernear 1.033 1 -> 0.033
-ddrmn311 remaindernear 10.33 1 -> 0.33
-ddrmn312 remaindernear 10.33 10 -> 0.33
-ddrmn313 remaindernear 103.3 1 -> 0.3
-ddrmn314 remaindernear 133 10 -> 3
-ddrmn315 remaindernear 1033 10 -> 3
-ddrmn316 remaindernear 1033 50 -> -17
-ddrmn317 remaindernear 101.0 3 -> -1.0
-ddrmn318 remaindernear 102.0 3 -> 0.0
-ddrmn319 remaindernear 103.0 3 -> 1.0
-ddrmn320 remaindernear 2.40 1 -> 0.40
-ddrmn321 remaindernear 2.400 1 -> 0.400
-ddrmn322 remaindernear 2.4 1 -> 0.4
-ddrmn323 remaindernear 2.4 2 -> 0.4
-ddrmn324 remaindernear 2.400 2 -> 0.400
-ddrmn325 remaindernear 1 0.3 -> 0.1
-ddrmn326 remaindernear 1 0.30 -> 0.10
-ddrmn327 remaindernear 1 0.300 -> 0.100
-ddrmn328 remaindernear 1 0.3000 -> 0.1000
-ddrmn329 remaindernear 1.0 0.3 -> 0.1
-ddrmn330 remaindernear 1.00 0.3 -> 0.10
-ddrmn331 remaindernear 1.000 0.3 -> 0.100
-ddrmn332 remaindernear 1.0000 0.3 -> 0.1000
-ddrmn333 remaindernear 0.5 2 -> 0.5
-ddrmn334 remaindernear 0.5 2.1 -> 0.5
-ddrmn335 remaindernear 0.5 2.01 -> 0.50
-ddrmn336 remaindernear 0.5 2.001 -> 0.500
-ddrmn337 remaindernear 0.50 2 -> 0.50
-ddrmn338 remaindernear 0.50 2.01 -> 0.50
-ddrmn339 remaindernear 0.50 2.001 -> 0.500
-
-ddrmn340 remaindernear 0.5 0.5000001 -> -1E-7
-ddrmn341 remaindernear 0.5 0.50000001 -> -1E-8
-ddrmn342 remaindernear 0.5 0.500000001 -> -1E-9
-ddrmn343 remaindernear 0.5 0.5000000001 -> -1E-10
-ddrmn344 remaindernear 0.5 0.50000000001 -> -1E-11
-ddrmn345 remaindernear 0.5 0.4999999 -> 1E-7
-ddrmn346 remaindernear 0.5 0.49999999 -> 1E-8
-ddrmn347 remaindernear 0.5 0.499999999 -> 1E-9
-ddrmn348 remaindernear 0.5 0.4999999999 -> 1E-10
-ddrmn349 remaindernear 0.5 0.49999999999 -> 1E-11
-ddrmn350 remaindernear 0.5 0.499999999999 -> 1E-12
-
-ddrmn351 remaindernear 0.03 7 -> 0.03
-ddrmn352 remaindernear 5 2 -> 1
-ddrmn353 remaindernear 4.1 2 -> 0.1
-ddrmn354 remaindernear 4.01 2 -> 0.01
-ddrmn355 remaindernear 4.001 2 -> 0.001
-ddrmn356 remaindernear 4.0001 2 -> 0.0001
-ddrmn357 remaindernear 4.00001 2 -> 0.00001
-ddrmn358 remaindernear 4.000001 2 -> 0.000001
-ddrmn359 remaindernear 4.0000001 2 -> 1E-7
-
-ddrmn360 remaindernear 1.2 0.7345 -> -0.2690
-ddrmn361 remaindernear 0.8 12 -> 0.8
-ddrmn362 remaindernear 0.8 0.2 -> 0.0
-ddrmn363 remaindernear 0.8 0.3 -> -0.1
-ddrmn364 remaindernear 0.800 12 -> 0.800
-ddrmn365 remaindernear 0.800 1.7 -> 0.800
-ddrmn366 remaindernear 2.400 2 -> 0.400
-
--- round to even
-ddrmn371 remaindernear 121 2 -> 1
-ddrmn372 remaindernear 122 2 -> 0
-ddrmn373 remaindernear 123 2 -> -1
-ddrmn374 remaindernear 124 2 -> 0
-ddrmn375 remaindernear 125 2 -> 1
-ddrmn376 remaindernear 126 2 -> 0
-ddrmn377 remaindernear 127 2 -> -1
-
-ddrmn381 remaindernear 12345 1 -> 0
-ddrmn382 remaindernear 12345 1.0001 -> -0.2344
-ddrmn383 remaindernear 12345 1.001 -> -0.333
-ddrmn384 remaindernear 12345 1.01 -> -0.23
-ddrmn385 remaindernear 12345 1.1 -> -0.3
-ddrmn386 remaindernear 12355 4 -> -1
-ddrmn387 remaindernear 12345 4 -> 1
-ddrmn388 remaindernear 12355 4.0001 -> -1.3089
-ddrmn389 remaindernear 12345 4.0001 -> 0.6914
-ddrmn390 remaindernear 12345 4.9 -> 1.9
-ddrmn391 remaindernear 12345 4.99 -> -0.26
-ddrmn392 remaindernear 12345 4.999 -> 2.469
-ddrmn393 remaindernear 12345 4.9999 -> 0.2469
-ddrmn394 remaindernear 12345 5 -> 0
-ddrmn395 remaindernear 12345 5.0001 -> -0.2469
-ddrmn396 remaindernear 12345 5.001 -> -2.469
-ddrmn397 remaindernear 12345 5.01 -> 0.36
-ddrmn398 remaindernear 12345 5.1 -> -2.1
-
--- the nasty division-by-1 cases
-ddrmn401 remaindernear 0.4 1 -> 0.4
-ddrmn402 remaindernear 0.45 1 -> 0.45
-ddrmn403 remaindernear 0.455 1 -> 0.455
-ddrmn404 remaindernear 0.4555 1 -> 0.4555
-ddrmn405 remaindernear 0.45555 1 -> 0.45555
-ddrmn406 remaindernear 0.455555 1 -> 0.455555
-ddrmn407 remaindernear 0.4555555 1 -> 0.4555555
-ddrmn408 remaindernear 0.45555555 1 -> 0.45555555
-ddrmn409 remaindernear 0.455555555 1 -> 0.455555555
--- with spill... [412 exercises sticktab loop]
-ddrmn411 remaindernear 0.5 1 -> 0.5
-ddrmn412 remaindernear 0.55 1 -> -0.45
-ddrmn413 remaindernear 0.555 1 -> -0.445
-ddrmn414 remaindernear 0.5555 1 -> -0.4445
-ddrmn415 remaindernear 0.55555 1 -> -0.44445
-ddrmn416 remaindernear 0.555555 1 -> -0.444445
-ddrmn417 remaindernear 0.5555555 1 -> -0.4444445
-ddrmn418 remaindernear 0.55555555 1 -> -0.44444445
-ddrmn419 remaindernear 0.555555555 1 -> -0.444444445
-
--- folddowns
-ddrmn421 remaindernear 1E+384 1 -> NaN Division_impossible
-ddrmn422 remaindernear 1E+384 1E+383 -> 0E+369 Clamped
-ddrmn423 remaindernear 1E+384 2E+383 -> 0E+369 Clamped
-ddrmn424 remaindernear 1E+384 3E+383 -> 1.00000000000000E+383 Clamped
-ddrmn425 remaindernear 1E+384 4E+383 -> 2.00000000000000E+383 Clamped
-ddrmn426 remaindernear 1E+384 5E+383 -> 0E+369 Clamped
-ddrmn427 remaindernear 1E+384 6E+383 -> -2.00000000000000E+383 Clamped
-ddrmn428 remaindernear 1E+384 7E+383 -> 3.00000000000000E+383 Clamped
-ddrmn429 remaindernear 1E+384 8E+383 -> 2.00000000000000E+383 Clamped
-ddrmn430 remaindernear 1E+384 9E+383 -> 1.00000000000000E+383 Clamped
--- tinies
-ddrmn431 remaindernear 1E-397 1E-398 -> 0E-398
-ddrmn432 remaindernear 1E-397 2E-398 -> 0E-398
-ddrmn433 remaindernear 1E-397 3E-398 -> 1E-398 Subnormal
-ddrmn434 remaindernear 1E-397 4E-398 -> 2E-398 Subnormal
-ddrmn435 remaindernear 1E-397 5E-398 -> 0E-398
-ddrmn436 remaindernear 1E-397 6E-398 -> -2E-398 Subnormal
-ddrmn437 remaindernear 1E-397 7E-398 -> 3E-398 Subnormal
-ddrmn438 remaindernear 1E-397 8E-398 -> 2E-398 Subnormal
-ddrmn439 remaindernear 1E-397 9E-398 -> 1E-398 Subnormal
-ddrmn440 remaindernear 1E-397 10E-398 -> 0E-398
-ddrmn441 remaindernear 1E-397 11E-398 -> -1E-398 Subnormal
-ddrmn442 remaindernear 100E-397 11E-398 -> -1E-398 Subnormal
-ddrmn443 remaindernear 100E-397 20E-398 -> 0E-398
-ddrmn444 remaindernear 100E-397 21E-398 -> -8E-398 Subnormal
-ddrmn445 remaindernear 100E-397 30E-398 -> 1.0E-397 Subnormal
-
--- zero signs
-ddrmn650 remaindernear 1 1 -> 0
-ddrmn651 remaindernear -1 1 -> -0
-ddrmn652 remaindernear 1 -1 -> 0
-ddrmn653 remaindernear -1 -1 -> -0
-ddrmn654 remaindernear 0 1 -> 0
-ddrmn655 remaindernear -0 1 -> -0
-ddrmn656 remaindernear 0 -1 -> 0
-ddrmn657 remaindernear -0 -1 -> -0
-ddrmn658 remaindernear 0.00 1 -> 0.00
-ddrmn659 remaindernear -0.00 1 -> -0.00
-
--- Specials
-ddrmn680 remaindernear Inf -Inf -> NaN Invalid_operation
-ddrmn681 remaindernear Inf -1000 -> NaN Invalid_operation
-ddrmn682 remaindernear Inf -1 -> NaN Invalid_operation
-ddrmn683 remaindernear Inf 0 -> NaN Invalid_operation
-ddrmn684 remaindernear Inf -0 -> NaN Invalid_operation
-ddrmn685 remaindernear Inf 1 -> NaN Invalid_operation
-ddrmn686 remaindernear Inf 1000 -> NaN Invalid_operation
-ddrmn687 remaindernear Inf Inf -> NaN Invalid_operation
-ddrmn688 remaindernear -1000 Inf -> -1000
-ddrmn689 remaindernear -Inf Inf -> NaN Invalid_operation
-ddrmn691 remaindernear -1 Inf -> -1
-ddrmn692 remaindernear 0 Inf -> 0
-ddrmn693 remaindernear -0 Inf -> -0
-ddrmn694 remaindernear 1 Inf -> 1
-ddrmn695 remaindernear 1000 Inf -> 1000
-ddrmn696 remaindernear Inf Inf -> NaN Invalid_operation
-
-ddrmn700 remaindernear -Inf -Inf -> NaN Invalid_operation
-ddrmn701 remaindernear -Inf -1000 -> NaN Invalid_operation
-ddrmn702 remaindernear -Inf -1 -> NaN Invalid_operation
-ddrmn703 remaindernear -Inf -0 -> NaN Invalid_operation
-ddrmn704 remaindernear -Inf 0 -> NaN Invalid_operation
-ddrmn705 remaindernear -Inf 1 -> NaN Invalid_operation
-ddrmn706 remaindernear -Inf 1000 -> NaN Invalid_operation
-ddrmn707 remaindernear -Inf Inf -> NaN Invalid_operation
-ddrmn708 remaindernear -Inf -Inf -> NaN Invalid_operation
-ddrmn709 remaindernear -1000 Inf -> -1000
-ddrmn710 remaindernear -1 -Inf -> -1
-ddrmn711 remaindernear -0 -Inf -> -0
-ddrmn712 remaindernear 0 -Inf -> 0
-ddrmn713 remaindernear 1 -Inf -> 1
-ddrmn714 remaindernear 1000 -Inf -> 1000
-ddrmn715 remaindernear Inf -Inf -> NaN Invalid_operation
-
-ddrmn721 remaindernear NaN -Inf -> NaN
-ddrmn722 remaindernear NaN -1000 -> NaN
-ddrmn723 remaindernear NaN -1 -> NaN
-ddrmn724 remaindernear NaN -0 -> NaN
-ddrmn725 remaindernear -NaN 0 -> -NaN
-ddrmn726 remaindernear NaN 1 -> NaN
-ddrmn727 remaindernear NaN 1000 -> NaN
-ddrmn728 remaindernear NaN Inf -> NaN
-ddrmn729 remaindernear NaN -NaN -> NaN
-ddrmn730 remaindernear -Inf NaN -> NaN
-ddrmn731 remaindernear -1000 NaN -> NaN
-ddrmn732 remaindernear -1 NaN -> NaN
-ddrmn733 remaindernear -0 -NaN -> -NaN
-ddrmn734 remaindernear 0 NaN -> NaN
-ddrmn735 remaindernear 1 -NaN -> -NaN
-ddrmn736 remaindernear 1000 NaN -> NaN
-ddrmn737 remaindernear Inf NaN -> NaN
-
-ddrmn741 remaindernear sNaN -Inf -> NaN Invalid_operation
-ddrmn742 remaindernear sNaN -1000 -> NaN Invalid_operation
-ddrmn743 remaindernear -sNaN -1 -> -NaN Invalid_operation
-ddrmn744 remaindernear sNaN -0 -> NaN Invalid_operation
-ddrmn745 remaindernear sNaN 0 -> NaN Invalid_operation
-ddrmn746 remaindernear sNaN 1 -> NaN Invalid_operation
-ddrmn747 remaindernear sNaN 1000 -> NaN Invalid_operation
-ddrmn749 remaindernear sNaN NaN -> NaN Invalid_operation
-ddrmn750 remaindernear sNaN sNaN -> NaN Invalid_operation
-ddrmn751 remaindernear NaN sNaN -> NaN Invalid_operation
-ddrmn752 remaindernear -Inf sNaN -> NaN Invalid_operation
-ddrmn753 remaindernear -1000 sNaN -> NaN Invalid_operation
-ddrmn754 remaindernear -1 sNaN -> NaN Invalid_operation
-ddrmn755 remaindernear -0 sNaN -> NaN Invalid_operation
-ddrmn756 remaindernear 0 sNaN -> NaN Invalid_operation
-ddrmn757 remaindernear 1 sNaN -> NaN Invalid_operation
-ddrmn758 remaindernear 1000 sNaN -> NaN Invalid_operation
-ddrmn759 remaindernear Inf -sNaN -> -NaN Invalid_operation
-
--- propaging NaNs
-ddrmn760 remaindernear NaN1 NaN7 -> NaN1
-ddrmn761 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation
-ddrmn762 remaindernear NaN3 sNaN9 -> NaN9 Invalid_operation
-ddrmn763 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation
-ddrmn764 remaindernear 15 NaN11 -> NaN11
-ddrmn765 remaindernear NaN6 NaN12 -> NaN6
-ddrmn766 remaindernear Inf NaN13 -> NaN13
-ddrmn767 remaindernear NaN14 -Inf -> NaN14
-ddrmn768 remaindernear 0 NaN15 -> NaN15
-ddrmn769 remaindernear NaN16 -0 -> NaN16
-
--- edge cases of impossible
-ddrmn770 remaindernear 1234567890123456 10 -> -4
-ddrmn771 remaindernear 1234567890123456 1 -> 0
-ddrmn772 remaindernear 1234567890123456 0.1 -> NaN Division_impossible
-ddrmn773 remaindernear 1234567890123456 0.01 -> NaN Division_impossible
-
--- long operand checks
-ddrmn801 remaindernear 12345678000 100 -> 0
-ddrmn802 remaindernear 1 12345678000 -> 1
-ddrmn803 remaindernear 1234567800 10 -> 0
-ddrmn804 remaindernear 1 1234567800 -> 1
-ddrmn805 remaindernear 1234567890 10 -> 0
-ddrmn806 remaindernear 1 1234567890 -> 1
-ddrmn807 remaindernear 1234567891 10 -> 1
-ddrmn808 remaindernear 1 1234567891 -> 1
-ddrmn809 remaindernear 12345678901 100 -> 1
-ddrmn810 remaindernear 1 12345678901 -> 1
-ddrmn811 remaindernear 1234567896 10 -> -4
-ddrmn812 remaindernear 1 1234567896 -> 1
-
-ddrmn821 remaindernear 12345678000 100 -> 0
-ddrmn822 remaindernear 1 12345678000 -> 1
-ddrmn823 remaindernear 1234567800 10 -> 0
-ddrmn824 remaindernear 1 1234567800 -> 1
-ddrmn825 remaindernear 1234567890 10 -> 0
-ddrmn826 remaindernear 1 1234567890 -> 1
-ddrmn827 remaindernear 1234567891 10 -> 1
-ddrmn828 remaindernear 1 1234567891 -> 1
-ddrmn829 remaindernear 12345678901 100 -> 1
-ddrmn830 remaindernear 1 12345678901 -> 1
-ddrmn831 remaindernear 1234567896 10 -> -4
-ddrmn832 remaindernear 1 1234567896 -> 1
-
--- from divideint
-ddrmn840 remaindernear 100000000.0 1 -> 0.0
-ddrmn841 remaindernear 100000000.4 1 -> 0.4
-ddrmn842 remaindernear 100000000.5 1 -> 0.5
-ddrmn843 remaindernear 100000000.9 1 -> -0.1
-ddrmn844 remaindernear 100000000.999 1 -> -0.001
-ddrmn850 remaindernear 100000003 5 -> -2
-ddrmn851 remaindernear 10000003 5 -> -2
-ddrmn852 remaindernear 1000003 5 -> -2
-ddrmn853 remaindernear 100003 5 -> -2
-ddrmn854 remaindernear 10003 5 -> -2
-ddrmn855 remaindernear 1003 5 -> -2
-ddrmn856 remaindernear 103 5 -> -2
-ddrmn857 remaindernear 13 5 -> -2
-ddrmn858 remaindernear 1 5 -> 1
-
--- Vladimir's cases 1234567890123456
-ddrmn860 remaindernear 123.0e1 1000000000000000 -> 1230
-ddrmn861 remaindernear 1230 1000000000000000 -> 1230
-ddrmn862 remaindernear 12.3e2 1000000000000000 -> 1230
-ddrmn863 remaindernear 1.23e3 1000000000000000 -> 1230
-ddrmn864 remaindernear 123e1 1000000000000000 -> 1230
-ddrmn870 remaindernear 123e1 1000000000000000 -> 1230
-ddrmn871 remaindernear 123e1 100000000000000 -> 1230
-ddrmn872 remaindernear 123e1 10000000000000 -> 1230
-ddrmn873 remaindernear 123e1 1000000000000 -> 1230
-ddrmn874 remaindernear 123e1 100000000000 -> 1230
-ddrmn875 remaindernear 123e1 10000000000 -> 1230
-ddrmn876 remaindernear 123e1 1000000000 -> 1230
-ddrmn877 remaindernear 123e1 100000000 -> 1230
-ddrmn878 remaindernear 1230 100000000 -> 1230
-ddrmn879 remaindernear 123e1 10000000 -> 1230
-ddrmn880 remaindernear 123e1 1000000 -> 1230
-ddrmn881 remaindernear 123e1 100000 -> 1230
-ddrmn882 remaindernear 123e1 10000 -> 1230
-ddrmn883 remaindernear 123e1 1000 -> 230
-ddrmn884 remaindernear 123e1 100 -> 30
-ddrmn885 remaindernear 123e1 10 -> 0
-ddrmn886 remaindernear 123e1 1 -> 0
-
-ddrmn890 remaindernear 123e1 2000000000000000 -> 1230
-ddrmn891 remaindernear 123e1 200000000000000 -> 1230
-ddrmn892 remaindernear 123e1 20000000000000 -> 1230
-ddrmn893 remaindernear 123e1 2000000000000 -> 1230
-ddrmn894 remaindernear 123e1 200000000000 -> 1230
-ddrmn895 remaindernear 123e1 20000000000 -> 1230
-ddrmn896 remaindernear 123e1 2000000000 -> 1230
-ddrmn897 remaindernear 123e1 200000000 -> 1230
-ddrmn899 remaindernear 123e1 20000000 -> 1230
-ddrmn900 remaindernear 123e1 2000000 -> 1230
-ddrmn901 remaindernear 123e1 200000 -> 1230
-ddrmn902 remaindernear 123e1 20000 -> 1230
-ddrmn903 remaindernear 123e1 2000 -> -770
-ddrmn904 remaindernear 123e1 200 -> 30
-ddrmn905 remaindernear 123e1 20 -> -10
-ddrmn906 remaindernear 123e1 2 -> 0
-
-ddrmn910 remaindernear 123e1 5000000000000000 -> 1230
-ddrmn911 remaindernear 123e1 500000000000000 -> 1230
-ddrmn912 remaindernear 123e1 50000000000000 -> 1230
-ddrmn913 remaindernear 123e1 5000000000000 -> 1230
-ddrmn914 remaindernear 123e1 500000000000 -> 1230
-ddrmn915 remaindernear 123e1 50000000000 -> 1230
-ddrmn916 remaindernear 123e1 5000000000 -> 1230
-ddrmn917 remaindernear 123e1 500000000 -> 1230
-ddrmn919 remaindernear 123e1 50000000 -> 1230
-ddrmn920 remaindernear 123e1 5000000 -> 1230
-ddrmn921 remaindernear 123e1 500000 -> 1230
-ddrmn922 remaindernear 123e1 50000 -> 1230
-ddrmn923 remaindernear 123e1 5000 -> 1230
-ddrmn924 remaindernear 123e1 500 -> 230
-ddrmn925 remaindernear 123e1 50 -> -20
-ddrmn926 remaindernear 123e1 5 -> 0
-
-ddrmn930 remaindernear 123e1 9000000000000000 -> 1230
-ddrmn931 remaindernear 123e1 900000000000000 -> 1230
-ddrmn932 remaindernear 123e1 90000000000000 -> 1230
-ddrmn933 remaindernear 123e1 9000000000000 -> 1230
-ddrmn934 remaindernear 123e1 900000000000 -> 1230
-ddrmn935 remaindernear 123e1 90000000000 -> 1230
-ddrmn936 remaindernear 123e1 9000000000 -> 1230
-ddrmn937 remaindernear 123e1 900000000 -> 1230
-ddrmn939 remaindernear 123e1 90000000 -> 1230
-ddrmn940 remaindernear 123e1 9000000 -> 1230
-ddrmn941 remaindernear 123e1 900000 -> 1230
-ddrmn942 remaindernear 123e1 90000 -> 1230
-ddrmn943 remaindernear 123e1 9000 -> 1230
-ddrmn944 remaindernear 123e1 900 -> 330
-ddrmn945 remaindernear 123e1 90 -> -30
-ddrmn946 remaindernear 123e1 9 -> -3
-
-ddrmn950 remaindernear 123e1 1000000000000000 -> 1230
-ddrmn961 remaindernear 123e1 2999999999999999 -> 1230
-ddrmn962 remaindernear 123e1 3999999999999999 -> 1230
-ddrmn963 remaindernear 123e1 4999999999999999 -> 1230
-ddrmn964 remaindernear 123e1 5999999999999999 -> 1230
-ddrmn965 remaindernear 123e1 6999999999999999 -> 1230
-ddrmn966 remaindernear 123e1 7999999999999999 -> 1230
-ddrmn967 remaindernear 123e1 8999999999999999 -> 1230
-ddrmn968 remaindernear 123e1 9999999999999999 -> 1230
-ddrmn969 remaindernear 123e1 9876543210987654 -> 1230
-
-ddrmn980 remaindernear 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
-
-
--- overflow and underflow tests [from divide]
-ddrmn1051 remaindernear 1e+277 1e-311 -> NaN Division_impossible
-ddrmn1052 remaindernear 1e+277 -1e-311 -> NaN Division_impossible
-ddrmn1053 remaindernear -1e+277 1e-311 -> NaN Division_impossible
-ddrmn1054 remaindernear -1e+277 -1e-311 -> NaN Division_impossible
-ddrmn1055 remaindernear 1e-277 1e+311 -> 1E-277
-ddrmn1056 remaindernear 1e-277 -1e+311 -> 1E-277
-ddrmn1057 remaindernear -1e-277 1e+311 -> -1E-277
-ddrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277
-
--- destructive subtract
-ddrmn1100 remainderNear 1234567890123456 1.000000000000001 -> -0.234567890123455
-ddrmn1101 remainderNear 1234567890123456 1.00000000000001 -> -0.34567890123444
-ddrmn1102 remainderNear 1234567890123456 1.0000000000001 -> -0.4567890123333
-ddrmn1103 remainderNear 1234567890123455 4.000000000000001 -> -1.308641972530864
-ddrmn1104 remainderNear 1234567890123456 4.000000000000001 -> -0.308641972530864
-ddrmn1115 remainderNear 1234567890123456 4.9999999999999 -> 0.6913578024696
-ddrmn1116 remainderNear 1234567890123456 4.99999999999999 -> -1.53086421975308
-ddrmn1117 remainderNear 1234567890123456 4.999999999999999 -> 1.246913578024691
-ddrmn1118 remainderNear 1234567890123456 5.000000000000001 -> 0.753086421975309
-ddrmn1119 remainderNear 1234567890123456 5.00000000000001 -> -1.46913578024691
-ddrmn1110 remainderNear 1234567890123456 5.0000000000001 -> 1.3086421975314
-
--- Null tests
-ddrmn1000 remaindernear 10 # -> NaN Invalid_operation
-ddrmn1001 remaindernear # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddRemainderNear.decTest -- decDouble remainder-near --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks (as base, above)
+ddrmn001 remaindernear 1 1 -> 0
+ddrmn002 remaindernear 2 1 -> 0
+ddrmn003 remaindernear 1 2 -> 1
+ddrmn004 remaindernear 2 2 -> 0
+ddrmn005 remaindernear 0 1 -> 0
+ddrmn006 remaindernear 0 2 -> 0
+ddrmn007 remaindernear 1 3 -> 1
+ddrmn008 remaindernear 2 3 -> -1
+ddrmn009 remaindernear 3 3 -> 0
+
+ddrmn010 remaindernear 2.4 1 -> 0.4
+ddrmn011 remaindernear 2.4 -1 -> 0.4
+ddrmn012 remaindernear -2.4 1 -> -0.4
+ddrmn013 remaindernear -2.4 -1 -> -0.4
+ddrmn014 remaindernear 2.40 1 -> 0.40
+ddrmn015 remaindernear 2.400 1 -> 0.400
+ddrmn016 remaindernear 2.4 2 -> 0.4
+ddrmn017 remaindernear 2.400 2 -> 0.400
+ddrmn018 remaindernear 2. 2 -> 0
+ddrmn019 remaindernear 20 20 -> 0
+
+ddrmn020 remaindernear 187 187 -> 0
+ddrmn021 remaindernear 5 2 -> 1
+ddrmn022 remaindernear 5 2.0 -> 1.0
+ddrmn023 remaindernear 5 2.000 -> 1.000
+ddrmn024 remaindernear 5 0.200 -> 0.000
+ddrmn025 remaindernear 5 0.200 -> 0.000
+
+ddrmn030 remaindernear 1 2 -> 1
+ddrmn031 remaindernear 1 4 -> 1
+ddrmn032 remaindernear 1 8 -> 1
+
+ddrmn033 remaindernear 1 16 -> 1
+ddrmn034 remaindernear 1 32 -> 1
+ddrmn035 remaindernear 1 64 -> 1
+ddrmn040 remaindernear 1 -2 -> 1
+ddrmn041 remaindernear 1 -4 -> 1
+ddrmn042 remaindernear 1 -8 -> 1
+ddrmn043 remaindernear 1 -16 -> 1
+ddrmn044 remaindernear 1 -32 -> 1
+ddrmn045 remaindernear 1 -64 -> 1
+ddrmn050 remaindernear -1 2 -> -1
+ddrmn051 remaindernear -1 4 -> -1
+ddrmn052 remaindernear -1 8 -> -1
+ddrmn053 remaindernear -1 16 -> -1
+ddrmn054 remaindernear -1 32 -> -1
+ddrmn055 remaindernear -1 64 -> -1
+ddrmn060 remaindernear -1 -2 -> -1
+ddrmn061 remaindernear -1 -4 -> -1
+ddrmn062 remaindernear -1 -8 -> -1
+ddrmn063 remaindernear -1 -16 -> -1
+ddrmn064 remaindernear -1 -32 -> -1
+ddrmn065 remaindernear -1 -64 -> -1
+
+ddrmn066 remaindernear 9.9 1 -> -0.1
+ddrmn067 remaindernear 99.7 1 -> -0.3
+ddrmn068 remaindernear 999999999 1 -> 0
+ddrmn069 remaindernear 999999999.4 1 -> 0.4
+ddrmn070 remaindernear 999999999.5 1 -> -0.5
+ddrmn071 remaindernear 999999999.9 1 -> -0.1
+ddrmn072 remaindernear 999999999.999 1 -> -0.001
+ddrmn073 remaindernear 999999.999999 1 -> -0.000001
+ddrmn074 remaindernear 9 1 -> 0
+ddrmn075 remaindernear 9999999999999999 1 -> 0
+ddrmn076 remaindernear 9999999999999999 2 -> -1
+ddrmn077 remaindernear 9999999999999999 3 -> 0
+ddrmn078 remaindernear 9999999999999999 4 -> -1
+
+ddrmn080 remaindernear 0. 1 -> 0
+ddrmn081 remaindernear .0 1 -> 0.0
+ddrmn082 remaindernear 0.00 1 -> 0.00
+ddrmn083 remaindernear 0.00E+9 1 -> 0
+ddrmn084 remaindernear 0.00E+3 1 -> 0
+ddrmn085 remaindernear 0.00E+2 1 -> 0
+ddrmn086 remaindernear 0.00E+1 1 -> 0.0
+ddrmn087 remaindernear 0.00E+0 1 -> 0.00
+ddrmn088 remaindernear 0.00E-0 1 -> 0.00
+ddrmn089 remaindernear 0.00E-1 1 -> 0.000
+ddrmn090 remaindernear 0.00E-2 1 -> 0.0000
+ddrmn091 remaindernear 0.00E-3 1 -> 0.00000
+ddrmn092 remaindernear 0.00E-4 1 -> 0.000000
+ddrmn093 remaindernear 0.00E-5 1 -> 0E-7
+ddrmn094 remaindernear 0.00E-6 1 -> 0E-8
+ddrmn095 remaindernear 0.0000E-50 1 -> 0E-54
+
+-- Various flavours of remaindernear by 0
+ddrmn101 remaindernear 0 0 -> NaN Division_undefined
+ddrmn102 remaindernear 0 -0 -> NaN Division_undefined
+ddrmn103 remaindernear -0 0 -> NaN Division_undefined
+ddrmn104 remaindernear -0 -0 -> NaN Division_undefined
+ddrmn105 remaindernear 0.0E5 0 -> NaN Division_undefined
+ddrmn106 remaindernear 0.000 0 -> NaN Division_undefined
+-- [Some think this next group should be Division_by_zero exception, but
+-- IEEE 854 is explicit that it is Invalid operation .. for
+-- remainder-near, anyway]
+ddrmn107 remaindernear 0.0001 0 -> NaN Invalid_operation
+ddrmn108 remaindernear 0.01 0 -> NaN Invalid_operation
+ddrmn109 remaindernear 0.1 0 -> NaN Invalid_operation
+ddrmn110 remaindernear 1 0 -> NaN Invalid_operation
+ddrmn111 remaindernear 1 0.0 -> NaN Invalid_operation
+ddrmn112 remaindernear 10 0.0 -> NaN Invalid_operation
+ddrmn113 remaindernear 1E+100 0.0 -> NaN Invalid_operation
+ddrmn114 remaindernear 1E+380 0 -> NaN Invalid_operation
+ddrmn115 remaindernear 0.0001 -0 -> NaN Invalid_operation
+ddrmn116 remaindernear 0.01 -0 -> NaN Invalid_operation
+ddrmn119 remaindernear 0.1 -0 -> NaN Invalid_operation
+ddrmn120 remaindernear 1 -0 -> NaN Invalid_operation
+ddrmn121 remaindernear 1 -0.0 -> NaN Invalid_operation
+ddrmn122 remaindernear 10 -0.0 -> NaN Invalid_operation
+ddrmn123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation
+ddrmn124 remaindernear 1E+384 -0 -> NaN Invalid_operation
+-- and zeros on left
+ddrmn130 remaindernear 0 1 -> 0
+ddrmn131 remaindernear 0 -1 -> 0
+ddrmn132 remaindernear 0.0 1 -> 0.0
+ddrmn133 remaindernear 0.0 -1 -> 0.0
+ddrmn134 remaindernear -0 1 -> -0
+ddrmn135 remaindernear -0 -1 -> -0
+ddrmn136 remaindernear -0.0 1 -> -0.0
+ddrmn137 remaindernear -0.0 -1 -> -0.0
+
+-- 0.5ers
+ddrmn143 remaindernear 0.5 2 -> 0.5
+ddrmn144 remaindernear 0.5 2.1 -> 0.5
+ddrmn145 remaindernear 0.5 2.01 -> 0.50
+ddrmn146 remaindernear 0.5 2.001 -> 0.500
+ddrmn147 remaindernear 0.50 2 -> 0.50
+ddrmn148 remaindernear 0.50 2.01 -> 0.50
+ddrmn149 remaindernear 0.50 2.001 -> 0.500
+
+-- steadies
+ddrmn150 remaindernear 1 1 -> 0
+ddrmn151 remaindernear 1 2 -> 1
+ddrmn152 remaindernear 1 3 -> 1
+ddrmn153 remaindernear 1 4 -> 1
+ddrmn154 remaindernear 1 5 -> 1
+ddrmn155 remaindernear 1 6 -> 1
+ddrmn156 remaindernear 1 7 -> 1
+ddrmn157 remaindernear 1 8 -> 1
+ddrmn158 remaindernear 1 9 -> 1
+ddrmn159 remaindernear 1 10 -> 1
+ddrmn160 remaindernear 1 1 -> 0
+ddrmn161 remaindernear 2 1 -> 0
+ddrmn162 remaindernear 3 1 -> 0
+ddrmn163 remaindernear 4 1 -> 0
+ddrmn164 remaindernear 5 1 -> 0
+ddrmn165 remaindernear 6 1 -> 0
+ddrmn166 remaindernear 7 1 -> 0
+ddrmn167 remaindernear 8 1 -> 0
+ddrmn168 remaindernear 9 1 -> 0
+ddrmn169 remaindernear 10 1 -> 0
+
+-- some differences from remainder
+ddrmn171 remaindernear 0.4 1.020 -> 0.400
+ddrmn172 remaindernear 0.50 1.020 -> 0.500
+ddrmn173 remaindernear 0.51 1.020 -> 0.510
+ddrmn174 remaindernear 0.52 1.020 -> -0.500
+ddrmn175 remaindernear 0.6 1.020 -> -0.420
+
+-- More flavours of remaindernear by 0
+ddrmn201 remaindernear 0 0 -> NaN Division_undefined
+ddrmn202 remaindernear 0.0E5 0 -> NaN Division_undefined
+ddrmn203 remaindernear 0.000 0 -> NaN Division_undefined
+ddrmn204 remaindernear 0.0001 0 -> NaN Invalid_operation
+ddrmn205 remaindernear 0.01 0 -> NaN Invalid_operation
+ddrmn206 remaindernear 0.1 0 -> NaN Invalid_operation
+ddrmn207 remaindernear 1 0 -> NaN Invalid_operation
+ddrmn208 remaindernear 1 0.0 -> NaN Invalid_operation
+ddrmn209 remaindernear 10 0.0 -> NaN Invalid_operation
+ddrmn210 remaindernear 1E+100 0.0 -> NaN Invalid_operation
+ddrmn211 remaindernear 1E+380 0 -> NaN Invalid_operation
+
+-- tests from the extended specification
+ddrmn221 remaindernear 2.1 3 -> -0.9
+ddrmn222 remaindernear 10 6 -> -2
+ddrmn223 remaindernear 10 3 -> 1
+ddrmn224 remaindernear -10 3 -> -1
+ddrmn225 remaindernear 10.2 1 -> 0.2
+ddrmn226 remaindernear 10 0.3 -> 0.1
+ddrmn227 remaindernear 3.6 1.3 -> -0.3
+
+-- some differences from remainder
+ddrmn231 remaindernear -0.4 1.020 -> -0.400
+ddrmn232 remaindernear -0.50 1.020 -> -0.500
+ddrmn233 remaindernear -0.51 1.020 -> -0.510
+ddrmn234 remaindernear -0.52 1.020 -> 0.500
+ddrmn235 remaindernear -0.6 1.020 -> 0.420
+
+-- high Xs
+ddrmn240 remaindernear 1E+2 1.00 -> 0.00
+
+-- ddrmn3xx are from DiagBigDecimal
+ddrmn301 remaindernear 1 3 -> 1
+ddrmn302 remaindernear 5 5 -> 0
+ddrmn303 remaindernear 13 10 -> 3
+ddrmn304 remaindernear 13 50 -> 13
+ddrmn305 remaindernear 13 100 -> 13
+ddrmn306 remaindernear 13 1000 -> 13
+ddrmn307 remaindernear .13 1 -> 0.13
+ddrmn308 remaindernear 0.133 1 -> 0.133
+ddrmn309 remaindernear 0.1033 1 -> 0.1033
+ddrmn310 remaindernear 1.033 1 -> 0.033
+ddrmn311 remaindernear 10.33 1 -> 0.33
+ddrmn312 remaindernear 10.33 10 -> 0.33
+ddrmn313 remaindernear 103.3 1 -> 0.3
+ddrmn314 remaindernear 133 10 -> 3
+ddrmn315 remaindernear 1033 10 -> 3
+ddrmn316 remaindernear 1033 50 -> -17
+ddrmn317 remaindernear 101.0 3 -> -1.0
+ddrmn318 remaindernear 102.0 3 -> 0.0
+ddrmn319 remaindernear 103.0 3 -> 1.0
+ddrmn320 remaindernear 2.40 1 -> 0.40
+ddrmn321 remaindernear 2.400 1 -> 0.400
+ddrmn322 remaindernear 2.4 1 -> 0.4
+ddrmn323 remaindernear 2.4 2 -> 0.4
+ddrmn324 remaindernear 2.400 2 -> 0.400
+ddrmn325 remaindernear 1 0.3 -> 0.1
+ddrmn326 remaindernear 1 0.30 -> 0.10
+ddrmn327 remaindernear 1 0.300 -> 0.100
+ddrmn328 remaindernear 1 0.3000 -> 0.1000
+ddrmn329 remaindernear 1.0 0.3 -> 0.1
+ddrmn330 remaindernear 1.00 0.3 -> 0.10
+ddrmn331 remaindernear 1.000 0.3 -> 0.100
+ddrmn332 remaindernear 1.0000 0.3 -> 0.1000
+ddrmn333 remaindernear 0.5 2 -> 0.5
+ddrmn334 remaindernear 0.5 2.1 -> 0.5
+ddrmn335 remaindernear 0.5 2.01 -> 0.50
+ddrmn336 remaindernear 0.5 2.001 -> 0.500
+ddrmn337 remaindernear 0.50 2 -> 0.50
+ddrmn338 remaindernear 0.50 2.01 -> 0.50
+ddrmn339 remaindernear 0.50 2.001 -> 0.500
+
+ddrmn340 remaindernear 0.5 0.5000001 -> -1E-7
+ddrmn341 remaindernear 0.5 0.50000001 -> -1E-8
+ddrmn342 remaindernear 0.5 0.500000001 -> -1E-9
+ddrmn343 remaindernear 0.5 0.5000000001 -> -1E-10
+ddrmn344 remaindernear 0.5 0.50000000001 -> -1E-11
+ddrmn345 remaindernear 0.5 0.4999999 -> 1E-7
+ddrmn346 remaindernear 0.5 0.49999999 -> 1E-8
+ddrmn347 remaindernear 0.5 0.499999999 -> 1E-9
+ddrmn348 remaindernear 0.5 0.4999999999 -> 1E-10
+ddrmn349 remaindernear 0.5 0.49999999999 -> 1E-11
+ddrmn350 remaindernear 0.5 0.499999999999 -> 1E-12
+
+ddrmn351 remaindernear 0.03 7 -> 0.03
+ddrmn352 remaindernear 5 2 -> 1
+ddrmn353 remaindernear 4.1 2 -> 0.1
+ddrmn354 remaindernear 4.01 2 -> 0.01
+ddrmn355 remaindernear 4.001 2 -> 0.001
+ddrmn356 remaindernear 4.0001 2 -> 0.0001
+ddrmn357 remaindernear 4.00001 2 -> 0.00001
+ddrmn358 remaindernear 4.000001 2 -> 0.000001
+ddrmn359 remaindernear 4.0000001 2 -> 1E-7
+
+ddrmn360 remaindernear 1.2 0.7345 -> -0.2690
+ddrmn361 remaindernear 0.8 12 -> 0.8
+ddrmn362 remaindernear 0.8 0.2 -> 0.0
+ddrmn363 remaindernear 0.8 0.3 -> -0.1
+ddrmn364 remaindernear 0.800 12 -> 0.800
+ddrmn365 remaindernear 0.800 1.7 -> 0.800
+ddrmn366 remaindernear 2.400 2 -> 0.400
+
+-- round to even
+ddrmn371 remaindernear 121 2 -> 1
+ddrmn372 remaindernear 122 2 -> 0
+ddrmn373 remaindernear 123 2 -> -1
+ddrmn374 remaindernear 124 2 -> 0
+ddrmn375 remaindernear 125 2 -> 1
+ddrmn376 remaindernear 126 2 -> 0
+ddrmn377 remaindernear 127 2 -> -1
+
+ddrmn381 remaindernear 12345 1 -> 0
+ddrmn382 remaindernear 12345 1.0001 -> -0.2344
+ddrmn383 remaindernear 12345 1.001 -> -0.333
+ddrmn384 remaindernear 12345 1.01 -> -0.23
+ddrmn385 remaindernear 12345 1.1 -> -0.3
+ddrmn386 remaindernear 12355 4 -> -1
+ddrmn387 remaindernear 12345 4 -> 1
+ddrmn388 remaindernear 12355 4.0001 -> -1.3089
+ddrmn389 remaindernear 12345 4.0001 -> 0.6914
+ddrmn390 remaindernear 12345 4.9 -> 1.9
+ddrmn391 remaindernear 12345 4.99 -> -0.26
+ddrmn392 remaindernear 12345 4.999 -> 2.469
+ddrmn393 remaindernear 12345 4.9999 -> 0.2469
+ddrmn394 remaindernear 12345 5 -> 0
+ddrmn395 remaindernear 12345 5.0001 -> -0.2469
+ddrmn396 remaindernear 12345 5.001 -> -2.469
+ddrmn397 remaindernear 12345 5.01 -> 0.36
+ddrmn398 remaindernear 12345 5.1 -> -2.1
+
+-- the nasty division-by-1 cases
+ddrmn401 remaindernear 0.4 1 -> 0.4
+ddrmn402 remaindernear 0.45 1 -> 0.45
+ddrmn403 remaindernear 0.455 1 -> 0.455
+ddrmn404 remaindernear 0.4555 1 -> 0.4555
+ddrmn405 remaindernear 0.45555 1 -> 0.45555
+ddrmn406 remaindernear 0.455555 1 -> 0.455555
+ddrmn407 remaindernear 0.4555555 1 -> 0.4555555
+ddrmn408 remaindernear 0.45555555 1 -> 0.45555555
+ddrmn409 remaindernear 0.455555555 1 -> 0.455555555
+-- with spill... [412 exercises sticktab loop]
+ddrmn411 remaindernear 0.5 1 -> 0.5
+ddrmn412 remaindernear 0.55 1 -> -0.45
+ddrmn413 remaindernear 0.555 1 -> -0.445
+ddrmn414 remaindernear 0.5555 1 -> -0.4445
+ddrmn415 remaindernear 0.55555 1 -> -0.44445
+ddrmn416 remaindernear 0.555555 1 -> -0.444445
+ddrmn417 remaindernear 0.5555555 1 -> -0.4444445
+ddrmn418 remaindernear 0.55555555 1 -> -0.44444445
+ddrmn419 remaindernear 0.555555555 1 -> -0.444444445
+
+-- folddowns
+ddrmn421 remaindernear 1E+384 1 -> NaN Division_impossible
+ddrmn422 remaindernear 1E+384 1E+383 -> 0E+369 Clamped
+ddrmn423 remaindernear 1E+384 2E+383 -> 0E+369 Clamped
+ddrmn424 remaindernear 1E+384 3E+383 -> 1.00000000000000E+383 Clamped
+ddrmn425 remaindernear 1E+384 4E+383 -> 2.00000000000000E+383 Clamped
+ddrmn426 remaindernear 1E+384 5E+383 -> 0E+369 Clamped
+ddrmn427 remaindernear 1E+384 6E+383 -> -2.00000000000000E+383 Clamped
+ddrmn428 remaindernear 1E+384 7E+383 -> 3.00000000000000E+383 Clamped
+ddrmn429 remaindernear 1E+384 8E+383 -> 2.00000000000000E+383 Clamped
+ddrmn430 remaindernear 1E+384 9E+383 -> 1.00000000000000E+383 Clamped
+-- tinies
+ddrmn431 remaindernear 1E-397 1E-398 -> 0E-398
+ddrmn432 remaindernear 1E-397 2E-398 -> 0E-398
+ddrmn433 remaindernear 1E-397 3E-398 -> 1E-398 Subnormal
+ddrmn434 remaindernear 1E-397 4E-398 -> 2E-398 Subnormal
+ddrmn435 remaindernear 1E-397 5E-398 -> 0E-398
+ddrmn436 remaindernear 1E-397 6E-398 -> -2E-398 Subnormal
+ddrmn437 remaindernear 1E-397 7E-398 -> 3E-398 Subnormal
+ddrmn438 remaindernear 1E-397 8E-398 -> 2E-398 Subnormal
+ddrmn439 remaindernear 1E-397 9E-398 -> 1E-398 Subnormal
+ddrmn440 remaindernear 1E-397 10E-398 -> 0E-398
+ddrmn441 remaindernear 1E-397 11E-398 -> -1E-398 Subnormal
+ddrmn442 remaindernear 100E-397 11E-398 -> -1E-398 Subnormal
+ddrmn443 remaindernear 100E-397 20E-398 -> 0E-398
+ddrmn444 remaindernear 100E-397 21E-398 -> -8E-398 Subnormal
+ddrmn445 remaindernear 100E-397 30E-398 -> 1.0E-397 Subnormal
+
+-- zero signs
+ddrmn650 remaindernear 1 1 -> 0
+ddrmn651 remaindernear -1 1 -> -0
+ddrmn652 remaindernear 1 -1 -> 0
+ddrmn653 remaindernear -1 -1 -> -0
+ddrmn654 remaindernear 0 1 -> 0
+ddrmn655 remaindernear -0 1 -> -0
+ddrmn656 remaindernear 0 -1 -> 0
+ddrmn657 remaindernear -0 -1 -> -0
+ddrmn658 remaindernear 0.00 1 -> 0.00
+ddrmn659 remaindernear -0.00 1 -> -0.00
+
+-- Specials
+ddrmn680 remaindernear Inf -Inf -> NaN Invalid_operation
+ddrmn681 remaindernear Inf -1000 -> NaN Invalid_operation
+ddrmn682 remaindernear Inf -1 -> NaN Invalid_operation
+ddrmn683 remaindernear Inf 0 -> NaN Invalid_operation
+ddrmn684 remaindernear Inf -0 -> NaN Invalid_operation
+ddrmn685 remaindernear Inf 1 -> NaN Invalid_operation
+ddrmn686 remaindernear Inf 1000 -> NaN Invalid_operation
+ddrmn687 remaindernear Inf Inf -> NaN Invalid_operation
+ddrmn688 remaindernear -1000 Inf -> -1000
+ddrmn689 remaindernear -Inf Inf -> NaN Invalid_operation
+ddrmn691 remaindernear -1 Inf -> -1
+ddrmn692 remaindernear 0 Inf -> 0
+ddrmn693 remaindernear -0 Inf -> -0
+ddrmn694 remaindernear 1 Inf -> 1
+ddrmn695 remaindernear 1000 Inf -> 1000
+ddrmn696 remaindernear Inf Inf -> NaN Invalid_operation
+
+ddrmn700 remaindernear -Inf -Inf -> NaN Invalid_operation
+ddrmn701 remaindernear -Inf -1000 -> NaN Invalid_operation
+ddrmn702 remaindernear -Inf -1 -> NaN Invalid_operation
+ddrmn703 remaindernear -Inf -0 -> NaN Invalid_operation
+ddrmn704 remaindernear -Inf 0 -> NaN Invalid_operation
+ddrmn705 remaindernear -Inf 1 -> NaN Invalid_operation
+ddrmn706 remaindernear -Inf 1000 -> NaN Invalid_operation
+ddrmn707 remaindernear -Inf Inf -> NaN Invalid_operation
+ddrmn708 remaindernear -Inf -Inf -> NaN Invalid_operation
+ddrmn709 remaindernear -1000 Inf -> -1000
+ddrmn710 remaindernear -1 -Inf -> -1
+ddrmn711 remaindernear -0 -Inf -> -0
+ddrmn712 remaindernear 0 -Inf -> 0
+ddrmn713 remaindernear 1 -Inf -> 1
+ddrmn714 remaindernear 1000 -Inf -> 1000
+ddrmn715 remaindernear Inf -Inf -> NaN Invalid_operation
+
+ddrmn721 remaindernear NaN -Inf -> NaN
+ddrmn722 remaindernear NaN -1000 -> NaN
+ddrmn723 remaindernear NaN -1 -> NaN
+ddrmn724 remaindernear NaN -0 -> NaN
+ddrmn725 remaindernear -NaN 0 -> -NaN
+ddrmn726 remaindernear NaN 1 -> NaN
+ddrmn727 remaindernear NaN 1000 -> NaN
+ddrmn728 remaindernear NaN Inf -> NaN
+ddrmn729 remaindernear NaN -NaN -> NaN
+ddrmn730 remaindernear -Inf NaN -> NaN
+ddrmn731 remaindernear -1000 NaN -> NaN
+ddrmn732 remaindernear -1 NaN -> NaN
+ddrmn733 remaindernear -0 -NaN -> -NaN
+ddrmn734 remaindernear 0 NaN -> NaN
+ddrmn735 remaindernear 1 -NaN -> -NaN
+ddrmn736 remaindernear 1000 NaN -> NaN
+ddrmn737 remaindernear Inf NaN -> NaN
+
+ddrmn741 remaindernear sNaN -Inf -> NaN Invalid_operation
+ddrmn742 remaindernear sNaN -1000 -> NaN Invalid_operation
+ddrmn743 remaindernear -sNaN -1 -> -NaN Invalid_operation
+ddrmn744 remaindernear sNaN -0 -> NaN Invalid_operation
+ddrmn745 remaindernear sNaN 0 -> NaN Invalid_operation
+ddrmn746 remaindernear sNaN 1 -> NaN Invalid_operation
+ddrmn747 remaindernear sNaN 1000 -> NaN Invalid_operation
+ddrmn749 remaindernear sNaN NaN -> NaN Invalid_operation
+ddrmn750 remaindernear sNaN sNaN -> NaN Invalid_operation
+ddrmn751 remaindernear NaN sNaN -> NaN Invalid_operation
+ddrmn752 remaindernear -Inf sNaN -> NaN Invalid_operation
+ddrmn753 remaindernear -1000 sNaN -> NaN Invalid_operation
+ddrmn754 remaindernear -1 sNaN -> NaN Invalid_operation
+ddrmn755 remaindernear -0 sNaN -> NaN Invalid_operation
+ddrmn756 remaindernear 0 sNaN -> NaN Invalid_operation
+ddrmn757 remaindernear 1 sNaN -> NaN Invalid_operation
+ddrmn758 remaindernear 1000 sNaN -> NaN Invalid_operation
+ddrmn759 remaindernear Inf -sNaN -> -NaN Invalid_operation
+
+-- propaging NaNs
+ddrmn760 remaindernear NaN1 NaN7 -> NaN1
+ddrmn761 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation
+ddrmn762 remaindernear NaN3 sNaN9 -> NaN9 Invalid_operation
+ddrmn763 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation
+ddrmn764 remaindernear 15 NaN11 -> NaN11
+ddrmn765 remaindernear NaN6 NaN12 -> NaN6
+ddrmn766 remaindernear Inf NaN13 -> NaN13
+ddrmn767 remaindernear NaN14 -Inf -> NaN14
+ddrmn768 remaindernear 0 NaN15 -> NaN15
+ddrmn769 remaindernear NaN16 -0 -> NaN16
+
+-- edge cases of impossible
+ddrmn770 remaindernear 1234567890123456 10 -> -4
+ddrmn771 remaindernear 1234567890123456 1 -> 0
+ddrmn772 remaindernear 1234567890123456 0.1 -> NaN Division_impossible
+ddrmn773 remaindernear 1234567890123456 0.01 -> NaN Division_impossible
+
+-- long operand checks
+ddrmn801 remaindernear 12345678000 100 -> 0
+ddrmn802 remaindernear 1 12345678000 -> 1
+ddrmn803 remaindernear 1234567800 10 -> 0
+ddrmn804 remaindernear 1 1234567800 -> 1
+ddrmn805 remaindernear 1234567890 10 -> 0
+ddrmn806 remaindernear 1 1234567890 -> 1
+ddrmn807 remaindernear 1234567891 10 -> 1
+ddrmn808 remaindernear 1 1234567891 -> 1
+ddrmn809 remaindernear 12345678901 100 -> 1
+ddrmn810 remaindernear 1 12345678901 -> 1
+ddrmn811 remaindernear 1234567896 10 -> -4
+ddrmn812 remaindernear 1 1234567896 -> 1
+
+ddrmn821 remaindernear 12345678000 100 -> 0
+ddrmn822 remaindernear 1 12345678000 -> 1
+ddrmn823 remaindernear 1234567800 10 -> 0
+ddrmn824 remaindernear 1 1234567800 -> 1
+ddrmn825 remaindernear 1234567890 10 -> 0
+ddrmn826 remaindernear 1 1234567890 -> 1
+ddrmn827 remaindernear 1234567891 10 -> 1
+ddrmn828 remaindernear 1 1234567891 -> 1
+ddrmn829 remaindernear 12345678901 100 -> 1
+ddrmn830 remaindernear 1 12345678901 -> 1
+ddrmn831 remaindernear 1234567896 10 -> -4
+ddrmn832 remaindernear 1 1234567896 -> 1
+
+-- from divideint
+ddrmn840 remaindernear 100000000.0 1 -> 0.0
+ddrmn841 remaindernear 100000000.4 1 -> 0.4
+ddrmn842 remaindernear 100000000.5 1 -> 0.5
+ddrmn843 remaindernear 100000000.9 1 -> -0.1
+ddrmn844 remaindernear 100000000.999 1 -> -0.001
+ddrmn850 remaindernear 100000003 5 -> -2
+ddrmn851 remaindernear 10000003 5 -> -2
+ddrmn852 remaindernear 1000003 5 -> -2
+ddrmn853 remaindernear 100003 5 -> -2
+ddrmn854 remaindernear 10003 5 -> -2
+ddrmn855 remaindernear 1003 5 -> -2
+ddrmn856 remaindernear 103 5 -> -2
+ddrmn857 remaindernear 13 5 -> -2
+ddrmn858 remaindernear 1 5 -> 1
+
+-- Vladimir's cases 1234567890123456
+ddrmn860 remaindernear 123.0e1 1000000000000000 -> 1230
+ddrmn861 remaindernear 1230 1000000000000000 -> 1230
+ddrmn862 remaindernear 12.3e2 1000000000000000 -> 1230
+ddrmn863 remaindernear 1.23e3 1000000000000000 -> 1230
+ddrmn864 remaindernear 123e1 1000000000000000 -> 1230
+ddrmn870 remaindernear 123e1 1000000000000000 -> 1230
+ddrmn871 remaindernear 123e1 100000000000000 -> 1230
+ddrmn872 remaindernear 123e1 10000000000000 -> 1230
+ddrmn873 remaindernear 123e1 1000000000000 -> 1230
+ddrmn874 remaindernear 123e1 100000000000 -> 1230
+ddrmn875 remaindernear 123e1 10000000000 -> 1230
+ddrmn876 remaindernear 123e1 1000000000 -> 1230
+ddrmn877 remaindernear 123e1 100000000 -> 1230
+ddrmn878 remaindernear 1230 100000000 -> 1230
+ddrmn879 remaindernear 123e1 10000000 -> 1230
+ddrmn880 remaindernear 123e1 1000000 -> 1230
+ddrmn881 remaindernear 123e1 100000 -> 1230
+ddrmn882 remaindernear 123e1 10000 -> 1230
+ddrmn883 remaindernear 123e1 1000 -> 230
+ddrmn884 remaindernear 123e1 100 -> 30
+ddrmn885 remaindernear 123e1 10 -> 0
+ddrmn886 remaindernear 123e1 1 -> 0
+
+ddrmn890 remaindernear 123e1 2000000000000000 -> 1230
+ddrmn891 remaindernear 123e1 200000000000000 -> 1230
+ddrmn892 remaindernear 123e1 20000000000000 -> 1230
+ddrmn893 remaindernear 123e1 2000000000000 -> 1230
+ddrmn894 remaindernear 123e1 200000000000 -> 1230
+ddrmn895 remaindernear 123e1 20000000000 -> 1230
+ddrmn896 remaindernear 123e1 2000000000 -> 1230
+ddrmn897 remaindernear 123e1 200000000 -> 1230
+ddrmn899 remaindernear 123e1 20000000 -> 1230
+ddrmn900 remaindernear 123e1 2000000 -> 1230
+ddrmn901 remaindernear 123e1 200000 -> 1230
+ddrmn902 remaindernear 123e1 20000 -> 1230
+ddrmn903 remaindernear 123e1 2000 -> -770
+ddrmn904 remaindernear 123e1 200 -> 30
+ddrmn905 remaindernear 123e1 20 -> -10
+ddrmn906 remaindernear 123e1 2 -> 0
+
+ddrmn910 remaindernear 123e1 5000000000000000 -> 1230
+ddrmn911 remaindernear 123e1 500000000000000 -> 1230
+ddrmn912 remaindernear 123e1 50000000000000 -> 1230
+ddrmn913 remaindernear 123e1 5000000000000 -> 1230
+ddrmn914 remaindernear 123e1 500000000000 -> 1230
+ddrmn915 remaindernear 123e1 50000000000 -> 1230
+ddrmn916 remaindernear 123e1 5000000000 -> 1230
+ddrmn917 remaindernear 123e1 500000000 -> 1230
+ddrmn919 remaindernear 123e1 50000000 -> 1230
+ddrmn920 remaindernear 123e1 5000000 -> 1230
+ddrmn921 remaindernear 123e1 500000 -> 1230
+ddrmn922 remaindernear 123e1 50000 -> 1230
+ddrmn923 remaindernear 123e1 5000 -> 1230
+ddrmn924 remaindernear 123e1 500 -> 230
+ddrmn925 remaindernear 123e1 50 -> -20
+ddrmn926 remaindernear 123e1 5 -> 0
+
+ddrmn930 remaindernear 123e1 9000000000000000 -> 1230
+ddrmn931 remaindernear 123e1 900000000000000 -> 1230
+ddrmn932 remaindernear 123e1 90000000000000 -> 1230
+ddrmn933 remaindernear 123e1 9000000000000 -> 1230
+ddrmn934 remaindernear 123e1 900000000000 -> 1230
+ddrmn935 remaindernear 123e1 90000000000 -> 1230
+ddrmn936 remaindernear 123e1 9000000000 -> 1230
+ddrmn937 remaindernear 123e1 900000000 -> 1230
+ddrmn939 remaindernear 123e1 90000000 -> 1230
+ddrmn940 remaindernear 123e1 9000000 -> 1230
+ddrmn941 remaindernear 123e1 900000 -> 1230
+ddrmn942 remaindernear 123e1 90000 -> 1230
+ddrmn943 remaindernear 123e1 9000 -> 1230
+ddrmn944 remaindernear 123e1 900 -> 330
+ddrmn945 remaindernear 123e1 90 -> -30
+ddrmn946 remaindernear 123e1 9 -> -3
+
+ddrmn950 remaindernear 123e1 1000000000000000 -> 1230
+ddrmn961 remaindernear 123e1 2999999999999999 -> 1230
+ddrmn962 remaindernear 123e1 3999999999999999 -> 1230
+ddrmn963 remaindernear 123e1 4999999999999999 -> 1230
+ddrmn964 remaindernear 123e1 5999999999999999 -> 1230
+ddrmn965 remaindernear 123e1 6999999999999999 -> 1230
+ddrmn966 remaindernear 123e1 7999999999999999 -> 1230
+ddrmn967 remaindernear 123e1 8999999999999999 -> 1230
+ddrmn968 remaindernear 123e1 9999999999999999 -> 1230
+ddrmn969 remaindernear 123e1 9876543210987654 -> 1230
+
+ddrmn980 remaindernear 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
+
+
+-- overflow and underflow tests [from divide]
+ddrmn1051 remaindernear 1e+277 1e-311 -> NaN Division_impossible
+ddrmn1052 remaindernear 1e+277 -1e-311 -> NaN Division_impossible
+ddrmn1053 remaindernear -1e+277 1e-311 -> NaN Division_impossible
+ddrmn1054 remaindernear -1e+277 -1e-311 -> NaN Division_impossible
+ddrmn1055 remaindernear 1e-277 1e+311 -> 1E-277
+ddrmn1056 remaindernear 1e-277 -1e+311 -> 1E-277
+ddrmn1057 remaindernear -1e-277 1e+311 -> -1E-277
+ddrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277
+
+-- destructive subtract
+ddrmn1100 remainderNear 1234567890123456 1.000000000000001 -> -0.234567890123455
+ddrmn1101 remainderNear 1234567890123456 1.00000000000001 -> -0.34567890123444
+ddrmn1102 remainderNear 1234567890123456 1.0000000000001 -> -0.4567890123333
+ddrmn1103 remainderNear 1234567890123455 4.000000000000001 -> -1.308641972530864
+ddrmn1104 remainderNear 1234567890123456 4.000000000000001 -> -0.308641972530864
+ddrmn1115 remainderNear 1234567890123456 4.9999999999999 -> 0.6913578024696
+ddrmn1116 remainderNear 1234567890123456 4.99999999999999 -> -1.53086421975308
+ddrmn1117 remainderNear 1234567890123456 4.999999999999999 -> 1.246913578024691
+ddrmn1118 remainderNear 1234567890123456 5.000000000000001 -> 0.753086421975309
+ddrmn1119 remainderNear 1234567890123456 5.00000000000001 -> -1.46913578024691
+ddrmn1110 remainderNear 1234567890123456 5.0000000000001 -> 1.3086421975314
+
+-- Null tests
+ddrmn1000 remaindernear 10 # -> NaN Invalid_operation
+ddrmn1001 remaindernear # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddRotate.decTest b/Lib/test/decimaltestdata/ddRotate.decTest
index 8b0fe2620d..87eeb1c0f1 100644
--- a/Lib/test/decimaltestdata/ddRotate.decTest
+++ b/Lib/test/decimaltestdata/ddRotate.decTest
@@ -1,262 +1,262 @@
-------------------------------------------------------------------------
--- ddRotate.decTest -- rotate a decDouble coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddrot001 rotate 0 0 -> 0
-ddrot002 rotate 0 2 -> 0
-ddrot003 rotate 1 2 -> 100
-ddrot004 rotate 1 15 -> 1000000000000000
-ddrot005 rotate 1 16 -> 1
-ddrot006 rotate 1 -1 -> 1000000000000000
-ddrot007 rotate 0 -2 -> 0
-ddrot008 rotate 1234567890123456 -1 -> 6123456789012345
-ddrot009 rotate 1234567890123456 -15 -> 2345678901234561
-ddrot010 rotate 1234567890123456 -16 -> 1234567890123456
-ddrot011 rotate 9934567890123456 -15 -> 9345678901234569
-ddrot012 rotate 9934567890123456 -16 -> 9934567890123456
-
--- rhs must be an integer
-ddrot015 rotate 1 1.5 -> NaN Invalid_operation
-ddrot016 rotate 1 1.0 -> NaN Invalid_operation
-ddrot017 rotate 1 0.1 -> NaN Invalid_operation
-ddrot018 rotate 1 0.0 -> NaN Invalid_operation
-ddrot019 rotate 1 1E+1 -> NaN Invalid_operation
-ddrot020 rotate 1 1E+99 -> NaN Invalid_operation
-ddrot021 rotate 1 Inf -> NaN Invalid_operation
-ddrot022 rotate 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-ddrot025 rotate 1 -1000 -> NaN Invalid_operation
-ddrot026 rotate 1 -17 -> NaN Invalid_operation
-ddrot027 rotate 1 17 -> NaN Invalid_operation
-ddrot028 rotate 1 1000 -> NaN Invalid_operation
-
--- full pattern
-ddrot030 rotate 1234567890123456 -16 -> 1234567890123456
-ddrot031 rotate 1234567890123456 -15 -> 2345678901234561
-ddrot032 rotate 1234567890123456 -14 -> 3456789012345612
-ddrot033 rotate 1234567890123456 -13 -> 4567890123456123
-ddrot034 rotate 1234567890123456 -12 -> 5678901234561234
-ddrot035 rotate 1234567890123456 -11 -> 6789012345612345
-ddrot036 rotate 1234567890123456 -10 -> 7890123456123456
-ddrot037 rotate 1234567890123456 -9 -> 8901234561234567
-ddrot038 rotate 1234567890123456 -8 -> 9012345612345678
-ddrot039 rotate 1234567890123456 -7 -> 123456123456789
-ddrot040 rotate 1234567890123456 -6 -> 1234561234567890
-ddrot041 rotate 1234567890123456 -5 -> 2345612345678901
-ddrot042 rotate 1234567890123456 -4 -> 3456123456789012
-ddrot043 rotate 1234567890123456 -3 -> 4561234567890123
-ddrot044 rotate 1234567890123456 -2 -> 5612345678901234
-ddrot045 rotate 1234567890123456 -1 -> 6123456789012345
-ddrot046 rotate 1234567890123456 -0 -> 1234567890123456
-
-ddrot047 rotate 1234567890123456 +0 -> 1234567890123456
-ddrot048 rotate 1234567890123456 +1 -> 2345678901234561
-ddrot049 rotate 1234567890123456 +2 -> 3456789012345612
-ddrot050 rotate 1234567890123456 +3 -> 4567890123456123
-ddrot051 rotate 1234567890123456 +4 -> 5678901234561234
-ddrot052 rotate 1234567890123456 +5 -> 6789012345612345
-ddrot053 rotate 1234567890123456 +6 -> 7890123456123456
-ddrot054 rotate 1234567890123456 +7 -> 8901234561234567
-ddrot055 rotate 1234567890123456 +8 -> 9012345612345678
-ddrot056 rotate 1234567890123456 +9 -> 123456123456789
-ddrot057 rotate 1234567890123456 +10 -> 1234561234567890
-ddrot058 rotate 1234567890123456 +11 -> 2345612345678901
-ddrot059 rotate 1234567890123456 +12 -> 3456123456789012
-ddrot060 rotate 1234567890123456 +13 -> 4561234567890123
-ddrot061 rotate 1234567890123456 +14 -> 5612345678901234
-ddrot062 rotate 1234567890123456 +15 -> 6123456789012345
-ddrot063 rotate 1234567890123456 +16 -> 1234567890123456
-
--- zeros
-ddrot070 rotate 0E-10 +9 -> 0E-10
-ddrot071 rotate 0E-10 -9 -> 0E-10
-ddrot072 rotate 0.000 +9 -> 0.000
-ddrot073 rotate 0.000 -9 -> 0.000
-ddrot074 rotate 0E+10 +9 -> 0E+10
-ddrot075 rotate 0E+10 -9 -> 0E+10
-ddrot076 rotate -0E-10 +9 -> -0E-10
-ddrot077 rotate -0E-10 -9 -> -0E-10
-ddrot078 rotate -0.000 +9 -> -0.000
-ddrot079 rotate -0.000 -9 -> -0.000
-ddrot080 rotate -0E+10 +9 -> -0E+10
-ddrot081 rotate -0E+10 -9 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-ddrot141 rotate 9.999999999999999E+384 -1 -> 9.999999999999999E+384
-ddrot142 rotate 9.999999999999999E+384 -15 -> 9.999999999999999E+384
-ddrot143 rotate 9.999999999999999E+384 1 -> 9.999999999999999E+384
-ddrot144 rotate 9.999999999999999E+384 15 -> 9.999999999999999E+384
-ddrot145 rotate 1E-383 -1 -> 1.000000000000000E-368
-ddrot146 rotate 1E-383 -15 -> 1.0E-382
-ddrot147 rotate 1E-383 1 -> 1.0E-382
-ddrot148 rotate 1E-383 15 -> 1.000000000000000E-368
-ddrot151 rotate 1.000000000000000E-383 -1 -> 1.00000000000000E-384
-ddrot152 rotate 1.000000000000000E-383 -15 -> 1E-398
-ddrot153 rotate 1.000000000000000E-383 1 -> 1E-398
-ddrot154 rotate 1.000000000000000E-383 15 -> 1.00000000000000E-384
-ddrot155 rotate 9.000000000000000E-383 -1 -> 9.00000000000000E-384
-ddrot156 rotate 9.000000000000000E-383 -15 -> 9E-398
-ddrot157 rotate 9.000000000000000E-383 1 -> 9E-398
-ddrot158 rotate 9.000000000000000E-383 15 -> 9.00000000000000E-384
-ddrot160 rotate 1E-398 -1 -> 1.000000000000000E-383
-ddrot161 rotate 1E-398 -15 -> 1.0E-397
-ddrot162 rotate 1E-398 1 -> 1.0E-397
-ddrot163 rotate 1E-398 15 -> 1.000000000000000E-383
--- negatives
-ddrot171 rotate -9.999999999999999E+384 -1 -> -9.999999999999999E+384
-ddrot172 rotate -9.999999999999999E+384 -15 -> -9.999999999999999E+384
-ddrot173 rotate -9.999999999999999E+384 1 -> -9.999999999999999E+384
-ddrot174 rotate -9.999999999999999E+384 15 -> -9.999999999999999E+384
-ddrot175 rotate -1E-383 -1 -> -1.000000000000000E-368
-ddrot176 rotate -1E-383 -15 -> -1.0E-382
-ddrot177 rotate -1E-383 1 -> -1.0E-382
-ddrot178 rotate -1E-383 15 -> -1.000000000000000E-368
-ddrot181 rotate -1.000000000000000E-383 -1 -> -1.00000000000000E-384
-ddrot182 rotate -1.000000000000000E-383 -15 -> -1E-398
-ddrot183 rotate -1.000000000000000E-383 1 -> -1E-398
-ddrot184 rotate -1.000000000000000E-383 15 -> -1.00000000000000E-384
-ddrot185 rotate -9.000000000000000E-383 -1 -> -9.00000000000000E-384
-ddrot186 rotate -9.000000000000000E-383 -15 -> -9E-398
-ddrot187 rotate -9.000000000000000E-383 1 -> -9E-398
-ddrot188 rotate -9.000000000000000E-383 15 -> -9.00000000000000E-384
-ddrot190 rotate -1E-398 -1 -> -1.000000000000000E-383
-ddrot191 rotate -1E-398 -15 -> -1.0E-397
-ddrot192 rotate -1E-398 1 -> -1.0E-397
-ddrot193 rotate -1E-398 15 -> -1.000000000000000E-383
-
--- more negatives (of sanities)
-ddrot201 rotate -0 0 -> -0
-ddrot202 rotate -0 2 -> -0
-ddrot203 rotate -1 2 -> -100
-ddrot204 rotate -1 15 -> -1000000000000000
-ddrot205 rotate -1 16 -> -1
-ddrot206 rotate -1 -1 -> -1000000000000000
-ddrot207 rotate -0 -2 -> -0
-ddrot208 rotate -1234567890123456 -1 -> -6123456789012345
-ddrot209 rotate -1234567890123456 -15 -> -2345678901234561
-ddrot210 rotate -1234567890123456 -16 -> -1234567890123456
-ddrot211 rotate -9934567890123456 -15 -> -9345678901234569
-ddrot212 rotate -9934567890123456 -16 -> -9934567890123456
-
-
--- Specials; NaNs are handled as usual
-ddrot781 rotate -Inf -8 -> -Infinity
-ddrot782 rotate -Inf -1 -> -Infinity
-ddrot783 rotate -Inf -0 -> -Infinity
-ddrot784 rotate -Inf 0 -> -Infinity
-ddrot785 rotate -Inf 1 -> -Infinity
-ddrot786 rotate -Inf 8 -> -Infinity
-ddrot787 rotate -1000 -Inf -> NaN Invalid_operation
-ddrot788 rotate -Inf -Inf -> NaN Invalid_operation
-ddrot789 rotate -1 -Inf -> NaN Invalid_operation
-ddrot790 rotate -0 -Inf -> NaN Invalid_operation
-ddrot791 rotate 0 -Inf -> NaN Invalid_operation
-ddrot792 rotate 1 -Inf -> NaN Invalid_operation
-ddrot793 rotate 1000 -Inf -> NaN Invalid_operation
-ddrot794 rotate Inf -Inf -> NaN Invalid_operation
-
-ddrot800 rotate Inf -Inf -> NaN Invalid_operation
-ddrot801 rotate Inf -8 -> Infinity
-ddrot802 rotate Inf -1 -> Infinity
-ddrot803 rotate Inf -0 -> Infinity
-ddrot804 rotate Inf 0 -> Infinity
-ddrot805 rotate Inf 1 -> Infinity
-ddrot806 rotate Inf 8 -> Infinity
-ddrot807 rotate Inf Inf -> NaN Invalid_operation
-ddrot808 rotate -1000 Inf -> NaN Invalid_operation
-ddrot809 rotate -Inf Inf -> NaN Invalid_operation
-ddrot810 rotate -1 Inf -> NaN Invalid_operation
-ddrot811 rotate -0 Inf -> NaN Invalid_operation
-ddrot812 rotate 0 Inf -> NaN Invalid_operation
-ddrot813 rotate 1 Inf -> NaN Invalid_operation
-ddrot814 rotate 1000 Inf -> NaN Invalid_operation
-ddrot815 rotate Inf Inf -> NaN Invalid_operation
-
-ddrot821 rotate NaN -Inf -> NaN
-ddrot822 rotate NaN -1000 -> NaN
-ddrot823 rotate NaN -1 -> NaN
-ddrot824 rotate NaN -0 -> NaN
-ddrot825 rotate NaN 0 -> NaN
-ddrot826 rotate NaN 1 -> NaN
-ddrot827 rotate NaN 1000 -> NaN
-ddrot828 rotate NaN Inf -> NaN
-ddrot829 rotate NaN NaN -> NaN
-ddrot830 rotate -Inf NaN -> NaN
-ddrot831 rotate -1000 NaN -> NaN
-ddrot832 rotate -1 NaN -> NaN
-ddrot833 rotate -0 NaN -> NaN
-ddrot834 rotate 0 NaN -> NaN
-ddrot835 rotate 1 NaN -> NaN
-ddrot836 rotate 1000 NaN -> NaN
-ddrot837 rotate Inf NaN -> NaN
-
-ddrot841 rotate sNaN -Inf -> NaN Invalid_operation
-ddrot842 rotate sNaN -1000 -> NaN Invalid_operation
-ddrot843 rotate sNaN -1 -> NaN Invalid_operation
-ddrot844 rotate sNaN -0 -> NaN Invalid_operation
-ddrot845 rotate sNaN 0 -> NaN Invalid_operation
-ddrot846 rotate sNaN 1 -> NaN Invalid_operation
-ddrot847 rotate sNaN 1000 -> NaN Invalid_operation
-ddrot848 rotate sNaN NaN -> NaN Invalid_operation
-ddrot849 rotate sNaN sNaN -> NaN Invalid_operation
-ddrot850 rotate NaN sNaN -> NaN Invalid_operation
-ddrot851 rotate -Inf sNaN -> NaN Invalid_operation
-ddrot852 rotate -1000 sNaN -> NaN Invalid_operation
-ddrot853 rotate -1 sNaN -> NaN Invalid_operation
-ddrot854 rotate -0 sNaN -> NaN Invalid_operation
-ddrot855 rotate 0 sNaN -> NaN Invalid_operation
-ddrot856 rotate 1 sNaN -> NaN Invalid_operation
-ddrot857 rotate 1000 sNaN -> NaN Invalid_operation
-ddrot858 rotate Inf sNaN -> NaN Invalid_operation
-ddrot859 rotate NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddrot861 rotate NaN1 -Inf -> NaN1
-ddrot862 rotate +NaN2 -1000 -> NaN2
-ddrot863 rotate NaN3 1000 -> NaN3
-ddrot864 rotate NaN4 Inf -> NaN4
-ddrot865 rotate NaN5 +NaN6 -> NaN5
-ddrot866 rotate -Inf NaN7 -> NaN7
-ddrot867 rotate -1000 NaN8 -> NaN8
-ddrot868 rotate 1000 NaN9 -> NaN9
-ddrot869 rotate Inf +NaN10 -> NaN10
-ddrot871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
-ddrot872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
-ddrot873 rotate sNaN13 1000 -> NaN13 Invalid_operation
-ddrot874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
-ddrot875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddrot876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
-ddrot877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
-ddrot878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
-ddrot879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
-ddrot880 rotate Inf sNaN23 -> NaN23 Invalid_operation
-ddrot881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddrot882 rotate -NaN26 NaN28 -> -NaN26
-ddrot883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddrot884 rotate 1000 -NaN30 -> -NaN30
-ddrot885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- ddRotate.decTest -- rotate a decDouble coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddrot001 rotate 0 0 -> 0
+ddrot002 rotate 0 2 -> 0
+ddrot003 rotate 1 2 -> 100
+ddrot004 rotate 1 15 -> 1000000000000000
+ddrot005 rotate 1 16 -> 1
+ddrot006 rotate 1 -1 -> 1000000000000000
+ddrot007 rotate 0 -2 -> 0
+ddrot008 rotate 1234567890123456 -1 -> 6123456789012345
+ddrot009 rotate 1234567890123456 -15 -> 2345678901234561
+ddrot010 rotate 1234567890123456 -16 -> 1234567890123456
+ddrot011 rotate 9934567890123456 -15 -> 9345678901234569
+ddrot012 rotate 9934567890123456 -16 -> 9934567890123456
+
+-- rhs must be an integer
+ddrot015 rotate 1 1.5 -> NaN Invalid_operation
+ddrot016 rotate 1 1.0 -> NaN Invalid_operation
+ddrot017 rotate 1 0.1 -> NaN Invalid_operation
+ddrot018 rotate 1 0.0 -> NaN Invalid_operation
+ddrot019 rotate 1 1E+1 -> NaN Invalid_operation
+ddrot020 rotate 1 1E+99 -> NaN Invalid_operation
+ddrot021 rotate 1 Inf -> NaN Invalid_operation
+ddrot022 rotate 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+ddrot025 rotate 1 -1000 -> NaN Invalid_operation
+ddrot026 rotate 1 -17 -> NaN Invalid_operation
+ddrot027 rotate 1 17 -> NaN Invalid_operation
+ddrot028 rotate 1 1000 -> NaN Invalid_operation
+
+-- full pattern
+ddrot030 rotate 1234567890123456 -16 -> 1234567890123456
+ddrot031 rotate 1234567890123456 -15 -> 2345678901234561
+ddrot032 rotate 1234567890123456 -14 -> 3456789012345612
+ddrot033 rotate 1234567890123456 -13 -> 4567890123456123
+ddrot034 rotate 1234567890123456 -12 -> 5678901234561234
+ddrot035 rotate 1234567890123456 -11 -> 6789012345612345
+ddrot036 rotate 1234567890123456 -10 -> 7890123456123456
+ddrot037 rotate 1234567890123456 -9 -> 8901234561234567
+ddrot038 rotate 1234567890123456 -8 -> 9012345612345678
+ddrot039 rotate 1234567890123456 -7 -> 123456123456789
+ddrot040 rotate 1234567890123456 -6 -> 1234561234567890
+ddrot041 rotate 1234567890123456 -5 -> 2345612345678901
+ddrot042 rotate 1234567890123456 -4 -> 3456123456789012
+ddrot043 rotate 1234567890123456 -3 -> 4561234567890123
+ddrot044 rotate 1234567890123456 -2 -> 5612345678901234
+ddrot045 rotate 1234567890123456 -1 -> 6123456789012345
+ddrot046 rotate 1234567890123456 -0 -> 1234567890123456
+
+ddrot047 rotate 1234567890123456 +0 -> 1234567890123456
+ddrot048 rotate 1234567890123456 +1 -> 2345678901234561
+ddrot049 rotate 1234567890123456 +2 -> 3456789012345612
+ddrot050 rotate 1234567890123456 +3 -> 4567890123456123
+ddrot051 rotate 1234567890123456 +4 -> 5678901234561234
+ddrot052 rotate 1234567890123456 +5 -> 6789012345612345
+ddrot053 rotate 1234567890123456 +6 -> 7890123456123456
+ddrot054 rotate 1234567890123456 +7 -> 8901234561234567
+ddrot055 rotate 1234567890123456 +8 -> 9012345612345678
+ddrot056 rotate 1234567890123456 +9 -> 123456123456789
+ddrot057 rotate 1234567890123456 +10 -> 1234561234567890
+ddrot058 rotate 1234567890123456 +11 -> 2345612345678901
+ddrot059 rotate 1234567890123456 +12 -> 3456123456789012
+ddrot060 rotate 1234567890123456 +13 -> 4561234567890123
+ddrot061 rotate 1234567890123456 +14 -> 5612345678901234
+ddrot062 rotate 1234567890123456 +15 -> 6123456789012345
+ddrot063 rotate 1234567890123456 +16 -> 1234567890123456
+
+-- zeros
+ddrot070 rotate 0E-10 +9 -> 0E-10
+ddrot071 rotate 0E-10 -9 -> 0E-10
+ddrot072 rotate 0.000 +9 -> 0.000
+ddrot073 rotate 0.000 -9 -> 0.000
+ddrot074 rotate 0E+10 +9 -> 0E+10
+ddrot075 rotate 0E+10 -9 -> 0E+10
+ddrot076 rotate -0E-10 +9 -> -0E-10
+ddrot077 rotate -0E-10 -9 -> -0E-10
+ddrot078 rotate -0.000 +9 -> -0.000
+ddrot079 rotate -0.000 -9 -> -0.000
+ddrot080 rotate -0E+10 +9 -> -0E+10
+ddrot081 rotate -0E+10 -9 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+ddrot141 rotate 9.999999999999999E+384 -1 -> 9.999999999999999E+384
+ddrot142 rotate 9.999999999999999E+384 -15 -> 9.999999999999999E+384
+ddrot143 rotate 9.999999999999999E+384 1 -> 9.999999999999999E+384
+ddrot144 rotate 9.999999999999999E+384 15 -> 9.999999999999999E+384
+ddrot145 rotate 1E-383 -1 -> 1.000000000000000E-368
+ddrot146 rotate 1E-383 -15 -> 1.0E-382
+ddrot147 rotate 1E-383 1 -> 1.0E-382
+ddrot148 rotate 1E-383 15 -> 1.000000000000000E-368
+ddrot151 rotate 1.000000000000000E-383 -1 -> 1.00000000000000E-384
+ddrot152 rotate 1.000000000000000E-383 -15 -> 1E-398
+ddrot153 rotate 1.000000000000000E-383 1 -> 1E-398
+ddrot154 rotate 1.000000000000000E-383 15 -> 1.00000000000000E-384
+ddrot155 rotate 9.000000000000000E-383 -1 -> 9.00000000000000E-384
+ddrot156 rotate 9.000000000000000E-383 -15 -> 9E-398
+ddrot157 rotate 9.000000000000000E-383 1 -> 9E-398
+ddrot158 rotate 9.000000000000000E-383 15 -> 9.00000000000000E-384
+ddrot160 rotate 1E-398 -1 -> 1.000000000000000E-383
+ddrot161 rotate 1E-398 -15 -> 1.0E-397
+ddrot162 rotate 1E-398 1 -> 1.0E-397
+ddrot163 rotate 1E-398 15 -> 1.000000000000000E-383
+-- negatives
+ddrot171 rotate -9.999999999999999E+384 -1 -> -9.999999999999999E+384
+ddrot172 rotate -9.999999999999999E+384 -15 -> -9.999999999999999E+384
+ddrot173 rotate -9.999999999999999E+384 1 -> -9.999999999999999E+384
+ddrot174 rotate -9.999999999999999E+384 15 -> -9.999999999999999E+384
+ddrot175 rotate -1E-383 -1 -> -1.000000000000000E-368
+ddrot176 rotate -1E-383 -15 -> -1.0E-382
+ddrot177 rotate -1E-383 1 -> -1.0E-382
+ddrot178 rotate -1E-383 15 -> -1.000000000000000E-368
+ddrot181 rotate -1.000000000000000E-383 -1 -> -1.00000000000000E-384
+ddrot182 rotate -1.000000000000000E-383 -15 -> -1E-398
+ddrot183 rotate -1.000000000000000E-383 1 -> -1E-398
+ddrot184 rotate -1.000000000000000E-383 15 -> -1.00000000000000E-384
+ddrot185 rotate -9.000000000000000E-383 -1 -> -9.00000000000000E-384
+ddrot186 rotate -9.000000000000000E-383 -15 -> -9E-398
+ddrot187 rotate -9.000000000000000E-383 1 -> -9E-398
+ddrot188 rotate -9.000000000000000E-383 15 -> -9.00000000000000E-384
+ddrot190 rotate -1E-398 -1 -> -1.000000000000000E-383
+ddrot191 rotate -1E-398 -15 -> -1.0E-397
+ddrot192 rotate -1E-398 1 -> -1.0E-397
+ddrot193 rotate -1E-398 15 -> -1.000000000000000E-383
+
+-- more negatives (of sanities)
+ddrot201 rotate -0 0 -> -0
+ddrot202 rotate -0 2 -> -0
+ddrot203 rotate -1 2 -> -100
+ddrot204 rotate -1 15 -> -1000000000000000
+ddrot205 rotate -1 16 -> -1
+ddrot206 rotate -1 -1 -> -1000000000000000
+ddrot207 rotate -0 -2 -> -0
+ddrot208 rotate -1234567890123456 -1 -> -6123456789012345
+ddrot209 rotate -1234567890123456 -15 -> -2345678901234561
+ddrot210 rotate -1234567890123456 -16 -> -1234567890123456
+ddrot211 rotate -9934567890123456 -15 -> -9345678901234569
+ddrot212 rotate -9934567890123456 -16 -> -9934567890123456
+
+
+-- Specials; NaNs are handled as usual
+ddrot781 rotate -Inf -8 -> -Infinity
+ddrot782 rotate -Inf -1 -> -Infinity
+ddrot783 rotate -Inf -0 -> -Infinity
+ddrot784 rotate -Inf 0 -> -Infinity
+ddrot785 rotate -Inf 1 -> -Infinity
+ddrot786 rotate -Inf 8 -> -Infinity
+ddrot787 rotate -1000 -Inf -> NaN Invalid_operation
+ddrot788 rotate -Inf -Inf -> NaN Invalid_operation
+ddrot789 rotate -1 -Inf -> NaN Invalid_operation
+ddrot790 rotate -0 -Inf -> NaN Invalid_operation
+ddrot791 rotate 0 -Inf -> NaN Invalid_operation
+ddrot792 rotate 1 -Inf -> NaN Invalid_operation
+ddrot793 rotate 1000 -Inf -> NaN Invalid_operation
+ddrot794 rotate Inf -Inf -> NaN Invalid_operation
+
+ddrot800 rotate Inf -Inf -> NaN Invalid_operation
+ddrot801 rotate Inf -8 -> Infinity
+ddrot802 rotate Inf -1 -> Infinity
+ddrot803 rotate Inf -0 -> Infinity
+ddrot804 rotate Inf 0 -> Infinity
+ddrot805 rotate Inf 1 -> Infinity
+ddrot806 rotate Inf 8 -> Infinity
+ddrot807 rotate Inf Inf -> NaN Invalid_operation
+ddrot808 rotate -1000 Inf -> NaN Invalid_operation
+ddrot809 rotate -Inf Inf -> NaN Invalid_operation
+ddrot810 rotate -1 Inf -> NaN Invalid_operation
+ddrot811 rotate -0 Inf -> NaN Invalid_operation
+ddrot812 rotate 0 Inf -> NaN Invalid_operation
+ddrot813 rotate 1 Inf -> NaN Invalid_operation
+ddrot814 rotate 1000 Inf -> NaN Invalid_operation
+ddrot815 rotate Inf Inf -> NaN Invalid_operation
+
+ddrot821 rotate NaN -Inf -> NaN
+ddrot822 rotate NaN -1000 -> NaN
+ddrot823 rotate NaN -1 -> NaN
+ddrot824 rotate NaN -0 -> NaN
+ddrot825 rotate NaN 0 -> NaN
+ddrot826 rotate NaN 1 -> NaN
+ddrot827 rotate NaN 1000 -> NaN
+ddrot828 rotate NaN Inf -> NaN
+ddrot829 rotate NaN NaN -> NaN
+ddrot830 rotate -Inf NaN -> NaN
+ddrot831 rotate -1000 NaN -> NaN
+ddrot832 rotate -1 NaN -> NaN
+ddrot833 rotate -0 NaN -> NaN
+ddrot834 rotate 0 NaN -> NaN
+ddrot835 rotate 1 NaN -> NaN
+ddrot836 rotate 1000 NaN -> NaN
+ddrot837 rotate Inf NaN -> NaN
+
+ddrot841 rotate sNaN -Inf -> NaN Invalid_operation
+ddrot842 rotate sNaN -1000 -> NaN Invalid_operation
+ddrot843 rotate sNaN -1 -> NaN Invalid_operation
+ddrot844 rotate sNaN -0 -> NaN Invalid_operation
+ddrot845 rotate sNaN 0 -> NaN Invalid_operation
+ddrot846 rotate sNaN 1 -> NaN Invalid_operation
+ddrot847 rotate sNaN 1000 -> NaN Invalid_operation
+ddrot848 rotate sNaN NaN -> NaN Invalid_operation
+ddrot849 rotate sNaN sNaN -> NaN Invalid_operation
+ddrot850 rotate NaN sNaN -> NaN Invalid_operation
+ddrot851 rotate -Inf sNaN -> NaN Invalid_operation
+ddrot852 rotate -1000 sNaN -> NaN Invalid_operation
+ddrot853 rotate -1 sNaN -> NaN Invalid_operation
+ddrot854 rotate -0 sNaN -> NaN Invalid_operation
+ddrot855 rotate 0 sNaN -> NaN Invalid_operation
+ddrot856 rotate 1 sNaN -> NaN Invalid_operation
+ddrot857 rotate 1000 sNaN -> NaN Invalid_operation
+ddrot858 rotate Inf sNaN -> NaN Invalid_operation
+ddrot859 rotate NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddrot861 rotate NaN1 -Inf -> NaN1
+ddrot862 rotate +NaN2 -1000 -> NaN2
+ddrot863 rotate NaN3 1000 -> NaN3
+ddrot864 rotate NaN4 Inf -> NaN4
+ddrot865 rotate NaN5 +NaN6 -> NaN5
+ddrot866 rotate -Inf NaN7 -> NaN7
+ddrot867 rotate -1000 NaN8 -> NaN8
+ddrot868 rotate 1000 NaN9 -> NaN9
+ddrot869 rotate Inf +NaN10 -> NaN10
+ddrot871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
+ddrot872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
+ddrot873 rotate sNaN13 1000 -> NaN13 Invalid_operation
+ddrot874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
+ddrot875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddrot876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
+ddrot877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
+ddrot878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
+ddrot879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
+ddrot880 rotate Inf sNaN23 -> NaN23 Invalid_operation
+ddrot881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddrot882 rotate -NaN26 NaN28 -> -NaN26
+ddrot883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddrot884 rotate 1000 -NaN30 -> -NaN30
+ddrot885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddSameQuantum.decTest b/Lib/test/decimaltestdata/ddSameQuantum.decTest
index 465b36a858..54a763cccf 100644
--- a/Lib/test/decimaltestdata/ddSameQuantum.decTest
+++ b/Lib/test/decimaltestdata/ddSameQuantum.decTest
@@ -1,389 +1,389 @@
-------------------------------------------------------------------------
--- ddSameQuantum.decTest -- check decDouble quantums match --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddsamq001 samequantum 0 0 -> 1
-ddsamq002 samequantum 0 1 -> 1
-ddsamq003 samequantum 1 0 -> 1
-ddsamq004 samequantum 1 1 -> 1
-
-ddsamq011 samequantum 10 1E+1 -> 0
-ddsamq012 samequantum 10E+1 10E+1 -> 1
-ddsamq013 samequantum 100 10E+1 -> 0
-ddsamq014 samequantum 100 1E+2 -> 0
-ddsamq015 samequantum 0.1 1E-2 -> 0
-ddsamq016 samequantum 0.1 1E-1 -> 1
-ddsamq017 samequantum 0.1 1E-0 -> 0
-ddsamq018 samequantum 999 999 -> 1
-ddsamq019 samequantum 999E-1 99.9 -> 1
-ddsamq020 samequantum 111E-1 22.2 -> 1
-ddsamq021 samequantum 111E-1 1234.2 -> 1
-
--- zeros
-ddsamq030 samequantum 0.0 1.1 -> 1
-ddsamq031 samequantum 0.0 1.11 -> 0
-ddsamq032 samequantum 0.0 0 -> 0
-ddsamq033 samequantum 0.0 0.0 -> 1
-ddsamq034 samequantum 0.0 0.00 -> 0
-ddsamq035 samequantum 0E+1 0E+0 -> 0
-ddsamq036 samequantum 0E+1 0E+1 -> 1
-ddsamq037 samequantum 0E+1 0E+2 -> 0
-ddsamq038 samequantum 0E-17 0E-16 -> 0
-ddsamq039 samequantum 0E-17 0E-17 -> 1
-ddsamq040 samequantum 0E-17 0E-18 -> 0
-ddsamq041 samequantum 0E-17 0.0E-15 -> 0
-ddsamq042 samequantum 0E-17 0.0E-16 -> 1
-ddsamq043 samequantum 0E-17 0.0E-17 -> 0
-ddsamq044 samequantum -0E-17 0.0E-16 -> 1
-ddsamq045 samequantum 0E-17 -0.0E-17 -> 0
-ddsamq046 samequantum 0E-17 -0.0E-16 -> 1
-ddsamq047 samequantum -0E-17 0.0E-17 -> 0
-ddsamq048 samequantum -0E-17 -0.0E-16 -> 1
-ddsamq049 samequantum -0E-17 -0.0E-17 -> 0
-
--- Nmax, Nmin, Ntiny
-ddsamq051 samequantum 9.999999999999999E+384 9.999999999999999E+384 -> 1
-ddsamq052 samequantum 1E-383 1E-383 -> 1
-ddsamq053 samequantum 1.000000000000000E-383 1.000000000000000E-383 -> 1
-ddsamq054 samequantum 1E-398 1E-398 -> 1
-ddsamq055 samequantum 9.999999999999999E+384 9.999999999999999E+384 -> 1
-ddsamq056 samequantum 1E-383 1E-383 -> 1
-ddsamq057 samequantum 1.000000000000000E-383 1.000000000000000E-383 -> 1
-ddsamq058 samequantum 1E-398 1E-398 -> 1
-
-ddsamq061 samequantum -1E-398 -1E-398 -> 1
-ddsamq062 samequantum -1.000000000000000E-383 -1.000000000000000E-383 -> 1
-ddsamq063 samequantum -1E-383 -1E-383 -> 1
-ddsamq064 samequantum -9.999999999999999E+384 -9.999999999999999E+384 -> 1
-ddsamq065 samequantum -1E-398 -1E-398 -> 1
-ddsamq066 samequantum -1.000000000000000E-383 -1.000000000000000E-383 -> 1
-ddsamq067 samequantum -1E-383 -1E-383 -> 1
-ddsamq068 samequantum -9.999999999999999E+384 -9.999999999999999E+384 -> 1
-
-ddsamq071 samequantum -4E-398 -1E-398 -> 1
-ddsamq072 samequantum -4.000000000000000E-383 -1.000040000000000E-383 -> 1
-ddsamq073 samequantum -4E-383 -1E-383 -> 1
-ddsamq074 samequantum -4.999999999999999E+384 -9.999999999949999E+384 -> 1
-ddsamq075 samequantum -4E-398 -1E-398 -> 1
-ddsamq076 samequantum -4.000000000000000E-383 -1.004000000000000E-383 -> 1
-ddsamq077 samequantum -4E-383 -1E-383 -> 1
-ddsamq078 samequantum -4.999999999999999E+384 -9.949999999999999E+384 -> 1
-
-ddsamq081 samequantum -4E-397 -1E-398 -> 0
-ddsamq082 samequantum -4.000000000000000E-383 -1.000040000000000E-336 -> 0
-ddsamq083 samequantum -4E-346 -1E-383 -> 0
-ddsamq084 samequantum -4.999999999999999E+384 -9.999499999999999E+336 -> 0
-ddsamq085 samequantum -4E-397 -1E-398 -> 0
-ddsamq086 samequantum -4.000000000000000E-383 -1.004000000000000E-336 -> 0
-ddsamq087 samequantum -4E-346 -1E-383 -> 0
-ddsamq088 samequantum -4.999999999999999E+384 -9.949999999999999E+336 -> 0
-
--- specials & combinations
-ddsamq0110 samequantum -Inf -Inf -> 1
-ddsamq0111 samequantum -Inf Inf -> 1
-ddsamq0112 samequantum -Inf NaN -> 0
-ddsamq0113 samequantum -Inf -7E+3 -> 0
-ddsamq0114 samequantum -Inf -7 -> 0
-ddsamq0115 samequantum -Inf -7E-3 -> 0
-ddsamq0116 samequantum -Inf -0E-3 -> 0
-ddsamq0117 samequantum -Inf -0 -> 0
-ddsamq0118 samequantum -Inf -0E+3 -> 0
-ddsamq0119 samequantum -Inf 0E-3 -> 0
-ddsamq0120 samequantum -Inf 0 -> 0
-ddsamq0121 samequantum -Inf 0E+3 -> 0
-ddsamq0122 samequantum -Inf 7E-3 -> 0
-ddsamq0123 samequantum -Inf 7 -> 0
-ddsamq0124 samequantum -Inf 7E+3 -> 0
-ddsamq0125 samequantum -Inf sNaN -> 0
-
-ddsamq0210 samequantum Inf -Inf -> 1
-ddsamq0211 samequantum Inf Inf -> 1
-ddsamq0212 samequantum Inf NaN -> 0
-ddsamq0213 samequantum Inf -7E+3 -> 0
-ddsamq0214 samequantum Inf -7 -> 0
-ddsamq0215 samequantum Inf -7E-3 -> 0
-ddsamq0216 samequantum Inf -0E-3 -> 0
-ddsamq0217 samequantum Inf -0 -> 0
-ddsamq0218 samequantum Inf -0E+3 -> 0
-ddsamq0219 samequantum Inf 0E-3 -> 0
-ddsamq0220 samequantum Inf 0 -> 0
-ddsamq0221 samequantum Inf 0E+3 -> 0
-ddsamq0222 samequantum Inf 7E-3 -> 0
-ddsamq0223 samequantum Inf 7 -> 0
-ddsamq0224 samequantum Inf 7E+3 -> 0
-ddsamq0225 samequantum Inf sNaN -> 0
-
-ddsamq0310 samequantum NaN -Inf -> 0
-ddsamq0311 samequantum NaN Inf -> 0
-ddsamq0312 samequantum NaN NaN -> 1
-ddsamq0313 samequantum NaN -7E+3 -> 0
-ddsamq0314 samequantum NaN -7 -> 0
-ddsamq0315 samequantum NaN -7E-3 -> 0
-ddsamq0316 samequantum NaN -0E-3 -> 0
-ddsamq0317 samequantum NaN -0 -> 0
-ddsamq0318 samequantum NaN -0E+3 -> 0
-ddsamq0319 samequantum NaN 0E-3 -> 0
-ddsamq0320 samequantum NaN 0 -> 0
-ddsamq0321 samequantum NaN 0E+3 -> 0
-ddsamq0322 samequantum NaN 7E-3 -> 0
-ddsamq0323 samequantum NaN 7 -> 0
-ddsamq0324 samequantum NaN 7E+3 -> 0
-ddsamq0325 samequantum NaN sNaN -> 1
-
-ddsamq0410 samequantum -7E+3 -Inf -> 0
-ddsamq0411 samequantum -7E+3 Inf -> 0
-ddsamq0412 samequantum -7E+3 NaN -> 0
-ddsamq0413 samequantum -7E+3 -7E+3 -> 1
-ddsamq0414 samequantum -7E+3 -7 -> 0
-ddsamq0415 samequantum -7E+3 -7E-3 -> 0
-ddsamq0416 samequantum -7E+3 -0E-3 -> 0
-ddsamq0417 samequantum -7E+3 -0 -> 0
-ddsamq0418 samequantum -7E+3 -0E+3 -> 1
-ddsamq0419 samequantum -7E+3 0E-3 -> 0
-ddsamq0420 samequantum -7E+3 0 -> 0
-ddsamq0421 samequantum -7E+3 0E+3 -> 1
-ddsamq0422 samequantum -7E+3 7E-3 -> 0
-ddsamq0423 samequantum -7E+3 7 -> 0
-ddsamq0424 samequantum -7E+3 7E+3 -> 1
-ddsamq0425 samequantum -7E+3 sNaN -> 0
-
-ddsamq0510 samequantum -7 -Inf -> 0
-ddsamq0511 samequantum -7 Inf -> 0
-ddsamq0512 samequantum -7 NaN -> 0
-ddsamq0513 samequantum -7 -7E+3 -> 0
-ddsamq0514 samequantum -7 -7 -> 1
-ddsamq0515 samequantum -7 -7E-3 -> 0
-ddsamq0516 samequantum -7 -0E-3 -> 0
-ddsamq0517 samequantum -7 -0 -> 1
-ddsamq0518 samequantum -7 -0E+3 -> 0
-ddsamq0519 samequantum -7 0E-3 -> 0
-ddsamq0520 samequantum -7 0 -> 1
-ddsamq0521 samequantum -7 0E+3 -> 0
-ddsamq0522 samequantum -7 7E-3 -> 0
-ddsamq0523 samequantum -7 7 -> 1
-ddsamq0524 samequantum -7 7E+3 -> 0
-ddsamq0525 samequantum -7 sNaN -> 0
-
-ddsamq0610 samequantum -7E-3 -Inf -> 0
-ddsamq0611 samequantum -7E-3 Inf -> 0
-ddsamq0612 samequantum -7E-3 NaN -> 0
-ddsamq0613 samequantum -7E-3 -7E+3 -> 0
-ddsamq0614 samequantum -7E-3 -7 -> 0
-ddsamq0615 samequantum -7E-3 -7E-3 -> 1
-ddsamq0616 samequantum -7E-3 -0E-3 -> 1
-ddsamq0617 samequantum -7E-3 -0 -> 0
-ddsamq0618 samequantum -7E-3 -0E+3 -> 0
-ddsamq0619 samequantum -7E-3 0E-3 -> 1
-ddsamq0620 samequantum -7E-3 0 -> 0
-ddsamq0621 samequantum -7E-3 0E+3 -> 0
-ddsamq0622 samequantum -7E-3 7E-3 -> 1
-ddsamq0623 samequantum -7E-3 7 -> 0
-ddsamq0624 samequantum -7E-3 7E+3 -> 0
-ddsamq0625 samequantum -7E-3 sNaN -> 0
-
-ddsamq0710 samequantum -0E-3 -Inf -> 0
-ddsamq0711 samequantum -0E-3 Inf -> 0
-ddsamq0712 samequantum -0E-3 NaN -> 0
-ddsamq0713 samequantum -0E-3 -7E+3 -> 0
-ddsamq0714 samequantum -0E-3 -7 -> 0
-ddsamq0715 samequantum -0E-3 -7E-3 -> 1
-ddsamq0716 samequantum -0E-3 -0E-3 -> 1
-ddsamq0717 samequantum -0E-3 -0 -> 0
-ddsamq0718 samequantum -0E-3 -0E+3 -> 0
-ddsamq0719 samequantum -0E-3 0E-3 -> 1
-ddsamq0720 samequantum -0E-3 0 -> 0
-ddsamq0721 samequantum -0E-3 0E+3 -> 0
-ddsamq0722 samequantum -0E-3 7E-3 -> 1
-ddsamq0723 samequantum -0E-3 7 -> 0
-ddsamq0724 samequantum -0E-3 7E+3 -> 0
-ddsamq0725 samequantum -0E-3 sNaN -> 0
-
-ddsamq0810 samequantum -0 -Inf -> 0
-ddsamq0811 samequantum -0 Inf -> 0
-ddsamq0812 samequantum -0 NaN -> 0
-ddsamq0813 samequantum -0 -7E+3 -> 0
-ddsamq0814 samequantum -0 -7 -> 1
-ddsamq0815 samequantum -0 -7E-3 -> 0
-ddsamq0816 samequantum -0 -0E-3 -> 0
-ddsamq0817 samequantum -0 -0 -> 1
-ddsamq0818 samequantum -0 -0E+3 -> 0
-ddsamq0819 samequantum -0 0E-3 -> 0
-ddsamq0820 samequantum -0 0 -> 1
-ddsamq0821 samequantum -0 0E+3 -> 0
-ddsamq0822 samequantum -0 7E-3 -> 0
-ddsamq0823 samequantum -0 7 -> 1
-ddsamq0824 samequantum -0 7E+3 -> 0
-ddsamq0825 samequantum -0 sNaN -> 0
-
-ddsamq0910 samequantum -0E+3 -Inf -> 0
-ddsamq0911 samequantum -0E+3 Inf -> 0
-ddsamq0912 samequantum -0E+3 NaN -> 0
-ddsamq0913 samequantum -0E+3 -7E+3 -> 1
-ddsamq0914 samequantum -0E+3 -7 -> 0
-ddsamq0915 samequantum -0E+3 -7E-3 -> 0
-ddsamq0916 samequantum -0E+3 -0E-3 -> 0
-ddsamq0917 samequantum -0E+3 -0 -> 0
-ddsamq0918 samequantum -0E+3 -0E+3 -> 1
-ddsamq0919 samequantum -0E+3 0E-3 -> 0
-ddsamq0920 samequantum -0E+3 0 -> 0
-ddsamq0921 samequantum -0E+3 0E+3 -> 1
-ddsamq0922 samequantum -0E+3 7E-3 -> 0
-ddsamq0923 samequantum -0E+3 7 -> 0
-ddsamq0924 samequantum -0E+3 7E+3 -> 1
-ddsamq0925 samequantum -0E+3 sNaN -> 0
-
-ddsamq1110 samequantum 0E-3 -Inf -> 0
-ddsamq1111 samequantum 0E-3 Inf -> 0
-ddsamq1112 samequantum 0E-3 NaN -> 0
-ddsamq1113 samequantum 0E-3 -7E+3 -> 0
-ddsamq1114 samequantum 0E-3 -7 -> 0
-ddsamq1115 samequantum 0E-3 -7E-3 -> 1
-ddsamq1116 samequantum 0E-3 -0E-3 -> 1
-ddsamq1117 samequantum 0E-3 -0 -> 0
-ddsamq1118 samequantum 0E-3 -0E+3 -> 0
-ddsamq1119 samequantum 0E-3 0E-3 -> 1
-ddsamq1120 samequantum 0E-3 0 -> 0
-ddsamq1121 samequantum 0E-3 0E+3 -> 0
-ddsamq1122 samequantum 0E-3 7E-3 -> 1
-ddsamq1123 samequantum 0E-3 7 -> 0
-ddsamq1124 samequantum 0E-3 7E+3 -> 0
-ddsamq1125 samequantum 0E-3 sNaN -> 0
-
-ddsamq1210 samequantum 0 -Inf -> 0
-ddsamq1211 samequantum 0 Inf -> 0
-ddsamq1212 samequantum 0 NaN -> 0
-ddsamq1213 samequantum 0 -7E+3 -> 0
-ddsamq1214 samequantum 0 -7 -> 1
-ddsamq1215 samequantum 0 -7E-3 -> 0
-ddsamq1216 samequantum 0 -0E-3 -> 0
-ddsamq1217 samequantum 0 -0 -> 1
-ddsamq1218 samequantum 0 -0E+3 -> 0
-ddsamq1219 samequantum 0 0E-3 -> 0
-ddsamq1220 samequantum 0 0 -> 1
-ddsamq1221 samequantum 0 0E+3 -> 0
-ddsamq1222 samequantum 0 7E-3 -> 0
-ddsamq1223 samequantum 0 7 -> 1
-ddsamq1224 samequantum 0 7E+3 -> 0
-ddsamq1225 samequantum 0 sNaN -> 0
-
-ddsamq1310 samequantum 0E+3 -Inf -> 0
-ddsamq1311 samequantum 0E+3 Inf -> 0
-ddsamq1312 samequantum 0E+3 NaN -> 0
-ddsamq1313 samequantum 0E+3 -7E+3 -> 1
-ddsamq1314 samequantum 0E+3 -7 -> 0
-ddsamq1315 samequantum 0E+3 -7E-3 -> 0
-ddsamq1316 samequantum 0E+3 -0E-3 -> 0
-ddsamq1317 samequantum 0E+3 -0 -> 0
-ddsamq1318 samequantum 0E+3 -0E+3 -> 1
-ddsamq1319 samequantum 0E+3 0E-3 -> 0
-ddsamq1320 samequantum 0E+3 0 -> 0
-ddsamq1321 samequantum 0E+3 0E+3 -> 1
-ddsamq1322 samequantum 0E+3 7E-3 -> 0
-ddsamq1323 samequantum 0E+3 7 -> 0
-ddsamq1324 samequantum 0E+3 7E+3 -> 1
-ddsamq1325 samequantum 0E+3 sNaN -> 0
-
-ddsamq1410 samequantum 7E-3 -Inf -> 0
-ddsamq1411 samequantum 7E-3 Inf -> 0
-ddsamq1412 samequantum 7E-3 NaN -> 0
-ddsamq1413 samequantum 7E-3 -7E+3 -> 0
-ddsamq1414 samequantum 7E-3 -7 -> 0
-ddsamq1415 samequantum 7E-3 -7E-3 -> 1
-ddsamq1416 samequantum 7E-3 -0E-3 -> 1
-ddsamq1417 samequantum 7E-3 -0 -> 0
-ddsamq1418 samequantum 7E-3 -0E+3 -> 0
-ddsamq1419 samequantum 7E-3 0E-3 -> 1
-ddsamq1420 samequantum 7E-3 0 -> 0
-ddsamq1421 samequantum 7E-3 0E+3 -> 0
-ddsamq1422 samequantum 7E-3 7E-3 -> 1
-ddsamq1423 samequantum 7E-3 7 -> 0
-ddsamq1424 samequantum 7E-3 7E+3 -> 0
-ddsamq1425 samequantum 7E-3 sNaN -> 0
-
-ddsamq1510 samequantum 7 -Inf -> 0
-ddsamq1511 samequantum 7 Inf -> 0
-ddsamq1512 samequantum 7 NaN -> 0
-ddsamq1513 samequantum 7 -7E+3 -> 0
-ddsamq1514 samequantum 7 -7 -> 1
-ddsamq1515 samequantum 7 -7E-3 -> 0
-ddsamq1516 samequantum 7 -0E-3 -> 0
-ddsamq1517 samequantum 7 -0 -> 1
-ddsamq1518 samequantum 7 -0E+3 -> 0
-ddsamq1519 samequantum 7 0E-3 -> 0
-ddsamq1520 samequantum 7 0 -> 1
-ddsamq1521 samequantum 7 0E+3 -> 0
-ddsamq1522 samequantum 7 7E-3 -> 0
-ddsamq1523 samequantum 7 7 -> 1
-ddsamq1524 samequantum 7 7E+3 -> 0
-ddsamq1525 samequantum 7 sNaN -> 0
-
-ddsamq1610 samequantum 7E+3 -Inf -> 0
-ddsamq1611 samequantum 7E+3 Inf -> 0
-ddsamq1612 samequantum 7E+3 NaN -> 0
-ddsamq1613 samequantum 7E+3 -7E+3 -> 1
-ddsamq1614 samequantum 7E+3 -7 -> 0
-ddsamq1615 samequantum 7E+3 -7E-3 -> 0
-ddsamq1616 samequantum 7E+3 -0E-3 -> 0
-ddsamq1617 samequantum 7E+3 -0 -> 0
-ddsamq1618 samequantum 7E+3 -0E+3 -> 1
-ddsamq1619 samequantum 7E+3 0E-3 -> 0
-ddsamq1620 samequantum 7E+3 0 -> 0
-ddsamq1621 samequantum 7E+3 0E+3 -> 1
-ddsamq1622 samequantum 7E+3 7E-3 -> 0
-ddsamq1623 samequantum 7E+3 7 -> 0
-ddsamq1624 samequantum 7E+3 7E+3 -> 1
-ddsamq1625 samequantum 7E+3 sNaN -> 0
-
-ddsamq1710 samequantum sNaN -Inf -> 0
-ddsamq1711 samequantum sNaN Inf -> 0
-ddsamq1712 samequantum sNaN NaN -> 1
-ddsamq1713 samequantum sNaN -7E+3 -> 0
-ddsamq1714 samequantum sNaN -7 -> 0
-ddsamq1715 samequantum sNaN -7E-3 -> 0
-ddsamq1716 samequantum sNaN -0E-3 -> 0
-ddsamq1717 samequantum sNaN -0 -> 0
-ddsamq1718 samequantum sNaN -0E+3 -> 0
-ddsamq1719 samequantum sNaN 0E-3 -> 0
-ddsamq1720 samequantum sNaN 0 -> 0
-ddsamq1721 samequantum sNaN 0E+3 -> 0
-ddsamq1722 samequantum sNaN 7E-3 -> 0
-ddsamq1723 samequantum sNaN 7 -> 0
-ddsamq1724 samequantum sNaN 7E+3 -> 0
-ddsamq1725 samequantum sNaN sNaN -> 1
--- noisy NaNs
-ddsamq1730 samequantum sNaN3 sNaN3 -> 1
-ddsamq1731 samequantum sNaN3 sNaN4 -> 1
-ddsamq1732 samequantum NaN3 NaN3 -> 1
-ddsamq1733 samequantum NaN3 NaN4 -> 1
-ddsamq1734 samequantum sNaN3 3 -> 0
-ddsamq1735 samequantum NaN3 3 -> 0
-ddsamq1736 samequantum 4 sNaN4 -> 0
-ddsamq1737 samequantum 3 NaN3 -> 0
-ddsamq1738 samequantum Inf sNaN4 -> 0
-ddsamq1739 samequantum -Inf NaN3 -> 0
-
+------------------------------------------------------------------------
+-- ddSameQuantum.decTest -- check decDouble quantums match --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddsamq001 samequantum 0 0 -> 1
+ddsamq002 samequantum 0 1 -> 1
+ddsamq003 samequantum 1 0 -> 1
+ddsamq004 samequantum 1 1 -> 1
+
+ddsamq011 samequantum 10 1E+1 -> 0
+ddsamq012 samequantum 10E+1 10E+1 -> 1
+ddsamq013 samequantum 100 10E+1 -> 0
+ddsamq014 samequantum 100 1E+2 -> 0
+ddsamq015 samequantum 0.1 1E-2 -> 0
+ddsamq016 samequantum 0.1 1E-1 -> 1
+ddsamq017 samequantum 0.1 1E-0 -> 0
+ddsamq018 samequantum 999 999 -> 1
+ddsamq019 samequantum 999E-1 99.9 -> 1
+ddsamq020 samequantum 111E-1 22.2 -> 1
+ddsamq021 samequantum 111E-1 1234.2 -> 1
+
+-- zeros
+ddsamq030 samequantum 0.0 1.1 -> 1
+ddsamq031 samequantum 0.0 1.11 -> 0
+ddsamq032 samequantum 0.0 0 -> 0
+ddsamq033 samequantum 0.0 0.0 -> 1
+ddsamq034 samequantum 0.0 0.00 -> 0
+ddsamq035 samequantum 0E+1 0E+0 -> 0
+ddsamq036 samequantum 0E+1 0E+1 -> 1
+ddsamq037 samequantum 0E+1 0E+2 -> 0
+ddsamq038 samequantum 0E-17 0E-16 -> 0
+ddsamq039 samequantum 0E-17 0E-17 -> 1
+ddsamq040 samequantum 0E-17 0E-18 -> 0
+ddsamq041 samequantum 0E-17 0.0E-15 -> 0
+ddsamq042 samequantum 0E-17 0.0E-16 -> 1
+ddsamq043 samequantum 0E-17 0.0E-17 -> 0
+ddsamq044 samequantum -0E-17 0.0E-16 -> 1
+ddsamq045 samequantum 0E-17 -0.0E-17 -> 0
+ddsamq046 samequantum 0E-17 -0.0E-16 -> 1
+ddsamq047 samequantum -0E-17 0.0E-17 -> 0
+ddsamq048 samequantum -0E-17 -0.0E-16 -> 1
+ddsamq049 samequantum -0E-17 -0.0E-17 -> 0
+
+-- Nmax, Nmin, Ntiny
+ddsamq051 samequantum 9.999999999999999E+384 9.999999999999999E+384 -> 1
+ddsamq052 samequantum 1E-383 1E-383 -> 1
+ddsamq053 samequantum 1.000000000000000E-383 1.000000000000000E-383 -> 1
+ddsamq054 samequantum 1E-398 1E-398 -> 1
+ddsamq055 samequantum 9.999999999999999E+384 9.999999999999999E+384 -> 1
+ddsamq056 samequantum 1E-383 1E-383 -> 1
+ddsamq057 samequantum 1.000000000000000E-383 1.000000000000000E-383 -> 1
+ddsamq058 samequantum 1E-398 1E-398 -> 1
+
+ddsamq061 samequantum -1E-398 -1E-398 -> 1
+ddsamq062 samequantum -1.000000000000000E-383 -1.000000000000000E-383 -> 1
+ddsamq063 samequantum -1E-383 -1E-383 -> 1
+ddsamq064 samequantum -9.999999999999999E+384 -9.999999999999999E+384 -> 1
+ddsamq065 samequantum -1E-398 -1E-398 -> 1
+ddsamq066 samequantum -1.000000000000000E-383 -1.000000000000000E-383 -> 1
+ddsamq067 samequantum -1E-383 -1E-383 -> 1
+ddsamq068 samequantum -9.999999999999999E+384 -9.999999999999999E+384 -> 1
+
+ddsamq071 samequantum -4E-398 -1E-398 -> 1
+ddsamq072 samequantum -4.000000000000000E-383 -1.000040000000000E-383 -> 1
+ddsamq073 samequantum -4E-383 -1E-383 -> 1
+ddsamq074 samequantum -4.999999999999999E+384 -9.999999999949999E+384 -> 1
+ddsamq075 samequantum -4E-398 -1E-398 -> 1
+ddsamq076 samequantum -4.000000000000000E-383 -1.004000000000000E-383 -> 1
+ddsamq077 samequantum -4E-383 -1E-383 -> 1
+ddsamq078 samequantum -4.999999999999999E+384 -9.949999999999999E+384 -> 1
+
+ddsamq081 samequantum -4E-397 -1E-398 -> 0
+ddsamq082 samequantum -4.000000000000000E-383 -1.000040000000000E-336 -> 0
+ddsamq083 samequantum -4E-346 -1E-383 -> 0
+ddsamq084 samequantum -4.999999999999999E+384 -9.999499999999999E+336 -> 0
+ddsamq085 samequantum -4E-397 -1E-398 -> 0
+ddsamq086 samequantum -4.000000000000000E-383 -1.004000000000000E-336 -> 0
+ddsamq087 samequantum -4E-346 -1E-383 -> 0
+ddsamq088 samequantum -4.999999999999999E+384 -9.949999999999999E+336 -> 0
+
+-- specials & combinations
+ddsamq0110 samequantum -Inf -Inf -> 1
+ddsamq0111 samequantum -Inf Inf -> 1
+ddsamq0112 samequantum -Inf NaN -> 0
+ddsamq0113 samequantum -Inf -7E+3 -> 0
+ddsamq0114 samequantum -Inf -7 -> 0
+ddsamq0115 samequantum -Inf -7E-3 -> 0
+ddsamq0116 samequantum -Inf -0E-3 -> 0
+ddsamq0117 samequantum -Inf -0 -> 0
+ddsamq0118 samequantum -Inf -0E+3 -> 0
+ddsamq0119 samequantum -Inf 0E-3 -> 0
+ddsamq0120 samequantum -Inf 0 -> 0
+ddsamq0121 samequantum -Inf 0E+3 -> 0
+ddsamq0122 samequantum -Inf 7E-3 -> 0
+ddsamq0123 samequantum -Inf 7 -> 0
+ddsamq0124 samequantum -Inf 7E+3 -> 0
+ddsamq0125 samequantum -Inf sNaN -> 0
+
+ddsamq0210 samequantum Inf -Inf -> 1
+ddsamq0211 samequantum Inf Inf -> 1
+ddsamq0212 samequantum Inf NaN -> 0
+ddsamq0213 samequantum Inf -7E+3 -> 0
+ddsamq0214 samequantum Inf -7 -> 0
+ddsamq0215 samequantum Inf -7E-3 -> 0
+ddsamq0216 samequantum Inf -0E-3 -> 0
+ddsamq0217 samequantum Inf -0 -> 0
+ddsamq0218 samequantum Inf -0E+3 -> 0
+ddsamq0219 samequantum Inf 0E-3 -> 0
+ddsamq0220 samequantum Inf 0 -> 0
+ddsamq0221 samequantum Inf 0E+3 -> 0
+ddsamq0222 samequantum Inf 7E-3 -> 0
+ddsamq0223 samequantum Inf 7 -> 0
+ddsamq0224 samequantum Inf 7E+3 -> 0
+ddsamq0225 samequantum Inf sNaN -> 0
+
+ddsamq0310 samequantum NaN -Inf -> 0
+ddsamq0311 samequantum NaN Inf -> 0
+ddsamq0312 samequantum NaN NaN -> 1
+ddsamq0313 samequantum NaN -7E+3 -> 0
+ddsamq0314 samequantum NaN -7 -> 0
+ddsamq0315 samequantum NaN -7E-3 -> 0
+ddsamq0316 samequantum NaN -0E-3 -> 0
+ddsamq0317 samequantum NaN -0 -> 0
+ddsamq0318 samequantum NaN -0E+3 -> 0
+ddsamq0319 samequantum NaN 0E-3 -> 0
+ddsamq0320 samequantum NaN 0 -> 0
+ddsamq0321 samequantum NaN 0E+3 -> 0
+ddsamq0322 samequantum NaN 7E-3 -> 0
+ddsamq0323 samequantum NaN 7 -> 0
+ddsamq0324 samequantum NaN 7E+3 -> 0
+ddsamq0325 samequantum NaN sNaN -> 1
+
+ddsamq0410 samequantum -7E+3 -Inf -> 0
+ddsamq0411 samequantum -7E+3 Inf -> 0
+ddsamq0412 samequantum -7E+3 NaN -> 0
+ddsamq0413 samequantum -7E+3 -7E+3 -> 1
+ddsamq0414 samequantum -7E+3 -7 -> 0
+ddsamq0415 samequantum -7E+3 -7E-3 -> 0
+ddsamq0416 samequantum -7E+3 -0E-3 -> 0
+ddsamq0417 samequantum -7E+3 -0 -> 0
+ddsamq0418 samequantum -7E+3 -0E+3 -> 1
+ddsamq0419 samequantum -7E+3 0E-3 -> 0
+ddsamq0420 samequantum -7E+3 0 -> 0
+ddsamq0421 samequantum -7E+3 0E+3 -> 1
+ddsamq0422 samequantum -7E+3 7E-3 -> 0
+ddsamq0423 samequantum -7E+3 7 -> 0
+ddsamq0424 samequantum -7E+3 7E+3 -> 1
+ddsamq0425 samequantum -7E+3 sNaN -> 0
+
+ddsamq0510 samequantum -7 -Inf -> 0
+ddsamq0511 samequantum -7 Inf -> 0
+ddsamq0512 samequantum -7 NaN -> 0
+ddsamq0513 samequantum -7 -7E+3 -> 0
+ddsamq0514 samequantum -7 -7 -> 1
+ddsamq0515 samequantum -7 -7E-3 -> 0
+ddsamq0516 samequantum -7 -0E-3 -> 0
+ddsamq0517 samequantum -7 -0 -> 1
+ddsamq0518 samequantum -7 -0E+3 -> 0
+ddsamq0519 samequantum -7 0E-3 -> 0
+ddsamq0520 samequantum -7 0 -> 1
+ddsamq0521 samequantum -7 0E+3 -> 0
+ddsamq0522 samequantum -7 7E-3 -> 0
+ddsamq0523 samequantum -7 7 -> 1
+ddsamq0524 samequantum -7 7E+3 -> 0
+ddsamq0525 samequantum -7 sNaN -> 0
+
+ddsamq0610 samequantum -7E-3 -Inf -> 0
+ddsamq0611 samequantum -7E-3 Inf -> 0
+ddsamq0612 samequantum -7E-3 NaN -> 0
+ddsamq0613 samequantum -7E-3 -7E+3 -> 0
+ddsamq0614 samequantum -7E-3 -7 -> 0
+ddsamq0615 samequantum -7E-3 -7E-3 -> 1
+ddsamq0616 samequantum -7E-3 -0E-3 -> 1
+ddsamq0617 samequantum -7E-3 -0 -> 0
+ddsamq0618 samequantum -7E-3 -0E+3 -> 0
+ddsamq0619 samequantum -7E-3 0E-3 -> 1
+ddsamq0620 samequantum -7E-3 0 -> 0
+ddsamq0621 samequantum -7E-3 0E+3 -> 0
+ddsamq0622 samequantum -7E-3 7E-3 -> 1
+ddsamq0623 samequantum -7E-3 7 -> 0
+ddsamq0624 samequantum -7E-3 7E+3 -> 0
+ddsamq0625 samequantum -7E-3 sNaN -> 0
+
+ddsamq0710 samequantum -0E-3 -Inf -> 0
+ddsamq0711 samequantum -0E-3 Inf -> 0
+ddsamq0712 samequantum -0E-3 NaN -> 0
+ddsamq0713 samequantum -0E-3 -7E+3 -> 0
+ddsamq0714 samequantum -0E-3 -7 -> 0
+ddsamq0715 samequantum -0E-3 -7E-3 -> 1
+ddsamq0716 samequantum -0E-3 -0E-3 -> 1
+ddsamq0717 samequantum -0E-3 -0 -> 0
+ddsamq0718 samequantum -0E-3 -0E+3 -> 0
+ddsamq0719 samequantum -0E-3 0E-3 -> 1
+ddsamq0720 samequantum -0E-3 0 -> 0
+ddsamq0721 samequantum -0E-3 0E+3 -> 0
+ddsamq0722 samequantum -0E-3 7E-3 -> 1
+ddsamq0723 samequantum -0E-3 7 -> 0
+ddsamq0724 samequantum -0E-3 7E+3 -> 0
+ddsamq0725 samequantum -0E-3 sNaN -> 0
+
+ddsamq0810 samequantum -0 -Inf -> 0
+ddsamq0811 samequantum -0 Inf -> 0
+ddsamq0812 samequantum -0 NaN -> 0
+ddsamq0813 samequantum -0 -7E+3 -> 0
+ddsamq0814 samequantum -0 -7 -> 1
+ddsamq0815 samequantum -0 -7E-3 -> 0
+ddsamq0816 samequantum -0 -0E-3 -> 0
+ddsamq0817 samequantum -0 -0 -> 1
+ddsamq0818 samequantum -0 -0E+3 -> 0
+ddsamq0819 samequantum -0 0E-3 -> 0
+ddsamq0820 samequantum -0 0 -> 1
+ddsamq0821 samequantum -0 0E+3 -> 0
+ddsamq0822 samequantum -0 7E-3 -> 0
+ddsamq0823 samequantum -0 7 -> 1
+ddsamq0824 samequantum -0 7E+3 -> 0
+ddsamq0825 samequantum -0 sNaN -> 0
+
+ddsamq0910 samequantum -0E+3 -Inf -> 0
+ddsamq0911 samequantum -0E+3 Inf -> 0
+ddsamq0912 samequantum -0E+3 NaN -> 0
+ddsamq0913 samequantum -0E+3 -7E+3 -> 1
+ddsamq0914 samequantum -0E+3 -7 -> 0
+ddsamq0915 samequantum -0E+3 -7E-3 -> 0
+ddsamq0916 samequantum -0E+3 -0E-3 -> 0
+ddsamq0917 samequantum -0E+3 -0 -> 0
+ddsamq0918 samequantum -0E+3 -0E+3 -> 1
+ddsamq0919 samequantum -0E+3 0E-3 -> 0
+ddsamq0920 samequantum -0E+3 0 -> 0
+ddsamq0921 samequantum -0E+3 0E+3 -> 1
+ddsamq0922 samequantum -0E+3 7E-3 -> 0
+ddsamq0923 samequantum -0E+3 7 -> 0
+ddsamq0924 samequantum -0E+3 7E+3 -> 1
+ddsamq0925 samequantum -0E+3 sNaN -> 0
+
+ddsamq1110 samequantum 0E-3 -Inf -> 0
+ddsamq1111 samequantum 0E-3 Inf -> 0
+ddsamq1112 samequantum 0E-3 NaN -> 0
+ddsamq1113 samequantum 0E-3 -7E+3 -> 0
+ddsamq1114 samequantum 0E-3 -7 -> 0
+ddsamq1115 samequantum 0E-3 -7E-3 -> 1
+ddsamq1116 samequantum 0E-3 -0E-3 -> 1
+ddsamq1117 samequantum 0E-3 -0 -> 0
+ddsamq1118 samequantum 0E-3 -0E+3 -> 0
+ddsamq1119 samequantum 0E-3 0E-3 -> 1
+ddsamq1120 samequantum 0E-3 0 -> 0
+ddsamq1121 samequantum 0E-3 0E+3 -> 0
+ddsamq1122 samequantum 0E-3 7E-3 -> 1
+ddsamq1123 samequantum 0E-3 7 -> 0
+ddsamq1124 samequantum 0E-3 7E+3 -> 0
+ddsamq1125 samequantum 0E-3 sNaN -> 0
+
+ddsamq1210 samequantum 0 -Inf -> 0
+ddsamq1211 samequantum 0 Inf -> 0
+ddsamq1212 samequantum 0 NaN -> 0
+ddsamq1213 samequantum 0 -7E+3 -> 0
+ddsamq1214 samequantum 0 -7 -> 1
+ddsamq1215 samequantum 0 -7E-3 -> 0
+ddsamq1216 samequantum 0 -0E-3 -> 0
+ddsamq1217 samequantum 0 -0 -> 1
+ddsamq1218 samequantum 0 -0E+3 -> 0
+ddsamq1219 samequantum 0 0E-3 -> 0
+ddsamq1220 samequantum 0 0 -> 1
+ddsamq1221 samequantum 0 0E+3 -> 0
+ddsamq1222 samequantum 0 7E-3 -> 0
+ddsamq1223 samequantum 0 7 -> 1
+ddsamq1224 samequantum 0 7E+3 -> 0
+ddsamq1225 samequantum 0 sNaN -> 0
+
+ddsamq1310 samequantum 0E+3 -Inf -> 0
+ddsamq1311 samequantum 0E+3 Inf -> 0
+ddsamq1312 samequantum 0E+3 NaN -> 0
+ddsamq1313 samequantum 0E+3 -7E+3 -> 1
+ddsamq1314 samequantum 0E+3 -7 -> 0
+ddsamq1315 samequantum 0E+3 -7E-3 -> 0
+ddsamq1316 samequantum 0E+3 -0E-3 -> 0
+ddsamq1317 samequantum 0E+3 -0 -> 0
+ddsamq1318 samequantum 0E+3 -0E+3 -> 1
+ddsamq1319 samequantum 0E+3 0E-3 -> 0
+ddsamq1320 samequantum 0E+3 0 -> 0
+ddsamq1321 samequantum 0E+3 0E+3 -> 1
+ddsamq1322 samequantum 0E+3 7E-3 -> 0
+ddsamq1323 samequantum 0E+3 7 -> 0
+ddsamq1324 samequantum 0E+3 7E+3 -> 1
+ddsamq1325 samequantum 0E+3 sNaN -> 0
+
+ddsamq1410 samequantum 7E-3 -Inf -> 0
+ddsamq1411 samequantum 7E-3 Inf -> 0
+ddsamq1412 samequantum 7E-3 NaN -> 0
+ddsamq1413 samequantum 7E-3 -7E+3 -> 0
+ddsamq1414 samequantum 7E-3 -7 -> 0
+ddsamq1415 samequantum 7E-3 -7E-3 -> 1
+ddsamq1416 samequantum 7E-3 -0E-3 -> 1
+ddsamq1417 samequantum 7E-3 -0 -> 0
+ddsamq1418 samequantum 7E-3 -0E+3 -> 0
+ddsamq1419 samequantum 7E-3 0E-3 -> 1
+ddsamq1420 samequantum 7E-3 0 -> 0
+ddsamq1421 samequantum 7E-3 0E+3 -> 0
+ddsamq1422 samequantum 7E-3 7E-3 -> 1
+ddsamq1423 samequantum 7E-3 7 -> 0
+ddsamq1424 samequantum 7E-3 7E+3 -> 0
+ddsamq1425 samequantum 7E-3 sNaN -> 0
+
+ddsamq1510 samequantum 7 -Inf -> 0
+ddsamq1511 samequantum 7 Inf -> 0
+ddsamq1512 samequantum 7 NaN -> 0
+ddsamq1513 samequantum 7 -7E+3 -> 0
+ddsamq1514 samequantum 7 -7 -> 1
+ddsamq1515 samequantum 7 -7E-3 -> 0
+ddsamq1516 samequantum 7 -0E-3 -> 0
+ddsamq1517 samequantum 7 -0 -> 1
+ddsamq1518 samequantum 7 -0E+3 -> 0
+ddsamq1519 samequantum 7 0E-3 -> 0
+ddsamq1520 samequantum 7 0 -> 1
+ddsamq1521 samequantum 7 0E+3 -> 0
+ddsamq1522 samequantum 7 7E-3 -> 0
+ddsamq1523 samequantum 7 7 -> 1
+ddsamq1524 samequantum 7 7E+3 -> 0
+ddsamq1525 samequantum 7 sNaN -> 0
+
+ddsamq1610 samequantum 7E+3 -Inf -> 0
+ddsamq1611 samequantum 7E+3 Inf -> 0
+ddsamq1612 samequantum 7E+3 NaN -> 0
+ddsamq1613 samequantum 7E+3 -7E+3 -> 1
+ddsamq1614 samequantum 7E+3 -7 -> 0
+ddsamq1615 samequantum 7E+3 -7E-3 -> 0
+ddsamq1616 samequantum 7E+3 -0E-3 -> 0
+ddsamq1617 samequantum 7E+3 -0 -> 0
+ddsamq1618 samequantum 7E+3 -0E+3 -> 1
+ddsamq1619 samequantum 7E+3 0E-3 -> 0
+ddsamq1620 samequantum 7E+3 0 -> 0
+ddsamq1621 samequantum 7E+3 0E+3 -> 1
+ddsamq1622 samequantum 7E+3 7E-3 -> 0
+ddsamq1623 samequantum 7E+3 7 -> 0
+ddsamq1624 samequantum 7E+3 7E+3 -> 1
+ddsamq1625 samequantum 7E+3 sNaN -> 0
+
+ddsamq1710 samequantum sNaN -Inf -> 0
+ddsamq1711 samequantum sNaN Inf -> 0
+ddsamq1712 samequantum sNaN NaN -> 1
+ddsamq1713 samequantum sNaN -7E+3 -> 0
+ddsamq1714 samequantum sNaN -7 -> 0
+ddsamq1715 samequantum sNaN -7E-3 -> 0
+ddsamq1716 samequantum sNaN -0E-3 -> 0
+ddsamq1717 samequantum sNaN -0 -> 0
+ddsamq1718 samequantum sNaN -0E+3 -> 0
+ddsamq1719 samequantum sNaN 0E-3 -> 0
+ddsamq1720 samequantum sNaN 0 -> 0
+ddsamq1721 samequantum sNaN 0E+3 -> 0
+ddsamq1722 samequantum sNaN 7E-3 -> 0
+ddsamq1723 samequantum sNaN 7 -> 0
+ddsamq1724 samequantum sNaN 7E+3 -> 0
+ddsamq1725 samequantum sNaN sNaN -> 1
+-- noisy NaNs
+ddsamq1730 samequantum sNaN3 sNaN3 -> 1
+ddsamq1731 samequantum sNaN3 sNaN4 -> 1
+ddsamq1732 samequantum NaN3 NaN3 -> 1
+ddsamq1733 samequantum NaN3 NaN4 -> 1
+ddsamq1734 samequantum sNaN3 3 -> 0
+ddsamq1735 samequantum NaN3 3 -> 0
+ddsamq1736 samequantum 4 sNaN4 -> 0
+ddsamq1737 samequantum 3 NaN3 -> 0
+ddsamq1738 samequantum Inf sNaN4 -> 0
+ddsamq1739 samequantum -Inf NaN3 -> 0
+
diff --git a/Lib/test/decimaltestdata/ddScaleB.decTest b/Lib/test/decimaltestdata/ddScaleB.decTest
index edee11bccc..6ba3e3976f 100644
--- a/Lib/test/decimaltestdata/ddScaleB.decTest
+++ b/Lib/test/decimaltestdata/ddScaleB.decTest
@@ -1,243 +1,243 @@
-------------------------------------------------------------------------
--- ddScalebB.decTest -- scale a decDouble by powers of 10 --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Max |rhs| is 2*(384+16) = 800
-
--- Sanity checks
-ddscb001 scaleb 7.50 10 -> 7.50E+10
-ddscb002 scaleb 7.50 3 -> 7.50E+3
-ddscb003 scaleb 7.50 2 -> 750
-ddscb004 scaleb 7.50 1 -> 75.0
-ddscb005 scaleb 7.50 0 -> 7.50
-ddscb006 scaleb 7.50 -1 -> 0.750
-ddscb007 scaleb 7.50 -2 -> 0.0750
-ddscb008 scaleb 7.50 -10 -> 7.50E-10
-ddscb009 scaleb -7.50 3 -> -7.50E+3
-ddscb010 scaleb -7.50 2 -> -750
-ddscb011 scaleb -7.50 1 -> -75.0
-ddscb012 scaleb -7.50 0 -> -7.50
-ddscb013 scaleb -7.50 -1 -> -0.750
-
--- Infinities
-ddscb014 scaleb Infinity 1 -> Infinity
-ddscb015 scaleb -Infinity 2 -> -Infinity
-ddscb016 scaleb Infinity -1 -> Infinity
-ddscb017 scaleb -Infinity -2 -> -Infinity
-
--- Next two are somewhat undefined in 754r; treat as non-integer
-ddscb018 scaleb 10 Infinity -> NaN Invalid_operation
-ddscb019 scaleb 10 -Infinity -> NaN Invalid_operation
-
--- NaNs are undefined in 754r; assume usual processing
--- NaNs, 0 payload
-ddscb021 scaleb NaN 1 -> NaN
-ddscb022 scaleb -NaN -1 -> -NaN
-ddscb023 scaleb sNaN 1 -> NaN Invalid_operation
-ddscb024 scaleb -sNaN 1 -> -NaN Invalid_operation
-ddscb025 scaleb 4 NaN -> NaN
-ddscb026 scaleb -Inf -NaN -> -NaN
-ddscb027 scaleb 4 sNaN -> NaN Invalid_operation
-ddscb028 scaleb Inf -sNaN -> -NaN Invalid_operation
-
--- non-integer RHS
-ddscb030 scaleb 1.23 1 -> 12.3
-ddscb031 scaleb 1.23 1.00 -> NaN Invalid_operation
-ddscb032 scaleb 1.23 1.1 -> NaN Invalid_operation
-ddscb033 scaleb 1.23 1.01 -> NaN Invalid_operation
-ddscb034 scaleb 1.23 0.01 -> NaN Invalid_operation
-ddscb035 scaleb 1.23 0.11 -> NaN Invalid_operation
-ddscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
-ddscb037 scaleb 1.23 -1 -> 0.123
-ddscb038 scaleb 1.23 -1.00 -> NaN Invalid_operation
-ddscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation
-ddscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation
-ddscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation
-ddscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation
-ddscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
-ddscb044 scaleb 1.23 0.1 -> NaN Invalid_operation
-ddscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation
-ddscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
-ddscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
-
--- out-of range RHS
-ddscb120 scaleb 1.23 799 -> Infinity Overflow Inexact Rounded
-ddscb121 scaleb 1.23 800 -> Infinity Overflow Inexact Rounded
-ddscb122 scaleb 1.23 801 -> NaN Invalid_operation
-ddscb123 scaleb 1.23 802 -> NaN Invalid_operation
-ddscb124 scaleb 1.23 -799 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddscb125 scaleb 1.23 -800 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddscb126 scaleb 1.23 -801 -> NaN Invalid_operation
-ddscb127 scaleb 1.23 -802 -> NaN Invalid_operation
-
--- NaNs, non-0 payload
--- propagating NaNs
-ddscb861 scaleb NaN01 -Inf -> NaN1
-ddscb862 scaleb -NaN02 -1000 -> -NaN2
-ddscb863 scaleb NaN03 1000 -> NaN3
-ddscb864 scaleb NaN04 Inf -> NaN4
-ddscb865 scaleb NaN05 NaN61 -> NaN5
-ddscb866 scaleb -Inf -NaN71 -> -NaN71
-ddscb867 scaleb -1000 NaN81 -> NaN81
-ddscb868 scaleb 1000 NaN91 -> NaN91
-ddscb869 scaleb Inf NaN101 -> NaN101
-ddscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
-ddscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
-ddscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
-ddscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
-ddscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
-ddscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
-ddscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
-ddscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
-ddscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
-ddscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
-ddscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- finites
-ddscb051 scaleb 7 -2 -> 0.07
-ddscb052 scaleb -7 -2 -> -0.07
-ddscb053 scaleb 75 -2 -> 0.75
-ddscb054 scaleb -75 -2 -> -0.75
-ddscb055 scaleb 7.50 -2 -> 0.0750
-ddscb056 scaleb -7.50 -2 -> -0.0750
-ddscb057 scaleb 7.500 -2 -> 0.07500
-ddscb058 scaleb -7.500 -2 -> -0.07500
-ddscb061 scaleb 7 -1 -> 0.7
-ddscb062 scaleb -7 -1 -> -0.7
-ddscb063 scaleb 75 -1 -> 7.5
-ddscb064 scaleb -75 -1 -> -7.5
-ddscb065 scaleb 7.50 -1 -> 0.750
-ddscb066 scaleb -7.50 -1 -> -0.750
-ddscb067 scaleb 7.500 -1 -> 0.7500
-ddscb068 scaleb -7.500 -1 -> -0.7500
-ddscb071 scaleb 7 0 -> 7
-ddscb072 scaleb -7 0 -> -7
-ddscb073 scaleb 75 0 -> 75
-ddscb074 scaleb -75 0 -> -75
-ddscb075 scaleb 7.50 0 -> 7.50
-ddscb076 scaleb -7.50 0 -> -7.50
-ddscb077 scaleb 7.500 0 -> 7.500
-ddscb078 scaleb -7.500 0 -> -7.500
-ddscb081 scaleb 7 1 -> 7E+1
-ddscb082 scaleb -7 1 -> -7E+1
-ddscb083 scaleb 75 1 -> 7.5E+2
-ddscb084 scaleb -75 1 -> -7.5E+2
-ddscb085 scaleb 7.50 1 -> 75.0
-ddscb086 scaleb -7.50 1 -> -75.0
-ddscb087 scaleb 7.500 1 -> 75.00
-ddscb088 scaleb -7.500 1 -> -75.00
-ddscb091 scaleb 7 2 -> 7E+2
-ddscb092 scaleb -7 2 -> -7E+2
-ddscb093 scaleb 75 2 -> 7.5E+3
-ddscb094 scaleb -75 2 -> -7.5E+3
-ddscb095 scaleb 7.50 2 -> 750
-ddscb096 scaleb -7.50 2 -> -750
-ddscb097 scaleb 7.500 2 -> 750.0
-ddscb098 scaleb -7.500 2 -> -750.0
-
--- zeros
-ddscb111 scaleb 0 1 -> 0E+1
-ddscb112 scaleb -0 2 -> -0E+2
-ddscb113 scaleb 0E+4 3 -> 0E+7
-ddscb114 scaleb -0E+4 4 -> -0E+8
-ddscb115 scaleb 0.0000 5 -> 0E+1
-ddscb116 scaleb -0.0000 6 -> -0E+2
-ddscb117 scaleb 0E-141 7 -> 0E-134
-ddscb118 scaleb -0E-141 8 -> -0E-133
-
--- Nmax, Nmin, Ntiny
-ddscb132 scaleb 9.999999999999999E+384 +384 -> Infinity Overflow Inexact Rounded
-ddscb133 scaleb 9.999999999999999E+384 +10 -> Infinity Overflow Inexact Rounded
-ddscb134 scaleb 9.999999999999999E+384 +1 -> Infinity Overflow Inexact Rounded
-ddscb135 scaleb 9.999999999999999E+384 0 -> 9.999999999999999E+384
-ddscb136 scaleb 9.999999999999999E+384 -1 -> 9.999999999999999E+383
-ddscb137 scaleb 1E-383 +1 -> 1E-382
-ddscb138 scaleb 1E-383 -0 -> 1E-383
-ddscb139 scaleb 1E-383 -1 -> 1E-384 Subnormal
-ddscb140 scaleb 1.000000000000000E-383 +1 -> 1.000000000000000E-382
-ddscb141 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383
-ddscb142 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded
-ddscb143 scaleb 1E-398 +1 -> 1E-397 Subnormal
-ddscb144 scaleb 1E-398 -0 -> 1E-398 Subnormal
-ddscb145 scaleb 1E-398 -1 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-ddscb150 scaleb -1E-398 +1 -> -1E-397 Subnormal
-ddscb151 scaleb -1E-398 -0 -> -1E-398 Subnormal
-ddscb152 scaleb -1E-398 -1 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddscb153 scaleb -1.000000000000000E-383 +1 -> -1.000000000000000E-382
-ddscb154 scaleb -1.000000000000000E-383 +0 -> -1.000000000000000E-383
-ddscb155 scaleb -1.000000000000000E-383 -1 -> -1.00000000000000E-384 Subnormal Rounded
-ddscb156 scaleb -1E-383 +1 -> -1E-382
-ddscb157 scaleb -1E-383 -0 -> -1E-383
-ddscb158 scaleb -1E-383 -1 -> -1E-384 Subnormal
-ddscb159 scaleb -9.999999999999999E+384 +1 -> -Infinity Overflow Inexact Rounded
-ddscb160 scaleb -9.999999999999999E+384 +0 -> -9.999999999999999E+384
-ddscb161 scaleb -9.999999999999999E+384 -1 -> -9.999999999999999E+383
-ddscb162 scaleb -9E+384 +1 -> -Infinity Overflow Inexact Rounded
-ddscb163 scaleb -1E+384 +1 -> -Infinity Overflow Inexact Rounded
-
--- some Origami
--- (these check that overflow is being done correctly)
-ddscb171 scaleb 1000E+365 +1 -> 1.000E+369
-ddscb172 scaleb 1000E+366 +1 -> 1.000E+370
-ddscb173 scaleb 1000E+367 +1 -> 1.000E+371
-ddscb174 scaleb 1000E+368 +1 -> 1.000E+372
-ddscb175 scaleb 1000E+369 +1 -> 1.0000E+373 Clamped
-ddscb176 scaleb 1000E+370 +1 -> 1.00000E+374 Clamped
-ddscb177 scaleb 1000E+371 +1 -> 1.000000E+375 Clamped
-ddscb178 scaleb 1000E+372 +1 -> 1.0000000E+376 Clamped
-ddscb179 scaleb 1000E+373 +1 -> 1.00000000E+377 Clamped
-ddscb180 scaleb 1000E+374 +1 -> 1.000000000E+378 Clamped
-ddscb181 scaleb 1000E+375 +1 -> 1.0000000000E+379 Clamped
-ddscb182 scaleb 1000E+376 +1 -> 1.00000000000E+380 Clamped
-ddscb183 scaleb 1000E+377 +1 -> 1.000000000000E+381 Clamped
-ddscb184 scaleb 1000E+378 +1 -> 1.0000000000000E+382 Clamped
-ddscb185 scaleb 1000E+379 +1 -> 1.00000000000000E+383 Clamped
-ddscb186 scaleb 1000E+380 +1 -> 1.000000000000000E+384 Clamped
-ddscb187 scaleb 1000E+381 +1 -> Infinity Overflow Inexact Rounded
-
--- and a few more subnormal truncations
--- (these check that underflow is being done correctly)
-ddscb201 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383
-ddscb202 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded
-ddscb203 scaleb 1.000000000000000E-383 -2 -> 1.0000000000000E-385 Subnormal Rounded
-ddscb204 scaleb 1.000000000000000E-383 -3 -> 1.000000000000E-386 Subnormal Rounded
-ddscb205 scaleb 1.000000000000000E-383 -4 -> 1.00000000000E-387 Subnormal Rounded
-ddscb206 scaleb 1.000000000000000E-383 -5 -> 1.0000000000E-388 Subnormal Rounded
-ddscb207 scaleb 1.000000000000000E-383 -6 -> 1.000000000E-389 Subnormal Rounded
-ddscb208 scaleb 1.000000000000000E-383 -7 -> 1.00000000E-390 Subnormal Rounded
-ddscb209 scaleb 1.000000000000000E-383 -8 -> 1.0000000E-391 Subnormal Rounded
-ddscb210 scaleb 1.000000000000000E-383 -9 -> 1.000000E-392 Subnormal Rounded
-ddscb211 scaleb 1.000000000000000E-383 -10 -> 1.00000E-393 Subnormal Rounded
-ddscb212 scaleb 1.000000000000000E-383 -11 -> 1.0000E-394 Subnormal Rounded
-ddscb213 scaleb 1.000000000000000E-383 -12 -> 1.000E-395 Subnormal Rounded
-ddscb214 scaleb 1.000000000000000E-383 -13 -> 1.00E-396 Subnormal Rounded
-ddscb215 scaleb 1.000000000000000E-383 -14 -> 1.0E-397 Subnormal Rounded
-ddscb216 scaleb 1.000000000000000E-383 -15 -> 1E-398 Subnormal Rounded
-ddscb217 scaleb 1.000000000000000E-383 -16 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddscb218 scaleb 1.000000000000000E-383 -17 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
+------------------------------------------------------------------------
+-- ddScalebB.decTest -- scale a decDouble by powers of 10 --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Max |rhs| is 2*(384+16) = 800
+
+-- Sanity checks
+ddscb001 scaleb 7.50 10 -> 7.50E+10
+ddscb002 scaleb 7.50 3 -> 7.50E+3
+ddscb003 scaleb 7.50 2 -> 750
+ddscb004 scaleb 7.50 1 -> 75.0
+ddscb005 scaleb 7.50 0 -> 7.50
+ddscb006 scaleb 7.50 -1 -> 0.750
+ddscb007 scaleb 7.50 -2 -> 0.0750
+ddscb008 scaleb 7.50 -10 -> 7.50E-10
+ddscb009 scaleb -7.50 3 -> -7.50E+3
+ddscb010 scaleb -7.50 2 -> -750
+ddscb011 scaleb -7.50 1 -> -75.0
+ddscb012 scaleb -7.50 0 -> -7.50
+ddscb013 scaleb -7.50 -1 -> -0.750
+
+-- Infinities
+ddscb014 scaleb Infinity 1 -> Infinity
+ddscb015 scaleb -Infinity 2 -> -Infinity
+ddscb016 scaleb Infinity -1 -> Infinity
+ddscb017 scaleb -Infinity -2 -> -Infinity
+
+-- Next two are somewhat undefined in 754r; treat as non-integer
+ddscb018 scaleb 10 Infinity -> NaN Invalid_operation
+ddscb019 scaleb 10 -Infinity -> NaN Invalid_operation
+
+-- NaNs are undefined in 754r; assume usual processing
+-- NaNs, 0 payload
+ddscb021 scaleb NaN 1 -> NaN
+ddscb022 scaleb -NaN -1 -> -NaN
+ddscb023 scaleb sNaN 1 -> NaN Invalid_operation
+ddscb024 scaleb -sNaN 1 -> -NaN Invalid_operation
+ddscb025 scaleb 4 NaN -> NaN
+ddscb026 scaleb -Inf -NaN -> -NaN
+ddscb027 scaleb 4 sNaN -> NaN Invalid_operation
+ddscb028 scaleb Inf -sNaN -> -NaN Invalid_operation
+
+-- non-integer RHS
+ddscb030 scaleb 1.23 1 -> 12.3
+ddscb031 scaleb 1.23 1.00 -> NaN Invalid_operation
+ddscb032 scaleb 1.23 1.1 -> NaN Invalid_operation
+ddscb033 scaleb 1.23 1.01 -> NaN Invalid_operation
+ddscb034 scaleb 1.23 0.01 -> NaN Invalid_operation
+ddscb035 scaleb 1.23 0.11 -> NaN Invalid_operation
+ddscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
+ddscb037 scaleb 1.23 -1 -> 0.123
+ddscb038 scaleb 1.23 -1.00 -> NaN Invalid_operation
+ddscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation
+ddscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation
+ddscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation
+ddscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation
+ddscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
+ddscb044 scaleb 1.23 0.1 -> NaN Invalid_operation
+ddscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation
+ddscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
+ddscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
+
+-- out-of range RHS
+ddscb120 scaleb 1.23 799 -> Infinity Overflow Inexact Rounded
+ddscb121 scaleb 1.23 800 -> Infinity Overflow Inexact Rounded
+ddscb122 scaleb 1.23 801 -> NaN Invalid_operation
+ddscb123 scaleb 1.23 802 -> NaN Invalid_operation
+ddscb124 scaleb 1.23 -799 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddscb125 scaleb 1.23 -800 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddscb126 scaleb 1.23 -801 -> NaN Invalid_operation
+ddscb127 scaleb 1.23 -802 -> NaN Invalid_operation
+
+-- NaNs, non-0 payload
+-- propagating NaNs
+ddscb861 scaleb NaN01 -Inf -> NaN1
+ddscb862 scaleb -NaN02 -1000 -> -NaN2
+ddscb863 scaleb NaN03 1000 -> NaN3
+ddscb864 scaleb NaN04 Inf -> NaN4
+ddscb865 scaleb NaN05 NaN61 -> NaN5
+ddscb866 scaleb -Inf -NaN71 -> -NaN71
+ddscb867 scaleb -1000 NaN81 -> NaN81
+ddscb868 scaleb 1000 NaN91 -> NaN91
+ddscb869 scaleb Inf NaN101 -> NaN101
+ddscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
+ddscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
+ddscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
+ddscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
+ddscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
+ddscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
+ddscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
+ddscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
+ddscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
+ddscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
+ddscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- finites
+ddscb051 scaleb 7 -2 -> 0.07
+ddscb052 scaleb -7 -2 -> -0.07
+ddscb053 scaleb 75 -2 -> 0.75
+ddscb054 scaleb -75 -2 -> -0.75
+ddscb055 scaleb 7.50 -2 -> 0.0750
+ddscb056 scaleb -7.50 -2 -> -0.0750
+ddscb057 scaleb 7.500 -2 -> 0.07500
+ddscb058 scaleb -7.500 -2 -> -0.07500
+ddscb061 scaleb 7 -1 -> 0.7
+ddscb062 scaleb -7 -1 -> -0.7
+ddscb063 scaleb 75 -1 -> 7.5
+ddscb064 scaleb -75 -1 -> -7.5
+ddscb065 scaleb 7.50 -1 -> 0.750
+ddscb066 scaleb -7.50 -1 -> -0.750
+ddscb067 scaleb 7.500 -1 -> 0.7500
+ddscb068 scaleb -7.500 -1 -> -0.7500
+ddscb071 scaleb 7 0 -> 7
+ddscb072 scaleb -7 0 -> -7
+ddscb073 scaleb 75 0 -> 75
+ddscb074 scaleb -75 0 -> -75
+ddscb075 scaleb 7.50 0 -> 7.50
+ddscb076 scaleb -7.50 0 -> -7.50
+ddscb077 scaleb 7.500 0 -> 7.500
+ddscb078 scaleb -7.500 0 -> -7.500
+ddscb081 scaleb 7 1 -> 7E+1
+ddscb082 scaleb -7 1 -> -7E+1
+ddscb083 scaleb 75 1 -> 7.5E+2
+ddscb084 scaleb -75 1 -> -7.5E+2
+ddscb085 scaleb 7.50 1 -> 75.0
+ddscb086 scaleb -7.50 1 -> -75.0
+ddscb087 scaleb 7.500 1 -> 75.00
+ddscb088 scaleb -7.500 1 -> -75.00
+ddscb091 scaleb 7 2 -> 7E+2
+ddscb092 scaleb -7 2 -> -7E+2
+ddscb093 scaleb 75 2 -> 7.5E+3
+ddscb094 scaleb -75 2 -> -7.5E+3
+ddscb095 scaleb 7.50 2 -> 750
+ddscb096 scaleb -7.50 2 -> -750
+ddscb097 scaleb 7.500 2 -> 750.0
+ddscb098 scaleb -7.500 2 -> -750.0
+
+-- zeros
+ddscb111 scaleb 0 1 -> 0E+1
+ddscb112 scaleb -0 2 -> -0E+2
+ddscb113 scaleb 0E+4 3 -> 0E+7
+ddscb114 scaleb -0E+4 4 -> -0E+8
+ddscb115 scaleb 0.0000 5 -> 0E+1
+ddscb116 scaleb -0.0000 6 -> -0E+2
+ddscb117 scaleb 0E-141 7 -> 0E-134
+ddscb118 scaleb -0E-141 8 -> -0E-133
+
+-- Nmax, Nmin, Ntiny
+ddscb132 scaleb 9.999999999999999E+384 +384 -> Infinity Overflow Inexact Rounded
+ddscb133 scaleb 9.999999999999999E+384 +10 -> Infinity Overflow Inexact Rounded
+ddscb134 scaleb 9.999999999999999E+384 +1 -> Infinity Overflow Inexact Rounded
+ddscb135 scaleb 9.999999999999999E+384 0 -> 9.999999999999999E+384
+ddscb136 scaleb 9.999999999999999E+384 -1 -> 9.999999999999999E+383
+ddscb137 scaleb 1E-383 +1 -> 1E-382
+ddscb138 scaleb 1E-383 -0 -> 1E-383
+ddscb139 scaleb 1E-383 -1 -> 1E-384 Subnormal
+ddscb140 scaleb 1.000000000000000E-383 +1 -> 1.000000000000000E-382
+ddscb141 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383
+ddscb142 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded
+ddscb143 scaleb 1E-398 +1 -> 1E-397 Subnormal
+ddscb144 scaleb 1E-398 -0 -> 1E-398 Subnormal
+ddscb145 scaleb 1E-398 -1 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+ddscb150 scaleb -1E-398 +1 -> -1E-397 Subnormal
+ddscb151 scaleb -1E-398 -0 -> -1E-398 Subnormal
+ddscb152 scaleb -1E-398 -1 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddscb153 scaleb -1.000000000000000E-383 +1 -> -1.000000000000000E-382
+ddscb154 scaleb -1.000000000000000E-383 +0 -> -1.000000000000000E-383
+ddscb155 scaleb -1.000000000000000E-383 -1 -> -1.00000000000000E-384 Subnormal Rounded
+ddscb156 scaleb -1E-383 +1 -> -1E-382
+ddscb157 scaleb -1E-383 -0 -> -1E-383
+ddscb158 scaleb -1E-383 -1 -> -1E-384 Subnormal
+ddscb159 scaleb -9.999999999999999E+384 +1 -> -Infinity Overflow Inexact Rounded
+ddscb160 scaleb -9.999999999999999E+384 +0 -> -9.999999999999999E+384
+ddscb161 scaleb -9.999999999999999E+384 -1 -> -9.999999999999999E+383
+ddscb162 scaleb -9E+384 +1 -> -Infinity Overflow Inexact Rounded
+ddscb163 scaleb -1E+384 +1 -> -Infinity Overflow Inexact Rounded
+
+-- some Origami
+-- (these check that overflow is being done correctly)
+ddscb171 scaleb 1000E+365 +1 -> 1.000E+369
+ddscb172 scaleb 1000E+366 +1 -> 1.000E+370
+ddscb173 scaleb 1000E+367 +1 -> 1.000E+371
+ddscb174 scaleb 1000E+368 +1 -> 1.000E+372
+ddscb175 scaleb 1000E+369 +1 -> 1.0000E+373 Clamped
+ddscb176 scaleb 1000E+370 +1 -> 1.00000E+374 Clamped
+ddscb177 scaleb 1000E+371 +1 -> 1.000000E+375 Clamped
+ddscb178 scaleb 1000E+372 +1 -> 1.0000000E+376 Clamped
+ddscb179 scaleb 1000E+373 +1 -> 1.00000000E+377 Clamped
+ddscb180 scaleb 1000E+374 +1 -> 1.000000000E+378 Clamped
+ddscb181 scaleb 1000E+375 +1 -> 1.0000000000E+379 Clamped
+ddscb182 scaleb 1000E+376 +1 -> 1.00000000000E+380 Clamped
+ddscb183 scaleb 1000E+377 +1 -> 1.000000000000E+381 Clamped
+ddscb184 scaleb 1000E+378 +1 -> 1.0000000000000E+382 Clamped
+ddscb185 scaleb 1000E+379 +1 -> 1.00000000000000E+383 Clamped
+ddscb186 scaleb 1000E+380 +1 -> 1.000000000000000E+384 Clamped
+ddscb187 scaleb 1000E+381 +1 -> Infinity Overflow Inexact Rounded
+
+-- and a few more subnormal truncations
+-- (these check that underflow is being done correctly)
+ddscb201 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383
+ddscb202 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded
+ddscb203 scaleb 1.000000000000000E-383 -2 -> 1.0000000000000E-385 Subnormal Rounded
+ddscb204 scaleb 1.000000000000000E-383 -3 -> 1.000000000000E-386 Subnormal Rounded
+ddscb205 scaleb 1.000000000000000E-383 -4 -> 1.00000000000E-387 Subnormal Rounded
+ddscb206 scaleb 1.000000000000000E-383 -5 -> 1.0000000000E-388 Subnormal Rounded
+ddscb207 scaleb 1.000000000000000E-383 -6 -> 1.000000000E-389 Subnormal Rounded
+ddscb208 scaleb 1.000000000000000E-383 -7 -> 1.00000000E-390 Subnormal Rounded
+ddscb209 scaleb 1.000000000000000E-383 -8 -> 1.0000000E-391 Subnormal Rounded
+ddscb210 scaleb 1.000000000000000E-383 -9 -> 1.000000E-392 Subnormal Rounded
+ddscb211 scaleb 1.000000000000000E-383 -10 -> 1.00000E-393 Subnormal Rounded
+ddscb212 scaleb 1.000000000000000E-383 -11 -> 1.0000E-394 Subnormal Rounded
+ddscb213 scaleb 1.000000000000000E-383 -12 -> 1.000E-395 Subnormal Rounded
+ddscb214 scaleb 1.000000000000000E-383 -13 -> 1.00E-396 Subnormal Rounded
+ddscb215 scaleb 1.000000000000000E-383 -14 -> 1.0E-397 Subnormal Rounded
+ddscb216 scaleb 1.000000000000000E-383 -15 -> 1E-398 Subnormal Rounded
+ddscb217 scaleb 1.000000000000000E-383 -16 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddscb218 scaleb 1.000000000000000E-383 -17 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
diff --git a/Lib/test/decimaltestdata/ddShift.decTest b/Lib/test/decimaltestdata/ddShift.decTest
index f62a236b2e..ec472403e6 100644
--- a/Lib/test/decimaltestdata/ddShift.decTest
+++ b/Lib/test/decimaltestdata/ddShift.decTest
@@ -1,262 +1,262 @@
-------------------------------------------------------------------------
--- ddShift.decTest -- shift decDouble coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddshi001 shift 0 0 -> 0
-ddshi002 shift 0 2 -> 0
-ddshi003 shift 1 2 -> 100
-ddshi004 shift 1 15 -> 1000000000000000
-ddshi005 shift 1 16 -> 0
-ddshi006 shift 1 -1 -> 0
-ddshi007 shift 0 -2 -> 0
-ddshi008 shift 1234567890123456 -1 -> 123456789012345
-ddshi009 shift 1234567890123456 -15 -> 1
-ddshi010 shift 1234567890123456 -16 -> 0
-ddshi011 shift 9934567890123456 -15 -> 9
-ddshi012 shift 9934567890123456 -16 -> 0
-
--- rhs must be an integer
-ddshi015 shift 1 1.5 -> NaN Invalid_operation
-ddshi016 shift 1 1.0 -> NaN Invalid_operation
-ddshi017 shift 1 0.1 -> NaN Invalid_operation
-ddshi018 shift 1 0.0 -> NaN Invalid_operation
-ddshi019 shift 1 1E+1 -> NaN Invalid_operation
-ddshi020 shift 1 1E+99 -> NaN Invalid_operation
-ddshi021 shift 1 Inf -> NaN Invalid_operation
-ddshi022 shift 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-ddshi025 shift 1 -1000 -> NaN Invalid_operation
-ddshi026 shift 1 -17 -> NaN Invalid_operation
-ddshi027 shift 1 17 -> NaN Invalid_operation
-ddshi028 shift 1 1000 -> NaN Invalid_operation
-
--- full shifting pattern
-ddshi030 shift 1234567890123456 -16 -> 0
-ddshi031 shift 1234567890123456 -15 -> 1
-ddshi032 shift 1234567890123456 -14 -> 12
-ddshi033 shift 1234567890123456 -13 -> 123
-ddshi034 shift 1234567890123456 -12 -> 1234
-ddshi035 shift 1234567890123456 -11 -> 12345
-ddshi036 shift 1234567890123456 -10 -> 123456
-ddshi037 shift 1234567890123456 -9 -> 1234567
-ddshi038 shift 1234567890123456 -8 -> 12345678
-ddshi039 shift 1234567890123456 -7 -> 123456789
-ddshi040 shift 1234567890123456 -6 -> 1234567890
-ddshi041 shift 1234567890123456 -5 -> 12345678901
-ddshi042 shift 1234567890123456 -4 -> 123456789012
-ddshi043 shift 1234567890123456 -3 -> 1234567890123
-ddshi044 shift 1234567890123456 -2 -> 12345678901234
-ddshi045 shift 1234567890123456 -1 -> 123456789012345
-ddshi046 shift 1234567890123456 -0 -> 1234567890123456
-
-ddshi047 shift 1234567890123456 +0 -> 1234567890123456
-ddshi048 shift 1234567890123456 +1 -> 2345678901234560
-ddshi049 shift 1234567890123456 +2 -> 3456789012345600
-ddshi050 shift 1234567890123456 +3 -> 4567890123456000
-ddshi051 shift 1234567890123456 +4 -> 5678901234560000
-ddshi052 shift 1234567890123456 +5 -> 6789012345600000
-ddshi053 shift 1234567890123456 +6 -> 7890123456000000
-ddshi054 shift 1234567890123456 +7 -> 8901234560000000
-ddshi055 shift 1234567890123456 +8 -> 9012345600000000
-ddshi056 shift 1234567890123456 +9 -> 123456000000000
-ddshi057 shift 1234567890123456 +10 -> 1234560000000000
-ddshi058 shift 1234567890123456 +11 -> 2345600000000000
-ddshi059 shift 1234567890123456 +12 -> 3456000000000000
-ddshi060 shift 1234567890123456 +13 -> 4560000000000000
-ddshi061 shift 1234567890123456 +14 -> 5600000000000000
-ddshi062 shift 1234567890123456 +15 -> 6000000000000000
-ddshi063 shift 1234567890123456 +16 -> 0
-
--- zeros
-ddshi070 shift 0E-10 +9 -> 0E-10
-ddshi071 shift 0E-10 -9 -> 0E-10
-ddshi072 shift 0.000 +9 -> 0.000
-ddshi073 shift 0.000 -9 -> 0.000
-ddshi074 shift 0E+10 +9 -> 0E+10
-ddshi075 shift 0E+10 -9 -> 0E+10
-ddshi076 shift -0E-10 +9 -> -0E-10
-ddshi077 shift -0E-10 -9 -> -0E-10
-ddshi078 shift -0.000 +9 -> -0.000
-ddshi079 shift -0.000 -9 -> -0.000
-ddshi080 shift -0E+10 +9 -> -0E+10
-ddshi081 shift -0E+10 -9 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-ddshi141 shift 9.999999999999999E+384 -1 -> 9.99999999999999E+383
-ddshi142 shift 9.999999999999999E+384 -15 -> 9E+369
-ddshi143 shift 9.999999999999999E+384 1 -> 9.999999999999990E+384
-ddshi144 shift 9.999999999999999E+384 15 -> 9.000000000000000E+384
-ddshi145 shift 1E-383 -1 -> 0E-383
-ddshi146 shift 1E-383 -15 -> 0E-383
-ddshi147 shift 1E-383 1 -> 1.0E-382
-ddshi148 shift 1E-383 15 -> 1.000000000000000E-368
-ddshi151 shift 1.000000000000000E-383 -1 -> 1.00000000000000E-384
-ddshi152 shift 1.000000000000000E-383 -15 -> 1E-398
-ddshi153 shift 1.000000000000000E-383 1 -> 0E-398
-ddshi154 shift 1.000000000000000E-383 15 -> 0E-398
-ddshi155 shift 9.000000000000000E-383 -1 -> 9.00000000000000E-384
-ddshi156 shift 9.000000000000000E-383 -15 -> 9E-398
-ddshi157 shift 9.000000000000000E-383 1 -> 0E-398
-ddshi158 shift 9.000000000000000E-383 15 -> 0E-398
-ddshi160 shift 1E-398 -1 -> 0E-398
-ddshi161 shift 1E-398 -15 -> 0E-398
-ddshi162 shift 1E-398 1 -> 1.0E-397
-ddshi163 shift 1E-398 15 -> 1.000000000000000E-383
--- negatives
-ddshi171 shift -9.999999999999999E+384 -1 -> -9.99999999999999E+383
-ddshi172 shift -9.999999999999999E+384 -15 -> -9E+369
-ddshi173 shift -9.999999999999999E+384 1 -> -9.999999999999990E+384
-ddshi174 shift -9.999999999999999E+384 15 -> -9.000000000000000E+384
-ddshi175 shift -1E-383 -1 -> -0E-383
-ddshi176 shift -1E-383 -15 -> -0E-383
-ddshi177 shift -1E-383 1 -> -1.0E-382
-ddshi178 shift -1E-383 15 -> -1.000000000000000E-368
-ddshi181 shift -1.000000000000000E-383 -1 -> -1.00000000000000E-384
-ddshi182 shift -1.000000000000000E-383 -15 -> -1E-398
-ddshi183 shift -1.000000000000000E-383 1 -> -0E-398
-ddshi184 shift -1.000000000000000E-383 15 -> -0E-398
-ddshi185 shift -9.000000000000000E-383 -1 -> -9.00000000000000E-384
-ddshi186 shift -9.000000000000000E-383 -15 -> -9E-398
-ddshi187 shift -9.000000000000000E-383 1 -> -0E-398
-ddshi188 shift -9.000000000000000E-383 15 -> -0E-398
-ddshi190 shift -1E-398 -1 -> -0E-398
-ddshi191 shift -1E-398 -15 -> -0E-398
-ddshi192 shift -1E-398 1 -> -1.0E-397
-ddshi193 shift -1E-398 15 -> -1.000000000000000E-383
-
--- more negatives (of sanities)
-ddshi201 shift -0 0 -> -0
-ddshi202 shift -0 2 -> -0
-ddshi203 shift -1 2 -> -100
-ddshi204 shift -1 15 -> -1000000000000000
-ddshi205 shift -1 16 -> -0
-ddshi206 shift -1 -1 -> -0
-ddshi207 shift -0 -2 -> -0
-ddshi208 shift -1234567890123456 -1 -> -123456789012345
-ddshi209 shift -1234567890123456 -15 -> -1
-ddshi210 shift -1234567890123456 -16 -> -0
-ddshi211 shift -9934567890123456 -15 -> -9
-ddshi212 shift -9934567890123456 -16 -> -0
-
-
--- Specials; NaNs are handled as usual
-ddshi781 shift -Inf -8 -> -Infinity
-ddshi782 shift -Inf -1 -> -Infinity
-ddshi783 shift -Inf -0 -> -Infinity
-ddshi784 shift -Inf 0 -> -Infinity
-ddshi785 shift -Inf 1 -> -Infinity
-ddshi786 shift -Inf 8 -> -Infinity
-ddshi787 shift -1000 -Inf -> NaN Invalid_operation
-ddshi788 shift -Inf -Inf -> NaN Invalid_operation
-ddshi789 shift -1 -Inf -> NaN Invalid_operation
-ddshi790 shift -0 -Inf -> NaN Invalid_operation
-ddshi791 shift 0 -Inf -> NaN Invalid_operation
-ddshi792 shift 1 -Inf -> NaN Invalid_operation
-ddshi793 shift 1000 -Inf -> NaN Invalid_operation
-ddshi794 shift Inf -Inf -> NaN Invalid_operation
-
-ddshi800 shift Inf -Inf -> NaN Invalid_operation
-ddshi801 shift Inf -8 -> Infinity
-ddshi802 shift Inf -1 -> Infinity
-ddshi803 shift Inf -0 -> Infinity
-ddshi804 shift Inf 0 -> Infinity
-ddshi805 shift Inf 1 -> Infinity
-ddshi806 shift Inf 8 -> Infinity
-ddshi807 shift Inf Inf -> NaN Invalid_operation
-ddshi808 shift -1000 Inf -> NaN Invalid_operation
-ddshi809 shift -Inf Inf -> NaN Invalid_operation
-ddshi810 shift -1 Inf -> NaN Invalid_operation
-ddshi811 shift -0 Inf -> NaN Invalid_operation
-ddshi812 shift 0 Inf -> NaN Invalid_operation
-ddshi813 shift 1 Inf -> NaN Invalid_operation
-ddshi814 shift 1000 Inf -> NaN Invalid_operation
-ddshi815 shift Inf Inf -> NaN Invalid_operation
-
-ddshi821 shift NaN -Inf -> NaN
-ddshi822 shift NaN -1000 -> NaN
-ddshi823 shift NaN -1 -> NaN
-ddshi824 shift NaN -0 -> NaN
-ddshi825 shift NaN 0 -> NaN
-ddshi826 shift NaN 1 -> NaN
-ddshi827 shift NaN 1000 -> NaN
-ddshi828 shift NaN Inf -> NaN
-ddshi829 shift NaN NaN -> NaN
-ddshi830 shift -Inf NaN -> NaN
-ddshi831 shift -1000 NaN -> NaN
-ddshi832 shift -1 NaN -> NaN
-ddshi833 shift -0 NaN -> NaN
-ddshi834 shift 0 NaN -> NaN
-ddshi835 shift 1 NaN -> NaN
-ddshi836 shift 1000 NaN -> NaN
-ddshi837 shift Inf NaN -> NaN
-
-ddshi841 shift sNaN -Inf -> NaN Invalid_operation
-ddshi842 shift sNaN -1000 -> NaN Invalid_operation
-ddshi843 shift sNaN -1 -> NaN Invalid_operation
-ddshi844 shift sNaN -0 -> NaN Invalid_operation
-ddshi845 shift sNaN 0 -> NaN Invalid_operation
-ddshi846 shift sNaN 1 -> NaN Invalid_operation
-ddshi847 shift sNaN 1000 -> NaN Invalid_operation
-ddshi848 shift sNaN NaN -> NaN Invalid_operation
-ddshi849 shift sNaN sNaN -> NaN Invalid_operation
-ddshi850 shift NaN sNaN -> NaN Invalid_operation
-ddshi851 shift -Inf sNaN -> NaN Invalid_operation
-ddshi852 shift -1000 sNaN -> NaN Invalid_operation
-ddshi853 shift -1 sNaN -> NaN Invalid_operation
-ddshi854 shift -0 sNaN -> NaN Invalid_operation
-ddshi855 shift 0 sNaN -> NaN Invalid_operation
-ddshi856 shift 1 sNaN -> NaN Invalid_operation
-ddshi857 shift 1000 sNaN -> NaN Invalid_operation
-ddshi858 shift Inf sNaN -> NaN Invalid_operation
-ddshi859 shift NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddshi861 shift NaN1 -Inf -> NaN1
-ddshi862 shift +NaN2 -1000 -> NaN2
-ddshi863 shift NaN3 1000 -> NaN3
-ddshi864 shift NaN4 Inf -> NaN4
-ddshi865 shift NaN5 +NaN6 -> NaN5
-ddshi866 shift -Inf NaN7 -> NaN7
-ddshi867 shift -1000 NaN8 -> NaN8
-ddshi868 shift 1000 NaN9 -> NaN9
-ddshi869 shift Inf +NaN10 -> NaN10
-ddshi871 shift sNaN11 -Inf -> NaN11 Invalid_operation
-ddshi872 shift sNaN12 -1000 -> NaN12 Invalid_operation
-ddshi873 shift sNaN13 1000 -> NaN13 Invalid_operation
-ddshi874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
-ddshi875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddshi876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
-ddshi877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
-ddshi878 shift -1000 sNaN21 -> NaN21 Invalid_operation
-ddshi879 shift 1000 sNaN22 -> NaN22 Invalid_operation
-ddshi880 shift Inf sNaN23 -> NaN23 Invalid_operation
-ddshi881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddshi882 shift -NaN26 NaN28 -> -NaN26
-ddshi883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddshi884 shift 1000 -NaN30 -> -NaN30
-ddshi885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- ddShift.decTest -- shift decDouble coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddshi001 shift 0 0 -> 0
+ddshi002 shift 0 2 -> 0
+ddshi003 shift 1 2 -> 100
+ddshi004 shift 1 15 -> 1000000000000000
+ddshi005 shift 1 16 -> 0
+ddshi006 shift 1 -1 -> 0
+ddshi007 shift 0 -2 -> 0
+ddshi008 shift 1234567890123456 -1 -> 123456789012345
+ddshi009 shift 1234567890123456 -15 -> 1
+ddshi010 shift 1234567890123456 -16 -> 0
+ddshi011 shift 9934567890123456 -15 -> 9
+ddshi012 shift 9934567890123456 -16 -> 0
+
+-- rhs must be an integer
+ddshi015 shift 1 1.5 -> NaN Invalid_operation
+ddshi016 shift 1 1.0 -> NaN Invalid_operation
+ddshi017 shift 1 0.1 -> NaN Invalid_operation
+ddshi018 shift 1 0.0 -> NaN Invalid_operation
+ddshi019 shift 1 1E+1 -> NaN Invalid_operation
+ddshi020 shift 1 1E+99 -> NaN Invalid_operation
+ddshi021 shift 1 Inf -> NaN Invalid_operation
+ddshi022 shift 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+ddshi025 shift 1 -1000 -> NaN Invalid_operation
+ddshi026 shift 1 -17 -> NaN Invalid_operation
+ddshi027 shift 1 17 -> NaN Invalid_operation
+ddshi028 shift 1 1000 -> NaN Invalid_operation
+
+-- full shifting pattern
+ddshi030 shift 1234567890123456 -16 -> 0
+ddshi031 shift 1234567890123456 -15 -> 1
+ddshi032 shift 1234567890123456 -14 -> 12
+ddshi033 shift 1234567890123456 -13 -> 123
+ddshi034 shift 1234567890123456 -12 -> 1234
+ddshi035 shift 1234567890123456 -11 -> 12345
+ddshi036 shift 1234567890123456 -10 -> 123456
+ddshi037 shift 1234567890123456 -9 -> 1234567
+ddshi038 shift 1234567890123456 -8 -> 12345678
+ddshi039 shift 1234567890123456 -7 -> 123456789
+ddshi040 shift 1234567890123456 -6 -> 1234567890
+ddshi041 shift 1234567890123456 -5 -> 12345678901
+ddshi042 shift 1234567890123456 -4 -> 123456789012
+ddshi043 shift 1234567890123456 -3 -> 1234567890123
+ddshi044 shift 1234567890123456 -2 -> 12345678901234
+ddshi045 shift 1234567890123456 -1 -> 123456789012345
+ddshi046 shift 1234567890123456 -0 -> 1234567890123456
+
+ddshi047 shift 1234567890123456 +0 -> 1234567890123456
+ddshi048 shift 1234567890123456 +1 -> 2345678901234560
+ddshi049 shift 1234567890123456 +2 -> 3456789012345600
+ddshi050 shift 1234567890123456 +3 -> 4567890123456000
+ddshi051 shift 1234567890123456 +4 -> 5678901234560000
+ddshi052 shift 1234567890123456 +5 -> 6789012345600000
+ddshi053 shift 1234567890123456 +6 -> 7890123456000000
+ddshi054 shift 1234567890123456 +7 -> 8901234560000000
+ddshi055 shift 1234567890123456 +8 -> 9012345600000000
+ddshi056 shift 1234567890123456 +9 -> 123456000000000
+ddshi057 shift 1234567890123456 +10 -> 1234560000000000
+ddshi058 shift 1234567890123456 +11 -> 2345600000000000
+ddshi059 shift 1234567890123456 +12 -> 3456000000000000
+ddshi060 shift 1234567890123456 +13 -> 4560000000000000
+ddshi061 shift 1234567890123456 +14 -> 5600000000000000
+ddshi062 shift 1234567890123456 +15 -> 6000000000000000
+ddshi063 shift 1234567890123456 +16 -> 0
+
+-- zeros
+ddshi070 shift 0E-10 +9 -> 0E-10
+ddshi071 shift 0E-10 -9 -> 0E-10
+ddshi072 shift 0.000 +9 -> 0.000
+ddshi073 shift 0.000 -9 -> 0.000
+ddshi074 shift 0E+10 +9 -> 0E+10
+ddshi075 shift 0E+10 -9 -> 0E+10
+ddshi076 shift -0E-10 +9 -> -0E-10
+ddshi077 shift -0E-10 -9 -> -0E-10
+ddshi078 shift -0.000 +9 -> -0.000
+ddshi079 shift -0.000 -9 -> -0.000
+ddshi080 shift -0E+10 +9 -> -0E+10
+ddshi081 shift -0E+10 -9 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+ddshi141 shift 9.999999999999999E+384 -1 -> 9.99999999999999E+383
+ddshi142 shift 9.999999999999999E+384 -15 -> 9E+369
+ddshi143 shift 9.999999999999999E+384 1 -> 9.999999999999990E+384
+ddshi144 shift 9.999999999999999E+384 15 -> 9.000000000000000E+384
+ddshi145 shift 1E-383 -1 -> 0E-383
+ddshi146 shift 1E-383 -15 -> 0E-383
+ddshi147 shift 1E-383 1 -> 1.0E-382
+ddshi148 shift 1E-383 15 -> 1.000000000000000E-368
+ddshi151 shift 1.000000000000000E-383 -1 -> 1.00000000000000E-384
+ddshi152 shift 1.000000000000000E-383 -15 -> 1E-398
+ddshi153 shift 1.000000000000000E-383 1 -> 0E-398
+ddshi154 shift 1.000000000000000E-383 15 -> 0E-398
+ddshi155 shift 9.000000000000000E-383 -1 -> 9.00000000000000E-384
+ddshi156 shift 9.000000000000000E-383 -15 -> 9E-398
+ddshi157 shift 9.000000000000000E-383 1 -> 0E-398
+ddshi158 shift 9.000000000000000E-383 15 -> 0E-398
+ddshi160 shift 1E-398 -1 -> 0E-398
+ddshi161 shift 1E-398 -15 -> 0E-398
+ddshi162 shift 1E-398 1 -> 1.0E-397
+ddshi163 shift 1E-398 15 -> 1.000000000000000E-383
+-- negatives
+ddshi171 shift -9.999999999999999E+384 -1 -> -9.99999999999999E+383
+ddshi172 shift -9.999999999999999E+384 -15 -> -9E+369
+ddshi173 shift -9.999999999999999E+384 1 -> -9.999999999999990E+384
+ddshi174 shift -9.999999999999999E+384 15 -> -9.000000000000000E+384
+ddshi175 shift -1E-383 -1 -> -0E-383
+ddshi176 shift -1E-383 -15 -> -0E-383
+ddshi177 shift -1E-383 1 -> -1.0E-382
+ddshi178 shift -1E-383 15 -> -1.000000000000000E-368
+ddshi181 shift -1.000000000000000E-383 -1 -> -1.00000000000000E-384
+ddshi182 shift -1.000000000000000E-383 -15 -> -1E-398
+ddshi183 shift -1.000000000000000E-383 1 -> -0E-398
+ddshi184 shift -1.000000000000000E-383 15 -> -0E-398
+ddshi185 shift -9.000000000000000E-383 -1 -> -9.00000000000000E-384
+ddshi186 shift -9.000000000000000E-383 -15 -> -9E-398
+ddshi187 shift -9.000000000000000E-383 1 -> -0E-398
+ddshi188 shift -9.000000000000000E-383 15 -> -0E-398
+ddshi190 shift -1E-398 -1 -> -0E-398
+ddshi191 shift -1E-398 -15 -> -0E-398
+ddshi192 shift -1E-398 1 -> -1.0E-397
+ddshi193 shift -1E-398 15 -> -1.000000000000000E-383
+
+-- more negatives (of sanities)
+ddshi201 shift -0 0 -> -0
+ddshi202 shift -0 2 -> -0
+ddshi203 shift -1 2 -> -100
+ddshi204 shift -1 15 -> -1000000000000000
+ddshi205 shift -1 16 -> -0
+ddshi206 shift -1 -1 -> -0
+ddshi207 shift -0 -2 -> -0
+ddshi208 shift -1234567890123456 -1 -> -123456789012345
+ddshi209 shift -1234567890123456 -15 -> -1
+ddshi210 shift -1234567890123456 -16 -> -0
+ddshi211 shift -9934567890123456 -15 -> -9
+ddshi212 shift -9934567890123456 -16 -> -0
+
+
+-- Specials; NaNs are handled as usual
+ddshi781 shift -Inf -8 -> -Infinity
+ddshi782 shift -Inf -1 -> -Infinity
+ddshi783 shift -Inf -0 -> -Infinity
+ddshi784 shift -Inf 0 -> -Infinity
+ddshi785 shift -Inf 1 -> -Infinity
+ddshi786 shift -Inf 8 -> -Infinity
+ddshi787 shift -1000 -Inf -> NaN Invalid_operation
+ddshi788 shift -Inf -Inf -> NaN Invalid_operation
+ddshi789 shift -1 -Inf -> NaN Invalid_operation
+ddshi790 shift -0 -Inf -> NaN Invalid_operation
+ddshi791 shift 0 -Inf -> NaN Invalid_operation
+ddshi792 shift 1 -Inf -> NaN Invalid_operation
+ddshi793 shift 1000 -Inf -> NaN Invalid_operation
+ddshi794 shift Inf -Inf -> NaN Invalid_operation
+
+ddshi800 shift Inf -Inf -> NaN Invalid_operation
+ddshi801 shift Inf -8 -> Infinity
+ddshi802 shift Inf -1 -> Infinity
+ddshi803 shift Inf -0 -> Infinity
+ddshi804 shift Inf 0 -> Infinity
+ddshi805 shift Inf 1 -> Infinity
+ddshi806 shift Inf 8 -> Infinity
+ddshi807 shift Inf Inf -> NaN Invalid_operation
+ddshi808 shift -1000 Inf -> NaN Invalid_operation
+ddshi809 shift -Inf Inf -> NaN Invalid_operation
+ddshi810 shift -1 Inf -> NaN Invalid_operation
+ddshi811 shift -0 Inf -> NaN Invalid_operation
+ddshi812 shift 0 Inf -> NaN Invalid_operation
+ddshi813 shift 1 Inf -> NaN Invalid_operation
+ddshi814 shift 1000 Inf -> NaN Invalid_operation
+ddshi815 shift Inf Inf -> NaN Invalid_operation
+
+ddshi821 shift NaN -Inf -> NaN
+ddshi822 shift NaN -1000 -> NaN
+ddshi823 shift NaN -1 -> NaN
+ddshi824 shift NaN -0 -> NaN
+ddshi825 shift NaN 0 -> NaN
+ddshi826 shift NaN 1 -> NaN
+ddshi827 shift NaN 1000 -> NaN
+ddshi828 shift NaN Inf -> NaN
+ddshi829 shift NaN NaN -> NaN
+ddshi830 shift -Inf NaN -> NaN
+ddshi831 shift -1000 NaN -> NaN
+ddshi832 shift -1 NaN -> NaN
+ddshi833 shift -0 NaN -> NaN
+ddshi834 shift 0 NaN -> NaN
+ddshi835 shift 1 NaN -> NaN
+ddshi836 shift 1000 NaN -> NaN
+ddshi837 shift Inf NaN -> NaN
+
+ddshi841 shift sNaN -Inf -> NaN Invalid_operation
+ddshi842 shift sNaN -1000 -> NaN Invalid_operation
+ddshi843 shift sNaN -1 -> NaN Invalid_operation
+ddshi844 shift sNaN -0 -> NaN Invalid_operation
+ddshi845 shift sNaN 0 -> NaN Invalid_operation
+ddshi846 shift sNaN 1 -> NaN Invalid_operation
+ddshi847 shift sNaN 1000 -> NaN Invalid_operation
+ddshi848 shift sNaN NaN -> NaN Invalid_operation
+ddshi849 shift sNaN sNaN -> NaN Invalid_operation
+ddshi850 shift NaN sNaN -> NaN Invalid_operation
+ddshi851 shift -Inf sNaN -> NaN Invalid_operation
+ddshi852 shift -1000 sNaN -> NaN Invalid_operation
+ddshi853 shift -1 sNaN -> NaN Invalid_operation
+ddshi854 shift -0 sNaN -> NaN Invalid_operation
+ddshi855 shift 0 sNaN -> NaN Invalid_operation
+ddshi856 shift 1 sNaN -> NaN Invalid_operation
+ddshi857 shift 1000 sNaN -> NaN Invalid_operation
+ddshi858 shift Inf sNaN -> NaN Invalid_operation
+ddshi859 shift NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddshi861 shift NaN1 -Inf -> NaN1
+ddshi862 shift +NaN2 -1000 -> NaN2
+ddshi863 shift NaN3 1000 -> NaN3
+ddshi864 shift NaN4 Inf -> NaN4
+ddshi865 shift NaN5 +NaN6 -> NaN5
+ddshi866 shift -Inf NaN7 -> NaN7
+ddshi867 shift -1000 NaN8 -> NaN8
+ddshi868 shift 1000 NaN9 -> NaN9
+ddshi869 shift Inf +NaN10 -> NaN10
+ddshi871 shift sNaN11 -Inf -> NaN11 Invalid_operation
+ddshi872 shift sNaN12 -1000 -> NaN12 Invalid_operation
+ddshi873 shift sNaN13 1000 -> NaN13 Invalid_operation
+ddshi874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
+ddshi875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddshi876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
+ddshi877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
+ddshi878 shift -1000 sNaN21 -> NaN21 Invalid_operation
+ddshi879 shift 1000 sNaN22 -> NaN22 Invalid_operation
+ddshi880 shift Inf sNaN23 -> NaN23 Invalid_operation
+ddshi881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddshi882 shift -NaN26 NaN28 -> -NaN26
+ddshi883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddshi884 shift 1000 -NaN30 -> -NaN30
+ddshi885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddSubtract.decTest b/Lib/test/decimaltestdata/ddSubtract.decTest
index 5ebc4878f0..15d47779eb 100644
--- a/Lib/test/decimaltestdata/ddSubtract.decTest
+++ b/Lib/test/decimaltestdata/ddSubtract.decTest
@@ -1,629 +1,629 @@
-------------------------------------------------------------------------
--- ddSubtract.decTest -- decDouble subtraction --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decDoubles only; all arguments are
--- representable in a decDouble
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- [first group are 'quick confidence check']
-ddsub001 subtract 0 0 -> '0'
-ddsub002 subtract 1 1 -> '0'
-ddsub003 subtract 1 2 -> '-1'
-ddsub004 subtract 2 1 -> '1'
-ddsub005 subtract 2 2 -> '0'
-ddsub006 subtract 3 2 -> '1'
-ddsub007 subtract 2 3 -> '-1'
-
-ddsub011 subtract -0 0 -> '-0'
-ddsub012 subtract -1 1 -> '-2'
-ddsub013 subtract -1 2 -> '-3'
-ddsub014 subtract -2 1 -> '-3'
-ddsub015 subtract -2 2 -> '-4'
-ddsub016 subtract -3 2 -> '-5'
-ddsub017 subtract -2 3 -> '-5'
-
-ddsub021 subtract 0 -0 -> '0'
-ddsub022 subtract 1 -1 -> '2'
-ddsub023 subtract 1 -2 -> '3'
-ddsub024 subtract 2 -1 -> '3'
-ddsub025 subtract 2 -2 -> '4'
-ddsub026 subtract 3 -2 -> '5'
-ddsub027 subtract 2 -3 -> '5'
-
-ddsub030 subtract 11 1 -> 10
-ddsub031 subtract 10 1 -> 9
-ddsub032 subtract 9 1 -> 8
-ddsub033 subtract 1 1 -> 0
-ddsub034 subtract 0 1 -> -1
-ddsub035 subtract -1 1 -> -2
-ddsub036 subtract -9 1 -> -10
-ddsub037 subtract -10 1 -> -11
-ddsub038 subtract -11 1 -> -12
-
-ddsub040 subtract '5.75' '3.3' -> '2.45'
-ddsub041 subtract '5' '-3' -> '8'
-ddsub042 subtract '-5' '-3' -> '-2'
-ddsub043 subtract '-7' '2.5' -> '-9.5'
-ddsub044 subtract '0.7' '0.3' -> '0.4'
-ddsub045 subtract '1.3' '0.3' -> '1.0'
-ddsub046 subtract '1.25' '1.25' -> '0.00'
-
-ddsub050 subtract '1.23456789' '1.00000000' -> '0.23456789'
-ddsub051 subtract '1.23456789' '1.00000089' -> '0.23456700'
-
-ddsub060 subtract '70' '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
-ddsub061 subtract '700' '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
-ddsub062 subtract '7000' '10000e+16' -> '-9.999999999999999E+19' Inexact Rounded
-ddsub063 subtract '70000' '10000e+16' -> '-9.999999999999993E+19' Rounded
-ddsub064 subtract '700000' '10000e+16' -> '-9.999999999999930E+19' Rounded
- -- symmetry:
-ddsub065 subtract '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
-ddsub066 subtract '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
-ddsub067 subtract '10000e+16' '7000' -> '9.999999999999999E+19' Inexact Rounded
-ddsub068 subtract '10000e+16' '70000' -> '9.999999999999993E+19' Rounded
-ddsub069 subtract '10000e+16' '700000' -> '9.999999999999930E+19' Rounded
-
- -- some of the next group are really constructor tests
-ddsub090 subtract '00.0' '0.0' -> '0.0'
-ddsub091 subtract '00.0' '0.00' -> '0.00'
-ddsub092 subtract '0.00' '00.0' -> '0.00'
-ddsub093 subtract '00.0' '0.00' -> '0.00'
-ddsub094 subtract '0.00' '00.0' -> '0.00'
-ddsub095 subtract '3' '.3' -> '2.7'
-ddsub096 subtract '3.' '.3' -> '2.7'
-ddsub097 subtract '3.0' '.3' -> '2.7'
-ddsub098 subtract '3.00' '.3' -> '2.70'
-ddsub099 subtract '3' '3' -> '0'
-ddsub100 subtract '3' '+3' -> '0'
-ddsub101 subtract '3' '-3' -> '6'
-ddsub102 subtract '3' '0.3' -> '2.7'
-ddsub103 subtract '3.' '0.3' -> '2.7'
-ddsub104 subtract '3.0' '0.3' -> '2.7'
-ddsub105 subtract '3.00' '0.3' -> '2.70'
-ddsub106 subtract '3' '3.0' -> '0.0'
-ddsub107 subtract '3' '+3.0' -> '0.0'
-ddsub108 subtract '3' '-3.0' -> '6.0'
-
--- the above all from add; massaged and extended. Now some new ones...
--- [particularly important for comparisons]
--- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
--- with input rounding.
-ddsub120 subtract '10.23456784' '10.23456789' -> '-5E-8'
-ddsub121 subtract '10.23456785' '10.23456789' -> '-4E-8'
-ddsub122 subtract '10.23456786' '10.23456789' -> '-3E-8'
-ddsub123 subtract '10.23456787' '10.23456789' -> '-2E-8'
-ddsub124 subtract '10.23456788' '10.23456789' -> '-1E-8'
-ddsub125 subtract '10.23456789' '10.23456789' -> '0E-8'
-ddsub126 subtract '10.23456790' '10.23456789' -> '1E-8'
-ddsub127 subtract '10.23456791' '10.23456789' -> '2E-8'
-ddsub128 subtract '10.23456792' '10.23456789' -> '3E-8'
-ddsub129 subtract '10.23456793' '10.23456789' -> '4E-8'
-ddsub130 subtract '10.23456794' '10.23456789' -> '5E-8'
-ddsub131 subtract '10.23456781' '10.23456786' -> '-5E-8'
-ddsub132 subtract '10.23456782' '10.23456786' -> '-4E-8'
-ddsub133 subtract '10.23456783' '10.23456786' -> '-3E-8'
-ddsub134 subtract '10.23456784' '10.23456786' -> '-2E-8'
-ddsub135 subtract '10.23456785' '10.23456786' -> '-1E-8'
-ddsub136 subtract '10.23456786' '10.23456786' -> '0E-8'
-ddsub137 subtract '10.23456787' '10.23456786' -> '1E-8'
-ddsub138 subtract '10.23456788' '10.23456786' -> '2E-8'
-ddsub139 subtract '10.23456789' '10.23456786' -> '3E-8'
-ddsub140 subtract '10.23456790' '10.23456786' -> '4E-8'
-ddsub141 subtract '10.23456791' '10.23456786' -> '5E-8'
-ddsub142 subtract '1' '0.999999999' -> '1E-9'
-ddsub143 subtract '0.999999999' '1' -> '-1E-9'
-ddsub144 subtract '-10.23456780' '-10.23456786' -> '6E-8'
-ddsub145 subtract '-10.23456790' '-10.23456786' -> '-4E-8'
-ddsub146 subtract '-10.23456791' '-10.23456786' -> '-5E-8'
-
--- additional scaled arithmetic tests [0.97 problem]
-ddsub160 subtract '0' '.1' -> '-0.1'
-ddsub161 subtract '00' '.97983' -> '-0.97983'
-ddsub162 subtract '0' '.9' -> '-0.9'
-ddsub163 subtract '0' '0.102' -> '-0.102'
-ddsub164 subtract '0' '.4' -> '-0.4'
-ddsub165 subtract '0' '.307' -> '-0.307'
-ddsub166 subtract '0' '.43822' -> '-0.43822'
-ddsub167 subtract '0' '.911' -> '-0.911'
-ddsub168 subtract '.0' '.02' -> '-0.02'
-ddsub169 subtract '00' '.392' -> '-0.392'
-ddsub170 subtract '0' '.26' -> '-0.26'
-ddsub171 subtract '0' '0.51' -> '-0.51'
-ddsub172 subtract '0' '.2234' -> '-0.2234'
-ddsub173 subtract '0' '.2' -> '-0.2'
-ddsub174 subtract '.0' '.0008' -> '-0.0008'
--- 0. on left
-ddsub180 subtract '0.0' '-.1' -> '0.1'
-ddsub181 subtract '0.00' '-.97983' -> '0.97983'
-ddsub182 subtract '0.0' '-.9' -> '0.9'
-ddsub183 subtract '0.0' '-0.102' -> '0.102'
-ddsub184 subtract '0.0' '-.4' -> '0.4'
-ddsub185 subtract '0.0' '-.307' -> '0.307'
-ddsub186 subtract '0.0' '-.43822' -> '0.43822'
-ddsub187 subtract '0.0' '-.911' -> '0.911'
-ddsub188 subtract '0.0' '-.02' -> '0.02'
-ddsub189 subtract '0.00' '-.392' -> '0.392'
-ddsub190 subtract '0.0' '-.26' -> '0.26'
-ddsub191 subtract '0.0' '-0.51' -> '0.51'
-ddsub192 subtract '0.0' '-.2234' -> '0.2234'
-ddsub193 subtract '0.0' '-.2' -> '0.2'
-ddsub194 subtract '0.0' '-.0008' -> '0.0008'
--- negatives of same
-ddsub200 subtract '0' '-.1' -> '0.1'
-ddsub201 subtract '00' '-.97983' -> '0.97983'
-ddsub202 subtract '0' '-.9' -> '0.9'
-ddsub203 subtract '0' '-0.102' -> '0.102'
-ddsub204 subtract '0' '-.4' -> '0.4'
-ddsub205 subtract '0' '-.307' -> '0.307'
-ddsub206 subtract '0' '-.43822' -> '0.43822'
-ddsub207 subtract '0' '-.911' -> '0.911'
-ddsub208 subtract '.0' '-.02' -> '0.02'
-ddsub209 subtract '00' '-.392' -> '0.392'
-ddsub210 subtract '0' '-.26' -> '0.26'
-ddsub211 subtract '0' '-0.51' -> '0.51'
-ddsub212 subtract '0' '-.2234' -> '0.2234'
-ddsub213 subtract '0' '-.2' -> '0.2'
-ddsub214 subtract '.0' '-.0008' -> '0.0008'
-
--- more fixed, LHS swaps [really the same as testcases under add]
-ddsub220 subtract '-56267E-12' 0 -> '-5.6267E-8'
-ddsub221 subtract '-56267E-11' 0 -> '-5.6267E-7'
-ddsub222 subtract '-56267E-10' 0 -> '-0.0000056267'
-ddsub223 subtract '-56267E-9' 0 -> '-0.000056267'
-ddsub224 subtract '-56267E-8' 0 -> '-0.00056267'
-ddsub225 subtract '-56267E-7' 0 -> '-0.0056267'
-ddsub226 subtract '-56267E-6' 0 -> '-0.056267'
-ddsub227 subtract '-56267E-5' 0 -> '-0.56267'
-ddsub228 subtract '-56267E-2' 0 -> '-562.67'
-ddsub229 subtract '-56267E-1' 0 -> '-5626.7'
-ddsub230 subtract '-56267E-0' 0 -> '-56267'
--- symmetry ...
-ddsub240 subtract 0 '-56267E-12' -> '5.6267E-8'
-ddsub241 subtract 0 '-56267E-11' -> '5.6267E-7'
-ddsub242 subtract 0 '-56267E-10' -> '0.0000056267'
-ddsub243 subtract 0 '-56267E-9' -> '0.000056267'
-ddsub244 subtract 0 '-56267E-8' -> '0.00056267'
-ddsub245 subtract 0 '-56267E-7' -> '0.0056267'
-ddsub246 subtract 0 '-56267E-6' -> '0.056267'
-ddsub247 subtract 0 '-56267E-5' -> '0.56267'
-ddsub248 subtract 0 '-56267E-2' -> '562.67'
-ddsub249 subtract 0 '-56267E-1' -> '5626.7'
-ddsub250 subtract 0 '-56267E-0' -> '56267'
-
--- now some more from the 'new' add
-ddsub301 subtract '1.23456789' '1.00000000' -> '0.23456789'
-ddsub302 subtract '1.23456789' '1.00000011' -> '0.23456778'
-
--- some carrying effects
-ddsub321 subtract '0.9998' '0.0000' -> '0.9998'
-ddsub322 subtract '0.9998' '0.0001' -> '0.9997'
-ddsub323 subtract '0.9998' '0.0002' -> '0.9996'
-ddsub324 subtract '0.9998' '0.0003' -> '0.9995'
-ddsub325 subtract '0.9998' '-0.0000' -> '0.9998'
-ddsub326 subtract '0.9998' '-0.0001' -> '0.9999'
-ddsub327 subtract '0.9998' '-0.0002' -> '1.0000'
-ddsub328 subtract '0.9998' '-0.0003' -> '1.0001'
-
--- internal boundaries
-ddsub346 subtract '10000e+9' '7' -> '9999999999993'
-ddsub347 subtract '10000e+9' '70' -> '9999999999930'
-ddsub348 subtract '10000e+9' '700' -> '9999999999300'
-ddsub349 subtract '10000e+9' '7000' -> '9999999993000'
-ddsub350 subtract '10000e+9' '70000' -> '9999999930000'
-ddsub351 subtract '10000e+9' '700000' -> '9999999300000'
-ddsub352 subtract '7' '10000e+9' -> '-9999999999993'
-ddsub353 subtract '70' '10000e+9' -> '-9999999999930'
-ddsub354 subtract '700' '10000e+9' -> '-9999999999300'
-ddsub355 subtract '7000' '10000e+9' -> '-9999999993000'
-ddsub356 subtract '70000' '10000e+9' -> '-9999999930000'
-ddsub357 subtract '700000' '10000e+9' -> '-9999999300000'
-
--- zero preservation
-ddsub361 subtract 1 '0.0001' -> '0.9999'
-ddsub362 subtract 1 '0.00001' -> '0.99999'
-ddsub363 subtract 1 '0.000001' -> '0.999999'
-ddsub364 subtract 1 '0.0000000000000001' -> '0.9999999999999999'
-ddsub365 subtract 1 '0.00000000000000001' -> '1.000000000000000' Inexact Rounded
-ddsub366 subtract 1 '0.000000000000000001' -> '1.000000000000000' Inexact Rounded
-
--- some funny zeros [in case of bad signum]
-ddsub370 subtract 1 0 -> 1
-ddsub371 subtract 1 0. -> 1
-ddsub372 subtract 1 .0 -> 1.0
-ddsub373 subtract 1 0.0 -> 1.0
-ddsub374 subtract 0 1 -> -1
-ddsub375 subtract 0. 1 -> -1
-ddsub376 subtract .0 1 -> -1.0
-ddsub377 subtract 0.0 1 -> -1.0
-
--- leading 0 digit before round
-ddsub910 subtract -103519362 -51897955.3 -> -51621406.7
-ddsub911 subtract 159579.444 89827.5229 -> 69751.9211
-
-ddsub920 subtract 333.0000000123456 33.00000001234566 -> 299.9999999999999 Inexact Rounded
-ddsub921 subtract 333.0000000123456 33.00000001234565 -> 300.0000000000000 Inexact Rounded
-ddsub922 subtract 133.0000000123456 33.00000001234565 -> 99.99999999999995
-ddsub923 subtract 133.0000000123456 33.00000001234564 -> 99.99999999999996
-ddsub924 subtract 133.0000000123456 33.00000001234540 -> 100.0000000000002 Rounded
-ddsub925 subtract 133.0000000123456 43.00000001234560 -> 90.00000000000000
-ddsub926 subtract 133.0000000123456 43.00000001234561 -> 89.99999999999999
-ddsub927 subtract 133.0000000123456 43.00000001234566 -> 89.99999999999994
-ddsub928 subtract 101.0000000123456 91.00000001234566 -> 9.99999999999994
-ddsub929 subtract 101.0000000123456 99.00000001234566 -> 1.99999999999994
-
--- more LHS swaps [were fixed]
-ddsub390 subtract '-56267E-10' 0 -> '-0.0000056267'
-ddsub391 subtract '-56267E-6' 0 -> '-0.056267'
-ddsub392 subtract '-56267E-5' 0 -> '-0.56267'
-ddsub393 subtract '-56267E-4' 0 -> '-5.6267'
-ddsub394 subtract '-56267E-3' 0 -> '-56.267'
-ddsub395 subtract '-56267E-2' 0 -> '-562.67'
-ddsub396 subtract '-56267E-1' 0 -> '-5626.7'
-ddsub397 subtract '-56267E-0' 0 -> '-56267'
-ddsub398 subtract '-5E-10' 0 -> '-5E-10'
-ddsub399 subtract '-5E-7' 0 -> '-5E-7'
-ddsub400 subtract '-5E-6' 0 -> '-0.000005'
-ddsub401 subtract '-5E-5' 0 -> '-0.00005'
-ddsub402 subtract '-5E-4' 0 -> '-0.0005'
-ddsub403 subtract '-5E-1' 0 -> '-0.5'
-ddsub404 subtract '-5E0' 0 -> '-5'
-ddsub405 subtract '-5E1' 0 -> '-50'
-ddsub406 subtract '-5E5' 0 -> '-500000'
-ddsub407 subtract '-5E15' 0 -> '-5000000000000000'
-ddsub408 subtract '-5E16' 0 -> '-5.000000000000000E+16' Rounded
-ddsub409 subtract '-5E17' 0 -> '-5.000000000000000E+17' Rounded
-ddsub410 subtract '-5E18' 0 -> '-5.000000000000000E+18' Rounded
-ddsub411 subtract '-5E100' 0 -> '-5.000000000000000E+100' Rounded
-
--- more RHS swaps [were fixed]
-ddsub420 subtract 0 '-56267E-10' -> '0.0000056267'
-ddsub421 subtract 0 '-56267E-6' -> '0.056267'
-ddsub422 subtract 0 '-56267E-5' -> '0.56267'
-ddsub423 subtract 0 '-56267E-4' -> '5.6267'
-ddsub424 subtract 0 '-56267E-3' -> '56.267'
-ddsub425 subtract 0 '-56267E-2' -> '562.67'
-ddsub426 subtract 0 '-56267E-1' -> '5626.7'
-ddsub427 subtract 0 '-56267E-0' -> '56267'
-ddsub428 subtract 0 '-5E-10' -> '5E-10'
-ddsub429 subtract 0 '-5E-7' -> '5E-7'
-ddsub430 subtract 0 '-5E-6' -> '0.000005'
-ddsub431 subtract 0 '-5E-5' -> '0.00005'
-ddsub432 subtract 0 '-5E-4' -> '0.0005'
-ddsub433 subtract 0 '-5E-1' -> '0.5'
-ddsub434 subtract 0 '-5E0' -> '5'
-ddsub435 subtract 0 '-5E1' -> '50'
-ddsub436 subtract 0 '-5E5' -> '500000'
-ddsub437 subtract 0 '-5E15' -> '5000000000000000'
-ddsub438 subtract 0 '-5E16' -> '5.000000000000000E+16' Rounded
-ddsub439 subtract 0 '-5E17' -> '5.000000000000000E+17' Rounded
-ddsub440 subtract 0 '-5E18' -> '5.000000000000000E+18' Rounded
-ddsub441 subtract 0 '-5E100' -> '5.000000000000000E+100' Rounded
-
-
--- try borderline precision, with carries, etc.
-ddsub461 subtract '1E+16' '1' -> '9999999999999999'
-ddsub462 subtract '1E+12' '-1.111' -> '1000000000001.111'
-ddsub463 subtract '1.111' '-1E+12' -> '1000000000001.111'
-ddsub464 subtract '-1' '-1E+16' -> '9999999999999999'
-ddsub465 subtract '7E+15' '1' -> '6999999999999999'
-ddsub466 subtract '7E+12' '-1.111' -> '7000000000001.111'
-ddsub467 subtract '1.111' '-7E+12' -> '7000000000001.111'
-ddsub468 subtract '-1' '-7E+15' -> '6999999999999999'
-
--- 1234567890123456 1234567890123456 1 23456789012345
-ddsub470 subtract '0.4444444444444444' '-0.5555555555555563' -> '1.000000000000001' Inexact Rounded
-ddsub471 subtract '0.4444444444444444' '-0.5555555555555562' -> '1.000000000000001' Inexact Rounded
-ddsub472 subtract '0.4444444444444444' '-0.5555555555555561' -> '1.000000000000000' Inexact Rounded
-ddsub473 subtract '0.4444444444444444' '-0.5555555555555560' -> '1.000000000000000' Inexact Rounded
-ddsub474 subtract '0.4444444444444444' '-0.5555555555555559' -> '1.000000000000000' Inexact Rounded
-ddsub475 subtract '0.4444444444444444' '-0.5555555555555558' -> '1.000000000000000' Inexact Rounded
-ddsub476 subtract '0.4444444444444444' '-0.5555555555555557' -> '1.000000000000000' Inexact Rounded
-ddsub477 subtract '0.4444444444444444' '-0.5555555555555556' -> '1.000000000000000' Rounded
-ddsub478 subtract '0.4444444444444444' '-0.5555555555555555' -> '0.9999999999999999'
-ddsub479 subtract '0.4444444444444444' '-0.5555555555555554' -> '0.9999999999999998'
-ddsub480 subtract '0.4444444444444444' '-0.5555555555555553' -> '0.9999999999999997'
-ddsub481 subtract '0.4444444444444444' '-0.5555555555555552' -> '0.9999999999999996'
-ddsub482 subtract '0.4444444444444444' '-0.5555555555555551' -> '0.9999999999999995'
-ddsub483 subtract '0.4444444444444444' '-0.5555555555555550' -> '0.9999999999999994'
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-ddsub500 subtract '1231234567456789' 0 -> '1231234567456789'
-ddsub501 subtract '1231234567456789' 0.000000001 -> '1231234567456789' Inexact Rounded
-ddsub502 subtract '1231234567456789' 0.000001 -> '1231234567456789' Inexact Rounded
-ddsub503 subtract '1231234567456789' 0.1 -> '1231234567456789' Inexact Rounded
-ddsub504 subtract '1231234567456789' 0.4 -> '1231234567456789' Inexact Rounded
-ddsub505 subtract '1231234567456789' 0.49 -> '1231234567456789' Inexact Rounded
-ddsub506 subtract '1231234567456789' 0.499999 -> '1231234567456789' Inexact Rounded
-ddsub507 subtract '1231234567456789' 0.499999999 -> '1231234567456789' Inexact Rounded
-ddsub508 subtract '1231234567456789' 0.5 -> '1231234567456789' Inexact Rounded
-ddsub509 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
-ddsub510 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
-ddsub511 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
-ddsub512 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
-ddsub513 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
-ddsub514 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
-ddsub515 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
-ddsub516 subtract '1231234567456789' 1 -> '1231234567456788'
-ddsub517 subtract '1231234567456789' 1.000000001 -> '1231234567456788' Inexact Rounded
-ddsub518 subtract '1231234567456789' 1.00001 -> '1231234567456788' Inexact Rounded
-ddsub519 subtract '1231234567456789' 1.1 -> '1231234567456788' Inexact Rounded
-
-rounding: half_even
-ddsub520 subtract '1231234567456789' 0 -> '1231234567456789'
-ddsub521 subtract '1231234567456789' 0.000000001 -> '1231234567456789' Inexact Rounded
-ddsub522 subtract '1231234567456789' 0.000001 -> '1231234567456789' Inexact Rounded
-ddsub523 subtract '1231234567456789' 0.1 -> '1231234567456789' Inexact Rounded
-ddsub524 subtract '1231234567456789' 0.4 -> '1231234567456789' Inexact Rounded
-ddsub525 subtract '1231234567456789' 0.49 -> '1231234567456789' Inexact Rounded
-ddsub526 subtract '1231234567456789' 0.499999 -> '1231234567456789' Inexact Rounded
-ddsub527 subtract '1231234567456789' 0.499999999 -> '1231234567456789' Inexact Rounded
-ddsub528 subtract '1231234567456789' 0.5 -> '1231234567456788' Inexact Rounded
-ddsub529 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
-ddsub530 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
-ddsub531 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
-ddsub532 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
-ddsub533 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
-ddsub534 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
-ddsub535 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
-ddsub536 subtract '1231234567456789' 1 -> '1231234567456788'
-ddsub537 subtract '1231234567456789' 1.00000001 -> '1231234567456788' Inexact Rounded
-ddsub538 subtract '1231234567456789' 1.00001 -> '1231234567456788' Inexact Rounded
-ddsub539 subtract '1231234567456789' 1.1 -> '1231234567456788' Inexact Rounded
--- critical few with even bottom digit...
-ddsub540 subtract '1231234567456788' 0.499999999 -> '1231234567456788' Inexact Rounded
-ddsub541 subtract '1231234567456788' 0.5 -> '1231234567456788' Inexact Rounded
-ddsub542 subtract '1231234567456788' 0.500000001 -> '1231234567456787' Inexact Rounded
-
-rounding: down
-ddsub550 subtract '1231234567456789' 0 -> '1231234567456789'
-ddsub551 subtract '1231234567456789' 0.000000001 -> '1231234567456788' Inexact Rounded
-ddsub552 subtract '1231234567456789' 0.000001 -> '1231234567456788' Inexact Rounded
-ddsub553 subtract '1231234567456789' 0.1 -> '1231234567456788' Inexact Rounded
-ddsub554 subtract '1231234567456789' 0.4 -> '1231234567456788' Inexact Rounded
-ddsub555 subtract '1231234567456789' 0.49 -> '1231234567456788' Inexact Rounded
-ddsub556 subtract '1231234567456789' 0.499999 -> '1231234567456788' Inexact Rounded
-ddsub557 subtract '1231234567456789' 0.499999999 -> '1231234567456788' Inexact Rounded
-ddsub558 subtract '1231234567456789' 0.5 -> '1231234567456788' Inexact Rounded
-ddsub559 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
-ddsub560 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
-ddsub561 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
-ddsub562 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
-ddsub563 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
-ddsub564 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
-ddsub565 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
-ddsub566 subtract '1231234567456789' 1 -> '1231234567456788'
-ddsub567 subtract '1231234567456789' 1.00000001 -> '1231234567456787' Inexact Rounded
-ddsub568 subtract '1231234567456789' 1.00001 -> '1231234567456787' Inexact Rounded
-ddsub569 subtract '1231234567456789' 1.1 -> '1231234567456787' Inexact Rounded
-
--- symmetry...
-rounding: half_up
-ddsub600 subtract 0 '1231234567456789' -> '-1231234567456789'
-ddsub601 subtract 0.000000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub602 subtract 0.000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub603 subtract 0.1 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub604 subtract 0.4 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub605 subtract 0.49 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub606 subtract 0.499999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub607 subtract 0.499999999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub608 subtract 0.5 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub609 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub610 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub611 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub612 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub613 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub614 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub615 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub616 subtract 1 '1231234567456789' -> '-1231234567456788'
-ddsub617 subtract 1.000000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub618 subtract 1.00001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub619 subtract 1.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-
-rounding: half_even
-ddsub620 subtract 0 '1231234567456789' -> '-1231234567456789'
-ddsub621 subtract 0.000000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub622 subtract 0.000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub623 subtract 0.1 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub624 subtract 0.4 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub625 subtract 0.49 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub626 subtract 0.499999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub627 subtract 0.499999999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub628 subtract 0.5 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub629 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub630 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub631 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub632 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub633 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub634 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub635 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub636 subtract 1 '1231234567456789' -> '-1231234567456788'
-ddsub637 subtract 1.00000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub638 subtract 1.00001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub639 subtract 1.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
--- critical few with even bottom digit...
-ddsub640 subtract 0.499999999 '1231234567456788' -> '-1231234567456788' Inexact Rounded
-ddsub641 subtract 0.5 '1231234567456788' -> '-1231234567456788' Inexact Rounded
-ddsub642 subtract 0.500000001 '1231234567456788' -> '-1231234567456787' Inexact Rounded
-
-rounding: down
-ddsub650 subtract 0 '1231234567456789' -> '-1231234567456789'
-ddsub651 subtract 0.000000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub652 subtract 0.000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub653 subtract 0.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub654 subtract 0.4 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub655 subtract 0.49 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub656 subtract 0.499999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub657 subtract 0.499999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub658 subtract 0.5 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub659 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub660 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub661 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub662 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub663 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub664 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub665 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub666 subtract 1 '1231234567456789' -> '-1231234567456788'
-ddsub667 subtract 1.00000001 '1231234567456789' -> '-1231234567456787' Inexact Rounded
-ddsub668 subtract 1.00001 '1231234567456789' -> '-1231234567456787' Inexact Rounded
-ddsub669 subtract 1.1 '1231234567456789' -> '-1231234567456787' Inexact Rounded
-
-
--- lots of leading zeros in intermediate result, and showing effects of
--- input rounding would have affected the following
-rounding: half_up
-ddsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
-ddsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
-ddsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
-ddsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
-ddsub674 subtract '1234567456789' '1234567456789.9' -> -0.9
-
-rounding: half_even
-ddsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
-ddsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
-ddsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
-ddsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
-ddsub684 subtract '1234567456789' '1234567456789.9' -> -0.9
-
-ddsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
-ddsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
-ddsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
-ddsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
-ddsub689 subtract '1234567456788' '1234567456788.9' -> -0.9
-
-rounding: down
-ddsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
-ddsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
-ddsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
-ddsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
-ddsub694 subtract '1234567456789' '1234567456789.9' -> -0.9
-
--- Specials
-ddsub780 subtract -Inf Inf -> -Infinity
-ddsub781 subtract -Inf 1000 -> -Infinity
-ddsub782 subtract -Inf 1 -> -Infinity
-ddsub783 subtract -Inf -0 -> -Infinity
-ddsub784 subtract -Inf -1 -> -Infinity
-ddsub785 subtract -Inf -1000 -> -Infinity
-ddsub787 subtract -1000 Inf -> -Infinity
-ddsub788 subtract -Inf Inf -> -Infinity
-ddsub789 subtract -1 Inf -> -Infinity
-ddsub790 subtract 0 Inf -> -Infinity
-ddsub791 subtract 1 Inf -> -Infinity
-ddsub792 subtract 1000 Inf -> -Infinity
-
-ddsub800 subtract Inf Inf -> NaN Invalid_operation
-ddsub801 subtract Inf 1000 -> Infinity
-ddsub802 subtract Inf 1 -> Infinity
-ddsub803 subtract Inf 0 -> Infinity
-ddsub804 subtract Inf -0 -> Infinity
-ddsub805 subtract Inf -1 -> Infinity
-ddsub806 subtract Inf -1000 -> Infinity
-ddsub807 subtract Inf -Inf -> Infinity
-ddsub808 subtract -1000 -Inf -> Infinity
-ddsub809 subtract -Inf -Inf -> NaN Invalid_operation
-ddsub810 subtract -1 -Inf -> Infinity
-ddsub811 subtract -0 -Inf -> Infinity
-ddsub812 subtract 0 -Inf -> Infinity
-ddsub813 subtract 1 -Inf -> Infinity
-ddsub814 subtract 1000 -Inf -> Infinity
-ddsub815 subtract Inf -Inf -> Infinity
-
-ddsub821 subtract NaN Inf -> NaN
-ddsub822 subtract -NaN 1000 -> -NaN
-ddsub823 subtract NaN 1 -> NaN
-ddsub824 subtract NaN 0 -> NaN
-ddsub825 subtract NaN -0 -> NaN
-ddsub826 subtract NaN -1 -> NaN
-ddsub827 subtract NaN -1000 -> NaN
-ddsub828 subtract NaN -Inf -> NaN
-ddsub829 subtract -NaN NaN -> -NaN
-ddsub830 subtract -Inf NaN -> NaN
-ddsub831 subtract -1000 NaN -> NaN
-ddsub832 subtract -1 NaN -> NaN
-ddsub833 subtract -0 NaN -> NaN
-ddsub834 subtract 0 NaN -> NaN
-ddsub835 subtract 1 NaN -> NaN
-ddsub836 subtract 1000 -NaN -> -NaN
-ddsub837 subtract Inf NaN -> NaN
-
-ddsub841 subtract sNaN Inf -> NaN Invalid_operation
-ddsub842 subtract -sNaN 1000 -> -NaN Invalid_operation
-ddsub843 subtract sNaN 1 -> NaN Invalid_operation
-ddsub844 subtract sNaN 0 -> NaN Invalid_operation
-ddsub845 subtract sNaN -0 -> NaN Invalid_operation
-ddsub846 subtract sNaN -1 -> NaN Invalid_operation
-ddsub847 subtract sNaN -1000 -> NaN Invalid_operation
-ddsub848 subtract sNaN NaN -> NaN Invalid_operation
-ddsub849 subtract sNaN sNaN -> NaN Invalid_operation
-ddsub850 subtract NaN sNaN -> NaN Invalid_operation
-ddsub851 subtract -Inf -sNaN -> -NaN Invalid_operation
-ddsub852 subtract -1000 sNaN -> NaN Invalid_operation
-ddsub853 subtract -1 sNaN -> NaN Invalid_operation
-ddsub854 subtract -0 sNaN -> NaN Invalid_operation
-ddsub855 subtract 0 sNaN -> NaN Invalid_operation
-ddsub856 subtract 1 sNaN -> NaN Invalid_operation
-ddsub857 subtract 1000 sNaN -> NaN Invalid_operation
-ddsub858 subtract Inf sNaN -> NaN Invalid_operation
-ddsub859 subtract NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddsub861 subtract NaN01 -Inf -> NaN1
-ddsub862 subtract -NaN02 -1000 -> -NaN2
-ddsub863 subtract NaN03 1000 -> NaN3
-ddsub864 subtract NaN04 Inf -> NaN4
-ddsub865 subtract NaN05 NaN61 -> NaN5
-ddsub866 subtract -Inf -NaN71 -> -NaN71
-ddsub867 subtract -1000 NaN81 -> NaN81
-ddsub868 subtract 1000 NaN91 -> NaN91
-ddsub869 subtract Inf NaN101 -> NaN101
-ddsub871 subtract sNaN011 -Inf -> NaN11 Invalid_operation
-ddsub872 subtract sNaN012 -1000 -> NaN12 Invalid_operation
-ddsub873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation
-ddsub874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation
-ddsub875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation
-ddsub876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation
-ddsub877 subtract -Inf sNaN201 -> NaN201 Invalid_operation
-ddsub878 subtract -1000 sNaN211 -> NaN211 Invalid_operation
-ddsub879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation
-ddsub880 subtract Inf sNaN231 -> NaN231 Invalid_operation
-ddsub881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- edge case spills
-ddsub901 subtract 2.E-3 1.002 -> -1.000
-ddsub902 subtract 2.0E-3 1.002 -> -1.0000
-ddsub903 subtract 2.00E-3 1.0020 -> -1.00000
-ddsub904 subtract 2.000E-3 1.00200 -> -1.000000
-ddsub905 subtract 2.0000E-3 1.002000 -> -1.0000000
-ddsub906 subtract 2.00000E-3 1.0020000 -> -1.00000000
-ddsub907 subtract 2.000000E-3 1.00200000 -> -1.000000000
-ddsub908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000
-
--- subnormals and overflows covered under Add
-
--- Null tests
-ddsub9990 subtract 10 # -> NaN Invalid_operation
-ddsub9991 subtract # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddSubtract.decTest -- decDouble subtraction --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decDoubles only; all arguments are
+-- representable in a decDouble
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+ddsub001 subtract 0 0 -> '0'
+ddsub002 subtract 1 1 -> '0'
+ddsub003 subtract 1 2 -> '-1'
+ddsub004 subtract 2 1 -> '1'
+ddsub005 subtract 2 2 -> '0'
+ddsub006 subtract 3 2 -> '1'
+ddsub007 subtract 2 3 -> '-1'
+
+ddsub011 subtract -0 0 -> '-0'
+ddsub012 subtract -1 1 -> '-2'
+ddsub013 subtract -1 2 -> '-3'
+ddsub014 subtract -2 1 -> '-3'
+ddsub015 subtract -2 2 -> '-4'
+ddsub016 subtract -3 2 -> '-5'
+ddsub017 subtract -2 3 -> '-5'
+
+ddsub021 subtract 0 -0 -> '0'
+ddsub022 subtract 1 -1 -> '2'
+ddsub023 subtract 1 -2 -> '3'
+ddsub024 subtract 2 -1 -> '3'
+ddsub025 subtract 2 -2 -> '4'
+ddsub026 subtract 3 -2 -> '5'
+ddsub027 subtract 2 -3 -> '5'
+
+ddsub030 subtract 11 1 -> 10
+ddsub031 subtract 10 1 -> 9
+ddsub032 subtract 9 1 -> 8
+ddsub033 subtract 1 1 -> 0
+ddsub034 subtract 0 1 -> -1
+ddsub035 subtract -1 1 -> -2
+ddsub036 subtract -9 1 -> -10
+ddsub037 subtract -10 1 -> -11
+ddsub038 subtract -11 1 -> -12
+
+ddsub040 subtract '5.75' '3.3' -> '2.45'
+ddsub041 subtract '5' '-3' -> '8'
+ddsub042 subtract '-5' '-3' -> '-2'
+ddsub043 subtract '-7' '2.5' -> '-9.5'
+ddsub044 subtract '0.7' '0.3' -> '0.4'
+ddsub045 subtract '1.3' '0.3' -> '1.0'
+ddsub046 subtract '1.25' '1.25' -> '0.00'
+
+ddsub050 subtract '1.23456789' '1.00000000' -> '0.23456789'
+ddsub051 subtract '1.23456789' '1.00000089' -> '0.23456700'
+
+ddsub060 subtract '70' '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
+ddsub061 subtract '700' '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
+ddsub062 subtract '7000' '10000e+16' -> '-9.999999999999999E+19' Inexact Rounded
+ddsub063 subtract '70000' '10000e+16' -> '-9.999999999999993E+19' Rounded
+ddsub064 subtract '700000' '10000e+16' -> '-9.999999999999930E+19' Rounded
+ -- symmetry:
+ddsub065 subtract '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
+ddsub066 subtract '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
+ddsub067 subtract '10000e+16' '7000' -> '9.999999999999999E+19' Inexact Rounded
+ddsub068 subtract '10000e+16' '70000' -> '9.999999999999993E+19' Rounded
+ddsub069 subtract '10000e+16' '700000' -> '9.999999999999930E+19' Rounded
+
+ -- some of the next group are really constructor tests
+ddsub090 subtract '00.0' '0.0' -> '0.0'
+ddsub091 subtract '00.0' '0.00' -> '0.00'
+ddsub092 subtract '0.00' '00.0' -> '0.00'
+ddsub093 subtract '00.0' '0.00' -> '0.00'
+ddsub094 subtract '0.00' '00.0' -> '0.00'
+ddsub095 subtract '3' '.3' -> '2.7'
+ddsub096 subtract '3.' '.3' -> '2.7'
+ddsub097 subtract '3.0' '.3' -> '2.7'
+ddsub098 subtract '3.00' '.3' -> '2.70'
+ddsub099 subtract '3' '3' -> '0'
+ddsub100 subtract '3' '+3' -> '0'
+ddsub101 subtract '3' '-3' -> '6'
+ddsub102 subtract '3' '0.3' -> '2.7'
+ddsub103 subtract '3.' '0.3' -> '2.7'
+ddsub104 subtract '3.0' '0.3' -> '2.7'
+ddsub105 subtract '3.00' '0.3' -> '2.70'
+ddsub106 subtract '3' '3.0' -> '0.0'
+ddsub107 subtract '3' '+3.0' -> '0.0'
+ddsub108 subtract '3' '-3.0' -> '6.0'
+
+-- the above all from add; massaged and extended. Now some new ones...
+-- [particularly important for comparisons]
+-- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
+-- with input rounding.
+ddsub120 subtract '10.23456784' '10.23456789' -> '-5E-8'
+ddsub121 subtract '10.23456785' '10.23456789' -> '-4E-8'
+ddsub122 subtract '10.23456786' '10.23456789' -> '-3E-8'
+ddsub123 subtract '10.23456787' '10.23456789' -> '-2E-8'
+ddsub124 subtract '10.23456788' '10.23456789' -> '-1E-8'
+ddsub125 subtract '10.23456789' '10.23456789' -> '0E-8'
+ddsub126 subtract '10.23456790' '10.23456789' -> '1E-8'
+ddsub127 subtract '10.23456791' '10.23456789' -> '2E-8'
+ddsub128 subtract '10.23456792' '10.23456789' -> '3E-8'
+ddsub129 subtract '10.23456793' '10.23456789' -> '4E-8'
+ddsub130 subtract '10.23456794' '10.23456789' -> '5E-8'
+ddsub131 subtract '10.23456781' '10.23456786' -> '-5E-8'
+ddsub132 subtract '10.23456782' '10.23456786' -> '-4E-8'
+ddsub133 subtract '10.23456783' '10.23456786' -> '-3E-8'
+ddsub134 subtract '10.23456784' '10.23456786' -> '-2E-8'
+ddsub135 subtract '10.23456785' '10.23456786' -> '-1E-8'
+ddsub136 subtract '10.23456786' '10.23456786' -> '0E-8'
+ddsub137 subtract '10.23456787' '10.23456786' -> '1E-8'
+ddsub138 subtract '10.23456788' '10.23456786' -> '2E-8'
+ddsub139 subtract '10.23456789' '10.23456786' -> '3E-8'
+ddsub140 subtract '10.23456790' '10.23456786' -> '4E-8'
+ddsub141 subtract '10.23456791' '10.23456786' -> '5E-8'
+ddsub142 subtract '1' '0.999999999' -> '1E-9'
+ddsub143 subtract '0.999999999' '1' -> '-1E-9'
+ddsub144 subtract '-10.23456780' '-10.23456786' -> '6E-8'
+ddsub145 subtract '-10.23456790' '-10.23456786' -> '-4E-8'
+ddsub146 subtract '-10.23456791' '-10.23456786' -> '-5E-8'
+
+-- additional scaled arithmetic tests [0.97 problem]
+ddsub160 subtract '0' '.1' -> '-0.1'
+ddsub161 subtract '00' '.97983' -> '-0.97983'
+ddsub162 subtract '0' '.9' -> '-0.9'
+ddsub163 subtract '0' '0.102' -> '-0.102'
+ddsub164 subtract '0' '.4' -> '-0.4'
+ddsub165 subtract '0' '.307' -> '-0.307'
+ddsub166 subtract '0' '.43822' -> '-0.43822'
+ddsub167 subtract '0' '.911' -> '-0.911'
+ddsub168 subtract '.0' '.02' -> '-0.02'
+ddsub169 subtract '00' '.392' -> '-0.392'
+ddsub170 subtract '0' '.26' -> '-0.26'
+ddsub171 subtract '0' '0.51' -> '-0.51'
+ddsub172 subtract '0' '.2234' -> '-0.2234'
+ddsub173 subtract '0' '.2' -> '-0.2'
+ddsub174 subtract '.0' '.0008' -> '-0.0008'
+-- 0. on left
+ddsub180 subtract '0.0' '-.1' -> '0.1'
+ddsub181 subtract '0.00' '-.97983' -> '0.97983'
+ddsub182 subtract '0.0' '-.9' -> '0.9'
+ddsub183 subtract '0.0' '-0.102' -> '0.102'
+ddsub184 subtract '0.0' '-.4' -> '0.4'
+ddsub185 subtract '0.0' '-.307' -> '0.307'
+ddsub186 subtract '0.0' '-.43822' -> '0.43822'
+ddsub187 subtract '0.0' '-.911' -> '0.911'
+ddsub188 subtract '0.0' '-.02' -> '0.02'
+ddsub189 subtract '0.00' '-.392' -> '0.392'
+ddsub190 subtract '0.0' '-.26' -> '0.26'
+ddsub191 subtract '0.0' '-0.51' -> '0.51'
+ddsub192 subtract '0.0' '-.2234' -> '0.2234'
+ddsub193 subtract '0.0' '-.2' -> '0.2'
+ddsub194 subtract '0.0' '-.0008' -> '0.0008'
+-- negatives of same
+ddsub200 subtract '0' '-.1' -> '0.1'
+ddsub201 subtract '00' '-.97983' -> '0.97983'
+ddsub202 subtract '0' '-.9' -> '0.9'
+ddsub203 subtract '0' '-0.102' -> '0.102'
+ddsub204 subtract '0' '-.4' -> '0.4'
+ddsub205 subtract '0' '-.307' -> '0.307'
+ddsub206 subtract '0' '-.43822' -> '0.43822'
+ddsub207 subtract '0' '-.911' -> '0.911'
+ddsub208 subtract '.0' '-.02' -> '0.02'
+ddsub209 subtract '00' '-.392' -> '0.392'
+ddsub210 subtract '0' '-.26' -> '0.26'
+ddsub211 subtract '0' '-0.51' -> '0.51'
+ddsub212 subtract '0' '-.2234' -> '0.2234'
+ddsub213 subtract '0' '-.2' -> '0.2'
+ddsub214 subtract '.0' '-.0008' -> '0.0008'
+
+-- more fixed, LHS swaps [really the same as testcases under add]
+ddsub220 subtract '-56267E-12' 0 -> '-5.6267E-8'
+ddsub221 subtract '-56267E-11' 0 -> '-5.6267E-7'
+ddsub222 subtract '-56267E-10' 0 -> '-0.0000056267'
+ddsub223 subtract '-56267E-9' 0 -> '-0.000056267'
+ddsub224 subtract '-56267E-8' 0 -> '-0.00056267'
+ddsub225 subtract '-56267E-7' 0 -> '-0.0056267'
+ddsub226 subtract '-56267E-6' 0 -> '-0.056267'
+ddsub227 subtract '-56267E-5' 0 -> '-0.56267'
+ddsub228 subtract '-56267E-2' 0 -> '-562.67'
+ddsub229 subtract '-56267E-1' 0 -> '-5626.7'
+ddsub230 subtract '-56267E-0' 0 -> '-56267'
+-- symmetry ...
+ddsub240 subtract 0 '-56267E-12' -> '5.6267E-8'
+ddsub241 subtract 0 '-56267E-11' -> '5.6267E-7'
+ddsub242 subtract 0 '-56267E-10' -> '0.0000056267'
+ddsub243 subtract 0 '-56267E-9' -> '0.000056267'
+ddsub244 subtract 0 '-56267E-8' -> '0.00056267'
+ddsub245 subtract 0 '-56267E-7' -> '0.0056267'
+ddsub246 subtract 0 '-56267E-6' -> '0.056267'
+ddsub247 subtract 0 '-56267E-5' -> '0.56267'
+ddsub248 subtract 0 '-56267E-2' -> '562.67'
+ddsub249 subtract 0 '-56267E-1' -> '5626.7'
+ddsub250 subtract 0 '-56267E-0' -> '56267'
+
+-- now some more from the 'new' add
+ddsub301 subtract '1.23456789' '1.00000000' -> '0.23456789'
+ddsub302 subtract '1.23456789' '1.00000011' -> '0.23456778'
+
+-- some carrying effects
+ddsub321 subtract '0.9998' '0.0000' -> '0.9998'
+ddsub322 subtract '0.9998' '0.0001' -> '0.9997'
+ddsub323 subtract '0.9998' '0.0002' -> '0.9996'
+ddsub324 subtract '0.9998' '0.0003' -> '0.9995'
+ddsub325 subtract '0.9998' '-0.0000' -> '0.9998'
+ddsub326 subtract '0.9998' '-0.0001' -> '0.9999'
+ddsub327 subtract '0.9998' '-0.0002' -> '1.0000'
+ddsub328 subtract '0.9998' '-0.0003' -> '1.0001'
+
+-- internal boundaries
+ddsub346 subtract '10000e+9' '7' -> '9999999999993'
+ddsub347 subtract '10000e+9' '70' -> '9999999999930'
+ddsub348 subtract '10000e+9' '700' -> '9999999999300'
+ddsub349 subtract '10000e+9' '7000' -> '9999999993000'
+ddsub350 subtract '10000e+9' '70000' -> '9999999930000'
+ddsub351 subtract '10000e+9' '700000' -> '9999999300000'
+ddsub352 subtract '7' '10000e+9' -> '-9999999999993'
+ddsub353 subtract '70' '10000e+9' -> '-9999999999930'
+ddsub354 subtract '700' '10000e+9' -> '-9999999999300'
+ddsub355 subtract '7000' '10000e+9' -> '-9999999993000'
+ddsub356 subtract '70000' '10000e+9' -> '-9999999930000'
+ddsub357 subtract '700000' '10000e+9' -> '-9999999300000'
+
+-- zero preservation
+ddsub361 subtract 1 '0.0001' -> '0.9999'
+ddsub362 subtract 1 '0.00001' -> '0.99999'
+ddsub363 subtract 1 '0.000001' -> '0.999999'
+ddsub364 subtract 1 '0.0000000000000001' -> '0.9999999999999999'
+ddsub365 subtract 1 '0.00000000000000001' -> '1.000000000000000' Inexact Rounded
+ddsub366 subtract 1 '0.000000000000000001' -> '1.000000000000000' Inexact Rounded
+
+-- some funny zeros [in case of bad signum]
+ddsub370 subtract 1 0 -> 1
+ddsub371 subtract 1 0. -> 1
+ddsub372 subtract 1 .0 -> 1.0
+ddsub373 subtract 1 0.0 -> 1.0
+ddsub374 subtract 0 1 -> -1
+ddsub375 subtract 0. 1 -> -1
+ddsub376 subtract .0 1 -> -1.0
+ddsub377 subtract 0.0 1 -> -1.0
+
+-- leading 0 digit before round
+ddsub910 subtract -103519362 -51897955.3 -> -51621406.7
+ddsub911 subtract 159579.444 89827.5229 -> 69751.9211
+
+ddsub920 subtract 333.0000000123456 33.00000001234566 -> 299.9999999999999 Inexact Rounded
+ddsub921 subtract 333.0000000123456 33.00000001234565 -> 300.0000000000000 Inexact Rounded
+ddsub922 subtract 133.0000000123456 33.00000001234565 -> 99.99999999999995
+ddsub923 subtract 133.0000000123456 33.00000001234564 -> 99.99999999999996
+ddsub924 subtract 133.0000000123456 33.00000001234540 -> 100.0000000000002 Rounded
+ddsub925 subtract 133.0000000123456 43.00000001234560 -> 90.00000000000000
+ddsub926 subtract 133.0000000123456 43.00000001234561 -> 89.99999999999999
+ddsub927 subtract 133.0000000123456 43.00000001234566 -> 89.99999999999994
+ddsub928 subtract 101.0000000123456 91.00000001234566 -> 9.99999999999994
+ddsub929 subtract 101.0000000123456 99.00000001234566 -> 1.99999999999994
+
+-- more LHS swaps [were fixed]
+ddsub390 subtract '-56267E-10' 0 -> '-0.0000056267'
+ddsub391 subtract '-56267E-6' 0 -> '-0.056267'
+ddsub392 subtract '-56267E-5' 0 -> '-0.56267'
+ddsub393 subtract '-56267E-4' 0 -> '-5.6267'
+ddsub394 subtract '-56267E-3' 0 -> '-56.267'
+ddsub395 subtract '-56267E-2' 0 -> '-562.67'
+ddsub396 subtract '-56267E-1' 0 -> '-5626.7'
+ddsub397 subtract '-56267E-0' 0 -> '-56267'
+ddsub398 subtract '-5E-10' 0 -> '-5E-10'
+ddsub399 subtract '-5E-7' 0 -> '-5E-7'
+ddsub400 subtract '-5E-6' 0 -> '-0.000005'
+ddsub401 subtract '-5E-5' 0 -> '-0.00005'
+ddsub402 subtract '-5E-4' 0 -> '-0.0005'
+ddsub403 subtract '-5E-1' 0 -> '-0.5'
+ddsub404 subtract '-5E0' 0 -> '-5'
+ddsub405 subtract '-5E1' 0 -> '-50'
+ddsub406 subtract '-5E5' 0 -> '-500000'
+ddsub407 subtract '-5E15' 0 -> '-5000000000000000'
+ddsub408 subtract '-5E16' 0 -> '-5.000000000000000E+16' Rounded
+ddsub409 subtract '-5E17' 0 -> '-5.000000000000000E+17' Rounded
+ddsub410 subtract '-5E18' 0 -> '-5.000000000000000E+18' Rounded
+ddsub411 subtract '-5E100' 0 -> '-5.000000000000000E+100' Rounded
+
+-- more RHS swaps [were fixed]
+ddsub420 subtract 0 '-56267E-10' -> '0.0000056267'
+ddsub421 subtract 0 '-56267E-6' -> '0.056267'
+ddsub422 subtract 0 '-56267E-5' -> '0.56267'
+ddsub423 subtract 0 '-56267E-4' -> '5.6267'
+ddsub424 subtract 0 '-56267E-3' -> '56.267'
+ddsub425 subtract 0 '-56267E-2' -> '562.67'
+ddsub426 subtract 0 '-56267E-1' -> '5626.7'
+ddsub427 subtract 0 '-56267E-0' -> '56267'
+ddsub428 subtract 0 '-5E-10' -> '5E-10'
+ddsub429 subtract 0 '-5E-7' -> '5E-7'
+ddsub430 subtract 0 '-5E-6' -> '0.000005'
+ddsub431 subtract 0 '-5E-5' -> '0.00005'
+ddsub432 subtract 0 '-5E-4' -> '0.0005'
+ddsub433 subtract 0 '-5E-1' -> '0.5'
+ddsub434 subtract 0 '-5E0' -> '5'
+ddsub435 subtract 0 '-5E1' -> '50'
+ddsub436 subtract 0 '-5E5' -> '500000'
+ddsub437 subtract 0 '-5E15' -> '5000000000000000'
+ddsub438 subtract 0 '-5E16' -> '5.000000000000000E+16' Rounded
+ddsub439 subtract 0 '-5E17' -> '5.000000000000000E+17' Rounded
+ddsub440 subtract 0 '-5E18' -> '5.000000000000000E+18' Rounded
+ddsub441 subtract 0 '-5E100' -> '5.000000000000000E+100' Rounded
+
+
+-- try borderline precision, with carries, etc.
+ddsub461 subtract '1E+16' '1' -> '9999999999999999'
+ddsub462 subtract '1E+12' '-1.111' -> '1000000000001.111'
+ddsub463 subtract '1.111' '-1E+12' -> '1000000000001.111'
+ddsub464 subtract '-1' '-1E+16' -> '9999999999999999'
+ddsub465 subtract '7E+15' '1' -> '6999999999999999'
+ddsub466 subtract '7E+12' '-1.111' -> '7000000000001.111'
+ddsub467 subtract '1.111' '-7E+12' -> '7000000000001.111'
+ddsub468 subtract '-1' '-7E+15' -> '6999999999999999'
+
+-- 1234567890123456 1234567890123456 1 23456789012345
+ddsub470 subtract '0.4444444444444444' '-0.5555555555555563' -> '1.000000000000001' Inexact Rounded
+ddsub471 subtract '0.4444444444444444' '-0.5555555555555562' -> '1.000000000000001' Inexact Rounded
+ddsub472 subtract '0.4444444444444444' '-0.5555555555555561' -> '1.000000000000000' Inexact Rounded
+ddsub473 subtract '0.4444444444444444' '-0.5555555555555560' -> '1.000000000000000' Inexact Rounded
+ddsub474 subtract '0.4444444444444444' '-0.5555555555555559' -> '1.000000000000000' Inexact Rounded
+ddsub475 subtract '0.4444444444444444' '-0.5555555555555558' -> '1.000000000000000' Inexact Rounded
+ddsub476 subtract '0.4444444444444444' '-0.5555555555555557' -> '1.000000000000000' Inexact Rounded
+ddsub477 subtract '0.4444444444444444' '-0.5555555555555556' -> '1.000000000000000' Rounded
+ddsub478 subtract '0.4444444444444444' '-0.5555555555555555' -> '0.9999999999999999'
+ddsub479 subtract '0.4444444444444444' '-0.5555555555555554' -> '0.9999999999999998'
+ddsub480 subtract '0.4444444444444444' '-0.5555555555555553' -> '0.9999999999999997'
+ddsub481 subtract '0.4444444444444444' '-0.5555555555555552' -> '0.9999999999999996'
+ddsub482 subtract '0.4444444444444444' '-0.5555555555555551' -> '0.9999999999999995'
+ddsub483 subtract '0.4444444444444444' '-0.5555555555555550' -> '0.9999999999999994'
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+ddsub500 subtract '1231234567456789' 0 -> '1231234567456789'
+ddsub501 subtract '1231234567456789' 0.000000001 -> '1231234567456789' Inexact Rounded
+ddsub502 subtract '1231234567456789' 0.000001 -> '1231234567456789' Inexact Rounded
+ddsub503 subtract '1231234567456789' 0.1 -> '1231234567456789' Inexact Rounded
+ddsub504 subtract '1231234567456789' 0.4 -> '1231234567456789' Inexact Rounded
+ddsub505 subtract '1231234567456789' 0.49 -> '1231234567456789' Inexact Rounded
+ddsub506 subtract '1231234567456789' 0.499999 -> '1231234567456789' Inexact Rounded
+ddsub507 subtract '1231234567456789' 0.499999999 -> '1231234567456789' Inexact Rounded
+ddsub508 subtract '1231234567456789' 0.5 -> '1231234567456789' Inexact Rounded
+ddsub509 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
+ddsub510 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
+ddsub511 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
+ddsub512 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
+ddsub513 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
+ddsub514 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
+ddsub515 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
+ddsub516 subtract '1231234567456789' 1 -> '1231234567456788'
+ddsub517 subtract '1231234567456789' 1.000000001 -> '1231234567456788' Inexact Rounded
+ddsub518 subtract '1231234567456789' 1.00001 -> '1231234567456788' Inexact Rounded
+ddsub519 subtract '1231234567456789' 1.1 -> '1231234567456788' Inexact Rounded
+
+rounding: half_even
+ddsub520 subtract '1231234567456789' 0 -> '1231234567456789'
+ddsub521 subtract '1231234567456789' 0.000000001 -> '1231234567456789' Inexact Rounded
+ddsub522 subtract '1231234567456789' 0.000001 -> '1231234567456789' Inexact Rounded
+ddsub523 subtract '1231234567456789' 0.1 -> '1231234567456789' Inexact Rounded
+ddsub524 subtract '1231234567456789' 0.4 -> '1231234567456789' Inexact Rounded
+ddsub525 subtract '1231234567456789' 0.49 -> '1231234567456789' Inexact Rounded
+ddsub526 subtract '1231234567456789' 0.499999 -> '1231234567456789' Inexact Rounded
+ddsub527 subtract '1231234567456789' 0.499999999 -> '1231234567456789' Inexact Rounded
+ddsub528 subtract '1231234567456789' 0.5 -> '1231234567456788' Inexact Rounded
+ddsub529 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
+ddsub530 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
+ddsub531 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
+ddsub532 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
+ddsub533 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
+ddsub534 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
+ddsub535 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
+ddsub536 subtract '1231234567456789' 1 -> '1231234567456788'
+ddsub537 subtract '1231234567456789' 1.00000001 -> '1231234567456788' Inexact Rounded
+ddsub538 subtract '1231234567456789' 1.00001 -> '1231234567456788' Inexact Rounded
+ddsub539 subtract '1231234567456789' 1.1 -> '1231234567456788' Inexact Rounded
+-- critical few with even bottom digit...
+ddsub540 subtract '1231234567456788' 0.499999999 -> '1231234567456788' Inexact Rounded
+ddsub541 subtract '1231234567456788' 0.5 -> '1231234567456788' Inexact Rounded
+ddsub542 subtract '1231234567456788' 0.500000001 -> '1231234567456787' Inexact Rounded
+
+rounding: down
+ddsub550 subtract '1231234567456789' 0 -> '1231234567456789'
+ddsub551 subtract '1231234567456789' 0.000000001 -> '1231234567456788' Inexact Rounded
+ddsub552 subtract '1231234567456789' 0.000001 -> '1231234567456788' Inexact Rounded
+ddsub553 subtract '1231234567456789' 0.1 -> '1231234567456788' Inexact Rounded
+ddsub554 subtract '1231234567456789' 0.4 -> '1231234567456788' Inexact Rounded
+ddsub555 subtract '1231234567456789' 0.49 -> '1231234567456788' Inexact Rounded
+ddsub556 subtract '1231234567456789' 0.499999 -> '1231234567456788' Inexact Rounded
+ddsub557 subtract '1231234567456789' 0.499999999 -> '1231234567456788' Inexact Rounded
+ddsub558 subtract '1231234567456789' 0.5 -> '1231234567456788' Inexact Rounded
+ddsub559 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
+ddsub560 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
+ddsub561 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
+ddsub562 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
+ddsub563 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
+ddsub564 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
+ddsub565 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
+ddsub566 subtract '1231234567456789' 1 -> '1231234567456788'
+ddsub567 subtract '1231234567456789' 1.00000001 -> '1231234567456787' Inexact Rounded
+ddsub568 subtract '1231234567456789' 1.00001 -> '1231234567456787' Inexact Rounded
+ddsub569 subtract '1231234567456789' 1.1 -> '1231234567456787' Inexact Rounded
+
+-- symmetry...
+rounding: half_up
+ddsub600 subtract 0 '1231234567456789' -> '-1231234567456789'
+ddsub601 subtract 0.000000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub602 subtract 0.000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub603 subtract 0.1 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub604 subtract 0.4 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub605 subtract 0.49 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub606 subtract 0.499999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub607 subtract 0.499999999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub608 subtract 0.5 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub609 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub610 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub611 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub612 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub613 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub614 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub615 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub616 subtract 1 '1231234567456789' -> '-1231234567456788'
+ddsub617 subtract 1.000000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub618 subtract 1.00001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub619 subtract 1.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+
+rounding: half_even
+ddsub620 subtract 0 '1231234567456789' -> '-1231234567456789'
+ddsub621 subtract 0.000000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub622 subtract 0.000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub623 subtract 0.1 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub624 subtract 0.4 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub625 subtract 0.49 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub626 subtract 0.499999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub627 subtract 0.499999999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub628 subtract 0.5 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub629 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub630 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub631 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub632 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub633 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub634 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub635 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub636 subtract 1 '1231234567456789' -> '-1231234567456788'
+ddsub637 subtract 1.00000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub638 subtract 1.00001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub639 subtract 1.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+-- critical few with even bottom digit...
+ddsub640 subtract 0.499999999 '1231234567456788' -> '-1231234567456788' Inexact Rounded
+ddsub641 subtract 0.5 '1231234567456788' -> '-1231234567456788' Inexact Rounded
+ddsub642 subtract 0.500000001 '1231234567456788' -> '-1231234567456787' Inexact Rounded
+
+rounding: down
+ddsub650 subtract 0 '1231234567456789' -> '-1231234567456789'
+ddsub651 subtract 0.000000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub652 subtract 0.000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub653 subtract 0.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub654 subtract 0.4 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub655 subtract 0.49 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub656 subtract 0.499999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub657 subtract 0.499999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub658 subtract 0.5 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub659 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub660 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub661 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub662 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub663 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub664 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub665 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub666 subtract 1 '1231234567456789' -> '-1231234567456788'
+ddsub667 subtract 1.00000001 '1231234567456789' -> '-1231234567456787' Inexact Rounded
+ddsub668 subtract 1.00001 '1231234567456789' -> '-1231234567456787' Inexact Rounded
+ddsub669 subtract 1.1 '1231234567456789' -> '-1231234567456787' Inexact Rounded
+
+
+-- lots of leading zeros in intermediate result, and showing effects of
+-- input rounding would have affected the following
+rounding: half_up
+ddsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
+ddsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
+ddsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
+ddsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
+ddsub674 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+rounding: half_even
+ddsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
+ddsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
+ddsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
+ddsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
+ddsub684 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+ddsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
+ddsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
+ddsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
+ddsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
+ddsub689 subtract '1234567456788' '1234567456788.9' -> -0.9
+
+rounding: down
+ddsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
+ddsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
+ddsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
+ddsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
+ddsub694 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+-- Specials
+ddsub780 subtract -Inf Inf -> -Infinity
+ddsub781 subtract -Inf 1000 -> -Infinity
+ddsub782 subtract -Inf 1 -> -Infinity
+ddsub783 subtract -Inf -0 -> -Infinity
+ddsub784 subtract -Inf -1 -> -Infinity
+ddsub785 subtract -Inf -1000 -> -Infinity
+ddsub787 subtract -1000 Inf -> -Infinity
+ddsub788 subtract -Inf Inf -> -Infinity
+ddsub789 subtract -1 Inf -> -Infinity
+ddsub790 subtract 0 Inf -> -Infinity
+ddsub791 subtract 1 Inf -> -Infinity
+ddsub792 subtract 1000 Inf -> -Infinity
+
+ddsub800 subtract Inf Inf -> NaN Invalid_operation
+ddsub801 subtract Inf 1000 -> Infinity
+ddsub802 subtract Inf 1 -> Infinity
+ddsub803 subtract Inf 0 -> Infinity
+ddsub804 subtract Inf -0 -> Infinity
+ddsub805 subtract Inf -1 -> Infinity
+ddsub806 subtract Inf -1000 -> Infinity
+ddsub807 subtract Inf -Inf -> Infinity
+ddsub808 subtract -1000 -Inf -> Infinity
+ddsub809 subtract -Inf -Inf -> NaN Invalid_operation
+ddsub810 subtract -1 -Inf -> Infinity
+ddsub811 subtract -0 -Inf -> Infinity
+ddsub812 subtract 0 -Inf -> Infinity
+ddsub813 subtract 1 -Inf -> Infinity
+ddsub814 subtract 1000 -Inf -> Infinity
+ddsub815 subtract Inf -Inf -> Infinity
+
+ddsub821 subtract NaN Inf -> NaN
+ddsub822 subtract -NaN 1000 -> -NaN
+ddsub823 subtract NaN 1 -> NaN
+ddsub824 subtract NaN 0 -> NaN
+ddsub825 subtract NaN -0 -> NaN
+ddsub826 subtract NaN -1 -> NaN
+ddsub827 subtract NaN -1000 -> NaN
+ddsub828 subtract NaN -Inf -> NaN
+ddsub829 subtract -NaN NaN -> -NaN
+ddsub830 subtract -Inf NaN -> NaN
+ddsub831 subtract -1000 NaN -> NaN
+ddsub832 subtract -1 NaN -> NaN
+ddsub833 subtract -0 NaN -> NaN
+ddsub834 subtract 0 NaN -> NaN
+ddsub835 subtract 1 NaN -> NaN
+ddsub836 subtract 1000 -NaN -> -NaN
+ddsub837 subtract Inf NaN -> NaN
+
+ddsub841 subtract sNaN Inf -> NaN Invalid_operation
+ddsub842 subtract -sNaN 1000 -> -NaN Invalid_operation
+ddsub843 subtract sNaN 1 -> NaN Invalid_operation
+ddsub844 subtract sNaN 0 -> NaN Invalid_operation
+ddsub845 subtract sNaN -0 -> NaN Invalid_operation
+ddsub846 subtract sNaN -1 -> NaN Invalid_operation
+ddsub847 subtract sNaN -1000 -> NaN Invalid_operation
+ddsub848 subtract sNaN NaN -> NaN Invalid_operation
+ddsub849 subtract sNaN sNaN -> NaN Invalid_operation
+ddsub850 subtract NaN sNaN -> NaN Invalid_operation
+ddsub851 subtract -Inf -sNaN -> -NaN Invalid_operation
+ddsub852 subtract -1000 sNaN -> NaN Invalid_operation
+ddsub853 subtract -1 sNaN -> NaN Invalid_operation
+ddsub854 subtract -0 sNaN -> NaN Invalid_operation
+ddsub855 subtract 0 sNaN -> NaN Invalid_operation
+ddsub856 subtract 1 sNaN -> NaN Invalid_operation
+ddsub857 subtract 1000 sNaN -> NaN Invalid_operation
+ddsub858 subtract Inf sNaN -> NaN Invalid_operation
+ddsub859 subtract NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddsub861 subtract NaN01 -Inf -> NaN1
+ddsub862 subtract -NaN02 -1000 -> -NaN2
+ddsub863 subtract NaN03 1000 -> NaN3
+ddsub864 subtract NaN04 Inf -> NaN4
+ddsub865 subtract NaN05 NaN61 -> NaN5
+ddsub866 subtract -Inf -NaN71 -> -NaN71
+ddsub867 subtract -1000 NaN81 -> NaN81
+ddsub868 subtract 1000 NaN91 -> NaN91
+ddsub869 subtract Inf NaN101 -> NaN101
+ddsub871 subtract sNaN011 -Inf -> NaN11 Invalid_operation
+ddsub872 subtract sNaN012 -1000 -> NaN12 Invalid_operation
+ddsub873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation
+ddsub874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation
+ddsub875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation
+ddsub876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation
+ddsub877 subtract -Inf sNaN201 -> NaN201 Invalid_operation
+ddsub878 subtract -1000 sNaN211 -> NaN211 Invalid_operation
+ddsub879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation
+ddsub880 subtract Inf sNaN231 -> NaN231 Invalid_operation
+ddsub881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- edge case spills
+ddsub901 subtract 2.E-3 1.002 -> -1.000
+ddsub902 subtract 2.0E-3 1.002 -> -1.0000
+ddsub903 subtract 2.00E-3 1.0020 -> -1.00000
+ddsub904 subtract 2.000E-3 1.00200 -> -1.000000
+ddsub905 subtract 2.0000E-3 1.002000 -> -1.0000000
+ddsub906 subtract 2.00000E-3 1.0020000 -> -1.00000000
+ddsub907 subtract 2.000000E-3 1.00200000 -> -1.000000000
+ddsub908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000
+
+-- subnormals and overflows covered under Add
+
+-- Null tests
+ddsub9990 subtract 10 # -> NaN Invalid_operation
+ddsub9991 subtract # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddToIntegral.decTest b/Lib/test/decimaltestdata/ddToIntegral.decTest
index bf6d61fa56..900bd4ac3a 100644
--- a/Lib/test/decimaltestdata/ddToIntegral.decTest
+++ b/Lib/test/decimaltestdata/ddToIntegral.decTest
@@ -1,257 +1,257 @@
-------------------------------------------------------------------------
--- ddToIntegral.decTest -- round Double to integral value --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests tests the extended specification 'round-to-integral
--- value-exact' operations (from IEEE 854, later modified in 754r).
--- All non-zero results are defined as being those from either copy or
--- quantize, so those are assumed to have been tested extensively
--- elsewhere; the tests here are for integrity, rounding mode, etc.
--- Also, it is assumed the test harness will use these tests for both
--- ToIntegralExact (which does set Inexact) and the fixed-name
--- functions (which do not set Inexact).
-
--- Note that decNumber implements an earlier definition of toIntegral
--- which never sets Inexact; the decTest operator for that is called
--- 'tointegral' instead of 'tointegralx'.
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddintx001 tointegralx 0 -> 0
-ddintx002 tointegralx 0.0 -> 0
-ddintx003 tointegralx 0.1 -> 0 Inexact Rounded
-ddintx004 tointegralx 0.2 -> 0 Inexact Rounded
-ddintx005 tointegralx 0.3 -> 0 Inexact Rounded
-ddintx006 tointegralx 0.4 -> 0 Inexact Rounded
-ddintx007 tointegralx 0.5 -> 0 Inexact Rounded
-ddintx008 tointegralx 0.6 -> 1 Inexact Rounded
-ddintx009 tointegralx 0.7 -> 1 Inexact Rounded
-ddintx010 tointegralx 0.8 -> 1 Inexact Rounded
-ddintx011 tointegralx 0.9 -> 1 Inexact Rounded
-ddintx012 tointegralx 1 -> 1
-ddintx013 tointegralx 1.0 -> 1 Rounded
-ddintx014 tointegralx 1.1 -> 1 Inexact Rounded
-ddintx015 tointegralx 1.2 -> 1 Inexact Rounded
-ddintx016 tointegralx 1.3 -> 1 Inexact Rounded
-ddintx017 tointegralx 1.4 -> 1 Inexact Rounded
-ddintx018 tointegralx 1.5 -> 2 Inexact Rounded
-ddintx019 tointegralx 1.6 -> 2 Inexact Rounded
-ddintx020 tointegralx 1.7 -> 2 Inexact Rounded
-ddintx021 tointegralx 1.8 -> 2 Inexact Rounded
-ddintx022 tointegralx 1.9 -> 2 Inexact Rounded
--- negatives
-ddintx031 tointegralx -0 -> -0
-ddintx032 tointegralx -0.0 -> -0
-ddintx033 tointegralx -0.1 -> -0 Inexact Rounded
-ddintx034 tointegralx -0.2 -> -0 Inexact Rounded
-ddintx035 tointegralx -0.3 -> -0 Inexact Rounded
-ddintx036 tointegralx -0.4 -> -0 Inexact Rounded
-ddintx037 tointegralx -0.5 -> -0 Inexact Rounded
-ddintx038 tointegralx -0.6 -> -1 Inexact Rounded
-ddintx039 tointegralx -0.7 -> -1 Inexact Rounded
-ddintx040 tointegralx -0.8 -> -1 Inexact Rounded
-ddintx041 tointegralx -0.9 -> -1 Inexact Rounded
-ddintx042 tointegralx -1 -> -1
-ddintx043 tointegralx -1.0 -> -1 Rounded
-ddintx044 tointegralx -1.1 -> -1 Inexact Rounded
-ddintx045 tointegralx -1.2 -> -1 Inexact Rounded
-ddintx046 tointegralx -1.3 -> -1 Inexact Rounded
-ddintx047 tointegralx -1.4 -> -1 Inexact Rounded
-ddintx048 tointegralx -1.5 -> -2 Inexact Rounded
-ddintx049 tointegralx -1.6 -> -2 Inexact Rounded
-ddintx050 tointegralx -1.7 -> -2 Inexact Rounded
-ddintx051 tointegralx -1.8 -> -2 Inexact Rounded
-ddintx052 tointegralx -1.9 -> -2 Inexact Rounded
--- next two would be NaN using quantize(x, 0)
-ddintx053 tointegralx 10E+60 -> 1.0E+61
-ddintx054 tointegralx -10E+60 -> -1.0E+61
-
--- numbers around precision
-ddintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
-ddintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
-ddintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
-ddintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
-ddintx065 tointegralx '56267E-0' -> '56267'
-ddintx066 tointegralx '56267E+0' -> '56267'
-ddintx067 tointegralx '56267E+1' -> '5.6267E+5'
-ddintx068 tointegralx '56267E+9' -> '5.6267E+13'
-ddintx069 tointegralx '56267E+10' -> '5.6267E+14'
-ddintx070 tointegralx '56267E+11' -> '5.6267E+15'
-ddintx071 tointegralx '56267E+12' -> '5.6267E+16'
-ddintx072 tointegralx '56267E+13' -> '5.6267E+17'
-ddintx073 tointegralx '1.23E+96' -> '1.23E+96'
-ddintx074 tointegralx '1.23E+384' -> #47fd300000000000 Clamped
-
-ddintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
-ddintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
-ddintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
-ddintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
-ddintx085 tointegralx '-56267E-0' -> '-56267'
-ddintx086 tointegralx '-56267E+0' -> '-56267'
-ddintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
-ddintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
-ddintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
-ddintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
-ddintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
-ddintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
-ddintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
-ddintx094 tointegralx '-1.23E+384' -> #c7fd300000000000 Clamped
-
--- subnormal inputs
-ddintx100 tointegralx 1E-299 -> 0 Inexact Rounded
-ddintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
-ddintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
-ddintx103 tointegralx 0E-299 -> 0
-
--- specials and zeros
-ddintx120 tointegralx 'Inf' -> Infinity
-ddintx121 tointegralx '-Inf' -> -Infinity
-ddintx122 tointegralx NaN -> NaN
-ddintx123 tointegralx sNaN -> NaN Invalid_operation
-ddintx124 tointegralx 0 -> 0
-ddintx125 tointegralx -0 -> -0
-ddintx126 tointegralx 0.000 -> 0
-ddintx127 tointegralx 0.00 -> 0
-ddintx128 tointegralx 0.0 -> 0
-ddintx129 tointegralx 0 -> 0
-ddintx130 tointegralx 0E-3 -> 0
-ddintx131 tointegralx 0E-2 -> 0
-ddintx132 tointegralx 0E-1 -> 0
-ddintx133 tointegralx 0E-0 -> 0
-ddintx134 tointegralx 0E+1 -> 0E+1
-ddintx135 tointegralx 0E+2 -> 0E+2
-ddintx136 tointegralx 0E+3 -> 0E+3
-ddintx137 tointegralx 0E+4 -> 0E+4
-ddintx138 tointegralx 0E+5 -> 0E+5
-ddintx139 tointegralx -0.000 -> -0
-ddintx140 tointegralx -0.00 -> -0
-ddintx141 tointegralx -0.0 -> -0
-ddintx142 tointegralx -0 -> -0
-ddintx143 tointegralx -0E-3 -> -0
-ddintx144 tointegralx -0E-2 -> -0
-ddintx145 tointegralx -0E-1 -> -0
-ddintx146 tointegralx -0E-0 -> -0
-ddintx147 tointegralx -0E+1 -> -0E+1
-ddintx148 tointegralx -0E+2 -> -0E+2
-ddintx149 tointegralx -0E+3 -> -0E+3
-ddintx150 tointegralx -0E+4 -> -0E+4
-ddintx151 tointegralx -0E+5 -> -0E+5
--- propagating NaNs
-ddintx152 tointegralx NaN808 -> NaN808
-ddintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
-ddintx154 tointegralx -NaN808 -> -NaN808
-ddintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
-ddintx156 tointegralx -NaN -> -NaN
-ddintx157 tointegralx -sNaN -> -NaN Invalid_operation
-
--- examples
-rounding: half_up
-ddintx200 tointegralx 2.1 -> 2 Inexact Rounded
-ddintx201 tointegralx 100 -> 100
-ddintx202 tointegralx 100.0 -> 100 Rounded
-ddintx203 tointegralx 101.5 -> 102 Inexact Rounded
-ddintx204 tointegralx -101.5 -> -102 Inexact Rounded
-ddintx205 tointegralx 10E+5 -> 1.0E+6
-ddintx206 tointegralx 7.89E+77 -> 7.89E+77
-ddintx207 tointegralx -Inf -> -Infinity
-
-
--- all rounding modes
-rounding: half_even
-ddintx210 tointegralx 55.5 -> 56 Inexact Rounded
-ddintx211 tointegralx 56.5 -> 56 Inexact Rounded
-ddintx212 tointegralx 57.5 -> 58 Inexact Rounded
-ddintx213 tointegralx -55.5 -> -56 Inexact Rounded
-ddintx214 tointegralx -56.5 -> -56 Inexact Rounded
-ddintx215 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_up
-
-ddintx220 tointegralx 55.5 -> 56 Inexact Rounded
-ddintx221 tointegralx 56.5 -> 57 Inexact Rounded
-ddintx222 tointegralx 57.5 -> 58 Inexact Rounded
-ddintx223 tointegralx -55.5 -> -56 Inexact Rounded
-ddintx224 tointegralx -56.5 -> -57 Inexact Rounded
-ddintx225 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_down
-
-ddintx230 tointegralx 55.5 -> 55 Inexact Rounded
-ddintx231 tointegralx 56.5 -> 56 Inexact Rounded
-ddintx232 tointegralx 57.5 -> 57 Inexact Rounded
-ddintx233 tointegralx -55.5 -> -55 Inexact Rounded
-ddintx234 tointegralx -56.5 -> -56 Inexact Rounded
-ddintx235 tointegralx -57.5 -> -57 Inexact Rounded
-
-rounding: up
-
-ddintx240 tointegralx 55.3 -> 56 Inexact Rounded
-ddintx241 tointegralx 56.3 -> 57 Inexact Rounded
-ddintx242 tointegralx 57.3 -> 58 Inexact Rounded
-ddintx243 tointegralx -55.3 -> -56 Inexact Rounded
-ddintx244 tointegralx -56.3 -> -57 Inexact Rounded
-ddintx245 tointegralx -57.3 -> -58 Inexact Rounded
-
-rounding: down
-
-ddintx250 tointegralx 55.7 -> 55 Inexact Rounded
-ddintx251 tointegralx 56.7 -> 56 Inexact Rounded
-ddintx252 tointegralx 57.7 -> 57 Inexact Rounded
-ddintx253 tointegralx -55.7 -> -55 Inexact Rounded
-ddintx254 tointegralx -56.7 -> -56 Inexact Rounded
-ddintx255 tointegralx -57.7 -> -57 Inexact Rounded
-
-rounding: ceiling
-
-ddintx260 tointegralx 55.3 -> 56 Inexact Rounded
-ddintx261 tointegralx 56.3 -> 57 Inexact Rounded
-ddintx262 tointegralx 57.3 -> 58 Inexact Rounded
-ddintx263 tointegralx -55.3 -> -55 Inexact Rounded
-ddintx264 tointegralx -56.3 -> -56 Inexact Rounded
-ddintx265 tointegralx -57.3 -> -57 Inexact Rounded
-
-rounding: floor
-
-ddintx270 tointegralx 55.7 -> 55 Inexact Rounded
-ddintx271 tointegralx 56.7 -> 56 Inexact Rounded
-ddintx272 tointegralx 57.7 -> 57 Inexact Rounded
-ddintx273 tointegralx -55.7 -> -56 Inexact Rounded
-ddintx274 tointegralx -56.7 -> -57 Inexact Rounded
-ddintx275 tointegralx -57.7 -> -58 Inexact Rounded
-
--- Int and uInt32 edge values for testing conversions
-ddintx300 tointegralx -2147483646 -> -2147483646
-ddintx301 tointegralx -2147483647 -> -2147483647
-ddintx302 tointegralx -2147483648 -> -2147483648
-ddintx303 tointegralx -2147483649 -> -2147483649
-ddintx304 tointegralx 2147483646 -> 2147483646
-ddintx305 tointegralx 2147483647 -> 2147483647
-ddintx306 tointegralx 2147483648 -> 2147483648
-ddintx307 tointegralx 2147483649 -> 2147483649
-ddintx308 tointegralx 4294967294 -> 4294967294
-ddintx309 tointegralx 4294967295 -> 4294967295
-ddintx310 tointegralx 4294967296 -> 4294967296
-ddintx311 tointegralx 4294967297 -> 4294967297
-
+------------------------------------------------------------------------
+-- ddToIntegral.decTest -- round Double to integral value --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests tests the extended specification 'round-to-integral
+-- value-exact' operations (from IEEE 854, later modified in 754r).
+-- All non-zero results are defined as being those from either copy or
+-- quantize, so those are assumed to have been tested extensively
+-- elsewhere; the tests here are for integrity, rounding mode, etc.
+-- Also, it is assumed the test harness will use these tests for both
+-- ToIntegralExact (which does set Inexact) and the fixed-name
+-- functions (which do not set Inexact).
+
+-- Note that decNumber implements an earlier definition of toIntegral
+-- which never sets Inexact; the decTest operator for that is called
+-- 'tointegral' instead of 'tointegralx'.
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddintx001 tointegralx 0 -> 0
+ddintx002 tointegralx 0.0 -> 0
+ddintx003 tointegralx 0.1 -> 0 Inexact Rounded
+ddintx004 tointegralx 0.2 -> 0 Inexact Rounded
+ddintx005 tointegralx 0.3 -> 0 Inexact Rounded
+ddintx006 tointegralx 0.4 -> 0 Inexact Rounded
+ddintx007 tointegralx 0.5 -> 0 Inexact Rounded
+ddintx008 tointegralx 0.6 -> 1 Inexact Rounded
+ddintx009 tointegralx 0.7 -> 1 Inexact Rounded
+ddintx010 tointegralx 0.8 -> 1 Inexact Rounded
+ddintx011 tointegralx 0.9 -> 1 Inexact Rounded
+ddintx012 tointegralx 1 -> 1
+ddintx013 tointegralx 1.0 -> 1 Rounded
+ddintx014 tointegralx 1.1 -> 1 Inexact Rounded
+ddintx015 tointegralx 1.2 -> 1 Inexact Rounded
+ddintx016 tointegralx 1.3 -> 1 Inexact Rounded
+ddintx017 tointegralx 1.4 -> 1 Inexact Rounded
+ddintx018 tointegralx 1.5 -> 2 Inexact Rounded
+ddintx019 tointegralx 1.6 -> 2 Inexact Rounded
+ddintx020 tointegralx 1.7 -> 2 Inexact Rounded
+ddintx021 tointegralx 1.8 -> 2 Inexact Rounded
+ddintx022 tointegralx 1.9 -> 2 Inexact Rounded
+-- negatives
+ddintx031 tointegralx -0 -> -0
+ddintx032 tointegralx -0.0 -> -0
+ddintx033 tointegralx -0.1 -> -0 Inexact Rounded
+ddintx034 tointegralx -0.2 -> -0 Inexact Rounded
+ddintx035 tointegralx -0.3 -> -0 Inexact Rounded
+ddintx036 tointegralx -0.4 -> -0 Inexact Rounded
+ddintx037 tointegralx -0.5 -> -0 Inexact Rounded
+ddintx038 tointegralx -0.6 -> -1 Inexact Rounded
+ddintx039 tointegralx -0.7 -> -1 Inexact Rounded
+ddintx040 tointegralx -0.8 -> -1 Inexact Rounded
+ddintx041 tointegralx -0.9 -> -1 Inexact Rounded
+ddintx042 tointegralx -1 -> -1
+ddintx043 tointegralx -1.0 -> -1 Rounded
+ddintx044 tointegralx -1.1 -> -1 Inexact Rounded
+ddintx045 tointegralx -1.2 -> -1 Inexact Rounded
+ddintx046 tointegralx -1.3 -> -1 Inexact Rounded
+ddintx047 tointegralx -1.4 -> -1 Inexact Rounded
+ddintx048 tointegralx -1.5 -> -2 Inexact Rounded
+ddintx049 tointegralx -1.6 -> -2 Inexact Rounded
+ddintx050 tointegralx -1.7 -> -2 Inexact Rounded
+ddintx051 tointegralx -1.8 -> -2 Inexact Rounded
+ddintx052 tointegralx -1.9 -> -2 Inexact Rounded
+-- next two would be NaN using quantize(x, 0)
+ddintx053 tointegralx 10E+60 -> 1.0E+61
+ddintx054 tointegralx -10E+60 -> -1.0E+61
+
+-- numbers around precision
+ddintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
+ddintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
+ddintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
+ddintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
+ddintx065 tointegralx '56267E-0' -> '56267'
+ddintx066 tointegralx '56267E+0' -> '56267'
+ddintx067 tointegralx '56267E+1' -> '5.6267E+5'
+ddintx068 tointegralx '56267E+9' -> '5.6267E+13'
+ddintx069 tointegralx '56267E+10' -> '5.6267E+14'
+ddintx070 tointegralx '56267E+11' -> '5.6267E+15'
+ddintx071 tointegralx '56267E+12' -> '5.6267E+16'
+ddintx072 tointegralx '56267E+13' -> '5.6267E+17'
+ddintx073 tointegralx '1.23E+96' -> '1.23E+96'
+ddintx074 tointegralx '1.23E+384' -> #47fd300000000000 Clamped
+
+ddintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
+ddintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
+ddintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
+ddintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
+ddintx085 tointegralx '-56267E-0' -> '-56267'
+ddintx086 tointegralx '-56267E+0' -> '-56267'
+ddintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
+ddintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
+ddintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
+ddintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
+ddintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
+ddintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
+ddintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
+ddintx094 tointegralx '-1.23E+384' -> #c7fd300000000000 Clamped
+
+-- subnormal inputs
+ddintx100 tointegralx 1E-299 -> 0 Inexact Rounded
+ddintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
+ddintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
+ddintx103 tointegralx 0E-299 -> 0
+
+-- specials and zeros
+ddintx120 tointegralx 'Inf' -> Infinity
+ddintx121 tointegralx '-Inf' -> -Infinity
+ddintx122 tointegralx NaN -> NaN
+ddintx123 tointegralx sNaN -> NaN Invalid_operation
+ddintx124 tointegralx 0 -> 0
+ddintx125 tointegralx -0 -> -0
+ddintx126 tointegralx 0.000 -> 0
+ddintx127 tointegralx 0.00 -> 0
+ddintx128 tointegralx 0.0 -> 0
+ddintx129 tointegralx 0 -> 0
+ddintx130 tointegralx 0E-3 -> 0
+ddintx131 tointegralx 0E-2 -> 0
+ddintx132 tointegralx 0E-1 -> 0
+ddintx133 tointegralx 0E-0 -> 0
+ddintx134 tointegralx 0E+1 -> 0E+1
+ddintx135 tointegralx 0E+2 -> 0E+2
+ddintx136 tointegralx 0E+3 -> 0E+3
+ddintx137 tointegralx 0E+4 -> 0E+4
+ddintx138 tointegralx 0E+5 -> 0E+5
+ddintx139 tointegralx -0.000 -> -0
+ddintx140 tointegralx -0.00 -> -0
+ddintx141 tointegralx -0.0 -> -0
+ddintx142 tointegralx -0 -> -0
+ddintx143 tointegralx -0E-3 -> -0
+ddintx144 tointegralx -0E-2 -> -0
+ddintx145 tointegralx -0E-1 -> -0
+ddintx146 tointegralx -0E-0 -> -0
+ddintx147 tointegralx -0E+1 -> -0E+1
+ddintx148 tointegralx -0E+2 -> -0E+2
+ddintx149 tointegralx -0E+3 -> -0E+3
+ddintx150 tointegralx -0E+4 -> -0E+4
+ddintx151 tointegralx -0E+5 -> -0E+5
+-- propagating NaNs
+ddintx152 tointegralx NaN808 -> NaN808
+ddintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
+ddintx154 tointegralx -NaN808 -> -NaN808
+ddintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
+ddintx156 tointegralx -NaN -> -NaN
+ddintx157 tointegralx -sNaN -> -NaN Invalid_operation
+
+-- examples
+rounding: half_up
+ddintx200 tointegralx 2.1 -> 2 Inexact Rounded
+ddintx201 tointegralx 100 -> 100
+ddintx202 tointegralx 100.0 -> 100 Rounded
+ddintx203 tointegralx 101.5 -> 102 Inexact Rounded
+ddintx204 tointegralx -101.5 -> -102 Inexact Rounded
+ddintx205 tointegralx 10E+5 -> 1.0E+6
+ddintx206 tointegralx 7.89E+77 -> 7.89E+77
+ddintx207 tointegralx -Inf -> -Infinity
+
+
+-- all rounding modes
+rounding: half_even
+ddintx210 tointegralx 55.5 -> 56 Inexact Rounded
+ddintx211 tointegralx 56.5 -> 56 Inexact Rounded
+ddintx212 tointegralx 57.5 -> 58 Inexact Rounded
+ddintx213 tointegralx -55.5 -> -56 Inexact Rounded
+ddintx214 tointegralx -56.5 -> -56 Inexact Rounded
+ddintx215 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_up
+
+ddintx220 tointegralx 55.5 -> 56 Inexact Rounded
+ddintx221 tointegralx 56.5 -> 57 Inexact Rounded
+ddintx222 tointegralx 57.5 -> 58 Inexact Rounded
+ddintx223 tointegralx -55.5 -> -56 Inexact Rounded
+ddintx224 tointegralx -56.5 -> -57 Inexact Rounded
+ddintx225 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_down
+
+ddintx230 tointegralx 55.5 -> 55 Inexact Rounded
+ddintx231 tointegralx 56.5 -> 56 Inexact Rounded
+ddintx232 tointegralx 57.5 -> 57 Inexact Rounded
+ddintx233 tointegralx -55.5 -> -55 Inexact Rounded
+ddintx234 tointegralx -56.5 -> -56 Inexact Rounded
+ddintx235 tointegralx -57.5 -> -57 Inexact Rounded
+
+rounding: up
+
+ddintx240 tointegralx 55.3 -> 56 Inexact Rounded
+ddintx241 tointegralx 56.3 -> 57 Inexact Rounded
+ddintx242 tointegralx 57.3 -> 58 Inexact Rounded
+ddintx243 tointegralx -55.3 -> -56 Inexact Rounded
+ddintx244 tointegralx -56.3 -> -57 Inexact Rounded
+ddintx245 tointegralx -57.3 -> -58 Inexact Rounded
+
+rounding: down
+
+ddintx250 tointegralx 55.7 -> 55 Inexact Rounded
+ddintx251 tointegralx 56.7 -> 56 Inexact Rounded
+ddintx252 tointegralx 57.7 -> 57 Inexact Rounded
+ddintx253 tointegralx -55.7 -> -55 Inexact Rounded
+ddintx254 tointegralx -56.7 -> -56 Inexact Rounded
+ddintx255 tointegralx -57.7 -> -57 Inexact Rounded
+
+rounding: ceiling
+
+ddintx260 tointegralx 55.3 -> 56 Inexact Rounded
+ddintx261 tointegralx 56.3 -> 57 Inexact Rounded
+ddintx262 tointegralx 57.3 -> 58 Inexact Rounded
+ddintx263 tointegralx -55.3 -> -55 Inexact Rounded
+ddintx264 tointegralx -56.3 -> -56 Inexact Rounded
+ddintx265 tointegralx -57.3 -> -57 Inexact Rounded
+
+rounding: floor
+
+ddintx270 tointegralx 55.7 -> 55 Inexact Rounded
+ddintx271 tointegralx 56.7 -> 56 Inexact Rounded
+ddintx272 tointegralx 57.7 -> 57 Inexact Rounded
+ddintx273 tointegralx -55.7 -> -56 Inexact Rounded
+ddintx274 tointegralx -56.7 -> -57 Inexact Rounded
+ddintx275 tointegralx -57.7 -> -58 Inexact Rounded
+
+-- Int and uInt32 edge values for testing conversions
+ddintx300 tointegralx -2147483646 -> -2147483646
+ddintx301 tointegralx -2147483647 -> -2147483647
+ddintx302 tointegralx -2147483648 -> -2147483648
+ddintx303 tointegralx -2147483649 -> -2147483649
+ddintx304 tointegralx 2147483646 -> 2147483646
+ddintx305 tointegralx 2147483647 -> 2147483647
+ddintx306 tointegralx 2147483648 -> 2147483648
+ddintx307 tointegralx 2147483649 -> 2147483649
+ddintx308 tointegralx 4294967294 -> 4294967294
+ddintx309 tointegralx 4294967295 -> 4294967295
+ddintx310 tointegralx 4294967296 -> 4294967296
+ddintx311 tointegralx 4294967297 -> 4294967297
+
diff --git a/Lib/test/decimaltestdata/ddXor.decTest b/Lib/test/decimaltestdata/ddXor.decTest
index 131c7eb4b0..3c55548e5e 100644
--- a/Lib/test/decimaltestdata/ddXor.decTest
+++ b/Lib/test/decimaltestdata/ddXor.decTest
@@ -1,337 +1,337 @@
-------------------------------------------------------------------------
--- ddXor.decTest -- digitwise logical XOR for decDoubles --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check (truth table)
-ddxor001 xor 0 0 -> 0
-ddxor002 xor 0 1 -> 1
-ddxor003 xor 1 0 -> 1
-ddxor004 xor 1 1 -> 0
-ddxor005 xor 1100 1010 -> 110
--- and at msd and msd-1
-ddxor006 xor 0000000000000000 0000000000000000 -> 0
-ddxor007 xor 0000000000000000 1000000000000000 -> 1000000000000000
-ddxor008 xor 1000000000000000 0000000000000000 -> 1000000000000000
-ddxor009 xor 1000000000000000 1000000000000000 -> 0
-ddxor010 xor 0000000000000000 0000000000000000 -> 0
-ddxor011 xor 0000000000000000 0100000000000000 -> 100000000000000
-ddxor012 xor 0100000000000000 0000000000000000 -> 100000000000000
-ddxor013 xor 0100000000000000 0100000000000000 -> 0
-
--- Various lengths
--- 1234567890123456 1234567890123456 1234567890123456
-ddxor021 xor 1111111110000000 1111111110000000 -> 0
-ddxor022 xor 111111110000000 111111110000000 -> 0
-ddxor023 xor 11111110000000 11111110000000 -> 0
-ddxor024 xor 1111110000000 1111110000000 -> 0
-ddxor025 xor 111110000000 111110000000 -> 0
-ddxor026 xor 11110000000 11110000000 -> 0
-ddxor027 xor 1110000000 1110000000 -> 0
-ddxor028 xor 110000000 110000000 -> 0
-ddxor029 xor 10000000 10000000 -> 0
-ddxor030 xor 1000000 1000000 -> 0
-ddxor031 xor 100000 100000 -> 0
-ddxor032 xor 10000 10000 -> 0
-ddxor033 xor 1000 1000 -> 0
-ddxor034 xor 100 100 -> 0
-ddxor035 xor 10 10 -> 0
-ddxor036 xor 1 1 -> 0
-
-ddxor040 xor 111111111 111111111111 -> 111000000000
-ddxor041 xor 11111111 111111111111 -> 111100000000
-ddxor042 xor 11111111 111111111 -> 100000000
-ddxor043 xor 1111111 100000010 -> 101111101
-ddxor044 xor 111111 100000100 -> 100111011
-ddxor045 xor 11111 100001000 -> 100010111
-ddxor046 xor 1111 100010000 -> 100011111
-ddxor047 xor 111 100100000 -> 100100111
-ddxor048 xor 11 101000000 -> 101000011
-ddxor049 xor 1 110000000 -> 110000001
-
-ddxor050 xor 1111111111 1 -> 1111111110
-ddxor051 xor 111111111 1 -> 111111110
-ddxor052 xor 11111111 1 -> 11111110
-ddxor053 xor 1111111 1 -> 1111110
-ddxor054 xor 111111 1 -> 111110
-ddxor055 xor 11111 1 -> 11110
-ddxor056 xor 1111 1 -> 1110
-ddxor057 xor 111 1 -> 110
-ddxor058 xor 11 1 -> 10
-ddxor059 xor 1 1 -> 0
-
-ddxor060 xor 1111111111 0 -> 1111111111
-ddxor061 xor 111111111 0 -> 111111111
-ddxor062 xor 11111111 0 -> 11111111
-ddxor063 xor 1111111 0 -> 1111111
-ddxor064 xor 111111 0 -> 111111
-ddxor065 xor 11111 0 -> 11111
-ddxor066 xor 1111 0 -> 1111
-ddxor067 xor 111 0 -> 111
-ddxor068 xor 11 0 -> 11
-ddxor069 xor 1 0 -> 1
-
-ddxor070 xor 1 1111111111 -> 1111111110
-ddxor071 xor 1 111111111 -> 111111110
-ddxor072 xor 1 11111111 -> 11111110
-ddxor073 xor 1 1111111 -> 1111110
-ddxor074 xor 1 111111 -> 111110
-ddxor075 xor 1 11111 -> 11110
-ddxor076 xor 1 1111 -> 1110
-ddxor077 xor 1 111 -> 110
-ddxor078 xor 1 11 -> 10
-ddxor079 xor 1 1 -> 0
-
-ddxor080 xor 0 1111111111 -> 1111111111
-ddxor081 xor 0 111111111 -> 111111111
-ddxor082 xor 0 11111111 -> 11111111
-ddxor083 xor 0 1111111 -> 1111111
-ddxor084 xor 0 111111 -> 111111
-ddxor085 xor 0 11111 -> 11111
-ddxor086 xor 0 1111 -> 1111
-ddxor087 xor 0 111 -> 111
-ddxor088 xor 0 11 -> 11
-ddxor089 xor 0 1 -> 1
-
-ddxor090 xor 011111111 111101111 -> 100010000
-ddxor091 xor 101111111 111101111 -> 10010000
-ddxor092 xor 110111111 111101111 -> 1010000
-ddxor093 xor 111011111 111101111 -> 110000
-ddxor094 xor 111101111 111101111 -> 0
-ddxor095 xor 111110111 111101111 -> 11000
-ddxor096 xor 111111011 111101111 -> 10100
-ddxor097 xor 111111101 111101111 -> 10010
-ddxor098 xor 111111110 111101111 -> 10001
-
-ddxor100 xor 111101111 011111111 -> 100010000
-ddxor101 xor 111101111 101111111 -> 10010000
-ddxor102 xor 111101111 110111111 -> 1010000
-ddxor103 xor 111101111 111011111 -> 110000
-ddxor104 xor 111101111 111101111 -> 0
-ddxor105 xor 111101111 111110111 -> 11000
-ddxor106 xor 111101111 111111011 -> 10100
-ddxor107 xor 111101111 111111101 -> 10010
-ddxor108 xor 111101111 111111110 -> 10001
-
--- non-0/1 should not be accepted, nor should signs
-ddxor220 xor 111111112 111111111 -> NaN Invalid_operation
-ddxor221 xor 333333333 333333333 -> NaN Invalid_operation
-ddxor222 xor 555555555 555555555 -> NaN Invalid_operation
-ddxor223 xor 777777777 777777777 -> NaN Invalid_operation
-ddxor224 xor 999999999 999999999 -> NaN Invalid_operation
-ddxor225 xor 222222222 999999999 -> NaN Invalid_operation
-ddxor226 xor 444444444 999999999 -> NaN Invalid_operation
-ddxor227 xor 666666666 999999999 -> NaN Invalid_operation
-ddxor228 xor 888888888 999999999 -> NaN Invalid_operation
-ddxor229 xor 999999999 222222222 -> NaN Invalid_operation
-ddxor230 xor 999999999 444444444 -> NaN Invalid_operation
-ddxor231 xor 999999999 666666666 -> NaN Invalid_operation
-ddxor232 xor 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-ddxor240 xor 567468689 -934981942 -> NaN Invalid_operation
-ddxor241 xor 567367689 934981942 -> NaN Invalid_operation
-ddxor242 xor -631917772 -706014634 -> NaN Invalid_operation
-ddxor243 xor -756253257 138579234 -> NaN Invalid_operation
-ddxor244 xor 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-ddxor250 xor 2000000000000000 1000000000000000 -> NaN Invalid_operation
-ddxor251 xor 7000000000000000 1000000000000000 -> NaN Invalid_operation
-ddxor252 xor 8000000000000000 1000000000000000 -> NaN Invalid_operation
-ddxor253 xor 9000000000000000 1000000000000000 -> NaN Invalid_operation
-ddxor254 xor 2000000000000000 0000000000000000 -> NaN Invalid_operation
-ddxor255 xor 7000000000000000 0000000000000000 -> NaN Invalid_operation
-ddxor256 xor 8000000000000000 0000000000000000 -> NaN Invalid_operation
-ddxor257 xor 9000000000000000 0000000000000000 -> NaN Invalid_operation
-ddxor258 xor 1000000000000000 2000000000000000 -> NaN Invalid_operation
-ddxor259 xor 1000000000000000 7000000000000000 -> NaN Invalid_operation
-ddxor260 xor 1000000000000000 8000000000000000 -> NaN Invalid_operation
-ddxor261 xor 1000000000000000 9000000000000000 -> NaN Invalid_operation
-ddxor262 xor 0000000000000000 2000000000000000 -> NaN Invalid_operation
-ddxor263 xor 0000000000000000 7000000000000000 -> NaN Invalid_operation
-ddxor264 xor 0000000000000000 8000000000000000 -> NaN Invalid_operation
-ddxor265 xor 0000000000000000 9000000000000000 -> NaN Invalid_operation
--- test MSD-1
-ddxor270 xor 0200001000000000 1000100000000010 -> NaN Invalid_operation
-ddxor271 xor 0700000100000000 1000010000000100 -> NaN Invalid_operation
-ddxor272 xor 0800000010000000 1000001000001000 -> NaN Invalid_operation
-ddxor273 xor 0900000001000000 1000000100010000 -> NaN Invalid_operation
-ddxor274 xor 1000000000100000 0200000010100000 -> NaN Invalid_operation
-ddxor275 xor 1000000000010000 0700000001000000 -> NaN Invalid_operation
-ddxor276 xor 1000000000001000 0800000010100000 -> NaN Invalid_operation
-ddxor277 xor 1000000000000100 0900000000010000 -> NaN Invalid_operation
--- test LSD
-ddxor280 xor 0010000000000002 1000000100000001 -> NaN Invalid_operation
-ddxor281 xor 0001000000000007 1000001000000011 -> NaN Invalid_operation
-ddxor282 xor 0000100000000008 1000010000000001 -> NaN Invalid_operation
-ddxor283 xor 0000010000000009 1000100000000001 -> NaN Invalid_operation
-ddxor284 xor 1000001000000000 0001000000000002 -> NaN Invalid_operation
-ddxor285 xor 1000000100000000 0010000000000007 -> NaN Invalid_operation
-ddxor286 xor 1000000010000000 0100000000000008 -> NaN Invalid_operation
-ddxor287 xor 1000000001000000 1000000000000009 -> NaN Invalid_operation
--- test Middie
-ddxor288 xor 0010000020000000 1000001000000000 -> NaN Invalid_operation
-ddxor289 xor 0001000070000001 1000000100000000 -> NaN Invalid_operation
-ddxor290 xor 0000100080000010 1000000010000000 -> NaN Invalid_operation
-ddxor291 xor 0000010090000100 1000000001000000 -> NaN Invalid_operation
-ddxor292 xor 1000001000001000 0000000020100000 -> NaN Invalid_operation
-ddxor293 xor 1000000100010000 0000000070010000 -> NaN Invalid_operation
-ddxor294 xor 1000000010100000 0000000080001000 -> NaN Invalid_operation
-ddxor295 xor 1000000001000000 0000000090000100 -> NaN Invalid_operation
--- signs
-ddxor296 xor -1000000001000000 -0000010000000100 -> NaN Invalid_operation
-ddxor297 xor -1000000001000000 0000000010000100 -> NaN Invalid_operation
-ddxor298 xor 1000000001000000 -0000001000000100 -> NaN Invalid_operation
-ddxor299 xor 1000000001000000 0000000011000100 -> 1000000010000100
-
--- Nmax, Nmin, Ntiny-like
-ddxor331 xor 2 9.99999999E+299 -> NaN Invalid_operation
-ddxor332 xor 3 1E-299 -> NaN Invalid_operation
-ddxor333 xor 4 1.00000000E-299 -> NaN Invalid_operation
-ddxor334 xor 5 1E-200 -> NaN Invalid_operation
-ddxor335 xor 6 -1E-200 -> NaN Invalid_operation
-ddxor336 xor 7 -1.00000000E-299 -> NaN Invalid_operation
-ddxor337 xor 8 -1E-299 -> NaN Invalid_operation
-ddxor338 xor 9 -9.99999999E+299 -> NaN Invalid_operation
-ddxor341 xor 9.99999999E+299 -18 -> NaN Invalid_operation
-ddxor342 xor 1E-299 01 -> NaN Invalid_operation
-ddxor343 xor 1.00000000E-299 -18 -> NaN Invalid_operation
-ddxor344 xor 1E-208 18 -> NaN Invalid_operation
-ddxor345 xor -1E-207 -10 -> NaN Invalid_operation
-ddxor346 xor -1.00000000E-299 18 -> NaN Invalid_operation
-ddxor347 xor -1E-299 10 -> NaN Invalid_operation
-ddxor348 xor -9.99999999E+299 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-ddxor361 xor 1.0 1 -> NaN Invalid_operation
-ddxor362 xor 1E+1 1 -> NaN Invalid_operation
-ddxor363 xor 0.0 1 -> NaN Invalid_operation
-ddxor364 xor 0E+1 1 -> NaN Invalid_operation
-ddxor365 xor 9.9 1 -> NaN Invalid_operation
-ddxor366 xor 9E+1 1 -> NaN Invalid_operation
-ddxor371 xor 0 1.0 -> NaN Invalid_operation
-ddxor372 xor 0 1E+1 -> NaN Invalid_operation
-ddxor373 xor 0 0.0 -> NaN Invalid_operation
-ddxor374 xor 0 0E+1 -> NaN Invalid_operation
-ddxor375 xor 0 9.9 -> NaN Invalid_operation
-ddxor376 xor 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-ddxor780 xor -Inf -Inf -> NaN Invalid_operation
-ddxor781 xor -Inf -1000 -> NaN Invalid_operation
-ddxor782 xor -Inf -1 -> NaN Invalid_operation
-ddxor783 xor -Inf -0 -> NaN Invalid_operation
-ddxor784 xor -Inf 0 -> NaN Invalid_operation
-ddxor785 xor -Inf 1 -> NaN Invalid_operation
-ddxor786 xor -Inf 1000 -> NaN Invalid_operation
-ddxor787 xor -1000 -Inf -> NaN Invalid_operation
-ddxor788 xor -Inf -Inf -> NaN Invalid_operation
-ddxor789 xor -1 -Inf -> NaN Invalid_operation
-ddxor790 xor -0 -Inf -> NaN Invalid_operation
-ddxor791 xor 0 -Inf -> NaN Invalid_operation
-ddxor792 xor 1 -Inf -> NaN Invalid_operation
-ddxor793 xor 1000 -Inf -> NaN Invalid_operation
-ddxor794 xor Inf -Inf -> NaN Invalid_operation
-
-ddxor800 xor Inf -Inf -> NaN Invalid_operation
-ddxor801 xor Inf -1000 -> NaN Invalid_operation
-ddxor802 xor Inf -1 -> NaN Invalid_operation
-ddxor803 xor Inf -0 -> NaN Invalid_operation
-ddxor804 xor Inf 0 -> NaN Invalid_operation
-ddxor805 xor Inf 1 -> NaN Invalid_operation
-ddxor806 xor Inf 1000 -> NaN Invalid_operation
-ddxor807 xor Inf Inf -> NaN Invalid_operation
-ddxor808 xor -1000 Inf -> NaN Invalid_operation
-ddxor809 xor -Inf Inf -> NaN Invalid_operation
-ddxor810 xor -1 Inf -> NaN Invalid_operation
-ddxor811 xor -0 Inf -> NaN Invalid_operation
-ddxor812 xor 0 Inf -> NaN Invalid_operation
-ddxor813 xor 1 Inf -> NaN Invalid_operation
-ddxor814 xor 1000 Inf -> NaN Invalid_operation
-ddxor815 xor Inf Inf -> NaN Invalid_operation
-
-ddxor821 xor NaN -Inf -> NaN Invalid_operation
-ddxor822 xor NaN -1000 -> NaN Invalid_operation
-ddxor823 xor NaN -1 -> NaN Invalid_operation
-ddxor824 xor NaN -0 -> NaN Invalid_operation
-ddxor825 xor NaN 0 -> NaN Invalid_operation
-ddxor826 xor NaN 1 -> NaN Invalid_operation
-ddxor827 xor NaN 1000 -> NaN Invalid_operation
-ddxor828 xor NaN Inf -> NaN Invalid_operation
-ddxor829 xor NaN NaN -> NaN Invalid_operation
-ddxor830 xor -Inf NaN -> NaN Invalid_operation
-ddxor831 xor -1000 NaN -> NaN Invalid_operation
-ddxor832 xor -1 NaN -> NaN Invalid_operation
-ddxor833 xor -0 NaN -> NaN Invalid_operation
-ddxor834 xor 0 NaN -> NaN Invalid_operation
-ddxor835 xor 1 NaN -> NaN Invalid_operation
-ddxor836 xor 1000 NaN -> NaN Invalid_operation
-ddxor837 xor Inf NaN -> NaN Invalid_operation
-
-ddxor841 xor sNaN -Inf -> NaN Invalid_operation
-ddxor842 xor sNaN -1000 -> NaN Invalid_operation
-ddxor843 xor sNaN -1 -> NaN Invalid_operation
-ddxor844 xor sNaN -0 -> NaN Invalid_operation
-ddxor845 xor sNaN 0 -> NaN Invalid_operation
-ddxor846 xor sNaN 1 -> NaN Invalid_operation
-ddxor847 xor sNaN 1000 -> NaN Invalid_operation
-ddxor848 xor sNaN NaN -> NaN Invalid_operation
-ddxor849 xor sNaN sNaN -> NaN Invalid_operation
-ddxor850 xor NaN sNaN -> NaN Invalid_operation
-ddxor851 xor -Inf sNaN -> NaN Invalid_operation
-ddxor852 xor -1000 sNaN -> NaN Invalid_operation
-ddxor853 xor -1 sNaN -> NaN Invalid_operation
-ddxor854 xor -0 sNaN -> NaN Invalid_operation
-ddxor855 xor 0 sNaN -> NaN Invalid_operation
-ddxor856 xor 1 sNaN -> NaN Invalid_operation
-ddxor857 xor 1000 sNaN -> NaN Invalid_operation
-ddxor858 xor Inf sNaN -> NaN Invalid_operation
-ddxor859 xor NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddxor861 xor NaN1 -Inf -> NaN Invalid_operation
-ddxor862 xor +NaN2 -1000 -> NaN Invalid_operation
-ddxor863 xor NaN3 1000 -> NaN Invalid_operation
-ddxor864 xor NaN4 Inf -> NaN Invalid_operation
-ddxor865 xor NaN5 +NaN6 -> NaN Invalid_operation
-ddxor866 xor -Inf NaN7 -> NaN Invalid_operation
-ddxor867 xor -1000 NaN8 -> NaN Invalid_operation
-ddxor868 xor 1000 NaN9 -> NaN Invalid_operation
-ddxor869 xor Inf +NaN10 -> NaN Invalid_operation
-ddxor871 xor sNaN11 -Inf -> NaN Invalid_operation
-ddxor872 xor sNaN12 -1000 -> NaN Invalid_operation
-ddxor873 xor sNaN13 1000 -> NaN Invalid_operation
-ddxor874 xor sNaN14 NaN17 -> NaN Invalid_operation
-ddxor875 xor sNaN15 sNaN18 -> NaN Invalid_operation
-ddxor876 xor NaN16 sNaN19 -> NaN Invalid_operation
-ddxor877 xor -Inf +sNaN20 -> NaN Invalid_operation
-ddxor878 xor -1000 sNaN21 -> NaN Invalid_operation
-ddxor879 xor 1000 sNaN22 -> NaN Invalid_operation
-ddxor880 xor Inf sNaN23 -> NaN Invalid_operation
-ddxor881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
-ddxor882 xor -NaN26 NaN28 -> NaN Invalid_operation
-ddxor883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
-ddxor884 xor 1000 -NaN30 -> NaN Invalid_operation
-ddxor885 xor 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddXor.decTest -- digitwise logical XOR for decDoubles --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check (truth table)
+ddxor001 xor 0 0 -> 0
+ddxor002 xor 0 1 -> 1
+ddxor003 xor 1 0 -> 1
+ddxor004 xor 1 1 -> 0
+ddxor005 xor 1100 1010 -> 110
+-- and at msd and msd-1
+ddxor006 xor 0000000000000000 0000000000000000 -> 0
+ddxor007 xor 0000000000000000 1000000000000000 -> 1000000000000000
+ddxor008 xor 1000000000000000 0000000000000000 -> 1000000000000000
+ddxor009 xor 1000000000000000 1000000000000000 -> 0
+ddxor010 xor 0000000000000000 0000000000000000 -> 0
+ddxor011 xor 0000000000000000 0100000000000000 -> 100000000000000
+ddxor012 xor 0100000000000000 0000000000000000 -> 100000000000000
+ddxor013 xor 0100000000000000 0100000000000000 -> 0
+
+-- Various lengths
+-- 1234567890123456 1234567890123456 1234567890123456
+ddxor021 xor 1111111110000000 1111111110000000 -> 0
+ddxor022 xor 111111110000000 111111110000000 -> 0
+ddxor023 xor 11111110000000 11111110000000 -> 0
+ddxor024 xor 1111110000000 1111110000000 -> 0
+ddxor025 xor 111110000000 111110000000 -> 0
+ddxor026 xor 11110000000 11110000000 -> 0
+ddxor027 xor 1110000000 1110000000 -> 0
+ddxor028 xor 110000000 110000000 -> 0
+ddxor029 xor 10000000 10000000 -> 0
+ddxor030 xor 1000000 1000000 -> 0
+ddxor031 xor 100000 100000 -> 0
+ddxor032 xor 10000 10000 -> 0
+ddxor033 xor 1000 1000 -> 0
+ddxor034 xor 100 100 -> 0
+ddxor035 xor 10 10 -> 0
+ddxor036 xor 1 1 -> 0
+
+ddxor040 xor 111111111 111111111111 -> 111000000000
+ddxor041 xor 11111111 111111111111 -> 111100000000
+ddxor042 xor 11111111 111111111 -> 100000000
+ddxor043 xor 1111111 100000010 -> 101111101
+ddxor044 xor 111111 100000100 -> 100111011
+ddxor045 xor 11111 100001000 -> 100010111
+ddxor046 xor 1111 100010000 -> 100011111
+ddxor047 xor 111 100100000 -> 100100111
+ddxor048 xor 11 101000000 -> 101000011
+ddxor049 xor 1 110000000 -> 110000001
+
+ddxor050 xor 1111111111 1 -> 1111111110
+ddxor051 xor 111111111 1 -> 111111110
+ddxor052 xor 11111111 1 -> 11111110
+ddxor053 xor 1111111 1 -> 1111110
+ddxor054 xor 111111 1 -> 111110
+ddxor055 xor 11111 1 -> 11110
+ddxor056 xor 1111 1 -> 1110
+ddxor057 xor 111 1 -> 110
+ddxor058 xor 11 1 -> 10
+ddxor059 xor 1 1 -> 0
+
+ddxor060 xor 1111111111 0 -> 1111111111
+ddxor061 xor 111111111 0 -> 111111111
+ddxor062 xor 11111111 0 -> 11111111
+ddxor063 xor 1111111 0 -> 1111111
+ddxor064 xor 111111 0 -> 111111
+ddxor065 xor 11111 0 -> 11111
+ddxor066 xor 1111 0 -> 1111
+ddxor067 xor 111 0 -> 111
+ddxor068 xor 11 0 -> 11
+ddxor069 xor 1 0 -> 1
+
+ddxor070 xor 1 1111111111 -> 1111111110
+ddxor071 xor 1 111111111 -> 111111110
+ddxor072 xor 1 11111111 -> 11111110
+ddxor073 xor 1 1111111 -> 1111110
+ddxor074 xor 1 111111 -> 111110
+ddxor075 xor 1 11111 -> 11110
+ddxor076 xor 1 1111 -> 1110
+ddxor077 xor 1 111 -> 110
+ddxor078 xor 1 11 -> 10
+ddxor079 xor 1 1 -> 0
+
+ddxor080 xor 0 1111111111 -> 1111111111
+ddxor081 xor 0 111111111 -> 111111111
+ddxor082 xor 0 11111111 -> 11111111
+ddxor083 xor 0 1111111 -> 1111111
+ddxor084 xor 0 111111 -> 111111
+ddxor085 xor 0 11111 -> 11111
+ddxor086 xor 0 1111 -> 1111
+ddxor087 xor 0 111 -> 111
+ddxor088 xor 0 11 -> 11
+ddxor089 xor 0 1 -> 1
+
+ddxor090 xor 011111111 111101111 -> 100010000
+ddxor091 xor 101111111 111101111 -> 10010000
+ddxor092 xor 110111111 111101111 -> 1010000
+ddxor093 xor 111011111 111101111 -> 110000
+ddxor094 xor 111101111 111101111 -> 0
+ddxor095 xor 111110111 111101111 -> 11000
+ddxor096 xor 111111011 111101111 -> 10100
+ddxor097 xor 111111101 111101111 -> 10010
+ddxor098 xor 111111110 111101111 -> 10001
+
+ddxor100 xor 111101111 011111111 -> 100010000
+ddxor101 xor 111101111 101111111 -> 10010000
+ddxor102 xor 111101111 110111111 -> 1010000
+ddxor103 xor 111101111 111011111 -> 110000
+ddxor104 xor 111101111 111101111 -> 0
+ddxor105 xor 111101111 111110111 -> 11000
+ddxor106 xor 111101111 111111011 -> 10100
+ddxor107 xor 111101111 111111101 -> 10010
+ddxor108 xor 111101111 111111110 -> 10001
+
+-- non-0/1 should not be accepted, nor should signs
+ddxor220 xor 111111112 111111111 -> NaN Invalid_operation
+ddxor221 xor 333333333 333333333 -> NaN Invalid_operation
+ddxor222 xor 555555555 555555555 -> NaN Invalid_operation
+ddxor223 xor 777777777 777777777 -> NaN Invalid_operation
+ddxor224 xor 999999999 999999999 -> NaN Invalid_operation
+ddxor225 xor 222222222 999999999 -> NaN Invalid_operation
+ddxor226 xor 444444444 999999999 -> NaN Invalid_operation
+ddxor227 xor 666666666 999999999 -> NaN Invalid_operation
+ddxor228 xor 888888888 999999999 -> NaN Invalid_operation
+ddxor229 xor 999999999 222222222 -> NaN Invalid_operation
+ddxor230 xor 999999999 444444444 -> NaN Invalid_operation
+ddxor231 xor 999999999 666666666 -> NaN Invalid_operation
+ddxor232 xor 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+ddxor240 xor 567468689 -934981942 -> NaN Invalid_operation
+ddxor241 xor 567367689 934981942 -> NaN Invalid_operation
+ddxor242 xor -631917772 -706014634 -> NaN Invalid_operation
+ddxor243 xor -756253257 138579234 -> NaN Invalid_operation
+ddxor244 xor 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+ddxor250 xor 2000000000000000 1000000000000000 -> NaN Invalid_operation
+ddxor251 xor 7000000000000000 1000000000000000 -> NaN Invalid_operation
+ddxor252 xor 8000000000000000 1000000000000000 -> NaN Invalid_operation
+ddxor253 xor 9000000000000000 1000000000000000 -> NaN Invalid_operation
+ddxor254 xor 2000000000000000 0000000000000000 -> NaN Invalid_operation
+ddxor255 xor 7000000000000000 0000000000000000 -> NaN Invalid_operation
+ddxor256 xor 8000000000000000 0000000000000000 -> NaN Invalid_operation
+ddxor257 xor 9000000000000000 0000000000000000 -> NaN Invalid_operation
+ddxor258 xor 1000000000000000 2000000000000000 -> NaN Invalid_operation
+ddxor259 xor 1000000000000000 7000000000000000 -> NaN Invalid_operation
+ddxor260 xor 1000000000000000 8000000000000000 -> NaN Invalid_operation
+ddxor261 xor 1000000000000000 9000000000000000 -> NaN Invalid_operation
+ddxor262 xor 0000000000000000 2000000000000000 -> NaN Invalid_operation
+ddxor263 xor 0000000000000000 7000000000000000 -> NaN Invalid_operation
+ddxor264 xor 0000000000000000 8000000000000000 -> NaN Invalid_operation
+ddxor265 xor 0000000000000000 9000000000000000 -> NaN Invalid_operation
+-- test MSD-1
+ddxor270 xor 0200001000000000 1000100000000010 -> NaN Invalid_operation
+ddxor271 xor 0700000100000000 1000010000000100 -> NaN Invalid_operation
+ddxor272 xor 0800000010000000 1000001000001000 -> NaN Invalid_operation
+ddxor273 xor 0900000001000000 1000000100010000 -> NaN Invalid_operation
+ddxor274 xor 1000000000100000 0200000010100000 -> NaN Invalid_operation
+ddxor275 xor 1000000000010000 0700000001000000 -> NaN Invalid_operation
+ddxor276 xor 1000000000001000 0800000010100000 -> NaN Invalid_operation
+ddxor277 xor 1000000000000100 0900000000010000 -> NaN Invalid_operation
+-- test LSD
+ddxor280 xor 0010000000000002 1000000100000001 -> NaN Invalid_operation
+ddxor281 xor 0001000000000007 1000001000000011 -> NaN Invalid_operation
+ddxor282 xor 0000100000000008 1000010000000001 -> NaN Invalid_operation
+ddxor283 xor 0000010000000009 1000100000000001 -> NaN Invalid_operation
+ddxor284 xor 1000001000000000 0001000000000002 -> NaN Invalid_operation
+ddxor285 xor 1000000100000000 0010000000000007 -> NaN Invalid_operation
+ddxor286 xor 1000000010000000 0100000000000008 -> NaN Invalid_operation
+ddxor287 xor 1000000001000000 1000000000000009 -> NaN Invalid_operation
+-- test Middie
+ddxor288 xor 0010000020000000 1000001000000000 -> NaN Invalid_operation
+ddxor289 xor 0001000070000001 1000000100000000 -> NaN Invalid_operation
+ddxor290 xor 0000100080000010 1000000010000000 -> NaN Invalid_operation
+ddxor291 xor 0000010090000100 1000000001000000 -> NaN Invalid_operation
+ddxor292 xor 1000001000001000 0000000020100000 -> NaN Invalid_operation
+ddxor293 xor 1000000100010000 0000000070010000 -> NaN Invalid_operation
+ddxor294 xor 1000000010100000 0000000080001000 -> NaN Invalid_operation
+ddxor295 xor 1000000001000000 0000000090000100 -> NaN Invalid_operation
+-- signs
+ddxor296 xor -1000000001000000 -0000010000000100 -> NaN Invalid_operation
+ddxor297 xor -1000000001000000 0000000010000100 -> NaN Invalid_operation
+ddxor298 xor 1000000001000000 -0000001000000100 -> NaN Invalid_operation
+ddxor299 xor 1000000001000000 0000000011000100 -> 1000000010000100
+
+-- Nmax, Nmin, Ntiny-like
+ddxor331 xor 2 9.99999999E+299 -> NaN Invalid_operation
+ddxor332 xor 3 1E-299 -> NaN Invalid_operation
+ddxor333 xor 4 1.00000000E-299 -> NaN Invalid_operation
+ddxor334 xor 5 1E-200 -> NaN Invalid_operation
+ddxor335 xor 6 -1E-200 -> NaN Invalid_operation
+ddxor336 xor 7 -1.00000000E-299 -> NaN Invalid_operation
+ddxor337 xor 8 -1E-299 -> NaN Invalid_operation
+ddxor338 xor 9 -9.99999999E+299 -> NaN Invalid_operation
+ddxor341 xor 9.99999999E+299 -18 -> NaN Invalid_operation
+ddxor342 xor 1E-299 01 -> NaN Invalid_operation
+ddxor343 xor 1.00000000E-299 -18 -> NaN Invalid_operation
+ddxor344 xor 1E-208 18 -> NaN Invalid_operation
+ddxor345 xor -1E-207 -10 -> NaN Invalid_operation
+ddxor346 xor -1.00000000E-299 18 -> NaN Invalid_operation
+ddxor347 xor -1E-299 10 -> NaN Invalid_operation
+ddxor348 xor -9.99999999E+299 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+ddxor361 xor 1.0 1 -> NaN Invalid_operation
+ddxor362 xor 1E+1 1 -> NaN Invalid_operation
+ddxor363 xor 0.0 1 -> NaN Invalid_operation
+ddxor364 xor 0E+1 1 -> NaN Invalid_operation
+ddxor365 xor 9.9 1 -> NaN Invalid_operation
+ddxor366 xor 9E+1 1 -> NaN Invalid_operation
+ddxor371 xor 0 1.0 -> NaN Invalid_operation
+ddxor372 xor 0 1E+1 -> NaN Invalid_operation
+ddxor373 xor 0 0.0 -> NaN Invalid_operation
+ddxor374 xor 0 0E+1 -> NaN Invalid_operation
+ddxor375 xor 0 9.9 -> NaN Invalid_operation
+ddxor376 xor 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+ddxor780 xor -Inf -Inf -> NaN Invalid_operation
+ddxor781 xor -Inf -1000 -> NaN Invalid_operation
+ddxor782 xor -Inf -1 -> NaN Invalid_operation
+ddxor783 xor -Inf -0 -> NaN Invalid_operation
+ddxor784 xor -Inf 0 -> NaN Invalid_operation
+ddxor785 xor -Inf 1 -> NaN Invalid_operation
+ddxor786 xor -Inf 1000 -> NaN Invalid_operation
+ddxor787 xor -1000 -Inf -> NaN Invalid_operation
+ddxor788 xor -Inf -Inf -> NaN Invalid_operation
+ddxor789 xor -1 -Inf -> NaN Invalid_operation
+ddxor790 xor -0 -Inf -> NaN Invalid_operation
+ddxor791 xor 0 -Inf -> NaN Invalid_operation
+ddxor792 xor 1 -Inf -> NaN Invalid_operation
+ddxor793 xor 1000 -Inf -> NaN Invalid_operation
+ddxor794 xor Inf -Inf -> NaN Invalid_operation
+
+ddxor800 xor Inf -Inf -> NaN Invalid_operation
+ddxor801 xor Inf -1000 -> NaN Invalid_operation
+ddxor802 xor Inf -1 -> NaN Invalid_operation
+ddxor803 xor Inf -0 -> NaN Invalid_operation
+ddxor804 xor Inf 0 -> NaN Invalid_operation
+ddxor805 xor Inf 1 -> NaN Invalid_operation
+ddxor806 xor Inf 1000 -> NaN Invalid_operation
+ddxor807 xor Inf Inf -> NaN Invalid_operation
+ddxor808 xor -1000 Inf -> NaN Invalid_operation
+ddxor809 xor -Inf Inf -> NaN Invalid_operation
+ddxor810 xor -1 Inf -> NaN Invalid_operation
+ddxor811 xor -0 Inf -> NaN Invalid_operation
+ddxor812 xor 0 Inf -> NaN Invalid_operation
+ddxor813 xor 1 Inf -> NaN Invalid_operation
+ddxor814 xor 1000 Inf -> NaN Invalid_operation
+ddxor815 xor Inf Inf -> NaN Invalid_operation
+
+ddxor821 xor NaN -Inf -> NaN Invalid_operation
+ddxor822 xor NaN -1000 -> NaN Invalid_operation
+ddxor823 xor NaN -1 -> NaN Invalid_operation
+ddxor824 xor NaN -0 -> NaN Invalid_operation
+ddxor825 xor NaN 0 -> NaN Invalid_operation
+ddxor826 xor NaN 1 -> NaN Invalid_operation
+ddxor827 xor NaN 1000 -> NaN Invalid_operation
+ddxor828 xor NaN Inf -> NaN Invalid_operation
+ddxor829 xor NaN NaN -> NaN Invalid_operation
+ddxor830 xor -Inf NaN -> NaN Invalid_operation
+ddxor831 xor -1000 NaN -> NaN Invalid_operation
+ddxor832 xor -1 NaN -> NaN Invalid_operation
+ddxor833 xor -0 NaN -> NaN Invalid_operation
+ddxor834 xor 0 NaN -> NaN Invalid_operation
+ddxor835 xor 1 NaN -> NaN Invalid_operation
+ddxor836 xor 1000 NaN -> NaN Invalid_operation
+ddxor837 xor Inf NaN -> NaN Invalid_operation
+
+ddxor841 xor sNaN -Inf -> NaN Invalid_operation
+ddxor842 xor sNaN -1000 -> NaN Invalid_operation
+ddxor843 xor sNaN -1 -> NaN Invalid_operation
+ddxor844 xor sNaN -0 -> NaN Invalid_operation
+ddxor845 xor sNaN 0 -> NaN Invalid_operation
+ddxor846 xor sNaN 1 -> NaN Invalid_operation
+ddxor847 xor sNaN 1000 -> NaN Invalid_operation
+ddxor848 xor sNaN NaN -> NaN Invalid_operation
+ddxor849 xor sNaN sNaN -> NaN Invalid_operation
+ddxor850 xor NaN sNaN -> NaN Invalid_operation
+ddxor851 xor -Inf sNaN -> NaN Invalid_operation
+ddxor852 xor -1000 sNaN -> NaN Invalid_operation
+ddxor853 xor -1 sNaN -> NaN Invalid_operation
+ddxor854 xor -0 sNaN -> NaN Invalid_operation
+ddxor855 xor 0 sNaN -> NaN Invalid_operation
+ddxor856 xor 1 sNaN -> NaN Invalid_operation
+ddxor857 xor 1000 sNaN -> NaN Invalid_operation
+ddxor858 xor Inf sNaN -> NaN Invalid_operation
+ddxor859 xor NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddxor861 xor NaN1 -Inf -> NaN Invalid_operation
+ddxor862 xor +NaN2 -1000 -> NaN Invalid_operation
+ddxor863 xor NaN3 1000 -> NaN Invalid_operation
+ddxor864 xor NaN4 Inf -> NaN Invalid_operation
+ddxor865 xor NaN5 +NaN6 -> NaN Invalid_operation
+ddxor866 xor -Inf NaN7 -> NaN Invalid_operation
+ddxor867 xor -1000 NaN8 -> NaN Invalid_operation
+ddxor868 xor 1000 NaN9 -> NaN Invalid_operation
+ddxor869 xor Inf +NaN10 -> NaN Invalid_operation
+ddxor871 xor sNaN11 -Inf -> NaN Invalid_operation
+ddxor872 xor sNaN12 -1000 -> NaN Invalid_operation
+ddxor873 xor sNaN13 1000 -> NaN Invalid_operation
+ddxor874 xor sNaN14 NaN17 -> NaN Invalid_operation
+ddxor875 xor sNaN15 sNaN18 -> NaN Invalid_operation
+ddxor876 xor NaN16 sNaN19 -> NaN Invalid_operation
+ddxor877 xor -Inf +sNaN20 -> NaN Invalid_operation
+ddxor878 xor -1000 sNaN21 -> NaN Invalid_operation
+ddxor879 xor 1000 sNaN22 -> NaN Invalid_operation
+ddxor880 xor Inf sNaN23 -> NaN Invalid_operation
+ddxor881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
+ddxor882 xor -NaN26 NaN28 -> NaN Invalid_operation
+ddxor883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
+ddxor884 xor 1000 -NaN30 -> NaN Invalid_operation
+ddxor885 xor 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqAbs.decTest b/Lib/test/decimaltestdata/dqAbs.decTest
index baaa063bbc..f9119a9e79 100644
--- a/Lib/test/decimaltestdata/dqAbs.decTest
+++ b/Lib/test/decimaltestdata/dqAbs.decTest
@@ -1,126 +1,126 @@
-------------------------------------------------------------------------
--- dqAbs.decTest -- decQuad absolute value, heeding sNaN --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqabs001 abs '1' -> '1'
-dqabs002 abs '-1' -> '1'
-dqabs003 abs '1.00' -> '1.00'
-dqabs004 abs '-1.00' -> '1.00'
-dqabs005 abs '0' -> '0'
-dqabs006 abs '0.00' -> '0.00'
-dqabs007 abs '00.0' -> '0.0'
-dqabs008 abs '00.00' -> '0.00'
-dqabs009 abs '00' -> '0'
-
-dqabs010 abs '-2' -> '2'
-dqabs011 abs '2' -> '2'
-dqabs012 abs '-2.00' -> '2.00'
-dqabs013 abs '2.00' -> '2.00'
-dqabs014 abs '-0' -> '0'
-dqabs015 abs '-0.00' -> '0.00'
-dqabs016 abs '-00.0' -> '0.0'
-dqabs017 abs '-00.00' -> '0.00'
-dqabs018 abs '-00' -> '0'
-
-dqabs020 abs '-2000000' -> '2000000'
-dqabs021 abs '2000000' -> '2000000'
-
-dqabs030 abs '+0.1' -> '0.1'
-dqabs031 abs '-0.1' -> '0.1'
-dqabs032 abs '+0.01' -> '0.01'
-dqabs033 abs '-0.01' -> '0.01'
-dqabs034 abs '+0.001' -> '0.001'
-dqabs035 abs '-0.001' -> '0.001'
-dqabs036 abs '+0.000001' -> '0.000001'
-dqabs037 abs '-0.000001' -> '0.000001'
-dqabs038 abs '+0.000000000001' -> '1E-12'
-dqabs039 abs '-0.000000000001' -> '1E-12'
-
--- examples from decArith
-dqabs040 abs '2.1' -> '2.1'
-dqabs041 abs '-100' -> '100'
-dqabs042 abs '101.5' -> '101.5'
-dqabs043 abs '-101.5' -> '101.5'
-
--- more fixed, potential LHS swaps/overlays if done by subtract 0
-dqabs060 abs '-56267E-10' -> '0.0000056267'
-dqabs061 abs '-56267E-5' -> '0.56267'
-dqabs062 abs '-56267E-2' -> '562.67'
-dqabs063 abs '-56267E-1' -> '5626.7'
-dqabs065 abs '-56267E-0' -> '56267'
-
--- subnormals and underflow
-
--- long operand tests
-dqabs321 abs 1234567890123456 -> 1234567890123456
-dqabs322 abs 12345678000 -> 12345678000
-dqabs323 abs 1234567800 -> 1234567800
-dqabs324 abs 1234567890 -> 1234567890
-dqabs325 abs 1234567891 -> 1234567891
-dqabs326 abs 12345678901 -> 12345678901
-dqabs327 abs 1234567896 -> 1234567896
-
--- zeros
-dqabs111 abs 0 -> 0
-dqabs112 abs -0 -> 0
-dqabs113 abs 0E+6 -> 0E+6
-dqabs114 abs -0E+6 -> 0E+6
-dqabs115 abs 0.0000 -> 0.0000
-dqabs116 abs -0.0000 -> 0.0000
-dqabs117 abs 0E-141 -> 0E-141
-dqabs118 abs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqabs121 abs 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqabs122 abs -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqabs123 abs 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-dqabs124 abs -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqabs131 abs 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqabs132 abs 1E-6143 -> 1E-6143
-dqabs133 abs 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqabs134 abs 1E-6176 -> 1E-6176 Subnormal
-
-dqabs135 abs -1E-6176 -> 1E-6176 Subnormal
-dqabs136 abs -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqabs137 abs -1E-6143 -> 1E-6143
-dqabs138 abs -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-
--- specials
-dqabs520 abs 'Inf' -> 'Infinity'
-dqabs521 abs '-Inf' -> 'Infinity'
-dqabs522 abs NaN -> NaN
-dqabs523 abs sNaN -> NaN Invalid_operation
-dqabs524 abs NaN22 -> NaN22
-dqabs525 abs sNaN33 -> NaN33 Invalid_operation
-dqabs526 abs -NaN22 -> -NaN22
-dqabs527 abs -sNaN33 -> -NaN33 Invalid_operation
-
--- Null tests
-dqabs900 abs # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqAbs.decTest -- decQuad absolute value, heeding sNaN --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqabs001 abs '1' -> '1'
+dqabs002 abs '-1' -> '1'
+dqabs003 abs '1.00' -> '1.00'
+dqabs004 abs '-1.00' -> '1.00'
+dqabs005 abs '0' -> '0'
+dqabs006 abs '0.00' -> '0.00'
+dqabs007 abs '00.0' -> '0.0'
+dqabs008 abs '00.00' -> '0.00'
+dqabs009 abs '00' -> '0'
+
+dqabs010 abs '-2' -> '2'
+dqabs011 abs '2' -> '2'
+dqabs012 abs '-2.00' -> '2.00'
+dqabs013 abs '2.00' -> '2.00'
+dqabs014 abs '-0' -> '0'
+dqabs015 abs '-0.00' -> '0.00'
+dqabs016 abs '-00.0' -> '0.0'
+dqabs017 abs '-00.00' -> '0.00'
+dqabs018 abs '-00' -> '0'
+
+dqabs020 abs '-2000000' -> '2000000'
+dqabs021 abs '2000000' -> '2000000'
+
+dqabs030 abs '+0.1' -> '0.1'
+dqabs031 abs '-0.1' -> '0.1'
+dqabs032 abs '+0.01' -> '0.01'
+dqabs033 abs '-0.01' -> '0.01'
+dqabs034 abs '+0.001' -> '0.001'
+dqabs035 abs '-0.001' -> '0.001'
+dqabs036 abs '+0.000001' -> '0.000001'
+dqabs037 abs '-0.000001' -> '0.000001'
+dqabs038 abs '+0.000000000001' -> '1E-12'
+dqabs039 abs '-0.000000000001' -> '1E-12'
+
+-- examples from decArith
+dqabs040 abs '2.1' -> '2.1'
+dqabs041 abs '-100' -> '100'
+dqabs042 abs '101.5' -> '101.5'
+dqabs043 abs '-101.5' -> '101.5'
+
+-- more fixed, potential LHS swaps/overlays if done by subtract 0
+dqabs060 abs '-56267E-10' -> '0.0000056267'
+dqabs061 abs '-56267E-5' -> '0.56267'
+dqabs062 abs '-56267E-2' -> '562.67'
+dqabs063 abs '-56267E-1' -> '5626.7'
+dqabs065 abs '-56267E-0' -> '56267'
+
+-- subnormals and underflow
+
+-- long operand tests
+dqabs321 abs 1234567890123456 -> 1234567890123456
+dqabs322 abs 12345678000 -> 12345678000
+dqabs323 abs 1234567800 -> 1234567800
+dqabs324 abs 1234567890 -> 1234567890
+dqabs325 abs 1234567891 -> 1234567891
+dqabs326 abs 12345678901 -> 12345678901
+dqabs327 abs 1234567896 -> 1234567896
+
+-- zeros
+dqabs111 abs 0 -> 0
+dqabs112 abs -0 -> 0
+dqabs113 abs 0E+6 -> 0E+6
+dqabs114 abs -0E+6 -> 0E+6
+dqabs115 abs 0.0000 -> 0.0000
+dqabs116 abs -0.0000 -> 0.0000
+dqabs117 abs 0E-141 -> 0E-141
+dqabs118 abs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqabs121 abs 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqabs122 abs -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqabs123 abs 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+dqabs124 abs -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqabs131 abs 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqabs132 abs 1E-6143 -> 1E-6143
+dqabs133 abs 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqabs134 abs 1E-6176 -> 1E-6176 Subnormal
+
+dqabs135 abs -1E-6176 -> 1E-6176 Subnormal
+dqabs136 abs -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqabs137 abs -1E-6143 -> 1E-6143
+dqabs138 abs -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+
+-- specials
+dqabs520 abs 'Inf' -> 'Infinity'
+dqabs521 abs '-Inf' -> 'Infinity'
+dqabs522 abs NaN -> NaN
+dqabs523 abs sNaN -> NaN Invalid_operation
+dqabs524 abs NaN22 -> NaN22
+dqabs525 abs sNaN33 -> NaN33 Invalid_operation
+dqabs526 abs -NaN22 -> -NaN22
+dqabs527 abs -sNaN33 -> -NaN33 Invalid_operation
+
+-- Null tests
+dqabs900 abs # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqAdd.decTest b/Lib/test/decimaltestdata/dqAdd.decTest
index b1df77abc6..b3ad892bc1 100644
--- a/Lib/test/decimaltestdata/dqAdd.decTest
+++ b/Lib/test/decimaltestdata/dqAdd.decTest
@@ -1,1215 +1,1215 @@
-------------------------------------------------------------------------
--- dqAdd.decTest -- decQuad addition --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decQuads only; all arguments are
--- representable in a decQuad
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- [first group are 'quick confidence check']
-dqadd001 add 1 1 -> 2
-dqadd002 add 2 3 -> 5
-dqadd003 add '5.75' '3.3' -> 9.05
-dqadd004 add '5' '-3' -> 2
-dqadd005 add '-5' '-3' -> -8
-dqadd006 add '-7' '2.5' -> -4.5
-dqadd007 add '0.7' '0.3' -> 1.0
-dqadd008 add '1.25' '1.25' -> 2.50
-dqadd009 add '1.23456789' '1.00000000' -> '2.23456789'
-dqadd010 add '1.23456789' '1.00000011' -> '2.23456800'
-
--- 1234567890123456 1234567890123456
-dqadd011 add '0.4444444444444444444444444444444446' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqadd012 add '0.4444444444444444444444444444444445' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
-dqadd013 add '0.4444444444444444444444444444444444' '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
-dqadd014 add '4444444444444444444444444444444444' '0.49' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd015 add '4444444444444444444444444444444444' '0.499' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd016 add '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd017 add '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd018 add '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
-dqadd019 add '4444444444444444444444444444444444' '0.501' -> '4444444444444444444444444444444445' Inexact Rounded
-dqadd020 add '4444444444444444444444444444444444' '0.51' -> '4444444444444444444444444444444445' Inexact Rounded
-
-dqadd021 add 0 1 -> 1
-dqadd022 add 1 1 -> 2
-dqadd023 add 2 1 -> 3
-dqadd024 add 3 1 -> 4
-dqadd025 add 4 1 -> 5
-dqadd026 add 5 1 -> 6
-dqadd027 add 6 1 -> 7
-dqadd028 add 7 1 -> 8
-dqadd029 add 8 1 -> 9
-dqadd030 add 9 1 -> 10
-
--- some carrying effects
-dqadd031 add '0.9998' '0.0000' -> '0.9998'
-dqadd032 add '0.9998' '0.0001' -> '0.9999'
-dqadd033 add '0.9998' '0.0002' -> '1.0000'
-dqadd034 add '0.9998' '0.0003' -> '1.0001'
-
-dqadd035 add '70' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd036 add '700' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd037 add '7000' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd038 add '70000' '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
-dqadd039 add '700000' '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded
-
--- symmetry:
-dqadd040 add '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd041 add '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd042 add '10000e+34' '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd044 add '10000e+34' '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
-dqadd045 add '10000e+34' '700000' -> '1.000000000000000000000000000000007E+38' Rounded
-
--- same, without rounding
-dqadd046 add '10000e+9' '7' -> '10000000000007'
-dqadd047 add '10000e+9' '70' -> '10000000000070'
-dqadd048 add '10000e+9' '700' -> '10000000000700'
-dqadd049 add '10000e+9' '7000' -> '10000000007000'
-dqadd050 add '10000e+9' '70000' -> '10000000070000'
-dqadd051 add '10000e+9' '700000' -> '10000000700000'
-dqadd052 add '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-dqadd053 add '12' '7.00' -> '19.00'
-dqadd054 add '1.3' '-1.07' -> '0.23'
-dqadd055 add '1.3' '-1.30' -> '0.00'
-dqadd056 add '1.3' '-2.07' -> '-0.77'
-dqadd057 add '1E+2' '1E+4' -> '1.01E+4'
-
--- leading zero preservation
-dqadd061 add 1 '0.0001' -> '1.0001'
-dqadd062 add 1 '0.00001' -> '1.00001'
-dqadd063 add 1 '0.000001' -> '1.000001'
-dqadd064 add 1 '0.0000001' -> '1.0000001'
-dqadd065 add 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-dqadd070 add 1 0 -> 1
-dqadd071 add 1 0. -> 1
-dqadd072 add 1 .0 -> 1.0
-dqadd073 add 1 0.0 -> 1.0
-dqadd074 add 1 0.00 -> 1.00
-dqadd075 add 0 1 -> 1
-dqadd076 add 0. 1 -> 1
-dqadd077 add .0 1 -> 1.0
-dqadd078 add 0.0 1 -> 1.0
-dqadd079 add 0.00 1 -> 1.00
-
--- some carries
-dqadd080 add 999999998 1 -> 999999999
-dqadd081 add 999999999 1 -> 1000000000
-dqadd082 add 99999999 1 -> 100000000
-dqadd083 add 9999999 1 -> 10000000
-dqadd084 add 999999 1 -> 1000000
-dqadd085 add 99999 1 -> 100000
-dqadd086 add 9999 1 -> 10000
-dqadd087 add 999 1 -> 1000
-dqadd088 add 99 1 -> 100
-dqadd089 add 9 1 -> 10
-
-
--- more LHS swaps
-dqadd090 add '-56267E-10' 0 -> '-0.0000056267'
-dqadd091 add '-56267E-6' 0 -> '-0.056267'
-dqadd092 add '-56267E-5' 0 -> '-0.56267'
-dqadd093 add '-56267E-4' 0 -> '-5.6267'
-dqadd094 add '-56267E-3' 0 -> '-56.267'
-dqadd095 add '-56267E-2' 0 -> '-562.67'
-dqadd096 add '-56267E-1' 0 -> '-5626.7'
-dqadd097 add '-56267E-0' 0 -> '-56267'
-dqadd098 add '-5E-10' 0 -> '-5E-10'
-dqadd099 add '-5E-7' 0 -> '-5E-7'
-dqadd100 add '-5E-6' 0 -> '-0.000005'
-dqadd101 add '-5E-5' 0 -> '-0.00005'
-dqadd102 add '-5E-4' 0 -> '-0.0005'
-dqadd103 add '-5E-1' 0 -> '-0.5'
-dqadd104 add '-5E0' 0 -> '-5'
-dqadd105 add '-5E1' 0 -> '-50'
-dqadd106 add '-5E5' 0 -> '-500000'
-dqadd107 add '-5E33' 0 -> '-5000000000000000000000000000000000'
-dqadd108 add '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
-dqadd109 add '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
-dqadd110 add '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
-dqadd111 add '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- more RHS swaps
-dqadd113 add 0 '-56267E-10' -> '-0.0000056267'
-dqadd114 add 0 '-56267E-6' -> '-0.056267'
-dqadd116 add 0 '-56267E-5' -> '-0.56267'
-dqadd117 add 0 '-56267E-4' -> '-5.6267'
-dqadd119 add 0 '-56267E-3' -> '-56.267'
-dqadd120 add 0 '-56267E-2' -> '-562.67'
-dqadd121 add 0 '-56267E-1' -> '-5626.7'
-dqadd122 add 0 '-56267E-0' -> '-56267'
-dqadd123 add 0 '-5E-10' -> '-5E-10'
-dqadd124 add 0 '-5E-7' -> '-5E-7'
-dqadd125 add 0 '-5E-6' -> '-0.000005'
-dqadd126 add 0 '-5E-5' -> '-0.00005'
-dqadd127 add 0 '-5E-4' -> '-0.0005'
-dqadd128 add 0 '-5E-1' -> '-0.5'
-dqadd129 add 0 '-5E0' -> '-5'
-dqadd130 add 0 '-5E1' -> '-50'
-dqadd131 add 0 '-5E5' -> '-500000'
-dqadd132 add 0 '-5E33' -> '-5000000000000000000000000000000000'
-dqadd133 add 0 '-5E34' -> '-5.000000000000000000000000000000000E+34' Rounded
-dqadd134 add 0 '-5E35' -> '-5.000000000000000000000000000000000E+35' Rounded
-dqadd135 add 0 '-5E36' -> '-5.000000000000000000000000000000000E+36' Rounded
-dqadd136 add 0 '-5E100' -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- related
-dqadd137 add 1 '0E-39' -> '1.000000000000000000000000000000000' Rounded
-dqadd138 add -1 '0E-39' -> '-1.000000000000000000000000000000000' Rounded
-dqadd139 add '0E-39' 1 -> '1.000000000000000000000000000000000' Rounded
-dqadd140 add '0E-39' -1 -> '-1.000000000000000000000000000000000' Rounded
-dqadd141 add 1E+29 0.0000 -> '100000000000000000000000000000.0000'
-dqadd142 add 1E+29 0.00000 -> '100000000000000000000000000000.0000' Rounded
-dqadd143 add 0.000 1E+30 -> '1000000000000000000000000000000.000'
-dqadd144 add 0.0000 1E+30 -> '1000000000000000000000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-dqadd146 add '00.0' 0 -> '0.0'
-dqadd147 add '0.00' 0 -> '0.00'
-dqadd148 add 0 '0.00' -> '0.00'
-dqadd149 add 0 '00.0' -> '0.0'
-dqadd150 add '00.0' '0.00' -> '0.00'
-dqadd151 add '0.00' '00.0' -> '0.00'
-dqadd152 add '3' '.3' -> '3.3'
-dqadd153 add '3.' '.3' -> '3.3'
-dqadd154 add '3.0' '.3' -> '3.3'
-dqadd155 add '3.00' '.3' -> '3.30'
-dqadd156 add '3' '3' -> '6'
-dqadd157 add '3' '+3' -> '6'
-dqadd158 add '3' '-3' -> '0'
-dqadd159 add '0.3' '-0.3' -> '0.0'
-dqadd160 add '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-dqadd161 add '1E+12' '-1' -> '999999999999'
-dqadd162 add '1E+12' '1.11' -> '1000000000001.11'
-dqadd163 add '1.11' '1E+12' -> '1000000000001.11'
-dqadd164 add '-1' '1E+12' -> '999999999999'
-dqadd165 add '7E+12' '-1' -> '6999999999999'
-dqadd166 add '7E+12' '1.11' -> '7000000000001.11'
-dqadd167 add '1.11' '7E+12' -> '7000000000001.11'
-dqadd168 add '-1' '7E+12' -> '6999999999999'
-
-rounding: half_up
-dqadd170 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd171 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd172 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd173 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
-dqadd174 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd175 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd176 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd177 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
-dqadd178 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd179 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd180 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd181 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd182 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd183 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-dqadd200 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd201 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd202 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd203 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd204 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd205 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd206 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd207 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd208 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd209 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd210 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd211 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd212 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd213 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd214 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd215 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd216 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd217 add '1231234567890123456784560123456789' 1.000000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd218 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd219 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
-
-rounding: half_even
-dqadd220 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd221 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd222 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd223 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd224 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd225 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd226 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd227 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd228 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd229 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd230 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd231 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd232 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd233 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd234 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd235 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd236 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd237 add '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd238 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd239 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
--- critical few with even bottom digit...
-dqadd240 add '1231234567890123456784560123456788' 0.499999999 -> '1231234567890123456784560123456788' Inexact Rounded
-dqadd241 add '1231234567890123456784560123456788' 0.5 -> '1231234567890123456784560123456788' Inexact Rounded
-dqadd242 add '1231234567890123456784560123456788' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
-
-rounding: down
-dqadd250 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd251 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd252 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd253 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd254 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd255 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd256 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd257 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd258 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd259 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd260 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd261 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd262 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd263 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd264 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd265 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd266 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd267 add '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd268 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd269 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-dqadd301 add -1 1 -> 0
-dqadd302 add 0 1 -> 1
-dqadd303 add 1 1 -> 2
-dqadd304 add 12 1 -> 13
-dqadd305 add 98 1 -> 99
-dqadd306 add 99 1 -> 100
-dqadd307 add 100 1 -> 101
-dqadd308 add 101 1 -> 102
-dqadd309 add -1 -1 -> -2
-dqadd310 add 0 -1 -> -1
-dqadd311 add 1 -1 -> 0
-dqadd312 add 12 -1 -> 11
-dqadd313 add 98 -1 -> 97
-dqadd314 add 99 -1 -> 98
-dqadd315 add 100 -1 -> 99
-dqadd316 add 101 -1 -> 100
-
-dqadd321 add -0.01 0.01 -> 0.00
-dqadd322 add 0.00 0.01 -> 0.01
-dqadd323 add 0.01 0.01 -> 0.02
-dqadd324 add 0.12 0.01 -> 0.13
-dqadd325 add 0.98 0.01 -> 0.99
-dqadd326 add 0.99 0.01 -> 1.00
-dqadd327 add 1.00 0.01 -> 1.01
-dqadd328 add 1.01 0.01 -> 1.02
-dqadd329 add -0.01 -0.01 -> -0.02
-dqadd330 add 0.00 -0.01 -> -0.01
-dqadd331 add 0.01 -0.01 -> 0.00
-dqadd332 add 0.12 -0.01 -> 0.11
-dqadd333 add 0.98 -0.01 -> 0.97
-dqadd334 add 0.99 -0.01 -> 0.98
-dqadd335 add 1.00 -0.01 -> 0.99
-dqadd336 add 1.01 -0.01 -> 1.00
-
--- some more cases where adding 0 affects the coefficient
-dqadd340 add 1E+3 0 -> 1000
-dqadd341 add 1E+33 0 -> 1000000000000000000000000000000000
-dqadd342 add 1E+34 0 -> 1.000000000000000000000000000000000E+34 Rounded
-dqadd343 add 1E+35 0 -> 1.000000000000000000000000000000000E+35 Rounded
--- which simply follow from these cases ...
-dqadd344 add 1E+3 1 -> 1001
-dqadd345 add 1E+33 1 -> 1000000000000000000000000000000001
-dqadd346 add 1E+34 1 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd347 add 1E+35 1 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
-dqadd348 add 1E+3 7 -> 1007
-dqadd349 add 1E+33 7 -> 1000000000000000000000000000000007
-dqadd350 add 1E+34 7 -> 1.000000000000000000000000000000001E+34 Inexact Rounded
-dqadd351 add 1E+35 7 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
-
--- tryzeros cases
-rounding: half_up
-dqadd360 add 0E+50 10000E+1 -> 1.0000E+5
-dqadd361 add 0E-50 10000E+1 -> 100000.0000000000000000000000000000 Rounded
-dqadd362 add 10000E+1 0E-50 -> 100000.0000000000000000000000000000 Rounded
-dqadd363 add 10000E+1 10000E-50 -> 100000.0000000000000000000000000000 Rounded Inexact
-dqadd364 add 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
--- 1 234567890123456789012345678901234
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-dqadd370 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd371 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-rounding: half_up
-dqadd372 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd373 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-rounding: half_even
-dqadd374 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd375 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-
--- ulp replacement tests
-dqadd400 add 1 77e-32 -> 1.00000000000000000000000000000077
-dqadd401 add 1 77e-33 -> 1.000000000000000000000000000000077
-dqadd402 add 1 77e-34 -> 1.000000000000000000000000000000008 Inexact Rounded
-dqadd403 add 1 77e-35 -> 1.000000000000000000000000000000001 Inexact Rounded
-dqadd404 add 1 77e-36 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd405 add 1 77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd406 add 1 77e-299 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd410 add 10 77e-32 -> 10.00000000000000000000000000000077
-dqadd411 add 10 77e-33 -> 10.00000000000000000000000000000008 Inexact Rounded
-dqadd412 add 10 77e-34 -> 10.00000000000000000000000000000001 Inexact Rounded
-dqadd413 add 10 77e-35 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd414 add 10 77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd415 add 10 77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd416 add 10 77e-299 -> 10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd420 add 77e-32 1 -> 1.00000000000000000000000000000077
-dqadd421 add 77e-33 1 -> 1.000000000000000000000000000000077
-dqadd422 add 77e-34 1 -> 1.000000000000000000000000000000008 Inexact Rounded
-dqadd423 add 77e-35 1 -> 1.000000000000000000000000000000001 Inexact Rounded
-dqadd424 add 77e-36 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd425 add 77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd426 add 77e-299 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd430 add 77e-32 10 -> 10.00000000000000000000000000000077
-dqadd431 add 77e-33 10 -> 10.00000000000000000000000000000008 Inexact Rounded
-dqadd432 add 77e-34 10 -> 10.00000000000000000000000000000001 Inexact Rounded
-dqadd433 add 77e-35 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd434 add 77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd435 add 77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd436 add 77e-299 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-
--- fastpath boundaries
--- 1234567890123456789012345678901234
-dqadd501 add '4444444444444444444444444444444444' '5555555555555555555555555555555555' -> '9999999999999999999999999999999999'
-dqadd502 add '4444444444444444444444444444444444' '4555555555555555555555555555555555' -> '8999999999999999999999999999999999'
-dqadd503 add '4444444444444444444444444444444444' '3555555555555555555055555555555555' -> '7999999999999999999499999999999999'
-dqadd504 add '4444444444444444444444444444444444' '3955555555555555555555555555555555' -> '8399999999999999999999999999999999'
-dqadd505 add '4444444444444444444444444444444444' '4955555555555555555555555555555555' -> '9399999999999999999999999999999999'
-dqadd506 add '4444444444444444444444444444444444' '5955555555555555555555555555555555' -> 1.040000000000000000000000000000000E+34 Inexact Rounded
-dqadd511 add '344444444444444444444444444444444' '555555555555555555555555555555555' -> '899999999999999999999999999999999'
-dqadd512 add '34444444444444444444444444444444' '55555555555555555555555555555555' -> '89999999999999999999999999999999'
-dqadd513 add '3444444444444444444444444444444' '5555555555555555555555555555555' -> '8999999999999999999999999999999'
-dqadd514 add '344444444444444444444444444444' '555555555555555555555555555555' -> '899999999999999999999999999999'
-dqadd515 add '34444444444444444444444444444' '55555555555555555555555555555' -> '89999999999999999999999999999'
-dqadd516 add '3444444444444444444444444444' '5555555555555555555555555555' -> '8999999999999999999999999999'
-dqadd517 add '344444444444444444444444444' '555555555555555555555555555' -> '899999999999999999999999999'
-dqadd518 add '34444444444444444444444444' '55555555555555555555555555' -> '89999999999999999999999999'
-dqadd519 add '3444444444444444444444444' '5555555555555555555555555' -> '8999999999999999999999999'
-dqadd520 add '344444444444444444444444' '555555555555555555555555' -> '899999999999999999999999'
-dqadd521 add '34444444444444444444444' '55555555555555555555555' -> '89999999999999999999999'
-dqadd522 add '3444444444444444444444' '5555555555555555555555' -> '8999999999999999999999'
-dqadd523 add '4444444444444444444444' '3333333333333333333333' -> '7777777777777777777777'
-dqadd524 add '344444444444444444444' '555555555555555555555' -> '899999999999999999999'
-dqadd525 add '34444444444444444444' '55555555555555555555' -> '89999999999999999999'
-dqadd526 add '3444444444444444444' '5555555555555555555' -> '8999999999999999999'
-dqadd527 add '344444444444444444' '555555555555555555' -> '899999999999999999'
-dqadd528 add '34444444444444444' '55555555555555555' -> '89999999999999999'
-dqadd529 add '3444444444444444' '5555555555555555' -> '8999999999999999'
-dqadd530 add '344444444444444' '555555555555555' -> '899999999999999'
-dqadd531 add '34444444444444' '55555555555555' -> '89999999999999'
-dqadd532 add '3444444444444' '5555555555555' -> '8999999999999'
-dqadd533 add '344444444444' '555555555555' -> '899999999999'
-dqadd534 add '34444444444' '55555555555' -> '89999999999'
-dqadd535 add '3444444444' '5555555555' -> '8999999999'
-dqadd536 add '344444444' '555555555' -> '899999999'
-dqadd537 add '34444444' '55555555' -> '89999999'
-dqadd538 add '3444444' '5555555' -> '8999999'
-dqadd539 add '344444' '555555' -> '899999'
-dqadd540 add '34444' '55555' -> '89999'
-dqadd541 add '3444' '5555' -> '8999'
-dqadd542 add '344' '555' -> '899'
-dqadd543 add '34' '55' -> '89'
-dqadd544 add '3' '5' -> '8'
-
-dqadd545 add '3000004000000000000000000000000000' '3000000000000040000000000000000000' -> '6000004000000040000000000000000000'
-dqadd546 add '3000000400000000000000000000000000' '4000000000000400000000000000000000' -> '7000000400000400000000000000000000'
-dqadd547 add '3000000040000000000000000000000000' '5000000000004000000000000000000000' -> '8000000040004000000000000000000000'
-dqadd548 add '4000000004000000000000000000000000' '3000000000040000000000000000000000' -> '7000000004040000000000000000000000'
-dqadd549 add '4000000000400000000000000000000000' '4000000000400000000000000000000000' -> '8000000000800000000000000000000000'
-dqadd550 add '4000000000040000000000000000000000' '5000000004000000000000000000000000' -> '9000000004040000000000000000000000'
-dqadd551 add '5000000000004000000000000000000000' '3000000040000000000000000000000000' -> '8000000040004000000000000000000000'
-dqadd552 add '5000000000000400000000000000000000' '4000000400000000000000000000000000' -> '9000000400000400000000000000000000'
-dqadd553 add '5000000000000040000000000000000000' '5000004000000000000000000000000000' -> 1.000000400000004000000000000000000E+34 Rounded
--- check propagation
-dqadd554 add '8999999999999999999999999999999999' '0000000000000000000000000000000001' -> 9000000000000000000000000000000000
-dqadd555 add '0000000000000000000000000000000001' '8999999999999999999999999999999999' -> 9000000000000000000000000000000000
-dqadd556 add '4444444444444444444444444444444444' '4555555555555555555555555555555556' -> 9000000000000000000000000000000000
-dqadd557 add '4555555555555555555555555555555556' '4444444444444444444444444444444444' -> 9000000000000000000000000000000000
-
--- negative ulps
-dqadd6440 add 1 -77e-32 -> 0.99999999999999999999999999999923
-dqadd6441 add 1 -77e-33 -> 0.999999999999999999999999999999923
-dqadd6442 add 1 -77e-34 -> 0.9999999999999999999999999999999923
-dqadd6443 add 1 -77e-35 -> 0.9999999999999999999999999999999992 Inexact Rounded
-dqadd6444 add 1 -77e-36 -> 0.9999999999999999999999999999999999 Inexact Rounded
-dqadd6445 add 1 -77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd6446 add 1 -77e-99 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd6450 add 10 -77e-32 -> 9.99999999999999999999999999999923
-dqadd6451 add 10 -77e-33 -> 9.999999999999999999999999999999923
-dqadd6452 add 10 -77e-34 -> 9.999999999999999999999999999999992 Inexact Rounded
-dqadd6453 add 10 -77e-35 -> 9.999999999999999999999999999999999 Inexact Rounded
-dqadd6454 add 10 -77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd6455 add 10 -77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd6456 add 10 -77e-99 -> 10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd6460 add -77e-32 1 -> 0.99999999999999999999999999999923
-dqadd6461 add -77e-33 1 -> 0.999999999999999999999999999999923
-dqadd6462 add -77e-34 1 -> 0.9999999999999999999999999999999923
-dqadd6463 add -77e-35 1 -> 0.9999999999999999999999999999999992 Inexact Rounded
-dqadd6464 add -77e-36 1 -> 0.9999999999999999999999999999999999 Inexact Rounded
-dqadd6465 add -77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd6466 add -77e-99 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd6470 add -77e-32 10 -> 9.99999999999999999999999999999923
-dqadd6471 add -77e-33 10 -> 9.999999999999999999999999999999923
-dqadd6472 add -77e-34 10 -> 9.999999999999999999999999999999992 Inexact Rounded
-dqadd6473 add -77e-35 10 -> 9.999999999999999999999999999999999 Inexact Rounded
-dqadd6474 add -77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd6475 add -77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd6476 add -77e-99 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-
--- negative ulps
-dqadd6480 add -1 77e-32 -> -0.99999999999999999999999999999923
-dqadd6481 add -1 77e-33 -> -0.999999999999999999999999999999923
-dqadd6482 add -1 77e-34 -> -0.9999999999999999999999999999999923
-dqadd6483 add -1 77e-35 -> -0.9999999999999999999999999999999992 Inexact Rounded
-dqadd6484 add -1 77e-36 -> -0.9999999999999999999999999999999999 Inexact Rounded
-dqadd6485 add -1 77e-37 -> -1.000000000000000000000000000000000 Inexact Rounded
-dqadd6486 add -1 77e-99 -> -1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd6490 add -10 77e-32 -> -9.99999999999999999999999999999923
-dqadd6491 add -10 77e-33 -> -9.999999999999999999999999999999923
-dqadd6492 add -10 77e-34 -> -9.999999999999999999999999999999992 Inexact Rounded
-dqadd6493 add -10 77e-35 -> -9.999999999999999999999999999999999 Inexact Rounded
-dqadd6494 add -10 77e-36 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd6495 add -10 77e-37 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd6496 add -10 77e-99 -> -10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd6500 add 77e-32 -1 -> -0.99999999999999999999999999999923
-dqadd6501 add 77e-33 -1 -> -0.999999999999999999999999999999923
-dqadd6502 add 77e-34 -1 -> -0.9999999999999999999999999999999923
-dqadd6503 add 77e-35 -1 -> -0.9999999999999999999999999999999992 Inexact Rounded
-dqadd6504 add 77e-36 -1 -> -0.9999999999999999999999999999999999 Inexact Rounded
-dqadd6505 add 77e-37 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
-dqadd6506 add 77e-99 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd6510 add 77e-32 -10 -> -9.99999999999999999999999999999923
-dqadd6511 add 77e-33 -10 -> -9.999999999999999999999999999999923
-dqadd6512 add 77e-34 -10 -> -9.999999999999999999999999999999992 Inexact Rounded
-dqadd6513 add 77e-35 -10 -> -9.999999999999999999999999999999999 Inexact Rounded
-dqadd6514 add 77e-36 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd6515 add 77e-37 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd6516 add 77e-99 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-
--- and some more residue effects and different roundings
-rounding: half_up
-dqadd6540 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd6541 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6542 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6543 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6544 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6545 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6546 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6547 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6548 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6549 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6550 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6551 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6552 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6553 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6554 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6555 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6556 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd6557 add '9876543219876543216543210123456789' 1.000000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6558 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6559 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
-rounding: half_even
-dqadd6560 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd6561 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6562 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6563 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6564 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6565 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6566 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6567 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6568 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6569 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6570 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6571 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6572 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6573 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6574 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6575 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6576 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd6577 add '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6578 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6579 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
--- critical few with even bottom digit...
-dqadd7540 add '9876543219876543216543210123456788' 0.499999999 -> '9876543219876543216543210123456788' Inexact Rounded
-dqadd7541 add '9876543219876543216543210123456788' 0.5 -> '9876543219876543216543210123456788' Inexact Rounded
-dqadd7542 add '9876543219876543216543210123456788' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
-
-rounding: down
-dqadd7550 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd7551 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7552 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7553 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7554 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7555 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7556 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7557 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7558 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7559 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7560 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7561 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7562 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7563 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7564 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7565 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7566 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd7567 add '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd7568 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd7569 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-dqadd7701 add 5.00 1.00E-3 -> 5.00100
-dqadd7702 add 00.00 0.000 -> 0.000
-dqadd7703 add 00.00 0E-3 -> 0.000
-dqadd7704 add 0E-3 00.00 -> 0.000
-
-dqadd7710 add 0E+3 00.00 -> 0.00
-dqadd7711 add 0E+3 00.0 -> 0.0
-dqadd7712 add 0E+3 00. -> 0
-dqadd7713 add 0E+3 00.E+1 -> 0E+1
-dqadd7714 add 0E+3 00.E+2 -> 0E+2
-dqadd7715 add 0E+3 00.E+3 -> 0E+3
-dqadd7716 add 0E+3 00.E+4 -> 0E+3
-dqadd7717 add 0E+3 00.E+5 -> 0E+3
-dqadd7718 add 0E+3 -00.0 -> 0.0
-dqadd7719 add 0E+3 -00. -> 0
-dqadd7731 add 0E+3 -00.E+1 -> 0E+1
-
-dqadd7720 add 00.00 0E+3 -> 0.00
-dqadd7721 add 00.0 0E+3 -> 0.0
-dqadd7722 add 00. 0E+3 -> 0
-dqadd7723 add 00.E+1 0E+3 -> 0E+1
-dqadd7724 add 00.E+2 0E+3 -> 0E+2
-dqadd7725 add 00.E+3 0E+3 -> 0E+3
-dqadd7726 add 00.E+4 0E+3 -> 0E+3
-dqadd7727 add 00.E+5 0E+3 -> 0E+3
-dqadd7728 add -00.00 0E+3 -> 0.00
-dqadd7729 add -00.0 0E+3 -> 0.0
-dqadd7730 add -00. 0E+3 -> 0
-
-dqadd7732 add 0 0 -> 0
-dqadd7733 add 0 -0 -> 0
-dqadd7734 add -0 0 -> 0
-dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case
-
-dqadd7736 add 1 -1 -> 0
-dqadd7737 add -1 -1 -> -2
-dqadd7738 add 1 1 -> 2
-dqadd7739 add -1 1 -> 0
-
-dqadd7741 add 0 -1 -> -1
-dqadd7742 add -0 -1 -> -1
-dqadd7743 add 0 1 -> 1
-dqadd7744 add -0 1 -> 1
-dqadd7745 add -1 0 -> -1
-dqadd7746 add -1 -0 -> -1
-dqadd7747 add 1 0 -> 1
-dqadd7748 add 1 -0 -> 1
-
-dqadd7751 add 0.0 -1 -> -1.0
-dqadd7752 add -0.0 -1 -> -1.0
-dqadd7753 add 0.0 1 -> 1.0
-dqadd7754 add -0.0 1 -> 1.0
-dqadd7755 add -1.0 0 -> -1.0
-dqadd7756 add -1.0 -0 -> -1.0
-dqadd7757 add 1.0 0 -> 1.0
-dqadd7758 add 1.0 -0 -> 1.0
-
-dqadd7761 add 0 -1.0 -> -1.0
-dqadd7762 add -0 -1.0 -> -1.0
-dqadd7763 add 0 1.0 -> 1.0
-dqadd7764 add -0 1.0 -> 1.0
-dqadd7765 add -1 0.0 -> -1.0
-dqadd7766 add -1 -0.0 -> -1.0
-dqadd7767 add 1 0.0 -> 1.0
-dqadd7768 add 1 -0.0 -> 1.0
-
-dqadd7771 add 0.0 -1.0 -> -1.0
-dqadd7772 add -0.0 -1.0 -> -1.0
-dqadd7773 add 0.0 1.0 -> 1.0
-dqadd7774 add -0.0 1.0 -> 1.0
-dqadd7775 add -1.0 0.0 -> -1.0
-dqadd7776 add -1.0 -0.0 -> -1.0
-dqadd7777 add 1.0 0.0 -> 1.0
-dqadd7778 add 1.0 -0.0 -> 1.0
-
--- Specials
-dqadd7780 add -Inf -Inf -> -Infinity
-dqadd7781 add -Inf -1000 -> -Infinity
-dqadd7782 add -Inf -1 -> -Infinity
-dqadd7783 add -Inf -0 -> -Infinity
-dqadd7784 add -Inf 0 -> -Infinity
-dqadd7785 add -Inf 1 -> -Infinity
-dqadd7786 add -Inf 1000 -> -Infinity
-dqadd7787 add -1000 -Inf -> -Infinity
-dqadd7788 add -Inf -Inf -> -Infinity
-dqadd7789 add -1 -Inf -> -Infinity
-dqadd7790 add -0 -Inf -> -Infinity
-dqadd7791 add 0 -Inf -> -Infinity
-dqadd7792 add 1 -Inf -> -Infinity
-dqadd7793 add 1000 -Inf -> -Infinity
-dqadd7794 add Inf -Inf -> NaN Invalid_operation
-
-dqadd7800 add Inf -Inf -> NaN Invalid_operation
-dqadd7801 add Inf -1000 -> Infinity
-dqadd7802 add Inf -1 -> Infinity
-dqadd7803 add Inf -0 -> Infinity
-dqadd7804 add Inf 0 -> Infinity
-dqadd7805 add Inf 1 -> Infinity
-dqadd7806 add Inf 1000 -> Infinity
-dqadd7807 add Inf Inf -> Infinity
-dqadd7808 add -1000 Inf -> Infinity
-dqadd7809 add -Inf Inf -> NaN Invalid_operation
-dqadd7810 add -1 Inf -> Infinity
-dqadd7811 add -0 Inf -> Infinity
-dqadd7812 add 0 Inf -> Infinity
-dqadd7813 add 1 Inf -> Infinity
-dqadd7814 add 1000 Inf -> Infinity
-dqadd7815 add Inf Inf -> Infinity
-
-dqadd7821 add NaN -Inf -> NaN
-dqadd7822 add NaN -1000 -> NaN
-dqadd7823 add NaN -1 -> NaN
-dqadd7824 add NaN -0 -> NaN
-dqadd7825 add NaN 0 -> NaN
-dqadd7826 add NaN 1 -> NaN
-dqadd7827 add NaN 1000 -> NaN
-dqadd7828 add NaN Inf -> NaN
-dqadd7829 add NaN NaN -> NaN
-dqadd7830 add -Inf NaN -> NaN
-dqadd7831 add -1000 NaN -> NaN
-dqadd7832 add -1 NaN -> NaN
-dqadd7833 add -0 NaN -> NaN
-dqadd7834 add 0 NaN -> NaN
-dqadd7835 add 1 NaN -> NaN
-dqadd7836 add 1000 NaN -> NaN
-dqadd7837 add Inf NaN -> NaN
-
-dqadd7841 add sNaN -Inf -> NaN Invalid_operation
-dqadd7842 add sNaN -1000 -> NaN Invalid_operation
-dqadd7843 add sNaN -1 -> NaN Invalid_operation
-dqadd7844 add sNaN -0 -> NaN Invalid_operation
-dqadd7845 add sNaN 0 -> NaN Invalid_operation
-dqadd7846 add sNaN 1 -> NaN Invalid_operation
-dqadd7847 add sNaN 1000 -> NaN Invalid_operation
-dqadd7848 add sNaN NaN -> NaN Invalid_operation
-dqadd7849 add sNaN sNaN -> NaN Invalid_operation
-dqadd7850 add NaN sNaN -> NaN Invalid_operation
-dqadd7851 add -Inf sNaN -> NaN Invalid_operation
-dqadd7852 add -1000 sNaN -> NaN Invalid_operation
-dqadd7853 add -1 sNaN -> NaN Invalid_operation
-dqadd7854 add -0 sNaN -> NaN Invalid_operation
-dqadd7855 add 0 sNaN -> NaN Invalid_operation
-dqadd7856 add 1 sNaN -> NaN Invalid_operation
-dqadd7857 add 1000 sNaN -> NaN Invalid_operation
-dqadd7858 add Inf sNaN -> NaN Invalid_operation
-dqadd7859 add NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqadd7861 add NaN1 -Inf -> NaN1
-dqadd7862 add +NaN2 -1000 -> NaN2
-dqadd7863 add NaN3 1000 -> NaN3
-dqadd7864 add NaN4 Inf -> NaN4
-dqadd7865 add NaN5 +NaN6 -> NaN5
-dqadd7866 add -Inf NaN7 -> NaN7
-dqadd7867 add -1000 NaN8 -> NaN8
-dqadd7868 add 1000 NaN9 -> NaN9
-dqadd7869 add Inf +NaN10 -> NaN10
-dqadd7871 add sNaN11 -Inf -> NaN11 Invalid_operation
-dqadd7872 add sNaN12 -1000 -> NaN12 Invalid_operation
-dqadd7873 add sNaN13 1000 -> NaN13 Invalid_operation
-dqadd7874 add sNaN14 NaN17 -> NaN14 Invalid_operation
-dqadd7875 add sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqadd7876 add NaN16 sNaN19 -> NaN19 Invalid_operation
-dqadd7877 add -Inf +sNaN20 -> NaN20 Invalid_operation
-dqadd7878 add -1000 sNaN21 -> NaN21 Invalid_operation
-dqadd7879 add 1000 sNaN22 -> NaN22 Invalid_operation
-dqadd7880 add Inf sNaN23 -> NaN23 Invalid_operation
-dqadd7881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqadd7882 add -NaN26 NaN28 -> -NaN26
-dqadd7883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqadd7884 add 1000 -NaN30 -> -NaN30
-dqadd7885 add 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Here we explore near the boundary of rounding a subnormal to Nmin
-dqadd7575 add 1E-6143 -1E-6176 -> 9.99999999999999999999999999999999E-6144 Subnormal
-dqadd7576 add -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal
-
--- check overflow edge case
--- 1234567890123456
-dqadd7972 apply 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqadd7973 add 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7974 add 9999999999999999999999999999999999E+6111 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7975 add 9999999999999999999999999999999999E+6111 1E+6111 -> Infinity Overflow Inexact Rounded
-dqadd7976 add 9999999999999999999999999999999999E+6111 9E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7977 add 9999999999999999999999999999999999E+6111 8E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7978 add 9999999999999999999999999999999999E+6111 7E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7979 add 9999999999999999999999999999999999E+6111 6E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7980 add 9999999999999999999999999999999999E+6111 5E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7981 add 9999999999999999999999999999999999E+6111 4E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7982 add 9999999999999999999999999999999999E+6111 3E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7983 add 9999999999999999999999999999999999E+6111 2E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7984 add 9999999999999999999999999999999999E+6111 1E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-
-dqadd7985 apply -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqadd7986 add -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7987 add -9999999999999999999999999999999999E+6111 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7988 add -9999999999999999999999999999999999E+6111 -1E+6111 -> -Infinity Overflow Inexact Rounded
-dqadd7989 add -9999999999999999999999999999999999E+6111 -9E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7990 add -9999999999999999999999999999999999E+6111 -8E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7991 add -9999999999999999999999999999999999E+6111 -7E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7992 add -9999999999999999999999999999999999E+6111 -6E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7993 add -9999999999999999999999999999999999E+6111 -5E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7994 add -9999999999999999999999999999999999E+6111 -4E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7995 add -9999999999999999999999999999999999E+6111 -3E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7996 add -9999999999999999999999999999999999E+6111 -2E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7997 add -9999999999999999999999999999999999E+6111 -1E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-dqadd71100 add 1e+2 -1e-6143 -> 99.99999999999999999999999999999999 Rounded Inexact
-dqadd71101 add 1e+1 -1e-6143 -> 9.999999999999999999999999999999999 Rounded Inexact
-dqadd71103 add +1 -1e-6143 -> 0.9999999999999999999999999999999999 Rounded Inexact
-dqadd71104 add 1e-1 -1e-6143 -> 0.09999999999999999999999999999999999 Rounded Inexact
-dqadd71105 add 1e-2 -1e-6143 -> 0.009999999999999999999999999999999999 Rounded Inexact
-dqadd71106 add 1e-3 -1e-6143 -> 0.0009999999999999999999999999999999999 Rounded Inexact
-dqadd71107 add 1e-4 -1e-6143 -> 0.00009999999999999999999999999999999999 Rounded Inexact
-dqadd71108 add 1e-5 -1e-6143 -> 0.000009999999999999999999999999999999999 Rounded Inexact
-dqadd71109 add 1e-6 -1e-6143 -> 9.999999999999999999999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-dqadd71110 add -1e+2 +1e-6143 -> -99.99999999999999999999999999999999 Rounded Inexact
-dqadd71111 add -1e+1 +1e-6143 -> -9.999999999999999999999999999999999 Rounded Inexact
-dqadd71113 add -1 +1e-6143 -> -0.9999999999999999999999999999999999 Rounded Inexact
-dqadd71114 add -1e-1 +1e-6143 -> -0.09999999999999999999999999999999999 Rounded Inexact
-dqadd71115 add -1e-2 +1e-6143 -> -0.009999999999999999999999999999999999 Rounded Inexact
-dqadd71116 add -1e-3 +1e-6143 -> -0.0009999999999999999999999999999999999 Rounded Inexact
-dqadd71117 add -1e-4 +1e-6143 -> -0.00009999999999999999999999999999999999 Rounded Inexact
-dqadd71118 add -1e-5 +1e-6143 -> -0.000009999999999999999999999999999999999 Rounded Inexact
-dqadd71119 add -1e-6 +1e-6143 -> -9.999999999999999999999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-dqadd71300 add 1E34 -0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71310 add 1E34 -0.51 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71311 add 1E34 -0.501 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71312 add 1E34 -0.5001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71313 add 1E34 -0.50001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71314 add 1E34 -0.500001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71315 add 1E34 -0.5000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71316 add 1E34 -0.50000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71317 add 1E34 -0.500000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71318 add 1E34 -0.5000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71319 add 1E34 -0.50000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71320 add 1E34 -0.500000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71321 add 1E34 -0.5000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71322 add 1E34 -0.50000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71323 add 1E34 -0.500000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71324 add 1E34 -0.5000000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71325 add 1E34 -0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71326 add 1E34 -0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71327 add 1E34 -0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71328 add 1E34 -0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71329 add 1E34 -0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71330 add 1E34 -0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71331 add 1E34 -0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71332 add 1E34 -0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71333 add 1E34 -0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71334 add 1E34 -0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71335 add 1E34 -0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71336 add 1E34 -0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71337 add 1E34 -0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71338 add 1E34 -0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71339 add 1E34 -0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-
-dqadd71340 add 1E34 -5000000.000010001 -> 9999999999999999999999999995000000 Inexact Rounded
-dqadd71341 add 1E34 -5000000.000000001 -> 9999999999999999999999999995000000 Inexact Rounded
-
-dqadd71349 add 9999999999999999999999999999999999 0.4 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71350 add 9999999999999999999999999999999999 0.49 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71351 add 9999999999999999999999999999999999 0.499 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71352 add 9999999999999999999999999999999999 0.4999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71353 add 9999999999999999999999999999999999 0.49999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71354 add 9999999999999999999999999999999999 0.499999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71355 add 9999999999999999999999999999999999 0.4999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71356 add 9999999999999999999999999999999999 0.49999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71357 add 9999999999999999999999999999999999 0.499999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71358 add 9999999999999999999999999999999999 0.4999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71359 add 9999999999999999999999999999999999 0.49999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71360 add 9999999999999999999999999999999999 0.499999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71361 add 9999999999999999999999999999999999 0.4999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71362 add 9999999999999999999999999999999999 0.49999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71363 add 9999999999999999999999999999999999 0.499999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71364 add 9999999999999999999999999999999999 0.4999999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71365 add 9999999999999999999999999999999999 0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71367 add 9999999999999999999999999999999999 0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71368 add 9999999999999999999999999999999999 0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71369 add 9999999999999999999999999999999999 0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71370 add 9999999999999999999999999999999999 0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71371 add 9999999999999999999999999999999999 0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71372 add 9999999999999999999999999999999999 0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71373 add 9999999999999999999999999999999999 0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71374 add 9999999999999999999999999999999999 0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71375 add 9999999999999999999999999999999999 0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71376 add 9999999999999999999999999999999999 0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71377 add 9999999999999999999999999999999999 0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71378 add 9999999999999999999999999999999999 0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71379 add 9999999999999999999999999999999999 0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71380 add 9999999999999999999999999999999999 0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71381 add 9999999999999999999999999999999999 0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71382 add 9999999999999999999999999999999999 0.5000000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71383 add 9999999999999999999999999999999999 0.500000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71384 add 9999999999999999999999999999999999 0.50000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71385 add 9999999999999999999999999999999999 0.5000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71386 add 9999999999999999999999999999999999 0.500000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71387 add 9999999999999999999999999999999999 0.50000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71388 add 9999999999999999999999999999999999 0.5000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71389 add 9999999999999999999999999999999999 0.500000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71390 add 9999999999999999999999999999999999 0.50000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71391 add 9999999999999999999999999999999999 0.5000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71392 add 9999999999999999999999999999999999 0.500001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71393 add 9999999999999999999999999999999999 0.50001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71394 add 9999999999999999999999999999999999 0.5001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71395 add 9999999999999999999999999999999999 0.501 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71396 add 9999999999999999999999999999999999 0.51 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-dqadd71420 add 0 1.123456789987654321123456789012345 -> 1.123456789987654321123456789012345
-dqadd71421 add 0 1.123456789987654321123456789012345E-1 -> 0.1123456789987654321123456789012345
-dqadd71422 add 0 1.123456789987654321123456789012345E-2 -> 0.01123456789987654321123456789012345
-dqadd71423 add 0 1.123456789987654321123456789012345E-3 -> 0.001123456789987654321123456789012345
-dqadd71424 add 0 1.123456789987654321123456789012345E-4 -> 0.0001123456789987654321123456789012345
-dqadd71425 add 0 1.123456789987654321123456789012345E-5 -> 0.00001123456789987654321123456789012345
-dqadd71426 add 0 1.123456789987654321123456789012345E-6 -> 0.000001123456789987654321123456789012345
-dqadd71427 add 0 1.123456789987654321123456789012345E-7 -> 1.123456789987654321123456789012345E-7
-dqadd71428 add 0 1.123456789987654321123456789012345E-8 -> 1.123456789987654321123456789012345E-8
-dqadd71429 add 0 1.123456789987654321123456789012345E-9 -> 1.123456789987654321123456789012345E-9
-dqadd71430 add 0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
-dqadd71431 add 0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
-dqadd71432 add 0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
-dqadd71433 add 0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
-dqadd71434 add 0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
-dqadd71435 add 0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
-dqadd71436 add 0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
-dqadd71437 add 0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
-dqadd71438 add 0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
-dqadd71439 add 0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
-dqadd71440 add 0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
-dqadd71441 add 0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
-dqadd71442 add 0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
-dqadd71443 add 0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
-dqadd71444 add 0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
-dqadd71445 add 0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
-dqadd71446 add 0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
-dqadd71447 add 0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
-dqadd71448 add 0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
-dqadd71449 add 0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
-dqadd71450 add 0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
-dqadd71451 add 0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
-dqadd71452 add 0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
-dqadd71453 add 0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
-dqadd71454 add 0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
-dqadd71455 add 0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
-dqadd71456 add 0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36
-
--- same, reversed 0
-dqadd71460 add 1.123456789987654321123456789012345 0 -> 1.123456789987654321123456789012345
-dqadd71461 add 1.123456789987654321123456789012345E-1 0 -> 0.1123456789987654321123456789012345
-dqadd71462 add 1.123456789987654321123456789012345E-2 0 -> 0.01123456789987654321123456789012345
-dqadd71463 add 1.123456789987654321123456789012345E-3 0 -> 0.001123456789987654321123456789012345
-dqadd71464 add 1.123456789987654321123456789012345E-4 0 -> 0.0001123456789987654321123456789012345
-dqadd71465 add 1.123456789987654321123456789012345E-5 0 -> 0.00001123456789987654321123456789012345
-dqadd71466 add 1.123456789987654321123456789012345E-6 0 -> 0.000001123456789987654321123456789012345
-dqadd71467 add 1.123456789987654321123456789012345E-7 0 -> 1.123456789987654321123456789012345E-7
-dqadd71468 add 1.123456789987654321123456789012345E-8 0 -> 1.123456789987654321123456789012345E-8
-dqadd71469 add 1.123456789987654321123456789012345E-9 0 -> 1.123456789987654321123456789012345E-9
-dqadd71470 add 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
-dqadd71471 add 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
-dqadd71472 add 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
-dqadd71473 add 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
-dqadd71474 add 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
-dqadd71475 add 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
-dqadd71476 add 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
-dqadd71477 add 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
-dqadd71478 add 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
-dqadd71479 add 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
-dqadd71480 add 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
-dqadd71481 add 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
-dqadd71482 add 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
-dqadd71483 add 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
-dqadd71484 add 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
-dqadd71485 add 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
-dqadd71486 add 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
-dqadd71487 add 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
-dqadd71488 add 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
-dqadd71489 add 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
-dqadd71490 add 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
-dqadd71491 add 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
-dqadd71492 add 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
-dqadd71493 add 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
-dqadd71494 add 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
-dqadd71495 add 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
-dqadd71496 add 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36
-
--- same, Es on the 0
-dqadd71500 add 1.123456789987654321123456789012345 0E-0 -> 1.123456789987654321123456789012345
-dqadd71501 add 1.123456789987654321123456789012345 0E-1 -> 1.123456789987654321123456789012345
-dqadd71502 add 1.123456789987654321123456789012345 0E-2 -> 1.123456789987654321123456789012345
-dqadd71503 add 1.123456789987654321123456789012345 0E-3 -> 1.123456789987654321123456789012345
-dqadd71504 add 1.123456789987654321123456789012345 0E-4 -> 1.123456789987654321123456789012345
-dqadd71505 add 1.123456789987654321123456789012345 0E-5 -> 1.123456789987654321123456789012345
-dqadd71506 add 1.123456789987654321123456789012345 0E-6 -> 1.123456789987654321123456789012345
-dqadd71507 add 1.123456789987654321123456789012345 0E-7 -> 1.123456789987654321123456789012345
-dqadd71508 add 1.123456789987654321123456789012345 0E-8 -> 1.123456789987654321123456789012345
-dqadd71509 add 1.123456789987654321123456789012345 0E-9 -> 1.123456789987654321123456789012345
-dqadd71510 add 1.123456789987654321123456789012345 0E-10 -> 1.123456789987654321123456789012345
-dqadd71511 add 1.123456789987654321123456789012345 0E-11 -> 1.123456789987654321123456789012345
-dqadd71512 add 1.123456789987654321123456789012345 0E-12 -> 1.123456789987654321123456789012345
-dqadd71513 add 1.123456789987654321123456789012345 0E-13 -> 1.123456789987654321123456789012345
-dqadd71514 add 1.123456789987654321123456789012345 0E-14 -> 1.123456789987654321123456789012345
-dqadd71515 add 1.123456789987654321123456789012345 0E-15 -> 1.123456789987654321123456789012345
-dqadd71516 add 1.123456789987654321123456789012345 0E-16 -> 1.123456789987654321123456789012345
-dqadd71517 add 1.123456789987654321123456789012345 0E-17 -> 1.123456789987654321123456789012345
-dqadd71518 add 1.123456789987654321123456789012345 0E-18 -> 1.123456789987654321123456789012345
-dqadd71519 add 1.123456789987654321123456789012345 0E-19 -> 1.123456789987654321123456789012345
-dqadd71520 add 1.123456789987654321123456789012345 0E-20 -> 1.123456789987654321123456789012345
-dqadd71521 add 1.123456789987654321123456789012345 0E-21 -> 1.123456789987654321123456789012345
-dqadd71522 add 1.123456789987654321123456789012345 0E-22 -> 1.123456789987654321123456789012345
-dqadd71523 add 1.123456789987654321123456789012345 0E-23 -> 1.123456789987654321123456789012345
-dqadd71524 add 1.123456789987654321123456789012345 0E-24 -> 1.123456789987654321123456789012345
-dqadd71525 add 1.123456789987654321123456789012345 0E-25 -> 1.123456789987654321123456789012345
-dqadd71526 add 1.123456789987654321123456789012345 0E-26 -> 1.123456789987654321123456789012345
-dqadd71527 add 1.123456789987654321123456789012345 0E-27 -> 1.123456789987654321123456789012345
-dqadd71528 add 1.123456789987654321123456789012345 0E-28 -> 1.123456789987654321123456789012345
-dqadd71529 add 1.123456789987654321123456789012345 0E-29 -> 1.123456789987654321123456789012345
-dqadd71530 add 1.123456789987654321123456789012345 0E-30 -> 1.123456789987654321123456789012345
-dqadd71531 add 1.123456789987654321123456789012345 0E-31 -> 1.123456789987654321123456789012345
-dqadd71532 add 1.123456789987654321123456789012345 0E-32 -> 1.123456789987654321123456789012345
-dqadd71533 add 1.123456789987654321123456789012345 0E-33 -> 1.123456789987654321123456789012345
--- next four flag Rounded because the 0 extends the result
-dqadd71534 add 1.123456789987654321123456789012345 0E-34 -> 1.123456789987654321123456789012345 Rounded
-dqadd71535 add 1.123456789987654321123456789012345 0E-35 -> 1.123456789987654321123456789012345 Rounded
-dqadd71536 add 1.123456789987654321123456789012345 0E-36 -> 1.123456789987654321123456789012345 Rounded
-dqadd71537 add 1.123456789987654321123456789012345 0E-37 -> 1.123456789987654321123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-dqadd71600 add 0 0E-19 -> 0E-19
-dqadd71601 add -0 0E-19 -> 0E-19
-dqadd71602 add 0 -0E-19 -> 0E-19
-dqadd71603 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71611 add -11 11 -> 0
-dqadd71612 add 11 -11 -> 0
-
-rounding: half_down
--- exact zeros from zeros
-dqadd71620 add 0 0E-19 -> 0E-19
-dqadd71621 add -0 0E-19 -> 0E-19
-dqadd71622 add 0 -0E-19 -> 0E-19
-dqadd71623 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71631 add -11 11 -> 0
-dqadd71632 add 11 -11 -> 0
-
-rounding: half_even
--- exact zeros from zeros
-dqadd71640 add 0 0E-19 -> 0E-19
-dqadd71641 add -0 0E-19 -> 0E-19
-dqadd71642 add 0 -0E-19 -> 0E-19
-dqadd71643 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71651 add -11 11 -> 0
-dqadd71652 add 11 -11 -> 0
-
-rounding: up
--- exact zeros from zeros
-dqadd71660 add 0 0E-19 -> 0E-19
-dqadd71661 add -0 0E-19 -> 0E-19
-dqadd71662 add 0 -0E-19 -> 0E-19
-dqadd71663 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71671 add -11 11 -> 0
-dqadd71672 add 11 -11 -> 0
-
-rounding: down
--- exact zeros from zeros
-dqadd71680 add 0 0E-19 -> 0E-19
-dqadd71681 add -0 0E-19 -> 0E-19
-dqadd71682 add 0 -0E-19 -> 0E-19
-dqadd71683 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71691 add -11 11 -> 0
-dqadd71692 add 11 -11 -> 0
-
-rounding: ceiling
--- exact zeros from zeros
-dqadd71700 add 0 0E-19 -> 0E-19
-dqadd71701 add -0 0E-19 -> 0E-19
-dqadd71702 add 0 -0E-19 -> 0E-19
-dqadd71703 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71711 add -11 11 -> 0
-dqadd71712 add 11 -11 -> 0
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-dqadd71720 add 0 0E-19 -> 0E-19
-dqadd71721 add -0 0E-19 -> -0E-19 -- *
-dqadd71722 add 0 -0E-19 -> -0E-19 -- *
-dqadd71723 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71731 add -11 11 -> -0 -- *
-dqadd71732 add 11 -11 -> -0 -- *
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dqadd71741 add 130E-2 120E-2 -> 2.50
-dqadd71742 add 130E-2 12E-1 -> 2.50
-dqadd71743 add 130E-2 1E0 -> 2.30
-dqadd71744 add 1E2 1E4 -> 1.01E+4
-dqadd71745 add 130E-2 -120E-2 -> 0.10
-dqadd71746 add 130E-2 -12E-1 -> 0.10
-dqadd71747 add 130E-2 -1E0 -> 0.30
-dqadd71748 add 1E2 -1E4 -> -9.9E+3
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-dqadd75001 add 1239876543211234567894567890123456 1 -> 1239876543211234567894567890123457
-dqadd75002 add 1239876543211234567894567890123456 0.6 -> 1239876543211234567894567890123457 Inexact Rounded
-dqadd75003 add 1239876543211234567894567890123456 0.06 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75004 add 1239876543211234567894567890123456 6E-3 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75005 add 1239876543211234567894567890123456 6E-4 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75006 add 1239876543211234567894567890123456 6E-5 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75007 add 1239876543211234567894567890123456 6E-6 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75008 add 1239876543211234567894567890123456 6E-7 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75009 add 1239876543211234567894567890123456 6E-8 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75010 add 1239876543211234567894567890123456 6E-9 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75011 add 1239876543211234567894567890123456 6E-10 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75012 add 1239876543211234567894567890123456 6E-11 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75013 add 1239876543211234567894567890123456 6E-12 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75014 add 1239876543211234567894567890123456 6E-13 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75015 add 1239876543211234567894567890123456 6E-14 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75016 add 1239876543211234567894567890123456 6E-15 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75017 add 1239876543211234567894567890123456 6E-16 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75018 add 1239876543211234567894567890123456 6E-17 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75019 add 1239876543211234567894567890123456 6E-18 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75020 add 1239876543211234567894567890123456 6E-19 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75021 add 1239876543211234567894567890123456 6E-20 -> 1239876543211234567894567890123456 Inexact Rounded
-
--- widening second argument at gap
-dqadd75030 add 12398765432112345678945678 1 -> 12398765432112345678945679
-dqadd75031 add 12398765432112345678945678 0.1 -> 12398765432112345678945678.1
-dqadd75032 add 12398765432112345678945678 0.12 -> 12398765432112345678945678.12
-dqadd75033 add 12398765432112345678945678 0.123 -> 12398765432112345678945678.123
-dqadd75034 add 12398765432112345678945678 0.1234 -> 12398765432112345678945678.1234
-dqadd75035 add 12398765432112345678945678 0.12345 -> 12398765432112345678945678.12345
-dqadd75036 add 12398765432112345678945678 0.123456 -> 12398765432112345678945678.123456
-dqadd75037 add 12398765432112345678945678 0.1234567 -> 12398765432112345678945678.1234567
-dqadd75038 add 12398765432112345678945678 0.12345678 -> 12398765432112345678945678.12345678
-dqadd75039 add 12398765432112345678945678 0.123456789 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75040 add 12398765432112345678945678 0.123456785 -> 12398765432112345678945678.12345678 Inexact Rounded
-dqadd75041 add 12398765432112345678945678 0.1234567850 -> 12398765432112345678945678.12345678 Inexact Rounded
-dqadd75042 add 12398765432112345678945678 0.1234567851 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75043 add 12398765432112345678945678 0.12345678501 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75044 add 12398765432112345678945678 0.123456785001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75045 add 12398765432112345678945678 0.1234567850001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75046 add 12398765432112345678945678 0.12345678500001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75047 add 12398765432112345678945678 0.123456785000001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75048 add 12398765432112345678945678 0.1234567850000001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75049 add 12398765432112345678945678 0.1234567850000000 -> 12398765432112345678945678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-dqadd75050 add 12398765432112345678945678 0.0234567750000000 -> 12398765432112345678945678.02345678 Inexact Rounded
-dqadd75051 add 12398765432112345678945678 0.0034567750000000 -> 12398765432112345678945678.00345678 Inexact Rounded
-dqadd75052 add 12398765432112345678945678 0.0004567750000000 -> 12398765432112345678945678.00045678 Inexact Rounded
-dqadd75053 add 12398765432112345678945678 0.0000567750000000 -> 12398765432112345678945678.00005678 Inexact Rounded
-dqadd75054 add 12398765432112345678945678 0.0000067750000000 -> 12398765432112345678945678.00000678 Inexact Rounded
-dqadd75055 add 12398765432112345678945678 0.0000007750000000 -> 12398765432112345678945678.00000078 Inexact Rounded
-dqadd75056 add 12398765432112345678945678 0.0000000750000000 -> 12398765432112345678945678.00000008 Inexact Rounded
-dqadd75057 add 12398765432112345678945678 0.0000000050000000 -> 12398765432112345678945678.00000000 Inexact Rounded
-dqadd75060 add 12398765432112345678945678 0.0234567750000001 -> 12398765432112345678945678.02345678 Inexact Rounded
-dqadd75061 add 12398765432112345678945678 0.0034567750000001 -> 12398765432112345678945678.00345678 Inexact Rounded
-dqadd75062 add 12398765432112345678945678 0.0004567750000001 -> 12398765432112345678945678.00045678 Inexact Rounded
-dqadd75063 add 12398765432112345678945678 0.0000567750000001 -> 12398765432112345678945678.00005678 Inexact Rounded
-dqadd75064 add 12398765432112345678945678 0.0000067750000001 -> 12398765432112345678945678.00000678 Inexact Rounded
-dqadd75065 add 12398765432112345678945678 0.0000007750000001 -> 12398765432112345678945678.00000078 Inexact Rounded
-dqadd75066 add 12398765432112345678945678 0.0000000750000001 -> 12398765432112345678945678.00000008 Inexact Rounded
-dqadd75067 add 12398765432112345678945678 0.0000000050000001 -> 12398765432112345678945678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-dqadd75070 add 12398765432112345678945678 1E-8 -> 12398765432112345678945678.00000001
-dqadd75071 add 12398765432112345678945678 1E-9 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75072 add 12398765432112345678945678 1E-10 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75073 add 12398765432112345678945678 1E-11 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75074 add 12398765432112345678945678 1E-12 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75075 add 12398765432112345678945678 1E-13 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75076 add 12398765432112345678945678 1E-14 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75077 add 12398765432112345678945678 1E-15 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75078 add 12398765432112345678945678 1E-16 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75079 add 12398765432112345678945678 1E-17 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75080 add 12398765432112345678945678 1E-18 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75081 add 12398765432112345678945678 1E-19 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75082 add 12398765432112345678945678 1E-20 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75083 add 12398765432112345678945678 1E-25 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75084 add 12398765432112345678945678 1E-30 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75085 add 12398765432112345678945678 1E-31 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75086 add 12398765432112345678945678 1E-32 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75087 add 12398765432112345678945678 1E-33 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75088 add 12398765432112345678945678 1E-34 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75089 add 12398765432112345678945678 1E-35 -> 12398765432112345678945678.00000001 Inexact Rounded
-
--- Null tests
-dqadd9990 add 10 # -> NaN Invalid_operation
-dqadd9991 add # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqAdd.decTest -- decQuad addition --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decQuads only; all arguments are
+-- representable in a decQuad
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+dqadd001 add 1 1 -> 2
+dqadd002 add 2 3 -> 5
+dqadd003 add '5.75' '3.3' -> 9.05
+dqadd004 add '5' '-3' -> 2
+dqadd005 add '-5' '-3' -> -8
+dqadd006 add '-7' '2.5' -> -4.5
+dqadd007 add '0.7' '0.3' -> 1.0
+dqadd008 add '1.25' '1.25' -> 2.50
+dqadd009 add '1.23456789' '1.00000000' -> '2.23456789'
+dqadd010 add '1.23456789' '1.00000011' -> '2.23456800'
+
+-- 1234567890123456 1234567890123456
+dqadd011 add '0.4444444444444444444444444444444446' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqadd012 add '0.4444444444444444444444444444444445' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
+dqadd013 add '0.4444444444444444444444444444444444' '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
+dqadd014 add '4444444444444444444444444444444444' '0.49' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd015 add '4444444444444444444444444444444444' '0.499' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd016 add '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd017 add '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd018 add '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
+dqadd019 add '4444444444444444444444444444444444' '0.501' -> '4444444444444444444444444444444445' Inexact Rounded
+dqadd020 add '4444444444444444444444444444444444' '0.51' -> '4444444444444444444444444444444445' Inexact Rounded
+
+dqadd021 add 0 1 -> 1
+dqadd022 add 1 1 -> 2
+dqadd023 add 2 1 -> 3
+dqadd024 add 3 1 -> 4
+dqadd025 add 4 1 -> 5
+dqadd026 add 5 1 -> 6
+dqadd027 add 6 1 -> 7
+dqadd028 add 7 1 -> 8
+dqadd029 add 8 1 -> 9
+dqadd030 add 9 1 -> 10
+
+-- some carrying effects
+dqadd031 add '0.9998' '0.0000' -> '0.9998'
+dqadd032 add '0.9998' '0.0001' -> '0.9999'
+dqadd033 add '0.9998' '0.0002' -> '1.0000'
+dqadd034 add '0.9998' '0.0003' -> '1.0001'
+
+dqadd035 add '70' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd036 add '700' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd037 add '7000' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd038 add '70000' '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
+dqadd039 add '700000' '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded
+
+-- symmetry:
+dqadd040 add '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd041 add '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd042 add '10000e+34' '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd044 add '10000e+34' '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
+dqadd045 add '10000e+34' '700000' -> '1.000000000000000000000000000000007E+38' Rounded
+
+-- same, without rounding
+dqadd046 add '10000e+9' '7' -> '10000000000007'
+dqadd047 add '10000e+9' '70' -> '10000000000070'
+dqadd048 add '10000e+9' '700' -> '10000000000700'
+dqadd049 add '10000e+9' '7000' -> '10000000007000'
+dqadd050 add '10000e+9' '70000' -> '10000000070000'
+dqadd051 add '10000e+9' '700000' -> '10000000700000'
+dqadd052 add '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+dqadd053 add '12' '7.00' -> '19.00'
+dqadd054 add '1.3' '-1.07' -> '0.23'
+dqadd055 add '1.3' '-1.30' -> '0.00'
+dqadd056 add '1.3' '-2.07' -> '-0.77'
+dqadd057 add '1E+2' '1E+4' -> '1.01E+4'
+
+-- leading zero preservation
+dqadd061 add 1 '0.0001' -> '1.0001'
+dqadd062 add 1 '0.00001' -> '1.00001'
+dqadd063 add 1 '0.000001' -> '1.000001'
+dqadd064 add 1 '0.0000001' -> '1.0000001'
+dqadd065 add 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+dqadd070 add 1 0 -> 1
+dqadd071 add 1 0. -> 1
+dqadd072 add 1 .0 -> 1.0
+dqadd073 add 1 0.0 -> 1.0
+dqadd074 add 1 0.00 -> 1.00
+dqadd075 add 0 1 -> 1
+dqadd076 add 0. 1 -> 1
+dqadd077 add .0 1 -> 1.0
+dqadd078 add 0.0 1 -> 1.0
+dqadd079 add 0.00 1 -> 1.00
+
+-- some carries
+dqadd080 add 999999998 1 -> 999999999
+dqadd081 add 999999999 1 -> 1000000000
+dqadd082 add 99999999 1 -> 100000000
+dqadd083 add 9999999 1 -> 10000000
+dqadd084 add 999999 1 -> 1000000
+dqadd085 add 99999 1 -> 100000
+dqadd086 add 9999 1 -> 10000
+dqadd087 add 999 1 -> 1000
+dqadd088 add 99 1 -> 100
+dqadd089 add 9 1 -> 10
+
+
+-- more LHS swaps
+dqadd090 add '-56267E-10' 0 -> '-0.0000056267'
+dqadd091 add '-56267E-6' 0 -> '-0.056267'
+dqadd092 add '-56267E-5' 0 -> '-0.56267'
+dqadd093 add '-56267E-4' 0 -> '-5.6267'
+dqadd094 add '-56267E-3' 0 -> '-56.267'
+dqadd095 add '-56267E-2' 0 -> '-562.67'
+dqadd096 add '-56267E-1' 0 -> '-5626.7'
+dqadd097 add '-56267E-0' 0 -> '-56267'
+dqadd098 add '-5E-10' 0 -> '-5E-10'
+dqadd099 add '-5E-7' 0 -> '-5E-7'
+dqadd100 add '-5E-6' 0 -> '-0.000005'
+dqadd101 add '-5E-5' 0 -> '-0.00005'
+dqadd102 add '-5E-4' 0 -> '-0.0005'
+dqadd103 add '-5E-1' 0 -> '-0.5'
+dqadd104 add '-5E0' 0 -> '-5'
+dqadd105 add '-5E1' 0 -> '-50'
+dqadd106 add '-5E5' 0 -> '-500000'
+dqadd107 add '-5E33' 0 -> '-5000000000000000000000000000000000'
+dqadd108 add '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
+dqadd109 add '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
+dqadd110 add '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
+dqadd111 add '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- more RHS swaps
+dqadd113 add 0 '-56267E-10' -> '-0.0000056267'
+dqadd114 add 0 '-56267E-6' -> '-0.056267'
+dqadd116 add 0 '-56267E-5' -> '-0.56267'
+dqadd117 add 0 '-56267E-4' -> '-5.6267'
+dqadd119 add 0 '-56267E-3' -> '-56.267'
+dqadd120 add 0 '-56267E-2' -> '-562.67'
+dqadd121 add 0 '-56267E-1' -> '-5626.7'
+dqadd122 add 0 '-56267E-0' -> '-56267'
+dqadd123 add 0 '-5E-10' -> '-5E-10'
+dqadd124 add 0 '-5E-7' -> '-5E-7'
+dqadd125 add 0 '-5E-6' -> '-0.000005'
+dqadd126 add 0 '-5E-5' -> '-0.00005'
+dqadd127 add 0 '-5E-4' -> '-0.0005'
+dqadd128 add 0 '-5E-1' -> '-0.5'
+dqadd129 add 0 '-5E0' -> '-5'
+dqadd130 add 0 '-5E1' -> '-50'
+dqadd131 add 0 '-5E5' -> '-500000'
+dqadd132 add 0 '-5E33' -> '-5000000000000000000000000000000000'
+dqadd133 add 0 '-5E34' -> '-5.000000000000000000000000000000000E+34' Rounded
+dqadd134 add 0 '-5E35' -> '-5.000000000000000000000000000000000E+35' Rounded
+dqadd135 add 0 '-5E36' -> '-5.000000000000000000000000000000000E+36' Rounded
+dqadd136 add 0 '-5E100' -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- related
+dqadd137 add 1 '0E-39' -> '1.000000000000000000000000000000000' Rounded
+dqadd138 add -1 '0E-39' -> '-1.000000000000000000000000000000000' Rounded
+dqadd139 add '0E-39' 1 -> '1.000000000000000000000000000000000' Rounded
+dqadd140 add '0E-39' -1 -> '-1.000000000000000000000000000000000' Rounded
+dqadd141 add 1E+29 0.0000 -> '100000000000000000000000000000.0000'
+dqadd142 add 1E+29 0.00000 -> '100000000000000000000000000000.0000' Rounded
+dqadd143 add 0.000 1E+30 -> '1000000000000000000000000000000.000'
+dqadd144 add 0.0000 1E+30 -> '1000000000000000000000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+dqadd146 add '00.0' 0 -> '0.0'
+dqadd147 add '0.00' 0 -> '0.00'
+dqadd148 add 0 '0.00' -> '0.00'
+dqadd149 add 0 '00.0' -> '0.0'
+dqadd150 add '00.0' '0.00' -> '0.00'
+dqadd151 add '0.00' '00.0' -> '0.00'
+dqadd152 add '3' '.3' -> '3.3'
+dqadd153 add '3.' '.3' -> '3.3'
+dqadd154 add '3.0' '.3' -> '3.3'
+dqadd155 add '3.00' '.3' -> '3.30'
+dqadd156 add '3' '3' -> '6'
+dqadd157 add '3' '+3' -> '6'
+dqadd158 add '3' '-3' -> '0'
+dqadd159 add '0.3' '-0.3' -> '0.0'
+dqadd160 add '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+dqadd161 add '1E+12' '-1' -> '999999999999'
+dqadd162 add '1E+12' '1.11' -> '1000000000001.11'
+dqadd163 add '1.11' '1E+12' -> '1000000000001.11'
+dqadd164 add '-1' '1E+12' -> '999999999999'
+dqadd165 add '7E+12' '-1' -> '6999999999999'
+dqadd166 add '7E+12' '1.11' -> '7000000000001.11'
+dqadd167 add '1.11' '7E+12' -> '7000000000001.11'
+dqadd168 add '-1' '7E+12' -> '6999999999999'
+
+rounding: half_up
+dqadd170 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd171 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd172 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd173 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
+dqadd174 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd175 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd176 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd177 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
+dqadd178 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd179 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd180 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd181 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd182 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd183 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+dqadd200 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd201 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd202 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd203 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd204 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd205 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd206 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd207 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd208 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd209 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd210 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd211 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd212 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd213 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd214 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd215 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd216 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd217 add '1231234567890123456784560123456789' 1.000000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd218 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd219 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+
+rounding: half_even
+dqadd220 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd221 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd222 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd223 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd224 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd225 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd226 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd227 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd228 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd229 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd230 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd231 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd232 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd233 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd234 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd235 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd236 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd237 add '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd238 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd239 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+-- critical few with even bottom digit...
+dqadd240 add '1231234567890123456784560123456788' 0.499999999 -> '1231234567890123456784560123456788' Inexact Rounded
+dqadd241 add '1231234567890123456784560123456788' 0.5 -> '1231234567890123456784560123456788' Inexact Rounded
+dqadd242 add '1231234567890123456784560123456788' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
+
+rounding: down
+dqadd250 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd251 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd252 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd253 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd254 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd255 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd256 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd257 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd258 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd259 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd260 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd261 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd262 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd263 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd264 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd265 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd266 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd267 add '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd268 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd269 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+dqadd301 add -1 1 -> 0
+dqadd302 add 0 1 -> 1
+dqadd303 add 1 1 -> 2
+dqadd304 add 12 1 -> 13
+dqadd305 add 98 1 -> 99
+dqadd306 add 99 1 -> 100
+dqadd307 add 100 1 -> 101
+dqadd308 add 101 1 -> 102
+dqadd309 add -1 -1 -> -2
+dqadd310 add 0 -1 -> -1
+dqadd311 add 1 -1 -> 0
+dqadd312 add 12 -1 -> 11
+dqadd313 add 98 -1 -> 97
+dqadd314 add 99 -1 -> 98
+dqadd315 add 100 -1 -> 99
+dqadd316 add 101 -1 -> 100
+
+dqadd321 add -0.01 0.01 -> 0.00
+dqadd322 add 0.00 0.01 -> 0.01
+dqadd323 add 0.01 0.01 -> 0.02
+dqadd324 add 0.12 0.01 -> 0.13
+dqadd325 add 0.98 0.01 -> 0.99
+dqadd326 add 0.99 0.01 -> 1.00
+dqadd327 add 1.00 0.01 -> 1.01
+dqadd328 add 1.01 0.01 -> 1.02
+dqadd329 add -0.01 -0.01 -> -0.02
+dqadd330 add 0.00 -0.01 -> -0.01
+dqadd331 add 0.01 -0.01 -> 0.00
+dqadd332 add 0.12 -0.01 -> 0.11
+dqadd333 add 0.98 -0.01 -> 0.97
+dqadd334 add 0.99 -0.01 -> 0.98
+dqadd335 add 1.00 -0.01 -> 0.99
+dqadd336 add 1.01 -0.01 -> 1.00
+
+-- some more cases where adding 0 affects the coefficient
+dqadd340 add 1E+3 0 -> 1000
+dqadd341 add 1E+33 0 -> 1000000000000000000000000000000000
+dqadd342 add 1E+34 0 -> 1.000000000000000000000000000000000E+34 Rounded
+dqadd343 add 1E+35 0 -> 1.000000000000000000000000000000000E+35 Rounded
+-- which simply follow from these cases ...
+dqadd344 add 1E+3 1 -> 1001
+dqadd345 add 1E+33 1 -> 1000000000000000000000000000000001
+dqadd346 add 1E+34 1 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd347 add 1E+35 1 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
+dqadd348 add 1E+3 7 -> 1007
+dqadd349 add 1E+33 7 -> 1000000000000000000000000000000007
+dqadd350 add 1E+34 7 -> 1.000000000000000000000000000000001E+34 Inexact Rounded
+dqadd351 add 1E+35 7 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
+
+-- tryzeros cases
+rounding: half_up
+dqadd360 add 0E+50 10000E+1 -> 1.0000E+5
+dqadd361 add 0E-50 10000E+1 -> 100000.0000000000000000000000000000 Rounded
+dqadd362 add 10000E+1 0E-50 -> 100000.0000000000000000000000000000 Rounded
+dqadd363 add 10000E+1 10000E-50 -> 100000.0000000000000000000000000000 Rounded Inexact
+dqadd364 add 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
+-- 1 234567890123456789012345678901234
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+dqadd370 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd371 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+rounding: half_up
+dqadd372 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd373 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+rounding: half_even
+dqadd374 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd375 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+
+-- ulp replacement tests
+dqadd400 add 1 77e-32 -> 1.00000000000000000000000000000077
+dqadd401 add 1 77e-33 -> 1.000000000000000000000000000000077
+dqadd402 add 1 77e-34 -> 1.000000000000000000000000000000008 Inexact Rounded
+dqadd403 add 1 77e-35 -> 1.000000000000000000000000000000001 Inexact Rounded
+dqadd404 add 1 77e-36 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd405 add 1 77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd406 add 1 77e-299 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd410 add 10 77e-32 -> 10.00000000000000000000000000000077
+dqadd411 add 10 77e-33 -> 10.00000000000000000000000000000008 Inexact Rounded
+dqadd412 add 10 77e-34 -> 10.00000000000000000000000000000001 Inexact Rounded
+dqadd413 add 10 77e-35 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd414 add 10 77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd415 add 10 77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd416 add 10 77e-299 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd420 add 77e-32 1 -> 1.00000000000000000000000000000077
+dqadd421 add 77e-33 1 -> 1.000000000000000000000000000000077
+dqadd422 add 77e-34 1 -> 1.000000000000000000000000000000008 Inexact Rounded
+dqadd423 add 77e-35 1 -> 1.000000000000000000000000000000001 Inexact Rounded
+dqadd424 add 77e-36 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd425 add 77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd426 add 77e-299 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd430 add 77e-32 10 -> 10.00000000000000000000000000000077
+dqadd431 add 77e-33 10 -> 10.00000000000000000000000000000008 Inexact Rounded
+dqadd432 add 77e-34 10 -> 10.00000000000000000000000000000001 Inexact Rounded
+dqadd433 add 77e-35 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd434 add 77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd435 add 77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd436 add 77e-299 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+-- fastpath boundaries
+-- 1234567890123456789012345678901234
+dqadd501 add '4444444444444444444444444444444444' '5555555555555555555555555555555555' -> '9999999999999999999999999999999999'
+dqadd502 add '4444444444444444444444444444444444' '4555555555555555555555555555555555' -> '8999999999999999999999999999999999'
+dqadd503 add '4444444444444444444444444444444444' '3555555555555555555055555555555555' -> '7999999999999999999499999999999999'
+dqadd504 add '4444444444444444444444444444444444' '3955555555555555555555555555555555' -> '8399999999999999999999999999999999'
+dqadd505 add '4444444444444444444444444444444444' '4955555555555555555555555555555555' -> '9399999999999999999999999999999999'
+dqadd506 add '4444444444444444444444444444444444' '5955555555555555555555555555555555' -> 1.040000000000000000000000000000000E+34 Inexact Rounded
+dqadd511 add '344444444444444444444444444444444' '555555555555555555555555555555555' -> '899999999999999999999999999999999'
+dqadd512 add '34444444444444444444444444444444' '55555555555555555555555555555555' -> '89999999999999999999999999999999'
+dqadd513 add '3444444444444444444444444444444' '5555555555555555555555555555555' -> '8999999999999999999999999999999'
+dqadd514 add '344444444444444444444444444444' '555555555555555555555555555555' -> '899999999999999999999999999999'
+dqadd515 add '34444444444444444444444444444' '55555555555555555555555555555' -> '89999999999999999999999999999'
+dqadd516 add '3444444444444444444444444444' '5555555555555555555555555555' -> '8999999999999999999999999999'
+dqadd517 add '344444444444444444444444444' '555555555555555555555555555' -> '899999999999999999999999999'
+dqadd518 add '34444444444444444444444444' '55555555555555555555555555' -> '89999999999999999999999999'
+dqadd519 add '3444444444444444444444444' '5555555555555555555555555' -> '8999999999999999999999999'
+dqadd520 add '344444444444444444444444' '555555555555555555555555' -> '899999999999999999999999'
+dqadd521 add '34444444444444444444444' '55555555555555555555555' -> '89999999999999999999999'
+dqadd522 add '3444444444444444444444' '5555555555555555555555' -> '8999999999999999999999'
+dqadd523 add '4444444444444444444444' '3333333333333333333333' -> '7777777777777777777777'
+dqadd524 add '344444444444444444444' '555555555555555555555' -> '899999999999999999999'
+dqadd525 add '34444444444444444444' '55555555555555555555' -> '89999999999999999999'
+dqadd526 add '3444444444444444444' '5555555555555555555' -> '8999999999999999999'
+dqadd527 add '344444444444444444' '555555555555555555' -> '899999999999999999'
+dqadd528 add '34444444444444444' '55555555555555555' -> '89999999999999999'
+dqadd529 add '3444444444444444' '5555555555555555' -> '8999999999999999'
+dqadd530 add '344444444444444' '555555555555555' -> '899999999999999'
+dqadd531 add '34444444444444' '55555555555555' -> '89999999999999'
+dqadd532 add '3444444444444' '5555555555555' -> '8999999999999'
+dqadd533 add '344444444444' '555555555555' -> '899999999999'
+dqadd534 add '34444444444' '55555555555' -> '89999999999'
+dqadd535 add '3444444444' '5555555555' -> '8999999999'
+dqadd536 add '344444444' '555555555' -> '899999999'
+dqadd537 add '34444444' '55555555' -> '89999999'
+dqadd538 add '3444444' '5555555' -> '8999999'
+dqadd539 add '344444' '555555' -> '899999'
+dqadd540 add '34444' '55555' -> '89999'
+dqadd541 add '3444' '5555' -> '8999'
+dqadd542 add '344' '555' -> '899'
+dqadd543 add '34' '55' -> '89'
+dqadd544 add '3' '5' -> '8'
+
+dqadd545 add '3000004000000000000000000000000000' '3000000000000040000000000000000000' -> '6000004000000040000000000000000000'
+dqadd546 add '3000000400000000000000000000000000' '4000000000000400000000000000000000' -> '7000000400000400000000000000000000'
+dqadd547 add '3000000040000000000000000000000000' '5000000000004000000000000000000000' -> '8000000040004000000000000000000000'
+dqadd548 add '4000000004000000000000000000000000' '3000000000040000000000000000000000' -> '7000000004040000000000000000000000'
+dqadd549 add '4000000000400000000000000000000000' '4000000000400000000000000000000000' -> '8000000000800000000000000000000000'
+dqadd550 add '4000000000040000000000000000000000' '5000000004000000000000000000000000' -> '9000000004040000000000000000000000'
+dqadd551 add '5000000000004000000000000000000000' '3000000040000000000000000000000000' -> '8000000040004000000000000000000000'
+dqadd552 add '5000000000000400000000000000000000' '4000000400000000000000000000000000' -> '9000000400000400000000000000000000'
+dqadd553 add '5000000000000040000000000000000000' '5000004000000000000000000000000000' -> 1.000000400000004000000000000000000E+34 Rounded
+-- check propagation
+dqadd554 add '8999999999999999999999999999999999' '0000000000000000000000000000000001' -> 9000000000000000000000000000000000
+dqadd555 add '0000000000000000000000000000000001' '8999999999999999999999999999999999' -> 9000000000000000000000000000000000
+dqadd556 add '4444444444444444444444444444444444' '4555555555555555555555555555555556' -> 9000000000000000000000000000000000
+dqadd557 add '4555555555555555555555555555555556' '4444444444444444444444444444444444' -> 9000000000000000000000000000000000
+
+-- negative ulps
+dqadd6440 add 1 -77e-32 -> 0.99999999999999999999999999999923
+dqadd6441 add 1 -77e-33 -> 0.999999999999999999999999999999923
+dqadd6442 add 1 -77e-34 -> 0.9999999999999999999999999999999923
+dqadd6443 add 1 -77e-35 -> 0.9999999999999999999999999999999992 Inexact Rounded
+dqadd6444 add 1 -77e-36 -> 0.9999999999999999999999999999999999 Inexact Rounded
+dqadd6445 add 1 -77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd6446 add 1 -77e-99 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd6450 add 10 -77e-32 -> 9.99999999999999999999999999999923
+dqadd6451 add 10 -77e-33 -> 9.999999999999999999999999999999923
+dqadd6452 add 10 -77e-34 -> 9.999999999999999999999999999999992 Inexact Rounded
+dqadd6453 add 10 -77e-35 -> 9.999999999999999999999999999999999 Inexact Rounded
+dqadd6454 add 10 -77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd6455 add 10 -77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd6456 add 10 -77e-99 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd6460 add -77e-32 1 -> 0.99999999999999999999999999999923
+dqadd6461 add -77e-33 1 -> 0.999999999999999999999999999999923
+dqadd6462 add -77e-34 1 -> 0.9999999999999999999999999999999923
+dqadd6463 add -77e-35 1 -> 0.9999999999999999999999999999999992 Inexact Rounded
+dqadd6464 add -77e-36 1 -> 0.9999999999999999999999999999999999 Inexact Rounded
+dqadd6465 add -77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd6466 add -77e-99 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd6470 add -77e-32 10 -> 9.99999999999999999999999999999923
+dqadd6471 add -77e-33 10 -> 9.999999999999999999999999999999923
+dqadd6472 add -77e-34 10 -> 9.999999999999999999999999999999992 Inexact Rounded
+dqadd6473 add -77e-35 10 -> 9.999999999999999999999999999999999 Inexact Rounded
+dqadd6474 add -77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd6475 add -77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd6476 add -77e-99 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+-- negative ulps
+dqadd6480 add -1 77e-32 -> -0.99999999999999999999999999999923
+dqadd6481 add -1 77e-33 -> -0.999999999999999999999999999999923
+dqadd6482 add -1 77e-34 -> -0.9999999999999999999999999999999923
+dqadd6483 add -1 77e-35 -> -0.9999999999999999999999999999999992 Inexact Rounded
+dqadd6484 add -1 77e-36 -> -0.9999999999999999999999999999999999 Inexact Rounded
+dqadd6485 add -1 77e-37 -> -1.000000000000000000000000000000000 Inexact Rounded
+dqadd6486 add -1 77e-99 -> -1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd6490 add -10 77e-32 -> -9.99999999999999999999999999999923
+dqadd6491 add -10 77e-33 -> -9.999999999999999999999999999999923
+dqadd6492 add -10 77e-34 -> -9.999999999999999999999999999999992 Inexact Rounded
+dqadd6493 add -10 77e-35 -> -9.999999999999999999999999999999999 Inexact Rounded
+dqadd6494 add -10 77e-36 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd6495 add -10 77e-37 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd6496 add -10 77e-99 -> -10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd6500 add 77e-32 -1 -> -0.99999999999999999999999999999923
+dqadd6501 add 77e-33 -1 -> -0.999999999999999999999999999999923
+dqadd6502 add 77e-34 -1 -> -0.9999999999999999999999999999999923
+dqadd6503 add 77e-35 -1 -> -0.9999999999999999999999999999999992 Inexact Rounded
+dqadd6504 add 77e-36 -1 -> -0.9999999999999999999999999999999999 Inexact Rounded
+dqadd6505 add 77e-37 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
+dqadd6506 add 77e-99 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd6510 add 77e-32 -10 -> -9.99999999999999999999999999999923
+dqadd6511 add 77e-33 -10 -> -9.999999999999999999999999999999923
+dqadd6512 add 77e-34 -10 -> -9.999999999999999999999999999999992 Inexact Rounded
+dqadd6513 add 77e-35 -10 -> -9.999999999999999999999999999999999 Inexact Rounded
+dqadd6514 add 77e-36 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd6515 add 77e-37 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd6516 add 77e-99 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+
+-- and some more residue effects and different roundings
+rounding: half_up
+dqadd6540 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd6541 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6542 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6543 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6544 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6545 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6546 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6547 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6548 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6549 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6550 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6551 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6552 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6553 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6554 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6555 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6556 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd6557 add '9876543219876543216543210123456789' 1.000000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6558 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6559 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+rounding: half_even
+dqadd6560 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd6561 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6562 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6563 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6564 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6565 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6566 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6567 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6568 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6569 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6570 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6571 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6572 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6573 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6574 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6575 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6576 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd6577 add '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6578 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6579 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+-- critical few with even bottom digit...
+dqadd7540 add '9876543219876543216543210123456788' 0.499999999 -> '9876543219876543216543210123456788' Inexact Rounded
+dqadd7541 add '9876543219876543216543210123456788' 0.5 -> '9876543219876543216543210123456788' Inexact Rounded
+dqadd7542 add '9876543219876543216543210123456788' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
+
+rounding: down
+dqadd7550 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd7551 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7552 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7553 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7554 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7555 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7556 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7557 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7558 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7559 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7560 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7561 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7562 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7563 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7564 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7565 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7566 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd7567 add '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd7568 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd7569 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+dqadd7701 add 5.00 1.00E-3 -> 5.00100
+dqadd7702 add 00.00 0.000 -> 0.000
+dqadd7703 add 00.00 0E-3 -> 0.000
+dqadd7704 add 0E-3 00.00 -> 0.000
+
+dqadd7710 add 0E+3 00.00 -> 0.00
+dqadd7711 add 0E+3 00.0 -> 0.0
+dqadd7712 add 0E+3 00. -> 0
+dqadd7713 add 0E+3 00.E+1 -> 0E+1
+dqadd7714 add 0E+3 00.E+2 -> 0E+2
+dqadd7715 add 0E+3 00.E+3 -> 0E+3
+dqadd7716 add 0E+3 00.E+4 -> 0E+3
+dqadd7717 add 0E+3 00.E+5 -> 0E+3
+dqadd7718 add 0E+3 -00.0 -> 0.0
+dqadd7719 add 0E+3 -00. -> 0
+dqadd7731 add 0E+3 -00.E+1 -> 0E+1
+
+dqadd7720 add 00.00 0E+3 -> 0.00
+dqadd7721 add 00.0 0E+3 -> 0.0
+dqadd7722 add 00. 0E+3 -> 0
+dqadd7723 add 00.E+1 0E+3 -> 0E+1
+dqadd7724 add 00.E+2 0E+3 -> 0E+2
+dqadd7725 add 00.E+3 0E+3 -> 0E+3
+dqadd7726 add 00.E+4 0E+3 -> 0E+3
+dqadd7727 add 00.E+5 0E+3 -> 0E+3
+dqadd7728 add -00.00 0E+3 -> 0.00
+dqadd7729 add -00.0 0E+3 -> 0.0
+dqadd7730 add -00. 0E+3 -> 0
+
+dqadd7732 add 0 0 -> 0
+dqadd7733 add 0 -0 -> 0
+dqadd7734 add -0 0 -> 0
+dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case
+
+dqadd7736 add 1 -1 -> 0
+dqadd7737 add -1 -1 -> -2
+dqadd7738 add 1 1 -> 2
+dqadd7739 add -1 1 -> 0
+
+dqadd7741 add 0 -1 -> -1
+dqadd7742 add -0 -1 -> -1
+dqadd7743 add 0 1 -> 1
+dqadd7744 add -0 1 -> 1
+dqadd7745 add -1 0 -> -1
+dqadd7746 add -1 -0 -> -1
+dqadd7747 add 1 0 -> 1
+dqadd7748 add 1 -0 -> 1
+
+dqadd7751 add 0.0 -1 -> -1.0
+dqadd7752 add -0.0 -1 -> -1.0
+dqadd7753 add 0.0 1 -> 1.0
+dqadd7754 add -0.0 1 -> 1.0
+dqadd7755 add -1.0 0 -> -1.0
+dqadd7756 add -1.0 -0 -> -1.0
+dqadd7757 add 1.0 0 -> 1.0
+dqadd7758 add 1.0 -0 -> 1.0
+
+dqadd7761 add 0 -1.0 -> -1.0
+dqadd7762 add -0 -1.0 -> -1.0
+dqadd7763 add 0 1.0 -> 1.0
+dqadd7764 add -0 1.0 -> 1.0
+dqadd7765 add -1 0.0 -> -1.0
+dqadd7766 add -1 -0.0 -> -1.0
+dqadd7767 add 1 0.0 -> 1.0
+dqadd7768 add 1 -0.0 -> 1.0
+
+dqadd7771 add 0.0 -1.0 -> -1.0
+dqadd7772 add -0.0 -1.0 -> -1.0
+dqadd7773 add 0.0 1.0 -> 1.0
+dqadd7774 add -0.0 1.0 -> 1.0
+dqadd7775 add -1.0 0.0 -> -1.0
+dqadd7776 add -1.0 -0.0 -> -1.0
+dqadd7777 add 1.0 0.0 -> 1.0
+dqadd7778 add 1.0 -0.0 -> 1.0
+
+-- Specials
+dqadd7780 add -Inf -Inf -> -Infinity
+dqadd7781 add -Inf -1000 -> -Infinity
+dqadd7782 add -Inf -1 -> -Infinity
+dqadd7783 add -Inf -0 -> -Infinity
+dqadd7784 add -Inf 0 -> -Infinity
+dqadd7785 add -Inf 1 -> -Infinity
+dqadd7786 add -Inf 1000 -> -Infinity
+dqadd7787 add -1000 -Inf -> -Infinity
+dqadd7788 add -Inf -Inf -> -Infinity
+dqadd7789 add -1 -Inf -> -Infinity
+dqadd7790 add -0 -Inf -> -Infinity
+dqadd7791 add 0 -Inf -> -Infinity
+dqadd7792 add 1 -Inf -> -Infinity
+dqadd7793 add 1000 -Inf -> -Infinity
+dqadd7794 add Inf -Inf -> NaN Invalid_operation
+
+dqadd7800 add Inf -Inf -> NaN Invalid_operation
+dqadd7801 add Inf -1000 -> Infinity
+dqadd7802 add Inf -1 -> Infinity
+dqadd7803 add Inf -0 -> Infinity
+dqadd7804 add Inf 0 -> Infinity
+dqadd7805 add Inf 1 -> Infinity
+dqadd7806 add Inf 1000 -> Infinity
+dqadd7807 add Inf Inf -> Infinity
+dqadd7808 add -1000 Inf -> Infinity
+dqadd7809 add -Inf Inf -> NaN Invalid_operation
+dqadd7810 add -1 Inf -> Infinity
+dqadd7811 add -0 Inf -> Infinity
+dqadd7812 add 0 Inf -> Infinity
+dqadd7813 add 1 Inf -> Infinity
+dqadd7814 add 1000 Inf -> Infinity
+dqadd7815 add Inf Inf -> Infinity
+
+dqadd7821 add NaN -Inf -> NaN
+dqadd7822 add NaN -1000 -> NaN
+dqadd7823 add NaN -1 -> NaN
+dqadd7824 add NaN -0 -> NaN
+dqadd7825 add NaN 0 -> NaN
+dqadd7826 add NaN 1 -> NaN
+dqadd7827 add NaN 1000 -> NaN
+dqadd7828 add NaN Inf -> NaN
+dqadd7829 add NaN NaN -> NaN
+dqadd7830 add -Inf NaN -> NaN
+dqadd7831 add -1000 NaN -> NaN
+dqadd7832 add -1 NaN -> NaN
+dqadd7833 add -0 NaN -> NaN
+dqadd7834 add 0 NaN -> NaN
+dqadd7835 add 1 NaN -> NaN
+dqadd7836 add 1000 NaN -> NaN
+dqadd7837 add Inf NaN -> NaN
+
+dqadd7841 add sNaN -Inf -> NaN Invalid_operation
+dqadd7842 add sNaN -1000 -> NaN Invalid_operation
+dqadd7843 add sNaN -1 -> NaN Invalid_operation
+dqadd7844 add sNaN -0 -> NaN Invalid_operation
+dqadd7845 add sNaN 0 -> NaN Invalid_operation
+dqadd7846 add sNaN 1 -> NaN Invalid_operation
+dqadd7847 add sNaN 1000 -> NaN Invalid_operation
+dqadd7848 add sNaN NaN -> NaN Invalid_operation
+dqadd7849 add sNaN sNaN -> NaN Invalid_operation
+dqadd7850 add NaN sNaN -> NaN Invalid_operation
+dqadd7851 add -Inf sNaN -> NaN Invalid_operation
+dqadd7852 add -1000 sNaN -> NaN Invalid_operation
+dqadd7853 add -1 sNaN -> NaN Invalid_operation
+dqadd7854 add -0 sNaN -> NaN Invalid_operation
+dqadd7855 add 0 sNaN -> NaN Invalid_operation
+dqadd7856 add 1 sNaN -> NaN Invalid_operation
+dqadd7857 add 1000 sNaN -> NaN Invalid_operation
+dqadd7858 add Inf sNaN -> NaN Invalid_operation
+dqadd7859 add NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqadd7861 add NaN1 -Inf -> NaN1
+dqadd7862 add +NaN2 -1000 -> NaN2
+dqadd7863 add NaN3 1000 -> NaN3
+dqadd7864 add NaN4 Inf -> NaN4
+dqadd7865 add NaN5 +NaN6 -> NaN5
+dqadd7866 add -Inf NaN7 -> NaN7
+dqadd7867 add -1000 NaN8 -> NaN8
+dqadd7868 add 1000 NaN9 -> NaN9
+dqadd7869 add Inf +NaN10 -> NaN10
+dqadd7871 add sNaN11 -Inf -> NaN11 Invalid_operation
+dqadd7872 add sNaN12 -1000 -> NaN12 Invalid_operation
+dqadd7873 add sNaN13 1000 -> NaN13 Invalid_operation
+dqadd7874 add sNaN14 NaN17 -> NaN14 Invalid_operation
+dqadd7875 add sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqadd7876 add NaN16 sNaN19 -> NaN19 Invalid_operation
+dqadd7877 add -Inf +sNaN20 -> NaN20 Invalid_operation
+dqadd7878 add -1000 sNaN21 -> NaN21 Invalid_operation
+dqadd7879 add 1000 sNaN22 -> NaN22 Invalid_operation
+dqadd7880 add Inf sNaN23 -> NaN23 Invalid_operation
+dqadd7881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqadd7882 add -NaN26 NaN28 -> -NaN26
+dqadd7883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqadd7884 add 1000 -NaN30 -> -NaN30
+dqadd7885 add 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Here we explore near the boundary of rounding a subnormal to Nmin
+dqadd7575 add 1E-6143 -1E-6176 -> 9.99999999999999999999999999999999E-6144 Subnormal
+dqadd7576 add -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal
+
+-- check overflow edge case
+-- 1234567890123456
+dqadd7972 apply 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqadd7973 add 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7974 add 9999999999999999999999999999999999E+6111 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7975 add 9999999999999999999999999999999999E+6111 1E+6111 -> Infinity Overflow Inexact Rounded
+dqadd7976 add 9999999999999999999999999999999999E+6111 9E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7977 add 9999999999999999999999999999999999E+6111 8E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7978 add 9999999999999999999999999999999999E+6111 7E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7979 add 9999999999999999999999999999999999E+6111 6E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7980 add 9999999999999999999999999999999999E+6111 5E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7981 add 9999999999999999999999999999999999E+6111 4E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7982 add 9999999999999999999999999999999999E+6111 3E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7983 add 9999999999999999999999999999999999E+6111 2E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7984 add 9999999999999999999999999999999999E+6111 1E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+
+dqadd7985 apply -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqadd7986 add -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7987 add -9999999999999999999999999999999999E+6111 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7988 add -9999999999999999999999999999999999E+6111 -1E+6111 -> -Infinity Overflow Inexact Rounded
+dqadd7989 add -9999999999999999999999999999999999E+6111 -9E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7990 add -9999999999999999999999999999999999E+6111 -8E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7991 add -9999999999999999999999999999999999E+6111 -7E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7992 add -9999999999999999999999999999999999E+6111 -6E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7993 add -9999999999999999999999999999999999E+6111 -5E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7994 add -9999999999999999999999999999999999E+6111 -4E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7995 add -9999999999999999999999999999999999E+6111 -3E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7996 add -9999999999999999999999999999999999E+6111 -2E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7997 add -9999999999999999999999999999999999E+6111 -1E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+dqadd71100 add 1e+2 -1e-6143 -> 99.99999999999999999999999999999999 Rounded Inexact
+dqadd71101 add 1e+1 -1e-6143 -> 9.999999999999999999999999999999999 Rounded Inexact
+dqadd71103 add +1 -1e-6143 -> 0.9999999999999999999999999999999999 Rounded Inexact
+dqadd71104 add 1e-1 -1e-6143 -> 0.09999999999999999999999999999999999 Rounded Inexact
+dqadd71105 add 1e-2 -1e-6143 -> 0.009999999999999999999999999999999999 Rounded Inexact
+dqadd71106 add 1e-3 -1e-6143 -> 0.0009999999999999999999999999999999999 Rounded Inexact
+dqadd71107 add 1e-4 -1e-6143 -> 0.00009999999999999999999999999999999999 Rounded Inexact
+dqadd71108 add 1e-5 -1e-6143 -> 0.000009999999999999999999999999999999999 Rounded Inexact
+dqadd71109 add 1e-6 -1e-6143 -> 9.999999999999999999999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+dqadd71110 add -1e+2 +1e-6143 -> -99.99999999999999999999999999999999 Rounded Inexact
+dqadd71111 add -1e+1 +1e-6143 -> -9.999999999999999999999999999999999 Rounded Inexact
+dqadd71113 add -1 +1e-6143 -> -0.9999999999999999999999999999999999 Rounded Inexact
+dqadd71114 add -1e-1 +1e-6143 -> -0.09999999999999999999999999999999999 Rounded Inexact
+dqadd71115 add -1e-2 +1e-6143 -> -0.009999999999999999999999999999999999 Rounded Inexact
+dqadd71116 add -1e-3 +1e-6143 -> -0.0009999999999999999999999999999999999 Rounded Inexact
+dqadd71117 add -1e-4 +1e-6143 -> -0.00009999999999999999999999999999999999 Rounded Inexact
+dqadd71118 add -1e-5 +1e-6143 -> -0.000009999999999999999999999999999999999 Rounded Inexact
+dqadd71119 add -1e-6 +1e-6143 -> -9.999999999999999999999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+dqadd71300 add 1E34 -0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71310 add 1E34 -0.51 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71311 add 1E34 -0.501 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71312 add 1E34 -0.5001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71313 add 1E34 -0.50001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71314 add 1E34 -0.500001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71315 add 1E34 -0.5000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71316 add 1E34 -0.50000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71317 add 1E34 -0.500000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71318 add 1E34 -0.5000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71319 add 1E34 -0.50000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71320 add 1E34 -0.500000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71321 add 1E34 -0.5000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71322 add 1E34 -0.50000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71323 add 1E34 -0.500000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71324 add 1E34 -0.5000000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71325 add 1E34 -0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71326 add 1E34 -0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71327 add 1E34 -0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71328 add 1E34 -0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71329 add 1E34 -0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71330 add 1E34 -0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71331 add 1E34 -0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71332 add 1E34 -0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71333 add 1E34 -0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71334 add 1E34 -0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71335 add 1E34 -0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71336 add 1E34 -0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71337 add 1E34 -0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71338 add 1E34 -0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71339 add 1E34 -0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+
+dqadd71340 add 1E34 -5000000.000010001 -> 9999999999999999999999999995000000 Inexact Rounded
+dqadd71341 add 1E34 -5000000.000000001 -> 9999999999999999999999999995000000 Inexact Rounded
+
+dqadd71349 add 9999999999999999999999999999999999 0.4 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71350 add 9999999999999999999999999999999999 0.49 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71351 add 9999999999999999999999999999999999 0.499 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71352 add 9999999999999999999999999999999999 0.4999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71353 add 9999999999999999999999999999999999 0.49999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71354 add 9999999999999999999999999999999999 0.499999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71355 add 9999999999999999999999999999999999 0.4999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71356 add 9999999999999999999999999999999999 0.49999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71357 add 9999999999999999999999999999999999 0.499999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71358 add 9999999999999999999999999999999999 0.4999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71359 add 9999999999999999999999999999999999 0.49999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71360 add 9999999999999999999999999999999999 0.499999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71361 add 9999999999999999999999999999999999 0.4999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71362 add 9999999999999999999999999999999999 0.49999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71363 add 9999999999999999999999999999999999 0.499999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71364 add 9999999999999999999999999999999999 0.4999999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71365 add 9999999999999999999999999999999999 0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71367 add 9999999999999999999999999999999999 0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71368 add 9999999999999999999999999999999999 0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71369 add 9999999999999999999999999999999999 0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71370 add 9999999999999999999999999999999999 0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71371 add 9999999999999999999999999999999999 0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71372 add 9999999999999999999999999999999999 0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71373 add 9999999999999999999999999999999999 0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71374 add 9999999999999999999999999999999999 0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71375 add 9999999999999999999999999999999999 0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71376 add 9999999999999999999999999999999999 0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71377 add 9999999999999999999999999999999999 0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71378 add 9999999999999999999999999999999999 0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71379 add 9999999999999999999999999999999999 0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71380 add 9999999999999999999999999999999999 0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71381 add 9999999999999999999999999999999999 0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71382 add 9999999999999999999999999999999999 0.5000000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71383 add 9999999999999999999999999999999999 0.500000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71384 add 9999999999999999999999999999999999 0.50000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71385 add 9999999999999999999999999999999999 0.5000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71386 add 9999999999999999999999999999999999 0.500000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71387 add 9999999999999999999999999999999999 0.50000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71388 add 9999999999999999999999999999999999 0.5000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71389 add 9999999999999999999999999999999999 0.500000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71390 add 9999999999999999999999999999999999 0.50000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71391 add 9999999999999999999999999999999999 0.5000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71392 add 9999999999999999999999999999999999 0.500001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71393 add 9999999999999999999999999999999999 0.50001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71394 add 9999999999999999999999999999999999 0.5001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71395 add 9999999999999999999999999999999999 0.501 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71396 add 9999999999999999999999999999999999 0.51 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+dqadd71420 add 0 1.123456789987654321123456789012345 -> 1.123456789987654321123456789012345
+dqadd71421 add 0 1.123456789987654321123456789012345E-1 -> 0.1123456789987654321123456789012345
+dqadd71422 add 0 1.123456789987654321123456789012345E-2 -> 0.01123456789987654321123456789012345
+dqadd71423 add 0 1.123456789987654321123456789012345E-3 -> 0.001123456789987654321123456789012345
+dqadd71424 add 0 1.123456789987654321123456789012345E-4 -> 0.0001123456789987654321123456789012345
+dqadd71425 add 0 1.123456789987654321123456789012345E-5 -> 0.00001123456789987654321123456789012345
+dqadd71426 add 0 1.123456789987654321123456789012345E-6 -> 0.000001123456789987654321123456789012345
+dqadd71427 add 0 1.123456789987654321123456789012345E-7 -> 1.123456789987654321123456789012345E-7
+dqadd71428 add 0 1.123456789987654321123456789012345E-8 -> 1.123456789987654321123456789012345E-8
+dqadd71429 add 0 1.123456789987654321123456789012345E-9 -> 1.123456789987654321123456789012345E-9
+dqadd71430 add 0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
+dqadd71431 add 0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
+dqadd71432 add 0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
+dqadd71433 add 0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
+dqadd71434 add 0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
+dqadd71435 add 0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
+dqadd71436 add 0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
+dqadd71437 add 0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
+dqadd71438 add 0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
+dqadd71439 add 0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
+dqadd71440 add 0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
+dqadd71441 add 0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
+dqadd71442 add 0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
+dqadd71443 add 0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
+dqadd71444 add 0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
+dqadd71445 add 0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
+dqadd71446 add 0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
+dqadd71447 add 0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
+dqadd71448 add 0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
+dqadd71449 add 0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
+dqadd71450 add 0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
+dqadd71451 add 0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
+dqadd71452 add 0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
+dqadd71453 add 0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
+dqadd71454 add 0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
+dqadd71455 add 0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
+dqadd71456 add 0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36
+
+-- same, reversed 0
+dqadd71460 add 1.123456789987654321123456789012345 0 -> 1.123456789987654321123456789012345
+dqadd71461 add 1.123456789987654321123456789012345E-1 0 -> 0.1123456789987654321123456789012345
+dqadd71462 add 1.123456789987654321123456789012345E-2 0 -> 0.01123456789987654321123456789012345
+dqadd71463 add 1.123456789987654321123456789012345E-3 0 -> 0.001123456789987654321123456789012345
+dqadd71464 add 1.123456789987654321123456789012345E-4 0 -> 0.0001123456789987654321123456789012345
+dqadd71465 add 1.123456789987654321123456789012345E-5 0 -> 0.00001123456789987654321123456789012345
+dqadd71466 add 1.123456789987654321123456789012345E-6 0 -> 0.000001123456789987654321123456789012345
+dqadd71467 add 1.123456789987654321123456789012345E-7 0 -> 1.123456789987654321123456789012345E-7
+dqadd71468 add 1.123456789987654321123456789012345E-8 0 -> 1.123456789987654321123456789012345E-8
+dqadd71469 add 1.123456789987654321123456789012345E-9 0 -> 1.123456789987654321123456789012345E-9
+dqadd71470 add 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
+dqadd71471 add 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
+dqadd71472 add 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
+dqadd71473 add 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
+dqadd71474 add 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
+dqadd71475 add 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
+dqadd71476 add 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
+dqadd71477 add 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
+dqadd71478 add 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
+dqadd71479 add 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
+dqadd71480 add 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
+dqadd71481 add 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
+dqadd71482 add 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
+dqadd71483 add 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
+dqadd71484 add 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
+dqadd71485 add 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
+dqadd71486 add 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
+dqadd71487 add 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
+dqadd71488 add 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
+dqadd71489 add 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
+dqadd71490 add 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
+dqadd71491 add 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
+dqadd71492 add 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
+dqadd71493 add 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
+dqadd71494 add 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
+dqadd71495 add 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
+dqadd71496 add 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36
+
+-- same, Es on the 0
+dqadd71500 add 1.123456789987654321123456789012345 0E-0 -> 1.123456789987654321123456789012345
+dqadd71501 add 1.123456789987654321123456789012345 0E-1 -> 1.123456789987654321123456789012345
+dqadd71502 add 1.123456789987654321123456789012345 0E-2 -> 1.123456789987654321123456789012345
+dqadd71503 add 1.123456789987654321123456789012345 0E-3 -> 1.123456789987654321123456789012345
+dqadd71504 add 1.123456789987654321123456789012345 0E-4 -> 1.123456789987654321123456789012345
+dqadd71505 add 1.123456789987654321123456789012345 0E-5 -> 1.123456789987654321123456789012345
+dqadd71506 add 1.123456789987654321123456789012345 0E-6 -> 1.123456789987654321123456789012345
+dqadd71507 add 1.123456789987654321123456789012345 0E-7 -> 1.123456789987654321123456789012345
+dqadd71508 add 1.123456789987654321123456789012345 0E-8 -> 1.123456789987654321123456789012345
+dqadd71509 add 1.123456789987654321123456789012345 0E-9 -> 1.123456789987654321123456789012345
+dqadd71510 add 1.123456789987654321123456789012345 0E-10 -> 1.123456789987654321123456789012345
+dqadd71511 add 1.123456789987654321123456789012345 0E-11 -> 1.123456789987654321123456789012345
+dqadd71512 add 1.123456789987654321123456789012345 0E-12 -> 1.123456789987654321123456789012345
+dqadd71513 add 1.123456789987654321123456789012345 0E-13 -> 1.123456789987654321123456789012345
+dqadd71514 add 1.123456789987654321123456789012345 0E-14 -> 1.123456789987654321123456789012345
+dqadd71515 add 1.123456789987654321123456789012345 0E-15 -> 1.123456789987654321123456789012345
+dqadd71516 add 1.123456789987654321123456789012345 0E-16 -> 1.123456789987654321123456789012345
+dqadd71517 add 1.123456789987654321123456789012345 0E-17 -> 1.123456789987654321123456789012345
+dqadd71518 add 1.123456789987654321123456789012345 0E-18 -> 1.123456789987654321123456789012345
+dqadd71519 add 1.123456789987654321123456789012345 0E-19 -> 1.123456789987654321123456789012345
+dqadd71520 add 1.123456789987654321123456789012345 0E-20 -> 1.123456789987654321123456789012345
+dqadd71521 add 1.123456789987654321123456789012345 0E-21 -> 1.123456789987654321123456789012345
+dqadd71522 add 1.123456789987654321123456789012345 0E-22 -> 1.123456789987654321123456789012345
+dqadd71523 add 1.123456789987654321123456789012345 0E-23 -> 1.123456789987654321123456789012345
+dqadd71524 add 1.123456789987654321123456789012345 0E-24 -> 1.123456789987654321123456789012345
+dqadd71525 add 1.123456789987654321123456789012345 0E-25 -> 1.123456789987654321123456789012345
+dqadd71526 add 1.123456789987654321123456789012345 0E-26 -> 1.123456789987654321123456789012345
+dqadd71527 add 1.123456789987654321123456789012345 0E-27 -> 1.123456789987654321123456789012345
+dqadd71528 add 1.123456789987654321123456789012345 0E-28 -> 1.123456789987654321123456789012345
+dqadd71529 add 1.123456789987654321123456789012345 0E-29 -> 1.123456789987654321123456789012345
+dqadd71530 add 1.123456789987654321123456789012345 0E-30 -> 1.123456789987654321123456789012345
+dqadd71531 add 1.123456789987654321123456789012345 0E-31 -> 1.123456789987654321123456789012345
+dqadd71532 add 1.123456789987654321123456789012345 0E-32 -> 1.123456789987654321123456789012345
+dqadd71533 add 1.123456789987654321123456789012345 0E-33 -> 1.123456789987654321123456789012345
+-- next four flag Rounded because the 0 extends the result
+dqadd71534 add 1.123456789987654321123456789012345 0E-34 -> 1.123456789987654321123456789012345 Rounded
+dqadd71535 add 1.123456789987654321123456789012345 0E-35 -> 1.123456789987654321123456789012345 Rounded
+dqadd71536 add 1.123456789987654321123456789012345 0E-36 -> 1.123456789987654321123456789012345 Rounded
+dqadd71537 add 1.123456789987654321123456789012345 0E-37 -> 1.123456789987654321123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+dqadd71600 add 0 0E-19 -> 0E-19
+dqadd71601 add -0 0E-19 -> 0E-19
+dqadd71602 add 0 -0E-19 -> 0E-19
+dqadd71603 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71611 add -11 11 -> 0
+dqadd71612 add 11 -11 -> 0
+
+rounding: half_down
+-- exact zeros from zeros
+dqadd71620 add 0 0E-19 -> 0E-19
+dqadd71621 add -0 0E-19 -> 0E-19
+dqadd71622 add 0 -0E-19 -> 0E-19
+dqadd71623 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71631 add -11 11 -> 0
+dqadd71632 add 11 -11 -> 0
+
+rounding: half_even
+-- exact zeros from zeros
+dqadd71640 add 0 0E-19 -> 0E-19
+dqadd71641 add -0 0E-19 -> 0E-19
+dqadd71642 add 0 -0E-19 -> 0E-19
+dqadd71643 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71651 add -11 11 -> 0
+dqadd71652 add 11 -11 -> 0
+
+rounding: up
+-- exact zeros from zeros
+dqadd71660 add 0 0E-19 -> 0E-19
+dqadd71661 add -0 0E-19 -> 0E-19
+dqadd71662 add 0 -0E-19 -> 0E-19
+dqadd71663 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71671 add -11 11 -> 0
+dqadd71672 add 11 -11 -> 0
+
+rounding: down
+-- exact zeros from zeros
+dqadd71680 add 0 0E-19 -> 0E-19
+dqadd71681 add -0 0E-19 -> 0E-19
+dqadd71682 add 0 -0E-19 -> 0E-19
+dqadd71683 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71691 add -11 11 -> 0
+dqadd71692 add 11 -11 -> 0
+
+rounding: ceiling
+-- exact zeros from zeros
+dqadd71700 add 0 0E-19 -> 0E-19
+dqadd71701 add -0 0E-19 -> 0E-19
+dqadd71702 add 0 -0E-19 -> 0E-19
+dqadd71703 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71711 add -11 11 -> 0
+dqadd71712 add 11 -11 -> 0
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+dqadd71720 add 0 0E-19 -> 0E-19
+dqadd71721 add -0 0E-19 -> -0E-19 -- *
+dqadd71722 add 0 -0E-19 -> -0E-19 -- *
+dqadd71723 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71731 add -11 11 -> -0 -- *
+dqadd71732 add 11 -11 -> -0 -- *
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dqadd71741 add 130E-2 120E-2 -> 2.50
+dqadd71742 add 130E-2 12E-1 -> 2.50
+dqadd71743 add 130E-2 1E0 -> 2.30
+dqadd71744 add 1E2 1E4 -> 1.01E+4
+dqadd71745 add 130E-2 -120E-2 -> 0.10
+dqadd71746 add 130E-2 -12E-1 -> 0.10
+dqadd71747 add 130E-2 -1E0 -> 0.30
+dqadd71748 add 1E2 -1E4 -> -9.9E+3
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+dqadd75001 add 1239876543211234567894567890123456 1 -> 1239876543211234567894567890123457
+dqadd75002 add 1239876543211234567894567890123456 0.6 -> 1239876543211234567894567890123457 Inexact Rounded
+dqadd75003 add 1239876543211234567894567890123456 0.06 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75004 add 1239876543211234567894567890123456 6E-3 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75005 add 1239876543211234567894567890123456 6E-4 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75006 add 1239876543211234567894567890123456 6E-5 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75007 add 1239876543211234567894567890123456 6E-6 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75008 add 1239876543211234567894567890123456 6E-7 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75009 add 1239876543211234567894567890123456 6E-8 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75010 add 1239876543211234567894567890123456 6E-9 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75011 add 1239876543211234567894567890123456 6E-10 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75012 add 1239876543211234567894567890123456 6E-11 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75013 add 1239876543211234567894567890123456 6E-12 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75014 add 1239876543211234567894567890123456 6E-13 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75015 add 1239876543211234567894567890123456 6E-14 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75016 add 1239876543211234567894567890123456 6E-15 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75017 add 1239876543211234567894567890123456 6E-16 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75018 add 1239876543211234567894567890123456 6E-17 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75019 add 1239876543211234567894567890123456 6E-18 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75020 add 1239876543211234567894567890123456 6E-19 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75021 add 1239876543211234567894567890123456 6E-20 -> 1239876543211234567894567890123456 Inexact Rounded
+
+-- widening second argument at gap
+dqadd75030 add 12398765432112345678945678 1 -> 12398765432112345678945679
+dqadd75031 add 12398765432112345678945678 0.1 -> 12398765432112345678945678.1
+dqadd75032 add 12398765432112345678945678 0.12 -> 12398765432112345678945678.12
+dqadd75033 add 12398765432112345678945678 0.123 -> 12398765432112345678945678.123
+dqadd75034 add 12398765432112345678945678 0.1234 -> 12398765432112345678945678.1234
+dqadd75035 add 12398765432112345678945678 0.12345 -> 12398765432112345678945678.12345
+dqadd75036 add 12398765432112345678945678 0.123456 -> 12398765432112345678945678.123456
+dqadd75037 add 12398765432112345678945678 0.1234567 -> 12398765432112345678945678.1234567
+dqadd75038 add 12398765432112345678945678 0.12345678 -> 12398765432112345678945678.12345678
+dqadd75039 add 12398765432112345678945678 0.123456789 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75040 add 12398765432112345678945678 0.123456785 -> 12398765432112345678945678.12345678 Inexact Rounded
+dqadd75041 add 12398765432112345678945678 0.1234567850 -> 12398765432112345678945678.12345678 Inexact Rounded
+dqadd75042 add 12398765432112345678945678 0.1234567851 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75043 add 12398765432112345678945678 0.12345678501 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75044 add 12398765432112345678945678 0.123456785001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75045 add 12398765432112345678945678 0.1234567850001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75046 add 12398765432112345678945678 0.12345678500001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75047 add 12398765432112345678945678 0.123456785000001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75048 add 12398765432112345678945678 0.1234567850000001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75049 add 12398765432112345678945678 0.1234567850000000 -> 12398765432112345678945678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+dqadd75050 add 12398765432112345678945678 0.0234567750000000 -> 12398765432112345678945678.02345678 Inexact Rounded
+dqadd75051 add 12398765432112345678945678 0.0034567750000000 -> 12398765432112345678945678.00345678 Inexact Rounded
+dqadd75052 add 12398765432112345678945678 0.0004567750000000 -> 12398765432112345678945678.00045678 Inexact Rounded
+dqadd75053 add 12398765432112345678945678 0.0000567750000000 -> 12398765432112345678945678.00005678 Inexact Rounded
+dqadd75054 add 12398765432112345678945678 0.0000067750000000 -> 12398765432112345678945678.00000678 Inexact Rounded
+dqadd75055 add 12398765432112345678945678 0.0000007750000000 -> 12398765432112345678945678.00000078 Inexact Rounded
+dqadd75056 add 12398765432112345678945678 0.0000000750000000 -> 12398765432112345678945678.00000008 Inexact Rounded
+dqadd75057 add 12398765432112345678945678 0.0000000050000000 -> 12398765432112345678945678.00000000 Inexact Rounded
+dqadd75060 add 12398765432112345678945678 0.0234567750000001 -> 12398765432112345678945678.02345678 Inexact Rounded
+dqadd75061 add 12398765432112345678945678 0.0034567750000001 -> 12398765432112345678945678.00345678 Inexact Rounded
+dqadd75062 add 12398765432112345678945678 0.0004567750000001 -> 12398765432112345678945678.00045678 Inexact Rounded
+dqadd75063 add 12398765432112345678945678 0.0000567750000001 -> 12398765432112345678945678.00005678 Inexact Rounded
+dqadd75064 add 12398765432112345678945678 0.0000067750000001 -> 12398765432112345678945678.00000678 Inexact Rounded
+dqadd75065 add 12398765432112345678945678 0.0000007750000001 -> 12398765432112345678945678.00000078 Inexact Rounded
+dqadd75066 add 12398765432112345678945678 0.0000000750000001 -> 12398765432112345678945678.00000008 Inexact Rounded
+dqadd75067 add 12398765432112345678945678 0.0000000050000001 -> 12398765432112345678945678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+dqadd75070 add 12398765432112345678945678 1E-8 -> 12398765432112345678945678.00000001
+dqadd75071 add 12398765432112345678945678 1E-9 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75072 add 12398765432112345678945678 1E-10 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75073 add 12398765432112345678945678 1E-11 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75074 add 12398765432112345678945678 1E-12 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75075 add 12398765432112345678945678 1E-13 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75076 add 12398765432112345678945678 1E-14 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75077 add 12398765432112345678945678 1E-15 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75078 add 12398765432112345678945678 1E-16 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75079 add 12398765432112345678945678 1E-17 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75080 add 12398765432112345678945678 1E-18 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75081 add 12398765432112345678945678 1E-19 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75082 add 12398765432112345678945678 1E-20 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75083 add 12398765432112345678945678 1E-25 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75084 add 12398765432112345678945678 1E-30 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75085 add 12398765432112345678945678 1E-31 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75086 add 12398765432112345678945678 1E-32 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75087 add 12398765432112345678945678 1E-33 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75088 add 12398765432112345678945678 1E-34 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75089 add 12398765432112345678945678 1E-35 -> 12398765432112345678945678.00000001 Inexact Rounded
+
+-- Null tests
+dqadd9990 add 10 # -> NaN Invalid_operation
+dqadd9991 add # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqAnd.decTest b/Lib/test/decimaltestdata/dqAnd.decTest
index d609bc1c3b..57c416b48c 100644
--- a/Lib/test/decimaltestdata/dqAnd.decTest
+++ b/Lib/test/decimaltestdata/dqAnd.decTest
@@ -1,420 +1,420 @@
-------------------------------------------------------------------------
--- dqAnd.decTest -- digitwise logical AND for decQuads --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check (truth table)
-dqand001 and 0 0 -> 0
-dqand002 and 0 1 -> 0
-dqand003 and 1 0 -> 0
-dqand004 and 1 1 -> 1
-dqand005 and 1100 1010 -> 1000
--- and at msd and msd-1
--- 1234567890123456789012345678901234
-dqand006 and 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqand007 and 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 0
-dqand008 and 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqand009 and 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqand010 and 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqand011 and 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 0
-dqand012 and 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqand013 and 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
-
--- Various lengths
--- 1234567890123456789012345678901234
-
-dqand601 and 0111111111111111111111111111111111 1111111111111111111111111111111111 -> 111111111111111111111111111111111
-dqand602 and 1011111111111111111111111111111111 1111111111111111111111111111111111 -> 1011111111111111111111111111111111
-dqand603 and 1101111111111111111111111111111111 1111111111111111111111111111111111 -> 1101111111111111111111111111111111
-dqand604 and 1110111111111111111111111111111111 1111111111111111111111111111111111 -> 1110111111111111111111111111111111
-dqand605 and 1111011111111111111111111111111111 1111111111111111111111111111111111 -> 1111011111111111111111111111111111
-dqand606 and 1111101111111111111111111111111111 1111111111111111111111111111111111 -> 1111101111111111111111111111111111
-dqand607 and 1111110111111111111111111111111111 1111111111111111111111111111111111 -> 1111110111111111111111111111111111
-dqand608 and 1111111011111111111111111111111111 1111111111111111111111111111111111 -> 1111111011111111111111111111111111
-dqand609 and 1111111101111111111111111111111111 1111111111111111111111111111111111 -> 1111111101111111111111111111111111
-dqand610 and 1111111110111111111111111111111111 1111111111111111111111111111111111 -> 1111111110111111111111111111111111
-dqand611 and 1111111111011111111111111111111111 1111111111111111111111111111111111 -> 1111111111011111111111111111111111
-dqand612 and 1111111111101111111111111111111111 1111111111111111111111111111111111 -> 1111111111101111111111111111111111
-dqand613 and 1111111111110111111111111111111111 1111111111111111111111111111111111 -> 1111111111110111111111111111111111
-dqand614 and 1111111111111011111111111111111111 1111111111111111111111111111111111 -> 1111111111111011111111111111111111
-dqand615 and 1111111111111101111111111111111111 1111111111111111111111111111111111 -> 1111111111111101111111111111111111
-dqand616 and 1111111111111110111111111111111111 1111111111111111111111111111111111 -> 1111111111111110111111111111111111
-dqand617 and 1111111111111111011111111111111111 1111111111111111111111111111111111 -> 1111111111111111011111111111111111
-dqand618 and 1111111111111111101111111111111111 1111111111111111111111111111111111 -> 1111111111111111101111111111111111
-dqand619 and 1111111111111111110111111111111111 1111111111111111111111111111111111 -> 1111111111111111110111111111111111
-dqand620 and 1111111111111111111011111111111111 1111111111111111111111111111111111 -> 1111111111111111111011111111111111
-dqand621 and 1111111111111111111101111111111111 1111111111111111111111111111111111 -> 1111111111111111111101111111111111
-dqand622 and 1111111111111111111110111111111111 1111111111111111111111111111111111 -> 1111111111111111111110111111111111
-dqand623 and 1111111111111111111111011111111111 1111111111111111111111111111111111 -> 1111111111111111111111011111111111
-dqand624 and 1111111111111111111111101111111111 1111111111111111111111111111111111 -> 1111111111111111111111101111111111
-dqand625 and 1111111111111111111111110111111111 1111111111111111111111111111111111 -> 1111111111111111111111110111111111
-dqand626 and 1111111111111111111111111011111111 1111111111111111111111111111111111 -> 1111111111111111111111111011111111
-dqand627 and 1111111111111111111111111101111111 1111111111111111111111111111111111 -> 1111111111111111111111111101111111
-dqand628 and 1111111111111111111111111110111111 1111111111111111111111111111111111 -> 1111111111111111111111111110111111
-dqand629 and 1111111111111111111111111111011111 1111111111111111111111111111111111 -> 1111111111111111111111111111011111
-dqand630 and 1111111111111111111111111111101111 1111111111111111111111111111111111 -> 1111111111111111111111111111101111
-dqand631 and 1111111111111111111111111111110111 1111111111111111111111111111111111 -> 1111111111111111111111111111110111
-dqand632 and 1111111111111111111111111111111011 1111111111111111111111111111111111 -> 1111111111111111111111111111111011
-dqand633 and 1111111111111111111111111111111101 1111111111111111111111111111111111 -> 1111111111111111111111111111111101
-dqand634 and 1111111111111111111111111111111110 1111111111111111111111111111111111 -> 1111111111111111111111111111111110
-
-dqand641 and 1111111111111111111111111111111111 0111111111111111111111111111111111 -> 111111111111111111111111111111111
-dqand642 and 1111111111111111111111111111111111 1011111111111111111111111111111111 -> 1011111111111111111111111111111111
-dqand643 and 1111111111111111111111111111111111 1101111111111111111111111111111111 -> 1101111111111111111111111111111111
-dqand644 and 1111111111111111111111111111111111 1110111111111111111111111111111111 -> 1110111111111111111111111111111111
-dqand645 and 1111111111111111111111111111111111 1111011111111111111111111111111111 -> 1111011111111111111111111111111111
-dqand646 and 1111111111111111111111111111111111 1111101111111111111111111111111111 -> 1111101111111111111111111111111111
-dqand647 and 1111111111111111111111111111111111 1111110111111111111111111111111111 -> 1111110111111111111111111111111111
-dqand648 and 1111111111111111111111111111111111 1111111011111111111111111111111111 -> 1111111011111111111111111111111111
-dqand649 and 1111111111111111111111111111111111 1111111101111111111111111111111111 -> 1111111101111111111111111111111111
-dqand650 and 1111111111111111111111111111111111 1111111110111111111111111111111111 -> 1111111110111111111111111111111111
-dqand651 and 1111111111111111111111111111111111 1111111111011111111111111111111111 -> 1111111111011111111111111111111111
-dqand652 and 1111111111111111111111111111111111 1111111111101111111111111111111111 -> 1111111111101111111111111111111111
-dqand653 and 1111111111111111111111111111111111 1111111111110111111111111111111111 -> 1111111111110111111111111111111111
-dqand654 and 1111111111111111111111111111111111 1111111111111011111111111111111111 -> 1111111111111011111111111111111111
-dqand655 and 1111111111111111111111111111111111 1111111111111101111111111111111111 -> 1111111111111101111111111111111111
-dqand656 and 1111111111111111111111111111111111 1111111111111110111111111111111111 -> 1111111111111110111111111111111111
-dqand657 and 1111111111111111111111111111111111 1111111111111111011111111111111111 -> 1111111111111111011111111111111111
-dqand658 and 1111111111111111111111111111111111 1111111111111111101111111111111111 -> 1111111111111111101111111111111111
-dqand659 and 1111111111111111111111111111111111 1111111111111111110111111111111111 -> 1111111111111111110111111111111111
-dqand660 and 1111111111111111111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111011111111111111
-dqand661 and 1111111111111111111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111101111111111111
-dqand662 and 1111111111111111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111110111111111111
-dqand663 and 1111111111111111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111011111111111
-dqand664 and 1111111111111111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111101111111111
-dqand665 and 1111111111111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111110111111111
-dqand666 and 1111111111111111111111111111111111 1111111111111111111111111011111111 -> 1111111111111111111111111011111111
-dqand667 and 1111111111111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111101111111
-dqand668 and 1111111111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111110111111
-dqand669 and 1111111111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111011111
-dqand670 and 1111111111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111101111
-dqand671 and 1111111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111110111
-dqand672 and 1111111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111011
-dqand673 and 1111111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111101
-dqand674 and 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
-dqand675 and 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 111111111111111111111111111111110
-dqand676 and 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
-
-dqand021 and 1111111111111111 1111111111111111 -> 1111111111111111
-dqand024 and 1111111111111111 111111111111111 -> 111111111111111
-dqand025 and 1111111111111111 11111111111111 -> 11111111111111
-dqand026 and 1111111111111111 1111111111111 -> 1111111111111
-dqand027 and 1111111111111111 111111111111 -> 111111111111
-dqand028 and 1111111111111111 11111111111 -> 11111111111
-dqand029 and 1111111111111111 1111111111 -> 1111111111
-dqand030 and 1111111111111111 111111111 -> 111111111
-dqand031 and 1111111111111111 11111111 -> 11111111
-dqand032 and 1111111111111111 1111111 -> 1111111
-dqand033 and 1111111111111111 111111 -> 111111
-dqand034 and 1111111111111111 11111 -> 11111
-dqand035 and 1111111111111111 1111 -> 1111
-dqand036 and 1111111111111111 111 -> 111
-dqand037 and 1111111111111111 11 -> 11
-dqand038 and 1111111111111111 1 -> 1
-dqand039 and 1111111111111111 0 -> 0
-
-dqand040 and 1111111111111111 1111111111111111 -> 1111111111111111
-dqand041 and 111111111111111 1111111111111111 -> 111111111111111
-dqand042 and 111111111111111 1111111111111111 -> 111111111111111
-dqand043 and 11111111111111 1111111111111111 -> 11111111111111
-dqand044 and 1111111111111 1111111111111111 -> 1111111111111
-dqand045 and 111111111111 1111111111111111 -> 111111111111
-dqand046 and 11111111111 1111111111111111 -> 11111111111
-dqand047 and 1111111111 1111111111111111 -> 1111111111
-dqand048 and 111111111 1111111111111111 -> 111111111
-dqand049 and 11111111 1111111111111111 -> 11111111
-dqand050 and 1111111 1111111111111111 -> 1111111
-dqand051 and 111111 1111111111111111 -> 111111
-dqand052 and 11111 1111111111111111 -> 11111
-dqand053 and 1111 1111111111111111 -> 1111
-dqand054 and 111 1111111111111111 -> 111
-dqand055 and 11 1111111111111111 -> 11
-dqand056 and 1 1111111111111111 -> 1
-dqand057 and 0 1111111111111111 -> 0
-
-dqand150 and 1111111111 1 -> 1
-dqand151 and 111111111 1 -> 1
-dqand152 and 11111111 1 -> 1
-dqand153 and 1111111 1 -> 1
-dqand154 and 111111 1 -> 1
-dqand155 and 11111 1 -> 1
-dqand156 and 1111 1 -> 1
-dqand157 and 111 1 -> 1
-dqand158 and 11 1 -> 1
-dqand159 and 1 1 -> 1
-
-dqand160 and 1111111111 0 -> 0
-dqand161 and 111111111 0 -> 0
-dqand162 and 11111111 0 -> 0
-dqand163 and 1111111 0 -> 0
-dqand164 and 111111 0 -> 0
-dqand165 and 11111 0 -> 0
-dqand166 and 1111 0 -> 0
-dqand167 and 111 0 -> 0
-dqand168 and 11 0 -> 0
-dqand169 and 1 0 -> 0
-
-dqand170 and 1 1111111111 -> 1
-dqand171 and 1 111111111 -> 1
-dqand172 and 1 11111111 -> 1
-dqand173 and 1 1111111 -> 1
-dqand174 and 1 111111 -> 1
-dqand175 and 1 11111 -> 1
-dqand176 and 1 1111 -> 1
-dqand177 and 1 111 -> 1
-dqand178 and 1 11 -> 1
-dqand179 and 1 1 -> 1
-
-dqand180 and 0 1111111111 -> 0
-dqand181 and 0 111111111 -> 0
-dqand182 and 0 11111111 -> 0
-dqand183 and 0 1111111 -> 0
-dqand184 and 0 111111 -> 0
-dqand185 and 0 11111 -> 0
-dqand186 and 0 1111 -> 0
-dqand187 and 0 111 -> 0
-dqand188 and 0 11 -> 0
-dqand189 and 0 1 -> 0
-
-dqand090 and 011111111 111111111 -> 11111111
-dqand091 and 101111111 111111111 -> 101111111
-dqand092 and 110111111 111111111 -> 110111111
-dqand093 and 111011111 111111111 -> 111011111
-dqand094 and 111101111 111111111 -> 111101111
-dqand095 and 111110111 111111111 -> 111110111
-dqand096 and 111111011 111111111 -> 111111011
-dqand097 and 111111101 111111111 -> 111111101
-dqand098 and 111111110 111111111 -> 111111110
-
-dqand100 and 111111111 011111111 -> 11111111
-dqand101 and 111111111 101111111 -> 101111111
-dqand102 and 111111111 110111111 -> 110111111
-dqand103 and 111111111 111011111 -> 111011111
-dqand104 and 111111111 111101111 -> 111101111
-dqand105 and 111111111 111110111 -> 111110111
-dqand106 and 111111111 111111011 -> 111111011
-dqand107 and 111111111 111111101 -> 111111101
-dqand108 and 111111111 111111110 -> 111111110
-
--- non-0/1 should not be accepted, nor should signs
-dqand220 and 111111112 111111111 -> NaN Invalid_operation
-dqand221 and 333333333 333333333 -> NaN Invalid_operation
-dqand222 and 555555555 555555555 -> NaN Invalid_operation
-dqand223 and 777777777 777777777 -> NaN Invalid_operation
-dqand224 and 999999999 999999999 -> NaN Invalid_operation
-dqand225 and 222222222 999999999 -> NaN Invalid_operation
-dqand226 and 444444444 999999999 -> NaN Invalid_operation
-dqand227 and 666666666 999999999 -> NaN Invalid_operation
-dqand228 and 888888888 999999999 -> NaN Invalid_operation
-dqand229 and 999999999 222222222 -> NaN Invalid_operation
-dqand230 and 999999999 444444444 -> NaN Invalid_operation
-dqand231 and 999999999 666666666 -> NaN Invalid_operation
-dqand232 and 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-dqand240 and 567468689 -934981942 -> NaN Invalid_operation
-dqand241 and 567367689 934981942 -> NaN Invalid_operation
-dqand242 and -631917772 -706014634 -> NaN Invalid_operation
-dqand243 and -756253257 138579234 -> NaN Invalid_operation
-dqand244 and 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-dqand250 and 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqand251 and 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqand252 and 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqand253 and 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqand254 and 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqand255 and 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqand256 and 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqand257 and 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqand258 and 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqand259 and 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqand260 and 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqand261 and 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
-dqand262 and 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqand263 and 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqand264 and 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqand265 and 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
--- test MSD-1
-dqand270 and 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
-dqand271 and 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
-dqand272 and 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
-dqand273 and 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
-dqand274 and 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
-dqand275 and 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
-dqand276 and 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
-dqand277 and 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
--- test LSD
-dqand280 and 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
-dqand281 and 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
-dqand282 and 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
-dqand283 and 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
-dqand284 and 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
-dqand285 and 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
-dqand286 and 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
-dqand287 and 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
--- test Middie
-dqand288 and 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
-dqand289 and 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
-dqand290 and 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
-dqand291 and 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
-dqand292 and 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
-dqand293 and 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
-dqand294 and 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
-dqand295 and 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
--- signs
-dqand296 and -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
-dqand297 and -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
-dqand298 and 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
-dqand299 and 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 110000110000110000001000000
-
--- Nmax, Nmin, Ntiny-like
-dqand331 and 2 9.99999999E+999 -> NaN Invalid_operation
-dqand332 and 3 1E-999 -> NaN Invalid_operation
-dqand333 and 4 1.00000000E-999 -> NaN Invalid_operation
-dqand334 and 5 1E-900 -> NaN Invalid_operation
-dqand335 and 6 -1E-900 -> NaN Invalid_operation
-dqand336 and 7 -1.00000000E-999 -> NaN Invalid_operation
-dqand337 and 8 -1E-999 -> NaN Invalid_operation
-dqand338 and 9 -9.99999999E+999 -> NaN Invalid_operation
-dqand341 and 9.99999999E+999 -18 -> NaN Invalid_operation
-dqand342 and 1E-999 01 -> NaN Invalid_operation
-dqand343 and 1.00000000E-999 -18 -> NaN Invalid_operation
-dqand344 and 1E-900 18 -> NaN Invalid_operation
-dqand345 and -1E-900 -10 -> NaN Invalid_operation
-dqand346 and -1.00000000E-999 18 -> NaN Invalid_operation
-dqand347 and -1E-999 10 -> NaN Invalid_operation
-dqand348 and -9.99999999E+999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-dqand361 and 1.0 1 -> NaN Invalid_operation
-dqand362 and 1E+1 1 -> NaN Invalid_operation
-dqand363 and 0.0 1 -> NaN Invalid_operation
-dqand364 and 0E+1 1 -> NaN Invalid_operation
-dqand365 and 9.9 1 -> NaN Invalid_operation
-dqand366 and 9E+1 1 -> NaN Invalid_operation
-dqand371 and 0 1.0 -> NaN Invalid_operation
-dqand372 and 0 1E+1 -> NaN Invalid_operation
-dqand373 and 0 0.0 -> NaN Invalid_operation
-dqand374 and 0 0E+1 -> NaN Invalid_operation
-dqand375 and 0 9.9 -> NaN Invalid_operation
-dqand376 and 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-dqand780 and -Inf -Inf -> NaN Invalid_operation
-dqand781 and -Inf -1000 -> NaN Invalid_operation
-dqand782 and -Inf -1 -> NaN Invalid_operation
-dqand783 and -Inf -0 -> NaN Invalid_operation
-dqand784 and -Inf 0 -> NaN Invalid_operation
-dqand785 and -Inf 1 -> NaN Invalid_operation
-dqand786 and -Inf 1000 -> NaN Invalid_operation
-dqand787 and -1000 -Inf -> NaN Invalid_operation
-dqand788 and -Inf -Inf -> NaN Invalid_operation
-dqand789 and -1 -Inf -> NaN Invalid_operation
-dqand790 and -0 -Inf -> NaN Invalid_operation
-dqand791 and 0 -Inf -> NaN Invalid_operation
-dqand792 and 1 -Inf -> NaN Invalid_operation
-dqand793 and 1000 -Inf -> NaN Invalid_operation
-dqand794 and Inf -Inf -> NaN Invalid_operation
-
-dqand800 and Inf -Inf -> NaN Invalid_operation
-dqand801 and Inf -1000 -> NaN Invalid_operation
-dqand802 and Inf -1 -> NaN Invalid_operation
-dqand803 and Inf -0 -> NaN Invalid_operation
-dqand804 and Inf 0 -> NaN Invalid_operation
-dqand805 and Inf 1 -> NaN Invalid_operation
-dqand806 and Inf 1000 -> NaN Invalid_operation
-dqand807 and Inf Inf -> NaN Invalid_operation
-dqand808 and -1000 Inf -> NaN Invalid_operation
-dqand809 and -Inf Inf -> NaN Invalid_operation
-dqand810 and -1 Inf -> NaN Invalid_operation
-dqand811 and -0 Inf -> NaN Invalid_operation
-dqand812 and 0 Inf -> NaN Invalid_operation
-dqand813 and 1 Inf -> NaN Invalid_operation
-dqand814 and 1000 Inf -> NaN Invalid_operation
-dqand815 and Inf Inf -> NaN Invalid_operation
-
-dqand821 and NaN -Inf -> NaN Invalid_operation
-dqand822 and NaN -1000 -> NaN Invalid_operation
-dqand823 and NaN -1 -> NaN Invalid_operation
-dqand824 and NaN -0 -> NaN Invalid_operation
-dqand825 and NaN 0 -> NaN Invalid_operation
-dqand826 and NaN 1 -> NaN Invalid_operation
-dqand827 and NaN 1000 -> NaN Invalid_operation
-dqand828 and NaN Inf -> NaN Invalid_operation
-dqand829 and NaN NaN -> NaN Invalid_operation
-dqand830 and -Inf NaN -> NaN Invalid_operation
-dqand831 and -1000 NaN -> NaN Invalid_operation
-dqand832 and -1 NaN -> NaN Invalid_operation
-dqand833 and -0 NaN -> NaN Invalid_operation
-dqand834 and 0 NaN -> NaN Invalid_operation
-dqand835 and 1 NaN -> NaN Invalid_operation
-dqand836 and 1000 NaN -> NaN Invalid_operation
-dqand837 and Inf NaN -> NaN Invalid_operation
-
-dqand841 and sNaN -Inf -> NaN Invalid_operation
-dqand842 and sNaN -1000 -> NaN Invalid_operation
-dqand843 and sNaN -1 -> NaN Invalid_operation
-dqand844 and sNaN -0 -> NaN Invalid_operation
-dqand845 and sNaN 0 -> NaN Invalid_operation
-dqand846 and sNaN 1 -> NaN Invalid_operation
-dqand847 and sNaN 1000 -> NaN Invalid_operation
-dqand848 and sNaN NaN -> NaN Invalid_operation
-dqand849 and sNaN sNaN -> NaN Invalid_operation
-dqand850 and NaN sNaN -> NaN Invalid_operation
-dqand851 and -Inf sNaN -> NaN Invalid_operation
-dqand852 and -1000 sNaN -> NaN Invalid_operation
-dqand853 and -1 sNaN -> NaN Invalid_operation
-dqand854 and -0 sNaN -> NaN Invalid_operation
-dqand855 and 0 sNaN -> NaN Invalid_operation
-dqand856 and 1 sNaN -> NaN Invalid_operation
-dqand857 and 1000 sNaN -> NaN Invalid_operation
-dqand858 and Inf sNaN -> NaN Invalid_operation
-dqand859 and NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqand861 and NaN1 -Inf -> NaN Invalid_operation
-dqand862 and +NaN2 -1000 -> NaN Invalid_operation
-dqand863 and NaN3 1000 -> NaN Invalid_operation
-dqand864 and NaN4 Inf -> NaN Invalid_operation
-dqand865 and NaN5 +NaN6 -> NaN Invalid_operation
-dqand866 and -Inf NaN7 -> NaN Invalid_operation
-dqand867 and -1000 NaN8 -> NaN Invalid_operation
-dqand868 and 1000 NaN9 -> NaN Invalid_operation
-dqand869 and Inf +NaN10 -> NaN Invalid_operation
-dqand871 and sNaN11 -Inf -> NaN Invalid_operation
-dqand872 and sNaN12 -1000 -> NaN Invalid_operation
-dqand873 and sNaN13 1000 -> NaN Invalid_operation
-dqand874 and sNaN14 NaN17 -> NaN Invalid_operation
-dqand875 and sNaN15 sNaN18 -> NaN Invalid_operation
-dqand876 and NaN16 sNaN19 -> NaN Invalid_operation
-dqand877 and -Inf +sNaN20 -> NaN Invalid_operation
-dqand878 and -1000 sNaN21 -> NaN Invalid_operation
-dqand879 and 1000 sNaN22 -> NaN Invalid_operation
-dqand880 and Inf sNaN23 -> NaN Invalid_operation
-dqand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
-dqand882 and -NaN26 NaN28 -> NaN Invalid_operation
-dqand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
-dqand884 and 1000 -NaN30 -> NaN Invalid_operation
-dqand885 and 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqAnd.decTest -- digitwise logical AND for decQuads --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check (truth table)
+dqand001 and 0 0 -> 0
+dqand002 and 0 1 -> 0
+dqand003 and 1 0 -> 0
+dqand004 and 1 1 -> 1
+dqand005 and 1100 1010 -> 1000
+-- and at msd and msd-1
+-- 1234567890123456789012345678901234
+dqand006 and 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqand007 and 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 0
+dqand008 and 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqand009 and 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqand010 and 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqand011 and 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 0
+dqand012 and 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqand013 and 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
+
+-- Various lengths
+-- 1234567890123456789012345678901234
+
+dqand601 and 0111111111111111111111111111111111 1111111111111111111111111111111111 -> 111111111111111111111111111111111
+dqand602 and 1011111111111111111111111111111111 1111111111111111111111111111111111 -> 1011111111111111111111111111111111
+dqand603 and 1101111111111111111111111111111111 1111111111111111111111111111111111 -> 1101111111111111111111111111111111
+dqand604 and 1110111111111111111111111111111111 1111111111111111111111111111111111 -> 1110111111111111111111111111111111
+dqand605 and 1111011111111111111111111111111111 1111111111111111111111111111111111 -> 1111011111111111111111111111111111
+dqand606 and 1111101111111111111111111111111111 1111111111111111111111111111111111 -> 1111101111111111111111111111111111
+dqand607 and 1111110111111111111111111111111111 1111111111111111111111111111111111 -> 1111110111111111111111111111111111
+dqand608 and 1111111011111111111111111111111111 1111111111111111111111111111111111 -> 1111111011111111111111111111111111
+dqand609 and 1111111101111111111111111111111111 1111111111111111111111111111111111 -> 1111111101111111111111111111111111
+dqand610 and 1111111110111111111111111111111111 1111111111111111111111111111111111 -> 1111111110111111111111111111111111
+dqand611 and 1111111111011111111111111111111111 1111111111111111111111111111111111 -> 1111111111011111111111111111111111
+dqand612 and 1111111111101111111111111111111111 1111111111111111111111111111111111 -> 1111111111101111111111111111111111
+dqand613 and 1111111111110111111111111111111111 1111111111111111111111111111111111 -> 1111111111110111111111111111111111
+dqand614 and 1111111111111011111111111111111111 1111111111111111111111111111111111 -> 1111111111111011111111111111111111
+dqand615 and 1111111111111101111111111111111111 1111111111111111111111111111111111 -> 1111111111111101111111111111111111
+dqand616 and 1111111111111110111111111111111111 1111111111111111111111111111111111 -> 1111111111111110111111111111111111
+dqand617 and 1111111111111111011111111111111111 1111111111111111111111111111111111 -> 1111111111111111011111111111111111
+dqand618 and 1111111111111111101111111111111111 1111111111111111111111111111111111 -> 1111111111111111101111111111111111
+dqand619 and 1111111111111111110111111111111111 1111111111111111111111111111111111 -> 1111111111111111110111111111111111
+dqand620 and 1111111111111111111011111111111111 1111111111111111111111111111111111 -> 1111111111111111111011111111111111
+dqand621 and 1111111111111111111101111111111111 1111111111111111111111111111111111 -> 1111111111111111111101111111111111
+dqand622 and 1111111111111111111110111111111111 1111111111111111111111111111111111 -> 1111111111111111111110111111111111
+dqand623 and 1111111111111111111111011111111111 1111111111111111111111111111111111 -> 1111111111111111111111011111111111
+dqand624 and 1111111111111111111111101111111111 1111111111111111111111111111111111 -> 1111111111111111111111101111111111
+dqand625 and 1111111111111111111111110111111111 1111111111111111111111111111111111 -> 1111111111111111111111110111111111
+dqand626 and 1111111111111111111111111011111111 1111111111111111111111111111111111 -> 1111111111111111111111111011111111
+dqand627 and 1111111111111111111111111101111111 1111111111111111111111111111111111 -> 1111111111111111111111111101111111
+dqand628 and 1111111111111111111111111110111111 1111111111111111111111111111111111 -> 1111111111111111111111111110111111
+dqand629 and 1111111111111111111111111111011111 1111111111111111111111111111111111 -> 1111111111111111111111111111011111
+dqand630 and 1111111111111111111111111111101111 1111111111111111111111111111111111 -> 1111111111111111111111111111101111
+dqand631 and 1111111111111111111111111111110111 1111111111111111111111111111111111 -> 1111111111111111111111111111110111
+dqand632 and 1111111111111111111111111111111011 1111111111111111111111111111111111 -> 1111111111111111111111111111111011
+dqand633 and 1111111111111111111111111111111101 1111111111111111111111111111111111 -> 1111111111111111111111111111111101
+dqand634 and 1111111111111111111111111111111110 1111111111111111111111111111111111 -> 1111111111111111111111111111111110
+
+dqand641 and 1111111111111111111111111111111111 0111111111111111111111111111111111 -> 111111111111111111111111111111111
+dqand642 and 1111111111111111111111111111111111 1011111111111111111111111111111111 -> 1011111111111111111111111111111111
+dqand643 and 1111111111111111111111111111111111 1101111111111111111111111111111111 -> 1101111111111111111111111111111111
+dqand644 and 1111111111111111111111111111111111 1110111111111111111111111111111111 -> 1110111111111111111111111111111111
+dqand645 and 1111111111111111111111111111111111 1111011111111111111111111111111111 -> 1111011111111111111111111111111111
+dqand646 and 1111111111111111111111111111111111 1111101111111111111111111111111111 -> 1111101111111111111111111111111111
+dqand647 and 1111111111111111111111111111111111 1111110111111111111111111111111111 -> 1111110111111111111111111111111111
+dqand648 and 1111111111111111111111111111111111 1111111011111111111111111111111111 -> 1111111011111111111111111111111111
+dqand649 and 1111111111111111111111111111111111 1111111101111111111111111111111111 -> 1111111101111111111111111111111111
+dqand650 and 1111111111111111111111111111111111 1111111110111111111111111111111111 -> 1111111110111111111111111111111111
+dqand651 and 1111111111111111111111111111111111 1111111111011111111111111111111111 -> 1111111111011111111111111111111111
+dqand652 and 1111111111111111111111111111111111 1111111111101111111111111111111111 -> 1111111111101111111111111111111111
+dqand653 and 1111111111111111111111111111111111 1111111111110111111111111111111111 -> 1111111111110111111111111111111111
+dqand654 and 1111111111111111111111111111111111 1111111111111011111111111111111111 -> 1111111111111011111111111111111111
+dqand655 and 1111111111111111111111111111111111 1111111111111101111111111111111111 -> 1111111111111101111111111111111111
+dqand656 and 1111111111111111111111111111111111 1111111111111110111111111111111111 -> 1111111111111110111111111111111111
+dqand657 and 1111111111111111111111111111111111 1111111111111111011111111111111111 -> 1111111111111111011111111111111111
+dqand658 and 1111111111111111111111111111111111 1111111111111111101111111111111111 -> 1111111111111111101111111111111111
+dqand659 and 1111111111111111111111111111111111 1111111111111111110111111111111111 -> 1111111111111111110111111111111111
+dqand660 and 1111111111111111111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111011111111111111
+dqand661 and 1111111111111111111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111101111111111111
+dqand662 and 1111111111111111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111110111111111111
+dqand663 and 1111111111111111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111011111111111
+dqand664 and 1111111111111111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111101111111111
+dqand665 and 1111111111111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111110111111111
+dqand666 and 1111111111111111111111111111111111 1111111111111111111111111011111111 -> 1111111111111111111111111011111111
+dqand667 and 1111111111111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111101111111
+dqand668 and 1111111111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111110111111
+dqand669 and 1111111111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111011111
+dqand670 and 1111111111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111101111
+dqand671 and 1111111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111110111
+dqand672 and 1111111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111011
+dqand673 and 1111111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111101
+dqand674 and 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
+dqand675 and 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 111111111111111111111111111111110
+dqand676 and 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
+
+dqand021 and 1111111111111111 1111111111111111 -> 1111111111111111
+dqand024 and 1111111111111111 111111111111111 -> 111111111111111
+dqand025 and 1111111111111111 11111111111111 -> 11111111111111
+dqand026 and 1111111111111111 1111111111111 -> 1111111111111
+dqand027 and 1111111111111111 111111111111 -> 111111111111
+dqand028 and 1111111111111111 11111111111 -> 11111111111
+dqand029 and 1111111111111111 1111111111 -> 1111111111
+dqand030 and 1111111111111111 111111111 -> 111111111
+dqand031 and 1111111111111111 11111111 -> 11111111
+dqand032 and 1111111111111111 1111111 -> 1111111
+dqand033 and 1111111111111111 111111 -> 111111
+dqand034 and 1111111111111111 11111 -> 11111
+dqand035 and 1111111111111111 1111 -> 1111
+dqand036 and 1111111111111111 111 -> 111
+dqand037 and 1111111111111111 11 -> 11
+dqand038 and 1111111111111111 1 -> 1
+dqand039 and 1111111111111111 0 -> 0
+
+dqand040 and 1111111111111111 1111111111111111 -> 1111111111111111
+dqand041 and 111111111111111 1111111111111111 -> 111111111111111
+dqand042 and 111111111111111 1111111111111111 -> 111111111111111
+dqand043 and 11111111111111 1111111111111111 -> 11111111111111
+dqand044 and 1111111111111 1111111111111111 -> 1111111111111
+dqand045 and 111111111111 1111111111111111 -> 111111111111
+dqand046 and 11111111111 1111111111111111 -> 11111111111
+dqand047 and 1111111111 1111111111111111 -> 1111111111
+dqand048 and 111111111 1111111111111111 -> 111111111
+dqand049 and 11111111 1111111111111111 -> 11111111
+dqand050 and 1111111 1111111111111111 -> 1111111
+dqand051 and 111111 1111111111111111 -> 111111
+dqand052 and 11111 1111111111111111 -> 11111
+dqand053 and 1111 1111111111111111 -> 1111
+dqand054 and 111 1111111111111111 -> 111
+dqand055 and 11 1111111111111111 -> 11
+dqand056 and 1 1111111111111111 -> 1
+dqand057 and 0 1111111111111111 -> 0
+
+dqand150 and 1111111111 1 -> 1
+dqand151 and 111111111 1 -> 1
+dqand152 and 11111111 1 -> 1
+dqand153 and 1111111 1 -> 1
+dqand154 and 111111 1 -> 1
+dqand155 and 11111 1 -> 1
+dqand156 and 1111 1 -> 1
+dqand157 and 111 1 -> 1
+dqand158 and 11 1 -> 1
+dqand159 and 1 1 -> 1
+
+dqand160 and 1111111111 0 -> 0
+dqand161 and 111111111 0 -> 0
+dqand162 and 11111111 0 -> 0
+dqand163 and 1111111 0 -> 0
+dqand164 and 111111 0 -> 0
+dqand165 and 11111 0 -> 0
+dqand166 and 1111 0 -> 0
+dqand167 and 111 0 -> 0
+dqand168 and 11 0 -> 0
+dqand169 and 1 0 -> 0
+
+dqand170 and 1 1111111111 -> 1
+dqand171 and 1 111111111 -> 1
+dqand172 and 1 11111111 -> 1
+dqand173 and 1 1111111 -> 1
+dqand174 and 1 111111 -> 1
+dqand175 and 1 11111 -> 1
+dqand176 and 1 1111 -> 1
+dqand177 and 1 111 -> 1
+dqand178 and 1 11 -> 1
+dqand179 and 1 1 -> 1
+
+dqand180 and 0 1111111111 -> 0
+dqand181 and 0 111111111 -> 0
+dqand182 and 0 11111111 -> 0
+dqand183 and 0 1111111 -> 0
+dqand184 and 0 111111 -> 0
+dqand185 and 0 11111 -> 0
+dqand186 and 0 1111 -> 0
+dqand187 and 0 111 -> 0
+dqand188 and 0 11 -> 0
+dqand189 and 0 1 -> 0
+
+dqand090 and 011111111 111111111 -> 11111111
+dqand091 and 101111111 111111111 -> 101111111
+dqand092 and 110111111 111111111 -> 110111111
+dqand093 and 111011111 111111111 -> 111011111
+dqand094 and 111101111 111111111 -> 111101111
+dqand095 and 111110111 111111111 -> 111110111
+dqand096 and 111111011 111111111 -> 111111011
+dqand097 and 111111101 111111111 -> 111111101
+dqand098 and 111111110 111111111 -> 111111110
+
+dqand100 and 111111111 011111111 -> 11111111
+dqand101 and 111111111 101111111 -> 101111111
+dqand102 and 111111111 110111111 -> 110111111
+dqand103 and 111111111 111011111 -> 111011111
+dqand104 and 111111111 111101111 -> 111101111
+dqand105 and 111111111 111110111 -> 111110111
+dqand106 and 111111111 111111011 -> 111111011
+dqand107 and 111111111 111111101 -> 111111101
+dqand108 and 111111111 111111110 -> 111111110
+
+-- non-0/1 should not be accepted, nor should signs
+dqand220 and 111111112 111111111 -> NaN Invalid_operation
+dqand221 and 333333333 333333333 -> NaN Invalid_operation
+dqand222 and 555555555 555555555 -> NaN Invalid_operation
+dqand223 and 777777777 777777777 -> NaN Invalid_operation
+dqand224 and 999999999 999999999 -> NaN Invalid_operation
+dqand225 and 222222222 999999999 -> NaN Invalid_operation
+dqand226 and 444444444 999999999 -> NaN Invalid_operation
+dqand227 and 666666666 999999999 -> NaN Invalid_operation
+dqand228 and 888888888 999999999 -> NaN Invalid_operation
+dqand229 and 999999999 222222222 -> NaN Invalid_operation
+dqand230 and 999999999 444444444 -> NaN Invalid_operation
+dqand231 and 999999999 666666666 -> NaN Invalid_operation
+dqand232 and 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+dqand240 and 567468689 -934981942 -> NaN Invalid_operation
+dqand241 and 567367689 934981942 -> NaN Invalid_operation
+dqand242 and -631917772 -706014634 -> NaN Invalid_operation
+dqand243 and -756253257 138579234 -> NaN Invalid_operation
+dqand244 and 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+dqand250 and 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqand251 and 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqand252 and 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqand253 and 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqand254 and 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqand255 and 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqand256 and 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqand257 and 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqand258 and 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqand259 and 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqand260 and 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqand261 and 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+dqand262 and 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqand263 and 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqand264 and 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqand265 and 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+-- test MSD-1
+dqand270 and 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
+dqand271 and 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
+dqand272 and 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
+dqand273 and 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
+dqand274 and 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
+dqand275 and 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
+dqand276 and 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
+dqand277 and 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
+-- test LSD
+dqand280 and 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
+dqand281 and 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
+dqand282 and 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
+dqand283 and 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
+dqand284 and 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
+dqand285 and 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
+dqand286 and 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
+dqand287 and 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
+-- test Middie
+dqand288 and 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
+dqand289 and 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
+dqand290 and 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
+dqand291 and 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
+dqand292 and 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
+dqand293 and 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
+dqand294 and 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
+dqand295 and 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
+-- signs
+dqand296 and -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
+dqand297 and -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
+dqand298 and 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
+dqand299 and 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 110000110000110000001000000
+
+-- Nmax, Nmin, Ntiny-like
+dqand331 and 2 9.99999999E+999 -> NaN Invalid_operation
+dqand332 and 3 1E-999 -> NaN Invalid_operation
+dqand333 and 4 1.00000000E-999 -> NaN Invalid_operation
+dqand334 and 5 1E-900 -> NaN Invalid_operation
+dqand335 and 6 -1E-900 -> NaN Invalid_operation
+dqand336 and 7 -1.00000000E-999 -> NaN Invalid_operation
+dqand337 and 8 -1E-999 -> NaN Invalid_operation
+dqand338 and 9 -9.99999999E+999 -> NaN Invalid_operation
+dqand341 and 9.99999999E+999 -18 -> NaN Invalid_operation
+dqand342 and 1E-999 01 -> NaN Invalid_operation
+dqand343 and 1.00000000E-999 -18 -> NaN Invalid_operation
+dqand344 and 1E-900 18 -> NaN Invalid_operation
+dqand345 and -1E-900 -10 -> NaN Invalid_operation
+dqand346 and -1.00000000E-999 18 -> NaN Invalid_operation
+dqand347 and -1E-999 10 -> NaN Invalid_operation
+dqand348 and -9.99999999E+999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+dqand361 and 1.0 1 -> NaN Invalid_operation
+dqand362 and 1E+1 1 -> NaN Invalid_operation
+dqand363 and 0.0 1 -> NaN Invalid_operation
+dqand364 and 0E+1 1 -> NaN Invalid_operation
+dqand365 and 9.9 1 -> NaN Invalid_operation
+dqand366 and 9E+1 1 -> NaN Invalid_operation
+dqand371 and 0 1.0 -> NaN Invalid_operation
+dqand372 and 0 1E+1 -> NaN Invalid_operation
+dqand373 and 0 0.0 -> NaN Invalid_operation
+dqand374 and 0 0E+1 -> NaN Invalid_operation
+dqand375 and 0 9.9 -> NaN Invalid_operation
+dqand376 and 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+dqand780 and -Inf -Inf -> NaN Invalid_operation
+dqand781 and -Inf -1000 -> NaN Invalid_operation
+dqand782 and -Inf -1 -> NaN Invalid_operation
+dqand783 and -Inf -0 -> NaN Invalid_operation
+dqand784 and -Inf 0 -> NaN Invalid_operation
+dqand785 and -Inf 1 -> NaN Invalid_operation
+dqand786 and -Inf 1000 -> NaN Invalid_operation
+dqand787 and -1000 -Inf -> NaN Invalid_operation
+dqand788 and -Inf -Inf -> NaN Invalid_operation
+dqand789 and -1 -Inf -> NaN Invalid_operation
+dqand790 and -0 -Inf -> NaN Invalid_operation
+dqand791 and 0 -Inf -> NaN Invalid_operation
+dqand792 and 1 -Inf -> NaN Invalid_operation
+dqand793 and 1000 -Inf -> NaN Invalid_operation
+dqand794 and Inf -Inf -> NaN Invalid_operation
+
+dqand800 and Inf -Inf -> NaN Invalid_operation
+dqand801 and Inf -1000 -> NaN Invalid_operation
+dqand802 and Inf -1 -> NaN Invalid_operation
+dqand803 and Inf -0 -> NaN Invalid_operation
+dqand804 and Inf 0 -> NaN Invalid_operation
+dqand805 and Inf 1 -> NaN Invalid_operation
+dqand806 and Inf 1000 -> NaN Invalid_operation
+dqand807 and Inf Inf -> NaN Invalid_operation
+dqand808 and -1000 Inf -> NaN Invalid_operation
+dqand809 and -Inf Inf -> NaN Invalid_operation
+dqand810 and -1 Inf -> NaN Invalid_operation
+dqand811 and -0 Inf -> NaN Invalid_operation
+dqand812 and 0 Inf -> NaN Invalid_operation
+dqand813 and 1 Inf -> NaN Invalid_operation
+dqand814 and 1000 Inf -> NaN Invalid_operation
+dqand815 and Inf Inf -> NaN Invalid_operation
+
+dqand821 and NaN -Inf -> NaN Invalid_operation
+dqand822 and NaN -1000 -> NaN Invalid_operation
+dqand823 and NaN -1 -> NaN Invalid_operation
+dqand824 and NaN -0 -> NaN Invalid_operation
+dqand825 and NaN 0 -> NaN Invalid_operation
+dqand826 and NaN 1 -> NaN Invalid_operation
+dqand827 and NaN 1000 -> NaN Invalid_operation
+dqand828 and NaN Inf -> NaN Invalid_operation
+dqand829 and NaN NaN -> NaN Invalid_operation
+dqand830 and -Inf NaN -> NaN Invalid_operation
+dqand831 and -1000 NaN -> NaN Invalid_operation
+dqand832 and -1 NaN -> NaN Invalid_operation
+dqand833 and -0 NaN -> NaN Invalid_operation
+dqand834 and 0 NaN -> NaN Invalid_operation
+dqand835 and 1 NaN -> NaN Invalid_operation
+dqand836 and 1000 NaN -> NaN Invalid_operation
+dqand837 and Inf NaN -> NaN Invalid_operation
+
+dqand841 and sNaN -Inf -> NaN Invalid_operation
+dqand842 and sNaN -1000 -> NaN Invalid_operation
+dqand843 and sNaN -1 -> NaN Invalid_operation
+dqand844 and sNaN -0 -> NaN Invalid_operation
+dqand845 and sNaN 0 -> NaN Invalid_operation
+dqand846 and sNaN 1 -> NaN Invalid_operation
+dqand847 and sNaN 1000 -> NaN Invalid_operation
+dqand848 and sNaN NaN -> NaN Invalid_operation
+dqand849 and sNaN sNaN -> NaN Invalid_operation
+dqand850 and NaN sNaN -> NaN Invalid_operation
+dqand851 and -Inf sNaN -> NaN Invalid_operation
+dqand852 and -1000 sNaN -> NaN Invalid_operation
+dqand853 and -1 sNaN -> NaN Invalid_operation
+dqand854 and -0 sNaN -> NaN Invalid_operation
+dqand855 and 0 sNaN -> NaN Invalid_operation
+dqand856 and 1 sNaN -> NaN Invalid_operation
+dqand857 and 1000 sNaN -> NaN Invalid_operation
+dqand858 and Inf sNaN -> NaN Invalid_operation
+dqand859 and NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqand861 and NaN1 -Inf -> NaN Invalid_operation
+dqand862 and +NaN2 -1000 -> NaN Invalid_operation
+dqand863 and NaN3 1000 -> NaN Invalid_operation
+dqand864 and NaN4 Inf -> NaN Invalid_operation
+dqand865 and NaN5 +NaN6 -> NaN Invalid_operation
+dqand866 and -Inf NaN7 -> NaN Invalid_operation
+dqand867 and -1000 NaN8 -> NaN Invalid_operation
+dqand868 and 1000 NaN9 -> NaN Invalid_operation
+dqand869 and Inf +NaN10 -> NaN Invalid_operation
+dqand871 and sNaN11 -Inf -> NaN Invalid_operation
+dqand872 and sNaN12 -1000 -> NaN Invalid_operation
+dqand873 and sNaN13 1000 -> NaN Invalid_operation
+dqand874 and sNaN14 NaN17 -> NaN Invalid_operation
+dqand875 and sNaN15 sNaN18 -> NaN Invalid_operation
+dqand876 and NaN16 sNaN19 -> NaN Invalid_operation
+dqand877 and -Inf +sNaN20 -> NaN Invalid_operation
+dqand878 and -1000 sNaN21 -> NaN Invalid_operation
+dqand879 and 1000 sNaN22 -> NaN Invalid_operation
+dqand880 and Inf sNaN23 -> NaN Invalid_operation
+dqand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
+dqand882 and -NaN26 NaN28 -> NaN Invalid_operation
+dqand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
+dqand884 and 1000 -NaN30 -> NaN Invalid_operation
+dqand885 and 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqBase.decTest b/Lib/test/decimaltestdata/dqBase.decTest
index d09c6bf02c..6bb463388e 100644
--- a/Lib/test/decimaltestdata/dqBase.decTest
+++ b/Lib/test/decimaltestdata/dqBase.decTest
@@ -1,1081 +1,1081 @@
-------------------------------------------------------------------------
--- dqBase.decTest -- base decQuad <--> string conversions --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests base conversions from string to a decimal number
--- and back to a string (in Scientific form)
-
--- Note that unlike other operations the operand is subject to rounding
--- to conform to emax and precision settings (that is, numbers will
--- conform to rules and exponent will be in permitted range). The
--- 'left hand side', therefore, may have numbers that cannot be
--- represented in a decQuad. Some testcases go to the limit of the
--- next-wider format, and hence these testcases may also be used to
--- test narrowing and widening operations.
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqbas001 toSci 0 -> 0
-dqbas002 toSci 1 -> 1
-dqbas003 toSci 1.0 -> 1.0
-dqbas004 toSci 1.00 -> 1.00
-dqbas005 toSci 10 -> 10
-dqbas006 toSci 1000 -> 1000
-dqbas007 toSci 10.0 -> 10.0
-dqbas008 toSci 10.1 -> 10.1
-dqbas009 toSci 10.4 -> 10.4
-dqbas010 toSci 10.5 -> 10.5
-dqbas011 toSci 10.6 -> 10.6
-dqbas012 toSci 10.9 -> 10.9
-dqbas013 toSci 11.0 -> 11.0
-dqbas014 toSci 1.234 -> 1.234
-dqbas015 toSci 0.123 -> 0.123
-dqbas016 toSci 0.012 -> 0.012
-dqbas017 toSci -0 -> -0
-dqbas018 toSci -0.0 -> -0.0
-dqbas019 toSci -00.00 -> -0.00
-
-dqbas021 toSci -1 -> -1
-dqbas022 toSci -1.0 -> -1.0
-dqbas023 toSci -0.1 -> -0.1
-dqbas024 toSci -9.1 -> -9.1
-dqbas025 toSci -9.11 -> -9.11
-dqbas026 toSci -9.119 -> -9.119
-dqbas027 toSci -9.999 -> -9.999
-
-dqbas030 toSci '123456789.123456' -> '123456789.123456'
-dqbas031 toSci '123456789.000000' -> '123456789.000000'
-dqbas032 toSci '123456789123456' -> '123456789123456'
-dqbas033 toSci '0.0000123456789' -> '0.0000123456789'
-dqbas034 toSci '0.00000123456789' -> '0.00000123456789'
-dqbas035 toSci '0.000000123456789' -> '1.23456789E-7'
-dqbas036 toSci '0.0000000123456789' -> '1.23456789E-8'
-
-dqbas037 toSci '0.123456789012344' -> '0.123456789012344'
-dqbas038 toSci '0.123456789012345' -> '0.123456789012345'
-
--- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
-dqbsn001 toSci -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqbsn002 toSci -1E-6143 -> -1E-6143
-dqbsn003 toSci -1E-6176 -> -1E-6176 Subnormal
-dqbsn004 toSci -0 -> -0
-dqbsn005 toSci +0 -> 0
-dqbsn006 toSci +1E-6176 -> 1E-6176 Subnormal
-dqbsn007 toSci +1E-6143 -> 1E-6143
-dqbsn008 toSci +9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-
--- String [many more examples are implicitly tested elsewhere]
--- strings without E cannot generate E in result
-dqbas040 toSci "12" -> '12'
-dqbas041 toSci "-76" -> '-76'
-dqbas042 toSci "12.76" -> '12.76'
-dqbas043 toSci "+12.76" -> '12.76'
-dqbas044 toSci "012.76" -> '12.76'
-dqbas045 toSci "+0.003" -> '0.003'
-dqbas046 toSci "17." -> '17'
-dqbas047 toSci ".5" -> '0.5'
-dqbas048 toSci "044" -> '44'
-dqbas049 toSci "0044" -> '44'
-dqbas050 toSci "0.0005" -> '0.0005'
-dqbas051 toSci "00.00005" -> '0.00005'
-dqbas052 toSci "0.000005" -> '0.000005'
-dqbas053 toSci "0.0000050" -> '0.0000050'
-dqbas054 toSci "0.0000005" -> '5E-7'
-dqbas055 toSci "0.00000005" -> '5E-8'
-dqbas056 toSci "12345678.543210" -> '12345678.543210'
-dqbas057 toSci "2345678.543210" -> '2345678.543210'
-dqbas058 toSci "345678.543210" -> '345678.543210'
-dqbas059 toSci "0345678.54321" -> '345678.54321'
-dqbas060 toSci "345678.5432" -> '345678.5432'
-dqbas061 toSci "+345678.5432" -> '345678.5432'
-dqbas062 toSci "+0345678.5432" -> '345678.5432'
-dqbas063 toSci "+00345678.5432" -> '345678.5432'
-dqbas064 toSci "-345678.5432" -> '-345678.5432'
-dqbas065 toSci "-0345678.5432" -> '-345678.5432'
-dqbas066 toSci "-00345678.5432" -> '-345678.5432'
--- examples
-dqbas067 toSci "5E-6" -> '0.000005'
-dqbas068 toSci "50E-7" -> '0.0000050'
-dqbas069 toSci "5E-7" -> '5E-7'
-
--- [No exotics as no Unicode]
-
--- rounded with dots in all (including edge) places
-dqbas071 toSci .1234567891234567890123456780123456123 -> 0.1234567891234567890123456780123456 Inexact Rounded
-dqbas072 toSci 1.234567891234567890123456780123456123 -> 1.234567891234567890123456780123456 Inexact Rounded
-dqbas073 toSci 12.34567891234567890123456780123456123 -> 12.34567891234567890123456780123456 Inexact Rounded
-dqbas074 toSci 123.4567891234567890123456780123456123 -> 123.4567891234567890123456780123456 Inexact Rounded
-dqbas075 toSci 1234.567891234567890123456780123456123 -> 1234.567891234567890123456780123456 Inexact Rounded
-dqbas076 toSci 12345.67891234567890123456780123456123 -> 12345.67891234567890123456780123456 Inexact Rounded
-dqbas077 toSci 123456.7891234567890123456780123456123 -> 123456.7891234567890123456780123456 Inexact Rounded
-dqbas078 toSci 1234567.891234567890123456780123456123 -> 1234567.891234567890123456780123456 Inexact Rounded
-dqbas079 toSci 12345678.91234567890123456780123456123 -> 12345678.91234567890123456780123456 Inexact Rounded
-dqbas080 toSci 123456789.1234567890123456780123456123 -> 123456789.1234567890123456780123456 Inexact Rounded
-dqbas081 toSci 1234567891.234567890123456780123456123 -> 1234567891.234567890123456780123456 Inexact Rounded
-dqbas082 toSci 12345678912.34567890123456780123456123 -> 12345678912.34567890123456780123456 Inexact Rounded
-dqbas083 toSci 123456789123.4567890123456780123456123 -> 123456789123.4567890123456780123456 Inexact Rounded
-dqbas084 toSci 1234567891234.567890123456780123456123 -> 1234567891234.567890123456780123456 Inexact Rounded
-dqbas085 toSci 12345678912345.67890123456780123456123 -> 12345678912345.67890123456780123456 Inexact Rounded
-dqbas086 toSci 123456789123456.7890123456780123456123 -> 123456789123456.7890123456780123456 Inexact Rounded
-dqbas087 toSci 1234567891234567.890123456780123456123 -> 1234567891234567.890123456780123456 Inexact Rounded
-dqbas088 toSci 12345678912345678.90123456780123456123 -> 12345678912345678.90123456780123456 Inexact Rounded
-dqbas089 toSci 123456789123456789.0123456780123456123 -> 123456789123456789.0123456780123456 Inexact Rounded
-dqbas090 toSci 1234567891234567890.123456780123456123 -> 1234567891234567890.123456780123456 Inexact Rounded
-dqbas091 toSci 12345678912345678901.23456780123456123 -> 12345678912345678901.23456780123456 Inexact Rounded
-dqbas092 toSci 123456789123456789012.3456780123456123 -> 123456789123456789012.3456780123456 Inexact Rounded
-dqbas093 toSci 1234567891234567890123.456780123456123 -> 1234567891234567890123.456780123456 Inexact Rounded
-dqbas094 toSci 12345678912345678901234.56780123456123 -> 12345678912345678901234.56780123456 Inexact Rounded
-dqbas095 toSci 123456789123456789012345.6780123456123 -> 123456789123456789012345.6780123456 Inexact Rounded
-dqbas096 toSci 1234567891234567890123456.780123456123 -> 1234567891234567890123456.780123456 Inexact Rounded
-dqbas097 toSci 12345678912345678901234567.80123456123 -> 12345678912345678901234567.80123456 Inexact Rounded
-dqbas098 toSci 123456789123456789012345678.0123456123 -> 123456789123456789012345678.0123456 Inexact Rounded
-dqbas099 toSci 1234567891234567890123456780.123456123 -> 1234567891234567890123456780.123456 Inexact Rounded
-dqbas100 toSci 12345678912345678901234567801.23456123 -> 12345678912345678901234567801.23456 Inexact Rounded
-dqbas101 toSci 123456789123456789012345678012.3456123 -> 123456789123456789012345678012.3456 Inexact Rounded
-dqbas102 toSci 1234567891234567890123456780123.456123 -> 1234567891234567890123456780123.456 Inexact Rounded
-dqbas103 toSci 12345678912345678901234567801234.56123 -> 12345678912345678901234567801234.56 Inexact Rounded
-dqbas104 toSci 123456789123456789012345678012345.6123 -> 123456789123456789012345678012345.6 Inexact Rounded
-dqbas105 toSci 1234567891234567890123456780123456.123 -> 1234567891234567890123456780123456 Inexact Rounded
-dqbas106 toSci 12345678912345678901234567801234561.23 -> 1.234567891234567890123456780123456E+34 Inexact Rounded
-dqbas107 toSci 123456789123456789012345678012345612.3 -> 1.234567891234567890123456780123456E+35 Inexact Rounded
-dqbas108 toSci 1234567891234567890123456780123456123. -> 1.234567891234567890123456780123456E+36 Inexact Rounded
--- 123456789012345678
-
--- Numbers with E
-dqbas130 toSci "0.000E-1" -> '0.0000'
-dqbas131 toSci "0.000E-2" -> '0.00000'
-dqbas132 toSci "0.000E-3" -> '0.000000'
-dqbas133 toSci "0.000E-4" -> '0E-7'
-dqbas134 toSci "0.00E-2" -> '0.0000'
-dqbas135 toSci "0.00E-3" -> '0.00000'
-dqbas136 toSci "0.00E-4" -> '0.000000'
-dqbas137 toSci "0.00E-5" -> '0E-7'
-dqbas138 toSci "+0E+9" -> '0E+9'
-dqbas139 toSci "-0E+9" -> '-0E+9'
-dqbas140 toSci "1E+9" -> '1E+9'
-dqbas141 toSci "1e+09" -> '1E+9'
-dqbas142 toSci "1E+90" -> '1E+90'
-dqbas143 toSci "+1E+009" -> '1E+9'
-dqbas144 toSci "0E+9" -> '0E+9'
-dqbas145 toSci "1E+9" -> '1E+9'
-dqbas146 toSci "1E+09" -> '1E+9'
-dqbas147 toSci "1e+90" -> '1E+90'
-dqbas148 toSci "1E+009" -> '1E+9'
-dqbas149 toSci "000E+9" -> '0E+9'
-dqbas150 toSci "1E9" -> '1E+9'
-dqbas151 toSci "1e09" -> '1E+9'
-dqbas152 toSci "1E90" -> '1E+90'
-dqbas153 toSci "1E009" -> '1E+9'
-dqbas154 toSci "0E9" -> '0E+9'
-dqbas155 toSci "0.000e+0" -> '0.000'
-dqbas156 toSci "0.000E-1" -> '0.0000'
-dqbas157 toSci "4E+9" -> '4E+9'
-dqbas158 toSci "44E+9" -> '4.4E+10'
-dqbas159 toSci "0.73e-7" -> '7.3E-8'
-dqbas160 toSci "00E+9" -> '0E+9'
-dqbas161 toSci "00E-9" -> '0E-9'
-dqbas162 toSci "10E+9" -> '1.0E+10'
-dqbas163 toSci "10E+09" -> '1.0E+10'
-dqbas164 toSci "10e+90" -> '1.0E+91'
-dqbas165 toSci "10E+009" -> '1.0E+10'
-dqbas166 toSci "100e+9" -> '1.00E+11'
-dqbas167 toSci "100e+09" -> '1.00E+11'
-dqbas168 toSci "100E+90" -> '1.00E+92'
-dqbas169 toSci "100e+009" -> '1.00E+11'
-
-dqbas170 toSci "1.265" -> '1.265'
-dqbas171 toSci "1.265E-20" -> '1.265E-20'
-dqbas172 toSci "1.265E-8" -> '1.265E-8'
-dqbas173 toSci "1.265E-4" -> '0.0001265'
-dqbas174 toSci "1.265E-3" -> '0.001265'
-dqbas175 toSci "1.265E-2" -> '0.01265'
-dqbas176 toSci "1.265E-1" -> '0.1265'
-dqbas177 toSci "1.265E-0" -> '1.265'
-dqbas178 toSci "1.265E+1" -> '12.65'
-dqbas179 toSci "1.265E+2" -> '126.5'
-dqbas180 toSci "1.265E+3" -> '1265'
-dqbas181 toSci "1.265E+4" -> '1.265E+4'
-dqbas182 toSci "1.265E+8" -> '1.265E+8'
-dqbas183 toSci "1.265E+20" -> '1.265E+20'
-
-dqbas190 toSci "12.65" -> '12.65'
-dqbas191 toSci "12.65E-20" -> '1.265E-19'
-dqbas192 toSci "12.65E-8" -> '1.265E-7'
-dqbas193 toSci "12.65E-4" -> '0.001265'
-dqbas194 toSci "12.65E-3" -> '0.01265'
-dqbas195 toSci "12.65E-2" -> '0.1265'
-dqbas196 toSci "12.65E-1" -> '1.265'
-dqbas197 toSci "12.65E-0" -> '12.65'
-dqbas198 toSci "12.65E+1" -> '126.5'
-dqbas199 toSci "12.65E+2" -> '1265'
-dqbas200 toSci "12.65E+3" -> '1.265E+4'
-dqbas201 toSci "12.65E+4" -> '1.265E+5'
-dqbas202 toSci "12.65E+8" -> '1.265E+9'
-dqbas203 toSci "12.65E+20" -> '1.265E+21'
-
-dqbas210 toSci "126.5" -> '126.5'
-dqbas211 toSci "126.5E-20" -> '1.265E-18'
-dqbas212 toSci "126.5E-8" -> '0.000001265'
-dqbas213 toSci "126.5E-4" -> '0.01265'
-dqbas214 toSci "126.5E-3" -> '0.1265'
-dqbas215 toSci "126.5E-2" -> '1.265'
-dqbas216 toSci "126.5E-1" -> '12.65'
-dqbas217 toSci "126.5E-0" -> '126.5'
-dqbas218 toSci "126.5E+1" -> '1265'
-dqbas219 toSci "126.5E+2" -> '1.265E+4'
-dqbas220 toSci "126.5E+3" -> '1.265E+5'
-dqbas221 toSci "126.5E+4" -> '1.265E+6'
-dqbas222 toSci "126.5E+8" -> '1.265E+10'
-dqbas223 toSci "126.5E+20" -> '1.265E+22'
-
-dqbas230 toSci "1265" -> '1265'
-dqbas231 toSci "1265E-20" -> '1.265E-17'
-dqbas232 toSci "1265E-8" -> '0.00001265'
-dqbas233 toSci "1265E-4" -> '0.1265'
-dqbas234 toSci "1265E-3" -> '1.265'
-dqbas235 toSci "1265E-2" -> '12.65'
-dqbas236 toSci "1265E-1" -> '126.5'
-dqbas237 toSci "1265E-0" -> '1265'
-dqbas238 toSci "1265E+1" -> '1.265E+4'
-dqbas239 toSci "1265E+2" -> '1.265E+5'
-dqbas240 toSci "1265E+3" -> '1.265E+6'
-dqbas241 toSci "1265E+4" -> '1.265E+7'
-dqbas242 toSci "1265E+8" -> '1.265E+11'
-dqbas243 toSci "1265E+20" -> '1.265E+23'
-
-dqbas250 toSci "0.1265" -> '0.1265'
-dqbas251 toSci "0.1265E-20" -> '1.265E-21'
-dqbas252 toSci "0.1265E-8" -> '1.265E-9'
-dqbas253 toSci "0.1265E-4" -> '0.00001265'
-dqbas254 toSci "0.1265E-3" -> '0.0001265'
-dqbas255 toSci "0.1265E-2" -> '0.001265'
-dqbas256 toSci "0.1265E-1" -> '0.01265'
-dqbas257 toSci "0.1265E-0" -> '0.1265'
-dqbas258 toSci "0.1265E+1" -> '1.265'
-dqbas259 toSci "0.1265E+2" -> '12.65'
-dqbas260 toSci "0.1265E+3" -> '126.5'
-dqbas261 toSci "0.1265E+4" -> '1265'
-dqbas262 toSci "0.1265E+8" -> '1.265E+7'
-dqbas263 toSci "0.1265E+20" -> '1.265E+19'
-
--- some more negative zeros [systematic tests below]
-dqbas290 toSci "-0.000E-1" -> '-0.0000'
-dqbas291 toSci "-0.000E-2" -> '-0.00000'
-dqbas292 toSci "-0.000E-3" -> '-0.000000'
-dqbas293 toSci "-0.000E-4" -> '-0E-7'
-dqbas294 toSci "-0.00E-2" -> '-0.0000'
-dqbas295 toSci "-0.00E-3" -> '-0.00000'
-dqbas296 toSci "-0.0E-2" -> '-0.000'
-dqbas297 toSci "-0.0E-3" -> '-0.0000'
-dqbas298 toSci "-0E-2" -> '-0.00'
-dqbas299 toSci "-0E-3" -> '-0.000'
-
--- Engineering notation tests
-dqbas301 toSci 10e12 -> 1.0E+13
-dqbas302 toEng 10e12 -> 10E+12
-dqbas303 toSci 10e11 -> 1.0E+12
-dqbas304 toEng 10e11 -> 1.0E+12
-dqbas305 toSci 10e10 -> 1.0E+11
-dqbas306 toEng 10e10 -> 100E+9
-dqbas307 toSci 10e9 -> 1.0E+10
-dqbas308 toEng 10e9 -> 10E+9
-dqbas309 toSci 10e8 -> 1.0E+9
-dqbas310 toEng 10e8 -> 1.0E+9
-dqbas311 toSci 10e7 -> 1.0E+8
-dqbas312 toEng 10e7 -> 100E+6
-dqbas313 toSci 10e6 -> 1.0E+7
-dqbas314 toEng 10e6 -> 10E+6
-dqbas315 toSci 10e5 -> 1.0E+6
-dqbas316 toEng 10e5 -> 1.0E+6
-dqbas317 toSci 10e4 -> 1.0E+5
-dqbas318 toEng 10e4 -> 100E+3
-dqbas319 toSci 10e3 -> 1.0E+4
-dqbas320 toEng 10e3 -> 10E+3
-dqbas321 toSci 10e2 -> 1.0E+3
-dqbas322 toEng 10e2 -> 1.0E+3
-dqbas323 toSci 10e1 -> 1.0E+2
-dqbas324 toEng 10e1 -> 100
-dqbas325 toSci 10e0 -> 10
-dqbas326 toEng 10e0 -> 10
-dqbas327 toSci 10e-1 -> 1.0
-dqbas328 toEng 10e-1 -> 1.0
-dqbas329 toSci 10e-2 -> 0.10
-dqbas330 toEng 10e-2 -> 0.10
-dqbas331 toSci 10e-3 -> 0.010
-dqbas332 toEng 10e-3 -> 0.010
-dqbas333 toSci 10e-4 -> 0.0010
-dqbas334 toEng 10e-4 -> 0.0010
-dqbas335 toSci 10e-5 -> 0.00010
-dqbas336 toEng 10e-5 -> 0.00010
-dqbas337 toSci 10e-6 -> 0.000010
-dqbas338 toEng 10e-6 -> 0.000010
-dqbas339 toSci 10e-7 -> 0.0000010
-dqbas340 toEng 10e-7 -> 0.0000010
-dqbas341 toSci 10e-8 -> 1.0E-7
-dqbas342 toEng 10e-8 -> 100E-9
-dqbas343 toSci 10e-9 -> 1.0E-8
-dqbas344 toEng 10e-9 -> 10E-9
-dqbas345 toSci 10e-10 -> 1.0E-9
-dqbas346 toEng 10e-10 -> 1.0E-9
-dqbas347 toSci 10e-11 -> 1.0E-10
-dqbas348 toEng 10e-11 -> 100E-12
-dqbas349 toSci 10e-12 -> 1.0E-11
-dqbas350 toEng 10e-12 -> 10E-12
-dqbas351 toSci 10e-13 -> 1.0E-12
-dqbas352 toEng 10e-13 -> 1.0E-12
-
-dqbas361 toSci 7E12 -> 7E+12
-dqbas362 toEng 7E12 -> 7E+12
-dqbas363 toSci 7E11 -> 7E+11
-dqbas364 toEng 7E11 -> 700E+9
-dqbas365 toSci 7E10 -> 7E+10
-dqbas366 toEng 7E10 -> 70E+9
-dqbas367 toSci 7E9 -> 7E+9
-dqbas368 toEng 7E9 -> 7E+9
-dqbas369 toSci 7E8 -> 7E+8
-dqbas370 toEng 7E8 -> 700E+6
-dqbas371 toSci 7E7 -> 7E+7
-dqbas372 toEng 7E7 -> 70E+6
-dqbas373 toSci 7E6 -> 7E+6
-dqbas374 toEng 7E6 -> 7E+6
-dqbas375 toSci 7E5 -> 7E+5
-dqbas376 toEng 7E5 -> 700E+3
-dqbas377 toSci 7E4 -> 7E+4
-dqbas378 toEng 7E4 -> 70E+3
-dqbas379 toSci 7E3 -> 7E+3
-dqbas380 toEng 7E3 -> 7E+3
-dqbas381 toSci 7E2 -> 7E+2
-dqbas382 toEng 7E2 -> 700
-dqbas383 toSci 7E1 -> 7E+1
-dqbas384 toEng 7E1 -> 70
-dqbas385 toSci 7E0 -> 7
-dqbas386 toEng 7E0 -> 7
-dqbas387 toSci 7E-1 -> 0.7
-dqbas388 toEng 7E-1 -> 0.7
-dqbas389 toSci 7E-2 -> 0.07
-dqbas390 toEng 7E-2 -> 0.07
-dqbas391 toSci 7E-3 -> 0.007
-dqbas392 toEng 7E-3 -> 0.007
-dqbas393 toSci 7E-4 -> 0.0007
-dqbas394 toEng 7E-4 -> 0.0007
-dqbas395 toSci 7E-5 -> 0.00007
-dqbas396 toEng 7E-5 -> 0.00007
-dqbas397 toSci 7E-6 -> 0.000007
-dqbas398 toEng 7E-6 -> 0.000007
-dqbas399 toSci 7E-7 -> 7E-7
-dqbas400 toEng 7E-7 -> 700E-9
-dqbas401 toSci 7E-8 -> 7E-8
-dqbas402 toEng 7E-8 -> 70E-9
-dqbas403 toSci 7E-9 -> 7E-9
-dqbas404 toEng 7E-9 -> 7E-9
-dqbas405 toSci 7E-10 -> 7E-10
-dqbas406 toEng 7E-10 -> 700E-12
-dqbas407 toSci 7E-11 -> 7E-11
-dqbas408 toEng 7E-11 -> 70E-12
-dqbas409 toSci 7E-12 -> 7E-12
-dqbas410 toEng 7E-12 -> 7E-12
-dqbas411 toSci 7E-13 -> 7E-13
-dqbas412 toEng 7E-13 -> 700E-15
-
--- Exacts remain exact up to precision ..
-dqbas420 toSci 100 -> 100
-dqbas422 toSci 1000 -> 1000
-dqbas424 toSci 999.9 -> 999.9
-dqbas426 toSci 1000.0 -> 1000.0
-dqbas428 toSci 1000.1 -> 1000.1
-dqbas430 toSci 10000 -> 10000
-dqbas432 toSci 1000000000000000000000000000000 -> 1000000000000000000000000000000
-dqbas434 toSci 10000000000000000000000000000000 -> 10000000000000000000000000000000
-dqbas436 toSci 100000000000000000000000000000000 -> 100000000000000000000000000000000
-dqbas438 toSci 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqbas440 toSci 10000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+34 Rounded
-dqbas442 toSci 10000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+34 Rounded
-dqbas444 toSci 10000000000000000000000000000000003 -> 1.000000000000000000000000000000000E+34 Rounded Inexact
-dqbas446 toSci 10000000000000000000000000000000005 -> 1.000000000000000000000000000000000E+34 Rounded Inexact
-dqbas448 toSci 100000000000000000000000000000000050 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
-dqbas450 toSci 10000000000000000000000000000000009 -> 1.000000000000000000000000000000001E+34 Rounded Inexact
-dqbas452 toSci 100000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+35 Rounded
-dqbas454 toSci 100000000000000000000000000000000003 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
-dqbas456 toSci 100000000000000000000000000000000005 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
-dqbas458 toSci 100000000000000000000000000000000009 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
-dqbas460 toSci 1000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+36 Rounded
-dqbas462 toSci 1000000000000000000000000000000000300 -> 1.000000000000000000000000000000000E+36 Rounded Inexact
-dqbas464 toSci 1000000000000000000000000000000000500 -> 1.000000000000000000000000000000000E+36 Rounded Inexact
-dqbas466 toSci 1000000000000000000000000000000000900 -> 1.000000000000000000000000000000001E+36 Rounded Inexact
-dqbas468 toSci 10000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+37 Rounded
-dqbas470 toSci 10000000000000000000000000000000003000 -> 1.000000000000000000000000000000000E+37 Rounded Inexact
-dqbas472 toSci 10000000000000000000000000000000005000 -> 1.000000000000000000000000000000000E+37 Rounded Inexact
-dqbas474 toSci 10000000000000000000000000000000009000 -> 1.000000000000000000000000000000001E+37 Rounded Inexact
-
--- check rounding modes heeded
-rounding: ceiling
-dqbsr401 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr402 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr403 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr404 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
-rounding: up
-dqbsr405 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr406 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr407 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr408 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
-rounding: floor
-dqbsr410 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr411 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr412 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr413 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112345 Rounded Inexact
-rounding: half_down
-dqbsr415 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr416 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr417 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr418 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr419 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
-rounding: half_even
-dqbsr421 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr422 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr423 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr424 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr425 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
-rounding: down
-dqbsr426 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr427 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr428 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr429 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112345 Rounded Inexact
-rounding: half_up
-dqbsr431 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr432 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr433 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr434 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112347 Rounded Inexact
-dqbsr435 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
--- negatives
-rounding: ceiling
-dqbsr501 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr502 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr503 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr504 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112345 Rounded Inexact
-rounding: up
-dqbsr505 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr506 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr507 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr508 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-rounding: floor
-dqbsr510 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr511 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr512 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr513 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-rounding: half_down
-dqbsr515 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr516 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr517 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr518 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr519 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-rounding: half_even
-dqbsr521 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr522 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr523 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr524 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr525 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-rounding: down
-dqbsr526 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr527 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr528 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr529 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112345 Rounded Inexact
-rounding: half_up
-dqbsr531 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr532 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr533 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr534 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112347 Rounded Inexact
-dqbsr535 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-
-rounding: half_even
-
--- The 'baddies' tests from DiagBigDecimal, plus some new ones
-dqbas500 toSci '1..2' -> NaN Conversion_syntax
-dqbas501 toSci '.' -> NaN Conversion_syntax
-dqbas502 toSci '..' -> NaN Conversion_syntax
-dqbas503 toSci '++1' -> NaN Conversion_syntax
-dqbas504 toSci '--1' -> NaN Conversion_syntax
-dqbas505 toSci '-+1' -> NaN Conversion_syntax
-dqbas506 toSci '+-1' -> NaN Conversion_syntax
-dqbas507 toSci '12e' -> NaN Conversion_syntax
-dqbas508 toSci '12e++' -> NaN Conversion_syntax
-dqbas509 toSci '12f4' -> NaN Conversion_syntax
-dqbas510 toSci ' +1' -> NaN Conversion_syntax
-dqbas511 toSci '+ 1' -> NaN Conversion_syntax
-dqbas512 toSci '12 ' -> NaN Conversion_syntax
-dqbas513 toSci ' + 1' -> NaN Conversion_syntax
-dqbas514 toSci ' - 1 ' -> NaN Conversion_syntax
-dqbas515 toSci 'x' -> NaN Conversion_syntax
-dqbas516 toSci '-1-' -> NaN Conversion_syntax
-dqbas517 toSci '12-' -> NaN Conversion_syntax
-dqbas518 toSci '3+' -> NaN Conversion_syntax
-dqbas519 toSci '' -> NaN Conversion_syntax
-dqbas520 toSci '1e-' -> NaN Conversion_syntax
-dqbas521 toSci '7e99999a' -> NaN Conversion_syntax
-dqbas522 toSci '7e123567890x' -> NaN Conversion_syntax
-dqbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
-dqbas524 toSci '' -> NaN Conversion_syntax
-dqbas525 toSci 'e100' -> NaN Conversion_syntax
-dqbas526 toSci '\u0e5a' -> NaN Conversion_syntax
-dqbas527 toSci '\u0b65' -> NaN Conversion_syntax
-dqbas528 toSci '123,65' -> NaN Conversion_syntax
-dqbas529 toSci '1.34.5' -> NaN Conversion_syntax
-dqbas530 toSci '.123.5' -> NaN Conversion_syntax
-dqbas531 toSci '01.35.' -> NaN Conversion_syntax
-dqbas532 toSci '01.35-' -> NaN Conversion_syntax
-dqbas533 toSci '0000..' -> NaN Conversion_syntax
-dqbas534 toSci '.0000.' -> NaN Conversion_syntax
-dqbas535 toSci '00..00' -> NaN Conversion_syntax
-dqbas536 toSci '111e*123' -> NaN Conversion_syntax
-dqbas537 toSci '111e123-' -> NaN Conversion_syntax
-dqbas538 toSci '111e+12+' -> NaN Conversion_syntax
-dqbas539 toSci '111e1-3-' -> NaN Conversion_syntax
-dqbas540 toSci '111e1*23' -> NaN Conversion_syntax
-dqbas541 toSci '111e1e+3' -> NaN Conversion_syntax
-dqbas542 toSci '1e1.0' -> NaN Conversion_syntax
-dqbas543 toSci '1e123e' -> NaN Conversion_syntax
-dqbas544 toSci 'ten' -> NaN Conversion_syntax
-dqbas545 toSci 'ONE' -> NaN Conversion_syntax
-dqbas546 toSci '1e.1' -> NaN Conversion_syntax
-dqbas547 toSci '1e1.' -> NaN Conversion_syntax
-dqbas548 toSci '1ee' -> NaN Conversion_syntax
-dqbas549 toSci 'e+1' -> NaN Conversion_syntax
-dqbas550 toSci '1.23.4' -> NaN Conversion_syntax
-dqbas551 toSci '1.2.1' -> NaN Conversion_syntax
-dqbas552 toSci '1E+1.2' -> NaN Conversion_syntax
-dqbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
-dqbas554 toSci '1E++1' -> NaN Conversion_syntax
-dqbas555 toSci '1E--1' -> NaN Conversion_syntax
-dqbas556 toSci '1E+-1' -> NaN Conversion_syntax
-dqbas557 toSci '1E-+1' -> NaN Conversion_syntax
-dqbas558 toSci '1E''1' -> NaN Conversion_syntax
-dqbas559 toSci "1E""1" -> NaN Conversion_syntax
-dqbas560 toSci "1E""""" -> NaN Conversion_syntax
--- Near-specials
-dqbas561 toSci "qNaN" -> NaN Conversion_syntax
-dqbas562 toSci "NaNq" -> NaN Conversion_syntax
-dqbas563 toSci "NaNs" -> NaN Conversion_syntax
-dqbas564 toSci "Infi" -> NaN Conversion_syntax
-dqbas565 toSci "Infin" -> NaN Conversion_syntax
-dqbas566 toSci "Infini" -> NaN Conversion_syntax
-dqbas567 toSci "Infinit" -> NaN Conversion_syntax
-dqbas568 toSci "-Infinit" -> NaN Conversion_syntax
-dqbas569 toSci "0Inf" -> NaN Conversion_syntax
-dqbas570 toSci "9Inf" -> NaN Conversion_syntax
-dqbas571 toSci "-0Inf" -> NaN Conversion_syntax
-dqbas572 toSci "-9Inf" -> NaN Conversion_syntax
-dqbas573 toSci "-sNa" -> NaN Conversion_syntax
-dqbas574 toSci "xNaN" -> NaN Conversion_syntax
-dqbas575 toSci "0sNaN" -> NaN Conversion_syntax
-
--- some baddies with dots and Es and dots and specials
-dqbas576 toSci 'e+1' -> NaN Conversion_syntax
-dqbas577 toSci '.e+1' -> NaN Conversion_syntax
-dqbas578 toSci '+.e+1' -> NaN Conversion_syntax
-dqbas579 toSci '-.e+' -> NaN Conversion_syntax
-dqbas580 toSci '-.e' -> NaN Conversion_syntax
-dqbas581 toSci 'E+1' -> NaN Conversion_syntax
-dqbas582 toSci '.E+1' -> NaN Conversion_syntax
-dqbas583 toSci '+.E+1' -> NaN Conversion_syntax
-dqbas584 toSci '-.E+' -> NaN Conversion_syntax
-dqbas585 toSci '-.E' -> NaN Conversion_syntax
-
-dqbas586 toSci '.NaN' -> NaN Conversion_syntax
-dqbas587 toSci '-.NaN' -> NaN Conversion_syntax
-dqbas588 toSci '+.sNaN' -> NaN Conversion_syntax
-dqbas589 toSci '+.Inf' -> NaN Conversion_syntax
-dqbas590 toSci '.Infinity' -> NaN Conversion_syntax
-
--- Zeros
-dqbas601 toSci 0.000000000 -> 0E-9
-dqbas602 toSci 0.00000000 -> 0E-8
-dqbas603 toSci 0.0000000 -> 0E-7
-dqbas604 toSci 0.000000 -> 0.000000
-dqbas605 toSci 0.00000 -> 0.00000
-dqbas606 toSci 0.0000 -> 0.0000
-dqbas607 toSci 0.000 -> 0.000
-dqbas608 toSci 0.00 -> 0.00
-dqbas609 toSci 0.0 -> 0.0
-dqbas610 toSci .0 -> 0.0
-dqbas611 toSci 0. -> 0
-dqbas612 toSci -.0 -> -0.0
-dqbas613 toSci -0. -> -0
-dqbas614 toSci -0.0 -> -0.0
-dqbas615 toSci -0.00 -> -0.00
-dqbas616 toSci -0.000 -> -0.000
-dqbas617 toSci -0.0000 -> -0.0000
-dqbas618 toSci -0.00000 -> -0.00000
-dqbas619 toSci -0.000000 -> -0.000000
-dqbas620 toSci -0.0000000 -> -0E-7
-dqbas621 toSci -0.00000000 -> -0E-8
-dqbas622 toSci -0.000000000 -> -0E-9
-
-dqbas630 toSci 0.00E+0 -> 0.00
-dqbas631 toSci 0.00E+1 -> 0.0
-dqbas632 toSci 0.00E+2 -> 0
-dqbas633 toSci 0.00E+3 -> 0E+1
-dqbas634 toSci 0.00E+4 -> 0E+2
-dqbas635 toSci 0.00E+5 -> 0E+3
-dqbas636 toSci 0.00E+6 -> 0E+4
-dqbas637 toSci 0.00E+7 -> 0E+5
-dqbas638 toSci 0.00E+8 -> 0E+6
-dqbas639 toSci 0.00E+9 -> 0E+7
-
-dqbas640 toSci 0.0E+0 -> 0.0
-dqbas641 toSci 0.0E+1 -> 0
-dqbas642 toSci 0.0E+2 -> 0E+1
-dqbas643 toSci 0.0E+3 -> 0E+2
-dqbas644 toSci 0.0E+4 -> 0E+3
-dqbas645 toSci 0.0E+5 -> 0E+4
-dqbas646 toSci 0.0E+6 -> 0E+5
-dqbas647 toSci 0.0E+7 -> 0E+6
-dqbas648 toSci 0.0E+8 -> 0E+7
-dqbas649 toSci 0.0E+9 -> 0E+8
-
-dqbas650 toSci 0E+0 -> 0
-dqbas651 toSci 0E+1 -> 0E+1
-dqbas652 toSci 0E+2 -> 0E+2
-dqbas653 toSci 0E+3 -> 0E+3
-dqbas654 toSci 0E+4 -> 0E+4
-dqbas655 toSci 0E+5 -> 0E+5
-dqbas656 toSci 0E+6 -> 0E+6
-dqbas657 toSci 0E+7 -> 0E+7
-dqbas658 toSci 0E+8 -> 0E+8
-dqbas659 toSci 0E+9 -> 0E+9
-
-dqbas660 toSci 0.0E-0 -> 0.0
-dqbas661 toSci 0.0E-1 -> 0.00
-dqbas662 toSci 0.0E-2 -> 0.000
-dqbas663 toSci 0.0E-3 -> 0.0000
-dqbas664 toSci 0.0E-4 -> 0.00000
-dqbas665 toSci 0.0E-5 -> 0.000000
-dqbas666 toSci 0.0E-6 -> 0E-7
-dqbas667 toSci 0.0E-7 -> 0E-8
-dqbas668 toSci 0.0E-8 -> 0E-9
-dqbas669 toSci 0.0E-9 -> 0E-10
-
-dqbas670 toSci 0.00E-0 -> 0.00
-dqbas671 toSci 0.00E-1 -> 0.000
-dqbas672 toSci 0.00E-2 -> 0.0000
-dqbas673 toSci 0.00E-3 -> 0.00000
-dqbas674 toSci 0.00E-4 -> 0.000000
-dqbas675 toSci 0.00E-5 -> 0E-7
-dqbas676 toSci 0.00E-6 -> 0E-8
-dqbas677 toSci 0.00E-7 -> 0E-9
-dqbas678 toSci 0.00E-8 -> 0E-10
-dqbas679 toSci 0.00E-9 -> 0E-11
-
-dqbas680 toSci 000000. -> 0
-dqbas681 toSci 00000. -> 0
-dqbas682 toSci 0000. -> 0
-dqbas683 toSci 000. -> 0
-dqbas684 toSci 00. -> 0
-dqbas685 toSci 0. -> 0
-dqbas686 toSci +00000. -> 0
-dqbas687 toSci -00000. -> -0
-dqbas688 toSci +0. -> 0
-dqbas689 toSci -0. -> -0
-
--- Specials
-dqbas700 toSci "NaN" -> NaN
-dqbas701 toSci "nan" -> NaN
-dqbas702 toSci "nAn" -> NaN
-dqbas703 toSci "NAN" -> NaN
-dqbas704 toSci "+NaN" -> NaN
-dqbas705 toSci "+nan" -> NaN
-dqbas706 toSci "+nAn" -> NaN
-dqbas707 toSci "+NAN" -> NaN
-dqbas708 toSci "-NaN" -> -NaN
-dqbas709 toSci "-nan" -> -NaN
-dqbas710 toSci "-nAn" -> -NaN
-dqbas711 toSci "-NAN" -> -NaN
-dqbas712 toSci 'NaN0' -> NaN
-dqbas713 toSci 'NaN1' -> NaN1
-dqbas714 toSci 'NaN12' -> NaN12
-dqbas715 toSci 'NaN123' -> NaN123
-dqbas716 toSci 'NaN1234' -> NaN1234
-dqbas717 toSci 'NaN01' -> NaN1
-dqbas718 toSci 'NaN012' -> NaN12
-dqbas719 toSci 'NaN0123' -> NaN123
-dqbas720 toSci 'NaN01234' -> NaN1234
-dqbas721 toSci 'NaN001' -> NaN1
-dqbas722 toSci 'NaN0012' -> NaN12
-dqbas723 toSci 'NaN00123' -> NaN123
-dqbas724 toSci 'NaN001234' -> NaN1234
-dqbas725 toSci 'NaN1234567890123456781234567890123456' -> NaN Conversion_syntax
-dqbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
-dqbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
-dqbas728 toSci 'NaN-12' -> NaN Conversion_syntax
-dqbas729 toSci 'NaN+12' -> NaN Conversion_syntax
-
-dqbas730 toSci "sNaN" -> sNaN
-dqbas731 toSci "snan" -> sNaN
-dqbas732 toSci "SnAn" -> sNaN
-dqbas733 toSci "SNAN" -> sNaN
-dqbas734 toSci "+sNaN" -> sNaN
-dqbas735 toSci "+snan" -> sNaN
-dqbas736 toSci "+SnAn" -> sNaN
-dqbas737 toSci "+SNAN" -> sNaN
-dqbas738 toSci "-sNaN" -> -sNaN
-dqbas739 toSci "-snan" -> -sNaN
-dqbas740 toSci "-SnAn" -> -sNaN
-dqbas741 toSci "-SNAN" -> -sNaN
-dqbas742 toSci 'sNaN0000' -> sNaN
-dqbas743 toSci 'sNaN7' -> sNaN7
-dqbas744 toSci 'sNaN007234' -> sNaN7234
-dqbas745 toSci 'sNaN1234567890123456787234561234567890' -> NaN Conversion_syntax
-dqbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
-dqbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
-
-dqbas748 toSci "Inf" -> Infinity
-dqbas749 toSci "inf" -> Infinity
-dqbas750 toSci "iNf" -> Infinity
-dqbas751 toSci "INF" -> Infinity
-dqbas752 toSci "+Inf" -> Infinity
-dqbas753 toSci "+inf" -> Infinity
-dqbas754 toSci "+iNf" -> Infinity
-dqbas755 toSci "+INF" -> Infinity
-dqbas756 toSci "-Inf" -> -Infinity
-dqbas757 toSci "-inf" -> -Infinity
-dqbas758 toSci "-iNf" -> -Infinity
-dqbas759 toSci "-INF" -> -Infinity
-
-dqbas760 toSci "Infinity" -> Infinity
-dqbas761 toSci "infinity" -> Infinity
-dqbas762 toSci "iNfInItY" -> Infinity
-dqbas763 toSci "INFINITY" -> Infinity
-dqbas764 toSci "+Infinity" -> Infinity
-dqbas765 toSci "+infinity" -> Infinity
-dqbas766 toSci "+iNfInItY" -> Infinity
-dqbas767 toSci "+INFINITY" -> Infinity
-dqbas768 toSci "-Infinity" -> -Infinity
-dqbas769 toSci "-infinity" -> -Infinity
-dqbas770 toSci "-iNfInItY" -> -Infinity
-dqbas771 toSci "-INFINITY" -> -Infinity
-
--- Specials and zeros for toEng
-dqbast772 toEng "NaN" -> NaN
-dqbast773 toEng "-Infinity" -> -Infinity
-dqbast774 toEng "-sNaN" -> -sNaN
-dqbast775 toEng "-NaN" -> -NaN
-dqbast776 toEng "+Infinity" -> Infinity
-dqbast778 toEng "+sNaN" -> sNaN
-dqbast779 toEng "+NaN" -> NaN
-dqbast780 toEng "INFINITY" -> Infinity
-dqbast781 toEng "SNAN" -> sNaN
-dqbast782 toEng "NAN" -> NaN
-dqbast783 toEng "infinity" -> Infinity
-dqbast784 toEng "snan" -> sNaN
-dqbast785 toEng "nan" -> NaN
-dqbast786 toEng "InFINITY" -> Infinity
-dqbast787 toEng "SnAN" -> sNaN
-dqbast788 toEng "nAN" -> NaN
-dqbast789 toEng "iNfinity" -> Infinity
-dqbast790 toEng "sNan" -> sNaN
-dqbast791 toEng "Nan" -> NaN
-dqbast792 toEng "Infinity" -> Infinity
-dqbast793 toEng "sNaN" -> sNaN
-
--- Zero toEng, etc.
-dqbast800 toEng 0e+1 -> "0.00E+3" -- doc example
-
-dqbast801 toEng 0.000000000 -> 0E-9
-dqbast802 toEng 0.00000000 -> 0.00E-6
-dqbast803 toEng 0.0000000 -> 0.0E-6
-dqbast804 toEng 0.000000 -> 0.000000
-dqbast805 toEng 0.00000 -> 0.00000
-dqbast806 toEng 0.0000 -> 0.0000
-dqbast807 toEng 0.000 -> 0.000
-dqbast808 toEng 0.00 -> 0.00
-dqbast809 toEng 0.0 -> 0.0
-dqbast810 toEng .0 -> 0.0
-dqbast811 toEng 0. -> 0
-dqbast812 toEng -.0 -> -0.0
-dqbast813 toEng -0. -> -0
-dqbast814 toEng -0.0 -> -0.0
-dqbast815 toEng -0.00 -> -0.00
-dqbast816 toEng -0.000 -> -0.000
-dqbast817 toEng -0.0000 -> -0.0000
-dqbast818 toEng -0.00000 -> -0.00000
-dqbast819 toEng -0.000000 -> -0.000000
-dqbast820 toEng -0.0000000 -> -0.0E-6
-dqbast821 toEng -0.00000000 -> -0.00E-6
-dqbast822 toEng -0.000000000 -> -0E-9
-
-dqbast830 toEng 0.00E+0 -> 0.00
-dqbast831 toEng 0.00E+1 -> 0.0
-dqbast832 toEng 0.00E+2 -> 0
-dqbast833 toEng 0.00E+3 -> 0.00E+3
-dqbast834 toEng 0.00E+4 -> 0.0E+3
-dqbast835 toEng 0.00E+5 -> 0E+3
-dqbast836 toEng 0.00E+6 -> 0.00E+6
-dqbast837 toEng 0.00E+7 -> 0.0E+6
-dqbast838 toEng 0.00E+8 -> 0E+6
-dqbast839 toEng 0.00E+9 -> 0.00E+9
-
-dqbast840 toEng 0.0E+0 -> 0.0
-dqbast841 toEng 0.0E+1 -> 0
-dqbast842 toEng 0.0E+2 -> 0.00E+3
-dqbast843 toEng 0.0E+3 -> 0.0E+3
-dqbast844 toEng 0.0E+4 -> 0E+3
-dqbast845 toEng 0.0E+5 -> 0.00E+6
-dqbast846 toEng 0.0E+6 -> 0.0E+6
-dqbast847 toEng 0.0E+7 -> 0E+6
-dqbast848 toEng 0.0E+8 -> 0.00E+9
-dqbast849 toEng 0.0E+9 -> 0.0E+9
-
-dqbast850 toEng 0E+0 -> 0
-dqbast851 toEng 0E+1 -> 0.00E+3
-dqbast852 toEng 0E+2 -> 0.0E+3
-dqbast853 toEng 0E+3 -> 0E+3
-dqbast854 toEng 0E+4 -> 0.00E+6
-dqbast855 toEng 0E+5 -> 0.0E+6
-dqbast856 toEng 0E+6 -> 0E+6
-dqbast857 toEng 0E+7 -> 0.00E+9
-dqbast858 toEng 0E+8 -> 0.0E+9
-dqbast859 toEng 0E+9 -> 0E+9
-
-dqbast860 toEng 0.0E-0 -> 0.0
-dqbast861 toEng 0.0E-1 -> 0.00
-dqbast862 toEng 0.0E-2 -> 0.000
-dqbast863 toEng 0.0E-3 -> 0.0000
-dqbast864 toEng 0.0E-4 -> 0.00000
-dqbast865 toEng 0.0E-5 -> 0.000000
-dqbast866 toEng 0.0E-6 -> 0.0E-6
-dqbast867 toEng 0.0E-7 -> 0.00E-6
-dqbast868 toEng 0.0E-8 -> 0E-9
-dqbast869 toEng 0.0E-9 -> 0.0E-9
-
-dqbast870 toEng 0.00E-0 -> 0.00
-dqbast871 toEng 0.00E-1 -> 0.000
-dqbast872 toEng 0.00E-2 -> 0.0000
-dqbast873 toEng 0.00E-3 -> 0.00000
-dqbast874 toEng 0.00E-4 -> 0.000000
-dqbast875 toEng 0.00E-5 -> 0.0E-6
-dqbast876 toEng 0.00E-6 -> 0.00E-6
-dqbast877 toEng 0.00E-7 -> 0E-9
-dqbast878 toEng 0.00E-8 -> 0.0E-9
-dqbast879 toEng 0.00E-9 -> 0.00E-9
-
--- long input strings
-dqbas801 tosci '01234567890123456' -> 1234567890123456
-dqbas802 tosci '001234567890123456' -> 1234567890123456
-dqbas803 tosci '0001234567890123456' -> 1234567890123456
-dqbas804 tosci '00001234567890123456' -> 1234567890123456
-dqbas805 tosci '000001234567890123456' -> 1234567890123456
-dqbas806 tosci '0000001234567890123456' -> 1234567890123456
-dqbas807 tosci '00000001234567890123456' -> 1234567890123456
-dqbas808 tosci '000000001234567890123456' -> 1234567890123456
-dqbas809 tosci '0000000001234567890123456' -> 1234567890123456
-dqbas810 tosci '00000000001234567890123456' -> 1234567890123456
-
-dqbas811 tosci '0.1234567890123456' -> 0.1234567890123456
-dqbas812 tosci '0.01234567890123456' -> 0.01234567890123456
-dqbas813 tosci '0.001234567890123456' -> 0.001234567890123456
-dqbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
-dqbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
-dqbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
-dqbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
-dqbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
-dqbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
-dqbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10
-
-dqbas821 tosci '12345678912345678901234567801234567890' -> 1.234567891234567890123456780123457E+37 Inexact Rounded
-dqbas822 tosci '123456789123456789012345678012345678901' -> 1.234567891234567890123456780123457E+38 Inexact Rounded
-dqbas823 tosci '1234567891234567890123456780123456789012' -> 1.234567891234567890123456780123457E+39 Inexact Rounded
-dqbas824 tosci '12345678912345678901234567801234567890123' -> 1.234567891234567890123456780123457E+40 Inexact Rounded
-dqbas825 tosci '123456789123456789012345678012345678901234' -> 1.234567891234567890123456780123457E+41 Inexact Rounded
-dqbas826 tosci '1234567891234567890123456780123456789012345' -> 1.234567891234567890123456780123457E+42 Inexact Rounded
-dqbas827 tosci '12345678912345678901234567801234567890123456' -> 1.234567891234567890123456780123457E+43 Inexact Rounded
-dqbas828 tosci '123456789123456789012345678012345678901234567' -> 1.234567891234567890123456780123457E+44 Inexact Rounded
-dqbas829 tosci '1234567891234567890123456780123456789012345678' -> 1.234567891234567890123456780123457E+45 Inexact Rounded
-
--- subnormals and overflows
-dqbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
-dqbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
-dqbas908 toSci '0.9e-999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas909 toSci '0.09e-999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
-dqbas911 toSci '10e-1000000000' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
-dqbas913 toSci '99e-9999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
-dqbas915 toSci '1111e-9999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas916 toSci '1111e-99999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
--- negatives the same
-dqbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
-dqbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
-dqbas920 toSci '-0.9e-999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas921 toSci '-0.09e-999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
-dqbas923 toSci '-10e-1000000000' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
-dqbas925 toSci '-99e-9999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
-dqbas927 toSci '-1111e-9999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas928 toSci '-1111e-99999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
-
--- overflow results at different rounding modes
-rounding: ceiling
-dqbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas931 toSci '-7e10000' -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-rounding: up
-dqbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: down
-dqbas934 toSci '7e10000' -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqbas935 toSci '-7e10000' -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-rounding: floor
-dqbas936 toSci '7e10000' -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_up
-dqbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_even
-dqbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_down
-dqbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_even
-
--- Now check 854/754r some subnormals and underflow to 0
-dqbem400 toSci 1.0000E-383 -> 1.0000E-383
-dqbem401 toSci 0.1E-6172 -> 1E-6173 Subnormal
-dqbem402 toSci 0.1000E-6172 -> 1.000E-6173 Subnormal
-dqbem403 toSci 0.0100E-6172 -> 1.00E-6174 Subnormal
-dqbem404 toSci 0.0010E-6172 -> 1.0E-6175 Subnormal
-dqbem405 toSci 0.0001E-6172 -> 1E-6176 Subnormal
-dqbem406 toSci 0.00010E-6172 -> 1E-6176 Subnormal Rounded
-dqbem407 toSci 0.00013E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqbem408 toSci 0.00015E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem409 toSci 0.00017E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem410 toSci 0.00023E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem411 toSci 0.00025E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem412 toSci 0.00027E-6172 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqbem413 toSci 0.000149E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqbem414 toSci 0.000150E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem415 toSci 0.000151E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem416 toSci 0.000249E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem417 toSci 0.000250E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem418 toSci 0.000251E-6172 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqbem419 toSci 0.00009E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqbem420 toSci 0.00005E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem421 toSci 0.00003E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem422 toSci 0.000009E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem423 toSci 0.000005E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem424 toSci 0.000003E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqbem425 toSci 0.001049E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
-dqbem426 toSci 0.001050E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
-dqbem427 toSci 0.001051E-6172 -> 1.1E-6175 Underflow Subnormal Inexact Rounded
-dqbem428 toSci 0.001149E-6172 -> 1.1E-6175 Underflow Subnormal Inexact Rounded
-dqbem429 toSci 0.001150E-6172 -> 1.2E-6175 Underflow Subnormal Inexact Rounded
-dqbem430 toSci 0.001151E-6172 -> 1.2E-6175 Underflow Subnormal Inexact Rounded
-
-dqbem432 toSci 0.010049E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
-dqbem433 toSci 0.010050E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
-dqbem434 toSci 0.010051E-6172 -> 1.01E-6174 Underflow Subnormal Inexact Rounded
-dqbem435 toSci 0.010149E-6172 -> 1.01E-6174 Underflow Subnormal Inexact Rounded
-dqbem436 toSci 0.010150E-6172 -> 1.02E-6174 Underflow Subnormal Inexact Rounded
-dqbem437 toSci 0.010151E-6172 -> 1.02E-6174 Underflow Subnormal Inexact Rounded
-
-dqbem440 toSci 0.10103E-6172 -> 1.010E-6173 Underflow Subnormal Inexact Rounded
-dqbem441 toSci 0.10105E-6172 -> 1.010E-6173 Underflow Subnormal Inexact Rounded
-dqbem442 toSci 0.10107E-6172 -> 1.011E-6173 Underflow Subnormal Inexact Rounded
-dqbem443 toSci 0.10113E-6172 -> 1.011E-6173 Underflow Subnormal Inexact Rounded
-dqbem444 toSci 0.10115E-6172 -> 1.012E-6173 Underflow Subnormal Inexact Rounded
-dqbem445 toSci 0.10117E-6172 -> 1.012E-6173 Underflow Subnormal Inexact Rounded
-
-dqbem450 toSci 1.10730E-6173 -> 1.107E-6173 Underflow Subnormal Inexact Rounded
-dqbem451 toSci 1.10750E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
-dqbem452 toSci 1.10770E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
-dqbem453 toSci 1.10830E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
-dqbem454 toSci 1.10850E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
-dqbem455 toSci 1.10870E-6173 -> 1.109E-6173 Underflow Subnormal Inexact Rounded
-
--- make sure sign OK
-dqbem456 toSci -0.10103E-6172 -> -1.010E-6173 Underflow Subnormal Inexact Rounded
-dqbem457 toSci -0.10105E-6172 -> -1.010E-6173 Underflow Subnormal Inexact Rounded
-dqbem458 toSci -0.10107E-6172 -> -1.011E-6173 Underflow Subnormal Inexact Rounded
-dqbem459 toSci -0.10113E-6172 -> -1.011E-6173 Underflow Subnormal Inexact Rounded
-dqbem460 toSci -0.10115E-6172 -> -1.012E-6173 Underflow Subnormal Inexact Rounded
-dqbem461 toSci -0.10117E-6172 -> -1.012E-6173 Underflow Subnormal Inexact Rounded
-
--- '999s' cases
-dqbem464 toSci 999999E-6173 -> 9.99999E-6168 Subnormal
-dqbem465 toSci 99999.0E-6172 -> 9.99990E-6168 Subnormal
-dqbem466 toSci 99999.E-6172 -> 9.9999E-6168 Subnormal
-dqbem467 toSci 9999.9E-6172 -> 9.9999E-6169 Subnormal
-dqbem468 toSci 999.99E-6172 -> 9.9999E-6170 Subnormal
-dqbem469 toSci 99.999E-6172 -> 9.9999E-6171 Subnormal
-dqbem470 toSci 9.9999E-6172 -> 9.9999E-6172 Subnormal
-dqbem471 toSci 0.99999E-6172 -> 1.0000E-6172 Underflow Subnormal Inexact Rounded
-dqbem472 toSci 0.099999E-6172 -> 1.000E-6173 Underflow Subnormal Inexact Rounded
-dqbem473 toSci 0.0099999E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
-dqbem474 toSci 0.00099999E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
-dqbem475 toSci 0.000099999E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqbem476 toSci 0.0000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem477 toSci 0.00000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem478 toSci 0.000000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- Exponents with insignificant leading zeros
-dqbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
-dqbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
-dqbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
-dqbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
-dqbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
-dqbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
-dqbas1007 toSci 1e-999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1008 toSci 1e-0999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1009 toSci 1e-00999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1010 toSci 1e-000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1011 toSci 1e-000000000000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1012 toSci 1e-000000000001000000007 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- check for double-rounded subnormals
-dqbas1041 toSci 1.1111111111111111111111111111152444E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
-dqbas1042 toSci 1.1111111111111111111111111111152445E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
-dqbas1043 toSci 1.1111111111111111111111111111152446E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
-
--- clamped zeros [see also clamp.decTest]
-dqbas1075 toSci 0e+10000 -> 0E+6111 Clamped
-dqbas1076 toSci 0e-10000 -> 0E-6176 Clamped
-dqbas1077 toSci -0e+10000 -> -0E+6111 Clamped
-dqbas1078 toSci -0e-10000 -> -0E-6176 Clamped
-
--- extreme values from next-wider
-dqbas1101 toSci -9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> -Infinity Overflow Inexact Rounded
-dqbas1102 toSci -1E-1572863 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
-dqbas1103 toSci -1E-1572932 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
-dqbas1104 toSci -0 -> -0
-dqbas1105 toSci +0 -> 0
-dqbas1106 toSci +1E-1572932 -> 0E-6176 Inexact Rounded Subnormal Underflow Clamped
-dqbas1107 toSci +1E-1572863 -> 0E-6176 Inexact Rounded Subnormal Underflow Clamped
-dqbas1108 toSci +9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> Infinity Overflow Inexact Rounded
-
+------------------------------------------------------------------------
+-- dqBase.decTest -- base decQuad <--> string conversions --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests base conversions from string to a decimal number
+-- and back to a string (in Scientific form)
+
+-- Note that unlike other operations the operand is subject to rounding
+-- to conform to emax and precision settings (that is, numbers will
+-- conform to rules and exponent will be in permitted range). The
+-- 'left hand side', therefore, may have numbers that cannot be
+-- represented in a decQuad. Some testcases go to the limit of the
+-- next-wider format, and hence these testcases may also be used to
+-- test narrowing and widening operations.
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqbas001 toSci 0 -> 0
+dqbas002 toSci 1 -> 1
+dqbas003 toSci 1.0 -> 1.0
+dqbas004 toSci 1.00 -> 1.00
+dqbas005 toSci 10 -> 10
+dqbas006 toSci 1000 -> 1000
+dqbas007 toSci 10.0 -> 10.0
+dqbas008 toSci 10.1 -> 10.1
+dqbas009 toSci 10.4 -> 10.4
+dqbas010 toSci 10.5 -> 10.5
+dqbas011 toSci 10.6 -> 10.6
+dqbas012 toSci 10.9 -> 10.9
+dqbas013 toSci 11.0 -> 11.0
+dqbas014 toSci 1.234 -> 1.234
+dqbas015 toSci 0.123 -> 0.123
+dqbas016 toSci 0.012 -> 0.012
+dqbas017 toSci -0 -> -0
+dqbas018 toSci -0.0 -> -0.0
+dqbas019 toSci -00.00 -> -0.00
+
+dqbas021 toSci -1 -> -1
+dqbas022 toSci -1.0 -> -1.0
+dqbas023 toSci -0.1 -> -0.1
+dqbas024 toSci -9.1 -> -9.1
+dqbas025 toSci -9.11 -> -9.11
+dqbas026 toSci -9.119 -> -9.119
+dqbas027 toSci -9.999 -> -9.999
+
+dqbas030 toSci '123456789.123456' -> '123456789.123456'
+dqbas031 toSci '123456789.000000' -> '123456789.000000'
+dqbas032 toSci '123456789123456' -> '123456789123456'
+dqbas033 toSci '0.0000123456789' -> '0.0000123456789'
+dqbas034 toSci '0.00000123456789' -> '0.00000123456789'
+dqbas035 toSci '0.000000123456789' -> '1.23456789E-7'
+dqbas036 toSci '0.0000000123456789' -> '1.23456789E-8'
+
+dqbas037 toSci '0.123456789012344' -> '0.123456789012344'
+dqbas038 toSci '0.123456789012345' -> '0.123456789012345'
+
+-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
+dqbsn001 toSci -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqbsn002 toSci -1E-6143 -> -1E-6143
+dqbsn003 toSci -1E-6176 -> -1E-6176 Subnormal
+dqbsn004 toSci -0 -> -0
+dqbsn005 toSci +0 -> 0
+dqbsn006 toSci +1E-6176 -> 1E-6176 Subnormal
+dqbsn007 toSci +1E-6143 -> 1E-6143
+dqbsn008 toSci +9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+
+-- String [many more examples are implicitly tested elsewhere]
+-- strings without E cannot generate E in result
+dqbas040 toSci "12" -> '12'
+dqbas041 toSci "-76" -> '-76'
+dqbas042 toSci "12.76" -> '12.76'
+dqbas043 toSci "+12.76" -> '12.76'
+dqbas044 toSci "012.76" -> '12.76'
+dqbas045 toSci "+0.003" -> '0.003'
+dqbas046 toSci "17." -> '17'
+dqbas047 toSci ".5" -> '0.5'
+dqbas048 toSci "044" -> '44'
+dqbas049 toSci "0044" -> '44'
+dqbas050 toSci "0.0005" -> '0.0005'
+dqbas051 toSci "00.00005" -> '0.00005'
+dqbas052 toSci "0.000005" -> '0.000005'
+dqbas053 toSci "0.0000050" -> '0.0000050'
+dqbas054 toSci "0.0000005" -> '5E-7'
+dqbas055 toSci "0.00000005" -> '5E-8'
+dqbas056 toSci "12345678.543210" -> '12345678.543210'
+dqbas057 toSci "2345678.543210" -> '2345678.543210'
+dqbas058 toSci "345678.543210" -> '345678.543210'
+dqbas059 toSci "0345678.54321" -> '345678.54321'
+dqbas060 toSci "345678.5432" -> '345678.5432'
+dqbas061 toSci "+345678.5432" -> '345678.5432'
+dqbas062 toSci "+0345678.5432" -> '345678.5432'
+dqbas063 toSci "+00345678.5432" -> '345678.5432'
+dqbas064 toSci "-345678.5432" -> '-345678.5432'
+dqbas065 toSci "-0345678.5432" -> '-345678.5432'
+dqbas066 toSci "-00345678.5432" -> '-345678.5432'
+-- examples
+dqbas067 toSci "5E-6" -> '0.000005'
+dqbas068 toSci "50E-7" -> '0.0000050'
+dqbas069 toSci "5E-7" -> '5E-7'
+
+-- [No exotics as no Unicode]
+
+-- rounded with dots in all (including edge) places
+dqbas071 toSci .1234567891234567890123456780123456123 -> 0.1234567891234567890123456780123456 Inexact Rounded
+dqbas072 toSci 1.234567891234567890123456780123456123 -> 1.234567891234567890123456780123456 Inexact Rounded
+dqbas073 toSci 12.34567891234567890123456780123456123 -> 12.34567891234567890123456780123456 Inexact Rounded
+dqbas074 toSci 123.4567891234567890123456780123456123 -> 123.4567891234567890123456780123456 Inexact Rounded
+dqbas075 toSci 1234.567891234567890123456780123456123 -> 1234.567891234567890123456780123456 Inexact Rounded
+dqbas076 toSci 12345.67891234567890123456780123456123 -> 12345.67891234567890123456780123456 Inexact Rounded
+dqbas077 toSci 123456.7891234567890123456780123456123 -> 123456.7891234567890123456780123456 Inexact Rounded
+dqbas078 toSci 1234567.891234567890123456780123456123 -> 1234567.891234567890123456780123456 Inexact Rounded
+dqbas079 toSci 12345678.91234567890123456780123456123 -> 12345678.91234567890123456780123456 Inexact Rounded
+dqbas080 toSci 123456789.1234567890123456780123456123 -> 123456789.1234567890123456780123456 Inexact Rounded
+dqbas081 toSci 1234567891.234567890123456780123456123 -> 1234567891.234567890123456780123456 Inexact Rounded
+dqbas082 toSci 12345678912.34567890123456780123456123 -> 12345678912.34567890123456780123456 Inexact Rounded
+dqbas083 toSci 123456789123.4567890123456780123456123 -> 123456789123.4567890123456780123456 Inexact Rounded
+dqbas084 toSci 1234567891234.567890123456780123456123 -> 1234567891234.567890123456780123456 Inexact Rounded
+dqbas085 toSci 12345678912345.67890123456780123456123 -> 12345678912345.67890123456780123456 Inexact Rounded
+dqbas086 toSci 123456789123456.7890123456780123456123 -> 123456789123456.7890123456780123456 Inexact Rounded
+dqbas087 toSci 1234567891234567.890123456780123456123 -> 1234567891234567.890123456780123456 Inexact Rounded
+dqbas088 toSci 12345678912345678.90123456780123456123 -> 12345678912345678.90123456780123456 Inexact Rounded
+dqbas089 toSci 123456789123456789.0123456780123456123 -> 123456789123456789.0123456780123456 Inexact Rounded
+dqbas090 toSci 1234567891234567890.123456780123456123 -> 1234567891234567890.123456780123456 Inexact Rounded
+dqbas091 toSci 12345678912345678901.23456780123456123 -> 12345678912345678901.23456780123456 Inexact Rounded
+dqbas092 toSci 123456789123456789012.3456780123456123 -> 123456789123456789012.3456780123456 Inexact Rounded
+dqbas093 toSci 1234567891234567890123.456780123456123 -> 1234567891234567890123.456780123456 Inexact Rounded
+dqbas094 toSci 12345678912345678901234.56780123456123 -> 12345678912345678901234.56780123456 Inexact Rounded
+dqbas095 toSci 123456789123456789012345.6780123456123 -> 123456789123456789012345.6780123456 Inexact Rounded
+dqbas096 toSci 1234567891234567890123456.780123456123 -> 1234567891234567890123456.780123456 Inexact Rounded
+dqbas097 toSci 12345678912345678901234567.80123456123 -> 12345678912345678901234567.80123456 Inexact Rounded
+dqbas098 toSci 123456789123456789012345678.0123456123 -> 123456789123456789012345678.0123456 Inexact Rounded
+dqbas099 toSci 1234567891234567890123456780.123456123 -> 1234567891234567890123456780.123456 Inexact Rounded
+dqbas100 toSci 12345678912345678901234567801.23456123 -> 12345678912345678901234567801.23456 Inexact Rounded
+dqbas101 toSci 123456789123456789012345678012.3456123 -> 123456789123456789012345678012.3456 Inexact Rounded
+dqbas102 toSci 1234567891234567890123456780123.456123 -> 1234567891234567890123456780123.456 Inexact Rounded
+dqbas103 toSci 12345678912345678901234567801234.56123 -> 12345678912345678901234567801234.56 Inexact Rounded
+dqbas104 toSci 123456789123456789012345678012345.6123 -> 123456789123456789012345678012345.6 Inexact Rounded
+dqbas105 toSci 1234567891234567890123456780123456.123 -> 1234567891234567890123456780123456 Inexact Rounded
+dqbas106 toSci 12345678912345678901234567801234561.23 -> 1.234567891234567890123456780123456E+34 Inexact Rounded
+dqbas107 toSci 123456789123456789012345678012345612.3 -> 1.234567891234567890123456780123456E+35 Inexact Rounded
+dqbas108 toSci 1234567891234567890123456780123456123. -> 1.234567891234567890123456780123456E+36 Inexact Rounded
+-- 123456789012345678
+
+-- Numbers with E
+dqbas130 toSci "0.000E-1" -> '0.0000'
+dqbas131 toSci "0.000E-2" -> '0.00000'
+dqbas132 toSci "0.000E-3" -> '0.000000'
+dqbas133 toSci "0.000E-4" -> '0E-7'
+dqbas134 toSci "0.00E-2" -> '0.0000'
+dqbas135 toSci "0.00E-3" -> '0.00000'
+dqbas136 toSci "0.00E-4" -> '0.000000'
+dqbas137 toSci "0.00E-5" -> '0E-7'
+dqbas138 toSci "+0E+9" -> '0E+9'
+dqbas139 toSci "-0E+9" -> '-0E+9'
+dqbas140 toSci "1E+9" -> '1E+9'
+dqbas141 toSci "1e+09" -> '1E+9'
+dqbas142 toSci "1E+90" -> '1E+90'
+dqbas143 toSci "+1E+009" -> '1E+9'
+dqbas144 toSci "0E+9" -> '0E+9'
+dqbas145 toSci "1E+9" -> '1E+9'
+dqbas146 toSci "1E+09" -> '1E+9'
+dqbas147 toSci "1e+90" -> '1E+90'
+dqbas148 toSci "1E+009" -> '1E+9'
+dqbas149 toSci "000E+9" -> '0E+9'
+dqbas150 toSci "1E9" -> '1E+9'
+dqbas151 toSci "1e09" -> '1E+9'
+dqbas152 toSci "1E90" -> '1E+90'
+dqbas153 toSci "1E009" -> '1E+9'
+dqbas154 toSci "0E9" -> '0E+9'
+dqbas155 toSci "0.000e+0" -> '0.000'
+dqbas156 toSci "0.000E-1" -> '0.0000'
+dqbas157 toSci "4E+9" -> '4E+9'
+dqbas158 toSci "44E+9" -> '4.4E+10'
+dqbas159 toSci "0.73e-7" -> '7.3E-8'
+dqbas160 toSci "00E+9" -> '0E+9'
+dqbas161 toSci "00E-9" -> '0E-9'
+dqbas162 toSci "10E+9" -> '1.0E+10'
+dqbas163 toSci "10E+09" -> '1.0E+10'
+dqbas164 toSci "10e+90" -> '1.0E+91'
+dqbas165 toSci "10E+009" -> '1.0E+10'
+dqbas166 toSci "100e+9" -> '1.00E+11'
+dqbas167 toSci "100e+09" -> '1.00E+11'
+dqbas168 toSci "100E+90" -> '1.00E+92'
+dqbas169 toSci "100e+009" -> '1.00E+11'
+
+dqbas170 toSci "1.265" -> '1.265'
+dqbas171 toSci "1.265E-20" -> '1.265E-20'
+dqbas172 toSci "1.265E-8" -> '1.265E-8'
+dqbas173 toSci "1.265E-4" -> '0.0001265'
+dqbas174 toSci "1.265E-3" -> '0.001265'
+dqbas175 toSci "1.265E-2" -> '0.01265'
+dqbas176 toSci "1.265E-1" -> '0.1265'
+dqbas177 toSci "1.265E-0" -> '1.265'
+dqbas178 toSci "1.265E+1" -> '12.65'
+dqbas179 toSci "1.265E+2" -> '126.5'
+dqbas180 toSci "1.265E+3" -> '1265'
+dqbas181 toSci "1.265E+4" -> '1.265E+4'
+dqbas182 toSci "1.265E+8" -> '1.265E+8'
+dqbas183 toSci "1.265E+20" -> '1.265E+20'
+
+dqbas190 toSci "12.65" -> '12.65'
+dqbas191 toSci "12.65E-20" -> '1.265E-19'
+dqbas192 toSci "12.65E-8" -> '1.265E-7'
+dqbas193 toSci "12.65E-4" -> '0.001265'
+dqbas194 toSci "12.65E-3" -> '0.01265'
+dqbas195 toSci "12.65E-2" -> '0.1265'
+dqbas196 toSci "12.65E-1" -> '1.265'
+dqbas197 toSci "12.65E-0" -> '12.65'
+dqbas198 toSci "12.65E+1" -> '126.5'
+dqbas199 toSci "12.65E+2" -> '1265'
+dqbas200 toSci "12.65E+3" -> '1.265E+4'
+dqbas201 toSci "12.65E+4" -> '1.265E+5'
+dqbas202 toSci "12.65E+8" -> '1.265E+9'
+dqbas203 toSci "12.65E+20" -> '1.265E+21'
+
+dqbas210 toSci "126.5" -> '126.5'
+dqbas211 toSci "126.5E-20" -> '1.265E-18'
+dqbas212 toSci "126.5E-8" -> '0.000001265'
+dqbas213 toSci "126.5E-4" -> '0.01265'
+dqbas214 toSci "126.5E-3" -> '0.1265'
+dqbas215 toSci "126.5E-2" -> '1.265'
+dqbas216 toSci "126.5E-1" -> '12.65'
+dqbas217 toSci "126.5E-0" -> '126.5'
+dqbas218 toSci "126.5E+1" -> '1265'
+dqbas219 toSci "126.5E+2" -> '1.265E+4'
+dqbas220 toSci "126.5E+3" -> '1.265E+5'
+dqbas221 toSci "126.5E+4" -> '1.265E+6'
+dqbas222 toSci "126.5E+8" -> '1.265E+10'
+dqbas223 toSci "126.5E+20" -> '1.265E+22'
+
+dqbas230 toSci "1265" -> '1265'
+dqbas231 toSci "1265E-20" -> '1.265E-17'
+dqbas232 toSci "1265E-8" -> '0.00001265'
+dqbas233 toSci "1265E-4" -> '0.1265'
+dqbas234 toSci "1265E-3" -> '1.265'
+dqbas235 toSci "1265E-2" -> '12.65'
+dqbas236 toSci "1265E-1" -> '126.5'
+dqbas237 toSci "1265E-0" -> '1265'
+dqbas238 toSci "1265E+1" -> '1.265E+4'
+dqbas239 toSci "1265E+2" -> '1.265E+5'
+dqbas240 toSci "1265E+3" -> '1.265E+6'
+dqbas241 toSci "1265E+4" -> '1.265E+7'
+dqbas242 toSci "1265E+8" -> '1.265E+11'
+dqbas243 toSci "1265E+20" -> '1.265E+23'
+
+dqbas250 toSci "0.1265" -> '0.1265'
+dqbas251 toSci "0.1265E-20" -> '1.265E-21'
+dqbas252 toSci "0.1265E-8" -> '1.265E-9'
+dqbas253 toSci "0.1265E-4" -> '0.00001265'
+dqbas254 toSci "0.1265E-3" -> '0.0001265'
+dqbas255 toSci "0.1265E-2" -> '0.001265'
+dqbas256 toSci "0.1265E-1" -> '0.01265'
+dqbas257 toSci "0.1265E-0" -> '0.1265'
+dqbas258 toSci "0.1265E+1" -> '1.265'
+dqbas259 toSci "0.1265E+2" -> '12.65'
+dqbas260 toSci "0.1265E+3" -> '126.5'
+dqbas261 toSci "0.1265E+4" -> '1265'
+dqbas262 toSci "0.1265E+8" -> '1.265E+7'
+dqbas263 toSci "0.1265E+20" -> '1.265E+19'
+
+-- some more negative zeros [systematic tests below]
+dqbas290 toSci "-0.000E-1" -> '-0.0000'
+dqbas291 toSci "-0.000E-2" -> '-0.00000'
+dqbas292 toSci "-0.000E-3" -> '-0.000000'
+dqbas293 toSci "-0.000E-4" -> '-0E-7'
+dqbas294 toSci "-0.00E-2" -> '-0.0000'
+dqbas295 toSci "-0.00E-3" -> '-0.00000'
+dqbas296 toSci "-0.0E-2" -> '-0.000'
+dqbas297 toSci "-0.0E-3" -> '-0.0000'
+dqbas298 toSci "-0E-2" -> '-0.00'
+dqbas299 toSci "-0E-3" -> '-0.000'
+
+-- Engineering notation tests
+dqbas301 toSci 10e12 -> 1.0E+13
+dqbas302 toEng 10e12 -> 10E+12
+dqbas303 toSci 10e11 -> 1.0E+12
+dqbas304 toEng 10e11 -> 1.0E+12
+dqbas305 toSci 10e10 -> 1.0E+11
+dqbas306 toEng 10e10 -> 100E+9
+dqbas307 toSci 10e9 -> 1.0E+10
+dqbas308 toEng 10e9 -> 10E+9
+dqbas309 toSci 10e8 -> 1.0E+9
+dqbas310 toEng 10e8 -> 1.0E+9
+dqbas311 toSci 10e7 -> 1.0E+8
+dqbas312 toEng 10e7 -> 100E+6
+dqbas313 toSci 10e6 -> 1.0E+7
+dqbas314 toEng 10e6 -> 10E+6
+dqbas315 toSci 10e5 -> 1.0E+6
+dqbas316 toEng 10e5 -> 1.0E+6
+dqbas317 toSci 10e4 -> 1.0E+5
+dqbas318 toEng 10e4 -> 100E+3
+dqbas319 toSci 10e3 -> 1.0E+4
+dqbas320 toEng 10e3 -> 10E+3
+dqbas321 toSci 10e2 -> 1.0E+3
+dqbas322 toEng 10e2 -> 1.0E+3
+dqbas323 toSci 10e1 -> 1.0E+2
+dqbas324 toEng 10e1 -> 100
+dqbas325 toSci 10e0 -> 10
+dqbas326 toEng 10e0 -> 10
+dqbas327 toSci 10e-1 -> 1.0
+dqbas328 toEng 10e-1 -> 1.0
+dqbas329 toSci 10e-2 -> 0.10
+dqbas330 toEng 10e-2 -> 0.10
+dqbas331 toSci 10e-3 -> 0.010
+dqbas332 toEng 10e-3 -> 0.010
+dqbas333 toSci 10e-4 -> 0.0010
+dqbas334 toEng 10e-4 -> 0.0010
+dqbas335 toSci 10e-5 -> 0.00010
+dqbas336 toEng 10e-5 -> 0.00010
+dqbas337 toSci 10e-6 -> 0.000010
+dqbas338 toEng 10e-6 -> 0.000010
+dqbas339 toSci 10e-7 -> 0.0000010
+dqbas340 toEng 10e-7 -> 0.0000010
+dqbas341 toSci 10e-8 -> 1.0E-7
+dqbas342 toEng 10e-8 -> 100E-9
+dqbas343 toSci 10e-9 -> 1.0E-8
+dqbas344 toEng 10e-9 -> 10E-9
+dqbas345 toSci 10e-10 -> 1.0E-9
+dqbas346 toEng 10e-10 -> 1.0E-9
+dqbas347 toSci 10e-11 -> 1.0E-10
+dqbas348 toEng 10e-11 -> 100E-12
+dqbas349 toSci 10e-12 -> 1.0E-11
+dqbas350 toEng 10e-12 -> 10E-12
+dqbas351 toSci 10e-13 -> 1.0E-12
+dqbas352 toEng 10e-13 -> 1.0E-12
+
+dqbas361 toSci 7E12 -> 7E+12
+dqbas362 toEng 7E12 -> 7E+12
+dqbas363 toSci 7E11 -> 7E+11
+dqbas364 toEng 7E11 -> 700E+9
+dqbas365 toSci 7E10 -> 7E+10
+dqbas366 toEng 7E10 -> 70E+9
+dqbas367 toSci 7E9 -> 7E+9
+dqbas368 toEng 7E9 -> 7E+9
+dqbas369 toSci 7E8 -> 7E+8
+dqbas370 toEng 7E8 -> 700E+6
+dqbas371 toSci 7E7 -> 7E+7
+dqbas372 toEng 7E7 -> 70E+6
+dqbas373 toSci 7E6 -> 7E+6
+dqbas374 toEng 7E6 -> 7E+6
+dqbas375 toSci 7E5 -> 7E+5
+dqbas376 toEng 7E5 -> 700E+3
+dqbas377 toSci 7E4 -> 7E+4
+dqbas378 toEng 7E4 -> 70E+3
+dqbas379 toSci 7E3 -> 7E+3
+dqbas380 toEng 7E3 -> 7E+3
+dqbas381 toSci 7E2 -> 7E+2
+dqbas382 toEng 7E2 -> 700
+dqbas383 toSci 7E1 -> 7E+1
+dqbas384 toEng 7E1 -> 70
+dqbas385 toSci 7E0 -> 7
+dqbas386 toEng 7E0 -> 7
+dqbas387 toSci 7E-1 -> 0.7
+dqbas388 toEng 7E-1 -> 0.7
+dqbas389 toSci 7E-2 -> 0.07
+dqbas390 toEng 7E-2 -> 0.07
+dqbas391 toSci 7E-3 -> 0.007
+dqbas392 toEng 7E-3 -> 0.007
+dqbas393 toSci 7E-4 -> 0.0007
+dqbas394 toEng 7E-4 -> 0.0007
+dqbas395 toSci 7E-5 -> 0.00007
+dqbas396 toEng 7E-5 -> 0.00007
+dqbas397 toSci 7E-6 -> 0.000007
+dqbas398 toEng 7E-6 -> 0.000007
+dqbas399 toSci 7E-7 -> 7E-7
+dqbas400 toEng 7E-7 -> 700E-9
+dqbas401 toSci 7E-8 -> 7E-8
+dqbas402 toEng 7E-8 -> 70E-9
+dqbas403 toSci 7E-9 -> 7E-9
+dqbas404 toEng 7E-9 -> 7E-9
+dqbas405 toSci 7E-10 -> 7E-10
+dqbas406 toEng 7E-10 -> 700E-12
+dqbas407 toSci 7E-11 -> 7E-11
+dqbas408 toEng 7E-11 -> 70E-12
+dqbas409 toSci 7E-12 -> 7E-12
+dqbas410 toEng 7E-12 -> 7E-12
+dqbas411 toSci 7E-13 -> 7E-13
+dqbas412 toEng 7E-13 -> 700E-15
+
+-- Exacts remain exact up to precision ..
+dqbas420 toSci 100 -> 100
+dqbas422 toSci 1000 -> 1000
+dqbas424 toSci 999.9 -> 999.9
+dqbas426 toSci 1000.0 -> 1000.0
+dqbas428 toSci 1000.1 -> 1000.1
+dqbas430 toSci 10000 -> 10000
+dqbas432 toSci 1000000000000000000000000000000 -> 1000000000000000000000000000000
+dqbas434 toSci 10000000000000000000000000000000 -> 10000000000000000000000000000000
+dqbas436 toSci 100000000000000000000000000000000 -> 100000000000000000000000000000000
+dqbas438 toSci 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqbas440 toSci 10000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+34 Rounded
+dqbas442 toSci 10000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+34 Rounded
+dqbas444 toSci 10000000000000000000000000000000003 -> 1.000000000000000000000000000000000E+34 Rounded Inexact
+dqbas446 toSci 10000000000000000000000000000000005 -> 1.000000000000000000000000000000000E+34 Rounded Inexact
+dqbas448 toSci 100000000000000000000000000000000050 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
+dqbas450 toSci 10000000000000000000000000000000009 -> 1.000000000000000000000000000000001E+34 Rounded Inexact
+dqbas452 toSci 100000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+35 Rounded
+dqbas454 toSci 100000000000000000000000000000000003 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
+dqbas456 toSci 100000000000000000000000000000000005 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
+dqbas458 toSci 100000000000000000000000000000000009 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
+dqbas460 toSci 1000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+36 Rounded
+dqbas462 toSci 1000000000000000000000000000000000300 -> 1.000000000000000000000000000000000E+36 Rounded Inexact
+dqbas464 toSci 1000000000000000000000000000000000500 -> 1.000000000000000000000000000000000E+36 Rounded Inexact
+dqbas466 toSci 1000000000000000000000000000000000900 -> 1.000000000000000000000000000000001E+36 Rounded Inexact
+dqbas468 toSci 10000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+37 Rounded
+dqbas470 toSci 10000000000000000000000000000000003000 -> 1.000000000000000000000000000000000E+37 Rounded Inexact
+dqbas472 toSci 10000000000000000000000000000000005000 -> 1.000000000000000000000000000000000E+37 Rounded Inexact
+dqbas474 toSci 10000000000000000000000000000000009000 -> 1.000000000000000000000000000000001E+37 Rounded Inexact
+
+-- check rounding modes heeded
+rounding: ceiling
+dqbsr401 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr402 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr403 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr404 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+rounding: up
+dqbsr405 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr406 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr407 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr408 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+rounding: floor
+dqbsr410 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr411 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr412 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr413 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112345 Rounded Inexact
+rounding: half_down
+dqbsr415 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr416 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr417 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr418 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr419 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+rounding: half_even
+dqbsr421 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr422 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr423 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr424 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr425 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+rounding: down
+dqbsr426 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr427 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr428 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr429 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112345 Rounded Inexact
+rounding: half_up
+dqbsr431 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr432 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr433 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr434 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112347 Rounded Inexact
+dqbsr435 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+-- negatives
+rounding: ceiling
+dqbsr501 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr502 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr503 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr504 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112345 Rounded Inexact
+rounding: up
+dqbsr505 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr506 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr507 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr508 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+rounding: floor
+dqbsr510 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr511 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr512 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr513 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+rounding: half_down
+dqbsr515 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr516 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr517 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr518 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr519 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+rounding: half_even
+dqbsr521 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr522 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr523 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr524 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr525 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+rounding: down
+dqbsr526 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr527 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr528 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr529 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112345 Rounded Inexact
+rounding: half_up
+dqbsr531 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr532 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr533 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr534 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112347 Rounded Inexact
+dqbsr535 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+
+rounding: half_even
+
+-- The 'baddies' tests from DiagBigDecimal, plus some new ones
+dqbas500 toSci '1..2' -> NaN Conversion_syntax
+dqbas501 toSci '.' -> NaN Conversion_syntax
+dqbas502 toSci '..' -> NaN Conversion_syntax
+dqbas503 toSci '++1' -> NaN Conversion_syntax
+dqbas504 toSci '--1' -> NaN Conversion_syntax
+dqbas505 toSci '-+1' -> NaN Conversion_syntax
+dqbas506 toSci '+-1' -> NaN Conversion_syntax
+dqbas507 toSci '12e' -> NaN Conversion_syntax
+dqbas508 toSci '12e++' -> NaN Conversion_syntax
+dqbas509 toSci '12f4' -> NaN Conversion_syntax
+dqbas510 toSci ' +1' -> NaN Conversion_syntax
+dqbas511 toSci '+ 1' -> NaN Conversion_syntax
+dqbas512 toSci '12 ' -> NaN Conversion_syntax
+dqbas513 toSci ' + 1' -> NaN Conversion_syntax
+dqbas514 toSci ' - 1 ' -> NaN Conversion_syntax
+dqbas515 toSci 'x' -> NaN Conversion_syntax
+dqbas516 toSci '-1-' -> NaN Conversion_syntax
+dqbas517 toSci '12-' -> NaN Conversion_syntax
+dqbas518 toSci '3+' -> NaN Conversion_syntax
+dqbas519 toSci '' -> NaN Conversion_syntax
+dqbas520 toSci '1e-' -> NaN Conversion_syntax
+dqbas521 toSci '7e99999a' -> NaN Conversion_syntax
+dqbas522 toSci '7e123567890x' -> NaN Conversion_syntax
+dqbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
+dqbas524 toSci '' -> NaN Conversion_syntax
+dqbas525 toSci 'e100' -> NaN Conversion_syntax
+dqbas526 toSci '\u0e5a' -> NaN Conversion_syntax
+dqbas527 toSci '\u0b65' -> NaN Conversion_syntax
+dqbas528 toSci '123,65' -> NaN Conversion_syntax
+dqbas529 toSci '1.34.5' -> NaN Conversion_syntax
+dqbas530 toSci '.123.5' -> NaN Conversion_syntax
+dqbas531 toSci '01.35.' -> NaN Conversion_syntax
+dqbas532 toSci '01.35-' -> NaN Conversion_syntax
+dqbas533 toSci '0000..' -> NaN Conversion_syntax
+dqbas534 toSci '.0000.' -> NaN Conversion_syntax
+dqbas535 toSci '00..00' -> NaN Conversion_syntax
+dqbas536 toSci '111e*123' -> NaN Conversion_syntax
+dqbas537 toSci '111e123-' -> NaN Conversion_syntax
+dqbas538 toSci '111e+12+' -> NaN Conversion_syntax
+dqbas539 toSci '111e1-3-' -> NaN Conversion_syntax
+dqbas540 toSci '111e1*23' -> NaN Conversion_syntax
+dqbas541 toSci '111e1e+3' -> NaN Conversion_syntax
+dqbas542 toSci '1e1.0' -> NaN Conversion_syntax
+dqbas543 toSci '1e123e' -> NaN Conversion_syntax
+dqbas544 toSci 'ten' -> NaN Conversion_syntax
+dqbas545 toSci 'ONE' -> NaN Conversion_syntax
+dqbas546 toSci '1e.1' -> NaN Conversion_syntax
+dqbas547 toSci '1e1.' -> NaN Conversion_syntax
+dqbas548 toSci '1ee' -> NaN Conversion_syntax
+dqbas549 toSci 'e+1' -> NaN Conversion_syntax
+dqbas550 toSci '1.23.4' -> NaN Conversion_syntax
+dqbas551 toSci '1.2.1' -> NaN Conversion_syntax
+dqbas552 toSci '1E+1.2' -> NaN Conversion_syntax
+dqbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
+dqbas554 toSci '1E++1' -> NaN Conversion_syntax
+dqbas555 toSci '1E--1' -> NaN Conversion_syntax
+dqbas556 toSci '1E+-1' -> NaN Conversion_syntax
+dqbas557 toSci '1E-+1' -> NaN Conversion_syntax
+dqbas558 toSci '1E''1' -> NaN Conversion_syntax
+dqbas559 toSci "1E""1" -> NaN Conversion_syntax
+dqbas560 toSci "1E""""" -> NaN Conversion_syntax
+-- Near-specials
+dqbas561 toSci "qNaN" -> NaN Conversion_syntax
+dqbas562 toSci "NaNq" -> NaN Conversion_syntax
+dqbas563 toSci "NaNs" -> NaN Conversion_syntax
+dqbas564 toSci "Infi" -> NaN Conversion_syntax
+dqbas565 toSci "Infin" -> NaN Conversion_syntax
+dqbas566 toSci "Infini" -> NaN Conversion_syntax
+dqbas567 toSci "Infinit" -> NaN Conversion_syntax
+dqbas568 toSci "-Infinit" -> NaN Conversion_syntax
+dqbas569 toSci "0Inf" -> NaN Conversion_syntax
+dqbas570 toSci "9Inf" -> NaN Conversion_syntax
+dqbas571 toSci "-0Inf" -> NaN Conversion_syntax
+dqbas572 toSci "-9Inf" -> NaN Conversion_syntax
+dqbas573 toSci "-sNa" -> NaN Conversion_syntax
+dqbas574 toSci "xNaN" -> NaN Conversion_syntax
+dqbas575 toSci "0sNaN" -> NaN Conversion_syntax
+
+-- some baddies with dots and Es and dots and specials
+dqbas576 toSci 'e+1' -> NaN Conversion_syntax
+dqbas577 toSci '.e+1' -> NaN Conversion_syntax
+dqbas578 toSci '+.e+1' -> NaN Conversion_syntax
+dqbas579 toSci '-.e+' -> NaN Conversion_syntax
+dqbas580 toSci '-.e' -> NaN Conversion_syntax
+dqbas581 toSci 'E+1' -> NaN Conversion_syntax
+dqbas582 toSci '.E+1' -> NaN Conversion_syntax
+dqbas583 toSci '+.E+1' -> NaN Conversion_syntax
+dqbas584 toSci '-.E+' -> NaN Conversion_syntax
+dqbas585 toSci '-.E' -> NaN Conversion_syntax
+
+dqbas586 toSci '.NaN' -> NaN Conversion_syntax
+dqbas587 toSci '-.NaN' -> NaN Conversion_syntax
+dqbas588 toSci '+.sNaN' -> NaN Conversion_syntax
+dqbas589 toSci '+.Inf' -> NaN Conversion_syntax
+dqbas590 toSci '.Infinity' -> NaN Conversion_syntax
+
+-- Zeros
+dqbas601 toSci 0.000000000 -> 0E-9
+dqbas602 toSci 0.00000000 -> 0E-8
+dqbas603 toSci 0.0000000 -> 0E-7
+dqbas604 toSci 0.000000 -> 0.000000
+dqbas605 toSci 0.00000 -> 0.00000
+dqbas606 toSci 0.0000 -> 0.0000
+dqbas607 toSci 0.000 -> 0.000
+dqbas608 toSci 0.00 -> 0.00
+dqbas609 toSci 0.0 -> 0.0
+dqbas610 toSci .0 -> 0.0
+dqbas611 toSci 0. -> 0
+dqbas612 toSci -.0 -> -0.0
+dqbas613 toSci -0. -> -0
+dqbas614 toSci -0.0 -> -0.0
+dqbas615 toSci -0.00 -> -0.00
+dqbas616 toSci -0.000 -> -0.000
+dqbas617 toSci -0.0000 -> -0.0000
+dqbas618 toSci -0.00000 -> -0.00000
+dqbas619 toSci -0.000000 -> -0.000000
+dqbas620 toSci -0.0000000 -> -0E-7
+dqbas621 toSci -0.00000000 -> -0E-8
+dqbas622 toSci -0.000000000 -> -0E-9
+
+dqbas630 toSci 0.00E+0 -> 0.00
+dqbas631 toSci 0.00E+1 -> 0.0
+dqbas632 toSci 0.00E+2 -> 0
+dqbas633 toSci 0.00E+3 -> 0E+1
+dqbas634 toSci 0.00E+4 -> 0E+2
+dqbas635 toSci 0.00E+5 -> 0E+3
+dqbas636 toSci 0.00E+6 -> 0E+4
+dqbas637 toSci 0.00E+7 -> 0E+5
+dqbas638 toSci 0.00E+8 -> 0E+6
+dqbas639 toSci 0.00E+9 -> 0E+7
+
+dqbas640 toSci 0.0E+0 -> 0.0
+dqbas641 toSci 0.0E+1 -> 0
+dqbas642 toSci 0.0E+2 -> 0E+1
+dqbas643 toSci 0.0E+3 -> 0E+2
+dqbas644 toSci 0.0E+4 -> 0E+3
+dqbas645 toSci 0.0E+5 -> 0E+4
+dqbas646 toSci 0.0E+6 -> 0E+5
+dqbas647 toSci 0.0E+7 -> 0E+6
+dqbas648 toSci 0.0E+8 -> 0E+7
+dqbas649 toSci 0.0E+9 -> 0E+8
+
+dqbas650 toSci 0E+0 -> 0
+dqbas651 toSci 0E+1 -> 0E+1
+dqbas652 toSci 0E+2 -> 0E+2
+dqbas653 toSci 0E+3 -> 0E+3
+dqbas654 toSci 0E+4 -> 0E+4
+dqbas655 toSci 0E+5 -> 0E+5
+dqbas656 toSci 0E+6 -> 0E+6
+dqbas657 toSci 0E+7 -> 0E+7
+dqbas658 toSci 0E+8 -> 0E+8
+dqbas659 toSci 0E+9 -> 0E+9
+
+dqbas660 toSci 0.0E-0 -> 0.0
+dqbas661 toSci 0.0E-1 -> 0.00
+dqbas662 toSci 0.0E-2 -> 0.000
+dqbas663 toSci 0.0E-3 -> 0.0000
+dqbas664 toSci 0.0E-4 -> 0.00000
+dqbas665 toSci 0.0E-5 -> 0.000000
+dqbas666 toSci 0.0E-6 -> 0E-7
+dqbas667 toSci 0.0E-7 -> 0E-8
+dqbas668 toSci 0.0E-8 -> 0E-9
+dqbas669 toSci 0.0E-9 -> 0E-10
+
+dqbas670 toSci 0.00E-0 -> 0.00
+dqbas671 toSci 0.00E-1 -> 0.000
+dqbas672 toSci 0.00E-2 -> 0.0000
+dqbas673 toSci 0.00E-3 -> 0.00000
+dqbas674 toSci 0.00E-4 -> 0.000000
+dqbas675 toSci 0.00E-5 -> 0E-7
+dqbas676 toSci 0.00E-6 -> 0E-8
+dqbas677 toSci 0.00E-7 -> 0E-9
+dqbas678 toSci 0.00E-8 -> 0E-10
+dqbas679 toSci 0.00E-9 -> 0E-11
+
+dqbas680 toSci 000000. -> 0
+dqbas681 toSci 00000. -> 0
+dqbas682 toSci 0000. -> 0
+dqbas683 toSci 000. -> 0
+dqbas684 toSci 00. -> 0
+dqbas685 toSci 0. -> 0
+dqbas686 toSci +00000. -> 0
+dqbas687 toSci -00000. -> -0
+dqbas688 toSci +0. -> 0
+dqbas689 toSci -0. -> -0
+
+-- Specials
+dqbas700 toSci "NaN" -> NaN
+dqbas701 toSci "nan" -> NaN
+dqbas702 toSci "nAn" -> NaN
+dqbas703 toSci "NAN" -> NaN
+dqbas704 toSci "+NaN" -> NaN
+dqbas705 toSci "+nan" -> NaN
+dqbas706 toSci "+nAn" -> NaN
+dqbas707 toSci "+NAN" -> NaN
+dqbas708 toSci "-NaN" -> -NaN
+dqbas709 toSci "-nan" -> -NaN
+dqbas710 toSci "-nAn" -> -NaN
+dqbas711 toSci "-NAN" -> -NaN
+dqbas712 toSci 'NaN0' -> NaN
+dqbas713 toSci 'NaN1' -> NaN1
+dqbas714 toSci 'NaN12' -> NaN12
+dqbas715 toSci 'NaN123' -> NaN123
+dqbas716 toSci 'NaN1234' -> NaN1234
+dqbas717 toSci 'NaN01' -> NaN1
+dqbas718 toSci 'NaN012' -> NaN12
+dqbas719 toSci 'NaN0123' -> NaN123
+dqbas720 toSci 'NaN01234' -> NaN1234
+dqbas721 toSci 'NaN001' -> NaN1
+dqbas722 toSci 'NaN0012' -> NaN12
+dqbas723 toSci 'NaN00123' -> NaN123
+dqbas724 toSci 'NaN001234' -> NaN1234
+dqbas725 toSci 'NaN1234567890123456781234567890123456' -> NaN Conversion_syntax
+dqbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
+dqbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
+dqbas728 toSci 'NaN-12' -> NaN Conversion_syntax
+dqbas729 toSci 'NaN+12' -> NaN Conversion_syntax
+
+dqbas730 toSci "sNaN" -> sNaN
+dqbas731 toSci "snan" -> sNaN
+dqbas732 toSci "SnAn" -> sNaN
+dqbas733 toSci "SNAN" -> sNaN
+dqbas734 toSci "+sNaN" -> sNaN
+dqbas735 toSci "+snan" -> sNaN
+dqbas736 toSci "+SnAn" -> sNaN
+dqbas737 toSci "+SNAN" -> sNaN
+dqbas738 toSci "-sNaN" -> -sNaN
+dqbas739 toSci "-snan" -> -sNaN
+dqbas740 toSci "-SnAn" -> -sNaN
+dqbas741 toSci "-SNAN" -> -sNaN
+dqbas742 toSci 'sNaN0000' -> sNaN
+dqbas743 toSci 'sNaN7' -> sNaN7
+dqbas744 toSci 'sNaN007234' -> sNaN7234
+dqbas745 toSci 'sNaN1234567890123456787234561234567890' -> NaN Conversion_syntax
+dqbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
+dqbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
+
+dqbas748 toSci "Inf" -> Infinity
+dqbas749 toSci "inf" -> Infinity
+dqbas750 toSci "iNf" -> Infinity
+dqbas751 toSci "INF" -> Infinity
+dqbas752 toSci "+Inf" -> Infinity
+dqbas753 toSci "+inf" -> Infinity
+dqbas754 toSci "+iNf" -> Infinity
+dqbas755 toSci "+INF" -> Infinity
+dqbas756 toSci "-Inf" -> -Infinity
+dqbas757 toSci "-inf" -> -Infinity
+dqbas758 toSci "-iNf" -> -Infinity
+dqbas759 toSci "-INF" -> -Infinity
+
+dqbas760 toSci "Infinity" -> Infinity
+dqbas761 toSci "infinity" -> Infinity
+dqbas762 toSci "iNfInItY" -> Infinity
+dqbas763 toSci "INFINITY" -> Infinity
+dqbas764 toSci "+Infinity" -> Infinity
+dqbas765 toSci "+infinity" -> Infinity
+dqbas766 toSci "+iNfInItY" -> Infinity
+dqbas767 toSci "+INFINITY" -> Infinity
+dqbas768 toSci "-Infinity" -> -Infinity
+dqbas769 toSci "-infinity" -> -Infinity
+dqbas770 toSci "-iNfInItY" -> -Infinity
+dqbas771 toSci "-INFINITY" -> -Infinity
+
+-- Specials and zeros for toEng
+dqbast772 toEng "NaN" -> NaN
+dqbast773 toEng "-Infinity" -> -Infinity
+dqbast774 toEng "-sNaN" -> -sNaN
+dqbast775 toEng "-NaN" -> -NaN
+dqbast776 toEng "+Infinity" -> Infinity
+dqbast778 toEng "+sNaN" -> sNaN
+dqbast779 toEng "+NaN" -> NaN
+dqbast780 toEng "INFINITY" -> Infinity
+dqbast781 toEng "SNAN" -> sNaN
+dqbast782 toEng "NAN" -> NaN
+dqbast783 toEng "infinity" -> Infinity
+dqbast784 toEng "snan" -> sNaN
+dqbast785 toEng "nan" -> NaN
+dqbast786 toEng "InFINITY" -> Infinity
+dqbast787 toEng "SnAN" -> sNaN
+dqbast788 toEng "nAN" -> NaN
+dqbast789 toEng "iNfinity" -> Infinity
+dqbast790 toEng "sNan" -> sNaN
+dqbast791 toEng "Nan" -> NaN
+dqbast792 toEng "Infinity" -> Infinity
+dqbast793 toEng "sNaN" -> sNaN
+
+-- Zero toEng, etc.
+dqbast800 toEng 0e+1 -> "0.00E+3" -- doc example
+
+dqbast801 toEng 0.000000000 -> 0E-9
+dqbast802 toEng 0.00000000 -> 0.00E-6
+dqbast803 toEng 0.0000000 -> 0.0E-6
+dqbast804 toEng 0.000000 -> 0.000000
+dqbast805 toEng 0.00000 -> 0.00000
+dqbast806 toEng 0.0000 -> 0.0000
+dqbast807 toEng 0.000 -> 0.000
+dqbast808 toEng 0.00 -> 0.00
+dqbast809 toEng 0.0 -> 0.0
+dqbast810 toEng .0 -> 0.0
+dqbast811 toEng 0. -> 0
+dqbast812 toEng -.0 -> -0.0
+dqbast813 toEng -0. -> -0
+dqbast814 toEng -0.0 -> -0.0
+dqbast815 toEng -0.00 -> -0.00
+dqbast816 toEng -0.000 -> -0.000
+dqbast817 toEng -0.0000 -> -0.0000
+dqbast818 toEng -0.00000 -> -0.00000
+dqbast819 toEng -0.000000 -> -0.000000
+dqbast820 toEng -0.0000000 -> -0.0E-6
+dqbast821 toEng -0.00000000 -> -0.00E-6
+dqbast822 toEng -0.000000000 -> -0E-9
+
+dqbast830 toEng 0.00E+0 -> 0.00
+dqbast831 toEng 0.00E+1 -> 0.0
+dqbast832 toEng 0.00E+2 -> 0
+dqbast833 toEng 0.00E+3 -> 0.00E+3
+dqbast834 toEng 0.00E+4 -> 0.0E+3
+dqbast835 toEng 0.00E+5 -> 0E+3
+dqbast836 toEng 0.00E+6 -> 0.00E+6
+dqbast837 toEng 0.00E+7 -> 0.0E+6
+dqbast838 toEng 0.00E+8 -> 0E+6
+dqbast839 toEng 0.00E+9 -> 0.00E+9
+
+dqbast840 toEng 0.0E+0 -> 0.0
+dqbast841 toEng 0.0E+1 -> 0
+dqbast842 toEng 0.0E+2 -> 0.00E+3
+dqbast843 toEng 0.0E+3 -> 0.0E+3
+dqbast844 toEng 0.0E+4 -> 0E+3
+dqbast845 toEng 0.0E+5 -> 0.00E+6
+dqbast846 toEng 0.0E+6 -> 0.0E+6
+dqbast847 toEng 0.0E+7 -> 0E+6
+dqbast848 toEng 0.0E+8 -> 0.00E+9
+dqbast849 toEng 0.0E+9 -> 0.0E+9
+
+dqbast850 toEng 0E+0 -> 0
+dqbast851 toEng 0E+1 -> 0.00E+3
+dqbast852 toEng 0E+2 -> 0.0E+3
+dqbast853 toEng 0E+3 -> 0E+3
+dqbast854 toEng 0E+4 -> 0.00E+6
+dqbast855 toEng 0E+5 -> 0.0E+6
+dqbast856 toEng 0E+6 -> 0E+6
+dqbast857 toEng 0E+7 -> 0.00E+9
+dqbast858 toEng 0E+8 -> 0.0E+9
+dqbast859 toEng 0E+9 -> 0E+9
+
+dqbast860 toEng 0.0E-0 -> 0.0
+dqbast861 toEng 0.0E-1 -> 0.00
+dqbast862 toEng 0.0E-2 -> 0.000
+dqbast863 toEng 0.0E-3 -> 0.0000
+dqbast864 toEng 0.0E-4 -> 0.00000
+dqbast865 toEng 0.0E-5 -> 0.000000
+dqbast866 toEng 0.0E-6 -> 0.0E-6
+dqbast867 toEng 0.0E-7 -> 0.00E-6
+dqbast868 toEng 0.0E-8 -> 0E-9
+dqbast869 toEng 0.0E-9 -> 0.0E-9
+
+dqbast870 toEng 0.00E-0 -> 0.00
+dqbast871 toEng 0.00E-1 -> 0.000
+dqbast872 toEng 0.00E-2 -> 0.0000
+dqbast873 toEng 0.00E-3 -> 0.00000
+dqbast874 toEng 0.00E-4 -> 0.000000
+dqbast875 toEng 0.00E-5 -> 0.0E-6
+dqbast876 toEng 0.00E-6 -> 0.00E-6
+dqbast877 toEng 0.00E-7 -> 0E-9
+dqbast878 toEng 0.00E-8 -> 0.0E-9
+dqbast879 toEng 0.00E-9 -> 0.00E-9
+
+-- long input strings
+dqbas801 tosci '01234567890123456' -> 1234567890123456
+dqbas802 tosci '001234567890123456' -> 1234567890123456
+dqbas803 tosci '0001234567890123456' -> 1234567890123456
+dqbas804 tosci '00001234567890123456' -> 1234567890123456
+dqbas805 tosci '000001234567890123456' -> 1234567890123456
+dqbas806 tosci '0000001234567890123456' -> 1234567890123456
+dqbas807 tosci '00000001234567890123456' -> 1234567890123456
+dqbas808 tosci '000000001234567890123456' -> 1234567890123456
+dqbas809 tosci '0000000001234567890123456' -> 1234567890123456
+dqbas810 tosci '00000000001234567890123456' -> 1234567890123456
+
+dqbas811 tosci '0.1234567890123456' -> 0.1234567890123456
+dqbas812 tosci '0.01234567890123456' -> 0.01234567890123456
+dqbas813 tosci '0.001234567890123456' -> 0.001234567890123456
+dqbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
+dqbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
+dqbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
+dqbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
+dqbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
+dqbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
+dqbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10
+
+dqbas821 tosci '12345678912345678901234567801234567890' -> 1.234567891234567890123456780123457E+37 Inexact Rounded
+dqbas822 tosci '123456789123456789012345678012345678901' -> 1.234567891234567890123456780123457E+38 Inexact Rounded
+dqbas823 tosci '1234567891234567890123456780123456789012' -> 1.234567891234567890123456780123457E+39 Inexact Rounded
+dqbas824 tosci '12345678912345678901234567801234567890123' -> 1.234567891234567890123456780123457E+40 Inexact Rounded
+dqbas825 tosci '123456789123456789012345678012345678901234' -> 1.234567891234567890123456780123457E+41 Inexact Rounded
+dqbas826 tosci '1234567891234567890123456780123456789012345' -> 1.234567891234567890123456780123457E+42 Inexact Rounded
+dqbas827 tosci '12345678912345678901234567801234567890123456' -> 1.234567891234567890123456780123457E+43 Inexact Rounded
+dqbas828 tosci '123456789123456789012345678012345678901234567' -> 1.234567891234567890123456780123457E+44 Inexact Rounded
+dqbas829 tosci '1234567891234567890123456780123456789012345678' -> 1.234567891234567890123456780123457E+45 Inexact Rounded
+
+-- subnormals and overflows
+dqbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
+dqbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
+dqbas908 toSci '0.9e-999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas909 toSci '0.09e-999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
+dqbas911 toSci '10e-1000000000' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
+dqbas913 toSci '99e-9999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
+dqbas915 toSci '1111e-9999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas916 toSci '1111e-99999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
+-- negatives the same
+dqbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
+dqbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
+dqbas920 toSci '-0.9e-999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas921 toSci '-0.09e-999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
+dqbas923 toSci '-10e-1000000000' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
+dqbas925 toSci '-99e-9999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
+dqbas927 toSci '-1111e-9999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas928 toSci '-1111e-99999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
+
+-- overflow results at different rounding modes
+rounding: ceiling
+dqbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas931 toSci '-7e10000' -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+rounding: up
+dqbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: down
+dqbas934 toSci '7e10000' -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqbas935 toSci '-7e10000' -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+rounding: floor
+dqbas936 toSci '7e10000' -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_up
+dqbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_even
+dqbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_down
+dqbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_even
+
+-- Now check 854/754r some subnormals and underflow to 0
+dqbem400 toSci 1.0000E-383 -> 1.0000E-383
+dqbem401 toSci 0.1E-6172 -> 1E-6173 Subnormal
+dqbem402 toSci 0.1000E-6172 -> 1.000E-6173 Subnormal
+dqbem403 toSci 0.0100E-6172 -> 1.00E-6174 Subnormal
+dqbem404 toSci 0.0010E-6172 -> 1.0E-6175 Subnormal
+dqbem405 toSci 0.0001E-6172 -> 1E-6176 Subnormal
+dqbem406 toSci 0.00010E-6172 -> 1E-6176 Subnormal Rounded
+dqbem407 toSci 0.00013E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqbem408 toSci 0.00015E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem409 toSci 0.00017E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem410 toSci 0.00023E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem411 toSci 0.00025E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem412 toSci 0.00027E-6172 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqbem413 toSci 0.000149E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqbem414 toSci 0.000150E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem415 toSci 0.000151E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem416 toSci 0.000249E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem417 toSci 0.000250E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem418 toSci 0.000251E-6172 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqbem419 toSci 0.00009E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqbem420 toSci 0.00005E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem421 toSci 0.00003E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem422 toSci 0.000009E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem423 toSci 0.000005E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem424 toSci 0.000003E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqbem425 toSci 0.001049E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
+dqbem426 toSci 0.001050E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
+dqbem427 toSci 0.001051E-6172 -> 1.1E-6175 Underflow Subnormal Inexact Rounded
+dqbem428 toSci 0.001149E-6172 -> 1.1E-6175 Underflow Subnormal Inexact Rounded
+dqbem429 toSci 0.001150E-6172 -> 1.2E-6175 Underflow Subnormal Inexact Rounded
+dqbem430 toSci 0.001151E-6172 -> 1.2E-6175 Underflow Subnormal Inexact Rounded
+
+dqbem432 toSci 0.010049E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
+dqbem433 toSci 0.010050E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
+dqbem434 toSci 0.010051E-6172 -> 1.01E-6174 Underflow Subnormal Inexact Rounded
+dqbem435 toSci 0.010149E-6172 -> 1.01E-6174 Underflow Subnormal Inexact Rounded
+dqbem436 toSci 0.010150E-6172 -> 1.02E-6174 Underflow Subnormal Inexact Rounded
+dqbem437 toSci 0.010151E-6172 -> 1.02E-6174 Underflow Subnormal Inexact Rounded
+
+dqbem440 toSci 0.10103E-6172 -> 1.010E-6173 Underflow Subnormal Inexact Rounded
+dqbem441 toSci 0.10105E-6172 -> 1.010E-6173 Underflow Subnormal Inexact Rounded
+dqbem442 toSci 0.10107E-6172 -> 1.011E-6173 Underflow Subnormal Inexact Rounded
+dqbem443 toSci 0.10113E-6172 -> 1.011E-6173 Underflow Subnormal Inexact Rounded
+dqbem444 toSci 0.10115E-6172 -> 1.012E-6173 Underflow Subnormal Inexact Rounded
+dqbem445 toSci 0.10117E-6172 -> 1.012E-6173 Underflow Subnormal Inexact Rounded
+
+dqbem450 toSci 1.10730E-6173 -> 1.107E-6173 Underflow Subnormal Inexact Rounded
+dqbem451 toSci 1.10750E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
+dqbem452 toSci 1.10770E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
+dqbem453 toSci 1.10830E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
+dqbem454 toSci 1.10850E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
+dqbem455 toSci 1.10870E-6173 -> 1.109E-6173 Underflow Subnormal Inexact Rounded
+
+-- make sure sign OK
+dqbem456 toSci -0.10103E-6172 -> -1.010E-6173 Underflow Subnormal Inexact Rounded
+dqbem457 toSci -0.10105E-6172 -> -1.010E-6173 Underflow Subnormal Inexact Rounded
+dqbem458 toSci -0.10107E-6172 -> -1.011E-6173 Underflow Subnormal Inexact Rounded
+dqbem459 toSci -0.10113E-6172 -> -1.011E-6173 Underflow Subnormal Inexact Rounded
+dqbem460 toSci -0.10115E-6172 -> -1.012E-6173 Underflow Subnormal Inexact Rounded
+dqbem461 toSci -0.10117E-6172 -> -1.012E-6173 Underflow Subnormal Inexact Rounded
+
+-- '999s' cases
+dqbem464 toSci 999999E-6173 -> 9.99999E-6168 Subnormal
+dqbem465 toSci 99999.0E-6172 -> 9.99990E-6168 Subnormal
+dqbem466 toSci 99999.E-6172 -> 9.9999E-6168 Subnormal
+dqbem467 toSci 9999.9E-6172 -> 9.9999E-6169 Subnormal
+dqbem468 toSci 999.99E-6172 -> 9.9999E-6170 Subnormal
+dqbem469 toSci 99.999E-6172 -> 9.9999E-6171 Subnormal
+dqbem470 toSci 9.9999E-6172 -> 9.9999E-6172 Subnormal
+dqbem471 toSci 0.99999E-6172 -> 1.0000E-6172 Underflow Subnormal Inexact Rounded
+dqbem472 toSci 0.099999E-6172 -> 1.000E-6173 Underflow Subnormal Inexact Rounded
+dqbem473 toSci 0.0099999E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
+dqbem474 toSci 0.00099999E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
+dqbem475 toSci 0.000099999E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqbem476 toSci 0.0000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem477 toSci 0.00000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem478 toSci 0.000000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- Exponents with insignificant leading zeros
+dqbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
+dqbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
+dqbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
+dqbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
+dqbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
+dqbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
+dqbas1007 toSci 1e-999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1008 toSci 1e-0999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1009 toSci 1e-00999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1010 toSci 1e-000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1011 toSci 1e-000000000000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1012 toSci 1e-000000000001000000007 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- check for double-rounded subnormals
+dqbas1041 toSci 1.1111111111111111111111111111152444E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
+dqbas1042 toSci 1.1111111111111111111111111111152445E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
+dqbas1043 toSci 1.1111111111111111111111111111152446E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
+
+-- clamped zeros [see also clamp.decTest]
+dqbas1075 toSci 0e+10000 -> 0E+6111 Clamped
+dqbas1076 toSci 0e-10000 -> 0E-6176 Clamped
+dqbas1077 toSci -0e+10000 -> -0E+6111 Clamped
+dqbas1078 toSci -0e-10000 -> -0E-6176 Clamped
+
+-- extreme values from next-wider
+dqbas1101 toSci -9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> -Infinity Overflow Inexact Rounded
+dqbas1102 toSci -1E-1572863 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
+dqbas1103 toSci -1E-1572932 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
+dqbas1104 toSci -0 -> -0
+dqbas1105 toSci +0 -> 0
+dqbas1106 toSci +1E-1572932 -> 0E-6176 Inexact Rounded Subnormal Underflow Clamped
+dqbas1107 toSci +1E-1572863 -> 0E-6176 Inexact Rounded Subnormal Underflow Clamped
+dqbas1108 toSci +9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> Infinity Overflow Inexact Rounded
+
diff --git a/Lib/test/decimaltestdata/dqCanonical.decTest b/Lib/test/decimaltestdata/dqCanonical.decTest
index 006db8595c..3ddf6eab2d 100644
--- a/Lib/test/decimaltestdata/dqCanonical.decTest
+++ b/Lib/test/decimaltestdata/dqCanonical.decTest
@@ -1,372 +1,372 @@
-------------------------------------------------------------------------
--- dqCanonical.decTest -- test decQuad canonical results --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests that copy operations leave uncanonical operands
--- unchanged, and vice versa
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Uncanonical declets are: abc, where:
--- a=1,2,3
--- b=6,7,e,f
--- c=e,f
-
--- assert some standard (canonical) values; this tests that FromString
--- produces canonical results (many more in decimalNN)
-dqcan001 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan002 apply 0 -> #22080000000000000000000000000000
-dqcan003 apply 1 -> #22080000000000000000000000000001
-dqcan004 apply -1 -> #a2080000000000000000000000000001
-dqcan005 apply Infinity -> #78000000000000000000000000000000
-dqcan006 apply -Infinity -> #f8000000000000000000000000000000
-dqcan007 apply -NaN -> #fc000000000000000000000000000000
-dqcan008 apply -sNaN -> #fe000000000000000000000000000000
-dqcan009 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan010 apply sNaN999999999999999999999999999999999 -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-decan011 apply 9999999999999999999999999999999999 -> #6e080ff3fcff3fcff3fcff3fcff3fcff
-dqcan012 apply 7.50 -> #220780000000000000000000000003d0
-dqcan013 apply 9.99 -> #220780000000000000000000000000ff
-
--- Base tests for canonical encodings (individual operator
--- propagation is tested later)
-
--- Finites: declets in coefficient
-dqcan021 canonical #77ffcff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan022 canonical #77fffff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan023 canonical #77ffcffffcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan024 canonical #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan025 canonical #77ffcff3fcffffcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan026 canonical #77ffcff3fcff3ffff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan027 canonical #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan028 canonical #77ffcff3fcff3fcff3ffff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan029 canonical #77ffcff3fcff3fcff3fcffffcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan030 canonical #77ffcff3fcff3fcff3fcff3ffff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan031 canonical #77ffcff3fcff3fcff3fcff3fcffffcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan032 canonical #77ffcff3fcff3fcff3fcff3fcff3ffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-
--- NaN: declets in payload
-dqcan061 canonical #7c000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan062 canonical #7c000ffffcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan063 canonical #7c000ff3ffff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan064 canonical #7c000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan065 canonical #7c000ff3fcff3ffff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan066 canonical #7c000ff3fcff3fcffffcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan067 canonical #7c000ff3fcff3fcff3ffff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan068 canonical #7c000ff3fcff3fcff3fcffffcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan069 canonical #7c000ff3fcff3fcff3fcff3ffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan070 canonical #7c000ff3fcff3fcff3fcff3fcffffcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan071 canonical #7c000ff3fcff3fcff3fcff3fcff3ffff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-dqcan081 canonical #7d000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan082 canonical #7c800ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan083 canonical #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan084 canonical #7c200ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan085 canonical #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan086 canonical #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan087 canonical #7c040ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan088 canonical #7c020ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan089 canonical #7c010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan090 canonical #7c008ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan091 canonical #7c004ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-
--- sNaN: declets in payload
-dqcan101 canonical #7e000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan102 canonical #7e000ffffcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan103 canonical #7e000ff3ffff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan104 canonical #7e000ff3fcffffcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan105 canonical #7e000ff3fcff3ffff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan106 canonical #7e000ff3fcff3fcffffcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan107 canonical #7e000ff3fcff3fcff3ffff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan108 canonical #7e000ff3fcff3fcff3fcffffcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan109 canonical #7e000ff3fcff3fcff3fcff3ffff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan100 canonical #7e000ff3fcff3fcff3fcff3fcffffcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan111 canonical #7e000ff3fcff3fcff3fcff3fcff3ffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
--- sNaN: exponent continuation bits [excluding sNaN selector]
-dqcan121 canonical #7f000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan122 canonical #7e800ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan123 canonical #7e400ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan124 canonical #7e200ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan125 canonical #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan126 canonical #7e080ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan127 canonical #7e040ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan128 canonical #7e020ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan129 canonical #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan130 canonical #7e008ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan131 canonical #7e004ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-
--- Inf: exponent continuation bits
-dqcan137 canonical #78000000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan138 canonical #79000000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan139 canonical #7a000000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan140 canonical #78800000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan141 canonical #78400000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan142 canonical #78200000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan143 canonical #78100000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan144 canonical #78080000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan145 canonical #78040000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan146 canonical #78020000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan147 canonical #78010000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan148 canonical #78008000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan149 canonical #78004000000000000000000000000000 -> #78000000000000000000000000000000
-
--- Inf: coefficient continuation bits (first, last, and a few others)
-dqcan150 canonical #78000000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan151 canonical #78020000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan152 canonical #78000000000000000000000000000001 -> #78000000000000000000000000000000
-dqcan153 canonical #78010000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan154 canonical #78002000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan155 canonical #78000800000000000000000000000000 -> #78000000000000000000000000000000
-dqcan156 canonical #78000020000000000000000000000000 -> #78000000000000000000000000000000
-dqcan157 canonical #78000004000000000000000000000000 -> #78000000000000000000000000000000
-dqcan158 canonical #78000000400000000000000000000000 -> #78000000000000000000000000000000
-dqcan159 canonical #78000000080000000000000000000000 -> #78000000000000000000000000000000
-dqcan160 canonical #78000000004000000000000000000000 -> #78000000000000000000000000000000
-dqcan161 canonical #78000000000200000000000000000000 -> #78000000000000000000000000000000
-dqcan162 canonical #78000000000080000000000000000000 -> #78000000000000000000000000000000
-dqcan163 canonical #78000000000002000000000000000000 -> #78000000000000000000000000000000
-dqcan164 canonical #78000000000000400000000000000000 -> #78000000000000000000000000000000
-dqcan165 canonical #78000000000000080000000000000000 -> #78000000000000000000000000000000
-dqcan166 canonical #78000000000000001000000000000000 -> #78000000000000000000000000000000
-dqcan167 canonical #78000000000000000200000000000000 -> #78000000000000000000000000000000
-dqcan168 canonical #78000000000000000080000000000000 -> #78000000000000000000000000000000
-dqcan169 canonical #78000000000000000004000000000000 -> #78000000000000000000000000000000
-dqcan170 canonical #78000000000000000000400000000000 -> #78000000000000000000000000000000
-dqcan171 canonical #78000000000000000000010000000000 -> #78000000000000000000000000000000
-dqcan172 canonical #78000000000000000000002000000000 -> #78000000000000000000000000000000
-dqcan173 canonical #78000000000000000000000400000000 -> #78000000000000000000000000000000
-dqcan174 canonical #78000000000000000000000080000000 -> #78000000000000000000000000000000
-dqcan175 canonical #78000000000000000000000002000000 -> #78000000000000000000000000000000
-dqcan176 canonical #78000000000000000000000000400000 -> #78000000000000000000000000000000
-dqcan177 canonical #78000000000000000000000000020000 -> #78000000000000000000000000000000
-dqcan178 canonical #78000000000000000000000000001000 -> #78000000000000000000000000000000
-dqcan179 canonical #78000000000000000000000000000400 -> #78000000000000000000000000000000
-dqcan180 canonical #78000000000000000000000000000020 -> #78000000000000000000000000000000
-dqcan181 canonical #78000000000000000000000000000008 -> #78000000000000000000000000000000
-
-
--- Now the operators -- trying to check paths that might fail to
--- canonicalize propagated operands
-
------ Add:
--- Finites: neutral 0
-dqcan202 add 0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan203 add #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
--- tiny zero
-dqcan204 add 0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
-dqcan205 add #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
--- tiny non zero
-dqcan206 add -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
-dqcan207 add #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
--- NaN: declets in payload
-dqcan211 add 0 #7c000ff3fcff3fcff3fcfffffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan212 add #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-dqcan213 add 0 #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan214 add #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- sNaN: declets in payload
-dqcan215 add 0 #7e000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan216 add #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-dqcan217 add 0 #7e500ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan218 add #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-dqcan220 add 0 #78010000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan221 add #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
--- Inf: coefficient continuation bits
-dqcan222 add 0 #78002000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan223 add #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
-dqcan224 add 0 #78000002000000000000000000000000 -> #78000000000000000000000000000000
-dqcan225 add #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
-dqcan226 add 0 #78000000000000000005000000000000 -> #78000000000000000000000000000000
-dqcan227 add #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000
-
------ Class: [does not return encoded]
-
------ Compare:
-dqcan231 compare -Inf 1 -> #a2080000000000000000000000000001
-dqcan232 compare -Inf -Inf -> #22080000000000000000000000000000
-dqcan233 compare 1 -Inf -> #22080000000000000000000000000001
-dqcan234 compare #7c010ff3fcff3fcff3fcff3ffffffcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan235 compare #7e004ff3fcff3fcff3ffffffcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-
------ CompareSig:
-dqcan241 comparesig -Inf 1 -> #a2080000000000000000000000000001
-dqcan242 comparesig -Inf -Inf -> #22080000000000000000000000000000
-dqcan243 comparesig 1 -Inf -> #22080000000000000000000000000001
-dqcan244 comparesig #7c400ff3ffff3fcff3fcff3fcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan245 comparesig #7e050ff3fcfffffff3fcff3fcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-
------ Copy: [does not usually canonicalize]
--- finites
-dqcan250 copy #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
-dqcan251 copy #ee080ff3fcff3ffff3fcff3ffff3fcff -> #ee080ff3fcff3ffff3fcff3ffff3fcff
--- NaNs
-dqcan252 copy #7c000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
-dqcan253 copy #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
--- sNaN
-dqcan254 copy #7e003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
-dqcan255 copy #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
--- Inf
-dqcan258 copy #78002000000000000000000000000000 -> #78002000000000000000000000000000
-dqcan259 copy #78000000000010000000000000100000 -> #78000000000010000000000000100000
-
------ CopyAbs: [does not usually canonicalize]
--- finites
-dqcan260 copyabs #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
-dqcan261 copyabs #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
--- NaNs
-dqcan262 copyabs #fc000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
-dqcan263 copyabs #fc080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
--- sNaN
-dqcan264 copyabs #fe003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
-dqcan265 copyabs #fe100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
--- Inf
-dqcan268 copyabs #f8002000000000000000000000000000 -> #78002000000000000000000000000000
-dqcan269 copyabs #f8000000000000700700700000000000 -> #78000000000000700700700000000000
-
------ CopyNegate: [does not usually canonicalize]
--- finites
-dqcan270 copynegate #6e080ff3fcff3fcfffffff3fcfffffff -> #ee080ff3fcff3fcfffffff3fcfffffff
-dqcan271 copynegate #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
--- NaNs
-dqcan272 copynegate #7c000ff3fcffffffffffff3fcff3fcff -> #fc000ff3fcffffffffffff3fcff3fcff
-dqcan273 copynegate #7c080ff3fcff3fcff3fcff3fcff3fcff -> #fc080ff3fcff3fcff3fcff3fcff3fcff
--- sNaN
-dqcan274 copynegate #7e003ff3fcffffffffffffffcff3fcff -> #fe003ff3fcffffffffffffffcff3fcff
-dqcan275 copynegate #7e100ff3fcff3fcff3fcff3fcff3fcff -> #fe100ff3fcff3fcff3fcff3fcff3fcff
--- Inf
-dqcan278 copynegate #78002000000000000000000000000000 -> #f8002000000000000000000000000000
-dqcan279 copynegate #78000000000010000000000000100000 -> #f8000000000010000000000000100000
-
------ CopySign: [does not usually canonicalize]
--- finites
-dqcan280 copysign #6e080ff3fcff3fcfffffff3fcfffffff -1 -> #ee080ff3fcff3fcfffffff3fcfffffff
-dqcan281 copysign #ee080ff3fcff3ffff3fcff3ffff3fcff 1 -> #6e080ff3fcff3ffff3fcff3ffff3fcff
--- NaNs
-dqcan282 copysign #7c000ff3fcffffffffffffffcff3fcff -1 -> #fc000ff3fcffffffffffffffcff3fcff
-dqcan283 copysign #7c080ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c080ff3fcff3fcff3fcff3fcff3fcff
--- sNaN
-dqcan284 copysign #7e003ff3fcffffffffffffffcff3fcff -1 -> #fe003ff3fcffffffffffffffcff3fcff
-dqcan285 copysign #7e100ff3fcff3fcff3fcff3fcff3fcff 1 -> #7e100ff3fcff3fcff3fcff3fcff3fcff
--- Inf
-dqcan288 copysign #78002000000000000000000000000000 -1 -> #f8002000000000000000000000000000
-dqcan289 copysign #78000000000010000000000000100000 1 -> #78000000000010000000000000100000
-
------ Multiply:
--- Finites: neutral 0
-dqcan302 multiply 1 #77ffff3fcff3fcff0000000000000000 -> #77ffff3fcff3fcff0000000000000000
-dqcan303 multiply #77fcffffcff3fcff0000000000000000 1 -> #77fccfffcff3fcff0000000000000000
--- negative
-dqcan306 multiply -1 #77ffff3fcff3fcff0000000000000000 -> #f7ffff3fcff3fcff0000000000000000
-dqcan307 multiply #77fcffffcff3fcff0000000000000000 -1 -> #f7fccfffcff3fcff0000000000000000
--- NaN: declets in payload
-dqcan311 multiply 1 #7c03ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000
-dqcan312 multiply #7c03ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000
--- NaN: exponent continuation bits [excluding sNaN selector]
-dqcan313 multiply 1 #7c40ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000
-dqcan314 multiply #7c40ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000
--- sNaN: declets in payload
-dqcan315 multiply 1 #7e00ffffcff3fcff0000000000000000 -> #7c000fffcff3fcff0000000000000000 Invalid_operation
-dqcan316 multiply #7e00ffffcff3fcff0000000000000000 1 -> #7c000fffcff3fcff0000000000000000 Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-dqcan317 multiply 1 #7e80ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
-dqcan318 multiply #7e80ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
--- Inf: exponent continuation bits
-dqcan320 multiply 1 #78800000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan321 multiply #78800000000000000000000000000000 1 -> #78000000000000000000000000000000
--- Inf: coefficient continuation bits
-dqcan322 multiply 1 #78020000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan323 multiply #78020000000000000000000000000000 1 -> #78000000000000000000000000000000
-dqcan324 multiply 1 #78000000000000010000000000000000 -> #78000000000000000000000000000000
-dqcan325 multiply #78000000000000010000000000000000 1 -> #78000000000000000000000000000000
-dqcan326 multiply 1 #78000020000000000000000000000000 -> #78000000000000000000000000000000
-dqcan327 multiply #78000020000000000000000000000000 1 -> #78000000000000000000000000000000
-
------ Quantize:
-dqcan401 quantize #ee080ff3fcff3fcff3fffffffff3fcff 0 -> #ee080ff3fcff3fcff3fcff3fcff3fcff
-dqcan402 quantize #ee080ff3fffffffffffcff3fcff3fcff 0 -> #ee080ff3fcff3fcff3fcff3fcff3fcff
-dqcan403 quantize #78800000000000000000000000000000 Inf -> #78000000000000000000000000000000
-dqcan404 quantize #78020000000000000000000000000000 -Inf -> #78000000000000000000000000000000
-dqcan410 quantize #7c080ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan411 quantize #fc000ff3fcfffffff3fcff3fcff3fcff 1 -> #fc000ff3fcff3fcff3fcff3fcff3fcff
-dqcan412 quantize #7e100ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan413 quantize #fe000ff3fcff3fcff3ffffffcff3fcff 1 -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-
------ Subtract:
--- Finites: neutral 0
-dqcan502 subtract 0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan503 subtract #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
--- tiny zero
-dqcan504 subtract 0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Rounded
-dqcan505 subtract #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
--- tiny non zero
-dqcan506 subtract -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
-dqcan507 subtract #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
--- NaN: declets in payload
-dqcan511 subtract 0 #7c000ff3fcff3fcff3fcfffffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan512 subtract #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-dqcan513 subtract 0 #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan514 subtract #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- sNaN: declets in payload
-dqcan515 subtract 0 #7e000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan516 subtract #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-dqcan517 subtract 0 #7e500ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan518 subtract #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-dqcan520 subtract 0 #78010000000000000000000000000000 -> #f8000000000000000000000000000000
-dqcan521 subtract #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
--- Inf: coefficient continuation bits
-dqcan522 subtract 0 #78002000000000000000000000000000 -> #f8000000000000000000000000000000
-dqcan523 subtract #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
-dqcan524 subtract 0 #78000002000000000000000000000000 -> #f8000000000000000000000000000000
-dqcan525 subtract #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
-dqcan526 subtract 0 #78000000000000000005000000000000 -> #f8000000000000000000000000000000
-dqcan527 subtract #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000
-
------ ToIntegral:
-dqcan601 tointegralx #6e080ff3fdff3fcff3fcff3fcff3fcff -> #6e080ff3fcff3fcff3fcff3fcff3fcff
-dqcan602 tointegralx #ee080ff3fcff3ffff3fcff3fcff3fcff -> #ee080ff3fcff3fcff3fcff3fcff3fcff
-dqcan603 tointegralx #78800000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan604 tointegralx #78020000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan614 tointegralx #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan615 tointegralx #fc000ff3fcff3fcff3fcffffcff3fcff -> #fc000ff3fcff3fcff3fcff3fcff3fcff
-dqcan616 tointegralx #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan617 tointegralx #fe000ff3fcff3fcff3fdff3fcff3fcff -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
-dqcan618 tointegralx #22080000000000000000000000000fff -> #22080000000000000000000000000cff
-dqcan619 tointegralx #22078000000000000000000000000fff -> #22080000000000000000000000000040 Inexact Rounded
-dqcan620 tointegralx #22074000000000000000000000000fff -> #22080000000000000000000000000004 Inexact Rounded
-dqcan621 tointegralx #22070000000000000000000000000fff -> #22080000000000000000000000000000 Inexact Rounded
-dqcan622 tointegralx #a2080000000000000000000000000fff -> #a2080000000000000000000000000cff
-dqcan623 tointegralx #a2078000000000000000000000000fff -> #a2080000000000000000000000000040 Inexact Rounded
-dqcan624 tointegralx #a2074000000000000000000000000fff -> #a2080000000000000000000000000004 Inexact Rounded
-dqcan625 tointegralx #a2070000000000000000000000000fff -> #a2080000000000000000000000000000 Inexact Rounded
-
-
-
+------------------------------------------------------------------------
+-- dqCanonical.decTest -- test decQuad canonical results --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests that copy operations leave uncanonical operands
+-- unchanged, and vice versa
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Uncanonical declets are: abc, where:
+-- a=1,2,3
+-- b=6,7,e,f
+-- c=e,f
+
+-- assert some standard (canonical) values; this tests that FromString
+-- produces canonical results (many more in decimalNN)
+dqcan001 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan002 apply 0 -> #22080000000000000000000000000000
+dqcan003 apply 1 -> #22080000000000000000000000000001
+dqcan004 apply -1 -> #a2080000000000000000000000000001
+dqcan005 apply Infinity -> #78000000000000000000000000000000
+dqcan006 apply -Infinity -> #f8000000000000000000000000000000
+dqcan007 apply -NaN -> #fc000000000000000000000000000000
+dqcan008 apply -sNaN -> #fe000000000000000000000000000000
+dqcan009 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan010 apply sNaN999999999999999999999999999999999 -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+decan011 apply 9999999999999999999999999999999999 -> #6e080ff3fcff3fcff3fcff3fcff3fcff
+dqcan012 apply 7.50 -> #220780000000000000000000000003d0
+dqcan013 apply 9.99 -> #220780000000000000000000000000ff
+
+-- Base tests for canonical encodings (individual operator
+-- propagation is tested later)
+
+-- Finites: declets in coefficient
+dqcan021 canonical #77ffcff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan022 canonical #77fffff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan023 canonical #77ffcffffcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan024 canonical #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan025 canonical #77ffcff3fcffffcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan026 canonical #77ffcff3fcff3ffff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan027 canonical #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan028 canonical #77ffcff3fcff3fcff3ffff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan029 canonical #77ffcff3fcff3fcff3fcffffcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan030 canonical #77ffcff3fcff3fcff3fcff3ffff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan031 canonical #77ffcff3fcff3fcff3fcff3fcffffcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan032 canonical #77ffcff3fcff3fcff3fcff3fcff3ffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+
+-- NaN: declets in payload
+dqcan061 canonical #7c000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan062 canonical #7c000ffffcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan063 canonical #7c000ff3ffff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan064 canonical #7c000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan065 canonical #7c000ff3fcff3ffff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan066 canonical #7c000ff3fcff3fcffffcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan067 canonical #7c000ff3fcff3fcff3ffff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan068 canonical #7c000ff3fcff3fcff3fcffffcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan069 canonical #7c000ff3fcff3fcff3fcff3ffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan070 canonical #7c000ff3fcff3fcff3fcff3fcffffcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan071 canonical #7c000ff3fcff3fcff3fcff3fcff3ffff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+dqcan081 canonical #7d000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan082 canonical #7c800ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan083 canonical #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan084 canonical #7c200ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan085 canonical #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan086 canonical #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan087 canonical #7c040ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan088 canonical #7c020ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan089 canonical #7c010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan090 canonical #7c008ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan091 canonical #7c004ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+
+-- sNaN: declets in payload
+dqcan101 canonical #7e000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan102 canonical #7e000ffffcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan103 canonical #7e000ff3ffff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan104 canonical #7e000ff3fcffffcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan105 canonical #7e000ff3fcff3ffff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan106 canonical #7e000ff3fcff3fcffffcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan107 canonical #7e000ff3fcff3fcff3ffff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan108 canonical #7e000ff3fcff3fcff3fcffffcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan109 canonical #7e000ff3fcff3fcff3fcff3ffff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan100 canonical #7e000ff3fcff3fcff3fcff3fcffffcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan111 canonical #7e000ff3fcff3fcff3fcff3fcff3ffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+dqcan121 canonical #7f000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan122 canonical #7e800ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan123 canonical #7e400ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan124 canonical #7e200ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan125 canonical #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan126 canonical #7e080ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan127 canonical #7e040ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan128 canonical #7e020ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan129 canonical #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan130 canonical #7e008ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan131 canonical #7e004ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+
+-- Inf: exponent continuation bits
+dqcan137 canonical #78000000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan138 canonical #79000000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan139 canonical #7a000000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan140 canonical #78800000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan141 canonical #78400000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan142 canonical #78200000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan143 canonical #78100000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan144 canonical #78080000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan145 canonical #78040000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan146 canonical #78020000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan147 canonical #78010000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan148 canonical #78008000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan149 canonical #78004000000000000000000000000000 -> #78000000000000000000000000000000
+
+-- Inf: coefficient continuation bits (first, last, and a few others)
+dqcan150 canonical #78000000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan151 canonical #78020000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan152 canonical #78000000000000000000000000000001 -> #78000000000000000000000000000000
+dqcan153 canonical #78010000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan154 canonical #78002000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan155 canonical #78000800000000000000000000000000 -> #78000000000000000000000000000000
+dqcan156 canonical #78000020000000000000000000000000 -> #78000000000000000000000000000000
+dqcan157 canonical #78000004000000000000000000000000 -> #78000000000000000000000000000000
+dqcan158 canonical #78000000400000000000000000000000 -> #78000000000000000000000000000000
+dqcan159 canonical #78000000080000000000000000000000 -> #78000000000000000000000000000000
+dqcan160 canonical #78000000004000000000000000000000 -> #78000000000000000000000000000000
+dqcan161 canonical #78000000000200000000000000000000 -> #78000000000000000000000000000000
+dqcan162 canonical #78000000000080000000000000000000 -> #78000000000000000000000000000000
+dqcan163 canonical #78000000000002000000000000000000 -> #78000000000000000000000000000000
+dqcan164 canonical #78000000000000400000000000000000 -> #78000000000000000000000000000000
+dqcan165 canonical #78000000000000080000000000000000 -> #78000000000000000000000000000000
+dqcan166 canonical #78000000000000001000000000000000 -> #78000000000000000000000000000000
+dqcan167 canonical #78000000000000000200000000000000 -> #78000000000000000000000000000000
+dqcan168 canonical #78000000000000000080000000000000 -> #78000000000000000000000000000000
+dqcan169 canonical #78000000000000000004000000000000 -> #78000000000000000000000000000000
+dqcan170 canonical #78000000000000000000400000000000 -> #78000000000000000000000000000000
+dqcan171 canonical #78000000000000000000010000000000 -> #78000000000000000000000000000000
+dqcan172 canonical #78000000000000000000002000000000 -> #78000000000000000000000000000000
+dqcan173 canonical #78000000000000000000000400000000 -> #78000000000000000000000000000000
+dqcan174 canonical #78000000000000000000000080000000 -> #78000000000000000000000000000000
+dqcan175 canonical #78000000000000000000000002000000 -> #78000000000000000000000000000000
+dqcan176 canonical #78000000000000000000000000400000 -> #78000000000000000000000000000000
+dqcan177 canonical #78000000000000000000000000020000 -> #78000000000000000000000000000000
+dqcan178 canonical #78000000000000000000000000001000 -> #78000000000000000000000000000000
+dqcan179 canonical #78000000000000000000000000000400 -> #78000000000000000000000000000000
+dqcan180 canonical #78000000000000000000000000000020 -> #78000000000000000000000000000000
+dqcan181 canonical #78000000000000000000000000000008 -> #78000000000000000000000000000000
+
+
+-- Now the operators -- trying to check paths that might fail to
+-- canonicalize propagated operands
+
+----- Add:
+-- Finites: neutral 0
+dqcan202 add 0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan203 add #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+-- tiny zero
+dqcan204 add 0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
+dqcan205 add #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
+-- tiny non zero
+dqcan206 add -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
+dqcan207 add #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
+-- NaN: declets in payload
+dqcan211 add 0 #7c000ff3fcff3fcff3fcfffffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan212 add #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+dqcan213 add 0 #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan214 add #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN: declets in payload
+dqcan215 add 0 #7e000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan216 add #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+dqcan217 add 0 #7e500ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan218 add #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+dqcan220 add 0 #78010000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan221 add #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
+-- Inf: coefficient continuation bits
+dqcan222 add 0 #78002000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan223 add #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
+dqcan224 add 0 #78000002000000000000000000000000 -> #78000000000000000000000000000000
+dqcan225 add #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
+dqcan226 add 0 #78000000000000000005000000000000 -> #78000000000000000000000000000000
+dqcan227 add #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000
+
+----- Class: [does not return encoded]
+
+----- Compare:
+dqcan231 compare -Inf 1 -> #a2080000000000000000000000000001
+dqcan232 compare -Inf -Inf -> #22080000000000000000000000000000
+dqcan233 compare 1 -Inf -> #22080000000000000000000000000001
+dqcan234 compare #7c010ff3fcff3fcff3fcff3ffffffcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan235 compare #7e004ff3fcff3fcff3ffffffcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+
+----- CompareSig:
+dqcan241 comparesig -Inf 1 -> #a2080000000000000000000000000001
+dqcan242 comparesig -Inf -Inf -> #22080000000000000000000000000000
+dqcan243 comparesig 1 -Inf -> #22080000000000000000000000000001
+dqcan244 comparesig #7c400ff3ffff3fcff3fcff3fcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan245 comparesig #7e050ff3fcfffffff3fcff3fcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+
+----- Copy: [does not usually canonicalize]
+-- finites
+dqcan250 copy #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
+dqcan251 copy #ee080ff3fcff3ffff3fcff3ffff3fcff -> #ee080ff3fcff3ffff3fcff3ffff3fcff
+-- NaNs
+dqcan252 copy #7c000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
+dqcan253 copy #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN
+dqcan254 copy #7e003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
+dqcan255 copy #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
+-- Inf
+dqcan258 copy #78002000000000000000000000000000 -> #78002000000000000000000000000000
+dqcan259 copy #78000000000010000000000000100000 -> #78000000000010000000000000100000
+
+----- CopyAbs: [does not usually canonicalize]
+-- finites
+dqcan260 copyabs #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
+dqcan261 copyabs #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
+-- NaNs
+dqcan262 copyabs #fc000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
+dqcan263 copyabs #fc080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN
+dqcan264 copyabs #fe003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
+dqcan265 copyabs #fe100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
+-- Inf
+dqcan268 copyabs #f8002000000000000000000000000000 -> #78002000000000000000000000000000
+dqcan269 copyabs #f8000000000000700700700000000000 -> #78000000000000700700700000000000
+
+----- CopyNegate: [does not usually canonicalize]
+-- finites
+dqcan270 copynegate #6e080ff3fcff3fcfffffff3fcfffffff -> #ee080ff3fcff3fcfffffff3fcfffffff
+dqcan271 copynegate #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
+-- NaNs
+dqcan272 copynegate #7c000ff3fcffffffffffff3fcff3fcff -> #fc000ff3fcffffffffffff3fcff3fcff
+dqcan273 copynegate #7c080ff3fcff3fcff3fcff3fcff3fcff -> #fc080ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN
+dqcan274 copynegate #7e003ff3fcffffffffffffffcff3fcff -> #fe003ff3fcffffffffffffffcff3fcff
+dqcan275 copynegate #7e100ff3fcff3fcff3fcff3fcff3fcff -> #fe100ff3fcff3fcff3fcff3fcff3fcff
+-- Inf
+dqcan278 copynegate #78002000000000000000000000000000 -> #f8002000000000000000000000000000
+dqcan279 copynegate #78000000000010000000000000100000 -> #f8000000000010000000000000100000
+
+----- CopySign: [does not usually canonicalize]
+-- finites
+dqcan280 copysign #6e080ff3fcff3fcfffffff3fcfffffff -1 -> #ee080ff3fcff3fcfffffff3fcfffffff
+dqcan281 copysign #ee080ff3fcff3ffff3fcff3ffff3fcff 1 -> #6e080ff3fcff3ffff3fcff3ffff3fcff
+-- NaNs
+dqcan282 copysign #7c000ff3fcffffffffffffffcff3fcff -1 -> #fc000ff3fcffffffffffffffcff3fcff
+dqcan283 copysign #7c080ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c080ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN
+dqcan284 copysign #7e003ff3fcffffffffffffffcff3fcff -1 -> #fe003ff3fcffffffffffffffcff3fcff
+dqcan285 copysign #7e100ff3fcff3fcff3fcff3fcff3fcff 1 -> #7e100ff3fcff3fcff3fcff3fcff3fcff
+-- Inf
+dqcan288 copysign #78002000000000000000000000000000 -1 -> #f8002000000000000000000000000000
+dqcan289 copysign #78000000000010000000000000100000 1 -> #78000000000010000000000000100000
+
+----- Multiply:
+-- Finites: neutral 0
+dqcan302 multiply 1 #77ffff3fcff3fcff0000000000000000 -> #77ffff3fcff3fcff0000000000000000
+dqcan303 multiply #77fcffffcff3fcff0000000000000000 1 -> #77fccfffcff3fcff0000000000000000
+-- negative
+dqcan306 multiply -1 #77ffff3fcff3fcff0000000000000000 -> #f7ffff3fcff3fcff0000000000000000
+dqcan307 multiply #77fcffffcff3fcff0000000000000000 -1 -> #f7fccfffcff3fcff0000000000000000
+-- NaN: declets in payload
+dqcan311 multiply 1 #7c03ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000
+dqcan312 multiply #7c03ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000
+-- NaN: exponent continuation bits [excluding sNaN selector]
+dqcan313 multiply 1 #7c40ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000
+dqcan314 multiply #7c40ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000
+-- sNaN: declets in payload
+dqcan315 multiply 1 #7e00ffffcff3fcff0000000000000000 -> #7c000fffcff3fcff0000000000000000 Invalid_operation
+dqcan316 multiply #7e00ffffcff3fcff0000000000000000 1 -> #7c000fffcff3fcff0000000000000000 Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+dqcan317 multiply 1 #7e80ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
+dqcan318 multiply #7e80ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
+-- Inf: exponent continuation bits
+dqcan320 multiply 1 #78800000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan321 multiply #78800000000000000000000000000000 1 -> #78000000000000000000000000000000
+-- Inf: coefficient continuation bits
+dqcan322 multiply 1 #78020000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan323 multiply #78020000000000000000000000000000 1 -> #78000000000000000000000000000000
+dqcan324 multiply 1 #78000000000000010000000000000000 -> #78000000000000000000000000000000
+dqcan325 multiply #78000000000000010000000000000000 1 -> #78000000000000000000000000000000
+dqcan326 multiply 1 #78000020000000000000000000000000 -> #78000000000000000000000000000000
+dqcan327 multiply #78000020000000000000000000000000 1 -> #78000000000000000000000000000000
+
+----- Quantize:
+dqcan401 quantize #ee080ff3fcff3fcff3fffffffff3fcff 0 -> #ee080ff3fcff3fcff3fcff3fcff3fcff
+dqcan402 quantize #ee080ff3fffffffffffcff3fcff3fcff 0 -> #ee080ff3fcff3fcff3fcff3fcff3fcff
+dqcan403 quantize #78800000000000000000000000000000 Inf -> #78000000000000000000000000000000
+dqcan404 quantize #78020000000000000000000000000000 -Inf -> #78000000000000000000000000000000
+dqcan410 quantize #7c080ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan411 quantize #fc000ff3fcfffffff3fcff3fcff3fcff 1 -> #fc000ff3fcff3fcff3fcff3fcff3fcff
+dqcan412 quantize #7e100ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan413 quantize #fe000ff3fcff3fcff3ffffffcff3fcff 1 -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+
+----- Subtract:
+-- Finites: neutral 0
+dqcan502 subtract 0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan503 subtract #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+-- tiny zero
+dqcan504 subtract 0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Rounded
+dqcan505 subtract #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
+-- tiny non zero
+dqcan506 subtract -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
+dqcan507 subtract #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
+-- NaN: declets in payload
+dqcan511 subtract 0 #7c000ff3fcff3fcff3fcfffffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan512 subtract #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+dqcan513 subtract 0 #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan514 subtract #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN: declets in payload
+dqcan515 subtract 0 #7e000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan516 subtract #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+dqcan517 subtract 0 #7e500ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan518 subtract #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+dqcan520 subtract 0 #78010000000000000000000000000000 -> #f8000000000000000000000000000000
+dqcan521 subtract #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
+-- Inf: coefficient continuation bits
+dqcan522 subtract 0 #78002000000000000000000000000000 -> #f8000000000000000000000000000000
+dqcan523 subtract #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
+dqcan524 subtract 0 #78000002000000000000000000000000 -> #f8000000000000000000000000000000
+dqcan525 subtract #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
+dqcan526 subtract 0 #78000000000000000005000000000000 -> #f8000000000000000000000000000000
+dqcan527 subtract #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000
+
+----- ToIntegral:
+dqcan601 tointegralx #6e080ff3fdff3fcff3fcff3fcff3fcff -> #6e080ff3fcff3fcff3fcff3fcff3fcff
+dqcan602 tointegralx #ee080ff3fcff3ffff3fcff3fcff3fcff -> #ee080ff3fcff3fcff3fcff3fcff3fcff
+dqcan603 tointegralx #78800000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan604 tointegralx #78020000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan614 tointegralx #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan615 tointegralx #fc000ff3fcff3fcff3fcffffcff3fcff -> #fc000ff3fcff3fcff3fcff3fcff3fcff
+dqcan616 tointegralx #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan617 tointegralx #fe000ff3fcff3fcff3fdff3fcff3fcff -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
+dqcan618 tointegralx #22080000000000000000000000000fff -> #22080000000000000000000000000cff
+dqcan619 tointegralx #22078000000000000000000000000fff -> #22080000000000000000000000000040 Inexact Rounded
+dqcan620 tointegralx #22074000000000000000000000000fff -> #22080000000000000000000000000004 Inexact Rounded
+dqcan621 tointegralx #22070000000000000000000000000fff -> #22080000000000000000000000000000 Inexact Rounded
+dqcan622 tointegralx #a2080000000000000000000000000fff -> #a2080000000000000000000000000cff
+dqcan623 tointegralx #a2078000000000000000000000000fff -> #a2080000000000000000000000000040 Inexact Rounded
+dqcan624 tointegralx #a2074000000000000000000000000fff -> #a2080000000000000000000000000004 Inexact Rounded
+dqcan625 tointegralx #a2070000000000000000000000000fff -> #a2080000000000000000000000000000 Inexact Rounded
+
+
+
diff --git a/Lib/test/decimaltestdata/dqClass.decTest b/Lib/test/decimaltestdata/dqClass.decTest
index d7e19b3829..f341933878 100644
--- a/Lib/test/decimaltestdata/dqClass.decTest
+++ b/Lib/test/decimaltestdata/dqClass.decTest
@@ -1,77 +1,77 @@
-------------------------------------------------------------------------
--- dqClass.decTest -- decQuad Class operations --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- [New 2006.11.27]
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqcla001 class 0 -> +Zero
-dqcla002 class 0.00 -> +Zero
-dqcla003 class 0E+5 -> +Zero
-dqcla004 class 1E-6176 -> +Subnormal
-dqcla005 class 0.1E-6143 -> +Subnormal
-dqcla006 class 0.99999999999999999999999999999999E-6143 -> +Subnormal
-dqcla007 class 1.00000000000000000000000000000000E-6143 -> +Normal
-dqcla008 class 1E-6143 -> +Normal
-dqcla009 class 1E-100 -> +Normal
-dqcla010 class 1E-10 -> +Normal
-dqcla012 class 1E-1 -> +Normal
-dqcla013 class 1 -> +Normal
-dqcla014 class 2.50 -> +Normal
-dqcla015 class 100.100 -> +Normal
-dqcla016 class 1E+30 -> +Normal
-dqcla017 class 1E+6144 -> +Normal
-dqcla018 class 9.99999999999999999999999999999999E+6144 -> +Normal
-dqcla019 class Inf -> +Infinity
-
-dqcla021 class -0 -> -Zero
-dqcla022 class -0.00 -> -Zero
-dqcla023 class -0E+5 -> -Zero
-dqcla024 class -1E-6176 -> -Subnormal
-dqcla025 class -0.1E-6143 -> -Subnormal
-dqcla026 class -0.99999999999999999999999999999999E-6143 -> -Subnormal
-dqcla027 class -1.00000000000000000000000000000000E-6143 -> -Normal
-dqcla028 class -1E-6143 -> -Normal
-dqcla029 class -1E-100 -> -Normal
-dqcla030 class -1E-10 -> -Normal
-dqcla032 class -1E-1 -> -Normal
-dqcla033 class -1 -> -Normal
-dqcla034 class -2.50 -> -Normal
-dqcla035 class -100.100 -> -Normal
-dqcla036 class -1E+30 -> -Normal
-dqcla037 class -1E+6144 -> -Normal
-dqcla0614 class -9.99999999999999999999999999999999E+6144 -> -Normal
-dqcla039 class -Inf -> -Infinity
-
-dqcla041 class NaN -> NaN
-dqcla042 class -NaN -> NaN
-dqcla043 class +NaN12345 -> NaN
-dqcla044 class sNaN -> sNaN
-dqcla045 class -sNaN -> sNaN
-dqcla046 class +sNaN12345 -> sNaN
-
-
-
+------------------------------------------------------------------------
+-- dqClass.decTest -- decQuad Class operations --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- [New 2006.11.27]
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqcla001 class 0 -> +Zero
+dqcla002 class 0.00 -> +Zero
+dqcla003 class 0E+5 -> +Zero
+dqcla004 class 1E-6176 -> +Subnormal
+dqcla005 class 0.1E-6143 -> +Subnormal
+dqcla006 class 0.99999999999999999999999999999999E-6143 -> +Subnormal
+dqcla007 class 1.00000000000000000000000000000000E-6143 -> +Normal
+dqcla008 class 1E-6143 -> +Normal
+dqcla009 class 1E-100 -> +Normal
+dqcla010 class 1E-10 -> +Normal
+dqcla012 class 1E-1 -> +Normal
+dqcla013 class 1 -> +Normal
+dqcla014 class 2.50 -> +Normal
+dqcla015 class 100.100 -> +Normal
+dqcla016 class 1E+30 -> +Normal
+dqcla017 class 1E+6144 -> +Normal
+dqcla018 class 9.99999999999999999999999999999999E+6144 -> +Normal
+dqcla019 class Inf -> +Infinity
+
+dqcla021 class -0 -> -Zero
+dqcla022 class -0.00 -> -Zero
+dqcla023 class -0E+5 -> -Zero
+dqcla024 class -1E-6176 -> -Subnormal
+dqcla025 class -0.1E-6143 -> -Subnormal
+dqcla026 class -0.99999999999999999999999999999999E-6143 -> -Subnormal
+dqcla027 class -1.00000000000000000000000000000000E-6143 -> -Normal
+dqcla028 class -1E-6143 -> -Normal
+dqcla029 class -1E-100 -> -Normal
+dqcla030 class -1E-10 -> -Normal
+dqcla032 class -1E-1 -> -Normal
+dqcla033 class -1 -> -Normal
+dqcla034 class -2.50 -> -Normal
+dqcla035 class -100.100 -> -Normal
+dqcla036 class -1E+30 -> -Normal
+dqcla037 class -1E+6144 -> -Normal
+dqcla0614 class -9.99999999999999999999999999999999E+6144 -> -Normal
+dqcla039 class -Inf -> -Infinity
+
+dqcla041 class NaN -> NaN
+dqcla042 class -NaN -> NaN
+dqcla043 class +NaN12345 -> NaN
+dqcla044 class sNaN -> sNaN
+dqcla045 class -sNaN -> sNaN
+dqcla046 class +sNaN12345 -> sNaN
+
+
+
diff --git a/Lib/test/decimaltestdata/dqCompare.decTest b/Lib/test/decimaltestdata/dqCompare.decTest
index b7b5ee6b8e..a617ad110a 100644
--- a/Lib/test/decimaltestdata/dqCompare.decTest
+++ b/Lib/test/decimaltestdata/dqCompare.decTest
@@ -1,753 +1,753 @@
-------------------------------------------------------------------------
--- dqCompare.decTest -- decQuad comparison that allows quiet NaNs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqcom001 compare -2 -2 -> 0
-dqcom002 compare -2 -1 -> -1
-dqcom003 compare -2 0 -> -1
-dqcom004 compare -2 1 -> -1
-dqcom005 compare -2 2 -> -1
-dqcom006 compare -1 -2 -> 1
-dqcom007 compare -1 -1 -> 0
-dqcom008 compare -1 0 -> -1
-dqcom009 compare -1 1 -> -1
-dqcom010 compare -1 2 -> -1
-dqcom011 compare 0 -2 -> 1
-dqcom012 compare 0 -1 -> 1
-dqcom013 compare 0 0 -> 0
-dqcom014 compare 0 1 -> -1
-dqcom015 compare 0 2 -> -1
-dqcom016 compare 1 -2 -> 1
-dqcom017 compare 1 -1 -> 1
-dqcom018 compare 1 0 -> 1
-dqcom019 compare 1 1 -> 0
-dqcom020 compare 1 2 -> -1
-dqcom021 compare 2 -2 -> 1
-dqcom022 compare 2 -1 -> 1
-dqcom023 compare 2 0 -> 1
-dqcom025 compare 2 1 -> 1
-dqcom026 compare 2 2 -> 0
-
-dqcom031 compare -20 -20 -> 0
-dqcom032 compare -20 -10 -> -1
-dqcom033 compare -20 00 -> -1
-dqcom034 compare -20 10 -> -1
-dqcom035 compare -20 20 -> -1
-dqcom036 compare -10 -20 -> 1
-dqcom037 compare -10 -10 -> 0
-dqcom038 compare -10 00 -> -1
-dqcom039 compare -10 10 -> -1
-dqcom040 compare -10 20 -> -1
-dqcom041 compare 00 -20 -> 1
-dqcom042 compare 00 -10 -> 1
-dqcom043 compare 00 00 -> 0
-dqcom044 compare 00 10 -> -1
-dqcom045 compare 00 20 -> -1
-dqcom046 compare 10 -20 -> 1
-dqcom047 compare 10 -10 -> 1
-dqcom048 compare 10 00 -> 1
-dqcom049 compare 10 10 -> 0
-dqcom050 compare 10 20 -> -1
-dqcom051 compare 20 -20 -> 1
-dqcom052 compare 20 -10 -> 1
-dqcom053 compare 20 00 -> 1
-dqcom055 compare 20 10 -> 1
-dqcom056 compare 20 20 -> 0
-
-dqcom061 compare -2.0 -2.0 -> 0
-dqcom062 compare -2.0 -1.0 -> -1
-dqcom063 compare -2.0 0.0 -> -1
-dqcom064 compare -2.0 1.0 -> -1
-dqcom065 compare -2.0 2.0 -> -1
-dqcom066 compare -1.0 -2.0 -> 1
-dqcom067 compare -1.0 -1.0 -> 0
-dqcom068 compare -1.0 0.0 -> -1
-dqcom069 compare -1.0 1.0 -> -1
-dqcom070 compare -1.0 2.0 -> -1
-dqcom071 compare 0.0 -2.0 -> 1
-dqcom072 compare 0.0 -1.0 -> 1
-dqcom073 compare 0.0 0.0 -> 0
-dqcom074 compare 0.0 1.0 -> -1
-dqcom075 compare 0.0 2.0 -> -1
-dqcom076 compare 1.0 -2.0 -> 1
-dqcom077 compare 1.0 -1.0 -> 1
-dqcom078 compare 1.0 0.0 -> 1
-dqcom079 compare 1.0 1.0 -> 0
-dqcom080 compare 1.0 2.0 -> -1
-dqcom081 compare 2.0 -2.0 -> 1
-dqcom082 compare 2.0 -1.0 -> 1
-dqcom083 compare 2.0 0.0 -> 1
-dqcom085 compare 2.0 1.0 -> 1
-dqcom086 compare 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-dqcom090 compare 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 0
-dqcom091 compare -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> -1
-dqcom092 compare 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
-dqcom093 compare -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0
-
--- some differing length/exponent cases
-dqcom100 compare 7.0 7.0 -> 0
-dqcom101 compare 7.0 7 -> 0
-dqcom102 compare 7 7.0 -> 0
-dqcom103 compare 7E+0 7.0 -> 0
-dqcom104 compare 70E-1 7.0 -> 0
-dqcom105 compare 0.7E+1 7 -> 0
-dqcom106 compare 70E-1 7 -> 0
-dqcom107 compare 7.0 7E+0 -> 0
-dqcom108 compare 7.0 70E-1 -> 0
-dqcom109 compare 7 0.7E+1 -> 0
-dqcom110 compare 7 70E-1 -> 0
-
-dqcom120 compare 8.0 7.0 -> 1
-dqcom121 compare 8.0 7 -> 1
-dqcom122 compare 8 7.0 -> 1
-dqcom123 compare 8E+0 7.0 -> 1
-dqcom124 compare 80E-1 7.0 -> 1
-dqcom125 compare 0.8E+1 7 -> 1
-dqcom126 compare 80E-1 7 -> 1
-dqcom127 compare 8.0 7E+0 -> 1
-dqcom128 compare 8.0 70E-1 -> 1
-dqcom129 compare 8 0.7E+1 -> 1
-dqcom130 compare 8 70E-1 -> 1
-
-dqcom140 compare 8.0 9.0 -> -1
-dqcom141 compare 8.0 9 -> -1
-dqcom142 compare 8 9.0 -> -1
-dqcom143 compare 8E+0 9.0 -> -1
-dqcom144 compare 80E-1 9.0 -> -1
-dqcom145 compare 0.8E+1 9 -> -1
-dqcom146 compare 80E-1 9 -> -1
-dqcom147 compare 8.0 9E+0 -> -1
-dqcom148 compare 8.0 90E-1 -> -1
-dqcom149 compare 8 0.9E+1 -> -1
-dqcom150 compare 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-dqcom200 compare -7.0 7.0 -> -1
-dqcom201 compare -7.0 7 -> -1
-dqcom202 compare -7 7.0 -> -1
-dqcom203 compare -7E+0 7.0 -> -1
-dqcom204 compare -70E-1 7.0 -> -1
-dqcom205 compare -0.7E+1 7 -> -1
-dqcom206 compare -70E-1 7 -> -1
-dqcom207 compare -7.0 7E+0 -> -1
-dqcom208 compare -7.0 70E-1 -> -1
-dqcom209 compare -7 0.7E+1 -> -1
-dqcom210 compare -7 70E-1 -> -1
-
-dqcom220 compare -8.0 7.0 -> -1
-dqcom221 compare -8.0 7 -> -1
-dqcom222 compare -8 7.0 -> -1
-dqcom223 compare -8E+0 7.0 -> -1
-dqcom224 compare -80E-1 7.0 -> -1
-dqcom225 compare -0.8E+1 7 -> -1
-dqcom226 compare -80E-1 7 -> -1
-dqcom227 compare -8.0 7E+0 -> -1
-dqcom228 compare -8.0 70E-1 -> -1
-dqcom229 compare -8 0.7E+1 -> -1
-dqcom230 compare -8 70E-1 -> -1
-
-dqcom240 compare -8.0 9.0 -> -1
-dqcom241 compare -8.0 9 -> -1
-dqcom242 compare -8 9.0 -> -1
-dqcom243 compare -8E+0 9.0 -> -1
-dqcom244 compare -80E-1 9.0 -> -1
-dqcom245 compare -0.8E+1 9 -> -1
-dqcom246 compare -80E-1 9 -> -1
-dqcom247 compare -8.0 9E+0 -> -1
-dqcom248 compare -8.0 90E-1 -> -1
-dqcom249 compare -8 0.9E+1 -> -1
-dqcom250 compare -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-dqcom300 compare 7.0 -7.0 -> 1
-dqcom301 compare 7.0 -7 -> 1
-dqcom302 compare 7 -7.0 -> 1
-dqcom303 compare 7E+0 -7.0 -> 1
-dqcom304 compare 70E-1 -7.0 -> 1
-dqcom305 compare .7E+1 -7 -> 1
-dqcom306 compare 70E-1 -7 -> 1
-dqcom307 compare 7.0 -7E+0 -> 1
-dqcom308 compare 7.0 -70E-1 -> 1
-dqcom309 compare 7 -.7E+1 -> 1
-dqcom310 compare 7 -70E-1 -> 1
-
-dqcom320 compare 8.0 -7.0 -> 1
-dqcom321 compare 8.0 -7 -> 1
-dqcom322 compare 8 -7.0 -> 1
-dqcom323 compare 8E+0 -7.0 -> 1
-dqcom324 compare 80E-1 -7.0 -> 1
-dqcom325 compare .8E+1 -7 -> 1
-dqcom326 compare 80E-1 -7 -> 1
-dqcom327 compare 8.0 -7E+0 -> 1
-dqcom328 compare 8.0 -70E-1 -> 1
-dqcom329 compare 8 -.7E+1 -> 1
-dqcom330 compare 8 -70E-1 -> 1
-
-dqcom340 compare 8.0 -9.0 -> 1
-dqcom341 compare 8.0 -9 -> 1
-dqcom342 compare 8 -9.0 -> 1
-dqcom343 compare 8E+0 -9.0 -> 1
-dqcom344 compare 80E-1 -9.0 -> 1
-dqcom345 compare .8E+1 -9 -> 1
-dqcom346 compare 80E-1 -9 -> 1
-dqcom347 compare 8.0 -9E+0 -> 1
-dqcom348 compare 8.0 -90E-1 -> 1
-dqcom349 compare 8 -.9E+1 -> 1
-dqcom350 compare 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-dqcom400 compare -7.0 -7.0 -> 0
-dqcom401 compare -7.0 -7 -> 0
-dqcom402 compare -7 -7.0 -> 0
-dqcom403 compare -7E+0 -7.0 -> 0
-dqcom404 compare -70E-1 -7.0 -> 0
-dqcom405 compare -.7E+1 -7 -> 0
-dqcom406 compare -70E-1 -7 -> 0
-dqcom407 compare -7.0 -7E+0 -> 0
-dqcom408 compare -7.0 -70E-1 -> 0
-dqcom409 compare -7 -.7E+1 -> 0
-dqcom410 compare -7 -70E-1 -> 0
-
-dqcom420 compare -8.0 -7.0 -> -1
-dqcom421 compare -8.0 -7 -> -1
-dqcom422 compare -8 -7.0 -> -1
-dqcom423 compare -8E+0 -7.0 -> -1
-dqcom424 compare -80E-1 -7.0 -> -1
-dqcom425 compare -.8E+1 -7 -> -1
-dqcom426 compare -80E-1 -7 -> -1
-dqcom427 compare -8.0 -7E+0 -> -1
-dqcom428 compare -8.0 -70E-1 -> -1
-dqcom429 compare -8 -.7E+1 -> -1
-dqcom430 compare -8 -70E-1 -> -1
-
-dqcom440 compare -8.0 -9.0 -> 1
-dqcom441 compare -8.0 -9 -> 1
-dqcom442 compare -8 -9.0 -> 1
-dqcom443 compare -8E+0 -9.0 -> 1
-dqcom444 compare -80E-1 -9.0 -> 1
-dqcom445 compare -.8E+1 -9 -> 1
-dqcom446 compare -80E-1 -9 -> 1
-dqcom447 compare -8.0 -9E+0 -> 1
-dqcom448 compare -8.0 -90E-1 -> 1
-dqcom449 compare -8 -.9E+1 -> 1
-dqcom450 compare -8 -90E-1 -> 1
-
--- misalignment traps for little-endian
-dqcom451 compare 1.0 0.1 -> 1
-dqcom452 compare 0.1 1.0 -> -1
-dqcom453 compare 10.0 0.1 -> 1
-dqcom454 compare 0.1 10.0 -> -1
-dqcom455 compare 100 1.0 -> 1
-dqcom456 compare 1.0 100 -> -1
-dqcom457 compare 1000 10.0 -> 1
-dqcom458 compare 10.0 1000 -> -1
-dqcom459 compare 10000 100.0 -> 1
-dqcom460 compare 100.0 10000 -> -1
-dqcom461 compare 100000 1000.0 -> 1
-dqcom462 compare 1000.0 100000 -> -1
-dqcom463 compare 1000000 10000.0 -> 1
-dqcom464 compare 10000.0 1000000 -> -1
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-dqcom473 compare 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
-dqcom474 compare 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
-dqcom475 compare 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
-dqcom476 compare 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
-dqcom477 compare 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
-dqcom478 compare 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
-dqcom479 compare 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
-dqcom480 compare 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
-dqcom481 compare 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
-dqcom482 compare 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
-dqcom483 compare 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
-dqcom487 compare 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
-dqcom488 compare 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
-dqcom489 compare 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
-dqcom490 compare 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
-dqcom491 compare 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
-dqcom492 compare 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
-dqcom493 compare 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
-dqcom494 compare 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
-dqcom495 compare 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
-dqcom496 compare 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
-dqcom497 compare 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-dqcom500 compare 1 1E-15 -> 1
-dqcom501 compare 1 1E-14 -> 1
-dqcom502 compare 1 1E-13 -> 1
-dqcom503 compare 1 1E-12 -> 1
-dqcom504 compare 1 1E-11 -> 1
-dqcom505 compare 1 1E-10 -> 1
-dqcom506 compare 1 1E-9 -> 1
-dqcom507 compare 1 1E-8 -> 1
-dqcom508 compare 1 1E-7 -> 1
-dqcom509 compare 1 1E-6 -> 1
-dqcom510 compare 1 1E-5 -> 1
-dqcom511 compare 1 1E-4 -> 1
-dqcom512 compare 1 1E-3 -> 1
-dqcom513 compare 1 1E-2 -> 1
-dqcom514 compare 1 1E-1 -> 1
-dqcom515 compare 1 1E-0 -> 0
-dqcom516 compare 1 1E+1 -> -1
-dqcom517 compare 1 1E+2 -> -1
-dqcom518 compare 1 1E+3 -> -1
-dqcom519 compare 1 1E+4 -> -1
-dqcom521 compare 1 1E+5 -> -1
-dqcom522 compare 1 1E+6 -> -1
-dqcom523 compare 1 1E+7 -> -1
-dqcom524 compare 1 1E+8 -> -1
-dqcom525 compare 1 1E+9 -> -1
-dqcom526 compare 1 1E+10 -> -1
-dqcom527 compare 1 1E+11 -> -1
-dqcom528 compare 1 1E+12 -> -1
-dqcom529 compare 1 1E+13 -> -1
-dqcom530 compare 1 1E+14 -> -1
-dqcom531 compare 1 1E+15 -> -1
--- LR swap
-dqcom540 compare 1E-15 1 -> -1
-dqcom541 compare 1E-14 1 -> -1
-dqcom542 compare 1E-13 1 -> -1
-dqcom543 compare 1E-12 1 -> -1
-dqcom544 compare 1E-11 1 -> -1
-dqcom545 compare 1E-10 1 -> -1
-dqcom546 compare 1E-9 1 -> -1
-dqcom547 compare 1E-8 1 -> -1
-dqcom548 compare 1E-7 1 -> -1
-dqcom549 compare 1E-6 1 -> -1
-dqcom550 compare 1E-5 1 -> -1
-dqcom551 compare 1E-4 1 -> -1
-dqcom552 compare 1E-3 1 -> -1
-dqcom553 compare 1E-2 1 -> -1
-dqcom554 compare 1E-1 1 -> -1
-dqcom555 compare 1E-0 1 -> 0
-dqcom556 compare 1E+1 1 -> 1
-dqcom557 compare 1E+2 1 -> 1
-dqcom558 compare 1E+3 1 -> 1
-dqcom559 compare 1E+4 1 -> 1
-dqcom561 compare 1E+5 1 -> 1
-dqcom562 compare 1E+6 1 -> 1
-dqcom563 compare 1E+7 1 -> 1
-dqcom564 compare 1E+8 1 -> 1
-dqcom565 compare 1E+9 1 -> 1
-dqcom566 compare 1E+10 1 -> 1
-dqcom567 compare 1E+11 1 -> 1
-dqcom568 compare 1E+12 1 -> 1
-dqcom569 compare 1E+13 1 -> 1
-dqcom570 compare 1E+14 1 -> 1
-dqcom571 compare 1E+15 1 -> 1
--- similar with a useful coefficient, one side only
-dqcom580 compare 0.000000987654321 1E-15 -> 1
-dqcom581 compare 0.000000987654321 1E-14 -> 1
-dqcom582 compare 0.000000987654321 1E-13 -> 1
-dqcom583 compare 0.000000987654321 1E-12 -> 1
-dqcom584 compare 0.000000987654321 1E-11 -> 1
-dqcom585 compare 0.000000987654321 1E-10 -> 1
-dqcom586 compare 0.000000987654321 1E-9 -> 1
-dqcom587 compare 0.000000987654321 1E-8 -> 1
-dqcom588 compare 0.000000987654321 1E-7 -> 1
-dqcom589 compare 0.000000987654321 1E-6 -> -1
-dqcom590 compare 0.000000987654321 1E-5 -> -1
-dqcom591 compare 0.000000987654321 1E-4 -> -1
-dqcom592 compare 0.000000987654321 1E-3 -> -1
-dqcom593 compare 0.000000987654321 1E-2 -> -1
-dqcom594 compare 0.000000987654321 1E-1 -> -1
-dqcom595 compare 0.000000987654321 1E-0 -> -1
-dqcom596 compare 0.000000987654321 1E+1 -> -1
-dqcom597 compare 0.000000987654321 1E+2 -> -1
-dqcom598 compare 0.000000987654321 1E+3 -> -1
-dqcom599 compare 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-dqcom600 compare 12 12.2345 -> -1
-dqcom601 compare 12.0 12.2345 -> -1
-dqcom602 compare 12.00 12.2345 -> -1
-dqcom603 compare 12.000 12.2345 -> -1
-dqcom604 compare 12.0000 12.2345 -> -1
-dqcom605 compare 12.00000 12.2345 -> -1
-dqcom606 compare 12.000000 12.2345 -> -1
-dqcom607 compare 12.0000000 12.2345 -> -1
-dqcom608 compare 12.00000000 12.2345 -> -1
-dqcom609 compare 12.000000000 12.2345 -> -1
-dqcom610 compare 12.1234 12 -> 1
-dqcom611 compare 12.1234 12.0 -> 1
-dqcom612 compare 12.1234 12.00 -> 1
-dqcom613 compare 12.1234 12.000 -> 1
-dqcom614 compare 12.1234 12.0000 -> 1
-dqcom615 compare 12.1234 12.00000 -> 1
-dqcom616 compare 12.1234 12.000000 -> 1
-dqcom617 compare 12.1234 12.0000000 -> 1
-dqcom618 compare 12.1234 12.00000000 -> 1
-dqcom619 compare 12.1234 12.000000000 -> 1
-dqcom620 compare -12 -12.2345 -> 1
-dqcom621 compare -12.0 -12.2345 -> 1
-dqcom622 compare -12.00 -12.2345 -> 1
-dqcom623 compare -12.000 -12.2345 -> 1
-dqcom624 compare -12.0000 -12.2345 -> 1
-dqcom625 compare -12.00000 -12.2345 -> 1
-dqcom626 compare -12.000000 -12.2345 -> 1
-dqcom627 compare -12.0000000 -12.2345 -> 1
-dqcom628 compare -12.00000000 -12.2345 -> 1
-dqcom629 compare -12.000000000 -12.2345 -> 1
-dqcom630 compare -12.1234 -12 -> -1
-dqcom631 compare -12.1234 -12.0 -> -1
-dqcom632 compare -12.1234 -12.00 -> -1
-dqcom633 compare -12.1234 -12.000 -> -1
-dqcom634 compare -12.1234 -12.0000 -> -1
-dqcom635 compare -12.1234 -12.00000 -> -1
-dqcom636 compare -12.1234 -12.000000 -> -1
-dqcom637 compare -12.1234 -12.0000000 -> -1
-dqcom638 compare -12.1234 -12.00000000 -> -1
-dqcom639 compare -12.1234 -12.000000000 -> -1
-
--- extended zeros
-dqcom640 compare 0 0 -> 0
-dqcom641 compare 0 -0 -> 0
-dqcom642 compare 0 -0.0 -> 0
-dqcom643 compare 0 0.0 -> 0
-dqcom644 compare -0 0 -> 0
-dqcom645 compare -0 -0 -> 0
-dqcom646 compare -0 -0.0 -> 0
-dqcom647 compare -0 0.0 -> 0
-dqcom648 compare 0.0 0 -> 0
-dqcom649 compare 0.0 -0 -> 0
-dqcom650 compare 0.0 -0.0 -> 0
-dqcom651 compare 0.0 0.0 -> 0
-dqcom652 compare -0.0 0 -> 0
-dqcom653 compare -0.0 -0 -> 0
-dqcom654 compare -0.0 -0.0 -> 0
-dqcom655 compare -0.0 0.0 -> 0
-
-dqcom656 compare -0E1 0.0 -> 0
-dqcom657 compare -0E2 0.0 -> 0
-dqcom658 compare 0E1 0.0 -> 0
-dqcom659 compare 0E2 0.0 -> 0
-dqcom660 compare -0E1 0 -> 0
-dqcom661 compare -0E2 0 -> 0
-dqcom662 compare 0E1 0 -> 0
-dqcom663 compare 0E2 0 -> 0
-dqcom664 compare -0E1 -0E1 -> 0
-dqcom665 compare -0E2 -0E1 -> 0
-dqcom666 compare 0E1 -0E1 -> 0
-dqcom667 compare 0E2 -0E1 -> 0
-dqcom668 compare -0E1 -0E2 -> 0
-dqcom669 compare -0E2 -0E2 -> 0
-dqcom670 compare 0E1 -0E2 -> 0
-dqcom671 compare 0E2 -0E2 -> 0
-dqcom672 compare -0E1 0E1 -> 0
-dqcom673 compare -0E2 0E1 -> 0
-dqcom674 compare 0E1 0E1 -> 0
-dqcom675 compare 0E2 0E1 -> 0
-dqcom676 compare -0E1 0E2 -> 0
-dqcom677 compare -0E2 0E2 -> 0
-dqcom678 compare 0E1 0E2 -> 0
-dqcom679 compare 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-dqcom680 compare 12 12 -> 0
-dqcom681 compare 12 12.0 -> 0
-dqcom682 compare 12 12.00 -> 0
-dqcom683 compare 12 12.000 -> 0
-dqcom684 compare 12 12.0000 -> 0
-dqcom685 compare 12 12.00000 -> 0
-dqcom686 compare 12 12.000000 -> 0
-dqcom687 compare 12 12.0000000 -> 0
-dqcom688 compare 12 12.00000000 -> 0
-dqcom689 compare 12 12.000000000 -> 0
-dqcom690 compare 12 12 -> 0
-dqcom691 compare 12.0 12 -> 0
-dqcom692 compare 12.00 12 -> 0
-dqcom693 compare 12.000 12 -> 0
-dqcom694 compare 12.0000 12 -> 0
-dqcom695 compare 12.00000 12 -> 0
-dqcom696 compare 12.000000 12 -> 0
-dqcom697 compare 12.0000000 12 -> 0
-dqcom698 compare 12.00000000 12 -> 0
-dqcom699 compare 12.000000000 12 -> 0
-
--- first, second, & last digit
-dqcom700 compare 1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
-dqcom701 compare 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
-dqcom702 compare 1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
-dqcom703 compare 1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
-dqcom704 compare 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
-dqcom705 compare 1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
-dqcom706 compare 1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
-dqcom707 compare 1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
-dqcom708 compare 1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1
-
--- miscellaneous
-dqcom721 compare 12345678000 1 -> 1
-dqcom722 compare 1 12345678000 -> -1
-dqcom723 compare 1234567800 1 -> 1
-dqcom724 compare 1 1234567800 -> -1
-dqcom725 compare 1234567890 1 -> 1
-dqcom726 compare 1 1234567890 -> -1
-dqcom727 compare 1234567891 1 -> 1
-dqcom728 compare 1 1234567891 -> -1
-dqcom729 compare 12345678901 1 -> 1
-dqcom730 compare 1 12345678901 -> -1
-dqcom731 compare 1234567896 1 -> 1
-dqcom732 compare 1 1234567896 -> -1
-
--- residue cases at lower precision
-dqcom740 compare 1 0.9999999 -> 1
-dqcom741 compare 1 0.999999 -> 1
-dqcom742 compare 1 0.99999 -> 1
-dqcom743 compare 1 1.0000 -> 0
-dqcom744 compare 1 1.00001 -> -1
-dqcom745 compare 1 1.000001 -> -1
-dqcom746 compare 1 1.0000001 -> -1
-dqcom750 compare 0.9999999 1 -> -1
-dqcom751 compare 0.999999 1 -> -1
-dqcom752 compare 0.99999 1 -> -1
-dqcom753 compare 1.0000 1 -> 0
-dqcom754 compare 1.00001 1 -> 1
-dqcom755 compare 1.000001 1 -> 1
-dqcom756 compare 1.0000001 1 -> 1
-
--- Specials
-dqcom780 compare Inf -Inf -> 1
-dqcom781 compare Inf -1000 -> 1
-dqcom782 compare Inf -1 -> 1
-dqcom783 compare Inf -0 -> 1
-dqcom784 compare Inf 0 -> 1
-dqcom785 compare Inf 1 -> 1
-dqcom786 compare Inf 1000 -> 1
-dqcom787 compare Inf Inf -> 0
-dqcom788 compare -1000 Inf -> -1
-dqcom789 compare -Inf Inf -> -1
-dqcom790 compare -1 Inf -> -1
-dqcom791 compare -0 Inf -> -1
-dqcom792 compare 0 Inf -> -1
-dqcom793 compare 1 Inf -> -1
-dqcom794 compare 1000 Inf -> -1
-dqcom795 compare Inf Inf -> 0
-
-dqcom800 compare -Inf -Inf -> 0
-dqcom801 compare -Inf -1000 -> -1
-dqcom802 compare -Inf -1 -> -1
-dqcom803 compare -Inf -0 -> -1
-dqcom804 compare -Inf 0 -> -1
-dqcom805 compare -Inf 1 -> -1
-dqcom806 compare -Inf 1000 -> -1
-dqcom807 compare -Inf Inf -> -1
-dqcom808 compare -Inf -Inf -> 0
-dqcom809 compare -1000 -Inf -> 1
-dqcom810 compare -1 -Inf -> 1
-dqcom811 compare -0 -Inf -> 1
-dqcom812 compare 0 -Inf -> 1
-dqcom813 compare 1 -Inf -> 1
-dqcom814 compare 1000 -Inf -> 1
-dqcom815 compare Inf -Inf -> 1
-
-dqcom821 compare NaN -Inf -> NaN
-dqcom822 compare NaN -1000 -> NaN
-dqcom823 compare NaN -1 -> NaN
-dqcom824 compare NaN -0 -> NaN
-dqcom825 compare NaN 0 -> NaN
-dqcom826 compare NaN 1 -> NaN
-dqcom827 compare NaN 1000 -> NaN
-dqcom828 compare NaN Inf -> NaN
-dqcom829 compare NaN NaN -> NaN
-dqcom830 compare -Inf NaN -> NaN
-dqcom831 compare -1000 NaN -> NaN
-dqcom832 compare -1 NaN -> NaN
-dqcom833 compare -0 NaN -> NaN
-dqcom834 compare 0 NaN -> NaN
-dqcom835 compare 1 NaN -> NaN
-dqcom836 compare 1000 NaN -> NaN
-dqcom837 compare Inf NaN -> NaN
-dqcom838 compare -NaN -NaN -> -NaN
-dqcom839 compare +NaN -NaN -> NaN
-dqcom840 compare -NaN +NaN -> -NaN
-
-dqcom841 compare sNaN -Inf -> NaN Invalid_operation
-dqcom842 compare sNaN -1000 -> NaN Invalid_operation
-dqcom843 compare sNaN -1 -> NaN Invalid_operation
-dqcom844 compare sNaN -0 -> NaN Invalid_operation
-dqcom845 compare sNaN 0 -> NaN Invalid_operation
-dqcom846 compare sNaN 1 -> NaN Invalid_operation
-dqcom847 compare sNaN 1000 -> NaN Invalid_operation
-dqcom848 compare sNaN NaN -> NaN Invalid_operation
-dqcom849 compare sNaN sNaN -> NaN Invalid_operation
-dqcom850 compare NaN sNaN -> NaN Invalid_operation
-dqcom851 compare -Inf sNaN -> NaN Invalid_operation
-dqcom852 compare -1000 sNaN -> NaN Invalid_operation
-dqcom853 compare -1 sNaN -> NaN Invalid_operation
-dqcom854 compare -0 sNaN -> NaN Invalid_operation
-dqcom855 compare 0 sNaN -> NaN Invalid_operation
-dqcom856 compare 1 sNaN -> NaN Invalid_operation
-dqcom857 compare 1000 sNaN -> NaN Invalid_operation
-dqcom858 compare Inf sNaN -> NaN Invalid_operation
-dqcom859 compare NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqcom860 compare NaN9 -Inf -> NaN9
-dqcom861 compare NaN8 999 -> NaN8
-dqcom862 compare NaN77 Inf -> NaN77
-dqcom863 compare -NaN67 NaN5 -> -NaN67
-dqcom864 compare -Inf -NaN4 -> -NaN4
-dqcom865 compare -999 -NaN33 -> -NaN33
-dqcom866 compare Inf NaN2 -> NaN2
-dqcom867 compare -NaN41 -NaN42 -> -NaN41
-dqcom868 compare +NaN41 -NaN42 -> NaN41
-dqcom869 compare -NaN41 +NaN42 -> -NaN41
-dqcom870 compare +NaN41 +NaN42 -> NaN41
-
-dqcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
-dqcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
-dqcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
-dqcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
-dqcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
-dqcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
-dqcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
-dqcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- wide range
-dqcom880 compare +1.23456789012345E-0 9E+6144 -> -1
-dqcom881 compare 9E+6144 +1.23456789012345E-0 -> 1
-dqcom882 compare +0.100 9E-6143 -> 1
-dqcom883 compare 9E-6143 +0.100 -> -1
-dqcom885 compare -1.23456789012345E-0 9E+6144 -> -1
-dqcom886 compare 9E+6144 -1.23456789012345E-0 -> 1
-dqcom887 compare -0.100 9E-6143 -> -1
-dqcom888 compare 9E-6143 -0.100 -> 1
-
--- signs
-dqcom901 compare 1e+77 1e+11 -> 1
-dqcom902 compare 1e+77 -1e+11 -> 1
-dqcom903 compare -1e+77 1e+11 -> -1
-dqcom904 compare -1e+77 -1e+11 -> -1
-dqcom905 compare 1e-77 1e-11 -> -1
-dqcom906 compare 1e-77 -1e-11 -> 1
-dqcom907 compare -1e-77 1e-11 -> -1
-dqcom908 compare -1e-77 -1e-11 -> 1
-
--- full alignment range, both ways
-dqcomp1001 compare 1 1.000000000000000000000000000000000 -> 0
-dqcomp1002 compare 1 1.00000000000000000000000000000000 -> 0
-dqcomp1003 compare 1 1.0000000000000000000000000000000 -> 0
-dqcomp1004 compare 1 1.000000000000000000000000000000 -> 0
-dqcomp1005 compare 1 1.00000000000000000000000000000 -> 0
-dqcomp1006 compare 1 1.0000000000000000000000000000 -> 0
-dqcomp1007 compare 1 1.000000000000000000000000000 -> 0
-dqcomp1008 compare 1 1.00000000000000000000000000 -> 0
-dqcomp1009 compare 1 1.0000000000000000000000000 -> 0
-dqcomp1010 compare 1 1.000000000000000000000000 -> 0
-dqcomp1011 compare 1 1.00000000000000000000000 -> 0
-dqcomp1012 compare 1 1.0000000000000000000000 -> 0
-dqcomp1013 compare 1 1.000000000000000000000 -> 0
-dqcomp1014 compare 1 1.00000000000000000000 -> 0
-dqcomp1015 compare 1 1.0000000000000000000 -> 0
-dqcomp1016 compare 1 1.000000000000000000 -> 0
-dqcomp1017 compare 1 1.00000000000000000 -> 0
-dqcomp1018 compare 1 1.0000000000000000 -> 0
-dqcomp1019 compare 1 1.000000000000000 -> 0
-dqcomp1020 compare 1 1.00000000000000 -> 0
-dqcomp1021 compare 1 1.0000000000000 -> 0
-dqcomp1022 compare 1 1.000000000000 -> 0
-dqcomp1023 compare 1 1.00000000000 -> 0
-dqcomp1024 compare 1 1.0000000000 -> 0
-dqcomp1025 compare 1 1.000000000 -> 0
-dqcomp1026 compare 1 1.00000000 -> 0
-dqcomp1027 compare 1 1.0000000 -> 0
-dqcomp1028 compare 1 1.000000 -> 0
-dqcomp1029 compare 1 1.00000 -> 0
-dqcomp1030 compare 1 1.0000 -> 0
-dqcomp1031 compare 1 1.000 -> 0
-dqcomp1032 compare 1 1.00 -> 0
-dqcomp1033 compare 1 1.0 -> 0
-
-dqcomp1041 compare 1.000000000000000000000000000000000 1 -> 0
-dqcomp1042 compare 1.00000000000000000000000000000000 1 -> 0
-dqcomp1043 compare 1.0000000000000000000000000000000 1 -> 0
-dqcomp1044 compare 1.000000000000000000000000000000 1 -> 0
-dqcomp1045 compare 1.00000000000000000000000000000 1 -> 0
-dqcomp1046 compare 1.0000000000000000000000000000 1 -> 0
-dqcomp1047 compare 1.000000000000000000000000000 1 -> 0
-dqcomp1048 compare 1.00000000000000000000000000 1 -> 0
-dqcomp1049 compare 1.0000000000000000000000000 1 -> 0
-dqcomp1050 compare 1.000000000000000000000000 1 -> 0
-dqcomp1051 compare 1.00000000000000000000000 1 -> 0
-dqcomp1052 compare 1.0000000000000000000000 1 -> 0
-dqcomp1053 compare 1.000000000000000000000 1 -> 0
-dqcomp1054 compare 1.00000000000000000000 1 -> 0
-dqcomp1055 compare 1.0000000000000000000 1 -> 0
-dqcomp1056 compare 1.000000000000000000 1 -> 0
-dqcomp1057 compare 1.00000000000000000 1 -> 0
-dqcomp1058 compare 1.0000000000000000 1 -> 0
-dqcomp1059 compare 1.000000000000000 1 -> 0
-dqcomp1060 compare 1.00000000000000 1 -> 0
-dqcomp1061 compare 1.0000000000000 1 -> 0
-dqcomp1062 compare 1.000000000000 1 -> 0
-dqcomp1063 compare 1.00000000000 1 -> 0
-dqcomp1064 compare 1.0000000000 1 -> 0
-dqcomp1065 compare 1.000000000 1 -> 0
-dqcomp1066 compare 1.00000000 1 -> 0
-dqcomp1067 compare 1.0000000 1 -> 0
-dqcomp1068 compare 1.000000 1 -> 0
-dqcomp1069 compare 1.00000 1 -> 0
-dqcomp1070 compare 1.0000 1 -> 0
-dqcomp1071 compare 1.000 1 -> 0
-dqcomp1072 compare 1.00 1 -> 0
-dqcomp1073 compare 1.0 1 -> 0
-
--- check MSD always detected non-zero
-dqcomp1080 compare 0 0.000000000000000000000000000000000 -> 0
-dqcomp1081 compare 0 1.000000000000000000000000000000000 -> -1
-dqcomp1082 compare 0 2.000000000000000000000000000000000 -> -1
-dqcomp1083 compare 0 3.000000000000000000000000000000000 -> -1
-dqcomp1084 compare 0 4.000000000000000000000000000000000 -> -1
-dqcomp1085 compare 0 5.000000000000000000000000000000000 -> -1
-dqcomp1086 compare 0 6.000000000000000000000000000000000 -> -1
-dqcomp1087 compare 0 7.000000000000000000000000000000000 -> -1
-dqcomp1088 compare 0 8.000000000000000000000000000000000 -> -1
-dqcomp1089 compare 0 9.000000000000000000000000000000000 -> -1
-dqcomp1090 compare 0.000000000000000000000000000000000 0 -> 0
-dqcomp1091 compare 1.000000000000000000000000000000000 0 -> 1
-dqcomp1092 compare 2.000000000000000000000000000000000 0 -> 1
-dqcomp1093 compare 3.000000000000000000000000000000000 0 -> 1
-dqcomp1094 compare 4.000000000000000000000000000000000 0 -> 1
-dqcomp1095 compare 5.000000000000000000000000000000000 0 -> 1
-dqcomp1096 compare 6.000000000000000000000000000000000 0 -> 1
-dqcomp1097 compare 7.000000000000000000000000000000000 0 -> 1
-dqcomp1098 compare 8.000000000000000000000000000000000 0 -> 1
-dqcomp1099 compare 9.000000000000000000000000000000000 0 -> 1
-
--- Null tests
-dqcom990 compare 10 # -> NaN Invalid_operation
-dqcom991 compare # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqCompare.decTest -- decQuad comparison that allows quiet NaNs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqcom001 compare -2 -2 -> 0
+dqcom002 compare -2 -1 -> -1
+dqcom003 compare -2 0 -> -1
+dqcom004 compare -2 1 -> -1
+dqcom005 compare -2 2 -> -1
+dqcom006 compare -1 -2 -> 1
+dqcom007 compare -1 -1 -> 0
+dqcom008 compare -1 0 -> -1
+dqcom009 compare -1 1 -> -1
+dqcom010 compare -1 2 -> -1
+dqcom011 compare 0 -2 -> 1
+dqcom012 compare 0 -1 -> 1
+dqcom013 compare 0 0 -> 0
+dqcom014 compare 0 1 -> -1
+dqcom015 compare 0 2 -> -1
+dqcom016 compare 1 -2 -> 1
+dqcom017 compare 1 -1 -> 1
+dqcom018 compare 1 0 -> 1
+dqcom019 compare 1 1 -> 0
+dqcom020 compare 1 2 -> -1
+dqcom021 compare 2 -2 -> 1
+dqcom022 compare 2 -1 -> 1
+dqcom023 compare 2 0 -> 1
+dqcom025 compare 2 1 -> 1
+dqcom026 compare 2 2 -> 0
+
+dqcom031 compare -20 -20 -> 0
+dqcom032 compare -20 -10 -> -1
+dqcom033 compare -20 00 -> -1
+dqcom034 compare -20 10 -> -1
+dqcom035 compare -20 20 -> -1
+dqcom036 compare -10 -20 -> 1
+dqcom037 compare -10 -10 -> 0
+dqcom038 compare -10 00 -> -1
+dqcom039 compare -10 10 -> -1
+dqcom040 compare -10 20 -> -1
+dqcom041 compare 00 -20 -> 1
+dqcom042 compare 00 -10 -> 1
+dqcom043 compare 00 00 -> 0
+dqcom044 compare 00 10 -> -1
+dqcom045 compare 00 20 -> -1
+dqcom046 compare 10 -20 -> 1
+dqcom047 compare 10 -10 -> 1
+dqcom048 compare 10 00 -> 1
+dqcom049 compare 10 10 -> 0
+dqcom050 compare 10 20 -> -1
+dqcom051 compare 20 -20 -> 1
+dqcom052 compare 20 -10 -> 1
+dqcom053 compare 20 00 -> 1
+dqcom055 compare 20 10 -> 1
+dqcom056 compare 20 20 -> 0
+
+dqcom061 compare -2.0 -2.0 -> 0
+dqcom062 compare -2.0 -1.0 -> -1
+dqcom063 compare -2.0 0.0 -> -1
+dqcom064 compare -2.0 1.0 -> -1
+dqcom065 compare -2.0 2.0 -> -1
+dqcom066 compare -1.0 -2.0 -> 1
+dqcom067 compare -1.0 -1.0 -> 0
+dqcom068 compare -1.0 0.0 -> -1
+dqcom069 compare -1.0 1.0 -> -1
+dqcom070 compare -1.0 2.0 -> -1
+dqcom071 compare 0.0 -2.0 -> 1
+dqcom072 compare 0.0 -1.0 -> 1
+dqcom073 compare 0.0 0.0 -> 0
+dqcom074 compare 0.0 1.0 -> -1
+dqcom075 compare 0.0 2.0 -> -1
+dqcom076 compare 1.0 -2.0 -> 1
+dqcom077 compare 1.0 -1.0 -> 1
+dqcom078 compare 1.0 0.0 -> 1
+dqcom079 compare 1.0 1.0 -> 0
+dqcom080 compare 1.0 2.0 -> -1
+dqcom081 compare 2.0 -2.0 -> 1
+dqcom082 compare 2.0 -1.0 -> 1
+dqcom083 compare 2.0 0.0 -> 1
+dqcom085 compare 2.0 1.0 -> 1
+dqcom086 compare 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+dqcom090 compare 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 0
+dqcom091 compare -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> -1
+dqcom092 compare 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
+dqcom093 compare -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0
+
+-- some differing length/exponent cases
+dqcom100 compare 7.0 7.0 -> 0
+dqcom101 compare 7.0 7 -> 0
+dqcom102 compare 7 7.0 -> 0
+dqcom103 compare 7E+0 7.0 -> 0
+dqcom104 compare 70E-1 7.0 -> 0
+dqcom105 compare 0.7E+1 7 -> 0
+dqcom106 compare 70E-1 7 -> 0
+dqcom107 compare 7.0 7E+0 -> 0
+dqcom108 compare 7.0 70E-1 -> 0
+dqcom109 compare 7 0.7E+1 -> 0
+dqcom110 compare 7 70E-1 -> 0
+
+dqcom120 compare 8.0 7.0 -> 1
+dqcom121 compare 8.0 7 -> 1
+dqcom122 compare 8 7.0 -> 1
+dqcom123 compare 8E+0 7.0 -> 1
+dqcom124 compare 80E-1 7.0 -> 1
+dqcom125 compare 0.8E+1 7 -> 1
+dqcom126 compare 80E-1 7 -> 1
+dqcom127 compare 8.0 7E+0 -> 1
+dqcom128 compare 8.0 70E-1 -> 1
+dqcom129 compare 8 0.7E+1 -> 1
+dqcom130 compare 8 70E-1 -> 1
+
+dqcom140 compare 8.0 9.0 -> -1
+dqcom141 compare 8.0 9 -> -1
+dqcom142 compare 8 9.0 -> -1
+dqcom143 compare 8E+0 9.0 -> -1
+dqcom144 compare 80E-1 9.0 -> -1
+dqcom145 compare 0.8E+1 9 -> -1
+dqcom146 compare 80E-1 9 -> -1
+dqcom147 compare 8.0 9E+0 -> -1
+dqcom148 compare 8.0 90E-1 -> -1
+dqcom149 compare 8 0.9E+1 -> -1
+dqcom150 compare 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+dqcom200 compare -7.0 7.0 -> -1
+dqcom201 compare -7.0 7 -> -1
+dqcom202 compare -7 7.0 -> -1
+dqcom203 compare -7E+0 7.0 -> -1
+dqcom204 compare -70E-1 7.0 -> -1
+dqcom205 compare -0.7E+1 7 -> -1
+dqcom206 compare -70E-1 7 -> -1
+dqcom207 compare -7.0 7E+0 -> -1
+dqcom208 compare -7.0 70E-1 -> -1
+dqcom209 compare -7 0.7E+1 -> -1
+dqcom210 compare -7 70E-1 -> -1
+
+dqcom220 compare -8.0 7.0 -> -1
+dqcom221 compare -8.0 7 -> -1
+dqcom222 compare -8 7.0 -> -1
+dqcom223 compare -8E+0 7.0 -> -1
+dqcom224 compare -80E-1 7.0 -> -1
+dqcom225 compare -0.8E+1 7 -> -1
+dqcom226 compare -80E-1 7 -> -1
+dqcom227 compare -8.0 7E+0 -> -1
+dqcom228 compare -8.0 70E-1 -> -1
+dqcom229 compare -8 0.7E+1 -> -1
+dqcom230 compare -8 70E-1 -> -1
+
+dqcom240 compare -8.0 9.0 -> -1
+dqcom241 compare -8.0 9 -> -1
+dqcom242 compare -8 9.0 -> -1
+dqcom243 compare -8E+0 9.0 -> -1
+dqcom244 compare -80E-1 9.0 -> -1
+dqcom245 compare -0.8E+1 9 -> -1
+dqcom246 compare -80E-1 9 -> -1
+dqcom247 compare -8.0 9E+0 -> -1
+dqcom248 compare -8.0 90E-1 -> -1
+dqcom249 compare -8 0.9E+1 -> -1
+dqcom250 compare -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+dqcom300 compare 7.0 -7.0 -> 1
+dqcom301 compare 7.0 -7 -> 1
+dqcom302 compare 7 -7.0 -> 1
+dqcom303 compare 7E+0 -7.0 -> 1
+dqcom304 compare 70E-1 -7.0 -> 1
+dqcom305 compare .7E+1 -7 -> 1
+dqcom306 compare 70E-1 -7 -> 1
+dqcom307 compare 7.0 -7E+0 -> 1
+dqcom308 compare 7.0 -70E-1 -> 1
+dqcom309 compare 7 -.7E+1 -> 1
+dqcom310 compare 7 -70E-1 -> 1
+
+dqcom320 compare 8.0 -7.0 -> 1
+dqcom321 compare 8.0 -7 -> 1
+dqcom322 compare 8 -7.0 -> 1
+dqcom323 compare 8E+0 -7.0 -> 1
+dqcom324 compare 80E-1 -7.0 -> 1
+dqcom325 compare .8E+1 -7 -> 1
+dqcom326 compare 80E-1 -7 -> 1
+dqcom327 compare 8.0 -7E+0 -> 1
+dqcom328 compare 8.0 -70E-1 -> 1
+dqcom329 compare 8 -.7E+1 -> 1
+dqcom330 compare 8 -70E-1 -> 1
+
+dqcom340 compare 8.0 -9.0 -> 1
+dqcom341 compare 8.0 -9 -> 1
+dqcom342 compare 8 -9.0 -> 1
+dqcom343 compare 8E+0 -9.0 -> 1
+dqcom344 compare 80E-1 -9.0 -> 1
+dqcom345 compare .8E+1 -9 -> 1
+dqcom346 compare 80E-1 -9 -> 1
+dqcom347 compare 8.0 -9E+0 -> 1
+dqcom348 compare 8.0 -90E-1 -> 1
+dqcom349 compare 8 -.9E+1 -> 1
+dqcom350 compare 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+dqcom400 compare -7.0 -7.0 -> 0
+dqcom401 compare -7.0 -7 -> 0
+dqcom402 compare -7 -7.0 -> 0
+dqcom403 compare -7E+0 -7.0 -> 0
+dqcom404 compare -70E-1 -7.0 -> 0
+dqcom405 compare -.7E+1 -7 -> 0
+dqcom406 compare -70E-1 -7 -> 0
+dqcom407 compare -7.0 -7E+0 -> 0
+dqcom408 compare -7.0 -70E-1 -> 0
+dqcom409 compare -7 -.7E+1 -> 0
+dqcom410 compare -7 -70E-1 -> 0
+
+dqcom420 compare -8.0 -7.0 -> -1
+dqcom421 compare -8.0 -7 -> -1
+dqcom422 compare -8 -7.0 -> -1
+dqcom423 compare -8E+0 -7.0 -> -1
+dqcom424 compare -80E-1 -7.0 -> -1
+dqcom425 compare -.8E+1 -7 -> -1
+dqcom426 compare -80E-1 -7 -> -1
+dqcom427 compare -8.0 -7E+0 -> -1
+dqcom428 compare -8.0 -70E-1 -> -1
+dqcom429 compare -8 -.7E+1 -> -1
+dqcom430 compare -8 -70E-1 -> -1
+
+dqcom440 compare -8.0 -9.0 -> 1
+dqcom441 compare -8.0 -9 -> 1
+dqcom442 compare -8 -9.0 -> 1
+dqcom443 compare -8E+0 -9.0 -> 1
+dqcom444 compare -80E-1 -9.0 -> 1
+dqcom445 compare -.8E+1 -9 -> 1
+dqcom446 compare -80E-1 -9 -> 1
+dqcom447 compare -8.0 -9E+0 -> 1
+dqcom448 compare -8.0 -90E-1 -> 1
+dqcom449 compare -8 -.9E+1 -> 1
+dqcom450 compare -8 -90E-1 -> 1
+
+-- misalignment traps for little-endian
+dqcom451 compare 1.0 0.1 -> 1
+dqcom452 compare 0.1 1.0 -> -1
+dqcom453 compare 10.0 0.1 -> 1
+dqcom454 compare 0.1 10.0 -> -1
+dqcom455 compare 100 1.0 -> 1
+dqcom456 compare 1.0 100 -> -1
+dqcom457 compare 1000 10.0 -> 1
+dqcom458 compare 10.0 1000 -> -1
+dqcom459 compare 10000 100.0 -> 1
+dqcom460 compare 100.0 10000 -> -1
+dqcom461 compare 100000 1000.0 -> 1
+dqcom462 compare 1000.0 100000 -> -1
+dqcom463 compare 1000000 10000.0 -> 1
+dqcom464 compare 10000.0 1000000 -> -1
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+dqcom473 compare 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
+dqcom474 compare 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
+dqcom475 compare 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
+dqcom476 compare 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
+dqcom477 compare 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
+dqcom478 compare 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
+dqcom479 compare 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
+dqcom480 compare 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
+dqcom481 compare 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
+dqcom482 compare 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
+dqcom483 compare 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
+dqcom487 compare 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
+dqcom488 compare 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
+dqcom489 compare 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
+dqcom490 compare 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
+dqcom491 compare 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
+dqcom492 compare 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
+dqcom493 compare 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
+dqcom494 compare 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
+dqcom495 compare 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
+dqcom496 compare 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
+dqcom497 compare 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+dqcom500 compare 1 1E-15 -> 1
+dqcom501 compare 1 1E-14 -> 1
+dqcom502 compare 1 1E-13 -> 1
+dqcom503 compare 1 1E-12 -> 1
+dqcom504 compare 1 1E-11 -> 1
+dqcom505 compare 1 1E-10 -> 1
+dqcom506 compare 1 1E-9 -> 1
+dqcom507 compare 1 1E-8 -> 1
+dqcom508 compare 1 1E-7 -> 1
+dqcom509 compare 1 1E-6 -> 1
+dqcom510 compare 1 1E-5 -> 1
+dqcom511 compare 1 1E-4 -> 1
+dqcom512 compare 1 1E-3 -> 1
+dqcom513 compare 1 1E-2 -> 1
+dqcom514 compare 1 1E-1 -> 1
+dqcom515 compare 1 1E-0 -> 0
+dqcom516 compare 1 1E+1 -> -1
+dqcom517 compare 1 1E+2 -> -1
+dqcom518 compare 1 1E+3 -> -1
+dqcom519 compare 1 1E+4 -> -1
+dqcom521 compare 1 1E+5 -> -1
+dqcom522 compare 1 1E+6 -> -1
+dqcom523 compare 1 1E+7 -> -1
+dqcom524 compare 1 1E+8 -> -1
+dqcom525 compare 1 1E+9 -> -1
+dqcom526 compare 1 1E+10 -> -1
+dqcom527 compare 1 1E+11 -> -1
+dqcom528 compare 1 1E+12 -> -1
+dqcom529 compare 1 1E+13 -> -1
+dqcom530 compare 1 1E+14 -> -1
+dqcom531 compare 1 1E+15 -> -1
+-- LR swap
+dqcom540 compare 1E-15 1 -> -1
+dqcom541 compare 1E-14 1 -> -1
+dqcom542 compare 1E-13 1 -> -1
+dqcom543 compare 1E-12 1 -> -1
+dqcom544 compare 1E-11 1 -> -1
+dqcom545 compare 1E-10 1 -> -1
+dqcom546 compare 1E-9 1 -> -1
+dqcom547 compare 1E-8 1 -> -1
+dqcom548 compare 1E-7 1 -> -1
+dqcom549 compare 1E-6 1 -> -1
+dqcom550 compare 1E-5 1 -> -1
+dqcom551 compare 1E-4 1 -> -1
+dqcom552 compare 1E-3 1 -> -1
+dqcom553 compare 1E-2 1 -> -1
+dqcom554 compare 1E-1 1 -> -1
+dqcom555 compare 1E-0 1 -> 0
+dqcom556 compare 1E+1 1 -> 1
+dqcom557 compare 1E+2 1 -> 1
+dqcom558 compare 1E+3 1 -> 1
+dqcom559 compare 1E+4 1 -> 1
+dqcom561 compare 1E+5 1 -> 1
+dqcom562 compare 1E+6 1 -> 1
+dqcom563 compare 1E+7 1 -> 1
+dqcom564 compare 1E+8 1 -> 1
+dqcom565 compare 1E+9 1 -> 1
+dqcom566 compare 1E+10 1 -> 1
+dqcom567 compare 1E+11 1 -> 1
+dqcom568 compare 1E+12 1 -> 1
+dqcom569 compare 1E+13 1 -> 1
+dqcom570 compare 1E+14 1 -> 1
+dqcom571 compare 1E+15 1 -> 1
+-- similar with a useful coefficient, one side only
+dqcom580 compare 0.000000987654321 1E-15 -> 1
+dqcom581 compare 0.000000987654321 1E-14 -> 1
+dqcom582 compare 0.000000987654321 1E-13 -> 1
+dqcom583 compare 0.000000987654321 1E-12 -> 1
+dqcom584 compare 0.000000987654321 1E-11 -> 1
+dqcom585 compare 0.000000987654321 1E-10 -> 1
+dqcom586 compare 0.000000987654321 1E-9 -> 1
+dqcom587 compare 0.000000987654321 1E-8 -> 1
+dqcom588 compare 0.000000987654321 1E-7 -> 1
+dqcom589 compare 0.000000987654321 1E-6 -> -1
+dqcom590 compare 0.000000987654321 1E-5 -> -1
+dqcom591 compare 0.000000987654321 1E-4 -> -1
+dqcom592 compare 0.000000987654321 1E-3 -> -1
+dqcom593 compare 0.000000987654321 1E-2 -> -1
+dqcom594 compare 0.000000987654321 1E-1 -> -1
+dqcom595 compare 0.000000987654321 1E-0 -> -1
+dqcom596 compare 0.000000987654321 1E+1 -> -1
+dqcom597 compare 0.000000987654321 1E+2 -> -1
+dqcom598 compare 0.000000987654321 1E+3 -> -1
+dqcom599 compare 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+dqcom600 compare 12 12.2345 -> -1
+dqcom601 compare 12.0 12.2345 -> -1
+dqcom602 compare 12.00 12.2345 -> -1
+dqcom603 compare 12.000 12.2345 -> -1
+dqcom604 compare 12.0000 12.2345 -> -1
+dqcom605 compare 12.00000 12.2345 -> -1
+dqcom606 compare 12.000000 12.2345 -> -1
+dqcom607 compare 12.0000000 12.2345 -> -1
+dqcom608 compare 12.00000000 12.2345 -> -1
+dqcom609 compare 12.000000000 12.2345 -> -1
+dqcom610 compare 12.1234 12 -> 1
+dqcom611 compare 12.1234 12.0 -> 1
+dqcom612 compare 12.1234 12.00 -> 1
+dqcom613 compare 12.1234 12.000 -> 1
+dqcom614 compare 12.1234 12.0000 -> 1
+dqcom615 compare 12.1234 12.00000 -> 1
+dqcom616 compare 12.1234 12.000000 -> 1
+dqcom617 compare 12.1234 12.0000000 -> 1
+dqcom618 compare 12.1234 12.00000000 -> 1
+dqcom619 compare 12.1234 12.000000000 -> 1
+dqcom620 compare -12 -12.2345 -> 1
+dqcom621 compare -12.0 -12.2345 -> 1
+dqcom622 compare -12.00 -12.2345 -> 1
+dqcom623 compare -12.000 -12.2345 -> 1
+dqcom624 compare -12.0000 -12.2345 -> 1
+dqcom625 compare -12.00000 -12.2345 -> 1
+dqcom626 compare -12.000000 -12.2345 -> 1
+dqcom627 compare -12.0000000 -12.2345 -> 1
+dqcom628 compare -12.00000000 -12.2345 -> 1
+dqcom629 compare -12.000000000 -12.2345 -> 1
+dqcom630 compare -12.1234 -12 -> -1
+dqcom631 compare -12.1234 -12.0 -> -1
+dqcom632 compare -12.1234 -12.00 -> -1
+dqcom633 compare -12.1234 -12.000 -> -1
+dqcom634 compare -12.1234 -12.0000 -> -1
+dqcom635 compare -12.1234 -12.00000 -> -1
+dqcom636 compare -12.1234 -12.000000 -> -1
+dqcom637 compare -12.1234 -12.0000000 -> -1
+dqcom638 compare -12.1234 -12.00000000 -> -1
+dqcom639 compare -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+dqcom640 compare 0 0 -> 0
+dqcom641 compare 0 -0 -> 0
+dqcom642 compare 0 -0.0 -> 0
+dqcom643 compare 0 0.0 -> 0
+dqcom644 compare -0 0 -> 0
+dqcom645 compare -0 -0 -> 0
+dqcom646 compare -0 -0.0 -> 0
+dqcom647 compare -0 0.0 -> 0
+dqcom648 compare 0.0 0 -> 0
+dqcom649 compare 0.0 -0 -> 0
+dqcom650 compare 0.0 -0.0 -> 0
+dqcom651 compare 0.0 0.0 -> 0
+dqcom652 compare -0.0 0 -> 0
+dqcom653 compare -0.0 -0 -> 0
+dqcom654 compare -0.0 -0.0 -> 0
+dqcom655 compare -0.0 0.0 -> 0
+
+dqcom656 compare -0E1 0.0 -> 0
+dqcom657 compare -0E2 0.0 -> 0
+dqcom658 compare 0E1 0.0 -> 0
+dqcom659 compare 0E2 0.0 -> 0
+dqcom660 compare -0E1 0 -> 0
+dqcom661 compare -0E2 0 -> 0
+dqcom662 compare 0E1 0 -> 0
+dqcom663 compare 0E2 0 -> 0
+dqcom664 compare -0E1 -0E1 -> 0
+dqcom665 compare -0E2 -0E1 -> 0
+dqcom666 compare 0E1 -0E1 -> 0
+dqcom667 compare 0E2 -0E1 -> 0
+dqcom668 compare -0E1 -0E2 -> 0
+dqcom669 compare -0E2 -0E2 -> 0
+dqcom670 compare 0E1 -0E2 -> 0
+dqcom671 compare 0E2 -0E2 -> 0
+dqcom672 compare -0E1 0E1 -> 0
+dqcom673 compare -0E2 0E1 -> 0
+dqcom674 compare 0E1 0E1 -> 0
+dqcom675 compare 0E2 0E1 -> 0
+dqcom676 compare -0E1 0E2 -> 0
+dqcom677 compare -0E2 0E2 -> 0
+dqcom678 compare 0E1 0E2 -> 0
+dqcom679 compare 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+dqcom680 compare 12 12 -> 0
+dqcom681 compare 12 12.0 -> 0
+dqcom682 compare 12 12.00 -> 0
+dqcom683 compare 12 12.000 -> 0
+dqcom684 compare 12 12.0000 -> 0
+dqcom685 compare 12 12.00000 -> 0
+dqcom686 compare 12 12.000000 -> 0
+dqcom687 compare 12 12.0000000 -> 0
+dqcom688 compare 12 12.00000000 -> 0
+dqcom689 compare 12 12.000000000 -> 0
+dqcom690 compare 12 12 -> 0
+dqcom691 compare 12.0 12 -> 0
+dqcom692 compare 12.00 12 -> 0
+dqcom693 compare 12.000 12 -> 0
+dqcom694 compare 12.0000 12 -> 0
+dqcom695 compare 12.00000 12 -> 0
+dqcom696 compare 12.000000 12 -> 0
+dqcom697 compare 12.0000000 12 -> 0
+dqcom698 compare 12.00000000 12 -> 0
+dqcom699 compare 12.000000000 12 -> 0
+
+-- first, second, & last digit
+dqcom700 compare 1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
+dqcom701 compare 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
+dqcom702 compare 1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
+dqcom703 compare 1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
+dqcom704 compare 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
+dqcom705 compare 1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
+dqcom706 compare 1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
+dqcom707 compare 1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
+dqcom708 compare 1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1
+
+-- miscellaneous
+dqcom721 compare 12345678000 1 -> 1
+dqcom722 compare 1 12345678000 -> -1
+dqcom723 compare 1234567800 1 -> 1
+dqcom724 compare 1 1234567800 -> -1
+dqcom725 compare 1234567890 1 -> 1
+dqcom726 compare 1 1234567890 -> -1
+dqcom727 compare 1234567891 1 -> 1
+dqcom728 compare 1 1234567891 -> -1
+dqcom729 compare 12345678901 1 -> 1
+dqcom730 compare 1 12345678901 -> -1
+dqcom731 compare 1234567896 1 -> 1
+dqcom732 compare 1 1234567896 -> -1
+
+-- residue cases at lower precision
+dqcom740 compare 1 0.9999999 -> 1
+dqcom741 compare 1 0.999999 -> 1
+dqcom742 compare 1 0.99999 -> 1
+dqcom743 compare 1 1.0000 -> 0
+dqcom744 compare 1 1.00001 -> -1
+dqcom745 compare 1 1.000001 -> -1
+dqcom746 compare 1 1.0000001 -> -1
+dqcom750 compare 0.9999999 1 -> -1
+dqcom751 compare 0.999999 1 -> -1
+dqcom752 compare 0.99999 1 -> -1
+dqcom753 compare 1.0000 1 -> 0
+dqcom754 compare 1.00001 1 -> 1
+dqcom755 compare 1.000001 1 -> 1
+dqcom756 compare 1.0000001 1 -> 1
+
+-- Specials
+dqcom780 compare Inf -Inf -> 1
+dqcom781 compare Inf -1000 -> 1
+dqcom782 compare Inf -1 -> 1
+dqcom783 compare Inf -0 -> 1
+dqcom784 compare Inf 0 -> 1
+dqcom785 compare Inf 1 -> 1
+dqcom786 compare Inf 1000 -> 1
+dqcom787 compare Inf Inf -> 0
+dqcom788 compare -1000 Inf -> -1
+dqcom789 compare -Inf Inf -> -1
+dqcom790 compare -1 Inf -> -1
+dqcom791 compare -0 Inf -> -1
+dqcom792 compare 0 Inf -> -1
+dqcom793 compare 1 Inf -> -1
+dqcom794 compare 1000 Inf -> -1
+dqcom795 compare Inf Inf -> 0
+
+dqcom800 compare -Inf -Inf -> 0
+dqcom801 compare -Inf -1000 -> -1
+dqcom802 compare -Inf -1 -> -1
+dqcom803 compare -Inf -0 -> -1
+dqcom804 compare -Inf 0 -> -1
+dqcom805 compare -Inf 1 -> -1
+dqcom806 compare -Inf 1000 -> -1
+dqcom807 compare -Inf Inf -> -1
+dqcom808 compare -Inf -Inf -> 0
+dqcom809 compare -1000 -Inf -> 1
+dqcom810 compare -1 -Inf -> 1
+dqcom811 compare -0 -Inf -> 1
+dqcom812 compare 0 -Inf -> 1
+dqcom813 compare 1 -Inf -> 1
+dqcom814 compare 1000 -Inf -> 1
+dqcom815 compare Inf -Inf -> 1
+
+dqcom821 compare NaN -Inf -> NaN
+dqcom822 compare NaN -1000 -> NaN
+dqcom823 compare NaN -1 -> NaN
+dqcom824 compare NaN -0 -> NaN
+dqcom825 compare NaN 0 -> NaN
+dqcom826 compare NaN 1 -> NaN
+dqcom827 compare NaN 1000 -> NaN
+dqcom828 compare NaN Inf -> NaN
+dqcom829 compare NaN NaN -> NaN
+dqcom830 compare -Inf NaN -> NaN
+dqcom831 compare -1000 NaN -> NaN
+dqcom832 compare -1 NaN -> NaN
+dqcom833 compare -0 NaN -> NaN
+dqcom834 compare 0 NaN -> NaN
+dqcom835 compare 1 NaN -> NaN
+dqcom836 compare 1000 NaN -> NaN
+dqcom837 compare Inf NaN -> NaN
+dqcom838 compare -NaN -NaN -> -NaN
+dqcom839 compare +NaN -NaN -> NaN
+dqcom840 compare -NaN +NaN -> -NaN
+
+dqcom841 compare sNaN -Inf -> NaN Invalid_operation
+dqcom842 compare sNaN -1000 -> NaN Invalid_operation
+dqcom843 compare sNaN -1 -> NaN Invalid_operation
+dqcom844 compare sNaN -0 -> NaN Invalid_operation
+dqcom845 compare sNaN 0 -> NaN Invalid_operation
+dqcom846 compare sNaN 1 -> NaN Invalid_operation
+dqcom847 compare sNaN 1000 -> NaN Invalid_operation
+dqcom848 compare sNaN NaN -> NaN Invalid_operation
+dqcom849 compare sNaN sNaN -> NaN Invalid_operation
+dqcom850 compare NaN sNaN -> NaN Invalid_operation
+dqcom851 compare -Inf sNaN -> NaN Invalid_operation
+dqcom852 compare -1000 sNaN -> NaN Invalid_operation
+dqcom853 compare -1 sNaN -> NaN Invalid_operation
+dqcom854 compare -0 sNaN -> NaN Invalid_operation
+dqcom855 compare 0 sNaN -> NaN Invalid_operation
+dqcom856 compare 1 sNaN -> NaN Invalid_operation
+dqcom857 compare 1000 sNaN -> NaN Invalid_operation
+dqcom858 compare Inf sNaN -> NaN Invalid_operation
+dqcom859 compare NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqcom860 compare NaN9 -Inf -> NaN9
+dqcom861 compare NaN8 999 -> NaN8
+dqcom862 compare NaN77 Inf -> NaN77
+dqcom863 compare -NaN67 NaN5 -> -NaN67
+dqcom864 compare -Inf -NaN4 -> -NaN4
+dqcom865 compare -999 -NaN33 -> -NaN33
+dqcom866 compare Inf NaN2 -> NaN2
+dqcom867 compare -NaN41 -NaN42 -> -NaN41
+dqcom868 compare +NaN41 -NaN42 -> NaN41
+dqcom869 compare -NaN41 +NaN42 -> -NaN41
+dqcom870 compare +NaN41 +NaN42 -> NaN41
+
+dqcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
+dqcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
+dqcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
+dqcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
+dqcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
+dqcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
+dqcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
+dqcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- wide range
+dqcom880 compare +1.23456789012345E-0 9E+6144 -> -1
+dqcom881 compare 9E+6144 +1.23456789012345E-0 -> 1
+dqcom882 compare +0.100 9E-6143 -> 1
+dqcom883 compare 9E-6143 +0.100 -> -1
+dqcom885 compare -1.23456789012345E-0 9E+6144 -> -1
+dqcom886 compare 9E+6144 -1.23456789012345E-0 -> 1
+dqcom887 compare -0.100 9E-6143 -> -1
+dqcom888 compare 9E-6143 -0.100 -> 1
+
+-- signs
+dqcom901 compare 1e+77 1e+11 -> 1
+dqcom902 compare 1e+77 -1e+11 -> 1
+dqcom903 compare -1e+77 1e+11 -> -1
+dqcom904 compare -1e+77 -1e+11 -> -1
+dqcom905 compare 1e-77 1e-11 -> -1
+dqcom906 compare 1e-77 -1e-11 -> 1
+dqcom907 compare -1e-77 1e-11 -> -1
+dqcom908 compare -1e-77 -1e-11 -> 1
+
+-- full alignment range, both ways
+dqcomp1001 compare 1 1.000000000000000000000000000000000 -> 0
+dqcomp1002 compare 1 1.00000000000000000000000000000000 -> 0
+dqcomp1003 compare 1 1.0000000000000000000000000000000 -> 0
+dqcomp1004 compare 1 1.000000000000000000000000000000 -> 0
+dqcomp1005 compare 1 1.00000000000000000000000000000 -> 0
+dqcomp1006 compare 1 1.0000000000000000000000000000 -> 0
+dqcomp1007 compare 1 1.000000000000000000000000000 -> 0
+dqcomp1008 compare 1 1.00000000000000000000000000 -> 0
+dqcomp1009 compare 1 1.0000000000000000000000000 -> 0
+dqcomp1010 compare 1 1.000000000000000000000000 -> 0
+dqcomp1011 compare 1 1.00000000000000000000000 -> 0
+dqcomp1012 compare 1 1.0000000000000000000000 -> 0
+dqcomp1013 compare 1 1.000000000000000000000 -> 0
+dqcomp1014 compare 1 1.00000000000000000000 -> 0
+dqcomp1015 compare 1 1.0000000000000000000 -> 0
+dqcomp1016 compare 1 1.000000000000000000 -> 0
+dqcomp1017 compare 1 1.00000000000000000 -> 0
+dqcomp1018 compare 1 1.0000000000000000 -> 0
+dqcomp1019 compare 1 1.000000000000000 -> 0
+dqcomp1020 compare 1 1.00000000000000 -> 0
+dqcomp1021 compare 1 1.0000000000000 -> 0
+dqcomp1022 compare 1 1.000000000000 -> 0
+dqcomp1023 compare 1 1.00000000000 -> 0
+dqcomp1024 compare 1 1.0000000000 -> 0
+dqcomp1025 compare 1 1.000000000 -> 0
+dqcomp1026 compare 1 1.00000000 -> 0
+dqcomp1027 compare 1 1.0000000 -> 0
+dqcomp1028 compare 1 1.000000 -> 0
+dqcomp1029 compare 1 1.00000 -> 0
+dqcomp1030 compare 1 1.0000 -> 0
+dqcomp1031 compare 1 1.000 -> 0
+dqcomp1032 compare 1 1.00 -> 0
+dqcomp1033 compare 1 1.0 -> 0
+
+dqcomp1041 compare 1.000000000000000000000000000000000 1 -> 0
+dqcomp1042 compare 1.00000000000000000000000000000000 1 -> 0
+dqcomp1043 compare 1.0000000000000000000000000000000 1 -> 0
+dqcomp1044 compare 1.000000000000000000000000000000 1 -> 0
+dqcomp1045 compare 1.00000000000000000000000000000 1 -> 0
+dqcomp1046 compare 1.0000000000000000000000000000 1 -> 0
+dqcomp1047 compare 1.000000000000000000000000000 1 -> 0
+dqcomp1048 compare 1.00000000000000000000000000 1 -> 0
+dqcomp1049 compare 1.0000000000000000000000000 1 -> 0
+dqcomp1050 compare 1.000000000000000000000000 1 -> 0
+dqcomp1051 compare 1.00000000000000000000000 1 -> 0
+dqcomp1052 compare 1.0000000000000000000000 1 -> 0
+dqcomp1053 compare 1.000000000000000000000 1 -> 0
+dqcomp1054 compare 1.00000000000000000000 1 -> 0
+dqcomp1055 compare 1.0000000000000000000 1 -> 0
+dqcomp1056 compare 1.000000000000000000 1 -> 0
+dqcomp1057 compare 1.00000000000000000 1 -> 0
+dqcomp1058 compare 1.0000000000000000 1 -> 0
+dqcomp1059 compare 1.000000000000000 1 -> 0
+dqcomp1060 compare 1.00000000000000 1 -> 0
+dqcomp1061 compare 1.0000000000000 1 -> 0
+dqcomp1062 compare 1.000000000000 1 -> 0
+dqcomp1063 compare 1.00000000000 1 -> 0
+dqcomp1064 compare 1.0000000000 1 -> 0
+dqcomp1065 compare 1.000000000 1 -> 0
+dqcomp1066 compare 1.00000000 1 -> 0
+dqcomp1067 compare 1.0000000 1 -> 0
+dqcomp1068 compare 1.000000 1 -> 0
+dqcomp1069 compare 1.00000 1 -> 0
+dqcomp1070 compare 1.0000 1 -> 0
+dqcomp1071 compare 1.000 1 -> 0
+dqcomp1072 compare 1.00 1 -> 0
+dqcomp1073 compare 1.0 1 -> 0
+
+-- check MSD always detected non-zero
+dqcomp1080 compare 0 0.000000000000000000000000000000000 -> 0
+dqcomp1081 compare 0 1.000000000000000000000000000000000 -> -1
+dqcomp1082 compare 0 2.000000000000000000000000000000000 -> -1
+dqcomp1083 compare 0 3.000000000000000000000000000000000 -> -1
+dqcomp1084 compare 0 4.000000000000000000000000000000000 -> -1
+dqcomp1085 compare 0 5.000000000000000000000000000000000 -> -1
+dqcomp1086 compare 0 6.000000000000000000000000000000000 -> -1
+dqcomp1087 compare 0 7.000000000000000000000000000000000 -> -1
+dqcomp1088 compare 0 8.000000000000000000000000000000000 -> -1
+dqcomp1089 compare 0 9.000000000000000000000000000000000 -> -1
+dqcomp1090 compare 0.000000000000000000000000000000000 0 -> 0
+dqcomp1091 compare 1.000000000000000000000000000000000 0 -> 1
+dqcomp1092 compare 2.000000000000000000000000000000000 0 -> 1
+dqcomp1093 compare 3.000000000000000000000000000000000 0 -> 1
+dqcomp1094 compare 4.000000000000000000000000000000000 0 -> 1
+dqcomp1095 compare 5.000000000000000000000000000000000 0 -> 1
+dqcomp1096 compare 6.000000000000000000000000000000000 0 -> 1
+dqcomp1097 compare 7.000000000000000000000000000000000 0 -> 1
+dqcomp1098 compare 8.000000000000000000000000000000000 0 -> 1
+dqcomp1099 compare 9.000000000000000000000000000000000 0 -> 1
+
+-- Null tests
+dqcom990 compare 10 # -> NaN Invalid_operation
+dqcom991 compare # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqCompareSig.decTest b/Lib/test/decimaltestdata/dqCompareSig.decTest
index 795f0916dd..c068d471c1 100644
--- a/Lib/test/decimaltestdata/dqCompareSig.decTest
+++ b/Lib/test/decimaltestdata/dqCompareSig.decTest
@@ -1,647 +1,647 @@
-------------------------------------------------------------------------
--- dqCompareSig.decTest -- decQuad comparison; all NaNs signal --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqcms001 comparesig -2 -2 -> 0
-dqcms002 comparesig -2 -1 -> -1
-dqcms003 comparesig -2 0 -> -1
-dqcms004 comparesig -2 1 -> -1
-dqcms005 comparesig -2 2 -> -1
-dqcms006 comparesig -1 -2 -> 1
-dqcms007 comparesig -1 -1 -> 0
-dqcms008 comparesig -1 0 -> -1
-dqcms009 comparesig -1 1 -> -1
-dqcms010 comparesig -1 2 -> -1
-dqcms011 comparesig 0 -2 -> 1
-dqcms012 comparesig 0 -1 -> 1
-dqcms013 comparesig 0 0 -> 0
-dqcms014 comparesig 0 1 -> -1
-dqcms015 comparesig 0 2 -> -1
-dqcms016 comparesig 1 -2 -> 1
-dqcms017 comparesig 1 -1 -> 1
-dqcms018 comparesig 1 0 -> 1
-dqcms019 comparesig 1 1 -> 0
-dqcms020 comparesig 1 2 -> -1
-dqcms021 comparesig 2 -2 -> 1
-dqcms022 comparesig 2 -1 -> 1
-dqcms023 comparesig 2 0 -> 1
-dqcms025 comparesig 2 1 -> 1
-dqcms026 comparesig 2 2 -> 0
-
-dqcms031 comparesig -20 -20 -> 0
-dqcms032 comparesig -20 -10 -> -1
-dqcms033 comparesig -20 00 -> -1
-dqcms034 comparesig -20 10 -> -1
-dqcms035 comparesig -20 20 -> -1
-dqcms036 comparesig -10 -20 -> 1
-dqcms037 comparesig -10 -10 -> 0
-dqcms038 comparesig -10 00 -> -1
-dqcms039 comparesig -10 10 -> -1
-dqcms040 comparesig -10 20 -> -1
-dqcms041 comparesig 00 -20 -> 1
-dqcms042 comparesig 00 -10 -> 1
-dqcms043 comparesig 00 00 -> 0
-dqcms044 comparesig 00 10 -> -1
-dqcms045 comparesig 00 20 -> -1
-dqcms046 comparesig 10 -20 -> 1
-dqcms047 comparesig 10 -10 -> 1
-dqcms048 comparesig 10 00 -> 1
-dqcms049 comparesig 10 10 -> 0
-dqcms050 comparesig 10 20 -> -1
-dqcms051 comparesig 20 -20 -> 1
-dqcms052 comparesig 20 -10 -> 1
-dqcms053 comparesig 20 00 -> 1
-dqcms055 comparesig 20 10 -> 1
-dqcms056 comparesig 20 20 -> 0
-
-dqcms061 comparesig -2.0 -2.0 -> 0
-dqcms062 comparesig -2.0 -1.0 -> -1
-dqcms063 comparesig -2.0 0.0 -> -1
-dqcms064 comparesig -2.0 1.0 -> -1
-dqcms065 comparesig -2.0 2.0 -> -1
-dqcms066 comparesig -1.0 -2.0 -> 1
-dqcms067 comparesig -1.0 -1.0 -> 0
-dqcms068 comparesig -1.0 0.0 -> -1
-dqcms069 comparesig -1.0 1.0 -> -1
-dqcms070 comparesig -1.0 2.0 -> -1
-dqcms071 comparesig 0.0 -2.0 -> 1
-dqcms072 comparesig 0.0 -1.0 -> 1
-dqcms073 comparesig 0.0 0.0 -> 0
-dqcms074 comparesig 0.0 1.0 -> -1
-dqcms075 comparesig 0.0 2.0 -> -1
-dqcms076 comparesig 1.0 -2.0 -> 1
-dqcms077 comparesig 1.0 -1.0 -> 1
-dqcms078 comparesig 1.0 0.0 -> 1
-dqcms079 comparesig 1.0 1.0 -> 0
-dqcms080 comparesig 1.0 2.0 -> -1
-dqcms081 comparesig 2.0 -2.0 -> 1
-dqcms082 comparesig 2.0 -1.0 -> 1
-dqcms083 comparesig 2.0 0.0 -> 1
-dqcms085 comparesig 2.0 1.0 -> 1
-dqcms086 comparesig 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-dqcms090 comparesig 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 0
-dqcms091 comparesig -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> -1
-dqcms092 comparesig 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
-dqcms093 comparesig -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0
-
--- some differing length/exponent cases
-dqcms100 comparesig 7.0 7.0 -> 0
-dqcms101 comparesig 7.0 7 -> 0
-dqcms102 comparesig 7 7.0 -> 0
-dqcms103 comparesig 7E+0 7.0 -> 0
-dqcms104 comparesig 70E-1 7.0 -> 0
-dqcms105 comparesig 0.7E+1 7 -> 0
-dqcms106 comparesig 70E-1 7 -> 0
-dqcms107 comparesig 7.0 7E+0 -> 0
-dqcms108 comparesig 7.0 70E-1 -> 0
-dqcms109 comparesig 7 0.7E+1 -> 0
-dqcms110 comparesig 7 70E-1 -> 0
-
-dqcms120 comparesig 8.0 7.0 -> 1
-dqcms121 comparesig 8.0 7 -> 1
-dqcms122 comparesig 8 7.0 -> 1
-dqcms123 comparesig 8E+0 7.0 -> 1
-dqcms124 comparesig 80E-1 7.0 -> 1
-dqcms125 comparesig 0.8E+1 7 -> 1
-dqcms126 comparesig 80E-1 7 -> 1
-dqcms127 comparesig 8.0 7E+0 -> 1
-dqcms128 comparesig 8.0 70E-1 -> 1
-dqcms129 comparesig 8 0.7E+1 -> 1
-dqcms130 comparesig 8 70E-1 -> 1
-
-dqcms140 comparesig 8.0 9.0 -> -1
-dqcms141 comparesig 8.0 9 -> -1
-dqcms142 comparesig 8 9.0 -> -1
-dqcms143 comparesig 8E+0 9.0 -> -1
-dqcms144 comparesig 80E-1 9.0 -> -1
-dqcms145 comparesig 0.8E+1 9 -> -1
-dqcms146 comparesig 80E-1 9 -> -1
-dqcms147 comparesig 8.0 9E+0 -> -1
-dqcms148 comparesig 8.0 90E-1 -> -1
-dqcms149 comparesig 8 0.9E+1 -> -1
-dqcms150 comparesig 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-dqcms200 comparesig -7.0 7.0 -> -1
-dqcms201 comparesig -7.0 7 -> -1
-dqcms202 comparesig -7 7.0 -> -1
-dqcms203 comparesig -7E+0 7.0 -> -1
-dqcms204 comparesig -70E-1 7.0 -> -1
-dqcms205 comparesig -0.7E+1 7 -> -1
-dqcms206 comparesig -70E-1 7 -> -1
-dqcms207 comparesig -7.0 7E+0 -> -1
-dqcms208 comparesig -7.0 70E-1 -> -1
-dqcms209 comparesig -7 0.7E+1 -> -1
-dqcms210 comparesig -7 70E-1 -> -1
-
-dqcms220 comparesig -8.0 7.0 -> -1
-dqcms221 comparesig -8.0 7 -> -1
-dqcms222 comparesig -8 7.0 -> -1
-dqcms223 comparesig -8E+0 7.0 -> -1
-dqcms224 comparesig -80E-1 7.0 -> -1
-dqcms225 comparesig -0.8E+1 7 -> -1
-dqcms226 comparesig -80E-1 7 -> -1
-dqcms227 comparesig -8.0 7E+0 -> -1
-dqcms228 comparesig -8.0 70E-1 -> -1
-dqcms229 comparesig -8 0.7E+1 -> -1
-dqcms230 comparesig -8 70E-1 -> -1
-
-dqcms240 comparesig -8.0 9.0 -> -1
-dqcms241 comparesig -8.0 9 -> -1
-dqcms242 comparesig -8 9.0 -> -1
-dqcms243 comparesig -8E+0 9.0 -> -1
-dqcms244 comparesig -80E-1 9.0 -> -1
-dqcms245 comparesig -0.8E+1 9 -> -1
-dqcms246 comparesig -80E-1 9 -> -1
-dqcms247 comparesig -8.0 9E+0 -> -1
-dqcms248 comparesig -8.0 90E-1 -> -1
-dqcms249 comparesig -8 0.9E+1 -> -1
-dqcms250 comparesig -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-dqcms300 comparesig 7.0 -7.0 -> 1
-dqcms301 comparesig 7.0 -7 -> 1
-dqcms302 comparesig 7 -7.0 -> 1
-dqcms303 comparesig 7E+0 -7.0 -> 1
-dqcms304 comparesig 70E-1 -7.0 -> 1
-dqcms305 comparesig .7E+1 -7 -> 1
-dqcms306 comparesig 70E-1 -7 -> 1
-dqcms307 comparesig 7.0 -7E+0 -> 1
-dqcms308 comparesig 7.0 -70E-1 -> 1
-dqcms309 comparesig 7 -.7E+1 -> 1
-dqcms310 comparesig 7 -70E-1 -> 1
-
-dqcms320 comparesig 8.0 -7.0 -> 1
-dqcms321 comparesig 8.0 -7 -> 1
-dqcms322 comparesig 8 -7.0 -> 1
-dqcms323 comparesig 8E+0 -7.0 -> 1
-dqcms324 comparesig 80E-1 -7.0 -> 1
-dqcms325 comparesig .8E+1 -7 -> 1
-dqcms326 comparesig 80E-1 -7 -> 1
-dqcms327 comparesig 8.0 -7E+0 -> 1
-dqcms328 comparesig 8.0 -70E-1 -> 1
-dqcms329 comparesig 8 -.7E+1 -> 1
-dqcms330 comparesig 8 -70E-1 -> 1
-
-dqcms340 comparesig 8.0 -9.0 -> 1
-dqcms341 comparesig 8.0 -9 -> 1
-dqcms342 comparesig 8 -9.0 -> 1
-dqcms343 comparesig 8E+0 -9.0 -> 1
-dqcms344 comparesig 80E-1 -9.0 -> 1
-dqcms345 comparesig .8E+1 -9 -> 1
-dqcms346 comparesig 80E-1 -9 -> 1
-dqcms347 comparesig 8.0 -9E+0 -> 1
-dqcms348 comparesig 8.0 -90E-1 -> 1
-dqcms349 comparesig 8 -.9E+1 -> 1
-dqcms350 comparesig 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-dqcms400 comparesig -7.0 -7.0 -> 0
-dqcms401 comparesig -7.0 -7 -> 0
-dqcms402 comparesig -7 -7.0 -> 0
-dqcms403 comparesig -7E+0 -7.0 -> 0
-dqcms404 comparesig -70E-1 -7.0 -> 0
-dqcms405 comparesig -.7E+1 -7 -> 0
-dqcms406 comparesig -70E-1 -7 -> 0
-dqcms407 comparesig -7.0 -7E+0 -> 0
-dqcms408 comparesig -7.0 -70E-1 -> 0
-dqcms409 comparesig -7 -.7E+1 -> 0
-dqcms410 comparesig -7 -70E-1 -> 0
-
-dqcms420 comparesig -8.0 -7.0 -> -1
-dqcms421 comparesig -8.0 -7 -> -1
-dqcms422 comparesig -8 -7.0 -> -1
-dqcms423 comparesig -8E+0 -7.0 -> -1
-dqcms424 comparesig -80E-1 -7.0 -> -1
-dqcms425 comparesig -.8E+1 -7 -> -1
-dqcms426 comparesig -80E-1 -7 -> -1
-dqcms427 comparesig -8.0 -7E+0 -> -1
-dqcms428 comparesig -8.0 -70E-1 -> -1
-dqcms429 comparesig -8 -.7E+1 -> -1
-dqcms430 comparesig -8 -70E-1 -> -1
-
-dqcms440 comparesig -8.0 -9.0 -> 1
-dqcms441 comparesig -8.0 -9 -> 1
-dqcms442 comparesig -8 -9.0 -> 1
-dqcms443 comparesig -8E+0 -9.0 -> 1
-dqcms444 comparesig -80E-1 -9.0 -> 1
-dqcms445 comparesig -.8E+1 -9 -> 1
-dqcms446 comparesig -80E-1 -9 -> 1
-dqcms447 comparesig -8.0 -9E+0 -> 1
-dqcms448 comparesig -8.0 -90E-1 -> 1
-dqcms449 comparesig -8 -.9E+1 -> 1
-dqcms450 comparesig -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-dqcms473 comparesig 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
-dqcms474 comparesig 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
-dqcms475 comparesig 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
-dqcms476 comparesig 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
-dqcms477 comparesig 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
-dqcms478 comparesig 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
-dqcms479 comparesig 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
-dqcms480 comparesig 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
-dqcms481 comparesig 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
-dqcms482 comparesig 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
-dqcms483 comparesig 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
-dqcms487 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
-dqcms488 comparesig 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
-dqcms489 comparesig 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
-dqcms490 comparesig 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
-dqcms491 comparesig 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
-dqcms492 comparesig 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
-dqcms493 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
-dqcms494 comparesig 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
-dqcms495 comparesig 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
-dqcms496 comparesig 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
-dqcms497 comparesig 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-dqcms500 comparesig 1 1E-15 -> 1
-dqcms501 comparesig 1 1E-14 -> 1
-dqcms502 comparesig 1 1E-13 -> 1
-dqcms503 comparesig 1 1E-12 -> 1
-dqcms504 comparesig 1 1E-11 -> 1
-dqcms505 comparesig 1 1E-10 -> 1
-dqcms506 comparesig 1 1E-9 -> 1
-dqcms507 comparesig 1 1E-8 -> 1
-dqcms508 comparesig 1 1E-7 -> 1
-dqcms509 comparesig 1 1E-6 -> 1
-dqcms510 comparesig 1 1E-5 -> 1
-dqcms511 comparesig 1 1E-4 -> 1
-dqcms512 comparesig 1 1E-3 -> 1
-dqcms513 comparesig 1 1E-2 -> 1
-dqcms514 comparesig 1 1E-1 -> 1
-dqcms515 comparesig 1 1E-0 -> 0
-dqcms516 comparesig 1 1E+1 -> -1
-dqcms517 comparesig 1 1E+2 -> -1
-dqcms518 comparesig 1 1E+3 -> -1
-dqcms519 comparesig 1 1E+4 -> -1
-dqcms521 comparesig 1 1E+5 -> -1
-dqcms522 comparesig 1 1E+6 -> -1
-dqcms523 comparesig 1 1E+7 -> -1
-dqcms524 comparesig 1 1E+8 -> -1
-dqcms525 comparesig 1 1E+9 -> -1
-dqcms526 comparesig 1 1E+10 -> -1
-dqcms527 comparesig 1 1E+11 -> -1
-dqcms528 comparesig 1 1E+12 -> -1
-dqcms529 comparesig 1 1E+13 -> -1
-dqcms530 comparesig 1 1E+14 -> -1
-dqcms531 comparesig 1 1E+15 -> -1
--- LR swap
-dqcms540 comparesig 1E-15 1 -> -1
-dqcms541 comparesig 1E-14 1 -> -1
-dqcms542 comparesig 1E-13 1 -> -1
-dqcms543 comparesig 1E-12 1 -> -1
-dqcms544 comparesig 1E-11 1 -> -1
-dqcms545 comparesig 1E-10 1 -> -1
-dqcms546 comparesig 1E-9 1 -> -1
-dqcms547 comparesig 1E-8 1 -> -1
-dqcms548 comparesig 1E-7 1 -> -1
-dqcms549 comparesig 1E-6 1 -> -1
-dqcms550 comparesig 1E-5 1 -> -1
-dqcms551 comparesig 1E-4 1 -> -1
-dqcms552 comparesig 1E-3 1 -> -1
-dqcms553 comparesig 1E-2 1 -> -1
-dqcms554 comparesig 1E-1 1 -> -1
-dqcms555 comparesig 1E-0 1 -> 0
-dqcms556 comparesig 1E+1 1 -> 1
-dqcms557 comparesig 1E+2 1 -> 1
-dqcms558 comparesig 1E+3 1 -> 1
-dqcms559 comparesig 1E+4 1 -> 1
-dqcms561 comparesig 1E+5 1 -> 1
-dqcms562 comparesig 1E+6 1 -> 1
-dqcms563 comparesig 1E+7 1 -> 1
-dqcms564 comparesig 1E+8 1 -> 1
-dqcms565 comparesig 1E+9 1 -> 1
-dqcms566 comparesig 1E+10 1 -> 1
-dqcms567 comparesig 1E+11 1 -> 1
-dqcms568 comparesig 1E+12 1 -> 1
-dqcms569 comparesig 1E+13 1 -> 1
-dqcms570 comparesig 1E+14 1 -> 1
-dqcms571 comparesig 1E+15 1 -> 1
--- similar with a useful coefficient, one side only
-dqcms580 comparesig 0.000000987654321 1E-15 -> 1
-dqcms581 comparesig 0.000000987654321 1E-14 -> 1
-dqcms582 comparesig 0.000000987654321 1E-13 -> 1
-dqcms583 comparesig 0.000000987654321 1E-12 -> 1
-dqcms584 comparesig 0.000000987654321 1E-11 -> 1
-dqcms585 comparesig 0.000000987654321 1E-10 -> 1
-dqcms586 comparesig 0.000000987654321 1E-9 -> 1
-dqcms587 comparesig 0.000000987654321 1E-8 -> 1
-dqcms588 comparesig 0.000000987654321 1E-7 -> 1
-dqcms589 comparesig 0.000000987654321 1E-6 -> -1
-dqcms590 comparesig 0.000000987654321 1E-5 -> -1
-dqcms591 comparesig 0.000000987654321 1E-4 -> -1
-dqcms592 comparesig 0.000000987654321 1E-3 -> -1
-dqcms593 comparesig 0.000000987654321 1E-2 -> -1
-dqcms594 comparesig 0.000000987654321 1E-1 -> -1
-dqcms595 comparesig 0.000000987654321 1E-0 -> -1
-dqcms596 comparesig 0.000000987654321 1E+1 -> -1
-dqcms597 comparesig 0.000000987654321 1E+2 -> -1
-dqcms598 comparesig 0.000000987654321 1E+3 -> -1
-dqcms599 comparesig 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-dqcms600 comparesig 12 12.2345 -> -1
-dqcms601 comparesig 12.0 12.2345 -> -1
-dqcms602 comparesig 12.00 12.2345 -> -1
-dqcms603 comparesig 12.000 12.2345 -> -1
-dqcms604 comparesig 12.0000 12.2345 -> -1
-dqcms605 comparesig 12.00000 12.2345 -> -1
-dqcms606 comparesig 12.000000 12.2345 -> -1
-dqcms607 comparesig 12.0000000 12.2345 -> -1
-dqcms608 comparesig 12.00000000 12.2345 -> -1
-dqcms609 comparesig 12.000000000 12.2345 -> -1
-dqcms610 comparesig 12.1234 12 -> 1
-dqcms611 comparesig 12.1234 12.0 -> 1
-dqcms612 comparesig 12.1234 12.00 -> 1
-dqcms613 comparesig 12.1234 12.000 -> 1
-dqcms614 comparesig 12.1234 12.0000 -> 1
-dqcms615 comparesig 12.1234 12.00000 -> 1
-dqcms616 comparesig 12.1234 12.000000 -> 1
-dqcms617 comparesig 12.1234 12.0000000 -> 1
-dqcms618 comparesig 12.1234 12.00000000 -> 1
-dqcms619 comparesig 12.1234 12.000000000 -> 1
-dqcms620 comparesig -12 -12.2345 -> 1
-dqcms621 comparesig -12.0 -12.2345 -> 1
-dqcms622 comparesig -12.00 -12.2345 -> 1
-dqcms623 comparesig -12.000 -12.2345 -> 1
-dqcms624 comparesig -12.0000 -12.2345 -> 1
-dqcms625 comparesig -12.00000 -12.2345 -> 1
-dqcms626 comparesig -12.000000 -12.2345 -> 1
-dqcms627 comparesig -12.0000000 -12.2345 -> 1
-dqcms628 comparesig -12.00000000 -12.2345 -> 1
-dqcms629 comparesig -12.000000000 -12.2345 -> 1
-dqcms630 comparesig -12.1234 -12 -> -1
-dqcms631 comparesig -12.1234 -12.0 -> -1
-dqcms632 comparesig -12.1234 -12.00 -> -1
-dqcms633 comparesig -12.1234 -12.000 -> -1
-dqcms634 comparesig -12.1234 -12.0000 -> -1
-dqcms635 comparesig -12.1234 -12.00000 -> -1
-dqcms636 comparesig -12.1234 -12.000000 -> -1
-dqcms637 comparesig -12.1234 -12.0000000 -> -1
-dqcms638 comparesig -12.1234 -12.00000000 -> -1
-dqcms639 comparesig -12.1234 -12.000000000 -> -1
-
--- extended zeros
-dqcms640 comparesig 0 0 -> 0
-dqcms641 comparesig 0 -0 -> 0
-dqcms642 comparesig 0 -0.0 -> 0
-dqcms643 comparesig 0 0.0 -> 0
-dqcms644 comparesig -0 0 -> 0
-dqcms645 comparesig -0 -0 -> 0
-dqcms646 comparesig -0 -0.0 -> 0
-dqcms647 comparesig -0 0.0 -> 0
-dqcms648 comparesig 0.0 0 -> 0
-dqcms649 comparesig 0.0 -0 -> 0
-dqcms650 comparesig 0.0 -0.0 -> 0
-dqcms651 comparesig 0.0 0.0 -> 0
-dqcms652 comparesig -0.0 0 -> 0
-dqcms653 comparesig -0.0 -0 -> 0
-dqcms654 comparesig -0.0 -0.0 -> 0
-dqcms655 comparesig -0.0 0.0 -> 0
-
-dqcms656 comparesig -0E1 0.0 -> 0
-dqcms657 comparesig -0E2 0.0 -> 0
-dqcms658 comparesig 0E1 0.0 -> 0
-dqcms659 comparesig 0E2 0.0 -> 0
-dqcms660 comparesig -0E1 0 -> 0
-dqcms661 comparesig -0E2 0 -> 0
-dqcms662 comparesig 0E1 0 -> 0
-dqcms663 comparesig 0E2 0 -> 0
-dqcms664 comparesig -0E1 -0E1 -> 0
-dqcms665 comparesig -0E2 -0E1 -> 0
-dqcms666 comparesig 0E1 -0E1 -> 0
-dqcms667 comparesig 0E2 -0E1 -> 0
-dqcms668 comparesig -0E1 -0E2 -> 0
-dqcms669 comparesig -0E2 -0E2 -> 0
-dqcms670 comparesig 0E1 -0E2 -> 0
-dqcms671 comparesig 0E2 -0E2 -> 0
-dqcms672 comparesig -0E1 0E1 -> 0
-dqcms673 comparesig -0E2 0E1 -> 0
-dqcms674 comparesig 0E1 0E1 -> 0
-dqcms675 comparesig 0E2 0E1 -> 0
-dqcms676 comparesig -0E1 0E2 -> 0
-dqcms677 comparesig -0E2 0E2 -> 0
-dqcms678 comparesig 0E1 0E2 -> 0
-dqcms679 comparesig 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-dqcms680 comparesig 12 12 -> 0
-dqcms681 comparesig 12 12.0 -> 0
-dqcms682 comparesig 12 12.00 -> 0
-dqcms683 comparesig 12 12.000 -> 0
-dqcms684 comparesig 12 12.0000 -> 0
-dqcms685 comparesig 12 12.00000 -> 0
-dqcms686 comparesig 12 12.000000 -> 0
-dqcms687 comparesig 12 12.0000000 -> 0
-dqcms688 comparesig 12 12.00000000 -> 0
-dqcms689 comparesig 12 12.000000000 -> 0
-dqcms690 comparesig 12 12 -> 0
-dqcms691 comparesig 12.0 12 -> 0
-dqcms692 comparesig 12.00 12 -> 0
-dqcms693 comparesig 12.000 12 -> 0
-dqcms694 comparesig 12.0000 12 -> 0
-dqcms695 comparesig 12.00000 12 -> 0
-dqcms696 comparesig 12.000000 12 -> 0
-dqcms697 comparesig 12.0000000 12 -> 0
-dqcms698 comparesig 12.00000000 12 -> 0
-dqcms699 comparesig 12.000000000 12 -> 0
-
--- first, second, & last digit
-dqcms700 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
-dqcms701 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
-dqcms702 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
-dqcms703 comparesig 1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
-dqcms704 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
-dqcms705 comparesig 1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
-dqcms706 comparesig 1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
-dqcms707 comparesig 1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
-dqcms708 comparesig 1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1
-
--- miscellaneous
-dqcms721 comparesig 12345678000 1 -> 1
-dqcms722 comparesig 1 12345678000 -> -1
-dqcms723 comparesig 1234567800 1 -> 1
-dqcms724 comparesig 1 1234567800 -> -1
-dqcms725 comparesig 1234567890 1 -> 1
-dqcms726 comparesig 1 1234567890 -> -1
-dqcms727 comparesig 1234567891 1 -> 1
-dqcms728 comparesig 1 1234567891 -> -1
-dqcms729 comparesig 12345678901 1 -> 1
-dqcms730 comparesig 1 12345678901 -> -1
-dqcms731 comparesig 1234567896 1 -> 1
-dqcms732 comparesig 1 1234567896 -> -1
-
--- residue cases at lower precision
-dqcms740 comparesig 1 0.9999999 -> 1
-dqcms741 comparesig 1 0.999999 -> 1
-dqcms742 comparesig 1 0.99999 -> 1
-dqcms743 comparesig 1 1.0000 -> 0
-dqcms744 comparesig 1 1.00001 -> -1
-dqcms745 comparesig 1 1.000001 -> -1
-dqcms746 comparesig 1 1.0000001 -> -1
-dqcms750 comparesig 0.9999999 1 -> -1
-dqcms751 comparesig 0.999999 1 -> -1
-dqcms752 comparesig 0.99999 1 -> -1
-dqcms753 comparesig 1.0000 1 -> 0
-dqcms754 comparesig 1.00001 1 -> 1
-dqcms755 comparesig 1.000001 1 -> 1
-dqcms756 comparesig 1.0000001 1 -> 1
-
--- Specials
-dqcms780 comparesig Inf -Inf -> 1
-dqcms781 comparesig Inf -1000 -> 1
-dqcms782 comparesig Inf -1 -> 1
-dqcms783 comparesig Inf -0 -> 1
-dqcms784 comparesig Inf 0 -> 1
-dqcms785 comparesig Inf 1 -> 1
-dqcms786 comparesig Inf 1000 -> 1
-dqcms787 comparesig Inf Inf -> 0
-dqcms788 comparesig -1000 Inf -> -1
-dqcms789 comparesig -Inf Inf -> -1
-dqcms790 comparesig -1 Inf -> -1
-dqcms791 comparesig -0 Inf -> -1
-dqcms792 comparesig 0 Inf -> -1
-dqcms793 comparesig 1 Inf -> -1
-dqcms794 comparesig 1000 Inf -> -1
-dqcms795 comparesig Inf Inf -> 0
-
-dqcms800 comparesig -Inf -Inf -> 0
-dqcms801 comparesig -Inf -1000 -> -1
-dqcms802 comparesig -Inf -1 -> -1
-dqcms803 comparesig -Inf -0 -> -1
-dqcms804 comparesig -Inf 0 -> -1
-dqcms805 comparesig -Inf 1 -> -1
-dqcms806 comparesig -Inf 1000 -> -1
-dqcms807 comparesig -Inf Inf -> -1
-dqcms808 comparesig -Inf -Inf -> 0
-dqcms809 comparesig -1000 -Inf -> 1
-dqcms810 comparesig -1 -Inf -> 1
-dqcms811 comparesig -0 -Inf -> 1
-dqcms812 comparesig 0 -Inf -> 1
-dqcms813 comparesig 1 -Inf -> 1
-dqcms814 comparesig 1000 -Inf -> 1
-dqcms815 comparesig Inf -Inf -> 1
-
-dqcms821 comparesig NaN -Inf -> NaN Invalid_operation
-dqcms822 comparesig NaN -1000 -> NaN Invalid_operation
-dqcms823 comparesig NaN -1 -> NaN Invalid_operation
-dqcms824 comparesig NaN -0 -> NaN Invalid_operation
-dqcms825 comparesig NaN 0 -> NaN Invalid_operation
-dqcms826 comparesig NaN 1 -> NaN Invalid_operation
-dqcms827 comparesig NaN 1000 -> NaN Invalid_operation
-dqcms828 comparesig NaN Inf -> NaN Invalid_operation
-dqcms829 comparesig NaN NaN -> NaN Invalid_operation
-dqcms830 comparesig -Inf NaN -> NaN Invalid_operation
-dqcms831 comparesig -1000 NaN -> NaN Invalid_operation
-dqcms832 comparesig -1 NaN -> NaN Invalid_operation
-dqcms833 comparesig -0 NaN -> NaN Invalid_operation
-dqcms834 comparesig 0 NaN -> NaN Invalid_operation
-dqcms835 comparesig 1 NaN -> NaN Invalid_operation
-dqcms836 comparesig 1000 NaN -> NaN Invalid_operation
-dqcms837 comparesig Inf NaN -> NaN Invalid_operation
-dqcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
-dqcms839 comparesig +NaN -NaN -> NaN Invalid_operation
-dqcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
-
-dqcms841 comparesig sNaN -Inf -> NaN Invalid_operation
-dqcms842 comparesig sNaN -1000 -> NaN Invalid_operation
-dqcms843 comparesig sNaN -1 -> NaN Invalid_operation
-dqcms844 comparesig sNaN -0 -> NaN Invalid_operation
-dqcms845 comparesig sNaN 0 -> NaN Invalid_operation
-dqcms846 comparesig sNaN 1 -> NaN Invalid_operation
-dqcms847 comparesig sNaN 1000 -> NaN Invalid_operation
-dqcms848 comparesig sNaN NaN -> NaN Invalid_operation
-dqcms849 comparesig sNaN sNaN -> NaN Invalid_operation
-dqcms850 comparesig NaN sNaN -> NaN Invalid_operation
-dqcms851 comparesig -Inf sNaN -> NaN Invalid_operation
-dqcms852 comparesig -1000 sNaN -> NaN Invalid_operation
-dqcms853 comparesig -1 sNaN -> NaN Invalid_operation
-dqcms854 comparesig -0 sNaN -> NaN Invalid_operation
-dqcms855 comparesig 0 sNaN -> NaN Invalid_operation
-dqcms856 comparesig 1 sNaN -> NaN Invalid_operation
-dqcms857 comparesig 1000 sNaN -> NaN Invalid_operation
-dqcms858 comparesig Inf sNaN -> NaN Invalid_operation
-dqcms859 comparesig NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
-dqcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
-dqcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
-dqcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
-dqcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
-dqcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
-dqcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
-dqcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
-dqcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
-dqcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
-dqcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
-
-dqcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
-dqcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
-dqcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
-dqcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
-dqcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
-dqcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
-dqcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
-dqcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- wide range
-dqcms880 comparesig +1.23456789012345E-0 9E+6144 -> -1
-dqcms881 comparesig 9E+6144 +1.23456789012345E-0 -> 1
-dqcms882 comparesig +0.100 9E-6143 -> 1
-dqcms883 comparesig 9E-6143 +0.100 -> -1
-dqcms885 comparesig -1.23456789012345E-0 9E+6144 -> -1
-dqcms886 comparesig 9E+6144 -1.23456789012345E-0 -> 1
-dqcms887 comparesig -0.100 9E-6143 -> -1
-dqcms888 comparesig 9E-6143 -0.100 -> 1
-
--- signs
-dqcms901 comparesig 1e+77 1e+11 -> 1
-dqcms902 comparesig 1e+77 -1e+11 -> 1
-dqcms903 comparesig -1e+77 1e+11 -> -1
-dqcms904 comparesig -1e+77 -1e+11 -> -1
-dqcms905 comparesig 1e-77 1e-11 -> -1
-dqcms906 comparesig 1e-77 -1e-11 -> 1
-dqcms907 comparesig -1e-77 1e-11 -> -1
-dqcms908 comparesig -1e-77 -1e-11 -> 1
-
--- Null tests
-dqcms990 comparesig 10 # -> NaN Invalid_operation
-dqcms991 comparesig # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqCompareSig.decTest -- decQuad comparison; all NaNs signal --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqcms001 comparesig -2 -2 -> 0
+dqcms002 comparesig -2 -1 -> -1
+dqcms003 comparesig -2 0 -> -1
+dqcms004 comparesig -2 1 -> -1
+dqcms005 comparesig -2 2 -> -1
+dqcms006 comparesig -1 -2 -> 1
+dqcms007 comparesig -1 -1 -> 0
+dqcms008 comparesig -1 0 -> -1
+dqcms009 comparesig -1 1 -> -1
+dqcms010 comparesig -1 2 -> -1
+dqcms011 comparesig 0 -2 -> 1
+dqcms012 comparesig 0 -1 -> 1
+dqcms013 comparesig 0 0 -> 0
+dqcms014 comparesig 0 1 -> -1
+dqcms015 comparesig 0 2 -> -1
+dqcms016 comparesig 1 -2 -> 1
+dqcms017 comparesig 1 -1 -> 1
+dqcms018 comparesig 1 0 -> 1
+dqcms019 comparesig 1 1 -> 0
+dqcms020 comparesig 1 2 -> -1
+dqcms021 comparesig 2 -2 -> 1
+dqcms022 comparesig 2 -1 -> 1
+dqcms023 comparesig 2 0 -> 1
+dqcms025 comparesig 2 1 -> 1
+dqcms026 comparesig 2 2 -> 0
+
+dqcms031 comparesig -20 -20 -> 0
+dqcms032 comparesig -20 -10 -> -1
+dqcms033 comparesig -20 00 -> -1
+dqcms034 comparesig -20 10 -> -1
+dqcms035 comparesig -20 20 -> -1
+dqcms036 comparesig -10 -20 -> 1
+dqcms037 comparesig -10 -10 -> 0
+dqcms038 comparesig -10 00 -> -1
+dqcms039 comparesig -10 10 -> -1
+dqcms040 comparesig -10 20 -> -1
+dqcms041 comparesig 00 -20 -> 1
+dqcms042 comparesig 00 -10 -> 1
+dqcms043 comparesig 00 00 -> 0
+dqcms044 comparesig 00 10 -> -1
+dqcms045 comparesig 00 20 -> -1
+dqcms046 comparesig 10 -20 -> 1
+dqcms047 comparesig 10 -10 -> 1
+dqcms048 comparesig 10 00 -> 1
+dqcms049 comparesig 10 10 -> 0
+dqcms050 comparesig 10 20 -> -1
+dqcms051 comparesig 20 -20 -> 1
+dqcms052 comparesig 20 -10 -> 1
+dqcms053 comparesig 20 00 -> 1
+dqcms055 comparesig 20 10 -> 1
+dqcms056 comparesig 20 20 -> 0
+
+dqcms061 comparesig -2.0 -2.0 -> 0
+dqcms062 comparesig -2.0 -1.0 -> -1
+dqcms063 comparesig -2.0 0.0 -> -1
+dqcms064 comparesig -2.0 1.0 -> -1
+dqcms065 comparesig -2.0 2.0 -> -1
+dqcms066 comparesig -1.0 -2.0 -> 1
+dqcms067 comparesig -1.0 -1.0 -> 0
+dqcms068 comparesig -1.0 0.0 -> -1
+dqcms069 comparesig -1.0 1.0 -> -1
+dqcms070 comparesig -1.0 2.0 -> -1
+dqcms071 comparesig 0.0 -2.0 -> 1
+dqcms072 comparesig 0.0 -1.0 -> 1
+dqcms073 comparesig 0.0 0.0 -> 0
+dqcms074 comparesig 0.0 1.0 -> -1
+dqcms075 comparesig 0.0 2.0 -> -1
+dqcms076 comparesig 1.0 -2.0 -> 1
+dqcms077 comparesig 1.0 -1.0 -> 1
+dqcms078 comparesig 1.0 0.0 -> 1
+dqcms079 comparesig 1.0 1.0 -> 0
+dqcms080 comparesig 1.0 2.0 -> -1
+dqcms081 comparesig 2.0 -2.0 -> 1
+dqcms082 comparesig 2.0 -1.0 -> 1
+dqcms083 comparesig 2.0 0.0 -> 1
+dqcms085 comparesig 2.0 1.0 -> 1
+dqcms086 comparesig 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+dqcms090 comparesig 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 0
+dqcms091 comparesig -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> -1
+dqcms092 comparesig 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
+dqcms093 comparesig -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0
+
+-- some differing length/exponent cases
+dqcms100 comparesig 7.0 7.0 -> 0
+dqcms101 comparesig 7.0 7 -> 0
+dqcms102 comparesig 7 7.0 -> 0
+dqcms103 comparesig 7E+0 7.0 -> 0
+dqcms104 comparesig 70E-1 7.0 -> 0
+dqcms105 comparesig 0.7E+1 7 -> 0
+dqcms106 comparesig 70E-1 7 -> 0
+dqcms107 comparesig 7.0 7E+0 -> 0
+dqcms108 comparesig 7.0 70E-1 -> 0
+dqcms109 comparesig 7 0.7E+1 -> 0
+dqcms110 comparesig 7 70E-1 -> 0
+
+dqcms120 comparesig 8.0 7.0 -> 1
+dqcms121 comparesig 8.0 7 -> 1
+dqcms122 comparesig 8 7.0 -> 1
+dqcms123 comparesig 8E+0 7.0 -> 1
+dqcms124 comparesig 80E-1 7.0 -> 1
+dqcms125 comparesig 0.8E+1 7 -> 1
+dqcms126 comparesig 80E-1 7 -> 1
+dqcms127 comparesig 8.0 7E+0 -> 1
+dqcms128 comparesig 8.0 70E-1 -> 1
+dqcms129 comparesig 8 0.7E+1 -> 1
+dqcms130 comparesig 8 70E-1 -> 1
+
+dqcms140 comparesig 8.0 9.0 -> -1
+dqcms141 comparesig 8.0 9 -> -1
+dqcms142 comparesig 8 9.0 -> -1
+dqcms143 comparesig 8E+0 9.0 -> -1
+dqcms144 comparesig 80E-1 9.0 -> -1
+dqcms145 comparesig 0.8E+1 9 -> -1
+dqcms146 comparesig 80E-1 9 -> -1
+dqcms147 comparesig 8.0 9E+0 -> -1
+dqcms148 comparesig 8.0 90E-1 -> -1
+dqcms149 comparesig 8 0.9E+1 -> -1
+dqcms150 comparesig 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+dqcms200 comparesig -7.0 7.0 -> -1
+dqcms201 comparesig -7.0 7 -> -1
+dqcms202 comparesig -7 7.0 -> -1
+dqcms203 comparesig -7E+0 7.0 -> -1
+dqcms204 comparesig -70E-1 7.0 -> -1
+dqcms205 comparesig -0.7E+1 7 -> -1
+dqcms206 comparesig -70E-1 7 -> -1
+dqcms207 comparesig -7.0 7E+0 -> -1
+dqcms208 comparesig -7.0 70E-1 -> -1
+dqcms209 comparesig -7 0.7E+1 -> -1
+dqcms210 comparesig -7 70E-1 -> -1
+
+dqcms220 comparesig -8.0 7.0 -> -1
+dqcms221 comparesig -8.0 7 -> -1
+dqcms222 comparesig -8 7.0 -> -1
+dqcms223 comparesig -8E+0 7.0 -> -1
+dqcms224 comparesig -80E-1 7.0 -> -1
+dqcms225 comparesig -0.8E+1 7 -> -1
+dqcms226 comparesig -80E-1 7 -> -1
+dqcms227 comparesig -8.0 7E+0 -> -1
+dqcms228 comparesig -8.0 70E-1 -> -1
+dqcms229 comparesig -8 0.7E+1 -> -1
+dqcms230 comparesig -8 70E-1 -> -1
+
+dqcms240 comparesig -8.0 9.0 -> -1
+dqcms241 comparesig -8.0 9 -> -1
+dqcms242 comparesig -8 9.0 -> -1
+dqcms243 comparesig -8E+0 9.0 -> -1
+dqcms244 comparesig -80E-1 9.0 -> -1
+dqcms245 comparesig -0.8E+1 9 -> -1
+dqcms246 comparesig -80E-1 9 -> -1
+dqcms247 comparesig -8.0 9E+0 -> -1
+dqcms248 comparesig -8.0 90E-1 -> -1
+dqcms249 comparesig -8 0.9E+1 -> -1
+dqcms250 comparesig -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+dqcms300 comparesig 7.0 -7.0 -> 1
+dqcms301 comparesig 7.0 -7 -> 1
+dqcms302 comparesig 7 -7.0 -> 1
+dqcms303 comparesig 7E+0 -7.0 -> 1
+dqcms304 comparesig 70E-1 -7.0 -> 1
+dqcms305 comparesig .7E+1 -7 -> 1
+dqcms306 comparesig 70E-1 -7 -> 1
+dqcms307 comparesig 7.0 -7E+0 -> 1
+dqcms308 comparesig 7.0 -70E-1 -> 1
+dqcms309 comparesig 7 -.7E+1 -> 1
+dqcms310 comparesig 7 -70E-1 -> 1
+
+dqcms320 comparesig 8.0 -7.0 -> 1
+dqcms321 comparesig 8.0 -7 -> 1
+dqcms322 comparesig 8 -7.0 -> 1
+dqcms323 comparesig 8E+0 -7.0 -> 1
+dqcms324 comparesig 80E-1 -7.0 -> 1
+dqcms325 comparesig .8E+1 -7 -> 1
+dqcms326 comparesig 80E-1 -7 -> 1
+dqcms327 comparesig 8.0 -7E+0 -> 1
+dqcms328 comparesig 8.0 -70E-1 -> 1
+dqcms329 comparesig 8 -.7E+1 -> 1
+dqcms330 comparesig 8 -70E-1 -> 1
+
+dqcms340 comparesig 8.0 -9.0 -> 1
+dqcms341 comparesig 8.0 -9 -> 1
+dqcms342 comparesig 8 -9.0 -> 1
+dqcms343 comparesig 8E+0 -9.0 -> 1
+dqcms344 comparesig 80E-1 -9.0 -> 1
+dqcms345 comparesig .8E+1 -9 -> 1
+dqcms346 comparesig 80E-1 -9 -> 1
+dqcms347 comparesig 8.0 -9E+0 -> 1
+dqcms348 comparesig 8.0 -90E-1 -> 1
+dqcms349 comparesig 8 -.9E+1 -> 1
+dqcms350 comparesig 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+dqcms400 comparesig -7.0 -7.0 -> 0
+dqcms401 comparesig -7.0 -7 -> 0
+dqcms402 comparesig -7 -7.0 -> 0
+dqcms403 comparesig -7E+0 -7.0 -> 0
+dqcms404 comparesig -70E-1 -7.0 -> 0
+dqcms405 comparesig -.7E+1 -7 -> 0
+dqcms406 comparesig -70E-1 -7 -> 0
+dqcms407 comparesig -7.0 -7E+0 -> 0
+dqcms408 comparesig -7.0 -70E-1 -> 0
+dqcms409 comparesig -7 -.7E+1 -> 0
+dqcms410 comparesig -7 -70E-1 -> 0
+
+dqcms420 comparesig -8.0 -7.0 -> -1
+dqcms421 comparesig -8.0 -7 -> -1
+dqcms422 comparesig -8 -7.0 -> -1
+dqcms423 comparesig -8E+0 -7.0 -> -1
+dqcms424 comparesig -80E-1 -7.0 -> -1
+dqcms425 comparesig -.8E+1 -7 -> -1
+dqcms426 comparesig -80E-1 -7 -> -1
+dqcms427 comparesig -8.0 -7E+0 -> -1
+dqcms428 comparesig -8.0 -70E-1 -> -1
+dqcms429 comparesig -8 -.7E+1 -> -1
+dqcms430 comparesig -8 -70E-1 -> -1
+
+dqcms440 comparesig -8.0 -9.0 -> 1
+dqcms441 comparesig -8.0 -9 -> 1
+dqcms442 comparesig -8 -9.0 -> 1
+dqcms443 comparesig -8E+0 -9.0 -> 1
+dqcms444 comparesig -80E-1 -9.0 -> 1
+dqcms445 comparesig -.8E+1 -9 -> 1
+dqcms446 comparesig -80E-1 -9 -> 1
+dqcms447 comparesig -8.0 -9E+0 -> 1
+dqcms448 comparesig -8.0 -90E-1 -> 1
+dqcms449 comparesig -8 -.9E+1 -> 1
+dqcms450 comparesig -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+dqcms473 comparesig 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
+dqcms474 comparesig 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
+dqcms475 comparesig 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
+dqcms476 comparesig 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
+dqcms477 comparesig 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
+dqcms478 comparesig 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
+dqcms479 comparesig 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
+dqcms480 comparesig 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
+dqcms481 comparesig 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
+dqcms482 comparesig 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
+dqcms483 comparesig 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
+dqcms487 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
+dqcms488 comparesig 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
+dqcms489 comparesig 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
+dqcms490 comparesig 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
+dqcms491 comparesig 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
+dqcms492 comparesig 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
+dqcms493 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
+dqcms494 comparesig 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
+dqcms495 comparesig 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
+dqcms496 comparesig 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
+dqcms497 comparesig 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+dqcms500 comparesig 1 1E-15 -> 1
+dqcms501 comparesig 1 1E-14 -> 1
+dqcms502 comparesig 1 1E-13 -> 1
+dqcms503 comparesig 1 1E-12 -> 1
+dqcms504 comparesig 1 1E-11 -> 1
+dqcms505 comparesig 1 1E-10 -> 1
+dqcms506 comparesig 1 1E-9 -> 1
+dqcms507 comparesig 1 1E-8 -> 1
+dqcms508 comparesig 1 1E-7 -> 1
+dqcms509 comparesig 1 1E-6 -> 1
+dqcms510 comparesig 1 1E-5 -> 1
+dqcms511 comparesig 1 1E-4 -> 1
+dqcms512 comparesig 1 1E-3 -> 1
+dqcms513 comparesig 1 1E-2 -> 1
+dqcms514 comparesig 1 1E-1 -> 1
+dqcms515 comparesig 1 1E-0 -> 0
+dqcms516 comparesig 1 1E+1 -> -1
+dqcms517 comparesig 1 1E+2 -> -1
+dqcms518 comparesig 1 1E+3 -> -1
+dqcms519 comparesig 1 1E+4 -> -1
+dqcms521 comparesig 1 1E+5 -> -1
+dqcms522 comparesig 1 1E+6 -> -1
+dqcms523 comparesig 1 1E+7 -> -1
+dqcms524 comparesig 1 1E+8 -> -1
+dqcms525 comparesig 1 1E+9 -> -1
+dqcms526 comparesig 1 1E+10 -> -1
+dqcms527 comparesig 1 1E+11 -> -1
+dqcms528 comparesig 1 1E+12 -> -1
+dqcms529 comparesig 1 1E+13 -> -1
+dqcms530 comparesig 1 1E+14 -> -1
+dqcms531 comparesig 1 1E+15 -> -1
+-- LR swap
+dqcms540 comparesig 1E-15 1 -> -1
+dqcms541 comparesig 1E-14 1 -> -1
+dqcms542 comparesig 1E-13 1 -> -1
+dqcms543 comparesig 1E-12 1 -> -1
+dqcms544 comparesig 1E-11 1 -> -1
+dqcms545 comparesig 1E-10 1 -> -1
+dqcms546 comparesig 1E-9 1 -> -1
+dqcms547 comparesig 1E-8 1 -> -1
+dqcms548 comparesig 1E-7 1 -> -1
+dqcms549 comparesig 1E-6 1 -> -1
+dqcms550 comparesig 1E-5 1 -> -1
+dqcms551 comparesig 1E-4 1 -> -1
+dqcms552 comparesig 1E-3 1 -> -1
+dqcms553 comparesig 1E-2 1 -> -1
+dqcms554 comparesig 1E-1 1 -> -1
+dqcms555 comparesig 1E-0 1 -> 0
+dqcms556 comparesig 1E+1 1 -> 1
+dqcms557 comparesig 1E+2 1 -> 1
+dqcms558 comparesig 1E+3 1 -> 1
+dqcms559 comparesig 1E+4 1 -> 1
+dqcms561 comparesig 1E+5 1 -> 1
+dqcms562 comparesig 1E+6 1 -> 1
+dqcms563 comparesig 1E+7 1 -> 1
+dqcms564 comparesig 1E+8 1 -> 1
+dqcms565 comparesig 1E+9 1 -> 1
+dqcms566 comparesig 1E+10 1 -> 1
+dqcms567 comparesig 1E+11 1 -> 1
+dqcms568 comparesig 1E+12 1 -> 1
+dqcms569 comparesig 1E+13 1 -> 1
+dqcms570 comparesig 1E+14 1 -> 1
+dqcms571 comparesig 1E+15 1 -> 1
+-- similar with a useful coefficient, one side only
+dqcms580 comparesig 0.000000987654321 1E-15 -> 1
+dqcms581 comparesig 0.000000987654321 1E-14 -> 1
+dqcms582 comparesig 0.000000987654321 1E-13 -> 1
+dqcms583 comparesig 0.000000987654321 1E-12 -> 1
+dqcms584 comparesig 0.000000987654321 1E-11 -> 1
+dqcms585 comparesig 0.000000987654321 1E-10 -> 1
+dqcms586 comparesig 0.000000987654321 1E-9 -> 1
+dqcms587 comparesig 0.000000987654321 1E-8 -> 1
+dqcms588 comparesig 0.000000987654321 1E-7 -> 1
+dqcms589 comparesig 0.000000987654321 1E-6 -> -1
+dqcms590 comparesig 0.000000987654321 1E-5 -> -1
+dqcms591 comparesig 0.000000987654321 1E-4 -> -1
+dqcms592 comparesig 0.000000987654321 1E-3 -> -1
+dqcms593 comparesig 0.000000987654321 1E-2 -> -1
+dqcms594 comparesig 0.000000987654321 1E-1 -> -1
+dqcms595 comparesig 0.000000987654321 1E-0 -> -1
+dqcms596 comparesig 0.000000987654321 1E+1 -> -1
+dqcms597 comparesig 0.000000987654321 1E+2 -> -1
+dqcms598 comparesig 0.000000987654321 1E+3 -> -1
+dqcms599 comparesig 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+dqcms600 comparesig 12 12.2345 -> -1
+dqcms601 comparesig 12.0 12.2345 -> -1
+dqcms602 comparesig 12.00 12.2345 -> -1
+dqcms603 comparesig 12.000 12.2345 -> -1
+dqcms604 comparesig 12.0000 12.2345 -> -1
+dqcms605 comparesig 12.00000 12.2345 -> -1
+dqcms606 comparesig 12.000000 12.2345 -> -1
+dqcms607 comparesig 12.0000000 12.2345 -> -1
+dqcms608 comparesig 12.00000000 12.2345 -> -1
+dqcms609 comparesig 12.000000000 12.2345 -> -1
+dqcms610 comparesig 12.1234 12 -> 1
+dqcms611 comparesig 12.1234 12.0 -> 1
+dqcms612 comparesig 12.1234 12.00 -> 1
+dqcms613 comparesig 12.1234 12.000 -> 1
+dqcms614 comparesig 12.1234 12.0000 -> 1
+dqcms615 comparesig 12.1234 12.00000 -> 1
+dqcms616 comparesig 12.1234 12.000000 -> 1
+dqcms617 comparesig 12.1234 12.0000000 -> 1
+dqcms618 comparesig 12.1234 12.00000000 -> 1
+dqcms619 comparesig 12.1234 12.000000000 -> 1
+dqcms620 comparesig -12 -12.2345 -> 1
+dqcms621 comparesig -12.0 -12.2345 -> 1
+dqcms622 comparesig -12.00 -12.2345 -> 1
+dqcms623 comparesig -12.000 -12.2345 -> 1
+dqcms624 comparesig -12.0000 -12.2345 -> 1
+dqcms625 comparesig -12.00000 -12.2345 -> 1
+dqcms626 comparesig -12.000000 -12.2345 -> 1
+dqcms627 comparesig -12.0000000 -12.2345 -> 1
+dqcms628 comparesig -12.00000000 -12.2345 -> 1
+dqcms629 comparesig -12.000000000 -12.2345 -> 1
+dqcms630 comparesig -12.1234 -12 -> -1
+dqcms631 comparesig -12.1234 -12.0 -> -1
+dqcms632 comparesig -12.1234 -12.00 -> -1
+dqcms633 comparesig -12.1234 -12.000 -> -1
+dqcms634 comparesig -12.1234 -12.0000 -> -1
+dqcms635 comparesig -12.1234 -12.00000 -> -1
+dqcms636 comparesig -12.1234 -12.000000 -> -1
+dqcms637 comparesig -12.1234 -12.0000000 -> -1
+dqcms638 comparesig -12.1234 -12.00000000 -> -1
+dqcms639 comparesig -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+dqcms640 comparesig 0 0 -> 0
+dqcms641 comparesig 0 -0 -> 0
+dqcms642 comparesig 0 -0.0 -> 0
+dqcms643 comparesig 0 0.0 -> 0
+dqcms644 comparesig -0 0 -> 0
+dqcms645 comparesig -0 -0 -> 0
+dqcms646 comparesig -0 -0.0 -> 0
+dqcms647 comparesig -0 0.0 -> 0
+dqcms648 comparesig 0.0 0 -> 0
+dqcms649 comparesig 0.0 -0 -> 0
+dqcms650 comparesig 0.0 -0.0 -> 0
+dqcms651 comparesig 0.0 0.0 -> 0
+dqcms652 comparesig -0.0 0 -> 0
+dqcms653 comparesig -0.0 -0 -> 0
+dqcms654 comparesig -0.0 -0.0 -> 0
+dqcms655 comparesig -0.0 0.0 -> 0
+
+dqcms656 comparesig -0E1 0.0 -> 0
+dqcms657 comparesig -0E2 0.0 -> 0
+dqcms658 comparesig 0E1 0.0 -> 0
+dqcms659 comparesig 0E2 0.0 -> 0
+dqcms660 comparesig -0E1 0 -> 0
+dqcms661 comparesig -0E2 0 -> 0
+dqcms662 comparesig 0E1 0 -> 0
+dqcms663 comparesig 0E2 0 -> 0
+dqcms664 comparesig -0E1 -0E1 -> 0
+dqcms665 comparesig -0E2 -0E1 -> 0
+dqcms666 comparesig 0E1 -0E1 -> 0
+dqcms667 comparesig 0E2 -0E1 -> 0
+dqcms668 comparesig -0E1 -0E2 -> 0
+dqcms669 comparesig -0E2 -0E2 -> 0
+dqcms670 comparesig 0E1 -0E2 -> 0
+dqcms671 comparesig 0E2 -0E2 -> 0
+dqcms672 comparesig -0E1 0E1 -> 0
+dqcms673 comparesig -0E2 0E1 -> 0
+dqcms674 comparesig 0E1 0E1 -> 0
+dqcms675 comparesig 0E2 0E1 -> 0
+dqcms676 comparesig -0E1 0E2 -> 0
+dqcms677 comparesig -0E2 0E2 -> 0
+dqcms678 comparesig 0E1 0E2 -> 0
+dqcms679 comparesig 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+dqcms680 comparesig 12 12 -> 0
+dqcms681 comparesig 12 12.0 -> 0
+dqcms682 comparesig 12 12.00 -> 0
+dqcms683 comparesig 12 12.000 -> 0
+dqcms684 comparesig 12 12.0000 -> 0
+dqcms685 comparesig 12 12.00000 -> 0
+dqcms686 comparesig 12 12.000000 -> 0
+dqcms687 comparesig 12 12.0000000 -> 0
+dqcms688 comparesig 12 12.00000000 -> 0
+dqcms689 comparesig 12 12.000000000 -> 0
+dqcms690 comparesig 12 12 -> 0
+dqcms691 comparesig 12.0 12 -> 0
+dqcms692 comparesig 12.00 12 -> 0
+dqcms693 comparesig 12.000 12 -> 0
+dqcms694 comparesig 12.0000 12 -> 0
+dqcms695 comparesig 12.00000 12 -> 0
+dqcms696 comparesig 12.000000 12 -> 0
+dqcms697 comparesig 12.0000000 12 -> 0
+dqcms698 comparesig 12.00000000 12 -> 0
+dqcms699 comparesig 12.000000000 12 -> 0
+
+-- first, second, & last digit
+dqcms700 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
+dqcms701 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
+dqcms702 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
+dqcms703 comparesig 1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
+dqcms704 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
+dqcms705 comparesig 1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
+dqcms706 comparesig 1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
+dqcms707 comparesig 1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
+dqcms708 comparesig 1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1
+
+-- miscellaneous
+dqcms721 comparesig 12345678000 1 -> 1
+dqcms722 comparesig 1 12345678000 -> -1
+dqcms723 comparesig 1234567800 1 -> 1
+dqcms724 comparesig 1 1234567800 -> -1
+dqcms725 comparesig 1234567890 1 -> 1
+dqcms726 comparesig 1 1234567890 -> -1
+dqcms727 comparesig 1234567891 1 -> 1
+dqcms728 comparesig 1 1234567891 -> -1
+dqcms729 comparesig 12345678901 1 -> 1
+dqcms730 comparesig 1 12345678901 -> -1
+dqcms731 comparesig 1234567896 1 -> 1
+dqcms732 comparesig 1 1234567896 -> -1
+
+-- residue cases at lower precision
+dqcms740 comparesig 1 0.9999999 -> 1
+dqcms741 comparesig 1 0.999999 -> 1
+dqcms742 comparesig 1 0.99999 -> 1
+dqcms743 comparesig 1 1.0000 -> 0
+dqcms744 comparesig 1 1.00001 -> -1
+dqcms745 comparesig 1 1.000001 -> -1
+dqcms746 comparesig 1 1.0000001 -> -1
+dqcms750 comparesig 0.9999999 1 -> -1
+dqcms751 comparesig 0.999999 1 -> -1
+dqcms752 comparesig 0.99999 1 -> -1
+dqcms753 comparesig 1.0000 1 -> 0
+dqcms754 comparesig 1.00001 1 -> 1
+dqcms755 comparesig 1.000001 1 -> 1
+dqcms756 comparesig 1.0000001 1 -> 1
+
+-- Specials
+dqcms780 comparesig Inf -Inf -> 1
+dqcms781 comparesig Inf -1000 -> 1
+dqcms782 comparesig Inf -1 -> 1
+dqcms783 comparesig Inf -0 -> 1
+dqcms784 comparesig Inf 0 -> 1
+dqcms785 comparesig Inf 1 -> 1
+dqcms786 comparesig Inf 1000 -> 1
+dqcms787 comparesig Inf Inf -> 0
+dqcms788 comparesig -1000 Inf -> -1
+dqcms789 comparesig -Inf Inf -> -1
+dqcms790 comparesig -1 Inf -> -1
+dqcms791 comparesig -0 Inf -> -1
+dqcms792 comparesig 0 Inf -> -1
+dqcms793 comparesig 1 Inf -> -1
+dqcms794 comparesig 1000 Inf -> -1
+dqcms795 comparesig Inf Inf -> 0
+
+dqcms800 comparesig -Inf -Inf -> 0
+dqcms801 comparesig -Inf -1000 -> -1
+dqcms802 comparesig -Inf -1 -> -1
+dqcms803 comparesig -Inf -0 -> -1
+dqcms804 comparesig -Inf 0 -> -1
+dqcms805 comparesig -Inf 1 -> -1
+dqcms806 comparesig -Inf 1000 -> -1
+dqcms807 comparesig -Inf Inf -> -1
+dqcms808 comparesig -Inf -Inf -> 0
+dqcms809 comparesig -1000 -Inf -> 1
+dqcms810 comparesig -1 -Inf -> 1
+dqcms811 comparesig -0 -Inf -> 1
+dqcms812 comparesig 0 -Inf -> 1
+dqcms813 comparesig 1 -Inf -> 1
+dqcms814 comparesig 1000 -Inf -> 1
+dqcms815 comparesig Inf -Inf -> 1
+
+dqcms821 comparesig NaN -Inf -> NaN Invalid_operation
+dqcms822 comparesig NaN -1000 -> NaN Invalid_operation
+dqcms823 comparesig NaN -1 -> NaN Invalid_operation
+dqcms824 comparesig NaN -0 -> NaN Invalid_operation
+dqcms825 comparesig NaN 0 -> NaN Invalid_operation
+dqcms826 comparesig NaN 1 -> NaN Invalid_operation
+dqcms827 comparesig NaN 1000 -> NaN Invalid_operation
+dqcms828 comparesig NaN Inf -> NaN Invalid_operation
+dqcms829 comparesig NaN NaN -> NaN Invalid_operation
+dqcms830 comparesig -Inf NaN -> NaN Invalid_operation
+dqcms831 comparesig -1000 NaN -> NaN Invalid_operation
+dqcms832 comparesig -1 NaN -> NaN Invalid_operation
+dqcms833 comparesig -0 NaN -> NaN Invalid_operation
+dqcms834 comparesig 0 NaN -> NaN Invalid_operation
+dqcms835 comparesig 1 NaN -> NaN Invalid_operation
+dqcms836 comparesig 1000 NaN -> NaN Invalid_operation
+dqcms837 comparesig Inf NaN -> NaN Invalid_operation
+dqcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
+dqcms839 comparesig +NaN -NaN -> NaN Invalid_operation
+dqcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
+
+dqcms841 comparesig sNaN -Inf -> NaN Invalid_operation
+dqcms842 comparesig sNaN -1000 -> NaN Invalid_operation
+dqcms843 comparesig sNaN -1 -> NaN Invalid_operation
+dqcms844 comparesig sNaN -0 -> NaN Invalid_operation
+dqcms845 comparesig sNaN 0 -> NaN Invalid_operation
+dqcms846 comparesig sNaN 1 -> NaN Invalid_operation
+dqcms847 comparesig sNaN 1000 -> NaN Invalid_operation
+dqcms848 comparesig sNaN NaN -> NaN Invalid_operation
+dqcms849 comparesig sNaN sNaN -> NaN Invalid_operation
+dqcms850 comparesig NaN sNaN -> NaN Invalid_operation
+dqcms851 comparesig -Inf sNaN -> NaN Invalid_operation
+dqcms852 comparesig -1000 sNaN -> NaN Invalid_operation
+dqcms853 comparesig -1 sNaN -> NaN Invalid_operation
+dqcms854 comparesig -0 sNaN -> NaN Invalid_operation
+dqcms855 comparesig 0 sNaN -> NaN Invalid_operation
+dqcms856 comparesig 1 sNaN -> NaN Invalid_operation
+dqcms857 comparesig 1000 sNaN -> NaN Invalid_operation
+dqcms858 comparesig Inf sNaN -> NaN Invalid_operation
+dqcms859 comparesig NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
+dqcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
+dqcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
+dqcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
+dqcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
+dqcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
+dqcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
+dqcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
+dqcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
+dqcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
+dqcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
+
+dqcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
+dqcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
+dqcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
+dqcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
+dqcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
+dqcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
+dqcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
+dqcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- wide range
+dqcms880 comparesig +1.23456789012345E-0 9E+6144 -> -1
+dqcms881 comparesig 9E+6144 +1.23456789012345E-0 -> 1
+dqcms882 comparesig +0.100 9E-6143 -> 1
+dqcms883 comparesig 9E-6143 +0.100 -> -1
+dqcms885 comparesig -1.23456789012345E-0 9E+6144 -> -1
+dqcms886 comparesig 9E+6144 -1.23456789012345E-0 -> 1
+dqcms887 comparesig -0.100 9E-6143 -> -1
+dqcms888 comparesig 9E-6143 -0.100 -> 1
+
+-- signs
+dqcms901 comparesig 1e+77 1e+11 -> 1
+dqcms902 comparesig 1e+77 -1e+11 -> 1
+dqcms903 comparesig -1e+77 1e+11 -> -1
+dqcms904 comparesig -1e+77 -1e+11 -> -1
+dqcms905 comparesig 1e-77 1e-11 -> -1
+dqcms906 comparesig 1e-77 -1e-11 -> 1
+dqcms907 comparesig -1e-77 1e-11 -> -1
+dqcms908 comparesig -1e-77 -1e-11 -> 1
+
+-- Null tests
+dqcms990 comparesig 10 # -> NaN Invalid_operation
+dqcms991 comparesig # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqCompareTotal.decTest b/Lib/test/decimaltestdata/dqCompareTotal.decTest
index 13701ccb57..bae3761909 100644
--- a/Lib/test/decimaltestdata/dqCompareTotal.decTest
+++ b/Lib/test/decimaltestdata/dqCompareTotal.decTest
@@ -1,706 +1,706 @@
-------------------------------------------------------------------------
--- dqCompareTotal.decTest -- decQuad comparison using total ordering --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqcot001 comparetotal -2 -2 -> 0
-dqcot002 comparetotal -2 -1 -> -1
-dqcot003 comparetotal -2 0 -> -1
-dqcot004 comparetotal -2 1 -> -1
-dqcot005 comparetotal -2 2 -> -1
-dqcot006 comparetotal -1 -2 -> 1
-dqcot007 comparetotal -1 -1 -> 0
-dqcot008 comparetotal -1 0 -> -1
-dqcot009 comparetotal -1 1 -> -1
-dqcot010 comparetotal -1 2 -> -1
-dqcot011 comparetotal 0 -2 -> 1
-dqcot012 comparetotal 0 -1 -> 1
-dqcot013 comparetotal 0 0 -> 0
-dqcot014 comparetotal 0 1 -> -1
-dqcot015 comparetotal 0 2 -> -1
-dqcot016 comparetotal 1 -2 -> 1
-dqcot017 comparetotal 1 -1 -> 1
-dqcot018 comparetotal 1 0 -> 1
-dqcot019 comparetotal 1 1 -> 0
-dqcot020 comparetotal 1 2 -> -1
-dqcot021 comparetotal 2 -2 -> 1
-dqcot022 comparetotal 2 -1 -> 1
-dqcot023 comparetotal 2 0 -> 1
-dqcot025 comparetotal 2 1 -> 1
-dqcot026 comparetotal 2 2 -> 0
-
-dqcot031 comparetotal -20 -20 -> 0
-dqcot032 comparetotal -20 -10 -> -1
-dqcot033 comparetotal -20 00 -> -1
-dqcot034 comparetotal -20 10 -> -1
-dqcot035 comparetotal -20 20 -> -1
-dqcot036 comparetotal -10 -20 -> 1
-dqcot037 comparetotal -10 -10 -> 0
-dqcot038 comparetotal -10 00 -> -1
-dqcot039 comparetotal -10 10 -> -1
-dqcot040 comparetotal -10 20 -> -1
-dqcot041 comparetotal 00 -20 -> 1
-dqcot042 comparetotal 00 -10 -> 1
-dqcot043 comparetotal 00 00 -> 0
-dqcot044 comparetotal 00 10 -> -1
-dqcot045 comparetotal 00 20 -> -1
-dqcot046 comparetotal 10 -20 -> 1
-dqcot047 comparetotal 10 -10 -> 1
-dqcot048 comparetotal 10 00 -> 1
-dqcot049 comparetotal 10 10 -> 0
-dqcot050 comparetotal 10 20 -> -1
-dqcot051 comparetotal 20 -20 -> 1
-dqcot052 comparetotal 20 -10 -> 1
-dqcot053 comparetotal 20 00 -> 1
-dqcot055 comparetotal 20 10 -> 1
-dqcot056 comparetotal 20 20 -> 0
-
-dqcot061 comparetotal -2.0 -2.0 -> 0
-dqcot062 comparetotal -2.0 -1.0 -> -1
-dqcot063 comparetotal -2.0 0.0 -> -1
-dqcot064 comparetotal -2.0 1.0 -> -1
-dqcot065 comparetotal -2.0 2.0 -> -1
-dqcot066 comparetotal -1.0 -2.0 -> 1
-dqcot067 comparetotal -1.0 -1.0 -> 0
-dqcot068 comparetotal -1.0 0.0 -> -1
-dqcot069 comparetotal -1.0 1.0 -> -1
-dqcot070 comparetotal -1.0 2.0 -> -1
-dqcot071 comparetotal 0.0 -2.0 -> 1
-dqcot072 comparetotal 0.0 -1.0 -> 1
-dqcot073 comparetotal 0.0 0.0 -> 0
-dqcot074 comparetotal 0.0 1.0 -> -1
-dqcot075 comparetotal 0.0 2.0 -> -1
-dqcot076 comparetotal 1.0 -2.0 -> 1
-dqcot077 comparetotal 1.0 -1.0 -> 1
-dqcot078 comparetotal 1.0 0.0 -> 1
-dqcot079 comparetotal 1.0 1.0 -> 0
-dqcot080 comparetotal 1.0 2.0 -> -1
-dqcot081 comparetotal 2.0 -2.0 -> 1
-dqcot082 comparetotal 2.0 -1.0 -> 1
-dqcot083 comparetotal 2.0 0.0 -> 1
-dqcot085 comparetotal 2.0 1.0 -> 1
-dqcot086 comparetotal 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-dqcot090 comparetotal 9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
-dqcot091 comparetotal -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> -1
-dqcot092 comparetotal 9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 1
-dqcot093 comparetotal -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-dqcot100 comparetotal 7.0 7.0 -> 0
-dqcot101 comparetotal 7.0 7 -> -1
-dqcot102 comparetotal 7 7.0 -> 1
-dqcot103 comparetotal 7E+0 7.0 -> 1
-dqcot104 comparetotal 70E-1 7.0 -> 0
-dqcot105 comparetotal 0.7E+1 7 -> 0
-dqcot106 comparetotal 70E-1 7 -> -1
-dqcot107 comparetotal 7.0 7E+0 -> -1
-dqcot108 comparetotal 7.0 70E-1 -> 0
-dqcot109 comparetotal 7 0.7E+1 -> 0
-dqcot110 comparetotal 7 70E-1 -> 1
-
-dqcot120 comparetotal 8.0 7.0 -> 1
-dqcot121 comparetotal 8.0 7 -> 1
-dqcot122 comparetotal 8 7.0 -> 1
-dqcot123 comparetotal 8E+0 7.0 -> 1
-dqcot124 comparetotal 80E-1 7.0 -> 1
-dqcot125 comparetotal 0.8E+1 7 -> 1
-dqcot126 comparetotal 80E-1 7 -> 1
-dqcot127 comparetotal 8.0 7E+0 -> 1
-dqcot128 comparetotal 8.0 70E-1 -> 1
-dqcot129 comparetotal 8 0.7E+1 -> 1
-dqcot130 comparetotal 8 70E-1 -> 1
-
-dqcot140 comparetotal 8.0 9.0 -> -1
-dqcot141 comparetotal 8.0 9 -> -1
-dqcot142 comparetotal 8 9.0 -> -1
-dqcot143 comparetotal 8E+0 9.0 -> -1
-dqcot144 comparetotal 80E-1 9.0 -> -1
-dqcot145 comparetotal 0.8E+1 9 -> -1
-dqcot146 comparetotal 80E-1 9 -> -1
-dqcot147 comparetotal 8.0 9E+0 -> -1
-dqcot148 comparetotal 8.0 90E-1 -> -1
-dqcot149 comparetotal 8 0.9E+1 -> -1
-dqcot150 comparetotal 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-dqcot200 comparetotal -7.0 7.0 -> -1
-dqcot201 comparetotal -7.0 7 -> -1
-dqcot202 comparetotal -7 7.0 -> -1
-dqcot203 comparetotal -7E+0 7.0 -> -1
-dqcot204 comparetotal -70E-1 7.0 -> -1
-dqcot205 comparetotal -0.7E+1 7 -> -1
-dqcot206 comparetotal -70E-1 7 -> -1
-dqcot207 comparetotal -7.0 7E+0 -> -1
-dqcot208 comparetotal -7.0 70E-1 -> -1
-dqcot209 comparetotal -7 0.7E+1 -> -1
-dqcot210 comparetotal -7 70E-1 -> -1
-
-dqcot220 comparetotal -8.0 7.0 -> -1
-dqcot221 comparetotal -8.0 7 -> -1
-dqcot222 comparetotal -8 7.0 -> -1
-dqcot223 comparetotal -8E+0 7.0 -> -1
-dqcot224 comparetotal -80E-1 7.0 -> -1
-dqcot225 comparetotal -0.8E+1 7 -> -1
-dqcot226 comparetotal -80E-1 7 -> -1
-dqcot227 comparetotal -8.0 7E+0 -> -1
-dqcot228 comparetotal -8.0 70E-1 -> -1
-dqcot229 comparetotal -8 0.7E+1 -> -1
-dqcot230 comparetotal -8 70E-1 -> -1
-
-dqcot240 comparetotal -8.0 9.0 -> -1
-dqcot241 comparetotal -8.0 9 -> -1
-dqcot242 comparetotal -8 9.0 -> -1
-dqcot243 comparetotal -8E+0 9.0 -> -1
-dqcot244 comparetotal -80E-1 9.0 -> -1
-dqcot245 comparetotal -0.8E+1 9 -> -1
-dqcot246 comparetotal -80E-1 9 -> -1
-dqcot247 comparetotal -8.0 9E+0 -> -1
-dqcot248 comparetotal -8.0 90E-1 -> -1
-dqcot249 comparetotal -8 0.9E+1 -> -1
-dqcot250 comparetotal -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-dqcot300 comparetotal 7.0 -7.0 -> 1
-dqcot301 comparetotal 7.0 -7 -> 1
-dqcot302 comparetotal 7 -7.0 -> 1
-dqcot303 comparetotal 7E+0 -7.0 -> 1
-dqcot304 comparetotal 70E-1 -7.0 -> 1
-dqcot305 comparetotal .7E+1 -7 -> 1
-dqcot306 comparetotal 70E-1 -7 -> 1
-dqcot307 comparetotal 7.0 -7E+0 -> 1
-dqcot308 comparetotal 7.0 -70E-1 -> 1
-dqcot309 comparetotal 7 -.7E+1 -> 1
-dqcot310 comparetotal 7 -70E-1 -> 1
-
-dqcot320 comparetotal 8.0 -7.0 -> 1
-dqcot321 comparetotal 8.0 -7 -> 1
-dqcot322 comparetotal 8 -7.0 -> 1
-dqcot323 comparetotal 8E+0 -7.0 -> 1
-dqcot324 comparetotal 80E-1 -7.0 -> 1
-dqcot325 comparetotal .8E+1 -7 -> 1
-dqcot326 comparetotal 80E-1 -7 -> 1
-dqcot327 comparetotal 8.0 -7E+0 -> 1
-dqcot328 comparetotal 8.0 -70E-1 -> 1
-dqcot329 comparetotal 8 -.7E+1 -> 1
-dqcot330 comparetotal 8 -70E-1 -> 1
-
-dqcot340 comparetotal 8.0 -9.0 -> 1
-dqcot341 comparetotal 8.0 -9 -> 1
-dqcot342 comparetotal 8 -9.0 -> 1
-dqcot343 comparetotal 8E+0 -9.0 -> 1
-dqcot344 comparetotal 80E-1 -9.0 -> 1
-dqcot345 comparetotal .8E+1 -9 -> 1
-dqcot346 comparetotal 80E-1 -9 -> 1
-dqcot347 comparetotal 8.0 -9E+0 -> 1
-dqcot348 comparetotal 8.0 -90E-1 -> 1
-dqcot349 comparetotal 8 -.9E+1 -> 1
-dqcot350 comparetotal 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-dqcot400 comparetotal -7.0 -7.0 -> 0
-dqcot401 comparetotal -7.0 -7 -> 1
-dqcot402 comparetotal -7 -7.0 -> -1
-dqcot403 comparetotal -7E+0 -7.0 -> -1
-dqcot404 comparetotal -70E-1 -7.0 -> 0
-dqcot405 comparetotal -.7E+1 -7 -> 0
-dqcot406 comparetotal -70E-1 -7 -> 1
-dqcot407 comparetotal -7.0 -7E+0 -> 1
-dqcot408 comparetotal -7.0 -70E-1 -> 0
-dqcot409 comparetotal -7 -.7E+1 -> 0
-dqcot410 comparetotal -7 -70E-1 -> -1
-
-dqcot420 comparetotal -8.0 -7.0 -> -1
-dqcot421 comparetotal -8.0 -7 -> -1
-dqcot422 comparetotal -8 -7.0 -> -1
-dqcot423 comparetotal -8E+0 -7.0 -> -1
-dqcot424 comparetotal -80E-1 -7.0 -> -1
-dqcot425 comparetotal -.8E+1 -7 -> -1
-dqcot426 comparetotal -80E-1 -7 -> -1
-dqcot427 comparetotal -8.0 -7E+0 -> -1
-dqcot428 comparetotal -8.0 -70E-1 -> -1
-dqcot429 comparetotal -8 -.7E+1 -> -1
-dqcot430 comparetotal -8 -70E-1 -> -1
-
-dqcot440 comparetotal -8.0 -9.0 -> 1
-dqcot441 comparetotal -8.0 -9 -> 1
-dqcot442 comparetotal -8 -9.0 -> 1
-dqcot443 comparetotal -8E+0 -9.0 -> 1
-dqcot444 comparetotal -80E-1 -9.0 -> 1
-dqcot445 comparetotal -.8E+1 -9 -> 1
-dqcot446 comparetotal -80E-1 -9 -> 1
-dqcot447 comparetotal -8.0 -9E+0 -> 1
-dqcot448 comparetotal -8.0 -90E-1 -> 1
-dqcot449 comparetotal -8 -.9E+1 -> 1
-dqcot450 comparetotal -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-dqcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
-dqcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
-dqcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
-dqcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
-dqcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
-dqcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
-dqcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
-dqcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
-dqcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
-dqcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
-dqcot483 comparetotal 123.456E-89 123.456E-89 -> 0
-dqcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
-dqcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
-dqcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
-dqcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
-dqcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
-dqcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
-dqcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
-dqcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
-dqcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
-dqcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
-dqcot497 comparetotal 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-dqcot498 comparetotal 1 1E-17 -> 1
-dqcot499 comparetotal 1 1E-16 -> 1
-dqcot500 comparetotal 1 1E-15 -> 1
-dqcot501 comparetotal 1 1E-14 -> 1
-dqcot502 comparetotal 1 1E-13 -> 1
-dqcot503 comparetotal 1 1E-12 -> 1
-dqcot504 comparetotal 1 1E-11 -> 1
-dqcot505 comparetotal 1 1E-10 -> 1
-dqcot506 comparetotal 1 1E-9 -> 1
-dqcot507 comparetotal 1 1E-8 -> 1
-dqcot508 comparetotal 1 1E-7 -> 1
-dqcot509 comparetotal 1 1E-6 -> 1
-dqcot510 comparetotal 1 1E-5 -> 1
-dqcot511 comparetotal 1 1E-4 -> 1
-dqcot512 comparetotal 1 1E-3 -> 1
-dqcot513 comparetotal 1 1E-2 -> 1
-dqcot514 comparetotal 1 1E-1 -> 1
-dqcot515 comparetotal 1 1E-0 -> 0
-dqcot516 comparetotal 1 1E+1 -> -1
-dqcot517 comparetotal 1 1E+2 -> -1
-dqcot518 comparetotal 1 1E+3 -> -1
-dqcot519 comparetotal 1 1E+4 -> -1
-dqcot521 comparetotal 1 1E+5 -> -1
-dqcot522 comparetotal 1 1E+6 -> -1
-dqcot523 comparetotal 1 1E+7 -> -1
-dqcot524 comparetotal 1 1E+8 -> -1
-dqcot525 comparetotal 1 1E+9 -> -1
-dqcot526 comparetotal 1 1E+10 -> -1
-dqcot527 comparetotal 1 1E+11 -> -1
-dqcot528 comparetotal 1 1E+12 -> -1
-dqcot529 comparetotal 1 1E+13 -> -1
-dqcot530 comparetotal 1 1E+14 -> -1
-dqcot531 comparetotal 1 1E+15 -> -1
-dqcot532 comparetotal 1 1E+16 -> -1
-dqcot533 comparetotal 1 1E+17 -> -1
--- LR swap
-dqcot538 comparetotal 1E-17 1 -> -1
-dqcot539 comparetotal 1E-16 1 -> -1
-dqcot540 comparetotal 1E-15 1 -> -1
-dqcot541 comparetotal 1E-14 1 -> -1
-dqcot542 comparetotal 1E-13 1 -> -1
-dqcot543 comparetotal 1E-12 1 -> -1
-dqcot544 comparetotal 1E-11 1 -> -1
-dqcot545 comparetotal 1E-10 1 -> -1
-dqcot546 comparetotal 1E-9 1 -> -1
-dqcot547 comparetotal 1E-8 1 -> -1
-dqcot548 comparetotal 1E-7 1 -> -1
-dqcot549 comparetotal 1E-6 1 -> -1
-dqcot550 comparetotal 1E-5 1 -> -1
-dqcot551 comparetotal 1E-4 1 -> -1
-dqcot552 comparetotal 1E-3 1 -> -1
-dqcot553 comparetotal 1E-2 1 -> -1
-dqcot554 comparetotal 1E-1 1 -> -1
-dqcot555 comparetotal 1E-0 1 -> 0
-dqcot556 comparetotal 1E+1 1 -> 1
-dqcot557 comparetotal 1E+2 1 -> 1
-dqcot558 comparetotal 1E+3 1 -> 1
-dqcot559 comparetotal 1E+4 1 -> 1
-dqcot561 comparetotal 1E+5 1 -> 1
-dqcot562 comparetotal 1E+6 1 -> 1
-dqcot563 comparetotal 1E+7 1 -> 1
-dqcot564 comparetotal 1E+8 1 -> 1
-dqcot565 comparetotal 1E+9 1 -> 1
-dqcot566 comparetotal 1E+10 1 -> 1
-dqcot567 comparetotal 1E+11 1 -> 1
-dqcot568 comparetotal 1E+12 1 -> 1
-dqcot569 comparetotal 1E+13 1 -> 1
-dqcot570 comparetotal 1E+14 1 -> 1
-dqcot571 comparetotal 1E+15 1 -> 1
-dqcot572 comparetotal 1E+16 1 -> 1
-dqcot573 comparetotal 1E+17 1 -> 1
--- similar with a useful coefficient, one side only
-dqcot578 comparetotal 0.000000987654321 1E-17 -> 1
-dqcot579 comparetotal 0.000000987654321 1E-16 -> 1
-dqcot580 comparetotal 0.000000987654321 1E-15 -> 1
-dqcot581 comparetotal 0.000000987654321 1E-14 -> 1
-dqcot582 comparetotal 0.000000987654321 1E-13 -> 1
-dqcot583 comparetotal 0.000000987654321 1E-12 -> 1
-dqcot584 comparetotal 0.000000987654321 1E-11 -> 1
-dqcot585 comparetotal 0.000000987654321 1E-10 -> 1
-dqcot586 comparetotal 0.000000987654321 1E-9 -> 1
-dqcot587 comparetotal 0.000000987654321 1E-8 -> 1
-dqcot588 comparetotal 0.000000987654321 1E-7 -> 1
-dqcot589 comparetotal 0.000000987654321 1E-6 -> -1
-dqcot590 comparetotal 0.000000987654321 1E-5 -> -1
-dqcot591 comparetotal 0.000000987654321 1E-4 -> -1
-dqcot592 comparetotal 0.000000987654321 1E-3 -> -1
-dqcot593 comparetotal 0.000000987654321 1E-2 -> -1
-dqcot594 comparetotal 0.000000987654321 1E-1 -> -1
-dqcot595 comparetotal 0.000000987654321 1E-0 -> -1
-dqcot596 comparetotal 0.000000987654321 1E+1 -> -1
-dqcot597 comparetotal 0.000000987654321 1E+2 -> -1
-dqcot598 comparetotal 0.000000987654321 1E+3 -> -1
-dqcot599 comparetotal 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-dqcot600 comparetotal 12 12.2345 -> -1
-dqcot601 comparetotal 12.0 12.2345 -> -1
-dqcot602 comparetotal 12.00 12.2345 -> -1
-dqcot603 comparetotal 12.000 12.2345 -> -1
-dqcot604 comparetotal 12.0000 12.2345 -> -1
-dqcot605 comparetotal 12.00000 12.2345 -> -1
-dqcot606 comparetotal 12.000000 12.2345 -> -1
-dqcot607 comparetotal 12.0000000 12.2345 -> -1
-dqcot608 comparetotal 12.00000000 12.2345 -> -1
-dqcot609 comparetotal 12.000000000 12.2345 -> -1
-dqcot610 comparetotal 12.1234 12 -> 1
-dqcot611 comparetotal 12.1234 12.0 -> 1
-dqcot612 comparetotal 12.1234 12.00 -> 1
-dqcot613 comparetotal 12.1234 12.000 -> 1
-dqcot614 comparetotal 12.1234 12.0000 -> 1
-dqcot615 comparetotal 12.1234 12.00000 -> 1
-dqcot616 comparetotal 12.1234 12.000000 -> 1
-dqcot617 comparetotal 12.1234 12.0000000 -> 1
-dqcot618 comparetotal 12.1234 12.00000000 -> 1
-dqcot619 comparetotal 12.1234 12.000000000 -> 1
-dqcot620 comparetotal -12 -12.2345 -> 1
-dqcot621 comparetotal -12.0 -12.2345 -> 1
-dqcot622 comparetotal -12.00 -12.2345 -> 1
-dqcot623 comparetotal -12.000 -12.2345 -> 1
-dqcot624 comparetotal -12.0000 -12.2345 -> 1
-dqcot625 comparetotal -12.00000 -12.2345 -> 1
-dqcot626 comparetotal -12.000000 -12.2345 -> 1
-dqcot627 comparetotal -12.0000000 -12.2345 -> 1
-dqcot628 comparetotal -12.00000000 -12.2345 -> 1
-dqcot629 comparetotal -12.000000000 -12.2345 -> 1
-dqcot630 comparetotal -12.1234 -12 -> -1
-dqcot631 comparetotal -12.1234 -12.0 -> -1
-dqcot632 comparetotal -12.1234 -12.00 -> -1
-dqcot633 comparetotal -12.1234 -12.000 -> -1
-dqcot634 comparetotal -12.1234 -12.0000 -> -1
-dqcot635 comparetotal -12.1234 -12.00000 -> -1
-dqcot636 comparetotal -12.1234 -12.000000 -> -1
-dqcot637 comparetotal -12.1234 -12.0000000 -> -1
-dqcot638 comparetotal -12.1234 -12.00000000 -> -1
-dqcot639 comparetotal -12.1234 -12.000000000 -> -1
-
--- extended zeros
-dqcot640 comparetotal 0 0 -> 0
-dqcot641 comparetotal 0 -0 -> 1
-dqcot642 comparetotal 0 -0.0 -> 1
-dqcot643 comparetotal 0 0.0 -> 1
-dqcot644 comparetotal -0 0 -> -1
-dqcot645 comparetotal -0 -0 -> 0
-dqcot646 comparetotal -0 -0.0 -> -1
-dqcot647 comparetotal -0 0.0 -> -1
-dqcot648 comparetotal 0.0 0 -> -1
-dqcot649 comparetotal 0.0 -0 -> 1
-dqcot650 comparetotal 0.0 -0.0 -> 1
-dqcot651 comparetotal 0.0 0.0 -> 0
-dqcot652 comparetotal -0.0 0 -> -1
-dqcot653 comparetotal -0.0 -0 -> 1
-dqcot654 comparetotal -0.0 -0.0 -> 0
-dqcot655 comparetotal -0.0 0.0 -> -1
-
-dqcot656 comparetotal -0E1 0.0 -> -1
-dqcot657 comparetotal -0E2 0.0 -> -1
-dqcot658 comparetotal 0E1 0.0 -> 1
-dqcot659 comparetotal 0E2 0.0 -> 1
-dqcot660 comparetotal -0E1 0 -> -1
-dqcot661 comparetotal -0E2 0 -> -1
-dqcot662 comparetotal 0E1 0 -> 1
-dqcot663 comparetotal 0E2 0 -> 1
-dqcot664 comparetotal -0E1 -0E1 -> 0
-dqcot665 comparetotal -0E2 -0E1 -> -1
-dqcot666 comparetotal 0E1 -0E1 -> 1
-dqcot667 comparetotal 0E2 -0E1 -> 1
-dqcot668 comparetotal -0E1 -0E2 -> 1
-dqcot669 comparetotal -0E2 -0E2 -> 0
-dqcot670 comparetotal 0E1 -0E2 -> 1
-dqcot671 comparetotal 0E2 -0E2 -> 1
-dqcot672 comparetotal -0E1 0E1 -> -1
-dqcot673 comparetotal -0E2 0E1 -> -1
-dqcot674 comparetotal 0E1 0E1 -> 0
-dqcot675 comparetotal 0E2 0E1 -> 1
-dqcot676 comparetotal -0E1 0E2 -> -1
-dqcot677 comparetotal -0E2 0E2 -> -1
-dqcot678 comparetotal 0E1 0E2 -> -1
-dqcot679 comparetotal 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-dqcot680 comparetotal 12 12 -> 0
-dqcot681 comparetotal 12 12.0 -> 1
-dqcot682 comparetotal 12 12.00 -> 1
-dqcot683 comparetotal 12 12.000 -> 1
-dqcot684 comparetotal 12 12.0000 -> 1
-dqcot685 comparetotal 12 12.00000 -> 1
-dqcot686 comparetotal 12 12.000000 -> 1
-dqcot687 comparetotal 12 12.0000000 -> 1
-dqcot688 comparetotal 12 12.00000000 -> 1
-dqcot689 comparetotal 12 12.000000000 -> 1
-dqcot690 comparetotal 12 12 -> 0
-dqcot691 comparetotal 12.0 12 -> -1
-dqcot692 comparetotal 12.00 12 -> -1
-dqcot693 comparetotal 12.000 12 -> -1
-dqcot694 comparetotal 12.0000 12 -> -1
-dqcot695 comparetotal 12.00000 12 -> -1
-dqcot696 comparetotal 12.000000 12 -> -1
-dqcot697 comparetotal 12.0000000 12 -> -1
-dqcot698 comparetotal 12.00000000 12 -> -1
-dqcot699 comparetotal 12.000000000 12 -> -1
-
--- old long operand checks
-dqcot701 comparetotal 12345678000 1 -> 1
-dqcot702 comparetotal 1 12345678000 -> -1
-dqcot703 comparetotal 1234567800 1 -> 1
-dqcot704 comparetotal 1 1234567800 -> -1
-dqcot705 comparetotal 1234567890 1 -> 1
-dqcot706 comparetotal 1 1234567890 -> -1
-dqcot707 comparetotal 1234567891 1 -> 1
-dqcot708 comparetotal 1 1234567891 -> -1
-dqcot709 comparetotal 12345678901 1 -> 1
-dqcot710 comparetotal 1 12345678901 -> -1
-dqcot711 comparetotal 1234567896 1 -> 1
-dqcot712 comparetotal 1 1234567896 -> -1
-dqcot713 comparetotal -1234567891 1 -> -1
-dqcot714 comparetotal 1 -1234567891 -> 1
-dqcot715 comparetotal -12345678901 1 -> -1
-dqcot716 comparetotal 1 -12345678901 -> 1
-dqcot717 comparetotal -1234567896 1 -> -1
-dqcot718 comparetotal 1 -1234567896 -> 1
-
--- old residue cases
-dqcot740 comparetotal 1 0.9999999 -> 1
-dqcot741 comparetotal 1 0.999999 -> 1
-dqcot742 comparetotal 1 0.99999 -> 1
-dqcot743 comparetotal 1 1.0000 -> 1
-dqcot744 comparetotal 1 1.00001 -> -1
-dqcot745 comparetotal 1 1.000001 -> -1
-dqcot746 comparetotal 1 1.0000001 -> -1
-dqcot750 comparetotal 0.9999999 1 -> -1
-dqcot751 comparetotal 0.999999 1 -> -1
-dqcot752 comparetotal 0.99999 1 -> -1
-dqcot753 comparetotal 1.0000 1 -> -1
-dqcot754 comparetotal 1.00001 1 -> 1
-dqcot755 comparetotal 1.000001 1 -> 1
-dqcot756 comparetotal 1.0000001 1 -> 1
-
--- Specials
-dqcot780 comparetotal Inf -Inf -> 1
-dqcot781 comparetotal Inf -1000 -> 1
-dqcot782 comparetotal Inf -1 -> 1
-dqcot783 comparetotal Inf -0 -> 1
-dqcot784 comparetotal Inf 0 -> 1
-dqcot785 comparetotal Inf 1 -> 1
-dqcot786 comparetotal Inf 1000 -> 1
-dqcot787 comparetotal Inf Inf -> 0
-dqcot788 comparetotal -1000 Inf -> -1
-dqcot789 comparetotal -Inf Inf -> -1
-dqcot790 comparetotal -1 Inf -> -1
-dqcot791 comparetotal -0 Inf -> -1
-dqcot792 comparetotal 0 Inf -> -1
-dqcot793 comparetotal 1 Inf -> -1
-dqcot794 comparetotal 1000 Inf -> -1
-dqcot795 comparetotal Inf Inf -> 0
-
-dqcot800 comparetotal -Inf -Inf -> 0
-dqcot801 comparetotal -Inf -1000 -> -1
-dqcot802 comparetotal -Inf -1 -> -1
-dqcot803 comparetotal -Inf -0 -> -1
-dqcot804 comparetotal -Inf 0 -> -1
-dqcot805 comparetotal -Inf 1 -> -1
-dqcot806 comparetotal -Inf 1000 -> -1
-dqcot807 comparetotal -Inf Inf -> -1
-dqcot808 comparetotal -Inf -Inf -> 0
-dqcot809 comparetotal -1000 -Inf -> 1
-dqcot810 comparetotal -1 -Inf -> 1
-dqcot811 comparetotal -0 -Inf -> 1
-dqcot812 comparetotal 0 -Inf -> 1
-dqcot813 comparetotal 1 -Inf -> 1
-dqcot814 comparetotal 1000 -Inf -> 1
-dqcot815 comparetotal Inf -Inf -> 1
-
-dqcot821 comparetotal NaN -Inf -> 1
-dqcot822 comparetotal NaN -1000 -> 1
-dqcot823 comparetotal NaN -1 -> 1
-dqcot824 comparetotal NaN -0 -> 1
-dqcot825 comparetotal NaN 0 -> 1
-dqcot826 comparetotal NaN 1 -> 1
-dqcot827 comparetotal NaN 1000 -> 1
-dqcot828 comparetotal NaN Inf -> 1
-dqcot829 comparetotal NaN NaN -> 0
-dqcot830 comparetotal -Inf NaN -> -1
-dqcot831 comparetotal -1000 NaN -> -1
-dqcot832 comparetotal -1 NaN -> -1
-dqcot833 comparetotal -0 NaN -> -1
-dqcot834 comparetotal 0 NaN -> -1
-dqcot835 comparetotal 1 NaN -> -1
-dqcot836 comparetotal 1000 NaN -> -1
-dqcot837 comparetotal Inf NaN -> -1
-dqcot838 comparetotal -NaN -NaN -> 0
-dqcot839 comparetotal +NaN -NaN -> 1
-dqcot840 comparetotal -NaN +NaN -> -1
-
-dqcot841 comparetotal sNaN -sNaN -> 1
-dqcot842 comparetotal sNaN -NaN -> 1
-dqcot843 comparetotal sNaN -Inf -> 1
-dqcot844 comparetotal sNaN -1000 -> 1
-dqcot845 comparetotal sNaN -1 -> 1
-dqcot846 comparetotal sNaN -0 -> 1
-dqcot847 comparetotal sNaN 0 -> 1
-dqcot848 comparetotal sNaN 1 -> 1
-dqcot849 comparetotal sNaN 1000 -> 1
-dqcot850 comparetotal sNaN NaN -> -1
-dqcot851 comparetotal sNaN sNaN -> 0
-
-dqcot852 comparetotal -sNaN sNaN -> -1
-dqcot853 comparetotal -NaN sNaN -> -1
-dqcot854 comparetotal -Inf sNaN -> -1
-dqcot855 comparetotal -1000 sNaN -> -1
-dqcot856 comparetotal -1 sNaN -> -1
-dqcot857 comparetotal -0 sNaN -> -1
-dqcot858 comparetotal 0 sNaN -> -1
-dqcot859 comparetotal 1 sNaN -> -1
-dqcot860 comparetotal 1000 sNaN -> -1
-dqcot861 comparetotal Inf sNaN -> -1
-dqcot862 comparetotal NaN sNaN -> 1
-dqcot863 comparetotal sNaN sNaN -> 0
-
-dqcot871 comparetotal -sNaN -sNaN -> 0
-dqcot872 comparetotal -sNaN -NaN -> 1
-dqcot873 comparetotal -sNaN -Inf -> -1
-dqcot874 comparetotal -sNaN -1000 -> -1
-dqcot875 comparetotal -sNaN -1 -> -1
-dqcot876 comparetotal -sNaN -0 -> -1
-dqcot877 comparetotal -sNaN 0 -> -1
-dqcot878 comparetotal -sNaN 1 -> -1
-dqcot879 comparetotal -sNaN 1000 -> -1
-dqcot880 comparetotal -sNaN NaN -> -1
-dqcot881 comparetotal -sNaN sNaN -> -1
-
-dqcot882 comparetotal -sNaN -sNaN -> 0
-dqcot883 comparetotal -NaN -sNaN -> -1
-dqcot884 comparetotal -Inf -sNaN -> 1
-dqcot885 comparetotal -1000 -sNaN -> 1
-dqcot886 comparetotal -1 -sNaN -> 1
-dqcot887 comparetotal -0 -sNaN -> 1
-dqcot888 comparetotal 0 -sNaN -> 1
-dqcot889 comparetotal 1 -sNaN -> 1
-dqcot890 comparetotal 1000 -sNaN -> 1
-dqcot891 comparetotal Inf -sNaN -> 1
-dqcot892 comparetotal NaN -sNaN -> 1
-dqcot893 comparetotal sNaN -sNaN -> 1
-
--- NaNs with payload
-dqcot960 comparetotal NaN9 -Inf -> 1
-dqcot961 comparetotal NaN8 999 -> 1
-dqcot962 comparetotal NaN77 Inf -> 1
-dqcot963 comparetotal -NaN67 NaN5 -> -1
-dqcot964 comparetotal -Inf -NaN4 -> 1
-dqcot965 comparetotal -999 -NaN33 -> 1
-dqcot966 comparetotal Inf NaN2 -> -1
-
-dqcot970 comparetotal -NaN41 -NaN42 -> 1
-dqcot971 comparetotal +NaN41 -NaN42 -> 1
-dqcot972 comparetotal -NaN41 +NaN42 -> -1
-dqcot973 comparetotal +NaN41 +NaN42 -> -1
-dqcot974 comparetotal -NaN42 -NaN01 -> -1
-dqcot975 comparetotal +NaN42 -NaN01 -> 1
-dqcot976 comparetotal -NaN42 +NaN01 -> -1
-dqcot977 comparetotal +NaN42 +NaN01 -> 1
-
-dqcot980 comparetotal -sNaN771 -sNaN772 -> 1
-dqcot981 comparetotal +sNaN771 -sNaN772 -> 1
-dqcot982 comparetotal -sNaN771 +sNaN772 -> -1
-dqcot983 comparetotal +sNaN771 +sNaN772 -> -1
-dqcot984 comparetotal -sNaN772 -sNaN771 -> -1
-dqcot985 comparetotal +sNaN772 -sNaN771 -> 1
-dqcot986 comparetotal -sNaN772 +sNaN771 -> -1
-dqcot987 comparetotal +sNaN772 +sNaN771 -> 1
-
-dqcot991 comparetotal -sNaN99 -Inf -> -1
-dqcot992 comparetotal sNaN98 -11 -> 1
-dqcot993 comparetotal sNaN97 NaN -> -1
-dqcot994 comparetotal sNaN16 sNaN94 -> -1
-dqcot995 comparetotal NaN85 sNaN83 -> 1
-dqcot996 comparetotal -Inf sNaN92 -> -1
-dqcot997 comparetotal 088 sNaN81 -> -1
-dqcot998 comparetotal Inf sNaN90 -> -1
-dqcot999 comparetotal NaN -sNaN89 -> 1
-
--- spread zeros
-dqcot1110 comparetotal 0E-6143 0 -> -1
-dqcot1111 comparetotal 0E-6143 -0 -> 1
-dqcot1112 comparetotal -0E-6143 0 -> -1
-dqcot1113 comparetotal -0E-6143 -0 -> 1
-dqcot1114 comparetotal 0E-6143 0E+6144 -> -1
-dqcot1115 comparetotal 0E-6143 -0E+6144 -> 1
-dqcot1116 comparetotal -0E-6143 0E+6144 -> -1
-dqcot1117 comparetotal -0E-6143 -0E+6144 -> 1
-dqcot1118 comparetotal 0 0E+6144 -> -1
-dqcot1119 comparetotal 0 -0E+6144 -> 1
-dqcot1120 comparetotal -0 0E+6144 -> -1
-dqcot1121 comparetotal -0 -0E+6144 -> 1
-
-dqcot1130 comparetotal 0E+6144 0 -> 1
-dqcot1131 comparetotal 0E+6144 -0 -> 1
-dqcot1132 comparetotal -0E+6144 0 -> -1
-dqcot1133 comparetotal -0E+6144 -0 -> -1
-dqcot1134 comparetotal 0E+6144 0E-6143 -> 1
-dqcot1135 comparetotal 0E+6144 -0E-6143 -> 1
-dqcot1136 comparetotal -0E+6144 0E-6143 -> -1
-dqcot1137 comparetotal -0E+6144 -0E-6143 -> -1
-dqcot1138 comparetotal 0 0E-6143 -> 1
-dqcot1139 comparetotal 0 -0E-6143 -> 1
-dqcot1140 comparetotal -0 0E-6143 -> -1
-dqcot1141 comparetotal -0 -0E-6143 -> -1
-
--- Null tests
-dqcot9990 comparetotal 10 # -> NaN Invalid_operation
-dqcot9991 comparetotal # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqCompareTotal.decTest -- decQuad comparison using total ordering --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqcot001 comparetotal -2 -2 -> 0
+dqcot002 comparetotal -2 -1 -> -1
+dqcot003 comparetotal -2 0 -> -1
+dqcot004 comparetotal -2 1 -> -1
+dqcot005 comparetotal -2 2 -> -1
+dqcot006 comparetotal -1 -2 -> 1
+dqcot007 comparetotal -1 -1 -> 0
+dqcot008 comparetotal -1 0 -> -1
+dqcot009 comparetotal -1 1 -> -1
+dqcot010 comparetotal -1 2 -> -1
+dqcot011 comparetotal 0 -2 -> 1
+dqcot012 comparetotal 0 -1 -> 1
+dqcot013 comparetotal 0 0 -> 0
+dqcot014 comparetotal 0 1 -> -1
+dqcot015 comparetotal 0 2 -> -1
+dqcot016 comparetotal 1 -2 -> 1
+dqcot017 comparetotal 1 -1 -> 1
+dqcot018 comparetotal 1 0 -> 1
+dqcot019 comparetotal 1 1 -> 0
+dqcot020 comparetotal 1 2 -> -1
+dqcot021 comparetotal 2 -2 -> 1
+dqcot022 comparetotal 2 -1 -> 1
+dqcot023 comparetotal 2 0 -> 1
+dqcot025 comparetotal 2 1 -> 1
+dqcot026 comparetotal 2 2 -> 0
+
+dqcot031 comparetotal -20 -20 -> 0
+dqcot032 comparetotal -20 -10 -> -1
+dqcot033 comparetotal -20 00 -> -1
+dqcot034 comparetotal -20 10 -> -1
+dqcot035 comparetotal -20 20 -> -1
+dqcot036 comparetotal -10 -20 -> 1
+dqcot037 comparetotal -10 -10 -> 0
+dqcot038 comparetotal -10 00 -> -1
+dqcot039 comparetotal -10 10 -> -1
+dqcot040 comparetotal -10 20 -> -1
+dqcot041 comparetotal 00 -20 -> 1
+dqcot042 comparetotal 00 -10 -> 1
+dqcot043 comparetotal 00 00 -> 0
+dqcot044 comparetotal 00 10 -> -1
+dqcot045 comparetotal 00 20 -> -1
+dqcot046 comparetotal 10 -20 -> 1
+dqcot047 comparetotal 10 -10 -> 1
+dqcot048 comparetotal 10 00 -> 1
+dqcot049 comparetotal 10 10 -> 0
+dqcot050 comparetotal 10 20 -> -1
+dqcot051 comparetotal 20 -20 -> 1
+dqcot052 comparetotal 20 -10 -> 1
+dqcot053 comparetotal 20 00 -> 1
+dqcot055 comparetotal 20 10 -> 1
+dqcot056 comparetotal 20 20 -> 0
+
+dqcot061 comparetotal -2.0 -2.0 -> 0
+dqcot062 comparetotal -2.0 -1.0 -> -1
+dqcot063 comparetotal -2.0 0.0 -> -1
+dqcot064 comparetotal -2.0 1.0 -> -1
+dqcot065 comparetotal -2.0 2.0 -> -1
+dqcot066 comparetotal -1.0 -2.0 -> 1
+dqcot067 comparetotal -1.0 -1.0 -> 0
+dqcot068 comparetotal -1.0 0.0 -> -1
+dqcot069 comparetotal -1.0 1.0 -> -1
+dqcot070 comparetotal -1.0 2.0 -> -1
+dqcot071 comparetotal 0.0 -2.0 -> 1
+dqcot072 comparetotal 0.0 -1.0 -> 1
+dqcot073 comparetotal 0.0 0.0 -> 0
+dqcot074 comparetotal 0.0 1.0 -> -1
+dqcot075 comparetotal 0.0 2.0 -> -1
+dqcot076 comparetotal 1.0 -2.0 -> 1
+dqcot077 comparetotal 1.0 -1.0 -> 1
+dqcot078 comparetotal 1.0 0.0 -> 1
+dqcot079 comparetotal 1.0 1.0 -> 0
+dqcot080 comparetotal 1.0 2.0 -> -1
+dqcot081 comparetotal 2.0 -2.0 -> 1
+dqcot082 comparetotal 2.0 -1.0 -> 1
+dqcot083 comparetotal 2.0 0.0 -> 1
+dqcot085 comparetotal 2.0 1.0 -> 1
+dqcot086 comparetotal 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+dqcot090 comparetotal 9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
+dqcot091 comparetotal -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> -1
+dqcot092 comparetotal 9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 1
+dqcot093 comparetotal -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+dqcot100 comparetotal 7.0 7.0 -> 0
+dqcot101 comparetotal 7.0 7 -> -1
+dqcot102 comparetotal 7 7.0 -> 1
+dqcot103 comparetotal 7E+0 7.0 -> 1
+dqcot104 comparetotal 70E-1 7.0 -> 0
+dqcot105 comparetotal 0.7E+1 7 -> 0
+dqcot106 comparetotal 70E-1 7 -> -1
+dqcot107 comparetotal 7.0 7E+0 -> -1
+dqcot108 comparetotal 7.0 70E-1 -> 0
+dqcot109 comparetotal 7 0.7E+1 -> 0
+dqcot110 comparetotal 7 70E-1 -> 1
+
+dqcot120 comparetotal 8.0 7.0 -> 1
+dqcot121 comparetotal 8.0 7 -> 1
+dqcot122 comparetotal 8 7.0 -> 1
+dqcot123 comparetotal 8E+0 7.0 -> 1
+dqcot124 comparetotal 80E-1 7.0 -> 1
+dqcot125 comparetotal 0.8E+1 7 -> 1
+dqcot126 comparetotal 80E-1 7 -> 1
+dqcot127 comparetotal 8.0 7E+0 -> 1
+dqcot128 comparetotal 8.0 70E-1 -> 1
+dqcot129 comparetotal 8 0.7E+1 -> 1
+dqcot130 comparetotal 8 70E-1 -> 1
+
+dqcot140 comparetotal 8.0 9.0 -> -1
+dqcot141 comparetotal 8.0 9 -> -1
+dqcot142 comparetotal 8 9.0 -> -1
+dqcot143 comparetotal 8E+0 9.0 -> -1
+dqcot144 comparetotal 80E-1 9.0 -> -1
+dqcot145 comparetotal 0.8E+1 9 -> -1
+dqcot146 comparetotal 80E-1 9 -> -1
+dqcot147 comparetotal 8.0 9E+0 -> -1
+dqcot148 comparetotal 8.0 90E-1 -> -1
+dqcot149 comparetotal 8 0.9E+1 -> -1
+dqcot150 comparetotal 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+dqcot200 comparetotal -7.0 7.0 -> -1
+dqcot201 comparetotal -7.0 7 -> -1
+dqcot202 comparetotal -7 7.0 -> -1
+dqcot203 comparetotal -7E+0 7.0 -> -1
+dqcot204 comparetotal -70E-1 7.0 -> -1
+dqcot205 comparetotal -0.7E+1 7 -> -1
+dqcot206 comparetotal -70E-1 7 -> -1
+dqcot207 comparetotal -7.0 7E+0 -> -1
+dqcot208 comparetotal -7.0 70E-1 -> -1
+dqcot209 comparetotal -7 0.7E+1 -> -1
+dqcot210 comparetotal -7 70E-1 -> -1
+
+dqcot220 comparetotal -8.0 7.0 -> -1
+dqcot221 comparetotal -8.0 7 -> -1
+dqcot222 comparetotal -8 7.0 -> -1
+dqcot223 comparetotal -8E+0 7.0 -> -1
+dqcot224 comparetotal -80E-1 7.0 -> -1
+dqcot225 comparetotal -0.8E+1 7 -> -1
+dqcot226 comparetotal -80E-1 7 -> -1
+dqcot227 comparetotal -8.0 7E+0 -> -1
+dqcot228 comparetotal -8.0 70E-1 -> -1
+dqcot229 comparetotal -8 0.7E+1 -> -1
+dqcot230 comparetotal -8 70E-1 -> -1
+
+dqcot240 comparetotal -8.0 9.0 -> -1
+dqcot241 comparetotal -8.0 9 -> -1
+dqcot242 comparetotal -8 9.0 -> -1
+dqcot243 comparetotal -8E+0 9.0 -> -1
+dqcot244 comparetotal -80E-1 9.0 -> -1
+dqcot245 comparetotal -0.8E+1 9 -> -1
+dqcot246 comparetotal -80E-1 9 -> -1
+dqcot247 comparetotal -8.0 9E+0 -> -1
+dqcot248 comparetotal -8.0 90E-1 -> -1
+dqcot249 comparetotal -8 0.9E+1 -> -1
+dqcot250 comparetotal -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+dqcot300 comparetotal 7.0 -7.0 -> 1
+dqcot301 comparetotal 7.0 -7 -> 1
+dqcot302 comparetotal 7 -7.0 -> 1
+dqcot303 comparetotal 7E+0 -7.0 -> 1
+dqcot304 comparetotal 70E-1 -7.0 -> 1
+dqcot305 comparetotal .7E+1 -7 -> 1
+dqcot306 comparetotal 70E-1 -7 -> 1
+dqcot307 comparetotal 7.0 -7E+0 -> 1
+dqcot308 comparetotal 7.0 -70E-1 -> 1
+dqcot309 comparetotal 7 -.7E+1 -> 1
+dqcot310 comparetotal 7 -70E-1 -> 1
+
+dqcot320 comparetotal 8.0 -7.0 -> 1
+dqcot321 comparetotal 8.0 -7 -> 1
+dqcot322 comparetotal 8 -7.0 -> 1
+dqcot323 comparetotal 8E+0 -7.0 -> 1
+dqcot324 comparetotal 80E-1 -7.0 -> 1
+dqcot325 comparetotal .8E+1 -7 -> 1
+dqcot326 comparetotal 80E-1 -7 -> 1
+dqcot327 comparetotal 8.0 -7E+0 -> 1
+dqcot328 comparetotal 8.0 -70E-1 -> 1
+dqcot329 comparetotal 8 -.7E+1 -> 1
+dqcot330 comparetotal 8 -70E-1 -> 1
+
+dqcot340 comparetotal 8.0 -9.0 -> 1
+dqcot341 comparetotal 8.0 -9 -> 1
+dqcot342 comparetotal 8 -9.0 -> 1
+dqcot343 comparetotal 8E+0 -9.0 -> 1
+dqcot344 comparetotal 80E-1 -9.0 -> 1
+dqcot345 comparetotal .8E+1 -9 -> 1
+dqcot346 comparetotal 80E-1 -9 -> 1
+dqcot347 comparetotal 8.0 -9E+0 -> 1
+dqcot348 comparetotal 8.0 -90E-1 -> 1
+dqcot349 comparetotal 8 -.9E+1 -> 1
+dqcot350 comparetotal 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+dqcot400 comparetotal -7.0 -7.0 -> 0
+dqcot401 comparetotal -7.0 -7 -> 1
+dqcot402 comparetotal -7 -7.0 -> -1
+dqcot403 comparetotal -7E+0 -7.0 -> -1
+dqcot404 comparetotal -70E-1 -7.0 -> 0
+dqcot405 comparetotal -.7E+1 -7 -> 0
+dqcot406 comparetotal -70E-1 -7 -> 1
+dqcot407 comparetotal -7.0 -7E+0 -> 1
+dqcot408 comparetotal -7.0 -70E-1 -> 0
+dqcot409 comparetotal -7 -.7E+1 -> 0
+dqcot410 comparetotal -7 -70E-1 -> -1
+
+dqcot420 comparetotal -8.0 -7.0 -> -1
+dqcot421 comparetotal -8.0 -7 -> -1
+dqcot422 comparetotal -8 -7.0 -> -1
+dqcot423 comparetotal -8E+0 -7.0 -> -1
+dqcot424 comparetotal -80E-1 -7.0 -> -1
+dqcot425 comparetotal -.8E+1 -7 -> -1
+dqcot426 comparetotal -80E-1 -7 -> -1
+dqcot427 comparetotal -8.0 -7E+0 -> -1
+dqcot428 comparetotal -8.0 -70E-1 -> -1
+dqcot429 comparetotal -8 -.7E+1 -> -1
+dqcot430 comparetotal -8 -70E-1 -> -1
+
+dqcot440 comparetotal -8.0 -9.0 -> 1
+dqcot441 comparetotal -8.0 -9 -> 1
+dqcot442 comparetotal -8 -9.0 -> 1
+dqcot443 comparetotal -8E+0 -9.0 -> 1
+dqcot444 comparetotal -80E-1 -9.0 -> 1
+dqcot445 comparetotal -.8E+1 -9 -> 1
+dqcot446 comparetotal -80E-1 -9 -> 1
+dqcot447 comparetotal -8.0 -9E+0 -> 1
+dqcot448 comparetotal -8.0 -90E-1 -> 1
+dqcot449 comparetotal -8 -.9E+1 -> 1
+dqcot450 comparetotal -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+dqcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
+dqcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
+dqcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
+dqcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
+dqcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
+dqcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
+dqcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
+dqcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
+dqcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
+dqcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
+dqcot483 comparetotal 123.456E-89 123.456E-89 -> 0
+dqcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
+dqcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
+dqcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
+dqcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
+dqcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
+dqcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
+dqcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
+dqcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
+dqcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
+dqcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
+dqcot497 comparetotal 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+dqcot498 comparetotal 1 1E-17 -> 1
+dqcot499 comparetotal 1 1E-16 -> 1
+dqcot500 comparetotal 1 1E-15 -> 1
+dqcot501 comparetotal 1 1E-14 -> 1
+dqcot502 comparetotal 1 1E-13 -> 1
+dqcot503 comparetotal 1 1E-12 -> 1
+dqcot504 comparetotal 1 1E-11 -> 1
+dqcot505 comparetotal 1 1E-10 -> 1
+dqcot506 comparetotal 1 1E-9 -> 1
+dqcot507 comparetotal 1 1E-8 -> 1
+dqcot508 comparetotal 1 1E-7 -> 1
+dqcot509 comparetotal 1 1E-6 -> 1
+dqcot510 comparetotal 1 1E-5 -> 1
+dqcot511 comparetotal 1 1E-4 -> 1
+dqcot512 comparetotal 1 1E-3 -> 1
+dqcot513 comparetotal 1 1E-2 -> 1
+dqcot514 comparetotal 1 1E-1 -> 1
+dqcot515 comparetotal 1 1E-0 -> 0
+dqcot516 comparetotal 1 1E+1 -> -1
+dqcot517 comparetotal 1 1E+2 -> -1
+dqcot518 comparetotal 1 1E+3 -> -1
+dqcot519 comparetotal 1 1E+4 -> -1
+dqcot521 comparetotal 1 1E+5 -> -1
+dqcot522 comparetotal 1 1E+6 -> -1
+dqcot523 comparetotal 1 1E+7 -> -1
+dqcot524 comparetotal 1 1E+8 -> -1
+dqcot525 comparetotal 1 1E+9 -> -1
+dqcot526 comparetotal 1 1E+10 -> -1
+dqcot527 comparetotal 1 1E+11 -> -1
+dqcot528 comparetotal 1 1E+12 -> -1
+dqcot529 comparetotal 1 1E+13 -> -1
+dqcot530 comparetotal 1 1E+14 -> -1
+dqcot531 comparetotal 1 1E+15 -> -1
+dqcot532 comparetotal 1 1E+16 -> -1
+dqcot533 comparetotal 1 1E+17 -> -1
+-- LR swap
+dqcot538 comparetotal 1E-17 1 -> -1
+dqcot539 comparetotal 1E-16 1 -> -1
+dqcot540 comparetotal 1E-15 1 -> -1
+dqcot541 comparetotal 1E-14 1 -> -1
+dqcot542 comparetotal 1E-13 1 -> -1
+dqcot543 comparetotal 1E-12 1 -> -1
+dqcot544 comparetotal 1E-11 1 -> -1
+dqcot545 comparetotal 1E-10 1 -> -1
+dqcot546 comparetotal 1E-9 1 -> -1
+dqcot547 comparetotal 1E-8 1 -> -1
+dqcot548 comparetotal 1E-7 1 -> -1
+dqcot549 comparetotal 1E-6 1 -> -1
+dqcot550 comparetotal 1E-5 1 -> -1
+dqcot551 comparetotal 1E-4 1 -> -1
+dqcot552 comparetotal 1E-3 1 -> -1
+dqcot553 comparetotal 1E-2 1 -> -1
+dqcot554 comparetotal 1E-1 1 -> -1
+dqcot555 comparetotal 1E-0 1 -> 0
+dqcot556 comparetotal 1E+1 1 -> 1
+dqcot557 comparetotal 1E+2 1 -> 1
+dqcot558 comparetotal 1E+3 1 -> 1
+dqcot559 comparetotal 1E+4 1 -> 1
+dqcot561 comparetotal 1E+5 1 -> 1
+dqcot562 comparetotal 1E+6 1 -> 1
+dqcot563 comparetotal 1E+7 1 -> 1
+dqcot564 comparetotal 1E+8 1 -> 1
+dqcot565 comparetotal 1E+9 1 -> 1
+dqcot566 comparetotal 1E+10 1 -> 1
+dqcot567 comparetotal 1E+11 1 -> 1
+dqcot568 comparetotal 1E+12 1 -> 1
+dqcot569 comparetotal 1E+13 1 -> 1
+dqcot570 comparetotal 1E+14 1 -> 1
+dqcot571 comparetotal 1E+15 1 -> 1
+dqcot572 comparetotal 1E+16 1 -> 1
+dqcot573 comparetotal 1E+17 1 -> 1
+-- similar with a useful coefficient, one side only
+dqcot578 comparetotal 0.000000987654321 1E-17 -> 1
+dqcot579 comparetotal 0.000000987654321 1E-16 -> 1
+dqcot580 comparetotal 0.000000987654321 1E-15 -> 1
+dqcot581 comparetotal 0.000000987654321 1E-14 -> 1
+dqcot582 comparetotal 0.000000987654321 1E-13 -> 1
+dqcot583 comparetotal 0.000000987654321 1E-12 -> 1
+dqcot584 comparetotal 0.000000987654321 1E-11 -> 1
+dqcot585 comparetotal 0.000000987654321 1E-10 -> 1
+dqcot586 comparetotal 0.000000987654321 1E-9 -> 1
+dqcot587 comparetotal 0.000000987654321 1E-8 -> 1
+dqcot588 comparetotal 0.000000987654321 1E-7 -> 1
+dqcot589 comparetotal 0.000000987654321 1E-6 -> -1
+dqcot590 comparetotal 0.000000987654321 1E-5 -> -1
+dqcot591 comparetotal 0.000000987654321 1E-4 -> -1
+dqcot592 comparetotal 0.000000987654321 1E-3 -> -1
+dqcot593 comparetotal 0.000000987654321 1E-2 -> -1
+dqcot594 comparetotal 0.000000987654321 1E-1 -> -1
+dqcot595 comparetotal 0.000000987654321 1E-0 -> -1
+dqcot596 comparetotal 0.000000987654321 1E+1 -> -1
+dqcot597 comparetotal 0.000000987654321 1E+2 -> -1
+dqcot598 comparetotal 0.000000987654321 1E+3 -> -1
+dqcot599 comparetotal 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+dqcot600 comparetotal 12 12.2345 -> -1
+dqcot601 comparetotal 12.0 12.2345 -> -1
+dqcot602 comparetotal 12.00 12.2345 -> -1
+dqcot603 comparetotal 12.000 12.2345 -> -1
+dqcot604 comparetotal 12.0000 12.2345 -> -1
+dqcot605 comparetotal 12.00000 12.2345 -> -1
+dqcot606 comparetotal 12.000000 12.2345 -> -1
+dqcot607 comparetotal 12.0000000 12.2345 -> -1
+dqcot608 comparetotal 12.00000000 12.2345 -> -1
+dqcot609 comparetotal 12.000000000 12.2345 -> -1
+dqcot610 comparetotal 12.1234 12 -> 1
+dqcot611 comparetotal 12.1234 12.0 -> 1
+dqcot612 comparetotal 12.1234 12.00 -> 1
+dqcot613 comparetotal 12.1234 12.000 -> 1
+dqcot614 comparetotal 12.1234 12.0000 -> 1
+dqcot615 comparetotal 12.1234 12.00000 -> 1
+dqcot616 comparetotal 12.1234 12.000000 -> 1
+dqcot617 comparetotal 12.1234 12.0000000 -> 1
+dqcot618 comparetotal 12.1234 12.00000000 -> 1
+dqcot619 comparetotal 12.1234 12.000000000 -> 1
+dqcot620 comparetotal -12 -12.2345 -> 1
+dqcot621 comparetotal -12.0 -12.2345 -> 1
+dqcot622 comparetotal -12.00 -12.2345 -> 1
+dqcot623 comparetotal -12.000 -12.2345 -> 1
+dqcot624 comparetotal -12.0000 -12.2345 -> 1
+dqcot625 comparetotal -12.00000 -12.2345 -> 1
+dqcot626 comparetotal -12.000000 -12.2345 -> 1
+dqcot627 comparetotal -12.0000000 -12.2345 -> 1
+dqcot628 comparetotal -12.00000000 -12.2345 -> 1
+dqcot629 comparetotal -12.000000000 -12.2345 -> 1
+dqcot630 comparetotal -12.1234 -12 -> -1
+dqcot631 comparetotal -12.1234 -12.0 -> -1
+dqcot632 comparetotal -12.1234 -12.00 -> -1
+dqcot633 comparetotal -12.1234 -12.000 -> -1
+dqcot634 comparetotal -12.1234 -12.0000 -> -1
+dqcot635 comparetotal -12.1234 -12.00000 -> -1
+dqcot636 comparetotal -12.1234 -12.000000 -> -1
+dqcot637 comparetotal -12.1234 -12.0000000 -> -1
+dqcot638 comparetotal -12.1234 -12.00000000 -> -1
+dqcot639 comparetotal -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+dqcot640 comparetotal 0 0 -> 0
+dqcot641 comparetotal 0 -0 -> 1
+dqcot642 comparetotal 0 -0.0 -> 1
+dqcot643 comparetotal 0 0.0 -> 1
+dqcot644 comparetotal -0 0 -> -1
+dqcot645 comparetotal -0 -0 -> 0
+dqcot646 comparetotal -0 -0.0 -> -1
+dqcot647 comparetotal -0 0.0 -> -1
+dqcot648 comparetotal 0.0 0 -> -1
+dqcot649 comparetotal 0.0 -0 -> 1
+dqcot650 comparetotal 0.0 -0.0 -> 1
+dqcot651 comparetotal 0.0 0.0 -> 0
+dqcot652 comparetotal -0.0 0 -> -1
+dqcot653 comparetotal -0.0 -0 -> 1
+dqcot654 comparetotal -0.0 -0.0 -> 0
+dqcot655 comparetotal -0.0 0.0 -> -1
+
+dqcot656 comparetotal -0E1 0.0 -> -1
+dqcot657 comparetotal -0E2 0.0 -> -1
+dqcot658 comparetotal 0E1 0.0 -> 1
+dqcot659 comparetotal 0E2 0.0 -> 1
+dqcot660 comparetotal -0E1 0 -> -1
+dqcot661 comparetotal -0E2 0 -> -1
+dqcot662 comparetotal 0E1 0 -> 1
+dqcot663 comparetotal 0E2 0 -> 1
+dqcot664 comparetotal -0E1 -0E1 -> 0
+dqcot665 comparetotal -0E2 -0E1 -> -1
+dqcot666 comparetotal 0E1 -0E1 -> 1
+dqcot667 comparetotal 0E2 -0E1 -> 1
+dqcot668 comparetotal -0E1 -0E2 -> 1
+dqcot669 comparetotal -0E2 -0E2 -> 0
+dqcot670 comparetotal 0E1 -0E2 -> 1
+dqcot671 comparetotal 0E2 -0E2 -> 1
+dqcot672 comparetotal -0E1 0E1 -> -1
+dqcot673 comparetotal -0E2 0E1 -> -1
+dqcot674 comparetotal 0E1 0E1 -> 0
+dqcot675 comparetotal 0E2 0E1 -> 1
+dqcot676 comparetotal -0E1 0E2 -> -1
+dqcot677 comparetotal -0E2 0E2 -> -1
+dqcot678 comparetotal 0E1 0E2 -> -1
+dqcot679 comparetotal 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+dqcot680 comparetotal 12 12 -> 0
+dqcot681 comparetotal 12 12.0 -> 1
+dqcot682 comparetotal 12 12.00 -> 1
+dqcot683 comparetotal 12 12.000 -> 1
+dqcot684 comparetotal 12 12.0000 -> 1
+dqcot685 comparetotal 12 12.00000 -> 1
+dqcot686 comparetotal 12 12.000000 -> 1
+dqcot687 comparetotal 12 12.0000000 -> 1
+dqcot688 comparetotal 12 12.00000000 -> 1
+dqcot689 comparetotal 12 12.000000000 -> 1
+dqcot690 comparetotal 12 12 -> 0
+dqcot691 comparetotal 12.0 12 -> -1
+dqcot692 comparetotal 12.00 12 -> -1
+dqcot693 comparetotal 12.000 12 -> -1
+dqcot694 comparetotal 12.0000 12 -> -1
+dqcot695 comparetotal 12.00000 12 -> -1
+dqcot696 comparetotal 12.000000 12 -> -1
+dqcot697 comparetotal 12.0000000 12 -> -1
+dqcot698 comparetotal 12.00000000 12 -> -1
+dqcot699 comparetotal 12.000000000 12 -> -1
+
+-- old long operand checks
+dqcot701 comparetotal 12345678000 1 -> 1
+dqcot702 comparetotal 1 12345678000 -> -1
+dqcot703 comparetotal 1234567800 1 -> 1
+dqcot704 comparetotal 1 1234567800 -> -1
+dqcot705 comparetotal 1234567890 1 -> 1
+dqcot706 comparetotal 1 1234567890 -> -1
+dqcot707 comparetotal 1234567891 1 -> 1
+dqcot708 comparetotal 1 1234567891 -> -1
+dqcot709 comparetotal 12345678901 1 -> 1
+dqcot710 comparetotal 1 12345678901 -> -1
+dqcot711 comparetotal 1234567896 1 -> 1
+dqcot712 comparetotal 1 1234567896 -> -1
+dqcot713 comparetotal -1234567891 1 -> -1
+dqcot714 comparetotal 1 -1234567891 -> 1
+dqcot715 comparetotal -12345678901 1 -> -1
+dqcot716 comparetotal 1 -12345678901 -> 1
+dqcot717 comparetotal -1234567896 1 -> -1
+dqcot718 comparetotal 1 -1234567896 -> 1
+
+-- old residue cases
+dqcot740 comparetotal 1 0.9999999 -> 1
+dqcot741 comparetotal 1 0.999999 -> 1
+dqcot742 comparetotal 1 0.99999 -> 1
+dqcot743 comparetotal 1 1.0000 -> 1
+dqcot744 comparetotal 1 1.00001 -> -1
+dqcot745 comparetotal 1 1.000001 -> -1
+dqcot746 comparetotal 1 1.0000001 -> -1
+dqcot750 comparetotal 0.9999999 1 -> -1
+dqcot751 comparetotal 0.999999 1 -> -1
+dqcot752 comparetotal 0.99999 1 -> -1
+dqcot753 comparetotal 1.0000 1 -> -1
+dqcot754 comparetotal 1.00001 1 -> 1
+dqcot755 comparetotal 1.000001 1 -> 1
+dqcot756 comparetotal 1.0000001 1 -> 1
+
+-- Specials
+dqcot780 comparetotal Inf -Inf -> 1
+dqcot781 comparetotal Inf -1000 -> 1
+dqcot782 comparetotal Inf -1 -> 1
+dqcot783 comparetotal Inf -0 -> 1
+dqcot784 comparetotal Inf 0 -> 1
+dqcot785 comparetotal Inf 1 -> 1
+dqcot786 comparetotal Inf 1000 -> 1
+dqcot787 comparetotal Inf Inf -> 0
+dqcot788 comparetotal -1000 Inf -> -1
+dqcot789 comparetotal -Inf Inf -> -1
+dqcot790 comparetotal -1 Inf -> -1
+dqcot791 comparetotal -0 Inf -> -1
+dqcot792 comparetotal 0 Inf -> -1
+dqcot793 comparetotal 1 Inf -> -1
+dqcot794 comparetotal 1000 Inf -> -1
+dqcot795 comparetotal Inf Inf -> 0
+
+dqcot800 comparetotal -Inf -Inf -> 0
+dqcot801 comparetotal -Inf -1000 -> -1
+dqcot802 comparetotal -Inf -1 -> -1
+dqcot803 comparetotal -Inf -0 -> -1
+dqcot804 comparetotal -Inf 0 -> -1
+dqcot805 comparetotal -Inf 1 -> -1
+dqcot806 comparetotal -Inf 1000 -> -1
+dqcot807 comparetotal -Inf Inf -> -1
+dqcot808 comparetotal -Inf -Inf -> 0
+dqcot809 comparetotal -1000 -Inf -> 1
+dqcot810 comparetotal -1 -Inf -> 1
+dqcot811 comparetotal -0 -Inf -> 1
+dqcot812 comparetotal 0 -Inf -> 1
+dqcot813 comparetotal 1 -Inf -> 1
+dqcot814 comparetotal 1000 -Inf -> 1
+dqcot815 comparetotal Inf -Inf -> 1
+
+dqcot821 comparetotal NaN -Inf -> 1
+dqcot822 comparetotal NaN -1000 -> 1
+dqcot823 comparetotal NaN -1 -> 1
+dqcot824 comparetotal NaN -0 -> 1
+dqcot825 comparetotal NaN 0 -> 1
+dqcot826 comparetotal NaN 1 -> 1
+dqcot827 comparetotal NaN 1000 -> 1
+dqcot828 comparetotal NaN Inf -> 1
+dqcot829 comparetotal NaN NaN -> 0
+dqcot830 comparetotal -Inf NaN -> -1
+dqcot831 comparetotal -1000 NaN -> -1
+dqcot832 comparetotal -1 NaN -> -1
+dqcot833 comparetotal -0 NaN -> -1
+dqcot834 comparetotal 0 NaN -> -1
+dqcot835 comparetotal 1 NaN -> -1
+dqcot836 comparetotal 1000 NaN -> -1
+dqcot837 comparetotal Inf NaN -> -1
+dqcot838 comparetotal -NaN -NaN -> 0
+dqcot839 comparetotal +NaN -NaN -> 1
+dqcot840 comparetotal -NaN +NaN -> -1
+
+dqcot841 comparetotal sNaN -sNaN -> 1
+dqcot842 comparetotal sNaN -NaN -> 1
+dqcot843 comparetotal sNaN -Inf -> 1
+dqcot844 comparetotal sNaN -1000 -> 1
+dqcot845 comparetotal sNaN -1 -> 1
+dqcot846 comparetotal sNaN -0 -> 1
+dqcot847 comparetotal sNaN 0 -> 1
+dqcot848 comparetotal sNaN 1 -> 1
+dqcot849 comparetotal sNaN 1000 -> 1
+dqcot850 comparetotal sNaN NaN -> -1
+dqcot851 comparetotal sNaN sNaN -> 0
+
+dqcot852 comparetotal -sNaN sNaN -> -1
+dqcot853 comparetotal -NaN sNaN -> -1
+dqcot854 comparetotal -Inf sNaN -> -1
+dqcot855 comparetotal -1000 sNaN -> -1
+dqcot856 comparetotal -1 sNaN -> -1
+dqcot857 comparetotal -0 sNaN -> -1
+dqcot858 comparetotal 0 sNaN -> -1
+dqcot859 comparetotal 1 sNaN -> -1
+dqcot860 comparetotal 1000 sNaN -> -1
+dqcot861 comparetotal Inf sNaN -> -1
+dqcot862 comparetotal NaN sNaN -> 1
+dqcot863 comparetotal sNaN sNaN -> 0
+
+dqcot871 comparetotal -sNaN -sNaN -> 0
+dqcot872 comparetotal -sNaN -NaN -> 1
+dqcot873 comparetotal -sNaN -Inf -> -1
+dqcot874 comparetotal -sNaN -1000 -> -1
+dqcot875 comparetotal -sNaN -1 -> -1
+dqcot876 comparetotal -sNaN -0 -> -1
+dqcot877 comparetotal -sNaN 0 -> -1
+dqcot878 comparetotal -sNaN 1 -> -1
+dqcot879 comparetotal -sNaN 1000 -> -1
+dqcot880 comparetotal -sNaN NaN -> -1
+dqcot881 comparetotal -sNaN sNaN -> -1
+
+dqcot882 comparetotal -sNaN -sNaN -> 0
+dqcot883 comparetotal -NaN -sNaN -> -1
+dqcot884 comparetotal -Inf -sNaN -> 1
+dqcot885 comparetotal -1000 -sNaN -> 1
+dqcot886 comparetotal -1 -sNaN -> 1
+dqcot887 comparetotal -0 -sNaN -> 1
+dqcot888 comparetotal 0 -sNaN -> 1
+dqcot889 comparetotal 1 -sNaN -> 1
+dqcot890 comparetotal 1000 -sNaN -> 1
+dqcot891 comparetotal Inf -sNaN -> 1
+dqcot892 comparetotal NaN -sNaN -> 1
+dqcot893 comparetotal sNaN -sNaN -> 1
+
+-- NaNs with payload
+dqcot960 comparetotal NaN9 -Inf -> 1
+dqcot961 comparetotal NaN8 999 -> 1
+dqcot962 comparetotal NaN77 Inf -> 1
+dqcot963 comparetotal -NaN67 NaN5 -> -1
+dqcot964 comparetotal -Inf -NaN4 -> 1
+dqcot965 comparetotal -999 -NaN33 -> 1
+dqcot966 comparetotal Inf NaN2 -> -1
+
+dqcot970 comparetotal -NaN41 -NaN42 -> 1
+dqcot971 comparetotal +NaN41 -NaN42 -> 1
+dqcot972 comparetotal -NaN41 +NaN42 -> -1
+dqcot973 comparetotal +NaN41 +NaN42 -> -1
+dqcot974 comparetotal -NaN42 -NaN01 -> -1
+dqcot975 comparetotal +NaN42 -NaN01 -> 1
+dqcot976 comparetotal -NaN42 +NaN01 -> -1
+dqcot977 comparetotal +NaN42 +NaN01 -> 1
+
+dqcot980 comparetotal -sNaN771 -sNaN772 -> 1
+dqcot981 comparetotal +sNaN771 -sNaN772 -> 1
+dqcot982 comparetotal -sNaN771 +sNaN772 -> -1
+dqcot983 comparetotal +sNaN771 +sNaN772 -> -1
+dqcot984 comparetotal -sNaN772 -sNaN771 -> -1
+dqcot985 comparetotal +sNaN772 -sNaN771 -> 1
+dqcot986 comparetotal -sNaN772 +sNaN771 -> -1
+dqcot987 comparetotal +sNaN772 +sNaN771 -> 1
+
+dqcot991 comparetotal -sNaN99 -Inf -> -1
+dqcot992 comparetotal sNaN98 -11 -> 1
+dqcot993 comparetotal sNaN97 NaN -> -1
+dqcot994 comparetotal sNaN16 sNaN94 -> -1
+dqcot995 comparetotal NaN85 sNaN83 -> 1
+dqcot996 comparetotal -Inf sNaN92 -> -1
+dqcot997 comparetotal 088 sNaN81 -> -1
+dqcot998 comparetotal Inf sNaN90 -> -1
+dqcot999 comparetotal NaN -sNaN89 -> 1
+
+-- spread zeros
+dqcot1110 comparetotal 0E-6143 0 -> -1
+dqcot1111 comparetotal 0E-6143 -0 -> 1
+dqcot1112 comparetotal -0E-6143 0 -> -1
+dqcot1113 comparetotal -0E-6143 -0 -> 1
+dqcot1114 comparetotal 0E-6143 0E+6144 -> -1
+dqcot1115 comparetotal 0E-6143 -0E+6144 -> 1
+dqcot1116 comparetotal -0E-6143 0E+6144 -> -1
+dqcot1117 comparetotal -0E-6143 -0E+6144 -> 1
+dqcot1118 comparetotal 0 0E+6144 -> -1
+dqcot1119 comparetotal 0 -0E+6144 -> 1
+dqcot1120 comparetotal -0 0E+6144 -> -1
+dqcot1121 comparetotal -0 -0E+6144 -> 1
+
+dqcot1130 comparetotal 0E+6144 0 -> 1
+dqcot1131 comparetotal 0E+6144 -0 -> 1
+dqcot1132 comparetotal -0E+6144 0 -> -1
+dqcot1133 comparetotal -0E+6144 -0 -> -1
+dqcot1134 comparetotal 0E+6144 0E-6143 -> 1
+dqcot1135 comparetotal 0E+6144 -0E-6143 -> 1
+dqcot1136 comparetotal -0E+6144 0E-6143 -> -1
+dqcot1137 comparetotal -0E+6144 -0E-6143 -> -1
+dqcot1138 comparetotal 0 0E-6143 -> 1
+dqcot1139 comparetotal 0 -0E-6143 -> 1
+dqcot1140 comparetotal -0 0E-6143 -> -1
+dqcot1141 comparetotal -0 -0E-6143 -> -1
+
+-- Null tests
+dqcot9990 comparetotal 10 # -> NaN Invalid_operation
+dqcot9991 comparetotal # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqCompareTotalMag.decTest b/Lib/test/decimaltestdata/dqCompareTotalMag.decTest
index 0b81bfbc24..48b3e086b1 100644
--- a/Lib/test/decimaltestdata/dqCompareTotalMag.decTest
+++ b/Lib/test/decimaltestdata/dqCompareTotalMag.decTest
@@ -1,706 +1,706 @@
-------------------------------------------------------------------------
--- dqCompareTotalMag.decTest -- decQuad comparison; abs. total order --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqctm001 comparetotmag -2 -2 -> 0
-dqctm002 comparetotmag -2 -1 -> 1
-dqctm003 comparetotmag -2 0 -> 1
-dqctm004 comparetotmag -2 1 -> 1
-dqctm005 comparetotmag -2 2 -> 0
-dqctm006 comparetotmag -1 -2 -> -1
-dqctm007 comparetotmag -1 -1 -> 0
-dqctm008 comparetotmag -1 0 -> 1
-dqctm009 comparetotmag -1 1 -> 0
-dqctm010 comparetotmag -1 2 -> -1
-dqctm011 comparetotmag 0 -2 -> -1
-dqctm012 comparetotmag 0 -1 -> -1
-dqctm013 comparetotmag 0 0 -> 0
-dqctm014 comparetotmag 0 1 -> -1
-dqctm015 comparetotmag 0 2 -> -1
-dqctm016 comparetotmag 1 -2 -> -1
-dqctm017 comparetotmag 1 -1 -> 0
-dqctm018 comparetotmag 1 0 -> 1
-dqctm019 comparetotmag 1 1 -> 0
-dqctm020 comparetotmag 1 2 -> -1
-dqctm021 comparetotmag 2 -2 -> 0
-dqctm022 comparetotmag 2 -1 -> 1
-dqctm023 comparetotmag 2 0 -> 1
-dqctm025 comparetotmag 2 1 -> 1
-dqctm026 comparetotmag 2 2 -> 0
-
-dqctm031 comparetotmag -20 -20 -> 0
-dqctm032 comparetotmag -20 -10 -> 1
-dqctm033 comparetotmag -20 00 -> 1
-dqctm034 comparetotmag -20 10 -> 1
-dqctm035 comparetotmag -20 20 -> 0
-dqctm036 comparetotmag -10 -20 -> -1
-dqctm037 comparetotmag -10 -10 -> 0
-dqctm038 comparetotmag -10 00 -> 1
-dqctm039 comparetotmag -10 10 -> 0
-dqctm040 comparetotmag -10 20 -> -1
-dqctm041 comparetotmag 00 -20 -> -1
-dqctm042 comparetotmag 00 -10 -> -1
-dqctm043 comparetotmag 00 00 -> 0
-dqctm044 comparetotmag 00 10 -> -1
-dqctm045 comparetotmag 00 20 -> -1
-dqctm046 comparetotmag 10 -20 -> -1
-dqctm047 comparetotmag 10 -10 -> 0
-dqctm048 comparetotmag 10 00 -> 1
-dqctm049 comparetotmag 10 10 -> 0
-dqctm050 comparetotmag 10 20 -> -1
-dqctm051 comparetotmag 20 -20 -> 0
-dqctm052 comparetotmag 20 -10 -> 1
-dqctm053 comparetotmag 20 00 -> 1
-dqctm055 comparetotmag 20 10 -> 1
-dqctm056 comparetotmag 20 20 -> 0
-
-dqctm061 comparetotmag -2.0 -2.0 -> 0
-dqctm062 comparetotmag -2.0 -1.0 -> 1
-dqctm063 comparetotmag -2.0 0.0 -> 1
-dqctm064 comparetotmag -2.0 1.0 -> 1
-dqctm065 comparetotmag -2.0 2.0 -> 0
-dqctm066 comparetotmag -1.0 -2.0 -> -1
-dqctm067 comparetotmag -1.0 -1.0 -> 0
-dqctm068 comparetotmag -1.0 0.0 -> 1
-dqctm069 comparetotmag -1.0 1.0 -> 0
-dqctm070 comparetotmag -1.0 2.0 -> -1
-dqctm071 comparetotmag 0.0 -2.0 -> -1
-dqctm072 comparetotmag 0.0 -1.0 -> -1
-dqctm073 comparetotmag 0.0 0.0 -> 0
-dqctm074 comparetotmag 0.0 1.0 -> -1
-dqctm075 comparetotmag 0.0 2.0 -> -1
-dqctm076 comparetotmag 1.0 -2.0 -> -1
-dqctm077 comparetotmag 1.0 -1.0 -> 0
-dqctm078 comparetotmag 1.0 0.0 -> 1
-dqctm079 comparetotmag 1.0 1.0 -> 0
-dqctm080 comparetotmag 1.0 2.0 -> -1
-dqctm081 comparetotmag 2.0 -2.0 -> 0
-dqctm082 comparetotmag 2.0 -1.0 -> 1
-dqctm083 comparetotmag 2.0 0.0 -> 1
-dqctm085 comparetotmag 2.0 1.0 -> 1
-dqctm086 comparetotmag 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-dqctm090 comparetotmag 9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
-dqctm091 comparetotmag -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
-dqctm092 comparetotmag 9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
-dqctm093 comparetotmag -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-dqctm100 comparetotmag 7.0 7.0 -> 0
-dqctm101 comparetotmag 7.0 7 -> -1
-dqctm102 comparetotmag 7 7.0 -> 1
-dqctm103 comparetotmag 7E+0 7.0 -> 1
-dqctm104 comparetotmag 70E-1 7.0 -> 0
-dqctm105 comparetotmag 0.7E+1 7 -> 0
-dqctm106 comparetotmag 70E-1 7 -> -1
-dqctm107 comparetotmag 7.0 7E+0 -> -1
-dqctm108 comparetotmag 7.0 70E-1 -> 0
-dqctm109 comparetotmag 7 0.7E+1 -> 0
-dqctm110 comparetotmag 7 70E-1 -> 1
-
-dqctm120 comparetotmag 8.0 7.0 -> 1
-dqctm121 comparetotmag 8.0 7 -> 1
-dqctm122 comparetotmag 8 7.0 -> 1
-dqctm123 comparetotmag 8E+0 7.0 -> 1
-dqctm124 comparetotmag 80E-1 7.0 -> 1
-dqctm125 comparetotmag 0.8E+1 7 -> 1
-dqctm126 comparetotmag 80E-1 7 -> 1
-dqctm127 comparetotmag 8.0 7E+0 -> 1
-dqctm128 comparetotmag 8.0 70E-1 -> 1
-dqctm129 comparetotmag 8 0.7E+1 -> 1
-dqctm130 comparetotmag 8 70E-1 -> 1
-
-dqctm140 comparetotmag 8.0 9.0 -> -1
-dqctm141 comparetotmag 8.0 9 -> -1
-dqctm142 comparetotmag 8 9.0 -> -1
-dqctm143 comparetotmag 8E+0 9.0 -> -1
-dqctm144 comparetotmag 80E-1 9.0 -> -1
-dqctm145 comparetotmag 0.8E+1 9 -> -1
-dqctm146 comparetotmag 80E-1 9 -> -1
-dqctm147 comparetotmag 8.0 9E+0 -> -1
-dqctm148 comparetotmag 8.0 90E-1 -> -1
-dqctm149 comparetotmag 8 0.9E+1 -> -1
-dqctm150 comparetotmag 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-dqctm200 comparetotmag -7.0 7.0 -> 0
-dqctm201 comparetotmag -7.0 7 -> -1
-dqctm202 comparetotmag -7 7.0 -> 1
-dqctm203 comparetotmag -7E+0 7.0 -> 1
-dqctm204 comparetotmag -70E-1 7.0 -> 0
-dqctm205 comparetotmag -0.7E+1 7 -> 0
-dqctm206 comparetotmag -70E-1 7 -> -1
-dqctm207 comparetotmag -7.0 7E+0 -> -1
-dqctm208 comparetotmag -7.0 70E-1 -> 0
-dqctm209 comparetotmag -7 0.7E+1 -> 0
-dqctm210 comparetotmag -7 70E-1 -> 1
-
-dqctm220 comparetotmag -8.0 7.0 -> 1
-dqctm221 comparetotmag -8.0 7 -> 1
-dqctm222 comparetotmag -8 7.0 -> 1
-dqctm223 comparetotmag -8E+0 7.0 -> 1
-dqctm224 comparetotmag -80E-1 7.0 -> 1
-dqctm225 comparetotmag -0.8E+1 7 -> 1
-dqctm226 comparetotmag -80E-1 7 -> 1
-dqctm227 comparetotmag -8.0 7E+0 -> 1
-dqctm228 comparetotmag -8.0 70E-1 -> 1
-dqctm229 comparetotmag -8 0.7E+1 -> 1
-dqctm230 comparetotmag -8 70E-1 -> 1
-
-dqctm240 comparetotmag -8.0 9.0 -> -1
-dqctm241 comparetotmag -8.0 9 -> -1
-dqctm242 comparetotmag -8 9.0 -> -1
-dqctm243 comparetotmag -8E+0 9.0 -> -1
-dqctm244 comparetotmag -80E-1 9.0 -> -1
-dqctm245 comparetotmag -0.8E+1 9 -> -1
-dqctm246 comparetotmag -80E-1 9 -> -1
-dqctm247 comparetotmag -8.0 9E+0 -> -1
-dqctm248 comparetotmag -8.0 90E-1 -> -1
-dqctm249 comparetotmag -8 0.9E+1 -> -1
-dqctm250 comparetotmag -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-dqctm300 comparetotmag 7.0 -7.0 -> 0
-dqctm301 comparetotmag 7.0 -7 -> -1
-dqctm302 comparetotmag 7 -7.0 -> 1
-dqctm303 comparetotmag 7E+0 -7.0 -> 1
-dqctm304 comparetotmag 70E-1 -7.0 -> 0
-dqctm305 comparetotmag .7E+1 -7 -> 0
-dqctm306 comparetotmag 70E-1 -7 -> -1
-dqctm307 comparetotmag 7.0 -7E+0 -> -1
-dqctm308 comparetotmag 7.0 -70E-1 -> 0
-dqctm309 comparetotmag 7 -.7E+1 -> 0
-dqctm310 comparetotmag 7 -70E-1 -> 1
-
-dqctm320 comparetotmag 8.0 -7.0 -> 1
-dqctm321 comparetotmag 8.0 -7 -> 1
-dqctm322 comparetotmag 8 -7.0 -> 1
-dqctm323 comparetotmag 8E+0 -7.0 -> 1
-dqctm324 comparetotmag 80E-1 -7.0 -> 1
-dqctm325 comparetotmag .8E+1 -7 -> 1
-dqctm326 comparetotmag 80E-1 -7 -> 1
-dqctm327 comparetotmag 8.0 -7E+0 -> 1
-dqctm328 comparetotmag 8.0 -70E-1 -> 1
-dqctm329 comparetotmag 8 -.7E+1 -> 1
-dqctm330 comparetotmag 8 -70E-1 -> 1
-
-dqctm340 comparetotmag 8.0 -9.0 -> -1
-dqctm341 comparetotmag 8.0 -9 -> -1
-dqctm342 comparetotmag 8 -9.0 -> -1
-dqctm343 comparetotmag 8E+0 -9.0 -> -1
-dqctm344 comparetotmag 80E-1 -9.0 -> -1
-dqctm345 comparetotmag .8E+1 -9 -> -1
-dqctm346 comparetotmag 80E-1 -9 -> -1
-dqctm347 comparetotmag 8.0 -9E+0 -> -1
-dqctm348 comparetotmag 8.0 -90E-1 -> -1
-dqctm349 comparetotmag 8 -.9E+1 -> -1
-dqctm350 comparetotmag 8 -90E-1 -> -1
-
--- and again, with sign changes -- ..
-dqctm400 comparetotmag -7.0 -7.0 -> 0
-dqctm401 comparetotmag -7.0 -7 -> -1
-dqctm402 comparetotmag -7 -7.0 -> 1
-dqctm403 comparetotmag -7E+0 -7.0 -> 1
-dqctm404 comparetotmag -70E-1 -7.0 -> 0
-dqctm405 comparetotmag -.7E+1 -7 -> 0
-dqctm406 comparetotmag -70E-1 -7 -> -1
-dqctm407 comparetotmag -7.0 -7E+0 -> -1
-dqctm408 comparetotmag -7.0 -70E-1 -> 0
-dqctm409 comparetotmag -7 -.7E+1 -> 0
-dqctm410 comparetotmag -7 -70E-1 -> 1
-
-dqctm420 comparetotmag -8.0 -7.0 -> 1
-dqctm421 comparetotmag -8.0 -7 -> 1
-dqctm422 comparetotmag -8 -7.0 -> 1
-dqctm423 comparetotmag -8E+0 -7.0 -> 1
-dqctm424 comparetotmag -80E-1 -7.0 -> 1
-dqctm425 comparetotmag -.8E+1 -7 -> 1
-dqctm426 comparetotmag -80E-1 -7 -> 1
-dqctm427 comparetotmag -8.0 -7E+0 -> 1
-dqctm428 comparetotmag -8.0 -70E-1 -> 1
-dqctm429 comparetotmag -8 -.7E+1 -> 1
-dqctm430 comparetotmag -8 -70E-1 -> 1
-
-dqctm440 comparetotmag -8.0 -9.0 -> -1
-dqctm441 comparetotmag -8.0 -9 -> -1
-dqctm442 comparetotmag -8 -9.0 -> -1
-dqctm443 comparetotmag -8E+0 -9.0 -> -1
-dqctm444 comparetotmag -80E-1 -9.0 -> -1
-dqctm445 comparetotmag -.8E+1 -9 -> -1
-dqctm446 comparetotmag -80E-1 -9 -> -1
-dqctm447 comparetotmag -8.0 -9E+0 -> -1
-dqctm448 comparetotmag -8.0 -90E-1 -> -1
-dqctm449 comparetotmag -8 -.9E+1 -> -1
-dqctm450 comparetotmag -8 -90E-1 -> -1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-dqctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
-dqctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
-dqctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
-dqctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
-dqctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
-dqctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
-dqctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
-dqctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
-dqctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
-dqctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
-dqctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
-dqctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
-dqctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
-dqctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
-dqctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
-dqctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
-dqctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
-dqctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
-dqctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
-dqctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
-dqctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
-dqctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-dqctm498 comparetotmag 1 1E-17 -> 1
-dqctm499 comparetotmag 1 1E-16 -> 1
-dqctm500 comparetotmag 1 1E-15 -> 1
-dqctm501 comparetotmag 1 1E-14 -> 1
-dqctm502 comparetotmag 1 1E-13 -> 1
-dqctm503 comparetotmag 1 1E-12 -> 1
-dqctm504 comparetotmag 1 1E-11 -> 1
-dqctm505 comparetotmag 1 1E-10 -> 1
-dqctm506 comparetotmag 1 1E-9 -> 1
-dqctm507 comparetotmag 1 1E-8 -> 1
-dqctm508 comparetotmag 1 1E-7 -> 1
-dqctm509 comparetotmag 1 1E-6 -> 1
-dqctm510 comparetotmag 1 1E-5 -> 1
-dqctm511 comparetotmag 1 1E-4 -> 1
-dqctm512 comparetotmag 1 1E-3 -> 1
-dqctm513 comparetotmag 1 1E-2 -> 1
-dqctm514 comparetotmag 1 1E-1 -> 1
-dqctm515 comparetotmag 1 1E-0 -> 0
-dqctm516 comparetotmag 1 1E+1 -> -1
-dqctm517 comparetotmag 1 1E+2 -> -1
-dqctm518 comparetotmag 1 1E+3 -> -1
-dqctm519 comparetotmag 1 1E+4 -> -1
-dqctm521 comparetotmag 1 1E+5 -> -1
-dqctm522 comparetotmag 1 1E+6 -> -1
-dqctm523 comparetotmag 1 1E+7 -> -1
-dqctm524 comparetotmag 1 1E+8 -> -1
-dqctm525 comparetotmag 1 1E+9 -> -1
-dqctm526 comparetotmag 1 1E+10 -> -1
-dqctm527 comparetotmag 1 1E+11 -> -1
-dqctm528 comparetotmag 1 1E+12 -> -1
-dqctm529 comparetotmag 1 1E+13 -> -1
-dqctm530 comparetotmag 1 1E+14 -> -1
-dqctm531 comparetotmag 1 1E+15 -> -1
-dqctm532 comparetotmag 1 1E+16 -> -1
-dqctm533 comparetotmag 1 1E+17 -> -1
--- LR swap
-dqctm538 comparetotmag 1E-17 1 -> -1
-dqctm539 comparetotmag 1E-16 1 -> -1
-dqctm540 comparetotmag 1E-15 1 -> -1
-dqctm541 comparetotmag 1E-14 1 -> -1
-dqctm542 comparetotmag 1E-13 1 -> -1
-dqctm543 comparetotmag 1E-12 1 -> -1
-dqctm544 comparetotmag 1E-11 1 -> -1
-dqctm545 comparetotmag 1E-10 1 -> -1
-dqctm546 comparetotmag 1E-9 1 -> -1
-dqctm547 comparetotmag 1E-8 1 -> -1
-dqctm548 comparetotmag 1E-7 1 -> -1
-dqctm549 comparetotmag 1E-6 1 -> -1
-dqctm550 comparetotmag 1E-5 1 -> -1
-dqctm551 comparetotmag 1E-4 1 -> -1
-dqctm552 comparetotmag 1E-3 1 -> -1
-dqctm553 comparetotmag 1E-2 1 -> -1
-dqctm554 comparetotmag 1E-1 1 -> -1
-dqctm555 comparetotmag 1E-0 1 -> 0
-dqctm556 comparetotmag 1E+1 1 -> 1
-dqctm557 comparetotmag 1E+2 1 -> 1
-dqctm558 comparetotmag 1E+3 1 -> 1
-dqctm559 comparetotmag 1E+4 1 -> 1
-dqctm561 comparetotmag 1E+5 1 -> 1
-dqctm562 comparetotmag 1E+6 1 -> 1
-dqctm563 comparetotmag 1E+7 1 -> 1
-dqctm564 comparetotmag 1E+8 1 -> 1
-dqctm565 comparetotmag 1E+9 1 -> 1
-dqctm566 comparetotmag 1E+10 1 -> 1
-dqctm567 comparetotmag 1E+11 1 -> 1
-dqctm568 comparetotmag 1E+12 1 -> 1
-dqctm569 comparetotmag 1E+13 1 -> 1
-dqctm570 comparetotmag 1E+14 1 -> 1
-dqctm571 comparetotmag 1E+15 1 -> 1
-dqctm572 comparetotmag 1E+16 1 -> 1
-dqctm573 comparetotmag 1E+17 1 -> 1
--- similar with a useful coefficient, one side only
-dqctm578 comparetotmag 0.000000987654321 1E-17 -> 1
-dqctm579 comparetotmag 0.000000987654321 1E-16 -> 1
-dqctm580 comparetotmag 0.000000987654321 1E-15 -> 1
-dqctm581 comparetotmag 0.000000987654321 1E-14 -> 1
-dqctm582 comparetotmag 0.000000987654321 1E-13 -> 1
-dqctm583 comparetotmag 0.000000987654321 1E-12 -> 1
-dqctm584 comparetotmag 0.000000987654321 1E-11 -> 1
-dqctm585 comparetotmag 0.000000987654321 1E-10 -> 1
-dqctm586 comparetotmag 0.000000987654321 1E-9 -> 1
-dqctm587 comparetotmag 0.000000987654321 1E-8 -> 1
-dqctm588 comparetotmag 0.000000987654321 1E-7 -> 1
-dqctm589 comparetotmag 0.000000987654321 1E-6 -> -1
-dqctm590 comparetotmag 0.000000987654321 1E-5 -> -1
-dqctm591 comparetotmag 0.000000987654321 1E-4 -> -1
-dqctm592 comparetotmag 0.000000987654321 1E-3 -> -1
-dqctm593 comparetotmag 0.000000987654321 1E-2 -> -1
-dqctm594 comparetotmag 0.000000987654321 1E-1 -> -1
-dqctm595 comparetotmag 0.000000987654321 1E-0 -> -1
-dqctm596 comparetotmag 0.000000987654321 1E+1 -> -1
-dqctm597 comparetotmag 0.000000987654321 1E+2 -> -1
-dqctm598 comparetotmag 0.000000987654321 1E+3 -> -1
-dqctm599 comparetotmag 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-dqctm600 comparetotmag 12 12.2345 -> -1
-dqctm601 comparetotmag 12.0 12.2345 -> -1
-dqctm602 comparetotmag 12.00 12.2345 -> -1
-dqctm603 comparetotmag 12.000 12.2345 -> -1
-dqctm604 comparetotmag 12.0000 12.2345 -> -1
-dqctm605 comparetotmag 12.00000 12.2345 -> -1
-dqctm606 comparetotmag 12.000000 12.2345 -> -1
-dqctm607 comparetotmag 12.0000000 12.2345 -> -1
-dqctm608 comparetotmag 12.00000000 12.2345 -> -1
-dqctm609 comparetotmag 12.000000000 12.2345 -> -1
-dqctm610 comparetotmag 12.1234 12 -> 1
-dqctm611 comparetotmag 12.1234 12.0 -> 1
-dqctm612 comparetotmag 12.1234 12.00 -> 1
-dqctm613 comparetotmag 12.1234 12.000 -> 1
-dqctm614 comparetotmag 12.1234 12.0000 -> 1
-dqctm615 comparetotmag 12.1234 12.00000 -> 1
-dqctm616 comparetotmag 12.1234 12.000000 -> 1
-dqctm617 comparetotmag 12.1234 12.0000000 -> 1
-dqctm618 comparetotmag 12.1234 12.00000000 -> 1
-dqctm619 comparetotmag 12.1234 12.000000000 -> 1
-dqctm620 comparetotmag -12 -12.2345 -> -1
-dqctm621 comparetotmag -12.0 -12.2345 -> -1
-dqctm622 comparetotmag -12.00 -12.2345 -> -1
-dqctm623 comparetotmag -12.000 -12.2345 -> -1
-dqctm624 comparetotmag -12.0000 -12.2345 -> -1
-dqctm625 comparetotmag -12.00000 -12.2345 -> -1
-dqctm626 comparetotmag -12.000000 -12.2345 -> -1
-dqctm627 comparetotmag -12.0000000 -12.2345 -> -1
-dqctm628 comparetotmag -12.00000000 -12.2345 -> -1
-dqctm629 comparetotmag -12.000000000 -12.2345 -> -1
-dqctm630 comparetotmag -12.1234 -12 -> 1
-dqctm631 comparetotmag -12.1234 -12.0 -> 1
-dqctm632 comparetotmag -12.1234 -12.00 -> 1
-dqctm633 comparetotmag -12.1234 -12.000 -> 1
-dqctm634 comparetotmag -12.1234 -12.0000 -> 1
-dqctm635 comparetotmag -12.1234 -12.00000 -> 1
-dqctm636 comparetotmag -12.1234 -12.000000 -> 1
-dqctm637 comparetotmag -12.1234 -12.0000000 -> 1
-dqctm638 comparetotmag -12.1234 -12.00000000 -> 1
-dqctm639 comparetotmag -12.1234 -12.000000000 -> 1
-
--- extended zeros
-dqctm640 comparetotmag 0 0 -> 0
-dqctm641 comparetotmag 0 -0 -> 0
-dqctm642 comparetotmag 0 -0.0 -> 1
-dqctm643 comparetotmag 0 0.0 -> 1
-dqctm644 comparetotmag -0 0 -> 0
-dqctm645 comparetotmag -0 -0 -> 0
-dqctm646 comparetotmag -0 -0.0 -> 1
-dqctm647 comparetotmag -0 0.0 -> 1
-dqctm648 comparetotmag 0.0 0 -> -1
-dqctm649 comparetotmag 0.0 -0 -> -1
-dqctm650 comparetotmag 0.0 -0.0 -> 0
-dqctm651 comparetotmag 0.0 0.0 -> 0
-dqctm652 comparetotmag -0.0 0 -> -1
-dqctm653 comparetotmag -0.0 -0 -> -1
-dqctm654 comparetotmag -0.0 -0.0 -> 0
-dqctm655 comparetotmag -0.0 0.0 -> 0
-
-dqctm656 comparetotmag -0E1 0.0 -> 1
-dqctm657 comparetotmag -0E2 0.0 -> 1
-dqctm658 comparetotmag 0E1 0.0 -> 1
-dqctm659 comparetotmag 0E2 0.0 -> 1
-dqctm660 comparetotmag -0E1 0 -> 1
-dqctm661 comparetotmag -0E2 0 -> 1
-dqctm662 comparetotmag 0E1 0 -> 1
-dqctm663 comparetotmag 0E2 0 -> 1
-dqctm664 comparetotmag -0E1 -0E1 -> 0
-dqctm665 comparetotmag -0E2 -0E1 -> 1
-dqctm666 comparetotmag 0E1 -0E1 -> 0
-dqctm667 comparetotmag 0E2 -0E1 -> 1
-dqctm668 comparetotmag -0E1 -0E2 -> -1
-dqctm669 comparetotmag -0E2 -0E2 -> 0
-dqctm670 comparetotmag 0E1 -0E2 -> -1
-dqctm671 comparetotmag 0E2 -0E2 -> 0
-dqctm672 comparetotmag -0E1 0E1 -> 0
-dqctm673 comparetotmag -0E2 0E1 -> 1
-dqctm674 comparetotmag 0E1 0E1 -> 0
-dqctm675 comparetotmag 0E2 0E1 -> 1
-dqctm676 comparetotmag -0E1 0E2 -> -1
-dqctm677 comparetotmag -0E2 0E2 -> 0
-dqctm678 comparetotmag 0E1 0E2 -> -1
-dqctm679 comparetotmag 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-dqctm680 comparetotmag 12 12 -> 0
-dqctm681 comparetotmag 12 12.0 -> 1
-dqctm682 comparetotmag 12 12.00 -> 1
-dqctm683 comparetotmag 12 12.000 -> 1
-dqctm684 comparetotmag 12 12.0000 -> 1
-dqctm685 comparetotmag 12 12.00000 -> 1
-dqctm686 comparetotmag 12 12.000000 -> 1
-dqctm687 comparetotmag 12 12.0000000 -> 1
-dqctm688 comparetotmag 12 12.00000000 -> 1
-dqctm689 comparetotmag 12 12.000000000 -> 1
-dqctm690 comparetotmag 12 12 -> 0
-dqctm691 comparetotmag 12.0 12 -> -1
-dqctm692 comparetotmag 12.00 12 -> -1
-dqctm693 comparetotmag 12.000 12 -> -1
-dqctm694 comparetotmag 12.0000 12 -> -1
-dqctm695 comparetotmag 12.00000 12 -> -1
-dqctm696 comparetotmag 12.000000 12 -> -1
-dqctm697 comparetotmag 12.0000000 12 -> -1
-dqctm698 comparetotmag 12.00000000 12 -> -1
-dqctm699 comparetotmag 12.000000000 12 -> -1
-
--- old long operand checks
-dqctm701 comparetotmag 12345678000 1 -> 1
-dqctm702 comparetotmag 1 12345678000 -> -1
-dqctm703 comparetotmag 1234567800 1 -> 1
-dqctm704 comparetotmag 1 1234567800 -> -1
-dqctm705 comparetotmag 1234567890 1 -> 1
-dqctm706 comparetotmag 1 1234567890 -> -1
-dqctm707 comparetotmag 1234567891 1 -> 1
-dqctm708 comparetotmag 1 1234567891 -> -1
-dqctm709 comparetotmag 12345678901 1 -> 1
-dqctm710 comparetotmag 1 12345678901 -> -1
-dqctm711 comparetotmag 1234567896 1 -> 1
-dqctm712 comparetotmag 1 1234567896 -> -1
-dqctm713 comparetotmag -1234567891 1 -> 1
-dqctm714 comparetotmag 1 -1234567891 -> -1
-dqctm715 comparetotmag -12345678901 1 -> 1
-dqctm716 comparetotmag 1 -12345678901 -> -1
-dqctm717 comparetotmag -1234567896 1 -> 1
-dqctm718 comparetotmag 1 -1234567896 -> -1
-
--- old residue cases
-dqctm740 comparetotmag 1 0.9999999 -> 1
-dqctm741 comparetotmag 1 0.999999 -> 1
-dqctm742 comparetotmag 1 0.99999 -> 1
-dqctm743 comparetotmag 1 1.0000 -> 1
-dqctm744 comparetotmag 1 1.00001 -> -1
-dqctm745 comparetotmag 1 1.000001 -> -1
-dqctm746 comparetotmag 1 1.0000001 -> -1
-dqctm750 comparetotmag 0.9999999 1 -> -1
-dqctm751 comparetotmag 0.999999 1 -> -1
-dqctm752 comparetotmag 0.99999 1 -> -1
-dqctm753 comparetotmag 1.0000 1 -> -1
-dqctm754 comparetotmag 1.00001 1 -> 1
-dqctm755 comparetotmag 1.000001 1 -> 1
-dqctm756 comparetotmag 1.0000001 1 -> 1
-
--- Specials
-dqctm780 comparetotmag Inf -Inf -> 0
-dqctm781 comparetotmag Inf -1000 -> 1
-dqctm782 comparetotmag Inf -1 -> 1
-dqctm783 comparetotmag Inf -0 -> 1
-dqctm784 comparetotmag Inf 0 -> 1
-dqctm785 comparetotmag Inf 1 -> 1
-dqctm786 comparetotmag Inf 1000 -> 1
-dqctm787 comparetotmag Inf Inf -> 0
-dqctm788 comparetotmag -1000 Inf -> -1
-dqctm789 comparetotmag -Inf Inf -> 0
-dqctm790 comparetotmag -1 Inf -> -1
-dqctm791 comparetotmag -0 Inf -> -1
-dqctm792 comparetotmag 0 Inf -> -1
-dqctm793 comparetotmag 1 Inf -> -1
-dqctm794 comparetotmag 1000 Inf -> -1
-dqctm795 comparetotmag Inf Inf -> 0
-
-dqctm800 comparetotmag -Inf -Inf -> 0
-dqctm801 comparetotmag -Inf -1000 -> 1
-dqctm802 comparetotmag -Inf -1 -> 1
-dqctm803 comparetotmag -Inf -0 -> 1
-dqctm804 comparetotmag -Inf 0 -> 1
-dqctm805 comparetotmag -Inf 1 -> 1
-dqctm806 comparetotmag -Inf 1000 -> 1
-dqctm807 comparetotmag -Inf Inf -> 0
-dqctm808 comparetotmag -Inf -Inf -> 0
-dqctm809 comparetotmag -1000 -Inf -> -1
-dqctm810 comparetotmag -1 -Inf -> -1
-dqctm811 comparetotmag -0 -Inf -> -1
-dqctm812 comparetotmag 0 -Inf -> -1
-dqctm813 comparetotmag 1 -Inf -> -1
-dqctm814 comparetotmag 1000 -Inf -> -1
-dqctm815 comparetotmag Inf -Inf -> 0
-
-dqctm821 comparetotmag NaN -Inf -> 1
-dqctm822 comparetotmag NaN -1000 -> 1
-dqctm823 comparetotmag NaN -1 -> 1
-dqctm824 comparetotmag NaN -0 -> 1
-dqctm825 comparetotmag NaN 0 -> 1
-dqctm826 comparetotmag NaN 1 -> 1
-dqctm827 comparetotmag NaN 1000 -> 1
-dqctm828 comparetotmag NaN Inf -> 1
-dqctm829 comparetotmag NaN NaN -> 0
-dqctm830 comparetotmag -Inf NaN -> -1
-dqctm831 comparetotmag -1000 NaN -> -1
-dqctm832 comparetotmag -1 NaN -> -1
-dqctm833 comparetotmag -0 NaN -> -1
-dqctm834 comparetotmag 0 NaN -> -1
-dqctm835 comparetotmag 1 NaN -> -1
-dqctm836 comparetotmag 1000 NaN -> -1
-dqctm837 comparetotmag Inf NaN -> -1
-dqctm838 comparetotmag -NaN -NaN -> 0
-dqctm839 comparetotmag +NaN -NaN -> 0
-dqctm840 comparetotmag -NaN +NaN -> 0
-
-dqctm841 comparetotmag sNaN -sNaN -> 0
-dqctm842 comparetotmag sNaN -NaN -> -1
-dqctm843 comparetotmag sNaN -Inf -> 1
-dqctm844 comparetotmag sNaN -1000 -> 1
-dqctm845 comparetotmag sNaN -1 -> 1
-dqctm846 comparetotmag sNaN -0 -> 1
-dqctm847 comparetotmag sNaN 0 -> 1
-dqctm848 comparetotmag sNaN 1 -> 1
-dqctm849 comparetotmag sNaN 1000 -> 1
-dqctm850 comparetotmag sNaN NaN -> -1
-dqctm851 comparetotmag sNaN sNaN -> 0
-
-dqctm852 comparetotmag -sNaN sNaN -> 0
-dqctm853 comparetotmag -NaN sNaN -> 1
-dqctm854 comparetotmag -Inf sNaN -> -1
-dqctm855 comparetotmag -1000 sNaN -> -1
-dqctm856 comparetotmag -1 sNaN -> -1
-dqctm857 comparetotmag -0 sNaN -> -1
-dqctm858 comparetotmag 0 sNaN -> -1
-dqctm859 comparetotmag 1 sNaN -> -1
-dqctm860 comparetotmag 1000 sNaN -> -1
-dqctm861 comparetotmag Inf sNaN -> -1
-dqctm862 comparetotmag NaN sNaN -> 1
-dqctm863 comparetotmag sNaN sNaN -> 0
-
-dqctm871 comparetotmag -sNaN -sNaN -> 0
-dqctm872 comparetotmag -sNaN -NaN -> -1
-dqctm873 comparetotmag -sNaN -Inf -> 1
-dqctm874 comparetotmag -sNaN -1000 -> 1
-dqctm875 comparetotmag -sNaN -1 -> 1
-dqctm876 comparetotmag -sNaN -0 -> 1
-dqctm877 comparetotmag -sNaN 0 -> 1
-dqctm878 comparetotmag -sNaN 1 -> 1
-dqctm879 comparetotmag -sNaN 1000 -> 1
-dqctm880 comparetotmag -sNaN NaN -> -1
-dqctm881 comparetotmag -sNaN sNaN -> 0
-
-dqctm882 comparetotmag -sNaN -sNaN -> 0
-dqctm883 comparetotmag -NaN -sNaN -> 1
-dqctm884 comparetotmag -Inf -sNaN -> -1
-dqctm885 comparetotmag -1000 -sNaN -> -1
-dqctm886 comparetotmag -1 -sNaN -> -1
-dqctm887 comparetotmag -0 -sNaN -> -1
-dqctm888 comparetotmag 0 -sNaN -> -1
-dqctm889 comparetotmag 1 -sNaN -> -1
-dqctm890 comparetotmag 1000 -sNaN -> -1
-dqctm891 comparetotmag Inf -sNaN -> -1
-dqctm892 comparetotmag NaN -sNaN -> 1
-dqctm893 comparetotmag sNaN -sNaN -> 0
-
--- NaNs with payload
-dqctm960 comparetotmag NaN9 -Inf -> 1
-dqctm961 comparetotmag NaN8 999 -> 1
-dqctm962 comparetotmag NaN77 Inf -> 1
-dqctm963 comparetotmag -NaN67 NaN5 -> 1
-dqctm964 comparetotmag -Inf -NaN4 -> -1
-dqctm965 comparetotmag -999 -NaN33 -> -1
-dqctm966 comparetotmag Inf NaN2 -> -1
-
-dqctm970 comparetotmag -NaN41 -NaN42 -> -1
-dqctm971 comparetotmag +NaN41 -NaN42 -> -1
-dqctm972 comparetotmag -NaN41 +NaN42 -> -1
-dqctm973 comparetotmag +NaN41 +NaN42 -> -1
-dqctm974 comparetotmag -NaN42 -NaN01 -> 1
-dqctm975 comparetotmag +NaN42 -NaN01 -> 1
-dqctm976 comparetotmag -NaN42 +NaN01 -> 1
-dqctm977 comparetotmag +NaN42 +NaN01 -> 1
-
-dqctm980 comparetotmag -sNaN771 -sNaN772 -> -1
-dqctm981 comparetotmag +sNaN771 -sNaN772 -> -1
-dqctm982 comparetotmag -sNaN771 +sNaN772 -> -1
-dqctm983 comparetotmag +sNaN771 +sNaN772 -> -1
-dqctm984 comparetotmag -sNaN772 -sNaN771 -> 1
-dqctm985 comparetotmag +sNaN772 -sNaN771 -> 1
-dqctm986 comparetotmag -sNaN772 +sNaN771 -> 1
-dqctm987 comparetotmag +sNaN772 +sNaN771 -> 1
-
-dqctm991 comparetotmag -sNaN99 -Inf -> 1
-dqctm992 comparetotmag sNaN98 -11 -> 1
-dqctm993 comparetotmag sNaN97 NaN -> -1
-dqctm994 comparetotmag sNaN16 sNaN94 -> -1
-dqctm995 comparetotmag NaN85 sNaN83 -> 1
-dqctm996 comparetotmag -Inf sNaN92 -> -1
-dqctm997 comparetotmag 088 sNaN81 -> -1
-dqctm998 comparetotmag Inf sNaN90 -> -1
-dqctm999 comparetotmag NaN -sNaN89 -> 1
-
--- spread zeros
-dqctm1110 comparetotmag 0E-6143 0 -> -1
-dqctm1111 comparetotmag 0E-6143 -0 -> -1
-dqctm1112 comparetotmag -0E-6143 0 -> -1
-dqctm1113 comparetotmag -0E-6143 -0 -> -1
-dqctm1114 comparetotmag 0E-6143 0E+6144 -> -1
-dqctm1115 comparetotmag 0E-6143 -0E+6144 -> -1
-dqctm1116 comparetotmag -0E-6143 0E+6144 -> -1
-dqctm1117 comparetotmag -0E-6143 -0E+6144 -> -1
-dqctm1118 comparetotmag 0 0E+6144 -> -1
-dqctm1119 comparetotmag 0 -0E+6144 -> -1
-dqctm1120 comparetotmag -0 0E+6144 -> -1
-dqctm1121 comparetotmag -0 -0E+6144 -> -1
-
-dqctm1130 comparetotmag 0E+6144 0 -> 1
-dqctm1131 comparetotmag 0E+6144 -0 -> 1
-dqctm1132 comparetotmag -0E+6144 0 -> 1
-dqctm1133 comparetotmag -0E+6144 -0 -> 1
-dqctm1134 comparetotmag 0E+6144 0E-6143 -> 1
-dqctm1135 comparetotmag 0E+6144 -0E-6143 -> 1
-dqctm1136 comparetotmag -0E+6144 0E-6143 -> 1
-dqctm1137 comparetotmag -0E+6144 -0E-6143 -> 1
-dqctm1138 comparetotmag 0 0E-6143 -> 1
-dqctm1139 comparetotmag 0 -0E-6143 -> 1
-dqctm1140 comparetotmag -0 0E-6143 -> 1
-dqctm1141 comparetotmag -0 -0E-6143 -> 1
-
--- Null tests
-dqctm9990 comparetotmag 10 # -> NaN Invalid_operation
-dqctm9991 comparetotmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqCompareTotalMag.decTest -- decQuad comparison; abs. total order --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqctm001 comparetotmag -2 -2 -> 0
+dqctm002 comparetotmag -2 -1 -> 1
+dqctm003 comparetotmag -2 0 -> 1
+dqctm004 comparetotmag -2 1 -> 1
+dqctm005 comparetotmag -2 2 -> 0
+dqctm006 comparetotmag -1 -2 -> -1
+dqctm007 comparetotmag -1 -1 -> 0
+dqctm008 comparetotmag -1 0 -> 1
+dqctm009 comparetotmag -1 1 -> 0
+dqctm010 comparetotmag -1 2 -> -1
+dqctm011 comparetotmag 0 -2 -> -1
+dqctm012 comparetotmag 0 -1 -> -1
+dqctm013 comparetotmag 0 0 -> 0
+dqctm014 comparetotmag 0 1 -> -1
+dqctm015 comparetotmag 0 2 -> -1
+dqctm016 comparetotmag 1 -2 -> -1
+dqctm017 comparetotmag 1 -1 -> 0
+dqctm018 comparetotmag 1 0 -> 1
+dqctm019 comparetotmag 1 1 -> 0
+dqctm020 comparetotmag 1 2 -> -1
+dqctm021 comparetotmag 2 -2 -> 0
+dqctm022 comparetotmag 2 -1 -> 1
+dqctm023 comparetotmag 2 0 -> 1
+dqctm025 comparetotmag 2 1 -> 1
+dqctm026 comparetotmag 2 2 -> 0
+
+dqctm031 comparetotmag -20 -20 -> 0
+dqctm032 comparetotmag -20 -10 -> 1
+dqctm033 comparetotmag -20 00 -> 1
+dqctm034 comparetotmag -20 10 -> 1
+dqctm035 comparetotmag -20 20 -> 0
+dqctm036 comparetotmag -10 -20 -> -1
+dqctm037 comparetotmag -10 -10 -> 0
+dqctm038 comparetotmag -10 00 -> 1
+dqctm039 comparetotmag -10 10 -> 0
+dqctm040 comparetotmag -10 20 -> -1
+dqctm041 comparetotmag 00 -20 -> -1
+dqctm042 comparetotmag 00 -10 -> -1
+dqctm043 comparetotmag 00 00 -> 0
+dqctm044 comparetotmag 00 10 -> -1
+dqctm045 comparetotmag 00 20 -> -1
+dqctm046 comparetotmag 10 -20 -> -1
+dqctm047 comparetotmag 10 -10 -> 0
+dqctm048 comparetotmag 10 00 -> 1
+dqctm049 comparetotmag 10 10 -> 0
+dqctm050 comparetotmag 10 20 -> -1
+dqctm051 comparetotmag 20 -20 -> 0
+dqctm052 comparetotmag 20 -10 -> 1
+dqctm053 comparetotmag 20 00 -> 1
+dqctm055 comparetotmag 20 10 -> 1
+dqctm056 comparetotmag 20 20 -> 0
+
+dqctm061 comparetotmag -2.0 -2.0 -> 0
+dqctm062 comparetotmag -2.0 -1.0 -> 1
+dqctm063 comparetotmag -2.0 0.0 -> 1
+dqctm064 comparetotmag -2.0 1.0 -> 1
+dqctm065 comparetotmag -2.0 2.0 -> 0
+dqctm066 comparetotmag -1.0 -2.0 -> -1
+dqctm067 comparetotmag -1.0 -1.0 -> 0
+dqctm068 comparetotmag -1.0 0.0 -> 1
+dqctm069 comparetotmag -1.0 1.0 -> 0
+dqctm070 comparetotmag -1.0 2.0 -> -1
+dqctm071 comparetotmag 0.0 -2.0 -> -1
+dqctm072 comparetotmag 0.0 -1.0 -> -1
+dqctm073 comparetotmag 0.0 0.0 -> 0
+dqctm074 comparetotmag 0.0 1.0 -> -1
+dqctm075 comparetotmag 0.0 2.0 -> -1
+dqctm076 comparetotmag 1.0 -2.0 -> -1
+dqctm077 comparetotmag 1.0 -1.0 -> 0
+dqctm078 comparetotmag 1.0 0.0 -> 1
+dqctm079 comparetotmag 1.0 1.0 -> 0
+dqctm080 comparetotmag 1.0 2.0 -> -1
+dqctm081 comparetotmag 2.0 -2.0 -> 0
+dqctm082 comparetotmag 2.0 -1.0 -> 1
+dqctm083 comparetotmag 2.0 0.0 -> 1
+dqctm085 comparetotmag 2.0 1.0 -> 1
+dqctm086 comparetotmag 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+dqctm090 comparetotmag 9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
+dqctm091 comparetotmag -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
+dqctm092 comparetotmag 9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
+dqctm093 comparetotmag -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+dqctm100 comparetotmag 7.0 7.0 -> 0
+dqctm101 comparetotmag 7.0 7 -> -1
+dqctm102 comparetotmag 7 7.0 -> 1
+dqctm103 comparetotmag 7E+0 7.0 -> 1
+dqctm104 comparetotmag 70E-1 7.0 -> 0
+dqctm105 comparetotmag 0.7E+1 7 -> 0
+dqctm106 comparetotmag 70E-1 7 -> -1
+dqctm107 comparetotmag 7.0 7E+0 -> -1
+dqctm108 comparetotmag 7.0 70E-1 -> 0
+dqctm109 comparetotmag 7 0.7E+1 -> 0
+dqctm110 comparetotmag 7 70E-1 -> 1
+
+dqctm120 comparetotmag 8.0 7.0 -> 1
+dqctm121 comparetotmag 8.0 7 -> 1
+dqctm122 comparetotmag 8 7.0 -> 1
+dqctm123 comparetotmag 8E+0 7.0 -> 1
+dqctm124 comparetotmag 80E-1 7.0 -> 1
+dqctm125 comparetotmag 0.8E+1 7 -> 1
+dqctm126 comparetotmag 80E-1 7 -> 1
+dqctm127 comparetotmag 8.0 7E+0 -> 1
+dqctm128 comparetotmag 8.0 70E-1 -> 1
+dqctm129 comparetotmag 8 0.7E+1 -> 1
+dqctm130 comparetotmag 8 70E-1 -> 1
+
+dqctm140 comparetotmag 8.0 9.0 -> -1
+dqctm141 comparetotmag 8.0 9 -> -1
+dqctm142 comparetotmag 8 9.0 -> -1
+dqctm143 comparetotmag 8E+0 9.0 -> -1
+dqctm144 comparetotmag 80E-1 9.0 -> -1
+dqctm145 comparetotmag 0.8E+1 9 -> -1
+dqctm146 comparetotmag 80E-1 9 -> -1
+dqctm147 comparetotmag 8.0 9E+0 -> -1
+dqctm148 comparetotmag 8.0 90E-1 -> -1
+dqctm149 comparetotmag 8 0.9E+1 -> -1
+dqctm150 comparetotmag 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+dqctm200 comparetotmag -7.0 7.0 -> 0
+dqctm201 comparetotmag -7.0 7 -> -1
+dqctm202 comparetotmag -7 7.0 -> 1
+dqctm203 comparetotmag -7E+0 7.0 -> 1
+dqctm204 comparetotmag -70E-1 7.0 -> 0
+dqctm205 comparetotmag -0.7E+1 7 -> 0
+dqctm206 comparetotmag -70E-1 7 -> -1
+dqctm207 comparetotmag -7.0 7E+0 -> -1
+dqctm208 comparetotmag -7.0 70E-1 -> 0
+dqctm209 comparetotmag -7 0.7E+1 -> 0
+dqctm210 comparetotmag -7 70E-1 -> 1
+
+dqctm220 comparetotmag -8.0 7.0 -> 1
+dqctm221 comparetotmag -8.0 7 -> 1
+dqctm222 comparetotmag -8 7.0 -> 1
+dqctm223 comparetotmag -8E+0 7.0 -> 1
+dqctm224 comparetotmag -80E-1 7.0 -> 1
+dqctm225 comparetotmag -0.8E+1 7 -> 1
+dqctm226 comparetotmag -80E-1 7 -> 1
+dqctm227 comparetotmag -8.0 7E+0 -> 1
+dqctm228 comparetotmag -8.0 70E-1 -> 1
+dqctm229 comparetotmag -8 0.7E+1 -> 1
+dqctm230 comparetotmag -8 70E-1 -> 1
+
+dqctm240 comparetotmag -8.0 9.0 -> -1
+dqctm241 comparetotmag -8.0 9 -> -1
+dqctm242 comparetotmag -8 9.0 -> -1
+dqctm243 comparetotmag -8E+0 9.0 -> -1
+dqctm244 comparetotmag -80E-1 9.0 -> -1
+dqctm245 comparetotmag -0.8E+1 9 -> -1
+dqctm246 comparetotmag -80E-1 9 -> -1
+dqctm247 comparetotmag -8.0 9E+0 -> -1
+dqctm248 comparetotmag -8.0 90E-1 -> -1
+dqctm249 comparetotmag -8 0.9E+1 -> -1
+dqctm250 comparetotmag -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+dqctm300 comparetotmag 7.0 -7.0 -> 0
+dqctm301 comparetotmag 7.0 -7 -> -1
+dqctm302 comparetotmag 7 -7.0 -> 1
+dqctm303 comparetotmag 7E+0 -7.0 -> 1
+dqctm304 comparetotmag 70E-1 -7.0 -> 0
+dqctm305 comparetotmag .7E+1 -7 -> 0
+dqctm306 comparetotmag 70E-1 -7 -> -1
+dqctm307 comparetotmag 7.0 -7E+0 -> -1
+dqctm308 comparetotmag 7.0 -70E-1 -> 0
+dqctm309 comparetotmag 7 -.7E+1 -> 0
+dqctm310 comparetotmag 7 -70E-1 -> 1
+
+dqctm320 comparetotmag 8.0 -7.0 -> 1
+dqctm321 comparetotmag 8.0 -7 -> 1
+dqctm322 comparetotmag 8 -7.0 -> 1
+dqctm323 comparetotmag 8E+0 -7.0 -> 1
+dqctm324 comparetotmag 80E-1 -7.0 -> 1
+dqctm325 comparetotmag .8E+1 -7 -> 1
+dqctm326 comparetotmag 80E-1 -7 -> 1
+dqctm327 comparetotmag 8.0 -7E+0 -> 1
+dqctm328 comparetotmag 8.0 -70E-1 -> 1
+dqctm329 comparetotmag 8 -.7E+1 -> 1
+dqctm330 comparetotmag 8 -70E-1 -> 1
+
+dqctm340 comparetotmag 8.0 -9.0 -> -1
+dqctm341 comparetotmag 8.0 -9 -> -1
+dqctm342 comparetotmag 8 -9.0 -> -1
+dqctm343 comparetotmag 8E+0 -9.0 -> -1
+dqctm344 comparetotmag 80E-1 -9.0 -> -1
+dqctm345 comparetotmag .8E+1 -9 -> -1
+dqctm346 comparetotmag 80E-1 -9 -> -1
+dqctm347 comparetotmag 8.0 -9E+0 -> -1
+dqctm348 comparetotmag 8.0 -90E-1 -> -1
+dqctm349 comparetotmag 8 -.9E+1 -> -1
+dqctm350 comparetotmag 8 -90E-1 -> -1
+
+-- and again, with sign changes -- ..
+dqctm400 comparetotmag -7.0 -7.0 -> 0
+dqctm401 comparetotmag -7.0 -7 -> -1
+dqctm402 comparetotmag -7 -7.0 -> 1
+dqctm403 comparetotmag -7E+0 -7.0 -> 1
+dqctm404 comparetotmag -70E-1 -7.0 -> 0
+dqctm405 comparetotmag -.7E+1 -7 -> 0
+dqctm406 comparetotmag -70E-1 -7 -> -1
+dqctm407 comparetotmag -7.0 -7E+0 -> -1
+dqctm408 comparetotmag -7.0 -70E-1 -> 0
+dqctm409 comparetotmag -7 -.7E+1 -> 0
+dqctm410 comparetotmag -7 -70E-1 -> 1
+
+dqctm420 comparetotmag -8.0 -7.0 -> 1
+dqctm421 comparetotmag -8.0 -7 -> 1
+dqctm422 comparetotmag -8 -7.0 -> 1
+dqctm423 comparetotmag -8E+0 -7.0 -> 1
+dqctm424 comparetotmag -80E-1 -7.0 -> 1
+dqctm425 comparetotmag -.8E+1 -7 -> 1
+dqctm426 comparetotmag -80E-1 -7 -> 1
+dqctm427 comparetotmag -8.0 -7E+0 -> 1
+dqctm428 comparetotmag -8.0 -70E-1 -> 1
+dqctm429 comparetotmag -8 -.7E+1 -> 1
+dqctm430 comparetotmag -8 -70E-1 -> 1
+
+dqctm440 comparetotmag -8.0 -9.0 -> -1
+dqctm441 comparetotmag -8.0 -9 -> -1
+dqctm442 comparetotmag -8 -9.0 -> -1
+dqctm443 comparetotmag -8E+0 -9.0 -> -1
+dqctm444 comparetotmag -80E-1 -9.0 -> -1
+dqctm445 comparetotmag -.8E+1 -9 -> -1
+dqctm446 comparetotmag -80E-1 -9 -> -1
+dqctm447 comparetotmag -8.0 -9E+0 -> -1
+dqctm448 comparetotmag -8.0 -90E-1 -> -1
+dqctm449 comparetotmag -8 -.9E+1 -> -1
+dqctm450 comparetotmag -8 -90E-1 -> -1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+dqctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
+dqctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
+dqctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
+dqctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
+dqctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
+dqctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
+dqctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
+dqctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
+dqctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
+dqctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
+dqctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
+dqctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
+dqctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
+dqctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
+dqctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
+dqctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
+dqctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
+dqctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
+dqctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
+dqctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
+dqctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
+dqctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+dqctm498 comparetotmag 1 1E-17 -> 1
+dqctm499 comparetotmag 1 1E-16 -> 1
+dqctm500 comparetotmag 1 1E-15 -> 1
+dqctm501 comparetotmag 1 1E-14 -> 1
+dqctm502 comparetotmag 1 1E-13 -> 1
+dqctm503 comparetotmag 1 1E-12 -> 1
+dqctm504 comparetotmag 1 1E-11 -> 1
+dqctm505 comparetotmag 1 1E-10 -> 1
+dqctm506 comparetotmag 1 1E-9 -> 1
+dqctm507 comparetotmag 1 1E-8 -> 1
+dqctm508 comparetotmag 1 1E-7 -> 1
+dqctm509 comparetotmag 1 1E-6 -> 1
+dqctm510 comparetotmag 1 1E-5 -> 1
+dqctm511 comparetotmag 1 1E-4 -> 1
+dqctm512 comparetotmag 1 1E-3 -> 1
+dqctm513 comparetotmag 1 1E-2 -> 1
+dqctm514 comparetotmag 1 1E-1 -> 1
+dqctm515 comparetotmag 1 1E-0 -> 0
+dqctm516 comparetotmag 1 1E+1 -> -1
+dqctm517 comparetotmag 1 1E+2 -> -1
+dqctm518 comparetotmag 1 1E+3 -> -1
+dqctm519 comparetotmag 1 1E+4 -> -1
+dqctm521 comparetotmag 1 1E+5 -> -1
+dqctm522 comparetotmag 1 1E+6 -> -1
+dqctm523 comparetotmag 1 1E+7 -> -1
+dqctm524 comparetotmag 1 1E+8 -> -1
+dqctm525 comparetotmag 1 1E+9 -> -1
+dqctm526 comparetotmag 1 1E+10 -> -1
+dqctm527 comparetotmag 1 1E+11 -> -1
+dqctm528 comparetotmag 1 1E+12 -> -1
+dqctm529 comparetotmag 1 1E+13 -> -1
+dqctm530 comparetotmag 1 1E+14 -> -1
+dqctm531 comparetotmag 1 1E+15 -> -1
+dqctm532 comparetotmag 1 1E+16 -> -1
+dqctm533 comparetotmag 1 1E+17 -> -1
+-- LR swap
+dqctm538 comparetotmag 1E-17 1 -> -1
+dqctm539 comparetotmag 1E-16 1 -> -1
+dqctm540 comparetotmag 1E-15 1 -> -1
+dqctm541 comparetotmag 1E-14 1 -> -1
+dqctm542 comparetotmag 1E-13 1 -> -1
+dqctm543 comparetotmag 1E-12 1 -> -1
+dqctm544 comparetotmag 1E-11 1 -> -1
+dqctm545 comparetotmag 1E-10 1 -> -1
+dqctm546 comparetotmag 1E-9 1 -> -1
+dqctm547 comparetotmag 1E-8 1 -> -1
+dqctm548 comparetotmag 1E-7 1 -> -1
+dqctm549 comparetotmag 1E-6 1 -> -1
+dqctm550 comparetotmag 1E-5 1 -> -1
+dqctm551 comparetotmag 1E-4 1 -> -1
+dqctm552 comparetotmag 1E-3 1 -> -1
+dqctm553 comparetotmag 1E-2 1 -> -1
+dqctm554 comparetotmag 1E-1 1 -> -1
+dqctm555 comparetotmag 1E-0 1 -> 0
+dqctm556 comparetotmag 1E+1 1 -> 1
+dqctm557 comparetotmag 1E+2 1 -> 1
+dqctm558 comparetotmag 1E+3 1 -> 1
+dqctm559 comparetotmag 1E+4 1 -> 1
+dqctm561 comparetotmag 1E+5 1 -> 1
+dqctm562 comparetotmag 1E+6 1 -> 1
+dqctm563 comparetotmag 1E+7 1 -> 1
+dqctm564 comparetotmag 1E+8 1 -> 1
+dqctm565 comparetotmag 1E+9 1 -> 1
+dqctm566 comparetotmag 1E+10 1 -> 1
+dqctm567 comparetotmag 1E+11 1 -> 1
+dqctm568 comparetotmag 1E+12 1 -> 1
+dqctm569 comparetotmag 1E+13 1 -> 1
+dqctm570 comparetotmag 1E+14 1 -> 1
+dqctm571 comparetotmag 1E+15 1 -> 1
+dqctm572 comparetotmag 1E+16 1 -> 1
+dqctm573 comparetotmag 1E+17 1 -> 1
+-- similar with a useful coefficient, one side only
+dqctm578 comparetotmag 0.000000987654321 1E-17 -> 1
+dqctm579 comparetotmag 0.000000987654321 1E-16 -> 1
+dqctm580 comparetotmag 0.000000987654321 1E-15 -> 1
+dqctm581 comparetotmag 0.000000987654321 1E-14 -> 1
+dqctm582 comparetotmag 0.000000987654321 1E-13 -> 1
+dqctm583 comparetotmag 0.000000987654321 1E-12 -> 1
+dqctm584 comparetotmag 0.000000987654321 1E-11 -> 1
+dqctm585 comparetotmag 0.000000987654321 1E-10 -> 1
+dqctm586 comparetotmag 0.000000987654321 1E-9 -> 1
+dqctm587 comparetotmag 0.000000987654321 1E-8 -> 1
+dqctm588 comparetotmag 0.000000987654321 1E-7 -> 1
+dqctm589 comparetotmag 0.000000987654321 1E-6 -> -1
+dqctm590 comparetotmag 0.000000987654321 1E-5 -> -1
+dqctm591 comparetotmag 0.000000987654321 1E-4 -> -1
+dqctm592 comparetotmag 0.000000987654321 1E-3 -> -1
+dqctm593 comparetotmag 0.000000987654321 1E-2 -> -1
+dqctm594 comparetotmag 0.000000987654321 1E-1 -> -1
+dqctm595 comparetotmag 0.000000987654321 1E-0 -> -1
+dqctm596 comparetotmag 0.000000987654321 1E+1 -> -1
+dqctm597 comparetotmag 0.000000987654321 1E+2 -> -1
+dqctm598 comparetotmag 0.000000987654321 1E+3 -> -1
+dqctm599 comparetotmag 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+dqctm600 comparetotmag 12 12.2345 -> -1
+dqctm601 comparetotmag 12.0 12.2345 -> -1
+dqctm602 comparetotmag 12.00 12.2345 -> -1
+dqctm603 comparetotmag 12.000 12.2345 -> -1
+dqctm604 comparetotmag 12.0000 12.2345 -> -1
+dqctm605 comparetotmag 12.00000 12.2345 -> -1
+dqctm606 comparetotmag 12.000000 12.2345 -> -1
+dqctm607 comparetotmag 12.0000000 12.2345 -> -1
+dqctm608 comparetotmag 12.00000000 12.2345 -> -1
+dqctm609 comparetotmag 12.000000000 12.2345 -> -1
+dqctm610 comparetotmag 12.1234 12 -> 1
+dqctm611 comparetotmag 12.1234 12.0 -> 1
+dqctm612 comparetotmag 12.1234 12.00 -> 1
+dqctm613 comparetotmag 12.1234 12.000 -> 1
+dqctm614 comparetotmag 12.1234 12.0000 -> 1
+dqctm615 comparetotmag 12.1234 12.00000 -> 1
+dqctm616 comparetotmag 12.1234 12.000000 -> 1
+dqctm617 comparetotmag 12.1234 12.0000000 -> 1
+dqctm618 comparetotmag 12.1234 12.00000000 -> 1
+dqctm619 comparetotmag 12.1234 12.000000000 -> 1
+dqctm620 comparetotmag -12 -12.2345 -> -1
+dqctm621 comparetotmag -12.0 -12.2345 -> -1
+dqctm622 comparetotmag -12.00 -12.2345 -> -1
+dqctm623 comparetotmag -12.000 -12.2345 -> -1
+dqctm624 comparetotmag -12.0000 -12.2345 -> -1
+dqctm625 comparetotmag -12.00000 -12.2345 -> -1
+dqctm626 comparetotmag -12.000000 -12.2345 -> -1
+dqctm627 comparetotmag -12.0000000 -12.2345 -> -1
+dqctm628 comparetotmag -12.00000000 -12.2345 -> -1
+dqctm629 comparetotmag -12.000000000 -12.2345 -> -1
+dqctm630 comparetotmag -12.1234 -12 -> 1
+dqctm631 comparetotmag -12.1234 -12.0 -> 1
+dqctm632 comparetotmag -12.1234 -12.00 -> 1
+dqctm633 comparetotmag -12.1234 -12.000 -> 1
+dqctm634 comparetotmag -12.1234 -12.0000 -> 1
+dqctm635 comparetotmag -12.1234 -12.00000 -> 1
+dqctm636 comparetotmag -12.1234 -12.000000 -> 1
+dqctm637 comparetotmag -12.1234 -12.0000000 -> 1
+dqctm638 comparetotmag -12.1234 -12.00000000 -> 1
+dqctm639 comparetotmag -12.1234 -12.000000000 -> 1
+
+-- extended zeros
+dqctm640 comparetotmag 0 0 -> 0
+dqctm641 comparetotmag 0 -0 -> 0
+dqctm642 comparetotmag 0 -0.0 -> 1
+dqctm643 comparetotmag 0 0.0 -> 1
+dqctm644 comparetotmag -0 0 -> 0
+dqctm645 comparetotmag -0 -0 -> 0
+dqctm646 comparetotmag -0 -0.0 -> 1
+dqctm647 comparetotmag -0 0.0 -> 1
+dqctm648 comparetotmag 0.0 0 -> -1
+dqctm649 comparetotmag 0.0 -0 -> -1
+dqctm650 comparetotmag 0.0 -0.0 -> 0
+dqctm651 comparetotmag 0.0 0.0 -> 0
+dqctm652 comparetotmag -0.0 0 -> -1
+dqctm653 comparetotmag -0.0 -0 -> -1
+dqctm654 comparetotmag -0.0 -0.0 -> 0
+dqctm655 comparetotmag -0.0 0.0 -> 0
+
+dqctm656 comparetotmag -0E1 0.0 -> 1
+dqctm657 comparetotmag -0E2 0.0 -> 1
+dqctm658 comparetotmag 0E1 0.0 -> 1
+dqctm659 comparetotmag 0E2 0.0 -> 1
+dqctm660 comparetotmag -0E1 0 -> 1
+dqctm661 comparetotmag -0E2 0 -> 1
+dqctm662 comparetotmag 0E1 0 -> 1
+dqctm663 comparetotmag 0E2 0 -> 1
+dqctm664 comparetotmag -0E1 -0E1 -> 0
+dqctm665 comparetotmag -0E2 -0E1 -> 1
+dqctm666 comparetotmag 0E1 -0E1 -> 0
+dqctm667 comparetotmag 0E2 -0E1 -> 1
+dqctm668 comparetotmag -0E1 -0E2 -> -1
+dqctm669 comparetotmag -0E2 -0E2 -> 0
+dqctm670 comparetotmag 0E1 -0E2 -> -1
+dqctm671 comparetotmag 0E2 -0E2 -> 0
+dqctm672 comparetotmag -0E1 0E1 -> 0
+dqctm673 comparetotmag -0E2 0E1 -> 1
+dqctm674 comparetotmag 0E1 0E1 -> 0
+dqctm675 comparetotmag 0E2 0E1 -> 1
+dqctm676 comparetotmag -0E1 0E2 -> -1
+dqctm677 comparetotmag -0E2 0E2 -> 0
+dqctm678 comparetotmag 0E1 0E2 -> -1
+dqctm679 comparetotmag 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+dqctm680 comparetotmag 12 12 -> 0
+dqctm681 comparetotmag 12 12.0 -> 1
+dqctm682 comparetotmag 12 12.00 -> 1
+dqctm683 comparetotmag 12 12.000 -> 1
+dqctm684 comparetotmag 12 12.0000 -> 1
+dqctm685 comparetotmag 12 12.00000 -> 1
+dqctm686 comparetotmag 12 12.000000 -> 1
+dqctm687 comparetotmag 12 12.0000000 -> 1
+dqctm688 comparetotmag 12 12.00000000 -> 1
+dqctm689 comparetotmag 12 12.000000000 -> 1
+dqctm690 comparetotmag 12 12 -> 0
+dqctm691 comparetotmag 12.0 12 -> -1
+dqctm692 comparetotmag 12.00 12 -> -1
+dqctm693 comparetotmag 12.000 12 -> -1
+dqctm694 comparetotmag 12.0000 12 -> -1
+dqctm695 comparetotmag 12.00000 12 -> -1
+dqctm696 comparetotmag 12.000000 12 -> -1
+dqctm697 comparetotmag 12.0000000 12 -> -1
+dqctm698 comparetotmag 12.00000000 12 -> -1
+dqctm699 comparetotmag 12.000000000 12 -> -1
+
+-- old long operand checks
+dqctm701 comparetotmag 12345678000 1 -> 1
+dqctm702 comparetotmag 1 12345678000 -> -1
+dqctm703 comparetotmag 1234567800 1 -> 1
+dqctm704 comparetotmag 1 1234567800 -> -1
+dqctm705 comparetotmag 1234567890 1 -> 1
+dqctm706 comparetotmag 1 1234567890 -> -1
+dqctm707 comparetotmag 1234567891 1 -> 1
+dqctm708 comparetotmag 1 1234567891 -> -1
+dqctm709 comparetotmag 12345678901 1 -> 1
+dqctm710 comparetotmag 1 12345678901 -> -1
+dqctm711 comparetotmag 1234567896 1 -> 1
+dqctm712 comparetotmag 1 1234567896 -> -1
+dqctm713 comparetotmag -1234567891 1 -> 1
+dqctm714 comparetotmag 1 -1234567891 -> -1
+dqctm715 comparetotmag -12345678901 1 -> 1
+dqctm716 comparetotmag 1 -12345678901 -> -1
+dqctm717 comparetotmag -1234567896 1 -> 1
+dqctm718 comparetotmag 1 -1234567896 -> -1
+
+-- old residue cases
+dqctm740 comparetotmag 1 0.9999999 -> 1
+dqctm741 comparetotmag 1 0.999999 -> 1
+dqctm742 comparetotmag 1 0.99999 -> 1
+dqctm743 comparetotmag 1 1.0000 -> 1
+dqctm744 comparetotmag 1 1.00001 -> -1
+dqctm745 comparetotmag 1 1.000001 -> -1
+dqctm746 comparetotmag 1 1.0000001 -> -1
+dqctm750 comparetotmag 0.9999999 1 -> -1
+dqctm751 comparetotmag 0.999999 1 -> -1
+dqctm752 comparetotmag 0.99999 1 -> -1
+dqctm753 comparetotmag 1.0000 1 -> -1
+dqctm754 comparetotmag 1.00001 1 -> 1
+dqctm755 comparetotmag 1.000001 1 -> 1
+dqctm756 comparetotmag 1.0000001 1 -> 1
+
+-- Specials
+dqctm780 comparetotmag Inf -Inf -> 0
+dqctm781 comparetotmag Inf -1000 -> 1
+dqctm782 comparetotmag Inf -1 -> 1
+dqctm783 comparetotmag Inf -0 -> 1
+dqctm784 comparetotmag Inf 0 -> 1
+dqctm785 comparetotmag Inf 1 -> 1
+dqctm786 comparetotmag Inf 1000 -> 1
+dqctm787 comparetotmag Inf Inf -> 0
+dqctm788 comparetotmag -1000 Inf -> -1
+dqctm789 comparetotmag -Inf Inf -> 0
+dqctm790 comparetotmag -1 Inf -> -1
+dqctm791 comparetotmag -0 Inf -> -1
+dqctm792 comparetotmag 0 Inf -> -1
+dqctm793 comparetotmag 1 Inf -> -1
+dqctm794 comparetotmag 1000 Inf -> -1
+dqctm795 comparetotmag Inf Inf -> 0
+
+dqctm800 comparetotmag -Inf -Inf -> 0
+dqctm801 comparetotmag -Inf -1000 -> 1
+dqctm802 comparetotmag -Inf -1 -> 1
+dqctm803 comparetotmag -Inf -0 -> 1
+dqctm804 comparetotmag -Inf 0 -> 1
+dqctm805 comparetotmag -Inf 1 -> 1
+dqctm806 comparetotmag -Inf 1000 -> 1
+dqctm807 comparetotmag -Inf Inf -> 0
+dqctm808 comparetotmag -Inf -Inf -> 0
+dqctm809 comparetotmag -1000 -Inf -> -1
+dqctm810 comparetotmag -1 -Inf -> -1
+dqctm811 comparetotmag -0 -Inf -> -1
+dqctm812 comparetotmag 0 -Inf -> -1
+dqctm813 comparetotmag 1 -Inf -> -1
+dqctm814 comparetotmag 1000 -Inf -> -1
+dqctm815 comparetotmag Inf -Inf -> 0
+
+dqctm821 comparetotmag NaN -Inf -> 1
+dqctm822 comparetotmag NaN -1000 -> 1
+dqctm823 comparetotmag NaN -1 -> 1
+dqctm824 comparetotmag NaN -0 -> 1
+dqctm825 comparetotmag NaN 0 -> 1
+dqctm826 comparetotmag NaN 1 -> 1
+dqctm827 comparetotmag NaN 1000 -> 1
+dqctm828 comparetotmag NaN Inf -> 1
+dqctm829 comparetotmag NaN NaN -> 0
+dqctm830 comparetotmag -Inf NaN -> -1
+dqctm831 comparetotmag -1000 NaN -> -1
+dqctm832 comparetotmag -1 NaN -> -1
+dqctm833 comparetotmag -0 NaN -> -1
+dqctm834 comparetotmag 0 NaN -> -1
+dqctm835 comparetotmag 1 NaN -> -1
+dqctm836 comparetotmag 1000 NaN -> -1
+dqctm837 comparetotmag Inf NaN -> -1
+dqctm838 comparetotmag -NaN -NaN -> 0
+dqctm839 comparetotmag +NaN -NaN -> 0
+dqctm840 comparetotmag -NaN +NaN -> 0
+
+dqctm841 comparetotmag sNaN -sNaN -> 0
+dqctm842 comparetotmag sNaN -NaN -> -1
+dqctm843 comparetotmag sNaN -Inf -> 1
+dqctm844 comparetotmag sNaN -1000 -> 1
+dqctm845 comparetotmag sNaN -1 -> 1
+dqctm846 comparetotmag sNaN -0 -> 1
+dqctm847 comparetotmag sNaN 0 -> 1
+dqctm848 comparetotmag sNaN 1 -> 1
+dqctm849 comparetotmag sNaN 1000 -> 1
+dqctm850 comparetotmag sNaN NaN -> -1
+dqctm851 comparetotmag sNaN sNaN -> 0
+
+dqctm852 comparetotmag -sNaN sNaN -> 0
+dqctm853 comparetotmag -NaN sNaN -> 1
+dqctm854 comparetotmag -Inf sNaN -> -1
+dqctm855 comparetotmag -1000 sNaN -> -1
+dqctm856 comparetotmag -1 sNaN -> -1
+dqctm857 comparetotmag -0 sNaN -> -1
+dqctm858 comparetotmag 0 sNaN -> -1
+dqctm859 comparetotmag 1 sNaN -> -1
+dqctm860 comparetotmag 1000 sNaN -> -1
+dqctm861 comparetotmag Inf sNaN -> -1
+dqctm862 comparetotmag NaN sNaN -> 1
+dqctm863 comparetotmag sNaN sNaN -> 0
+
+dqctm871 comparetotmag -sNaN -sNaN -> 0
+dqctm872 comparetotmag -sNaN -NaN -> -1
+dqctm873 comparetotmag -sNaN -Inf -> 1
+dqctm874 comparetotmag -sNaN -1000 -> 1
+dqctm875 comparetotmag -sNaN -1 -> 1
+dqctm876 comparetotmag -sNaN -0 -> 1
+dqctm877 comparetotmag -sNaN 0 -> 1
+dqctm878 comparetotmag -sNaN 1 -> 1
+dqctm879 comparetotmag -sNaN 1000 -> 1
+dqctm880 comparetotmag -sNaN NaN -> -1
+dqctm881 comparetotmag -sNaN sNaN -> 0
+
+dqctm882 comparetotmag -sNaN -sNaN -> 0
+dqctm883 comparetotmag -NaN -sNaN -> 1
+dqctm884 comparetotmag -Inf -sNaN -> -1
+dqctm885 comparetotmag -1000 -sNaN -> -1
+dqctm886 comparetotmag -1 -sNaN -> -1
+dqctm887 comparetotmag -0 -sNaN -> -1
+dqctm888 comparetotmag 0 -sNaN -> -1
+dqctm889 comparetotmag 1 -sNaN -> -1
+dqctm890 comparetotmag 1000 -sNaN -> -1
+dqctm891 comparetotmag Inf -sNaN -> -1
+dqctm892 comparetotmag NaN -sNaN -> 1
+dqctm893 comparetotmag sNaN -sNaN -> 0
+
+-- NaNs with payload
+dqctm960 comparetotmag NaN9 -Inf -> 1
+dqctm961 comparetotmag NaN8 999 -> 1
+dqctm962 comparetotmag NaN77 Inf -> 1
+dqctm963 comparetotmag -NaN67 NaN5 -> 1
+dqctm964 comparetotmag -Inf -NaN4 -> -1
+dqctm965 comparetotmag -999 -NaN33 -> -1
+dqctm966 comparetotmag Inf NaN2 -> -1
+
+dqctm970 comparetotmag -NaN41 -NaN42 -> -1
+dqctm971 comparetotmag +NaN41 -NaN42 -> -1
+dqctm972 comparetotmag -NaN41 +NaN42 -> -1
+dqctm973 comparetotmag +NaN41 +NaN42 -> -1
+dqctm974 comparetotmag -NaN42 -NaN01 -> 1
+dqctm975 comparetotmag +NaN42 -NaN01 -> 1
+dqctm976 comparetotmag -NaN42 +NaN01 -> 1
+dqctm977 comparetotmag +NaN42 +NaN01 -> 1
+
+dqctm980 comparetotmag -sNaN771 -sNaN772 -> -1
+dqctm981 comparetotmag +sNaN771 -sNaN772 -> -1
+dqctm982 comparetotmag -sNaN771 +sNaN772 -> -1
+dqctm983 comparetotmag +sNaN771 +sNaN772 -> -1
+dqctm984 comparetotmag -sNaN772 -sNaN771 -> 1
+dqctm985 comparetotmag +sNaN772 -sNaN771 -> 1
+dqctm986 comparetotmag -sNaN772 +sNaN771 -> 1
+dqctm987 comparetotmag +sNaN772 +sNaN771 -> 1
+
+dqctm991 comparetotmag -sNaN99 -Inf -> 1
+dqctm992 comparetotmag sNaN98 -11 -> 1
+dqctm993 comparetotmag sNaN97 NaN -> -1
+dqctm994 comparetotmag sNaN16 sNaN94 -> -1
+dqctm995 comparetotmag NaN85 sNaN83 -> 1
+dqctm996 comparetotmag -Inf sNaN92 -> -1
+dqctm997 comparetotmag 088 sNaN81 -> -1
+dqctm998 comparetotmag Inf sNaN90 -> -1
+dqctm999 comparetotmag NaN -sNaN89 -> 1
+
+-- spread zeros
+dqctm1110 comparetotmag 0E-6143 0 -> -1
+dqctm1111 comparetotmag 0E-6143 -0 -> -1
+dqctm1112 comparetotmag -0E-6143 0 -> -1
+dqctm1113 comparetotmag -0E-6143 -0 -> -1
+dqctm1114 comparetotmag 0E-6143 0E+6144 -> -1
+dqctm1115 comparetotmag 0E-6143 -0E+6144 -> -1
+dqctm1116 comparetotmag -0E-6143 0E+6144 -> -1
+dqctm1117 comparetotmag -0E-6143 -0E+6144 -> -1
+dqctm1118 comparetotmag 0 0E+6144 -> -1
+dqctm1119 comparetotmag 0 -0E+6144 -> -1
+dqctm1120 comparetotmag -0 0E+6144 -> -1
+dqctm1121 comparetotmag -0 -0E+6144 -> -1
+
+dqctm1130 comparetotmag 0E+6144 0 -> 1
+dqctm1131 comparetotmag 0E+6144 -0 -> 1
+dqctm1132 comparetotmag -0E+6144 0 -> 1
+dqctm1133 comparetotmag -0E+6144 -0 -> 1
+dqctm1134 comparetotmag 0E+6144 0E-6143 -> 1
+dqctm1135 comparetotmag 0E+6144 -0E-6143 -> 1
+dqctm1136 comparetotmag -0E+6144 0E-6143 -> 1
+dqctm1137 comparetotmag -0E+6144 -0E-6143 -> 1
+dqctm1138 comparetotmag 0 0E-6143 -> 1
+dqctm1139 comparetotmag 0 -0E-6143 -> 1
+dqctm1140 comparetotmag -0 0E-6143 -> 1
+dqctm1141 comparetotmag -0 -0E-6143 -> 1
+
+-- Null tests
+dqctm9990 comparetotmag 10 # -> NaN Invalid_operation
+dqctm9991 comparetotmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqCopy.decTest b/Lib/test/decimaltestdata/dqCopy.decTest
index 0c6243158f..7254d68bb7 100644
--- a/Lib/test/decimaltestdata/dqCopy.decTest
+++ b/Lib/test/decimaltestdata/dqCopy.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqCopy.decTest -- quiet decQuad copy --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqcpy001 copy +7.50 -> 7.50
-
--- Infinities
-dqcpy011 copy Infinity -> Infinity
-dqcpy012 copy -Infinity -> -Infinity
-
--- NaNs, 0 payload
-dqcpy021 copy NaN -> NaN
-dqcpy022 copy -NaN -> -NaN
-dqcpy023 copy sNaN -> sNaN
-dqcpy024 copy -sNaN -> -sNaN
-
--- NaNs, non-0 payload
-dqcpy031 copy NaN10 -> NaN10
-dqcpy032 copy -NaN10 -> -NaN10
-dqcpy033 copy sNaN10 -> sNaN10
-dqcpy034 copy -sNaN10 -> -sNaN10
-dqcpy035 copy NaN7 -> NaN7
-dqcpy036 copy -NaN7 -> -NaN7
-dqcpy037 copy sNaN101 -> sNaN101
-dqcpy038 copy -sNaN101 -> -sNaN101
-
--- finites
-dqcpy101 copy 7 -> 7
-dqcpy102 copy -7 -> -7
-dqcpy103 copy 75 -> 75
-dqcpy104 copy -75 -> -75
-dqcpy105 copy 7.50 -> 7.50
-dqcpy106 copy -7.50 -> -7.50
-dqcpy107 copy 7.500 -> 7.500
-dqcpy108 copy -7.500 -> -7.500
-
--- zeros
-dqcpy111 copy 0 -> 0
-dqcpy112 copy -0 -> -0
-dqcpy113 copy 0E+4 -> 0E+4
-dqcpy114 copy -0E+4 -> -0E+4
-dqcpy115 copy 0.0000 -> 0.0000
-dqcpy116 copy -0.0000 -> -0.0000
-dqcpy117 copy 0E-141 -> 0E-141
-dqcpy118 copy -0E-141 -> -0E-141
-
--- full coefficients, alternating bits
-dqcpy121 copy 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqcpy122 copy -2682682682682682682682682682682682 -> -2682682682682682682682682682682682
-dqcpy123 copy 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-dqcpy124 copy -1341341341341341341341341341341341 -> -1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcpy131 copy 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqcpy132 copy 1E-6143 -> 1E-6143
-dqcpy133 copy 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqcpy134 copy 1E-6176 -> 1E-6176
-
-dqcpy135 copy -1E-6176 -> -1E-6176
-dqcpy136 copy -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqcpy137 copy -1E-6143 -> -1E-6143
-dqcpy138 copy -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqCopy.decTest -- quiet decQuad copy --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqcpy001 copy +7.50 -> 7.50
+
+-- Infinities
+dqcpy011 copy Infinity -> Infinity
+dqcpy012 copy -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+dqcpy021 copy NaN -> NaN
+dqcpy022 copy -NaN -> -NaN
+dqcpy023 copy sNaN -> sNaN
+dqcpy024 copy -sNaN -> -sNaN
+
+-- NaNs, non-0 payload
+dqcpy031 copy NaN10 -> NaN10
+dqcpy032 copy -NaN10 -> -NaN10
+dqcpy033 copy sNaN10 -> sNaN10
+dqcpy034 copy -sNaN10 -> -sNaN10
+dqcpy035 copy NaN7 -> NaN7
+dqcpy036 copy -NaN7 -> -NaN7
+dqcpy037 copy sNaN101 -> sNaN101
+dqcpy038 copy -sNaN101 -> -sNaN101
+
+-- finites
+dqcpy101 copy 7 -> 7
+dqcpy102 copy -7 -> -7
+dqcpy103 copy 75 -> 75
+dqcpy104 copy -75 -> -75
+dqcpy105 copy 7.50 -> 7.50
+dqcpy106 copy -7.50 -> -7.50
+dqcpy107 copy 7.500 -> 7.500
+dqcpy108 copy -7.500 -> -7.500
+
+-- zeros
+dqcpy111 copy 0 -> 0
+dqcpy112 copy -0 -> -0
+dqcpy113 copy 0E+4 -> 0E+4
+dqcpy114 copy -0E+4 -> -0E+4
+dqcpy115 copy 0.0000 -> 0.0000
+dqcpy116 copy -0.0000 -> -0.0000
+dqcpy117 copy 0E-141 -> 0E-141
+dqcpy118 copy -0E-141 -> -0E-141
+
+-- full coefficients, alternating bits
+dqcpy121 copy 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqcpy122 copy -2682682682682682682682682682682682 -> -2682682682682682682682682682682682
+dqcpy123 copy 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+dqcpy124 copy -1341341341341341341341341341341341 -> -1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcpy131 copy 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqcpy132 copy 1E-6143 -> 1E-6143
+dqcpy133 copy 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqcpy134 copy 1E-6176 -> 1E-6176
+
+dqcpy135 copy -1E-6176 -> -1E-6176
+dqcpy136 copy -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqcpy137 copy -1E-6143 -> -1E-6143
+dqcpy138 copy -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqCopyAbs.decTest b/Lib/test/decimaltestdata/dqCopyAbs.decTest
index 16bcb4eaed..bdec0206de 100644
--- a/Lib/test/decimaltestdata/dqCopyAbs.decTest
+++ b/Lib/test/decimaltestdata/dqCopyAbs.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqCopyAbs.decTest -- quiet decQuad copy and set sign to zero --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqcpa001 copyabs +7.50 -> 7.50
-
--- Infinities
-dqcpa011 copyabs Infinity -> Infinity
-dqcpa012 copyabs -Infinity -> Infinity
-
--- NaNs, 0 payload
-dqcpa021 copyabs NaN -> NaN
-dqcpa022 copyabs -NaN -> NaN
-dqcpa023 copyabs sNaN -> sNaN
-dqcpa024 copyabs -sNaN -> sNaN
-
--- NaNs, non-0 payload
-dqcpa031 copyabs NaN10 -> NaN10
-dqcpa032 copyabs -NaN15 -> NaN15
-dqcpa033 copyabs sNaN15 -> sNaN15
-dqcpa034 copyabs -sNaN10 -> sNaN10
-dqcpa035 copyabs NaN7 -> NaN7
-dqcpa036 copyabs -NaN7 -> NaN7
-dqcpa037 copyabs sNaN101 -> sNaN101
-dqcpa038 copyabs -sNaN101 -> sNaN101
-
--- finites
-dqcpa101 copyabs 7 -> 7
-dqcpa102 copyabs -7 -> 7
-dqcpa103 copyabs 75 -> 75
-dqcpa104 copyabs -75 -> 75
-dqcpa105 copyabs 7.10 -> 7.10
-dqcpa106 copyabs -7.10 -> 7.10
-dqcpa107 copyabs 7.500 -> 7.500
-dqcpa108 copyabs -7.500 -> 7.500
-
--- zeros
-dqcpa111 copyabs 0 -> 0
-dqcpa112 copyabs -0 -> 0
-dqcpa113 copyabs 0E+6 -> 0E+6
-dqcpa114 copyabs -0E+6 -> 0E+6
-dqcpa115 copyabs 0.0000 -> 0.0000
-dqcpa116 copyabs -0.0000 -> 0.0000
-dqcpa117 copyabs 0E-141 -> 0E-141
-dqcpa118 copyabs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqcpa121 copyabs 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqcpa122 copyabs -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqcpa123 copyabs 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-dqcpa124 copyabs -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcpa131 copyabs 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqcpa132 copyabs 1E-6143 -> 1E-6143
-dqcpa133 copyabs 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqcpa134 copyabs 1E-6176 -> 1E-6176
-
-dqcpa135 copyabs -1E-6176 -> 1E-6176
-dqcpa136 copyabs -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqcpa137 copyabs -1E-6143 -> 1E-6143
-dqcpa138 copyabs -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqCopyAbs.decTest -- quiet decQuad copy and set sign to zero --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqcpa001 copyabs +7.50 -> 7.50
+
+-- Infinities
+dqcpa011 copyabs Infinity -> Infinity
+dqcpa012 copyabs -Infinity -> Infinity
+
+-- NaNs, 0 payload
+dqcpa021 copyabs NaN -> NaN
+dqcpa022 copyabs -NaN -> NaN
+dqcpa023 copyabs sNaN -> sNaN
+dqcpa024 copyabs -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+dqcpa031 copyabs NaN10 -> NaN10
+dqcpa032 copyabs -NaN15 -> NaN15
+dqcpa033 copyabs sNaN15 -> sNaN15
+dqcpa034 copyabs -sNaN10 -> sNaN10
+dqcpa035 copyabs NaN7 -> NaN7
+dqcpa036 copyabs -NaN7 -> NaN7
+dqcpa037 copyabs sNaN101 -> sNaN101
+dqcpa038 copyabs -sNaN101 -> sNaN101
+
+-- finites
+dqcpa101 copyabs 7 -> 7
+dqcpa102 copyabs -7 -> 7
+dqcpa103 copyabs 75 -> 75
+dqcpa104 copyabs -75 -> 75
+dqcpa105 copyabs 7.10 -> 7.10
+dqcpa106 copyabs -7.10 -> 7.10
+dqcpa107 copyabs 7.500 -> 7.500
+dqcpa108 copyabs -7.500 -> 7.500
+
+-- zeros
+dqcpa111 copyabs 0 -> 0
+dqcpa112 copyabs -0 -> 0
+dqcpa113 copyabs 0E+6 -> 0E+6
+dqcpa114 copyabs -0E+6 -> 0E+6
+dqcpa115 copyabs 0.0000 -> 0.0000
+dqcpa116 copyabs -0.0000 -> 0.0000
+dqcpa117 copyabs 0E-141 -> 0E-141
+dqcpa118 copyabs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqcpa121 copyabs 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqcpa122 copyabs -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqcpa123 copyabs 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+dqcpa124 copyabs -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcpa131 copyabs 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqcpa132 copyabs 1E-6143 -> 1E-6143
+dqcpa133 copyabs 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqcpa134 copyabs 1E-6176 -> 1E-6176
+
+dqcpa135 copyabs -1E-6176 -> 1E-6176
+dqcpa136 copyabs -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqcpa137 copyabs -1E-6143 -> 1E-6143
+dqcpa138 copyabs -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqCopyNegate.decTest b/Lib/test/decimaltestdata/dqCopyNegate.decTest
index 6253f5a355..ea00855772 100644
--- a/Lib/test/decimaltestdata/dqCopyNegate.decTest
+++ b/Lib/test/decimaltestdata/dqCopyNegate.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqCopyNegate.decTest -- quiet decQuad copy and negate --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqcpn001 copynegate +7.50 -> -7.50
-
--- Infinities
-dqcpn011 copynegate Infinity -> -Infinity
-dqcpn012 copynegate -Infinity -> Infinity
-
--- NaNs, 0 payload
-dqcpn021 copynegate NaN -> -NaN
-dqcpn022 copynegate -NaN -> NaN
-dqcpn023 copynegate sNaN -> -sNaN
-dqcpn024 copynegate -sNaN -> sNaN
-
--- NaNs, non-0 payload
-dqcpn031 copynegate NaN13 -> -NaN13
-dqcpn032 copynegate -NaN13 -> NaN13
-dqcpn033 copynegate sNaN13 -> -sNaN13
-dqcpn034 copynegate -sNaN13 -> sNaN13
-dqcpn035 copynegate NaN70 -> -NaN70
-dqcpn036 copynegate -NaN70 -> NaN70
-dqcpn037 copynegate sNaN101 -> -sNaN101
-dqcpn038 copynegate -sNaN101 -> sNaN101
-
--- finites
-dqcpn101 copynegate 7 -> -7
-dqcpn102 copynegate -7 -> 7
-dqcpn103 copynegate 75 -> -75
-dqcpn104 copynegate -75 -> 75
-dqcpn105 copynegate 7.50 -> -7.50
-dqcpn106 copynegate -7.50 -> 7.50
-dqcpn107 copynegate 7.500 -> -7.500
-dqcpn108 copynegate -7.500 -> 7.500
-
--- zeros
-dqcpn111 copynegate 0 -> -0
-dqcpn112 copynegate -0 -> 0
-dqcpn113 copynegate 0E+4 -> -0E+4
-dqcpn114 copynegate -0E+4 -> 0E+4
-dqcpn115 copynegate 0.0000 -> -0.0000
-dqcpn116 copynegate -0.0000 -> 0.0000
-dqcpn117 copynegate 0E-141 -> -0E-141
-dqcpn118 copynegate -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqcpn121 copynegate 2682682682682682682682682682682682 -> -2682682682682682682682682682682682
-dqcpn122 copynegate -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqcpn123 copynegate 1341341341341341341341341341341341 -> -1341341341341341341341341341341341
-dqcpn124 copynegate -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcpn131 copynegate 9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqcpn132 copynegate 1E-6143 -> -1E-6143
-dqcpn133 copynegate 1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqcpn134 copynegate 1E-6176 -> -1E-6176
-
-dqcpn135 copynegate -1E-6176 -> 1E-6176
-dqcpn136 copynegate -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqcpn137 copynegate -1E-6143 -> 1E-6143
-dqcpn138 copynegate -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqCopyNegate.decTest -- quiet decQuad copy and negate --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqcpn001 copynegate +7.50 -> -7.50
+
+-- Infinities
+dqcpn011 copynegate Infinity -> -Infinity
+dqcpn012 copynegate -Infinity -> Infinity
+
+-- NaNs, 0 payload
+dqcpn021 copynegate NaN -> -NaN
+dqcpn022 copynegate -NaN -> NaN
+dqcpn023 copynegate sNaN -> -sNaN
+dqcpn024 copynegate -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+dqcpn031 copynegate NaN13 -> -NaN13
+dqcpn032 copynegate -NaN13 -> NaN13
+dqcpn033 copynegate sNaN13 -> -sNaN13
+dqcpn034 copynegate -sNaN13 -> sNaN13
+dqcpn035 copynegate NaN70 -> -NaN70
+dqcpn036 copynegate -NaN70 -> NaN70
+dqcpn037 copynegate sNaN101 -> -sNaN101
+dqcpn038 copynegate -sNaN101 -> sNaN101
+
+-- finites
+dqcpn101 copynegate 7 -> -7
+dqcpn102 copynegate -7 -> 7
+dqcpn103 copynegate 75 -> -75
+dqcpn104 copynegate -75 -> 75
+dqcpn105 copynegate 7.50 -> -7.50
+dqcpn106 copynegate -7.50 -> 7.50
+dqcpn107 copynegate 7.500 -> -7.500
+dqcpn108 copynegate -7.500 -> 7.500
+
+-- zeros
+dqcpn111 copynegate 0 -> -0
+dqcpn112 copynegate -0 -> 0
+dqcpn113 copynegate 0E+4 -> -0E+4
+dqcpn114 copynegate -0E+4 -> 0E+4
+dqcpn115 copynegate 0.0000 -> -0.0000
+dqcpn116 copynegate -0.0000 -> 0.0000
+dqcpn117 copynegate 0E-141 -> -0E-141
+dqcpn118 copynegate -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqcpn121 copynegate 2682682682682682682682682682682682 -> -2682682682682682682682682682682682
+dqcpn122 copynegate -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqcpn123 copynegate 1341341341341341341341341341341341 -> -1341341341341341341341341341341341
+dqcpn124 copynegate -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcpn131 copynegate 9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqcpn132 copynegate 1E-6143 -> -1E-6143
+dqcpn133 copynegate 1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqcpn134 copynegate 1E-6176 -> -1E-6176
+
+dqcpn135 copynegate -1E-6176 -> 1E-6176
+dqcpn136 copynegate -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqcpn137 copynegate -1E-6143 -> 1E-6143
+dqcpn138 copynegate -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqCopySign.decTest b/Lib/test/decimaltestdata/dqCopySign.decTest
index 97b5e6e955..ce794b7c35 100644
--- a/Lib/test/decimaltestdata/dqCopySign.decTest
+++ b/Lib/test/decimaltestdata/dqCopySign.decTest
@@ -1,175 +1,175 @@
-------------------------------------------------------------------------
--- dqCopySign.decTest -- quiet decQuad copy with sign from rhs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqcps001 copysign +7.50 11 -> 7.50
-
--- Infinities
-dqcps011 copysign Infinity 11 -> Infinity
-dqcps012 copysign -Infinity 11 -> Infinity
-
--- NaNs, 0 payload
-dqcps021 copysign NaN 11 -> NaN
-dqcps022 copysign -NaN 11 -> NaN
-dqcps023 copysign sNaN 11 -> sNaN
-dqcps024 copysign -sNaN 11 -> sNaN
-
--- NaNs, non-0 payload
-dqcps031 copysign NaN10 11 -> NaN10
-dqcps032 copysign -NaN10 11 -> NaN10
-dqcps033 copysign sNaN10 11 -> sNaN10
-dqcps034 copysign -sNaN10 11 -> sNaN10
-dqcps035 copysign NaN7 11 -> NaN7
-dqcps036 copysign -NaN7 11 -> NaN7
-dqcps037 copysign sNaN101 11 -> sNaN101
-dqcps038 copysign -sNaN101 11 -> sNaN101
-
--- finites
-dqcps101 copysign 7 11 -> 7
-dqcps102 copysign -7 11 -> 7
-dqcps103 copysign 75 11 -> 75
-dqcps104 copysign -75 11 -> 75
-dqcps105 copysign 7.50 11 -> 7.50
-dqcps106 copysign -7.50 11 -> 7.50
-dqcps107 copysign 7.500 11 -> 7.500
-dqcps108 copysign -7.500 11 -> 7.500
-
--- zeros
-dqcps111 copysign 0 11 -> 0
-dqcps112 copysign -0 11 -> 0
-dqcps113 copysign 0E+4 11 -> 0E+4
-dqcps114 copysign -0E+4 11 -> 0E+4
-dqcps115 copysign 0.0000 11 -> 0.0000
-dqcps116 copysign -0.0000 11 -> 0.0000
-dqcps117 copysign 0E-141 11 -> 0E-141
-dqcps118 copysign -0E-141 11 -> 0E-141
-
--- full coefficients, alternating bits
-dqcps121 copysign 2682682682682682682682682682682682 8 -> 2682682682682682682682682682682682
-dqcps122 copysign -2682682682682682682682682682682682 8 -> 2682682682682682682682682682682682
-dqcps123 copysign 1341341341341341341341341341341341 8 -> 1341341341341341341341341341341341
-dqcps124 copysign -1341341341341341341341341341341341 8 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcps131 copysign 9.999999999999999999999999999999999E+6144 8 -> 9.999999999999999999999999999999999E+6144
-dqcps132 copysign 1E-6143 8 -> 1E-6143
-dqcps133 copysign 1.000000000000000000000000000000000E-6143 8 -> 1.000000000000000000000000000000000E-6143
-dqcps134 copysign 1E-6176 8 -> 1E-6176
-
-dqcps135 copysign -1E-6176 8 -> 1E-6176
-dqcps136 copysign -1.000000000000000000000000000000000E-6143 8 -> 1.000000000000000000000000000000000E-6143
-dqcps137 copysign -1E-6143 8 -> 1E-6143
-dqcps138 copysign -9.999999999999999999999999999999999E+6144 8 -> 9.999999999999999999999999999999999E+6144
-
--- repeat with negative RHS
-
--- Infinities
-dqcps211 copysign Infinity -34 -> -Infinity
-dqcps212 copysign -Infinity -34 -> -Infinity
-
--- NaNs, 0 payload
-dqcps221 copysign NaN -34 -> -NaN
-dqcps222 copysign -NaN -34 -> -NaN
-dqcps223 copysign sNaN -34 -> -sNaN
-dqcps224 copysign -sNaN -34 -> -sNaN
-
--- NaNs, non-0 payload
-dqcps231 copysign NaN10 -34 -> -NaN10
-dqcps232 copysign -NaN10 -34 -> -NaN10
-dqcps233 copysign sNaN10 -34 -> -sNaN10
-dqcps234 copysign -sNaN10 -34 -> -sNaN10
-dqcps235 copysign NaN7 -34 -> -NaN7
-dqcps236 copysign -NaN7 -34 -> -NaN7
-dqcps237 copysign sNaN101 -34 -> -sNaN101
-dqcps238 copysign -sNaN101 -34 -> -sNaN101
-
--- finites
-dqcps301 copysign 7 -34 -> -7
-dqcps302 copysign -7 -34 -> -7
-dqcps303 copysign 75 -34 -> -75
-dqcps304 copysign -75 -34 -> -75
-dqcps305 copysign 7.50 -34 -> -7.50
-dqcps306 copysign -7.50 -34 -> -7.50
-dqcps307 copysign 7.500 -34 -> -7.500
-dqcps308 copysign -7.500 -34 -> -7.500
-
--- zeros
-dqcps311 copysign 0 -34 -> -0
-dqcps312 copysign -0 -34 -> -0
-dqcps313 copysign 0E+4 -34 -> -0E+4
-dqcps314 copysign -0E+4 -34 -> -0E+4
-dqcps315 copysign 0.0000 -34 -> -0.0000
-dqcps316 copysign -0.0000 -34 -> -0.0000
-dqcps317 copysign 0E-141 -34 -> -0E-141
-dqcps318 copysign -0E-141 -34 -> -0E-141
-
--- full coefficients, alternating bits
-dqcps321 copysign 2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
-dqcps322 copysign -2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
-dqcps323 copysign 1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
-dqcps324 copysign -1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcps331 copysign 9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144
-dqcps332 copysign 1E-6143 -1 -> -1E-6143
-dqcps333 copysign 1.000000000000000000000000000000000E-6143 -1 -> -1.000000000000000000000000000000000E-6143
-dqcps334 copysign 1E-6176 -1 -> -1E-6176
-
-dqcps335 copysign -1E-6176 -3 -> -1E-6176
-dqcps336 copysign -1.000000000000000000000000000000000E-6143 -3 -> -1.000000000000000000000000000000000E-6143
-dqcps337 copysign -1E-6143 -3 -> -1E-6143
-dqcps338 copysign -9.999999999999999999999999999999999E+6144 -3 -> -9.999999999999999999999999999999999E+6144
-
--- Other kinds of RHS
-dqcps401 copysign 701 -34 -> -701
-dqcps402 copysign -720 -34 -> -720
-dqcps403 copysign 701 -0 -> -701
-dqcps404 copysign -720 -0 -> -720
-dqcps405 copysign 701 +0 -> 701
-dqcps406 copysign -720 +0 -> 720
-dqcps407 copysign 701 +34 -> 701
-dqcps408 copysign -720 +34 -> 720
-
-dqcps413 copysign 701 -Inf -> -701
-dqcps414 copysign -720 -Inf -> -720
-dqcps415 copysign 701 +Inf -> 701
-dqcps416 copysign -720 +Inf -> 720
-
-dqcps420 copysign 701 -NaN -> -701
-dqcps421 copysign -720 -NaN -> -720
-dqcps422 copysign 701 +NaN -> 701
-dqcps423 copysign -720 +NaN -> 720
-dqcps425 copysign -720 +NaN8 -> 720
-
-dqcps426 copysign 701 -sNaN -> -701
-dqcps427 copysign -720 -sNaN -> -720
-dqcps428 copysign 701 +sNaN -> 701
-dqcps429 copysign -720 +sNaN -> 720
-dqcps430 copysign -720 +sNaN3 -> 720
-
+------------------------------------------------------------------------
+-- dqCopySign.decTest -- quiet decQuad copy with sign from rhs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqcps001 copysign +7.50 11 -> 7.50
+
+-- Infinities
+dqcps011 copysign Infinity 11 -> Infinity
+dqcps012 copysign -Infinity 11 -> Infinity
+
+-- NaNs, 0 payload
+dqcps021 copysign NaN 11 -> NaN
+dqcps022 copysign -NaN 11 -> NaN
+dqcps023 copysign sNaN 11 -> sNaN
+dqcps024 copysign -sNaN 11 -> sNaN
+
+-- NaNs, non-0 payload
+dqcps031 copysign NaN10 11 -> NaN10
+dqcps032 copysign -NaN10 11 -> NaN10
+dqcps033 copysign sNaN10 11 -> sNaN10
+dqcps034 copysign -sNaN10 11 -> sNaN10
+dqcps035 copysign NaN7 11 -> NaN7
+dqcps036 copysign -NaN7 11 -> NaN7
+dqcps037 copysign sNaN101 11 -> sNaN101
+dqcps038 copysign -sNaN101 11 -> sNaN101
+
+-- finites
+dqcps101 copysign 7 11 -> 7
+dqcps102 copysign -7 11 -> 7
+dqcps103 copysign 75 11 -> 75
+dqcps104 copysign -75 11 -> 75
+dqcps105 copysign 7.50 11 -> 7.50
+dqcps106 copysign -7.50 11 -> 7.50
+dqcps107 copysign 7.500 11 -> 7.500
+dqcps108 copysign -7.500 11 -> 7.500
+
+-- zeros
+dqcps111 copysign 0 11 -> 0
+dqcps112 copysign -0 11 -> 0
+dqcps113 copysign 0E+4 11 -> 0E+4
+dqcps114 copysign -0E+4 11 -> 0E+4
+dqcps115 copysign 0.0000 11 -> 0.0000
+dqcps116 copysign -0.0000 11 -> 0.0000
+dqcps117 copysign 0E-141 11 -> 0E-141
+dqcps118 copysign -0E-141 11 -> 0E-141
+
+-- full coefficients, alternating bits
+dqcps121 copysign 2682682682682682682682682682682682 8 -> 2682682682682682682682682682682682
+dqcps122 copysign -2682682682682682682682682682682682 8 -> 2682682682682682682682682682682682
+dqcps123 copysign 1341341341341341341341341341341341 8 -> 1341341341341341341341341341341341
+dqcps124 copysign -1341341341341341341341341341341341 8 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcps131 copysign 9.999999999999999999999999999999999E+6144 8 -> 9.999999999999999999999999999999999E+6144
+dqcps132 copysign 1E-6143 8 -> 1E-6143
+dqcps133 copysign 1.000000000000000000000000000000000E-6143 8 -> 1.000000000000000000000000000000000E-6143
+dqcps134 copysign 1E-6176 8 -> 1E-6176
+
+dqcps135 copysign -1E-6176 8 -> 1E-6176
+dqcps136 copysign -1.000000000000000000000000000000000E-6143 8 -> 1.000000000000000000000000000000000E-6143
+dqcps137 copysign -1E-6143 8 -> 1E-6143
+dqcps138 copysign -9.999999999999999999999999999999999E+6144 8 -> 9.999999999999999999999999999999999E+6144
+
+-- repeat with negative RHS
+
+-- Infinities
+dqcps211 copysign Infinity -34 -> -Infinity
+dqcps212 copysign -Infinity -34 -> -Infinity
+
+-- NaNs, 0 payload
+dqcps221 copysign NaN -34 -> -NaN
+dqcps222 copysign -NaN -34 -> -NaN
+dqcps223 copysign sNaN -34 -> -sNaN
+dqcps224 copysign -sNaN -34 -> -sNaN
+
+-- NaNs, non-0 payload
+dqcps231 copysign NaN10 -34 -> -NaN10
+dqcps232 copysign -NaN10 -34 -> -NaN10
+dqcps233 copysign sNaN10 -34 -> -sNaN10
+dqcps234 copysign -sNaN10 -34 -> -sNaN10
+dqcps235 copysign NaN7 -34 -> -NaN7
+dqcps236 copysign -NaN7 -34 -> -NaN7
+dqcps237 copysign sNaN101 -34 -> -sNaN101
+dqcps238 copysign -sNaN101 -34 -> -sNaN101
+
+-- finites
+dqcps301 copysign 7 -34 -> -7
+dqcps302 copysign -7 -34 -> -7
+dqcps303 copysign 75 -34 -> -75
+dqcps304 copysign -75 -34 -> -75
+dqcps305 copysign 7.50 -34 -> -7.50
+dqcps306 copysign -7.50 -34 -> -7.50
+dqcps307 copysign 7.500 -34 -> -7.500
+dqcps308 copysign -7.500 -34 -> -7.500
+
+-- zeros
+dqcps311 copysign 0 -34 -> -0
+dqcps312 copysign -0 -34 -> -0
+dqcps313 copysign 0E+4 -34 -> -0E+4
+dqcps314 copysign -0E+4 -34 -> -0E+4
+dqcps315 copysign 0.0000 -34 -> -0.0000
+dqcps316 copysign -0.0000 -34 -> -0.0000
+dqcps317 copysign 0E-141 -34 -> -0E-141
+dqcps318 copysign -0E-141 -34 -> -0E-141
+
+-- full coefficients, alternating bits
+dqcps321 copysign 2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
+dqcps322 copysign -2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
+dqcps323 copysign 1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
+dqcps324 copysign -1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcps331 copysign 9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144
+dqcps332 copysign 1E-6143 -1 -> -1E-6143
+dqcps333 copysign 1.000000000000000000000000000000000E-6143 -1 -> -1.000000000000000000000000000000000E-6143
+dqcps334 copysign 1E-6176 -1 -> -1E-6176
+
+dqcps335 copysign -1E-6176 -3 -> -1E-6176
+dqcps336 copysign -1.000000000000000000000000000000000E-6143 -3 -> -1.000000000000000000000000000000000E-6143
+dqcps337 copysign -1E-6143 -3 -> -1E-6143
+dqcps338 copysign -9.999999999999999999999999999999999E+6144 -3 -> -9.999999999999999999999999999999999E+6144
+
+-- Other kinds of RHS
+dqcps401 copysign 701 -34 -> -701
+dqcps402 copysign -720 -34 -> -720
+dqcps403 copysign 701 -0 -> -701
+dqcps404 copysign -720 -0 -> -720
+dqcps405 copysign 701 +0 -> 701
+dqcps406 copysign -720 +0 -> 720
+dqcps407 copysign 701 +34 -> 701
+dqcps408 copysign -720 +34 -> 720
+
+dqcps413 copysign 701 -Inf -> -701
+dqcps414 copysign -720 -Inf -> -720
+dqcps415 copysign 701 +Inf -> 701
+dqcps416 copysign -720 +Inf -> 720
+
+dqcps420 copysign 701 -NaN -> -701
+dqcps421 copysign -720 -NaN -> -720
+dqcps422 copysign 701 +NaN -> 701
+dqcps423 copysign -720 +NaN -> 720
+dqcps425 copysign -720 +NaN8 -> 720
+
+dqcps426 copysign 701 -sNaN -> -701
+dqcps427 copysign -720 -sNaN -> -720
+dqcps428 copysign 701 +sNaN -> 701
+dqcps429 copysign -720 +sNaN -> 720
+dqcps430 copysign -720 +sNaN3 -> 720
+
diff --git a/Lib/test/decimaltestdata/dqDivide.decTest b/Lib/test/decimaltestdata/dqDivide.decTest
index 2abb939d54..3cf60c6024 100644
--- a/Lib/test/decimaltestdata/dqDivide.decTest
+++ b/Lib/test/decimaltestdata/dqDivide.decTest
@@ -1,808 +1,808 @@
-------------------------------------------------------------------------
--- dqDivide.decTest -- decQuad division --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqdiv001 divide 1 1 -> 1
-dqdiv002 divide 2 1 -> 2
-dqdiv003 divide 1 2 -> 0.5
-dqdiv004 divide 2 2 -> 1
-dqdiv005 divide 0 1 -> 0
-dqdiv006 divide 0 2 -> 0
-dqdiv007 divide 1 3 -> 0.3333333333333333333333333333333333 Inexact Rounded
-dqdiv008 divide 2 3 -> 0.6666666666666666666666666666666667 Inexact Rounded
-dqdiv009 divide 3 3 -> 1
-
-dqdiv010 divide 2.4 1 -> 2.4
-dqdiv011 divide 2.4 -1 -> -2.4
-dqdiv012 divide -2.4 1 -> -2.4
-dqdiv013 divide -2.4 -1 -> 2.4
-dqdiv014 divide 2.40 1 -> 2.40
-dqdiv015 divide 2.400 1 -> 2.400
-dqdiv016 divide 2.4 2 -> 1.2
-dqdiv017 divide 2.400 2 -> 1.200
-dqdiv018 divide 2. 2 -> 1
-dqdiv019 divide 20 20 -> 1
-
-dqdiv020 divide 187 187 -> 1
-dqdiv021 divide 5 2 -> 2.5
-dqdiv022 divide 50 20 -> 2.5
-dqdiv023 divide 500 200 -> 2.5
-dqdiv024 divide 50.0 20.0 -> 2.5
-dqdiv025 divide 5.00 2.00 -> 2.5
-dqdiv026 divide 5 2.0 -> 2.5
-dqdiv027 divide 5 2.000 -> 2.5
-dqdiv028 divide 5 0.20 -> 25
-dqdiv029 divide 5 0.200 -> 25
-dqdiv030 divide 10 1 -> 10
-dqdiv031 divide 100 1 -> 100
-dqdiv032 divide 1000 1 -> 1000
-dqdiv033 divide 1000 100 -> 10
-
-dqdiv035 divide 1 2 -> 0.5
-dqdiv036 divide 1 4 -> 0.25
-dqdiv037 divide 1 8 -> 0.125
-dqdiv038 divide 1 16 -> 0.0625
-dqdiv039 divide 1 32 -> 0.03125
-dqdiv040 divide 1 64 -> 0.015625
-dqdiv041 divide 1 -2 -> -0.5
-dqdiv042 divide 1 -4 -> -0.25
-dqdiv043 divide 1 -8 -> -0.125
-dqdiv044 divide 1 -16 -> -0.0625
-dqdiv045 divide 1 -32 -> -0.03125
-dqdiv046 divide 1 -64 -> -0.015625
-dqdiv047 divide -1 2 -> -0.5
-dqdiv048 divide -1 4 -> -0.25
-dqdiv049 divide -1 8 -> -0.125
-dqdiv050 divide -1 16 -> -0.0625
-dqdiv051 divide -1 32 -> -0.03125
-dqdiv052 divide -1 64 -> -0.015625
-dqdiv053 divide -1 -2 -> 0.5
-dqdiv054 divide -1 -4 -> 0.25
-dqdiv055 divide -1 -8 -> 0.125
-dqdiv056 divide -1 -16 -> 0.0625
-dqdiv057 divide -1 -32 -> 0.03125
-dqdiv058 divide -1 -64 -> 0.015625
-
--- bcdTime
-dqdiv060 divide 1 7 -> 0.1428571428571428571428571428571429 Inexact Rounded
-dqdiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717123193907511985359 Inexact Rounded
-
--- 1234567890123456
-dqdiv067 divide 9999999999999999999999999999999999 1 -> 9999999999999999999999999999999999
-dqdiv068 divide 999999999999999999999999999999999 1 -> 999999999999999999999999999999999
-dqdiv069 divide 99999999999999999999999999999999 1 -> 99999999999999999999999999999999
-dqdiv070 divide 99999999999999999 1 -> 99999999999999999
-dqdiv071 divide 9999999999999999 1 -> 9999999999999999
-dqdiv072 divide 999999999999999 1 -> 999999999999999
-dqdiv073 divide 99999999999999 1 -> 99999999999999
-dqdiv074 divide 9999999999999 1 -> 9999999999999
-dqdiv075 divide 999999999999 1 -> 999999999999
-dqdiv076 divide 99999999999 1 -> 99999999999
-dqdiv077 divide 9999999999 1 -> 9999999999
-dqdiv078 divide 999999999 1 -> 999999999
-dqdiv079 divide 99999999 1 -> 99999999
-dqdiv080 divide 9999999 1 -> 9999999
-dqdiv081 divide 999999 1 -> 999999
-dqdiv082 divide 99999 1 -> 99999
-dqdiv083 divide 9999 1 -> 9999
-dqdiv084 divide 999 1 -> 999
-dqdiv085 divide 99 1 -> 99
-dqdiv086 divide 9 1 -> 9
-
-dqdiv090 divide 0. 1 -> 0
-dqdiv091 divide .0 1 -> 0.0
-dqdiv092 divide 0.00 1 -> 0.00
-dqdiv093 divide 0.00E+9 1 -> 0E+7
-dqdiv094 divide 0.0000E-50 1 -> 0E-54
-
-dqdiv095 divide 1 1E-8 -> 1E+8
-dqdiv096 divide 1 1E-9 -> 1E+9
-dqdiv097 divide 1 1E-10 -> 1E+10
-dqdiv098 divide 1 1E-11 -> 1E+11
-dqdiv099 divide 1 1E-12 -> 1E+12
-
-dqdiv100 divide 1 1 -> 1
-dqdiv101 divide 1 2 -> 0.5
-dqdiv102 divide 1 3 -> 0.3333333333333333333333333333333333 Inexact Rounded
-dqdiv103 divide 1 4 -> 0.25
-dqdiv104 divide 1 5 -> 0.2
-dqdiv105 divide 1 6 -> 0.1666666666666666666666666666666667 Inexact Rounded
-dqdiv106 divide 1 7 -> 0.1428571428571428571428571428571429 Inexact Rounded
-dqdiv107 divide 1 8 -> 0.125
-dqdiv108 divide 1 9 -> 0.1111111111111111111111111111111111 Inexact Rounded
-dqdiv109 divide 1 10 -> 0.1
-dqdiv110 divide 1 1 -> 1
-dqdiv111 divide 2 1 -> 2
-dqdiv112 divide 3 1 -> 3
-dqdiv113 divide 4 1 -> 4
-dqdiv114 divide 5 1 -> 5
-dqdiv115 divide 6 1 -> 6
-dqdiv116 divide 7 1 -> 7
-dqdiv117 divide 8 1 -> 8
-dqdiv118 divide 9 1 -> 9
-dqdiv119 divide 10 1 -> 10
-
-dqdiv120 divide 3E+1 0.001 -> 3E+4
-dqdiv121 divide 2.200 2 -> 1.100
-
-dqdiv130 divide 12345 4.999 -> 2469.493898779755951190238047609522 Inexact Rounded
-dqdiv131 divide 12345 4.99 -> 2473.947895791583166332665330661323 Inexact Rounded
-dqdiv132 divide 12345 4.9 -> 2519.387755102040816326530612244898 Inexact Rounded
-dqdiv133 divide 12345 5 -> 2469
-dqdiv134 divide 12345 5.1 -> 2420.588235294117647058823529411765 Inexact Rounded
-dqdiv135 divide 12345 5.01 -> 2464.071856287425149700598802395210 Inexact Rounded
-dqdiv136 divide 12345 5.001 -> 2468.506298740251949610077984403119 Inexact Rounded
-
--- test possibly imprecise results
-dqdiv220 divide 391 597 -> 0.6549413735343383584589614740368509 Inexact Rounded
-dqdiv221 divide 391 -597 -> -0.6549413735343383584589614740368509 Inexact Rounded
-dqdiv222 divide -391 597 -> -0.6549413735343383584589614740368509 Inexact Rounded
-dqdiv223 divide -391 -597 -> 0.6549413735343383584589614740368509 Inexact Rounded
-
--- test some cases that are close to exponent overflow
-dqdiv270 divide 1 1e6144 -> 1E-6144 Subnormal
-dqdiv271 divide 1 0.9e6144 -> 1.11111111111111111111111111111111E-6144 Rounded Inexact Subnormal Underflow
-dqdiv272 divide 1 0.99e6144 -> 1.01010101010101010101010101010101E-6144 Rounded Inexact Subnormal Underflow
-dqdiv273 divide 1 0.9999999999999999e6144 -> 1.00000000000000010000000000000001E-6144 Rounded Inexact Subnormal Underflow
-dqdiv274 divide 9e6144 1 -> 9.000000000000000000000000000000000E+6144 Clamped
-dqdiv275 divide 9.9e6144 1 -> 9.900000000000000000000000000000000E+6144 Clamped
-dqdiv276 divide 9.99e6144 1 -> 9.990000000000000000000000000000000E+6144 Clamped
-dqdiv277 divide 9.999999999999999e6144 1 -> 9.999999999999999000000000000000000E+6144 Clamped
-
-dqdiv278 divide 1 0.9999999999999999999999999999999999e6144 -> 1.00000000000000000000000000000000E-6144 Rounded Inexact Subnormal Underflow
-dqdiv279 divide 9.999999999999999999999999999999999e6144 1 -> 9.999999999999999999999999999999999E+6144
-
--- Divide into 0 tests
-dqdiv301 divide 0 7 -> 0
-dqdiv302 divide 0 7E-5 -> 0E+5
-dqdiv303 divide 0 7E-1 -> 0E+1
-dqdiv304 divide 0 7E+1 -> 0.0
-dqdiv305 divide 0 7E+5 -> 0.00000
-dqdiv306 divide 0 7E+6 -> 0.000000
-dqdiv307 divide 0 7E+7 -> 0E-7
-dqdiv308 divide 0 70E-5 -> 0E+5
-dqdiv309 divide 0 70E-1 -> 0E+1
-dqdiv310 divide 0 70E+0 -> 0
-dqdiv311 divide 0 70E+1 -> 0.0
-dqdiv312 divide 0 70E+5 -> 0.00000
-dqdiv313 divide 0 70E+6 -> 0.000000
-dqdiv314 divide 0 70E+7 -> 0E-7
-dqdiv315 divide 0 700E-5 -> 0E+5
-dqdiv316 divide 0 700E-1 -> 0E+1
-dqdiv317 divide 0 700E+0 -> 0
-dqdiv318 divide 0 700E+1 -> 0.0
-dqdiv319 divide 0 700E+5 -> 0.00000
-dqdiv320 divide 0 700E+6 -> 0.000000
-dqdiv321 divide 0 700E+7 -> 0E-7
-dqdiv322 divide 0 700E+77 -> 0E-77
-
-dqdiv331 divide 0E-3 7E-5 -> 0E+2
-dqdiv332 divide 0E-3 7E-1 -> 0.00
-dqdiv333 divide 0E-3 7E+1 -> 0.0000
-dqdiv334 divide 0E-3 7E+5 -> 0E-8
-dqdiv335 divide 0E-1 7E-5 -> 0E+4
-dqdiv336 divide 0E-1 7E-1 -> 0
-dqdiv337 divide 0E-1 7E+1 -> 0.00
-dqdiv338 divide 0E-1 7E+5 -> 0.000000
-dqdiv339 divide 0E+1 7E-5 -> 0E+6
-dqdiv340 divide 0E+1 7E-1 -> 0E+2
-dqdiv341 divide 0E+1 7E+1 -> 0
-dqdiv342 divide 0E+1 7E+5 -> 0.0000
-dqdiv343 divide 0E+3 7E-5 -> 0E+8
-dqdiv344 divide 0E+3 7E-1 -> 0E+4
-dqdiv345 divide 0E+3 7E+1 -> 0E+2
-dqdiv346 divide 0E+3 7E+5 -> 0.00
-
--- These were 'input rounding'
-dqdiv441 divide 12345678000 1 -> 12345678000
-dqdiv442 divide 1 12345678000 -> 8.100000664200054464404466081166219E-11 Inexact Rounded
-dqdiv443 divide 1234567800 1 -> 1234567800
-dqdiv444 divide 1 1234567800 -> 8.100000664200054464404466081166219E-10 Inexact Rounded
-dqdiv445 divide 1234567890 1 -> 1234567890
-dqdiv446 divide 1 1234567890 -> 8.100000073710000670761006103925156E-10 Inexact Rounded
-dqdiv447 divide 1234567891 1 -> 1234567891
-dqdiv448 divide 1 1234567891 -> 8.100000067149000556665214614754629E-10 Inexact Rounded
-dqdiv449 divide 12345678901 1 -> 12345678901
-dqdiv450 divide 1 12345678901 -> 8.100000073053900658873130042376760E-11 Inexact Rounded
-dqdiv451 divide 1234567896 1 -> 1234567896
-dqdiv452 divide 1 1234567896 -> 8.100000034344000145618560617422697E-10 Inexact Rounded
-
--- high-lows
-dqdiv453 divide 1e+1 1 -> 1E+1
-dqdiv454 divide 1e+1 1.0 -> 1E+1
-dqdiv455 divide 1e+1 1.00 -> 1E+1
-dqdiv456 divide 1e+2 2 -> 5E+1
-dqdiv457 divide 1e+2 2.0 -> 5E+1
-dqdiv458 divide 1e+2 2.00 -> 5E+1
-
--- some from IEEE discussions
-dqdiv460 divide 3e0 2e0 -> 1.5
-dqdiv461 divide 30e-1 2e0 -> 1.5
-dqdiv462 divide 300e-2 2e0 -> 1.50
-dqdiv464 divide 3000e-3 2e0 -> 1.500
-dqdiv465 divide 3e0 20e-1 -> 1.5
-dqdiv466 divide 30e-1 20e-1 -> 1.5
-dqdiv467 divide 300e-2 20e-1 -> 1.5
-dqdiv468 divide 3000e-3 20e-1 -> 1.50
-dqdiv469 divide 3e0 200e-2 -> 1.5
-dqdiv470 divide 30e-1 200e-2 -> 1.5
-dqdiv471 divide 300e-2 200e-2 -> 1.5
-dqdiv472 divide 3000e-3 200e-2 -> 1.5
-dqdiv473 divide 3e0 2000e-3 -> 1.5
-dqdiv474 divide 30e-1 2000e-3 -> 1.5
-dqdiv475 divide 300e-2 2000e-3 -> 1.5
-dqdiv476 divide 3000e-3 2000e-3 -> 1.5
-
--- some reciprocals
-dqdiv480 divide 1 1.0E+33 -> 1E-33
-dqdiv481 divide 1 10E+33 -> 1E-34
-dqdiv482 divide 1 1.0E-33 -> 1E+33
-dqdiv483 divide 1 10E-33 -> 1E+32
-
--- RMS discussion table
-dqdiv484 divide 0e5 1e3 -> 0E+2
-dqdiv485 divide 0e5 2e3 -> 0E+2
-dqdiv486 divide 0e5 10e2 -> 0E+3
-dqdiv487 divide 0e5 20e2 -> 0E+3
-dqdiv488 divide 0e5 100e1 -> 0E+4
-dqdiv489 divide 0e5 200e1 -> 0E+4
-
-dqdiv491 divide 1e5 1e3 -> 1E+2
-dqdiv492 divide 1e5 2e3 -> 5E+1
-dqdiv493 divide 1e5 10e2 -> 1E+2
-dqdiv494 divide 1e5 20e2 -> 5E+1
-dqdiv495 divide 1e5 100e1 -> 1E+2
-dqdiv496 divide 1e5 200e1 -> 5E+1
-
--- tryzeros cases
-rounding: half_up
-dqdiv497 divide 0E+6108 1000E-33 -> 0E+6111 Clamped
-dqdiv498 divide 0E-6170 1000E+33 -> 0E-6176 Clamped
-
-rounding: half_up
-
--- focus on trailing zeros issues
-dqdiv500 divide 1 9.9 -> 0.1010101010101010101010101010101010 Inexact Rounded
-dqdiv501 divide 1 9.09 -> 0.1100110011001100110011001100110011 Inexact Rounded
-dqdiv502 divide 1 9.009 -> 0.1110001110001110001110001110001110 Inexact Rounded
-
-dqdiv511 divide 1 2 -> 0.5
-dqdiv512 divide 1.0 2 -> 0.5
-dqdiv513 divide 1.00 2 -> 0.50
-dqdiv514 divide 1.000 2 -> 0.500
-dqdiv515 divide 1.0000 2 -> 0.5000
-dqdiv516 divide 1.00000 2 -> 0.50000
-dqdiv517 divide 1.000000 2 -> 0.500000
-dqdiv518 divide 1.0000000 2 -> 0.5000000
-dqdiv519 divide 1.00 2.00 -> 0.5
-
-dqdiv521 divide 2 1 -> 2
-dqdiv522 divide 2 1.0 -> 2
-dqdiv523 divide 2 1.00 -> 2
-dqdiv524 divide 2 1.000 -> 2
-dqdiv525 divide 2 1.0000 -> 2
-dqdiv526 divide 2 1.00000 -> 2
-dqdiv527 divide 2 1.000000 -> 2
-dqdiv528 divide 2 1.0000000 -> 2
-dqdiv529 divide 2.00 1.00 -> 2
-
-dqdiv530 divide 2.40 2 -> 1.20
-dqdiv531 divide 2.40 4 -> 0.60
-dqdiv532 divide 2.40 10 -> 0.24
-dqdiv533 divide 2.40 2.0 -> 1.2
-dqdiv534 divide 2.40 4.0 -> 0.6
-dqdiv535 divide 2.40 10.0 -> 0.24
-dqdiv536 divide 2.40 2.00 -> 1.2
-dqdiv537 divide 2.40 4.00 -> 0.6
-dqdiv538 divide 2.40 10.00 -> 0.24
-dqdiv539 divide 0.9 0.1 -> 9
-dqdiv540 divide 0.9 0.01 -> 9E+1
-dqdiv541 divide 0.9 0.001 -> 9E+2
-dqdiv542 divide 5 2 -> 2.5
-dqdiv543 divide 5 2.0 -> 2.5
-dqdiv544 divide 5 2.00 -> 2.5
-dqdiv545 divide 5 20 -> 0.25
-dqdiv546 divide 5 20.0 -> 0.25
-dqdiv547 divide 2.400 2 -> 1.200
-dqdiv548 divide 2.400 2.0 -> 1.20
-dqdiv549 divide 2.400 2.400 -> 1
-
-dqdiv550 divide 240 1 -> 240
-dqdiv551 divide 240 10 -> 24
-dqdiv552 divide 240 100 -> 2.4
-dqdiv553 divide 240 1000 -> 0.24
-dqdiv554 divide 2400 1 -> 2400
-dqdiv555 divide 2400 10 -> 240
-dqdiv556 divide 2400 100 -> 24
-dqdiv557 divide 2400 1000 -> 2.4
-
--- +ve exponent
-dqdiv600 divide 2.4E+9 2 -> 1.2E+9
-dqdiv601 divide 2.40E+9 2 -> 1.20E+9
-dqdiv602 divide 2.400E+9 2 -> 1.200E+9
-dqdiv603 divide 2.4000E+9 2 -> 1.2000E+9
-dqdiv604 divide 24E+8 2 -> 1.2E+9
-dqdiv605 divide 240E+7 2 -> 1.20E+9
-dqdiv606 divide 2400E+6 2 -> 1.200E+9
-dqdiv607 divide 24000E+5 2 -> 1.2000E+9
-
--- more zeros, etc.
-dqdiv731 divide 5.00 1E-3 -> 5.00E+3
-dqdiv732 divide 00.00 0.000 -> NaN Division_undefined
-dqdiv733 divide 00.00 0E-3 -> NaN Division_undefined
-dqdiv734 divide 0 -0 -> NaN Division_undefined
-dqdiv735 divide -0 0 -> NaN Division_undefined
-dqdiv736 divide -0 -0 -> NaN Division_undefined
-
-dqdiv741 divide 0 -1 -> -0
-dqdiv742 divide -0 -1 -> 0
-dqdiv743 divide 0 1 -> 0
-dqdiv744 divide -0 1 -> -0
-dqdiv745 divide -1 0 -> -Infinity Division_by_zero
-dqdiv746 divide -1 -0 -> Infinity Division_by_zero
-dqdiv747 divide 1 0 -> Infinity Division_by_zero
-dqdiv748 divide 1 -0 -> -Infinity Division_by_zero
-
-dqdiv751 divide 0.0 -1 -> -0.0
-dqdiv752 divide -0.0 -1 -> 0.0
-dqdiv753 divide 0.0 1 -> 0.0
-dqdiv754 divide -0.0 1 -> -0.0
-dqdiv755 divide -1.0 0 -> -Infinity Division_by_zero
-dqdiv756 divide -1.0 -0 -> Infinity Division_by_zero
-dqdiv757 divide 1.0 0 -> Infinity Division_by_zero
-dqdiv758 divide 1.0 -0 -> -Infinity Division_by_zero
-
-dqdiv761 divide 0 -1.0 -> -0E+1
-dqdiv762 divide -0 -1.0 -> 0E+1
-dqdiv763 divide 0 1.0 -> 0E+1
-dqdiv764 divide -0 1.0 -> -0E+1
-dqdiv765 divide -1 0.0 -> -Infinity Division_by_zero
-dqdiv766 divide -1 -0.0 -> Infinity Division_by_zero
-dqdiv767 divide 1 0.0 -> Infinity Division_by_zero
-dqdiv768 divide 1 -0.0 -> -Infinity Division_by_zero
-
-dqdiv771 divide 0.0 -1.0 -> -0
-dqdiv772 divide -0.0 -1.0 -> 0
-dqdiv773 divide 0.0 1.0 -> 0
-dqdiv774 divide -0.0 1.0 -> -0
-dqdiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
-dqdiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
-dqdiv777 divide 1.0 0.0 -> Infinity Division_by_zero
-dqdiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
-
--- Specials
-dqdiv780 divide Inf -Inf -> NaN Invalid_operation
-dqdiv781 divide Inf -1000 -> -Infinity
-dqdiv782 divide Inf -1 -> -Infinity
-dqdiv783 divide Inf -0 -> -Infinity
-dqdiv784 divide Inf 0 -> Infinity
-dqdiv785 divide Inf 1 -> Infinity
-dqdiv786 divide Inf 1000 -> Infinity
-dqdiv787 divide Inf Inf -> NaN Invalid_operation
-dqdiv788 divide -1000 Inf -> -0E-6176 Clamped
-dqdiv789 divide -Inf Inf -> NaN Invalid_operation
-dqdiv790 divide -1 Inf -> -0E-6176 Clamped
-dqdiv791 divide -0 Inf -> -0E-6176 Clamped
-dqdiv792 divide 0 Inf -> 0E-6176 Clamped
-dqdiv793 divide 1 Inf -> 0E-6176 Clamped
-dqdiv794 divide 1000 Inf -> 0E-6176 Clamped
-dqdiv795 divide Inf Inf -> NaN Invalid_operation
-
-dqdiv800 divide -Inf -Inf -> NaN Invalid_operation
-dqdiv801 divide -Inf -1000 -> Infinity
-dqdiv802 divide -Inf -1 -> Infinity
-dqdiv803 divide -Inf -0 -> Infinity
-dqdiv804 divide -Inf 0 -> -Infinity
-dqdiv805 divide -Inf 1 -> -Infinity
-dqdiv806 divide -Inf 1000 -> -Infinity
-dqdiv807 divide -Inf Inf -> NaN Invalid_operation
-dqdiv808 divide -1000 Inf -> -0E-6176 Clamped
-dqdiv809 divide -Inf -Inf -> NaN Invalid_operation
-dqdiv810 divide -1 -Inf -> 0E-6176 Clamped
-dqdiv811 divide -0 -Inf -> 0E-6176 Clamped
-dqdiv812 divide 0 -Inf -> -0E-6176 Clamped
-dqdiv813 divide 1 -Inf -> -0E-6176 Clamped
-dqdiv814 divide 1000 -Inf -> -0E-6176 Clamped
-dqdiv815 divide Inf -Inf -> NaN Invalid_operation
-
-dqdiv821 divide NaN -Inf -> NaN
-dqdiv822 divide NaN -1000 -> NaN
-dqdiv823 divide NaN -1 -> NaN
-dqdiv824 divide NaN -0 -> NaN
-dqdiv825 divide NaN 0 -> NaN
-dqdiv826 divide NaN 1 -> NaN
-dqdiv827 divide NaN 1000 -> NaN
-dqdiv828 divide NaN Inf -> NaN
-dqdiv829 divide NaN NaN -> NaN
-dqdiv830 divide -Inf NaN -> NaN
-dqdiv831 divide -1000 NaN -> NaN
-dqdiv832 divide -1 NaN -> NaN
-dqdiv833 divide -0 NaN -> NaN
-dqdiv834 divide 0 NaN -> NaN
-dqdiv835 divide 1 NaN -> NaN
-dqdiv836 divide 1000 NaN -> NaN
-dqdiv837 divide Inf NaN -> NaN
-
-dqdiv841 divide sNaN -Inf -> NaN Invalid_operation
-dqdiv842 divide sNaN -1000 -> NaN Invalid_operation
-dqdiv843 divide sNaN -1 -> NaN Invalid_operation
-dqdiv844 divide sNaN -0 -> NaN Invalid_operation
-dqdiv845 divide sNaN 0 -> NaN Invalid_operation
-dqdiv846 divide sNaN 1 -> NaN Invalid_operation
-dqdiv847 divide sNaN 1000 -> NaN Invalid_operation
-dqdiv848 divide sNaN NaN -> NaN Invalid_operation
-dqdiv849 divide sNaN sNaN -> NaN Invalid_operation
-dqdiv850 divide NaN sNaN -> NaN Invalid_operation
-dqdiv851 divide -Inf sNaN -> NaN Invalid_operation
-dqdiv852 divide -1000 sNaN -> NaN Invalid_operation
-dqdiv853 divide -1 sNaN -> NaN Invalid_operation
-dqdiv854 divide -0 sNaN -> NaN Invalid_operation
-dqdiv855 divide 0 sNaN -> NaN Invalid_operation
-dqdiv856 divide 1 sNaN -> NaN Invalid_operation
-dqdiv857 divide 1000 sNaN -> NaN Invalid_operation
-dqdiv858 divide Inf sNaN -> NaN Invalid_operation
-dqdiv859 divide NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqdiv861 divide NaN9 -Inf -> NaN9
-dqdiv862 divide NaN8 1000 -> NaN8
-dqdiv863 divide NaN7 Inf -> NaN7
-dqdiv864 divide NaN6 NaN5 -> NaN6
-dqdiv865 divide -Inf NaN4 -> NaN4
-dqdiv866 divide -1000 NaN3 -> NaN3
-dqdiv867 divide Inf NaN2 -> NaN2
-
-dqdiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
-dqdiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
-dqdiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
-dqdiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
-dqdiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
-dqdiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
-dqdiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
-dqdiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
-dqdiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
-
-dqdiv881 divide -NaN9 -Inf -> -NaN9
-dqdiv882 divide -NaN8 1000 -> -NaN8
-dqdiv883 divide -NaN7 Inf -> -NaN7
-dqdiv884 divide -NaN6 -NaN5 -> -NaN6
-dqdiv885 divide -Inf -NaN4 -> -NaN4
-dqdiv886 divide -1000 -NaN3 -> -NaN3
-dqdiv887 divide Inf -NaN2 -> -NaN2
-
-dqdiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqdiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
-dqdiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
-dqdiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
-dqdiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-dqdiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
-dqdiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
-dqdiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
-dqdiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- Various flavours of divide by 0
-dqdiv901 divide 0 0 -> NaN Division_undefined
-dqdiv902 divide 0.0E5 0 -> NaN Division_undefined
-dqdiv903 divide 0.000 0 -> NaN Division_undefined
-dqdiv904 divide 0.0001 0 -> Infinity Division_by_zero
-dqdiv905 divide 0.01 0 -> Infinity Division_by_zero
-dqdiv906 divide 0.1 0 -> Infinity Division_by_zero
-dqdiv907 divide 1 0 -> Infinity Division_by_zero
-dqdiv908 divide 1 0.0 -> Infinity Division_by_zero
-dqdiv909 divide 10 0.0 -> Infinity Division_by_zero
-dqdiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
-dqdiv911 divide 1E+100 0 -> Infinity Division_by_zero
-
-dqdiv921 divide -0.0001 0 -> -Infinity Division_by_zero
-dqdiv922 divide -0.01 0 -> -Infinity Division_by_zero
-dqdiv923 divide -0.1 0 -> -Infinity Division_by_zero
-dqdiv924 divide -1 0 -> -Infinity Division_by_zero
-dqdiv925 divide -1 0.0 -> -Infinity Division_by_zero
-dqdiv926 divide -10 0.0 -> -Infinity Division_by_zero
-dqdiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
-dqdiv928 divide -1E+100 0 -> -Infinity Division_by_zero
-
-dqdiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
-dqdiv932 divide 0.01 -0 -> -Infinity Division_by_zero
-dqdiv933 divide 0.1 -0 -> -Infinity Division_by_zero
-dqdiv934 divide 1 -0 -> -Infinity Division_by_zero
-dqdiv935 divide 1 -0.0 -> -Infinity Division_by_zero
-dqdiv936 divide 10 -0.0 -> -Infinity Division_by_zero
-dqdiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
-dqdiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
-
-dqdiv941 divide -0.0001 -0 -> Infinity Division_by_zero
-dqdiv942 divide -0.01 -0 -> Infinity Division_by_zero
-dqdiv943 divide -0.1 -0 -> Infinity Division_by_zero
-dqdiv944 divide -1 -0 -> Infinity Division_by_zero
-dqdiv945 divide -1 -0.0 -> Infinity Division_by_zero
-dqdiv946 divide -10 -0.0 -> Infinity Division_by_zero
-dqdiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
-dqdiv948 divide -1E+100 -0 -> Infinity Division_by_zero
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dqdiv1021 divide 1E0 1E0 -> 1
-dqdiv1022 divide 1E0 2E0 -> 0.5
-dqdiv1023 divide 1E0 3E0 -> 0.3333333333333333333333333333333333 Inexact Rounded
-dqdiv1024 divide 100E-2 1000E-3 -> 1
-dqdiv1025 divide 24E-1 2E0 -> 1.2
-dqdiv1026 divide 2400E-3 2E0 -> 1.200
-dqdiv1027 divide 5E0 2E0 -> 2.5
-dqdiv1028 divide 5E0 20E-1 -> 2.5
-dqdiv1029 divide 5E0 2000E-3 -> 2.5
-dqdiv1030 divide 5E0 2E-1 -> 25
-dqdiv1031 divide 5E0 20E-2 -> 25
-dqdiv1032 divide 480E-2 3E0 -> 1.60
-dqdiv1033 divide 47E-1 2E0 -> 2.35
-
--- ECMAScript bad examples
-rounding: half_down
-dqdiv1040 divide 5 9 -> 0.5555555555555555555555555555555556 Inexact Rounded
-rounding: half_even
-dqdiv1041 divide 6 11 -> 0.5454545454545454545454545454545455 Inexact Rounded
-
--- Gyuris example
-dqdiv1050 divide 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 0.9999999999999999999999999999991254 Inexact Rounded
-
--- overflow and underflow tests .. note subnormal results
--- signs
-dqdiv1751 divide 1e+4277 1e-3311 -> Infinity Overflow Inexact Rounded
-dqdiv1752 divide 1e+4277 -1e-3311 -> -Infinity Overflow Inexact Rounded
-dqdiv1753 divide -1e+4277 1e-3311 -> -Infinity Overflow Inexact Rounded
-dqdiv1754 divide -1e+4277 -1e-3311 -> Infinity Overflow Inexact Rounded
-dqdiv1755 divide 1e-4277 1e+3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1756 divide 1e-4277 -1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1757 divide -1e-4277 1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1758 divide -1e-4277 -1e+3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dqdiv1760 divide 1e-6069 1e+101 -> 1E-6170 Subnormal
-dqdiv1761 divide 1e-6069 1e+102 -> 1E-6171 Subnormal
-dqdiv1762 divide 1e-6069 1e+103 -> 1E-6172 Subnormal
-dqdiv1763 divide 1e-6069 1e+104 -> 1E-6173 Subnormal
-dqdiv1764 divide 1e-6069 1e+105 -> 1E-6174 Subnormal
-dqdiv1765 divide 1e-6069 1e+106 -> 1E-6175 Subnormal
-dqdiv1766 divide 1e-6069 1e+107 -> 1E-6176 Subnormal
-dqdiv1767 divide 1e-6069 1e+108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1768 divide 1e-6069 1e+109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1769 divide 1e-6069 1e+110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-dqdiv1770 divide 1e+40 1e-6101 -> 1.000000000000000000000000000000E+6141 Clamped
-dqdiv1771 divide 1e+40 1e-6102 -> 1.0000000000000000000000000000000E+6142 Clamped
-dqdiv1772 divide 1e+40 1e-6103 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqdiv1773 divide 1e+40 1e-6104 -> 1.000000000000000000000000000000000E+6144 Clamped
-dqdiv1774 divide 1e+40 1e-6105 -> Infinity Overflow Inexact Rounded
-dqdiv1775 divide 1e+40 1e-6106 -> Infinity Overflow Inexact Rounded
-dqdiv1776 divide 1e+40 1e-6107 -> Infinity Overflow Inexact Rounded
-dqdiv1777 divide 1e+40 1e-6108 -> Infinity Overflow Inexact Rounded
-dqdiv1778 divide 1e+40 1e-6109 -> Infinity Overflow Inexact Rounded
-dqdiv1779 divide 1e+40 1e-6110 -> Infinity Overflow Inexact Rounded
-
-dqdiv1801 divide 1.0000E-6172 1 -> 1.0000E-6172 Subnormal
-dqdiv1802 divide 1.000E-6172 1e+1 -> 1.000E-6173 Subnormal
-dqdiv1803 divide 1.00E-6172 1e+2 -> 1.00E-6174 Subnormal
-dqdiv1804 divide 1.0E-6172 1e+3 -> 1.0E-6175 Subnormal
-dqdiv1805 divide 1.0E-6172 1e+4 -> 1E-6176 Subnormal Rounded
-dqdiv1806 divide 1.3E-6172 1e+4 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1807 divide 1.5E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1808 divide 1.7E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1809 divide 2.3E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1810 divide 2.5E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1811 divide 2.7E-6172 1e+4 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1812 divide 1.49E-6172 1e+4 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1813 divide 1.50E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1814 divide 1.51E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1815 divide 2.49E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1816 divide 2.50E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1817 divide 2.51E-6172 1e+4 -> 3E-6176 Underflow Subnormal Inexact Rounded
-
-dqdiv1818 divide 1E-6172 1e+4 -> 1E-6176 Subnormal
-dqdiv1819 divide 3E-6172 1e+5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1820 divide 5E-6172 1e+5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1821 divide 7E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1822 divide 9E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1823 divide 9.9E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-
-dqdiv1824 divide 1E-6172 -1e+4 -> -1E-6176 Subnormal
-dqdiv1825 divide 3E-6172 -1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1826 divide -5E-6172 1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1827 divide 7E-6172 -1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1828 divide -9E-6172 1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1829 divide 9.9E-6172 -1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1830 divide 3.0E-6172 -1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqdiv1831 divide 1.0E-5977 1e+200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1832 divide 1.0E-5977 1e+199 -> 1E-6176 Subnormal Rounded
-dqdiv1833 divide 1.0E-5977 1e+198 -> 1.0E-6175 Subnormal
-dqdiv1834 divide 2.0E-5977 2e+198 -> 1.0E-6175 Subnormal
-dqdiv1835 divide 4.0E-5977 4e+198 -> 1.0E-6175 Subnormal
-dqdiv1836 divide 10.0E-5977 10e+198 -> 1.0E-6175 Subnormal
-dqdiv1837 divide 30.0E-5977 30e+198 -> 1.0E-6175 Subnormal
-dqdiv1838 divide 40.0E-5982 40e+166 -> 1.0E-6148 Subnormal
-dqdiv1839 divide 40.0E-5982 40e+165 -> 1.0E-6147 Subnormal
-dqdiv1840 divide 40.0E-5982 40e+164 -> 1.0E-6146 Subnormal
-
--- randoms
-rounding: half_even
-dqdiv2010 divide -5231195652931651968034356117118850 -7243718664422548573203260970.34995 -> 722169.9095831284624736051460550680 Inexact Rounded
-dqdiv2011 divide -89584669773927.82711237350022515352 -42077943728529635884.21142627532985 -> 0.000002129017291146471565928125887527266 Inexact Rounded
-dqdiv2012 divide -2.828201693360723203806974891946180E-232 812596541221823960386384403089240.9 -> -3.480450075640521320040055759125120E-265 Inexact Rounded
-dqdiv2013 divide -6442775372761069267502937539408720 24904085056.69185465145182606089196 -> -258703556388226463687701.4884719589 Inexact Rounded
-dqdiv2014 divide 5.535520011272625629610079879714705 -44343664650.57203052003068113531208 -> -1.248322630728089308975940533493562E-10 Inexact Rounded
-dqdiv2015 divide 65919273712517865964325.99419625010 -314733354141381737378622515.7789054 -> -0.0002094448295521490616379784758911632 Inexact Rounded
-dqdiv2016 divide -7.779172568193197107115275140431129E+759 -140453015639.3988987652895178782143 -> 5.538629792161641534962774244238115E+748 Inexact Rounded
-dqdiv2017 divide 644314832597569.0181226067518178797 -115024585257425.1635759521565201075 -> -5.601540150356479257367687450922795 Inexact Rounded
-dqdiv2018 divide 6.898640941579611450676592553286870E-47 -11272429881407851485163914999.25943 -> -6.119923578285338689371137648319280E-75 Inexact Rounded
-dqdiv2019 divide -3591344544888727133.30819750163254 5329395.423792795661446561090331037 -> -673874662941.1968525589460533725290 Inexact Rounded
-dqdiv2020 divide -7.682356781384631313156462724425838E+747 -6.60375855512219057281922141809940E+703 -> 1.163330960279556016678379128875149E+44 Inexact Rounded
-dqdiv2021 divide -4511495596596941820863224.274679699 3365395017.263329795449661616090724 -> -1340554548115304.904166888018346299 Inexact Rounded
-dqdiv2022 divide 5.211164127840931517263639608151299 164.5566381356276567012533847006453 -> 0.03166790587655228864478260157156510 Inexact Rounded
-dqdiv2023 divide -49891.2243893458830384077684620383 -47179.9312961860747554053371171530 -> 1.057467084386767291602189656430268 Inexact Rounded
-dqdiv2024 divide 15065477.47214268488077415462413353 4366211.120892953261309529740552596 -> 3.450469309661227984244545513441359 Inexact Rounded
-dqdiv2025 divide 1.575670269440761846109602429612644E+370 653199649324740300.006185482643439 -> 2.412233795700359170904588548041481E+352 Inexact Rounded
-dqdiv2026 divide -2112422311733448924573432192.620145 -80067206.03590693153848215848613406 -> 26383115089417660175.20102646756574 Inexact Rounded
-dqdiv2027 divide -67096536051279809.32218611548721839 -869685412881941081664251990181.1049 -> 7.715035236584805921278566365231168E-14 Inexact Rounded
-dqdiv2028 divide -58612908548962047.21866913425488972 -978449597531.3873665583475633831644 -> 59903.86085991703091236507859837023 Inexact Rounded
-dqdiv2029 divide -133032412010942.1476864138213319796 -7.882059293498670705446528648201359E-428 -> 1.687787506504433064549515681693715E+441 Inexact Rounded
-dqdiv2030 divide 1.83746698338966029492299716360513E+977 -9.897926608979649951672839879128603E+154 -> -1.856416051542212552042390218062458E+822 Inexact Rounded
-dqdiv2031 divide -113742475841399236307128962.1507063 8298602.203049834732657567965262989 -> -13706221006665137826.16557393919929 Inexact Rounded
-dqdiv2032 divide 196.4787574650754152995941808331862 929.6553388472318094427422117172394 -> 0.2113458066176526651006917922814018 Inexact Rounded
-dqdiv2033 divide 71931221465.43867996282803628130350 3838685934206426257090718.402248853 -> 1.873850132527423413607199513324021E-14 Inexact Rounded
-dqdiv2034 divide 488.4282502289651653783596246312885 -80.68940956806634280078706577953188 -> -6.053189047280693318844801899473272 Inexact Rounded
-dqdiv2035 divide 9.001764344963921754981762913247394E-162 -8.585540973667205753734967645386919E-729 -> -1.048479574271827326396012573232934E+567 Inexact Rounded
-dqdiv2036 divide -7.404133959409894743706402857145471E-828 -51.38159929460289711134684843086265 -> 1.441008855516029461032061785219773E-829 Inexact Rounded
-dqdiv2037 divide 2.967520235574419794048994436040717E-613 -6252513855.91394894949879262731889 -> -4.746123405656409127572998751885338E-623 Inexact Rounded
-dqdiv2038 divide -18826852654824040505.83920366765051 -6336924877942437992590557460147340 -> 2.970976146546494669807886278519194E-15 Inexact Rounded
-dqdiv2039 divide -8.101406784809197604949584001735949E+561 4.823300306948942821076681658771635E+361 -> -1.679639721610839204738445747238987E+200 Inexact Rounded
-dqdiv2040 divide -6.11981977773094052331062585191723E+295 1.507610253755339328302779005586534E+238 -> -4.059285058911577244044418416044763E+57 Inexact Rounded
-dqdiv2041 divide 6.472638850046815880599220534274055E-596 -4.475233712083047516933911786159972 -> -1.446324207062261745520496475778879E-596 Inexact Rounded
-dqdiv2042 divide -84438593330.71277839631144509397112 -586684596204401664208947.4054879633 -> 1.439250218550041228759983937772504E-13 Inexact Rounded
-dqdiv2043 divide 9.354533233294022616695815656704369E-24 405.500390626135304252144163591746 -> 2.306911028827774549740571229736198E-26 Inexact Rounded
-dqdiv2044 divide 985606423350210.7374876650149957881 -36811563697.41925681866694859828794 -> -26774.36990864119445335813354717711 Inexact Rounded
-dqdiv2045 divide -8.187280774177715706278002247766311E-123 -38784124393.91212870828430001300068 -> 2.110987653356139147357240727794365E-133 Inexact Rounded
-dqdiv2046 divide -4.612203126350070903459245798371657E+912 7.971562182727956290901984736800519E+64 -> -5.785820922708683237098826662769748E+847 Inexact Rounded
-dqdiv2047 divide 4.661015909421485298247928967977089E+888 -6.360911253323922338737311563845581E+388 -> -7.327591478321365980156654539638836E+499 Inexact Rounded
-dqdiv2048 divide 9156078172903.257500003260710833030 7.189796653262147139071634237964074E-90 -> 1.273482215766000994365201545096026E+102 Inexact Rounded
-dqdiv2049 divide -1.710722303327476586373477781276586E-311 -3167561628260156837329323.729380695 -> 5.400754599578613984875752958645655E-336 Inexact Rounded
-dqdiv2050 divide -4.647935210881806238321616345413021E-878 209388.5431867744648177308460639582 -> -2.219765771394593733140494297388140E-883 Inexact Rounded
-dqdiv2051 divide 5958.694728395760992719084781582700 4.541510156564315632536353171846096E-746 -> 1.312051393253638664947852693005480E+749 Inexact Rounded
-dqdiv2052 divide -7.935732544649702175256699886872093E-489 -7.433329073664793138998765647467971E+360 -> 1.067587949626076917672271619664656E-849 Inexact Rounded
-dqdiv2053 divide -2746650864601157.863589959939901350 7.016684945507647528907184694359598E+548 -> -3.914456593009309529351254950429932E-534 Inexact Rounded
-dqdiv2054 divide 3605149408631197365447953.994569178 -75614025825649082.78264864428237833 -> -47678315.88472693507060063188020532 Inexact Rounded
-dqdiv2055 divide 788194320921798404906375214.196349 -6.222718148433247384932573401976337E-418 -> -1.266639918634671803982222244977287E+444 Inexact Rounded
-dqdiv2056 divide 5620722730534752.758208943447603211 6.843552841168538319123000917657759E-139 -> 8.213164800485434666629970443739554E+153 Inexact Rounded
-dqdiv2057 divide 7304534676713703938102.403949019402 -576169.3685010935108153023803590835 -> -12677756014201995.31969237144394772 Inexact Rounded
-dqdiv2058 divide 8067918762.134621639254916786945547 -8.774771480055536009105596163864758E+954 -> -9.194448858836332156766764605125245E-946 Inexact Rounded
-dqdiv2059 divide 8.702093454123046507578256899537563E-324 -5.875399733016018404580201176576293E-401 -> -1.481106622452052581470443526957335E+77 Inexact Rounded
-dqdiv2060 divide -41426.01662518451861386352415092356 90.00146621684478300510769802013464 -> -460.2815750287318692732067709176200 Inexact Rounded
-
--- random divide tests with result near 1
-dqdiv4001 divide 2003100352770753969878925664524900 2003100352770753969878925664497824 -> 1.000000000000000000000000000013517 Inexact Rounded
-dqdiv4002 divide 4817785793916490652579552318371645 4817785793916490652579552318362097 -> 1.000000000000000000000000000001982 Inexact Rounded
-dqdiv4003 divide 8299187410920067325648068439560282 8299187410920067325648068439591159 -> 0.9999999999999999999999999999962795 Inexact Rounded
-dqdiv4004 divide 5641088455897407044544461785365899 5641088455897407044544461785389965 -> 0.9999999999999999999999999999957338 Inexact Rounded
-dqdiv4005 divide 5752274694706545359326361313490424 5752274694706545359326361313502723 -> 0.9999999999999999999999999999978619 Inexact Rounded
-dqdiv4006 divide 6762079477373670594829319346099665 6762079477373670594829319346132579 -> 0.9999999999999999999999999999951326 Inexact Rounded
-dqdiv4007 divide 7286425153691890341633023222602916 7286425153691890341633023222606556 -> 0.9999999999999999999999999999995004 Inexact Rounded
-dqdiv4008 divide 9481233991901305727648306421946655 9481233991901305727648306421919124 -> 1.000000000000000000000000000002904 Inexact Rounded
-dqdiv4009 divide 4282053941893951742029444065614311 4282053941893951742029444065583077 -> 1.000000000000000000000000000007294 Inexact Rounded
-dqdiv4010 divide 626888225441250639741781850338695 626888225441250639741781850327299 -> 1.000000000000000000000000000018179 Inexact Rounded
-dqdiv4011 divide 3860973649222028009456598604468547 3860973649222028009456598604476849 -> 0.9999999999999999999999999999978498 Inexact Rounded
-dqdiv4012 divide 4753157080127468127908060607821839 4753157080127468127908060607788379 -> 1.000000000000000000000000000007040 Inexact Rounded
-dqdiv4013 divide 552448546203754062805706277880419 552448546203754062805706277881903 -> 0.9999999999999999999999999999973138 Inexact Rounded
-dqdiv4014 divide 8405954527952158455323713728917395 8405954527952158455323713728933866 -> 0.9999999999999999999999999999980406 Inexact Rounded
-dqdiv4015 divide 7554096502235321142555802238016116 7554096502235321142555802238026546 -> 0.9999999999999999999999999999986193 Inexact Rounded
-dqdiv4016 divide 4053257674127518606871054934746782 4053257674127518606871054934767355 -> 0.9999999999999999999999999999949243 Inexact Rounded
-dqdiv4017 divide 7112419420755090454716888844011582 7112419420755090454716888844038105 -> 0.9999999999999999999999999999962709 Inexact Rounded
-dqdiv4018 divide 3132302137520072728164549730911846 3132302137520072728164549730908416 -> 1.000000000000000000000000000001095 Inexact Rounded
-dqdiv4019 divide 4788374045841416355706715048161013 4788374045841416355706715048190077 -> 0.9999999999999999999999999999939303 Inexact Rounded
-dqdiv4020 divide 9466021636047630218238075099510597 9466021636047630218238075099484053 -> 1.000000000000000000000000000002804 Inexact Rounded
-dqdiv4021 divide 912742745646765625597399692138650 912742745646765625597399692139042 -> 0.9999999999999999999999999999995705 Inexact Rounded
-dqdiv4022 divide 9508402742933643208806264897188504 9508402742933643208806264897195973 -> 0.9999999999999999999999999999992145 Inexact Rounded
-dqdiv4023 divide 1186956795727233704962361914360895 1186956795727233704962361914329577 -> 1.000000000000000000000000000026385 Inexact Rounded
-dqdiv4024 divide 5972210268839014812696916170967938 5972210268839014812696916170954974 -> 1.000000000000000000000000000002171 Inexact Rounded
-dqdiv4025 divide 2303801625521619930894460139793140 2303801625521619930894460139799643 -> 0.9999999999999999999999999999971773 Inexact Rounded
-dqdiv4026 divide 6022231560002898264777393473966595 6022231560002898264777393473947198 -> 1.000000000000000000000000000003221 Inexact Rounded
-dqdiv4027 divide 8426148335801396199969346032210893 8426148335801396199969346032203179 -> 1.000000000000000000000000000000915 Inexact Rounded
-dqdiv4028 divide 8812278947028784637382847098411749 8812278947028784637382847098385317 -> 1.000000000000000000000000000002999 Inexact Rounded
-dqdiv4029 divide 8145282002348367383264197170116146 8145282002348367383264197170083988 -> 1.000000000000000000000000000003948 Inexact Rounded
-dqdiv4030 divide 6821577571876840153123510107387026 6821577571876840153123510107418008 -> 0.9999999999999999999999999999954582 Inexact Rounded
-dqdiv4031 divide 9018555319518966970480565482023720 9018555319518966970480565482013346 -> 1.000000000000000000000000000001150 Inexact Rounded
-dqdiv4032 divide 4602155712998228449640717252788864 4602155712998228449640717252818502 -> 0.9999999999999999999999999999935600 Inexact Rounded
-dqdiv4033 divide 6675607481522785614506828292264472 6675607481522785614506828292277100 -> 0.9999999999999999999999999999981083 Inexact Rounded
-dqdiv4034 divide 4015881516871833897766945836264472 4015881516871833897766945836262645 -> 1.000000000000000000000000000000455 Inexact Rounded
-dqdiv4035 divide 1415580205933411837595459716910365 1415580205933411837595459716880139 -> 1.000000000000000000000000000021352 Inexact Rounded
-dqdiv4036 divide 9432968297069542816752035276361552 9432968297069542816752035276353054 -> 1.000000000000000000000000000000901 Inexact Rounded
-dqdiv4037 divide 4799319591303848500532766682140658 4799319591303848500532766682172655 -> 0.9999999999999999999999999999933330 Inexact Rounded
-dqdiv4038 divide 316854270732839529790584284987472 316854270732839529790584285004832 -> 0.9999999999999999999999999999452114 Inexact Rounded
-dqdiv4039 divide 3598981300592490427826027975697415 3598981300592490427826027975686712 -> 1.000000000000000000000000000002974 Inexact Rounded
-dqdiv4040 divide 1664315435694461371155800682196520 1664315435694461371155800682195617 -> 1.000000000000000000000000000000543 Inexact Rounded
-dqdiv4041 divide 1680872316531128890102855316510581 1680872316531128890102855316495545 -> 1.000000000000000000000000000008945 Inexact Rounded
-dqdiv4042 divide 9881274879566405475755499281644730 9881274879566405475755499281615743 -> 1.000000000000000000000000000002934 Inexact Rounded
-dqdiv4043 divide 4737225957717466960447204232279216 4737225957717466960447204232277452 -> 1.000000000000000000000000000000372 Inexact Rounded
-dqdiv4044 divide 2482097379414867061213319346418288 2482097379414867061213319346387936 -> 1.000000000000000000000000000012228 Inexact Rounded
-dqdiv4045 divide 7406977595233762723576434122161868 7406977595233762723576434122189042 -> 0.9999999999999999999999999999963313 Inexact Rounded
-dqdiv4046 divide 228782057757566047086593281773577 228782057757566047086593281769727 -> 1.000000000000000000000000000016828 Inexact Rounded
-dqdiv4047 divide 2956594270240579648823270540367653 2956594270240579648823270540368556 -> 0.9999999999999999999999999999996946 Inexact Rounded
-dqdiv4048 divide 6326964098897620620534136767634340 6326964098897620620534136767619339 -> 1.000000000000000000000000000002371 Inexact Rounded
-dqdiv4049 divide 414586440456590215247002678327800 414586440456590215247002678316922 -> 1.000000000000000000000000000026238 Inexact Rounded
-dqdiv4050 divide 7364552208570039386220505636779125 7364552208570039386220505636803548 -> 0.9999999999999999999999999999966837 Inexact Rounded
-dqdiv4051 divide 5626266749902369710022824950590056 5626266749902369710022824950591008 -> 0.9999999999999999999999999999998308 Inexact Rounded
-dqdiv4052 divide 4863278293916197454987481343460484 4863278293916197454987481343442522 -> 1.000000000000000000000000000003693 Inexact Rounded
-dqdiv4053 divide 1170713582030637359713249796835483 1170713582030637359713249796823345 -> 1.000000000000000000000000000010368 Inexact Rounded
-dqdiv4054 divide 9838062494725965667776326556052931 9838062494725965667776326556061002 -> 0.9999999999999999999999999999991796 Inexact Rounded
-dqdiv4055 divide 4071388731298861093005687091498922 4071388731298861093005687091498278 -> 1.000000000000000000000000000000158 Inexact Rounded
-dqdiv4056 divide 8753155722324706795855038590272526 8753155722324706795855038590276656 -> 0.9999999999999999999999999999995282 Inexact Rounded
-dqdiv4057 divide 4399941911533273418844742658240485 4399941911533273418844742658219891 -> 1.000000000000000000000000000004681 Inexact Rounded
-dqdiv4058 divide 4127884159949503677776430620050269 4127884159949503677776430620026091 -> 1.000000000000000000000000000005857 Inexact Rounded
-dqdiv4059 divide 5536160822360800067042528317438808 5536160822360800067042528317450687 -> 0.9999999999999999999999999999978543 Inexact Rounded
-dqdiv4060 divide 3973234998468664936671088237710246 3973234998468664936671088237741886 -> 0.9999999999999999999999999999920367 Inexact Rounded
-dqdiv4061 divide 9824855935638263593410444142327358 9824855935638263593410444142328576 -> 0.9999999999999999999999999999998760 Inexact Rounded
-dqdiv4062 divide 5917078517340218131867327300814867 5917078517340218131867327300788701 -> 1.000000000000000000000000000004422 Inexact Rounded
-dqdiv4063 divide 4354236601830544882286139612521362 4354236601830544882286139612543223 -> 0.9999999999999999999999999999949794 Inexact Rounded
-dqdiv4064 divide 8058474772375259017342110013891294 8058474772375259017342110013906792 -> 0.9999999999999999999999999999980768 Inexact Rounded
-dqdiv4065 divide 5519604020981748170517093746166328 5519604020981748170517093746181763 -> 0.9999999999999999999999999999972036 Inexact Rounded
-dqdiv4066 divide 1502130966879805458831323782443139 1502130966879805458831323782412213 -> 1.000000000000000000000000000020588 Inexact Rounded
-dqdiv4067 divide 562795633719481212915159787980270 562795633719481212915159788007066 -> 0.9999999999999999999999999999523877 Inexact Rounded
-dqdiv4068 divide 6584743324494664273941281557268878 6584743324494664273941281557258945 -> 1.000000000000000000000000000001508 Inexact Rounded
-dqdiv4069 divide 3632000327285743997976431109416500 3632000327285743997976431109408107 -> 1.000000000000000000000000000002311 Inexact Rounded
-dqdiv4070 divide 1145827237315430089388953838561450 1145827237315430089388953838527332 -> 1.000000000000000000000000000029776 Inexact Rounded
-dqdiv4071 divide 8874431010357691869725372317350380 8874431010357691869725372317316472 -> 1.000000000000000000000000000003821 Inexact Rounded
-dqdiv4072 divide 992948718902804648119753141202196 992948718902804648119753141235222 -> 0.9999999999999999999999999999667395 Inexact Rounded
-dqdiv4073 divide 2522735183374218505142417265439989 2522735183374218505142417265453779 -> 0.9999999999999999999999999999945337 Inexact Rounded
-dqdiv4074 divide 2668419161912936508006872303501052 2668419161912936508006872303471036 -> 1.000000000000000000000000000011249 Inexact Rounded
-dqdiv4075 divide 3036169085665186712590941111775092 3036169085665186712590941111808846 -> 0.9999999999999999999999999999888827 Inexact Rounded
-dqdiv4076 divide 9441634604917231638508898934006147 9441634604917231638508898934000288 -> 1.000000000000000000000000000000621 Inexact Rounded
-dqdiv4077 divide 2677301353164377091111458811839190 2677301353164377091111458811867722 -> 0.9999999999999999999999999999893430 Inexact Rounded
-dqdiv4078 divide 6844979203112066166583765857171426 6844979203112066166583765857189682 -> 0.9999999999999999999999999999973329 Inexact Rounded
-dqdiv4079 divide 2220337435141796724323783960231661 2220337435141796724323783960208778 -> 1.000000000000000000000000000010306 Inexact Rounded
-dqdiv4080 divide 6447424700019783931569996989561380 6447424700019783931569996989572454 -> 0.9999999999999999999999999999982824 Inexact Rounded
-dqdiv4081 divide 7512856762696607119847092195587180 7512856762696607119847092195557346 -> 1.000000000000000000000000000003971 Inexact Rounded
-dqdiv4082 divide 7395261981193960399087819077237482 7395261981193960399087819077242487 -> 0.9999999999999999999999999999993232 Inexact Rounded
-dqdiv4083 divide 2253442467682584035792724884376735 2253442467682584035792724884407178 -> 0.9999999999999999999999999999864904 Inexact Rounded
-dqdiv4084 divide 8153138680300213135577336466190997 8153138680300213135577336466220607 -> 0.9999999999999999999999999999963683 Inexact Rounded
-dqdiv4085 divide 4668731252254148074041022681801390 4668731252254148074041022681778101 -> 1.000000000000000000000000000004988 Inexact Rounded
-dqdiv4086 divide 6078404557993669696040425501815056 6078404557993669696040425501797612 -> 1.000000000000000000000000000002870 Inexact Rounded
-dqdiv4087 divide 2306352359874261623223356878316278 2306352359874261623223356878335612 -> 0.9999999999999999999999999999916171 Inexact Rounded
-dqdiv4088 divide 3264842186668480362900909564091908 3264842186668480362900909564058658 -> 1.000000000000000000000000000010184 Inexact Rounded
-dqdiv4089 divide 6971985047279636878957959608612204 6971985047279636878957959608615088 -> 0.9999999999999999999999999999995863 Inexact Rounded
-dqdiv4090 divide 5262810889952721235466445973816257 5262810889952721235466445973783077 -> 1.000000000000000000000000000006305 Inexact Rounded
-dqdiv4091 divide 7947944731035267178548357070080288 7947944731035267178548357070061339 -> 1.000000000000000000000000000002384 Inexact Rounded
-dqdiv4092 divide 5071808908395375108383035800443229 5071808908395375108383035800412429 -> 1.000000000000000000000000000006073 Inexact Rounded
-dqdiv4093 divide 2043146542084503655511507209262969 2043146542084503655511507209249263 -> 1.000000000000000000000000000006708 Inexact Rounded
-dqdiv4094 divide 4097632735384534181661959731264802 4097632735384534181661959731234499 -> 1.000000000000000000000000000007395 Inexact Rounded
-dqdiv4095 divide 3061477642831387489729464587044430 3061477642831387489729464587059452 -> 0.9999999999999999999999999999950932 Inexact Rounded
-dqdiv4096 divide 3429854941039776159498802936252638 3429854941039776159498802936246415 -> 1.000000000000000000000000000001814 Inexact Rounded
-dqdiv4097 divide 4874324979578599700024133278284545 4874324979578599700024133278262131 -> 1.000000000000000000000000000004598 Inexact Rounded
-dqdiv4098 divide 5701652369691833541455978515820882 5701652369691833541455978515834854 -> 0.9999999999999999999999999999975495 Inexact Rounded
-dqdiv4099 divide 2928205728402945266953255632343113 2928205728402945266953255632373794 -> 0.9999999999999999999999999999895223 Inexact Rounded
-
--- Null tests
-dqdiv9998 divide 10 # -> NaN Invalid_operation
-dqdiv9999 divide # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqDivide.decTest -- decQuad division --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqdiv001 divide 1 1 -> 1
+dqdiv002 divide 2 1 -> 2
+dqdiv003 divide 1 2 -> 0.5
+dqdiv004 divide 2 2 -> 1
+dqdiv005 divide 0 1 -> 0
+dqdiv006 divide 0 2 -> 0
+dqdiv007 divide 1 3 -> 0.3333333333333333333333333333333333 Inexact Rounded
+dqdiv008 divide 2 3 -> 0.6666666666666666666666666666666667 Inexact Rounded
+dqdiv009 divide 3 3 -> 1
+
+dqdiv010 divide 2.4 1 -> 2.4
+dqdiv011 divide 2.4 -1 -> -2.4
+dqdiv012 divide -2.4 1 -> -2.4
+dqdiv013 divide -2.4 -1 -> 2.4
+dqdiv014 divide 2.40 1 -> 2.40
+dqdiv015 divide 2.400 1 -> 2.400
+dqdiv016 divide 2.4 2 -> 1.2
+dqdiv017 divide 2.400 2 -> 1.200
+dqdiv018 divide 2. 2 -> 1
+dqdiv019 divide 20 20 -> 1
+
+dqdiv020 divide 187 187 -> 1
+dqdiv021 divide 5 2 -> 2.5
+dqdiv022 divide 50 20 -> 2.5
+dqdiv023 divide 500 200 -> 2.5
+dqdiv024 divide 50.0 20.0 -> 2.5
+dqdiv025 divide 5.00 2.00 -> 2.5
+dqdiv026 divide 5 2.0 -> 2.5
+dqdiv027 divide 5 2.000 -> 2.5
+dqdiv028 divide 5 0.20 -> 25
+dqdiv029 divide 5 0.200 -> 25
+dqdiv030 divide 10 1 -> 10
+dqdiv031 divide 100 1 -> 100
+dqdiv032 divide 1000 1 -> 1000
+dqdiv033 divide 1000 100 -> 10
+
+dqdiv035 divide 1 2 -> 0.5
+dqdiv036 divide 1 4 -> 0.25
+dqdiv037 divide 1 8 -> 0.125
+dqdiv038 divide 1 16 -> 0.0625
+dqdiv039 divide 1 32 -> 0.03125
+dqdiv040 divide 1 64 -> 0.015625
+dqdiv041 divide 1 -2 -> -0.5
+dqdiv042 divide 1 -4 -> -0.25
+dqdiv043 divide 1 -8 -> -0.125
+dqdiv044 divide 1 -16 -> -0.0625
+dqdiv045 divide 1 -32 -> -0.03125
+dqdiv046 divide 1 -64 -> -0.015625
+dqdiv047 divide -1 2 -> -0.5
+dqdiv048 divide -1 4 -> -0.25
+dqdiv049 divide -1 8 -> -0.125
+dqdiv050 divide -1 16 -> -0.0625
+dqdiv051 divide -1 32 -> -0.03125
+dqdiv052 divide -1 64 -> -0.015625
+dqdiv053 divide -1 -2 -> 0.5
+dqdiv054 divide -1 -4 -> 0.25
+dqdiv055 divide -1 -8 -> 0.125
+dqdiv056 divide -1 -16 -> 0.0625
+dqdiv057 divide -1 -32 -> 0.03125
+dqdiv058 divide -1 -64 -> 0.015625
+
+-- bcdTime
+dqdiv060 divide 1 7 -> 0.1428571428571428571428571428571429 Inexact Rounded
+dqdiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717123193907511985359 Inexact Rounded
+
+-- 1234567890123456
+dqdiv067 divide 9999999999999999999999999999999999 1 -> 9999999999999999999999999999999999
+dqdiv068 divide 999999999999999999999999999999999 1 -> 999999999999999999999999999999999
+dqdiv069 divide 99999999999999999999999999999999 1 -> 99999999999999999999999999999999
+dqdiv070 divide 99999999999999999 1 -> 99999999999999999
+dqdiv071 divide 9999999999999999 1 -> 9999999999999999
+dqdiv072 divide 999999999999999 1 -> 999999999999999
+dqdiv073 divide 99999999999999 1 -> 99999999999999
+dqdiv074 divide 9999999999999 1 -> 9999999999999
+dqdiv075 divide 999999999999 1 -> 999999999999
+dqdiv076 divide 99999999999 1 -> 99999999999
+dqdiv077 divide 9999999999 1 -> 9999999999
+dqdiv078 divide 999999999 1 -> 999999999
+dqdiv079 divide 99999999 1 -> 99999999
+dqdiv080 divide 9999999 1 -> 9999999
+dqdiv081 divide 999999 1 -> 999999
+dqdiv082 divide 99999 1 -> 99999
+dqdiv083 divide 9999 1 -> 9999
+dqdiv084 divide 999 1 -> 999
+dqdiv085 divide 99 1 -> 99
+dqdiv086 divide 9 1 -> 9
+
+dqdiv090 divide 0. 1 -> 0
+dqdiv091 divide .0 1 -> 0.0
+dqdiv092 divide 0.00 1 -> 0.00
+dqdiv093 divide 0.00E+9 1 -> 0E+7
+dqdiv094 divide 0.0000E-50 1 -> 0E-54
+
+dqdiv095 divide 1 1E-8 -> 1E+8
+dqdiv096 divide 1 1E-9 -> 1E+9
+dqdiv097 divide 1 1E-10 -> 1E+10
+dqdiv098 divide 1 1E-11 -> 1E+11
+dqdiv099 divide 1 1E-12 -> 1E+12
+
+dqdiv100 divide 1 1 -> 1
+dqdiv101 divide 1 2 -> 0.5
+dqdiv102 divide 1 3 -> 0.3333333333333333333333333333333333 Inexact Rounded
+dqdiv103 divide 1 4 -> 0.25
+dqdiv104 divide 1 5 -> 0.2
+dqdiv105 divide 1 6 -> 0.1666666666666666666666666666666667 Inexact Rounded
+dqdiv106 divide 1 7 -> 0.1428571428571428571428571428571429 Inexact Rounded
+dqdiv107 divide 1 8 -> 0.125
+dqdiv108 divide 1 9 -> 0.1111111111111111111111111111111111 Inexact Rounded
+dqdiv109 divide 1 10 -> 0.1
+dqdiv110 divide 1 1 -> 1
+dqdiv111 divide 2 1 -> 2
+dqdiv112 divide 3 1 -> 3
+dqdiv113 divide 4 1 -> 4
+dqdiv114 divide 5 1 -> 5
+dqdiv115 divide 6 1 -> 6
+dqdiv116 divide 7 1 -> 7
+dqdiv117 divide 8 1 -> 8
+dqdiv118 divide 9 1 -> 9
+dqdiv119 divide 10 1 -> 10
+
+dqdiv120 divide 3E+1 0.001 -> 3E+4
+dqdiv121 divide 2.200 2 -> 1.100
+
+dqdiv130 divide 12345 4.999 -> 2469.493898779755951190238047609522 Inexact Rounded
+dqdiv131 divide 12345 4.99 -> 2473.947895791583166332665330661323 Inexact Rounded
+dqdiv132 divide 12345 4.9 -> 2519.387755102040816326530612244898 Inexact Rounded
+dqdiv133 divide 12345 5 -> 2469
+dqdiv134 divide 12345 5.1 -> 2420.588235294117647058823529411765 Inexact Rounded
+dqdiv135 divide 12345 5.01 -> 2464.071856287425149700598802395210 Inexact Rounded
+dqdiv136 divide 12345 5.001 -> 2468.506298740251949610077984403119 Inexact Rounded
+
+-- test possibly imprecise results
+dqdiv220 divide 391 597 -> 0.6549413735343383584589614740368509 Inexact Rounded
+dqdiv221 divide 391 -597 -> -0.6549413735343383584589614740368509 Inexact Rounded
+dqdiv222 divide -391 597 -> -0.6549413735343383584589614740368509 Inexact Rounded
+dqdiv223 divide -391 -597 -> 0.6549413735343383584589614740368509 Inexact Rounded
+
+-- test some cases that are close to exponent overflow
+dqdiv270 divide 1 1e6144 -> 1E-6144 Subnormal
+dqdiv271 divide 1 0.9e6144 -> 1.11111111111111111111111111111111E-6144 Rounded Inexact Subnormal Underflow
+dqdiv272 divide 1 0.99e6144 -> 1.01010101010101010101010101010101E-6144 Rounded Inexact Subnormal Underflow
+dqdiv273 divide 1 0.9999999999999999e6144 -> 1.00000000000000010000000000000001E-6144 Rounded Inexact Subnormal Underflow
+dqdiv274 divide 9e6144 1 -> 9.000000000000000000000000000000000E+6144 Clamped
+dqdiv275 divide 9.9e6144 1 -> 9.900000000000000000000000000000000E+6144 Clamped
+dqdiv276 divide 9.99e6144 1 -> 9.990000000000000000000000000000000E+6144 Clamped
+dqdiv277 divide 9.999999999999999e6144 1 -> 9.999999999999999000000000000000000E+6144 Clamped
+
+dqdiv278 divide 1 0.9999999999999999999999999999999999e6144 -> 1.00000000000000000000000000000000E-6144 Rounded Inexact Subnormal Underflow
+dqdiv279 divide 9.999999999999999999999999999999999e6144 1 -> 9.999999999999999999999999999999999E+6144
+
+-- Divide into 0 tests
+dqdiv301 divide 0 7 -> 0
+dqdiv302 divide 0 7E-5 -> 0E+5
+dqdiv303 divide 0 7E-1 -> 0E+1
+dqdiv304 divide 0 7E+1 -> 0.0
+dqdiv305 divide 0 7E+5 -> 0.00000
+dqdiv306 divide 0 7E+6 -> 0.000000
+dqdiv307 divide 0 7E+7 -> 0E-7
+dqdiv308 divide 0 70E-5 -> 0E+5
+dqdiv309 divide 0 70E-1 -> 0E+1
+dqdiv310 divide 0 70E+0 -> 0
+dqdiv311 divide 0 70E+1 -> 0.0
+dqdiv312 divide 0 70E+5 -> 0.00000
+dqdiv313 divide 0 70E+6 -> 0.000000
+dqdiv314 divide 0 70E+7 -> 0E-7
+dqdiv315 divide 0 700E-5 -> 0E+5
+dqdiv316 divide 0 700E-1 -> 0E+1
+dqdiv317 divide 0 700E+0 -> 0
+dqdiv318 divide 0 700E+1 -> 0.0
+dqdiv319 divide 0 700E+5 -> 0.00000
+dqdiv320 divide 0 700E+6 -> 0.000000
+dqdiv321 divide 0 700E+7 -> 0E-7
+dqdiv322 divide 0 700E+77 -> 0E-77
+
+dqdiv331 divide 0E-3 7E-5 -> 0E+2
+dqdiv332 divide 0E-3 7E-1 -> 0.00
+dqdiv333 divide 0E-3 7E+1 -> 0.0000
+dqdiv334 divide 0E-3 7E+5 -> 0E-8
+dqdiv335 divide 0E-1 7E-5 -> 0E+4
+dqdiv336 divide 0E-1 7E-1 -> 0
+dqdiv337 divide 0E-1 7E+1 -> 0.00
+dqdiv338 divide 0E-1 7E+5 -> 0.000000
+dqdiv339 divide 0E+1 7E-5 -> 0E+6
+dqdiv340 divide 0E+1 7E-1 -> 0E+2
+dqdiv341 divide 0E+1 7E+1 -> 0
+dqdiv342 divide 0E+1 7E+5 -> 0.0000
+dqdiv343 divide 0E+3 7E-5 -> 0E+8
+dqdiv344 divide 0E+3 7E-1 -> 0E+4
+dqdiv345 divide 0E+3 7E+1 -> 0E+2
+dqdiv346 divide 0E+3 7E+5 -> 0.00
+
+-- These were 'input rounding'
+dqdiv441 divide 12345678000 1 -> 12345678000
+dqdiv442 divide 1 12345678000 -> 8.100000664200054464404466081166219E-11 Inexact Rounded
+dqdiv443 divide 1234567800 1 -> 1234567800
+dqdiv444 divide 1 1234567800 -> 8.100000664200054464404466081166219E-10 Inexact Rounded
+dqdiv445 divide 1234567890 1 -> 1234567890
+dqdiv446 divide 1 1234567890 -> 8.100000073710000670761006103925156E-10 Inexact Rounded
+dqdiv447 divide 1234567891 1 -> 1234567891
+dqdiv448 divide 1 1234567891 -> 8.100000067149000556665214614754629E-10 Inexact Rounded
+dqdiv449 divide 12345678901 1 -> 12345678901
+dqdiv450 divide 1 12345678901 -> 8.100000073053900658873130042376760E-11 Inexact Rounded
+dqdiv451 divide 1234567896 1 -> 1234567896
+dqdiv452 divide 1 1234567896 -> 8.100000034344000145618560617422697E-10 Inexact Rounded
+
+-- high-lows
+dqdiv453 divide 1e+1 1 -> 1E+1
+dqdiv454 divide 1e+1 1.0 -> 1E+1
+dqdiv455 divide 1e+1 1.00 -> 1E+1
+dqdiv456 divide 1e+2 2 -> 5E+1
+dqdiv457 divide 1e+2 2.0 -> 5E+1
+dqdiv458 divide 1e+2 2.00 -> 5E+1
+
+-- some from IEEE discussions
+dqdiv460 divide 3e0 2e0 -> 1.5
+dqdiv461 divide 30e-1 2e0 -> 1.5
+dqdiv462 divide 300e-2 2e0 -> 1.50
+dqdiv464 divide 3000e-3 2e0 -> 1.500
+dqdiv465 divide 3e0 20e-1 -> 1.5
+dqdiv466 divide 30e-1 20e-1 -> 1.5
+dqdiv467 divide 300e-2 20e-1 -> 1.5
+dqdiv468 divide 3000e-3 20e-1 -> 1.50
+dqdiv469 divide 3e0 200e-2 -> 1.5
+dqdiv470 divide 30e-1 200e-2 -> 1.5
+dqdiv471 divide 300e-2 200e-2 -> 1.5
+dqdiv472 divide 3000e-3 200e-2 -> 1.5
+dqdiv473 divide 3e0 2000e-3 -> 1.5
+dqdiv474 divide 30e-1 2000e-3 -> 1.5
+dqdiv475 divide 300e-2 2000e-3 -> 1.5
+dqdiv476 divide 3000e-3 2000e-3 -> 1.5
+
+-- some reciprocals
+dqdiv480 divide 1 1.0E+33 -> 1E-33
+dqdiv481 divide 1 10E+33 -> 1E-34
+dqdiv482 divide 1 1.0E-33 -> 1E+33
+dqdiv483 divide 1 10E-33 -> 1E+32
+
+-- RMS discussion table
+dqdiv484 divide 0e5 1e3 -> 0E+2
+dqdiv485 divide 0e5 2e3 -> 0E+2
+dqdiv486 divide 0e5 10e2 -> 0E+3
+dqdiv487 divide 0e5 20e2 -> 0E+3
+dqdiv488 divide 0e5 100e1 -> 0E+4
+dqdiv489 divide 0e5 200e1 -> 0E+4
+
+dqdiv491 divide 1e5 1e3 -> 1E+2
+dqdiv492 divide 1e5 2e3 -> 5E+1
+dqdiv493 divide 1e5 10e2 -> 1E+2
+dqdiv494 divide 1e5 20e2 -> 5E+1
+dqdiv495 divide 1e5 100e1 -> 1E+2
+dqdiv496 divide 1e5 200e1 -> 5E+1
+
+-- tryzeros cases
+rounding: half_up
+dqdiv497 divide 0E+6108 1000E-33 -> 0E+6111 Clamped
+dqdiv498 divide 0E-6170 1000E+33 -> 0E-6176 Clamped
+
+rounding: half_up
+
+-- focus on trailing zeros issues
+dqdiv500 divide 1 9.9 -> 0.1010101010101010101010101010101010 Inexact Rounded
+dqdiv501 divide 1 9.09 -> 0.1100110011001100110011001100110011 Inexact Rounded
+dqdiv502 divide 1 9.009 -> 0.1110001110001110001110001110001110 Inexact Rounded
+
+dqdiv511 divide 1 2 -> 0.5
+dqdiv512 divide 1.0 2 -> 0.5
+dqdiv513 divide 1.00 2 -> 0.50
+dqdiv514 divide 1.000 2 -> 0.500
+dqdiv515 divide 1.0000 2 -> 0.5000
+dqdiv516 divide 1.00000 2 -> 0.50000
+dqdiv517 divide 1.000000 2 -> 0.500000
+dqdiv518 divide 1.0000000 2 -> 0.5000000
+dqdiv519 divide 1.00 2.00 -> 0.5
+
+dqdiv521 divide 2 1 -> 2
+dqdiv522 divide 2 1.0 -> 2
+dqdiv523 divide 2 1.00 -> 2
+dqdiv524 divide 2 1.000 -> 2
+dqdiv525 divide 2 1.0000 -> 2
+dqdiv526 divide 2 1.00000 -> 2
+dqdiv527 divide 2 1.000000 -> 2
+dqdiv528 divide 2 1.0000000 -> 2
+dqdiv529 divide 2.00 1.00 -> 2
+
+dqdiv530 divide 2.40 2 -> 1.20
+dqdiv531 divide 2.40 4 -> 0.60
+dqdiv532 divide 2.40 10 -> 0.24
+dqdiv533 divide 2.40 2.0 -> 1.2
+dqdiv534 divide 2.40 4.0 -> 0.6
+dqdiv535 divide 2.40 10.0 -> 0.24
+dqdiv536 divide 2.40 2.00 -> 1.2
+dqdiv537 divide 2.40 4.00 -> 0.6
+dqdiv538 divide 2.40 10.00 -> 0.24
+dqdiv539 divide 0.9 0.1 -> 9
+dqdiv540 divide 0.9 0.01 -> 9E+1
+dqdiv541 divide 0.9 0.001 -> 9E+2
+dqdiv542 divide 5 2 -> 2.5
+dqdiv543 divide 5 2.0 -> 2.5
+dqdiv544 divide 5 2.00 -> 2.5
+dqdiv545 divide 5 20 -> 0.25
+dqdiv546 divide 5 20.0 -> 0.25
+dqdiv547 divide 2.400 2 -> 1.200
+dqdiv548 divide 2.400 2.0 -> 1.20
+dqdiv549 divide 2.400 2.400 -> 1
+
+dqdiv550 divide 240 1 -> 240
+dqdiv551 divide 240 10 -> 24
+dqdiv552 divide 240 100 -> 2.4
+dqdiv553 divide 240 1000 -> 0.24
+dqdiv554 divide 2400 1 -> 2400
+dqdiv555 divide 2400 10 -> 240
+dqdiv556 divide 2400 100 -> 24
+dqdiv557 divide 2400 1000 -> 2.4
+
+-- +ve exponent
+dqdiv600 divide 2.4E+9 2 -> 1.2E+9
+dqdiv601 divide 2.40E+9 2 -> 1.20E+9
+dqdiv602 divide 2.400E+9 2 -> 1.200E+9
+dqdiv603 divide 2.4000E+9 2 -> 1.2000E+9
+dqdiv604 divide 24E+8 2 -> 1.2E+9
+dqdiv605 divide 240E+7 2 -> 1.20E+9
+dqdiv606 divide 2400E+6 2 -> 1.200E+9
+dqdiv607 divide 24000E+5 2 -> 1.2000E+9
+
+-- more zeros, etc.
+dqdiv731 divide 5.00 1E-3 -> 5.00E+3
+dqdiv732 divide 00.00 0.000 -> NaN Division_undefined
+dqdiv733 divide 00.00 0E-3 -> NaN Division_undefined
+dqdiv734 divide 0 -0 -> NaN Division_undefined
+dqdiv735 divide -0 0 -> NaN Division_undefined
+dqdiv736 divide -0 -0 -> NaN Division_undefined
+
+dqdiv741 divide 0 -1 -> -0
+dqdiv742 divide -0 -1 -> 0
+dqdiv743 divide 0 1 -> 0
+dqdiv744 divide -0 1 -> -0
+dqdiv745 divide -1 0 -> -Infinity Division_by_zero
+dqdiv746 divide -1 -0 -> Infinity Division_by_zero
+dqdiv747 divide 1 0 -> Infinity Division_by_zero
+dqdiv748 divide 1 -0 -> -Infinity Division_by_zero
+
+dqdiv751 divide 0.0 -1 -> -0.0
+dqdiv752 divide -0.0 -1 -> 0.0
+dqdiv753 divide 0.0 1 -> 0.0
+dqdiv754 divide -0.0 1 -> -0.0
+dqdiv755 divide -1.0 0 -> -Infinity Division_by_zero
+dqdiv756 divide -1.0 -0 -> Infinity Division_by_zero
+dqdiv757 divide 1.0 0 -> Infinity Division_by_zero
+dqdiv758 divide 1.0 -0 -> -Infinity Division_by_zero
+
+dqdiv761 divide 0 -1.0 -> -0E+1
+dqdiv762 divide -0 -1.0 -> 0E+1
+dqdiv763 divide 0 1.0 -> 0E+1
+dqdiv764 divide -0 1.0 -> -0E+1
+dqdiv765 divide -1 0.0 -> -Infinity Division_by_zero
+dqdiv766 divide -1 -0.0 -> Infinity Division_by_zero
+dqdiv767 divide 1 0.0 -> Infinity Division_by_zero
+dqdiv768 divide 1 -0.0 -> -Infinity Division_by_zero
+
+dqdiv771 divide 0.0 -1.0 -> -0
+dqdiv772 divide -0.0 -1.0 -> 0
+dqdiv773 divide 0.0 1.0 -> 0
+dqdiv774 divide -0.0 1.0 -> -0
+dqdiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
+dqdiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
+dqdiv777 divide 1.0 0.0 -> Infinity Division_by_zero
+dqdiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
+
+-- Specials
+dqdiv780 divide Inf -Inf -> NaN Invalid_operation
+dqdiv781 divide Inf -1000 -> -Infinity
+dqdiv782 divide Inf -1 -> -Infinity
+dqdiv783 divide Inf -0 -> -Infinity
+dqdiv784 divide Inf 0 -> Infinity
+dqdiv785 divide Inf 1 -> Infinity
+dqdiv786 divide Inf 1000 -> Infinity
+dqdiv787 divide Inf Inf -> NaN Invalid_operation
+dqdiv788 divide -1000 Inf -> -0E-6176 Clamped
+dqdiv789 divide -Inf Inf -> NaN Invalid_operation
+dqdiv790 divide -1 Inf -> -0E-6176 Clamped
+dqdiv791 divide -0 Inf -> -0E-6176 Clamped
+dqdiv792 divide 0 Inf -> 0E-6176 Clamped
+dqdiv793 divide 1 Inf -> 0E-6176 Clamped
+dqdiv794 divide 1000 Inf -> 0E-6176 Clamped
+dqdiv795 divide Inf Inf -> NaN Invalid_operation
+
+dqdiv800 divide -Inf -Inf -> NaN Invalid_operation
+dqdiv801 divide -Inf -1000 -> Infinity
+dqdiv802 divide -Inf -1 -> Infinity
+dqdiv803 divide -Inf -0 -> Infinity
+dqdiv804 divide -Inf 0 -> -Infinity
+dqdiv805 divide -Inf 1 -> -Infinity
+dqdiv806 divide -Inf 1000 -> -Infinity
+dqdiv807 divide -Inf Inf -> NaN Invalid_operation
+dqdiv808 divide -1000 Inf -> -0E-6176 Clamped
+dqdiv809 divide -Inf -Inf -> NaN Invalid_operation
+dqdiv810 divide -1 -Inf -> 0E-6176 Clamped
+dqdiv811 divide -0 -Inf -> 0E-6176 Clamped
+dqdiv812 divide 0 -Inf -> -0E-6176 Clamped
+dqdiv813 divide 1 -Inf -> -0E-6176 Clamped
+dqdiv814 divide 1000 -Inf -> -0E-6176 Clamped
+dqdiv815 divide Inf -Inf -> NaN Invalid_operation
+
+dqdiv821 divide NaN -Inf -> NaN
+dqdiv822 divide NaN -1000 -> NaN
+dqdiv823 divide NaN -1 -> NaN
+dqdiv824 divide NaN -0 -> NaN
+dqdiv825 divide NaN 0 -> NaN
+dqdiv826 divide NaN 1 -> NaN
+dqdiv827 divide NaN 1000 -> NaN
+dqdiv828 divide NaN Inf -> NaN
+dqdiv829 divide NaN NaN -> NaN
+dqdiv830 divide -Inf NaN -> NaN
+dqdiv831 divide -1000 NaN -> NaN
+dqdiv832 divide -1 NaN -> NaN
+dqdiv833 divide -0 NaN -> NaN
+dqdiv834 divide 0 NaN -> NaN
+dqdiv835 divide 1 NaN -> NaN
+dqdiv836 divide 1000 NaN -> NaN
+dqdiv837 divide Inf NaN -> NaN
+
+dqdiv841 divide sNaN -Inf -> NaN Invalid_operation
+dqdiv842 divide sNaN -1000 -> NaN Invalid_operation
+dqdiv843 divide sNaN -1 -> NaN Invalid_operation
+dqdiv844 divide sNaN -0 -> NaN Invalid_operation
+dqdiv845 divide sNaN 0 -> NaN Invalid_operation
+dqdiv846 divide sNaN 1 -> NaN Invalid_operation
+dqdiv847 divide sNaN 1000 -> NaN Invalid_operation
+dqdiv848 divide sNaN NaN -> NaN Invalid_operation
+dqdiv849 divide sNaN sNaN -> NaN Invalid_operation
+dqdiv850 divide NaN sNaN -> NaN Invalid_operation
+dqdiv851 divide -Inf sNaN -> NaN Invalid_operation
+dqdiv852 divide -1000 sNaN -> NaN Invalid_operation
+dqdiv853 divide -1 sNaN -> NaN Invalid_operation
+dqdiv854 divide -0 sNaN -> NaN Invalid_operation
+dqdiv855 divide 0 sNaN -> NaN Invalid_operation
+dqdiv856 divide 1 sNaN -> NaN Invalid_operation
+dqdiv857 divide 1000 sNaN -> NaN Invalid_operation
+dqdiv858 divide Inf sNaN -> NaN Invalid_operation
+dqdiv859 divide NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqdiv861 divide NaN9 -Inf -> NaN9
+dqdiv862 divide NaN8 1000 -> NaN8
+dqdiv863 divide NaN7 Inf -> NaN7
+dqdiv864 divide NaN6 NaN5 -> NaN6
+dqdiv865 divide -Inf NaN4 -> NaN4
+dqdiv866 divide -1000 NaN3 -> NaN3
+dqdiv867 divide Inf NaN2 -> NaN2
+
+dqdiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
+dqdiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
+dqdiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
+dqdiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
+dqdiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
+dqdiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
+dqdiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
+dqdiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
+dqdiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
+
+dqdiv881 divide -NaN9 -Inf -> -NaN9
+dqdiv882 divide -NaN8 1000 -> -NaN8
+dqdiv883 divide -NaN7 Inf -> -NaN7
+dqdiv884 divide -NaN6 -NaN5 -> -NaN6
+dqdiv885 divide -Inf -NaN4 -> -NaN4
+dqdiv886 divide -1000 -NaN3 -> -NaN3
+dqdiv887 divide Inf -NaN2 -> -NaN2
+
+dqdiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqdiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
+dqdiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
+dqdiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
+dqdiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+dqdiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
+dqdiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
+dqdiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
+dqdiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- Various flavours of divide by 0
+dqdiv901 divide 0 0 -> NaN Division_undefined
+dqdiv902 divide 0.0E5 0 -> NaN Division_undefined
+dqdiv903 divide 0.000 0 -> NaN Division_undefined
+dqdiv904 divide 0.0001 0 -> Infinity Division_by_zero
+dqdiv905 divide 0.01 0 -> Infinity Division_by_zero
+dqdiv906 divide 0.1 0 -> Infinity Division_by_zero
+dqdiv907 divide 1 0 -> Infinity Division_by_zero
+dqdiv908 divide 1 0.0 -> Infinity Division_by_zero
+dqdiv909 divide 10 0.0 -> Infinity Division_by_zero
+dqdiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
+dqdiv911 divide 1E+100 0 -> Infinity Division_by_zero
+
+dqdiv921 divide -0.0001 0 -> -Infinity Division_by_zero
+dqdiv922 divide -0.01 0 -> -Infinity Division_by_zero
+dqdiv923 divide -0.1 0 -> -Infinity Division_by_zero
+dqdiv924 divide -1 0 -> -Infinity Division_by_zero
+dqdiv925 divide -1 0.0 -> -Infinity Division_by_zero
+dqdiv926 divide -10 0.0 -> -Infinity Division_by_zero
+dqdiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
+dqdiv928 divide -1E+100 0 -> -Infinity Division_by_zero
+
+dqdiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
+dqdiv932 divide 0.01 -0 -> -Infinity Division_by_zero
+dqdiv933 divide 0.1 -0 -> -Infinity Division_by_zero
+dqdiv934 divide 1 -0 -> -Infinity Division_by_zero
+dqdiv935 divide 1 -0.0 -> -Infinity Division_by_zero
+dqdiv936 divide 10 -0.0 -> -Infinity Division_by_zero
+dqdiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
+dqdiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
+
+dqdiv941 divide -0.0001 -0 -> Infinity Division_by_zero
+dqdiv942 divide -0.01 -0 -> Infinity Division_by_zero
+dqdiv943 divide -0.1 -0 -> Infinity Division_by_zero
+dqdiv944 divide -1 -0 -> Infinity Division_by_zero
+dqdiv945 divide -1 -0.0 -> Infinity Division_by_zero
+dqdiv946 divide -10 -0.0 -> Infinity Division_by_zero
+dqdiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
+dqdiv948 divide -1E+100 -0 -> Infinity Division_by_zero
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dqdiv1021 divide 1E0 1E0 -> 1
+dqdiv1022 divide 1E0 2E0 -> 0.5
+dqdiv1023 divide 1E0 3E0 -> 0.3333333333333333333333333333333333 Inexact Rounded
+dqdiv1024 divide 100E-2 1000E-3 -> 1
+dqdiv1025 divide 24E-1 2E0 -> 1.2
+dqdiv1026 divide 2400E-3 2E0 -> 1.200
+dqdiv1027 divide 5E0 2E0 -> 2.5
+dqdiv1028 divide 5E0 20E-1 -> 2.5
+dqdiv1029 divide 5E0 2000E-3 -> 2.5
+dqdiv1030 divide 5E0 2E-1 -> 25
+dqdiv1031 divide 5E0 20E-2 -> 25
+dqdiv1032 divide 480E-2 3E0 -> 1.60
+dqdiv1033 divide 47E-1 2E0 -> 2.35
+
+-- ECMAScript bad examples
+rounding: half_down
+dqdiv1040 divide 5 9 -> 0.5555555555555555555555555555555556 Inexact Rounded
+rounding: half_even
+dqdiv1041 divide 6 11 -> 0.5454545454545454545454545454545455 Inexact Rounded
+
+-- Gyuris example
+dqdiv1050 divide 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 0.9999999999999999999999999999991254 Inexact Rounded
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+dqdiv1751 divide 1e+4277 1e-3311 -> Infinity Overflow Inexact Rounded
+dqdiv1752 divide 1e+4277 -1e-3311 -> -Infinity Overflow Inexact Rounded
+dqdiv1753 divide -1e+4277 1e-3311 -> -Infinity Overflow Inexact Rounded
+dqdiv1754 divide -1e+4277 -1e-3311 -> Infinity Overflow Inexact Rounded
+dqdiv1755 divide 1e-4277 1e+3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1756 divide 1e-4277 -1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1757 divide -1e-4277 1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1758 divide -1e-4277 -1e+3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dqdiv1760 divide 1e-6069 1e+101 -> 1E-6170 Subnormal
+dqdiv1761 divide 1e-6069 1e+102 -> 1E-6171 Subnormal
+dqdiv1762 divide 1e-6069 1e+103 -> 1E-6172 Subnormal
+dqdiv1763 divide 1e-6069 1e+104 -> 1E-6173 Subnormal
+dqdiv1764 divide 1e-6069 1e+105 -> 1E-6174 Subnormal
+dqdiv1765 divide 1e-6069 1e+106 -> 1E-6175 Subnormal
+dqdiv1766 divide 1e-6069 1e+107 -> 1E-6176 Subnormal
+dqdiv1767 divide 1e-6069 1e+108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1768 divide 1e-6069 1e+109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1769 divide 1e-6069 1e+110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+dqdiv1770 divide 1e+40 1e-6101 -> 1.000000000000000000000000000000E+6141 Clamped
+dqdiv1771 divide 1e+40 1e-6102 -> 1.0000000000000000000000000000000E+6142 Clamped
+dqdiv1772 divide 1e+40 1e-6103 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqdiv1773 divide 1e+40 1e-6104 -> 1.000000000000000000000000000000000E+6144 Clamped
+dqdiv1774 divide 1e+40 1e-6105 -> Infinity Overflow Inexact Rounded
+dqdiv1775 divide 1e+40 1e-6106 -> Infinity Overflow Inexact Rounded
+dqdiv1776 divide 1e+40 1e-6107 -> Infinity Overflow Inexact Rounded
+dqdiv1777 divide 1e+40 1e-6108 -> Infinity Overflow Inexact Rounded
+dqdiv1778 divide 1e+40 1e-6109 -> Infinity Overflow Inexact Rounded
+dqdiv1779 divide 1e+40 1e-6110 -> Infinity Overflow Inexact Rounded
+
+dqdiv1801 divide 1.0000E-6172 1 -> 1.0000E-6172 Subnormal
+dqdiv1802 divide 1.000E-6172 1e+1 -> 1.000E-6173 Subnormal
+dqdiv1803 divide 1.00E-6172 1e+2 -> 1.00E-6174 Subnormal
+dqdiv1804 divide 1.0E-6172 1e+3 -> 1.0E-6175 Subnormal
+dqdiv1805 divide 1.0E-6172 1e+4 -> 1E-6176 Subnormal Rounded
+dqdiv1806 divide 1.3E-6172 1e+4 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1807 divide 1.5E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1808 divide 1.7E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1809 divide 2.3E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1810 divide 2.5E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1811 divide 2.7E-6172 1e+4 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1812 divide 1.49E-6172 1e+4 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1813 divide 1.50E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1814 divide 1.51E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1815 divide 2.49E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1816 divide 2.50E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1817 divide 2.51E-6172 1e+4 -> 3E-6176 Underflow Subnormal Inexact Rounded
+
+dqdiv1818 divide 1E-6172 1e+4 -> 1E-6176 Subnormal
+dqdiv1819 divide 3E-6172 1e+5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1820 divide 5E-6172 1e+5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1821 divide 7E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1822 divide 9E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1823 divide 9.9E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+dqdiv1824 divide 1E-6172 -1e+4 -> -1E-6176 Subnormal
+dqdiv1825 divide 3E-6172 -1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1826 divide -5E-6172 1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1827 divide 7E-6172 -1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1828 divide -9E-6172 1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1829 divide 9.9E-6172 -1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1830 divide 3.0E-6172 -1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqdiv1831 divide 1.0E-5977 1e+200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1832 divide 1.0E-5977 1e+199 -> 1E-6176 Subnormal Rounded
+dqdiv1833 divide 1.0E-5977 1e+198 -> 1.0E-6175 Subnormal
+dqdiv1834 divide 2.0E-5977 2e+198 -> 1.0E-6175 Subnormal
+dqdiv1835 divide 4.0E-5977 4e+198 -> 1.0E-6175 Subnormal
+dqdiv1836 divide 10.0E-5977 10e+198 -> 1.0E-6175 Subnormal
+dqdiv1837 divide 30.0E-5977 30e+198 -> 1.0E-6175 Subnormal
+dqdiv1838 divide 40.0E-5982 40e+166 -> 1.0E-6148 Subnormal
+dqdiv1839 divide 40.0E-5982 40e+165 -> 1.0E-6147 Subnormal
+dqdiv1840 divide 40.0E-5982 40e+164 -> 1.0E-6146 Subnormal
+
+-- randoms
+rounding: half_even
+dqdiv2010 divide -5231195652931651968034356117118850 -7243718664422548573203260970.34995 -> 722169.9095831284624736051460550680 Inexact Rounded
+dqdiv2011 divide -89584669773927.82711237350022515352 -42077943728529635884.21142627532985 -> 0.000002129017291146471565928125887527266 Inexact Rounded
+dqdiv2012 divide -2.828201693360723203806974891946180E-232 812596541221823960386384403089240.9 -> -3.480450075640521320040055759125120E-265 Inexact Rounded
+dqdiv2013 divide -6442775372761069267502937539408720 24904085056.69185465145182606089196 -> -258703556388226463687701.4884719589 Inexact Rounded
+dqdiv2014 divide 5.535520011272625629610079879714705 -44343664650.57203052003068113531208 -> -1.248322630728089308975940533493562E-10 Inexact Rounded
+dqdiv2015 divide 65919273712517865964325.99419625010 -314733354141381737378622515.7789054 -> -0.0002094448295521490616379784758911632 Inexact Rounded
+dqdiv2016 divide -7.779172568193197107115275140431129E+759 -140453015639.3988987652895178782143 -> 5.538629792161641534962774244238115E+748 Inexact Rounded
+dqdiv2017 divide 644314832597569.0181226067518178797 -115024585257425.1635759521565201075 -> -5.601540150356479257367687450922795 Inexact Rounded
+dqdiv2018 divide 6.898640941579611450676592553286870E-47 -11272429881407851485163914999.25943 -> -6.119923578285338689371137648319280E-75 Inexact Rounded
+dqdiv2019 divide -3591344544888727133.30819750163254 5329395.423792795661446561090331037 -> -673874662941.1968525589460533725290 Inexact Rounded
+dqdiv2020 divide -7.682356781384631313156462724425838E+747 -6.60375855512219057281922141809940E+703 -> 1.163330960279556016678379128875149E+44 Inexact Rounded
+dqdiv2021 divide -4511495596596941820863224.274679699 3365395017.263329795449661616090724 -> -1340554548115304.904166888018346299 Inexact Rounded
+dqdiv2022 divide 5.211164127840931517263639608151299 164.5566381356276567012533847006453 -> 0.03166790587655228864478260157156510 Inexact Rounded
+dqdiv2023 divide -49891.2243893458830384077684620383 -47179.9312961860747554053371171530 -> 1.057467084386767291602189656430268 Inexact Rounded
+dqdiv2024 divide 15065477.47214268488077415462413353 4366211.120892953261309529740552596 -> 3.450469309661227984244545513441359 Inexact Rounded
+dqdiv2025 divide 1.575670269440761846109602429612644E+370 653199649324740300.006185482643439 -> 2.412233795700359170904588548041481E+352 Inexact Rounded
+dqdiv2026 divide -2112422311733448924573432192.620145 -80067206.03590693153848215848613406 -> 26383115089417660175.20102646756574 Inexact Rounded
+dqdiv2027 divide -67096536051279809.32218611548721839 -869685412881941081664251990181.1049 -> 7.715035236584805921278566365231168E-14 Inexact Rounded
+dqdiv2028 divide -58612908548962047.21866913425488972 -978449597531.3873665583475633831644 -> 59903.86085991703091236507859837023 Inexact Rounded
+dqdiv2029 divide -133032412010942.1476864138213319796 -7.882059293498670705446528648201359E-428 -> 1.687787506504433064549515681693715E+441 Inexact Rounded
+dqdiv2030 divide 1.83746698338966029492299716360513E+977 -9.897926608979649951672839879128603E+154 -> -1.856416051542212552042390218062458E+822 Inexact Rounded
+dqdiv2031 divide -113742475841399236307128962.1507063 8298602.203049834732657567965262989 -> -13706221006665137826.16557393919929 Inexact Rounded
+dqdiv2032 divide 196.4787574650754152995941808331862 929.6553388472318094427422117172394 -> 0.2113458066176526651006917922814018 Inexact Rounded
+dqdiv2033 divide 71931221465.43867996282803628130350 3838685934206426257090718.402248853 -> 1.873850132527423413607199513324021E-14 Inexact Rounded
+dqdiv2034 divide 488.4282502289651653783596246312885 -80.68940956806634280078706577953188 -> -6.053189047280693318844801899473272 Inexact Rounded
+dqdiv2035 divide 9.001764344963921754981762913247394E-162 -8.585540973667205753734967645386919E-729 -> -1.048479574271827326396012573232934E+567 Inexact Rounded
+dqdiv2036 divide -7.404133959409894743706402857145471E-828 -51.38159929460289711134684843086265 -> 1.441008855516029461032061785219773E-829 Inexact Rounded
+dqdiv2037 divide 2.967520235574419794048994436040717E-613 -6252513855.91394894949879262731889 -> -4.746123405656409127572998751885338E-623 Inexact Rounded
+dqdiv2038 divide -18826852654824040505.83920366765051 -6336924877942437992590557460147340 -> 2.970976146546494669807886278519194E-15 Inexact Rounded
+dqdiv2039 divide -8.101406784809197604949584001735949E+561 4.823300306948942821076681658771635E+361 -> -1.679639721610839204738445747238987E+200 Inexact Rounded
+dqdiv2040 divide -6.11981977773094052331062585191723E+295 1.507610253755339328302779005586534E+238 -> -4.059285058911577244044418416044763E+57 Inexact Rounded
+dqdiv2041 divide 6.472638850046815880599220534274055E-596 -4.475233712083047516933911786159972 -> -1.446324207062261745520496475778879E-596 Inexact Rounded
+dqdiv2042 divide -84438593330.71277839631144509397112 -586684596204401664208947.4054879633 -> 1.439250218550041228759983937772504E-13 Inexact Rounded
+dqdiv2043 divide 9.354533233294022616695815656704369E-24 405.500390626135304252144163591746 -> 2.306911028827774549740571229736198E-26 Inexact Rounded
+dqdiv2044 divide 985606423350210.7374876650149957881 -36811563697.41925681866694859828794 -> -26774.36990864119445335813354717711 Inexact Rounded
+dqdiv2045 divide -8.187280774177715706278002247766311E-123 -38784124393.91212870828430001300068 -> 2.110987653356139147357240727794365E-133 Inexact Rounded
+dqdiv2046 divide -4.612203126350070903459245798371657E+912 7.971562182727956290901984736800519E+64 -> -5.785820922708683237098826662769748E+847 Inexact Rounded
+dqdiv2047 divide 4.661015909421485298247928967977089E+888 -6.360911253323922338737311563845581E+388 -> -7.327591478321365980156654539638836E+499 Inexact Rounded
+dqdiv2048 divide 9156078172903.257500003260710833030 7.189796653262147139071634237964074E-90 -> 1.273482215766000994365201545096026E+102 Inexact Rounded
+dqdiv2049 divide -1.710722303327476586373477781276586E-311 -3167561628260156837329323.729380695 -> 5.400754599578613984875752958645655E-336 Inexact Rounded
+dqdiv2050 divide -4.647935210881806238321616345413021E-878 209388.5431867744648177308460639582 -> -2.219765771394593733140494297388140E-883 Inexact Rounded
+dqdiv2051 divide 5958.694728395760992719084781582700 4.541510156564315632536353171846096E-746 -> 1.312051393253638664947852693005480E+749 Inexact Rounded
+dqdiv2052 divide -7.935732544649702175256699886872093E-489 -7.433329073664793138998765647467971E+360 -> 1.067587949626076917672271619664656E-849 Inexact Rounded
+dqdiv2053 divide -2746650864601157.863589959939901350 7.016684945507647528907184694359598E+548 -> -3.914456593009309529351254950429932E-534 Inexact Rounded
+dqdiv2054 divide 3605149408631197365447953.994569178 -75614025825649082.78264864428237833 -> -47678315.88472693507060063188020532 Inexact Rounded
+dqdiv2055 divide 788194320921798404906375214.196349 -6.222718148433247384932573401976337E-418 -> -1.266639918634671803982222244977287E+444 Inexact Rounded
+dqdiv2056 divide 5620722730534752.758208943447603211 6.843552841168538319123000917657759E-139 -> 8.213164800485434666629970443739554E+153 Inexact Rounded
+dqdiv2057 divide 7304534676713703938102.403949019402 -576169.3685010935108153023803590835 -> -12677756014201995.31969237144394772 Inexact Rounded
+dqdiv2058 divide 8067918762.134621639254916786945547 -8.774771480055536009105596163864758E+954 -> -9.194448858836332156766764605125245E-946 Inexact Rounded
+dqdiv2059 divide 8.702093454123046507578256899537563E-324 -5.875399733016018404580201176576293E-401 -> -1.481106622452052581470443526957335E+77 Inexact Rounded
+dqdiv2060 divide -41426.01662518451861386352415092356 90.00146621684478300510769802013464 -> -460.2815750287318692732067709176200 Inexact Rounded
+
+-- random divide tests with result near 1
+dqdiv4001 divide 2003100352770753969878925664524900 2003100352770753969878925664497824 -> 1.000000000000000000000000000013517 Inexact Rounded
+dqdiv4002 divide 4817785793916490652579552318371645 4817785793916490652579552318362097 -> 1.000000000000000000000000000001982 Inexact Rounded
+dqdiv4003 divide 8299187410920067325648068439560282 8299187410920067325648068439591159 -> 0.9999999999999999999999999999962795 Inexact Rounded
+dqdiv4004 divide 5641088455897407044544461785365899 5641088455897407044544461785389965 -> 0.9999999999999999999999999999957338 Inexact Rounded
+dqdiv4005 divide 5752274694706545359326361313490424 5752274694706545359326361313502723 -> 0.9999999999999999999999999999978619 Inexact Rounded
+dqdiv4006 divide 6762079477373670594829319346099665 6762079477373670594829319346132579 -> 0.9999999999999999999999999999951326 Inexact Rounded
+dqdiv4007 divide 7286425153691890341633023222602916 7286425153691890341633023222606556 -> 0.9999999999999999999999999999995004 Inexact Rounded
+dqdiv4008 divide 9481233991901305727648306421946655 9481233991901305727648306421919124 -> 1.000000000000000000000000000002904 Inexact Rounded
+dqdiv4009 divide 4282053941893951742029444065614311 4282053941893951742029444065583077 -> 1.000000000000000000000000000007294 Inexact Rounded
+dqdiv4010 divide 626888225441250639741781850338695 626888225441250639741781850327299 -> 1.000000000000000000000000000018179 Inexact Rounded
+dqdiv4011 divide 3860973649222028009456598604468547 3860973649222028009456598604476849 -> 0.9999999999999999999999999999978498 Inexact Rounded
+dqdiv4012 divide 4753157080127468127908060607821839 4753157080127468127908060607788379 -> 1.000000000000000000000000000007040 Inexact Rounded
+dqdiv4013 divide 552448546203754062805706277880419 552448546203754062805706277881903 -> 0.9999999999999999999999999999973138 Inexact Rounded
+dqdiv4014 divide 8405954527952158455323713728917395 8405954527952158455323713728933866 -> 0.9999999999999999999999999999980406 Inexact Rounded
+dqdiv4015 divide 7554096502235321142555802238016116 7554096502235321142555802238026546 -> 0.9999999999999999999999999999986193 Inexact Rounded
+dqdiv4016 divide 4053257674127518606871054934746782 4053257674127518606871054934767355 -> 0.9999999999999999999999999999949243 Inexact Rounded
+dqdiv4017 divide 7112419420755090454716888844011582 7112419420755090454716888844038105 -> 0.9999999999999999999999999999962709 Inexact Rounded
+dqdiv4018 divide 3132302137520072728164549730911846 3132302137520072728164549730908416 -> 1.000000000000000000000000000001095 Inexact Rounded
+dqdiv4019 divide 4788374045841416355706715048161013 4788374045841416355706715048190077 -> 0.9999999999999999999999999999939303 Inexact Rounded
+dqdiv4020 divide 9466021636047630218238075099510597 9466021636047630218238075099484053 -> 1.000000000000000000000000000002804 Inexact Rounded
+dqdiv4021 divide 912742745646765625597399692138650 912742745646765625597399692139042 -> 0.9999999999999999999999999999995705 Inexact Rounded
+dqdiv4022 divide 9508402742933643208806264897188504 9508402742933643208806264897195973 -> 0.9999999999999999999999999999992145 Inexact Rounded
+dqdiv4023 divide 1186956795727233704962361914360895 1186956795727233704962361914329577 -> 1.000000000000000000000000000026385 Inexact Rounded
+dqdiv4024 divide 5972210268839014812696916170967938 5972210268839014812696916170954974 -> 1.000000000000000000000000000002171 Inexact Rounded
+dqdiv4025 divide 2303801625521619930894460139793140 2303801625521619930894460139799643 -> 0.9999999999999999999999999999971773 Inexact Rounded
+dqdiv4026 divide 6022231560002898264777393473966595 6022231560002898264777393473947198 -> 1.000000000000000000000000000003221 Inexact Rounded
+dqdiv4027 divide 8426148335801396199969346032210893 8426148335801396199969346032203179 -> 1.000000000000000000000000000000915 Inexact Rounded
+dqdiv4028 divide 8812278947028784637382847098411749 8812278947028784637382847098385317 -> 1.000000000000000000000000000002999 Inexact Rounded
+dqdiv4029 divide 8145282002348367383264197170116146 8145282002348367383264197170083988 -> 1.000000000000000000000000000003948 Inexact Rounded
+dqdiv4030 divide 6821577571876840153123510107387026 6821577571876840153123510107418008 -> 0.9999999999999999999999999999954582 Inexact Rounded
+dqdiv4031 divide 9018555319518966970480565482023720 9018555319518966970480565482013346 -> 1.000000000000000000000000000001150 Inexact Rounded
+dqdiv4032 divide 4602155712998228449640717252788864 4602155712998228449640717252818502 -> 0.9999999999999999999999999999935600 Inexact Rounded
+dqdiv4033 divide 6675607481522785614506828292264472 6675607481522785614506828292277100 -> 0.9999999999999999999999999999981083 Inexact Rounded
+dqdiv4034 divide 4015881516871833897766945836264472 4015881516871833897766945836262645 -> 1.000000000000000000000000000000455 Inexact Rounded
+dqdiv4035 divide 1415580205933411837595459716910365 1415580205933411837595459716880139 -> 1.000000000000000000000000000021352 Inexact Rounded
+dqdiv4036 divide 9432968297069542816752035276361552 9432968297069542816752035276353054 -> 1.000000000000000000000000000000901 Inexact Rounded
+dqdiv4037 divide 4799319591303848500532766682140658 4799319591303848500532766682172655 -> 0.9999999999999999999999999999933330 Inexact Rounded
+dqdiv4038 divide 316854270732839529790584284987472 316854270732839529790584285004832 -> 0.9999999999999999999999999999452114 Inexact Rounded
+dqdiv4039 divide 3598981300592490427826027975697415 3598981300592490427826027975686712 -> 1.000000000000000000000000000002974 Inexact Rounded
+dqdiv4040 divide 1664315435694461371155800682196520 1664315435694461371155800682195617 -> 1.000000000000000000000000000000543 Inexact Rounded
+dqdiv4041 divide 1680872316531128890102855316510581 1680872316531128890102855316495545 -> 1.000000000000000000000000000008945 Inexact Rounded
+dqdiv4042 divide 9881274879566405475755499281644730 9881274879566405475755499281615743 -> 1.000000000000000000000000000002934 Inexact Rounded
+dqdiv4043 divide 4737225957717466960447204232279216 4737225957717466960447204232277452 -> 1.000000000000000000000000000000372 Inexact Rounded
+dqdiv4044 divide 2482097379414867061213319346418288 2482097379414867061213319346387936 -> 1.000000000000000000000000000012228 Inexact Rounded
+dqdiv4045 divide 7406977595233762723576434122161868 7406977595233762723576434122189042 -> 0.9999999999999999999999999999963313 Inexact Rounded
+dqdiv4046 divide 228782057757566047086593281773577 228782057757566047086593281769727 -> 1.000000000000000000000000000016828 Inexact Rounded
+dqdiv4047 divide 2956594270240579648823270540367653 2956594270240579648823270540368556 -> 0.9999999999999999999999999999996946 Inexact Rounded
+dqdiv4048 divide 6326964098897620620534136767634340 6326964098897620620534136767619339 -> 1.000000000000000000000000000002371 Inexact Rounded
+dqdiv4049 divide 414586440456590215247002678327800 414586440456590215247002678316922 -> 1.000000000000000000000000000026238 Inexact Rounded
+dqdiv4050 divide 7364552208570039386220505636779125 7364552208570039386220505636803548 -> 0.9999999999999999999999999999966837 Inexact Rounded
+dqdiv4051 divide 5626266749902369710022824950590056 5626266749902369710022824950591008 -> 0.9999999999999999999999999999998308 Inexact Rounded
+dqdiv4052 divide 4863278293916197454987481343460484 4863278293916197454987481343442522 -> 1.000000000000000000000000000003693 Inexact Rounded
+dqdiv4053 divide 1170713582030637359713249796835483 1170713582030637359713249796823345 -> 1.000000000000000000000000000010368 Inexact Rounded
+dqdiv4054 divide 9838062494725965667776326556052931 9838062494725965667776326556061002 -> 0.9999999999999999999999999999991796 Inexact Rounded
+dqdiv4055 divide 4071388731298861093005687091498922 4071388731298861093005687091498278 -> 1.000000000000000000000000000000158 Inexact Rounded
+dqdiv4056 divide 8753155722324706795855038590272526 8753155722324706795855038590276656 -> 0.9999999999999999999999999999995282 Inexact Rounded
+dqdiv4057 divide 4399941911533273418844742658240485 4399941911533273418844742658219891 -> 1.000000000000000000000000000004681 Inexact Rounded
+dqdiv4058 divide 4127884159949503677776430620050269 4127884159949503677776430620026091 -> 1.000000000000000000000000000005857 Inexact Rounded
+dqdiv4059 divide 5536160822360800067042528317438808 5536160822360800067042528317450687 -> 0.9999999999999999999999999999978543 Inexact Rounded
+dqdiv4060 divide 3973234998468664936671088237710246 3973234998468664936671088237741886 -> 0.9999999999999999999999999999920367 Inexact Rounded
+dqdiv4061 divide 9824855935638263593410444142327358 9824855935638263593410444142328576 -> 0.9999999999999999999999999999998760 Inexact Rounded
+dqdiv4062 divide 5917078517340218131867327300814867 5917078517340218131867327300788701 -> 1.000000000000000000000000000004422 Inexact Rounded
+dqdiv4063 divide 4354236601830544882286139612521362 4354236601830544882286139612543223 -> 0.9999999999999999999999999999949794 Inexact Rounded
+dqdiv4064 divide 8058474772375259017342110013891294 8058474772375259017342110013906792 -> 0.9999999999999999999999999999980768 Inexact Rounded
+dqdiv4065 divide 5519604020981748170517093746166328 5519604020981748170517093746181763 -> 0.9999999999999999999999999999972036 Inexact Rounded
+dqdiv4066 divide 1502130966879805458831323782443139 1502130966879805458831323782412213 -> 1.000000000000000000000000000020588 Inexact Rounded
+dqdiv4067 divide 562795633719481212915159787980270 562795633719481212915159788007066 -> 0.9999999999999999999999999999523877 Inexact Rounded
+dqdiv4068 divide 6584743324494664273941281557268878 6584743324494664273941281557258945 -> 1.000000000000000000000000000001508 Inexact Rounded
+dqdiv4069 divide 3632000327285743997976431109416500 3632000327285743997976431109408107 -> 1.000000000000000000000000000002311 Inexact Rounded
+dqdiv4070 divide 1145827237315430089388953838561450 1145827237315430089388953838527332 -> 1.000000000000000000000000000029776 Inexact Rounded
+dqdiv4071 divide 8874431010357691869725372317350380 8874431010357691869725372317316472 -> 1.000000000000000000000000000003821 Inexact Rounded
+dqdiv4072 divide 992948718902804648119753141202196 992948718902804648119753141235222 -> 0.9999999999999999999999999999667395 Inexact Rounded
+dqdiv4073 divide 2522735183374218505142417265439989 2522735183374218505142417265453779 -> 0.9999999999999999999999999999945337 Inexact Rounded
+dqdiv4074 divide 2668419161912936508006872303501052 2668419161912936508006872303471036 -> 1.000000000000000000000000000011249 Inexact Rounded
+dqdiv4075 divide 3036169085665186712590941111775092 3036169085665186712590941111808846 -> 0.9999999999999999999999999999888827 Inexact Rounded
+dqdiv4076 divide 9441634604917231638508898934006147 9441634604917231638508898934000288 -> 1.000000000000000000000000000000621 Inexact Rounded
+dqdiv4077 divide 2677301353164377091111458811839190 2677301353164377091111458811867722 -> 0.9999999999999999999999999999893430 Inexact Rounded
+dqdiv4078 divide 6844979203112066166583765857171426 6844979203112066166583765857189682 -> 0.9999999999999999999999999999973329 Inexact Rounded
+dqdiv4079 divide 2220337435141796724323783960231661 2220337435141796724323783960208778 -> 1.000000000000000000000000000010306 Inexact Rounded
+dqdiv4080 divide 6447424700019783931569996989561380 6447424700019783931569996989572454 -> 0.9999999999999999999999999999982824 Inexact Rounded
+dqdiv4081 divide 7512856762696607119847092195587180 7512856762696607119847092195557346 -> 1.000000000000000000000000000003971 Inexact Rounded
+dqdiv4082 divide 7395261981193960399087819077237482 7395261981193960399087819077242487 -> 0.9999999999999999999999999999993232 Inexact Rounded
+dqdiv4083 divide 2253442467682584035792724884376735 2253442467682584035792724884407178 -> 0.9999999999999999999999999999864904 Inexact Rounded
+dqdiv4084 divide 8153138680300213135577336466190997 8153138680300213135577336466220607 -> 0.9999999999999999999999999999963683 Inexact Rounded
+dqdiv4085 divide 4668731252254148074041022681801390 4668731252254148074041022681778101 -> 1.000000000000000000000000000004988 Inexact Rounded
+dqdiv4086 divide 6078404557993669696040425501815056 6078404557993669696040425501797612 -> 1.000000000000000000000000000002870 Inexact Rounded
+dqdiv4087 divide 2306352359874261623223356878316278 2306352359874261623223356878335612 -> 0.9999999999999999999999999999916171 Inexact Rounded
+dqdiv4088 divide 3264842186668480362900909564091908 3264842186668480362900909564058658 -> 1.000000000000000000000000000010184 Inexact Rounded
+dqdiv4089 divide 6971985047279636878957959608612204 6971985047279636878957959608615088 -> 0.9999999999999999999999999999995863 Inexact Rounded
+dqdiv4090 divide 5262810889952721235466445973816257 5262810889952721235466445973783077 -> 1.000000000000000000000000000006305 Inexact Rounded
+dqdiv4091 divide 7947944731035267178548357070080288 7947944731035267178548357070061339 -> 1.000000000000000000000000000002384 Inexact Rounded
+dqdiv4092 divide 5071808908395375108383035800443229 5071808908395375108383035800412429 -> 1.000000000000000000000000000006073 Inexact Rounded
+dqdiv4093 divide 2043146542084503655511507209262969 2043146542084503655511507209249263 -> 1.000000000000000000000000000006708 Inexact Rounded
+dqdiv4094 divide 4097632735384534181661959731264802 4097632735384534181661959731234499 -> 1.000000000000000000000000000007395 Inexact Rounded
+dqdiv4095 divide 3061477642831387489729464587044430 3061477642831387489729464587059452 -> 0.9999999999999999999999999999950932 Inexact Rounded
+dqdiv4096 divide 3429854941039776159498802936252638 3429854941039776159498802936246415 -> 1.000000000000000000000000000001814 Inexact Rounded
+dqdiv4097 divide 4874324979578599700024133278284545 4874324979578599700024133278262131 -> 1.000000000000000000000000000004598 Inexact Rounded
+dqdiv4098 divide 5701652369691833541455978515820882 5701652369691833541455978515834854 -> 0.9999999999999999999999999999975495 Inexact Rounded
+dqdiv4099 divide 2928205728402945266953255632343113 2928205728402945266953255632373794 -> 0.9999999999999999999999999999895223 Inexact Rounded
+
+-- Null tests
+dqdiv9998 divide 10 # -> NaN Invalid_operation
+dqdiv9999 divide # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqDivideInt.decTest b/Lib/test/decimaltestdata/dqDivideInt.decTest
index c29035119f..3fec6dbaa3 100644
--- a/Lib/test/decimaltestdata/dqDivideInt.decTest
+++ b/Lib/test/decimaltestdata/dqDivideInt.decTest
@@ -1,453 +1,453 @@
-------------------------------------------------------------------------
--- dqDivideInt.decTest -- decQuad integer division --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-
-dqdvi001 divideint 1 1 -> 1
-dqdvi002 divideint 2 1 -> 2
-dqdvi003 divideint 1 2 -> 0
-dqdvi004 divideint 2 2 -> 1
-dqdvi005 divideint 0 1 -> 0
-dqdvi006 divideint 0 2 -> 0
-dqdvi007 divideint 1 3 -> 0
-dqdvi008 divideint 2 3 -> 0
-dqdvi009 divideint 3 3 -> 1
-
-dqdvi010 divideint 2.4 1 -> 2
-dqdvi011 divideint 2.4 -1 -> -2
-dqdvi012 divideint -2.4 1 -> -2
-dqdvi013 divideint -2.4 -1 -> 2
-dqdvi014 divideint 2.40 1 -> 2
-dqdvi015 divideint 2.400 1 -> 2
-dqdvi016 divideint 2.4 2 -> 1
-dqdvi017 divideint 2.400 2 -> 1
-dqdvi018 divideint 2. 2 -> 1
-dqdvi019 divideint 20 20 -> 1
-
-dqdvi020 divideint 187 187 -> 1
-dqdvi021 divideint 5 2 -> 2
-dqdvi022 divideint 5 2.0 -> 2
-dqdvi023 divideint 5 2.000 -> 2
-dqdvi024 divideint 5 0.200 -> 25
-dqdvi025 divideint 5 0.200 -> 25
-
-dqdvi030 divideint 1 2 -> 0
-dqdvi031 divideint 1 4 -> 0
-dqdvi032 divideint 1 8 -> 0
-dqdvi033 divideint 1 16 -> 0
-dqdvi034 divideint 1 32 -> 0
-dqdvi035 divideint 1 64 -> 0
-dqdvi040 divideint 1 -2 -> -0
-dqdvi041 divideint 1 -4 -> -0
-dqdvi042 divideint 1 -8 -> -0
-dqdvi043 divideint 1 -16 -> -0
-dqdvi044 divideint 1 -32 -> -0
-dqdvi045 divideint 1 -64 -> -0
-dqdvi050 divideint -1 2 -> -0
-dqdvi051 divideint -1 4 -> -0
-dqdvi052 divideint -1 8 -> -0
-dqdvi053 divideint -1 16 -> -0
-dqdvi054 divideint -1 32 -> -0
-dqdvi055 divideint -1 64 -> -0
-dqdvi060 divideint -1 -2 -> 0
-dqdvi061 divideint -1 -4 -> 0
-dqdvi062 divideint -1 -8 -> 0
-dqdvi063 divideint -1 -16 -> 0
-dqdvi064 divideint -1 -32 -> 0
-dqdvi065 divideint -1 -64 -> 0
-
--- similar with powers of ten
-dqdvi160 divideint 1 1 -> 1
-dqdvi161 divideint 1 10 -> 0
-dqdvi162 divideint 1 100 -> 0
-dqdvi163 divideint 1 1000 -> 0
-dqdvi164 divideint 1 10000 -> 0
-dqdvi165 divideint 1 100000 -> 0
-dqdvi166 divideint 1 1000000 -> 0
-dqdvi167 divideint 1 10000000 -> 0
-dqdvi168 divideint 1 100000000 -> 0
-dqdvi170 divideint 1 -1 -> -1
-dqdvi171 divideint 1 -10 -> -0
-dqdvi172 divideint 1 -100 -> -0
-dqdvi173 divideint 1 -1000 -> -0
-dqdvi174 divideint 1 -10000 -> -0
-dqdvi175 divideint 1 -100000 -> -0
-dqdvi176 divideint 1 -1000000 -> -0
-dqdvi177 divideint 1 -10000000 -> -0
-dqdvi178 divideint 1 -100000000 -> -0
-dqdvi180 divideint -1 1 -> -1
-dqdvi181 divideint -1 10 -> -0
-dqdvi182 divideint -1 100 -> -0
-dqdvi183 divideint -1 1000 -> -0
-dqdvi184 divideint -1 10000 -> -0
-dqdvi185 divideint -1 100000 -> -0
-dqdvi186 divideint -1 1000000 -> -0
-dqdvi187 divideint -1 10000000 -> -0
-dqdvi188 divideint -1 100000000 -> -0
-dqdvi190 divideint -1 -1 -> 1
-dqdvi191 divideint -1 -10 -> 0
-dqdvi192 divideint -1 -100 -> 0
-dqdvi193 divideint -1 -1000 -> 0
-dqdvi194 divideint -1 -10000 -> 0
-dqdvi195 divideint -1 -100000 -> 0
-dqdvi196 divideint -1 -1000000 -> 0
-dqdvi197 divideint -1 -10000000 -> 0
-dqdvi198 divideint -1 -100000000 -> 0
-
--- some long operand (at p=9) cases
-dqdvi070 divideint 999999999 1 -> 999999999
-dqdvi071 divideint 999999999.4 1 -> 999999999
-dqdvi072 divideint 999999999.5 1 -> 999999999
-dqdvi073 divideint 999999999.9 1 -> 999999999
-dqdvi074 divideint 999999999.999 1 -> 999999999
-
-dqdvi090 divideint 0. 1 -> 0
-dqdvi091 divideint .0 1 -> 0
-dqdvi092 divideint 0.00 1 -> 0
-dqdvi093 divideint 0.00E+9 1 -> 0
-dqdvi094 divideint 0.0000E-50 1 -> 0
-
-dqdvi100 divideint 1 1 -> 1
-dqdvi101 divideint 1 2 -> 0
-dqdvi102 divideint 1 3 -> 0
-dqdvi103 divideint 1 4 -> 0
-dqdvi104 divideint 1 5 -> 0
-dqdvi105 divideint 1 6 -> 0
-dqdvi106 divideint 1 7 -> 0
-dqdvi107 divideint 1 8 -> 0
-dqdvi108 divideint 1 9 -> 0
-dqdvi109 divideint 1 10 -> 0
-dqdvi110 divideint 1 1 -> 1
-dqdvi111 divideint 2 1 -> 2
-dqdvi112 divideint 3 1 -> 3
-dqdvi113 divideint 4 1 -> 4
-dqdvi114 divideint 5 1 -> 5
-dqdvi115 divideint 6 1 -> 6
-dqdvi116 divideint 7 1 -> 7
-dqdvi117 divideint 8 1 -> 8
-dqdvi118 divideint 9 1 -> 9
-dqdvi119 divideint 10 1 -> 10
-
--- from DiagBigDecimal
-dqdvi131 divideint 101.3 1 -> 101
-dqdvi132 divideint 101.0 1 -> 101
-dqdvi133 divideint 101.3 3 -> 33
-dqdvi134 divideint 101.0 3 -> 33
-dqdvi135 divideint 2.4 1 -> 2
-dqdvi136 divideint 2.400 1 -> 2
-dqdvi137 divideint 18 18 -> 1
-dqdvi138 divideint 1120 1000 -> 1
-dqdvi139 divideint 2.4 2 -> 1
-dqdvi140 divideint 2.400 2 -> 1
-dqdvi141 divideint 0.5 2.000 -> 0
-dqdvi142 divideint 8.005 7 -> 1
-dqdvi143 divideint 5 2 -> 2
-dqdvi144 divideint 0 2 -> 0
-dqdvi145 divideint 0.00 2 -> 0
-
--- Others
-dqdvi150 divideint 12345 4.999 -> 2469
-dqdvi151 divideint 12345 4.99 -> 2473
-dqdvi152 divideint 12345 4.9 -> 2519
-dqdvi153 divideint 12345 5 -> 2469
-dqdvi154 divideint 12345 5.1 -> 2420
-dqdvi155 divideint 12345 5.01 -> 2464
-dqdvi156 divideint 12345 5.001 -> 2468
-dqdvi157 divideint 101 7.6 -> 13
-
--- Various flavours of divideint by 0
-dqdvi201 divideint 0 0 -> NaN Division_undefined
-dqdvi202 divideint 0.0E5 0 -> NaN Division_undefined
-dqdvi203 divideint 0.000 0 -> NaN Division_undefined
-dqdvi204 divideint 0.0001 0 -> Infinity Division_by_zero
-dqdvi205 divideint 0.01 0 -> Infinity Division_by_zero
-dqdvi206 divideint 0.1 0 -> Infinity Division_by_zero
-dqdvi207 divideint 1 0 -> Infinity Division_by_zero
-dqdvi208 divideint 1 0.0 -> Infinity Division_by_zero
-dqdvi209 divideint 10 0.0 -> Infinity Division_by_zero
-dqdvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
-dqdvi211 divideint 1E+380 0 -> Infinity Division_by_zero
-dqdvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
-dqdvi215 divideint -0.01 0 -> -Infinity Division_by_zero
-dqdvi216 divideint -0.1 0 -> -Infinity Division_by_zero
-dqdvi217 divideint -1 0 -> -Infinity Division_by_zero
-dqdvi218 divideint -1 0.0 -> -Infinity Division_by_zero
-dqdvi219 divideint -10 0.0 -> -Infinity Division_by_zero
-dqdvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
-dqdvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
-
--- test some cases that are close to exponent overflow
-dqdvi270 divideint 1 1e384 -> 0
-dqdvi271 divideint 1 0.9e384 -> 0
-dqdvi272 divideint 1 0.99e384 -> 0
-dqdvi273 divideint 1 0.9999999999999999e384 -> 0
-dqdvi274 divideint 9e384 1 -> NaN Division_impossible
-dqdvi275 divideint 9.9e384 1 -> NaN Division_impossible
-dqdvi276 divideint 9.99e384 1 -> NaN Division_impossible
-dqdvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
-
-dqdvi280 divideint 0.1 9e-383 -> NaN Division_impossible
-dqdvi281 divideint 0.1 99e-383 -> NaN Division_impossible
-dqdvi282 divideint 0.1 999e-383 -> NaN Division_impossible
-dqdvi283 divideint 0.1 9e-382 -> NaN Division_impossible
-dqdvi284 divideint 0.1 99e-382 -> NaN Division_impossible
-
--- GD edge cases: lhs smaller than rhs but more digits
-dqdvi301 divideint 0.9 2 -> 0
-dqdvi302 divideint 0.9 2.0 -> 0
-dqdvi303 divideint 0.9 2.1 -> 0
-dqdvi304 divideint 0.9 2.00 -> 0
-dqdvi305 divideint 0.9 2.01 -> 0
-dqdvi306 divideint 0.12 1 -> 0
-dqdvi307 divideint 0.12 1.0 -> 0
-dqdvi308 divideint 0.12 1.00 -> 0
-dqdvi309 divideint 0.12 1.0 -> 0
-dqdvi310 divideint 0.12 1.00 -> 0
-dqdvi311 divideint 0.12 2 -> 0
-dqdvi312 divideint 0.12 2.0 -> 0
-dqdvi313 divideint 0.12 2.1 -> 0
-dqdvi314 divideint 0.12 2.00 -> 0
-dqdvi315 divideint 0.12 2.01 -> 0
-
--- edge cases of impossible
-dqdvi330 divideint 1234567987654321987654321890123456 10 -> 123456798765432198765432189012345
-dqdvi331 divideint 1234567987654321987654321890123456 1 -> 1234567987654321987654321890123456
-dqdvi332 divideint 1234567987654321987654321890123456 0.1 -> NaN Division_impossible
-dqdvi333 divideint 1234567987654321987654321890123456 0.01 -> NaN Division_impossible
-
--- overflow and underflow tests [from divide]
-dqdvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
-dqdvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
-dqdvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
-dqdvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
-dqdvi1055 divideint 1e-277 1e+311 -> 0
-dqdvi1056 divideint 1e-277 -1e+311 -> -0
-dqdvi1057 divideint -1e-277 1e+311 -> -0
-dqdvi1058 divideint -1e-277 -1e+311 -> 0
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dqdvi1060 divideint 1e-291 1e+101 -> 0
-dqdvi1061 divideint 1e-291 1e+102 -> 0
-dqdvi1062 divideint 1e-291 1e+103 -> 0
-dqdvi1063 divideint 1e-291 1e+104 -> 0
-dqdvi1064 divideint 1e-291 1e+105 -> 0
-dqdvi1065 divideint 1e-291 1e+106 -> 0
-dqdvi1066 divideint 1e-291 1e+107 -> 0
-dqdvi1067 divideint 1e-291 1e+108 -> 0
-dqdvi1068 divideint 1e-291 1e+109 -> 0
-dqdvi1069 divideint 1e-291 1e+110 -> 0
-
-dqdvi1101 divideint 1.0000E-394 1 -> 0
-dqdvi1102 divideint 1.000E-394 1e+1 -> 0
-dqdvi1103 divideint 1.00E-394 1e+2 -> 0
-
-dqdvi1118 divideint 1E-394 1e+4 -> 0
-dqdvi1119 divideint 3E-394 -1e+5 -> -0
-dqdvi1120 divideint 5E-394 1e+5 -> 0
-
-dqdvi1124 divideint 1E-394 -1e+4 -> -0
-dqdvi1130 divideint 3.0E-394 -1e+5 -> -0
-
-dqdvi1131 divideint 1.0E-199 1e+200 -> 0
-dqdvi1132 divideint 1.0E-199 1e+199 -> 0
-dqdvi1133 divideint 1.0E-199 1e+198 -> 0
-dqdvi1134 divideint 2.0E-199 2e+198 -> 0
-dqdvi1135 divideint 4.0E-199 4e+198 -> 0
-
--- long operand checks
-dqdvi401 divideint 12345678000 100 -> 123456780
-dqdvi402 divideint 1 12345678000 -> 0
-dqdvi403 divideint 1234567800 10 -> 123456780
-dqdvi404 divideint 1 1234567800 -> 0
-dqdvi405 divideint 1234567890 10 -> 123456789
-dqdvi406 divideint 1 1234567890 -> 0
-dqdvi407 divideint 1234567891 10 -> 123456789
-dqdvi408 divideint 1 1234567891 -> 0
-dqdvi409 divideint 12345678901 100 -> 123456789
-dqdvi410 divideint 1 12345678901 -> 0
-dqdvi411 divideint 1234567896 10 -> 123456789
-dqdvi412 divideint 1 1234567896 -> 0
-dqdvi413 divideint 12345678948 100 -> 123456789
-dqdvi414 divideint 12345678949 100 -> 123456789
-dqdvi415 divideint 12345678950 100 -> 123456789
-dqdvi416 divideint 12345678951 100 -> 123456789
-dqdvi417 divideint 12345678999 100 -> 123456789
-dqdvi441 divideint 12345678000 1 -> 12345678000
-dqdvi442 divideint 1 12345678000 -> 0
-dqdvi443 divideint 1234567800 1 -> 1234567800
-dqdvi444 divideint 1 1234567800 -> 0
-dqdvi445 divideint 1234567890 1 -> 1234567890
-dqdvi446 divideint 1 1234567890 -> 0
-dqdvi447 divideint 1234567891 1 -> 1234567891
-dqdvi448 divideint 1 1234567891 -> 0
-dqdvi449 divideint 12345678901 1 -> 12345678901
-dqdvi450 divideint 1 12345678901 -> 0
-dqdvi451 divideint 1234567896 1 -> 1234567896
-dqdvi452 divideint 1 1234567896 -> 0
-
--- more zeros, etc.
-dqdvi531 divideint 5.00 1E-3 -> 5000
-dqdvi532 divideint 00.00 0.000 -> NaN Division_undefined
-dqdvi533 divideint 00.00 0E-3 -> NaN Division_undefined
-dqdvi534 divideint 0 -0 -> NaN Division_undefined
-dqdvi535 divideint -0 0 -> NaN Division_undefined
-dqdvi536 divideint -0 -0 -> NaN Division_undefined
-
-dqdvi541 divideint 0 -1 -> -0
-dqdvi542 divideint -0 -1 -> 0
-dqdvi543 divideint 0 1 -> 0
-dqdvi544 divideint -0 1 -> -0
-dqdvi545 divideint -1 0 -> -Infinity Division_by_zero
-dqdvi546 divideint -1 -0 -> Infinity Division_by_zero
-dqdvi547 divideint 1 0 -> Infinity Division_by_zero
-dqdvi548 divideint 1 -0 -> -Infinity Division_by_zero
-
-dqdvi551 divideint 0.0 -1 -> -0
-dqdvi552 divideint -0.0 -1 -> 0
-dqdvi553 divideint 0.0 1 -> 0
-dqdvi554 divideint -0.0 1 -> -0
-dqdvi555 divideint -1.0 0 -> -Infinity Division_by_zero
-dqdvi556 divideint -1.0 -0 -> Infinity Division_by_zero
-dqdvi557 divideint 1.0 0 -> Infinity Division_by_zero
-dqdvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
-
-dqdvi561 divideint 0 -1.0 -> -0
-dqdvi562 divideint -0 -1.0 -> 0
-dqdvi563 divideint 0 1.0 -> 0
-dqdvi564 divideint -0 1.0 -> -0
-dqdvi565 divideint -1 0.0 -> -Infinity Division_by_zero
-dqdvi566 divideint -1 -0.0 -> Infinity Division_by_zero
-dqdvi567 divideint 1 0.0 -> Infinity Division_by_zero
-dqdvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
-
-dqdvi571 divideint 0.0 -1.0 -> -0
-dqdvi572 divideint -0.0 -1.0 -> 0
-dqdvi573 divideint 0.0 1.0 -> 0
-dqdvi574 divideint -0.0 1.0 -> -0
-dqdvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
-dqdvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
-dqdvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
-dqdvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
-
--- Specials
-dqdvi580 divideint Inf -Inf -> NaN Invalid_operation
-dqdvi581 divideint Inf -1000 -> -Infinity
-dqdvi582 divideint Inf -1 -> -Infinity
-dqdvi583 divideint Inf -0 -> -Infinity
-dqdvi584 divideint Inf 0 -> Infinity
-dqdvi585 divideint Inf 1 -> Infinity
-dqdvi586 divideint Inf 1000 -> Infinity
-dqdvi587 divideint Inf Inf -> NaN Invalid_operation
-dqdvi588 divideint -1000 Inf -> -0
-dqdvi589 divideint -Inf Inf -> NaN Invalid_operation
-dqdvi590 divideint -1 Inf -> -0
-dqdvi591 divideint -0 Inf -> -0
-dqdvi592 divideint 0 Inf -> 0
-dqdvi593 divideint 1 Inf -> 0
-dqdvi594 divideint 1000 Inf -> 0
-dqdvi595 divideint Inf Inf -> NaN Invalid_operation
-
-dqdvi600 divideint -Inf -Inf -> NaN Invalid_operation
-dqdvi601 divideint -Inf -1000 -> Infinity
-dqdvi602 divideint -Inf -1 -> Infinity
-dqdvi603 divideint -Inf -0 -> Infinity
-dqdvi604 divideint -Inf 0 -> -Infinity
-dqdvi605 divideint -Inf 1 -> -Infinity
-dqdvi606 divideint -Inf 1000 -> -Infinity
-dqdvi607 divideint -Inf Inf -> NaN Invalid_operation
-dqdvi608 divideint -1000 Inf -> -0
-dqdvi609 divideint -Inf -Inf -> NaN Invalid_operation
-dqdvi610 divideint -1 -Inf -> 0
-dqdvi611 divideint -0 -Inf -> 0
-dqdvi612 divideint 0 -Inf -> -0
-dqdvi613 divideint 1 -Inf -> -0
-dqdvi614 divideint 1000 -Inf -> -0
-dqdvi615 divideint Inf -Inf -> NaN Invalid_operation
-
-dqdvi621 divideint NaN -Inf -> NaN
-dqdvi622 divideint NaN -1000 -> NaN
-dqdvi623 divideint NaN -1 -> NaN
-dqdvi624 divideint NaN -0 -> NaN
-dqdvi625 divideint NaN 0 -> NaN
-dqdvi626 divideint NaN 1 -> NaN
-dqdvi627 divideint NaN 1000 -> NaN
-dqdvi628 divideint NaN Inf -> NaN
-dqdvi629 divideint NaN NaN -> NaN
-dqdvi630 divideint -Inf NaN -> NaN
-dqdvi631 divideint -1000 NaN -> NaN
-dqdvi632 divideint -1 NaN -> NaN
-dqdvi633 divideint -0 NaN -> NaN
-dqdvi634 divideint 0 NaN -> NaN
-dqdvi635 divideint 1 NaN -> NaN
-dqdvi636 divideint 1000 NaN -> NaN
-dqdvi637 divideint Inf NaN -> NaN
-
-dqdvi641 divideint sNaN -Inf -> NaN Invalid_operation
-dqdvi642 divideint sNaN -1000 -> NaN Invalid_operation
-dqdvi643 divideint sNaN -1 -> NaN Invalid_operation
-dqdvi644 divideint sNaN -0 -> NaN Invalid_operation
-dqdvi645 divideint sNaN 0 -> NaN Invalid_operation
-dqdvi646 divideint sNaN 1 -> NaN Invalid_operation
-dqdvi647 divideint sNaN 1000 -> NaN Invalid_operation
-dqdvi648 divideint sNaN NaN -> NaN Invalid_operation
-dqdvi649 divideint sNaN sNaN -> NaN Invalid_operation
-dqdvi650 divideint NaN sNaN -> NaN Invalid_operation
-dqdvi651 divideint -Inf sNaN -> NaN Invalid_operation
-dqdvi652 divideint -1000 sNaN -> NaN Invalid_operation
-dqdvi653 divideint -1 sNaN -> NaN Invalid_operation
-dqdvi654 divideint -0 sNaN -> NaN Invalid_operation
-dqdvi655 divideint 0 sNaN -> NaN Invalid_operation
-dqdvi656 divideint 1 sNaN -> NaN Invalid_operation
-dqdvi657 divideint 1000 sNaN -> NaN Invalid_operation
-dqdvi658 divideint Inf sNaN -> NaN Invalid_operation
-dqdvi659 divideint NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqdvi661 divideint NaN9 -Inf -> NaN9
-dqdvi662 divideint NaN8 1000 -> NaN8
-dqdvi663 divideint NaN7 Inf -> NaN7
-dqdvi664 divideint -NaN6 NaN5 -> -NaN6
-dqdvi665 divideint -Inf NaN4 -> NaN4
-dqdvi666 divideint -1000 NaN3 -> NaN3
-dqdvi667 divideint Inf -NaN2 -> -NaN2
-
-dqdvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqdvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
-dqdvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
-dqdvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
-dqdvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
-dqdvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
-dqdvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
-dqdvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
-dqdvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
-
--- Gyuris example
-dqdvi700 divideint 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 0
-
--- Null tests
-dqdvi900 divideint 10 # -> NaN Invalid_operation
-dqdvi901 divideint # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqDivideInt.decTest -- decQuad integer division --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+
+dqdvi001 divideint 1 1 -> 1
+dqdvi002 divideint 2 1 -> 2
+dqdvi003 divideint 1 2 -> 0
+dqdvi004 divideint 2 2 -> 1
+dqdvi005 divideint 0 1 -> 0
+dqdvi006 divideint 0 2 -> 0
+dqdvi007 divideint 1 3 -> 0
+dqdvi008 divideint 2 3 -> 0
+dqdvi009 divideint 3 3 -> 1
+
+dqdvi010 divideint 2.4 1 -> 2
+dqdvi011 divideint 2.4 -1 -> -2
+dqdvi012 divideint -2.4 1 -> -2
+dqdvi013 divideint -2.4 -1 -> 2
+dqdvi014 divideint 2.40 1 -> 2
+dqdvi015 divideint 2.400 1 -> 2
+dqdvi016 divideint 2.4 2 -> 1
+dqdvi017 divideint 2.400 2 -> 1
+dqdvi018 divideint 2. 2 -> 1
+dqdvi019 divideint 20 20 -> 1
+
+dqdvi020 divideint 187 187 -> 1
+dqdvi021 divideint 5 2 -> 2
+dqdvi022 divideint 5 2.0 -> 2
+dqdvi023 divideint 5 2.000 -> 2
+dqdvi024 divideint 5 0.200 -> 25
+dqdvi025 divideint 5 0.200 -> 25
+
+dqdvi030 divideint 1 2 -> 0
+dqdvi031 divideint 1 4 -> 0
+dqdvi032 divideint 1 8 -> 0
+dqdvi033 divideint 1 16 -> 0
+dqdvi034 divideint 1 32 -> 0
+dqdvi035 divideint 1 64 -> 0
+dqdvi040 divideint 1 -2 -> -0
+dqdvi041 divideint 1 -4 -> -0
+dqdvi042 divideint 1 -8 -> -0
+dqdvi043 divideint 1 -16 -> -0
+dqdvi044 divideint 1 -32 -> -0
+dqdvi045 divideint 1 -64 -> -0
+dqdvi050 divideint -1 2 -> -0
+dqdvi051 divideint -1 4 -> -0
+dqdvi052 divideint -1 8 -> -0
+dqdvi053 divideint -1 16 -> -0
+dqdvi054 divideint -1 32 -> -0
+dqdvi055 divideint -1 64 -> -0
+dqdvi060 divideint -1 -2 -> 0
+dqdvi061 divideint -1 -4 -> 0
+dqdvi062 divideint -1 -8 -> 0
+dqdvi063 divideint -1 -16 -> 0
+dqdvi064 divideint -1 -32 -> 0
+dqdvi065 divideint -1 -64 -> 0
+
+-- similar with powers of ten
+dqdvi160 divideint 1 1 -> 1
+dqdvi161 divideint 1 10 -> 0
+dqdvi162 divideint 1 100 -> 0
+dqdvi163 divideint 1 1000 -> 0
+dqdvi164 divideint 1 10000 -> 0
+dqdvi165 divideint 1 100000 -> 0
+dqdvi166 divideint 1 1000000 -> 0
+dqdvi167 divideint 1 10000000 -> 0
+dqdvi168 divideint 1 100000000 -> 0
+dqdvi170 divideint 1 -1 -> -1
+dqdvi171 divideint 1 -10 -> -0
+dqdvi172 divideint 1 -100 -> -0
+dqdvi173 divideint 1 -1000 -> -0
+dqdvi174 divideint 1 -10000 -> -0
+dqdvi175 divideint 1 -100000 -> -0
+dqdvi176 divideint 1 -1000000 -> -0
+dqdvi177 divideint 1 -10000000 -> -0
+dqdvi178 divideint 1 -100000000 -> -0
+dqdvi180 divideint -1 1 -> -1
+dqdvi181 divideint -1 10 -> -0
+dqdvi182 divideint -1 100 -> -0
+dqdvi183 divideint -1 1000 -> -0
+dqdvi184 divideint -1 10000 -> -0
+dqdvi185 divideint -1 100000 -> -0
+dqdvi186 divideint -1 1000000 -> -0
+dqdvi187 divideint -1 10000000 -> -0
+dqdvi188 divideint -1 100000000 -> -0
+dqdvi190 divideint -1 -1 -> 1
+dqdvi191 divideint -1 -10 -> 0
+dqdvi192 divideint -1 -100 -> 0
+dqdvi193 divideint -1 -1000 -> 0
+dqdvi194 divideint -1 -10000 -> 0
+dqdvi195 divideint -1 -100000 -> 0
+dqdvi196 divideint -1 -1000000 -> 0
+dqdvi197 divideint -1 -10000000 -> 0
+dqdvi198 divideint -1 -100000000 -> 0
+
+-- some long operand (at p=9) cases
+dqdvi070 divideint 999999999 1 -> 999999999
+dqdvi071 divideint 999999999.4 1 -> 999999999
+dqdvi072 divideint 999999999.5 1 -> 999999999
+dqdvi073 divideint 999999999.9 1 -> 999999999
+dqdvi074 divideint 999999999.999 1 -> 999999999
+
+dqdvi090 divideint 0. 1 -> 0
+dqdvi091 divideint .0 1 -> 0
+dqdvi092 divideint 0.00 1 -> 0
+dqdvi093 divideint 0.00E+9 1 -> 0
+dqdvi094 divideint 0.0000E-50 1 -> 0
+
+dqdvi100 divideint 1 1 -> 1
+dqdvi101 divideint 1 2 -> 0
+dqdvi102 divideint 1 3 -> 0
+dqdvi103 divideint 1 4 -> 0
+dqdvi104 divideint 1 5 -> 0
+dqdvi105 divideint 1 6 -> 0
+dqdvi106 divideint 1 7 -> 0
+dqdvi107 divideint 1 8 -> 0
+dqdvi108 divideint 1 9 -> 0
+dqdvi109 divideint 1 10 -> 0
+dqdvi110 divideint 1 1 -> 1
+dqdvi111 divideint 2 1 -> 2
+dqdvi112 divideint 3 1 -> 3
+dqdvi113 divideint 4 1 -> 4
+dqdvi114 divideint 5 1 -> 5
+dqdvi115 divideint 6 1 -> 6
+dqdvi116 divideint 7 1 -> 7
+dqdvi117 divideint 8 1 -> 8
+dqdvi118 divideint 9 1 -> 9
+dqdvi119 divideint 10 1 -> 10
+
+-- from DiagBigDecimal
+dqdvi131 divideint 101.3 1 -> 101
+dqdvi132 divideint 101.0 1 -> 101
+dqdvi133 divideint 101.3 3 -> 33
+dqdvi134 divideint 101.0 3 -> 33
+dqdvi135 divideint 2.4 1 -> 2
+dqdvi136 divideint 2.400 1 -> 2
+dqdvi137 divideint 18 18 -> 1
+dqdvi138 divideint 1120 1000 -> 1
+dqdvi139 divideint 2.4 2 -> 1
+dqdvi140 divideint 2.400 2 -> 1
+dqdvi141 divideint 0.5 2.000 -> 0
+dqdvi142 divideint 8.005 7 -> 1
+dqdvi143 divideint 5 2 -> 2
+dqdvi144 divideint 0 2 -> 0
+dqdvi145 divideint 0.00 2 -> 0
+
+-- Others
+dqdvi150 divideint 12345 4.999 -> 2469
+dqdvi151 divideint 12345 4.99 -> 2473
+dqdvi152 divideint 12345 4.9 -> 2519
+dqdvi153 divideint 12345 5 -> 2469
+dqdvi154 divideint 12345 5.1 -> 2420
+dqdvi155 divideint 12345 5.01 -> 2464
+dqdvi156 divideint 12345 5.001 -> 2468
+dqdvi157 divideint 101 7.6 -> 13
+
+-- Various flavours of divideint by 0
+dqdvi201 divideint 0 0 -> NaN Division_undefined
+dqdvi202 divideint 0.0E5 0 -> NaN Division_undefined
+dqdvi203 divideint 0.000 0 -> NaN Division_undefined
+dqdvi204 divideint 0.0001 0 -> Infinity Division_by_zero
+dqdvi205 divideint 0.01 0 -> Infinity Division_by_zero
+dqdvi206 divideint 0.1 0 -> Infinity Division_by_zero
+dqdvi207 divideint 1 0 -> Infinity Division_by_zero
+dqdvi208 divideint 1 0.0 -> Infinity Division_by_zero
+dqdvi209 divideint 10 0.0 -> Infinity Division_by_zero
+dqdvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
+dqdvi211 divideint 1E+380 0 -> Infinity Division_by_zero
+dqdvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
+dqdvi215 divideint -0.01 0 -> -Infinity Division_by_zero
+dqdvi216 divideint -0.1 0 -> -Infinity Division_by_zero
+dqdvi217 divideint -1 0 -> -Infinity Division_by_zero
+dqdvi218 divideint -1 0.0 -> -Infinity Division_by_zero
+dqdvi219 divideint -10 0.0 -> -Infinity Division_by_zero
+dqdvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
+dqdvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
+
+-- test some cases that are close to exponent overflow
+dqdvi270 divideint 1 1e384 -> 0
+dqdvi271 divideint 1 0.9e384 -> 0
+dqdvi272 divideint 1 0.99e384 -> 0
+dqdvi273 divideint 1 0.9999999999999999e384 -> 0
+dqdvi274 divideint 9e384 1 -> NaN Division_impossible
+dqdvi275 divideint 9.9e384 1 -> NaN Division_impossible
+dqdvi276 divideint 9.99e384 1 -> NaN Division_impossible
+dqdvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
+
+dqdvi280 divideint 0.1 9e-383 -> NaN Division_impossible
+dqdvi281 divideint 0.1 99e-383 -> NaN Division_impossible
+dqdvi282 divideint 0.1 999e-383 -> NaN Division_impossible
+dqdvi283 divideint 0.1 9e-382 -> NaN Division_impossible
+dqdvi284 divideint 0.1 99e-382 -> NaN Division_impossible
+
+-- GD edge cases: lhs smaller than rhs but more digits
+dqdvi301 divideint 0.9 2 -> 0
+dqdvi302 divideint 0.9 2.0 -> 0
+dqdvi303 divideint 0.9 2.1 -> 0
+dqdvi304 divideint 0.9 2.00 -> 0
+dqdvi305 divideint 0.9 2.01 -> 0
+dqdvi306 divideint 0.12 1 -> 0
+dqdvi307 divideint 0.12 1.0 -> 0
+dqdvi308 divideint 0.12 1.00 -> 0
+dqdvi309 divideint 0.12 1.0 -> 0
+dqdvi310 divideint 0.12 1.00 -> 0
+dqdvi311 divideint 0.12 2 -> 0
+dqdvi312 divideint 0.12 2.0 -> 0
+dqdvi313 divideint 0.12 2.1 -> 0
+dqdvi314 divideint 0.12 2.00 -> 0
+dqdvi315 divideint 0.12 2.01 -> 0
+
+-- edge cases of impossible
+dqdvi330 divideint 1234567987654321987654321890123456 10 -> 123456798765432198765432189012345
+dqdvi331 divideint 1234567987654321987654321890123456 1 -> 1234567987654321987654321890123456
+dqdvi332 divideint 1234567987654321987654321890123456 0.1 -> NaN Division_impossible
+dqdvi333 divideint 1234567987654321987654321890123456 0.01 -> NaN Division_impossible
+
+-- overflow and underflow tests [from divide]
+dqdvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
+dqdvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
+dqdvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
+dqdvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
+dqdvi1055 divideint 1e-277 1e+311 -> 0
+dqdvi1056 divideint 1e-277 -1e+311 -> -0
+dqdvi1057 divideint -1e-277 1e+311 -> -0
+dqdvi1058 divideint -1e-277 -1e+311 -> 0
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dqdvi1060 divideint 1e-291 1e+101 -> 0
+dqdvi1061 divideint 1e-291 1e+102 -> 0
+dqdvi1062 divideint 1e-291 1e+103 -> 0
+dqdvi1063 divideint 1e-291 1e+104 -> 0
+dqdvi1064 divideint 1e-291 1e+105 -> 0
+dqdvi1065 divideint 1e-291 1e+106 -> 0
+dqdvi1066 divideint 1e-291 1e+107 -> 0
+dqdvi1067 divideint 1e-291 1e+108 -> 0
+dqdvi1068 divideint 1e-291 1e+109 -> 0
+dqdvi1069 divideint 1e-291 1e+110 -> 0
+
+dqdvi1101 divideint 1.0000E-394 1 -> 0
+dqdvi1102 divideint 1.000E-394 1e+1 -> 0
+dqdvi1103 divideint 1.00E-394 1e+2 -> 0
+
+dqdvi1118 divideint 1E-394 1e+4 -> 0
+dqdvi1119 divideint 3E-394 -1e+5 -> -0
+dqdvi1120 divideint 5E-394 1e+5 -> 0
+
+dqdvi1124 divideint 1E-394 -1e+4 -> -0
+dqdvi1130 divideint 3.0E-394 -1e+5 -> -0
+
+dqdvi1131 divideint 1.0E-199 1e+200 -> 0
+dqdvi1132 divideint 1.0E-199 1e+199 -> 0
+dqdvi1133 divideint 1.0E-199 1e+198 -> 0
+dqdvi1134 divideint 2.0E-199 2e+198 -> 0
+dqdvi1135 divideint 4.0E-199 4e+198 -> 0
+
+-- long operand checks
+dqdvi401 divideint 12345678000 100 -> 123456780
+dqdvi402 divideint 1 12345678000 -> 0
+dqdvi403 divideint 1234567800 10 -> 123456780
+dqdvi404 divideint 1 1234567800 -> 0
+dqdvi405 divideint 1234567890 10 -> 123456789
+dqdvi406 divideint 1 1234567890 -> 0
+dqdvi407 divideint 1234567891 10 -> 123456789
+dqdvi408 divideint 1 1234567891 -> 0
+dqdvi409 divideint 12345678901 100 -> 123456789
+dqdvi410 divideint 1 12345678901 -> 0
+dqdvi411 divideint 1234567896 10 -> 123456789
+dqdvi412 divideint 1 1234567896 -> 0
+dqdvi413 divideint 12345678948 100 -> 123456789
+dqdvi414 divideint 12345678949 100 -> 123456789
+dqdvi415 divideint 12345678950 100 -> 123456789
+dqdvi416 divideint 12345678951 100 -> 123456789
+dqdvi417 divideint 12345678999 100 -> 123456789
+dqdvi441 divideint 12345678000 1 -> 12345678000
+dqdvi442 divideint 1 12345678000 -> 0
+dqdvi443 divideint 1234567800 1 -> 1234567800
+dqdvi444 divideint 1 1234567800 -> 0
+dqdvi445 divideint 1234567890 1 -> 1234567890
+dqdvi446 divideint 1 1234567890 -> 0
+dqdvi447 divideint 1234567891 1 -> 1234567891
+dqdvi448 divideint 1 1234567891 -> 0
+dqdvi449 divideint 12345678901 1 -> 12345678901
+dqdvi450 divideint 1 12345678901 -> 0
+dqdvi451 divideint 1234567896 1 -> 1234567896
+dqdvi452 divideint 1 1234567896 -> 0
+
+-- more zeros, etc.
+dqdvi531 divideint 5.00 1E-3 -> 5000
+dqdvi532 divideint 00.00 0.000 -> NaN Division_undefined
+dqdvi533 divideint 00.00 0E-3 -> NaN Division_undefined
+dqdvi534 divideint 0 -0 -> NaN Division_undefined
+dqdvi535 divideint -0 0 -> NaN Division_undefined
+dqdvi536 divideint -0 -0 -> NaN Division_undefined
+
+dqdvi541 divideint 0 -1 -> -0
+dqdvi542 divideint -0 -1 -> 0
+dqdvi543 divideint 0 1 -> 0
+dqdvi544 divideint -0 1 -> -0
+dqdvi545 divideint -1 0 -> -Infinity Division_by_zero
+dqdvi546 divideint -1 -0 -> Infinity Division_by_zero
+dqdvi547 divideint 1 0 -> Infinity Division_by_zero
+dqdvi548 divideint 1 -0 -> -Infinity Division_by_zero
+
+dqdvi551 divideint 0.0 -1 -> -0
+dqdvi552 divideint -0.0 -1 -> 0
+dqdvi553 divideint 0.0 1 -> 0
+dqdvi554 divideint -0.0 1 -> -0
+dqdvi555 divideint -1.0 0 -> -Infinity Division_by_zero
+dqdvi556 divideint -1.0 -0 -> Infinity Division_by_zero
+dqdvi557 divideint 1.0 0 -> Infinity Division_by_zero
+dqdvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
+
+dqdvi561 divideint 0 -1.0 -> -0
+dqdvi562 divideint -0 -1.0 -> 0
+dqdvi563 divideint 0 1.0 -> 0
+dqdvi564 divideint -0 1.0 -> -0
+dqdvi565 divideint -1 0.0 -> -Infinity Division_by_zero
+dqdvi566 divideint -1 -0.0 -> Infinity Division_by_zero
+dqdvi567 divideint 1 0.0 -> Infinity Division_by_zero
+dqdvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
+
+dqdvi571 divideint 0.0 -1.0 -> -0
+dqdvi572 divideint -0.0 -1.0 -> 0
+dqdvi573 divideint 0.0 1.0 -> 0
+dqdvi574 divideint -0.0 1.0 -> -0
+dqdvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
+dqdvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
+dqdvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
+dqdvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
+
+-- Specials
+dqdvi580 divideint Inf -Inf -> NaN Invalid_operation
+dqdvi581 divideint Inf -1000 -> -Infinity
+dqdvi582 divideint Inf -1 -> -Infinity
+dqdvi583 divideint Inf -0 -> -Infinity
+dqdvi584 divideint Inf 0 -> Infinity
+dqdvi585 divideint Inf 1 -> Infinity
+dqdvi586 divideint Inf 1000 -> Infinity
+dqdvi587 divideint Inf Inf -> NaN Invalid_operation
+dqdvi588 divideint -1000 Inf -> -0
+dqdvi589 divideint -Inf Inf -> NaN Invalid_operation
+dqdvi590 divideint -1 Inf -> -0
+dqdvi591 divideint -0 Inf -> -0
+dqdvi592 divideint 0 Inf -> 0
+dqdvi593 divideint 1 Inf -> 0
+dqdvi594 divideint 1000 Inf -> 0
+dqdvi595 divideint Inf Inf -> NaN Invalid_operation
+
+dqdvi600 divideint -Inf -Inf -> NaN Invalid_operation
+dqdvi601 divideint -Inf -1000 -> Infinity
+dqdvi602 divideint -Inf -1 -> Infinity
+dqdvi603 divideint -Inf -0 -> Infinity
+dqdvi604 divideint -Inf 0 -> -Infinity
+dqdvi605 divideint -Inf 1 -> -Infinity
+dqdvi606 divideint -Inf 1000 -> -Infinity
+dqdvi607 divideint -Inf Inf -> NaN Invalid_operation
+dqdvi608 divideint -1000 Inf -> -0
+dqdvi609 divideint -Inf -Inf -> NaN Invalid_operation
+dqdvi610 divideint -1 -Inf -> 0
+dqdvi611 divideint -0 -Inf -> 0
+dqdvi612 divideint 0 -Inf -> -0
+dqdvi613 divideint 1 -Inf -> -0
+dqdvi614 divideint 1000 -Inf -> -0
+dqdvi615 divideint Inf -Inf -> NaN Invalid_operation
+
+dqdvi621 divideint NaN -Inf -> NaN
+dqdvi622 divideint NaN -1000 -> NaN
+dqdvi623 divideint NaN -1 -> NaN
+dqdvi624 divideint NaN -0 -> NaN
+dqdvi625 divideint NaN 0 -> NaN
+dqdvi626 divideint NaN 1 -> NaN
+dqdvi627 divideint NaN 1000 -> NaN
+dqdvi628 divideint NaN Inf -> NaN
+dqdvi629 divideint NaN NaN -> NaN
+dqdvi630 divideint -Inf NaN -> NaN
+dqdvi631 divideint -1000 NaN -> NaN
+dqdvi632 divideint -1 NaN -> NaN
+dqdvi633 divideint -0 NaN -> NaN
+dqdvi634 divideint 0 NaN -> NaN
+dqdvi635 divideint 1 NaN -> NaN
+dqdvi636 divideint 1000 NaN -> NaN
+dqdvi637 divideint Inf NaN -> NaN
+
+dqdvi641 divideint sNaN -Inf -> NaN Invalid_operation
+dqdvi642 divideint sNaN -1000 -> NaN Invalid_operation
+dqdvi643 divideint sNaN -1 -> NaN Invalid_operation
+dqdvi644 divideint sNaN -0 -> NaN Invalid_operation
+dqdvi645 divideint sNaN 0 -> NaN Invalid_operation
+dqdvi646 divideint sNaN 1 -> NaN Invalid_operation
+dqdvi647 divideint sNaN 1000 -> NaN Invalid_operation
+dqdvi648 divideint sNaN NaN -> NaN Invalid_operation
+dqdvi649 divideint sNaN sNaN -> NaN Invalid_operation
+dqdvi650 divideint NaN sNaN -> NaN Invalid_operation
+dqdvi651 divideint -Inf sNaN -> NaN Invalid_operation
+dqdvi652 divideint -1000 sNaN -> NaN Invalid_operation
+dqdvi653 divideint -1 sNaN -> NaN Invalid_operation
+dqdvi654 divideint -0 sNaN -> NaN Invalid_operation
+dqdvi655 divideint 0 sNaN -> NaN Invalid_operation
+dqdvi656 divideint 1 sNaN -> NaN Invalid_operation
+dqdvi657 divideint 1000 sNaN -> NaN Invalid_operation
+dqdvi658 divideint Inf sNaN -> NaN Invalid_operation
+dqdvi659 divideint NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqdvi661 divideint NaN9 -Inf -> NaN9
+dqdvi662 divideint NaN8 1000 -> NaN8
+dqdvi663 divideint NaN7 Inf -> NaN7
+dqdvi664 divideint -NaN6 NaN5 -> -NaN6
+dqdvi665 divideint -Inf NaN4 -> NaN4
+dqdvi666 divideint -1000 NaN3 -> NaN3
+dqdvi667 divideint Inf -NaN2 -> -NaN2
+
+dqdvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqdvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
+dqdvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
+dqdvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
+dqdvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
+dqdvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
+dqdvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
+dqdvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
+dqdvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
+
+-- Gyuris example
+dqdvi700 divideint 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 0
+
+-- Null tests
+dqdvi900 divideint 10 # -> NaN Invalid_operation
+dqdvi901 divideint # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqEncode.decTest b/Lib/test/decimaltestdata/dqEncode.decTest
index 49edf5b280..8c5d7b9b30 100644
--- a/Lib/test/decimaltestdata/dqEncode.decTest
+++ b/Lib/test/decimaltestdata/dqEncode.decTest
@@ -1,477 +1,477 @@
-------------------------------------------------------------------------
--- dqEncode.decTest -- decimal sixteen-byte format testcases --
--- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
--- [Previously called decimal128.decTest]
-version: 2.59
-
--- This set of tests is for the sixteen-byte concrete representation.
--- Its characteristics are:
---
--- 1 bit sign
--- 5 bits combination field
--- 12 bits exponent continuation
--- 110 bits coefficient continuation
---
--- Total exponent length 14 bits
--- Total coefficient length 114 bits (34 digits)
---
--- Elimit = 12287 (maximum encoded exponent)
--- Emax = 6144 (largest exponent value)
--- Emin = -6143 (smallest exponent value)
--- bias = 6176 (subtracted from encoded exponent) = -Etiny
-
--- The testcases here have only exactly representable data on the
--- 'left-hand-side'; rounding from strings is tested in 'base'
--- testcase groups.
-
-extended: 1
-clamp: 1
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
-
--- General testcases
--- (mostly derived from the Strawman 4 document and examples)
-decq001 apply #A20780000000000000000000000003D0 -> -7.50
-decq002 apply -7.50 -> #A20780000000000000000000000003D0
--- derivative canonical plain strings
-decq003 apply #A20840000000000000000000000003D0 -> -7.50E+3
-decq004 apply -7.50E+3 -> #A20840000000000000000000000003D0
-decq005 apply #A20800000000000000000000000003D0 -> -750
-decq006 apply -750 -> #A20800000000000000000000000003D0
-decq007 apply #A207c0000000000000000000000003D0 -> -75.0
-decq008 apply -75.0 -> #A207c0000000000000000000000003D0
-decq009 apply #A20740000000000000000000000003D0 -> -0.750
-decq010 apply -0.750 -> #A20740000000000000000000000003D0
-decq011 apply #A20700000000000000000000000003D0 -> -0.0750
-decq012 apply -0.0750 -> #A20700000000000000000000000003D0
-decq013 apply #A20680000000000000000000000003D0 -> -0.000750
-decq014 apply -0.000750 -> #A20680000000000000000000000003D0
-decq015 apply #A20600000000000000000000000003D0 -> -0.00000750
-decq016 apply -0.00000750 -> #A20600000000000000000000000003D0
-decq017 apply #A205c0000000000000000000000003D0 -> -7.50E-7
-decq018 apply -7.50E-7 -> #A205c0000000000000000000000003D0
-
--- Normality
-decq020 apply 1234567890123456789012345678901234 -> #2608134b9c1e28e56f3c127177823534
-decq021 apply -1234567890123456789012345678901234 -> #a608134b9c1e28e56f3c127177823534
-decq022 apply 1111111111111111111111111111111111 -> #26080912449124491244912449124491
-
--- Nmax and similar
-decq031 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-decq032 apply #77ffcff3fcff3fcff3fcff3fcff3fcff -> 9.999999999999999999999999999999999E+6144
-decq033 apply 1.234567890123456789012345678901234E+6144 -> #47ffd34b9c1e28e56f3c127177823534
-decq034 apply #47ffd34b9c1e28e56f3c127177823534 -> 1.234567890123456789012345678901234E+6144
--- fold-downs (more below)
-decq035 apply 1.23E+6144 -> #47ffd300000000000000000000000000 Clamped
-decq036 apply #47ffd300000000000000000000000000 -> 1.230000000000000000000000000000000E+6144
-decq037 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped
-decq038 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144
-
-decq051 apply 12345 -> #220800000000000000000000000049c5
-decq052 apply #220800000000000000000000000049c5 -> 12345
-decq053 apply 1234 -> #22080000000000000000000000000534
-decq054 apply #22080000000000000000000000000534 -> 1234
-decq055 apply 123 -> #220800000000000000000000000000a3
-decq056 apply #220800000000000000000000000000a3 -> 123
-decq057 apply 12 -> #22080000000000000000000000000012
-decq058 apply #22080000000000000000000000000012 -> 12
-decq059 apply 1 -> #22080000000000000000000000000001
-decq060 apply #22080000000000000000000000000001 -> 1
-decq061 apply 1.23 -> #220780000000000000000000000000a3
-decq062 apply #220780000000000000000000000000a3 -> 1.23
-decq063 apply 123.45 -> #220780000000000000000000000049c5
-decq064 apply #220780000000000000000000000049c5 -> 123.45
-
--- Nmin and below
-decq071 apply 1E-6143 -> #00084000000000000000000000000001
-decq072 apply #00084000000000000000000000000001 -> 1E-6143
-decq073 apply 1.000000000000000000000000000000000E-6143 -> #04000000000000000000000000000000
-decq074 apply #04000000000000000000000000000000 -> 1.000000000000000000000000000000000E-6143
-decq075 apply 1.000000000000000000000000000000001E-6143 -> #04000000000000000000000000000001
-decq076 apply #04000000000000000000000000000001 -> 1.000000000000000000000000000000001E-6143
-
-decq077 apply 0.100000000000000000000000000000000E-6143 -> #00000800000000000000000000000000 Subnormal
-decq078 apply #00000800000000000000000000000000 -> 1.00000000000000000000000000000000E-6144 Subnormal
-decq079 apply 0.000000000000000000000000000000010E-6143 -> #00000000000000000000000000000010 Subnormal
-decq080 apply #00000000000000000000000000000010 -> 1.0E-6175 Subnormal
-decq081 apply 0.00000000000000000000000000000001E-6143 -> #00004000000000000000000000000001 Subnormal
-decq082 apply #00004000000000000000000000000001 -> 1E-6175 Subnormal
-decq083 apply 0.000000000000000000000000000000001E-6143 -> #00000000000000000000000000000001 Subnormal
-decq084 apply #00000000000000000000000000000001 -> 1E-6176 Subnormal
-
--- underflows cannot be tested for simple copies, check edge cases
-decq090 apply 1e-6176 -> #00000000000000000000000000000001 Subnormal
-decq100 apply 999999999999999999999999999999999e-6176 -> #00000ff3fcff3fcff3fcff3fcff3fcff Subnormal
-
--- same again, negatives
--- Nmax and similar
-decq122 apply -9.999999999999999999999999999999999E+6144 -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
-decq123 apply #f7ffcff3fcff3fcff3fcff3fcff3fcff -> -9.999999999999999999999999999999999E+6144
-decq124 apply -1.234567890123456789012345678901234E+6144 -> #c7ffd34b9c1e28e56f3c127177823534
-decq125 apply #c7ffd34b9c1e28e56f3c127177823534 -> -1.234567890123456789012345678901234E+6144
--- fold-downs (more below)
-decq130 apply -1.23E+6144 -> #c7ffd300000000000000000000000000 Clamped
-decq131 apply #c7ffd300000000000000000000000000 -> -1.230000000000000000000000000000000E+6144
-decq132 apply -1E+6144 -> #c7ffc000000000000000000000000000 Clamped
-decq133 apply #c7ffc000000000000000000000000000 -> -1.000000000000000000000000000000000E+6144
-
-decq151 apply -12345 -> #a20800000000000000000000000049c5
-decq152 apply #a20800000000000000000000000049c5 -> -12345
-decq153 apply -1234 -> #a2080000000000000000000000000534
-decq154 apply #a2080000000000000000000000000534 -> -1234
-decq155 apply -123 -> #a20800000000000000000000000000a3
-decq156 apply #a20800000000000000000000000000a3 -> -123
-decq157 apply -12 -> #a2080000000000000000000000000012
-decq158 apply #a2080000000000000000000000000012 -> -12
-decq159 apply -1 -> #a2080000000000000000000000000001
-decq160 apply #a2080000000000000000000000000001 -> -1
-decq161 apply -1.23 -> #a20780000000000000000000000000a3
-decq162 apply #a20780000000000000000000000000a3 -> -1.23
-decq163 apply -123.45 -> #a20780000000000000000000000049c5
-decq164 apply #a20780000000000000000000000049c5 -> -123.45
-
--- Nmin and below
-decq171 apply -1E-6143 -> #80084000000000000000000000000001
-decq172 apply #80084000000000000000000000000001 -> -1E-6143
-decq173 apply -1.000000000000000000000000000000000E-6143 -> #84000000000000000000000000000000
-decq174 apply #84000000000000000000000000000000 -> -1.000000000000000000000000000000000E-6143
-decq175 apply -1.000000000000000000000000000000001E-6143 -> #84000000000000000000000000000001
-decq176 apply #84000000000000000000000000000001 -> -1.000000000000000000000000000000001E-6143
-
-decq177 apply -0.100000000000000000000000000000000E-6143 -> #80000800000000000000000000000000 Subnormal
-decq178 apply #80000800000000000000000000000000 -> -1.00000000000000000000000000000000E-6144 Subnormal
-decq179 apply -0.000000000000000000000000000000010E-6143 -> #80000000000000000000000000000010 Subnormal
-decq180 apply #80000000000000000000000000000010 -> -1.0E-6175 Subnormal
-decq181 apply -0.00000000000000000000000000000001E-6143 -> #80004000000000000000000000000001 Subnormal
-decq182 apply #80004000000000000000000000000001 -> -1E-6175 Subnormal
-decq183 apply -0.000000000000000000000000000000001E-6143 -> #80000000000000000000000000000001 Subnormal
-decq184 apply #80000000000000000000000000000001 -> -1E-6176 Subnormal
-
--- underflow edge cases
-decq190 apply -1e-6176 -> #80000000000000000000000000000001 Subnormal
-decq200 apply -999999999999999999999999999999999e-6176 -> #80000ff3fcff3fcff3fcff3fcff3fcff Subnormal
-
--- zeros
-decq400 apply 0E-8000 -> #00000000000000000000000000000000 Clamped
-decq401 apply 0E-6177 -> #00000000000000000000000000000000 Clamped
-decq402 apply 0E-6176 -> #00000000000000000000000000000000
-decq403 apply #00000000000000000000000000000000 -> 0E-6176
-decq404 apply 0.000000000000000000000000000000000E-6143 -> #00000000000000000000000000000000
-decq405 apply #00000000000000000000000000000000 -> 0E-6176
-decq406 apply 0E-2 -> #22078000000000000000000000000000
-decq407 apply #22078000000000000000000000000000 -> 0.00
-decq408 apply 0 -> #22080000000000000000000000000000
-decq409 apply #22080000000000000000000000000000 -> 0
-decq410 apply 0E+3 -> #2208c000000000000000000000000000
-decq411 apply #2208c000000000000000000000000000 -> 0E+3
-decq412 apply 0E+6111 -> #43ffc000000000000000000000000000
-decq413 apply #43ffc000000000000000000000000000 -> 0E+6111
--- clamped zeros...
-decq414 apply 0E+6112 -> #43ffc000000000000000000000000000 Clamped
-decq415 apply #43ffc000000000000000000000000000 -> 0E+6111
-decq416 apply 0E+6144 -> #43ffc000000000000000000000000000 Clamped
-decq417 apply #43ffc000000000000000000000000000 -> 0E+6111
-decq418 apply 0E+8000 -> #43ffc000000000000000000000000000 Clamped
-decq419 apply #43ffc000000000000000000000000000 -> 0E+6111
-
--- negative zeros
-decq420 apply -0E-8000 -> #80000000000000000000000000000000 Clamped
-decq421 apply -0E-6177 -> #80000000000000000000000000000000 Clamped
-decq422 apply -0E-6176 -> #80000000000000000000000000000000
-decq423 apply #80000000000000000000000000000000 -> -0E-6176
-decq424 apply -0.000000000000000000000000000000000E-6143 -> #80000000000000000000000000000000
-decq425 apply #80000000000000000000000000000000 -> -0E-6176
-decq426 apply -0E-2 -> #a2078000000000000000000000000000
-decq427 apply #a2078000000000000000000000000000 -> -0.00
-decq428 apply -0 -> #a2080000000000000000000000000000
-decq429 apply #a2080000000000000000000000000000 -> -0
-decq430 apply -0E+3 -> #a208c000000000000000000000000000
-decq431 apply #a208c000000000000000000000000000 -> -0E+3
-decq432 apply -0E+6111 -> #c3ffc000000000000000000000000000
-decq433 apply #c3ffc000000000000000000000000000 -> -0E+6111
--- clamped zeros...
-decq434 apply -0E+6112 -> #c3ffc000000000000000000000000000 Clamped
-decq435 apply #c3ffc000000000000000000000000000 -> -0E+6111
-decq436 apply -0E+6144 -> #c3ffc000000000000000000000000000 Clamped
-decq437 apply #c3ffc000000000000000000000000000 -> -0E+6111
-decq438 apply -0E+8000 -> #c3ffc000000000000000000000000000 Clamped
-decq439 apply #c3ffc000000000000000000000000000 -> -0E+6111
-
--- exponent lengths
-decq440 apply #22080000000000000000000000000007 -> 7
-decq441 apply 7 -> #22080000000000000000000000000007
-decq442 apply #220a4000000000000000000000000007 -> 7E+9
-decq443 apply 7E+9 -> #220a4000000000000000000000000007
-decq444 apply #2220c000000000000000000000000007 -> 7E+99
-decq445 apply 7E+99 -> #2220c000000000000000000000000007
-decq446 apply #2301c000000000000000000000000007 -> 7E+999
-decq447 apply 7E+999 -> #2301c000000000000000000000000007
-decq448 apply #43e3c000000000000000000000000007 -> 7E+5999
-decq449 apply 7E+5999 -> #43e3c000000000000000000000000007
-
--- Specials
-decq500 apply Infinity -> #78000000000000000000000000000000
-decq501 apply #78787878787878787878787878787878 -> #78000000000000000000000000000000
-decq502 apply #78000000000000000000000000000000 -> Infinity
-decq503 apply #79797979797979797979797979797979 -> #78000000000000000000000000000000
-decq504 apply #79000000000000000000000000000000 -> Infinity
-decq505 apply #7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #78000000000000000000000000000000
-decq506 apply #7a000000000000000000000000000000 -> Infinity
-decq507 apply #7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #78000000000000000000000000000000
-decq508 apply #7b000000000000000000000000000000 -> Infinity
-
-decq509 apply NaN -> #7c000000000000000000000000000000
-decq510 apply #7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #7c003c7c7c7c7c7c7c7c7c7c7c7c7c7c
-decq511 apply #7c000000000000000000000000000000 -> NaN
-decq512 apply #7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #7c003d7d7d7d7d7d7d7d7d7d7d7d7d7d
-decq513 apply #7d000000000000000000000000000000 -> NaN
-decq514 apply #7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #7e003e7e7c7e7e7e7e7c7e7e7e7e7c7e
-decq515 apply #7e000000000000000000000000000000 -> sNaN
-decq516 apply #7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #7e003f7f7c7f7f7f7f7c7f7f7f7f7c7f
-decq517 apply #7f000000000000000000000000000000 -> sNaN
-decq518 apply #7fffffffffffffffffffffffffffffff -> sNaN999999999999999999999999999999999
-decq519 apply #7fffffffffffffffffffffffffffffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-
-decq520 apply -Infinity -> #f8000000000000000000000000000000
-decq521 apply #f8787878787878787878787878787878 -> #f8000000000000000000000000000000
-decq522 apply #f8000000000000000000000000000000 -> -Infinity
-decq523 apply #f9797979797979797979797979797979 -> #f8000000000000000000000000000000
-decq524 apply #f9000000000000000000000000000000 -> -Infinity
-decq525 apply #fa7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #f8000000000000000000000000000000
-decq526 apply #fa000000000000000000000000000000 -> -Infinity
-decq527 apply #fb7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #f8000000000000000000000000000000
-decq528 apply #fb000000000000000000000000000000 -> -Infinity
-
-decq529 apply -NaN -> #fc000000000000000000000000000000
-decq530 apply #fc7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #fc003c7c7c7c7c7c7c7c7c7c7c7c7c7c
-decq531 apply #fc000000000000000000000000000000 -> -NaN
-decq532 apply #fd7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #fc003d7d7d7d7d7d7d7d7d7d7d7d7d7d
-decq533 apply #fd000000000000000000000000000000 -> -NaN
-decq534 apply #fe7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #fe003e7e7c7e7e7e7e7c7e7e7e7e7c7e
-decq535 apply #fe000000000000000000000000000000 -> -sNaN
-decq536 apply #ff7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #fe003f7f7c7f7f7f7f7c7f7f7f7f7c7f
-decq537 apply #ff000000000000000000000000000000 -> -sNaN
-decq538 apply #ffffffffffffffffffffffffffffffff -> -sNaN999999999999999999999999999999999
-decq539 apply #ffffffffffffffffffffffffffffffff -> #fe000ff3fcff3fcff3fcff3fcff3fcff
-
-decq540 apply NaN -> #7c000000000000000000000000000000
-decq541 apply NaN0 -> #7c000000000000000000000000000000
-decq542 apply NaN1 -> #7c000000000000000000000000000001
-decq543 apply NaN12 -> #7c000000000000000000000000000012
-decq544 apply NaN79 -> #7c000000000000000000000000000079
-decq545 apply NaN12345 -> #7c0000000000000000000000000049c5
-decq546 apply NaN123456 -> #7c000000000000000000000000028e56
-decq547 apply NaN799799 -> #7c0000000000000000000000000f7fdf
-decq548 apply NaN799799799799799799799799799799799 -> #7c003dff7fdff7fdff7fdff7fdff7fdf
-decq549 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-decq550 apply 9999999999999999999999999999999999 -> #6e080ff3fcff3fcff3fcff3fcff3fcff
-
--- fold-down full sequence
-decq601 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped
-decq602 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144
-decq603 apply 1E+6143 -> #43ffc800000000000000000000000000 Clamped
-decq604 apply #43ffc800000000000000000000000000 -> 1.00000000000000000000000000000000E+6143
-decq605 apply 1E+6142 -> #43ffc100000000000000000000000000 Clamped
-decq606 apply #43ffc100000000000000000000000000 -> 1.0000000000000000000000000000000E+6142
-decq607 apply 1E+6141 -> #43ffc010000000000000000000000000 Clamped
-decq608 apply #43ffc010000000000000000000000000 -> 1.000000000000000000000000000000E+6141
-decq609 apply 1E+6140 -> #43ffc002000000000000000000000000 Clamped
-decq610 apply #43ffc002000000000000000000000000 -> 1.00000000000000000000000000000E+6140
-decq611 apply 1E+6139 -> #43ffc000400000000000000000000000 Clamped
-decq612 apply #43ffc000400000000000000000000000 -> 1.0000000000000000000000000000E+6139
-decq613 apply 1E+6138 -> #43ffc000040000000000000000000000 Clamped
-decq614 apply #43ffc000040000000000000000000000 -> 1.000000000000000000000000000E+6138
-decq615 apply 1E+6137 -> #43ffc000008000000000000000000000 Clamped
-decq616 apply #43ffc000008000000000000000000000 -> 1.00000000000000000000000000E+6137
-decq617 apply 1E+6136 -> #43ffc000001000000000000000000000 Clamped
-decq618 apply #43ffc000001000000000000000000000 -> 1.0000000000000000000000000E+6136
-decq619 apply 1E+6135 -> #43ffc000000100000000000000000000 Clamped
-decq620 apply #43ffc000000100000000000000000000 -> 1.000000000000000000000000E+6135
-decq621 apply 1E+6134 -> #43ffc000000020000000000000000000 Clamped
-decq622 apply #43ffc000000020000000000000000000 -> 1.00000000000000000000000E+6134
-decq623 apply 1E+6133 -> #43ffc000000004000000000000000000 Clamped
-decq624 apply #43ffc000000004000000000000000000 -> 1.0000000000000000000000E+6133
-decq625 apply 1E+6132 -> #43ffc000000000400000000000000000 Clamped
-decq626 apply #43ffc000000000400000000000000000 -> 1.000000000000000000000E+6132
-decq627 apply 1E+6131 -> #43ffc000000000080000000000000000 Clamped
-decq628 apply #43ffc000000000080000000000000000 -> 1.00000000000000000000E+6131
-decq629 apply 1E+6130 -> #43ffc000000000010000000000000000 Clamped
-decq630 apply #43ffc000000000010000000000000000 -> 1.0000000000000000000E+6130
-decq631 apply 1E+6129 -> #43ffc000000000001000000000000000 Clamped
-decq632 apply #43ffc000000000001000000000000000 -> 1.000000000000000000E+6129
-decq633 apply 1E+6128 -> #43ffc000000000000200000000000000 Clamped
-decq634 apply #43ffc000000000000200000000000000 -> 1.00000000000000000E+6128
-decq635 apply 1E+6127 -> #43ffc000000000000040000000000000 Clamped
-decq636 apply #43ffc000000000000040000000000000 -> 1.0000000000000000E+6127
-decq637 apply 1E+6126 -> #43ffc000000000000004000000000000 Clamped
-decq638 apply #43ffc000000000000004000000000000 -> 1.000000000000000E+6126
-decq639 apply 1E+6125 -> #43ffc000000000000000800000000000 Clamped
-decq640 apply #43ffc000000000000000800000000000 -> 1.00000000000000E+6125
-decq641 apply 1E+6124 -> #43ffc000000000000000100000000000 Clamped
-decq642 apply #43ffc000000000000000100000000000 -> 1.0000000000000E+6124
-decq643 apply 1E+6123 -> #43ffc000000000000000010000000000 Clamped
-decq644 apply #43ffc000000000000000010000000000 -> 1.000000000000E+6123
-decq645 apply 1E+6122 -> #43ffc000000000000000002000000000 Clamped
-decq646 apply #43ffc000000000000000002000000000 -> 1.00000000000E+6122
-decq647 apply 1E+6121 -> #43ffc000000000000000000400000000 Clamped
-decq648 apply #43ffc000000000000000000400000000 -> 1.0000000000E+6121
-decq649 apply 1E+6120 -> #43ffc000000000000000000040000000 Clamped
-decq650 apply #43ffc000000000000000000040000000 -> 1.000000000E+6120
-decq651 apply 1E+6119 -> #43ffc000000000000000000008000000 Clamped
-decq652 apply #43ffc000000000000000000008000000 -> 1.00000000E+6119
-decq653 apply 1E+6118 -> #43ffc000000000000000000001000000 Clamped
-decq654 apply #43ffc000000000000000000001000000 -> 1.0000000E+6118
-decq655 apply 1E+6117 -> #43ffc000000000000000000000100000 Clamped
-decq656 apply #43ffc000000000000000000000100000 -> 1.000000E+6117
-decq657 apply 1E+6116 -> #43ffc000000000000000000000020000 Clamped
-decq658 apply #43ffc000000000000000000000020000 -> 1.00000E+6116
-decq659 apply 1E+6115 -> #43ffc000000000000000000000004000 Clamped
-decq660 apply #43ffc000000000000000000000004000 -> 1.0000E+6115
-decq661 apply 1E+6114 -> #43ffc000000000000000000000000400 Clamped
-decq662 apply #43ffc000000000000000000000000400 -> 1.000E+6114
-decq663 apply 1E+6113 -> #43ffc000000000000000000000000080 Clamped
-decq664 apply #43ffc000000000000000000000000080 -> 1.00E+6113
-decq665 apply 1E+6112 -> #43ffc000000000000000000000000010 Clamped
-decq666 apply #43ffc000000000000000000000000010 -> 1.0E+6112
-decq667 apply 1E+6111 -> #43ffc000000000000000000000000001
-decq668 apply #43ffc000000000000000000000000001 -> 1E+6111
-decq669 apply 1E+6110 -> #43ff8000000000000000000000000001
-decq670 apply #43ff8000000000000000000000000001 -> 1E+6110
-
--- Selected DPD codes
-decq700 apply #22080000000000000000000000000000 -> 0
-decq701 apply #22080000000000000000000000000009 -> 9
-decq702 apply #22080000000000000000000000000010 -> 10
-decq703 apply #22080000000000000000000000000019 -> 19
-decq704 apply #22080000000000000000000000000020 -> 20
-decq705 apply #22080000000000000000000000000029 -> 29
-decq706 apply #22080000000000000000000000000030 -> 30
-decq707 apply #22080000000000000000000000000039 -> 39
-decq708 apply #22080000000000000000000000000040 -> 40
-decq709 apply #22080000000000000000000000000049 -> 49
-decq710 apply #22080000000000000000000000000050 -> 50
-decq711 apply #22080000000000000000000000000059 -> 59
-decq712 apply #22080000000000000000000000000060 -> 60
-decq713 apply #22080000000000000000000000000069 -> 69
-decq714 apply #22080000000000000000000000000070 -> 70
-decq715 apply #22080000000000000000000000000071 -> 71
-decq716 apply #22080000000000000000000000000072 -> 72
-decq717 apply #22080000000000000000000000000073 -> 73
-decq718 apply #22080000000000000000000000000074 -> 74
-decq719 apply #22080000000000000000000000000075 -> 75
-decq720 apply #22080000000000000000000000000076 -> 76
-decq721 apply #22080000000000000000000000000077 -> 77
-decq722 apply #22080000000000000000000000000078 -> 78
-decq723 apply #22080000000000000000000000000079 -> 79
-
-decq730 apply #2208000000000000000000000000029e -> 994
-decq731 apply #2208000000000000000000000000029f -> 995
-decq732 apply #220800000000000000000000000002a0 -> 520
-decq733 apply #220800000000000000000000000002a1 -> 521
-
--- DPD: one of each of the huffman groups
-decq740 apply #220800000000000000000000000003f7 -> 777
-decq741 apply #220800000000000000000000000003f8 -> 778
-decq742 apply #220800000000000000000000000003eb -> 787
-decq743 apply #2208000000000000000000000000037d -> 877
-decq744 apply #2208000000000000000000000000039f -> 997
-decq745 apply #220800000000000000000000000003bf -> 979
-decq746 apply #220800000000000000000000000003df -> 799
-decq747 apply #2208000000000000000000000000006e -> 888
-
-
--- DPD all-highs cases (includes the 24 redundant codes)
-decq750 apply #2208000000000000000000000000006e -> 888
-decq751 apply #2208000000000000000000000000016e -> 888
-decq752 apply #2208000000000000000000000000026e -> 888
-decq753 apply #2208000000000000000000000000036e -> 888
-decq754 apply #2208000000000000000000000000006f -> 889
-decq755 apply #2208000000000000000000000000016f -> 889
-decq756 apply #2208000000000000000000000000026f -> 889
-decq757 apply #2208000000000000000000000000036f -> 889
-
-decq760 apply #2208000000000000000000000000007e -> 898
-decq761 apply #2208000000000000000000000000017e -> 898
-decq762 apply #2208000000000000000000000000027e -> 898
-decq763 apply #2208000000000000000000000000037e -> 898
-decq764 apply #2208000000000000000000000000007f -> 899
-decq765 apply #2208000000000000000000000000017f -> 899
-decq766 apply #2208000000000000000000000000027f -> 899
-decq767 apply #2208000000000000000000000000037f -> 899
-
-decq770 apply #220800000000000000000000000000ee -> 988
-decq771 apply #220800000000000000000000000001ee -> 988
-decq772 apply #220800000000000000000000000002ee -> 988
-decq773 apply #220800000000000000000000000003ee -> 988
-decq774 apply #220800000000000000000000000000ef -> 989
-decq775 apply #220800000000000000000000000001ef -> 989
-decq776 apply #220800000000000000000000000002ef -> 989
-decq777 apply #220800000000000000000000000003ef -> 989
-
-decq780 apply #220800000000000000000000000000fe -> 998
-decq781 apply #220800000000000000000000000001fe -> 998
-decq782 apply #220800000000000000000000000002fe -> 998
-decq783 apply #220800000000000000000000000003fe -> 998
-decq784 apply #220800000000000000000000000000ff -> 999
-decq785 apply #220800000000000000000000000001ff -> 999
-decq786 apply #220800000000000000000000000002ff -> 999
-decq787 apply #220800000000000000000000000003ff -> 999
-
--- Miscellaneous (testers' queries, etc.)
-
-decq790 apply #2208000000000000000000000000c000 -> 30000
-decq791 apply #22080000000000000000000000007800 -> 890000
-decq792 apply 30000 -> #2208000000000000000000000000c000
-decq793 apply 890000 -> #22080000000000000000000000007800
-
--- values around [u]int32 edges (zeros done earlier)
-decq800 apply -2147483646 -> #a208000000000000000000008c78af46
-decq801 apply -2147483647 -> #a208000000000000000000008c78af47
-decq802 apply -2147483648 -> #a208000000000000000000008c78af48
-decq803 apply -2147483649 -> #a208000000000000000000008c78af49
-decq804 apply 2147483646 -> #2208000000000000000000008c78af46
-decq805 apply 2147483647 -> #2208000000000000000000008c78af47
-decq806 apply 2147483648 -> #2208000000000000000000008c78af48
-decq807 apply 2147483649 -> #2208000000000000000000008c78af49
-decq808 apply 4294967294 -> #22080000000000000000000115afb55a
-decq809 apply 4294967295 -> #22080000000000000000000115afb55b
-decq810 apply 4294967296 -> #22080000000000000000000115afb57a
-decq811 apply 4294967297 -> #22080000000000000000000115afb57b
-
-decq820 apply #a208000000000000000000008c78af46 -> -2147483646
-decq821 apply #a208000000000000000000008c78af47 -> -2147483647
-decq822 apply #a208000000000000000000008c78af48 -> -2147483648
-decq823 apply #a208000000000000000000008c78af49 -> -2147483649
-decq824 apply #2208000000000000000000008c78af46 -> 2147483646
-decq825 apply #2208000000000000000000008c78af47 -> 2147483647
-decq826 apply #2208000000000000000000008c78af48 -> 2147483648
-decq827 apply #2208000000000000000000008c78af49 -> 2147483649
-decq828 apply #22080000000000000000000115afb55a -> 4294967294
-decq829 apply #22080000000000000000000115afb55b -> 4294967295
-decq830 apply #22080000000000000000000115afb57a -> 4294967296
-decq831 apply #22080000000000000000000115afb57b -> 4294967297
-
--- VG testcase
-decq840 apply #2080000000000000F294000000172636 -> 8.81125000000001349436E-1548
-decq841 apply #20800000000000008000000000000000 -> 8.000000000000000000E-1550
-decq842 apply #1EF98490000000010F6E4E0000000000 -> 7.049000000000010795488000000000000E-3097
-decq843 multiply #20800000000000008000000000000000 #2080000000000000F294000000172636 -> #1EF98490000000010F6E4E0000000000 Rounded
-
+------------------------------------------------------------------------
+-- dqEncode.decTest -- decimal sixteen-byte format testcases --
+-- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+-- [Previously called decimal128.decTest]
+version: 2.59
+
+-- This set of tests is for the sixteen-byte concrete representation.
+-- Its characteristics are:
+--
+-- 1 bit sign
+-- 5 bits combination field
+-- 12 bits exponent continuation
+-- 110 bits coefficient continuation
+--
+-- Total exponent length 14 bits
+-- Total coefficient length 114 bits (34 digits)
+--
+-- Elimit = 12287 (maximum encoded exponent)
+-- Emax = 6144 (largest exponent value)
+-- Emin = -6143 (smallest exponent value)
+-- bias = 6176 (subtracted from encoded exponent) = -Etiny
+
+-- The testcases here have only exactly representable data on the
+-- 'left-hand-side'; rounding from strings is tested in 'base'
+-- testcase groups.
+
+extended: 1
+clamp: 1
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+
+-- General testcases
+-- (mostly derived from the Strawman 4 document and examples)
+decq001 apply #A20780000000000000000000000003D0 -> -7.50
+decq002 apply -7.50 -> #A20780000000000000000000000003D0
+-- derivative canonical plain strings
+decq003 apply #A20840000000000000000000000003D0 -> -7.50E+3
+decq004 apply -7.50E+3 -> #A20840000000000000000000000003D0
+decq005 apply #A20800000000000000000000000003D0 -> -750
+decq006 apply -750 -> #A20800000000000000000000000003D0
+decq007 apply #A207c0000000000000000000000003D0 -> -75.0
+decq008 apply -75.0 -> #A207c0000000000000000000000003D0
+decq009 apply #A20740000000000000000000000003D0 -> -0.750
+decq010 apply -0.750 -> #A20740000000000000000000000003D0
+decq011 apply #A20700000000000000000000000003D0 -> -0.0750
+decq012 apply -0.0750 -> #A20700000000000000000000000003D0
+decq013 apply #A20680000000000000000000000003D0 -> -0.000750
+decq014 apply -0.000750 -> #A20680000000000000000000000003D0
+decq015 apply #A20600000000000000000000000003D0 -> -0.00000750
+decq016 apply -0.00000750 -> #A20600000000000000000000000003D0
+decq017 apply #A205c0000000000000000000000003D0 -> -7.50E-7
+decq018 apply -7.50E-7 -> #A205c0000000000000000000000003D0
+
+-- Normality
+decq020 apply 1234567890123456789012345678901234 -> #2608134b9c1e28e56f3c127177823534
+decq021 apply -1234567890123456789012345678901234 -> #a608134b9c1e28e56f3c127177823534
+decq022 apply 1111111111111111111111111111111111 -> #26080912449124491244912449124491
+
+-- Nmax and similar
+decq031 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+decq032 apply #77ffcff3fcff3fcff3fcff3fcff3fcff -> 9.999999999999999999999999999999999E+6144
+decq033 apply 1.234567890123456789012345678901234E+6144 -> #47ffd34b9c1e28e56f3c127177823534
+decq034 apply #47ffd34b9c1e28e56f3c127177823534 -> 1.234567890123456789012345678901234E+6144
+-- fold-downs (more below)
+decq035 apply 1.23E+6144 -> #47ffd300000000000000000000000000 Clamped
+decq036 apply #47ffd300000000000000000000000000 -> 1.230000000000000000000000000000000E+6144
+decq037 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped
+decq038 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144
+
+decq051 apply 12345 -> #220800000000000000000000000049c5
+decq052 apply #220800000000000000000000000049c5 -> 12345
+decq053 apply 1234 -> #22080000000000000000000000000534
+decq054 apply #22080000000000000000000000000534 -> 1234
+decq055 apply 123 -> #220800000000000000000000000000a3
+decq056 apply #220800000000000000000000000000a3 -> 123
+decq057 apply 12 -> #22080000000000000000000000000012
+decq058 apply #22080000000000000000000000000012 -> 12
+decq059 apply 1 -> #22080000000000000000000000000001
+decq060 apply #22080000000000000000000000000001 -> 1
+decq061 apply 1.23 -> #220780000000000000000000000000a3
+decq062 apply #220780000000000000000000000000a3 -> 1.23
+decq063 apply 123.45 -> #220780000000000000000000000049c5
+decq064 apply #220780000000000000000000000049c5 -> 123.45
+
+-- Nmin and below
+decq071 apply 1E-6143 -> #00084000000000000000000000000001
+decq072 apply #00084000000000000000000000000001 -> 1E-6143
+decq073 apply 1.000000000000000000000000000000000E-6143 -> #04000000000000000000000000000000
+decq074 apply #04000000000000000000000000000000 -> 1.000000000000000000000000000000000E-6143
+decq075 apply 1.000000000000000000000000000000001E-6143 -> #04000000000000000000000000000001
+decq076 apply #04000000000000000000000000000001 -> 1.000000000000000000000000000000001E-6143
+
+decq077 apply 0.100000000000000000000000000000000E-6143 -> #00000800000000000000000000000000 Subnormal
+decq078 apply #00000800000000000000000000000000 -> 1.00000000000000000000000000000000E-6144 Subnormal
+decq079 apply 0.000000000000000000000000000000010E-6143 -> #00000000000000000000000000000010 Subnormal
+decq080 apply #00000000000000000000000000000010 -> 1.0E-6175 Subnormal
+decq081 apply 0.00000000000000000000000000000001E-6143 -> #00004000000000000000000000000001 Subnormal
+decq082 apply #00004000000000000000000000000001 -> 1E-6175 Subnormal
+decq083 apply 0.000000000000000000000000000000001E-6143 -> #00000000000000000000000000000001 Subnormal
+decq084 apply #00000000000000000000000000000001 -> 1E-6176 Subnormal
+
+-- underflows cannot be tested for simple copies, check edge cases
+decq090 apply 1e-6176 -> #00000000000000000000000000000001 Subnormal
+decq100 apply 999999999999999999999999999999999e-6176 -> #00000ff3fcff3fcff3fcff3fcff3fcff Subnormal
+
+-- same again, negatives
+-- Nmax and similar
+decq122 apply -9.999999999999999999999999999999999E+6144 -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
+decq123 apply #f7ffcff3fcff3fcff3fcff3fcff3fcff -> -9.999999999999999999999999999999999E+6144
+decq124 apply -1.234567890123456789012345678901234E+6144 -> #c7ffd34b9c1e28e56f3c127177823534
+decq125 apply #c7ffd34b9c1e28e56f3c127177823534 -> -1.234567890123456789012345678901234E+6144
+-- fold-downs (more below)
+decq130 apply -1.23E+6144 -> #c7ffd300000000000000000000000000 Clamped
+decq131 apply #c7ffd300000000000000000000000000 -> -1.230000000000000000000000000000000E+6144
+decq132 apply -1E+6144 -> #c7ffc000000000000000000000000000 Clamped
+decq133 apply #c7ffc000000000000000000000000000 -> -1.000000000000000000000000000000000E+6144
+
+decq151 apply -12345 -> #a20800000000000000000000000049c5
+decq152 apply #a20800000000000000000000000049c5 -> -12345
+decq153 apply -1234 -> #a2080000000000000000000000000534
+decq154 apply #a2080000000000000000000000000534 -> -1234
+decq155 apply -123 -> #a20800000000000000000000000000a3
+decq156 apply #a20800000000000000000000000000a3 -> -123
+decq157 apply -12 -> #a2080000000000000000000000000012
+decq158 apply #a2080000000000000000000000000012 -> -12
+decq159 apply -1 -> #a2080000000000000000000000000001
+decq160 apply #a2080000000000000000000000000001 -> -1
+decq161 apply -1.23 -> #a20780000000000000000000000000a3
+decq162 apply #a20780000000000000000000000000a3 -> -1.23
+decq163 apply -123.45 -> #a20780000000000000000000000049c5
+decq164 apply #a20780000000000000000000000049c5 -> -123.45
+
+-- Nmin and below
+decq171 apply -1E-6143 -> #80084000000000000000000000000001
+decq172 apply #80084000000000000000000000000001 -> -1E-6143
+decq173 apply -1.000000000000000000000000000000000E-6143 -> #84000000000000000000000000000000
+decq174 apply #84000000000000000000000000000000 -> -1.000000000000000000000000000000000E-6143
+decq175 apply -1.000000000000000000000000000000001E-6143 -> #84000000000000000000000000000001
+decq176 apply #84000000000000000000000000000001 -> -1.000000000000000000000000000000001E-6143
+
+decq177 apply -0.100000000000000000000000000000000E-6143 -> #80000800000000000000000000000000 Subnormal
+decq178 apply #80000800000000000000000000000000 -> -1.00000000000000000000000000000000E-6144 Subnormal
+decq179 apply -0.000000000000000000000000000000010E-6143 -> #80000000000000000000000000000010 Subnormal
+decq180 apply #80000000000000000000000000000010 -> -1.0E-6175 Subnormal
+decq181 apply -0.00000000000000000000000000000001E-6143 -> #80004000000000000000000000000001 Subnormal
+decq182 apply #80004000000000000000000000000001 -> -1E-6175 Subnormal
+decq183 apply -0.000000000000000000000000000000001E-6143 -> #80000000000000000000000000000001 Subnormal
+decq184 apply #80000000000000000000000000000001 -> -1E-6176 Subnormal
+
+-- underflow edge cases
+decq190 apply -1e-6176 -> #80000000000000000000000000000001 Subnormal
+decq200 apply -999999999999999999999999999999999e-6176 -> #80000ff3fcff3fcff3fcff3fcff3fcff Subnormal
+
+-- zeros
+decq400 apply 0E-8000 -> #00000000000000000000000000000000 Clamped
+decq401 apply 0E-6177 -> #00000000000000000000000000000000 Clamped
+decq402 apply 0E-6176 -> #00000000000000000000000000000000
+decq403 apply #00000000000000000000000000000000 -> 0E-6176
+decq404 apply 0.000000000000000000000000000000000E-6143 -> #00000000000000000000000000000000
+decq405 apply #00000000000000000000000000000000 -> 0E-6176
+decq406 apply 0E-2 -> #22078000000000000000000000000000
+decq407 apply #22078000000000000000000000000000 -> 0.00
+decq408 apply 0 -> #22080000000000000000000000000000
+decq409 apply #22080000000000000000000000000000 -> 0
+decq410 apply 0E+3 -> #2208c000000000000000000000000000
+decq411 apply #2208c000000000000000000000000000 -> 0E+3
+decq412 apply 0E+6111 -> #43ffc000000000000000000000000000
+decq413 apply #43ffc000000000000000000000000000 -> 0E+6111
+-- clamped zeros...
+decq414 apply 0E+6112 -> #43ffc000000000000000000000000000 Clamped
+decq415 apply #43ffc000000000000000000000000000 -> 0E+6111
+decq416 apply 0E+6144 -> #43ffc000000000000000000000000000 Clamped
+decq417 apply #43ffc000000000000000000000000000 -> 0E+6111
+decq418 apply 0E+8000 -> #43ffc000000000000000000000000000 Clamped
+decq419 apply #43ffc000000000000000000000000000 -> 0E+6111
+
+-- negative zeros
+decq420 apply -0E-8000 -> #80000000000000000000000000000000 Clamped
+decq421 apply -0E-6177 -> #80000000000000000000000000000000 Clamped
+decq422 apply -0E-6176 -> #80000000000000000000000000000000
+decq423 apply #80000000000000000000000000000000 -> -0E-6176
+decq424 apply -0.000000000000000000000000000000000E-6143 -> #80000000000000000000000000000000
+decq425 apply #80000000000000000000000000000000 -> -0E-6176
+decq426 apply -0E-2 -> #a2078000000000000000000000000000
+decq427 apply #a2078000000000000000000000000000 -> -0.00
+decq428 apply -0 -> #a2080000000000000000000000000000
+decq429 apply #a2080000000000000000000000000000 -> -0
+decq430 apply -0E+3 -> #a208c000000000000000000000000000
+decq431 apply #a208c000000000000000000000000000 -> -0E+3
+decq432 apply -0E+6111 -> #c3ffc000000000000000000000000000
+decq433 apply #c3ffc000000000000000000000000000 -> -0E+6111
+-- clamped zeros...
+decq434 apply -0E+6112 -> #c3ffc000000000000000000000000000 Clamped
+decq435 apply #c3ffc000000000000000000000000000 -> -0E+6111
+decq436 apply -0E+6144 -> #c3ffc000000000000000000000000000 Clamped
+decq437 apply #c3ffc000000000000000000000000000 -> -0E+6111
+decq438 apply -0E+8000 -> #c3ffc000000000000000000000000000 Clamped
+decq439 apply #c3ffc000000000000000000000000000 -> -0E+6111
+
+-- exponent lengths
+decq440 apply #22080000000000000000000000000007 -> 7
+decq441 apply 7 -> #22080000000000000000000000000007
+decq442 apply #220a4000000000000000000000000007 -> 7E+9
+decq443 apply 7E+9 -> #220a4000000000000000000000000007
+decq444 apply #2220c000000000000000000000000007 -> 7E+99
+decq445 apply 7E+99 -> #2220c000000000000000000000000007
+decq446 apply #2301c000000000000000000000000007 -> 7E+999
+decq447 apply 7E+999 -> #2301c000000000000000000000000007
+decq448 apply #43e3c000000000000000000000000007 -> 7E+5999
+decq449 apply 7E+5999 -> #43e3c000000000000000000000000007
+
+-- Specials
+decq500 apply Infinity -> #78000000000000000000000000000000
+decq501 apply #78787878787878787878787878787878 -> #78000000000000000000000000000000
+decq502 apply #78000000000000000000000000000000 -> Infinity
+decq503 apply #79797979797979797979797979797979 -> #78000000000000000000000000000000
+decq504 apply #79000000000000000000000000000000 -> Infinity
+decq505 apply #7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #78000000000000000000000000000000
+decq506 apply #7a000000000000000000000000000000 -> Infinity
+decq507 apply #7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #78000000000000000000000000000000
+decq508 apply #7b000000000000000000000000000000 -> Infinity
+
+decq509 apply NaN -> #7c000000000000000000000000000000
+decq510 apply #7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #7c003c7c7c7c7c7c7c7c7c7c7c7c7c7c
+decq511 apply #7c000000000000000000000000000000 -> NaN
+decq512 apply #7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #7c003d7d7d7d7d7d7d7d7d7d7d7d7d7d
+decq513 apply #7d000000000000000000000000000000 -> NaN
+decq514 apply #7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #7e003e7e7c7e7e7e7e7c7e7e7e7e7c7e
+decq515 apply #7e000000000000000000000000000000 -> sNaN
+decq516 apply #7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #7e003f7f7c7f7f7f7f7c7f7f7f7f7c7f
+decq517 apply #7f000000000000000000000000000000 -> sNaN
+decq518 apply #7fffffffffffffffffffffffffffffff -> sNaN999999999999999999999999999999999
+decq519 apply #7fffffffffffffffffffffffffffffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+
+decq520 apply -Infinity -> #f8000000000000000000000000000000
+decq521 apply #f8787878787878787878787878787878 -> #f8000000000000000000000000000000
+decq522 apply #f8000000000000000000000000000000 -> -Infinity
+decq523 apply #f9797979797979797979797979797979 -> #f8000000000000000000000000000000
+decq524 apply #f9000000000000000000000000000000 -> -Infinity
+decq525 apply #fa7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #f8000000000000000000000000000000
+decq526 apply #fa000000000000000000000000000000 -> -Infinity
+decq527 apply #fb7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #f8000000000000000000000000000000
+decq528 apply #fb000000000000000000000000000000 -> -Infinity
+
+decq529 apply -NaN -> #fc000000000000000000000000000000
+decq530 apply #fc7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #fc003c7c7c7c7c7c7c7c7c7c7c7c7c7c
+decq531 apply #fc000000000000000000000000000000 -> -NaN
+decq532 apply #fd7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #fc003d7d7d7d7d7d7d7d7d7d7d7d7d7d
+decq533 apply #fd000000000000000000000000000000 -> -NaN
+decq534 apply #fe7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #fe003e7e7c7e7e7e7e7c7e7e7e7e7c7e
+decq535 apply #fe000000000000000000000000000000 -> -sNaN
+decq536 apply #ff7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #fe003f7f7c7f7f7f7f7c7f7f7f7f7c7f
+decq537 apply #ff000000000000000000000000000000 -> -sNaN
+decq538 apply #ffffffffffffffffffffffffffffffff -> -sNaN999999999999999999999999999999999
+decq539 apply #ffffffffffffffffffffffffffffffff -> #fe000ff3fcff3fcff3fcff3fcff3fcff
+
+decq540 apply NaN -> #7c000000000000000000000000000000
+decq541 apply NaN0 -> #7c000000000000000000000000000000
+decq542 apply NaN1 -> #7c000000000000000000000000000001
+decq543 apply NaN12 -> #7c000000000000000000000000000012
+decq544 apply NaN79 -> #7c000000000000000000000000000079
+decq545 apply NaN12345 -> #7c0000000000000000000000000049c5
+decq546 apply NaN123456 -> #7c000000000000000000000000028e56
+decq547 apply NaN799799 -> #7c0000000000000000000000000f7fdf
+decq548 apply NaN799799799799799799799799799799799 -> #7c003dff7fdff7fdff7fdff7fdff7fdf
+decq549 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+decq550 apply 9999999999999999999999999999999999 -> #6e080ff3fcff3fcff3fcff3fcff3fcff
+
+-- fold-down full sequence
+decq601 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped
+decq602 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144
+decq603 apply 1E+6143 -> #43ffc800000000000000000000000000 Clamped
+decq604 apply #43ffc800000000000000000000000000 -> 1.00000000000000000000000000000000E+6143
+decq605 apply 1E+6142 -> #43ffc100000000000000000000000000 Clamped
+decq606 apply #43ffc100000000000000000000000000 -> 1.0000000000000000000000000000000E+6142
+decq607 apply 1E+6141 -> #43ffc010000000000000000000000000 Clamped
+decq608 apply #43ffc010000000000000000000000000 -> 1.000000000000000000000000000000E+6141
+decq609 apply 1E+6140 -> #43ffc002000000000000000000000000 Clamped
+decq610 apply #43ffc002000000000000000000000000 -> 1.00000000000000000000000000000E+6140
+decq611 apply 1E+6139 -> #43ffc000400000000000000000000000 Clamped
+decq612 apply #43ffc000400000000000000000000000 -> 1.0000000000000000000000000000E+6139
+decq613 apply 1E+6138 -> #43ffc000040000000000000000000000 Clamped
+decq614 apply #43ffc000040000000000000000000000 -> 1.000000000000000000000000000E+6138
+decq615 apply 1E+6137 -> #43ffc000008000000000000000000000 Clamped
+decq616 apply #43ffc000008000000000000000000000 -> 1.00000000000000000000000000E+6137
+decq617 apply 1E+6136 -> #43ffc000001000000000000000000000 Clamped
+decq618 apply #43ffc000001000000000000000000000 -> 1.0000000000000000000000000E+6136
+decq619 apply 1E+6135 -> #43ffc000000100000000000000000000 Clamped
+decq620 apply #43ffc000000100000000000000000000 -> 1.000000000000000000000000E+6135
+decq621 apply 1E+6134 -> #43ffc000000020000000000000000000 Clamped
+decq622 apply #43ffc000000020000000000000000000 -> 1.00000000000000000000000E+6134
+decq623 apply 1E+6133 -> #43ffc000000004000000000000000000 Clamped
+decq624 apply #43ffc000000004000000000000000000 -> 1.0000000000000000000000E+6133
+decq625 apply 1E+6132 -> #43ffc000000000400000000000000000 Clamped
+decq626 apply #43ffc000000000400000000000000000 -> 1.000000000000000000000E+6132
+decq627 apply 1E+6131 -> #43ffc000000000080000000000000000 Clamped
+decq628 apply #43ffc000000000080000000000000000 -> 1.00000000000000000000E+6131
+decq629 apply 1E+6130 -> #43ffc000000000010000000000000000 Clamped
+decq630 apply #43ffc000000000010000000000000000 -> 1.0000000000000000000E+6130
+decq631 apply 1E+6129 -> #43ffc000000000001000000000000000 Clamped
+decq632 apply #43ffc000000000001000000000000000 -> 1.000000000000000000E+6129
+decq633 apply 1E+6128 -> #43ffc000000000000200000000000000 Clamped
+decq634 apply #43ffc000000000000200000000000000 -> 1.00000000000000000E+6128
+decq635 apply 1E+6127 -> #43ffc000000000000040000000000000 Clamped
+decq636 apply #43ffc000000000000040000000000000 -> 1.0000000000000000E+6127
+decq637 apply 1E+6126 -> #43ffc000000000000004000000000000 Clamped
+decq638 apply #43ffc000000000000004000000000000 -> 1.000000000000000E+6126
+decq639 apply 1E+6125 -> #43ffc000000000000000800000000000 Clamped
+decq640 apply #43ffc000000000000000800000000000 -> 1.00000000000000E+6125
+decq641 apply 1E+6124 -> #43ffc000000000000000100000000000 Clamped
+decq642 apply #43ffc000000000000000100000000000 -> 1.0000000000000E+6124
+decq643 apply 1E+6123 -> #43ffc000000000000000010000000000 Clamped
+decq644 apply #43ffc000000000000000010000000000 -> 1.000000000000E+6123
+decq645 apply 1E+6122 -> #43ffc000000000000000002000000000 Clamped
+decq646 apply #43ffc000000000000000002000000000 -> 1.00000000000E+6122
+decq647 apply 1E+6121 -> #43ffc000000000000000000400000000 Clamped
+decq648 apply #43ffc000000000000000000400000000 -> 1.0000000000E+6121
+decq649 apply 1E+6120 -> #43ffc000000000000000000040000000 Clamped
+decq650 apply #43ffc000000000000000000040000000 -> 1.000000000E+6120
+decq651 apply 1E+6119 -> #43ffc000000000000000000008000000 Clamped
+decq652 apply #43ffc000000000000000000008000000 -> 1.00000000E+6119
+decq653 apply 1E+6118 -> #43ffc000000000000000000001000000 Clamped
+decq654 apply #43ffc000000000000000000001000000 -> 1.0000000E+6118
+decq655 apply 1E+6117 -> #43ffc000000000000000000000100000 Clamped
+decq656 apply #43ffc000000000000000000000100000 -> 1.000000E+6117
+decq657 apply 1E+6116 -> #43ffc000000000000000000000020000 Clamped
+decq658 apply #43ffc000000000000000000000020000 -> 1.00000E+6116
+decq659 apply 1E+6115 -> #43ffc000000000000000000000004000 Clamped
+decq660 apply #43ffc000000000000000000000004000 -> 1.0000E+6115
+decq661 apply 1E+6114 -> #43ffc000000000000000000000000400 Clamped
+decq662 apply #43ffc000000000000000000000000400 -> 1.000E+6114
+decq663 apply 1E+6113 -> #43ffc000000000000000000000000080 Clamped
+decq664 apply #43ffc000000000000000000000000080 -> 1.00E+6113
+decq665 apply 1E+6112 -> #43ffc000000000000000000000000010 Clamped
+decq666 apply #43ffc000000000000000000000000010 -> 1.0E+6112
+decq667 apply 1E+6111 -> #43ffc000000000000000000000000001
+decq668 apply #43ffc000000000000000000000000001 -> 1E+6111
+decq669 apply 1E+6110 -> #43ff8000000000000000000000000001
+decq670 apply #43ff8000000000000000000000000001 -> 1E+6110
+
+-- Selected DPD codes
+decq700 apply #22080000000000000000000000000000 -> 0
+decq701 apply #22080000000000000000000000000009 -> 9
+decq702 apply #22080000000000000000000000000010 -> 10
+decq703 apply #22080000000000000000000000000019 -> 19
+decq704 apply #22080000000000000000000000000020 -> 20
+decq705 apply #22080000000000000000000000000029 -> 29
+decq706 apply #22080000000000000000000000000030 -> 30
+decq707 apply #22080000000000000000000000000039 -> 39
+decq708 apply #22080000000000000000000000000040 -> 40
+decq709 apply #22080000000000000000000000000049 -> 49
+decq710 apply #22080000000000000000000000000050 -> 50
+decq711 apply #22080000000000000000000000000059 -> 59
+decq712 apply #22080000000000000000000000000060 -> 60
+decq713 apply #22080000000000000000000000000069 -> 69
+decq714 apply #22080000000000000000000000000070 -> 70
+decq715 apply #22080000000000000000000000000071 -> 71
+decq716 apply #22080000000000000000000000000072 -> 72
+decq717 apply #22080000000000000000000000000073 -> 73
+decq718 apply #22080000000000000000000000000074 -> 74
+decq719 apply #22080000000000000000000000000075 -> 75
+decq720 apply #22080000000000000000000000000076 -> 76
+decq721 apply #22080000000000000000000000000077 -> 77
+decq722 apply #22080000000000000000000000000078 -> 78
+decq723 apply #22080000000000000000000000000079 -> 79
+
+decq730 apply #2208000000000000000000000000029e -> 994
+decq731 apply #2208000000000000000000000000029f -> 995
+decq732 apply #220800000000000000000000000002a0 -> 520
+decq733 apply #220800000000000000000000000002a1 -> 521
+
+-- DPD: one of each of the huffman groups
+decq740 apply #220800000000000000000000000003f7 -> 777
+decq741 apply #220800000000000000000000000003f8 -> 778
+decq742 apply #220800000000000000000000000003eb -> 787
+decq743 apply #2208000000000000000000000000037d -> 877
+decq744 apply #2208000000000000000000000000039f -> 997
+decq745 apply #220800000000000000000000000003bf -> 979
+decq746 apply #220800000000000000000000000003df -> 799
+decq747 apply #2208000000000000000000000000006e -> 888
+
+
+-- DPD all-highs cases (includes the 24 redundant codes)
+decq750 apply #2208000000000000000000000000006e -> 888
+decq751 apply #2208000000000000000000000000016e -> 888
+decq752 apply #2208000000000000000000000000026e -> 888
+decq753 apply #2208000000000000000000000000036e -> 888
+decq754 apply #2208000000000000000000000000006f -> 889
+decq755 apply #2208000000000000000000000000016f -> 889
+decq756 apply #2208000000000000000000000000026f -> 889
+decq757 apply #2208000000000000000000000000036f -> 889
+
+decq760 apply #2208000000000000000000000000007e -> 898
+decq761 apply #2208000000000000000000000000017e -> 898
+decq762 apply #2208000000000000000000000000027e -> 898
+decq763 apply #2208000000000000000000000000037e -> 898
+decq764 apply #2208000000000000000000000000007f -> 899
+decq765 apply #2208000000000000000000000000017f -> 899
+decq766 apply #2208000000000000000000000000027f -> 899
+decq767 apply #2208000000000000000000000000037f -> 899
+
+decq770 apply #220800000000000000000000000000ee -> 988
+decq771 apply #220800000000000000000000000001ee -> 988
+decq772 apply #220800000000000000000000000002ee -> 988
+decq773 apply #220800000000000000000000000003ee -> 988
+decq774 apply #220800000000000000000000000000ef -> 989
+decq775 apply #220800000000000000000000000001ef -> 989
+decq776 apply #220800000000000000000000000002ef -> 989
+decq777 apply #220800000000000000000000000003ef -> 989
+
+decq780 apply #220800000000000000000000000000fe -> 998
+decq781 apply #220800000000000000000000000001fe -> 998
+decq782 apply #220800000000000000000000000002fe -> 998
+decq783 apply #220800000000000000000000000003fe -> 998
+decq784 apply #220800000000000000000000000000ff -> 999
+decq785 apply #220800000000000000000000000001ff -> 999
+decq786 apply #220800000000000000000000000002ff -> 999
+decq787 apply #220800000000000000000000000003ff -> 999
+
+-- Miscellaneous (testers' queries, etc.)
+
+decq790 apply #2208000000000000000000000000c000 -> 30000
+decq791 apply #22080000000000000000000000007800 -> 890000
+decq792 apply 30000 -> #2208000000000000000000000000c000
+decq793 apply 890000 -> #22080000000000000000000000007800
+
+-- values around [u]int32 edges (zeros done earlier)
+decq800 apply -2147483646 -> #a208000000000000000000008c78af46
+decq801 apply -2147483647 -> #a208000000000000000000008c78af47
+decq802 apply -2147483648 -> #a208000000000000000000008c78af48
+decq803 apply -2147483649 -> #a208000000000000000000008c78af49
+decq804 apply 2147483646 -> #2208000000000000000000008c78af46
+decq805 apply 2147483647 -> #2208000000000000000000008c78af47
+decq806 apply 2147483648 -> #2208000000000000000000008c78af48
+decq807 apply 2147483649 -> #2208000000000000000000008c78af49
+decq808 apply 4294967294 -> #22080000000000000000000115afb55a
+decq809 apply 4294967295 -> #22080000000000000000000115afb55b
+decq810 apply 4294967296 -> #22080000000000000000000115afb57a
+decq811 apply 4294967297 -> #22080000000000000000000115afb57b
+
+decq820 apply #a208000000000000000000008c78af46 -> -2147483646
+decq821 apply #a208000000000000000000008c78af47 -> -2147483647
+decq822 apply #a208000000000000000000008c78af48 -> -2147483648
+decq823 apply #a208000000000000000000008c78af49 -> -2147483649
+decq824 apply #2208000000000000000000008c78af46 -> 2147483646
+decq825 apply #2208000000000000000000008c78af47 -> 2147483647
+decq826 apply #2208000000000000000000008c78af48 -> 2147483648
+decq827 apply #2208000000000000000000008c78af49 -> 2147483649
+decq828 apply #22080000000000000000000115afb55a -> 4294967294
+decq829 apply #22080000000000000000000115afb55b -> 4294967295
+decq830 apply #22080000000000000000000115afb57a -> 4294967296
+decq831 apply #22080000000000000000000115afb57b -> 4294967297
+
+-- VG testcase
+decq840 apply #2080000000000000F294000000172636 -> 8.81125000000001349436E-1548
+decq841 apply #20800000000000008000000000000000 -> 8.000000000000000000E-1550
+decq842 apply #1EF98490000000010F6E4E0000000000 -> 7.049000000000010795488000000000000E-3097
+decq843 multiply #20800000000000008000000000000000 #2080000000000000F294000000172636 -> #1EF98490000000010F6E4E0000000000 Rounded
+
diff --git a/Lib/test/decimaltestdata/dqFMA.decTest b/Lib/test/decimaltestdata/dqFMA.decTest
index d884553b8a..2353f2fa2c 100644
--- a/Lib/test/decimaltestdata/dqFMA.decTest
+++ b/Lib/test/decimaltestdata/dqFMA.decTest
@@ -1,1786 +1,1786 @@
-------------------------------------------------------------------------
--- dqFMA.decTest -- decQuad Fused Multiply Add --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- These tests comprese three parts:
--- 1. Sanity checks and other three-operand tests (especially those
--- where the fused operation makes a difference)
--- 2. Multiply tests (third operand is neutral zero [0E+emax])
--- 3. Addition tests (first operand is 1)
--- The multiply and addition tests are extensive because FMA may have
--- its own dedicated multiplication or addition routine(s), and they
--- also inherently check the left-to-right properties.
-
--- Sanity checks
-dqfma0001 fma 1 1 1 -> 2
-dqfma0002 fma 1 1 2 -> 3
-dqfma0003 fma 2 2 3 -> 7
-dqfma0004 fma 9 9 9 -> 90
-dqfma0005 fma -1 1 1 -> 0
-dqfma0006 fma -1 1 2 -> 1
-dqfma0007 fma -2 2 3 -> -1
-dqfma0008 fma -9 9 9 -> -72
-dqfma0011 fma 1 -1 1 -> 0
-dqfma0012 fma 1 -1 2 -> 1
-dqfma0013 fma 2 -2 3 -> -1
-dqfma0014 fma 9 -9 9 -> -72
-dqfma0015 fma 1 1 -1 -> 0
-dqfma0016 fma 1 1 -2 -> -1
-dqfma0017 fma 2 2 -3 -> 1
-dqfma0018 fma 9 9 -9 -> 72
-
--- non-integer exacts
-dqfma0100 fma 25.2 63.6 -438 -> 1164.72
-dqfma0101 fma 0.301 0.380 334 -> 334.114380
-dqfma0102 fma 49.2 -4.8 23.3 -> -212.86
-dqfma0103 fma 4.22 0.079 -94.6 -> -94.26662
-dqfma0104 fma 903 0.797 0.887 -> 720.578
-dqfma0105 fma 6.13 -161 65.9 -> -921.03
-dqfma0106 fma 28.2 727 5.45 -> 20506.85
-dqfma0107 fma 4 605 688 -> 3108
-dqfma0108 fma 93.3 0.19 0.226 -> 17.953
-dqfma0109 fma 0.169 -341 5.61 -> -52.019
-dqfma0110 fma -72.2 30 -51.2 -> -2217.2
-dqfma0111 fma -0.409 13 20.4 -> 15.083
-dqfma0112 fma 317 77.0 19.0 -> 24428.0
-dqfma0113 fma 47 6.58 1.62 -> 310.88
-dqfma0114 fma 1.36 0.984 0.493 -> 1.83124
-dqfma0115 fma 72.7 274 1.56 -> 19921.36
-dqfma0116 fma 335 847 83 -> 283828
-dqfma0117 fma 666 0.247 25.4 -> 189.902
-dqfma0118 fma -3.87 3.06 78.0 -> 66.1578
-dqfma0119 fma 0.742 192 35.6 -> 178.064
-dqfma0120 fma -91.6 5.29 0.153 -> -484.411
-
--- cases where result is different from separate multiply + add; each
--- is preceded by the result of unfused multiply and add
--- [this is about 20% of all similar cases in general]
--- -> 4.500119002100000209469729375698778E+38
-dqfma0202 fma 68537985861355864457.5694 6565875762972086605.85969 35892634447236753.172812 -> 4.500119002100000209469729375698779E+38 Inexact Rounded
--- -> 5.996248469584594346858881620185514E+41
-dqfma0208 fma 89261822344727628571.9 6717595845654131383336.89 5061036497288796076266.11 -> 5.996248469584594346858881620185513E+41 Inexact Rounded
--- -> 1.899242968678256924021594770874070E+34
-dqfma0210 fma 320506237232448685.495971 59257597764017967.984448 3205615239077711589912.85 -> 1.899242968678256924021594770874071E+34 Inexact Rounded
--- -> 7.078596978842809537929699954860309E+37
-dqfma0215 fma 220247843259112263.17995 321392340287987979002.80 47533279819997167655440 -> 7.078596978842809537929699954860308E+37 Inexact Rounded
--- -> 1.224955667581427559754106862350743E+37
-dqfma0226 fma 23880729790368880412.1449 512947333827064719.55407 217117438419590824502.963 -> 1.224955667581427559754106862350744E+37 Inexact Rounded
--- -> -2.530094043253148806272276368579144E+42
-dqfma0229 fma 2539892357016099706.4126 -996142232667504817717435 53682082598315949425.937 -> -2.530094043253148806272276368579143E+42 Inexact Rounded
--- -> 1.713387085759711954319391412788454E+37
-dqfma0233 fma 4546339491341624464.0804 3768717864169205581 83578980278690395184.620 -> 1.713387085759711954319391412788453E+37 Inexact Rounded
--- -> 4.062275663405823716411579117771547E+35
-dqfma0235 fma 409242119433816131.42253 992633815166741501.477249 70179636544416756129546 -> 4.062275663405823716411579117771548E+35 Inexact Rounded
--- -> 6.002604327732568490562249875306823E+47
-dqfma0258 fma 817941336593541742159684 733867339769310729266598 78563844650942419311830.8 -> 6.002604327732568490562249875306822E+47 Inexact Rounded
--- -> -2.027022514381452197510103395283874E+39
-dqfma0264 fma 387617310169161270.737532 -5229442703414956061216.62 57665666816652967150473.5 -> -2.027022514381452197510103395283873E+39 Inexact Rounded
--- -> -7.856525039803554001144089842730361E+37
-dqfma0267 fma -847655845720565274701.210 92685316564117739.83984 22780950041376424429.5686 -> -7.856525039803554001144089842730360E+37 Inexact Rounded
--- -> 1.695515562011520746125607502237559E+38
-dqfma0268 fma 21590290365127685.3675 7853139227576541379426.8 -3275859437236180.761544 -> 1.695515562011520746125607502237558E+38 Inexact Rounded
--- -> -8.448422935783289219748115038014710E+38
-dqfma0269 fma -974320636272862697.971586 867109103641860247440.756 -9775170775902454762.98 -> -8.448422935783289219748115038014709E+38 Inexact Rounded
-
--- Cases where multiply would overflow or underflow if separate
-dqfma0300 fma 9e+6144 10 0 -> Infinity Overflow Inexact Rounded
-dqfma0301 fma 1e+6144 10 0 -> Infinity Overflow Inexact Rounded
-dqfma0302 fma 1e+6144 10 -1e+6144 -> 9.000000000000000000000000000000000E+6144 Clamped
-dqfma0303 fma 1e+6144 10 -9e+6144 -> 1.000000000000000000000000000000000E+6144 Clamped
--- subnormal etc.
-dqfma0305 fma 1e-6176 0.1 0 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma0306 fma 1e-6176 0.1 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqfma0307 fma 1e-6176 0.1 1e-6176 -> 1E-6176 Underflow Subnormal Inexact Rounded
-
--- Infinite combinations
-dqfma0800 fma Inf Inf Inf -> Infinity
-dqfma0801 fma Inf Inf -Inf -> NaN Invalid_operation
-dqfma0802 fma Inf -Inf Inf -> NaN Invalid_operation
-dqfma0803 fma Inf -Inf -Inf -> -Infinity
-dqfma0804 fma -Inf Inf Inf -> NaN Invalid_operation
-dqfma0805 fma -Inf Inf -Inf -> -Infinity
-dqfma0806 fma -Inf -Inf Inf -> Infinity
-dqfma0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
-
--- Triple NaN propagation
-dqfma0900 fma NaN2 NaN3 NaN5 -> NaN2
-dqfma0901 fma 0 NaN3 NaN5 -> NaN3
-dqfma0902 fma 0 0 NaN5 -> NaN5
--- first sNaN wins (consider qNaN from earlier sNaN being
--- overridden by an sNaN in third operand)
-dqfma0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-dqfma0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
-dqfma0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
-dqfma0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-dqfma0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
-dqfma0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
-
--- MULTIPLICATION TESTS ------------------------------------------------
-rounding: half_even
-
--- sanity checks
-dqfma2000 fma 2 2 0e+6144 -> 4
-dqfma2001 fma 2 3 0e+6144 -> 6
-dqfma2002 fma 5 1 0e+6144 -> 5
-dqfma2003 fma 5 2 0e+6144 -> 10
-dqfma2004 fma 1.20 2 0e+6144 -> 2.40
-dqfma2005 fma 1.20 0 0e+6144 -> 0.00
-dqfma2006 fma 1.20 -2 0e+6144 -> -2.40
-dqfma2007 fma -1.20 2 0e+6144 -> -2.40
-dqfma2008 fma -1.20 0 0e+6144 -> 0.00
-dqfma2009 fma -1.20 -2 0e+6144 -> 2.40
-dqfma2010 fma 5.09 7.1 0e+6144 -> 36.139
-dqfma2011 fma 2.5 4 0e+6144 -> 10.0
-dqfma2012 fma 2.50 4 0e+6144 -> 10.00
-dqfma2013 fma 1.23456789 1.0000000000000000000000000000 0e+6144 -> 1.234567890000000000000000000000000 Rounded
-dqfma2015 fma 2.50 4 0e+6144 -> 10.00
-dqfma2016 fma 9.99999999999999999 9.99999999999999999 0e+6144 -> 99.99999999999999980000000000000000 Inexact Rounded
-dqfma2017 fma 9.99999999999999999 -9.99999999999999999 0e+6144 -> -99.99999999999999980000000000000000 Inexact Rounded
-dqfma2018 fma -9.99999999999999999 9.99999999999999999 0e+6144 -> -99.99999999999999980000000000000000 Inexact Rounded
-dqfma2019 fma -9.99999999999999999 -9.99999999999999999 0e+6144 -> 99.99999999999999980000000000000000 Inexact Rounded
-
--- zeros, etc.
-dqfma2021 fma 0 0 0e+6144 -> 0
-dqfma2022 fma 0 -0 0e+6144 -> 0
-dqfma2023 fma -0 0 0e+6144 -> 0
-dqfma2024 fma -0 -0 0e+6144 -> 0
-dqfma2025 fma -0.0 -0.0 0e+6144 -> 0.00
-dqfma2026 fma -0.0 -0.0 0e+6144 -> 0.00
-dqfma2027 fma -0.0 -0.0 0e+6144 -> 0.00
-dqfma2028 fma -0.0 -0.0 0e+6144 -> 0.00
-dqfma2030 fma 5.00 1E-3 0e+6144 -> 0.00500
-dqfma2031 fma 00.00 0.000 0e+6144 -> 0.00000
-dqfma2032 fma 00.00 0E-3 0e+6144 -> 0.00000 -- rhs is 0
-dqfma2033 fma 0E-3 00.00 0e+6144 -> 0.00000 -- lhs is 0
-dqfma2034 fma -5.00 1E-3 0e+6144 -> -0.00500
-dqfma2035 fma -00.00 0.000 0e+6144 -> 0.00000
-dqfma2036 fma -00.00 0E-3 0e+6144 -> 0.00000 -- rhs is 0
-dqfma2037 fma -0E-3 00.00 0e+6144 -> 0.00000 -- lhs is 0
-dqfma2038 fma 5.00 -1E-3 0e+6144 -> -0.00500
-dqfma2039 fma 00.00 -0.000 0e+6144 -> 0.00000
-dqfma2040 fma 00.00 -0E-3 0e+6144 -> 0.00000 -- rhs is 0
-dqfma2041 fma 0E-3 -00.00 0e+6144 -> 0.00000 -- lhs is 0
-dqfma2042 fma -5.00 -1E-3 0e+6144 -> 0.00500
-dqfma2043 fma -00.00 -0.000 0e+6144 -> 0.00000
-dqfma2044 fma -00.00 -0E-3 0e+6144 -> 0.00000 -- rhs is 0
-dqfma2045 fma -0E-3 -00.00 0e+6144 -> 0.00000 -- lhs is 0
-
--- examples from decarith
-dqfma2050 fma 1.20 3 0e+6144 -> 3.60
-dqfma2051 fma 7 3 0e+6144 -> 21
-dqfma2052 fma 0.9 0.8 0e+6144 -> 0.72
-dqfma2053 fma 0.9 -0 0e+6144 -> 0.0
-dqfma2054 fma 654321 654321 0e+6144 -> 428135971041
-
-dqfma2060 fma 123.45 1e7 0e+6144 -> 1.2345E+9
-dqfma2061 fma 123.45 1e8 0e+6144 -> 1.2345E+10
-dqfma2062 fma 123.45 1e+9 0e+6144 -> 1.2345E+11
-dqfma2063 fma 123.45 1e10 0e+6144 -> 1.2345E+12
-dqfma2064 fma 123.45 1e11 0e+6144 -> 1.2345E+13
-dqfma2065 fma 123.45 1e12 0e+6144 -> 1.2345E+14
-dqfma2066 fma 123.45 1e13 0e+6144 -> 1.2345E+15
-
-
--- test some intermediate lengths
--- 1234567890123456
-dqfma2080 fma 0.1 1230123456456789 0e+6144 -> 123012345645678.9
-dqfma2084 fma 0.1 1230123456456789 0e+6144 -> 123012345645678.9
-dqfma2090 fma 1230123456456789 0.1 0e+6144 -> 123012345645678.9
-dqfma2094 fma 1230123456456789 0.1 0e+6144 -> 123012345645678.9
-
--- test some more edge cases and carries
-dqfma2101 fma 9 9 0e+6144 -> 81
-dqfma2102 fma 9 90 0e+6144 -> 810
-dqfma2103 fma 9 900 0e+6144 -> 8100
-dqfma2104 fma 9 9000 0e+6144 -> 81000
-dqfma2105 fma 9 90000 0e+6144 -> 810000
-dqfma2106 fma 9 900000 0e+6144 -> 8100000
-dqfma2107 fma 9 9000000 0e+6144 -> 81000000
-dqfma2108 fma 9 90000000 0e+6144 -> 810000000
-dqfma2109 fma 9 900000000 0e+6144 -> 8100000000
-dqfma2110 fma 9 9000000000 0e+6144 -> 81000000000
-dqfma2111 fma 9 90000000000 0e+6144 -> 810000000000
-dqfma2112 fma 9 900000000000 0e+6144 -> 8100000000000
-dqfma2113 fma 9 9000000000000 0e+6144 -> 81000000000000
-dqfma2114 fma 9 90000000000000 0e+6144 -> 810000000000000
-dqfma2115 fma 9 900000000000000 0e+6144 -> 8100000000000000
---dqfma2116 fma 9 9000000000000000 0e+6144 -> 81000000000000000
---dqfma2117 fma 9 90000000000000000 0e+6144 -> 810000000000000000
---dqfma2118 fma 9 900000000000000000 0e+6144 -> 8100000000000000000
---dqfma2119 fma 9 9000000000000000000 0e+6144 -> 81000000000000000000
---dqfma2120 fma 9 90000000000000000000 0e+6144 -> 810000000000000000000
---dqfma2121 fma 9 900000000000000000000 0e+6144 -> 8100000000000000000000
---dqfma2122 fma 9 9000000000000000000000 0e+6144 -> 81000000000000000000000
---dqfma2123 fma 9 90000000000000000000000 0e+6144 -> 810000000000000000000000
--- test some more edge cases without carries
-dqfma2131 fma 3 3 0e+6144 -> 9
-dqfma2132 fma 3 30 0e+6144 -> 90
-dqfma2133 fma 3 300 0e+6144 -> 900
-dqfma2134 fma 3 3000 0e+6144 -> 9000
-dqfma2135 fma 3 30000 0e+6144 -> 90000
-dqfma2136 fma 3 300000 0e+6144 -> 900000
-dqfma2137 fma 3 3000000 0e+6144 -> 9000000
-dqfma2138 fma 3 30000000 0e+6144 -> 90000000
-dqfma2139 fma 3 300000000 0e+6144 -> 900000000
-dqfma2140 fma 3 3000000000 0e+6144 -> 9000000000
-dqfma2141 fma 3 30000000000 0e+6144 -> 90000000000
-dqfma2142 fma 3 300000000000 0e+6144 -> 900000000000
-dqfma2143 fma 3 3000000000000 0e+6144 -> 9000000000000
-dqfma2144 fma 3 30000000000000 0e+6144 -> 90000000000000
-dqfma2145 fma 3 300000000000000 0e+6144 -> 900000000000000
-dqfma2146 fma 3 3000000000000000 0e+6144 -> 9000000000000000
-dqfma2147 fma 3 30000000000000000 0e+6144 -> 90000000000000000
-dqfma2148 fma 3 300000000000000000 0e+6144 -> 900000000000000000
-dqfma2149 fma 3 3000000000000000000 0e+6144 -> 9000000000000000000
-dqfma2150 fma 3 30000000000000000000 0e+6144 -> 90000000000000000000
-dqfma2151 fma 3 300000000000000000000 0e+6144 -> 900000000000000000000
-dqfma2152 fma 3 3000000000000000000000 0e+6144 -> 9000000000000000000000
-dqfma2153 fma 3 30000000000000000000000 0e+6144 -> 90000000000000000000000
-
-dqfma2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0e+6144 -> 145433.2908011933696719165119928296 Inexact Rounded
-
--- test some edge cases with exact rounding
-dqfma2301 fma 900000000000000000 9 0e+6144 -> 8100000000000000000
-dqfma2302 fma 900000000000000000 90 0e+6144 -> 81000000000000000000
-dqfma2303 fma 900000000000000000 900 0e+6144 -> 810000000000000000000
-dqfma2304 fma 900000000000000000 9000 0e+6144 -> 8100000000000000000000
-dqfma2305 fma 900000000000000000 90000 0e+6144 -> 81000000000000000000000
-dqfma2306 fma 900000000000000000 900000 0e+6144 -> 810000000000000000000000
-dqfma2307 fma 900000000000000000 9000000 0e+6144 -> 8100000000000000000000000
-dqfma2308 fma 900000000000000000 90000000 0e+6144 -> 81000000000000000000000000
-dqfma2309 fma 900000000000000000 900000000 0e+6144 -> 810000000000000000000000000
-dqfma2310 fma 900000000000000000 9000000000 0e+6144 -> 8100000000000000000000000000
-dqfma2311 fma 900000000000000000 90000000000 0e+6144 -> 81000000000000000000000000000
-dqfma2312 fma 900000000000000000 900000000000 0e+6144 -> 810000000000000000000000000000
-dqfma2313 fma 900000000000000000 9000000000000 0e+6144 -> 8100000000000000000000000000000
-dqfma2314 fma 900000000000000000 90000000000000 0e+6144 -> 81000000000000000000000000000000
-dqfma2315 fma 900000000000000000 900000000000000 0e+6144 -> 810000000000000000000000000000000
-dqfma2316 fma 900000000000000000 9000000000000000 0e+6144 -> 8100000000000000000000000000000000
-dqfma2317 fma 9000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+34 Rounded
-dqfma2318 fma 90000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+35 Rounded
-dqfma2319 fma 900000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+36 Rounded
-dqfma2320 fma 9000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+37 Rounded
-dqfma2321 fma 90000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+38 Rounded
-dqfma2322 fma 900000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+39 Rounded
-dqfma2323 fma 9000000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+40 Rounded
-
--- tryzeros cases
-dqfma2504 fma 0E-4260 1000E-4260 0e+6144 -> 0E-6176 Clamped
-dqfma2505 fma 100E+4260 0E+4260 0e+6144 -> 0E+6111 Clamped
-
--- mixed with zeros
-dqfma2541 fma 0 -1 0e+6144 -> 0
-dqfma2542 fma -0 -1 0e+6144 -> 0
-dqfma2543 fma 0 1 0e+6144 -> 0
-dqfma2544 fma -0 1 0e+6144 -> 0
-dqfma2545 fma -1 0 0e+6144 -> 0
-dqfma2546 fma -1 -0 0e+6144 -> 0
-dqfma2547 fma 1 0 0e+6144 -> 0
-dqfma2548 fma 1 -0 0e+6144 -> 0
-
-dqfma2551 fma 0.0 -1 0e+6144 -> 0.0
-dqfma2552 fma -0.0 -1 0e+6144 -> 0.0
-dqfma2553 fma 0.0 1 0e+6144 -> 0.0
-dqfma2554 fma -0.0 1 0e+6144 -> 0.0
-dqfma2555 fma -1.0 0 0e+6144 -> 0.0
-dqfma2556 fma -1.0 -0 0e+6144 -> 0.0
-dqfma2557 fma 1.0 0 0e+6144 -> 0.0
-dqfma2558 fma 1.0 -0 0e+6144 -> 0.0
-
-dqfma2561 fma 0 -1.0 0e+6144 -> 0.0
-dqfma2562 fma -0 -1.0 0e+6144 -> 0.0
-dqfma2563 fma 0 1.0 0e+6144 -> 0.0
-dqfma2564 fma -0 1.0 0e+6144 -> 0.0
-dqfma2565 fma -1 0.0 0e+6144 -> 0.0
-dqfma2566 fma -1 -0.0 0e+6144 -> 0.0
-dqfma2567 fma 1 0.0 0e+6144 -> 0.0
-dqfma2568 fma 1 -0.0 0e+6144 -> 0.0
-
-dqfma2571 fma 0.0 -1.0 0e+6144 -> 0.00
-dqfma2572 fma -0.0 -1.0 0e+6144 -> 0.00
-dqfma2573 fma 0.0 1.0 0e+6144 -> 0.00
-dqfma2574 fma -0.0 1.0 0e+6144 -> 0.00
-dqfma2575 fma -1.0 0.0 0e+6144 -> 0.00
-dqfma2576 fma -1.0 -0.0 0e+6144 -> 0.00
-dqfma2577 fma 1.0 0.0 0e+6144 -> 0.00
-dqfma2578 fma 1.0 -0.0 0e+6144 -> 0.00
-dqfma2579 fma 1.0 0.0 0e+6144 -> 0.00
-dqfma2530 fma -1.0 -0.0 0e+6144 -> 0.00
-dqfma2531 fma -1.0 0.0 0e+6144 -> 0.00
-dqfma2532 fma 1.0 -0.0 -0e+6144 -> -0.00
-dqfma2533 fma 1.0 0.0 -0e+6144 -> 0.00
-dqfma2534 fma -1.0 -0.0 -0e+6144 -> 0.00
-dqfma2535 fma -1.0 0.0 -0e+6144 -> -0.00
-
-
--- Specials
-dqfma2580 fma Inf -Inf 0e+6144 -> -Infinity
-dqfma2581 fma Inf -1000 0e+6144 -> -Infinity
-dqfma2582 fma Inf -1 0e+6144 -> -Infinity
-dqfma2583 fma Inf -0 0e+6144 -> NaN Invalid_operation
-dqfma2584 fma Inf 0 0e+6144 -> NaN Invalid_operation
-dqfma2585 fma Inf 1 0e+6144 -> Infinity
-dqfma2586 fma Inf 1000 0e+6144 -> Infinity
-dqfma2587 fma Inf Inf 0e+6144 -> Infinity
-dqfma2588 fma -1000 Inf 0e+6144 -> -Infinity
-dqfma2589 fma -Inf Inf 0e+6144 -> -Infinity
-dqfma2590 fma -1 Inf 0e+6144 -> -Infinity
-dqfma2591 fma -0 Inf 0e+6144 -> NaN Invalid_operation
-dqfma2592 fma 0 Inf 0e+6144 -> NaN Invalid_operation
-dqfma2593 fma 1 Inf 0e+6144 -> Infinity
-dqfma2594 fma 1000 Inf 0e+6144 -> Infinity
-dqfma2595 fma Inf Inf 0e+6144 -> Infinity
-
-dqfma2600 fma -Inf -Inf 0e+6144 -> Infinity
-dqfma2601 fma -Inf -1000 0e+6144 -> Infinity
-dqfma2602 fma -Inf -1 0e+6144 -> Infinity
-dqfma2603 fma -Inf -0 0e+6144 -> NaN Invalid_operation
-dqfma2604 fma -Inf 0 0e+6144 -> NaN Invalid_operation
-dqfma2605 fma -Inf 1 0e+6144 -> -Infinity
-dqfma2606 fma -Inf 1000 0e+6144 -> -Infinity
-dqfma2607 fma -Inf Inf 0e+6144 -> -Infinity
-dqfma2608 fma -1000 Inf 0e+6144 -> -Infinity
-dqfma2609 fma -Inf -Inf 0e+6144 -> Infinity
-dqfma2610 fma -1 -Inf 0e+6144 -> Infinity
-dqfma2611 fma -0 -Inf 0e+6144 -> NaN Invalid_operation
-dqfma2612 fma 0 -Inf 0e+6144 -> NaN Invalid_operation
-dqfma2613 fma 1 -Inf 0e+6144 -> -Infinity
-dqfma2614 fma 1000 -Inf 0e+6144 -> -Infinity
-dqfma2615 fma Inf -Inf 0e+6144 -> -Infinity
-
-dqfma2621 fma NaN -Inf 0e+6144 -> NaN
-dqfma2622 fma NaN -1000 0e+6144 -> NaN
-dqfma2623 fma NaN -1 0e+6144 -> NaN
-dqfma2624 fma NaN -0 0e+6144 -> NaN
-dqfma2625 fma NaN 0 0e+6144 -> NaN
-dqfma2626 fma NaN 1 0e+6144 -> NaN
-dqfma2627 fma NaN 1000 0e+6144 -> NaN
-dqfma2628 fma NaN Inf 0e+6144 -> NaN
-dqfma2629 fma NaN NaN 0e+6144 -> NaN
-dqfma2630 fma -Inf NaN 0e+6144 -> NaN
-dqfma2631 fma -1000 NaN 0e+6144 -> NaN
-dqfma2632 fma -1 NaN 0e+6144 -> NaN
-dqfma2633 fma -0 NaN 0e+6144 -> NaN
-dqfma2634 fma 0 NaN 0e+6144 -> NaN
-dqfma2635 fma 1 NaN 0e+6144 -> NaN
-dqfma2636 fma 1000 NaN 0e+6144 -> NaN
-dqfma2637 fma Inf NaN 0e+6144 -> NaN
-
-dqfma2641 fma sNaN -Inf 0e+6144 -> NaN Invalid_operation
-dqfma2642 fma sNaN -1000 0e+6144 -> NaN Invalid_operation
-dqfma2643 fma sNaN -1 0e+6144 -> NaN Invalid_operation
-dqfma2644 fma sNaN -0 0e+6144 -> NaN Invalid_operation
-dqfma2645 fma sNaN 0 0e+6144 -> NaN Invalid_operation
-dqfma2646 fma sNaN 1 0e+6144 -> NaN Invalid_operation
-dqfma2647 fma sNaN 1000 0e+6144 -> NaN Invalid_operation
-dqfma2648 fma sNaN NaN 0e+6144 -> NaN Invalid_operation
-dqfma2649 fma sNaN sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2650 fma NaN sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2651 fma -Inf sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2652 fma -1000 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2653 fma -1 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2654 fma -0 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2655 fma 0 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2656 fma 1 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2657 fma 1000 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2658 fma Inf sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2659 fma NaN sNaN 0e+6144 -> NaN Invalid_operation
-
--- propagating NaNs
-dqfma2661 fma NaN9 -Inf 0e+6144 -> NaN9
-dqfma2662 fma NaN8 999 0e+6144 -> NaN8
-dqfma2663 fma NaN71 Inf 0e+6144 -> NaN71
-dqfma2664 fma NaN6 NaN5 0e+6144 -> NaN6
-dqfma2665 fma -Inf NaN4 0e+6144 -> NaN4
-dqfma2666 fma -999 NaN33 0e+6144 -> NaN33
-dqfma2667 fma Inf NaN2 0e+6144 -> NaN2
-
-dqfma2671 fma sNaN99 -Inf 0e+6144 -> NaN99 Invalid_operation
-dqfma2672 fma sNaN98 -11 0e+6144 -> NaN98 Invalid_operation
-dqfma2673 fma sNaN97 NaN 0e+6144 -> NaN97 Invalid_operation
-dqfma2674 fma sNaN16 sNaN94 0e+6144 -> NaN16 Invalid_operation
-dqfma2675 fma NaN95 sNaN93 0e+6144 -> NaN93 Invalid_operation
-dqfma2676 fma -Inf sNaN92 0e+6144 -> NaN92 Invalid_operation
-dqfma2677 fma 088 sNaN91 0e+6144 -> NaN91 Invalid_operation
-dqfma2678 fma Inf sNaN90 0e+6144 -> NaN90 Invalid_operation
-dqfma2679 fma NaN sNaN89 0e+6144 -> NaN89 Invalid_operation
-
-dqfma2681 fma -NaN9 -Inf 0e+6144 -> -NaN9
-dqfma2682 fma -NaN8 999 0e+6144 -> -NaN8
-dqfma2683 fma -NaN71 Inf 0e+6144 -> -NaN71
-dqfma2684 fma -NaN6 -NaN5 0e+6144 -> -NaN6
-dqfma2685 fma -Inf -NaN4 0e+6144 -> -NaN4
-dqfma2686 fma -999 -NaN33 0e+6144 -> -NaN33
-dqfma2687 fma Inf -NaN2 0e+6144 -> -NaN2
-
-dqfma2691 fma -sNaN99 -Inf 0e+6144 -> -NaN99 Invalid_operation
-dqfma2692 fma -sNaN98 -11 0e+6144 -> -NaN98 Invalid_operation
-dqfma2693 fma -sNaN97 NaN 0e+6144 -> -NaN97 Invalid_operation
-dqfma2694 fma -sNaN16 -sNaN94 0e+6144 -> -NaN16 Invalid_operation
-dqfma2695 fma -NaN95 -sNaN93 0e+6144 -> -NaN93 Invalid_operation
-dqfma2696 fma -Inf -sNaN92 0e+6144 -> -NaN92 Invalid_operation
-dqfma2697 fma 088 -sNaN91 0e+6144 -> -NaN91 Invalid_operation
-dqfma2698 fma Inf -sNaN90 0e+6144 -> -NaN90 Invalid_operation
-dqfma2699 fma -NaN -sNaN89 0e+6144 -> -NaN89 Invalid_operation
-
-dqfma2701 fma -NaN -Inf 0e+6144 -> -NaN
-dqfma2702 fma -NaN 999 0e+6144 -> -NaN
-dqfma2703 fma -NaN Inf 0e+6144 -> -NaN
-dqfma2704 fma -NaN -NaN 0e+6144 -> -NaN
-dqfma2705 fma -Inf -NaN0 0e+6144 -> -NaN
-dqfma2706 fma -999 -NaN 0e+6144 -> -NaN
-dqfma2707 fma Inf -NaN 0e+6144 -> -NaN
-
-dqfma2711 fma -sNaN -Inf 0e+6144 -> -NaN Invalid_operation
-dqfma2712 fma -sNaN -11 0e+6144 -> -NaN Invalid_operation
-dqfma2713 fma -sNaN00 NaN 0e+6144 -> -NaN Invalid_operation
-dqfma2714 fma -sNaN -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2715 fma -NaN -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2716 fma -Inf -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2717 fma 088 -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2718 fma Inf -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2719 fma -NaN -sNaN 0e+6144 -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
--- signs
-dqfma2751 fma 1e+4277 1e+3311 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2752 fma 1e+4277 -1e+3311 0e+6144 -> -Infinity Overflow Inexact Rounded
-dqfma2753 fma -1e+4277 1e+3311 0e+6144 -> -Infinity Overflow Inexact Rounded
-dqfma2754 fma -1e+4277 -1e+3311 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2755 fma 1e-4277 1e-3311 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2756 fma 1e-4277 -1e-3311 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2757 fma -1e-4277 1e-3311 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2758 fma -1e-4277 -1e-3311 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dqfma2760 fma 1e-6069 1e-101 0e+6144 -> 1E-6170 Subnormal
-dqfma2761 fma 1e-6069 1e-102 0e+6144 -> 1E-6171 Subnormal
-dqfma2762 fma 1e-6069 1e-103 0e+6144 -> 1E-6172 Subnormal
-dqfma2763 fma 1e-6069 1e-104 0e+6144 -> 1E-6173 Subnormal
-dqfma2764 fma 1e-6069 1e-105 0e+6144 -> 1E-6174 Subnormal
-dqfma2765 fma 1e-6069 1e-106 0e+6144 -> 1E-6175 Subnormal
-dqfma2766 fma 1e-6069 1e-107 0e+6144 -> 1E-6176 Subnormal
-dqfma2767 fma 1e-6069 1e-108 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2768 fma 1e-6069 1e-109 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2769 fma 1e-6069 1e-110 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-dqfma2770 fma 1e+40 1e+6101 0e+6144 -> 1.000000000000000000000000000000E+6141 Clamped
-dqfma2771 fma 1e+40 1e+6102 0e+6144 -> 1.0000000000000000000000000000000E+6142 Clamped
-dqfma2772 fma 1e+40 1e+6103 0e+6144 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqfma2773 fma 1e+40 1e+6104 0e+6144 -> 1.000000000000000000000000000000000E+6144 Clamped
-dqfma2774 fma 1e+40 1e+6105 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2775 fma 1e+40 1e+6106 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2776 fma 1e+40 1e+6107 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2777 fma 1e+40 1e+6108 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2778 fma 1e+40 1e+6109 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2779 fma 1e+40 1e+6110 0e+6144 -> Infinity Overflow Inexact Rounded
-
-dqfma2801 fma 1.0000E-6172 1 0e+6144 -> 1.0000E-6172 Subnormal
-dqfma2802 fma 1.000E-6172 1e-1 0e+6144 -> 1.000E-6173 Subnormal
-dqfma2803 fma 1.00E-6172 1e-2 0e+6144 -> 1.00E-6174 Subnormal
-dqfma2804 fma 1.0E-6172 1e-3 0e+6144 -> 1.0E-6175 Subnormal
-dqfma2805 fma 1.0E-6172 1e-4 0e+6144 -> 1E-6176 Subnormal Rounded
-dqfma2806 fma 1.3E-6172 1e-4 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2807 fma 1.5E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2808 fma 1.7E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2809 fma 2.3E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2810 fma 2.5E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2811 fma 2.7E-6172 1e-4 0e+6144 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqfma2812 fma 1.49E-6172 1e-4 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2813 fma 1.50E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2814 fma 1.51E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2815 fma 2.49E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2816 fma 2.50E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2817 fma 2.51E-6172 1e-4 0e+6144 -> 3E-6176 Underflow Subnormal Inexact Rounded
-
-dqfma2818 fma 1E-6172 1e-4 0e+6144 -> 1E-6176 Subnormal
-dqfma2819 fma 3E-6172 1e-5 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2820 fma 5E-6172 1e-5 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2821 fma 7E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2822 fma 9E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2823 fma 9.9E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-
-dqfma2824 fma 1E-6172 -1e-4 0e+6144 -> -1E-6176 Subnormal
-dqfma2825 fma 3E-6172 -1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2826 fma -5E-6172 1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2827 fma 7E-6172 -1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2828 fma -9E-6172 1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2829 fma 9.9E-6172 -1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2830 fma 3.0E-6172 -1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqfma2831 fma 1.0E-5977 1e-200 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2832 fma 1.0E-5977 1e-199 0e+6144 -> 1E-6176 Subnormal Rounded
-dqfma2833 fma 1.0E-5977 1e-198 0e+6144 -> 1.0E-6175 Subnormal
-dqfma2834 fma 2.0E-5977 2e-198 0e+6144 -> 4.0E-6175 Subnormal
-dqfma2835 fma 4.0E-5977 4e-198 0e+6144 -> 1.60E-6174 Subnormal
-dqfma2836 fma 10.0E-5977 10e-198 0e+6144 -> 1.000E-6173 Subnormal
-dqfma2837 fma 30.0E-5977 30e-198 0e+6144 -> 9.000E-6173 Subnormal
-dqfma2838 fma 40.0E-5982 40e-166 0e+6144 -> 1.6000E-6145 Subnormal
-dqfma2839 fma 40.0E-5982 40e-165 0e+6144 -> 1.6000E-6144 Subnormal
-dqfma2840 fma 40.0E-5982 40e-164 0e+6144 -> 1.6000E-6143
-
--- Long operand overflow may be a different path
-dqfma2870 fma 100 9.999E+6143 0e+6144 -> Infinity Inexact Overflow Rounded
-dqfma2871 fma 100 -9.999E+6143 0e+6144 -> -Infinity Inexact Overflow Rounded
-dqfma2872 fma 9.999E+6143 100 0e+6144 -> Infinity Inexact Overflow Rounded
-dqfma2873 fma -9.999E+6143 100 0e+6144 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-dqfma2881 fma 1.2347E-6133 1.2347E-40 0e+6144 -> 1.524E-6173 Inexact Rounded Subnormal Underflow
-dqfma2882 fma 1.234E-6133 1.234E-40 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqfma2883 fma 1.23E-6133 1.23E-40 0e+6144 -> 1.513E-6173 Inexact Rounded Subnormal Underflow
-dqfma2884 fma 1.2E-6133 1.2E-40 0e+6144 -> 1.44E-6173 Subnormal
-dqfma2885 fma 1.2E-6133 1.2E-41 0e+6144 -> 1.44E-6174 Subnormal
-dqfma2886 fma 1.2E-6133 1.2E-42 0e+6144 -> 1.4E-6175 Subnormal Inexact Rounded Underflow
-dqfma2887 fma 1.2E-6133 1.3E-42 0e+6144 -> 1.6E-6175 Subnormal Inexact Rounded Underflow
-dqfma2888 fma 1.3E-6133 1.3E-42 0e+6144 -> 1.7E-6175 Subnormal Inexact Rounded Underflow
-dqfma2889 fma 1.3E-6133 1.3E-43 0e+6144 -> 2E-6176 Subnormal Inexact Rounded Underflow
-dqfma2890 fma 1.3E-6134 1.3E-43 0e+6144 -> 0E-6176 Clamped Subnormal Inexact Rounded Underflow
-
-dqfma2891 fma 1.2345E-39 1.234E-6133 0e+6144 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
-dqfma2892 fma 1.23456E-39 1.234E-6133 0e+6144 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
-dqfma2893 fma 1.2345E-40 1.234E-6133 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqfma2894 fma 1.23456E-40 1.234E-6133 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqfma2895 fma 1.2345E-41 1.234E-6133 0e+6144 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
-dqfma2896 fma 1.23456E-41 1.234E-6133 0e+6144 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
--- prove operands are exact
-dqfma2906 fma 9.999999999999999999999999999999999E-6143 1 0e+6144 -> 9.999999999999999999999999999999999E-6143
-dqfma2907 fma 1 0.09999999999999999999999999999999999 0e+6144 -> 0.09999999999999999999999999999999999
--- the next rounds to Nmin
-dqfma2908 fma 9.999999999999999999999999999999999E-6143 0.09999999999999999999999999999999999 0e+6144 -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded
-
--- hugest
-dqfma2909 fma 9999999999999999999999999999999999 9999999999999999999999999999999999 0e+6144 -> 9.999999999999999999999999999999998E+67 Inexact Rounded
-
--- Examples from SQL proposal (Krishna Kulkarni)
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
-dqfma21001 fma 130E-2 120E-2 0e+6144 -> 1.5600
-dqfma21002 fma 130E-2 12E-1 0e+6144 -> 1.560
-dqfma21003 fma 130E-2 1E0 0e+6144 -> 1.30
-dqfma21004 fma 1E2 1E4 0e+6144 -> 1E+6
-
--- Null tests
-dqfma2990 fma 10 # 0e+6144 -> NaN Invalid_operation
-dqfma2991 fma # 10 0e+6144 -> NaN Invalid_operation
-
-
--- ADDITION TESTS ------------------------------------------------------
-rounding: half_even
-
--- [first group are 'quick confidence check']
-dqadd3001 fma 1 1 1 -> 2
-dqadd3002 fma 1 2 3 -> 5
-dqadd3003 fma 1 '5.75' '3.3' -> 9.05
-dqadd3004 fma 1 '5' '-3' -> 2
-dqadd3005 fma 1 '-5' '-3' -> -8
-dqadd3006 fma 1 '-7' '2.5' -> -4.5
-dqadd3007 fma 1 '0.7' '0.3' -> 1.0
-dqadd3008 fma 1 '1.25' '1.25' -> 2.50
-dqadd3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
-dqadd3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
-
--- 1234567890123456 1234567890123456
-dqadd3011 fma 1 '0.4444444444444444444444444444444446' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqadd3012 fma 1 '0.4444444444444444444444444444444445' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
-dqadd3013 fma 1 '0.4444444444444444444444444444444444' '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
-dqadd3014 fma 1 '4444444444444444444444444444444444' '0.49' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd3015 fma 1 '4444444444444444444444444444444444' '0.499' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd3016 fma 1 '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd3017 fma 1 '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd3018 fma 1 '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
-dqadd3019 fma 1 '4444444444444444444444444444444444' '0.501' -> '4444444444444444444444444444444445' Inexact Rounded
-dqadd3020 fma 1 '4444444444444444444444444444444444' '0.51' -> '4444444444444444444444444444444445' Inexact Rounded
-
-dqadd3021 fma 1 0 1 -> 1
-dqadd3022 fma 1 1 1 -> 2
-dqadd3023 fma 1 2 1 -> 3
-dqadd3024 fma 1 3 1 -> 4
-dqadd3025 fma 1 4 1 -> 5
-dqadd3026 fma 1 5 1 -> 6
-dqadd3027 fma 1 6 1 -> 7
-dqadd3028 fma 1 7 1 -> 8
-dqadd3029 fma 1 8 1 -> 9
-dqadd3030 fma 1 9 1 -> 10
-
--- some carrying effects
-dqadd3031 fma 1 '0.9998' '0.0000' -> '0.9998'
-dqadd3032 fma 1 '0.9998' '0.0001' -> '0.9999'
-dqadd3033 fma 1 '0.9998' '0.0002' -> '1.0000'
-dqadd3034 fma 1 '0.9998' '0.0003' -> '1.0001'
-
-dqadd3035 fma 1 '70' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3036 fma 1 '700' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3037 fma 1 '7000' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3038 fma 1 '70000' '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
-dqadd3039 fma 1 '700000' '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded
-
--- symmetry:
-dqadd3040 fma 1 '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3041 fma 1 '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3042 fma 1 '10000e+34' '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3044 fma 1 '10000e+34' '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
-dqadd3045 fma 1 '10000e+34' '700000' -> '1.000000000000000000000000000000007E+38' Rounded
-
--- same, without rounding
-dqadd3046 fma 1 '10000e+9' '7' -> '10000000000007'
-dqadd3047 fma 1 '10000e+9' '70' -> '10000000000070'
-dqadd3048 fma 1 '10000e+9' '700' -> '10000000000700'
-dqadd3049 fma 1 '10000e+9' '7000' -> '10000000007000'
-dqadd3050 fma 1 '10000e+9' '70000' -> '10000000070000'
-dqadd3051 fma 1 '10000e+9' '700000' -> '10000000700000'
-dqadd3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-dqadd3053 fma 1 '12' '7.00' -> '19.00'
-dqadd3054 fma 1 '1.3' '-1.07' -> '0.23'
-dqadd3055 fma 1 '1.3' '-1.30' -> '0.00'
-dqadd3056 fma 1 '1.3' '-2.07' -> '-0.77'
-dqadd3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
-
--- leading zero preservation
-dqadd3061 fma 1 1 '0.0001' -> '1.0001'
-dqadd3062 fma 1 1 '0.00001' -> '1.00001'
-dqadd3063 fma 1 1 '0.000001' -> '1.000001'
-dqadd3064 fma 1 1 '0.0000001' -> '1.0000001'
-dqadd3065 fma 1 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-dqadd3070 fma 1 1 0 -> 1
-dqadd3071 fma 1 1 0. -> 1
-dqadd3072 fma 1 1 .0 -> 1.0
-dqadd3073 fma 1 1 0.0 -> 1.0
-dqadd3074 fma 1 1 0.00 -> 1.00
-dqadd3075 fma 1 0 1 -> 1
-dqadd3076 fma 1 0. 1 -> 1
-dqadd3077 fma 1 .0 1 -> 1.0
-dqadd3078 fma 1 0.0 1 -> 1.0
-dqadd3079 fma 1 0.00 1 -> 1.00
-
--- some carries
-dqadd3080 fma 1 999999998 1 -> 999999999
-dqadd3081 fma 1 999999999 1 -> 1000000000
-dqadd3082 fma 1 99999999 1 -> 100000000
-dqadd3083 fma 1 9999999 1 -> 10000000
-dqadd3084 fma 1 999999 1 -> 1000000
-dqadd3085 fma 1 99999 1 -> 100000
-dqadd3086 fma 1 9999 1 -> 10000
-dqadd3087 fma 1 999 1 -> 1000
-dqadd3088 fma 1 99 1 -> 100
-dqadd3089 fma 1 9 1 -> 10
-
-
--- more LHS swaps
-dqadd3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
-dqadd3091 fma 1 '-56267E-6' 0 -> '-0.056267'
-dqadd3092 fma 1 '-56267E-5' 0 -> '-0.56267'
-dqadd3093 fma 1 '-56267E-4' 0 -> '-5.6267'
-dqadd3094 fma 1 '-56267E-3' 0 -> '-56.267'
-dqadd3095 fma 1 '-56267E-2' 0 -> '-562.67'
-dqadd3096 fma 1 '-56267E-1' 0 -> '-5626.7'
-dqadd3097 fma 1 '-56267E-0' 0 -> '-56267'
-dqadd3098 fma 1 '-5E-10' 0 -> '-5E-10'
-dqadd3099 fma 1 '-5E-7' 0 -> '-5E-7'
-dqadd3100 fma 1 '-5E-6' 0 -> '-0.000005'
-dqadd3101 fma 1 '-5E-5' 0 -> '-0.00005'
-dqadd3102 fma 1 '-5E-4' 0 -> '-0.0005'
-dqadd3103 fma 1 '-5E-1' 0 -> '-0.5'
-dqadd3104 fma 1 '-5E0' 0 -> '-5'
-dqadd3105 fma 1 '-5E1' 0 -> '-50'
-dqadd3106 fma 1 '-5E5' 0 -> '-500000'
-dqadd3107 fma 1 '-5E33' 0 -> '-5000000000000000000000000000000000'
-dqadd3108 fma 1 '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
-dqadd3109 fma 1 '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
-dqadd3110 fma 1 '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
-dqadd3111 fma 1 '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- more RHS swaps
-dqadd3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
-dqadd3114 fma 1 0 '-56267E-6' -> '-0.056267'
-dqadd3116 fma 1 0 '-56267E-5' -> '-0.56267'
-dqadd3117 fma 1 0 '-56267E-4' -> '-5.6267'
-dqadd3119 fma 1 0 '-56267E-3' -> '-56.267'
-dqadd3120 fma 1 0 '-56267E-2' -> '-562.67'
-dqadd3121 fma 1 0 '-56267E-1' -> '-5626.7'
-dqadd3122 fma 1 0 '-56267E-0' -> '-56267'
-dqadd3123 fma 1 0 '-5E-10' -> '-5E-10'
-dqadd3124 fma 1 0 '-5E-7' -> '-5E-7'
-dqadd3125 fma 1 0 '-5E-6' -> '-0.000005'
-dqadd3126 fma 1 0 '-5E-5' -> '-0.00005'
-dqadd3127 fma 1 0 '-5E-4' -> '-0.0005'
-dqadd3128 fma 1 0 '-5E-1' -> '-0.5'
-dqadd3129 fma 1 0 '-5E0' -> '-5'
-dqadd3130 fma 1 0 '-5E1' -> '-50'
-dqadd3131 fma 1 0 '-5E5' -> '-500000'
-dqadd3132 fma 1 0 '-5E33' -> '-5000000000000000000000000000000000'
-dqadd3133 fma 1 0 '-5E34' -> '-5.000000000000000000000000000000000E+34' Rounded
-dqadd3134 fma 1 0 '-5E35' -> '-5.000000000000000000000000000000000E+35' Rounded
-dqadd3135 fma 1 0 '-5E36' -> '-5.000000000000000000000000000000000E+36' Rounded
-dqadd3136 fma 1 0 '-5E100' -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- related
-dqadd3137 fma 1 1 '0E-39' -> '1.000000000000000000000000000000000' Rounded
-dqadd3138 fma 1 -1 '0E-39' -> '-1.000000000000000000000000000000000' Rounded
-dqadd3139 fma 1 '0E-39' 1 -> '1.000000000000000000000000000000000' Rounded
-dqadd3140 fma 1 '0E-39' -1 -> '-1.000000000000000000000000000000000' Rounded
-dqadd3141 fma 1 1E+29 0.0000 -> '100000000000000000000000000000.0000'
-dqadd3142 fma 1 1E+29 0.00000 -> '100000000000000000000000000000.0000' Rounded
-dqadd3143 fma 1 0.000 1E+30 -> '1000000000000000000000000000000.000'
-dqadd3144 fma 1 0.0000 1E+30 -> '1000000000000000000000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-dqadd3146 fma 1 '00.0' 0 -> '0.0'
-dqadd3147 fma 1 '0.00' 0 -> '0.00'
-dqadd3148 fma 1 0 '0.00' -> '0.00'
-dqadd3149 fma 1 0 '00.0' -> '0.0'
-dqadd3150 fma 1 '00.0' '0.00' -> '0.00'
-dqadd3151 fma 1 '0.00' '00.0' -> '0.00'
-dqadd3152 fma 1 '3' '.3' -> '3.3'
-dqadd3153 fma 1 '3.' '.3' -> '3.3'
-dqadd3154 fma 1 '3.0' '.3' -> '3.3'
-dqadd3155 fma 1 '3.00' '.3' -> '3.30'
-dqadd3156 fma 1 '3' '3' -> '6'
-dqadd3157 fma 1 '3' '+3' -> '6'
-dqadd3158 fma 1 '3' '-3' -> '0'
-dqadd3159 fma 1 '0.3' '-0.3' -> '0.0'
-dqadd3160 fma 1 '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-dqadd3161 fma 1 '1E+12' '-1' -> '999999999999'
-dqadd3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
-dqadd3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
-dqadd3164 fma 1 '-1' '1E+12' -> '999999999999'
-dqadd3165 fma 1 '7E+12' '-1' -> '6999999999999'
-dqadd3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
-dqadd3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
-dqadd3168 fma 1 '-1' '7E+12' -> '6999999999999'
-
-rounding: half_up
-dqadd3170 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd3171 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd3172 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd3173 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
-dqadd3174 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd3175 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd3176 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd3177 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
-dqadd3178 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd3179 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd3180 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd3181 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd3182 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd3183 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-dqadd3200 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd3201 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3202 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3203 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3204 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3205 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3206 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3207 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3208 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3209 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3210 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3211 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3212 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3213 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3214 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3215 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3216 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd3217 fma 1 '1231234567890123456784560123456789' 1.000000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3218 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3219 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
-
-rounding: half_even
-dqadd3220 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd3221 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3222 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3223 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3224 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3225 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3226 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3227 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3228 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3229 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3230 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3231 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3232 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3233 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3234 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3235 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3236 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd3237 fma 1 '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3238 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3239 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
--- critical few with even bottom digit...
-dqadd3240 fma 1 '1231234567890123456784560123456788' 0.499999999 -> '1231234567890123456784560123456788' Inexact Rounded
-dqadd3241 fma 1 '1231234567890123456784560123456788' 0.5 -> '1231234567890123456784560123456788' Inexact Rounded
-dqadd3242 fma 1 '1231234567890123456784560123456788' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
-
-rounding: down
-dqadd3250 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd3251 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3252 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3253 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3254 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3255 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3256 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3257 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3258 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3259 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3260 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3261 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3262 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3263 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3264 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3265 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3266 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd3267 fma 1 '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3268 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3269 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-dqadd3301 fma 1 -1 1 -> 0
-dqadd3302 fma 1 0 1 -> 1
-dqadd3303 fma 1 1 1 -> 2
-dqadd3304 fma 1 12 1 -> 13
-dqadd3305 fma 1 98 1 -> 99
-dqadd3306 fma 1 99 1 -> 100
-dqadd3307 fma 1 100 1 -> 101
-dqadd3308 fma 1 101 1 -> 102
-dqadd3309 fma 1 -1 -1 -> -2
-dqadd3310 fma 1 0 -1 -> -1
-dqadd3311 fma 1 1 -1 -> 0
-dqadd3312 fma 1 12 -1 -> 11
-dqadd3313 fma 1 98 -1 -> 97
-dqadd3314 fma 1 99 -1 -> 98
-dqadd3315 fma 1 100 -1 -> 99
-dqadd3316 fma 1 101 -1 -> 100
-
-dqadd3321 fma 1 -0.01 0.01 -> 0.00
-dqadd3322 fma 1 0.00 0.01 -> 0.01
-dqadd3323 fma 1 0.01 0.01 -> 0.02
-dqadd3324 fma 1 0.12 0.01 -> 0.13
-dqadd3325 fma 1 0.98 0.01 -> 0.99
-dqadd3326 fma 1 0.99 0.01 -> 1.00
-dqadd3327 fma 1 1.00 0.01 -> 1.01
-dqadd3328 fma 1 1.01 0.01 -> 1.02
-dqadd3329 fma 1 -0.01 -0.01 -> -0.02
-dqadd3330 fma 1 0.00 -0.01 -> -0.01
-dqadd3331 fma 1 0.01 -0.01 -> 0.00
-dqadd3332 fma 1 0.12 -0.01 -> 0.11
-dqadd3333 fma 1 0.98 -0.01 -> 0.97
-dqadd3334 fma 1 0.99 -0.01 -> 0.98
-dqadd3335 fma 1 1.00 -0.01 -> 0.99
-dqadd3336 fma 1 1.01 -0.01 -> 1.00
-
--- some more cases where adding 0 affects the coefficient
-dqadd3340 fma 1 1E+3 0 -> 1000
-dqadd3341 fma 1 1E+33 0 -> 1000000000000000000000000000000000
-dqadd3342 fma 1 1E+34 0 -> 1.000000000000000000000000000000000E+34 Rounded
-dqadd3343 fma 1 1E+35 0 -> 1.000000000000000000000000000000000E+35 Rounded
--- which simply follow from these cases ...
-dqadd3344 fma 1 1E+3 1 -> 1001
-dqadd3345 fma 1 1E+33 1 -> 1000000000000000000000000000000001
-dqadd3346 fma 1 1E+34 1 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd3347 fma 1 1E+35 1 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
-dqadd3348 fma 1 1E+3 7 -> 1007
-dqadd3349 fma 1 1E+33 7 -> 1000000000000000000000000000000007
-dqadd3350 fma 1 1E+34 7 -> 1.000000000000000000000000000000001E+34 Inexact Rounded
-dqadd3351 fma 1 1E+35 7 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
-
--- tryzeros cases
-rounding: half_up
-dqadd3360 fma 1 0E+50 10000E+1 -> 1.0000E+5
-dqadd3361 fma 1 0E-50 10000E+1 -> 100000.0000000000000000000000000000 Rounded
-dqadd3362 fma 1 10000E+1 0E-50 -> 100000.0000000000000000000000000000 Rounded
-dqadd3363 fma 1 10000E+1 10000E-50 -> 100000.0000000000000000000000000000 Rounded Inexact
-dqadd3364 fma 1 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
--- 1 234567890123456789012345678901234
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-dqadd3370 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd3371 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-rounding: half_up
-dqadd3372 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd3373 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-rounding: half_even
-dqadd3374 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd3375 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-
--- ulp replacement tests
-dqadd3400 fma 1 1 77e-32 -> 1.00000000000000000000000000000077
-dqadd3401 fma 1 1 77e-33 -> 1.000000000000000000000000000000077
-dqadd3402 fma 1 1 77e-34 -> 1.000000000000000000000000000000008 Inexact Rounded
-dqadd3403 fma 1 1 77e-35 -> 1.000000000000000000000000000000001 Inexact Rounded
-dqadd3404 fma 1 1 77e-36 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd3405 fma 1 1 77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd3406 fma 1 1 77e-299 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd3410 fma 1 10 77e-32 -> 10.00000000000000000000000000000077
-dqadd3411 fma 1 10 77e-33 -> 10.00000000000000000000000000000008 Inexact Rounded
-dqadd3412 fma 1 10 77e-34 -> 10.00000000000000000000000000000001 Inexact Rounded
-dqadd3413 fma 1 10 77e-35 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3414 fma 1 10 77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3415 fma 1 10 77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3416 fma 1 10 77e-299 -> 10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd3420 fma 1 77e-32 1 -> 1.00000000000000000000000000000077
-dqadd3421 fma 1 77e-33 1 -> 1.000000000000000000000000000000077
-dqadd3422 fma 1 77e-34 1 -> 1.000000000000000000000000000000008 Inexact Rounded
-dqadd3423 fma 1 77e-35 1 -> 1.000000000000000000000000000000001 Inexact Rounded
-dqadd3424 fma 1 77e-36 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd3425 fma 1 77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd3426 fma 1 77e-299 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd3430 fma 1 77e-32 10 -> 10.00000000000000000000000000000077
-dqadd3431 fma 1 77e-33 10 -> 10.00000000000000000000000000000008 Inexact Rounded
-dqadd3432 fma 1 77e-34 10 -> 10.00000000000000000000000000000001 Inexact Rounded
-dqadd3433 fma 1 77e-35 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3434 fma 1 77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3435 fma 1 77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3436 fma 1 77e-299 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-
--- negative ulps
-dqadd36440 fma 1 1 -77e-32 -> 0.99999999999999999999999999999923
-dqadd36441 fma 1 1 -77e-33 -> 0.999999999999999999999999999999923
-dqadd36442 fma 1 1 -77e-34 -> 0.9999999999999999999999999999999923
-dqadd36443 fma 1 1 -77e-35 -> 0.9999999999999999999999999999999992 Inexact Rounded
-dqadd36444 fma 1 1 -77e-36 -> 0.9999999999999999999999999999999999 Inexact Rounded
-dqadd36445 fma 1 1 -77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd36446 fma 1 1 -77e-99 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd36450 fma 1 10 -77e-32 -> 9.99999999999999999999999999999923
-dqadd36451 fma 1 10 -77e-33 -> 9.999999999999999999999999999999923
-dqadd36452 fma 1 10 -77e-34 -> 9.999999999999999999999999999999992 Inexact Rounded
-dqadd36453 fma 1 10 -77e-35 -> 9.999999999999999999999999999999999 Inexact Rounded
-dqadd36454 fma 1 10 -77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd36455 fma 1 10 -77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd36456 fma 1 10 -77e-99 -> 10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd36460 fma 1 -77e-32 1 -> 0.99999999999999999999999999999923
-dqadd36461 fma 1 -77e-33 1 -> 0.999999999999999999999999999999923
-dqadd36462 fma 1 -77e-34 1 -> 0.9999999999999999999999999999999923
-dqadd36463 fma 1 -77e-35 1 -> 0.9999999999999999999999999999999992 Inexact Rounded
-dqadd36464 fma 1 -77e-36 1 -> 0.9999999999999999999999999999999999 Inexact Rounded
-dqadd36465 fma 1 -77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd36466 fma 1 -77e-99 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd36470 fma 1 -77e-32 10 -> 9.99999999999999999999999999999923
-dqadd36471 fma 1 -77e-33 10 -> 9.999999999999999999999999999999923
-dqadd36472 fma 1 -77e-34 10 -> 9.999999999999999999999999999999992 Inexact Rounded
-dqadd36473 fma 1 -77e-35 10 -> 9.999999999999999999999999999999999 Inexact Rounded
-dqadd36474 fma 1 -77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd36475 fma 1 -77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd36476 fma 1 -77e-99 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-
--- negative ulps
-dqadd36480 fma 1 -1 77e-32 -> -0.99999999999999999999999999999923
-dqadd36481 fma 1 -1 77e-33 -> -0.999999999999999999999999999999923
-dqadd36482 fma 1 -1 77e-34 -> -0.9999999999999999999999999999999923
-dqadd36483 fma 1 -1 77e-35 -> -0.9999999999999999999999999999999992 Inexact Rounded
-dqadd36484 fma 1 -1 77e-36 -> -0.9999999999999999999999999999999999 Inexact Rounded
-dqadd36485 fma 1 -1 77e-37 -> -1.000000000000000000000000000000000 Inexact Rounded
-dqadd36486 fma 1 -1 77e-99 -> -1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd36490 fma 1 -10 77e-32 -> -9.99999999999999999999999999999923
-dqadd36491 fma 1 -10 77e-33 -> -9.999999999999999999999999999999923
-dqadd36492 fma 1 -10 77e-34 -> -9.999999999999999999999999999999992 Inexact Rounded
-dqadd36493 fma 1 -10 77e-35 -> -9.999999999999999999999999999999999 Inexact Rounded
-dqadd36494 fma 1 -10 77e-36 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd36495 fma 1 -10 77e-37 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd36496 fma 1 -10 77e-99 -> -10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd36500 fma 1 77e-32 -1 -> -0.99999999999999999999999999999923
-dqadd36501 fma 1 77e-33 -1 -> -0.999999999999999999999999999999923
-dqadd36502 fma 1 77e-34 -1 -> -0.9999999999999999999999999999999923
-dqadd36503 fma 1 77e-35 -1 -> -0.9999999999999999999999999999999992 Inexact Rounded
-dqadd36504 fma 1 77e-36 -1 -> -0.9999999999999999999999999999999999 Inexact Rounded
-dqadd36505 fma 1 77e-37 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
-dqadd36506 fma 1 77e-99 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd36510 fma 1 77e-32 -10 -> -9.99999999999999999999999999999923
-dqadd36511 fma 1 77e-33 -10 -> -9.999999999999999999999999999999923
-dqadd36512 fma 1 77e-34 -10 -> -9.999999999999999999999999999999992 Inexact Rounded
-dqadd36513 fma 1 77e-35 -10 -> -9.999999999999999999999999999999999 Inexact Rounded
-dqadd36514 fma 1 77e-36 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd36515 fma 1 77e-37 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd36516 fma 1 77e-99 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-
--- and some more residue effects and different roundings
-rounding: half_up
-dqadd36540 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd36541 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36542 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36543 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36544 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36545 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36546 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36547 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36548 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36549 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36550 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36551 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36552 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36553 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36554 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36555 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36556 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd36557 fma 1 '9876543219876543216543210123456789' 1.000000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36558 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36559 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
-rounding: half_even
-dqadd36560 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd36561 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36562 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36563 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36564 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36565 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36566 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36567 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36568 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36569 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36570 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36571 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36572 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36573 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36574 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36575 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36576 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd36577 fma 1 '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36578 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36579 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
--- critical few with even bottom digit...
-dqadd37540 fma 1 '9876543219876543216543210123456788' 0.499999999 -> '9876543219876543216543210123456788' Inexact Rounded
-dqadd37541 fma 1 '9876543219876543216543210123456788' 0.5 -> '9876543219876543216543210123456788' Inexact Rounded
-dqadd37542 fma 1 '9876543219876543216543210123456788' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
-
-rounding: down
-dqadd37550 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd37551 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37552 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37553 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37554 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37555 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37556 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37557 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37558 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37559 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37560 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37561 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37562 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37563 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37564 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37565 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37566 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd37567 fma 1 '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd37568 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd37569 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-dqadd37701 fma 1 5.00 1.00E-3 -> 5.00100
-dqadd37702 fma 1 00.00 0.000 -> 0.000
-dqadd37703 fma 1 00.00 0E-3 -> 0.000
-dqadd37704 fma 1 0E-3 00.00 -> 0.000
-
-dqadd37710 fma 1 0E+3 00.00 -> 0.00
-dqadd37711 fma 1 0E+3 00.0 -> 0.0
-dqadd37712 fma 1 0E+3 00. -> 0
-dqadd37713 fma 1 0E+3 00.E+1 -> 0E+1
-dqadd37714 fma 1 0E+3 00.E+2 -> 0E+2
-dqadd37715 fma 1 0E+3 00.E+3 -> 0E+3
-dqadd37716 fma 1 0E+3 00.E+4 -> 0E+3
-dqadd37717 fma 1 0E+3 00.E+5 -> 0E+3
-dqadd37718 fma 1 0E+3 -00.0 -> 0.0
-dqadd37719 fma 1 0E+3 -00. -> 0
-dqadd37731 fma 1 0E+3 -00.E+1 -> 0E+1
-
-dqadd37720 fma 1 00.00 0E+3 -> 0.00
-dqadd37721 fma 1 00.0 0E+3 -> 0.0
-dqadd37722 fma 1 00. 0E+3 -> 0
-dqadd37723 fma 1 00.E+1 0E+3 -> 0E+1
-dqadd37724 fma 1 00.E+2 0E+3 -> 0E+2
-dqadd37725 fma 1 00.E+3 0E+3 -> 0E+3
-dqadd37726 fma 1 00.E+4 0E+3 -> 0E+3
-dqadd37727 fma 1 00.E+5 0E+3 -> 0E+3
-dqadd37728 fma 1 -00.00 0E+3 -> 0.00
-dqadd37729 fma 1 -00.0 0E+3 -> 0.0
-dqadd37730 fma 1 -00. 0E+3 -> 0
-
-dqadd37732 fma 1 0 0 -> 0
-dqadd37733 fma 1 0 -0 -> 0
-dqadd37734 fma 1 -0 0 -> 0
-dqadd37735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
-
-dqadd37736 fma 1 1 -1 -> 0
-dqadd37737 fma 1 -1 -1 -> -2
-dqadd37738 fma 1 1 1 -> 2
-dqadd37739 fma 1 -1 1 -> 0
-
-dqadd37741 fma 1 0 -1 -> -1
-dqadd37742 fma 1 -0 -1 -> -1
-dqadd37743 fma 1 0 1 -> 1
-dqadd37744 fma 1 -0 1 -> 1
-dqadd37745 fma 1 -1 0 -> -1
-dqadd37746 fma 1 -1 -0 -> -1
-dqadd37747 fma 1 1 0 -> 1
-dqadd37748 fma 1 1 -0 -> 1
-
-dqadd37751 fma 1 0.0 -1 -> -1.0
-dqadd37752 fma 1 -0.0 -1 -> -1.0
-dqadd37753 fma 1 0.0 1 -> 1.0
-dqadd37754 fma 1 -0.0 1 -> 1.0
-dqadd37755 fma 1 -1.0 0 -> -1.0
-dqadd37756 fma 1 -1.0 -0 -> -1.0
-dqadd37757 fma 1 1.0 0 -> 1.0
-dqadd37758 fma 1 1.0 -0 -> 1.0
-
-dqadd37761 fma 1 0 -1.0 -> -1.0
-dqadd37762 fma 1 -0 -1.0 -> -1.0
-dqadd37763 fma 1 0 1.0 -> 1.0
-dqadd37764 fma 1 -0 1.0 -> 1.0
-dqadd37765 fma 1 -1 0.0 -> -1.0
-dqadd37766 fma 1 -1 -0.0 -> -1.0
-dqadd37767 fma 1 1 0.0 -> 1.0
-dqadd37768 fma 1 1 -0.0 -> 1.0
-
-dqadd37771 fma 1 0.0 -1.0 -> -1.0
-dqadd37772 fma 1 -0.0 -1.0 -> -1.0
-dqadd37773 fma 1 0.0 1.0 -> 1.0
-dqadd37774 fma 1 -0.0 1.0 -> 1.0
-dqadd37775 fma 1 -1.0 0.0 -> -1.0
-dqadd37776 fma 1 -1.0 -0.0 -> -1.0
-dqadd37777 fma 1 1.0 0.0 -> 1.0
-dqadd37778 fma 1 1.0 -0.0 -> 1.0
-
--- Specials
-dqadd37780 fma 1 -Inf -Inf -> -Infinity
-dqadd37781 fma 1 -Inf -1000 -> -Infinity
-dqadd37782 fma 1 -Inf -1 -> -Infinity
-dqadd37783 fma 1 -Inf -0 -> -Infinity
-dqadd37784 fma 1 -Inf 0 -> -Infinity
-dqadd37785 fma 1 -Inf 1 -> -Infinity
-dqadd37786 fma 1 -Inf 1000 -> -Infinity
-dqadd37787 fma 1 -1000 -Inf -> -Infinity
-dqadd37788 fma 1 -Inf -Inf -> -Infinity
-dqadd37789 fma 1 -1 -Inf -> -Infinity
-dqadd37790 fma 1 -0 -Inf -> -Infinity
-dqadd37791 fma 1 0 -Inf -> -Infinity
-dqadd37792 fma 1 1 -Inf -> -Infinity
-dqadd37793 fma 1 1000 -Inf -> -Infinity
-dqadd37794 fma 1 Inf -Inf -> NaN Invalid_operation
-
-dqadd37800 fma 1 Inf -Inf -> NaN Invalid_operation
-dqadd37801 fma 1 Inf -1000 -> Infinity
-dqadd37802 fma 1 Inf -1 -> Infinity
-dqadd37803 fma 1 Inf -0 -> Infinity
-dqadd37804 fma 1 Inf 0 -> Infinity
-dqadd37805 fma 1 Inf 1 -> Infinity
-dqadd37806 fma 1 Inf 1000 -> Infinity
-dqadd37807 fma 1 Inf Inf -> Infinity
-dqadd37808 fma 1 -1000 Inf -> Infinity
-dqadd37809 fma 1 -Inf Inf -> NaN Invalid_operation
-dqadd37810 fma 1 -1 Inf -> Infinity
-dqadd37811 fma 1 -0 Inf -> Infinity
-dqadd37812 fma 1 0 Inf -> Infinity
-dqadd37813 fma 1 1 Inf -> Infinity
-dqadd37814 fma 1 1000 Inf -> Infinity
-dqadd37815 fma 1 Inf Inf -> Infinity
-
-dqadd37821 fma 1 NaN -Inf -> NaN
-dqadd37822 fma 1 NaN -1000 -> NaN
-dqadd37823 fma 1 NaN -1 -> NaN
-dqadd37824 fma 1 NaN -0 -> NaN
-dqadd37825 fma 1 NaN 0 -> NaN
-dqadd37826 fma 1 NaN 1 -> NaN
-dqadd37827 fma 1 NaN 1000 -> NaN
-dqadd37828 fma 1 NaN Inf -> NaN
-dqadd37829 fma 1 NaN NaN -> NaN
-dqadd37830 fma 1 -Inf NaN -> NaN
-dqadd37831 fma 1 -1000 NaN -> NaN
-dqadd37832 fma 1 -1 NaN -> NaN
-dqadd37833 fma 1 -0 NaN -> NaN
-dqadd37834 fma 1 0 NaN -> NaN
-dqadd37835 fma 1 1 NaN -> NaN
-dqadd37836 fma 1 1000 NaN -> NaN
-dqadd37837 fma 1 Inf NaN -> NaN
-
-dqadd37841 fma 1 sNaN -Inf -> NaN Invalid_operation
-dqadd37842 fma 1 sNaN -1000 -> NaN Invalid_operation
-dqadd37843 fma 1 sNaN -1 -> NaN Invalid_operation
-dqadd37844 fma 1 sNaN -0 -> NaN Invalid_operation
-dqadd37845 fma 1 sNaN 0 -> NaN Invalid_operation
-dqadd37846 fma 1 sNaN 1 -> NaN Invalid_operation
-dqadd37847 fma 1 sNaN 1000 -> NaN Invalid_operation
-dqadd37848 fma 1 sNaN NaN -> NaN Invalid_operation
-dqadd37849 fma 1 sNaN sNaN -> NaN Invalid_operation
-dqadd37850 fma 1 NaN sNaN -> NaN Invalid_operation
-dqadd37851 fma 1 -Inf sNaN -> NaN Invalid_operation
-dqadd37852 fma 1 -1000 sNaN -> NaN Invalid_operation
-dqadd37853 fma 1 -1 sNaN -> NaN Invalid_operation
-dqadd37854 fma 1 -0 sNaN -> NaN Invalid_operation
-dqadd37855 fma 1 0 sNaN -> NaN Invalid_operation
-dqadd37856 fma 1 1 sNaN -> NaN Invalid_operation
-dqadd37857 fma 1 1000 sNaN -> NaN Invalid_operation
-dqadd37858 fma 1 Inf sNaN -> NaN Invalid_operation
-dqadd37859 fma 1 NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqadd37861 fma 1 NaN1 -Inf -> NaN1
-dqadd37862 fma 1 +NaN2 -1000 -> NaN2
-dqadd37863 fma 1 NaN3 1000 -> NaN3
-dqadd37864 fma 1 NaN4 Inf -> NaN4
-dqadd37865 fma 1 NaN5 +NaN6 -> NaN5
-dqadd37866 fma 1 -Inf NaN7 -> NaN7
-dqadd37867 fma 1 -1000 NaN8 -> NaN8
-dqadd37868 fma 1 1000 NaN9 -> NaN9
-dqadd37869 fma 1 Inf +NaN10 -> NaN10
-dqadd37871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
-dqadd37872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
-dqadd37873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
-dqadd37874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
-dqadd37875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqadd37876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
-dqadd37877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
-dqadd37878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
-dqadd37879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
-dqadd37880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
-dqadd37881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqadd37882 fma 1 -NaN26 NaN28 -> -NaN26
-dqadd37883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqadd37884 fma 1 1000 -NaN30 -> -NaN30
-dqadd37885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Here we explore near the boundary of rounding a subnormal to Nmin
-dqadd37575 fma 1 1E-6143 -1E-6176 -> 9.99999999999999999999999999999999E-6144 Subnormal
-dqadd37576 fma 1 -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal
-
--- check overflow edge case
--- 1234567890123456
-dqadd37972 apply 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqadd37973 fma 1 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37974 fma 1 9999999999999999999999999999999999E+6111 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37975 fma 1 9999999999999999999999999999999999E+6111 1E+6111 -> Infinity Overflow Inexact Rounded
-dqadd37976 fma 1 9999999999999999999999999999999999E+6111 9E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37977 fma 1 9999999999999999999999999999999999E+6111 8E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37978 fma 1 9999999999999999999999999999999999E+6111 7E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37979 fma 1 9999999999999999999999999999999999E+6111 6E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37980 fma 1 9999999999999999999999999999999999E+6111 5E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37981 fma 1 9999999999999999999999999999999999E+6111 4E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37982 fma 1 9999999999999999999999999999999999E+6111 3E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37983 fma 1 9999999999999999999999999999999999E+6111 2E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37984 fma 1 9999999999999999999999999999999999E+6111 1E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-
-dqadd37985 apply -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqadd37986 fma 1 -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37987 fma 1 -9999999999999999999999999999999999E+6111 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37988 fma 1 -9999999999999999999999999999999999E+6111 -1E+6111 -> -Infinity Overflow Inexact Rounded
-dqadd37989 fma 1 -9999999999999999999999999999999999E+6111 -9E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37990 fma 1 -9999999999999999999999999999999999E+6111 -8E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37991 fma 1 -9999999999999999999999999999999999E+6111 -7E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37992 fma 1 -9999999999999999999999999999999999E+6111 -6E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37993 fma 1 -9999999999999999999999999999999999E+6111 -5E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37994 fma 1 -9999999999999999999999999999999999E+6111 -4E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37995 fma 1 -9999999999999999999999999999999999E+6111 -3E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37996 fma 1 -9999999999999999999999999999999999E+6111 -2E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37997 fma 1 -9999999999999999999999999999999999E+6111 -1E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-dqadd371100 fma 1 1e+2 -1e-6143 -> 99.99999999999999999999999999999999 Rounded Inexact
-dqadd371101 fma 1 1e+1 -1e-6143 -> 9.999999999999999999999999999999999 Rounded Inexact
-dqadd371103 fma 1 +1 -1e-6143 -> 0.9999999999999999999999999999999999 Rounded Inexact
-dqadd371104 fma 1 1e-1 -1e-6143 -> 0.09999999999999999999999999999999999 Rounded Inexact
-dqadd371105 fma 1 1e-2 -1e-6143 -> 0.009999999999999999999999999999999999 Rounded Inexact
-dqadd371106 fma 1 1e-3 -1e-6143 -> 0.0009999999999999999999999999999999999 Rounded Inexact
-dqadd371107 fma 1 1e-4 -1e-6143 -> 0.00009999999999999999999999999999999999 Rounded Inexact
-dqadd371108 fma 1 1e-5 -1e-6143 -> 0.000009999999999999999999999999999999999 Rounded Inexact
-dqadd371109 fma 1 1e-6 -1e-6143 -> 9.999999999999999999999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-dqadd371110 fma 1 -1e+2 +1e-6143 -> -99.99999999999999999999999999999999 Rounded Inexact
-dqadd371111 fma 1 -1e+1 +1e-6143 -> -9.999999999999999999999999999999999 Rounded Inexact
-dqadd371113 fma 1 -1 +1e-6143 -> -0.9999999999999999999999999999999999 Rounded Inexact
-dqadd371114 fma 1 -1e-1 +1e-6143 -> -0.09999999999999999999999999999999999 Rounded Inexact
-dqadd371115 fma 1 -1e-2 +1e-6143 -> -0.009999999999999999999999999999999999 Rounded Inexact
-dqadd371116 fma 1 -1e-3 +1e-6143 -> -0.0009999999999999999999999999999999999 Rounded Inexact
-dqadd371117 fma 1 -1e-4 +1e-6143 -> -0.00009999999999999999999999999999999999 Rounded Inexact
-dqadd371118 fma 1 -1e-5 +1e-6143 -> -0.000009999999999999999999999999999999999 Rounded Inexact
-dqadd371119 fma 1 -1e-6 +1e-6143 -> -9.999999999999999999999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-dqadd371300 fma 1 1E34 -0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371310 fma 1 1E34 -0.51 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371311 fma 1 1E34 -0.501 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371312 fma 1 1E34 -0.5001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371313 fma 1 1E34 -0.50001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371314 fma 1 1E34 -0.500001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371315 fma 1 1E34 -0.5000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371316 fma 1 1E34 -0.50000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371317 fma 1 1E34 -0.500000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371318 fma 1 1E34 -0.5000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371319 fma 1 1E34 -0.50000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371320 fma 1 1E34 -0.500000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371321 fma 1 1E34 -0.5000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371322 fma 1 1E34 -0.50000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371323 fma 1 1E34 -0.500000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371324 fma 1 1E34 -0.5000000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371325 fma 1 1E34 -0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371326 fma 1 1E34 -0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371327 fma 1 1E34 -0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371328 fma 1 1E34 -0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371329 fma 1 1E34 -0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371330 fma 1 1E34 -0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371331 fma 1 1E34 -0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371332 fma 1 1E34 -0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371333 fma 1 1E34 -0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371334 fma 1 1E34 -0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371335 fma 1 1E34 -0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371336 fma 1 1E34 -0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371337 fma 1 1E34 -0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371338 fma 1 1E34 -0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371339 fma 1 1E34 -0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-
-dqadd371340 fma 1 1E34 -5000000.000010001 -> 9999999999999999999999999995000000 Inexact Rounded
-dqadd371341 fma 1 1E34 -5000000.000000001 -> 9999999999999999999999999995000000 Inexact Rounded
-
-dqadd371349 fma 1 9999999999999999999999999999999999 0.4 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371350 fma 1 9999999999999999999999999999999999 0.49 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371351 fma 1 9999999999999999999999999999999999 0.499 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371352 fma 1 9999999999999999999999999999999999 0.4999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371353 fma 1 9999999999999999999999999999999999 0.49999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371354 fma 1 9999999999999999999999999999999999 0.499999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371355 fma 1 9999999999999999999999999999999999 0.4999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371356 fma 1 9999999999999999999999999999999999 0.49999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371357 fma 1 9999999999999999999999999999999999 0.499999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371358 fma 1 9999999999999999999999999999999999 0.4999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371359 fma 1 9999999999999999999999999999999999 0.49999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371360 fma 1 9999999999999999999999999999999999 0.499999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371361 fma 1 9999999999999999999999999999999999 0.4999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371362 fma 1 9999999999999999999999999999999999 0.49999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371363 fma 1 9999999999999999999999999999999999 0.499999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371364 fma 1 9999999999999999999999999999999999 0.4999999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371365 fma 1 9999999999999999999999999999999999 0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371367 fma 1 9999999999999999999999999999999999 0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371368 fma 1 9999999999999999999999999999999999 0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371369 fma 1 9999999999999999999999999999999999 0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371370 fma 1 9999999999999999999999999999999999 0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371371 fma 1 9999999999999999999999999999999999 0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371372 fma 1 9999999999999999999999999999999999 0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371373 fma 1 9999999999999999999999999999999999 0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371374 fma 1 9999999999999999999999999999999999 0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371375 fma 1 9999999999999999999999999999999999 0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371376 fma 1 9999999999999999999999999999999999 0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371377 fma 1 9999999999999999999999999999999999 0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371378 fma 1 9999999999999999999999999999999999 0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371379 fma 1 9999999999999999999999999999999999 0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371380 fma 1 9999999999999999999999999999999999 0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371381 fma 1 9999999999999999999999999999999999 0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371382 fma 1 9999999999999999999999999999999999 0.5000000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371383 fma 1 9999999999999999999999999999999999 0.500000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371384 fma 1 9999999999999999999999999999999999 0.50000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371385 fma 1 9999999999999999999999999999999999 0.5000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371386 fma 1 9999999999999999999999999999999999 0.500000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371387 fma 1 9999999999999999999999999999999999 0.50000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371388 fma 1 9999999999999999999999999999999999 0.5000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371389 fma 1 9999999999999999999999999999999999 0.500000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371390 fma 1 9999999999999999999999999999999999 0.50000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371391 fma 1 9999999999999999999999999999999999 0.5000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371392 fma 1 9999999999999999999999999999999999 0.500001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371393 fma 1 9999999999999999999999999999999999 0.50001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371394 fma 1 9999999999999999999999999999999999 0.5001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371395 fma 1 9999999999999999999999999999999999 0.501 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371396 fma 1 9999999999999999999999999999999999 0.51 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-dqadd371420 fma 1 0 1.123456789987654321123456789012345 -> 1.123456789987654321123456789012345
-dqadd371421 fma 1 0 1.123456789987654321123456789012345E-1 -> 0.1123456789987654321123456789012345
-dqadd371422 fma 1 0 1.123456789987654321123456789012345E-2 -> 0.01123456789987654321123456789012345
-dqadd371423 fma 1 0 1.123456789987654321123456789012345E-3 -> 0.001123456789987654321123456789012345
-dqadd371424 fma 1 0 1.123456789987654321123456789012345E-4 -> 0.0001123456789987654321123456789012345
-dqadd371425 fma 1 0 1.123456789987654321123456789012345E-5 -> 0.00001123456789987654321123456789012345
-dqadd371426 fma 1 0 1.123456789987654321123456789012345E-6 -> 0.000001123456789987654321123456789012345
-dqadd371427 fma 1 0 1.123456789987654321123456789012345E-7 -> 1.123456789987654321123456789012345E-7
-dqadd371428 fma 1 0 1.123456789987654321123456789012345E-8 -> 1.123456789987654321123456789012345E-8
-dqadd371429 fma 1 0 1.123456789987654321123456789012345E-9 -> 1.123456789987654321123456789012345E-9
-dqadd371430 fma 1 0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
-dqadd371431 fma 1 0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
-dqadd371432 fma 1 0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
-dqadd371433 fma 1 0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
-dqadd371434 fma 1 0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
-dqadd371435 fma 1 0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
-dqadd371436 fma 1 0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
-dqadd371437 fma 1 0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
-dqadd371438 fma 1 0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
-dqadd371439 fma 1 0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
-dqadd371440 fma 1 0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
-dqadd371441 fma 1 0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
-dqadd371442 fma 1 0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
-dqadd371443 fma 1 0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
-dqadd371444 fma 1 0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
-dqadd371445 fma 1 0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
-dqadd371446 fma 1 0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
-dqadd371447 fma 1 0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
-dqadd371448 fma 1 0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
-dqadd371449 fma 1 0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
-dqadd371450 fma 1 0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
-dqadd371451 fma 1 0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
-dqadd371452 fma 1 0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
-dqadd371453 fma 1 0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
-dqadd371454 fma 1 0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
-dqadd371455 fma 1 0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
-dqadd371456 fma 1 0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36
-
--- same, reversed 0
-dqadd371460 fma 1 1.123456789987654321123456789012345 0 -> 1.123456789987654321123456789012345
-dqadd371461 fma 1 1.123456789987654321123456789012345E-1 0 -> 0.1123456789987654321123456789012345
-dqadd371462 fma 1 1.123456789987654321123456789012345E-2 0 -> 0.01123456789987654321123456789012345
-dqadd371463 fma 1 1.123456789987654321123456789012345E-3 0 -> 0.001123456789987654321123456789012345
-dqadd371464 fma 1 1.123456789987654321123456789012345E-4 0 -> 0.0001123456789987654321123456789012345
-dqadd371465 fma 1 1.123456789987654321123456789012345E-5 0 -> 0.00001123456789987654321123456789012345
-dqadd371466 fma 1 1.123456789987654321123456789012345E-6 0 -> 0.000001123456789987654321123456789012345
-dqadd371467 fma 1 1.123456789987654321123456789012345E-7 0 -> 1.123456789987654321123456789012345E-7
-dqadd371468 fma 1 1.123456789987654321123456789012345E-8 0 -> 1.123456789987654321123456789012345E-8
-dqadd371469 fma 1 1.123456789987654321123456789012345E-9 0 -> 1.123456789987654321123456789012345E-9
-dqadd371470 fma 1 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
-dqadd371471 fma 1 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
-dqadd371472 fma 1 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
-dqadd371473 fma 1 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
-dqadd371474 fma 1 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
-dqadd371475 fma 1 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
-dqadd371476 fma 1 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
-dqadd371477 fma 1 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
-dqadd371478 fma 1 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
-dqadd371479 fma 1 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
-dqadd371480 fma 1 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
-dqadd371481 fma 1 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
-dqadd371482 fma 1 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
-dqadd371483 fma 1 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
-dqadd371484 fma 1 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
-dqadd371485 fma 1 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
-dqadd371486 fma 1 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
-dqadd371487 fma 1 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
-dqadd371488 fma 1 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
-dqadd371489 fma 1 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
-dqadd371490 fma 1 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
-dqadd371491 fma 1 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
-dqadd371492 fma 1 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
-dqadd371493 fma 1 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
-dqadd371494 fma 1 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
-dqadd371495 fma 1 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
-dqadd371496 fma 1 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36
-
--- same, Es on the 0
-dqadd371500 fma 1 1.123456789987654321123456789012345 0E-0 -> 1.123456789987654321123456789012345
-dqadd371501 fma 1 1.123456789987654321123456789012345 0E-1 -> 1.123456789987654321123456789012345
-dqadd371502 fma 1 1.123456789987654321123456789012345 0E-2 -> 1.123456789987654321123456789012345
-dqadd371503 fma 1 1.123456789987654321123456789012345 0E-3 -> 1.123456789987654321123456789012345
-dqadd371504 fma 1 1.123456789987654321123456789012345 0E-4 -> 1.123456789987654321123456789012345
-dqadd371505 fma 1 1.123456789987654321123456789012345 0E-5 -> 1.123456789987654321123456789012345
-dqadd371506 fma 1 1.123456789987654321123456789012345 0E-6 -> 1.123456789987654321123456789012345
-dqadd371507 fma 1 1.123456789987654321123456789012345 0E-7 -> 1.123456789987654321123456789012345
-dqadd371508 fma 1 1.123456789987654321123456789012345 0E-8 -> 1.123456789987654321123456789012345
-dqadd371509 fma 1 1.123456789987654321123456789012345 0E-9 -> 1.123456789987654321123456789012345
-dqadd371510 fma 1 1.123456789987654321123456789012345 0E-10 -> 1.123456789987654321123456789012345
-dqadd371511 fma 1 1.123456789987654321123456789012345 0E-11 -> 1.123456789987654321123456789012345
-dqadd371512 fma 1 1.123456789987654321123456789012345 0E-12 -> 1.123456789987654321123456789012345
-dqadd371513 fma 1 1.123456789987654321123456789012345 0E-13 -> 1.123456789987654321123456789012345
-dqadd371514 fma 1 1.123456789987654321123456789012345 0E-14 -> 1.123456789987654321123456789012345
-dqadd371515 fma 1 1.123456789987654321123456789012345 0E-15 -> 1.123456789987654321123456789012345
-dqadd371516 fma 1 1.123456789987654321123456789012345 0E-16 -> 1.123456789987654321123456789012345
-dqadd371517 fma 1 1.123456789987654321123456789012345 0E-17 -> 1.123456789987654321123456789012345
-dqadd371518 fma 1 1.123456789987654321123456789012345 0E-18 -> 1.123456789987654321123456789012345
-dqadd371519 fma 1 1.123456789987654321123456789012345 0E-19 -> 1.123456789987654321123456789012345
-dqadd371520 fma 1 1.123456789987654321123456789012345 0E-20 -> 1.123456789987654321123456789012345
-dqadd371521 fma 1 1.123456789987654321123456789012345 0E-21 -> 1.123456789987654321123456789012345
-dqadd371522 fma 1 1.123456789987654321123456789012345 0E-22 -> 1.123456789987654321123456789012345
-dqadd371523 fma 1 1.123456789987654321123456789012345 0E-23 -> 1.123456789987654321123456789012345
-dqadd371524 fma 1 1.123456789987654321123456789012345 0E-24 -> 1.123456789987654321123456789012345
-dqadd371525 fma 1 1.123456789987654321123456789012345 0E-25 -> 1.123456789987654321123456789012345
-dqadd371526 fma 1 1.123456789987654321123456789012345 0E-26 -> 1.123456789987654321123456789012345
-dqadd371527 fma 1 1.123456789987654321123456789012345 0E-27 -> 1.123456789987654321123456789012345
-dqadd371528 fma 1 1.123456789987654321123456789012345 0E-28 -> 1.123456789987654321123456789012345
-dqadd371529 fma 1 1.123456789987654321123456789012345 0E-29 -> 1.123456789987654321123456789012345
-dqadd371530 fma 1 1.123456789987654321123456789012345 0E-30 -> 1.123456789987654321123456789012345
-dqadd371531 fma 1 1.123456789987654321123456789012345 0E-31 -> 1.123456789987654321123456789012345
-dqadd371532 fma 1 1.123456789987654321123456789012345 0E-32 -> 1.123456789987654321123456789012345
-dqadd371533 fma 1 1.123456789987654321123456789012345 0E-33 -> 1.123456789987654321123456789012345
--- next four flag Rounded because the 0 extends the result
-dqadd371534 fma 1 1.123456789987654321123456789012345 0E-34 -> 1.123456789987654321123456789012345 Rounded
-dqadd371535 fma 1 1.123456789987654321123456789012345 0E-35 -> 1.123456789987654321123456789012345 Rounded
-dqadd371536 fma 1 1.123456789987654321123456789012345 0E-36 -> 1.123456789987654321123456789012345 Rounded
-dqadd371537 fma 1 1.123456789987654321123456789012345 0E-37 -> 1.123456789987654321123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-dqadd371600 fma 1 0 0E-19 -> 0E-19
-dqadd371601 fma 1 -0 0E-19 -> 0E-19
-dqadd371602 fma 1 0 -0E-19 -> 0E-19
-dqadd371603 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371611 fma 1 -11 11 -> 0
-dqadd371612 fma 1 11 -11 -> 0
--- overflow
-dqadd371613 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371614 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: half_down
--- exact zeros from zeros
-dqadd371620 fma 1 0 0E-19 -> 0E-19
-dqadd371621 fma 1 -0 0E-19 -> 0E-19
-dqadd371622 fma 1 0 -0E-19 -> 0E-19
-dqadd371623 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371631 fma 1 -11 11 -> 0
-dqadd371632 fma 1 11 -11 -> 0
--- overflow
-dqadd371633 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371634 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: half_even
--- exact zeros from zeros
-dqadd371640 fma 1 0 0E-19 -> 0E-19
-dqadd371641 fma 1 -0 0E-19 -> 0E-19
-dqadd371642 fma 1 0 -0E-19 -> 0E-19
-dqadd371643 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371651 fma 1 -11 11 -> 0
-dqadd371652 fma 1 11 -11 -> 0
--- overflow
-dqadd371653 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371654 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: up
--- exact zeros from zeros
-dqadd371660 fma 1 0 0E-19 -> 0E-19
-dqadd371661 fma 1 -0 0E-19 -> 0E-19
-dqadd371662 fma 1 0 -0E-19 -> 0E-19
-dqadd371663 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371671 fma 1 -11 11 -> 0
-dqadd371672 fma 1 11 -11 -> 0
--- overflow
-dqadd371673 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371674 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: down
--- exact zeros from zeros
-dqadd371680 fma 1 0 0E-19 -> 0E-19
-dqadd371681 fma 1 -0 0E-19 -> 0E-19
-dqadd371682 fma 1 0 -0E-19 -> 0E-19
-dqadd371683 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371691 fma 1 -11 11 -> 0
-dqadd371692 fma 1 11 -11 -> 0
--- overflow
-dqadd371693 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqadd371694 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-
-rounding: ceiling
--- exact zeros from zeros
-dqadd371700 fma 1 0 0E-19 -> 0E-19
-dqadd371701 fma 1 -0 0E-19 -> 0E-19
-dqadd371702 fma 1 0 -0E-19 -> 0E-19
-dqadd371703 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371711 fma 1 -11 11 -> 0
-dqadd371712 fma 1 11 -11 -> 0
--- overflow
-dqadd371713 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371714 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-dqadd371720 fma 1 0 0E-19 -> 0E-19
-dqadd371721 fma 1 -0 0E-19 -> -0E-19 -- *
-dqadd371722 fma 1 0 -0E-19 -> -0E-19 -- *
-dqadd371723 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371731 fma 1 -11 11 -> -0 -- *
-dqadd371732 fma 1 11 -11 -> -0 -- *
--- overflow
-dqadd371733 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqadd371734 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: 05up
--- exact zeros from zeros
-dqadd371740 fma 1 0 0E-19 -> 0E-19
-dqadd371741 fma 1 -0 0E-19 -> 0E-19
-dqadd371742 fma 1 0 -0E-19 -> 0E-19
-dqadd371743 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371751 fma 1 -11 11 -> 0
-dqadd371752 fma 1 11 -11 -> 0
--- overflow
-dqadd371753 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqadd371754 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dqadd371761 fma 1 130E-2 120E-2 -> 2.50
-dqadd371762 fma 1 130E-2 12E-1 -> 2.50
-dqadd371763 fma 1 130E-2 1E0 -> 2.30
-dqadd371764 fma 1 1E2 1E4 -> 1.01E+4
-dqadd371765 fma 1 130E-2 -120E-2 -> 0.10
-dqadd371766 fma 1 130E-2 -12E-1 -> 0.10
-dqadd371767 fma 1 130E-2 -1E0 -> 0.30
-dqadd371768 fma 1 1E2 -1E4 -> -9.9E+3
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-dqadd375001 fma 1 1239876543211234567894567890123456 1 -> 1239876543211234567894567890123457
-dqadd375002 fma 1 1239876543211234567894567890123456 0.6 -> 1239876543211234567894567890123457 Inexact Rounded
-dqadd375003 fma 1 1239876543211234567894567890123456 0.06 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375004 fma 1 1239876543211234567894567890123456 6E-3 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375005 fma 1 1239876543211234567894567890123456 6E-4 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375006 fma 1 1239876543211234567894567890123456 6E-5 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375007 fma 1 1239876543211234567894567890123456 6E-6 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375008 fma 1 1239876543211234567894567890123456 6E-7 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375009 fma 1 1239876543211234567894567890123456 6E-8 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375010 fma 1 1239876543211234567894567890123456 6E-9 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375011 fma 1 1239876543211234567894567890123456 6E-10 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375012 fma 1 1239876543211234567894567890123456 6E-11 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375013 fma 1 1239876543211234567894567890123456 6E-12 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375014 fma 1 1239876543211234567894567890123456 6E-13 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375015 fma 1 1239876543211234567894567890123456 6E-14 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375016 fma 1 1239876543211234567894567890123456 6E-15 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375017 fma 1 1239876543211234567894567890123456 6E-16 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375018 fma 1 1239876543211234567894567890123456 6E-17 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375019 fma 1 1239876543211234567894567890123456 6E-18 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375020 fma 1 1239876543211234567894567890123456 6E-19 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375021 fma 1 1239876543211234567894567890123456 6E-20 -> 1239876543211234567894567890123456 Inexact Rounded
-
--- widening second argument at gap
-dqadd375030 fma 1 12398765432112345678945678 1 -> 12398765432112345678945679
-dqadd375031 fma 1 12398765432112345678945678 0.1 -> 12398765432112345678945678.1
-dqadd375032 fma 1 12398765432112345678945678 0.12 -> 12398765432112345678945678.12
-dqadd375033 fma 1 12398765432112345678945678 0.123 -> 12398765432112345678945678.123
-dqadd375034 fma 1 12398765432112345678945678 0.1234 -> 12398765432112345678945678.1234
-dqadd375035 fma 1 12398765432112345678945678 0.12345 -> 12398765432112345678945678.12345
-dqadd375036 fma 1 12398765432112345678945678 0.123456 -> 12398765432112345678945678.123456
-dqadd375037 fma 1 12398765432112345678945678 0.1234567 -> 12398765432112345678945678.1234567
-dqadd375038 fma 1 12398765432112345678945678 0.12345678 -> 12398765432112345678945678.12345678
-dqadd375039 fma 1 12398765432112345678945678 0.123456789 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375040 fma 1 12398765432112345678945678 0.123456785 -> 12398765432112345678945678.12345678 Inexact Rounded
-dqadd375041 fma 1 12398765432112345678945678 0.1234567850 -> 12398765432112345678945678.12345678 Inexact Rounded
-dqadd375042 fma 1 12398765432112345678945678 0.1234567851 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375043 fma 1 12398765432112345678945678 0.12345678501 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375044 fma 1 12398765432112345678945678 0.123456785001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375045 fma 1 12398765432112345678945678 0.1234567850001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375046 fma 1 12398765432112345678945678 0.12345678500001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375047 fma 1 12398765432112345678945678 0.123456785000001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375048 fma 1 12398765432112345678945678 0.1234567850000001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375049 fma 1 12398765432112345678945678 0.1234567850000000 -> 12398765432112345678945678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-dqadd375050 fma 1 12398765432112345678945678 0.0234567750000000 -> 12398765432112345678945678.02345678 Inexact Rounded
-dqadd375051 fma 1 12398765432112345678945678 0.0034567750000000 -> 12398765432112345678945678.00345678 Inexact Rounded
-dqadd375052 fma 1 12398765432112345678945678 0.0004567750000000 -> 12398765432112345678945678.00045678 Inexact Rounded
-dqadd375053 fma 1 12398765432112345678945678 0.0000567750000000 -> 12398765432112345678945678.00005678 Inexact Rounded
-dqadd375054 fma 1 12398765432112345678945678 0.0000067750000000 -> 12398765432112345678945678.00000678 Inexact Rounded
-dqadd375055 fma 1 12398765432112345678945678 0.0000007750000000 -> 12398765432112345678945678.00000078 Inexact Rounded
-dqadd375056 fma 1 12398765432112345678945678 0.0000000750000000 -> 12398765432112345678945678.00000008 Inexact Rounded
-dqadd375057 fma 1 12398765432112345678945678 0.0000000050000000 -> 12398765432112345678945678.00000000 Inexact Rounded
-dqadd375060 fma 1 12398765432112345678945678 0.0234567750000001 -> 12398765432112345678945678.02345678 Inexact Rounded
-dqadd375061 fma 1 12398765432112345678945678 0.0034567750000001 -> 12398765432112345678945678.00345678 Inexact Rounded
-dqadd375062 fma 1 12398765432112345678945678 0.0004567750000001 -> 12398765432112345678945678.00045678 Inexact Rounded
-dqadd375063 fma 1 12398765432112345678945678 0.0000567750000001 -> 12398765432112345678945678.00005678 Inexact Rounded
-dqadd375064 fma 1 12398765432112345678945678 0.0000067750000001 -> 12398765432112345678945678.00000678 Inexact Rounded
-dqadd375065 fma 1 12398765432112345678945678 0.0000007750000001 -> 12398765432112345678945678.00000078 Inexact Rounded
-dqadd375066 fma 1 12398765432112345678945678 0.0000000750000001 -> 12398765432112345678945678.00000008 Inexact Rounded
-dqadd375067 fma 1 12398765432112345678945678 0.0000000050000001 -> 12398765432112345678945678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-dqadd375070 fma 1 12398765432112345678945678 1E-8 -> 12398765432112345678945678.00000001
-dqadd375071 fma 1 12398765432112345678945678 1E-9 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375072 fma 1 12398765432112345678945678 1E-10 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375073 fma 1 12398765432112345678945678 1E-11 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375074 fma 1 12398765432112345678945678 1E-12 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375075 fma 1 12398765432112345678945678 1E-13 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375076 fma 1 12398765432112345678945678 1E-14 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375077 fma 1 12398765432112345678945678 1E-15 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375078 fma 1 12398765432112345678945678 1E-16 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375079 fma 1 12398765432112345678945678 1E-17 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375080 fma 1 12398765432112345678945678 1E-18 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375081 fma 1 12398765432112345678945678 1E-19 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375082 fma 1 12398765432112345678945678 1E-20 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375083 fma 1 12398765432112345678945678 1E-25 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375084 fma 1 12398765432112345678945678 1E-30 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375085 fma 1 12398765432112345678945678 1E-31 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375086 fma 1 12398765432112345678945678 1E-32 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375087 fma 1 12398765432112345678945678 1E-33 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375088 fma 1 12398765432112345678945678 1E-34 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375089 fma 1 12398765432112345678945678 1E-35 -> 12398765432112345678945678.00000001 Inexact Rounded
-
--- Destructive subtract (from remainder tests)
-
--- +++ some of these will be off-by-one remainder vs remainderNear
-
-dqfma4000 fma -1234567890123456789012345678901233 1.000000000000000000000000000000001 1234567890123456789012345678901234 -> -0.234567890123456789012345678901233
-dqfma4001 fma -1234567890123456789012345678901222 1.00000000000000000000000000000001 1234567890123456789012345678901234 -> -0.34567890123456789012345678901222
-dqfma4002 fma -1234567890123456789012345678901111 1.0000000000000000000000000000001 1234567890123456789012345678901234 -> -0.4567890123456789012345678901111
-dqfma4003 fma -308641972530864197253086419725314 4.000000000000000000000000000000001 1234567890123456789012345678901255 -> -1.308641972530864197253086419725314
-dqfma4004 fma -308641972530864197253086419725308 4.000000000000000000000000000000001 1234567890123456789012345678901234 -> 1.691358027469135802746913580274692
-dqfma4005 fma -246913578024691357802469135780252 4.9999999999999999999999999999999 1234567890123456789012345678901234 -> -1.3086421975308642197530864219748
-dqfma4006 fma -246913578024691357802469135780247 4.99999999999999999999999999999999 1234567890123456789012345678901234 -> 1.46913578024691357802469135780247
-dqfma4007 fma -246913578024691357802469135780247 4.999999999999999999999999999999999 1234567890123456789012345678901234 -> -0.753086421975308642197530864219753
-dqfma4008 fma -246913578024691357802469135780247 5.000000000000000000000000000000001 1234567890123456789012345678901234 -> -1.246913578024691357802469135780247
-dqfma4009 fma -246913578024691357802469135780246 5.00000000000000000000000000000001 1234567890123456789012345678901234 -> 1.53086421975308642197530864219754
-dqfma4010 fma -246913578024691357802469135780242 5.0000000000000000000000000000001 1234567890123456789012345678901234 -> -0.6913578024691357802469135780242
-dqfma4011 fma -1234567890123456789012345678901232 1.000000000000000000000000000000001 1234567890123456789012345678901234 -> 0.765432109876543210987654321098768
-dqfma4012 fma -1234567890123456789012345678901221 1.00000000000000000000000000000001 1234567890123456789012345678901234 -> 0.65432109876543210987654321098779
-dqfma4013 fma -1234567890123456789012345678901110 1.0000000000000000000000000000001 1234567890123456789012345678901234 -> 0.5432109876543210987654321098890
-dqfma4014 fma -308641972530864197253086419725313 4.000000000000000000000000000000001 1234567890123456789012345678901255 -> 2.691358027469135802746913580274687
-dqfma4015 fma -308641972530864197253086419725308 4.000000000000000000000000000000001 1234567890123456789012345678901234 -> 1.691358027469135802746913580274692
-dqfma4016 fma -246913578024691357802469135780251 4.9999999999999999999999999999999 1234567890123456789012345678901234 -> 3.6913578024691357802469135780251
-dqfma4017 fma -246913578024691357802469135780247 4.99999999999999999999999999999999 1234567890123456789012345678901234 -> 1.46913578024691357802469135780247
-dqfma4018 fma -246913578024691357802469135780246 4.999999999999999999999999999999999 1234567890123456789012345678901234 -> 4.246913578024691357802469135780246
-dqfma4019 fma -246913578024691357802469135780241 5.0000000000000000000000000000001 1234567890123456789012345678901234 -> 4.3086421975308642197530864219759
-
--- Null tests
-dqadd39990 fma 1 10 # -> NaN Invalid_operation
-dqadd39991 fma 1 # 10 -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- dqFMA.decTest -- decQuad Fused Multiply Add --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- These tests comprese three parts:
+-- 1. Sanity checks and other three-operand tests (especially those
+-- where the fused operation makes a difference)
+-- 2. Multiply tests (third operand is neutral zero [0E+emax])
+-- 3. Addition tests (first operand is 1)
+-- The multiply and addition tests are extensive because FMA may have
+-- its own dedicated multiplication or addition routine(s), and they
+-- also inherently check the left-to-right properties.
+
+-- Sanity checks
+dqfma0001 fma 1 1 1 -> 2
+dqfma0002 fma 1 1 2 -> 3
+dqfma0003 fma 2 2 3 -> 7
+dqfma0004 fma 9 9 9 -> 90
+dqfma0005 fma -1 1 1 -> 0
+dqfma0006 fma -1 1 2 -> 1
+dqfma0007 fma -2 2 3 -> -1
+dqfma0008 fma -9 9 9 -> -72
+dqfma0011 fma 1 -1 1 -> 0
+dqfma0012 fma 1 -1 2 -> 1
+dqfma0013 fma 2 -2 3 -> -1
+dqfma0014 fma 9 -9 9 -> -72
+dqfma0015 fma 1 1 -1 -> 0
+dqfma0016 fma 1 1 -2 -> -1
+dqfma0017 fma 2 2 -3 -> 1
+dqfma0018 fma 9 9 -9 -> 72
+
+-- non-integer exacts
+dqfma0100 fma 25.2 63.6 -438 -> 1164.72
+dqfma0101 fma 0.301 0.380 334 -> 334.114380
+dqfma0102 fma 49.2 -4.8 23.3 -> -212.86
+dqfma0103 fma 4.22 0.079 -94.6 -> -94.26662
+dqfma0104 fma 903 0.797 0.887 -> 720.578
+dqfma0105 fma 6.13 -161 65.9 -> -921.03
+dqfma0106 fma 28.2 727 5.45 -> 20506.85
+dqfma0107 fma 4 605 688 -> 3108
+dqfma0108 fma 93.3 0.19 0.226 -> 17.953
+dqfma0109 fma 0.169 -341 5.61 -> -52.019
+dqfma0110 fma -72.2 30 -51.2 -> -2217.2
+dqfma0111 fma -0.409 13 20.4 -> 15.083
+dqfma0112 fma 317 77.0 19.0 -> 24428.0
+dqfma0113 fma 47 6.58 1.62 -> 310.88
+dqfma0114 fma 1.36 0.984 0.493 -> 1.83124
+dqfma0115 fma 72.7 274 1.56 -> 19921.36
+dqfma0116 fma 335 847 83 -> 283828
+dqfma0117 fma 666 0.247 25.4 -> 189.902
+dqfma0118 fma -3.87 3.06 78.0 -> 66.1578
+dqfma0119 fma 0.742 192 35.6 -> 178.064
+dqfma0120 fma -91.6 5.29 0.153 -> -484.411
+
+-- cases where result is different from separate multiply + add; each
+-- is preceded by the result of unfused multiply and add
+-- [this is about 20% of all similar cases in general]
+-- -> 4.500119002100000209469729375698778E+38
+dqfma0202 fma 68537985861355864457.5694 6565875762972086605.85969 35892634447236753.172812 -> 4.500119002100000209469729375698779E+38 Inexact Rounded
+-- -> 5.996248469584594346858881620185514E+41
+dqfma0208 fma 89261822344727628571.9 6717595845654131383336.89 5061036497288796076266.11 -> 5.996248469584594346858881620185513E+41 Inexact Rounded
+-- -> 1.899242968678256924021594770874070E+34
+dqfma0210 fma 320506237232448685.495971 59257597764017967.984448 3205615239077711589912.85 -> 1.899242968678256924021594770874071E+34 Inexact Rounded
+-- -> 7.078596978842809537929699954860309E+37
+dqfma0215 fma 220247843259112263.17995 321392340287987979002.80 47533279819997167655440 -> 7.078596978842809537929699954860308E+37 Inexact Rounded
+-- -> 1.224955667581427559754106862350743E+37
+dqfma0226 fma 23880729790368880412.1449 512947333827064719.55407 217117438419590824502.963 -> 1.224955667581427559754106862350744E+37 Inexact Rounded
+-- -> -2.530094043253148806272276368579144E+42
+dqfma0229 fma 2539892357016099706.4126 -996142232667504817717435 53682082598315949425.937 -> -2.530094043253148806272276368579143E+42 Inexact Rounded
+-- -> 1.713387085759711954319391412788454E+37
+dqfma0233 fma 4546339491341624464.0804 3768717864169205581 83578980278690395184.620 -> 1.713387085759711954319391412788453E+37 Inexact Rounded
+-- -> 4.062275663405823716411579117771547E+35
+dqfma0235 fma 409242119433816131.42253 992633815166741501.477249 70179636544416756129546 -> 4.062275663405823716411579117771548E+35 Inexact Rounded
+-- -> 6.002604327732568490562249875306823E+47
+dqfma0258 fma 817941336593541742159684 733867339769310729266598 78563844650942419311830.8 -> 6.002604327732568490562249875306822E+47 Inexact Rounded
+-- -> -2.027022514381452197510103395283874E+39
+dqfma0264 fma 387617310169161270.737532 -5229442703414956061216.62 57665666816652967150473.5 -> -2.027022514381452197510103395283873E+39 Inexact Rounded
+-- -> -7.856525039803554001144089842730361E+37
+dqfma0267 fma -847655845720565274701.210 92685316564117739.83984 22780950041376424429.5686 -> -7.856525039803554001144089842730360E+37 Inexact Rounded
+-- -> 1.695515562011520746125607502237559E+38
+dqfma0268 fma 21590290365127685.3675 7853139227576541379426.8 -3275859437236180.761544 -> 1.695515562011520746125607502237558E+38 Inexact Rounded
+-- -> -8.448422935783289219748115038014710E+38
+dqfma0269 fma -974320636272862697.971586 867109103641860247440.756 -9775170775902454762.98 -> -8.448422935783289219748115038014709E+38 Inexact Rounded
+
+-- Cases where multiply would overflow or underflow if separate
+dqfma0300 fma 9e+6144 10 0 -> Infinity Overflow Inexact Rounded
+dqfma0301 fma 1e+6144 10 0 -> Infinity Overflow Inexact Rounded
+dqfma0302 fma 1e+6144 10 -1e+6144 -> 9.000000000000000000000000000000000E+6144 Clamped
+dqfma0303 fma 1e+6144 10 -9e+6144 -> 1.000000000000000000000000000000000E+6144 Clamped
+-- subnormal etc.
+dqfma0305 fma 1e-6176 0.1 0 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma0306 fma 1e-6176 0.1 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqfma0307 fma 1e-6176 0.1 1e-6176 -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+-- Infinite combinations
+dqfma0800 fma Inf Inf Inf -> Infinity
+dqfma0801 fma Inf Inf -Inf -> NaN Invalid_operation
+dqfma0802 fma Inf -Inf Inf -> NaN Invalid_operation
+dqfma0803 fma Inf -Inf -Inf -> -Infinity
+dqfma0804 fma -Inf Inf Inf -> NaN Invalid_operation
+dqfma0805 fma -Inf Inf -Inf -> -Infinity
+dqfma0806 fma -Inf -Inf Inf -> Infinity
+dqfma0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
+
+-- Triple NaN propagation
+dqfma0900 fma NaN2 NaN3 NaN5 -> NaN2
+dqfma0901 fma 0 NaN3 NaN5 -> NaN3
+dqfma0902 fma 0 0 NaN5 -> NaN5
+-- first sNaN wins (consider qNaN from earlier sNaN being
+-- overridden by an sNaN in third operand)
+dqfma0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+dqfma0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
+dqfma0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
+dqfma0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+dqfma0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
+dqfma0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
+
+-- MULTIPLICATION TESTS ------------------------------------------------
+rounding: half_even
+
+-- sanity checks
+dqfma2000 fma 2 2 0e+6144 -> 4
+dqfma2001 fma 2 3 0e+6144 -> 6
+dqfma2002 fma 5 1 0e+6144 -> 5
+dqfma2003 fma 5 2 0e+6144 -> 10
+dqfma2004 fma 1.20 2 0e+6144 -> 2.40
+dqfma2005 fma 1.20 0 0e+6144 -> 0.00
+dqfma2006 fma 1.20 -2 0e+6144 -> -2.40
+dqfma2007 fma -1.20 2 0e+6144 -> -2.40
+dqfma2008 fma -1.20 0 0e+6144 -> 0.00
+dqfma2009 fma -1.20 -2 0e+6144 -> 2.40
+dqfma2010 fma 5.09 7.1 0e+6144 -> 36.139
+dqfma2011 fma 2.5 4 0e+6144 -> 10.0
+dqfma2012 fma 2.50 4 0e+6144 -> 10.00
+dqfma2013 fma 1.23456789 1.0000000000000000000000000000 0e+6144 -> 1.234567890000000000000000000000000 Rounded
+dqfma2015 fma 2.50 4 0e+6144 -> 10.00
+dqfma2016 fma 9.99999999999999999 9.99999999999999999 0e+6144 -> 99.99999999999999980000000000000000 Inexact Rounded
+dqfma2017 fma 9.99999999999999999 -9.99999999999999999 0e+6144 -> -99.99999999999999980000000000000000 Inexact Rounded
+dqfma2018 fma -9.99999999999999999 9.99999999999999999 0e+6144 -> -99.99999999999999980000000000000000 Inexact Rounded
+dqfma2019 fma -9.99999999999999999 -9.99999999999999999 0e+6144 -> 99.99999999999999980000000000000000 Inexact Rounded
+
+-- zeros, etc.
+dqfma2021 fma 0 0 0e+6144 -> 0
+dqfma2022 fma 0 -0 0e+6144 -> 0
+dqfma2023 fma -0 0 0e+6144 -> 0
+dqfma2024 fma -0 -0 0e+6144 -> 0
+dqfma2025 fma -0.0 -0.0 0e+6144 -> 0.00
+dqfma2026 fma -0.0 -0.0 0e+6144 -> 0.00
+dqfma2027 fma -0.0 -0.0 0e+6144 -> 0.00
+dqfma2028 fma -0.0 -0.0 0e+6144 -> 0.00
+dqfma2030 fma 5.00 1E-3 0e+6144 -> 0.00500
+dqfma2031 fma 00.00 0.000 0e+6144 -> 0.00000
+dqfma2032 fma 00.00 0E-3 0e+6144 -> 0.00000 -- rhs is 0
+dqfma2033 fma 0E-3 00.00 0e+6144 -> 0.00000 -- lhs is 0
+dqfma2034 fma -5.00 1E-3 0e+6144 -> -0.00500
+dqfma2035 fma -00.00 0.000 0e+6144 -> 0.00000
+dqfma2036 fma -00.00 0E-3 0e+6144 -> 0.00000 -- rhs is 0
+dqfma2037 fma -0E-3 00.00 0e+6144 -> 0.00000 -- lhs is 0
+dqfma2038 fma 5.00 -1E-3 0e+6144 -> -0.00500
+dqfma2039 fma 00.00 -0.000 0e+6144 -> 0.00000
+dqfma2040 fma 00.00 -0E-3 0e+6144 -> 0.00000 -- rhs is 0
+dqfma2041 fma 0E-3 -00.00 0e+6144 -> 0.00000 -- lhs is 0
+dqfma2042 fma -5.00 -1E-3 0e+6144 -> 0.00500
+dqfma2043 fma -00.00 -0.000 0e+6144 -> 0.00000
+dqfma2044 fma -00.00 -0E-3 0e+6144 -> 0.00000 -- rhs is 0
+dqfma2045 fma -0E-3 -00.00 0e+6144 -> 0.00000 -- lhs is 0
+
+-- examples from decarith
+dqfma2050 fma 1.20 3 0e+6144 -> 3.60
+dqfma2051 fma 7 3 0e+6144 -> 21
+dqfma2052 fma 0.9 0.8 0e+6144 -> 0.72
+dqfma2053 fma 0.9 -0 0e+6144 -> 0.0
+dqfma2054 fma 654321 654321 0e+6144 -> 428135971041
+
+dqfma2060 fma 123.45 1e7 0e+6144 -> 1.2345E+9
+dqfma2061 fma 123.45 1e8 0e+6144 -> 1.2345E+10
+dqfma2062 fma 123.45 1e+9 0e+6144 -> 1.2345E+11
+dqfma2063 fma 123.45 1e10 0e+6144 -> 1.2345E+12
+dqfma2064 fma 123.45 1e11 0e+6144 -> 1.2345E+13
+dqfma2065 fma 123.45 1e12 0e+6144 -> 1.2345E+14
+dqfma2066 fma 123.45 1e13 0e+6144 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+-- 1234567890123456
+dqfma2080 fma 0.1 1230123456456789 0e+6144 -> 123012345645678.9
+dqfma2084 fma 0.1 1230123456456789 0e+6144 -> 123012345645678.9
+dqfma2090 fma 1230123456456789 0.1 0e+6144 -> 123012345645678.9
+dqfma2094 fma 1230123456456789 0.1 0e+6144 -> 123012345645678.9
+
+-- test some more edge cases and carries
+dqfma2101 fma 9 9 0e+6144 -> 81
+dqfma2102 fma 9 90 0e+6144 -> 810
+dqfma2103 fma 9 900 0e+6144 -> 8100
+dqfma2104 fma 9 9000 0e+6144 -> 81000
+dqfma2105 fma 9 90000 0e+6144 -> 810000
+dqfma2106 fma 9 900000 0e+6144 -> 8100000
+dqfma2107 fma 9 9000000 0e+6144 -> 81000000
+dqfma2108 fma 9 90000000 0e+6144 -> 810000000
+dqfma2109 fma 9 900000000 0e+6144 -> 8100000000
+dqfma2110 fma 9 9000000000 0e+6144 -> 81000000000
+dqfma2111 fma 9 90000000000 0e+6144 -> 810000000000
+dqfma2112 fma 9 900000000000 0e+6144 -> 8100000000000
+dqfma2113 fma 9 9000000000000 0e+6144 -> 81000000000000
+dqfma2114 fma 9 90000000000000 0e+6144 -> 810000000000000
+dqfma2115 fma 9 900000000000000 0e+6144 -> 8100000000000000
+--dqfma2116 fma 9 9000000000000000 0e+6144 -> 81000000000000000
+--dqfma2117 fma 9 90000000000000000 0e+6144 -> 810000000000000000
+--dqfma2118 fma 9 900000000000000000 0e+6144 -> 8100000000000000000
+--dqfma2119 fma 9 9000000000000000000 0e+6144 -> 81000000000000000000
+--dqfma2120 fma 9 90000000000000000000 0e+6144 -> 810000000000000000000
+--dqfma2121 fma 9 900000000000000000000 0e+6144 -> 8100000000000000000000
+--dqfma2122 fma 9 9000000000000000000000 0e+6144 -> 81000000000000000000000
+--dqfma2123 fma 9 90000000000000000000000 0e+6144 -> 810000000000000000000000
+-- test some more edge cases without carries
+dqfma2131 fma 3 3 0e+6144 -> 9
+dqfma2132 fma 3 30 0e+6144 -> 90
+dqfma2133 fma 3 300 0e+6144 -> 900
+dqfma2134 fma 3 3000 0e+6144 -> 9000
+dqfma2135 fma 3 30000 0e+6144 -> 90000
+dqfma2136 fma 3 300000 0e+6144 -> 900000
+dqfma2137 fma 3 3000000 0e+6144 -> 9000000
+dqfma2138 fma 3 30000000 0e+6144 -> 90000000
+dqfma2139 fma 3 300000000 0e+6144 -> 900000000
+dqfma2140 fma 3 3000000000 0e+6144 -> 9000000000
+dqfma2141 fma 3 30000000000 0e+6144 -> 90000000000
+dqfma2142 fma 3 300000000000 0e+6144 -> 900000000000
+dqfma2143 fma 3 3000000000000 0e+6144 -> 9000000000000
+dqfma2144 fma 3 30000000000000 0e+6144 -> 90000000000000
+dqfma2145 fma 3 300000000000000 0e+6144 -> 900000000000000
+dqfma2146 fma 3 3000000000000000 0e+6144 -> 9000000000000000
+dqfma2147 fma 3 30000000000000000 0e+6144 -> 90000000000000000
+dqfma2148 fma 3 300000000000000000 0e+6144 -> 900000000000000000
+dqfma2149 fma 3 3000000000000000000 0e+6144 -> 9000000000000000000
+dqfma2150 fma 3 30000000000000000000 0e+6144 -> 90000000000000000000
+dqfma2151 fma 3 300000000000000000000 0e+6144 -> 900000000000000000000
+dqfma2152 fma 3 3000000000000000000000 0e+6144 -> 9000000000000000000000
+dqfma2153 fma 3 30000000000000000000000 0e+6144 -> 90000000000000000000000
+
+dqfma2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0e+6144 -> 145433.2908011933696719165119928296 Inexact Rounded
+
+-- test some edge cases with exact rounding
+dqfma2301 fma 900000000000000000 9 0e+6144 -> 8100000000000000000
+dqfma2302 fma 900000000000000000 90 0e+6144 -> 81000000000000000000
+dqfma2303 fma 900000000000000000 900 0e+6144 -> 810000000000000000000
+dqfma2304 fma 900000000000000000 9000 0e+6144 -> 8100000000000000000000
+dqfma2305 fma 900000000000000000 90000 0e+6144 -> 81000000000000000000000
+dqfma2306 fma 900000000000000000 900000 0e+6144 -> 810000000000000000000000
+dqfma2307 fma 900000000000000000 9000000 0e+6144 -> 8100000000000000000000000
+dqfma2308 fma 900000000000000000 90000000 0e+6144 -> 81000000000000000000000000
+dqfma2309 fma 900000000000000000 900000000 0e+6144 -> 810000000000000000000000000
+dqfma2310 fma 900000000000000000 9000000000 0e+6144 -> 8100000000000000000000000000
+dqfma2311 fma 900000000000000000 90000000000 0e+6144 -> 81000000000000000000000000000
+dqfma2312 fma 900000000000000000 900000000000 0e+6144 -> 810000000000000000000000000000
+dqfma2313 fma 900000000000000000 9000000000000 0e+6144 -> 8100000000000000000000000000000
+dqfma2314 fma 900000000000000000 90000000000000 0e+6144 -> 81000000000000000000000000000000
+dqfma2315 fma 900000000000000000 900000000000000 0e+6144 -> 810000000000000000000000000000000
+dqfma2316 fma 900000000000000000 9000000000000000 0e+6144 -> 8100000000000000000000000000000000
+dqfma2317 fma 9000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+34 Rounded
+dqfma2318 fma 90000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+35 Rounded
+dqfma2319 fma 900000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+36 Rounded
+dqfma2320 fma 9000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+37 Rounded
+dqfma2321 fma 90000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+38 Rounded
+dqfma2322 fma 900000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+39 Rounded
+dqfma2323 fma 9000000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+40 Rounded
+
+-- tryzeros cases
+dqfma2504 fma 0E-4260 1000E-4260 0e+6144 -> 0E-6176 Clamped
+dqfma2505 fma 100E+4260 0E+4260 0e+6144 -> 0E+6111 Clamped
+
+-- mixed with zeros
+dqfma2541 fma 0 -1 0e+6144 -> 0
+dqfma2542 fma -0 -1 0e+6144 -> 0
+dqfma2543 fma 0 1 0e+6144 -> 0
+dqfma2544 fma -0 1 0e+6144 -> 0
+dqfma2545 fma -1 0 0e+6144 -> 0
+dqfma2546 fma -1 -0 0e+6144 -> 0
+dqfma2547 fma 1 0 0e+6144 -> 0
+dqfma2548 fma 1 -0 0e+6144 -> 0
+
+dqfma2551 fma 0.0 -1 0e+6144 -> 0.0
+dqfma2552 fma -0.0 -1 0e+6144 -> 0.0
+dqfma2553 fma 0.0 1 0e+6144 -> 0.0
+dqfma2554 fma -0.0 1 0e+6144 -> 0.0
+dqfma2555 fma -1.0 0 0e+6144 -> 0.0
+dqfma2556 fma -1.0 -0 0e+6144 -> 0.0
+dqfma2557 fma 1.0 0 0e+6144 -> 0.0
+dqfma2558 fma 1.0 -0 0e+6144 -> 0.0
+
+dqfma2561 fma 0 -1.0 0e+6144 -> 0.0
+dqfma2562 fma -0 -1.0 0e+6144 -> 0.0
+dqfma2563 fma 0 1.0 0e+6144 -> 0.0
+dqfma2564 fma -0 1.0 0e+6144 -> 0.0
+dqfma2565 fma -1 0.0 0e+6144 -> 0.0
+dqfma2566 fma -1 -0.0 0e+6144 -> 0.0
+dqfma2567 fma 1 0.0 0e+6144 -> 0.0
+dqfma2568 fma 1 -0.0 0e+6144 -> 0.0
+
+dqfma2571 fma 0.0 -1.0 0e+6144 -> 0.00
+dqfma2572 fma -0.0 -1.0 0e+6144 -> 0.00
+dqfma2573 fma 0.0 1.0 0e+6144 -> 0.00
+dqfma2574 fma -0.0 1.0 0e+6144 -> 0.00
+dqfma2575 fma -1.0 0.0 0e+6144 -> 0.00
+dqfma2576 fma -1.0 -0.0 0e+6144 -> 0.00
+dqfma2577 fma 1.0 0.0 0e+6144 -> 0.00
+dqfma2578 fma 1.0 -0.0 0e+6144 -> 0.00
+dqfma2579 fma 1.0 0.0 0e+6144 -> 0.00
+dqfma2530 fma -1.0 -0.0 0e+6144 -> 0.00
+dqfma2531 fma -1.0 0.0 0e+6144 -> 0.00
+dqfma2532 fma 1.0 -0.0 -0e+6144 -> -0.00
+dqfma2533 fma 1.0 0.0 -0e+6144 -> 0.00
+dqfma2534 fma -1.0 -0.0 -0e+6144 -> 0.00
+dqfma2535 fma -1.0 0.0 -0e+6144 -> -0.00
+
+
+-- Specials
+dqfma2580 fma Inf -Inf 0e+6144 -> -Infinity
+dqfma2581 fma Inf -1000 0e+6144 -> -Infinity
+dqfma2582 fma Inf -1 0e+6144 -> -Infinity
+dqfma2583 fma Inf -0 0e+6144 -> NaN Invalid_operation
+dqfma2584 fma Inf 0 0e+6144 -> NaN Invalid_operation
+dqfma2585 fma Inf 1 0e+6144 -> Infinity
+dqfma2586 fma Inf 1000 0e+6144 -> Infinity
+dqfma2587 fma Inf Inf 0e+6144 -> Infinity
+dqfma2588 fma -1000 Inf 0e+6144 -> -Infinity
+dqfma2589 fma -Inf Inf 0e+6144 -> -Infinity
+dqfma2590 fma -1 Inf 0e+6144 -> -Infinity
+dqfma2591 fma -0 Inf 0e+6144 -> NaN Invalid_operation
+dqfma2592 fma 0 Inf 0e+6144 -> NaN Invalid_operation
+dqfma2593 fma 1 Inf 0e+6144 -> Infinity
+dqfma2594 fma 1000 Inf 0e+6144 -> Infinity
+dqfma2595 fma Inf Inf 0e+6144 -> Infinity
+
+dqfma2600 fma -Inf -Inf 0e+6144 -> Infinity
+dqfma2601 fma -Inf -1000 0e+6144 -> Infinity
+dqfma2602 fma -Inf -1 0e+6144 -> Infinity
+dqfma2603 fma -Inf -0 0e+6144 -> NaN Invalid_operation
+dqfma2604 fma -Inf 0 0e+6144 -> NaN Invalid_operation
+dqfma2605 fma -Inf 1 0e+6144 -> -Infinity
+dqfma2606 fma -Inf 1000 0e+6144 -> -Infinity
+dqfma2607 fma -Inf Inf 0e+6144 -> -Infinity
+dqfma2608 fma -1000 Inf 0e+6144 -> -Infinity
+dqfma2609 fma -Inf -Inf 0e+6144 -> Infinity
+dqfma2610 fma -1 -Inf 0e+6144 -> Infinity
+dqfma2611 fma -0 -Inf 0e+6144 -> NaN Invalid_operation
+dqfma2612 fma 0 -Inf 0e+6144 -> NaN Invalid_operation
+dqfma2613 fma 1 -Inf 0e+6144 -> -Infinity
+dqfma2614 fma 1000 -Inf 0e+6144 -> -Infinity
+dqfma2615 fma Inf -Inf 0e+6144 -> -Infinity
+
+dqfma2621 fma NaN -Inf 0e+6144 -> NaN
+dqfma2622 fma NaN -1000 0e+6144 -> NaN
+dqfma2623 fma NaN -1 0e+6144 -> NaN
+dqfma2624 fma NaN -0 0e+6144 -> NaN
+dqfma2625 fma NaN 0 0e+6144 -> NaN
+dqfma2626 fma NaN 1 0e+6144 -> NaN
+dqfma2627 fma NaN 1000 0e+6144 -> NaN
+dqfma2628 fma NaN Inf 0e+6144 -> NaN
+dqfma2629 fma NaN NaN 0e+6144 -> NaN
+dqfma2630 fma -Inf NaN 0e+6144 -> NaN
+dqfma2631 fma -1000 NaN 0e+6144 -> NaN
+dqfma2632 fma -1 NaN 0e+6144 -> NaN
+dqfma2633 fma -0 NaN 0e+6144 -> NaN
+dqfma2634 fma 0 NaN 0e+6144 -> NaN
+dqfma2635 fma 1 NaN 0e+6144 -> NaN
+dqfma2636 fma 1000 NaN 0e+6144 -> NaN
+dqfma2637 fma Inf NaN 0e+6144 -> NaN
+
+dqfma2641 fma sNaN -Inf 0e+6144 -> NaN Invalid_operation
+dqfma2642 fma sNaN -1000 0e+6144 -> NaN Invalid_operation
+dqfma2643 fma sNaN -1 0e+6144 -> NaN Invalid_operation
+dqfma2644 fma sNaN -0 0e+6144 -> NaN Invalid_operation
+dqfma2645 fma sNaN 0 0e+6144 -> NaN Invalid_operation
+dqfma2646 fma sNaN 1 0e+6144 -> NaN Invalid_operation
+dqfma2647 fma sNaN 1000 0e+6144 -> NaN Invalid_operation
+dqfma2648 fma sNaN NaN 0e+6144 -> NaN Invalid_operation
+dqfma2649 fma sNaN sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2650 fma NaN sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2651 fma -Inf sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2652 fma -1000 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2653 fma -1 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2654 fma -0 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2655 fma 0 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2656 fma 1 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2657 fma 1000 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2658 fma Inf sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2659 fma NaN sNaN 0e+6144 -> NaN Invalid_operation
+
+-- propagating NaNs
+dqfma2661 fma NaN9 -Inf 0e+6144 -> NaN9
+dqfma2662 fma NaN8 999 0e+6144 -> NaN8
+dqfma2663 fma NaN71 Inf 0e+6144 -> NaN71
+dqfma2664 fma NaN6 NaN5 0e+6144 -> NaN6
+dqfma2665 fma -Inf NaN4 0e+6144 -> NaN4
+dqfma2666 fma -999 NaN33 0e+6144 -> NaN33
+dqfma2667 fma Inf NaN2 0e+6144 -> NaN2
+
+dqfma2671 fma sNaN99 -Inf 0e+6144 -> NaN99 Invalid_operation
+dqfma2672 fma sNaN98 -11 0e+6144 -> NaN98 Invalid_operation
+dqfma2673 fma sNaN97 NaN 0e+6144 -> NaN97 Invalid_operation
+dqfma2674 fma sNaN16 sNaN94 0e+6144 -> NaN16 Invalid_operation
+dqfma2675 fma NaN95 sNaN93 0e+6144 -> NaN93 Invalid_operation
+dqfma2676 fma -Inf sNaN92 0e+6144 -> NaN92 Invalid_operation
+dqfma2677 fma 088 sNaN91 0e+6144 -> NaN91 Invalid_operation
+dqfma2678 fma Inf sNaN90 0e+6144 -> NaN90 Invalid_operation
+dqfma2679 fma NaN sNaN89 0e+6144 -> NaN89 Invalid_operation
+
+dqfma2681 fma -NaN9 -Inf 0e+6144 -> -NaN9
+dqfma2682 fma -NaN8 999 0e+6144 -> -NaN8
+dqfma2683 fma -NaN71 Inf 0e+6144 -> -NaN71
+dqfma2684 fma -NaN6 -NaN5 0e+6144 -> -NaN6
+dqfma2685 fma -Inf -NaN4 0e+6144 -> -NaN4
+dqfma2686 fma -999 -NaN33 0e+6144 -> -NaN33
+dqfma2687 fma Inf -NaN2 0e+6144 -> -NaN2
+
+dqfma2691 fma -sNaN99 -Inf 0e+6144 -> -NaN99 Invalid_operation
+dqfma2692 fma -sNaN98 -11 0e+6144 -> -NaN98 Invalid_operation
+dqfma2693 fma -sNaN97 NaN 0e+6144 -> -NaN97 Invalid_operation
+dqfma2694 fma -sNaN16 -sNaN94 0e+6144 -> -NaN16 Invalid_operation
+dqfma2695 fma -NaN95 -sNaN93 0e+6144 -> -NaN93 Invalid_operation
+dqfma2696 fma -Inf -sNaN92 0e+6144 -> -NaN92 Invalid_operation
+dqfma2697 fma 088 -sNaN91 0e+6144 -> -NaN91 Invalid_operation
+dqfma2698 fma Inf -sNaN90 0e+6144 -> -NaN90 Invalid_operation
+dqfma2699 fma -NaN -sNaN89 0e+6144 -> -NaN89 Invalid_operation
+
+dqfma2701 fma -NaN -Inf 0e+6144 -> -NaN
+dqfma2702 fma -NaN 999 0e+6144 -> -NaN
+dqfma2703 fma -NaN Inf 0e+6144 -> -NaN
+dqfma2704 fma -NaN -NaN 0e+6144 -> -NaN
+dqfma2705 fma -Inf -NaN0 0e+6144 -> -NaN
+dqfma2706 fma -999 -NaN 0e+6144 -> -NaN
+dqfma2707 fma Inf -NaN 0e+6144 -> -NaN
+
+dqfma2711 fma -sNaN -Inf 0e+6144 -> -NaN Invalid_operation
+dqfma2712 fma -sNaN -11 0e+6144 -> -NaN Invalid_operation
+dqfma2713 fma -sNaN00 NaN 0e+6144 -> -NaN Invalid_operation
+dqfma2714 fma -sNaN -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2715 fma -NaN -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2716 fma -Inf -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2717 fma 088 -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2718 fma Inf -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2719 fma -NaN -sNaN 0e+6144 -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+dqfma2751 fma 1e+4277 1e+3311 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2752 fma 1e+4277 -1e+3311 0e+6144 -> -Infinity Overflow Inexact Rounded
+dqfma2753 fma -1e+4277 1e+3311 0e+6144 -> -Infinity Overflow Inexact Rounded
+dqfma2754 fma -1e+4277 -1e+3311 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2755 fma 1e-4277 1e-3311 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2756 fma 1e-4277 -1e-3311 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2757 fma -1e-4277 1e-3311 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2758 fma -1e-4277 -1e-3311 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dqfma2760 fma 1e-6069 1e-101 0e+6144 -> 1E-6170 Subnormal
+dqfma2761 fma 1e-6069 1e-102 0e+6144 -> 1E-6171 Subnormal
+dqfma2762 fma 1e-6069 1e-103 0e+6144 -> 1E-6172 Subnormal
+dqfma2763 fma 1e-6069 1e-104 0e+6144 -> 1E-6173 Subnormal
+dqfma2764 fma 1e-6069 1e-105 0e+6144 -> 1E-6174 Subnormal
+dqfma2765 fma 1e-6069 1e-106 0e+6144 -> 1E-6175 Subnormal
+dqfma2766 fma 1e-6069 1e-107 0e+6144 -> 1E-6176 Subnormal
+dqfma2767 fma 1e-6069 1e-108 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2768 fma 1e-6069 1e-109 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2769 fma 1e-6069 1e-110 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+dqfma2770 fma 1e+40 1e+6101 0e+6144 -> 1.000000000000000000000000000000E+6141 Clamped
+dqfma2771 fma 1e+40 1e+6102 0e+6144 -> 1.0000000000000000000000000000000E+6142 Clamped
+dqfma2772 fma 1e+40 1e+6103 0e+6144 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqfma2773 fma 1e+40 1e+6104 0e+6144 -> 1.000000000000000000000000000000000E+6144 Clamped
+dqfma2774 fma 1e+40 1e+6105 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2775 fma 1e+40 1e+6106 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2776 fma 1e+40 1e+6107 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2777 fma 1e+40 1e+6108 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2778 fma 1e+40 1e+6109 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2779 fma 1e+40 1e+6110 0e+6144 -> Infinity Overflow Inexact Rounded
+
+dqfma2801 fma 1.0000E-6172 1 0e+6144 -> 1.0000E-6172 Subnormal
+dqfma2802 fma 1.000E-6172 1e-1 0e+6144 -> 1.000E-6173 Subnormal
+dqfma2803 fma 1.00E-6172 1e-2 0e+6144 -> 1.00E-6174 Subnormal
+dqfma2804 fma 1.0E-6172 1e-3 0e+6144 -> 1.0E-6175 Subnormal
+dqfma2805 fma 1.0E-6172 1e-4 0e+6144 -> 1E-6176 Subnormal Rounded
+dqfma2806 fma 1.3E-6172 1e-4 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2807 fma 1.5E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2808 fma 1.7E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2809 fma 2.3E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2810 fma 2.5E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2811 fma 2.7E-6172 1e-4 0e+6144 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqfma2812 fma 1.49E-6172 1e-4 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2813 fma 1.50E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2814 fma 1.51E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2815 fma 2.49E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2816 fma 2.50E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2817 fma 2.51E-6172 1e-4 0e+6144 -> 3E-6176 Underflow Subnormal Inexact Rounded
+
+dqfma2818 fma 1E-6172 1e-4 0e+6144 -> 1E-6176 Subnormal
+dqfma2819 fma 3E-6172 1e-5 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2820 fma 5E-6172 1e-5 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2821 fma 7E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2822 fma 9E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2823 fma 9.9E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+dqfma2824 fma 1E-6172 -1e-4 0e+6144 -> -1E-6176 Subnormal
+dqfma2825 fma 3E-6172 -1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2826 fma -5E-6172 1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2827 fma 7E-6172 -1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2828 fma -9E-6172 1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2829 fma 9.9E-6172 -1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2830 fma 3.0E-6172 -1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqfma2831 fma 1.0E-5977 1e-200 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2832 fma 1.0E-5977 1e-199 0e+6144 -> 1E-6176 Subnormal Rounded
+dqfma2833 fma 1.0E-5977 1e-198 0e+6144 -> 1.0E-6175 Subnormal
+dqfma2834 fma 2.0E-5977 2e-198 0e+6144 -> 4.0E-6175 Subnormal
+dqfma2835 fma 4.0E-5977 4e-198 0e+6144 -> 1.60E-6174 Subnormal
+dqfma2836 fma 10.0E-5977 10e-198 0e+6144 -> 1.000E-6173 Subnormal
+dqfma2837 fma 30.0E-5977 30e-198 0e+6144 -> 9.000E-6173 Subnormal
+dqfma2838 fma 40.0E-5982 40e-166 0e+6144 -> 1.6000E-6145 Subnormal
+dqfma2839 fma 40.0E-5982 40e-165 0e+6144 -> 1.6000E-6144 Subnormal
+dqfma2840 fma 40.0E-5982 40e-164 0e+6144 -> 1.6000E-6143
+
+-- Long operand overflow may be a different path
+dqfma2870 fma 100 9.999E+6143 0e+6144 -> Infinity Inexact Overflow Rounded
+dqfma2871 fma 100 -9.999E+6143 0e+6144 -> -Infinity Inexact Overflow Rounded
+dqfma2872 fma 9.999E+6143 100 0e+6144 -> Infinity Inexact Overflow Rounded
+dqfma2873 fma -9.999E+6143 100 0e+6144 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+dqfma2881 fma 1.2347E-6133 1.2347E-40 0e+6144 -> 1.524E-6173 Inexact Rounded Subnormal Underflow
+dqfma2882 fma 1.234E-6133 1.234E-40 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqfma2883 fma 1.23E-6133 1.23E-40 0e+6144 -> 1.513E-6173 Inexact Rounded Subnormal Underflow
+dqfma2884 fma 1.2E-6133 1.2E-40 0e+6144 -> 1.44E-6173 Subnormal
+dqfma2885 fma 1.2E-6133 1.2E-41 0e+6144 -> 1.44E-6174 Subnormal
+dqfma2886 fma 1.2E-6133 1.2E-42 0e+6144 -> 1.4E-6175 Subnormal Inexact Rounded Underflow
+dqfma2887 fma 1.2E-6133 1.3E-42 0e+6144 -> 1.6E-6175 Subnormal Inexact Rounded Underflow
+dqfma2888 fma 1.3E-6133 1.3E-42 0e+6144 -> 1.7E-6175 Subnormal Inexact Rounded Underflow
+dqfma2889 fma 1.3E-6133 1.3E-43 0e+6144 -> 2E-6176 Subnormal Inexact Rounded Underflow
+dqfma2890 fma 1.3E-6134 1.3E-43 0e+6144 -> 0E-6176 Clamped Subnormal Inexact Rounded Underflow
+
+dqfma2891 fma 1.2345E-39 1.234E-6133 0e+6144 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
+dqfma2892 fma 1.23456E-39 1.234E-6133 0e+6144 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
+dqfma2893 fma 1.2345E-40 1.234E-6133 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqfma2894 fma 1.23456E-40 1.234E-6133 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqfma2895 fma 1.2345E-41 1.234E-6133 0e+6144 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
+dqfma2896 fma 1.23456E-41 1.234E-6133 0e+6144 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+-- prove operands are exact
+dqfma2906 fma 9.999999999999999999999999999999999E-6143 1 0e+6144 -> 9.999999999999999999999999999999999E-6143
+dqfma2907 fma 1 0.09999999999999999999999999999999999 0e+6144 -> 0.09999999999999999999999999999999999
+-- the next rounds to Nmin
+dqfma2908 fma 9.999999999999999999999999999999999E-6143 0.09999999999999999999999999999999999 0e+6144 -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded
+
+-- hugest
+dqfma2909 fma 9999999999999999999999999999999999 9999999999999999999999999999999999 0e+6144 -> 9.999999999999999999999999999999998E+67 Inexact Rounded
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+dqfma21001 fma 130E-2 120E-2 0e+6144 -> 1.5600
+dqfma21002 fma 130E-2 12E-1 0e+6144 -> 1.560
+dqfma21003 fma 130E-2 1E0 0e+6144 -> 1.30
+dqfma21004 fma 1E2 1E4 0e+6144 -> 1E+6
+
+-- Null tests
+dqfma2990 fma 10 # 0e+6144 -> NaN Invalid_operation
+dqfma2991 fma # 10 0e+6144 -> NaN Invalid_operation
+
+
+-- ADDITION TESTS ------------------------------------------------------
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+dqadd3001 fma 1 1 1 -> 2
+dqadd3002 fma 1 2 3 -> 5
+dqadd3003 fma 1 '5.75' '3.3' -> 9.05
+dqadd3004 fma 1 '5' '-3' -> 2
+dqadd3005 fma 1 '-5' '-3' -> -8
+dqadd3006 fma 1 '-7' '2.5' -> -4.5
+dqadd3007 fma 1 '0.7' '0.3' -> 1.0
+dqadd3008 fma 1 '1.25' '1.25' -> 2.50
+dqadd3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
+dqadd3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
+
+-- 1234567890123456 1234567890123456
+dqadd3011 fma 1 '0.4444444444444444444444444444444446' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqadd3012 fma 1 '0.4444444444444444444444444444444445' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
+dqadd3013 fma 1 '0.4444444444444444444444444444444444' '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
+dqadd3014 fma 1 '4444444444444444444444444444444444' '0.49' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd3015 fma 1 '4444444444444444444444444444444444' '0.499' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd3016 fma 1 '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd3017 fma 1 '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd3018 fma 1 '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
+dqadd3019 fma 1 '4444444444444444444444444444444444' '0.501' -> '4444444444444444444444444444444445' Inexact Rounded
+dqadd3020 fma 1 '4444444444444444444444444444444444' '0.51' -> '4444444444444444444444444444444445' Inexact Rounded
+
+dqadd3021 fma 1 0 1 -> 1
+dqadd3022 fma 1 1 1 -> 2
+dqadd3023 fma 1 2 1 -> 3
+dqadd3024 fma 1 3 1 -> 4
+dqadd3025 fma 1 4 1 -> 5
+dqadd3026 fma 1 5 1 -> 6
+dqadd3027 fma 1 6 1 -> 7
+dqadd3028 fma 1 7 1 -> 8
+dqadd3029 fma 1 8 1 -> 9
+dqadd3030 fma 1 9 1 -> 10
+
+-- some carrying effects
+dqadd3031 fma 1 '0.9998' '0.0000' -> '0.9998'
+dqadd3032 fma 1 '0.9998' '0.0001' -> '0.9999'
+dqadd3033 fma 1 '0.9998' '0.0002' -> '1.0000'
+dqadd3034 fma 1 '0.9998' '0.0003' -> '1.0001'
+
+dqadd3035 fma 1 '70' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3036 fma 1 '700' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3037 fma 1 '7000' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3038 fma 1 '70000' '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
+dqadd3039 fma 1 '700000' '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded
+
+-- symmetry:
+dqadd3040 fma 1 '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3041 fma 1 '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3042 fma 1 '10000e+34' '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3044 fma 1 '10000e+34' '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
+dqadd3045 fma 1 '10000e+34' '700000' -> '1.000000000000000000000000000000007E+38' Rounded
+
+-- same, without rounding
+dqadd3046 fma 1 '10000e+9' '7' -> '10000000000007'
+dqadd3047 fma 1 '10000e+9' '70' -> '10000000000070'
+dqadd3048 fma 1 '10000e+9' '700' -> '10000000000700'
+dqadd3049 fma 1 '10000e+9' '7000' -> '10000000007000'
+dqadd3050 fma 1 '10000e+9' '70000' -> '10000000070000'
+dqadd3051 fma 1 '10000e+9' '700000' -> '10000000700000'
+dqadd3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+dqadd3053 fma 1 '12' '7.00' -> '19.00'
+dqadd3054 fma 1 '1.3' '-1.07' -> '0.23'
+dqadd3055 fma 1 '1.3' '-1.30' -> '0.00'
+dqadd3056 fma 1 '1.3' '-2.07' -> '-0.77'
+dqadd3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
+
+-- leading zero preservation
+dqadd3061 fma 1 1 '0.0001' -> '1.0001'
+dqadd3062 fma 1 1 '0.00001' -> '1.00001'
+dqadd3063 fma 1 1 '0.000001' -> '1.000001'
+dqadd3064 fma 1 1 '0.0000001' -> '1.0000001'
+dqadd3065 fma 1 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+dqadd3070 fma 1 1 0 -> 1
+dqadd3071 fma 1 1 0. -> 1
+dqadd3072 fma 1 1 .0 -> 1.0
+dqadd3073 fma 1 1 0.0 -> 1.0
+dqadd3074 fma 1 1 0.00 -> 1.00
+dqadd3075 fma 1 0 1 -> 1
+dqadd3076 fma 1 0. 1 -> 1
+dqadd3077 fma 1 .0 1 -> 1.0
+dqadd3078 fma 1 0.0 1 -> 1.0
+dqadd3079 fma 1 0.00 1 -> 1.00
+
+-- some carries
+dqadd3080 fma 1 999999998 1 -> 999999999
+dqadd3081 fma 1 999999999 1 -> 1000000000
+dqadd3082 fma 1 99999999 1 -> 100000000
+dqadd3083 fma 1 9999999 1 -> 10000000
+dqadd3084 fma 1 999999 1 -> 1000000
+dqadd3085 fma 1 99999 1 -> 100000
+dqadd3086 fma 1 9999 1 -> 10000
+dqadd3087 fma 1 999 1 -> 1000
+dqadd3088 fma 1 99 1 -> 100
+dqadd3089 fma 1 9 1 -> 10
+
+
+-- more LHS swaps
+dqadd3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
+dqadd3091 fma 1 '-56267E-6' 0 -> '-0.056267'
+dqadd3092 fma 1 '-56267E-5' 0 -> '-0.56267'
+dqadd3093 fma 1 '-56267E-4' 0 -> '-5.6267'
+dqadd3094 fma 1 '-56267E-3' 0 -> '-56.267'
+dqadd3095 fma 1 '-56267E-2' 0 -> '-562.67'
+dqadd3096 fma 1 '-56267E-1' 0 -> '-5626.7'
+dqadd3097 fma 1 '-56267E-0' 0 -> '-56267'
+dqadd3098 fma 1 '-5E-10' 0 -> '-5E-10'
+dqadd3099 fma 1 '-5E-7' 0 -> '-5E-7'
+dqadd3100 fma 1 '-5E-6' 0 -> '-0.000005'
+dqadd3101 fma 1 '-5E-5' 0 -> '-0.00005'
+dqadd3102 fma 1 '-5E-4' 0 -> '-0.0005'
+dqadd3103 fma 1 '-5E-1' 0 -> '-0.5'
+dqadd3104 fma 1 '-5E0' 0 -> '-5'
+dqadd3105 fma 1 '-5E1' 0 -> '-50'
+dqadd3106 fma 1 '-5E5' 0 -> '-500000'
+dqadd3107 fma 1 '-5E33' 0 -> '-5000000000000000000000000000000000'
+dqadd3108 fma 1 '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
+dqadd3109 fma 1 '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
+dqadd3110 fma 1 '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
+dqadd3111 fma 1 '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- more RHS swaps
+dqadd3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
+dqadd3114 fma 1 0 '-56267E-6' -> '-0.056267'
+dqadd3116 fma 1 0 '-56267E-5' -> '-0.56267'
+dqadd3117 fma 1 0 '-56267E-4' -> '-5.6267'
+dqadd3119 fma 1 0 '-56267E-3' -> '-56.267'
+dqadd3120 fma 1 0 '-56267E-2' -> '-562.67'
+dqadd3121 fma 1 0 '-56267E-1' -> '-5626.7'
+dqadd3122 fma 1 0 '-56267E-0' -> '-56267'
+dqadd3123 fma 1 0 '-5E-10' -> '-5E-10'
+dqadd3124 fma 1 0 '-5E-7' -> '-5E-7'
+dqadd3125 fma 1 0 '-5E-6' -> '-0.000005'
+dqadd3126 fma 1 0 '-5E-5' -> '-0.00005'
+dqadd3127 fma 1 0 '-5E-4' -> '-0.0005'
+dqadd3128 fma 1 0 '-5E-1' -> '-0.5'
+dqadd3129 fma 1 0 '-5E0' -> '-5'
+dqadd3130 fma 1 0 '-5E1' -> '-50'
+dqadd3131 fma 1 0 '-5E5' -> '-500000'
+dqadd3132 fma 1 0 '-5E33' -> '-5000000000000000000000000000000000'
+dqadd3133 fma 1 0 '-5E34' -> '-5.000000000000000000000000000000000E+34' Rounded
+dqadd3134 fma 1 0 '-5E35' -> '-5.000000000000000000000000000000000E+35' Rounded
+dqadd3135 fma 1 0 '-5E36' -> '-5.000000000000000000000000000000000E+36' Rounded
+dqadd3136 fma 1 0 '-5E100' -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- related
+dqadd3137 fma 1 1 '0E-39' -> '1.000000000000000000000000000000000' Rounded
+dqadd3138 fma 1 -1 '0E-39' -> '-1.000000000000000000000000000000000' Rounded
+dqadd3139 fma 1 '0E-39' 1 -> '1.000000000000000000000000000000000' Rounded
+dqadd3140 fma 1 '0E-39' -1 -> '-1.000000000000000000000000000000000' Rounded
+dqadd3141 fma 1 1E+29 0.0000 -> '100000000000000000000000000000.0000'
+dqadd3142 fma 1 1E+29 0.00000 -> '100000000000000000000000000000.0000' Rounded
+dqadd3143 fma 1 0.000 1E+30 -> '1000000000000000000000000000000.000'
+dqadd3144 fma 1 0.0000 1E+30 -> '1000000000000000000000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+dqadd3146 fma 1 '00.0' 0 -> '0.0'
+dqadd3147 fma 1 '0.00' 0 -> '0.00'
+dqadd3148 fma 1 0 '0.00' -> '0.00'
+dqadd3149 fma 1 0 '00.0' -> '0.0'
+dqadd3150 fma 1 '00.0' '0.00' -> '0.00'
+dqadd3151 fma 1 '0.00' '00.0' -> '0.00'
+dqadd3152 fma 1 '3' '.3' -> '3.3'
+dqadd3153 fma 1 '3.' '.3' -> '3.3'
+dqadd3154 fma 1 '3.0' '.3' -> '3.3'
+dqadd3155 fma 1 '3.00' '.3' -> '3.30'
+dqadd3156 fma 1 '3' '3' -> '6'
+dqadd3157 fma 1 '3' '+3' -> '6'
+dqadd3158 fma 1 '3' '-3' -> '0'
+dqadd3159 fma 1 '0.3' '-0.3' -> '0.0'
+dqadd3160 fma 1 '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+dqadd3161 fma 1 '1E+12' '-1' -> '999999999999'
+dqadd3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
+dqadd3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
+dqadd3164 fma 1 '-1' '1E+12' -> '999999999999'
+dqadd3165 fma 1 '7E+12' '-1' -> '6999999999999'
+dqadd3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
+dqadd3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
+dqadd3168 fma 1 '-1' '7E+12' -> '6999999999999'
+
+rounding: half_up
+dqadd3170 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd3171 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd3172 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd3173 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
+dqadd3174 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd3175 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd3176 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd3177 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
+dqadd3178 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd3179 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd3180 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd3181 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd3182 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd3183 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+dqadd3200 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd3201 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3202 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3203 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3204 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3205 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3206 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3207 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3208 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3209 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3210 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3211 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3212 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3213 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3214 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3215 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3216 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd3217 fma 1 '1231234567890123456784560123456789' 1.000000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3218 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3219 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+
+rounding: half_even
+dqadd3220 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd3221 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3222 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3223 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3224 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3225 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3226 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3227 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3228 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3229 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3230 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3231 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3232 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3233 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3234 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3235 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3236 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd3237 fma 1 '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3238 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3239 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+-- critical few with even bottom digit...
+dqadd3240 fma 1 '1231234567890123456784560123456788' 0.499999999 -> '1231234567890123456784560123456788' Inexact Rounded
+dqadd3241 fma 1 '1231234567890123456784560123456788' 0.5 -> '1231234567890123456784560123456788' Inexact Rounded
+dqadd3242 fma 1 '1231234567890123456784560123456788' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
+
+rounding: down
+dqadd3250 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd3251 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3252 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3253 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3254 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3255 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3256 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3257 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3258 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3259 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3260 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3261 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3262 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3263 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3264 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3265 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3266 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd3267 fma 1 '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3268 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3269 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+dqadd3301 fma 1 -1 1 -> 0
+dqadd3302 fma 1 0 1 -> 1
+dqadd3303 fma 1 1 1 -> 2
+dqadd3304 fma 1 12 1 -> 13
+dqadd3305 fma 1 98 1 -> 99
+dqadd3306 fma 1 99 1 -> 100
+dqadd3307 fma 1 100 1 -> 101
+dqadd3308 fma 1 101 1 -> 102
+dqadd3309 fma 1 -1 -1 -> -2
+dqadd3310 fma 1 0 -1 -> -1
+dqadd3311 fma 1 1 -1 -> 0
+dqadd3312 fma 1 12 -1 -> 11
+dqadd3313 fma 1 98 -1 -> 97
+dqadd3314 fma 1 99 -1 -> 98
+dqadd3315 fma 1 100 -1 -> 99
+dqadd3316 fma 1 101 -1 -> 100
+
+dqadd3321 fma 1 -0.01 0.01 -> 0.00
+dqadd3322 fma 1 0.00 0.01 -> 0.01
+dqadd3323 fma 1 0.01 0.01 -> 0.02
+dqadd3324 fma 1 0.12 0.01 -> 0.13
+dqadd3325 fma 1 0.98 0.01 -> 0.99
+dqadd3326 fma 1 0.99 0.01 -> 1.00
+dqadd3327 fma 1 1.00 0.01 -> 1.01
+dqadd3328 fma 1 1.01 0.01 -> 1.02
+dqadd3329 fma 1 -0.01 -0.01 -> -0.02
+dqadd3330 fma 1 0.00 -0.01 -> -0.01
+dqadd3331 fma 1 0.01 -0.01 -> 0.00
+dqadd3332 fma 1 0.12 -0.01 -> 0.11
+dqadd3333 fma 1 0.98 -0.01 -> 0.97
+dqadd3334 fma 1 0.99 -0.01 -> 0.98
+dqadd3335 fma 1 1.00 -0.01 -> 0.99
+dqadd3336 fma 1 1.01 -0.01 -> 1.00
+
+-- some more cases where adding 0 affects the coefficient
+dqadd3340 fma 1 1E+3 0 -> 1000
+dqadd3341 fma 1 1E+33 0 -> 1000000000000000000000000000000000
+dqadd3342 fma 1 1E+34 0 -> 1.000000000000000000000000000000000E+34 Rounded
+dqadd3343 fma 1 1E+35 0 -> 1.000000000000000000000000000000000E+35 Rounded
+-- which simply follow from these cases ...
+dqadd3344 fma 1 1E+3 1 -> 1001
+dqadd3345 fma 1 1E+33 1 -> 1000000000000000000000000000000001
+dqadd3346 fma 1 1E+34 1 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd3347 fma 1 1E+35 1 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
+dqadd3348 fma 1 1E+3 7 -> 1007
+dqadd3349 fma 1 1E+33 7 -> 1000000000000000000000000000000007
+dqadd3350 fma 1 1E+34 7 -> 1.000000000000000000000000000000001E+34 Inexact Rounded
+dqadd3351 fma 1 1E+35 7 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
+
+-- tryzeros cases
+rounding: half_up
+dqadd3360 fma 1 0E+50 10000E+1 -> 1.0000E+5
+dqadd3361 fma 1 0E-50 10000E+1 -> 100000.0000000000000000000000000000 Rounded
+dqadd3362 fma 1 10000E+1 0E-50 -> 100000.0000000000000000000000000000 Rounded
+dqadd3363 fma 1 10000E+1 10000E-50 -> 100000.0000000000000000000000000000 Rounded Inexact
+dqadd3364 fma 1 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
+-- 1 234567890123456789012345678901234
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+dqadd3370 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd3371 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+rounding: half_up
+dqadd3372 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd3373 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+rounding: half_even
+dqadd3374 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd3375 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+
+-- ulp replacement tests
+dqadd3400 fma 1 1 77e-32 -> 1.00000000000000000000000000000077
+dqadd3401 fma 1 1 77e-33 -> 1.000000000000000000000000000000077
+dqadd3402 fma 1 1 77e-34 -> 1.000000000000000000000000000000008 Inexact Rounded
+dqadd3403 fma 1 1 77e-35 -> 1.000000000000000000000000000000001 Inexact Rounded
+dqadd3404 fma 1 1 77e-36 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd3405 fma 1 1 77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd3406 fma 1 1 77e-299 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd3410 fma 1 10 77e-32 -> 10.00000000000000000000000000000077
+dqadd3411 fma 1 10 77e-33 -> 10.00000000000000000000000000000008 Inexact Rounded
+dqadd3412 fma 1 10 77e-34 -> 10.00000000000000000000000000000001 Inexact Rounded
+dqadd3413 fma 1 10 77e-35 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3414 fma 1 10 77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3415 fma 1 10 77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3416 fma 1 10 77e-299 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd3420 fma 1 77e-32 1 -> 1.00000000000000000000000000000077
+dqadd3421 fma 1 77e-33 1 -> 1.000000000000000000000000000000077
+dqadd3422 fma 1 77e-34 1 -> 1.000000000000000000000000000000008 Inexact Rounded
+dqadd3423 fma 1 77e-35 1 -> 1.000000000000000000000000000000001 Inexact Rounded
+dqadd3424 fma 1 77e-36 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd3425 fma 1 77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd3426 fma 1 77e-299 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd3430 fma 1 77e-32 10 -> 10.00000000000000000000000000000077
+dqadd3431 fma 1 77e-33 10 -> 10.00000000000000000000000000000008 Inexact Rounded
+dqadd3432 fma 1 77e-34 10 -> 10.00000000000000000000000000000001 Inexact Rounded
+dqadd3433 fma 1 77e-35 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3434 fma 1 77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3435 fma 1 77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3436 fma 1 77e-299 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+-- negative ulps
+dqadd36440 fma 1 1 -77e-32 -> 0.99999999999999999999999999999923
+dqadd36441 fma 1 1 -77e-33 -> 0.999999999999999999999999999999923
+dqadd36442 fma 1 1 -77e-34 -> 0.9999999999999999999999999999999923
+dqadd36443 fma 1 1 -77e-35 -> 0.9999999999999999999999999999999992 Inexact Rounded
+dqadd36444 fma 1 1 -77e-36 -> 0.9999999999999999999999999999999999 Inexact Rounded
+dqadd36445 fma 1 1 -77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd36446 fma 1 1 -77e-99 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd36450 fma 1 10 -77e-32 -> 9.99999999999999999999999999999923
+dqadd36451 fma 1 10 -77e-33 -> 9.999999999999999999999999999999923
+dqadd36452 fma 1 10 -77e-34 -> 9.999999999999999999999999999999992 Inexact Rounded
+dqadd36453 fma 1 10 -77e-35 -> 9.999999999999999999999999999999999 Inexact Rounded
+dqadd36454 fma 1 10 -77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd36455 fma 1 10 -77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd36456 fma 1 10 -77e-99 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd36460 fma 1 -77e-32 1 -> 0.99999999999999999999999999999923
+dqadd36461 fma 1 -77e-33 1 -> 0.999999999999999999999999999999923
+dqadd36462 fma 1 -77e-34 1 -> 0.9999999999999999999999999999999923
+dqadd36463 fma 1 -77e-35 1 -> 0.9999999999999999999999999999999992 Inexact Rounded
+dqadd36464 fma 1 -77e-36 1 -> 0.9999999999999999999999999999999999 Inexact Rounded
+dqadd36465 fma 1 -77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd36466 fma 1 -77e-99 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd36470 fma 1 -77e-32 10 -> 9.99999999999999999999999999999923
+dqadd36471 fma 1 -77e-33 10 -> 9.999999999999999999999999999999923
+dqadd36472 fma 1 -77e-34 10 -> 9.999999999999999999999999999999992 Inexact Rounded
+dqadd36473 fma 1 -77e-35 10 -> 9.999999999999999999999999999999999 Inexact Rounded
+dqadd36474 fma 1 -77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd36475 fma 1 -77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd36476 fma 1 -77e-99 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+-- negative ulps
+dqadd36480 fma 1 -1 77e-32 -> -0.99999999999999999999999999999923
+dqadd36481 fma 1 -1 77e-33 -> -0.999999999999999999999999999999923
+dqadd36482 fma 1 -1 77e-34 -> -0.9999999999999999999999999999999923
+dqadd36483 fma 1 -1 77e-35 -> -0.9999999999999999999999999999999992 Inexact Rounded
+dqadd36484 fma 1 -1 77e-36 -> -0.9999999999999999999999999999999999 Inexact Rounded
+dqadd36485 fma 1 -1 77e-37 -> -1.000000000000000000000000000000000 Inexact Rounded
+dqadd36486 fma 1 -1 77e-99 -> -1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd36490 fma 1 -10 77e-32 -> -9.99999999999999999999999999999923
+dqadd36491 fma 1 -10 77e-33 -> -9.999999999999999999999999999999923
+dqadd36492 fma 1 -10 77e-34 -> -9.999999999999999999999999999999992 Inexact Rounded
+dqadd36493 fma 1 -10 77e-35 -> -9.999999999999999999999999999999999 Inexact Rounded
+dqadd36494 fma 1 -10 77e-36 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd36495 fma 1 -10 77e-37 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd36496 fma 1 -10 77e-99 -> -10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd36500 fma 1 77e-32 -1 -> -0.99999999999999999999999999999923
+dqadd36501 fma 1 77e-33 -1 -> -0.999999999999999999999999999999923
+dqadd36502 fma 1 77e-34 -1 -> -0.9999999999999999999999999999999923
+dqadd36503 fma 1 77e-35 -1 -> -0.9999999999999999999999999999999992 Inexact Rounded
+dqadd36504 fma 1 77e-36 -1 -> -0.9999999999999999999999999999999999 Inexact Rounded
+dqadd36505 fma 1 77e-37 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
+dqadd36506 fma 1 77e-99 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd36510 fma 1 77e-32 -10 -> -9.99999999999999999999999999999923
+dqadd36511 fma 1 77e-33 -10 -> -9.999999999999999999999999999999923
+dqadd36512 fma 1 77e-34 -10 -> -9.999999999999999999999999999999992 Inexact Rounded
+dqadd36513 fma 1 77e-35 -10 -> -9.999999999999999999999999999999999 Inexact Rounded
+dqadd36514 fma 1 77e-36 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd36515 fma 1 77e-37 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd36516 fma 1 77e-99 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+
+-- and some more residue effects and different roundings
+rounding: half_up
+dqadd36540 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd36541 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36542 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36543 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36544 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36545 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36546 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36547 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36548 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36549 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36550 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36551 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36552 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36553 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36554 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36555 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36556 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd36557 fma 1 '9876543219876543216543210123456789' 1.000000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36558 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36559 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+rounding: half_even
+dqadd36560 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd36561 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36562 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36563 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36564 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36565 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36566 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36567 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36568 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36569 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36570 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36571 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36572 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36573 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36574 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36575 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36576 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd36577 fma 1 '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36578 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36579 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+-- critical few with even bottom digit...
+dqadd37540 fma 1 '9876543219876543216543210123456788' 0.499999999 -> '9876543219876543216543210123456788' Inexact Rounded
+dqadd37541 fma 1 '9876543219876543216543210123456788' 0.5 -> '9876543219876543216543210123456788' Inexact Rounded
+dqadd37542 fma 1 '9876543219876543216543210123456788' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
+
+rounding: down
+dqadd37550 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd37551 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37552 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37553 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37554 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37555 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37556 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37557 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37558 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37559 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37560 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37561 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37562 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37563 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37564 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37565 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37566 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd37567 fma 1 '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd37568 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd37569 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+dqadd37701 fma 1 5.00 1.00E-3 -> 5.00100
+dqadd37702 fma 1 00.00 0.000 -> 0.000
+dqadd37703 fma 1 00.00 0E-3 -> 0.000
+dqadd37704 fma 1 0E-3 00.00 -> 0.000
+
+dqadd37710 fma 1 0E+3 00.00 -> 0.00
+dqadd37711 fma 1 0E+3 00.0 -> 0.0
+dqadd37712 fma 1 0E+3 00. -> 0
+dqadd37713 fma 1 0E+3 00.E+1 -> 0E+1
+dqadd37714 fma 1 0E+3 00.E+2 -> 0E+2
+dqadd37715 fma 1 0E+3 00.E+3 -> 0E+3
+dqadd37716 fma 1 0E+3 00.E+4 -> 0E+3
+dqadd37717 fma 1 0E+3 00.E+5 -> 0E+3
+dqadd37718 fma 1 0E+3 -00.0 -> 0.0
+dqadd37719 fma 1 0E+3 -00. -> 0
+dqadd37731 fma 1 0E+3 -00.E+1 -> 0E+1
+
+dqadd37720 fma 1 00.00 0E+3 -> 0.00
+dqadd37721 fma 1 00.0 0E+3 -> 0.0
+dqadd37722 fma 1 00. 0E+3 -> 0
+dqadd37723 fma 1 00.E+1 0E+3 -> 0E+1
+dqadd37724 fma 1 00.E+2 0E+3 -> 0E+2
+dqadd37725 fma 1 00.E+3 0E+3 -> 0E+3
+dqadd37726 fma 1 00.E+4 0E+3 -> 0E+3
+dqadd37727 fma 1 00.E+5 0E+3 -> 0E+3
+dqadd37728 fma 1 -00.00 0E+3 -> 0.00
+dqadd37729 fma 1 -00.0 0E+3 -> 0.0
+dqadd37730 fma 1 -00. 0E+3 -> 0
+
+dqadd37732 fma 1 0 0 -> 0
+dqadd37733 fma 1 0 -0 -> 0
+dqadd37734 fma 1 -0 0 -> 0
+dqadd37735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
+
+dqadd37736 fma 1 1 -1 -> 0
+dqadd37737 fma 1 -1 -1 -> -2
+dqadd37738 fma 1 1 1 -> 2
+dqadd37739 fma 1 -1 1 -> 0
+
+dqadd37741 fma 1 0 -1 -> -1
+dqadd37742 fma 1 -0 -1 -> -1
+dqadd37743 fma 1 0 1 -> 1
+dqadd37744 fma 1 -0 1 -> 1
+dqadd37745 fma 1 -1 0 -> -1
+dqadd37746 fma 1 -1 -0 -> -1
+dqadd37747 fma 1 1 0 -> 1
+dqadd37748 fma 1 1 -0 -> 1
+
+dqadd37751 fma 1 0.0 -1 -> -1.0
+dqadd37752 fma 1 -0.0 -1 -> -1.0
+dqadd37753 fma 1 0.0 1 -> 1.0
+dqadd37754 fma 1 -0.0 1 -> 1.0
+dqadd37755 fma 1 -1.0 0 -> -1.0
+dqadd37756 fma 1 -1.0 -0 -> -1.0
+dqadd37757 fma 1 1.0 0 -> 1.0
+dqadd37758 fma 1 1.0 -0 -> 1.0
+
+dqadd37761 fma 1 0 -1.0 -> -1.0
+dqadd37762 fma 1 -0 -1.0 -> -1.0
+dqadd37763 fma 1 0 1.0 -> 1.0
+dqadd37764 fma 1 -0 1.0 -> 1.0
+dqadd37765 fma 1 -1 0.0 -> -1.0
+dqadd37766 fma 1 -1 -0.0 -> -1.0
+dqadd37767 fma 1 1 0.0 -> 1.0
+dqadd37768 fma 1 1 -0.0 -> 1.0
+
+dqadd37771 fma 1 0.0 -1.0 -> -1.0
+dqadd37772 fma 1 -0.0 -1.0 -> -1.0
+dqadd37773 fma 1 0.0 1.0 -> 1.0
+dqadd37774 fma 1 -0.0 1.0 -> 1.0
+dqadd37775 fma 1 -1.0 0.0 -> -1.0
+dqadd37776 fma 1 -1.0 -0.0 -> -1.0
+dqadd37777 fma 1 1.0 0.0 -> 1.0
+dqadd37778 fma 1 1.0 -0.0 -> 1.0
+
+-- Specials
+dqadd37780 fma 1 -Inf -Inf -> -Infinity
+dqadd37781 fma 1 -Inf -1000 -> -Infinity
+dqadd37782 fma 1 -Inf -1 -> -Infinity
+dqadd37783 fma 1 -Inf -0 -> -Infinity
+dqadd37784 fma 1 -Inf 0 -> -Infinity
+dqadd37785 fma 1 -Inf 1 -> -Infinity
+dqadd37786 fma 1 -Inf 1000 -> -Infinity
+dqadd37787 fma 1 -1000 -Inf -> -Infinity
+dqadd37788 fma 1 -Inf -Inf -> -Infinity
+dqadd37789 fma 1 -1 -Inf -> -Infinity
+dqadd37790 fma 1 -0 -Inf -> -Infinity
+dqadd37791 fma 1 0 -Inf -> -Infinity
+dqadd37792 fma 1 1 -Inf -> -Infinity
+dqadd37793 fma 1 1000 -Inf -> -Infinity
+dqadd37794 fma 1 Inf -Inf -> NaN Invalid_operation
+
+dqadd37800 fma 1 Inf -Inf -> NaN Invalid_operation
+dqadd37801 fma 1 Inf -1000 -> Infinity
+dqadd37802 fma 1 Inf -1 -> Infinity
+dqadd37803 fma 1 Inf -0 -> Infinity
+dqadd37804 fma 1 Inf 0 -> Infinity
+dqadd37805 fma 1 Inf 1 -> Infinity
+dqadd37806 fma 1 Inf 1000 -> Infinity
+dqadd37807 fma 1 Inf Inf -> Infinity
+dqadd37808 fma 1 -1000 Inf -> Infinity
+dqadd37809 fma 1 -Inf Inf -> NaN Invalid_operation
+dqadd37810 fma 1 -1 Inf -> Infinity
+dqadd37811 fma 1 -0 Inf -> Infinity
+dqadd37812 fma 1 0 Inf -> Infinity
+dqadd37813 fma 1 1 Inf -> Infinity
+dqadd37814 fma 1 1000 Inf -> Infinity
+dqadd37815 fma 1 Inf Inf -> Infinity
+
+dqadd37821 fma 1 NaN -Inf -> NaN
+dqadd37822 fma 1 NaN -1000 -> NaN
+dqadd37823 fma 1 NaN -1 -> NaN
+dqadd37824 fma 1 NaN -0 -> NaN
+dqadd37825 fma 1 NaN 0 -> NaN
+dqadd37826 fma 1 NaN 1 -> NaN
+dqadd37827 fma 1 NaN 1000 -> NaN
+dqadd37828 fma 1 NaN Inf -> NaN
+dqadd37829 fma 1 NaN NaN -> NaN
+dqadd37830 fma 1 -Inf NaN -> NaN
+dqadd37831 fma 1 -1000 NaN -> NaN
+dqadd37832 fma 1 -1 NaN -> NaN
+dqadd37833 fma 1 -0 NaN -> NaN
+dqadd37834 fma 1 0 NaN -> NaN
+dqadd37835 fma 1 1 NaN -> NaN
+dqadd37836 fma 1 1000 NaN -> NaN
+dqadd37837 fma 1 Inf NaN -> NaN
+
+dqadd37841 fma 1 sNaN -Inf -> NaN Invalid_operation
+dqadd37842 fma 1 sNaN -1000 -> NaN Invalid_operation
+dqadd37843 fma 1 sNaN -1 -> NaN Invalid_operation
+dqadd37844 fma 1 sNaN -0 -> NaN Invalid_operation
+dqadd37845 fma 1 sNaN 0 -> NaN Invalid_operation
+dqadd37846 fma 1 sNaN 1 -> NaN Invalid_operation
+dqadd37847 fma 1 sNaN 1000 -> NaN Invalid_operation
+dqadd37848 fma 1 sNaN NaN -> NaN Invalid_operation
+dqadd37849 fma 1 sNaN sNaN -> NaN Invalid_operation
+dqadd37850 fma 1 NaN sNaN -> NaN Invalid_operation
+dqadd37851 fma 1 -Inf sNaN -> NaN Invalid_operation
+dqadd37852 fma 1 -1000 sNaN -> NaN Invalid_operation
+dqadd37853 fma 1 -1 sNaN -> NaN Invalid_operation
+dqadd37854 fma 1 -0 sNaN -> NaN Invalid_operation
+dqadd37855 fma 1 0 sNaN -> NaN Invalid_operation
+dqadd37856 fma 1 1 sNaN -> NaN Invalid_operation
+dqadd37857 fma 1 1000 sNaN -> NaN Invalid_operation
+dqadd37858 fma 1 Inf sNaN -> NaN Invalid_operation
+dqadd37859 fma 1 NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqadd37861 fma 1 NaN1 -Inf -> NaN1
+dqadd37862 fma 1 +NaN2 -1000 -> NaN2
+dqadd37863 fma 1 NaN3 1000 -> NaN3
+dqadd37864 fma 1 NaN4 Inf -> NaN4
+dqadd37865 fma 1 NaN5 +NaN6 -> NaN5
+dqadd37866 fma 1 -Inf NaN7 -> NaN7
+dqadd37867 fma 1 -1000 NaN8 -> NaN8
+dqadd37868 fma 1 1000 NaN9 -> NaN9
+dqadd37869 fma 1 Inf +NaN10 -> NaN10
+dqadd37871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
+dqadd37872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
+dqadd37873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
+dqadd37874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
+dqadd37875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqadd37876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
+dqadd37877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
+dqadd37878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
+dqadd37879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
+dqadd37880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
+dqadd37881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqadd37882 fma 1 -NaN26 NaN28 -> -NaN26
+dqadd37883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqadd37884 fma 1 1000 -NaN30 -> -NaN30
+dqadd37885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Here we explore near the boundary of rounding a subnormal to Nmin
+dqadd37575 fma 1 1E-6143 -1E-6176 -> 9.99999999999999999999999999999999E-6144 Subnormal
+dqadd37576 fma 1 -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal
+
+-- check overflow edge case
+-- 1234567890123456
+dqadd37972 apply 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqadd37973 fma 1 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37974 fma 1 9999999999999999999999999999999999E+6111 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37975 fma 1 9999999999999999999999999999999999E+6111 1E+6111 -> Infinity Overflow Inexact Rounded
+dqadd37976 fma 1 9999999999999999999999999999999999E+6111 9E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37977 fma 1 9999999999999999999999999999999999E+6111 8E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37978 fma 1 9999999999999999999999999999999999E+6111 7E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37979 fma 1 9999999999999999999999999999999999E+6111 6E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37980 fma 1 9999999999999999999999999999999999E+6111 5E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37981 fma 1 9999999999999999999999999999999999E+6111 4E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37982 fma 1 9999999999999999999999999999999999E+6111 3E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37983 fma 1 9999999999999999999999999999999999E+6111 2E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37984 fma 1 9999999999999999999999999999999999E+6111 1E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+
+dqadd37985 apply -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqadd37986 fma 1 -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37987 fma 1 -9999999999999999999999999999999999E+6111 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37988 fma 1 -9999999999999999999999999999999999E+6111 -1E+6111 -> -Infinity Overflow Inexact Rounded
+dqadd37989 fma 1 -9999999999999999999999999999999999E+6111 -9E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37990 fma 1 -9999999999999999999999999999999999E+6111 -8E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37991 fma 1 -9999999999999999999999999999999999E+6111 -7E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37992 fma 1 -9999999999999999999999999999999999E+6111 -6E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37993 fma 1 -9999999999999999999999999999999999E+6111 -5E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37994 fma 1 -9999999999999999999999999999999999E+6111 -4E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37995 fma 1 -9999999999999999999999999999999999E+6111 -3E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37996 fma 1 -9999999999999999999999999999999999E+6111 -2E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37997 fma 1 -9999999999999999999999999999999999E+6111 -1E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+dqadd371100 fma 1 1e+2 -1e-6143 -> 99.99999999999999999999999999999999 Rounded Inexact
+dqadd371101 fma 1 1e+1 -1e-6143 -> 9.999999999999999999999999999999999 Rounded Inexact
+dqadd371103 fma 1 +1 -1e-6143 -> 0.9999999999999999999999999999999999 Rounded Inexact
+dqadd371104 fma 1 1e-1 -1e-6143 -> 0.09999999999999999999999999999999999 Rounded Inexact
+dqadd371105 fma 1 1e-2 -1e-6143 -> 0.009999999999999999999999999999999999 Rounded Inexact
+dqadd371106 fma 1 1e-3 -1e-6143 -> 0.0009999999999999999999999999999999999 Rounded Inexact
+dqadd371107 fma 1 1e-4 -1e-6143 -> 0.00009999999999999999999999999999999999 Rounded Inexact
+dqadd371108 fma 1 1e-5 -1e-6143 -> 0.000009999999999999999999999999999999999 Rounded Inexact
+dqadd371109 fma 1 1e-6 -1e-6143 -> 9.999999999999999999999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+dqadd371110 fma 1 -1e+2 +1e-6143 -> -99.99999999999999999999999999999999 Rounded Inexact
+dqadd371111 fma 1 -1e+1 +1e-6143 -> -9.999999999999999999999999999999999 Rounded Inexact
+dqadd371113 fma 1 -1 +1e-6143 -> -0.9999999999999999999999999999999999 Rounded Inexact
+dqadd371114 fma 1 -1e-1 +1e-6143 -> -0.09999999999999999999999999999999999 Rounded Inexact
+dqadd371115 fma 1 -1e-2 +1e-6143 -> -0.009999999999999999999999999999999999 Rounded Inexact
+dqadd371116 fma 1 -1e-3 +1e-6143 -> -0.0009999999999999999999999999999999999 Rounded Inexact
+dqadd371117 fma 1 -1e-4 +1e-6143 -> -0.00009999999999999999999999999999999999 Rounded Inexact
+dqadd371118 fma 1 -1e-5 +1e-6143 -> -0.000009999999999999999999999999999999999 Rounded Inexact
+dqadd371119 fma 1 -1e-6 +1e-6143 -> -9.999999999999999999999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+dqadd371300 fma 1 1E34 -0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371310 fma 1 1E34 -0.51 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371311 fma 1 1E34 -0.501 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371312 fma 1 1E34 -0.5001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371313 fma 1 1E34 -0.50001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371314 fma 1 1E34 -0.500001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371315 fma 1 1E34 -0.5000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371316 fma 1 1E34 -0.50000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371317 fma 1 1E34 -0.500000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371318 fma 1 1E34 -0.5000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371319 fma 1 1E34 -0.50000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371320 fma 1 1E34 -0.500000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371321 fma 1 1E34 -0.5000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371322 fma 1 1E34 -0.50000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371323 fma 1 1E34 -0.500000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371324 fma 1 1E34 -0.5000000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371325 fma 1 1E34 -0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371326 fma 1 1E34 -0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371327 fma 1 1E34 -0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371328 fma 1 1E34 -0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371329 fma 1 1E34 -0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371330 fma 1 1E34 -0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371331 fma 1 1E34 -0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371332 fma 1 1E34 -0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371333 fma 1 1E34 -0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371334 fma 1 1E34 -0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371335 fma 1 1E34 -0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371336 fma 1 1E34 -0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371337 fma 1 1E34 -0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371338 fma 1 1E34 -0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371339 fma 1 1E34 -0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+
+dqadd371340 fma 1 1E34 -5000000.000010001 -> 9999999999999999999999999995000000 Inexact Rounded
+dqadd371341 fma 1 1E34 -5000000.000000001 -> 9999999999999999999999999995000000 Inexact Rounded
+
+dqadd371349 fma 1 9999999999999999999999999999999999 0.4 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371350 fma 1 9999999999999999999999999999999999 0.49 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371351 fma 1 9999999999999999999999999999999999 0.499 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371352 fma 1 9999999999999999999999999999999999 0.4999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371353 fma 1 9999999999999999999999999999999999 0.49999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371354 fma 1 9999999999999999999999999999999999 0.499999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371355 fma 1 9999999999999999999999999999999999 0.4999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371356 fma 1 9999999999999999999999999999999999 0.49999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371357 fma 1 9999999999999999999999999999999999 0.499999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371358 fma 1 9999999999999999999999999999999999 0.4999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371359 fma 1 9999999999999999999999999999999999 0.49999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371360 fma 1 9999999999999999999999999999999999 0.499999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371361 fma 1 9999999999999999999999999999999999 0.4999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371362 fma 1 9999999999999999999999999999999999 0.49999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371363 fma 1 9999999999999999999999999999999999 0.499999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371364 fma 1 9999999999999999999999999999999999 0.4999999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371365 fma 1 9999999999999999999999999999999999 0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371367 fma 1 9999999999999999999999999999999999 0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371368 fma 1 9999999999999999999999999999999999 0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371369 fma 1 9999999999999999999999999999999999 0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371370 fma 1 9999999999999999999999999999999999 0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371371 fma 1 9999999999999999999999999999999999 0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371372 fma 1 9999999999999999999999999999999999 0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371373 fma 1 9999999999999999999999999999999999 0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371374 fma 1 9999999999999999999999999999999999 0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371375 fma 1 9999999999999999999999999999999999 0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371376 fma 1 9999999999999999999999999999999999 0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371377 fma 1 9999999999999999999999999999999999 0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371378 fma 1 9999999999999999999999999999999999 0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371379 fma 1 9999999999999999999999999999999999 0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371380 fma 1 9999999999999999999999999999999999 0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371381 fma 1 9999999999999999999999999999999999 0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371382 fma 1 9999999999999999999999999999999999 0.5000000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371383 fma 1 9999999999999999999999999999999999 0.500000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371384 fma 1 9999999999999999999999999999999999 0.50000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371385 fma 1 9999999999999999999999999999999999 0.5000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371386 fma 1 9999999999999999999999999999999999 0.500000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371387 fma 1 9999999999999999999999999999999999 0.50000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371388 fma 1 9999999999999999999999999999999999 0.5000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371389 fma 1 9999999999999999999999999999999999 0.500000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371390 fma 1 9999999999999999999999999999999999 0.50000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371391 fma 1 9999999999999999999999999999999999 0.5000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371392 fma 1 9999999999999999999999999999999999 0.500001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371393 fma 1 9999999999999999999999999999999999 0.50001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371394 fma 1 9999999999999999999999999999999999 0.5001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371395 fma 1 9999999999999999999999999999999999 0.501 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371396 fma 1 9999999999999999999999999999999999 0.51 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+dqadd371420 fma 1 0 1.123456789987654321123456789012345 -> 1.123456789987654321123456789012345
+dqadd371421 fma 1 0 1.123456789987654321123456789012345E-1 -> 0.1123456789987654321123456789012345
+dqadd371422 fma 1 0 1.123456789987654321123456789012345E-2 -> 0.01123456789987654321123456789012345
+dqadd371423 fma 1 0 1.123456789987654321123456789012345E-3 -> 0.001123456789987654321123456789012345
+dqadd371424 fma 1 0 1.123456789987654321123456789012345E-4 -> 0.0001123456789987654321123456789012345
+dqadd371425 fma 1 0 1.123456789987654321123456789012345E-5 -> 0.00001123456789987654321123456789012345
+dqadd371426 fma 1 0 1.123456789987654321123456789012345E-6 -> 0.000001123456789987654321123456789012345
+dqadd371427 fma 1 0 1.123456789987654321123456789012345E-7 -> 1.123456789987654321123456789012345E-7
+dqadd371428 fma 1 0 1.123456789987654321123456789012345E-8 -> 1.123456789987654321123456789012345E-8
+dqadd371429 fma 1 0 1.123456789987654321123456789012345E-9 -> 1.123456789987654321123456789012345E-9
+dqadd371430 fma 1 0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
+dqadd371431 fma 1 0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
+dqadd371432 fma 1 0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
+dqadd371433 fma 1 0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
+dqadd371434 fma 1 0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
+dqadd371435 fma 1 0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
+dqadd371436 fma 1 0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
+dqadd371437 fma 1 0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
+dqadd371438 fma 1 0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
+dqadd371439 fma 1 0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
+dqadd371440 fma 1 0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
+dqadd371441 fma 1 0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
+dqadd371442 fma 1 0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
+dqadd371443 fma 1 0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
+dqadd371444 fma 1 0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
+dqadd371445 fma 1 0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
+dqadd371446 fma 1 0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
+dqadd371447 fma 1 0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
+dqadd371448 fma 1 0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
+dqadd371449 fma 1 0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
+dqadd371450 fma 1 0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
+dqadd371451 fma 1 0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
+dqadd371452 fma 1 0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
+dqadd371453 fma 1 0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
+dqadd371454 fma 1 0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
+dqadd371455 fma 1 0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
+dqadd371456 fma 1 0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36
+
+-- same, reversed 0
+dqadd371460 fma 1 1.123456789987654321123456789012345 0 -> 1.123456789987654321123456789012345
+dqadd371461 fma 1 1.123456789987654321123456789012345E-1 0 -> 0.1123456789987654321123456789012345
+dqadd371462 fma 1 1.123456789987654321123456789012345E-2 0 -> 0.01123456789987654321123456789012345
+dqadd371463 fma 1 1.123456789987654321123456789012345E-3 0 -> 0.001123456789987654321123456789012345
+dqadd371464 fma 1 1.123456789987654321123456789012345E-4 0 -> 0.0001123456789987654321123456789012345
+dqadd371465 fma 1 1.123456789987654321123456789012345E-5 0 -> 0.00001123456789987654321123456789012345
+dqadd371466 fma 1 1.123456789987654321123456789012345E-6 0 -> 0.000001123456789987654321123456789012345
+dqadd371467 fma 1 1.123456789987654321123456789012345E-7 0 -> 1.123456789987654321123456789012345E-7
+dqadd371468 fma 1 1.123456789987654321123456789012345E-8 0 -> 1.123456789987654321123456789012345E-8
+dqadd371469 fma 1 1.123456789987654321123456789012345E-9 0 -> 1.123456789987654321123456789012345E-9
+dqadd371470 fma 1 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
+dqadd371471 fma 1 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
+dqadd371472 fma 1 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
+dqadd371473 fma 1 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
+dqadd371474 fma 1 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
+dqadd371475 fma 1 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
+dqadd371476 fma 1 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
+dqadd371477 fma 1 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
+dqadd371478 fma 1 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
+dqadd371479 fma 1 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
+dqadd371480 fma 1 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
+dqadd371481 fma 1 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
+dqadd371482 fma 1 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
+dqadd371483 fma 1 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
+dqadd371484 fma 1 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
+dqadd371485 fma 1 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
+dqadd371486 fma 1 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
+dqadd371487 fma 1 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
+dqadd371488 fma 1 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
+dqadd371489 fma 1 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
+dqadd371490 fma 1 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
+dqadd371491 fma 1 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
+dqadd371492 fma 1 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
+dqadd371493 fma 1 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
+dqadd371494 fma 1 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
+dqadd371495 fma 1 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
+dqadd371496 fma 1 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36
+
+-- same, Es on the 0
+dqadd371500 fma 1 1.123456789987654321123456789012345 0E-0 -> 1.123456789987654321123456789012345
+dqadd371501 fma 1 1.123456789987654321123456789012345 0E-1 -> 1.123456789987654321123456789012345
+dqadd371502 fma 1 1.123456789987654321123456789012345 0E-2 -> 1.123456789987654321123456789012345
+dqadd371503 fma 1 1.123456789987654321123456789012345 0E-3 -> 1.123456789987654321123456789012345
+dqadd371504 fma 1 1.123456789987654321123456789012345 0E-4 -> 1.123456789987654321123456789012345
+dqadd371505 fma 1 1.123456789987654321123456789012345 0E-5 -> 1.123456789987654321123456789012345
+dqadd371506 fma 1 1.123456789987654321123456789012345 0E-6 -> 1.123456789987654321123456789012345
+dqadd371507 fma 1 1.123456789987654321123456789012345 0E-7 -> 1.123456789987654321123456789012345
+dqadd371508 fma 1 1.123456789987654321123456789012345 0E-8 -> 1.123456789987654321123456789012345
+dqadd371509 fma 1 1.123456789987654321123456789012345 0E-9 -> 1.123456789987654321123456789012345
+dqadd371510 fma 1 1.123456789987654321123456789012345 0E-10 -> 1.123456789987654321123456789012345
+dqadd371511 fma 1 1.123456789987654321123456789012345 0E-11 -> 1.123456789987654321123456789012345
+dqadd371512 fma 1 1.123456789987654321123456789012345 0E-12 -> 1.123456789987654321123456789012345
+dqadd371513 fma 1 1.123456789987654321123456789012345 0E-13 -> 1.123456789987654321123456789012345
+dqadd371514 fma 1 1.123456789987654321123456789012345 0E-14 -> 1.123456789987654321123456789012345
+dqadd371515 fma 1 1.123456789987654321123456789012345 0E-15 -> 1.123456789987654321123456789012345
+dqadd371516 fma 1 1.123456789987654321123456789012345 0E-16 -> 1.123456789987654321123456789012345
+dqadd371517 fma 1 1.123456789987654321123456789012345 0E-17 -> 1.123456789987654321123456789012345
+dqadd371518 fma 1 1.123456789987654321123456789012345 0E-18 -> 1.123456789987654321123456789012345
+dqadd371519 fma 1 1.123456789987654321123456789012345 0E-19 -> 1.123456789987654321123456789012345
+dqadd371520 fma 1 1.123456789987654321123456789012345 0E-20 -> 1.123456789987654321123456789012345
+dqadd371521 fma 1 1.123456789987654321123456789012345 0E-21 -> 1.123456789987654321123456789012345
+dqadd371522 fma 1 1.123456789987654321123456789012345 0E-22 -> 1.123456789987654321123456789012345
+dqadd371523 fma 1 1.123456789987654321123456789012345 0E-23 -> 1.123456789987654321123456789012345
+dqadd371524 fma 1 1.123456789987654321123456789012345 0E-24 -> 1.123456789987654321123456789012345
+dqadd371525 fma 1 1.123456789987654321123456789012345 0E-25 -> 1.123456789987654321123456789012345
+dqadd371526 fma 1 1.123456789987654321123456789012345 0E-26 -> 1.123456789987654321123456789012345
+dqadd371527 fma 1 1.123456789987654321123456789012345 0E-27 -> 1.123456789987654321123456789012345
+dqadd371528 fma 1 1.123456789987654321123456789012345 0E-28 -> 1.123456789987654321123456789012345
+dqadd371529 fma 1 1.123456789987654321123456789012345 0E-29 -> 1.123456789987654321123456789012345
+dqadd371530 fma 1 1.123456789987654321123456789012345 0E-30 -> 1.123456789987654321123456789012345
+dqadd371531 fma 1 1.123456789987654321123456789012345 0E-31 -> 1.123456789987654321123456789012345
+dqadd371532 fma 1 1.123456789987654321123456789012345 0E-32 -> 1.123456789987654321123456789012345
+dqadd371533 fma 1 1.123456789987654321123456789012345 0E-33 -> 1.123456789987654321123456789012345
+-- next four flag Rounded because the 0 extends the result
+dqadd371534 fma 1 1.123456789987654321123456789012345 0E-34 -> 1.123456789987654321123456789012345 Rounded
+dqadd371535 fma 1 1.123456789987654321123456789012345 0E-35 -> 1.123456789987654321123456789012345 Rounded
+dqadd371536 fma 1 1.123456789987654321123456789012345 0E-36 -> 1.123456789987654321123456789012345 Rounded
+dqadd371537 fma 1 1.123456789987654321123456789012345 0E-37 -> 1.123456789987654321123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+dqadd371600 fma 1 0 0E-19 -> 0E-19
+dqadd371601 fma 1 -0 0E-19 -> 0E-19
+dqadd371602 fma 1 0 -0E-19 -> 0E-19
+dqadd371603 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371611 fma 1 -11 11 -> 0
+dqadd371612 fma 1 11 -11 -> 0
+-- overflow
+dqadd371613 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371614 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: half_down
+-- exact zeros from zeros
+dqadd371620 fma 1 0 0E-19 -> 0E-19
+dqadd371621 fma 1 -0 0E-19 -> 0E-19
+dqadd371622 fma 1 0 -0E-19 -> 0E-19
+dqadd371623 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371631 fma 1 -11 11 -> 0
+dqadd371632 fma 1 11 -11 -> 0
+-- overflow
+dqadd371633 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371634 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: half_even
+-- exact zeros from zeros
+dqadd371640 fma 1 0 0E-19 -> 0E-19
+dqadd371641 fma 1 -0 0E-19 -> 0E-19
+dqadd371642 fma 1 0 -0E-19 -> 0E-19
+dqadd371643 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371651 fma 1 -11 11 -> 0
+dqadd371652 fma 1 11 -11 -> 0
+-- overflow
+dqadd371653 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371654 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: up
+-- exact zeros from zeros
+dqadd371660 fma 1 0 0E-19 -> 0E-19
+dqadd371661 fma 1 -0 0E-19 -> 0E-19
+dqadd371662 fma 1 0 -0E-19 -> 0E-19
+dqadd371663 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371671 fma 1 -11 11 -> 0
+dqadd371672 fma 1 11 -11 -> 0
+-- overflow
+dqadd371673 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371674 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: down
+-- exact zeros from zeros
+dqadd371680 fma 1 0 0E-19 -> 0E-19
+dqadd371681 fma 1 -0 0E-19 -> 0E-19
+dqadd371682 fma 1 0 -0E-19 -> 0E-19
+dqadd371683 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371691 fma 1 -11 11 -> 0
+dqadd371692 fma 1 11 -11 -> 0
+-- overflow
+dqadd371693 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqadd371694 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+
+rounding: ceiling
+-- exact zeros from zeros
+dqadd371700 fma 1 0 0E-19 -> 0E-19
+dqadd371701 fma 1 -0 0E-19 -> 0E-19
+dqadd371702 fma 1 0 -0E-19 -> 0E-19
+dqadd371703 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371711 fma 1 -11 11 -> 0
+dqadd371712 fma 1 11 -11 -> 0
+-- overflow
+dqadd371713 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371714 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+dqadd371720 fma 1 0 0E-19 -> 0E-19
+dqadd371721 fma 1 -0 0E-19 -> -0E-19 -- *
+dqadd371722 fma 1 0 -0E-19 -> -0E-19 -- *
+dqadd371723 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371731 fma 1 -11 11 -> -0 -- *
+dqadd371732 fma 1 11 -11 -> -0 -- *
+-- overflow
+dqadd371733 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqadd371734 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: 05up
+-- exact zeros from zeros
+dqadd371740 fma 1 0 0E-19 -> 0E-19
+dqadd371741 fma 1 -0 0E-19 -> 0E-19
+dqadd371742 fma 1 0 -0E-19 -> 0E-19
+dqadd371743 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371751 fma 1 -11 11 -> 0
+dqadd371752 fma 1 11 -11 -> 0
+-- overflow
+dqadd371753 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqadd371754 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dqadd371761 fma 1 130E-2 120E-2 -> 2.50
+dqadd371762 fma 1 130E-2 12E-1 -> 2.50
+dqadd371763 fma 1 130E-2 1E0 -> 2.30
+dqadd371764 fma 1 1E2 1E4 -> 1.01E+4
+dqadd371765 fma 1 130E-2 -120E-2 -> 0.10
+dqadd371766 fma 1 130E-2 -12E-1 -> 0.10
+dqadd371767 fma 1 130E-2 -1E0 -> 0.30
+dqadd371768 fma 1 1E2 -1E4 -> -9.9E+3
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+dqadd375001 fma 1 1239876543211234567894567890123456 1 -> 1239876543211234567894567890123457
+dqadd375002 fma 1 1239876543211234567894567890123456 0.6 -> 1239876543211234567894567890123457 Inexact Rounded
+dqadd375003 fma 1 1239876543211234567894567890123456 0.06 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375004 fma 1 1239876543211234567894567890123456 6E-3 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375005 fma 1 1239876543211234567894567890123456 6E-4 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375006 fma 1 1239876543211234567894567890123456 6E-5 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375007 fma 1 1239876543211234567894567890123456 6E-6 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375008 fma 1 1239876543211234567894567890123456 6E-7 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375009 fma 1 1239876543211234567894567890123456 6E-8 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375010 fma 1 1239876543211234567894567890123456 6E-9 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375011 fma 1 1239876543211234567894567890123456 6E-10 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375012 fma 1 1239876543211234567894567890123456 6E-11 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375013 fma 1 1239876543211234567894567890123456 6E-12 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375014 fma 1 1239876543211234567894567890123456 6E-13 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375015 fma 1 1239876543211234567894567890123456 6E-14 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375016 fma 1 1239876543211234567894567890123456 6E-15 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375017 fma 1 1239876543211234567894567890123456 6E-16 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375018 fma 1 1239876543211234567894567890123456 6E-17 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375019 fma 1 1239876543211234567894567890123456 6E-18 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375020 fma 1 1239876543211234567894567890123456 6E-19 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375021 fma 1 1239876543211234567894567890123456 6E-20 -> 1239876543211234567894567890123456 Inexact Rounded
+
+-- widening second argument at gap
+dqadd375030 fma 1 12398765432112345678945678 1 -> 12398765432112345678945679
+dqadd375031 fma 1 12398765432112345678945678 0.1 -> 12398765432112345678945678.1
+dqadd375032 fma 1 12398765432112345678945678 0.12 -> 12398765432112345678945678.12
+dqadd375033 fma 1 12398765432112345678945678 0.123 -> 12398765432112345678945678.123
+dqadd375034 fma 1 12398765432112345678945678 0.1234 -> 12398765432112345678945678.1234
+dqadd375035 fma 1 12398765432112345678945678 0.12345 -> 12398765432112345678945678.12345
+dqadd375036 fma 1 12398765432112345678945678 0.123456 -> 12398765432112345678945678.123456
+dqadd375037 fma 1 12398765432112345678945678 0.1234567 -> 12398765432112345678945678.1234567
+dqadd375038 fma 1 12398765432112345678945678 0.12345678 -> 12398765432112345678945678.12345678
+dqadd375039 fma 1 12398765432112345678945678 0.123456789 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375040 fma 1 12398765432112345678945678 0.123456785 -> 12398765432112345678945678.12345678 Inexact Rounded
+dqadd375041 fma 1 12398765432112345678945678 0.1234567850 -> 12398765432112345678945678.12345678 Inexact Rounded
+dqadd375042 fma 1 12398765432112345678945678 0.1234567851 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375043 fma 1 12398765432112345678945678 0.12345678501 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375044 fma 1 12398765432112345678945678 0.123456785001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375045 fma 1 12398765432112345678945678 0.1234567850001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375046 fma 1 12398765432112345678945678 0.12345678500001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375047 fma 1 12398765432112345678945678 0.123456785000001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375048 fma 1 12398765432112345678945678 0.1234567850000001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375049 fma 1 12398765432112345678945678 0.1234567850000000 -> 12398765432112345678945678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+dqadd375050 fma 1 12398765432112345678945678 0.0234567750000000 -> 12398765432112345678945678.02345678 Inexact Rounded
+dqadd375051 fma 1 12398765432112345678945678 0.0034567750000000 -> 12398765432112345678945678.00345678 Inexact Rounded
+dqadd375052 fma 1 12398765432112345678945678 0.0004567750000000 -> 12398765432112345678945678.00045678 Inexact Rounded
+dqadd375053 fma 1 12398765432112345678945678 0.0000567750000000 -> 12398765432112345678945678.00005678 Inexact Rounded
+dqadd375054 fma 1 12398765432112345678945678 0.0000067750000000 -> 12398765432112345678945678.00000678 Inexact Rounded
+dqadd375055 fma 1 12398765432112345678945678 0.0000007750000000 -> 12398765432112345678945678.00000078 Inexact Rounded
+dqadd375056 fma 1 12398765432112345678945678 0.0000000750000000 -> 12398765432112345678945678.00000008 Inexact Rounded
+dqadd375057 fma 1 12398765432112345678945678 0.0000000050000000 -> 12398765432112345678945678.00000000 Inexact Rounded
+dqadd375060 fma 1 12398765432112345678945678 0.0234567750000001 -> 12398765432112345678945678.02345678 Inexact Rounded
+dqadd375061 fma 1 12398765432112345678945678 0.0034567750000001 -> 12398765432112345678945678.00345678 Inexact Rounded
+dqadd375062 fma 1 12398765432112345678945678 0.0004567750000001 -> 12398765432112345678945678.00045678 Inexact Rounded
+dqadd375063 fma 1 12398765432112345678945678 0.0000567750000001 -> 12398765432112345678945678.00005678 Inexact Rounded
+dqadd375064 fma 1 12398765432112345678945678 0.0000067750000001 -> 12398765432112345678945678.00000678 Inexact Rounded
+dqadd375065 fma 1 12398765432112345678945678 0.0000007750000001 -> 12398765432112345678945678.00000078 Inexact Rounded
+dqadd375066 fma 1 12398765432112345678945678 0.0000000750000001 -> 12398765432112345678945678.00000008 Inexact Rounded
+dqadd375067 fma 1 12398765432112345678945678 0.0000000050000001 -> 12398765432112345678945678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+dqadd375070 fma 1 12398765432112345678945678 1E-8 -> 12398765432112345678945678.00000001
+dqadd375071 fma 1 12398765432112345678945678 1E-9 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375072 fma 1 12398765432112345678945678 1E-10 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375073 fma 1 12398765432112345678945678 1E-11 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375074 fma 1 12398765432112345678945678 1E-12 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375075 fma 1 12398765432112345678945678 1E-13 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375076 fma 1 12398765432112345678945678 1E-14 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375077 fma 1 12398765432112345678945678 1E-15 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375078 fma 1 12398765432112345678945678 1E-16 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375079 fma 1 12398765432112345678945678 1E-17 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375080 fma 1 12398765432112345678945678 1E-18 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375081 fma 1 12398765432112345678945678 1E-19 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375082 fma 1 12398765432112345678945678 1E-20 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375083 fma 1 12398765432112345678945678 1E-25 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375084 fma 1 12398765432112345678945678 1E-30 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375085 fma 1 12398765432112345678945678 1E-31 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375086 fma 1 12398765432112345678945678 1E-32 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375087 fma 1 12398765432112345678945678 1E-33 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375088 fma 1 12398765432112345678945678 1E-34 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375089 fma 1 12398765432112345678945678 1E-35 -> 12398765432112345678945678.00000001 Inexact Rounded
+
+-- Destructive subtract (from remainder tests)
+
+-- +++ some of these will be off-by-one remainder vs remainderNear
+
+dqfma4000 fma -1234567890123456789012345678901233 1.000000000000000000000000000000001 1234567890123456789012345678901234 -> -0.234567890123456789012345678901233
+dqfma4001 fma -1234567890123456789012345678901222 1.00000000000000000000000000000001 1234567890123456789012345678901234 -> -0.34567890123456789012345678901222
+dqfma4002 fma -1234567890123456789012345678901111 1.0000000000000000000000000000001 1234567890123456789012345678901234 -> -0.4567890123456789012345678901111
+dqfma4003 fma -308641972530864197253086419725314 4.000000000000000000000000000000001 1234567890123456789012345678901255 -> -1.308641972530864197253086419725314
+dqfma4004 fma -308641972530864197253086419725308 4.000000000000000000000000000000001 1234567890123456789012345678901234 -> 1.691358027469135802746913580274692
+dqfma4005 fma -246913578024691357802469135780252 4.9999999999999999999999999999999 1234567890123456789012345678901234 -> -1.3086421975308642197530864219748
+dqfma4006 fma -246913578024691357802469135780247 4.99999999999999999999999999999999 1234567890123456789012345678901234 -> 1.46913578024691357802469135780247
+dqfma4007 fma -246913578024691357802469135780247 4.999999999999999999999999999999999 1234567890123456789012345678901234 -> -0.753086421975308642197530864219753
+dqfma4008 fma -246913578024691357802469135780247 5.000000000000000000000000000000001 1234567890123456789012345678901234 -> -1.246913578024691357802469135780247
+dqfma4009 fma -246913578024691357802469135780246 5.00000000000000000000000000000001 1234567890123456789012345678901234 -> 1.53086421975308642197530864219754
+dqfma4010 fma -246913578024691357802469135780242 5.0000000000000000000000000000001 1234567890123456789012345678901234 -> -0.6913578024691357802469135780242
+dqfma4011 fma -1234567890123456789012345678901232 1.000000000000000000000000000000001 1234567890123456789012345678901234 -> 0.765432109876543210987654321098768
+dqfma4012 fma -1234567890123456789012345678901221 1.00000000000000000000000000000001 1234567890123456789012345678901234 -> 0.65432109876543210987654321098779
+dqfma4013 fma -1234567890123456789012345678901110 1.0000000000000000000000000000001 1234567890123456789012345678901234 -> 0.5432109876543210987654321098890
+dqfma4014 fma -308641972530864197253086419725313 4.000000000000000000000000000000001 1234567890123456789012345678901255 -> 2.691358027469135802746913580274687
+dqfma4015 fma -308641972530864197253086419725308 4.000000000000000000000000000000001 1234567890123456789012345678901234 -> 1.691358027469135802746913580274692
+dqfma4016 fma -246913578024691357802469135780251 4.9999999999999999999999999999999 1234567890123456789012345678901234 -> 3.6913578024691357802469135780251
+dqfma4017 fma -246913578024691357802469135780247 4.99999999999999999999999999999999 1234567890123456789012345678901234 -> 1.46913578024691357802469135780247
+dqfma4018 fma -246913578024691357802469135780246 4.999999999999999999999999999999999 1234567890123456789012345678901234 -> 4.246913578024691357802469135780246
+dqfma4019 fma -246913578024691357802469135780241 5.0000000000000000000000000000001 1234567890123456789012345678901234 -> 4.3086421975308642197530864219759
+
+-- Null tests
+dqadd39990 fma 1 10 # -> NaN Invalid_operation
+dqadd39991 fma 1 # 10 -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/dqInvert.decTest b/Lib/test/decimaltestdata/dqInvert.decTest
index 522cfc80f0..3a1e29e21d 100644
--- a/Lib/test/decimaltestdata/dqInvert.decTest
+++ b/Lib/test/decimaltestdata/dqInvert.decTest
@@ -1,245 +1,245 @@
-------------------------------------------------------------------------
--- dqInvert.decTest -- digitwise logical INVERT for decQuads --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check (truth table)
-dqinv001 invert 0 -> 1111111111111111111111111111111111
-dqinv002 invert 1 -> 1111111111111111111111111111111110
-dqinv003 invert 10 -> 1111111111111111111111111111111101
-dqinv004 invert 111111111 -> 1111111111111111111111111000000000
-dqinv005 invert 000000000 -> 1111111111111111111111111111111111
--- and at msd and msd-1
-dqinv007 invert 0000000000000000000000000000000000 -> 1111111111111111111111111111111111
-dqinv008 invert 1000000000000000000000000000000000 -> 111111111111111111111111111111111
-dqinv009 invert 0000000000000000000000000000000000 -> 1111111111111111111111111111111111
-dqinv010 invert 0100000000000000000000000000000000 -> 1011111111111111111111111111111111
-dqinv011 invert 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
-dqinv012 invert 1111111111111111111111111111111111 -> 0
-dqinv013 invert 0011111111111111111111111111111111 -> 1100000000000000000000000000000000
-dqinv014 invert 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
-
--- Various lengths
-dqinv600 invert 0111111111111111111011111111111111 -> 1000000000000000000100000000000000
-dqinv601 invert 0011111111111111110101111111111111 -> 1100000000000000001010000000000000
-dqinv602 invert 0101111111111111101110111111111111 -> 1010000000000000010001000000000000
-dqinv603 invert 0110111111111111011111011111111111 -> 1001000000000000100000100000000000
-dqinv604 invert 0111011111111110111111101111111111 -> 1000100000000001000000010000000000
-dqinv605 invert 0111101111111101111111110111111111 -> 1000010000000010000000001000000000
-dqinv606 invert 0111110111111011111111111011111111 -> 1000001000000100000000000100000000
-dqinv607 invert 0111111011110111111111111101111111 -> 1000000100001000000000000010000000
-dqinv608 invert 0111111101101111111111111110111111 -> 1000000010010000000000000001000000
-dqinv609 invert 0111111110011111111111111111011111 -> 1000000001100000000000000000100000
-dqinv610 invert 0111111110011111111111111111101111 -> 1000000001100000000000000000010000
-dqinv611 invert 0111111101101111111111111111110111 -> 1000000010010000000000000000001000
-dqinv612 invert 0111111011110111111111111111111011 -> 1000000100001000000000000000000100
-dqinv613 invert 0111110111111011111111111111111101 -> 1000001000000100000000000000000010
-dqinv614 invert 0111101111111101111111111111111110 -> 1000010000000010000000000000000001
-dqinv615 invert 0111011111111110111111111111111111 -> 1000100000000001000000000000000000
-dqinv616 invert 0110111111111111011111111111111110 -> 1001000000000000100000000000000001
-dqinv617 invert 0101111111111111101111111111111101 -> 1010000000000000010000000000000010
-dqinv618 invert 0011111111111111110111111111111011 -> 1100000000000000001000000000000100
-dqinv619 invert 0101111111111111111011111111110111 -> 1010000000000000000100000000001000
-dqinv620 invert 0110111111111111111101111111101111 -> 1001000000000000000010000000010000
-dqinv621 invert 0111011111111111111110111111011111 -> 1000100000000000000001000000100000
-dqinv622 invert 0111101111111111111111011110111111 -> 1000010000000000000000100001000000
-dqinv623 invert 0111110111111111111111101101111111 -> 1000001000000000000000010010000000
-dqinv624 invert 0111111011111111111111110011111111 -> 1000000100000000000000001100000000
-dqinv625 invert 0111111101111111111111110011111111 -> 1000000010000000000000001100000000
-dqinv626 invert 0111111110111111111111101101111111 -> 1000000001000000000000010010000000
-dqinv627 invert 0111111111011111111111011110111111 -> 1000000000100000000000100001000000
-dqinv628 invert 0111111111101111111110111111011111 -> 1000000000010000000001000000100000
-dqinv629 invert 0111111111110111111101111111101111 -> 1000000000001000000010000000010000
-dqinv630 invert 0111111111111011111011111111110111 -> 1000000000000100000100000000001000
-dqinv631 invert 0111111111111101110111111111111011 -> 1000000000000010001000000000000100
-dqinv632 invert 0111111111111110101111111111111101 -> 1000000000000001010000000000000010
-dqinv633 invert 0111111111111111011111111111111110 -> 1000000000000000100000000000000001
-
-dqinv021 invert 111111111 -> 1111111111111111111111111000000000
-dqinv022 invert 111111111111 -> 1111111111111111111111000000000000
-dqinv023 invert 11111111 -> 1111111111111111111111111100000000
-dqinv025 invert 1111111 -> 1111111111111111111111111110000000
-dqinv026 invert 111111 -> 1111111111111111111111111111000000
-dqinv027 invert 11111 -> 1111111111111111111111111111100000
-dqinv028 invert 1111 -> 1111111111111111111111111111110000
-dqinv029 invert 111 -> 1111111111111111111111111111111000
-dqinv031 invert 11 -> 1111111111111111111111111111111100
-dqinv032 invert 1 -> 1111111111111111111111111111111110
-dqinv033 invert 111111111111 -> 1111111111111111111111000000000000
-dqinv034 invert 11111111111 -> 1111111111111111111111100000000000
-dqinv035 invert 1111111111 -> 1111111111111111111111110000000000
-dqinv036 invert 111111111 -> 1111111111111111111111111000000000
-
-dqinv040 invert 011111111 -> 1111111111111111111111111100000000
-dqinv041 invert 101111111 -> 1111111111111111111111111010000000
-dqinv042 invert 110111111 -> 1111111111111111111111111001000000
-dqinv043 invert 111011111 -> 1111111111111111111111111000100000
-dqinv044 invert 111101111 -> 1111111111111111111111111000010000
-dqinv045 invert 111110111 -> 1111111111111111111111111000001000
-dqinv046 invert 111111011 -> 1111111111111111111111111000000100
-dqinv047 invert 111111101 -> 1111111111111111111111111000000010
-dqinv048 invert 111111110 -> 1111111111111111111111111000000001
-dqinv049 invert 011111011 -> 1111111111111111111111111100000100
-dqinv050 invert 101111101 -> 1111111111111111111111111010000010
-dqinv051 invert 110111110 -> 1111111111111111111111111001000001
-dqinv052 invert 111011101 -> 1111111111111111111111111000100010
-dqinv053 invert 111101011 -> 1111111111111111111111111000010100
-dqinv054 invert 111110111 -> 1111111111111111111111111000001000
-dqinv055 invert 111101011 -> 1111111111111111111111111000010100
-dqinv056 invert 111011101 -> 1111111111111111111111111000100010
-dqinv057 invert 110111110 -> 1111111111111111111111111001000001
-dqinv058 invert 101111101 -> 1111111111111111111111111010000010
-dqinv059 invert 011111011 -> 1111111111111111111111111100000100
-
-dqinv080 invert 1000000011111111 -> 1111111111111111110111111100000000
-dqinv081 invert 0100000101111111 -> 1111111111111111111011111010000000
-dqinv082 invert 0010000110111111 -> 1111111111111111111101111001000000
-dqinv083 invert 0001000111011111 -> 1111111111111111111110111000100000
-dqinv084 invert 0000100111101111 -> 1111111111111111111111011000010000
-dqinv085 invert 0000010111110111 -> 1111111111111111111111101000001000
-dqinv086 invert 0000001111111011 -> 1111111111111111111111110000000100
-dqinv087 invert 0000010111111101 -> 1111111111111111111111101000000010
-dqinv088 invert 0000100111111110 -> 1111111111111111111111011000000001
-dqinv089 invert 0001000011111011 -> 1111111111111111111110111100000100
-dqinv090 invert 0010000101111101 -> 1111111111111111111101111010000010
-dqinv091 invert 0100000110111110 -> 1111111111111111111011111001000001
-dqinv092 invert 1000000111011101 -> 1111111111111111110111111000100010
-dqinv093 invert 0100000111101011 -> 1111111111111111111011111000010100
-dqinv094 invert 0010000111110111 -> 1111111111111111111101111000001000
-dqinv095 invert 0001000111101011 -> 1111111111111111111110111000010100
-dqinv096 invert 0000100111011101 -> 1111111111111111111111011000100010
-dqinv097 invert 0000010110111110 -> 1111111111111111111111101001000001
-dqinv098 invert 0000001101111101 -> 1111111111111111111111110010000010
-dqinv099 invert 0000010011111011 -> 1111111111111111111111101100000100
-
--- and more thorough MSD/LSD tests [8 and 9 mght be encoded differently...]
-dqinv151 invert 1111111111111111111111111111111110 -> 1
-dqinv152 invert 1111111111111111110000000000000000 -> 1111111111111111
-dqinv153 invert 1000000000000000001111111111111111 -> 111111111111111110000000000000000
-dqinv154 invert 1111111111111111111000000000000000 -> 111111111111111
-dqinv155 invert 0100000000000000000111111111111111 -> 1011111111111111111000000000000000
-dqinv156 invert 1011111111111111110100000000000000 -> 100000000000000001011111111111111
-dqinv157 invert 1101111111111111110111111111111111 -> 10000000000000001000000000000000
-dqinv158 invert 1110111111111111110011111111111111 -> 1000000000000001100000000000000
-
--- non-0/1 should not be accepted, nor should signs
-dqinv220 invert 111111112 -> NaN Invalid_operation
-dqinv221 invert 333333333 -> NaN Invalid_operation
-dqinv222 invert 555555555 -> NaN Invalid_operation
-dqinv223 invert 777777777 -> NaN Invalid_operation
-dqinv224 invert 999999999 -> NaN Invalid_operation
-dqinv225 invert 222222222 -> NaN Invalid_operation
-dqinv226 invert 444444444 -> NaN Invalid_operation
-dqinv227 invert 666666666 -> NaN Invalid_operation
-dqinv228 invert 888888888 -> NaN Invalid_operation
-dqinv229 invert 999999999 -> NaN Invalid_operation
-dqinv230 invert 999999999 -> NaN Invalid_operation
-dqinv231 invert 999999999 -> NaN Invalid_operation
-dqinv232 invert 999999999 -> NaN Invalid_operation
--- a few randoms
-dqinv240 invert 567468689 -> NaN Invalid_operation
-dqinv241 invert 567367689 -> NaN Invalid_operation
-dqinv242 invert -631917772 -> NaN Invalid_operation
-dqinv243 invert -756253257 -> NaN Invalid_operation
-dqinv244 invert 835590149 -> NaN Invalid_operation
--- test MSD
-dqinv250 invert 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv251 invert 3000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv252 invert 4000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv253 invert 5000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv254 invert 6000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv255 invert 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv256 invert 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv257 invert 9000000111000111000111000000000000 -> NaN Invalid_operation
--- test MSD-1
-dqinv270 invert 0200000111000111000111001000000000 -> NaN Invalid_operation
-dqinv271 invert 0300000111000111000111000100000000 -> NaN Invalid_operation
-dqinv272 invert 0400000111000111000111000010000000 -> NaN Invalid_operation
-dqinv273 invert 0500000111000111000111000001000000 -> NaN Invalid_operation
-dqinv274 invert 1600000111000111000111000000100000 -> NaN Invalid_operation
-dqinv275 invert 1700000111000111000111000000010000 -> NaN Invalid_operation
-dqinv276 invert 1800000111000111000111000000001000 -> NaN Invalid_operation
-dqinv277 invert 1900000111000111000111000000000100 -> NaN Invalid_operation
--- test LSD
-dqinv280 invert 0010000111000111000111000000000002 -> NaN Invalid_operation
-dqinv281 invert 0001000111000111000111000000000003 -> NaN Invalid_operation
-dqinv282 invert 0000000111000111000111100000000004 -> NaN Invalid_operation
-dqinv283 invert 0000000111000111000111010000000005 -> NaN Invalid_operation
-dqinv284 invert 1000000111000111000111001000000006 -> NaN Invalid_operation
-dqinv285 invert 1000000111000111000111000100000007 -> NaN Invalid_operation
-dqinv286 invert 1000000111000111000111000010000008 -> NaN Invalid_operation
-dqinv287 invert 1000000111000111000111000001000009 -> NaN Invalid_operation
--- test Middie
-dqinv288 invert 0010000111000111000111000020000000 -> NaN Invalid_operation
-dqinv289 invert 0001000111000111000111000030000001 -> NaN Invalid_operation
-dqinv290 invert 0000000111000111000111100040000010 -> NaN Invalid_operation
-dqinv291 invert 0000000111000111000111010050000100 -> NaN Invalid_operation
-dqinv292 invert 1000000111000111000111001060001000 -> NaN Invalid_operation
-dqinv293 invert 1000000111000111000111000170010000 -> NaN Invalid_operation
-dqinv294 invert 1000000111000111000111000080100000 -> NaN Invalid_operation
-dqinv295 invert 1000000111000111000111000091000000 -> NaN Invalid_operation
--- signs
-dqinv296 invert -1000000111000111000111000001000000 -> NaN Invalid_operation
-dqinv299 invert 1000000111000111000111000001000000 -> 111111000111000111000111110111111
-
--- Nmax, Nmin, Ntiny-like
-dqinv341 invert 9.99999999E+2998 -> NaN Invalid_operation
-dqinv342 invert 1E-2998 -> NaN Invalid_operation
-dqinv343 invert 1.00000000E-2998 -> NaN Invalid_operation
-dqinv344 invert 1E-2078 -> NaN Invalid_operation
-dqinv345 invert -1E-2078 -> NaN Invalid_operation
-dqinv346 invert -1.00000000E-2998 -> NaN Invalid_operation
-dqinv347 invert -1E-2998 -> NaN Invalid_operation
-dqinv348 invert -9.99999999E+2998 -> NaN Invalid_operation
-
--- A few other non-integers
-dqinv361 invert 1.0 -> NaN Invalid_operation
-dqinv362 invert 1E+1 -> NaN Invalid_operation
-dqinv363 invert 0.0 -> NaN Invalid_operation
-dqinv364 invert 0E+1 -> NaN Invalid_operation
-dqinv365 invert 9.9 -> NaN Invalid_operation
-dqinv366 invert 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-dqinv788 invert -Inf -> NaN Invalid_operation
-dqinv794 invert Inf -> NaN Invalid_operation
-dqinv821 invert NaN -> NaN Invalid_operation
-dqinv841 invert sNaN -> NaN Invalid_operation
--- propagating NaNs
-dqinv861 invert NaN1 -> NaN Invalid_operation
-dqinv862 invert +NaN2 -> NaN Invalid_operation
-dqinv863 invert NaN3 -> NaN Invalid_operation
-dqinv864 invert NaN4 -> NaN Invalid_operation
-dqinv865 invert NaN5 -> NaN Invalid_operation
-dqinv871 invert sNaN11 -> NaN Invalid_operation
-dqinv872 invert sNaN12 -> NaN Invalid_operation
-dqinv873 invert sNaN13 -> NaN Invalid_operation
-dqinv874 invert sNaN14 -> NaN Invalid_operation
-dqinv875 invert sNaN15 -> NaN Invalid_operation
-dqinv876 invert NaN16 -> NaN Invalid_operation
-dqinv881 invert +NaN25 -> NaN Invalid_operation
-dqinv882 invert -NaN26 -> NaN Invalid_operation
-dqinv883 invert -sNaN27 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqInvert.decTest -- digitwise logical INVERT for decQuads --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check (truth table)
+dqinv001 invert 0 -> 1111111111111111111111111111111111
+dqinv002 invert 1 -> 1111111111111111111111111111111110
+dqinv003 invert 10 -> 1111111111111111111111111111111101
+dqinv004 invert 111111111 -> 1111111111111111111111111000000000
+dqinv005 invert 000000000 -> 1111111111111111111111111111111111
+-- and at msd and msd-1
+dqinv007 invert 0000000000000000000000000000000000 -> 1111111111111111111111111111111111
+dqinv008 invert 1000000000000000000000000000000000 -> 111111111111111111111111111111111
+dqinv009 invert 0000000000000000000000000000000000 -> 1111111111111111111111111111111111
+dqinv010 invert 0100000000000000000000000000000000 -> 1011111111111111111111111111111111
+dqinv011 invert 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
+dqinv012 invert 1111111111111111111111111111111111 -> 0
+dqinv013 invert 0011111111111111111111111111111111 -> 1100000000000000000000000000000000
+dqinv014 invert 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
+
+-- Various lengths
+dqinv600 invert 0111111111111111111011111111111111 -> 1000000000000000000100000000000000
+dqinv601 invert 0011111111111111110101111111111111 -> 1100000000000000001010000000000000
+dqinv602 invert 0101111111111111101110111111111111 -> 1010000000000000010001000000000000
+dqinv603 invert 0110111111111111011111011111111111 -> 1001000000000000100000100000000000
+dqinv604 invert 0111011111111110111111101111111111 -> 1000100000000001000000010000000000
+dqinv605 invert 0111101111111101111111110111111111 -> 1000010000000010000000001000000000
+dqinv606 invert 0111110111111011111111111011111111 -> 1000001000000100000000000100000000
+dqinv607 invert 0111111011110111111111111101111111 -> 1000000100001000000000000010000000
+dqinv608 invert 0111111101101111111111111110111111 -> 1000000010010000000000000001000000
+dqinv609 invert 0111111110011111111111111111011111 -> 1000000001100000000000000000100000
+dqinv610 invert 0111111110011111111111111111101111 -> 1000000001100000000000000000010000
+dqinv611 invert 0111111101101111111111111111110111 -> 1000000010010000000000000000001000
+dqinv612 invert 0111111011110111111111111111111011 -> 1000000100001000000000000000000100
+dqinv613 invert 0111110111111011111111111111111101 -> 1000001000000100000000000000000010
+dqinv614 invert 0111101111111101111111111111111110 -> 1000010000000010000000000000000001
+dqinv615 invert 0111011111111110111111111111111111 -> 1000100000000001000000000000000000
+dqinv616 invert 0110111111111111011111111111111110 -> 1001000000000000100000000000000001
+dqinv617 invert 0101111111111111101111111111111101 -> 1010000000000000010000000000000010
+dqinv618 invert 0011111111111111110111111111111011 -> 1100000000000000001000000000000100
+dqinv619 invert 0101111111111111111011111111110111 -> 1010000000000000000100000000001000
+dqinv620 invert 0110111111111111111101111111101111 -> 1001000000000000000010000000010000
+dqinv621 invert 0111011111111111111110111111011111 -> 1000100000000000000001000000100000
+dqinv622 invert 0111101111111111111111011110111111 -> 1000010000000000000000100001000000
+dqinv623 invert 0111110111111111111111101101111111 -> 1000001000000000000000010010000000
+dqinv624 invert 0111111011111111111111110011111111 -> 1000000100000000000000001100000000
+dqinv625 invert 0111111101111111111111110011111111 -> 1000000010000000000000001100000000
+dqinv626 invert 0111111110111111111111101101111111 -> 1000000001000000000000010010000000
+dqinv627 invert 0111111111011111111111011110111111 -> 1000000000100000000000100001000000
+dqinv628 invert 0111111111101111111110111111011111 -> 1000000000010000000001000000100000
+dqinv629 invert 0111111111110111111101111111101111 -> 1000000000001000000010000000010000
+dqinv630 invert 0111111111111011111011111111110111 -> 1000000000000100000100000000001000
+dqinv631 invert 0111111111111101110111111111111011 -> 1000000000000010001000000000000100
+dqinv632 invert 0111111111111110101111111111111101 -> 1000000000000001010000000000000010
+dqinv633 invert 0111111111111111011111111111111110 -> 1000000000000000100000000000000001
+
+dqinv021 invert 111111111 -> 1111111111111111111111111000000000
+dqinv022 invert 111111111111 -> 1111111111111111111111000000000000
+dqinv023 invert 11111111 -> 1111111111111111111111111100000000
+dqinv025 invert 1111111 -> 1111111111111111111111111110000000
+dqinv026 invert 111111 -> 1111111111111111111111111111000000
+dqinv027 invert 11111 -> 1111111111111111111111111111100000
+dqinv028 invert 1111 -> 1111111111111111111111111111110000
+dqinv029 invert 111 -> 1111111111111111111111111111111000
+dqinv031 invert 11 -> 1111111111111111111111111111111100
+dqinv032 invert 1 -> 1111111111111111111111111111111110
+dqinv033 invert 111111111111 -> 1111111111111111111111000000000000
+dqinv034 invert 11111111111 -> 1111111111111111111111100000000000
+dqinv035 invert 1111111111 -> 1111111111111111111111110000000000
+dqinv036 invert 111111111 -> 1111111111111111111111111000000000
+
+dqinv040 invert 011111111 -> 1111111111111111111111111100000000
+dqinv041 invert 101111111 -> 1111111111111111111111111010000000
+dqinv042 invert 110111111 -> 1111111111111111111111111001000000
+dqinv043 invert 111011111 -> 1111111111111111111111111000100000
+dqinv044 invert 111101111 -> 1111111111111111111111111000010000
+dqinv045 invert 111110111 -> 1111111111111111111111111000001000
+dqinv046 invert 111111011 -> 1111111111111111111111111000000100
+dqinv047 invert 111111101 -> 1111111111111111111111111000000010
+dqinv048 invert 111111110 -> 1111111111111111111111111000000001
+dqinv049 invert 011111011 -> 1111111111111111111111111100000100
+dqinv050 invert 101111101 -> 1111111111111111111111111010000010
+dqinv051 invert 110111110 -> 1111111111111111111111111001000001
+dqinv052 invert 111011101 -> 1111111111111111111111111000100010
+dqinv053 invert 111101011 -> 1111111111111111111111111000010100
+dqinv054 invert 111110111 -> 1111111111111111111111111000001000
+dqinv055 invert 111101011 -> 1111111111111111111111111000010100
+dqinv056 invert 111011101 -> 1111111111111111111111111000100010
+dqinv057 invert 110111110 -> 1111111111111111111111111001000001
+dqinv058 invert 101111101 -> 1111111111111111111111111010000010
+dqinv059 invert 011111011 -> 1111111111111111111111111100000100
+
+dqinv080 invert 1000000011111111 -> 1111111111111111110111111100000000
+dqinv081 invert 0100000101111111 -> 1111111111111111111011111010000000
+dqinv082 invert 0010000110111111 -> 1111111111111111111101111001000000
+dqinv083 invert 0001000111011111 -> 1111111111111111111110111000100000
+dqinv084 invert 0000100111101111 -> 1111111111111111111111011000010000
+dqinv085 invert 0000010111110111 -> 1111111111111111111111101000001000
+dqinv086 invert 0000001111111011 -> 1111111111111111111111110000000100
+dqinv087 invert 0000010111111101 -> 1111111111111111111111101000000010
+dqinv088 invert 0000100111111110 -> 1111111111111111111111011000000001
+dqinv089 invert 0001000011111011 -> 1111111111111111111110111100000100
+dqinv090 invert 0010000101111101 -> 1111111111111111111101111010000010
+dqinv091 invert 0100000110111110 -> 1111111111111111111011111001000001
+dqinv092 invert 1000000111011101 -> 1111111111111111110111111000100010
+dqinv093 invert 0100000111101011 -> 1111111111111111111011111000010100
+dqinv094 invert 0010000111110111 -> 1111111111111111111101111000001000
+dqinv095 invert 0001000111101011 -> 1111111111111111111110111000010100
+dqinv096 invert 0000100111011101 -> 1111111111111111111111011000100010
+dqinv097 invert 0000010110111110 -> 1111111111111111111111101001000001
+dqinv098 invert 0000001101111101 -> 1111111111111111111111110010000010
+dqinv099 invert 0000010011111011 -> 1111111111111111111111101100000100
+
+-- and more thorough MSD/LSD tests [8 and 9 mght be encoded differently...]
+dqinv151 invert 1111111111111111111111111111111110 -> 1
+dqinv152 invert 1111111111111111110000000000000000 -> 1111111111111111
+dqinv153 invert 1000000000000000001111111111111111 -> 111111111111111110000000000000000
+dqinv154 invert 1111111111111111111000000000000000 -> 111111111111111
+dqinv155 invert 0100000000000000000111111111111111 -> 1011111111111111111000000000000000
+dqinv156 invert 1011111111111111110100000000000000 -> 100000000000000001011111111111111
+dqinv157 invert 1101111111111111110111111111111111 -> 10000000000000001000000000000000
+dqinv158 invert 1110111111111111110011111111111111 -> 1000000000000001100000000000000
+
+-- non-0/1 should not be accepted, nor should signs
+dqinv220 invert 111111112 -> NaN Invalid_operation
+dqinv221 invert 333333333 -> NaN Invalid_operation
+dqinv222 invert 555555555 -> NaN Invalid_operation
+dqinv223 invert 777777777 -> NaN Invalid_operation
+dqinv224 invert 999999999 -> NaN Invalid_operation
+dqinv225 invert 222222222 -> NaN Invalid_operation
+dqinv226 invert 444444444 -> NaN Invalid_operation
+dqinv227 invert 666666666 -> NaN Invalid_operation
+dqinv228 invert 888888888 -> NaN Invalid_operation
+dqinv229 invert 999999999 -> NaN Invalid_operation
+dqinv230 invert 999999999 -> NaN Invalid_operation
+dqinv231 invert 999999999 -> NaN Invalid_operation
+dqinv232 invert 999999999 -> NaN Invalid_operation
+-- a few randoms
+dqinv240 invert 567468689 -> NaN Invalid_operation
+dqinv241 invert 567367689 -> NaN Invalid_operation
+dqinv242 invert -631917772 -> NaN Invalid_operation
+dqinv243 invert -756253257 -> NaN Invalid_operation
+dqinv244 invert 835590149 -> NaN Invalid_operation
+-- test MSD
+dqinv250 invert 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv251 invert 3000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv252 invert 4000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv253 invert 5000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv254 invert 6000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv255 invert 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv256 invert 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv257 invert 9000000111000111000111000000000000 -> NaN Invalid_operation
+-- test MSD-1
+dqinv270 invert 0200000111000111000111001000000000 -> NaN Invalid_operation
+dqinv271 invert 0300000111000111000111000100000000 -> NaN Invalid_operation
+dqinv272 invert 0400000111000111000111000010000000 -> NaN Invalid_operation
+dqinv273 invert 0500000111000111000111000001000000 -> NaN Invalid_operation
+dqinv274 invert 1600000111000111000111000000100000 -> NaN Invalid_operation
+dqinv275 invert 1700000111000111000111000000010000 -> NaN Invalid_operation
+dqinv276 invert 1800000111000111000111000000001000 -> NaN Invalid_operation
+dqinv277 invert 1900000111000111000111000000000100 -> NaN Invalid_operation
+-- test LSD
+dqinv280 invert 0010000111000111000111000000000002 -> NaN Invalid_operation
+dqinv281 invert 0001000111000111000111000000000003 -> NaN Invalid_operation
+dqinv282 invert 0000000111000111000111100000000004 -> NaN Invalid_operation
+dqinv283 invert 0000000111000111000111010000000005 -> NaN Invalid_operation
+dqinv284 invert 1000000111000111000111001000000006 -> NaN Invalid_operation
+dqinv285 invert 1000000111000111000111000100000007 -> NaN Invalid_operation
+dqinv286 invert 1000000111000111000111000010000008 -> NaN Invalid_operation
+dqinv287 invert 1000000111000111000111000001000009 -> NaN Invalid_operation
+-- test Middie
+dqinv288 invert 0010000111000111000111000020000000 -> NaN Invalid_operation
+dqinv289 invert 0001000111000111000111000030000001 -> NaN Invalid_operation
+dqinv290 invert 0000000111000111000111100040000010 -> NaN Invalid_operation
+dqinv291 invert 0000000111000111000111010050000100 -> NaN Invalid_operation
+dqinv292 invert 1000000111000111000111001060001000 -> NaN Invalid_operation
+dqinv293 invert 1000000111000111000111000170010000 -> NaN Invalid_operation
+dqinv294 invert 1000000111000111000111000080100000 -> NaN Invalid_operation
+dqinv295 invert 1000000111000111000111000091000000 -> NaN Invalid_operation
+-- signs
+dqinv296 invert -1000000111000111000111000001000000 -> NaN Invalid_operation
+dqinv299 invert 1000000111000111000111000001000000 -> 111111000111000111000111110111111
+
+-- Nmax, Nmin, Ntiny-like
+dqinv341 invert 9.99999999E+2998 -> NaN Invalid_operation
+dqinv342 invert 1E-2998 -> NaN Invalid_operation
+dqinv343 invert 1.00000000E-2998 -> NaN Invalid_operation
+dqinv344 invert 1E-2078 -> NaN Invalid_operation
+dqinv345 invert -1E-2078 -> NaN Invalid_operation
+dqinv346 invert -1.00000000E-2998 -> NaN Invalid_operation
+dqinv347 invert -1E-2998 -> NaN Invalid_operation
+dqinv348 invert -9.99999999E+2998 -> NaN Invalid_operation
+
+-- A few other non-integers
+dqinv361 invert 1.0 -> NaN Invalid_operation
+dqinv362 invert 1E+1 -> NaN Invalid_operation
+dqinv363 invert 0.0 -> NaN Invalid_operation
+dqinv364 invert 0E+1 -> NaN Invalid_operation
+dqinv365 invert 9.9 -> NaN Invalid_operation
+dqinv366 invert 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+dqinv788 invert -Inf -> NaN Invalid_operation
+dqinv794 invert Inf -> NaN Invalid_operation
+dqinv821 invert NaN -> NaN Invalid_operation
+dqinv841 invert sNaN -> NaN Invalid_operation
+-- propagating NaNs
+dqinv861 invert NaN1 -> NaN Invalid_operation
+dqinv862 invert +NaN2 -> NaN Invalid_operation
+dqinv863 invert NaN3 -> NaN Invalid_operation
+dqinv864 invert NaN4 -> NaN Invalid_operation
+dqinv865 invert NaN5 -> NaN Invalid_operation
+dqinv871 invert sNaN11 -> NaN Invalid_operation
+dqinv872 invert sNaN12 -> NaN Invalid_operation
+dqinv873 invert sNaN13 -> NaN Invalid_operation
+dqinv874 invert sNaN14 -> NaN Invalid_operation
+dqinv875 invert sNaN15 -> NaN Invalid_operation
+dqinv876 invert NaN16 -> NaN Invalid_operation
+dqinv881 invert +NaN25 -> NaN Invalid_operation
+dqinv882 invert -NaN26 -> NaN Invalid_operation
+dqinv883 invert -sNaN27 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqLogB.decTest b/Lib/test/decimaltestdata/dqLogB.decTest
index 449f3dcb8d..a18313dc01 100644
--- a/Lib/test/decimaltestdata/dqLogB.decTest
+++ b/Lib/test/decimaltestdata/dqLogB.decTest
@@ -1,160 +1,160 @@
-------------------------------------------------------------------------
--- dqLogB.decTest -- integral 754r adjusted exponent, for decQuads --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- basics
-dqlogb000 logb 0 -> -Infinity Division_by_zero
-dqlogb001 logb 1E-6176 -> -6176
-dqlogb002 logb 1E-6143 -> -6143
-dqlogb003 logb 0.001 -> -3
-dqlogb004 logb 0.03 -> -2
-dqlogb005 logb 1 -> 0
-dqlogb006 logb 2 -> 0
-dqlogb007 logb 2.5 -> 0
-dqlogb008 logb 2.50 -> 0
-dqlogb009 logb 2.500 -> 0
-dqlogb010 logb 10 -> 1
-dqlogb011 logb 70 -> 1
-dqlogb012 logb 100 -> 2
-dqlogb013 logb 250 -> 2
-dqlogb014 logb 9E+6144 -> 6144
-dqlogb015 logb +Infinity -> Infinity
-
--- negatives appear to be treated as positives
-dqlogb021 logb -0 -> -Infinity Division_by_zero
-dqlogb022 logb -1E-6176 -> -6176
-dqlogb023 logb -9E-6143 -> -6143
-dqlogb024 logb -0.001 -> -3
-dqlogb025 logb -1 -> 0
-dqlogb026 logb -2 -> 0
-dqlogb027 logb -10 -> 1
-dqlogb028 logb -70 -> 1
-dqlogb029 logb -100 -> 2
-dqlogb030 logb -9E+6144 -> 6144
-dqlogb031 logb -Infinity -> Infinity
-
--- zeros
-dqlogb111 logb 0 -> -Infinity Division_by_zero
-dqlogb112 logb -0 -> -Infinity Division_by_zero
-dqlogb113 logb 0E+4 -> -Infinity Division_by_zero
-dqlogb114 logb -0E+4 -> -Infinity Division_by_zero
-dqlogb115 logb 0.0000 -> -Infinity Division_by_zero
-dqlogb116 logb -0.0000 -> -Infinity Division_by_zero
-dqlogb117 logb 0E-141 -> -Infinity Division_by_zero
-dqlogb118 logb -0E-141 -> -Infinity Division_by_zero
-
--- full coefficients, alternating bits
-dqlogb121 logb 268268268 -> 8
-dqlogb122 logb -268268268 -> 8
-dqlogb123 logb 134134134 -> 8
-dqlogb124 logb -134134134 -> 8
-
--- Nmax, Nmin, Ntiny
-dqlogb131 logb 9.999999999999999999999999999999999E+6144 -> 6144
-dqlogb132 logb 1E-6143 -> -6143
-dqlogb133 logb 1.000000000000000000000000000000000E-6143 -> -6143
-dqlogb134 logb 1E-6176 -> -6176
-
-dqlogb135 logb -1E-6176 -> -6176
-dqlogb136 logb -1.000000000000000000000000000000000E-6143 -> -6143
-dqlogb137 logb -1E-6143 -> -6143
-dqlogb1614 logb -9.999999999999999999999999999999999E+6144 -> 6144
-
--- ones
-dqlogb0061 logb 1 -> 0
-dqlogb0062 logb 1.0 -> 0
-dqlogb0063 logb 1.000000000000000 -> 0
-
--- notable cases -- exact powers of 10
-dqlogb1100 logb 1 -> 0
-dqlogb1101 logb 10 -> 1
-dqlogb1102 logb 100 -> 2
-dqlogb1103 logb 1000 -> 3
-dqlogb1104 logb 10000 -> 4
-dqlogb1105 logb 100000 -> 5
-dqlogb1106 logb 1000000 -> 6
-dqlogb1107 logb 10000000 -> 7
-dqlogb1108 logb 100000000 -> 8
-dqlogb1109 logb 1000000000 -> 9
-dqlogb1110 logb 10000000000 -> 10
-dqlogb1111 logb 100000000000 -> 11
-dqlogb1112 logb 1000000000000 -> 12
-dqlogb1113 logb 0.00000000001 -> -11
-dqlogb1114 logb 0.0000000001 -> -10
-dqlogb1115 logb 0.000000001 -> -9
-dqlogb1116 logb 0.00000001 -> -8
-dqlogb1117 logb 0.0000001 -> -7
-dqlogb1118 logb 0.000001 -> -6
-dqlogb1119 logb 0.00001 -> -5
-dqlogb1120 logb 0.0001 -> -4
-dqlogb1121 logb 0.001 -> -3
-dqlogb1122 logb 0.01 -> -2
-dqlogb1123 logb 0.1 -> -1
-dqlogb1124 logb 1E-99 -> -99
-dqlogb1125 logb 1E-100 -> -100
-dqlogb1127 logb 1E-299 -> -299
-dqlogb1126 logb 1E-6143 -> -6143
-
--- suggestions from Ilan Nehama
-dqlogb1400 logb 10E-3 -> -2
-dqlogb1401 logb 10E-2 -> -1
-dqlogb1402 logb 100E-2 -> 0
-dqlogb1403 logb 1000E-2 -> 1
-dqlogb1404 logb 10000E-2 -> 2
-dqlogb1405 logb 10E-1 -> 0
-dqlogb1406 logb 100E-1 -> 1
-dqlogb1407 logb 1000E-1 -> 2
-dqlogb1408 logb 10000E-1 -> 3
-dqlogb1409 logb 10E0 -> 1
-dqlogb1410 logb 100E0 -> 2
-dqlogb1411 logb 1000E0 -> 3
-dqlogb1412 logb 10000E0 -> 4
-dqlogb1413 logb 10E1 -> 2
-dqlogb1414 logb 100E1 -> 3
-dqlogb1415 logb 1000E1 -> 4
-dqlogb1416 logb 10000E1 -> 5
-dqlogb1417 logb 10E2 -> 3
-dqlogb1418 logb 100E2 -> 4
-dqlogb1419 logb 1000E2 -> 5
-dqlogb1420 logb 10000E2 -> 6
-
--- special values
-dqlogb820 logb Infinity -> Infinity
-dqlogb821 logb 0 -> -Infinity Division_by_zero
-dqlogb822 logb NaN -> NaN
-dqlogb823 logb sNaN -> NaN Invalid_operation
--- propagating NaNs
-dqlogb824 logb sNaN123 -> NaN123 Invalid_operation
-dqlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
-dqlogb826 logb NaN456 -> NaN456
-dqlogb827 logb -NaN654 -> -NaN654
-dqlogb828 logb NaN1 -> NaN1
-
--- Null test
-dqlogb900 logb # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- dqLogB.decTest -- integral 754r adjusted exponent, for decQuads --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- basics
+dqlogb000 logb 0 -> -Infinity Division_by_zero
+dqlogb001 logb 1E-6176 -> -6176
+dqlogb002 logb 1E-6143 -> -6143
+dqlogb003 logb 0.001 -> -3
+dqlogb004 logb 0.03 -> -2
+dqlogb005 logb 1 -> 0
+dqlogb006 logb 2 -> 0
+dqlogb007 logb 2.5 -> 0
+dqlogb008 logb 2.50 -> 0
+dqlogb009 logb 2.500 -> 0
+dqlogb010 logb 10 -> 1
+dqlogb011 logb 70 -> 1
+dqlogb012 logb 100 -> 2
+dqlogb013 logb 250 -> 2
+dqlogb014 logb 9E+6144 -> 6144
+dqlogb015 logb +Infinity -> Infinity
+
+-- negatives appear to be treated as positives
+dqlogb021 logb -0 -> -Infinity Division_by_zero
+dqlogb022 logb -1E-6176 -> -6176
+dqlogb023 logb -9E-6143 -> -6143
+dqlogb024 logb -0.001 -> -3
+dqlogb025 logb -1 -> 0
+dqlogb026 logb -2 -> 0
+dqlogb027 logb -10 -> 1
+dqlogb028 logb -70 -> 1
+dqlogb029 logb -100 -> 2
+dqlogb030 logb -9E+6144 -> 6144
+dqlogb031 logb -Infinity -> Infinity
+
+-- zeros
+dqlogb111 logb 0 -> -Infinity Division_by_zero
+dqlogb112 logb -0 -> -Infinity Division_by_zero
+dqlogb113 logb 0E+4 -> -Infinity Division_by_zero
+dqlogb114 logb -0E+4 -> -Infinity Division_by_zero
+dqlogb115 logb 0.0000 -> -Infinity Division_by_zero
+dqlogb116 logb -0.0000 -> -Infinity Division_by_zero
+dqlogb117 logb 0E-141 -> -Infinity Division_by_zero
+dqlogb118 logb -0E-141 -> -Infinity Division_by_zero
+
+-- full coefficients, alternating bits
+dqlogb121 logb 268268268 -> 8
+dqlogb122 logb -268268268 -> 8
+dqlogb123 logb 134134134 -> 8
+dqlogb124 logb -134134134 -> 8
+
+-- Nmax, Nmin, Ntiny
+dqlogb131 logb 9.999999999999999999999999999999999E+6144 -> 6144
+dqlogb132 logb 1E-6143 -> -6143
+dqlogb133 logb 1.000000000000000000000000000000000E-6143 -> -6143
+dqlogb134 logb 1E-6176 -> -6176
+
+dqlogb135 logb -1E-6176 -> -6176
+dqlogb136 logb -1.000000000000000000000000000000000E-6143 -> -6143
+dqlogb137 logb -1E-6143 -> -6143
+dqlogb1614 logb -9.999999999999999999999999999999999E+6144 -> 6144
+
+-- ones
+dqlogb0061 logb 1 -> 0
+dqlogb0062 logb 1.0 -> 0
+dqlogb0063 logb 1.000000000000000 -> 0
+
+-- notable cases -- exact powers of 10
+dqlogb1100 logb 1 -> 0
+dqlogb1101 logb 10 -> 1
+dqlogb1102 logb 100 -> 2
+dqlogb1103 logb 1000 -> 3
+dqlogb1104 logb 10000 -> 4
+dqlogb1105 logb 100000 -> 5
+dqlogb1106 logb 1000000 -> 6
+dqlogb1107 logb 10000000 -> 7
+dqlogb1108 logb 100000000 -> 8
+dqlogb1109 logb 1000000000 -> 9
+dqlogb1110 logb 10000000000 -> 10
+dqlogb1111 logb 100000000000 -> 11
+dqlogb1112 logb 1000000000000 -> 12
+dqlogb1113 logb 0.00000000001 -> -11
+dqlogb1114 logb 0.0000000001 -> -10
+dqlogb1115 logb 0.000000001 -> -9
+dqlogb1116 logb 0.00000001 -> -8
+dqlogb1117 logb 0.0000001 -> -7
+dqlogb1118 logb 0.000001 -> -6
+dqlogb1119 logb 0.00001 -> -5
+dqlogb1120 logb 0.0001 -> -4
+dqlogb1121 logb 0.001 -> -3
+dqlogb1122 logb 0.01 -> -2
+dqlogb1123 logb 0.1 -> -1
+dqlogb1124 logb 1E-99 -> -99
+dqlogb1125 logb 1E-100 -> -100
+dqlogb1127 logb 1E-299 -> -299
+dqlogb1126 logb 1E-6143 -> -6143
+
+-- suggestions from Ilan Nehama
+dqlogb1400 logb 10E-3 -> -2
+dqlogb1401 logb 10E-2 -> -1
+dqlogb1402 logb 100E-2 -> 0
+dqlogb1403 logb 1000E-2 -> 1
+dqlogb1404 logb 10000E-2 -> 2
+dqlogb1405 logb 10E-1 -> 0
+dqlogb1406 logb 100E-1 -> 1
+dqlogb1407 logb 1000E-1 -> 2
+dqlogb1408 logb 10000E-1 -> 3
+dqlogb1409 logb 10E0 -> 1
+dqlogb1410 logb 100E0 -> 2
+dqlogb1411 logb 1000E0 -> 3
+dqlogb1412 logb 10000E0 -> 4
+dqlogb1413 logb 10E1 -> 2
+dqlogb1414 logb 100E1 -> 3
+dqlogb1415 logb 1000E1 -> 4
+dqlogb1416 logb 10000E1 -> 5
+dqlogb1417 logb 10E2 -> 3
+dqlogb1418 logb 100E2 -> 4
+dqlogb1419 logb 1000E2 -> 5
+dqlogb1420 logb 10000E2 -> 6
+
+-- special values
+dqlogb820 logb Infinity -> Infinity
+dqlogb821 logb 0 -> -Infinity Division_by_zero
+dqlogb822 logb NaN -> NaN
+dqlogb823 logb sNaN -> NaN Invalid_operation
+-- propagating NaNs
+dqlogb824 logb sNaN123 -> NaN123 Invalid_operation
+dqlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
+dqlogb826 logb NaN456 -> NaN456
+dqlogb827 logb -NaN654 -> -NaN654
+dqlogb828 logb NaN1 -> NaN1
+
+-- Null test
+dqlogb900 logb # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/dqMax.decTest b/Lib/test/decimaltestdata/dqMax.decTest
index 162d4bda3d..dc6a1ab8f8 100644
--- a/Lib/test/decimaltestdata/dqMax.decTest
+++ b/Lib/test/decimaltestdata/dqMax.decTest
@@ -1,322 +1,322 @@
-------------------------------------------------------------------------
--- dqMax.decTest -- decQuad maxnum --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmax001 max -2 -2 -> -2
-dqmax002 max -2 -1 -> -1
-dqmax003 max -2 0 -> 0
-dqmax004 max -2 1 -> 1
-dqmax005 max -2 2 -> 2
-dqmax006 max -1 -2 -> -1
-dqmax007 max -1 -1 -> -1
-dqmax008 max -1 0 -> 0
-dqmax009 max -1 1 -> 1
-dqmax010 max -1 2 -> 2
-dqmax011 max 0 -2 -> 0
-dqmax012 max 0 -1 -> 0
-dqmax013 max 0 0 -> 0
-dqmax014 max 0 1 -> 1
-dqmax015 max 0 2 -> 2
-dqmax016 max 1 -2 -> 1
-dqmax017 max 1 -1 -> 1
-dqmax018 max 1 0 -> 1
-dqmax019 max 1 1 -> 1
-dqmax020 max 1 2 -> 2
-dqmax021 max 2 -2 -> 2
-dqmax022 max 2 -1 -> 2
-dqmax023 max 2 0 -> 2
-dqmax025 max 2 1 -> 2
-dqmax026 max 2 2 -> 2
-
--- extended zeros
-dqmax030 max 0 0 -> 0
-dqmax031 max 0 -0 -> 0
-dqmax032 max 0 -0.0 -> 0
-dqmax033 max 0 0.0 -> 0
-dqmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-dqmax035 max -0 -0 -> -0
-dqmax036 max -0 -0.0 -> -0.0
-dqmax037 max -0 0.0 -> 0.0
-dqmax038 max 0.0 0 -> 0
-dqmax039 max 0.0 -0 -> 0.0
-dqmax040 max 0.0 -0.0 -> 0.0
-dqmax041 max 0.0 0.0 -> 0.0
-dqmax042 max -0.0 0 -> 0
-dqmax043 max -0.0 -0 -> -0.0
-dqmax044 max -0.0 -0.0 -> -0.0
-dqmax045 max -0.0 0.0 -> 0.0
-
-dqmax050 max -0E1 0E1 -> 0E+1
-dqmax051 max -0E2 0E2 -> 0E+2
-dqmax052 max -0E2 0E1 -> 0E+1
-dqmax053 max -0E1 0E2 -> 0E+2
-dqmax054 max 0E1 -0E1 -> 0E+1
-dqmax055 max 0E2 -0E2 -> 0E+2
-dqmax056 max 0E2 -0E1 -> 0E+2
-dqmax057 max 0E1 -0E2 -> 0E+1
-
-dqmax058 max 0E1 0E1 -> 0E+1
-dqmax059 max 0E2 0E2 -> 0E+2
-dqmax060 max 0E2 0E1 -> 0E+2
-dqmax061 max 0E1 0E2 -> 0E+2
-dqmax062 max -0E1 -0E1 -> -0E+1
-dqmax063 max -0E2 -0E2 -> -0E+2
-dqmax064 max -0E2 -0E1 -> -0E+1
-dqmax065 max -0E1 -0E2 -> -0E+1
-
--- Specials
-dqmax090 max Inf -Inf -> Infinity
-dqmax091 max Inf -1000 -> Infinity
-dqmax092 max Inf -1 -> Infinity
-dqmax093 max Inf -0 -> Infinity
-dqmax094 max Inf 0 -> Infinity
-dqmax095 max Inf 1 -> Infinity
-dqmax096 max Inf 1000 -> Infinity
-dqmax097 max Inf Inf -> Infinity
-dqmax098 max -1000 Inf -> Infinity
-dqmax099 max -Inf Inf -> Infinity
-dqmax100 max -1 Inf -> Infinity
-dqmax101 max -0 Inf -> Infinity
-dqmax102 max 0 Inf -> Infinity
-dqmax103 max 1 Inf -> Infinity
-dqmax104 max 1000 Inf -> Infinity
-dqmax105 max Inf Inf -> Infinity
-
-dqmax120 max -Inf -Inf -> -Infinity
-dqmax121 max -Inf -1000 -> -1000
-dqmax122 max -Inf -1 -> -1
-dqmax123 max -Inf -0 -> -0
-dqmax124 max -Inf 0 -> 0
-dqmax125 max -Inf 1 -> 1
-dqmax126 max -Inf 1000 -> 1000
-dqmax127 max -Inf Inf -> Infinity
-dqmax128 max -Inf -Inf -> -Infinity
-dqmax129 max -1000 -Inf -> -1000
-dqmax130 max -1 -Inf -> -1
-dqmax131 max -0 -Inf -> -0
-dqmax132 max 0 -Inf -> 0
-dqmax133 max 1 -Inf -> 1
-dqmax134 max 1000 -Inf -> 1000
-dqmax135 max Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-dqmax141 max NaN -Inf -> -Infinity
-dqmax142 max NaN -1000 -> -1000
-dqmax143 max NaN -1 -> -1
-dqmax144 max NaN -0 -> -0
-dqmax145 max NaN 0 -> 0
-dqmax146 max NaN 1 -> 1
-dqmax147 max NaN 1000 -> 1000
-dqmax148 max NaN Inf -> Infinity
-dqmax149 max NaN NaN -> NaN
-dqmax150 max -Inf NaN -> -Infinity
-dqmax151 max -1000 NaN -> -1000
-dqmax152 max -1 NaN -> -1
-dqmax153 max -0 NaN -> -0
-dqmax154 max 0 NaN -> 0
-dqmax155 max 1 NaN -> 1
-dqmax156 max 1000 NaN -> 1000
-dqmax157 max Inf NaN -> Infinity
-
-dqmax161 max sNaN -Inf -> NaN Invalid_operation
-dqmax162 max sNaN -1000 -> NaN Invalid_operation
-dqmax163 max sNaN -1 -> NaN Invalid_operation
-dqmax164 max sNaN -0 -> NaN Invalid_operation
-dqmax165 max sNaN 0 -> NaN Invalid_operation
-dqmax166 max sNaN 1 -> NaN Invalid_operation
-dqmax167 max sNaN 1000 -> NaN Invalid_operation
-dqmax168 max sNaN NaN -> NaN Invalid_operation
-dqmax169 max sNaN sNaN -> NaN Invalid_operation
-dqmax170 max NaN sNaN -> NaN Invalid_operation
-dqmax171 max -Inf sNaN -> NaN Invalid_operation
-dqmax172 max -1000 sNaN -> NaN Invalid_operation
-dqmax173 max -1 sNaN -> NaN Invalid_operation
-dqmax174 max -0 sNaN -> NaN Invalid_operation
-dqmax175 max 0 sNaN -> NaN Invalid_operation
-dqmax176 max 1 sNaN -> NaN Invalid_operation
-dqmax177 max 1000 sNaN -> NaN Invalid_operation
-dqmax178 max Inf sNaN -> NaN Invalid_operation
-dqmax179 max NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmax181 max NaN9 -Inf -> -Infinity
-dqmax182 max NaN8 9 -> 9
-dqmax183 max -NaN7 Inf -> Infinity
-
-dqmax184 max -NaN1 NaN11 -> -NaN1
-dqmax185 max NaN2 NaN12 -> NaN2
-dqmax186 max -NaN13 -NaN7 -> -NaN13
-dqmax187 max NaN14 -NaN5 -> NaN14
-
-dqmax188 max -Inf NaN4 -> -Infinity
-dqmax189 max -9 -NaN3 -> -9
-dqmax190 max Inf NaN2 -> Infinity
-
-dqmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
-dqmax192 max sNaN98 -1 -> NaN98 Invalid_operation
-dqmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
-dqmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
-dqmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
-dqmax197 max 0 sNaN91 -> NaN91 Invalid_operation
-dqmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmax199 max NaN sNaN89 -> NaN89 Invalid_operation
-
--- old rounding checks
-dqmax221 max 12345678000 1 -> 12345678000
-dqmax222 max 1 12345678000 -> 12345678000
-dqmax223 max 1234567800 1 -> 1234567800
-dqmax224 max 1 1234567800 -> 1234567800
-dqmax225 max 1234567890 1 -> 1234567890
-dqmax226 max 1 1234567890 -> 1234567890
-dqmax227 max 1234567891 1 -> 1234567891
-dqmax228 max 1 1234567891 -> 1234567891
-dqmax229 max 12345678901 1 -> 12345678901
-dqmax230 max 1 12345678901 -> 12345678901
-dqmax231 max 1234567896 1 -> 1234567896
-dqmax232 max 1 1234567896 -> 1234567896
-dqmax233 max -1234567891 1 -> 1
-dqmax234 max 1 -1234567891 -> 1
-dqmax235 max -12345678901 1 -> 1
-dqmax236 max 1 -12345678901 -> 1
-dqmax237 max -1234567896 1 -> 1
-dqmax238 max 1 -1234567896 -> 1
-
--- from examples
-dqmax280 max '3' '2' -> '3'
-dqmax281 max '-10' '3' -> '3'
-dqmax282 max '1.0' '1' -> '1'
-dqmax283 max '1' '1.0' -> '1'
-dqmax284 max '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-dqmax401 max Inf 1.1 -> Infinity
-dqmax402 max 1.1 1 -> 1.1
-dqmax403 max 1 1.0 -> 1
-dqmax404 max 1.0 0.1 -> 1.0
-dqmax405 max 0.1 0.10 -> 0.1
-dqmax406 max 0.10 0.100 -> 0.10
-dqmax407 max 0.10 0 -> 0.10
-dqmax408 max 0 0.0 -> 0
-dqmax409 max 0.0 -0 -> 0.0
-dqmax410 max 0.0 -0.0 -> 0.0
-dqmax411 max 0.00 -0.0 -> 0.00
-dqmax412 max 0.0 -0.00 -> 0.0
-dqmax413 max 0 -0.0 -> 0
-dqmax414 max 0 -0 -> 0
-dqmax415 max -0.0 -0 -> -0.0
-dqmax416 max -0 -0.100 -> -0
-dqmax417 max -0.100 -0.10 -> -0.100
-dqmax418 max -0.10 -0.1 -> -0.10
-dqmax419 max -0.1 -1.0 -> -0.1
-dqmax420 max -1.0 -1 -> -1.0
-dqmax421 max -1 -1.1 -> -1
-dqmax423 max -1.1 -Inf -> -1.1
--- same with operands reversed
-dqmax431 max 1.1 Inf -> Infinity
-dqmax432 max 1 1.1 -> 1.1
-dqmax433 max 1.0 1 -> 1
-dqmax434 max 0.1 1.0 -> 1.0
-dqmax435 max 0.10 0.1 -> 0.1
-dqmax436 max 0.100 0.10 -> 0.10
-dqmax437 max 0 0.10 -> 0.10
-dqmax438 max 0.0 0 -> 0
-dqmax439 max -0 0.0 -> 0.0
-dqmax440 max -0.0 0.0 -> 0.0
-dqmax441 max -0.0 0.00 -> 0.00
-dqmax442 max -0.00 0.0 -> 0.0
-dqmax443 max -0.0 0 -> 0
-dqmax444 max -0 0 -> 0
-dqmax445 max -0 -0.0 -> -0.0
-dqmax446 max -0.100 -0 -> -0
-dqmax447 max -0.10 -0.100 -> -0.100
-dqmax448 max -0.1 -0.10 -> -0.10
-dqmax449 max -1.0 -0.1 -> -0.1
-dqmax450 max -1 -1.0 -> -1.0
-dqmax451 max -1.1 -1 -> -1
-dqmax453 max -Inf -1.1 -> -1.1
--- largies
-dqmax460 max 1000 1E+3 -> 1E+3
-dqmax461 max 1E+3 1000 -> 1E+3
-dqmax462 max 1000 -1E+3 -> 1000
-dqmax463 max 1E+3 -1000 -> 1E+3
-dqmax464 max -1000 1E+3 -> 1E+3
-dqmax465 max -1E+3 1000 -> 1000
-dqmax466 max -1000 -1E+3 -> -1000
-dqmax467 max -1E+3 -1000 -> -1000
-
--- misalignment traps for little-endian
-dqmax471 max 1.0 0.1 -> 1.0
-dqmax472 max 0.1 1.0 -> 1.0
-dqmax473 max 10.0 0.1 -> 10.0
-dqmax474 max 0.1 10.0 -> 10.0
-dqmax475 max 100 1.0 -> 100
-dqmax476 max 1.0 100 -> 100
-dqmax477 max 1000 10.0 -> 1000
-dqmax478 max 10.0 1000 -> 1000
-dqmax479 max 10000 100.0 -> 10000
-dqmax480 max 100.0 10000 -> 10000
-dqmax481 max 100000 1000.0 -> 100000
-dqmax482 max 1000.0 100000 -> 100000
-dqmax483 max 1000000 10000.0 -> 1000000
-dqmax484 max 10000.0 1000000 -> 1000000
-
--- subnormals
-dqmax510 max 1.00E-6143 0 -> 1.00E-6143
-dqmax511 max 0.1E-6143 0 -> 1E-6144 Subnormal
-dqmax512 max 0.10E-6143 0 -> 1.0E-6144 Subnormal
-dqmax513 max 0.100E-6143 0 -> 1.00E-6144 Subnormal
-dqmax514 max 0.01E-6143 0 -> 1E-6145 Subnormal
-dqmax515 max 0.999E-6143 0 -> 9.99E-6144 Subnormal
-dqmax516 max 0.099E-6143 0 -> 9.9E-6145 Subnormal
-dqmax517 max 0.009E-6143 0 -> 9E-6146 Subnormal
-dqmax518 max 0.001E-6143 0 -> 1E-6146 Subnormal
-dqmax519 max 0.0009E-6143 0 -> 9E-6147 Subnormal
-dqmax520 max 0.0001E-6143 0 -> 1E-6147 Subnormal
-
-dqmax530 max -1.00E-6143 0 -> 0
-dqmax531 max -0.1E-6143 0 -> 0
-dqmax532 max -0.10E-6143 0 -> 0
-dqmax533 max -0.100E-6143 0 -> 0
-dqmax534 max -0.01E-6143 0 -> 0
-dqmax535 max -0.999E-6143 0 -> 0
-dqmax536 max -0.099E-6143 0 -> 0
-dqmax537 max -0.009E-6143 0 -> 0
-dqmax538 max -0.001E-6143 0 -> 0
-dqmax539 max -0.0009E-6143 0 -> 0
-dqmax540 max -0.0001E-6143 0 -> 0
-
--- Null tests
-dqmax900 max 10 # -> NaN Invalid_operation
-dqmax901 max # 10 -> NaN Invalid_operation
-
-
-
+------------------------------------------------------------------------
+-- dqMax.decTest -- decQuad maxnum --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmax001 max -2 -2 -> -2
+dqmax002 max -2 -1 -> -1
+dqmax003 max -2 0 -> 0
+dqmax004 max -2 1 -> 1
+dqmax005 max -2 2 -> 2
+dqmax006 max -1 -2 -> -1
+dqmax007 max -1 -1 -> -1
+dqmax008 max -1 0 -> 0
+dqmax009 max -1 1 -> 1
+dqmax010 max -1 2 -> 2
+dqmax011 max 0 -2 -> 0
+dqmax012 max 0 -1 -> 0
+dqmax013 max 0 0 -> 0
+dqmax014 max 0 1 -> 1
+dqmax015 max 0 2 -> 2
+dqmax016 max 1 -2 -> 1
+dqmax017 max 1 -1 -> 1
+dqmax018 max 1 0 -> 1
+dqmax019 max 1 1 -> 1
+dqmax020 max 1 2 -> 2
+dqmax021 max 2 -2 -> 2
+dqmax022 max 2 -1 -> 2
+dqmax023 max 2 0 -> 2
+dqmax025 max 2 1 -> 2
+dqmax026 max 2 2 -> 2
+
+-- extended zeros
+dqmax030 max 0 0 -> 0
+dqmax031 max 0 -0 -> 0
+dqmax032 max 0 -0.0 -> 0
+dqmax033 max 0 0.0 -> 0
+dqmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+dqmax035 max -0 -0 -> -0
+dqmax036 max -0 -0.0 -> -0.0
+dqmax037 max -0 0.0 -> 0.0
+dqmax038 max 0.0 0 -> 0
+dqmax039 max 0.0 -0 -> 0.0
+dqmax040 max 0.0 -0.0 -> 0.0
+dqmax041 max 0.0 0.0 -> 0.0
+dqmax042 max -0.0 0 -> 0
+dqmax043 max -0.0 -0 -> -0.0
+dqmax044 max -0.0 -0.0 -> -0.0
+dqmax045 max -0.0 0.0 -> 0.0
+
+dqmax050 max -0E1 0E1 -> 0E+1
+dqmax051 max -0E2 0E2 -> 0E+2
+dqmax052 max -0E2 0E1 -> 0E+1
+dqmax053 max -0E1 0E2 -> 0E+2
+dqmax054 max 0E1 -0E1 -> 0E+1
+dqmax055 max 0E2 -0E2 -> 0E+2
+dqmax056 max 0E2 -0E1 -> 0E+2
+dqmax057 max 0E1 -0E2 -> 0E+1
+
+dqmax058 max 0E1 0E1 -> 0E+1
+dqmax059 max 0E2 0E2 -> 0E+2
+dqmax060 max 0E2 0E1 -> 0E+2
+dqmax061 max 0E1 0E2 -> 0E+2
+dqmax062 max -0E1 -0E1 -> -0E+1
+dqmax063 max -0E2 -0E2 -> -0E+2
+dqmax064 max -0E2 -0E1 -> -0E+1
+dqmax065 max -0E1 -0E2 -> -0E+1
+
+-- Specials
+dqmax090 max Inf -Inf -> Infinity
+dqmax091 max Inf -1000 -> Infinity
+dqmax092 max Inf -1 -> Infinity
+dqmax093 max Inf -0 -> Infinity
+dqmax094 max Inf 0 -> Infinity
+dqmax095 max Inf 1 -> Infinity
+dqmax096 max Inf 1000 -> Infinity
+dqmax097 max Inf Inf -> Infinity
+dqmax098 max -1000 Inf -> Infinity
+dqmax099 max -Inf Inf -> Infinity
+dqmax100 max -1 Inf -> Infinity
+dqmax101 max -0 Inf -> Infinity
+dqmax102 max 0 Inf -> Infinity
+dqmax103 max 1 Inf -> Infinity
+dqmax104 max 1000 Inf -> Infinity
+dqmax105 max Inf Inf -> Infinity
+
+dqmax120 max -Inf -Inf -> -Infinity
+dqmax121 max -Inf -1000 -> -1000
+dqmax122 max -Inf -1 -> -1
+dqmax123 max -Inf -0 -> -0
+dqmax124 max -Inf 0 -> 0
+dqmax125 max -Inf 1 -> 1
+dqmax126 max -Inf 1000 -> 1000
+dqmax127 max -Inf Inf -> Infinity
+dqmax128 max -Inf -Inf -> -Infinity
+dqmax129 max -1000 -Inf -> -1000
+dqmax130 max -1 -Inf -> -1
+dqmax131 max -0 -Inf -> -0
+dqmax132 max 0 -Inf -> 0
+dqmax133 max 1 -Inf -> 1
+dqmax134 max 1000 -Inf -> 1000
+dqmax135 max Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+dqmax141 max NaN -Inf -> -Infinity
+dqmax142 max NaN -1000 -> -1000
+dqmax143 max NaN -1 -> -1
+dqmax144 max NaN -0 -> -0
+dqmax145 max NaN 0 -> 0
+dqmax146 max NaN 1 -> 1
+dqmax147 max NaN 1000 -> 1000
+dqmax148 max NaN Inf -> Infinity
+dqmax149 max NaN NaN -> NaN
+dqmax150 max -Inf NaN -> -Infinity
+dqmax151 max -1000 NaN -> -1000
+dqmax152 max -1 NaN -> -1
+dqmax153 max -0 NaN -> -0
+dqmax154 max 0 NaN -> 0
+dqmax155 max 1 NaN -> 1
+dqmax156 max 1000 NaN -> 1000
+dqmax157 max Inf NaN -> Infinity
+
+dqmax161 max sNaN -Inf -> NaN Invalid_operation
+dqmax162 max sNaN -1000 -> NaN Invalid_operation
+dqmax163 max sNaN -1 -> NaN Invalid_operation
+dqmax164 max sNaN -0 -> NaN Invalid_operation
+dqmax165 max sNaN 0 -> NaN Invalid_operation
+dqmax166 max sNaN 1 -> NaN Invalid_operation
+dqmax167 max sNaN 1000 -> NaN Invalid_operation
+dqmax168 max sNaN NaN -> NaN Invalid_operation
+dqmax169 max sNaN sNaN -> NaN Invalid_operation
+dqmax170 max NaN sNaN -> NaN Invalid_operation
+dqmax171 max -Inf sNaN -> NaN Invalid_operation
+dqmax172 max -1000 sNaN -> NaN Invalid_operation
+dqmax173 max -1 sNaN -> NaN Invalid_operation
+dqmax174 max -0 sNaN -> NaN Invalid_operation
+dqmax175 max 0 sNaN -> NaN Invalid_operation
+dqmax176 max 1 sNaN -> NaN Invalid_operation
+dqmax177 max 1000 sNaN -> NaN Invalid_operation
+dqmax178 max Inf sNaN -> NaN Invalid_operation
+dqmax179 max NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmax181 max NaN9 -Inf -> -Infinity
+dqmax182 max NaN8 9 -> 9
+dqmax183 max -NaN7 Inf -> Infinity
+
+dqmax184 max -NaN1 NaN11 -> -NaN1
+dqmax185 max NaN2 NaN12 -> NaN2
+dqmax186 max -NaN13 -NaN7 -> -NaN13
+dqmax187 max NaN14 -NaN5 -> NaN14
+
+dqmax188 max -Inf NaN4 -> -Infinity
+dqmax189 max -9 -NaN3 -> -9
+dqmax190 max Inf NaN2 -> Infinity
+
+dqmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
+dqmax192 max sNaN98 -1 -> NaN98 Invalid_operation
+dqmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
+dqmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
+dqmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
+dqmax197 max 0 sNaN91 -> NaN91 Invalid_operation
+dqmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmax199 max NaN sNaN89 -> NaN89 Invalid_operation
+
+-- old rounding checks
+dqmax221 max 12345678000 1 -> 12345678000
+dqmax222 max 1 12345678000 -> 12345678000
+dqmax223 max 1234567800 1 -> 1234567800
+dqmax224 max 1 1234567800 -> 1234567800
+dqmax225 max 1234567890 1 -> 1234567890
+dqmax226 max 1 1234567890 -> 1234567890
+dqmax227 max 1234567891 1 -> 1234567891
+dqmax228 max 1 1234567891 -> 1234567891
+dqmax229 max 12345678901 1 -> 12345678901
+dqmax230 max 1 12345678901 -> 12345678901
+dqmax231 max 1234567896 1 -> 1234567896
+dqmax232 max 1 1234567896 -> 1234567896
+dqmax233 max -1234567891 1 -> 1
+dqmax234 max 1 -1234567891 -> 1
+dqmax235 max -12345678901 1 -> 1
+dqmax236 max 1 -12345678901 -> 1
+dqmax237 max -1234567896 1 -> 1
+dqmax238 max 1 -1234567896 -> 1
+
+-- from examples
+dqmax280 max '3' '2' -> '3'
+dqmax281 max '-10' '3' -> '3'
+dqmax282 max '1.0' '1' -> '1'
+dqmax283 max '1' '1.0' -> '1'
+dqmax284 max '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+dqmax401 max Inf 1.1 -> Infinity
+dqmax402 max 1.1 1 -> 1.1
+dqmax403 max 1 1.0 -> 1
+dqmax404 max 1.0 0.1 -> 1.0
+dqmax405 max 0.1 0.10 -> 0.1
+dqmax406 max 0.10 0.100 -> 0.10
+dqmax407 max 0.10 0 -> 0.10
+dqmax408 max 0 0.0 -> 0
+dqmax409 max 0.0 -0 -> 0.0
+dqmax410 max 0.0 -0.0 -> 0.0
+dqmax411 max 0.00 -0.0 -> 0.00
+dqmax412 max 0.0 -0.00 -> 0.0
+dqmax413 max 0 -0.0 -> 0
+dqmax414 max 0 -0 -> 0
+dqmax415 max -0.0 -0 -> -0.0
+dqmax416 max -0 -0.100 -> -0
+dqmax417 max -0.100 -0.10 -> -0.100
+dqmax418 max -0.10 -0.1 -> -0.10
+dqmax419 max -0.1 -1.0 -> -0.1
+dqmax420 max -1.0 -1 -> -1.0
+dqmax421 max -1 -1.1 -> -1
+dqmax423 max -1.1 -Inf -> -1.1
+-- same with operands reversed
+dqmax431 max 1.1 Inf -> Infinity
+dqmax432 max 1 1.1 -> 1.1
+dqmax433 max 1.0 1 -> 1
+dqmax434 max 0.1 1.0 -> 1.0
+dqmax435 max 0.10 0.1 -> 0.1
+dqmax436 max 0.100 0.10 -> 0.10
+dqmax437 max 0 0.10 -> 0.10
+dqmax438 max 0.0 0 -> 0
+dqmax439 max -0 0.0 -> 0.0
+dqmax440 max -0.0 0.0 -> 0.0
+dqmax441 max -0.0 0.00 -> 0.00
+dqmax442 max -0.00 0.0 -> 0.0
+dqmax443 max -0.0 0 -> 0
+dqmax444 max -0 0 -> 0
+dqmax445 max -0 -0.0 -> -0.0
+dqmax446 max -0.100 -0 -> -0
+dqmax447 max -0.10 -0.100 -> -0.100
+dqmax448 max -0.1 -0.10 -> -0.10
+dqmax449 max -1.0 -0.1 -> -0.1
+dqmax450 max -1 -1.0 -> -1.0
+dqmax451 max -1.1 -1 -> -1
+dqmax453 max -Inf -1.1 -> -1.1
+-- largies
+dqmax460 max 1000 1E+3 -> 1E+3
+dqmax461 max 1E+3 1000 -> 1E+3
+dqmax462 max 1000 -1E+3 -> 1000
+dqmax463 max 1E+3 -1000 -> 1E+3
+dqmax464 max -1000 1E+3 -> 1E+3
+dqmax465 max -1E+3 1000 -> 1000
+dqmax466 max -1000 -1E+3 -> -1000
+dqmax467 max -1E+3 -1000 -> -1000
+
+-- misalignment traps for little-endian
+dqmax471 max 1.0 0.1 -> 1.0
+dqmax472 max 0.1 1.0 -> 1.0
+dqmax473 max 10.0 0.1 -> 10.0
+dqmax474 max 0.1 10.0 -> 10.0
+dqmax475 max 100 1.0 -> 100
+dqmax476 max 1.0 100 -> 100
+dqmax477 max 1000 10.0 -> 1000
+dqmax478 max 10.0 1000 -> 1000
+dqmax479 max 10000 100.0 -> 10000
+dqmax480 max 100.0 10000 -> 10000
+dqmax481 max 100000 1000.0 -> 100000
+dqmax482 max 1000.0 100000 -> 100000
+dqmax483 max 1000000 10000.0 -> 1000000
+dqmax484 max 10000.0 1000000 -> 1000000
+
+-- subnormals
+dqmax510 max 1.00E-6143 0 -> 1.00E-6143
+dqmax511 max 0.1E-6143 0 -> 1E-6144 Subnormal
+dqmax512 max 0.10E-6143 0 -> 1.0E-6144 Subnormal
+dqmax513 max 0.100E-6143 0 -> 1.00E-6144 Subnormal
+dqmax514 max 0.01E-6143 0 -> 1E-6145 Subnormal
+dqmax515 max 0.999E-6143 0 -> 9.99E-6144 Subnormal
+dqmax516 max 0.099E-6143 0 -> 9.9E-6145 Subnormal
+dqmax517 max 0.009E-6143 0 -> 9E-6146 Subnormal
+dqmax518 max 0.001E-6143 0 -> 1E-6146 Subnormal
+dqmax519 max 0.0009E-6143 0 -> 9E-6147 Subnormal
+dqmax520 max 0.0001E-6143 0 -> 1E-6147 Subnormal
+
+dqmax530 max -1.00E-6143 0 -> 0
+dqmax531 max -0.1E-6143 0 -> 0
+dqmax532 max -0.10E-6143 0 -> 0
+dqmax533 max -0.100E-6143 0 -> 0
+dqmax534 max -0.01E-6143 0 -> 0
+dqmax535 max -0.999E-6143 0 -> 0
+dqmax536 max -0.099E-6143 0 -> 0
+dqmax537 max -0.009E-6143 0 -> 0
+dqmax538 max -0.001E-6143 0 -> 0
+dqmax539 max -0.0009E-6143 0 -> 0
+dqmax540 max -0.0001E-6143 0 -> 0
+
+-- Null tests
+dqmax900 max 10 # -> NaN Invalid_operation
+dqmax901 max # 10 -> NaN Invalid_operation
+
+
+
diff --git a/Lib/test/decimaltestdata/dqMaxMag.decTest b/Lib/test/decimaltestdata/dqMaxMag.decTest
index 6621e80d92..6f5be24609 100644
--- a/Lib/test/decimaltestdata/dqMaxMag.decTest
+++ b/Lib/test/decimaltestdata/dqMaxMag.decTest
@@ -1,304 +1,304 @@
-------------------------------------------------------------------------
--- dqMaxMag.decTest -- decQuad maxnummag --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmxg001 maxmag -2 -2 -> -2
-dqmxg002 maxmag -2 -1 -> -2
-dqmxg003 maxmag -2 0 -> -2
-dqmxg004 maxmag -2 1 -> -2
-dqmxg005 maxmag -2 2 -> 2
-dqmxg006 maxmag -1 -2 -> -2
-dqmxg007 maxmag -1 -1 -> -1
-dqmxg008 maxmag -1 0 -> -1
-dqmxg009 maxmag -1 1 -> 1
-dqmxg010 maxmag -1 2 -> 2
-dqmxg011 maxmag 0 -2 -> -2
-dqmxg012 maxmag 0 -1 -> -1
-dqmxg013 maxmag 0 0 -> 0
-dqmxg014 maxmag 0 1 -> 1
-dqmxg015 maxmag 0 2 -> 2
-dqmxg016 maxmag 1 -2 -> -2
-dqmxg017 maxmag 1 -1 -> 1
-dqmxg018 maxmag 1 0 -> 1
-dqmxg019 maxmag 1 1 -> 1
-dqmxg020 maxmag 1 2 -> 2
-dqmxg021 maxmag 2 -2 -> 2
-dqmxg022 maxmag 2 -1 -> 2
-dqmxg023 maxmag 2 0 -> 2
-dqmxg025 maxmag 2 1 -> 2
-dqmxg026 maxmag 2 2 -> 2
-
--- extended zeros
-dqmxg030 maxmag 0 0 -> 0
-dqmxg031 maxmag 0 -0 -> 0
-dqmxg032 maxmag 0 -0.0 -> 0
-dqmxg033 maxmag 0 0.0 -> 0
-dqmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-dqmxg035 maxmag -0 -0 -> -0
-dqmxg036 maxmag -0 -0.0 -> -0.0
-dqmxg037 maxmag -0 0.0 -> 0.0
-dqmxg038 maxmag 0.0 0 -> 0
-dqmxg039 maxmag 0.0 -0 -> 0.0
-dqmxg040 maxmag 0.0 -0.0 -> 0.0
-dqmxg041 maxmag 0.0 0.0 -> 0.0
-dqmxg042 maxmag -0.0 0 -> 0
-dqmxg043 maxmag -0.0 -0 -> -0.0
-dqmxg044 maxmag -0.0 -0.0 -> -0.0
-dqmxg045 maxmag -0.0 0.0 -> 0.0
-
-dqmxg050 maxmag -0E1 0E1 -> 0E+1
-dqmxg051 maxmag -0E2 0E2 -> 0E+2
-dqmxg052 maxmag -0E2 0E1 -> 0E+1
-dqmxg053 maxmag -0E1 0E2 -> 0E+2
-dqmxg054 maxmag 0E1 -0E1 -> 0E+1
-dqmxg055 maxmag 0E2 -0E2 -> 0E+2
-dqmxg056 maxmag 0E2 -0E1 -> 0E+2
-dqmxg057 maxmag 0E1 -0E2 -> 0E+1
-
-dqmxg058 maxmag 0E1 0E1 -> 0E+1
-dqmxg059 maxmag 0E2 0E2 -> 0E+2
-dqmxg060 maxmag 0E2 0E1 -> 0E+2
-dqmxg061 maxmag 0E1 0E2 -> 0E+2
-dqmxg062 maxmag -0E1 -0E1 -> -0E+1
-dqmxg063 maxmag -0E2 -0E2 -> -0E+2
-dqmxg064 maxmag -0E2 -0E1 -> -0E+1
-dqmxg065 maxmag -0E1 -0E2 -> -0E+1
-
--- Specials
-dqmxg090 maxmag Inf -Inf -> Infinity
-dqmxg091 maxmag Inf -1000 -> Infinity
-dqmxg092 maxmag Inf -1 -> Infinity
-dqmxg093 maxmag Inf -0 -> Infinity
-dqmxg094 maxmag Inf 0 -> Infinity
-dqmxg095 maxmag Inf 1 -> Infinity
-dqmxg096 maxmag Inf 1000 -> Infinity
-dqmxg097 maxmag Inf Inf -> Infinity
-dqmxg098 maxmag -1000 Inf -> Infinity
-dqmxg099 maxmag -Inf Inf -> Infinity
-dqmxg100 maxmag -1 Inf -> Infinity
-dqmxg101 maxmag -0 Inf -> Infinity
-dqmxg102 maxmag 0 Inf -> Infinity
-dqmxg103 maxmag 1 Inf -> Infinity
-dqmxg104 maxmag 1000 Inf -> Infinity
-dqmxg105 maxmag Inf Inf -> Infinity
-
-dqmxg120 maxmag -Inf -Inf -> -Infinity
-dqmxg121 maxmag -Inf -1000 -> -Infinity
-dqmxg122 maxmag -Inf -1 -> -Infinity
-dqmxg123 maxmag -Inf -0 -> -Infinity
-dqmxg124 maxmag -Inf 0 -> -Infinity
-dqmxg125 maxmag -Inf 1 -> -Infinity
-dqmxg126 maxmag -Inf 1000 -> -Infinity
-dqmxg127 maxmag -Inf Inf -> Infinity
-dqmxg128 maxmag -Inf -Inf -> -Infinity
-dqmxg129 maxmag -1000 -Inf -> -Infinity
-dqmxg130 maxmag -1 -Inf -> -Infinity
-dqmxg131 maxmag -0 -Inf -> -Infinity
-dqmxg132 maxmag 0 -Inf -> -Infinity
-dqmxg133 maxmag 1 -Inf -> -Infinity
-dqmxg134 maxmag 1000 -Inf -> -Infinity
-dqmxg135 maxmag Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-dqmxg141 maxmag NaN -Inf -> -Infinity
-dqmxg142 maxmag NaN -1000 -> -1000
-dqmxg143 maxmag NaN -1 -> -1
-dqmxg144 maxmag NaN -0 -> -0
-dqmxg145 maxmag NaN 0 -> 0
-dqmxg146 maxmag NaN 1 -> 1
-dqmxg147 maxmag NaN 1000 -> 1000
-dqmxg148 maxmag NaN Inf -> Infinity
-dqmxg149 maxmag NaN NaN -> NaN
-dqmxg150 maxmag -Inf NaN -> -Infinity
-dqmxg151 maxmag -1000 NaN -> -1000
-dqmxg152 maxmag -1 NaN -> -1
-dqmxg153 maxmag -0 NaN -> -0
-dqmxg154 maxmag 0 NaN -> 0
-dqmxg155 maxmag 1 NaN -> 1
-dqmxg156 maxmag 1000 NaN -> 1000
-dqmxg157 maxmag Inf NaN -> Infinity
-
-dqmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
-dqmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
-dqmxg163 maxmag sNaN -1 -> NaN Invalid_operation
-dqmxg164 maxmag sNaN -0 -> NaN Invalid_operation
-dqmxg165 maxmag sNaN 0 -> NaN Invalid_operation
-dqmxg166 maxmag sNaN 1 -> NaN Invalid_operation
-dqmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
-dqmxg168 maxmag sNaN NaN -> NaN Invalid_operation
-dqmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
-dqmxg170 maxmag NaN sNaN -> NaN Invalid_operation
-dqmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
-dqmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
-dqmxg173 maxmag -1 sNaN -> NaN Invalid_operation
-dqmxg174 maxmag -0 sNaN -> NaN Invalid_operation
-dqmxg175 maxmag 0 sNaN -> NaN Invalid_operation
-dqmxg176 maxmag 1 sNaN -> NaN Invalid_operation
-dqmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
-dqmxg178 maxmag Inf sNaN -> NaN Invalid_operation
-dqmxg179 maxmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmxg181 maxmag NaN9 -Inf -> -Infinity
-dqmxg182 maxmag NaN8 9 -> 9
-dqmxg183 maxmag -NaN7 Inf -> Infinity
-
-dqmxg184 maxmag -NaN1 NaN11 -> -NaN1
-dqmxg185 maxmag NaN2 NaN12 -> NaN2
-dqmxg186 maxmag -NaN13 -NaN7 -> -NaN13
-dqmxg187 maxmag NaN14 -NaN5 -> NaN14
-
-dqmxg188 maxmag -Inf NaN4 -> -Infinity
-dqmxg189 maxmag -9 -NaN3 -> -9
-dqmxg190 maxmag Inf NaN2 -> Infinity
-
-dqmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
-dqmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
-dqmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
-dqmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
-dqmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
-dqmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
-dqmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
-
--- old rounding checks
-dqmxg221 maxmag 12345678000 1 -> 12345678000
-dqmxg222 maxmag 1 12345678000 -> 12345678000
-dqmxg223 maxmag 1234567800 1 -> 1234567800
-dqmxg224 maxmag 1 1234567800 -> 1234567800
-dqmxg225 maxmag 1234567890 1 -> 1234567890
-dqmxg226 maxmag 1 1234567890 -> 1234567890
-dqmxg227 maxmag 1234567891 1 -> 1234567891
-dqmxg228 maxmag 1 1234567891 -> 1234567891
-dqmxg229 maxmag 12345678901 1 -> 12345678901
-dqmxg230 maxmag 1 12345678901 -> 12345678901
-dqmxg231 maxmag 1234567896 1 -> 1234567896
-dqmxg232 maxmag 1 1234567896 -> 1234567896
-dqmxg233 maxmag -1234567891 1 -> -1234567891
-dqmxg234 maxmag 1 -1234567891 -> -1234567891
-dqmxg235 maxmag -12345678901 1 -> -12345678901
-dqmxg236 maxmag 1 -12345678901 -> -12345678901
-dqmxg237 maxmag -1234567896 1 -> -1234567896
-dqmxg238 maxmag 1 -1234567896 -> -1234567896
-
--- from examples
-dqmxg280 maxmag '3' '2' -> '3'
-dqmxg281 maxmag '-10' '3' -> '-10'
-dqmxg282 maxmag '1.0' '1' -> '1'
-dqmxg283 maxmag '1' '1.0' -> '1'
-dqmxg284 maxmag '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-dqmxg401 maxmag Inf 1.1 -> Infinity
-dqmxg402 maxmag 1.1 1 -> 1.1
-dqmxg403 maxmag 1 1.0 -> 1
-dqmxg404 maxmag 1.0 0.1 -> 1.0
-dqmxg405 maxmag 0.1 0.10 -> 0.1
-dqmxg406 maxmag 0.10 0.100 -> 0.10
-dqmxg407 maxmag 0.10 0 -> 0.10
-dqmxg408 maxmag 0 0.0 -> 0
-dqmxg409 maxmag 0.0 -0 -> 0.0
-dqmxg410 maxmag 0.0 -0.0 -> 0.0
-dqmxg411 maxmag 0.00 -0.0 -> 0.00
-dqmxg412 maxmag 0.0 -0.00 -> 0.0
-dqmxg413 maxmag 0 -0.0 -> 0
-dqmxg414 maxmag 0 -0 -> 0
-dqmxg415 maxmag -0.0 -0 -> -0.0
-dqmxg416 maxmag -0 -0.100 -> -0.100
-dqmxg417 maxmag -0.100 -0.10 -> -0.100
-dqmxg418 maxmag -0.10 -0.1 -> -0.10
-dqmxg419 maxmag -0.1 -1.0 -> -1.0
-dqmxg420 maxmag -1.0 -1 -> -1.0
-dqmxg421 maxmag -1 -1.1 -> -1.1
-dqmxg423 maxmag -1.1 -Inf -> -Infinity
--- same with operands reversed
-dqmxg431 maxmag 1.1 Inf -> Infinity
-dqmxg432 maxmag 1 1.1 -> 1.1
-dqmxg433 maxmag 1.0 1 -> 1
-dqmxg434 maxmag 0.1 1.0 -> 1.0
-dqmxg435 maxmag 0.10 0.1 -> 0.1
-dqmxg436 maxmag 0.100 0.10 -> 0.10
-dqmxg437 maxmag 0 0.10 -> 0.10
-dqmxg438 maxmag 0.0 0 -> 0
-dqmxg439 maxmag -0 0.0 -> 0.0
-dqmxg440 maxmag -0.0 0.0 -> 0.0
-dqmxg441 maxmag -0.0 0.00 -> 0.00
-dqmxg442 maxmag -0.00 0.0 -> 0.0
-dqmxg443 maxmag -0.0 0 -> 0
-dqmxg444 maxmag -0 0 -> 0
-dqmxg445 maxmag -0 -0.0 -> -0.0
-dqmxg446 maxmag -0.100 -0 -> -0.100
-dqmxg447 maxmag -0.10 -0.100 -> -0.100
-dqmxg448 maxmag -0.1 -0.10 -> -0.10
-dqmxg449 maxmag -1.0 -0.1 -> -1.0
-dqmxg450 maxmag -1 -1.0 -> -1.0
-dqmxg451 maxmag -1.1 -1 -> -1.1
-dqmxg453 maxmag -Inf -1.1 -> -Infinity
--- largies
-dqmxg460 maxmag 1000 1E+3 -> 1E+3
-dqmxg461 maxmag 1E+3 1000 -> 1E+3
-dqmxg462 maxmag 1000 -1E+3 -> 1000
-dqmxg463 maxmag 1E+3 -1000 -> 1E+3
-dqmxg464 maxmag -1000 1E+3 -> 1E+3
-dqmxg465 maxmag -1E+3 1000 -> 1000
-dqmxg466 maxmag -1000 -1E+3 -> -1000
-dqmxg467 maxmag -1E+3 -1000 -> -1000
-
--- subnormals
-dqmxg510 maxmag 1.00E-6143 0 -> 1.00E-6143
-dqmxg511 maxmag 0.1E-6143 0 -> 1E-6144 Subnormal
-dqmxg512 maxmag 0.10E-6143 0 -> 1.0E-6144 Subnormal
-dqmxg513 maxmag 0.100E-6143 0 -> 1.00E-6144 Subnormal
-dqmxg514 maxmag 0.01E-6143 0 -> 1E-6145 Subnormal
-dqmxg515 maxmag 0.999E-6143 0 -> 9.99E-6144 Subnormal
-dqmxg516 maxmag 0.099E-6143 0 -> 9.9E-6145 Subnormal
-dqmxg517 maxmag 0.009E-6143 0 -> 9E-6146 Subnormal
-dqmxg518 maxmag 0.001E-6143 0 -> 1E-6146 Subnormal
-dqmxg519 maxmag 0.0009E-6143 0 -> 9E-6147 Subnormal
-dqmxg520 maxmag 0.0001E-6143 0 -> 1E-6147 Subnormal
-
-dqmxg530 maxmag -1.00E-6143 0 -> -1.00E-6143
-dqmxg531 maxmag -0.1E-6143 0 -> -1E-6144 Subnormal
-dqmxg532 maxmag -0.10E-6143 0 -> -1.0E-6144 Subnormal
-dqmxg533 maxmag -0.100E-6143 0 -> -1.00E-6144 Subnormal
-dqmxg534 maxmag -0.01E-6143 0 -> -1E-6145 Subnormal
-dqmxg535 maxmag -0.999E-6143 0 -> -9.99E-6144 Subnormal
-dqmxg536 maxmag -0.099E-6143 0 -> -9.9E-6145 Subnormal
-dqmxg537 maxmag -0.009E-6143 0 -> -9E-6146 Subnormal
-dqmxg538 maxmag -0.001E-6143 0 -> -1E-6146 Subnormal
-dqmxg539 maxmag -0.0009E-6143 0 -> -9E-6147 Subnormal
-dqmxg540 maxmag -0.0001E-6143 0 -> -1E-6147 Subnormal
-
--- Null tests
-dqmxg900 maxmag 10 # -> NaN Invalid_operation
-dqmxg901 maxmag # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqMaxMag.decTest -- decQuad maxnummag --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmxg001 maxmag -2 -2 -> -2
+dqmxg002 maxmag -2 -1 -> -2
+dqmxg003 maxmag -2 0 -> -2
+dqmxg004 maxmag -2 1 -> -2
+dqmxg005 maxmag -2 2 -> 2
+dqmxg006 maxmag -1 -2 -> -2
+dqmxg007 maxmag -1 -1 -> -1
+dqmxg008 maxmag -1 0 -> -1
+dqmxg009 maxmag -1 1 -> 1
+dqmxg010 maxmag -1 2 -> 2
+dqmxg011 maxmag 0 -2 -> -2
+dqmxg012 maxmag 0 -1 -> -1
+dqmxg013 maxmag 0 0 -> 0
+dqmxg014 maxmag 0 1 -> 1
+dqmxg015 maxmag 0 2 -> 2
+dqmxg016 maxmag 1 -2 -> -2
+dqmxg017 maxmag 1 -1 -> 1
+dqmxg018 maxmag 1 0 -> 1
+dqmxg019 maxmag 1 1 -> 1
+dqmxg020 maxmag 1 2 -> 2
+dqmxg021 maxmag 2 -2 -> 2
+dqmxg022 maxmag 2 -1 -> 2
+dqmxg023 maxmag 2 0 -> 2
+dqmxg025 maxmag 2 1 -> 2
+dqmxg026 maxmag 2 2 -> 2
+
+-- extended zeros
+dqmxg030 maxmag 0 0 -> 0
+dqmxg031 maxmag 0 -0 -> 0
+dqmxg032 maxmag 0 -0.0 -> 0
+dqmxg033 maxmag 0 0.0 -> 0
+dqmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+dqmxg035 maxmag -0 -0 -> -0
+dqmxg036 maxmag -0 -0.0 -> -0.0
+dqmxg037 maxmag -0 0.0 -> 0.0
+dqmxg038 maxmag 0.0 0 -> 0
+dqmxg039 maxmag 0.0 -0 -> 0.0
+dqmxg040 maxmag 0.0 -0.0 -> 0.0
+dqmxg041 maxmag 0.0 0.0 -> 0.0
+dqmxg042 maxmag -0.0 0 -> 0
+dqmxg043 maxmag -0.0 -0 -> -0.0
+dqmxg044 maxmag -0.0 -0.0 -> -0.0
+dqmxg045 maxmag -0.0 0.0 -> 0.0
+
+dqmxg050 maxmag -0E1 0E1 -> 0E+1
+dqmxg051 maxmag -0E2 0E2 -> 0E+2
+dqmxg052 maxmag -0E2 0E1 -> 0E+1
+dqmxg053 maxmag -0E1 0E2 -> 0E+2
+dqmxg054 maxmag 0E1 -0E1 -> 0E+1
+dqmxg055 maxmag 0E2 -0E2 -> 0E+2
+dqmxg056 maxmag 0E2 -0E1 -> 0E+2
+dqmxg057 maxmag 0E1 -0E2 -> 0E+1
+
+dqmxg058 maxmag 0E1 0E1 -> 0E+1
+dqmxg059 maxmag 0E2 0E2 -> 0E+2
+dqmxg060 maxmag 0E2 0E1 -> 0E+2
+dqmxg061 maxmag 0E1 0E2 -> 0E+2
+dqmxg062 maxmag -0E1 -0E1 -> -0E+1
+dqmxg063 maxmag -0E2 -0E2 -> -0E+2
+dqmxg064 maxmag -0E2 -0E1 -> -0E+1
+dqmxg065 maxmag -0E1 -0E2 -> -0E+1
+
+-- Specials
+dqmxg090 maxmag Inf -Inf -> Infinity
+dqmxg091 maxmag Inf -1000 -> Infinity
+dqmxg092 maxmag Inf -1 -> Infinity
+dqmxg093 maxmag Inf -0 -> Infinity
+dqmxg094 maxmag Inf 0 -> Infinity
+dqmxg095 maxmag Inf 1 -> Infinity
+dqmxg096 maxmag Inf 1000 -> Infinity
+dqmxg097 maxmag Inf Inf -> Infinity
+dqmxg098 maxmag -1000 Inf -> Infinity
+dqmxg099 maxmag -Inf Inf -> Infinity
+dqmxg100 maxmag -1 Inf -> Infinity
+dqmxg101 maxmag -0 Inf -> Infinity
+dqmxg102 maxmag 0 Inf -> Infinity
+dqmxg103 maxmag 1 Inf -> Infinity
+dqmxg104 maxmag 1000 Inf -> Infinity
+dqmxg105 maxmag Inf Inf -> Infinity
+
+dqmxg120 maxmag -Inf -Inf -> -Infinity
+dqmxg121 maxmag -Inf -1000 -> -Infinity
+dqmxg122 maxmag -Inf -1 -> -Infinity
+dqmxg123 maxmag -Inf -0 -> -Infinity
+dqmxg124 maxmag -Inf 0 -> -Infinity
+dqmxg125 maxmag -Inf 1 -> -Infinity
+dqmxg126 maxmag -Inf 1000 -> -Infinity
+dqmxg127 maxmag -Inf Inf -> Infinity
+dqmxg128 maxmag -Inf -Inf -> -Infinity
+dqmxg129 maxmag -1000 -Inf -> -Infinity
+dqmxg130 maxmag -1 -Inf -> -Infinity
+dqmxg131 maxmag -0 -Inf -> -Infinity
+dqmxg132 maxmag 0 -Inf -> -Infinity
+dqmxg133 maxmag 1 -Inf -> -Infinity
+dqmxg134 maxmag 1000 -Inf -> -Infinity
+dqmxg135 maxmag Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+dqmxg141 maxmag NaN -Inf -> -Infinity
+dqmxg142 maxmag NaN -1000 -> -1000
+dqmxg143 maxmag NaN -1 -> -1
+dqmxg144 maxmag NaN -0 -> -0
+dqmxg145 maxmag NaN 0 -> 0
+dqmxg146 maxmag NaN 1 -> 1
+dqmxg147 maxmag NaN 1000 -> 1000
+dqmxg148 maxmag NaN Inf -> Infinity
+dqmxg149 maxmag NaN NaN -> NaN
+dqmxg150 maxmag -Inf NaN -> -Infinity
+dqmxg151 maxmag -1000 NaN -> -1000
+dqmxg152 maxmag -1 NaN -> -1
+dqmxg153 maxmag -0 NaN -> -0
+dqmxg154 maxmag 0 NaN -> 0
+dqmxg155 maxmag 1 NaN -> 1
+dqmxg156 maxmag 1000 NaN -> 1000
+dqmxg157 maxmag Inf NaN -> Infinity
+
+dqmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
+dqmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
+dqmxg163 maxmag sNaN -1 -> NaN Invalid_operation
+dqmxg164 maxmag sNaN -0 -> NaN Invalid_operation
+dqmxg165 maxmag sNaN 0 -> NaN Invalid_operation
+dqmxg166 maxmag sNaN 1 -> NaN Invalid_operation
+dqmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
+dqmxg168 maxmag sNaN NaN -> NaN Invalid_operation
+dqmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
+dqmxg170 maxmag NaN sNaN -> NaN Invalid_operation
+dqmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
+dqmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
+dqmxg173 maxmag -1 sNaN -> NaN Invalid_operation
+dqmxg174 maxmag -0 sNaN -> NaN Invalid_operation
+dqmxg175 maxmag 0 sNaN -> NaN Invalid_operation
+dqmxg176 maxmag 1 sNaN -> NaN Invalid_operation
+dqmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
+dqmxg178 maxmag Inf sNaN -> NaN Invalid_operation
+dqmxg179 maxmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmxg181 maxmag NaN9 -Inf -> -Infinity
+dqmxg182 maxmag NaN8 9 -> 9
+dqmxg183 maxmag -NaN7 Inf -> Infinity
+
+dqmxg184 maxmag -NaN1 NaN11 -> -NaN1
+dqmxg185 maxmag NaN2 NaN12 -> NaN2
+dqmxg186 maxmag -NaN13 -NaN7 -> -NaN13
+dqmxg187 maxmag NaN14 -NaN5 -> NaN14
+
+dqmxg188 maxmag -Inf NaN4 -> -Infinity
+dqmxg189 maxmag -9 -NaN3 -> -9
+dqmxg190 maxmag Inf NaN2 -> Infinity
+
+dqmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
+dqmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
+dqmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
+dqmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
+dqmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
+dqmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
+dqmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
+
+-- old rounding checks
+dqmxg221 maxmag 12345678000 1 -> 12345678000
+dqmxg222 maxmag 1 12345678000 -> 12345678000
+dqmxg223 maxmag 1234567800 1 -> 1234567800
+dqmxg224 maxmag 1 1234567800 -> 1234567800
+dqmxg225 maxmag 1234567890 1 -> 1234567890
+dqmxg226 maxmag 1 1234567890 -> 1234567890
+dqmxg227 maxmag 1234567891 1 -> 1234567891
+dqmxg228 maxmag 1 1234567891 -> 1234567891
+dqmxg229 maxmag 12345678901 1 -> 12345678901
+dqmxg230 maxmag 1 12345678901 -> 12345678901
+dqmxg231 maxmag 1234567896 1 -> 1234567896
+dqmxg232 maxmag 1 1234567896 -> 1234567896
+dqmxg233 maxmag -1234567891 1 -> -1234567891
+dqmxg234 maxmag 1 -1234567891 -> -1234567891
+dqmxg235 maxmag -12345678901 1 -> -12345678901
+dqmxg236 maxmag 1 -12345678901 -> -12345678901
+dqmxg237 maxmag -1234567896 1 -> -1234567896
+dqmxg238 maxmag 1 -1234567896 -> -1234567896
+
+-- from examples
+dqmxg280 maxmag '3' '2' -> '3'
+dqmxg281 maxmag '-10' '3' -> '-10'
+dqmxg282 maxmag '1.0' '1' -> '1'
+dqmxg283 maxmag '1' '1.0' -> '1'
+dqmxg284 maxmag '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+dqmxg401 maxmag Inf 1.1 -> Infinity
+dqmxg402 maxmag 1.1 1 -> 1.1
+dqmxg403 maxmag 1 1.0 -> 1
+dqmxg404 maxmag 1.0 0.1 -> 1.0
+dqmxg405 maxmag 0.1 0.10 -> 0.1
+dqmxg406 maxmag 0.10 0.100 -> 0.10
+dqmxg407 maxmag 0.10 0 -> 0.10
+dqmxg408 maxmag 0 0.0 -> 0
+dqmxg409 maxmag 0.0 -0 -> 0.0
+dqmxg410 maxmag 0.0 -0.0 -> 0.0
+dqmxg411 maxmag 0.00 -0.0 -> 0.00
+dqmxg412 maxmag 0.0 -0.00 -> 0.0
+dqmxg413 maxmag 0 -0.0 -> 0
+dqmxg414 maxmag 0 -0 -> 0
+dqmxg415 maxmag -0.0 -0 -> -0.0
+dqmxg416 maxmag -0 -0.100 -> -0.100
+dqmxg417 maxmag -0.100 -0.10 -> -0.100
+dqmxg418 maxmag -0.10 -0.1 -> -0.10
+dqmxg419 maxmag -0.1 -1.0 -> -1.0
+dqmxg420 maxmag -1.0 -1 -> -1.0
+dqmxg421 maxmag -1 -1.1 -> -1.1
+dqmxg423 maxmag -1.1 -Inf -> -Infinity
+-- same with operands reversed
+dqmxg431 maxmag 1.1 Inf -> Infinity
+dqmxg432 maxmag 1 1.1 -> 1.1
+dqmxg433 maxmag 1.0 1 -> 1
+dqmxg434 maxmag 0.1 1.0 -> 1.0
+dqmxg435 maxmag 0.10 0.1 -> 0.1
+dqmxg436 maxmag 0.100 0.10 -> 0.10
+dqmxg437 maxmag 0 0.10 -> 0.10
+dqmxg438 maxmag 0.0 0 -> 0
+dqmxg439 maxmag -0 0.0 -> 0.0
+dqmxg440 maxmag -0.0 0.0 -> 0.0
+dqmxg441 maxmag -0.0 0.00 -> 0.00
+dqmxg442 maxmag -0.00 0.0 -> 0.0
+dqmxg443 maxmag -0.0 0 -> 0
+dqmxg444 maxmag -0 0 -> 0
+dqmxg445 maxmag -0 -0.0 -> -0.0
+dqmxg446 maxmag -0.100 -0 -> -0.100
+dqmxg447 maxmag -0.10 -0.100 -> -0.100
+dqmxg448 maxmag -0.1 -0.10 -> -0.10
+dqmxg449 maxmag -1.0 -0.1 -> -1.0
+dqmxg450 maxmag -1 -1.0 -> -1.0
+dqmxg451 maxmag -1.1 -1 -> -1.1
+dqmxg453 maxmag -Inf -1.1 -> -Infinity
+-- largies
+dqmxg460 maxmag 1000 1E+3 -> 1E+3
+dqmxg461 maxmag 1E+3 1000 -> 1E+3
+dqmxg462 maxmag 1000 -1E+3 -> 1000
+dqmxg463 maxmag 1E+3 -1000 -> 1E+3
+dqmxg464 maxmag -1000 1E+3 -> 1E+3
+dqmxg465 maxmag -1E+3 1000 -> 1000
+dqmxg466 maxmag -1000 -1E+3 -> -1000
+dqmxg467 maxmag -1E+3 -1000 -> -1000
+
+-- subnormals
+dqmxg510 maxmag 1.00E-6143 0 -> 1.00E-6143
+dqmxg511 maxmag 0.1E-6143 0 -> 1E-6144 Subnormal
+dqmxg512 maxmag 0.10E-6143 0 -> 1.0E-6144 Subnormal
+dqmxg513 maxmag 0.100E-6143 0 -> 1.00E-6144 Subnormal
+dqmxg514 maxmag 0.01E-6143 0 -> 1E-6145 Subnormal
+dqmxg515 maxmag 0.999E-6143 0 -> 9.99E-6144 Subnormal
+dqmxg516 maxmag 0.099E-6143 0 -> 9.9E-6145 Subnormal
+dqmxg517 maxmag 0.009E-6143 0 -> 9E-6146 Subnormal
+dqmxg518 maxmag 0.001E-6143 0 -> 1E-6146 Subnormal
+dqmxg519 maxmag 0.0009E-6143 0 -> 9E-6147 Subnormal
+dqmxg520 maxmag 0.0001E-6143 0 -> 1E-6147 Subnormal
+
+dqmxg530 maxmag -1.00E-6143 0 -> -1.00E-6143
+dqmxg531 maxmag -0.1E-6143 0 -> -1E-6144 Subnormal
+dqmxg532 maxmag -0.10E-6143 0 -> -1.0E-6144 Subnormal
+dqmxg533 maxmag -0.100E-6143 0 -> -1.00E-6144 Subnormal
+dqmxg534 maxmag -0.01E-6143 0 -> -1E-6145 Subnormal
+dqmxg535 maxmag -0.999E-6143 0 -> -9.99E-6144 Subnormal
+dqmxg536 maxmag -0.099E-6143 0 -> -9.9E-6145 Subnormal
+dqmxg537 maxmag -0.009E-6143 0 -> -9E-6146 Subnormal
+dqmxg538 maxmag -0.001E-6143 0 -> -1E-6146 Subnormal
+dqmxg539 maxmag -0.0009E-6143 0 -> -9E-6147 Subnormal
+dqmxg540 maxmag -0.0001E-6143 0 -> -1E-6147 Subnormal
+
+-- Null tests
+dqmxg900 maxmag 10 # -> NaN Invalid_operation
+dqmxg901 maxmag # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqMin.decTest b/Lib/test/decimaltestdata/dqMin.decTest
index c87f4c54ed..53020398c5 100644
--- a/Lib/test/decimaltestdata/dqMin.decTest
+++ b/Lib/test/decimaltestdata/dqMin.decTest
@@ -1,309 +1,309 @@
-------------------------------------------------------------------------
--- dqMin.decTest -- decQuad minnum --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmin001 min -2 -2 -> -2
-dqmin002 min -2 -1 -> -2
-dqmin003 min -2 0 -> -2
-dqmin004 min -2 1 -> -2
-dqmin005 min -2 2 -> -2
-dqmin006 min -1 -2 -> -2
-dqmin007 min -1 -1 -> -1
-dqmin008 min -1 0 -> -1
-dqmin009 min -1 1 -> -1
-dqmin010 min -1 2 -> -1
-dqmin011 min 0 -2 -> -2
-dqmin012 min 0 -1 -> -1
-dqmin013 min 0 0 -> 0
-dqmin014 min 0 1 -> 0
-dqmin015 min 0 2 -> 0
-dqmin016 min 1 -2 -> -2
-dqmin017 min 1 -1 -> -1
-dqmin018 min 1 0 -> 0
-dqmin019 min 1 1 -> 1
-dqmin020 min 1 2 -> 1
-dqmin021 min 2 -2 -> -2
-dqmin022 min 2 -1 -> -1
-dqmin023 min 2 0 -> 0
-dqmin025 min 2 1 -> 1
-dqmin026 min 2 2 -> 2
-
--- extended zeros
-dqmin030 min 0 0 -> 0
-dqmin031 min 0 -0 -> -0
-dqmin032 min 0 -0.0 -> -0.0
-dqmin033 min 0 0.0 -> 0.0
-dqmin034 min -0 0 -> -0
-dqmin035 min -0 -0 -> -0
-dqmin036 min -0 -0.0 -> -0
-dqmin037 min -0 0.0 -> -0
-dqmin038 min 0.0 0 -> 0.0
-dqmin039 min 0.0 -0 -> -0
-dqmin040 min 0.0 -0.0 -> -0.0
-dqmin041 min 0.0 0.0 -> 0.0
-dqmin042 min -0.0 0 -> -0.0
-dqmin043 min -0.0 -0 -> -0
-dqmin044 min -0.0 -0.0 -> -0.0
-dqmin045 min -0.0 0.0 -> -0.0
-
-dqmin046 min 0E1 -0E1 -> -0E+1
-dqmin047 min -0E1 0E2 -> -0E+1
-dqmin048 min 0E2 0E1 -> 0E+1
-dqmin049 min 0E1 0E2 -> 0E+1
-dqmin050 min -0E3 -0E2 -> -0E+3
-dqmin051 min -0E2 -0E3 -> -0E+3
-
--- Specials
-dqmin090 min Inf -Inf -> -Infinity
-dqmin091 min Inf -1000 -> -1000
-dqmin092 min Inf -1 -> -1
-dqmin093 min Inf -0 -> -0
-dqmin094 min Inf 0 -> 0
-dqmin095 min Inf 1 -> 1
-dqmin096 min Inf 1000 -> 1000
-dqmin097 min Inf Inf -> Infinity
-dqmin098 min -1000 Inf -> -1000
-dqmin099 min -Inf Inf -> -Infinity
-dqmin100 min -1 Inf -> -1
-dqmin101 min -0 Inf -> -0
-dqmin102 min 0 Inf -> 0
-dqmin103 min 1 Inf -> 1
-dqmin104 min 1000 Inf -> 1000
-dqmin105 min Inf Inf -> Infinity
-
-dqmin120 min -Inf -Inf -> -Infinity
-dqmin121 min -Inf -1000 -> -Infinity
-dqmin122 min -Inf -1 -> -Infinity
-dqmin123 min -Inf -0 -> -Infinity
-dqmin124 min -Inf 0 -> -Infinity
-dqmin125 min -Inf 1 -> -Infinity
-dqmin126 min -Inf 1000 -> -Infinity
-dqmin127 min -Inf Inf -> -Infinity
-dqmin128 min -Inf -Inf -> -Infinity
-dqmin129 min -1000 -Inf -> -Infinity
-dqmin130 min -1 -Inf -> -Infinity
-dqmin131 min -0 -Inf -> -Infinity
-dqmin132 min 0 -Inf -> -Infinity
-dqmin133 min 1 -Inf -> -Infinity
-dqmin134 min 1000 -Inf -> -Infinity
-dqmin135 min Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-dqmin141 min NaN -Inf -> -Infinity
-dqmin142 min NaN -1000 -> -1000
-dqmin143 min NaN -1 -> -1
-dqmin144 min NaN -0 -> -0
-dqmin145 min NaN 0 -> 0
-dqmin146 min NaN 1 -> 1
-dqmin147 min NaN 1000 -> 1000
-dqmin148 min NaN Inf -> Infinity
-dqmin149 min NaN NaN -> NaN
-dqmin150 min -Inf NaN -> -Infinity
-dqmin151 min -1000 NaN -> -1000
-dqmin152 min -1 -NaN -> -1
-dqmin153 min -0 NaN -> -0
-dqmin154 min 0 -NaN -> 0
-dqmin155 min 1 NaN -> 1
-dqmin156 min 1000 NaN -> 1000
-dqmin157 min Inf NaN -> Infinity
-
-dqmin161 min sNaN -Inf -> NaN Invalid_operation
-dqmin162 min sNaN -1000 -> NaN Invalid_operation
-dqmin163 min sNaN -1 -> NaN Invalid_operation
-dqmin164 min sNaN -0 -> NaN Invalid_operation
-dqmin165 min -sNaN 0 -> -NaN Invalid_operation
-dqmin166 min -sNaN 1 -> -NaN Invalid_operation
-dqmin167 min sNaN 1000 -> NaN Invalid_operation
-dqmin168 min sNaN NaN -> NaN Invalid_operation
-dqmin169 min sNaN sNaN -> NaN Invalid_operation
-dqmin170 min NaN sNaN -> NaN Invalid_operation
-dqmin171 min -Inf sNaN -> NaN Invalid_operation
-dqmin172 min -1000 sNaN -> NaN Invalid_operation
-dqmin173 min -1 sNaN -> NaN Invalid_operation
-dqmin174 min -0 sNaN -> NaN Invalid_operation
-dqmin175 min 0 sNaN -> NaN Invalid_operation
-dqmin176 min 1 sNaN -> NaN Invalid_operation
-dqmin177 min 1000 sNaN -> NaN Invalid_operation
-dqmin178 min Inf sNaN -> NaN Invalid_operation
-dqmin179 min NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmin181 min NaN9 -Inf -> -Infinity
-dqmin182 min -NaN8 9990 -> 9990
-dqmin183 min NaN71 Inf -> Infinity
-
-dqmin184 min NaN1 NaN54 -> NaN1
-dqmin185 min NaN22 -NaN53 -> NaN22
-dqmin186 min -NaN3 NaN6 -> -NaN3
-dqmin187 min -NaN44 NaN7 -> -NaN44
-
-dqmin188 min -Inf NaN41 -> -Infinity
-dqmin189 min -9999 -NaN33 -> -9999
-dqmin190 min Inf NaN2 -> Infinity
-
-dqmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
-dqmin192 min sNaN98 -11 -> NaN98 Invalid_operation
-dqmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
-dqmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
-dqmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
-dqmin197 min 088 sNaN91 -> NaN91 Invalid_operation
-dqmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmin199 min NaN sNaN86 -> NaN86 Invalid_operation
-
--- old rounding checks
-dqmin221 min -12345678000 1 -> -12345678000
-dqmin222 min 1 -12345678000 -> -12345678000
-dqmin223 min -1234567800 1 -> -1234567800
-dqmin224 min 1 -1234567800 -> -1234567800
-dqmin225 min -1234567890 1 -> -1234567890
-dqmin226 min 1 -1234567890 -> -1234567890
-dqmin227 min -1234567891 1 -> -1234567891
-dqmin228 min 1 -1234567891 -> -1234567891
-dqmin229 min -12345678901 1 -> -12345678901
-dqmin230 min 1 -12345678901 -> -12345678901
-dqmin231 min -1234567896 1 -> -1234567896
-dqmin232 min 1 -1234567896 -> -1234567896
-dqmin233 min 1234567891 1 -> 1
-dqmin234 min 1 1234567891 -> 1
-dqmin235 min 12345678901 1 -> 1
-dqmin236 min 1 12345678901 -> 1
-dqmin237 min 1234567896 1 -> 1
-dqmin238 min 1 1234567896 -> 1
-
--- from examples
-dqmin280 min '3' '2' -> '2'
-dqmin281 min '-10' '3' -> '-10'
-dqmin282 min '1.0' '1' -> '1.0'
-dqmin283 min '1' '1.0' -> '1.0'
-dqmin284 min '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-dqmin401 min Inf 1.1 -> 1.1
-dqmin402 min 1.1 1 -> 1
-dqmin403 min 1 1.0 -> 1.0
-dqmin404 min 1.0 0.1 -> 0.1
-dqmin405 min 0.1 0.10 -> 0.10
-dqmin406 min 0.10 0.100 -> 0.100
-dqmin407 min 0.10 0 -> 0
-dqmin408 min 0 0.0 -> 0.0
-dqmin409 min 0.0 -0 -> -0
-dqmin410 min 0.0 -0.0 -> -0.0
-dqmin411 min 0.00 -0.0 -> -0.0
-dqmin412 min 0.0 -0.00 -> -0.00
-dqmin413 min 0 -0.0 -> -0.0
-dqmin414 min 0 -0 -> -0
-dqmin415 min -0.0 -0 -> -0
-dqmin416 min -0 -0.100 -> -0.100
-dqmin417 min -0.100 -0.10 -> -0.10
-dqmin418 min -0.10 -0.1 -> -0.1
-dqmin419 min -0.1 -1.0 -> -1.0
-dqmin420 min -1.0 -1 -> -1
-dqmin421 min -1 -1.1 -> -1.1
-dqmin423 min -1.1 -Inf -> -Infinity
--- same with operands reversed
-dqmin431 min 1.1 Inf -> 1.1
-dqmin432 min 1 1.1 -> 1
-dqmin433 min 1.0 1 -> 1.0
-dqmin434 min 0.1 1.0 -> 0.1
-dqmin435 min 0.10 0.1 -> 0.10
-dqmin436 min 0.100 0.10 -> 0.100
-dqmin437 min 0 0.10 -> 0
-dqmin438 min 0.0 0 -> 0.0
-dqmin439 min -0 0.0 -> -0
-dqmin440 min -0.0 0.0 -> -0.0
-dqmin441 min -0.0 0.00 -> -0.0
-dqmin442 min -0.00 0.0 -> -0.00
-dqmin443 min -0.0 0 -> -0.0
-dqmin444 min -0 0 -> -0
-dqmin445 min -0 -0.0 -> -0
-dqmin446 min -0.100 -0 -> -0.100
-dqmin447 min -0.10 -0.100 -> -0.10
-dqmin448 min -0.1 -0.10 -> -0.1
-dqmin449 min -1.0 -0.1 -> -1.0
-dqmin450 min -1 -1.0 -> -1
-dqmin451 min -1.1 -1 -> -1.1
-dqmin453 min -Inf -1.1 -> -Infinity
--- largies
-dqmin460 min 1000 1E+3 -> 1000
-dqmin461 min 1E+3 1000 -> 1000
-dqmin462 min 1000 -1E+3 -> -1E+3
-dqmin463 min 1E+3 -384 -> -384
-dqmin464 min -384 1E+3 -> -384
-dqmin465 min -1E+3 1000 -> -1E+3
-dqmin466 min -384 -1E+3 -> -1E+3
-dqmin467 min -1E+3 -384 -> -1E+3
-
--- misalignment traps for little-endian
-dqmin471 min 1.0 0.1 -> 0.1
-dqmin472 min 0.1 1.0 -> 0.1
-dqmin473 min 10.0 0.1 -> 0.1
-dqmin474 min 0.1 10.0 -> 0.1
-dqmin475 min 100 1.0 -> 1.0
-dqmin476 min 1.0 100 -> 1.0
-dqmin477 min 1000 10.0 -> 10.0
-dqmin478 min 10.0 1000 -> 10.0
-dqmin479 min 10000 100.0 -> 100.0
-dqmin480 min 100.0 10000 -> 100.0
-dqmin481 min 100000 1000.0 -> 1000.0
-dqmin482 min 1000.0 100000 -> 1000.0
-dqmin483 min 1000000 10000.0 -> 10000.0
-dqmin484 min 10000.0 1000000 -> 10000.0
-
--- subnormals
-dqmin510 min 1.00E-6143 0 -> 0
-dqmin511 min 0.1E-6143 0 -> 0
-dqmin512 min 0.10E-6143 0 -> 0
-dqmin513 min 0.100E-6143 0 -> 0
-dqmin514 min 0.01E-6143 0 -> 0
-dqmin515 min 0.999E-6143 0 -> 0
-dqmin516 min 0.099E-6143 0 -> 0
-dqmin517 min 0.009E-6143 0 -> 0
-dqmin518 min 0.001E-6143 0 -> 0
-dqmin519 min 0.0009E-6143 0 -> 0
-dqmin520 min 0.0001E-6143 0 -> 0
-
-dqmin530 min -1.00E-6143 0 -> -1.00E-6143
-dqmin531 min -0.1E-6143 0 -> -1E-6144 Subnormal
-dqmin532 min -0.10E-6143 0 -> -1.0E-6144 Subnormal
-dqmin533 min -0.100E-6143 0 -> -1.00E-6144 Subnormal
-dqmin534 min -0.01E-6143 0 -> -1E-6145 Subnormal
-dqmin535 min -0.999E-6143 0 -> -9.99E-6144 Subnormal
-dqmin536 min -0.099E-6143 0 -> -9.9E-6145 Subnormal
-dqmin537 min -0.009E-6143 0 -> -9E-6146 Subnormal
-dqmin538 min -0.001E-6143 0 -> -1E-6146 Subnormal
-dqmin539 min -0.0009E-6143 0 -> -9E-6147 Subnormal
-dqmin540 min -0.0001E-6143 0 -> -1E-6147 Subnormal
-
-
--- Null tests
-dqmin900 min 10 # -> NaN Invalid_operation
-dqmin901 min # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqMin.decTest -- decQuad minnum --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmin001 min -2 -2 -> -2
+dqmin002 min -2 -1 -> -2
+dqmin003 min -2 0 -> -2
+dqmin004 min -2 1 -> -2
+dqmin005 min -2 2 -> -2
+dqmin006 min -1 -2 -> -2
+dqmin007 min -1 -1 -> -1
+dqmin008 min -1 0 -> -1
+dqmin009 min -1 1 -> -1
+dqmin010 min -1 2 -> -1
+dqmin011 min 0 -2 -> -2
+dqmin012 min 0 -1 -> -1
+dqmin013 min 0 0 -> 0
+dqmin014 min 0 1 -> 0
+dqmin015 min 0 2 -> 0
+dqmin016 min 1 -2 -> -2
+dqmin017 min 1 -1 -> -1
+dqmin018 min 1 0 -> 0
+dqmin019 min 1 1 -> 1
+dqmin020 min 1 2 -> 1
+dqmin021 min 2 -2 -> -2
+dqmin022 min 2 -1 -> -1
+dqmin023 min 2 0 -> 0
+dqmin025 min 2 1 -> 1
+dqmin026 min 2 2 -> 2
+
+-- extended zeros
+dqmin030 min 0 0 -> 0
+dqmin031 min 0 -0 -> -0
+dqmin032 min 0 -0.0 -> -0.0
+dqmin033 min 0 0.0 -> 0.0
+dqmin034 min -0 0 -> -0
+dqmin035 min -0 -0 -> -0
+dqmin036 min -0 -0.0 -> -0
+dqmin037 min -0 0.0 -> -0
+dqmin038 min 0.0 0 -> 0.0
+dqmin039 min 0.0 -0 -> -0
+dqmin040 min 0.0 -0.0 -> -0.0
+dqmin041 min 0.0 0.0 -> 0.0
+dqmin042 min -0.0 0 -> -0.0
+dqmin043 min -0.0 -0 -> -0
+dqmin044 min -0.0 -0.0 -> -0.0
+dqmin045 min -0.0 0.0 -> -0.0
+
+dqmin046 min 0E1 -0E1 -> -0E+1
+dqmin047 min -0E1 0E2 -> -0E+1
+dqmin048 min 0E2 0E1 -> 0E+1
+dqmin049 min 0E1 0E2 -> 0E+1
+dqmin050 min -0E3 -0E2 -> -0E+3
+dqmin051 min -0E2 -0E3 -> -0E+3
+
+-- Specials
+dqmin090 min Inf -Inf -> -Infinity
+dqmin091 min Inf -1000 -> -1000
+dqmin092 min Inf -1 -> -1
+dqmin093 min Inf -0 -> -0
+dqmin094 min Inf 0 -> 0
+dqmin095 min Inf 1 -> 1
+dqmin096 min Inf 1000 -> 1000
+dqmin097 min Inf Inf -> Infinity
+dqmin098 min -1000 Inf -> -1000
+dqmin099 min -Inf Inf -> -Infinity
+dqmin100 min -1 Inf -> -1
+dqmin101 min -0 Inf -> -0
+dqmin102 min 0 Inf -> 0
+dqmin103 min 1 Inf -> 1
+dqmin104 min 1000 Inf -> 1000
+dqmin105 min Inf Inf -> Infinity
+
+dqmin120 min -Inf -Inf -> -Infinity
+dqmin121 min -Inf -1000 -> -Infinity
+dqmin122 min -Inf -1 -> -Infinity
+dqmin123 min -Inf -0 -> -Infinity
+dqmin124 min -Inf 0 -> -Infinity
+dqmin125 min -Inf 1 -> -Infinity
+dqmin126 min -Inf 1000 -> -Infinity
+dqmin127 min -Inf Inf -> -Infinity
+dqmin128 min -Inf -Inf -> -Infinity
+dqmin129 min -1000 -Inf -> -Infinity
+dqmin130 min -1 -Inf -> -Infinity
+dqmin131 min -0 -Inf -> -Infinity
+dqmin132 min 0 -Inf -> -Infinity
+dqmin133 min 1 -Inf -> -Infinity
+dqmin134 min 1000 -Inf -> -Infinity
+dqmin135 min Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+dqmin141 min NaN -Inf -> -Infinity
+dqmin142 min NaN -1000 -> -1000
+dqmin143 min NaN -1 -> -1
+dqmin144 min NaN -0 -> -0
+dqmin145 min NaN 0 -> 0
+dqmin146 min NaN 1 -> 1
+dqmin147 min NaN 1000 -> 1000
+dqmin148 min NaN Inf -> Infinity
+dqmin149 min NaN NaN -> NaN
+dqmin150 min -Inf NaN -> -Infinity
+dqmin151 min -1000 NaN -> -1000
+dqmin152 min -1 -NaN -> -1
+dqmin153 min -0 NaN -> -0
+dqmin154 min 0 -NaN -> 0
+dqmin155 min 1 NaN -> 1
+dqmin156 min 1000 NaN -> 1000
+dqmin157 min Inf NaN -> Infinity
+
+dqmin161 min sNaN -Inf -> NaN Invalid_operation
+dqmin162 min sNaN -1000 -> NaN Invalid_operation
+dqmin163 min sNaN -1 -> NaN Invalid_operation
+dqmin164 min sNaN -0 -> NaN Invalid_operation
+dqmin165 min -sNaN 0 -> -NaN Invalid_operation
+dqmin166 min -sNaN 1 -> -NaN Invalid_operation
+dqmin167 min sNaN 1000 -> NaN Invalid_operation
+dqmin168 min sNaN NaN -> NaN Invalid_operation
+dqmin169 min sNaN sNaN -> NaN Invalid_operation
+dqmin170 min NaN sNaN -> NaN Invalid_operation
+dqmin171 min -Inf sNaN -> NaN Invalid_operation
+dqmin172 min -1000 sNaN -> NaN Invalid_operation
+dqmin173 min -1 sNaN -> NaN Invalid_operation
+dqmin174 min -0 sNaN -> NaN Invalid_operation
+dqmin175 min 0 sNaN -> NaN Invalid_operation
+dqmin176 min 1 sNaN -> NaN Invalid_operation
+dqmin177 min 1000 sNaN -> NaN Invalid_operation
+dqmin178 min Inf sNaN -> NaN Invalid_operation
+dqmin179 min NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmin181 min NaN9 -Inf -> -Infinity
+dqmin182 min -NaN8 9990 -> 9990
+dqmin183 min NaN71 Inf -> Infinity
+
+dqmin184 min NaN1 NaN54 -> NaN1
+dqmin185 min NaN22 -NaN53 -> NaN22
+dqmin186 min -NaN3 NaN6 -> -NaN3
+dqmin187 min -NaN44 NaN7 -> -NaN44
+
+dqmin188 min -Inf NaN41 -> -Infinity
+dqmin189 min -9999 -NaN33 -> -9999
+dqmin190 min Inf NaN2 -> Infinity
+
+dqmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
+dqmin192 min sNaN98 -11 -> NaN98 Invalid_operation
+dqmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
+dqmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
+dqmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
+dqmin197 min 088 sNaN91 -> NaN91 Invalid_operation
+dqmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmin199 min NaN sNaN86 -> NaN86 Invalid_operation
+
+-- old rounding checks
+dqmin221 min -12345678000 1 -> -12345678000
+dqmin222 min 1 -12345678000 -> -12345678000
+dqmin223 min -1234567800 1 -> -1234567800
+dqmin224 min 1 -1234567800 -> -1234567800
+dqmin225 min -1234567890 1 -> -1234567890
+dqmin226 min 1 -1234567890 -> -1234567890
+dqmin227 min -1234567891 1 -> -1234567891
+dqmin228 min 1 -1234567891 -> -1234567891
+dqmin229 min -12345678901 1 -> -12345678901
+dqmin230 min 1 -12345678901 -> -12345678901
+dqmin231 min -1234567896 1 -> -1234567896
+dqmin232 min 1 -1234567896 -> -1234567896
+dqmin233 min 1234567891 1 -> 1
+dqmin234 min 1 1234567891 -> 1
+dqmin235 min 12345678901 1 -> 1
+dqmin236 min 1 12345678901 -> 1
+dqmin237 min 1234567896 1 -> 1
+dqmin238 min 1 1234567896 -> 1
+
+-- from examples
+dqmin280 min '3' '2' -> '2'
+dqmin281 min '-10' '3' -> '-10'
+dqmin282 min '1.0' '1' -> '1.0'
+dqmin283 min '1' '1.0' -> '1.0'
+dqmin284 min '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+dqmin401 min Inf 1.1 -> 1.1
+dqmin402 min 1.1 1 -> 1
+dqmin403 min 1 1.0 -> 1.0
+dqmin404 min 1.0 0.1 -> 0.1
+dqmin405 min 0.1 0.10 -> 0.10
+dqmin406 min 0.10 0.100 -> 0.100
+dqmin407 min 0.10 0 -> 0
+dqmin408 min 0 0.0 -> 0.0
+dqmin409 min 0.0 -0 -> -0
+dqmin410 min 0.0 -0.0 -> -0.0
+dqmin411 min 0.00 -0.0 -> -0.0
+dqmin412 min 0.0 -0.00 -> -0.00
+dqmin413 min 0 -0.0 -> -0.0
+dqmin414 min 0 -0 -> -0
+dqmin415 min -0.0 -0 -> -0
+dqmin416 min -0 -0.100 -> -0.100
+dqmin417 min -0.100 -0.10 -> -0.10
+dqmin418 min -0.10 -0.1 -> -0.1
+dqmin419 min -0.1 -1.0 -> -1.0
+dqmin420 min -1.0 -1 -> -1
+dqmin421 min -1 -1.1 -> -1.1
+dqmin423 min -1.1 -Inf -> -Infinity
+-- same with operands reversed
+dqmin431 min 1.1 Inf -> 1.1
+dqmin432 min 1 1.1 -> 1
+dqmin433 min 1.0 1 -> 1.0
+dqmin434 min 0.1 1.0 -> 0.1
+dqmin435 min 0.10 0.1 -> 0.10
+dqmin436 min 0.100 0.10 -> 0.100
+dqmin437 min 0 0.10 -> 0
+dqmin438 min 0.0 0 -> 0.0
+dqmin439 min -0 0.0 -> -0
+dqmin440 min -0.0 0.0 -> -0.0
+dqmin441 min -0.0 0.00 -> -0.0
+dqmin442 min -0.00 0.0 -> -0.00
+dqmin443 min -0.0 0 -> -0.0
+dqmin444 min -0 0 -> -0
+dqmin445 min -0 -0.0 -> -0
+dqmin446 min -0.100 -0 -> -0.100
+dqmin447 min -0.10 -0.100 -> -0.10
+dqmin448 min -0.1 -0.10 -> -0.1
+dqmin449 min -1.0 -0.1 -> -1.0
+dqmin450 min -1 -1.0 -> -1
+dqmin451 min -1.1 -1 -> -1.1
+dqmin453 min -Inf -1.1 -> -Infinity
+-- largies
+dqmin460 min 1000 1E+3 -> 1000
+dqmin461 min 1E+3 1000 -> 1000
+dqmin462 min 1000 -1E+3 -> -1E+3
+dqmin463 min 1E+3 -384 -> -384
+dqmin464 min -384 1E+3 -> -384
+dqmin465 min -1E+3 1000 -> -1E+3
+dqmin466 min -384 -1E+3 -> -1E+3
+dqmin467 min -1E+3 -384 -> -1E+3
+
+-- misalignment traps for little-endian
+dqmin471 min 1.0 0.1 -> 0.1
+dqmin472 min 0.1 1.0 -> 0.1
+dqmin473 min 10.0 0.1 -> 0.1
+dqmin474 min 0.1 10.0 -> 0.1
+dqmin475 min 100 1.0 -> 1.0
+dqmin476 min 1.0 100 -> 1.0
+dqmin477 min 1000 10.0 -> 10.0
+dqmin478 min 10.0 1000 -> 10.0
+dqmin479 min 10000 100.0 -> 100.0
+dqmin480 min 100.0 10000 -> 100.0
+dqmin481 min 100000 1000.0 -> 1000.0
+dqmin482 min 1000.0 100000 -> 1000.0
+dqmin483 min 1000000 10000.0 -> 10000.0
+dqmin484 min 10000.0 1000000 -> 10000.0
+
+-- subnormals
+dqmin510 min 1.00E-6143 0 -> 0
+dqmin511 min 0.1E-6143 0 -> 0
+dqmin512 min 0.10E-6143 0 -> 0
+dqmin513 min 0.100E-6143 0 -> 0
+dqmin514 min 0.01E-6143 0 -> 0
+dqmin515 min 0.999E-6143 0 -> 0
+dqmin516 min 0.099E-6143 0 -> 0
+dqmin517 min 0.009E-6143 0 -> 0
+dqmin518 min 0.001E-6143 0 -> 0
+dqmin519 min 0.0009E-6143 0 -> 0
+dqmin520 min 0.0001E-6143 0 -> 0
+
+dqmin530 min -1.00E-6143 0 -> -1.00E-6143
+dqmin531 min -0.1E-6143 0 -> -1E-6144 Subnormal
+dqmin532 min -0.10E-6143 0 -> -1.0E-6144 Subnormal
+dqmin533 min -0.100E-6143 0 -> -1.00E-6144 Subnormal
+dqmin534 min -0.01E-6143 0 -> -1E-6145 Subnormal
+dqmin535 min -0.999E-6143 0 -> -9.99E-6144 Subnormal
+dqmin536 min -0.099E-6143 0 -> -9.9E-6145 Subnormal
+dqmin537 min -0.009E-6143 0 -> -9E-6146 Subnormal
+dqmin538 min -0.001E-6143 0 -> -1E-6146 Subnormal
+dqmin539 min -0.0009E-6143 0 -> -9E-6147 Subnormal
+dqmin540 min -0.0001E-6143 0 -> -1E-6147 Subnormal
+
+
+-- Null tests
+dqmin900 min 10 # -> NaN Invalid_operation
+dqmin901 min # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqMinMag.decTest b/Lib/test/decimaltestdata/dqMinMag.decTest
index edc2e476ac..71b886fb58 100644
--- a/Lib/test/decimaltestdata/dqMinMag.decTest
+++ b/Lib/test/decimaltestdata/dqMinMag.decTest
@@ -1,293 +1,293 @@
-------------------------------------------------------------------------
--- dqMinMag.decTest -- decQuad minnummag --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmng001 minmag -2 -2 -> -2
-dqmng002 minmag -2 -1 -> -1
-dqmng003 minmag -2 0 -> 0
-dqmng004 minmag -2 1 -> 1
-dqmng005 minmag -2 2 -> -2
-dqmng006 minmag -1 -2 -> -1
-dqmng007 minmag -1 -1 -> -1
-dqmng008 minmag -1 0 -> 0
-dqmng009 minmag -1 1 -> -1
-dqmng010 minmag -1 2 -> -1
-dqmng011 minmag 0 -2 -> 0
-dqmng012 minmag 0 -1 -> 0
-dqmng013 minmag 0 0 -> 0
-dqmng014 minmag 0 1 -> 0
-dqmng015 minmag 0 2 -> 0
-dqmng016 minmag 1 -2 -> 1
-dqmng017 minmag 1 -1 -> -1
-dqmng018 minmag 1 0 -> 0
-dqmng019 minmag 1 1 -> 1
-dqmng020 minmag 1 2 -> 1
-dqmng021 minmag 2 -2 -> -2
-dqmng022 minmag 2 -1 -> -1
-dqmng023 minmag 2 0 -> 0
-dqmng025 minmag 2 1 -> 1
-dqmng026 minmag 2 2 -> 2
-
--- extended zeros
-dqmng030 minmag 0 0 -> 0
-dqmng031 minmag 0 -0 -> -0
-dqmng032 minmag 0 -0.0 -> -0.0
-dqmng033 minmag 0 0.0 -> 0.0
-dqmng034 minmag -0 0 -> -0
-dqmng035 minmag -0 -0 -> -0
-dqmng036 minmag -0 -0.0 -> -0
-dqmng037 minmag -0 0.0 -> -0
-dqmng038 minmag 0.0 0 -> 0.0
-dqmng039 minmag 0.0 -0 -> -0
-dqmng040 minmag 0.0 -0.0 -> -0.0
-dqmng041 minmag 0.0 0.0 -> 0.0
-dqmng042 minmag -0.0 0 -> -0.0
-dqmng043 minmag -0.0 -0 -> -0
-dqmng044 minmag -0.0 -0.0 -> -0.0
-dqmng045 minmag -0.0 0.0 -> -0.0
-
-dqmng046 minmag 0E1 -0E1 -> -0E+1
-dqmng047 minmag -0E1 0E2 -> -0E+1
-dqmng048 minmag 0E2 0E1 -> 0E+1
-dqmng049 minmag 0E1 0E2 -> 0E+1
-dqmng050 minmag -0E3 -0E2 -> -0E+3
-dqmng051 minmag -0E2 -0E3 -> -0E+3
-
--- Specials
-dqmng090 minmag Inf -Inf -> -Infinity
-dqmng091 minmag Inf -1000 -> -1000
-dqmng092 minmag Inf -1 -> -1
-dqmng093 minmag Inf -0 -> -0
-dqmng094 minmag Inf 0 -> 0
-dqmng095 minmag Inf 1 -> 1
-dqmng096 minmag Inf 1000 -> 1000
-dqmng097 minmag Inf Inf -> Infinity
-dqmng098 minmag -1000 Inf -> -1000
-dqmng099 minmag -Inf Inf -> -Infinity
-dqmng100 minmag -1 Inf -> -1
-dqmng101 minmag -0 Inf -> -0
-dqmng102 minmag 0 Inf -> 0
-dqmng103 minmag 1 Inf -> 1
-dqmng104 minmag 1000 Inf -> 1000
-dqmng105 minmag Inf Inf -> Infinity
-
-dqmng120 minmag -Inf -Inf -> -Infinity
-dqmng121 minmag -Inf -1000 -> -1000
-dqmng122 minmag -Inf -1 -> -1
-dqmng123 minmag -Inf -0 -> -0
-dqmng124 minmag -Inf 0 -> 0
-dqmng125 minmag -Inf 1 -> 1
-dqmng126 minmag -Inf 1000 -> 1000
-dqmng127 minmag -Inf Inf -> -Infinity
-dqmng128 minmag -Inf -Inf -> -Infinity
-dqmng129 minmag -1000 -Inf -> -1000
-dqmng130 minmag -1 -Inf -> -1
-dqmng131 minmag -0 -Inf -> -0
-dqmng132 minmag 0 -Inf -> 0
-dqmng133 minmag 1 -Inf -> 1
-dqmng134 minmag 1000 -Inf -> 1000
-dqmng135 minmag Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-dqmng141 minmag NaN -Inf -> -Infinity
-dqmng142 minmag NaN -1000 -> -1000
-dqmng143 minmag NaN -1 -> -1
-dqmng144 minmag NaN -0 -> -0
-dqmng145 minmag NaN 0 -> 0
-dqmng146 minmag NaN 1 -> 1
-dqmng147 minmag NaN 1000 -> 1000
-dqmng148 minmag NaN Inf -> Infinity
-dqmng149 minmag NaN NaN -> NaN
-dqmng150 minmag -Inf NaN -> -Infinity
-dqmng151 minmag -1000 NaN -> -1000
-dqmng152 minmag -1 -NaN -> -1
-dqmng153 minmag -0 NaN -> -0
-dqmng154 minmag 0 -NaN -> 0
-dqmng155 minmag 1 NaN -> 1
-dqmng156 minmag 1000 NaN -> 1000
-dqmng157 minmag Inf NaN -> Infinity
-
-dqmng161 minmag sNaN -Inf -> NaN Invalid_operation
-dqmng162 minmag sNaN -1000 -> NaN Invalid_operation
-dqmng163 minmag sNaN -1 -> NaN Invalid_operation
-dqmng164 minmag sNaN -0 -> NaN Invalid_operation
-dqmng165 minmag -sNaN 0 -> -NaN Invalid_operation
-dqmng166 minmag -sNaN 1 -> -NaN Invalid_operation
-dqmng167 minmag sNaN 1000 -> NaN Invalid_operation
-dqmng168 minmag sNaN NaN -> NaN Invalid_operation
-dqmng169 minmag sNaN sNaN -> NaN Invalid_operation
-dqmng170 minmag NaN sNaN -> NaN Invalid_operation
-dqmng171 minmag -Inf sNaN -> NaN Invalid_operation
-dqmng172 minmag -1000 sNaN -> NaN Invalid_operation
-dqmng173 minmag -1 sNaN -> NaN Invalid_operation
-dqmng174 minmag -0 sNaN -> NaN Invalid_operation
-dqmng175 minmag 0 sNaN -> NaN Invalid_operation
-dqmng176 minmag 1 sNaN -> NaN Invalid_operation
-dqmng177 minmag 1000 sNaN -> NaN Invalid_operation
-dqmng178 minmag Inf sNaN -> NaN Invalid_operation
-dqmng179 minmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmng181 minmag NaN9 -Inf -> -Infinity
-dqmng182 minmag -NaN8 9990 -> 9990
-dqmng183 minmag NaN71 Inf -> Infinity
-
-dqmng184 minmag NaN1 NaN54 -> NaN1
-dqmng185 minmag NaN22 -NaN53 -> NaN22
-dqmng186 minmag -NaN3 NaN6 -> -NaN3
-dqmng187 minmag -NaN44 NaN7 -> -NaN44
-
-dqmng188 minmag -Inf NaN41 -> -Infinity
-dqmng189 minmag -9999 -NaN33 -> -9999
-dqmng190 minmag Inf NaN2 -> Infinity
-
-dqmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
-dqmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
-dqmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
-dqmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
-dqmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
-dqmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
-dqmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
-
--- old rounding checks
-dqmng221 minmag -12345678000 1 -> 1
-dqmng222 minmag 1 -12345678000 -> 1
-dqmng223 minmag -1234567800 1 -> 1
-dqmng224 minmag 1 -1234567800 -> 1
-dqmng225 minmag -1234567890 1 -> 1
-dqmng226 minmag 1 -1234567890 -> 1
-dqmng227 minmag -1234567891 1 -> 1
-dqmng228 minmag 1 -1234567891 -> 1
-dqmng229 minmag -12345678901 1 -> 1
-dqmng230 minmag 1 -12345678901 -> 1
-dqmng231 minmag -1234567896 1 -> 1
-dqmng232 minmag 1 -1234567896 -> 1
-dqmng233 minmag 1234567891 1 -> 1
-dqmng234 minmag 1 1234567891 -> 1
-dqmng235 minmag 12345678901 1 -> 1
-dqmng236 minmag 1 12345678901 -> 1
-dqmng237 minmag 1234567896 1 -> 1
-dqmng238 minmag 1 1234567896 -> 1
-
--- from examples
-dqmng280 minmag '3' '2' -> '2'
-dqmng281 minmag '-10' '3' -> '3'
-dqmng282 minmag '1.0' '1' -> '1.0'
-dqmng283 minmag '1' '1.0' -> '1.0'
-dqmng284 minmag '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-dqmng401 minmag Inf 1.1 -> 1.1
-dqmng402 minmag 1.1 1 -> 1
-dqmng403 minmag 1 1.0 -> 1.0
-dqmng404 minmag 1.0 0.1 -> 0.1
-dqmng405 minmag 0.1 0.10 -> 0.10
-dqmng406 minmag 0.10 0.100 -> 0.100
-dqmng407 minmag 0.10 0 -> 0
-dqmng408 minmag 0 0.0 -> 0.0
-dqmng409 minmag 0.0 -0 -> -0
-dqmng410 minmag 0.0 -0.0 -> -0.0
-dqmng411 minmag 0.00 -0.0 -> -0.0
-dqmng412 minmag 0.0 -0.00 -> -0.00
-dqmng413 minmag 0 -0.0 -> -0.0
-dqmng414 minmag 0 -0 -> -0
-dqmng415 minmag -0.0 -0 -> -0
-dqmng416 minmag -0 -0.100 -> -0
-dqmng417 minmag -0.100 -0.10 -> -0.10
-dqmng418 minmag -0.10 -0.1 -> -0.1
-dqmng419 minmag -0.1 -1.0 -> -0.1
-dqmng420 minmag -1.0 -1 -> -1
-dqmng421 minmag -1 -1.1 -> -1
-dqmng423 minmag -1.1 -Inf -> -1.1
--- same with operands reversed
-dqmng431 minmag 1.1 Inf -> 1.1
-dqmng432 minmag 1 1.1 -> 1
-dqmng433 minmag 1.0 1 -> 1.0
-dqmng434 minmag 0.1 1.0 -> 0.1
-dqmng435 minmag 0.10 0.1 -> 0.10
-dqmng436 minmag 0.100 0.10 -> 0.100
-dqmng437 minmag 0 0.10 -> 0
-dqmng438 minmag 0.0 0 -> 0.0
-dqmng439 minmag -0 0.0 -> -0
-dqmng440 minmag -0.0 0.0 -> -0.0
-dqmng441 minmag -0.0 0.00 -> -0.0
-dqmng442 minmag -0.00 0.0 -> -0.00
-dqmng443 minmag -0.0 0 -> -0.0
-dqmng444 minmag -0 0 -> -0
-dqmng445 minmag -0 -0.0 -> -0
-dqmng446 minmag -0.100 -0 -> -0
-dqmng447 minmag -0.10 -0.100 -> -0.10
-dqmng448 minmag -0.1 -0.10 -> -0.1
-dqmng449 minmag -1.0 -0.1 -> -0.1
-dqmng450 minmag -1 -1.0 -> -1
-dqmng451 minmag -1.1 -1 -> -1
-dqmng453 minmag -Inf -1.1 -> -1.1
--- largies
-dqmng460 minmag 1000 1E+3 -> 1000
-dqmng461 minmag 1E+3 1000 -> 1000
-dqmng462 minmag 1000 -1E+3 -> -1E+3
-dqmng463 minmag 1E+3 -384 -> -384
-dqmng464 minmag -384 1E+3 -> -384
-dqmng465 minmag -1E+3 1000 -> -1E+3
-dqmng466 minmag -384 -1E+3 -> -384
-dqmng467 minmag -1E+3 -384 -> -384
-
--- subnormals
-dqmng510 minmag 1.00E-6143 0 -> 0
-dqmng511 minmag 0.1E-6143 0 -> 0
-dqmng512 minmag 0.10E-6143 0 -> 0
-dqmng513 minmag 0.100E-6143 0 -> 0
-dqmng514 minmag 0.01E-6143 0 -> 0
-dqmng515 minmag 0.999E-6143 0 -> 0
-dqmng516 minmag 0.099E-6143 0 -> 0
-dqmng517 minmag 0.009E-6143 0 -> 0
-dqmng518 minmag 0.001E-6143 0 -> 0
-dqmng519 minmag 0.0009E-6143 0 -> 0
-dqmng520 minmag 0.0001E-6143 0 -> 0
-
-dqmng530 minmag -1.00E-6143 0 -> 0
-dqmng531 minmag -0.1E-6143 0 -> 0
-dqmng532 minmag -0.10E-6143 0 -> 0
-dqmng533 minmag -0.100E-6143 0 -> 0
-dqmng534 minmag -0.01E-6143 0 -> 0
-dqmng535 minmag -0.999E-6143 0 -> 0
-dqmng536 minmag -0.099E-6143 0 -> 0
-dqmng537 minmag -0.009E-6143 0 -> 0
-dqmng538 minmag -0.001E-6143 0 -> 0
-dqmng539 minmag -0.0009E-6143 0 -> 0
-dqmng540 minmag -0.0001E-6143 0 -> 0
-
-
--- Null tests
-dqmng900 minmag 10 # -> NaN Invalid_operation
-dqmng901 minmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqMinMag.decTest -- decQuad minnummag --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmng001 minmag -2 -2 -> -2
+dqmng002 minmag -2 -1 -> -1
+dqmng003 minmag -2 0 -> 0
+dqmng004 minmag -2 1 -> 1
+dqmng005 minmag -2 2 -> -2
+dqmng006 minmag -1 -2 -> -1
+dqmng007 minmag -1 -1 -> -1
+dqmng008 minmag -1 0 -> 0
+dqmng009 minmag -1 1 -> -1
+dqmng010 minmag -1 2 -> -1
+dqmng011 minmag 0 -2 -> 0
+dqmng012 minmag 0 -1 -> 0
+dqmng013 minmag 0 0 -> 0
+dqmng014 minmag 0 1 -> 0
+dqmng015 minmag 0 2 -> 0
+dqmng016 minmag 1 -2 -> 1
+dqmng017 minmag 1 -1 -> -1
+dqmng018 minmag 1 0 -> 0
+dqmng019 minmag 1 1 -> 1
+dqmng020 minmag 1 2 -> 1
+dqmng021 minmag 2 -2 -> -2
+dqmng022 minmag 2 -1 -> -1
+dqmng023 minmag 2 0 -> 0
+dqmng025 minmag 2 1 -> 1
+dqmng026 minmag 2 2 -> 2
+
+-- extended zeros
+dqmng030 minmag 0 0 -> 0
+dqmng031 minmag 0 -0 -> -0
+dqmng032 minmag 0 -0.0 -> -0.0
+dqmng033 minmag 0 0.0 -> 0.0
+dqmng034 minmag -0 0 -> -0
+dqmng035 minmag -0 -0 -> -0
+dqmng036 minmag -0 -0.0 -> -0
+dqmng037 minmag -0 0.0 -> -0
+dqmng038 minmag 0.0 0 -> 0.0
+dqmng039 minmag 0.0 -0 -> -0
+dqmng040 minmag 0.0 -0.0 -> -0.0
+dqmng041 minmag 0.0 0.0 -> 0.0
+dqmng042 minmag -0.0 0 -> -0.0
+dqmng043 minmag -0.0 -0 -> -0
+dqmng044 minmag -0.0 -0.0 -> -0.0
+dqmng045 minmag -0.0 0.0 -> -0.0
+
+dqmng046 minmag 0E1 -0E1 -> -0E+1
+dqmng047 minmag -0E1 0E2 -> -0E+1
+dqmng048 minmag 0E2 0E1 -> 0E+1
+dqmng049 minmag 0E1 0E2 -> 0E+1
+dqmng050 minmag -0E3 -0E2 -> -0E+3
+dqmng051 minmag -0E2 -0E3 -> -0E+3
+
+-- Specials
+dqmng090 minmag Inf -Inf -> -Infinity
+dqmng091 minmag Inf -1000 -> -1000
+dqmng092 minmag Inf -1 -> -1
+dqmng093 minmag Inf -0 -> -0
+dqmng094 minmag Inf 0 -> 0
+dqmng095 minmag Inf 1 -> 1
+dqmng096 minmag Inf 1000 -> 1000
+dqmng097 minmag Inf Inf -> Infinity
+dqmng098 minmag -1000 Inf -> -1000
+dqmng099 minmag -Inf Inf -> -Infinity
+dqmng100 minmag -1 Inf -> -1
+dqmng101 minmag -0 Inf -> -0
+dqmng102 minmag 0 Inf -> 0
+dqmng103 minmag 1 Inf -> 1
+dqmng104 minmag 1000 Inf -> 1000
+dqmng105 minmag Inf Inf -> Infinity
+
+dqmng120 minmag -Inf -Inf -> -Infinity
+dqmng121 minmag -Inf -1000 -> -1000
+dqmng122 minmag -Inf -1 -> -1
+dqmng123 minmag -Inf -0 -> -0
+dqmng124 minmag -Inf 0 -> 0
+dqmng125 minmag -Inf 1 -> 1
+dqmng126 minmag -Inf 1000 -> 1000
+dqmng127 minmag -Inf Inf -> -Infinity
+dqmng128 minmag -Inf -Inf -> -Infinity
+dqmng129 minmag -1000 -Inf -> -1000
+dqmng130 minmag -1 -Inf -> -1
+dqmng131 minmag -0 -Inf -> -0
+dqmng132 minmag 0 -Inf -> 0
+dqmng133 minmag 1 -Inf -> 1
+dqmng134 minmag 1000 -Inf -> 1000
+dqmng135 minmag Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+dqmng141 minmag NaN -Inf -> -Infinity
+dqmng142 minmag NaN -1000 -> -1000
+dqmng143 minmag NaN -1 -> -1
+dqmng144 minmag NaN -0 -> -0
+dqmng145 minmag NaN 0 -> 0
+dqmng146 minmag NaN 1 -> 1
+dqmng147 minmag NaN 1000 -> 1000
+dqmng148 minmag NaN Inf -> Infinity
+dqmng149 minmag NaN NaN -> NaN
+dqmng150 minmag -Inf NaN -> -Infinity
+dqmng151 minmag -1000 NaN -> -1000
+dqmng152 minmag -1 -NaN -> -1
+dqmng153 minmag -0 NaN -> -0
+dqmng154 minmag 0 -NaN -> 0
+dqmng155 minmag 1 NaN -> 1
+dqmng156 minmag 1000 NaN -> 1000
+dqmng157 minmag Inf NaN -> Infinity
+
+dqmng161 minmag sNaN -Inf -> NaN Invalid_operation
+dqmng162 minmag sNaN -1000 -> NaN Invalid_operation
+dqmng163 minmag sNaN -1 -> NaN Invalid_operation
+dqmng164 minmag sNaN -0 -> NaN Invalid_operation
+dqmng165 minmag -sNaN 0 -> -NaN Invalid_operation
+dqmng166 minmag -sNaN 1 -> -NaN Invalid_operation
+dqmng167 minmag sNaN 1000 -> NaN Invalid_operation
+dqmng168 minmag sNaN NaN -> NaN Invalid_operation
+dqmng169 minmag sNaN sNaN -> NaN Invalid_operation
+dqmng170 minmag NaN sNaN -> NaN Invalid_operation
+dqmng171 minmag -Inf sNaN -> NaN Invalid_operation
+dqmng172 minmag -1000 sNaN -> NaN Invalid_operation
+dqmng173 minmag -1 sNaN -> NaN Invalid_operation
+dqmng174 minmag -0 sNaN -> NaN Invalid_operation
+dqmng175 minmag 0 sNaN -> NaN Invalid_operation
+dqmng176 minmag 1 sNaN -> NaN Invalid_operation
+dqmng177 minmag 1000 sNaN -> NaN Invalid_operation
+dqmng178 minmag Inf sNaN -> NaN Invalid_operation
+dqmng179 minmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmng181 minmag NaN9 -Inf -> -Infinity
+dqmng182 minmag -NaN8 9990 -> 9990
+dqmng183 minmag NaN71 Inf -> Infinity
+
+dqmng184 minmag NaN1 NaN54 -> NaN1
+dqmng185 minmag NaN22 -NaN53 -> NaN22
+dqmng186 minmag -NaN3 NaN6 -> -NaN3
+dqmng187 minmag -NaN44 NaN7 -> -NaN44
+
+dqmng188 minmag -Inf NaN41 -> -Infinity
+dqmng189 minmag -9999 -NaN33 -> -9999
+dqmng190 minmag Inf NaN2 -> Infinity
+
+dqmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
+dqmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
+dqmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
+dqmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
+dqmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
+dqmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
+dqmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
+
+-- old rounding checks
+dqmng221 minmag -12345678000 1 -> 1
+dqmng222 minmag 1 -12345678000 -> 1
+dqmng223 minmag -1234567800 1 -> 1
+dqmng224 minmag 1 -1234567800 -> 1
+dqmng225 minmag -1234567890 1 -> 1
+dqmng226 minmag 1 -1234567890 -> 1
+dqmng227 minmag -1234567891 1 -> 1
+dqmng228 minmag 1 -1234567891 -> 1
+dqmng229 minmag -12345678901 1 -> 1
+dqmng230 minmag 1 -12345678901 -> 1
+dqmng231 minmag -1234567896 1 -> 1
+dqmng232 minmag 1 -1234567896 -> 1
+dqmng233 minmag 1234567891 1 -> 1
+dqmng234 minmag 1 1234567891 -> 1
+dqmng235 minmag 12345678901 1 -> 1
+dqmng236 minmag 1 12345678901 -> 1
+dqmng237 minmag 1234567896 1 -> 1
+dqmng238 minmag 1 1234567896 -> 1
+
+-- from examples
+dqmng280 minmag '3' '2' -> '2'
+dqmng281 minmag '-10' '3' -> '3'
+dqmng282 minmag '1.0' '1' -> '1.0'
+dqmng283 minmag '1' '1.0' -> '1.0'
+dqmng284 minmag '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+dqmng401 minmag Inf 1.1 -> 1.1
+dqmng402 minmag 1.1 1 -> 1
+dqmng403 minmag 1 1.0 -> 1.0
+dqmng404 minmag 1.0 0.1 -> 0.1
+dqmng405 minmag 0.1 0.10 -> 0.10
+dqmng406 minmag 0.10 0.100 -> 0.100
+dqmng407 minmag 0.10 0 -> 0
+dqmng408 minmag 0 0.0 -> 0.0
+dqmng409 minmag 0.0 -0 -> -0
+dqmng410 minmag 0.0 -0.0 -> -0.0
+dqmng411 minmag 0.00 -0.0 -> -0.0
+dqmng412 minmag 0.0 -0.00 -> -0.00
+dqmng413 minmag 0 -0.0 -> -0.0
+dqmng414 minmag 0 -0 -> -0
+dqmng415 minmag -0.0 -0 -> -0
+dqmng416 minmag -0 -0.100 -> -0
+dqmng417 minmag -0.100 -0.10 -> -0.10
+dqmng418 minmag -0.10 -0.1 -> -0.1
+dqmng419 minmag -0.1 -1.0 -> -0.1
+dqmng420 minmag -1.0 -1 -> -1
+dqmng421 minmag -1 -1.1 -> -1
+dqmng423 minmag -1.1 -Inf -> -1.1
+-- same with operands reversed
+dqmng431 minmag 1.1 Inf -> 1.1
+dqmng432 minmag 1 1.1 -> 1
+dqmng433 minmag 1.0 1 -> 1.0
+dqmng434 minmag 0.1 1.0 -> 0.1
+dqmng435 minmag 0.10 0.1 -> 0.10
+dqmng436 minmag 0.100 0.10 -> 0.100
+dqmng437 minmag 0 0.10 -> 0
+dqmng438 minmag 0.0 0 -> 0.0
+dqmng439 minmag -0 0.0 -> -0
+dqmng440 minmag -0.0 0.0 -> -0.0
+dqmng441 minmag -0.0 0.00 -> -0.0
+dqmng442 minmag -0.00 0.0 -> -0.00
+dqmng443 minmag -0.0 0 -> -0.0
+dqmng444 minmag -0 0 -> -0
+dqmng445 minmag -0 -0.0 -> -0
+dqmng446 minmag -0.100 -0 -> -0
+dqmng447 minmag -0.10 -0.100 -> -0.10
+dqmng448 minmag -0.1 -0.10 -> -0.1
+dqmng449 minmag -1.0 -0.1 -> -0.1
+dqmng450 minmag -1 -1.0 -> -1
+dqmng451 minmag -1.1 -1 -> -1
+dqmng453 minmag -Inf -1.1 -> -1.1
+-- largies
+dqmng460 minmag 1000 1E+3 -> 1000
+dqmng461 minmag 1E+3 1000 -> 1000
+dqmng462 minmag 1000 -1E+3 -> -1E+3
+dqmng463 minmag 1E+3 -384 -> -384
+dqmng464 minmag -384 1E+3 -> -384
+dqmng465 minmag -1E+3 1000 -> -1E+3
+dqmng466 minmag -384 -1E+3 -> -384
+dqmng467 minmag -1E+3 -384 -> -384
+
+-- subnormals
+dqmng510 minmag 1.00E-6143 0 -> 0
+dqmng511 minmag 0.1E-6143 0 -> 0
+dqmng512 minmag 0.10E-6143 0 -> 0
+dqmng513 minmag 0.100E-6143 0 -> 0
+dqmng514 minmag 0.01E-6143 0 -> 0
+dqmng515 minmag 0.999E-6143 0 -> 0
+dqmng516 minmag 0.099E-6143 0 -> 0
+dqmng517 minmag 0.009E-6143 0 -> 0
+dqmng518 minmag 0.001E-6143 0 -> 0
+dqmng519 minmag 0.0009E-6143 0 -> 0
+dqmng520 minmag 0.0001E-6143 0 -> 0
+
+dqmng530 minmag -1.00E-6143 0 -> 0
+dqmng531 minmag -0.1E-6143 0 -> 0
+dqmng532 minmag -0.10E-6143 0 -> 0
+dqmng533 minmag -0.100E-6143 0 -> 0
+dqmng534 minmag -0.01E-6143 0 -> 0
+dqmng535 minmag -0.999E-6143 0 -> 0
+dqmng536 minmag -0.099E-6143 0 -> 0
+dqmng537 minmag -0.009E-6143 0 -> 0
+dqmng538 minmag -0.001E-6143 0 -> 0
+dqmng539 minmag -0.0009E-6143 0 -> 0
+dqmng540 minmag -0.0001E-6143 0 -> 0
+
+
+-- Null tests
+dqmng900 minmag 10 # -> NaN Invalid_operation
+dqmng901 minmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqMinus.decTest b/Lib/test/decimaltestdata/dqMinus.decTest
index 02e462e0be..7a007791bf 100644
--- a/Lib/test/decimaltestdata/dqMinus.decTest
+++ b/Lib/test/decimaltestdata/dqMinus.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqMinus.decTest -- decQuad 0-x --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqmns001 minus +7.50 -> -7.50
-
--- Infinities
-dqmns011 minus Infinity -> -Infinity
-dqmns012 minus -Infinity -> Infinity
-
--- NaNs, 0 payload
-dqmns021 minus NaN -> NaN
-dqmns022 minus -NaN -> -NaN
-dqmns023 minus sNaN -> NaN Invalid_operation
-dqmns024 minus -sNaN -> -NaN Invalid_operation
-
--- NaNs, non-0 payload
-dqmns031 minus NaN13 -> NaN13
-dqmns032 minus -NaN13 -> -NaN13
-dqmns033 minus sNaN13 -> NaN13 Invalid_operation
-dqmns034 minus -sNaN13 -> -NaN13 Invalid_operation
-dqmns035 minus NaN70 -> NaN70
-dqmns036 minus -NaN70 -> -NaN70
-dqmns037 minus sNaN101 -> NaN101 Invalid_operation
-dqmns038 minus -sNaN101 -> -NaN101 Invalid_operation
-
--- finites
-dqmns101 minus 7 -> -7
-dqmns102 minus -7 -> 7
-dqmns103 minus 75 -> -75
-dqmns104 minus -75 -> 75
-dqmns105 minus 7.50 -> -7.50
-dqmns106 minus -7.50 -> 7.50
-dqmns107 minus 7.500 -> -7.500
-dqmns108 minus -7.500 -> 7.500
-
--- zeros
-dqmns111 minus 0 -> 0
-dqmns112 minus -0 -> 0
-dqmns113 minus 0E+4 -> 0E+4
-dqmns114 minus -0E+4 -> 0E+4
-dqmns115 minus 0.0000 -> 0.0000
-dqmns116 minus -0.0000 -> 0.0000
-dqmns117 minus 0E-141 -> 0E-141
-dqmns118 minus -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqmns121 minus 2682682682682682682682682682682682 -> -2682682682682682682682682682682682
-dqmns122 minus -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqmns123 minus 1341341341341341341341341341341341 -> -1341341341341341341341341341341341
-dqmns124 minus -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqmns131 minus 9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqmns132 minus 1E-6143 -> -1E-6143
-dqmns133 minus 1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqmns134 minus 1E-6176 -> -1E-6176 Subnormal
-
-dqmns135 minus -1E-6176 -> 1E-6176 Subnormal
-dqmns136 minus -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqmns137 minus -1E-6143 -> 1E-6143
-dqmns138 minus -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqMinus.decTest -- decQuad 0-x --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqmns001 minus +7.50 -> -7.50
+
+-- Infinities
+dqmns011 minus Infinity -> -Infinity
+dqmns012 minus -Infinity -> Infinity
+
+-- NaNs, 0 payload
+dqmns021 minus NaN -> NaN
+dqmns022 minus -NaN -> -NaN
+dqmns023 minus sNaN -> NaN Invalid_operation
+dqmns024 minus -sNaN -> -NaN Invalid_operation
+
+-- NaNs, non-0 payload
+dqmns031 minus NaN13 -> NaN13
+dqmns032 minus -NaN13 -> -NaN13
+dqmns033 minus sNaN13 -> NaN13 Invalid_operation
+dqmns034 minus -sNaN13 -> -NaN13 Invalid_operation
+dqmns035 minus NaN70 -> NaN70
+dqmns036 minus -NaN70 -> -NaN70
+dqmns037 minus sNaN101 -> NaN101 Invalid_operation
+dqmns038 minus -sNaN101 -> -NaN101 Invalid_operation
+
+-- finites
+dqmns101 minus 7 -> -7
+dqmns102 minus -7 -> 7
+dqmns103 minus 75 -> -75
+dqmns104 minus -75 -> 75
+dqmns105 minus 7.50 -> -7.50
+dqmns106 minus -7.50 -> 7.50
+dqmns107 minus 7.500 -> -7.500
+dqmns108 minus -7.500 -> 7.500
+
+-- zeros
+dqmns111 minus 0 -> 0
+dqmns112 minus -0 -> 0
+dqmns113 minus 0E+4 -> 0E+4
+dqmns114 minus -0E+4 -> 0E+4
+dqmns115 minus 0.0000 -> 0.0000
+dqmns116 minus -0.0000 -> 0.0000
+dqmns117 minus 0E-141 -> 0E-141
+dqmns118 minus -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqmns121 minus 2682682682682682682682682682682682 -> -2682682682682682682682682682682682
+dqmns122 minus -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqmns123 minus 1341341341341341341341341341341341 -> -1341341341341341341341341341341341
+dqmns124 minus -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqmns131 minus 9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqmns132 minus 1E-6143 -> -1E-6143
+dqmns133 minus 1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqmns134 minus 1E-6176 -> -1E-6176 Subnormal
+
+dqmns135 minus -1E-6176 -> 1E-6176 Subnormal
+dqmns136 minus -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqmns137 minus -1E-6143 -> 1E-6143
+dqmns138 minus -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqMultiply.decTest b/Lib/test/decimaltestdata/dqMultiply.decTest
index 8387a858d3..676c1f5ea4 100644
--- a/Lib/test/decimaltestdata/dqMultiply.decTest
+++ b/Lib/test/decimaltestdata/dqMultiply.decTest
@@ -1,589 +1,589 @@
-------------------------------------------------------------------------
--- dqMultiply.decTest -- decQuad multiplication --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decQuads only; all arguments are
--- representable in a decQuad
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmul000 multiply 2 2 -> 4
-dqmul001 multiply 2 3 -> 6
-dqmul002 multiply 5 1 -> 5
-dqmul003 multiply 5 2 -> 10
-dqmul004 multiply 1.20 2 -> 2.40
-dqmul005 multiply 1.20 0 -> 0.00
-dqmul006 multiply 1.20 -2 -> -2.40
-dqmul007 multiply -1.20 2 -> -2.40
-dqmul008 multiply -1.20 0 -> -0.00
-dqmul009 multiply -1.20 -2 -> 2.40
-dqmul010 multiply 5.09 7.1 -> 36.139
-dqmul011 multiply 2.5 4 -> 10.0
-dqmul012 multiply 2.50 4 -> 10.00
-dqmul013 multiply 1.23456789 1.0000000000000000000000000000 -> 1.234567890000000000000000000000000 Rounded
-dqmul015 multiply 2.50 4 -> 10.00
-dqmul016 multiply 9.99999999999999999 9.99999999999999999 -> 99.99999999999999980000000000000000 Inexact Rounded
-dqmul017 multiply 9.99999999999999999 -9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
-dqmul018 multiply -9.99999999999999999 9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
-dqmul019 multiply -9.99999999999999999 -9.99999999999999999 -> 99.99999999999999980000000000000000 Inexact Rounded
-
--- zeros, etc.
-dqmul021 multiply 0 0 -> 0
-dqmul022 multiply 0 -0 -> -0
-dqmul023 multiply -0 0 -> -0
-dqmul024 multiply -0 -0 -> 0
-dqmul025 multiply -0.0 -0.0 -> 0.00
-dqmul026 multiply -0.0 -0.0 -> 0.00
-dqmul027 multiply -0.0 -0.0 -> 0.00
-dqmul028 multiply -0.0 -0.0 -> 0.00
-dqmul030 multiply 5.00 1E-3 -> 0.00500
-dqmul031 multiply 00.00 0.000 -> 0.00000
-dqmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
-dqmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
-dqmul034 multiply -5.00 1E-3 -> -0.00500
-dqmul035 multiply -00.00 0.000 -> -0.00000
-dqmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
-dqmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
-dqmul038 multiply 5.00 -1E-3 -> -0.00500
-dqmul039 multiply 00.00 -0.000 -> -0.00000
-dqmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
-dqmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
-dqmul042 multiply -5.00 -1E-3 -> 0.00500
-dqmul043 multiply -00.00 -0.000 -> 0.00000
-dqmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
-dqmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
-
--- examples from decarith
-dqmul050 multiply 1.20 3 -> 3.60
-dqmul051 multiply 7 3 -> 21
-dqmul052 multiply 0.9 0.8 -> 0.72
-dqmul053 multiply 0.9 -0 -> -0.0
-dqmul054 multiply 654321 654321 -> 428135971041
-
-dqmul060 multiply 123.45 1e7 -> 1.2345E+9
-dqmul061 multiply 123.45 1e8 -> 1.2345E+10
-dqmul062 multiply 123.45 1e+9 -> 1.2345E+11
-dqmul063 multiply 123.45 1e10 -> 1.2345E+12
-dqmul064 multiply 123.45 1e11 -> 1.2345E+13
-dqmul065 multiply 123.45 1e12 -> 1.2345E+14
-dqmul066 multiply 123.45 1e13 -> 1.2345E+15
-
-
--- test some intermediate lengths
--- 1234567890123456
-dqmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
-dqmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
-dqmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
-dqmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
-
--- test some more edge cases and carries
-dqmul101 multiply 9 9 -> 81
-dqmul102 multiply 9 90 -> 810
-dqmul103 multiply 9 900 -> 8100
-dqmul104 multiply 9 9000 -> 81000
-dqmul105 multiply 9 90000 -> 810000
-dqmul106 multiply 9 900000 -> 8100000
-dqmul107 multiply 9 9000000 -> 81000000
-dqmul108 multiply 9 90000000 -> 810000000
-dqmul109 multiply 9 900000000 -> 8100000000
-dqmul110 multiply 9 9000000000 -> 81000000000
-dqmul111 multiply 9 90000000000 -> 810000000000
-dqmul112 multiply 9 900000000000 -> 8100000000000
-dqmul113 multiply 9 9000000000000 -> 81000000000000
-dqmul114 multiply 9 90000000000000 -> 810000000000000
-dqmul115 multiply 9 900000000000000 -> 8100000000000000
---dqmul116 multiply 9 9000000000000000 -> 81000000000000000
---dqmul117 multiply 9 90000000000000000 -> 810000000000000000
---dqmul118 multiply 9 900000000000000000 -> 8100000000000000000
---dqmul119 multiply 9 9000000000000000000 -> 81000000000000000000
---dqmul120 multiply 9 90000000000000000000 -> 810000000000000000000
---dqmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
---dqmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
---dqmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
--- test some more edge cases without carries
-dqmul131 multiply 3 3 -> 9
-dqmul132 multiply 3 30 -> 90
-dqmul133 multiply 3 300 -> 900
-dqmul134 multiply 3 3000 -> 9000
-dqmul135 multiply 3 30000 -> 90000
-dqmul136 multiply 3 300000 -> 900000
-dqmul137 multiply 3 3000000 -> 9000000
-dqmul138 multiply 3 30000000 -> 90000000
-dqmul139 multiply 3 300000000 -> 900000000
-dqmul140 multiply 3 3000000000 -> 9000000000
-dqmul141 multiply 3 30000000000 -> 90000000000
-dqmul142 multiply 3 300000000000 -> 900000000000
-dqmul143 multiply 3 3000000000000 -> 9000000000000
-dqmul144 multiply 3 30000000000000 -> 90000000000000
-dqmul145 multiply 3 300000000000000 -> 900000000000000
-dqmul146 multiply 3 3000000000000000 -> 9000000000000000
-dqmul147 multiply 3 30000000000000000 -> 90000000000000000
-dqmul148 multiply 3 300000000000000000 -> 900000000000000000
-dqmul149 multiply 3 3000000000000000000 -> 9000000000000000000
-dqmul150 multiply 3 30000000000000000000 -> 90000000000000000000
-dqmul151 multiply 3 300000000000000000000 -> 900000000000000000000
-dqmul152 multiply 3 3000000000000000000000 -> 9000000000000000000000
-dqmul153 multiply 3 30000000000000000000000 -> 90000000000000000000000
-
-dqmul263 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165119928296 Inexact Rounded
-
--- test some edge cases with exact rounding
-dqmul301 multiply 900000000000000000 9 -> 8100000000000000000
-dqmul302 multiply 900000000000000000 90 -> 81000000000000000000
-dqmul303 multiply 900000000000000000 900 -> 810000000000000000000
-dqmul304 multiply 900000000000000000 9000 -> 8100000000000000000000
-dqmul305 multiply 900000000000000000 90000 -> 81000000000000000000000
-dqmul306 multiply 900000000000000000 900000 -> 810000000000000000000000
-dqmul307 multiply 900000000000000000 9000000 -> 8100000000000000000000000
-dqmul308 multiply 900000000000000000 90000000 -> 81000000000000000000000000
-dqmul309 multiply 900000000000000000 900000000 -> 810000000000000000000000000
-dqmul310 multiply 900000000000000000 9000000000 -> 8100000000000000000000000000
-dqmul311 multiply 900000000000000000 90000000000 -> 81000000000000000000000000000
-dqmul312 multiply 900000000000000000 900000000000 -> 810000000000000000000000000000
-dqmul313 multiply 900000000000000000 9000000000000 -> 8100000000000000000000000000000
-dqmul314 multiply 900000000000000000 90000000000000 -> 81000000000000000000000000000000
-dqmul315 multiply 900000000000000000 900000000000000 -> 810000000000000000000000000000000
-dqmul316 multiply 900000000000000000 9000000000000000 -> 8100000000000000000000000000000000
-dqmul317 multiply 9000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+34 Rounded
-dqmul318 multiply 90000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+35 Rounded
-dqmul319 multiply 900000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+36 Rounded
-dqmul320 multiply 9000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+37 Rounded
-dqmul321 multiply 90000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+38 Rounded
-dqmul322 multiply 900000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+39 Rounded
-dqmul323 multiply 9000000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+40 Rounded
-
--- tryzeros cases
-dqmul504 multiply 0E-4260 1000E-4260 -> 0E-6176 Clamped
-dqmul505 multiply 100E+4260 0E+4260 -> 0E+6111 Clamped
-
--- mixed with zeros
-dqmul541 multiply 0 -1 -> -0
-dqmul542 multiply -0 -1 -> 0
-dqmul543 multiply 0 1 -> 0
-dqmul544 multiply -0 1 -> -0
-dqmul545 multiply -1 0 -> -0
-dqmul546 multiply -1 -0 -> 0
-dqmul547 multiply 1 0 -> 0
-dqmul548 multiply 1 -0 -> -0
-
-dqmul551 multiply 0.0 -1 -> -0.0
-dqmul552 multiply -0.0 -1 -> 0.0
-dqmul553 multiply 0.0 1 -> 0.0
-dqmul554 multiply -0.0 1 -> -0.0
-dqmul555 multiply -1.0 0 -> -0.0
-dqmul556 multiply -1.0 -0 -> 0.0
-dqmul557 multiply 1.0 0 -> 0.0
-dqmul558 multiply 1.0 -0 -> -0.0
-
-dqmul561 multiply 0 -1.0 -> -0.0
-dqmul562 multiply -0 -1.0 -> 0.0
-dqmul563 multiply 0 1.0 -> 0.0
-dqmul564 multiply -0 1.0 -> -0.0
-dqmul565 multiply -1 0.0 -> -0.0
-dqmul566 multiply -1 -0.0 -> 0.0
-dqmul567 multiply 1 0.0 -> 0.0
-dqmul568 multiply 1 -0.0 -> -0.0
-
-dqmul571 multiply 0.0 -1.0 -> -0.00
-dqmul572 multiply -0.0 -1.0 -> 0.00
-dqmul573 multiply 0.0 1.0 -> 0.00
-dqmul574 multiply -0.0 1.0 -> -0.00
-dqmul575 multiply -1.0 0.0 -> -0.00
-dqmul576 multiply -1.0 -0.0 -> 0.00
-dqmul577 multiply 1.0 0.0 -> 0.00
-dqmul578 multiply 1.0 -0.0 -> -0.00
-
-
--- Specials
-dqmul580 multiply Inf -Inf -> -Infinity
-dqmul581 multiply Inf -1000 -> -Infinity
-dqmul582 multiply Inf -1 -> -Infinity
-dqmul583 multiply Inf -0 -> NaN Invalid_operation
-dqmul584 multiply Inf 0 -> NaN Invalid_operation
-dqmul585 multiply Inf 1 -> Infinity
-dqmul586 multiply Inf 1000 -> Infinity
-dqmul587 multiply Inf Inf -> Infinity
-dqmul588 multiply -1000 Inf -> -Infinity
-dqmul589 multiply -Inf Inf -> -Infinity
-dqmul590 multiply -1 Inf -> -Infinity
-dqmul591 multiply -0 Inf -> NaN Invalid_operation
-dqmul592 multiply 0 Inf -> NaN Invalid_operation
-dqmul593 multiply 1 Inf -> Infinity
-dqmul594 multiply 1000 Inf -> Infinity
-dqmul595 multiply Inf Inf -> Infinity
-
-dqmul600 multiply -Inf -Inf -> Infinity
-dqmul601 multiply -Inf -1000 -> Infinity
-dqmul602 multiply -Inf -1 -> Infinity
-dqmul603 multiply -Inf -0 -> NaN Invalid_operation
-dqmul604 multiply -Inf 0 -> NaN Invalid_operation
-dqmul605 multiply -Inf 1 -> -Infinity
-dqmul606 multiply -Inf 1000 -> -Infinity
-dqmul607 multiply -Inf Inf -> -Infinity
-dqmul608 multiply -1000 Inf -> -Infinity
-dqmul609 multiply -Inf -Inf -> Infinity
-dqmul610 multiply -1 -Inf -> Infinity
-dqmul611 multiply -0 -Inf -> NaN Invalid_operation
-dqmul612 multiply 0 -Inf -> NaN Invalid_operation
-dqmul613 multiply 1 -Inf -> -Infinity
-dqmul614 multiply 1000 -Inf -> -Infinity
-dqmul615 multiply Inf -Inf -> -Infinity
-
-dqmul621 multiply NaN -Inf -> NaN
-dqmul622 multiply NaN -1000 -> NaN
-dqmul623 multiply NaN -1 -> NaN
-dqmul624 multiply NaN -0 -> NaN
-dqmul625 multiply NaN 0 -> NaN
-dqmul626 multiply NaN 1 -> NaN
-dqmul627 multiply NaN 1000 -> NaN
-dqmul628 multiply NaN Inf -> NaN
-dqmul629 multiply NaN NaN -> NaN
-dqmul630 multiply -Inf NaN -> NaN
-dqmul631 multiply -1000 NaN -> NaN
-dqmul632 multiply -1 NaN -> NaN
-dqmul633 multiply -0 NaN -> NaN
-dqmul634 multiply 0 NaN -> NaN
-dqmul635 multiply 1 NaN -> NaN
-dqmul636 multiply 1000 NaN -> NaN
-dqmul637 multiply Inf NaN -> NaN
-
-dqmul641 multiply sNaN -Inf -> NaN Invalid_operation
-dqmul642 multiply sNaN -1000 -> NaN Invalid_operation
-dqmul643 multiply sNaN -1 -> NaN Invalid_operation
-dqmul644 multiply sNaN -0 -> NaN Invalid_operation
-dqmul645 multiply sNaN 0 -> NaN Invalid_operation
-dqmul646 multiply sNaN 1 -> NaN Invalid_operation
-dqmul647 multiply sNaN 1000 -> NaN Invalid_operation
-dqmul648 multiply sNaN NaN -> NaN Invalid_operation
-dqmul649 multiply sNaN sNaN -> NaN Invalid_operation
-dqmul650 multiply NaN sNaN -> NaN Invalid_operation
-dqmul651 multiply -Inf sNaN -> NaN Invalid_operation
-dqmul652 multiply -1000 sNaN -> NaN Invalid_operation
-dqmul653 multiply -1 sNaN -> NaN Invalid_operation
-dqmul654 multiply -0 sNaN -> NaN Invalid_operation
-dqmul655 multiply 0 sNaN -> NaN Invalid_operation
-dqmul656 multiply 1 sNaN -> NaN Invalid_operation
-dqmul657 multiply 1000 sNaN -> NaN Invalid_operation
-dqmul658 multiply Inf sNaN -> NaN Invalid_operation
-dqmul659 multiply NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmul661 multiply NaN9 -Inf -> NaN9
-dqmul662 multiply NaN8 999 -> NaN8
-dqmul663 multiply NaN71 Inf -> NaN71
-dqmul664 multiply NaN6 NaN5 -> NaN6
-dqmul665 multiply -Inf NaN4 -> NaN4
-dqmul666 multiply -999 NaN33 -> NaN33
-dqmul667 multiply Inf NaN2 -> NaN2
-
-dqmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
-dqmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
-dqmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
-dqmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
-dqmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
-dqmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
-dqmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
-dqmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
-
-dqmul681 multiply -NaN9 -Inf -> -NaN9
-dqmul682 multiply -NaN8 999 -> -NaN8
-dqmul683 multiply -NaN71 Inf -> -NaN71
-dqmul684 multiply -NaN6 -NaN5 -> -NaN6
-dqmul685 multiply -Inf -NaN4 -> -NaN4
-dqmul686 multiply -999 -NaN33 -> -NaN33
-dqmul687 multiply Inf -NaN2 -> -NaN2
-
-dqmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
-dqmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
-dqmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
-dqmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-dqmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
-dqmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
-dqmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
-
-dqmul701 multiply -NaN -Inf -> -NaN
-dqmul702 multiply -NaN 999 -> -NaN
-dqmul703 multiply -NaN Inf -> -NaN
-dqmul704 multiply -NaN -NaN -> -NaN
-dqmul705 multiply -Inf -NaN0 -> -NaN
-dqmul706 multiply -999 -NaN -> -NaN
-dqmul707 multiply Inf -NaN -> -NaN
-
-dqmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
-dqmul712 multiply -sNaN -11 -> -NaN Invalid_operation
-dqmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
-dqmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
-dqmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
-dqmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
-dqmul717 multiply 088 -sNaN -> -NaN Invalid_operation
-dqmul718 multiply Inf -sNaN -> -NaN Invalid_operation
-dqmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
--- signs
-dqmul751 multiply 1e+4277 1e+3311 -> Infinity Overflow Inexact Rounded
-dqmul752 multiply 1e+4277 -1e+3311 -> -Infinity Overflow Inexact Rounded
-dqmul753 multiply -1e+4277 1e+3311 -> -Infinity Overflow Inexact Rounded
-dqmul754 multiply -1e+4277 -1e+3311 -> Infinity Overflow Inexact Rounded
-dqmul755 multiply 1e-4277 1e-3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul756 multiply 1e-4277 -1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul757 multiply -1e-4277 1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul758 multiply -1e-4277 -1e-3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dqmul760 multiply 1e-6069 1e-101 -> 1E-6170 Subnormal
-dqmul761 multiply 1e-6069 1e-102 -> 1E-6171 Subnormal
-dqmul762 multiply 1e-6069 1e-103 -> 1E-6172 Subnormal
-dqmul763 multiply 1e-6069 1e-104 -> 1E-6173 Subnormal
-dqmul764 multiply 1e-6069 1e-105 -> 1E-6174 Subnormal
-dqmul765 multiply 1e-6069 1e-106 -> 1E-6175 Subnormal
-dqmul766 multiply 1e-6069 1e-107 -> 1E-6176 Subnormal
-dqmul767 multiply 1e-6069 1e-108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul768 multiply 1e-6069 1e-109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul769 multiply 1e-6069 1e-110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-dqmul770 multiply 1e+40 1e+6101 -> 1.000000000000000000000000000000E+6141 Clamped
-dqmul771 multiply 1e+40 1e+6102 -> 1.0000000000000000000000000000000E+6142 Clamped
-dqmul772 multiply 1e+40 1e+6103 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqmul773 multiply 1e+40 1e+6104 -> 1.000000000000000000000000000000000E+6144 Clamped
-dqmul774 multiply 1e+40 1e+6105 -> Infinity Overflow Inexact Rounded
-dqmul775 multiply 1e+40 1e+6106 -> Infinity Overflow Inexact Rounded
-dqmul776 multiply 1e+40 1e+6107 -> Infinity Overflow Inexact Rounded
-dqmul777 multiply 1e+40 1e+6108 -> Infinity Overflow Inexact Rounded
-dqmul778 multiply 1e+40 1e+6109 -> Infinity Overflow Inexact Rounded
-dqmul779 multiply 1e+40 1e+6110 -> Infinity Overflow Inexact Rounded
-
-dqmul801 multiply 1.0000E-6172 1 -> 1.0000E-6172 Subnormal
-dqmul802 multiply 1.000E-6172 1e-1 -> 1.000E-6173 Subnormal
-dqmul803 multiply 1.00E-6172 1e-2 -> 1.00E-6174 Subnormal
-dqmul804 multiply 1.0E-6172 1e-3 -> 1.0E-6175 Subnormal
-dqmul805 multiply 1.0E-6172 1e-4 -> 1E-6176 Subnormal Rounded
-dqmul806 multiply 1.3E-6172 1e-4 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqmul807 multiply 1.5E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul808 multiply 1.7E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul809 multiply 2.3E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul810 multiply 2.5E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul811 multiply 2.7E-6172 1e-4 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqmul812 multiply 1.49E-6172 1e-4 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqmul813 multiply 1.50E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul814 multiply 1.51E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul815 multiply 2.49E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul816 multiply 2.50E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul817 multiply 2.51E-6172 1e-4 -> 3E-6176 Underflow Subnormal Inexact Rounded
-
-dqmul818 multiply 1E-6172 1e-4 -> 1E-6176 Subnormal
-dqmul819 multiply 3E-6172 1e-5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul820 multiply 5E-6172 1e-5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul821 multiply 7E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqmul822 multiply 9E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqmul823 multiply 9.9E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-
-dqmul824 multiply 1E-6172 -1e-4 -> -1E-6176 Subnormal
-dqmul825 multiply 3E-6172 -1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul826 multiply -5E-6172 1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul827 multiply 7E-6172 -1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqmul828 multiply -9E-6172 1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqmul829 multiply 9.9E-6172 -1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqmul830 multiply 3.0E-6172 -1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqmul831 multiply 1.0E-5977 1e-200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul832 multiply 1.0E-5977 1e-199 -> 1E-6176 Subnormal Rounded
-dqmul833 multiply 1.0E-5977 1e-198 -> 1.0E-6175 Subnormal
-dqmul834 multiply 2.0E-5977 2e-198 -> 4.0E-6175 Subnormal
-dqmul835 multiply 4.0E-5977 4e-198 -> 1.60E-6174 Subnormal
-dqmul836 multiply 10.0E-5977 10e-198 -> 1.000E-6173 Subnormal
-dqmul837 multiply 30.0E-5977 30e-198 -> 9.000E-6173 Subnormal
-dqmul838 multiply 40.0E-5982 40e-166 -> 1.6000E-6145 Subnormal
-dqmul839 multiply 40.0E-5982 40e-165 -> 1.6000E-6144 Subnormal
-dqmul840 multiply 40.0E-5982 40e-164 -> 1.6000E-6143
-
--- Long operand overflow may be a different path
-dqmul870 multiply 100 9.999E+6143 -> Infinity Inexact Overflow Rounded
-dqmul871 multiply 100 -9.999E+6143 -> -Infinity Inexact Overflow Rounded
-dqmul872 multiply 9.999E+6143 100 -> Infinity Inexact Overflow Rounded
-dqmul873 multiply -9.999E+6143 100 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-dqmul881 multiply 1.2347E-6133 1.2347E-40 -> 1.524E-6173 Inexact Rounded Subnormal Underflow
-dqmul882 multiply 1.234E-6133 1.234E-40 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqmul883 multiply 1.23E-6133 1.23E-40 -> 1.513E-6173 Inexact Rounded Subnormal Underflow
-dqmul884 multiply 1.2E-6133 1.2E-40 -> 1.44E-6173 Subnormal
-dqmul885 multiply 1.2E-6133 1.2E-41 -> 1.44E-6174 Subnormal
-dqmul886 multiply 1.2E-6133 1.2E-42 -> 1.4E-6175 Subnormal Inexact Rounded Underflow
-dqmul887 multiply 1.2E-6133 1.3E-42 -> 1.6E-6175 Subnormal Inexact Rounded Underflow
-dqmul888 multiply 1.3E-6133 1.3E-42 -> 1.7E-6175 Subnormal Inexact Rounded Underflow
-dqmul889 multiply 1.3E-6133 1.3E-43 -> 2E-6176 Subnormal Inexact Rounded Underflow
-dqmul890 multiply 1.3E-6134 1.3E-43 -> 0E-6176 Clamped Subnormal Inexact Rounded Underflow
-
-dqmul891 multiply 1.2345E-39 1.234E-6133 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
-dqmul892 multiply 1.23456E-39 1.234E-6133 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
-dqmul893 multiply 1.2345E-40 1.234E-6133 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqmul894 multiply 1.23456E-40 1.234E-6133 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqmul895 multiply 1.2345E-41 1.234E-6133 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
-dqmul896 multiply 1.23456E-41 1.234E-6133 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
--- prove operands are exact
-dqmul906 multiply 9.999999999999999999999999999999999E-6143 1 -> 9.999999999999999999999999999999999E-6143
-dqmul907 multiply 1 0.09999999999999999999999999999999999 -> 0.09999999999999999999999999999999999
--- the next rounds to Nmin
-dqmul908 multiply 9.999999999999999999999999999999999E-6143 0.09999999999999999999999999999999999 -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded
-
--- hugest
-dqmul909 multiply 9999999999999999999999999999999999 9999999999999999999999999999999999 -> 9.999999999999999999999999999999998E+67 Inexact Rounded
--- VG case
-dqmul910 multiply 8.81125000000001349436E-1548 8.000000000000000000E-1550 -> 7.049000000000010795488000000000000E-3097 Rounded
-
--- Examples from SQL proposal (Krishna Kulkarni)
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
-dqmul911 multiply 130E-2 120E-2 -> 1.5600
-dqmul912 multiply 130E-2 12E-1 -> 1.560
-dqmul913 multiply 130E-2 1E0 -> 1.30
-dqmul914 multiply 1E2 1E4 -> 1E+6
-
--- power-of-ten edge cases
-dqmul1001 multiply 1 10 -> 10
-dqmul1002 multiply 1 100 -> 100
-dqmul1003 multiply 1 1000 -> 1000
-dqmul1004 multiply 1 10000 -> 10000
-dqmul1005 multiply 1 100000 -> 100000
-dqmul1006 multiply 1 1000000 -> 1000000
-dqmul1007 multiply 1 10000000 -> 10000000
-dqmul1008 multiply 1 100000000 -> 100000000
-dqmul1009 multiply 1 1000000000 -> 1000000000
-dqmul1010 multiply 1 10000000000 -> 10000000000
-dqmul1011 multiply 1 100000000000 -> 100000000000
-dqmul1012 multiply 1 1000000000000 -> 1000000000000
-dqmul1013 multiply 1 10000000000000 -> 10000000000000
-dqmul1014 multiply 1 100000000000000 -> 100000000000000
-dqmul1015 multiply 1 1000000000000000 -> 1000000000000000
-
-dqmul1016 multiply 1 1000000000000000000 -> 1000000000000000000
-dqmul1017 multiply 1 100000000000000000000000000 -> 100000000000000000000000000
-dqmul1018 multiply 1 1000000000000000000000000000 -> 1000000000000000000000000000
-dqmul1019 multiply 1 10000000000000000000000000000 -> 10000000000000000000000000000
-dqmul1020 multiply 1 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1021 multiply 10 1 -> 10
-dqmul1022 multiply 10 10 -> 100
-dqmul1023 multiply 10 100 -> 1000
-dqmul1024 multiply 10 1000 -> 10000
-dqmul1025 multiply 10 10000 -> 100000
-dqmul1026 multiply 10 100000 -> 1000000
-dqmul1027 multiply 10 1000000 -> 10000000
-dqmul1028 multiply 10 10000000 -> 100000000
-dqmul1029 multiply 10 100000000 -> 1000000000
-dqmul1030 multiply 10 1000000000 -> 10000000000
-dqmul1031 multiply 10 10000000000 -> 100000000000
-dqmul1032 multiply 10 100000000000 -> 1000000000000
-dqmul1033 multiply 10 1000000000000 -> 10000000000000
-dqmul1034 multiply 10 10000000000000 -> 100000000000000
-dqmul1035 multiply 10 100000000000000 -> 1000000000000000
-
-dqmul1036 multiply 10 100000000000000000 -> 1000000000000000000
-dqmul1037 multiply 10 10000000000000000000000000 -> 100000000000000000000000000
-dqmul1038 multiply 10 100000000000000000000000000 -> 1000000000000000000000000000
-dqmul1039 multiply 10 1000000000000000000000000000 -> 10000000000000000000000000000
-dqmul1040 multiply 10 100000000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1041 multiply 100 0.1 -> 10.0
-dqmul1042 multiply 100 1 -> 100
-dqmul1043 multiply 100 10 -> 1000
-dqmul1044 multiply 100 100 -> 10000
-dqmul1045 multiply 100 1000 -> 100000
-dqmul1046 multiply 100 10000 -> 1000000
-dqmul1047 multiply 100 100000 -> 10000000
-dqmul1048 multiply 100 1000000 -> 100000000
-dqmul1049 multiply 100 10000000 -> 1000000000
-dqmul1050 multiply 100 100000000 -> 10000000000
-dqmul1051 multiply 100 1000000000 -> 100000000000
-dqmul1052 multiply 100 10000000000 -> 1000000000000
-dqmul1053 multiply 100 100000000000 -> 10000000000000
-dqmul1054 multiply 100 1000000000000 -> 100000000000000
-dqmul1055 multiply 100 10000000000000 -> 1000000000000000
-
-dqmul1056 multiply 100 10000000000000000 -> 1000000000000000000
-dqmul1057 multiply 100 1000000000000000000000000 -> 100000000000000000000000000
-dqmul1058 multiply 100 10000000000000000000000000 -> 1000000000000000000000000000
-dqmul1059 multiply 100 100000000000000000000000000 -> 10000000000000000000000000000
-dqmul1060 multiply 100 10000000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1061 multiply 1000 0.01 -> 10.00
-dqmul1062 multiply 1000 0.1 -> 100.0
-dqmul1063 multiply 1000 1 -> 1000
-dqmul1064 multiply 1000 10 -> 10000
-dqmul1065 multiply 1000 100 -> 100000
-dqmul1066 multiply 1000 1000 -> 1000000
-dqmul1067 multiply 1000 10000 -> 10000000
-dqmul1068 multiply 1000 100000 -> 100000000
-dqmul1069 multiply 1000 1000000 -> 1000000000
-dqmul1070 multiply 1000 10000000 -> 10000000000
-dqmul1071 multiply 1000 100000000 -> 100000000000
-dqmul1072 multiply 1000 1000000000 -> 1000000000000
-dqmul1073 multiply 1000 10000000000 -> 10000000000000
-dqmul1074 multiply 1000 100000000000 -> 100000000000000
-dqmul1075 multiply 1000 1000000000000 -> 1000000000000000
-
-dqmul1076 multiply 1000 1000000000000000 -> 1000000000000000000
-dqmul1077 multiply 1000 100000000000000000000000 -> 100000000000000000000000000
-dqmul1078 multiply 1000 1000000000000000000000000 -> 1000000000000000000000000000
-dqmul1079 multiply 1000 10000000000000000000000000 -> 10000000000000000000000000000
-dqmul1080 multiply 1000 1000000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1081 multiply 10000 0.001 -> 10.000
-dqmul1082 multiply 10000 0.01 -> 100.00
-dqmul1083 multiply 10000 0.1 -> 1000.0
-dqmul1084 multiply 10000 1 -> 10000
-dqmul1085 multiply 10000 10 -> 100000
-dqmul1086 multiply 10000 100 -> 1000000
-dqmul1087 multiply 10000 1000 -> 10000000
-dqmul1088 multiply 10000 10000 -> 100000000
-dqmul1089 multiply 10000 100000 -> 1000000000
-dqmul1090 multiply 10000 1000000 -> 10000000000
-dqmul1091 multiply 10000 10000000 -> 100000000000
-dqmul1092 multiply 10000 100000000 -> 1000000000000
-dqmul1093 multiply 10000 1000000000 -> 10000000000000
-dqmul1094 multiply 10000 10000000000 -> 100000000000000
-dqmul1095 multiply 10000 100000000000 -> 1000000000000000
-
-dqmul1096 multiply 10000 100000000000000 -> 1000000000000000000
-dqmul1097 multiply 10000 10000000000000000000000 -> 100000000000000000000000000
-dqmul1098 multiply 10000 100000000000000000000000 -> 1000000000000000000000000000
-dqmul1099 multiply 10000 1000000000000000000000000 -> 10000000000000000000000000000
-dqmul1100 multiply 10000 100000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1107 multiply 10000 99999999999 -> 999999999990000
-dqmul1108 multiply 10000 99999999999 -> 999999999990000
-
--- Null tests
-dqmul9990 multiply 10 # -> NaN Invalid_operation
-dqmul9991 multiply # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqMultiply.decTest -- decQuad multiplication --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decQuads only; all arguments are
+-- representable in a decQuad
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmul000 multiply 2 2 -> 4
+dqmul001 multiply 2 3 -> 6
+dqmul002 multiply 5 1 -> 5
+dqmul003 multiply 5 2 -> 10
+dqmul004 multiply 1.20 2 -> 2.40
+dqmul005 multiply 1.20 0 -> 0.00
+dqmul006 multiply 1.20 -2 -> -2.40
+dqmul007 multiply -1.20 2 -> -2.40
+dqmul008 multiply -1.20 0 -> -0.00
+dqmul009 multiply -1.20 -2 -> 2.40
+dqmul010 multiply 5.09 7.1 -> 36.139
+dqmul011 multiply 2.5 4 -> 10.0
+dqmul012 multiply 2.50 4 -> 10.00
+dqmul013 multiply 1.23456789 1.0000000000000000000000000000 -> 1.234567890000000000000000000000000 Rounded
+dqmul015 multiply 2.50 4 -> 10.00
+dqmul016 multiply 9.99999999999999999 9.99999999999999999 -> 99.99999999999999980000000000000000 Inexact Rounded
+dqmul017 multiply 9.99999999999999999 -9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
+dqmul018 multiply -9.99999999999999999 9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
+dqmul019 multiply -9.99999999999999999 -9.99999999999999999 -> 99.99999999999999980000000000000000 Inexact Rounded
+
+-- zeros, etc.
+dqmul021 multiply 0 0 -> 0
+dqmul022 multiply 0 -0 -> -0
+dqmul023 multiply -0 0 -> -0
+dqmul024 multiply -0 -0 -> 0
+dqmul025 multiply -0.0 -0.0 -> 0.00
+dqmul026 multiply -0.0 -0.0 -> 0.00
+dqmul027 multiply -0.0 -0.0 -> 0.00
+dqmul028 multiply -0.0 -0.0 -> 0.00
+dqmul030 multiply 5.00 1E-3 -> 0.00500
+dqmul031 multiply 00.00 0.000 -> 0.00000
+dqmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
+dqmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
+dqmul034 multiply -5.00 1E-3 -> -0.00500
+dqmul035 multiply -00.00 0.000 -> -0.00000
+dqmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
+dqmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
+dqmul038 multiply 5.00 -1E-3 -> -0.00500
+dqmul039 multiply 00.00 -0.000 -> -0.00000
+dqmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
+dqmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
+dqmul042 multiply -5.00 -1E-3 -> 0.00500
+dqmul043 multiply -00.00 -0.000 -> 0.00000
+dqmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
+dqmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
+
+-- examples from decarith
+dqmul050 multiply 1.20 3 -> 3.60
+dqmul051 multiply 7 3 -> 21
+dqmul052 multiply 0.9 0.8 -> 0.72
+dqmul053 multiply 0.9 -0 -> -0.0
+dqmul054 multiply 654321 654321 -> 428135971041
+
+dqmul060 multiply 123.45 1e7 -> 1.2345E+9
+dqmul061 multiply 123.45 1e8 -> 1.2345E+10
+dqmul062 multiply 123.45 1e+9 -> 1.2345E+11
+dqmul063 multiply 123.45 1e10 -> 1.2345E+12
+dqmul064 multiply 123.45 1e11 -> 1.2345E+13
+dqmul065 multiply 123.45 1e12 -> 1.2345E+14
+dqmul066 multiply 123.45 1e13 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+-- 1234567890123456
+dqmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
+dqmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
+dqmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
+dqmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
+
+-- test some more edge cases and carries
+dqmul101 multiply 9 9 -> 81
+dqmul102 multiply 9 90 -> 810
+dqmul103 multiply 9 900 -> 8100
+dqmul104 multiply 9 9000 -> 81000
+dqmul105 multiply 9 90000 -> 810000
+dqmul106 multiply 9 900000 -> 8100000
+dqmul107 multiply 9 9000000 -> 81000000
+dqmul108 multiply 9 90000000 -> 810000000
+dqmul109 multiply 9 900000000 -> 8100000000
+dqmul110 multiply 9 9000000000 -> 81000000000
+dqmul111 multiply 9 90000000000 -> 810000000000
+dqmul112 multiply 9 900000000000 -> 8100000000000
+dqmul113 multiply 9 9000000000000 -> 81000000000000
+dqmul114 multiply 9 90000000000000 -> 810000000000000
+dqmul115 multiply 9 900000000000000 -> 8100000000000000
+--dqmul116 multiply 9 9000000000000000 -> 81000000000000000
+--dqmul117 multiply 9 90000000000000000 -> 810000000000000000
+--dqmul118 multiply 9 900000000000000000 -> 8100000000000000000
+--dqmul119 multiply 9 9000000000000000000 -> 81000000000000000000
+--dqmul120 multiply 9 90000000000000000000 -> 810000000000000000000
+--dqmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
+--dqmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
+--dqmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
+-- test some more edge cases without carries
+dqmul131 multiply 3 3 -> 9
+dqmul132 multiply 3 30 -> 90
+dqmul133 multiply 3 300 -> 900
+dqmul134 multiply 3 3000 -> 9000
+dqmul135 multiply 3 30000 -> 90000
+dqmul136 multiply 3 300000 -> 900000
+dqmul137 multiply 3 3000000 -> 9000000
+dqmul138 multiply 3 30000000 -> 90000000
+dqmul139 multiply 3 300000000 -> 900000000
+dqmul140 multiply 3 3000000000 -> 9000000000
+dqmul141 multiply 3 30000000000 -> 90000000000
+dqmul142 multiply 3 300000000000 -> 900000000000
+dqmul143 multiply 3 3000000000000 -> 9000000000000
+dqmul144 multiply 3 30000000000000 -> 90000000000000
+dqmul145 multiply 3 300000000000000 -> 900000000000000
+dqmul146 multiply 3 3000000000000000 -> 9000000000000000
+dqmul147 multiply 3 30000000000000000 -> 90000000000000000
+dqmul148 multiply 3 300000000000000000 -> 900000000000000000
+dqmul149 multiply 3 3000000000000000000 -> 9000000000000000000
+dqmul150 multiply 3 30000000000000000000 -> 90000000000000000000
+dqmul151 multiply 3 300000000000000000000 -> 900000000000000000000
+dqmul152 multiply 3 3000000000000000000000 -> 9000000000000000000000
+dqmul153 multiply 3 30000000000000000000000 -> 90000000000000000000000
+
+dqmul263 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165119928296 Inexact Rounded
+
+-- test some edge cases with exact rounding
+dqmul301 multiply 900000000000000000 9 -> 8100000000000000000
+dqmul302 multiply 900000000000000000 90 -> 81000000000000000000
+dqmul303 multiply 900000000000000000 900 -> 810000000000000000000
+dqmul304 multiply 900000000000000000 9000 -> 8100000000000000000000
+dqmul305 multiply 900000000000000000 90000 -> 81000000000000000000000
+dqmul306 multiply 900000000000000000 900000 -> 810000000000000000000000
+dqmul307 multiply 900000000000000000 9000000 -> 8100000000000000000000000
+dqmul308 multiply 900000000000000000 90000000 -> 81000000000000000000000000
+dqmul309 multiply 900000000000000000 900000000 -> 810000000000000000000000000
+dqmul310 multiply 900000000000000000 9000000000 -> 8100000000000000000000000000
+dqmul311 multiply 900000000000000000 90000000000 -> 81000000000000000000000000000
+dqmul312 multiply 900000000000000000 900000000000 -> 810000000000000000000000000000
+dqmul313 multiply 900000000000000000 9000000000000 -> 8100000000000000000000000000000
+dqmul314 multiply 900000000000000000 90000000000000 -> 81000000000000000000000000000000
+dqmul315 multiply 900000000000000000 900000000000000 -> 810000000000000000000000000000000
+dqmul316 multiply 900000000000000000 9000000000000000 -> 8100000000000000000000000000000000
+dqmul317 multiply 9000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+34 Rounded
+dqmul318 multiply 90000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+35 Rounded
+dqmul319 multiply 900000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+36 Rounded
+dqmul320 multiply 9000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+37 Rounded
+dqmul321 multiply 90000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+38 Rounded
+dqmul322 multiply 900000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+39 Rounded
+dqmul323 multiply 9000000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+40 Rounded
+
+-- tryzeros cases
+dqmul504 multiply 0E-4260 1000E-4260 -> 0E-6176 Clamped
+dqmul505 multiply 100E+4260 0E+4260 -> 0E+6111 Clamped
+
+-- mixed with zeros
+dqmul541 multiply 0 -1 -> -0
+dqmul542 multiply -0 -1 -> 0
+dqmul543 multiply 0 1 -> 0
+dqmul544 multiply -0 1 -> -0
+dqmul545 multiply -1 0 -> -0
+dqmul546 multiply -1 -0 -> 0
+dqmul547 multiply 1 0 -> 0
+dqmul548 multiply 1 -0 -> -0
+
+dqmul551 multiply 0.0 -1 -> -0.0
+dqmul552 multiply -0.0 -1 -> 0.0
+dqmul553 multiply 0.0 1 -> 0.0
+dqmul554 multiply -0.0 1 -> -0.0
+dqmul555 multiply -1.0 0 -> -0.0
+dqmul556 multiply -1.0 -0 -> 0.0
+dqmul557 multiply 1.0 0 -> 0.0
+dqmul558 multiply 1.0 -0 -> -0.0
+
+dqmul561 multiply 0 -1.0 -> -0.0
+dqmul562 multiply -0 -1.0 -> 0.0
+dqmul563 multiply 0 1.0 -> 0.0
+dqmul564 multiply -0 1.0 -> -0.0
+dqmul565 multiply -1 0.0 -> -0.0
+dqmul566 multiply -1 -0.0 -> 0.0
+dqmul567 multiply 1 0.0 -> 0.0
+dqmul568 multiply 1 -0.0 -> -0.0
+
+dqmul571 multiply 0.0 -1.0 -> -0.00
+dqmul572 multiply -0.0 -1.0 -> 0.00
+dqmul573 multiply 0.0 1.0 -> 0.00
+dqmul574 multiply -0.0 1.0 -> -0.00
+dqmul575 multiply -1.0 0.0 -> -0.00
+dqmul576 multiply -1.0 -0.0 -> 0.00
+dqmul577 multiply 1.0 0.0 -> 0.00
+dqmul578 multiply 1.0 -0.0 -> -0.00
+
+
+-- Specials
+dqmul580 multiply Inf -Inf -> -Infinity
+dqmul581 multiply Inf -1000 -> -Infinity
+dqmul582 multiply Inf -1 -> -Infinity
+dqmul583 multiply Inf -0 -> NaN Invalid_operation
+dqmul584 multiply Inf 0 -> NaN Invalid_operation
+dqmul585 multiply Inf 1 -> Infinity
+dqmul586 multiply Inf 1000 -> Infinity
+dqmul587 multiply Inf Inf -> Infinity
+dqmul588 multiply -1000 Inf -> -Infinity
+dqmul589 multiply -Inf Inf -> -Infinity
+dqmul590 multiply -1 Inf -> -Infinity
+dqmul591 multiply -0 Inf -> NaN Invalid_operation
+dqmul592 multiply 0 Inf -> NaN Invalid_operation
+dqmul593 multiply 1 Inf -> Infinity
+dqmul594 multiply 1000 Inf -> Infinity
+dqmul595 multiply Inf Inf -> Infinity
+
+dqmul600 multiply -Inf -Inf -> Infinity
+dqmul601 multiply -Inf -1000 -> Infinity
+dqmul602 multiply -Inf -1 -> Infinity
+dqmul603 multiply -Inf -0 -> NaN Invalid_operation
+dqmul604 multiply -Inf 0 -> NaN Invalid_operation
+dqmul605 multiply -Inf 1 -> -Infinity
+dqmul606 multiply -Inf 1000 -> -Infinity
+dqmul607 multiply -Inf Inf -> -Infinity
+dqmul608 multiply -1000 Inf -> -Infinity
+dqmul609 multiply -Inf -Inf -> Infinity
+dqmul610 multiply -1 -Inf -> Infinity
+dqmul611 multiply -0 -Inf -> NaN Invalid_operation
+dqmul612 multiply 0 -Inf -> NaN Invalid_operation
+dqmul613 multiply 1 -Inf -> -Infinity
+dqmul614 multiply 1000 -Inf -> -Infinity
+dqmul615 multiply Inf -Inf -> -Infinity
+
+dqmul621 multiply NaN -Inf -> NaN
+dqmul622 multiply NaN -1000 -> NaN
+dqmul623 multiply NaN -1 -> NaN
+dqmul624 multiply NaN -0 -> NaN
+dqmul625 multiply NaN 0 -> NaN
+dqmul626 multiply NaN 1 -> NaN
+dqmul627 multiply NaN 1000 -> NaN
+dqmul628 multiply NaN Inf -> NaN
+dqmul629 multiply NaN NaN -> NaN
+dqmul630 multiply -Inf NaN -> NaN
+dqmul631 multiply -1000 NaN -> NaN
+dqmul632 multiply -1 NaN -> NaN
+dqmul633 multiply -0 NaN -> NaN
+dqmul634 multiply 0 NaN -> NaN
+dqmul635 multiply 1 NaN -> NaN
+dqmul636 multiply 1000 NaN -> NaN
+dqmul637 multiply Inf NaN -> NaN
+
+dqmul641 multiply sNaN -Inf -> NaN Invalid_operation
+dqmul642 multiply sNaN -1000 -> NaN Invalid_operation
+dqmul643 multiply sNaN -1 -> NaN Invalid_operation
+dqmul644 multiply sNaN -0 -> NaN Invalid_operation
+dqmul645 multiply sNaN 0 -> NaN Invalid_operation
+dqmul646 multiply sNaN 1 -> NaN Invalid_operation
+dqmul647 multiply sNaN 1000 -> NaN Invalid_operation
+dqmul648 multiply sNaN NaN -> NaN Invalid_operation
+dqmul649 multiply sNaN sNaN -> NaN Invalid_operation
+dqmul650 multiply NaN sNaN -> NaN Invalid_operation
+dqmul651 multiply -Inf sNaN -> NaN Invalid_operation
+dqmul652 multiply -1000 sNaN -> NaN Invalid_operation
+dqmul653 multiply -1 sNaN -> NaN Invalid_operation
+dqmul654 multiply -0 sNaN -> NaN Invalid_operation
+dqmul655 multiply 0 sNaN -> NaN Invalid_operation
+dqmul656 multiply 1 sNaN -> NaN Invalid_operation
+dqmul657 multiply 1000 sNaN -> NaN Invalid_operation
+dqmul658 multiply Inf sNaN -> NaN Invalid_operation
+dqmul659 multiply NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmul661 multiply NaN9 -Inf -> NaN9
+dqmul662 multiply NaN8 999 -> NaN8
+dqmul663 multiply NaN71 Inf -> NaN71
+dqmul664 multiply NaN6 NaN5 -> NaN6
+dqmul665 multiply -Inf NaN4 -> NaN4
+dqmul666 multiply -999 NaN33 -> NaN33
+dqmul667 multiply Inf NaN2 -> NaN2
+
+dqmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
+dqmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
+dqmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
+dqmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
+dqmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
+dqmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
+dqmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
+dqmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
+
+dqmul681 multiply -NaN9 -Inf -> -NaN9
+dqmul682 multiply -NaN8 999 -> -NaN8
+dqmul683 multiply -NaN71 Inf -> -NaN71
+dqmul684 multiply -NaN6 -NaN5 -> -NaN6
+dqmul685 multiply -Inf -NaN4 -> -NaN4
+dqmul686 multiply -999 -NaN33 -> -NaN33
+dqmul687 multiply Inf -NaN2 -> -NaN2
+
+dqmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
+dqmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
+dqmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
+dqmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+dqmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
+dqmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
+dqmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
+
+dqmul701 multiply -NaN -Inf -> -NaN
+dqmul702 multiply -NaN 999 -> -NaN
+dqmul703 multiply -NaN Inf -> -NaN
+dqmul704 multiply -NaN -NaN -> -NaN
+dqmul705 multiply -Inf -NaN0 -> -NaN
+dqmul706 multiply -999 -NaN -> -NaN
+dqmul707 multiply Inf -NaN -> -NaN
+
+dqmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
+dqmul712 multiply -sNaN -11 -> -NaN Invalid_operation
+dqmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
+dqmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
+dqmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
+dqmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
+dqmul717 multiply 088 -sNaN -> -NaN Invalid_operation
+dqmul718 multiply Inf -sNaN -> -NaN Invalid_operation
+dqmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+dqmul751 multiply 1e+4277 1e+3311 -> Infinity Overflow Inexact Rounded
+dqmul752 multiply 1e+4277 -1e+3311 -> -Infinity Overflow Inexact Rounded
+dqmul753 multiply -1e+4277 1e+3311 -> -Infinity Overflow Inexact Rounded
+dqmul754 multiply -1e+4277 -1e+3311 -> Infinity Overflow Inexact Rounded
+dqmul755 multiply 1e-4277 1e-3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul756 multiply 1e-4277 -1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul757 multiply -1e-4277 1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul758 multiply -1e-4277 -1e-3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dqmul760 multiply 1e-6069 1e-101 -> 1E-6170 Subnormal
+dqmul761 multiply 1e-6069 1e-102 -> 1E-6171 Subnormal
+dqmul762 multiply 1e-6069 1e-103 -> 1E-6172 Subnormal
+dqmul763 multiply 1e-6069 1e-104 -> 1E-6173 Subnormal
+dqmul764 multiply 1e-6069 1e-105 -> 1E-6174 Subnormal
+dqmul765 multiply 1e-6069 1e-106 -> 1E-6175 Subnormal
+dqmul766 multiply 1e-6069 1e-107 -> 1E-6176 Subnormal
+dqmul767 multiply 1e-6069 1e-108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul768 multiply 1e-6069 1e-109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul769 multiply 1e-6069 1e-110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+dqmul770 multiply 1e+40 1e+6101 -> 1.000000000000000000000000000000E+6141 Clamped
+dqmul771 multiply 1e+40 1e+6102 -> 1.0000000000000000000000000000000E+6142 Clamped
+dqmul772 multiply 1e+40 1e+6103 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqmul773 multiply 1e+40 1e+6104 -> 1.000000000000000000000000000000000E+6144 Clamped
+dqmul774 multiply 1e+40 1e+6105 -> Infinity Overflow Inexact Rounded
+dqmul775 multiply 1e+40 1e+6106 -> Infinity Overflow Inexact Rounded
+dqmul776 multiply 1e+40 1e+6107 -> Infinity Overflow Inexact Rounded
+dqmul777 multiply 1e+40 1e+6108 -> Infinity Overflow Inexact Rounded
+dqmul778 multiply 1e+40 1e+6109 -> Infinity Overflow Inexact Rounded
+dqmul779 multiply 1e+40 1e+6110 -> Infinity Overflow Inexact Rounded
+
+dqmul801 multiply 1.0000E-6172 1 -> 1.0000E-6172 Subnormal
+dqmul802 multiply 1.000E-6172 1e-1 -> 1.000E-6173 Subnormal
+dqmul803 multiply 1.00E-6172 1e-2 -> 1.00E-6174 Subnormal
+dqmul804 multiply 1.0E-6172 1e-3 -> 1.0E-6175 Subnormal
+dqmul805 multiply 1.0E-6172 1e-4 -> 1E-6176 Subnormal Rounded
+dqmul806 multiply 1.3E-6172 1e-4 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqmul807 multiply 1.5E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul808 multiply 1.7E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul809 multiply 2.3E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul810 multiply 2.5E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul811 multiply 2.7E-6172 1e-4 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqmul812 multiply 1.49E-6172 1e-4 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqmul813 multiply 1.50E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul814 multiply 1.51E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul815 multiply 2.49E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul816 multiply 2.50E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul817 multiply 2.51E-6172 1e-4 -> 3E-6176 Underflow Subnormal Inexact Rounded
+
+dqmul818 multiply 1E-6172 1e-4 -> 1E-6176 Subnormal
+dqmul819 multiply 3E-6172 1e-5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul820 multiply 5E-6172 1e-5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul821 multiply 7E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqmul822 multiply 9E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqmul823 multiply 9.9E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+dqmul824 multiply 1E-6172 -1e-4 -> -1E-6176 Subnormal
+dqmul825 multiply 3E-6172 -1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul826 multiply -5E-6172 1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul827 multiply 7E-6172 -1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqmul828 multiply -9E-6172 1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqmul829 multiply 9.9E-6172 -1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqmul830 multiply 3.0E-6172 -1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqmul831 multiply 1.0E-5977 1e-200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul832 multiply 1.0E-5977 1e-199 -> 1E-6176 Subnormal Rounded
+dqmul833 multiply 1.0E-5977 1e-198 -> 1.0E-6175 Subnormal
+dqmul834 multiply 2.0E-5977 2e-198 -> 4.0E-6175 Subnormal
+dqmul835 multiply 4.0E-5977 4e-198 -> 1.60E-6174 Subnormal
+dqmul836 multiply 10.0E-5977 10e-198 -> 1.000E-6173 Subnormal
+dqmul837 multiply 30.0E-5977 30e-198 -> 9.000E-6173 Subnormal
+dqmul838 multiply 40.0E-5982 40e-166 -> 1.6000E-6145 Subnormal
+dqmul839 multiply 40.0E-5982 40e-165 -> 1.6000E-6144 Subnormal
+dqmul840 multiply 40.0E-5982 40e-164 -> 1.6000E-6143
+
+-- Long operand overflow may be a different path
+dqmul870 multiply 100 9.999E+6143 -> Infinity Inexact Overflow Rounded
+dqmul871 multiply 100 -9.999E+6143 -> -Infinity Inexact Overflow Rounded
+dqmul872 multiply 9.999E+6143 100 -> Infinity Inexact Overflow Rounded
+dqmul873 multiply -9.999E+6143 100 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+dqmul881 multiply 1.2347E-6133 1.2347E-40 -> 1.524E-6173 Inexact Rounded Subnormal Underflow
+dqmul882 multiply 1.234E-6133 1.234E-40 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqmul883 multiply 1.23E-6133 1.23E-40 -> 1.513E-6173 Inexact Rounded Subnormal Underflow
+dqmul884 multiply 1.2E-6133 1.2E-40 -> 1.44E-6173 Subnormal
+dqmul885 multiply 1.2E-6133 1.2E-41 -> 1.44E-6174 Subnormal
+dqmul886 multiply 1.2E-6133 1.2E-42 -> 1.4E-6175 Subnormal Inexact Rounded Underflow
+dqmul887 multiply 1.2E-6133 1.3E-42 -> 1.6E-6175 Subnormal Inexact Rounded Underflow
+dqmul888 multiply 1.3E-6133 1.3E-42 -> 1.7E-6175 Subnormal Inexact Rounded Underflow
+dqmul889 multiply 1.3E-6133 1.3E-43 -> 2E-6176 Subnormal Inexact Rounded Underflow
+dqmul890 multiply 1.3E-6134 1.3E-43 -> 0E-6176 Clamped Subnormal Inexact Rounded Underflow
+
+dqmul891 multiply 1.2345E-39 1.234E-6133 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
+dqmul892 multiply 1.23456E-39 1.234E-6133 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
+dqmul893 multiply 1.2345E-40 1.234E-6133 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqmul894 multiply 1.23456E-40 1.234E-6133 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqmul895 multiply 1.2345E-41 1.234E-6133 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
+dqmul896 multiply 1.23456E-41 1.234E-6133 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+-- prove operands are exact
+dqmul906 multiply 9.999999999999999999999999999999999E-6143 1 -> 9.999999999999999999999999999999999E-6143
+dqmul907 multiply 1 0.09999999999999999999999999999999999 -> 0.09999999999999999999999999999999999
+-- the next rounds to Nmin
+dqmul908 multiply 9.999999999999999999999999999999999E-6143 0.09999999999999999999999999999999999 -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded
+
+-- hugest
+dqmul909 multiply 9999999999999999999999999999999999 9999999999999999999999999999999999 -> 9.999999999999999999999999999999998E+67 Inexact Rounded
+-- VG case
+dqmul910 multiply 8.81125000000001349436E-1548 8.000000000000000000E-1550 -> 7.049000000000010795488000000000000E-3097 Rounded
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+dqmul911 multiply 130E-2 120E-2 -> 1.5600
+dqmul912 multiply 130E-2 12E-1 -> 1.560
+dqmul913 multiply 130E-2 1E0 -> 1.30
+dqmul914 multiply 1E2 1E4 -> 1E+6
+
+-- power-of-ten edge cases
+dqmul1001 multiply 1 10 -> 10
+dqmul1002 multiply 1 100 -> 100
+dqmul1003 multiply 1 1000 -> 1000
+dqmul1004 multiply 1 10000 -> 10000
+dqmul1005 multiply 1 100000 -> 100000
+dqmul1006 multiply 1 1000000 -> 1000000
+dqmul1007 multiply 1 10000000 -> 10000000
+dqmul1008 multiply 1 100000000 -> 100000000
+dqmul1009 multiply 1 1000000000 -> 1000000000
+dqmul1010 multiply 1 10000000000 -> 10000000000
+dqmul1011 multiply 1 100000000000 -> 100000000000
+dqmul1012 multiply 1 1000000000000 -> 1000000000000
+dqmul1013 multiply 1 10000000000000 -> 10000000000000
+dqmul1014 multiply 1 100000000000000 -> 100000000000000
+dqmul1015 multiply 1 1000000000000000 -> 1000000000000000
+
+dqmul1016 multiply 1 1000000000000000000 -> 1000000000000000000
+dqmul1017 multiply 1 100000000000000000000000000 -> 100000000000000000000000000
+dqmul1018 multiply 1 1000000000000000000000000000 -> 1000000000000000000000000000
+dqmul1019 multiply 1 10000000000000000000000000000 -> 10000000000000000000000000000
+dqmul1020 multiply 1 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1021 multiply 10 1 -> 10
+dqmul1022 multiply 10 10 -> 100
+dqmul1023 multiply 10 100 -> 1000
+dqmul1024 multiply 10 1000 -> 10000
+dqmul1025 multiply 10 10000 -> 100000
+dqmul1026 multiply 10 100000 -> 1000000
+dqmul1027 multiply 10 1000000 -> 10000000
+dqmul1028 multiply 10 10000000 -> 100000000
+dqmul1029 multiply 10 100000000 -> 1000000000
+dqmul1030 multiply 10 1000000000 -> 10000000000
+dqmul1031 multiply 10 10000000000 -> 100000000000
+dqmul1032 multiply 10 100000000000 -> 1000000000000
+dqmul1033 multiply 10 1000000000000 -> 10000000000000
+dqmul1034 multiply 10 10000000000000 -> 100000000000000
+dqmul1035 multiply 10 100000000000000 -> 1000000000000000
+
+dqmul1036 multiply 10 100000000000000000 -> 1000000000000000000
+dqmul1037 multiply 10 10000000000000000000000000 -> 100000000000000000000000000
+dqmul1038 multiply 10 100000000000000000000000000 -> 1000000000000000000000000000
+dqmul1039 multiply 10 1000000000000000000000000000 -> 10000000000000000000000000000
+dqmul1040 multiply 10 100000000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1041 multiply 100 0.1 -> 10.0
+dqmul1042 multiply 100 1 -> 100
+dqmul1043 multiply 100 10 -> 1000
+dqmul1044 multiply 100 100 -> 10000
+dqmul1045 multiply 100 1000 -> 100000
+dqmul1046 multiply 100 10000 -> 1000000
+dqmul1047 multiply 100 100000 -> 10000000
+dqmul1048 multiply 100 1000000 -> 100000000
+dqmul1049 multiply 100 10000000 -> 1000000000
+dqmul1050 multiply 100 100000000 -> 10000000000
+dqmul1051 multiply 100 1000000000 -> 100000000000
+dqmul1052 multiply 100 10000000000 -> 1000000000000
+dqmul1053 multiply 100 100000000000 -> 10000000000000
+dqmul1054 multiply 100 1000000000000 -> 100000000000000
+dqmul1055 multiply 100 10000000000000 -> 1000000000000000
+
+dqmul1056 multiply 100 10000000000000000 -> 1000000000000000000
+dqmul1057 multiply 100 1000000000000000000000000 -> 100000000000000000000000000
+dqmul1058 multiply 100 10000000000000000000000000 -> 1000000000000000000000000000
+dqmul1059 multiply 100 100000000000000000000000000 -> 10000000000000000000000000000
+dqmul1060 multiply 100 10000000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1061 multiply 1000 0.01 -> 10.00
+dqmul1062 multiply 1000 0.1 -> 100.0
+dqmul1063 multiply 1000 1 -> 1000
+dqmul1064 multiply 1000 10 -> 10000
+dqmul1065 multiply 1000 100 -> 100000
+dqmul1066 multiply 1000 1000 -> 1000000
+dqmul1067 multiply 1000 10000 -> 10000000
+dqmul1068 multiply 1000 100000 -> 100000000
+dqmul1069 multiply 1000 1000000 -> 1000000000
+dqmul1070 multiply 1000 10000000 -> 10000000000
+dqmul1071 multiply 1000 100000000 -> 100000000000
+dqmul1072 multiply 1000 1000000000 -> 1000000000000
+dqmul1073 multiply 1000 10000000000 -> 10000000000000
+dqmul1074 multiply 1000 100000000000 -> 100000000000000
+dqmul1075 multiply 1000 1000000000000 -> 1000000000000000
+
+dqmul1076 multiply 1000 1000000000000000 -> 1000000000000000000
+dqmul1077 multiply 1000 100000000000000000000000 -> 100000000000000000000000000
+dqmul1078 multiply 1000 1000000000000000000000000 -> 1000000000000000000000000000
+dqmul1079 multiply 1000 10000000000000000000000000 -> 10000000000000000000000000000
+dqmul1080 multiply 1000 1000000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1081 multiply 10000 0.001 -> 10.000
+dqmul1082 multiply 10000 0.01 -> 100.00
+dqmul1083 multiply 10000 0.1 -> 1000.0
+dqmul1084 multiply 10000 1 -> 10000
+dqmul1085 multiply 10000 10 -> 100000
+dqmul1086 multiply 10000 100 -> 1000000
+dqmul1087 multiply 10000 1000 -> 10000000
+dqmul1088 multiply 10000 10000 -> 100000000
+dqmul1089 multiply 10000 100000 -> 1000000000
+dqmul1090 multiply 10000 1000000 -> 10000000000
+dqmul1091 multiply 10000 10000000 -> 100000000000
+dqmul1092 multiply 10000 100000000 -> 1000000000000
+dqmul1093 multiply 10000 1000000000 -> 10000000000000
+dqmul1094 multiply 10000 10000000000 -> 100000000000000
+dqmul1095 multiply 10000 100000000000 -> 1000000000000000
+
+dqmul1096 multiply 10000 100000000000000 -> 1000000000000000000
+dqmul1097 multiply 10000 10000000000000000000000 -> 100000000000000000000000000
+dqmul1098 multiply 10000 100000000000000000000000 -> 1000000000000000000000000000
+dqmul1099 multiply 10000 1000000000000000000000000 -> 10000000000000000000000000000
+dqmul1100 multiply 10000 100000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1107 multiply 10000 99999999999 -> 999999999990000
+dqmul1108 multiply 10000 99999999999 -> 999999999990000
+
+-- Null tests
+dqmul9990 multiply 10 # -> NaN Invalid_operation
+dqmul9991 multiply # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqNextMinus.decTest b/Lib/test/decimaltestdata/dqNextMinus.decTest
index 8177b58c6d..34f39581c3 100644
--- a/Lib/test/decimaltestdata/dqNextMinus.decTest
+++ b/Lib/test/decimaltestdata/dqNextMinus.decTest
@@ -1,126 +1,126 @@
-------------------------------------------------------------------------
--- dqNextMinus.decTest -- decQuad next that is less [754r nextdown] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqnextm001 nextminus 0.9999999999999999999999999999999995 -> 0.9999999999999999999999999999999994
-dqnextm002 nextminus 0.9999999999999999999999999999999996 -> 0.9999999999999999999999999999999995
-dqnextm003 nextminus 0.9999999999999999999999999999999997 -> 0.9999999999999999999999999999999996
-dqnextm004 nextminus 0.9999999999999999999999999999999998 -> 0.9999999999999999999999999999999997
-dqnextm005 nextminus 0.9999999999999999999999999999999999 -> 0.9999999999999999999999999999999998
-dqnextm006 nextminus 1.000000000000000000000000000000000 -> 0.9999999999999999999999999999999999
-dqnextm007 nextminus 1.0 -> 0.9999999999999999999999999999999999
-dqnextm008 nextminus 1 -> 0.9999999999999999999999999999999999
-dqnextm009 nextminus 1.000000000000000000000000000000001 -> 1.000000000000000000000000000000000
-dqnextm010 nextminus 1.000000000000000000000000000000002 -> 1.000000000000000000000000000000001
-dqnextm011 nextminus 1.000000000000000000000000000000003 -> 1.000000000000000000000000000000002
-dqnextm012 nextminus 1.000000000000000000000000000000004 -> 1.000000000000000000000000000000003
-dqnextm013 nextminus 1.000000000000000000000000000000005 -> 1.000000000000000000000000000000004
-dqnextm014 nextminus 1.000000000000000000000000000000006 -> 1.000000000000000000000000000000005
-dqnextm015 nextminus 1.000000000000000000000000000000007 -> 1.000000000000000000000000000000006
-dqnextm016 nextminus 1.000000000000000000000000000000008 -> 1.000000000000000000000000000000007
-dqnextm017 nextminus 1.000000000000000000000000000000009 -> 1.000000000000000000000000000000008
-dqnextm018 nextminus 1.000000000000000000000000000000010 -> 1.000000000000000000000000000000009
-dqnextm019 nextminus 1.000000000000000000000000000000011 -> 1.000000000000000000000000000000010
-dqnextm020 nextminus 1.000000000000000000000000000000012 -> 1.000000000000000000000000000000011
-
-dqnextm021 nextminus -0.9999999999999999999999999999999995 -> -0.9999999999999999999999999999999996
-dqnextm022 nextminus -0.9999999999999999999999999999999996 -> -0.9999999999999999999999999999999997
-dqnextm023 nextminus -0.9999999999999999999999999999999997 -> -0.9999999999999999999999999999999998
-dqnextm024 nextminus -0.9999999999999999999999999999999998 -> -0.9999999999999999999999999999999999
-dqnextm025 nextminus -0.9999999999999999999999999999999999 -> -1.000000000000000000000000000000000
-dqnextm026 nextminus -1.000000000000000000000000000000000 -> -1.000000000000000000000000000000001
-dqnextm027 nextminus -1.0 -> -1.000000000000000000000000000000001
-dqnextm028 nextminus -1 -> -1.000000000000000000000000000000001
-dqnextm029 nextminus -1.000000000000000000000000000000001 -> -1.000000000000000000000000000000002
-dqnextm030 nextminus -1.000000000000000000000000000000002 -> -1.000000000000000000000000000000003
-dqnextm031 nextminus -1.000000000000000000000000000000003 -> -1.000000000000000000000000000000004
-dqnextm032 nextminus -1.000000000000000000000000000000004 -> -1.000000000000000000000000000000005
-dqnextm033 nextminus -1.000000000000000000000000000000005 -> -1.000000000000000000000000000000006
-dqnextm034 nextminus -1.000000000000000000000000000000006 -> -1.000000000000000000000000000000007
-dqnextm035 nextminus -1.000000000000000000000000000000007 -> -1.000000000000000000000000000000008
-dqnextm036 nextminus -1.000000000000000000000000000000008 -> -1.000000000000000000000000000000009
-dqnextm037 nextminus -1.000000000000000000000000000000009 -> -1.000000000000000000000000000000010
-dqnextm038 nextminus -1.000000000000000000000000000000010 -> -1.000000000000000000000000000000011
-dqnextm039 nextminus -1.000000000000000000000000000000011 -> -1.000000000000000000000000000000012
-
--- ultra-tiny inputs
-dqnextm062 nextminus 1E-6176 -> 0E-6176
-dqnextm065 nextminus -1E-6176 -> -2E-6176
-
--- Zeros
-dqnextm100 nextminus -0 -> -1E-6176
-dqnextm101 nextminus 0 -> -1E-6176
-dqnextm102 nextminus 0.00 -> -1E-6176
-dqnextm103 nextminus -0.00 -> -1E-6176
-dqnextm104 nextminus 0E-300 -> -1E-6176
-dqnextm105 nextminus 0E+300 -> -1E-6176
-dqnextm106 nextminus 0E+30000 -> -1E-6176
-dqnextm107 nextminus -0E+30000 -> -1E-6176
-
--- specials
-dqnextm150 nextminus Inf -> 9.999999999999999999999999999999999E+6144
-dqnextm151 nextminus -Inf -> -Infinity
-dqnextm152 nextminus NaN -> NaN
-dqnextm153 nextminus sNaN -> NaN Invalid_operation
-dqnextm154 nextminus NaN77 -> NaN77
-dqnextm155 nextminus sNaN88 -> NaN88 Invalid_operation
-dqnextm156 nextminus -NaN -> -NaN
-dqnextm157 nextminus -sNaN -> -NaN Invalid_operation
-dqnextm158 nextminus -NaN77 -> -NaN77
-dqnextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-dqnextm170 nextminus 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999998E+6144
-dqnextm171 nextminus 9.999999999999999999999999999999998E+6144 -> 9.999999999999999999999999999999997E+6144
-dqnextm172 nextminus 1E-6143 -> 9.99999999999999999999999999999999E-6144
-dqnextm173 nextminus 1.000000000000000000000000000000000E-6143 -> 9.99999999999999999999999999999999E-6144
-dqnextm174 nextminus 9E-6176 -> 8E-6176
-dqnextm175 nextminus 9.9E-6175 -> 9.8E-6175
-dqnextm176 nextminus 9.99999999999999999999999999999E-6147 -> 9.99999999999999999999999999998E-6147
-dqnextm177 nextminus 9.99999999999999999999999999999999E-6144 -> 9.99999999999999999999999999999998E-6144
-dqnextm178 nextminus 9.99999999999999999999999999999998E-6144 -> 9.99999999999999999999999999999997E-6144
-dqnextm179 nextminus 9.99999999999999999999999999999997E-6144 -> 9.99999999999999999999999999999996E-6144
-dqnextm180 nextminus 0E-6176 -> -1E-6176
-dqnextm181 nextminus 1E-6176 -> 0E-6176
-dqnextm182 nextminus 2E-6176 -> 1E-6176
-
-dqnextm183 nextminus -0E-6176 -> -1E-6176
-dqnextm184 nextminus -1E-6176 -> -2E-6176
-dqnextm185 nextminus -2E-6176 -> -3E-6176
-dqnextm186 nextminus -10E-6176 -> -1.1E-6175
-dqnextm187 nextminus -100E-6176 -> -1.01E-6174
-dqnextm188 nextminus -100000E-6176 -> -1.00001E-6171
-dqnextm189 nextminus -1.00000000000000000000000000000E-6143 -> -1.000000000000000000000000000000001E-6143
-dqnextm190 nextminus -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000001E-6143
-dqnextm191 nextminus -1E-6143 -> -1.000000000000000000000000000000001E-6143
-dqnextm192 nextminus -9.999999999999999999999999999999998E+6144 -> -9.999999999999999999999999999999999E+6144
-dqnextm193 nextminus -9.999999999999999999999999999999999E+6144 -> -Infinity
-
--- Null tests
-dqnextm900 nextminus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqNextMinus.decTest -- decQuad next that is less [754r nextdown] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqnextm001 nextminus 0.9999999999999999999999999999999995 -> 0.9999999999999999999999999999999994
+dqnextm002 nextminus 0.9999999999999999999999999999999996 -> 0.9999999999999999999999999999999995
+dqnextm003 nextminus 0.9999999999999999999999999999999997 -> 0.9999999999999999999999999999999996
+dqnextm004 nextminus 0.9999999999999999999999999999999998 -> 0.9999999999999999999999999999999997
+dqnextm005 nextminus 0.9999999999999999999999999999999999 -> 0.9999999999999999999999999999999998
+dqnextm006 nextminus 1.000000000000000000000000000000000 -> 0.9999999999999999999999999999999999
+dqnextm007 nextminus 1.0 -> 0.9999999999999999999999999999999999
+dqnextm008 nextminus 1 -> 0.9999999999999999999999999999999999
+dqnextm009 nextminus 1.000000000000000000000000000000001 -> 1.000000000000000000000000000000000
+dqnextm010 nextminus 1.000000000000000000000000000000002 -> 1.000000000000000000000000000000001
+dqnextm011 nextminus 1.000000000000000000000000000000003 -> 1.000000000000000000000000000000002
+dqnextm012 nextminus 1.000000000000000000000000000000004 -> 1.000000000000000000000000000000003
+dqnextm013 nextminus 1.000000000000000000000000000000005 -> 1.000000000000000000000000000000004
+dqnextm014 nextminus 1.000000000000000000000000000000006 -> 1.000000000000000000000000000000005
+dqnextm015 nextminus 1.000000000000000000000000000000007 -> 1.000000000000000000000000000000006
+dqnextm016 nextminus 1.000000000000000000000000000000008 -> 1.000000000000000000000000000000007
+dqnextm017 nextminus 1.000000000000000000000000000000009 -> 1.000000000000000000000000000000008
+dqnextm018 nextminus 1.000000000000000000000000000000010 -> 1.000000000000000000000000000000009
+dqnextm019 nextminus 1.000000000000000000000000000000011 -> 1.000000000000000000000000000000010
+dqnextm020 nextminus 1.000000000000000000000000000000012 -> 1.000000000000000000000000000000011
+
+dqnextm021 nextminus -0.9999999999999999999999999999999995 -> -0.9999999999999999999999999999999996
+dqnextm022 nextminus -0.9999999999999999999999999999999996 -> -0.9999999999999999999999999999999997
+dqnextm023 nextminus -0.9999999999999999999999999999999997 -> -0.9999999999999999999999999999999998
+dqnextm024 nextminus -0.9999999999999999999999999999999998 -> -0.9999999999999999999999999999999999
+dqnextm025 nextminus -0.9999999999999999999999999999999999 -> -1.000000000000000000000000000000000
+dqnextm026 nextminus -1.000000000000000000000000000000000 -> -1.000000000000000000000000000000001
+dqnextm027 nextminus -1.0 -> -1.000000000000000000000000000000001
+dqnextm028 nextminus -1 -> -1.000000000000000000000000000000001
+dqnextm029 nextminus -1.000000000000000000000000000000001 -> -1.000000000000000000000000000000002
+dqnextm030 nextminus -1.000000000000000000000000000000002 -> -1.000000000000000000000000000000003
+dqnextm031 nextminus -1.000000000000000000000000000000003 -> -1.000000000000000000000000000000004
+dqnextm032 nextminus -1.000000000000000000000000000000004 -> -1.000000000000000000000000000000005
+dqnextm033 nextminus -1.000000000000000000000000000000005 -> -1.000000000000000000000000000000006
+dqnextm034 nextminus -1.000000000000000000000000000000006 -> -1.000000000000000000000000000000007
+dqnextm035 nextminus -1.000000000000000000000000000000007 -> -1.000000000000000000000000000000008
+dqnextm036 nextminus -1.000000000000000000000000000000008 -> -1.000000000000000000000000000000009
+dqnextm037 nextminus -1.000000000000000000000000000000009 -> -1.000000000000000000000000000000010
+dqnextm038 nextminus -1.000000000000000000000000000000010 -> -1.000000000000000000000000000000011
+dqnextm039 nextminus -1.000000000000000000000000000000011 -> -1.000000000000000000000000000000012
+
+-- ultra-tiny inputs
+dqnextm062 nextminus 1E-6176 -> 0E-6176
+dqnextm065 nextminus -1E-6176 -> -2E-6176
+
+-- Zeros
+dqnextm100 nextminus -0 -> -1E-6176
+dqnextm101 nextminus 0 -> -1E-6176
+dqnextm102 nextminus 0.00 -> -1E-6176
+dqnextm103 nextminus -0.00 -> -1E-6176
+dqnextm104 nextminus 0E-300 -> -1E-6176
+dqnextm105 nextminus 0E+300 -> -1E-6176
+dqnextm106 nextminus 0E+30000 -> -1E-6176
+dqnextm107 nextminus -0E+30000 -> -1E-6176
+
+-- specials
+dqnextm150 nextminus Inf -> 9.999999999999999999999999999999999E+6144
+dqnextm151 nextminus -Inf -> -Infinity
+dqnextm152 nextminus NaN -> NaN
+dqnextm153 nextminus sNaN -> NaN Invalid_operation
+dqnextm154 nextminus NaN77 -> NaN77
+dqnextm155 nextminus sNaN88 -> NaN88 Invalid_operation
+dqnextm156 nextminus -NaN -> -NaN
+dqnextm157 nextminus -sNaN -> -NaN Invalid_operation
+dqnextm158 nextminus -NaN77 -> -NaN77
+dqnextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+dqnextm170 nextminus 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999998E+6144
+dqnextm171 nextminus 9.999999999999999999999999999999998E+6144 -> 9.999999999999999999999999999999997E+6144
+dqnextm172 nextminus 1E-6143 -> 9.99999999999999999999999999999999E-6144
+dqnextm173 nextminus 1.000000000000000000000000000000000E-6143 -> 9.99999999999999999999999999999999E-6144
+dqnextm174 nextminus 9E-6176 -> 8E-6176
+dqnextm175 nextminus 9.9E-6175 -> 9.8E-6175
+dqnextm176 nextminus 9.99999999999999999999999999999E-6147 -> 9.99999999999999999999999999998E-6147
+dqnextm177 nextminus 9.99999999999999999999999999999999E-6144 -> 9.99999999999999999999999999999998E-6144
+dqnextm178 nextminus 9.99999999999999999999999999999998E-6144 -> 9.99999999999999999999999999999997E-6144
+dqnextm179 nextminus 9.99999999999999999999999999999997E-6144 -> 9.99999999999999999999999999999996E-6144
+dqnextm180 nextminus 0E-6176 -> -1E-6176
+dqnextm181 nextminus 1E-6176 -> 0E-6176
+dqnextm182 nextminus 2E-6176 -> 1E-6176
+
+dqnextm183 nextminus -0E-6176 -> -1E-6176
+dqnextm184 nextminus -1E-6176 -> -2E-6176
+dqnextm185 nextminus -2E-6176 -> -3E-6176
+dqnextm186 nextminus -10E-6176 -> -1.1E-6175
+dqnextm187 nextminus -100E-6176 -> -1.01E-6174
+dqnextm188 nextminus -100000E-6176 -> -1.00001E-6171
+dqnextm189 nextminus -1.00000000000000000000000000000E-6143 -> -1.000000000000000000000000000000001E-6143
+dqnextm190 nextminus -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000001E-6143
+dqnextm191 nextminus -1E-6143 -> -1.000000000000000000000000000000001E-6143
+dqnextm192 nextminus -9.999999999999999999999999999999998E+6144 -> -9.999999999999999999999999999999999E+6144
+dqnextm193 nextminus -9.999999999999999999999999999999999E+6144 -> -Infinity
+
+-- Null tests
+dqnextm900 nextminus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqNextPlus.decTest b/Lib/test/decimaltestdata/dqNextPlus.decTest
index 8c8e9cd2e7..ac3f04e69b 100644
--- a/Lib/test/decimaltestdata/dqNextPlus.decTest
+++ b/Lib/test/decimaltestdata/dqNextPlus.decTest
@@ -1,124 +1,124 @@
-------------------------------------------------------------------------
--- dqNextPlus.decTest -- decQuad next that is greater [754r nextup] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqnextp001 nextplus 0.9999999999999999999999999999999995 -> 0.9999999999999999999999999999999996
-dqnextp002 nextplus 0.9999999999999999999999999999999996 -> 0.9999999999999999999999999999999997
-dqnextp003 nextplus 0.9999999999999999999999999999999997 -> 0.9999999999999999999999999999999998
-dqnextp004 nextplus 0.9999999999999999999999999999999998 -> 0.9999999999999999999999999999999999
-dqnextp005 nextplus 0.9999999999999999999999999999999999 -> 1.000000000000000000000000000000000
-dqnextp006 nextplus 1.000000000000000000000000000000000 -> 1.000000000000000000000000000000001
-dqnextp007 nextplus 1.0 -> 1.000000000000000000000000000000001
-dqnextp008 nextplus 1 -> 1.000000000000000000000000000000001
-dqnextp009 nextplus 1.000000000000000000000000000000001 -> 1.000000000000000000000000000000002
-dqnextp010 nextplus 1.000000000000000000000000000000002 -> 1.000000000000000000000000000000003
-dqnextp011 nextplus 1.000000000000000000000000000000003 -> 1.000000000000000000000000000000004
-dqnextp012 nextplus 1.000000000000000000000000000000004 -> 1.000000000000000000000000000000005
-dqnextp013 nextplus 1.000000000000000000000000000000005 -> 1.000000000000000000000000000000006
-dqnextp014 nextplus 1.000000000000000000000000000000006 -> 1.000000000000000000000000000000007
-dqnextp015 nextplus 1.000000000000000000000000000000007 -> 1.000000000000000000000000000000008
-dqnextp016 nextplus 1.000000000000000000000000000000008 -> 1.000000000000000000000000000000009
-dqnextp017 nextplus 1.000000000000000000000000000000009 -> 1.000000000000000000000000000000010
-dqnextp018 nextplus 1.000000000000000000000000000000010 -> 1.000000000000000000000000000000011
-dqnextp019 nextplus 1.000000000000000000000000000000011 -> 1.000000000000000000000000000000012
-
-dqnextp021 nextplus -0.9999999999999999999999999999999995 -> -0.9999999999999999999999999999999994
-dqnextp022 nextplus -0.9999999999999999999999999999999996 -> -0.9999999999999999999999999999999995
-dqnextp023 nextplus -0.9999999999999999999999999999999997 -> -0.9999999999999999999999999999999996
-dqnextp024 nextplus -0.9999999999999999999999999999999998 -> -0.9999999999999999999999999999999997
-dqnextp025 nextplus -0.9999999999999999999999999999999999 -> -0.9999999999999999999999999999999998
-dqnextp026 nextplus -1.000000000000000000000000000000000 -> -0.9999999999999999999999999999999999
-dqnextp027 nextplus -1.0 -> -0.9999999999999999999999999999999999
-dqnextp028 nextplus -1 -> -0.9999999999999999999999999999999999
-dqnextp029 nextplus -1.000000000000000000000000000000001 -> -1.000000000000000000000000000000000
-dqnextp030 nextplus -1.000000000000000000000000000000002 -> -1.000000000000000000000000000000001
-dqnextp031 nextplus -1.000000000000000000000000000000003 -> -1.000000000000000000000000000000002
-dqnextp032 nextplus -1.000000000000000000000000000000004 -> -1.000000000000000000000000000000003
-dqnextp033 nextplus -1.000000000000000000000000000000005 -> -1.000000000000000000000000000000004
-dqnextp034 nextplus -1.000000000000000000000000000000006 -> -1.000000000000000000000000000000005
-dqnextp035 nextplus -1.000000000000000000000000000000007 -> -1.000000000000000000000000000000006
-dqnextp036 nextplus -1.000000000000000000000000000000008 -> -1.000000000000000000000000000000007
-dqnextp037 nextplus -1.000000000000000000000000000000009 -> -1.000000000000000000000000000000008
-dqnextp038 nextplus -1.000000000000000000000000000000010 -> -1.000000000000000000000000000000009
-dqnextp039 nextplus -1.000000000000000000000000000000011 -> -1.000000000000000000000000000000010
-dqnextp040 nextplus -1.000000000000000000000000000000012 -> -1.000000000000000000000000000000011
-
--- Zeros
-dqnextp100 nextplus 0 -> 1E-6176
-dqnextp101 nextplus 0.00 -> 1E-6176
-dqnextp102 nextplus 0E-300 -> 1E-6176
-dqnextp103 nextplus 0E+300 -> 1E-6176
-dqnextp104 nextplus 0E+30000 -> 1E-6176
-dqnextp105 nextplus -0 -> 1E-6176
-dqnextp106 nextplus -0.00 -> 1E-6176
-dqnextp107 nextplus -0E-300 -> 1E-6176
-dqnextp108 nextplus -0E+300 -> 1E-6176
-dqnextp109 nextplus -0E+30000 -> 1E-6176
-
--- specials
-dqnextp150 nextplus Inf -> Infinity
-dqnextp151 nextplus -Inf -> -9.999999999999999999999999999999999E+6144
-dqnextp152 nextplus NaN -> NaN
-dqnextp153 nextplus sNaN -> NaN Invalid_operation
-dqnextp154 nextplus NaN77 -> NaN77
-dqnextp155 nextplus sNaN88 -> NaN88 Invalid_operation
-dqnextp156 nextplus -NaN -> -NaN
-dqnextp157 nextplus -sNaN -> -NaN Invalid_operation
-dqnextp158 nextplus -NaN77 -> -NaN77
-dqnextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-dqnextp170 nextplus -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999998E+6144
-dqnextp171 nextplus -9.999999999999999999999999999999998E+6144 -> -9.999999999999999999999999999999997E+6144
-dqnextp172 nextplus -1E-6143 -> -9.99999999999999999999999999999999E-6144
-dqnextp173 nextplus -1.000000000000000E-6143 -> -9.99999999999999999999999999999999E-6144
-dqnextp174 nextplus -9E-6176 -> -8E-6176
-dqnextp175 nextplus -9.9E-6175 -> -9.8E-6175
-dqnextp176 nextplus -9.99999999999999999999999999999E-6147 -> -9.99999999999999999999999999998E-6147
-dqnextp177 nextplus -9.99999999999999999999999999999999E-6144 -> -9.99999999999999999999999999999998E-6144
-dqnextp178 nextplus -9.99999999999999999999999999999998E-6144 -> -9.99999999999999999999999999999997E-6144
-dqnextp179 nextplus -9.99999999999999999999999999999997E-6144 -> -9.99999999999999999999999999999996E-6144
-dqnextp180 nextplus -0E-6176 -> 1E-6176
-dqnextp181 nextplus -1E-6176 -> -0E-6176
-dqnextp182 nextplus -2E-6176 -> -1E-6176
-
-dqnextp183 nextplus 0E-6176 -> 1E-6176
-dqnextp184 nextplus 1E-6176 -> 2E-6176
-dqnextp185 nextplus 2E-6176 -> 3E-6176
-dqnextp186 nextplus 10E-6176 -> 1.1E-6175
-dqnextp187 nextplus 100E-6176 -> 1.01E-6174
-dqnextp188 nextplus 100000E-6176 -> 1.00001E-6171
-dqnextp189 nextplus 1.00000000000000000000000000000E-6143 -> 1.000000000000000000000000000000001E-6143
-dqnextp190 nextplus 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000001E-6143
-dqnextp191 nextplus 1E-6143 -> 1.000000000000000000000000000000001E-6143
-dqnextp192 nextplus 9.999999999999999999999999999999998E+6144 -> 9.999999999999999999999999999999999E+6144
-dqnextp193 nextplus 9.999999999999999999999999999999999E+6144 -> Infinity
-
--- Null tests
-dqnextp900 nextplus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqNextPlus.decTest -- decQuad next that is greater [754r nextup] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqnextp001 nextplus 0.9999999999999999999999999999999995 -> 0.9999999999999999999999999999999996
+dqnextp002 nextplus 0.9999999999999999999999999999999996 -> 0.9999999999999999999999999999999997
+dqnextp003 nextplus 0.9999999999999999999999999999999997 -> 0.9999999999999999999999999999999998
+dqnextp004 nextplus 0.9999999999999999999999999999999998 -> 0.9999999999999999999999999999999999
+dqnextp005 nextplus 0.9999999999999999999999999999999999 -> 1.000000000000000000000000000000000
+dqnextp006 nextplus 1.000000000000000000000000000000000 -> 1.000000000000000000000000000000001
+dqnextp007 nextplus 1.0 -> 1.000000000000000000000000000000001
+dqnextp008 nextplus 1 -> 1.000000000000000000000000000000001
+dqnextp009 nextplus 1.000000000000000000000000000000001 -> 1.000000000000000000000000000000002
+dqnextp010 nextplus 1.000000000000000000000000000000002 -> 1.000000000000000000000000000000003
+dqnextp011 nextplus 1.000000000000000000000000000000003 -> 1.000000000000000000000000000000004
+dqnextp012 nextplus 1.000000000000000000000000000000004 -> 1.000000000000000000000000000000005
+dqnextp013 nextplus 1.000000000000000000000000000000005 -> 1.000000000000000000000000000000006
+dqnextp014 nextplus 1.000000000000000000000000000000006 -> 1.000000000000000000000000000000007
+dqnextp015 nextplus 1.000000000000000000000000000000007 -> 1.000000000000000000000000000000008
+dqnextp016 nextplus 1.000000000000000000000000000000008 -> 1.000000000000000000000000000000009
+dqnextp017 nextplus 1.000000000000000000000000000000009 -> 1.000000000000000000000000000000010
+dqnextp018 nextplus 1.000000000000000000000000000000010 -> 1.000000000000000000000000000000011
+dqnextp019 nextplus 1.000000000000000000000000000000011 -> 1.000000000000000000000000000000012
+
+dqnextp021 nextplus -0.9999999999999999999999999999999995 -> -0.9999999999999999999999999999999994
+dqnextp022 nextplus -0.9999999999999999999999999999999996 -> -0.9999999999999999999999999999999995
+dqnextp023 nextplus -0.9999999999999999999999999999999997 -> -0.9999999999999999999999999999999996
+dqnextp024 nextplus -0.9999999999999999999999999999999998 -> -0.9999999999999999999999999999999997
+dqnextp025 nextplus -0.9999999999999999999999999999999999 -> -0.9999999999999999999999999999999998
+dqnextp026 nextplus -1.000000000000000000000000000000000 -> -0.9999999999999999999999999999999999
+dqnextp027 nextplus -1.0 -> -0.9999999999999999999999999999999999
+dqnextp028 nextplus -1 -> -0.9999999999999999999999999999999999
+dqnextp029 nextplus -1.000000000000000000000000000000001 -> -1.000000000000000000000000000000000
+dqnextp030 nextplus -1.000000000000000000000000000000002 -> -1.000000000000000000000000000000001
+dqnextp031 nextplus -1.000000000000000000000000000000003 -> -1.000000000000000000000000000000002
+dqnextp032 nextplus -1.000000000000000000000000000000004 -> -1.000000000000000000000000000000003
+dqnextp033 nextplus -1.000000000000000000000000000000005 -> -1.000000000000000000000000000000004
+dqnextp034 nextplus -1.000000000000000000000000000000006 -> -1.000000000000000000000000000000005
+dqnextp035 nextplus -1.000000000000000000000000000000007 -> -1.000000000000000000000000000000006
+dqnextp036 nextplus -1.000000000000000000000000000000008 -> -1.000000000000000000000000000000007
+dqnextp037 nextplus -1.000000000000000000000000000000009 -> -1.000000000000000000000000000000008
+dqnextp038 nextplus -1.000000000000000000000000000000010 -> -1.000000000000000000000000000000009
+dqnextp039 nextplus -1.000000000000000000000000000000011 -> -1.000000000000000000000000000000010
+dqnextp040 nextplus -1.000000000000000000000000000000012 -> -1.000000000000000000000000000000011
+
+-- Zeros
+dqnextp100 nextplus 0 -> 1E-6176
+dqnextp101 nextplus 0.00 -> 1E-6176
+dqnextp102 nextplus 0E-300 -> 1E-6176
+dqnextp103 nextplus 0E+300 -> 1E-6176
+dqnextp104 nextplus 0E+30000 -> 1E-6176
+dqnextp105 nextplus -0 -> 1E-6176
+dqnextp106 nextplus -0.00 -> 1E-6176
+dqnextp107 nextplus -0E-300 -> 1E-6176
+dqnextp108 nextplus -0E+300 -> 1E-6176
+dqnextp109 nextplus -0E+30000 -> 1E-6176
+
+-- specials
+dqnextp150 nextplus Inf -> Infinity
+dqnextp151 nextplus -Inf -> -9.999999999999999999999999999999999E+6144
+dqnextp152 nextplus NaN -> NaN
+dqnextp153 nextplus sNaN -> NaN Invalid_operation
+dqnextp154 nextplus NaN77 -> NaN77
+dqnextp155 nextplus sNaN88 -> NaN88 Invalid_operation
+dqnextp156 nextplus -NaN -> -NaN
+dqnextp157 nextplus -sNaN -> -NaN Invalid_operation
+dqnextp158 nextplus -NaN77 -> -NaN77
+dqnextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+dqnextp170 nextplus -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999998E+6144
+dqnextp171 nextplus -9.999999999999999999999999999999998E+6144 -> -9.999999999999999999999999999999997E+6144
+dqnextp172 nextplus -1E-6143 -> -9.99999999999999999999999999999999E-6144
+dqnextp173 nextplus -1.000000000000000E-6143 -> -9.99999999999999999999999999999999E-6144
+dqnextp174 nextplus -9E-6176 -> -8E-6176
+dqnextp175 nextplus -9.9E-6175 -> -9.8E-6175
+dqnextp176 nextplus -9.99999999999999999999999999999E-6147 -> -9.99999999999999999999999999998E-6147
+dqnextp177 nextplus -9.99999999999999999999999999999999E-6144 -> -9.99999999999999999999999999999998E-6144
+dqnextp178 nextplus -9.99999999999999999999999999999998E-6144 -> -9.99999999999999999999999999999997E-6144
+dqnextp179 nextplus -9.99999999999999999999999999999997E-6144 -> -9.99999999999999999999999999999996E-6144
+dqnextp180 nextplus -0E-6176 -> 1E-6176
+dqnextp181 nextplus -1E-6176 -> -0E-6176
+dqnextp182 nextplus -2E-6176 -> -1E-6176
+
+dqnextp183 nextplus 0E-6176 -> 1E-6176
+dqnextp184 nextplus 1E-6176 -> 2E-6176
+dqnextp185 nextplus 2E-6176 -> 3E-6176
+dqnextp186 nextplus 10E-6176 -> 1.1E-6175
+dqnextp187 nextplus 100E-6176 -> 1.01E-6174
+dqnextp188 nextplus 100000E-6176 -> 1.00001E-6171
+dqnextp189 nextplus 1.00000000000000000000000000000E-6143 -> 1.000000000000000000000000000000001E-6143
+dqnextp190 nextplus 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000001E-6143
+dqnextp191 nextplus 1E-6143 -> 1.000000000000000000000000000000001E-6143
+dqnextp192 nextplus 9.999999999999999999999999999999998E+6144 -> 9.999999999999999999999999999999999E+6144
+dqnextp193 nextplus 9.999999999999999999999999999999999E+6144 -> Infinity
+
+-- Null tests
+dqnextp900 nextplus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqNextToward.decTest b/Lib/test/decimaltestdata/dqNextToward.decTest
index 107e7f5c50..e6d1e0befb 100644
--- a/Lib/test/decimaltestdata/dqNextToward.decTest
+++ b/Lib/test/decimaltestdata/dqNextToward.decTest
@@ -1,375 +1,375 @@
-------------------------------------------------------------------------
--- dqNextToward.decTest -- decQuad next toward rhs [754r nextafter] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-
--- Sanity check with a scattering of numerics
-dqnextt001 nexttoward 10 10 -> 10
-dqnextt002 nexttoward -10 -10 -> -10
-dqnextt003 nexttoward 1 10 -> 1.000000000000000000000000000000001
-dqnextt004 nexttoward 1 -10 -> 0.9999999999999999999999999999999999
-dqnextt005 nexttoward -1 10 -> -0.9999999999999999999999999999999999
-dqnextt006 nexttoward -1 -10 -> -1.000000000000000000000000000000001
-dqnextt007 nexttoward 0 10 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt008 nexttoward 0 -10 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt009 nexttoward 9.999999999999999999999999999999999E+6144 +Infinity -> Infinity Overflow Inexact Rounded
-dqnextt010 nexttoward -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
-dqnextt011 nexttoward 9.999999999999999999999999999999999 10 -> 10.00000000000000000000000000000000
-dqnextt012 nexttoward 10 9.999999999999999999999999999999999 -> 9.999999999999999999999999999999999
-dqnextt013 nexttoward -9.999999999999999999999999999999999 -10 -> -10.00000000000000000000000000000000
-dqnextt014 nexttoward -10 -9.999999999999999999999999999999999 -> -9.999999999999999999999999999999999
-dqnextt015 nexttoward 9.999999999999999999999999999999998 10 -> 9.999999999999999999999999999999999
-dqnextt016 nexttoward 10 9.999999999999999999999999999999998 -> 9.999999999999999999999999999999999
-dqnextt017 nexttoward -9.999999999999999999999999999999998 -10 -> -9.999999999999999999999999999999999
-dqnextt018 nexttoward -10 -9.999999999999999999999999999999998 -> -9.999999999999999999999999999999999
-
-------- lhs=rhs
--- finites
-dqnextt101 nexttoward 7 7 -> 7
-dqnextt102 nexttoward -7 -7 -> -7
-dqnextt103 nexttoward 75 75 -> 75
-dqnextt104 nexttoward -75 -75 -> -75
-dqnextt105 nexttoward 7.50 7.5 -> 7.50
-dqnextt106 nexttoward -7.50 -7.50 -> -7.50
-dqnextt107 nexttoward 7.500 7.5000 -> 7.500
-dqnextt108 nexttoward -7.500 -7.5 -> -7.500
-
--- zeros
-dqnextt111 nexttoward 0 0 -> 0
-dqnextt112 nexttoward -0 -0 -> -0
-dqnextt113 nexttoward 0E+4 0 -> 0E+4
-dqnextt114 nexttoward -0E+4 -0 -> -0E+4
-dqnextt115 nexttoward 0.00000000000 0.000000000000 -> 0E-11
-dqnextt116 nexttoward -0.00000000000 -0.00 -> -0E-11
-dqnextt117 nexttoward 0E-141 0 -> 0E-141
-dqnextt118 nexttoward -0E-141 -000 -> -0E-141
-
--- full coefficients, alternating bits
-dqnextt121 nexttoward 268268268 268268268 -> 268268268
-dqnextt122 nexttoward -268268268 -268268268 -> -268268268
-dqnextt123 nexttoward 134134134 134134134 -> 134134134
-dqnextt124 nexttoward -134134134 -134134134 -> -134134134
-
--- Nmax, Nmin, Ntiny
-dqnextt131 nexttoward 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqnextt132 nexttoward 1E-6143 1E-6143 -> 1E-6143
-dqnextt133 nexttoward 1.000000000000000000000000000000000E-6143 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqnextt134 nexttoward 1E-6176 1E-6176 -> 1E-6176
-
-dqnextt135 nexttoward -1E-6176 -1E-6176 -> -1E-6176
-dqnextt136 nexttoward -1.000000000000000000000000000000000E-6143 -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqnextt137 nexttoward -1E-6143 -1E-6143 -> -1E-6143
-dqnextt138 nexttoward -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-
-------- lhs<rhs
-dqnextt201 nexttoward 0.9999999999999999999999999999999995 Infinity -> 0.9999999999999999999999999999999996
-dqnextt202 nexttoward 0.9999999999999999999999999999999996 Infinity -> 0.9999999999999999999999999999999997
-dqnextt203 nexttoward 0.9999999999999999999999999999999997 Infinity -> 0.9999999999999999999999999999999998
-dqnextt204 nexttoward 0.9999999999999999999999999999999998 Infinity -> 0.9999999999999999999999999999999999
-dqnextt205 nexttoward 0.9999999999999999999999999999999999 Infinity -> 1.000000000000000000000000000000000
-dqnextt206 nexttoward 1.000000000000000000000000000000000 Infinity -> 1.000000000000000000000000000000001
-dqnextt207 nexttoward 1.0 Infinity -> 1.000000000000000000000000000000001
-dqnextt208 nexttoward 1 Infinity -> 1.000000000000000000000000000000001
-dqnextt209 nexttoward 1.000000000000000000000000000000001 Infinity -> 1.000000000000000000000000000000002
-dqnextt210 nexttoward 1.000000000000000000000000000000002 Infinity -> 1.000000000000000000000000000000003
-dqnextt211 nexttoward 1.000000000000000000000000000000003 Infinity -> 1.000000000000000000000000000000004
-dqnextt212 nexttoward 1.000000000000000000000000000000004 Infinity -> 1.000000000000000000000000000000005
-dqnextt213 nexttoward 1.000000000000000000000000000000005 Infinity -> 1.000000000000000000000000000000006
-dqnextt214 nexttoward 1.000000000000000000000000000000006 Infinity -> 1.000000000000000000000000000000007
-dqnextt215 nexttoward 1.000000000000000000000000000000007 Infinity -> 1.000000000000000000000000000000008
-dqnextt216 nexttoward 1.000000000000000000000000000000008 Infinity -> 1.000000000000000000000000000000009
-dqnextt217 nexttoward 1.000000000000000000000000000000009 Infinity -> 1.000000000000000000000000000000010
-dqnextt218 nexttoward 1.000000000000000000000000000000010 Infinity -> 1.000000000000000000000000000000011
-dqnextt219 nexttoward 1.000000000000000000000000000000011 Infinity -> 1.000000000000000000000000000000012
-
-dqnextt221 nexttoward -0.9999999999999999999999999999999995 Infinity -> -0.9999999999999999999999999999999994
-dqnextt222 nexttoward -0.9999999999999999999999999999999996 Infinity -> -0.9999999999999999999999999999999995
-dqnextt223 nexttoward -0.9999999999999999999999999999999997 Infinity -> -0.9999999999999999999999999999999996
-dqnextt224 nexttoward -0.9999999999999999999999999999999998 Infinity -> -0.9999999999999999999999999999999997
-dqnextt225 nexttoward -0.9999999999999999999999999999999999 Infinity -> -0.9999999999999999999999999999999998
-dqnextt226 nexttoward -1.000000000000000000000000000000000 Infinity -> -0.9999999999999999999999999999999999
-dqnextt227 nexttoward -1.0 Infinity -> -0.9999999999999999999999999999999999
-dqnextt228 nexttoward -1 Infinity -> -0.9999999999999999999999999999999999
-dqnextt229 nexttoward -1.000000000000000000000000000000001 Infinity -> -1.000000000000000000000000000000000
-dqnextt230 nexttoward -1.000000000000000000000000000000002 Infinity -> -1.000000000000000000000000000000001
-dqnextt231 nexttoward -1.000000000000000000000000000000003 Infinity -> -1.000000000000000000000000000000002
-dqnextt232 nexttoward -1.000000000000000000000000000000004 Infinity -> -1.000000000000000000000000000000003
-dqnextt233 nexttoward -1.000000000000000000000000000000005 Infinity -> -1.000000000000000000000000000000004
-dqnextt234 nexttoward -1.000000000000000000000000000000006 Infinity -> -1.000000000000000000000000000000005
-dqnextt235 nexttoward -1.000000000000000000000000000000007 Infinity -> -1.000000000000000000000000000000006
-dqnextt236 nexttoward -1.000000000000000000000000000000008 Infinity -> -1.000000000000000000000000000000007
-dqnextt237 nexttoward -1.000000000000000000000000000000009 Infinity -> -1.000000000000000000000000000000008
-dqnextt238 nexttoward -1.000000000000000000000000000000010 Infinity -> -1.000000000000000000000000000000009
-dqnextt239 nexttoward -1.000000000000000000000000000000011 Infinity -> -1.000000000000000000000000000000010
-dqnextt240 nexttoward -1.000000000000000000000000000000012 Infinity -> -1.000000000000000000000000000000011
-
--- Zeros
-dqnextt300 nexttoward 0 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt301 nexttoward 0.00 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt302 nexttoward 0E-300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt303 nexttoward 0E+300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt304 nexttoward 0E+30000 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt305 nexttoward -0 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt306 nexttoward -0.00 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt307 nexttoward -0E-300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt308 nexttoward -0E+300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt309 nexttoward -0E+30000 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-
--- specials
-dqnextt350 nexttoward Inf Infinity -> Infinity
-dqnextt351 nexttoward -Inf Infinity -> -9.999999999999999999999999999999999E+6144
-dqnextt352 nexttoward NaN Infinity -> NaN
-dqnextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
-dqnextt354 nexttoward NaN77 Infinity -> NaN77
-dqnextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
-dqnextt356 nexttoward -NaN Infinity -> -NaN
-dqnextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
-dqnextt358 nexttoward -NaN77 Infinity -> -NaN77
-dqnextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-dqnextt370 nexttoward -9.999999999999999999999999999999999E+6144 Infinity -> -9.999999999999999999999999999999998E+6144
-dqnextt371 nexttoward -9.999999999999999999999999999999998E+6144 Infinity -> -9.999999999999999999999999999999997E+6144
-dqnextt372 nexttoward -1E-6143 Infinity -> -9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
-dqnextt373 nexttoward -1.000000000000000E-6143 Infinity -> -9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
-dqnextt374 nexttoward -9E-6176 Infinity -> -8E-6176 Underflow Subnormal Inexact Rounded
-dqnextt375 nexttoward -9.9E-6175 Infinity -> -9.8E-6175 Underflow Subnormal Inexact Rounded
-dqnextt376 nexttoward -9.99999999999999999999999999999E-6147 Infinity -> -9.99999999999999999999999999998E-6147 Underflow Subnormal Inexact Rounded
-dqnextt377 nexttoward -9.99999999999999999999999999999999E-6144 Infinity -> -9.99999999999999999999999999999998E-6144 Underflow Subnormal Inexact Rounded
-dqnextt378 nexttoward -9.99999999999999999999999999999998E-6144 Infinity -> -9.99999999999999999999999999999997E-6144 Underflow Subnormal Inexact Rounded
-dqnextt379 nexttoward -9.99999999999999999999999999999997E-6144 Infinity -> -9.99999999999999999999999999999996E-6144 Underflow Subnormal Inexact Rounded
-dqnextt380 nexttoward -0E-6176 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt381 nexttoward -1E-6176 Infinity -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqnextt382 nexttoward -2E-6176 Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-
-dqnextt383 nexttoward 0E-6176 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt384 nexttoward 1E-6176 Infinity -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqnextt385 nexttoward 2E-6176 Infinity -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqnextt386 nexttoward 10E-6176 Infinity -> 1.1E-6175 Underflow Subnormal Inexact Rounded
-dqnextt387 nexttoward 100E-6176 Infinity -> 1.01E-6174 Underflow Subnormal Inexact Rounded
-dqnextt388 nexttoward 100000E-6176 Infinity -> 1.00001E-6171 Underflow Subnormal Inexact Rounded
-dqnextt389 nexttoward 1.00000000000000000000000000000E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
-dqnextt390 nexttoward 1.000000000000000000000000000000000E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
-dqnextt391 nexttoward 1E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
-dqnextt392 nexttoward 9.999999999999999999999999999999997E+6144 Infinity -> 9.999999999999999999999999999999998E+6144
-dqnextt393 nexttoward 9.999999999999999999999999999999998E+6144 Infinity -> 9.999999999999999999999999999999999E+6144
-dqnextt394 nexttoward 9.999999999999999999999999999999999E+6144 Infinity -> Infinity Overflow Inexact Rounded
-
-------- lhs>rhs
-dqnextt401 nexttoward 0.9999999999999999999999999999999995 -Infinity -> 0.9999999999999999999999999999999994
-dqnextt402 nexttoward 0.9999999999999999999999999999999996 -Infinity -> 0.9999999999999999999999999999999995
-dqnextt403 nexttoward 0.9999999999999999999999999999999997 -Infinity -> 0.9999999999999999999999999999999996
-dqnextt404 nexttoward 0.9999999999999999999999999999999998 -Infinity -> 0.9999999999999999999999999999999997
-dqnextt405 nexttoward 0.9999999999999999999999999999999999 -Infinity -> 0.9999999999999999999999999999999998
-dqnextt406 nexttoward 1.000000000000000000000000000000000 -Infinity -> 0.9999999999999999999999999999999999
-dqnextt407 nexttoward 1.0 -Infinity -> 0.9999999999999999999999999999999999
-dqnextt408 nexttoward 1 -Infinity -> 0.9999999999999999999999999999999999
-dqnextt409 nexttoward 1.000000000000000000000000000000001 -Infinity -> 1.000000000000000000000000000000000
-dqnextt410 nexttoward 1.000000000000000000000000000000002 -Infinity -> 1.000000000000000000000000000000001
-dqnextt411 nexttoward 1.000000000000000000000000000000003 -Infinity -> 1.000000000000000000000000000000002
-dqnextt412 nexttoward 1.000000000000000000000000000000004 -Infinity -> 1.000000000000000000000000000000003
-dqnextt413 nexttoward 1.000000000000000000000000000000005 -Infinity -> 1.000000000000000000000000000000004
-dqnextt414 nexttoward 1.000000000000000000000000000000006 -Infinity -> 1.000000000000000000000000000000005
-dqnextt415 nexttoward 1.000000000000000000000000000000007 -Infinity -> 1.000000000000000000000000000000006
-dqnextt416 nexttoward 1.000000000000000000000000000000008 -Infinity -> 1.000000000000000000000000000000007
-dqnextt417 nexttoward 1.000000000000000000000000000000009 -Infinity -> 1.000000000000000000000000000000008
-dqnextt418 nexttoward 1.000000000000000000000000000000010 -Infinity -> 1.000000000000000000000000000000009
-dqnextt419 nexttoward 1.000000000000000000000000000000011 -Infinity -> 1.000000000000000000000000000000010
-dqnextt420 nexttoward 1.000000000000000000000000000000012 -Infinity -> 1.000000000000000000000000000000011
-
-dqnextt421 nexttoward -0.9999999999999999999999999999999995 -Infinity -> -0.9999999999999999999999999999999996
-dqnextt422 nexttoward -0.9999999999999999999999999999999996 -Infinity -> -0.9999999999999999999999999999999997
-dqnextt423 nexttoward -0.9999999999999999999999999999999997 -Infinity -> -0.9999999999999999999999999999999998
-dqnextt424 nexttoward -0.9999999999999999999999999999999998 -Infinity -> -0.9999999999999999999999999999999999
-dqnextt425 nexttoward -0.9999999999999999999999999999999999 -Infinity -> -1.000000000000000000000000000000000
-dqnextt426 nexttoward -1.000000000000000000000000000000000 -Infinity -> -1.000000000000000000000000000000001
-dqnextt427 nexttoward -1.0 -Infinity -> -1.000000000000000000000000000000001
-dqnextt428 nexttoward -1 -Infinity -> -1.000000000000000000000000000000001
-dqnextt429 nexttoward -1.000000000000000000000000000000001 -Infinity -> -1.000000000000000000000000000000002
-dqnextt430 nexttoward -1.000000000000000000000000000000002 -Infinity -> -1.000000000000000000000000000000003
-dqnextt431 nexttoward -1.000000000000000000000000000000003 -Infinity -> -1.000000000000000000000000000000004
-dqnextt432 nexttoward -1.000000000000000000000000000000004 -Infinity -> -1.000000000000000000000000000000005
-dqnextt433 nexttoward -1.000000000000000000000000000000005 -Infinity -> -1.000000000000000000000000000000006
-dqnextt434 nexttoward -1.000000000000000000000000000000006 -Infinity -> -1.000000000000000000000000000000007
-dqnextt435 nexttoward -1.000000000000000000000000000000007 -Infinity -> -1.000000000000000000000000000000008
-dqnextt436 nexttoward -1.000000000000000000000000000000008 -Infinity -> -1.000000000000000000000000000000009
-dqnextt437 nexttoward -1.000000000000000000000000000000009 -Infinity -> -1.000000000000000000000000000000010
-dqnextt438 nexttoward -1.000000000000000000000000000000010 -Infinity -> -1.000000000000000000000000000000011
-dqnextt439 nexttoward -1.000000000000000000000000000000011 -Infinity -> -1.000000000000000000000000000000012
-
--- Zeros
-dqnextt500 nexttoward -0 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt501 nexttoward 0 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt502 nexttoward 0.00 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt503 nexttoward -0.00 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt504 nexttoward 0E-300 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt505 nexttoward 0E+300 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt506 nexttoward 0E+30000 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt507 nexttoward -0E+30000 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-
--- specials
-dqnextt550 nexttoward Inf -Infinity -> 9.999999999999999999999999999999999E+6144
-dqnextt551 nexttoward -Inf -Infinity -> -Infinity
-dqnextt552 nexttoward NaN -Infinity -> NaN
-dqnextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
-dqnextt554 nexttoward NaN77 -Infinity -> NaN77
-dqnextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
-dqnextt556 nexttoward -NaN -Infinity -> -NaN
-dqnextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
-dqnextt558 nexttoward -NaN77 -Infinity -> -NaN77
-dqnextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-dqnextt670 nexttoward 9.999999999999999999999999999999999E+6144 -Infinity -> 9.999999999999999999999999999999998E+6144
-dqnextt671 nexttoward 9.999999999999999999999999999999998E+6144 -Infinity -> 9.999999999999999999999999999999997E+6144
-dqnextt672 nexttoward 1E-6143 -Infinity -> 9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
-dqnextt673 nexttoward 1.000000000000000000000000000000000E-6143 -Infinity -> 9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
-dqnextt674 nexttoward 9E-6176 -Infinity -> 8E-6176 Underflow Subnormal Inexact Rounded
-dqnextt675 nexttoward 9.9E-6175 -Infinity -> 9.8E-6175 Underflow Subnormal Inexact Rounded
-dqnextt676 nexttoward 9.99999999999999999999999999999E-6147 -Infinity -> 9.99999999999999999999999999998E-6147 Underflow Subnormal Inexact Rounded
-dqnextt677 nexttoward 9.99999999999999999999999999999999E-6144 -Infinity -> 9.99999999999999999999999999999998E-6144 Underflow Subnormal Inexact Rounded
-dqnextt678 nexttoward 9.99999999999999999999999999999998E-6144 -Infinity -> 9.99999999999999999999999999999997E-6144 Underflow Subnormal Inexact Rounded
-dqnextt679 nexttoward 9.99999999999999999999999999999997E-6144 -Infinity -> 9.99999999999999999999999999999996E-6144 Underflow Subnormal Inexact Rounded
-dqnextt680 nexttoward 0E-6176 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt681 nexttoward 1E-6176 -Infinity -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqnextt682 nexttoward 2E-6176 -Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-
-dqnextt683 nexttoward -0E-6176 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt684 nexttoward -1E-6176 -Infinity -> -2E-6176 Underflow Subnormal Inexact Rounded
-dqnextt685 nexttoward -2E-6176 -Infinity -> -3E-6176 Underflow Subnormal Inexact Rounded
-dqnextt686 nexttoward -10E-6176 -Infinity -> -1.1E-6175 Underflow Subnormal Inexact Rounded
-dqnextt687 nexttoward -100E-6176 -Infinity -> -1.01E-6174 Underflow Subnormal Inexact Rounded
-dqnextt688 nexttoward -100000E-6176 -Infinity -> -1.00001E-6171 Underflow Subnormal Inexact Rounded
-dqnextt689 nexttoward -1.00000000000000000000000000000E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
-dqnextt690 nexttoward -1.000000000000000000000000000000000E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
-dqnextt691 nexttoward -1E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
-dqnextt692 nexttoward -9.999999999999999999999999999999998E+6144 -Infinity -> -9.999999999999999999999999999999999E+6144
-dqnextt693 nexttoward -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
-
-------- Specials
-dqnextt780 nexttoward -Inf -Inf -> -Infinity
-dqnextt781 nexttoward -Inf -1000 -> -9.999999999999999999999999999999999E+6144
-dqnextt782 nexttoward -Inf -1 -> -9.999999999999999999999999999999999E+6144
-dqnextt783 nexttoward -Inf -0 -> -9.999999999999999999999999999999999E+6144
-dqnextt784 nexttoward -Inf 0 -> -9.999999999999999999999999999999999E+6144
-dqnextt785 nexttoward -Inf 1 -> -9.999999999999999999999999999999999E+6144
-dqnextt786 nexttoward -Inf 1000 -> -9.999999999999999999999999999999999E+6144
-dqnextt787 nexttoward -1000 -Inf -> -1000.000000000000000000000000000001
-dqnextt788 nexttoward -Inf -Inf -> -Infinity
-dqnextt789 nexttoward -1 -Inf -> -1.000000000000000000000000000000001
-dqnextt790 nexttoward -0 -Inf -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt791 nexttoward 0 -Inf -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt792 nexttoward 1 -Inf -> 0.9999999999999999999999999999999999
-dqnextt793 nexttoward 1000 -Inf -> 999.9999999999999999999999999999999
-dqnextt794 nexttoward Inf -Inf -> 9.999999999999999999999999999999999E+6144
-
-dqnextt800 nexttoward Inf -Inf -> 9.999999999999999999999999999999999E+6144
-dqnextt801 nexttoward Inf -1000 -> 9.999999999999999999999999999999999E+6144
-dqnextt802 nexttoward Inf -1 -> 9.999999999999999999999999999999999E+6144
-dqnextt803 nexttoward Inf -0 -> 9.999999999999999999999999999999999E+6144
-dqnextt804 nexttoward Inf 0 -> 9.999999999999999999999999999999999E+6144
-dqnextt805 nexttoward Inf 1 -> 9.999999999999999999999999999999999E+6144
-dqnextt806 nexttoward Inf 1000 -> 9.999999999999999999999999999999999E+6144
-dqnextt807 nexttoward Inf Inf -> Infinity
-dqnextt808 nexttoward -1000 Inf -> -999.9999999999999999999999999999999
-dqnextt809 nexttoward -Inf Inf -> -9.999999999999999999999999999999999E+6144
-dqnextt810 nexttoward -1 Inf -> -0.9999999999999999999999999999999999
-dqnextt811 nexttoward -0 Inf -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt812 nexttoward 0 Inf -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt813 nexttoward 1 Inf -> 1.000000000000000000000000000000001
-dqnextt814 nexttoward 1000 Inf -> 1000.000000000000000000000000000001
-dqnextt815 nexttoward Inf Inf -> Infinity
-
-dqnextt821 nexttoward NaN -Inf -> NaN
-dqnextt822 nexttoward NaN -1000 -> NaN
-dqnextt823 nexttoward NaN -1 -> NaN
-dqnextt824 nexttoward NaN -0 -> NaN
-dqnextt825 nexttoward NaN 0 -> NaN
-dqnextt826 nexttoward NaN 1 -> NaN
-dqnextt827 nexttoward NaN 1000 -> NaN
-dqnextt828 nexttoward NaN Inf -> NaN
-dqnextt829 nexttoward NaN NaN -> NaN
-dqnextt830 nexttoward -Inf NaN -> NaN
-dqnextt831 nexttoward -1000 NaN -> NaN
-dqnextt832 nexttoward -1 NaN -> NaN
-dqnextt833 nexttoward -0 NaN -> NaN
-dqnextt834 nexttoward 0 NaN -> NaN
-dqnextt835 nexttoward 1 NaN -> NaN
-dqnextt836 nexttoward 1000 NaN -> NaN
-dqnextt837 nexttoward Inf NaN -> NaN
-
-dqnextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
-dqnextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
-dqnextt843 nexttoward sNaN -1 -> NaN Invalid_operation
-dqnextt844 nexttoward sNaN -0 -> NaN Invalid_operation
-dqnextt845 nexttoward sNaN 0 -> NaN Invalid_operation
-dqnextt846 nexttoward sNaN 1 -> NaN Invalid_operation
-dqnextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
-dqnextt848 nexttoward sNaN NaN -> NaN Invalid_operation
-dqnextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
-dqnextt850 nexttoward NaN sNaN -> NaN Invalid_operation
-dqnextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
-dqnextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
-dqnextt853 nexttoward -1 sNaN -> NaN Invalid_operation
-dqnextt854 nexttoward -0 sNaN -> NaN Invalid_operation
-dqnextt855 nexttoward 0 sNaN -> NaN Invalid_operation
-dqnextt856 nexttoward 1 sNaN -> NaN Invalid_operation
-dqnextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
-dqnextt858 nexttoward Inf sNaN -> NaN Invalid_operation
-dqnextt859 nexttoward NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqnextt861 nexttoward NaN1 -Inf -> NaN1
-dqnextt862 nexttoward +NaN2 -1000 -> NaN2
-dqnextt863 nexttoward NaN3 1000 -> NaN3
-dqnextt864 nexttoward NaN4 Inf -> NaN4
-dqnextt865 nexttoward NaN5 +NaN6 -> NaN5
-dqnextt866 nexttoward -Inf NaN7 -> NaN7
-dqnextt867 nexttoward -1000 NaN8 -> NaN8
-dqnextt868 nexttoward 1000 NaN9 -> NaN9
-dqnextt869 nexttoward Inf +NaN10 -> NaN10
-dqnextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
-dqnextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
-dqnextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
-dqnextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
-dqnextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqnextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
-dqnextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
-dqnextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
-dqnextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
-dqnextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
-dqnextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqnextt882 nexttoward -NaN26 NaN28 -> -NaN26
-dqnextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqnextt884 nexttoward 1000 -NaN30 -> -NaN30
-dqnextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Null tests
-dqnextt900 nexttoward 1 # -> NaN Invalid_operation
-dqnextt901 nexttoward # 1 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqNextToward.decTest -- decQuad next toward rhs [754r nextafter] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+
+-- Sanity check with a scattering of numerics
+dqnextt001 nexttoward 10 10 -> 10
+dqnextt002 nexttoward -10 -10 -> -10
+dqnextt003 nexttoward 1 10 -> 1.000000000000000000000000000000001
+dqnextt004 nexttoward 1 -10 -> 0.9999999999999999999999999999999999
+dqnextt005 nexttoward -1 10 -> -0.9999999999999999999999999999999999
+dqnextt006 nexttoward -1 -10 -> -1.000000000000000000000000000000001
+dqnextt007 nexttoward 0 10 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt008 nexttoward 0 -10 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt009 nexttoward 9.999999999999999999999999999999999E+6144 +Infinity -> Infinity Overflow Inexact Rounded
+dqnextt010 nexttoward -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
+dqnextt011 nexttoward 9.999999999999999999999999999999999 10 -> 10.00000000000000000000000000000000
+dqnextt012 nexttoward 10 9.999999999999999999999999999999999 -> 9.999999999999999999999999999999999
+dqnextt013 nexttoward -9.999999999999999999999999999999999 -10 -> -10.00000000000000000000000000000000
+dqnextt014 nexttoward -10 -9.999999999999999999999999999999999 -> -9.999999999999999999999999999999999
+dqnextt015 nexttoward 9.999999999999999999999999999999998 10 -> 9.999999999999999999999999999999999
+dqnextt016 nexttoward 10 9.999999999999999999999999999999998 -> 9.999999999999999999999999999999999
+dqnextt017 nexttoward -9.999999999999999999999999999999998 -10 -> -9.999999999999999999999999999999999
+dqnextt018 nexttoward -10 -9.999999999999999999999999999999998 -> -9.999999999999999999999999999999999
+
+------- lhs=rhs
+-- finites
+dqnextt101 nexttoward 7 7 -> 7
+dqnextt102 nexttoward -7 -7 -> -7
+dqnextt103 nexttoward 75 75 -> 75
+dqnextt104 nexttoward -75 -75 -> -75
+dqnextt105 nexttoward 7.50 7.5 -> 7.50
+dqnextt106 nexttoward -7.50 -7.50 -> -7.50
+dqnextt107 nexttoward 7.500 7.5000 -> 7.500
+dqnextt108 nexttoward -7.500 -7.5 -> -7.500
+
+-- zeros
+dqnextt111 nexttoward 0 0 -> 0
+dqnextt112 nexttoward -0 -0 -> -0
+dqnextt113 nexttoward 0E+4 0 -> 0E+4
+dqnextt114 nexttoward -0E+4 -0 -> -0E+4
+dqnextt115 nexttoward 0.00000000000 0.000000000000 -> 0E-11
+dqnextt116 nexttoward -0.00000000000 -0.00 -> -0E-11
+dqnextt117 nexttoward 0E-141 0 -> 0E-141
+dqnextt118 nexttoward -0E-141 -000 -> -0E-141
+
+-- full coefficients, alternating bits
+dqnextt121 nexttoward 268268268 268268268 -> 268268268
+dqnextt122 nexttoward -268268268 -268268268 -> -268268268
+dqnextt123 nexttoward 134134134 134134134 -> 134134134
+dqnextt124 nexttoward -134134134 -134134134 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+dqnextt131 nexttoward 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqnextt132 nexttoward 1E-6143 1E-6143 -> 1E-6143
+dqnextt133 nexttoward 1.000000000000000000000000000000000E-6143 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqnextt134 nexttoward 1E-6176 1E-6176 -> 1E-6176
+
+dqnextt135 nexttoward -1E-6176 -1E-6176 -> -1E-6176
+dqnextt136 nexttoward -1.000000000000000000000000000000000E-6143 -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqnextt137 nexttoward -1E-6143 -1E-6143 -> -1E-6143
+dqnextt138 nexttoward -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+
+------- lhs<rhs
+dqnextt201 nexttoward 0.9999999999999999999999999999999995 Infinity -> 0.9999999999999999999999999999999996
+dqnextt202 nexttoward 0.9999999999999999999999999999999996 Infinity -> 0.9999999999999999999999999999999997
+dqnextt203 nexttoward 0.9999999999999999999999999999999997 Infinity -> 0.9999999999999999999999999999999998
+dqnextt204 nexttoward 0.9999999999999999999999999999999998 Infinity -> 0.9999999999999999999999999999999999
+dqnextt205 nexttoward 0.9999999999999999999999999999999999 Infinity -> 1.000000000000000000000000000000000
+dqnextt206 nexttoward 1.000000000000000000000000000000000 Infinity -> 1.000000000000000000000000000000001
+dqnextt207 nexttoward 1.0 Infinity -> 1.000000000000000000000000000000001
+dqnextt208 nexttoward 1 Infinity -> 1.000000000000000000000000000000001
+dqnextt209 nexttoward 1.000000000000000000000000000000001 Infinity -> 1.000000000000000000000000000000002
+dqnextt210 nexttoward 1.000000000000000000000000000000002 Infinity -> 1.000000000000000000000000000000003
+dqnextt211 nexttoward 1.000000000000000000000000000000003 Infinity -> 1.000000000000000000000000000000004
+dqnextt212 nexttoward 1.000000000000000000000000000000004 Infinity -> 1.000000000000000000000000000000005
+dqnextt213 nexttoward 1.000000000000000000000000000000005 Infinity -> 1.000000000000000000000000000000006
+dqnextt214 nexttoward 1.000000000000000000000000000000006 Infinity -> 1.000000000000000000000000000000007
+dqnextt215 nexttoward 1.000000000000000000000000000000007 Infinity -> 1.000000000000000000000000000000008
+dqnextt216 nexttoward 1.000000000000000000000000000000008 Infinity -> 1.000000000000000000000000000000009
+dqnextt217 nexttoward 1.000000000000000000000000000000009 Infinity -> 1.000000000000000000000000000000010
+dqnextt218 nexttoward 1.000000000000000000000000000000010 Infinity -> 1.000000000000000000000000000000011
+dqnextt219 nexttoward 1.000000000000000000000000000000011 Infinity -> 1.000000000000000000000000000000012
+
+dqnextt221 nexttoward -0.9999999999999999999999999999999995 Infinity -> -0.9999999999999999999999999999999994
+dqnextt222 nexttoward -0.9999999999999999999999999999999996 Infinity -> -0.9999999999999999999999999999999995
+dqnextt223 nexttoward -0.9999999999999999999999999999999997 Infinity -> -0.9999999999999999999999999999999996
+dqnextt224 nexttoward -0.9999999999999999999999999999999998 Infinity -> -0.9999999999999999999999999999999997
+dqnextt225 nexttoward -0.9999999999999999999999999999999999 Infinity -> -0.9999999999999999999999999999999998
+dqnextt226 nexttoward -1.000000000000000000000000000000000 Infinity -> -0.9999999999999999999999999999999999
+dqnextt227 nexttoward -1.0 Infinity -> -0.9999999999999999999999999999999999
+dqnextt228 nexttoward -1 Infinity -> -0.9999999999999999999999999999999999
+dqnextt229 nexttoward -1.000000000000000000000000000000001 Infinity -> -1.000000000000000000000000000000000
+dqnextt230 nexttoward -1.000000000000000000000000000000002 Infinity -> -1.000000000000000000000000000000001
+dqnextt231 nexttoward -1.000000000000000000000000000000003 Infinity -> -1.000000000000000000000000000000002
+dqnextt232 nexttoward -1.000000000000000000000000000000004 Infinity -> -1.000000000000000000000000000000003
+dqnextt233 nexttoward -1.000000000000000000000000000000005 Infinity -> -1.000000000000000000000000000000004
+dqnextt234 nexttoward -1.000000000000000000000000000000006 Infinity -> -1.000000000000000000000000000000005
+dqnextt235 nexttoward -1.000000000000000000000000000000007 Infinity -> -1.000000000000000000000000000000006
+dqnextt236 nexttoward -1.000000000000000000000000000000008 Infinity -> -1.000000000000000000000000000000007
+dqnextt237 nexttoward -1.000000000000000000000000000000009 Infinity -> -1.000000000000000000000000000000008
+dqnextt238 nexttoward -1.000000000000000000000000000000010 Infinity -> -1.000000000000000000000000000000009
+dqnextt239 nexttoward -1.000000000000000000000000000000011 Infinity -> -1.000000000000000000000000000000010
+dqnextt240 nexttoward -1.000000000000000000000000000000012 Infinity -> -1.000000000000000000000000000000011
+
+-- Zeros
+dqnextt300 nexttoward 0 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt301 nexttoward 0.00 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt302 nexttoward 0E-300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt303 nexttoward 0E+300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt304 nexttoward 0E+30000 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt305 nexttoward -0 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt306 nexttoward -0.00 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt307 nexttoward -0E-300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt308 nexttoward -0E+300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt309 nexttoward -0E+30000 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+-- specials
+dqnextt350 nexttoward Inf Infinity -> Infinity
+dqnextt351 nexttoward -Inf Infinity -> -9.999999999999999999999999999999999E+6144
+dqnextt352 nexttoward NaN Infinity -> NaN
+dqnextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
+dqnextt354 nexttoward NaN77 Infinity -> NaN77
+dqnextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
+dqnextt356 nexttoward -NaN Infinity -> -NaN
+dqnextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
+dqnextt358 nexttoward -NaN77 Infinity -> -NaN77
+dqnextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+dqnextt370 nexttoward -9.999999999999999999999999999999999E+6144 Infinity -> -9.999999999999999999999999999999998E+6144
+dqnextt371 nexttoward -9.999999999999999999999999999999998E+6144 Infinity -> -9.999999999999999999999999999999997E+6144
+dqnextt372 nexttoward -1E-6143 Infinity -> -9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
+dqnextt373 nexttoward -1.000000000000000E-6143 Infinity -> -9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
+dqnextt374 nexttoward -9E-6176 Infinity -> -8E-6176 Underflow Subnormal Inexact Rounded
+dqnextt375 nexttoward -9.9E-6175 Infinity -> -9.8E-6175 Underflow Subnormal Inexact Rounded
+dqnextt376 nexttoward -9.99999999999999999999999999999E-6147 Infinity -> -9.99999999999999999999999999998E-6147 Underflow Subnormal Inexact Rounded
+dqnextt377 nexttoward -9.99999999999999999999999999999999E-6144 Infinity -> -9.99999999999999999999999999999998E-6144 Underflow Subnormal Inexact Rounded
+dqnextt378 nexttoward -9.99999999999999999999999999999998E-6144 Infinity -> -9.99999999999999999999999999999997E-6144 Underflow Subnormal Inexact Rounded
+dqnextt379 nexttoward -9.99999999999999999999999999999997E-6144 Infinity -> -9.99999999999999999999999999999996E-6144 Underflow Subnormal Inexact Rounded
+dqnextt380 nexttoward -0E-6176 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt381 nexttoward -1E-6176 Infinity -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqnextt382 nexttoward -2E-6176 Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+
+dqnextt383 nexttoward 0E-6176 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt384 nexttoward 1E-6176 Infinity -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqnextt385 nexttoward 2E-6176 Infinity -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqnextt386 nexttoward 10E-6176 Infinity -> 1.1E-6175 Underflow Subnormal Inexact Rounded
+dqnextt387 nexttoward 100E-6176 Infinity -> 1.01E-6174 Underflow Subnormal Inexact Rounded
+dqnextt388 nexttoward 100000E-6176 Infinity -> 1.00001E-6171 Underflow Subnormal Inexact Rounded
+dqnextt389 nexttoward 1.00000000000000000000000000000E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
+dqnextt390 nexttoward 1.000000000000000000000000000000000E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
+dqnextt391 nexttoward 1E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
+dqnextt392 nexttoward 9.999999999999999999999999999999997E+6144 Infinity -> 9.999999999999999999999999999999998E+6144
+dqnextt393 nexttoward 9.999999999999999999999999999999998E+6144 Infinity -> 9.999999999999999999999999999999999E+6144
+dqnextt394 nexttoward 9.999999999999999999999999999999999E+6144 Infinity -> Infinity Overflow Inexact Rounded
+
+------- lhs>rhs
+dqnextt401 nexttoward 0.9999999999999999999999999999999995 -Infinity -> 0.9999999999999999999999999999999994
+dqnextt402 nexttoward 0.9999999999999999999999999999999996 -Infinity -> 0.9999999999999999999999999999999995
+dqnextt403 nexttoward 0.9999999999999999999999999999999997 -Infinity -> 0.9999999999999999999999999999999996
+dqnextt404 nexttoward 0.9999999999999999999999999999999998 -Infinity -> 0.9999999999999999999999999999999997
+dqnextt405 nexttoward 0.9999999999999999999999999999999999 -Infinity -> 0.9999999999999999999999999999999998
+dqnextt406 nexttoward 1.000000000000000000000000000000000 -Infinity -> 0.9999999999999999999999999999999999
+dqnextt407 nexttoward 1.0 -Infinity -> 0.9999999999999999999999999999999999
+dqnextt408 nexttoward 1 -Infinity -> 0.9999999999999999999999999999999999
+dqnextt409 nexttoward 1.000000000000000000000000000000001 -Infinity -> 1.000000000000000000000000000000000
+dqnextt410 nexttoward 1.000000000000000000000000000000002 -Infinity -> 1.000000000000000000000000000000001
+dqnextt411 nexttoward 1.000000000000000000000000000000003 -Infinity -> 1.000000000000000000000000000000002
+dqnextt412 nexttoward 1.000000000000000000000000000000004 -Infinity -> 1.000000000000000000000000000000003
+dqnextt413 nexttoward 1.000000000000000000000000000000005 -Infinity -> 1.000000000000000000000000000000004
+dqnextt414 nexttoward 1.000000000000000000000000000000006 -Infinity -> 1.000000000000000000000000000000005
+dqnextt415 nexttoward 1.000000000000000000000000000000007 -Infinity -> 1.000000000000000000000000000000006
+dqnextt416 nexttoward 1.000000000000000000000000000000008 -Infinity -> 1.000000000000000000000000000000007
+dqnextt417 nexttoward 1.000000000000000000000000000000009 -Infinity -> 1.000000000000000000000000000000008
+dqnextt418 nexttoward 1.000000000000000000000000000000010 -Infinity -> 1.000000000000000000000000000000009
+dqnextt419 nexttoward 1.000000000000000000000000000000011 -Infinity -> 1.000000000000000000000000000000010
+dqnextt420 nexttoward 1.000000000000000000000000000000012 -Infinity -> 1.000000000000000000000000000000011
+
+dqnextt421 nexttoward -0.9999999999999999999999999999999995 -Infinity -> -0.9999999999999999999999999999999996
+dqnextt422 nexttoward -0.9999999999999999999999999999999996 -Infinity -> -0.9999999999999999999999999999999997
+dqnextt423 nexttoward -0.9999999999999999999999999999999997 -Infinity -> -0.9999999999999999999999999999999998
+dqnextt424 nexttoward -0.9999999999999999999999999999999998 -Infinity -> -0.9999999999999999999999999999999999
+dqnextt425 nexttoward -0.9999999999999999999999999999999999 -Infinity -> -1.000000000000000000000000000000000
+dqnextt426 nexttoward -1.000000000000000000000000000000000 -Infinity -> -1.000000000000000000000000000000001
+dqnextt427 nexttoward -1.0 -Infinity -> -1.000000000000000000000000000000001
+dqnextt428 nexttoward -1 -Infinity -> -1.000000000000000000000000000000001
+dqnextt429 nexttoward -1.000000000000000000000000000000001 -Infinity -> -1.000000000000000000000000000000002
+dqnextt430 nexttoward -1.000000000000000000000000000000002 -Infinity -> -1.000000000000000000000000000000003
+dqnextt431 nexttoward -1.000000000000000000000000000000003 -Infinity -> -1.000000000000000000000000000000004
+dqnextt432 nexttoward -1.000000000000000000000000000000004 -Infinity -> -1.000000000000000000000000000000005
+dqnextt433 nexttoward -1.000000000000000000000000000000005 -Infinity -> -1.000000000000000000000000000000006
+dqnextt434 nexttoward -1.000000000000000000000000000000006 -Infinity -> -1.000000000000000000000000000000007
+dqnextt435 nexttoward -1.000000000000000000000000000000007 -Infinity -> -1.000000000000000000000000000000008
+dqnextt436 nexttoward -1.000000000000000000000000000000008 -Infinity -> -1.000000000000000000000000000000009
+dqnextt437 nexttoward -1.000000000000000000000000000000009 -Infinity -> -1.000000000000000000000000000000010
+dqnextt438 nexttoward -1.000000000000000000000000000000010 -Infinity -> -1.000000000000000000000000000000011
+dqnextt439 nexttoward -1.000000000000000000000000000000011 -Infinity -> -1.000000000000000000000000000000012
+
+-- Zeros
+dqnextt500 nexttoward -0 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt501 nexttoward 0 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt502 nexttoward 0.00 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt503 nexttoward -0.00 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt504 nexttoward 0E-300 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt505 nexttoward 0E+300 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt506 nexttoward 0E+30000 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt507 nexttoward -0E+30000 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+
+-- specials
+dqnextt550 nexttoward Inf -Infinity -> 9.999999999999999999999999999999999E+6144
+dqnextt551 nexttoward -Inf -Infinity -> -Infinity
+dqnextt552 nexttoward NaN -Infinity -> NaN
+dqnextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
+dqnextt554 nexttoward NaN77 -Infinity -> NaN77
+dqnextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
+dqnextt556 nexttoward -NaN -Infinity -> -NaN
+dqnextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
+dqnextt558 nexttoward -NaN77 -Infinity -> -NaN77
+dqnextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+dqnextt670 nexttoward 9.999999999999999999999999999999999E+6144 -Infinity -> 9.999999999999999999999999999999998E+6144
+dqnextt671 nexttoward 9.999999999999999999999999999999998E+6144 -Infinity -> 9.999999999999999999999999999999997E+6144
+dqnextt672 nexttoward 1E-6143 -Infinity -> 9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
+dqnextt673 nexttoward 1.000000000000000000000000000000000E-6143 -Infinity -> 9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
+dqnextt674 nexttoward 9E-6176 -Infinity -> 8E-6176 Underflow Subnormal Inexact Rounded
+dqnextt675 nexttoward 9.9E-6175 -Infinity -> 9.8E-6175 Underflow Subnormal Inexact Rounded
+dqnextt676 nexttoward 9.99999999999999999999999999999E-6147 -Infinity -> 9.99999999999999999999999999998E-6147 Underflow Subnormal Inexact Rounded
+dqnextt677 nexttoward 9.99999999999999999999999999999999E-6144 -Infinity -> 9.99999999999999999999999999999998E-6144 Underflow Subnormal Inexact Rounded
+dqnextt678 nexttoward 9.99999999999999999999999999999998E-6144 -Infinity -> 9.99999999999999999999999999999997E-6144 Underflow Subnormal Inexact Rounded
+dqnextt679 nexttoward 9.99999999999999999999999999999997E-6144 -Infinity -> 9.99999999999999999999999999999996E-6144 Underflow Subnormal Inexact Rounded
+dqnextt680 nexttoward 0E-6176 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt681 nexttoward 1E-6176 -Infinity -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqnextt682 nexttoward 2E-6176 -Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+dqnextt683 nexttoward -0E-6176 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt684 nexttoward -1E-6176 -Infinity -> -2E-6176 Underflow Subnormal Inexact Rounded
+dqnextt685 nexttoward -2E-6176 -Infinity -> -3E-6176 Underflow Subnormal Inexact Rounded
+dqnextt686 nexttoward -10E-6176 -Infinity -> -1.1E-6175 Underflow Subnormal Inexact Rounded
+dqnextt687 nexttoward -100E-6176 -Infinity -> -1.01E-6174 Underflow Subnormal Inexact Rounded
+dqnextt688 nexttoward -100000E-6176 -Infinity -> -1.00001E-6171 Underflow Subnormal Inexact Rounded
+dqnextt689 nexttoward -1.00000000000000000000000000000E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
+dqnextt690 nexttoward -1.000000000000000000000000000000000E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
+dqnextt691 nexttoward -1E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
+dqnextt692 nexttoward -9.999999999999999999999999999999998E+6144 -Infinity -> -9.999999999999999999999999999999999E+6144
+dqnextt693 nexttoward -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
+
+------- Specials
+dqnextt780 nexttoward -Inf -Inf -> -Infinity
+dqnextt781 nexttoward -Inf -1000 -> -9.999999999999999999999999999999999E+6144
+dqnextt782 nexttoward -Inf -1 -> -9.999999999999999999999999999999999E+6144
+dqnextt783 nexttoward -Inf -0 -> -9.999999999999999999999999999999999E+6144
+dqnextt784 nexttoward -Inf 0 -> -9.999999999999999999999999999999999E+6144
+dqnextt785 nexttoward -Inf 1 -> -9.999999999999999999999999999999999E+6144
+dqnextt786 nexttoward -Inf 1000 -> -9.999999999999999999999999999999999E+6144
+dqnextt787 nexttoward -1000 -Inf -> -1000.000000000000000000000000000001
+dqnextt788 nexttoward -Inf -Inf -> -Infinity
+dqnextt789 nexttoward -1 -Inf -> -1.000000000000000000000000000000001
+dqnextt790 nexttoward -0 -Inf -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt791 nexttoward 0 -Inf -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt792 nexttoward 1 -Inf -> 0.9999999999999999999999999999999999
+dqnextt793 nexttoward 1000 -Inf -> 999.9999999999999999999999999999999
+dqnextt794 nexttoward Inf -Inf -> 9.999999999999999999999999999999999E+6144
+
+dqnextt800 nexttoward Inf -Inf -> 9.999999999999999999999999999999999E+6144
+dqnextt801 nexttoward Inf -1000 -> 9.999999999999999999999999999999999E+6144
+dqnextt802 nexttoward Inf -1 -> 9.999999999999999999999999999999999E+6144
+dqnextt803 nexttoward Inf -0 -> 9.999999999999999999999999999999999E+6144
+dqnextt804 nexttoward Inf 0 -> 9.999999999999999999999999999999999E+6144
+dqnextt805 nexttoward Inf 1 -> 9.999999999999999999999999999999999E+6144
+dqnextt806 nexttoward Inf 1000 -> 9.999999999999999999999999999999999E+6144
+dqnextt807 nexttoward Inf Inf -> Infinity
+dqnextt808 nexttoward -1000 Inf -> -999.9999999999999999999999999999999
+dqnextt809 nexttoward -Inf Inf -> -9.999999999999999999999999999999999E+6144
+dqnextt810 nexttoward -1 Inf -> -0.9999999999999999999999999999999999
+dqnextt811 nexttoward -0 Inf -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt812 nexttoward 0 Inf -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt813 nexttoward 1 Inf -> 1.000000000000000000000000000000001
+dqnextt814 nexttoward 1000 Inf -> 1000.000000000000000000000000000001
+dqnextt815 nexttoward Inf Inf -> Infinity
+
+dqnextt821 nexttoward NaN -Inf -> NaN
+dqnextt822 nexttoward NaN -1000 -> NaN
+dqnextt823 nexttoward NaN -1 -> NaN
+dqnextt824 nexttoward NaN -0 -> NaN
+dqnextt825 nexttoward NaN 0 -> NaN
+dqnextt826 nexttoward NaN 1 -> NaN
+dqnextt827 nexttoward NaN 1000 -> NaN
+dqnextt828 nexttoward NaN Inf -> NaN
+dqnextt829 nexttoward NaN NaN -> NaN
+dqnextt830 nexttoward -Inf NaN -> NaN
+dqnextt831 nexttoward -1000 NaN -> NaN
+dqnextt832 nexttoward -1 NaN -> NaN
+dqnextt833 nexttoward -0 NaN -> NaN
+dqnextt834 nexttoward 0 NaN -> NaN
+dqnextt835 nexttoward 1 NaN -> NaN
+dqnextt836 nexttoward 1000 NaN -> NaN
+dqnextt837 nexttoward Inf NaN -> NaN
+
+dqnextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
+dqnextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
+dqnextt843 nexttoward sNaN -1 -> NaN Invalid_operation
+dqnextt844 nexttoward sNaN -0 -> NaN Invalid_operation
+dqnextt845 nexttoward sNaN 0 -> NaN Invalid_operation
+dqnextt846 nexttoward sNaN 1 -> NaN Invalid_operation
+dqnextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
+dqnextt848 nexttoward sNaN NaN -> NaN Invalid_operation
+dqnextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
+dqnextt850 nexttoward NaN sNaN -> NaN Invalid_operation
+dqnextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
+dqnextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
+dqnextt853 nexttoward -1 sNaN -> NaN Invalid_operation
+dqnextt854 nexttoward -0 sNaN -> NaN Invalid_operation
+dqnextt855 nexttoward 0 sNaN -> NaN Invalid_operation
+dqnextt856 nexttoward 1 sNaN -> NaN Invalid_operation
+dqnextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
+dqnextt858 nexttoward Inf sNaN -> NaN Invalid_operation
+dqnextt859 nexttoward NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqnextt861 nexttoward NaN1 -Inf -> NaN1
+dqnextt862 nexttoward +NaN2 -1000 -> NaN2
+dqnextt863 nexttoward NaN3 1000 -> NaN3
+dqnextt864 nexttoward NaN4 Inf -> NaN4
+dqnextt865 nexttoward NaN5 +NaN6 -> NaN5
+dqnextt866 nexttoward -Inf NaN7 -> NaN7
+dqnextt867 nexttoward -1000 NaN8 -> NaN8
+dqnextt868 nexttoward 1000 NaN9 -> NaN9
+dqnextt869 nexttoward Inf +NaN10 -> NaN10
+dqnextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
+dqnextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
+dqnextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
+dqnextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
+dqnextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqnextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
+dqnextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
+dqnextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
+dqnextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
+dqnextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
+dqnextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqnextt882 nexttoward -NaN26 NaN28 -> -NaN26
+dqnextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqnextt884 nexttoward 1000 -NaN30 -> -NaN30
+dqnextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Null tests
+dqnextt900 nexttoward 1 # -> NaN Invalid_operation
+dqnextt901 nexttoward # 1 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqOr.decTest b/Lib/test/decimaltestdata/dqOr.decTest
index 1fd34b2b35..daa3c86094 100644
--- a/Lib/test/decimaltestdata/dqOr.decTest
+++ b/Lib/test/decimaltestdata/dqOr.decTest
@@ -1,401 +1,401 @@
-------------------------------------------------------------------------
--- dqOr.decTest -- digitwise logical OR for decQuads --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check (truth table)
-dqor001 or 0 0 -> 0
-dqor002 or 0 1 -> 1
-dqor003 or 1 0 -> 1
-dqor004 or 1 1 -> 1
-dqor005 or 1100 1010 -> 1110
--- and at msd and msd-1
-dqor006 or 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqor007 or 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqor008 or 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqor009 or 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqor010 or 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqor011 or 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
-dqor012 or 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 100000000000000000000000000000000
-dqor013 or 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
-
--- Various lengths
-dqor601 or 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111111
-dqor602 or 1011111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111111
-dqor603 or 1101111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111111
-dqor604 or 1110111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111111111
-dqor605 or 1111011111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111111111
-dqor606 or 1111101111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111111111
-dqor607 or 1111110111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111111111111
-dqor608 or 1111111011111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111111111111
-dqor609 or 1111111101111111111111111111111111 1111111111111111111111111011111111 -> 1111111111111111111111111111111111
-dqor610 or 1111111110111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111111111111111
-dqor611 or 1111111111011111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111111111111111
-dqor612 or 1111111111101111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111111111111111
-dqor613 or 1111111111110111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111111111111111111
-dqor614 or 1111111111111011111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111111111111111111
-dqor615 or 1111111111111101111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111111111111111111
-dqor616 or 1111111111111110111111111111111111 1111111111111111110111111111111111 -> 1111111111111111111111111111111111
-dqor617 or 1111111111111111011111111111111111 1111111111111111101111111111111111 -> 1111111111111111111111111111111111
-dqor618 or 1111111111111111101111111111111111 1111111111111111011111111111111111 -> 1111111111111111111111111111111111
-dqor619 or 1111111111111111110111111111111111 1111111111111110111111111111111111 -> 1111111111111111111111111111111111
-dqor620 or 1111111111111111111011111111111111 1111111111111101111111111111111111 -> 1111111111111111111111111111111111
-dqor621 or 1111111111111111111101111111111111 1111111111111011111111111111111111 -> 1111111111111111111111111111111111
-dqor622 or 1111111111111111111110111111111111 1111111111110111111111111111111111 -> 1111111111111111111111111111111111
-dqor623 or 1111111111111111111111011111111111 1111111111101111111111111111111111 -> 1111111111111111111111111111111111
-dqor624 or 1111111111111111111111101111111111 1111111111011111111111111111111111 -> 1111111111111111111111111111111111
-dqor625 or 1111111111111111111111110111111111 1111111110111111111111111111111111 -> 1111111111111111111111111111111111
-dqor626 or 1111111111111111111111111011111111 1111111101111111111111111111111111 -> 1111111111111111111111111111111111
-dqor627 or 1111111111111111111111111101111111 1111111011111111111111111111111111 -> 1111111111111111111111111111111111
-dqor628 or 1111111111111111111111111110111111 1111110111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor629 or 1111111111111111111111111111011111 1111101111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor630 or 1111111111111111111111111111101111 1111011111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor631 or 1111111111111111111111111111110111 1110111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor632 or 1111111111111111111111111111111011 1101111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor633 or 1111111111111111111111111111111101 1011111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor634 or 1111111111111111111111111111111110 0111111111111111111111111111111111 -> 1111111111111111111111111111111111
-
-dqor641 or 1111111111111111111111111111111110 0111111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor642 or 1111111111111111111111111111111101 1011111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor643 or 1111111111111111111111111111111011 1101111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor644 or 1111111111111111111111111111110111 1110111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor645 or 1111111111111111111111111111101111 1111011111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor646 or 1111111111111111111111111111011111 1111101111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor647 or 1111111111111111111111111110111111 1111110111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor648 or 1111111111111111111111111101111111 1111111011111111111111111111111111 -> 1111111111111111111111111111111111
-dqor649 or 1111111111111111111111111011111111 1111111101111111111111111111111111 -> 1111111111111111111111111111111111
-dqor650 or 1111111111111111111111110111111111 1111111110111111111111111111111111 -> 1111111111111111111111111111111111
-dqor651 or 1111111111111111111111101111111111 1111111111011111111111111111111111 -> 1111111111111111111111111111111111
-dqor652 or 1111111111111111111111011111111111 1111111111101111111111111111111111 -> 1111111111111111111111111111111111
-dqor653 or 1111111111111111111110111111111111 1111111111110111111111111111111111 -> 1111111111111111111111111111111111
-dqor654 or 1111111111111111111101111111111111 1111111111111011111111111111111111 -> 1111111111111111111111111111111111
-dqor655 or 1111111111111111111011111111111111 1111111111111101111111111111111111 -> 1111111111111111111111111111111111
-dqor656 or 1111111111111111110111111111111111 1111111111111110111111111111111111 -> 1111111111111111111111111111111111
-dqor657 or 1010101010101010101010101010101010 1010101010101010001010101010101010 -> 1010101010101010101010101010101010
-dqor658 or 1111111111111111011111111111111111 1111111111111111101111111111111111 -> 1111111111111111111111111111111111
-dqor659 or 1111111111111110111111111111111111 1111111111111111110111111111111111 -> 1111111111111111111111111111111111
-dqor660 or 1111111111111101111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111111111111111111
-dqor661 or 1111111111111011111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111111111111111111
-dqor662 or 1111111111110111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111111111111111111
-dqor663 or 1111111111101111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111111111111111
-dqor664 or 1111111111011111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111111111111111
-dqor665 or 1111111110111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111111111111111
-dqor666 or 0101010101010101010101010101010101 0101010101010101010101010001010101 -> 101010101010101010101010101010101
-dqor667 or 1111111011111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111111111111
-dqor668 or 1111110111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111111111111
-dqor669 or 1111101111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111111111
-dqor670 or 1111011111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111111111
-dqor671 or 1110111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111111111
-dqor672 or 1101111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111111
-dqor673 or 1011111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111111
-dqor674 or 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111111
-dqor675 or 0111111111111111111111111111111110 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
-dqor676 or 1111111111111111111111111111111110 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
-
-dqor681 or 0111111111111111111111111111111111 0111111111011111111111111111111110 -> 111111111111111111111111111111111
-dqor682 or 1011111111111111111111111111111111 1011111110101111111111111111111101 -> 1011111111111111111111111111111111
-dqor683 or 1101111111111111111111111111111111 1101111101110111111111111111111011 -> 1101111111111111111111111111111111
-dqor684 or 1110111111111111111111111111111111 1110111011111011111111111111110111 -> 1110111111111111111111111111111111
-dqor685 or 1111011111111111111111111111111111 1111010111111101111111111111101111 -> 1111011111111111111111111111111111
-dqor686 or 1111101111111111111111111111111111 1111101111111110111111111111011111 -> 1111101111111111111111111111111111
-dqor687 or 1111110111111111111111111111111111 1111010111111111011111111110111111 -> 1111110111111111111111111111111111
-dqor688 or 1111111011111111111111111111111111 1110111011111111101111111101111111 -> 1111111011111111111111111111111111
-dqor689 or 1111111101111111111111111111111111 1101111101111111110111111011111111 -> 1111111101111111111111111111111111
-dqor690 or 1111111110111111111111111111111111 1011111110111111111011110111111110 -> 1111111110111111111111111111111111
-dqor691 or 1111111111011111111111111111111111 0111111111011111111101101111111101 -> 1111111111011111111111111111111111
-dqor692 or 1111111111101111111111111111111111 1111111111101111111110011111111011 -> 1111111111101111111111111111111111
-dqor693 or 1111111111110111111111111111111111 1111111111110111111110011111110111 -> 1111111111110111111111111111111111
-dqor694 or 1111111111111011111111111111111111 1111111111111011111101101111101111 -> 1111111111111011111111111111111111
-dqor695 or 1111111111111101111111111111111111 1111111111111101111011110111011111 -> 1111111111111101111111111111111111
-dqor696 or 1111111111111110111111111111111111 1111111111111110110111111010111111 -> 1111111111111110111111111111111111
-dqor697 or 1111111111111111011111111111111111 1111111111111111001111111101111111 -> 1111111111111111011111111111111111
-dqor698 or 1111111111111111101111111111111111 1111111111111111001111111010111111 -> 1111111111111111101111111111111111
-dqor699 or 1111111111111111110111111111111111 1111111111111110110111110111011111 -> 1111111111111111110111111111111111
-dqor700 or 1111111111111111111011111111111111 1111111111111101111011101111101111 -> 1111111111111111111011111111111111
-dqor701 or 1111111111111111111101111111111111 1111111111111011111101011111110111 -> 1111111111111111111101111111111111
-dqor702 or 1111111111111111111110111111111111 1111111111110111111110111111111011 -> 1111111111111111111110111111111111
-dqor703 or 1111111111111111111111011111111111 1111111111101111111101011111111101 -> 1111111111111111111111011111111111
-dqor704 or 1111111111111111111111101111111111 1111111111011111111011101111111110 -> 1111111111111111111111101111111111
-dqor705 or 1111111111111111111111110111111111 0111111110111111110111110111111111 -> 1111111111111111111111110111111111
-dqor706 or 1111111111111111111111111011111111 1011111101111111101111111011111111 -> 1111111111111111111111111011111111
-dqor707 or 1111111111111111111111111101111111 1101111011111111011111111101111111 -> 1111111111111111111111111101111111
-dqor708 or 1111111111111111111111111110111111 1110110111111110111111111110111111 -> 1111111111111111111111111110111111
-dqor709 or 1111111111111111111111111111011111 1111001111111101111111111111011111 -> 1111111111111111111111111111011111
-dqor710 or 1111111111111111111111111111101111 1111001111111011111111111111101111 -> 1111111111111111111111111111101111
-dqor711 or 1111111111111111111111111111110111 1110110111110111111111111111110111 -> 1111111111111111111111111111110111
-dqor712 or 1111111111111111111111111111111011 1101111011101111111111111111111011 -> 1111111111111111111111111111111011
-dqor713 or 1111111111111111111111111111111101 1011111101011111111111111111111101 -> 1111111111111111111111111111111101
-dqor714 or 1111111111111111111111111111111110 0111111110111111111111111111111110 -> 1111111111111111111111111111111110
-
-
-
--- 1234567890123456 1234567890123456 1234567890123456
-dqor020 or 1111111111111111 1111111111111111 -> 1111111111111111
-dqor021 or 111111111111111 111111111111111 -> 111111111111111
-dqor022 or 11111111111111 11111111111111 -> 11111111111111
-dqor023 or 1111111111111 1111111111111 -> 1111111111111
-dqor024 or 111111111111 111111111111 -> 111111111111
-dqor025 or 11111111111 11111111111 -> 11111111111
-dqor026 or 1111111111 1111111111 -> 1111111111
-dqor027 or 111111111 111111111 -> 111111111
-dqor028 or 11111111 11111111 -> 11111111
-dqor029 or 1111111 1111111 -> 1111111
-dqor030 or 111111 111111 -> 111111
-dqor031 or 11111 11111 -> 11111
-dqor032 or 1111 1111 -> 1111
-dqor033 or 111 111 -> 111
-dqor034 or 11 11 -> 11
-dqor035 or 1 1 -> 1
-dqor036 or 0 0 -> 0
-
-dqor042 or 111111110000000 1111111110000000 -> 1111111110000000
-dqor043 or 11111110000000 1000000100000000 -> 1011111110000000
-dqor044 or 1111110000000 1000001000000000 -> 1001111110000000
-dqor045 or 111110000000 1000010000000000 -> 1000111110000000
-dqor046 or 11110000000 1000100000000000 -> 1000111110000000
-dqor047 or 1110000000 1001000000000000 -> 1001001110000000
-dqor048 or 110000000 1010000000000000 -> 1010000110000000
-dqor049 or 10000000 1100000000000000 -> 1100000010000000
-
-dqor090 or 011111111 111101111 -> 111111111
-dqor091 or 101111111 111101111 -> 111111111
-dqor092 or 110111111 111101111 -> 111111111
-dqor093 or 111011111 111101111 -> 111111111
-dqor094 or 111101111 111101111 -> 111101111
-dqor095 or 111110111 111101111 -> 111111111
-dqor096 or 111111011 111101111 -> 111111111
-dqor097 or 111111101 111101111 -> 111111111
-dqor098 or 111111110 111101111 -> 111111111
-
-dqor100 or 111101111 011111111 -> 111111111
-dqor101 or 111101111 101111111 -> 111111111
-dqor102 or 111101111 110111111 -> 111111111
-dqor103 or 111101111 111011111 -> 111111111
-dqor104 or 111101111 111101111 -> 111101111
-dqor105 or 111101111 111110111 -> 111111111
-dqor106 or 111101111 111111011 -> 111111111
-dqor107 or 111101111 111111101 -> 111111111
-dqor108 or 111101111 111111110 -> 111111111
-
--- non-0/1 should not be accepted, nor should signs
-dqor220 or 111111112 111111111 -> NaN Invalid_operation
-dqor221 or 333333333 333333333 -> NaN Invalid_operation
-dqor222 or 555555555 555555555 -> NaN Invalid_operation
-dqor223 or 777777777 777777777 -> NaN Invalid_operation
-dqor224 or 999999999 999999999 -> NaN Invalid_operation
-dqor225 or 222222222 999999999 -> NaN Invalid_operation
-dqor226 or 444444444 999999999 -> NaN Invalid_operation
-dqor227 or 666666666 999999999 -> NaN Invalid_operation
-dqor228 or 888888888 999999999 -> NaN Invalid_operation
-dqor229 or 999999999 222222222 -> NaN Invalid_operation
-dqor230 or 999999999 444444444 -> NaN Invalid_operation
-dqor231 or 999999999 666666666 -> NaN Invalid_operation
-dqor232 or 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-dqor240 or 567468689 -934981942 -> NaN Invalid_operation
-dqor241 or 567367689 934981942 -> NaN Invalid_operation
-dqor242 or -631917772 -706014634 -> NaN Invalid_operation
-dqor243 or -756253257 138579234 -> NaN Invalid_operation
-dqor244 or 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-dqor250 or 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqor251 or 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqor252 or 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqor253 or 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqor254 or 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqor255 or 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqor256 or 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqor257 or 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqor258 or 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqor259 or 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqor260 or 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqor261 or 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
-dqor262 or 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqor263 or 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqor264 or 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqor265 or 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
--- test MSD-1
-dqor270 or 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
-dqor271 or 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
-dqor272 or 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
-dqor273 or 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
-dqor274 or 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
-dqor275 or 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
-dqor276 or 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
-dqor277 or 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
--- test LSD
-dqor280 or 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
-dqor281 or 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
-dqor282 or 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
-dqor283 or 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
-dqor284 or 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
-dqor285 or 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
-dqor286 or 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
-dqor287 or 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
--- test Middie
-dqor288 or 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
-dqor289 or 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
-dqor290 or 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
-dqor291 or 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
-dqor292 or 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
-dqor293 or 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
-dqor294 or 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
-dqor295 or 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
--- signs
-dqor296 or -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
-dqor297 or -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
-dqor298 or 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
-dqor299 or 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 1000001111001111001111000011000100
-
--- Nmax, Nmin, Ntiny-like
-dqor331 or 2 9.99999999E+1999 -> NaN Invalid_operation
-dqor332 or 3 1E-1999 -> NaN Invalid_operation
-dqor333 or 4 1.00000000E-1999 -> NaN Invalid_operation
-dqor334 or 5 1E-1009 -> NaN Invalid_operation
-dqor335 or 6 -1E-1009 -> NaN Invalid_operation
-dqor336 or 7 -1.00000000E-1999 -> NaN Invalid_operation
-dqor337 or 8 -1E-1999 -> NaN Invalid_operation
-dqor338 or 9 -9.99999999E+1999 -> NaN Invalid_operation
-dqor341 or 9.99999999E+2999 -18 -> NaN Invalid_operation
-dqor342 or 1E-2999 01 -> NaN Invalid_operation
-dqor343 or 1.00000000E-2999 -18 -> NaN Invalid_operation
-dqor344 or 1E-1009 18 -> NaN Invalid_operation
-dqor345 or -1E-1009 -10 -> NaN Invalid_operation
-dqor346 or -1.00000000E-2999 18 -> NaN Invalid_operation
-dqor347 or -1E-2999 10 -> NaN Invalid_operation
-dqor348 or -9.99999999E+2999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-dqor361 or 1.0 1 -> NaN Invalid_operation
-dqor362 or 1E+1 1 -> NaN Invalid_operation
-dqor363 or 0.0 1 -> NaN Invalid_operation
-dqor364 or 0E+1 1 -> NaN Invalid_operation
-dqor365 or 9.9 1 -> NaN Invalid_operation
-dqor366 or 9E+1 1 -> NaN Invalid_operation
-dqor371 or 0 1.0 -> NaN Invalid_operation
-dqor372 or 0 1E+1 -> NaN Invalid_operation
-dqor373 or 0 0.0 -> NaN Invalid_operation
-dqor374 or 0 0E+1 -> NaN Invalid_operation
-dqor375 or 0 9.9 -> NaN Invalid_operation
-dqor376 or 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-dqor780 or -Inf -Inf -> NaN Invalid_operation
-dqor781 or -Inf -1000 -> NaN Invalid_operation
-dqor782 or -Inf -1 -> NaN Invalid_operation
-dqor783 or -Inf -0 -> NaN Invalid_operation
-dqor784 or -Inf 0 -> NaN Invalid_operation
-dqor785 or -Inf 1 -> NaN Invalid_operation
-dqor786 or -Inf 1000 -> NaN Invalid_operation
-dqor787 or -1000 -Inf -> NaN Invalid_operation
-dqor788 or -Inf -Inf -> NaN Invalid_operation
-dqor789 or -1 -Inf -> NaN Invalid_operation
-dqor790 or -0 -Inf -> NaN Invalid_operation
-dqor791 or 0 -Inf -> NaN Invalid_operation
-dqor792 or 1 -Inf -> NaN Invalid_operation
-dqor793 or 1000 -Inf -> NaN Invalid_operation
-dqor794 or Inf -Inf -> NaN Invalid_operation
-
-dqor800 or Inf -Inf -> NaN Invalid_operation
-dqor801 or Inf -1000 -> NaN Invalid_operation
-dqor802 or Inf -1 -> NaN Invalid_operation
-dqor803 or Inf -0 -> NaN Invalid_operation
-dqor804 or Inf 0 -> NaN Invalid_operation
-dqor805 or Inf 1 -> NaN Invalid_operation
-dqor806 or Inf 1000 -> NaN Invalid_operation
-dqor807 or Inf Inf -> NaN Invalid_operation
-dqor808 or -1000 Inf -> NaN Invalid_operation
-dqor809 or -Inf Inf -> NaN Invalid_operation
-dqor810 or -1 Inf -> NaN Invalid_operation
-dqor811 or -0 Inf -> NaN Invalid_operation
-dqor812 or 0 Inf -> NaN Invalid_operation
-dqor813 or 1 Inf -> NaN Invalid_operation
-dqor814 or 1000 Inf -> NaN Invalid_operation
-dqor815 or Inf Inf -> NaN Invalid_operation
-
-dqor821 or NaN -Inf -> NaN Invalid_operation
-dqor822 or NaN -1000 -> NaN Invalid_operation
-dqor823 or NaN -1 -> NaN Invalid_operation
-dqor824 or NaN -0 -> NaN Invalid_operation
-dqor825 or NaN 0 -> NaN Invalid_operation
-dqor826 or NaN 1 -> NaN Invalid_operation
-dqor827 or NaN 1000 -> NaN Invalid_operation
-dqor828 or NaN Inf -> NaN Invalid_operation
-dqor829 or NaN NaN -> NaN Invalid_operation
-dqor830 or -Inf NaN -> NaN Invalid_operation
-dqor831 or -1000 NaN -> NaN Invalid_operation
-dqor832 or -1 NaN -> NaN Invalid_operation
-dqor833 or -0 NaN -> NaN Invalid_operation
-dqor834 or 0 NaN -> NaN Invalid_operation
-dqor835 or 1 NaN -> NaN Invalid_operation
-dqor836 or 1000 NaN -> NaN Invalid_operation
-dqor837 or Inf NaN -> NaN Invalid_operation
-
-dqor841 or sNaN -Inf -> NaN Invalid_operation
-dqor842 or sNaN -1000 -> NaN Invalid_operation
-dqor843 or sNaN -1 -> NaN Invalid_operation
-dqor844 or sNaN -0 -> NaN Invalid_operation
-dqor845 or sNaN 0 -> NaN Invalid_operation
-dqor846 or sNaN 1 -> NaN Invalid_operation
-dqor847 or sNaN 1000 -> NaN Invalid_operation
-dqor848 or sNaN NaN -> NaN Invalid_operation
-dqor849 or sNaN sNaN -> NaN Invalid_operation
-dqor850 or NaN sNaN -> NaN Invalid_operation
-dqor851 or -Inf sNaN -> NaN Invalid_operation
-dqor852 or -1000 sNaN -> NaN Invalid_operation
-dqor853 or -1 sNaN -> NaN Invalid_operation
-dqor854 or -0 sNaN -> NaN Invalid_operation
-dqor855 or 0 sNaN -> NaN Invalid_operation
-dqor856 or 1 sNaN -> NaN Invalid_operation
-dqor857 or 1000 sNaN -> NaN Invalid_operation
-dqor858 or Inf sNaN -> NaN Invalid_operation
-dqor859 or NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqor861 or NaN1 -Inf -> NaN Invalid_operation
-dqor862 or +NaN2 -1000 -> NaN Invalid_operation
-dqor863 or NaN3 1000 -> NaN Invalid_operation
-dqor864 or NaN4 Inf -> NaN Invalid_operation
-dqor865 or NaN5 +NaN6 -> NaN Invalid_operation
-dqor866 or -Inf NaN7 -> NaN Invalid_operation
-dqor867 or -1000 NaN8 -> NaN Invalid_operation
-dqor868 or 1000 NaN9 -> NaN Invalid_operation
-dqor869 or Inf +NaN10 -> NaN Invalid_operation
-dqor871 or sNaN11 -Inf -> NaN Invalid_operation
-dqor872 or sNaN12 -1000 -> NaN Invalid_operation
-dqor873 or sNaN13 1000 -> NaN Invalid_operation
-dqor874 or sNaN14 NaN17 -> NaN Invalid_operation
-dqor875 or sNaN15 sNaN18 -> NaN Invalid_operation
-dqor876 or NaN16 sNaN19 -> NaN Invalid_operation
-dqor877 or -Inf +sNaN20 -> NaN Invalid_operation
-dqor878 or -1000 sNaN21 -> NaN Invalid_operation
-dqor879 or 1000 sNaN22 -> NaN Invalid_operation
-dqor880 or Inf sNaN23 -> NaN Invalid_operation
-dqor881 or +NaN25 +sNaN24 -> NaN Invalid_operation
-dqor882 or -NaN26 NaN28 -> NaN Invalid_operation
-dqor883 or -sNaN27 sNaN29 -> NaN Invalid_operation
-dqor884 or 1000 -NaN30 -> NaN Invalid_operation
-dqor885 or 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqOr.decTest -- digitwise logical OR for decQuads --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check (truth table)
+dqor001 or 0 0 -> 0
+dqor002 or 0 1 -> 1
+dqor003 or 1 0 -> 1
+dqor004 or 1 1 -> 1
+dqor005 or 1100 1010 -> 1110
+-- and at msd and msd-1
+dqor006 or 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqor007 or 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqor008 or 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqor009 or 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqor010 or 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqor011 or 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
+dqor012 or 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 100000000000000000000000000000000
+dqor013 or 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
+
+-- Various lengths
+dqor601 or 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111111
+dqor602 or 1011111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111111
+dqor603 or 1101111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111111
+dqor604 or 1110111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111111111
+dqor605 or 1111011111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111111111
+dqor606 or 1111101111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111111111
+dqor607 or 1111110111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111111111111
+dqor608 or 1111111011111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111111111111
+dqor609 or 1111111101111111111111111111111111 1111111111111111111111111011111111 -> 1111111111111111111111111111111111
+dqor610 or 1111111110111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111111111111111
+dqor611 or 1111111111011111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111111111111111
+dqor612 or 1111111111101111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111111111111111
+dqor613 or 1111111111110111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111111111111111111
+dqor614 or 1111111111111011111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111111111111111111
+dqor615 or 1111111111111101111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111111111111111111
+dqor616 or 1111111111111110111111111111111111 1111111111111111110111111111111111 -> 1111111111111111111111111111111111
+dqor617 or 1111111111111111011111111111111111 1111111111111111101111111111111111 -> 1111111111111111111111111111111111
+dqor618 or 1111111111111111101111111111111111 1111111111111111011111111111111111 -> 1111111111111111111111111111111111
+dqor619 or 1111111111111111110111111111111111 1111111111111110111111111111111111 -> 1111111111111111111111111111111111
+dqor620 or 1111111111111111111011111111111111 1111111111111101111111111111111111 -> 1111111111111111111111111111111111
+dqor621 or 1111111111111111111101111111111111 1111111111111011111111111111111111 -> 1111111111111111111111111111111111
+dqor622 or 1111111111111111111110111111111111 1111111111110111111111111111111111 -> 1111111111111111111111111111111111
+dqor623 or 1111111111111111111111011111111111 1111111111101111111111111111111111 -> 1111111111111111111111111111111111
+dqor624 or 1111111111111111111111101111111111 1111111111011111111111111111111111 -> 1111111111111111111111111111111111
+dqor625 or 1111111111111111111111110111111111 1111111110111111111111111111111111 -> 1111111111111111111111111111111111
+dqor626 or 1111111111111111111111111011111111 1111111101111111111111111111111111 -> 1111111111111111111111111111111111
+dqor627 or 1111111111111111111111111101111111 1111111011111111111111111111111111 -> 1111111111111111111111111111111111
+dqor628 or 1111111111111111111111111110111111 1111110111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor629 or 1111111111111111111111111111011111 1111101111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor630 or 1111111111111111111111111111101111 1111011111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor631 or 1111111111111111111111111111110111 1110111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor632 or 1111111111111111111111111111111011 1101111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor633 or 1111111111111111111111111111111101 1011111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor634 or 1111111111111111111111111111111110 0111111111111111111111111111111111 -> 1111111111111111111111111111111111
+
+dqor641 or 1111111111111111111111111111111110 0111111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor642 or 1111111111111111111111111111111101 1011111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor643 or 1111111111111111111111111111111011 1101111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor644 or 1111111111111111111111111111110111 1110111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor645 or 1111111111111111111111111111101111 1111011111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor646 or 1111111111111111111111111111011111 1111101111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor647 or 1111111111111111111111111110111111 1111110111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor648 or 1111111111111111111111111101111111 1111111011111111111111111111111111 -> 1111111111111111111111111111111111
+dqor649 or 1111111111111111111111111011111111 1111111101111111111111111111111111 -> 1111111111111111111111111111111111
+dqor650 or 1111111111111111111111110111111111 1111111110111111111111111111111111 -> 1111111111111111111111111111111111
+dqor651 or 1111111111111111111111101111111111 1111111111011111111111111111111111 -> 1111111111111111111111111111111111
+dqor652 or 1111111111111111111111011111111111 1111111111101111111111111111111111 -> 1111111111111111111111111111111111
+dqor653 or 1111111111111111111110111111111111 1111111111110111111111111111111111 -> 1111111111111111111111111111111111
+dqor654 or 1111111111111111111101111111111111 1111111111111011111111111111111111 -> 1111111111111111111111111111111111
+dqor655 or 1111111111111111111011111111111111 1111111111111101111111111111111111 -> 1111111111111111111111111111111111
+dqor656 or 1111111111111111110111111111111111 1111111111111110111111111111111111 -> 1111111111111111111111111111111111
+dqor657 or 1010101010101010101010101010101010 1010101010101010001010101010101010 -> 1010101010101010101010101010101010
+dqor658 or 1111111111111111011111111111111111 1111111111111111101111111111111111 -> 1111111111111111111111111111111111
+dqor659 or 1111111111111110111111111111111111 1111111111111111110111111111111111 -> 1111111111111111111111111111111111
+dqor660 or 1111111111111101111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111111111111111111
+dqor661 or 1111111111111011111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111111111111111111
+dqor662 or 1111111111110111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111111111111111111
+dqor663 or 1111111111101111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111111111111111
+dqor664 or 1111111111011111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111111111111111
+dqor665 or 1111111110111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111111111111111
+dqor666 or 0101010101010101010101010101010101 0101010101010101010101010001010101 -> 101010101010101010101010101010101
+dqor667 or 1111111011111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111111111111
+dqor668 or 1111110111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111111111111
+dqor669 or 1111101111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111111111
+dqor670 or 1111011111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111111111
+dqor671 or 1110111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111111111
+dqor672 or 1101111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111111
+dqor673 or 1011111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111111
+dqor674 or 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111111
+dqor675 or 0111111111111111111111111111111110 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
+dqor676 or 1111111111111111111111111111111110 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
+
+dqor681 or 0111111111111111111111111111111111 0111111111011111111111111111111110 -> 111111111111111111111111111111111
+dqor682 or 1011111111111111111111111111111111 1011111110101111111111111111111101 -> 1011111111111111111111111111111111
+dqor683 or 1101111111111111111111111111111111 1101111101110111111111111111111011 -> 1101111111111111111111111111111111
+dqor684 or 1110111111111111111111111111111111 1110111011111011111111111111110111 -> 1110111111111111111111111111111111
+dqor685 or 1111011111111111111111111111111111 1111010111111101111111111111101111 -> 1111011111111111111111111111111111
+dqor686 or 1111101111111111111111111111111111 1111101111111110111111111111011111 -> 1111101111111111111111111111111111
+dqor687 or 1111110111111111111111111111111111 1111010111111111011111111110111111 -> 1111110111111111111111111111111111
+dqor688 or 1111111011111111111111111111111111 1110111011111111101111111101111111 -> 1111111011111111111111111111111111
+dqor689 or 1111111101111111111111111111111111 1101111101111111110111111011111111 -> 1111111101111111111111111111111111
+dqor690 or 1111111110111111111111111111111111 1011111110111111111011110111111110 -> 1111111110111111111111111111111111
+dqor691 or 1111111111011111111111111111111111 0111111111011111111101101111111101 -> 1111111111011111111111111111111111
+dqor692 or 1111111111101111111111111111111111 1111111111101111111110011111111011 -> 1111111111101111111111111111111111
+dqor693 or 1111111111110111111111111111111111 1111111111110111111110011111110111 -> 1111111111110111111111111111111111
+dqor694 or 1111111111111011111111111111111111 1111111111111011111101101111101111 -> 1111111111111011111111111111111111
+dqor695 or 1111111111111101111111111111111111 1111111111111101111011110111011111 -> 1111111111111101111111111111111111
+dqor696 or 1111111111111110111111111111111111 1111111111111110110111111010111111 -> 1111111111111110111111111111111111
+dqor697 or 1111111111111111011111111111111111 1111111111111111001111111101111111 -> 1111111111111111011111111111111111
+dqor698 or 1111111111111111101111111111111111 1111111111111111001111111010111111 -> 1111111111111111101111111111111111
+dqor699 or 1111111111111111110111111111111111 1111111111111110110111110111011111 -> 1111111111111111110111111111111111
+dqor700 or 1111111111111111111011111111111111 1111111111111101111011101111101111 -> 1111111111111111111011111111111111
+dqor701 or 1111111111111111111101111111111111 1111111111111011111101011111110111 -> 1111111111111111111101111111111111
+dqor702 or 1111111111111111111110111111111111 1111111111110111111110111111111011 -> 1111111111111111111110111111111111
+dqor703 or 1111111111111111111111011111111111 1111111111101111111101011111111101 -> 1111111111111111111111011111111111
+dqor704 or 1111111111111111111111101111111111 1111111111011111111011101111111110 -> 1111111111111111111111101111111111
+dqor705 or 1111111111111111111111110111111111 0111111110111111110111110111111111 -> 1111111111111111111111110111111111
+dqor706 or 1111111111111111111111111011111111 1011111101111111101111111011111111 -> 1111111111111111111111111011111111
+dqor707 or 1111111111111111111111111101111111 1101111011111111011111111101111111 -> 1111111111111111111111111101111111
+dqor708 or 1111111111111111111111111110111111 1110110111111110111111111110111111 -> 1111111111111111111111111110111111
+dqor709 or 1111111111111111111111111111011111 1111001111111101111111111111011111 -> 1111111111111111111111111111011111
+dqor710 or 1111111111111111111111111111101111 1111001111111011111111111111101111 -> 1111111111111111111111111111101111
+dqor711 or 1111111111111111111111111111110111 1110110111110111111111111111110111 -> 1111111111111111111111111111110111
+dqor712 or 1111111111111111111111111111111011 1101111011101111111111111111111011 -> 1111111111111111111111111111111011
+dqor713 or 1111111111111111111111111111111101 1011111101011111111111111111111101 -> 1111111111111111111111111111111101
+dqor714 or 1111111111111111111111111111111110 0111111110111111111111111111111110 -> 1111111111111111111111111111111110
+
+
+
+-- 1234567890123456 1234567890123456 1234567890123456
+dqor020 or 1111111111111111 1111111111111111 -> 1111111111111111
+dqor021 or 111111111111111 111111111111111 -> 111111111111111
+dqor022 or 11111111111111 11111111111111 -> 11111111111111
+dqor023 or 1111111111111 1111111111111 -> 1111111111111
+dqor024 or 111111111111 111111111111 -> 111111111111
+dqor025 or 11111111111 11111111111 -> 11111111111
+dqor026 or 1111111111 1111111111 -> 1111111111
+dqor027 or 111111111 111111111 -> 111111111
+dqor028 or 11111111 11111111 -> 11111111
+dqor029 or 1111111 1111111 -> 1111111
+dqor030 or 111111 111111 -> 111111
+dqor031 or 11111 11111 -> 11111
+dqor032 or 1111 1111 -> 1111
+dqor033 or 111 111 -> 111
+dqor034 or 11 11 -> 11
+dqor035 or 1 1 -> 1
+dqor036 or 0 0 -> 0
+
+dqor042 or 111111110000000 1111111110000000 -> 1111111110000000
+dqor043 or 11111110000000 1000000100000000 -> 1011111110000000
+dqor044 or 1111110000000 1000001000000000 -> 1001111110000000
+dqor045 or 111110000000 1000010000000000 -> 1000111110000000
+dqor046 or 11110000000 1000100000000000 -> 1000111110000000
+dqor047 or 1110000000 1001000000000000 -> 1001001110000000
+dqor048 or 110000000 1010000000000000 -> 1010000110000000
+dqor049 or 10000000 1100000000000000 -> 1100000010000000
+
+dqor090 or 011111111 111101111 -> 111111111
+dqor091 or 101111111 111101111 -> 111111111
+dqor092 or 110111111 111101111 -> 111111111
+dqor093 or 111011111 111101111 -> 111111111
+dqor094 or 111101111 111101111 -> 111101111
+dqor095 or 111110111 111101111 -> 111111111
+dqor096 or 111111011 111101111 -> 111111111
+dqor097 or 111111101 111101111 -> 111111111
+dqor098 or 111111110 111101111 -> 111111111
+
+dqor100 or 111101111 011111111 -> 111111111
+dqor101 or 111101111 101111111 -> 111111111
+dqor102 or 111101111 110111111 -> 111111111
+dqor103 or 111101111 111011111 -> 111111111
+dqor104 or 111101111 111101111 -> 111101111
+dqor105 or 111101111 111110111 -> 111111111
+dqor106 or 111101111 111111011 -> 111111111
+dqor107 or 111101111 111111101 -> 111111111
+dqor108 or 111101111 111111110 -> 111111111
+
+-- non-0/1 should not be accepted, nor should signs
+dqor220 or 111111112 111111111 -> NaN Invalid_operation
+dqor221 or 333333333 333333333 -> NaN Invalid_operation
+dqor222 or 555555555 555555555 -> NaN Invalid_operation
+dqor223 or 777777777 777777777 -> NaN Invalid_operation
+dqor224 or 999999999 999999999 -> NaN Invalid_operation
+dqor225 or 222222222 999999999 -> NaN Invalid_operation
+dqor226 or 444444444 999999999 -> NaN Invalid_operation
+dqor227 or 666666666 999999999 -> NaN Invalid_operation
+dqor228 or 888888888 999999999 -> NaN Invalid_operation
+dqor229 or 999999999 222222222 -> NaN Invalid_operation
+dqor230 or 999999999 444444444 -> NaN Invalid_operation
+dqor231 or 999999999 666666666 -> NaN Invalid_operation
+dqor232 or 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+dqor240 or 567468689 -934981942 -> NaN Invalid_operation
+dqor241 or 567367689 934981942 -> NaN Invalid_operation
+dqor242 or -631917772 -706014634 -> NaN Invalid_operation
+dqor243 or -756253257 138579234 -> NaN Invalid_operation
+dqor244 or 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+dqor250 or 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqor251 or 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqor252 or 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqor253 or 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqor254 or 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqor255 or 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqor256 or 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqor257 or 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqor258 or 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqor259 or 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqor260 or 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqor261 or 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+dqor262 or 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqor263 or 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqor264 or 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqor265 or 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+-- test MSD-1
+dqor270 or 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
+dqor271 or 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
+dqor272 or 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
+dqor273 or 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
+dqor274 or 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
+dqor275 or 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
+dqor276 or 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
+dqor277 or 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
+-- test LSD
+dqor280 or 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
+dqor281 or 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
+dqor282 or 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
+dqor283 or 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
+dqor284 or 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
+dqor285 or 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
+dqor286 or 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
+dqor287 or 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
+-- test Middie
+dqor288 or 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
+dqor289 or 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
+dqor290 or 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
+dqor291 or 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
+dqor292 or 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
+dqor293 or 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
+dqor294 or 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
+dqor295 or 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
+-- signs
+dqor296 or -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
+dqor297 or -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
+dqor298 or 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
+dqor299 or 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 1000001111001111001111000011000100
+
+-- Nmax, Nmin, Ntiny-like
+dqor331 or 2 9.99999999E+1999 -> NaN Invalid_operation
+dqor332 or 3 1E-1999 -> NaN Invalid_operation
+dqor333 or 4 1.00000000E-1999 -> NaN Invalid_operation
+dqor334 or 5 1E-1009 -> NaN Invalid_operation
+dqor335 or 6 -1E-1009 -> NaN Invalid_operation
+dqor336 or 7 -1.00000000E-1999 -> NaN Invalid_operation
+dqor337 or 8 -1E-1999 -> NaN Invalid_operation
+dqor338 or 9 -9.99999999E+1999 -> NaN Invalid_operation
+dqor341 or 9.99999999E+2999 -18 -> NaN Invalid_operation
+dqor342 or 1E-2999 01 -> NaN Invalid_operation
+dqor343 or 1.00000000E-2999 -18 -> NaN Invalid_operation
+dqor344 or 1E-1009 18 -> NaN Invalid_operation
+dqor345 or -1E-1009 -10 -> NaN Invalid_operation
+dqor346 or -1.00000000E-2999 18 -> NaN Invalid_operation
+dqor347 or -1E-2999 10 -> NaN Invalid_operation
+dqor348 or -9.99999999E+2999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+dqor361 or 1.0 1 -> NaN Invalid_operation
+dqor362 or 1E+1 1 -> NaN Invalid_operation
+dqor363 or 0.0 1 -> NaN Invalid_operation
+dqor364 or 0E+1 1 -> NaN Invalid_operation
+dqor365 or 9.9 1 -> NaN Invalid_operation
+dqor366 or 9E+1 1 -> NaN Invalid_operation
+dqor371 or 0 1.0 -> NaN Invalid_operation
+dqor372 or 0 1E+1 -> NaN Invalid_operation
+dqor373 or 0 0.0 -> NaN Invalid_operation
+dqor374 or 0 0E+1 -> NaN Invalid_operation
+dqor375 or 0 9.9 -> NaN Invalid_operation
+dqor376 or 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+dqor780 or -Inf -Inf -> NaN Invalid_operation
+dqor781 or -Inf -1000 -> NaN Invalid_operation
+dqor782 or -Inf -1 -> NaN Invalid_operation
+dqor783 or -Inf -0 -> NaN Invalid_operation
+dqor784 or -Inf 0 -> NaN Invalid_operation
+dqor785 or -Inf 1 -> NaN Invalid_operation
+dqor786 or -Inf 1000 -> NaN Invalid_operation
+dqor787 or -1000 -Inf -> NaN Invalid_operation
+dqor788 or -Inf -Inf -> NaN Invalid_operation
+dqor789 or -1 -Inf -> NaN Invalid_operation
+dqor790 or -0 -Inf -> NaN Invalid_operation
+dqor791 or 0 -Inf -> NaN Invalid_operation
+dqor792 or 1 -Inf -> NaN Invalid_operation
+dqor793 or 1000 -Inf -> NaN Invalid_operation
+dqor794 or Inf -Inf -> NaN Invalid_operation
+
+dqor800 or Inf -Inf -> NaN Invalid_operation
+dqor801 or Inf -1000 -> NaN Invalid_operation
+dqor802 or Inf -1 -> NaN Invalid_operation
+dqor803 or Inf -0 -> NaN Invalid_operation
+dqor804 or Inf 0 -> NaN Invalid_operation
+dqor805 or Inf 1 -> NaN Invalid_operation
+dqor806 or Inf 1000 -> NaN Invalid_operation
+dqor807 or Inf Inf -> NaN Invalid_operation
+dqor808 or -1000 Inf -> NaN Invalid_operation
+dqor809 or -Inf Inf -> NaN Invalid_operation
+dqor810 or -1 Inf -> NaN Invalid_operation
+dqor811 or -0 Inf -> NaN Invalid_operation
+dqor812 or 0 Inf -> NaN Invalid_operation
+dqor813 or 1 Inf -> NaN Invalid_operation
+dqor814 or 1000 Inf -> NaN Invalid_operation
+dqor815 or Inf Inf -> NaN Invalid_operation
+
+dqor821 or NaN -Inf -> NaN Invalid_operation
+dqor822 or NaN -1000 -> NaN Invalid_operation
+dqor823 or NaN -1 -> NaN Invalid_operation
+dqor824 or NaN -0 -> NaN Invalid_operation
+dqor825 or NaN 0 -> NaN Invalid_operation
+dqor826 or NaN 1 -> NaN Invalid_operation
+dqor827 or NaN 1000 -> NaN Invalid_operation
+dqor828 or NaN Inf -> NaN Invalid_operation
+dqor829 or NaN NaN -> NaN Invalid_operation
+dqor830 or -Inf NaN -> NaN Invalid_operation
+dqor831 or -1000 NaN -> NaN Invalid_operation
+dqor832 or -1 NaN -> NaN Invalid_operation
+dqor833 or -0 NaN -> NaN Invalid_operation
+dqor834 or 0 NaN -> NaN Invalid_operation
+dqor835 or 1 NaN -> NaN Invalid_operation
+dqor836 or 1000 NaN -> NaN Invalid_operation
+dqor837 or Inf NaN -> NaN Invalid_operation
+
+dqor841 or sNaN -Inf -> NaN Invalid_operation
+dqor842 or sNaN -1000 -> NaN Invalid_operation
+dqor843 or sNaN -1 -> NaN Invalid_operation
+dqor844 or sNaN -0 -> NaN Invalid_operation
+dqor845 or sNaN 0 -> NaN Invalid_operation
+dqor846 or sNaN 1 -> NaN Invalid_operation
+dqor847 or sNaN 1000 -> NaN Invalid_operation
+dqor848 or sNaN NaN -> NaN Invalid_operation
+dqor849 or sNaN sNaN -> NaN Invalid_operation
+dqor850 or NaN sNaN -> NaN Invalid_operation
+dqor851 or -Inf sNaN -> NaN Invalid_operation
+dqor852 or -1000 sNaN -> NaN Invalid_operation
+dqor853 or -1 sNaN -> NaN Invalid_operation
+dqor854 or -0 sNaN -> NaN Invalid_operation
+dqor855 or 0 sNaN -> NaN Invalid_operation
+dqor856 or 1 sNaN -> NaN Invalid_operation
+dqor857 or 1000 sNaN -> NaN Invalid_operation
+dqor858 or Inf sNaN -> NaN Invalid_operation
+dqor859 or NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqor861 or NaN1 -Inf -> NaN Invalid_operation
+dqor862 or +NaN2 -1000 -> NaN Invalid_operation
+dqor863 or NaN3 1000 -> NaN Invalid_operation
+dqor864 or NaN4 Inf -> NaN Invalid_operation
+dqor865 or NaN5 +NaN6 -> NaN Invalid_operation
+dqor866 or -Inf NaN7 -> NaN Invalid_operation
+dqor867 or -1000 NaN8 -> NaN Invalid_operation
+dqor868 or 1000 NaN9 -> NaN Invalid_operation
+dqor869 or Inf +NaN10 -> NaN Invalid_operation
+dqor871 or sNaN11 -Inf -> NaN Invalid_operation
+dqor872 or sNaN12 -1000 -> NaN Invalid_operation
+dqor873 or sNaN13 1000 -> NaN Invalid_operation
+dqor874 or sNaN14 NaN17 -> NaN Invalid_operation
+dqor875 or sNaN15 sNaN18 -> NaN Invalid_operation
+dqor876 or NaN16 sNaN19 -> NaN Invalid_operation
+dqor877 or -Inf +sNaN20 -> NaN Invalid_operation
+dqor878 or -1000 sNaN21 -> NaN Invalid_operation
+dqor879 or 1000 sNaN22 -> NaN Invalid_operation
+dqor880 or Inf sNaN23 -> NaN Invalid_operation
+dqor881 or +NaN25 +sNaN24 -> NaN Invalid_operation
+dqor882 or -NaN26 NaN28 -> NaN Invalid_operation
+dqor883 or -sNaN27 sNaN29 -> NaN Invalid_operation
+dqor884 or 1000 -NaN30 -> NaN Invalid_operation
+dqor885 or 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqPlus.decTest b/Lib/test/decimaltestdata/dqPlus.decTest
index 8aecaab796..df1a15ca7f 100644
--- a/Lib/test/decimaltestdata/dqPlus.decTest
+++ b/Lib/test/decimaltestdata/dqPlus.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqPlus.decTest -- decQuad 0+x --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqpls001 plus +7.50 -> 7.50
-
--- Infinities
-dqpls011 plus Infinity -> Infinity
-dqpls012 plus -Infinity -> -Infinity
-
--- NaNs, 0 payload
-ddqls021 plus NaN -> NaN
-ddqls022 plus -NaN -> -NaN
-ddqls023 plus sNaN -> NaN Invalid_operation
-ddqls024 plus -sNaN -> -NaN Invalid_operation
-
--- NaNs, non-0 payload
-ddqls031 plus NaN13 -> NaN13
-ddqls032 plus -NaN13 -> -NaN13
-ddqls033 plus sNaN13 -> NaN13 Invalid_operation
-ddqls034 plus -sNaN13 -> -NaN13 Invalid_operation
-ddqls035 plus NaN70 -> NaN70
-ddqls036 plus -NaN70 -> -NaN70
-ddqls037 plus sNaN101 -> NaN101 Invalid_operation
-ddqls038 plus -sNaN101 -> -NaN101 Invalid_operation
-
--- finites
-dqpls101 plus 7 -> 7
-dqpls102 plus -7 -> -7
-dqpls103 plus 75 -> 75
-dqpls104 plus -75 -> -75
-dqpls105 plus 7.50 -> 7.50
-dqpls106 plus -7.50 -> -7.50
-dqpls107 plus 7.500 -> 7.500
-dqpls108 plus -7.500 -> -7.500
-
--- zeros
-dqpls111 plus 0 -> 0
-dqpls112 plus -0 -> 0
-dqpls113 plus 0E+4 -> 0E+4
-dqpls114 plus -0E+4 -> 0E+4
-dqpls115 plus 0.0000 -> 0.0000
-dqpls116 plus -0.0000 -> 0.0000
-dqpls117 plus 0E-141 -> 0E-141
-dqpls118 plus -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqpls121 plus 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqpls122 plus -2682682682682682682682682682682682 -> -2682682682682682682682682682682682
-dqpls123 plus 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-dqpls124 plus -1341341341341341341341341341341341 -> -1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqpls131 plus 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqpls132 plus 1E-6143 -> 1E-6143
-dqpls133 plus 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqpls134 plus 1E-6176 -> 1E-6176 Subnormal
-
-dqpls135 plus -1E-6176 -> -1E-6176 Subnormal
-dqpls136 plus -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqpls137 plus -1E-6143 -> -1E-6143
-dqpls138 plus -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqPlus.decTest -- decQuad 0+x --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqpls001 plus +7.50 -> 7.50
+
+-- Infinities
+dqpls011 plus Infinity -> Infinity
+dqpls012 plus -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+ddqls021 plus NaN -> NaN
+ddqls022 plus -NaN -> -NaN
+ddqls023 plus sNaN -> NaN Invalid_operation
+ddqls024 plus -sNaN -> -NaN Invalid_operation
+
+-- NaNs, non-0 payload
+ddqls031 plus NaN13 -> NaN13
+ddqls032 plus -NaN13 -> -NaN13
+ddqls033 plus sNaN13 -> NaN13 Invalid_operation
+ddqls034 plus -sNaN13 -> -NaN13 Invalid_operation
+ddqls035 plus NaN70 -> NaN70
+ddqls036 plus -NaN70 -> -NaN70
+ddqls037 plus sNaN101 -> NaN101 Invalid_operation
+ddqls038 plus -sNaN101 -> -NaN101 Invalid_operation
+
+-- finites
+dqpls101 plus 7 -> 7
+dqpls102 plus -7 -> -7
+dqpls103 plus 75 -> 75
+dqpls104 plus -75 -> -75
+dqpls105 plus 7.50 -> 7.50
+dqpls106 plus -7.50 -> -7.50
+dqpls107 plus 7.500 -> 7.500
+dqpls108 plus -7.500 -> -7.500
+
+-- zeros
+dqpls111 plus 0 -> 0
+dqpls112 plus -0 -> 0
+dqpls113 plus 0E+4 -> 0E+4
+dqpls114 plus -0E+4 -> 0E+4
+dqpls115 plus 0.0000 -> 0.0000
+dqpls116 plus -0.0000 -> 0.0000
+dqpls117 plus 0E-141 -> 0E-141
+dqpls118 plus -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqpls121 plus 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqpls122 plus -2682682682682682682682682682682682 -> -2682682682682682682682682682682682
+dqpls123 plus 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+dqpls124 plus -1341341341341341341341341341341341 -> -1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqpls131 plus 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqpls132 plus 1E-6143 -> 1E-6143
+dqpls133 plus 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqpls134 plus 1E-6176 -> 1E-6176 Subnormal
+
+dqpls135 plus -1E-6176 -> -1E-6176 Subnormal
+dqpls136 plus -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqpls137 plus -1E-6143 -> -1E-6143
+dqpls138 plus -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqQuantize.decTest b/Lib/test/decimaltestdata/dqQuantize.decTest
index 51471c2626..4ed39b45c4 100644
--- a/Lib/test/decimaltestdata/dqQuantize.decTest
+++ b/Lib/test/decimaltestdata/dqQuantize.decTest
@@ -1,836 +1,836 @@
-------------------------------------------------------------------------
--- dqQuantize.decTest -- decQuad quantize operation --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Most of the tests here assume a "regular pattern", where the
--- sign and coefficient are +1.
--- 2004.03.15 Underflow for quantize is suppressed
--- 2005.06.08 More extensive tests for 'does not fit'
--- [Forked from quantize.decTest 2006.11.25]
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqqua001 quantize 0 1e0 -> 0
-dqqua002 quantize 1 1e0 -> 1
-dqqua003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded
-dqqua005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded
-dqqua006 quantize 0.1 1e0 -> 0 Inexact Rounded
-dqqua007 quantize 0.1 1e-1 -> 0.1
-dqqua008 quantize 0.1 1e-2 -> 0.10
-dqqua009 quantize 0.1 1e-3 -> 0.100
-dqqua010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded
-dqqua011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded
-dqqua012 quantize 0.9 1e+0 -> 1 Inexact Rounded
-dqqua013 quantize 0.9 1e-1 -> 0.9
-dqqua014 quantize 0.9 1e-2 -> 0.90
-dqqua015 quantize 0.9 1e-3 -> 0.900
--- negatives
-dqqua021 quantize -0 1e0 -> -0
-dqqua022 quantize -1 1e0 -> -1
-dqqua023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded
-dqqua025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded
-dqqua026 quantize -0.1 1e0 -> -0 Inexact Rounded
-dqqua027 quantize -0.1 1e-1 -> -0.1
-dqqua028 quantize -0.1 1e-2 -> -0.10
-dqqua029 quantize -0.1 1e-3 -> -0.100
-dqqua030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
-dqqua031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
-dqqua032 quantize -0.9 1e+0 -> -1 Inexact Rounded
-dqqua033 quantize -0.9 1e-1 -> -0.9
-dqqua034 quantize -0.9 1e-2 -> -0.90
-dqqua035 quantize -0.9 1e-3 -> -0.900
-dqqua036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded
-dqqua037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded
-dqqua038 quantize -0.5 1e+0 -> -0 Inexact Rounded
-dqqua039 quantize -0.5 1e-1 -> -0.5
-dqqua040 quantize -0.5 1e-2 -> -0.50
-dqqua041 quantize -0.5 1e-3 -> -0.500
-dqqua042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
-dqqua043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
-dqqua044 quantize -0.9 1e+0 -> -1 Inexact Rounded
-dqqua045 quantize -0.9 1e-1 -> -0.9
-dqqua046 quantize -0.9 1e-2 -> -0.90
-dqqua047 quantize -0.9 1e-3 -> -0.900
-
--- examples from Specification
-dqqua060 quantize 2.17 0.001 -> 2.170
-dqqua061 quantize 2.17 0.01 -> 2.17
-dqqua062 quantize 2.17 0.1 -> 2.2 Inexact Rounded
-dqqua063 quantize 2.17 1e+0 -> 2 Inexact Rounded
-dqqua064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded
-dqqua065 quantize -Inf Inf -> -Infinity
-dqqua066 quantize 2 Inf -> NaN Invalid_operation
-dqqua067 quantize -0.1 1 -> -0 Inexact Rounded
-dqqua068 quantize -0 1e+5 -> -0E+5
-dqqua069 quantize +123451234567899876543216789012345.6 1e-2 -> NaN Invalid_operation
-dqqua070 quantize -987651234567899876543214335236450.6 1e-2 -> NaN Invalid_operation
-dqqua071 quantize 217 1e-1 -> 217.0
-dqqua072 quantize 217 1e+0 -> 217
-dqqua073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded
-dqqua074 quantize 217 1e+2 -> 2E+2 Inexact Rounded
-
--- general tests ..
-dqqua089 quantize 12 1e+4 -> 0E+4 Inexact Rounded
-dqqua090 quantize 12 1e+3 -> 0E+3 Inexact Rounded
-dqqua091 quantize 12 1e+2 -> 0E+2 Inexact Rounded
-dqqua092 quantize 12 1e+1 -> 1E+1 Inexact Rounded
-dqqua093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded
-dqqua094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded
-dqqua095 quantize 1.2345 1e-6 -> 1.234500
-dqqua096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded
-dqqua097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded
-dqqua098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded
-dqqua099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded
-dqqua100 quantize 92 1e+2 -> 1E+2 Inexact Rounded
-
-dqqua101 quantize -1 1e0 -> -1
-dqqua102 quantize -1 1e-1 -> -1.0
-dqqua103 quantize -1 1e-2 -> -1.00
-dqqua104 quantize 0 1e0 -> 0
-dqqua105 quantize 0 1e-1 -> 0.0
-dqqua106 quantize 0 1e-2 -> 0.00
-dqqua107 quantize 0.00 1e0 -> 0
-dqqua108 quantize 0 1e+1 -> 0E+1
-dqqua109 quantize 0 1e+2 -> 0E+2
-dqqua110 quantize +1 1e0 -> 1
-dqqua111 quantize +1 1e-1 -> 1.0
-dqqua112 quantize +1 1e-2 -> 1.00
-
-dqqua120 quantize 1.04 1e-3 -> 1.040
-dqqua121 quantize 1.04 1e-2 -> 1.04
-dqqua122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded
-dqqua123 quantize 1.04 1e0 -> 1 Inexact Rounded
-dqqua124 quantize 1.05 1e-3 -> 1.050
-dqqua125 quantize 1.05 1e-2 -> 1.05
-dqqua126 quantize 1.05 1e-1 -> 1.0 Inexact Rounded
-dqqua131 quantize 1.05 1e0 -> 1 Inexact Rounded
-dqqua132 quantize 1.06 1e-3 -> 1.060
-dqqua133 quantize 1.06 1e-2 -> 1.06
-dqqua134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded
-dqqua135 quantize 1.06 1e0 -> 1 Inexact Rounded
-
-dqqua140 quantize -10 1e-2 -> -10.00
-dqqua141 quantize +1 1e-2 -> 1.00
-dqqua142 quantize +10 1e-2 -> 10.00
-dqqua143 quantize 1E+37 1e-2 -> NaN Invalid_operation
-dqqua144 quantize 1E-37 1e-2 -> 0.00 Inexact Rounded
-dqqua145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded
-dqqua146 quantize 1E-2 1e-2 -> 0.01
-dqqua147 quantize 1E-1 1e-2 -> 0.10
-dqqua148 quantize 0E-37 1e-2 -> 0.00
-
-dqqua150 quantize 1.0600 1e-5 -> 1.06000
-dqqua151 quantize 1.0600 1e-4 -> 1.0600
-dqqua152 quantize 1.0600 1e-3 -> 1.060 Rounded
-dqqua153 quantize 1.0600 1e-2 -> 1.06 Rounded
-dqqua154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded
-dqqua155 quantize 1.0600 1e0 -> 1 Inexact Rounded
-
--- a couple where rounding was different in base tests
-rounding: half_up
-dqqua157 quantize -0.5 1e+0 -> -1 Inexact Rounded
-dqqua158 quantize 1.05 1e-1 -> 1.1 Inexact Rounded
-dqqua159 quantize 1.06 1e0 -> 1 Inexact Rounded
-rounding: half_even
-
--- base tests with non-1 coefficients
-dqqua161 quantize 0 -9e0 -> 0
-dqqua162 quantize 1 -7e0 -> 1
-dqqua163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded
-dqqua165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded
-dqqua166 quantize 0.1 2e0 -> 0 Inexact Rounded
-dqqua167 quantize 0.1 3e-1 -> 0.1
-dqqua168 quantize 0.1 44e-2 -> 0.10
-dqqua169 quantize 0.1 555e-3 -> 0.100
-dqqua170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded
-dqqua171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded
-dqqua172 quantize 0.9 -88e+0 -> 1 Inexact Rounded
-dqqua173 quantize 0.9 -9e-1 -> 0.9
-dqqua174 quantize 0.9 0e-2 -> 0.90
-dqqua175 quantize 0.9 1.1e-3 -> 0.9000
--- negatives
-dqqua181 quantize -0 1.1e0 -> -0.0
-dqqua182 quantize -1 -1e0 -> -1
-dqqua183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded
-dqqua185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded
-dqqua186 quantize -0.1 71e0 -> -0 Inexact Rounded
-dqqua187 quantize -0.1 -91e-1 -> -0.1
-dqqua188 quantize -0.1 -.1e-2 -> -0.100
-dqqua189 quantize -0.1 -1e-3 -> -0.100
-dqqua190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded
-dqqua191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded
-dqqua192 quantize -0.9 -10e+0 -> -1 Inexact Rounded
-dqqua193 quantize -0.9 100e-1 -> -0.9
-dqqua194 quantize -0.9 999e-2 -> -0.90
-
--- +ve exponents ..
-dqqua201 quantize -1 1e+0 -> -1
-dqqua202 quantize -1 1e+1 -> -0E+1 Inexact Rounded
-dqqua203 quantize -1 1e+2 -> -0E+2 Inexact Rounded
-dqqua204 quantize 0 1e+0 -> 0
-dqqua205 quantize 0 1e+1 -> 0E+1
-dqqua206 quantize 0 1e+2 -> 0E+2
-dqqua207 quantize +1 1e+0 -> 1
-dqqua208 quantize +1 1e+1 -> 0E+1 Inexact Rounded
-dqqua209 quantize +1 1e+2 -> 0E+2 Inexact Rounded
-
-dqqua220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded
-dqqua221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded
-dqqua222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded
-dqqua223 quantize 1.04 1e+0 -> 1 Inexact Rounded
-dqqua224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
-dqqua225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
-dqqua226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
-dqqua227 quantize 1.05 1e+0 -> 1 Inexact Rounded
-dqqua228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
-dqqua229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
-dqqua230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
-dqqua231 quantize 1.05 1e+0 -> 1 Inexact Rounded
-dqqua232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded
-dqqua233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded
-dqqua234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded
-dqqua235 quantize 1.06 1e+0 -> 1 Inexact Rounded
-
-dqqua240 quantize -10 1e+1 -> -1E+1 Rounded
-dqqua241 quantize +1 1e+1 -> 0E+1 Inexact Rounded
-dqqua242 quantize +10 1e+1 -> 1E+1 Rounded
-dqqua243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1
-dqqua244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1
-dqqua245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1
-dqqua246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1
-dqqua247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1
-dqqua248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1
-dqqua249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1
-dqqua250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1
-dqqua251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1
--- next one tries to add 9 zeros
-dqqua252 quantize 1E+37 1e+1 -> NaN Invalid_operation
-dqqua253 quantize 1E-37 1e+1 -> 0E+1 Inexact Rounded
-dqqua254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded
-dqqua255 quantize 0E-37 1e+1 -> 0E+1
-dqqua256 quantize -0E-37 1e+1 -> -0E+1
-dqqua257 quantize -0E-1 1e+1 -> -0E+1
-dqqua258 quantize -0 1e+1 -> -0E+1
-dqqua259 quantize -0E+1 1e+1 -> -0E+1
-
-dqqua260 quantize -10 1e+2 -> -0E+2 Inexact Rounded
-dqqua261 quantize +1 1e+2 -> 0E+2 Inexact Rounded
-dqqua262 quantize +10 1e+2 -> 0E+2 Inexact Rounded
-dqqua263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded
-dqqua264 quantize 1E+2 1e+2 -> 1E+2
-dqqua265 quantize 1E+3 1e+2 -> 1.0E+3
-dqqua266 quantize 1E+4 1e+2 -> 1.00E+4
-dqqua267 quantize 1E+5 1e+2 -> 1.000E+5
-dqqua268 quantize 1E+6 1e+2 -> 1.0000E+6
-dqqua269 quantize 1E+7 1e+2 -> 1.00000E+7
-dqqua270 quantize 1E+8 1e+2 -> 1.000000E+8
-dqqua271 quantize 1E+9 1e+2 -> 1.0000000E+9
-dqqua272 quantize 1E+10 1e+2 -> 1.00000000E+10
-dqqua273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded
-dqqua274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded
-dqqua275 quantize 0E-10 1e+2 -> 0E+2
-
-dqqua280 quantize -10 1e+3 -> -0E+3 Inexact Rounded
-dqqua281 quantize +1 1e+3 -> 0E+3 Inexact Rounded
-dqqua282 quantize +10 1e+3 -> 0E+3 Inexact Rounded
-dqqua283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded
-dqqua284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded
-dqqua285 quantize 1E+3 1e+3 -> 1E+3
-dqqua286 quantize 1E+4 1e+3 -> 1.0E+4
-dqqua287 quantize 1E+5 1e+3 -> 1.00E+5
-dqqua288 quantize 1E+6 1e+3 -> 1.000E+6
-dqqua289 quantize 1E+7 1e+3 -> 1.0000E+7
-dqqua290 quantize 1E+8 1e+3 -> 1.00000E+8
-dqqua291 quantize 1E+9 1e+3 -> 1.000000E+9
-dqqua292 quantize 1E+10 1e+3 -> 1.0000000E+10
-dqqua293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded
-dqqua294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded
-dqqua295 quantize 0E-10 1e+3 -> 0E+3
-
--- round up from below [sign wrong in JIT compiler once]
-dqqua300 quantize 0.0078 1e-5 -> 0.00780
-dqqua301 quantize 0.0078 1e-4 -> 0.0078
-dqqua302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded
-dqqua303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded
-dqqua304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded
-dqqua305 quantize 0.0078 1e0 -> 0 Inexact Rounded
-dqqua306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded
-dqqua307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded
-
-dqqua310 quantize -0.0078 1e-5 -> -0.00780
-dqqua311 quantize -0.0078 1e-4 -> -0.0078
-dqqua312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded
-dqqua313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded
-dqqua314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded
-dqqua315 quantize -0.0078 1e0 -> -0 Inexact Rounded
-dqqua316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded
-dqqua317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded
-
-dqqua320 quantize 0.078 1e-5 -> 0.07800
-dqqua321 quantize 0.078 1e-4 -> 0.0780
-dqqua322 quantize 0.078 1e-3 -> 0.078
-dqqua323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded
-dqqua324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded
-dqqua325 quantize 0.078 1e0 -> 0 Inexact Rounded
-dqqua326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded
-dqqua327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded
-
-dqqua330 quantize -0.078 1e-5 -> -0.07800
-dqqua331 quantize -0.078 1e-4 -> -0.0780
-dqqua332 quantize -0.078 1e-3 -> -0.078
-dqqua333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded
-dqqua334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded
-dqqua335 quantize -0.078 1e0 -> -0 Inexact Rounded
-dqqua336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded
-dqqua337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded
-
-dqqua340 quantize 0.78 1e-5 -> 0.78000
-dqqua341 quantize 0.78 1e-4 -> 0.7800
-dqqua342 quantize 0.78 1e-3 -> 0.780
-dqqua343 quantize 0.78 1e-2 -> 0.78
-dqqua344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded
-dqqua345 quantize 0.78 1e0 -> 1 Inexact Rounded
-dqqua346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded
-dqqua347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded
-
-dqqua350 quantize -0.78 1e-5 -> -0.78000
-dqqua351 quantize -0.78 1e-4 -> -0.7800
-dqqua352 quantize -0.78 1e-3 -> -0.780
-dqqua353 quantize -0.78 1e-2 -> -0.78
-dqqua354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded
-dqqua355 quantize -0.78 1e0 -> -1 Inexact Rounded
-dqqua356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded
-dqqua357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded
-
-dqqua360 quantize 7.8 1e-5 -> 7.80000
-dqqua361 quantize 7.8 1e-4 -> 7.8000
-dqqua362 quantize 7.8 1e-3 -> 7.800
-dqqua363 quantize 7.8 1e-2 -> 7.80
-dqqua364 quantize 7.8 1e-1 -> 7.8
-dqqua365 quantize 7.8 1e0 -> 8 Inexact Rounded
-dqqua366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded
-dqqua367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded
-dqqua368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded
-
-dqqua370 quantize -7.8 1e-5 -> -7.80000
-dqqua371 quantize -7.8 1e-4 -> -7.8000
-dqqua372 quantize -7.8 1e-3 -> -7.800
-dqqua373 quantize -7.8 1e-2 -> -7.80
-dqqua374 quantize -7.8 1e-1 -> -7.8
-dqqua375 quantize -7.8 1e0 -> -8 Inexact Rounded
-dqqua376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded
-dqqua377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded
-dqqua378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded
-
--- some individuals
-dqqua380 quantize 1122334455667788991234567352364.506 1e-2 -> 1122334455667788991234567352364.51 Inexact Rounded
-dqqua381 quantize 11223344556677889912345673523645.06 1e-2 -> 11223344556677889912345673523645.06
-dqqua382 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
-dqqua383 quantize 1122334455667788991234567352364506 1e-2 -> NaN Invalid_operation
-dqqua384 quantize -1122334455667788991234567352364.506 1e-2 -> -1122334455667788991234567352364.51 Inexact Rounded
-dqqua385 quantize -11223344556677889912345673523645.06 1e-2 -> -11223344556677889912345673523645.06
-dqqua386 quantize -112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
-dqqua387 quantize -1122334455667788991234567352364506 1e-2 -> NaN Invalid_operation
-
-rounding: down
-dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
-rounding: half_up
-
--- and a few more from e-mail discussions
-dqqua391 quantize 11223344556677889912345678912.34567 1e-3 -> 11223344556677889912345678912.346 Inexact Rounded
-dqqua392 quantize 112233445566778899123456789123.4567 1e-3 -> 112233445566778899123456789123.457 Inexact Rounded
-dqqua393 quantize 1122334455667788991234567891234567. 1e-3 -> NaN Invalid_operation
-
--- some 9999 round-up cases
-dqqua400 quantize 9.999 1e-5 -> 9.99900
-dqqua401 quantize 9.999 1e-4 -> 9.9990
-dqqua402 quantize 9.999 1e-3 -> 9.999
-dqqua403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded
-dqqua404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded
-dqqua405 quantize 9.999 1e0 -> 10 Inexact Rounded
-dqqua406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded
-dqqua407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded
-
-dqqua410 quantize 0.999 1e-5 -> 0.99900
-dqqua411 quantize 0.999 1e-4 -> 0.9990
-dqqua412 quantize 0.999 1e-3 -> 0.999
-dqqua413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded
-dqqua414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded
-dqqua415 quantize 0.999 1e0 -> 1 Inexact Rounded
-dqqua416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded
-
-dqqua420 quantize 0.0999 1e-5 -> 0.09990
-dqqua421 quantize 0.0999 1e-4 -> 0.0999
-dqqua422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded
-dqqua423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded
-dqqua424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded
-dqqua425 quantize 0.0999 1e0 -> 0 Inexact Rounded
-dqqua426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded
-
-dqqua430 quantize 0.00999 1e-5 -> 0.00999
-dqqua431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded
-dqqua432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded
-dqqua433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded
-dqqua434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded
-dqqua435 quantize 0.00999 1e0 -> 0 Inexact Rounded
-dqqua436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded
-
-dqqua440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded
-dqqua441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded
-dqqua442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded
-dqqua443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded
-dqqua444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded
-dqqua445 quantize 0.000999 1e0 -> 0 Inexact Rounded
-dqqua446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded
-
-dqqua1001 quantize 0.000 0.001 -> 0.000
-dqqua1002 quantize 0.001 0.001 -> 0.001
-dqqua1003 quantize 0.0012 0.001 -> 0.001 Inexact Rounded
-dqqua1004 quantize 0.0018 0.001 -> 0.002 Inexact Rounded
-dqqua1005 quantize 0.501 0.001 -> 0.501
-dqqua1006 quantize 0.5012 0.001 -> 0.501 Inexact Rounded
-dqqua1007 quantize 0.5018 0.001 -> 0.502 Inexact Rounded
-dqqua1008 quantize 0.999 0.001 -> 0.999
-
-dqqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
-dqqua482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
-dqqua483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
-dqqua484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
-dqqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
-dqqua486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
--- a potential double-round
-dqqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
-dqqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
-
-dqqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
-dqqua492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
-dqqua493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
-dqqua494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
-dqqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
-dqqua496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
-dqqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
-dqqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
-
--- Zeros
-dqqua500 quantize 0 1e1 -> 0E+1
-dqqua501 quantize 0 1e0 -> 0
-dqqua502 quantize 0 1e-1 -> 0.0
-dqqua503 quantize 0.0 1e-1 -> 0.0
-dqqua504 quantize 0.0 1e0 -> 0
-dqqua505 quantize 0.0 1e+1 -> 0E+1
-dqqua506 quantize 0E+1 1e-1 -> 0.0
-dqqua507 quantize 0E+1 1e0 -> 0
-dqqua508 quantize 0E+1 1e+1 -> 0E+1
-dqqua509 quantize -0 1e1 -> -0E+1
-dqqua510 quantize -0 1e0 -> -0
-dqqua511 quantize -0 1e-1 -> -0.0
-dqqua512 quantize -0.0 1e-1 -> -0.0
-dqqua513 quantize -0.0 1e0 -> -0
-dqqua514 quantize -0.0 1e+1 -> -0E+1
-dqqua515 quantize -0E+1 1e-1 -> -0.0
-dqqua516 quantize -0E+1 1e0 -> -0
-dqqua517 quantize -0E+1 1e+1 -> -0E+1
--- #519 here once a problem
-dqqua518 quantize 0 0E-3 -> 0.000
-dqqua519 quantize 0 0E-33 -> 0E-33
-dqqua520 quantize 0.00000000000000000000000000000000 0E-33 -> 0E-33
-dqqua521 quantize 0.000000000000000000000000000000000 0E-33 -> 0E-33
-
--- Some non-zeros with lots of padding on the right
-dqqua523 quantize 1 0E-33 -> 1.000000000000000000000000000000000
-dqqua524 quantize 12 0E-32 -> 12.00000000000000000000000000000000
-dqqua525 quantize 123 0E-31 -> 123.0000000000000000000000000000000
-dqqua526 quantize 123 0E-32 -> NaN Invalid_operation
-dqqua527 quantize 123.4 0E-31 -> 123.4000000000000000000000000000000
-dqqua528 quantize 123.4 0E-32 -> NaN Invalid_operation
-
--- Suspicious RHS values
-dqqua530 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
-dqqua531 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
-dqqua532 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
-dqqua533 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
--- next four are "won't fit" overflows
-dqqua536 quantize 1.234 1e-299 -> NaN Invalid_operation
-dqqua537 quantize 123.456 1e-299 -> NaN Invalid_operation
-dqqua538 quantize 1.234 1e-299 -> NaN Invalid_operation
-dqqua539 quantize 123.456 1e-299 -> NaN Invalid_operation
-
-dqqua542 quantize 1.234E+299 1e299 -> 1E+299 Inexact Rounded
-dqqua543 quantize 1.234E+298 1e299 -> 0E+299 Inexact Rounded
-dqqua544 quantize 1.234 1e299 -> 0E+299 Inexact Rounded
-dqqua547 quantize 0 1e-299 -> 0E-299
--- next two are "won't fit" overflows
-dqqua548 quantize 1.234 1e-299 -> NaN Invalid_operation
-dqqua549 quantize 1.234 1e-300 -> NaN Invalid_operation
--- [more below]
-
--- Specials
-dqqua580 quantize Inf -Inf -> Infinity
-dqqua581 quantize Inf 1e-299 -> NaN Invalid_operation
-dqqua582 quantize Inf 1e-1 -> NaN Invalid_operation
-dqqua583 quantize Inf 1e0 -> NaN Invalid_operation
-dqqua584 quantize Inf 1e1 -> NaN Invalid_operation
-dqqua585 quantize Inf 1e299 -> NaN Invalid_operation
-dqqua586 quantize Inf Inf -> Infinity
-dqqua587 quantize -1000 Inf -> NaN Invalid_operation
-dqqua588 quantize -Inf Inf -> -Infinity
-dqqua589 quantize -1 Inf -> NaN Invalid_operation
-dqqua590 quantize 0 Inf -> NaN Invalid_operation
-dqqua591 quantize 1 Inf -> NaN Invalid_operation
-dqqua592 quantize 1000 Inf -> NaN Invalid_operation
-dqqua593 quantize Inf Inf -> Infinity
-dqqua594 quantize Inf 1e-0 -> NaN Invalid_operation
-dqqua595 quantize -0 Inf -> NaN Invalid_operation
-
-dqqua600 quantize -Inf -Inf -> -Infinity
-dqqua601 quantize -Inf 1e-299 -> NaN Invalid_operation
-dqqua602 quantize -Inf 1e-1 -> NaN Invalid_operation
-dqqua603 quantize -Inf 1e0 -> NaN Invalid_operation
-dqqua604 quantize -Inf 1e1 -> NaN Invalid_operation
-dqqua605 quantize -Inf 1e299 -> NaN Invalid_operation
-dqqua606 quantize -Inf Inf -> -Infinity
-dqqua607 quantize -1000 Inf -> NaN Invalid_operation
-dqqua608 quantize -Inf -Inf -> -Infinity
-dqqua609 quantize -1 -Inf -> NaN Invalid_operation
-dqqua610 quantize 0 -Inf -> NaN Invalid_operation
-dqqua611 quantize 1 -Inf -> NaN Invalid_operation
-dqqua612 quantize 1000 -Inf -> NaN Invalid_operation
-dqqua613 quantize Inf -Inf -> Infinity
-dqqua614 quantize -Inf 1e-0 -> NaN Invalid_operation
-dqqua615 quantize -0 -Inf -> NaN Invalid_operation
-
-dqqua621 quantize NaN -Inf -> NaN
-dqqua622 quantize NaN 1e-299 -> NaN
-dqqua623 quantize NaN 1e-1 -> NaN
-dqqua624 quantize NaN 1e0 -> NaN
-dqqua625 quantize NaN 1e1 -> NaN
-dqqua626 quantize NaN 1e299 -> NaN
-dqqua627 quantize NaN Inf -> NaN
-dqqua628 quantize NaN NaN -> NaN
-dqqua629 quantize -Inf NaN -> NaN
-dqqua630 quantize -1000 NaN -> NaN
-dqqua631 quantize -1 NaN -> NaN
-dqqua632 quantize 0 NaN -> NaN
-dqqua633 quantize 1 NaN -> NaN
-dqqua634 quantize 1000 NaN -> NaN
-dqqua635 quantize Inf NaN -> NaN
-dqqua636 quantize NaN 1e-0 -> NaN
-dqqua637 quantize -0 NaN -> NaN
-
-dqqua641 quantize sNaN -Inf -> NaN Invalid_operation
-dqqua642 quantize sNaN 1e-299 -> NaN Invalid_operation
-dqqua643 quantize sNaN 1e-1 -> NaN Invalid_operation
-dqqua644 quantize sNaN 1e0 -> NaN Invalid_operation
-dqqua645 quantize sNaN 1e1 -> NaN Invalid_operation
-dqqua646 quantize sNaN 1e299 -> NaN Invalid_operation
-dqqua647 quantize sNaN NaN -> NaN Invalid_operation
-dqqua648 quantize sNaN sNaN -> NaN Invalid_operation
-dqqua649 quantize NaN sNaN -> NaN Invalid_operation
-dqqua650 quantize -Inf sNaN -> NaN Invalid_operation
-dqqua651 quantize -1000 sNaN -> NaN Invalid_operation
-dqqua652 quantize -1 sNaN -> NaN Invalid_operation
-dqqua653 quantize 0 sNaN -> NaN Invalid_operation
-dqqua654 quantize 1 sNaN -> NaN Invalid_operation
-dqqua655 quantize 1000 sNaN -> NaN Invalid_operation
-dqqua656 quantize Inf sNaN -> NaN Invalid_operation
-dqqua657 quantize NaN sNaN -> NaN Invalid_operation
-dqqua658 quantize sNaN 1e-0 -> NaN Invalid_operation
-dqqua659 quantize -0 sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqqua661 quantize NaN9 -Inf -> NaN9
-dqqua662 quantize NaN8 919 -> NaN8
-dqqua663 quantize NaN71 Inf -> NaN71
-dqqua664 quantize NaN6 NaN5 -> NaN6
-dqqua665 quantize -Inf NaN4 -> NaN4
-dqqua666 quantize -919 NaN31 -> NaN31
-dqqua667 quantize Inf NaN2 -> NaN2
-
-dqqua671 quantize sNaN99 -Inf -> NaN99 Invalid_operation
-dqqua672 quantize sNaN98 -11 -> NaN98 Invalid_operation
-dqqua673 quantize sNaN97 NaN -> NaN97 Invalid_operation
-dqqua674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation
-dqqua675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation
-dqqua676 quantize -Inf sNaN92 -> NaN92 Invalid_operation
-dqqua677 quantize 088 sNaN91 -> NaN91 Invalid_operation
-dqqua678 quantize Inf sNaN90 -> NaN90 Invalid_operation
-dqqua679 quantize NaN sNaN88 -> NaN88 Invalid_operation
-
-dqqua681 quantize -NaN9 -Inf -> -NaN9
-dqqua682 quantize -NaN8 919 -> -NaN8
-dqqua683 quantize -NaN71 Inf -> -NaN71
-dqqua684 quantize -NaN6 -NaN5 -> -NaN6
-dqqua685 quantize -Inf -NaN4 -> -NaN4
-dqqua686 quantize -919 -NaN31 -> -NaN31
-dqqua687 quantize Inf -NaN2 -> -NaN2
-
-dqqua691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqqua692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation
-dqqua693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation
-dqqua694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation
-dqqua695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-dqqua696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation
-dqqua697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation
-dqqua698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation
-dqqua699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation
-
--- subnormals and underflow
-dqqua710 quantize 1.00E-6143 1e-6143 -> 1E-6143 Rounded
-dqqua711 quantize 0.1E-6143 2e-6144 -> 1E-6144 Subnormal
-dqqua712 quantize 0.10E-6143 3e-6144 -> 1E-6144 Subnormal Rounded
-dqqua713 quantize 0.100E-6143 4e-6144 -> 1E-6144 Subnormal Rounded
-dqqua714 quantize 0.01E-6143 5e-6145 -> 1E-6145 Subnormal
--- next is rounded to Emin
-dqqua715 quantize 0.999E-6143 1e-6143 -> 1E-6143 Inexact Rounded
-dqqua716 quantize 0.099E-6143 10e-6144 -> 1E-6144 Inexact Rounded Subnormal
-
-dqqua717 quantize 0.009E-6143 1e-6145 -> 1E-6145 Inexact Rounded Subnormal
-dqqua718 quantize 0.001E-6143 1e-6145 -> 0E-6145 Inexact Rounded
-dqqua719 quantize 0.0009E-6143 1e-6145 -> 0E-6145 Inexact Rounded
-dqqua720 quantize 0.0001E-6143 1e-6145 -> 0E-6145 Inexact Rounded
-
-dqqua730 quantize -1.00E-6143 1e-6143 -> -1E-6143 Rounded
-dqqua731 quantize -0.1E-6143 1e-6143 -> -0E-6143 Rounded Inexact
-dqqua732 quantize -0.10E-6143 1e-6143 -> -0E-6143 Rounded Inexact
-dqqua733 quantize -0.100E-6143 1e-6143 -> -0E-6143 Rounded Inexact
-dqqua734 quantize -0.01E-6143 1e-6143 -> -0E-6143 Inexact Rounded
--- next is rounded to Emin
-dqqua735 quantize -0.999E-6143 90e-6143 -> -1E-6143 Inexact Rounded
-dqqua736 quantize -0.099E-6143 -1e-6143 -> -0E-6143 Inexact Rounded
-dqqua737 quantize -0.009E-6143 -1e-6143 -> -0E-6143 Inexact Rounded
-dqqua738 quantize -0.001E-6143 -0e-6143 -> -0E-6143 Inexact Rounded
-dqqua739 quantize -0.0001E-6143 0e-6143 -> -0E-6143 Inexact Rounded
-
-dqqua740 quantize -1.00E-6143 1e-6144 -> -1.0E-6143 Rounded
-dqqua741 quantize -0.1E-6143 1e-6144 -> -1E-6144 Subnormal
-dqqua742 quantize -0.10E-6143 1e-6144 -> -1E-6144 Subnormal Rounded
-dqqua743 quantize -0.100E-6143 1e-6144 -> -1E-6144 Subnormal Rounded
-dqqua744 quantize -0.01E-6143 1e-6144 -> -0E-6144 Inexact Rounded
--- next is rounded to Emin
-dqqua745 quantize -0.999E-6143 1e-6144 -> -1.0E-6143 Inexact Rounded
-dqqua746 quantize -0.099E-6143 1e-6144 -> -1E-6144 Inexact Rounded Subnormal
-dqqua747 quantize -0.009E-6143 1e-6144 -> -0E-6144 Inexact Rounded
-dqqua748 quantize -0.001E-6143 1e-6144 -> -0E-6144 Inexact Rounded
-dqqua749 quantize -0.0001E-6143 1e-6144 -> -0E-6144 Inexact Rounded
-
-dqqua750 quantize -1.00E-6143 1e-6145 -> -1.00E-6143
-dqqua751 quantize -0.1E-6143 1e-6145 -> -1.0E-6144 Subnormal
-dqqua752 quantize -0.10E-6143 1e-6145 -> -1.0E-6144 Subnormal
-dqqua753 quantize -0.100E-6143 1e-6145 -> -1.0E-6144 Subnormal Rounded
-dqqua754 quantize -0.01E-6143 1e-6145 -> -1E-6145 Subnormal
--- next is rounded to Emin
-dqqua755 quantize -0.999E-6143 1e-6145 -> -1.00E-6143 Inexact Rounded
-dqqua756 quantize -0.099E-6143 1e-6145 -> -1.0E-6144 Inexact Rounded Subnormal
-dqqua757 quantize -0.009E-6143 1e-6145 -> -1E-6145 Inexact Rounded Subnormal
-dqqua758 quantize -0.001E-6143 1e-6145 -> -0E-6145 Inexact Rounded
-dqqua759 quantize -0.0001E-6143 1e-6145 -> -0E-6145 Inexact Rounded
-
-dqqua760 quantize -1.00E-6143 1e-6146 -> -1.000E-6143
-dqqua761 quantize -0.1E-6143 1e-6146 -> -1.00E-6144 Subnormal
-dqqua762 quantize -0.10E-6143 1e-6146 -> -1.00E-6144 Subnormal
-dqqua763 quantize -0.100E-6143 1e-6146 -> -1.00E-6144 Subnormal
-dqqua764 quantize -0.01E-6143 1e-6146 -> -1.0E-6145 Subnormal
-dqqua765 quantize -0.999E-6143 1e-6146 -> -9.99E-6144 Subnormal
-dqqua766 quantize -0.099E-6143 1e-6146 -> -9.9E-6145 Subnormal
-dqqua767 quantize -0.009E-6143 1e-6146 -> -9E-6146 Subnormal
-dqqua768 quantize -0.001E-6143 1e-6146 -> -1E-6146 Subnormal
-dqqua769 quantize -0.0001E-6143 1e-6146 -> -0E-6146 Inexact Rounded
-
--- More from Fung Lee
--- the next four would appear to be in error, but they are misleading (the
--- operands will be clamped to a lower exponent) and so are omitted
--- dqqua1021 quantize 8.666666666666000E+6144 1.000000000000000E+6144 -> 8.666666666666000000000000000000000E+6144 Clamped
--- dqqua1022 quantize -8.666666666666000E+6144 1.000000000000000E+6144 -> -8.666666666666000000000000000000000E+6144 Clamped
--- dqqua1027 quantize 8.666666666666000E+323 1E+31 -> NaN Invalid_operation
--- dqqua1030 quantize 8.66666666E+3 1E+3 -> 9E+3 Inexact Rounded
-
--- Int and uInt32 edge values for testing conversions
-dqqua1040 quantize -2147483646 0 -> -2147483646
-dqqua1041 quantize -2147483647 0 -> -2147483647
-dqqua1042 quantize -2147483648 0 -> -2147483648
-dqqua1043 quantize -2147483649 0 -> -2147483649
-dqqua1044 quantize 2147483646 0 -> 2147483646
-dqqua1045 quantize 2147483647 0 -> 2147483647
-dqqua1046 quantize 2147483648 0 -> 2147483648
-dqqua1047 quantize 2147483649 0 -> 2147483649
-dqqua1048 quantize 4294967294 0 -> 4294967294
-dqqua1049 quantize 4294967295 0 -> 4294967295
-dqqua1050 quantize 4294967296 0 -> 4294967296
-dqqua1051 quantize 4294967297 0 -> 4294967297
-
--- Rounding swathe
-rounding: half_even
-dqqua1100 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1101 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1102 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1103 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-dqqua1104 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1105 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua1106 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1107 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1108 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1109 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: half_up
-dqqua1200 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1201 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1202 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1203 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-dqqua1204 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1205 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-dqqua1206 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1207 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1208 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1209 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: half_down
-dqqua1300 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1301 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1302 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1303 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-dqqua1304 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1305 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua1306 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1307 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1308 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1309 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: up
-dqqua1400 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1401 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
-dqqua1402 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
-dqqua1403 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-dqqua1404 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1405 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-dqqua1406 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1407 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1408 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1409 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-dqqua1411 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
-
-rounding: down
-dqqua1500 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1501 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1502 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1503 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-dqqua1504 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
-dqqua1505 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua1506 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-dqqua1507 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
-dqqua1508 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
-dqqua1509 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
-dqqua1511 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
-
-rounding: ceiling
-dqqua1600 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1601 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
-dqqua1602 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
-dqqua1603 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-dqqua1604 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1605 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-dqqua1606 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1607 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1608 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1609 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-dqqua1611 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
-
-rounding: floor
-dqqua1700 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1701 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1702 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1703 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-dqqua1704 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
-dqqua1705 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua1706 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-dqqua1707 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
-dqqua1708 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
-dqqua1709 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
-dqqua1711 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
-
-rounding: 05up
-dqqua1800 quantize 1.2000 1.00 -> 1.20 Rounded
-dqqua1801 quantize 1.2001 1.00 -> 1.21 Inexact Rounded
-dqqua1802 quantize 1.2010 1.00 -> 1.21 Inexact Rounded
-dqqua1803 quantize 1.2050 1.00 -> 1.21 Inexact Rounded
-dqqua1804 quantize 1.2051 1.00 -> 1.21 Inexact Rounded
-dqqua1807 quantize 1.2060 1.00 -> 1.21 Inexact Rounded
-dqqua1808 quantize 1.2070 1.00 -> 1.21 Inexact Rounded
-dqqua1809 quantize 1.2099 1.00 -> 1.21 Inexact Rounded
-dqqua1811 quantize -1.2099 1.00 -> -1.21 Inexact Rounded
-
-dqqua1900 quantize 1.2100 1.00 -> 1.21 Rounded
-dqqua1901 quantize 1.2101 1.00 -> 1.21 Inexact Rounded
-dqqua1902 quantize 1.2110 1.00 -> 1.21 Inexact Rounded
-dqqua1903 quantize 1.2150 1.00 -> 1.21 Inexact Rounded
-dqqua1904 quantize 1.2151 1.00 -> 1.21 Inexact Rounded
-dqqua1907 quantize 1.2160 1.00 -> 1.21 Inexact Rounded
-dqqua1908 quantize 1.2170 1.00 -> 1.21 Inexact Rounded
-dqqua1909 quantize 1.2199 1.00 -> 1.21 Inexact Rounded
-dqqua1911 quantize -1.2199 1.00 -> -1.21 Inexact Rounded
-
-dqqua2000 quantize 1.2400 1.00 -> 1.24 Rounded
-dqqua2001 quantize 1.2401 1.00 -> 1.24 Inexact Rounded
-dqqua2002 quantize 1.2410 1.00 -> 1.24 Inexact Rounded
-dqqua2003 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua2004 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-dqqua2007 quantize 1.2460 1.00 -> 1.24 Inexact Rounded
-dqqua2008 quantize 1.2470 1.00 -> 1.24 Inexact Rounded
-dqqua2009 quantize 1.2499 1.00 -> 1.24 Inexact Rounded
-dqqua2011 quantize -1.2499 1.00 -> -1.24 Inexact Rounded
-
-dqqua2100 quantize 1.2500 1.00 -> 1.25 Rounded
-dqqua2101 quantize 1.2501 1.00 -> 1.26 Inexact Rounded
-dqqua2102 quantize 1.2510 1.00 -> 1.26 Inexact Rounded
-dqqua2103 quantize 1.2550 1.00 -> 1.26 Inexact Rounded
-dqqua2104 quantize 1.2551 1.00 -> 1.26 Inexact Rounded
-dqqua2107 quantize 1.2560 1.00 -> 1.26 Inexact Rounded
-dqqua2108 quantize 1.2570 1.00 -> 1.26 Inexact Rounded
-dqqua2109 quantize 1.2599 1.00 -> 1.26 Inexact Rounded
-dqqua2111 quantize -1.2599 1.00 -> -1.26 Inexact Rounded
-
-dqqua2200 quantize 1.2600 1.00 -> 1.26 Rounded
-dqqua2201 quantize 1.2601 1.00 -> 1.26 Inexact Rounded
-dqqua2202 quantize 1.2610 1.00 -> 1.26 Inexact Rounded
-dqqua2203 quantize 1.2650 1.00 -> 1.26 Inexact Rounded
-dqqua2204 quantize 1.2651 1.00 -> 1.26 Inexact Rounded
-dqqua2207 quantize 1.2660 1.00 -> 1.26 Inexact Rounded
-dqqua2208 quantize 1.2670 1.00 -> 1.26 Inexact Rounded
-dqqua2209 quantize 1.2699 1.00 -> 1.26 Inexact Rounded
-dqqua2211 quantize -1.2699 1.00 -> -1.26 Inexact Rounded
-
-dqqua2300 quantize 1.2900 1.00 -> 1.29 Rounded
-dqqua2301 quantize 1.2901 1.00 -> 1.29 Inexact Rounded
-dqqua2302 quantize 1.2910 1.00 -> 1.29 Inexact Rounded
-dqqua2303 quantize 1.2950 1.00 -> 1.29 Inexact Rounded
-dqqua2304 quantize 1.2951 1.00 -> 1.29 Inexact Rounded
-dqqua2307 quantize 1.2960 1.00 -> 1.29 Inexact Rounded
-dqqua2308 quantize 1.2970 1.00 -> 1.29 Inexact Rounded
-dqqua2309 quantize 1.2999 1.00 -> 1.29 Inexact Rounded
-dqqua2311 quantize -1.2999 1.00 -> -1.29 Inexact Rounded
-
--- Null tests
-dqqua998 quantize 10 # -> NaN Invalid_operation
-dqqua999 quantize # 1e10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqQuantize.decTest -- decQuad quantize operation --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Most of the tests here assume a "regular pattern", where the
+-- sign and coefficient are +1.
+-- 2004.03.15 Underflow for quantize is suppressed
+-- 2005.06.08 More extensive tests for 'does not fit'
+-- [Forked from quantize.decTest 2006.11.25]
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqqua001 quantize 0 1e0 -> 0
+dqqua002 quantize 1 1e0 -> 1
+dqqua003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded
+dqqua005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded
+dqqua006 quantize 0.1 1e0 -> 0 Inexact Rounded
+dqqua007 quantize 0.1 1e-1 -> 0.1
+dqqua008 quantize 0.1 1e-2 -> 0.10
+dqqua009 quantize 0.1 1e-3 -> 0.100
+dqqua010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded
+dqqua011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded
+dqqua012 quantize 0.9 1e+0 -> 1 Inexact Rounded
+dqqua013 quantize 0.9 1e-1 -> 0.9
+dqqua014 quantize 0.9 1e-2 -> 0.90
+dqqua015 quantize 0.9 1e-3 -> 0.900
+-- negatives
+dqqua021 quantize -0 1e0 -> -0
+dqqua022 quantize -1 1e0 -> -1
+dqqua023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded
+dqqua025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded
+dqqua026 quantize -0.1 1e0 -> -0 Inexact Rounded
+dqqua027 quantize -0.1 1e-1 -> -0.1
+dqqua028 quantize -0.1 1e-2 -> -0.10
+dqqua029 quantize -0.1 1e-3 -> -0.100
+dqqua030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
+dqqua031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
+dqqua032 quantize -0.9 1e+0 -> -1 Inexact Rounded
+dqqua033 quantize -0.9 1e-1 -> -0.9
+dqqua034 quantize -0.9 1e-2 -> -0.90
+dqqua035 quantize -0.9 1e-3 -> -0.900
+dqqua036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded
+dqqua037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded
+dqqua038 quantize -0.5 1e+0 -> -0 Inexact Rounded
+dqqua039 quantize -0.5 1e-1 -> -0.5
+dqqua040 quantize -0.5 1e-2 -> -0.50
+dqqua041 quantize -0.5 1e-3 -> -0.500
+dqqua042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
+dqqua043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
+dqqua044 quantize -0.9 1e+0 -> -1 Inexact Rounded
+dqqua045 quantize -0.9 1e-1 -> -0.9
+dqqua046 quantize -0.9 1e-2 -> -0.90
+dqqua047 quantize -0.9 1e-3 -> -0.900
+
+-- examples from Specification
+dqqua060 quantize 2.17 0.001 -> 2.170
+dqqua061 quantize 2.17 0.01 -> 2.17
+dqqua062 quantize 2.17 0.1 -> 2.2 Inexact Rounded
+dqqua063 quantize 2.17 1e+0 -> 2 Inexact Rounded
+dqqua064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded
+dqqua065 quantize -Inf Inf -> -Infinity
+dqqua066 quantize 2 Inf -> NaN Invalid_operation
+dqqua067 quantize -0.1 1 -> -0 Inexact Rounded
+dqqua068 quantize -0 1e+5 -> -0E+5
+dqqua069 quantize +123451234567899876543216789012345.6 1e-2 -> NaN Invalid_operation
+dqqua070 quantize -987651234567899876543214335236450.6 1e-2 -> NaN Invalid_operation
+dqqua071 quantize 217 1e-1 -> 217.0
+dqqua072 quantize 217 1e+0 -> 217
+dqqua073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded
+dqqua074 quantize 217 1e+2 -> 2E+2 Inexact Rounded
+
+-- general tests ..
+dqqua089 quantize 12 1e+4 -> 0E+4 Inexact Rounded
+dqqua090 quantize 12 1e+3 -> 0E+3 Inexact Rounded
+dqqua091 quantize 12 1e+2 -> 0E+2 Inexact Rounded
+dqqua092 quantize 12 1e+1 -> 1E+1 Inexact Rounded
+dqqua093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded
+dqqua094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded
+dqqua095 quantize 1.2345 1e-6 -> 1.234500
+dqqua096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded
+dqqua097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded
+dqqua098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded
+dqqua099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded
+dqqua100 quantize 92 1e+2 -> 1E+2 Inexact Rounded
+
+dqqua101 quantize -1 1e0 -> -1
+dqqua102 quantize -1 1e-1 -> -1.0
+dqqua103 quantize -1 1e-2 -> -1.00
+dqqua104 quantize 0 1e0 -> 0
+dqqua105 quantize 0 1e-1 -> 0.0
+dqqua106 quantize 0 1e-2 -> 0.00
+dqqua107 quantize 0.00 1e0 -> 0
+dqqua108 quantize 0 1e+1 -> 0E+1
+dqqua109 quantize 0 1e+2 -> 0E+2
+dqqua110 quantize +1 1e0 -> 1
+dqqua111 quantize +1 1e-1 -> 1.0
+dqqua112 quantize +1 1e-2 -> 1.00
+
+dqqua120 quantize 1.04 1e-3 -> 1.040
+dqqua121 quantize 1.04 1e-2 -> 1.04
+dqqua122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded
+dqqua123 quantize 1.04 1e0 -> 1 Inexact Rounded
+dqqua124 quantize 1.05 1e-3 -> 1.050
+dqqua125 quantize 1.05 1e-2 -> 1.05
+dqqua126 quantize 1.05 1e-1 -> 1.0 Inexact Rounded
+dqqua131 quantize 1.05 1e0 -> 1 Inexact Rounded
+dqqua132 quantize 1.06 1e-3 -> 1.060
+dqqua133 quantize 1.06 1e-2 -> 1.06
+dqqua134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded
+dqqua135 quantize 1.06 1e0 -> 1 Inexact Rounded
+
+dqqua140 quantize -10 1e-2 -> -10.00
+dqqua141 quantize +1 1e-2 -> 1.00
+dqqua142 quantize +10 1e-2 -> 10.00
+dqqua143 quantize 1E+37 1e-2 -> NaN Invalid_operation
+dqqua144 quantize 1E-37 1e-2 -> 0.00 Inexact Rounded
+dqqua145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded
+dqqua146 quantize 1E-2 1e-2 -> 0.01
+dqqua147 quantize 1E-1 1e-2 -> 0.10
+dqqua148 quantize 0E-37 1e-2 -> 0.00
+
+dqqua150 quantize 1.0600 1e-5 -> 1.06000
+dqqua151 quantize 1.0600 1e-4 -> 1.0600
+dqqua152 quantize 1.0600 1e-3 -> 1.060 Rounded
+dqqua153 quantize 1.0600 1e-2 -> 1.06 Rounded
+dqqua154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded
+dqqua155 quantize 1.0600 1e0 -> 1 Inexact Rounded
+
+-- a couple where rounding was different in base tests
+rounding: half_up
+dqqua157 quantize -0.5 1e+0 -> -1 Inexact Rounded
+dqqua158 quantize 1.05 1e-1 -> 1.1 Inexact Rounded
+dqqua159 quantize 1.06 1e0 -> 1 Inexact Rounded
+rounding: half_even
+
+-- base tests with non-1 coefficients
+dqqua161 quantize 0 -9e0 -> 0
+dqqua162 quantize 1 -7e0 -> 1
+dqqua163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded
+dqqua165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded
+dqqua166 quantize 0.1 2e0 -> 0 Inexact Rounded
+dqqua167 quantize 0.1 3e-1 -> 0.1
+dqqua168 quantize 0.1 44e-2 -> 0.10
+dqqua169 quantize 0.1 555e-3 -> 0.100
+dqqua170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded
+dqqua171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded
+dqqua172 quantize 0.9 -88e+0 -> 1 Inexact Rounded
+dqqua173 quantize 0.9 -9e-1 -> 0.9
+dqqua174 quantize 0.9 0e-2 -> 0.90
+dqqua175 quantize 0.9 1.1e-3 -> 0.9000
+-- negatives
+dqqua181 quantize -0 1.1e0 -> -0.0
+dqqua182 quantize -1 -1e0 -> -1
+dqqua183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded
+dqqua185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded
+dqqua186 quantize -0.1 71e0 -> -0 Inexact Rounded
+dqqua187 quantize -0.1 -91e-1 -> -0.1
+dqqua188 quantize -0.1 -.1e-2 -> -0.100
+dqqua189 quantize -0.1 -1e-3 -> -0.100
+dqqua190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded
+dqqua191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded
+dqqua192 quantize -0.9 -10e+0 -> -1 Inexact Rounded
+dqqua193 quantize -0.9 100e-1 -> -0.9
+dqqua194 quantize -0.9 999e-2 -> -0.90
+
+-- +ve exponents ..
+dqqua201 quantize -1 1e+0 -> -1
+dqqua202 quantize -1 1e+1 -> -0E+1 Inexact Rounded
+dqqua203 quantize -1 1e+2 -> -0E+2 Inexact Rounded
+dqqua204 quantize 0 1e+0 -> 0
+dqqua205 quantize 0 1e+1 -> 0E+1
+dqqua206 quantize 0 1e+2 -> 0E+2
+dqqua207 quantize +1 1e+0 -> 1
+dqqua208 quantize +1 1e+1 -> 0E+1 Inexact Rounded
+dqqua209 quantize +1 1e+2 -> 0E+2 Inexact Rounded
+
+dqqua220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded
+dqqua221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded
+dqqua222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded
+dqqua223 quantize 1.04 1e+0 -> 1 Inexact Rounded
+dqqua224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
+dqqua225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
+dqqua226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
+dqqua227 quantize 1.05 1e+0 -> 1 Inexact Rounded
+dqqua228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
+dqqua229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
+dqqua230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
+dqqua231 quantize 1.05 1e+0 -> 1 Inexact Rounded
+dqqua232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded
+dqqua233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded
+dqqua234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded
+dqqua235 quantize 1.06 1e+0 -> 1 Inexact Rounded
+
+dqqua240 quantize -10 1e+1 -> -1E+1 Rounded
+dqqua241 quantize +1 1e+1 -> 0E+1 Inexact Rounded
+dqqua242 quantize +10 1e+1 -> 1E+1 Rounded
+dqqua243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1
+dqqua244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1
+dqqua245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1
+dqqua246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1
+dqqua247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1
+dqqua248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1
+dqqua249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1
+dqqua250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1
+dqqua251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1
+-- next one tries to add 9 zeros
+dqqua252 quantize 1E+37 1e+1 -> NaN Invalid_operation
+dqqua253 quantize 1E-37 1e+1 -> 0E+1 Inexact Rounded
+dqqua254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded
+dqqua255 quantize 0E-37 1e+1 -> 0E+1
+dqqua256 quantize -0E-37 1e+1 -> -0E+1
+dqqua257 quantize -0E-1 1e+1 -> -0E+1
+dqqua258 quantize -0 1e+1 -> -0E+1
+dqqua259 quantize -0E+1 1e+1 -> -0E+1
+
+dqqua260 quantize -10 1e+2 -> -0E+2 Inexact Rounded
+dqqua261 quantize +1 1e+2 -> 0E+2 Inexact Rounded
+dqqua262 quantize +10 1e+2 -> 0E+2 Inexact Rounded
+dqqua263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded
+dqqua264 quantize 1E+2 1e+2 -> 1E+2
+dqqua265 quantize 1E+3 1e+2 -> 1.0E+3
+dqqua266 quantize 1E+4 1e+2 -> 1.00E+4
+dqqua267 quantize 1E+5 1e+2 -> 1.000E+5
+dqqua268 quantize 1E+6 1e+2 -> 1.0000E+6
+dqqua269 quantize 1E+7 1e+2 -> 1.00000E+7
+dqqua270 quantize 1E+8 1e+2 -> 1.000000E+8
+dqqua271 quantize 1E+9 1e+2 -> 1.0000000E+9
+dqqua272 quantize 1E+10 1e+2 -> 1.00000000E+10
+dqqua273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded
+dqqua274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded
+dqqua275 quantize 0E-10 1e+2 -> 0E+2
+
+dqqua280 quantize -10 1e+3 -> -0E+3 Inexact Rounded
+dqqua281 quantize +1 1e+3 -> 0E+3 Inexact Rounded
+dqqua282 quantize +10 1e+3 -> 0E+3 Inexact Rounded
+dqqua283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded
+dqqua284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded
+dqqua285 quantize 1E+3 1e+3 -> 1E+3
+dqqua286 quantize 1E+4 1e+3 -> 1.0E+4
+dqqua287 quantize 1E+5 1e+3 -> 1.00E+5
+dqqua288 quantize 1E+6 1e+3 -> 1.000E+6
+dqqua289 quantize 1E+7 1e+3 -> 1.0000E+7
+dqqua290 quantize 1E+8 1e+3 -> 1.00000E+8
+dqqua291 quantize 1E+9 1e+3 -> 1.000000E+9
+dqqua292 quantize 1E+10 1e+3 -> 1.0000000E+10
+dqqua293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded
+dqqua294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded
+dqqua295 quantize 0E-10 1e+3 -> 0E+3
+
+-- round up from below [sign wrong in JIT compiler once]
+dqqua300 quantize 0.0078 1e-5 -> 0.00780
+dqqua301 quantize 0.0078 1e-4 -> 0.0078
+dqqua302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded
+dqqua303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded
+dqqua304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded
+dqqua305 quantize 0.0078 1e0 -> 0 Inexact Rounded
+dqqua306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded
+dqqua307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded
+
+dqqua310 quantize -0.0078 1e-5 -> -0.00780
+dqqua311 quantize -0.0078 1e-4 -> -0.0078
+dqqua312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded
+dqqua313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded
+dqqua314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded
+dqqua315 quantize -0.0078 1e0 -> -0 Inexact Rounded
+dqqua316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded
+dqqua317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded
+
+dqqua320 quantize 0.078 1e-5 -> 0.07800
+dqqua321 quantize 0.078 1e-4 -> 0.0780
+dqqua322 quantize 0.078 1e-3 -> 0.078
+dqqua323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded
+dqqua324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded
+dqqua325 quantize 0.078 1e0 -> 0 Inexact Rounded
+dqqua326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded
+dqqua327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded
+
+dqqua330 quantize -0.078 1e-5 -> -0.07800
+dqqua331 quantize -0.078 1e-4 -> -0.0780
+dqqua332 quantize -0.078 1e-3 -> -0.078
+dqqua333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded
+dqqua334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded
+dqqua335 quantize -0.078 1e0 -> -0 Inexact Rounded
+dqqua336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded
+dqqua337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded
+
+dqqua340 quantize 0.78 1e-5 -> 0.78000
+dqqua341 quantize 0.78 1e-4 -> 0.7800
+dqqua342 quantize 0.78 1e-3 -> 0.780
+dqqua343 quantize 0.78 1e-2 -> 0.78
+dqqua344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded
+dqqua345 quantize 0.78 1e0 -> 1 Inexact Rounded
+dqqua346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded
+dqqua347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded
+
+dqqua350 quantize -0.78 1e-5 -> -0.78000
+dqqua351 quantize -0.78 1e-4 -> -0.7800
+dqqua352 quantize -0.78 1e-3 -> -0.780
+dqqua353 quantize -0.78 1e-2 -> -0.78
+dqqua354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded
+dqqua355 quantize -0.78 1e0 -> -1 Inexact Rounded
+dqqua356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded
+dqqua357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded
+
+dqqua360 quantize 7.8 1e-5 -> 7.80000
+dqqua361 quantize 7.8 1e-4 -> 7.8000
+dqqua362 quantize 7.8 1e-3 -> 7.800
+dqqua363 quantize 7.8 1e-2 -> 7.80
+dqqua364 quantize 7.8 1e-1 -> 7.8
+dqqua365 quantize 7.8 1e0 -> 8 Inexact Rounded
+dqqua366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded
+dqqua367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded
+dqqua368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded
+
+dqqua370 quantize -7.8 1e-5 -> -7.80000
+dqqua371 quantize -7.8 1e-4 -> -7.8000
+dqqua372 quantize -7.8 1e-3 -> -7.800
+dqqua373 quantize -7.8 1e-2 -> -7.80
+dqqua374 quantize -7.8 1e-1 -> -7.8
+dqqua375 quantize -7.8 1e0 -> -8 Inexact Rounded
+dqqua376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded
+dqqua377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded
+dqqua378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded
+
+-- some individuals
+dqqua380 quantize 1122334455667788991234567352364.506 1e-2 -> 1122334455667788991234567352364.51 Inexact Rounded
+dqqua381 quantize 11223344556677889912345673523645.06 1e-2 -> 11223344556677889912345673523645.06
+dqqua382 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
+dqqua383 quantize 1122334455667788991234567352364506 1e-2 -> NaN Invalid_operation
+dqqua384 quantize -1122334455667788991234567352364.506 1e-2 -> -1122334455667788991234567352364.51 Inexact Rounded
+dqqua385 quantize -11223344556677889912345673523645.06 1e-2 -> -11223344556677889912345673523645.06
+dqqua386 quantize -112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
+dqqua387 quantize -1122334455667788991234567352364506 1e-2 -> NaN Invalid_operation
+
+rounding: down
+dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
+rounding: half_up
+
+-- and a few more from e-mail discussions
+dqqua391 quantize 11223344556677889912345678912.34567 1e-3 -> 11223344556677889912345678912.346 Inexact Rounded
+dqqua392 quantize 112233445566778899123456789123.4567 1e-3 -> 112233445566778899123456789123.457 Inexact Rounded
+dqqua393 quantize 1122334455667788991234567891234567. 1e-3 -> NaN Invalid_operation
+
+-- some 9999 round-up cases
+dqqua400 quantize 9.999 1e-5 -> 9.99900
+dqqua401 quantize 9.999 1e-4 -> 9.9990
+dqqua402 quantize 9.999 1e-3 -> 9.999
+dqqua403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded
+dqqua404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded
+dqqua405 quantize 9.999 1e0 -> 10 Inexact Rounded
+dqqua406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded
+dqqua407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded
+
+dqqua410 quantize 0.999 1e-5 -> 0.99900
+dqqua411 quantize 0.999 1e-4 -> 0.9990
+dqqua412 quantize 0.999 1e-3 -> 0.999
+dqqua413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded
+dqqua414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded
+dqqua415 quantize 0.999 1e0 -> 1 Inexact Rounded
+dqqua416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded
+
+dqqua420 quantize 0.0999 1e-5 -> 0.09990
+dqqua421 quantize 0.0999 1e-4 -> 0.0999
+dqqua422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded
+dqqua423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded
+dqqua424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded
+dqqua425 quantize 0.0999 1e0 -> 0 Inexact Rounded
+dqqua426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded
+
+dqqua430 quantize 0.00999 1e-5 -> 0.00999
+dqqua431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded
+dqqua432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded
+dqqua433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded
+dqqua434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded
+dqqua435 quantize 0.00999 1e0 -> 0 Inexact Rounded
+dqqua436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded
+
+dqqua440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded
+dqqua441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded
+dqqua442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded
+dqqua443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded
+dqqua444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded
+dqqua445 quantize 0.000999 1e0 -> 0 Inexact Rounded
+dqqua446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded
+
+dqqua1001 quantize 0.000 0.001 -> 0.000
+dqqua1002 quantize 0.001 0.001 -> 0.001
+dqqua1003 quantize 0.0012 0.001 -> 0.001 Inexact Rounded
+dqqua1004 quantize 0.0018 0.001 -> 0.002 Inexact Rounded
+dqqua1005 quantize 0.501 0.001 -> 0.501
+dqqua1006 quantize 0.5012 0.001 -> 0.501 Inexact Rounded
+dqqua1007 quantize 0.5018 0.001 -> 0.502 Inexact Rounded
+dqqua1008 quantize 0.999 0.001 -> 0.999
+
+dqqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
+dqqua482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
+dqqua483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
+dqqua484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
+dqqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
+dqqua486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
+-- a potential double-round
+dqqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
+dqqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
+
+dqqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
+dqqua492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
+dqqua493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
+dqqua494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
+dqqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
+dqqua496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
+dqqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
+dqqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
+
+-- Zeros
+dqqua500 quantize 0 1e1 -> 0E+1
+dqqua501 quantize 0 1e0 -> 0
+dqqua502 quantize 0 1e-1 -> 0.0
+dqqua503 quantize 0.0 1e-1 -> 0.0
+dqqua504 quantize 0.0 1e0 -> 0
+dqqua505 quantize 0.0 1e+1 -> 0E+1
+dqqua506 quantize 0E+1 1e-1 -> 0.0
+dqqua507 quantize 0E+1 1e0 -> 0
+dqqua508 quantize 0E+1 1e+1 -> 0E+1
+dqqua509 quantize -0 1e1 -> -0E+1
+dqqua510 quantize -0 1e0 -> -0
+dqqua511 quantize -0 1e-1 -> -0.0
+dqqua512 quantize -0.0 1e-1 -> -0.0
+dqqua513 quantize -0.0 1e0 -> -0
+dqqua514 quantize -0.0 1e+1 -> -0E+1
+dqqua515 quantize -0E+1 1e-1 -> -0.0
+dqqua516 quantize -0E+1 1e0 -> -0
+dqqua517 quantize -0E+1 1e+1 -> -0E+1
+-- #519 here once a problem
+dqqua518 quantize 0 0E-3 -> 0.000
+dqqua519 quantize 0 0E-33 -> 0E-33
+dqqua520 quantize 0.00000000000000000000000000000000 0E-33 -> 0E-33
+dqqua521 quantize 0.000000000000000000000000000000000 0E-33 -> 0E-33
+
+-- Some non-zeros with lots of padding on the right
+dqqua523 quantize 1 0E-33 -> 1.000000000000000000000000000000000
+dqqua524 quantize 12 0E-32 -> 12.00000000000000000000000000000000
+dqqua525 quantize 123 0E-31 -> 123.0000000000000000000000000000000
+dqqua526 quantize 123 0E-32 -> NaN Invalid_operation
+dqqua527 quantize 123.4 0E-31 -> 123.4000000000000000000000000000000
+dqqua528 quantize 123.4 0E-32 -> NaN Invalid_operation
+
+-- Suspicious RHS values
+dqqua530 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
+dqqua531 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
+dqqua532 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
+dqqua533 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
+-- next four are "won't fit" overflows
+dqqua536 quantize 1.234 1e-299 -> NaN Invalid_operation
+dqqua537 quantize 123.456 1e-299 -> NaN Invalid_operation
+dqqua538 quantize 1.234 1e-299 -> NaN Invalid_operation
+dqqua539 quantize 123.456 1e-299 -> NaN Invalid_operation
+
+dqqua542 quantize 1.234E+299 1e299 -> 1E+299 Inexact Rounded
+dqqua543 quantize 1.234E+298 1e299 -> 0E+299 Inexact Rounded
+dqqua544 quantize 1.234 1e299 -> 0E+299 Inexact Rounded
+dqqua547 quantize 0 1e-299 -> 0E-299
+-- next two are "won't fit" overflows
+dqqua548 quantize 1.234 1e-299 -> NaN Invalid_operation
+dqqua549 quantize 1.234 1e-300 -> NaN Invalid_operation
+-- [more below]
+
+-- Specials
+dqqua580 quantize Inf -Inf -> Infinity
+dqqua581 quantize Inf 1e-299 -> NaN Invalid_operation
+dqqua582 quantize Inf 1e-1 -> NaN Invalid_operation
+dqqua583 quantize Inf 1e0 -> NaN Invalid_operation
+dqqua584 quantize Inf 1e1 -> NaN Invalid_operation
+dqqua585 quantize Inf 1e299 -> NaN Invalid_operation
+dqqua586 quantize Inf Inf -> Infinity
+dqqua587 quantize -1000 Inf -> NaN Invalid_operation
+dqqua588 quantize -Inf Inf -> -Infinity
+dqqua589 quantize -1 Inf -> NaN Invalid_operation
+dqqua590 quantize 0 Inf -> NaN Invalid_operation
+dqqua591 quantize 1 Inf -> NaN Invalid_operation
+dqqua592 quantize 1000 Inf -> NaN Invalid_operation
+dqqua593 quantize Inf Inf -> Infinity
+dqqua594 quantize Inf 1e-0 -> NaN Invalid_operation
+dqqua595 quantize -0 Inf -> NaN Invalid_operation
+
+dqqua600 quantize -Inf -Inf -> -Infinity
+dqqua601 quantize -Inf 1e-299 -> NaN Invalid_operation
+dqqua602 quantize -Inf 1e-1 -> NaN Invalid_operation
+dqqua603 quantize -Inf 1e0 -> NaN Invalid_operation
+dqqua604 quantize -Inf 1e1 -> NaN Invalid_operation
+dqqua605 quantize -Inf 1e299 -> NaN Invalid_operation
+dqqua606 quantize -Inf Inf -> -Infinity
+dqqua607 quantize -1000 Inf -> NaN Invalid_operation
+dqqua608 quantize -Inf -Inf -> -Infinity
+dqqua609 quantize -1 -Inf -> NaN Invalid_operation
+dqqua610 quantize 0 -Inf -> NaN Invalid_operation
+dqqua611 quantize 1 -Inf -> NaN Invalid_operation
+dqqua612 quantize 1000 -Inf -> NaN Invalid_operation
+dqqua613 quantize Inf -Inf -> Infinity
+dqqua614 quantize -Inf 1e-0 -> NaN Invalid_operation
+dqqua615 quantize -0 -Inf -> NaN Invalid_operation
+
+dqqua621 quantize NaN -Inf -> NaN
+dqqua622 quantize NaN 1e-299 -> NaN
+dqqua623 quantize NaN 1e-1 -> NaN
+dqqua624 quantize NaN 1e0 -> NaN
+dqqua625 quantize NaN 1e1 -> NaN
+dqqua626 quantize NaN 1e299 -> NaN
+dqqua627 quantize NaN Inf -> NaN
+dqqua628 quantize NaN NaN -> NaN
+dqqua629 quantize -Inf NaN -> NaN
+dqqua630 quantize -1000 NaN -> NaN
+dqqua631 quantize -1 NaN -> NaN
+dqqua632 quantize 0 NaN -> NaN
+dqqua633 quantize 1 NaN -> NaN
+dqqua634 quantize 1000 NaN -> NaN
+dqqua635 quantize Inf NaN -> NaN
+dqqua636 quantize NaN 1e-0 -> NaN
+dqqua637 quantize -0 NaN -> NaN
+
+dqqua641 quantize sNaN -Inf -> NaN Invalid_operation
+dqqua642 quantize sNaN 1e-299 -> NaN Invalid_operation
+dqqua643 quantize sNaN 1e-1 -> NaN Invalid_operation
+dqqua644 quantize sNaN 1e0 -> NaN Invalid_operation
+dqqua645 quantize sNaN 1e1 -> NaN Invalid_operation
+dqqua646 quantize sNaN 1e299 -> NaN Invalid_operation
+dqqua647 quantize sNaN NaN -> NaN Invalid_operation
+dqqua648 quantize sNaN sNaN -> NaN Invalid_operation
+dqqua649 quantize NaN sNaN -> NaN Invalid_operation
+dqqua650 quantize -Inf sNaN -> NaN Invalid_operation
+dqqua651 quantize -1000 sNaN -> NaN Invalid_operation
+dqqua652 quantize -1 sNaN -> NaN Invalid_operation
+dqqua653 quantize 0 sNaN -> NaN Invalid_operation
+dqqua654 quantize 1 sNaN -> NaN Invalid_operation
+dqqua655 quantize 1000 sNaN -> NaN Invalid_operation
+dqqua656 quantize Inf sNaN -> NaN Invalid_operation
+dqqua657 quantize NaN sNaN -> NaN Invalid_operation
+dqqua658 quantize sNaN 1e-0 -> NaN Invalid_operation
+dqqua659 quantize -0 sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqqua661 quantize NaN9 -Inf -> NaN9
+dqqua662 quantize NaN8 919 -> NaN8
+dqqua663 quantize NaN71 Inf -> NaN71
+dqqua664 quantize NaN6 NaN5 -> NaN6
+dqqua665 quantize -Inf NaN4 -> NaN4
+dqqua666 quantize -919 NaN31 -> NaN31
+dqqua667 quantize Inf NaN2 -> NaN2
+
+dqqua671 quantize sNaN99 -Inf -> NaN99 Invalid_operation
+dqqua672 quantize sNaN98 -11 -> NaN98 Invalid_operation
+dqqua673 quantize sNaN97 NaN -> NaN97 Invalid_operation
+dqqua674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation
+dqqua675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation
+dqqua676 quantize -Inf sNaN92 -> NaN92 Invalid_operation
+dqqua677 quantize 088 sNaN91 -> NaN91 Invalid_operation
+dqqua678 quantize Inf sNaN90 -> NaN90 Invalid_operation
+dqqua679 quantize NaN sNaN88 -> NaN88 Invalid_operation
+
+dqqua681 quantize -NaN9 -Inf -> -NaN9
+dqqua682 quantize -NaN8 919 -> -NaN8
+dqqua683 quantize -NaN71 Inf -> -NaN71
+dqqua684 quantize -NaN6 -NaN5 -> -NaN6
+dqqua685 quantize -Inf -NaN4 -> -NaN4
+dqqua686 quantize -919 -NaN31 -> -NaN31
+dqqua687 quantize Inf -NaN2 -> -NaN2
+
+dqqua691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqqua692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation
+dqqua693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation
+dqqua694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation
+dqqua695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+dqqua696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation
+dqqua697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation
+dqqua698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation
+dqqua699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation
+
+-- subnormals and underflow
+dqqua710 quantize 1.00E-6143 1e-6143 -> 1E-6143 Rounded
+dqqua711 quantize 0.1E-6143 2e-6144 -> 1E-6144 Subnormal
+dqqua712 quantize 0.10E-6143 3e-6144 -> 1E-6144 Subnormal Rounded
+dqqua713 quantize 0.100E-6143 4e-6144 -> 1E-6144 Subnormal Rounded
+dqqua714 quantize 0.01E-6143 5e-6145 -> 1E-6145 Subnormal
+-- next is rounded to Emin
+dqqua715 quantize 0.999E-6143 1e-6143 -> 1E-6143 Inexact Rounded
+dqqua716 quantize 0.099E-6143 10e-6144 -> 1E-6144 Inexact Rounded Subnormal
+
+dqqua717 quantize 0.009E-6143 1e-6145 -> 1E-6145 Inexact Rounded Subnormal
+dqqua718 quantize 0.001E-6143 1e-6145 -> 0E-6145 Inexact Rounded
+dqqua719 quantize 0.0009E-6143 1e-6145 -> 0E-6145 Inexact Rounded
+dqqua720 quantize 0.0001E-6143 1e-6145 -> 0E-6145 Inexact Rounded
+
+dqqua730 quantize -1.00E-6143 1e-6143 -> -1E-6143 Rounded
+dqqua731 quantize -0.1E-6143 1e-6143 -> -0E-6143 Rounded Inexact
+dqqua732 quantize -0.10E-6143 1e-6143 -> -0E-6143 Rounded Inexact
+dqqua733 quantize -0.100E-6143 1e-6143 -> -0E-6143 Rounded Inexact
+dqqua734 quantize -0.01E-6143 1e-6143 -> -0E-6143 Inexact Rounded
+-- next is rounded to Emin
+dqqua735 quantize -0.999E-6143 90e-6143 -> -1E-6143 Inexact Rounded
+dqqua736 quantize -0.099E-6143 -1e-6143 -> -0E-6143 Inexact Rounded
+dqqua737 quantize -0.009E-6143 -1e-6143 -> -0E-6143 Inexact Rounded
+dqqua738 quantize -0.001E-6143 -0e-6143 -> -0E-6143 Inexact Rounded
+dqqua739 quantize -0.0001E-6143 0e-6143 -> -0E-6143 Inexact Rounded
+
+dqqua740 quantize -1.00E-6143 1e-6144 -> -1.0E-6143 Rounded
+dqqua741 quantize -0.1E-6143 1e-6144 -> -1E-6144 Subnormal
+dqqua742 quantize -0.10E-6143 1e-6144 -> -1E-6144 Subnormal Rounded
+dqqua743 quantize -0.100E-6143 1e-6144 -> -1E-6144 Subnormal Rounded
+dqqua744 quantize -0.01E-6143 1e-6144 -> -0E-6144 Inexact Rounded
+-- next is rounded to Emin
+dqqua745 quantize -0.999E-6143 1e-6144 -> -1.0E-6143 Inexact Rounded
+dqqua746 quantize -0.099E-6143 1e-6144 -> -1E-6144 Inexact Rounded Subnormal
+dqqua747 quantize -0.009E-6143 1e-6144 -> -0E-6144 Inexact Rounded
+dqqua748 quantize -0.001E-6143 1e-6144 -> -0E-6144 Inexact Rounded
+dqqua749 quantize -0.0001E-6143 1e-6144 -> -0E-6144 Inexact Rounded
+
+dqqua750 quantize -1.00E-6143 1e-6145 -> -1.00E-6143
+dqqua751 quantize -0.1E-6143 1e-6145 -> -1.0E-6144 Subnormal
+dqqua752 quantize -0.10E-6143 1e-6145 -> -1.0E-6144 Subnormal
+dqqua753 quantize -0.100E-6143 1e-6145 -> -1.0E-6144 Subnormal Rounded
+dqqua754 quantize -0.01E-6143 1e-6145 -> -1E-6145 Subnormal
+-- next is rounded to Emin
+dqqua755 quantize -0.999E-6143 1e-6145 -> -1.00E-6143 Inexact Rounded
+dqqua756 quantize -0.099E-6143 1e-6145 -> -1.0E-6144 Inexact Rounded Subnormal
+dqqua757 quantize -0.009E-6143 1e-6145 -> -1E-6145 Inexact Rounded Subnormal
+dqqua758 quantize -0.001E-6143 1e-6145 -> -0E-6145 Inexact Rounded
+dqqua759 quantize -0.0001E-6143 1e-6145 -> -0E-6145 Inexact Rounded
+
+dqqua760 quantize -1.00E-6143 1e-6146 -> -1.000E-6143
+dqqua761 quantize -0.1E-6143 1e-6146 -> -1.00E-6144 Subnormal
+dqqua762 quantize -0.10E-6143 1e-6146 -> -1.00E-6144 Subnormal
+dqqua763 quantize -0.100E-6143 1e-6146 -> -1.00E-6144 Subnormal
+dqqua764 quantize -0.01E-6143 1e-6146 -> -1.0E-6145 Subnormal
+dqqua765 quantize -0.999E-6143 1e-6146 -> -9.99E-6144 Subnormal
+dqqua766 quantize -0.099E-6143 1e-6146 -> -9.9E-6145 Subnormal
+dqqua767 quantize -0.009E-6143 1e-6146 -> -9E-6146 Subnormal
+dqqua768 quantize -0.001E-6143 1e-6146 -> -1E-6146 Subnormal
+dqqua769 quantize -0.0001E-6143 1e-6146 -> -0E-6146 Inexact Rounded
+
+-- More from Fung Lee
+-- the next four would appear to be in error, but they are misleading (the
+-- operands will be clamped to a lower exponent) and so are omitted
+-- dqqua1021 quantize 8.666666666666000E+6144 1.000000000000000E+6144 -> 8.666666666666000000000000000000000E+6144 Clamped
+-- dqqua1022 quantize -8.666666666666000E+6144 1.000000000000000E+6144 -> -8.666666666666000000000000000000000E+6144 Clamped
+-- dqqua1027 quantize 8.666666666666000E+323 1E+31 -> NaN Invalid_operation
+-- dqqua1030 quantize 8.66666666E+3 1E+3 -> 9E+3 Inexact Rounded
+
+-- Int and uInt32 edge values for testing conversions
+dqqua1040 quantize -2147483646 0 -> -2147483646
+dqqua1041 quantize -2147483647 0 -> -2147483647
+dqqua1042 quantize -2147483648 0 -> -2147483648
+dqqua1043 quantize -2147483649 0 -> -2147483649
+dqqua1044 quantize 2147483646 0 -> 2147483646
+dqqua1045 quantize 2147483647 0 -> 2147483647
+dqqua1046 quantize 2147483648 0 -> 2147483648
+dqqua1047 quantize 2147483649 0 -> 2147483649
+dqqua1048 quantize 4294967294 0 -> 4294967294
+dqqua1049 quantize 4294967295 0 -> 4294967295
+dqqua1050 quantize 4294967296 0 -> 4294967296
+dqqua1051 quantize 4294967297 0 -> 4294967297
+
+-- Rounding swathe
+rounding: half_even
+dqqua1100 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1101 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1102 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1103 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+dqqua1104 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1105 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua1106 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1107 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1108 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1109 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: half_up
+dqqua1200 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1201 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1202 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1203 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+dqqua1204 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1205 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+dqqua1206 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1207 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1208 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1209 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: half_down
+dqqua1300 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1301 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1302 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1303 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+dqqua1304 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1305 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua1306 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1307 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1308 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1309 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: up
+dqqua1400 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1401 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
+dqqua1402 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
+dqqua1403 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+dqqua1404 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1405 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+dqqua1406 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1407 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1408 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1409 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+dqqua1411 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
+
+rounding: down
+dqqua1500 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1501 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1502 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1503 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+dqqua1504 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
+dqqua1505 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua1506 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+dqqua1507 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
+dqqua1508 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
+dqqua1509 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
+dqqua1511 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
+
+rounding: ceiling
+dqqua1600 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1601 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
+dqqua1602 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
+dqqua1603 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+dqqua1604 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1605 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+dqqua1606 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1607 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1608 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1609 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+dqqua1611 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
+
+rounding: floor
+dqqua1700 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1701 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1702 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1703 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+dqqua1704 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
+dqqua1705 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua1706 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+dqqua1707 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
+dqqua1708 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
+dqqua1709 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
+dqqua1711 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
+
+rounding: 05up
+dqqua1800 quantize 1.2000 1.00 -> 1.20 Rounded
+dqqua1801 quantize 1.2001 1.00 -> 1.21 Inexact Rounded
+dqqua1802 quantize 1.2010 1.00 -> 1.21 Inexact Rounded
+dqqua1803 quantize 1.2050 1.00 -> 1.21 Inexact Rounded
+dqqua1804 quantize 1.2051 1.00 -> 1.21 Inexact Rounded
+dqqua1807 quantize 1.2060 1.00 -> 1.21 Inexact Rounded
+dqqua1808 quantize 1.2070 1.00 -> 1.21 Inexact Rounded
+dqqua1809 quantize 1.2099 1.00 -> 1.21 Inexact Rounded
+dqqua1811 quantize -1.2099 1.00 -> -1.21 Inexact Rounded
+
+dqqua1900 quantize 1.2100 1.00 -> 1.21 Rounded
+dqqua1901 quantize 1.2101 1.00 -> 1.21 Inexact Rounded
+dqqua1902 quantize 1.2110 1.00 -> 1.21 Inexact Rounded
+dqqua1903 quantize 1.2150 1.00 -> 1.21 Inexact Rounded
+dqqua1904 quantize 1.2151 1.00 -> 1.21 Inexact Rounded
+dqqua1907 quantize 1.2160 1.00 -> 1.21 Inexact Rounded
+dqqua1908 quantize 1.2170 1.00 -> 1.21 Inexact Rounded
+dqqua1909 quantize 1.2199 1.00 -> 1.21 Inexact Rounded
+dqqua1911 quantize -1.2199 1.00 -> -1.21 Inexact Rounded
+
+dqqua2000 quantize 1.2400 1.00 -> 1.24 Rounded
+dqqua2001 quantize 1.2401 1.00 -> 1.24 Inexact Rounded
+dqqua2002 quantize 1.2410 1.00 -> 1.24 Inexact Rounded
+dqqua2003 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua2004 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+dqqua2007 quantize 1.2460 1.00 -> 1.24 Inexact Rounded
+dqqua2008 quantize 1.2470 1.00 -> 1.24 Inexact Rounded
+dqqua2009 quantize 1.2499 1.00 -> 1.24 Inexact Rounded
+dqqua2011 quantize -1.2499 1.00 -> -1.24 Inexact Rounded
+
+dqqua2100 quantize 1.2500 1.00 -> 1.25 Rounded
+dqqua2101 quantize 1.2501 1.00 -> 1.26 Inexact Rounded
+dqqua2102 quantize 1.2510 1.00 -> 1.26 Inexact Rounded
+dqqua2103 quantize 1.2550 1.00 -> 1.26 Inexact Rounded
+dqqua2104 quantize 1.2551 1.00 -> 1.26 Inexact Rounded
+dqqua2107 quantize 1.2560 1.00 -> 1.26 Inexact Rounded
+dqqua2108 quantize 1.2570 1.00 -> 1.26 Inexact Rounded
+dqqua2109 quantize 1.2599 1.00 -> 1.26 Inexact Rounded
+dqqua2111 quantize -1.2599 1.00 -> -1.26 Inexact Rounded
+
+dqqua2200 quantize 1.2600 1.00 -> 1.26 Rounded
+dqqua2201 quantize 1.2601 1.00 -> 1.26 Inexact Rounded
+dqqua2202 quantize 1.2610 1.00 -> 1.26 Inexact Rounded
+dqqua2203 quantize 1.2650 1.00 -> 1.26 Inexact Rounded
+dqqua2204 quantize 1.2651 1.00 -> 1.26 Inexact Rounded
+dqqua2207 quantize 1.2660 1.00 -> 1.26 Inexact Rounded
+dqqua2208 quantize 1.2670 1.00 -> 1.26 Inexact Rounded
+dqqua2209 quantize 1.2699 1.00 -> 1.26 Inexact Rounded
+dqqua2211 quantize -1.2699 1.00 -> -1.26 Inexact Rounded
+
+dqqua2300 quantize 1.2900 1.00 -> 1.29 Rounded
+dqqua2301 quantize 1.2901 1.00 -> 1.29 Inexact Rounded
+dqqua2302 quantize 1.2910 1.00 -> 1.29 Inexact Rounded
+dqqua2303 quantize 1.2950 1.00 -> 1.29 Inexact Rounded
+dqqua2304 quantize 1.2951 1.00 -> 1.29 Inexact Rounded
+dqqua2307 quantize 1.2960 1.00 -> 1.29 Inexact Rounded
+dqqua2308 quantize 1.2970 1.00 -> 1.29 Inexact Rounded
+dqqua2309 quantize 1.2999 1.00 -> 1.29 Inexact Rounded
+dqqua2311 quantize -1.2999 1.00 -> -1.29 Inexact Rounded
+
+-- Null tests
+dqqua998 quantize 10 # -> NaN Invalid_operation
+dqqua999 quantize # 1e10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqReduce.decTest b/Lib/test/decimaltestdata/dqReduce.decTest
index 5635e6b70f..236574f4c7 100644
--- a/Lib/test/decimaltestdata/dqReduce.decTest
+++ b/Lib/test/decimaltestdata/dqReduce.decTest
@@ -1,183 +1,183 @@
-------------------------------------------------------------------------
--- dqReduce.decTest -- remove trailing zeros from a decQuad --
--- Copyright (c) IBM Corporation, 2003, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqred001 reduce '1' -> '1'
-dqred002 reduce '-1' -> '-1'
-dqred003 reduce '1.00' -> '1'
-dqred004 reduce '-1.00' -> '-1'
-dqred005 reduce '0' -> '0'
-dqred006 reduce '0.00' -> '0'
-dqred007 reduce '00.0' -> '0'
-dqred008 reduce '00.00' -> '0'
-dqred009 reduce '00' -> '0'
-dqred010 reduce '0E+1' -> '0'
-dqred011 reduce '0E+5' -> '0'
-
-dqred012 reduce '-2' -> '-2'
-dqred013 reduce '2' -> '2'
-dqred014 reduce '-2.00' -> '-2'
-dqred015 reduce '2.00' -> '2'
-dqred016 reduce '-0' -> '-0'
-dqred017 reduce '-0.00' -> '-0'
-dqred018 reduce '-00.0' -> '-0'
-dqred019 reduce '-00.00' -> '-0'
-dqred020 reduce '-00' -> '-0'
-dqred021 reduce '-0E+5' -> '-0'
-dqred022 reduce '-0E+1' -> '-0'
-
-dqred030 reduce '+0.1' -> '0.1'
-dqred031 reduce '-0.1' -> '-0.1'
-dqred032 reduce '+0.01' -> '0.01'
-dqred033 reduce '-0.01' -> '-0.01'
-dqred034 reduce '+0.001' -> '0.001'
-dqred035 reduce '-0.001' -> '-0.001'
-dqred036 reduce '+0.000001' -> '0.000001'
-dqred037 reduce '-0.000001' -> '-0.000001'
-dqred038 reduce '+0.000000000001' -> '1E-12'
-dqred039 reduce '-0.000000000001' -> '-1E-12'
-
-dqred041 reduce 1.1 -> 1.1
-dqred042 reduce 1.10 -> 1.1
-dqred043 reduce 1.100 -> 1.1
-dqred044 reduce 1.110 -> 1.11
-dqred045 reduce -1.1 -> -1.1
-dqred046 reduce -1.10 -> -1.1
-dqred047 reduce -1.100 -> -1.1
-dqred048 reduce -1.110 -> -1.11
-dqred049 reduce 9.9 -> 9.9
-dqred050 reduce 9.90 -> 9.9
-dqred051 reduce 9.900 -> 9.9
-dqred052 reduce 9.990 -> 9.99
-dqred053 reduce -9.9 -> -9.9
-dqred054 reduce -9.90 -> -9.9
-dqred055 reduce -9.900 -> -9.9
-dqred056 reduce -9.990 -> -9.99
-
--- some trailing fractional zeros with zeros in units
-dqred060 reduce 10.0 -> 1E+1
-dqred061 reduce 10.00 -> 1E+1
-dqred062 reduce 100.0 -> 1E+2
-dqred063 reduce 100.00 -> 1E+2
-dqred064 reduce 1.1000E+3 -> 1.1E+3
-dqred065 reduce 1.10000E+3 -> 1.1E+3
-dqred066 reduce -10.0 -> -1E+1
-dqred067 reduce -10.00 -> -1E+1
-dqred068 reduce -100.0 -> -1E+2
-dqred069 reduce -100.00 -> -1E+2
-dqred070 reduce -1.1000E+3 -> -1.1E+3
-dqred071 reduce -1.10000E+3 -> -1.1E+3
-
--- some insignificant trailing zeros with positive exponent
-dqred080 reduce 10E+1 -> 1E+2
-dqred081 reduce 100E+1 -> 1E+3
-dqred082 reduce 1.0E+2 -> 1E+2
-dqred083 reduce 1.0E+3 -> 1E+3
-dqred084 reduce 1.1E+3 -> 1.1E+3
-dqred085 reduce 1.00E+3 -> 1E+3
-dqred086 reduce 1.10E+3 -> 1.1E+3
-dqred087 reduce -10E+1 -> -1E+2
-dqred088 reduce -100E+1 -> -1E+3
-dqred089 reduce -1.0E+2 -> -1E+2
-dqred090 reduce -1.0E+3 -> -1E+3
-dqred091 reduce -1.1E+3 -> -1.1E+3
-dqred092 reduce -1.00E+3 -> -1E+3
-dqred093 reduce -1.10E+3 -> -1.1E+3
-
--- some significant trailing zeros, were we to be trimming
-dqred100 reduce 11 -> 11
-dqred101 reduce 10 -> 1E+1
-dqred102 reduce 10. -> 1E+1
-dqred103 reduce 1.1E+1 -> 11
-dqred104 reduce 1.0E+1 -> 1E+1
-dqred105 reduce 1.10E+2 -> 1.1E+2
-dqred106 reduce 1.00E+2 -> 1E+2
-dqred107 reduce 1.100E+3 -> 1.1E+3
-dqred108 reduce 1.000E+3 -> 1E+3
-dqred109 reduce 1.000000E+6 -> 1E+6
-dqred110 reduce -11 -> -11
-dqred111 reduce -10 -> -1E+1
-dqred112 reduce -10. -> -1E+1
-dqred113 reduce -1.1E+1 -> -11
-dqred114 reduce -1.0E+1 -> -1E+1
-dqred115 reduce -1.10E+2 -> -1.1E+2
-dqred116 reduce -1.00E+2 -> -1E+2
-dqred117 reduce -1.100E+3 -> -1.1E+3
-dqred118 reduce -1.000E+3 -> -1E+3
-dqred119 reduce -1.00000E+5 -> -1E+5
-dqred120 reduce -1.000000E+6 -> -1E+6
-dqred121 reduce -10.00000E+6 -> -1E+7
-dqred122 reduce -100.0000E+6 -> -1E+8
-dqred123 reduce -1000.000E+6 -> -1E+9
-dqred124 reduce -10000.00E+6 -> -1E+10
-dqred125 reduce -100000.0E+6 -> -1E+11
-dqred126 reduce -1000000.E+6 -> -1E+12
-
--- examples from decArith
-dqred140 reduce '2.1' -> '2.1'
-dqred141 reduce '-2.0' -> '-2'
-dqred142 reduce '1.200' -> '1.2'
-dqred143 reduce '-120' -> '-1.2E+2'
-dqred144 reduce '120.00' -> '1.2E+2'
-dqred145 reduce '0.00' -> '0'
-
--- Nmax, Nmin, Ntiny
--- note origami effect on some of these
-dqred151 reduce 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqred152 reduce 9.999999999999999999999999000000000E+6140 -> 9.99999999999999999999999900000E+6140
-dqred153 reduce 9.999999999999999999999999999990000E+6144 -> 9.999999999999999999999999999990000E+6144
-dqred154 reduce 1E-6143 -> 1E-6143
-dqred155 reduce 1.000000000000000000000000000000000E-6143 -> 1E-6143
-dqred156 reduce 2.000E-6173 -> 2E-6173 Subnormal
-dqred157 reduce 1E-6176 -> 1E-6176 Subnormal
-
-dqred161 reduce -1E-6176 -> -1E-6176 Subnormal
-dqred162 reduce -2.000E-6173 -> -2E-6173 Subnormal
-dqred163 reduce -1.000000000000000000000000000000000E-6143 -> -1E-6143
-dqred164 reduce -1E-6143 -> -1E-6143
-dqred165 reduce -9.999999999999999999999999000000000E+6140 -> -9.99999999999999999999999900000E+6140
-dqred166 reduce -9.999999999999999999999999999990000E+6144 -> -9.999999999999999999999999999990000E+6144
-dqred167 reduce -9.999999999999999999999999999999990E+6144 -> -9.999999999999999999999999999999990E+6144
-dqred168 reduce -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqred169 reduce -9.999999999999999999999999999999990E+6144 -> -9.999999999999999999999999999999990E+6144
-
-
--- specials (reduce does not affect payload)
-dqred820 reduce 'Inf' -> 'Infinity'
-dqred821 reduce '-Inf' -> '-Infinity'
-dqred822 reduce NaN -> NaN
-dqred823 reduce sNaN -> NaN Invalid_operation
-dqred824 reduce NaN101 -> NaN101
-dqred825 reduce sNaN010 -> NaN10 Invalid_operation
-dqred827 reduce -NaN -> -NaN
-dqred828 reduce -sNaN -> -NaN Invalid_operation
-dqred829 reduce -NaN101 -> -NaN101
-dqred830 reduce -sNaN010 -> -NaN10 Invalid_operation
-
--- Null test
-dqred900 reduce # -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqReduce.decTest -- remove trailing zeros from a decQuad --
+-- Copyright (c) IBM Corporation, 2003, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqred001 reduce '1' -> '1'
+dqred002 reduce '-1' -> '-1'
+dqred003 reduce '1.00' -> '1'
+dqred004 reduce '-1.00' -> '-1'
+dqred005 reduce '0' -> '0'
+dqred006 reduce '0.00' -> '0'
+dqred007 reduce '00.0' -> '0'
+dqred008 reduce '00.00' -> '0'
+dqred009 reduce '00' -> '0'
+dqred010 reduce '0E+1' -> '0'
+dqred011 reduce '0E+5' -> '0'
+
+dqred012 reduce '-2' -> '-2'
+dqred013 reduce '2' -> '2'
+dqred014 reduce '-2.00' -> '-2'
+dqred015 reduce '2.00' -> '2'
+dqred016 reduce '-0' -> '-0'
+dqred017 reduce '-0.00' -> '-0'
+dqred018 reduce '-00.0' -> '-0'
+dqred019 reduce '-00.00' -> '-0'
+dqred020 reduce '-00' -> '-0'
+dqred021 reduce '-0E+5' -> '-0'
+dqred022 reduce '-0E+1' -> '-0'
+
+dqred030 reduce '+0.1' -> '0.1'
+dqred031 reduce '-0.1' -> '-0.1'
+dqred032 reduce '+0.01' -> '0.01'
+dqred033 reduce '-0.01' -> '-0.01'
+dqred034 reduce '+0.001' -> '0.001'
+dqred035 reduce '-0.001' -> '-0.001'
+dqred036 reduce '+0.000001' -> '0.000001'
+dqred037 reduce '-0.000001' -> '-0.000001'
+dqred038 reduce '+0.000000000001' -> '1E-12'
+dqred039 reduce '-0.000000000001' -> '-1E-12'
+
+dqred041 reduce 1.1 -> 1.1
+dqred042 reduce 1.10 -> 1.1
+dqred043 reduce 1.100 -> 1.1
+dqred044 reduce 1.110 -> 1.11
+dqred045 reduce -1.1 -> -1.1
+dqred046 reduce -1.10 -> -1.1
+dqred047 reduce -1.100 -> -1.1
+dqred048 reduce -1.110 -> -1.11
+dqred049 reduce 9.9 -> 9.9
+dqred050 reduce 9.90 -> 9.9
+dqred051 reduce 9.900 -> 9.9
+dqred052 reduce 9.990 -> 9.99
+dqred053 reduce -9.9 -> -9.9
+dqred054 reduce -9.90 -> -9.9
+dqred055 reduce -9.900 -> -9.9
+dqred056 reduce -9.990 -> -9.99
+
+-- some trailing fractional zeros with zeros in units
+dqred060 reduce 10.0 -> 1E+1
+dqred061 reduce 10.00 -> 1E+1
+dqred062 reduce 100.0 -> 1E+2
+dqred063 reduce 100.00 -> 1E+2
+dqred064 reduce 1.1000E+3 -> 1.1E+3
+dqred065 reduce 1.10000E+3 -> 1.1E+3
+dqred066 reduce -10.0 -> -1E+1
+dqred067 reduce -10.00 -> -1E+1
+dqred068 reduce -100.0 -> -1E+2
+dqred069 reduce -100.00 -> -1E+2
+dqred070 reduce -1.1000E+3 -> -1.1E+3
+dqred071 reduce -1.10000E+3 -> -1.1E+3
+
+-- some insignificant trailing zeros with positive exponent
+dqred080 reduce 10E+1 -> 1E+2
+dqred081 reduce 100E+1 -> 1E+3
+dqred082 reduce 1.0E+2 -> 1E+2
+dqred083 reduce 1.0E+3 -> 1E+3
+dqred084 reduce 1.1E+3 -> 1.1E+3
+dqred085 reduce 1.00E+3 -> 1E+3
+dqred086 reduce 1.10E+3 -> 1.1E+3
+dqred087 reduce -10E+1 -> -1E+2
+dqred088 reduce -100E+1 -> -1E+3
+dqred089 reduce -1.0E+2 -> -1E+2
+dqred090 reduce -1.0E+3 -> -1E+3
+dqred091 reduce -1.1E+3 -> -1.1E+3
+dqred092 reduce -1.00E+3 -> -1E+3
+dqred093 reduce -1.10E+3 -> -1.1E+3
+
+-- some significant trailing zeros, were we to be trimming
+dqred100 reduce 11 -> 11
+dqred101 reduce 10 -> 1E+1
+dqred102 reduce 10. -> 1E+1
+dqred103 reduce 1.1E+1 -> 11
+dqred104 reduce 1.0E+1 -> 1E+1
+dqred105 reduce 1.10E+2 -> 1.1E+2
+dqred106 reduce 1.00E+2 -> 1E+2
+dqred107 reduce 1.100E+3 -> 1.1E+3
+dqred108 reduce 1.000E+3 -> 1E+3
+dqred109 reduce 1.000000E+6 -> 1E+6
+dqred110 reduce -11 -> -11
+dqred111 reduce -10 -> -1E+1
+dqred112 reduce -10. -> -1E+1
+dqred113 reduce -1.1E+1 -> -11
+dqred114 reduce -1.0E+1 -> -1E+1
+dqred115 reduce -1.10E+2 -> -1.1E+2
+dqred116 reduce -1.00E+2 -> -1E+2
+dqred117 reduce -1.100E+3 -> -1.1E+3
+dqred118 reduce -1.000E+3 -> -1E+3
+dqred119 reduce -1.00000E+5 -> -1E+5
+dqred120 reduce -1.000000E+6 -> -1E+6
+dqred121 reduce -10.00000E+6 -> -1E+7
+dqred122 reduce -100.0000E+6 -> -1E+8
+dqred123 reduce -1000.000E+6 -> -1E+9
+dqred124 reduce -10000.00E+6 -> -1E+10
+dqred125 reduce -100000.0E+6 -> -1E+11
+dqred126 reduce -1000000.E+6 -> -1E+12
+
+-- examples from decArith
+dqred140 reduce '2.1' -> '2.1'
+dqred141 reduce '-2.0' -> '-2'
+dqred142 reduce '1.200' -> '1.2'
+dqred143 reduce '-120' -> '-1.2E+2'
+dqred144 reduce '120.00' -> '1.2E+2'
+dqred145 reduce '0.00' -> '0'
+
+-- Nmax, Nmin, Ntiny
+-- note origami effect on some of these
+dqred151 reduce 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqred152 reduce 9.999999999999999999999999000000000E+6140 -> 9.99999999999999999999999900000E+6140
+dqred153 reduce 9.999999999999999999999999999990000E+6144 -> 9.999999999999999999999999999990000E+6144
+dqred154 reduce 1E-6143 -> 1E-6143
+dqred155 reduce 1.000000000000000000000000000000000E-6143 -> 1E-6143
+dqred156 reduce 2.000E-6173 -> 2E-6173 Subnormal
+dqred157 reduce 1E-6176 -> 1E-6176 Subnormal
+
+dqred161 reduce -1E-6176 -> -1E-6176 Subnormal
+dqred162 reduce -2.000E-6173 -> -2E-6173 Subnormal
+dqred163 reduce -1.000000000000000000000000000000000E-6143 -> -1E-6143
+dqred164 reduce -1E-6143 -> -1E-6143
+dqred165 reduce -9.999999999999999999999999000000000E+6140 -> -9.99999999999999999999999900000E+6140
+dqred166 reduce -9.999999999999999999999999999990000E+6144 -> -9.999999999999999999999999999990000E+6144
+dqred167 reduce -9.999999999999999999999999999999990E+6144 -> -9.999999999999999999999999999999990E+6144
+dqred168 reduce -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqred169 reduce -9.999999999999999999999999999999990E+6144 -> -9.999999999999999999999999999999990E+6144
+
+
+-- specials (reduce does not affect payload)
+dqred820 reduce 'Inf' -> 'Infinity'
+dqred821 reduce '-Inf' -> '-Infinity'
+dqred822 reduce NaN -> NaN
+dqred823 reduce sNaN -> NaN Invalid_operation
+dqred824 reduce NaN101 -> NaN101
+dqred825 reduce sNaN010 -> NaN10 Invalid_operation
+dqred827 reduce -NaN -> -NaN
+dqred828 reduce -sNaN -> -NaN Invalid_operation
+dqred829 reduce -NaN101 -> -NaN101
+dqred830 reduce -sNaN010 -> -NaN10 Invalid_operation
+
+-- Null test
+dqred900 reduce # -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqRemainder.decTest b/Lib/test/decimaltestdata/dqRemainder.decTest
index 090d3cf559..bae8eae526 100644
--- a/Lib/test/decimaltestdata/dqRemainder.decTest
+++ b/Lib/test/decimaltestdata/dqRemainder.decTest
@@ -1,597 +1,597 @@
-------------------------------------------------------------------------
--- dqRemainder.decTest -- decQuad remainder --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks (as base, above)
-dqrem001 remainder 1 1 -> 0
-dqrem002 remainder 2 1 -> 0
-dqrem003 remainder 1 2 -> 1
-dqrem004 remainder 2 2 -> 0
-dqrem005 remainder 0 1 -> 0
-dqrem006 remainder 0 2 -> 0
-dqrem007 remainder 1 3 -> 1
-dqrem008 remainder 2 3 -> 2
-dqrem009 remainder 3 3 -> 0
-
-dqrem010 remainder 2.4 1 -> 0.4
-dqrem011 remainder 2.4 -1 -> 0.4
-dqrem012 remainder -2.4 1 -> -0.4
-dqrem013 remainder -2.4 -1 -> -0.4
-dqrem014 remainder 2.40 1 -> 0.40
-dqrem015 remainder 2.400 1 -> 0.400
-dqrem016 remainder 2.4 2 -> 0.4
-dqrem017 remainder 2.400 2 -> 0.400
-dqrem018 remainder 2. 2 -> 0
-dqrem019 remainder 20 20 -> 0
-
-dqrem020 remainder 187 187 -> 0
-dqrem021 remainder 5 2 -> 1
-dqrem022 remainder 5 2.0 -> 1.0
-dqrem023 remainder 5 2.000 -> 1.000
-dqrem024 remainder 5 0.200 -> 0.000
-dqrem025 remainder 5 0.200 -> 0.000
-
-dqrem030 remainder 1 2 -> 1
-dqrem031 remainder 1 4 -> 1
-dqrem032 remainder 1 8 -> 1
-
-dqrem033 remainder 1 16 -> 1
-dqrem034 remainder 1 32 -> 1
-dqrem035 remainder 1 64 -> 1
-dqrem040 remainder 1 -2 -> 1
-dqrem041 remainder 1 -4 -> 1
-dqrem042 remainder 1 -8 -> 1
-dqrem043 remainder 1 -16 -> 1
-dqrem044 remainder 1 -32 -> 1
-dqrem045 remainder 1 -64 -> 1
-dqrem050 remainder -1 2 -> -1
-dqrem051 remainder -1 4 -> -1
-dqrem052 remainder -1 8 -> -1
-dqrem053 remainder -1 16 -> -1
-dqrem054 remainder -1 32 -> -1
-dqrem055 remainder -1 64 -> -1
-dqrem060 remainder -1 -2 -> -1
-dqrem061 remainder -1 -4 -> -1
-dqrem062 remainder -1 -8 -> -1
-dqrem063 remainder -1 -16 -> -1
-dqrem064 remainder -1 -32 -> -1
-dqrem065 remainder -1 -64 -> -1
-
-dqrem066 remainder 999999999 1 -> 0
-dqrem067 remainder 999999999.4 1 -> 0.4
-dqrem068 remainder 999999999.5 1 -> 0.5
-dqrem069 remainder 999999999.9 1 -> 0.9
-dqrem070 remainder 999999999.999 1 -> 0.999
-dqrem071 remainder 999999.999999 1 -> 0.999999
-dqrem072 remainder 9 1 -> 0
-
-dqrem080 remainder 0. 1 -> 0
-dqrem081 remainder .0 1 -> 0.0
-dqrem082 remainder 0.00 1 -> 0.00
-dqrem083 remainder 0.00E+9 1 -> 0
-dqrem084 remainder 0.00E+3 1 -> 0
-dqrem085 remainder 0.00E+2 1 -> 0
-dqrem086 remainder 0.00E+1 1 -> 0.0
-dqrem087 remainder 0.00E+0 1 -> 0.00
-dqrem088 remainder 0.00E-0 1 -> 0.00
-dqrem089 remainder 0.00E-1 1 -> 0.000
-dqrem090 remainder 0.00E-2 1 -> 0.0000
-dqrem091 remainder 0.00E-3 1 -> 0.00000
-dqrem092 remainder 0.00E-4 1 -> 0.000000
-dqrem093 remainder 0.00E-5 1 -> 0E-7
-dqrem094 remainder 0.00E-6 1 -> 0E-8
-dqrem095 remainder 0.0000E-50 1 -> 0E-54
-
--- Various flavours of remainder by 0
-dqrem101 remainder 0 0 -> NaN Division_undefined
-dqrem102 remainder 0 -0 -> NaN Division_undefined
-dqrem103 remainder -0 0 -> NaN Division_undefined
-dqrem104 remainder -0 -0 -> NaN Division_undefined
-dqrem105 remainder 0.0E5 0 -> NaN Division_undefined
-dqrem106 remainder 0.000 0 -> NaN Division_undefined
--- [Some think this next group should be Division_by_zero exception, but
--- IEEE 854 is explicit that it is Invalid operation .. for
--- remainder-near, anyway]
-dqrem107 remainder 0.0001 0 -> NaN Invalid_operation
-dqrem108 remainder 0.01 0 -> NaN Invalid_operation
-dqrem109 remainder 0.1 0 -> NaN Invalid_operation
-dqrem110 remainder 1 0 -> NaN Invalid_operation
-dqrem111 remainder 1 0.0 -> NaN Invalid_operation
-dqrem112 remainder 10 0.0 -> NaN Invalid_operation
-dqrem113 remainder 1E+100 0.0 -> NaN Invalid_operation
-dqrem114 remainder 1E+380 0 -> NaN Invalid_operation
-dqrem115 remainder 0.0001 -0 -> NaN Invalid_operation
-dqrem116 remainder 0.01 -0 -> NaN Invalid_operation
-dqrem119 remainder 0.1 -0 -> NaN Invalid_operation
-dqrem120 remainder 1 -0 -> NaN Invalid_operation
-dqrem121 remainder 1 -0.0 -> NaN Invalid_operation
-dqrem122 remainder 10 -0.0 -> NaN Invalid_operation
-dqrem123 remainder 1E+100 -0.0 -> NaN Invalid_operation
-dqrem124 remainder 1E+384 -0 -> NaN Invalid_operation
--- and zeros on left
-dqrem130 remainder 0 1 -> 0
-dqrem131 remainder 0 -1 -> 0
-dqrem132 remainder 0.0 1 -> 0.0
-dqrem133 remainder 0.0 -1 -> 0.0
-dqrem134 remainder -0 1 -> -0
-dqrem135 remainder -0 -1 -> -0
-dqrem136 remainder -0.0 1 -> -0.0
-dqrem137 remainder -0.0 -1 -> -0.0
-
--- 0.5ers
-dqrem143 remainder 0.5 2 -> 0.5
-dqrem144 remainder 0.5 2.1 -> 0.5
-dqrem145 remainder 0.5 2.01 -> 0.50
-dqrem146 remainder 0.5 2.001 -> 0.500
-dqrem147 remainder 0.50 2 -> 0.50
-dqrem148 remainder 0.50 2.01 -> 0.50
-dqrem149 remainder 0.50 2.001 -> 0.500
-
--- steadies
-dqrem150 remainder 1 1 -> 0
-dqrem151 remainder 1 2 -> 1
-dqrem152 remainder 1 3 -> 1
-dqrem153 remainder 1 4 -> 1
-dqrem154 remainder 1 5 -> 1
-dqrem155 remainder 1 6 -> 1
-dqrem156 remainder 1 7 -> 1
-dqrem157 remainder 1 8 -> 1
-dqrem158 remainder 1 9 -> 1
-dqrem159 remainder 1 10 -> 1
-dqrem160 remainder 1 1 -> 0
-dqrem161 remainder 2 1 -> 0
-dqrem162 remainder 3 1 -> 0
-dqrem163 remainder 4 1 -> 0
-dqrem164 remainder 5 1 -> 0
-dqrem165 remainder 6 1 -> 0
-dqrem166 remainder 7 1 -> 0
-dqrem167 remainder 8 1 -> 0
-dqrem168 remainder 9 1 -> 0
-dqrem169 remainder 10 1 -> 0
-
--- some differences from remainderNear
-dqrem171 remainder 0.4 1.020 -> 0.400
-dqrem172 remainder 0.50 1.020 -> 0.500
-dqrem173 remainder 0.51 1.020 -> 0.510
-dqrem174 remainder 0.52 1.020 -> 0.520
-dqrem175 remainder 0.6 1.020 -> 0.600
-
--- More flavours of remainder by 0
-dqrem201 remainder 0 0 -> NaN Division_undefined
-dqrem202 remainder 0.0E5 0 -> NaN Division_undefined
-dqrem203 remainder 0.000 0 -> NaN Division_undefined
-dqrem204 remainder 0.0001 0 -> NaN Invalid_operation
-dqrem205 remainder 0.01 0 -> NaN Invalid_operation
-dqrem206 remainder 0.1 0 -> NaN Invalid_operation
-dqrem207 remainder 1 0 -> NaN Invalid_operation
-dqrem208 remainder 1 0.0 -> NaN Invalid_operation
-dqrem209 remainder 10 0.0 -> NaN Invalid_operation
-dqrem210 remainder 1E+100 0.0 -> NaN Invalid_operation
-dqrem211 remainder 1E+380 0 -> NaN Invalid_operation
-
--- some differences from remainderNear
-dqrem231 remainder -0.4 1.020 -> -0.400
-dqrem232 remainder -0.50 1.020 -> -0.500
-dqrem233 remainder -0.51 1.020 -> -0.510
-dqrem234 remainder -0.52 1.020 -> -0.520
-dqrem235 remainder -0.6 1.020 -> -0.600
-
--- high Xs
-dqrem240 remainder 1E+2 1.00 -> 0.00
-
--- dqrem3xx are from DiagBigDecimal
-dqrem301 remainder 1 3 -> 1
-dqrem302 remainder 5 5 -> 0
-dqrem303 remainder 13 10 -> 3
-dqrem304 remainder 13 50 -> 13
-dqrem305 remainder 13 100 -> 13
-dqrem306 remainder 13 1000 -> 13
-dqrem307 remainder .13 1 -> 0.13
-dqrem308 remainder 0.133 1 -> 0.133
-dqrem309 remainder 0.1033 1 -> 0.1033
-dqrem310 remainder 1.033 1 -> 0.033
-dqrem311 remainder 10.33 1 -> 0.33
-dqrem312 remainder 10.33 10 -> 0.33
-dqrem313 remainder 103.3 1 -> 0.3
-dqrem314 remainder 133 10 -> 3
-dqrem315 remainder 1033 10 -> 3
-dqrem316 remainder 1033 50 -> 33
-dqrem317 remainder 101.0 3 -> 2.0
-dqrem318 remainder 102.0 3 -> 0.0
-dqrem319 remainder 103.0 3 -> 1.0
-dqrem320 remainder 2.40 1 -> 0.40
-dqrem321 remainder 2.400 1 -> 0.400
-dqrem322 remainder 2.4 1 -> 0.4
-dqrem323 remainder 2.4 2 -> 0.4
-dqrem324 remainder 2.400 2 -> 0.400
-dqrem325 remainder 1 0.3 -> 0.1
-dqrem326 remainder 1 0.30 -> 0.10
-dqrem327 remainder 1 0.300 -> 0.100
-dqrem328 remainder 1 0.3000 -> 0.1000
-dqrem329 remainder 1.0 0.3 -> 0.1
-dqrem330 remainder 1.00 0.3 -> 0.10
-dqrem331 remainder 1.000 0.3 -> 0.100
-dqrem332 remainder 1.0000 0.3 -> 0.1000
-dqrem333 remainder 0.5 2 -> 0.5
-dqrem334 remainder 0.5 2.1 -> 0.5
-dqrem335 remainder 0.5 2.01 -> 0.50
-dqrem336 remainder 0.5 2.001 -> 0.500
-dqrem337 remainder 0.50 2 -> 0.50
-dqrem338 remainder 0.50 2.01 -> 0.50
-dqrem339 remainder 0.50 2.001 -> 0.500
-
-dqrem340 remainder 0.5 0.5000001 -> 0.5000000
-dqrem341 remainder 0.5 0.50000001 -> 0.50000000
-dqrem342 remainder 0.5 0.500000001 -> 0.500000000
-dqrem343 remainder 0.5 0.5000000001 -> 0.5000000000
-dqrem344 remainder 0.5 0.50000000001 -> 0.50000000000
-dqrem345 remainder 0.5 0.4999999 -> 1E-7
-dqrem346 remainder 0.5 0.49999999 -> 1E-8
-dqrem347 remainder 0.5 0.499999999 -> 1E-9
-dqrem348 remainder 0.5 0.4999999999 -> 1E-10
-dqrem349 remainder 0.5 0.49999999999 -> 1E-11
-dqrem350 remainder 0.5 0.499999999999 -> 1E-12
-
-dqrem351 remainder 0.03 7 -> 0.03
-dqrem352 remainder 5 2 -> 1
-dqrem353 remainder 4.1 2 -> 0.1
-dqrem354 remainder 4.01 2 -> 0.01
-dqrem355 remainder 4.001 2 -> 0.001
-dqrem356 remainder 4.0001 2 -> 0.0001
-dqrem357 remainder 4.00001 2 -> 0.00001
-dqrem358 remainder 4.000001 2 -> 0.000001
-dqrem359 remainder 4.0000001 2 -> 1E-7
-
-dqrem360 remainder 1.2 0.7345 -> 0.4655
-dqrem361 remainder 0.8 12 -> 0.8
-dqrem362 remainder 0.8 0.2 -> 0.0
-dqrem363 remainder 0.8 0.3 -> 0.2
-dqrem364 remainder 0.800 12 -> 0.800
-dqrem365 remainder 0.800 1.7 -> 0.800
-dqrem366 remainder 2.400 2 -> 0.400
-
-dqrem371 remainder 2.400 2 -> 0.400
-
-dqrem381 remainder 12345 1 -> 0
-dqrem382 remainder 12345 1.0001 -> 0.7657
-dqrem383 remainder 12345 1.001 -> 0.668
-dqrem384 remainder 12345 1.01 -> 0.78
-dqrem385 remainder 12345 1.1 -> 0.8
-dqrem386 remainder 12355 4 -> 3
-dqrem387 remainder 12345 4 -> 1
-dqrem388 remainder 12355 4.0001 -> 2.6912
-dqrem389 remainder 12345 4.0001 -> 0.6914
-dqrem390 remainder 12345 4.9 -> 1.9
-dqrem391 remainder 12345 4.99 -> 4.73
-dqrem392 remainder 12345 4.999 -> 2.469
-dqrem393 remainder 12345 4.9999 -> 0.2469
-dqrem394 remainder 12345 5 -> 0
-dqrem395 remainder 12345 5.0001 -> 4.7532
-dqrem396 remainder 12345 5.001 -> 2.532
-dqrem397 remainder 12345 5.01 -> 0.36
-dqrem398 remainder 12345 5.1 -> 3.0
-
--- the nasty division-by-1 cases
-dqrem401 remainder 0.5 1 -> 0.5
-dqrem402 remainder 0.55 1 -> 0.55
-dqrem403 remainder 0.555 1 -> 0.555
-dqrem404 remainder 0.5555 1 -> 0.5555
-dqrem405 remainder 0.55555 1 -> 0.55555
-dqrem406 remainder 0.555555 1 -> 0.555555
-dqrem407 remainder 0.5555555 1 -> 0.5555555
-dqrem408 remainder 0.55555555 1 -> 0.55555555
-dqrem409 remainder 0.555555555 1 -> 0.555555555
-
--- folddowns
-dqrem421 remainder 1E+6144 1 -> NaN Division_impossible
-dqrem422 remainder 1E+6144 1E+6143 -> 0E+6111 Clamped
-dqrem423 remainder 1E+6144 2E+6143 -> 0E+6111 Clamped
-dqrem424 remainder 1E+6144 3E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqrem425 remainder 1E+6144 4E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
-dqrem426 remainder 1E+6144 5E+6143 -> 0E+6111 Clamped
-dqrem427 remainder 1E+6144 6E+6143 -> 4.00000000000000000000000000000000E+6143 Clamped
-dqrem428 remainder 1E+6144 7E+6143 -> 3.00000000000000000000000000000000E+6143 Clamped
-dqrem429 remainder 1E+6144 8E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
-dqrem430 remainder 1E+6144 9E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
--- tinies
-dqrem431 remainder 1E-6175 1E-6176 -> 0E-6176
-dqrem432 remainder 1E-6175 2E-6176 -> 0E-6176
-dqrem433 remainder 1E-6175 3E-6176 -> 1E-6176 Subnormal
-dqrem434 remainder 1E-6175 4E-6176 -> 2E-6176 Subnormal
-dqrem435 remainder 1E-6175 5E-6176 -> 0E-6176
-dqrem436 remainder 1E-6175 6E-6176 -> 4E-6176 Subnormal
-dqrem437 remainder 1E-6175 7E-6176 -> 3E-6176 Subnormal
-dqrem438 remainder 1E-6175 8E-6176 -> 2E-6176 Subnormal
-dqrem439 remainder 1E-6175 9E-6176 -> 1E-6176 Subnormal
-dqrem440 remainder 1E-6175 10E-6176 -> 0E-6176
-dqrem441 remainder 1E-6175 11E-6176 -> 1.0E-6175 Subnormal
-dqrem442 remainder 100E-6175 11E-6176 -> 1.0E-6175 Subnormal
-dqrem443 remainder 100E-6175 20E-6176 -> 0E-6176
-dqrem444 remainder 100E-6175 21E-6176 -> 1.3E-6175 Subnormal
-dqrem445 remainder 100E-6175 30E-6176 -> 1.0E-6175 Subnormal
-
--- zero signs
-dqrem650 remainder 1 1 -> 0
-dqrem651 remainder -1 1 -> -0
-dqrem652 remainder 1 -1 -> 0
-dqrem653 remainder -1 -1 -> -0
-dqrem654 remainder 0 1 -> 0
-dqrem655 remainder -0 1 -> -0
-dqrem656 remainder 0 -1 -> 0
-dqrem657 remainder -0 -1 -> -0
-dqrem658 remainder 0.00 1 -> 0.00
-dqrem659 remainder -0.00 1 -> -0.00
-
--- Specials
-dqrem680 remainder Inf -Inf -> NaN Invalid_operation
-dqrem681 remainder Inf -1000 -> NaN Invalid_operation
-dqrem682 remainder Inf -1 -> NaN Invalid_operation
-dqrem683 remainder Inf 0 -> NaN Invalid_operation
-dqrem684 remainder Inf -0 -> NaN Invalid_operation
-dqrem685 remainder Inf 1 -> NaN Invalid_operation
-dqrem686 remainder Inf 1000 -> NaN Invalid_operation
-dqrem687 remainder Inf Inf -> NaN Invalid_operation
-dqrem688 remainder -1000 Inf -> -1000
-dqrem689 remainder -Inf Inf -> NaN Invalid_operation
-dqrem691 remainder -1 Inf -> -1
-dqrem692 remainder 0 Inf -> 0
-dqrem693 remainder -0 Inf -> -0
-dqrem694 remainder 1 Inf -> 1
-dqrem695 remainder 1000 Inf -> 1000
-dqrem696 remainder Inf Inf -> NaN Invalid_operation
-
-dqrem700 remainder -Inf -Inf -> NaN Invalid_operation
-dqrem701 remainder -Inf -1000 -> NaN Invalid_operation
-dqrem702 remainder -Inf -1 -> NaN Invalid_operation
-dqrem703 remainder -Inf -0 -> NaN Invalid_operation
-dqrem704 remainder -Inf 0 -> NaN Invalid_operation
-dqrem705 remainder -Inf 1 -> NaN Invalid_operation
-dqrem706 remainder -Inf 1000 -> NaN Invalid_operation
-dqrem707 remainder -Inf Inf -> NaN Invalid_operation
-dqrem708 remainder -Inf -Inf -> NaN Invalid_operation
-dqrem709 remainder -1000 Inf -> -1000
-dqrem710 remainder -1 -Inf -> -1
-dqrem711 remainder -0 -Inf -> -0
-dqrem712 remainder 0 -Inf -> 0
-dqrem713 remainder 1 -Inf -> 1
-dqrem714 remainder 1000 -Inf -> 1000
-dqrem715 remainder Inf -Inf -> NaN Invalid_operation
-
-dqrem721 remainder NaN -Inf -> NaN
-dqrem722 remainder NaN -1000 -> NaN
-dqrem723 remainder NaN -1 -> NaN
-dqrem724 remainder NaN -0 -> NaN
-dqrem725 remainder -NaN 0 -> -NaN
-dqrem726 remainder NaN 1 -> NaN
-dqrem727 remainder NaN 1000 -> NaN
-dqrem728 remainder NaN Inf -> NaN
-dqrem729 remainder NaN -NaN -> NaN
-dqrem730 remainder -Inf NaN -> NaN
-dqrem731 remainder -1000 NaN -> NaN
-dqrem732 remainder -1 NaN -> NaN
-dqrem733 remainder -0 -NaN -> -NaN
-dqrem734 remainder 0 NaN -> NaN
-dqrem735 remainder 1 -NaN -> -NaN
-dqrem736 remainder 1000 NaN -> NaN
-dqrem737 remainder Inf NaN -> NaN
-
-dqrem741 remainder sNaN -Inf -> NaN Invalid_operation
-dqrem742 remainder sNaN -1000 -> NaN Invalid_operation
-dqrem743 remainder -sNaN -1 -> -NaN Invalid_operation
-dqrem744 remainder sNaN -0 -> NaN Invalid_operation
-dqrem745 remainder sNaN 0 -> NaN Invalid_operation
-dqrem746 remainder sNaN 1 -> NaN Invalid_operation
-dqrem747 remainder sNaN 1000 -> NaN Invalid_operation
-dqrem749 remainder sNaN NaN -> NaN Invalid_operation
-dqrem750 remainder sNaN sNaN -> NaN Invalid_operation
-dqrem751 remainder NaN sNaN -> NaN Invalid_operation
-dqrem752 remainder -Inf sNaN -> NaN Invalid_operation
-dqrem753 remainder -1000 sNaN -> NaN Invalid_operation
-dqrem754 remainder -1 sNaN -> NaN Invalid_operation
-dqrem755 remainder -0 sNaN -> NaN Invalid_operation
-dqrem756 remainder 0 sNaN -> NaN Invalid_operation
-dqrem757 remainder 1 sNaN -> NaN Invalid_operation
-dqrem758 remainder 1000 sNaN -> NaN Invalid_operation
-dqrem759 remainder Inf -sNaN -> -NaN Invalid_operation
-
--- propaging NaNs
-dqrem760 remainder NaN1 NaN7 -> NaN1
-dqrem761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation
-dqrem762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation
-dqrem763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation
-dqrem764 remainder 15 NaN11 -> NaN11
-dqrem765 remainder NaN6 NaN12 -> NaN6
-dqrem766 remainder Inf NaN13 -> NaN13
-dqrem767 remainder NaN14 -Inf -> NaN14
-dqrem768 remainder 0 NaN15 -> NaN15
-dqrem769 remainder NaN16 -0 -> NaN16
-
--- edge cases of impossible
-dqrem770 remainder 1234568888888887777777777890123456 10 -> 6
-dqrem771 remainder 1234568888888887777777777890123456 1 -> 0
-dqrem772 remainder 1234568888888887777777777890123456 0.1 -> NaN Division_impossible
-dqrem773 remainder 1234568888888887777777777890123456 0.01 -> NaN Division_impossible
-
--- long operand checks
-dqrem801 remainder 12345678000 100 -> 0
-dqrem802 remainder 1 12345678000 -> 1
-dqrem803 remainder 1234567800 10 -> 0
-dqrem804 remainder 1 1234567800 -> 1
-dqrem805 remainder 1234567890 10 -> 0
-dqrem806 remainder 1 1234567890 -> 1
-dqrem807 remainder 1234567891 10 -> 1
-dqrem808 remainder 1 1234567891 -> 1
-dqrem809 remainder 12345678901 100 -> 1
-dqrem810 remainder 1 12345678901 -> 1
-dqrem811 remainder 1234567896 10 -> 6
-dqrem812 remainder 1 1234567896 -> 1
-
-dqrem821 remainder 12345678000 100 -> 0
-dqrem822 remainder 1 12345678000 -> 1
-dqrem823 remainder 1234567800 10 -> 0
-dqrem824 remainder 1 1234567800 -> 1
-dqrem825 remainder 1234567890 10 -> 0
-dqrem826 remainder 1 1234567890 -> 1
-dqrem827 remainder 1234567891 10 -> 1
-dqrem828 remainder 1 1234567891 -> 1
-dqrem829 remainder 12345678901 100 -> 1
-dqrem830 remainder 1 12345678901 -> 1
-dqrem831 remainder 1234567896 10 -> 6
-dqrem832 remainder 1 1234567896 -> 1
-
--- from divideint
-dqrem840 remainder 100000000.0 1 -> 0.0
-dqrem841 remainder 100000000.4 1 -> 0.4
-dqrem842 remainder 100000000.5 1 -> 0.5
-dqrem843 remainder 100000000.9 1 -> 0.9
-dqrem844 remainder 100000000.999 1 -> 0.999
-dqrem850 remainder 100000003 5 -> 3
-dqrem851 remainder 10000003 5 -> 3
-dqrem852 remainder 1000003 5 -> 3
-dqrem853 remainder 100003 5 -> 3
-dqrem854 remainder 10003 5 -> 3
-dqrem855 remainder 1003 5 -> 3
-dqrem856 remainder 103 5 -> 3
-dqrem857 remainder 13 5 -> 3
-dqrem858 remainder 1 5 -> 1
-
--- Vladimir's cases 1234567890123456
-dqrem860 remainder 123.0e1 1000000000000000 -> 1230
-dqrem861 remainder 1230 1000000000000000 -> 1230
-dqrem862 remainder 12.3e2 1000000000000000 -> 1230
-dqrem863 remainder 1.23e3 1000000000000000 -> 1230
-dqrem864 remainder 123e1 1000000000000000 -> 1230
-dqrem870 remainder 123e1 1000000000000000 -> 1230
-dqrem871 remainder 123e1 100000000000000 -> 1230
-dqrem872 remainder 123e1 10000000000000 -> 1230
-dqrem873 remainder 123e1 1000000000000 -> 1230
-dqrem874 remainder 123e1 100000000000 -> 1230
-dqrem875 remainder 123e1 10000000000 -> 1230
-dqrem876 remainder 123e1 1000000000 -> 1230
-dqrem877 remainder 123e1 100000000 -> 1230
-dqrem878 remainder 1230 100000000 -> 1230
-dqrem879 remainder 123e1 10000000 -> 1230
-dqrem880 remainder 123e1 1000000 -> 1230
-dqrem881 remainder 123e1 100000 -> 1230
-dqrem882 remainder 123e1 10000 -> 1230
-dqrem883 remainder 123e1 1000 -> 230
-dqrem884 remainder 123e1 100 -> 30
-dqrem885 remainder 123e1 10 -> 0
-dqrem886 remainder 123e1 1 -> 0
-
-dqrem890 remainder 123e1 2000000000000000 -> 1230
-dqrem891 remainder 123e1 200000000000000 -> 1230
-dqrem892 remainder 123e1 20000000000000 -> 1230
-dqrem893 remainder 123e1 2000000000000 -> 1230
-dqrem894 remainder 123e1 200000000000 -> 1230
-dqrem895 remainder 123e1 20000000000 -> 1230
-dqrem896 remainder 123e1 2000000000 -> 1230
-dqrem897 remainder 123e1 200000000 -> 1230
-dqrem899 remainder 123e1 20000000 -> 1230
-dqrem900 remainder 123e1 2000000 -> 1230
-dqrem901 remainder 123e1 200000 -> 1230
-dqrem902 remainder 123e1 20000 -> 1230
-dqrem903 remainder 123e1 2000 -> 1230
-dqrem904 remainder 123e1 200 -> 30
-dqrem905 remainder 123e1 20 -> 10
-dqrem906 remainder 123e1 2 -> 0
-
-dqrem910 remainder 123e1 5000000000000000 -> 1230
-dqrem911 remainder 123e1 500000000000000 -> 1230
-dqrem912 remainder 123e1 50000000000000 -> 1230
-dqrem913 remainder 123e1 5000000000000 -> 1230
-dqrem914 remainder 123e1 500000000000 -> 1230
-dqrem915 remainder 123e1 50000000000 -> 1230
-dqrem916 remainder 123e1 5000000000 -> 1230
-dqrem917 remainder 123e1 500000000 -> 1230
-dqrem919 remainder 123e1 50000000 -> 1230
-dqrem920 remainder 123e1 5000000 -> 1230
-dqrem921 remainder 123e1 500000 -> 1230
-dqrem922 remainder 123e1 50000 -> 1230
-dqrem923 remainder 123e1 5000 -> 1230
-dqrem924 remainder 123e1 500 -> 230
-dqrem925 remainder 123e1 50 -> 30
-dqrem926 remainder 123e1 5 -> 0
-
-dqrem930 remainder 123e1 9000000000000000 -> 1230
-dqrem931 remainder 123e1 900000000000000 -> 1230
-dqrem932 remainder 123e1 90000000000000 -> 1230
-dqrem933 remainder 123e1 9000000000000 -> 1230
-dqrem934 remainder 123e1 900000000000 -> 1230
-dqrem935 remainder 123e1 90000000000 -> 1230
-dqrem936 remainder 123e1 9000000000 -> 1230
-dqrem937 remainder 123e1 900000000 -> 1230
-dqrem939 remainder 123e1 90000000 -> 1230
-dqrem940 remainder 123e1 9000000 -> 1230
-dqrem941 remainder 123e1 900000 -> 1230
-dqrem942 remainder 123e1 90000 -> 1230
-dqrem943 remainder 123e1 9000 -> 1230
-dqrem944 remainder 123e1 900 -> 330
-dqrem945 remainder 123e1 90 -> 60
-dqrem946 remainder 123e1 9 -> 6
-
-dqrem950 remainder 123e1 1000000000000000 -> 1230
-dqrem961 remainder 123e1 2999999999999999 -> 1230
-dqrem962 remainder 123e1 3999999999999999 -> 1230
-dqrem963 remainder 123e1 4999999999999999 -> 1230
-dqrem964 remainder 123e1 5999999999999999 -> 1230
-dqrem965 remainder 123e1 6999999999999999 -> 1230
-dqrem966 remainder 123e1 7999999999999999 -> 1230
-dqrem967 remainder 123e1 8999999999999999 -> 1230
-dqrem968 remainder 123e1 9999999999999999 -> 1230
-dqrem969 remainder 123e1 9876543210987654 -> 1230
-
-dqrem980 remainder 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
-
--- overflow and underflow tests [from divide]
-dqrem1051 remainder 1e+277 1e-311 -> NaN Division_impossible
-dqrem1052 remainder 1e+277 -1e-311 -> NaN Division_impossible
-dqrem1053 remainder -1e+277 1e-311 -> NaN Division_impossible
-dqrem1054 remainder -1e+277 -1e-311 -> NaN Division_impossible
-dqrem1055 remainder 1e-277 1e+311 -> 1E-277
-dqrem1056 remainder 1e-277 -1e+311 -> 1E-277
-dqrem1057 remainder -1e-277 1e+311 -> -1E-277
-dqrem1058 remainder -1e-277 -1e+311 -> -1E-277
-
--- Gyuris example
-dqrem1070 remainder 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 8.336804418094040989630006819881709E-6143
-
--- destructive subtract
-dqrem1120 remainder 1234567890123456789012345678901234 1.000000000000000000000000000000001 -> 0.765432109876543210987654321098768
-dqrem1121 remainder 1234567890123456789012345678901234 1.00000000000000000000000000000001 -> 0.65432109876543210987654321098779
-dqrem1122 remainder 1234567890123456789012345678901234 1.0000000000000000000000000000001 -> 0.5432109876543210987654321098890
-dqrem1123 remainder 1234567890123456789012345678901255 4.000000000000000000000000000000001 -> 2.691358027469135802746913580274687
-dqrem1124 remainder 1234567890123456789012345678901234 4.000000000000000000000000000000001 -> 1.691358027469135802746913580274692
-dqrem1125 remainder 1234567890123456789012345678901234 4.9999999999999999999999999999999 -> 3.6913578024691357802469135780251
-dqrem1126 remainder 1234567890123456789012345678901234 4.99999999999999999999999999999999 -> 1.46913578024691357802469135780247
-dqrem1127 remainder 1234567890123456789012345678901234 4.999999999999999999999999999999999 -> 4.246913578024691357802469135780246
-dqrem1128 remainder 1234567890123456789012345678901234 5.0000000000000000000000000000001 -> 4.3086421975308642197530864219759
-
--- Null tests
-dqrem1000 remainder 10 # -> NaN Invalid_operation
-dqrem1001 remainder # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqRemainder.decTest -- decQuad remainder --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks (as base, above)
+dqrem001 remainder 1 1 -> 0
+dqrem002 remainder 2 1 -> 0
+dqrem003 remainder 1 2 -> 1
+dqrem004 remainder 2 2 -> 0
+dqrem005 remainder 0 1 -> 0
+dqrem006 remainder 0 2 -> 0
+dqrem007 remainder 1 3 -> 1
+dqrem008 remainder 2 3 -> 2
+dqrem009 remainder 3 3 -> 0
+
+dqrem010 remainder 2.4 1 -> 0.4
+dqrem011 remainder 2.4 -1 -> 0.4
+dqrem012 remainder -2.4 1 -> -0.4
+dqrem013 remainder -2.4 -1 -> -0.4
+dqrem014 remainder 2.40 1 -> 0.40
+dqrem015 remainder 2.400 1 -> 0.400
+dqrem016 remainder 2.4 2 -> 0.4
+dqrem017 remainder 2.400 2 -> 0.400
+dqrem018 remainder 2. 2 -> 0
+dqrem019 remainder 20 20 -> 0
+
+dqrem020 remainder 187 187 -> 0
+dqrem021 remainder 5 2 -> 1
+dqrem022 remainder 5 2.0 -> 1.0
+dqrem023 remainder 5 2.000 -> 1.000
+dqrem024 remainder 5 0.200 -> 0.000
+dqrem025 remainder 5 0.200 -> 0.000
+
+dqrem030 remainder 1 2 -> 1
+dqrem031 remainder 1 4 -> 1
+dqrem032 remainder 1 8 -> 1
+
+dqrem033 remainder 1 16 -> 1
+dqrem034 remainder 1 32 -> 1
+dqrem035 remainder 1 64 -> 1
+dqrem040 remainder 1 -2 -> 1
+dqrem041 remainder 1 -4 -> 1
+dqrem042 remainder 1 -8 -> 1
+dqrem043 remainder 1 -16 -> 1
+dqrem044 remainder 1 -32 -> 1
+dqrem045 remainder 1 -64 -> 1
+dqrem050 remainder -1 2 -> -1
+dqrem051 remainder -1 4 -> -1
+dqrem052 remainder -1 8 -> -1
+dqrem053 remainder -1 16 -> -1
+dqrem054 remainder -1 32 -> -1
+dqrem055 remainder -1 64 -> -1
+dqrem060 remainder -1 -2 -> -1
+dqrem061 remainder -1 -4 -> -1
+dqrem062 remainder -1 -8 -> -1
+dqrem063 remainder -1 -16 -> -1
+dqrem064 remainder -1 -32 -> -1
+dqrem065 remainder -1 -64 -> -1
+
+dqrem066 remainder 999999999 1 -> 0
+dqrem067 remainder 999999999.4 1 -> 0.4
+dqrem068 remainder 999999999.5 1 -> 0.5
+dqrem069 remainder 999999999.9 1 -> 0.9
+dqrem070 remainder 999999999.999 1 -> 0.999
+dqrem071 remainder 999999.999999 1 -> 0.999999
+dqrem072 remainder 9 1 -> 0
+
+dqrem080 remainder 0. 1 -> 0
+dqrem081 remainder .0 1 -> 0.0
+dqrem082 remainder 0.00 1 -> 0.00
+dqrem083 remainder 0.00E+9 1 -> 0
+dqrem084 remainder 0.00E+3 1 -> 0
+dqrem085 remainder 0.00E+2 1 -> 0
+dqrem086 remainder 0.00E+1 1 -> 0.0
+dqrem087 remainder 0.00E+0 1 -> 0.00
+dqrem088 remainder 0.00E-0 1 -> 0.00
+dqrem089 remainder 0.00E-1 1 -> 0.000
+dqrem090 remainder 0.00E-2 1 -> 0.0000
+dqrem091 remainder 0.00E-3 1 -> 0.00000
+dqrem092 remainder 0.00E-4 1 -> 0.000000
+dqrem093 remainder 0.00E-5 1 -> 0E-7
+dqrem094 remainder 0.00E-6 1 -> 0E-8
+dqrem095 remainder 0.0000E-50 1 -> 0E-54
+
+-- Various flavours of remainder by 0
+dqrem101 remainder 0 0 -> NaN Division_undefined
+dqrem102 remainder 0 -0 -> NaN Division_undefined
+dqrem103 remainder -0 0 -> NaN Division_undefined
+dqrem104 remainder -0 -0 -> NaN Division_undefined
+dqrem105 remainder 0.0E5 0 -> NaN Division_undefined
+dqrem106 remainder 0.000 0 -> NaN Division_undefined
+-- [Some think this next group should be Division_by_zero exception, but
+-- IEEE 854 is explicit that it is Invalid operation .. for
+-- remainder-near, anyway]
+dqrem107 remainder 0.0001 0 -> NaN Invalid_operation
+dqrem108 remainder 0.01 0 -> NaN Invalid_operation
+dqrem109 remainder 0.1 0 -> NaN Invalid_operation
+dqrem110 remainder 1 0 -> NaN Invalid_operation
+dqrem111 remainder 1 0.0 -> NaN Invalid_operation
+dqrem112 remainder 10 0.0 -> NaN Invalid_operation
+dqrem113 remainder 1E+100 0.0 -> NaN Invalid_operation
+dqrem114 remainder 1E+380 0 -> NaN Invalid_operation
+dqrem115 remainder 0.0001 -0 -> NaN Invalid_operation
+dqrem116 remainder 0.01 -0 -> NaN Invalid_operation
+dqrem119 remainder 0.1 -0 -> NaN Invalid_operation
+dqrem120 remainder 1 -0 -> NaN Invalid_operation
+dqrem121 remainder 1 -0.0 -> NaN Invalid_operation
+dqrem122 remainder 10 -0.0 -> NaN Invalid_operation
+dqrem123 remainder 1E+100 -0.0 -> NaN Invalid_operation
+dqrem124 remainder 1E+384 -0 -> NaN Invalid_operation
+-- and zeros on left
+dqrem130 remainder 0 1 -> 0
+dqrem131 remainder 0 -1 -> 0
+dqrem132 remainder 0.0 1 -> 0.0
+dqrem133 remainder 0.0 -1 -> 0.0
+dqrem134 remainder -0 1 -> -0
+dqrem135 remainder -0 -1 -> -0
+dqrem136 remainder -0.0 1 -> -0.0
+dqrem137 remainder -0.0 -1 -> -0.0
+
+-- 0.5ers
+dqrem143 remainder 0.5 2 -> 0.5
+dqrem144 remainder 0.5 2.1 -> 0.5
+dqrem145 remainder 0.5 2.01 -> 0.50
+dqrem146 remainder 0.5 2.001 -> 0.500
+dqrem147 remainder 0.50 2 -> 0.50
+dqrem148 remainder 0.50 2.01 -> 0.50
+dqrem149 remainder 0.50 2.001 -> 0.500
+
+-- steadies
+dqrem150 remainder 1 1 -> 0
+dqrem151 remainder 1 2 -> 1
+dqrem152 remainder 1 3 -> 1
+dqrem153 remainder 1 4 -> 1
+dqrem154 remainder 1 5 -> 1
+dqrem155 remainder 1 6 -> 1
+dqrem156 remainder 1 7 -> 1
+dqrem157 remainder 1 8 -> 1
+dqrem158 remainder 1 9 -> 1
+dqrem159 remainder 1 10 -> 1
+dqrem160 remainder 1 1 -> 0
+dqrem161 remainder 2 1 -> 0
+dqrem162 remainder 3 1 -> 0
+dqrem163 remainder 4 1 -> 0
+dqrem164 remainder 5 1 -> 0
+dqrem165 remainder 6 1 -> 0
+dqrem166 remainder 7 1 -> 0
+dqrem167 remainder 8 1 -> 0
+dqrem168 remainder 9 1 -> 0
+dqrem169 remainder 10 1 -> 0
+
+-- some differences from remainderNear
+dqrem171 remainder 0.4 1.020 -> 0.400
+dqrem172 remainder 0.50 1.020 -> 0.500
+dqrem173 remainder 0.51 1.020 -> 0.510
+dqrem174 remainder 0.52 1.020 -> 0.520
+dqrem175 remainder 0.6 1.020 -> 0.600
+
+-- More flavours of remainder by 0
+dqrem201 remainder 0 0 -> NaN Division_undefined
+dqrem202 remainder 0.0E5 0 -> NaN Division_undefined
+dqrem203 remainder 0.000 0 -> NaN Division_undefined
+dqrem204 remainder 0.0001 0 -> NaN Invalid_operation
+dqrem205 remainder 0.01 0 -> NaN Invalid_operation
+dqrem206 remainder 0.1 0 -> NaN Invalid_operation
+dqrem207 remainder 1 0 -> NaN Invalid_operation
+dqrem208 remainder 1 0.0 -> NaN Invalid_operation
+dqrem209 remainder 10 0.0 -> NaN Invalid_operation
+dqrem210 remainder 1E+100 0.0 -> NaN Invalid_operation
+dqrem211 remainder 1E+380 0 -> NaN Invalid_operation
+
+-- some differences from remainderNear
+dqrem231 remainder -0.4 1.020 -> -0.400
+dqrem232 remainder -0.50 1.020 -> -0.500
+dqrem233 remainder -0.51 1.020 -> -0.510
+dqrem234 remainder -0.52 1.020 -> -0.520
+dqrem235 remainder -0.6 1.020 -> -0.600
+
+-- high Xs
+dqrem240 remainder 1E+2 1.00 -> 0.00
+
+-- dqrem3xx are from DiagBigDecimal
+dqrem301 remainder 1 3 -> 1
+dqrem302 remainder 5 5 -> 0
+dqrem303 remainder 13 10 -> 3
+dqrem304 remainder 13 50 -> 13
+dqrem305 remainder 13 100 -> 13
+dqrem306 remainder 13 1000 -> 13
+dqrem307 remainder .13 1 -> 0.13
+dqrem308 remainder 0.133 1 -> 0.133
+dqrem309 remainder 0.1033 1 -> 0.1033
+dqrem310 remainder 1.033 1 -> 0.033
+dqrem311 remainder 10.33 1 -> 0.33
+dqrem312 remainder 10.33 10 -> 0.33
+dqrem313 remainder 103.3 1 -> 0.3
+dqrem314 remainder 133 10 -> 3
+dqrem315 remainder 1033 10 -> 3
+dqrem316 remainder 1033 50 -> 33
+dqrem317 remainder 101.0 3 -> 2.0
+dqrem318 remainder 102.0 3 -> 0.0
+dqrem319 remainder 103.0 3 -> 1.0
+dqrem320 remainder 2.40 1 -> 0.40
+dqrem321 remainder 2.400 1 -> 0.400
+dqrem322 remainder 2.4 1 -> 0.4
+dqrem323 remainder 2.4 2 -> 0.4
+dqrem324 remainder 2.400 2 -> 0.400
+dqrem325 remainder 1 0.3 -> 0.1
+dqrem326 remainder 1 0.30 -> 0.10
+dqrem327 remainder 1 0.300 -> 0.100
+dqrem328 remainder 1 0.3000 -> 0.1000
+dqrem329 remainder 1.0 0.3 -> 0.1
+dqrem330 remainder 1.00 0.3 -> 0.10
+dqrem331 remainder 1.000 0.3 -> 0.100
+dqrem332 remainder 1.0000 0.3 -> 0.1000
+dqrem333 remainder 0.5 2 -> 0.5
+dqrem334 remainder 0.5 2.1 -> 0.5
+dqrem335 remainder 0.5 2.01 -> 0.50
+dqrem336 remainder 0.5 2.001 -> 0.500
+dqrem337 remainder 0.50 2 -> 0.50
+dqrem338 remainder 0.50 2.01 -> 0.50
+dqrem339 remainder 0.50 2.001 -> 0.500
+
+dqrem340 remainder 0.5 0.5000001 -> 0.5000000
+dqrem341 remainder 0.5 0.50000001 -> 0.50000000
+dqrem342 remainder 0.5 0.500000001 -> 0.500000000
+dqrem343 remainder 0.5 0.5000000001 -> 0.5000000000
+dqrem344 remainder 0.5 0.50000000001 -> 0.50000000000
+dqrem345 remainder 0.5 0.4999999 -> 1E-7
+dqrem346 remainder 0.5 0.49999999 -> 1E-8
+dqrem347 remainder 0.5 0.499999999 -> 1E-9
+dqrem348 remainder 0.5 0.4999999999 -> 1E-10
+dqrem349 remainder 0.5 0.49999999999 -> 1E-11
+dqrem350 remainder 0.5 0.499999999999 -> 1E-12
+
+dqrem351 remainder 0.03 7 -> 0.03
+dqrem352 remainder 5 2 -> 1
+dqrem353 remainder 4.1 2 -> 0.1
+dqrem354 remainder 4.01 2 -> 0.01
+dqrem355 remainder 4.001 2 -> 0.001
+dqrem356 remainder 4.0001 2 -> 0.0001
+dqrem357 remainder 4.00001 2 -> 0.00001
+dqrem358 remainder 4.000001 2 -> 0.000001
+dqrem359 remainder 4.0000001 2 -> 1E-7
+
+dqrem360 remainder 1.2 0.7345 -> 0.4655
+dqrem361 remainder 0.8 12 -> 0.8
+dqrem362 remainder 0.8 0.2 -> 0.0
+dqrem363 remainder 0.8 0.3 -> 0.2
+dqrem364 remainder 0.800 12 -> 0.800
+dqrem365 remainder 0.800 1.7 -> 0.800
+dqrem366 remainder 2.400 2 -> 0.400
+
+dqrem371 remainder 2.400 2 -> 0.400
+
+dqrem381 remainder 12345 1 -> 0
+dqrem382 remainder 12345 1.0001 -> 0.7657
+dqrem383 remainder 12345 1.001 -> 0.668
+dqrem384 remainder 12345 1.01 -> 0.78
+dqrem385 remainder 12345 1.1 -> 0.8
+dqrem386 remainder 12355 4 -> 3
+dqrem387 remainder 12345 4 -> 1
+dqrem388 remainder 12355 4.0001 -> 2.6912
+dqrem389 remainder 12345 4.0001 -> 0.6914
+dqrem390 remainder 12345 4.9 -> 1.9
+dqrem391 remainder 12345 4.99 -> 4.73
+dqrem392 remainder 12345 4.999 -> 2.469
+dqrem393 remainder 12345 4.9999 -> 0.2469
+dqrem394 remainder 12345 5 -> 0
+dqrem395 remainder 12345 5.0001 -> 4.7532
+dqrem396 remainder 12345 5.001 -> 2.532
+dqrem397 remainder 12345 5.01 -> 0.36
+dqrem398 remainder 12345 5.1 -> 3.0
+
+-- the nasty division-by-1 cases
+dqrem401 remainder 0.5 1 -> 0.5
+dqrem402 remainder 0.55 1 -> 0.55
+dqrem403 remainder 0.555 1 -> 0.555
+dqrem404 remainder 0.5555 1 -> 0.5555
+dqrem405 remainder 0.55555 1 -> 0.55555
+dqrem406 remainder 0.555555 1 -> 0.555555
+dqrem407 remainder 0.5555555 1 -> 0.5555555
+dqrem408 remainder 0.55555555 1 -> 0.55555555
+dqrem409 remainder 0.555555555 1 -> 0.555555555
+
+-- folddowns
+dqrem421 remainder 1E+6144 1 -> NaN Division_impossible
+dqrem422 remainder 1E+6144 1E+6143 -> 0E+6111 Clamped
+dqrem423 remainder 1E+6144 2E+6143 -> 0E+6111 Clamped
+dqrem424 remainder 1E+6144 3E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqrem425 remainder 1E+6144 4E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
+dqrem426 remainder 1E+6144 5E+6143 -> 0E+6111 Clamped
+dqrem427 remainder 1E+6144 6E+6143 -> 4.00000000000000000000000000000000E+6143 Clamped
+dqrem428 remainder 1E+6144 7E+6143 -> 3.00000000000000000000000000000000E+6143 Clamped
+dqrem429 remainder 1E+6144 8E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
+dqrem430 remainder 1E+6144 9E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
+-- tinies
+dqrem431 remainder 1E-6175 1E-6176 -> 0E-6176
+dqrem432 remainder 1E-6175 2E-6176 -> 0E-6176
+dqrem433 remainder 1E-6175 3E-6176 -> 1E-6176 Subnormal
+dqrem434 remainder 1E-6175 4E-6176 -> 2E-6176 Subnormal
+dqrem435 remainder 1E-6175 5E-6176 -> 0E-6176
+dqrem436 remainder 1E-6175 6E-6176 -> 4E-6176 Subnormal
+dqrem437 remainder 1E-6175 7E-6176 -> 3E-6176 Subnormal
+dqrem438 remainder 1E-6175 8E-6176 -> 2E-6176 Subnormal
+dqrem439 remainder 1E-6175 9E-6176 -> 1E-6176 Subnormal
+dqrem440 remainder 1E-6175 10E-6176 -> 0E-6176
+dqrem441 remainder 1E-6175 11E-6176 -> 1.0E-6175 Subnormal
+dqrem442 remainder 100E-6175 11E-6176 -> 1.0E-6175 Subnormal
+dqrem443 remainder 100E-6175 20E-6176 -> 0E-6176
+dqrem444 remainder 100E-6175 21E-6176 -> 1.3E-6175 Subnormal
+dqrem445 remainder 100E-6175 30E-6176 -> 1.0E-6175 Subnormal
+
+-- zero signs
+dqrem650 remainder 1 1 -> 0
+dqrem651 remainder -1 1 -> -0
+dqrem652 remainder 1 -1 -> 0
+dqrem653 remainder -1 -1 -> -0
+dqrem654 remainder 0 1 -> 0
+dqrem655 remainder -0 1 -> -0
+dqrem656 remainder 0 -1 -> 0
+dqrem657 remainder -0 -1 -> -0
+dqrem658 remainder 0.00 1 -> 0.00
+dqrem659 remainder -0.00 1 -> -0.00
+
+-- Specials
+dqrem680 remainder Inf -Inf -> NaN Invalid_operation
+dqrem681 remainder Inf -1000 -> NaN Invalid_operation
+dqrem682 remainder Inf -1 -> NaN Invalid_operation
+dqrem683 remainder Inf 0 -> NaN Invalid_operation
+dqrem684 remainder Inf -0 -> NaN Invalid_operation
+dqrem685 remainder Inf 1 -> NaN Invalid_operation
+dqrem686 remainder Inf 1000 -> NaN Invalid_operation
+dqrem687 remainder Inf Inf -> NaN Invalid_operation
+dqrem688 remainder -1000 Inf -> -1000
+dqrem689 remainder -Inf Inf -> NaN Invalid_operation
+dqrem691 remainder -1 Inf -> -1
+dqrem692 remainder 0 Inf -> 0
+dqrem693 remainder -0 Inf -> -0
+dqrem694 remainder 1 Inf -> 1
+dqrem695 remainder 1000 Inf -> 1000
+dqrem696 remainder Inf Inf -> NaN Invalid_operation
+
+dqrem700 remainder -Inf -Inf -> NaN Invalid_operation
+dqrem701 remainder -Inf -1000 -> NaN Invalid_operation
+dqrem702 remainder -Inf -1 -> NaN Invalid_operation
+dqrem703 remainder -Inf -0 -> NaN Invalid_operation
+dqrem704 remainder -Inf 0 -> NaN Invalid_operation
+dqrem705 remainder -Inf 1 -> NaN Invalid_operation
+dqrem706 remainder -Inf 1000 -> NaN Invalid_operation
+dqrem707 remainder -Inf Inf -> NaN Invalid_operation
+dqrem708 remainder -Inf -Inf -> NaN Invalid_operation
+dqrem709 remainder -1000 Inf -> -1000
+dqrem710 remainder -1 -Inf -> -1
+dqrem711 remainder -0 -Inf -> -0
+dqrem712 remainder 0 -Inf -> 0
+dqrem713 remainder 1 -Inf -> 1
+dqrem714 remainder 1000 -Inf -> 1000
+dqrem715 remainder Inf -Inf -> NaN Invalid_operation
+
+dqrem721 remainder NaN -Inf -> NaN
+dqrem722 remainder NaN -1000 -> NaN
+dqrem723 remainder NaN -1 -> NaN
+dqrem724 remainder NaN -0 -> NaN
+dqrem725 remainder -NaN 0 -> -NaN
+dqrem726 remainder NaN 1 -> NaN
+dqrem727 remainder NaN 1000 -> NaN
+dqrem728 remainder NaN Inf -> NaN
+dqrem729 remainder NaN -NaN -> NaN
+dqrem730 remainder -Inf NaN -> NaN
+dqrem731 remainder -1000 NaN -> NaN
+dqrem732 remainder -1 NaN -> NaN
+dqrem733 remainder -0 -NaN -> -NaN
+dqrem734 remainder 0 NaN -> NaN
+dqrem735 remainder 1 -NaN -> -NaN
+dqrem736 remainder 1000 NaN -> NaN
+dqrem737 remainder Inf NaN -> NaN
+
+dqrem741 remainder sNaN -Inf -> NaN Invalid_operation
+dqrem742 remainder sNaN -1000 -> NaN Invalid_operation
+dqrem743 remainder -sNaN -1 -> -NaN Invalid_operation
+dqrem744 remainder sNaN -0 -> NaN Invalid_operation
+dqrem745 remainder sNaN 0 -> NaN Invalid_operation
+dqrem746 remainder sNaN 1 -> NaN Invalid_operation
+dqrem747 remainder sNaN 1000 -> NaN Invalid_operation
+dqrem749 remainder sNaN NaN -> NaN Invalid_operation
+dqrem750 remainder sNaN sNaN -> NaN Invalid_operation
+dqrem751 remainder NaN sNaN -> NaN Invalid_operation
+dqrem752 remainder -Inf sNaN -> NaN Invalid_operation
+dqrem753 remainder -1000 sNaN -> NaN Invalid_operation
+dqrem754 remainder -1 sNaN -> NaN Invalid_operation
+dqrem755 remainder -0 sNaN -> NaN Invalid_operation
+dqrem756 remainder 0 sNaN -> NaN Invalid_operation
+dqrem757 remainder 1 sNaN -> NaN Invalid_operation
+dqrem758 remainder 1000 sNaN -> NaN Invalid_operation
+dqrem759 remainder Inf -sNaN -> -NaN Invalid_operation
+
+-- propaging NaNs
+dqrem760 remainder NaN1 NaN7 -> NaN1
+dqrem761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation
+dqrem762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation
+dqrem763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation
+dqrem764 remainder 15 NaN11 -> NaN11
+dqrem765 remainder NaN6 NaN12 -> NaN6
+dqrem766 remainder Inf NaN13 -> NaN13
+dqrem767 remainder NaN14 -Inf -> NaN14
+dqrem768 remainder 0 NaN15 -> NaN15
+dqrem769 remainder NaN16 -0 -> NaN16
+
+-- edge cases of impossible
+dqrem770 remainder 1234568888888887777777777890123456 10 -> 6
+dqrem771 remainder 1234568888888887777777777890123456 1 -> 0
+dqrem772 remainder 1234568888888887777777777890123456 0.1 -> NaN Division_impossible
+dqrem773 remainder 1234568888888887777777777890123456 0.01 -> NaN Division_impossible
+
+-- long operand checks
+dqrem801 remainder 12345678000 100 -> 0
+dqrem802 remainder 1 12345678000 -> 1
+dqrem803 remainder 1234567800 10 -> 0
+dqrem804 remainder 1 1234567800 -> 1
+dqrem805 remainder 1234567890 10 -> 0
+dqrem806 remainder 1 1234567890 -> 1
+dqrem807 remainder 1234567891 10 -> 1
+dqrem808 remainder 1 1234567891 -> 1
+dqrem809 remainder 12345678901 100 -> 1
+dqrem810 remainder 1 12345678901 -> 1
+dqrem811 remainder 1234567896 10 -> 6
+dqrem812 remainder 1 1234567896 -> 1
+
+dqrem821 remainder 12345678000 100 -> 0
+dqrem822 remainder 1 12345678000 -> 1
+dqrem823 remainder 1234567800 10 -> 0
+dqrem824 remainder 1 1234567800 -> 1
+dqrem825 remainder 1234567890 10 -> 0
+dqrem826 remainder 1 1234567890 -> 1
+dqrem827 remainder 1234567891 10 -> 1
+dqrem828 remainder 1 1234567891 -> 1
+dqrem829 remainder 12345678901 100 -> 1
+dqrem830 remainder 1 12345678901 -> 1
+dqrem831 remainder 1234567896 10 -> 6
+dqrem832 remainder 1 1234567896 -> 1
+
+-- from divideint
+dqrem840 remainder 100000000.0 1 -> 0.0
+dqrem841 remainder 100000000.4 1 -> 0.4
+dqrem842 remainder 100000000.5 1 -> 0.5
+dqrem843 remainder 100000000.9 1 -> 0.9
+dqrem844 remainder 100000000.999 1 -> 0.999
+dqrem850 remainder 100000003 5 -> 3
+dqrem851 remainder 10000003 5 -> 3
+dqrem852 remainder 1000003 5 -> 3
+dqrem853 remainder 100003 5 -> 3
+dqrem854 remainder 10003 5 -> 3
+dqrem855 remainder 1003 5 -> 3
+dqrem856 remainder 103 5 -> 3
+dqrem857 remainder 13 5 -> 3
+dqrem858 remainder 1 5 -> 1
+
+-- Vladimir's cases 1234567890123456
+dqrem860 remainder 123.0e1 1000000000000000 -> 1230
+dqrem861 remainder 1230 1000000000000000 -> 1230
+dqrem862 remainder 12.3e2 1000000000000000 -> 1230
+dqrem863 remainder 1.23e3 1000000000000000 -> 1230
+dqrem864 remainder 123e1 1000000000000000 -> 1230
+dqrem870 remainder 123e1 1000000000000000 -> 1230
+dqrem871 remainder 123e1 100000000000000 -> 1230
+dqrem872 remainder 123e1 10000000000000 -> 1230
+dqrem873 remainder 123e1 1000000000000 -> 1230
+dqrem874 remainder 123e1 100000000000 -> 1230
+dqrem875 remainder 123e1 10000000000 -> 1230
+dqrem876 remainder 123e1 1000000000 -> 1230
+dqrem877 remainder 123e1 100000000 -> 1230
+dqrem878 remainder 1230 100000000 -> 1230
+dqrem879 remainder 123e1 10000000 -> 1230
+dqrem880 remainder 123e1 1000000 -> 1230
+dqrem881 remainder 123e1 100000 -> 1230
+dqrem882 remainder 123e1 10000 -> 1230
+dqrem883 remainder 123e1 1000 -> 230
+dqrem884 remainder 123e1 100 -> 30
+dqrem885 remainder 123e1 10 -> 0
+dqrem886 remainder 123e1 1 -> 0
+
+dqrem890 remainder 123e1 2000000000000000 -> 1230
+dqrem891 remainder 123e1 200000000000000 -> 1230
+dqrem892 remainder 123e1 20000000000000 -> 1230
+dqrem893 remainder 123e1 2000000000000 -> 1230
+dqrem894 remainder 123e1 200000000000 -> 1230
+dqrem895 remainder 123e1 20000000000 -> 1230
+dqrem896 remainder 123e1 2000000000 -> 1230
+dqrem897 remainder 123e1 200000000 -> 1230
+dqrem899 remainder 123e1 20000000 -> 1230
+dqrem900 remainder 123e1 2000000 -> 1230
+dqrem901 remainder 123e1 200000 -> 1230
+dqrem902 remainder 123e1 20000 -> 1230
+dqrem903 remainder 123e1 2000 -> 1230
+dqrem904 remainder 123e1 200 -> 30
+dqrem905 remainder 123e1 20 -> 10
+dqrem906 remainder 123e1 2 -> 0
+
+dqrem910 remainder 123e1 5000000000000000 -> 1230
+dqrem911 remainder 123e1 500000000000000 -> 1230
+dqrem912 remainder 123e1 50000000000000 -> 1230
+dqrem913 remainder 123e1 5000000000000 -> 1230
+dqrem914 remainder 123e1 500000000000 -> 1230
+dqrem915 remainder 123e1 50000000000 -> 1230
+dqrem916 remainder 123e1 5000000000 -> 1230
+dqrem917 remainder 123e1 500000000 -> 1230
+dqrem919 remainder 123e1 50000000 -> 1230
+dqrem920 remainder 123e1 5000000 -> 1230
+dqrem921 remainder 123e1 500000 -> 1230
+dqrem922 remainder 123e1 50000 -> 1230
+dqrem923 remainder 123e1 5000 -> 1230
+dqrem924 remainder 123e1 500 -> 230
+dqrem925 remainder 123e1 50 -> 30
+dqrem926 remainder 123e1 5 -> 0
+
+dqrem930 remainder 123e1 9000000000000000 -> 1230
+dqrem931 remainder 123e1 900000000000000 -> 1230
+dqrem932 remainder 123e1 90000000000000 -> 1230
+dqrem933 remainder 123e1 9000000000000 -> 1230
+dqrem934 remainder 123e1 900000000000 -> 1230
+dqrem935 remainder 123e1 90000000000 -> 1230
+dqrem936 remainder 123e1 9000000000 -> 1230
+dqrem937 remainder 123e1 900000000 -> 1230
+dqrem939 remainder 123e1 90000000 -> 1230
+dqrem940 remainder 123e1 9000000 -> 1230
+dqrem941 remainder 123e1 900000 -> 1230
+dqrem942 remainder 123e1 90000 -> 1230
+dqrem943 remainder 123e1 9000 -> 1230
+dqrem944 remainder 123e1 900 -> 330
+dqrem945 remainder 123e1 90 -> 60
+dqrem946 remainder 123e1 9 -> 6
+
+dqrem950 remainder 123e1 1000000000000000 -> 1230
+dqrem961 remainder 123e1 2999999999999999 -> 1230
+dqrem962 remainder 123e1 3999999999999999 -> 1230
+dqrem963 remainder 123e1 4999999999999999 -> 1230
+dqrem964 remainder 123e1 5999999999999999 -> 1230
+dqrem965 remainder 123e1 6999999999999999 -> 1230
+dqrem966 remainder 123e1 7999999999999999 -> 1230
+dqrem967 remainder 123e1 8999999999999999 -> 1230
+dqrem968 remainder 123e1 9999999999999999 -> 1230
+dqrem969 remainder 123e1 9876543210987654 -> 1230
+
+dqrem980 remainder 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
+
+-- overflow and underflow tests [from divide]
+dqrem1051 remainder 1e+277 1e-311 -> NaN Division_impossible
+dqrem1052 remainder 1e+277 -1e-311 -> NaN Division_impossible
+dqrem1053 remainder -1e+277 1e-311 -> NaN Division_impossible
+dqrem1054 remainder -1e+277 -1e-311 -> NaN Division_impossible
+dqrem1055 remainder 1e-277 1e+311 -> 1E-277
+dqrem1056 remainder 1e-277 -1e+311 -> 1E-277
+dqrem1057 remainder -1e-277 1e+311 -> -1E-277
+dqrem1058 remainder -1e-277 -1e+311 -> -1E-277
+
+-- Gyuris example
+dqrem1070 remainder 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 8.336804418094040989630006819881709E-6143
+
+-- destructive subtract
+dqrem1120 remainder 1234567890123456789012345678901234 1.000000000000000000000000000000001 -> 0.765432109876543210987654321098768
+dqrem1121 remainder 1234567890123456789012345678901234 1.00000000000000000000000000000001 -> 0.65432109876543210987654321098779
+dqrem1122 remainder 1234567890123456789012345678901234 1.0000000000000000000000000000001 -> 0.5432109876543210987654321098890
+dqrem1123 remainder 1234567890123456789012345678901255 4.000000000000000000000000000000001 -> 2.691358027469135802746913580274687
+dqrem1124 remainder 1234567890123456789012345678901234 4.000000000000000000000000000000001 -> 1.691358027469135802746913580274692
+dqrem1125 remainder 1234567890123456789012345678901234 4.9999999999999999999999999999999 -> 3.6913578024691357802469135780251
+dqrem1126 remainder 1234567890123456789012345678901234 4.99999999999999999999999999999999 -> 1.46913578024691357802469135780247
+dqrem1127 remainder 1234567890123456789012345678901234 4.999999999999999999999999999999999 -> 4.246913578024691357802469135780246
+dqrem1128 remainder 1234567890123456789012345678901234 5.0000000000000000000000000000001 -> 4.3086421975308642197530864219759
+
+-- Null tests
+dqrem1000 remainder 10 # -> NaN Invalid_operation
+dqrem1001 remainder # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqRemainderNear.decTest b/Lib/test/decimaltestdata/dqRemainderNear.decTest
index 0dd273fe38..b850626fe4 100644
--- a/Lib/test/decimaltestdata/dqRemainderNear.decTest
+++ b/Lib/test/decimaltestdata/dqRemainderNear.decTest
@@ -1,631 +1,631 @@
-------------------------------------------------------------------------
--- dqRemainderNear.decTest -- decQuad remainder-near --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks (as base, above)
-dqrmn001 remaindernear 1 1 -> 0
-dqrmn002 remaindernear 2 1 -> 0
-dqrmn003 remaindernear 1 2 -> 1
-dqrmn004 remaindernear 2 2 -> 0
-dqrmn005 remaindernear 0 1 -> 0
-dqrmn006 remaindernear 0 2 -> 0
-dqrmn007 remaindernear 1 3 -> 1
-dqrmn008 remaindernear 2 3 -> -1
-dqrmn009 remaindernear 3 3 -> 0
-
-dqrmn010 remaindernear 2.4 1 -> 0.4
-dqrmn011 remaindernear 2.4 -1 -> 0.4
-dqrmn012 remaindernear -2.4 1 -> -0.4
-dqrmn013 remaindernear -2.4 -1 -> -0.4
-dqrmn014 remaindernear 2.40 1 -> 0.40
-dqrmn015 remaindernear 2.400 1 -> 0.400
-dqrmn016 remaindernear 2.4 2 -> 0.4
-dqrmn017 remaindernear 2.400 2 -> 0.400
-dqrmn018 remaindernear 2. 2 -> 0
-dqrmn019 remaindernear 20 20 -> 0
-
-dqrmn020 remaindernear 187 187 -> 0
-dqrmn021 remaindernear 5 2 -> 1
-dqrmn022 remaindernear 5 2.0 -> 1.0
-dqrmn023 remaindernear 5 2.000 -> 1.000
-dqrmn024 remaindernear 5 0.200 -> 0.000
-dqrmn025 remaindernear 5 0.200 -> 0.000
-
-dqrmn030 remaindernear 1 2 -> 1
-dqrmn031 remaindernear 1 4 -> 1
-dqrmn032 remaindernear 1 8 -> 1
-
-dqrmn033 remaindernear 1 16 -> 1
-dqrmn034 remaindernear 1 32 -> 1
-dqrmn035 remaindernear 1 64 -> 1
-dqrmn040 remaindernear 1 -2 -> 1
-dqrmn041 remaindernear 1 -4 -> 1
-dqrmn042 remaindernear 1 -8 -> 1
-dqrmn043 remaindernear 1 -16 -> 1
-dqrmn044 remaindernear 1 -32 -> 1
-dqrmn045 remaindernear 1 -64 -> 1
-dqrmn050 remaindernear -1 2 -> -1
-dqrmn051 remaindernear -1 4 -> -1
-dqrmn052 remaindernear -1 8 -> -1
-dqrmn053 remaindernear -1 16 -> -1
-dqrmn054 remaindernear -1 32 -> -1
-dqrmn055 remaindernear -1 64 -> -1
-dqrmn060 remaindernear -1 -2 -> -1
-dqrmn061 remaindernear -1 -4 -> -1
-dqrmn062 remaindernear -1 -8 -> -1
-dqrmn063 remaindernear -1 -16 -> -1
-dqrmn064 remaindernear -1 -32 -> -1
-dqrmn065 remaindernear -1 -64 -> -1
-
-dqrmn066 remaindernear 9.9 1 -> -0.1
-dqrmn067 remaindernear 99.7 1 -> -0.3
-dqrmn068 remaindernear 999999999 1 -> 0
-dqrmn069 remaindernear 999999999.4 1 -> 0.4
-dqrmn070 remaindernear 999999999.5 1 -> -0.5
-dqrmn071 remaindernear 999999999.9 1 -> -0.1
-dqrmn072 remaindernear 999999999.999 1 -> -0.001
-dqrmn073 remaindernear 999999.999999 1 -> -0.000001
-dqrmn074 remaindernear 9 1 -> 0
-dqrmn075 remaindernear 9999999999999999 1 -> 0
-dqrmn076 remaindernear 9999999999999999 2 -> -1
-dqrmn077 remaindernear 9999999999999999 3 -> 0
-dqrmn078 remaindernear 9999999999999999 4 -> -1
-
-dqrmn080 remaindernear 0. 1 -> 0
-dqrmn081 remaindernear .0 1 -> 0.0
-dqrmn082 remaindernear 0.00 1 -> 0.00
-dqrmn083 remaindernear 0.00E+9 1 -> 0
-dqrmn084 remaindernear 0.00E+3 1 -> 0
-dqrmn085 remaindernear 0.00E+2 1 -> 0
-dqrmn086 remaindernear 0.00E+1 1 -> 0.0
-dqrmn087 remaindernear 0.00E+0 1 -> 0.00
-dqrmn088 remaindernear 0.00E-0 1 -> 0.00
-dqrmn089 remaindernear 0.00E-1 1 -> 0.000
-dqrmn090 remaindernear 0.00E-2 1 -> 0.0000
-dqrmn091 remaindernear 0.00E-3 1 -> 0.00000
-dqrmn092 remaindernear 0.00E-4 1 -> 0.000000
-dqrmn093 remaindernear 0.00E-5 1 -> 0E-7
-dqrmn094 remaindernear 0.00E-6 1 -> 0E-8
-dqrmn095 remaindernear 0.0000E-50 1 -> 0E-54
-
--- Various flavours of remaindernear by 0
-dqrmn101 remaindernear 0 0 -> NaN Division_undefined
-dqrmn102 remaindernear 0 -0 -> NaN Division_undefined
-dqrmn103 remaindernear -0 0 -> NaN Division_undefined
-dqrmn104 remaindernear -0 -0 -> NaN Division_undefined
-dqrmn105 remaindernear 0.0E5 0 -> NaN Division_undefined
-dqrmn106 remaindernear 0.000 0 -> NaN Division_undefined
--- [Some think this next group should be Division_by_zero exception, but
--- IEEE 854 is explicit that it is Invalid operation .. for
--- remainder-near, anyway]
-dqrmn107 remaindernear 0.0001 0 -> NaN Invalid_operation
-dqrmn108 remaindernear 0.01 0 -> NaN Invalid_operation
-dqrmn109 remaindernear 0.1 0 -> NaN Invalid_operation
-dqrmn110 remaindernear 1 0 -> NaN Invalid_operation
-dqrmn111 remaindernear 1 0.0 -> NaN Invalid_operation
-dqrmn112 remaindernear 10 0.0 -> NaN Invalid_operation
-dqrmn113 remaindernear 1E+100 0.0 -> NaN Invalid_operation
-dqrmn114 remaindernear 1E+380 0 -> NaN Invalid_operation
-dqrmn115 remaindernear 0.0001 -0 -> NaN Invalid_operation
-dqrmn116 remaindernear 0.01 -0 -> NaN Invalid_operation
-dqrmn119 remaindernear 0.1 -0 -> NaN Invalid_operation
-dqrmn120 remaindernear 1 -0 -> NaN Invalid_operation
-dqrmn121 remaindernear 1 -0.0 -> NaN Invalid_operation
-dqrmn122 remaindernear 10 -0.0 -> NaN Invalid_operation
-dqrmn123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation
-dqrmn124 remaindernear 1E+384 -0 -> NaN Invalid_operation
--- and zeros on left
-dqrmn130 remaindernear 0 1 -> 0
-dqrmn131 remaindernear 0 -1 -> 0
-dqrmn132 remaindernear 0.0 1 -> 0.0
-dqrmn133 remaindernear 0.0 -1 -> 0.0
-dqrmn134 remaindernear -0 1 -> -0
-dqrmn135 remaindernear -0 -1 -> -0
-dqrmn136 remaindernear -0.0 1 -> -0.0
-dqrmn137 remaindernear -0.0 -1 -> -0.0
-
--- 0.5ers
-dqrmn143 remaindernear 0.5 2 -> 0.5
-dqrmn144 remaindernear 0.5 2.1 -> 0.5
-dqrmn145 remaindernear 0.5 2.01 -> 0.50
-dqrmn146 remaindernear 0.5 2.001 -> 0.500
-dqrmn147 remaindernear 0.50 2 -> 0.50
-dqrmn148 remaindernear 0.50 2.01 -> 0.50
-dqrmn149 remaindernear 0.50 2.001 -> 0.500
-
--- steadies
-dqrmn150 remaindernear 1 1 -> 0
-dqrmn151 remaindernear 1 2 -> 1
-dqrmn152 remaindernear 1 3 -> 1
-dqrmn153 remaindernear 1 4 -> 1
-dqrmn154 remaindernear 1 5 -> 1
-dqrmn155 remaindernear 1 6 -> 1
-dqrmn156 remaindernear 1 7 -> 1
-dqrmn157 remaindernear 1 8 -> 1
-dqrmn158 remaindernear 1 9 -> 1
-dqrmn159 remaindernear 1 10 -> 1
-dqrmn160 remaindernear 1 1 -> 0
-dqrmn161 remaindernear 2 1 -> 0
-dqrmn162 remaindernear 3 1 -> 0
-dqrmn163 remaindernear 4 1 -> 0
-dqrmn164 remaindernear 5 1 -> 0
-dqrmn165 remaindernear 6 1 -> 0
-dqrmn166 remaindernear 7 1 -> 0
-dqrmn167 remaindernear 8 1 -> 0
-dqrmn168 remaindernear 9 1 -> 0
-dqrmn169 remaindernear 10 1 -> 0
-
--- some differences from remainder
-dqrmn171 remaindernear 0.4 1.020 -> 0.400
-dqrmn172 remaindernear 0.50 1.020 -> 0.500
-dqrmn173 remaindernear 0.51 1.020 -> 0.510
-dqrmn174 remaindernear 0.52 1.020 -> -0.500
-dqrmn175 remaindernear 0.6 1.020 -> -0.420
-
--- More flavours of remaindernear by 0
-dqrmn201 remaindernear 0 0 -> NaN Division_undefined
-dqrmn202 remaindernear 0.0E5 0 -> NaN Division_undefined
-dqrmn203 remaindernear 0.000 0 -> NaN Division_undefined
-dqrmn204 remaindernear 0.0001 0 -> NaN Invalid_operation
-dqrmn205 remaindernear 0.01 0 -> NaN Invalid_operation
-dqrmn206 remaindernear 0.1 0 -> NaN Invalid_operation
-dqrmn207 remaindernear 1 0 -> NaN Invalid_operation
-dqrmn208 remaindernear 1 0.0 -> NaN Invalid_operation
-dqrmn209 remaindernear 10 0.0 -> NaN Invalid_operation
-dqrmn210 remaindernear 1E+100 0.0 -> NaN Invalid_operation
-dqrmn211 remaindernear 1E+380 0 -> NaN Invalid_operation
-
--- tests from the extended specification
-dqrmn221 remaindernear 2.1 3 -> -0.9
-dqrmn222 remaindernear 10 6 -> -2
-dqrmn223 remaindernear 10 3 -> 1
-dqrmn224 remaindernear -10 3 -> -1
-dqrmn225 remaindernear 10.2 1 -> 0.2
-dqrmn226 remaindernear 10 0.3 -> 0.1
-dqrmn227 remaindernear 3.6 1.3 -> -0.3
-
--- some differences from remainder
-dqrmn231 remaindernear -0.4 1.020 -> -0.400
-dqrmn232 remaindernear -0.50 1.020 -> -0.500
-dqrmn233 remaindernear -0.51 1.020 -> -0.510
-dqrmn234 remaindernear -0.52 1.020 -> 0.500
-dqrmn235 remaindernear -0.6 1.020 -> 0.420
-
--- high Xs
-dqrmn240 remaindernear 1E+2 1.00 -> 0.00
-
--- dqrmn3xx are from DiagBigDecimal
-dqrmn301 remaindernear 1 3 -> 1
-dqrmn302 remaindernear 5 5 -> 0
-dqrmn303 remaindernear 13 10 -> 3
-dqrmn304 remaindernear 13 50 -> 13
-dqrmn305 remaindernear 13 100 -> 13
-dqrmn306 remaindernear 13 1000 -> 13
-dqrmn307 remaindernear .13 1 -> 0.13
-dqrmn308 remaindernear 0.133 1 -> 0.133
-dqrmn309 remaindernear 0.1033 1 -> 0.1033
-dqrmn310 remaindernear 1.033 1 -> 0.033
-dqrmn311 remaindernear 10.33 1 -> 0.33
-dqrmn312 remaindernear 10.33 10 -> 0.33
-dqrmn313 remaindernear 103.3 1 -> 0.3
-dqrmn314 remaindernear 133 10 -> 3
-dqrmn315 remaindernear 1033 10 -> 3
-dqrmn316 remaindernear 1033 50 -> -17
-dqrmn317 remaindernear 101.0 3 -> -1.0
-dqrmn318 remaindernear 102.0 3 -> 0.0
-dqrmn319 remaindernear 103.0 3 -> 1.0
-dqrmn320 remaindernear 2.40 1 -> 0.40
-dqrmn321 remaindernear 2.400 1 -> 0.400
-dqrmn322 remaindernear 2.4 1 -> 0.4
-dqrmn323 remaindernear 2.4 2 -> 0.4
-dqrmn324 remaindernear 2.400 2 -> 0.400
-dqrmn325 remaindernear 1 0.3 -> 0.1
-dqrmn326 remaindernear 1 0.30 -> 0.10
-dqrmn327 remaindernear 1 0.300 -> 0.100
-dqrmn328 remaindernear 1 0.3000 -> 0.1000
-dqrmn329 remaindernear 1.0 0.3 -> 0.1
-dqrmn330 remaindernear 1.00 0.3 -> 0.10
-dqrmn331 remaindernear 1.000 0.3 -> 0.100
-dqrmn332 remaindernear 1.0000 0.3 -> 0.1000
-dqrmn333 remaindernear 0.5 2 -> 0.5
-dqrmn334 remaindernear 0.5 2.1 -> 0.5
-dqrmn335 remaindernear 0.5 2.01 -> 0.50
-dqrmn336 remaindernear 0.5 2.001 -> 0.500
-dqrmn337 remaindernear 0.50 2 -> 0.50
-dqrmn338 remaindernear 0.50 2.01 -> 0.50
-dqrmn339 remaindernear 0.50 2.001 -> 0.500
-
-dqrmn340 remaindernear 0.5 0.5000001 -> -1E-7
-dqrmn341 remaindernear 0.5 0.50000001 -> -1E-8
-dqrmn342 remaindernear 0.5 0.500000001 -> -1E-9
-dqrmn343 remaindernear 0.5 0.5000000001 -> -1E-10
-dqrmn344 remaindernear 0.5 0.50000000001 -> -1E-11
-dqrmn345 remaindernear 0.5 0.4999999 -> 1E-7
-dqrmn346 remaindernear 0.5 0.49999999 -> 1E-8
-dqrmn347 remaindernear 0.5 0.499999999 -> 1E-9
-dqrmn348 remaindernear 0.5 0.4999999999 -> 1E-10
-dqrmn349 remaindernear 0.5 0.49999999999 -> 1E-11
-dqrmn350 remaindernear 0.5 0.499999999999 -> 1E-12
-
-dqrmn351 remaindernear 0.03 7 -> 0.03
-dqrmn352 remaindernear 5 2 -> 1
-dqrmn353 remaindernear 4.1 2 -> 0.1
-dqrmn354 remaindernear 4.01 2 -> 0.01
-dqrmn355 remaindernear 4.001 2 -> 0.001
-dqrmn356 remaindernear 4.0001 2 -> 0.0001
-dqrmn357 remaindernear 4.00001 2 -> 0.00001
-dqrmn358 remaindernear 4.000001 2 -> 0.000001
-dqrmn359 remaindernear 4.0000001 2 -> 1E-7
-
-dqrmn360 remaindernear 1.2 0.7345 -> -0.2690
-dqrmn361 remaindernear 0.8 12 -> 0.8
-dqrmn362 remaindernear 0.8 0.2 -> 0.0
-dqrmn363 remaindernear 0.8 0.3 -> -0.1
-dqrmn364 remaindernear 0.800 12 -> 0.800
-dqrmn365 remaindernear 0.800 1.7 -> 0.800
-dqrmn366 remaindernear 2.400 2 -> 0.400
-
--- round to even
-dqrmn371 remaindernear 121 2 -> 1
-dqrmn372 remaindernear 122 2 -> 0
-dqrmn373 remaindernear 123 2 -> -1
-dqrmn374 remaindernear 124 2 -> 0
-dqrmn375 remaindernear 125 2 -> 1
-dqrmn376 remaindernear 126 2 -> 0
-dqrmn377 remaindernear 127 2 -> -1
-
-dqrmn381 remaindernear 12345 1 -> 0
-dqrmn382 remaindernear 12345 1.0001 -> -0.2344
-dqrmn383 remaindernear 12345 1.001 -> -0.333
-dqrmn384 remaindernear 12345 1.01 -> -0.23
-dqrmn385 remaindernear 12345 1.1 -> -0.3
-dqrmn386 remaindernear 12355 4 -> -1
-dqrmn387 remaindernear 12345 4 -> 1
-dqrmn388 remaindernear 12355 4.0001 -> -1.3089
-dqrmn389 remaindernear 12345 4.0001 -> 0.6914
-dqrmn390 remaindernear 12345 4.9 -> 1.9
-dqrmn391 remaindernear 12345 4.99 -> -0.26
-dqrmn392 remaindernear 12345 4.999 -> 2.469
-dqrmn393 remaindernear 12345 4.9999 -> 0.2469
-dqrmn394 remaindernear 12345 5 -> 0
-dqrmn395 remaindernear 12345 5.0001 -> -0.2469
-dqrmn396 remaindernear 12345 5.001 -> -2.469
-dqrmn397 remaindernear 12345 5.01 -> 0.36
-dqrmn398 remaindernear 12345 5.1 -> -2.1
-
--- the nasty division-by-1 cases
-dqrmn401 remaindernear 0.4 1 -> 0.4
-dqrmn402 remaindernear 0.45 1 -> 0.45
-dqrmn403 remaindernear 0.455 1 -> 0.455
-dqrmn404 remaindernear 0.4555 1 -> 0.4555
-dqrmn405 remaindernear 0.45555 1 -> 0.45555
-dqrmn406 remaindernear 0.455555 1 -> 0.455555
-dqrmn407 remaindernear 0.4555555 1 -> 0.4555555
-dqrmn408 remaindernear 0.45555555 1 -> 0.45555555
-dqrmn409 remaindernear 0.455555555 1 -> 0.455555555
--- with spill... [412 exercises sticktab loop]
-dqrmn411 remaindernear 0.5 1 -> 0.5
-dqrmn412 remaindernear 0.55 1 -> -0.45
-dqrmn413 remaindernear 0.555 1 -> -0.445
-dqrmn414 remaindernear 0.5555 1 -> -0.4445
-dqrmn415 remaindernear 0.55555 1 -> -0.44445
-dqrmn416 remaindernear 0.555555 1 -> -0.444445
-dqrmn417 remaindernear 0.5555555 1 -> -0.4444445
-dqrmn418 remaindernear 0.55555555 1 -> -0.44444445
-dqrmn419 remaindernear 0.555555555 1 -> -0.444444445
-
--- folddowns
-dqrmn421 remaindernear 1E+6144 1 -> NaN Division_impossible
-dqrmn422 remaindernear 1E+6144 1E+6143 -> 0E+6111 Clamped
-dqrmn423 remaindernear 1E+6144 2E+6143 -> 0E+6111 Clamped
-dqrmn424 remaindernear 1E+6144 3E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqrmn425 remaindernear 1E+6144 4E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
-dqrmn426 remaindernear 1E+6144 5E+6143 -> 0E+6111 Clamped
-dqrmn427 remaindernear 1E+6144 6E+6143 -> -2.00000000000000000000000000000000E+6143 Clamped
-dqrmn428 remaindernear 1E+6144 7E+6143 -> 3.00000000000000000000000000000000E+6143 Clamped
-dqrmn429 remaindernear 1E+6144 8E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
-dqrmn430 remaindernear 1E+6144 9E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
--- tinies
-dqrmn431 remaindernear 1E-6175 1E-6176 -> 0E-6176
-dqrmn432 remaindernear 1E-6175 2E-6176 -> 0E-6176
-dqrmn433 remaindernear 1E-6175 3E-6176 -> 1E-6176 Subnormal
-dqrmn434 remaindernear 1E-6175 4E-6176 -> 2E-6176 Subnormal
-dqrmn435 remaindernear 1E-6175 5E-6176 -> 0E-6176
-dqrmn436 remaindernear 1E-6175 6E-6176 -> -2E-6176 Subnormal
-dqrmn437 remaindernear 1E-6175 7E-6176 -> 3E-6176 Subnormal
-dqrmn438 remaindernear 1E-6175 8E-6176 -> 2E-6176 Subnormal
-dqrmn439 remaindernear 1E-6175 9E-6176 -> 1E-6176 Subnormal
-dqrmn440 remaindernear 1E-6175 10E-6176 -> 0E-6176
-dqrmn441 remaindernear 1E-6175 11E-6176 -> -1E-6176 Subnormal
-dqrmn442 remaindernear 100E-6175 11E-6176 -> -1E-6176 Subnormal
-dqrmn443 remaindernear 100E-6175 20E-6176 -> 0E-6176
-dqrmn444 remaindernear 100E-6175 21E-6176 -> -8E-6176 Subnormal
-dqrmn445 remaindernear 100E-6175 30E-6176 -> 1.0E-6175 Subnormal
-
--- zero signs
-dqrmn650 remaindernear 1 1 -> 0
-dqrmn651 remaindernear -1 1 -> -0
-dqrmn652 remaindernear 1 -1 -> 0
-dqrmn653 remaindernear -1 -1 -> -0
-dqrmn654 remaindernear 0 1 -> 0
-dqrmn655 remaindernear -0 1 -> -0
-dqrmn656 remaindernear 0 -1 -> 0
-dqrmn657 remaindernear -0 -1 -> -0
-dqrmn658 remaindernear 0.00 1 -> 0.00
-dqrmn659 remaindernear -0.00 1 -> -0.00
-
--- Specials
-dqrmn680 remaindernear Inf -Inf -> NaN Invalid_operation
-dqrmn681 remaindernear Inf -1000 -> NaN Invalid_operation
-dqrmn682 remaindernear Inf -1 -> NaN Invalid_operation
-dqrmn683 remaindernear Inf 0 -> NaN Invalid_operation
-dqrmn684 remaindernear Inf -0 -> NaN Invalid_operation
-dqrmn685 remaindernear Inf 1 -> NaN Invalid_operation
-dqrmn686 remaindernear Inf 1000 -> NaN Invalid_operation
-dqrmn687 remaindernear Inf Inf -> NaN Invalid_operation
-dqrmn688 remaindernear -1000 Inf -> -1000
-dqrmn689 remaindernear -Inf Inf -> NaN Invalid_operation
-dqrmn691 remaindernear -1 Inf -> -1
-dqrmn692 remaindernear 0 Inf -> 0
-dqrmn693 remaindernear -0 Inf -> -0
-dqrmn694 remaindernear 1 Inf -> 1
-dqrmn695 remaindernear 1000 Inf -> 1000
-dqrmn696 remaindernear Inf Inf -> NaN Invalid_operation
-
-dqrmn700 remaindernear -Inf -Inf -> NaN Invalid_operation
-dqrmn701 remaindernear -Inf -1000 -> NaN Invalid_operation
-dqrmn702 remaindernear -Inf -1 -> NaN Invalid_operation
-dqrmn703 remaindernear -Inf -0 -> NaN Invalid_operation
-dqrmn704 remaindernear -Inf 0 -> NaN Invalid_operation
-dqrmn705 remaindernear -Inf 1 -> NaN Invalid_operation
-dqrmn706 remaindernear -Inf 1000 -> NaN Invalid_operation
-dqrmn707 remaindernear -Inf Inf -> NaN Invalid_operation
-dqrmn708 remaindernear -Inf -Inf -> NaN Invalid_operation
-dqrmn709 remaindernear -1000 Inf -> -1000
-dqrmn710 remaindernear -1 -Inf -> -1
-dqrmn711 remaindernear -0 -Inf -> -0
-dqrmn712 remaindernear 0 -Inf -> 0
-dqrmn713 remaindernear 1 -Inf -> 1
-dqrmn714 remaindernear 1000 -Inf -> 1000
-dqrmn715 remaindernear Inf -Inf -> NaN Invalid_operation
-
-dqrmn721 remaindernear NaN -Inf -> NaN
-dqrmn722 remaindernear NaN -1000 -> NaN
-dqrmn723 remaindernear NaN -1 -> NaN
-dqrmn724 remaindernear NaN -0 -> NaN
-dqrmn725 remaindernear -NaN 0 -> -NaN
-dqrmn726 remaindernear NaN 1 -> NaN
-dqrmn727 remaindernear NaN 1000 -> NaN
-dqrmn728 remaindernear NaN Inf -> NaN
-dqrmn729 remaindernear NaN -NaN -> NaN
-dqrmn730 remaindernear -Inf NaN -> NaN
-dqrmn731 remaindernear -1000 NaN -> NaN
-dqrmn732 remaindernear -1 NaN -> NaN
-dqrmn733 remaindernear -0 -NaN -> -NaN
-dqrmn734 remaindernear 0 NaN -> NaN
-dqrmn735 remaindernear 1 -NaN -> -NaN
-dqrmn736 remaindernear 1000 NaN -> NaN
-dqrmn737 remaindernear Inf NaN -> NaN
-
-dqrmn741 remaindernear sNaN -Inf -> NaN Invalid_operation
-dqrmn742 remaindernear sNaN -1000 -> NaN Invalid_operation
-dqrmn743 remaindernear -sNaN -1 -> -NaN Invalid_operation
-dqrmn744 remaindernear sNaN -0 -> NaN Invalid_operation
-dqrmn745 remaindernear sNaN 0 -> NaN Invalid_operation
-dqrmn746 remaindernear sNaN 1 -> NaN Invalid_operation
-dqrmn747 remaindernear sNaN 1000 -> NaN Invalid_operation
-dqrmn749 remaindernear sNaN NaN -> NaN Invalid_operation
-dqrmn750 remaindernear sNaN sNaN -> NaN Invalid_operation
-dqrmn751 remaindernear NaN sNaN -> NaN Invalid_operation
-dqrmn752 remaindernear -Inf sNaN -> NaN Invalid_operation
-dqrmn753 remaindernear -1000 sNaN -> NaN Invalid_operation
-dqrmn754 remaindernear -1 sNaN -> NaN Invalid_operation
-dqrmn755 remaindernear -0 sNaN -> NaN Invalid_operation
-dqrmn756 remaindernear 0 sNaN -> NaN Invalid_operation
-dqrmn757 remaindernear 1 sNaN -> NaN Invalid_operation
-dqrmn758 remaindernear 1000 sNaN -> NaN Invalid_operation
-dqrmn759 remaindernear Inf -sNaN -> -NaN Invalid_operation
-
--- propaging NaNs
-dqrmn760 remaindernear NaN1 NaN7 -> NaN1
-dqrmn761 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation
-dqrmn762 remaindernear NaN3 sNaN9 -> NaN9 Invalid_operation
-dqrmn763 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation
-dqrmn764 remaindernear 15 NaN11 -> NaN11
-dqrmn765 remaindernear NaN6 NaN12 -> NaN6
-dqrmn766 remaindernear Inf NaN13 -> NaN13
-dqrmn767 remaindernear NaN14 -Inf -> NaN14
-dqrmn768 remaindernear 0 NaN15 -> NaN15
-dqrmn769 remaindernear NaN16 -0 -> NaN16
-
--- edge cases of impossible
-dqrmn770 remaindernear 1234500000000000000000067890123456 10 -> -4
-dqrmn771 remaindernear 1234500000000000000000067890123456 1 -> 0
-dqrmn772 remaindernear 1234500000000000000000067890123456 0.1 -> NaN Division_impossible
-dqrmn773 remaindernear 1234500000000000000000067890123456 0.01 -> NaN Division_impossible
-
--- long operand checks
-dqrmn801 remaindernear 12345678000 100 -> 0
-dqrmn802 remaindernear 1 12345678000 -> 1
-dqrmn803 remaindernear 1234567800 10 -> 0
-dqrmn804 remaindernear 1 1234567800 -> 1
-dqrmn805 remaindernear 1234567890 10 -> 0
-dqrmn806 remaindernear 1 1234567890 -> 1
-dqrmn807 remaindernear 1234567891 10 -> 1
-dqrmn808 remaindernear 1 1234567891 -> 1
-dqrmn809 remaindernear 12345678901 100 -> 1
-dqrmn810 remaindernear 1 12345678901 -> 1
-dqrmn811 remaindernear 1234567896 10 -> -4
-dqrmn812 remaindernear 1 1234567896 -> 1
-
-dqrmn821 remaindernear 12345678000 100 -> 0
-dqrmn822 remaindernear 1 12345678000 -> 1
-dqrmn823 remaindernear 1234567800 10 -> 0
-dqrmn824 remaindernear 1 1234567800 -> 1
-dqrmn825 remaindernear 1234567890 10 -> 0
-dqrmn826 remaindernear 1 1234567890 -> 1
-dqrmn827 remaindernear 1234567891 10 -> 1
-dqrmn828 remaindernear 1 1234567891 -> 1
-dqrmn829 remaindernear 12345678901 100 -> 1
-dqrmn830 remaindernear 1 12345678901 -> 1
-dqrmn831 remaindernear 1234567896 10 -> -4
-dqrmn832 remaindernear 1 1234567896 -> 1
-
--- from divideint
-dqrmn840 remaindernear 100000000.0 1 -> 0.0
-dqrmn841 remaindernear 100000000.4 1 -> 0.4
-dqrmn842 remaindernear 100000000.5 1 -> 0.5
-dqrmn843 remaindernear 100000000.9 1 -> -0.1
-dqrmn844 remaindernear 100000000.999 1 -> -0.001
-dqrmn850 remaindernear 100000003 5 -> -2
-dqrmn851 remaindernear 10000003 5 -> -2
-dqrmn852 remaindernear 1000003 5 -> -2
-dqrmn853 remaindernear 100003 5 -> -2
-dqrmn854 remaindernear 10003 5 -> -2
-dqrmn855 remaindernear 1003 5 -> -2
-dqrmn856 remaindernear 103 5 -> -2
-dqrmn857 remaindernear 13 5 -> -2
-dqrmn858 remaindernear 1 5 -> 1
-
--- Vladimir's cases 1234567890123456
-dqrmn860 remaindernear 123.0e1 1000000000000000 -> 1230
-dqrmn861 remaindernear 1230 1000000000000000 -> 1230
-dqrmn862 remaindernear 12.3e2 1000000000000000 -> 1230
-dqrmn863 remaindernear 1.23e3 1000000000000000 -> 1230
-dqrmn864 remaindernear 123e1 1000000000000000 -> 1230
-dqrmn870 remaindernear 123e1 1000000000000000 -> 1230
-dqrmn871 remaindernear 123e1 100000000000000 -> 1230
-dqrmn872 remaindernear 123e1 10000000000000 -> 1230
-dqrmn873 remaindernear 123e1 1000000000000 -> 1230
-dqrmn874 remaindernear 123e1 100000000000 -> 1230
-dqrmn875 remaindernear 123e1 10000000000 -> 1230
-dqrmn876 remaindernear 123e1 1000000000 -> 1230
-dqrmn877 remaindernear 123e1 100000000 -> 1230
-dqrmn878 remaindernear 1230 100000000 -> 1230
-dqrmn879 remaindernear 123e1 10000000 -> 1230
-dqrmn880 remaindernear 123e1 1000000 -> 1230
-dqrmn881 remaindernear 123e1 100000 -> 1230
-dqrmn882 remaindernear 123e1 10000 -> 1230
-dqrmn883 remaindernear 123e1 1000 -> 230
-dqrmn884 remaindernear 123e1 100 -> 30
-dqrmn885 remaindernear 123e1 10 -> 0
-dqrmn886 remaindernear 123e1 1 -> 0
-
-dqrmn890 remaindernear 123e1 2000000000000000 -> 1230
-dqrmn891 remaindernear 123e1 200000000000000 -> 1230
-dqrmn892 remaindernear 123e1 20000000000000 -> 1230
-dqrmn893 remaindernear 123e1 2000000000000 -> 1230
-dqrmn894 remaindernear 123e1 200000000000 -> 1230
-dqrmn895 remaindernear 123e1 20000000000 -> 1230
-dqrmn896 remaindernear 123e1 2000000000 -> 1230
-dqrmn897 remaindernear 123e1 200000000 -> 1230
-dqrmn899 remaindernear 123e1 20000000 -> 1230
-dqrmn900 remaindernear 123e1 2000000 -> 1230
-dqrmn901 remaindernear 123e1 200000 -> 1230
-dqrmn902 remaindernear 123e1 20000 -> 1230
-dqrmn903 remaindernear 123e1 2000 -> -770
-dqrmn904 remaindernear 123e1 200 -> 30
-dqrmn905 remaindernear 123e1 20 -> -10
-dqrmn906 remaindernear 123e1 2 -> 0
-
-dqrmn910 remaindernear 123e1 5000000000000000 -> 1230
-dqrmn911 remaindernear 123e1 500000000000000 -> 1230
-dqrmn912 remaindernear 123e1 50000000000000 -> 1230
-dqrmn913 remaindernear 123e1 5000000000000 -> 1230
-dqrmn914 remaindernear 123e1 500000000000 -> 1230
-dqrmn915 remaindernear 123e1 50000000000 -> 1230
-dqrmn916 remaindernear 123e1 5000000000 -> 1230
-dqrmn917 remaindernear 123e1 500000000 -> 1230
-dqrmn919 remaindernear 123e1 50000000 -> 1230
-dqrmn920 remaindernear 123e1 5000000 -> 1230
-dqrmn921 remaindernear 123e1 500000 -> 1230
-dqrmn922 remaindernear 123e1 50000 -> 1230
-dqrmn923 remaindernear 123e1 5000 -> 1230
-dqrmn924 remaindernear 123e1 500 -> 230
-dqrmn925 remaindernear 123e1 50 -> -20
-dqrmn926 remaindernear 123e1 5 -> 0
-
-dqrmn930 remaindernear 123e1 9000000000000000 -> 1230
-dqrmn931 remaindernear 123e1 900000000000000 -> 1230
-dqrmn932 remaindernear 123e1 90000000000000 -> 1230
-dqrmn933 remaindernear 123e1 9000000000000 -> 1230
-dqrmn934 remaindernear 123e1 900000000000 -> 1230
-dqrmn935 remaindernear 123e1 90000000000 -> 1230
-dqrmn936 remaindernear 123e1 9000000000 -> 1230
-dqrmn937 remaindernear 123e1 900000000 -> 1230
-dqrmn939 remaindernear 123e1 90000000 -> 1230
-dqrmn940 remaindernear 123e1 9000000 -> 1230
-dqrmn941 remaindernear 123e1 900000 -> 1230
-dqrmn942 remaindernear 123e1 90000 -> 1230
-dqrmn943 remaindernear 123e1 9000 -> 1230
-dqrmn944 remaindernear 123e1 900 -> 330
-dqrmn945 remaindernear 123e1 90 -> -30
-dqrmn946 remaindernear 123e1 9 -> -3
-
-dqrmn950 remaindernear 123e1 1000000000000000 -> 1230
-dqrmn961 remaindernear 123e1 2999999999999999 -> 1230
-dqrmn962 remaindernear 123e1 3999999999999999 -> 1230
-dqrmn963 remaindernear 123e1 4999999999999999 -> 1230
-dqrmn964 remaindernear 123e1 5999999999999999 -> 1230
-dqrmn965 remaindernear 123e1 6999999999999999 -> 1230
-dqrmn966 remaindernear 123e1 7999999999999999 -> 1230
-dqrmn967 remaindernear 123e1 8999999999999999 -> 1230
-dqrmn968 remaindernear 123e1 9999999999999999 -> 1230
-dqrmn969 remaindernear 123e1 9876543210987654 -> 1230
-
-dqrmn980 remaindernear 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
-
--- overflow and underflow tests [from divide]
-dqrmn1051 remaindernear 1e+277 1e-311 -> NaN Division_impossible
-dqrmn1052 remaindernear 1e+277 -1e-311 -> NaN Division_impossible
-dqrmn1053 remaindernear -1e+277 1e-311 -> NaN Division_impossible
-dqrmn1054 remaindernear -1e+277 -1e-311 -> NaN Division_impossible
-dqrmn1055 remaindernear 1e-277 1e+311 -> 1E-277
-dqrmn1056 remaindernear 1e-277 -1e+311 -> 1E-277
-dqrmn1057 remaindernear -1e-277 1e+311 -> -1E-277
-dqrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277
-
--- Gyuris example
-dqrmn1070 remainder 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 8.336804418094040989630006819881709E-6143
-
--- destructive subtract
-dqrmn1101 remaindernear 1234567890123456789012345678901234 1.000000000000000000000000000000001 -> -0.234567890123456789012345678901233
-dqrmn1102 remaindernear 1234567890123456789012345678901234 1.00000000000000000000000000000001 -> -0.34567890123456789012345678901222
-dqrmn1103 remaindernear 1234567890123456789012345678901234 1.0000000000000000000000000000001 -> -0.4567890123456789012345678901111
-dqrmn1104 remaindernear 1234567890123456789012345678901255 4.000000000000000000000000000000001 -> -1.308641972530864197253086419725314
-dqrmn1105 remaindernear 1234567890123456789012345678901234 4.000000000000000000000000000000001 -> 1.691358027469135802746913580274692
-dqrmn1106 remaindernear 1234567890123456789012345678901234 4.9999999999999999999999999999999 -> -1.3086421975308642197530864219748
-dqrmn1107 remaindernear 1234567890123456789012345678901234 4.99999999999999999999999999999999 -> 1.46913578024691357802469135780247
-dqrmn1108 remaindernear 1234567890123456789012345678901234 4.999999999999999999999999999999999 -> -0.753086421975308642197530864219753
-dqrmn1109 remaindernear 1234567890123456789012345678901234 5.000000000000000000000000000000001 -> -1.246913578024691357802469135780247
-dqrmn1110 remaindernear 1234567890123456789012345678901234 5.00000000000000000000000000000001 -> 1.53086421975308642197530864219754
-dqrmn1111 remaindernear 1234567890123456789012345678901234 5.0000000000000000000000000000001 -> -0.6913578024691357802469135780242
-
--- Null tests
-dqrmn1000 remaindernear 10 # -> NaN Invalid_operation
-dqrmn1001 remaindernear # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqRemainderNear.decTest -- decQuad remainder-near --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks (as base, above)
+dqrmn001 remaindernear 1 1 -> 0
+dqrmn002 remaindernear 2 1 -> 0
+dqrmn003 remaindernear 1 2 -> 1
+dqrmn004 remaindernear 2 2 -> 0
+dqrmn005 remaindernear 0 1 -> 0
+dqrmn006 remaindernear 0 2 -> 0
+dqrmn007 remaindernear 1 3 -> 1
+dqrmn008 remaindernear 2 3 -> -1
+dqrmn009 remaindernear 3 3 -> 0
+
+dqrmn010 remaindernear 2.4 1 -> 0.4
+dqrmn011 remaindernear 2.4 -1 -> 0.4
+dqrmn012 remaindernear -2.4 1 -> -0.4
+dqrmn013 remaindernear -2.4 -1 -> -0.4
+dqrmn014 remaindernear 2.40 1 -> 0.40
+dqrmn015 remaindernear 2.400 1 -> 0.400
+dqrmn016 remaindernear 2.4 2 -> 0.4
+dqrmn017 remaindernear 2.400 2 -> 0.400
+dqrmn018 remaindernear 2. 2 -> 0
+dqrmn019 remaindernear 20 20 -> 0
+
+dqrmn020 remaindernear 187 187 -> 0
+dqrmn021 remaindernear 5 2 -> 1
+dqrmn022 remaindernear 5 2.0 -> 1.0
+dqrmn023 remaindernear 5 2.000 -> 1.000
+dqrmn024 remaindernear 5 0.200 -> 0.000
+dqrmn025 remaindernear 5 0.200 -> 0.000
+
+dqrmn030 remaindernear 1 2 -> 1
+dqrmn031 remaindernear 1 4 -> 1
+dqrmn032 remaindernear 1 8 -> 1
+
+dqrmn033 remaindernear 1 16 -> 1
+dqrmn034 remaindernear 1 32 -> 1
+dqrmn035 remaindernear 1 64 -> 1
+dqrmn040 remaindernear 1 -2 -> 1
+dqrmn041 remaindernear 1 -4 -> 1
+dqrmn042 remaindernear 1 -8 -> 1
+dqrmn043 remaindernear 1 -16 -> 1
+dqrmn044 remaindernear 1 -32 -> 1
+dqrmn045 remaindernear 1 -64 -> 1
+dqrmn050 remaindernear -1 2 -> -1
+dqrmn051 remaindernear -1 4 -> -1
+dqrmn052 remaindernear -1 8 -> -1
+dqrmn053 remaindernear -1 16 -> -1
+dqrmn054 remaindernear -1 32 -> -1
+dqrmn055 remaindernear -1 64 -> -1
+dqrmn060 remaindernear -1 -2 -> -1
+dqrmn061 remaindernear -1 -4 -> -1
+dqrmn062 remaindernear -1 -8 -> -1
+dqrmn063 remaindernear -1 -16 -> -1
+dqrmn064 remaindernear -1 -32 -> -1
+dqrmn065 remaindernear -1 -64 -> -1
+
+dqrmn066 remaindernear 9.9 1 -> -0.1
+dqrmn067 remaindernear 99.7 1 -> -0.3
+dqrmn068 remaindernear 999999999 1 -> 0
+dqrmn069 remaindernear 999999999.4 1 -> 0.4
+dqrmn070 remaindernear 999999999.5 1 -> -0.5
+dqrmn071 remaindernear 999999999.9 1 -> -0.1
+dqrmn072 remaindernear 999999999.999 1 -> -0.001
+dqrmn073 remaindernear 999999.999999 1 -> -0.000001
+dqrmn074 remaindernear 9 1 -> 0
+dqrmn075 remaindernear 9999999999999999 1 -> 0
+dqrmn076 remaindernear 9999999999999999 2 -> -1
+dqrmn077 remaindernear 9999999999999999 3 -> 0
+dqrmn078 remaindernear 9999999999999999 4 -> -1
+
+dqrmn080 remaindernear 0. 1 -> 0
+dqrmn081 remaindernear .0 1 -> 0.0
+dqrmn082 remaindernear 0.00 1 -> 0.00
+dqrmn083 remaindernear 0.00E+9 1 -> 0
+dqrmn084 remaindernear 0.00E+3 1 -> 0
+dqrmn085 remaindernear 0.00E+2 1 -> 0
+dqrmn086 remaindernear 0.00E+1 1 -> 0.0
+dqrmn087 remaindernear 0.00E+0 1 -> 0.00
+dqrmn088 remaindernear 0.00E-0 1 -> 0.00
+dqrmn089 remaindernear 0.00E-1 1 -> 0.000
+dqrmn090 remaindernear 0.00E-2 1 -> 0.0000
+dqrmn091 remaindernear 0.00E-3 1 -> 0.00000
+dqrmn092 remaindernear 0.00E-4 1 -> 0.000000
+dqrmn093 remaindernear 0.00E-5 1 -> 0E-7
+dqrmn094 remaindernear 0.00E-6 1 -> 0E-8
+dqrmn095 remaindernear 0.0000E-50 1 -> 0E-54
+
+-- Various flavours of remaindernear by 0
+dqrmn101 remaindernear 0 0 -> NaN Division_undefined
+dqrmn102 remaindernear 0 -0 -> NaN Division_undefined
+dqrmn103 remaindernear -0 0 -> NaN Division_undefined
+dqrmn104 remaindernear -0 -0 -> NaN Division_undefined
+dqrmn105 remaindernear 0.0E5 0 -> NaN Division_undefined
+dqrmn106 remaindernear 0.000 0 -> NaN Division_undefined
+-- [Some think this next group should be Division_by_zero exception, but
+-- IEEE 854 is explicit that it is Invalid operation .. for
+-- remainder-near, anyway]
+dqrmn107 remaindernear 0.0001 0 -> NaN Invalid_operation
+dqrmn108 remaindernear 0.01 0 -> NaN Invalid_operation
+dqrmn109 remaindernear 0.1 0 -> NaN Invalid_operation
+dqrmn110 remaindernear 1 0 -> NaN Invalid_operation
+dqrmn111 remaindernear 1 0.0 -> NaN Invalid_operation
+dqrmn112 remaindernear 10 0.0 -> NaN Invalid_operation
+dqrmn113 remaindernear 1E+100 0.0 -> NaN Invalid_operation
+dqrmn114 remaindernear 1E+380 0 -> NaN Invalid_operation
+dqrmn115 remaindernear 0.0001 -0 -> NaN Invalid_operation
+dqrmn116 remaindernear 0.01 -0 -> NaN Invalid_operation
+dqrmn119 remaindernear 0.1 -0 -> NaN Invalid_operation
+dqrmn120 remaindernear 1 -0 -> NaN Invalid_operation
+dqrmn121 remaindernear 1 -0.0 -> NaN Invalid_operation
+dqrmn122 remaindernear 10 -0.0 -> NaN Invalid_operation
+dqrmn123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation
+dqrmn124 remaindernear 1E+384 -0 -> NaN Invalid_operation
+-- and zeros on left
+dqrmn130 remaindernear 0 1 -> 0
+dqrmn131 remaindernear 0 -1 -> 0
+dqrmn132 remaindernear 0.0 1 -> 0.0
+dqrmn133 remaindernear 0.0 -1 -> 0.0
+dqrmn134 remaindernear -0 1 -> -0
+dqrmn135 remaindernear -0 -1 -> -0
+dqrmn136 remaindernear -0.0 1 -> -0.0
+dqrmn137 remaindernear -0.0 -1 -> -0.0
+
+-- 0.5ers
+dqrmn143 remaindernear 0.5 2 -> 0.5
+dqrmn144 remaindernear 0.5 2.1 -> 0.5
+dqrmn145 remaindernear 0.5 2.01 -> 0.50
+dqrmn146 remaindernear 0.5 2.001 -> 0.500
+dqrmn147 remaindernear 0.50 2 -> 0.50
+dqrmn148 remaindernear 0.50 2.01 -> 0.50
+dqrmn149 remaindernear 0.50 2.001 -> 0.500
+
+-- steadies
+dqrmn150 remaindernear 1 1 -> 0
+dqrmn151 remaindernear 1 2 -> 1
+dqrmn152 remaindernear 1 3 -> 1
+dqrmn153 remaindernear 1 4 -> 1
+dqrmn154 remaindernear 1 5 -> 1
+dqrmn155 remaindernear 1 6 -> 1
+dqrmn156 remaindernear 1 7 -> 1
+dqrmn157 remaindernear 1 8 -> 1
+dqrmn158 remaindernear 1 9 -> 1
+dqrmn159 remaindernear 1 10 -> 1
+dqrmn160 remaindernear 1 1 -> 0
+dqrmn161 remaindernear 2 1 -> 0
+dqrmn162 remaindernear 3 1 -> 0
+dqrmn163 remaindernear 4 1 -> 0
+dqrmn164 remaindernear 5 1 -> 0
+dqrmn165 remaindernear 6 1 -> 0
+dqrmn166 remaindernear 7 1 -> 0
+dqrmn167 remaindernear 8 1 -> 0
+dqrmn168 remaindernear 9 1 -> 0
+dqrmn169 remaindernear 10 1 -> 0
+
+-- some differences from remainder
+dqrmn171 remaindernear 0.4 1.020 -> 0.400
+dqrmn172 remaindernear 0.50 1.020 -> 0.500
+dqrmn173 remaindernear 0.51 1.020 -> 0.510
+dqrmn174 remaindernear 0.52 1.020 -> -0.500
+dqrmn175 remaindernear 0.6 1.020 -> -0.420
+
+-- More flavours of remaindernear by 0
+dqrmn201 remaindernear 0 0 -> NaN Division_undefined
+dqrmn202 remaindernear 0.0E5 0 -> NaN Division_undefined
+dqrmn203 remaindernear 0.000 0 -> NaN Division_undefined
+dqrmn204 remaindernear 0.0001 0 -> NaN Invalid_operation
+dqrmn205 remaindernear 0.01 0 -> NaN Invalid_operation
+dqrmn206 remaindernear 0.1 0 -> NaN Invalid_operation
+dqrmn207 remaindernear 1 0 -> NaN Invalid_operation
+dqrmn208 remaindernear 1 0.0 -> NaN Invalid_operation
+dqrmn209 remaindernear 10 0.0 -> NaN Invalid_operation
+dqrmn210 remaindernear 1E+100 0.0 -> NaN Invalid_operation
+dqrmn211 remaindernear 1E+380 0 -> NaN Invalid_operation
+
+-- tests from the extended specification
+dqrmn221 remaindernear 2.1 3 -> -0.9
+dqrmn222 remaindernear 10 6 -> -2
+dqrmn223 remaindernear 10 3 -> 1
+dqrmn224 remaindernear -10 3 -> -1
+dqrmn225 remaindernear 10.2 1 -> 0.2
+dqrmn226 remaindernear 10 0.3 -> 0.1
+dqrmn227 remaindernear 3.6 1.3 -> -0.3
+
+-- some differences from remainder
+dqrmn231 remaindernear -0.4 1.020 -> -0.400
+dqrmn232 remaindernear -0.50 1.020 -> -0.500
+dqrmn233 remaindernear -0.51 1.020 -> -0.510
+dqrmn234 remaindernear -0.52 1.020 -> 0.500
+dqrmn235 remaindernear -0.6 1.020 -> 0.420
+
+-- high Xs
+dqrmn240 remaindernear 1E+2 1.00 -> 0.00
+
+-- dqrmn3xx are from DiagBigDecimal
+dqrmn301 remaindernear 1 3 -> 1
+dqrmn302 remaindernear 5 5 -> 0
+dqrmn303 remaindernear 13 10 -> 3
+dqrmn304 remaindernear 13 50 -> 13
+dqrmn305 remaindernear 13 100 -> 13
+dqrmn306 remaindernear 13 1000 -> 13
+dqrmn307 remaindernear .13 1 -> 0.13
+dqrmn308 remaindernear 0.133 1 -> 0.133
+dqrmn309 remaindernear 0.1033 1 -> 0.1033
+dqrmn310 remaindernear 1.033 1 -> 0.033
+dqrmn311 remaindernear 10.33 1 -> 0.33
+dqrmn312 remaindernear 10.33 10 -> 0.33
+dqrmn313 remaindernear 103.3 1 -> 0.3
+dqrmn314 remaindernear 133 10 -> 3
+dqrmn315 remaindernear 1033 10 -> 3
+dqrmn316 remaindernear 1033 50 -> -17
+dqrmn317 remaindernear 101.0 3 -> -1.0
+dqrmn318 remaindernear 102.0 3 -> 0.0
+dqrmn319 remaindernear 103.0 3 -> 1.0
+dqrmn320 remaindernear 2.40 1 -> 0.40
+dqrmn321 remaindernear 2.400 1 -> 0.400
+dqrmn322 remaindernear 2.4 1 -> 0.4
+dqrmn323 remaindernear 2.4 2 -> 0.4
+dqrmn324 remaindernear 2.400 2 -> 0.400
+dqrmn325 remaindernear 1 0.3 -> 0.1
+dqrmn326 remaindernear 1 0.30 -> 0.10
+dqrmn327 remaindernear 1 0.300 -> 0.100
+dqrmn328 remaindernear 1 0.3000 -> 0.1000
+dqrmn329 remaindernear 1.0 0.3 -> 0.1
+dqrmn330 remaindernear 1.00 0.3 -> 0.10
+dqrmn331 remaindernear 1.000 0.3 -> 0.100
+dqrmn332 remaindernear 1.0000 0.3 -> 0.1000
+dqrmn333 remaindernear 0.5 2 -> 0.5
+dqrmn334 remaindernear 0.5 2.1 -> 0.5
+dqrmn335 remaindernear 0.5 2.01 -> 0.50
+dqrmn336 remaindernear 0.5 2.001 -> 0.500
+dqrmn337 remaindernear 0.50 2 -> 0.50
+dqrmn338 remaindernear 0.50 2.01 -> 0.50
+dqrmn339 remaindernear 0.50 2.001 -> 0.500
+
+dqrmn340 remaindernear 0.5 0.5000001 -> -1E-7
+dqrmn341 remaindernear 0.5 0.50000001 -> -1E-8
+dqrmn342 remaindernear 0.5 0.500000001 -> -1E-9
+dqrmn343 remaindernear 0.5 0.5000000001 -> -1E-10
+dqrmn344 remaindernear 0.5 0.50000000001 -> -1E-11
+dqrmn345 remaindernear 0.5 0.4999999 -> 1E-7
+dqrmn346 remaindernear 0.5 0.49999999 -> 1E-8
+dqrmn347 remaindernear 0.5 0.499999999 -> 1E-9
+dqrmn348 remaindernear 0.5 0.4999999999 -> 1E-10
+dqrmn349 remaindernear 0.5 0.49999999999 -> 1E-11
+dqrmn350 remaindernear 0.5 0.499999999999 -> 1E-12
+
+dqrmn351 remaindernear 0.03 7 -> 0.03
+dqrmn352 remaindernear 5 2 -> 1
+dqrmn353 remaindernear 4.1 2 -> 0.1
+dqrmn354 remaindernear 4.01 2 -> 0.01
+dqrmn355 remaindernear 4.001 2 -> 0.001
+dqrmn356 remaindernear 4.0001 2 -> 0.0001
+dqrmn357 remaindernear 4.00001 2 -> 0.00001
+dqrmn358 remaindernear 4.000001 2 -> 0.000001
+dqrmn359 remaindernear 4.0000001 2 -> 1E-7
+
+dqrmn360 remaindernear 1.2 0.7345 -> -0.2690
+dqrmn361 remaindernear 0.8 12 -> 0.8
+dqrmn362 remaindernear 0.8 0.2 -> 0.0
+dqrmn363 remaindernear 0.8 0.3 -> -0.1
+dqrmn364 remaindernear 0.800 12 -> 0.800
+dqrmn365 remaindernear 0.800 1.7 -> 0.800
+dqrmn366 remaindernear 2.400 2 -> 0.400
+
+-- round to even
+dqrmn371 remaindernear 121 2 -> 1
+dqrmn372 remaindernear 122 2 -> 0
+dqrmn373 remaindernear 123 2 -> -1
+dqrmn374 remaindernear 124 2 -> 0
+dqrmn375 remaindernear 125 2 -> 1
+dqrmn376 remaindernear 126 2 -> 0
+dqrmn377 remaindernear 127 2 -> -1
+
+dqrmn381 remaindernear 12345 1 -> 0
+dqrmn382 remaindernear 12345 1.0001 -> -0.2344
+dqrmn383 remaindernear 12345 1.001 -> -0.333
+dqrmn384 remaindernear 12345 1.01 -> -0.23
+dqrmn385 remaindernear 12345 1.1 -> -0.3
+dqrmn386 remaindernear 12355 4 -> -1
+dqrmn387 remaindernear 12345 4 -> 1
+dqrmn388 remaindernear 12355 4.0001 -> -1.3089
+dqrmn389 remaindernear 12345 4.0001 -> 0.6914
+dqrmn390 remaindernear 12345 4.9 -> 1.9
+dqrmn391 remaindernear 12345 4.99 -> -0.26
+dqrmn392 remaindernear 12345 4.999 -> 2.469
+dqrmn393 remaindernear 12345 4.9999 -> 0.2469
+dqrmn394 remaindernear 12345 5 -> 0
+dqrmn395 remaindernear 12345 5.0001 -> -0.2469
+dqrmn396 remaindernear 12345 5.001 -> -2.469
+dqrmn397 remaindernear 12345 5.01 -> 0.36
+dqrmn398 remaindernear 12345 5.1 -> -2.1
+
+-- the nasty division-by-1 cases
+dqrmn401 remaindernear 0.4 1 -> 0.4
+dqrmn402 remaindernear 0.45 1 -> 0.45
+dqrmn403 remaindernear 0.455 1 -> 0.455
+dqrmn404 remaindernear 0.4555 1 -> 0.4555
+dqrmn405 remaindernear 0.45555 1 -> 0.45555
+dqrmn406 remaindernear 0.455555 1 -> 0.455555
+dqrmn407 remaindernear 0.4555555 1 -> 0.4555555
+dqrmn408 remaindernear 0.45555555 1 -> 0.45555555
+dqrmn409 remaindernear 0.455555555 1 -> 0.455555555
+-- with spill... [412 exercises sticktab loop]
+dqrmn411 remaindernear 0.5 1 -> 0.5
+dqrmn412 remaindernear 0.55 1 -> -0.45
+dqrmn413 remaindernear 0.555 1 -> -0.445
+dqrmn414 remaindernear 0.5555 1 -> -0.4445
+dqrmn415 remaindernear 0.55555 1 -> -0.44445
+dqrmn416 remaindernear 0.555555 1 -> -0.444445
+dqrmn417 remaindernear 0.5555555 1 -> -0.4444445
+dqrmn418 remaindernear 0.55555555 1 -> -0.44444445
+dqrmn419 remaindernear 0.555555555 1 -> -0.444444445
+
+-- folddowns
+dqrmn421 remaindernear 1E+6144 1 -> NaN Division_impossible
+dqrmn422 remaindernear 1E+6144 1E+6143 -> 0E+6111 Clamped
+dqrmn423 remaindernear 1E+6144 2E+6143 -> 0E+6111 Clamped
+dqrmn424 remaindernear 1E+6144 3E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqrmn425 remaindernear 1E+6144 4E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
+dqrmn426 remaindernear 1E+6144 5E+6143 -> 0E+6111 Clamped
+dqrmn427 remaindernear 1E+6144 6E+6143 -> -2.00000000000000000000000000000000E+6143 Clamped
+dqrmn428 remaindernear 1E+6144 7E+6143 -> 3.00000000000000000000000000000000E+6143 Clamped
+dqrmn429 remaindernear 1E+6144 8E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
+dqrmn430 remaindernear 1E+6144 9E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
+-- tinies
+dqrmn431 remaindernear 1E-6175 1E-6176 -> 0E-6176
+dqrmn432 remaindernear 1E-6175 2E-6176 -> 0E-6176
+dqrmn433 remaindernear 1E-6175 3E-6176 -> 1E-6176 Subnormal
+dqrmn434 remaindernear 1E-6175 4E-6176 -> 2E-6176 Subnormal
+dqrmn435 remaindernear 1E-6175 5E-6176 -> 0E-6176
+dqrmn436 remaindernear 1E-6175 6E-6176 -> -2E-6176 Subnormal
+dqrmn437 remaindernear 1E-6175 7E-6176 -> 3E-6176 Subnormal
+dqrmn438 remaindernear 1E-6175 8E-6176 -> 2E-6176 Subnormal
+dqrmn439 remaindernear 1E-6175 9E-6176 -> 1E-6176 Subnormal
+dqrmn440 remaindernear 1E-6175 10E-6176 -> 0E-6176
+dqrmn441 remaindernear 1E-6175 11E-6176 -> -1E-6176 Subnormal
+dqrmn442 remaindernear 100E-6175 11E-6176 -> -1E-6176 Subnormal
+dqrmn443 remaindernear 100E-6175 20E-6176 -> 0E-6176
+dqrmn444 remaindernear 100E-6175 21E-6176 -> -8E-6176 Subnormal
+dqrmn445 remaindernear 100E-6175 30E-6176 -> 1.0E-6175 Subnormal
+
+-- zero signs
+dqrmn650 remaindernear 1 1 -> 0
+dqrmn651 remaindernear -1 1 -> -0
+dqrmn652 remaindernear 1 -1 -> 0
+dqrmn653 remaindernear -1 -1 -> -0
+dqrmn654 remaindernear 0 1 -> 0
+dqrmn655 remaindernear -0 1 -> -0
+dqrmn656 remaindernear 0 -1 -> 0
+dqrmn657 remaindernear -0 -1 -> -0
+dqrmn658 remaindernear 0.00 1 -> 0.00
+dqrmn659 remaindernear -0.00 1 -> -0.00
+
+-- Specials
+dqrmn680 remaindernear Inf -Inf -> NaN Invalid_operation
+dqrmn681 remaindernear Inf -1000 -> NaN Invalid_operation
+dqrmn682 remaindernear Inf -1 -> NaN Invalid_operation
+dqrmn683 remaindernear Inf 0 -> NaN Invalid_operation
+dqrmn684 remaindernear Inf -0 -> NaN Invalid_operation
+dqrmn685 remaindernear Inf 1 -> NaN Invalid_operation
+dqrmn686 remaindernear Inf 1000 -> NaN Invalid_operation
+dqrmn687 remaindernear Inf Inf -> NaN Invalid_operation
+dqrmn688 remaindernear -1000 Inf -> -1000
+dqrmn689 remaindernear -Inf Inf -> NaN Invalid_operation
+dqrmn691 remaindernear -1 Inf -> -1
+dqrmn692 remaindernear 0 Inf -> 0
+dqrmn693 remaindernear -0 Inf -> -0
+dqrmn694 remaindernear 1 Inf -> 1
+dqrmn695 remaindernear 1000 Inf -> 1000
+dqrmn696 remaindernear Inf Inf -> NaN Invalid_operation
+
+dqrmn700 remaindernear -Inf -Inf -> NaN Invalid_operation
+dqrmn701 remaindernear -Inf -1000 -> NaN Invalid_operation
+dqrmn702 remaindernear -Inf -1 -> NaN Invalid_operation
+dqrmn703 remaindernear -Inf -0 -> NaN Invalid_operation
+dqrmn704 remaindernear -Inf 0 -> NaN Invalid_operation
+dqrmn705 remaindernear -Inf 1 -> NaN Invalid_operation
+dqrmn706 remaindernear -Inf 1000 -> NaN Invalid_operation
+dqrmn707 remaindernear -Inf Inf -> NaN Invalid_operation
+dqrmn708 remaindernear -Inf -Inf -> NaN Invalid_operation
+dqrmn709 remaindernear -1000 Inf -> -1000
+dqrmn710 remaindernear -1 -Inf -> -1
+dqrmn711 remaindernear -0 -Inf -> -0
+dqrmn712 remaindernear 0 -Inf -> 0
+dqrmn713 remaindernear 1 -Inf -> 1
+dqrmn714 remaindernear 1000 -Inf -> 1000
+dqrmn715 remaindernear Inf -Inf -> NaN Invalid_operation
+
+dqrmn721 remaindernear NaN -Inf -> NaN
+dqrmn722 remaindernear NaN -1000 -> NaN
+dqrmn723 remaindernear NaN -1 -> NaN
+dqrmn724 remaindernear NaN -0 -> NaN
+dqrmn725 remaindernear -NaN 0 -> -NaN
+dqrmn726 remaindernear NaN 1 -> NaN
+dqrmn727 remaindernear NaN 1000 -> NaN
+dqrmn728 remaindernear NaN Inf -> NaN
+dqrmn729 remaindernear NaN -NaN -> NaN
+dqrmn730 remaindernear -Inf NaN -> NaN
+dqrmn731 remaindernear -1000 NaN -> NaN
+dqrmn732 remaindernear -1 NaN -> NaN
+dqrmn733 remaindernear -0 -NaN -> -NaN
+dqrmn734 remaindernear 0 NaN -> NaN
+dqrmn735 remaindernear 1 -NaN -> -NaN
+dqrmn736 remaindernear 1000 NaN -> NaN
+dqrmn737 remaindernear Inf NaN -> NaN
+
+dqrmn741 remaindernear sNaN -Inf -> NaN Invalid_operation
+dqrmn742 remaindernear sNaN -1000 -> NaN Invalid_operation
+dqrmn743 remaindernear -sNaN -1 -> -NaN Invalid_operation
+dqrmn744 remaindernear sNaN -0 -> NaN Invalid_operation
+dqrmn745 remaindernear sNaN 0 -> NaN Invalid_operation
+dqrmn746 remaindernear sNaN 1 -> NaN Invalid_operation
+dqrmn747 remaindernear sNaN 1000 -> NaN Invalid_operation
+dqrmn749 remaindernear sNaN NaN -> NaN Invalid_operation
+dqrmn750 remaindernear sNaN sNaN -> NaN Invalid_operation
+dqrmn751 remaindernear NaN sNaN -> NaN Invalid_operation
+dqrmn752 remaindernear -Inf sNaN -> NaN Invalid_operation
+dqrmn753 remaindernear -1000 sNaN -> NaN Invalid_operation
+dqrmn754 remaindernear -1 sNaN -> NaN Invalid_operation
+dqrmn755 remaindernear -0 sNaN -> NaN Invalid_operation
+dqrmn756 remaindernear 0 sNaN -> NaN Invalid_operation
+dqrmn757 remaindernear 1 sNaN -> NaN Invalid_operation
+dqrmn758 remaindernear 1000 sNaN -> NaN Invalid_operation
+dqrmn759 remaindernear Inf -sNaN -> -NaN Invalid_operation
+
+-- propaging NaNs
+dqrmn760 remaindernear NaN1 NaN7 -> NaN1
+dqrmn761 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation
+dqrmn762 remaindernear NaN3 sNaN9 -> NaN9 Invalid_operation
+dqrmn763 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation
+dqrmn764 remaindernear 15 NaN11 -> NaN11
+dqrmn765 remaindernear NaN6 NaN12 -> NaN6
+dqrmn766 remaindernear Inf NaN13 -> NaN13
+dqrmn767 remaindernear NaN14 -Inf -> NaN14
+dqrmn768 remaindernear 0 NaN15 -> NaN15
+dqrmn769 remaindernear NaN16 -0 -> NaN16
+
+-- edge cases of impossible
+dqrmn770 remaindernear 1234500000000000000000067890123456 10 -> -4
+dqrmn771 remaindernear 1234500000000000000000067890123456 1 -> 0
+dqrmn772 remaindernear 1234500000000000000000067890123456 0.1 -> NaN Division_impossible
+dqrmn773 remaindernear 1234500000000000000000067890123456 0.01 -> NaN Division_impossible
+
+-- long operand checks
+dqrmn801 remaindernear 12345678000 100 -> 0
+dqrmn802 remaindernear 1 12345678000 -> 1
+dqrmn803 remaindernear 1234567800 10 -> 0
+dqrmn804 remaindernear 1 1234567800 -> 1
+dqrmn805 remaindernear 1234567890 10 -> 0
+dqrmn806 remaindernear 1 1234567890 -> 1
+dqrmn807 remaindernear 1234567891 10 -> 1
+dqrmn808 remaindernear 1 1234567891 -> 1
+dqrmn809 remaindernear 12345678901 100 -> 1
+dqrmn810 remaindernear 1 12345678901 -> 1
+dqrmn811 remaindernear 1234567896 10 -> -4
+dqrmn812 remaindernear 1 1234567896 -> 1
+
+dqrmn821 remaindernear 12345678000 100 -> 0
+dqrmn822 remaindernear 1 12345678000 -> 1
+dqrmn823 remaindernear 1234567800 10 -> 0
+dqrmn824 remaindernear 1 1234567800 -> 1
+dqrmn825 remaindernear 1234567890 10 -> 0
+dqrmn826 remaindernear 1 1234567890 -> 1
+dqrmn827 remaindernear 1234567891 10 -> 1
+dqrmn828 remaindernear 1 1234567891 -> 1
+dqrmn829 remaindernear 12345678901 100 -> 1
+dqrmn830 remaindernear 1 12345678901 -> 1
+dqrmn831 remaindernear 1234567896 10 -> -4
+dqrmn832 remaindernear 1 1234567896 -> 1
+
+-- from divideint
+dqrmn840 remaindernear 100000000.0 1 -> 0.0
+dqrmn841 remaindernear 100000000.4 1 -> 0.4
+dqrmn842 remaindernear 100000000.5 1 -> 0.5
+dqrmn843 remaindernear 100000000.9 1 -> -0.1
+dqrmn844 remaindernear 100000000.999 1 -> -0.001
+dqrmn850 remaindernear 100000003 5 -> -2
+dqrmn851 remaindernear 10000003 5 -> -2
+dqrmn852 remaindernear 1000003 5 -> -2
+dqrmn853 remaindernear 100003 5 -> -2
+dqrmn854 remaindernear 10003 5 -> -2
+dqrmn855 remaindernear 1003 5 -> -2
+dqrmn856 remaindernear 103 5 -> -2
+dqrmn857 remaindernear 13 5 -> -2
+dqrmn858 remaindernear 1 5 -> 1
+
+-- Vladimir's cases 1234567890123456
+dqrmn860 remaindernear 123.0e1 1000000000000000 -> 1230
+dqrmn861 remaindernear 1230 1000000000000000 -> 1230
+dqrmn862 remaindernear 12.3e2 1000000000000000 -> 1230
+dqrmn863 remaindernear 1.23e3 1000000000000000 -> 1230
+dqrmn864 remaindernear 123e1 1000000000000000 -> 1230
+dqrmn870 remaindernear 123e1 1000000000000000 -> 1230
+dqrmn871 remaindernear 123e1 100000000000000 -> 1230
+dqrmn872 remaindernear 123e1 10000000000000 -> 1230
+dqrmn873 remaindernear 123e1 1000000000000 -> 1230
+dqrmn874 remaindernear 123e1 100000000000 -> 1230
+dqrmn875 remaindernear 123e1 10000000000 -> 1230
+dqrmn876 remaindernear 123e1 1000000000 -> 1230
+dqrmn877 remaindernear 123e1 100000000 -> 1230
+dqrmn878 remaindernear 1230 100000000 -> 1230
+dqrmn879 remaindernear 123e1 10000000 -> 1230
+dqrmn880 remaindernear 123e1 1000000 -> 1230
+dqrmn881 remaindernear 123e1 100000 -> 1230
+dqrmn882 remaindernear 123e1 10000 -> 1230
+dqrmn883 remaindernear 123e1 1000 -> 230
+dqrmn884 remaindernear 123e1 100 -> 30
+dqrmn885 remaindernear 123e1 10 -> 0
+dqrmn886 remaindernear 123e1 1 -> 0
+
+dqrmn890 remaindernear 123e1 2000000000000000 -> 1230
+dqrmn891 remaindernear 123e1 200000000000000 -> 1230
+dqrmn892 remaindernear 123e1 20000000000000 -> 1230
+dqrmn893 remaindernear 123e1 2000000000000 -> 1230
+dqrmn894 remaindernear 123e1 200000000000 -> 1230
+dqrmn895 remaindernear 123e1 20000000000 -> 1230
+dqrmn896 remaindernear 123e1 2000000000 -> 1230
+dqrmn897 remaindernear 123e1 200000000 -> 1230
+dqrmn899 remaindernear 123e1 20000000 -> 1230
+dqrmn900 remaindernear 123e1 2000000 -> 1230
+dqrmn901 remaindernear 123e1 200000 -> 1230
+dqrmn902 remaindernear 123e1 20000 -> 1230
+dqrmn903 remaindernear 123e1 2000 -> -770
+dqrmn904 remaindernear 123e1 200 -> 30
+dqrmn905 remaindernear 123e1 20 -> -10
+dqrmn906 remaindernear 123e1 2 -> 0
+
+dqrmn910 remaindernear 123e1 5000000000000000 -> 1230
+dqrmn911 remaindernear 123e1 500000000000000 -> 1230
+dqrmn912 remaindernear 123e1 50000000000000 -> 1230
+dqrmn913 remaindernear 123e1 5000000000000 -> 1230
+dqrmn914 remaindernear 123e1 500000000000 -> 1230
+dqrmn915 remaindernear 123e1 50000000000 -> 1230
+dqrmn916 remaindernear 123e1 5000000000 -> 1230
+dqrmn917 remaindernear 123e1 500000000 -> 1230
+dqrmn919 remaindernear 123e1 50000000 -> 1230
+dqrmn920 remaindernear 123e1 5000000 -> 1230
+dqrmn921 remaindernear 123e1 500000 -> 1230
+dqrmn922 remaindernear 123e1 50000 -> 1230
+dqrmn923 remaindernear 123e1 5000 -> 1230
+dqrmn924 remaindernear 123e1 500 -> 230
+dqrmn925 remaindernear 123e1 50 -> -20
+dqrmn926 remaindernear 123e1 5 -> 0
+
+dqrmn930 remaindernear 123e1 9000000000000000 -> 1230
+dqrmn931 remaindernear 123e1 900000000000000 -> 1230
+dqrmn932 remaindernear 123e1 90000000000000 -> 1230
+dqrmn933 remaindernear 123e1 9000000000000 -> 1230
+dqrmn934 remaindernear 123e1 900000000000 -> 1230
+dqrmn935 remaindernear 123e1 90000000000 -> 1230
+dqrmn936 remaindernear 123e1 9000000000 -> 1230
+dqrmn937 remaindernear 123e1 900000000 -> 1230
+dqrmn939 remaindernear 123e1 90000000 -> 1230
+dqrmn940 remaindernear 123e1 9000000 -> 1230
+dqrmn941 remaindernear 123e1 900000 -> 1230
+dqrmn942 remaindernear 123e1 90000 -> 1230
+dqrmn943 remaindernear 123e1 9000 -> 1230
+dqrmn944 remaindernear 123e1 900 -> 330
+dqrmn945 remaindernear 123e1 90 -> -30
+dqrmn946 remaindernear 123e1 9 -> -3
+
+dqrmn950 remaindernear 123e1 1000000000000000 -> 1230
+dqrmn961 remaindernear 123e1 2999999999999999 -> 1230
+dqrmn962 remaindernear 123e1 3999999999999999 -> 1230
+dqrmn963 remaindernear 123e1 4999999999999999 -> 1230
+dqrmn964 remaindernear 123e1 5999999999999999 -> 1230
+dqrmn965 remaindernear 123e1 6999999999999999 -> 1230
+dqrmn966 remaindernear 123e1 7999999999999999 -> 1230
+dqrmn967 remaindernear 123e1 8999999999999999 -> 1230
+dqrmn968 remaindernear 123e1 9999999999999999 -> 1230
+dqrmn969 remaindernear 123e1 9876543210987654 -> 1230
+
+dqrmn980 remaindernear 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
+
+-- overflow and underflow tests [from divide]
+dqrmn1051 remaindernear 1e+277 1e-311 -> NaN Division_impossible
+dqrmn1052 remaindernear 1e+277 -1e-311 -> NaN Division_impossible
+dqrmn1053 remaindernear -1e+277 1e-311 -> NaN Division_impossible
+dqrmn1054 remaindernear -1e+277 -1e-311 -> NaN Division_impossible
+dqrmn1055 remaindernear 1e-277 1e+311 -> 1E-277
+dqrmn1056 remaindernear 1e-277 -1e+311 -> 1E-277
+dqrmn1057 remaindernear -1e-277 1e+311 -> -1E-277
+dqrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277
+
+-- Gyuris example
+dqrmn1070 remainder 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 8.336804418094040989630006819881709E-6143
+
+-- destructive subtract
+dqrmn1101 remaindernear 1234567890123456789012345678901234 1.000000000000000000000000000000001 -> -0.234567890123456789012345678901233
+dqrmn1102 remaindernear 1234567890123456789012345678901234 1.00000000000000000000000000000001 -> -0.34567890123456789012345678901222
+dqrmn1103 remaindernear 1234567890123456789012345678901234 1.0000000000000000000000000000001 -> -0.4567890123456789012345678901111
+dqrmn1104 remaindernear 1234567890123456789012345678901255 4.000000000000000000000000000000001 -> -1.308641972530864197253086419725314
+dqrmn1105 remaindernear 1234567890123456789012345678901234 4.000000000000000000000000000000001 -> 1.691358027469135802746913580274692
+dqrmn1106 remaindernear 1234567890123456789012345678901234 4.9999999999999999999999999999999 -> -1.3086421975308642197530864219748
+dqrmn1107 remaindernear 1234567890123456789012345678901234 4.99999999999999999999999999999999 -> 1.46913578024691357802469135780247
+dqrmn1108 remaindernear 1234567890123456789012345678901234 4.999999999999999999999999999999999 -> -0.753086421975308642197530864219753
+dqrmn1109 remaindernear 1234567890123456789012345678901234 5.000000000000000000000000000000001 -> -1.246913578024691357802469135780247
+dqrmn1110 remaindernear 1234567890123456789012345678901234 5.00000000000000000000000000000001 -> 1.53086421975308642197530864219754
+dqrmn1111 remaindernear 1234567890123456789012345678901234 5.0000000000000000000000000000001 -> -0.6913578024691357802469135780242
+
+-- Null tests
+dqrmn1000 remaindernear 10 # -> NaN Invalid_operation
+dqrmn1001 remaindernear # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqRotate.decTest b/Lib/test/decimaltestdata/dqRotate.decTest
index edcf9eed23..858b823e08 100644
--- a/Lib/test/decimaltestdata/dqRotate.decTest
+++ b/Lib/test/decimaltestdata/dqRotate.decTest
@@ -1,298 +1,298 @@
-------------------------------------------------------------------------
--- dqRotate.decTest -- rotate decQuad coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqrot001 rotate 0 0 -> 0
-dqrot002 rotate 0 2 -> 0
-dqrot003 rotate 1 2 -> 100
-dqrot004 rotate 1 33 -> 1000000000000000000000000000000000
-dqrot005 rotate 1 34 -> 1
-dqrot006 rotate 1 -1 -> 1000000000000000000000000000000000
-dqrot007 rotate 0 -2 -> 0
-dqrot008 rotate 1234567890123456789012345678901234 -1 -> 4123456789012345678901234567890123
-dqrot009 rotate 1234567890123456789012345678901234 -33 -> 2345678901234567890123456789012341
-dqrot010 rotate 1234567890123456789012345678901234 -34 -> 1234567890123456789012345678901234
-dqrot011 rotate 9934567890123456789012345678901234 -33 -> 9345678901234567890123456789012349
-dqrot012 rotate 9934567890123456789012345678901234 -34 -> 9934567890123456789012345678901234
-
--- rhs must be an integer
-dqrot015 rotate 1 1.5 -> NaN Invalid_operation
-dqrot016 rotate 1 1.0 -> NaN Invalid_operation
-dqrot017 rotate 1 0.1 -> NaN Invalid_operation
-dqrot018 rotate 1 0.0 -> NaN Invalid_operation
-dqrot019 rotate 1 1E+1 -> NaN Invalid_operation
-dqrot020 rotate 1 1E+99 -> NaN Invalid_operation
-dqrot021 rotate 1 Inf -> NaN Invalid_operation
-dqrot022 rotate 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-dqrot025 rotate 1 -1000 -> NaN Invalid_operation
-dqrot026 rotate 1 -35 -> NaN Invalid_operation
-dqrot027 rotate 1 35 -> NaN Invalid_operation
-dqrot028 rotate 1 1000 -> NaN Invalid_operation
-
--- full pattern
-dqrot030 rotate 1234567890123456789012345678901234 -34 -> 1234567890123456789012345678901234
-dqrot031 rotate 1234567890123456789012345678901234 -33 -> 2345678901234567890123456789012341
-dqrot032 rotate 1234567890123456789012345678901234 -32 -> 3456789012345678901234567890123412
-dqrot033 rotate 1234567890123456789012345678901234 -31 -> 4567890123456789012345678901234123
-dqrot034 rotate 1234567890123456789012345678901234 -30 -> 5678901234567890123456789012341234
-dqrot035 rotate 1234567890123456789012345678901234 -29 -> 6789012345678901234567890123412345
-dqrot036 rotate 1234567890123456789012345678901234 -28 -> 7890123456789012345678901234123456
-dqrot037 rotate 1234567890123456789012345678901234 -27 -> 8901234567890123456789012341234567
-dqrot038 rotate 1234567890123456789012345678901234 -26 -> 9012345678901234567890123412345678
-dqrot039 rotate 1234567890123456789012345678901234 -25 -> 123456789012345678901234123456789
-dqrot040 rotate 1234567890123456789012345678901234 -24 -> 1234567890123456789012341234567890
-dqrot041 rotate 1234567890123456789012345678901234 -23 -> 2345678901234567890123412345678901
-dqrot042 rotate 1234567890123456789012345678901234 -22 -> 3456789012345678901234123456789012
-dqrot043 rotate 1234567890123456789012345678901234 -21 -> 4567890123456789012341234567890123
-dqrot044 rotate 1234567890123456789012345678901234 -20 -> 5678901234567890123412345678901234
-dqrot045 rotate 1234567890123456789012345678901234 -19 -> 6789012345678901234123456789012345
-dqrot047 rotate 1234567890123456789012345678901234 -18 -> 7890123456789012341234567890123456
-dqrot048 rotate 1234567890123456789012345678901234 -17 -> 8901234567890123412345678901234567
-dqrot049 rotate 1234567890123456789012345678901234 -16 -> 9012345678901234123456789012345678
-dqrot050 rotate 1234567890123456789012345678901234 -15 -> 123456789012341234567890123456789
-dqrot051 rotate 1234567890123456789012345678901234 -14 -> 1234567890123412345678901234567890
-dqrot052 rotate 1234567890123456789012345678901234 -13 -> 2345678901234123456789012345678901
-dqrot053 rotate 1234567890123456789012345678901234 -12 -> 3456789012341234567890123456789012
-dqrot054 rotate 1234567890123456789012345678901234 -11 -> 4567890123412345678901234567890123
-dqrot055 rotate 1234567890123456789012345678901234 -10 -> 5678901234123456789012345678901234
-dqrot056 rotate 1234567890123456789012345678901234 -9 -> 6789012341234567890123456789012345
-dqrot057 rotate 1234567890123456789012345678901234 -8 -> 7890123412345678901234567890123456
-dqrot058 rotate 1234567890123456789012345678901234 -7 -> 8901234123456789012345678901234567
-dqrot059 rotate 1234567890123456789012345678901234 -6 -> 9012341234567890123456789012345678
-dqrot060 rotate 1234567890123456789012345678901234 -5 -> 123412345678901234567890123456789
-dqrot061 rotate 1234567890123456789012345678901234 -4 -> 1234123456789012345678901234567890
-dqrot062 rotate 1234567890123456789012345678901234 -3 -> 2341234567890123456789012345678901
-dqrot063 rotate 1234567890123456789012345678901234 -2 -> 3412345678901234567890123456789012
-dqrot064 rotate 1234567890123456789012345678901234 -1 -> 4123456789012345678901234567890123
-dqrot065 rotate 1234567890123456789012345678901234 -0 -> 1234567890123456789012345678901234
-
-dqrot066 rotate 1234567890123456789012345678901234 +0 -> 1234567890123456789012345678901234
-dqrot067 rotate 1234567890123456789012345678901234 +1 -> 2345678901234567890123456789012341
-dqrot068 rotate 1234567890123456789012345678901234 +2 -> 3456789012345678901234567890123412
-dqrot069 rotate 1234567890123456789012345678901234 +3 -> 4567890123456789012345678901234123
-dqrot070 rotate 1234567890123456789012345678901234 +4 -> 5678901234567890123456789012341234
-dqrot071 rotate 1234567890123456789012345678901234 +5 -> 6789012345678901234567890123412345
-dqrot072 rotate 1234567890123456789012345678901234 +6 -> 7890123456789012345678901234123456
-dqrot073 rotate 1234567890123456789012345678901234 +7 -> 8901234567890123456789012341234567
-dqrot074 rotate 1234567890123456789012345678901234 +8 -> 9012345678901234567890123412345678
-dqrot075 rotate 1234567890123456789012345678901234 +9 -> 123456789012345678901234123456789
-dqrot076 rotate 1234567890123456789012345678901234 +10 -> 1234567890123456789012341234567890
-dqrot077 rotate 1234567890123456789012345678901234 +11 -> 2345678901234567890123412345678901
-dqrot078 rotate 1234567890123456789012345678901234 +12 -> 3456789012345678901234123456789012
-dqrot079 rotate 1234567890123456789012345678901234 +13 -> 4567890123456789012341234567890123
-dqrot080 rotate 1234567890123456789012345678901234 +14 -> 5678901234567890123412345678901234
-dqrot081 rotate 1234567890123456789012345678901234 +15 -> 6789012345678901234123456789012345
-dqrot082 rotate 1234567890123456789012345678901234 +16 -> 7890123456789012341234567890123456
-dqrot083 rotate 1234567890123456789012345678901234 +17 -> 8901234567890123412345678901234567
-dqrot084 rotate 1234567890123456789012345678901234 +18 -> 9012345678901234123456789012345678
-dqrot085 rotate 1234567890123456789012345678901234 +19 -> 123456789012341234567890123456789
-dqrot086 rotate 1234567890123456789012345678901234 +20 -> 1234567890123412345678901234567890
-dqrot087 rotate 1234567890123456789012345678901234 +21 -> 2345678901234123456789012345678901
-dqrot088 rotate 1234567890123456789012345678901234 +22 -> 3456789012341234567890123456789012
-dqrot089 rotate 1234567890123456789012345678901234 +23 -> 4567890123412345678901234567890123
-dqrot090 rotate 1234567890123456789012345678901234 +24 -> 5678901234123456789012345678901234
-dqrot091 rotate 1234567890123456789012345678901234 +25 -> 6789012341234567890123456789012345
-dqrot092 rotate 1234567890123456789012345678901234 +26 -> 7890123412345678901234567890123456
-dqrot093 rotate 1234567890123456789012345678901234 +27 -> 8901234123456789012345678901234567
-dqrot094 rotate 1234567890123456789012345678901234 +28 -> 9012341234567890123456789012345678
-dqrot095 rotate 1234567890123456789012345678901234 +29 -> 123412345678901234567890123456789
-dqrot096 rotate 1234567890123456789012345678901234 +30 -> 1234123456789012345678901234567890
-dqrot097 rotate 1234567890123456789012345678901234 +31 -> 2341234567890123456789012345678901
-dqrot098 rotate 1234567890123456789012345678901234 +32 -> 3412345678901234567890123456789012
-dqrot099 rotate 1234567890123456789012345678901234 +33 -> 4123456789012345678901234567890123
-dqrot100 rotate 1234567890123456789012345678901234 +34 -> 1234567890123456789012345678901234
-
--- zeros
-dqrot270 rotate 0E-10 +29 -> 0E-10
-dqrot271 rotate 0E-10 -29 -> 0E-10
-dqrot272 rotate 0.000 +29 -> 0.000
-dqrot273 rotate 0.000 -29 -> 0.000
-dqrot274 rotate 0E+10 +29 -> 0E+10
-dqrot275 rotate 0E+10 -29 -> 0E+10
-dqrot276 rotate -0E-10 +29 -> -0E-10
-dqrot277 rotate -0E-10 -29 -> -0E-10
-dqrot278 rotate -0.000 +29 -> -0.000
-dqrot279 rotate -0.000 -29 -> -0.000
-dqrot280 rotate -0E+10 +29 -> -0E+10
-dqrot281 rotate -0E+10 -29 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-dqrot141 rotate 9.999999999999999999999999999999999E+6144 -1 -> 9.999999999999999999999999999999999E+6144
-dqrot142 rotate 9.999999999999999999999999999999999E+6144 -33 -> 9.999999999999999999999999999999999E+6144
-dqrot143 rotate 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144
-dqrot144 rotate 9.999999999999999999999999999999999E+6144 33 -> 9.999999999999999999999999999999999E+6144
-dqrot145 rotate 1E-6143 -1 -> 1.000000000000000000000000000000000E-6110
-dqrot146 rotate 1E-6143 -33 -> 1.0E-6142
-dqrot147 rotate 1E-6143 1 -> 1.0E-6142
-dqrot148 rotate 1E-6143 33 -> 1.000000000000000000000000000000000E-6110
-dqrot151 rotate 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144
-dqrot152 rotate 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176
-dqrot153 rotate 1.000000000000000000000000000000000E-6143 1 -> 1E-6176
-dqrot154 rotate 1.000000000000000000000000000000000E-6143 33 -> 1.00000000000000000000000000000000E-6144
-dqrot155 rotate 9.000000000000000000000000000000000E-6143 -1 -> 9.00000000000000000000000000000000E-6144
-dqrot156 rotate 9.000000000000000000000000000000000E-6143 -33 -> 9E-6176
-dqrot157 rotate 9.000000000000000000000000000000000E-6143 1 -> 9E-6176
-dqrot158 rotate 9.000000000000000000000000000000000E-6143 33 -> 9.00000000000000000000000000000000E-6144
-dqrot160 rotate 1E-6176 -1 -> 1.000000000000000000000000000000000E-6143
-dqrot161 rotate 1E-6176 -33 -> 1.0E-6175
-dqrot162 rotate 1E-6176 1 -> 1.0E-6175
-dqrot163 rotate 1E-6176 33 -> 1.000000000000000000000000000000000E-6143
--- negatives
-dqrot171 rotate -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144
-dqrot172 rotate -9.999999999999999999999999999999999E+6144 -33 -> -9.999999999999999999999999999999999E+6144
-dqrot173 rotate -9.999999999999999999999999999999999E+6144 1 -> -9.999999999999999999999999999999999E+6144
-dqrot174 rotate -9.999999999999999999999999999999999E+6144 33 -> -9.999999999999999999999999999999999E+6144
-dqrot175 rotate -1E-6143 -1 -> -1.000000000000000000000000000000000E-6110
-dqrot176 rotate -1E-6143 -33 -> -1.0E-6142
-dqrot177 rotate -1E-6143 1 -> -1.0E-6142
-dqrot178 rotate -1E-6143 33 -> -1.000000000000000000000000000000000E-6110
-dqrot181 rotate -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144
-dqrot182 rotate -1.000000000000000000000000000000000E-6143 -33 -> -1E-6176
-dqrot183 rotate -1.000000000000000000000000000000000E-6143 1 -> -1E-6176
-dqrot184 rotate -1.000000000000000000000000000000000E-6143 33 -> -1.00000000000000000000000000000000E-6144
-dqrot185 rotate -9.000000000000000000000000000000000E-6143 -1 -> -9.00000000000000000000000000000000E-6144
-dqrot186 rotate -9.000000000000000000000000000000000E-6143 -33 -> -9E-6176
-dqrot187 rotate -9.000000000000000000000000000000000E-6143 1 -> -9E-6176
-dqrot188 rotate -9.000000000000000000000000000000000E-6143 33 -> -9.00000000000000000000000000000000E-6144
-dqrot190 rotate -1E-6176 -1 -> -1.000000000000000000000000000000000E-6143
-dqrot191 rotate -1E-6176 -33 -> -1.0E-6175
-dqrot192 rotate -1E-6176 1 -> -1.0E-6175
-dqrot193 rotate -1E-6176 33 -> -1.000000000000000000000000000000000E-6143
-
--- more negatives (of sanities)
-dqrot201 rotate -0 0 -> -0
-dqrot202 rotate -0 2 -> -0
-dqrot203 rotate -1 2 -> -100
-dqrot204 rotate -1 33 -> -1000000000000000000000000000000000
-dqrot205 rotate -1 34 -> -1
-dqrot206 rotate -1 -1 -> -1000000000000000000000000000000000
-dqrot207 rotate -0 -2 -> -0
-dqrot208 rotate -1234567890123456789012345678901234 -1 -> -4123456789012345678901234567890123
-dqrot209 rotate -1234567890123456789012345678901234 -33 -> -2345678901234567890123456789012341
-dqrot210 rotate -1234567890123456789012345678901234 -34 -> -1234567890123456789012345678901234
-dqrot211 rotate -9934567890123456789012345678901234 -33 -> -9345678901234567890123456789012349
-dqrot212 rotate -9934567890123456789012345678901234 -34 -> -9934567890123456789012345678901234
-
-
--- Specials; NaNs are handled as usual
-dqrot781 rotate -Inf -8 -> -Infinity
-dqrot782 rotate -Inf -1 -> -Infinity
-dqrot783 rotate -Inf -0 -> -Infinity
-dqrot784 rotate -Inf 0 -> -Infinity
-dqrot785 rotate -Inf 1 -> -Infinity
-dqrot786 rotate -Inf 8 -> -Infinity
-dqrot787 rotate -1000 -Inf -> NaN Invalid_operation
-dqrot788 rotate -Inf -Inf -> NaN Invalid_operation
-dqrot789 rotate -1 -Inf -> NaN Invalid_operation
-dqrot790 rotate -0 -Inf -> NaN Invalid_operation
-dqrot791 rotate 0 -Inf -> NaN Invalid_operation
-dqrot792 rotate 1 -Inf -> NaN Invalid_operation
-dqrot793 rotate 1000 -Inf -> NaN Invalid_operation
-dqrot794 rotate Inf -Inf -> NaN Invalid_operation
-
-dqrot800 rotate Inf -Inf -> NaN Invalid_operation
-dqrot801 rotate Inf -8 -> Infinity
-dqrot802 rotate Inf -1 -> Infinity
-dqrot803 rotate Inf -0 -> Infinity
-dqrot804 rotate Inf 0 -> Infinity
-dqrot805 rotate Inf 1 -> Infinity
-dqrot806 rotate Inf 8 -> Infinity
-dqrot807 rotate Inf Inf -> NaN Invalid_operation
-dqrot808 rotate -1000 Inf -> NaN Invalid_operation
-dqrot809 rotate -Inf Inf -> NaN Invalid_operation
-dqrot810 rotate -1 Inf -> NaN Invalid_operation
-dqrot811 rotate -0 Inf -> NaN Invalid_operation
-dqrot812 rotate 0 Inf -> NaN Invalid_operation
-dqrot813 rotate 1 Inf -> NaN Invalid_operation
-dqrot814 rotate 1000 Inf -> NaN Invalid_operation
-dqrot815 rotate Inf Inf -> NaN Invalid_operation
-
-dqrot821 rotate NaN -Inf -> NaN
-dqrot822 rotate NaN -1000 -> NaN
-dqrot823 rotate NaN -1 -> NaN
-dqrot824 rotate NaN -0 -> NaN
-dqrot825 rotate NaN 0 -> NaN
-dqrot826 rotate NaN 1 -> NaN
-dqrot827 rotate NaN 1000 -> NaN
-dqrot828 rotate NaN Inf -> NaN
-dqrot829 rotate NaN NaN -> NaN
-dqrot830 rotate -Inf NaN -> NaN
-dqrot831 rotate -1000 NaN -> NaN
-dqrot832 rotate -1 NaN -> NaN
-dqrot833 rotate -0 NaN -> NaN
-dqrot834 rotate 0 NaN -> NaN
-dqrot835 rotate 1 NaN -> NaN
-dqrot836 rotate 1000 NaN -> NaN
-dqrot837 rotate Inf NaN -> NaN
-
-dqrot841 rotate sNaN -Inf -> NaN Invalid_operation
-dqrot842 rotate sNaN -1000 -> NaN Invalid_operation
-dqrot843 rotate sNaN -1 -> NaN Invalid_operation
-dqrot844 rotate sNaN -0 -> NaN Invalid_operation
-dqrot845 rotate sNaN 0 -> NaN Invalid_operation
-dqrot846 rotate sNaN 1 -> NaN Invalid_operation
-dqrot847 rotate sNaN 1000 -> NaN Invalid_operation
-dqrot848 rotate sNaN NaN -> NaN Invalid_operation
-dqrot849 rotate sNaN sNaN -> NaN Invalid_operation
-dqrot850 rotate NaN sNaN -> NaN Invalid_operation
-dqrot851 rotate -Inf sNaN -> NaN Invalid_operation
-dqrot852 rotate -1000 sNaN -> NaN Invalid_operation
-dqrot853 rotate -1 sNaN -> NaN Invalid_operation
-dqrot854 rotate -0 sNaN -> NaN Invalid_operation
-dqrot855 rotate 0 sNaN -> NaN Invalid_operation
-dqrot856 rotate 1 sNaN -> NaN Invalid_operation
-dqrot857 rotate 1000 sNaN -> NaN Invalid_operation
-dqrot858 rotate Inf sNaN -> NaN Invalid_operation
-dqrot859 rotate NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqrot861 rotate NaN1 -Inf -> NaN1
-dqrot862 rotate +NaN2 -1000 -> NaN2
-dqrot863 rotate NaN3 1000 -> NaN3
-dqrot864 rotate NaN4 Inf -> NaN4
-dqrot865 rotate NaN5 +NaN6 -> NaN5
-dqrot866 rotate -Inf NaN7 -> NaN7
-dqrot867 rotate -1000 NaN8 -> NaN8
-dqrot868 rotate 1000 NaN9 -> NaN9
-dqrot869 rotate Inf +NaN10 -> NaN10
-dqrot871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
-dqrot872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
-dqrot873 rotate sNaN13 1000 -> NaN13 Invalid_operation
-dqrot874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
-dqrot875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqrot876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
-dqrot877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
-dqrot878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
-dqrot879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
-dqrot880 rotate Inf sNaN23 -> NaN23 Invalid_operation
-dqrot881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqrot882 rotate -NaN26 NaN28 -> -NaN26
-dqrot883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqrot884 rotate 1000 -NaN30 -> -NaN30
-dqrot885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- dqRotate.decTest -- rotate decQuad coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqrot001 rotate 0 0 -> 0
+dqrot002 rotate 0 2 -> 0
+dqrot003 rotate 1 2 -> 100
+dqrot004 rotate 1 33 -> 1000000000000000000000000000000000
+dqrot005 rotate 1 34 -> 1
+dqrot006 rotate 1 -1 -> 1000000000000000000000000000000000
+dqrot007 rotate 0 -2 -> 0
+dqrot008 rotate 1234567890123456789012345678901234 -1 -> 4123456789012345678901234567890123
+dqrot009 rotate 1234567890123456789012345678901234 -33 -> 2345678901234567890123456789012341
+dqrot010 rotate 1234567890123456789012345678901234 -34 -> 1234567890123456789012345678901234
+dqrot011 rotate 9934567890123456789012345678901234 -33 -> 9345678901234567890123456789012349
+dqrot012 rotate 9934567890123456789012345678901234 -34 -> 9934567890123456789012345678901234
+
+-- rhs must be an integer
+dqrot015 rotate 1 1.5 -> NaN Invalid_operation
+dqrot016 rotate 1 1.0 -> NaN Invalid_operation
+dqrot017 rotate 1 0.1 -> NaN Invalid_operation
+dqrot018 rotate 1 0.0 -> NaN Invalid_operation
+dqrot019 rotate 1 1E+1 -> NaN Invalid_operation
+dqrot020 rotate 1 1E+99 -> NaN Invalid_operation
+dqrot021 rotate 1 Inf -> NaN Invalid_operation
+dqrot022 rotate 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+dqrot025 rotate 1 -1000 -> NaN Invalid_operation
+dqrot026 rotate 1 -35 -> NaN Invalid_operation
+dqrot027 rotate 1 35 -> NaN Invalid_operation
+dqrot028 rotate 1 1000 -> NaN Invalid_operation
+
+-- full pattern
+dqrot030 rotate 1234567890123456789012345678901234 -34 -> 1234567890123456789012345678901234
+dqrot031 rotate 1234567890123456789012345678901234 -33 -> 2345678901234567890123456789012341
+dqrot032 rotate 1234567890123456789012345678901234 -32 -> 3456789012345678901234567890123412
+dqrot033 rotate 1234567890123456789012345678901234 -31 -> 4567890123456789012345678901234123
+dqrot034 rotate 1234567890123456789012345678901234 -30 -> 5678901234567890123456789012341234
+dqrot035 rotate 1234567890123456789012345678901234 -29 -> 6789012345678901234567890123412345
+dqrot036 rotate 1234567890123456789012345678901234 -28 -> 7890123456789012345678901234123456
+dqrot037 rotate 1234567890123456789012345678901234 -27 -> 8901234567890123456789012341234567
+dqrot038 rotate 1234567890123456789012345678901234 -26 -> 9012345678901234567890123412345678
+dqrot039 rotate 1234567890123456789012345678901234 -25 -> 123456789012345678901234123456789
+dqrot040 rotate 1234567890123456789012345678901234 -24 -> 1234567890123456789012341234567890
+dqrot041 rotate 1234567890123456789012345678901234 -23 -> 2345678901234567890123412345678901
+dqrot042 rotate 1234567890123456789012345678901234 -22 -> 3456789012345678901234123456789012
+dqrot043 rotate 1234567890123456789012345678901234 -21 -> 4567890123456789012341234567890123
+dqrot044 rotate 1234567890123456789012345678901234 -20 -> 5678901234567890123412345678901234
+dqrot045 rotate 1234567890123456789012345678901234 -19 -> 6789012345678901234123456789012345
+dqrot047 rotate 1234567890123456789012345678901234 -18 -> 7890123456789012341234567890123456
+dqrot048 rotate 1234567890123456789012345678901234 -17 -> 8901234567890123412345678901234567
+dqrot049 rotate 1234567890123456789012345678901234 -16 -> 9012345678901234123456789012345678
+dqrot050 rotate 1234567890123456789012345678901234 -15 -> 123456789012341234567890123456789
+dqrot051 rotate 1234567890123456789012345678901234 -14 -> 1234567890123412345678901234567890
+dqrot052 rotate 1234567890123456789012345678901234 -13 -> 2345678901234123456789012345678901
+dqrot053 rotate 1234567890123456789012345678901234 -12 -> 3456789012341234567890123456789012
+dqrot054 rotate 1234567890123456789012345678901234 -11 -> 4567890123412345678901234567890123
+dqrot055 rotate 1234567890123456789012345678901234 -10 -> 5678901234123456789012345678901234
+dqrot056 rotate 1234567890123456789012345678901234 -9 -> 6789012341234567890123456789012345
+dqrot057 rotate 1234567890123456789012345678901234 -8 -> 7890123412345678901234567890123456
+dqrot058 rotate 1234567890123456789012345678901234 -7 -> 8901234123456789012345678901234567
+dqrot059 rotate 1234567890123456789012345678901234 -6 -> 9012341234567890123456789012345678
+dqrot060 rotate 1234567890123456789012345678901234 -5 -> 123412345678901234567890123456789
+dqrot061 rotate 1234567890123456789012345678901234 -4 -> 1234123456789012345678901234567890
+dqrot062 rotate 1234567890123456789012345678901234 -3 -> 2341234567890123456789012345678901
+dqrot063 rotate 1234567890123456789012345678901234 -2 -> 3412345678901234567890123456789012
+dqrot064 rotate 1234567890123456789012345678901234 -1 -> 4123456789012345678901234567890123
+dqrot065 rotate 1234567890123456789012345678901234 -0 -> 1234567890123456789012345678901234
+
+dqrot066 rotate 1234567890123456789012345678901234 +0 -> 1234567890123456789012345678901234
+dqrot067 rotate 1234567890123456789012345678901234 +1 -> 2345678901234567890123456789012341
+dqrot068 rotate 1234567890123456789012345678901234 +2 -> 3456789012345678901234567890123412
+dqrot069 rotate 1234567890123456789012345678901234 +3 -> 4567890123456789012345678901234123
+dqrot070 rotate 1234567890123456789012345678901234 +4 -> 5678901234567890123456789012341234
+dqrot071 rotate 1234567890123456789012345678901234 +5 -> 6789012345678901234567890123412345
+dqrot072 rotate 1234567890123456789012345678901234 +6 -> 7890123456789012345678901234123456
+dqrot073 rotate 1234567890123456789012345678901234 +7 -> 8901234567890123456789012341234567
+dqrot074 rotate 1234567890123456789012345678901234 +8 -> 9012345678901234567890123412345678
+dqrot075 rotate 1234567890123456789012345678901234 +9 -> 123456789012345678901234123456789
+dqrot076 rotate 1234567890123456789012345678901234 +10 -> 1234567890123456789012341234567890
+dqrot077 rotate 1234567890123456789012345678901234 +11 -> 2345678901234567890123412345678901
+dqrot078 rotate 1234567890123456789012345678901234 +12 -> 3456789012345678901234123456789012
+dqrot079 rotate 1234567890123456789012345678901234 +13 -> 4567890123456789012341234567890123
+dqrot080 rotate 1234567890123456789012345678901234 +14 -> 5678901234567890123412345678901234
+dqrot081 rotate 1234567890123456789012345678901234 +15 -> 6789012345678901234123456789012345
+dqrot082 rotate 1234567890123456789012345678901234 +16 -> 7890123456789012341234567890123456
+dqrot083 rotate 1234567890123456789012345678901234 +17 -> 8901234567890123412345678901234567
+dqrot084 rotate 1234567890123456789012345678901234 +18 -> 9012345678901234123456789012345678
+dqrot085 rotate 1234567890123456789012345678901234 +19 -> 123456789012341234567890123456789
+dqrot086 rotate 1234567890123456789012345678901234 +20 -> 1234567890123412345678901234567890
+dqrot087 rotate 1234567890123456789012345678901234 +21 -> 2345678901234123456789012345678901
+dqrot088 rotate 1234567890123456789012345678901234 +22 -> 3456789012341234567890123456789012
+dqrot089 rotate 1234567890123456789012345678901234 +23 -> 4567890123412345678901234567890123
+dqrot090 rotate 1234567890123456789012345678901234 +24 -> 5678901234123456789012345678901234
+dqrot091 rotate 1234567890123456789012345678901234 +25 -> 6789012341234567890123456789012345
+dqrot092 rotate 1234567890123456789012345678901234 +26 -> 7890123412345678901234567890123456
+dqrot093 rotate 1234567890123456789012345678901234 +27 -> 8901234123456789012345678901234567
+dqrot094 rotate 1234567890123456789012345678901234 +28 -> 9012341234567890123456789012345678
+dqrot095 rotate 1234567890123456789012345678901234 +29 -> 123412345678901234567890123456789
+dqrot096 rotate 1234567890123456789012345678901234 +30 -> 1234123456789012345678901234567890
+dqrot097 rotate 1234567890123456789012345678901234 +31 -> 2341234567890123456789012345678901
+dqrot098 rotate 1234567890123456789012345678901234 +32 -> 3412345678901234567890123456789012
+dqrot099 rotate 1234567890123456789012345678901234 +33 -> 4123456789012345678901234567890123
+dqrot100 rotate 1234567890123456789012345678901234 +34 -> 1234567890123456789012345678901234
+
+-- zeros
+dqrot270 rotate 0E-10 +29 -> 0E-10
+dqrot271 rotate 0E-10 -29 -> 0E-10
+dqrot272 rotate 0.000 +29 -> 0.000
+dqrot273 rotate 0.000 -29 -> 0.000
+dqrot274 rotate 0E+10 +29 -> 0E+10
+dqrot275 rotate 0E+10 -29 -> 0E+10
+dqrot276 rotate -0E-10 +29 -> -0E-10
+dqrot277 rotate -0E-10 -29 -> -0E-10
+dqrot278 rotate -0.000 +29 -> -0.000
+dqrot279 rotate -0.000 -29 -> -0.000
+dqrot280 rotate -0E+10 +29 -> -0E+10
+dqrot281 rotate -0E+10 -29 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+dqrot141 rotate 9.999999999999999999999999999999999E+6144 -1 -> 9.999999999999999999999999999999999E+6144
+dqrot142 rotate 9.999999999999999999999999999999999E+6144 -33 -> 9.999999999999999999999999999999999E+6144
+dqrot143 rotate 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144
+dqrot144 rotate 9.999999999999999999999999999999999E+6144 33 -> 9.999999999999999999999999999999999E+6144
+dqrot145 rotate 1E-6143 -1 -> 1.000000000000000000000000000000000E-6110
+dqrot146 rotate 1E-6143 -33 -> 1.0E-6142
+dqrot147 rotate 1E-6143 1 -> 1.0E-6142
+dqrot148 rotate 1E-6143 33 -> 1.000000000000000000000000000000000E-6110
+dqrot151 rotate 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144
+dqrot152 rotate 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176
+dqrot153 rotate 1.000000000000000000000000000000000E-6143 1 -> 1E-6176
+dqrot154 rotate 1.000000000000000000000000000000000E-6143 33 -> 1.00000000000000000000000000000000E-6144
+dqrot155 rotate 9.000000000000000000000000000000000E-6143 -1 -> 9.00000000000000000000000000000000E-6144
+dqrot156 rotate 9.000000000000000000000000000000000E-6143 -33 -> 9E-6176
+dqrot157 rotate 9.000000000000000000000000000000000E-6143 1 -> 9E-6176
+dqrot158 rotate 9.000000000000000000000000000000000E-6143 33 -> 9.00000000000000000000000000000000E-6144
+dqrot160 rotate 1E-6176 -1 -> 1.000000000000000000000000000000000E-6143
+dqrot161 rotate 1E-6176 -33 -> 1.0E-6175
+dqrot162 rotate 1E-6176 1 -> 1.0E-6175
+dqrot163 rotate 1E-6176 33 -> 1.000000000000000000000000000000000E-6143
+-- negatives
+dqrot171 rotate -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144
+dqrot172 rotate -9.999999999999999999999999999999999E+6144 -33 -> -9.999999999999999999999999999999999E+6144
+dqrot173 rotate -9.999999999999999999999999999999999E+6144 1 -> -9.999999999999999999999999999999999E+6144
+dqrot174 rotate -9.999999999999999999999999999999999E+6144 33 -> -9.999999999999999999999999999999999E+6144
+dqrot175 rotate -1E-6143 -1 -> -1.000000000000000000000000000000000E-6110
+dqrot176 rotate -1E-6143 -33 -> -1.0E-6142
+dqrot177 rotate -1E-6143 1 -> -1.0E-6142
+dqrot178 rotate -1E-6143 33 -> -1.000000000000000000000000000000000E-6110
+dqrot181 rotate -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144
+dqrot182 rotate -1.000000000000000000000000000000000E-6143 -33 -> -1E-6176
+dqrot183 rotate -1.000000000000000000000000000000000E-6143 1 -> -1E-6176
+dqrot184 rotate -1.000000000000000000000000000000000E-6143 33 -> -1.00000000000000000000000000000000E-6144
+dqrot185 rotate -9.000000000000000000000000000000000E-6143 -1 -> -9.00000000000000000000000000000000E-6144
+dqrot186 rotate -9.000000000000000000000000000000000E-6143 -33 -> -9E-6176
+dqrot187 rotate -9.000000000000000000000000000000000E-6143 1 -> -9E-6176
+dqrot188 rotate -9.000000000000000000000000000000000E-6143 33 -> -9.00000000000000000000000000000000E-6144
+dqrot190 rotate -1E-6176 -1 -> -1.000000000000000000000000000000000E-6143
+dqrot191 rotate -1E-6176 -33 -> -1.0E-6175
+dqrot192 rotate -1E-6176 1 -> -1.0E-6175
+dqrot193 rotate -1E-6176 33 -> -1.000000000000000000000000000000000E-6143
+
+-- more negatives (of sanities)
+dqrot201 rotate -0 0 -> -0
+dqrot202 rotate -0 2 -> -0
+dqrot203 rotate -1 2 -> -100
+dqrot204 rotate -1 33 -> -1000000000000000000000000000000000
+dqrot205 rotate -1 34 -> -1
+dqrot206 rotate -1 -1 -> -1000000000000000000000000000000000
+dqrot207 rotate -0 -2 -> -0
+dqrot208 rotate -1234567890123456789012345678901234 -1 -> -4123456789012345678901234567890123
+dqrot209 rotate -1234567890123456789012345678901234 -33 -> -2345678901234567890123456789012341
+dqrot210 rotate -1234567890123456789012345678901234 -34 -> -1234567890123456789012345678901234
+dqrot211 rotate -9934567890123456789012345678901234 -33 -> -9345678901234567890123456789012349
+dqrot212 rotate -9934567890123456789012345678901234 -34 -> -9934567890123456789012345678901234
+
+
+-- Specials; NaNs are handled as usual
+dqrot781 rotate -Inf -8 -> -Infinity
+dqrot782 rotate -Inf -1 -> -Infinity
+dqrot783 rotate -Inf -0 -> -Infinity
+dqrot784 rotate -Inf 0 -> -Infinity
+dqrot785 rotate -Inf 1 -> -Infinity
+dqrot786 rotate -Inf 8 -> -Infinity
+dqrot787 rotate -1000 -Inf -> NaN Invalid_operation
+dqrot788 rotate -Inf -Inf -> NaN Invalid_operation
+dqrot789 rotate -1 -Inf -> NaN Invalid_operation
+dqrot790 rotate -0 -Inf -> NaN Invalid_operation
+dqrot791 rotate 0 -Inf -> NaN Invalid_operation
+dqrot792 rotate 1 -Inf -> NaN Invalid_operation
+dqrot793 rotate 1000 -Inf -> NaN Invalid_operation
+dqrot794 rotate Inf -Inf -> NaN Invalid_operation
+
+dqrot800 rotate Inf -Inf -> NaN Invalid_operation
+dqrot801 rotate Inf -8 -> Infinity
+dqrot802 rotate Inf -1 -> Infinity
+dqrot803 rotate Inf -0 -> Infinity
+dqrot804 rotate Inf 0 -> Infinity
+dqrot805 rotate Inf 1 -> Infinity
+dqrot806 rotate Inf 8 -> Infinity
+dqrot807 rotate Inf Inf -> NaN Invalid_operation
+dqrot808 rotate -1000 Inf -> NaN Invalid_operation
+dqrot809 rotate -Inf Inf -> NaN Invalid_operation
+dqrot810 rotate -1 Inf -> NaN Invalid_operation
+dqrot811 rotate -0 Inf -> NaN Invalid_operation
+dqrot812 rotate 0 Inf -> NaN Invalid_operation
+dqrot813 rotate 1 Inf -> NaN Invalid_operation
+dqrot814 rotate 1000 Inf -> NaN Invalid_operation
+dqrot815 rotate Inf Inf -> NaN Invalid_operation
+
+dqrot821 rotate NaN -Inf -> NaN
+dqrot822 rotate NaN -1000 -> NaN
+dqrot823 rotate NaN -1 -> NaN
+dqrot824 rotate NaN -0 -> NaN
+dqrot825 rotate NaN 0 -> NaN
+dqrot826 rotate NaN 1 -> NaN
+dqrot827 rotate NaN 1000 -> NaN
+dqrot828 rotate NaN Inf -> NaN
+dqrot829 rotate NaN NaN -> NaN
+dqrot830 rotate -Inf NaN -> NaN
+dqrot831 rotate -1000 NaN -> NaN
+dqrot832 rotate -1 NaN -> NaN
+dqrot833 rotate -0 NaN -> NaN
+dqrot834 rotate 0 NaN -> NaN
+dqrot835 rotate 1 NaN -> NaN
+dqrot836 rotate 1000 NaN -> NaN
+dqrot837 rotate Inf NaN -> NaN
+
+dqrot841 rotate sNaN -Inf -> NaN Invalid_operation
+dqrot842 rotate sNaN -1000 -> NaN Invalid_operation
+dqrot843 rotate sNaN -1 -> NaN Invalid_operation
+dqrot844 rotate sNaN -0 -> NaN Invalid_operation
+dqrot845 rotate sNaN 0 -> NaN Invalid_operation
+dqrot846 rotate sNaN 1 -> NaN Invalid_operation
+dqrot847 rotate sNaN 1000 -> NaN Invalid_operation
+dqrot848 rotate sNaN NaN -> NaN Invalid_operation
+dqrot849 rotate sNaN sNaN -> NaN Invalid_operation
+dqrot850 rotate NaN sNaN -> NaN Invalid_operation
+dqrot851 rotate -Inf sNaN -> NaN Invalid_operation
+dqrot852 rotate -1000 sNaN -> NaN Invalid_operation
+dqrot853 rotate -1 sNaN -> NaN Invalid_operation
+dqrot854 rotate -0 sNaN -> NaN Invalid_operation
+dqrot855 rotate 0 sNaN -> NaN Invalid_operation
+dqrot856 rotate 1 sNaN -> NaN Invalid_operation
+dqrot857 rotate 1000 sNaN -> NaN Invalid_operation
+dqrot858 rotate Inf sNaN -> NaN Invalid_operation
+dqrot859 rotate NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqrot861 rotate NaN1 -Inf -> NaN1
+dqrot862 rotate +NaN2 -1000 -> NaN2
+dqrot863 rotate NaN3 1000 -> NaN3
+dqrot864 rotate NaN4 Inf -> NaN4
+dqrot865 rotate NaN5 +NaN6 -> NaN5
+dqrot866 rotate -Inf NaN7 -> NaN7
+dqrot867 rotate -1000 NaN8 -> NaN8
+dqrot868 rotate 1000 NaN9 -> NaN9
+dqrot869 rotate Inf +NaN10 -> NaN10
+dqrot871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
+dqrot872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
+dqrot873 rotate sNaN13 1000 -> NaN13 Invalid_operation
+dqrot874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
+dqrot875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqrot876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
+dqrot877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
+dqrot878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
+dqrot879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
+dqrot880 rotate Inf sNaN23 -> NaN23 Invalid_operation
+dqrot881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqrot882 rotate -NaN26 NaN28 -> -NaN26
+dqrot883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqrot884 rotate 1000 -NaN30 -> -NaN30
+dqrot885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqSameQuantum.decTest b/Lib/test/decimaltestdata/dqSameQuantum.decTest
index 257cda802d..2f356bbae9 100644
--- a/Lib/test/decimaltestdata/dqSameQuantum.decTest
+++ b/Lib/test/decimaltestdata/dqSameQuantum.decTest
@@ -1,389 +1,389 @@
-------------------------------------------------------------------------
--- dqSameQuantum.decTest -- check decQuad quantums match --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqsamq001 samequantum 0 0 -> 1
-dqsamq002 samequantum 0 1 -> 1
-dqsamq003 samequantum 1 0 -> 1
-dqsamq004 samequantum 1 1 -> 1
-
-dqsamq011 samequantum 10 1E+1 -> 0
-dqsamq012 samequantum 10E+1 10E+1 -> 1
-dqsamq013 samequantum 100 10E+1 -> 0
-dqsamq014 samequantum 100 1E+2 -> 0
-dqsamq015 samequantum 0.1 1E-2 -> 0
-dqsamq016 samequantum 0.1 1E-1 -> 1
-dqsamq017 samequantum 0.1 1E-0 -> 0
-dqsamq018 samequantum 999 999 -> 1
-dqsamq019 samequantum 999E-1 99.9 -> 1
-dqsamq020 samequantum 111E-1 22.2 -> 1
-dqsamq021 samequantum 111E-1 1234.2 -> 1
-
--- zeros
-dqsamq030 samequantum 0.0 1.1 -> 1
-dqsamq031 samequantum 0.0 1.11 -> 0
-dqsamq032 samequantum 0.0 0 -> 0
-dqsamq033 samequantum 0.0 0.0 -> 1
-dqsamq034 samequantum 0.0 0.00 -> 0
-dqsamq035 samequantum 0E+1 0E+0 -> 0
-dqsamq036 samequantum 0E+1 0E+1 -> 1
-dqsamq037 samequantum 0E+1 0E+2 -> 0
-dqsamq038 samequantum 0E-17 0E-16 -> 0
-dqsamq039 samequantum 0E-17 0E-17 -> 1
-dqsamq040 samequantum 0E-17 0E-18 -> 0
-dqsamq041 samequantum 0E-17 0.0E-15 -> 0
-dqsamq042 samequantum 0E-17 0.0E-16 -> 1
-dqsamq043 samequantum 0E-17 0.0E-17 -> 0
-dqsamq044 samequantum -0E-17 0.0E-16 -> 1
-dqsamq045 samequantum 0E-17 -0.0E-17 -> 0
-dqsamq046 samequantum 0E-17 -0.0E-16 -> 1
-dqsamq047 samequantum -0E-17 0.0E-17 -> 0
-dqsamq048 samequantum -0E-17 -0.0E-16 -> 1
-dqsamq049 samequantum -0E-17 -0.0E-17 -> 0
-
--- Nmax, Nmin, Ntiny
-dqsamq051 samequantum 9.99999999999999999999999999999999E+6144 9.99999999999999999999999999999999E+6144 -> 1
-dqsamq052 samequantum 1E-6143 1E-6143 -> 1
-dqsamq053 samequantum 1.00000000000000000000000000000000E-6143 1.00000000000000000000000000000000E-6143 -> 1
-dqsamq054 samequantum 1E-6176 1E-6176 -> 1
-dqsamq055 samequantum 9.99999999999999999999999999999999E+6144 9.99999999999999999999999999999999E+6144 -> 1
-dqsamq056 samequantum 1E-6143 1E-6143 -> 1
-dqsamq057 samequantum 1.00000000000000000000000000000000E-6143 1.00000000000000000000000000000000E-6143 -> 1
-dqsamq058 samequantum 1E-6176 1E-6176 -> 1
-
-dqsamq061 samequantum -1E-6176 -1E-6176 -> 1
-dqsamq062 samequantum -1.00000000000000000000000000000000E-6143 -1.00000000000000000000000000000000E-6143 -> 1
-dqsamq063 samequantum -1E-6143 -1E-6143 -> 1
-dqsamq064 samequantum -9.99999999999999999999999999999999E+6144 -9.99999999999999999999999999999999E+6144 -> 1
-dqsamq065 samequantum -1E-6176 -1E-6176 -> 1
-dqsamq066 samequantum -1.00000000000000000000000000000000E-6143 -1.00000000000000000000000000000000E-6143 -> 1
-dqsamq067 samequantum -1E-6143 -1E-6143 -> 1
-dqsamq068 samequantum -9.99999999999999999999999999999999E+6144 -9.99999999999999999999999999999999E+6144 -> 1
-
-dqsamq071 samequantum -4E-6176 -1E-6176 -> 1
-dqsamq072 samequantum -4.00000000000000000000000000000000E-6143 -1.00000000000000000000000000004000E-6143 -> 1
-dqsamq073 samequantum -4E-6143 -1E-6143 -> 1
-dqsamq074 samequantum -4.99999999999999999999999999999999E+6144 -9.99949999999999999999999999999999E+6144 -> 1
-dqsamq075 samequantum -4E-6176 -1E-6176 -> 1
-dqsamq076 samequantum -4.00000000000000000000000000000000E-6143 -1.00400000000000000000000000000000E-6143 -> 1
-dqsamq077 samequantum -4E-6143 -1E-6143 -> 1
-dqsamq078 samequantum -4.99999999999999999999999999999999E+6144 -9.94999999999999999999999999999999E+6144 -> 1
-
-dqsamq081 samequantum -4E-1006 -1E-6176 -> 0
-dqsamq082 samequantum -4.00000000000000000000000000000000E-6143 -1.00004000000000000000000000000000E-6136 -> 0
-dqsamq083 samequantum -4E-6140 -1E-6143 -> 0
-dqsamq084 samequantum -4.99999999999999999999999999999999E+6144 -9.99949999999999999999999999999999E+6136 -> 0
-dqsamq085 samequantum -4E-1006 -1E-6176 -> 0
-dqsamq086 samequantum -4.00000000000000000000000000000000E-6143 -1.00400000000000000000000000000000E-6136 -> 0
-dqsamq087 samequantum -4E-6133 -1E-6143 -> 0
-dqsamq088 samequantum -4.99999999999999999999999999999999E+6144 -9.94999999999999999999999999999999E+6136 -> 0
-
--- specials & combinations
-dqsamq0110 samequantum -Inf -Inf -> 1
-dqsamq0111 samequantum -Inf Inf -> 1
-dqsamq0112 samequantum -Inf NaN -> 0
-dqsamq0113 samequantum -Inf -7E+3 -> 0
-dqsamq0114 samequantum -Inf -7 -> 0
-dqsamq0115 samequantum -Inf -7E-3 -> 0
-dqsamq0116 samequantum -Inf -0E-3 -> 0
-dqsamq0117 samequantum -Inf -0 -> 0
-dqsamq0118 samequantum -Inf -0E+3 -> 0
-dqsamq0119 samequantum -Inf 0E-3 -> 0
-dqsamq0120 samequantum -Inf 0 -> 0
-dqsamq0121 samequantum -Inf 0E+3 -> 0
-dqsamq0122 samequantum -Inf 7E-3 -> 0
-dqsamq0123 samequantum -Inf 7 -> 0
-dqsamq0124 samequantum -Inf 7E+3 -> 0
-dqsamq0125 samequantum -Inf sNaN -> 0
-
-dqsamq0210 samequantum Inf -Inf -> 1
-dqsamq0211 samequantum Inf Inf -> 1
-dqsamq0212 samequantum Inf NaN -> 0
-dqsamq0213 samequantum Inf -7E+3 -> 0
-dqsamq0214 samequantum Inf -7 -> 0
-dqsamq0215 samequantum Inf -7E-3 -> 0
-dqsamq0216 samequantum Inf -0E-3 -> 0
-dqsamq0217 samequantum Inf -0 -> 0
-dqsamq0218 samequantum Inf -0E+3 -> 0
-dqsamq0219 samequantum Inf 0E-3 -> 0
-dqsamq0220 samequantum Inf 0 -> 0
-dqsamq0221 samequantum Inf 0E+3 -> 0
-dqsamq0222 samequantum Inf 7E-3 -> 0
-dqsamq0223 samequantum Inf 7 -> 0
-dqsamq0224 samequantum Inf 7E+3 -> 0
-dqsamq0225 samequantum Inf sNaN -> 0
-
-dqsamq0310 samequantum NaN -Inf -> 0
-dqsamq0311 samequantum NaN Inf -> 0
-dqsamq0312 samequantum NaN NaN -> 1
-dqsamq0313 samequantum NaN -7E+3 -> 0
-dqsamq0314 samequantum NaN -7 -> 0
-dqsamq0315 samequantum NaN -7E-3 -> 0
-dqsamq0316 samequantum NaN -0E-3 -> 0
-dqsamq0317 samequantum NaN -0 -> 0
-dqsamq0318 samequantum NaN -0E+3 -> 0
-dqsamq0319 samequantum NaN 0E-3 -> 0
-dqsamq0320 samequantum NaN 0 -> 0
-dqsamq0321 samequantum NaN 0E+3 -> 0
-dqsamq0322 samequantum NaN 7E-3 -> 0
-dqsamq0323 samequantum NaN 7 -> 0
-dqsamq0324 samequantum NaN 7E+3 -> 0
-dqsamq0325 samequantum NaN sNaN -> 1
-
-dqsamq0410 samequantum -7E+3 -Inf -> 0
-dqsamq0411 samequantum -7E+3 Inf -> 0
-dqsamq0412 samequantum -7E+3 NaN -> 0
-dqsamq0413 samequantum -7E+3 -7E+3 -> 1
-dqsamq0414 samequantum -7E+3 -7 -> 0
-dqsamq0415 samequantum -7E+3 -7E-3 -> 0
-dqsamq0416 samequantum -7E+3 -0E-3 -> 0
-dqsamq0417 samequantum -7E+3 -0 -> 0
-dqsamq0418 samequantum -7E+3 -0E+3 -> 1
-dqsamq0419 samequantum -7E+3 0E-3 -> 0
-dqsamq0420 samequantum -7E+3 0 -> 0
-dqsamq0421 samequantum -7E+3 0E+3 -> 1
-dqsamq0422 samequantum -7E+3 7E-3 -> 0
-dqsamq0423 samequantum -7E+3 7 -> 0
-dqsamq0424 samequantum -7E+3 7E+3 -> 1
-dqsamq0425 samequantum -7E+3 sNaN -> 0
-
-dqsamq0510 samequantum -7 -Inf -> 0
-dqsamq0511 samequantum -7 Inf -> 0
-dqsamq0512 samequantum -7 NaN -> 0
-dqsamq0513 samequantum -7 -7E+3 -> 0
-dqsamq0514 samequantum -7 -7 -> 1
-dqsamq0515 samequantum -7 -7E-3 -> 0
-dqsamq0516 samequantum -7 -0E-3 -> 0
-dqsamq0517 samequantum -7 -0 -> 1
-dqsamq0518 samequantum -7 -0E+3 -> 0
-dqsamq0519 samequantum -7 0E-3 -> 0
-dqsamq0520 samequantum -7 0 -> 1
-dqsamq0521 samequantum -7 0E+3 -> 0
-dqsamq0522 samequantum -7 7E-3 -> 0
-dqsamq0523 samequantum -7 7 -> 1
-dqsamq0524 samequantum -7 7E+3 -> 0
-dqsamq0525 samequantum -7 sNaN -> 0
-
-dqsamq0610 samequantum -7E-3 -Inf -> 0
-dqsamq0611 samequantum -7E-3 Inf -> 0
-dqsamq0612 samequantum -7E-3 NaN -> 0
-dqsamq0613 samequantum -7E-3 -7E+3 -> 0
-dqsamq0614 samequantum -7E-3 -7 -> 0
-dqsamq0615 samequantum -7E-3 -7E-3 -> 1
-dqsamq0616 samequantum -7E-3 -0E-3 -> 1
-dqsamq0617 samequantum -7E-3 -0 -> 0
-dqsamq0618 samequantum -7E-3 -0E+3 -> 0
-dqsamq0619 samequantum -7E-3 0E-3 -> 1
-dqsamq0620 samequantum -7E-3 0 -> 0
-dqsamq0621 samequantum -7E-3 0E+3 -> 0
-dqsamq0622 samequantum -7E-3 7E-3 -> 1
-dqsamq0623 samequantum -7E-3 7 -> 0
-dqsamq0624 samequantum -7E-3 7E+3 -> 0
-dqsamq0625 samequantum -7E-3 sNaN -> 0
-
-dqsamq0710 samequantum -0E-3 -Inf -> 0
-dqsamq0711 samequantum -0E-3 Inf -> 0
-dqsamq0712 samequantum -0E-3 NaN -> 0
-dqsamq0713 samequantum -0E-3 -7E+3 -> 0
-dqsamq0714 samequantum -0E-3 -7 -> 0
-dqsamq0715 samequantum -0E-3 -7E-3 -> 1
-dqsamq0716 samequantum -0E-3 -0E-3 -> 1
-dqsamq0717 samequantum -0E-3 -0 -> 0
-dqsamq0718 samequantum -0E-3 -0E+3 -> 0
-dqsamq0719 samequantum -0E-3 0E-3 -> 1
-dqsamq0720 samequantum -0E-3 0 -> 0
-dqsamq0721 samequantum -0E-3 0E+3 -> 0
-dqsamq0722 samequantum -0E-3 7E-3 -> 1
-dqsamq0723 samequantum -0E-3 7 -> 0
-dqsamq0724 samequantum -0E-3 7E+3 -> 0
-dqsamq0725 samequantum -0E-3 sNaN -> 0
-
-dqsamq0810 samequantum -0 -Inf -> 0
-dqsamq0811 samequantum -0 Inf -> 0
-dqsamq0812 samequantum -0 NaN -> 0
-dqsamq0813 samequantum -0 -7E+3 -> 0
-dqsamq0814 samequantum -0 -7 -> 1
-dqsamq0815 samequantum -0 -7E-3 -> 0
-dqsamq0816 samequantum -0 -0E-3 -> 0
-dqsamq0817 samequantum -0 -0 -> 1
-dqsamq0818 samequantum -0 -0E+3 -> 0
-dqsamq0819 samequantum -0 0E-3 -> 0
-dqsamq0820 samequantum -0 0 -> 1
-dqsamq0821 samequantum -0 0E+3 -> 0
-dqsamq0822 samequantum -0 7E-3 -> 0
-dqsamq0823 samequantum -0 7 -> 1
-dqsamq0824 samequantum -0 7E+3 -> 0
-dqsamq0825 samequantum -0 sNaN -> 0
-
-dqsamq0910 samequantum -0E+3 -Inf -> 0
-dqsamq0911 samequantum -0E+3 Inf -> 0
-dqsamq0912 samequantum -0E+3 NaN -> 0
-dqsamq0913 samequantum -0E+3 -7E+3 -> 1
-dqsamq0914 samequantum -0E+3 -7 -> 0
-dqsamq0915 samequantum -0E+3 -7E-3 -> 0
-dqsamq0916 samequantum -0E+3 -0E-3 -> 0
-dqsamq0917 samequantum -0E+3 -0 -> 0
-dqsamq0918 samequantum -0E+3 -0E+3 -> 1
-dqsamq0919 samequantum -0E+3 0E-3 -> 0
-dqsamq0920 samequantum -0E+3 0 -> 0
-dqsamq0921 samequantum -0E+3 0E+3 -> 1
-dqsamq0922 samequantum -0E+3 7E-3 -> 0
-dqsamq0923 samequantum -0E+3 7 -> 0
-dqsamq0924 samequantum -0E+3 7E+3 -> 1
-dqsamq0925 samequantum -0E+3 sNaN -> 0
-
-dqsamq1110 samequantum 0E-3 -Inf -> 0
-dqsamq1111 samequantum 0E-3 Inf -> 0
-dqsamq1112 samequantum 0E-3 NaN -> 0
-dqsamq1113 samequantum 0E-3 -7E+3 -> 0
-dqsamq1114 samequantum 0E-3 -7 -> 0
-dqsamq1115 samequantum 0E-3 -7E-3 -> 1
-dqsamq1116 samequantum 0E-3 -0E-3 -> 1
-dqsamq1117 samequantum 0E-3 -0 -> 0
-dqsamq1118 samequantum 0E-3 -0E+3 -> 0
-dqsamq1119 samequantum 0E-3 0E-3 -> 1
-dqsamq1120 samequantum 0E-3 0 -> 0
-dqsamq1121 samequantum 0E-3 0E+3 -> 0
-dqsamq1122 samequantum 0E-3 7E-3 -> 1
-dqsamq1123 samequantum 0E-3 7 -> 0
-dqsamq1124 samequantum 0E-3 7E+3 -> 0
-dqsamq1125 samequantum 0E-3 sNaN -> 0
-
-dqsamq1210 samequantum 0 -Inf -> 0
-dqsamq1211 samequantum 0 Inf -> 0
-dqsamq1212 samequantum 0 NaN -> 0
-dqsamq1213 samequantum 0 -7E+3 -> 0
-dqsamq1214 samequantum 0 -7 -> 1
-dqsamq1215 samequantum 0 -7E-3 -> 0
-dqsamq1216 samequantum 0 -0E-3 -> 0
-dqsamq1217 samequantum 0 -0 -> 1
-dqsamq1218 samequantum 0 -0E+3 -> 0
-dqsamq1219 samequantum 0 0E-3 -> 0
-dqsamq1220 samequantum 0 0 -> 1
-dqsamq1221 samequantum 0 0E+3 -> 0
-dqsamq1222 samequantum 0 7E-3 -> 0
-dqsamq1223 samequantum 0 7 -> 1
-dqsamq1224 samequantum 0 7E+3 -> 0
-dqsamq1225 samequantum 0 sNaN -> 0
-
-dqsamq1310 samequantum 0E+3 -Inf -> 0
-dqsamq1311 samequantum 0E+3 Inf -> 0
-dqsamq1312 samequantum 0E+3 NaN -> 0
-dqsamq1313 samequantum 0E+3 -7E+3 -> 1
-dqsamq1314 samequantum 0E+3 -7 -> 0
-dqsamq1315 samequantum 0E+3 -7E-3 -> 0
-dqsamq1316 samequantum 0E+3 -0E-3 -> 0
-dqsamq1317 samequantum 0E+3 -0 -> 0
-dqsamq1318 samequantum 0E+3 -0E+3 -> 1
-dqsamq1319 samequantum 0E+3 0E-3 -> 0
-dqsamq1320 samequantum 0E+3 0 -> 0
-dqsamq1321 samequantum 0E+3 0E+3 -> 1
-dqsamq1322 samequantum 0E+3 7E-3 -> 0
-dqsamq1323 samequantum 0E+3 7 -> 0
-dqsamq1324 samequantum 0E+3 7E+3 -> 1
-dqsamq1325 samequantum 0E+3 sNaN -> 0
-
-dqsamq1410 samequantum 7E-3 -Inf -> 0
-dqsamq1411 samequantum 7E-3 Inf -> 0
-dqsamq1412 samequantum 7E-3 NaN -> 0
-dqsamq1413 samequantum 7E-3 -7E+3 -> 0
-dqsamq1414 samequantum 7E-3 -7 -> 0
-dqsamq1415 samequantum 7E-3 -7E-3 -> 1
-dqsamq1416 samequantum 7E-3 -0E-3 -> 1
-dqsamq1417 samequantum 7E-3 -0 -> 0
-dqsamq1418 samequantum 7E-3 -0E+3 -> 0
-dqsamq1419 samequantum 7E-3 0E-3 -> 1
-dqsamq1420 samequantum 7E-3 0 -> 0
-dqsamq1421 samequantum 7E-3 0E+3 -> 0
-dqsamq1422 samequantum 7E-3 7E-3 -> 1
-dqsamq1423 samequantum 7E-3 7 -> 0
-dqsamq1424 samequantum 7E-3 7E+3 -> 0
-dqsamq1425 samequantum 7E-3 sNaN -> 0
-
-dqsamq1510 samequantum 7 -Inf -> 0
-dqsamq1511 samequantum 7 Inf -> 0
-dqsamq1512 samequantum 7 NaN -> 0
-dqsamq1513 samequantum 7 -7E+3 -> 0
-dqsamq1514 samequantum 7 -7 -> 1
-dqsamq1515 samequantum 7 -7E-3 -> 0
-dqsamq1516 samequantum 7 -0E-3 -> 0
-dqsamq1517 samequantum 7 -0 -> 1
-dqsamq1518 samequantum 7 -0E+3 -> 0
-dqsamq1519 samequantum 7 0E-3 -> 0
-dqsamq1520 samequantum 7 0 -> 1
-dqsamq1521 samequantum 7 0E+3 -> 0
-dqsamq1522 samequantum 7 7E-3 -> 0
-dqsamq1523 samequantum 7 7 -> 1
-dqsamq1524 samequantum 7 7E+3 -> 0
-dqsamq1525 samequantum 7 sNaN -> 0
-
-dqsamq1610 samequantum 7E+3 -Inf -> 0
-dqsamq1611 samequantum 7E+3 Inf -> 0
-dqsamq1612 samequantum 7E+3 NaN -> 0
-dqsamq1613 samequantum 7E+3 -7E+3 -> 1
-dqsamq1614 samequantum 7E+3 -7 -> 0
-dqsamq1615 samequantum 7E+3 -7E-3 -> 0
-dqsamq1616 samequantum 7E+3 -0E-3 -> 0
-dqsamq1617 samequantum 7E+3 -0 -> 0
-dqsamq1618 samequantum 7E+3 -0E+3 -> 1
-dqsamq1619 samequantum 7E+3 0E-3 -> 0
-dqsamq1620 samequantum 7E+3 0 -> 0
-dqsamq1621 samequantum 7E+3 0E+3 -> 1
-dqsamq1622 samequantum 7E+3 7E-3 -> 0
-dqsamq1623 samequantum 7E+3 7 -> 0
-dqsamq1624 samequantum 7E+3 7E+3 -> 1
-dqsamq1625 samequantum 7E+3 sNaN -> 0
-
-dqsamq1710 samequantum sNaN -Inf -> 0
-dqsamq1711 samequantum sNaN Inf -> 0
-dqsamq1712 samequantum sNaN NaN -> 1
-dqsamq1713 samequantum sNaN -7E+3 -> 0
-dqsamq1714 samequantum sNaN -7 -> 0
-dqsamq1715 samequantum sNaN -7E-3 -> 0
-dqsamq1716 samequantum sNaN -0E-3 -> 0
-dqsamq1717 samequantum sNaN -0 -> 0
-dqsamq1718 samequantum sNaN -0E+3 -> 0
-dqsamq1719 samequantum sNaN 0E-3 -> 0
-dqsamq1720 samequantum sNaN 0 -> 0
-dqsamq1721 samequantum sNaN 0E+3 -> 0
-dqsamq1722 samequantum sNaN 7E-3 -> 0
-dqsamq1723 samequantum sNaN 7 -> 0
-dqsamq1724 samequantum sNaN 7E+3 -> 0
-dqsamq1725 samequantum sNaN sNaN -> 1
--- noisy NaNs
-dqsamq1730 samequantum sNaN3 sNaN3 -> 1
-dqsamq1731 samequantum sNaN3 sNaN4 -> 1
-dqsamq1732 samequantum NaN3 NaN3 -> 1
-dqsamq1733 samequantum NaN3 NaN4 -> 1
-dqsamq1734 samequantum sNaN3 3 -> 0
-dqsamq1735 samequantum NaN3 3 -> 0
-dqsamq1736 samequantum 4 sNaN4 -> 0
-dqsamq1737 samequantum 3 NaN3 -> 0
-dqsamq1738 samequantum Inf sNaN4 -> 0
-dqsamq1739 samequantum -Inf NaN3 -> 0
-
+------------------------------------------------------------------------
+-- dqSameQuantum.decTest -- check decQuad quantums match --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqsamq001 samequantum 0 0 -> 1
+dqsamq002 samequantum 0 1 -> 1
+dqsamq003 samequantum 1 0 -> 1
+dqsamq004 samequantum 1 1 -> 1
+
+dqsamq011 samequantum 10 1E+1 -> 0
+dqsamq012 samequantum 10E+1 10E+1 -> 1
+dqsamq013 samequantum 100 10E+1 -> 0
+dqsamq014 samequantum 100 1E+2 -> 0
+dqsamq015 samequantum 0.1 1E-2 -> 0
+dqsamq016 samequantum 0.1 1E-1 -> 1
+dqsamq017 samequantum 0.1 1E-0 -> 0
+dqsamq018 samequantum 999 999 -> 1
+dqsamq019 samequantum 999E-1 99.9 -> 1
+dqsamq020 samequantum 111E-1 22.2 -> 1
+dqsamq021 samequantum 111E-1 1234.2 -> 1
+
+-- zeros
+dqsamq030 samequantum 0.0 1.1 -> 1
+dqsamq031 samequantum 0.0 1.11 -> 0
+dqsamq032 samequantum 0.0 0 -> 0
+dqsamq033 samequantum 0.0 0.0 -> 1
+dqsamq034 samequantum 0.0 0.00 -> 0
+dqsamq035 samequantum 0E+1 0E+0 -> 0
+dqsamq036 samequantum 0E+1 0E+1 -> 1
+dqsamq037 samequantum 0E+1 0E+2 -> 0
+dqsamq038 samequantum 0E-17 0E-16 -> 0
+dqsamq039 samequantum 0E-17 0E-17 -> 1
+dqsamq040 samequantum 0E-17 0E-18 -> 0
+dqsamq041 samequantum 0E-17 0.0E-15 -> 0
+dqsamq042 samequantum 0E-17 0.0E-16 -> 1
+dqsamq043 samequantum 0E-17 0.0E-17 -> 0
+dqsamq044 samequantum -0E-17 0.0E-16 -> 1
+dqsamq045 samequantum 0E-17 -0.0E-17 -> 0
+dqsamq046 samequantum 0E-17 -0.0E-16 -> 1
+dqsamq047 samequantum -0E-17 0.0E-17 -> 0
+dqsamq048 samequantum -0E-17 -0.0E-16 -> 1
+dqsamq049 samequantum -0E-17 -0.0E-17 -> 0
+
+-- Nmax, Nmin, Ntiny
+dqsamq051 samequantum 9.99999999999999999999999999999999E+6144 9.99999999999999999999999999999999E+6144 -> 1
+dqsamq052 samequantum 1E-6143 1E-6143 -> 1
+dqsamq053 samequantum 1.00000000000000000000000000000000E-6143 1.00000000000000000000000000000000E-6143 -> 1
+dqsamq054 samequantum 1E-6176 1E-6176 -> 1
+dqsamq055 samequantum 9.99999999999999999999999999999999E+6144 9.99999999999999999999999999999999E+6144 -> 1
+dqsamq056 samequantum 1E-6143 1E-6143 -> 1
+dqsamq057 samequantum 1.00000000000000000000000000000000E-6143 1.00000000000000000000000000000000E-6143 -> 1
+dqsamq058 samequantum 1E-6176 1E-6176 -> 1
+
+dqsamq061 samequantum -1E-6176 -1E-6176 -> 1
+dqsamq062 samequantum -1.00000000000000000000000000000000E-6143 -1.00000000000000000000000000000000E-6143 -> 1
+dqsamq063 samequantum -1E-6143 -1E-6143 -> 1
+dqsamq064 samequantum -9.99999999999999999999999999999999E+6144 -9.99999999999999999999999999999999E+6144 -> 1
+dqsamq065 samequantum -1E-6176 -1E-6176 -> 1
+dqsamq066 samequantum -1.00000000000000000000000000000000E-6143 -1.00000000000000000000000000000000E-6143 -> 1
+dqsamq067 samequantum -1E-6143 -1E-6143 -> 1
+dqsamq068 samequantum -9.99999999999999999999999999999999E+6144 -9.99999999999999999999999999999999E+6144 -> 1
+
+dqsamq071 samequantum -4E-6176 -1E-6176 -> 1
+dqsamq072 samequantum -4.00000000000000000000000000000000E-6143 -1.00000000000000000000000000004000E-6143 -> 1
+dqsamq073 samequantum -4E-6143 -1E-6143 -> 1
+dqsamq074 samequantum -4.99999999999999999999999999999999E+6144 -9.99949999999999999999999999999999E+6144 -> 1
+dqsamq075 samequantum -4E-6176 -1E-6176 -> 1
+dqsamq076 samequantum -4.00000000000000000000000000000000E-6143 -1.00400000000000000000000000000000E-6143 -> 1
+dqsamq077 samequantum -4E-6143 -1E-6143 -> 1
+dqsamq078 samequantum -4.99999999999999999999999999999999E+6144 -9.94999999999999999999999999999999E+6144 -> 1
+
+dqsamq081 samequantum -4E-1006 -1E-6176 -> 0
+dqsamq082 samequantum -4.00000000000000000000000000000000E-6143 -1.00004000000000000000000000000000E-6136 -> 0
+dqsamq083 samequantum -4E-6140 -1E-6143 -> 0
+dqsamq084 samequantum -4.99999999999999999999999999999999E+6144 -9.99949999999999999999999999999999E+6136 -> 0
+dqsamq085 samequantum -4E-1006 -1E-6176 -> 0
+dqsamq086 samequantum -4.00000000000000000000000000000000E-6143 -1.00400000000000000000000000000000E-6136 -> 0
+dqsamq087 samequantum -4E-6133 -1E-6143 -> 0
+dqsamq088 samequantum -4.99999999999999999999999999999999E+6144 -9.94999999999999999999999999999999E+6136 -> 0
+
+-- specials & combinations
+dqsamq0110 samequantum -Inf -Inf -> 1
+dqsamq0111 samequantum -Inf Inf -> 1
+dqsamq0112 samequantum -Inf NaN -> 0
+dqsamq0113 samequantum -Inf -7E+3 -> 0
+dqsamq0114 samequantum -Inf -7 -> 0
+dqsamq0115 samequantum -Inf -7E-3 -> 0
+dqsamq0116 samequantum -Inf -0E-3 -> 0
+dqsamq0117 samequantum -Inf -0 -> 0
+dqsamq0118 samequantum -Inf -0E+3 -> 0
+dqsamq0119 samequantum -Inf 0E-3 -> 0
+dqsamq0120 samequantum -Inf 0 -> 0
+dqsamq0121 samequantum -Inf 0E+3 -> 0
+dqsamq0122 samequantum -Inf 7E-3 -> 0
+dqsamq0123 samequantum -Inf 7 -> 0
+dqsamq0124 samequantum -Inf 7E+3 -> 0
+dqsamq0125 samequantum -Inf sNaN -> 0
+
+dqsamq0210 samequantum Inf -Inf -> 1
+dqsamq0211 samequantum Inf Inf -> 1
+dqsamq0212 samequantum Inf NaN -> 0
+dqsamq0213 samequantum Inf -7E+3 -> 0
+dqsamq0214 samequantum Inf -7 -> 0
+dqsamq0215 samequantum Inf -7E-3 -> 0
+dqsamq0216 samequantum Inf -0E-3 -> 0
+dqsamq0217 samequantum Inf -0 -> 0
+dqsamq0218 samequantum Inf -0E+3 -> 0
+dqsamq0219 samequantum Inf 0E-3 -> 0
+dqsamq0220 samequantum Inf 0 -> 0
+dqsamq0221 samequantum Inf 0E+3 -> 0
+dqsamq0222 samequantum Inf 7E-3 -> 0
+dqsamq0223 samequantum Inf 7 -> 0
+dqsamq0224 samequantum Inf 7E+3 -> 0
+dqsamq0225 samequantum Inf sNaN -> 0
+
+dqsamq0310 samequantum NaN -Inf -> 0
+dqsamq0311 samequantum NaN Inf -> 0
+dqsamq0312 samequantum NaN NaN -> 1
+dqsamq0313 samequantum NaN -7E+3 -> 0
+dqsamq0314 samequantum NaN -7 -> 0
+dqsamq0315 samequantum NaN -7E-3 -> 0
+dqsamq0316 samequantum NaN -0E-3 -> 0
+dqsamq0317 samequantum NaN -0 -> 0
+dqsamq0318 samequantum NaN -0E+3 -> 0
+dqsamq0319 samequantum NaN 0E-3 -> 0
+dqsamq0320 samequantum NaN 0 -> 0
+dqsamq0321 samequantum NaN 0E+3 -> 0
+dqsamq0322 samequantum NaN 7E-3 -> 0
+dqsamq0323 samequantum NaN 7 -> 0
+dqsamq0324 samequantum NaN 7E+3 -> 0
+dqsamq0325 samequantum NaN sNaN -> 1
+
+dqsamq0410 samequantum -7E+3 -Inf -> 0
+dqsamq0411 samequantum -7E+3 Inf -> 0
+dqsamq0412 samequantum -7E+3 NaN -> 0
+dqsamq0413 samequantum -7E+3 -7E+3 -> 1
+dqsamq0414 samequantum -7E+3 -7 -> 0
+dqsamq0415 samequantum -7E+3 -7E-3 -> 0
+dqsamq0416 samequantum -7E+3 -0E-3 -> 0
+dqsamq0417 samequantum -7E+3 -0 -> 0
+dqsamq0418 samequantum -7E+3 -0E+3 -> 1
+dqsamq0419 samequantum -7E+3 0E-3 -> 0
+dqsamq0420 samequantum -7E+3 0 -> 0
+dqsamq0421 samequantum -7E+3 0E+3 -> 1
+dqsamq0422 samequantum -7E+3 7E-3 -> 0
+dqsamq0423 samequantum -7E+3 7 -> 0
+dqsamq0424 samequantum -7E+3 7E+3 -> 1
+dqsamq0425 samequantum -7E+3 sNaN -> 0
+
+dqsamq0510 samequantum -7 -Inf -> 0
+dqsamq0511 samequantum -7 Inf -> 0
+dqsamq0512 samequantum -7 NaN -> 0
+dqsamq0513 samequantum -7 -7E+3 -> 0
+dqsamq0514 samequantum -7 -7 -> 1
+dqsamq0515 samequantum -7 -7E-3 -> 0
+dqsamq0516 samequantum -7 -0E-3 -> 0
+dqsamq0517 samequantum -7 -0 -> 1
+dqsamq0518 samequantum -7 -0E+3 -> 0
+dqsamq0519 samequantum -7 0E-3 -> 0
+dqsamq0520 samequantum -7 0 -> 1
+dqsamq0521 samequantum -7 0E+3 -> 0
+dqsamq0522 samequantum -7 7E-3 -> 0
+dqsamq0523 samequantum -7 7 -> 1
+dqsamq0524 samequantum -7 7E+3 -> 0
+dqsamq0525 samequantum -7 sNaN -> 0
+
+dqsamq0610 samequantum -7E-3 -Inf -> 0
+dqsamq0611 samequantum -7E-3 Inf -> 0
+dqsamq0612 samequantum -7E-3 NaN -> 0
+dqsamq0613 samequantum -7E-3 -7E+3 -> 0
+dqsamq0614 samequantum -7E-3 -7 -> 0
+dqsamq0615 samequantum -7E-3 -7E-3 -> 1
+dqsamq0616 samequantum -7E-3 -0E-3 -> 1
+dqsamq0617 samequantum -7E-3 -0 -> 0
+dqsamq0618 samequantum -7E-3 -0E+3 -> 0
+dqsamq0619 samequantum -7E-3 0E-3 -> 1
+dqsamq0620 samequantum -7E-3 0 -> 0
+dqsamq0621 samequantum -7E-3 0E+3 -> 0
+dqsamq0622 samequantum -7E-3 7E-3 -> 1
+dqsamq0623 samequantum -7E-3 7 -> 0
+dqsamq0624 samequantum -7E-3 7E+3 -> 0
+dqsamq0625 samequantum -7E-3 sNaN -> 0
+
+dqsamq0710 samequantum -0E-3 -Inf -> 0
+dqsamq0711 samequantum -0E-3 Inf -> 0
+dqsamq0712 samequantum -0E-3 NaN -> 0
+dqsamq0713 samequantum -0E-3 -7E+3 -> 0
+dqsamq0714 samequantum -0E-3 -7 -> 0
+dqsamq0715 samequantum -0E-3 -7E-3 -> 1
+dqsamq0716 samequantum -0E-3 -0E-3 -> 1
+dqsamq0717 samequantum -0E-3 -0 -> 0
+dqsamq0718 samequantum -0E-3 -0E+3 -> 0
+dqsamq0719 samequantum -0E-3 0E-3 -> 1
+dqsamq0720 samequantum -0E-3 0 -> 0
+dqsamq0721 samequantum -0E-3 0E+3 -> 0
+dqsamq0722 samequantum -0E-3 7E-3 -> 1
+dqsamq0723 samequantum -0E-3 7 -> 0
+dqsamq0724 samequantum -0E-3 7E+3 -> 0
+dqsamq0725 samequantum -0E-3 sNaN -> 0
+
+dqsamq0810 samequantum -0 -Inf -> 0
+dqsamq0811 samequantum -0 Inf -> 0
+dqsamq0812 samequantum -0 NaN -> 0
+dqsamq0813 samequantum -0 -7E+3 -> 0
+dqsamq0814 samequantum -0 -7 -> 1
+dqsamq0815 samequantum -0 -7E-3 -> 0
+dqsamq0816 samequantum -0 -0E-3 -> 0
+dqsamq0817 samequantum -0 -0 -> 1
+dqsamq0818 samequantum -0 -0E+3 -> 0
+dqsamq0819 samequantum -0 0E-3 -> 0
+dqsamq0820 samequantum -0 0 -> 1
+dqsamq0821 samequantum -0 0E+3 -> 0
+dqsamq0822 samequantum -0 7E-3 -> 0
+dqsamq0823 samequantum -0 7 -> 1
+dqsamq0824 samequantum -0 7E+3 -> 0
+dqsamq0825 samequantum -0 sNaN -> 0
+
+dqsamq0910 samequantum -0E+3 -Inf -> 0
+dqsamq0911 samequantum -0E+3 Inf -> 0
+dqsamq0912 samequantum -0E+3 NaN -> 0
+dqsamq0913 samequantum -0E+3 -7E+3 -> 1
+dqsamq0914 samequantum -0E+3 -7 -> 0
+dqsamq0915 samequantum -0E+3 -7E-3 -> 0
+dqsamq0916 samequantum -0E+3 -0E-3 -> 0
+dqsamq0917 samequantum -0E+3 -0 -> 0
+dqsamq0918 samequantum -0E+3 -0E+3 -> 1
+dqsamq0919 samequantum -0E+3 0E-3 -> 0
+dqsamq0920 samequantum -0E+3 0 -> 0
+dqsamq0921 samequantum -0E+3 0E+3 -> 1
+dqsamq0922 samequantum -0E+3 7E-3 -> 0
+dqsamq0923 samequantum -0E+3 7 -> 0
+dqsamq0924 samequantum -0E+3 7E+3 -> 1
+dqsamq0925 samequantum -0E+3 sNaN -> 0
+
+dqsamq1110 samequantum 0E-3 -Inf -> 0
+dqsamq1111 samequantum 0E-3 Inf -> 0
+dqsamq1112 samequantum 0E-3 NaN -> 0
+dqsamq1113 samequantum 0E-3 -7E+3 -> 0
+dqsamq1114 samequantum 0E-3 -7 -> 0
+dqsamq1115 samequantum 0E-3 -7E-3 -> 1
+dqsamq1116 samequantum 0E-3 -0E-3 -> 1
+dqsamq1117 samequantum 0E-3 -0 -> 0
+dqsamq1118 samequantum 0E-3 -0E+3 -> 0
+dqsamq1119 samequantum 0E-3 0E-3 -> 1
+dqsamq1120 samequantum 0E-3 0 -> 0
+dqsamq1121 samequantum 0E-3 0E+3 -> 0
+dqsamq1122 samequantum 0E-3 7E-3 -> 1
+dqsamq1123 samequantum 0E-3 7 -> 0
+dqsamq1124 samequantum 0E-3 7E+3 -> 0
+dqsamq1125 samequantum 0E-3 sNaN -> 0
+
+dqsamq1210 samequantum 0 -Inf -> 0
+dqsamq1211 samequantum 0 Inf -> 0
+dqsamq1212 samequantum 0 NaN -> 0
+dqsamq1213 samequantum 0 -7E+3 -> 0
+dqsamq1214 samequantum 0 -7 -> 1
+dqsamq1215 samequantum 0 -7E-3 -> 0
+dqsamq1216 samequantum 0 -0E-3 -> 0
+dqsamq1217 samequantum 0 -0 -> 1
+dqsamq1218 samequantum 0 -0E+3 -> 0
+dqsamq1219 samequantum 0 0E-3 -> 0
+dqsamq1220 samequantum 0 0 -> 1
+dqsamq1221 samequantum 0 0E+3 -> 0
+dqsamq1222 samequantum 0 7E-3 -> 0
+dqsamq1223 samequantum 0 7 -> 1
+dqsamq1224 samequantum 0 7E+3 -> 0
+dqsamq1225 samequantum 0 sNaN -> 0
+
+dqsamq1310 samequantum 0E+3 -Inf -> 0
+dqsamq1311 samequantum 0E+3 Inf -> 0
+dqsamq1312 samequantum 0E+3 NaN -> 0
+dqsamq1313 samequantum 0E+3 -7E+3 -> 1
+dqsamq1314 samequantum 0E+3 -7 -> 0
+dqsamq1315 samequantum 0E+3 -7E-3 -> 0
+dqsamq1316 samequantum 0E+3 -0E-3 -> 0
+dqsamq1317 samequantum 0E+3 -0 -> 0
+dqsamq1318 samequantum 0E+3 -0E+3 -> 1
+dqsamq1319 samequantum 0E+3 0E-3 -> 0
+dqsamq1320 samequantum 0E+3 0 -> 0
+dqsamq1321 samequantum 0E+3 0E+3 -> 1
+dqsamq1322 samequantum 0E+3 7E-3 -> 0
+dqsamq1323 samequantum 0E+3 7 -> 0
+dqsamq1324 samequantum 0E+3 7E+3 -> 1
+dqsamq1325 samequantum 0E+3 sNaN -> 0
+
+dqsamq1410 samequantum 7E-3 -Inf -> 0
+dqsamq1411 samequantum 7E-3 Inf -> 0
+dqsamq1412 samequantum 7E-3 NaN -> 0
+dqsamq1413 samequantum 7E-3 -7E+3 -> 0
+dqsamq1414 samequantum 7E-3 -7 -> 0
+dqsamq1415 samequantum 7E-3 -7E-3 -> 1
+dqsamq1416 samequantum 7E-3 -0E-3 -> 1
+dqsamq1417 samequantum 7E-3 -0 -> 0
+dqsamq1418 samequantum 7E-3 -0E+3 -> 0
+dqsamq1419 samequantum 7E-3 0E-3 -> 1
+dqsamq1420 samequantum 7E-3 0 -> 0
+dqsamq1421 samequantum 7E-3 0E+3 -> 0
+dqsamq1422 samequantum 7E-3 7E-3 -> 1
+dqsamq1423 samequantum 7E-3 7 -> 0
+dqsamq1424 samequantum 7E-3 7E+3 -> 0
+dqsamq1425 samequantum 7E-3 sNaN -> 0
+
+dqsamq1510 samequantum 7 -Inf -> 0
+dqsamq1511 samequantum 7 Inf -> 0
+dqsamq1512 samequantum 7 NaN -> 0
+dqsamq1513 samequantum 7 -7E+3 -> 0
+dqsamq1514 samequantum 7 -7 -> 1
+dqsamq1515 samequantum 7 -7E-3 -> 0
+dqsamq1516 samequantum 7 -0E-3 -> 0
+dqsamq1517 samequantum 7 -0 -> 1
+dqsamq1518 samequantum 7 -0E+3 -> 0
+dqsamq1519 samequantum 7 0E-3 -> 0
+dqsamq1520 samequantum 7 0 -> 1
+dqsamq1521 samequantum 7 0E+3 -> 0
+dqsamq1522 samequantum 7 7E-3 -> 0
+dqsamq1523 samequantum 7 7 -> 1
+dqsamq1524 samequantum 7 7E+3 -> 0
+dqsamq1525 samequantum 7 sNaN -> 0
+
+dqsamq1610 samequantum 7E+3 -Inf -> 0
+dqsamq1611 samequantum 7E+3 Inf -> 0
+dqsamq1612 samequantum 7E+3 NaN -> 0
+dqsamq1613 samequantum 7E+3 -7E+3 -> 1
+dqsamq1614 samequantum 7E+3 -7 -> 0
+dqsamq1615 samequantum 7E+3 -7E-3 -> 0
+dqsamq1616 samequantum 7E+3 -0E-3 -> 0
+dqsamq1617 samequantum 7E+3 -0 -> 0
+dqsamq1618 samequantum 7E+3 -0E+3 -> 1
+dqsamq1619 samequantum 7E+3 0E-3 -> 0
+dqsamq1620 samequantum 7E+3 0 -> 0
+dqsamq1621 samequantum 7E+3 0E+3 -> 1
+dqsamq1622 samequantum 7E+3 7E-3 -> 0
+dqsamq1623 samequantum 7E+3 7 -> 0
+dqsamq1624 samequantum 7E+3 7E+3 -> 1
+dqsamq1625 samequantum 7E+3 sNaN -> 0
+
+dqsamq1710 samequantum sNaN -Inf -> 0
+dqsamq1711 samequantum sNaN Inf -> 0
+dqsamq1712 samequantum sNaN NaN -> 1
+dqsamq1713 samequantum sNaN -7E+3 -> 0
+dqsamq1714 samequantum sNaN -7 -> 0
+dqsamq1715 samequantum sNaN -7E-3 -> 0
+dqsamq1716 samequantum sNaN -0E-3 -> 0
+dqsamq1717 samequantum sNaN -0 -> 0
+dqsamq1718 samequantum sNaN -0E+3 -> 0
+dqsamq1719 samequantum sNaN 0E-3 -> 0
+dqsamq1720 samequantum sNaN 0 -> 0
+dqsamq1721 samequantum sNaN 0E+3 -> 0
+dqsamq1722 samequantum sNaN 7E-3 -> 0
+dqsamq1723 samequantum sNaN 7 -> 0
+dqsamq1724 samequantum sNaN 7E+3 -> 0
+dqsamq1725 samequantum sNaN sNaN -> 1
+-- noisy NaNs
+dqsamq1730 samequantum sNaN3 sNaN3 -> 1
+dqsamq1731 samequantum sNaN3 sNaN4 -> 1
+dqsamq1732 samequantum NaN3 NaN3 -> 1
+dqsamq1733 samequantum NaN3 NaN4 -> 1
+dqsamq1734 samequantum sNaN3 3 -> 0
+dqsamq1735 samequantum NaN3 3 -> 0
+dqsamq1736 samequantum 4 sNaN4 -> 0
+dqsamq1737 samequantum 3 NaN3 -> 0
+dqsamq1738 samequantum Inf sNaN4 -> 0
+dqsamq1739 samequantum -Inf NaN3 -> 0
+
diff --git a/Lib/test/decimaltestdata/dqScaleB.decTest b/Lib/test/decimaltestdata/dqScaleB.decTest
index 045dc58d82..01e1191963 100644
--- a/Lib/test/decimaltestdata/dqScaleB.decTest
+++ b/Lib/test/decimaltestdata/dqScaleB.decTest
@@ -1,260 +1,260 @@
-------------------------------------------------------------------------
--- dqScalebB.decTest -- scale a decQuad by powers of 10 --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Max |rhs| is 2*(6144+34) = 12356
-
--- Sanity checks
-dqscb001 scaleb 7.50 10 -> 7.50E+10
-dqscb002 scaleb 7.50 3 -> 7.50E+3
-dqscb003 scaleb 7.50 2 -> 750
-dqscb004 scaleb 7.50 1 -> 75.0
-dqscb005 scaleb 7.50 0 -> 7.50
-dqscb006 scaleb 7.50 -1 -> 0.750
-dqscb007 scaleb 7.50 -2 -> 0.0750
-dqscb008 scaleb 7.50 -10 -> 7.50E-10
-dqscb009 scaleb -7.50 3 -> -7.50E+3
-dqscb010 scaleb -7.50 2 -> -750
-dqscb011 scaleb -7.50 1 -> -75.0
-dqscb012 scaleb -7.50 0 -> -7.50
-dqscb013 scaleb -7.50 -1 -> -0.750
-
--- Infinities
-dqscb014 scaleb Infinity 1 -> Infinity
-dqscb015 scaleb -Infinity 2 -> -Infinity
-dqscb016 scaleb Infinity -1 -> Infinity
-dqscb017 scaleb -Infinity -2 -> -Infinity
-
--- Next two are somewhat undefined in 754r; treat as non-integer
-dqscb018 scaleb 10 Infinity -> NaN Invalid_operation
-dqscb019 scaleb 10 -Infinity -> NaN Invalid_operation
-
--- NaNs are undefined in 754r; assume usual processing
--- NaNs, 0 payload
-dqscb021 scaleb NaN 1 -> NaN
-dqscb022 scaleb -NaN -1 -> -NaN
-dqscb023 scaleb sNaN 1 -> NaN Invalid_operation
-dqscb024 scaleb -sNaN 1 -> -NaN Invalid_operation
-dqscb025 scaleb 4 NaN -> NaN
-dqscb026 scaleb -Inf -NaN -> -NaN
-dqscb027 scaleb 4 sNaN -> NaN Invalid_operation
-dqscb028 scaleb Inf -sNaN -> -NaN Invalid_operation
-
--- non-integer RHS
-dqscb030 scaleb 1.23 1 -> 12.3
-dqscb031 scaleb 1.23 1.00 -> NaN Invalid_operation
-dqscb032 scaleb 1.23 1.1 -> NaN Invalid_operation
-dqscb033 scaleb 1.23 1.01 -> NaN Invalid_operation
-dqscb034 scaleb 1.23 0.01 -> NaN Invalid_operation
-dqscb035 scaleb 1.23 0.11 -> NaN Invalid_operation
-dqscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
-dqscb037 scaleb 1.23 -1 -> 0.123
-dqscb0614 scaleb 1.23 -1.00 -> NaN Invalid_operation
-dqscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation
-dqscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation
-dqscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation
-dqscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation
-dqscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
-dqscb044 scaleb 1.23 0.1 -> NaN Invalid_operation
-dqscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation
-dqscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
-dqscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
-
--- out-of range RHS
-dqscb120 scaleb 1.23 12355 -> Infinity Overflow Inexact Rounded
-dqscb121 scaleb 1.23 12356 -> Infinity Overflow Inexact Rounded
-dqscb122 scaleb 1.23 12357 -> NaN Invalid_operation
-dqscb123 scaleb 1.23 12358 -> NaN Invalid_operation
-dqscb124 scaleb 1.23 -12355 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqscb125 scaleb 1.23 -12356 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqscb126 scaleb 1.23 -12357 -> NaN Invalid_operation
-dqscb127 scaleb 1.23 -12358 -> NaN Invalid_operation
-
--- NaNs, non-0 payload
--- propagating NaNs
-dqscb861 scaleb NaN01 -Inf -> NaN1
-dqscb862 scaleb -NaN02 -1000 -> -NaN2
-dqscb863 scaleb NaN03 1000 -> NaN3
-dqscb864 scaleb NaN04 Inf -> NaN4
-dqscb865 scaleb NaN05 NaN61 -> NaN5
-dqscb866 scaleb -Inf -NaN71 -> -NaN71
-dqscb867 scaleb -1000 NaN81 -> NaN81
-dqscb868 scaleb 1000 NaN91 -> NaN91
-dqscb869 scaleb Inf NaN101 -> NaN101
-dqscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
-dqscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
-dqscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
-dqscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
-dqscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
-dqscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
-dqscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
-dqscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
-dqscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
-dqscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
-dqscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- finites
-dqscb051 scaleb 7 -2 -> 0.07
-dqscb052 scaleb -7 -2 -> -0.07
-dqscb053 scaleb 75 -2 -> 0.75
-dqscb054 scaleb -75 -2 -> -0.75
-dqscb055 scaleb 7.50 -2 -> 0.0750
-dqscb056 scaleb -7.50 -2 -> -0.0750
-dqscb057 scaleb 7.500 -2 -> 0.07500
-dqscb058 scaleb -7.500 -2 -> -0.07500
-dqscb061 scaleb 7 -1 -> 0.7
-dqscb062 scaleb -7 -1 -> -0.7
-dqscb063 scaleb 75 -1 -> 7.5
-dqscb064 scaleb -75 -1 -> -7.5
-dqscb065 scaleb 7.50 -1 -> 0.750
-dqscb066 scaleb -7.50 -1 -> -0.750
-dqscb067 scaleb 7.500 -1 -> 0.7500
-dqscb068 scaleb -7.500 -1 -> -0.7500
-dqscb071 scaleb 7 0 -> 7
-dqscb072 scaleb -7 0 -> -7
-dqscb073 scaleb 75 0 -> 75
-dqscb074 scaleb -75 0 -> -75
-dqscb075 scaleb 7.50 0 -> 7.50
-dqscb076 scaleb -7.50 0 -> -7.50
-dqscb077 scaleb 7.500 0 -> 7.500
-dqscb078 scaleb -7.500 0 -> -7.500
-dqscb081 scaleb 7 1 -> 7E+1
-dqscb082 scaleb -7 1 -> -7E+1
-dqscb083 scaleb 75 1 -> 7.5E+2
-dqscb084 scaleb -75 1 -> -7.5E+2
-dqscb085 scaleb 7.50 1 -> 75.0
-dqscb086 scaleb -7.50 1 -> -75.0
-dqscb087 scaleb 7.500 1 -> 75.00
-dqscb088 scaleb -7.500 1 -> -75.00
-dqscb091 scaleb 7 2 -> 7E+2
-dqscb092 scaleb -7 2 -> -7E+2
-dqscb093 scaleb 75 2 -> 7.5E+3
-dqscb094 scaleb -75 2 -> -7.5E+3
-dqscb095 scaleb 7.50 2 -> 750
-dqscb096 scaleb -7.50 2 -> -750
-dqscb097 scaleb 7.500 2 -> 750.0
-dqscb098 scaleb -7.500 2 -> -750.0
-
--- zeros
-dqscb111 scaleb 0 1 -> 0E+1
-dqscb112 scaleb -0 2 -> -0E+2
-dqscb113 scaleb 0E+4 3 -> 0E+7
-dqscb114 scaleb -0E+4 4 -> -0E+8
-dqscb115 scaleb 0.0000 5 -> 0E+1
-dqscb116 scaleb -0.0000 6 -> -0E+2
-dqscb117 scaleb 0E-141 7 -> 0E-134
-dqscb118 scaleb -0E-141 8 -> -0E-133
-
--- Nmax, Nmin, Ntiny
-dqscb132 scaleb 9.999999999999999999999999999999999E+6144 +6144 -> Infinity Overflow Inexact Rounded
-dqscb133 scaleb 9.999999999999999999999999999999999E+6144 +10 -> Infinity Overflow Inexact Rounded
-dqscb134 scaleb 9.999999999999999999999999999999999E+6144 +1 -> Infinity Overflow Inexact Rounded
-dqscb135 scaleb 9.999999999999999999999999999999999E+6144 0 -> 9.999999999999999999999999999999999E+6144
-dqscb136 scaleb 9.999999999999999999999999999999999E+6144 -1 -> 9.999999999999999999999999999999999E+6143
-dqscb137 scaleb 1E-6143 +1 -> 1E-6142
-dqscb1614 scaleb 1E-6143 -0 -> 1E-6143
-dqscb139 scaleb 1E-6143 -1 -> 1E-6144 Subnormal
-dqscb140 scaleb 1.000000000000000000000000000000000E-6143 +1 -> 1.000000000000000000000000000000000E-6142
-dqscb141 scaleb 1.000000000000000000000000000000000E-6143 0 -> 1.000000000000000000000000000000000E-6143
-dqscb142 scaleb 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
-dqscb143 scaleb 1E-6176 +1 -> 1E-6175 Subnormal
-dqscb144 scaleb 1E-6176 -0 -> 1E-6176 Subnormal
-dqscb145 scaleb 1E-6176 -1 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqscb150 scaleb -1E-6176 +1 -> -1E-6175 Subnormal
-dqscb151 scaleb -1E-6176 -0 -> -1E-6176 Subnormal
-dqscb152 scaleb -1E-6176 -1 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqscb153 scaleb -1.000000000000000000000000000000000E-6143 +1 -> -1.000000000000000000000000000000000E-6142
-dqscb154 scaleb -1.000000000000000000000000000000000E-6143 +0 -> -1.000000000000000000000000000000000E-6143
-dqscb155 scaleb -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144 Subnormal Rounded
-dqscb156 scaleb -1E-6143 +1 -> -1E-6142
-dqscb157 scaleb -1E-6143 -0 -> -1E-6143
-dqscb158 scaleb -1E-6143 -1 -> -1E-6144 Subnormal
-dqscb159 scaleb -9.999999999999999999999999999999999E+6144 +1 -> -Infinity Overflow Inexact Rounded
-dqscb160 scaleb -9.999999999999999999999999999999999E+6144 +0 -> -9.999999999999999999999999999999999E+6144
-dqscb161 scaleb -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6143
-dqscb162 scaleb -9E+6144 +1 -> -Infinity Overflow Inexact Rounded
-dqscb163 scaleb -1E+6144 +1 -> -Infinity Overflow Inexact Rounded
-
--- some Origami
--- (these check that overflow is being done correctly)
-dqscb171 scaleb 1000E+6109 +1 -> 1.000E+6113
-dqscb172 scaleb 1000E+6110 +1 -> 1.000E+6114
-dqscb173 scaleb 1000E+6111 +1 -> 1.0000E+6115 Clamped
-dqscb174 scaleb 1000E+6112 +1 -> 1.00000E+6116 Clamped
-dqscb175 scaleb 1000E+6113 +1 -> 1.000000E+6117 Clamped
-dqscb176 scaleb 1000E+6114 +1 -> 1.0000000E+6118 Clamped
-dqscb177 scaleb 1000E+6131 +1 -> 1.000000000000000000000000E+6135 Clamped
-dqscb178 scaleb 1000E+6132 +1 -> 1.0000000000000000000000000E+6136 Clamped
-dqscb179 scaleb 1000E+6133 +1 -> 1.00000000000000000000000000E+6137 Clamped
-dqscb180 scaleb 1000E+6134 +1 -> 1.000000000000000000000000000E+6138 Clamped
-dqscb181 scaleb 1000E+6135 +1 -> 1.0000000000000000000000000000E+6139 Clamped
-dqscb182 scaleb 1000E+6136 +1 -> 1.00000000000000000000000000000E+6140 Clamped
-dqscb183 scaleb 1000E+6137 +1 -> 1.000000000000000000000000000000E+6141 Clamped
-dqscb184 scaleb 1000E+6138 +1 -> 1.0000000000000000000000000000000E+6142 Clamped
-dqscb185 scaleb 1000E+6139 +1 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqscb186 scaleb 1000E+6140 +1 -> 1.000000000000000000000000000000000E+6144 Clamped
-dqscb187 scaleb 1000E+6141 +1 -> Infinity Overflow Inexact Rounded
-
--- and a few more subnormal truncations
--- (these check that underflow is being done correctly)
-dqscb221 scaleb 1.000000000000000000000000000000000E-6143 0 -> 1.000000000000000000000000000000000E-6143
-dqscb222 scaleb 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
-dqscb223 scaleb 1.000000000000000000000000000000000E-6143 -2 -> 1.0000000000000000000000000000000E-6145 Subnormal Rounded
-dqscb224 scaleb 1.000000000000000000000000000000000E-6143 -3 -> 1.000000000000000000000000000000E-6146 Subnormal Rounded
-dqscb225 scaleb 1.000000000000000000000000000000000E-6143 -4 -> 1.00000000000000000000000000000E-6147 Subnormal Rounded
-dqscb226 scaleb 1.000000000000000000000000000000000E-6143 -5 -> 1.0000000000000000000000000000E-6148 Subnormal Rounded
-dqscb227 scaleb 1.000000000000000000000000000000000E-6143 -6 -> 1.000000000000000000000000000E-6149 Subnormal Rounded
-dqscb228 scaleb 1.000000000000000000000000000000000E-6143 -7 -> 1.00000000000000000000000000E-6150 Subnormal Rounded
-dqscb229 scaleb 1.000000000000000000000000000000000E-6143 -8 -> 1.0000000000000000000000000E-6151 Subnormal Rounded
-dqscb230 scaleb 1.000000000000000000000000000000000E-6143 -9 -> 1.000000000000000000000000E-6152 Subnormal Rounded
-dqscb231 scaleb 1.000000000000000000000000000000000E-6143 -10 -> 1.00000000000000000000000E-6153 Subnormal Rounded
-dqscb232 scaleb 1.000000000000000000000000000000000E-6143 -11 -> 1.0000000000000000000000E-6154 Subnormal Rounded
-dqscb233 scaleb 1.000000000000000000000000000000000E-6143 -12 -> 1.000000000000000000000E-6155 Subnormal Rounded
-dqscb234 scaleb 1.000000000000000000000000000000000E-6143 -13 -> 1.00000000000000000000E-6156 Subnormal Rounded
-dqscb235 scaleb 1.000000000000000000000000000000000E-6143 -14 -> 1.0000000000000000000E-6157 Subnormal Rounded
-dqscb236 scaleb 1.000000000000000000000000000000000E-6143 -15 -> 1.000000000000000000E-6158 Subnormal Rounded
-dqscb237 scaleb 1.000000000000000000000000000000000E-6143 -16 -> 1.00000000000000000E-6159 Subnormal Rounded
-dqscb238 scaleb 1.000000000000000000000000000000000E-6143 -17 -> 1.0000000000000000E-6160 Subnormal Rounded
-dqscb239 scaleb 1.000000000000000000000000000000000E-6143 -18 -> 1.000000000000000E-6161 Subnormal Rounded
-dqscb202 scaleb 1.000000000000000000000000000000000E-6143 -19 -> 1.00000000000000E-6162 Subnormal Rounded
-dqscb203 scaleb 1.000000000000000000000000000000000E-6143 -20 -> 1.0000000000000E-6163 Subnormal Rounded
-dqscb204 scaleb 1.000000000000000000000000000000000E-6143 -21 -> 1.000000000000E-6164 Subnormal Rounded
-dqscb205 scaleb 1.000000000000000000000000000000000E-6143 -22 -> 1.00000000000E-6165 Subnormal Rounded
-dqscb206 scaleb 1.000000000000000000000000000000000E-6143 -23 -> 1.0000000000E-6166 Subnormal Rounded
-dqscb207 scaleb 1.000000000000000000000000000000000E-6143 -24 -> 1.000000000E-6167 Subnormal Rounded
-dqscb208 scaleb 1.000000000000000000000000000000000E-6143 -25 -> 1.00000000E-6168 Subnormal Rounded
-dqscb209 scaleb 1.000000000000000000000000000000000E-6143 -26 -> 1.0000000E-6169 Subnormal Rounded
-dqscb210 scaleb 1.000000000000000000000000000000000E-6143 -27 -> 1.000000E-6170 Subnormal Rounded
-dqscb211 scaleb 1.000000000000000000000000000000000E-6143 -28 -> 1.00000E-6171 Subnormal Rounded
-dqscb212 scaleb 1.000000000000000000000000000000000E-6143 -29 -> 1.0000E-6172 Subnormal Rounded
-dqscb213 scaleb 1.000000000000000000000000000000000E-6143 -30 -> 1.000E-6173 Subnormal Rounded
-dqscb214 scaleb 1.000000000000000000000000000000000E-6143 -31 -> 1.00E-6174 Subnormal Rounded
-dqscb215 scaleb 1.000000000000000000000000000000000E-6143 -32 -> 1.0E-6175 Subnormal Rounded
-dqscb216 scaleb 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176 Subnormal Rounded
-dqscb217 scaleb 1.000000000000000000000000000000000E-6143 -34 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqscb218 scaleb 1.000000000000000000000000000000000E-6143 -35 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+------------------------------------------------------------------------
+-- dqScalebB.decTest -- scale a decQuad by powers of 10 --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Max |rhs| is 2*(6144+34) = 12356
+
+-- Sanity checks
+dqscb001 scaleb 7.50 10 -> 7.50E+10
+dqscb002 scaleb 7.50 3 -> 7.50E+3
+dqscb003 scaleb 7.50 2 -> 750
+dqscb004 scaleb 7.50 1 -> 75.0
+dqscb005 scaleb 7.50 0 -> 7.50
+dqscb006 scaleb 7.50 -1 -> 0.750
+dqscb007 scaleb 7.50 -2 -> 0.0750
+dqscb008 scaleb 7.50 -10 -> 7.50E-10
+dqscb009 scaleb -7.50 3 -> -7.50E+3
+dqscb010 scaleb -7.50 2 -> -750
+dqscb011 scaleb -7.50 1 -> -75.0
+dqscb012 scaleb -7.50 0 -> -7.50
+dqscb013 scaleb -7.50 -1 -> -0.750
+
+-- Infinities
+dqscb014 scaleb Infinity 1 -> Infinity
+dqscb015 scaleb -Infinity 2 -> -Infinity
+dqscb016 scaleb Infinity -1 -> Infinity
+dqscb017 scaleb -Infinity -2 -> -Infinity
+
+-- Next two are somewhat undefined in 754r; treat as non-integer
+dqscb018 scaleb 10 Infinity -> NaN Invalid_operation
+dqscb019 scaleb 10 -Infinity -> NaN Invalid_operation
+
+-- NaNs are undefined in 754r; assume usual processing
+-- NaNs, 0 payload
+dqscb021 scaleb NaN 1 -> NaN
+dqscb022 scaleb -NaN -1 -> -NaN
+dqscb023 scaleb sNaN 1 -> NaN Invalid_operation
+dqscb024 scaleb -sNaN 1 -> -NaN Invalid_operation
+dqscb025 scaleb 4 NaN -> NaN
+dqscb026 scaleb -Inf -NaN -> -NaN
+dqscb027 scaleb 4 sNaN -> NaN Invalid_operation
+dqscb028 scaleb Inf -sNaN -> -NaN Invalid_operation
+
+-- non-integer RHS
+dqscb030 scaleb 1.23 1 -> 12.3
+dqscb031 scaleb 1.23 1.00 -> NaN Invalid_operation
+dqscb032 scaleb 1.23 1.1 -> NaN Invalid_operation
+dqscb033 scaleb 1.23 1.01 -> NaN Invalid_operation
+dqscb034 scaleb 1.23 0.01 -> NaN Invalid_operation
+dqscb035 scaleb 1.23 0.11 -> NaN Invalid_operation
+dqscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
+dqscb037 scaleb 1.23 -1 -> 0.123
+dqscb0614 scaleb 1.23 -1.00 -> NaN Invalid_operation
+dqscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation
+dqscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation
+dqscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation
+dqscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation
+dqscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
+dqscb044 scaleb 1.23 0.1 -> NaN Invalid_operation
+dqscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation
+dqscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
+dqscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
+
+-- out-of range RHS
+dqscb120 scaleb 1.23 12355 -> Infinity Overflow Inexact Rounded
+dqscb121 scaleb 1.23 12356 -> Infinity Overflow Inexact Rounded
+dqscb122 scaleb 1.23 12357 -> NaN Invalid_operation
+dqscb123 scaleb 1.23 12358 -> NaN Invalid_operation
+dqscb124 scaleb 1.23 -12355 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqscb125 scaleb 1.23 -12356 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqscb126 scaleb 1.23 -12357 -> NaN Invalid_operation
+dqscb127 scaleb 1.23 -12358 -> NaN Invalid_operation
+
+-- NaNs, non-0 payload
+-- propagating NaNs
+dqscb861 scaleb NaN01 -Inf -> NaN1
+dqscb862 scaleb -NaN02 -1000 -> -NaN2
+dqscb863 scaleb NaN03 1000 -> NaN3
+dqscb864 scaleb NaN04 Inf -> NaN4
+dqscb865 scaleb NaN05 NaN61 -> NaN5
+dqscb866 scaleb -Inf -NaN71 -> -NaN71
+dqscb867 scaleb -1000 NaN81 -> NaN81
+dqscb868 scaleb 1000 NaN91 -> NaN91
+dqscb869 scaleb Inf NaN101 -> NaN101
+dqscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
+dqscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
+dqscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
+dqscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
+dqscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
+dqscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
+dqscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
+dqscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
+dqscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
+dqscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
+dqscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- finites
+dqscb051 scaleb 7 -2 -> 0.07
+dqscb052 scaleb -7 -2 -> -0.07
+dqscb053 scaleb 75 -2 -> 0.75
+dqscb054 scaleb -75 -2 -> -0.75
+dqscb055 scaleb 7.50 -2 -> 0.0750
+dqscb056 scaleb -7.50 -2 -> -0.0750
+dqscb057 scaleb 7.500 -2 -> 0.07500
+dqscb058 scaleb -7.500 -2 -> -0.07500
+dqscb061 scaleb 7 -1 -> 0.7
+dqscb062 scaleb -7 -1 -> -0.7
+dqscb063 scaleb 75 -1 -> 7.5
+dqscb064 scaleb -75 -1 -> -7.5
+dqscb065 scaleb 7.50 -1 -> 0.750
+dqscb066 scaleb -7.50 -1 -> -0.750
+dqscb067 scaleb 7.500 -1 -> 0.7500
+dqscb068 scaleb -7.500 -1 -> -0.7500
+dqscb071 scaleb 7 0 -> 7
+dqscb072 scaleb -7 0 -> -7
+dqscb073 scaleb 75 0 -> 75
+dqscb074 scaleb -75 0 -> -75
+dqscb075 scaleb 7.50 0 -> 7.50
+dqscb076 scaleb -7.50 0 -> -7.50
+dqscb077 scaleb 7.500 0 -> 7.500
+dqscb078 scaleb -7.500 0 -> -7.500
+dqscb081 scaleb 7 1 -> 7E+1
+dqscb082 scaleb -7 1 -> -7E+1
+dqscb083 scaleb 75 1 -> 7.5E+2
+dqscb084 scaleb -75 1 -> -7.5E+2
+dqscb085 scaleb 7.50 1 -> 75.0
+dqscb086 scaleb -7.50 1 -> -75.0
+dqscb087 scaleb 7.500 1 -> 75.00
+dqscb088 scaleb -7.500 1 -> -75.00
+dqscb091 scaleb 7 2 -> 7E+2
+dqscb092 scaleb -7 2 -> -7E+2
+dqscb093 scaleb 75 2 -> 7.5E+3
+dqscb094 scaleb -75 2 -> -7.5E+3
+dqscb095 scaleb 7.50 2 -> 750
+dqscb096 scaleb -7.50 2 -> -750
+dqscb097 scaleb 7.500 2 -> 750.0
+dqscb098 scaleb -7.500 2 -> -750.0
+
+-- zeros
+dqscb111 scaleb 0 1 -> 0E+1
+dqscb112 scaleb -0 2 -> -0E+2
+dqscb113 scaleb 0E+4 3 -> 0E+7
+dqscb114 scaleb -0E+4 4 -> -0E+8
+dqscb115 scaleb 0.0000 5 -> 0E+1
+dqscb116 scaleb -0.0000 6 -> -0E+2
+dqscb117 scaleb 0E-141 7 -> 0E-134
+dqscb118 scaleb -0E-141 8 -> -0E-133
+
+-- Nmax, Nmin, Ntiny
+dqscb132 scaleb 9.999999999999999999999999999999999E+6144 +6144 -> Infinity Overflow Inexact Rounded
+dqscb133 scaleb 9.999999999999999999999999999999999E+6144 +10 -> Infinity Overflow Inexact Rounded
+dqscb134 scaleb 9.999999999999999999999999999999999E+6144 +1 -> Infinity Overflow Inexact Rounded
+dqscb135 scaleb 9.999999999999999999999999999999999E+6144 0 -> 9.999999999999999999999999999999999E+6144
+dqscb136 scaleb 9.999999999999999999999999999999999E+6144 -1 -> 9.999999999999999999999999999999999E+6143
+dqscb137 scaleb 1E-6143 +1 -> 1E-6142
+dqscb1614 scaleb 1E-6143 -0 -> 1E-6143
+dqscb139 scaleb 1E-6143 -1 -> 1E-6144 Subnormal
+dqscb140 scaleb 1.000000000000000000000000000000000E-6143 +1 -> 1.000000000000000000000000000000000E-6142
+dqscb141 scaleb 1.000000000000000000000000000000000E-6143 0 -> 1.000000000000000000000000000000000E-6143
+dqscb142 scaleb 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
+dqscb143 scaleb 1E-6176 +1 -> 1E-6175 Subnormal
+dqscb144 scaleb 1E-6176 -0 -> 1E-6176 Subnormal
+dqscb145 scaleb 1E-6176 -1 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqscb150 scaleb -1E-6176 +1 -> -1E-6175 Subnormal
+dqscb151 scaleb -1E-6176 -0 -> -1E-6176 Subnormal
+dqscb152 scaleb -1E-6176 -1 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqscb153 scaleb -1.000000000000000000000000000000000E-6143 +1 -> -1.000000000000000000000000000000000E-6142
+dqscb154 scaleb -1.000000000000000000000000000000000E-6143 +0 -> -1.000000000000000000000000000000000E-6143
+dqscb155 scaleb -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144 Subnormal Rounded
+dqscb156 scaleb -1E-6143 +1 -> -1E-6142
+dqscb157 scaleb -1E-6143 -0 -> -1E-6143
+dqscb158 scaleb -1E-6143 -1 -> -1E-6144 Subnormal
+dqscb159 scaleb -9.999999999999999999999999999999999E+6144 +1 -> -Infinity Overflow Inexact Rounded
+dqscb160 scaleb -9.999999999999999999999999999999999E+6144 +0 -> -9.999999999999999999999999999999999E+6144
+dqscb161 scaleb -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6143
+dqscb162 scaleb -9E+6144 +1 -> -Infinity Overflow Inexact Rounded
+dqscb163 scaleb -1E+6144 +1 -> -Infinity Overflow Inexact Rounded
+
+-- some Origami
+-- (these check that overflow is being done correctly)
+dqscb171 scaleb 1000E+6109 +1 -> 1.000E+6113
+dqscb172 scaleb 1000E+6110 +1 -> 1.000E+6114
+dqscb173 scaleb 1000E+6111 +1 -> 1.0000E+6115 Clamped
+dqscb174 scaleb 1000E+6112 +1 -> 1.00000E+6116 Clamped
+dqscb175 scaleb 1000E+6113 +1 -> 1.000000E+6117 Clamped
+dqscb176 scaleb 1000E+6114 +1 -> 1.0000000E+6118 Clamped
+dqscb177 scaleb 1000E+6131 +1 -> 1.000000000000000000000000E+6135 Clamped
+dqscb178 scaleb 1000E+6132 +1 -> 1.0000000000000000000000000E+6136 Clamped
+dqscb179 scaleb 1000E+6133 +1 -> 1.00000000000000000000000000E+6137 Clamped
+dqscb180 scaleb 1000E+6134 +1 -> 1.000000000000000000000000000E+6138 Clamped
+dqscb181 scaleb 1000E+6135 +1 -> 1.0000000000000000000000000000E+6139 Clamped
+dqscb182 scaleb 1000E+6136 +1 -> 1.00000000000000000000000000000E+6140 Clamped
+dqscb183 scaleb 1000E+6137 +1 -> 1.000000000000000000000000000000E+6141 Clamped
+dqscb184 scaleb 1000E+6138 +1 -> 1.0000000000000000000000000000000E+6142 Clamped
+dqscb185 scaleb 1000E+6139 +1 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqscb186 scaleb 1000E+6140 +1 -> 1.000000000000000000000000000000000E+6144 Clamped
+dqscb187 scaleb 1000E+6141 +1 -> Infinity Overflow Inexact Rounded
+
+-- and a few more subnormal truncations
+-- (these check that underflow is being done correctly)
+dqscb221 scaleb 1.000000000000000000000000000000000E-6143 0 -> 1.000000000000000000000000000000000E-6143
+dqscb222 scaleb 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
+dqscb223 scaleb 1.000000000000000000000000000000000E-6143 -2 -> 1.0000000000000000000000000000000E-6145 Subnormal Rounded
+dqscb224 scaleb 1.000000000000000000000000000000000E-6143 -3 -> 1.000000000000000000000000000000E-6146 Subnormal Rounded
+dqscb225 scaleb 1.000000000000000000000000000000000E-6143 -4 -> 1.00000000000000000000000000000E-6147 Subnormal Rounded
+dqscb226 scaleb 1.000000000000000000000000000000000E-6143 -5 -> 1.0000000000000000000000000000E-6148 Subnormal Rounded
+dqscb227 scaleb 1.000000000000000000000000000000000E-6143 -6 -> 1.000000000000000000000000000E-6149 Subnormal Rounded
+dqscb228 scaleb 1.000000000000000000000000000000000E-6143 -7 -> 1.00000000000000000000000000E-6150 Subnormal Rounded
+dqscb229 scaleb 1.000000000000000000000000000000000E-6143 -8 -> 1.0000000000000000000000000E-6151 Subnormal Rounded
+dqscb230 scaleb 1.000000000000000000000000000000000E-6143 -9 -> 1.000000000000000000000000E-6152 Subnormal Rounded
+dqscb231 scaleb 1.000000000000000000000000000000000E-6143 -10 -> 1.00000000000000000000000E-6153 Subnormal Rounded
+dqscb232 scaleb 1.000000000000000000000000000000000E-6143 -11 -> 1.0000000000000000000000E-6154 Subnormal Rounded
+dqscb233 scaleb 1.000000000000000000000000000000000E-6143 -12 -> 1.000000000000000000000E-6155 Subnormal Rounded
+dqscb234 scaleb 1.000000000000000000000000000000000E-6143 -13 -> 1.00000000000000000000E-6156 Subnormal Rounded
+dqscb235 scaleb 1.000000000000000000000000000000000E-6143 -14 -> 1.0000000000000000000E-6157 Subnormal Rounded
+dqscb236 scaleb 1.000000000000000000000000000000000E-6143 -15 -> 1.000000000000000000E-6158 Subnormal Rounded
+dqscb237 scaleb 1.000000000000000000000000000000000E-6143 -16 -> 1.00000000000000000E-6159 Subnormal Rounded
+dqscb238 scaleb 1.000000000000000000000000000000000E-6143 -17 -> 1.0000000000000000E-6160 Subnormal Rounded
+dqscb239 scaleb 1.000000000000000000000000000000000E-6143 -18 -> 1.000000000000000E-6161 Subnormal Rounded
+dqscb202 scaleb 1.000000000000000000000000000000000E-6143 -19 -> 1.00000000000000E-6162 Subnormal Rounded
+dqscb203 scaleb 1.000000000000000000000000000000000E-6143 -20 -> 1.0000000000000E-6163 Subnormal Rounded
+dqscb204 scaleb 1.000000000000000000000000000000000E-6143 -21 -> 1.000000000000E-6164 Subnormal Rounded
+dqscb205 scaleb 1.000000000000000000000000000000000E-6143 -22 -> 1.00000000000E-6165 Subnormal Rounded
+dqscb206 scaleb 1.000000000000000000000000000000000E-6143 -23 -> 1.0000000000E-6166 Subnormal Rounded
+dqscb207 scaleb 1.000000000000000000000000000000000E-6143 -24 -> 1.000000000E-6167 Subnormal Rounded
+dqscb208 scaleb 1.000000000000000000000000000000000E-6143 -25 -> 1.00000000E-6168 Subnormal Rounded
+dqscb209 scaleb 1.000000000000000000000000000000000E-6143 -26 -> 1.0000000E-6169 Subnormal Rounded
+dqscb210 scaleb 1.000000000000000000000000000000000E-6143 -27 -> 1.000000E-6170 Subnormal Rounded
+dqscb211 scaleb 1.000000000000000000000000000000000E-6143 -28 -> 1.00000E-6171 Subnormal Rounded
+dqscb212 scaleb 1.000000000000000000000000000000000E-6143 -29 -> 1.0000E-6172 Subnormal Rounded
+dqscb213 scaleb 1.000000000000000000000000000000000E-6143 -30 -> 1.000E-6173 Subnormal Rounded
+dqscb214 scaleb 1.000000000000000000000000000000000E-6143 -31 -> 1.00E-6174 Subnormal Rounded
+dqscb215 scaleb 1.000000000000000000000000000000000E-6143 -32 -> 1.0E-6175 Subnormal Rounded
+dqscb216 scaleb 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176 Subnormal Rounded
+dqscb217 scaleb 1.000000000000000000000000000000000E-6143 -34 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqscb218 scaleb 1.000000000000000000000000000000000E-6143 -35 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
diff --git a/Lib/test/decimaltestdata/dqShift.decTest b/Lib/test/decimaltestdata/dqShift.decTest
index 6d69213455..4ee836eb48 100644
--- a/Lib/test/decimaltestdata/dqShift.decTest
+++ b/Lib/test/decimaltestdata/dqShift.decTest
@@ -1,298 +1,298 @@
-------------------------------------------------------------------------
--- dqShift.decTest -- shift decQuad coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqshi001 shift 0 0 -> 0
-dqshi002 shift 0 2 -> 0
-dqshi003 shift 1 2 -> 100
-dqshi004 shift 1 33 -> 1000000000000000000000000000000000
-dqshi005 shift 1 34 -> 0
-dqshi006 shift 1 -1 -> 0
-dqshi007 shift 0 -2 -> 0
-dqshi008 shift 1234567890123456789012345678901234 -1 -> 123456789012345678901234567890123
-dqshi009 shift 1234567890123456789012345678901234 -33 -> 1
-dqshi010 shift 1234567890123456789012345678901234 -34 -> 0
-dqshi011 shift 9934567890123456789012345678901234 -33 -> 9
-dqshi012 shift 9934567890123456789012345678901234 -34 -> 0
-
--- rhs must be an integer
-dqshi015 shift 1 1.5 -> NaN Invalid_operation
-dqshi016 shift 1 1.0 -> NaN Invalid_operation
-dqshi017 shift 1 0.1 -> NaN Invalid_operation
-dqshi018 shift 1 0.0 -> NaN Invalid_operation
-dqshi019 shift 1 1E+1 -> NaN Invalid_operation
-dqshi020 shift 1 1E+99 -> NaN Invalid_operation
-dqshi021 shift 1 Inf -> NaN Invalid_operation
-dqshi022 shift 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-dqshi025 shift 1 -1000 -> NaN Invalid_operation
-dqshi026 shift 1 -35 -> NaN Invalid_operation
-dqshi027 shift 1 35 -> NaN Invalid_operation
-dqshi028 shift 1 1000 -> NaN Invalid_operation
-
--- full shifting pattern
-dqshi030 shift 1234567890123456789012345678901234 -34 -> 0
-dqshi031 shift 1234567890123456789012345678901234 -33 -> 1
-dqshi032 shift 1234567890123456789012345678901234 -32 -> 12
-dqshi033 shift 1234567890123456789012345678901234 -31 -> 123
-dqshi034 shift 1234567890123456789012345678901234 -30 -> 1234
-dqshi035 shift 1234567890123456789012345678901234 -29 -> 12345
-dqshi036 shift 1234567890123456789012345678901234 -28 -> 123456
-dqshi037 shift 1234567890123456789012345678901234 -27 -> 1234567
-dqshi038 shift 1234567890123456789012345678901234 -26 -> 12345678
-dqshi039 shift 1234567890123456789012345678901234 -25 -> 123456789
-dqshi040 shift 1234567890123456789012345678901234 -24 -> 1234567890
-dqshi041 shift 1234567890123456789012345678901234 -23 -> 12345678901
-dqshi042 shift 1234567890123456789012345678901234 -22 -> 123456789012
-dqshi043 shift 1234567890123456789012345678901234 -21 -> 1234567890123
-dqshi044 shift 1234567890123456789012345678901234 -20 -> 12345678901234
-dqshi045 shift 1234567890123456789012345678901234 -19 -> 123456789012345
-dqshi047 shift 1234567890123456789012345678901234 -18 -> 1234567890123456
-dqshi048 shift 1234567890123456789012345678901234 -17 -> 12345678901234567
-dqshi049 shift 1234567890123456789012345678901234 -16 -> 123456789012345678
-dqshi050 shift 1234567890123456789012345678901234 -15 -> 1234567890123456789
-dqshi051 shift 1234567890123456789012345678901234 -14 -> 12345678901234567890
-dqshi052 shift 1234567890123456789012345678901234 -13 -> 123456789012345678901
-dqshi053 shift 1234567890123456789012345678901234 -12 -> 1234567890123456789012
-dqshi054 shift 1234567890123456789012345678901234 -11 -> 12345678901234567890123
-dqshi055 shift 1234567890123456789012345678901234 -10 -> 123456789012345678901234
-dqshi056 shift 1234567890123456789012345678901234 -9 -> 1234567890123456789012345
-dqshi057 shift 1234567890123456789012345678901234 -8 -> 12345678901234567890123456
-dqshi058 shift 1234567890123456789012345678901234 -7 -> 123456789012345678901234567
-dqshi059 shift 1234567890123456789012345678901234 -6 -> 1234567890123456789012345678
-dqshi060 shift 1234567890123456789012345678901234 -5 -> 12345678901234567890123456789
-dqshi061 shift 1234567890123456789012345678901234 -4 -> 123456789012345678901234567890
-dqshi062 shift 1234567890123456789012345678901234 -3 -> 1234567890123456789012345678901
-dqshi063 shift 1234567890123456789012345678901234 -2 -> 12345678901234567890123456789012
-dqshi064 shift 1234567890123456789012345678901234 -1 -> 123456789012345678901234567890123
-dqshi065 shift 1234567890123456789012345678901234 -0 -> 1234567890123456789012345678901234
-
-dqshi066 shift 1234567890123456789012345678901234 +0 -> 1234567890123456789012345678901234
-dqshi067 shift 1234567890123456789012345678901234 +1 -> 2345678901234567890123456789012340
-dqshi068 shift 1234567890123456789012345678901234 +2 -> 3456789012345678901234567890123400
-dqshi069 shift 1234567890123456789012345678901234 +3 -> 4567890123456789012345678901234000
-dqshi070 shift 1234567890123456789012345678901234 +4 -> 5678901234567890123456789012340000
-dqshi071 shift 1234567890123456789012345678901234 +5 -> 6789012345678901234567890123400000
-dqshi072 shift 1234567890123456789012345678901234 +6 -> 7890123456789012345678901234000000
-dqshi073 shift 1234567890123456789012345678901234 +7 -> 8901234567890123456789012340000000
-dqshi074 shift 1234567890123456789012345678901234 +8 -> 9012345678901234567890123400000000
-dqshi075 shift 1234567890123456789012345678901234 +9 -> 123456789012345678901234000000000
-dqshi076 shift 1234567890123456789012345678901234 +10 -> 1234567890123456789012340000000000
-dqshi077 shift 1234567890123456789012345678901234 +11 -> 2345678901234567890123400000000000
-dqshi078 shift 1234567890123456789012345678901234 +12 -> 3456789012345678901234000000000000
-dqshi079 shift 1234567890123456789012345678901234 +13 -> 4567890123456789012340000000000000
-dqshi080 shift 1234567890123456789012345678901234 +14 -> 5678901234567890123400000000000000
-dqshi081 shift 1234567890123456789012345678901234 +15 -> 6789012345678901234000000000000000
-dqshi082 shift 1234567890123456789012345678901234 +16 -> 7890123456789012340000000000000000
-dqshi083 shift 1234567890123456789012345678901234 +17 -> 8901234567890123400000000000000000
-dqshi084 shift 1234567890123456789012345678901234 +18 -> 9012345678901234000000000000000000
-dqshi085 shift 1234567890123456789012345678901234 +19 -> 123456789012340000000000000000000
-dqshi086 shift 1234567890123456789012345678901234 +20 -> 1234567890123400000000000000000000
-dqshi087 shift 1234567890123456789012345678901234 +21 -> 2345678901234000000000000000000000
-dqshi088 shift 1234567890123456789012345678901234 +22 -> 3456789012340000000000000000000000
-dqshi089 shift 1234567890123456789012345678901234 +23 -> 4567890123400000000000000000000000
-dqshi090 shift 1234567890123456789012345678901234 +24 -> 5678901234000000000000000000000000
-dqshi091 shift 1234567890123456789012345678901234 +25 -> 6789012340000000000000000000000000
-dqshi092 shift 1234567890123456789012345678901234 +26 -> 7890123400000000000000000000000000
-dqshi093 shift 1234567890123456789012345678901234 +27 -> 8901234000000000000000000000000000
-dqshi094 shift 1234567890123456789012345678901234 +28 -> 9012340000000000000000000000000000
-dqshi095 shift 1234567890123456789012345678901234 +29 -> 123400000000000000000000000000000
-dqshi096 shift 1234567890123456789012345678901234 +30 -> 1234000000000000000000000000000000
-dqshi097 shift 1234567890123456789012345678901234 +31 -> 2340000000000000000000000000000000
-dqshi098 shift 1234567890123456789012345678901234 +32 -> 3400000000000000000000000000000000
-dqshi099 shift 1234567890123456789012345678901234 +33 -> 4000000000000000000000000000000000
-dqshi100 shift 1234567890123456789012345678901234 +34 -> 0
-
--- zeros
-dqshi270 shift 0E-10 +29 -> 0E-10
-dqshi271 shift 0E-10 -29 -> 0E-10
-dqshi272 shift 0.000 +29 -> 0.000
-dqshi273 shift 0.000 -29 -> 0.000
-dqshi274 shift 0E+10 +29 -> 0E+10
-dqshi275 shift 0E+10 -29 -> 0E+10
-dqshi276 shift -0E-10 +29 -> -0E-10
-dqshi277 shift -0E-10 -29 -> -0E-10
-dqshi278 shift -0.000 +29 -> -0.000
-dqshi279 shift -0.000 -29 -> -0.000
-dqshi280 shift -0E+10 +29 -> -0E+10
-dqshi281 shift -0E+10 -29 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-dqshi141 shift 9.999999999999999999999999999999999E+6144 -1 -> 9.99999999999999999999999999999999E+6143
-dqshi142 shift 9.999999999999999999999999999999999E+6144 -33 -> 9E+6111
-dqshi143 shift 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999990E+6144
-dqshi144 shift 9.999999999999999999999999999999999E+6144 33 -> 9.000000000000000000000000000000000E+6144
-dqshi145 shift 1E-6143 -1 -> 0E-6143
-dqshi146 shift 1E-6143 -33 -> 0E-6143
-dqshi147 shift 1E-6143 1 -> 1.0E-6142
-dqshi148 shift 1E-6143 33 -> 1.000000000000000000000000000000000E-6110
-dqshi151 shift 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144
-dqshi152 shift 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176
-dqshi153 shift 1.000000000000000000000000000000000E-6143 1 -> 0E-6176
-dqshi154 shift 1.000000000000000000000000000000000E-6143 33 -> 0E-6176
-dqshi155 shift 9.000000000000000000000000000000000E-6143 -1 -> 9.00000000000000000000000000000000E-6144
-dqshi156 shift 9.000000000000000000000000000000000E-6143 -33 -> 9E-6176
-dqshi157 shift 9.000000000000000000000000000000000E-6143 1 -> 0E-6176
-dqshi158 shift 9.000000000000000000000000000000000E-6143 33 -> 0E-6176
-dqshi160 shift 1E-6176 -1 -> 0E-6176
-dqshi161 shift 1E-6176 -33 -> 0E-6176
-dqshi162 shift 1E-6176 1 -> 1.0E-6175
-dqshi163 shift 1E-6176 33 -> 1.000000000000000000000000000000000E-6143
--- negatives
-dqshi171 shift -9.999999999999999999999999999999999E+6144 -1 -> -9.99999999999999999999999999999999E+6143
-dqshi172 shift -9.999999999999999999999999999999999E+6144 -33 -> -9E+6111
-dqshi173 shift -9.999999999999999999999999999999999E+6144 1 -> -9.999999999999999999999999999999990E+6144
-dqshi174 shift -9.999999999999999999999999999999999E+6144 33 -> -9.000000000000000000000000000000000E+6144
-dqshi175 shift -1E-6143 -1 -> -0E-6143
-dqshi176 shift -1E-6143 -33 -> -0E-6143
-dqshi177 shift -1E-6143 1 -> -1.0E-6142
-dqshi178 shift -1E-6143 33 -> -1.000000000000000000000000000000000E-6110
-dqshi181 shift -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144
-dqshi182 shift -1.000000000000000000000000000000000E-6143 -33 -> -1E-6176
-dqshi183 shift -1.000000000000000000000000000000000E-6143 1 -> -0E-6176
-dqshi184 shift -1.000000000000000000000000000000000E-6143 33 -> -0E-6176
-dqshi185 shift -9.000000000000000000000000000000000E-6143 -1 -> -9.00000000000000000000000000000000E-6144
-dqshi186 shift -9.000000000000000000000000000000000E-6143 -33 -> -9E-6176
-dqshi187 shift -9.000000000000000000000000000000000E-6143 1 -> -0E-6176
-dqshi188 shift -9.000000000000000000000000000000000E-6143 33 -> -0E-6176
-dqshi190 shift -1E-6176 -1 -> -0E-6176
-dqshi191 shift -1E-6176 -33 -> -0E-6176
-dqshi192 shift -1E-6176 1 -> -1.0E-6175
-dqshi193 shift -1E-6176 33 -> -1.000000000000000000000000000000000E-6143
-
--- more negatives (of sanities)
-dqshi201 shift -0 0 -> -0
-dqshi202 shift -0 2 -> -0
-dqshi203 shift -1 2 -> -100
-dqshi204 shift -1 33 -> -1000000000000000000000000000000000
-dqshi205 shift -1 34 -> -0
-dqshi206 shift -1 -1 -> -0
-dqshi207 shift -0 -2 -> -0
-dqshi208 shift -1234567890123456789012345678901234 -1 -> -123456789012345678901234567890123
-dqshi209 shift -1234567890123456789012345678901234 -33 -> -1
-dqshi210 shift -1234567890123456789012345678901234 -34 -> -0
-dqshi211 shift -9934567890123456789012345678901234 -33 -> -9
-dqshi212 shift -9934567890123456789012345678901234 -34 -> -0
-
-
--- Specials; NaNs are handled as usual
-dqshi781 shift -Inf -8 -> -Infinity
-dqshi782 shift -Inf -1 -> -Infinity
-dqshi783 shift -Inf -0 -> -Infinity
-dqshi784 shift -Inf 0 -> -Infinity
-dqshi785 shift -Inf 1 -> -Infinity
-dqshi786 shift -Inf 8 -> -Infinity
-dqshi787 shift -1000 -Inf -> NaN Invalid_operation
-dqshi788 shift -Inf -Inf -> NaN Invalid_operation
-dqshi789 shift -1 -Inf -> NaN Invalid_operation
-dqshi790 shift -0 -Inf -> NaN Invalid_operation
-dqshi791 shift 0 -Inf -> NaN Invalid_operation
-dqshi792 shift 1 -Inf -> NaN Invalid_operation
-dqshi793 shift 1000 -Inf -> NaN Invalid_operation
-dqshi794 shift Inf -Inf -> NaN Invalid_operation
-
-dqshi800 shift Inf -Inf -> NaN Invalid_operation
-dqshi801 shift Inf -8 -> Infinity
-dqshi802 shift Inf -1 -> Infinity
-dqshi803 shift Inf -0 -> Infinity
-dqshi804 shift Inf 0 -> Infinity
-dqshi805 shift Inf 1 -> Infinity
-dqshi806 shift Inf 8 -> Infinity
-dqshi807 shift Inf Inf -> NaN Invalid_operation
-dqshi808 shift -1000 Inf -> NaN Invalid_operation
-dqshi809 shift -Inf Inf -> NaN Invalid_operation
-dqshi810 shift -1 Inf -> NaN Invalid_operation
-dqshi811 shift -0 Inf -> NaN Invalid_operation
-dqshi812 shift 0 Inf -> NaN Invalid_operation
-dqshi813 shift 1 Inf -> NaN Invalid_operation
-dqshi814 shift 1000 Inf -> NaN Invalid_operation
-dqshi815 shift Inf Inf -> NaN Invalid_operation
-
-dqshi821 shift NaN -Inf -> NaN
-dqshi822 shift NaN -1000 -> NaN
-dqshi823 shift NaN -1 -> NaN
-dqshi824 shift NaN -0 -> NaN
-dqshi825 shift NaN 0 -> NaN
-dqshi826 shift NaN 1 -> NaN
-dqshi827 shift NaN 1000 -> NaN
-dqshi828 shift NaN Inf -> NaN
-dqshi829 shift NaN NaN -> NaN
-dqshi830 shift -Inf NaN -> NaN
-dqshi831 shift -1000 NaN -> NaN
-dqshi832 shift -1 NaN -> NaN
-dqshi833 shift -0 NaN -> NaN
-dqshi834 shift 0 NaN -> NaN
-dqshi835 shift 1 NaN -> NaN
-dqshi836 shift 1000 NaN -> NaN
-dqshi837 shift Inf NaN -> NaN
-
-dqshi841 shift sNaN -Inf -> NaN Invalid_operation
-dqshi842 shift sNaN -1000 -> NaN Invalid_operation
-dqshi843 shift sNaN -1 -> NaN Invalid_operation
-dqshi844 shift sNaN -0 -> NaN Invalid_operation
-dqshi845 shift sNaN 0 -> NaN Invalid_operation
-dqshi846 shift sNaN 1 -> NaN Invalid_operation
-dqshi847 shift sNaN 1000 -> NaN Invalid_operation
-dqshi848 shift sNaN NaN -> NaN Invalid_operation
-dqshi849 shift sNaN sNaN -> NaN Invalid_operation
-dqshi850 shift NaN sNaN -> NaN Invalid_operation
-dqshi851 shift -Inf sNaN -> NaN Invalid_operation
-dqshi852 shift -1000 sNaN -> NaN Invalid_operation
-dqshi853 shift -1 sNaN -> NaN Invalid_operation
-dqshi854 shift -0 sNaN -> NaN Invalid_operation
-dqshi855 shift 0 sNaN -> NaN Invalid_operation
-dqshi856 shift 1 sNaN -> NaN Invalid_operation
-dqshi857 shift 1000 sNaN -> NaN Invalid_operation
-dqshi858 shift Inf sNaN -> NaN Invalid_operation
-dqshi859 shift NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqshi861 shift NaN1 -Inf -> NaN1
-dqshi862 shift +NaN2 -1000 -> NaN2
-dqshi863 shift NaN3 1000 -> NaN3
-dqshi864 shift NaN4 Inf -> NaN4
-dqshi865 shift NaN5 +NaN6 -> NaN5
-dqshi866 shift -Inf NaN7 -> NaN7
-dqshi867 shift -1000 NaN8 -> NaN8
-dqshi868 shift 1000 NaN9 -> NaN9
-dqshi869 shift Inf +NaN10 -> NaN10
-dqshi871 shift sNaN11 -Inf -> NaN11 Invalid_operation
-dqshi872 shift sNaN12 -1000 -> NaN12 Invalid_operation
-dqshi873 shift sNaN13 1000 -> NaN13 Invalid_operation
-dqshi874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
-dqshi875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqshi876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
-dqshi877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
-dqshi878 shift -1000 sNaN21 -> NaN21 Invalid_operation
-dqshi879 shift 1000 sNaN22 -> NaN22 Invalid_operation
-dqshi880 shift Inf sNaN23 -> NaN23 Invalid_operation
-dqshi881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqshi882 shift -NaN26 NaN28 -> -NaN26
-dqshi883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqshi884 shift 1000 -NaN30 -> -NaN30
-dqshi885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- dqShift.decTest -- shift decQuad coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqshi001 shift 0 0 -> 0
+dqshi002 shift 0 2 -> 0
+dqshi003 shift 1 2 -> 100
+dqshi004 shift 1 33 -> 1000000000000000000000000000000000
+dqshi005 shift 1 34 -> 0
+dqshi006 shift 1 -1 -> 0
+dqshi007 shift 0 -2 -> 0
+dqshi008 shift 1234567890123456789012345678901234 -1 -> 123456789012345678901234567890123
+dqshi009 shift 1234567890123456789012345678901234 -33 -> 1
+dqshi010 shift 1234567890123456789012345678901234 -34 -> 0
+dqshi011 shift 9934567890123456789012345678901234 -33 -> 9
+dqshi012 shift 9934567890123456789012345678901234 -34 -> 0
+
+-- rhs must be an integer
+dqshi015 shift 1 1.5 -> NaN Invalid_operation
+dqshi016 shift 1 1.0 -> NaN Invalid_operation
+dqshi017 shift 1 0.1 -> NaN Invalid_operation
+dqshi018 shift 1 0.0 -> NaN Invalid_operation
+dqshi019 shift 1 1E+1 -> NaN Invalid_operation
+dqshi020 shift 1 1E+99 -> NaN Invalid_operation
+dqshi021 shift 1 Inf -> NaN Invalid_operation
+dqshi022 shift 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+dqshi025 shift 1 -1000 -> NaN Invalid_operation
+dqshi026 shift 1 -35 -> NaN Invalid_operation
+dqshi027 shift 1 35 -> NaN Invalid_operation
+dqshi028 shift 1 1000 -> NaN Invalid_operation
+
+-- full shifting pattern
+dqshi030 shift 1234567890123456789012345678901234 -34 -> 0
+dqshi031 shift 1234567890123456789012345678901234 -33 -> 1
+dqshi032 shift 1234567890123456789012345678901234 -32 -> 12
+dqshi033 shift 1234567890123456789012345678901234 -31 -> 123
+dqshi034 shift 1234567890123456789012345678901234 -30 -> 1234
+dqshi035 shift 1234567890123456789012345678901234 -29 -> 12345
+dqshi036 shift 1234567890123456789012345678901234 -28 -> 123456
+dqshi037 shift 1234567890123456789012345678901234 -27 -> 1234567
+dqshi038 shift 1234567890123456789012345678901234 -26 -> 12345678
+dqshi039 shift 1234567890123456789012345678901234 -25 -> 123456789
+dqshi040 shift 1234567890123456789012345678901234 -24 -> 1234567890
+dqshi041 shift 1234567890123456789012345678901234 -23 -> 12345678901
+dqshi042 shift 1234567890123456789012345678901234 -22 -> 123456789012
+dqshi043 shift 1234567890123456789012345678901234 -21 -> 1234567890123
+dqshi044 shift 1234567890123456789012345678901234 -20 -> 12345678901234
+dqshi045 shift 1234567890123456789012345678901234 -19 -> 123456789012345
+dqshi047 shift 1234567890123456789012345678901234 -18 -> 1234567890123456
+dqshi048 shift 1234567890123456789012345678901234 -17 -> 12345678901234567
+dqshi049 shift 1234567890123456789012345678901234 -16 -> 123456789012345678
+dqshi050 shift 1234567890123456789012345678901234 -15 -> 1234567890123456789
+dqshi051 shift 1234567890123456789012345678901234 -14 -> 12345678901234567890
+dqshi052 shift 1234567890123456789012345678901234 -13 -> 123456789012345678901
+dqshi053 shift 1234567890123456789012345678901234 -12 -> 1234567890123456789012
+dqshi054 shift 1234567890123456789012345678901234 -11 -> 12345678901234567890123
+dqshi055 shift 1234567890123456789012345678901234 -10 -> 123456789012345678901234
+dqshi056 shift 1234567890123456789012345678901234 -9 -> 1234567890123456789012345
+dqshi057 shift 1234567890123456789012345678901234 -8 -> 12345678901234567890123456
+dqshi058 shift 1234567890123456789012345678901234 -7 -> 123456789012345678901234567
+dqshi059 shift 1234567890123456789012345678901234 -6 -> 1234567890123456789012345678
+dqshi060 shift 1234567890123456789012345678901234 -5 -> 12345678901234567890123456789
+dqshi061 shift 1234567890123456789012345678901234 -4 -> 123456789012345678901234567890
+dqshi062 shift 1234567890123456789012345678901234 -3 -> 1234567890123456789012345678901
+dqshi063 shift 1234567890123456789012345678901234 -2 -> 12345678901234567890123456789012
+dqshi064 shift 1234567890123456789012345678901234 -1 -> 123456789012345678901234567890123
+dqshi065 shift 1234567890123456789012345678901234 -0 -> 1234567890123456789012345678901234
+
+dqshi066 shift 1234567890123456789012345678901234 +0 -> 1234567890123456789012345678901234
+dqshi067 shift 1234567890123456789012345678901234 +1 -> 2345678901234567890123456789012340
+dqshi068 shift 1234567890123456789012345678901234 +2 -> 3456789012345678901234567890123400
+dqshi069 shift 1234567890123456789012345678901234 +3 -> 4567890123456789012345678901234000
+dqshi070 shift 1234567890123456789012345678901234 +4 -> 5678901234567890123456789012340000
+dqshi071 shift 1234567890123456789012345678901234 +5 -> 6789012345678901234567890123400000
+dqshi072 shift 1234567890123456789012345678901234 +6 -> 7890123456789012345678901234000000
+dqshi073 shift 1234567890123456789012345678901234 +7 -> 8901234567890123456789012340000000
+dqshi074 shift 1234567890123456789012345678901234 +8 -> 9012345678901234567890123400000000
+dqshi075 shift 1234567890123456789012345678901234 +9 -> 123456789012345678901234000000000
+dqshi076 shift 1234567890123456789012345678901234 +10 -> 1234567890123456789012340000000000
+dqshi077 shift 1234567890123456789012345678901234 +11 -> 2345678901234567890123400000000000
+dqshi078 shift 1234567890123456789012345678901234 +12 -> 3456789012345678901234000000000000
+dqshi079 shift 1234567890123456789012345678901234 +13 -> 4567890123456789012340000000000000
+dqshi080 shift 1234567890123456789012345678901234 +14 -> 5678901234567890123400000000000000
+dqshi081 shift 1234567890123456789012345678901234 +15 -> 6789012345678901234000000000000000
+dqshi082 shift 1234567890123456789012345678901234 +16 -> 7890123456789012340000000000000000
+dqshi083 shift 1234567890123456789012345678901234 +17 -> 8901234567890123400000000000000000
+dqshi084 shift 1234567890123456789012345678901234 +18 -> 9012345678901234000000000000000000
+dqshi085 shift 1234567890123456789012345678901234 +19 -> 123456789012340000000000000000000
+dqshi086 shift 1234567890123456789012345678901234 +20 -> 1234567890123400000000000000000000
+dqshi087 shift 1234567890123456789012345678901234 +21 -> 2345678901234000000000000000000000
+dqshi088 shift 1234567890123456789012345678901234 +22 -> 3456789012340000000000000000000000
+dqshi089 shift 1234567890123456789012345678901234 +23 -> 4567890123400000000000000000000000
+dqshi090 shift 1234567890123456789012345678901234 +24 -> 5678901234000000000000000000000000
+dqshi091 shift 1234567890123456789012345678901234 +25 -> 6789012340000000000000000000000000
+dqshi092 shift 1234567890123456789012345678901234 +26 -> 7890123400000000000000000000000000
+dqshi093 shift 1234567890123456789012345678901234 +27 -> 8901234000000000000000000000000000
+dqshi094 shift 1234567890123456789012345678901234 +28 -> 9012340000000000000000000000000000
+dqshi095 shift 1234567890123456789012345678901234 +29 -> 123400000000000000000000000000000
+dqshi096 shift 1234567890123456789012345678901234 +30 -> 1234000000000000000000000000000000
+dqshi097 shift 1234567890123456789012345678901234 +31 -> 2340000000000000000000000000000000
+dqshi098 shift 1234567890123456789012345678901234 +32 -> 3400000000000000000000000000000000
+dqshi099 shift 1234567890123456789012345678901234 +33 -> 4000000000000000000000000000000000
+dqshi100 shift 1234567890123456789012345678901234 +34 -> 0
+
+-- zeros
+dqshi270 shift 0E-10 +29 -> 0E-10
+dqshi271 shift 0E-10 -29 -> 0E-10
+dqshi272 shift 0.000 +29 -> 0.000
+dqshi273 shift 0.000 -29 -> 0.000
+dqshi274 shift 0E+10 +29 -> 0E+10
+dqshi275 shift 0E+10 -29 -> 0E+10
+dqshi276 shift -0E-10 +29 -> -0E-10
+dqshi277 shift -0E-10 -29 -> -0E-10
+dqshi278 shift -0.000 +29 -> -0.000
+dqshi279 shift -0.000 -29 -> -0.000
+dqshi280 shift -0E+10 +29 -> -0E+10
+dqshi281 shift -0E+10 -29 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+dqshi141 shift 9.999999999999999999999999999999999E+6144 -1 -> 9.99999999999999999999999999999999E+6143
+dqshi142 shift 9.999999999999999999999999999999999E+6144 -33 -> 9E+6111
+dqshi143 shift 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999990E+6144
+dqshi144 shift 9.999999999999999999999999999999999E+6144 33 -> 9.000000000000000000000000000000000E+6144
+dqshi145 shift 1E-6143 -1 -> 0E-6143
+dqshi146 shift 1E-6143 -33 -> 0E-6143
+dqshi147 shift 1E-6143 1 -> 1.0E-6142
+dqshi148 shift 1E-6143 33 -> 1.000000000000000000000000000000000E-6110
+dqshi151 shift 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144
+dqshi152 shift 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176
+dqshi153 shift 1.000000000000000000000000000000000E-6143 1 -> 0E-6176
+dqshi154 shift 1.000000000000000000000000000000000E-6143 33 -> 0E-6176
+dqshi155 shift 9.000000000000000000000000000000000E-6143 -1 -> 9.00000000000000000000000000000000E-6144
+dqshi156 shift 9.000000000000000000000000000000000E-6143 -33 -> 9E-6176
+dqshi157 shift 9.000000000000000000000000000000000E-6143 1 -> 0E-6176
+dqshi158 shift 9.000000000000000000000000000000000E-6143 33 -> 0E-6176
+dqshi160 shift 1E-6176 -1 -> 0E-6176
+dqshi161 shift 1E-6176 -33 -> 0E-6176
+dqshi162 shift 1E-6176 1 -> 1.0E-6175
+dqshi163 shift 1E-6176 33 -> 1.000000000000000000000000000000000E-6143
+-- negatives
+dqshi171 shift -9.999999999999999999999999999999999E+6144 -1 -> -9.99999999999999999999999999999999E+6143
+dqshi172 shift -9.999999999999999999999999999999999E+6144 -33 -> -9E+6111
+dqshi173 shift -9.999999999999999999999999999999999E+6144 1 -> -9.999999999999999999999999999999990E+6144
+dqshi174 shift -9.999999999999999999999999999999999E+6144 33 -> -9.000000000000000000000000000000000E+6144
+dqshi175 shift -1E-6143 -1 -> -0E-6143
+dqshi176 shift -1E-6143 -33 -> -0E-6143
+dqshi177 shift -1E-6143 1 -> -1.0E-6142
+dqshi178 shift -1E-6143 33 -> -1.000000000000000000000000000000000E-6110
+dqshi181 shift -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144
+dqshi182 shift -1.000000000000000000000000000000000E-6143 -33 -> -1E-6176
+dqshi183 shift -1.000000000000000000000000000000000E-6143 1 -> -0E-6176
+dqshi184 shift -1.000000000000000000000000000000000E-6143 33 -> -0E-6176
+dqshi185 shift -9.000000000000000000000000000000000E-6143 -1 -> -9.00000000000000000000000000000000E-6144
+dqshi186 shift -9.000000000000000000000000000000000E-6143 -33 -> -9E-6176
+dqshi187 shift -9.000000000000000000000000000000000E-6143 1 -> -0E-6176
+dqshi188 shift -9.000000000000000000000000000000000E-6143 33 -> -0E-6176
+dqshi190 shift -1E-6176 -1 -> -0E-6176
+dqshi191 shift -1E-6176 -33 -> -0E-6176
+dqshi192 shift -1E-6176 1 -> -1.0E-6175
+dqshi193 shift -1E-6176 33 -> -1.000000000000000000000000000000000E-6143
+
+-- more negatives (of sanities)
+dqshi201 shift -0 0 -> -0
+dqshi202 shift -0 2 -> -0
+dqshi203 shift -1 2 -> -100
+dqshi204 shift -1 33 -> -1000000000000000000000000000000000
+dqshi205 shift -1 34 -> -0
+dqshi206 shift -1 -1 -> -0
+dqshi207 shift -0 -2 -> -0
+dqshi208 shift -1234567890123456789012345678901234 -1 -> -123456789012345678901234567890123
+dqshi209 shift -1234567890123456789012345678901234 -33 -> -1
+dqshi210 shift -1234567890123456789012345678901234 -34 -> -0
+dqshi211 shift -9934567890123456789012345678901234 -33 -> -9
+dqshi212 shift -9934567890123456789012345678901234 -34 -> -0
+
+
+-- Specials; NaNs are handled as usual
+dqshi781 shift -Inf -8 -> -Infinity
+dqshi782 shift -Inf -1 -> -Infinity
+dqshi783 shift -Inf -0 -> -Infinity
+dqshi784 shift -Inf 0 -> -Infinity
+dqshi785 shift -Inf 1 -> -Infinity
+dqshi786 shift -Inf 8 -> -Infinity
+dqshi787 shift -1000 -Inf -> NaN Invalid_operation
+dqshi788 shift -Inf -Inf -> NaN Invalid_operation
+dqshi789 shift -1 -Inf -> NaN Invalid_operation
+dqshi790 shift -0 -Inf -> NaN Invalid_operation
+dqshi791 shift 0 -Inf -> NaN Invalid_operation
+dqshi792 shift 1 -Inf -> NaN Invalid_operation
+dqshi793 shift 1000 -Inf -> NaN Invalid_operation
+dqshi794 shift Inf -Inf -> NaN Invalid_operation
+
+dqshi800 shift Inf -Inf -> NaN Invalid_operation
+dqshi801 shift Inf -8 -> Infinity
+dqshi802 shift Inf -1 -> Infinity
+dqshi803 shift Inf -0 -> Infinity
+dqshi804 shift Inf 0 -> Infinity
+dqshi805 shift Inf 1 -> Infinity
+dqshi806 shift Inf 8 -> Infinity
+dqshi807 shift Inf Inf -> NaN Invalid_operation
+dqshi808 shift -1000 Inf -> NaN Invalid_operation
+dqshi809 shift -Inf Inf -> NaN Invalid_operation
+dqshi810 shift -1 Inf -> NaN Invalid_operation
+dqshi811 shift -0 Inf -> NaN Invalid_operation
+dqshi812 shift 0 Inf -> NaN Invalid_operation
+dqshi813 shift 1 Inf -> NaN Invalid_operation
+dqshi814 shift 1000 Inf -> NaN Invalid_operation
+dqshi815 shift Inf Inf -> NaN Invalid_operation
+
+dqshi821 shift NaN -Inf -> NaN
+dqshi822 shift NaN -1000 -> NaN
+dqshi823 shift NaN -1 -> NaN
+dqshi824 shift NaN -0 -> NaN
+dqshi825 shift NaN 0 -> NaN
+dqshi826 shift NaN 1 -> NaN
+dqshi827 shift NaN 1000 -> NaN
+dqshi828 shift NaN Inf -> NaN
+dqshi829 shift NaN NaN -> NaN
+dqshi830 shift -Inf NaN -> NaN
+dqshi831 shift -1000 NaN -> NaN
+dqshi832 shift -1 NaN -> NaN
+dqshi833 shift -0 NaN -> NaN
+dqshi834 shift 0 NaN -> NaN
+dqshi835 shift 1 NaN -> NaN
+dqshi836 shift 1000 NaN -> NaN
+dqshi837 shift Inf NaN -> NaN
+
+dqshi841 shift sNaN -Inf -> NaN Invalid_operation
+dqshi842 shift sNaN -1000 -> NaN Invalid_operation
+dqshi843 shift sNaN -1 -> NaN Invalid_operation
+dqshi844 shift sNaN -0 -> NaN Invalid_operation
+dqshi845 shift sNaN 0 -> NaN Invalid_operation
+dqshi846 shift sNaN 1 -> NaN Invalid_operation
+dqshi847 shift sNaN 1000 -> NaN Invalid_operation
+dqshi848 shift sNaN NaN -> NaN Invalid_operation
+dqshi849 shift sNaN sNaN -> NaN Invalid_operation
+dqshi850 shift NaN sNaN -> NaN Invalid_operation
+dqshi851 shift -Inf sNaN -> NaN Invalid_operation
+dqshi852 shift -1000 sNaN -> NaN Invalid_operation
+dqshi853 shift -1 sNaN -> NaN Invalid_operation
+dqshi854 shift -0 sNaN -> NaN Invalid_operation
+dqshi855 shift 0 sNaN -> NaN Invalid_operation
+dqshi856 shift 1 sNaN -> NaN Invalid_operation
+dqshi857 shift 1000 sNaN -> NaN Invalid_operation
+dqshi858 shift Inf sNaN -> NaN Invalid_operation
+dqshi859 shift NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqshi861 shift NaN1 -Inf -> NaN1
+dqshi862 shift +NaN2 -1000 -> NaN2
+dqshi863 shift NaN3 1000 -> NaN3
+dqshi864 shift NaN4 Inf -> NaN4
+dqshi865 shift NaN5 +NaN6 -> NaN5
+dqshi866 shift -Inf NaN7 -> NaN7
+dqshi867 shift -1000 NaN8 -> NaN8
+dqshi868 shift 1000 NaN9 -> NaN9
+dqshi869 shift Inf +NaN10 -> NaN10
+dqshi871 shift sNaN11 -Inf -> NaN11 Invalid_operation
+dqshi872 shift sNaN12 -1000 -> NaN12 Invalid_operation
+dqshi873 shift sNaN13 1000 -> NaN13 Invalid_operation
+dqshi874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
+dqshi875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqshi876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
+dqshi877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
+dqshi878 shift -1000 sNaN21 -> NaN21 Invalid_operation
+dqshi879 shift 1000 sNaN22 -> NaN22 Invalid_operation
+dqshi880 shift Inf sNaN23 -> NaN23 Invalid_operation
+dqshi881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqshi882 shift -NaN26 NaN28 -> -NaN26
+dqshi883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqshi884 shift 1000 -NaN30 -> -NaN30
+dqshi885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqSubtract.decTest b/Lib/test/decimaltestdata/dqSubtract.decTest
index 34572f69d5..f3b92270f9 100644
--- a/Lib/test/decimaltestdata/dqSubtract.decTest
+++ b/Lib/test/decimaltestdata/dqSubtract.decTest
@@ -1,635 +1,635 @@
-------------------------------------------------------------------------
--- dqSubtract.decTest -- decQuad subtraction --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decQuads only; all arguments are
--- representable in a decQuad
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- [first group are 'quick confidence check']
-dqsub001 subtract 0 0 -> '0'
-dqsub002 subtract 1 1 -> '0'
-dqsub003 subtract 1 2 -> '-1'
-dqsub004 subtract 2 1 -> '1'
-dqsub005 subtract 2 2 -> '0'
-dqsub006 subtract 3 2 -> '1'
-dqsub007 subtract 2 3 -> '-1'
-
-dqsub011 subtract -0 0 -> '-0'
-dqsub012 subtract -1 1 -> '-2'
-dqsub013 subtract -1 2 -> '-3'
-dqsub014 subtract -2 1 -> '-3'
-dqsub015 subtract -2 2 -> '-4'
-dqsub016 subtract -3 2 -> '-5'
-dqsub017 subtract -2 3 -> '-5'
-
-dqsub021 subtract 0 -0 -> '0'
-dqsub022 subtract 1 -1 -> '2'
-dqsub023 subtract 1 -2 -> '3'
-dqsub024 subtract 2 -1 -> '3'
-dqsub025 subtract 2 -2 -> '4'
-dqsub026 subtract 3 -2 -> '5'
-dqsub027 subtract 2 -3 -> '5'
-
-dqsub030 subtract 11 1 -> 10
-dqsub031 subtract 10 1 -> 9
-dqsub032 subtract 9 1 -> 8
-dqsub033 subtract 1 1 -> 0
-dqsub034 subtract 0 1 -> -1
-dqsub035 subtract -1 1 -> -2
-dqsub036 subtract -9 1 -> -10
-dqsub037 subtract -10 1 -> -11
-dqsub038 subtract -11 1 -> -12
-
-dqsub040 subtract '5.75' '3.3' -> '2.45'
-dqsub041 subtract '5' '-3' -> '8'
-dqsub042 subtract '-5' '-3' -> '-2'
-dqsub043 subtract '-7' '2.5' -> '-9.5'
-dqsub044 subtract '0.7' '0.3' -> '0.4'
-dqsub045 subtract '1.3' '0.3' -> '1.0'
-dqsub046 subtract '1.25' '1.25' -> '0.00'
-
-dqsub050 subtract '1.23456789' '1.00000000' -> '0.23456789'
-dqsub051 subtract '1.23456789' '1.00000089' -> '0.23456700'
-
-dqsub060 subtract '70' '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
-dqsub061 subtract '700' '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
-dqsub062 subtract '7000' '10000e+34' -> '-9.999999999999999999999999999999999E+37' Inexact Rounded
-dqsub063 subtract '70000' '10000e+34' -> '-9.999999999999999999999999999999993E+37' Rounded
-dqsub064 subtract '700000' '10000e+34' -> '-9.999999999999999999999999999999930E+37' Rounded
- -- symmetry:
-dqsub065 subtract '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqsub066 subtract '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqsub067 subtract '10000e+34' '7000' -> '9.999999999999999999999999999999999E+37' Inexact Rounded
-dqsub068 subtract '10000e+34' '70000' -> '9.999999999999999999999999999999993E+37' Rounded
-dqsub069 subtract '10000e+34' '700000' -> '9.999999999999999999999999999999930E+37' Rounded
-
- -- some of the next group are really constructor tests
-dqsub090 subtract '00.0' '0.0' -> '0.0'
-dqsub091 subtract '00.0' '0.00' -> '0.00'
-dqsub092 subtract '0.00' '00.0' -> '0.00'
-dqsub093 subtract '00.0' '0.00' -> '0.00'
-dqsub094 subtract '0.00' '00.0' -> '0.00'
-dqsub095 subtract '3' '.3' -> '2.7'
-dqsub096 subtract '3.' '.3' -> '2.7'
-dqsub097 subtract '3.0' '.3' -> '2.7'
-dqsub098 subtract '3.00' '.3' -> '2.70'
-dqsub099 subtract '3' '3' -> '0'
-dqsub100 subtract '3' '+3' -> '0'
-dqsub101 subtract '3' '-3' -> '6'
-dqsub102 subtract '3' '0.3' -> '2.7'
-dqsub103 subtract '3.' '0.3' -> '2.7'
-dqsub104 subtract '3.0' '0.3' -> '2.7'
-dqsub105 subtract '3.00' '0.3' -> '2.70'
-dqsub106 subtract '3' '3.0' -> '0.0'
-dqsub107 subtract '3' '+3.0' -> '0.0'
-dqsub108 subtract '3' '-3.0' -> '6.0'
-
--- the above all from add; massaged and extended. Now some new ones...
--- [particularly important for comparisons]
--- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
--- with input rounding.
-dqsub120 subtract '10.23456784' '10.23456789' -> '-5E-8'
-dqsub121 subtract '10.23456785' '10.23456789' -> '-4E-8'
-dqsub122 subtract '10.23456786' '10.23456789' -> '-3E-8'
-dqsub123 subtract '10.23456787' '10.23456789' -> '-2E-8'
-dqsub124 subtract '10.23456788' '10.23456789' -> '-1E-8'
-dqsub125 subtract '10.23456789' '10.23456789' -> '0E-8'
-dqsub126 subtract '10.23456790' '10.23456789' -> '1E-8'
-dqsub127 subtract '10.23456791' '10.23456789' -> '2E-8'
-dqsub128 subtract '10.23456792' '10.23456789' -> '3E-8'
-dqsub129 subtract '10.23456793' '10.23456789' -> '4E-8'
-dqsub130 subtract '10.23456794' '10.23456789' -> '5E-8'
-dqsub131 subtract '10.23456781' '10.23456786' -> '-5E-8'
-dqsub132 subtract '10.23456782' '10.23456786' -> '-4E-8'
-dqsub133 subtract '10.23456783' '10.23456786' -> '-3E-8'
-dqsub134 subtract '10.23456784' '10.23456786' -> '-2E-8'
-dqsub135 subtract '10.23456785' '10.23456786' -> '-1E-8'
-dqsub136 subtract '10.23456786' '10.23456786' -> '0E-8'
-dqsub137 subtract '10.23456787' '10.23456786' -> '1E-8'
-dqsub138 subtract '10.23456788' '10.23456786' -> '2E-8'
-dqsub139 subtract '10.23456789' '10.23456786' -> '3E-8'
-dqsub140 subtract '10.23456790' '10.23456786' -> '4E-8'
-dqsub141 subtract '10.23456791' '10.23456786' -> '5E-8'
-dqsub142 subtract '1' '0.999999999' -> '1E-9'
-dqsub143 subtract '0.999999999' '1' -> '-1E-9'
-dqsub144 subtract '-10.23456780' '-10.23456786' -> '6E-8'
-dqsub145 subtract '-10.23456790' '-10.23456786' -> '-4E-8'
-dqsub146 subtract '-10.23456791' '-10.23456786' -> '-5E-8'
-
--- additional scaled arithmetic tests [0.97 problem]
-dqsub160 subtract '0' '.1' -> '-0.1'
-dqsub161 subtract '00' '.97983' -> '-0.97983'
-dqsub162 subtract '0' '.9' -> '-0.9'
-dqsub163 subtract '0' '0.102' -> '-0.102'
-dqsub164 subtract '0' '.4' -> '-0.4'
-dqsub165 subtract '0' '.307' -> '-0.307'
-dqsub166 subtract '0' '.43822' -> '-0.43822'
-dqsub167 subtract '0' '.911' -> '-0.911'
-dqsub168 subtract '.0' '.02' -> '-0.02'
-dqsub169 subtract '00' '.392' -> '-0.392'
-dqsub170 subtract '0' '.26' -> '-0.26'
-dqsub171 subtract '0' '0.51' -> '-0.51'
-dqsub172 subtract '0' '.2234' -> '-0.2234'
-dqsub173 subtract '0' '.2' -> '-0.2'
-dqsub174 subtract '.0' '.0008' -> '-0.0008'
--- 0. on left
-dqsub180 subtract '0.0' '-.1' -> '0.1'
-dqsub181 subtract '0.00' '-.97983' -> '0.97983'
-dqsub182 subtract '0.0' '-.9' -> '0.9'
-dqsub183 subtract '0.0' '-0.102' -> '0.102'
-dqsub184 subtract '0.0' '-.4' -> '0.4'
-dqsub185 subtract '0.0' '-.307' -> '0.307'
-dqsub186 subtract '0.0' '-.43822' -> '0.43822'
-dqsub187 subtract '0.0' '-.911' -> '0.911'
-dqsub188 subtract '0.0' '-.02' -> '0.02'
-dqsub189 subtract '0.00' '-.392' -> '0.392'
-dqsub190 subtract '0.0' '-.26' -> '0.26'
-dqsub191 subtract '0.0' '-0.51' -> '0.51'
-dqsub192 subtract '0.0' '-.2234' -> '0.2234'
-dqsub193 subtract '0.0' '-.2' -> '0.2'
-dqsub194 subtract '0.0' '-.0008' -> '0.0008'
--- negatives of same
-dqsub200 subtract '0' '-.1' -> '0.1'
-dqsub201 subtract '00' '-.97983' -> '0.97983'
-dqsub202 subtract '0' '-.9' -> '0.9'
-dqsub203 subtract '0' '-0.102' -> '0.102'
-dqsub204 subtract '0' '-.4' -> '0.4'
-dqsub205 subtract '0' '-.307' -> '0.307'
-dqsub206 subtract '0' '-.43822' -> '0.43822'
-dqsub207 subtract '0' '-.911' -> '0.911'
-dqsub208 subtract '.0' '-.02' -> '0.02'
-dqsub209 subtract '00' '-.392' -> '0.392'
-dqsub210 subtract '0' '-.26' -> '0.26'
-dqsub211 subtract '0' '-0.51' -> '0.51'
-dqsub212 subtract '0' '-.2234' -> '0.2234'
-dqsub213 subtract '0' '-.2' -> '0.2'
-dqsub214 subtract '.0' '-.0008' -> '0.0008'
-
--- more fixed, LHS swaps [really the same as testcases under add]
-dqsub220 subtract '-56267E-12' 0 -> '-5.6267E-8'
-dqsub221 subtract '-56267E-11' 0 -> '-5.6267E-7'
-dqsub222 subtract '-56267E-10' 0 -> '-0.0000056267'
-dqsub223 subtract '-56267E-9' 0 -> '-0.000056267'
-dqsub224 subtract '-56267E-8' 0 -> '-0.00056267'
-dqsub225 subtract '-56267E-7' 0 -> '-0.0056267'
-dqsub226 subtract '-56267E-6' 0 -> '-0.056267'
-dqsub227 subtract '-56267E-5' 0 -> '-0.56267'
-dqsub228 subtract '-56267E-2' 0 -> '-562.67'
-dqsub229 subtract '-56267E-1' 0 -> '-5626.7'
-dqsub230 subtract '-56267E-0' 0 -> '-56267'
--- symmetry ...
-dqsub240 subtract 0 '-56267E-12' -> '5.6267E-8'
-dqsub241 subtract 0 '-56267E-11' -> '5.6267E-7'
-dqsub242 subtract 0 '-56267E-10' -> '0.0000056267'
-dqsub243 subtract 0 '-56267E-9' -> '0.000056267'
-dqsub244 subtract 0 '-56267E-8' -> '0.00056267'
-dqsub245 subtract 0 '-56267E-7' -> '0.0056267'
-dqsub246 subtract 0 '-56267E-6' -> '0.056267'
-dqsub247 subtract 0 '-56267E-5' -> '0.56267'
-dqsub248 subtract 0 '-56267E-2' -> '562.67'
-dqsub249 subtract 0 '-56267E-1' -> '5626.7'
-dqsub250 subtract 0 '-56267E-0' -> '56267'
-
--- now some more from the 'new' add
-dqsub301 subtract '1.23456789' '1.00000000' -> '0.23456789'
-dqsub302 subtract '1.23456789' '1.00000011' -> '0.23456778'
-
--- some carrying effects
-dqsub321 subtract '0.9998' '0.0000' -> '0.9998'
-dqsub322 subtract '0.9998' '0.0001' -> '0.9997'
-dqsub323 subtract '0.9998' '0.0002' -> '0.9996'
-dqsub324 subtract '0.9998' '0.0003' -> '0.9995'
-dqsub325 subtract '0.9998' '-0.0000' -> '0.9998'
-dqsub326 subtract '0.9998' '-0.0001' -> '0.9999'
-dqsub327 subtract '0.9998' '-0.0002' -> '1.0000'
-dqsub328 subtract '0.9998' '-0.0003' -> '1.0001'
-
--- internal boundaries
-dqsub346 subtract '10000e+9' '7' -> '9999999999993'
-dqsub347 subtract '10000e+9' '70' -> '9999999999930'
-dqsub348 subtract '10000e+9' '700' -> '9999999999300'
-dqsub349 subtract '10000e+9' '7000' -> '9999999993000'
-dqsub350 subtract '10000e+9' '70000' -> '9999999930000'
-dqsub351 subtract '10000e+9' '700000' -> '9999999300000'
-dqsub352 subtract '7' '10000e+9' -> '-9999999999993'
-dqsub353 subtract '70' '10000e+9' -> '-9999999999930'
-dqsub354 subtract '700' '10000e+9' -> '-9999999999300'
-dqsub355 subtract '7000' '10000e+9' -> '-9999999993000'
-dqsub356 subtract '70000' '10000e+9' -> '-9999999930000'
-dqsub357 subtract '700000' '10000e+9' -> '-9999999300000'
-
--- zero preservation
-dqsub361 subtract 1 '0.0001' -> '0.9999'
-dqsub362 subtract 1 '0.00001' -> '0.99999'
-dqsub363 subtract 1 '0.000001' -> '0.999999'
-dqsub364 subtract 1 '0.0000000000000000000000000000000001' -> '0.9999999999999999999999999999999999'
-dqsub365 subtract 1 '0.00000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub366 subtract 1 '0.000000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
-
--- some funny zeros [in case of bad signum]
-dqsub370 subtract 1 0 -> 1
-dqsub371 subtract 1 0. -> 1
-dqsub372 subtract 1 .0 -> 1.0
-dqsub373 subtract 1 0.0 -> 1.0
-dqsub374 subtract 0 1 -> -1
-dqsub375 subtract 0. 1 -> -1
-dqsub376 subtract .0 1 -> -1.0
-dqsub377 subtract 0.0 1 -> -1.0
-
--- leading 0 digit before round
-dqsub910 subtract -103519362 -51897955.3 -> -51621406.7
-dqsub911 subtract 159579.444 89827.5229 -> 69751.9211
-
-dqsub920 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234566 -> 299.9999999999999999999999999999999 Inexact Rounded
-dqsub921 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 300.0000000000000000000000000000000 Inexact Rounded
-dqsub922 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 99.99999999999999999999999999999995
-dqsub923 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234564 -> 99.99999999999999999999999999999996
-dqsub924 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234540 -> 100.0000000000000000000000000000002 Rounded
-dqsub925 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234560 -> 90.00000000000000000000000000000000
-dqsub926 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234561 -> 89.99999999999999999999999999999999
-dqsub927 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234566 -> 89.99999999999999999999999999999994
-dqsub928 subtract 101.0000000000000000000000000123456 91.00000000000000000000000001234566 -> 9.99999999999999999999999999999994
-dqsub929 subtract 101.0000000000000000000000000123456 99.00000000000000000000000001234566 -> 1.99999999999999999999999999999994
-
--- more LHS swaps [were fixed]
-dqsub390 subtract '-56267E-10' 0 -> '-0.0000056267'
-dqsub391 subtract '-56267E-6' 0 -> '-0.056267'
-dqsub392 subtract '-56267E-5' 0 -> '-0.56267'
-dqsub393 subtract '-56267E-4' 0 -> '-5.6267'
-dqsub394 subtract '-56267E-3' 0 -> '-56.267'
-dqsub395 subtract '-56267E-2' 0 -> '-562.67'
-dqsub396 subtract '-56267E-1' 0 -> '-5626.7'
-dqsub397 subtract '-56267E-0' 0 -> '-56267'
-dqsub398 subtract '-5E-10' 0 -> '-5E-10'
-dqsub399 subtract '-5E-7' 0 -> '-5E-7'
-dqsub400 subtract '-5E-6' 0 -> '-0.000005'
-dqsub401 subtract '-5E-5' 0 -> '-0.00005'
-dqsub402 subtract '-5E-4' 0 -> '-0.0005'
-dqsub403 subtract '-5E-1' 0 -> '-0.5'
-dqsub404 subtract '-5E0' 0 -> '-5'
-dqsub405 subtract '-5E1' 0 -> '-50'
-dqsub406 subtract '-5E5' 0 -> '-500000'
-dqsub407 subtract '-5E33' 0 -> '-5000000000000000000000000000000000'
-dqsub408 subtract '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
-dqsub409 subtract '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
-dqsub410 subtract '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
-dqsub411 subtract '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- more RHS swaps [were fixed]
-dqsub420 subtract 0 '-56267E-10' -> '0.0000056267'
-dqsub421 subtract 0 '-56267E-6' -> '0.056267'
-dqsub422 subtract 0 '-56267E-5' -> '0.56267'
-dqsub423 subtract 0 '-56267E-4' -> '5.6267'
-dqsub424 subtract 0 '-56267E-3' -> '56.267'
-dqsub425 subtract 0 '-56267E-2' -> '562.67'
-dqsub426 subtract 0 '-56267E-1' -> '5626.7'
-dqsub427 subtract 0 '-56267E-0' -> '56267'
-dqsub428 subtract 0 '-5E-10' -> '5E-10'
-dqsub429 subtract 0 '-5E-7' -> '5E-7'
-dqsub430 subtract 0 '-5E-6' -> '0.000005'
-dqsub431 subtract 0 '-5E-5' -> '0.00005'
-dqsub432 subtract 0 '-5E-4' -> '0.0005'
-dqsub433 subtract 0 '-5E-1' -> '0.5'
-dqsub434 subtract 0 '-5E0' -> '5'
-dqsub435 subtract 0 '-5E1' -> '50'
-dqsub436 subtract 0 '-5E5' -> '500000'
-dqsub437 subtract 0 '-5E33' -> '5000000000000000000000000000000000'
-dqsub438 subtract 0 '-5E34' -> '5.000000000000000000000000000000000E+34' Rounded
-dqsub439 subtract 0 '-5E35' -> '5.000000000000000000000000000000000E+35' Rounded
-dqsub440 subtract 0 '-5E36' -> '5.000000000000000000000000000000000E+36' Rounded
-dqsub441 subtract 0 '-5E100' -> '5.000000000000000000000000000000000E+100' Rounded
-
-
--- try borderline precision, with carries, etc.
-dqsub461 subtract '1E+16' '1' -> '9999999999999999'
-dqsub462 subtract '1E+12' '-1.111' -> '1000000000001.111'
-dqsub463 subtract '1.111' '-1E+12' -> '1000000000001.111'
-dqsub464 subtract '-1' '-1E+16' -> '9999999999999999'
-dqsub465 subtract '7E+15' '1' -> '6999999999999999'
-dqsub466 subtract '7E+12' '-1.111' -> '7000000000001.111'
-dqsub467 subtract '1.111' '-7E+12' -> '7000000000001.111'
-dqsub468 subtract '-1' '-7E+15' -> '6999999999999999'
-
--- 1234567890123456 1234567890123456 1 23456789012345
-dqsub470 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555563' -> '1.000000000000000000000000000000001' Inexact Rounded
-dqsub471 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555562' -> '1.000000000000000000000000000000001' Inexact Rounded
-dqsub472 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555561' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub473 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555560' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub474 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555559' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub475 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555558' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub476 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555557' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub477 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555556' -> '1.000000000000000000000000000000000' Rounded
-dqsub478 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
-dqsub479 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555554' -> '0.9999999999999999999999999999999998'
-dqsub480 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555553' -> '0.9999999999999999999999999999999997'
-dqsub481 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555552' -> '0.9999999999999999999999999999999996'
-dqsub482 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555551' -> '0.9999999999999999999999999999999995'
-dqsub483 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555550' -> '0.9999999999999999999999999999999994'
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-dqsub500 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
-dqsub501 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub502 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub503 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub504 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub505 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub506 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub507 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub508 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub509 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub510 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub511 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub512 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub513 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub514 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub515 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub516 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
-dqsub517 subtract '1231234555555555555555555567456789' 1.000000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub518 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub519 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456788' Inexact Rounded
-
-rounding: half_even
-dqsub520 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
-dqsub521 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub522 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub523 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub524 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub525 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub526 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub527 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub528 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub529 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub530 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub531 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub532 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub533 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub534 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub535 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub536 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
-dqsub537 subtract '1231234555555555555555555567456789' 1.00000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub538 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub539 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456788' Inexact Rounded
--- critical few with even bottom digit...
-dqsub540 subtract '1231234555555555555555555567456788' 0.499999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub541 subtract '1231234555555555555555555567456788' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub542 subtract '1231234555555555555555555567456788' 0.500000001 -> '1231234555555555555555555567456787' Inexact Rounded
-
-rounding: down
-dqsub550 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
-dqsub551 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub552 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub553 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub554 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub555 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub556 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub557 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub558 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub559 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub560 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub561 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub562 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub563 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub564 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub565 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub566 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
-dqsub567 subtract '1231234555555555555555555567456789' 1.00000001 -> '1231234555555555555555555567456787' Inexact Rounded
-dqsub568 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456787' Inexact Rounded
-dqsub569 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456787' Inexact Rounded
-
--- symmetry...
-rounding: half_up
-dqsub600 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
-dqsub601 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub602 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub603 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub604 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub605 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub606 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub607 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub608 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub609 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub610 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub611 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub612 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub613 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub614 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub615 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub616 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
-dqsub617 subtract 1.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub618 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub619 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-
-rounding: half_even
-dqsub620 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
-dqsub621 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub622 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub623 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub624 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub625 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub626 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub627 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub628 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub629 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub630 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub631 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub632 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub633 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub634 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub635 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub636 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
-dqsub637 subtract 1.00000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub638 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub639 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
--- critical few with even bottom digit...
-dqsub640 subtract 0.499999999 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub641 subtract 0.5 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub642 subtract 0.500000001 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456787' Inexact Rounded
-
-rounding: down
-dqsub650 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
-dqsub651 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub652 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub653 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub654 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub655 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub656 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub657 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub658 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub659 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub660 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub661 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub662 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub663 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub664 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub665 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub666 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
-dqsub667 subtract 1.00000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
-dqsub668 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
-dqsub669 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
-
-
--- lots of leading zeros in intermediate result, and showing effects of
--- input rounding would have affected the following
-rounding: half_up
-dqsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
-dqsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
-dqsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
-dqsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
-dqsub674 subtract '1234567456789' '1234567456789.9' -> -0.9
-
-rounding: half_even
-dqsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
-dqsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
-dqsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
-dqsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
-dqsub684 subtract '1234567456789' '1234567456789.9' -> -0.9
-
-dqsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
-dqsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
-dqsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
-dqsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
-dqsub689 subtract '1234567456788' '1234567456788.9' -> -0.9
-
-rounding: down
-dqsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
-dqsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
-dqsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
-dqsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
-dqsub694 subtract '1234567456789' '1234567456789.9' -> -0.9
-
--- Specials
-dqsub780 subtract -Inf Inf -> -Infinity
-dqsub781 subtract -Inf 1000 -> -Infinity
-dqsub782 subtract -Inf 1 -> -Infinity
-dqsub783 subtract -Inf -0 -> -Infinity
-dqsub784 subtract -Inf -1 -> -Infinity
-dqsub785 subtract -Inf -1000 -> -Infinity
-dqsub787 subtract -1000 Inf -> -Infinity
-dqsub788 subtract -Inf Inf -> -Infinity
-dqsub789 subtract -1 Inf -> -Infinity
-dqsub790 subtract 0 Inf -> -Infinity
-dqsub791 subtract 1 Inf -> -Infinity
-dqsub792 subtract 1000 Inf -> -Infinity
-
-dqsub800 subtract Inf Inf -> NaN Invalid_operation
-dqsub801 subtract Inf 1000 -> Infinity
-dqsub802 subtract Inf 1 -> Infinity
-dqsub803 subtract Inf 0 -> Infinity
-dqsub804 subtract Inf -0 -> Infinity
-dqsub805 subtract Inf -1 -> Infinity
-dqsub806 subtract Inf -1000 -> Infinity
-dqsub807 subtract Inf -Inf -> Infinity
-dqsub808 subtract -1000 -Inf -> Infinity
-dqsub809 subtract -Inf -Inf -> NaN Invalid_operation
-dqsub810 subtract -1 -Inf -> Infinity
-dqsub811 subtract -0 -Inf -> Infinity
-dqsub812 subtract 0 -Inf -> Infinity
-dqsub813 subtract 1 -Inf -> Infinity
-dqsub814 subtract 1000 -Inf -> Infinity
-dqsub815 subtract Inf -Inf -> Infinity
-
-dqsub821 subtract NaN Inf -> NaN
-dqsub822 subtract -NaN 1000 -> -NaN
-dqsub823 subtract NaN 1 -> NaN
-dqsub824 subtract NaN 0 -> NaN
-dqsub825 subtract NaN -0 -> NaN
-dqsub826 subtract NaN -1 -> NaN
-dqsub827 subtract NaN -1000 -> NaN
-dqsub828 subtract NaN -Inf -> NaN
-dqsub829 subtract -NaN NaN -> -NaN
-dqsub830 subtract -Inf NaN -> NaN
-dqsub831 subtract -1000 NaN -> NaN
-dqsub832 subtract -1 NaN -> NaN
-dqsub833 subtract -0 NaN -> NaN
-dqsub834 subtract 0 NaN -> NaN
-dqsub835 subtract 1 NaN -> NaN
-dqsub836 subtract 1000 -NaN -> -NaN
-dqsub837 subtract Inf NaN -> NaN
-
-dqsub841 subtract sNaN Inf -> NaN Invalid_operation
-dqsub842 subtract -sNaN 1000 -> -NaN Invalid_operation
-dqsub843 subtract sNaN 1 -> NaN Invalid_operation
-dqsub844 subtract sNaN 0 -> NaN Invalid_operation
-dqsub845 subtract sNaN -0 -> NaN Invalid_operation
-dqsub846 subtract sNaN -1 -> NaN Invalid_operation
-dqsub847 subtract sNaN -1000 -> NaN Invalid_operation
-dqsub848 subtract sNaN NaN -> NaN Invalid_operation
-dqsub849 subtract sNaN sNaN -> NaN Invalid_operation
-dqsub850 subtract NaN sNaN -> NaN Invalid_operation
-dqsub851 subtract -Inf -sNaN -> -NaN Invalid_operation
-dqsub852 subtract -1000 sNaN -> NaN Invalid_operation
-dqsub853 subtract -1 sNaN -> NaN Invalid_operation
-dqsub854 subtract -0 sNaN -> NaN Invalid_operation
-dqsub855 subtract 0 sNaN -> NaN Invalid_operation
-dqsub856 subtract 1 sNaN -> NaN Invalid_operation
-dqsub857 subtract 1000 sNaN -> NaN Invalid_operation
-dqsub858 subtract Inf sNaN -> NaN Invalid_operation
-dqsub859 subtract NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqsub861 subtract NaN01 -Inf -> NaN1
-dqsub862 subtract -NaN02 -1000 -> -NaN2
-dqsub863 subtract NaN03 1000 -> NaN3
-dqsub864 subtract NaN04 Inf -> NaN4
-dqsub865 subtract NaN05 NaN61 -> NaN5
-dqsub866 subtract -Inf -NaN71 -> -NaN71
-dqsub867 subtract -1000 NaN81 -> NaN81
-dqsub868 subtract 1000 NaN91 -> NaN91
-dqsub869 subtract Inf NaN101 -> NaN101
-dqsub871 subtract sNaN011 -Inf -> NaN11 Invalid_operation
-dqsub872 subtract sNaN012 -1000 -> NaN12 Invalid_operation
-dqsub873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation
-dqsub874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation
-dqsub875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation
-dqsub876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation
-dqsub877 subtract -Inf sNaN201 -> NaN201 Invalid_operation
-dqsub878 subtract -1000 sNaN211 -> NaN211 Invalid_operation
-dqsub879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation
-dqsub880 subtract Inf sNaN231 -> NaN231 Invalid_operation
-dqsub881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- edge case spills
-dqsub901 subtract 2.E-3 1.002 -> -1.000
-dqsub902 subtract 2.0E-3 1.002 -> -1.0000
-dqsub903 subtract 2.00E-3 1.0020 -> -1.00000
-dqsub904 subtract 2.000E-3 1.00200 -> -1.000000
-dqsub905 subtract 2.0000E-3 1.002000 -> -1.0000000
-dqsub906 subtract 2.00000E-3 1.0020000 -> -1.00000000
-dqsub907 subtract 2.000000E-3 1.00200000 -> -1.000000000
-dqsub908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000
-
--- subnormals and overflows covered under Add
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dqsub1125 subtract 130E-2 120E-2 -> 0.10
-dqsub1126 subtract 130E-2 12E-1 -> 0.10
-dqsub1127 subtract 130E-2 1E0 -> 0.30
-dqsub1128 subtract 1E2 1E4 -> -9.9E+3
-
--- Null tests
-dqsub9990 subtract 10 # -> NaN Invalid_operation
-dqsub9991 subtract # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqSubtract.decTest -- decQuad subtraction --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decQuads only; all arguments are
+-- representable in a decQuad
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+dqsub001 subtract 0 0 -> '0'
+dqsub002 subtract 1 1 -> '0'
+dqsub003 subtract 1 2 -> '-1'
+dqsub004 subtract 2 1 -> '1'
+dqsub005 subtract 2 2 -> '0'
+dqsub006 subtract 3 2 -> '1'
+dqsub007 subtract 2 3 -> '-1'
+
+dqsub011 subtract -0 0 -> '-0'
+dqsub012 subtract -1 1 -> '-2'
+dqsub013 subtract -1 2 -> '-3'
+dqsub014 subtract -2 1 -> '-3'
+dqsub015 subtract -2 2 -> '-4'
+dqsub016 subtract -3 2 -> '-5'
+dqsub017 subtract -2 3 -> '-5'
+
+dqsub021 subtract 0 -0 -> '0'
+dqsub022 subtract 1 -1 -> '2'
+dqsub023 subtract 1 -2 -> '3'
+dqsub024 subtract 2 -1 -> '3'
+dqsub025 subtract 2 -2 -> '4'
+dqsub026 subtract 3 -2 -> '5'
+dqsub027 subtract 2 -3 -> '5'
+
+dqsub030 subtract 11 1 -> 10
+dqsub031 subtract 10 1 -> 9
+dqsub032 subtract 9 1 -> 8
+dqsub033 subtract 1 1 -> 0
+dqsub034 subtract 0 1 -> -1
+dqsub035 subtract -1 1 -> -2
+dqsub036 subtract -9 1 -> -10
+dqsub037 subtract -10 1 -> -11
+dqsub038 subtract -11 1 -> -12
+
+dqsub040 subtract '5.75' '3.3' -> '2.45'
+dqsub041 subtract '5' '-3' -> '8'
+dqsub042 subtract '-5' '-3' -> '-2'
+dqsub043 subtract '-7' '2.5' -> '-9.5'
+dqsub044 subtract '0.7' '0.3' -> '0.4'
+dqsub045 subtract '1.3' '0.3' -> '1.0'
+dqsub046 subtract '1.25' '1.25' -> '0.00'
+
+dqsub050 subtract '1.23456789' '1.00000000' -> '0.23456789'
+dqsub051 subtract '1.23456789' '1.00000089' -> '0.23456700'
+
+dqsub060 subtract '70' '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
+dqsub061 subtract '700' '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
+dqsub062 subtract '7000' '10000e+34' -> '-9.999999999999999999999999999999999E+37' Inexact Rounded
+dqsub063 subtract '70000' '10000e+34' -> '-9.999999999999999999999999999999993E+37' Rounded
+dqsub064 subtract '700000' '10000e+34' -> '-9.999999999999999999999999999999930E+37' Rounded
+ -- symmetry:
+dqsub065 subtract '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqsub066 subtract '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqsub067 subtract '10000e+34' '7000' -> '9.999999999999999999999999999999999E+37' Inexact Rounded
+dqsub068 subtract '10000e+34' '70000' -> '9.999999999999999999999999999999993E+37' Rounded
+dqsub069 subtract '10000e+34' '700000' -> '9.999999999999999999999999999999930E+37' Rounded
+
+ -- some of the next group are really constructor tests
+dqsub090 subtract '00.0' '0.0' -> '0.0'
+dqsub091 subtract '00.0' '0.00' -> '0.00'
+dqsub092 subtract '0.00' '00.0' -> '0.00'
+dqsub093 subtract '00.0' '0.00' -> '0.00'
+dqsub094 subtract '0.00' '00.0' -> '0.00'
+dqsub095 subtract '3' '.3' -> '2.7'
+dqsub096 subtract '3.' '.3' -> '2.7'
+dqsub097 subtract '3.0' '.3' -> '2.7'
+dqsub098 subtract '3.00' '.3' -> '2.70'
+dqsub099 subtract '3' '3' -> '0'
+dqsub100 subtract '3' '+3' -> '0'
+dqsub101 subtract '3' '-3' -> '6'
+dqsub102 subtract '3' '0.3' -> '2.7'
+dqsub103 subtract '3.' '0.3' -> '2.7'
+dqsub104 subtract '3.0' '0.3' -> '2.7'
+dqsub105 subtract '3.00' '0.3' -> '2.70'
+dqsub106 subtract '3' '3.0' -> '0.0'
+dqsub107 subtract '3' '+3.0' -> '0.0'
+dqsub108 subtract '3' '-3.0' -> '6.0'
+
+-- the above all from add; massaged and extended. Now some new ones...
+-- [particularly important for comparisons]
+-- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
+-- with input rounding.
+dqsub120 subtract '10.23456784' '10.23456789' -> '-5E-8'
+dqsub121 subtract '10.23456785' '10.23456789' -> '-4E-8'
+dqsub122 subtract '10.23456786' '10.23456789' -> '-3E-8'
+dqsub123 subtract '10.23456787' '10.23456789' -> '-2E-8'
+dqsub124 subtract '10.23456788' '10.23456789' -> '-1E-8'
+dqsub125 subtract '10.23456789' '10.23456789' -> '0E-8'
+dqsub126 subtract '10.23456790' '10.23456789' -> '1E-8'
+dqsub127 subtract '10.23456791' '10.23456789' -> '2E-8'
+dqsub128 subtract '10.23456792' '10.23456789' -> '3E-8'
+dqsub129 subtract '10.23456793' '10.23456789' -> '4E-8'
+dqsub130 subtract '10.23456794' '10.23456789' -> '5E-8'
+dqsub131 subtract '10.23456781' '10.23456786' -> '-5E-8'
+dqsub132 subtract '10.23456782' '10.23456786' -> '-4E-8'
+dqsub133 subtract '10.23456783' '10.23456786' -> '-3E-8'
+dqsub134 subtract '10.23456784' '10.23456786' -> '-2E-8'
+dqsub135 subtract '10.23456785' '10.23456786' -> '-1E-8'
+dqsub136 subtract '10.23456786' '10.23456786' -> '0E-8'
+dqsub137 subtract '10.23456787' '10.23456786' -> '1E-8'
+dqsub138 subtract '10.23456788' '10.23456786' -> '2E-8'
+dqsub139 subtract '10.23456789' '10.23456786' -> '3E-8'
+dqsub140 subtract '10.23456790' '10.23456786' -> '4E-8'
+dqsub141 subtract '10.23456791' '10.23456786' -> '5E-8'
+dqsub142 subtract '1' '0.999999999' -> '1E-9'
+dqsub143 subtract '0.999999999' '1' -> '-1E-9'
+dqsub144 subtract '-10.23456780' '-10.23456786' -> '6E-8'
+dqsub145 subtract '-10.23456790' '-10.23456786' -> '-4E-8'
+dqsub146 subtract '-10.23456791' '-10.23456786' -> '-5E-8'
+
+-- additional scaled arithmetic tests [0.97 problem]
+dqsub160 subtract '0' '.1' -> '-0.1'
+dqsub161 subtract '00' '.97983' -> '-0.97983'
+dqsub162 subtract '0' '.9' -> '-0.9'
+dqsub163 subtract '0' '0.102' -> '-0.102'
+dqsub164 subtract '0' '.4' -> '-0.4'
+dqsub165 subtract '0' '.307' -> '-0.307'
+dqsub166 subtract '0' '.43822' -> '-0.43822'
+dqsub167 subtract '0' '.911' -> '-0.911'
+dqsub168 subtract '.0' '.02' -> '-0.02'
+dqsub169 subtract '00' '.392' -> '-0.392'
+dqsub170 subtract '0' '.26' -> '-0.26'
+dqsub171 subtract '0' '0.51' -> '-0.51'
+dqsub172 subtract '0' '.2234' -> '-0.2234'
+dqsub173 subtract '0' '.2' -> '-0.2'
+dqsub174 subtract '.0' '.0008' -> '-0.0008'
+-- 0. on left
+dqsub180 subtract '0.0' '-.1' -> '0.1'
+dqsub181 subtract '0.00' '-.97983' -> '0.97983'
+dqsub182 subtract '0.0' '-.9' -> '0.9'
+dqsub183 subtract '0.0' '-0.102' -> '0.102'
+dqsub184 subtract '0.0' '-.4' -> '0.4'
+dqsub185 subtract '0.0' '-.307' -> '0.307'
+dqsub186 subtract '0.0' '-.43822' -> '0.43822'
+dqsub187 subtract '0.0' '-.911' -> '0.911'
+dqsub188 subtract '0.0' '-.02' -> '0.02'
+dqsub189 subtract '0.00' '-.392' -> '0.392'
+dqsub190 subtract '0.0' '-.26' -> '0.26'
+dqsub191 subtract '0.0' '-0.51' -> '0.51'
+dqsub192 subtract '0.0' '-.2234' -> '0.2234'
+dqsub193 subtract '0.0' '-.2' -> '0.2'
+dqsub194 subtract '0.0' '-.0008' -> '0.0008'
+-- negatives of same
+dqsub200 subtract '0' '-.1' -> '0.1'
+dqsub201 subtract '00' '-.97983' -> '0.97983'
+dqsub202 subtract '0' '-.9' -> '0.9'
+dqsub203 subtract '0' '-0.102' -> '0.102'
+dqsub204 subtract '0' '-.4' -> '0.4'
+dqsub205 subtract '0' '-.307' -> '0.307'
+dqsub206 subtract '0' '-.43822' -> '0.43822'
+dqsub207 subtract '0' '-.911' -> '0.911'
+dqsub208 subtract '.0' '-.02' -> '0.02'
+dqsub209 subtract '00' '-.392' -> '0.392'
+dqsub210 subtract '0' '-.26' -> '0.26'
+dqsub211 subtract '0' '-0.51' -> '0.51'
+dqsub212 subtract '0' '-.2234' -> '0.2234'
+dqsub213 subtract '0' '-.2' -> '0.2'
+dqsub214 subtract '.0' '-.0008' -> '0.0008'
+
+-- more fixed, LHS swaps [really the same as testcases under add]
+dqsub220 subtract '-56267E-12' 0 -> '-5.6267E-8'
+dqsub221 subtract '-56267E-11' 0 -> '-5.6267E-7'
+dqsub222 subtract '-56267E-10' 0 -> '-0.0000056267'
+dqsub223 subtract '-56267E-9' 0 -> '-0.000056267'
+dqsub224 subtract '-56267E-8' 0 -> '-0.00056267'
+dqsub225 subtract '-56267E-7' 0 -> '-0.0056267'
+dqsub226 subtract '-56267E-6' 0 -> '-0.056267'
+dqsub227 subtract '-56267E-5' 0 -> '-0.56267'
+dqsub228 subtract '-56267E-2' 0 -> '-562.67'
+dqsub229 subtract '-56267E-1' 0 -> '-5626.7'
+dqsub230 subtract '-56267E-0' 0 -> '-56267'
+-- symmetry ...
+dqsub240 subtract 0 '-56267E-12' -> '5.6267E-8'
+dqsub241 subtract 0 '-56267E-11' -> '5.6267E-7'
+dqsub242 subtract 0 '-56267E-10' -> '0.0000056267'
+dqsub243 subtract 0 '-56267E-9' -> '0.000056267'
+dqsub244 subtract 0 '-56267E-8' -> '0.00056267'
+dqsub245 subtract 0 '-56267E-7' -> '0.0056267'
+dqsub246 subtract 0 '-56267E-6' -> '0.056267'
+dqsub247 subtract 0 '-56267E-5' -> '0.56267'
+dqsub248 subtract 0 '-56267E-2' -> '562.67'
+dqsub249 subtract 0 '-56267E-1' -> '5626.7'
+dqsub250 subtract 0 '-56267E-0' -> '56267'
+
+-- now some more from the 'new' add
+dqsub301 subtract '1.23456789' '1.00000000' -> '0.23456789'
+dqsub302 subtract '1.23456789' '1.00000011' -> '0.23456778'
+
+-- some carrying effects
+dqsub321 subtract '0.9998' '0.0000' -> '0.9998'
+dqsub322 subtract '0.9998' '0.0001' -> '0.9997'
+dqsub323 subtract '0.9998' '0.0002' -> '0.9996'
+dqsub324 subtract '0.9998' '0.0003' -> '0.9995'
+dqsub325 subtract '0.9998' '-0.0000' -> '0.9998'
+dqsub326 subtract '0.9998' '-0.0001' -> '0.9999'
+dqsub327 subtract '0.9998' '-0.0002' -> '1.0000'
+dqsub328 subtract '0.9998' '-0.0003' -> '1.0001'
+
+-- internal boundaries
+dqsub346 subtract '10000e+9' '7' -> '9999999999993'
+dqsub347 subtract '10000e+9' '70' -> '9999999999930'
+dqsub348 subtract '10000e+9' '700' -> '9999999999300'
+dqsub349 subtract '10000e+9' '7000' -> '9999999993000'
+dqsub350 subtract '10000e+9' '70000' -> '9999999930000'
+dqsub351 subtract '10000e+9' '700000' -> '9999999300000'
+dqsub352 subtract '7' '10000e+9' -> '-9999999999993'
+dqsub353 subtract '70' '10000e+9' -> '-9999999999930'
+dqsub354 subtract '700' '10000e+9' -> '-9999999999300'
+dqsub355 subtract '7000' '10000e+9' -> '-9999999993000'
+dqsub356 subtract '70000' '10000e+9' -> '-9999999930000'
+dqsub357 subtract '700000' '10000e+9' -> '-9999999300000'
+
+-- zero preservation
+dqsub361 subtract 1 '0.0001' -> '0.9999'
+dqsub362 subtract 1 '0.00001' -> '0.99999'
+dqsub363 subtract 1 '0.000001' -> '0.999999'
+dqsub364 subtract 1 '0.0000000000000000000000000000000001' -> '0.9999999999999999999999999999999999'
+dqsub365 subtract 1 '0.00000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub366 subtract 1 '0.000000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
+
+-- some funny zeros [in case of bad signum]
+dqsub370 subtract 1 0 -> 1
+dqsub371 subtract 1 0. -> 1
+dqsub372 subtract 1 .0 -> 1.0
+dqsub373 subtract 1 0.0 -> 1.0
+dqsub374 subtract 0 1 -> -1
+dqsub375 subtract 0. 1 -> -1
+dqsub376 subtract .0 1 -> -1.0
+dqsub377 subtract 0.0 1 -> -1.0
+
+-- leading 0 digit before round
+dqsub910 subtract -103519362 -51897955.3 -> -51621406.7
+dqsub911 subtract 159579.444 89827.5229 -> 69751.9211
+
+dqsub920 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234566 -> 299.9999999999999999999999999999999 Inexact Rounded
+dqsub921 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 300.0000000000000000000000000000000 Inexact Rounded
+dqsub922 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 99.99999999999999999999999999999995
+dqsub923 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234564 -> 99.99999999999999999999999999999996
+dqsub924 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234540 -> 100.0000000000000000000000000000002 Rounded
+dqsub925 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234560 -> 90.00000000000000000000000000000000
+dqsub926 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234561 -> 89.99999999999999999999999999999999
+dqsub927 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234566 -> 89.99999999999999999999999999999994
+dqsub928 subtract 101.0000000000000000000000000123456 91.00000000000000000000000001234566 -> 9.99999999999999999999999999999994
+dqsub929 subtract 101.0000000000000000000000000123456 99.00000000000000000000000001234566 -> 1.99999999999999999999999999999994
+
+-- more LHS swaps [were fixed]
+dqsub390 subtract '-56267E-10' 0 -> '-0.0000056267'
+dqsub391 subtract '-56267E-6' 0 -> '-0.056267'
+dqsub392 subtract '-56267E-5' 0 -> '-0.56267'
+dqsub393 subtract '-56267E-4' 0 -> '-5.6267'
+dqsub394 subtract '-56267E-3' 0 -> '-56.267'
+dqsub395 subtract '-56267E-2' 0 -> '-562.67'
+dqsub396 subtract '-56267E-1' 0 -> '-5626.7'
+dqsub397 subtract '-56267E-0' 0 -> '-56267'
+dqsub398 subtract '-5E-10' 0 -> '-5E-10'
+dqsub399 subtract '-5E-7' 0 -> '-5E-7'
+dqsub400 subtract '-5E-6' 0 -> '-0.000005'
+dqsub401 subtract '-5E-5' 0 -> '-0.00005'
+dqsub402 subtract '-5E-4' 0 -> '-0.0005'
+dqsub403 subtract '-5E-1' 0 -> '-0.5'
+dqsub404 subtract '-5E0' 0 -> '-5'
+dqsub405 subtract '-5E1' 0 -> '-50'
+dqsub406 subtract '-5E5' 0 -> '-500000'
+dqsub407 subtract '-5E33' 0 -> '-5000000000000000000000000000000000'
+dqsub408 subtract '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
+dqsub409 subtract '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
+dqsub410 subtract '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
+dqsub411 subtract '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- more RHS swaps [were fixed]
+dqsub420 subtract 0 '-56267E-10' -> '0.0000056267'
+dqsub421 subtract 0 '-56267E-6' -> '0.056267'
+dqsub422 subtract 0 '-56267E-5' -> '0.56267'
+dqsub423 subtract 0 '-56267E-4' -> '5.6267'
+dqsub424 subtract 0 '-56267E-3' -> '56.267'
+dqsub425 subtract 0 '-56267E-2' -> '562.67'
+dqsub426 subtract 0 '-56267E-1' -> '5626.7'
+dqsub427 subtract 0 '-56267E-0' -> '56267'
+dqsub428 subtract 0 '-5E-10' -> '5E-10'
+dqsub429 subtract 0 '-5E-7' -> '5E-7'
+dqsub430 subtract 0 '-5E-6' -> '0.000005'
+dqsub431 subtract 0 '-5E-5' -> '0.00005'
+dqsub432 subtract 0 '-5E-4' -> '0.0005'
+dqsub433 subtract 0 '-5E-1' -> '0.5'
+dqsub434 subtract 0 '-5E0' -> '5'
+dqsub435 subtract 0 '-5E1' -> '50'
+dqsub436 subtract 0 '-5E5' -> '500000'
+dqsub437 subtract 0 '-5E33' -> '5000000000000000000000000000000000'
+dqsub438 subtract 0 '-5E34' -> '5.000000000000000000000000000000000E+34' Rounded
+dqsub439 subtract 0 '-5E35' -> '5.000000000000000000000000000000000E+35' Rounded
+dqsub440 subtract 0 '-5E36' -> '5.000000000000000000000000000000000E+36' Rounded
+dqsub441 subtract 0 '-5E100' -> '5.000000000000000000000000000000000E+100' Rounded
+
+
+-- try borderline precision, with carries, etc.
+dqsub461 subtract '1E+16' '1' -> '9999999999999999'
+dqsub462 subtract '1E+12' '-1.111' -> '1000000000001.111'
+dqsub463 subtract '1.111' '-1E+12' -> '1000000000001.111'
+dqsub464 subtract '-1' '-1E+16' -> '9999999999999999'
+dqsub465 subtract '7E+15' '1' -> '6999999999999999'
+dqsub466 subtract '7E+12' '-1.111' -> '7000000000001.111'
+dqsub467 subtract '1.111' '-7E+12' -> '7000000000001.111'
+dqsub468 subtract '-1' '-7E+15' -> '6999999999999999'
+
+-- 1234567890123456 1234567890123456 1 23456789012345
+dqsub470 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555563' -> '1.000000000000000000000000000000001' Inexact Rounded
+dqsub471 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555562' -> '1.000000000000000000000000000000001' Inexact Rounded
+dqsub472 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555561' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub473 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555560' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub474 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555559' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub475 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555558' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub476 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555557' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub477 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555556' -> '1.000000000000000000000000000000000' Rounded
+dqsub478 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
+dqsub479 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555554' -> '0.9999999999999999999999999999999998'
+dqsub480 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555553' -> '0.9999999999999999999999999999999997'
+dqsub481 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555552' -> '0.9999999999999999999999999999999996'
+dqsub482 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555551' -> '0.9999999999999999999999999999999995'
+dqsub483 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555550' -> '0.9999999999999999999999999999999994'
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+dqsub500 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
+dqsub501 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub502 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub503 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub504 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub505 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub506 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub507 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub508 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub509 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub510 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub511 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub512 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub513 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub514 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub515 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub516 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
+dqsub517 subtract '1231234555555555555555555567456789' 1.000000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub518 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub519 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456788' Inexact Rounded
+
+rounding: half_even
+dqsub520 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
+dqsub521 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub522 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub523 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub524 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub525 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub526 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub527 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub528 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub529 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub530 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub531 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub532 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub533 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub534 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub535 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub536 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
+dqsub537 subtract '1231234555555555555555555567456789' 1.00000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub538 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub539 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456788' Inexact Rounded
+-- critical few with even bottom digit...
+dqsub540 subtract '1231234555555555555555555567456788' 0.499999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub541 subtract '1231234555555555555555555567456788' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub542 subtract '1231234555555555555555555567456788' 0.500000001 -> '1231234555555555555555555567456787' Inexact Rounded
+
+rounding: down
+dqsub550 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
+dqsub551 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub552 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub553 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub554 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub555 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub556 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub557 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub558 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub559 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub560 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub561 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub562 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub563 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub564 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub565 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub566 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
+dqsub567 subtract '1231234555555555555555555567456789' 1.00000001 -> '1231234555555555555555555567456787' Inexact Rounded
+dqsub568 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456787' Inexact Rounded
+dqsub569 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456787' Inexact Rounded
+
+-- symmetry...
+rounding: half_up
+dqsub600 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
+dqsub601 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub602 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub603 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub604 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub605 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub606 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub607 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub608 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub609 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub610 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub611 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub612 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub613 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub614 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub615 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub616 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
+dqsub617 subtract 1.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub618 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub619 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+
+rounding: half_even
+dqsub620 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
+dqsub621 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub622 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub623 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub624 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub625 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub626 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub627 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub628 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub629 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub630 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub631 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub632 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub633 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub634 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub635 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub636 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
+dqsub637 subtract 1.00000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub638 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub639 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+-- critical few with even bottom digit...
+dqsub640 subtract 0.499999999 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub641 subtract 0.5 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub642 subtract 0.500000001 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456787' Inexact Rounded
+
+rounding: down
+dqsub650 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
+dqsub651 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub652 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub653 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub654 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub655 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub656 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub657 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub658 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub659 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub660 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub661 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub662 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub663 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub664 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub665 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub666 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
+dqsub667 subtract 1.00000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
+dqsub668 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
+dqsub669 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
+
+
+-- lots of leading zeros in intermediate result, and showing effects of
+-- input rounding would have affected the following
+rounding: half_up
+dqsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
+dqsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
+dqsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
+dqsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
+dqsub674 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+rounding: half_even
+dqsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
+dqsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
+dqsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
+dqsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
+dqsub684 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+dqsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
+dqsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
+dqsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
+dqsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
+dqsub689 subtract '1234567456788' '1234567456788.9' -> -0.9
+
+rounding: down
+dqsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
+dqsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
+dqsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
+dqsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
+dqsub694 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+-- Specials
+dqsub780 subtract -Inf Inf -> -Infinity
+dqsub781 subtract -Inf 1000 -> -Infinity
+dqsub782 subtract -Inf 1 -> -Infinity
+dqsub783 subtract -Inf -0 -> -Infinity
+dqsub784 subtract -Inf -1 -> -Infinity
+dqsub785 subtract -Inf -1000 -> -Infinity
+dqsub787 subtract -1000 Inf -> -Infinity
+dqsub788 subtract -Inf Inf -> -Infinity
+dqsub789 subtract -1 Inf -> -Infinity
+dqsub790 subtract 0 Inf -> -Infinity
+dqsub791 subtract 1 Inf -> -Infinity
+dqsub792 subtract 1000 Inf -> -Infinity
+
+dqsub800 subtract Inf Inf -> NaN Invalid_operation
+dqsub801 subtract Inf 1000 -> Infinity
+dqsub802 subtract Inf 1 -> Infinity
+dqsub803 subtract Inf 0 -> Infinity
+dqsub804 subtract Inf -0 -> Infinity
+dqsub805 subtract Inf -1 -> Infinity
+dqsub806 subtract Inf -1000 -> Infinity
+dqsub807 subtract Inf -Inf -> Infinity
+dqsub808 subtract -1000 -Inf -> Infinity
+dqsub809 subtract -Inf -Inf -> NaN Invalid_operation
+dqsub810 subtract -1 -Inf -> Infinity
+dqsub811 subtract -0 -Inf -> Infinity
+dqsub812 subtract 0 -Inf -> Infinity
+dqsub813 subtract 1 -Inf -> Infinity
+dqsub814 subtract 1000 -Inf -> Infinity
+dqsub815 subtract Inf -Inf -> Infinity
+
+dqsub821 subtract NaN Inf -> NaN
+dqsub822 subtract -NaN 1000 -> -NaN
+dqsub823 subtract NaN 1 -> NaN
+dqsub824 subtract NaN 0 -> NaN
+dqsub825 subtract NaN -0 -> NaN
+dqsub826 subtract NaN -1 -> NaN
+dqsub827 subtract NaN -1000 -> NaN
+dqsub828 subtract NaN -Inf -> NaN
+dqsub829 subtract -NaN NaN -> -NaN
+dqsub830 subtract -Inf NaN -> NaN
+dqsub831 subtract -1000 NaN -> NaN
+dqsub832 subtract -1 NaN -> NaN
+dqsub833 subtract -0 NaN -> NaN
+dqsub834 subtract 0 NaN -> NaN
+dqsub835 subtract 1 NaN -> NaN
+dqsub836 subtract 1000 -NaN -> -NaN
+dqsub837 subtract Inf NaN -> NaN
+
+dqsub841 subtract sNaN Inf -> NaN Invalid_operation
+dqsub842 subtract -sNaN 1000 -> -NaN Invalid_operation
+dqsub843 subtract sNaN 1 -> NaN Invalid_operation
+dqsub844 subtract sNaN 0 -> NaN Invalid_operation
+dqsub845 subtract sNaN -0 -> NaN Invalid_operation
+dqsub846 subtract sNaN -1 -> NaN Invalid_operation
+dqsub847 subtract sNaN -1000 -> NaN Invalid_operation
+dqsub848 subtract sNaN NaN -> NaN Invalid_operation
+dqsub849 subtract sNaN sNaN -> NaN Invalid_operation
+dqsub850 subtract NaN sNaN -> NaN Invalid_operation
+dqsub851 subtract -Inf -sNaN -> -NaN Invalid_operation
+dqsub852 subtract -1000 sNaN -> NaN Invalid_operation
+dqsub853 subtract -1 sNaN -> NaN Invalid_operation
+dqsub854 subtract -0 sNaN -> NaN Invalid_operation
+dqsub855 subtract 0 sNaN -> NaN Invalid_operation
+dqsub856 subtract 1 sNaN -> NaN Invalid_operation
+dqsub857 subtract 1000 sNaN -> NaN Invalid_operation
+dqsub858 subtract Inf sNaN -> NaN Invalid_operation
+dqsub859 subtract NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqsub861 subtract NaN01 -Inf -> NaN1
+dqsub862 subtract -NaN02 -1000 -> -NaN2
+dqsub863 subtract NaN03 1000 -> NaN3
+dqsub864 subtract NaN04 Inf -> NaN4
+dqsub865 subtract NaN05 NaN61 -> NaN5
+dqsub866 subtract -Inf -NaN71 -> -NaN71
+dqsub867 subtract -1000 NaN81 -> NaN81
+dqsub868 subtract 1000 NaN91 -> NaN91
+dqsub869 subtract Inf NaN101 -> NaN101
+dqsub871 subtract sNaN011 -Inf -> NaN11 Invalid_operation
+dqsub872 subtract sNaN012 -1000 -> NaN12 Invalid_operation
+dqsub873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation
+dqsub874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation
+dqsub875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation
+dqsub876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation
+dqsub877 subtract -Inf sNaN201 -> NaN201 Invalid_operation
+dqsub878 subtract -1000 sNaN211 -> NaN211 Invalid_operation
+dqsub879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation
+dqsub880 subtract Inf sNaN231 -> NaN231 Invalid_operation
+dqsub881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- edge case spills
+dqsub901 subtract 2.E-3 1.002 -> -1.000
+dqsub902 subtract 2.0E-3 1.002 -> -1.0000
+dqsub903 subtract 2.00E-3 1.0020 -> -1.00000
+dqsub904 subtract 2.000E-3 1.00200 -> -1.000000
+dqsub905 subtract 2.0000E-3 1.002000 -> -1.0000000
+dqsub906 subtract 2.00000E-3 1.0020000 -> -1.00000000
+dqsub907 subtract 2.000000E-3 1.00200000 -> -1.000000000
+dqsub908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000
+
+-- subnormals and overflows covered under Add
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dqsub1125 subtract 130E-2 120E-2 -> 0.10
+dqsub1126 subtract 130E-2 12E-1 -> 0.10
+dqsub1127 subtract 130E-2 1E0 -> 0.30
+dqsub1128 subtract 1E2 1E4 -> -9.9E+3
+
+-- Null tests
+dqsub9990 subtract 10 # -> NaN Invalid_operation
+dqsub9991 subtract # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqToIntegral.decTest b/Lib/test/decimaltestdata/dqToIntegral.decTest
index 3055de572d..eb12387eab 100644
--- a/Lib/test/decimaltestdata/dqToIntegral.decTest
+++ b/Lib/test/decimaltestdata/dqToIntegral.decTest
@@ -1,257 +1,257 @@
-------------------------------------------------------------------------
--- dqToIntegral.decTest -- round Quad to integral value --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests tests the extended specification 'round-to-integral
--- value-exact' operations (from IEEE 854, later modified in 754r).
--- All non-zero results are defined as being those from either copy or
--- quantize, so those are assumed to have been tested extensively
--- elsewhere; the tests here are for integrity, rounding mode, etc.
--- Also, it is assumed the test harness will use these tests for both
--- ToIntegralExact (which does set Inexact) and the fixed-name
--- functions (which do not set Inexact).
-
--- Note that decNumber implements an earlier definition of toIntegral
--- which never sets Inexact; the decTest operator for that is called
--- 'tointegral' instead of 'tointegralx'.
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqintx001 tointegralx 0 -> 0
-dqintx002 tointegralx 0.0 -> 0
-dqintx003 tointegralx 0.1 -> 0 Inexact Rounded
-dqintx004 tointegralx 0.2 -> 0 Inexact Rounded
-dqintx005 tointegralx 0.3 -> 0 Inexact Rounded
-dqintx006 tointegralx 0.4 -> 0 Inexact Rounded
-dqintx007 tointegralx 0.5 -> 0 Inexact Rounded
-dqintx008 tointegralx 0.6 -> 1 Inexact Rounded
-dqintx009 tointegralx 0.7 -> 1 Inexact Rounded
-dqintx010 tointegralx 0.8 -> 1 Inexact Rounded
-dqintx011 tointegralx 0.9 -> 1 Inexact Rounded
-dqintx012 tointegralx 1 -> 1
-dqintx013 tointegralx 1.0 -> 1 Rounded
-dqintx014 tointegralx 1.1 -> 1 Inexact Rounded
-dqintx015 tointegralx 1.2 -> 1 Inexact Rounded
-dqintx016 tointegralx 1.3 -> 1 Inexact Rounded
-dqintx017 tointegralx 1.4 -> 1 Inexact Rounded
-dqintx018 tointegralx 1.5 -> 2 Inexact Rounded
-dqintx019 tointegralx 1.6 -> 2 Inexact Rounded
-dqintx020 tointegralx 1.7 -> 2 Inexact Rounded
-dqintx021 tointegralx 1.8 -> 2 Inexact Rounded
-dqintx022 tointegralx 1.9 -> 2 Inexact Rounded
--- negatives
-dqintx031 tointegralx -0 -> -0
-dqintx032 tointegralx -0.0 -> -0
-dqintx033 tointegralx -0.1 -> -0 Inexact Rounded
-dqintx034 tointegralx -0.2 -> -0 Inexact Rounded
-dqintx035 tointegralx -0.3 -> -0 Inexact Rounded
-dqintx036 tointegralx -0.4 -> -0 Inexact Rounded
-dqintx037 tointegralx -0.5 -> -0 Inexact Rounded
-dqintx038 tointegralx -0.6 -> -1 Inexact Rounded
-dqintx039 tointegralx -0.7 -> -1 Inexact Rounded
-dqintx040 tointegralx -0.8 -> -1 Inexact Rounded
-dqintx041 tointegralx -0.9 -> -1 Inexact Rounded
-dqintx042 tointegralx -1 -> -1
-dqintx043 tointegralx -1.0 -> -1 Rounded
-dqintx044 tointegralx -1.1 -> -1 Inexact Rounded
-dqintx045 tointegralx -1.2 -> -1 Inexact Rounded
-dqintx046 tointegralx -1.3 -> -1 Inexact Rounded
-dqintx047 tointegralx -1.4 -> -1 Inexact Rounded
-dqintx048 tointegralx -1.5 -> -2 Inexact Rounded
-dqintx049 tointegralx -1.6 -> -2 Inexact Rounded
-dqintx050 tointegralx -1.7 -> -2 Inexact Rounded
-dqintx051 tointegralx -1.8 -> -2 Inexact Rounded
-dqintx052 tointegralx -1.9 -> -2 Inexact Rounded
--- next two would be NaN using quantize(x, 0)
-dqintx053 tointegralx 10E+60 -> 1.0E+61
-dqintx054 tointegralx -10E+60 -> -1.0E+61
-
--- numbers around precision
-dqintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
-dqintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
-dqintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
-dqintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
-dqintx065 tointegralx '56267E-0' -> '56267'
-dqintx066 tointegralx '56267E+0' -> '56267'
-dqintx067 tointegralx '56267E+1' -> '5.6267E+5'
-dqintx068 tointegralx '56267E+9' -> '5.6267E+13'
-dqintx069 tointegralx '56267E+10' -> '5.6267E+14'
-dqintx070 tointegralx '56267E+11' -> '5.6267E+15'
-dqintx071 tointegralx '56267E+12' -> '5.6267E+16'
-dqintx072 tointegralx '56267E+13' -> '5.6267E+17'
-dqintx073 tointegralx '1.23E+96' -> '1.23E+96'
-dqintx074 tointegralx '1.23E+6144' -> #47ffd300000000000000000000000000 Clamped
-
-dqintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
-dqintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
-dqintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
-dqintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
-dqintx085 tointegralx '-56267E-0' -> '-56267'
-dqintx086 tointegralx '-56267E+0' -> '-56267'
-dqintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
-dqintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
-dqintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
-dqintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
-dqintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
-dqintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
-dqintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
-dqintx094 tointegralx '-1.23E+6144' -> #c7ffd300000000000000000000000000 Clamped
-
--- subnormal inputs
-dqintx100 tointegralx 1E-299 -> 0 Inexact Rounded
-dqintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
-dqintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
-dqintx103 tointegralx 0E-299 -> 0
-
--- specials and zeros
-dqintx120 tointegralx 'Inf' -> Infinity
-dqintx121 tointegralx '-Inf' -> -Infinity
-dqintx122 tointegralx NaN -> NaN
-dqintx123 tointegralx sNaN -> NaN Invalid_operation
-dqintx124 tointegralx 0 -> 0
-dqintx125 tointegralx -0 -> -0
-dqintx126 tointegralx 0.000 -> 0
-dqintx127 tointegralx 0.00 -> 0
-dqintx128 tointegralx 0.0 -> 0
-dqintx129 tointegralx 0 -> 0
-dqintx130 tointegralx 0E-3 -> 0
-dqintx131 tointegralx 0E-2 -> 0
-dqintx132 tointegralx 0E-1 -> 0
-dqintx133 tointegralx 0E-0 -> 0
-dqintx134 tointegralx 0E+1 -> 0E+1
-dqintx135 tointegralx 0E+2 -> 0E+2
-dqintx136 tointegralx 0E+3 -> 0E+3
-dqintx137 tointegralx 0E+4 -> 0E+4
-dqintx138 tointegralx 0E+5 -> 0E+5
-dqintx139 tointegralx -0.000 -> -0
-dqintx140 tointegralx -0.00 -> -0
-dqintx141 tointegralx -0.0 -> -0
-dqintx142 tointegralx -0 -> -0
-dqintx143 tointegralx -0E-3 -> -0
-dqintx144 tointegralx -0E-2 -> -0
-dqintx145 tointegralx -0E-1 -> -0
-dqintx146 tointegralx -0E-0 -> -0
-dqintx147 tointegralx -0E+1 -> -0E+1
-dqintx148 tointegralx -0E+2 -> -0E+2
-dqintx149 tointegralx -0E+3 -> -0E+3
-dqintx150 tointegralx -0E+4 -> -0E+4
-dqintx151 tointegralx -0E+5 -> -0E+5
--- propagating NaNs
-dqintx152 tointegralx NaN808 -> NaN808
-dqintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
-dqintx154 tointegralx -NaN808 -> -NaN808
-dqintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
-dqintx156 tointegralx -NaN -> -NaN
-dqintx157 tointegralx -sNaN -> -NaN Invalid_operation
-
--- examples
-rounding: half_up
-dqintx200 tointegralx 2.1 -> 2 Inexact Rounded
-dqintx201 tointegralx 100 -> 100
-dqintx202 tointegralx 100.0 -> 100 Rounded
-dqintx203 tointegralx 101.5 -> 102 Inexact Rounded
-dqintx204 tointegralx -101.5 -> -102 Inexact Rounded
-dqintx205 tointegralx 10E+5 -> 1.0E+6
-dqintx206 tointegralx 7.89E+77 -> 7.89E+77
-dqintx207 tointegralx -Inf -> -Infinity
-
-
--- all rounding modes
-rounding: half_even
-dqintx210 tointegralx 55.5 -> 56 Inexact Rounded
-dqintx211 tointegralx 56.5 -> 56 Inexact Rounded
-dqintx212 tointegralx 57.5 -> 58 Inexact Rounded
-dqintx213 tointegralx -55.5 -> -56 Inexact Rounded
-dqintx214 tointegralx -56.5 -> -56 Inexact Rounded
-dqintx215 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_up
-
-dqintx220 tointegralx 55.5 -> 56 Inexact Rounded
-dqintx221 tointegralx 56.5 -> 57 Inexact Rounded
-dqintx222 tointegralx 57.5 -> 58 Inexact Rounded
-dqintx223 tointegralx -55.5 -> -56 Inexact Rounded
-dqintx224 tointegralx -56.5 -> -57 Inexact Rounded
-dqintx225 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_down
-
-dqintx230 tointegralx 55.5 -> 55 Inexact Rounded
-dqintx231 tointegralx 56.5 -> 56 Inexact Rounded
-dqintx232 tointegralx 57.5 -> 57 Inexact Rounded
-dqintx233 tointegralx -55.5 -> -55 Inexact Rounded
-dqintx234 tointegralx -56.5 -> -56 Inexact Rounded
-dqintx235 tointegralx -57.5 -> -57 Inexact Rounded
-
-rounding: up
-
-dqintx240 tointegralx 55.3 -> 56 Inexact Rounded
-dqintx241 tointegralx 56.3 -> 57 Inexact Rounded
-dqintx242 tointegralx 57.3 -> 58 Inexact Rounded
-dqintx243 tointegralx -55.3 -> -56 Inexact Rounded
-dqintx244 tointegralx -56.3 -> -57 Inexact Rounded
-dqintx245 tointegralx -57.3 -> -58 Inexact Rounded
-
-rounding: down
-
-dqintx250 tointegralx 55.7 -> 55 Inexact Rounded
-dqintx251 tointegralx 56.7 -> 56 Inexact Rounded
-dqintx252 tointegralx 57.7 -> 57 Inexact Rounded
-dqintx253 tointegralx -55.7 -> -55 Inexact Rounded
-dqintx254 tointegralx -56.7 -> -56 Inexact Rounded
-dqintx255 tointegralx -57.7 -> -57 Inexact Rounded
-
-rounding: ceiling
-
-dqintx260 tointegralx 55.3 -> 56 Inexact Rounded
-dqintx261 tointegralx 56.3 -> 57 Inexact Rounded
-dqintx262 tointegralx 57.3 -> 58 Inexact Rounded
-dqintx263 tointegralx -55.3 -> -55 Inexact Rounded
-dqintx264 tointegralx -56.3 -> -56 Inexact Rounded
-dqintx265 tointegralx -57.3 -> -57 Inexact Rounded
-
-rounding: floor
-
-dqintx270 tointegralx 55.7 -> 55 Inexact Rounded
-dqintx271 tointegralx 56.7 -> 56 Inexact Rounded
-dqintx272 tointegralx 57.7 -> 57 Inexact Rounded
-dqintx273 tointegralx -55.7 -> -56 Inexact Rounded
-dqintx274 tointegralx -56.7 -> -57 Inexact Rounded
-dqintx275 tointegralx -57.7 -> -58 Inexact Rounded
-
--- Int and uInt32 edge values for testing conversions
-dqintx300 tointegralx -2147483646 -> -2147483646
-dqintx301 tointegralx -2147483647 -> -2147483647
-dqintx302 tointegralx -2147483648 -> -2147483648
-dqintx303 tointegralx -2147483649 -> -2147483649
-dqintx304 tointegralx 2147483646 -> 2147483646
-dqintx305 tointegralx 2147483647 -> 2147483647
-dqintx306 tointegralx 2147483648 -> 2147483648
-dqintx307 tointegralx 2147483649 -> 2147483649
-dqintx308 tointegralx 4294967294 -> 4294967294
-dqintx309 tointegralx 4294967295 -> 4294967295
-dqintx310 tointegralx 4294967296 -> 4294967296
-dqintx311 tointegralx 4294967297 -> 4294967297
-
+------------------------------------------------------------------------
+-- dqToIntegral.decTest -- round Quad to integral value --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests tests the extended specification 'round-to-integral
+-- value-exact' operations (from IEEE 854, later modified in 754r).
+-- All non-zero results are defined as being those from either copy or
+-- quantize, so those are assumed to have been tested extensively
+-- elsewhere; the tests here are for integrity, rounding mode, etc.
+-- Also, it is assumed the test harness will use these tests for both
+-- ToIntegralExact (which does set Inexact) and the fixed-name
+-- functions (which do not set Inexact).
+
+-- Note that decNumber implements an earlier definition of toIntegral
+-- which never sets Inexact; the decTest operator for that is called
+-- 'tointegral' instead of 'tointegralx'.
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqintx001 tointegralx 0 -> 0
+dqintx002 tointegralx 0.0 -> 0
+dqintx003 tointegralx 0.1 -> 0 Inexact Rounded
+dqintx004 tointegralx 0.2 -> 0 Inexact Rounded
+dqintx005 tointegralx 0.3 -> 0 Inexact Rounded
+dqintx006 tointegralx 0.4 -> 0 Inexact Rounded
+dqintx007 tointegralx 0.5 -> 0 Inexact Rounded
+dqintx008 tointegralx 0.6 -> 1 Inexact Rounded
+dqintx009 tointegralx 0.7 -> 1 Inexact Rounded
+dqintx010 tointegralx 0.8 -> 1 Inexact Rounded
+dqintx011 tointegralx 0.9 -> 1 Inexact Rounded
+dqintx012 tointegralx 1 -> 1
+dqintx013 tointegralx 1.0 -> 1 Rounded
+dqintx014 tointegralx 1.1 -> 1 Inexact Rounded
+dqintx015 tointegralx 1.2 -> 1 Inexact Rounded
+dqintx016 tointegralx 1.3 -> 1 Inexact Rounded
+dqintx017 tointegralx 1.4 -> 1 Inexact Rounded
+dqintx018 tointegralx 1.5 -> 2 Inexact Rounded
+dqintx019 tointegralx 1.6 -> 2 Inexact Rounded
+dqintx020 tointegralx 1.7 -> 2 Inexact Rounded
+dqintx021 tointegralx 1.8 -> 2 Inexact Rounded
+dqintx022 tointegralx 1.9 -> 2 Inexact Rounded
+-- negatives
+dqintx031 tointegralx -0 -> -0
+dqintx032 tointegralx -0.0 -> -0
+dqintx033 tointegralx -0.1 -> -0 Inexact Rounded
+dqintx034 tointegralx -0.2 -> -0 Inexact Rounded
+dqintx035 tointegralx -0.3 -> -0 Inexact Rounded
+dqintx036 tointegralx -0.4 -> -0 Inexact Rounded
+dqintx037 tointegralx -0.5 -> -0 Inexact Rounded
+dqintx038 tointegralx -0.6 -> -1 Inexact Rounded
+dqintx039 tointegralx -0.7 -> -1 Inexact Rounded
+dqintx040 tointegralx -0.8 -> -1 Inexact Rounded
+dqintx041 tointegralx -0.9 -> -1 Inexact Rounded
+dqintx042 tointegralx -1 -> -1
+dqintx043 tointegralx -1.0 -> -1 Rounded
+dqintx044 tointegralx -1.1 -> -1 Inexact Rounded
+dqintx045 tointegralx -1.2 -> -1 Inexact Rounded
+dqintx046 tointegralx -1.3 -> -1 Inexact Rounded
+dqintx047 tointegralx -1.4 -> -1 Inexact Rounded
+dqintx048 tointegralx -1.5 -> -2 Inexact Rounded
+dqintx049 tointegralx -1.6 -> -2 Inexact Rounded
+dqintx050 tointegralx -1.7 -> -2 Inexact Rounded
+dqintx051 tointegralx -1.8 -> -2 Inexact Rounded
+dqintx052 tointegralx -1.9 -> -2 Inexact Rounded
+-- next two would be NaN using quantize(x, 0)
+dqintx053 tointegralx 10E+60 -> 1.0E+61
+dqintx054 tointegralx -10E+60 -> -1.0E+61
+
+-- numbers around precision
+dqintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
+dqintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
+dqintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
+dqintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
+dqintx065 tointegralx '56267E-0' -> '56267'
+dqintx066 tointegralx '56267E+0' -> '56267'
+dqintx067 tointegralx '56267E+1' -> '5.6267E+5'
+dqintx068 tointegralx '56267E+9' -> '5.6267E+13'
+dqintx069 tointegralx '56267E+10' -> '5.6267E+14'
+dqintx070 tointegralx '56267E+11' -> '5.6267E+15'
+dqintx071 tointegralx '56267E+12' -> '5.6267E+16'
+dqintx072 tointegralx '56267E+13' -> '5.6267E+17'
+dqintx073 tointegralx '1.23E+96' -> '1.23E+96'
+dqintx074 tointegralx '1.23E+6144' -> #47ffd300000000000000000000000000 Clamped
+
+dqintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
+dqintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
+dqintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
+dqintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
+dqintx085 tointegralx '-56267E-0' -> '-56267'
+dqintx086 tointegralx '-56267E+0' -> '-56267'
+dqintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
+dqintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
+dqintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
+dqintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
+dqintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
+dqintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
+dqintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
+dqintx094 tointegralx '-1.23E+6144' -> #c7ffd300000000000000000000000000 Clamped
+
+-- subnormal inputs
+dqintx100 tointegralx 1E-299 -> 0 Inexact Rounded
+dqintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
+dqintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
+dqintx103 tointegralx 0E-299 -> 0
+
+-- specials and zeros
+dqintx120 tointegralx 'Inf' -> Infinity
+dqintx121 tointegralx '-Inf' -> -Infinity
+dqintx122 tointegralx NaN -> NaN
+dqintx123 tointegralx sNaN -> NaN Invalid_operation
+dqintx124 tointegralx 0 -> 0
+dqintx125 tointegralx -0 -> -0
+dqintx126 tointegralx 0.000 -> 0
+dqintx127 tointegralx 0.00 -> 0
+dqintx128 tointegralx 0.0 -> 0
+dqintx129 tointegralx 0 -> 0
+dqintx130 tointegralx 0E-3 -> 0
+dqintx131 tointegralx 0E-2 -> 0
+dqintx132 tointegralx 0E-1 -> 0
+dqintx133 tointegralx 0E-0 -> 0
+dqintx134 tointegralx 0E+1 -> 0E+1
+dqintx135 tointegralx 0E+2 -> 0E+2
+dqintx136 tointegralx 0E+3 -> 0E+3
+dqintx137 tointegralx 0E+4 -> 0E+4
+dqintx138 tointegralx 0E+5 -> 0E+5
+dqintx139 tointegralx -0.000 -> -0
+dqintx140 tointegralx -0.00 -> -0
+dqintx141 tointegralx -0.0 -> -0
+dqintx142 tointegralx -0 -> -0
+dqintx143 tointegralx -0E-3 -> -0
+dqintx144 tointegralx -0E-2 -> -0
+dqintx145 tointegralx -0E-1 -> -0
+dqintx146 tointegralx -0E-0 -> -0
+dqintx147 tointegralx -0E+1 -> -0E+1
+dqintx148 tointegralx -0E+2 -> -0E+2
+dqintx149 tointegralx -0E+3 -> -0E+3
+dqintx150 tointegralx -0E+4 -> -0E+4
+dqintx151 tointegralx -0E+5 -> -0E+5
+-- propagating NaNs
+dqintx152 tointegralx NaN808 -> NaN808
+dqintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
+dqintx154 tointegralx -NaN808 -> -NaN808
+dqintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
+dqintx156 tointegralx -NaN -> -NaN
+dqintx157 tointegralx -sNaN -> -NaN Invalid_operation
+
+-- examples
+rounding: half_up
+dqintx200 tointegralx 2.1 -> 2 Inexact Rounded
+dqintx201 tointegralx 100 -> 100
+dqintx202 tointegralx 100.0 -> 100 Rounded
+dqintx203 tointegralx 101.5 -> 102 Inexact Rounded
+dqintx204 tointegralx -101.5 -> -102 Inexact Rounded
+dqintx205 tointegralx 10E+5 -> 1.0E+6
+dqintx206 tointegralx 7.89E+77 -> 7.89E+77
+dqintx207 tointegralx -Inf -> -Infinity
+
+
+-- all rounding modes
+rounding: half_even
+dqintx210 tointegralx 55.5 -> 56 Inexact Rounded
+dqintx211 tointegralx 56.5 -> 56 Inexact Rounded
+dqintx212 tointegralx 57.5 -> 58 Inexact Rounded
+dqintx213 tointegralx -55.5 -> -56 Inexact Rounded
+dqintx214 tointegralx -56.5 -> -56 Inexact Rounded
+dqintx215 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_up
+
+dqintx220 tointegralx 55.5 -> 56 Inexact Rounded
+dqintx221 tointegralx 56.5 -> 57 Inexact Rounded
+dqintx222 tointegralx 57.5 -> 58 Inexact Rounded
+dqintx223 tointegralx -55.5 -> -56 Inexact Rounded
+dqintx224 tointegralx -56.5 -> -57 Inexact Rounded
+dqintx225 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_down
+
+dqintx230 tointegralx 55.5 -> 55 Inexact Rounded
+dqintx231 tointegralx 56.5 -> 56 Inexact Rounded
+dqintx232 tointegralx 57.5 -> 57 Inexact Rounded
+dqintx233 tointegralx -55.5 -> -55 Inexact Rounded
+dqintx234 tointegralx -56.5 -> -56 Inexact Rounded
+dqintx235 tointegralx -57.5 -> -57 Inexact Rounded
+
+rounding: up
+
+dqintx240 tointegralx 55.3 -> 56 Inexact Rounded
+dqintx241 tointegralx 56.3 -> 57 Inexact Rounded
+dqintx242 tointegralx 57.3 -> 58 Inexact Rounded
+dqintx243 tointegralx -55.3 -> -56 Inexact Rounded
+dqintx244 tointegralx -56.3 -> -57 Inexact Rounded
+dqintx245 tointegralx -57.3 -> -58 Inexact Rounded
+
+rounding: down
+
+dqintx250 tointegralx 55.7 -> 55 Inexact Rounded
+dqintx251 tointegralx 56.7 -> 56 Inexact Rounded
+dqintx252 tointegralx 57.7 -> 57 Inexact Rounded
+dqintx253 tointegralx -55.7 -> -55 Inexact Rounded
+dqintx254 tointegralx -56.7 -> -56 Inexact Rounded
+dqintx255 tointegralx -57.7 -> -57 Inexact Rounded
+
+rounding: ceiling
+
+dqintx260 tointegralx 55.3 -> 56 Inexact Rounded
+dqintx261 tointegralx 56.3 -> 57 Inexact Rounded
+dqintx262 tointegralx 57.3 -> 58 Inexact Rounded
+dqintx263 tointegralx -55.3 -> -55 Inexact Rounded
+dqintx264 tointegralx -56.3 -> -56 Inexact Rounded
+dqintx265 tointegralx -57.3 -> -57 Inexact Rounded
+
+rounding: floor
+
+dqintx270 tointegralx 55.7 -> 55 Inexact Rounded
+dqintx271 tointegralx 56.7 -> 56 Inexact Rounded
+dqintx272 tointegralx 57.7 -> 57 Inexact Rounded
+dqintx273 tointegralx -55.7 -> -56 Inexact Rounded
+dqintx274 tointegralx -56.7 -> -57 Inexact Rounded
+dqintx275 tointegralx -57.7 -> -58 Inexact Rounded
+
+-- Int and uInt32 edge values for testing conversions
+dqintx300 tointegralx -2147483646 -> -2147483646
+dqintx301 tointegralx -2147483647 -> -2147483647
+dqintx302 tointegralx -2147483648 -> -2147483648
+dqintx303 tointegralx -2147483649 -> -2147483649
+dqintx304 tointegralx 2147483646 -> 2147483646
+dqintx305 tointegralx 2147483647 -> 2147483647
+dqintx306 tointegralx 2147483648 -> 2147483648
+dqintx307 tointegralx 2147483649 -> 2147483649
+dqintx308 tointegralx 4294967294 -> 4294967294
+dqintx309 tointegralx 4294967295 -> 4294967295
+dqintx310 tointegralx 4294967296 -> 4294967296
+dqintx311 tointegralx 4294967297 -> 4294967297
+
diff --git a/Lib/test/decimaltestdata/dqXor.decTest b/Lib/test/decimaltestdata/dqXor.decTest
index 2216e9ebf8..fbb32e441b 100644
--- a/Lib/test/decimaltestdata/dqXor.decTest
+++ b/Lib/test/decimaltestdata/dqXor.decTest
@@ -1,410 +1,410 @@
-------------------------------------------------------------------------
--- dqXor.decTest -- digitwise logical XOR for decQuads --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check (truth table)
-dqxor001 xor 0 0 -> 0
-dqxor002 xor 0 1 -> 1
-dqxor003 xor 1 0 -> 1
-dqxor004 xor 1 1 -> 0
-dqxor005 xor 1100 1010 -> 110
--- and at msd and msd-1
-dqxor006 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqxor007 xor 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqxor008 xor 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqxor009 xor 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 0
-dqxor010 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqxor011 xor 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
-dqxor012 xor 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 100000000000000000000000000000000
-dqxor013 xor 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 0
-
--- Various lengths
--- 1234567890123456789012345678901234
-dqxor601 xor 0111111111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000000000
-dqxor602 xor 1011111111111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000000000
-dqxor603 xor 1101111111111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000000000
-dqxor604 xor 1110111111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000000
-dqxor605 xor 1111011111111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000000
-dqxor606 xor 1111101111111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000000
-dqxor607 xor 1111110111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000
-dqxor608 xor 1111111011111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000
-dqxor609 xor 1111111101111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000
-dqxor610 xor 1111111110111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000
-dqxor611 xor 1111111111011111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000
-dqxor612 xor 1111111111101111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000
-dqxor613 xor 1111111111110111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000
-dqxor614 xor 1111111111111011111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000
-dqxor615 xor 1111111111111101111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000
-dqxor616 xor 1111111111111110111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000
-dqxor617 xor 1111111111111111011111111111111111 1111111111111111111111111111111111 -> 100000000000000000
-dqxor618 xor 1111111111111111101111111111111111 1111111111111111111111111111111111 -> 10000000000000000
-dqxor619 xor 1111111111111111110111111111111111 1111111111111111111111111111111111 -> 1000000000000000
-dqxor620 xor 1111111111111111111011111111111111 1111111111111111111111111111111111 -> 100000000000000
-dqxor621 xor 1111111111111111111101111111111111 1111111111111111111111111111111111 -> 10000000000000
-dqxor622 xor 1111111111111111111110111111111111 1111111111111111111111111111111111 -> 1000000000000
-dqxor623 xor 1111111111111111111111011111111111 1111111111111111111111111111111111 -> 100000000000
-dqxor624 xor 1111111111111111111111101111111111 1111111111111111111111111111111111 -> 10000000000
-dqxor625 xor 1111111111111111111111110111111111 1111111111111111111111111111111111 -> 1000000000
-dqxor626 xor 1111111111111111111111111011111111 1111111111111111111111111111111111 -> 100000000
-dqxor627 xor 1111111111111111111111111101111111 1111111111111111111111111111111111 -> 10000000
-dqxor628 xor 1111111111111111111111111110111111 1111111111111111111111111111111111 -> 1000000
-dqxor629 xor 1111111111111111111111111111011111 1111111111111111111111111111111111 -> 100000
-dqxor630 xor 1111111111111111111111111111101111 1111111111111111111111111111111111 -> 10000
-dqxor631 xor 1111111111111111111111111111110111 1111111111111111111111111111111111 -> 1000
-dqxor632 xor 1111111111111111111111111111111011 1111111111111111111111111111111111 -> 100
-dqxor633 xor 1111111111111111111111111111111101 1111111111111111111111111111111111 -> 10
-dqxor634 xor 1111111111111111111111111111111110 1111111111111111111111111111111111 -> 1
-
-dqxor641 xor 1111111111111111111111111111111111 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
-dqxor642 xor 1111111111111111111111111111111111 1011111111111111111111111111111111 -> 100000000000000000000000000000000
-dqxor643 xor 1111111111111111111111111111111111 1101111111111111111111111111111111 -> 10000000000000000000000000000000
-dqxor644 xor 1111111111111111111111111111111111 1110111111111111111111111111111111 -> 1000000000000000000000000000000
-dqxor645 xor 1111111111111111111111111111111111 1111011111111111111111111111111111 -> 100000000000000000000000000000
-dqxor646 xor 1111111111111111111111111111111111 1111101111111111111111111111111111 -> 10000000000000000000000000000
-dqxor647 xor 1111111111111111111111111111111111 1111110111111111111111111111111111 -> 1000000000000000000000000000
-dqxor648 xor 1111111111111111111111111111111111 1111111011111111111111111111111111 -> 100000000000000000000000000
-dqxor649 xor 1111111111111111111111111111111111 1111111101111111111111111111111111 -> 10000000000000000000000000
-dqxor650 xor 1111111111111111111111111111111111 1111111110111111111111111111111111 -> 1000000000000000000000000
-dqxor651 xor 1111111111111111111111111111111111 1111111111011111111111111111111111 -> 100000000000000000000000
-dqxor652 xor 1111111111111111111111111111111111 1111111111101111111111111111111111 -> 10000000000000000000000
-dqxor653 xor 1111111111111111111111111111111111 1111111111110111111111111111111111 -> 1000000000000000000000
-dqxor654 xor 1111111111111111111111111111111111 1111111111111011111111111111111111 -> 100000000000000000000
-dqxor655 xor 1111111111111111111111111111111111 1111111111111101111111111111111111 -> 10000000000000000000
-dqxor656 xor 1111111111111111111111111111111111 1111111111111110111111111111111111 -> 1000000000000000000
-dqxor657 xor 1111111111111111111111111111111111 1111111111111111011111111111111111 -> 100000000000000000
-dqxor658 xor 1111111111111111111111111111111111 1111111111111111101111111111111111 -> 10000000000000000
-dqxor659 xor 1111111111111111111111111111111111 1111111111111111110111111111111111 -> 1000000000000000
-dqxor660 xor 1111111111111111111111111111111111 1111111111111111111011111111111111 -> 100000000000000
-dqxor661 xor 1111111111111111111111111111111111 1111111111111111111101111111111111 -> 10000000000000
-dqxor662 xor 1111111111111111111111111111111111 1111111111111111111110111111111111 -> 1000000000000
-dqxor663 xor 1111111111111111111111111111111111 1111111111111111111111011111111111 -> 100000000000
-dqxor664 xor 1111111111111111111111111111111111 1111111111111111111111101111111111 -> 10000000000
-dqxor665 xor 1111111111111111111111111111111111 1111111111111111111111110111111111 -> 1000000000
-dqxor666 xor 1111111111111111111111111111111111 1111111111111111111111111011111111 -> 100000000
-dqxor667 xor 1111111111111111111111111111111111 1111111111111111111111111101111111 -> 10000000
-dqxor668 xor 1111111111111111111111111111111111 1111111111111111111111111110111111 -> 1000000
-dqxor669 xor 1111111111111111111111111111111111 1111111111111111111111111111011111 -> 100000
-dqxor670 xor 1111111111111111111111111111111111 1111111111111111111111111111101111 -> 10000
-dqxor671 xor 1111111111111111111111111111111111 1111111111111111111111111111110111 -> 1000
-dqxor672 xor 1111111111111111111111111111111111 1111111111111111111111111111111011 -> 100
-dqxor673 xor 1111111111111111111111111111111111 1111111111111111111111111111111101 -> 10
-dqxor674 xor 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1
-dqxor675 xor 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1000000000000000000000000000000001
-dqxor676 xor 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1
-
-
-dqxor021 xor 1111111110000000 1111111110000000 -> 0
-dqxor022 xor 111111110000000 111111110000000 -> 0
-dqxor023 xor 11111110000000 11111110000000 -> 0
-dqxor024 xor 1111110000000 1111110000000 -> 0
-dqxor025 xor 111110000000 111110000000 -> 0
-dqxor026 xor 11110000000 11110000000 -> 0
-dqxor027 xor 1110000000 1110000000 -> 0
-dqxor028 xor 110000000 110000000 -> 0
-dqxor029 xor 10000000 10000000 -> 0
-dqxor030 xor 1000000 1000000 -> 0
-dqxor031 xor 100000 100000 -> 0
-dqxor032 xor 10000 10000 -> 0
-dqxor033 xor 1000 1000 -> 0
-dqxor034 xor 100 100 -> 0
-dqxor035 xor 10 10 -> 0
-dqxor036 xor 1 1 -> 0
-
-dqxor040 xor 111111111 111111111111 -> 111000000000
-dqxor041 xor 11111111 111111111111 -> 111100000000
-dqxor042 xor 11111111 111111111 -> 100000000
-dqxor043 xor 1111111 100000010 -> 101111101
-dqxor044 xor 111111 100000100 -> 100111011
-dqxor045 xor 11111 100001000 -> 100010111
-dqxor046 xor 1111 100010000 -> 100011111
-dqxor047 xor 111 100100000 -> 100100111
-dqxor048 xor 11 101000000 -> 101000011
-dqxor049 xor 1 110000000 -> 110000001
-
-dqxor050 xor 1111111111 1 -> 1111111110
-dqxor051 xor 111111111 1 -> 111111110
-dqxor052 xor 11111111 1 -> 11111110
-dqxor053 xor 1111111 1 -> 1111110
-dqxor054 xor 111111 1 -> 111110
-dqxor055 xor 11111 1 -> 11110
-dqxor056 xor 1111 1 -> 1110
-dqxor057 xor 111 1 -> 110
-dqxor058 xor 11 1 -> 10
-dqxor059 xor 1 1 -> 0
-
-dqxor060 xor 1111111111 0 -> 1111111111
-dqxor061 xor 111111111 0 -> 111111111
-dqxor062 xor 11111111 0 -> 11111111
-dqxor063 xor 1111111 0 -> 1111111
-dqxor064 xor 111111 0 -> 111111
-dqxor065 xor 11111 0 -> 11111
-dqxor066 xor 1111 0 -> 1111
-dqxor067 xor 111 0 -> 111
-dqxor068 xor 11 0 -> 11
-dqxor069 xor 1 0 -> 1
-
-dqxor070 xor 1 1111111111 -> 1111111110
-dqxor071 xor 1 111111111 -> 111111110
-dqxor072 xor 1 11111111 -> 11111110
-dqxor073 xor 1 1111111 -> 1111110
-dqxor074 xor 1 111111 -> 111110
-dqxor075 xor 1 11111 -> 11110
-dqxor076 xor 1 1111 -> 1110
-dqxor077 xor 1 111 -> 110
-dqxor078 xor 1 11 -> 10
-dqxor079 xor 1 1 -> 0
-
-dqxor080 xor 0 1111111111 -> 1111111111
-dqxor081 xor 0 111111111 -> 111111111
-dqxor082 xor 0 11111111 -> 11111111
-dqxor083 xor 0 1111111 -> 1111111
-dqxor084 xor 0 111111 -> 111111
-dqxor085 xor 0 11111 -> 11111
-dqxor086 xor 0 1111 -> 1111
-dqxor087 xor 0 111 -> 111
-dqxor088 xor 0 11 -> 11
-dqxor089 xor 0 1 -> 1
-
-dqxor090 xor 011111111 111101111 -> 100010000
-dqxor091 xor 101111111 111101111 -> 10010000
-dqxor092 xor 110111111 111101111 -> 1010000
-dqxor093 xor 111011111 111101111 -> 110000
-dqxor094 xor 111101111 111101111 -> 0
-dqxor095 xor 111110111 111101111 -> 11000
-dqxor096 xor 111111011 111101111 -> 10100
-dqxor097 xor 111111101 111101111 -> 10010
-dqxor098 xor 111111110 111101111 -> 10001
-
-dqxor100 xor 111101111 011111111 -> 100010000
-dqxor101 xor 111101111 101111111 -> 10010000
-dqxor102 xor 111101111 110111111 -> 1010000
-dqxor103 xor 111101111 111011111 -> 110000
-dqxor104 xor 111101111 111101111 -> 0
-dqxor105 xor 111101111 111110111 -> 11000
-dqxor106 xor 111101111 111111011 -> 10100
-dqxor107 xor 111101111 111111101 -> 10010
-dqxor108 xor 111101111 111111110 -> 10001
-
--- non-0/1 should not be accepted, nor should signs
-dqxor220 xor 111111112 111111111 -> NaN Invalid_operation
-dqxor221 xor 333333333 333333333 -> NaN Invalid_operation
-dqxor222 xor 555555555 555555555 -> NaN Invalid_operation
-dqxor223 xor 777777777 777777777 -> NaN Invalid_operation
-dqxor224 xor 999999999 999999999 -> NaN Invalid_operation
-dqxor225 xor 222222222 999999999 -> NaN Invalid_operation
-dqxor226 xor 444444444 999999999 -> NaN Invalid_operation
-dqxor227 xor 666666666 999999999 -> NaN Invalid_operation
-dqxor228 xor 888888888 999999999 -> NaN Invalid_operation
-dqxor229 xor 999999999 222222222 -> NaN Invalid_operation
-dqxor230 xor 999999999 444444444 -> NaN Invalid_operation
-dqxor231 xor 999999999 666666666 -> NaN Invalid_operation
-dqxor232 xor 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-dqxor240 xor 567468689 -934981942 -> NaN Invalid_operation
-dqxor241 xor 567367689 934981942 -> NaN Invalid_operation
-dqxor242 xor -631917772 -706014634 -> NaN Invalid_operation
-dqxor243 xor -756253257 138579234 -> NaN Invalid_operation
-dqxor244 xor 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-dqxor250 xor 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor251 xor 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor252 xor 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor253 xor 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor254 xor 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor255 xor 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor256 xor 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor257 xor 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor258 xor 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor259 xor 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor260 xor 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor261 xor 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor262 xor 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor263 xor 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor264 xor 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor265 xor 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
--- test MSD-1
-dqxor270 xor 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
-dqxor271 xor 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
-dqxor272 xor 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
-dqxor273 xor 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
-dqxor274 xor 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
-dqxor275 xor 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
-dqxor276 xor 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
-dqxor277 xor 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
--- test LSD
-dqxor280 xor 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
-dqxor281 xor 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
-dqxor282 xor 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
-dqxor283 xor 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
-dqxor284 xor 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
-dqxor285 xor 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
-dqxor286 xor 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
-dqxor287 xor 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
--- test Middie
-dqxor288 xor 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
-dqxor289 xor 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
-dqxor290 xor 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
-dqxor291 xor 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
-dqxor292 xor 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
-dqxor293 xor 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
-dqxor294 xor 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
-dqxor295 xor 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
--- signs
-dqxor296 xor -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
-dqxor297 xor -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
-dqxor298 xor 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
-dqxor299 xor 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 1000001001001001001001000010000100
-
--- Nmax, Nmin, Ntiny-like
-dqxor331 xor 2 9.99999999E+999 -> NaN Invalid_operation
-dqxor332 xor 3 1E-999 -> NaN Invalid_operation
-dqxor333 xor 4 1.00000000E-2821 -> NaN Invalid_operation
-dqxor334 xor 5 1E-900 -> NaN Invalid_operation
-dqxor335 xor 6 -1E-900 -> NaN Invalid_operation
-dqxor336 xor 7 -1.00000000E-999 -> NaN Invalid_operation
-dqxor337 xor 8 -1E-999 -> NaN Invalid_operation
-dqxor338 xor 9 -9.99999999E+999 -> NaN Invalid_operation
-dqxor341 xor 9.99999999E+999 -18 -> NaN Invalid_operation
-dqxor342 xor 1E-999 01 -> NaN Invalid_operation
-dqxor343 xor 1.00000000E-999 -18 -> NaN Invalid_operation
-dqxor344 xor 1E-908 18 -> NaN Invalid_operation
-dqxor345 xor -1E-907 -10 -> NaN Invalid_operation
-dqxor346 xor -1.00000000E-999 18 -> NaN Invalid_operation
-dqxor347 xor -1E-999 10 -> NaN Invalid_operation
-dqxor348 xor -9.99999999E+2991 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-dqxor361 xor 1.0 1 -> NaN Invalid_operation
-dqxor362 xor 1E+1 1 -> NaN Invalid_operation
-dqxor363 xor 0.0 1 -> NaN Invalid_operation
-dqxor364 xor 0E+1 1 -> NaN Invalid_operation
-dqxor365 xor 9.9 1 -> NaN Invalid_operation
-dqxor366 xor 9E+1 1 -> NaN Invalid_operation
-dqxor371 xor 0 1.0 -> NaN Invalid_operation
-dqxor372 xor 0 1E+1 -> NaN Invalid_operation
-dqxor373 xor 0 0.0 -> NaN Invalid_operation
-dqxor374 xor 0 0E+1 -> NaN Invalid_operation
-dqxor375 xor 0 9.9 -> NaN Invalid_operation
-dqxor376 xor 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-dqxor780 xor -Inf -Inf -> NaN Invalid_operation
-dqxor781 xor -Inf -1000 -> NaN Invalid_operation
-dqxor782 xor -Inf -1 -> NaN Invalid_operation
-dqxor783 xor -Inf -0 -> NaN Invalid_operation
-dqxor784 xor -Inf 0 -> NaN Invalid_operation
-dqxor785 xor -Inf 1 -> NaN Invalid_operation
-dqxor786 xor -Inf 1000 -> NaN Invalid_operation
-dqxor787 xor -1000 -Inf -> NaN Invalid_operation
-dqxor788 xor -Inf -Inf -> NaN Invalid_operation
-dqxor789 xor -1 -Inf -> NaN Invalid_operation
-dqxor790 xor -0 -Inf -> NaN Invalid_operation
-dqxor791 xor 0 -Inf -> NaN Invalid_operation
-dqxor792 xor 1 -Inf -> NaN Invalid_operation
-dqxor793 xor 1000 -Inf -> NaN Invalid_operation
-dqxor794 xor Inf -Inf -> NaN Invalid_operation
-
-dqxor800 xor Inf -Inf -> NaN Invalid_operation
-dqxor801 xor Inf -1000 -> NaN Invalid_operation
-dqxor802 xor Inf -1 -> NaN Invalid_operation
-dqxor803 xor Inf -0 -> NaN Invalid_operation
-dqxor804 xor Inf 0 -> NaN Invalid_operation
-dqxor805 xor Inf 1 -> NaN Invalid_operation
-dqxor806 xor Inf 1000 -> NaN Invalid_operation
-dqxor807 xor Inf Inf -> NaN Invalid_operation
-dqxor808 xor -1000 Inf -> NaN Invalid_operation
-dqxor809 xor -Inf Inf -> NaN Invalid_operation
-dqxor810 xor -1 Inf -> NaN Invalid_operation
-dqxor811 xor -0 Inf -> NaN Invalid_operation
-dqxor812 xor 0 Inf -> NaN Invalid_operation
-dqxor813 xor 1 Inf -> NaN Invalid_operation
-dqxor814 xor 1000 Inf -> NaN Invalid_operation
-dqxor815 xor Inf Inf -> NaN Invalid_operation
-
-dqxor821 xor NaN -Inf -> NaN Invalid_operation
-dqxor822 xor NaN -1000 -> NaN Invalid_operation
-dqxor823 xor NaN -1 -> NaN Invalid_operation
-dqxor824 xor NaN -0 -> NaN Invalid_operation
-dqxor825 xor NaN 0 -> NaN Invalid_operation
-dqxor826 xor NaN 1 -> NaN Invalid_operation
-dqxor827 xor NaN 1000 -> NaN Invalid_operation
-dqxor828 xor NaN Inf -> NaN Invalid_operation
-dqxor829 xor NaN NaN -> NaN Invalid_operation
-dqxor830 xor -Inf NaN -> NaN Invalid_operation
-dqxor831 xor -1000 NaN -> NaN Invalid_operation
-dqxor832 xor -1 NaN -> NaN Invalid_operation
-dqxor833 xor -0 NaN -> NaN Invalid_operation
-dqxor834 xor 0 NaN -> NaN Invalid_operation
-dqxor835 xor 1 NaN -> NaN Invalid_operation
-dqxor836 xor 1000 NaN -> NaN Invalid_operation
-dqxor837 xor Inf NaN -> NaN Invalid_operation
-
-dqxor841 xor sNaN -Inf -> NaN Invalid_operation
-dqxor842 xor sNaN -1000 -> NaN Invalid_operation
-dqxor843 xor sNaN -1 -> NaN Invalid_operation
-dqxor844 xor sNaN -0 -> NaN Invalid_operation
-dqxor845 xor sNaN 0 -> NaN Invalid_operation
-dqxor846 xor sNaN 1 -> NaN Invalid_operation
-dqxor847 xor sNaN 1000 -> NaN Invalid_operation
-dqxor848 xor sNaN NaN -> NaN Invalid_operation
-dqxor849 xor sNaN sNaN -> NaN Invalid_operation
-dqxor850 xor NaN sNaN -> NaN Invalid_operation
-dqxor851 xor -Inf sNaN -> NaN Invalid_operation
-dqxor852 xor -1000 sNaN -> NaN Invalid_operation
-dqxor853 xor -1 sNaN -> NaN Invalid_operation
-dqxor854 xor -0 sNaN -> NaN Invalid_operation
-dqxor855 xor 0 sNaN -> NaN Invalid_operation
-dqxor856 xor 1 sNaN -> NaN Invalid_operation
-dqxor857 xor 1000 sNaN -> NaN Invalid_operation
-dqxor858 xor Inf sNaN -> NaN Invalid_operation
-dqxor859 xor NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqxor861 xor NaN1 -Inf -> NaN Invalid_operation
-dqxor862 xor +NaN2 -1000 -> NaN Invalid_operation
-dqxor863 xor NaN3 1000 -> NaN Invalid_operation
-dqxor864 xor NaN4 Inf -> NaN Invalid_operation
-dqxor865 xor NaN5 +NaN6 -> NaN Invalid_operation
-dqxor866 xor -Inf NaN7 -> NaN Invalid_operation
-dqxor867 xor -1000 NaN8 -> NaN Invalid_operation
-dqxor868 xor 1000 NaN9 -> NaN Invalid_operation
-dqxor869 xor Inf +NaN10 -> NaN Invalid_operation
-dqxor871 xor sNaN11 -Inf -> NaN Invalid_operation
-dqxor872 xor sNaN12 -1000 -> NaN Invalid_operation
-dqxor873 xor sNaN13 1000 -> NaN Invalid_operation
-dqxor874 xor sNaN14 NaN17 -> NaN Invalid_operation
-dqxor875 xor sNaN15 sNaN18 -> NaN Invalid_operation
-dqxor876 xor NaN16 sNaN19 -> NaN Invalid_operation
-dqxor877 xor -Inf +sNaN20 -> NaN Invalid_operation
-dqxor878 xor -1000 sNaN21 -> NaN Invalid_operation
-dqxor879 xor 1000 sNaN22 -> NaN Invalid_operation
-dqxor880 xor Inf sNaN23 -> NaN Invalid_operation
-dqxor881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
-dqxor882 xor -NaN26 NaN28 -> NaN Invalid_operation
-dqxor883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
-dqxor884 xor 1000 -NaN30 -> NaN Invalid_operation
-dqxor885 xor 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqXor.decTest -- digitwise logical XOR for decQuads --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check (truth table)
+dqxor001 xor 0 0 -> 0
+dqxor002 xor 0 1 -> 1
+dqxor003 xor 1 0 -> 1
+dqxor004 xor 1 1 -> 0
+dqxor005 xor 1100 1010 -> 110
+-- and at msd and msd-1
+dqxor006 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqxor007 xor 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqxor008 xor 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqxor009 xor 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 0
+dqxor010 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqxor011 xor 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
+dqxor012 xor 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 100000000000000000000000000000000
+dqxor013 xor 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 0
+
+-- Various lengths
+-- 1234567890123456789012345678901234
+dqxor601 xor 0111111111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000000000
+dqxor602 xor 1011111111111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000000000
+dqxor603 xor 1101111111111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000000000
+dqxor604 xor 1110111111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000000
+dqxor605 xor 1111011111111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000000
+dqxor606 xor 1111101111111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000000
+dqxor607 xor 1111110111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000
+dqxor608 xor 1111111011111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000
+dqxor609 xor 1111111101111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000
+dqxor610 xor 1111111110111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000
+dqxor611 xor 1111111111011111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000
+dqxor612 xor 1111111111101111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000
+dqxor613 xor 1111111111110111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000
+dqxor614 xor 1111111111111011111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000
+dqxor615 xor 1111111111111101111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000
+dqxor616 xor 1111111111111110111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000
+dqxor617 xor 1111111111111111011111111111111111 1111111111111111111111111111111111 -> 100000000000000000
+dqxor618 xor 1111111111111111101111111111111111 1111111111111111111111111111111111 -> 10000000000000000
+dqxor619 xor 1111111111111111110111111111111111 1111111111111111111111111111111111 -> 1000000000000000
+dqxor620 xor 1111111111111111111011111111111111 1111111111111111111111111111111111 -> 100000000000000
+dqxor621 xor 1111111111111111111101111111111111 1111111111111111111111111111111111 -> 10000000000000
+dqxor622 xor 1111111111111111111110111111111111 1111111111111111111111111111111111 -> 1000000000000
+dqxor623 xor 1111111111111111111111011111111111 1111111111111111111111111111111111 -> 100000000000
+dqxor624 xor 1111111111111111111111101111111111 1111111111111111111111111111111111 -> 10000000000
+dqxor625 xor 1111111111111111111111110111111111 1111111111111111111111111111111111 -> 1000000000
+dqxor626 xor 1111111111111111111111111011111111 1111111111111111111111111111111111 -> 100000000
+dqxor627 xor 1111111111111111111111111101111111 1111111111111111111111111111111111 -> 10000000
+dqxor628 xor 1111111111111111111111111110111111 1111111111111111111111111111111111 -> 1000000
+dqxor629 xor 1111111111111111111111111111011111 1111111111111111111111111111111111 -> 100000
+dqxor630 xor 1111111111111111111111111111101111 1111111111111111111111111111111111 -> 10000
+dqxor631 xor 1111111111111111111111111111110111 1111111111111111111111111111111111 -> 1000
+dqxor632 xor 1111111111111111111111111111111011 1111111111111111111111111111111111 -> 100
+dqxor633 xor 1111111111111111111111111111111101 1111111111111111111111111111111111 -> 10
+dqxor634 xor 1111111111111111111111111111111110 1111111111111111111111111111111111 -> 1
+
+dqxor641 xor 1111111111111111111111111111111111 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
+dqxor642 xor 1111111111111111111111111111111111 1011111111111111111111111111111111 -> 100000000000000000000000000000000
+dqxor643 xor 1111111111111111111111111111111111 1101111111111111111111111111111111 -> 10000000000000000000000000000000
+dqxor644 xor 1111111111111111111111111111111111 1110111111111111111111111111111111 -> 1000000000000000000000000000000
+dqxor645 xor 1111111111111111111111111111111111 1111011111111111111111111111111111 -> 100000000000000000000000000000
+dqxor646 xor 1111111111111111111111111111111111 1111101111111111111111111111111111 -> 10000000000000000000000000000
+dqxor647 xor 1111111111111111111111111111111111 1111110111111111111111111111111111 -> 1000000000000000000000000000
+dqxor648 xor 1111111111111111111111111111111111 1111111011111111111111111111111111 -> 100000000000000000000000000
+dqxor649 xor 1111111111111111111111111111111111 1111111101111111111111111111111111 -> 10000000000000000000000000
+dqxor650 xor 1111111111111111111111111111111111 1111111110111111111111111111111111 -> 1000000000000000000000000
+dqxor651 xor 1111111111111111111111111111111111 1111111111011111111111111111111111 -> 100000000000000000000000
+dqxor652 xor 1111111111111111111111111111111111 1111111111101111111111111111111111 -> 10000000000000000000000
+dqxor653 xor 1111111111111111111111111111111111 1111111111110111111111111111111111 -> 1000000000000000000000
+dqxor654 xor 1111111111111111111111111111111111 1111111111111011111111111111111111 -> 100000000000000000000
+dqxor655 xor 1111111111111111111111111111111111 1111111111111101111111111111111111 -> 10000000000000000000
+dqxor656 xor 1111111111111111111111111111111111 1111111111111110111111111111111111 -> 1000000000000000000
+dqxor657 xor 1111111111111111111111111111111111 1111111111111111011111111111111111 -> 100000000000000000
+dqxor658 xor 1111111111111111111111111111111111 1111111111111111101111111111111111 -> 10000000000000000
+dqxor659 xor 1111111111111111111111111111111111 1111111111111111110111111111111111 -> 1000000000000000
+dqxor660 xor 1111111111111111111111111111111111 1111111111111111111011111111111111 -> 100000000000000
+dqxor661 xor 1111111111111111111111111111111111 1111111111111111111101111111111111 -> 10000000000000
+dqxor662 xor 1111111111111111111111111111111111 1111111111111111111110111111111111 -> 1000000000000
+dqxor663 xor 1111111111111111111111111111111111 1111111111111111111111011111111111 -> 100000000000
+dqxor664 xor 1111111111111111111111111111111111 1111111111111111111111101111111111 -> 10000000000
+dqxor665 xor 1111111111111111111111111111111111 1111111111111111111111110111111111 -> 1000000000
+dqxor666 xor 1111111111111111111111111111111111 1111111111111111111111111011111111 -> 100000000
+dqxor667 xor 1111111111111111111111111111111111 1111111111111111111111111101111111 -> 10000000
+dqxor668 xor 1111111111111111111111111111111111 1111111111111111111111111110111111 -> 1000000
+dqxor669 xor 1111111111111111111111111111111111 1111111111111111111111111111011111 -> 100000
+dqxor670 xor 1111111111111111111111111111111111 1111111111111111111111111111101111 -> 10000
+dqxor671 xor 1111111111111111111111111111111111 1111111111111111111111111111110111 -> 1000
+dqxor672 xor 1111111111111111111111111111111111 1111111111111111111111111111111011 -> 100
+dqxor673 xor 1111111111111111111111111111111111 1111111111111111111111111111111101 -> 10
+dqxor674 xor 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1
+dqxor675 xor 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1000000000000000000000000000000001
+dqxor676 xor 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1
+
+
+dqxor021 xor 1111111110000000 1111111110000000 -> 0
+dqxor022 xor 111111110000000 111111110000000 -> 0
+dqxor023 xor 11111110000000 11111110000000 -> 0
+dqxor024 xor 1111110000000 1111110000000 -> 0
+dqxor025 xor 111110000000 111110000000 -> 0
+dqxor026 xor 11110000000 11110000000 -> 0
+dqxor027 xor 1110000000 1110000000 -> 0
+dqxor028 xor 110000000 110000000 -> 0
+dqxor029 xor 10000000 10000000 -> 0
+dqxor030 xor 1000000 1000000 -> 0
+dqxor031 xor 100000 100000 -> 0
+dqxor032 xor 10000 10000 -> 0
+dqxor033 xor 1000 1000 -> 0
+dqxor034 xor 100 100 -> 0
+dqxor035 xor 10 10 -> 0
+dqxor036 xor 1 1 -> 0
+
+dqxor040 xor 111111111 111111111111 -> 111000000000
+dqxor041 xor 11111111 111111111111 -> 111100000000
+dqxor042 xor 11111111 111111111 -> 100000000
+dqxor043 xor 1111111 100000010 -> 101111101
+dqxor044 xor 111111 100000100 -> 100111011
+dqxor045 xor 11111 100001000 -> 100010111
+dqxor046 xor 1111 100010000 -> 100011111
+dqxor047 xor 111 100100000 -> 100100111
+dqxor048 xor 11 101000000 -> 101000011
+dqxor049 xor 1 110000000 -> 110000001
+
+dqxor050 xor 1111111111 1 -> 1111111110
+dqxor051 xor 111111111 1 -> 111111110
+dqxor052 xor 11111111 1 -> 11111110
+dqxor053 xor 1111111 1 -> 1111110
+dqxor054 xor 111111 1 -> 111110
+dqxor055 xor 11111 1 -> 11110
+dqxor056 xor 1111 1 -> 1110
+dqxor057 xor 111 1 -> 110
+dqxor058 xor 11 1 -> 10
+dqxor059 xor 1 1 -> 0
+
+dqxor060 xor 1111111111 0 -> 1111111111
+dqxor061 xor 111111111 0 -> 111111111
+dqxor062 xor 11111111 0 -> 11111111
+dqxor063 xor 1111111 0 -> 1111111
+dqxor064 xor 111111 0 -> 111111
+dqxor065 xor 11111 0 -> 11111
+dqxor066 xor 1111 0 -> 1111
+dqxor067 xor 111 0 -> 111
+dqxor068 xor 11 0 -> 11
+dqxor069 xor 1 0 -> 1
+
+dqxor070 xor 1 1111111111 -> 1111111110
+dqxor071 xor 1 111111111 -> 111111110
+dqxor072 xor 1 11111111 -> 11111110
+dqxor073 xor 1 1111111 -> 1111110
+dqxor074 xor 1 111111 -> 111110
+dqxor075 xor 1 11111 -> 11110
+dqxor076 xor 1 1111 -> 1110
+dqxor077 xor 1 111 -> 110
+dqxor078 xor 1 11 -> 10
+dqxor079 xor 1 1 -> 0
+
+dqxor080 xor 0 1111111111 -> 1111111111
+dqxor081 xor 0 111111111 -> 111111111
+dqxor082 xor 0 11111111 -> 11111111
+dqxor083 xor 0 1111111 -> 1111111
+dqxor084 xor 0 111111 -> 111111
+dqxor085 xor 0 11111 -> 11111
+dqxor086 xor 0 1111 -> 1111
+dqxor087 xor 0 111 -> 111
+dqxor088 xor 0 11 -> 11
+dqxor089 xor 0 1 -> 1
+
+dqxor090 xor 011111111 111101111 -> 100010000
+dqxor091 xor 101111111 111101111 -> 10010000
+dqxor092 xor 110111111 111101111 -> 1010000
+dqxor093 xor 111011111 111101111 -> 110000
+dqxor094 xor 111101111 111101111 -> 0
+dqxor095 xor 111110111 111101111 -> 11000
+dqxor096 xor 111111011 111101111 -> 10100
+dqxor097 xor 111111101 111101111 -> 10010
+dqxor098 xor 111111110 111101111 -> 10001
+
+dqxor100 xor 111101111 011111111 -> 100010000
+dqxor101 xor 111101111 101111111 -> 10010000
+dqxor102 xor 111101111 110111111 -> 1010000
+dqxor103 xor 111101111 111011111 -> 110000
+dqxor104 xor 111101111 111101111 -> 0
+dqxor105 xor 111101111 111110111 -> 11000
+dqxor106 xor 111101111 111111011 -> 10100
+dqxor107 xor 111101111 111111101 -> 10010
+dqxor108 xor 111101111 111111110 -> 10001
+
+-- non-0/1 should not be accepted, nor should signs
+dqxor220 xor 111111112 111111111 -> NaN Invalid_operation
+dqxor221 xor 333333333 333333333 -> NaN Invalid_operation
+dqxor222 xor 555555555 555555555 -> NaN Invalid_operation
+dqxor223 xor 777777777 777777777 -> NaN Invalid_operation
+dqxor224 xor 999999999 999999999 -> NaN Invalid_operation
+dqxor225 xor 222222222 999999999 -> NaN Invalid_operation
+dqxor226 xor 444444444 999999999 -> NaN Invalid_operation
+dqxor227 xor 666666666 999999999 -> NaN Invalid_operation
+dqxor228 xor 888888888 999999999 -> NaN Invalid_operation
+dqxor229 xor 999999999 222222222 -> NaN Invalid_operation
+dqxor230 xor 999999999 444444444 -> NaN Invalid_operation
+dqxor231 xor 999999999 666666666 -> NaN Invalid_operation
+dqxor232 xor 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+dqxor240 xor 567468689 -934981942 -> NaN Invalid_operation
+dqxor241 xor 567367689 934981942 -> NaN Invalid_operation
+dqxor242 xor -631917772 -706014634 -> NaN Invalid_operation
+dqxor243 xor -756253257 138579234 -> NaN Invalid_operation
+dqxor244 xor 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+dqxor250 xor 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor251 xor 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor252 xor 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor253 xor 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor254 xor 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor255 xor 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor256 xor 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor257 xor 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor258 xor 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor259 xor 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor260 xor 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor261 xor 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor262 xor 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor263 xor 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor264 xor 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor265 xor 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+-- test MSD-1
+dqxor270 xor 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
+dqxor271 xor 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
+dqxor272 xor 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
+dqxor273 xor 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
+dqxor274 xor 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
+dqxor275 xor 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
+dqxor276 xor 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
+dqxor277 xor 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
+-- test LSD
+dqxor280 xor 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
+dqxor281 xor 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
+dqxor282 xor 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
+dqxor283 xor 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
+dqxor284 xor 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
+dqxor285 xor 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
+dqxor286 xor 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
+dqxor287 xor 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
+-- test Middie
+dqxor288 xor 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
+dqxor289 xor 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
+dqxor290 xor 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
+dqxor291 xor 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
+dqxor292 xor 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
+dqxor293 xor 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
+dqxor294 xor 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
+dqxor295 xor 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
+-- signs
+dqxor296 xor -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
+dqxor297 xor -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
+dqxor298 xor 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
+dqxor299 xor 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 1000001001001001001001000010000100
+
+-- Nmax, Nmin, Ntiny-like
+dqxor331 xor 2 9.99999999E+999 -> NaN Invalid_operation
+dqxor332 xor 3 1E-999 -> NaN Invalid_operation
+dqxor333 xor 4 1.00000000E-2821 -> NaN Invalid_operation
+dqxor334 xor 5 1E-900 -> NaN Invalid_operation
+dqxor335 xor 6 -1E-900 -> NaN Invalid_operation
+dqxor336 xor 7 -1.00000000E-999 -> NaN Invalid_operation
+dqxor337 xor 8 -1E-999 -> NaN Invalid_operation
+dqxor338 xor 9 -9.99999999E+999 -> NaN Invalid_operation
+dqxor341 xor 9.99999999E+999 -18 -> NaN Invalid_operation
+dqxor342 xor 1E-999 01 -> NaN Invalid_operation
+dqxor343 xor 1.00000000E-999 -18 -> NaN Invalid_operation
+dqxor344 xor 1E-908 18 -> NaN Invalid_operation
+dqxor345 xor -1E-907 -10 -> NaN Invalid_operation
+dqxor346 xor -1.00000000E-999 18 -> NaN Invalid_operation
+dqxor347 xor -1E-999 10 -> NaN Invalid_operation
+dqxor348 xor -9.99999999E+2991 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+dqxor361 xor 1.0 1 -> NaN Invalid_operation
+dqxor362 xor 1E+1 1 -> NaN Invalid_operation
+dqxor363 xor 0.0 1 -> NaN Invalid_operation
+dqxor364 xor 0E+1 1 -> NaN Invalid_operation
+dqxor365 xor 9.9 1 -> NaN Invalid_operation
+dqxor366 xor 9E+1 1 -> NaN Invalid_operation
+dqxor371 xor 0 1.0 -> NaN Invalid_operation
+dqxor372 xor 0 1E+1 -> NaN Invalid_operation
+dqxor373 xor 0 0.0 -> NaN Invalid_operation
+dqxor374 xor 0 0E+1 -> NaN Invalid_operation
+dqxor375 xor 0 9.9 -> NaN Invalid_operation
+dqxor376 xor 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+dqxor780 xor -Inf -Inf -> NaN Invalid_operation
+dqxor781 xor -Inf -1000 -> NaN Invalid_operation
+dqxor782 xor -Inf -1 -> NaN Invalid_operation
+dqxor783 xor -Inf -0 -> NaN Invalid_operation
+dqxor784 xor -Inf 0 -> NaN Invalid_operation
+dqxor785 xor -Inf 1 -> NaN Invalid_operation
+dqxor786 xor -Inf 1000 -> NaN Invalid_operation
+dqxor787 xor -1000 -Inf -> NaN Invalid_operation
+dqxor788 xor -Inf -Inf -> NaN Invalid_operation
+dqxor789 xor -1 -Inf -> NaN Invalid_operation
+dqxor790 xor -0 -Inf -> NaN Invalid_operation
+dqxor791 xor 0 -Inf -> NaN Invalid_operation
+dqxor792 xor 1 -Inf -> NaN Invalid_operation
+dqxor793 xor 1000 -Inf -> NaN Invalid_operation
+dqxor794 xor Inf -Inf -> NaN Invalid_operation
+
+dqxor800 xor Inf -Inf -> NaN Invalid_operation
+dqxor801 xor Inf -1000 -> NaN Invalid_operation
+dqxor802 xor Inf -1 -> NaN Invalid_operation
+dqxor803 xor Inf -0 -> NaN Invalid_operation
+dqxor804 xor Inf 0 -> NaN Invalid_operation
+dqxor805 xor Inf 1 -> NaN Invalid_operation
+dqxor806 xor Inf 1000 -> NaN Invalid_operation
+dqxor807 xor Inf Inf -> NaN Invalid_operation
+dqxor808 xor -1000 Inf -> NaN Invalid_operation
+dqxor809 xor -Inf Inf -> NaN Invalid_operation
+dqxor810 xor -1 Inf -> NaN Invalid_operation
+dqxor811 xor -0 Inf -> NaN Invalid_operation
+dqxor812 xor 0 Inf -> NaN Invalid_operation
+dqxor813 xor 1 Inf -> NaN Invalid_operation
+dqxor814 xor 1000 Inf -> NaN Invalid_operation
+dqxor815 xor Inf Inf -> NaN Invalid_operation
+
+dqxor821 xor NaN -Inf -> NaN Invalid_operation
+dqxor822 xor NaN -1000 -> NaN Invalid_operation
+dqxor823 xor NaN -1 -> NaN Invalid_operation
+dqxor824 xor NaN -0 -> NaN Invalid_operation
+dqxor825 xor NaN 0 -> NaN Invalid_operation
+dqxor826 xor NaN 1 -> NaN Invalid_operation
+dqxor827 xor NaN 1000 -> NaN Invalid_operation
+dqxor828 xor NaN Inf -> NaN Invalid_operation
+dqxor829 xor NaN NaN -> NaN Invalid_operation
+dqxor830 xor -Inf NaN -> NaN Invalid_operation
+dqxor831 xor -1000 NaN -> NaN Invalid_operation
+dqxor832 xor -1 NaN -> NaN Invalid_operation
+dqxor833 xor -0 NaN -> NaN Invalid_operation
+dqxor834 xor 0 NaN -> NaN Invalid_operation
+dqxor835 xor 1 NaN -> NaN Invalid_operation
+dqxor836 xor 1000 NaN -> NaN Invalid_operation
+dqxor837 xor Inf NaN -> NaN Invalid_operation
+
+dqxor841 xor sNaN -Inf -> NaN Invalid_operation
+dqxor842 xor sNaN -1000 -> NaN Invalid_operation
+dqxor843 xor sNaN -1 -> NaN Invalid_operation
+dqxor844 xor sNaN -0 -> NaN Invalid_operation
+dqxor845 xor sNaN 0 -> NaN Invalid_operation
+dqxor846 xor sNaN 1 -> NaN Invalid_operation
+dqxor847 xor sNaN 1000 -> NaN Invalid_operation
+dqxor848 xor sNaN NaN -> NaN Invalid_operation
+dqxor849 xor sNaN sNaN -> NaN Invalid_operation
+dqxor850 xor NaN sNaN -> NaN Invalid_operation
+dqxor851 xor -Inf sNaN -> NaN Invalid_operation
+dqxor852 xor -1000 sNaN -> NaN Invalid_operation
+dqxor853 xor -1 sNaN -> NaN Invalid_operation
+dqxor854 xor -0 sNaN -> NaN Invalid_operation
+dqxor855 xor 0 sNaN -> NaN Invalid_operation
+dqxor856 xor 1 sNaN -> NaN Invalid_operation
+dqxor857 xor 1000 sNaN -> NaN Invalid_operation
+dqxor858 xor Inf sNaN -> NaN Invalid_operation
+dqxor859 xor NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqxor861 xor NaN1 -Inf -> NaN Invalid_operation
+dqxor862 xor +NaN2 -1000 -> NaN Invalid_operation
+dqxor863 xor NaN3 1000 -> NaN Invalid_operation
+dqxor864 xor NaN4 Inf -> NaN Invalid_operation
+dqxor865 xor NaN5 +NaN6 -> NaN Invalid_operation
+dqxor866 xor -Inf NaN7 -> NaN Invalid_operation
+dqxor867 xor -1000 NaN8 -> NaN Invalid_operation
+dqxor868 xor 1000 NaN9 -> NaN Invalid_operation
+dqxor869 xor Inf +NaN10 -> NaN Invalid_operation
+dqxor871 xor sNaN11 -Inf -> NaN Invalid_operation
+dqxor872 xor sNaN12 -1000 -> NaN Invalid_operation
+dqxor873 xor sNaN13 1000 -> NaN Invalid_operation
+dqxor874 xor sNaN14 NaN17 -> NaN Invalid_operation
+dqxor875 xor sNaN15 sNaN18 -> NaN Invalid_operation
+dqxor876 xor NaN16 sNaN19 -> NaN Invalid_operation
+dqxor877 xor -Inf +sNaN20 -> NaN Invalid_operation
+dqxor878 xor -1000 sNaN21 -> NaN Invalid_operation
+dqxor879 xor 1000 sNaN22 -> NaN Invalid_operation
+dqxor880 xor Inf sNaN23 -> NaN Invalid_operation
+dqxor881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
+dqxor882 xor -NaN26 NaN28 -> NaN Invalid_operation
+dqxor883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
+dqxor884 xor 1000 -NaN30 -> NaN Invalid_operation
+dqxor885 xor 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dsBase.decTest b/Lib/test/decimaltestdata/dsBase.decTest
index 5e5e5a5d91..8ac45fc552 100644
--- a/Lib/test/decimaltestdata/dsBase.decTest
+++ b/Lib/test/decimaltestdata/dsBase.decTest
@@ -1,1062 +1,1062 @@
-------------------------------------------------------------------------
--- dsBase.decTest -- base decSingle <--> string conversions --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests base conversions from string to a decimal number
--- and back to a string (in Scientific form)
-
--- Note that unlike other operations the operand is subject to rounding
--- to conform to emax and precision settings (that is, numbers will
--- conform to rules and exponent will be in permitted range). The
--- 'left hand side', therefore, may have numbers that cannot be
--- represented in a decSingle. Some testcases go to the limit of the
--- next-wider format, and hence these testcases may also be used to
--- test narrowing and widening operations.
-
-extended: 1
-clamp: 1
-precision: 7
-maxExponent: 96
-minExponent: -95
-rounding: half_even
-
-dsbas001 toSci 0 -> 0
-dsbas002 toSci 1 -> 1
-dsbas003 toSci 1.0 -> 1.0
-dsbas004 toSci 1.00 -> 1.00
-dsbas005 toSci 10 -> 10
-dsbas006 toSci 1000 -> 1000
-dsbas007 toSci 10.0 -> 10.0
-dsbas008 toSci 10.1 -> 10.1
-dsbas009 toSci 10.4 -> 10.4
-dsbas010 toSci 10.5 -> 10.5
-dsbas011 toSci 10.6 -> 10.6
-dsbas012 toSci 10.9 -> 10.9
-dsbas013 toSci 11.0 -> 11.0
-dsbas014 toSci 1.234 -> 1.234
-dsbas015 toSci 0.123 -> 0.123
-dsbas016 toSci 0.012 -> 0.012
-dsbas017 toSci -0 -> -0
-dsbas018 toSci -0.0 -> -0.0
-dsbas019 toSci -00.00 -> -0.00
-
-dsbas021 toSci -1 -> -1
-dsbas022 toSci -1.0 -> -1.0
-dsbas023 toSci -0.1 -> -0.1
-dsbas024 toSci -9.1 -> -9.1
-dsbas025 toSci -9.11 -> -9.11
-dsbas026 toSci -9.119 -> -9.119
-dsbas027 toSci -9.999 -> -9.999
-
-dsbas030 toSci '1234.567' -> '1234.567'
-dsbas031 toSci '1234.000' -> '1234.000'
-dsbas032 toSci '1234912' -> '1234912'
-dsbas033 toSci '0.00001234567' -> '0.00001234567'
-dsbas034 toSci '0.000001234567' -> '0.000001234567'
-dsbas035 toSci '0.0000001234567' -> '1.234567E-7'
-dsbas036 toSci '0.00000001234567' -> '1.234567E-8'
-
-dsbas037 toSci '0.1234564' -> '0.1234564'
-dsbas038 toSci '0.1234565' -> '0.1234565'
-
--- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
-dsbsn001 toSci -9.999999E+96 -> -9.999999E+96
-dsbsn002 toSci -1E-95 -> -1E-95
-dsbsn003 toSci -1E-101 -> -1E-101 Subnormal
-dsbsn004 toSci -0 -> -0
-dsbsn005 toSci +0 -> 0
-dsbsn006 toSci +1E-101 -> 1E-101 Subnormal
-dsbsn007 toSci +1E-95 -> 1E-95
-dsbsn008 toSci +9.999999E+96 -> 9.999999E+96
-
--- String [many more examples are implicitly tested elsewhere]
--- strings without E cannot generate E in result
-dsbas040 toSci "12" -> '12'
-dsbas041 toSci "-76" -> '-76'
-dsbas042 toSci "12.76" -> '12.76'
-dsbas043 toSci "+12.76" -> '12.76'
-dsbas044 toSci "012.76" -> '12.76'
-dsbas045 toSci "+0.003" -> '0.003'
-dsbas046 toSci "17." -> '17'
-dsbas047 toSci ".5" -> '0.5'
-dsbas048 toSci "044" -> '44'
-dsbas049 toSci "0044" -> '44'
-dsbas050 toSci "0.0005" -> '0.0005'
-dsbas051 toSci "00.00005" -> '0.00005'
-dsbas052 toSci "0.000005" -> '0.000005'
-dsbas053 toSci "0.0000050" -> '0.0000050'
-dsbas054 toSci "0.0000005" -> '5E-7'
-dsbas055 toSci "0.00000005" -> '5E-8'
-dsbas056 toSci "12678.54" -> '12678.54'
-dsbas057 toSci "2678.543" -> '2678.543'
-dsbas058 toSci "345678.5" -> '345678.5'
-dsbas059 toSci "0678.5432" -> '678.5432'
-dsbas060 toSci "678.5432" -> '678.5432'
-dsbas061 toSci "+678.5432" -> '678.5432'
-dsbas062 toSci "+0678.5432" -> '678.5432'
-dsbas063 toSci "+00678.5432" -> '678.5432'
-dsbas064 toSci "-678.5432" -> '-678.5432'
-dsbas065 toSci "-0678.5432" -> '-678.5432'
-dsbas066 toSci "-00678.5432" -> '-678.5432'
--- examples
-dsbas067 toSci "5E-6" -> '0.000005'
-dsbas068 toSci "50E-7" -> '0.0000050'
-dsbas069 toSci "5E-7" -> '5E-7'
-
--- [No exotics as no Unicode]
-
--- rounded with dots in all (including edge) places
-dsbas071 toSci .1234567890123456 -> 0.1234568 Inexact Rounded
-dsbas072 toSci 1.234567890123456 -> 1.234568 Inexact Rounded
-dsbas073 toSci 12.34567890123456 -> 12.34568 Inexact Rounded
-dsbas074 toSci 123.4567890123456 -> 123.4568 Inexact Rounded
-dsbas075 toSci 1234.567890123456 -> 1234.568 Inexact Rounded
-dsbas076 toSci 12345.67890123456 -> 12345.68 Inexact Rounded
-dsbas077 toSci 123456.7890123456 -> 123456.8 Inexact Rounded
-dsbas078 toSci 1234567.890123456 -> 1234568 Inexact Rounded
-dsbas079 toSci 12345678.90123456 -> 1.234568E+7 Inexact Rounded
-dsbas080 toSci 123456789.0123456 -> 1.234568E+8 Inexact Rounded
-dsbas081 toSci 1234567890.123456 -> 1.234568E+9 Inexact Rounded
-dsbas082 toSci 12345678901.23456 -> 1.234568E+10 Inexact Rounded
-dsbas083 toSci 123456789012.3456 -> 1.234568E+11 Inexact Rounded
-dsbas084 toSci 1234567890123.456 -> 1.234568E+12 Inexact Rounded
-dsbas085 toSci 12345678901234.56 -> 1.234568E+13 Inexact Rounded
-dsbas086 toSci 123456789012345.6 -> 1.234568E+14 Inexact Rounded
-dsbas087 toSci 1234567890123456. -> 1.234568E+15 Inexact Rounded
-dsbas088 toSci 1234567890123456 -> 1.234568E+15 Inexact Rounded
-
--- Numbers with E
-dsbas130 toSci "0.000E-1" -> '0.0000'
-dsbas131 toSci "0.000E-2" -> '0.00000'
-dsbas132 toSci "0.000E-3" -> '0.000000'
-dsbas133 toSci "0.000E-4" -> '0E-7'
-dsbas134 toSci "0.00E-2" -> '0.0000'
-dsbas135 toSci "0.00E-3" -> '0.00000'
-dsbas136 toSci "0.00E-4" -> '0.000000'
-dsbas137 toSci "0.00E-5" -> '0E-7'
-dsbas138 toSci "+0E+9" -> '0E+9'
-dsbas139 toSci "-0E+9" -> '-0E+9'
-dsbas140 toSci "1E+9" -> '1E+9'
-dsbas141 toSci "1e+09" -> '1E+9'
-dsbas142 toSci "1E+90" -> '1E+90'
-dsbas143 toSci "+1E+009" -> '1E+9'
-dsbas144 toSci "0E+9" -> '0E+9'
-dsbas145 toSci "1E+9" -> '1E+9'
-dsbas146 toSci "1E+09" -> '1E+9'
-dsbas147 toSci "1e+90" -> '1E+90'
-dsbas148 toSci "1E+009" -> '1E+9'
-dsbas149 toSci "000E+9" -> '0E+9'
-dsbas150 toSci "1E9" -> '1E+9'
-dsbas151 toSci "1e09" -> '1E+9'
-dsbas152 toSci "1E90" -> '1E+90'
-dsbas153 toSci "1E009" -> '1E+9'
-dsbas154 toSci "0E9" -> '0E+9'
-dsbas155 toSci "0.000e+0" -> '0.000'
-dsbas156 toSci "0.000E-1" -> '0.0000'
-dsbas157 toSci "4E+9" -> '4E+9'
-dsbas158 toSci "44E+9" -> '4.4E+10'
-dsbas159 toSci "0.73e-7" -> '7.3E-8'
-dsbas160 toSci "00E+9" -> '0E+9'
-dsbas161 toSci "00E-9" -> '0E-9'
-dsbas162 toSci "10E+9" -> '1.0E+10'
-dsbas163 toSci "10E+09" -> '1.0E+10'
-dsbas164 toSci "10e+90" -> '1.0E+91'
-dsbas165 toSci "10E+009" -> '1.0E+10'
-dsbas166 toSci "100e+9" -> '1.00E+11'
-dsbas167 toSci "100e+09" -> '1.00E+11'
-dsbas168 toSci "100E+90" -> '1.00E+92'
-dsbas169 toSci "100e+009" -> '1.00E+11'
-
-dsbas170 toSci "1.265" -> '1.265'
-dsbas171 toSci "1.265E-20" -> '1.265E-20'
-dsbas172 toSci "1.265E-8" -> '1.265E-8'
-dsbas173 toSci "1.265E-4" -> '0.0001265'
-dsbas174 toSci "1.265E-3" -> '0.001265'
-dsbas175 toSci "1.265E-2" -> '0.01265'
-dsbas176 toSci "1.265E-1" -> '0.1265'
-dsbas177 toSci "1.265E-0" -> '1.265'
-dsbas178 toSci "1.265E+1" -> '12.65'
-dsbas179 toSci "1.265E+2" -> '126.5'
-dsbas180 toSci "1.265E+3" -> '1265'
-dsbas181 toSci "1.265E+4" -> '1.265E+4'
-dsbas182 toSci "1.265E+8" -> '1.265E+8'
-dsbas183 toSci "1.265E+20" -> '1.265E+20'
-
-dsbas190 toSci "12.65" -> '12.65'
-dsbas191 toSci "12.65E-20" -> '1.265E-19'
-dsbas192 toSci "12.65E-8" -> '1.265E-7'
-dsbas193 toSci "12.65E-4" -> '0.001265'
-dsbas194 toSci "12.65E-3" -> '0.01265'
-dsbas195 toSci "12.65E-2" -> '0.1265'
-dsbas196 toSci "12.65E-1" -> '1.265'
-dsbas197 toSci "12.65E-0" -> '12.65'
-dsbas198 toSci "12.65E+1" -> '126.5'
-dsbas199 toSci "12.65E+2" -> '1265'
-dsbas200 toSci "12.65E+3" -> '1.265E+4'
-dsbas201 toSci "12.65E+4" -> '1.265E+5'
-dsbas202 toSci "12.65E+8" -> '1.265E+9'
-dsbas203 toSci "12.65E+20" -> '1.265E+21'
-
-dsbas210 toSci "126.5" -> '126.5'
-dsbas211 toSci "126.5E-20" -> '1.265E-18'
-dsbas212 toSci "126.5E-8" -> '0.000001265'
-dsbas213 toSci "126.5E-4" -> '0.01265'
-dsbas214 toSci "126.5E-3" -> '0.1265'
-dsbas215 toSci "126.5E-2" -> '1.265'
-dsbas216 toSci "126.5E-1" -> '12.65'
-dsbas217 toSci "126.5E-0" -> '126.5'
-dsbas218 toSci "126.5E+1" -> '1265'
-dsbas219 toSci "126.5E+2" -> '1.265E+4'
-dsbas220 toSci "126.5E+3" -> '1.265E+5'
-dsbas221 toSci "126.5E+4" -> '1.265E+6'
-dsbas222 toSci "126.5E+8" -> '1.265E+10'
-dsbas223 toSci "126.5E+20" -> '1.265E+22'
-
-dsbas230 toSci "1265" -> '1265'
-dsbas231 toSci "1265E-20" -> '1.265E-17'
-dsbas232 toSci "1265E-8" -> '0.00001265'
-dsbas233 toSci "1265E-4" -> '0.1265'
-dsbas234 toSci "1265E-3" -> '1.265'
-dsbas235 toSci "1265E-2" -> '12.65'
-dsbas236 toSci "1265E-1" -> '126.5'
-dsbas237 toSci "1265E-0" -> '1265'
-dsbas238 toSci "1265E+1" -> '1.265E+4'
-dsbas239 toSci "1265E+2" -> '1.265E+5'
-dsbas240 toSci "1265E+3" -> '1.265E+6'
-dsbas241 toSci "1265E+4" -> '1.265E+7'
-dsbas242 toSci "1265E+8" -> '1.265E+11'
-dsbas243 toSci "1265E+20" -> '1.265E+23'
-
-dsbas250 toSci "0.1265" -> '0.1265'
-dsbas251 toSci "0.1265E-20" -> '1.265E-21'
-dsbas252 toSci "0.1265E-8" -> '1.265E-9'
-dsbas253 toSci "0.1265E-4" -> '0.00001265'
-dsbas254 toSci "0.1265E-3" -> '0.0001265'
-dsbas255 toSci "0.1265E-2" -> '0.001265'
-dsbas256 toSci "0.1265E-1" -> '0.01265'
-dsbas257 toSci "0.1265E-0" -> '0.1265'
-dsbas258 toSci "0.1265E+1" -> '1.265'
-dsbas259 toSci "0.1265E+2" -> '12.65'
-dsbas260 toSci "0.1265E+3" -> '126.5'
-dsbas261 toSci "0.1265E+4" -> '1265'
-dsbas262 toSci "0.1265E+8" -> '1.265E+7'
-dsbas263 toSci "0.1265E+20" -> '1.265E+19'
-
--- some more negative zeros [systematic tests below]
-dsbas290 toSci "-0.000E-1" -> '-0.0000'
-dsbas291 toSci "-0.000E-2" -> '-0.00000'
-dsbas292 toSci "-0.000E-3" -> '-0.000000'
-dsbas293 toSci "-0.000E-4" -> '-0E-7'
-dsbas294 toSci "-0.00E-2" -> '-0.0000'
-dsbas295 toSci "-0.00E-3" -> '-0.00000'
-dsbas296 toSci "-0.0E-2" -> '-0.000'
-dsbas297 toSci "-0.0E-3" -> '-0.0000'
-dsbas298 toSci "-0E-2" -> '-0.00'
-dsbas299 toSci "-0E-3" -> '-0.000'
-
--- Engineering notation tests
-dsbas301 toSci 10e12 -> 1.0E+13
-dsbas302 toEng 10e12 -> 10E+12
-dsbas303 toSci 10e11 -> 1.0E+12
-dsbas304 toEng 10e11 -> 1.0E+12
-dsbas305 toSci 10e10 -> 1.0E+11
-dsbas306 toEng 10e10 -> 100E+9
-dsbas307 toSci 10e9 -> 1.0E+10
-dsbas308 toEng 10e9 -> 10E+9
-dsbas309 toSci 10e8 -> 1.0E+9
-dsbas310 toEng 10e8 -> 1.0E+9
-dsbas311 toSci 10e7 -> 1.0E+8
-dsbas312 toEng 10e7 -> 100E+6
-dsbas313 toSci 10e6 -> 1.0E+7
-dsbas314 toEng 10e6 -> 10E+6
-dsbas315 toSci 10e5 -> 1.0E+6
-dsbas316 toEng 10e5 -> 1.0E+6
-dsbas317 toSci 10e4 -> 1.0E+5
-dsbas318 toEng 10e4 -> 100E+3
-dsbas319 toSci 10e3 -> 1.0E+4
-dsbas320 toEng 10e3 -> 10E+3
-dsbas321 toSci 10e2 -> 1.0E+3
-dsbas322 toEng 10e2 -> 1.0E+3
-dsbas323 toSci 10e1 -> 1.0E+2
-dsbas324 toEng 10e1 -> 100
-dsbas325 toSci 10e0 -> 10
-dsbas326 toEng 10e0 -> 10
-dsbas327 toSci 10e-1 -> 1.0
-dsbas328 toEng 10e-1 -> 1.0
-dsbas329 toSci 10e-2 -> 0.10
-dsbas330 toEng 10e-2 -> 0.10
-dsbas331 toSci 10e-3 -> 0.010
-dsbas332 toEng 10e-3 -> 0.010
-dsbas333 toSci 10e-4 -> 0.0010
-dsbas334 toEng 10e-4 -> 0.0010
-dsbas335 toSci 10e-5 -> 0.00010
-dsbas336 toEng 10e-5 -> 0.00010
-dsbas337 toSci 10e-6 -> 0.000010
-dsbas338 toEng 10e-6 -> 0.000010
-dsbas339 toSci 10e-7 -> 0.0000010
-dsbas340 toEng 10e-7 -> 0.0000010
-dsbas341 toSci 10e-8 -> 1.0E-7
-dsbas342 toEng 10e-8 -> 100E-9
-dsbas343 toSci 10e-9 -> 1.0E-8
-dsbas344 toEng 10e-9 -> 10E-9
-dsbas345 toSci 10e-10 -> 1.0E-9
-dsbas346 toEng 10e-10 -> 1.0E-9
-dsbas347 toSci 10e-11 -> 1.0E-10
-dsbas348 toEng 10e-11 -> 100E-12
-dsbas349 toSci 10e-12 -> 1.0E-11
-dsbas350 toEng 10e-12 -> 10E-12
-dsbas351 toSci 10e-13 -> 1.0E-12
-dsbas352 toEng 10e-13 -> 1.0E-12
-
-dsbas361 toSci 7E12 -> 7E+12
-dsbas362 toEng 7E12 -> 7E+12
-dsbas363 toSci 7E11 -> 7E+11
-dsbas364 toEng 7E11 -> 700E+9
-dsbas365 toSci 7E10 -> 7E+10
-dsbas366 toEng 7E10 -> 70E+9
-dsbas367 toSci 7E9 -> 7E+9
-dsbas368 toEng 7E9 -> 7E+9
-dsbas369 toSci 7E8 -> 7E+8
-dsbas370 toEng 7E8 -> 700E+6
-dsbas371 toSci 7E7 -> 7E+7
-dsbas372 toEng 7E7 -> 70E+6
-dsbas373 toSci 7E6 -> 7E+6
-dsbas374 toEng 7E6 -> 7E+6
-dsbas375 toSci 7E5 -> 7E+5
-dsbas376 toEng 7E5 -> 700E+3
-dsbas377 toSci 7E4 -> 7E+4
-dsbas378 toEng 7E4 -> 70E+3
-dsbas379 toSci 7E3 -> 7E+3
-dsbas380 toEng 7E3 -> 7E+3
-dsbas381 toSci 7E2 -> 7E+2
-dsbas382 toEng 7E2 -> 700
-dsbas383 toSci 7E1 -> 7E+1
-dsbas384 toEng 7E1 -> 70
-dsbas385 toSci 7E0 -> 7
-dsbas386 toEng 7E0 -> 7
-dsbas387 toSci 7E-1 -> 0.7
-dsbas388 toEng 7E-1 -> 0.7
-dsbas389 toSci 7E-2 -> 0.07
-dsbas390 toEng 7E-2 -> 0.07
-dsbas391 toSci 7E-3 -> 0.007
-dsbas392 toEng 7E-3 -> 0.007
-dsbas393 toSci 7E-4 -> 0.0007
-dsbas394 toEng 7E-4 -> 0.0007
-dsbas395 toSci 7E-5 -> 0.00007
-dsbas396 toEng 7E-5 -> 0.00007
-dsbas397 toSci 7E-6 -> 0.000007
-dsbas398 toEng 7E-6 -> 0.000007
-dsbas399 toSci 7E-7 -> 7E-7
-dsbas400 toEng 7E-7 -> 700E-9
-dsbas401 toSci 7E-8 -> 7E-8
-dsbas402 toEng 7E-8 -> 70E-9
-dsbas403 toSci 7E-9 -> 7E-9
-dsbas404 toEng 7E-9 -> 7E-9
-dsbas405 toSci 7E-10 -> 7E-10
-dsbas406 toEng 7E-10 -> 700E-12
-dsbas407 toSci 7E-11 -> 7E-11
-dsbas408 toEng 7E-11 -> 70E-12
-dsbas409 toSci 7E-12 -> 7E-12
-dsbas410 toEng 7E-12 -> 7E-12
-dsbas411 toSci 7E-13 -> 7E-13
-dsbas412 toEng 7E-13 -> 700E-15
-
--- Exacts remain exact up to precision ..
-dsbas420 toSci 100 -> 100
-dsbas422 toSci 1000 -> 1000
-dsbas424 toSci 999.9 -> 999.9
-dsbas426 toSci 1000.0 -> 1000.0
-dsbas428 toSci 1000.1 -> 1000.1
-dsbas430 toSci 10000 -> 10000
-dsbas432 toSci 1000 -> 1000
-dsbas434 toSci 10000 -> 10000
-dsbas436 toSci 100000 -> 100000
-dsbas438 toSci 1000000 -> 1000000
-dsbas440 toSci 10000000 -> 1.000000E+7 Rounded
-dsbas442 toSci 10000000 -> 1.000000E+7 Rounded
-dsbas444 toSci 10000003 -> 1.000000E+7 Rounded Inexact
-dsbas446 toSci 10000005 -> 1.000000E+7 Rounded Inexact
-dsbas448 toSci 100000050 -> 1.000000E+8 Rounded Inexact
-dsbas450 toSci 10000009 -> 1.000001E+7 Rounded Inexact
-dsbas452 toSci 100000000 -> 1.000000E+8 Rounded
-dsbas454 toSci 100000003 -> 1.000000E+8 Rounded Inexact
-dsbas456 toSci 100000005 -> 1.000000E+8 Rounded Inexact
-dsbas458 toSci 100000009 -> 1.000000E+8 Rounded Inexact
-dsbas460 toSci 1000000000 -> 1.000000E+9 Rounded
-dsbas462 toSci 1000000300 -> 1.000000E+9 Rounded Inexact
-dsbas464 toSci 1000000500 -> 1.000000E+9 Rounded Inexact
-dsbas466 toSci 1000000900 -> 1.000001E+9 Rounded Inexact
-dsbas468 toSci 10000000000 -> 1.000000E+10 Rounded
-dsbas470 toSci 10000003000 -> 1.000000E+10 Rounded Inexact
-dsbas472 toSci 10000005000 -> 1.000000E+10 Rounded Inexact
-dsbas474 toSci 10000009000 -> 1.000001E+10 Rounded Inexact
-
--- check rounding modes heeded
-rounding: ceiling
-dsbsr401 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr402 toSci 1.11234549 -> 1.112346 Rounded Inexact
-dsbsr403 toSci 1.11234550 -> 1.112346 Rounded Inexact
-dsbsr404 toSci 1.11234551 -> 1.112346 Rounded Inexact
-rounding: up
-dsbsr405 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr406 toSci 1.11234549 -> 1.112346 Rounded Inexact
-dsbsr407 toSci 1.11234550 -> 1.112346 Rounded Inexact
-dsbsr408 toSci 1.11234551 -> 1.112346 Rounded Inexact
-rounding: floor
-dsbsr410 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr411 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr412 toSci 1.11234550 -> 1.112345 Rounded Inexact
-dsbsr413 toSci 1.11234551 -> 1.112345 Rounded Inexact
-rounding: half_down
-dsbsr415 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr416 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr417 toSci 1.11234550 -> 1.112345 Rounded Inexact
-dsbsr418 toSci 1.11234650 -> 1.112346 Rounded Inexact
-dsbsr419 toSci 1.11234551 -> 1.112346 Rounded Inexact
-rounding: half_even
-dsbsr421 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr422 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr423 toSci 1.11234550 -> 1.112346 Rounded Inexact
-dsbsr424 toSci 1.11234650 -> 1.112346 Rounded Inexact
-dsbsr425 toSci 1.11234551 -> 1.112346 Rounded Inexact
-rounding: down
-dsbsr426 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr427 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr428 toSci 1.11234550 -> 1.112345 Rounded Inexact
-dsbsr429 toSci 1.11234551 -> 1.112345 Rounded Inexact
-rounding: half_up
-dsbsr431 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr432 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr433 toSci 1.11234550 -> 1.112346 Rounded Inexact
-dsbsr434 toSci 1.11234650 -> 1.112347 Rounded Inexact
-dsbsr435 toSci 1.11234551 -> 1.112346 Rounded Inexact
--- negatives
-rounding: ceiling
-dsbsr501 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr502 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr503 toSci -1.11234550 -> -1.112345 Rounded Inexact
-dsbsr504 toSci -1.11234551 -> -1.112345 Rounded Inexact
-rounding: up
-dsbsr505 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr506 toSci -1.11234549 -> -1.112346 Rounded Inexact
-dsbsr507 toSci -1.11234550 -> -1.112346 Rounded Inexact
-dsbsr508 toSci -1.11234551 -> -1.112346 Rounded Inexact
-rounding: floor
-dsbsr510 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr511 toSci -1.11234549 -> -1.112346 Rounded Inexact
-dsbsr512 toSci -1.11234550 -> -1.112346 Rounded Inexact
-dsbsr513 toSci -1.11234551 -> -1.112346 Rounded Inexact
-rounding: half_down
-dsbsr515 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr516 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr517 toSci -1.11234550 -> -1.112345 Rounded Inexact
-dsbsr518 toSci -1.11234650 -> -1.112346 Rounded Inexact
-dsbsr519 toSci -1.11234551 -> -1.112346 Rounded Inexact
-rounding: half_even
-dsbsr521 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr522 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr523 toSci -1.11234550 -> -1.112346 Rounded Inexact
-dsbsr524 toSci -1.11234650 -> -1.112346 Rounded Inexact
-dsbsr525 toSci -1.11234551 -> -1.112346 Rounded Inexact
-rounding: down
-dsbsr526 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr527 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr528 toSci -1.11234550 -> -1.112345 Rounded Inexact
-dsbsr529 toSci -1.11234551 -> -1.112345 Rounded Inexact
-rounding: half_up
-dsbsr531 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr532 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr533 toSci -1.11234550 -> -1.112346 Rounded Inexact
-dsbsr534 toSci -1.11234650 -> -1.112347 Rounded Inexact
-dsbsr535 toSci -1.11234551 -> -1.112346 Rounded Inexact
-
-rounding: half_even
-
--- The 'baddies' tests from DiagBigDecimal, plus some new ones
-dsbas500 toSci '1..2' -> NaN Conversion_syntax
-dsbas501 toSci '.' -> NaN Conversion_syntax
-dsbas502 toSci '..' -> NaN Conversion_syntax
-dsbas503 toSci '++1' -> NaN Conversion_syntax
-dsbas504 toSci '--1' -> NaN Conversion_syntax
-dsbas505 toSci '-+1' -> NaN Conversion_syntax
-dsbas506 toSci '+-1' -> NaN Conversion_syntax
-dsbas507 toSci '12e' -> NaN Conversion_syntax
-dsbas508 toSci '12e++' -> NaN Conversion_syntax
-dsbas509 toSci '12f4' -> NaN Conversion_syntax
-dsbas510 toSci ' +1' -> NaN Conversion_syntax
-dsbas511 toSci '+ 1' -> NaN Conversion_syntax
-dsbas512 toSci '12 ' -> NaN Conversion_syntax
-dsbas513 toSci ' + 1' -> NaN Conversion_syntax
-dsbas514 toSci ' - 1 ' -> NaN Conversion_syntax
-dsbas515 toSci 'x' -> NaN Conversion_syntax
-dsbas516 toSci '-1-' -> NaN Conversion_syntax
-dsbas517 toSci '12-' -> NaN Conversion_syntax
-dsbas518 toSci '3+' -> NaN Conversion_syntax
-dsbas519 toSci '' -> NaN Conversion_syntax
-dsbas520 toSci '1e-' -> NaN Conversion_syntax
-dsbas521 toSci '7e99999a' -> NaN Conversion_syntax
-dsbas522 toSci '7e123567890x' -> NaN Conversion_syntax
-dsbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
-dsbas524 toSci '' -> NaN Conversion_syntax
-dsbas525 toSci 'e100' -> NaN Conversion_syntax
-dsbas526 toSci '\u0e5a' -> NaN Conversion_syntax
-dsbas527 toSci '\u0b65' -> NaN Conversion_syntax
-dsbas528 toSci '123,65' -> NaN Conversion_syntax
-dsbas529 toSci '1.34.5' -> NaN Conversion_syntax
-dsbas530 toSci '.123.5' -> NaN Conversion_syntax
-dsbas531 toSci '01.35.' -> NaN Conversion_syntax
-dsbas532 toSci '01.35-' -> NaN Conversion_syntax
-dsbas533 toSci '0000..' -> NaN Conversion_syntax
-dsbas534 toSci '.0000.' -> NaN Conversion_syntax
-dsbas535 toSci '00..00' -> NaN Conversion_syntax
-dsbas536 toSci '111e*123' -> NaN Conversion_syntax
-dsbas537 toSci '111e123-' -> NaN Conversion_syntax
-dsbas538 toSci '111e+12+' -> NaN Conversion_syntax
-dsbas539 toSci '111e1-3-' -> NaN Conversion_syntax
-dsbas540 toSci '111e1*23' -> NaN Conversion_syntax
-dsbas541 toSci '111e1e+3' -> NaN Conversion_syntax
-dsbas542 toSci '1e1.0' -> NaN Conversion_syntax
-dsbas543 toSci '1e123e' -> NaN Conversion_syntax
-dsbas544 toSci 'ten' -> NaN Conversion_syntax
-dsbas545 toSci 'ONE' -> NaN Conversion_syntax
-dsbas546 toSci '1e.1' -> NaN Conversion_syntax
-dsbas547 toSci '1e1.' -> NaN Conversion_syntax
-dsbas548 toSci '1ee' -> NaN Conversion_syntax
-dsbas549 toSci 'e+1' -> NaN Conversion_syntax
-dsbas550 toSci '1.23.4' -> NaN Conversion_syntax
-dsbas551 toSci '1.2.1' -> NaN Conversion_syntax
-dsbas552 toSci '1E+1.2' -> NaN Conversion_syntax
-dsbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
-dsbas554 toSci '1E++1' -> NaN Conversion_syntax
-dsbas555 toSci '1E--1' -> NaN Conversion_syntax
-dsbas556 toSci '1E+-1' -> NaN Conversion_syntax
-dsbas557 toSci '1E-+1' -> NaN Conversion_syntax
-dsbas558 toSci '1E''1' -> NaN Conversion_syntax
-dsbas559 toSci "1E""1" -> NaN Conversion_syntax
-dsbas560 toSci "1E""""" -> NaN Conversion_syntax
--- Near-specials
-dsbas561 toSci "qNaN" -> NaN Conversion_syntax
-dsbas562 toSci "NaNq" -> NaN Conversion_syntax
-dsbas563 toSci "NaNs" -> NaN Conversion_syntax
-dsbas564 toSci "Infi" -> NaN Conversion_syntax
-dsbas565 toSci "Infin" -> NaN Conversion_syntax
-dsbas566 toSci "Infini" -> NaN Conversion_syntax
-dsbas567 toSci "Infinit" -> NaN Conversion_syntax
-dsbas568 toSci "-Infinit" -> NaN Conversion_syntax
-dsbas569 toSci "0Inf" -> NaN Conversion_syntax
-dsbas570 toSci "9Inf" -> NaN Conversion_syntax
-dsbas571 toSci "-0Inf" -> NaN Conversion_syntax
-dsbas572 toSci "-9Inf" -> NaN Conversion_syntax
-dsbas573 toSci "-sNa" -> NaN Conversion_syntax
-dsbas574 toSci "xNaN" -> NaN Conversion_syntax
-dsbas575 toSci "0sNaN" -> NaN Conversion_syntax
-
--- some baddies with dots and Es and dots and specials
-dsbas576 toSci 'e+1' -> NaN Conversion_syntax
-dsbas577 toSci '.e+1' -> NaN Conversion_syntax
-dsbas578 toSci '+.e+1' -> NaN Conversion_syntax
-dsbas579 toSci '-.e+' -> NaN Conversion_syntax
-dsbas580 toSci '-.e' -> NaN Conversion_syntax
-dsbas581 toSci 'E+1' -> NaN Conversion_syntax
-dsbas582 toSci '.E+1' -> NaN Conversion_syntax
-dsbas583 toSci '+.E+1' -> NaN Conversion_syntax
-dsbas584 toSci '-.E+' -> NaN Conversion_syntax
-dsbas585 toSci '-.E' -> NaN Conversion_syntax
-
-dsbas586 toSci '.NaN' -> NaN Conversion_syntax
-dsbas587 toSci '-.NaN' -> NaN Conversion_syntax
-dsbas588 toSci '+.sNaN' -> NaN Conversion_syntax
-dsbas589 toSci '+.Inf' -> NaN Conversion_syntax
-dsbas590 toSci '.Infinity' -> NaN Conversion_syntax
-
--- Zeros
-dsbas601 toSci 0.000000000 -> 0E-9
-dsbas602 toSci 0.00000000 -> 0E-8
-dsbas603 toSci 0.0000000 -> 0E-7
-dsbas604 toSci 0.000000 -> 0.000000
-dsbas605 toSci 0.00000 -> 0.00000
-dsbas606 toSci 0.0000 -> 0.0000
-dsbas607 toSci 0.000 -> 0.000
-dsbas608 toSci 0.00 -> 0.00
-dsbas609 toSci 0.0 -> 0.0
-dsbas610 toSci .0 -> 0.0
-dsbas611 toSci 0. -> 0
-dsbas612 toSci -.0 -> -0.0
-dsbas613 toSci -0. -> -0
-dsbas614 toSci -0.0 -> -0.0
-dsbas615 toSci -0.00 -> -0.00
-dsbas616 toSci -0.000 -> -0.000
-dsbas617 toSci -0.0000 -> -0.0000
-dsbas618 toSci -0.00000 -> -0.00000
-dsbas619 toSci -0.000000 -> -0.000000
-dsbas620 toSci -0.0000000 -> -0E-7
-dsbas621 toSci -0.00000000 -> -0E-8
-dsbas622 toSci -0.000000000 -> -0E-9
-
-dsbas630 toSci 0.00E+0 -> 0.00
-dsbas631 toSci 0.00E+1 -> 0.0
-dsbas632 toSci 0.00E+2 -> 0
-dsbas633 toSci 0.00E+3 -> 0E+1
-dsbas634 toSci 0.00E+4 -> 0E+2
-dsbas635 toSci 0.00E+5 -> 0E+3
-dsbas636 toSci 0.00E+6 -> 0E+4
-dsbas637 toSci 0.00E+7 -> 0E+5
-dsbas638 toSci 0.00E+8 -> 0E+6
-dsbas639 toSci 0.00E+9 -> 0E+7
-
-dsbas640 toSci 0.0E+0 -> 0.0
-dsbas641 toSci 0.0E+1 -> 0
-dsbas642 toSci 0.0E+2 -> 0E+1
-dsbas643 toSci 0.0E+3 -> 0E+2
-dsbas644 toSci 0.0E+4 -> 0E+3
-dsbas645 toSci 0.0E+5 -> 0E+4
-dsbas646 toSci 0.0E+6 -> 0E+5
-dsbas647 toSci 0.0E+7 -> 0E+6
-dsbas648 toSci 0.0E+8 -> 0E+7
-dsbas649 toSci 0.0E+9 -> 0E+8
-
-dsbas650 toSci 0E+0 -> 0
-dsbas651 toSci 0E+1 -> 0E+1
-dsbas652 toSci 0E+2 -> 0E+2
-dsbas653 toSci 0E+3 -> 0E+3
-dsbas654 toSci 0E+4 -> 0E+4
-dsbas655 toSci 0E+5 -> 0E+5
-dsbas656 toSci 0E+6 -> 0E+6
-dsbas657 toSci 0E+7 -> 0E+7
-dsbas658 toSci 0E+8 -> 0E+8
-dsbas659 toSci 0E+9 -> 0E+9
-
-dsbas660 toSci 0.0E-0 -> 0.0
-dsbas661 toSci 0.0E-1 -> 0.00
-dsbas662 toSci 0.0E-2 -> 0.000
-dsbas663 toSci 0.0E-3 -> 0.0000
-dsbas664 toSci 0.0E-4 -> 0.00000
-dsbas665 toSci 0.0E-5 -> 0.000000
-dsbas666 toSci 0.0E-6 -> 0E-7
-dsbas667 toSci 0.0E-7 -> 0E-8
-dsbas668 toSci 0.0E-8 -> 0E-9
-dsbas669 toSci 0.0E-9 -> 0E-10
-
-dsbas670 toSci 0.00E-0 -> 0.00
-dsbas671 toSci 0.00E-1 -> 0.000
-dsbas672 toSci 0.00E-2 -> 0.0000
-dsbas673 toSci 0.00E-3 -> 0.00000
-dsbas674 toSci 0.00E-4 -> 0.000000
-dsbas675 toSci 0.00E-5 -> 0E-7
-dsbas676 toSci 0.00E-6 -> 0E-8
-dsbas677 toSci 0.00E-7 -> 0E-9
-dsbas678 toSci 0.00E-8 -> 0E-10
-dsbas679 toSci 0.00E-9 -> 0E-11
-
-dsbas680 toSci 000000. -> 0
-dsbas681 toSci 00000. -> 0
-dsbas682 toSci 0000. -> 0
-dsbas683 toSci 000. -> 0
-dsbas684 toSci 00. -> 0
-dsbas685 toSci 0. -> 0
-dsbas686 toSci +00000. -> 0
-dsbas687 toSci -00000. -> -0
-dsbas688 toSci +0. -> 0
-dsbas689 toSci -0. -> -0
-
--- Specials
-dsbas700 toSci "NaN" -> NaN
-dsbas701 toSci "nan" -> NaN
-dsbas702 toSci "nAn" -> NaN
-dsbas703 toSci "NAN" -> NaN
-dsbas704 toSci "+NaN" -> NaN
-dsbas705 toSci "+nan" -> NaN
-dsbas706 toSci "+nAn" -> NaN
-dsbas707 toSci "+NAN" -> NaN
-dsbas708 toSci "-NaN" -> -NaN
-dsbas709 toSci "-nan" -> -NaN
-dsbas710 toSci "-nAn" -> -NaN
-dsbas711 toSci "-NAN" -> -NaN
-dsbas712 toSci 'NaN0' -> NaN
-dsbas713 toSci 'NaN1' -> NaN1
-dsbas714 toSci 'NaN12' -> NaN12
-dsbas715 toSci 'NaN123' -> NaN123
-dsbas716 toSci 'NaN1234' -> NaN1234
-dsbas717 toSci 'NaN01' -> NaN1
-dsbas718 toSci 'NaN012' -> NaN12
-dsbas719 toSci 'NaN0123' -> NaN123
-dsbas720 toSci 'NaN01234' -> NaN1234
-dsbas721 toSci 'NaN001' -> NaN1
-dsbas722 toSci 'NaN0012' -> NaN12
-dsbas723 toSci 'NaN00123' -> NaN123
-dsbas724 toSci 'NaN001234' -> NaN1234
-dsbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
-dsbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
-dsbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
-dsbas728 toSci 'NaN-12' -> NaN Conversion_syntax
-dsbas729 toSci 'NaN+12' -> NaN Conversion_syntax
-
-dsbas730 toSci "sNaN" -> sNaN
-dsbas731 toSci "snan" -> sNaN
-dsbas732 toSci "SnAn" -> sNaN
-dsbas733 toSci "SNAN" -> sNaN
-dsbas734 toSci "+sNaN" -> sNaN
-dsbas735 toSci "+snan" -> sNaN
-dsbas736 toSci "+SnAn" -> sNaN
-dsbas737 toSci "+SNAN" -> sNaN
-dsbas738 toSci "-sNaN" -> -sNaN
-dsbas739 toSci "-snan" -> -sNaN
-dsbas740 toSci "-SnAn" -> -sNaN
-dsbas741 toSci "-SNAN" -> -sNaN
-dsbas742 toSci 'sNaN0000' -> sNaN
-dsbas743 toSci 'sNaN7' -> sNaN7
-dsbas744 toSci 'sNaN007234' -> sNaN7234
-dsbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
-dsbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
-dsbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
-
-dsbas748 toSci "Inf" -> Infinity
-dsbas749 toSci "inf" -> Infinity
-dsbas750 toSci "iNf" -> Infinity
-dsbas751 toSci "INF" -> Infinity
-dsbas752 toSci "+Inf" -> Infinity
-dsbas753 toSci "+inf" -> Infinity
-dsbas754 toSci "+iNf" -> Infinity
-dsbas755 toSci "+INF" -> Infinity
-dsbas756 toSci "-Inf" -> -Infinity
-dsbas757 toSci "-inf" -> -Infinity
-dsbas758 toSci "-iNf" -> -Infinity
-dsbas759 toSci "-INF" -> -Infinity
-
-dsbas760 toSci "Infinity" -> Infinity
-dsbas761 toSci "infinity" -> Infinity
-dsbas762 toSci "iNfInItY" -> Infinity
-dsbas763 toSci "INFINITY" -> Infinity
-dsbas764 toSci "+Infinity" -> Infinity
-dsbas765 toSci "+infinity" -> Infinity
-dsbas766 toSci "+iNfInItY" -> Infinity
-dsbas767 toSci "+INFINITY" -> Infinity
-dsbas768 toSci "-Infinity" -> -Infinity
-dsbas769 toSci "-infinity" -> -Infinity
-dsbas770 toSci "-iNfInItY" -> -Infinity
-dsbas771 toSci "-INFINITY" -> -Infinity
-
--- Specials and zeros for toEng
-dsbast772 toEng "NaN" -> NaN
-dsbast773 toEng "-Infinity" -> -Infinity
-dsbast774 toEng "-sNaN" -> -sNaN
-dsbast775 toEng "-NaN" -> -NaN
-dsbast776 toEng "+Infinity" -> Infinity
-dsbast778 toEng "+sNaN" -> sNaN
-dsbast779 toEng "+NaN" -> NaN
-dsbast780 toEng "INFINITY" -> Infinity
-dsbast781 toEng "SNAN" -> sNaN
-dsbast782 toEng "NAN" -> NaN
-dsbast783 toEng "infinity" -> Infinity
-dsbast784 toEng "snan" -> sNaN
-dsbast785 toEng "nan" -> NaN
-dsbast786 toEng "InFINITY" -> Infinity
-dsbast787 toEng "SnAN" -> sNaN
-dsbast788 toEng "nAN" -> NaN
-dsbast789 toEng "iNfinity" -> Infinity
-dsbast790 toEng "sNan" -> sNaN
-dsbast791 toEng "Nan" -> NaN
-dsbast792 toEng "Infinity" -> Infinity
-dsbast793 toEng "sNaN" -> sNaN
-
--- Zero toEng, etc.
-dsbast800 toEng 0e+1 -> "0.00E+3" -- doc example
-
-dsbast801 toEng 0.000000000 -> 0E-9
-dsbast802 toEng 0.00000000 -> 0.00E-6
-dsbast803 toEng 0.0000000 -> 0.0E-6
-dsbast804 toEng 0.000000 -> 0.000000
-dsbast805 toEng 0.00000 -> 0.00000
-dsbast806 toEng 0.0000 -> 0.0000
-dsbast807 toEng 0.000 -> 0.000
-dsbast808 toEng 0.00 -> 0.00
-dsbast809 toEng 0.0 -> 0.0
-dsbast810 toEng .0 -> 0.0
-dsbast811 toEng 0. -> 0
-dsbast812 toEng -.0 -> -0.0
-dsbast813 toEng -0. -> -0
-dsbast814 toEng -0.0 -> -0.0
-dsbast815 toEng -0.00 -> -0.00
-dsbast816 toEng -0.000 -> -0.000
-dsbast817 toEng -0.0000 -> -0.0000
-dsbast818 toEng -0.00000 -> -0.00000
-dsbast819 toEng -0.000000 -> -0.000000
-dsbast820 toEng -0.0000000 -> -0.0E-6
-dsbast821 toEng -0.00000000 -> -0.00E-6
-dsbast822 toEng -0.000000000 -> -0E-9
-
-dsbast830 toEng 0.00E+0 -> 0.00
-dsbast831 toEng 0.00E+1 -> 0.0
-dsbast832 toEng 0.00E+2 -> 0
-dsbast833 toEng 0.00E+3 -> 0.00E+3
-dsbast834 toEng 0.00E+4 -> 0.0E+3
-dsbast835 toEng 0.00E+5 -> 0E+3
-dsbast836 toEng 0.00E+6 -> 0.00E+6
-dsbast837 toEng 0.00E+7 -> 0.0E+6
-dsbast838 toEng 0.00E+8 -> 0E+6
-dsbast839 toEng 0.00E+9 -> 0.00E+9
-
-dsbast840 toEng 0.0E+0 -> 0.0
-dsbast841 toEng 0.0E+1 -> 0
-dsbast842 toEng 0.0E+2 -> 0.00E+3
-dsbast843 toEng 0.0E+3 -> 0.0E+3
-dsbast844 toEng 0.0E+4 -> 0E+3
-dsbast845 toEng 0.0E+5 -> 0.00E+6
-dsbast846 toEng 0.0E+6 -> 0.0E+6
-dsbast847 toEng 0.0E+7 -> 0E+6
-dsbast848 toEng 0.0E+8 -> 0.00E+9
-dsbast849 toEng 0.0E+9 -> 0.0E+9
-
-dsbast850 toEng 0E+0 -> 0
-dsbast851 toEng 0E+1 -> 0.00E+3
-dsbast852 toEng 0E+2 -> 0.0E+3
-dsbast853 toEng 0E+3 -> 0E+3
-dsbast854 toEng 0E+4 -> 0.00E+6
-dsbast855 toEng 0E+5 -> 0.0E+6
-dsbast856 toEng 0E+6 -> 0E+6
-dsbast857 toEng 0E+7 -> 0.00E+9
-dsbast858 toEng 0E+8 -> 0.0E+9
-dsbast859 toEng 0E+9 -> 0E+9
-
-dsbast860 toEng 0.0E-0 -> 0.0
-dsbast861 toEng 0.0E-1 -> 0.00
-dsbast862 toEng 0.0E-2 -> 0.000
-dsbast863 toEng 0.0E-3 -> 0.0000
-dsbast864 toEng 0.0E-4 -> 0.00000
-dsbast865 toEng 0.0E-5 -> 0.000000
-dsbast866 toEng 0.0E-6 -> 0.0E-6
-dsbast867 toEng 0.0E-7 -> 0.00E-6
-dsbast868 toEng 0.0E-8 -> 0E-9
-dsbast869 toEng 0.0E-9 -> 0.0E-9
-
-dsbast870 toEng 0.00E-0 -> 0.00
-dsbast871 toEng 0.00E-1 -> 0.000
-dsbast872 toEng 0.00E-2 -> 0.0000
-dsbast873 toEng 0.00E-3 -> 0.00000
-dsbast874 toEng 0.00E-4 -> 0.000000
-dsbast875 toEng 0.00E-5 -> 0.0E-6
-dsbast876 toEng 0.00E-6 -> 0.00E-6
-dsbast877 toEng 0.00E-7 -> 0E-9
-dsbast878 toEng 0.00E-8 -> 0.0E-9
-dsbast879 toEng 0.00E-9 -> 0.00E-9
-
--- long input strings
-dsbas801 tosci '01234567' -> 1234567
-dsbas802 tosci '001234567' -> 1234567
-dsbas803 tosci '0001234567' -> 1234567
-dsbas804 tosci '00001234567' -> 1234567
-dsbas805 tosci '000001234567' -> 1234567
-dsbas806 tosci '0000001234567' -> 1234567
-dsbas807 tosci '00000001234567' -> 1234567
-dsbas808 tosci '000000001234567' -> 1234567
-dsbas809 tosci '0000000001234567' -> 1234567
-dsbas810 tosci '00000000001234567' -> 1234567
-
-dsbas811 tosci '0.1234567' -> 0.1234567
-dsbas812 tosci '0.01234567' -> 0.01234567
-dsbas813 tosci '0.001234567' -> 0.001234567
-dsbas814 tosci '0.0001234567' -> 0.0001234567
-dsbas815 tosci '0.00001234567' -> 0.00001234567
-dsbas816 tosci '0.000001234567' -> 0.000001234567
-dsbas817 tosci '0.0000001234567' -> 1.234567E-7
-dsbas818 tosci '0.00000001234567' -> 1.234567E-8
-dsbas819 tosci '0.000000001234567' -> 1.234567E-9
-dsbas820 tosci '0.0000000001234567' -> 1.234567E-10
-
-dsbas821 tosci '123456790' -> 1.234568E+8 Inexact Rounded
-dsbas822 tosci '1234567901' -> 1.234568E+9 Inexact Rounded
-dsbas823 tosci '12345679012' -> 1.234568E+10 Inexact Rounded
-dsbas824 tosci '123456790123' -> 1.234568E+11 Inexact Rounded
-dsbas825 tosci '1234567901234' -> 1.234568E+12 Inexact Rounded
-dsbas826 tosci '12345679012345' -> 1.234568E+13 Inexact Rounded
-dsbas827 tosci '123456790123456' -> 1.234568E+14 Inexact Rounded
-dsbas828 tosci '1234567901234567' -> 1.234568E+15 Inexact Rounded
-dsbas829 tosci '1234567890123456' -> 1.234568E+15 Inexact Rounded
-
--- subnormals and overflows
-dsbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
-dsbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
-dsbas908 toSci '0.9e-999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas909 toSci '0.09e-999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
-dsbas911 toSci '10e-1000000000' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
-dsbas913 toSci '99e-9999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
-dsbas915 toSci '1111e-9999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas916 toSci '1111e-99999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
--- negatives the same
-dsbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
-dsbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
-dsbas920 toSci '-0.9e-999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas921 toSci '-0.09e-999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
-dsbas923 toSci '-10e-1000000000' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
-dsbas925 toSci '-99e-9999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
-dsbas927 toSci '-1111e-9999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas928 toSci '-1111e-99999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
-
--- overflow results at different rounding modes
-rounding: ceiling
-dsbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas931 toSci '-7e10000' -> -9.999999E+96 Overflow Inexact Rounded
-rounding: up
-dsbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: down
-dsbas934 toSci '7e10000' -> 9.999999E+96 Overflow Inexact Rounded
-dsbas935 toSci '-7e10000' -> -9.999999E+96 Overflow Inexact Rounded
-rounding: floor
-dsbas936 toSci '7e10000' -> 9.999999E+96 Overflow Inexact Rounded
-dsbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_up
-dsbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_even
-dsbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_down
-dsbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_even
-
--- Now check 854/754r some subnormals and underflow to 0
-dsbem400 toSci 1.0000E-86 -> 1.0000E-86
-dsbem401 toSci 0.1E-97 -> 1E-98 Subnormal
-dsbem402 toSci 0.1000E-97 -> 1.000E-98 Subnormal
-dsbem403 toSci 0.0100E-97 -> 1.00E-99 Subnormal
-dsbem404 toSci 0.0010E-97 -> 1.0E-100 Subnormal
-dsbem405 toSci 0.0001E-97 -> 1E-101 Subnormal
-dsbem406 toSci 0.00010E-97 -> 1E-101 Subnormal Rounded
-dsbem407 toSci 0.00013E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
-dsbem408 toSci 0.00015E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem409 toSci 0.00017E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem410 toSci 0.00023E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem411 toSci 0.00025E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem412 toSci 0.00027E-97 -> 3E-101 Underflow Subnormal Inexact Rounded
-dsbem413 toSci 0.000149E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
-dsbem414 toSci 0.000150E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem415 toSci 0.000151E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem416 toSci 0.000249E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem417 toSci 0.000250E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem418 toSci 0.000251E-97 -> 3E-101 Underflow Subnormal Inexact Rounded
-dsbem419 toSci 0.00009E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
-dsbem420 toSci 0.00005E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem421 toSci 0.00003E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem422 toSci 0.000009E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem423 toSci 0.000005E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem424 toSci 0.000003E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-
-dsbem425 toSci 0.001049E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
-dsbem426 toSci 0.001050E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
-dsbem427 toSci 0.001051E-97 -> 1.1E-100 Underflow Subnormal Inexact Rounded
-dsbem428 toSci 0.001149E-97 -> 1.1E-100 Underflow Subnormal Inexact Rounded
-dsbem429 toSci 0.001150E-97 -> 1.2E-100 Underflow Subnormal Inexact Rounded
-dsbem430 toSci 0.001151E-97 -> 1.2E-100 Underflow Subnormal Inexact Rounded
-
-dsbem432 toSci 0.010049E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
-dsbem433 toSci 0.010050E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
-dsbem434 toSci 0.010051E-97 -> 1.01E-99 Underflow Subnormal Inexact Rounded
-dsbem435 toSci 0.010149E-97 -> 1.01E-99 Underflow Subnormal Inexact Rounded
-dsbem436 toSci 0.010150E-97 -> 1.02E-99 Underflow Subnormal Inexact Rounded
-dsbem437 toSci 0.010151E-97 -> 1.02E-99 Underflow Subnormal Inexact Rounded
-
-dsbem440 toSci 0.10103E-97 -> 1.010E-98 Underflow Subnormal Inexact Rounded
-dsbem441 toSci 0.10105E-97 -> 1.010E-98 Underflow Subnormal Inexact Rounded
-dsbem442 toSci 0.10107E-97 -> 1.011E-98 Underflow Subnormal Inexact Rounded
-dsbem443 toSci 0.10113E-97 -> 1.011E-98 Underflow Subnormal Inexact Rounded
-dsbem444 toSci 0.10115E-97 -> 1.012E-98 Underflow Subnormal Inexact Rounded
-dsbem445 toSci 0.10117E-97 -> 1.012E-98 Underflow Subnormal Inexact Rounded
-
-dsbem450 toSci 1.10730E-98 -> 1.107E-98 Underflow Subnormal Inexact Rounded
-dsbem451 toSci 1.10750E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
-dsbem452 toSci 1.10770E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
-dsbem453 toSci 1.10830E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
-dsbem454 toSci 1.10850E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
-dsbem455 toSci 1.10870E-98 -> 1.109E-98 Underflow Subnormal Inexact Rounded
-
--- make sure sign OK
-dsbem456 toSci -0.10103E-97 -> -1.010E-98 Underflow Subnormal Inexact Rounded
-dsbem457 toSci -0.10105E-97 -> -1.010E-98 Underflow Subnormal Inexact Rounded
-dsbem458 toSci -0.10107E-97 -> -1.011E-98 Underflow Subnormal Inexact Rounded
-dsbem459 toSci -0.10113E-97 -> -1.011E-98 Underflow Subnormal Inexact Rounded
-dsbem460 toSci -0.10115E-97 -> -1.012E-98 Underflow Subnormal Inexact Rounded
-dsbem461 toSci -0.10117E-97 -> -1.012E-98 Underflow Subnormal Inexact Rounded
-
--- '999s' cases
-dsbem464 toSci 999999E-98 -> 9.99999E-93
-dsbem465 toSci 99999.0E-97 -> 9.99990E-93
-dsbem466 toSci 99999.E-97 -> 9.9999E-93
-dsbem467 toSci 9999.9E-97 -> 9.9999E-94
-dsbem468 toSci 999.99E-97 -> 9.9999E-95
-dsbem469 toSci 99.999E-97 -> 9.9999E-96 Subnormal
-dsbem470 toSci 9.9999E-97 -> 9.9999E-97 Subnormal
-dsbem471 toSci 0.99999E-97 -> 1.0000E-97 Underflow Subnormal Inexact Rounded
-dsbem472 toSci 0.099999E-97 -> 1.000E-98 Underflow Subnormal Inexact Rounded
-dsbem473 toSci 0.0099999E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
-dsbem474 toSci 0.00099999E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
-dsbem475 toSci 0.000099999E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
-dsbem476 toSci 0.0000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem477 toSci 0.00000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem478 toSci 0.000000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-
--- Exponents with insignificant leading zeros
-dsbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
-dsbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
-dsbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
-dsbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
-dsbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
-dsbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
-dsbas1007 toSci 1e-999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1008 toSci 1e-0999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1009 toSci 1e-00999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1010 toSci 1e-000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1011 toSci 1e-000000000000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1012 toSci 1e-000000000001000000007 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-
--- check for double-rounded subnormals
-dsbas1041 toSci 1.1152444E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
-dsbas1042 toSci 1.1152445E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
-dsbas1043 toSci 1.1152446E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
-
--- clamped zeros [see also clamp.decTest]
-dsbas1075 toSci 0e+10000 -> 0E+90 Clamped
-dsbas1076 toSci 0e-10000 -> 0E-101 Clamped
-dsbas1077 toSci -0e+10000 -> -0E+90 Clamped
-dsbas1078 toSci -0e-10000 -> -0E-101 Clamped
-
--- extreme values from next-wider
-dsbas1101 toSci -9.999999999999999E+384 -> -Infinity Overflow Inexact Rounded
-dsbas1102 toSci -1E-383 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
-dsbas1103 toSci -1E-398 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
-dsbas1104 toSci -0 -> -0
-dsbas1105 toSci +0 -> 0
-dsbas1106 toSci +1E-398 -> 0E-101 Inexact Rounded Subnormal Underflow Clamped
-dsbas1107 toSci +1E-383 -> 0E-101 Inexact Rounded Subnormal Underflow Clamped
-dsbas1108 toSci +9.999999999999999E+384 -> Infinity Overflow Inexact Rounded
-
--- narrowing case
-dsbas1110 toSci 2.000000000000000E-99 -> 2.00E-99 Rounded Subnormal
+------------------------------------------------------------------------
+-- dsBase.decTest -- base decSingle <--> string conversions --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests base conversions from string to a decimal number
+-- and back to a string (in Scientific form)
+
+-- Note that unlike other operations the operand is subject to rounding
+-- to conform to emax and precision settings (that is, numbers will
+-- conform to rules and exponent will be in permitted range). The
+-- 'left hand side', therefore, may have numbers that cannot be
+-- represented in a decSingle. Some testcases go to the limit of the
+-- next-wider format, and hence these testcases may also be used to
+-- test narrowing and widening operations.
+
+extended: 1
+clamp: 1
+precision: 7
+maxExponent: 96
+minExponent: -95
+rounding: half_even
+
+dsbas001 toSci 0 -> 0
+dsbas002 toSci 1 -> 1
+dsbas003 toSci 1.0 -> 1.0
+dsbas004 toSci 1.00 -> 1.00
+dsbas005 toSci 10 -> 10
+dsbas006 toSci 1000 -> 1000
+dsbas007 toSci 10.0 -> 10.0
+dsbas008 toSci 10.1 -> 10.1
+dsbas009 toSci 10.4 -> 10.4
+dsbas010 toSci 10.5 -> 10.5
+dsbas011 toSci 10.6 -> 10.6
+dsbas012 toSci 10.9 -> 10.9
+dsbas013 toSci 11.0 -> 11.0
+dsbas014 toSci 1.234 -> 1.234
+dsbas015 toSci 0.123 -> 0.123
+dsbas016 toSci 0.012 -> 0.012
+dsbas017 toSci -0 -> -0
+dsbas018 toSci -0.0 -> -0.0
+dsbas019 toSci -00.00 -> -0.00
+
+dsbas021 toSci -1 -> -1
+dsbas022 toSci -1.0 -> -1.0
+dsbas023 toSci -0.1 -> -0.1
+dsbas024 toSci -9.1 -> -9.1
+dsbas025 toSci -9.11 -> -9.11
+dsbas026 toSci -9.119 -> -9.119
+dsbas027 toSci -9.999 -> -9.999
+
+dsbas030 toSci '1234.567' -> '1234.567'
+dsbas031 toSci '1234.000' -> '1234.000'
+dsbas032 toSci '1234912' -> '1234912'
+dsbas033 toSci '0.00001234567' -> '0.00001234567'
+dsbas034 toSci '0.000001234567' -> '0.000001234567'
+dsbas035 toSci '0.0000001234567' -> '1.234567E-7'
+dsbas036 toSci '0.00000001234567' -> '1.234567E-8'
+
+dsbas037 toSci '0.1234564' -> '0.1234564'
+dsbas038 toSci '0.1234565' -> '0.1234565'
+
+-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
+dsbsn001 toSci -9.999999E+96 -> -9.999999E+96
+dsbsn002 toSci -1E-95 -> -1E-95
+dsbsn003 toSci -1E-101 -> -1E-101 Subnormal
+dsbsn004 toSci -0 -> -0
+dsbsn005 toSci +0 -> 0
+dsbsn006 toSci +1E-101 -> 1E-101 Subnormal
+dsbsn007 toSci +1E-95 -> 1E-95
+dsbsn008 toSci +9.999999E+96 -> 9.999999E+96
+
+-- String [many more examples are implicitly tested elsewhere]
+-- strings without E cannot generate E in result
+dsbas040 toSci "12" -> '12'
+dsbas041 toSci "-76" -> '-76'
+dsbas042 toSci "12.76" -> '12.76'
+dsbas043 toSci "+12.76" -> '12.76'
+dsbas044 toSci "012.76" -> '12.76'
+dsbas045 toSci "+0.003" -> '0.003'
+dsbas046 toSci "17." -> '17'
+dsbas047 toSci ".5" -> '0.5'
+dsbas048 toSci "044" -> '44'
+dsbas049 toSci "0044" -> '44'
+dsbas050 toSci "0.0005" -> '0.0005'
+dsbas051 toSci "00.00005" -> '0.00005'
+dsbas052 toSci "0.000005" -> '0.000005'
+dsbas053 toSci "0.0000050" -> '0.0000050'
+dsbas054 toSci "0.0000005" -> '5E-7'
+dsbas055 toSci "0.00000005" -> '5E-8'
+dsbas056 toSci "12678.54" -> '12678.54'
+dsbas057 toSci "2678.543" -> '2678.543'
+dsbas058 toSci "345678.5" -> '345678.5'
+dsbas059 toSci "0678.5432" -> '678.5432'
+dsbas060 toSci "678.5432" -> '678.5432'
+dsbas061 toSci "+678.5432" -> '678.5432'
+dsbas062 toSci "+0678.5432" -> '678.5432'
+dsbas063 toSci "+00678.5432" -> '678.5432'
+dsbas064 toSci "-678.5432" -> '-678.5432'
+dsbas065 toSci "-0678.5432" -> '-678.5432'
+dsbas066 toSci "-00678.5432" -> '-678.5432'
+-- examples
+dsbas067 toSci "5E-6" -> '0.000005'
+dsbas068 toSci "50E-7" -> '0.0000050'
+dsbas069 toSci "5E-7" -> '5E-7'
+
+-- [No exotics as no Unicode]
+
+-- rounded with dots in all (including edge) places
+dsbas071 toSci .1234567890123456 -> 0.1234568 Inexact Rounded
+dsbas072 toSci 1.234567890123456 -> 1.234568 Inexact Rounded
+dsbas073 toSci 12.34567890123456 -> 12.34568 Inexact Rounded
+dsbas074 toSci 123.4567890123456 -> 123.4568 Inexact Rounded
+dsbas075 toSci 1234.567890123456 -> 1234.568 Inexact Rounded
+dsbas076 toSci 12345.67890123456 -> 12345.68 Inexact Rounded
+dsbas077 toSci 123456.7890123456 -> 123456.8 Inexact Rounded
+dsbas078 toSci 1234567.890123456 -> 1234568 Inexact Rounded
+dsbas079 toSci 12345678.90123456 -> 1.234568E+7 Inexact Rounded
+dsbas080 toSci 123456789.0123456 -> 1.234568E+8 Inexact Rounded
+dsbas081 toSci 1234567890.123456 -> 1.234568E+9 Inexact Rounded
+dsbas082 toSci 12345678901.23456 -> 1.234568E+10 Inexact Rounded
+dsbas083 toSci 123456789012.3456 -> 1.234568E+11 Inexact Rounded
+dsbas084 toSci 1234567890123.456 -> 1.234568E+12 Inexact Rounded
+dsbas085 toSci 12345678901234.56 -> 1.234568E+13 Inexact Rounded
+dsbas086 toSci 123456789012345.6 -> 1.234568E+14 Inexact Rounded
+dsbas087 toSci 1234567890123456. -> 1.234568E+15 Inexact Rounded
+dsbas088 toSci 1234567890123456 -> 1.234568E+15 Inexact Rounded
+
+-- Numbers with E
+dsbas130 toSci "0.000E-1" -> '0.0000'
+dsbas131 toSci "0.000E-2" -> '0.00000'
+dsbas132 toSci "0.000E-3" -> '0.000000'
+dsbas133 toSci "0.000E-4" -> '0E-7'
+dsbas134 toSci "0.00E-2" -> '0.0000'
+dsbas135 toSci "0.00E-3" -> '0.00000'
+dsbas136 toSci "0.00E-4" -> '0.000000'
+dsbas137 toSci "0.00E-5" -> '0E-7'
+dsbas138 toSci "+0E+9" -> '0E+9'
+dsbas139 toSci "-0E+9" -> '-0E+9'
+dsbas140 toSci "1E+9" -> '1E+9'
+dsbas141 toSci "1e+09" -> '1E+9'
+dsbas142 toSci "1E+90" -> '1E+90'
+dsbas143 toSci "+1E+009" -> '1E+9'
+dsbas144 toSci "0E+9" -> '0E+9'
+dsbas145 toSci "1E+9" -> '1E+9'
+dsbas146 toSci "1E+09" -> '1E+9'
+dsbas147 toSci "1e+90" -> '1E+90'
+dsbas148 toSci "1E+009" -> '1E+9'
+dsbas149 toSci "000E+9" -> '0E+9'
+dsbas150 toSci "1E9" -> '1E+9'
+dsbas151 toSci "1e09" -> '1E+9'
+dsbas152 toSci "1E90" -> '1E+90'
+dsbas153 toSci "1E009" -> '1E+9'
+dsbas154 toSci "0E9" -> '0E+9'
+dsbas155 toSci "0.000e+0" -> '0.000'
+dsbas156 toSci "0.000E-1" -> '0.0000'
+dsbas157 toSci "4E+9" -> '4E+9'
+dsbas158 toSci "44E+9" -> '4.4E+10'
+dsbas159 toSci "0.73e-7" -> '7.3E-8'
+dsbas160 toSci "00E+9" -> '0E+9'
+dsbas161 toSci "00E-9" -> '0E-9'
+dsbas162 toSci "10E+9" -> '1.0E+10'
+dsbas163 toSci "10E+09" -> '1.0E+10'
+dsbas164 toSci "10e+90" -> '1.0E+91'
+dsbas165 toSci "10E+009" -> '1.0E+10'
+dsbas166 toSci "100e+9" -> '1.00E+11'
+dsbas167 toSci "100e+09" -> '1.00E+11'
+dsbas168 toSci "100E+90" -> '1.00E+92'
+dsbas169 toSci "100e+009" -> '1.00E+11'
+
+dsbas170 toSci "1.265" -> '1.265'
+dsbas171 toSci "1.265E-20" -> '1.265E-20'
+dsbas172 toSci "1.265E-8" -> '1.265E-8'
+dsbas173 toSci "1.265E-4" -> '0.0001265'
+dsbas174 toSci "1.265E-3" -> '0.001265'
+dsbas175 toSci "1.265E-2" -> '0.01265'
+dsbas176 toSci "1.265E-1" -> '0.1265'
+dsbas177 toSci "1.265E-0" -> '1.265'
+dsbas178 toSci "1.265E+1" -> '12.65'
+dsbas179 toSci "1.265E+2" -> '126.5'
+dsbas180 toSci "1.265E+3" -> '1265'
+dsbas181 toSci "1.265E+4" -> '1.265E+4'
+dsbas182 toSci "1.265E+8" -> '1.265E+8'
+dsbas183 toSci "1.265E+20" -> '1.265E+20'
+
+dsbas190 toSci "12.65" -> '12.65'
+dsbas191 toSci "12.65E-20" -> '1.265E-19'
+dsbas192 toSci "12.65E-8" -> '1.265E-7'
+dsbas193 toSci "12.65E-4" -> '0.001265'
+dsbas194 toSci "12.65E-3" -> '0.01265'
+dsbas195 toSci "12.65E-2" -> '0.1265'
+dsbas196 toSci "12.65E-1" -> '1.265'
+dsbas197 toSci "12.65E-0" -> '12.65'
+dsbas198 toSci "12.65E+1" -> '126.5'
+dsbas199 toSci "12.65E+2" -> '1265'
+dsbas200 toSci "12.65E+3" -> '1.265E+4'
+dsbas201 toSci "12.65E+4" -> '1.265E+5'
+dsbas202 toSci "12.65E+8" -> '1.265E+9'
+dsbas203 toSci "12.65E+20" -> '1.265E+21'
+
+dsbas210 toSci "126.5" -> '126.5'
+dsbas211 toSci "126.5E-20" -> '1.265E-18'
+dsbas212 toSci "126.5E-8" -> '0.000001265'
+dsbas213 toSci "126.5E-4" -> '0.01265'
+dsbas214 toSci "126.5E-3" -> '0.1265'
+dsbas215 toSci "126.5E-2" -> '1.265'
+dsbas216 toSci "126.5E-1" -> '12.65'
+dsbas217 toSci "126.5E-0" -> '126.5'
+dsbas218 toSci "126.5E+1" -> '1265'
+dsbas219 toSci "126.5E+2" -> '1.265E+4'
+dsbas220 toSci "126.5E+3" -> '1.265E+5'
+dsbas221 toSci "126.5E+4" -> '1.265E+6'
+dsbas222 toSci "126.5E+8" -> '1.265E+10'
+dsbas223 toSci "126.5E+20" -> '1.265E+22'
+
+dsbas230 toSci "1265" -> '1265'
+dsbas231 toSci "1265E-20" -> '1.265E-17'
+dsbas232 toSci "1265E-8" -> '0.00001265'
+dsbas233 toSci "1265E-4" -> '0.1265'
+dsbas234 toSci "1265E-3" -> '1.265'
+dsbas235 toSci "1265E-2" -> '12.65'
+dsbas236 toSci "1265E-1" -> '126.5'
+dsbas237 toSci "1265E-0" -> '1265'
+dsbas238 toSci "1265E+1" -> '1.265E+4'
+dsbas239 toSci "1265E+2" -> '1.265E+5'
+dsbas240 toSci "1265E+3" -> '1.265E+6'
+dsbas241 toSci "1265E+4" -> '1.265E+7'
+dsbas242 toSci "1265E+8" -> '1.265E+11'
+dsbas243 toSci "1265E+20" -> '1.265E+23'
+
+dsbas250 toSci "0.1265" -> '0.1265'
+dsbas251 toSci "0.1265E-20" -> '1.265E-21'
+dsbas252 toSci "0.1265E-8" -> '1.265E-9'
+dsbas253 toSci "0.1265E-4" -> '0.00001265'
+dsbas254 toSci "0.1265E-3" -> '0.0001265'
+dsbas255 toSci "0.1265E-2" -> '0.001265'
+dsbas256 toSci "0.1265E-1" -> '0.01265'
+dsbas257 toSci "0.1265E-0" -> '0.1265'
+dsbas258 toSci "0.1265E+1" -> '1.265'
+dsbas259 toSci "0.1265E+2" -> '12.65'
+dsbas260 toSci "0.1265E+3" -> '126.5'
+dsbas261 toSci "0.1265E+4" -> '1265'
+dsbas262 toSci "0.1265E+8" -> '1.265E+7'
+dsbas263 toSci "0.1265E+20" -> '1.265E+19'
+
+-- some more negative zeros [systematic tests below]
+dsbas290 toSci "-0.000E-1" -> '-0.0000'
+dsbas291 toSci "-0.000E-2" -> '-0.00000'
+dsbas292 toSci "-0.000E-3" -> '-0.000000'
+dsbas293 toSci "-0.000E-4" -> '-0E-7'
+dsbas294 toSci "-0.00E-2" -> '-0.0000'
+dsbas295 toSci "-0.00E-3" -> '-0.00000'
+dsbas296 toSci "-0.0E-2" -> '-0.000'
+dsbas297 toSci "-0.0E-3" -> '-0.0000'
+dsbas298 toSci "-0E-2" -> '-0.00'
+dsbas299 toSci "-0E-3" -> '-0.000'
+
+-- Engineering notation tests
+dsbas301 toSci 10e12 -> 1.0E+13
+dsbas302 toEng 10e12 -> 10E+12
+dsbas303 toSci 10e11 -> 1.0E+12
+dsbas304 toEng 10e11 -> 1.0E+12
+dsbas305 toSci 10e10 -> 1.0E+11
+dsbas306 toEng 10e10 -> 100E+9
+dsbas307 toSci 10e9 -> 1.0E+10
+dsbas308 toEng 10e9 -> 10E+9
+dsbas309 toSci 10e8 -> 1.0E+9
+dsbas310 toEng 10e8 -> 1.0E+9
+dsbas311 toSci 10e7 -> 1.0E+8
+dsbas312 toEng 10e7 -> 100E+6
+dsbas313 toSci 10e6 -> 1.0E+7
+dsbas314 toEng 10e6 -> 10E+6
+dsbas315 toSci 10e5 -> 1.0E+6
+dsbas316 toEng 10e5 -> 1.0E+6
+dsbas317 toSci 10e4 -> 1.0E+5
+dsbas318 toEng 10e4 -> 100E+3
+dsbas319 toSci 10e3 -> 1.0E+4
+dsbas320 toEng 10e3 -> 10E+3
+dsbas321 toSci 10e2 -> 1.0E+3
+dsbas322 toEng 10e2 -> 1.0E+3
+dsbas323 toSci 10e1 -> 1.0E+2
+dsbas324 toEng 10e1 -> 100
+dsbas325 toSci 10e0 -> 10
+dsbas326 toEng 10e0 -> 10
+dsbas327 toSci 10e-1 -> 1.0
+dsbas328 toEng 10e-1 -> 1.0
+dsbas329 toSci 10e-2 -> 0.10
+dsbas330 toEng 10e-2 -> 0.10
+dsbas331 toSci 10e-3 -> 0.010
+dsbas332 toEng 10e-3 -> 0.010
+dsbas333 toSci 10e-4 -> 0.0010
+dsbas334 toEng 10e-4 -> 0.0010
+dsbas335 toSci 10e-5 -> 0.00010
+dsbas336 toEng 10e-5 -> 0.00010
+dsbas337 toSci 10e-6 -> 0.000010
+dsbas338 toEng 10e-6 -> 0.000010
+dsbas339 toSci 10e-7 -> 0.0000010
+dsbas340 toEng 10e-7 -> 0.0000010
+dsbas341 toSci 10e-8 -> 1.0E-7
+dsbas342 toEng 10e-8 -> 100E-9
+dsbas343 toSci 10e-9 -> 1.0E-8
+dsbas344 toEng 10e-9 -> 10E-9
+dsbas345 toSci 10e-10 -> 1.0E-9
+dsbas346 toEng 10e-10 -> 1.0E-9
+dsbas347 toSci 10e-11 -> 1.0E-10
+dsbas348 toEng 10e-11 -> 100E-12
+dsbas349 toSci 10e-12 -> 1.0E-11
+dsbas350 toEng 10e-12 -> 10E-12
+dsbas351 toSci 10e-13 -> 1.0E-12
+dsbas352 toEng 10e-13 -> 1.0E-12
+
+dsbas361 toSci 7E12 -> 7E+12
+dsbas362 toEng 7E12 -> 7E+12
+dsbas363 toSci 7E11 -> 7E+11
+dsbas364 toEng 7E11 -> 700E+9
+dsbas365 toSci 7E10 -> 7E+10
+dsbas366 toEng 7E10 -> 70E+9
+dsbas367 toSci 7E9 -> 7E+9
+dsbas368 toEng 7E9 -> 7E+9
+dsbas369 toSci 7E8 -> 7E+8
+dsbas370 toEng 7E8 -> 700E+6
+dsbas371 toSci 7E7 -> 7E+7
+dsbas372 toEng 7E7 -> 70E+6
+dsbas373 toSci 7E6 -> 7E+6
+dsbas374 toEng 7E6 -> 7E+6
+dsbas375 toSci 7E5 -> 7E+5
+dsbas376 toEng 7E5 -> 700E+3
+dsbas377 toSci 7E4 -> 7E+4
+dsbas378 toEng 7E4 -> 70E+3
+dsbas379 toSci 7E3 -> 7E+3
+dsbas380 toEng 7E3 -> 7E+3
+dsbas381 toSci 7E2 -> 7E+2
+dsbas382 toEng 7E2 -> 700
+dsbas383 toSci 7E1 -> 7E+1
+dsbas384 toEng 7E1 -> 70
+dsbas385 toSci 7E0 -> 7
+dsbas386 toEng 7E0 -> 7
+dsbas387 toSci 7E-1 -> 0.7
+dsbas388 toEng 7E-1 -> 0.7
+dsbas389 toSci 7E-2 -> 0.07
+dsbas390 toEng 7E-2 -> 0.07
+dsbas391 toSci 7E-3 -> 0.007
+dsbas392 toEng 7E-3 -> 0.007
+dsbas393 toSci 7E-4 -> 0.0007
+dsbas394 toEng 7E-4 -> 0.0007
+dsbas395 toSci 7E-5 -> 0.00007
+dsbas396 toEng 7E-5 -> 0.00007
+dsbas397 toSci 7E-6 -> 0.000007
+dsbas398 toEng 7E-6 -> 0.000007
+dsbas399 toSci 7E-7 -> 7E-7
+dsbas400 toEng 7E-7 -> 700E-9
+dsbas401 toSci 7E-8 -> 7E-8
+dsbas402 toEng 7E-8 -> 70E-9
+dsbas403 toSci 7E-9 -> 7E-9
+dsbas404 toEng 7E-9 -> 7E-9
+dsbas405 toSci 7E-10 -> 7E-10
+dsbas406 toEng 7E-10 -> 700E-12
+dsbas407 toSci 7E-11 -> 7E-11
+dsbas408 toEng 7E-11 -> 70E-12
+dsbas409 toSci 7E-12 -> 7E-12
+dsbas410 toEng 7E-12 -> 7E-12
+dsbas411 toSci 7E-13 -> 7E-13
+dsbas412 toEng 7E-13 -> 700E-15
+
+-- Exacts remain exact up to precision ..
+dsbas420 toSci 100 -> 100
+dsbas422 toSci 1000 -> 1000
+dsbas424 toSci 999.9 -> 999.9
+dsbas426 toSci 1000.0 -> 1000.0
+dsbas428 toSci 1000.1 -> 1000.1
+dsbas430 toSci 10000 -> 10000
+dsbas432 toSci 1000 -> 1000
+dsbas434 toSci 10000 -> 10000
+dsbas436 toSci 100000 -> 100000
+dsbas438 toSci 1000000 -> 1000000
+dsbas440 toSci 10000000 -> 1.000000E+7 Rounded
+dsbas442 toSci 10000000 -> 1.000000E+7 Rounded
+dsbas444 toSci 10000003 -> 1.000000E+7 Rounded Inexact
+dsbas446 toSci 10000005 -> 1.000000E+7 Rounded Inexact
+dsbas448 toSci 100000050 -> 1.000000E+8 Rounded Inexact
+dsbas450 toSci 10000009 -> 1.000001E+7 Rounded Inexact
+dsbas452 toSci 100000000 -> 1.000000E+8 Rounded
+dsbas454 toSci 100000003 -> 1.000000E+8 Rounded Inexact
+dsbas456 toSci 100000005 -> 1.000000E+8 Rounded Inexact
+dsbas458 toSci 100000009 -> 1.000000E+8 Rounded Inexact
+dsbas460 toSci 1000000000 -> 1.000000E+9 Rounded
+dsbas462 toSci 1000000300 -> 1.000000E+9 Rounded Inexact
+dsbas464 toSci 1000000500 -> 1.000000E+9 Rounded Inexact
+dsbas466 toSci 1000000900 -> 1.000001E+9 Rounded Inexact
+dsbas468 toSci 10000000000 -> 1.000000E+10 Rounded
+dsbas470 toSci 10000003000 -> 1.000000E+10 Rounded Inexact
+dsbas472 toSci 10000005000 -> 1.000000E+10 Rounded Inexact
+dsbas474 toSci 10000009000 -> 1.000001E+10 Rounded Inexact
+
+-- check rounding modes heeded
+rounding: ceiling
+dsbsr401 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr402 toSci 1.11234549 -> 1.112346 Rounded Inexact
+dsbsr403 toSci 1.11234550 -> 1.112346 Rounded Inexact
+dsbsr404 toSci 1.11234551 -> 1.112346 Rounded Inexact
+rounding: up
+dsbsr405 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr406 toSci 1.11234549 -> 1.112346 Rounded Inexact
+dsbsr407 toSci 1.11234550 -> 1.112346 Rounded Inexact
+dsbsr408 toSci 1.11234551 -> 1.112346 Rounded Inexact
+rounding: floor
+dsbsr410 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr411 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr412 toSci 1.11234550 -> 1.112345 Rounded Inexact
+dsbsr413 toSci 1.11234551 -> 1.112345 Rounded Inexact
+rounding: half_down
+dsbsr415 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr416 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr417 toSci 1.11234550 -> 1.112345 Rounded Inexact
+dsbsr418 toSci 1.11234650 -> 1.112346 Rounded Inexact
+dsbsr419 toSci 1.11234551 -> 1.112346 Rounded Inexact
+rounding: half_even
+dsbsr421 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr422 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr423 toSci 1.11234550 -> 1.112346 Rounded Inexact
+dsbsr424 toSci 1.11234650 -> 1.112346 Rounded Inexact
+dsbsr425 toSci 1.11234551 -> 1.112346 Rounded Inexact
+rounding: down
+dsbsr426 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr427 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr428 toSci 1.11234550 -> 1.112345 Rounded Inexact
+dsbsr429 toSci 1.11234551 -> 1.112345 Rounded Inexact
+rounding: half_up
+dsbsr431 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr432 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr433 toSci 1.11234550 -> 1.112346 Rounded Inexact
+dsbsr434 toSci 1.11234650 -> 1.112347 Rounded Inexact
+dsbsr435 toSci 1.11234551 -> 1.112346 Rounded Inexact
+-- negatives
+rounding: ceiling
+dsbsr501 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr502 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr503 toSci -1.11234550 -> -1.112345 Rounded Inexact
+dsbsr504 toSci -1.11234551 -> -1.112345 Rounded Inexact
+rounding: up
+dsbsr505 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr506 toSci -1.11234549 -> -1.112346 Rounded Inexact
+dsbsr507 toSci -1.11234550 -> -1.112346 Rounded Inexact
+dsbsr508 toSci -1.11234551 -> -1.112346 Rounded Inexact
+rounding: floor
+dsbsr510 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr511 toSci -1.11234549 -> -1.112346 Rounded Inexact
+dsbsr512 toSci -1.11234550 -> -1.112346 Rounded Inexact
+dsbsr513 toSci -1.11234551 -> -1.112346 Rounded Inexact
+rounding: half_down
+dsbsr515 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr516 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr517 toSci -1.11234550 -> -1.112345 Rounded Inexact
+dsbsr518 toSci -1.11234650 -> -1.112346 Rounded Inexact
+dsbsr519 toSci -1.11234551 -> -1.112346 Rounded Inexact
+rounding: half_even
+dsbsr521 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr522 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr523 toSci -1.11234550 -> -1.112346 Rounded Inexact
+dsbsr524 toSci -1.11234650 -> -1.112346 Rounded Inexact
+dsbsr525 toSci -1.11234551 -> -1.112346 Rounded Inexact
+rounding: down
+dsbsr526 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr527 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr528 toSci -1.11234550 -> -1.112345 Rounded Inexact
+dsbsr529 toSci -1.11234551 -> -1.112345 Rounded Inexact
+rounding: half_up
+dsbsr531 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr532 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr533 toSci -1.11234550 -> -1.112346 Rounded Inexact
+dsbsr534 toSci -1.11234650 -> -1.112347 Rounded Inexact
+dsbsr535 toSci -1.11234551 -> -1.112346 Rounded Inexact
+
+rounding: half_even
+
+-- The 'baddies' tests from DiagBigDecimal, plus some new ones
+dsbas500 toSci '1..2' -> NaN Conversion_syntax
+dsbas501 toSci '.' -> NaN Conversion_syntax
+dsbas502 toSci '..' -> NaN Conversion_syntax
+dsbas503 toSci '++1' -> NaN Conversion_syntax
+dsbas504 toSci '--1' -> NaN Conversion_syntax
+dsbas505 toSci '-+1' -> NaN Conversion_syntax
+dsbas506 toSci '+-1' -> NaN Conversion_syntax
+dsbas507 toSci '12e' -> NaN Conversion_syntax
+dsbas508 toSci '12e++' -> NaN Conversion_syntax
+dsbas509 toSci '12f4' -> NaN Conversion_syntax
+dsbas510 toSci ' +1' -> NaN Conversion_syntax
+dsbas511 toSci '+ 1' -> NaN Conversion_syntax
+dsbas512 toSci '12 ' -> NaN Conversion_syntax
+dsbas513 toSci ' + 1' -> NaN Conversion_syntax
+dsbas514 toSci ' - 1 ' -> NaN Conversion_syntax
+dsbas515 toSci 'x' -> NaN Conversion_syntax
+dsbas516 toSci '-1-' -> NaN Conversion_syntax
+dsbas517 toSci '12-' -> NaN Conversion_syntax
+dsbas518 toSci '3+' -> NaN Conversion_syntax
+dsbas519 toSci '' -> NaN Conversion_syntax
+dsbas520 toSci '1e-' -> NaN Conversion_syntax
+dsbas521 toSci '7e99999a' -> NaN Conversion_syntax
+dsbas522 toSci '7e123567890x' -> NaN Conversion_syntax
+dsbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
+dsbas524 toSci '' -> NaN Conversion_syntax
+dsbas525 toSci 'e100' -> NaN Conversion_syntax
+dsbas526 toSci '\u0e5a' -> NaN Conversion_syntax
+dsbas527 toSci '\u0b65' -> NaN Conversion_syntax
+dsbas528 toSci '123,65' -> NaN Conversion_syntax
+dsbas529 toSci '1.34.5' -> NaN Conversion_syntax
+dsbas530 toSci '.123.5' -> NaN Conversion_syntax
+dsbas531 toSci '01.35.' -> NaN Conversion_syntax
+dsbas532 toSci '01.35-' -> NaN Conversion_syntax
+dsbas533 toSci '0000..' -> NaN Conversion_syntax
+dsbas534 toSci '.0000.' -> NaN Conversion_syntax
+dsbas535 toSci '00..00' -> NaN Conversion_syntax
+dsbas536 toSci '111e*123' -> NaN Conversion_syntax
+dsbas537 toSci '111e123-' -> NaN Conversion_syntax
+dsbas538 toSci '111e+12+' -> NaN Conversion_syntax
+dsbas539 toSci '111e1-3-' -> NaN Conversion_syntax
+dsbas540 toSci '111e1*23' -> NaN Conversion_syntax
+dsbas541 toSci '111e1e+3' -> NaN Conversion_syntax
+dsbas542 toSci '1e1.0' -> NaN Conversion_syntax
+dsbas543 toSci '1e123e' -> NaN Conversion_syntax
+dsbas544 toSci 'ten' -> NaN Conversion_syntax
+dsbas545 toSci 'ONE' -> NaN Conversion_syntax
+dsbas546 toSci '1e.1' -> NaN Conversion_syntax
+dsbas547 toSci '1e1.' -> NaN Conversion_syntax
+dsbas548 toSci '1ee' -> NaN Conversion_syntax
+dsbas549 toSci 'e+1' -> NaN Conversion_syntax
+dsbas550 toSci '1.23.4' -> NaN Conversion_syntax
+dsbas551 toSci '1.2.1' -> NaN Conversion_syntax
+dsbas552 toSci '1E+1.2' -> NaN Conversion_syntax
+dsbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
+dsbas554 toSci '1E++1' -> NaN Conversion_syntax
+dsbas555 toSci '1E--1' -> NaN Conversion_syntax
+dsbas556 toSci '1E+-1' -> NaN Conversion_syntax
+dsbas557 toSci '1E-+1' -> NaN Conversion_syntax
+dsbas558 toSci '1E''1' -> NaN Conversion_syntax
+dsbas559 toSci "1E""1" -> NaN Conversion_syntax
+dsbas560 toSci "1E""""" -> NaN Conversion_syntax
+-- Near-specials
+dsbas561 toSci "qNaN" -> NaN Conversion_syntax
+dsbas562 toSci "NaNq" -> NaN Conversion_syntax
+dsbas563 toSci "NaNs" -> NaN Conversion_syntax
+dsbas564 toSci "Infi" -> NaN Conversion_syntax
+dsbas565 toSci "Infin" -> NaN Conversion_syntax
+dsbas566 toSci "Infini" -> NaN Conversion_syntax
+dsbas567 toSci "Infinit" -> NaN Conversion_syntax
+dsbas568 toSci "-Infinit" -> NaN Conversion_syntax
+dsbas569 toSci "0Inf" -> NaN Conversion_syntax
+dsbas570 toSci "9Inf" -> NaN Conversion_syntax
+dsbas571 toSci "-0Inf" -> NaN Conversion_syntax
+dsbas572 toSci "-9Inf" -> NaN Conversion_syntax
+dsbas573 toSci "-sNa" -> NaN Conversion_syntax
+dsbas574 toSci "xNaN" -> NaN Conversion_syntax
+dsbas575 toSci "0sNaN" -> NaN Conversion_syntax
+
+-- some baddies with dots and Es and dots and specials
+dsbas576 toSci 'e+1' -> NaN Conversion_syntax
+dsbas577 toSci '.e+1' -> NaN Conversion_syntax
+dsbas578 toSci '+.e+1' -> NaN Conversion_syntax
+dsbas579 toSci '-.e+' -> NaN Conversion_syntax
+dsbas580 toSci '-.e' -> NaN Conversion_syntax
+dsbas581 toSci 'E+1' -> NaN Conversion_syntax
+dsbas582 toSci '.E+1' -> NaN Conversion_syntax
+dsbas583 toSci '+.E+1' -> NaN Conversion_syntax
+dsbas584 toSci '-.E+' -> NaN Conversion_syntax
+dsbas585 toSci '-.E' -> NaN Conversion_syntax
+
+dsbas586 toSci '.NaN' -> NaN Conversion_syntax
+dsbas587 toSci '-.NaN' -> NaN Conversion_syntax
+dsbas588 toSci '+.sNaN' -> NaN Conversion_syntax
+dsbas589 toSci '+.Inf' -> NaN Conversion_syntax
+dsbas590 toSci '.Infinity' -> NaN Conversion_syntax
+
+-- Zeros
+dsbas601 toSci 0.000000000 -> 0E-9
+dsbas602 toSci 0.00000000 -> 0E-8
+dsbas603 toSci 0.0000000 -> 0E-7
+dsbas604 toSci 0.000000 -> 0.000000
+dsbas605 toSci 0.00000 -> 0.00000
+dsbas606 toSci 0.0000 -> 0.0000
+dsbas607 toSci 0.000 -> 0.000
+dsbas608 toSci 0.00 -> 0.00
+dsbas609 toSci 0.0 -> 0.0
+dsbas610 toSci .0 -> 0.0
+dsbas611 toSci 0. -> 0
+dsbas612 toSci -.0 -> -0.0
+dsbas613 toSci -0. -> -0
+dsbas614 toSci -0.0 -> -0.0
+dsbas615 toSci -0.00 -> -0.00
+dsbas616 toSci -0.000 -> -0.000
+dsbas617 toSci -0.0000 -> -0.0000
+dsbas618 toSci -0.00000 -> -0.00000
+dsbas619 toSci -0.000000 -> -0.000000
+dsbas620 toSci -0.0000000 -> -0E-7
+dsbas621 toSci -0.00000000 -> -0E-8
+dsbas622 toSci -0.000000000 -> -0E-9
+
+dsbas630 toSci 0.00E+0 -> 0.00
+dsbas631 toSci 0.00E+1 -> 0.0
+dsbas632 toSci 0.00E+2 -> 0
+dsbas633 toSci 0.00E+3 -> 0E+1
+dsbas634 toSci 0.00E+4 -> 0E+2
+dsbas635 toSci 0.00E+5 -> 0E+3
+dsbas636 toSci 0.00E+6 -> 0E+4
+dsbas637 toSci 0.00E+7 -> 0E+5
+dsbas638 toSci 0.00E+8 -> 0E+6
+dsbas639 toSci 0.00E+9 -> 0E+7
+
+dsbas640 toSci 0.0E+0 -> 0.0
+dsbas641 toSci 0.0E+1 -> 0
+dsbas642 toSci 0.0E+2 -> 0E+1
+dsbas643 toSci 0.0E+3 -> 0E+2
+dsbas644 toSci 0.0E+4 -> 0E+3
+dsbas645 toSci 0.0E+5 -> 0E+4
+dsbas646 toSci 0.0E+6 -> 0E+5
+dsbas647 toSci 0.0E+7 -> 0E+6
+dsbas648 toSci 0.0E+8 -> 0E+7
+dsbas649 toSci 0.0E+9 -> 0E+8
+
+dsbas650 toSci 0E+0 -> 0
+dsbas651 toSci 0E+1 -> 0E+1
+dsbas652 toSci 0E+2 -> 0E+2
+dsbas653 toSci 0E+3 -> 0E+3
+dsbas654 toSci 0E+4 -> 0E+4
+dsbas655 toSci 0E+5 -> 0E+5
+dsbas656 toSci 0E+6 -> 0E+6
+dsbas657 toSci 0E+7 -> 0E+7
+dsbas658 toSci 0E+8 -> 0E+8
+dsbas659 toSci 0E+9 -> 0E+9
+
+dsbas660 toSci 0.0E-0 -> 0.0
+dsbas661 toSci 0.0E-1 -> 0.00
+dsbas662 toSci 0.0E-2 -> 0.000
+dsbas663 toSci 0.0E-3 -> 0.0000
+dsbas664 toSci 0.0E-4 -> 0.00000
+dsbas665 toSci 0.0E-5 -> 0.000000
+dsbas666 toSci 0.0E-6 -> 0E-7
+dsbas667 toSci 0.0E-7 -> 0E-8
+dsbas668 toSci 0.0E-8 -> 0E-9
+dsbas669 toSci 0.0E-9 -> 0E-10
+
+dsbas670 toSci 0.00E-0 -> 0.00
+dsbas671 toSci 0.00E-1 -> 0.000
+dsbas672 toSci 0.00E-2 -> 0.0000
+dsbas673 toSci 0.00E-3 -> 0.00000
+dsbas674 toSci 0.00E-4 -> 0.000000
+dsbas675 toSci 0.00E-5 -> 0E-7
+dsbas676 toSci 0.00E-6 -> 0E-8
+dsbas677 toSci 0.00E-7 -> 0E-9
+dsbas678 toSci 0.00E-8 -> 0E-10
+dsbas679 toSci 0.00E-9 -> 0E-11
+
+dsbas680 toSci 000000. -> 0
+dsbas681 toSci 00000. -> 0
+dsbas682 toSci 0000. -> 0
+dsbas683 toSci 000. -> 0
+dsbas684 toSci 00. -> 0
+dsbas685 toSci 0. -> 0
+dsbas686 toSci +00000. -> 0
+dsbas687 toSci -00000. -> -0
+dsbas688 toSci +0. -> 0
+dsbas689 toSci -0. -> -0
+
+-- Specials
+dsbas700 toSci "NaN" -> NaN
+dsbas701 toSci "nan" -> NaN
+dsbas702 toSci "nAn" -> NaN
+dsbas703 toSci "NAN" -> NaN
+dsbas704 toSci "+NaN" -> NaN
+dsbas705 toSci "+nan" -> NaN
+dsbas706 toSci "+nAn" -> NaN
+dsbas707 toSci "+NAN" -> NaN
+dsbas708 toSci "-NaN" -> -NaN
+dsbas709 toSci "-nan" -> -NaN
+dsbas710 toSci "-nAn" -> -NaN
+dsbas711 toSci "-NAN" -> -NaN
+dsbas712 toSci 'NaN0' -> NaN
+dsbas713 toSci 'NaN1' -> NaN1
+dsbas714 toSci 'NaN12' -> NaN12
+dsbas715 toSci 'NaN123' -> NaN123
+dsbas716 toSci 'NaN1234' -> NaN1234
+dsbas717 toSci 'NaN01' -> NaN1
+dsbas718 toSci 'NaN012' -> NaN12
+dsbas719 toSci 'NaN0123' -> NaN123
+dsbas720 toSci 'NaN01234' -> NaN1234
+dsbas721 toSci 'NaN001' -> NaN1
+dsbas722 toSci 'NaN0012' -> NaN12
+dsbas723 toSci 'NaN00123' -> NaN123
+dsbas724 toSci 'NaN001234' -> NaN1234
+dsbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
+dsbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
+dsbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
+dsbas728 toSci 'NaN-12' -> NaN Conversion_syntax
+dsbas729 toSci 'NaN+12' -> NaN Conversion_syntax
+
+dsbas730 toSci "sNaN" -> sNaN
+dsbas731 toSci "snan" -> sNaN
+dsbas732 toSci "SnAn" -> sNaN
+dsbas733 toSci "SNAN" -> sNaN
+dsbas734 toSci "+sNaN" -> sNaN
+dsbas735 toSci "+snan" -> sNaN
+dsbas736 toSci "+SnAn" -> sNaN
+dsbas737 toSci "+SNAN" -> sNaN
+dsbas738 toSci "-sNaN" -> -sNaN
+dsbas739 toSci "-snan" -> -sNaN
+dsbas740 toSci "-SnAn" -> -sNaN
+dsbas741 toSci "-SNAN" -> -sNaN
+dsbas742 toSci 'sNaN0000' -> sNaN
+dsbas743 toSci 'sNaN7' -> sNaN7
+dsbas744 toSci 'sNaN007234' -> sNaN7234
+dsbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
+dsbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
+dsbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
+
+dsbas748 toSci "Inf" -> Infinity
+dsbas749 toSci "inf" -> Infinity
+dsbas750 toSci "iNf" -> Infinity
+dsbas751 toSci "INF" -> Infinity
+dsbas752 toSci "+Inf" -> Infinity
+dsbas753 toSci "+inf" -> Infinity
+dsbas754 toSci "+iNf" -> Infinity
+dsbas755 toSci "+INF" -> Infinity
+dsbas756 toSci "-Inf" -> -Infinity
+dsbas757 toSci "-inf" -> -Infinity
+dsbas758 toSci "-iNf" -> -Infinity
+dsbas759 toSci "-INF" -> -Infinity
+
+dsbas760 toSci "Infinity" -> Infinity
+dsbas761 toSci "infinity" -> Infinity
+dsbas762 toSci "iNfInItY" -> Infinity
+dsbas763 toSci "INFINITY" -> Infinity
+dsbas764 toSci "+Infinity" -> Infinity
+dsbas765 toSci "+infinity" -> Infinity
+dsbas766 toSci "+iNfInItY" -> Infinity
+dsbas767 toSci "+INFINITY" -> Infinity
+dsbas768 toSci "-Infinity" -> -Infinity
+dsbas769 toSci "-infinity" -> -Infinity
+dsbas770 toSci "-iNfInItY" -> -Infinity
+dsbas771 toSci "-INFINITY" -> -Infinity
+
+-- Specials and zeros for toEng
+dsbast772 toEng "NaN" -> NaN
+dsbast773 toEng "-Infinity" -> -Infinity
+dsbast774 toEng "-sNaN" -> -sNaN
+dsbast775 toEng "-NaN" -> -NaN
+dsbast776 toEng "+Infinity" -> Infinity
+dsbast778 toEng "+sNaN" -> sNaN
+dsbast779 toEng "+NaN" -> NaN
+dsbast780 toEng "INFINITY" -> Infinity
+dsbast781 toEng "SNAN" -> sNaN
+dsbast782 toEng "NAN" -> NaN
+dsbast783 toEng "infinity" -> Infinity
+dsbast784 toEng "snan" -> sNaN
+dsbast785 toEng "nan" -> NaN
+dsbast786 toEng "InFINITY" -> Infinity
+dsbast787 toEng "SnAN" -> sNaN
+dsbast788 toEng "nAN" -> NaN
+dsbast789 toEng "iNfinity" -> Infinity
+dsbast790 toEng "sNan" -> sNaN
+dsbast791 toEng "Nan" -> NaN
+dsbast792 toEng "Infinity" -> Infinity
+dsbast793 toEng "sNaN" -> sNaN
+
+-- Zero toEng, etc.
+dsbast800 toEng 0e+1 -> "0.00E+3" -- doc example
+
+dsbast801 toEng 0.000000000 -> 0E-9
+dsbast802 toEng 0.00000000 -> 0.00E-6
+dsbast803 toEng 0.0000000 -> 0.0E-6
+dsbast804 toEng 0.000000 -> 0.000000
+dsbast805 toEng 0.00000 -> 0.00000
+dsbast806 toEng 0.0000 -> 0.0000
+dsbast807 toEng 0.000 -> 0.000
+dsbast808 toEng 0.00 -> 0.00
+dsbast809 toEng 0.0 -> 0.0
+dsbast810 toEng .0 -> 0.0
+dsbast811 toEng 0. -> 0
+dsbast812 toEng -.0 -> -0.0
+dsbast813 toEng -0. -> -0
+dsbast814 toEng -0.0 -> -0.0
+dsbast815 toEng -0.00 -> -0.00
+dsbast816 toEng -0.000 -> -0.000
+dsbast817 toEng -0.0000 -> -0.0000
+dsbast818 toEng -0.00000 -> -0.00000
+dsbast819 toEng -0.000000 -> -0.000000
+dsbast820 toEng -0.0000000 -> -0.0E-6
+dsbast821 toEng -0.00000000 -> -0.00E-6
+dsbast822 toEng -0.000000000 -> -0E-9
+
+dsbast830 toEng 0.00E+0 -> 0.00
+dsbast831 toEng 0.00E+1 -> 0.0
+dsbast832 toEng 0.00E+2 -> 0
+dsbast833 toEng 0.00E+3 -> 0.00E+3
+dsbast834 toEng 0.00E+4 -> 0.0E+3
+dsbast835 toEng 0.00E+5 -> 0E+3
+dsbast836 toEng 0.00E+6 -> 0.00E+6
+dsbast837 toEng 0.00E+7 -> 0.0E+6
+dsbast838 toEng 0.00E+8 -> 0E+6
+dsbast839 toEng 0.00E+9 -> 0.00E+9
+
+dsbast840 toEng 0.0E+0 -> 0.0
+dsbast841 toEng 0.0E+1 -> 0
+dsbast842 toEng 0.0E+2 -> 0.00E+3
+dsbast843 toEng 0.0E+3 -> 0.0E+3
+dsbast844 toEng 0.0E+4 -> 0E+3
+dsbast845 toEng 0.0E+5 -> 0.00E+6
+dsbast846 toEng 0.0E+6 -> 0.0E+6
+dsbast847 toEng 0.0E+7 -> 0E+6
+dsbast848 toEng 0.0E+8 -> 0.00E+9
+dsbast849 toEng 0.0E+9 -> 0.0E+9
+
+dsbast850 toEng 0E+0 -> 0
+dsbast851 toEng 0E+1 -> 0.00E+3
+dsbast852 toEng 0E+2 -> 0.0E+3
+dsbast853 toEng 0E+3 -> 0E+3
+dsbast854 toEng 0E+4 -> 0.00E+6
+dsbast855 toEng 0E+5 -> 0.0E+6
+dsbast856 toEng 0E+6 -> 0E+6
+dsbast857 toEng 0E+7 -> 0.00E+9
+dsbast858 toEng 0E+8 -> 0.0E+9
+dsbast859 toEng 0E+9 -> 0E+9
+
+dsbast860 toEng 0.0E-0 -> 0.0
+dsbast861 toEng 0.0E-1 -> 0.00
+dsbast862 toEng 0.0E-2 -> 0.000
+dsbast863 toEng 0.0E-3 -> 0.0000
+dsbast864 toEng 0.0E-4 -> 0.00000
+dsbast865 toEng 0.0E-5 -> 0.000000
+dsbast866 toEng 0.0E-6 -> 0.0E-6
+dsbast867 toEng 0.0E-7 -> 0.00E-6
+dsbast868 toEng 0.0E-8 -> 0E-9
+dsbast869 toEng 0.0E-9 -> 0.0E-9
+
+dsbast870 toEng 0.00E-0 -> 0.00
+dsbast871 toEng 0.00E-1 -> 0.000
+dsbast872 toEng 0.00E-2 -> 0.0000
+dsbast873 toEng 0.00E-3 -> 0.00000
+dsbast874 toEng 0.00E-4 -> 0.000000
+dsbast875 toEng 0.00E-5 -> 0.0E-6
+dsbast876 toEng 0.00E-6 -> 0.00E-6
+dsbast877 toEng 0.00E-7 -> 0E-9
+dsbast878 toEng 0.00E-8 -> 0.0E-9
+dsbast879 toEng 0.00E-9 -> 0.00E-9
+
+-- long input strings
+dsbas801 tosci '01234567' -> 1234567
+dsbas802 tosci '001234567' -> 1234567
+dsbas803 tosci '0001234567' -> 1234567
+dsbas804 tosci '00001234567' -> 1234567
+dsbas805 tosci '000001234567' -> 1234567
+dsbas806 tosci '0000001234567' -> 1234567
+dsbas807 tosci '00000001234567' -> 1234567
+dsbas808 tosci '000000001234567' -> 1234567
+dsbas809 tosci '0000000001234567' -> 1234567
+dsbas810 tosci '00000000001234567' -> 1234567
+
+dsbas811 tosci '0.1234567' -> 0.1234567
+dsbas812 tosci '0.01234567' -> 0.01234567
+dsbas813 tosci '0.001234567' -> 0.001234567
+dsbas814 tosci '0.0001234567' -> 0.0001234567
+dsbas815 tosci '0.00001234567' -> 0.00001234567
+dsbas816 tosci '0.000001234567' -> 0.000001234567
+dsbas817 tosci '0.0000001234567' -> 1.234567E-7
+dsbas818 tosci '0.00000001234567' -> 1.234567E-8
+dsbas819 tosci '0.000000001234567' -> 1.234567E-9
+dsbas820 tosci '0.0000000001234567' -> 1.234567E-10
+
+dsbas821 tosci '123456790' -> 1.234568E+8 Inexact Rounded
+dsbas822 tosci '1234567901' -> 1.234568E+9 Inexact Rounded
+dsbas823 tosci '12345679012' -> 1.234568E+10 Inexact Rounded
+dsbas824 tosci '123456790123' -> 1.234568E+11 Inexact Rounded
+dsbas825 tosci '1234567901234' -> 1.234568E+12 Inexact Rounded
+dsbas826 tosci '12345679012345' -> 1.234568E+13 Inexact Rounded
+dsbas827 tosci '123456790123456' -> 1.234568E+14 Inexact Rounded
+dsbas828 tosci '1234567901234567' -> 1.234568E+15 Inexact Rounded
+dsbas829 tosci '1234567890123456' -> 1.234568E+15 Inexact Rounded
+
+-- subnormals and overflows
+dsbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
+dsbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
+dsbas908 toSci '0.9e-999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas909 toSci '0.09e-999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
+dsbas911 toSci '10e-1000000000' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
+dsbas913 toSci '99e-9999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
+dsbas915 toSci '1111e-9999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas916 toSci '1111e-99999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
+-- negatives the same
+dsbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
+dsbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
+dsbas920 toSci '-0.9e-999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas921 toSci '-0.09e-999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
+dsbas923 toSci '-10e-1000000000' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
+dsbas925 toSci '-99e-9999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
+dsbas927 toSci '-1111e-9999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas928 toSci '-1111e-99999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
+
+-- overflow results at different rounding modes
+rounding: ceiling
+dsbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas931 toSci '-7e10000' -> -9.999999E+96 Overflow Inexact Rounded
+rounding: up
+dsbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: down
+dsbas934 toSci '7e10000' -> 9.999999E+96 Overflow Inexact Rounded
+dsbas935 toSci '-7e10000' -> -9.999999E+96 Overflow Inexact Rounded
+rounding: floor
+dsbas936 toSci '7e10000' -> 9.999999E+96 Overflow Inexact Rounded
+dsbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_up
+dsbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_even
+dsbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_down
+dsbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_even
+
+-- Now check 854/754r some subnormals and underflow to 0
+dsbem400 toSci 1.0000E-86 -> 1.0000E-86
+dsbem401 toSci 0.1E-97 -> 1E-98 Subnormal
+dsbem402 toSci 0.1000E-97 -> 1.000E-98 Subnormal
+dsbem403 toSci 0.0100E-97 -> 1.00E-99 Subnormal
+dsbem404 toSci 0.0010E-97 -> 1.0E-100 Subnormal
+dsbem405 toSci 0.0001E-97 -> 1E-101 Subnormal
+dsbem406 toSci 0.00010E-97 -> 1E-101 Subnormal Rounded
+dsbem407 toSci 0.00013E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
+dsbem408 toSci 0.00015E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem409 toSci 0.00017E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem410 toSci 0.00023E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem411 toSci 0.00025E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem412 toSci 0.00027E-97 -> 3E-101 Underflow Subnormal Inexact Rounded
+dsbem413 toSci 0.000149E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
+dsbem414 toSci 0.000150E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem415 toSci 0.000151E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem416 toSci 0.000249E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem417 toSci 0.000250E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem418 toSci 0.000251E-97 -> 3E-101 Underflow Subnormal Inexact Rounded
+dsbem419 toSci 0.00009E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
+dsbem420 toSci 0.00005E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem421 toSci 0.00003E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem422 toSci 0.000009E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem423 toSci 0.000005E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem424 toSci 0.000003E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+
+dsbem425 toSci 0.001049E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
+dsbem426 toSci 0.001050E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
+dsbem427 toSci 0.001051E-97 -> 1.1E-100 Underflow Subnormal Inexact Rounded
+dsbem428 toSci 0.001149E-97 -> 1.1E-100 Underflow Subnormal Inexact Rounded
+dsbem429 toSci 0.001150E-97 -> 1.2E-100 Underflow Subnormal Inexact Rounded
+dsbem430 toSci 0.001151E-97 -> 1.2E-100 Underflow Subnormal Inexact Rounded
+
+dsbem432 toSci 0.010049E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
+dsbem433 toSci 0.010050E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
+dsbem434 toSci 0.010051E-97 -> 1.01E-99 Underflow Subnormal Inexact Rounded
+dsbem435 toSci 0.010149E-97 -> 1.01E-99 Underflow Subnormal Inexact Rounded
+dsbem436 toSci 0.010150E-97 -> 1.02E-99 Underflow Subnormal Inexact Rounded
+dsbem437 toSci 0.010151E-97 -> 1.02E-99 Underflow Subnormal Inexact Rounded
+
+dsbem440 toSci 0.10103E-97 -> 1.010E-98 Underflow Subnormal Inexact Rounded
+dsbem441 toSci 0.10105E-97 -> 1.010E-98 Underflow Subnormal Inexact Rounded
+dsbem442 toSci 0.10107E-97 -> 1.011E-98 Underflow Subnormal Inexact Rounded
+dsbem443 toSci 0.10113E-97 -> 1.011E-98 Underflow Subnormal Inexact Rounded
+dsbem444 toSci 0.10115E-97 -> 1.012E-98 Underflow Subnormal Inexact Rounded
+dsbem445 toSci 0.10117E-97 -> 1.012E-98 Underflow Subnormal Inexact Rounded
+
+dsbem450 toSci 1.10730E-98 -> 1.107E-98 Underflow Subnormal Inexact Rounded
+dsbem451 toSci 1.10750E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
+dsbem452 toSci 1.10770E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
+dsbem453 toSci 1.10830E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
+dsbem454 toSci 1.10850E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
+dsbem455 toSci 1.10870E-98 -> 1.109E-98 Underflow Subnormal Inexact Rounded
+
+-- make sure sign OK
+dsbem456 toSci -0.10103E-97 -> -1.010E-98 Underflow Subnormal Inexact Rounded
+dsbem457 toSci -0.10105E-97 -> -1.010E-98 Underflow Subnormal Inexact Rounded
+dsbem458 toSci -0.10107E-97 -> -1.011E-98 Underflow Subnormal Inexact Rounded
+dsbem459 toSci -0.10113E-97 -> -1.011E-98 Underflow Subnormal Inexact Rounded
+dsbem460 toSci -0.10115E-97 -> -1.012E-98 Underflow Subnormal Inexact Rounded
+dsbem461 toSci -0.10117E-97 -> -1.012E-98 Underflow Subnormal Inexact Rounded
+
+-- '999s' cases
+dsbem464 toSci 999999E-98 -> 9.99999E-93
+dsbem465 toSci 99999.0E-97 -> 9.99990E-93
+dsbem466 toSci 99999.E-97 -> 9.9999E-93
+dsbem467 toSci 9999.9E-97 -> 9.9999E-94
+dsbem468 toSci 999.99E-97 -> 9.9999E-95
+dsbem469 toSci 99.999E-97 -> 9.9999E-96 Subnormal
+dsbem470 toSci 9.9999E-97 -> 9.9999E-97 Subnormal
+dsbem471 toSci 0.99999E-97 -> 1.0000E-97 Underflow Subnormal Inexact Rounded
+dsbem472 toSci 0.099999E-97 -> 1.000E-98 Underflow Subnormal Inexact Rounded
+dsbem473 toSci 0.0099999E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
+dsbem474 toSci 0.00099999E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
+dsbem475 toSci 0.000099999E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
+dsbem476 toSci 0.0000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem477 toSci 0.00000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem478 toSci 0.000000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+
+-- Exponents with insignificant leading zeros
+dsbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
+dsbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
+dsbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
+dsbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
+dsbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
+dsbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
+dsbas1007 toSci 1e-999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1008 toSci 1e-0999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1009 toSci 1e-00999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1010 toSci 1e-000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1011 toSci 1e-000000000000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1012 toSci 1e-000000000001000000007 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+
+-- check for double-rounded subnormals
+dsbas1041 toSci 1.1152444E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
+dsbas1042 toSci 1.1152445E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
+dsbas1043 toSci 1.1152446E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
+
+-- clamped zeros [see also clamp.decTest]
+dsbas1075 toSci 0e+10000 -> 0E+90 Clamped
+dsbas1076 toSci 0e-10000 -> 0E-101 Clamped
+dsbas1077 toSci -0e+10000 -> -0E+90 Clamped
+dsbas1078 toSci -0e-10000 -> -0E-101 Clamped
+
+-- extreme values from next-wider
+dsbas1101 toSci -9.999999999999999E+384 -> -Infinity Overflow Inexact Rounded
+dsbas1102 toSci -1E-383 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
+dsbas1103 toSci -1E-398 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
+dsbas1104 toSci -0 -> -0
+dsbas1105 toSci +0 -> 0
+dsbas1106 toSci +1E-398 -> 0E-101 Inexact Rounded Subnormal Underflow Clamped
+dsbas1107 toSci +1E-383 -> 0E-101 Inexact Rounded Subnormal Underflow Clamped
+dsbas1108 toSci +9.999999999999999E+384 -> Infinity Overflow Inexact Rounded
+
+-- narrowing case
+dsbas1110 toSci 2.000000000000000E-99 -> 2.00E-99 Rounded Subnormal
diff --git a/Lib/test/decimaltestdata/dsEncode.decTest b/Lib/test/decimaltestdata/dsEncode.decTest
index 818578b179..7264748759 100644
--- a/Lib/test/decimaltestdata/dsEncode.decTest
+++ b/Lib/test/decimaltestdata/dsEncode.decTest
@@ -1,372 +1,372 @@
-------------------------------------------------------------------------
--- dsEncode.decTest -- decimal four-byte format testcases --
--- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
--- [Previously called decimal32.decTest]
-version: 2.59
-
--- This set of tests is for the four-byte concrete representation.
--- Its characteristics are:
---
--- 1 bit sign
--- 5 bits combination field
--- 6 bits exponent continuation
--- 20 bits coefficient continuation
---
--- Total exponent length 8 bits
--- Total coefficient length 24 bits (7 digits)
---
--- Elimit = 191 (maximum encoded exponent)
--- Emax = 96 (largest exponent value)
--- Emin = -95 (smallest exponent value)
--- bias = 101 (subtracted from encoded exponent) = -Etiny
-
--- The testcases here have only exactly representable data on the
--- 'left-hand-side'; rounding from strings is tested in 'base'
--- testcase groups.
-
-extended: 1
-clamp: 1
-precision: 7
-rounding: half_up
-maxExponent: 96
-minExponent: -95
-
--- General testcases
--- (mostly derived from the Strawman 4 document and examples)
-decs001 apply #A23003D0 -> -7.50
-decs002 apply -7.50 -> #A23003D0
--- derivative canonical plain strings
-decs003 apply #A26003D0 -> -7.50E+3
-decs004 apply -7.50E+3 -> #A26003D0
-decs005 apply #A25003D0 -> -750
-decs006 apply -750 -> #A25003D0
-decs007 apply #A24003D0 -> -75.0
-decs008 apply -75.0 -> #A24003D0
-decs009 apply #A22003D0 -> -0.750
-decs010 apply -0.750 -> #A22003D0
-decs011 apply #A21003D0 -> -0.0750
-decs012 apply -0.0750 -> #A21003D0
-decs013 apply #A1f003D0 -> -0.000750
-decs014 apply -0.000750 -> #A1f003D0
-decs015 apply #A1d003D0 -> -0.00000750
-decs016 apply -0.00000750 -> #A1d003D0
-decs017 apply #A1c003D0 -> -7.50E-7
-decs018 apply -7.50E-7 -> #A1c003D0
-
--- Normality
-decs020 apply 1234567 -> #2654d2e7
-decs021 apply -1234567 -> #a654d2e7
-decs022 apply 1111111 -> #26524491
-
--- Nmax and similar
-decs031 apply 9.999999E+96 -> #77f3fcff
-decs032 apply #77f3fcff -> 9.999999E+96
-decs033 apply 1.234567E+96 -> #47f4d2e7
-decs034 apply #47f4d2e7 -> 1.234567E+96
--- fold-downs (more below)
-decs035 apply 1.23E+96 -> #47f4c000 Clamped
-decs036 apply #47f4c000 -> 1.230000E+96
-decs037 apply 1E+96 -> #47f00000 Clamped
-decs038 apply #47f00000 -> 1.000000E+96
-
-decs051 apply 12345 -> #225049c5
-decs052 apply #225049c5 -> 12345
-decs053 apply 1234 -> #22500534
-decs054 apply #22500534 -> 1234
-decs055 apply 123 -> #225000a3
-decs056 apply #225000a3 -> 123
-decs057 apply 12 -> #22500012
-decs058 apply #22500012 -> 12
-decs059 apply 1 -> #22500001
-decs060 apply #22500001 -> 1
-decs061 apply 1.23 -> #223000a3
-decs062 apply #223000a3 -> 1.23
-decs063 apply 123.45 -> #223049c5
-decs064 apply #223049c5 -> 123.45
-
--- Nmin and below
-decs071 apply 1E-95 -> #00600001
-decs072 apply #00600001 -> 1E-95
-decs073 apply 1.000000E-95 -> #04000000
-decs074 apply #04000000 -> 1.000000E-95
-decs075 apply 1.000001E-95 -> #04000001
-decs076 apply #04000001 -> 1.000001E-95
-
-decs077 apply 0.100000E-95 -> #00020000 Subnormal
-decs07x apply 1.00000E-96 -> 1.00000E-96 Subnormal
-decs078 apply #00020000 -> 1.00000E-96 Subnormal
-decs079 apply 0.000010E-95 -> #00000010 Subnormal
-decs080 apply #00000010 -> 1.0E-100 Subnormal
-decs081 apply 0.000001E-95 -> #00000001 Subnormal
-decs082 apply #00000001 -> 1E-101 Subnormal
-decs083 apply 1e-101 -> #00000001 Subnormal
-decs084 apply #00000001 -> 1E-101 Subnormal
-decs08x apply 1e-101 -> 1E-101 Subnormal
-
--- underflows cannot be tested; just check edge case
-decs090 apply 1e-101 -> #00000001 Subnormal
-
--- same again, negatives --
-
--- Nmax and similar
-decs122 apply -9.999999E+96 -> #f7f3fcff
-decs123 apply #f7f3fcff -> -9.999999E+96
-decs124 apply -1.234567E+96 -> #c7f4d2e7
-decs125 apply #c7f4d2e7 -> -1.234567E+96
--- fold-downs (more below)
-decs130 apply -1.23E+96 -> #c7f4c000 Clamped
-decs131 apply #c7f4c000 -> -1.230000E+96
-decs132 apply -1E+96 -> #c7f00000 Clamped
-decs133 apply #c7f00000 -> -1.000000E+96
-
-decs151 apply -12345 -> #a25049c5
-decs152 apply #a25049c5 -> -12345
-decs153 apply -1234 -> #a2500534
-decs154 apply #a2500534 -> -1234
-decs155 apply -123 -> #a25000a3
-decs156 apply #a25000a3 -> -123
-decs157 apply -12 -> #a2500012
-decs158 apply #a2500012 -> -12
-decs159 apply -1 -> #a2500001
-decs160 apply #a2500001 -> -1
-decs161 apply -1.23 -> #a23000a3
-decs162 apply #a23000a3 -> -1.23
-decs163 apply -123.45 -> #a23049c5
-decs164 apply #a23049c5 -> -123.45
-
--- Nmin and below
-decs171 apply -1E-95 -> #80600001
-decs172 apply #80600001 -> -1E-95
-decs173 apply -1.000000E-95 -> #84000000
-decs174 apply #84000000 -> -1.000000E-95
-decs175 apply -1.000001E-95 -> #84000001
-decs176 apply #84000001 -> -1.000001E-95
-
-decs177 apply -0.100000E-95 -> #80020000 Subnormal
-decs178 apply #80020000 -> -1.00000E-96 Subnormal
-decs179 apply -0.000010E-95 -> #80000010 Subnormal
-decs180 apply #80000010 -> -1.0E-100 Subnormal
-decs181 apply -0.000001E-95 -> #80000001 Subnormal
-decs182 apply #80000001 -> -1E-101 Subnormal
-decs183 apply -1e-101 -> #80000001 Subnormal
-decs184 apply #80000001 -> -1E-101 Subnormal
-
--- underflow edge case
-decs190 apply -1e-101 -> #80000001 Subnormal
-
--- zeros
-decs400 apply 0E-400 -> #00000000 Clamped
-decs401 apply 0E-101 -> #00000000
-decs402 apply #00000000 -> 0E-101
-decs403 apply 0.000000E-95 -> #00000000
-decs404 apply #00000000 -> 0E-101
-decs405 apply 0E-2 -> #22300000
-decs406 apply #22300000 -> 0.00
-decs407 apply 0 -> #22500000
-decs408 apply #22500000 -> 0
-decs409 apply 0E+3 -> #22800000
-decs410 apply #22800000 -> 0E+3
-decs411 apply 0E+90 -> #43f00000
-decs412 apply #43f00000 -> 0E+90
--- clamped zeros...
-decs413 apply 0E+91 -> #43f00000 Clamped
-decs414 apply #43f00000 -> 0E+90
-decs415 apply 0E+96 -> #43f00000 Clamped
-decs416 apply #43f00000 -> 0E+90
-decs417 apply 0E+400 -> #43f00000 Clamped
-decs418 apply #43f00000 -> 0E+90
-
--- negative zeros
-decs420 apply -0E-400 -> #80000000 Clamped
-decs421 apply -0E-101 -> #80000000
-decs422 apply #80000000 -> -0E-101
-decs423 apply -0.000000E-95 -> #80000000
-decs424 apply #80000000 -> -0E-101
-decs425 apply -0E-2 -> #a2300000
-decs426 apply #a2300000 -> -0.00
-decs427 apply -0 -> #a2500000
-decs428 apply #a2500000 -> -0
-decs429 apply -0E+3 -> #a2800000
-decs430 apply #a2800000 -> -0E+3
-decs431 apply -0E+90 -> #c3f00000
-decs432 apply #c3f00000 -> -0E+90
--- clamped zeros...
-decs433 apply -0E+91 -> #c3f00000 Clamped
-decs434 apply #c3f00000 -> -0E+90
-decs435 apply -0E+96 -> #c3f00000 Clamped
-decs436 apply #c3f00000 -> -0E+90
-decs437 apply -0E+400 -> #c3f00000 Clamped
-decs438 apply #c3f00000 -> -0E+90
-
--- Specials
-decs500 apply Infinity -> #78000000
-decs501 apply #78787878 -> #78000000
-decs502 apply #78000000 -> Infinity
-decs503 apply #79797979 -> #78000000
-decs504 apply #79000000 -> Infinity
-decs505 apply #7a7a7a7a -> #78000000
-decs506 apply #7a000000 -> Infinity
-decs507 apply #7b7b7b7b -> #78000000
-decs508 apply #7b000000 -> Infinity
-decs509 apply #7c7c7c7c -> #7c0c7c7c
-
-decs510 apply NaN -> #7c000000
-decs511 apply #7c000000 -> NaN
-decs512 apply #7d7d7d7d -> #7c0d7d7d
-decs513 apply #7d000000 -> NaN
-decs514 apply #7e7e7e7e -> #7e0e7c7e
-decs515 apply #7e000000 -> sNaN
-decs516 apply #7f7f7f7f -> #7e0f7c7f
-decs517 apply #7f000000 -> sNaN
-decs518 apply #7fffffff -> sNaN999999
-decs519 apply #7fffffff -> #7e03fcff
-
-decs520 apply -Infinity -> #f8000000
-decs521 apply #f8787878 -> #f8000000
-decs522 apply #f8000000 -> -Infinity
-decs523 apply #f9797979 -> #f8000000
-decs524 apply #f9000000 -> -Infinity
-decs525 apply #fa7a7a7a -> #f8000000
-decs526 apply #fa000000 -> -Infinity
-decs527 apply #fb7b7b7b -> #f8000000
-decs528 apply #fb000000 -> -Infinity
-
-decs529 apply -NaN -> #fc000000
-decs530 apply #fc7c7c7c -> #fc0c7c7c
-decs531 apply #fc000000 -> -NaN
-decs532 apply #fd7d7d7d -> #fc0d7d7d
-decs533 apply #fd000000 -> -NaN
-decs534 apply #fe7e7e7e -> #fe0e7c7e
-decs535 apply #fe000000 -> -sNaN
-decs536 apply #ff7f7f7f -> #fe0f7c7f
-decs537 apply #ff000000 -> -sNaN
-decs538 apply #ffffffff -> -sNaN999999
-decs539 apply #ffffffff -> #fe03fcff
-
--- diagnostic NaNs
-decs540 apply NaN -> #7c000000
-decs541 apply NaN0 -> #7c000000
-decs542 apply NaN1 -> #7c000001
-decs543 apply NaN12 -> #7c000012
-decs544 apply NaN79 -> #7c000079
-decs545 apply NaN12345 -> #7c0049c5
-decs546 apply NaN123456 -> #7c028e56
-decs547 apply NaN799799 -> #7c0f7fdf
-decs548 apply NaN999999 -> #7c03fcff
-
-
--- fold-down full sequence
-decs601 apply 1E+96 -> #47f00000 Clamped
-decs602 apply #47f00000 -> 1.000000E+96
-decs603 apply 1E+95 -> #43f20000 Clamped
-decs604 apply #43f20000 -> 1.00000E+95
-decs605 apply 1E+94 -> #43f04000 Clamped
-decs606 apply #43f04000 -> 1.0000E+94
-decs607 apply 1E+93 -> #43f00400 Clamped
-decs608 apply #43f00400 -> 1.000E+93
-decs609 apply 1E+92 -> #43f00080 Clamped
-decs610 apply #43f00080 -> 1.00E+92
-decs611 apply 1E+91 -> #43f00010 Clamped
-decs612 apply #43f00010 -> 1.0E+91
-decs613 apply 1E+90 -> #43f00001
-decs614 apply #43f00001 -> 1E+90
-
-
--- Selected DPD codes
-decs700 apply #22500000 -> 0
-decs701 apply #22500009 -> 9
-decs702 apply #22500010 -> 10
-decs703 apply #22500019 -> 19
-decs704 apply #22500020 -> 20
-decs705 apply #22500029 -> 29
-decs706 apply #22500030 -> 30
-decs707 apply #22500039 -> 39
-decs708 apply #22500040 -> 40
-decs709 apply #22500049 -> 49
-decs710 apply #22500050 -> 50
-decs711 apply #22500059 -> 59
-decs712 apply #22500060 -> 60
-decs713 apply #22500069 -> 69
-decs714 apply #22500070 -> 70
-decs715 apply #22500071 -> 71
-decs716 apply #22500072 -> 72
-decs717 apply #22500073 -> 73
-decs718 apply #22500074 -> 74
-decs719 apply #22500075 -> 75
-decs720 apply #22500076 -> 76
-decs721 apply #22500077 -> 77
-decs722 apply #22500078 -> 78
-decs723 apply #22500079 -> 79
-
-decs730 apply #2250029e -> 994
-decs731 apply #2250029f -> 995
-decs732 apply #225002a0 -> 520
-decs733 apply #225002a1 -> 521
-
--- DPD: one of each of the huffman groups
-decs740 apply #225003f7 -> 777
-decs741 apply #225003f8 -> 778
-decs742 apply #225003eb -> 787
-decs743 apply #2250037d -> 877
-decs744 apply #2250039f -> 997
-decs745 apply #225003bf -> 979
-decs746 apply #225003df -> 799
-decs747 apply #2250006e -> 888
-
-
--- DPD all-highs cases (includes the 24 redundant codes)
-decs750 apply #2250006e -> 888
-decs751 apply #2250016e -> 888
-decs752 apply #2250026e -> 888
-decs753 apply #2250036e -> 888
-decs754 apply #2250006f -> 889
-decs755 apply #2250016f -> 889
-decs756 apply #2250026f -> 889
-decs757 apply #2250036f -> 889
-
-decs760 apply #2250007e -> 898
-decs761 apply #2250017e -> 898
-decs762 apply #2250027e -> 898
-decs763 apply #2250037e -> 898
-decs764 apply #2250007f -> 899
-decs765 apply #2250017f -> 899
-decs766 apply #2250027f -> 899
-decs767 apply #2250037f -> 899
-
-decs770 apply #225000ee -> 988
-decs771 apply #225001ee -> 988
-decs772 apply #225002ee -> 988
-decs773 apply #225003ee -> 988
-decs774 apply #225000ef -> 989
-decs775 apply #225001ef -> 989
-decs776 apply #225002ef -> 989
-decs777 apply #225003ef -> 989
-
-decs780 apply #225000fe -> 998
-decs781 apply #225001fe -> 998
-decs782 apply #225002fe -> 998
-decs783 apply #225003fe -> 998
-decs784 apply #225000ff -> 999
-decs785 apply #225001ff -> 999
-decs786 apply #225002ff -> 999
-decs787 apply #225003ff -> 999
-
--- narrowing case
-decs790 apply 2.00E-99 -> #00000100 Subnormal
-decs791 apply #00000100 -> 2.00E-99 Subnormal
+------------------------------------------------------------------------
+-- dsEncode.decTest -- decimal four-byte format testcases --
+-- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+-- [Previously called decimal32.decTest]
+version: 2.59
+
+-- This set of tests is for the four-byte concrete representation.
+-- Its characteristics are:
+--
+-- 1 bit sign
+-- 5 bits combination field
+-- 6 bits exponent continuation
+-- 20 bits coefficient continuation
+--
+-- Total exponent length 8 bits
+-- Total coefficient length 24 bits (7 digits)
+--
+-- Elimit = 191 (maximum encoded exponent)
+-- Emax = 96 (largest exponent value)
+-- Emin = -95 (smallest exponent value)
+-- bias = 101 (subtracted from encoded exponent) = -Etiny
+
+-- The testcases here have only exactly representable data on the
+-- 'left-hand-side'; rounding from strings is tested in 'base'
+-- testcase groups.
+
+extended: 1
+clamp: 1
+precision: 7
+rounding: half_up
+maxExponent: 96
+minExponent: -95
+
+-- General testcases
+-- (mostly derived from the Strawman 4 document and examples)
+decs001 apply #A23003D0 -> -7.50
+decs002 apply -7.50 -> #A23003D0
+-- derivative canonical plain strings
+decs003 apply #A26003D0 -> -7.50E+3
+decs004 apply -7.50E+3 -> #A26003D0
+decs005 apply #A25003D0 -> -750
+decs006 apply -750 -> #A25003D0
+decs007 apply #A24003D0 -> -75.0
+decs008 apply -75.0 -> #A24003D0
+decs009 apply #A22003D0 -> -0.750
+decs010 apply -0.750 -> #A22003D0
+decs011 apply #A21003D0 -> -0.0750
+decs012 apply -0.0750 -> #A21003D0
+decs013 apply #A1f003D0 -> -0.000750
+decs014 apply -0.000750 -> #A1f003D0
+decs015 apply #A1d003D0 -> -0.00000750
+decs016 apply -0.00000750 -> #A1d003D0
+decs017 apply #A1c003D0 -> -7.50E-7
+decs018 apply -7.50E-7 -> #A1c003D0
+
+-- Normality
+decs020 apply 1234567 -> #2654d2e7
+decs021 apply -1234567 -> #a654d2e7
+decs022 apply 1111111 -> #26524491
+
+-- Nmax and similar
+decs031 apply 9.999999E+96 -> #77f3fcff
+decs032 apply #77f3fcff -> 9.999999E+96
+decs033 apply 1.234567E+96 -> #47f4d2e7
+decs034 apply #47f4d2e7 -> 1.234567E+96
+-- fold-downs (more below)
+decs035 apply 1.23E+96 -> #47f4c000 Clamped
+decs036 apply #47f4c000 -> 1.230000E+96
+decs037 apply 1E+96 -> #47f00000 Clamped
+decs038 apply #47f00000 -> 1.000000E+96
+
+decs051 apply 12345 -> #225049c5
+decs052 apply #225049c5 -> 12345
+decs053 apply 1234 -> #22500534
+decs054 apply #22500534 -> 1234
+decs055 apply 123 -> #225000a3
+decs056 apply #225000a3 -> 123
+decs057 apply 12 -> #22500012
+decs058 apply #22500012 -> 12
+decs059 apply 1 -> #22500001
+decs060 apply #22500001 -> 1
+decs061 apply 1.23 -> #223000a3
+decs062 apply #223000a3 -> 1.23
+decs063 apply 123.45 -> #223049c5
+decs064 apply #223049c5 -> 123.45
+
+-- Nmin and below
+decs071 apply 1E-95 -> #00600001
+decs072 apply #00600001 -> 1E-95
+decs073 apply 1.000000E-95 -> #04000000
+decs074 apply #04000000 -> 1.000000E-95
+decs075 apply 1.000001E-95 -> #04000001
+decs076 apply #04000001 -> 1.000001E-95
+
+decs077 apply 0.100000E-95 -> #00020000 Subnormal
+decs07x apply 1.00000E-96 -> 1.00000E-96 Subnormal
+decs078 apply #00020000 -> 1.00000E-96 Subnormal
+decs079 apply 0.000010E-95 -> #00000010 Subnormal
+decs080 apply #00000010 -> 1.0E-100 Subnormal
+decs081 apply 0.000001E-95 -> #00000001 Subnormal
+decs082 apply #00000001 -> 1E-101 Subnormal
+decs083 apply 1e-101 -> #00000001 Subnormal
+decs084 apply #00000001 -> 1E-101 Subnormal
+decs08x apply 1e-101 -> 1E-101 Subnormal
+
+-- underflows cannot be tested; just check edge case
+decs090 apply 1e-101 -> #00000001 Subnormal
+
+-- same again, negatives --
+
+-- Nmax and similar
+decs122 apply -9.999999E+96 -> #f7f3fcff
+decs123 apply #f7f3fcff -> -9.999999E+96
+decs124 apply -1.234567E+96 -> #c7f4d2e7
+decs125 apply #c7f4d2e7 -> -1.234567E+96
+-- fold-downs (more below)
+decs130 apply -1.23E+96 -> #c7f4c000 Clamped
+decs131 apply #c7f4c000 -> -1.230000E+96
+decs132 apply -1E+96 -> #c7f00000 Clamped
+decs133 apply #c7f00000 -> -1.000000E+96
+
+decs151 apply -12345 -> #a25049c5
+decs152 apply #a25049c5 -> -12345
+decs153 apply -1234 -> #a2500534
+decs154 apply #a2500534 -> -1234
+decs155 apply -123 -> #a25000a3
+decs156 apply #a25000a3 -> -123
+decs157 apply -12 -> #a2500012
+decs158 apply #a2500012 -> -12
+decs159 apply -1 -> #a2500001
+decs160 apply #a2500001 -> -1
+decs161 apply -1.23 -> #a23000a3
+decs162 apply #a23000a3 -> -1.23
+decs163 apply -123.45 -> #a23049c5
+decs164 apply #a23049c5 -> -123.45
+
+-- Nmin and below
+decs171 apply -1E-95 -> #80600001
+decs172 apply #80600001 -> -1E-95
+decs173 apply -1.000000E-95 -> #84000000
+decs174 apply #84000000 -> -1.000000E-95
+decs175 apply -1.000001E-95 -> #84000001
+decs176 apply #84000001 -> -1.000001E-95
+
+decs177 apply -0.100000E-95 -> #80020000 Subnormal
+decs178 apply #80020000 -> -1.00000E-96 Subnormal
+decs179 apply -0.000010E-95 -> #80000010 Subnormal
+decs180 apply #80000010 -> -1.0E-100 Subnormal
+decs181 apply -0.000001E-95 -> #80000001 Subnormal
+decs182 apply #80000001 -> -1E-101 Subnormal
+decs183 apply -1e-101 -> #80000001 Subnormal
+decs184 apply #80000001 -> -1E-101 Subnormal
+
+-- underflow edge case
+decs190 apply -1e-101 -> #80000001 Subnormal
+
+-- zeros
+decs400 apply 0E-400 -> #00000000 Clamped
+decs401 apply 0E-101 -> #00000000
+decs402 apply #00000000 -> 0E-101
+decs403 apply 0.000000E-95 -> #00000000
+decs404 apply #00000000 -> 0E-101
+decs405 apply 0E-2 -> #22300000
+decs406 apply #22300000 -> 0.00
+decs407 apply 0 -> #22500000
+decs408 apply #22500000 -> 0
+decs409 apply 0E+3 -> #22800000
+decs410 apply #22800000 -> 0E+3
+decs411 apply 0E+90 -> #43f00000
+decs412 apply #43f00000 -> 0E+90
+-- clamped zeros...
+decs413 apply 0E+91 -> #43f00000 Clamped
+decs414 apply #43f00000 -> 0E+90
+decs415 apply 0E+96 -> #43f00000 Clamped
+decs416 apply #43f00000 -> 0E+90
+decs417 apply 0E+400 -> #43f00000 Clamped
+decs418 apply #43f00000 -> 0E+90
+
+-- negative zeros
+decs420 apply -0E-400 -> #80000000 Clamped
+decs421 apply -0E-101 -> #80000000
+decs422 apply #80000000 -> -0E-101
+decs423 apply -0.000000E-95 -> #80000000
+decs424 apply #80000000 -> -0E-101
+decs425 apply -0E-2 -> #a2300000
+decs426 apply #a2300000 -> -0.00
+decs427 apply -0 -> #a2500000
+decs428 apply #a2500000 -> -0
+decs429 apply -0E+3 -> #a2800000
+decs430 apply #a2800000 -> -0E+3
+decs431 apply -0E+90 -> #c3f00000
+decs432 apply #c3f00000 -> -0E+90
+-- clamped zeros...
+decs433 apply -0E+91 -> #c3f00000 Clamped
+decs434 apply #c3f00000 -> -0E+90
+decs435 apply -0E+96 -> #c3f00000 Clamped
+decs436 apply #c3f00000 -> -0E+90
+decs437 apply -0E+400 -> #c3f00000 Clamped
+decs438 apply #c3f00000 -> -0E+90
+
+-- Specials
+decs500 apply Infinity -> #78000000
+decs501 apply #78787878 -> #78000000
+decs502 apply #78000000 -> Infinity
+decs503 apply #79797979 -> #78000000
+decs504 apply #79000000 -> Infinity
+decs505 apply #7a7a7a7a -> #78000000
+decs506 apply #7a000000 -> Infinity
+decs507 apply #7b7b7b7b -> #78000000
+decs508 apply #7b000000 -> Infinity
+decs509 apply #7c7c7c7c -> #7c0c7c7c
+
+decs510 apply NaN -> #7c000000
+decs511 apply #7c000000 -> NaN
+decs512 apply #7d7d7d7d -> #7c0d7d7d
+decs513 apply #7d000000 -> NaN
+decs514 apply #7e7e7e7e -> #7e0e7c7e
+decs515 apply #7e000000 -> sNaN
+decs516 apply #7f7f7f7f -> #7e0f7c7f
+decs517 apply #7f000000 -> sNaN
+decs518 apply #7fffffff -> sNaN999999
+decs519 apply #7fffffff -> #7e03fcff
+
+decs520 apply -Infinity -> #f8000000
+decs521 apply #f8787878 -> #f8000000
+decs522 apply #f8000000 -> -Infinity
+decs523 apply #f9797979 -> #f8000000
+decs524 apply #f9000000 -> -Infinity
+decs525 apply #fa7a7a7a -> #f8000000
+decs526 apply #fa000000 -> -Infinity
+decs527 apply #fb7b7b7b -> #f8000000
+decs528 apply #fb000000 -> -Infinity
+
+decs529 apply -NaN -> #fc000000
+decs530 apply #fc7c7c7c -> #fc0c7c7c
+decs531 apply #fc000000 -> -NaN
+decs532 apply #fd7d7d7d -> #fc0d7d7d
+decs533 apply #fd000000 -> -NaN
+decs534 apply #fe7e7e7e -> #fe0e7c7e
+decs535 apply #fe000000 -> -sNaN
+decs536 apply #ff7f7f7f -> #fe0f7c7f
+decs537 apply #ff000000 -> -sNaN
+decs538 apply #ffffffff -> -sNaN999999
+decs539 apply #ffffffff -> #fe03fcff
+
+-- diagnostic NaNs
+decs540 apply NaN -> #7c000000
+decs541 apply NaN0 -> #7c000000
+decs542 apply NaN1 -> #7c000001
+decs543 apply NaN12 -> #7c000012
+decs544 apply NaN79 -> #7c000079
+decs545 apply NaN12345 -> #7c0049c5
+decs546 apply NaN123456 -> #7c028e56
+decs547 apply NaN799799 -> #7c0f7fdf
+decs548 apply NaN999999 -> #7c03fcff
+
+
+-- fold-down full sequence
+decs601 apply 1E+96 -> #47f00000 Clamped
+decs602 apply #47f00000 -> 1.000000E+96
+decs603 apply 1E+95 -> #43f20000 Clamped
+decs604 apply #43f20000 -> 1.00000E+95
+decs605 apply 1E+94 -> #43f04000 Clamped
+decs606 apply #43f04000 -> 1.0000E+94
+decs607 apply 1E+93 -> #43f00400 Clamped
+decs608 apply #43f00400 -> 1.000E+93
+decs609 apply 1E+92 -> #43f00080 Clamped
+decs610 apply #43f00080 -> 1.00E+92
+decs611 apply 1E+91 -> #43f00010 Clamped
+decs612 apply #43f00010 -> 1.0E+91
+decs613 apply 1E+90 -> #43f00001
+decs614 apply #43f00001 -> 1E+90
+
+
+-- Selected DPD codes
+decs700 apply #22500000 -> 0
+decs701 apply #22500009 -> 9
+decs702 apply #22500010 -> 10
+decs703 apply #22500019 -> 19
+decs704 apply #22500020 -> 20
+decs705 apply #22500029 -> 29
+decs706 apply #22500030 -> 30
+decs707 apply #22500039 -> 39
+decs708 apply #22500040 -> 40
+decs709 apply #22500049 -> 49
+decs710 apply #22500050 -> 50
+decs711 apply #22500059 -> 59
+decs712 apply #22500060 -> 60
+decs713 apply #22500069 -> 69
+decs714 apply #22500070 -> 70
+decs715 apply #22500071 -> 71
+decs716 apply #22500072 -> 72
+decs717 apply #22500073 -> 73
+decs718 apply #22500074 -> 74
+decs719 apply #22500075 -> 75
+decs720 apply #22500076 -> 76
+decs721 apply #22500077 -> 77
+decs722 apply #22500078 -> 78
+decs723 apply #22500079 -> 79
+
+decs730 apply #2250029e -> 994
+decs731 apply #2250029f -> 995
+decs732 apply #225002a0 -> 520
+decs733 apply #225002a1 -> 521
+
+-- DPD: one of each of the huffman groups
+decs740 apply #225003f7 -> 777
+decs741 apply #225003f8 -> 778
+decs742 apply #225003eb -> 787
+decs743 apply #2250037d -> 877
+decs744 apply #2250039f -> 997
+decs745 apply #225003bf -> 979
+decs746 apply #225003df -> 799
+decs747 apply #2250006e -> 888
+
+
+-- DPD all-highs cases (includes the 24 redundant codes)
+decs750 apply #2250006e -> 888
+decs751 apply #2250016e -> 888
+decs752 apply #2250026e -> 888
+decs753 apply #2250036e -> 888
+decs754 apply #2250006f -> 889
+decs755 apply #2250016f -> 889
+decs756 apply #2250026f -> 889
+decs757 apply #2250036f -> 889
+
+decs760 apply #2250007e -> 898
+decs761 apply #2250017e -> 898
+decs762 apply #2250027e -> 898
+decs763 apply #2250037e -> 898
+decs764 apply #2250007f -> 899
+decs765 apply #2250017f -> 899
+decs766 apply #2250027f -> 899
+decs767 apply #2250037f -> 899
+
+decs770 apply #225000ee -> 988
+decs771 apply #225001ee -> 988
+decs772 apply #225002ee -> 988
+decs773 apply #225003ee -> 988
+decs774 apply #225000ef -> 989
+decs775 apply #225001ef -> 989
+decs776 apply #225002ef -> 989
+decs777 apply #225003ef -> 989
+
+decs780 apply #225000fe -> 998
+decs781 apply #225001fe -> 998
+decs782 apply #225002fe -> 998
+decs783 apply #225003fe -> 998
+decs784 apply #225000ff -> 999
+decs785 apply #225001ff -> 999
+decs786 apply #225002ff -> 999
+decs787 apply #225003ff -> 999
+
+-- narrowing case
+decs790 apply 2.00E-99 -> #00000100 Subnormal
+decs791 apply #00000100 -> 2.00E-99 Subnormal
diff --git a/Lib/test/decimaltestdata/exp.decTest b/Lib/test/decimaltestdata/exp.decTest
index eab990d3ef..021b478ac2 100644
--- a/Lib/test/decimaltestdata/exp.decTest
+++ b/Lib/test/decimaltestdata/exp.decTest
@@ -1,674 +1,674 @@
-------------------------------------------------------------------------
--- exp.decTest -- decimal natural exponentiation --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Tests of the exponential funtion. Currently all testcases here
--- show results which are correctly rounded (within <= 0.5 ulp).
-
-extended: 1
-precision: 9
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- basics (examples in specificiation, etc.)
-expx001 exp -Infinity -> 0
-expx002 exp -10 -> 0.0000453999298 Inexact Rounded
-expx003 exp -1 -> 0.367879441 Inexact Rounded
-expx004 exp 0 -> 1
-expx005 exp -0 -> 1
-expx006 exp 1 -> 2.71828183 Inexact Rounded
-expx007 exp 0.693147181 -> 2.00000000 Inexact Rounded
-expx008 exp 10 -> 22026.4658 Inexact Rounded
-expx009 exp +Infinity -> Infinity
-
--- tiny edge cases
-precision: 7
-expx011 exp 0.1 -> 1.105171 Inexact Rounded
-expx012 exp 0.01 -> 1.010050 Inexact Rounded
-expx013 exp 0.001 -> 1.001001 Inexact Rounded
-expx014 exp 0.0001 -> 1.000100 Inexact Rounded
-expx015 exp 0.00001 -> 1.000010 Inexact Rounded
-expx016 exp 0.000001 -> 1.000001 Inexact Rounded
-expx017 exp 0.0000001 -> 1.000000 Inexact Rounded
-expx018 exp 0.0000003 -> 1.000000 Inexact Rounded
-expx019 exp 0.0000004 -> 1.000000 Inexact Rounded
-expx020 exp 0.0000005 -> 1.000001 Inexact Rounded
-expx021 exp 0.0000008 -> 1.000001 Inexact Rounded
-expx022 exp 0.0000009 -> 1.000001 Inexact Rounded
-expx023 exp 0.0000010 -> 1.000001 Inexact Rounded
-expx024 exp 0.0000011 -> 1.000001 Inexact Rounded
-expx025 exp 0.00000009 -> 1.000000 Inexact Rounded
-expx026 exp 0.00000005 -> 1.000000 Inexact Rounded
-expx027 exp 0.00000004 -> 1.000000 Inexact Rounded
-expx028 exp 0.00000001 -> 1.000000 Inexact Rounded
-
--- and some more zeros
-expx030 exp 0.00000000 -> 1
-expx031 exp 0E+100 -> 1
-expx032 exp 0E-100 -> 1
-expx033 exp -0.00000000 -> 1
-expx034 exp -0E+100 -> 1
-expx035 exp -0E-100 -> 1
-
--- basic e=0, e=1, e=2, e=4, e>=8 cases
-precision: 7
-expx041 exp 1 -> 2.718282 Inexact Rounded
-expx042 exp -1 -> 0.3678794 Inexact Rounded
-expx043 exp 10 -> 22026.47 Inexact Rounded
-expx044 exp -10 -> 0.00004539993 Inexact Rounded
-expx045 exp 100 -> 2.688117E+43 Inexact Rounded
-expx046 exp -100 -> 3.720076E-44 Inexact Rounded
-expx047 exp 1000 -> Infinity Overflow Inexact Rounded
-expx048 exp -1000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx049 exp 100000000 -> Infinity Overflow Inexact Rounded
-expx050 exp -100000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-
--- miscellanea
--- similar to 'VF bug' test, at 17, but with last digit corrected for decimal
-precision: 16
-expx055 exp -5.42410311287441459172E+2 -> 2.717658486884572E-236 Inexact Rounded
--- result from NetRexx/Java prototype -> 2.7176584868845721117677929628617246054459644711108E-236
--- result from Rexx (series) version -> 2.717658486884572111767792962861724605446E-236
-precision: 17
-expx056 exp -5.42410311287441459172E+2 -> 2.7176584868845721E-236 Inexact Rounded
-precision: 18
-expx057 exp -5.42410311287441459172E+2 -> 2.71765848688457211E-236 Inexact Rounded
-precision: 19
-expx058 exp -5.42410311287441459172E+2 -> 2.717658486884572112E-236 Inexact Rounded
-precision: 20
-expx059 exp -5.42410311287441459172E+2 -> 2.7176584868845721118E-236 Inexact Rounded
-
--- rounding in areas of ..500.., ..499.., ..100.., ..999.. sequences
-precision: 50
-expx101 exp -9E-8 -> 0.99999991000000404999987850000273374995079250073811 Inexact Rounded
-precision: 31
-expx102 exp -9E-8 -> 0.9999999100000040499998785000027 Inexact Rounded
-precision: 30
-expx103 exp -9E-8 -> 0.999999910000004049999878500003 Inexact Rounded
-precision: 29
-expx104 exp -9E-8 -> 0.99999991000000404999987850000 Inexact Rounded
-precision: 28
-expx105 exp -9E-8 -> 0.9999999100000040499998785000 Inexact Rounded
-precision: 27
-expx106 exp -9E-8 -> 0.999999910000004049999878500 Inexact Rounded
-precision: 26
-expx107 exp -9E-8 -> 0.99999991000000404999987850 Inexact Rounded
-precision: 25
-expx108 exp -9E-8 -> 0.9999999100000040499998785 Inexact Rounded
-precision: 24
-expx109 exp -9E-8 -> 0.999999910000004049999879 Inexact Rounded
-precision: 23
-expx110 exp -9E-8 -> 0.99999991000000404999988 Inexact Rounded
-precision: 22
-expx111 exp -9E-8 -> 0.9999999100000040499999 Inexact Rounded
-precision: 21
-expx112 exp -9E-8 -> 0.999999910000004050000 Inexact Rounded
-precision: 20
-expx113 exp -9E-8 -> 0.99999991000000405000 Inexact Rounded
-precision: 19
-expx114 exp -9E-8 -> 0.9999999100000040500 Inexact Rounded
-precision: 18
-expx115 exp -9E-8 -> 0.999999910000004050 Inexact Rounded
-precision: 17
-expx116 exp -9E-8 -> 0.99999991000000405 Inexact Rounded
-precision: 16
-expx117 exp -9E-8 -> 0.9999999100000040 Inexact Rounded
-precision: 15
-expx118 exp -9E-8 -> 0.999999910000004 Inexact Rounded
-precision: 14
-expx119 exp -9E-8 -> 0.99999991000000 Inexact Rounded
-precision: 13
-expx120 exp -9E-8 -> 0.9999999100000 Inexact Rounded
-precision: 12
-expx121 exp -9E-8 -> 0.999999910000 Inexact Rounded
-precision: 11
-expx122 exp -9E-8 -> 0.99999991000 Inexact Rounded
-precision: 10
-expx123 exp -9E-8 -> 0.9999999100 Inexact Rounded
-precision: 9
-expx124 exp -9E-8 -> 0.999999910 Inexact Rounded
-precision: 8
-expx125 exp -9E-8 -> 0.99999991 Inexact Rounded
-precision: 7
-expx126 exp -9E-8 -> 0.9999999 Inexact Rounded
-precision: 6
-expx127 exp -9E-8 -> 1.00000 Inexact Rounded
-precision: 5
-expx128 exp -9E-8 -> 1.0000 Inexact Rounded
-precision: 4
-expx129 exp -9E-8 -> 1.000 Inexact Rounded
-precision: 3
-expx130 exp -9E-8 -> 1.00 Inexact Rounded
-precision: 2
-expx131 exp -9E-8 -> 1.0 Inexact Rounded
-precision: 1
-expx132 exp -9E-8 -> 1 Inexact Rounded
-
-
--- sanity checks, with iteration counts [normalized so 0<=|x|<1]
-precision: 50
-
-expx210 exp 0 -> 1
--- iterations: 2
-expx211 exp -1E-40 -> 0.99999999999999999999999999999999999999990000000000 Inexact Rounded
--- iterations: 8
-expx212 exp -9E-7 -> 0.99999910000040499987850002733749507925073811240510 Inexact Rounded
--- iterations: 6
-expx213 exp -9E-8 -> 0.99999991000000404999987850000273374995079250073811 Inexact Rounded
--- iterations: 15
-expx214 exp -0.003 -> 0.99700449550337297601206623409756091074177480489845 Inexact Rounded
--- iterations: 14
-expx215 exp -0.001 -> 0.99900049983337499166805535716765597470235590236008 Inexact Rounded
--- iterations: 26
-expx216 exp -0.1 -> 0.90483741803595957316424905944643662119470536098040 Inexact Rounded
--- iterations: 39
-expx217 exp -0.7 -> 0.49658530379140951470480009339752896170766716571182 Inexact Rounded
--- iterations: 41
-expx218 exp -0.9 -> 0.40656965974059911188345423964562598783370337617038 Inexact Rounded
--- iterations: 43
-expx219 exp -0.99 -> 0.37157669102204569053152411990820138691802885490501 Inexact Rounded
--- iterations: 26
-expx220 exp -1 -> 0.36787944117144232159552377016146086744581113103177 Inexact Rounded
--- iterations: 26
-expx221 exp -1.01 -> 0.36421897957152331975704629563734548959589139192482 Inexact Rounded
--- iterations: 27
-expx222 exp -1.1 -> 0.33287108369807955328884690643131552161247952156921 Inexact Rounded
--- iterations: 28
-expx223 exp -1.5 -> 0.22313016014842982893328047076401252134217162936108 Inexact Rounded
--- iterations: 30
-expx224 exp -2 -> 0.13533528323661269189399949497248440340763154590958 Inexact Rounded
--- iterations: 36
-expx225 exp -5 -> 0.0067379469990854670966360484231484242488495850273551 Inexact Rounded
--- iterations: 26
-expx226 exp -10 -> 0.000045399929762484851535591515560550610237918088866565 Inexact Rounded
--- iterations: 28
-expx227 exp -14 -> 8.3152871910356788406398514256526229460765836498457E-7 Inexact Rounded
--- iterations: 29
-expx228 exp -15 -> 3.0590232050182578837147949770228963937082078081856E-7 Inexact Rounded
--- iterations: 30
-expx233 exp 0 -> 1
--- iterations: 2
-expx234 exp 1E-40 -> 1.0000000000000000000000000000000000000001000000000 Inexact Rounded
--- iterations: 7
-expx235 exp 9E-7 -> 1.0000009000004050001215000273375049207507381125949 Inexact Rounded
--- iterations: 6
-expx236 exp 9E-8 -> 1.0000000900000040500001215000027337500492075007381 Inexact Rounded
--- iterations: 15
-expx237 exp 0.003 -> 1.0030045045033770260129340913489002053318727195619 Inexact Rounded
--- iterations: 13
-expx238 exp 0.001 -> 1.0010005001667083416680557539930583115630762005807 Inexact Rounded
--- iterations: 25
-expx239 exp 0.1 -> 1.1051709180756476248117078264902466682245471947375 Inexact Rounded
--- iterations: 38
-expx240 exp 0.7 -> 2.0137527074704765216245493885830652700175423941459 Inexact Rounded
--- iterations: 41
-expx241 exp 0.9 -> 2.4596031111569496638001265636024706954217723064401 Inexact Rounded
--- iterations: 42
-expx242 exp 0.99 -> 2.6912344723492622890998794040710139721802931841030 Inexact Rounded
--- iterations: 26
-expx243 exp 1 -> 2.7182818284590452353602874713526624977572470937000 Inexact Rounded
--- iterations: 26
-expx244 exp 1.01 -> 2.7456010150169164939897763166603876240737508195960 Inexact Rounded
--- iterations: 26
-expx245 exp 1.1 -> 3.0041660239464331120584079535886723932826810260163 Inexact Rounded
--- iterations: 28
-expx246 exp 1.5 -> 4.4816890703380648226020554601192758190057498683697 Inexact Rounded
--- iterations: 29
-expx247 exp 2 -> 7.3890560989306502272304274605750078131803155705518 Inexact Rounded
--- iterations: 36
-expx248 exp 5 -> 148.41315910257660342111558004055227962348766759388 Inexact Rounded
--- iterations: 26
-expx249 exp 10 -> 22026.465794806716516957900645284244366353512618557 Inexact Rounded
--- iterations: 28
-expx250 exp 14 -> 1202604.2841647767777492367707678594494124865433761 Inexact Rounded
--- iterations: 28
-expx251 exp 15 -> 3269017.3724721106393018550460917213155057385438200 Inexact Rounded
--- iterations: 29
-
--- a biggie [result verified 3 ways]
-precision: 250
-expx260 exp 1 -> 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668 Inexact Rounded
-
--- extreme range boundaries
-precision: 16
-maxExponent: 999999
-minExponent: -999999
--- Ntiny boundary
-expx290 exp -2302618.022332529 -> 0E-1000014 Underflow Subnormal Inexact Rounded Clamped
-expx291 exp -2302618.022332528 -> 1E-1000014 Underflow Subnormal Inexact Rounded
--- Nmax/10 and Nmax boundary
-expx292 exp 2302582.790408952 -> 9.999999993100277E+999998 Inexact Rounded
-expx293 exp 2302582.790408953 -> 1.000000000310028E+999999 Inexact Rounded
-expx294 exp 2302585.092993946 -> 9.999999003159870E+999999 Inexact Rounded
-expx295 exp 2302585.092994036 -> 9.999999903159821E+999999 Inexact Rounded
-expx296 exp 2302585.092994045 -> 9.999999993159820E+999999 Inexact Rounded
-expx297 exp 2302585.092994046 -> Infinity Overflow Inexact Rounded
-
--- 0<-x<<1 effects
-precision: 30
-expx320 exp -4.9999999999999E-8 -> 0.999999950000001250000979166617 Inexact Rounded
-expx321 exp -5.0000000000000E-8 -> 0.999999950000001249999979166667 Inexact Rounded
-expx322 exp -5.0000000000001E-8 -> 0.999999950000001249998979166717 Inexact Rounded
-precision: 20
-expx323 exp -4.9999999999999E-8 -> 0.99999995000000125000 Inexact Rounded
-expx324 exp -5.0000000000000E-8 -> 0.99999995000000125000 Inexact Rounded
-expx325 exp -5.0000000000001E-8 -> 0.99999995000000125000 Inexact Rounded
-precision: 14
-expx326 exp -4.9999999999999E-8 -> 0.99999995000000 Inexact Rounded
-expx327 exp -5.0000000000000E-8 -> 0.99999995000000 Inexact Rounded
-expx328 exp -5.0000000000001E-8 -> 0.99999995000000 Inexact Rounded
--- overprecise and 0<-x<<1
-precision: 8
-expx330 exp -4.9999999999999E-8 -> 0.99999995 Inexact Rounded
-expx331 exp -5.0000000000000E-8 -> 0.99999995 Inexact Rounded
-expx332 exp -5.0000000000001E-8 -> 0.99999995 Inexact Rounded
-precision: 7
-expx333 exp -4.9999999999999E-8 -> 1.000000 Inexact Rounded
-expx334 exp -5.0000000000000E-8 -> 1.000000 Inexact Rounded
-expx335 exp -5.0000000000001E-8 -> 1.000000 Inexact Rounded
-precision: 3
-expx336 exp -4.9999999999999E-8 -> 1.00 Inexact Rounded
-expx337 exp -5.0000000000000E-8 -> 1.00 Inexact Rounded
-expx338 exp -5.0000000000001E-8 -> 1.00 Inexact Rounded
-
--- 0<x<<1 effects
-precision: 30
-expx340 exp 4.9999999999999E-8 -> 1.00000005000000124999902083328 Inexact Rounded
-expx341 exp 5.0000000000000E-8 -> 1.00000005000000125000002083333 Inexact Rounded
-expx342 exp 5.0000000000001E-8 -> 1.00000005000000125000102083338 Inexact Rounded
-precision: 20
-expx343 exp 4.9999999999999E-8 -> 1.0000000500000012500 Inexact Rounded
-expx344 exp 5.0000000000000E-8 -> 1.0000000500000012500 Inexact Rounded
-expx345 exp 5.0000000000001E-8 -> 1.0000000500000012500 Inexact Rounded
-precision: 14
-expx346 exp 4.9999999999999E-8 -> 1.0000000500000 Inexact Rounded
-expx347 exp 5.0000000000000E-8 -> 1.0000000500000 Inexact Rounded
-expx348 exp 5.0000000000001E-8 -> 1.0000000500000 Inexact Rounded
--- overprecise and 0<x<<1
-precision: 8
-expx350 exp 4.9999999999999E-8 -> 1.0000001 Inexact Rounded
-expx351 exp 5.0000000000000E-8 -> 1.0000001 Inexact Rounded
-expx352 exp 5.0000000000001E-8 -> 1.0000001 Inexact Rounded
-precision: 7
-expx353 exp 4.9999999999999E-8 -> 1.000000 Inexact Rounded
-expx354 exp 5.0000000000000E-8 -> 1.000000 Inexact Rounded
-expx355 exp 5.0000000000001E-8 -> 1.000000 Inexact Rounded
-precision: 3
-expx356 exp 4.9999999999999E-8 -> 1.00 Inexact Rounded
-expx357 exp 5.0000000000000E-8 -> 1.00 Inexact Rounded
-expx358 exp 5.0000000000001E-8 -> 1.00 Inexact Rounded
-
--- cases near 1 -- 1 2345678901234567890
-precision: 20
-expx401 exp 0.99999999999996 -> 2.7182818284589365041 Inexact Rounded
-expx402 exp 0.99999999999997 -> 2.7182818284589636869 Inexact Rounded
-expx403 exp 0.99999999999998 -> 2.7182818284589908697 Inexact Rounded
-expx404 exp 0.99999999999999 -> 2.7182818284590180525 Inexact Rounded
-expx405 exp 1.0000000000000 -> 2.7182818284590452354 Inexact Rounded
-expx406 exp 1.0000000000001 -> 2.7182818284593170635 Inexact Rounded
-expx407 exp 1.0000000000002 -> 2.7182818284595888917 Inexact Rounded
-precision: 14
-expx411 exp 0.99999999999996 -> 2.7182818284589 Inexact Rounded
-expx412 exp 0.99999999999997 -> 2.7182818284590 Inexact Rounded
-expx413 exp 0.99999999999998 -> 2.7182818284590 Inexact Rounded
-expx414 exp 0.99999999999999 -> 2.7182818284590 Inexact Rounded
-expx415 exp 1.0000000000000 -> 2.7182818284590 Inexact Rounded
-expx416 exp 1.0000000000001 -> 2.7182818284593 Inexact Rounded
-expx417 exp 1.0000000000002 -> 2.7182818284596 Inexact Rounded
--- overprecise...
-precision: 7
-expx421 exp 0.99999999999996 -> 2.718282 Inexact Rounded
-expx422 exp 0.99999999999997 -> 2.718282 Inexact Rounded
-expx423 exp 0.99999999999998 -> 2.718282 Inexact Rounded
-expx424 exp 0.99999999999999 -> 2.718282 Inexact Rounded
-expx425 exp 1.0000000000001 -> 2.718282 Inexact Rounded
-expx426 exp 1.0000000000002 -> 2.718282 Inexact Rounded
-expx427 exp 1.0000000000003 -> 2.718282 Inexact Rounded
-precision: 2
-expx431 exp 0.99999999999996 -> 2.7 Inexact Rounded
-expx432 exp 0.99999999999997 -> 2.7 Inexact Rounded
-expx433 exp 0.99999999999998 -> 2.7 Inexact Rounded
-expx434 exp 0.99999999999999 -> 2.7 Inexact Rounded
-expx435 exp 1.0000000000001 -> 2.7 Inexact Rounded
-expx436 exp 1.0000000000002 -> 2.7 Inexact Rounded
-expx437 exp 1.0000000000003 -> 2.7 Inexact Rounded
-
--- basics at low precisions
-precision: 3
-expx501 exp -Infinity -> 0
-expx502 exp -10 -> 0.0000454 Inexact Rounded
-expx503 exp -1 -> 0.368 Inexact Rounded
-expx504 exp 0 -> 1
-expx505 exp -0 -> 1
-expx506 exp 1 -> 2.72 Inexact Rounded
-expx507 exp 0.693147181 -> 2.00 Inexact Rounded
-expx508 exp 10 -> 2.20E+4 Inexact Rounded
-expx509 exp +Infinity -> Infinity
-precision: 2
-expx511 exp -Infinity -> 0
-expx512 exp -10 -> 0.000045 Inexact Rounded
-expx513 exp -1 -> 0.37 Inexact Rounded
-expx514 exp 0 -> 1
-expx515 exp -0 -> 1
-expx516 exp 1 -> 2.7 Inexact Rounded
-expx517 exp 0.693147181 -> 2.0 Inexact Rounded
-expx518 exp 10 -> 2.2E+4 Inexact Rounded
-expx519 exp +Infinity -> Infinity
-precision: 1
-expx521 exp -Infinity -> 0
-expx522 exp -10 -> 0.00005 Inexact Rounded
-expx523 exp -1 -> 0.4 Inexact Rounded
-expx524 exp 0 -> 1
-expx525 exp -0 -> 1
-expx526 exp 1 -> 3 Inexact Rounded
-expx527 exp 0.693147181 -> 2 Inexact Rounded
-expx528 exp 10 -> 2E+4 Inexact Rounded
-expx529 exp +Infinity -> Infinity
-
--- overflows, including some overprecise borderlines
-precision: 7
-maxExponent: 384
-minExponent: -383
-expx701 exp 1000000000 -> Infinity Overflow Inexact Rounded
-expx702 exp 100000000 -> Infinity Overflow Inexact Rounded
-expx703 exp 10000000 -> Infinity Overflow Inexact Rounded
-expx704 exp 1000000 -> Infinity Overflow Inexact Rounded
-expx705 exp 100000 -> Infinity Overflow Inexact Rounded
-expx706 exp 10000 -> Infinity Overflow Inexact Rounded
-expx707 exp 1000 -> Infinity Overflow Inexact Rounded
-expx708 exp 886.4952608 -> Infinity Overflow Inexact Rounded
-expx709 exp 886.4952607 -> 9.999999E+384 Inexact Rounded
-expx710 exp 886.49527 -> Infinity Overflow Inexact Rounded
-expx711 exp 886.49526 -> 9.999992E+384 Inexact Rounded
-precision: 16
-expx721 exp 886.4952608027075883 -> Infinity Overflow Inexact Rounded
-expx722 exp 886.4952608027075882 -> 9.999999999999999E+384 Inexact Rounded
-expx723 exp 886.49526080270759 -> Infinity Overflow Inexact Rounded
-expx724 exp 886.49526080270758 -> 9.999999999999917E+384 Inexact Rounded
-expx725 exp 886.4952608027076 -> Infinity Overflow Inexact Rounded
-expx726 exp 886.4952608027075 -> 9.999999999999117E+384 Inexact Rounded
--- and by special request ...
-precision: 15
-expx731 exp 886.495260802708 -> Infinity Overflow Inexact Rounded
-expx732 exp 886.495260802707 -> 9.99999999999412E+384 Inexact Rounded
-expx733 exp 886.495260802706 -> 9.99999999998412E+384 Inexact Rounded
-maxExponent: 999
-minExponent: -999
-expx735 exp 2302.58509299405 -> Infinity Overflow Inexact Rounded
-expx736 exp 2302.58509299404 -> 9.99999999994316E+999 Inexact Rounded
-expx737 exp 2302.58509299403 -> 9.99999999984316E+999 Inexact Rounded
-
--- subnormals and underflows, including underflow-to-zero edge point
-precision: 7
-maxExponent: 384
-minExponent: -383
-expx751 exp -1000000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx752 exp -100000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx753 exp -10000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx754 exp -1000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx755 exp -100000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx756 exp -10000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx757 exp -1000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx758 exp -881.89009 -> 1.000001E-383 Inexact Rounded
-expx759 exp -881.8901 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
-expx760 exp -885 -> 4.4605E-385 Inexact Rounded Underflow Subnormal
-expx761 exp -888 -> 2.221E-386 Inexact Rounded Underflow Subnormal
-expx762 exp -890 -> 3.01E-387 Inexact Rounded Underflow Subnormal
-expx763 exp -892.9 -> 1.7E-388 Inexact Rounded Underflow Subnormal
-expx764 exp -893 -> 1.5E-388 Inexact Rounded Underflow Subnormal
-expx765 exp -893.5 -> 9E-389 Inexact Rounded Underflow Subnormal
-expx766 exp -895.7056 -> 1E-389 Inexact Rounded Underflow Subnormal
-expx769 exp -895.8 -> 1E-389 Inexact Rounded Underflow Subnormal
-expx770 exp -895.73 -> 1E-389 Inexact Rounded Underflow Subnormal
-expx771 exp -896.3987 -> 1E-389 Inexact Rounded Underflow Subnormal
-expx772 exp -896.3988 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
-expx773 exp -898.0081 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
-expx774 exp -898.0082 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
-
--- special values
-maxexponent: 999
-minexponent: -999
-expx820 exp Inf -> Infinity
-expx821 exp -Inf -> 0
-expx822 exp NaN -> NaN
-expx823 exp sNaN -> NaN Invalid_operation
--- propagating NaNs
-expx824 exp sNaN123 -> NaN123 Invalid_operation
-expx825 exp -sNaN321 -> -NaN321 Invalid_operation
-expx826 exp NaN456 -> NaN456
-expx827 exp -NaN654 -> -NaN654
-expx828 exp NaN1 -> NaN1
-
--- Invalid operations due to restrictions
--- [next two probably skipped by most test harnesses]
-precision: 100000000
-expx901 exp -Infinity -> NaN Invalid_context
-precision: 99999999
-expx902 exp -Infinity -> NaN Invalid_context
-
-precision: 9
-maxExponent: 1000000
-minExponent: -999999
-expx903 exp -Infinity -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999999
-expx904 exp -Infinity -> 0
-maxExponent: 999999
-minExponent: -1000000
-expx905 exp -Infinity -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999998
-expx906 exp -Infinity -> 0
-
---
-maxExponent: 384
-minExponent: -383
-precision: 16
-rounding: half_even
-
--- Null test
-expx900 exp # -> NaN Invalid_operation
-
-
--- Randoms P=50, within 0-999
-Precision: 50
-maxExponent: 384
-minExponent: -383
-expx1501 exp 656.35397950590285612266095596539934213943872885728 -> 1.1243757610640319783611178528839652672062820040314E+285 Inexact Rounded
-expx1502 exp 0.93620571093652800225038550600780322831236082781471 -> 2.5502865130986176689199711857825771311178046842009 Inexact Rounded
-expx1503 exp 0.00000000000000008340785856601514714183373874105791 -> 1.0000000000000000834078585660151506202691740252512 Inexact Rounded
-expx1504 exp 0.00009174057262887789625745574686545163168788456203 -> 1.0000917447809239005146722341251524081006051473273 Inexact Rounded
-expx1505 exp 33.909116897973797735657751591014926629051117541243 -> 532773181025002.03543618901306726495870476617232229 Inexact Rounded
-expx1506 exp 0.00000740470413004406592124575295278456936809587311 -> 1.0000074047315449333590066395670306135567889210814 Inexact Rounded
-expx1507 exp 0.00000000000124854922222108802453746922483071445492 -> 1.0000000000012485492222218674621176239911424968263 Inexact Rounded
-expx1508 exp 4.1793280674155659794286951159430651258356014391382 -> 65.321946520147199404199787811336860087975118278185 Inexact Rounded
-expx1509 exp 485.43595745460655893746179890255529919221550201686 -> 6.6398403920459617255950476953129377459845366585463E+210 Inexact Rounded
-expx1510 exp 0.00000000003547259806590856032527875157830328156597 -> 1.0000000000354725980665377129320589406715000685515 Inexact Rounded
-expx1511 exp 0.00000000000000759621497339104047930616478635042678 -> 1.0000000000000075962149733910693305471257715463887 Inexact Rounded
-expx1512 exp 9.7959168821760339304571595474480640286072720233796 -> 17960.261146042955179164303653412650751681436352437 Inexact Rounded
-expx1513 exp 0.00000000566642006258290526783901451194943164535581 -> 1.0000000056664200786370634609832438815665249347650 Inexact Rounded
-expx1514 exp 741.29888791134298194088827572374718940925820027354 -> 8.7501694006317332808128946666402622432064923198731E+321 Inexact Rounded
-expx1515 exp 032.75573003552517668808529099897153710887014947935 -> 168125196578678.17725841108617955904425345631092339 Inexact Rounded
-expx1516 exp 42.333700726429333308594265553422902463737399437644 -> 2428245675864172475.4681119493045657797309369672012 Inexact Rounded
-expx1517 exp 0.00000000000000559682616876491888197609158802835798 -> 1.0000000000000055968261687649345442076732739577049 Inexact Rounded
-expx1518 exp 0.00000000000080703688668280193584758300973549486312 -> 1.0000000000008070368866831275901158164321867914342 Inexact Rounded
-expx1519 exp 640.72396012796509482382712891709072570653606838251 -> 1.8318094990683394229304133068983914236995326891045E+278 Inexact Rounded
-expx1520 exp 0.00000000000000509458922167631071416948112219512224 -> 1.0000000000000050945892216763236915891499324358556 Inexact Rounded
-expx1521 exp 6.7670394314315206378625221583973414660727960241395 -> 868.73613012822031367806248697092884415119568271315 Inexact Rounded
-expx1522 exp 04.823217407412963506638267226891024138054783122548 -> 124.36457929588837129731821077586705505565904205366 Inexact Rounded
-expx1523 exp 193.51307878701196403991208482520115359690106143615 -> 1.1006830872854715677390914655452261550768957576034E+84 Inexact Rounded
-expx1524 exp 5.7307749038303650539200345901210497015617393970463 -> 308.20800743106843083522721523715645950574866495196 Inexact Rounded
-expx1525 exp 0.00000000000095217825199797965200541169123743500267 -> 1.0000000000009521782519984329737172007991390381273 Inexact Rounded
-expx1526 exp 0.00027131440949183370966393682617930153495028919140 -> 1.0002713512185751022906058160480606598754913607364 Inexact Rounded
-expx1527 exp 0.00000000064503059114680682343002315662069272707123 -> 1.0000000006450305913548390552323517403613135496633 Inexact Rounded
-expx1528 exp 0.00000000000000095616643506527288866235238548440593 -> 1.0000000000000009561664350652733457894781582009094 Inexact Rounded
-expx1529 exp 0.00000000000000086449942811678650244459550252743433 -> 1.0000000000000008644994281167868761242261096529986 Inexact Rounded
-expx1530 exp 0.06223488355635359965683053157729204988381887621850 -> 1.0642122813392406657789688931838919323826250630831 Inexact Rounded
-expx1531 exp 0.00000400710807804429435502657131912308680674057053 -> 1.0000040071161065125925620890019319832127863559260 Inexact Rounded
-expx1532 exp 85.522796894744576211573232055494551429297878413017 -> 13870073686404228452757799770251085177.853337368935 Inexact Rounded
-expx1533 exp 9.1496720811363678696938036379756663548353399954363 -> 9411.3537122832743386783597629161763057370034495157 Inexact Rounded
-expx1534 exp 8.2215705240788294472944382056330516738577785177942 -> 3720.3406813383076953899654701615084425598377758189 Inexact Rounded
-expx1535 exp 0.00000000015772064569640613142823203726821076239561 -> 1.0000000001577206457088440324683315788358926129830 Inexact Rounded
-expx1536 exp 0.58179346473959531432624153576883440625538017532480 -> 1.7892445018275360163797022372655837188423194863605 Inexact Rounded
-expx1537 exp 33.555726197149525061455517784870570470833498096559 -> 374168069896324.62578073148993526626307095854407952 Inexact Rounded
-expx1538 exp 9.7898079803906215094140010009583375537259810398659 -> 17850.878119912208888217100998019986634620368538426 Inexact Rounded
-expx1539 exp 89.157697327174521542502447953032536541038636966347 -> 525649152320166503771224149330448089550.67293829227 Inexact Rounded
-expx1540 exp 25.022947600123328912029051897171319573322888514885 -> 73676343442.952517824345431437683153304645851960524 Inexact Rounded
-
--- exp(1) at 34
-Precision: 34
-expx1200 exp 1 -> 2.718281828459045235360287471352662 Inexact Rounded
-
--- Randoms P=34, within 0-999
-Precision: 34
-maxExponent: 6144
-minExponent: -6143
-expx1201 exp 309.5948855821510212996700645087188 -> 2.853319692901387521201738015050724E+134 Inexact Rounded
-expx1202 exp 9.936543068706211420422803962680164 -> 20672.15839203171877476511093276022 Inexact Rounded
-expx1203 exp 6.307870323881505684429839491707908 -> 548.8747777054637296137277391754665 Inexact Rounded
-expx1204 exp 0.0003543281389438420535201308282503 -> 1.000354390920573746164733350843155 Inexact Rounded
-expx1205 exp 0.0000037087453363918375598394920229 -> 1.000003708752213796324841920189323 Inexact Rounded
-expx1206 exp 0.0020432312687512438040222444116585 -> 1.002045320088164826013561630975308 Inexact Rounded
-expx1207 exp 6.856313340032177672550343216129586 -> 949.8587981604144147983589660524396 Inexact Rounded
-expx1208 exp 0.0000000000402094928333815643326418 -> 1.000000000040209492834189965989612 Inexact Rounded
-expx1209 exp 0.0049610784722412117632647003545839 -> 1.004973404997901987039589029277833 Inexact Rounded
-expx1210 exp 0.0000891471883724066909746786702686 -> 1.000089151162101085412780088266699 Inexact Rounded
-expx1211 exp 08.59979170376061890684723211112566 -> 5430.528314920905714615339273738097 Inexact Rounded
-expx1212 exp 9.473117039341003854872778112752590 -> 13005.36234331224953460055897913917 Inexact Rounded
-expx1213 exp 0.0999060724692207648429969999310118 -> 1.105067116975190602296052700726802 Inexact Rounded
-expx1214 exp 0.0000000927804533555877884082269247 -> 1.000000092780457659694183954740772 Inexact Rounded
-expx1215 exp 0.0376578583872889916298772818265677 -> 1.038375900489771946477857818447556 Inexact Rounded
-expx1216 exp 261.6896411697539524911536116712307 -> 4.470613562127465095241600174941460E+113 Inexact Rounded
-expx1217 exp 0.0709997423269162980875824213889626 -> 1.073580949235407949417814485533172 Inexact Rounded
-expx1218 exp 0.0000000444605583295169895235658731 -> 1.000000044460559317887627657593900 Inexact Rounded
-expx1219 exp 0.0000021224072854777512281369815185 -> 1.000002122409537785687390631070906 Inexact Rounded
-expx1220 exp 547.5174462574156885473558485475052 -> 6.078629247383807942612114579728672E+237 Inexact Rounded
-expx1221 exp 0.0000009067598041615192002339844670 -> 1.000000906760215268314680115374387 Inexact Rounded
-expx1222 exp 0.0316476500308065365803455533244603 -> 1.032153761880187977658387961769034 Inexact Rounded
-expx1223 exp 84.46160530377645101833996706384473 -> 4.799644995897968383503269871697856E+36 Inexact Rounded
-expx1224 exp 0.0000000000520599740290848018904145 -> 1.000000000052059974030439922338393 Inexact Rounded
-expx1225 exp 0.0000006748530640093620665651726708 -> 1.000000674853291722742292331812997 Inexact Rounded
-expx1226 exp 0.0000000116853119761042020507916169 -> 1.000000011685312044377460306165203 Inexact Rounded
-expx1227 exp 0.0022593818094258636727616886693280 -> 1.002261936135876893707094845543461 Inexact Rounded
-expx1228 exp 0.0029398857673478912249856509667517 -> 1.002944211469495086813087651287012 Inexact Rounded
-expx1229 exp 0.7511480029928802775376270557636963 -> 2.119431734510320169806976569366789 Inexact Rounded
-expx1230 exp 174.9431952176750671150886423048447 -> 9.481222305374955011464619468044051E+75 Inexact Rounded
-expx1231 exp 0.0000810612451694136129199895164424 -> 1.000081064530720924186615149646920 Inexact Rounded
-expx1232 exp 51.06888989702669288180946272499035 -> 15098613888619165073959.89896018749 Inexact Rounded
-expx1233 exp 0.0000000005992887599437093651494510 -> 1.000000000599288760123282874082758 Inexact Rounded
-expx1234 exp 714.8549046761054856311108828903972 -> 2.867744544891081117381595080480784E+310 Inexact Rounded
-expx1235 exp 0.0000000004468247802990643645607110 -> 1.000000000446824780398890556720233 Inexact Rounded
-expx1236 exp 831.5818151589890366323551672043709 -> 1.417077409182624969435938062261655E+361 Inexact Rounded
-expx1237 exp 0.0000000006868323825179605747108044 -> 1.000000000686832382753829935602454 Inexact Rounded
-expx1238 exp 0.0000001306740266408976840228440255 -> 1.000000130674035178748675187648098 Inexact Rounded
-expx1239 exp 0.3182210609022267704811502412335163 -> 1.374680115667798185758927247894859 Inexact Rounded
-expx1240 exp 0.0147741234179104437440264644295501 -> 1.014883800239950682628277534839222 Inexact Rounded
-
--- Randoms P=16, within 0-99
-Precision: 16
-maxExponent: 384
-minExponent: -383
-expx1101 exp 8.473011527013724 -> 4783.900643969246 Inexact Rounded
-expx1102 exp 0.0000055753022764 -> 1.000005575317818 Inexact Rounded
-expx1103 exp 0.0000323474114482 -> 1.000032347934631 Inexact Rounded
-expx1104 exp 64.54374138544166 -> 1.073966476173531E+28 Inexact Rounded
-expx1105 exp 90.47203246416569 -> 1.956610887250643E+39 Inexact Rounded
-expx1106 exp 9.299931532342757 -> 10937.27033325227 Inexact Rounded
-expx1107 exp 8.759678437852203 -> 6372.062234495381 Inexact Rounded
-expx1108 exp 0.0000931755127172 -> 1.000093179853690 Inexact Rounded
-expx1109 exp 0.0000028101158373 -> 1.000002810119786 Inexact Rounded
-expx1110 exp 0.0000008008130919 -> 1.000000800813413 Inexact Rounded
-expx1111 exp 8.339771722299049 -> 4187.133803081878 Inexact Rounded
-expx1112 exp 0.0026140497995474 -> 1.002617469406750 Inexact Rounded
-expx1113 exp 0.7478033356261771 -> 2.112354781975418 Inexact Rounded
-expx1114 exp 51.77663761827966 -> 3.064135801120365E+22 Inexact Rounded
-expx1115 exp 0.1524989783061012 -> 1.164741272084955 Inexact Rounded
-expx1116 exp 0.0066298798669219 -> 1.006651906170791 Inexact Rounded
-expx1117 exp 9.955141865534960 -> 21060.23334287038 Inexact Rounded
-expx1118 exp 92.34503059198483 -> 1.273318993481226E+40 Inexact Rounded
-expx1119 exp 0.0000709388677346 -> 1.000070941383956 Inexact Rounded
-expx1120 exp 79.12883036433204 -> 2.318538899389243E+34 Inexact Rounded
-expx1121 exp 0.0000090881548873 -> 1.000009088196185 Inexact Rounded
-expx1122 exp 0.0424828809603411 -> 1.043398194245720 Inexact Rounded
-expx1123 exp 0.8009035891427416 -> 2.227552811933310 Inexact Rounded
-expx1124 exp 8.825786167283102 -> 6807.540455289995 Inexact Rounded
-expx1125 exp 1.535457249746275 -> 4.643448260146849 Inexact Rounded
-expx1126 exp 69.02254254355800 -> 9.464754500670653E+29 Inexact Rounded
-expx1127 exp 0.0007050554368713 -> 1.000705304046880 Inexact Rounded
-expx1128 exp 0.0000081206549504 -> 1.000008120687923 Inexact Rounded
-expx1129 exp 0.621774854641137 -> 1.862230298554903 Inexact Rounded
-expx1130 exp 3.847629031404354 -> 46.88177613568203 Inexact Rounded
-expx1131 exp 24.81250184697732 -> 59694268456.19966 Inexact Rounded
-expx1132 exp 5.107546500516044 -> 165.2643809755670 Inexact Rounded
-expx1133 exp 79.17810943951986 -> 2.435656372541360E+34 Inexact Rounded
-expx1134 exp 0.0051394695667015 -> 1.005152699295301 Inexact Rounded
-expx1135 exp 57.44504488501725 -> 8.872908566929688E+24 Inexact Rounded
-expx1136 exp 0.0000508388968036 -> 1.000050840189122 Inexact Rounded
-expx1137 exp 69.71309932148997 -> 1.888053740693541E+30 Inexact Rounded
-expx1138 exp 0.0064183412981502 -> 1.006438982988835 Inexact Rounded
-expx1139 exp 9.346991220814677 -> 11464.27802035082 Inexact Rounded
-expx1140 exp 33.09087139999152 -> 235062229168763.5 Inexact Rounded
-
--- Randoms P=7, within 0-9
-Precision: 7
-maxExponent: 96
-minExponent: -95
-expx1001 exp 2.395441 -> 10.97304 Inexact Rounded
-expx1002 exp 0.6406779 -> 1.897767 Inexact Rounded
-expx1003 exp 0.5618218 -> 1.753865 Inexact Rounded
-expx1004 exp 3.055120 -> 21.22373 Inexact Rounded
-expx1005 exp 1.536792 -> 4.649650 Inexact Rounded
-expx1006 exp 0.0801591 -> 1.083459 Inexact Rounded
-expx1007 exp 0.0966875 -> 1.101516 Inexact Rounded
-expx1008 exp 0.0646761 -> 1.066813 Inexact Rounded
-expx1009 exp 0.0095670 -> 1.009613 Inexact Rounded
-expx1010 exp 2.956859 -> 19.23745 Inexact Rounded
-expx1011 exp 7.504679 -> 1816.522 Inexact Rounded
-expx1012 exp 0.0045259 -> 1.004536 Inexact Rounded
-expx1013 exp 3.810071 -> 45.15364 Inexact Rounded
-expx1014 exp 1.502390 -> 4.492413 Inexact Rounded
-expx1015 exp 0.0321523 -> 1.032675 Inexact Rounded
-expx1016 exp 0.0057214 -> 1.005738 Inexact Rounded
-expx1017 exp 9.811445 -> 18241.33 Inexact Rounded
-expx1018 exp 3.245249 -> 25.66810 Inexact Rounded
-expx1019 exp 0.3189742 -> 1.375716 Inexact Rounded
-expx1020 exp 0.8621610 -> 2.368273 Inexact Rounded
-expx1021 exp 0.0122511 -> 1.012326 Inexact Rounded
-expx1022 exp 2.202088 -> 9.043877 Inexact Rounded
-expx1023 exp 8.778203 -> 6491.202 Inexact Rounded
-expx1024 exp 0.1896279 -> 1.208800 Inexact Rounded
-expx1025 exp 0.4510947 -> 1.570030 Inexact Rounded
-expx1026 exp 0.276413 -> 1.318392 Inexact Rounded
-expx1027 exp 4.490067 -> 89.12742 Inexact Rounded
-expx1028 exp 0.0439786 -> 1.044960 Inexact Rounded
-expx1029 exp 0.8168245 -> 2.263301 Inexact Rounded
-expx1030 exp 0.0391658 -> 1.039943 Inexact Rounded
-expx1031 exp 9.261816 -> 10528.24 Inexact Rounded
-expx1032 exp 9.611186 -> 14930.87 Inexact Rounded
-expx1033 exp 9.118125 -> 9119.087 Inexact Rounded
-expx1034 exp 9.469083 -> 12953.00 Inexact Rounded
-expx1035 exp 0.0499983 -> 1.051269 Inexact Rounded
-expx1036 exp 0.0050746 -> 1.005087 Inexact Rounded
-expx1037 exp 0.0014696 -> 1.001471 Inexact Rounded
-expx1038 exp 9.138494 -> 9306.739 Inexact Rounded
-expx1039 exp 0.0065436 -> 1.006565 Inexact Rounded
-expx1040 exp 0.7284803 -> 2.071930 Inexact Rounded
-
+------------------------------------------------------------------------
+-- exp.decTest -- decimal natural exponentiation --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Tests of the exponential funtion. Currently all testcases here
+-- show results which are correctly rounded (within <= 0.5 ulp).
+
+extended: 1
+precision: 9
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- basics (examples in specificiation, etc.)
+expx001 exp -Infinity -> 0
+expx002 exp -10 -> 0.0000453999298 Inexact Rounded
+expx003 exp -1 -> 0.367879441 Inexact Rounded
+expx004 exp 0 -> 1
+expx005 exp -0 -> 1
+expx006 exp 1 -> 2.71828183 Inexact Rounded
+expx007 exp 0.693147181 -> 2.00000000 Inexact Rounded
+expx008 exp 10 -> 22026.4658 Inexact Rounded
+expx009 exp +Infinity -> Infinity
+
+-- tiny edge cases
+precision: 7
+expx011 exp 0.1 -> 1.105171 Inexact Rounded
+expx012 exp 0.01 -> 1.010050 Inexact Rounded
+expx013 exp 0.001 -> 1.001001 Inexact Rounded
+expx014 exp 0.0001 -> 1.000100 Inexact Rounded
+expx015 exp 0.00001 -> 1.000010 Inexact Rounded
+expx016 exp 0.000001 -> 1.000001 Inexact Rounded
+expx017 exp 0.0000001 -> 1.000000 Inexact Rounded
+expx018 exp 0.0000003 -> 1.000000 Inexact Rounded
+expx019 exp 0.0000004 -> 1.000000 Inexact Rounded
+expx020 exp 0.0000005 -> 1.000001 Inexact Rounded
+expx021 exp 0.0000008 -> 1.000001 Inexact Rounded
+expx022 exp 0.0000009 -> 1.000001 Inexact Rounded
+expx023 exp 0.0000010 -> 1.000001 Inexact Rounded
+expx024 exp 0.0000011 -> 1.000001 Inexact Rounded
+expx025 exp 0.00000009 -> 1.000000 Inexact Rounded
+expx026 exp 0.00000005 -> 1.000000 Inexact Rounded
+expx027 exp 0.00000004 -> 1.000000 Inexact Rounded
+expx028 exp 0.00000001 -> 1.000000 Inexact Rounded
+
+-- and some more zeros
+expx030 exp 0.00000000 -> 1
+expx031 exp 0E+100 -> 1
+expx032 exp 0E-100 -> 1
+expx033 exp -0.00000000 -> 1
+expx034 exp -0E+100 -> 1
+expx035 exp -0E-100 -> 1
+
+-- basic e=0, e=1, e=2, e=4, e>=8 cases
+precision: 7
+expx041 exp 1 -> 2.718282 Inexact Rounded
+expx042 exp -1 -> 0.3678794 Inexact Rounded
+expx043 exp 10 -> 22026.47 Inexact Rounded
+expx044 exp -10 -> 0.00004539993 Inexact Rounded
+expx045 exp 100 -> 2.688117E+43 Inexact Rounded
+expx046 exp -100 -> 3.720076E-44 Inexact Rounded
+expx047 exp 1000 -> Infinity Overflow Inexact Rounded
+expx048 exp -1000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx049 exp 100000000 -> Infinity Overflow Inexact Rounded
+expx050 exp -100000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+
+-- miscellanea
+-- similar to 'VF bug' test, at 17, but with last digit corrected for decimal
+precision: 16
+expx055 exp -5.42410311287441459172E+2 -> 2.717658486884572E-236 Inexact Rounded
+-- result from NetRexx/Java prototype -> 2.7176584868845721117677929628617246054459644711108E-236
+-- result from Rexx (series) version -> 2.717658486884572111767792962861724605446E-236
+precision: 17
+expx056 exp -5.42410311287441459172E+2 -> 2.7176584868845721E-236 Inexact Rounded
+precision: 18
+expx057 exp -5.42410311287441459172E+2 -> 2.71765848688457211E-236 Inexact Rounded
+precision: 19
+expx058 exp -5.42410311287441459172E+2 -> 2.717658486884572112E-236 Inexact Rounded
+precision: 20
+expx059 exp -5.42410311287441459172E+2 -> 2.7176584868845721118E-236 Inexact Rounded
+
+-- rounding in areas of ..500.., ..499.., ..100.., ..999.. sequences
+precision: 50
+expx101 exp -9E-8 -> 0.99999991000000404999987850000273374995079250073811 Inexact Rounded
+precision: 31
+expx102 exp -9E-8 -> 0.9999999100000040499998785000027 Inexact Rounded
+precision: 30
+expx103 exp -9E-8 -> 0.999999910000004049999878500003 Inexact Rounded
+precision: 29
+expx104 exp -9E-8 -> 0.99999991000000404999987850000 Inexact Rounded
+precision: 28
+expx105 exp -9E-8 -> 0.9999999100000040499998785000 Inexact Rounded
+precision: 27
+expx106 exp -9E-8 -> 0.999999910000004049999878500 Inexact Rounded
+precision: 26
+expx107 exp -9E-8 -> 0.99999991000000404999987850 Inexact Rounded
+precision: 25
+expx108 exp -9E-8 -> 0.9999999100000040499998785 Inexact Rounded
+precision: 24
+expx109 exp -9E-8 -> 0.999999910000004049999879 Inexact Rounded
+precision: 23
+expx110 exp -9E-8 -> 0.99999991000000404999988 Inexact Rounded
+precision: 22
+expx111 exp -9E-8 -> 0.9999999100000040499999 Inexact Rounded
+precision: 21
+expx112 exp -9E-8 -> 0.999999910000004050000 Inexact Rounded
+precision: 20
+expx113 exp -9E-8 -> 0.99999991000000405000 Inexact Rounded
+precision: 19
+expx114 exp -9E-8 -> 0.9999999100000040500 Inexact Rounded
+precision: 18
+expx115 exp -9E-8 -> 0.999999910000004050 Inexact Rounded
+precision: 17
+expx116 exp -9E-8 -> 0.99999991000000405 Inexact Rounded
+precision: 16
+expx117 exp -9E-8 -> 0.9999999100000040 Inexact Rounded
+precision: 15
+expx118 exp -9E-8 -> 0.999999910000004 Inexact Rounded
+precision: 14
+expx119 exp -9E-8 -> 0.99999991000000 Inexact Rounded
+precision: 13
+expx120 exp -9E-8 -> 0.9999999100000 Inexact Rounded
+precision: 12
+expx121 exp -9E-8 -> 0.999999910000 Inexact Rounded
+precision: 11
+expx122 exp -9E-8 -> 0.99999991000 Inexact Rounded
+precision: 10
+expx123 exp -9E-8 -> 0.9999999100 Inexact Rounded
+precision: 9
+expx124 exp -9E-8 -> 0.999999910 Inexact Rounded
+precision: 8
+expx125 exp -9E-8 -> 0.99999991 Inexact Rounded
+precision: 7
+expx126 exp -9E-8 -> 0.9999999 Inexact Rounded
+precision: 6
+expx127 exp -9E-8 -> 1.00000 Inexact Rounded
+precision: 5
+expx128 exp -9E-8 -> 1.0000 Inexact Rounded
+precision: 4
+expx129 exp -9E-8 -> 1.000 Inexact Rounded
+precision: 3
+expx130 exp -9E-8 -> 1.00 Inexact Rounded
+precision: 2
+expx131 exp -9E-8 -> 1.0 Inexact Rounded
+precision: 1
+expx132 exp -9E-8 -> 1 Inexact Rounded
+
+
+-- sanity checks, with iteration counts [normalized so 0<=|x|<1]
+precision: 50
+
+expx210 exp 0 -> 1
+-- iterations: 2
+expx211 exp -1E-40 -> 0.99999999999999999999999999999999999999990000000000 Inexact Rounded
+-- iterations: 8
+expx212 exp -9E-7 -> 0.99999910000040499987850002733749507925073811240510 Inexact Rounded
+-- iterations: 6
+expx213 exp -9E-8 -> 0.99999991000000404999987850000273374995079250073811 Inexact Rounded
+-- iterations: 15
+expx214 exp -0.003 -> 0.99700449550337297601206623409756091074177480489845 Inexact Rounded
+-- iterations: 14
+expx215 exp -0.001 -> 0.99900049983337499166805535716765597470235590236008 Inexact Rounded
+-- iterations: 26
+expx216 exp -0.1 -> 0.90483741803595957316424905944643662119470536098040 Inexact Rounded
+-- iterations: 39
+expx217 exp -0.7 -> 0.49658530379140951470480009339752896170766716571182 Inexact Rounded
+-- iterations: 41
+expx218 exp -0.9 -> 0.40656965974059911188345423964562598783370337617038 Inexact Rounded
+-- iterations: 43
+expx219 exp -0.99 -> 0.37157669102204569053152411990820138691802885490501 Inexact Rounded
+-- iterations: 26
+expx220 exp -1 -> 0.36787944117144232159552377016146086744581113103177 Inexact Rounded
+-- iterations: 26
+expx221 exp -1.01 -> 0.36421897957152331975704629563734548959589139192482 Inexact Rounded
+-- iterations: 27
+expx222 exp -1.1 -> 0.33287108369807955328884690643131552161247952156921 Inexact Rounded
+-- iterations: 28
+expx223 exp -1.5 -> 0.22313016014842982893328047076401252134217162936108 Inexact Rounded
+-- iterations: 30
+expx224 exp -2 -> 0.13533528323661269189399949497248440340763154590958 Inexact Rounded
+-- iterations: 36
+expx225 exp -5 -> 0.0067379469990854670966360484231484242488495850273551 Inexact Rounded
+-- iterations: 26
+expx226 exp -10 -> 0.000045399929762484851535591515560550610237918088866565 Inexact Rounded
+-- iterations: 28
+expx227 exp -14 -> 8.3152871910356788406398514256526229460765836498457E-7 Inexact Rounded
+-- iterations: 29
+expx228 exp -15 -> 3.0590232050182578837147949770228963937082078081856E-7 Inexact Rounded
+-- iterations: 30
+expx233 exp 0 -> 1
+-- iterations: 2
+expx234 exp 1E-40 -> 1.0000000000000000000000000000000000000001000000000 Inexact Rounded
+-- iterations: 7
+expx235 exp 9E-7 -> 1.0000009000004050001215000273375049207507381125949 Inexact Rounded
+-- iterations: 6
+expx236 exp 9E-8 -> 1.0000000900000040500001215000027337500492075007381 Inexact Rounded
+-- iterations: 15
+expx237 exp 0.003 -> 1.0030045045033770260129340913489002053318727195619 Inexact Rounded
+-- iterations: 13
+expx238 exp 0.001 -> 1.0010005001667083416680557539930583115630762005807 Inexact Rounded
+-- iterations: 25
+expx239 exp 0.1 -> 1.1051709180756476248117078264902466682245471947375 Inexact Rounded
+-- iterations: 38
+expx240 exp 0.7 -> 2.0137527074704765216245493885830652700175423941459 Inexact Rounded
+-- iterations: 41
+expx241 exp 0.9 -> 2.4596031111569496638001265636024706954217723064401 Inexact Rounded
+-- iterations: 42
+expx242 exp 0.99 -> 2.6912344723492622890998794040710139721802931841030 Inexact Rounded
+-- iterations: 26
+expx243 exp 1 -> 2.7182818284590452353602874713526624977572470937000 Inexact Rounded
+-- iterations: 26
+expx244 exp 1.01 -> 2.7456010150169164939897763166603876240737508195960 Inexact Rounded
+-- iterations: 26
+expx245 exp 1.1 -> 3.0041660239464331120584079535886723932826810260163 Inexact Rounded
+-- iterations: 28
+expx246 exp 1.5 -> 4.4816890703380648226020554601192758190057498683697 Inexact Rounded
+-- iterations: 29
+expx247 exp 2 -> 7.3890560989306502272304274605750078131803155705518 Inexact Rounded
+-- iterations: 36
+expx248 exp 5 -> 148.41315910257660342111558004055227962348766759388 Inexact Rounded
+-- iterations: 26
+expx249 exp 10 -> 22026.465794806716516957900645284244366353512618557 Inexact Rounded
+-- iterations: 28
+expx250 exp 14 -> 1202604.2841647767777492367707678594494124865433761 Inexact Rounded
+-- iterations: 28
+expx251 exp 15 -> 3269017.3724721106393018550460917213155057385438200 Inexact Rounded
+-- iterations: 29
+
+-- a biggie [result verified 3 ways]
+precision: 250
+expx260 exp 1 -> 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668 Inexact Rounded
+
+-- extreme range boundaries
+precision: 16
+maxExponent: 999999
+minExponent: -999999
+-- Ntiny boundary
+expx290 exp -2302618.022332529 -> 0E-1000014 Underflow Subnormal Inexact Rounded Clamped
+expx291 exp -2302618.022332528 -> 1E-1000014 Underflow Subnormal Inexact Rounded
+-- Nmax/10 and Nmax boundary
+expx292 exp 2302582.790408952 -> 9.999999993100277E+999998 Inexact Rounded
+expx293 exp 2302582.790408953 -> 1.000000000310028E+999999 Inexact Rounded
+expx294 exp 2302585.092993946 -> 9.999999003159870E+999999 Inexact Rounded
+expx295 exp 2302585.092994036 -> 9.999999903159821E+999999 Inexact Rounded
+expx296 exp 2302585.092994045 -> 9.999999993159820E+999999 Inexact Rounded
+expx297 exp 2302585.092994046 -> Infinity Overflow Inexact Rounded
+
+-- 0<-x<<1 effects
+precision: 30
+expx320 exp -4.9999999999999E-8 -> 0.999999950000001250000979166617 Inexact Rounded
+expx321 exp -5.0000000000000E-8 -> 0.999999950000001249999979166667 Inexact Rounded
+expx322 exp -5.0000000000001E-8 -> 0.999999950000001249998979166717 Inexact Rounded
+precision: 20
+expx323 exp -4.9999999999999E-8 -> 0.99999995000000125000 Inexact Rounded
+expx324 exp -5.0000000000000E-8 -> 0.99999995000000125000 Inexact Rounded
+expx325 exp -5.0000000000001E-8 -> 0.99999995000000125000 Inexact Rounded
+precision: 14
+expx326 exp -4.9999999999999E-8 -> 0.99999995000000 Inexact Rounded
+expx327 exp -5.0000000000000E-8 -> 0.99999995000000 Inexact Rounded
+expx328 exp -5.0000000000001E-8 -> 0.99999995000000 Inexact Rounded
+-- overprecise and 0<-x<<1
+precision: 8
+expx330 exp -4.9999999999999E-8 -> 0.99999995 Inexact Rounded
+expx331 exp -5.0000000000000E-8 -> 0.99999995 Inexact Rounded
+expx332 exp -5.0000000000001E-8 -> 0.99999995 Inexact Rounded
+precision: 7
+expx333 exp -4.9999999999999E-8 -> 1.000000 Inexact Rounded
+expx334 exp -5.0000000000000E-8 -> 1.000000 Inexact Rounded
+expx335 exp -5.0000000000001E-8 -> 1.000000 Inexact Rounded
+precision: 3
+expx336 exp -4.9999999999999E-8 -> 1.00 Inexact Rounded
+expx337 exp -5.0000000000000E-8 -> 1.00 Inexact Rounded
+expx338 exp -5.0000000000001E-8 -> 1.00 Inexact Rounded
+
+-- 0<x<<1 effects
+precision: 30
+expx340 exp 4.9999999999999E-8 -> 1.00000005000000124999902083328 Inexact Rounded
+expx341 exp 5.0000000000000E-8 -> 1.00000005000000125000002083333 Inexact Rounded
+expx342 exp 5.0000000000001E-8 -> 1.00000005000000125000102083338 Inexact Rounded
+precision: 20
+expx343 exp 4.9999999999999E-8 -> 1.0000000500000012500 Inexact Rounded
+expx344 exp 5.0000000000000E-8 -> 1.0000000500000012500 Inexact Rounded
+expx345 exp 5.0000000000001E-8 -> 1.0000000500000012500 Inexact Rounded
+precision: 14
+expx346 exp 4.9999999999999E-8 -> 1.0000000500000 Inexact Rounded
+expx347 exp 5.0000000000000E-8 -> 1.0000000500000 Inexact Rounded
+expx348 exp 5.0000000000001E-8 -> 1.0000000500000 Inexact Rounded
+-- overprecise and 0<x<<1
+precision: 8
+expx350 exp 4.9999999999999E-8 -> 1.0000001 Inexact Rounded
+expx351 exp 5.0000000000000E-8 -> 1.0000001 Inexact Rounded
+expx352 exp 5.0000000000001E-8 -> 1.0000001 Inexact Rounded
+precision: 7
+expx353 exp 4.9999999999999E-8 -> 1.000000 Inexact Rounded
+expx354 exp 5.0000000000000E-8 -> 1.000000 Inexact Rounded
+expx355 exp 5.0000000000001E-8 -> 1.000000 Inexact Rounded
+precision: 3
+expx356 exp 4.9999999999999E-8 -> 1.00 Inexact Rounded
+expx357 exp 5.0000000000000E-8 -> 1.00 Inexact Rounded
+expx358 exp 5.0000000000001E-8 -> 1.00 Inexact Rounded
+
+-- cases near 1 -- 1 2345678901234567890
+precision: 20
+expx401 exp 0.99999999999996 -> 2.7182818284589365041 Inexact Rounded
+expx402 exp 0.99999999999997 -> 2.7182818284589636869 Inexact Rounded
+expx403 exp 0.99999999999998 -> 2.7182818284589908697 Inexact Rounded
+expx404 exp 0.99999999999999 -> 2.7182818284590180525 Inexact Rounded
+expx405 exp 1.0000000000000 -> 2.7182818284590452354 Inexact Rounded
+expx406 exp 1.0000000000001 -> 2.7182818284593170635 Inexact Rounded
+expx407 exp 1.0000000000002 -> 2.7182818284595888917 Inexact Rounded
+precision: 14
+expx411 exp 0.99999999999996 -> 2.7182818284589 Inexact Rounded
+expx412 exp 0.99999999999997 -> 2.7182818284590 Inexact Rounded
+expx413 exp 0.99999999999998 -> 2.7182818284590 Inexact Rounded
+expx414 exp 0.99999999999999 -> 2.7182818284590 Inexact Rounded
+expx415 exp 1.0000000000000 -> 2.7182818284590 Inexact Rounded
+expx416 exp 1.0000000000001 -> 2.7182818284593 Inexact Rounded
+expx417 exp 1.0000000000002 -> 2.7182818284596 Inexact Rounded
+-- overprecise...
+precision: 7
+expx421 exp 0.99999999999996 -> 2.718282 Inexact Rounded
+expx422 exp 0.99999999999997 -> 2.718282 Inexact Rounded
+expx423 exp 0.99999999999998 -> 2.718282 Inexact Rounded
+expx424 exp 0.99999999999999 -> 2.718282 Inexact Rounded
+expx425 exp 1.0000000000001 -> 2.718282 Inexact Rounded
+expx426 exp 1.0000000000002 -> 2.718282 Inexact Rounded
+expx427 exp 1.0000000000003 -> 2.718282 Inexact Rounded
+precision: 2
+expx431 exp 0.99999999999996 -> 2.7 Inexact Rounded
+expx432 exp 0.99999999999997 -> 2.7 Inexact Rounded
+expx433 exp 0.99999999999998 -> 2.7 Inexact Rounded
+expx434 exp 0.99999999999999 -> 2.7 Inexact Rounded
+expx435 exp 1.0000000000001 -> 2.7 Inexact Rounded
+expx436 exp 1.0000000000002 -> 2.7 Inexact Rounded
+expx437 exp 1.0000000000003 -> 2.7 Inexact Rounded
+
+-- basics at low precisions
+precision: 3
+expx501 exp -Infinity -> 0
+expx502 exp -10 -> 0.0000454 Inexact Rounded
+expx503 exp -1 -> 0.368 Inexact Rounded
+expx504 exp 0 -> 1
+expx505 exp -0 -> 1
+expx506 exp 1 -> 2.72 Inexact Rounded
+expx507 exp 0.693147181 -> 2.00 Inexact Rounded
+expx508 exp 10 -> 2.20E+4 Inexact Rounded
+expx509 exp +Infinity -> Infinity
+precision: 2
+expx511 exp -Infinity -> 0
+expx512 exp -10 -> 0.000045 Inexact Rounded
+expx513 exp -1 -> 0.37 Inexact Rounded
+expx514 exp 0 -> 1
+expx515 exp -0 -> 1
+expx516 exp 1 -> 2.7 Inexact Rounded
+expx517 exp 0.693147181 -> 2.0 Inexact Rounded
+expx518 exp 10 -> 2.2E+4 Inexact Rounded
+expx519 exp +Infinity -> Infinity
+precision: 1
+expx521 exp -Infinity -> 0
+expx522 exp -10 -> 0.00005 Inexact Rounded
+expx523 exp -1 -> 0.4 Inexact Rounded
+expx524 exp 0 -> 1
+expx525 exp -0 -> 1
+expx526 exp 1 -> 3 Inexact Rounded
+expx527 exp 0.693147181 -> 2 Inexact Rounded
+expx528 exp 10 -> 2E+4 Inexact Rounded
+expx529 exp +Infinity -> Infinity
+
+-- overflows, including some overprecise borderlines
+precision: 7
+maxExponent: 384
+minExponent: -383
+expx701 exp 1000000000 -> Infinity Overflow Inexact Rounded
+expx702 exp 100000000 -> Infinity Overflow Inexact Rounded
+expx703 exp 10000000 -> Infinity Overflow Inexact Rounded
+expx704 exp 1000000 -> Infinity Overflow Inexact Rounded
+expx705 exp 100000 -> Infinity Overflow Inexact Rounded
+expx706 exp 10000 -> Infinity Overflow Inexact Rounded
+expx707 exp 1000 -> Infinity Overflow Inexact Rounded
+expx708 exp 886.4952608 -> Infinity Overflow Inexact Rounded
+expx709 exp 886.4952607 -> 9.999999E+384 Inexact Rounded
+expx710 exp 886.49527 -> Infinity Overflow Inexact Rounded
+expx711 exp 886.49526 -> 9.999992E+384 Inexact Rounded
+precision: 16
+expx721 exp 886.4952608027075883 -> Infinity Overflow Inexact Rounded
+expx722 exp 886.4952608027075882 -> 9.999999999999999E+384 Inexact Rounded
+expx723 exp 886.49526080270759 -> Infinity Overflow Inexact Rounded
+expx724 exp 886.49526080270758 -> 9.999999999999917E+384 Inexact Rounded
+expx725 exp 886.4952608027076 -> Infinity Overflow Inexact Rounded
+expx726 exp 886.4952608027075 -> 9.999999999999117E+384 Inexact Rounded
+-- and by special request ...
+precision: 15
+expx731 exp 886.495260802708 -> Infinity Overflow Inexact Rounded
+expx732 exp 886.495260802707 -> 9.99999999999412E+384 Inexact Rounded
+expx733 exp 886.495260802706 -> 9.99999999998412E+384 Inexact Rounded
+maxExponent: 999
+minExponent: -999
+expx735 exp 2302.58509299405 -> Infinity Overflow Inexact Rounded
+expx736 exp 2302.58509299404 -> 9.99999999994316E+999 Inexact Rounded
+expx737 exp 2302.58509299403 -> 9.99999999984316E+999 Inexact Rounded
+
+-- subnormals and underflows, including underflow-to-zero edge point
+precision: 7
+maxExponent: 384
+minExponent: -383
+expx751 exp -1000000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx752 exp -100000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx753 exp -10000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx754 exp -1000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx755 exp -100000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx756 exp -10000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx757 exp -1000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx758 exp -881.89009 -> 1.000001E-383 Inexact Rounded
+expx759 exp -881.8901 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
+expx760 exp -885 -> 4.4605E-385 Inexact Rounded Underflow Subnormal
+expx761 exp -888 -> 2.221E-386 Inexact Rounded Underflow Subnormal
+expx762 exp -890 -> 3.01E-387 Inexact Rounded Underflow Subnormal
+expx763 exp -892.9 -> 1.7E-388 Inexact Rounded Underflow Subnormal
+expx764 exp -893 -> 1.5E-388 Inexact Rounded Underflow Subnormal
+expx765 exp -893.5 -> 9E-389 Inexact Rounded Underflow Subnormal
+expx766 exp -895.7056 -> 1E-389 Inexact Rounded Underflow Subnormal
+expx769 exp -895.8 -> 1E-389 Inexact Rounded Underflow Subnormal
+expx770 exp -895.73 -> 1E-389 Inexact Rounded Underflow Subnormal
+expx771 exp -896.3987 -> 1E-389 Inexact Rounded Underflow Subnormal
+expx772 exp -896.3988 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
+expx773 exp -898.0081 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
+expx774 exp -898.0082 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
+
+-- special values
+maxexponent: 999
+minexponent: -999
+expx820 exp Inf -> Infinity
+expx821 exp -Inf -> 0
+expx822 exp NaN -> NaN
+expx823 exp sNaN -> NaN Invalid_operation
+-- propagating NaNs
+expx824 exp sNaN123 -> NaN123 Invalid_operation
+expx825 exp -sNaN321 -> -NaN321 Invalid_operation
+expx826 exp NaN456 -> NaN456
+expx827 exp -NaN654 -> -NaN654
+expx828 exp NaN1 -> NaN1
+
+-- Invalid operations due to restrictions
+-- [next two probably skipped by most test harnesses]
+precision: 100000000
+expx901 exp -Infinity -> NaN Invalid_context
+precision: 99999999
+expx902 exp -Infinity -> NaN Invalid_context
+
+precision: 9
+maxExponent: 1000000
+minExponent: -999999
+expx903 exp -Infinity -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999999
+expx904 exp -Infinity -> 0
+maxExponent: 999999
+minExponent: -1000000
+expx905 exp -Infinity -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999998
+expx906 exp -Infinity -> 0
+
+--
+maxExponent: 384
+minExponent: -383
+precision: 16
+rounding: half_even
+
+-- Null test
+expx900 exp # -> NaN Invalid_operation
+
+
+-- Randoms P=50, within 0-999
+Precision: 50
+maxExponent: 384
+minExponent: -383
+expx1501 exp 656.35397950590285612266095596539934213943872885728 -> 1.1243757610640319783611178528839652672062820040314E+285 Inexact Rounded
+expx1502 exp 0.93620571093652800225038550600780322831236082781471 -> 2.5502865130986176689199711857825771311178046842009 Inexact Rounded
+expx1503 exp 0.00000000000000008340785856601514714183373874105791 -> 1.0000000000000000834078585660151506202691740252512 Inexact Rounded
+expx1504 exp 0.00009174057262887789625745574686545163168788456203 -> 1.0000917447809239005146722341251524081006051473273 Inexact Rounded
+expx1505 exp 33.909116897973797735657751591014926629051117541243 -> 532773181025002.03543618901306726495870476617232229 Inexact Rounded
+expx1506 exp 0.00000740470413004406592124575295278456936809587311 -> 1.0000074047315449333590066395670306135567889210814 Inexact Rounded
+expx1507 exp 0.00000000000124854922222108802453746922483071445492 -> 1.0000000000012485492222218674621176239911424968263 Inexact Rounded
+expx1508 exp 4.1793280674155659794286951159430651258356014391382 -> 65.321946520147199404199787811336860087975118278185 Inexact Rounded
+expx1509 exp 485.43595745460655893746179890255529919221550201686 -> 6.6398403920459617255950476953129377459845366585463E+210 Inexact Rounded
+expx1510 exp 0.00000000003547259806590856032527875157830328156597 -> 1.0000000000354725980665377129320589406715000685515 Inexact Rounded
+expx1511 exp 0.00000000000000759621497339104047930616478635042678 -> 1.0000000000000075962149733910693305471257715463887 Inexact Rounded
+expx1512 exp 9.7959168821760339304571595474480640286072720233796 -> 17960.261146042955179164303653412650751681436352437 Inexact Rounded
+expx1513 exp 0.00000000566642006258290526783901451194943164535581 -> 1.0000000056664200786370634609832438815665249347650 Inexact Rounded
+expx1514 exp 741.29888791134298194088827572374718940925820027354 -> 8.7501694006317332808128946666402622432064923198731E+321 Inexact Rounded
+expx1515 exp 032.75573003552517668808529099897153710887014947935 -> 168125196578678.17725841108617955904425345631092339 Inexact Rounded
+expx1516 exp 42.333700726429333308594265553422902463737399437644 -> 2428245675864172475.4681119493045657797309369672012 Inexact Rounded
+expx1517 exp 0.00000000000000559682616876491888197609158802835798 -> 1.0000000000000055968261687649345442076732739577049 Inexact Rounded
+expx1518 exp 0.00000000000080703688668280193584758300973549486312 -> 1.0000000000008070368866831275901158164321867914342 Inexact Rounded
+expx1519 exp 640.72396012796509482382712891709072570653606838251 -> 1.8318094990683394229304133068983914236995326891045E+278 Inexact Rounded
+expx1520 exp 0.00000000000000509458922167631071416948112219512224 -> 1.0000000000000050945892216763236915891499324358556 Inexact Rounded
+expx1521 exp 6.7670394314315206378625221583973414660727960241395 -> 868.73613012822031367806248697092884415119568271315 Inexact Rounded
+expx1522 exp 04.823217407412963506638267226891024138054783122548 -> 124.36457929588837129731821077586705505565904205366 Inexact Rounded
+expx1523 exp 193.51307878701196403991208482520115359690106143615 -> 1.1006830872854715677390914655452261550768957576034E+84 Inexact Rounded
+expx1524 exp 5.7307749038303650539200345901210497015617393970463 -> 308.20800743106843083522721523715645950574866495196 Inexact Rounded
+expx1525 exp 0.00000000000095217825199797965200541169123743500267 -> 1.0000000000009521782519984329737172007991390381273 Inexact Rounded
+expx1526 exp 0.00027131440949183370966393682617930153495028919140 -> 1.0002713512185751022906058160480606598754913607364 Inexact Rounded
+expx1527 exp 0.00000000064503059114680682343002315662069272707123 -> 1.0000000006450305913548390552323517403613135496633 Inexact Rounded
+expx1528 exp 0.00000000000000095616643506527288866235238548440593 -> 1.0000000000000009561664350652733457894781582009094 Inexact Rounded
+expx1529 exp 0.00000000000000086449942811678650244459550252743433 -> 1.0000000000000008644994281167868761242261096529986 Inexact Rounded
+expx1530 exp 0.06223488355635359965683053157729204988381887621850 -> 1.0642122813392406657789688931838919323826250630831 Inexact Rounded
+expx1531 exp 0.00000400710807804429435502657131912308680674057053 -> 1.0000040071161065125925620890019319832127863559260 Inexact Rounded
+expx1532 exp 85.522796894744576211573232055494551429297878413017 -> 13870073686404228452757799770251085177.853337368935 Inexact Rounded
+expx1533 exp 9.1496720811363678696938036379756663548353399954363 -> 9411.3537122832743386783597629161763057370034495157 Inexact Rounded
+expx1534 exp 8.2215705240788294472944382056330516738577785177942 -> 3720.3406813383076953899654701615084425598377758189 Inexact Rounded
+expx1535 exp 0.00000000015772064569640613142823203726821076239561 -> 1.0000000001577206457088440324683315788358926129830 Inexact Rounded
+expx1536 exp 0.58179346473959531432624153576883440625538017532480 -> 1.7892445018275360163797022372655837188423194863605 Inexact Rounded
+expx1537 exp 33.555726197149525061455517784870570470833498096559 -> 374168069896324.62578073148993526626307095854407952 Inexact Rounded
+expx1538 exp 9.7898079803906215094140010009583375537259810398659 -> 17850.878119912208888217100998019986634620368538426 Inexact Rounded
+expx1539 exp 89.157697327174521542502447953032536541038636966347 -> 525649152320166503771224149330448089550.67293829227 Inexact Rounded
+expx1540 exp 25.022947600123328912029051897171319573322888514885 -> 73676343442.952517824345431437683153304645851960524 Inexact Rounded
+
+-- exp(1) at 34
+Precision: 34
+expx1200 exp 1 -> 2.718281828459045235360287471352662 Inexact Rounded
+
+-- Randoms P=34, within 0-999
+Precision: 34
+maxExponent: 6144
+minExponent: -6143
+expx1201 exp 309.5948855821510212996700645087188 -> 2.853319692901387521201738015050724E+134 Inexact Rounded
+expx1202 exp 9.936543068706211420422803962680164 -> 20672.15839203171877476511093276022 Inexact Rounded
+expx1203 exp 6.307870323881505684429839491707908 -> 548.8747777054637296137277391754665 Inexact Rounded
+expx1204 exp 0.0003543281389438420535201308282503 -> 1.000354390920573746164733350843155 Inexact Rounded
+expx1205 exp 0.0000037087453363918375598394920229 -> 1.000003708752213796324841920189323 Inexact Rounded
+expx1206 exp 0.0020432312687512438040222444116585 -> 1.002045320088164826013561630975308 Inexact Rounded
+expx1207 exp 6.856313340032177672550343216129586 -> 949.8587981604144147983589660524396 Inexact Rounded
+expx1208 exp 0.0000000000402094928333815643326418 -> 1.000000000040209492834189965989612 Inexact Rounded
+expx1209 exp 0.0049610784722412117632647003545839 -> 1.004973404997901987039589029277833 Inexact Rounded
+expx1210 exp 0.0000891471883724066909746786702686 -> 1.000089151162101085412780088266699 Inexact Rounded
+expx1211 exp 08.59979170376061890684723211112566 -> 5430.528314920905714615339273738097 Inexact Rounded
+expx1212 exp 9.473117039341003854872778112752590 -> 13005.36234331224953460055897913917 Inexact Rounded
+expx1213 exp 0.0999060724692207648429969999310118 -> 1.105067116975190602296052700726802 Inexact Rounded
+expx1214 exp 0.0000000927804533555877884082269247 -> 1.000000092780457659694183954740772 Inexact Rounded
+expx1215 exp 0.0376578583872889916298772818265677 -> 1.038375900489771946477857818447556 Inexact Rounded
+expx1216 exp 261.6896411697539524911536116712307 -> 4.470613562127465095241600174941460E+113 Inexact Rounded
+expx1217 exp 0.0709997423269162980875824213889626 -> 1.073580949235407949417814485533172 Inexact Rounded
+expx1218 exp 0.0000000444605583295169895235658731 -> 1.000000044460559317887627657593900 Inexact Rounded
+expx1219 exp 0.0000021224072854777512281369815185 -> 1.000002122409537785687390631070906 Inexact Rounded
+expx1220 exp 547.5174462574156885473558485475052 -> 6.078629247383807942612114579728672E+237 Inexact Rounded
+expx1221 exp 0.0000009067598041615192002339844670 -> 1.000000906760215268314680115374387 Inexact Rounded
+expx1222 exp 0.0316476500308065365803455533244603 -> 1.032153761880187977658387961769034 Inexact Rounded
+expx1223 exp 84.46160530377645101833996706384473 -> 4.799644995897968383503269871697856E+36 Inexact Rounded
+expx1224 exp 0.0000000000520599740290848018904145 -> 1.000000000052059974030439922338393 Inexact Rounded
+expx1225 exp 0.0000006748530640093620665651726708 -> 1.000000674853291722742292331812997 Inexact Rounded
+expx1226 exp 0.0000000116853119761042020507916169 -> 1.000000011685312044377460306165203 Inexact Rounded
+expx1227 exp 0.0022593818094258636727616886693280 -> 1.002261936135876893707094845543461 Inexact Rounded
+expx1228 exp 0.0029398857673478912249856509667517 -> 1.002944211469495086813087651287012 Inexact Rounded
+expx1229 exp 0.7511480029928802775376270557636963 -> 2.119431734510320169806976569366789 Inexact Rounded
+expx1230 exp 174.9431952176750671150886423048447 -> 9.481222305374955011464619468044051E+75 Inexact Rounded
+expx1231 exp 0.0000810612451694136129199895164424 -> 1.000081064530720924186615149646920 Inexact Rounded
+expx1232 exp 51.06888989702669288180946272499035 -> 15098613888619165073959.89896018749 Inexact Rounded
+expx1233 exp 0.0000000005992887599437093651494510 -> 1.000000000599288760123282874082758 Inexact Rounded
+expx1234 exp 714.8549046761054856311108828903972 -> 2.867744544891081117381595080480784E+310 Inexact Rounded
+expx1235 exp 0.0000000004468247802990643645607110 -> 1.000000000446824780398890556720233 Inexact Rounded
+expx1236 exp 831.5818151589890366323551672043709 -> 1.417077409182624969435938062261655E+361 Inexact Rounded
+expx1237 exp 0.0000000006868323825179605747108044 -> 1.000000000686832382753829935602454 Inexact Rounded
+expx1238 exp 0.0000001306740266408976840228440255 -> 1.000000130674035178748675187648098 Inexact Rounded
+expx1239 exp 0.3182210609022267704811502412335163 -> 1.374680115667798185758927247894859 Inexact Rounded
+expx1240 exp 0.0147741234179104437440264644295501 -> 1.014883800239950682628277534839222 Inexact Rounded
+
+-- Randoms P=16, within 0-99
+Precision: 16
+maxExponent: 384
+minExponent: -383
+expx1101 exp 8.473011527013724 -> 4783.900643969246 Inexact Rounded
+expx1102 exp 0.0000055753022764 -> 1.000005575317818 Inexact Rounded
+expx1103 exp 0.0000323474114482 -> 1.000032347934631 Inexact Rounded
+expx1104 exp 64.54374138544166 -> 1.073966476173531E+28 Inexact Rounded
+expx1105 exp 90.47203246416569 -> 1.956610887250643E+39 Inexact Rounded
+expx1106 exp 9.299931532342757 -> 10937.27033325227 Inexact Rounded
+expx1107 exp 8.759678437852203 -> 6372.062234495381 Inexact Rounded
+expx1108 exp 0.0000931755127172 -> 1.000093179853690 Inexact Rounded
+expx1109 exp 0.0000028101158373 -> 1.000002810119786 Inexact Rounded
+expx1110 exp 0.0000008008130919 -> 1.000000800813413 Inexact Rounded
+expx1111 exp 8.339771722299049 -> 4187.133803081878 Inexact Rounded
+expx1112 exp 0.0026140497995474 -> 1.002617469406750 Inexact Rounded
+expx1113 exp 0.7478033356261771 -> 2.112354781975418 Inexact Rounded
+expx1114 exp 51.77663761827966 -> 3.064135801120365E+22 Inexact Rounded
+expx1115 exp 0.1524989783061012 -> 1.164741272084955 Inexact Rounded
+expx1116 exp 0.0066298798669219 -> 1.006651906170791 Inexact Rounded
+expx1117 exp 9.955141865534960 -> 21060.23334287038 Inexact Rounded
+expx1118 exp 92.34503059198483 -> 1.273318993481226E+40 Inexact Rounded
+expx1119 exp 0.0000709388677346 -> 1.000070941383956 Inexact Rounded
+expx1120 exp 79.12883036433204 -> 2.318538899389243E+34 Inexact Rounded
+expx1121 exp 0.0000090881548873 -> 1.000009088196185 Inexact Rounded
+expx1122 exp 0.0424828809603411 -> 1.043398194245720 Inexact Rounded
+expx1123 exp 0.8009035891427416 -> 2.227552811933310 Inexact Rounded
+expx1124 exp 8.825786167283102 -> 6807.540455289995 Inexact Rounded
+expx1125 exp 1.535457249746275 -> 4.643448260146849 Inexact Rounded
+expx1126 exp 69.02254254355800 -> 9.464754500670653E+29 Inexact Rounded
+expx1127 exp 0.0007050554368713 -> 1.000705304046880 Inexact Rounded
+expx1128 exp 0.0000081206549504 -> 1.000008120687923 Inexact Rounded
+expx1129 exp 0.621774854641137 -> 1.862230298554903 Inexact Rounded
+expx1130 exp 3.847629031404354 -> 46.88177613568203 Inexact Rounded
+expx1131 exp 24.81250184697732 -> 59694268456.19966 Inexact Rounded
+expx1132 exp 5.107546500516044 -> 165.2643809755670 Inexact Rounded
+expx1133 exp 79.17810943951986 -> 2.435656372541360E+34 Inexact Rounded
+expx1134 exp 0.0051394695667015 -> 1.005152699295301 Inexact Rounded
+expx1135 exp 57.44504488501725 -> 8.872908566929688E+24 Inexact Rounded
+expx1136 exp 0.0000508388968036 -> 1.000050840189122 Inexact Rounded
+expx1137 exp 69.71309932148997 -> 1.888053740693541E+30 Inexact Rounded
+expx1138 exp 0.0064183412981502 -> 1.006438982988835 Inexact Rounded
+expx1139 exp 9.346991220814677 -> 11464.27802035082 Inexact Rounded
+expx1140 exp 33.09087139999152 -> 235062229168763.5 Inexact Rounded
+
+-- Randoms P=7, within 0-9
+Precision: 7
+maxExponent: 96
+minExponent: -95
+expx1001 exp 2.395441 -> 10.97304 Inexact Rounded
+expx1002 exp 0.6406779 -> 1.897767 Inexact Rounded
+expx1003 exp 0.5618218 -> 1.753865 Inexact Rounded
+expx1004 exp 3.055120 -> 21.22373 Inexact Rounded
+expx1005 exp 1.536792 -> 4.649650 Inexact Rounded
+expx1006 exp 0.0801591 -> 1.083459 Inexact Rounded
+expx1007 exp 0.0966875 -> 1.101516 Inexact Rounded
+expx1008 exp 0.0646761 -> 1.066813 Inexact Rounded
+expx1009 exp 0.0095670 -> 1.009613 Inexact Rounded
+expx1010 exp 2.956859 -> 19.23745 Inexact Rounded
+expx1011 exp 7.504679 -> 1816.522 Inexact Rounded
+expx1012 exp 0.0045259 -> 1.004536 Inexact Rounded
+expx1013 exp 3.810071 -> 45.15364 Inexact Rounded
+expx1014 exp 1.502390 -> 4.492413 Inexact Rounded
+expx1015 exp 0.0321523 -> 1.032675 Inexact Rounded
+expx1016 exp 0.0057214 -> 1.005738 Inexact Rounded
+expx1017 exp 9.811445 -> 18241.33 Inexact Rounded
+expx1018 exp 3.245249 -> 25.66810 Inexact Rounded
+expx1019 exp 0.3189742 -> 1.375716 Inexact Rounded
+expx1020 exp 0.8621610 -> 2.368273 Inexact Rounded
+expx1021 exp 0.0122511 -> 1.012326 Inexact Rounded
+expx1022 exp 2.202088 -> 9.043877 Inexact Rounded
+expx1023 exp 8.778203 -> 6491.202 Inexact Rounded
+expx1024 exp 0.1896279 -> 1.208800 Inexact Rounded
+expx1025 exp 0.4510947 -> 1.570030 Inexact Rounded
+expx1026 exp 0.276413 -> 1.318392 Inexact Rounded
+expx1027 exp 4.490067 -> 89.12742 Inexact Rounded
+expx1028 exp 0.0439786 -> 1.044960 Inexact Rounded
+expx1029 exp 0.8168245 -> 2.263301 Inexact Rounded
+expx1030 exp 0.0391658 -> 1.039943 Inexact Rounded
+expx1031 exp 9.261816 -> 10528.24 Inexact Rounded
+expx1032 exp 9.611186 -> 14930.87 Inexact Rounded
+expx1033 exp 9.118125 -> 9119.087 Inexact Rounded
+expx1034 exp 9.469083 -> 12953.00 Inexact Rounded
+expx1035 exp 0.0499983 -> 1.051269 Inexact Rounded
+expx1036 exp 0.0050746 -> 1.005087 Inexact Rounded
+expx1037 exp 0.0014696 -> 1.001471 Inexact Rounded
+expx1038 exp 9.138494 -> 9306.739 Inexact Rounded
+expx1039 exp 0.0065436 -> 1.006565 Inexact Rounded
+expx1040 exp 0.7284803 -> 2.071930 Inexact Rounded
+
diff --git a/Lib/test/decimaltestdata/fma.decTest b/Lib/test/decimaltestdata/fma.decTest
index a8197ef8a4..b0a81ca179 100644
--- a/Lib/test/decimaltestdata/fma.decTest
+++ b/Lib/test/decimaltestdata/fma.decTest
@@ -1,3426 +1,3426 @@
-------------------------------------------------------------------------
--- fma.decTest -- decimal fused multiply add --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- These tests comprese three parts:
--- 1. Sanity checks and other three-operand tests (especially those
--- where the fused operation makes a difference)
--- 2. Multiply tests (third operand is neutral zero [0E+emax])
--- 3. Addition tests (first operand is 1)
--- The multiply and addition tests are extensive because FMA may have
--- its own dedicated multiplication or addition routine(s), and they
--- also inherently check the left-to-right properties.
-
--- Sanity checks
-fmax0001 fma 1 1 1 -> 2
-fmax0002 fma 1 1 2 -> 3
-fmax0003 fma 2 2 3 -> 7
-fmax0004 fma 9 9 9 -> 90
-fmax0005 fma -1 1 1 -> 0
-fmax0006 fma -1 1 2 -> 1
-fmax0007 fma -2 2 3 -> -1
-fmax0008 fma -9 9 9 -> -72
-fmax0011 fma 1 -1 1 -> 0
-fmax0012 fma 1 -1 2 -> 1
-fmax0013 fma 2 -2 3 -> -1
-fmax0014 fma 9 -9 9 -> -72
-fmax0015 fma 1 1 -1 -> 0
-fmax0016 fma 1 1 -2 -> -1
-fmax0017 fma 2 2 -3 -> 1
-fmax0018 fma 9 9 -9 -> 72
-fmax0019 fma 3 5 7 -> 22
-fmax0029 fma 3 -5 7 -> -8
-
--- non-integer exacts
-fma0100 fma 25.2 63.6 -438 -> 1164.72
-fma0101 fma 0.301 0.380 334 -> 334.114380
-fma0102 fma 49.2 -4.8 23.3 -> -212.86
-fma0103 fma 4.22 0.079 -94.6 -> -94.26662
-fma0104 fma 903 0.797 0.887 -> 720.578
-fma0105 fma 6.13 -161 65.9 -> -921.03
-fma0106 fma 28.2 727 5.45 -> 20506.85
-fma0107 fma 4 605 688 -> 3108
-fma0108 fma 93.3 0.19 0.226 -> 17.953
-fma0109 fma 0.169 -341 5.61 -> -52.019
-fma0110 fma -72.2 30 -51.2 -> -2217.2
-fma0111 fma -0.409 13 20.4 -> 15.083
-fma0112 fma 317 77.0 19.0 -> 24428.0
-fma0113 fma 47 6.58 1.62 -> 310.88
-fma0114 fma 1.36 0.984 0.493 -> 1.83124
-fma0115 fma 72.7 274 1.56 -> 19921.36
-fma0116 fma 335 847 83 -> 283828
-fma0117 fma 666 0.247 25.4 -> 189.902
-fma0118 fma -3.87 3.06 78.0 -> 66.1578
-fma0119 fma 0.742 192 35.6 -> 178.064
-fma0120 fma -91.6 5.29 0.153 -> -484.411
-
--- cases where result is different from separate multiply + add; each
--- is preceded by the result of unfused multiply and add
--- [this is about 20% of all similar cases in general]
--- 888565290 1557.96930 -86087.7578 -> 1.38435735E+12
-fma0201 fma 888565290 1557.96930 -86087.7578 -> 1.38435736E+12 Inexact Rounded
--- -85519342.9 735155419 42010431 -> -6.28700084E+16
-fma0205 fma -85519342.9 735155419 42010431 -> -6.28700083E+16 Inexact Rounded
--- -98025.5 -294603.472 10414348.2 -> 2.88890669E+10
-fma0208 fma -98025.5 -294603.472 10414348.2 -> 2.88890670E+10 Inexact Rounded
--- 5967627.39 83526540.6 498494.810 -> 4.98455271E+14
-fma0211 fma 5967627.39 83526540.6 498494.810 -> 4.98455272E+14 Inexact Rounded
--- 3456.9433 874.39518 197866.615 -> 3220601.18
-fma0216 fma 3456.9433 874.39518 197866.615 -> 3220601.17 Inexact Rounded
--- 62769.8287 2096.98927 48.420317 -> 131627705
-fma0218 fma 62769.8287 2096.98927 48.420317 -> 131627706 Inexact Rounded
--- -68.81500 59961113.9 -8988862 -> -4.13521291E+9
-fma0219 fma -68.81500 59961113.9 -8988862 -> -4.13521292E+9 Inexact Rounded
--- 2126341.02 63491.5152 302427455 -> 1.35307040E+11
-fma0226 fma 2126341.02 63491.5152 302427455 -> 1.35307041E+11 Inexact Rounded
-
-
--- Infinite combinations
-fmax0800 fma Inf Inf Inf -> Infinity
-fmax0801 fma Inf Inf -Inf -> NaN Invalid_operation
-fmax0802 fma Inf -Inf Inf -> NaN Invalid_operation
-fmax0803 fma Inf -Inf -Inf -> -Infinity
-fmax0804 fma -Inf Inf Inf -> NaN Invalid_operation
-fmax0805 fma -Inf Inf -Inf -> -Infinity
-fmax0806 fma -Inf -Inf Inf -> Infinity
-fmax0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
-fmax0808 fma -Inf 0 1 -> NaN Invalid_operation
-fmax0809 fma -Inf 0 NaN -> NaN Invalid_operation
-
--- Triple NaN propagation
-fmax0900 fma NaN2 NaN3 NaN5 -> NaN2
-fmax0901 fma 0 NaN3 NaN5 -> NaN3
-fmax0902 fma 0 0 NaN5 -> NaN5
--- first sNaN wins (consider qNaN from earlier sNaN being
--- overridden by an sNaN in third operand)
-fmax0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-fmax0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
-fmax0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
-fmax0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-fmax0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
-fmax0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
-
--- MULTIPLICATION TESTS ------------------------------------------------
--- sanity checks (as base, above)
-fmax2000 fma 2 2 0E+999999 -> 4
-fmax2001 fma 2 3 0E+999999 -> 6
-fmax2002 fma 5 1 0E+999999 -> 5
-fmax2003 fma 5 2 0E+999999 -> 10
-fmax2004 fma 1.20 2 0E+999999 -> 2.40
-fmax2005 fma 1.20 0 0E+999999 -> 0.00
-fmax2006 fma 1.20 -2 0E+999999 -> -2.40
-fmax2007 fma -1.20 2 0E+999999 -> -2.40
-fmax2008 fma -1.20 0 0E+999999 -> 0.00
-fmax2009 fma -1.20 -2 0E+999999 -> 2.40
-fmax2010 fma 5.09 7.1 0E+999999 -> 36.139
-fmax2011 fma 2.5 4 0E+999999 -> 10.0
-fmax2012 fma 2.50 4 0E+999999 -> 10.00
-fmax2013 fma 1.23456789 1.00000000 0E+999999 -> 1.23456789 Rounded
-fmax2014 fma 9.999999999 9.999999999 0E+999999 -> 100.000000 Inexact Rounded
-fmax2015 fma 2.50 4 0E+999999 -> 10.00
-precision: 6
-fmax2016 fma 2.50 4 0E+999999 -> 10.00
-fmax2017 fma 9.999999 9.999999 0E+999999 -> 100.000 Inexact Rounded
-fmax2018 fma 9.999999 -9.999999 0E+999999 -> -100.000 Inexact Rounded
-fmax2019 fma -9.999999 9.999999 0E+999999 -> -100.000 Inexact Rounded
-fmax2020 fma -9.999999 -9.999999 0E+999999 -> 100.000 Inexact Rounded
-
--- 1999.12.21: next one is a edge case if intermediate longs are used
-precision: 15
-fmax2059 fma 999999999999 9765625 0E+999999 -> 9.76562499999023E+18 Inexact Rounded
-precision: 30
-fmax2160 fma 999999999999 9765625 0E+999999 -> 9765624999990234375
-precision: 9
------
-
--- zeros, etc.
-fmax2021 fma 0 0 0E+999999 -> 0
-fmax2022 fma 0 -0 0E+999999 -> 0
-fmax2023 fma -0 0 0E+999999 -> 0
-fmax2024 fma -0 -0 0E+999999 -> 0
-fmax2025 fma -0.0 -0.0 0E+999999 -> 0.00
-fmax2026 fma -0.0 -0.0 0E+999999 -> 0.00
-fmax2027 fma -0.0 -0.0 0E+999999 -> 0.00
-fmax2028 fma -0.0 -0.0 0E+999999 -> 0.00
-fmax2030 fma 5.00 1E-3 0E+999999 -> 0.00500
-fmax2031 fma 00.00 0.000 0E+999999 -> 0.00000
-fmax2032 fma 00.00 0E-3 0E+999999 -> 0.00000 -- rhs is 0
-fmax2033 fma 0E-3 00.00 0E+999999 -> 0.00000 -- lhs is 0
-fmax2034 fma -5.00 1E-3 0E+999999 -> -0.00500
-fmax2035 fma -00.00 0.000 0E+999999 -> 0.00000
-fmax2036 fma -00.00 0E-3 0E+999999 -> 0.00000 -- rhs is 0
-fmax2037 fma -0E-3 00.00 0E+999999 -> 0.00000 -- lhs is 0
-fmax2038 fma 5.00 -1E-3 0E+999999 -> -0.00500
-fmax2039 fma 00.00 -0.000 0E+999999 -> 0.00000
-fmax2040 fma 00.00 -0E-3 0E+999999 -> 0.00000 -- rhs is 0
-fmax2041 fma 0E-3 -00.00 0E+999999 -> 0.00000 -- lhs is 0
-fmax2042 fma -5.00 -1E-3 0E+999999 -> 0.00500
-fmax2043 fma -00.00 -0.000 0E+999999 -> 0.00000
-fmax2044 fma -00.00 -0E-3 0E+999999 -> 0.00000 -- rhs is 0
-fmax2045 fma -0E-3 -00.00 0E+999999 -> 0.00000 -- lhs is 0
-
--- examples from decarith multiply
-fmax2050 fma 1.20 3 0E+999999 -> 3.60
-fmax2051 fma 7 3 0E+999999 -> 21
-fmax2052 fma 0.9 0.8 0E+999999 -> 0.72
-fmax2053 fma 0.9 -0 0E+999999 -> 0.0
-fmax2054 fma 654321 654321 0E+999999 -> 4.28135971E+11 Inexact Rounded
-
-fmax2060 fma 123.45 1e7 0E+999999 -> 1.2345E+9
-fmax2061 fma 123.45 1e8 0E+999999 -> 1.2345E+10
-fmax2062 fma 123.45 1e+9 0E+999999 -> 1.2345E+11
-fmax2063 fma 123.45 1e10 0E+999999 -> 1.2345E+12
-fmax2064 fma 123.45 1e11 0E+999999 -> 1.2345E+13
-fmax2065 fma 123.45 1e12 0E+999999 -> 1.2345E+14
-fmax2066 fma 123.45 1e13 0E+999999 -> 1.2345E+15
-
-
--- test some intermediate lengths
-precision: 9
-fmax2080 fma 0.1 123456789 0E+999999 -> 12345678.9
-fmax2081 fma 0.1 1234567891 0E+999999 -> 123456789 Inexact Rounded
-fmax2082 fma 0.1 12345678912 0E+999999 -> 1.23456789E+9 Inexact Rounded
-fmax2083 fma 0.1 12345678912345 0E+999999 -> 1.23456789E+12 Inexact Rounded
-fmax2084 fma 0.1 123456789 0E+999999 -> 12345678.9
-precision: 8
-fmax2085 fma 0.1 12345678912 0E+999999 -> 1.2345679E+9 Inexact Rounded
-fmax2086 fma 0.1 12345678912345 0E+999999 -> 1.2345679E+12 Inexact Rounded
-precision: 7
-fmax2087 fma 0.1 12345678912 0E+999999 -> 1.234568E+9 Inexact Rounded
-fmax2088 fma 0.1 12345678912345 0E+999999 -> 1.234568E+12 Inexact Rounded
-
-precision: 9
-fmax2090 fma 123456789 0.1 0E+999999 -> 12345678.9
-fmax2091 fma 1234567891 0.1 0E+999999 -> 123456789 Inexact Rounded
-fmax2092 fma 12345678912 0.1 0E+999999 -> 1.23456789E+9 Inexact Rounded
-fmax2093 fma 12345678912345 0.1 0E+999999 -> 1.23456789E+12 Inexact Rounded
-fmax2094 fma 123456789 0.1 0E+999999 -> 12345678.9
-precision: 8
-fmax2095 fma 12345678912 0.1 0E+999999 -> 1.2345679E+9 Inexact Rounded
-fmax2096 fma 12345678912345 0.1 0E+999999 -> 1.2345679E+12 Inexact Rounded
-precision: 7
-fmax2097 fma 12345678912 0.1 0E+999999 -> 1.234568E+9 Inexact Rounded
-fmax2098 fma 12345678912345 0.1 0E+999999 -> 1.234568E+12 Inexact Rounded
-
--- test some more edge cases and carries
-maxexponent: 9999
-minexponent: -9999
-precision: 33
-fmax2101 fma 9 9 0E+999999 -> 81
-fmax2102 fma 9 90 0E+999999 -> 810
-fmax2103 fma 9 900 0E+999999 -> 8100
-fmax2104 fma 9 9000 0E+999999 -> 81000
-fmax2105 fma 9 90000 0E+999999 -> 810000
-fmax2106 fma 9 900000 0E+999999 -> 8100000
-fmax2107 fma 9 9000000 0E+999999 -> 81000000
-fmax2108 fma 9 90000000 0E+999999 -> 810000000
-fmax2109 fma 9 900000000 0E+999999 -> 8100000000
-fmax2110 fma 9 9000000000 0E+999999 -> 81000000000
-fmax2111 fma 9 90000000000 0E+999999 -> 810000000000
-fmax2112 fma 9 900000000000 0E+999999 -> 8100000000000
-fmax2113 fma 9 9000000000000 0E+999999 -> 81000000000000
-fmax2114 fma 9 90000000000000 0E+999999 -> 810000000000000
-fmax2115 fma 9 900000000000000 0E+999999 -> 8100000000000000
-fmax2116 fma 9 9000000000000000 0E+999999 -> 81000000000000000
-fmax2117 fma 9 90000000000000000 0E+999999 -> 810000000000000000
-fmax2118 fma 9 900000000000000000 0E+999999 -> 8100000000000000000
-fmax2119 fma 9 9000000000000000000 0E+999999 -> 81000000000000000000
-fmax2120 fma 9 90000000000000000000 0E+999999 -> 810000000000000000000
-fmax2121 fma 9 900000000000000000000 0E+999999 -> 8100000000000000000000
-fmax2122 fma 9 9000000000000000000000 0E+999999 -> 81000000000000000000000
-fmax2123 fma 9 90000000000000000000000 0E+999999 -> 810000000000000000000000
--- test some more edge cases without carries
-fmax2131 fma 3 3 0E+999999 -> 9
-fmax2132 fma 3 30 0E+999999 -> 90
-fmax2133 fma 3 300 0E+999999 -> 900
-fmax2134 fma 3 3000 0E+999999 -> 9000
-fmax2135 fma 3 30000 0E+999999 -> 90000
-fmax2136 fma 3 300000 0E+999999 -> 900000
-fmax2137 fma 3 3000000 0E+999999 -> 9000000
-fmax2138 fma 3 30000000 0E+999999 -> 90000000
-fmax2139 fma 3 300000000 0E+999999 -> 900000000
-fmax2140 fma 3 3000000000 0E+999999 -> 9000000000
-fmax2141 fma 3 30000000000 0E+999999 -> 90000000000
-fmax2142 fma 3 300000000000 0E+999999 -> 900000000000
-fmax2143 fma 3 3000000000000 0E+999999 -> 9000000000000
-fmax2144 fma 3 30000000000000 0E+999999 -> 90000000000000
-fmax2145 fma 3 300000000000000 0E+999999 -> 900000000000000
-fmax2146 fma 3 3000000000000000 0E+999999 -> 9000000000000000
-fmax2147 fma 3 30000000000000000 0E+999999 -> 90000000000000000
-fmax2148 fma 3 300000000000000000 0E+999999 -> 900000000000000000
-fmax2149 fma 3 3000000000000000000 0E+999999 -> 9000000000000000000
-fmax2150 fma 3 30000000000000000000 0E+999999 -> 90000000000000000000
-fmax2151 fma 3 300000000000000000000 0E+999999 -> 900000000000000000000
-fmax2152 fma 3 3000000000000000000000 0E+999999 -> 9000000000000000000000
-fmax2153 fma 3 30000000000000000000000 0E+999999 -> 90000000000000000000000
-
-maxexponent: 999999
-minexponent: -999999
-precision: 9
--- test some cases that are close to exponent overflow/underflow
-fmax2170 fma 1 9e999999 0E+999999 -> 9E+999999
-fmax2171 fma 1 9.9e999999 0E+999999 -> 9.9E+999999
-fmax2172 fma 1 9.99e999999 0E+999999 -> 9.99E+999999
-fmax2173 fma 9e999999 1 0E+999999 -> 9E+999999
-fmax2174 fma 9.9e999999 1 0E+999999 -> 9.9E+999999
-fmax2176 fma 9.99e999999 1 0E+999999 -> 9.99E+999999
-fmax2177 fma 1 9.99999e999999 0E+999999 -> 9.99999E+999999
-fmax2178 fma 9.99999e999999 1 0E+999999 -> 9.99999E+999999
-
-fmax2180 fma 0.1 9e-999998 0E+999999 -> 9E-999999
-fmax2181 fma 0.1 99e-999998 0E+999999 -> 9.9E-999998
-fmax2182 fma 0.1 999e-999998 0E+999999 -> 9.99E-999997
-
-fmax2183 fma 0.1 9e-999998 0E+999999 -> 9E-999999
-fmax2184 fma 0.1 99e-999998 0E+999999 -> 9.9E-999998
-fmax2185 fma 0.1 999e-999998 0E+999999 -> 9.99E-999997
-fmax2186 fma 0.1 999e-999997 0E+999999 -> 9.99E-999996
-fmax2187 fma 0.1 9999e-999997 0E+999999 -> 9.999E-999995
-fmax2188 fma 0.1 99999e-999997 0E+999999 -> 9.9999E-999994
-
-fmax2190 fma 1 9e-999998 0E+999999 -> 9E-999998
-fmax2191 fma 1 99e-999998 0E+999999 -> 9.9E-999997
-fmax2192 fma 1 999e-999998 0E+999999 -> 9.99E-999996
-fmax2193 fma 9e-999998 1 0E+999999 -> 9E-999998
-fmax2194 fma 99e-999998 1 0E+999999 -> 9.9E-999997
-fmax2195 fma 999e-999998 1 0E+999999 -> 9.99E-999996
-
--- long operand triangle
-precision: 33
-fmax2246 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916511992830 Inexact Rounded
-precision: 32
-fmax2247 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651199283 Inexact Rounded
-precision: 31
-fmax2248 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165119928 Inexact Rounded
-precision: 30
-fmax2249 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916511993 Inexact Rounded
-precision: 29
-fmax2250 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651199 Inexact Rounded
-precision: 28
-fmax2251 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165120 Inexact Rounded
-precision: 27
-fmax2252 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916512 Inexact Rounded
-precision: 26
-fmax2253 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651 Inexact Rounded
-precision: 25
-fmax2254 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165 Inexact Rounded
-precision: 24
-fmax2255 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671917 Inexact Rounded
-precision: 23
-fmax2256 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967192 Inexact Rounded
-precision: 22
-fmax2257 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719 Inexact Rounded
-precision: 21
-fmax2258 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369672 Inexact Rounded
-precision: 20
-fmax2259 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967 Inexact Rounded
-precision: 19
-fmax2260 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933697 Inexact Rounded
-precision: 18
-fmax2261 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193370 Inexact Rounded
-precision: 17
-fmax2262 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119337 Inexact Rounded
-precision: 16
-fmax2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011934 Inexact Rounded
-precision: 15
-fmax2264 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193 Inexact Rounded
-precision: 14
-fmax2265 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119 Inexact Rounded
-precision: 13
-fmax2266 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908012 Inexact Rounded
-precision: 12
-fmax2267 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801 Inexact Rounded
-precision: 11
-fmax2268 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080 Inexact Rounded
-precision: 10
-fmax2269 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908 Inexact Rounded
-precision: 9
-fmax2270 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.291 Inexact Rounded
-precision: 8
-fmax2271 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29 Inexact Rounded
-precision: 7
-fmax2272 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.3 Inexact Rounded
-precision: 6
-fmax2273 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433 Inexact Rounded
-precision: 5
-fmax2274 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.4543E+5 Inexact Rounded
-precision: 4
-fmax2275 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.454E+5 Inexact Rounded
-precision: 3
-fmax2276 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.45E+5 Inexact Rounded
-precision: 2
-fmax2277 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.5E+5 Inexact Rounded
-precision: 1
-fmax2278 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1E+5 Inexact Rounded
-
--- test some edge cases with exact rounding
-maxexponent: 9999
-minexponent: -9999
-precision: 9
-fmax2301 fma 9 9 0E+999999 -> 81
-fmax2302 fma 9 90 0E+999999 -> 810
-fmax2303 fma 9 900 0E+999999 -> 8100
-fmax2304 fma 9 9000 0E+999999 -> 81000
-fmax2305 fma 9 90000 0E+999999 -> 810000
-fmax2306 fma 9 900000 0E+999999 -> 8100000
-fmax2307 fma 9 9000000 0E+999999 -> 81000000
-fmax2308 fma 9 90000000 0E+999999 -> 810000000
-fmax2309 fma 9 900000000 0E+999999 -> 8.10000000E+9 Rounded
-fmax2310 fma 9 9000000000 0E+999999 -> 8.10000000E+10 Rounded
-fmax2311 fma 9 90000000000 0E+999999 -> 8.10000000E+11 Rounded
-fmax2312 fma 9 900000000000 0E+999999 -> 8.10000000E+12 Rounded
-fmax2313 fma 9 9000000000000 0E+999999 -> 8.10000000E+13 Rounded
-fmax2314 fma 9 90000000000000 0E+999999 -> 8.10000000E+14 Rounded
-fmax2315 fma 9 900000000000000 0E+999999 -> 8.10000000E+15 Rounded
-fmax2316 fma 9 9000000000000000 0E+999999 -> 8.10000000E+16 Rounded
-fmax2317 fma 9 90000000000000000 0E+999999 -> 8.10000000E+17 Rounded
-fmax2318 fma 9 900000000000000000 0E+999999 -> 8.10000000E+18 Rounded
-fmax2319 fma 9 9000000000000000000 0E+999999 -> 8.10000000E+19 Rounded
-fmax2320 fma 9 90000000000000000000 0E+999999 -> 8.10000000E+20 Rounded
-fmax2321 fma 9 900000000000000000000 0E+999999 -> 8.10000000E+21 Rounded
-fmax2322 fma 9 9000000000000000000000 0E+999999 -> 8.10000000E+22 Rounded
-fmax2323 fma 9 90000000000000000000000 0E+999999 -> 8.10000000E+23 Rounded
-
--- fastpath breakers
-precision: 29
-fmax2330 fma 1.491824697641270317824852952837224 1.105170918075647624811707826490246514675628614562883537345747603 0E+999999 -> 1.6487212707001281468486507878 Inexact Rounded
-precision: 55
-fmax2331 fma 0.8958341352965282506768545828765117803873717284891040428 0.8958341352965282506768545828765117803873717284891040428 0E+999999 -> 0.8025187979624784829842553829934069955890983696752228299 Inexact Rounded
-
-
--- tryzeros cases
-precision: 7
-rounding: half_up
-maxExponent: 92
-minexponent: -92
-fmax2504 fma 0E-60 1000E-60 0E+999999 -> 0E-98 Clamped
-fmax2505 fma 100E+60 0E+60 0E+999999 -> 0E+92 Clamped
-
--- mixed with zeros
-maxexponent: 999999
-minexponent: -999999
-precision: 9
-fmax2541 fma 0 -1 0E+999999 -> 0
-fmax2542 fma -0 -1 0E+999999 -> 0
-fmax2543 fma 0 1 0E+999999 -> 0
-fmax2544 fma -0 1 0E+999999 -> 0
-fmax2545 fma -1 0 0E+999999 -> 0
-fmax2546 fma -1 -0 0E+999999 -> 0
-fmax2547 fma 1 0 0E+999999 -> 0
-fmax2548 fma 1 -0 0E+999999 -> 0
-
-fmax2551 fma 0.0 -1 0E+999999 -> 0.0
-fmax2552 fma -0.0 -1 0E+999999 -> 0.0
-fmax2553 fma 0.0 1 0E+999999 -> 0.0
-fmax2554 fma -0.0 1 0E+999999 -> 0.0
-fmax2555 fma -1.0 0 0E+999999 -> 0.0
-fmax2556 fma -1.0 -0 0E+999999 -> 0.0
-fmax2557 fma 1.0 0 0E+999999 -> 0.0
-fmax2558 fma 1.0 -0 0E+999999 -> 0.0
-
-fmax2561 fma 0 -1.0 0E+999999 -> 0.0
-fmax2562 fma -0 -1.0 0E+999999 -> 0.0
-fmax2563 fma 0 1.0 0E+999999 -> 0.0
-fmax2564 fma -0 1.0 0E+999999 -> 0.0
-fmax2565 fma -1 0.0 0E+999999 -> 0.0
-fmax2566 fma -1 -0.0 0E+999999 -> 0.0
-fmax2567 fma 1 0.0 0E+999999 -> 0.0
-fmax2568 fma 1 -0.0 0E+999999 -> 0.0
-
-fmax2571 fma 0.0 -1.0 0E+999999 -> 0.00
-fmax2572 fma -0.0 -1.0 0E+999999 -> 0.00
-fmax2573 fma 0.0 1.0 0E+999999 -> 0.00
-fmax2574 fma -0.0 1.0 0E+999999 -> 0.00
-fmax2575 fma -1.0 0.0 0E+999999 -> 0.00
-fmax2576 fma -1.0 -0.0 0E+999999 -> 0.00
-fmax2577 fma 1.0 0.0 0E+999999 -> 0.00
-fmax2578 fma 1.0 -0.0 0E+999999 -> 0.00
-
-
--- Specials
-fmax2580 fma Inf -Inf 0E+999999 -> -Infinity
-fmax2581 fma Inf -1000 0E+999999 -> -Infinity
-fmax2582 fma Inf -1 0E+999999 -> -Infinity
-fmax2583 fma Inf -0 0E+999999 -> NaN Invalid_operation
-fmax2584 fma Inf 0 0E+999999 -> NaN Invalid_operation
-fmax2585 fma Inf 1 0E+999999 -> Infinity
-fmax2586 fma Inf 1000 0E+999999 -> Infinity
-fmax2587 fma Inf Inf 0E+999999 -> Infinity
-fmax2588 fma -1000 Inf 0E+999999 -> -Infinity
-fmax2589 fma -Inf Inf 0E+999999 -> -Infinity
-fmax2590 fma -1 Inf 0E+999999 -> -Infinity
-fmax2591 fma -0 Inf 0E+999999 -> NaN Invalid_operation
-fmax2592 fma 0 Inf 0E+999999 -> NaN Invalid_operation
-fmax2593 fma 1 Inf 0E+999999 -> Infinity
-fmax2594 fma 1000 Inf 0E+999999 -> Infinity
-fmax2595 fma Inf Inf 0E+999999 -> Infinity
-
-fmax2600 fma -Inf -Inf 0E+999999 -> Infinity
-fmax2601 fma -Inf -1000 0E+999999 -> Infinity
-fmax2602 fma -Inf -1 0E+999999 -> Infinity
-fmax2603 fma -Inf -0 0E+999999 -> NaN Invalid_operation
-fmax2604 fma -Inf 0 0E+999999 -> NaN Invalid_operation
-fmax2605 fma -Inf 1 0E+999999 -> -Infinity
-fmax2606 fma -Inf 1000 0E+999999 -> -Infinity
-fmax2607 fma -Inf Inf 0E+999999 -> -Infinity
-fmax2608 fma -1000 Inf 0E+999999 -> -Infinity
-fmax2609 fma -Inf -Inf 0E+999999 -> Infinity
-fmax2610 fma -1 -Inf 0E+999999 -> Infinity
-fmax2611 fma -0 -Inf 0E+999999 -> NaN Invalid_operation
-fmax2612 fma 0 -Inf 0E+999999 -> NaN Invalid_operation
-fmax2613 fma 1 -Inf 0E+999999 -> -Infinity
-fmax2614 fma 1000 -Inf 0E+999999 -> -Infinity
-fmax2615 fma Inf -Inf 0E+999999 -> -Infinity
-
-fmax2621 fma NaN -Inf 0E+999999 -> NaN
-fmax2622 fma NaN -1000 0E+999999 -> NaN
-fmax2623 fma NaN -1 0E+999999 -> NaN
-fmax2624 fma NaN -0 0E+999999 -> NaN
-fmax2625 fma NaN 0 0E+999999 -> NaN
-fmax2626 fma NaN 1 0E+999999 -> NaN
-fmax2627 fma NaN 1000 0E+999999 -> NaN
-fmax2628 fma NaN Inf 0E+999999 -> NaN
-fmax2629 fma NaN NaN 0E+999999 -> NaN
-fmax2630 fma -Inf NaN 0E+999999 -> NaN
-fmax2631 fma -1000 NaN 0E+999999 -> NaN
-fmax2632 fma -1 NaN 0E+999999 -> NaN
-fmax2633 fma -0 NaN 0E+999999 -> NaN
-fmax2634 fma 0 NaN 0E+999999 -> NaN
-fmax2635 fma 1 NaN 0E+999999 -> NaN
-fmax2636 fma 1000 NaN 0E+999999 -> NaN
-fmax2637 fma Inf NaN 0E+999999 -> NaN
-
-fmax2641 fma sNaN -Inf 0E+999999 -> NaN Invalid_operation
-fmax2642 fma sNaN -1000 0E+999999 -> NaN Invalid_operation
-fmax2643 fma sNaN -1 0E+999999 -> NaN Invalid_operation
-fmax2644 fma sNaN -0 0E+999999 -> NaN Invalid_operation
-fmax2645 fma sNaN 0 0E+999999 -> NaN Invalid_operation
-fmax2646 fma sNaN 1 0E+999999 -> NaN Invalid_operation
-fmax2647 fma sNaN 1000 0E+999999 -> NaN Invalid_operation
-fmax2648 fma sNaN NaN 0E+999999 -> NaN Invalid_operation
-fmax2649 fma sNaN sNaN 0E+999999 -> NaN Invalid_operation
-fmax2650 fma NaN sNaN 0E+999999 -> NaN Invalid_operation
-fmax2651 fma -Inf sNaN 0E+999999 -> NaN Invalid_operation
-fmax2652 fma -1000 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2653 fma -1 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2654 fma -0 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2655 fma 0 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2656 fma 1 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2657 fma 1000 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2658 fma Inf sNaN 0E+999999 -> NaN Invalid_operation
-fmax2659 fma NaN sNaN 0E+999999 -> NaN Invalid_operation
-
--- propagating NaNs
-fmax2661 fma NaN9 -Inf 0E+999999 -> NaN9
-fmax2662 fma NaN8 999 0E+999999 -> NaN8
-fmax2663 fma NaN71 Inf 0E+999999 -> NaN71
-fmax2664 fma NaN6 NaN5 0E+999999 -> NaN6
-fmax2665 fma -Inf NaN4 0E+999999 -> NaN4
-fmax2666 fma -999 NaN33 0E+999999 -> NaN33
-fmax2667 fma Inf NaN2 0E+999999 -> NaN2
-
-fmax2671 fma sNaN99 -Inf 0E+999999 -> NaN99 Invalid_operation
-fmax2672 fma sNaN98 -11 0E+999999 -> NaN98 Invalid_operation
-fmax2673 fma sNaN97 NaN 0E+999999 -> NaN97 Invalid_operation
-fmax2674 fma sNaN16 sNaN94 0E+999999 -> NaN16 Invalid_operation
-fmax2675 fma NaN95 sNaN93 0E+999999 -> NaN93 Invalid_operation
-fmax2676 fma -Inf sNaN92 0E+999999 -> NaN92 Invalid_operation
-fmax2677 fma 088 sNaN91 0E+999999 -> NaN91 Invalid_operation
-fmax2678 fma Inf sNaN90 0E+999999 -> NaN90 Invalid_operation
-fmax2679 fma NaN sNaN89 0E+999999 -> NaN89 Invalid_operation
-
-fmax2681 fma -NaN9 -Inf 0E+999999 -> -NaN9
-fmax2682 fma -NaN8 999 0E+999999 -> -NaN8
-fmax2683 fma -NaN71 Inf 0E+999999 -> -NaN71
-fmax2684 fma -NaN6 -NaN5 0E+999999 -> -NaN6
-fmax2685 fma -Inf -NaN4 0E+999999 -> -NaN4
-fmax2686 fma -999 -NaN33 0E+999999 -> -NaN33
-fmax2687 fma Inf -NaN2 0E+999999 -> -NaN2
-
-fmax2691 fma -sNaN99 -Inf 0E+999999 -> -NaN99 Invalid_operation
-fmax2692 fma -sNaN98 -11 0E+999999 -> -NaN98 Invalid_operation
-fmax2693 fma -sNaN97 NaN 0E+999999 -> -NaN97 Invalid_operation
-fmax2694 fma -sNaN16 -sNaN94 0E+999999 -> -NaN16 Invalid_operation
-fmax2695 fma -NaN95 -sNaN93 0E+999999 -> -NaN93 Invalid_operation
-fmax2696 fma -Inf -sNaN92 0E+999999 -> -NaN92 Invalid_operation
-fmax2697 fma 088 -sNaN91 0E+999999 -> -NaN91 Invalid_operation
-fmax2698 fma Inf -sNaN90 0E+999999 -> -NaN90 Invalid_operation
-fmax2699 fma -NaN -sNaN89 0E+999999 -> -NaN89 Invalid_operation
-
-fmax2701 fma -NaN -Inf 0E+999999 -> -NaN
-fmax2702 fma -NaN 999 0E+999999 -> -NaN
-fmax2703 fma -NaN Inf 0E+999999 -> -NaN
-fmax2704 fma -NaN -NaN 0E+999999 -> -NaN
-fmax2705 fma -Inf -NaN0 0E+999999 -> -NaN
-fmax2706 fma -999 -NaN 0E+999999 -> -NaN
-fmax2707 fma Inf -NaN 0E+999999 -> -NaN
-
-fmax2711 fma -sNaN -Inf 0E+999999 -> -NaN Invalid_operation
-fmax2712 fma -sNaN -11 0E+999999 -> -NaN Invalid_operation
-fmax2713 fma -sNaN00 NaN 0E+999999 -> -NaN Invalid_operation
-fmax2714 fma -sNaN -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2715 fma -NaN -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2716 fma -Inf -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2717 fma 088 -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2718 fma Inf -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2719 fma -NaN -sNaN 0E+999999 -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
-maxexponent: 999999
-minexponent: -999999
-fmax2730 fma +1.23456789012345E-0 9E+999999 0E+999999 -> Infinity Inexact Overflow Rounded
-fmax2731 fma 9E+999999 +1.23456789012345E-0 0E+999999 -> Infinity Inexact Overflow Rounded
-fmax2732 fma +0.100 9E-999999 0E+999999 -> 9.00E-1000000 Subnormal
-fmax2733 fma 9E-999999 +0.100 0E+999999 -> 9.00E-1000000 Subnormal
-fmax2735 fma -1.23456789012345E-0 9E+999999 0E+999999 -> -Infinity Inexact Overflow Rounded
-fmax2736 fma 9E+999999 -1.23456789012345E-0 0E+999999 -> -Infinity Inexact Overflow Rounded
-fmax2737 fma -0.100 9E-999999 0E+999999 -> -9.00E-1000000 Subnormal
-fmax2738 fma 9E-999999 -0.100 0E+999999 -> -9.00E-1000000 Subnormal
-
--- signs
-fmax2751 fma 1e+777777 1e+411111 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2752 fma 1e+777777 -1e+411111 0E+999999 -> -Infinity Overflow Inexact Rounded
-fmax2753 fma -1e+777777 1e+411111 0E+999999 -> -Infinity Overflow Inexact Rounded
-fmax2754 fma -1e+777777 -1e+411111 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2755 fma 1e-777777 1e-411111 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2756 fma 1e-777777 -1e-411111 0E+999999 -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2757 fma -1e-777777 1e-411111 0E+999999 -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2758 fma -1e-777777 -1e-411111 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-precision: 9
-fmax2760 fma 1e-600000 1e-400001 0E+999999 -> 1E-1000001 Subnormal
-fmax2761 fma 1e-600000 1e-400002 0E+999999 -> 1E-1000002 Subnormal
-fmax2762 fma 1e-600000 1e-400003 0E+999999 -> 1E-1000003 Subnormal
-fmax2763 fma 1e-600000 1e-400004 0E+999999 -> 1E-1000004 Subnormal
-fmax2764 fma 1e-600000 1e-400005 0E+999999 -> 1E-1000005 Subnormal
-fmax2765 fma 1e-600000 1e-400006 0E+999999 -> 1E-1000006 Subnormal
-fmax2766 fma 1e-600000 1e-400007 0E+999999 -> 1E-1000007 Subnormal
-fmax2767 fma 1e-600000 1e-400008 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2768 fma 1e-600000 1e-400009 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2769 fma 1e-600000 1e-400010 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-fmax2770 fma 1e+600000 1e+400001 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2771 fma 1e+600000 1e+400002 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2772 fma 1e+600000 1e+400003 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2773 fma 1e+600000 1e+400004 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2774 fma 1e+600000 1e+400005 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2775 fma 1e+600000 1e+400006 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2776 fma 1e+600000 1e+400007 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2777 fma 1e+600000 1e+400008 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2778 fma 1e+600000 1e+400009 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2779 fma 1e+600000 1e+400010 0E+999999 -> Infinity Overflow Inexact Rounded
-
--- 'subnormal' test edge condition at higher precisions
-precision: 99
-fmax2780 fma 1e-600000 1e-400007 0E+999999 -> 1E-1000007 Subnormal
-fmax2781 fma 1e-600000 1e-400008 0E+999999 -> 1E-1000008 Subnormal
-fmax2782 fma 1e-600000 1e-400097 0E+999999 -> 1E-1000097 Subnormal
-fmax2783 fma 1e-600000 1e-400098 0E+999999 -> 0E-1000097 Underflow Subnormal Inexact Rounded Clamped
-precision: 999
-fmax2784 fma 1e-600000 1e-400997 0E+999999 -> 1E-1000997 Subnormal
-fmax2785 fma 1e-600000 1e-400998 0E+999999 -> 0E-1000997 Underflow Subnormal Inexact Rounded Clamped
-
--- test subnormals rounding
-precision: 5
-maxExponent: 999
-minexponent: -999
-rounding: half_even
-
-fmax2801 fma 1.0000E-999 1 0E+999999 -> 1.0000E-999
-fmax2802 fma 1.000E-999 1e-1 0E+999999 -> 1.000E-1000 Subnormal
-fmax2803 fma 1.00E-999 1e-2 0E+999999 -> 1.00E-1001 Subnormal
-fmax2804 fma 1.0E-999 1e-3 0E+999999 -> 1.0E-1002 Subnormal
-fmax2805 fma 1.0E-999 1e-4 0E+999999 -> 1E-1003 Subnormal Rounded
-fmax2806 fma 1.3E-999 1e-4 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-fmax2807 fma 1.5E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2808 fma 1.7E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2809 fma 2.3E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2810 fma 2.5E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2811 fma 2.7E-999 1e-4 0E+999999 -> 3E-1003 Underflow Subnormal Inexact Rounded
-fmax2812 fma 1.49E-999 1e-4 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-fmax2813 fma 1.50E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2814 fma 1.51E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2815 fma 2.49E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2816 fma 2.50E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2817 fma 2.51E-999 1e-4 0E+999999 -> 3E-1003 Underflow Subnormal Inexact Rounded
-
-fmax2818 fma 1E-999 1e-4 0E+999999 -> 1E-1003 Subnormal
-fmax2819 fma 3E-999 1e-5 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2820 fma 5E-999 1e-5 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2821 fma 7E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-fmax2822 fma 9E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-fmax2823 fma 9.9E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-
-fmax2824 fma 1E-999 -1e-4 0E+999999 -> -1E-1003 Subnormal
-fmax2825 fma 3E-999 -1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2826 fma -5E-999 1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2827 fma 7E-999 -1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
-fmax2828 fma -9E-999 1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
-fmax2829 fma 9.9E-999 -1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
-fmax2830 fma 3.0E-999 -1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
-
-fmax2831 fma 1.0E-501 1e-501 0E+999999 -> 1.0E-1002 Subnormal
-fmax2832 fma 2.0E-501 2e-501 0E+999999 -> 4.0E-1002 Subnormal
-fmax2833 fma 4.0E-501 4e-501 0E+999999 -> 1.60E-1001 Subnormal
-fmax2834 fma 10.0E-501 10e-501 0E+999999 -> 1.000E-1000 Subnormal
-fmax2835 fma 30.0E-501 30e-501 0E+999999 -> 9.000E-1000 Subnormal
-fmax2836 fma 40.0E-501 40e-501 0E+999999 -> 1.6000E-999
-
--- squares
-fmax2840 fma 1E-502 1e-502 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2841 fma 1E-501 1e-501 0E+999999 -> 1E-1002 Subnormal
-fmax2842 fma 2E-501 2e-501 0E+999999 -> 4E-1002 Subnormal
-fmax2843 fma 4E-501 4e-501 0E+999999 -> 1.6E-1001 Subnormal
-fmax2844 fma 10E-501 10e-501 0E+999999 -> 1.00E-1000 Subnormal
-fmax2845 fma 30E-501 30e-501 0E+999999 -> 9.00E-1000 Subnormal
-fmax2846 fma 40E-501 40e-501 0E+999999 -> 1.600E-999
-
--- cubes
-fmax2850 fma 1E-670 1e-335 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2851 fma 1E-668 1e-334 0E+999999 -> 1E-1002 Subnormal
-fmax2852 fma 4E-668 2e-334 0E+999999 -> 8E-1002 Subnormal
-fmax2853 fma 9E-668 3e-334 0E+999999 -> 2.7E-1001 Subnormal
-fmax2854 fma 16E-668 4e-334 0E+999999 -> 6.4E-1001 Subnormal
-fmax2855 fma 25E-668 5e-334 0E+999999 -> 1.25E-1000 Subnormal
-fmax2856 fma 10E-668 100e-334 0E+999999 -> 1.000E-999
-
--- test derived from result of 0.099 ** 999 at 15 digits with unlimited exponent
-precision: 19
-fmax2860 fma 6636851557994578716E-520 6636851557994578716E-520 0E+999999 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded
-
--- Long operand overflow may be a different path
-precision: 3
-maxExponent: 999999
-minexponent: -999999
-fmax2870 fma 1 9.999E+999999 0E+999999 -> Infinity Inexact Overflow Rounded
-fmax2871 fma 1 -9.999E+999999 0E+999999 -> -Infinity Inexact Overflow Rounded
-fmax2872 fma 9.999E+999999 1 0E+999999 -> Infinity Inexact Overflow Rounded
-fmax2873 fma -9.999E+999999 1 0E+999999 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-precision: 5
-maxexponent: 79
-minexponent: -79
-fmax2881 fma 1.2347E-40 1.2347E-40 0E+999999 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax2882 fma 1.234E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
-fmax2883 fma 1.23E-40 1.23E-40 0E+999999 -> 1.513E-80 Inexact Rounded Subnormal Underflow
-fmax2884 fma 1.2E-40 1.2E-40 0E+999999 -> 1.44E-80 Subnormal
-fmax2885 fma 1.2E-40 1.2E-41 0E+999999 -> 1.44E-81 Subnormal
-fmax2886 fma 1.2E-40 1.2E-42 0E+999999 -> 1.4E-82 Subnormal Inexact Rounded Underflow
-fmax2887 fma 1.2E-40 1.3E-42 0E+999999 -> 1.6E-82 Subnormal Inexact Rounded Underflow
-fmax2888 fma 1.3E-40 1.3E-42 0E+999999 -> 1.7E-82 Subnormal Inexact Rounded Underflow
-fmax2889 fma 1.3E-40 1.3E-43 0E+999999 -> 2E-83 Subnormal Inexact Rounded Underflow
-fmax2890 fma 1.3E-41 1.3E-43 0E+999999 -> 0E-83 Clamped Subnormal Inexact Rounded Underflow
-
-fmax2891 fma 1.2345E-39 1.234E-40 0E+999999 -> 1.5234E-79 Inexact Rounded
-fmax2892 fma 1.23456E-39 1.234E-40 0E+999999 -> 1.5234E-79 Inexact Rounded
-fmax2893 fma 1.2345E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
-fmax2894 fma 1.23456E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
-fmax2895 fma 1.2345E-41 1.234E-40 0E+999999 -> 1.52E-81 Inexact Rounded Subnormal Underflow
-fmax2896 fma 1.23456E-41 1.234E-40 0E+999999 -> 1.52E-81 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
-fmax2900 fma 0.3000000000E-191 0.3000000000E-191 0E+999999 -> 9.00000000000000E-384 Subnormal Rounded
-fmax2901 fma 0.3000000001E-191 0.3000000001E-191 0E+999999 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
-fmax2902 fma 9.999999999999999E-383 0.0999999999999 0E+999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
-fmax2903 fma 9.999999999999999E-383 0.09999999999999 0E+999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
-fmax2904 fma 9.999999999999999E-383 0.099999999999999 0E+999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
-fmax2905 fma 9.999999999999999E-383 0.0999999999999999 0E+999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
--- prove operands are exact
-fmax2906 fma 9.999999999999999E-383 1 0E+999999 -> 9.999999999999999E-383
-fmax2907 fma 1 0.09999999999999999 0E+999999 -> 0.09999999999999999
--- the next rounds to Nmin
-fmax2908 fma 9.999999999999999E-383 0.09999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax2909 fma 9.999999999999999E-383 0.099999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax2910 fma 9.999999999999999E-383 0.0999999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax2911 fma 9.999999999999999E-383 0.09999999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-
--- Examples from SQL proposal (Krishna Kulkarni)
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
-fmax2921 fma 130E-2 120E-2 0E+999999 -> 1.5600
-fmax2922 fma 130E-2 12E-1 0E+999999 -> 1.560
-fmax2923 fma 130E-2 1E0 0E+999999 -> 1.30
-
--- Null tests
-fmax2990 fma # 10 0E+999999 -> NaN Invalid_operation
-fmax2991 fma 10 # 0E+999999 -> NaN Invalid_operation
-
--- ADDITION TESTS ------------------------------------------------------
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- [first group are 'quick confidence check']
-fmax3001 fma 1 1 1 -> 2
-fmax3002 fma 1 2 3 -> 5
-fmax3003 fma 1 '5.75' '3.3' -> 9.05
-fmax3004 fma 1 '5' '-3' -> 2
-fmax3005 fma 1 '-5' '-3' -> -8
-fmax3006 fma 1 '-7' '2.5' -> -4.5
-fmax3007 fma 1 '0.7' '0.3' -> 1.0
-fmax3008 fma 1 '1.25' '1.25' -> 2.50
-fmax3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
-fmax3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
-
-fmax3011 fma 1 '0.4444444444' '0.5555555555' -> '1.00000000' Inexact Rounded
-fmax3012 fma 1 '0.4444444440' '0.5555555555' -> '1.00000000' Inexact Rounded
-fmax3013 fma 1 '0.4444444444' '0.5555555550' -> '0.999999999' Inexact Rounded
-fmax3014 fma 1 '0.44444444449' '0' -> '0.444444444' Inexact Rounded
-fmax3015 fma 1 '0.444444444499' '0' -> '0.444444444' Inexact Rounded
-fmax3016 fma 1 '0.4444444444999' '0' -> '0.444444444' Inexact Rounded
-fmax3017 fma 1 '0.4444444445000' '0' -> '0.444444445' Inexact Rounded
-fmax3018 fma 1 '0.4444444445001' '0' -> '0.444444445' Inexact Rounded
-fmax3019 fma 1 '0.444444444501' '0' -> '0.444444445' Inexact Rounded
-fmax3020 fma 1 '0.44444444451' '0' -> '0.444444445' Inexact Rounded
-
-fmax3021 fma 1 0 1 -> 1
-fmax3022 fma 1 1 1 -> 2
-fmax3023 fma 1 2 1 -> 3
-fmax3024 fma 1 3 1 -> 4
-fmax3025 fma 1 4 1 -> 5
-fmax3026 fma 1 5 1 -> 6
-fmax3027 fma 1 6 1 -> 7
-fmax3028 fma 1 7 1 -> 8
-fmax3029 fma 1 8 1 -> 9
-fmax3030 fma 1 9 1 -> 10
-
--- some carrying effects
-fmax3031 fma 1 '0.9998' '0.0000' -> '0.9998'
-fmax3032 fma 1 '0.9998' '0.0001' -> '0.9999'
-fmax3033 fma 1 '0.9998' '0.0002' -> '1.0000'
-fmax3034 fma 1 '0.9998' '0.0003' -> '1.0001'
-
-fmax3035 fma 1 '70' '10000e+9' -> '1.00000000E+13' Inexact Rounded
-fmax3036 fma 1 '700' '10000e+9' -> '1.00000000E+13' Inexact Rounded
-fmax3037 fma 1 '7000' '10000e+9' -> '1.00000000E+13' Inexact Rounded
-fmax3038 fma 1 '70000' '10000e+9' -> '1.00000001E+13' Inexact Rounded
-fmax3039 fma 1 '700000' '10000e+9' -> '1.00000007E+13' Rounded
-
--- symmetry:
-fmax3040 fma 1 '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded
-fmax3041 fma 1 '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded
-fmax3042 fma 1 '10000e+9' '7000' -> '1.00000000E+13' Inexact Rounded
-fmax3044 fma 1 '10000e+9' '70000' -> '1.00000001E+13' Inexact Rounded
-fmax3045 fma 1 '10000e+9' '700000' -> '1.00000007E+13' Rounded
-
--- same, higher precision
-precision: 15
-fmax3046 fma 1 '10000e+9' '7' -> '10000000000007'
-fmax3047 fma 1 '10000e+9' '70' -> '10000000000070'
-fmax3048 fma 1 '10000e+9' '700' -> '10000000000700'
-fmax3049 fma 1 '10000e+9' '7000' -> '10000000007000'
-fmax3050 fma 1 '10000e+9' '70000' -> '10000000070000'
-fmax3051 fma 1 '10000e+9' '700000' -> '10000000700000'
-fmax3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-fmax3053 fma 1 '12' '7.00' -> '19.00'
-fmax3054 fma 1 '1.3' '-1.07' -> '0.23'
-fmax3055 fma 1 '1.3' '-1.30' -> '0.00'
-fmax3056 fma 1 '1.3' '-2.07' -> '-0.77'
-fmax3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
-
--- zero preservation
-precision: 6
-fmax3060 fma 1 '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded
-fmax3061 fma 1 1 '0.0001' -> '1.0001'
-fmax3062 fma 1 1 '0.00001' -> '1.00001'
-fmax3063 fma 1 1 '0.000001' -> '1.00000' Inexact Rounded
-fmax3064 fma 1 1 '0.0000001' -> '1.00000' Inexact Rounded
-fmax3065 fma 1 1 '0.00000001' -> '1.00000' Inexact Rounded
-
--- some funny zeros [in case of bad signum]
-fmax3070 fma 1 1 0 -> 1
-fmax3071 fma 1 1 0. -> 1
-fmax3072 fma 1 1 .0 -> 1.0
-fmax3073 fma 1 1 0.0 -> 1.0
-fmax3074 fma 1 1 0.00 -> 1.00
-fmax3075 fma 1 0 1 -> 1
-fmax3076 fma 1 0. 1 -> 1
-fmax3077 fma 1 .0 1 -> 1.0
-fmax3078 fma 1 0.0 1 -> 1.0
-fmax3079 fma 1 0.00 1 -> 1.00
-
-precision: 9
-
--- some carries
-fmax3080 fma 1 999999998 1 -> 999999999
-fmax3081 fma 1 999999999 1 -> 1.00000000E+9 Rounded
-fmax3082 fma 1 99999999 1 -> 100000000
-fmax3083 fma 1 9999999 1 -> 10000000
-fmax3084 fma 1 999999 1 -> 1000000
-fmax3085 fma 1 99999 1 -> 100000
-fmax3086 fma 1 9999 1 -> 10000
-fmax3087 fma 1 999 1 -> 1000
-fmax3088 fma 1 99 1 -> 100
-fmax3089 fma 1 9 1 -> 10
-
-
--- more LHS swaps
-fmax3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
-fmax3091 fma 1 '-56267E-6' 0 -> '-0.056267'
-fmax3092 fma 1 '-56267E-5' 0 -> '-0.56267'
-fmax3093 fma 1 '-56267E-4' 0 -> '-5.6267'
-fmax3094 fma 1 '-56267E-3' 0 -> '-56.267'
-fmax3095 fma 1 '-56267E-2' 0 -> '-562.67'
-fmax3096 fma 1 '-56267E-1' 0 -> '-5626.7'
-fmax3097 fma 1 '-56267E-0' 0 -> '-56267'
-fmax3098 fma 1 '-5E-10' 0 -> '-5E-10'
-fmax3099 fma 1 '-5E-7' 0 -> '-5E-7'
-fmax3100 fma 1 '-5E-6' 0 -> '-0.000005'
-fmax3101 fma 1 '-5E-5' 0 -> '-0.00005'
-fmax3102 fma 1 '-5E-4' 0 -> '-0.0005'
-fmax3103 fma 1 '-5E-1' 0 -> '-0.5'
-fmax3104 fma 1 '-5E0' 0 -> '-5'
-fmax3105 fma 1 '-5E1' 0 -> '-50'
-fmax3106 fma 1 '-5E5' 0 -> '-500000'
-fmax3107 fma 1 '-5E8' 0 -> '-500000000'
-fmax3108 fma 1 '-5E9' 0 -> '-5.00000000E+9' Rounded
-fmax3109 fma 1 '-5E10' 0 -> '-5.00000000E+10' Rounded
-fmax3110 fma 1 '-5E11' 0 -> '-5.00000000E+11' Rounded
-fmax3111 fma 1 '-5E100' 0 -> '-5.00000000E+100' Rounded
-
--- more RHS swaps
-fmax3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
-fmax3114 fma 1 0 '-56267E-6' -> '-0.056267'
-fmax3116 fma 1 0 '-56267E-5' -> '-0.56267'
-fmax3117 fma 1 0 '-56267E-4' -> '-5.6267'
-fmax3119 fma 1 0 '-56267E-3' -> '-56.267'
-fmax3120 fma 1 0 '-56267E-2' -> '-562.67'
-fmax3121 fma 1 0 '-56267E-1' -> '-5626.7'
-fmax3122 fma 1 0 '-56267E-0' -> '-56267'
-fmax3123 fma 1 0 '-5E-10' -> '-5E-10'
-fmax3124 fma 1 0 '-5E-7' -> '-5E-7'
-fmax3125 fma 1 0 '-5E-6' -> '-0.000005'
-fmax3126 fma 1 0 '-5E-5' -> '-0.00005'
-fmax3127 fma 1 0 '-5E-4' -> '-0.0005'
-fmax3128 fma 1 0 '-5E-1' -> '-0.5'
-fmax3129 fma 1 0 '-5E0' -> '-5'
-fmax3130 fma 1 0 '-5E1' -> '-50'
-fmax3131 fma 1 0 '-5E5' -> '-500000'
-fmax3132 fma 1 0 '-5E8' -> '-500000000'
-fmax3133 fma 1 0 '-5E9' -> '-5.00000000E+9' Rounded
-fmax3134 fma 1 0 '-5E10' -> '-5.00000000E+10' Rounded
-fmax3135 fma 1 0 '-5E11' -> '-5.00000000E+11' Rounded
-fmax3136 fma 1 0 '-5E100' -> '-5.00000000E+100' Rounded
-
--- related
-fmax3137 fma 1 1 '0E-12' -> '1.00000000' Rounded
-fmax3138 fma 1 -1 '0E-12' -> '-1.00000000' Rounded
-fmax3139 fma 1 '0E-12' 1 -> '1.00000000' Rounded
-fmax3140 fma 1 '0E-12' -1 -> '-1.00000000' Rounded
-fmax3141 fma 1 1E+4 0.0000 -> '10000.0000'
-fmax3142 fma 1 1E+4 0.00000 -> '10000.0000' Rounded
-fmax3143 fma 1 0.000 1E+5 -> '100000.000'
-fmax3144 fma 1 0.0000 1E+5 -> '100000.000' Rounded
-
--- [some of the next group are really constructor tests]
-fmax3146 fma 1 '00.0' 0 -> '0.0'
-fmax3147 fma 1 '0.00' 0 -> '0.00'
-fmax3148 fma 1 0 '0.00' -> '0.00'
-fmax3149 fma 1 0 '00.0' -> '0.0'
-fmax3150 fma 1 '00.0' '0.00' -> '0.00'
-fmax3151 fma 1 '0.00' '00.0' -> '0.00'
-fmax3152 fma 1 '3' '.3' -> '3.3'
-fmax3153 fma 1 '3.' '.3' -> '3.3'
-fmax3154 fma 1 '3.0' '.3' -> '3.3'
-fmax3155 fma 1 '3.00' '.3' -> '3.30'
-fmax3156 fma 1 '3' '3' -> '6'
-fmax3157 fma 1 '3' '+3' -> '6'
-fmax3158 fma 1 '3' '-3' -> '0'
-fmax3159 fma 1 '0.3' '-0.3' -> '0.0'
-fmax3160 fma 1 '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-precision: 15
-fmax3161 fma 1 '1E+12' '-1' -> '999999999999'
-fmax3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
-fmax3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
-fmax3164 fma 1 '-1' '1E+12' -> '999999999999'
-fmax3165 fma 1 '7E+12' '-1' -> '6999999999999'
-fmax3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
-fmax3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
-fmax3168 fma 1 '-1' '7E+12' -> '6999999999999'
-
--- 123456789012345 123456789012345 1 23456789012345
-fmax3170 fma 1 '0.444444444444444' '0.555555555555563' -> '1.00000000000001' Inexact Rounded
-fmax3171 fma 1 '0.444444444444444' '0.555555555555562' -> '1.00000000000001' Inexact Rounded
-fmax3172 fma 1 '0.444444444444444' '0.555555555555561' -> '1.00000000000001' Inexact Rounded
-fmax3173 fma 1 '0.444444444444444' '0.555555555555560' -> '1.00000000000000' Inexact Rounded
-fmax3174 fma 1 '0.444444444444444' '0.555555555555559' -> '1.00000000000000' Inexact Rounded
-fmax3175 fma 1 '0.444444444444444' '0.555555555555558' -> '1.00000000000000' Inexact Rounded
-fmax3176 fma 1 '0.444444444444444' '0.555555555555557' -> '1.00000000000000' Inexact Rounded
-fmax3177 fma 1 '0.444444444444444' '0.555555555555556' -> '1.00000000000000' Rounded
-fmax3178 fma 1 '0.444444444444444' '0.555555555555555' -> '0.999999999999999'
-fmax3179 fma 1 '0.444444444444444' '0.555555555555554' -> '0.999999999999998'
-fmax3180 fma 1 '0.444444444444444' '0.555555555555553' -> '0.999999999999997'
-fmax3181 fma 1 '0.444444444444444' '0.555555555555552' -> '0.999999999999996'
-fmax3182 fma 1 '0.444444444444444' '0.555555555555551' -> '0.999999999999995'
-fmax3183 fma 1 '0.444444444444444' '0.555555555555550' -> '0.999999999999994'
-
--- and some more, including residue effects and different roundings
-precision: 9
-rounding: half_up
-fmax3200 fma 1 '123456789' 0 -> '123456789'
-fmax3201 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
-fmax3202 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
-fmax3203 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
-fmax3204 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
-fmax3205 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
-fmax3206 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
-fmax3207 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
-fmax3208 fma 1 '123456789' 0.5 -> '123456790' Inexact Rounded
-fmax3209 fma 1 '123456789' 0.500000001 -> '123456790' Inexact Rounded
-fmax3210 fma 1 '123456789' 0.500001 -> '123456790' Inexact Rounded
-fmax3211 fma 1 '123456789' 0.51 -> '123456790' Inexact Rounded
-fmax3212 fma 1 '123456789' 0.6 -> '123456790' Inexact Rounded
-fmax3213 fma 1 '123456789' 0.9 -> '123456790' Inexact Rounded
-fmax3214 fma 1 '123456789' 0.99999 -> '123456790' Inexact Rounded
-fmax3215 fma 1 '123456789' 0.999999999 -> '123456790' Inexact Rounded
-fmax3216 fma 1 '123456789' 1 -> '123456790'
-fmax3217 fma 1 '123456789' 1.000000001 -> '123456790' Inexact Rounded
-fmax3218 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
-fmax3219 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
-
-rounding: half_even
-fmax3220 fma 1 '123456789' 0 -> '123456789'
-fmax3221 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
-fmax3222 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
-fmax3223 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
-fmax3224 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
-fmax3225 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
-fmax3226 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
-fmax3227 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
-fmax3228 fma 1 '123456789' 0.5 -> '123456790' Inexact Rounded
-fmax3229 fma 1 '123456789' 0.500000001 -> '123456790' Inexact Rounded
-fmax3230 fma 1 '123456789' 0.500001 -> '123456790' Inexact Rounded
-fmax3231 fma 1 '123456789' 0.51 -> '123456790' Inexact Rounded
-fmax3232 fma 1 '123456789' 0.6 -> '123456790' Inexact Rounded
-fmax3233 fma 1 '123456789' 0.9 -> '123456790' Inexact Rounded
-fmax3234 fma 1 '123456789' 0.99999 -> '123456790' Inexact Rounded
-fmax3235 fma 1 '123456789' 0.999999999 -> '123456790' Inexact Rounded
-fmax3236 fma 1 '123456789' 1 -> '123456790'
-fmax3237 fma 1 '123456789' 1.00000001 -> '123456790' Inexact Rounded
-fmax3238 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
-fmax3239 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
--- critical few with even bottom digit...
-fmax3240 fma 1 '123456788' 0.499999999 -> '123456788' Inexact Rounded
-fmax3241 fma 1 '123456788' 0.5 -> '123456788' Inexact Rounded
-fmax3242 fma 1 '123456788' 0.500000001 -> '123456789' Inexact Rounded
-
-rounding: down
-fmax3250 fma 1 '123456789' 0 -> '123456789'
-fmax3251 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
-fmax3252 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
-fmax3253 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
-fmax3254 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
-fmax3255 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
-fmax3256 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
-fmax3257 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
-fmax3258 fma 1 '123456789' 0.5 -> '123456789' Inexact Rounded
-fmax3259 fma 1 '123456789' 0.500000001 -> '123456789' Inexact Rounded
-fmax3260 fma 1 '123456789' 0.500001 -> '123456789' Inexact Rounded
-fmax3261 fma 1 '123456789' 0.51 -> '123456789' Inexact Rounded
-fmax3262 fma 1 '123456789' 0.6 -> '123456789' Inexact Rounded
-fmax3263 fma 1 '123456789' 0.9 -> '123456789' Inexact Rounded
-fmax3264 fma 1 '123456789' 0.99999 -> '123456789' Inexact Rounded
-fmax3265 fma 1 '123456789' 0.999999999 -> '123456789' Inexact Rounded
-fmax3266 fma 1 '123456789' 1 -> '123456790'
-fmax3267 fma 1 '123456789' 1.00000001 -> '123456790' Inexact Rounded
-fmax3268 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
-fmax3269 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
-
--- input preparation tests (operands should not be rounded)
-precision: 3
-rounding: half_up
-
-fmax3270 fma 1 '12345678900000' 9999999999999 -> '2.23E+13' Inexact Rounded
-fmax3271 fma 1 '9999999999999' 12345678900000 -> '2.23E+13' Inexact Rounded
-
-fmax3272 fma 1 '12E+3' '3444' -> '1.54E+4' Inexact Rounded
-fmax3273 fma 1 '12E+3' '3446' -> '1.54E+4' Inexact Rounded
-fmax3274 fma 1 '12E+3' '3449.9' -> '1.54E+4' Inexact Rounded
-fmax3275 fma 1 '12E+3' '3450.0' -> '1.55E+4' Inexact Rounded
-fmax3276 fma 1 '12E+3' '3450.1' -> '1.55E+4' Inexact Rounded
-fmax3277 fma 1 '12E+3' '3454' -> '1.55E+4' Inexact Rounded
-fmax3278 fma 1 '12E+3' '3456' -> '1.55E+4' Inexact Rounded
-
-fmax3281 fma 1 '3444' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3282 fma 1 '3446' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3283 fma 1 '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3284 fma 1 '3450.0' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3285 fma 1 '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3286 fma 1 '3454' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3287 fma 1 '3456' '12E+3' -> '1.55E+4' Inexact Rounded
-
-rounding: half_down
-fmax3291 fma 1 '3444' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3292 fma 1 '3446' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3293 fma 1 '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3294 fma 1 '3450.0' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3295 fma 1 '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3296 fma 1 '3454' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3297 fma 1 '3456' '12E+3' -> '1.55E+4' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-fmax3301 fma 1 -1 1 -> 0
-fmax3302 fma 1 0 1 -> 1
-fmax3303 fma 1 1 1 -> 2
-fmax3304 fma 1 12 1 -> 13
-fmax3305 fma 1 98 1 -> 99
-fmax3306 fma 1 99 1 -> 100
-fmax3307 fma 1 100 1 -> 101
-fmax3308 fma 1 101 1 -> 102
-fmax3309 fma 1 -1 -1 -> -2
-fmax3310 fma 1 0 -1 -> -1
-fmax3311 fma 1 1 -1 -> 0
-fmax3312 fma 1 12 -1 -> 11
-fmax3313 fma 1 98 -1 -> 97
-fmax3314 fma 1 99 -1 -> 98
-fmax3315 fma 1 100 -1 -> 99
-fmax3316 fma 1 101 -1 -> 100
-
-fmax3321 fma 1 -0.01 0.01 -> 0.00
-fmax3322 fma 1 0.00 0.01 -> 0.01
-fmax3323 fma 1 0.01 0.01 -> 0.02
-fmax3324 fma 1 0.12 0.01 -> 0.13
-fmax3325 fma 1 0.98 0.01 -> 0.99
-fmax3326 fma 1 0.99 0.01 -> 1.00
-fmax3327 fma 1 1.00 0.01 -> 1.01
-fmax3328 fma 1 1.01 0.01 -> 1.02
-fmax3329 fma 1 -0.01 -0.01 -> -0.02
-fmax3330 fma 1 0.00 -0.01 -> -0.01
-fmax3331 fma 1 0.01 -0.01 -> 0.00
-fmax3332 fma 1 0.12 -0.01 -> 0.11
-fmax3333 fma 1 0.98 -0.01 -> 0.97
-fmax3334 fma 1 0.99 -0.01 -> 0.98
-fmax3335 fma 1 1.00 -0.01 -> 0.99
-fmax3336 fma 1 1.01 -0.01 -> 1.00
-
--- some more cases where fma 1 ing 0 affects the coefficient
-precision: 9
-fmax3340 fma 1 1E+3 0 -> 1000
-fmax3341 fma 1 1E+8 0 -> 100000000
-fmax3342 fma 1 1E+9 0 -> 1.00000000E+9 Rounded
-fmax3343 fma 1 1E+10 0 -> 1.00000000E+10 Rounded
--- which simply follow from these cases ...
-fmax3344 fma 1 1E+3 1 -> 1001
-fmax3345 fma 1 1E+8 1 -> 100000001
-fmax3346 fma 1 1E+9 1 -> 1.00000000E+9 Inexact Rounded
-fmax3347 fma 1 1E+10 1 -> 1.00000000E+10 Inexact Rounded
-fmax3348 fma 1 1E+3 7 -> 1007
-fmax3349 fma 1 1E+8 7 -> 100000007
-fmax3350 fma 1 1E+9 7 -> 1.00000001E+9 Inexact Rounded
-fmax3351 fma 1 1E+10 7 -> 1.00000000E+10 Inexact Rounded
-
--- tryzeros cases
-precision: 7
-rounding: half_up
-maxExponent: 92
-minexponent: -92
-fmax3361 fma 1 0E+50 10000E+1 -> 1.0000E+5
-fmax3362 fma 1 10000E+1 0E-50 -> 100000.0 Rounded
-fmax3363 fma 1 10000E+1 10000E-50 -> 100000.0 Rounded Inexact
-fmax3364 fma 1 9.999999E+92 -9.999999E+92 -> 0E+86
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-precision: 10
-fmax3370 fma 1 99999999 81512 -> 100081511
-precision: 6
-fmax3371 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
-rounding: half_up
-precision: 10
-fmax3372 fma 1 99999999 81512 -> 100081511
-precision: 6
-fmax3373 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
-rounding: half_even
-precision: 10
-fmax3374 fma 1 99999999 81512 -> 100081511
-precision: 6
-fmax3375 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
-
--- ulp replacement tests
-precision: 9
-maxexponent: 999999
-minexponent: -999999
-fmax3400 fma 1 1 77e-7 -> 1.0000077
-fmax3401 fma 1 1 77e-8 -> 1.00000077
-fmax3402 fma 1 1 77e-9 -> 1.00000008 Inexact Rounded
-fmax3403 fma 1 1 77e-10 -> 1.00000001 Inexact Rounded
-fmax3404 fma 1 1 77e-11 -> 1.00000000 Inexact Rounded
-fmax3405 fma 1 1 77e-12 -> 1.00000000 Inexact Rounded
-fmax3406 fma 1 1 77e-999 -> 1.00000000 Inexact Rounded
-fmax3407 fma 1 1 77e-999999 -> 1.00000000 Inexact Rounded
-
-fmax3410 fma 1 10 77e-7 -> 10.0000077
-fmax3411 fma 1 10 77e-8 -> 10.0000008 Inexact Rounded
-fmax3412 fma 1 10 77e-9 -> 10.0000001 Inexact Rounded
-fmax3413 fma 1 10 77e-10 -> 10.0000000 Inexact Rounded
-fmax3414 fma 1 10 77e-11 -> 10.0000000 Inexact Rounded
-fmax3415 fma 1 10 77e-12 -> 10.0000000 Inexact Rounded
-fmax3416 fma 1 10 77e-999 -> 10.0000000 Inexact Rounded
-fmax3417 fma 1 10 77e-999999 -> 10.0000000 Inexact Rounded
-
-fmax3420 fma 1 77e-7 1 -> 1.0000077
-fmax3421 fma 1 77e-8 1 -> 1.00000077
-fmax3422 fma 1 77e-9 1 -> 1.00000008 Inexact Rounded
-fmax3423 fma 1 77e-10 1 -> 1.00000001 Inexact Rounded
-fmax3424 fma 1 77e-11 1 -> 1.00000000 Inexact Rounded
-fmax3425 fma 1 77e-12 1 -> 1.00000000 Inexact Rounded
-fmax3426 fma 1 77e-999 1 -> 1.00000000 Inexact Rounded
-fmax3427 fma 1 77e-999999 1 -> 1.00000000 Inexact Rounded
-
-fmax3430 fma 1 77e-7 10 -> 10.0000077
-fmax3431 fma 1 77e-8 10 -> 10.0000008 Inexact Rounded
-fmax3432 fma 1 77e-9 10 -> 10.0000001 Inexact Rounded
-fmax3433 fma 1 77e-10 10 -> 10.0000000 Inexact Rounded
-fmax3434 fma 1 77e-11 10 -> 10.0000000 Inexact Rounded
-fmax3435 fma 1 77e-12 10 -> 10.0000000 Inexact Rounded
-fmax3436 fma 1 77e-999 10 -> 10.0000000 Inexact Rounded
-fmax3437 fma 1 77e-999999 10 -> 10.0000000 Inexact Rounded
-
--- negative ulps
-fmax3440 fma 1 1 -77e-7 -> 0.9999923
-fmax3441 fma 1 1 -77e-8 -> 0.99999923
-fmax3442 fma 1 1 -77e-9 -> 0.999999923
-fmax3443 fma 1 1 -77e-10 -> 0.999999992 Inexact Rounded
-fmax3444 fma 1 1 -77e-11 -> 0.999999999 Inexact Rounded
-fmax3445 fma 1 1 -77e-12 -> 1.00000000 Inexact Rounded
-fmax3446 fma 1 1 -77e-999 -> 1.00000000 Inexact Rounded
-fmax3447 fma 1 1 -77e-999999 -> 1.00000000 Inexact Rounded
-
-fmax3450 fma 1 10 -77e-7 -> 9.9999923
-fmax3451 fma 1 10 -77e-8 -> 9.99999923
-fmax3452 fma 1 10 -77e-9 -> 9.99999992 Inexact Rounded
-fmax3453 fma 1 10 -77e-10 -> 9.99999999 Inexact Rounded
-fmax3454 fma 1 10 -77e-11 -> 10.0000000 Inexact Rounded
-fmax3455 fma 1 10 -77e-12 -> 10.0000000 Inexact Rounded
-fmax3456 fma 1 10 -77e-999 -> 10.0000000 Inexact Rounded
-fmax3457 fma 1 10 -77e-999999 -> 10.0000000 Inexact Rounded
-
-fmax3460 fma 1 -77e-7 1 -> 0.9999923
-fmax3461 fma 1 -77e-8 1 -> 0.99999923
-fmax3462 fma 1 -77e-9 1 -> 0.999999923
-fmax3463 fma 1 -77e-10 1 -> 0.999999992 Inexact Rounded
-fmax3464 fma 1 -77e-11 1 -> 0.999999999 Inexact Rounded
-fmax3465 fma 1 -77e-12 1 -> 1.00000000 Inexact Rounded
-fmax3466 fma 1 -77e-999 1 -> 1.00000000 Inexact Rounded
-fmax3467 fma 1 -77e-999999 1 -> 1.00000000 Inexact Rounded
-
-fmax3470 fma 1 -77e-7 10 -> 9.9999923
-fmax3471 fma 1 -77e-8 10 -> 9.99999923
-fmax3472 fma 1 -77e-9 10 -> 9.99999992 Inexact Rounded
-fmax3473 fma 1 -77e-10 10 -> 9.99999999 Inexact Rounded
-fmax3474 fma 1 -77e-11 10 -> 10.0000000 Inexact Rounded
-fmax3475 fma 1 -77e-12 10 -> 10.0000000 Inexact Rounded
-fmax3476 fma 1 -77e-999 10 -> 10.0000000 Inexact Rounded
-fmax3477 fma 1 -77e-999999 10 -> 10.0000000 Inexact Rounded
-
--- negative ulps
-fmax3480 fma 1 -1 77e-7 -> -0.9999923
-fmax3481 fma 1 -1 77e-8 -> -0.99999923
-fmax3482 fma 1 -1 77e-9 -> -0.999999923
-fmax3483 fma 1 -1 77e-10 -> -0.999999992 Inexact Rounded
-fmax3484 fma 1 -1 77e-11 -> -0.999999999 Inexact Rounded
-fmax3485 fma 1 -1 77e-12 -> -1.00000000 Inexact Rounded
-fmax3486 fma 1 -1 77e-999 -> -1.00000000 Inexact Rounded
-fmax3487 fma 1 -1 77e-999999 -> -1.00000000 Inexact Rounded
-
-fmax3490 fma 1 -10 77e-7 -> -9.9999923
-fmax3491 fma 1 -10 77e-8 -> -9.99999923
-fmax3492 fma 1 -10 77e-9 -> -9.99999992 Inexact Rounded
-fmax3493 fma 1 -10 77e-10 -> -9.99999999 Inexact Rounded
-fmax3494 fma 1 -10 77e-11 -> -10.0000000 Inexact Rounded
-fmax3495 fma 1 -10 77e-12 -> -10.0000000 Inexact Rounded
-fmax3496 fma 1 -10 77e-999 -> -10.0000000 Inexact Rounded
-fmax3497 fma 1 -10 77e-999999 -> -10.0000000 Inexact Rounded
-
-fmax3500 fma 1 77e-7 -1 -> -0.9999923
-fmax3501 fma 1 77e-8 -1 -> -0.99999923
-fmax3502 fma 1 77e-9 -1 -> -0.999999923
-fmax3503 fma 1 77e-10 -1 -> -0.999999992 Inexact Rounded
-fmax3504 fma 1 77e-11 -1 -> -0.999999999 Inexact Rounded
-fmax3505 fma 1 77e-12 -1 -> -1.00000000 Inexact Rounded
-fmax3506 fma 1 77e-999 -1 -> -1.00000000 Inexact Rounded
-fmax3507 fma 1 77e-999999 -1 -> -1.00000000 Inexact Rounded
-
-fmax3510 fma 1 77e-7 -10 -> -9.9999923
-fmax3511 fma 1 77e-8 -10 -> -9.99999923
-fmax3512 fma 1 77e-9 -10 -> -9.99999992 Inexact Rounded
-fmax3513 fma 1 77e-10 -10 -> -9.99999999 Inexact Rounded
-fmax3514 fma 1 77e-11 -10 -> -10.0000000 Inexact Rounded
-fmax3515 fma 1 77e-12 -10 -> -10.0000000 Inexact Rounded
-fmax3516 fma 1 77e-999 -10 -> -10.0000000 Inexact Rounded
-fmax3517 fma 1 77e-999999 -10 -> -10.0000000 Inexact Rounded
-
-
--- long operands
-maxexponent: 999
-minexponent: -999
-precision: 9
-fmax3521 fma 1 12345678000 0 -> 1.23456780E+10 Rounded
-fmax3522 fma 1 0 12345678000 -> 1.23456780E+10 Rounded
-fmax3523 fma 1 1234567800 0 -> 1.23456780E+9 Rounded
-fmax3524 fma 1 0 1234567800 -> 1.23456780E+9 Rounded
-fmax3525 fma 1 1234567890 0 -> 1.23456789E+9 Rounded
-fmax3526 fma 1 0 1234567890 -> 1.23456789E+9 Rounded
-fmax3527 fma 1 1234567891 0 -> 1.23456789E+9 Inexact Rounded
-fmax3528 fma 1 0 1234567891 -> 1.23456789E+9 Inexact Rounded
-fmax3529 fma 1 12345678901 0 -> 1.23456789E+10 Inexact Rounded
-fmax3530 fma 1 0 12345678901 -> 1.23456789E+10 Inexact Rounded
-fmax3531 fma 1 1234567896 0 -> 1.23456790E+9 Inexact Rounded
-fmax3532 fma 1 0 1234567896 -> 1.23456790E+9 Inexact Rounded
-
-precision: 15
--- still checking
-fmax3541 fma 1 12345678000 0 -> 12345678000
-fmax3542 fma 1 0 12345678000 -> 12345678000
-fmax3543 fma 1 1234567800 0 -> 1234567800
-fmax3544 fma 1 0 1234567800 -> 1234567800
-fmax3545 fma 1 1234567890 0 -> 1234567890
-fmax3546 fma 1 0 1234567890 -> 1234567890
-fmax3547 fma 1 1234567891 0 -> 1234567891
-fmax3548 fma 1 0 1234567891 -> 1234567891
-fmax3549 fma 1 12345678901 0 -> 12345678901
-fmax3550 fma 1 0 12345678901 -> 12345678901
-fmax3551 fma 1 1234567896 0 -> 1234567896
-fmax3552 fma 1 0 1234567896 -> 1234567896
-
--- verify a query
-precision: 16
-maxExponent: +394
-minExponent: -393
-rounding: down
-fmax3561 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
-fmax3562 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
--- and using decimal64 bounds...
-precision: 16
-maxExponent: +384
-minExponent: -383
-rounding: down
-fmax3563 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
-fmax3564 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
-
-
--- some more residue effects with extreme rounding
-precision: 9
-rounding: half_up
-fmax3601 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-rounding: half_even
-fmax3602 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-rounding: half_down
-fmax3603 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-rounding: floor
-fmax3604 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-rounding: ceiling
-fmax3605 fma 1 123456789 0.000001 -> 123456790 Inexact Rounded
-rounding: up
-fmax3606 fma 1 123456789 0.000001 -> 123456790 Inexact Rounded
-rounding: down
-fmax3607 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-
-rounding: half_up
-fmax3611 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: half_even
-fmax3612 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: half_down
-fmax3613 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: floor
-fmax3614 fma 1 123456789 -0.000001 -> 123456788 Inexact Rounded
-rounding: ceiling
-fmax3615 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: up
-fmax3616 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: down
-fmax3617 fma 1 123456789 -0.000001 -> 123456788 Inexact Rounded
-
-rounding: half_up
-fmax3621 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-rounding: half_even
-fmax3622 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-rounding: half_down
-fmax3623 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-rounding: floor
-fmax3624 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-rounding: ceiling
-fmax3625 fma 1 123456789 0.499999 -> 123456790 Inexact Rounded
-rounding: up
-fmax3626 fma 1 123456789 0.499999 -> 123456790 Inexact Rounded
-rounding: down
-fmax3627 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-
-rounding: half_up
-fmax3631 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: half_even
-fmax3632 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: half_down
-fmax3633 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: floor
-fmax3634 fma 1 123456789 -0.499999 -> 123456788 Inexact Rounded
-rounding: ceiling
-fmax3635 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: up
-fmax3636 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: down
-fmax3637 fma 1 123456789 -0.499999 -> 123456788 Inexact Rounded
-
-rounding: half_up
-fmax3641 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: half_even
-fmax3642 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: half_down
-fmax3643 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: floor
-fmax3644 fma 1 123456789 0.500001 -> 123456789 Inexact Rounded
-rounding: ceiling
-fmax3645 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: up
-fmax3646 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: down
-fmax3647 fma 1 123456789 0.500001 -> 123456789 Inexact Rounded
-
-rounding: half_up
-fmax3651 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-rounding: half_even
-fmax3652 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-rounding: half_down
-fmax3653 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-rounding: floor
-fmax3654 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-rounding: ceiling
-fmax3655 fma 1 123456789 -0.500001 -> 123456789 Inexact Rounded
-rounding: up
-fmax3656 fma 1 123456789 -0.500001 -> 123456789 Inexact Rounded
-rounding: down
-fmax3657 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-
--- long operand triangle
-rounding: half_up
-precision: 37
-fmax3660 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114834538
-precision: 36
-fmax3661 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483454 Inexact Rounded
-precision: 35
-fmax3662 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148345 Inexact Rounded
-precision: 34
-fmax3663 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114835 Inexact Rounded
-precision: 33
-fmax3664 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483 Inexact Rounded
-precision: 32
-fmax3665 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148 Inexact Rounded
-precision: 31
-fmax3666 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337115 Inexact Rounded
-precision: 30
-fmax3667 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711 Inexact Rounded
-precision: 29
-fmax3668 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371 Inexact Rounded
-precision: 28
-fmax3669 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337 Inexact Rounded
-precision: 27
-fmax3670 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892234 Inexact Rounded
-precision: 26
-fmax3671 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223 Inexact Rounded
-precision: 25
-fmax3672 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922 Inexact Rounded
-precision: 24
-fmax3673 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892 Inexact Rounded
-precision: 23
-fmax3674 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389 Inexact Rounded
-precision: 22
-fmax3675 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023639 Inexact Rounded
-precision: 21
-fmax3676 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102364 Inexact Rounded
-precision: 20
-fmax3677 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236 Inexact Rounded
-precision: 19
-fmax3678 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211024 Inexact Rounded
-precision: 18
-fmax3679 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102 Inexact Rounded
-precision: 17
-fmax3680 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110 Inexact Rounded
-precision: 16
-fmax3681 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211 Inexact Rounded
-precision: 15
-fmax3682 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221 Inexact Rounded
-precision: 14
-fmax3683 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422 Inexact Rounded
-precision: 13
-fmax3684 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42 Inexact Rounded
-precision: 12
-fmax3685 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4 Inexact Rounded
-precision: 11
-fmax3686 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166 Inexact Rounded
-precision: 10
-fmax3687 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117417E+10 Inexact Rounded
-precision: 9
-fmax3688 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84711742E+10 Inexact Rounded
-precision: 8
-fmax3689 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471174E+10 Inexact Rounded
-precision: 7
-fmax3690 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117E+10 Inexact Rounded
-precision: 6
-fmax3691 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84712E+10 Inexact Rounded
-precision: 5
-fmax3692 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471E+10 Inexact Rounded
-precision: 4
-fmax3693 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847E+10 Inexact Rounded
-precision: 3
-fmax3694 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.85E+10 Inexact Rounded
-precision: 2
-fmax3695 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8E+10 Inexact Rounded
-precision: 1
-fmax3696 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 1E+11 Inexact Rounded
-
--- more zeros, etc.
-rounding: half_up
-precision: 9
-
-fmax3701 fma 1 5.00 1.00E-3 -> 5.00100
-fmax3702 fma 1 00.00 0.000 -> 0.000
-fmax3703 fma 1 00.00 0E-3 -> 0.000
-fmax3704 fma 1 0E-3 00.00 -> 0.000
-
-fmax3710 fma 1 0E+3 00.00 -> 0.00
-fmax3711 fma 1 0E+3 00.0 -> 0.0
-fmax3712 fma 1 0E+3 00. -> 0
-fmax3713 fma 1 0E+3 00.E+1 -> 0E+1
-fmax3714 fma 1 0E+3 00.E+2 -> 0E+2
-fmax3715 fma 1 0E+3 00.E+3 -> 0E+3
-fmax3716 fma 1 0E+3 00.E+4 -> 0E+3
-fmax3717 fma 1 0E+3 00.E+5 -> 0E+3
-fmax3718 fma 1 0E+3 -00.0 -> 0.0
-fmax3719 fma 1 0E+3 -00. -> 0
-fmax3731 fma 1 0E+3 -00.E+1 -> 0E+1
-
-fmax3720 fma 1 00.00 0E+3 -> 0.00
-fmax3721 fma 1 00.0 0E+3 -> 0.0
-fmax3722 fma 1 00. 0E+3 -> 0
-fmax3723 fma 1 00.E+1 0E+3 -> 0E+1
-fmax3724 fma 1 00.E+2 0E+3 -> 0E+2
-fmax3725 fma 1 00.E+3 0E+3 -> 0E+3
-fmax3726 fma 1 00.E+4 0E+3 -> 0E+3
-fmax3727 fma 1 00.E+5 0E+3 -> 0E+3
-fmax3728 fma 1 -00.00 0E+3 -> 0.00
-fmax3729 fma 1 -00.0 0E+3 -> 0.0
-fmax3730 fma 1 -00. 0E+3 -> 0
-
-fmax3732 fma 1 0 0 -> 0
-fmax3733 fma 1 0 -0 -> 0
-fmax3734 fma 1 -0 0 -> 0
-fmax3735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
-
-fmax3736 fma 1 1 -1 -> 0
-fmax3737 fma 1 -1 -1 -> -2
-fmax3738 fma 1 1 1 -> 2
-fmax3739 fma 1 -1 1 -> 0
-
-fmax3741 fma 1 0 -1 -> -1
-fmax3742 fma 1 -0 -1 -> -1
-fmax3743 fma 1 0 1 -> 1
-fmax3744 fma 1 -0 1 -> 1
-fmax3745 fma 1 -1 0 -> -1
-fmax3746 fma 1 -1 -0 -> -1
-fmax3747 fma 1 1 0 -> 1
-fmax3748 fma 1 1 -0 -> 1
-
-fmax3751 fma 1 0.0 -1 -> -1.0
-fmax3752 fma 1 -0.0 -1 -> -1.0
-fmax3753 fma 1 0.0 1 -> 1.0
-fmax3754 fma 1 -0.0 1 -> 1.0
-fmax3755 fma 1 -1.0 0 -> -1.0
-fmax3756 fma 1 -1.0 -0 -> -1.0
-fmax3757 fma 1 1.0 0 -> 1.0
-fmax3758 fma 1 1.0 -0 -> 1.0
-
-fmax3761 fma 1 0 -1.0 -> -1.0
-fmax3762 fma 1 -0 -1.0 -> -1.0
-fmax3763 fma 1 0 1.0 -> 1.0
-fmax3764 fma 1 -0 1.0 -> 1.0
-fmax3765 fma 1 -1 0.0 -> -1.0
-fmax3766 fma 1 -1 -0.0 -> -1.0
-fmax3767 fma 1 1 0.0 -> 1.0
-fmax3768 fma 1 1 -0.0 -> 1.0
-
-fmax3771 fma 1 0.0 -1.0 -> -1.0
-fmax3772 fma 1 -0.0 -1.0 -> -1.0
-fmax3773 fma 1 0.0 1.0 -> 1.0
-fmax3774 fma 1 -0.0 1.0 -> 1.0
-fmax3775 fma 1 -1.0 0.0 -> -1.0
-fmax3776 fma 1 -1.0 -0.0 -> -1.0
-fmax3777 fma 1 1.0 0.0 -> 1.0
-fmax3778 fma 1 1.0 -0.0 -> 1.0
-
--- Specials
-fmax3780 fma 1 -Inf -Inf -> -Infinity
-fmax3781 fma 1 -Inf -1000 -> -Infinity
-fmax3782 fma 1 -Inf -1 -> -Infinity
-fmax3783 fma 1 -Inf -0 -> -Infinity
-fmax3784 fma 1 -Inf 0 -> -Infinity
-fmax3785 fma 1 -Inf 1 -> -Infinity
-fmax3786 fma 1 -Inf 1000 -> -Infinity
-fmax3787 fma 1 -1000 -Inf -> -Infinity
-fmax3788 fma 1 -Inf -Inf -> -Infinity
-fmax3789 fma 1 -1 -Inf -> -Infinity
-fmax3790 fma 1 -0 -Inf -> -Infinity
-fmax3791 fma 1 0 -Inf -> -Infinity
-fmax3792 fma 1 1 -Inf -> -Infinity
-fmax3793 fma 1 1000 -Inf -> -Infinity
-fmax3794 fma 1 Inf -Inf -> NaN Invalid_operation
-
-fmax3800 fma 1 Inf -Inf -> NaN Invalid_operation
-fmax3801 fma 1 Inf -1000 -> Infinity
-fmax3802 fma 1 Inf -1 -> Infinity
-fmax3803 fma 1 Inf -0 -> Infinity
-fmax3804 fma 1 Inf 0 -> Infinity
-fmax3805 fma 1 Inf 1 -> Infinity
-fmax3806 fma 1 Inf 1000 -> Infinity
-fmax3807 fma 1 Inf Inf -> Infinity
-fmax3808 fma 1 -1000 Inf -> Infinity
-fmax3809 fma 1 -Inf Inf -> NaN Invalid_operation
-fmax3810 fma 1 -1 Inf -> Infinity
-fmax3811 fma 1 -0 Inf -> Infinity
-fmax3812 fma 1 0 Inf -> Infinity
-fmax3813 fma 1 1 Inf -> Infinity
-fmax3814 fma 1 1000 Inf -> Infinity
-fmax3815 fma 1 Inf Inf -> Infinity
-
-fmax3821 fma 1 NaN -Inf -> NaN
-fmax3822 fma 1 NaN -1000 -> NaN
-fmax3823 fma 1 NaN -1 -> NaN
-fmax3824 fma 1 NaN -0 -> NaN
-fmax3825 fma 1 NaN 0 -> NaN
-fmax3826 fma 1 NaN 1 -> NaN
-fmax3827 fma 1 NaN 1000 -> NaN
-fmax3828 fma 1 NaN Inf -> NaN
-fmax3829 fma 1 NaN NaN -> NaN
-fmax3830 fma 1 -Inf NaN -> NaN
-fmax3831 fma 1 -1000 NaN -> NaN
-fmax3832 fma 1 -1 NaN -> NaN
-fmax3833 fma 1 -0 NaN -> NaN
-fmax3834 fma 1 0 NaN -> NaN
-fmax3835 fma 1 1 NaN -> NaN
-fmax3836 fma 1 1000 NaN -> NaN
-fmax3837 fma 1 Inf NaN -> NaN
-
-fmax3841 fma 1 sNaN -Inf -> NaN Invalid_operation
-fmax3842 fma 1 sNaN -1000 -> NaN Invalid_operation
-fmax3843 fma 1 sNaN -1 -> NaN Invalid_operation
-fmax3844 fma 1 sNaN -0 -> NaN Invalid_operation
-fmax3845 fma 1 sNaN 0 -> NaN Invalid_operation
-fmax3846 fma 1 sNaN 1 -> NaN Invalid_operation
-fmax3847 fma 1 sNaN 1000 -> NaN Invalid_operation
-fmax3848 fma 1 sNaN NaN -> NaN Invalid_operation
-fmax3849 fma 1 sNaN sNaN -> NaN Invalid_operation
-fmax3850 fma 1 NaN sNaN -> NaN Invalid_operation
-fmax3851 fma 1 -Inf sNaN -> NaN Invalid_operation
-fmax3852 fma 1 -1000 sNaN -> NaN Invalid_operation
-fmax3853 fma 1 -1 sNaN -> NaN Invalid_operation
-fmax3854 fma 1 -0 sNaN -> NaN Invalid_operation
-fmax3855 fma 1 0 sNaN -> NaN Invalid_operation
-fmax3856 fma 1 1 sNaN -> NaN Invalid_operation
-fmax3857 fma 1 1000 sNaN -> NaN Invalid_operation
-fmax3858 fma 1 Inf sNaN -> NaN Invalid_operation
-fmax3859 fma 1 NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-fmax3861 fma 1 NaN1 -Inf -> NaN1
-fmax3862 fma 1 +NaN2 -1000 -> NaN2
-fmax3863 fma 1 NaN3 1000 -> NaN3
-fmax3864 fma 1 NaN4 Inf -> NaN4
-fmax3865 fma 1 NaN5 +NaN6 -> NaN5
-fmax3866 fma 1 -Inf NaN7 -> NaN7
-fmax3867 fma 1 -1000 NaN8 -> NaN8
-fmax3868 fma 1 1000 NaN9 -> NaN9
-fmax3869 fma 1 Inf +NaN10 -> NaN10
-fmax3871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
-fmax3872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
-fmax3873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
-fmax3874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
-fmax3875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
-fmax3876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
-fmax3877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
-fmax3878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
-fmax3879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
-fmax3880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
-fmax3881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
-fmax3882 fma 1 -NaN26 NaN28 -> -NaN26
-fmax3883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-fmax3884 fma 1 1000 -NaN30 -> -NaN30
-fmax3885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- overflow, underflow and subnormal tests
-maxexponent: 999999
-minexponent: -999999
-precision: 9
-fmax3890 fma 1 1E+999999 9E+999999 -> Infinity Overflow Inexact Rounded
-fmax3891 fma 1 9E+999999 1E+999999 -> Infinity Overflow Inexact Rounded
-fmax3892 fma 1 -1.1E-999999 1E-999999 -> -1E-1000000 Subnormal
-fmax3893 fma 1 1E-999999 -1.1e-999999 -> -1E-1000000 Subnormal
-fmax3894 fma 1 -1.0001E-999999 1E-999999 -> -1E-1000003 Subnormal
-fmax3895 fma 1 1E-999999 -1.0001e-999999 -> -1E-1000003 Subnormal
-fmax3896 fma 1 -1E+999999 -9E+999999 -> -Infinity Overflow Inexact Rounded
-fmax3897 fma 1 -9E+999999 -1E+999999 -> -Infinity Overflow Inexact Rounded
-fmax3898 fma 1 +1.1E-999999 -1E-999999 -> 1E-1000000 Subnormal
-fmax3899 fma 1 -1E-999999 +1.1e-999999 -> 1E-1000000 Subnormal
-fmax3900 fma 1 +1.0001E-999999 -1E-999999 -> 1E-1000003 Subnormal
-fmax3901 fma 1 -1E-999999 +1.0001e-999999 -> 1E-1000003 Subnormal
-fmax3902 fma 1 -1E+999999 +9E+999999 -> 8E+999999
-fmax3903 fma 1 -9E+999999 +1E+999999 -> -8E+999999
-
-precision: 3
-fmax3904 fma 1 0 -9.999E+999999 -> -Infinity Inexact Overflow Rounded
-fmax3905 fma 1 -9.999E+999999 0 -> -Infinity Inexact Overflow Rounded
-fmax3906 fma 1 0 9.999E+999999 -> Infinity Inexact Overflow Rounded
-fmax3907 fma 1 9.999E+999999 0 -> Infinity Inexact Overflow Rounded
-
-precision: 3
-maxexponent: 999
-minexponent: -999
-fmax3910 fma 1 1.00E-999 0 -> 1.00E-999
-fmax3911 fma 1 0.1E-999 0 -> 1E-1000 Subnormal
-fmax3912 fma 1 0.10E-999 0 -> 1.0E-1000 Subnormal
-fmax3913 fma 1 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded
-fmax3914 fma 1 0.01E-999 0 -> 1E-1001 Subnormal
--- next is rounded to Nmin
-fmax3915 fma 1 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow
-fmax3916 fma 1 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3917 fma 1 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow
-fmax3918 fma 1 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3919 fma 1 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3920 fma 1 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-
-fmax3930 fma 1 -1.00E-999 0 -> -1.00E-999
-fmax3931 fma 1 -0.1E-999 0 -> -1E-1000 Subnormal
-fmax3932 fma 1 -0.10E-999 0 -> -1.0E-1000 Subnormal
-fmax3933 fma 1 -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded
-fmax3934 fma 1 -0.01E-999 0 -> -1E-1001 Subnormal
--- next is rounded to Nmin
-fmax3935 fma 1 -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow
-fmax3936 fma 1 -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3937 fma 1 -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow
-fmax3938 fma 1 -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3939 fma 1 -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3940 fma 1 -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-
--- some non-zero subnormal fma 1 s
-fmax3950 fma 1 1.00E-999 0.1E-999 -> 1.10E-999
-fmax3951 fma 1 0.1E-999 0.1E-999 -> 2E-1000 Subnormal
-fmax3952 fma 1 0.10E-999 0.1E-999 -> 2.0E-1000 Subnormal
-fmax3953 fma 1 0.100E-999 0.1E-999 -> 2.0E-1000 Subnormal Rounded
-fmax3954 fma 1 0.01E-999 0.1E-999 -> 1.1E-1000 Subnormal
-fmax3955 fma 1 0.999E-999 0.1E-999 -> 1.10E-999 Inexact Rounded
-fmax3956 fma 1 0.099E-999 0.1E-999 -> 2.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3957 fma 1 0.009E-999 0.1E-999 -> 1.1E-1000 Inexact Rounded Subnormal Underflow
-fmax3958 fma 1 0.001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3959 fma 1 0.0009E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3960 fma 1 0.0001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
--- negatives...
-fmax3961 fma 1 1.00E-999 -0.1E-999 -> 9.0E-1000 Subnormal
-fmax3962 fma 1 0.1E-999 -0.1E-999 -> 0E-1000
-fmax3963 fma 1 0.10E-999 -0.1E-999 -> 0E-1001
-fmax3964 fma 1 0.100E-999 -0.1E-999 -> 0E-1001 Clamped
-fmax3965 fma 1 0.01E-999 -0.1E-999 -> -9E-1001 Subnormal
-fmax3966 fma 1 0.999E-999 -0.1E-999 -> 9.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3967 fma 1 0.099E-999 -0.1E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3968 fma 1 0.009E-999 -0.1E-999 -> -9E-1001 Inexact Rounded Subnormal Underflow
-fmax3969 fma 1 0.001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3970 fma 1 0.0009E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3971 fma 1 0.0001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-
--- some 'real' numbers
-maxExponent: 384
-minExponent: -383
-precision: 8
-fmax3566 fma 1 99999061735E-394 0E-394 -> 9.999906E-384 Inexact Rounded Underflow Subnormal
-precision: 7
-fmax3567 fma 1 99999061735E-394 0E-394 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
-precision: 6
-fmax3568 fma 1 99999061735E-394 0E-394 -> 9.9999E-384 Inexact Rounded Underflow Subnormal
-
--- now the case where we can get underflow but the result is normal
--- [note this can't happen if the operands are also bounded, as we
--- cannot represent 1E-399, for example]
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
-fmax3571 fma 1 1E-383 0 -> 1E-383
-fmax3572 fma 1 1E-384 0 -> 1E-384 Subnormal
-fmax3573 fma 1 1E-383 1E-384 -> 1.1E-383
-fmax3574 subtract 1E-383 1E-384 -> 9E-384 Subnormal
-
--- Here we explore the boundary of rounding a subnormal to Nmin
-fmax3575 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
-fmax3576 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
-fmax3577 subtract 1E-383 1E-399 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax3578 subtract 1E-383 1E-400 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax3579 subtract 1E-383 1E-401 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax3580 subtract 1E-383 1E-402 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-
--- check for double-rounded subnormals
-precision: 5
-maxexponent: 79
-minexponent: -79
--- Add: lhs and rhs 0
-fmax31001 fma 1 1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31002 fma 1 1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31003 fma 1 1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31004 fma 1 0 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31005 fma 1 0 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31006 fma 1 0 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-
--- Add: lhs >> rhs and vice versa
-fmax31011 fma 1 1.52444E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31012 fma 1 1.52445E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31013 fma 1 1.52446E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31014 fma 1 1E-100 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31015 fma 1 1E-100 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31016 fma 1 1E-100 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-
--- Add: lhs + rhs fma 1 ition carried out
-fmax31021 fma 1 1.52443E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31022 fma 1 1.52444E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31023 fma 1 1.52445E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31024 fma 1 1.00001E-80 1.52443E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31025 fma 1 1.00001E-80 1.52444E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31026 fma 1 1.00001E-80 1.52445E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-
--- And for round down full and subnormal results
-precision: 16
-maxExponent: +384
-minExponent: -383
-rounding: down
-
-fmax31100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
-fmax31101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
-fmax31103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
-fmax31104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
-fmax31105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
-fmax31106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
-fmax31107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
-fmax31108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
-fmax31109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-fmax31110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
-fmax31111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
-fmax31113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
-fmax31114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
-fmax31115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
-fmax31116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
-fmax31117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
-fmax31118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
-fmax31119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
-
-rounding: down
-precision: 7
-maxExponent: +96
-minExponent: -95
-fmax31130 fma 1 1 -1e-200 -> 0.9999999 Rounded Inexact
--- subnormal boundary
-fmax31131 fma 1 1.000000E-94 -1e-200 -> 9.999999E-95 Rounded Inexact
-fmax31132 fma 1 1.000001E-95 -1e-200 -> 1.000000E-95 Rounded Inexact
-fmax31133 fma 1 1.000000E-95 -1e-200 -> 9.99999E-96 Rounded Inexact Subnormal Underflow
-fmax31134 fma 1 0.999999E-95 -1e-200 -> 9.99998E-96 Rounded Inexact Subnormal Underflow
-fmax31135 fma 1 0.001000E-95 -1e-200 -> 9.99E-99 Rounded Inexact Subnormal Underflow
-fmax31136 fma 1 0.000999E-95 -1e-200 -> 9.98E-99 Rounded Inexact Subnormal Underflow
-fmax31137 fma 1 1.000000E-95 -1e-101 -> 9.99999E-96 Subnormal
-fmax31138 fma 1 10000E-101 -1e-200 -> 9.999E-98 Subnormal Inexact Rounded Underflow
-fmax31139 fma 1 1000E-101 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow
-fmax31140 fma 1 100E-101 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow
-fmax31141 fma 1 10E-101 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow
-fmax31142 fma 1 1E-101 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31143 fma 1 0E-101 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31144 fma 1 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-
-fmax31151 fma 1 10000E-102 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow
-fmax31152 fma 1 1000E-102 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow
-fmax31153 fma 1 100E-102 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow
-fmax31154 fma 1 10E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31155 fma 1 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31156 fma 1 0E-102 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31157 fma 1 1E-103 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-
-fmax31160 fma 1 100E-105 -1e-101 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31161 fma 1 100E-105 -1e-201 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-
--- tests based on Gunnar Degnbol's edge case
-precision: 15
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
-fmax31200 fma 1 1E15 -0.5 -> 1.00000000000000E+15 Inexact Rounded
-fmax31201 fma 1 1E15 -0.50 -> 1.00000000000000E+15 Inexact Rounded
-fmax31210 fma 1 1E15 -0.51 -> 999999999999999 Inexact Rounded
-fmax31211 fma 1 1E15 -0.501 -> 999999999999999 Inexact Rounded
-fmax31212 fma 1 1E15 -0.5001 -> 999999999999999 Inexact Rounded
-fmax31213 fma 1 1E15 -0.50001 -> 999999999999999 Inexact Rounded
-fmax31214 fma 1 1E15 -0.500001 -> 999999999999999 Inexact Rounded
-fmax31215 fma 1 1E15 -0.5000001 -> 999999999999999 Inexact Rounded
-fmax31216 fma 1 1E15 -0.50000001 -> 999999999999999 Inexact Rounded
-fmax31217 fma 1 1E15 -0.500000001 -> 999999999999999 Inexact Rounded
-fmax31218 fma 1 1E15 -0.5000000001 -> 999999999999999 Inexact Rounded
-fmax31219 fma 1 1E15 -0.50000000001 -> 999999999999999 Inexact Rounded
-fmax31220 fma 1 1E15 -0.500000000001 -> 999999999999999 Inexact Rounded
-fmax31221 fma 1 1E15 -0.5000000000001 -> 999999999999999 Inexact Rounded
-fmax31222 fma 1 1E15 -0.50000000000001 -> 999999999999999 Inexact Rounded
-fmax31223 fma 1 1E15 -0.500000000000001 -> 999999999999999 Inexact Rounded
-fmax31224 fma 1 1E15 -0.5000000000000001 -> 999999999999999 Inexact Rounded
-fmax31225 fma 1 1E15 -0.5000000000000000 -> 1.00000000000000E+15 Inexact Rounded
-fmax31230 fma 1 1E15 -5000000.000000001 -> 999999995000000 Inexact Rounded
-
-precision: 16
-
-fmax31300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
-fmax31310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
-fmax31311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
-fmax31312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
-fmax31313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
-fmax31314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
-fmax31315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
-fmax31316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
-fmax31317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
-fmax31318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
-fmax31319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
-fmax31320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
-fmax31321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
-fmax31322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
-fmax31323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
-fmax31324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
-fmax31325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
-fmax31339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
-
-fmax31340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
-fmax31341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
-
-fmax31349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
-fmax31350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
-fmax31351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
-fmax31352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
-fmax31353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
-fmax31354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
-fmax31355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
-fmax31356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
-fmax31357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
-fmax31358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
-fmax31359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
-fmax31360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
-fmax31361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
-fmax31362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
-fmax31363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
-fmax31364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
-fmax31365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
-fmax31380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
-fmax31381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
-fmax31382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
-fmax31396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-precision: 15
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
-fmax31400 fma 1 0 1.23456789012345 -> 1.23456789012345
-fmax31401 fma 1 0 1.23456789012345E-1 -> 0.123456789012345
-fmax31402 fma 1 0 1.23456789012345E-2 -> 0.0123456789012345
-fmax31403 fma 1 0 1.23456789012345E-3 -> 0.00123456789012345
-fmax31404 fma 1 0 1.23456789012345E-4 -> 0.000123456789012345
-fmax31405 fma 1 0 1.23456789012345E-5 -> 0.0000123456789012345
-fmax31406 fma 1 0 1.23456789012345E-6 -> 0.00000123456789012345
-fmax31407 fma 1 0 1.23456789012345E-7 -> 1.23456789012345E-7
-fmax31408 fma 1 0 1.23456789012345E-8 -> 1.23456789012345E-8
-fmax31409 fma 1 0 1.23456789012345E-9 -> 1.23456789012345E-9
-fmax31410 fma 1 0 1.23456789012345E-10 -> 1.23456789012345E-10
-fmax31411 fma 1 0 1.23456789012345E-11 -> 1.23456789012345E-11
-fmax31412 fma 1 0 1.23456789012345E-12 -> 1.23456789012345E-12
-fmax31413 fma 1 0 1.23456789012345E-13 -> 1.23456789012345E-13
-fmax31414 fma 1 0 1.23456789012345E-14 -> 1.23456789012345E-14
-fmax31415 fma 1 0 1.23456789012345E-15 -> 1.23456789012345E-15
-fmax31416 fma 1 0 1.23456789012345E-16 -> 1.23456789012345E-16
-fmax31417 fma 1 0 1.23456789012345E-17 -> 1.23456789012345E-17
-fmax31418 fma 1 0 1.23456789012345E-18 -> 1.23456789012345E-18
-fmax31419 fma 1 0 1.23456789012345E-19 -> 1.23456789012345E-19
-
--- same, precision 16..
-precision: 16
-fmax31420 fma 1 0 1.123456789012345 -> 1.123456789012345
-fmax31421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
-fmax31422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
-fmax31423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
-fmax31424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
-fmax31425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
-fmax31426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
-fmax31427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
-fmax31428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
-fmax31429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
-fmax31430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
-fmax31431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
-fmax31432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
-fmax31433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
-fmax31434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
-fmax31435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
-fmax31436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
-fmax31437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
-fmax31438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
-fmax31439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
-
--- same, reversed 0
-fmax31440 fma 1 1.123456789012345 0 -> 1.123456789012345
-fmax31441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
-fmax31442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
-fmax31443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
-fmax31444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
-fmax31445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
-fmax31446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
-fmax31447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
-fmax31448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
-fmax31449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
-fmax31450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
-fmax31451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
-fmax31452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
-fmax31453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
-fmax31454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
-fmax31455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
-fmax31456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
-fmax31457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
-fmax31458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
-fmax31459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
-
--- same, Es on the 0
-fmax31460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
-fmax31461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
-fmax31462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
-fmax31463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
-fmax31464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
-fmax31465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
-fmax31466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
-fmax31467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
-fmax31468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
-fmax31469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
-fmax31470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
-fmax31471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
-fmax31472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
-fmax31473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
-fmax31474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
-fmax31475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
--- next four flag Rounded because the 0 extends the result
-fmax31476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
-fmax31477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
-fmax31478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
-fmax31479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-precision: 16
-maxExponent: 384
-minexponent: -383
-
-rounding: half_up
--- exact zeros from zeros
-fmax31500 fma 1 0 0E-19 -> 0E-19
-fmax31501 fma 1 -0 0E-19 -> 0E-19
-fmax31502 fma 1 0 -0E-19 -> 0E-19
-fmax31503 fma 1 -0 -0E-19 -> -0E-19
-fmax31504 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31505 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31506 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31507 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31511 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31512 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31513 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31514 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31515 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31516 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31517 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31518 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: half_down
--- exact zeros from zeros
-fmax31520 fma 1 0 0E-19 -> 0E-19
-fmax31521 fma 1 -0 0E-19 -> 0E-19
-fmax31522 fma 1 0 -0E-19 -> 0E-19
-fmax31523 fma 1 -0 -0E-19 -> -0E-19
-fmax31524 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31525 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31526 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31527 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31531 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31532 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31533 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31534 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31535 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31536 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31537 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31538 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: half_even
--- exact zeros from zeros
-fmax31540 fma 1 0 0E-19 -> 0E-19
-fmax31541 fma 1 -0 0E-19 -> 0E-19
-fmax31542 fma 1 0 -0E-19 -> 0E-19
-fmax31543 fma 1 -0 -0E-19 -> -0E-19
-fmax31544 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31545 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31546 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31547 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31551 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31552 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31553 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31554 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31555 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31556 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31557 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31558 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: up
--- exact zeros from zeros
-fmax31560 fma 1 0 0E-19 -> 0E-19
-fmax31561 fma 1 -0 0E-19 -> 0E-19
-fmax31562 fma 1 0 -0E-19 -> 0E-19
-fmax31563 fma 1 -0 -0E-19 -> -0E-19
-fmax31564 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31565 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31566 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31567 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31571 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31572 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31573 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-fmax31574 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
--- some exact zeros from non-zeros
-fmax31575 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31576 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31577 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31578 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
-
-rounding: down
--- exact zeros from zeros
-fmax31580 fma 1 0 0E-19 -> 0E-19
-fmax31581 fma 1 -0 0E-19 -> 0E-19
-fmax31582 fma 1 0 -0E-19 -> 0E-19
-fmax31583 fma 1 -0 -0E-19 -> -0E-19
-fmax31584 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31585 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31586 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31587 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31591 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31592 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31593 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31594 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31595 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31596 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31597 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31598 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: ceiling
--- exact zeros from zeros
-fmax31600 fma 1 0 0E-19 -> 0E-19
-fmax31601 fma 1 -0 0E-19 -> 0E-19
-fmax31602 fma 1 0 -0E-19 -> 0E-19
-fmax31603 fma 1 -0 -0E-19 -> -0E-19
-fmax31604 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31605 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31606 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31607 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31611 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31612 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31613 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31614 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31615 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31616 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31617 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31618 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-fmax31620 fma 1 0 0E-19 -> 0E-19
-fmax31621 fma 1 -0 0E-19 -> -0E-19 -- *
-fmax31622 fma 1 0 -0E-19 -> -0E-19 -- *
-fmax31623 fma 1 -0 -0E-19 -> -0E-19
-fmax31624 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31625 fma 1 -0E-400 0E-19 -> -0E-398 Clamped -- *
-fmax31626 fma 1 0E-400 -0E-19 -> -0E-398 Clamped -- *
-fmax31627 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31631 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31632 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31633 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-fmax31634 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
--- some exact zeros from non-zeros
-fmax31635 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31636 fma 1 -1E-401 1E-401 -> -0E-398 Clamped -- *
-fmax31637 fma 1 1E-401 -1E-401 -> -0E-398 Clamped -- *
-fmax31638 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
-
--- BigDecimal problem testcases 2006.01.23
-precision: 16
-maxExponent: 384
-minexponent: -383
-
-rounding: down
-precision: 7
-fmax31651 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 6
-fmax31652 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 5
-fmax31653 fma 1 10001E+2 -2E+1 -> 1.0000E+6 Inexact Rounded
-precision: 4
-fmax31654 fma 1 10001E+2 -2E+1 -> 1.000E+6 Inexact Rounded
-precision: 3
-fmax31655 fma 1 10001E+2 -2E+1 -> 1.00E+6 Inexact Rounded
-precision: 2
-fmax31656 fma 1 10001E+2 -2E+1 -> 1.0E+6 Inexact Rounded
-precision: 1
-fmax31657 fma 1 10001E+2 -2E+1 -> 1E+6 Inexact Rounded
-
-rounding: half_even
-precision: 7
-fmax31661 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 6
-fmax31662 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 5
-fmax31663 fma 1 10001E+2 -2E+1 -> 1.0001E+6 Inexact Rounded
-precision: 4
-fmax31664 fma 1 10001E+2 -2E+1 -> 1.000E+6 Inexact Rounded
-precision: 3
-fmax31665 fma 1 10001E+2 -2E+1 -> 1.00E+6 Inexact Rounded
-precision: 2
-fmax31666 fma 1 10001E+2 -2E+1 -> 1.0E+6 Inexact Rounded
-precision: 1
-fmax31667 fma 1 10001E+2 -2E+1 -> 1E+6 Inexact Rounded
-
-rounding: up
-precision: 7
-fmax31671 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 6
-fmax31672 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 5
-fmax31673 fma 1 10001E+2 -2E+1 -> 1.0001E+6 Inexact Rounded
-precision: 4
-fmax31674 fma 1 10001E+2 -2E+1 -> 1.001E+6 Inexact Rounded
-precision: 3
-fmax31675 fma 1 10001E+2 -2E+1 -> 1.01E+6 Inexact Rounded
-precision: 2
-fmax31676 fma 1 10001E+2 -2E+1 -> 1.1E+6 Inexact Rounded
-precision: 1
-fmax31677 fma 1 10001E+2 -2E+1 -> 2E+6 Inexact Rounded
-
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
--- Examples from SQL proposal (Krishna Kulkarni)
-fmax31701 fma 1 130E-2 120E-2 -> 2.50
-fmax31702 fma 1 130E-2 12E-1 -> 2.50
-fmax31703 fma 1 130E-2 1E0 -> 2.30
-fmax31704 fma 1 1E2 1E4 -> 1.01E+4
-fmax31705 subtract 130E-2 120E-2 -> 0.10
-fmax31706 subtract 130E-2 12E-1 -> 0.10
-fmax31707 subtract 130E-2 1E0 -> 0.30
-fmax31708 subtract 1E2 1E4 -> -9.9E+3
-
-------------------------------------------------------------------------
--- Same as above, using decimal64 default parameters --
-------------------------------------------------------------------------
-precision: 16
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- [first group are 'quick confidence check']
-fmax36001 fma 1 1 1 -> 2
-fmax36002 fma 1 2 3 -> 5
-fmax36003 fma 1 '5.75' '3.3' -> 9.05
-fmax36004 fma 1 '5' '-3' -> 2
-fmax36005 fma 1 '-5' '-3' -> -8
-fmax36006 fma 1 '-7' '2.5' -> -4.5
-fmax36007 fma 1 '0.7' '0.3' -> 1.0
-fmax36008 fma 1 '1.25' '1.25' -> 2.50
-fmax36009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
-fmax36010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
-
-fmax36011 fma 1 '0.44444444444444444' '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
-fmax36012 fma 1 '0.44444444444444440' '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
-fmax36013 fma 1 '0.44444444444444444' '0.55555555555555550' -> '0.9999999999999999' Inexact Rounded
-fmax36014 fma 1 '0.444444444444444449' '0' -> '0.4444444444444444' Inexact Rounded
-fmax36015 fma 1 '0.4444444444444444499' '0' -> '0.4444444444444444' Inexact Rounded
-fmax36016 fma 1 '0.44444444444444444999' '0' -> '0.4444444444444444' Inexact Rounded
-fmax36017 fma 1 '0.44444444444444445000' '0' -> '0.4444444444444444' Inexact Rounded
-fmax36018 fma 1 '0.44444444444444445001' '0' -> '0.4444444444444445' Inexact Rounded
-fmax36019 fma 1 '0.4444444444444444501' '0' -> '0.4444444444444445' Inexact Rounded
-fmax36020 fma 1 '0.444444444444444451' '0' -> '0.4444444444444445' Inexact Rounded
-
-fmax36021 fma 1 0 1 -> 1
-fmax36022 fma 1 1 1 -> 2
-fmax36023 fma 1 2 1 -> 3
-fmax36024 fma 1 3 1 -> 4
-fmax36025 fma 1 4 1 -> 5
-fmax36026 fma 1 5 1 -> 6
-fmax36027 fma 1 6 1 -> 7
-fmax36028 fma 1 7 1 -> 8
-fmax36029 fma 1 8 1 -> 9
-fmax36030 fma 1 9 1 -> 10
-
--- some carrying effects
-fmax36031 fma 1 '0.9998' '0.0000' -> '0.9998'
-fmax36032 fma 1 '0.9998' '0.0001' -> '0.9999'
-fmax36033 fma 1 '0.9998' '0.0002' -> '1.0000'
-fmax36034 fma 1 '0.9998' '0.0003' -> '1.0001'
-
-fmax36035 fma 1 '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-fmax36036 fma 1 '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-fmax36037 fma 1 '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-fmax36038 fma 1 '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
-fmax36039 fma 1 '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
-
--- symmetry:
-fmax36040 fma 1 '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
-fmax36041 fma 1 '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
-fmax36042 fma 1 '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
-fmax36044 fma 1 '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
-fmax36045 fma 1 '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
-
-fmax36046 fma 1 '10000e+9' '7' -> '10000000000007'
-fmax36047 fma 1 '10000e+9' '70' -> '10000000000070'
-fmax36048 fma 1 '10000e+9' '700' -> '10000000000700'
-fmax36049 fma 1 '10000e+9' '7000' -> '10000000007000'
-fmax36050 fma 1 '10000e+9' '70000' -> '10000000070000'
-fmax36051 fma 1 '10000e+9' '700000' -> '10000000700000'
-
--- examples from decarith
-fmax36053 fma 1 '12' '7.00' -> '19.00'
-fmax36054 fma 1 '1.3' '-1.07' -> '0.23'
-fmax36055 fma 1 '1.3' '-1.30' -> '0.00'
-fmax36056 fma 1 '1.3' '-2.07' -> '-0.77'
-fmax36057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
-
--- from above
-fmax36061 fma 1 1 '0.1' -> '1.1'
-fmax36062 fma 1 1 '0.01' -> '1.01'
-fmax36063 fma 1 1 '0.001' -> '1.001'
-fmax36064 fma 1 1 '0.0001' -> '1.0001'
-fmax36065 fma 1 1 '0.00001' -> '1.00001'
-fmax36066 fma 1 1 '0.000001' -> '1.000001'
-fmax36067 fma 1 1 '0.0000001' -> '1.0000001'
-fmax36068 fma 1 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-fmax36070 fma 1 1 0 -> 1
-fmax36071 fma 1 1 0. -> 1
-fmax36072 fma 1 1 .0 -> 1.0
-fmax36073 fma 1 1 0.0 -> 1.0
-fmax36074 fma 1 1 0.00 -> 1.00
-fmax36075 fma 1 0 1 -> 1
-fmax36076 fma 1 0. 1 -> 1
-fmax36077 fma 1 .0 1 -> 1.0
-fmax36078 fma 1 0.0 1 -> 1.0
-fmax36079 fma 1 0.00 1 -> 1.00
-
--- some carries
-fmax36080 fma 1 9999999999999998 1 -> 9999999999999999
-fmax36081 fma 1 9999999999999999 1 -> 1.000000000000000E+16 Rounded
-fmax36082 fma 1 999999999999999 1 -> 1000000000000000
-fmax36083 fma 1 9999999999999 1 -> 10000000000000
-fmax36084 fma 1 99999999999 1 -> 100000000000
-fmax36085 fma 1 999999999 1 -> 1000000000
-fmax36086 fma 1 9999999 1 -> 10000000
-fmax36087 fma 1 99999 1 -> 100000
-fmax36088 fma 1 999 1 -> 1000
-fmax36089 fma 1 9 1 -> 10
-
-
--- more LHS swaps
-fmax36090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
-fmax36091 fma 1 '-56267E-6' 0 -> '-0.056267'
-fmax36092 fma 1 '-56267E-5' 0 -> '-0.56267'
-fmax36093 fma 1 '-56267E-4' 0 -> '-5.6267'
-fmax36094 fma 1 '-56267E-3' 0 -> '-56.267'
-fmax36095 fma 1 '-56267E-2' 0 -> '-562.67'
-fmax36096 fma 1 '-56267E-1' 0 -> '-5626.7'
-fmax36097 fma 1 '-56267E-0' 0 -> '-56267'
-fmax36098 fma 1 '-5E-10' 0 -> '-5E-10'
-fmax36099 fma 1 '-5E-7' 0 -> '-5E-7'
-fmax36100 fma 1 '-5E-6' 0 -> '-0.000005'
-fmax36101 fma 1 '-5E-5' 0 -> '-0.00005'
-fmax36102 fma 1 '-5E-4' 0 -> '-0.0005'
-fmax36103 fma 1 '-5E-1' 0 -> '-0.5'
-fmax36104 fma 1 '-5E0' 0 -> '-5'
-fmax36105 fma 1 '-5E1' 0 -> '-50'
-fmax36106 fma 1 '-5E5' 0 -> '-500000'
-fmax36107 fma 1 '-5E15' 0 -> '-5000000000000000'
-fmax36108 fma 1 '-5E16' 0 -> '-5.000000000000000E+16' Rounded
-fmax36109 fma 1 '-5E17' 0 -> '-5.000000000000000E+17' Rounded
-fmax36110 fma 1 '-5E18' 0 -> '-5.000000000000000E+18' Rounded
-fmax36111 fma 1 '-5E100' 0 -> '-5.000000000000000E+100' Rounded
-
--- more RHS swaps
-fmax36113 fma 1 0 '-56267E-10' -> '-0.0000056267'
-fmax36114 fma 1 0 '-56267E-6' -> '-0.056267'
-fmax36116 fma 1 0 '-56267E-5' -> '-0.56267'
-fmax36117 fma 1 0 '-56267E-4' -> '-5.6267'
-fmax36119 fma 1 0 '-56267E-3' -> '-56.267'
-fmax36120 fma 1 0 '-56267E-2' -> '-562.67'
-fmax36121 fma 1 0 '-56267E-1' -> '-5626.7'
-fmax36122 fma 1 0 '-56267E-0' -> '-56267'
-fmax36123 fma 1 0 '-5E-10' -> '-5E-10'
-fmax36124 fma 1 0 '-5E-7' -> '-5E-7'
-fmax36125 fma 1 0 '-5E-6' -> '-0.000005'
-fmax36126 fma 1 0 '-5E-5' -> '-0.00005'
-fmax36127 fma 1 0 '-5E-4' -> '-0.0005'
-fmax36128 fma 1 0 '-5E-1' -> '-0.5'
-fmax36129 fma 1 0 '-5E0' -> '-5'
-fmax36130 fma 1 0 '-5E1' -> '-50'
-fmax36131 fma 1 0 '-5E5' -> '-500000'
-fmax36132 fma 1 0 '-5E15' -> '-5000000000000000'
-fmax36133 fma 1 0 '-5E16' -> '-5.000000000000000E+16' Rounded
-fmax36134 fma 1 0 '-5E17' -> '-5.000000000000000E+17' Rounded
-fmax36135 fma 1 0 '-5E18' -> '-5.000000000000000E+18' Rounded
-fmax36136 fma 1 0 '-5E100' -> '-5.000000000000000E+100' Rounded
-
--- related
-fmax36137 fma 1 1 '0E-19' -> '1.000000000000000' Rounded
-fmax36138 fma 1 -1 '0E-19' -> '-1.000000000000000' Rounded
-fmax36139 fma 1 '0E-19' 1 -> '1.000000000000000' Rounded
-fmax36140 fma 1 '0E-19' -1 -> '-1.000000000000000' Rounded
-fmax36141 fma 1 1E+11 0.0000 -> '100000000000.0000'
-fmax36142 fma 1 1E+11 0.00000 -> '100000000000.0000' Rounded
-fmax36143 fma 1 0.000 1E+12 -> '1000000000000.000'
-fmax36144 fma 1 0.0000 1E+12 -> '1000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-fmax36146 fma 1 '00.0' 0 -> '0.0'
-fmax36147 fma 1 '0.00' 0 -> '0.00'
-fmax36148 fma 1 0 '0.00' -> '0.00'
-fmax36149 fma 1 0 '00.0' -> '0.0'
-fmax36150 fma 1 '00.0' '0.00' -> '0.00'
-fmax36151 fma 1 '0.00' '00.0' -> '0.00'
-fmax36152 fma 1 '3' '.3' -> '3.3'
-fmax36153 fma 1 '3.' '.3' -> '3.3'
-fmax36154 fma 1 '3.0' '.3' -> '3.3'
-fmax36155 fma 1 '3.00' '.3' -> '3.30'
-fmax36156 fma 1 '3' '3' -> '6'
-fmax36157 fma 1 '3' '+3' -> '6'
-fmax36158 fma 1 '3' '-3' -> '0'
-fmax36159 fma 1 '0.3' '-0.3' -> '0.0'
-fmax36160 fma 1 '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-fmax36161 fma 1 '1E+13' '-1' -> '9999999999999'
-fmax36162 fma 1 '1E+13' '1.11' -> '10000000000001.11'
-fmax36163 fma 1 '1.11' '1E+13' -> '10000000000001.11'
-fmax36164 fma 1 '-1' '1E+13' -> '9999999999999'
-fmax36165 fma 1 '7E+13' '-1' -> '69999999999999'
-fmax36166 fma 1 '7E+13' '1.11' -> '70000000000001.11'
-fmax36167 fma 1 '1.11' '7E+13' -> '70000000000001.11'
-fmax36168 fma 1 '-1' '7E+13' -> '69999999999999'
-
--- 1234567890123456 1234567890123456 1 234567890123456
-fmax36170 fma 1 '0.4444444444444444' '0.5555555555555563' -> '1.000000000000001' Inexact Rounded
-fmax36171 fma 1 '0.4444444444444444' '0.5555555555555562' -> '1.000000000000001' Inexact Rounded
-fmax36172 fma 1 '0.4444444444444444' '0.5555555555555561' -> '1.000000000000000' Inexact Rounded
-fmax36173 fma 1 '0.4444444444444444' '0.5555555555555560' -> '1.000000000000000' Inexact Rounded
-fmax36174 fma 1 '0.4444444444444444' '0.5555555555555559' -> '1.000000000000000' Inexact Rounded
-fmax36175 fma 1 '0.4444444444444444' '0.5555555555555558' -> '1.000000000000000' Inexact Rounded
-fmax36176 fma 1 '0.4444444444444444' '0.5555555555555557' -> '1.000000000000000' Inexact Rounded
-fmax36177 fma 1 '0.4444444444444444' '0.5555555555555556' -> '1.000000000000000' Rounded
-fmax36178 fma 1 '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
-fmax36179 fma 1 '0.4444444444444444' '0.5555555555555554' -> '0.9999999999999998'
-fmax36180 fma 1 '0.4444444444444444' '0.5555555555555553' -> '0.9999999999999997'
-fmax36181 fma 1 '0.4444444444444444' '0.5555555555555552' -> '0.9999999999999996'
-fmax36182 fma 1 '0.4444444444444444' '0.5555555555555551' -> '0.9999999999999995'
-fmax36183 fma 1 '0.4444444444444444' '0.5555555555555550' -> '0.9999999999999994'
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-fmax36200 fma 1 '6543210123456789' 0 -> '6543210123456789'
-fmax36201 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-fmax36202 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-fmax36203 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-fmax36204 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-fmax36205 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-fmax36206 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36207 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36208 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-fmax36209 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-fmax36210 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-fmax36211 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-fmax36212 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-fmax36213 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-fmax36214 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-fmax36215 fma 1 '6543210123456789' 0.999999 -> '6543210123456790' Inexact Rounded
-fmax36216 fma 1 '6543210123456789' 1 -> '6543210123456790'
-fmax36217 fma 1 '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
-fmax36218 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-fmax36219 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
-rounding: half_even
-fmax36220 fma 1 '6543210123456789' 0 -> '6543210123456789'
-fmax36221 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-fmax36222 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-fmax36223 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-fmax36224 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-fmax36225 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-fmax36226 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36227 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36228 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-fmax36229 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-fmax36230 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-fmax36231 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-fmax36232 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-fmax36233 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-fmax36234 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-fmax36235 fma 1 '6543210123456789' 0.999999 -> '6543210123456790' Inexact Rounded
-fmax36236 fma 1 '6543210123456789' 1 -> '6543210123456790'
-fmax36237 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-fmax36238 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-fmax36239 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
--- critical few with even bottom digit...
-fmax36240 fma 1 '6543210123456788' 0.499999 -> '6543210123456788' Inexact Rounded
-fmax36241 fma 1 '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
-fmax36242 fma 1 '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
-
-rounding: down
-fmax36250 fma 1 '6543210123456789' 0 -> '6543210123456789'
-fmax36251 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-fmax36252 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-fmax36253 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-fmax36254 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-fmax36255 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-fmax36256 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36257 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36258 fma 1 '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
-fmax36259 fma 1 '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
-fmax36260 fma 1 '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
-fmax36261 fma 1 '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
-fmax36262 fma 1 '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
-fmax36263 fma 1 '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
-fmax36264 fma 1 '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
-fmax36265 fma 1 '6543210123456789' 0.999999 -> '6543210123456789' Inexact Rounded
-fmax36266 fma 1 '6543210123456789' 1 -> '6543210123456790'
-fmax36267 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-fmax36268 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-fmax36269 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_even
-fmax36301 fma 1 -1 1 -> 0
-fmax36302 fma 1 0 1 -> 1
-fmax36303 fma 1 1 1 -> 2
-fmax36304 fma 1 12 1 -> 13
-fmax36305 fma 1 98 1 -> 99
-fmax36306 fma 1 99 1 -> 100
-fmax36307 fma 1 100 1 -> 101
-fmax36308 fma 1 101 1 -> 102
-fmax36309 fma 1 -1 -1 -> -2
-fmax36310 fma 1 0 -1 -> -1
-fmax36311 fma 1 1 -1 -> 0
-fmax36312 fma 1 12 -1 -> 11
-fmax36313 fma 1 98 -1 -> 97
-fmax36314 fma 1 99 -1 -> 98
-fmax36315 fma 1 100 -1 -> 99
-fmax36316 fma 1 101 -1 -> 100
-
-fmax36321 fma 1 -0.01 0.01 -> 0.00
-fmax36322 fma 1 0.00 0.01 -> 0.01
-fmax36323 fma 1 0.01 0.01 -> 0.02
-fmax36324 fma 1 0.12 0.01 -> 0.13
-fmax36325 fma 1 0.98 0.01 -> 0.99
-fmax36326 fma 1 0.99 0.01 -> 1.00
-fmax36327 fma 1 1.00 0.01 -> 1.01
-fmax36328 fma 1 1.01 0.01 -> 1.02
-fmax36329 fma 1 -0.01 -0.01 -> -0.02
-fmax36330 fma 1 0.00 -0.01 -> -0.01
-fmax36331 fma 1 0.01 -0.01 -> 0.00
-fmax36332 fma 1 0.12 -0.01 -> 0.11
-fmax36333 fma 1 0.98 -0.01 -> 0.97
-fmax36334 fma 1 0.99 -0.01 -> 0.98
-fmax36335 fma 1 1.00 -0.01 -> 0.99
-fmax36336 fma 1 1.01 -0.01 -> 1.00
-
--- some more cases where fma 1 ing 0 affects the coefficient
-fmax36340 fma 1 1E+3 0 -> 1000
-fmax36341 fma 1 1E+15 0 -> 1000000000000000
-fmax36342 fma 1 1E+16 0 -> 1.000000000000000E+16 Rounded
-fmax36343 fma 1 1E+17 0 -> 1.000000000000000E+17 Rounded
--- which simply follow from these cases ...
-fmax36344 fma 1 1E+3 1 -> 1001
-fmax36345 fma 1 1E+15 1 -> 1000000000000001
-fmax36346 fma 1 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
-fmax36347 fma 1 1E+17 1 -> 1.000000000000000E+17 Inexact Rounded
-fmax36348 fma 1 1E+3 7 -> 1007
-fmax36349 fma 1 1E+15 7 -> 1000000000000007
-fmax36350 fma 1 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
-fmax36351 fma 1 1E+17 7 -> 1.000000000000000E+17 Inexact Rounded
-
--- tryzeros cases
-fmax36361 fma 1 0E+50 10000E+1 -> 1.0000E+5
-fmax36362 fma 1 10000E+1 0E-50 -> 100000.0000000000 Rounded
-fmax36363 fma 1 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
-fmax36364 fma 1 12.34 0e-398 -> 12.34000000000000 Rounded
-
--- ulp replacement tests
-fmax36400 fma 1 1 77e-14 -> 1.00000000000077
-fmax36401 fma 1 1 77e-15 -> 1.000000000000077
-fmax36402 fma 1 1 77e-16 -> 1.000000000000008 Inexact Rounded
-fmax36403 fma 1 1 77e-17 -> 1.000000000000001 Inexact Rounded
-fmax36404 fma 1 1 77e-18 -> 1.000000000000000 Inexact Rounded
-fmax36405 fma 1 1 77e-19 -> 1.000000000000000 Inexact Rounded
-fmax36406 fma 1 1 77e-99 -> 1.000000000000000 Inexact Rounded
-
-fmax36410 fma 1 10 77e-14 -> 10.00000000000077
-fmax36411 fma 1 10 77e-15 -> 10.00000000000008 Inexact Rounded
-fmax36412 fma 1 10 77e-16 -> 10.00000000000001 Inexact Rounded
-fmax36413 fma 1 10 77e-17 -> 10.00000000000000 Inexact Rounded
-fmax36414 fma 1 10 77e-18 -> 10.00000000000000 Inexact Rounded
-fmax36415 fma 1 10 77e-19 -> 10.00000000000000 Inexact Rounded
-fmax36416 fma 1 10 77e-99 -> 10.00000000000000 Inexact Rounded
-
-fmax36420 fma 1 77e-14 1 -> 1.00000000000077
-fmax36421 fma 1 77e-15 1 -> 1.000000000000077
-fmax36422 fma 1 77e-16 1 -> 1.000000000000008 Inexact Rounded
-fmax36423 fma 1 77e-17 1 -> 1.000000000000001 Inexact Rounded
-fmax36424 fma 1 77e-18 1 -> 1.000000000000000 Inexact Rounded
-fmax36425 fma 1 77e-19 1 -> 1.000000000000000 Inexact Rounded
-fmax36426 fma 1 77e-99 1 -> 1.000000000000000 Inexact Rounded
-
-fmax36430 fma 1 77e-14 10 -> 10.00000000000077
-fmax36431 fma 1 77e-15 10 -> 10.00000000000008 Inexact Rounded
-fmax36432 fma 1 77e-16 10 -> 10.00000000000001 Inexact Rounded
-fmax36433 fma 1 77e-17 10 -> 10.00000000000000 Inexact Rounded
-fmax36434 fma 1 77e-18 10 -> 10.00000000000000 Inexact Rounded
-fmax36435 fma 1 77e-19 10 -> 10.00000000000000 Inexact Rounded
-fmax36436 fma 1 77e-99 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-fmax36440 fma 1 1 -77e-14 -> 0.99999999999923
-fmax36441 fma 1 1 -77e-15 -> 0.999999999999923
-fmax36442 fma 1 1 -77e-16 -> 0.9999999999999923
-fmax36443 fma 1 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
-fmax36444 fma 1 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
-fmax36445 fma 1 1 -77e-19 -> 1.000000000000000 Inexact Rounded
-fmax36446 fma 1 1 -77e-99 -> 1.000000000000000 Inexact Rounded
-
-fmax36450 fma 1 10 -77e-14 -> 9.99999999999923
-fmax36451 fma 1 10 -77e-15 -> 9.999999999999923
-fmax36452 fma 1 10 -77e-16 -> 9.999999999999992 Inexact Rounded
-fmax36453 fma 1 10 -77e-17 -> 9.999999999999999 Inexact Rounded
-fmax36454 fma 1 10 -77e-18 -> 10.00000000000000 Inexact Rounded
-fmax36455 fma 1 10 -77e-19 -> 10.00000000000000 Inexact Rounded
-fmax36456 fma 1 10 -77e-99 -> 10.00000000000000 Inexact Rounded
-
-fmax36460 fma 1 -77e-14 1 -> 0.99999999999923
-fmax36461 fma 1 -77e-15 1 -> 0.999999999999923
-fmax36462 fma 1 -77e-16 1 -> 0.9999999999999923
-fmax36463 fma 1 -77e-17 1 -> 0.9999999999999992 Inexact Rounded
-fmax36464 fma 1 -77e-18 1 -> 0.9999999999999999 Inexact Rounded
-fmax36465 fma 1 -77e-19 1 -> 1.000000000000000 Inexact Rounded
-fmax36466 fma 1 -77e-99 1 -> 1.000000000000000 Inexact Rounded
-
-fmax36470 fma 1 -77e-14 10 -> 9.99999999999923
-fmax36471 fma 1 -77e-15 10 -> 9.999999999999923
-fmax36472 fma 1 -77e-16 10 -> 9.999999999999992 Inexact Rounded
-fmax36473 fma 1 -77e-17 10 -> 9.999999999999999 Inexact Rounded
-fmax36474 fma 1 -77e-18 10 -> 10.00000000000000 Inexact Rounded
-fmax36475 fma 1 -77e-19 10 -> 10.00000000000000 Inexact Rounded
-fmax36476 fma 1 -77e-99 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-fmax36480 fma 1 -1 77e-14 -> -0.99999999999923
-fmax36481 fma 1 -1 77e-15 -> -0.999999999999923
-fmax36482 fma 1 -1 77e-16 -> -0.9999999999999923
-fmax36483 fma 1 -1 77e-17 -> -0.9999999999999992 Inexact Rounded
-fmax36484 fma 1 -1 77e-18 -> -0.9999999999999999 Inexact Rounded
-fmax36485 fma 1 -1 77e-19 -> -1.000000000000000 Inexact Rounded
-fmax36486 fma 1 -1 77e-99 -> -1.000000000000000 Inexact Rounded
-
-fmax36490 fma 1 -10 77e-14 -> -9.99999999999923
-fmax36491 fma 1 -10 77e-15 -> -9.999999999999923
-fmax36492 fma 1 -10 77e-16 -> -9.999999999999992 Inexact Rounded
-fmax36493 fma 1 -10 77e-17 -> -9.999999999999999 Inexact Rounded
-fmax36494 fma 1 -10 77e-18 -> -10.00000000000000 Inexact Rounded
-fmax36495 fma 1 -10 77e-19 -> -10.00000000000000 Inexact Rounded
-fmax36496 fma 1 -10 77e-99 -> -10.00000000000000 Inexact Rounded
-
-fmax36500 fma 1 77e-14 -1 -> -0.99999999999923
-fmax36501 fma 1 77e-15 -1 -> -0.999999999999923
-fmax36502 fma 1 77e-16 -1 -> -0.9999999999999923
-fmax36503 fma 1 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
-fmax36504 fma 1 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
-fmax36505 fma 1 77e-19 -1 -> -1.000000000000000 Inexact Rounded
-fmax36506 fma 1 77e-99 -1 -> -1.000000000000000 Inexact Rounded
-
-fmax36510 fma 1 77e-14 -10 -> -9.99999999999923
-fmax36511 fma 1 77e-15 -10 -> -9.999999999999923
-fmax36512 fma 1 77e-16 -10 -> -9.999999999999992 Inexact Rounded
-fmax36513 fma 1 77e-17 -10 -> -9.999999999999999 Inexact Rounded
-fmax36514 fma 1 77e-18 -10 -> -10.00000000000000 Inexact Rounded
-fmax36515 fma 1 77e-19 -10 -> -10.00000000000000 Inexact Rounded
-fmax36516 fma 1 77e-99 -10 -> -10.00000000000000 Inexact Rounded
-
-
--- long operands
-fmax36521 fma 1 101234562345678000 0 -> 1.012345623456780E+17 Rounded
-fmax36522 fma 1 0 101234562345678000 -> 1.012345623456780E+17 Rounded
-fmax36523 fma 1 10123456234567800 0 -> 1.012345623456780E+16 Rounded
-fmax36524 fma 1 0 10123456234567800 -> 1.012345623456780E+16 Rounded
-fmax36525 fma 1 10123456234567890 0 -> 1.012345623456789E+16 Rounded
-fmax36526 fma 1 0 10123456234567890 -> 1.012345623456789E+16 Rounded
-fmax36527 fma 1 10123456234567891 0 -> 1.012345623456789E+16 Inexact Rounded
-fmax36528 fma 1 0 10123456234567891 -> 1.012345623456789E+16 Inexact Rounded
-fmax36529 fma 1 101234562345678901 0 -> 1.012345623456789E+17 Inexact Rounded
-fmax36530 fma 1 0 101234562345678901 -> 1.012345623456789E+17 Inexact Rounded
-fmax36531 fma 1 10123456234567896 0 -> 1.012345623456790E+16 Inexact Rounded
-fmax36532 fma 1 0 10123456234567896 -> 1.012345623456790E+16 Inexact Rounded
-
--- verify a query
-rounding: down
-fmax36561 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
-fmax36562 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
--- and using decimal64 bounds...
-rounding: down
-fmax36563 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
-fmax36564 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-fmax36701 fma 1 5.00 1.00E-3 -> 5.00100
-fmax36702 fma 1 00.00 0.000 -> 0.000
-fmax36703 fma 1 00.00 0E-3 -> 0.000
-fmax36704 fma 1 0E-3 00.00 -> 0.000
-
-fmax36710 fma 1 0E+3 00.00 -> 0.00
-fmax36711 fma 1 0E+3 00.0 -> 0.0
-fmax36712 fma 1 0E+3 00. -> 0
-fmax36713 fma 1 0E+3 00.E+1 -> 0E+1
-fmax36714 fma 1 0E+3 00.E+2 -> 0E+2
-fmax36715 fma 1 0E+3 00.E+3 -> 0E+3
-fmax36716 fma 1 0E+3 00.E+4 -> 0E+3
-fmax36717 fma 1 0E+3 00.E+5 -> 0E+3
-fmax36718 fma 1 0E+3 -00.0 -> 0.0
-fmax36719 fma 1 0E+3 -00. -> 0
-fmax36731 fma 1 0E+3 -00.E+1 -> 0E+1
-
-fmax36720 fma 1 00.00 0E+3 -> 0.00
-fmax36721 fma 1 00.0 0E+3 -> 0.0
-fmax36722 fma 1 00. 0E+3 -> 0
-fmax36723 fma 1 00.E+1 0E+3 -> 0E+1
-fmax36724 fma 1 00.E+2 0E+3 -> 0E+2
-fmax36725 fma 1 00.E+3 0E+3 -> 0E+3
-fmax36726 fma 1 00.E+4 0E+3 -> 0E+3
-fmax36727 fma 1 00.E+5 0E+3 -> 0E+3
-fmax36728 fma 1 -00.00 0E+3 -> 0.00
-fmax36729 fma 1 -00.0 0E+3 -> 0.0
-fmax36730 fma 1 -00. 0E+3 -> 0
-
-fmax36732 fma 1 0 0 -> 0
-fmax36733 fma 1 0 -0 -> 0
-fmax36734 fma 1 -0 0 -> 0
-fmax36735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
-
-fmax36736 fma 1 1 -1 -> 0
-fmax36737 fma 1 -1 -1 -> -2
-fmax36738 fma 1 1 1 -> 2
-fmax36739 fma 1 -1 1 -> 0
-
-fmax36741 fma 1 0 -1 -> -1
-fmax36742 fma 1 -0 -1 -> -1
-fmax36743 fma 1 0 1 -> 1
-fmax36744 fma 1 -0 1 -> 1
-fmax36745 fma 1 -1 0 -> -1
-fmax36746 fma 1 -1 -0 -> -1
-fmax36747 fma 1 1 0 -> 1
-fmax36748 fma 1 1 -0 -> 1
-
-fmax36751 fma 1 0.0 -1 -> -1.0
-fmax36752 fma 1 -0.0 -1 -> -1.0
-fmax36753 fma 1 0.0 1 -> 1.0
-fmax36754 fma 1 -0.0 1 -> 1.0
-fmax36755 fma 1 -1.0 0 -> -1.0
-fmax36756 fma 1 -1.0 -0 -> -1.0
-fmax36757 fma 1 1.0 0 -> 1.0
-fmax36758 fma 1 1.0 -0 -> 1.0
-
-fmax36761 fma 1 0 -1.0 -> -1.0
-fmax36762 fma 1 -0 -1.0 -> -1.0
-fmax36763 fma 1 0 1.0 -> 1.0
-fmax36764 fma 1 -0 1.0 -> 1.0
-fmax36765 fma 1 -1 0.0 -> -1.0
-fmax36766 fma 1 -1 -0.0 -> -1.0
-fmax36767 fma 1 1 0.0 -> 1.0
-fmax36768 fma 1 1 -0.0 -> 1.0
-
-fmax36771 fma 1 0.0 -1.0 -> -1.0
-fmax36772 fma 1 -0.0 -1.0 -> -1.0
-fmax36773 fma 1 0.0 1.0 -> 1.0
-fmax36774 fma 1 -0.0 1.0 -> 1.0
-fmax36775 fma 1 -1.0 0.0 -> -1.0
-fmax36776 fma 1 -1.0 -0.0 -> -1.0
-fmax36777 fma 1 1.0 0.0 -> 1.0
-fmax36778 fma 1 1.0 -0.0 -> 1.0
-
--- Specials
-fmax36780 fma 1 -Inf -Inf -> -Infinity
-fmax36781 fma 1 -Inf -1000 -> -Infinity
-fmax36782 fma 1 -Inf -1 -> -Infinity
-fmax36783 fma 1 -Inf -0 -> -Infinity
-fmax36784 fma 1 -Inf 0 -> -Infinity
-fmax36785 fma 1 -Inf 1 -> -Infinity
-fmax36786 fma 1 -Inf 1000 -> -Infinity
-fmax36787 fma 1 -1000 -Inf -> -Infinity
-fmax36788 fma 1 -Inf -Inf -> -Infinity
-fmax36789 fma 1 -1 -Inf -> -Infinity
-fmax36790 fma 1 -0 -Inf -> -Infinity
-fmax36791 fma 1 0 -Inf -> -Infinity
-fmax36792 fma 1 1 -Inf -> -Infinity
-fmax36793 fma 1 1000 -Inf -> -Infinity
-fmax36794 fma 1 Inf -Inf -> NaN Invalid_operation
-
-fmax36800 fma 1 Inf -Inf -> NaN Invalid_operation
-fmax36801 fma 1 Inf -1000 -> Infinity
-fmax36802 fma 1 Inf -1 -> Infinity
-fmax36803 fma 1 Inf -0 -> Infinity
-fmax36804 fma 1 Inf 0 -> Infinity
-fmax36805 fma 1 Inf 1 -> Infinity
-fmax36806 fma 1 Inf 1000 -> Infinity
-fmax36807 fma 1 Inf Inf -> Infinity
-fmax36808 fma 1 -1000 Inf -> Infinity
-fmax36809 fma 1 -Inf Inf -> NaN Invalid_operation
-fmax36810 fma 1 -1 Inf -> Infinity
-fmax36811 fma 1 -0 Inf -> Infinity
-fmax36812 fma 1 0 Inf -> Infinity
-fmax36813 fma 1 1 Inf -> Infinity
-fmax36814 fma 1 1000 Inf -> Infinity
-fmax36815 fma 1 Inf Inf -> Infinity
-
-fmax36821 fma 1 NaN -Inf -> NaN
-fmax36822 fma 1 NaN -1000 -> NaN
-fmax36823 fma 1 NaN -1 -> NaN
-fmax36824 fma 1 NaN -0 -> NaN
-fmax36825 fma 1 NaN 0 -> NaN
-fmax36826 fma 1 NaN 1 -> NaN
-fmax36827 fma 1 NaN 1000 -> NaN
-fmax36828 fma 1 NaN Inf -> NaN
-fmax36829 fma 1 NaN NaN -> NaN
-fmax36830 fma 1 -Inf NaN -> NaN
-fmax36831 fma 1 -1000 NaN -> NaN
-fmax36832 fma 1 -1 NaN -> NaN
-fmax36833 fma 1 -0 NaN -> NaN
-fmax36834 fma 1 0 NaN -> NaN
-fmax36835 fma 1 1 NaN -> NaN
-fmax36836 fma 1 1000 NaN -> NaN
-fmax36837 fma 1 Inf NaN -> NaN
-
-fmax36841 fma 1 sNaN -Inf -> NaN Invalid_operation
-fmax36842 fma 1 sNaN -1000 -> NaN Invalid_operation
-fmax36843 fma 1 sNaN -1 -> NaN Invalid_operation
-fmax36844 fma 1 sNaN -0 -> NaN Invalid_operation
-fmax36845 fma 1 sNaN 0 -> NaN Invalid_operation
-fmax36846 fma 1 sNaN 1 -> NaN Invalid_operation
-fmax36847 fma 1 sNaN 1000 -> NaN Invalid_operation
-fmax36848 fma 1 sNaN NaN -> NaN Invalid_operation
-fmax36849 fma 1 sNaN sNaN -> NaN Invalid_operation
-fmax36850 fma 1 NaN sNaN -> NaN Invalid_operation
-fmax36851 fma 1 -Inf sNaN -> NaN Invalid_operation
-fmax36852 fma 1 -1000 sNaN -> NaN Invalid_operation
-fmax36853 fma 1 -1 sNaN -> NaN Invalid_operation
-fmax36854 fma 1 -0 sNaN -> NaN Invalid_operation
-fmax36855 fma 1 0 sNaN -> NaN Invalid_operation
-fmax36856 fma 1 1 sNaN -> NaN Invalid_operation
-fmax36857 fma 1 1000 sNaN -> NaN Invalid_operation
-fmax36858 fma 1 Inf sNaN -> NaN Invalid_operation
-fmax36859 fma 1 NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-fmax36861 fma 1 NaN1 -Inf -> NaN1
-fmax36862 fma 1 +NaN2 -1000 -> NaN2
-fmax36863 fma 1 NaN3 1000 -> NaN3
-fmax36864 fma 1 NaN4 Inf -> NaN4
-fmax36865 fma 1 NaN5 +NaN6 -> NaN5
-fmax36866 fma 1 -Inf NaN7 -> NaN7
-fmax36867 fma 1 -1000 NaN8 -> NaN8
-fmax36868 fma 1 1000 NaN9 -> NaN9
-fmax36869 fma 1 Inf +NaN10 -> NaN10
-fmax36871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
-fmax36872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
-fmax36873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
-fmax36874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
-fmax36875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
-fmax36876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
-fmax36877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
-fmax36878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
-fmax36879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
-fmax36880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
-fmax36881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
-fmax36882 fma 1 -NaN26 NaN28 -> -NaN26
-fmax36883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-fmax36884 fma 1 1000 -NaN30 -> -NaN30
-fmax36885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- now the case where we can get underflow but the result is normal
--- [note this can't happen if the operands are also bounded, as we
--- cannot represent 1E-399, for example]
-
-fmax36571 fma 1 1E-383 0 -> 1E-383
-fmax36572 fma 1 1E-384 0 -> 1E-384 Subnormal
-fmax36573 fma 1 1E-383 1E-384 -> 1.1E-383
-fmax36574 subtract 1E-383 1E-384 -> 9E-384 Subnormal
-
--- Here we explore the boundary of rounding a subnormal to Nmin
-fmax36575 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
-fmax36576 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
-fmax36577 subtract 1E-383 1E-399 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax36578 subtract 1E-383 1E-400 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax36579 subtract 1E-383 1E-401 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax36580 subtract 1E-383 1E-402 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-
--- check overflow edge case
--- 1234567890123456
-fmax36972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
-fmax36973 fma 1 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
-fmax36974 fma 1 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
-fmax36975 fma 1 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
-fmax36976 fma 1 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
-fmax36977 fma 1 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
-fmax36978 fma 1 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
-fmax36979 fma 1 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
-fmax36980 fma 1 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
-fmax36981 fma 1 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
-fmax36982 fma 1 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
-fmax36983 fma 1 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
-fmax36984 fma 1 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
-
-fmax36985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
-fmax36986 fma 1 -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
-fmax36987 fma 1 -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
-fmax36988 fma 1 -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
-fmax36989 fma 1 -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
-fmax36990 fma 1 -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
-fmax36991 fma 1 -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
-fmax36992 fma 1 -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
-fmax36993 fma 1 -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
-fmax36994 fma 1 -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
-fmax36995 fma 1 -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
-fmax36996 fma 1 -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
-fmax36997 fma 1 -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-fmax361100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
-fmax361101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
-fmax361103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
-fmax361104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
-fmax361105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
-fmax361106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
-fmax361107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
-fmax361108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
-fmax361109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-fmax361110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
-fmax361111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
-fmax361113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
-fmax361114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
-fmax361115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
-fmax361116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
-fmax361117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
-fmax361118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
-fmax361119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-fmax361300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
-fmax361310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
-fmax361311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
-fmax361312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
-fmax361313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
-fmax361314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
-fmax361315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
-fmax361316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
-fmax361317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
-fmax361318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
-fmax361319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
-fmax361320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
-fmax361321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
-fmax361322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
-fmax361323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
-fmax361324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
-fmax361325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
-fmax361339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
-
-fmax361340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
-fmax361341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
-
-fmax361349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
-fmax361350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
-fmax361351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
-fmax361352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
-fmax361353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
-fmax361354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
-fmax361355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
-fmax361356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
-fmax361357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
-fmax361358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
-fmax361359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
-fmax361360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
-fmax361361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
-fmax361362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
-fmax361363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
-fmax361364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
-fmax361365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
-fmax361380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
-fmax361381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
-fmax361382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
-fmax361396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-fmax361420 fma 1 0 1.123456789012345 -> 1.123456789012345
-fmax361421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
-fmax361422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
-fmax361423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
-fmax361424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
-fmax361425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
-fmax361426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
-fmax361427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
-fmax361428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
-fmax361429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
-fmax361430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
-fmax361431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
-fmax361432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
-fmax361433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
-fmax361434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
-fmax361435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
-fmax361436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
-fmax361437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
-fmax361438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
-fmax361439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
-
--- same, reversed 0
-fmax361440 fma 1 1.123456789012345 0 -> 1.123456789012345
-fmax361441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
-fmax361442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
-fmax361443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
-fmax361444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
-fmax361445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
-fmax361446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
-fmax361447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
-fmax361448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
-fmax361449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
-fmax361450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
-fmax361451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
-fmax361452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
-fmax361453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
-fmax361454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
-fmax361455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
-fmax361456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
-fmax361457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
-fmax361458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
-fmax361459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
-
--- same, Es on the 0
-fmax361460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
-fmax361461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
-fmax361462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
-fmax361463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
-fmax361464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
-fmax361465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
-fmax361466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
-fmax361467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
-fmax361468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
-fmax361469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
-fmax361470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
-fmax361471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
-fmax361472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
-fmax361473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
-fmax361474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
-fmax361475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
--- next four flag Rounded because the 0 extends the result
-fmax361476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
-fmax361477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
-fmax361478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
-fmax361479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-fmax361500 fma 1 0 0E-19 -> 0E-19
-fmax361501 fma 1 -0 0E-19 -> 0E-19
-fmax361502 fma 1 0 -0E-19 -> 0E-19
-fmax361503 fma 1 -0 -0E-19 -> -0E-19
-fmax361504 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361505 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361506 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361507 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361511 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361512 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361513 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361514 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361515 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361516 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361517 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361518 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: half_down
--- exact zeros from zeros
-fmax361520 fma 1 0 0E-19 -> 0E-19
-fmax361521 fma 1 -0 0E-19 -> 0E-19
-fmax361522 fma 1 0 -0E-19 -> 0E-19
-fmax361523 fma 1 -0 -0E-19 -> -0E-19
-fmax361524 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361525 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361526 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361527 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361531 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361532 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361533 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361534 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361535 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361536 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361537 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361538 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: half_even
--- exact zeros from zeros
-fmax361540 fma 1 0 0E-19 -> 0E-19
-fmax361541 fma 1 -0 0E-19 -> 0E-19
-fmax361542 fma 1 0 -0E-19 -> 0E-19
-fmax361543 fma 1 -0 -0E-19 -> -0E-19
-fmax361544 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361545 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361546 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361547 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361551 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361552 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361553 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361554 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361555 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361556 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361557 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361558 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: up
--- exact zeros from zeros
-fmax361560 fma 1 0 0E-19 -> 0E-19
-fmax361561 fma 1 -0 0E-19 -> 0E-19
-fmax361562 fma 1 0 -0E-19 -> 0E-19
-fmax361563 fma 1 -0 -0E-19 -> -0E-19
-fmax361564 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361565 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361566 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361567 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361571 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361572 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361573 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-fmax361574 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
--- some exact zeros from non-zeros
-fmax361575 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361576 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361577 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361578 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
-
-rounding: down
--- exact zeros from zeros
-fmax361580 fma 1 0 0E-19 -> 0E-19
-fmax361581 fma 1 -0 0E-19 -> 0E-19
-fmax361582 fma 1 0 -0E-19 -> 0E-19
-fmax361583 fma 1 -0 -0E-19 -> -0E-19
-fmax361584 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361585 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361586 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361587 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361591 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361592 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361593 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361594 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361595 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361596 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361597 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361598 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: ceiling
--- exact zeros from zeros
-fmax361600 fma 1 0 0E-19 -> 0E-19
-fmax361601 fma 1 -0 0E-19 -> 0E-19
-fmax361602 fma 1 0 -0E-19 -> 0E-19
-fmax361603 fma 1 -0 -0E-19 -> -0E-19
-fmax361604 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361605 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361606 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361607 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361611 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361612 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361613 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361614 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361615 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361616 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361617 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361618 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-fmax361620 fma 1 0 0E-19 -> 0E-19
-fmax361621 fma 1 -0 0E-19 -> -0E-19 -- *
-fmax361622 fma 1 0 -0E-19 -> -0E-19 -- *
-fmax361623 fma 1 -0 -0E-19 -> -0E-19
-fmax361624 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361625 fma 1 -0E-400 0E-19 -> -0E-398 Clamped -- *
-fmax361626 fma 1 0E-400 -0E-19 -> -0E-398 Clamped -- *
-fmax361627 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361631 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361632 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361633 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-fmax361634 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
--- some exact zeros from non-zeros
-fmax361635 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361636 fma 1 -1E-401 1E-401 -> -0E-398 Clamped -- *
-fmax361637 fma 1 1E-401 -1E-401 -> -0E-398 Clamped -- *
-fmax361638 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
-
--- Examples from SQL proposal (Krishna Kulkarni)
-fmax361701 fma 1 130E-2 120E-2 -> 2.50
-fmax361702 fma 1 130E-2 12E-1 -> 2.50
-fmax361703 fma 1 130E-2 1E0 -> 2.30
-fmax361704 fma 1 1E2 1E4 -> 1.01E+4
-fmax361705 subtract 130E-2 120E-2 -> 0.10
-fmax361706 subtract 130E-2 12E-1 -> 0.10
-fmax361707 subtract 130E-2 1E0 -> 0.30
-fmax361708 subtract 1E2 1E4 -> -9.9E+3
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-fmax362001 fma 1 1234567890123456 1 -> 1234567890123457
-fmax362002 fma 1 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
-fmax362003 fma 1 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
-fmax362004 fma 1 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
-fmax362005 fma 1 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
-fmax362006 fma 1 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
-fmax362007 fma 1 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
-fmax362008 fma 1 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
-fmax362009 fma 1 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
-fmax362010 fma 1 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
-fmax362011 fma 1 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
-fmax362012 fma 1 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
-fmax362013 fma 1 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
-fmax362014 fma 1 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
-fmax362015 fma 1 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
-fmax362016 fma 1 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
-fmax362017 fma 1 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
-fmax362018 fma 1 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
-fmax362019 fma 1 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
-fmax362020 fma 1 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
-fmax362021 fma 1 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
-
--- widening second argument at gap
-fmax362030 fma 1 12345678 1 -> 12345679
-fmax362031 fma 1 12345678 0.1 -> 12345678.1
-fmax362032 fma 1 12345678 0.12 -> 12345678.12
-fmax362033 fma 1 12345678 0.123 -> 12345678.123
-fmax362034 fma 1 12345678 0.1234 -> 12345678.1234
-fmax362035 fma 1 12345678 0.12345 -> 12345678.12345
-fmax362036 fma 1 12345678 0.123456 -> 12345678.123456
-fmax362037 fma 1 12345678 0.1234567 -> 12345678.1234567
-fmax362038 fma 1 12345678 0.12345678 -> 12345678.12345678
-fmax362039 fma 1 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
-fmax362040 fma 1 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
-fmax362041 fma 1 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
-fmax362042 fma 1 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
-fmax362043 fma 1 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
-fmax362044 fma 1 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
-fmax362045 fma 1 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
-fmax362046 fma 1 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
-fmax362047 fma 1 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
-fmax362048 fma 1 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
-fmax362049 fma 1 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-fmax362050 fma 1 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
-fmax362051 fma 1 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
-fmax362052 fma 1 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
-fmax362053 fma 1 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
-fmax362054 fma 1 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
-fmax362055 fma 1 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
-fmax362056 fma 1 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
-fmax362057 fma 1 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
-fmax362060 fma 1 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
-fmax362061 fma 1 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
-fmax362062 fma 1 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
-fmax362063 fma 1 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
-fmax362064 fma 1 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
-fmax362065 fma 1 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
-fmax362066 fma 1 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
-fmax362067 fma 1 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-fmax362070 fma 1 12345678 1E-8 -> 12345678.00000001
-fmax362071 fma 1 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
-fmax362072 fma 1 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
-fmax362073 fma 1 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
-fmax362074 fma 1 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
-fmax362075 fma 1 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
-fmax362076 fma 1 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
-fmax362077 fma 1 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
-fmax362078 fma 1 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
-fmax362079 fma 1 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
-fmax362080 fma 1 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
-fmax362081 fma 1 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
-fmax362082 fma 1 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
-fmax362083 fma 1 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
-fmax362084 fma 1 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
-fmax362085 fma 1 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
-fmax362086 fma 1 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
-fmax362087 fma 1 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
-fmax362088 fma 1 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
-fmax362089 fma 1 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
-
--- payload decapitate x3
-precision: 5
-fmax363000 fma 1 1 sNaN1234567890 -> NaN67890 Invalid_operation
-fmax363001 fma 1 -sNaN1234512345 1 -> -NaN12345 Invalid_operation
-fmax363002 fma sNaN1234554321 1 1 -> NaN54321 Invalid_operation
-
--- Null tests
-fmax39990 fma 1 10 # -> NaN Invalid_operation
-fmax39991 fma 1 # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- fma.decTest -- decimal fused multiply add --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- These tests comprese three parts:
+-- 1. Sanity checks and other three-operand tests (especially those
+-- where the fused operation makes a difference)
+-- 2. Multiply tests (third operand is neutral zero [0E+emax])
+-- 3. Addition tests (first operand is 1)
+-- The multiply and addition tests are extensive because FMA may have
+-- its own dedicated multiplication or addition routine(s), and they
+-- also inherently check the left-to-right properties.
+
+-- Sanity checks
+fmax0001 fma 1 1 1 -> 2
+fmax0002 fma 1 1 2 -> 3
+fmax0003 fma 2 2 3 -> 7
+fmax0004 fma 9 9 9 -> 90
+fmax0005 fma -1 1 1 -> 0
+fmax0006 fma -1 1 2 -> 1
+fmax0007 fma -2 2 3 -> -1
+fmax0008 fma -9 9 9 -> -72
+fmax0011 fma 1 -1 1 -> 0
+fmax0012 fma 1 -1 2 -> 1
+fmax0013 fma 2 -2 3 -> -1
+fmax0014 fma 9 -9 9 -> -72
+fmax0015 fma 1 1 -1 -> 0
+fmax0016 fma 1 1 -2 -> -1
+fmax0017 fma 2 2 -3 -> 1
+fmax0018 fma 9 9 -9 -> 72
+fmax0019 fma 3 5 7 -> 22
+fmax0029 fma 3 -5 7 -> -8
+
+-- non-integer exacts
+fma0100 fma 25.2 63.6 -438 -> 1164.72
+fma0101 fma 0.301 0.380 334 -> 334.114380
+fma0102 fma 49.2 -4.8 23.3 -> -212.86
+fma0103 fma 4.22 0.079 -94.6 -> -94.26662
+fma0104 fma 903 0.797 0.887 -> 720.578
+fma0105 fma 6.13 -161 65.9 -> -921.03
+fma0106 fma 28.2 727 5.45 -> 20506.85
+fma0107 fma 4 605 688 -> 3108
+fma0108 fma 93.3 0.19 0.226 -> 17.953
+fma0109 fma 0.169 -341 5.61 -> -52.019
+fma0110 fma -72.2 30 -51.2 -> -2217.2
+fma0111 fma -0.409 13 20.4 -> 15.083
+fma0112 fma 317 77.0 19.0 -> 24428.0
+fma0113 fma 47 6.58 1.62 -> 310.88
+fma0114 fma 1.36 0.984 0.493 -> 1.83124
+fma0115 fma 72.7 274 1.56 -> 19921.36
+fma0116 fma 335 847 83 -> 283828
+fma0117 fma 666 0.247 25.4 -> 189.902
+fma0118 fma -3.87 3.06 78.0 -> 66.1578
+fma0119 fma 0.742 192 35.6 -> 178.064
+fma0120 fma -91.6 5.29 0.153 -> -484.411
+
+-- cases where result is different from separate multiply + add; each
+-- is preceded by the result of unfused multiply and add
+-- [this is about 20% of all similar cases in general]
+-- 888565290 1557.96930 -86087.7578 -> 1.38435735E+12
+fma0201 fma 888565290 1557.96930 -86087.7578 -> 1.38435736E+12 Inexact Rounded
+-- -85519342.9 735155419 42010431 -> -6.28700084E+16
+fma0205 fma -85519342.9 735155419 42010431 -> -6.28700083E+16 Inexact Rounded
+-- -98025.5 -294603.472 10414348.2 -> 2.88890669E+10
+fma0208 fma -98025.5 -294603.472 10414348.2 -> 2.88890670E+10 Inexact Rounded
+-- 5967627.39 83526540.6 498494.810 -> 4.98455271E+14
+fma0211 fma 5967627.39 83526540.6 498494.810 -> 4.98455272E+14 Inexact Rounded
+-- 3456.9433 874.39518 197866.615 -> 3220601.18
+fma0216 fma 3456.9433 874.39518 197866.615 -> 3220601.17 Inexact Rounded
+-- 62769.8287 2096.98927 48.420317 -> 131627705
+fma0218 fma 62769.8287 2096.98927 48.420317 -> 131627706 Inexact Rounded
+-- -68.81500 59961113.9 -8988862 -> -4.13521291E+9
+fma0219 fma -68.81500 59961113.9 -8988862 -> -4.13521292E+9 Inexact Rounded
+-- 2126341.02 63491.5152 302427455 -> 1.35307040E+11
+fma0226 fma 2126341.02 63491.5152 302427455 -> 1.35307041E+11 Inexact Rounded
+
+
+-- Infinite combinations
+fmax0800 fma Inf Inf Inf -> Infinity
+fmax0801 fma Inf Inf -Inf -> NaN Invalid_operation
+fmax0802 fma Inf -Inf Inf -> NaN Invalid_operation
+fmax0803 fma Inf -Inf -Inf -> -Infinity
+fmax0804 fma -Inf Inf Inf -> NaN Invalid_operation
+fmax0805 fma -Inf Inf -Inf -> -Infinity
+fmax0806 fma -Inf -Inf Inf -> Infinity
+fmax0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
+fmax0808 fma -Inf 0 1 -> NaN Invalid_operation
+fmax0809 fma -Inf 0 NaN -> NaN Invalid_operation
+
+-- Triple NaN propagation
+fmax0900 fma NaN2 NaN3 NaN5 -> NaN2
+fmax0901 fma 0 NaN3 NaN5 -> NaN3
+fmax0902 fma 0 0 NaN5 -> NaN5
+-- first sNaN wins (consider qNaN from earlier sNaN being
+-- overridden by an sNaN in third operand)
+fmax0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+fmax0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
+fmax0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
+fmax0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+fmax0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
+fmax0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
+
+-- MULTIPLICATION TESTS ------------------------------------------------
+-- sanity checks (as base, above)
+fmax2000 fma 2 2 0E+999999 -> 4
+fmax2001 fma 2 3 0E+999999 -> 6
+fmax2002 fma 5 1 0E+999999 -> 5
+fmax2003 fma 5 2 0E+999999 -> 10
+fmax2004 fma 1.20 2 0E+999999 -> 2.40
+fmax2005 fma 1.20 0 0E+999999 -> 0.00
+fmax2006 fma 1.20 -2 0E+999999 -> -2.40
+fmax2007 fma -1.20 2 0E+999999 -> -2.40
+fmax2008 fma -1.20 0 0E+999999 -> 0.00
+fmax2009 fma -1.20 -2 0E+999999 -> 2.40
+fmax2010 fma 5.09 7.1 0E+999999 -> 36.139
+fmax2011 fma 2.5 4 0E+999999 -> 10.0
+fmax2012 fma 2.50 4 0E+999999 -> 10.00
+fmax2013 fma 1.23456789 1.00000000 0E+999999 -> 1.23456789 Rounded
+fmax2014 fma 9.999999999 9.999999999 0E+999999 -> 100.000000 Inexact Rounded
+fmax2015 fma 2.50 4 0E+999999 -> 10.00
+precision: 6
+fmax2016 fma 2.50 4 0E+999999 -> 10.00
+fmax2017 fma 9.999999 9.999999 0E+999999 -> 100.000 Inexact Rounded
+fmax2018 fma 9.999999 -9.999999 0E+999999 -> -100.000 Inexact Rounded
+fmax2019 fma -9.999999 9.999999 0E+999999 -> -100.000 Inexact Rounded
+fmax2020 fma -9.999999 -9.999999 0E+999999 -> 100.000 Inexact Rounded
+
+-- 1999.12.21: next one is a edge case if intermediate longs are used
+precision: 15
+fmax2059 fma 999999999999 9765625 0E+999999 -> 9.76562499999023E+18 Inexact Rounded
+precision: 30
+fmax2160 fma 999999999999 9765625 0E+999999 -> 9765624999990234375
+precision: 9
+-----
+
+-- zeros, etc.
+fmax2021 fma 0 0 0E+999999 -> 0
+fmax2022 fma 0 -0 0E+999999 -> 0
+fmax2023 fma -0 0 0E+999999 -> 0
+fmax2024 fma -0 -0 0E+999999 -> 0
+fmax2025 fma -0.0 -0.0 0E+999999 -> 0.00
+fmax2026 fma -0.0 -0.0 0E+999999 -> 0.00
+fmax2027 fma -0.0 -0.0 0E+999999 -> 0.00
+fmax2028 fma -0.0 -0.0 0E+999999 -> 0.00
+fmax2030 fma 5.00 1E-3 0E+999999 -> 0.00500
+fmax2031 fma 00.00 0.000 0E+999999 -> 0.00000
+fmax2032 fma 00.00 0E-3 0E+999999 -> 0.00000 -- rhs is 0
+fmax2033 fma 0E-3 00.00 0E+999999 -> 0.00000 -- lhs is 0
+fmax2034 fma -5.00 1E-3 0E+999999 -> -0.00500
+fmax2035 fma -00.00 0.000 0E+999999 -> 0.00000
+fmax2036 fma -00.00 0E-3 0E+999999 -> 0.00000 -- rhs is 0
+fmax2037 fma -0E-3 00.00 0E+999999 -> 0.00000 -- lhs is 0
+fmax2038 fma 5.00 -1E-3 0E+999999 -> -0.00500
+fmax2039 fma 00.00 -0.000 0E+999999 -> 0.00000
+fmax2040 fma 00.00 -0E-3 0E+999999 -> 0.00000 -- rhs is 0
+fmax2041 fma 0E-3 -00.00 0E+999999 -> 0.00000 -- lhs is 0
+fmax2042 fma -5.00 -1E-3 0E+999999 -> 0.00500
+fmax2043 fma -00.00 -0.000 0E+999999 -> 0.00000
+fmax2044 fma -00.00 -0E-3 0E+999999 -> 0.00000 -- rhs is 0
+fmax2045 fma -0E-3 -00.00 0E+999999 -> 0.00000 -- lhs is 0
+
+-- examples from decarith multiply
+fmax2050 fma 1.20 3 0E+999999 -> 3.60
+fmax2051 fma 7 3 0E+999999 -> 21
+fmax2052 fma 0.9 0.8 0E+999999 -> 0.72
+fmax2053 fma 0.9 -0 0E+999999 -> 0.0
+fmax2054 fma 654321 654321 0E+999999 -> 4.28135971E+11 Inexact Rounded
+
+fmax2060 fma 123.45 1e7 0E+999999 -> 1.2345E+9
+fmax2061 fma 123.45 1e8 0E+999999 -> 1.2345E+10
+fmax2062 fma 123.45 1e+9 0E+999999 -> 1.2345E+11
+fmax2063 fma 123.45 1e10 0E+999999 -> 1.2345E+12
+fmax2064 fma 123.45 1e11 0E+999999 -> 1.2345E+13
+fmax2065 fma 123.45 1e12 0E+999999 -> 1.2345E+14
+fmax2066 fma 123.45 1e13 0E+999999 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+precision: 9
+fmax2080 fma 0.1 123456789 0E+999999 -> 12345678.9
+fmax2081 fma 0.1 1234567891 0E+999999 -> 123456789 Inexact Rounded
+fmax2082 fma 0.1 12345678912 0E+999999 -> 1.23456789E+9 Inexact Rounded
+fmax2083 fma 0.1 12345678912345 0E+999999 -> 1.23456789E+12 Inexact Rounded
+fmax2084 fma 0.1 123456789 0E+999999 -> 12345678.9
+precision: 8
+fmax2085 fma 0.1 12345678912 0E+999999 -> 1.2345679E+9 Inexact Rounded
+fmax2086 fma 0.1 12345678912345 0E+999999 -> 1.2345679E+12 Inexact Rounded
+precision: 7
+fmax2087 fma 0.1 12345678912 0E+999999 -> 1.234568E+9 Inexact Rounded
+fmax2088 fma 0.1 12345678912345 0E+999999 -> 1.234568E+12 Inexact Rounded
+
+precision: 9
+fmax2090 fma 123456789 0.1 0E+999999 -> 12345678.9
+fmax2091 fma 1234567891 0.1 0E+999999 -> 123456789 Inexact Rounded
+fmax2092 fma 12345678912 0.1 0E+999999 -> 1.23456789E+9 Inexact Rounded
+fmax2093 fma 12345678912345 0.1 0E+999999 -> 1.23456789E+12 Inexact Rounded
+fmax2094 fma 123456789 0.1 0E+999999 -> 12345678.9
+precision: 8
+fmax2095 fma 12345678912 0.1 0E+999999 -> 1.2345679E+9 Inexact Rounded
+fmax2096 fma 12345678912345 0.1 0E+999999 -> 1.2345679E+12 Inexact Rounded
+precision: 7
+fmax2097 fma 12345678912 0.1 0E+999999 -> 1.234568E+9 Inexact Rounded
+fmax2098 fma 12345678912345 0.1 0E+999999 -> 1.234568E+12 Inexact Rounded
+
+-- test some more edge cases and carries
+maxexponent: 9999
+minexponent: -9999
+precision: 33
+fmax2101 fma 9 9 0E+999999 -> 81
+fmax2102 fma 9 90 0E+999999 -> 810
+fmax2103 fma 9 900 0E+999999 -> 8100
+fmax2104 fma 9 9000 0E+999999 -> 81000
+fmax2105 fma 9 90000 0E+999999 -> 810000
+fmax2106 fma 9 900000 0E+999999 -> 8100000
+fmax2107 fma 9 9000000 0E+999999 -> 81000000
+fmax2108 fma 9 90000000 0E+999999 -> 810000000
+fmax2109 fma 9 900000000 0E+999999 -> 8100000000
+fmax2110 fma 9 9000000000 0E+999999 -> 81000000000
+fmax2111 fma 9 90000000000 0E+999999 -> 810000000000
+fmax2112 fma 9 900000000000 0E+999999 -> 8100000000000
+fmax2113 fma 9 9000000000000 0E+999999 -> 81000000000000
+fmax2114 fma 9 90000000000000 0E+999999 -> 810000000000000
+fmax2115 fma 9 900000000000000 0E+999999 -> 8100000000000000
+fmax2116 fma 9 9000000000000000 0E+999999 -> 81000000000000000
+fmax2117 fma 9 90000000000000000 0E+999999 -> 810000000000000000
+fmax2118 fma 9 900000000000000000 0E+999999 -> 8100000000000000000
+fmax2119 fma 9 9000000000000000000 0E+999999 -> 81000000000000000000
+fmax2120 fma 9 90000000000000000000 0E+999999 -> 810000000000000000000
+fmax2121 fma 9 900000000000000000000 0E+999999 -> 8100000000000000000000
+fmax2122 fma 9 9000000000000000000000 0E+999999 -> 81000000000000000000000
+fmax2123 fma 9 90000000000000000000000 0E+999999 -> 810000000000000000000000
+-- test some more edge cases without carries
+fmax2131 fma 3 3 0E+999999 -> 9
+fmax2132 fma 3 30 0E+999999 -> 90
+fmax2133 fma 3 300 0E+999999 -> 900
+fmax2134 fma 3 3000 0E+999999 -> 9000
+fmax2135 fma 3 30000 0E+999999 -> 90000
+fmax2136 fma 3 300000 0E+999999 -> 900000
+fmax2137 fma 3 3000000 0E+999999 -> 9000000
+fmax2138 fma 3 30000000 0E+999999 -> 90000000
+fmax2139 fma 3 300000000 0E+999999 -> 900000000
+fmax2140 fma 3 3000000000 0E+999999 -> 9000000000
+fmax2141 fma 3 30000000000 0E+999999 -> 90000000000
+fmax2142 fma 3 300000000000 0E+999999 -> 900000000000
+fmax2143 fma 3 3000000000000 0E+999999 -> 9000000000000
+fmax2144 fma 3 30000000000000 0E+999999 -> 90000000000000
+fmax2145 fma 3 300000000000000 0E+999999 -> 900000000000000
+fmax2146 fma 3 3000000000000000 0E+999999 -> 9000000000000000
+fmax2147 fma 3 30000000000000000 0E+999999 -> 90000000000000000
+fmax2148 fma 3 300000000000000000 0E+999999 -> 900000000000000000
+fmax2149 fma 3 3000000000000000000 0E+999999 -> 9000000000000000000
+fmax2150 fma 3 30000000000000000000 0E+999999 -> 90000000000000000000
+fmax2151 fma 3 300000000000000000000 0E+999999 -> 900000000000000000000
+fmax2152 fma 3 3000000000000000000000 0E+999999 -> 9000000000000000000000
+fmax2153 fma 3 30000000000000000000000 0E+999999 -> 90000000000000000000000
+
+maxexponent: 999999
+minexponent: -999999
+precision: 9
+-- test some cases that are close to exponent overflow/underflow
+fmax2170 fma 1 9e999999 0E+999999 -> 9E+999999
+fmax2171 fma 1 9.9e999999 0E+999999 -> 9.9E+999999
+fmax2172 fma 1 9.99e999999 0E+999999 -> 9.99E+999999
+fmax2173 fma 9e999999 1 0E+999999 -> 9E+999999
+fmax2174 fma 9.9e999999 1 0E+999999 -> 9.9E+999999
+fmax2176 fma 9.99e999999 1 0E+999999 -> 9.99E+999999
+fmax2177 fma 1 9.99999e999999 0E+999999 -> 9.99999E+999999
+fmax2178 fma 9.99999e999999 1 0E+999999 -> 9.99999E+999999
+
+fmax2180 fma 0.1 9e-999998 0E+999999 -> 9E-999999
+fmax2181 fma 0.1 99e-999998 0E+999999 -> 9.9E-999998
+fmax2182 fma 0.1 999e-999998 0E+999999 -> 9.99E-999997
+
+fmax2183 fma 0.1 9e-999998 0E+999999 -> 9E-999999
+fmax2184 fma 0.1 99e-999998 0E+999999 -> 9.9E-999998
+fmax2185 fma 0.1 999e-999998 0E+999999 -> 9.99E-999997
+fmax2186 fma 0.1 999e-999997 0E+999999 -> 9.99E-999996
+fmax2187 fma 0.1 9999e-999997 0E+999999 -> 9.999E-999995
+fmax2188 fma 0.1 99999e-999997 0E+999999 -> 9.9999E-999994
+
+fmax2190 fma 1 9e-999998 0E+999999 -> 9E-999998
+fmax2191 fma 1 99e-999998 0E+999999 -> 9.9E-999997
+fmax2192 fma 1 999e-999998 0E+999999 -> 9.99E-999996
+fmax2193 fma 9e-999998 1 0E+999999 -> 9E-999998
+fmax2194 fma 99e-999998 1 0E+999999 -> 9.9E-999997
+fmax2195 fma 999e-999998 1 0E+999999 -> 9.99E-999996
+
+-- long operand triangle
+precision: 33
+fmax2246 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916511992830 Inexact Rounded
+precision: 32
+fmax2247 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651199283 Inexact Rounded
+precision: 31
+fmax2248 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165119928 Inexact Rounded
+precision: 30
+fmax2249 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916511993 Inexact Rounded
+precision: 29
+fmax2250 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651199 Inexact Rounded
+precision: 28
+fmax2251 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165120 Inexact Rounded
+precision: 27
+fmax2252 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916512 Inexact Rounded
+precision: 26
+fmax2253 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651 Inexact Rounded
+precision: 25
+fmax2254 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165 Inexact Rounded
+precision: 24
+fmax2255 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671917 Inexact Rounded
+precision: 23
+fmax2256 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967192 Inexact Rounded
+precision: 22
+fmax2257 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719 Inexact Rounded
+precision: 21
+fmax2258 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369672 Inexact Rounded
+precision: 20
+fmax2259 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967 Inexact Rounded
+precision: 19
+fmax2260 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933697 Inexact Rounded
+precision: 18
+fmax2261 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193370 Inexact Rounded
+precision: 17
+fmax2262 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119337 Inexact Rounded
+precision: 16
+fmax2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011934 Inexact Rounded
+precision: 15
+fmax2264 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193 Inexact Rounded
+precision: 14
+fmax2265 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119 Inexact Rounded
+precision: 13
+fmax2266 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908012 Inexact Rounded
+precision: 12
+fmax2267 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801 Inexact Rounded
+precision: 11
+fmax2268 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080 Inexact Rounded
+precision: 10
+fmax2269 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908 Inexact Rounded
+precision: 9
+fmax2270 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.291 Inexact Rounded
+precision: 8
+fmax2271 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29 Inexact Rounded
+precision: 7
+fmax2272 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.3 Inexact Rounded
+precision: 6
+fmax2273 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433 Inexact Rounded
+precision: 5
+fmax2274 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.4543E+5 Inexact Rounded
+precision: 4
+fmax2275 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.454E+5 Inexact Rounded
+precision: 3
+fmax2276 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.45E+5 Inexact Rounded
+precision: 2
+fmax2277 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.5E+5 Inexact Rounded
+precision: 1
+fmax2278 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1E+5 Inexact Rounded
+
+-- test some edge cases with exact rounding
+maxexponent: 9999
+minexponent: -9999
+precision: 9
+fmax2301 fma 9 9 0E+999999 -> 81
+fmax2302 fma 9 90 0E+999999 -> 810
+fmax2303 fma 9 900 0E+999999 -> 8100
+fmax2304 fma 9 9000 0E+999999 -> 81000
+fmax2305 fma 9 90000 0E+999999 -> 810000
+fmax2306 fma 9 900000 0E+999999 -> 8100000
+fmax2307 fma 9 9000000 0E+999999 -> 81000000
+fmax2308 fma 9 90000000 0E+999999 -> 810000000
+fmax2309 fma 9 900000000 0E+999999 -> 8.10000000E+9 Rounded
+fmax2310 fma 9 9000000000 0E+999999 -> 8.10000000E+10 Rounded
+fmax2311 fma 9 90000000000 0E+999999 -> 8.10000000E+11 Rounded
+fmax2312 fma 9 900000000000 0E+999999 -> 8.10000000E+12 Rounded
+fmax2313 fma 9 9000000000000 0E+999999 -> 8.10000000E+13 Rounded
+fmax2314 fma 9 90000000000000 0E+999999 -> 8.10000000E+14 Rounded
+fmax2315 fma 9 900000000000000 0E+999999 -> 8.10000000E+15 Rounded
+fmax2316 fma 9 9000000000000000 0E+999999 -> 8.10000000E+16 Rounded
+fmax2317 fma 9 90000000000000000 0E+999999 -> 8.10000000E+17 Rounded
+fmax2318 fma 9 900000000000000000 0E+999999 -> 8.10000000E+18 Rounded
+fmax2319 fma 9 9000000000000000000 0E+999999 -> 8.10000000E+19 Rounded
+fmax2320 fma 9 90000000000000000000 0E+999999 -> 8.10000000E+20 Rounded
+fmax2321 fma 9 900000000000000000000 0E+999999 -> 8.10000000E+21 Rounded
+fmax2322 fma 9 9000000000000000000000 0E+999999 -> 8.10000000E+22 Rounded
+fmax2323 fma 9 90000000000000000000000 0E+999999 -> 8.10000000E+23 Rounded
+
+-- fastpath breakers
+precision: 29
+fmax2330 fma 1.491824697641270317824852952837224 1.105170918075647624811707826490246514675628614562883537345747603 0E+999999 -> 1.6487212707001281468486507878 Inexact Rounded
+precision: 55
+fmax2331 fma 0.8958341352965282506768545828765117803873717284891040428 0.8958341352965282506768545828765117803873717284891040428 0E+999999 -> 0.8025187979624784829842553829934069955890983696752228299 Inexact Rounded
+
+
+-- tryzeros cases
+precision: 7
+rounding: half_up
+maxExponent: 92
+minexponent: -92
+fmax2504 fma 0E-60 1000E-60 0E+999999 -> 0E-98 Clamped
+fmax2505 fma 100E+60 0E+60 0E+999999 -> 0E+92 Clamped
+
+-- mixed with zeros
+maxexponent: 999999
+minexponent: -999999
+precision: 9
+fmax2541 fma 0 -1 0E+999999 -> 0
+fmax2542 fma -0 -1 0E+999999 -> 0
+fmax2543 fma 0 1 0E+999999 -> 0
+fmax2544 fma -0 1 0E+999999 -> 0
+fmax2545 fma -1 0 0E+999999 -> 0
+fmax2546 fma -1 -0 0E+999999 -> 0
+fmax2547 fma 1 0 0E+999999 -> 0
+fmax2548 fma 1 -0 0E+999999 -> 0
+
+fmax2551 fma 0.0 -1 0E+999999 -> 0.0
+fmax2552 fma -0.0 -1 0E+999999 -> 0.0
+fmax2553 fma 0.0 1 0E+999999 -> 0.0
+fmax2554 fma -0.0 1 0E+999999 -> 0.0
+fmax2555 fma -1.0 0 0E+999999 -> 0.0
+fmax2556 fma -1.0 -0 0E+999999 -> 0.0
+fmax2557 fma 1.0 0 0E+999999 -> 0.0
+fmax2558 fma 1.0 -0 0E+999999 -> 0.0
+
+fmax2561 fma 0 -1.0 0E+999999 -> 0.0
+fmax2562 fma -0 -1.0 0E+999999 -> 0.0
+fmax2563 fma 0 1.0 0E+999999 -> 0.0
+fmax2564 fma -0 1.0 0E+999999 -> 0.0
+fmax2565 fma -1 0.0 0E+999999 -> 0.0
+fmax2566 fma -1 -0.0 0E+999999 -> 0.0
+fmax2567 fma 1 0.0 0E+999999 -> 0.0
+fmax2568 fma 1 -0.0 0E+999999 -> 0.0
+
+fmax2571 fma 0.0 -1.0 0E+999999 -> 0.00
+fmax2572 fma -0.0 -1.0 0E+999999 -> 0.00
+fmax2573 fma 0.0 1.0 0E+999999 -> 0.00
+fmax2574 fma -0.0 1.0 0E+999999 -> 0.00
+fmax2575 fma -1.0 0.0 0E+999999 -> 0.00
+fmax2576 fma -1.0 -0.0 0E+999999 -> 0.00
+fmax2577 fma 1.0 0.0 0E+999999 -> 0.00
+fmax2578 fma 1.0 -0.0 0E+999999 -> 0.00
+
+
+-- Specials
+fmax2580 fma Inf -Inf 0E+999999 -> -Infinity
+fmax2581 fma Inf -1000 0E+999999 -> -Infinity
+fmax2582 fma Inf -1 0E+999999 -> -Infinity
+fmax2583 fma Inf -0 0E+999999 -> NaN Invalid_operation
+fmax2584 fma Inf 0 0E+999999 -> NaN Invalid_operation
+fmax2585 fma Inf 1 0E+999999 -> Infinity
+fmax2586 fma Inf 1000 0E+999999 -> Infinity
+fmax2587 fma Inf Inf 0E+999999 -> Infinity
+fmax2588 fma -1000 Inf 0E+999999 -> -Infinity
+fmax2589 fma -Inf Inf 0E+999999 -> -Infinity
+fmax2590 fma -1 Inf 0E+999999 -> -Infinity
+fmax2591 fma -0 Inf 0E+999999 -> NaN Invalid_operation
+fmax2592 fma 0 Inf 0E+999999 -> NaN Invalid_operation
+fmax2593 fma 1 Inf 0E+999999 -> Infinity
+fmax2594 fma 1000 Inf 0E+999999 -> Infinity
+fmax2595 fma Inf Inf 0E+999999 -> Infinity
+
+fmax2600 fma -Inf -Inf 0E+999999 -> Infinity
+fmax2601 fma -Inf -1000 0E+999999 -> Infinity
+fmax2602 fma -Inf -1 0E+999999 -> Infinity
+fmax2603 fma -Inf -0 0E+999999 -> NaN Invalid_operation
+fmax2604 fma -Inf 0 0E+999999 -> NaN Invalid_operation
+fmax2605 fma -Inf 1 0E+999999 -> -Infinity
+fmax2606 fma -Inf 1000 0E+999999 -> -Infinity
+fmax2607 fma -Inf Inf 0E+999999 -> -Infinity
+fmax2608 fma -1000 Inf 0E+999999 -> -Infinity
+fmax2609 fma -Inf -Inf 0E+999999 -> Infinity
+fmax2610 fma -1 -Inf 0E+999999 -> Infinity
+fmax2611 fma -0 -Inf 0E+999999 -> NaN Invalid_operation
+fmax2612 fma 0 -Inf 0E+999999 -> NaN Invalid_operation
+fmax2613 fma 1 -Inf 0E+999999 -> -Infinity
+fmax2614 fma 1000 -Inf 0E+999999 -> -Infinity
+fmax2615 fma Inf -Inf 0E+999999 -> -Infinity
+
+fmax2621 fma NaN -Inf 0E+999999 -> NaN
+fmax2622 fma NaN -1000 0E+999999 -> NaN
+fmax2623 fma NaN -1 0E+999999 -> NaN
+fmax2624 fma NaN -0 0E+999999 -> NaN
+fmax2625 fma NaN 0 0E+999999 -> NaN
+fmax2626 fma NaN 1 0E+999999 -> NaN
+fmax2627 fma NaN 1000 0E+999999 -> NaN
+fmax2628 fma NaN Inf 0E+999999 -> NaN
+fmax2629 fma NaN NaN 0E+999999 -> NaN
+fmax2630 fma -Inf NaN 0E+999999 -> NaN
+fmax2631 fma -1000 NaN 0E+999999 -> NaN
+fmax2632 fma -1 NaN 0E+999999 -> NaN
+fmax2633 fma -0 NaN 0E+999999 -> NaN
+fmax2634 fma 0 NaN 0E+999999 -> NaN
+fmax2635 fma 1 NaN 0E+999999 -> NaN
+fmax2636 fma 1000 NaN 0E+999999 -> NaN
+fmax2637 fma Inf NaN 0E+999999 -> NaN
+
+fmax2641 fma sNaN -Inf 0E+999999 -> NaN Invalid_operation
+fmax2642 fma sNaN -1000 0E+999999 -> NaN Invalid_operation
+fmax2643 fma sNaN -1 0E+999999 -> NaN Invalid_operation
+fmax2644 fma sNaN -0 0E+999999 -> NaN Invalid_operation
+fmax2645 fma sNaN 0 0E+999999 -> NaN Invalid_operation
+fmax2646 fma sNaN 1 0E+999999 -> NaN Invalid_operation
+fmax2647 fma sNaN 1000 0E+999999 -> NaN Invalid_operation
+fmax2648 fma sNaN NaN 0E+999999 -> NaN Invalid_operation
+fmax2649 fma sNaN sNaN 0E+999999 -> NaN Invalid_operation
+fmax2650 fma NaN sNaN 0E+999999 -> NaN Invalid_operation
+fmax2651 fma -Inf sNaN 0E+999999 -> NaN Invalid_operation
+fmax2652 fma -1000 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2653 fma -1 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2654 fma -0 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2655 fma 0 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2656 fma 1 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2657 fma 1000 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2658 fma Inf sNaN 0E+999999 -> NaN Invalid_operation
+fmax2659 fma NaN sNaN 0E+999999 -> NaN Invalid_operation
+
+-- propagating NaNs
+fmax2661 fma NaN9 -Inf 0E+999999 -> NaN9
+fmax2662 fma NaN8 999 0E+999999 -> NaN8
+fmax2663 fma NaN71 Inf 0E+999999 -> NaN71
+fmax2664 fma NaN6 NaN5 0E+999999 -> NaN6
+fmax2665 fma -Inf NaN4 0E+999999 -> NaN4
+fmax2666 fma -999 NaN33 0E+999999 -> NaN33
+fmax2667 fma Inf NaN2 0E+999999 -> NaN2
+
+fmax2671 fma sNaN99 -Inf 0E+999999 -> NaN99 Invalid_operation
+fmax2672 fma sNaN98 -11 0E+999999 -> NaN98 Invalid_operation
+fmax2673 fma sNaN97 NaN 0E+999999 -> NaN97 Invalid_operation
+fmax2674 fma sNaN16 sNaN94 0E+999999 -> NaN16 Invalid_operation
+fmax2675 fma NaN95 sNaN93 0E+999999 -> NaN93 Invalid_operation
+fmax2676 fma -Inf sNaN92 0E+999999 -> NaN92 Invalid_operation
+fmax2677 fma 088 sNaN91 0E+999999 -> NaN91 Invalid_operation
+fmax2678 fma Inf sNaN90 0E+999999 -> NaN90 Invalid_operation
+fmax2679 fma NaN sNaN89 0E+999999 -> NaN89 Invalid_operation
+
+fmax2681 fma -NaN9 -Inf 0E+999999 -> -NaN9
+fmax2682 fma -NaN8 999 0E+999999 -> -NaN8
+fmax2683 fma -NaN71 Inf 0E+999999 -> -NaN71
+fmax2684 fma -NaN6 -NaN5 0E+999999 -> -NaN6
+fmax2685 fma -Inf -NaN4 0E+999999 -> -NaN4
+fmax2686 fma -999 -NaN33 0E+999999 -> -NaN33
+fmax2687 fma Inf -NaN2 0E+999999 -> -NaN2
+
+fmax2691 fma -sNaN99 -Inf 0E+999999 -> -NaN99 Invalid_operation
+fmax2692 fma -sNaN98 -11 0E+999999 -> -NaN98 Invalid_operation
+fmax2693 fma -sNaN97 NaN 0E+999999 -> -NaN97 Invalid_operation
+fmax2694 fma -sNaN16 -sNaN94 0E+999999 -> -NaN16 Invalid_operation
+fmax2695 fma -NaN95 -sNaN93 0E+999999 -> -NaN93 Invalid_operation
+fmax2696 fma -Inf -sNaN92 0E+999999 -> -NaN92 Invalid_operation
+fmax2697 fma 088 -sNaN91 0E+999999 -> -NaN91 Invalid_operation
+fmax2698 fma Inf -sNaN90 0E+999999 -> -NaN90 Invalid_operation
+fmax2699 fma -NaN -sNaN89 0E+999999 -> -NaN89 Invalid_operation
+
+fmax2701 fma -NaN -Inf 0E+999999 -> -NaN
+fmax2702 fma -NaN 999 0E+999999 -> -NaN
+fmax2703 fma -NaN Inf 0E+999999 -> -NaN
+fmax2704 fma -NaN -NaN 0E+999999 -> -NaN
+fmax2705 fma -Inf -NaN0 0E+999999 -> -NaN
+fmax2706 fma -999 -NaN 0E+999999 -> -NaN
+fmax2707 fma Inf -NaN 0E+999999 -> -NaN
+
+fmax2711 fma -sNaN -Inf 0E+999999 -> -NaN Invalid_operation
+fmax2712 fma -sNaN -11 0E+999999 -> -NaN Invalid_operation
+fmax2713 fma -sNaN00 NaN 0E+999999 -> -NaN Invalid_operation
+fmax2714 fma -sNaN -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2715 fma -NaN -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2716 fma -Inf -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2717 fma 088 -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2718 fma Inf -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2719 fma -NaN -sNaN 0E+999999 -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+maxexponent: 999999
+minexponent: -999999
+fmax2730 fma +1.23456789012345E-0 9E+999999 0E+999999 -> Infinity Inexact Overflow Rounded
+fmax2731 fma 9E+999999 +1.23456789012345E-0 0E+999999 -> Infinity Inexact Overflow Rounded
+fmax2732 fma +0.100 9E-999999 0E+999999 -> 9.00E-1000000 Subnormal
+fmax2733 fma 9E-999999 +0.100 0E+999999 -> 9.00E-1000000 Subnormal
+fmax2735 fma -1.23456789012345E-0 9E+999999 0E+999999 -> -Infinity Inexact Overflow Rounded
+fmax2736 fma 9E+999999 -1.23456789012345E-0 0E+999999 -> -Infinity Inexact Overflow Rounded
+fmax2737 fma -0.100 9E-999999 0E+999999 -> -9.00E-1000000 Subnormal
+fmax2738 fma 9E-999999 -0.100 0E+999999 -> -9.00E-1000000 Subnormal
+
+-- signs
+fmax2751 fma 1e+777777 1e+411111 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2752 fma 1e+777777 -1e+411111 0E+999999 -> -Infinity Overflow Inexact Rounded
+fmax2753 fma -1e+777777 1e+411111 0E+999999 -> -Infinity Overflow Inexact Rounded
+fmax2754 fma -1e+777777 -1e+411111 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2755 fma 1e-777777 1e-411111 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2756 fma 1e-777777 -1e-411111 0E+999999 -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2757 fma -1e-777777 1e-411111 0E+999999 -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2758 fma -1e-777777 -1e-411111 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+precision: 9
+fmax2760 fma 1e-600000 1e-400001 0E+999999 -> 1E-1000001 Subnormal
+fmax2761 fma 1e-600000 1e-400002 0E+999999 -> 1E-1000002 Subnormal
+fmax2762 fma 1e-600000 1e-400003 0E+999999 -> 1E-1000003 Subnormal
+fmax2763 fma 1e-600000 1e-400004 0E+999999 -> 1E-1000004 Subnormal
+fmax2764 fma 1e-600000 1e-400005 0E+999999 -> 1E-1000005 Subnormal
+fmax2765 fma 1e-600000 1e-400006 0E+999999 -> 1E-1000006 Subnormal
+fmax2766 fma 1e-600000 1e-400007 0E+999999 -> 1E-1000007 Subnormal
+fmax2767 fma 1e-600000 1e-400008 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2768 fma 1e-600000 1e-400009 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2769 fma 1e-600000 1e-400010 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+fmax2770 fma 1e+600000 1e+400001 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2771 fma 1e+600000 1e+400002 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2772 fma 1e+600000 1e+400003 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2773 fma 1e+600000 1e+400004 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2774 fma 1e+600000 1e+400005 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2775 fma 1e+600000 1e+400006 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2776 fma 1e+600000 1e+400007 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2777 fma 1e+600000 1e+400008 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2778 fma 1e+600000 1e+400009 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2779 fma 1e+600000 1e+400010 0E+999999 -> Infinity Overflow Inexact Rounded
+
+-- 'subnormal' test edge condition at higher precisions
+precision: 99
+fmax2780 fma 1e-600000 1e-400007 0E+999999 -> 1E-1000007 Subnormal
+fmax2781 fma 1e-600000 1e-400008 0E+999999 -> 1E-1000008 Subnormal
+fmax2782 fma 1e-600000 1e-400097 0E+999999 -> 1E-1000097 Subnormal
+fmax2783 fma 1e-600000 1e-400098 0E+999999 -> 0E-1000097 Underflow Subnormal Inexact Rounded Clamped
+precision: 999
+fmax2784 fma 1e-600000 1e-400997 0E+999999 -> 1E-1000997 Subnormal
+fmax2785 fma 1e-600000 1e-400998 0E+999999 -> 0E-1000997 Underflow Subnormal Inexact Rounded Clamped
+
+-- test subnormals rounding
+precision: 5
+maxExponent: 999
+minexponent: -999
+rounding: half_even
+
+fmax2801 fma 1.0000E-999 1 0E+999999 -> 1.0000E-999
+fmax2802 fma 1.000E-999 1e-1 0E+999999 -> 1.000E-1000 Subnormal
+fmax2803 fma 1.00E-999 1e-2 0E+999999 -> 1.00E-1001 Subnormal
+fmax2804 fma 1.0E-999 1e-3 0E+999999 -> 1.0E-1002 Subnormal
+fmax2805 fma 1.0E-999 1e-4 0E+999999 -> 1E-1003 Subnormal Rounded
+fmax2806 fma 1.3E-999 1e-4 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+fmax2807 fma 1.5E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2808 fma 1.7E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2809 fma 2.3E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2810 fma 2.5E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2811 fma 2.7E-999 1e-4 0E+999999 -> 3E-1003 Underflow Subnormal Inexact Rounded
+fmax2812 fma 1.49E-999 1e-4 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+fmax2813 fma 1.50E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2814 fma 1.51E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2815 fma 2.49E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2816 fma 2.50E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2817 fma 2.51E-999 1e-4 0E+999999 -> 3E-1003 Underflow Subnormal Inexact Rounded
+
+fmax2818 fma 1E-999 1e-4 0E+999999 -> 1E-1003 Subnormal
+fmax2819 fma 3E-999 1e-5 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2820 fma 5E-999 1e-5 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2821 fma 7E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+fmax2822 fma 9E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+fmax2823 fma 9.9E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+
+fmax2824 fma 1E-999 -1e-4 0E+999999 -> -1E-1003 Subnormal
+fmax2825 fma 3E-999 -1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2826 fma -5E-999 1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2827 fma 7E-999 -1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
+fmax2828 fma -9E-999 1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
+fmax2829 fma 9.9E-999 -1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
+fmax2830 fma 3.0E-999 -1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
+
+fmax2831 fma 1.0E-501 1e-501 0E+999999 -> 1.0E-1002 Subnormal
+fmax2832 fma 2.0E-501 2e-501 0E+999999 -> 4.0E-1002 Subnormal
+fmax2833 fma 4.0E-501 4e-501 0E+999999 -> 1.60E-1001 Subnormal
+fmax2834 fma 10.0E-501 10e-501 0E+999999 -> 1.000E-1000 Subnormal
+fmax2835 fma 30.0E-501 30e-501 0E+999999 -> 9.000E-1000 Subnormal
+fmax2836 fma 40.0E-501 40e-501 0E+999999 -> 1.6000E-999
+
+-- squares
+fmax2840 fma 1E-502 1e-502 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2841 fma 1E-501 1e-501 0E+999999 -> 1E-1002 Subnormal
+fmax2842 fma 2E-501 2e-501 0E+999999 -> 4E-1002 Subnormal
+fmax2843 fma 4E-501 4e-501 0E+999999 -> 1.6E-1001 Subnormal
+fmax2844 fma 10E-501 10e-501 0E+999999 -> 1.00E-1000 Subnormal
+fmax2845 fma 30E-501 30e-501 0E+999999 -> 9.00E-1000 Subnormal
+fmax2846 fma 40E-501 40e-501 0E+999999 -> 1.600E-999
+
+-- cubes
+fmax2850 fma 1E-670 1e-335 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2851 fma 1E-668 1e-334 0E+999999 -> 1E-1002 Subnormal
+fmax2852 fma 4E-668 2e-334 0E+999999 -> 8E-1002 Subnormal
+fmax2853 fma 9E-668 3e-334 0E+999999 -> 2.7E-1001 Subnormal
+fmax2854 fma 16E-668 4e-334 0E+999999 -> 6.4E-1001 Subnormal
+fmax2855 fma 25E-668 5e-334 0E+999999 -> 1.25E-1000 Subnormal
+fmax2856 fma 10E-668 100e-334 0E+999999 -> 1.000E-999
+
+-- test derived from result of 0.099 ** 999 at 15 digits with unlimited exponent
+precision: 19
+fmax2860 fma 6636851557994578716E-520 6636851557994578716E-520 0E+999999 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded
+
+-- Long operand overflow may be a different path
+precision: 3
+maxExponent: 999999
+minexponent: -999999
+fmax2870 fma 1 9.999E+999999 0E+999999 -> Infinity Inexact Overflow Rounded
+fmax2871 fma 1 -9.999E+999999 0E+999999 -> -Infinity Inexact Overflow Rounded
+fmax2872 fma 9.999E+999999 1 0E+999999 -> Infinity Inexact Overflow Rounded
+fmax2873 fma -9.999E+999999 1 0E+999999 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+precision: 5
+maxexponent: 79
+minexponent: -79
+fmax2881 fma 1.2347E-40 1.2347E-40 0E+999999 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax2882 fma 1.234E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
+fmax2883 fma 1.23E-40 1.23E-40 0E+999999 -> 1.513E-80 Inexact Rounded Subnormal Underflow
+fmax2884 fma 1.2E-40 1.2E-40 0E+999999 -> 1.44E-80 Subnormal
+fmax2885 fma 1.2E-40 1.2E-41 0E+999999 -> 1.44E-81 Subnormal
+fmax2886 fma 1.2E-40 1.2E-42 0E+999999 -> 1.4E-82 Subnormal Inexact Rounded Underflow
+fmax2887 fma 1.2E-40 1.3E-42 0E+999999 -> 1.6E-82 Subnormal Inexact Rounded Underflow
+fmax2888 fma 1.3E-40 1.3E-42 0E+999999 -> 1.7E-82 Subnormal Inexact Rounded Underflow
+fmax2889 fma 1.3E-40 1.3E-43 0E+999999 -> 2E-83 Subnormal Inexact Rounded Underflow
+fmax2890 fma 1.3E-41 1.3E-43 0E+999999 -> 0E-83 Clamped Subnormal Inexact Rounded Underflow
+
+fmax2891 fma 1.2345E-39 1.234E-40 0E+999999 -> 1.5234E-79 Inexact Rounded
+fmax2892 fma 1.23456E-39 1.234E-40 0E+999999 -> 1.5234E-79 Inexact Rounded
+fmax2893 fma 1.2345E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
+fmax2894 fma 1.23456E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
+fmax2895 fma 1.2345E-41 1.234E-40 0E+999999 -> 1.52E-81 Inexact Rounded Subnormal Underflow
+fmax2896 fma 1.23456E-41 1.234E-40 0E+999999 -> 1.52E-81 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+fmax2900 fma 0.3000000000E-191 0.3000000000E-191 0E+999999 -> 9.00000000000000E-384 Subnormal Rounded
+fmax2901 fma 0.3000000001E-191 0.3000000001E-191 0E+999999 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
+fmax2902 fma 9.999999999999999E-383 0.0999999999999 0E+999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
+fmax2903 fma 9.999999999999999E-383 0.09999999999999 0E+999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
+fmax2904 fma 9.999999999999999E-383 0.099999999999999 0E+999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
+fmax2905 fma 9.999999999999999E-383 0.0999999999999999 0E+999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
+-- prove operands are exact
+fmax2906 fma 9.999999999999999E-383 1 0E+999999 -> 9.999999999999999E-383
+fmax2907 fma 1 0.09999999999999999 0E+999999 -> 0.09999999999999999
+-- the next rounds to Nmin
+fmax2908 fma 9.999999999999999E-383 0.09999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax2909 fma 9.999999999999999E-383 0.099999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax2910 fma 9.999999999999999E-383 0.0999999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax2911 fma 9.999999999999999E-383 0.09999999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+fmax2921 fma 130E-2 120E-2 0E+999999 -> 1.5600
+fmax2922 fma 130E-2 12E-1 0E+999999 -> 1.560
+fmax2923 fma 130E-2 1E0 0E+999999 -> 1.30
+
+-- Null tests
+fmax2990 fma # 10 0E+999999 -> NaN Invalid_operation
+fmax2991 fma 10 # 0E+999999 -> NaN Invalid_operation
+
+-- ADDITION TESTS ------------------------------------------------------
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- [first group are 'quick confidence check']
+fmax3001 fma 1 1 1 -> 2
+fmax3002 fma 1 2 3 -> 5
+fmax3003 fma 1 '5.75' '3.3' -> 9.05
+fmax3004 fma 1 '5' '-3' -> 2
+fmax3005 fma 1 '-5' '-3' -> -8
+fmax3006 fma 1 '-7' '2.5' -> -4.5
+fmax3007 fma 1 '0.7' '0.3' -> 1.0
+fmax3008 fma 1 '1.25' '1.25' -> 2.50
+fmax3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
+fmax3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
+
+fmax3011 fma 1 '0.4444444444' '0.5555555555' -> '1.00000000' Inexact Rounded
+fmax3012 fma 1 '0.4444444440' '0.5555555555' -> '1.00000000' Inexact Rounded
+fmax3013 fma 1 '0.4444444444' '0.5555555550' -> '0.999999999' Inexact Rounded
+fmax3014 fma 1 '0.44444444449' '0' -> '0.444444444' Inexact Rounded
+fmax3015 fma 1 '0.444444444499' '0' -> '0.444444444' Inexact Rounded
+fmax3016 fma 1 '0.4444444444999' '0' -> '0.444444444' Inexact Rounded
+fmax3017 fma 1 '0.4444444445000' '0' -> '0.444444445' Inexact Rounded
+fmax3018 fma 1 '0.4444444445001' '0' -> '0.444444445' Inexact Rounded
+fmax3019 fma 1 '0.444444444501' '0' -> '0.444444445' Inexact Rounded
+fmax3020 fma 1 '0.44444444451' '0' -> '0.444444445' Inexact Rounded
+
+fmax3021 fma 1 0 1 -> 1
+fmax3022 fma 1 1 1 -> 2
+fmax3023 fma 1 2 1 -> 3
+fmax3024 fma 1 3 1 -> 4
+fmax3025 fma 1 4 1 -> 5
+fmax3026 fma 1 5 1 -> 6
+fmax3027 fma 1 6 1 -> 7
+fmax3028 fma 1 7 1 -> 8
+fmax3029 fma 1 8 1 -> 9
+fmax3030 fma 1 9 1 -> 10
+
+-- some carrying effects
+fmax3031 fma 1 '0.9998' '0.0000' -> '0.9998'
+fmax3032 fma 1 '0.9998' '0.0001' -> '0.9999'
+fmax3033 fma 1 '0.9998' '0.0002' -> '1.0000'
+fmax3034 fma 1 '0.9998' '0.0003' -> '1.0001'
+
+fmax3035 fma 1 '70' '10000e+9' -> '1.00000000E+13' Inexact Rounded
+fmax3036 fma 1 '700' '10000e+9' -> '1.00000000E+13' Inexact Rounded
+fmax3037 fma 1 '7000' '10000e+9' -> '1.00000000E+13' Inexact Rounded
+fmax3038 fma 1 '70000' '10000e+9' -> '1.00000001E+13' Inexact Rounded
+fmax3039 fma 1 '700000' '10000e+9' -> '1.00000007E+13' Rounded
+
+-- symmetry:
+fmax3040 fma 1 '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded
+fmax3041 fma 1 '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded
+fmax3042 fma 1 '10000e+9' '7000' -> '1.00000000E+13' Inexact Rounded
+fmax3044 fma 1 '10000e+9' '70000' -> '1.00000001E+13' Inexact Rounded
+fmax3045 fma 1 '10000e+9' '700000' -> '1.00000007E+13' Rounded
+
+-- same, higher precision
+precision: 15
+fmax3046 fma 1 '10000e+9' '7' -> '10000000000007'
+fmax3047 fma 1 '10000e+9' '70' -> '10000000000070'
+fmax3048 fma 1 '10000e+9' '700' -> '10000000000700'
+fmax3049 fma 1 '10000e+9' '7000' -> '10000000007000'
+fmax3050 fma 1 '10000e+9' '70000' -> '10000000070000'
+fmax3051 fma 1 '10000e+9' '700000' -> '10000000700000'
+fmax3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+fmax3053 fma 1 '12' '7.00' -> '19.00'
+fmax3054 fma 1 '1.3' '-1.07' -> '0.23'
+fmax3055 fma 1 '1.3' '-1.30' -> '0.00'
+fmax3056 fma 1 '1.3' '-2.07' -> '-0.77'
+fmax3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
+
+-- zero preservation
+precision: 6
+fmax3060 fma 1 '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded
+fmax3061 fma 1 1 '0.0001' -> '1.0001'
+fmax3062 fma 1 1 '0.00001' -> '1.00001'
+fmax3063 fma 1 1 '0.000001' -> '1.00000' Inexact Rounded
+fmax3064 fma 1 1 '0.0000001' -> '1.00000' Inexact Rounded
+fmax3065 fma 1 1 '0.00000001' -> '1.00000' Inexact Rounded
+
+-- some funny zeros [in case of bad signum]
+fmax3070 fma 1 1 0 -> 1
+fmax3071 fma 1 1 0. -> 1
+fmax3072 fma 1 1 .0 -> 1.0
+fmax3073 fma 1 1 0.0 -> 1.0
+fmax3074 fma 1 1 0.00 -> 1.00
+fmax3075 fma 1 0 1 -> 1
+fmax3076 fma 1 0. 1 -> 1
+fmax3077 fma 1 .0 1 -> 1.0
+fmax3078 fma 1 0.0 1 -> 1.0
+fmax3079 fma 1 0.00 1 -> 1.00
+
+precision: 9
+
+-- some carries
+fmax3080 fma 1 999999998 1 -> 999999999
+fmax3081 fma 1 999999999 1 -> 1.00000000E+9 Rounded
+fmax3082 fma 1 99999999 1 -> 100000000
+fmax3083 fma 1 9999999 1 -> 10000000
+fmax3084 fma 1 999999 1 -> 1000000
+fmax3085 fma 1 99999 1 -> 100000
+fmax3086 fma 1 9999 1 -> 10000
+fmax3087 fma 1 999 1 -> 1000
+fmax3088 fma 1 99 1 -> 100
+fmax3089 fma 1 9 1 -> 10
+
+
+-- more LHS swaps
+fmax3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
+fmax3091 fma 1 '-56267E-6' 0 -> '-0.056267'
+fmax3092 fma 1 '-56267E-5' 0 -> '-0.56267'
+fmax3093 fma 1 '-56267E-4' 0 -> '-5.6267'
+fmax3094 fma 1 '-56267E-3' 0 -> '-56.267'
+fmax3095 fma 1 '-56267E-2' 0 -> '-562.67'
+fmax3096 fma 1 '-56267E-1' 0 -> '-5626.7'
+fmax3097 fma 1 '-56267E-0' 0 -> '-56267'
+fmax3098 fma 1 '-5E-10' 0 -> '-5E-10'
+fmax3099 fma 1 '-5E-7' 0 -> '-5E-7'
+fmax3100 fma 1 '-5E-6' 0 -> '-0.000005'
+fmax3101 fma 1 '-5E-5' 0 -> '-0.00005'
+fmax3102 fma 1 '-5E-4' 0 -> '-0.0005'
+fmax3103 fma 1 '-5E-1' 0 -> '-0.5'
+fmax3104 fma 1 '-5E0' 0 -> '-5'
+fmax3105 fma 1 '-5E1' 0 -> '-50'
+fmax3106 fma 1 '-5E5' 0 -> '-500000'
+fmax3107 fma 1 '-5E8' 0 -> '-500000000'
+fmax3108 fma 1 '-5E9' 0 -> '-5.00000000E+9' Rounded
+fmax3109 fma 1 '-5E10' 0 -> '-5.00000000E+10' Rounded
+fmax3110 fma 1 '-5E11' 0 -> '-5.00000000E+11' Rounded
+fmax3111 fma 1 '-5E100' 0 -> '-5.00000000E+100' Rounded
+
+-- more RHS swaps
+fmax3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
+fmax3114 fma 1 0 '-56267E-6' -> '-0.056267'
+fmax3116 fma 1 0 '-56267E-5' -> '-0.56267'
+fmax3117 fma 1 0 '-56267E-4' -> '-5.6267'
+fmax3119 fma 1 0 '-56267E-3' -> '-56.267'
+fmax3120 fma 1 0 '-56267E-2' -> '-562.67'
+fmax3121 fma 1 0 '-56267E-1' -> '-5626.7'
+fmax3122 fma 1 0 '-56267E-0' -> '-56267'
+fmax3123 fma 1 0 '-5E-10' -> '-5E-10'
+fmax3124 fma 1 0 '-5E-7' -> '-5E-7'
+fmax3125 fma 1 0 '-5E-6' -> '-0.000005'
+fmax3126 fma 1 0 '-5E-5' -> '-0.00005'
+fmax3127 fma 1 0 '-5E-4' -> '-0.0005'
+fmax3128 fma 1 0 '-5E-1' -> '-0.5'
+fmax3129 fma 1 0 '-5E0' -> '-5'
+fmax3130 fma 1 0 '-5E1' -> '-50'
+fmax3131 fma 1 0 '-5E5' -> '-500000'
+fmax3132 fma 1 0 '-5E8' -> '-500000000'
+fmax3133 fma 1 0 '-5E9' -> '-5.00000000E+9' Rounded
+fmax3134 fma 1 0 '-5E10' -> '-5.00000000E+10' Rounded
+fmax3135 fma 1 0 '-5E11' -> '-5.00000000E+11' Rounded
+fmax3136 fma 1 0 '-5E100' -> '-5.00000000E+100' Rounded
+
+-- related
+fmax3137 fma 1 1 '0E-12' -> '1.00000000' Rounded
+fmax3138 fma 1 -1 '0E-12' -> '-1.00000000' Rounded
+fmax3139 fma 1 '0E-12' 1 -> '1.00000000' Rounded
+fmax3140 fma 1 '0E-12' -1 -> '-1.00000000' Rounded
+fmax3141 fma 1 1E+4 0.0000 -> '10000.0000'
+fmax3142 fma 1 1E+4 0.00000 -> '10000.0000' Rounded
+fmax3143 fma 1 0.000 1E+5 -> '100000.000'
+fmax3144 fma 1 0.0000 1E+5 -> '100000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+fmax3146 fma 1 '00.0' 0 -> '0.0'
+fmax3147 fma 1 '0.00' 0 -> '0.00'
+fmax3148 fma 1 0 '0.00' -> '0.00'
+fmax3149 fma 1 0 '00.0' -> '0.0'
+fmax3150 fma 1 '00.0' '0.00' -> '0.00'
+fmax3151 fma 1 '0.00' '00.0' -> '0.00'
+fmax3152 fma 1 '3' '.3' -> '3.3'
+fmax3153 fma 1 '3.' '.3' -> '3.3'
+fmax3154 fma 1 '3.0' '.3' -> '3.3'
+fmax3155 fma 1 '3.00' '.3' -> '3.30'
+fmax3156 fma 1 '3' '3' -> '6'
+fmax3157 fma 1 '3' '+3' -> '6'
+fmax3158 fma 1 '3' '-3' -> '0'
+fmax3159 fma 1 '0.3' '-0.3' -> '0.0'
+fmax3160 fma 1 '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+precision: 15
+fmax3161 fma 1 '1E+12' '-1' -> '999999999999'
+fmax3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
+fmax3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
+fmax3164 fma 1 '-1' '1E+12' -> '999999999999'
+fmax3165 fma 1 '7E+12' '-1' -> '6999999999999'
+fmax3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
+fmax3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
+fmax3168 fma 1 '-1' '7E+12' -> '6999999999999'
+
+-- 123456789012345 123456789012345 1 23456789012345
+fmax3170 fma 1 '0.444444444444444' '0.555555555555563' -> '1.00000000000001' Inexact Rounded
+fmax3171 fma 1 '0.444444444444444' '0.555555555555562' -> '1.00000000000001' Inexact Rounded
+fmax3172 fma 1 '0.444444444444444' '0.555555555555561' -> '1.00000000000001' Inexact Rounded
+fmax3173 fma 1 '0.444444444444444' '0.555555555555560' -> '1.00000000000000' Inexact Rounded
+fmax3174 fma 1 '0.444444444444444' '0.555555555555559' -> '1.00000000000000' Inexact Rounded
+fmax3175 fma 1 '0.444444444444444' '0.555555555555558' -> '1.00000000000000' Inexact Rounded
+fmax3176 fma 1 '0.444444444444444' '0.555555555555557' -> '1.00000000000000' Inexact Rounded
+fmax3177 fma 1 '0.444444444444444' '0.555555555555556' -> '1.00000000000000' Rounded
+fmax3178 fma 1 '0.444444444444444' '0.555555555555555' -> '0.999999999999999'
+fmax3179 fma 1 '0.444444444444444' '0.555555555555554' -> '0.999999999999998'
+fmax3180 fma 1 '0.444444444444444' '0.555555555555553' -> '0.999999999999997'
+fmax3181 fma 1 '0.444444444444444' '0.555555555555552' -> '0.999999999999996'
+fmax3182 fma 1 '0.444444444444444' '0.555555555555551' -> '0.999999999999995'
+fmax3183 fma 1 '0.444444444444444' '0.555555555555550' -> '0.999999999999994'
+
+-- and some more, including residue effects and different roundings
+precision: 9
+rounding: half_up
+fmax3200 fma 1 '123456789' 0 -> '123456789'
+fmax3201 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
+fmax3202 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
+fmax3203 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
+fmax3204 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
+fmax3205 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
+fmax3206 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
+fmax3207 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
+fmax3208 fma 1 '123456789' 0.5 -> '123456790' Inexact Rounded
+fmax3209 fma 1 '123456789' 0.500000001 -> '123456790' Inexact Rounded
+fmax3210 fma 1 '123456789' 0.500001 -> '123456790' Inexact Rounded
+fmax3211 fma 1 '123456789' 0.51 -> '123456790' Inexact Rounded
+fmax3212 fma 1 '123456789' 0.6 -> '123456790' Inexact Rounded
+fmax3213 fma 1 '123456789' 0.9 -> '123456790' Inexact Rounded
+fmax3214 fma 1 '123456789' 0.99999 -> '123456790' Inexact Rounded
+fmax3215 fma 1 '123456789' 0.999999999 -> '123456790' Inexact Rounded
+fmax3216 fma 1 '123456789' 1 -> '123456790'
+fmax3217 fma 1 '123456789' 1.000000001 -> '123456790' Inexact Rounded
+fmax3218 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
+fmax3219 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
+
+rounding: half_even
+fmax3220 fma 1 '123456789' 0 -> '123456789'
+fmax3221 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
+fmax3222 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
+fmax3223 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
+fmax3224 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
+fmax3225 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
+fmax3226 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
+fmax3227 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
+fmax3228 fma 1 '123456789' 0.5 -> '123456790' Inexact Rounded
+fmax3229 fma 1 '123456789' 0.500000001 -> '123456790' Inexact Rounded
+fmax3230 fma 1 '123456789' 0.500001 -> '123456790' Inexact Rounded
+fmax3231 fma 1 '123456789' 0.51 -> '123456790' Inexact Rounded
+fmax3232 fma 1 '123456789' 0.6 -> '123456790' Inexact Rounded
+fmax3233 fma 1 '123456789' 0.9 -> '123456790' Inexact Rounded
+fmax3234 fma 1 '123456789' 0.99999 -> '123456790' Inexact Rounded
+fmax3235 fma 1 '123456789' 0.999999999 -> '123456790' Inexact Rounded
+fmax3236 fma 1 '123456789' 1 -> '123456790'
+fmax3237 fma 1 '123456789' 1.00000001 -> '123456790' Inexact Rounded
+fmax3238 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
+fmax3239 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
+-- critical few with even bottom digit...
+fmax3240 fma 1 '123456788' 0.499999999 -> '123456788' Inexact Rounded
+fmax3241 fma 1 '123456788' 0.5 -> '123456788' Inexact Rounded
+fmax3242 fma 1 '123456788' 0.500000001 -> '123456789' Inexact Rounded
+
+rounding: down
+fmax3250 fma 1 '123456789' 0 -> '123456789'
+fmax3251 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
+fmax3252 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
+fmax3253 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
+fmax3254 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
+fmax3255 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
+fmax3256 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
+fmax3257 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
+fmax3258 fma 1 '123456789' 0.5 -> '123456789' Inexact Rounded
+fmax3259 fma 1 '123456789' 0.500000001 -> '123456789' Inexact Rounded
+fmax3260 fma 1 '123456789' 0.500001 -> '123456789' Inexact Rounded
+fmax3261 fma 1 '123456789' 0.51 -> '123456789' Inexact Rounded
+fmax3262 fma 1 '123456789' 0.6 -> '123456789' Inexact Rounded
+fmax3263 fma 1 '123456789' 0.9 -> '123456789' Inexact Rounded
+fmax3264 fma 1 '123456789' 0.99999 -> '123456789' Inexact Rounded
+fmax3265 fma 1 '123456789' 0.999999999 -> '123456789' Inexact Rounded
+fmax3266 fma 1 '123456789' 1 -> '123456790'
+fmax3267 fma 1 '123456789' 1.00000001 -> '123456790' Inexact Rounded
+fmax3268 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
+fmax3269 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
+
+-- input preparation tests (operands should not be rounded)
+precision: 3
+rounding: half_up
+
+fmax3270 fma 1 '12345678900000' 9999999999999 -> '2.23E+13' Inexact Rounded
+fmax3271 fma 1 '9999999999999' 12345678900000 -> '2.23E+13' Inexact Rounded
+
+fmax3272 fma 1 '12E+3' '3444' -> '1.54E+4' Inexact Rounded
+fmax3273 fma 1 '12E+3' '3446' -> '1.54E+4' Inexact Rounded
+fmax3274 fma 1 '12E+3' '3449.9' -> '1.54E+4' Inexact Rounded
+fmax3275 fma 1 '12E+3' '3450.0' -> '1.55E+4' Inexact Rounded
+fmax3276 fma 1 '12E+3' '3450.1' -> '1.55E+4' Inexact Rounded
+fmax3277 fma 1 '12E+3' '3454' -> '1.55E+4' Inexact Rounded
+fmax3278 fma 1 '12E+3' '3456' -> '1.55E+4' Inexact Rounded
+
+fmax3281 fma 1 '3444' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3282 fma 1 '3446' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3283 fma 1 '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3284 fma 1 '3450.0' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3285 fma 1 '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3286 fma 1 '3454' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3287 fma 1 '3456' '12E+3' -> '1.55E+4' Inexact Rounded
+
+rounding: half_down
+fmax3291 fma 1 '3444' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3292 fma 1 '3446' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3293 fma 1 '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3294 fma 1 '3450.0' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3295 fma 1 '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3296 fma 1 '3454' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3297 fma 1 '3456' '12E+3' -> '1.55E+4' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+fmax3301 fma 1 -1 1 -> 0
+fmax3302 fma 1 0 1 -> 1
+fmax3303 fma 1 1 1 -> 2
+fmax3304 fma 1 12 1 -> 13
+fmax3305 fma 1 98 1 -> 99
+fmax3306 fma 1 99 1 -> 100
+fmax3307 fma 1 100 1 -> 101
+fmax3308 fma 1 101 1 -> 102
+fmax3309 fma 1 -1 -1 -> -2
+fmax3310 fma 1 0 -1 -> -1
+fmax3311 fma 1 1 -1 -> 0
+fmax3312 fma 1 12 -1 -> 11
+fmax3313 fma 1 98 -1 -> 97
+fmax3314 fma 1 99 -1 -> 98
+fmax3315 fma 1 100 -1 -> 99
+fmax3316 fma 1 101 -1 -> 100
+
+fmax3321 fma 1 -0.01 0.01 -> 0.00
+fmax3322 fma 1 0.00 0.01 -> 0.01
+fmax3323 fma 1 0.01 0.01 -> 0.02
+fmax3324 fma 1 0.12 0.01 -> 0.13
+fmax3325 fma 1 0.98 0.01 -> 0.99
+fmax3326 fma 1 0.99 0.01 -> 1.00
+fmax3327 fma 1 1.00 0.01 -> 1.01
+fmax3328 fma 1 1.01 0.01 -> 1.02
+fmax3329 fma 1 -0.01 -0.01 -> -0.02
+fmax3330 fma 1 0.00 -0.01 -> -0.01
+fmax3331 fma 1 0.01 -0.01 -> 0.00
+fmax3332 fma 1 0.12 -0.01 -> 0.11
+fmax3333 fma 1 0.98 -0.01 -> 0.97
+fmax3334 fma 1 0.99 -0.01 -> 0.98
+fmax3335 fma 1 1.00 -0.01 -> 0.99
+fmax3336 fma 1 1.01 -0.01 -> 1.00
+
+-- some more cases where fma 1 ing 0 affects the coefficient
+precision: 9
+fmax3340 fma 1 1E+3 0 -> 1000
+fmax3341 fma 1 1E+8 0 -> 100000000
+fmax3342 fma 1 1E+9 0 -> 1.00000000E+9 Rounded
+fmax3343 fma 1 1E+10 0 -> 1.00000000E+10 Rounded
+-- which simply follow from these cases ...
+fmax3344 fma 1 1E+3 1 -> 1001
+fmax3345 fma 1 1E+8 1 -> 100000001
+fmax3346 fma 1 1E+9 1 -> 1.00000000E+9 Inexact Rounded
+fmax3347 fma 1 1E+10 1 -> 1.00000000E+10 Inexact Rounded
+fmax3348 fma 1 1E+3 7 -> 1007
+fmax3349 fma 1 1E+8 7 -> 100000007
+fmax3350 fma 1 1E+9 7 -> 1.00000001E+9 Inexact Rounded
+fmax3351 fma 1 1E+10 7 -> 1.00000000E+10 Inexact Rounded
+
+-- tryzeros cases
+precision: 7
+rounding: half_up
+maxExponent: 92
+minexponent: -92
+fmax3361 fma 1 0E+50 10000E+1 -> 1.0000E+5
+fmax3362 fma 1 10000E+1 0E-50 -> 100000.0 Rounded
+fmax3363 fma 1 10000E+1 10000E-50 -> 100000.0 Rounded Inexact
+fmax3364 fma 1 9.999999E+92 -9.999999E+92 -> 0E+86
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+precision: 10
+fmax3370 fma 1 99999999 81512 -> 100081511
+precision: 6
+fmax3371 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
+rounding: half_up
+precision: 10
+fmax3372 fma 1 99999999 81512 -> 100081511
+precision: 6
+fmax3373 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
+rounding: half_even
+precision: 10
+fmax3374 fma 1 99999999 81512 -> 100081511
+precision: 6
+fmax3375 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
+
+-- ulp replacement tests
+precision: 9
+maxexponent: 999999
+minexponent: -999999
+fmax3400 fma 1 1 77e-7 -> 1.0000077
+fmax3401 fma 1 1 77e-8 -> 1.00000077
+fmax3402 fma 1 1 77e-9 -> 1.00000008 Inexact Rounded
+fmax3403 fma 1 1 77e-10 -> 1.00000001 Inexact Rounded
+fmax3404 fma 1 1 77e-11 -> 1.00000000 Inexact Rounded
+fmax3405 fma 1 1 77e-12 -> 1.00000000 Inexact Rounded
+fmax3406 fma 1 1 77e-999 -> 1.00000000 Inexact Rounded
+fmax3407 fma 1 1 77e-999999 -> 1.00000000 Inexact Rounded
+
+fmax3410 fma 1 10 77e-7 -> 10.0000077
+fmax3411 fma 1 10 77e-8 -> 10.0000008 Inexact Rounded
+fmax3412 fma 1 10 77e-9 -> 10.0000001 Inexact Rounded
+fmax3413 fma 1 10 77e-10 -> 10.0000000 Inexact Rounded
+fmax3414 fma 1 10 77e-11 -> 10.0000000 Inexact Rounded
+fmax3415 fma 1 10 77e-12 -> 10.0000000 Inexact Rounded
+fmax3416 fma 1 10 77e-999 -> 10.0000000 Inexact Rounded
+fmax3417 fma 1 10 77e-999999 -> 10.0000000 Inexact Rounded
+
+fmax3420 fma 1 77e-7 1 -> 1.0000077
+fmax3421 fma 1 77e-8 1 -> 1.00000077
+fmax3422 fma 1 77e-9 1 -> 1.00000008 Inexact Rounded
+fmax3423 fma 1 77e-10 1 -> 1.00000001 Inexact Rounded
+fmax3424 fma 1 77e-11 1 -> 1.00000000 Inexact Rounded
+fmax3425 fma 1 77e-12 1 -> 1.00000000 Inexact Rounded
+fmax3426 fma 1 77e-999 1 -> 1.00000000 Inexact Rounded
+fmax3427 fma 1 77e-999999 1 -> 1.00000000 Inexact Rounded
+
+fmax3430 fma 1 77e-7 10 -> 10.0000077
+fmax3431 fma 1 77e-8 10 -> 10.0000008 Inexact Rounded
+fmax3432 fma 1 77e-9 10 -> 10.0000001 Inexact Rounded
+fmax3433 fma 1 77e-10 10 -> 10.0000000 Inexact Rounded
+fmax3434 fma 1 77e-11 10 -> 10.0000000 Inexact Rounded
+fmax3435 fma 1 77e-12 10 -> 10.0000000 Inexact Rounded
+fmax3436 fma 1 77e-999 10 -> 10.0000000 Inexact Rounded
+fmax3437 fma 1 77e-999999 10 -> 10.0000000 Inexact Rounded
+
+-- negative ulps
+fmax3440 fma 1 1 -77e-7 -> 0.9999923
+fmax3441 fma 1 1 -77e-8 -> 0.99999923
+fmax3442 fma 1 1 -77e-9 -> 0.999999923
+fmax3443 fma 1 1 -77e-10 -> 0.999999992 Inexact Rounded
+fmax3444 fma 1 1 -77e-11 -> 0.999999999 Inexact Rounded
+fmax3445 fma 1 1 -77e-12 -> 1.00000000 Inexact Rounded
+fmax3446 fma 1 1 -77e-999 -> 1.00000000 Inexact Rounded
+fmax3447 fma 1 1 -77e-999999 -> 1.00000000 Inexact Rounded
+
+fmax3450 fma 1 10 -77e-7 -> 9.9999923
+fmax3451 fma 1 10 -77e-8 -> 9.99999923
+fmax3452 fma 1 10 -77e-9 -> 9.99999992 Inexact Rounded
+fmax3453 fma 1 10 -77e-10 -> 9.99999999 Inexact Rounded
+fmax3454 fma 1 10 -77e-11 -> 10.0000000 Inexact Rounded
+fmax3455 fma 1 10 -77e-12 -> 10.0000000 Inexact Rounded
+fmax3456 fma 1 10 -77e-999 -> 10.0000000 Inexact Rounded
+fmax3457 fma 1 10 -77e-999999 -> 10.0000000 Inexact Rounded
+
+fmax3460 fma 1 -77e-7 1 -> 0.9999923
+fmax3461 fma 1 -77e-8 1 -> 0.99999923
+fmax3462 fma 1 -77e-9 1 -> 0.999999923
+fmax3463 fma 1 -77e-10 1 -> 0.999999992 Inexact Rounded
+fmax3464 fma 1 -77e-11 1 -> 0.999999999 Inexact Rounded
+fmax3465 fma 1 -77e-12 1 -> 1.00000000 Inexact Rounded
+fmax3466 fma 1 -77e-999 1 -> 1.00000000 Inexact Rounded
+fmax3467 fma 1 -77e-999999 1 -> 1.00000000 Inexact Rounded
+
+fmax3470 fma 1 -77e-7 10 -> 9.9999923
+fmax3471 fma 1 -77e-8 10 -> 9.99999923
+fmax3472 fma 1 -77e-9 10 -> 9.99999992 Inexact Rounded
+fmax3473 fma 1 -77e-10 10 -> 9.99999999 Inexact Rounded
+fmax3474 fma 1 -77e-11 10 -> 10.0000000 Inexact Rounded
+fmax3475 fma 1 -77e-12 10 -> 10.0000000 Inexact Rounded
+fmax3476 fma 1 -77e-999 10 -> 10.0000000 Inexact Rounded
+fmax3477 fma 1 -77e-999999 10 -> 10.0000000 Inexact Rounded
+
+-- negative ulps
+fmax3480 fma 1 -1 77e-7 -> -0.9999923
+fmax3481 fma 1 -1 77e-8 -> -0.99999923
+fmax3482 fma 1 -1 77e-9 -> -0.999999923
+fmax3483 fma 1 -1 77e-10 -> -0.999999992 Inexact Rounded
+fmax3484 fma 1 -1 77e-11 -> -0.999999999 Inexact Rounded
+fmax3485 fma 1 -1 77e-12 -> -1.00000000 Inexact Rounded
+fmax3486 fma 1 -1 77e-999 -> -1.00000000 Inexact Rounded
+fmax3487 fma 1 -1 77e-999999 -> -1.00000000 Inexact Rounded
+
+fmax3490 fma 1 -10 77e-7 -> -9.9999923
+fmax3491 fma 1 -10 77e-8 -> -9.99999923
+fmax3492 fma 1 -10 77e-9 -> -9.99999992 Inexact Rounded
+fmax3493 fma 1 -10 77e-10 -> -9.99999999 Inexact Rounded
+fmax3494 fma 1 -10 77e-11 -> -10.0000000 Inexact Rounded
+fmax3495 fma 1 -10 77e-12 -> -10.0000000 Inexact Rounded
+fmax3496 fma 1 -10 77e-999 -> -10.0000000 Inexact Rounded
+fmax3497 fma 1 -10 77e-999999 -> -10.0000000 Inexact Rounded
+
+fmax3500 fma 1 77e-7 -1 -> -0.9999923
+fmax3501 fma 1 77e-8 -1 -> -0.99999923
+fmax3502 fma 1 77e-9 -1 -> -0.999999923
+fmax3503 fma 1 77e-10 -1 -> -0.999999992 Inexact Rounded
+fmax3504 fma 1 77e-11 -1 -> -0.999999999 Inexact Rounded
+fmax3505 fma 1 77e-12 -1 -> -1.00000000 Inexact Rounded
+fmax3506 fma 1 77e-999 -1 -> -1.00000000 Inexact Rounded
+fmax3507 fma 1 77e-999999 -1 -> -1.00000000 Inexact Rounded
+
+fmax3510 fma 1 77e-7 -10 -> -9.9999923
+fmax3511 fma 1 77e-8 -10 -> -9.99999923
+fmax3512 fma 1 77e-9 -10 -> -9.99999992 Inexact Rounded
+fmax3513 fma 1 77e-10 -10 -> -9.99999999 Inexact Rounded
+fmax3514 fma 1 77e-11 -10 -> -10.0000000 Inexact Rounded
+fmax3515 fma 1 77e-12 -10 -> -10.0000000 Inexact Rounded
+fmax3516 fma 1 77e-999 -10 -> -10.0000000 Inexact Rounded
+fmax3517 fma 1 77e-999999 -10 -> -10.0000000 Inexact Rounded
+
+
+-- long operands
+maxexponent: 999
+minexponent: -999
+precision: 9
+fmax3521 fma 1 12345678000 0 -> 1.23456780E+10 Rounded
+fmax3522 fma 1 0 12345678000 -> 1.23456780E+10 Rounded
+fmax3523 fma 1 1234567800 0 -> 1.23456780E+9 Rounded
+fmax3524 fma 1 0 1234567800 -> 1.23456780E+9 Rounded
+fmax3525 fma 1 1234567890 0 -> 1.23456789E+9 Rounded
+fmax3526 fma 1 0 1234567890 -> 1.23456789E+9 Rounded
+fmax3527 fma 1 1234567891 0 -> 1.23456789E+9 Inexact Rounded
+fmax3528 fma 1 0 1234567891 -> 1.23456789E+9 Inexact Rounded
+fmax3529 fma 1 12345678901 0 -> 1.23456789E+10 Inexact Rounded
+fmax3530 fma 1 0 12345678901 -> 1.23456789E+10 Inexact Rounded
+fmax3531 fma 1 1234567896 0 -> 1.23456790E+9 Inexact Rounded
+fmax3532 fma 1 0 1234567896 -> 1.23456790E+9 Inexact Rounded
+
+precision: 15
+-- still checking
+fmax3541 fma 1 12345678000 0 -> 12345678000
+fmax3542 fma 1 0 12345678000 -> 12345678000
+fmax3543 fma 1 1234567800 0 -> 1234567800
+fmax3544 fma 1 0 1234567800 -> 1234567800
+fmax3545 fma 1 1234567890 0 -> 1234567890
+fmax3546 fma 1 0 1234567890 -> 1234567890
+fmax3547 fma 1 1234567891 0 -> 1234567891
+fmax3548 fma 1 0 1234567891 -> 1234567891
+fmax3549 fma 1 12345678901 0 -> 12345678901
+fmax3550 fma 1 0 12345678901 -> 12345678901
+fmax3551 fma 1 1234567896 0 -> 1234567896
+fmax3552 fma 1 0 1234567896 -> 1234567896
+
+-- verify a query
+precision: 16
+maxExponent: +394
+minExponent: -393
+rounding: down
+fmax3561 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
+fmax3562 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
+-- and using decimal64 bounds...
+precision: 16
+maxExponent: +384
+minExponent: -383
+rounding: down
+fmax3563 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
+fmax3564 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
+
+
+-- some more residue effects with extreme rounding
+precision: 9
+rounding: half_up
+fmax3601 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+rounding: half_even
+fmax3602 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+rounding: half_down
+fmax3603 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+rounding: floor
+fmax3604 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+rounding: ceiling
+fmax3605 fma 1 123456789 0.000001 -> 123456790 Inexact Rounded
+rounding: up
+fmax3606 fma 1 123456789 0.000001 -> 123456790 Inexact Rounded
+rounding: down
+fmax3607 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+
+rounding: half_up
+fmax3611 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: half_even
+fmax3612 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: half_down
+fmax3613 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: floor
+fmax3614 fma 1 123456789 -0.000001 -> 123456788 Inexact Rounded
+rounding: ceiling
+fmax3615 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: up
+fmax3616 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: down
+fmax3617 fma 1 123456789 -0.000001 -> 123456788 Inexact Rounded
+
+rounding: half_up
+fmax3621 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+rounding: half_even
+fmax3622 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+rounding: half_down
+fmax3623 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+rounding: floor
+fmax3624 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+rounding: ceiling
+fmax3625 fma 1 123456789 0.499999 -> 123456790 Inexact Rounded
+rounding: up
+fmax3626 fma 1 123456789 0.499999 -> 123456790 Inexact Rounded
+rounding: down
+fmax3627 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+
+rounding: half_up
+fmax3631 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: half_even
+fmax3632 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: half_down
+fmax3633 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: floor
+fmax3634 fma 1 123456789 -0.499999 -> 123456788 Inexact Rounded
+rounding: ceiling
+fmax3635 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: up
+fmax3636 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: down
+fmax3637 fma 1 123456789 -0.499999 -> 123456788 Inexact Rounded
+
+rounding: half_up
+fmax3641 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: half_even
+fmax3642 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: half_down
+fmax3643 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: floor
+fmax3644 fma 1 123456789 0.500001 -> 123456789 Inexact Rounded
+rounding: ceiling
+fmax3645 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: up
+fmax3646 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: down
+fmax3647 fma 1 123456789 0.500001 -> 123456789 Inexact Rounded
+
+rounding: half_up
+fmax3651 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+rounding: half_even
+fmax3652 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+rounding: half_down
+fmax3653 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+rounding: floor
+fmax3654 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+rounding: ceiling
+fmax3655 fma 1 123456789 -0.500001 -> 123456789 Inexact Rounded
+rounding: up
+fmax3656 fma 1 123456789 -0.500001 -> 123456789 Inexact Rounded
+rounding: down
+fmax3657 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+
+-- long operand triangle
+rounding: half_up
+precision: 37
+fmax3660 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114834538
+precision: 36
+fmax3661 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483454 Inexact Rounded
+precision: 35
+fmax3662 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148345 Inexact Rounded
+precision: 34
+fmax3663 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114835 Inexact Rounded
+precision: 33
+fmax3664 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483 Inexact Rounded
+precision: 32
+fmax3665 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148 Inexact Rounded
+precision: 31
+fmax3666 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337115 Inexact Rounded
+precision: 30
+fmax3667 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711 Inexact Rounded
+precision: 29
+fmax3668 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371 Inexact Rounded
+precision: 28
+fmax3669 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337 Inexact Rounded
+precision: 27
+fmax3670 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892234 Inexact Rounded
+precision: 26
+fmax3671 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223 Inexact Rounded
+precision: 25
+fmax3672 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922 Inexact Rounded
+precision: 24
+fmax3673 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892 Inexact Rounded
+precision: 23
+fmax3674 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389 Inexact Rounded
+precision: 22
+fmax3675 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023639 Inexact Rounded
+precision: 21
+fmax3676 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102364 Inexact Rounded
+precision: 20
+fmax3677 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236 Inexact Rounded
+precision: 19
+fmax3678 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211024 Inexact Rounded
+precision: 18
+fmax3679 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102 Inexact Rounded
+precision: 17
+fmax3680 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110 Inexact Rounded
+precision: 16
+fmax3681 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211 Inexact Rounded
+precision: 15
+fmax3682 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221 Inexact Rounded
+precision: 14
+fmax3683 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422 Inexact Rounded
+precision: 13
+fmax3684 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42 Inexact Rounded
+precision: 12
+fmax3685 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4 Inexact Rounded
+precision: 11
+fmax3686 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166 Inexact Rounded
+precision: 10
+fmax3687 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117417E+10 Inexact Rounded
+precision: 9
+fmax3688 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84711742E+10 Inexact Rounded
+precision: 8
+fmax3689 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471174E+10 Inexact Rounded
+precision: 7
+fmax3690 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117E+10 Inexact Rounded
+precision: 6
+fmax3691 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84712E+10 Inexact Rounded
+precision: 5
+fmax3692 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471E+10 Inexact Rounded
+precision: 4
+fmax3693 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847E+10 Inexact Rounded
+precision: 3
+fmax3694 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.85E+10 Inexact Rounded
+precision: 2
+fmax3695 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8E+10 Inexact Rounded
+precision: 1
+fmax3696 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 1E+11 Inexact Rounded
+
+-- more zeros, etc.
+rounding: half_up
+precision: 9
+
+fmax3701 fma 1 5.00 1.00E-3 -> 5.00100
+fmax3702 fma 1 00.00 0.000 -> 0.000
+fmax3703 fma 1 00.00 0E-3 -> 0.000
+fmax3704 fma 1 0E-3 00.00 -> 0.000
+
+fmax3710 fma 1 0E+3 00.00 -> 0.00
+fmax3711 fma 1 0E+3 00.0 -> 0.0
+fmax3712 fma 1 0E+3 00. -> 0
+fmax3713 fma 1 0E+3 00.E+1 -> 0E+1
+fmax3714 fma 1 0E+3 00.E+2 -> 0E+2
+fmax3715 fma 1 0E+3 00.E+3 -> 0E+3
+fmax3716 fma 1 0E+3 00.E+4 -> 0E+3
+fmax3717 fma 1 0E+3 00.E+5 -> 0E+3
+fmax3718 fma 1 0E+3 -00.0 -> 0.0
+fmax3719 fma 1 0E+3 -00. -> 0
+fmax3731 fma 1 0E+3 -00.E+1 -> 0E+1
+
+fmax3720 fma 1 00.00 0E+3 -> 0.00
+fmax3721 fma 1 00.0 0E+3 -> 0.0
+fmax3722 fma 1 00. 0E+3 -> 0
+fmax3723 fma 1 00.E+1 0E+3 -> 0E+1
+fmax3724 fma 1 00.E+2 0E+3 -> 0E+2
+fmax3725 fma 1 00.E+3 0E+3 -> 0E+3
+fmax3726 fma 1 00.E+4 0E+3 -> 0E+3
+fmax3727 fma 1 00.E+5 0E+3 -> 0E+3
+fmax3728 fma 1 -00.00 0E+3 -> 0.00
+fmax3729 fma 1 -00.0 0E+3 -> 0.0
+fmax3730 fma 1 -00. 0E+3 -> 0
+
+fmax3732 fma 1 0 0 -> 0
+fmax3733 fma 1 0 -0 -> 0
+fmax3734 fma 1 -0 0 -> 0
+fmax3735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
+
+fmax3736 fma 1 1 -1 -> 0
+fmax3737 fma 1 -1 -1 -> -2
+fmax3738 fma 1 1 1 -> 2
+fmax3739 fma 1 -1 1 -> 0
+
+fmax3741 fma 1 0 -1 -> -1
+fmax3742 fma 1 -0 -1 -> -1
+fmax3743 fma 1 0 1 -> 1
+fmax3744 fma 1 -0 1 -> 1
+fmax3745 fma 1 -1 0 -> -1
+fmax3746 fma 1 -1 -0 -> -1
+fmax3747 fma 1 1 0 -> 1
+fmax3748 fma 1 1 -0 -> 1
+
+fmax3751 fma 1 0.0 -1 -> -1.0
+fmax3752 fma 1 -0.0 -1 -> -1.0
+fmax3753 fma 1 0.0 1 -> 1.0
+fmax3754 fma 1 -0.0 1 -> 1.0
+fmax3755 fma 1 -1.0 0 -> -1.0
+fmax3756 fma 1 -1.0 -0 -> -1.0
+fmax3757 fma 1 1.0 0 -> 1.0
+fmax3758 fma 1 1.0 -0 -> 1.0
+
+fmax3761 fma 1 0 -1.0 -> -1.0
+fmax3762 fma 1 -0 -1.0 -> -1.0
+fmax3763 fma 1 0 1.0 -> 1.0
+fmax3764 fma 1 -0 1.0 -> 1.0
+fmax3765 fma 1 -1 0.0 -> -1.0
+fmax3766 fma 1 -1 -0.0 -> -1.0
+fmax3767 fma 1 1 0.0 -> 1.0
+fmax3768 fma 1 1 -0.0 -> 1.0
+
+fmax3771 fma 1 0.0 -1.0 -> -1.0
+fmax3772 fma 1 -0.0 -1.0 -> -1.0
+fmax3773 fma 1 0.0 1.0 -> 1.0
+fmax3774 fma 1 -0.0 1.0 -> 1.0
+fmax3775 fma 1 -1.0 0.0 -> -1.0
+fmax3776 fma 1 -1.0 -0.0 -> -1.0
+fmax3777 fma 1 1.0 0.0 -> 1.0
+fmax3778 fma 1 1.0 -0.0 -> 1.0
+
+-- Specials
+fmax3780 fma 1 -Inf -Inf -> -Infinity
+fmax3781 fma 1 -Inf -1000 -> -Infinity
+fmax3782 fma 1 -Inf -1 -> -Infinity
+fmax3783 fma 1 -Inf -0 -> -Infinity
+fmax3784 fma 1 -Inf 0 -> -Infinity
+fmax3785 fma 1 -Inf 1 -> -Infinity
+fmax3786 fma 1 -Inf 1000 -> -Infinity
+fmax3787 fma 1 -1000 -Inf -> -Infinity
+fmax3788 fma 1 -Inf -Inf -> -Infinity
+fmax3789 fma 1 -1 -Inf -> -Infinity
+fmax3790 fma 1 -0 -Inf -> -Infinity
+fmax3791 fma 1 0 -Inf -> -Infinity
+fmax3792 fma 1 1 -Inf -> -Infinity
+fmax3793 fma 1 1000 -Inf -> -Infinity
+fmax3794 fma 1 Inf -Inf -> NaN Invalid_operation
+
+fmax3800 fma 1 Inf -Inf -> NaN Invalid_operation
+fmax3801 fma 1 Inf -1000 -> Infinity
+fmax3802 fma 1 Inf -1 -> Infinity
+fmax3803 fma 1 Inf -0 -> Infinity
+fmax3804 fma 1 Inf 0 -> Infinity
+fmax3805 fma 1 Inf 1 -> Infinity
+fmax3806 fma 1 Inf 1000 -> Infinity
+fmax3807 fma 1 Inf Inf -> Infinity
+fmax3808 fma 1 -1000 Inf -> Infinity
+fmax3809 fma 1 -Inf Inf -> NaN Invalid_operation
+fmax3810 fma 1 -1 Inf -> Infinity
+fmax3811 fma 1 -0 Inf -> Infinity
+fmax3812 fma 1 0 Inf -> Infinity
+fmax3813 fma 1 1 Inf -> Infinity
+fmax3814 fma 1 1000 Inf -> Infinity
+fmax3815 fma 1 Inf Inf -> Infinity
+
+fmax3821 fma 1 NaN -Inf -> NaN
+fmax3822 fma 1 NaN -1000 -> NaN
+fmax3823 fma 1 NaN -1 -> NaN
+fmax3824 fma 1 NaN -0 -> NaN
+fmax3825 fma 1 NaN 0 -> NaN
+fmax3826 fma 1 NaN 1 -> NaN
+fmax3827 fma 1 NaN 1000 -> NaN
+fmax3828 fma 1 NaN Inf -> NaN
+fmax3829 fma 1 NaN NaN -> NaN
+fmax3830 fma 1 -Inf NaN -> NaN
+fmax3831 fma 1 -1000 NaN -> NaN
+fmax3832 fma 1 -1 NaN -> NaN
+fmax3833 fma 1 -0 NaN -> NaN
+fmax3834 fma 1 0 NaN -> NaN
+fmax3835 fma 1 1 NaN -> NaN
+fmax3836 fma 1 1000 NaN -> NaN
+fmax3837 fma 1 Inf NaN -> NaN
+
+fmax3841 fma 1 sNaN -Inf -> NaN Invalid_operation
+fmax3842 fma 1 sNaN -1000 -> NaN Invalid_operation
+fmax3843 fma 1 sNaN -1 -> NaN Invalid_operation
+fmax3844 fma 1 sNaN -0 -> NaN Invalid_operation
+fmax3845 fma 1 sNaN 0 -> NaN Invalid_operation
+fmax3846 fma 1 sNaN 1 -> NaN Invalid_operation
+fmax3847 fma 1 sNaN 1000 -> NaN Invalid_operation
+fmax3848 fma 1 sNaN NaN -> NaN Invalid_operation
+fmax3849 fma 1 sNaN sNaN -> NaN Invalid_operation
+fmax3850 fma 1 NaN sNaN -> NaN Invalid_operation
+fmax3851 fma 1 -Inf sNaN -> NaN Invalid_operation
+fmax3852 fma 1 -1000 sNaN -> NaN Invalid_operation
+fmax3853 fma 1 -1 sNaN -> NaN Invalid_operation
+fmax3854 fma 1 -0 sNaN -> NaN Invalid_operation
+fmax3855 fma 1 0 sNaN -> NaN Invalid_operation
+fmax3856 fma 1 1 sNaN -> NaN Invalid_operation
+fmax3857 fma 1 1000 sNaN -> NaN Invalid_operation
+fmax3858 fma 1 Inf sNaN -> NaN Invalid_operation
+fmax3859 fma 1 NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+fmax3861 fma 1 NaN1 -Inf -> NaN1
+fmax3862 fma 1 +NaN2 -1000 -> NaN2
+fmax3863 fma 1 NaN3 1000 -> NaN3
+fmax3864 fma 1 NaN4 Inf -> NaN4
+fmax3865 fma 1 NaN5 +NaN6 -> NaN5
+fmax3866 fma 1 -Inf NaN7 -> NaN7
+fmax3867 fma 1 -1000 NaN8 -> NaN8
+fmax3868 fma 1 1000 NaN9 -> NaN9
+fmax3869 fma 1 Inf +NaN10 -> NaN10
+fmax3871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
+fmax3872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
+fmax3873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
+fmax3874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
+fmax3875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
+fmax3876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
+fmax3877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
+fmax3878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
+fmax3879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
+fmax3880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
+fmax3881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
+fmax3882 fma 1 -NaN26 NaN28 -> -NaN26
+fmax3883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+fmax3884 fma 1 1000 -NaN30 -> -NaN30
+fmax3885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- overflow, underflow and subnormal tests
+maxexponent: 999999
+minexponent: -999999
+precision: 9
+fmax3890 fma 1 1E+999999 9E+999999 -> Infinity Overflow Inexact Rounded
+fmax3891 fma 1 9E+999999 1E+999999 -> Infinity Overflow Inexact Rounded
+fmax3892 fma 1 -1.1E-999999 1E-999999 -> -1E-1000000 Subnormal
+fmax3893 fma 1 1E-999999 -1.1e-999999 -> -1E-1000000 Subnormal
+fmax3894 fma 1 -1.0001E-999999 1E-999999 -> -1E-1000003 Subnormal
+fmax3895 fma 1 1E-999999 -1.0001e-999999 -> -1E-1000003 Subnormal
+fmax3896 fma 1 -1E+999999 -9E+999999 -> -Infinity Overflow Inexact Rounded
+fmax3897 fma 1 -9E+999999 -1E+999999 -> -Infinity Overflow Inexact Rounded
+fmax3898 fma 1 +1.1E-999999 -1E-999999 -> 1E-1000000 Subnormal
+fmax3899 fma 1 -1E-999999 +1.1e-999999 -> 1E-1000000 Subnormal
+fmax3900 fma 1 +1.0001E-999999 -1E-999999 -> 1E-1000003 Subnormal
+fmax3901 fma 1 -1E-999999 +1.0001e-999999 -> 1E-1000003 Subnormal
+fmax3902 fma 1 -1E+999999 +9E+999999 -> 8E+999999
+fmax3903 fma 1 -9E+999999 +1E+999999 -> -8E+999999
+
+precision: 3
+fmax3904 fma 1 0 -9.999E+999999 -> -Infinity Inexact Overflow Rounded
+fmax3905 fma 1 -9.999E+999999 0 -> -Infinity Inexact Overflow Rounded
+fmax3906 fma 1 0 9.999E+999999 -> Infinity Inexact Overflow Rounded
+fmax3907 fma 1 9.999E+999999 0 -> Infinity Inexact Overflow Rounded
+
+precision: 3
+maxexponent: 999
+minexponent: -999
+fmax3910 fma 1 1.00E-999 0 -> 1.00E-999
+fmax3911 fma 1 0.1E-999 0 -> 1E-1000 Subnormal
+fmax3912 fma 1 0.10E-999 0 -> 1.0E-1000 Subnormal
+fmax3913 fma 1 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded
+fmax3914 fma 1 0.01E-999 0 -> 1E-1001 Subnormal
+-- next is rounded to Nmin
+fmax3915 fma 1 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow
+fmax3916 fma 1 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3917 fma 1 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow
+fmax3918 fma 1 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3919 fma 1 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3920 fma 1 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+
+fmax3930 fma 1 -1.00E-999 0 -> -1.00E-999
+fmax3931 fma 1 -0.1E-999 0 -> -1E-1000 Subnormal
+fmax3932 fma 1 -0.10E-999 0 -> -1.0E-1000 Subnormal
+fmax3933 fma 1 -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded
+fmax3934 fma 1 -0.01E-999 0 -> -1E-1001 Subnormal
+-- next is rounded to Nmin
+fmax3935 fma 1 -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow
+fmax3936 fma 1 -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3937 fma 1 -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow
+fmax3938 fma 1 -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3939 fma 1 -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3940 fma 1 -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+
+-- some non-zero subnormal fma 1 s
+fmax3950 fma 1 1.00E-999 0.1E-999 -> 1.10E-999
+fmax3951 fma 1 0.1E-999 0.1E-999 -> 2E-1000 Subnormal
+fmax3952 fma 1 0.10E-999 0.1E-999 -> 2.0E-1000 Subnormal
+fmax3953 fma 1 0.100E-999 0.1E-999 -> 2.0E-1000 Subnormal Rounded
+fmax3954 fma 1 0.01E-999 0.1E-999 -> 1.1E-1000 Subnormal
+fmax3955 fma 1 0.999E-999 0.1E-999 -> 1.10E-999 Inexact Rounded
+fmax3956 fma 1 0.099E-999 0.1E-999 -> 2.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3957 fma 1 0.009E-999 0.1E-999 -> 1.1E-1000 Inexact Rounded Subnormal Underflow
+fmax3958 fma 1 0.001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3959 fma 1 0.0009E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3960 fma 1 0.0001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+-- negatives...
+fmax3961 fma 1 1.00E-999 -0.1E-999 -> 9.0E-1000 Subnormal
+fmax3962 fma 1 0.1E-999 -0.1E-999 -> 0E-1000
+fmax3963 fma 1 0.10E-999 -0.1E-999 -> 0E-1001
+fmax3964 fma 1 0.100E-999 -0.1E-999 -> 0E-1001 Clamped
+fmax3965 fma 1 0.01E-999 -0.1E-999 -> -9E-1001 Subnormal
+fmax3966 fma 1 0.999E-999 -0.1E-999 -> 9.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3967 fma 1 0.099E-999 -0.1E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3968 fma 1 0.009E-999 -0.1E-999 -> -9E-1001 Inexact Rounded Subnormal Underflow
+fmax3969 fma 1 0.001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3970 fma 1 0.0009E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3971 fma 1 0.0001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+
+-- some 'real' numbers
+maxExponent: 384
+minExponent: -383
+precision: 8
+fmax3566 fma 1 99999061735E-394 0E-394 -> 9.999906E-384 Inexact Rounded Underflow Subnormal
+precision: 7
+fmax3567 fma 1 99999061735E-394 0E-394 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
+precision: 6
+fmax3568 fma 1 99999061735E-394 0E-394 -> 9.9999E-384 Inexact Rounded Underflow Subnormal
+
+-- now the case where we can get underflow but the result is normal
+-- [note this can't happen if the operands are also bounded, as we
+-- cannot represent 1E-399, for example]
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+fmax3571 fma 1 1E-383 0 -> 1E-383
+fmax3572 fma 1 1E-384 0 -> 1E-384 Subnormal
+fmax3573 fma 1 1E-383 1E-384 -> 1.1E-383
+fmax3574 subtract 1E-383 1E-384 -> 9E-384 Subnormal
+
+-- Here we explore the boundary of rounding a subnormal to Nmin
+fmax3575 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
+fmax3576 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
+fmax3577 subtract 1E-383 1E-399 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax3578 subtract 1E-383 1E-400 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax3579 subtract 1E-383 1E-401 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax3580 subtract 1E-383 1E-402 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+
+-- check for double-rounded subnormals
+precision: 5
+maxexponent: 79
+minexponent: -79
+-- Add: lhs and rhs 0
+fmax31001 fma 1 1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31002 fma 1 1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31003 fma 1 1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31004 fma 1 0 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31005 fma 1 0 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31006 fma 1 0 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+
+-- Add: lhs >> rhs and vice versa
+fmax31011 fma 1 1.52444E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31012 fma 1 1.52445E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31013 fma 1 1.52446E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31014 fma 1 1E-100 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31015 fma 1 1E-100 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31016 fma 1 1E-100 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+
+-- Add: lhs + rhs fma 1 ition carried out
+fmax31021 fma 1 1.52443E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31022 fma 1 1.52444E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31023 fma 1 1.52445E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31024 fma 1 1.00001E-80 1.52443E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31025 fma 1 1.00001E-80 1.52444E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31026 fma 1 1.00001E-80 1.52445E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+
+-- And for round down full and subnormal results
+precision: 16
+maxExponent: +384
+minExponent: -383
+rounding: down
+
+fmax31100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
+fmax31101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
+fmax31103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
+fmax31104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
+fmax31105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
+fmax31106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
+fmax31107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
+fmax31108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
+fmax31109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+fmax31110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
+fmax31111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
+fmax31113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
+fmax31114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
+fmax31115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
+fmax31116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
+fmax31117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
+fmax31118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
+fmax31119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
+
+rounding: down
+precision: 7
+maxExponent: +96
+minExponent: -95
+fmax31130 fma 1 1 -1e-200 -> 0.9999999 Rounded Inexact
+-- subnormal boundary
+fmax31131 fma 1 1.000000E-94 -1e-200 -> 9.999999E-95 Rounded Inexact
+fmax31132 fma 1 1.000001E-95 -1e-200 -> 1.000000E-95 Rounded Inexact
+fmax31133 fma 1 1.000000E-95 -1e-200 -> 9.99999E-96 Rounded Inexact Subnormal Underflow
+fmax31134 fma 1 0.999999E-95 -1e-200 -> 9.99998E-96 Rounded Inexact Subnormal Underflow
+fmax31135 fma 1 0.001000E-95 -1e-200 -> 9.99E-99 Rounded Inexact Subnormal Underflow
+fmax31136 fma 1 0.000999E-95 -1e-200 -> 9.98E-99 Rounded Inexact Subnormal Underflow
+fmax31137 fma 1 1.000000E-95 -1e-101 -> 9.99999E-96 Subnormal
+fmax31138 fma 1 10000E-101 -1e-200 -> 9.999E-98 Subnormal Inexact Rounded Underflow
+fmax31139 fma 1 1000E-101 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow
+fmax31140 fma 1 100E-101 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow
+fmax31141 fma 1 10E-101 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow
+fmax31142 fma 1 1E-101 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31143 fma 1 0E-101 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31144 fma 1 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+
+fmax31151 fma 1 10000E-102 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow
+fmax31152 fma 1 1000E-102 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow
+fmax31153 fma 1 100E-102 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow
+fmax31154 fma 1 10E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31155 fma 1 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31156 fma 1 0E-102 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31157 fma 1 1E-103 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+
+fmax31160 fma 1 100E-105 -1e-101 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31161 fma 1 100E-105 -1e-201 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+
+-- tests based on Gunnar Degnbol's edge case
+precision: 15
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+fmax31200 fma 1 1E15 -0.5 -> 1.00000000000000E+15 Inexact Rounded
+fmax31201 fma 1 1E15 -0.50 -> 1.00000000000000E+15 Inexact Rounded
+fmax31210 fma 1 1E15 -0.51 -> 999999999999999 Inexact Rounded
+fmax31211 fma 1 1E15 -0.501 -> 999999999999999 Inexact Rounded
+fmax31212 fma 1 1E15 -0.5001 -> 999999999999999 Inexact Rounded
+fmax31213 fma 1 1E15 -0.50001 -> 999999999999999 Inexact Rounded
+fmax31214 fma 1 1E15 -0.500001 -> 999999999999999 Inexact Rounded
+fmax31215 fma 1 1E15 -0.5000001 -> 999999999999999 Inexact Rounded
+fmax31216 fma 1 1E15 -0.50000001 -> 999999999999999 Inexact Rounded
+fmax31217 fma 1 1E15 -0.500000001 -> 999999999999999 Inexact Rounded
+fmax31218 fma 1 1E15 -0.5000000001 -> 999999999999999 Inexact Rounded
+fmax31219 fma 1 1E15 -0.50000000001 -> 999999999999999 Inexact Rounded
+fmax31220 fma 1 1E15 -0.500000000001 -> 999999999999999 Inexact Rounded
+fmax31221 fma 1 1E15 -0.5000000000001 -> 999999999999999 Inexact Rounded
+fmax31222 fma 1 1E15 -0.50000000000001 -> 999999999999999 Inexact Rounded
+fmax31223 fma 1 1E15 -0.500000000000001 -> 999999999999999 Inexact Rounded
+fmax31224 fma 1 1E15 -0.5000000000000001 -> 999999999999999 Inexact Rounded
+fmax31225 fma 1 1E15 -0.5000000000000000 -> 1.00000000000000E+15 Inexact Rounded
+fmax31230 fma 1 1E15 -5000000.000000001 -> 999999995000000 Inexact Rounded
+
+precision: 16
+
+fmax31300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
+fmax31310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
+fmax31311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
+fmax31312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
+fmax31313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
+fmax31314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
+fmax31315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
+fmax31316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
+fmax31317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
+fmax31318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
+fmax31319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
+fmax31320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
+fmax31321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
+fmax31322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
+fmax31323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
+fmax31324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
+fmax31325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
+fmax31339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
+
+fmax31340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
+fmax31341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
+
+fmax31349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
+fmax31350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
+fmax31351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
+fmax31352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
+fmax31353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
+fmax31354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
+fmax31355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
+fmax31356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
+fmax31357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
+fmax31358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
+fmax31359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
+fmax31360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
+fmax31361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
+fmax31362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
+fmax31363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
+fmax31364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
+fmax31365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
+fmax31380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
+fmax31381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
+fmax31382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
+fmax31396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+precision: 15
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+fmax31400 fma 1 0 1.23456789012345 -> 1.23456789012345
+fmax31401 fma 1 0 1.23456789012345E-1 -> 0.123456789012345
+fmax31402 fma 1 0 1.23456789012345E-2 -> 0.0123456789012345
+fmax31403 fma 1 0 1.23456789012345E-3 -> 0.00123456789012345
+fmax31404 fma 1 0 1.23456789012345E-4 -> 0.000123456789012345
+fmax31405 fma 1 0 1.23456789012345E-5 -> 0.0000123456789012345
+fmax31406 fma 1 0 1.23456789012345E-6 -> 0.00000123456789012345
+fmax31407 fma 1 0 1.23456789012345E-7 -> 1.23456789012345E-7
+fmax31408 fma 1 0 1.23456789012345E-8 -> 1.23456789012345E-8
+fmax31409 fma 1 0 1.23456789012345E-9 -> 1.23456789012345E-9
+fmax31410 fma 1 0 1.23456789012345E-10 -> 1.23456789012345E-10
+fmax31411 fma 1 0 1.23456789012345E-11 -> 1.23456789012345E-11
+fmax31412 fma 1 0 1.23456789012345E-12 -> 1.23456789012345E-12
+fmax31413 fma 1 0 1.23456789012345E-13 -> 1.23456789012345E-13
+fmax31414 fma 1 0 1.23456789012345E-14 -> 1.23456789012345E-14
+fmax31415 fma 1 0 1.23456789012345E-15 -> 1.23456789012345E-15
+fmax31416 fma 1 0 1.23456789012345E-16 -> 1.23456789012345E-16
+fmax31417 fma 1 0 1.23456789012345E-17 -> 1.23456789012345E-17
+fmax31418 fma 1 0 1.23456789012345E-18 -> 1.23456789012345E-18
+fmax31419 fma 1 0 1.23456789012345E-19 -> 1.23456789012345E-19
+
+-- same, precision 16..
+precision: 16
+fmax31420 fma 1 0 1.123456789012345 -> 1.123456789012345
+fmax31421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
+fmax31422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
+fmax31423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
+fmax31424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
+fmax31425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
+fmax31426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
+fmax31427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
+fmax31428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
+fmax31429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
+fmax31430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
+fmax31431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
+fmax31432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
+fmax31433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
+fmax31434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
+fmax31435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
+fmax31436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
+fmax31437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
+fmax31438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
+fmax31439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
+
+-- same, reversed 0
+fmax31440 fma 1 1.123456789012345 0 -> 1.123456789012345
+fmax31441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
+fmax31442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
+fmax31443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
+fmax31444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
+fmax31445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
+fmax31446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
+fmax31447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
+fmax31448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
+fmax31449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
+fmax31450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
+fmax31451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
+fmax31452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
+fmax31453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
+fmax31454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
+fmax31455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
+fmax31456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
+fmax31457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
+fmax31458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
+fmax31459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
+
+-- same, Es on the 0
+fmax31460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
+fmax31461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
+fmax31462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
+fmax31463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
+fmax31464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
+fmax31465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
+fmax31466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
+fmax31467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
+fmax31468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
+fmax31469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
+fmax31470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
+fmax31471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
+fmax31472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
+fmax31473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
+fmax31474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
+fmax31475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
+-- next four flag Rounded because the 0 extends the result
+fmax31476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
+fmax31477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
+fmax31478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
+fmax31479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+precision: 16
+maxExponent: 384
+minexponent: -383
+
+rounding: half_up
+-- exact zeros from zeros
+fmax31500 fma 1 0 0E-19 -> 0E-19
+fmax31501 fma 1 -0 0E-19 -> 0E-19
+fmax31502 fma 1 0 -0E-19 -> 0E-19
+fmax31503 fma 1 -0 -0E-19 -> -0E-19
+fmax31504 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31505 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31506 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31507 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31511 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31512 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31513 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31514 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31515 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31516 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31517 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31518 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: half_down
+-- exact zeros from zeros
+fmax31520 fma 1 0 0E-19 -> 0E-19
+fmax31521 fma 1 -0 0E-19 -> 0E-19
+fmax31522 fma 1 0 -0E-19 -> 0E-19
+fmax31523 fma 1 -0 -0E-19 -> -0E-19
+fmax31524 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31525 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31526 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31527 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31531 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31532 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31533 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31534 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31535 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31536 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31537 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31538 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: half_even
+-- exact zeros from zeros
+fmax31540 fma 1 0 0E-19 -> 0E-19
+fmax31541 fma 1 -0 0E-19 -> 0E-19
+fmax31542 fma 1 0 -0E-19 -> 0E-19
+fmax31543 fma 1 -0 -0E-19 -> -0E-19
+fmax31544 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31545 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31546 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31547 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31551 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31552 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31553 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31554 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31555 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31556 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31557 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31558 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: up
+-- exact zeros from zeros
+fmax31560 fma 1 0 0E-19 -> 0E-19
+fmax31561 fma 1 -0 0E-19 -> 0E-19
+fmax31562 fma 1 0 -0E-19 -> 0E-19
+fmax31563 fma 1 -0 -0E-19 -> -0E-19
+fmax31564 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31565 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31566 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31567 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31571 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31572 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31573 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+fmax31574 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+-- some exact zeros from non-zeros
+fmax31575 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31576 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31577 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31578 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
+
+rounding: down
+-- exact zeros from zeros
+fmax31580 fma 1 0 0E-19 -> 0E-19
+fmax31581 fma 1 -0 0E-19 -> 0E-19
+fmax31582 fma 1 0 -0E-19 -> 0E-19
+fmax31583 fma 1 -0 -0E-19 -> -0E-19
+fmax31584 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31585 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31586 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31587 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31591 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31592 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31593 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31594 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31595 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31596 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31597 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31598 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: ceiling
+-- exact zeros from zeros
+fmax31600 fma 1 0 0E-19 -> 0E-19
+fmax31601 fma 1 -0 0E-19 -> 0E-19
+fmax31602 fma 1 0 -0E-19 -> 0E-19
+fmax31603 fma 1 -0 -0E-19 -> -0E-19
+fmax31604 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31605 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31606 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31607 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31611 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31612 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31613 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31614 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31615 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31616 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31617 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31618 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+fmax31620 fma 1 0 0E-19 -> 0E-19
+fmax31621 fma 1 -0 0E-19 -> -0E-19 -- *
+fmax31622 fma 1 0 -0E-19 -> -0E-19 -- *
+fmax31623 fma 1 -0 -0E-19 -> -0E-19
+fmax31624 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31625 fma 1 -0E-400 0E-19 -> -0E-398 Clamped -- *
+fmax31626 fma 1 0E-400 -0E-19 -> -0E-398 Clamped -- *
+fmax31627 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31631 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31632 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31633 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+fmax31634 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+-- some exact zeros from non-zeros
+fmax31635 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31636 fma 1 -1E-401 1E-401 -> -0E-398 Clamped -- *
+fmax31637 fma 1 1E-401 -1E-401 -> -0E-398 Clamped -- *
+fmax31638 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
+
+-- BigDecimal problem testcases 2006.01.23
+precision: 16
+maxExponent: 384
+minexponent: -383
+
+rounding: down
+precision: 7
+fmax31651 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 6
+fmax31652 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 5
+fmax31653 fma 1 10001E+2 -2E+1 -> 1.0000E+6 Inexact Rounded
+precision: 4
+fmax31654 fma 1 10001E+2 -2E+1 -> 1.000E+6 Inexact Rounded
+precision: 3
+fmax31655 fma 1 10001E+2 -2E+1 -> 1.00E+6 Inexact Rounded
+precision: 2
+fmax31656 fma 1 10001E+2 -2E+1 -> 1.0E+6 Inexact Rounded
+precision: 1
+fmax31657 fma 1 10001E+2 -2E+1 -> 1E+6 Inexact Rounded
+
+rounding: half_even
+precision: 7
+fmax31661 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 6
+fmax31662 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 5
+fmax31663 fma 1 10001E+2 -2E+1 -> 1.0001E+6 Inexact Rounded
+precision: 4
+fmax31664 fma 1 10001E+2 -2E+1 -> 1.000E+6 Inexact Rounded
+precision: 3
+fmax31665 fma 1 10001E+2 -2E+1 -> 1.00E+6 Inexact Rounded
+precision: 2
+fmax31666 fma 1 10001E+2 -2E+1 -> 1.0E+6 Inexact Rounded
+precision: 1
+fmax31667 fma 1 10001E+2 -2E+1 -> 1E+6 Inexact Rounded
+
+rounding: up
+precision: 7
+fmax31671 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 6
+fmax31672 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 5
+fmax31673 fma 1 10001E+2 -2E+1 -> 1.0001E+6 Inexact Rounded
+precision: 4
+fmax31674 fma 1 10001E+2 -2E+1 -> 1.001E+6 Inexact Rounded
+precision: 3
+fmax31675 fma 1 10001E+2 -2E+1 -> 1.01E+6 Inexact Rounded
+precision: 2
+fmax31676 fma 1 10001E+2 -2E+1 -> 1.1E+6 Inexact Rounded
+precision: 1
+fmax31677 fma 1 10001E+2 -2E+1 -> 2E+6 Inexact Rounded
+
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+-- Examples from SQL proposal (Krishna Kulkarni)
+fmax31701 fma 1 130E-2 120E-2 -> 2.50
+fmax31702 fma 1 130E-2 12E-1 -> 2.50
+fmax31703 fma 1 130E-2 1E0 -> 2.30
+fmax31704 fma 1 1E2 1E4 -> 1.01E+4
+fmax31705 subtract 130E-2 120E-2 -> 0.10
+fmax31706 subtract 130E-2 12E-1 -> 0.10
+fmax31707 subtract 130E-2 1E0 -> 0.30
+fmax31708 subtract 1E2 1E4 -> -9.9E+3
+
+------------------------------------------------------------------------
+-- Same as above, using decimal64 default parameters --
+------------------------------------------------------------------------
+precision: 16
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- [first group are 'quick confidence check']
+fmax36001 fma 1 1 1 -> 2
+fmax36002 fma 1 2 3 -> 5
+fmax36003 fma 1 '5.75' '3.3' -> 9.05
+fmax36004 fma 1 '5' '-3' -> 2
+fmax36005 fma 1 '-5' '-3' -> -8
+fmax36006 fma 1 '-7' '2.5' -> -4.5
+fmax36007 fma 1 '0.7' '0.3' -> 1.0
+fmax36008 fma 1 '1.25' '1.25' -> 2.50
+fmax36009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
+fmax36010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
+
+fmax36011 fma 1 '0.44444444444444444' '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
+fmax36012 fma 1 '0.44444444444444440' '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
+fmax36013 fma 1 '0.44444444444444444' '0.55555555555555550' -> '0.9999999999999999' Inexact Rounded
+fmax36014 fma 1 '0.444444444444444449' '0' -> '0.4444444444444444' Inexact Rounded
+fmax36015 fma 1 '0.4444444444444444499' '0' -> '0.4444444444444444' Inexact Rounded
+fmax36016 fma 1 '0.44444444444444444999' '0' -> '0.4444444444444444' Inexact Rounded
+fmax36017 fma 1 '0.44444444444444445000' '0' -> '0.4444444444444444' Inexact Rounded
+fmax36018 fma 1 '0.44444444444444445001' '0' -> '0.4444444444444445' Inexact Rounded
+fmax36019 fma 1 '0.4444444444444444501' '0' -> '0.4444444444444445' Inexact Rounded
+fmax36020 fma 1 '0.444444444444444451' '0' -> '0.4444444444444445' Inexact Rounded
+
+fmax36021 fma 1 0 1 -> 1
+fmax36022 fma 1 1 1 -> 2
+fmax36023 fma 1 2 1 -> 3
+fmax36024 fma 1 3 1 -> 4
+fmax36025 fma 1 4 1 -> 5
+fmax36026 fma 1 5 1 -> 6
+fmax36027 fma 1 6 1 -> 7
+fmax36028 fma 1 7 1 -> 8
+fmax36029 fma 1 8 1 -> 9
+fmax36030 fma 1 9 1 -> 10
+
+-- some carrying effects
+fmax36031 fma 1 '0.9998' '0.0000' -> '0.9998'
+fmax36032 fma 1 '0.9998' '0.0001' -> '0.9999'
+fmax36033 fma 1 '0.9998' '0.0002' -> '1.0000'
+fmax36034 fma 1 '0.9998' '0.0003' -> '1.0001'
+
+fmax36035 fma 1 '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+fmax36036 fma 1 '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+fmax36037 fma 1 '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+fmax36038 fma 1 '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
+fmax36039 fma 1 '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
+
+-- symmetry:
+fmax36040 fma 1 '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
+fmax36041 fma 1 '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
+fmax36042 fma 1 '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
+fmax36044 fma 1 '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
+fmax36045 fma 1 '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
+
+fmax36046 fma 1 '10000e+9' '7' -> '10000000000007'
+fmax36047 fma 1 '10000e+9' '70' -> '10000000000070'
+fmax36048 fma 1 '10000e+9' '700' -> '10000000000700'
+fmax36049 fma 1 '10000e+9' '7000' -> '10000000007000'
+fmax36050 fma 1 '10000e+9' '70000' -> '10000000070000'
+fmax36051 fma 1 '10000e+9' '700000' -> '10000000700000'
+
+-- examples from decarith
+fmax36053 fma 1 '12' '7.00' -> '19.00'
+fmax36054 fma 1 '1.3' '-1.07' -> '0.23'
+fmax36055 fma 1 '1.3' '-1.30' -> '0.00'
+fmax36056 fma 1 '1.3' '-2.07' -> '-0.77'
+fmax36057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
+
+-- from above
+fmax36061 fma 1 1 '0.1' -> '1.1'
+fmax36062 fma 1 1 '0.01' -> '1.01'
+fmax36063 fma 1 1 '0.001' -> '1.001'
+fmax36064 fma 1 1 '0.0001' -> '1.0001'
+fmax36065 fma 1 1 '0.00001' -> '1.00001'
+fmax36066 fma 1 1 '0.000001' -> '1.000001'
+fmax36067 fma 1 1 '0.0000001' -> '1.0000001'
+fmax36068 fma 1 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+fmax36070 fma 1 1 0 -> 1
+fmax36071 fma 1 1 0. -> 1
+fmax36072 fma 1 1 .0 -> 1.0
+fmax36073 fma 1 1 0.0 -> 1.0
+fmax36074 fma 1 1 0.00 -> 1.00
+fmax36075 fma 1 0 1 -> 1
+fmax36076 fma 1 0. 1 -> 1
+fmax36077 fma 1 .0 1 -> 1.0
+fmax36078 fma 1 0.0 1 -> 1.0
+fmax36079 fma 1 0.00 1 -> 1.00
+
+-- some carries
+fmax36080 fma 1 9999999999999998 1 -> 9999999999999999
+fmax36081 fma 1 9999999999999999 1 -> 1.000000000000000E+16 Rounded
+fmax36082 fma 1 999999999999999 1 -> 1000000000000000
+fmax36083 fma 1 9999999999999 1 -> 10000000000000
+fmax36084 fma 1 99999999999 1 -> 100000000000
+fmax36085 fma 1 999999999 1 -> 1000000000
+fmax36086 fma 1 9999999 1 -> 10000000
+fmax36087 fma 1 99999 1 -> 100000
+fmax36088 fma 1 999 1 -> 1000
+fmax36089 fma 1 9 1 -> 10
+
+
+-- more LHS swaps
+fmax36090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
+fmax36091 fma 1 '-56267E-6' 0 -> '-0.056267'
+fmax36092 fma 1 '-56267E-5' 0 -> '-0.56267'
+fmax36093 fma 1 '-56267E-4' 0 -> '-5.6267'
+fmax36094 fma 1 '-56267E-3' 0 -> '-56.267'
+fmax36095 fma 1 '-56267E-2' 0 -> '-562.67'
+fmax36096 fma 1 '-56267E-1' 0 -> '-5626.7'
+fmax36097 fma 1 '-56267E-0' 0 -> '-56267'
+fmax36098 fma 1 '-5E-10' 0 -> '-5E-10'
+fmax36099 fma 1 '-5E-7' 0 -> '-5E-7'
+fmax36100 fma 1 '-5E-6' 0 -> '-0.000005'
+fmax36101 fma 1 '-5E-5' 0 -> '-0.00005'
+fmax36102 fma 1 '-5E-4' 0 -> '-0.0005'
+fmax36103 fma 1 '-5E-1' 0 -> '-0.5'
+fmax36104 fma 1 '-5E0' 0 -> '-5'
+fmax36105 fma 1 '-5E1' 0 -> '-50'
+fmax36106 fma 1 '-5E5' 0 -> '-500000'
+fmax36107 fma 1 '-5E15' 0 -> '-5000000000000000'
+fmax36108 fma 1 '-5E16' 0 -> '-5.000000000000000E+16' Rounded
+fmax36109 fma 1 '-5E17' 0 -> '-5.000000000000000E+17' Rounded
+fmax36110 fma 1 '-5E18' 0 -> '-5.000000000000000E+18' Rounded
+fmax36111 fma 1 '-5E100' 0 -> '-5.000000000000000E+100' Rounded
+
+-- more RHS swaps
+fmax36113 fma 1 0 '-56267E-10' -> '-0.0000056267'
+fmax36114 fma 1 0 '-56267E-6' -> '-0.056267'
+fmax36116 fma 1 0 '-56267E-5' -> '-0.56267'
+fmax36117 fma 1 0 '-56267E-4' -> '-5.6267'
+fmax36119 fma 1 0 '-56267E-3' -> '-56.267'
+fmax36120 fma 1 0 '-56267E-2' -> '-562.67'
+fmax36121 fma 1 0 '-56267E-1' -> '-5626.7'
+fmax36122 fma 1 0 '-56267E-0' -> '-56267'
+fmax36123 fma 1 0 '-5E-10' -> '-5E-10'
+fmax36124 fma 1 0 '-5E-7' -> '-5E-7'
+fmax36125 fma 1 0 '-5E-6' -> '-0.000005'
+fmax36126 fma 1 0 '-5E-5' -> '-0.00005'
+fmax36127 fma 1 0 '-5E-4' -> '-0.0005'
+fmax36128 fma 1 0 '-5E-1' -> '-0.5'
+fmax36129 fma 1 0 '-5E0' -> '-5'
+fmax36130 fma 1 0 '-5E1' -> '-50'
+fmax36131 fma 1 0 '-5E5' -> '-500000'
+fmax36132 fma 1 0 '-5E15' -> '-5000000000000000'
+fmax36133 fma 1 0 '-5E16' -> '-5.000000000000000E+16' Rounded
+fmax36134 fma 1 0 '-5E17' -> '-5.000000000000000E+17' Rounded
+fmax36135 fma 1 0 '-5E18' -> '-5.000000000000000E+18' Rounded
+fmax36136 fma 1 0 '-5E100' -> '-5.000000000000000E+100' Rounded
+
+-- related
+fmax36137 fma 1 1 '0E-19' -> '1.000000000000000' Rounded
+fmax36138 fma 1 -1 '0E-19' -> '-1.000000000000000' Rounded
+fmax36139 fma 1 '0E-19' 1 -> '1.000000000000000' Rounded
+fmax36140 fma 1 '0E-19' -1 -> '-1.000000000000000' Rounded
+fmax36141 fma 1 1E+11 0.0000 -> '100000000000.0000'
+fmax36142 fma 1 1E+11 0.00000 -> '100000000000.0000' Rounded
+fmax36143 fma 1 0.000 1E+12 -> '1000000000000.000'
+fmax36144 fma 1 0.0000 1E+12 -> '1000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+fmax36146 fma 1 '00.0' 0 -> '0.0'
+fmax36147 fma 1 '0.00' 0 -> '0.00'
+fmax36148 fma 1 0 '0.00' -> '0.00'
+fmax36149 fma 1 0 '00.0' -> '0.0'
+fmax36150 fma 1 '00.0' '0.00' -> '0.00'
+fmax36151 fma 1 '0.00' '00.0' -> '0.00'
+fmax36152 fma 1 '3' '.3' -> '3.3'
+fmax36153 fma 1 '3.' '.3' -> '3.3'
+fmax36154 fma 1 '3.0' '.3' -> '3.3'
+fmax36155 fma 1 '3.00' '.3' -> '3.30'
+fmax36156 fma 1 '3' '3' -> '6'
+fmax36157 fma 1 '3' '+3' -> '6'
+fmax36158 fma 1 '3' '-3' -> '0'
+fmax36159 fma 1 '0.3' '-0.3' -> '0.0'
+fmax36160 fma 1 '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+fmax36161 fma 1 '1E+13' '-1' -> '9999999999999'
+fmax36162 fma 1 '1E+13' '1.11' -> '10000000000001.11'
+fmax36163 fma 1 '1.11' '1E+13' -> '10000000000001.11'
+fmax36164 fma 1 '-1' '1E+13' -> '9999999999999'
+fmax36165 fma 1 '7E+13' '-1' -> '69999999999999'
+fmax36166 fma 1 '7E+13' '1.11' -> '70000000000001.11'
+fmax36167 fma 1 '1.11' '7E+13' -> '70000000000001.11'
+fmax36168 fma 1 '-1' '7E+13' -> '69999999999999'
+
+-- 1234567890123456 1234567890123456 1 234567890123456
+fmax36170 fma 1 '0.4444444444444444' '0.5555555555555563' -> '1.000000000000001' Inexact Rounded
+fmax36171 fma 1 '0.4444444444444444' '0.5555555555555562' -> '1.000000000000001' Inexact Rounded
+fmax36172 fma 1 '0.4444444444444444' '0.5555555555555561' -> '1.000000000000000' Inexact Rounded
+fmax36173 fma 1 '0.4444444444444444' '0.5555555555555560' -> '1.000000000000000' Inexact Rounded
+fmax36174 fma 1 '0.4444444444444444' '0.5555555555555559' -> '1.000000000000000' Inexact Rounded
+fmax36175 fma 1 '0.4444444444444444' '0.5555555555555558' -> '1.000000000000000' Inexact Rounded
+fmax36176 fma 1 '0.4444444444444444' '0.5555555555555557' -> '1.000000000000000' Inexact Rounded
+fmax36177 fma 1 '0.4444444444444444' '0.5555555555555556' -> '1.000000000000000' Rounded
+fmax36178 fma 1 '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
+fmax36179 fma 1 '0.4444444444444444' '0.5555555555555554' -> '0.9999999999999998'
+fmax36180 fma 1 '0.4444444444444444' '0.5555555555555553' -> '0.9999999999999997'
+fmax36181 fma 1 '0.4444444444444444' '0.5555555555555552' -> '0.9999999999999996'
+fmax36182 fma 1 '0.4444444444444444' '0.5555555555555551' -> '0.9999999999999995'
+fmax36183 fma 1 '0.4444444444444444' '0.5555555555555550' -> '0.9999999999999994'
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+fmax36200 fma 1 '6543210123456789' 0 -> '6543210123456789'
+fmax36201 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+fmax36202 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+fmax36203 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+fmax36204 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+fmax36205 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+fmax36206 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36207 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36208 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+fmax36209 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+fmax36210 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+fmax36211 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+fmax36212 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+fmax36213 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+fmax36214 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+fmax36215 fma 1 '6543210123456789' 0.999999 -> '6543210123456790' Inexact Rounded
+fmax36216 fma 1 '6543210123456789' 1 -> '6543210123456790'
+fmax36217 fma 1 '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
+fmax36218 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+fmax36219 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+rounding: half_even
+fmax36220 fma 1 '6543210123456789' 0 -> '6543210123456789'
+fmax36221 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+fmax36222 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+fmax36223 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+fmax36224 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+fmax36225 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+fmax36226 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36227 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36228 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+fmax36229 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+fmax36230 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+fmax36231 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+fmax36232 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+fmax36233 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+fmax36234 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+fmax36235 fma 1 '6543210123456789' 0.999999 -> '6543210123456790' Inexact Rounded
+fmax36236 fma 1 '6543210123456789' 1 -> '6543210123456790'
+fmax36237 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+fmax36238 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+fmax36239 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+-- critical few with even bottom digit...
+fmax36240 fma 1 '6543210123456788' 0.499999 -> '6543210123456788' Inexact Rounded
+fmax36241 fma 1 '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
+fmax36242 fma 1 '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
+
+rounding: down
+fmax36250 fma 1 '6543210123456789' 0 -> '6543210123456789'
+fmax36251 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+fmax36252 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+fmax36253 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+fmax36254 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+fmax36255 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+fmax36256 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36257 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36258 fma 1 '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
+fmax36259 fma 1 '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
+fmax36260 fma 1 '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
+fmax36261 fma 1 '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
+fmax36262 fma 1 '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
+fmax36263 fma 1 '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
+fmax36264 fma 1 '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
+fmax36265 fma 1 '6543210123456789' 0.999999 -> '6543210123456789' Inexact Rounded
+fmax36266 fma 1 '6543210123456789' 1 -> '6543210123456790'
+fmax36267 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+fmax36268 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+fmax36269 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_even
+fmax36301 fma 1 -1 1 -> 0
+fmax36302 fma 1 0 1 -> 1
+fmax36303 fma 1 1 1 -> 2
+fmax36304 fma 1 12 1 -> 13
+fmax36305 fma 1 98 1 -> 99
+fmax36306 fma 1 99 1 -> 100
+fmax36307 fma 1 100 1 -> 101
+fmax36308 fma 1 101 1 -> 102
+fmax36309 fma 1 -1 -1 -> -2
+fmax36310 fma 1 0 -1 -> -1
+fmax36311 fma 1 1 -1 -> 0
+fmax36312 fma 1 12 -1 -> 11
+fmax36313 fma 1 98 -1 -> 97
+fmax36314 fma 1 99 -1 -> 98
+fmax36315 fma 1 100 -1 -> 99
+fmax36316 fma 1 101 -1 -> 100
+
+fmax36321 fma 1 -0.01 0.01 -> 0.00
+fmax36322 fma 1 0.00 0.01 -> 0.01
+fmax36323 fma 1 0.01 0.01 -> 0.02
+fmax36324 fma 1 0.12 0.01 -> 0.13
+fmax36325 fma 1 0.98 0.01 -> 0.99
+fmax36326 fma 1 0.99 0.01 -> 1.00
+fmax36327 fma 1 1.00 0.01 -> 1.01
+fmax36328 fma 1 1.01 0.01 -> 1.02
+fmax36329 fma 1 -0.01 -0.01 -> -0.02
+fmax36330 fma 1 0.00 -0.01 -> -0.01
+fmax36331 fma 1 0.01 -0.01 -> 0.00
+fmax36332 fma 1 0.12 -0.01 -> 0.11
+fmax36333 fma 1 0.98 -0.01 -> 0.97
+fmax36334 fma 1 0.99 -0.01 -> 0.98
+fmax36335 fma 1 1.00 -0.01 -> 0.99
+fmax36336 fma 1 1.01 -0.01 -> 1.00
+
+-- some more cases where fma 1 ing 0 affects the coefficient
+fmax36340 fma 1 1E+3 0 -> 1000
+fmax36341 fma 1 1E+15 0 -> 1000000000000000
+fmax36342 fma 1 1E+16 0 -> 1.000000000000000E+16 Rounded
+fmax36343 fma 1 1E+17 0 -> 1.000000000000000E+17 Rounded
+-- which simply follow from these cases ...
+fmax36344 fma 1 1E+3 1 -> 1001
+fmax36345 fma 1 1E+15 1 -> 1000000000000001
+fmax36346 fma 1 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
+fmax36347 fma 1 1E+17 1 -> 1.000000000000000E+17 Inexact Rounded
+fmax36348 fma 1 1E+3 7 -> 1007
+fmax36349 fma 1 1E+15 7 -> 1000000000000007
+fmax36350 fma 1 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
+fmax36351 fma 1 1E+17 7 -> 1.000000000000000E+17 Inexact Rounded
+
+-- tryzeros cases
+fmax36361 fma 1 0E+50 10000E+1 -> 1.0000E+5
+fmax36362 fma 1 10000E+1 0E-50 -> 100000.0000000000 Rounded
+fmax36363 fma 1 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
+fmax36364 fma 1 12.34 0e-398 -> 12.34000000000000 Rounded
+
+-- ulp replacement tests
+fmax36400 fma 1 1 77e-14 -> 1.00000000000077
+fmax36401 fma 1 1 77e-15 -> 1.000000000000077
+fmax36402 fma 1 1 77e-16 -> 1.000000000000008 Inexact Rounded
+fmax36403 fma 1 1 77e-17 -> 1.000000000000001 Inexact Rounded
+fmax36404 fma 1 1 77e-18 -> 1.000000000000000 Inexact Rounded
+fmax36405 fma 1 1 77e-19 -> 1.000000000000000 Inexact Rounded
+fmax36406 fma 1 1 77e-99 -> 1.000000000000000 Inexact Rounded
+
+fmax36410 fma 1 10 77e-14 -> 10.00000000000077
+fmax36411 fma 1 10 77e-15 -> 10.00000000000008 Inexact Rounded
+fmax36412 fma 1 10 77e-16 -> 10.00000000000001 Inexact Rounded
+fmax36413 fma 1 10 77e-17 -> 10.00000000000000 Inexact Rounded
+fmax36414 fma 1 10 77e-18 -> 10.00000000000000 Inexact Rounded
+fmax36415 fma 1 10 77e-19 -> 10.00000000000000 Inexact Rounded
+fmax36416 fma 1 10 77e-99 -> 10.00000000000000 Inexact Rounded
+
+fmax36420 fma 1 77e-14 1 -> 1.00000000000077
+fmax36421 fma 1 77e-15 1 -> 1.000000000000077
+fmax36422 fma 1 77e-16 1 -> 1.000000000000008 Inexact Rounded
+fmax36423 fma 1 77e-17 1 -> 1.000000000000001 Inexact Rounded
+fmax36424 fma 1 77e-18 1 -> 1.000000000000000 Inexact Rounded
+fmax36425 fma 1 77e-19 1 -> 1.000000000000000 Inexact Rounded
+fmax36426 fma 1 77e-99 1 -> 1.000000000000000 Inexact Rounded
+
+fmax36430 fma 1 77e-14 10 -> 10.00000000000077
+fmax36431 fma 1 77e-15 10 -> 10.00000000000008 Inexact Rounded
+fmax36432 fma 1 77e-16 10 -> 10.00000000000001 Inexact Rounded
+fmax36433 fma 1 77e-17 10 -> 10.00000000000000 Inexact Rounded
+fmax36434 fma 1 77e-18 10 -> 10.00000000000000 Inexact Rounded
+fmax36435 fma 1 77e-19 10 -> 10.00000000000000 Inexact Rounded
+fmax36436 fma 1 77e-99 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+fmax36440 fma 1 1 -77e-14 -> 0.99999999999923
+fmax36441 fma 1 1 -77e-15 -> 0.999999999999923
+fmax36442 fma 1 1 -77e-16 -> 0.9999999999999923
+fmax36443 fma 1 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
+fmax36444 fma 1 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
+fmax36445 fma 1 1 -77e-19 -> 1.000000000000000 Inexact Rounded
+fmax36446 fma 1 1 -77e-99 -> 1.000000000000000 Inexact Rounded
+
+fmax36450 fma 1 10 -77e-14 -> 9.99999999999923
+fmax36451 fma 1 10 -77e-15 -> 9.999999999999923
+fmax36452 fma 1 10 -77e-16 -> 9.999999999999992 Inexact Rounded
+fmax36453 fma 1 10 -77e-17 -> 9.999999999999999 Inexact Rounded
+fmax36454 fma 1 10 -77e-18 -> 10.00000000000000 Inexact Rounded
+fmax36455 fma 1 10 -77e-19 -> 10.00000000000000 Inexact Rounded
+fmax36456 fma 1 10 -77e-99 -> 10.00000000000000 Inexact Rounded
+
+fmax36460 fma 1 -77e-14 1 -> 0.99999999999923
+fmax36461 fma 1 -77e-15 1 -> 0.999999999999923
+fmax36462 fma 1 -77e-16 1 -> 0.9999999999999923
+fmax36463 fma 1 -77e-17 1 -> 0.9999999999999992 Inexact Rounded
+fmax36464 fma 1 -77e-18 1 -> 0.9999999999999999 Inexact Rounded
+fmax36465 fma 1 -77e-19 1 -> 1.000000000000000 Inexact Rounded
+fmax36466 fma 1 -77e-99 1 -> 1.000000000000000 Inexact Rounded
+
+fmax36470 fma 1 -77e-14 10 -> 9.99999999999923
+fmax36471 fma 1 -77e-15 10 -> 9.999999999999923
+fmax36472 fma 1 -77e-16 10 -> 9.999999999999992 Inexact Rounded
+fmax36473 fma 1 -77e-17 10 -> 9.999999999999999 Inexact Rounded
+fmax36474 fma 1 -77e-18 10 -> 10.00000000000000 Inexact Rounded
+fmax36475 fma 1 -77e-19 10 -> 10.00000000000000 Inexact Rounded
+fmax36476 fma 1 -77e-99 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+fmax36480 fma 1 -1 77e-14 -> -0.99999999999923
+fmax36481 fma 1 -1 77e-15 -> -0.999999999999923
+fmax36482 fma 1 -1 77e-16 -> -0.9999999999999923
+fmax36483 fma 1 -1 77e-17 -> -0.9999999999999992 Inexact Rounded
+fmax36484 fma 1 -1 77e-18 -> -0.9999999999999999 Inexact Rounded
+fmax36485 fma 1 -1 77e-19 -> -1.000000000000000 Inexact Rounded
+fmax36486 fma 1 -1 77e-99 -> -1.000000000000000 Inexact Rounded
+
+fmax36490 fma 1 -10 77e-14 -> -9.99999999999923
+fmax36491 fma 1 -10 77e-15 -> -9.999999999999923
+fmax36492 fma 1 -10 77e-16 -> -9.999999999999992 Inexact Rounded
+fmax36493 fma 1 -10 77e-17 -> -9.999999999999999 Inexact Rounded
+fmax36494 fma 1 -10 77e-18 -> -10.00000000000000 Inexact Rounded
+fmax36495 fma 1 -10 77e-19 -> -10.00000000000000 Inexact Rounded
+fmax36496 fma 1 -10 77e-99 -> -10.00000000000000 Inexact Rounded
+
+fmax36500 fma 1 77e-14 -1 -> -0.99999999999923
+fmax36501 fma 1 77e-15 -1 -> -0.999999999999923
+fmax36502 fma 1 77e-16 -1 -> -0.9999999999999923
+fmax36503 fma 1 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
+fmax36504 fma 1 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
+fmax36505 fma 1 77e-19 -1 -> -1.000000000000000 Inexact Rounded
+fmax36506 fma 1 77e-99 -1 -> -1.000000000000000 Inexact Rounded
+
+fmax36510 fma 1 77e-14 -10 -> -9.99999999999923
+fmax36511 fma 1 77e-15 -10 -> -9.999999999999923
+fmax36512 fma 1 77e-16 -10 -> -9.999999999999992 Inexact Rounded
+fmax36513 fma 1 77e-17 -10 -> -9.999999999999999 Inexact Rounded
+fmax36514 fma 1 77e-18 -10 -> -10.00000000000000 Inexact Rounded
+fmax36515 fma 1 77e-19 -10 -> -10.00000000000000 Inexact Rounded
+fmax36516 fma 1 77e-99 -10 -> -10.00000000000000 Inexact Rounded
+
+
+-- long operands
+fmax36521 fma 1 101234562345678000 0 -> 1.012345623456780E+17 Rounded
+fmax36522 fma 1 0 101234562345678000 -> 1.012345623456780E+17 Rounded
+fmax36523 fma 1 10123456234567800 0 -> 1.012345623456780E+16 Rounded
+fmax36524 fma 1 0 10123456234567800 -> 1.012345623456780E+16 Rounded
+fmax36525 fma 1 10123456234567890 0 -> 1.012345623456789E+16 Rounded
+fmax36526 fma 1 0 10123456234567890 -> 1.012345623456789E+16 Rounded
+fmax36527 fma 1 10123456234567891 0 -> 1.012345623456789E+16 Inexact Rounded
+fmax36528 fma 1 0 10123456234567891 -> 1.012345623456789E+16 Inexact Rounded
+fmax36529 fma 1 101234562345678901 0 -> 1.012345623456789E+17 Inexact Rounded
+fmax36530 fma 1 0 101234562345678901 -> 1.012345623456789E+17 Inexact Rounded
+fmax36531 fma 1 10123456234567896 0 -> 1.012345623456790E+16 Inexact Rounded
+fmax36532 fma 1 0 10123456234567896 -> 1.012345623456790E+16 Inexact Rounded
+
+-- verify a query
+rounding: down
+fmax36561 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
+fmax36562 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
+-- and using decimal64 bounds...
+rounding: down
+fmax36563 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
+fmax36564 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+fmax36701 fma 1 5.00 1.00E-3 -> 5.00100
+fmax36702 fma 1 00.00 0.000 -> 0.000
+fmax36703 fma 1 00.00 0E-3 -> 0.000
+fmax36704 fma 1 0E-3 00.00 -> 0.000
+
+fmax36710 fma 1 0E+3 00.00 -> 0.00
+fmax36711 fma 1 0E+3 00.0 -> 0.0
+fmax36712 fma 1 0E+3 00. -> 0
+fmax36713 fma 1 0E+3 00.E+1 -> 0E+1
+fmax36714 fma 1 0E+3 00.E+2 -> 0E+2
+fmax36715 fma 1 0E+3 00.E+3 -> 0E+3
+fmax36716 fma 1 0E+3 00.E+4 -> 0E+3
+fmax36717 fma 1 0E+3 00.E+5 -> 0E+3
+fmax36718 fma 1 0E+3 -00.0 -> 0.0
+fmax36719 fma 1 0E+3 -00. -> 0
+fmax36731 fma 1 0E+3 -00.E+1 -> 0E+1
+
+fmax36720 fma 1 00.00 0E+3 -> 0.00
+fmax36721 fma 1 00.0 0E+3 -> 0.0
+fmax36722 fma 1 00. 0E+3 -> 0
+fmax36723 fma 1 00.E+1 0E+3 -> 0E+1
+fmax36724 fma 1 00.E+2 0E+3 -> 0E+2
+fmax36725 fma 1 00.E+3 0E+3 -> 0E+3
+fmax36726 fma 1 00.E+4 0E+3 -> 0E+3
+fmax36727 fma 1 00.E+5 0E+3 -> 0E+3
+fmax36728 fma 1 -00.00 0E+3 -> 0.00
+fmax36729 fma 1 -00.0 0E+3 -> 0.0
+fmax36730 fma 1 -00. 0E+3 -> 0
+
+fmax36732 fma 1 0 0 -> 0
+fmax36733 fma 1 0 -0 -> 0
+fmax36734 fma 1 -0 0 -> 0
+fmax36735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
+
+fmax36736 fma 1 1 -1 -> 0
+fmax36737 fma 1 -1 -1 -> -2
+fmax36738 fma 1 1 1 -> 2
+fmax36739 fma 1 -1 1 -> 0
+
+fmax36741 fma 1 0 -1 -> -1
+fmax36742 fma 1 -0 -1 -> -1
+fmax36743 fma 1 0 1 -> 1
+fmax36744 fma 1 -0 1 -> 1
+fmax36745 fma 1 -1 0 -> -1
+fmax36746 fma 1 -1 -0 -> -1
+fmax36747 fma 1 1 0 -> 1
+fmax36748 fma 1 1 -0 -> 1
+
+fmax36751 fma 1 0.0 -1 -> -1.0
+fmax36752 fma 1 -0.0 -1 -> -1.0
+fmax36753 fma 1 0.0 1 -> 1.0
+fmax36754 fma 1 -0.0 1 -> 1.0
+fmax36755 fma 1 -1.0 0 -> -1.0
+fmax36756 fma 1 -1.0 -0 -> -1.0
+fmax36757 fma 1 1.0 0 -> 1.0
+fmax36758 fma 1 1.0 -0 -> 1.0
+
+fmax36761 fma 1 0 -1.0 -> -1.0
+fmax36762 fma 1 -0 -1.0 -> -1.0
+fmax36763 fma 1 0 1.0 -> 1.0
+fmax36764 fma 1 -0 1.0 -> 1.0
+fmax36765 fma 1 -1 0.0 -> -1.0
+fmax36766 fma 1 -1 -0.0 -> -1.0
+fmax36767 fma 1 1 0.0 -> 1.0
+fmax36768 fma 1 1 -0.0 -> 1.0
+
+fmax36771 fma 1 0.0 -1.0 -> -1.0
+fmax36772 fma 1 -0.0 -1.0 -> -1.0
+fmax36773 fma 1 0.0 1.0 -> 1.0
+fmax36774 fma 1 -0.0 1.0 -> 1.0
+fmax36775 fma 1 -1.0 0.0 -> -1.0
+fmax36776 fma 1 -1.0 -0.0 -> -1.0
+fmax36777 fma 1 1.0 0.0 -> 1.0
+fmax36778 fma 1 1.0 -0.0 -> 1.0
+
+-- Specials
+fmax36780 fma 1 -Inf -Inf -> -Infinity
+fmax36781 fma 1 -Inf -1000 -> -Infinity
+fmax36782 fma 1 -Inf -1 -> -Infinity
+fmax36783 fma 1 -Inf -0 -> -Infinity
+fmax36784 fma 1 -Inf 0 -> -Infinity
+fmax36785 fma 1 -Inf 1 -> -Infinity
+fmax36786 fma 1 -Inf 1000 -> -Infinity
+fmax36787 fma 1 -1000 -Inf -> -Infinity
+fmax36788 fma 1 -Inf -Inf -> -Infinity
+fmax36789 fma 1 -1 -Inf -> -Infinity
+fmax36790 fma 1 -0 -Inf -> -Infinity
+fmax36791 fma 1 0 -Inf -> -Infinity
+fmax36792 fma 1 1 -Inf -> -Infinity
+fmax36793 fma 1 1000 -Inf -> -Infinity
+fmax36794 fma 1 Inf -Inf -> NaN Invalid_operation
+
+fmax36800 fma 1 Inf -Inf -> NaN Invalid_operation
+fmax36801 fma 1 Inf -1000 -> Infinity
+fmax36802 fma 1 Inf -1 -> Infinity
+fmax36803 fma 1 Inf -0 -> Infinity
+fmax36804 fma 1 Inf 0 -> Infinity
+fmax36805 fma 1 Inf 1 -> Infinity
+fmax36806 fma 1 Inf 1000 -> Infinity
+fmax36807 fma 1 Inf Inf -> Infinity
+fmax36808 fma 1 -1000 Inf -> Infinity
+fmax36809 fma 1 -Inf Inf -> NaN Invalid_operation
+fmax36810 fma 1 -1 Inf -> Infinity
+fmax36811 fma 1 -0 Inf -> Infinity
+fmax36812 fma 1 0 Inf -> Infinity
+fmax36813 fma 1 1 Inf -> Infinity
+fmax36814 fma 1 1000 Inf -> Infinity
+fmax36815 fma 1 Inf Inf -> Infinity
+
+fmax36821 fma 1 NaN -Inf -> NaN
+fmax36822 fma 1 NaN -1000 -> NaN
+fmax36823 fma 1 NaN -1 -> NaN
+fmax36824 fma 1 NaN -0 -> NaN
+fmax36825 fma 1 NaN 0 -> NaN
+fmax36826 fma 1 NaN 1 -> NaN
+fmax36827 fma 1 NaN 1000 -> NaN
+fmax36828 fma 1 NaN Inf -> NaN
+fmax36829 fma 1 NaN NaN -> NaN
+fmax36830 fma 1 -Inf NaN -> NaN
+fmax36831 fma 1 -1000 NaN -> NaN
+fmax36832 fma 1 -1 NaN -> NaN
+fmax36833 fma 1 -0 NaN -> NaN
+fmax36834 fma 1 0 NaN -> NaN
+fmax36835 fma 1 1 NaN -> NaN
+fmax36836 fma 1 1000 NaN -> NaN
+fmax36837 fma 1 Inf NaN -> NaN
+
+fmax36841 fma 1 sNaN -Inf -> NaN Invalid_operation
+fmax36842 fma 1 sNaN -1000 -> NaN Invalid_operation
+fmax36843 fma 1 sNaN -1 -> NaN Invalid_operation
+fmax36844 fma 1 sNaN -0 -> NaN Invalid_operation
+fmax36845 fma 1 sNaN 0 -> NaN Invalid_operation
+fmax36846 fma 1 sNaN 1 -> NaN Invalid_operation
+fmax36847 fma 1 sNaN 1000 -> NaN Invalid_operation
+fmax36848 fma 1 sNaN NaN -> NaN Invalid_operation
+fmax36849 fma 1 sNaN sNaN -> NaN Invalid_operation
+fmax36850 fma 1 NaN sNaN -> NaN Invalid_operation
+fmax36851 fma 1 -Inf sNaN -> NaN Invalid_operation
+fmax36852 fma 1 -1000 sNaN -> NaN Invalid_operation
+fmax36853 fma 1 -1 sNaN -> NaN Invalid_operation
+fmax36854 fma 1 -0 sNaN -> NaN Invalid_operation
+fmax36855 fma 1 0 sNaN -> NaN Invalid_operation
+fmax36856 fma 1 1 sNaN -> NaN Invalid_operation
+fmax36857 fma 1 1000 sNaN -> NaN Invalid_operation
+fmax36858 fma 1 Inf sNaN -> NaN Invalid_operation
+fmax36859 fma 1 NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+fmax36861 fma 1 NaN1 -Inf -> NaN1
+fmax36862 fma 1 +NaN2 -1000 -> NaN2
+fmax36863 fma 1 NaN3 1000 -> NaN3
+fmax36864 fma 1 NaN4 Inf -> NaN4
+fmax36865 fma 1 NaN5 +NaN6 -> NaN5
+fmax36866 fma 1 -Inf NaN7 -> NaN7
+fmax36867 fma 1 -1000 NaN8 -> NaN8
+fmax36868 fma 1 1000 NaN9 -> NaN9
+fmax36869 fma 1 Inf +NaN10 -> NaN10
+fmax36871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
+fmax36872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
+fmax36873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
+fmax36874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
+fmax36875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
+fmax36876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
+fmax36877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
+fmax36878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
+fmax36879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
+fmax36880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
+fmax36881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
+fmax36882 fma 1 -NaN26 NaN28 -> -NaN26
+fmax36883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+fmax36884 fma 1 1000 -NaN30 -> -NaN30
+fmax36885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- now the case where we can get underflow but the result is normal
+-- [note this can't happen if the operands are also bounded, as we
+-- cannot represent 1E-399, for example]
+
+fmax36571 fma 1 1E-383 0 -> 1E-383
+fmax36572 fma 1 1E-384 0 -> 1E-384 Subnormal
+fmax36573 fma 1 1E-383 1E-384 -> 1.1E-383
+fmax36574 subtract 1E-383 1E-384 -> 9E-384 Subnormal
+
+-- Here we explore the boundary of rounding a subnormal to Nmin
+fmax36575 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
+fmax36576 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
+fmax36577 subtract 1E-383 1E-399 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax36578 subtract 1E-383 1E-400 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax36579 subtract 1E-383 1E-401 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax36580 subtract 1E-383 1E-402 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+
+-- check overflow edge case
+-- 1234567890123456
+fmax36972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
+fmax36973 fma 1 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
+fmax36974 fma 1 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
+fmax36975 fma 1 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
+fmax36976 fma 1 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
+fmax36977 fma 1 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
+fmax36978 fma 1 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
+fmax36979 fma 1 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
+fmax36980 fma 1 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
+fmax36981 fma 1 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
+fmax36982 fma 1 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
+fmax36983 fma 1 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
+fmax36984 fma 1 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
+
+fmax36985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
+fmax36986 fma 1 -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
+fmax36987 fma 1 -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
+fmax36988 fma 1 -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
+fmax36989 fma 1 -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
+fmax36990 fma 1 -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
+fmax36991 fma 1 -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
+fmax36992 fma 1 -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
+fmax36993 fma 1 -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
+fmax36994 fma 1 -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
+fmax36995 fma 1 -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
+fmax36996 fma 1 -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
+fmax36997 fma 1 -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+fmax361100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
+fmax361101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
+fmax361103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
+fmax361104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
+fmax361105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
+fmax361106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
+fmax361107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
+fmax361108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
+fmax361109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+fmax361110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
+fmax361111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
+fmax361113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
+fmax361114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
+fmax361115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
+fmax361116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
+fmax361117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
+fmax361118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
+fmax361119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+fmax361300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
+fmax361310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
+fmax361311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
+fmax361312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
+fmax361313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
+fmax361314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
+fmax361315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
+fmax361316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
+fmax361317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
+fmax361318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
+fmax361319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
+fmax361320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
+fmax361321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
+fmax361322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
+fmax361323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
+fmax361324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
+fmax361325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
+fmax361339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
+
+fmax361340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
+fmax361341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
+
+fmax361349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
+fmax361350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
+fmax361351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
+fmax361352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
+fmax361353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
+fmax361354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
+fmax361355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
+fmax361356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
+fmax361357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
+fmax361358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
+fmax361359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
+fmax361360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
+fmax361361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
+fmax361362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
+fmax361363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
+fmax361364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
+fmax361365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
+fmax361380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
+fmax361381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
+fmax361382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
+fmax361396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+fmax361420 fma 1 0 1.123456789012345 -> 1.123456789012345
+fmax361421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
+fmax361422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
+fmax361423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
+fmax361424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
+fmax361425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
+fmax361426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
+fmax361427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
+fmax361428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
+fmax361429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
+fmax361430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
+fmax361431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
+fmax361432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
+fmax361433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
+fmax361434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
+fmax361435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
+fmax361436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
+fmax361437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
+fmax361438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
+fmax361439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
+
+-- same, reversed 0
+fmax361440 fma 1 1.123456789012345 0 -> 1.123456789012345
+fmax361441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
+fmax361442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
+fmax361443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
+fmax361444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
+fmax361445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
+fmax361446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
+fmax361447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
+fmax361448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
+fmax361449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
+fmax361450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
+fmax361451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
+fmax361452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
+fmax361453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
+fmax361454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
+fmax361455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
+fmax361456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
+fmax361457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
+fmax361458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
+fmax361459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
+
+-- same, Es on the 0
+fmax361460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
+fmax361461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
+fmax361462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
+fmax361463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
+fmax361464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
+fmax361465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
+fmax361466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
+fmax361467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
+fmax361468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
+fmax361469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
+fmax361470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
+fmax361471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
+fmax361472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
+fmax361473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
+fmax361474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
+fmax361475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
+-- next four flag Rounded because the 0 extends the result
+fmax361476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
+fmax361477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
+fmax361478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
+fmax361479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+fmax361500 fma 1 0 0E-19 -> 0E-19
+fmax361501 fma 1 -0 0E-19 -> 0E-19
+fmax361502 fma 1 0 -0E-19 -> 0E-19
+fmax361503 fma 1 -0 -0E-19 -> -0E-19
+fmax361504 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361505 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361506 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361507 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361511 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361512 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361513 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361514 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361515 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361516 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361517 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361518 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: half_down
+-- exact zeros from zeros
+fmax361520 fma 1 0 0E-19 -> 0E-19
+fmax361521 fma 1 -0 0E-19 -> 0E-19
+fmax361522 fma 1 0 -0E-19 -> 0E-19
+fmax361523 fma 1 -0 -0E-19 -> -0E-19
+fmax361524 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361525 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361526 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361527 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361531 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361532 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361533 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361534 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361535 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361536 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361537 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361538 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: half_even
+-- exact zeros from zeros
+fmax361540 fma 1 0 0E-19 -> 0E-19
+fmax361541 fma 1 -0 0E-19 -> 0E-19
+fmax361542 fma 1 0 -0E-19 -> 0E-19
+fmax361543 fma 1 -0 -0E-19 -> -0E-19
+fmax361544 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361545 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361546 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361547 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361551 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361552 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361553 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361554 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361555 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361556 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361557 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361558 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: up
+-- exact zeros from zeros
+fmax361560 fma 1 0 0E-19 -> 0E-19
+fmax361561 fma 1 -0 0E-19 -> 0E-19
+fmax361562 fma 1 0 -0E-19 -> 0E-19
+fmax361563 fma 1 -0 -0E-19 -> -0E-19
+fmax361564 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361565 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361566 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361567 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361571 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361572 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361573 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+fmax361574 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+-- some exact zeros from non-zeros
+fmax361575 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361576 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361577 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361578 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
+
+rounding: down
+-- exact zeros from zeros
+fmax361580 fma 1 0 0E-19 -> 0E-19
+fmax361581 fma 1 -0 0E-19 -> 0E-19
+fmax361582 fma 1 0 -0E-19 -> 0E-19
+fmax361583 fma 1 -0 -0E-19 -> -0E-19
+fmax361584 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361585 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361586 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361587 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361591 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361592 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361593 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361594 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361595 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361596 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361597 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361598 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: ceiling
+-- exact zeros from zeros
+fmax361600 fma 1 0 0E-19 -> 0E-19
+fmax361601 fma 1 -0 0E-19 -> 0E-19
+fmax361602 fma 1 0 -0E-19 -> 0E-19
+fmax361603 fma 1 -0 -0E-19 -> -0E-19
+fmax361604 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361605 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361606 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361607 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361611 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361612 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361613 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361614 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361615 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361616 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361617 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361618 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+fmax361620 fma 1 0 0E-19 -> 0E-19
+fmax361621 fma 1 -0 0E-19 -> -0E-19 -- *
+fmax361622 fma 1 0 -0E-19 -> -0E-19 -- *
+fmax361623 fma 1 -0 -0E-19 -> -0E-19
+fmax361624 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361625 fma 1 -0E-400 0E-19 -> -0E-398 Clamped -- *
+fmax361626 fma 1 0E-400 -0E-19 -> -0E-398 Clamped -- *
+fmax361627 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361631 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361632 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361633 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+fmax361634 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+-- some exact zeros from non-zeros
+fmax361635 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361636 fma 1 -1E-401 1E-401 -> -0E-398 Clamped -- *
+fmax361637 fma 1 1E-401 -1E-401 -> -0E-398 Clamped -- *
+fmax361638 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+fmax361701 fma 1 130E-2 120E-2 -> 2.50
+fmax361702 fma 1 130E-2 12E-1 -> 2.50
+fmax361703 fma 1 130E-2 1E0 -> 2.30
+fmax361704 fma 1 1E2 1E4 -> 1.01E+4
+fmax361705 subtract 130E-2 120E-2 -> 0.10
+fmax361706 subtract 130E-2 12E-1 -> 0.10
+fmax361707 subtract 130E-2 1E0 -> 0.30
+fmax361708 subtract 1E2 1E4 -> -9.9E+3
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+fmax362001 fma 1 1234567890123456 1 -> 1234567890123457
+fmax362002 fma 1 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
+fmax362003 fma 1 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
+fmax362004 fma 1 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
+fmax362005 fma 1 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
+fmax362006 fma 1 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
+fmax362007 fma 1 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
+fmax362008 fma 1 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
+fmax362009 fma 1 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
+fmax362010 fma 1 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
+fmax362011 fma 1 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
+fmax362012 fma 1 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
+fmax362013 fma 1 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
+fmax362014 fma 1 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
+fmax362015 fma 1 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
+fmax362016 fma 1 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
+fmax362017 fma 1 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
+fmax362018 fma 1 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
+fmax362019 fma 1 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
+fmax362020 fma 1 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
+fmax362021 fma 1 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
+
+-- widening second argument at gap
+fmax362030 fma 1 12345678 1 -> 12345679
+fmax362031 fma 1 12345678 0.1 -> 12345678.1
+fmax362032 fma 1 12345678 0.12 -> 12345678.12
+fmax362033 fma 1 12345678 0.123 -> 12345678.123
+fmax362034 fma 1 12345678 0.1234 -> 12345678.1234
+fmax362035 fma 1 12345678 0.12345 -> 12345678.12345
+fmax362036 fma 1 12345678 0.123456 -> 12345678.123456
+fmax362037 fma 1 12345678 0.1234567 -> 12345678.1234567
+fmax362038 fma 1 12345678 0.12345678 -> 12345678.12345678
+fmax362039 fma 1 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
+fmax362040 fma 1 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
+fmax362041 fma 1 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
+fmax362042 fma 1 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
+fmax362043 fma 1 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
+fmax362044 fma 1 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
+fmax362045 fma 1 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
+fmax362046 fma 1 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
+fmax362047 fma 1 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
+fmax362048 fma 1 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
+fmax362049 fma 1 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+fmax362050 fma 1 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
+fmax362051 fma 1 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
+fmax362052 fma 1 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
+fmax362053 fma 1 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
+fmax362054 fma 1 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
+fmax362055 fma 1 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
+fmax362056 fma 1 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
+fmax362057 fma 1 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
+fmax362060 fma 1 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
+fmax362061 fma 1 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
+fmax362062 fma 1 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
+fmax362063 fma 1 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
+fmax362064 fma 1 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
+fmax362065 fma 1 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
+fmax362066 fma 1 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
+fmax362067 fma 1 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+fmax362070 fma 1 12345678 1E-8 -> 12345678.00000001
+fmax362071 fma 1 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
+fmax362072 fma 1 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
+fmax362073 fma 1 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
+fmax362074 fma 1 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
+fmax362075 fma 1 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
+fmax362076 fma 1 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
+fmax362077 fma 1 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
+fmax362078 fma 1 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
+fmax362079 fma 1 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
+fmax362080 fma 1 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
+fmax362081 fma 1 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
+fmax362082 fma 1 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
+fmax362083 fma 1 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
+fmax362084 fma 1 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
+fmax362085 fma 1 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
+fmax362086 fma 1 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
+fmax362087 fma 1 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
+fmax362088 fma 1 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
+fmax362089 fma 1 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
+
+-- payload decapitate x3
+precision: 5
+fmax363000 fma 1 1 sNaN1234567890 -> NaN67890 Invalid_operation
+fmax363001 fma 1 -sNaN1234512345 1 -> -NaN12345 Invalid_operation
+fmax363002 fma sNaN1234554321 1 1 -> NaN54321 Invalid_operation
+
+-- Null tests
+fmax39990 fma 1 10 # -> NaN Invalid_operation
+fmax39991 fma 1 # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/invert.decTest b/Lib/test/decimaltestdata/invert.decTest
index a2f7be5a77..9ef5a9137c 100644
--- a/Lib/test/decimaltestdata/invert.decTest
+++ b/Lib/test/decimaltestdata/invert.decTest
@@ -1,176 +1,176 @@
-------------------------------------------------------------------------
--- invert.decTest -- digitwise logical INVERT --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check (truth table), and examples from decArith
-invx001 invert 0 -> 111111111
-invx002 invert 1 -> 111111110
-invx003 invert 10 -> 111111101
-invx004 invert 111111111 -> 0
-invx005 invert 000000000 -> 111111111
-invx006 invert 101010101 -> '10101010'
--- and at msd and msd-1
-invx007 invert 000000000 -> 111111111
-invx009 invert 100000000 -> 11111111
-invx011 invert 000000000 -> 111111111
-invx013 invert 010000000 -> 101111111
-
--- Various lengths
--- 123456789 123456789
-invx021 invert 111111111 -> 0
-invx022 invert 111111111111 -> 0
-invx023 invert 11111111 -> 100000000
-invx025 invert 1111111 -> 110000000
-invx026 invert 111111 -> 111000000
-invx027 invert 11111 -> 111100000
-invx028 invert 1111 -> 111110000
-invx029 invert 111 -> 111111000
-invx031 invert 11 -> 111111100
-invx032 invert 1 -> 111111110
-invx033 invert 111111111111 -> 0
-invx034 invert 11111111111 -> 0
-invx035 invert 1111111111 -> 0
-invx036 invert 111111111 -> 0
-
-invx080 invert 011111111 -> 100000000
-invx081 invert 101111111 -> 10000000
-invx082 invert 110111111 -> 1000000
-invx083 invert 111011111 -> 100000
-invx084 invert 111101111 -> 10000
-invx085 invert 111110111 -> 1000
-invx086 invert 111111011 -> 100
-invx087 invert 111111101 -> 10
-invx088 invert 111111110 -> 1
-invx089 invert 011111011 -> 100000100
-invx090 invert 101111101 -> 10000010
-invx091 invert 110111110 -> 1000001
-invx092 invert 111011101 -> 100010
-invx093 invert 111101011 -> 10100
-invx094 invert 111110111 -> 1000
-invx095 invert 111101011 -> 10100
-invx096 invert 111011101 -> 100010
-invx097 invert 110111110 -> 1000001
-invx098 invert 101111101 -> 10000010
-invx099 invert 011111011 -> 100000100
-
--- non-0/1 should not be accepted, nor should signs
-invx220 invert 111111112 -> NaN Invalid_operation
-invx221 invert 333333333 -> NaN Invalid_operation
-invx222 invert 555555555 -> NaN Invalid_operation
-invx223 invert 777777777 -> NaN Invalid_operation
-invx224 invert 999999999 -> NaN Invalid_operation
-invx225 invert 222222222 -> NaN Invalid_operation
-invx226 invert 444444444 -> NaN Invalid_operation
-invx227 invert 666666666 -> NaN Invalid_operation
-invx228 invert 888888888 -> NaN Invalid_operation
-invx229 invert 999999999 -> NaN Invalid_operation
-invx230 invert 999999999 -> NaN Invalid_operation
-invx231 invert 999999999 -> NaN Invalid_operation
-invx232 invert 999999999 -> NaN Invalid_operation
--- a few randoms
-invx240 invert 567468689 -> NaN Invalid_operation
-invx241 invert 567367689 -> NaN Invalid_operation
-invx242 invert -631917772 -> NaN Invalid_operation
-invx243 invert -756253257 -> NaN Invalid_operation
-invx244 invert 835590149 -> NaN Invalid_operation
--- test MSD
-invx250 invert 200000000 -> NaN Invalid_operation
-invx251 invert 300000000 -> NaN Invalid_operation
-invx252 invert 400000000 -> NaN Invalid_operation
-invx253 invert 500000000 -> NaN Invalid_operation
-invx254 invert 600000000 -> NaN Invalid_operation
-invx255 invert 700000000 -> NaN Invalid_operation
-invx256 invert 800000000 -> NaN Invalid_operation
-invx257 invert 900000000 -> NaN Invalid_operation
--- test MSD-1
-invx270 invert 021000000 -> NaN Invalid_operation
-invx271 invert 030100000 -> NaN Invalid_operation
-invx272 invert 040010000 -> NaN Invalid_operation
-invx273 invert 050001000 -> NaN Invalid_operation
-invx274 invert 160000100 -> NaN Invalid_operation
-invx275 invert 170000010 -> NaN Invalid_operation
-invx276 invert 180000000 -> NaN Invalid_operation
-invx277 invert 190000000 -> NaN Invalid_operation
--- test LSD
-invx280 invert 000000002 -> NaN Invalid_operation
-invx281 invert 000000003 -> NaN Invalid_operation
-invx282 invert 000000004 -> NaN Invalid_operation
-invx283 invert 000000005 -> NaN Invalid_operation
-invx284 invert 101000006 -> NaN Invalid_operation
-invx285 invert 100100007 -> NaN Invalid_operation
-invx286 invert 100010008 -> NaN Invalid_operation
-invx287 invert 100001009 -> NaN Invalid_operation
--- test Middie
-invx288 invert 000020000 -> NaN Invalid_operation
-invx289 invert 000030001 -> NaN Invalid_operation
-invx290 invert 000040000 -> NaN Invalid_operation
-invx291 invert 000050000 -> NaN Invalid_operation
-invx292 invert 101060000 -> NaN Invalid_operation
-invx293 invert 100170010 -> NaN Invalid_operation
-invx294 invert 100080100 -> NaN Invalid_operation
-invx295 invert 100091000 -> NaN Invalid_operation
--- signs
-invx296 invert -100001000 -> NaN Invalid_operation
-invx299 invert 100001000 -> 11110111
-
--- Nmax, Nmin, Ntiny
-invx341 invert 9.99999999E+999 -> NaN Invalid_operation
-invx342 invert 1E-999 -> NaN Invalid_operation
-invx343 invert 1.00000000E-999 -> NaN Invalid_operation
-invx344 invert 1E-1007 -> NaN Invalid_operation
-invx345 invert -1E-1007 -> NaN Invalid_operation
-invx346 invert -1.00000000E-999 -> NaN Invalid_operation
-invx347 invert -1E-999 -> NaN Invalid_operation
-invx348 invert -9.99999999E+999 -> NaN Invalid_operation
-
--- A few other non-integers
-invx361 invert 1.0 -> NaN Invalid_operation
-invx362 invert 1E+1 -> NaN Invalid_operation
-invx363 invert 0.0 -> NaN Invalid_operation
-invx364 invert 0E+1 -> NaN Invalid_operation
-invx365 invert 9.9 -> NaN Invalid_operation
-invx366 invert 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-invx788 invert -Inf -> NaN Invalid_operation
-invx794 invert Inf -> NaN Invalid_operation
-invx821 invert NaN -> NaN Invalid_operation
-invx841 invert sNaN -> NaN Invalid_operation
--- propagating NaNs
-invx861 invert NaN1 -> NaN Invalid_operation
-invx862 invert +NaN2 -> NaN Invalid_operation
-invx863 invert NaN3 -> NaN Invalid_operation
-invx864 invert NaN4 -> NaN Invalid_operation
-invx865 invert NaN5 -> NaN Invalid_operation
-invx871 invert sNaN11 -> NaN Invalid_operation
-invx872 invert sNaN12 -> NaN Invalid_operation
-invx873 invert sNaN13 -> NaN Invalid_operation
-invx874 invert sNaN14 -> NaN Invalid_operation
-invx875 invert sNaN15 -> NaN Invalid_operation
-invx876 invert NaN16 -> NaN Invalid_operation
-invx881 invert +NaN25 -> NaN Invalid_operation
-invx882 invert -NaN26 -> NaN Invalid_operation
-invx883 invert -sNaN27 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- invert.decTest -- digitwise logical INVERT --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check (truth table), and examples from decArith
+invx001 invert 0 -> 111111111
+invx002 invert 1 -> 111111110
+invx003 invert 10 -> 111111101
+invx004 invert 111111111 -> 0
+invx005 invert 000000000 -> 111111111
+invx006 invert 101010101 -> '10101010'
+-- and at msd and msd-1
+invx007 invert 000000000 -> 111111111
+invx009 invert 100000000 -> 11111111
+invx011 invert 000000000 -> 111111111
+invx013 invert 010000000 -> 101111111
+
+-- Various lengths
+-- 123456789 123456789
+invx021 invert 111111111 -> 0
+invx022 invert 111111111111 -> 0
+invx023 invert 11111111 -> 100000000
+invx025 invert 1111111 -> 110000000
+invx026 invert 111111 -> 111000000
+invx027 invert 11111 -> 111100000
+invx028 invert 1111 -> 111110000
+invx029 invert 111 -> 111111000
+invx031 invert 11 -> 111111100
+invx032 invert 1 -> 111111110
+invx033 invert 111111111111 -> 0
+invx034 invert 11111111111 -> 0
+invx035 invert 1111111111 -> 0
+invx036 invert 111111111 -> 0
+
+invx080 invert 011111111 -> 100000000
+invx081 invert 101111111 -> 10000000
+invx082 invert 110111111 -> 1000000
+invx083 invert 111011111 -> 100000
+invx084 invert 111101111 -> 10000
+invx085 invert 111110111 -> 1000
+invx086 invert 111111011 -> 100
+invx087 invert 111111101 -> 10
+invx088 invert 111111110 -> 1
+invx089 invert 011111011 -> 100000100
+invx090 invert 101111101 -> 10000010
+invx091 invert 110111110 -> 1000001
+invx092 invert 111011101 -> 100010
+invx093 invert 111101011 -> 10100
+invx094 invert 111110111 -> 1000
+invx095 invert 111101011 -> 10100
+invx096 invert 111011101 -> 100010
+invx097 invert 110111110 -> 1000001
+invx098 invert 101111101 -> 10000010
+invx099 invert 011111011 -> 100000100
+
+-- non-0/1 should not be accepted, nor should signs
+invx220 invert 111111112 -> NaN Invalid_operation
+invx221 invert 333333333 -> NaN Invalid_operation
+invx222 invert 555555555 -> NaN Invalid_operation
+invx223 invert 777777777 -> NaN Invalid_operation
+invx224 invert 999999999 -> NaN Invalid_operation
+invx225 invert 222222222 -> NaN Invalid_operation
+invx226 invert 444444444 -> NaN Invalid_operation
+invx227 invert 666666666 -> NaN Invalid_operation
+invx228 invert 888888888 -> NaN Invalid_operation
+invx229 invert 999999999 -> NaN Invalid_operation
+invx230 invert 999999999 -> NaN Invalid_operation
+invx231 invert 999999999 -> NaN Invalid_operation
+invx232 invert 999999999 -> NaN Invalid_operation
+-- a few randoms
+invx240 invert 567468689 -> NaN Invalid_operation
+invx241 invert 567367689 -> NaN Invalid_operation
+invx242 invert -631917772 -> NaN Invalid_operation
+invx243 invert -756253257 -> NaN Invalid_operation
+invx244 invert 835590149 -> NaN Invalid_operation
+-- test MSD
+invx250 invert 200000000 -> NaN Invalid_operation
+invx251 invert 300000000 -> NaN Invalid_operation
+invx252 invert 400000000 -> NaN Invalid_operation
+invx253 invert 500000000 -> NaN Invalid_operation
+invx254 invert 600000000 -> NaN Invalid_operation
+invx255 invert 700000000 -> NaN Invalid_operation
+invx256 invert 800000000 -> NaN Invalid_operation
+invx257 invert 900000000 -> NaN Invalid_operation
+-- test MSD-1
+invx270 invert 021000000 -> NaN Invalid_operation
+invx271 invert 030100000 -> NaN Invalid_operation
+invx272 invert 040010000 -> NaN Invalid_operation
+invx273 invert 050001000 -> NaN Invalid_operation
+invx274 invert 160000100 -> NaN Invalid_operation
+invx275 invert 170000010 -> NaN Invalid_operation
+invx276 invert 180000000 -> NaN Invalid_operation
+invx277 invert 190000000 -> NaN Invalid_operation
+-- test LSD
+invx280 invert 000000002 -> NaN Invalid_operation
+invx281 invert 000000003 -> NaN Invalid_operation
+invx282 invert 000000004 -> NaN Invalid_operation
+invx283 invert 000000005 -> NaN Invalid_operation
+invx284 invert 101000006 -> NaN Invalid_operation
+invx285 invert 100100007 -> NaN Invalid_operation
+invx286 invert 100010008 -> NaN Invalid_operation
+invx287 invert 100001009 -> NaN Invalid_operation
+-- test Middie
+invx288 invert 000020000 -> NaN Invalid_operation
+invx289 invert 000030001 -> NaN Invalid_operation
+invx290 invert 000040000 -> NaN Invalid_operation
+invx291 invert 000050000 -> NaN Invalid_operation
+invx292 invert 101060000 -> NaN Invalid_operation
+invx293 invert 100170010 -> NaN Invalid_operation
+invx294 invert 100080100 -> NaN Invalid_operation
+invx295 invert 100091000 -> NaN Invalid_operation
+-- signs
+invx296 invert -100001000 -> NaN Invalid_operation
+invx299 invert 100001000 -> 11110111
+
+-- Nmax, Nmin, Ntiny
+invx341 invert 9.99999999E+999 -> NaN Invalid_operation
+invx342 invert 1E-999 -> NaN Invalid_operation
+invx343 invert 1.00000000E-999 -> NaN Invalid_operation
+invx344 invert 1E-1007 -> NaN Invalid_operation
+invx345 invert -1E-1007 -> NaN Invalid_operation
+invx346 invert -1.00000000E-999 -> NaN Invalid_operation
+invx347 invert -1E-999 -> NaN Invalid_operation
+invx348 invert -9.99999999E+999 -> NaN Invalid_operation
+
+-- A few other non-integers
+invx361 invert 1.0 -> NaN Invalid_operation
+invx362 invert 1E+1 -> NaN Invalid_operation
+invx363 invert 0.0 -> NaN Invalid_operation
+invx364 invert 0E+1 -> NaN Invalid_operation
+invx365 invert 9.9 -> NaN Invalid_operation
+invx366 invert 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+invx788 invert -Inf -> NaN Invalid_operation
+invx794 invert Inf -> NaN Invalid_operation
+invx821 invert NaN -> NaN Invalid_operation
+invx841 invert sNaN -> NaN Invalid_operation
+-- propagating NaNs
+invx861 invert NaN1 -> NaN Invalid_operation
+invx862 invert +NaN2 -> NaN Invalid_operation
+invx863 invert NaN3 -> NaN Invalid_operation
+invx864 invert NaN4 -> NaN Invalid_operation
+invx865 invert NaN5 -> NaN Invalid_operation
+invx871 invert sNaN11 -> NaN Invalid_operation
+invx872 invert sNaN12 -> NaN Invalid_operation
+invx873 invert sNaN13 -> NaN Invalid_operation
+invx874 invert sNaN14 -> NaN Invalid_operation
+invx875 invert sNaN15 -> NaN Invalid_operation
+invx876 invert NaN16 -> NaN Invalid_operation
+invx881 invert +NaN25 -> NaN Invalid_operation
+invx882 invert -NaN26 -> NaN Invalid_operation
+invx883 invert -sNaN27 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ln.decTest b/Lib/test/decimaltestdata/ln.decTest
index f602af2377..efcb2a6606 100644
--- a/Lib/test/decimaltestdata/ln.decTest
+++ b/Lib/test/decimaltestdata/ln.decTest
@@ -1,611 +1,611 @@
-------------------------------------------------------------------------
--- ln.decTest -- decimal natural logarithm --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 16
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- basics (examples in specification)
-precision: 9
-lnxs001 ln 0 -> -Infinity
-lnxs002 ln 1.000 -> 0
-lnxs003 ln 2.71828183 -> 1.00000000 Inexact Rounded
-lnxs004 ln 10 -> 2.30258509 Inexact Rounded
-lnxs005 ln +Infinity -> Infinity
-
-
--- basics
-precision: 16
-lnx0001 ln 0 -> -Infinity
-lnx0002 ln 1E-9 -> -20.72326583694641 Inexact Rounded
-lnx0003 ln 0.0007 -> -7.264430222920869 Inexact Rounded
-lnx0004 ln 0.1 -> -2.302585092994046 Inexact Rounded
-lnx0005 ln 0.7 -> -0.3566749439387324 Inexact Rounded
-lnx0006 ln 1 -> 0
-lnx0007 ln 1.000 -> 0
-lnx0008 ln 1.5 -> 0.4054651081081644 Inexact Rounded
-lnx0009 ln 2 -> 0.6931471805599453 Inexact Rounded
-lnx0010 ln 2.718281828459045 -> 0.9999999999999999 Inexact Rounded
-lnx0011 ln 2.718281828459046 -> 1.000000000000000 Inexact Rounded
-lnx0012 ln 2.718281828459047 -> 1.000000000000001 Inexact Rounded
-lnx0013 ln 10 -> 2.302585092994046 Inexact Rounded
-lnx0014 ln 10.5 -> 2.351375257163478 Inexact Rounded
-lnx0015 ln 9999 -> 9.210240366975849 Inexact Rounded
-lnx0016 ln 1E6 -> 13.81551055796427 Inexact Rounded
-lnx0017 ln 1E+9 -> 20.72326583694641 Inexact Rounded
-lnx0018 ln +Infinity -> Infinity
-
--- notable cases
--- negatives
-lnx0021 ln -1E-9 -> NaN Invalid_operation
-lnx0022 ln -0.0007 -> NaN Invalid_operation
-lnx0023 ln -0.1 -> NaN Invalid_operation
-lnx0024 ln -0.7 -> NaN Invalid_operation
-lnx0025 ln -1 -> NaN Invalid_operation
-lnx0026 ln -1.5 -> NaN Invalid_operation
-lnx0027 ln -2 -> NaN Invalid_operation
-lnx0029 ln -10.5 -> NaN Invalid_operation
-lnx0028 ln -9999 -> NaN Invalid_operation
-lnx0030 ln -2.718281828459045 -> NaN Invalid_operation
-lnx0031 ln -2.718281828459046 -> NaN Invalid_operation
-lnx0032 ln -0 -> -Infinity
-lnx0033 ln -0E+17 -> -Infinity
-lnx0034 ln -0E-17 -> -Infinity
--- other zeros
-lnx0041 ln 0 -> -Infinity
-lnx0042 ln 0E+17 -> -Infinity
-lnx0043 ln 0E-17 -> -Infinity
--- infinities
-lnx0045 ln -Infinity -> NaN Invalid_operation
-lnx0046 ln +Infinity -> Infinity
--- ones
-lnx0050 ln 1 -> 0
-lnx0051 ln 1.0 -> 0
-lnx0052 ln 1.000000000000000 -> 0
-lnx0053 ln 1.000000000000000000 -> 0
-
--- lower precision basics
-Precision: 7
-lnx0101 ln 0 -> -Infinity
-lnx0102 ln 1E-9 -> -20.72327 Inexact Rounded
-lnx0103 ln 0.0007 -> -7.264430 Inexact Rounded
-lnx0104 ln 0.1 -> -2.302585 Inexact Rounded
-lnx0105 ln 0.7 -> -0.3566749 Inexact Rounded
-lnx0106 ln 1 -> 0
-lnx0107 ln 1.5 -> 0.4054651 Inexact Rounded
-lnx0108 ln 2 -> 0.6931472 Inexact Rounded
-lnx0109 ln 2.718281828459045 -> 1.000000 Inexact Rounded
-lnx0110 ln 2.718281828459046 -> 1.000000 Inexact Rounded
-lnx0111 ln 2.718281828459047 -> 1.000000 Inexact Rounded
-lnx0112 ln 10 -> 2.302585 Inexact Rounded
-lnx0113 ln 10.5 -> 2.351375 Inexact Rounded
-lnx0114 ln 9999 -> 9.210240 Inexact Rounded
-lnx0115 ln 1E6 -> 13.81551 Inexact Rounded
-lnx0116 ln 1E+9 -> 20.72327 Inexact Rounded
-lnx0117 ln +Infinity -> Infinity
-Precision: 2
-lnx0121 ln 0 -> -Infinity
-lnx0122 ln 1E-9 -> -21 Inexact Rounded
-lnx0123 ln 0.0007 -> -7.3 Inexact Rounded
-lnx0124 ln 0.1 -> -2.3 Inexact Rounded
-lnx0125 ln 0.7 -> -0.36 Inexact Rounded
-lnx0126 ln 1 -> 0
-lnx0127 ln 1.5 -> 0.41 Inexact Rounded
-lnx0128 ln 2 -> 0.69 Inexact Rounded
-lnx0129 ln 2.718281828459045 -> 1.0 Inexact Rounded
-lnx0130 ln 2.718281828459046 -> 1.0 Inexact Rounded
-lnx0131 ln 2.718281828459047 -> 1.0 Inexact Rounded
-lnx0132 ln 10 -> 2.3 Inexact Rounded
-lnx0133 ln 10.5 -> 2.4 Inexact Rounded
-lnx0134 ln 9999 -> 9.2 Inexact Rounded
-lnx0135 ln 1E6 -> 14 Inexact Rounded
-lnx0136 ln 1E+9 -> 21 Inexact Rounded
-lnx0137 ln +Infinity -> Infinity
-Precision: 1
-lnx0141 ln 0 -> -Infinity
-lnx0142 ln 1E-9 -> -2E+1 Inexact Rounded
-lnx0143 ln 0.0007 -> -7 Inexact Rounded
-lnx0144 ln 0.1 -> -2 Inexact Rounded
-lnx0145 ln 0.7 -> -0.4 Inexact Rounded
-lnx0146 ln 1 -> 0
-lnx0147 ln 1.5 -> 0.4 Inexact Rounded
-lnx0148 ln 2 -> 0.7 Inexact Rounded
-lnx0149 ln 2.718281828459045 -> 1 Inexact Rounded
-lnx0150 ln 2.718281828459046 -> 1 Inexact Rounded
-lnx0151 ln 2.718281828459047 -> 1 Inexact Rounded
-lnx0152 ln 10 -> 2 Inexact Rounded
-lnx0153 ln 10.5 -> 2 Inexact Rounded
-lnx0154 ln 9999 -> 9 Inexact Rounded
-lnx0155 ln 1E6 -> 1E+1 Inexact Rounded
-lnx0156 ln 1E+9 -> 2E+1 Inexact Rounded
-lnx0157 ln +Infinity -> Infinity
-
--- group low-precision ln(1)s:
-precision: 1
-lnx0161 ln 1 -> 0
-precision: 2
-lnx0162 ln 1 -> 0
-precision: 3
-lnx0163 ln 1 -> 0
-precision: 4
-lnx0164 ln 1 -> 0
-precision: 5
-lnx0165 ln 1 -> 0
-precision: 6
-lnx0166 ln 1 -> 0
-precision: 7
-lnx0167 ln 1 -> 0
-precision: 8
-lnx0168 ln 1 -> 0
-
--- edge-test ln(2) and ln(10) in case of lookasides
-precision: 45
-lnx201 ln 2 -> 0.693147180559945309417232121458176568075500134 Inexact Rounded
-lnx202 ln 10 -> 2.30258509299404568401799145468436420760110149 Inexact Rounded
-precision: 44
-lnx203 ln 2 -> 0.69314718055994530941723212145817656807550013 Inexact Rounded
-lnx204 ln 10 -> 2.3025850929940456840179914546843642076011015 Inexact Rounded
-precision: 43
-lnx205 ln 2 -> 0.6931471805599453094172321214581765680755001 Inexact Rounded
-lnx206 ln 10 -> 2.302585092994045684017991454684364207601101 Inexact Rounded
-precision: 42
-lnx207 ln 2 -> 0.693147180559945309417232121458176568075500 Inexact Rounded
-lnx208 ln 10 -> 2.30258509299404568401799145468436420760110 Inexact Rounded
-precision: 41
-lnx209 ln 2 -> 0.69314718055994530941723212145817656807550 Inexact Rounded
-lnx210 ln 10 -> 2.3025850929940456840179914546843642076011 Inexact Rounded
-precision: 40
-lnx211 ln 2 -> 0.6931471805599453094172321214581765680755 Inexact Rounded
-lnx212 ln 10 -> 2.302585092994045684017991454684364207601 Inexact Rounded
-precision: 39
-lnx213 ln 2 -> 0.693147180559945309417232121458176568076 Inexact Rounded
-lnx214 ln 10 -> 2.30258509299404568401799145468436420760 Inexact Rounded
-precision: 38
-lnx215 ln 2 -> 0.69314718055994530941723212145817656808 Inexact Rounded
-lnx216 ln 10 -> 2.3025850929940456840179914546843642076 Inexact Rounded
-precision: 37
-lnx217 ln 2 -> 0.6931471805599453094172321214581765681 Inexact Rounded
-lnx218 ln 10 -> 2.302585092994045684017991454684364208 Inexact Rounded
-precision: 36
-lnx219 ln 2 -> 0.693147180559945309417232121458176568 Inexact Rounded
-lnx220 ln 10 -> 2.30258509299404568401799145468436421 Inexact Rounded
-precision: 35
-lnx221 ln 2 -> 0.69314718055994530941723212145817657 Inexact Rounded
-lnx222 ln 10 -> 2.3025850929940456840179914546843642 Inexact Rounded
-precision: 34
-lnx223 ln 2 -> 0.6931471805599453094172321214581766 Inexact Rounded
-lnx224 ln 10 -> 2.302585092994045684017991454684364 Inexact Rounded
-precision: 33
-lnx225 ln 2 -> 0.693147180559945309417232121458177 Inexact Rounded
-lnx226 ln 10 -> 2.30258509299404568401799145468436 Inexact Rounded
-precision: 32
-lnx227 ln 2 -> 0.69314718055994530941723212145818 Inexact Rounded
-lnx228 ln 10 -> 2.3025850929940456840179914546844 Inexact Rounded
-precision: 31
-lnx229 ln 2 -> 0.6931471805599453094172321214582 Inexact Rounded
-lnx230 ln 10 -> 2.302585092994045684017991454684 Inexact Rounded
-precision: 30
-lnx231 ln 2 -> 0.693147180559945309417232121458 Inexact Rounded
-lnx232 ln 10 -> 2.30258509299404568401799145468 Inexact Rounded
-
--- extreme input range values
-maxExponent: 384
-minExponent: -383
-Precision: 16
-
-lnx0901 ln 1e-400 -> -921.0340371976183 Inexact Rounded
-lnx0902 ln 1e+400 -> 921.0340371976183 Inexact Rounded
-lnx0903 ln 1e-999999 -> -2302582.790408953 Inexact Rounded
-lnx0904 ln 1e+999999 -> 2302582.790408953 Inexact Rounded
-lnx0905 ln 1e-1000013 -> -2302615.026600255 Inexact Rounded
-lnx0906 ln 2e-1000013 -> -2302614.333453074 Inexact Rounded
-
-lnx0910 ln 9.999999e+999999 -> 2302585.092993946 Inexact Rounded
-lnx0911 ln 9.9999999e+999999 -> 2302585.092994036 Inexact Rounded
-lnx0912 ln 9.99999999e+999999 -> 2302585.092994045 Inexact Rounded
-lnx0913 ln 9.999999999e+999999 -> 2302585.092994046 Inexact Rounded
-lnx0914 ln 9.999999999999e+999999 -> 2302585.092994046 Inexact Rounded
-lnx0915 ln 9.999999999999999e+999999 -> 2302585.092994046 Inexact Rounded
-lnx0916 ln 9.999999999999999999999999e+999999 -> 2302585.092994046 Inexact Rounded
-
--- randoms
--- P=50, within 0-999
-Precision: 50
-maxExponent: 384
-minExponent: -383
-lnx1501 ln 0.00098800906574486388604608477869812518857023768951 -> -6.9198186844033787995945147836955586009548513043689 Inexact Rounded
-lnx1502 ln 158.15866624664623070184595045304145949900714987827 -> 5.0635987458895647454907806507503825602758392287684 Inexact Rounded
-lnx1503 ln 0.00565661412059571925040285814021799775249288309321 -> -5.1749297776760632102047540300491550931651318975237 Inexact Rounded
-lnx1504 ln 0.00000006914232532620489602008402091666547903180607 -> -16.487098770877825308138976818688771638172333034347 Inexact Rounded
-lnx1505 ln 0.00025380374621297657504661540749355251231770070723 -> -8.2789492423005003205242162741569033124260321954589 Inexact Rounded
-lnx1506 ln 83.033654063877426261108592599182418953442677554806 -> 4.4192459962647137976949249810815698465031609843669 Inexact Rounded
-lnx1507 ln 0.00000000416863228092481651627734668440663678118729 -> -19.295677845122141772791294599714950175284915666430 Inexact Rounded
-lnx1508 ln 0.00000140847873187820570181214271960511080523457669 -> -13.473000349581967189668305314384952251556809480339 Inexact Rounded
-lnx1509 ln 66.176106555181527101630351127583944689752069132522 -> 4.1923194696232505883666171116966137694013431504252 Inexact Rounded
-lnx1510 ln 0.00000000000009899043487403590900111602024562297908 -> -29.943753166877840985821508112917991506656545174163 Inexact Rounded
-lnx1511 ln 0.00000000000324618296721747097510453388683912733569 -> -26.453541281444586819009546418577507163362590139422 Inexact Rounded
-lnx1512 ln 72.646968818463546449499147579023555008392860423385 -> 4.2856116660689646882852128853423566276718230426479 Inexact Rounded
-lnx1513 ln 0.00000000000000066755483124635612574263153825990523 -> -34.942910142802769319262875080398852491588707172483 Inexact Rounded
-lnx1514 ln 61.002910447202398204114909451851111424657671911002 -> 4.1109215752843377323363182051446177066434038096529 Inexact Rounded
-lnx1515 ln 917.06917611331980999227893584010544542312239174774 -> 6.8211829068303114128752453661946446979787826282907 Inexact Rounded
-lnx1516 ln 0.00000000170823794883673083358549749078972003965194 -> -20.187803436976150477297246666771626827057191023004 Inexact Rounded
-lnx1517 ln 0.53731767845358224445809761315159249898566542910649 -> -0.62116577939968409211736413628236285160048357000961 Inexact Rounded
-lnx1518 ln 0.00000000000000008965291392882804161299758708033373 -> -36.950585970980857376081265073276303670820056916206 Inexact Rounded
-lnx1519 ln 0.00000000006990244916026429904498278982530170295668 -> -23.383920429244457578373523508427783144589480420753 Inexact Rounded
-lnx1520 ln 4.0312542977070300070506064666536478373801988540614 -> 1.3940775676592451945795752796421391871302024763305 Inexact Rounded
-lnx1521 ln 271.84991311551875601432518819562391699324632396423 -> 5.6052501239873862517916679747146539808077431873478 Inexact Rounded
-lnx1522 ln 7.4118671629373864667229445746862314443895404818689 -> 2.0030823863706344628239147639318289961917060121141 Inexact Rounded
-lnx1523 ln 0.00000000000002026311452625364905357321664186034258 -> -31.529974180054438792043856877314043794320951134754 Inexact Rounded
-lnx1524 ln 0.00000000000009563398651261756952398250624737809347 -> -29.978248130576972953141284136962670021368834792579 Inexact Rounded
-lnx1525 ln 0.00000000009556772669409858653026558223465197808991 -> -23.071185939748285541228206161472956661196956741186 Inexact Rounded
-lnx1526 ln 6.8441648298027301292342057248737326152250794026761 -> 1.9233964395801946597272589473417948024361005082908 Inexact Rounded
-lnx1527 ln 0.00000000000073059699884439979394945822035704264577 -> -27.944914388353724718836101828677771967128509603158 Inexact Rounded
-lnx1528 ln 0.00000000000000002610078280419082263138064745416787 -> -38.184566367516207885573773320135965798717120735115 Inexact Rounded
-lnx1529 ln 0.00000000000000000150259517166294243088546806083283 -> -41.039337946266676108538170837580051699618334928421 Inexact Rounded
-lnx1530 ln 0.00000000000000087919160541714580707181969708502091 -> -34.667528818827671507514319744047440696187358676848 Inexact Rounded
-lnx1531 ln 0.00000000000395726725120787763271849577708068584598 -> -26.255467416961357741818735787226671938678424748431 Inexact Rounded
-lnx1532 ln 0.00000000002014334901669366218018377213150715938355 -> -24.628146955635359035289123027319969201693737159108 Inexact Rounded
-lnx1533 ln 0.00000008097927101101093117753938766241442896030637 -> -16.329072628469715178637178365710373398203190937454 Inexact Rounded
-lnx1534 ln 0.00000000000017115834162632864392039668116243984176 -> -29.396187292434898225453626794459285157263177528034 Inexact Rounded
-lnx1535 ln 0.39168317593866334087305459933723864294857086105035 -> -0.93730199062757240485836637306785037368746737693029 Inexact Rounded
-lnx1536 ln 79.335036798971515026519630103325369729637514127617 -> 4.3736798570287828823772149735170431010616961976965 Inexact Rounded
-lnx1537 ln 0.00000000000000056004952129926137413602116591493625 -> -35.118506463181870020730685884333000241039028127213 Inexact Rounded
-lnx1538 ln 0.00000006006035907843890918832481099660639553666078 -> -16.627915795747112566532705974853114454405010472043 Inexact Rounded
-lnx1539 ln 0.00000000085242024937414906371333826574632450587590 -> -20.882941460268101080186482230657774997273494107221 Inexact Rounded
-lnx1540 ln 0.00000000000043671099499262350316173246550771951561 -> -28.459504757285639221776305968469058854558726593945 Inexact Rounded
-
--- P=34, within 0-999
-Precision: 34
-lnx1201 ln 0.0086732880815927182997566810334394 -> -4.747507311920844752486938187973721 Inexact Rounded
-lnx1202 ln 0.0007104103693460260609792222569854 -> -7.249667769903503023005549250347695 Inexact Rounded
-lnx1203 ln 786.8398945385105190697541493392742 -> 6.668024790031836340471824147010546 Inexact Rounded
-lnx1204 ln 0.7723073620282687656895190171967399 -> -0.2583726708506850868786816238217326 Inexact Rounded
-lnx1205 ln 0.0061057951517197631287183938412200 -> -5.098516933918797347064454103742635 Inexact Rounded
-lnx1206 ln 0.6181379708184393730103917562498745 -> -0.4810435926903365087463387760350021 Inexact Rounded
-lnx1207 ln 09.13888261229039989110753389096760 -> 2.212538125507975574509563027696021 Inexact Rounded
-lnx1208 ln 802.0105417063143696497292158147174 -> 6.687121752052341737234832203350214 Inexact Rounded
-lnx1209 ln 778.7749710387773713523028497333058 -> 6.657722135126935472086625031413031 Inexact Rounded
-lnx1210 ln 0.0024457295895346502513567679390616 -> -6.013411799940245345321348290398517 Inexact Rounded
-lnx1211 ln 0.0000511296947872828310338864217860 -> -9.881145118237281798081573131711636 Inexact Rounded
-lnx1212 ln 0.0000246803508602554924938685155658 -> -10.60950314264825661825360971430218 Inexact Rounded
-lnx1213 ln 9.027898199253511668242977766616082 -> 2.200319582778899029786017830557293 Inexact Rounded
-lnx1214 ln 0.0991812396542505631850692800904188 -> -2.310806398964672258823043180400384 Inexact Rounded
-lnx1215 ln 0.0000000000070238810143028811223924 -> -25.68170519961636647174714538290075 Inexact Rounded
-lnx1216 ln 2.630101665342826494730394729313167 -> 0.9670225014664367465128243039749559 Inexact Rounded
-lnx1217 ln 0.0056878928594359587691526063254683 -> -5.169415422904037819736637399445096 Inexact Rounded
-lnx1218 ln 567.3436047121057843908106573095590 -> 6.340965124964258486463444360787970 Inexact Rounded
-lnx1219 ln 1.199291248124655996614605745649725 -> 0.1817307557425911805765087755675657 Inexact Rounded
-lnx1220 ln 25.02050448582031098696267479135557 -> 3.219695668137659139544178905459317 Inexact Rounded
-lnx1221 ln 0.0000000000009939597023558756961300 -> -27.63707972996537636504396558259058 Inexact Rounded
-lnx1222 ln 0.0000007988551670159429716506430403 -> -14.04008617542597230988198612376415 Inexact Rounded
-lnx1223 ln 4.681515800176129184873770605589795 -> 1.543621946415383338972124445445748 Inexact Rounded
-lnx1224 ln 15.95126669161103011206658749345781 -> 2.769538242479483539275986395443539 Inexact Rounded
-lnx1225 ln 0.0301626783922211213675457279076066 -> -3.501149933677283341023932281826341 Inexact Rounded
-lnx1226 ln 000.0040544064881821770528475185674 -> -5.507950967557021671647165889608324 Inexact Rounded
-lnx1227 ln 29.01617095935593792095913785100360 -> 3.367853293862745651888450004473297 Inexact Rounded
-lnx1228 ln 78.01836167344736733024804243195323 -> 4.356944205055768575987781375003992 Inexact Rounded
-lnx1229 ln 0.0000000096545319316965321158634893 -> -18.45583840160965814462095477365013 Inexact Rounded
-lnx1230 ln 97.95475237720579752770587185074428 -> 4.584505661612812742208619358214729 Inexact Rounded
-lnx1231 ln 528.0609262050423246402564228432371 -> 6.269211667589138113396583894315956 Inexact Rounded
-lnx1232 ln 0.0000002250064349732969696660452972 -> -15.30713683526963996712167701738724 Inexact Rounded
-lnx1233 ln 47.97063637767998658567199049725754 -> 3.870589081585660692195989854842372 Inexact Rounded
-lnx1234 ln 0.0005394311344541432318853513414361 -> -7.524995428393925934087126702974121 Inexact Rounded
-lnx1235 ln 0.0000000090973385649567471674972633 -> -18.51528393158931783447035004125791 Inexact Rounded
-lnx1236 ln 0.0000000000238776490227576197317977 -> -24.45807828188389561331158879207262 Inexact Rounded
-lnx1237 ln 0.0000236587000231921532145326218758 -> -10.65177964499823314952429277979034 Inexact Rounded
-lnx1238 ln 499.1277448846130709827154556125942 -> 6.212862064761427967461188083514774 Inexact Rounded
-lnx1239 ln 0.0000003960192300284787663712417647 -> -14.74180306619298548093697608293284 Inexact Rounded
-lnx1240 ln 41.08268350829477451667228892495136 -> 3.715586706887278039173584859218960 Inexact Rounded
-
--- P=16, within 0-99
-Precision: 16
-lnx1101 ln 7.964875261033948 -> 2.075041282352241 Inexact Rounded
-lnx1102 ln 13.54527396845394 -> 2.606037701870263 Inexact Rounded
-lnx1103 ln 0.0008026554341331 -> -7.127585034321814 Inexact Rounded
-lnx1104 ln 0.0000030582233261 -> -12.69767642300625 Inexact Rounded
-lnx1105 ln 0.0004477497509672 -> -7.711276073210766 Inexact Rounded
-lnx1106 ln 7.616268622474371 -> 2.030286567675148 Inexact Rounded
-lnx1107 ln 51.58329925806381 -> 3.943197962309569 Inexact Rounded
-lnx1108 ln 0.0018197497951263 -> -6.309056262549345 Inexact Rounded
-lnx1109 ln 2.956282457072984 -> 1.083932552334575 Inexact Rounded
-lnx1110 ln 0.3843325579189906 -> -0.9562470649400558 Inexact Rounded
-lnx1111 ln 0.0074466329265663 -> -4.899993304919237 Inexact Rounded
-lnx1112 ln 0.0003372478532993 -> -7.994692428206378 Inexact Rounded
-lnx1113 ln 0.0084792263167809 -> -4.770136069569271 Inexact Rounded
-lnx1114 ln 5.926756998151102 -> 1.779477182834305 Inexact Rounded
-lnx1115 ln 9.025699152180897 -> 2.200075969604119 Inexact Rounded
-lnx1116 ln 1.910124643533526 -> 0.6471684983238183 Inexact Rounded
-lnx1117 ln 0.8158922711411020 -> -0.2034729533939387 Inexact Rounded
-lnx1118 ln 0.0067080016475322 -> -5.004454189414139 Inexact Rounded
-lnx1119 ln 0.0047583242092716 -> -5.347859729601094 Inexact Rounded
-lnx1120 ln 0.0386647411641339 -> -3.252827175263113 Inexact Rounded
-lnx1121 ln 0.0050226427841761 -> -5.293799032774131 Inexact Rounded
-lnx1122 ln 6.927937541637261 -> 1.935562155866906 Inexact Rounded
-lnx1123 ln 0.0000095745343513 -> -11.55640365579814 Inexact Rounded
-lnx1124 ln 1.602465492956538 -> 0.4715433763243936 Inexact Rounded
-lnx1125 ln 38.98415625087535 -> 3.663155313610213 Inexact Rounded
-lnx1126 ln 5.343182042276734 -> 1.675821363568112 Inexact Rounded
-lnx1127 ln 55.89763703245816 -> 4.023522107934110 Inexact Rounded
-lnx1128 ln 0.7445257810280847 -> -0.2950077988101030 Inexact Rounded
-lnx1129 ln 1.631407314946094 -> 0.4894430257201248 Inexact Rounded
-lnx1130 ln 0.0005462451932602 -> -7.512442611116852 Inexact Rounded
-lnx1131 ln 0.0000864173269362 -> -9.356322359017317 Inexact Rounded
-lnx1132 ln 5.227161719132849 -> 1.653868438439637 Inexact Rounded
-lnx1133 ln 60.57078466941998 -> 4.103812675662452 Inexact Rounded
-lnx1134 ln 0.0992864325333160 -> -2.309746348350318 Inexact Rounded
-lnx1135 ln 09.48564268447325 -> 2.249779359074983 Inexact Rounded
-lnx1136 ln 0.0036106089355634 -> -5.623878840650787 Inexact Rounded
-lnx1137 ln 1.805176865587172 -> 0.5906585734593707 Inexact Rounded
-lnx1138 ln 62.59363259642255 -> 4.136663557220559 Inexact Rounded
-lnx1139 ln 4.373828261137201 -> 1.475638657912000 Inexact Rounded
-lnx1140 ln 0.994483524148738 -> -0.005531747794938690 Inexact Rounded
-
--- P=7, within 0-9
-Precision: 7
-lnx1001 ln 0.0912025 -> -2.394673 Inexact Rounded
-lnx1002 ln 0.9728626 -> -0.02751242 Inexact Rounded
-lnx1003 ln 0.3886032 -> -0.9451965 Inexact Rounded
-lnx1004 ln 8.798639 -> 2.174597 Inexact Rounded
-lnx1005 ln 2.459121 -> 0.8998040 Inexact Rounded
-lnx1006 ln 2.013193 -> 0.6997220 Inexact Rounded
-lnx1007 ln 9.064857 -> 2.204405 Inexact Rounded
-lnx1008 ln 5.796417 -> 1.757240 Inexact Rounded
-lnx1009 ln 0.1143471 -> -2.168517 Inexact Rounded
-lnx1010 ln 0.5341542 -> -0.6270707 Inexact Rounded
-lnx1011 ln 6.693781 -> 1.901179 Inexact Rounded
-lnx1012 ln 0.0081779 -> -4.806320 Inexact Rounded
-lnx1013 ln 8.313616 -> 2.117895 Inexact Rounded
-lnx1014 ln 3.486925 -> 1.249020 Inexact Rounded
-lnx1015 ln 0.1801401 -> -1.714020 Inexact Rounded
-lnx1016 ln 0.5227148 -> -0.6487193 Inexact Rounded
-lnx1017 ln 7.818111 -> 2.056443 Inexact Rounded
-lnx1018 ln 0.0870671 -> -2.441076 Inexact Rounded
-lnx1019 ln 8.153966 -> 2.098504 Inexact Rounded
-lnx1020 ln 2.040975 -> 0.7134276 Inexact Rounded
-lnx1021 ln 1.481642 -> 0.3931509 Inexact Rounded
-lnx1022 ln 0.2610123 -> -1.343188 Inexact Rounded
-lnx1023 ln 0.466723 -> -0.7620193 Inexact Rounded
-lnx1024 ln 0.0518756 -> -2.958907 Inexact Rounded
-lnx1025 ln 2.056410 -> 0.7209617 Inexact Rounded
-lnx1026 ln 0.181522 -> -1.706378 Inexact Rounded
-lnx1027 ln 0.515551 -> -0.6625190 Inexact Rounded
-lnx1028 ln 8.425089 -> 2.131214 Inexact Rounded
-lnx1029 ln 2.077091 -> 0.7309684 Inexact Rounded
-lnx1030 ln 6.212705 -> 1.826596 Inexact Rounded
-lnx1031 ln 5.729343 -> 1.745601 Inexact Rounded
-lnx1032 ln 4.831251 -> 1.575105 Inexact Rounded
-lnx1033 ln 2.029760 -> 0.7079176 Inexact Rounded
-lnx1034 ln 8.615060 -> 2.153512 Inexact Rounded
-lnx1035 ln 0.0611511 -> -2.794407 Inexact Rounded
-lnx1036 ln 5.195269 -> 1.647748 Inexact Rounded
-lnx1037 ln 9.617686 -> 2.263604 Inexact Rounded
-lnx1038 ln 0.0049382 -> -5.310754 Inexact Rounded
-lnx1039 ln 2.786840 -> 1.024908 Inexact Rounded
-lnx1040 ln 0.0091073 -> -4.698679 Inexact Rounded
-
--- from here 3-digit tests are based on reverse exp tests
-precision: 9
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
-lnx001 ln 0 -> -Infinity
-lnx002 ln 0.367879441 -> -1.00000000 Inexact Rounded
-lnx003 ln 1 -> 0
-lnx005 ln 2.71828183 -> 1.00000000 Inexact Rounded
-lnx006 ln 2.00000000 -> 0.693147181 Inexact Rounded
-lnx007 ln +Infinity -> Infinity
-
--- tiny edge cases
-precision: 7
-lnx011 ln 1.105171 -> 0.1000001 Inexact Rounded
-lnx012 ln 1.010050 -> 0.009999835 Inexact Rounded
-lnx013 ln 1.000010 -> 0.000009999950 Inexact Rounded
-lnx014 ln 1.000001 -> 9.999995E-7 Inexact Rounded
-lnx015 ln 1.000000 -> 0
-
--- basic e=0, e=1, e=2, e=4, e>=8 cases
-precision: 7
-lnx041 ln 2.718282 -> 1.000000 Inexact Rounded
-lnx042 ln 0.3678794 -> -1.000000 Inexact Rounded
-lnx043 ln 22026.47 -> 10.00000 Inexact Rounded
-lnx044 ln 0.00004539993 -> -10.00000 Inexact Rounded
-lnx045 ln 2.688117E+43 -> 100.0000 Inexact Rounded
-lnx046 ln 3.720076E-44 -> -100.0000 Inexact Rounded
-lnx047 ln Infinity -> Infinity
-lnx048 ln 0E-389 -> -Infinity
-
--- miscellanea
-precision: 16
-lnx055 ln 2.717658486884572E-236 -> -542.4103112874415 Inexact Rounded
-precision: 17
-lnx056 ln 2.7176584868845721E-236 -> -542.41031128744146 Inexact Rounded
-precision: 18
-lnx057 ln 2.71765848688457211E-236 -> -542.410311287441459 Inexact Rounded
-precision: 19
-lnx058 ln 2.717658486884572112E-236 -> -542.4103112874414592 Inexact Rounded
-precision: 20
-lnx059 ln 2.7176584868845721118E-236 -> -542.41031128744145917 Inexact Rounded
-
--- inputs ending in ..500.., ..499.., ..100.., ..999.. sequences
-precision: 50
-lnx102 ln 0.9999999100000040499998785000027 -> -9.0000000000000000000000033749953829996446124861750E-8 Inexact Rounded
-precision: 30
-lnx103 ln 0.999999910000004049999878500003 -> -8.99999999999999999999997337499E-8 Inexact Rounded
-precision: 29
-lnx104 ln 0.99999991000000404999987850000 -> -9.0000000000000000000002733750E-8 Inexact Rounded
-precision: 28
-lnx105 ln 0.9999999100000040499998785000 -> -9.000000000000000000000273375E-8 Inexact Rounded
-precision: 27
-lnx106 ln 0.999999910000004049999878500 -> -9.00000000000000000000027338E-8 Inexact Rounded
-precision: 26
-lnx107 ln 0.99999991000000404999987850 -> -9.0000000000000000000002734E-8 Inexact Rounded
-precision: 25
-lnx108 ln 0.9999999100000040499998785 -> -9.000000000000000000000273E-8 Inexact Rounded
-precision: 24
-lnx109 ln 0.999999910000004049999879 -> -8.99999999999999995000027E-8 Inexact Rounded
-precision: 23
-lnx110 ln 0.99999991000000404999988 -> -8.9999999999999998500003E-8 Inexact Rounded
-precision: 22
-lnx111 ln 0.9999999100000040499999 -> -8.999999999999997850000E-8 Inexact Rounded
-precision: 21
-lnx112 ln 0.999999910000004050000 -> -8.99999999999998785000E-8 Inexact Rounded
-precision: 20
-lnx113 ln 0.99999991000000405000 -> -8.9999999999999878500E-8 Inexact Rounded
-precision: 19
-lnx114 ln 0.9999999100000040500 -> -8.999999999999987850E-8 Inexact Rounded
-precision: 18
-lnx115 ln 0.999999910000004050 -> -8.99999999999998785E-8 Inexact Rounded
--- next may be a > 0.5ulp case; a more precise answer is:
--- -8.99999999999998784999918E-8
-precision: 17
-lnx116 ln 0.99999991000000405 -> -8.9999999999999878E-8 Inexact Rounded
-precision: 16
-lnx117 ln 0.9999999100000040 -> -9.000000004999988E-8 Inexact Rounded
-precision: 15
-lnx118 ln 0.999999910000004 -> -9.00000000499999E-8 Inexact Rounded
-precision: 14
-lnx119 ln 0.99999991000000 -> -9.0000004050000E-8 Inexact Rounded
-precision: 13
-lnx120 ln 0.9999999100000 -> -9.000000405000E-8 Inexact Rounded
-precision: 12
-lnx121 ln 0.999999910000 -> -9.00000040500E-8 Inexact Rounded
-precision: 11
-lnx122 ln 0.99999991000 -> -9.0000004050E-8 Inexact Rounded
-precision: 10
-lnx123 ln 0.9999999100 -> -9.000000405E-8 Inexact Rounded
-precision: 9
-lnx124 ln 0.999999910 -> -9.00000041E-8 Inexact Rounded
-precision: 8
-lnx125 ln 0.99999991 -> -9.0000004E-8 Inexact Rounded
-precision: 7
-lnx126 ln 0.9999999 -> -1.000000E-7 Inexact Rounded
-precision: 16
-lnx126b ln 0.9999999 -> -1.000000050000003E-7 Inexact Rounded
-precision: 6
-lnx127 ln 0.999999 -> -0.00000100000 Inexact Rounded
-precision: 5
-lnx128 ln 0.99999 -> -0.000010000 Inexact Rounded
-precision: 4
-lnx129 ln 0.9999 -> -0.0001000 Inexact Rounded
-precision: 3
-lnx130 ln 0.999 -> -0.00100 Inexact Rounded
-precision: 2
-lnx131 ln 0.99 -> -0.010 Inexact Rounded
-precision: 1
-lnx132 ln 0.9 -> -0.1 Inexact Rounded
-
-
--- cases near 1 -- 1 2345678901234567890
-precision: 20
-lnx401 ln 2.7182818284589365041 -> 0.99999999999996000000 Inexact Rounded
-lnx402 ln 2.7182818284589636869 -> 0.99999999999997000000 Inexact Rounded
-lnx403 ln 2.7182818284589908697 -> 0.99999999999997999999 Inexact Rounded
-lnx404 ln 2.7182818284590180525 -> 0.99999999999998999998 Inexact Rounded
-lnx405 ln 2.7182818284590452354 -> 1.0000000000000000000 Inexact Rounded
-lnx406 ln 2.7182818284593170635 -> 1.0000000000001000000 Inexact Rounded
-lnx407 ln 2.7182818284595888917 -> 1.0000000000002000000 Inexact Rounded
-precision: 14
-lnx411 ln 2.7182818284589 -> 0.99999999999995 Inexact Rounded
-lnx413 ln 2.7182818284590 -> 0.99999999999998 Inexact Rounded
-lnx416 ln 2.7182818284591 -> 1.0000000000000 Inexact Rounded
-lnx417 ln 2.7182818284592 -> 1.0000000000001 Inexact Rounded
-
--- overflows, including some exp overprecise borderlines
-precision: 7
-maxExponent: 384
-minExponent: -383
-lnx709 ln 9.999999E+384 -> 886.4953 Inexact Rounded
-lnx711 ln 9.999992E+384 -> 886.4953 Inexact Rounded
-precision: 16
-lnx722 ln 9.999999999999999E+384 -> 886.4952608027076 Inexact Rounded
-lnx724 ln 9.999999999999917E+384 -> 886.4952608027076 Inexact Rounded
-lnx726 ln 9.999999999999117E+384 -> 886.4952608027075 Inexact Rounded
--- and more...
-precision: 15
-maxExponent: 999
-minExponent: -999
-lnx731 ln 9.99999999999999E+999 -> 2302.58509299405 Inexact Rounded
--- next may be a > 0.5ulp case; a more precise answer is:
--- 2302.58509299404495001799145442
-lnx732 ln 9.99999999999266E+999 -> 2302.58509299404 Inexact Rounded
-lnx733 ln 9.99999999999265E+999 -> 2302.58509299404 Inexact Rounded
-lnx734 ln 9.99999999999264E+999 -> 2302.58509299404 Inexact Rounded
-
--- subnormals and underflows for exp, including underflow-to-zero edge point
-precision: 7
-maxExponent: 384
-minExponent: -383
-lnx751 ln 0E-389 -> -Infinity
-lnx758 ln 1.000001E-383 -> -881.8901 Inexact Rounded
-lnx759 ln 9.99991E-384 -> -881.8901 Inexact Rounded
-lnx760 ln 4.4605E-385 -> -885.0000 Inexact Rounded
-lnx761 ln 2.221E-386 -> -887.9999 Inexact Rounded
-lnx762 ln 3.01E-387 -> -889.9985 Inexact Rounded
-lnx763 ln 1.7E-388 -> -892.8724 Inexact Rounded
-lnx764 ln 1.5E-388 -> -892.9976 Inexact Rounded
-lnx765 ln 9E-389 -> -893.5084 Inexact Rounded
-lnx766 ln 1E-389 -> -895.7056 Inexact Rounded
-lnx774 ln 0E-389 -> -Infinity
-
--- special values
-lnx820 ln Infinity -> Infinity
-lnx821 ln 0 -> -Infinity
-lnx822 ln NaN -> NaN
-lnx823 ln sNaN -> NaN Invalid_operation
--- propagating NaNs
-lnx824 ln sNaN123 -> NaN123 Invalid_operation
-lnx825 ln -sNaN321 -> -NaN321 Invalid_operation
-lnx826 ln NaN456 -> NaN456
-lnx827 ln -NaN654 -> -NaN654
-lnx828 ln NaN1 -> NaN1
-
--- Invalid operations due to restrictions
--- [next two probably skipped by most test harnesses]
-precision: 100000000
-lnx901 ln 1 -> NaN Invalid_context
-precision: 99999999
-lnx902 ln 0 -> NaN Invalid_context
-
-precision: 9
-maxExponent: 1000000
-minExponent: -999999
-lnx903 ln 1 -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999999
-lnx904 ln 0 -> -Infinity
-maxExponent: 999999
-minExponent: -1000000
-lnx905 ln 1 -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999998
-lnx906 ln 0 -> -Infinity
-
--- payload decapitate
-precision: 5
-lnx910 ln -sNaN1234567890 -> -NaN67890 Invalid_operation
-
--- Null test
-lnx900 ln # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- ln.decTest -- decimal natural logarithm --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 16
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- basics (examples in specification)
+precision: 9
+lnxs001 ln 0 -> -Infinity
+lnxs002 ln 1.000 -> 0
+lnxs003 ln 2.71828183 -> 1.00000000 Inexact Rounded
+lnxs004 ln 10 -> 2.30258509 Inexact Rounded
+lnxs005 ln +Infinity -> Infinity
+
+
+-- basics
+precision: 16
+lnx0001 ln 0 -> -Infinity
+lnx0002 ln 1E-9 -> -20.72326583694641 Inexact Rounded
+lnx0003 ln 0.0007 -> -7.264430222920869 Inexact Rounded
+lnx0004 ln 0.1 -> -2.302585092994046 Inexact Rounded
+lnx0005 ln 0.7 -> -0.3566749439387324 Inexact Rounded
+lnx0006 ln 1 -> 0
+lnx0007 ln 1.000 -> 0
+lnx0008 ln 1.5 -> 0.4054651081081644 Inexact Rounded
+lnx0009 ln 2 -> 0.6931471805599453 Inexact Rounded
+lnx0010 ln 2.718281828459045 -> 0.9999999999999999 Inexact Rounded
+lnx0011 ln 2.718281828459046 -> 1.000000000000000 Inexact Rounded
+lnx0012 ln 2.718281828459047 -> 1.000000000000001 Inexact Rounded
+lnx0013 ln 10 -> 2.302585092994046 Inexact Rounded
+lnx0014 ln 10.5 -> 2.351375257163478 Inexact Rounded
+lnx0015 ln 9999 -> 9.210240366975849 Inexact Rounded
+lnx0016 ln 1E6 -> 13.81551055796427 Inexact Rounded
+lnx0017 ln 1E+9 -> 20.72326583694641 Inexact Rounded
+lnx0018 ln +Infinity -> Infinity
+
+-- notable cases
+-- negatives
+lnx0021 ln -1E-9 -> NaN Invalid_operation
+lnx0022 ln -0.0007 -> NaN Invalid_operation
+lnx0023 ln -0.1 -> NaN Invalid_operation
+lnx0024 ln -0.7 -> NaN Invalid_operation
+lnx0025 ln -1 -> NaN Invalid_operation
+lnx0026 ln -1.5 -> NaN Invalid_operation
+lnx0027 ln -2 -> NaN Invalid_operation
+lnx0029 ln -10.5 -> NaN Invalid_operation
+lnx0028 ln -9999 -> NaN Invalid_operation
+lnx0030 ln -2.718281828459045 -> NaN Invalid_operation
+lnx0031 ln -2.718281828459046 -> NaN Invalid_operation
+lnx0032 ln -0 -> -Infinity
+lnx0033 ln -0E+17 -> -Infinity
+lnx0034 ln -0E-17 -> -Infinity
+-- other zeros
+lnx0041 ln 0 -> -Infinity
+lnx0042 ln 0E+17 -> -Infinity
+lnx0043 ln 0E-17 -> -Infinity
+-- infinities
+lnx0045 ln -Infinity -> NaN Invalid_operation
+lnx0046 ln +Infinity -> Infinity
+-- ones
+lnx0050 ln 1 -> 0
+lnx0051 ln 1.0 -> 0
+lnx0052 ln 1.000000000000000 -> 0
+lnx0053 ln 1.000000000000000000 -> 0
+
+-- lower precision basics
+Precision: 7
+lnx0101 ln 0 -> -Infinity
+lnx0102 ln 1E-9 -> -20.72327 Inexact Rounded
+lnx0103 ln 0.0007 -> -7.264430 Inexact Rounded
+lnx0104 ln 0.1 -> -2.302585 Inexact Rounded
+lnx0105 ln 0.7 -> -0.3566749 Inexact Rounded
+lnx0106 ln 1 -> 0
+lnx0107 ln 1.5 -> 0.4054651 Inexact Rounded
+lnx0108 ln 2 -> 0.6931472 Inexact Rounded
+lnx0109 ln 2.718281828459045 -> 1.000000 Inexact Rounded
+lnx0110 ln 2.718281828459046 -> 1.000000 Inexact Rounded
+lnx0111 ln 2.718281828459047 -> 1.000000 Inexact Rounded
+lnx0112 ln 10 -> 2.302585 Inexact Rounded
+lnx0113 ln 10.5 -> 2.351375 Inexact Rounded
+lnx0114 ln 9999 -> 9.210240 Inexact Rounded
+lnx0115 ln 1E6 -> 13.81551 Inexact Rounded
+lnx0116 ln 1E+9 -> 20.72327 Inexact Rounded
+lnx0117 ln +Infinity -> Infinity
+Precision: 2
+lnx0121 ln 0 -> -Infinity
+lnx0122 ln 1E-9 -> -21 Inexact Rounded
+lnx0123 ln 0.0007 -> -7.3 Inexact Rounded
+lnx0124 ln 0.1 -> -2.3 Inexact Rounded
+lnx0125 ln 0.7 -> -0.36 Inexact Rounded
+lnx0126 ln 1 -> 0
+lnx0127 ln 1.5 -> 0.41 Inexact Rounded
+lnx0128 ln 2 -> 0.69 Inexact Rounded
+lnx0129 ln 2.718281828459045 -> 1.0 Inexact Rounded
+lnx0130 ln 2.718281828459046 -> 1.0 Inexact Rounded
+lnx0131 ln 2.718281828459047 -> 1.0 Inexact Rounded
+lnx0132 ln 10 -> 2.3 Inexact Rounded
+lnx0133 ln 10.5 -> 2.4 Inexact Rounded
+lnx0134 ln 9999 -> 9.2 Inexact Rounded
+lnx0135 ln 1E6 -> 14 Inexact Rounded
+lnx0136 ln 1E+9 -> 21 Inexact Rounded
+lnx0137 ln +Infinity -> Infinity
+Precision: 1
+lnx0141 ln 0 -> -Infinity
+lnx0142 ln 1E-9 -> -2E+1 Inexact Rounded
+lnx0143 ln 0.0007 -> -7 Inexact Rounded
+lnx0144 ln 0.1 -> -2 Inexact Rounded
+lnx0145 ln 0.7 -> -0.4 Inexact Rounded
+lnx0146 ln 1 -> 0
+lnx0147 ln 1.5 -> 0.4 Inexact Rounded
+lnx0148 ln 2 -> 0.7 Inexact Rounded
+lnx0149 ln 2.718281828459045 -> 1 Inexact Rounded
+lnx0150 ln 2.718281828459046 -> 1 Inexact Rounded
+lnx0151 ln 2.718281828459047 -> 1 Inexact Rounded
+lnx0152 ln 10 -> 2 Inexact Rounded
+lnx0153 ln 10.5 -> 2 Inexact Rounded
+lnx0154 ln 9999 -> 9 Inexact Rounded
+lnx0155 ln 1E6 -> 1E+1 Inexact Rounded
+lnx0156 ln 1E+9 -> 2E+1 Inexact Rounded
+lnx0157 ln +Infinity -> Infinity
+
+-- group low-precision ln(1)s:
+precision: 1
+lnx0161 ln 1 -> 0
+precision: 2
+lnx0162 ln 1 -> 0
+precision: 3
+lnx0163 ln 1 -> 0
+precision: 4
+lnx0164 ln 1 -> 0
+precision: 5
+lnx0165 ln 1 -> 0
+precision: 6
+lnx0166 ln 1 -> 0
+precision: 7
+lnx0167 ln 1 -> 0
+precision: 8
+lnx0168 ln 1 -> 0
+
+-- edge-test ln(2) and ln(10) in case of lookasides
+precision: 45
+lnx201 ln 2 -> 0.693147180559945309417232121458176568075500134 Inexact Rounded
+lnx202 ln 10 -> 2.30258509299404568401799145468436420760110149 Inexact Rounded
+precision: 44
+lnx203 ln 2 -> 0.69314718055994530941723212145817656807550013 Inexact Rounded
+lnx204 ln 10 -> 2.3025850929940456840179914546843642076011015 Inexact Rounded
+precision: 43
+lnx205 ln 2 -> 0.6931471805599453094172321214581765680755001 Inexact Rounded
+lnx206 ln 10 -> 2.302585092994045684017991454684364207601101 Inexact Rounded
+precision: 42
+lnx207 ln 2 -> 0.693147180559945309417232121458176568075500 Inexact Rounded
+lnx208 ln 10 -> 2.30258509299404568401799145468436420760110 Inexact Rounded
+precision: 41
+lnx209 ln 2 -> 0.69314718055994530941723212145817656807550 Inexact Rounded
+lnx210 ln 10 -> 2.3025850929940456840179914546843642076011 Inexact Rounded
+precision: 40
+lnx211 ln 2 -> 0.6931471805599453094172321214581765680755 Inexact Rounded
+lnx212 ln 10 -> 2.302585092994045684017991454684364207601 Inexact Rounded
+precision: 39
+lnx213 ln 2 -> 0.693147180559945309417232121458176568076 Inexact Rounded
+lnx214 ln 10 -> 2.30258509299404568401799145468436420760 Inexact Rounded
+precision: 38
+lnx215 ln 2 -> 0.69314718055994530941723212145817656808 Inexact Rounded
+lnx216 ln 10 -> 2.3025850929940456840179914546843642076 Inexact Rounded
+precision: 37
+lnx217 ln 2 -> 0.6931471805599453094172321214581765681 Inexact Rounded
+lnx218 ln 10 -> 2.302585092994045684017991454684364208 Inexact Rounded
+precision: 36
+lnx219 ln 2 -> 0.693147180559945309417232121458176568 Inexact Rounded
+lnx220 ln 10 -> 2.30258509299404568401799145468436421 Inexact Rounded
+precision: 35
+lnx221 ln 2 -> 0.69314718055994530941723212145817657 Inexact Rounded
+lnx222 ln 10 -> 2.3025850929940456840179914546843642 Inexact Rounded
+precision: 34
+lnx223 ln 2 -> 0.6931471805599453094172321214581766 Inexact Rounded
+lnx224 ln 10 -> 2.302585092994045684017991454684364 Inexact Rounded
+precision: 33
+lnx225 ln 2 -> 0.693147180559945309417232121458177 Inexact Rounded
+lnx226 ln 10 -> 2.30258509299404568401799145468436 Inexact Rounded
+precision: 32
+lnx227 ln 2 -> 0.69314718055994530941723212145818 Inexact Rounded
+lnx228 ln 10 -> 2.3025850929940456840179914546844 Inexact Rounded
+precision: 31
+lnx229 ln 2 -> 0.6931471805599453094172321214582 Inexact Rounded
+lnx230 ln 10 -> 2.302585092994045684017991454684 Inexact Rounded
+precision: 30
+lnx231 ln 2 -> 0.693147180559945309417232121458 Inexact Rounded
+lnx232 ln 10 -> 2.30258509299404568401799145468 Inexact Rounded
+
+-- extreme input range values
+maxExponent: 384
+minExponent: -383
+Precision: 16
+
+lnx0901 ln 1e-400 -> -921.0340371976183 Inexact Rounded
+lnx0902 ln 1e+400 -> 921.0340371976183 Inexact Rounded
+lnx0903 ln 1e-999999 -> -2302582.790408953 Inexact Rounded
+lnx0904 ln 1e+999999 -> 2302582.790408953 Inexact Rounded
+lnx0905 ln 1e-1000013 -> -2302615.026600255 Inexact Rounded
+lnx0906 ln 2e-1000013 -> -2302614.333453074 Inexact Rounded
+
+lnx0910 ln 9.999999e+999999 -> 2302585.092993946 Inexact Rounded
+lnx0911 ln 9.9999999e+999999 -> 2302585.092994036 Inexact Rounded
+lnx0912 ln 9.99999999e+999999 -> 2302585.092994045 Inexact Rounded
+lnx0913 ln 9.999999999e+999999 -> 2302585.092994046 Inexact Rounded
+lnx0914 ln 9.999999999999e+999999 -> 2302585.092994046 Inexact Rounded
+lnx0915 ln 9.999999999999999e+999999 -> 2302585.092994046 Inexact Rounded
+lnx0916 ln 9.999999999999999999999999e+999999 -> 2302585.092994046 Inexact Rounded
+
+-- randoms
+-- P=50, within 0-999
+Precision: 50
+maxExponent: 384
+minExponent: -383
+lnx1501 ln 0.00098800906574486388604608477869812518857023768951 -> -6.9198186844033787995945147836955586009548513043689 Inexact Rounded
+lnx1502 ln 158.15866624664623070184595045304145949900714987827 -> 5.0635987458895647454907806507503825602758392287684 Inexact Rounded
+lnx1503 ln 0.00565661412059571925040285814021799775249288309321 -> -5.1749297776760632102047540300491550931651318975237 Inexact Rounded
+lnx1504 ln 0.00000006914232532620489602008402091666547903180607 -> -16.487098770877825308138976818688771638172333034347 Inexact Rounded
+lnx1505 ln 0.00025380374621297657504661540749355251231770070723 -> -8.2789492423005003205242162741569033124260321954589 Inexact Rounded
+lnx1506 ln 83.033654063877426261108592599182418953442677554806 -> 4.4192459962647137976949249810815698465031609843669 Inexact Rounded
+lnx1507 ln 0.00000000416863228092481651627734668440663678118729 -> -19.295677845122141772791294599714950175284915666430 Inexact Rounded
+lnx1508 ln 0.00000140847873187820570181214271960511080523457669 -> -13.473000349581967189668305314384952251556809480339 Inexact Rounded
+lnx1509 ln 66.176106555181527101630351127583944689752069132522 -> 4.1923194696232505883666171116966137694013431504252 Inexact Rounded
+lnx1510 ln 0.00000000000009899043487403590900111602024562297908 -> -29.943753166877840985821508112917991506656545174163 Inexact Rounded
+lnx1511 ln 0.00000000000324618296721747097510453388683912733569 -> -26.453541281444586819009546418577507163362590139422 Inexact Rounded
+lnx1512 ln 72.646968818463546449499147579023555008392860423385 -> 4.2856116660689646882852128853423566276718230426479 Inexact Rounded
+lnx1513 ln 0.00000000000000066755483124635612574263153825990523 -> -34.942910142802769319262875080398852491588707172483 Inexact Rounded
+lnx1514 ln 61.002910447202398204114909451851111424657671911002 -> 4.1109215752843377323363182051446177066434038096529 Inexact Rounded
+lnx1515 ln 917.06917611331980999227893584010544542312239174774 -> 6.8211829068303114128752453661946446979787826282907 Inexact Rounded
+lnx1516 ln 0.00000000170823794883673083358549749078972003965194 -> -20.187803436976150477297246666771626827057191023004 Inexact Rounded
+lnx1517 ln 0.53731767845358224445809761315159249898566542910649 -> -0.62116577939968409211736413628236285160048357000961 Inexact Rounded
+lnx1518 ln 0.00000000000000008965291392882804161299758708033373 -> -36.950585970980857376081265073276303670820056916206 Inexact Rounded
+lnx1519 ln 0.00000000006990244916026429904498278982530170295668 -> -23.383920429244457578373523508427783144589480420753 Inexact Rounded
+lnx1520 ln 4.0312542977070300070506064666536478373801988540614 -> 1.3940775676592451945795752796421391871302024763305 Inexact Rounded
+lnx1521 ln 271.84991311551875601432518819562391699324632396423 -> 5.6052501239873862517916679747146539808077431873478 Inexact Rounded
+lnx1522 ln 7.4118671629373864667229445746862314443895404818689 -> 2.0030823863706344628239147639318289961917060121141 Inexact Rounded
+lnx1523 ln 0.00000000000002026311452625364905357321664186034258 -> -31.529974180054438792043856877314043794320951134754 Inexact Rounded
+lnx1524 ln 0.00000000000009563398651261756952398250624737809347 -> -29.978248130576972953141284136962670021368834792579 Inexact Rounded
+lnx1525 ln 0.00000000009556772669409858653026558223465197808991 -> -23.071185939748285541228206161472956661196956741186 Inexact Rounded
+lnx1526 ln 6.8441648298027301292342057248737326152250794026761 -> 1.9233964395801946597272589473417948024361005082908 Inexact Rounded
+lnx1527 ln 0.00000000000073059699884439979394945822035704264577 -> -27.944914388353724718836101828677771967128509603158 Inexact Rounded
+lnx1528 ln 0.00000000000000002610078280419082263138064745416787 -> -38.184566367516207885573773320135965798717120735115 Inexact Rounded
+lnx1529 ln 0.00000000000000000150259517166294243088546806083283 -> -41.039337946266676108538170837580051699618334928421 Inexact Rounded
+lnx1530 ln 0.00000000000000087919160541714580707181969708502091 -> -34.667528818827671507514319744047440696187358676848 Inexact Rounded
+lnx1531 ln 0.00000000000395726725120787763271849577708068584598 -> -26.255467416961357741818735787226671938678424748431 Inexact Rounded
+lnx1532 ln 0.00000000002014334901669366218018377213150715938355 -> -24.628146955635359035289123027319969201693737159108 Inexact Rounded
+lnx1533 ln 0.00000008097927101101093117753938766241442896030637 -> -16.329072628469715178637178365710373398203190937454 Inexact Rounded
+lnx1534 ln 0.00000000000017115834162632864392039668116243984176 -> -29.396187292434898225453626794459285157263177528034 Inexact Rounded
+lnx1535 ln 0.39168317593866334087305459933723864294857086105035 -> -0.93730199062757240485836637306785037368746737693029 Inexact Rounded
+lnx1536 ln 79.335036798971515026519630103325369729637514127617 -> 4.3736798570287828823772149735170431010616961976965 Inexact Rounded
+lnx1537 ln 0.00000000000000056004952129926137413602116591493625 -> -35.118506463181870020730685884333000241039028127213 Inexact Rounded
+lnx1538 ln 0.00000006006035907843890918832481099660639553666078 -> -16.627915795747112566532705974853114454405010472043 Inexact Rounded
+lnx1539 ln 0.00000000085242024937414906371333826574632450587590 -> -20.882941460268101080186482230657774997273494107221 Inexact Rounded
+lnx1540 ln 0.00000000000043671099499262350316173246550771951561 -> -28.459504757285639221776305968469058854558726593945 Inexact Rounded
+
+-- P=34, within 0-999
+Precision: 34
+lnx1201 ln 0.0086732880815927182997566810334394 -> -4.747507311920844752486938187973721 Inexact Rounded
+lnx1202 ln 0.0007104103693460260609792222569854 -> -7.249667769903503023005549250347695 Inexact Rounded
+lnx1203 ln 786.8398945385105190697541493392742 -> 6.668024790031836340471824147010546 Inexact Rounded
+lnx1204 ln 0.7723073620282687656895190171967399 -> -0.2583726708506850868786816238217326 Inexact Rounded
+lnx1205 ln 0.0061057951517197631287183938412200 -> -5.098516933918797347064454103742635 Inexact Rounded
+lnx1206 ln 0.6181379708184393730103917562498745 -> -0.4810435926903365087463387760350021 Inexact Rounded
+lnx1207 ln 09.13888261229039989110753389096760 -> 2.212538125507975574509563027696021 Inexact Rounded
+lnx1208 ln 802.0105417063143696497292158147174 -> 6.687121752052341737234832203350214 Inexact Rounded
+lnx1209 ln 778.7749710387773713523028497333058 -> 6.657722135126935472086625031413031 Inexact Rounded
+lnx1210 ln 0.0024457295895346502513567679390616 -> -6.013411799940245345321348290398517 Inexact Rounded
+lnx1211 ln 0.0000511296947872828310338864217860 -> -9.881145118237281798081573131711636 Inexact Rounded
+lnx1212 ln 0.0000246803508602554924938685155658 -> -10.60950314264825661825360971430218 Inexact Rounded
+lnx1213 ln 9.027898199253511668242977766616082 -> 2.200319582778899029786017830557293 Inexact Rounded
+lnx1214 ln 0.0991812396542505631850692800904188 -> -2.310806398964672258823043180400384 Inexact Rounded
+lnx1215 ln 0.0000000000070238810143028811223924 -> -25.68170519961636647174714538290075 Inexact Rounded
+lnx1216 ln 2.630101665342826494730394729313167 -> 0.9670225014664367465128243039749559 Inexact Rounded
+lnx1217 ln 0.0056878928594359587691526063254683 -> -5.169415422904037819736637399445096 Inexact Rounded
+lnx1218 ln 567.3436047121057843908106573095590 -> 6.340965124964258486463444360787970 Inexact Rounded
+lnx1219 ln 1.199291248124655996614605745649725 -> 0.1817307557425911805765087755675657 Inexact Rounded
+lnx1220 ln 25.02050448582031098696267479135557 -> 3.219695668137659139544178905459317 Inexact Rounded
+lnx1221 ln 0.0000000000009939597023558756961300 -> -27.63707972996537636504396558259058 Inexact Rounded
+lnx1222 ln 0.0000007988551670159429716506430403 -> -14.04008617542597230988198612376415 Inexact Rounded
+lnx1223 ln 4.681515800176129184873770605589795 -> 1.543621946415383338972124445445748 Inexact Rounded
+lnx1224 ln 15.95126669161103011206658749345781 -> 2.769538242479483539275986395443539 Inexact Rounded
+lnx1225 ln 0.0301626783922211213675457279076066 -> -3.501149933677283341023932281826341 Inexact Rounded
+lnx1226 ln 000.0040544064881821770528475185674 -> -5.507950967557021671647165889608324 Inexact Rounded
+lnx1227 ln 29.01617095935593792095913785100360 -> 3.367853293862745651888450004473297 Inexact Rounded
+lnx1228 ln 78.01836167344736733024804243195323 -> 4.356944205055768575987781375003992 Inexact Rounded
+lnx1229 ln 0.0000000096545319316965321158634893 -> -18.45583840160965814462095477365013 Inexact Rounded
+lnx1230 ln 97.95475237720579752770587185074428 -> 4.584505661612812742208619358214729 Inexact Rounded
+lnx1231 ln 528.0609262050423246402564228432371 -> 6.269211667589138113396583894315956 Inexact Rounded
+lnx1232 ln 0.0000002250064349732969696660452972 -> -15.30713683526963996712167701738724 Inexact Rounded
+lnx1233 ln 47.97063637767998658567199049725754 -> 3.870589081585660692195989854842372 Inexact Rounded
+lnx1234 ln 0.0005394311344541432318853513414361 -> -7.524995428393925934087126702974121 Inexact Rounded
+lnx1235 ln 0.0000000090973385649567471674972633 -> -18.51528393158931783447035004125791 Inexact Rounded
+lnx1236 ln 0.0000000000238776490227576197317977 -> -24.45807828188389561331158879207262 Inexact Rounded
+lnx1237 ln 0.0000236587000231921532145326218758 -> -10.65177964499823314952429277979034 Inexact Rounded
+lnx1238 ln 499.1277448846130709827154556125942 -> 6.212862064761427967461188083514774 Inexact Rounded
+lnx1239 ln 0.0000003960192300284787663712417647 -> -14.74180306619298548093697608293284 Inexact Rounded
+lnx1240 ln 41.08268350829477451667228892495136 -> 3.715586706887278039173584859218960 Inexact Rounded
+
+-- P=16, within 0-99
+Precision: 16
+lnx1101 ln 7.964875261033948 -> 2.075041282352241 Inexact Rounded
+lnx1102 ln 13.54527396845394 -> 2.606037701870263 Inexact Rounded
+lnx1103 ln 0.0008026554341331 -> -7.127585034321814 Inexact Rounded
+lnx1104 ln 0.0000030582233261 -> -12.69767642300625 Inexact Rounded
+lnx1105 ln 0.0004477497509672 -> -7.711276073210766 Inexact Rounded
+lnx1106 ln 7.616268622474371 -> 2.030286567675148 Inexact Rounded
+lnx1107 ln 51.58329925806381 -> 3.943197962309569 Inexact Rounded
+lnx1108 ln 0.0018197497951263 -> -6.309056262549345 Inexact Rounded
+lnx1109 ln 2.956282457072984 -> 1.083932552334575 Inexact Rounded
+lnx1110 ln 0.3843325579189906 -> -0.9562470649400558 Inexact Rounded
+lnx1111 ln 0.0074466329265663 -> -4.899993304919237 Inexact Rounded
+lnx1112 ln 0.0003372478532993 -> -7.994692428206378 Inexact Rounded
+lnx1113 ln 0.0084792263167809 -> -4.770136069569271 Inexact Rounded
+lnx1114 ln 5.926756998151102 -> 1.779477182834305 Inexact Rounded
+lnx1115 ln 9.025699152180897 -> 2.200075969604119 Inexact Rounded
+lnx1116 ln 1.910124643533526 -> 0.6471684983238183 Inexact Rounded
+lnx1117 ln 0.8158922711411020 -> -0.2034729533939387 Inexact Rounded
+lnx1118 ln 0.0067080016475322 -> -5.004454189414139 Inexact Rounded
+lnx1119 ln 0.0047583242092716 -> -5.347859729601094 Inexact Rounded
+lnx1120 ln 0.0386647411641339 -> -3.252827175263113 Inexact Rounded
+lnx1121 ln 0.0050226427841761 -> -5.293799032774131 Inexact Rounded
+lnx1122 ln 6.927937541637261 -> 1.935562155866906 Inexact Rounded
+lnx1123 ln 0.0000095745343513 -> -11.55640365579814 Inexact Rounded
+lnx1124 ln 1.602465492956538 -> 0.4715433763243936 Inexact Rounded
+lnx1125 ln 38.98415625087535 -> 3.663155313610213 Inexact Rounded
+lnx1126 ln 5.343182042276734 -> 1.675821363568112 Inexact Rounded
+lnx1127 ln 55.89763703245816 -> 4.023522107934110 Inexact Rounded
+lnx1128 ln 0.7445257810280847 -> -0.2950077988101030 Inexact Rounded
+lnx1129 ln 1.631407314946094 -> 0.4894430257201248 Inexact Rounded
+lnx1130 ln 0.0005462451932602 -> -7.512442611116852 Inexact Rounded
+lnx1131 ln 0.0000864173269362 -> -9.356322359017317 Inexact Rounded
+lnx1132 ln 5.227161719132849 -> 1.653868438439637 Inexact Rounded
+lnx1133 ln 60.57078466941998 -> 4.103812675662452 Inexact Rounded
+lnx1134 ln 0.0992864325333160 -> -2.309746348350318 Inexact Rounded
+lnx1135 ln 09.48564268447325 -> 2.249779359074983 Inexact Rounded
+lnx1136 ln 0.0036106089355634 -> -5.623878840650787 Inexact Rounded
+lnx1137 ln 1.805176865587172 -> 0.5906585734593707 Inexact Rounded
+lnx1138 ln 62.59363259642255 -> 4.136663557220559 Inexact Rounded
+lnx1139 ln 4.373828261137201 -> 1.475638657912000 Inexact Rounded
+lnx1140 ln 0.994483524148738 -> -0.005531747794938690 Inexact Rounded
+
+-- P=7, within 0-9
+Precision: 7
+lnx1001 ln 0.0912025 -> -2.394673 Inexact Rounded
+lnx1002 ln 0.9728626 -> -0.02751242 Inexact Rounded
+lnx1003 ln 0.3886032 -> -0.9451965 Inexact Rounded
+lnx1004 ln 8.798639 -> 2.174597 Inexact Rounded
+lnx1005 ln 2.459121 -> 0.8998040 Inexact Rounded
+lnx1006 ln 2.013193 -> 0.6997220 Inexact Rounded
+lnx1007 ln 9.064857 -> 2.204405 Inexact Rounded
+lnx1008 ln 5.796417 -> 1.757240 Inexact Rounded
+lnx1009 ln 0.1143471 -> -2.168517 Inexact Rounded
+lnx1010 ln 0.5341542 -> -0.6270707 Inexact Rounded
+lnx1011 ln 6.693781 -> 1.901179 Inexact Rounded
+lnx1012 ln 0.0081779 -> -4.806320 Inexact Rounded
+lnx1013 ln 8.313616 -> 2.117895 Inexact Rounded
+lnx1014 ln 3.486925 -> 1.249020 Inexact Rounded
+lnx1015 ln 0.1801401 -> -1.714020 Inexact Rounded
+lnx1016 ln 0.5227148 -> -0.6487193 Inexact Rounded
+lnx1017 ln 7.818111 -> 2.056443 Inexact Rounded
+lnx1018 ln 0.0870671 -> -2.441076 Inexact Rounded
+lnx1019 ln 8.153966 -> 2.098504 Inexact Rounded
+lnx1020 ln 2.040975 -> 0.7134276 Inexact Rounded
+lnx1021 ln 1.481642 -> 0.3931509 Inexact Rounded
+lnx1022 ln 0.2610123 -> -1.343188 Inexact Rounded
+lnx1023 ln 0.466723 -> -0.7620193 Inexact Rounded
+lnx1024 ln 0.0518756 -> -2.958907 Inexact Rounded
+lnx1025 ln 2.056410 -> 0.7209617 Inexact Rounded
+lnx1026 ln 0.181522 -> -1.706378 Inexact Rounded
+lnx1027 ln 0.515551 -> -0.6625190 Inexact Rounded
+lnx1028 ln 8.425089 -> 2.131214 Inexact Rounded
+lnx1029 ln 2.077091 -> 0.7309684 Inexact Rounded
+lnx1030 ln 6.212705 -> 1.826596 Inexact Rounded
+lnx1031 ln 5.729343 -> 1.745601 Inexact Rounded
+lnx1032 ln 4.831251 -> 1.575105 Inexact Rounded
+lnx1033 ln 2.029760 -> 0.7079176 Inexact Rounded
+lnx1034 ln 8.615060 -> 2.153512 Inexact Rounded
+lnx1035 ln 0.0611511 -> -2.794407 Inexact Rounded
+lnx1036 ln 5.195269 -> 1.647748 Inexact Rounded
+lnx1037 ln 9.617686 -> 2.263604 Inexact Rounded
+lnx1038 ln 0.0049382 -> -5.310754 Inexact Rounded
+lnx1039 ln 2.786840 -> 1.024908 Inexact Rounded
+lnx1040 ln 0.0091073 -> -4.698679 Inexact Rounded
+
+-- from here 3-digit tests are based on reverse exp tests
+precision: 9
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+lnx001 ln 0 -> -Infinity
+lnx002 ln 0.367879441 -> -1.00000000 Inexact Rounded
+lnx003 ln 1 -> 0
+lnx005 ln 2.71828183 -> 1.00000000 Inexact Rounded
+lnx006 ln 2.00000000 -> 0.693147181 Inexact Rounded
+lnx007 ln +Infinity -> Infinity
+
+-- tiny edge cases
+precision: 7
+lnx011 ln 1.105171 -> 0.1000001 Inexact Rounded
+lnx012 ln 1.010050 -> 0.009999835 Inexact Rounded
+lnx013 ln 1.000010 -> 0.000009999950 Inexact Rounded
+lnx014 ln 1.000001 -> 9.999995E-7 Inexact Rounded
+lnx015 ln 1.000000 -> 0
+
+-- basic e=0, e=1, e=2, e=4, e>=8 cases
+precision: 7
+lnx041 ln 2.718282 -> 1.000000 Inexact Rounded
+lnx042 ln 0.3678794 -> -1.000000 Inexact Rounded
+lnx043 ln 22026.47 -> 10.00000 Inexact Rounded
+lnx044 ln 0.00004539993 -> -10.00000 Inexact Rounded
+lnx045 ln 2.688117E+43 -> 100.0000 Inexact Rounded
+lnx046 ln 3.720076E-44 -> -100.0000 Inexact Rounded
+lnx047 ln Infinity -> Infinity
+lnx048 ln 0E-389 -> -Infinity
+
+-- miscellanea
+precision: 16
+lnx055 ln 2.717658486884572E-236 -> -542.4103112874415 Inexact Rounded
+precision: 17
+lnx056 ln 2.7176584868845721E-236 -> -542.41031128744146 Inexact Rounded
+precision: 18
+lnx057 ln 2.71765848688457211E-236 -> -542.410311287441459 Inexact Rounded
+precision: 19
+lnx058 ln 2.717658486884572112E-236 -> -542.4103112874414592 Inexact Rounded
+precision: 20
+lnx059 ln 2.7176584868845721118E-236 -> -542.41031128744145917 Inexact Rounded
+
+-- inputs ending in ..500.., ..499.., ..100.., ..999.. sequences
+precision: 50
+lnx102 ln 0.9999999100000040499998785000027 -> -9.0000000000000000000000033749953829996446124861750E-8 Inexact Rounded
+precision: 30
+lnx103 ln 0.999999910000004049999878500003 -> -8.99999999999999999999997337499E-8 Inexact Rounded
+precision: 29
+lnx104 ln 0.99999991000000404999987850000 -> -9.0000000000000000000002733750E-8 Inexact Rounded
+precision: 28
+lnx105 ln 0.9999999100000040499998785000 -> -9.000000000000000000000273375E-8 Inexact Rounded
+precision: 27
+lnx106 ln 0.999999910000004049999878500 -> -9.00000000000000000000027338E-8 Inexact Rounded
+precision: 26
+lnx107 ln 0.99999991000000404999987850 -> -9.0000000000000000000002734E-8 Inexact Rounded
+precision: 25
+lnx108 ln 0.9999999100000040499998785 -> -9.000000000000000000000273E-8 Inexact Rounded
+precision: 24
+lnx109 ln 0.999999910000004049999879 -> -8.99999999999999995000027E-8 Inexact Rounded
+precision: 23
+lnx110 ln 0.99999991000000404999988 -> -8.9999999999999998500003E-8 Inexact Rounded
+precision: 22
+lnx111 ln 0.9999999100000040499999 -> -8.999999999999997850000E-8 Inexact Rounded
+precision: 21
+lnx112 ln 0.999999910000004050000 -> -8.99999999999998785000E-8 Inexact Rounded
+precision: 20
+lnx113 ln 0.99999991000000405000 -> -8.9999999999999878500E-8 Inexact Rounded
+precision: 19
+lnx114 ln 0.9999999100000040500 -> -8.999999999999987850E-8 Inexact Rounded
+precision: 18
+lnx115 ln 0.999999910000004050 -> -8.99999999999998785E-8 Inexact Rounded
+-- next may be a > 0.5ulp case; a more precise answer is:
+-- -8.99999999999998784999918E-8
+precision: 17
+lnx116 ln 0.99999991000000405 -> -8.9999999999999878E-8 Inexact Rounded
+precision: 16
+lnx117 ln 0.9999999100000040 -> -9.000000004999988E-8 Inexact Rounded
+precision: 15
+lnx118 ln 0.999999910000004 -> -9.00000000499999E-8 Inexact Rounded
+precision: 14
+lnx119 ln 0.99999991000000 -> -9.0000004050000E-8 Inexact Rounded
+precision: 13
+lnx120 ln 0.9999999100000 -> -9.000000405000E-8 Inexact Rounded
+precision: 12
+lnx121 ln 0.999999910000 -> -9.00000040500E-8 Inexact Rounded
+precision: 11
+lnx122 ln 0.99999991000 -> -9.0000004050E-8 Inexact Rounded
+precision: 10
+lnx123 ln 0.9999999100 -> -9.000000405E-8 Inexact Rounded
+precision: 9
+lnx124 ln 0.999999910 -> -9.00000041E-8 Inexact Rounded
+precision: 8
+lnx125 ln 0.99999991 -> -9.0000004E-8 Inexact Rounded
+precision: 7
+lnx126 ln 0.9999999 -> -1.000000E-7 Inexact Rounded
+precision: 16
+lnx126b ln 0.9999999 -> -1.000000050000003E-7 Inexact Rounded
+precision: 6
+lnx127 ln 0.999999 -> -0.00000100000 Inexact Rounded
+precision: 5
+lnx128 ln 0.99999 -> -0.000010000 Inexact Rounded
+precision: 4
+lnx129 ln 0.9999 -> -0.0001000 Inexact Rounded
+precision: 3
+lnx130 ln 0.999 -> -0.00100 Inexact Rounded
+precision: 2
+lnx131 ln 0.99 -> -0.010 Inexact Rounded
+precision: 1
+lnx132 ln 0.9 -> -0.1 Inexact Rounded
+
+
+-- cases near 1 -- 1 2345678901234567890
+precision: 20
+lnx401 ln 2.7182818284589365041 -> 0.99999999999996000000 Inexact Rounded
+lnx402 ln 2.7182818284589636869 -> 0.99999999999997000000 Inexact Rounded
+lnx403 ln 2.7182818284589908697 -> 0.99999999999997999999 Inexact Rounded
+lnx404 ln 2.7182818284590180525 -> 0.99999999999998999998 Inexact Rounded
+lnx405 ln 2.7182818284590452354 -> 1.0000000000000000000 Inexact Rounded
+lnx406 ln 2.7182818284593170635 -> 1.0000000000001000000 Inexact Rounded
+lnx407 ln 2.7182818284595888917 -> 1.0000000000002000000 Inexact Rounded
+precision: 14
+lnx411 ln 2.7182818284589 -> 0.99999999999995 Inexact Rounded
+lnx413 ln 2.7182818284590 -> 0.99999999999998 Inexact Rounded
+lnx416 ln 2.7182818284591 -> 1.0000000000000 Inexact Rounded
+lnx417 ln 2.7182818284592 -> 1.0000000000001 Inexact Rounded
+
+-- overflows, including some exp overprecise borderlines
+precision: 7
+maxExponent: 384
+minExponent: -383
+lnx709 ln 9.999999E+384 -> 886.4953 Inexact Rounded
+lnx711 ln 9.999992E+384 -> 886.4953 Inexact Rounded
+precision: 16
+lnx722 ln 9.999999999999999E+384 -> 886.4952608027076 Inexact Rounded
+lnx724 ln 9.999999999999917E+384 -> 886.4952608027076 Inexact Rounded
+lnx726 ln 9.999999999999117E+384 -> 886.4952608027075 Inexact Rounded
+-- and more...
+precision: 15
+maxExponent: 999
+minExponent: -999
+lnx731 ln 9.99999999999999E+999 -> 2302.58509299405 Inexact Rounded
+-- next may be a > 0.5ulp case; a more precise answer is:
+-- 2302.58509299404495001799145442
+lnx732 ln 9.99999999999266E+999 -> 2302.58509299404 Inexact Rounded
+lnx733 ln 9.99999999999265E+999 -> 2302.58509299404 Inexact Rounded
+lnx734 ln 9.99999999999264E+999 -> 2302.58509299404 Inexact Rounded
+
+-- subnormals and underflows for exp, including underflow-to-zero edge point
+precision: 7
+maxExponent: 384
+minExponent: -383
+lnx751 ln 0E-389 -> -Infinity
+lnx758 ln 1.000001E-383 -> -881.8901 Inexact Rounded
+lnx759 ln 9.99991E-384 -> -881.8901 Inexact Rounded
+lnx760 ln 4.4605E-385 -> -885.0000 Inexact Rounded
+lnx761 ln 2.221E-386 -> -887.9999 Inexact Rounded
+lnx762 ln 3.01E-387 -> -889.9985 Inexact Rounded
+lnx763 ln 1.7E-388 -> -892.8724 Inexact Rounded
+lnx764 ln 1.5E-388 -> -892.9976 Inexact Rounded
+lnx765 ln 9E-389 -> -893.5084 Inexact Rounded
+lnx766 ln 1E-389 -> -895.7056 Inexact Rounded
+lnx774 ln 0E-389 -> -Infinity
+
+-- special values
+lnx820 ln Infinity -> Infinity
+lnx821 ln 0 -> -Infinity
+lnx822 ln NaN -> NaN
+lnx823 ln sNaN -> NaN Invalid_operation
+-- propagating NaNs
+lnx824 ln sNaN123 -> NaN123 Invalid_operation
+lnx825 ln -sNaN321 -> -NaN321 Invalid_operation
+lnx826 ln NaN456 -> NaN456
+lnx827 ln -NaN654 -> -NaN654
+lnx828 ln NaN1 -> NaN1
+
+-- Invalid operations due to restrictions
+-- [next two probably skipped by most test harnesses]
+precision: 100000000
+lnx901 ln 1 -> NaN Invalid_context
+precision: 99999999
+lnx902 ln 0 -> NaN Invalid_context
+
+precision: 9
+maxExponent: 1000000
+minExponent: -999999
+lnx903 ln 1 -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999999
+lnx904 ln 0 -> -Infinity
+maxExponent: 999999
+minExponent: -1000000
+lnx905 ln 1 -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999998
+lnx906 ln 0 -> -Infinity
+
+-- payload decapitate
+precision: 5
+lnx910 ln -sNaN1234567890 -> -NaN67890 Invalid_operation
+
+-- Null test
+lnx900 ln # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/log10.decTest b/Lib/test/decimaltestdata/log10.decTest
index 6502f0d091..5169eabde3 100644
--- a/Lib/test/decimaltestdata/log10.decTest
+++ b/Lib/test/decimaltestdata/log10.decTest
@@ -1,551 +1,551 @@
-------------------------------------------------------------------------
--- log10.decTest -- decimal logarithm in base 10 --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This emphasises the testing of notable cases, as they will often
--- have unusual paths (especially the 10**n results).
-
-extended: 1
-precision: 16
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- examples in specification
-precision: 9
-logxs000 log10 0 -> -Infinity
-logxs001 log10 0.001 -> -3
-logxs002 log10 1 -> 0
-logxs003 log10 2 -> 0.301029996 Inexact Rounded
-logxs004 log10 10 -> 1
-logxs005 log10 70 -> 1.84509804 Inexact Rounded
-logxs006 log10 +Infinity -> Infinity
-
-
--- basics (examples in specification, etc.)
-precision: 16
-logx0000 log10 0 -> -Infinity
-logx0001 log10 7E-1000 -> -999.1549019599857 Inexact Rounded
-logx0002 log10 1.1E-9 -> -8.958607314841775 Inexact Rounded
-logx0003 log10 0.0007 -> -3.154901959985743 Inexact Rounded
-logx0004 log10 0.11 -> -0.9586073148417750 Inexact Rounded
-logx0005 log10 0.7 -> -0.1549019599857432 Inexact Rounded
-logx0006 log10 1 -> 0
-logx0007 log10 1.5 -> 0.1760912590556812 Inexact Rounded
-logx0008 log10 2 -> 0.3010299956639812 Inexact Rounded
-logx0009 log10 2.718281828459045 -> 0.4342944819032518 Inexact Rounded
-logx0010 log10 2.718281828459046 -> 0.4342944819032519 Inexact Rounded
-logx0011 log10 2.718281828459047 -> 0.4342944819032521 Inexact Rounded
-logx0012 log10 7 -> 0.8450980400142568 Inexact Rounded
-logx0013 log10 10 -> 1
-logx0014 log10 10.5 -> 1.021189299069938 Inexact Rounded
-logx0015 log10 11 -> 1.041392685158225 Inexact Rounded
-logx0016 log10 70 -> 1.845098040014257 Inexact Rounded
-logx0017 log10 9999 -> 3.999956568380192 Inexact Rounded
-logx0018 log10 1.21E6 -> 6.082785370316450 Inexact Rounded
-logx0019 log10 1.1E+9 -> 9.041392685158225 Inexact Rounded
-logx0020 log10 7E+1000 -> 1000.845098040014 Inexact Rounded
-logx0021 log10 +Infinity -> Infinity
-
--- notable cases
--- negatives
-logx0031 log10 -1E-9 -> NaN Invalid_operation
-logx0032 log10 -0.0007 -> NaN Invalid_operation
-logx0033 log10 -0.1 -> NaN Invalid_operation
-logx0034 log10 -0.7 -> NaN Invalid_operation
-logx0035 log10 -1 -> NaN Invalid_operation
-logx0036 log10 -1.5 -> NaN Invalid_operation
-logx0037 log10 -2 -> NaN Invalid_operation
-logx0038 log10 -10.5 -> NaN Invalid_operation
-logx0039 log10 -10.5 -> NaN Invalid_operation
-logx0040 log10 -9999 -> NaN Invalid_operation
-logx0041 log10 -10 -> NaN Invalid_operation
-logx0042 log10 -0 -> -Infinity
-logx0043 log10 -0E+17 -> -Infinity
-logx0044 log10 -0E-17 -> -Infinity
--- other zeros
-logx0051 log10 0 -> -Infinity
-logx0052 log10 0E+17 -> -Infinity
-logx0053 log10 0E-17 -> -Infinity
--- infinities
-logx0055 log10 -Infinity -> NaN Invalid_operation
-logx0056 log10 +Infinity -> Infinity
--- ones
-logx0061 log10 1 -> 0
-logx0062 log10 1.0 -> 0
-logx0063 log10 1.000000000000000 -> 0
-logx0064 log10 1.000000000000000000 -> 0
-
--- notable cases -- exact powers of 10
-logx1100 log10 1 -> 0
-logx1101 log10 10 -> 1
-logx1102 log10 100 -> 2
-logx1103 log10 1000 -> 3
-logx1104 log10 10000 -> 4
-logx1105 log10 100000 -> 5
-logx1106 log10 1000000 -> 6
-logx1107 log10 10000000 -> 7
-logx1108 log10 100000000 -> 8
-logx1109 log10 1000000000 -> 9
-logx1110 log10 10000000000 -> 10
-logx1111 log10 100000000000 -> 11
-logx1112 log10 1000000000000 -> 12
-logx1113 log10 0.00000000001 -> -11
-logx1114 log10 0.0000000001 -> -10
-logx1115 log10 0.000000001 -> -9
-logx1116 log10 0.00000001 -> -8
-logx1117 log10 0.0000001 -> -7
-logx1118 log10 0.000001 -> -6
-logx1119 log10 0.00001 -> -5
-logx1120 log10 0.0001 -> -4
-logx1121 log10 0.001 -> -3
-logx1122 log10 0.01 -> -2
-logx1123 log10 0.1 -> -1
-logx1124 log10 1E-99 -> -99
-logx1125 log10 1E-100 -> -100
-logx1126 log10 1E-383 -> -383
-
--- check normally exact cases round properly
-precision: 1
-logx1141 log10 10000000000 -> 1E+1 Rounded
-logx1142 log10 1000000000000 -> 1E+1 Inexact Rounded
-logx1143 log10 1E+100 -> 1E+2 Rounded
-logx1144 log10 1E+123 -> 1E+2 Inexact Rounded
-logx1145 log10 1E+126 -> 1E+2 Inexact Rounded
-logx1146 log10 1E+916 -> 9E+2 Inexact Rounded
-logx1147 log10 1E+999 -> 1E+3 Inexact Rounded
-
-precision: 2
-logx1151 log10 10000000000 -> 10
-logx1152 log10 1000000000000 -> 12
-logx1153 log10 1E+100 -> 1.0E+2 Rounded
-logx1154 log10 1E+123 -> 1.2E+2 Inexact Rounded
-logx1155 log10 1E+126 -> 1.3E+2 Inexact Rounded
-logx1156 log10 1E+916 -> 9.2E+2 Inexact Rounded
-logx1157 log10 1E+999 -> 1.0E+3 Inexact Rounded
--- some half-way point rounds, other cases, and negatives
-logx1158 log10 1E+125 -> 1.2E+2 Inexact Rounded
-logx1159 log10 1E+135 -> 1.4E+2 Inexact Rounded
-logx1160 log10 1E+129 -> 1.3E+2 Inexact Rounded
-logx1161 log10 1E+131 -> 1.3E+2 Inexact Rounded
-logx1162 log10 1E-123 -> -1.2E+2 Inexact Rounded
-logx1163 log10 1E-126 -> -1.3E+2 Inexact Rounded
-logx1164 log10 1E-916 -> -9.2E+2 Inexact Rounded
-logx1165 log10 1E-999 -> -1.0E+3 Inexact Rounded
-logx1166 log10 1E-125 -> -1.2E+2 Inexact Rounded
-logx1167 log10 1E-135 -> -1.4E+2 Inexact Rounded
-logx1168 log10 1E-129 -> -1.3E+2 Inexact Rounded
-logx1169 log10 1E-131 -> -1.3E+2 Inexact Rounded
-
-precision: 3
-logx1171 log10 10000000000 -> 10
-logx1172 log10 1000000000000 -> 12
-logx1173 log10 1E+100 -> 100
-logx1174 log10 1E+123 -> 123
-logx1175 log10 1E+126 -> 126
-logx1176 log10 1E+916 -> 916
-logx1177 log10 1E+999 -> 999
-
--- log10(2) .. tests both ln(2) and ln(10) constants, too
-precision: 50
-logx1201 log10 2 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
-logx1202 log10 2.000 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
-logx1203 log10 0.2E1 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
-precision: 49
-logx1204 log10 2 -> 0.3010299956639811952137388947244930267681898814621 Inexact Rounded
-precision: 48
-logx1205 log10 2 -> 0.301029995663981195213738894724493026768189881462 Inexact Rounded
-precision: 47
-logx1206 log10 2 -> 0.30102999566398119521373889472449302676818988146 Inexact Rounded
-precision: 46
-logx1207 log10 2 -> 0.3010299956639811952137388947244930267681898815 Inexact Rounded
-precision: 45
-logx1208 log10 2 -> 0.301029995663981195213738894724493026768189881 Inexact Rounded
-precision: 44
-logx1209 log10 2 -> 0.30102999566398119521373889472449302676818988 Inexact Rounded
-precision: 43
-logx1210 log10 2 -> 0.3010299956639811952137388947244930267681899 Inexact Rounded
-precision: 42
-logx1211 log10 2 -> 0.301029995663981195213738894724493026768190 Inexact Rounded
-precision: 41
-logx1212 log10 2 -> 0.30102999566398119521373889472449302676819 Inexact Rounded
-precision: 40
-logx1213 log10 2 -> 0.3010299956639811952137388947244930267682 Inexact Rounded
-precision: 39
-logx1214 log10 2 -> 0.301029995663981195213738894724493026768 Inexact Rounded
-precision: 38
-logx1215 log10 2 -> 0.30102999566398119521373889472449302677 Inexact Rounded
-precision: 37
-logx1216 log10 2 -> 0.3010299956639811952137388947244930268 Inexact Rounded
-precision: 36
-logx1217 log10 2 -> 0.301029995663981195213738894724493027 Inexact Rounded
-precision: 35
-logx1218 log10 2 -> 0.30102999566398119521373889472449303 Inexact Rounded
-precision: 34
-logx1219 log10 2 -> 0.3010299956639811952137388947244930 Inexact Rounded
-precision: 33
-logx1220 log10 2 -> 0.301029995663981195213738894724493 Inexact Rounded
-precision: 32
-logx1221 log10 2 -> 0.30102999566398119521373889472449 Inexact Rounded
-precision: 31
-logx1222 log10 2 -> 0.3010299956639811952137388947245 Inexact Rounded
-precision: 30
-logx1223 log10 2 -> 0.301029995663981195213738894724 Inexact Rounded
-precision: 29
-logx1224 log10 2 -> 0.30102999566398119521373889472 Inexact Rounded
-precision: 28
-logx1225 log10 2 -> 0.3010299956639811952137388947 Inexact Rounded
-precision: 27
-logx1226 log10 2 -> 0.301029995663981195213738895 Inexact Rounded
-precision: 26
-logx1227 log10 2 -> 0.30102999566398119521373889 Inexact Rounded
-precision: 25
-logx1228 log10 2 -> 0.3010299956639811952137389 Inexact Rounded
-precision: 24
-logx1229 log10 2 -> 0.301029995663981195213739 Inexact Rounded
-precision: 23
-logx1230 log10 2 -> 0.30102999566398119521374 Inexact Rounded
-precision: 22
-logx1231 log10 2 -> 0.3010299956639811952137 Inexact Rounded
-precision: 21
-logx1232 log10 2 -> 0.301029995663981195214 Inexact Rounded
-precision: 20
-logx1233 log10 2 -> 0.30102999566398119521 Inexact Rounded
-precision: 19
-logx1234 log10 2 -> 0.3010299956639811952 Inexact Rounded
-precision: 18
-logx1235 log10 2 -> 0.301029995663981195 Inexact Rounded
-precision: 17
-logx1236 log10 2 -> 0.30102999566398120 Inexact Rounded
-precision: 16
-logx1237 log10 2 -> 0.3010299956639812 Inexact Rounded
-precision: 15
-logx1238 log10 2 -> 0.301029995663981 Inexact Rounded
-precision: 14
-logx1239 log10 2 -> 0.30102999566398 Inexact Rounded
-precision: 13
-logx1240 log10 2 -> 0.3010299956640 Inexact Rounded
-precision: 12
-logx1241 log10 2 -> 0.301029995664 Inexact Rounded
-precision: 11
-logx1242 log10 2 -> 0.30102999566 Inexact Rounded
-precision: 10
-logx1243 log10 2 -> 0.3010299957 Inexact Rounded
-precision: 9
-logx1244 log10 2 -> 0.301029996 Inexact Rounded
-precision: 8
-logx1245 log10 2 -> 0.30103000 Inexact Rounded
-precision: 7
-logx1246 log10 2 -> 0.3010300 Inexact Rounded
-precision: 6
-logx1247 log10 2 -> 0.301030 Inexact Rounded
-precision: 5
-logx1248 log10 2 -> 0.30103 Inexact Rounded
-precision: 4
-logx1249 log10 2 -> 0.3010 Inexact Rounded
-precision: 3
-logx1250 log10 2 -> 0.301 Inexact Rounded
-precision: 2
-logx1251 log10 2 -> 0.30 Inexact Rounded
-precision: 1
-logx1252 log10 2 -> 0.3 Inexact Rounded
-
-maxExponent: 384
-minExponent: -383
-precision: 16
-rounding: half_even
-
--- More close-to-e, etc., tests
-precision: 34
-logx1301 log10 2.718281828459045235360287471352661 -> 0.4342944819032518276511289189166048 Inexact Rounded
-logx1302 log10 2.718281828459045235360287471352662 -> 0.4342944819032518276511289189166050 Inexact Rounded
-logx1303 log10 2.718281828459045235360287471352663 -> 0.4342944819032518276511289189166052 Inexact Rounded
-logx1304 log10 0.99999999999999999999999999999999 -> -4.342944819032518276511289189166073E-33 Inexact Rounded
-logx1305 log10 0.999999999999999999999999999999999 -> -4.342944819032518276511289189166053E-34 Inexact Rounded
-logx1306 log10 0.9999999999999999999999999999999999 -> -4.342944819032518276511289189166051E-35 Inexact Rounded
-logx1307 log10 1.000000000000000000000000000000000 -> 0
-logx1308 log10 1.0000000000000000000000000000000001 -> 4.342944819032518276511289189166051E-35 Inexact Rounded
-logx1309 log10 1.000000000000000000000000000000001 -> 4.342944819032518276511289189166049E-34 Inexact Rounded
-logx1310 log10 1.00000000000000000000000000000001 -> 4.342944819032518276511289189166029E-33 Inexact Rounded
--- lower p
-precision: 7
-logx1320 log10 0.999999 -> -4.342947E-7 Inexact Rounded
-logx1321 log10 0.9999999 -> -4.342945E-8 Inexact Rounded
-logx1322 log10 0.99999999 -> -4.342945E-9 Inexact Rounded
-logx1323 log10 0.999999999 -> -4.342945E-10 Inexact Rounded
-logx1324 log10 1.00000000 -> 0
-logx1325 log10 1.00000001 -> 4.342945E-9 Inexact Rounded
-logx1326 log10 1.0000001 -> 4.342945E-8 Inexact Rounded
-logx1327 log10 1.000001 -> 4.342943E-7 Inexact Rounded
-
--- near 10^3
-precision: 9
-logx1331 log10 999.9999998 -> 3.00000000 Inexact Rounded
-logx1332 log10 999.9999999 -> 3.00000000 Inexact Rounded
-logx1333 log10 1000.000000 -> 3
-logx1334 log10 1000.000001 -> 3.00000000 Inexact Rounded
-logx1335 log10 1000.000002 -> 3.00000000 Inexact Rounded
-precision: 16
-logx1341 log10 999.9999998 -> 2.999999999913141 Inexact Rounded
-logx1342 log10 999.9999999 -> 2.999999999956571 Inexact Rounded
-logx1343 log10 1000.000000 -> 3
-logx1344 log10 1000.000001 -> 3.000000000434294 Inexact Rounded
-logx1345 log10 1000.000002 -> 3.000000000868589 Inexact Rounded
-
--- suggestions from Ilan Nehama
-logx1400 log10 10E-3 -> -2
-logx1401 log10 10E-2 -> -1
-logx1402 log10 100E-2 -> 0
-logx1403 log10 1000E-2 -> 1
-logx1404 log10 10000E-2 -> 2
-logx1405 log10 10E-1 -> 0
-logx1406 log10 100E-1 -> 1
-logx1407 log10 1000E-1 -> 2
-logx1408 log10 10000E-1 -> 3
-logx1409 log10 10E0 -> 1
-logx1410 log10 100E0 -> 2
-logx1411 log10 1000E0 -> 3
-logx1412 log10 10000E0 -> 4
-logx1413 log10 10E1 -> 2
-logx1414 log10 100E1 -> 3
-logx1415 log10 1000E1 -> 4
-logx1416 log10 10000E1 -> 5
-logx1417 log10 10E2 -> 3
-logx1418 log10 100E2 -> 4
-logx1419 log10 1000E2 -> 5
-logx1420 log10 10000E2 -> 6
-
--- Randoms
--- P=50, within 0-9999
-Precision: 50
-logx2501 log10 0.00035448001667968141775891246991912655961163345904 -> -3.4504082425411775290864053318247274944685586188505 Inexact Rounded
-logx2502 log10 70.636455726424311228255338637935330826995136597644 -> 1.8490288998408492045793070255302335558140975719247 Inexact Rounded
-logx2503 log10 0.00000000000000233550362473821889060812804063040169 -> -14.631619454343834858023578299142866557717904223667 Inexact Rounded
-logx2504 log10 97.783628621523244679901260358286898958832135433764 -> 1.9902661493224219517897657964362571690592734407330 Inexact Rounded
-logx2505 log10 0062.2377135315858392802612812022807838599572017342 -> 1.7940536293085066199287632725026837018486533544141 Inexact Rounded
-logx2506 log10 6.3767634652071053619977602804724129652981747879532 -> 0.80460030789825961615100163576080761326857374098644 Inexact Rounded
-logx2507 log10 63.297088981313278529306533814195068850532666658798 -> 1.8013837373724427092417170149098614410849353839673 Inexact Rounded
-logx2508 log10 0.00000077239693316881797717820110898167721602299187 -> -6.1121594592718550613773886241951966264826760310047 Inexact Rounded
-logx2509 log10 0.00000003953580359780185534830572461922527831395002 -> -7.4030094293833847136252547069905477213541787177561 Inexact Rounded
-logx2510 log10 754.62905817369989169188998111527272688791544577204 -> 2.8777335243761300047758534304371912099958057545416 Inexact Rounded
-logx2511 log10 0.00000048360378410241428936607147056283282849158312 -> -6.3155103095309353457604038397980091650760346334512 Inexact Rounded
-logx2512 log10 0.00007509037583645612577196104591672080542932166089 -> -4.1244157219700166314012344705538088030592896111026 Inexact Rounded
-logx2513 log10 0.00000000000705475944638915053419839063567898092064 -> -11.151517790256466048553810002525868198178167950377 Inexact Rounded
-logx2514 log10 9.6210300460497657917445410947099633479609165120661 -> 0.98322157093260978206633922877716078683518617768411 Inexact Rounded
-logx2515 log10 0.00000000050150361386555527496607245976120864985611 -> -9.2997259330798261040411086835563234390934934629340 Inexact Rounded
-logx2516 log10 098.24754029731994125797723545333677604490074810751 -> 1.9923216862874337077795278629351060819105679670633 Inexact Rounded
-logx2517 log10 7.5091998150046994320441463854301624742491015752980 -> 0.87559366078005924080766469158763499725414024128781 Inexact Rounded
-logx2518 log10 0.00000000000079540571273330075193668596942268542425 -> -12.099411294165176028817305108475326325006250936963 Inexact Rounded
-logx2519 log10 0.00000042395034799555215782907515074134154915491701 -> -6.3726850039125381134069450802108893075604464135297 Inexact Rounded
-logx2520 log10 56.683376304674355481905023145238799909301732694982 -> 1.7534557107853480435703421826077606250636580091754 Inexact Rounded
-logx2521 log10 48.734033811444195070807606721517169810438049581227 -> 1.6878323602741065190942654710049433808208291564049 Inexact Rounded
-logx2522 log10 0.00074830310930046865009851706989430228561880221063 -> -3.1259224502209974082223667712016445572431791920618 Inexact Rounded
-logx2523 log10 36.677348885111593384020836720396262497122708598359 -> 1.5643979364260796086754530282302605477567469395425 Inexact Rounded
-logx2524 log10 0.00000000000000004495678560480432858812419145833744 -> -16.347204748239740510014320630363244015916029619561 Inexact Rounded
-logx2525 log10 9509.5854013650642799374159131940108748594774307104 -> 3.9781615829916326741100166519726824430945406302661 Inexact Rounded
-logx2526 log10 0.07834891268689177014044454793608715276615743819097 -> -1.1059670262197643147805517398621288897669876996348 Inexact Rounded
-logx2527 log10 0.00000029584529880706128444454688454999032801904794 -> -6.5289353275814043710076526920566721570375026917206 Inexact Rounded
-logx2528 log10 3.0713496544497618098794332787772186176981011904294 -> 0.48732926103896828546424341029492468100431414072994 Inexact Rounded
-logx2529 log10 352.66392670788816474407442785460803833927136413943 -> 2.5473610388199562714709836398243933320284077008314 Inexact Rounded
-logx2530 log10 0.00304743125181876267210516527361742185617091801650 -> -2.5160660830163981967774124745311497447050056400207 Inexact Rounded
-logx2531 log10 0.00000076120535894952136499250364604538117729437183 -> -6.1184981629047051532448413863950776496652483019415 Inexact Rounded
-logx2532 log10 769.88795978534353052965286195053735007473187735815 -> 2.8864275277862652709986498581064117950288798222100 Inexact Rounded
-logx2533 log10 0.00000000000000041297494808612226304619570016336188 -> -15.384076292745415917510668454361868659468669804710 Inexact Rounded
-logx2534 log10 860.88864595714426940247940960258558876903741966974 -> 2.9349469800554277915920278090647283233440859155176 Inexact Rounded
-logx2535 log10 5839.0328812994787235900178587371051096898683972444 -> 3.7663409208972392569269125539438874737147906238543 Inexact Rounded
-logx2536 log10 0.00000028532710151284840471670497112821201598377841 -> -6.5446569753514027675878879843238065488490618159490 Inexact Rounded
-logx2537 log10 0.00000000000000009734490059931638483445631835651581 -> -16.011686794011271135978633880864278692254243106931 Inexact Rounded
-logx2538 log10 5.8610949526439529489252302463450302981511714144330 -> 0.76797875722452549281028552067645732490929361952278 Inexact Rounded
-logx2539 log10 6.6282432221115923372151148990137179611977576327206 -> 0.82139843639227213211012044000785757267155736071361 Inexact Rounded
-logx2540 log10 0.00000000001994071862386846626954819923923344413454 -> -10.700259194632339980266559224447212260115021637626 Inexact Rounded
-
--- P=34, within 0-9999
-Precision: 34
-logx2201 log10 1.522513203889714179088327328864183 -> 0.1825610677098896250496651330492109 Inexact Rounded
-logx2202 log10 0.171123774769717316154080888930404 -> -0.7666896483548462582461898092764408 Inexact Rounded
-logx2203 log10 0.0000000997467236251714283104963838 -> -7.001101360652518274271569010312115 Inexact Rounded
-logx2204 log10 0.0008856103624122479769647543468633 -> -3.052757310476070891830490327138190 Inexact Rounded
-logx2205 log10 1.938274868738032930709498221236758 -> 0.2874153648259449520201536171714594 Inexact Rounded
-logx2206 log10 479.5667847823826713082613445010097 -> 2.680849095850361068709165157286435 Inexact Rounded
-logx2207 log10 8856.136599178820202141823157336804 -> 3.947244306584767101480454261950559 Inexact Rounded
-logx2208 log10 0.0000911026318801903982642871344858 -> -4.040469076434979398438617464033826 Inexact Rounded
-logx2209 log10 0.0000000000017271112650427414732630 -> -11.76267968314038748995178212654921 Inexact Rounded
-logx2210 log10 6.962605370078885647639503548229695 -> 0.8427717807200322352686396925992250 Inexact Rounded
-logx2211 log10 0.3354804428992793132855923541692781 -> -0.4743327923012159170967636070844834 Inexact Rounded
-logx2212 log10 2.079864257474859008252165836663504 -> 0.3180349916198059046812506741388856 Inexact Rounded
-logx2213 log10 2805.479529292939499220276986621988 -> 3.448007104139974344565978780624744 Inexact Rounded
-logx2214 log10 66.45731133034187374557028537213949 -> 1.822542767005644041661520936223086 Inexact Rounded
-logx2215 log10 0.0000001206521261762681738274822835 -> -6.918465020390216969561494755767318 Inexact Rounded
-logx2216 log10 0.0000000001884891916264401160472381 -> -9.724713548119065386091933007528633 Inexact Rounded
-logx2217 log10 0.0000015467279551726326581314582759 -> -5.810586065070435383755759514608738 Inexact Rounded
-logx2218 log10 0.0090776316728068586744633914135952 -> -2.042027442843745884503280954390114 Inexact Rounded
-logx2219 log10 0.0000000000024541106528713393740030 -> -11.61010585935635713090119156069479 Inexact Rounded
-logx2220 log10 14.12936879385863410081087750645856 -> 1.150122760895466989841057385742662 Inexact Rounded
-logx2221 log10 0.0000036912481831392922922647231392 -> -5.432826753789892283556211380824203 Inexact Rounded
-logx2222 log10 0.0000000004067477525420424270138734 -> -9.390674838050073122857868012475060 Inexact Rounded
-logx2223 log10 7080.122562705399744969319589806194 -> 3.850040775747103318724330047546916 Inexact Rounded
-logx2224 log10 261.3491411363679209175524790255725 -> 2.417221077227536319655699517530855 Inexact Rounded
-logx2225 log10 003.9945581449915240094728380041494 -> 0.6014687471531988260823066997845691 Inexact Rounded
-logx2226 log10 0.0000000000583549164588495206767840 -> -10.23392254834182677023231713519341 Inexact Rounded
-logx2227 log10 9567.961832607240278342761088487484 -> 3.980819434211107631569386147016368 Inexact Rounded
-logx2228 log10 06.26592979160342972777219828867033 -> 0.7969855243966221408595024012574729 Inexact Rounded
-logx2229 log10 0.0000000000589847046598067273287319 -> -10.22926059078206218717755253582907 Inexact Rounded
-logx2230 log10 567.9388648235589204769442863724997 -> 2.754301589058313576472380262907638 Inexact Rounded
-logx2231 log10 039.7790325480037778918162264883415 -> 1.599654216592019199639285308997886 Inexact Rounded
-logx2232 log10 0.0000000005123951921894162149817207 -> -9.290394953898862694847327137242690 Inexact Rounded
-logx2233 log10 0.0000000000038500999723636904276723 -> -11.41452799337924056186867324854691 Inexact Rounded
-logx2234 log10 0.0006726500658977759825616537935864 -> -3.172210810922768725687671849421792 Inexact Rounded
-logx2235 log10 260.2400250475967528429943779126507 -> 2.415374092073799204236801383070064 Inexact Rounded
-logx2236 log10 0.0000000006101942339385102585042548 -> -9.214531900562046557191261226632509 Inexact Rounded
-logx2237 log10 0.0000000010846867501382746760066557 -> -8.964695664883282406359874242387236 Inexact Rounded
-logx2238 log10 60.24078375568814769010333711509928 -> 1.779890613567084253168373266648922 Inexact Rounded
-logx2239 log10 0.0012058738711757669337600252986093 -> -2.918698115012605915753728220896010 Inexact Rounded
-logx2240 log10 230.9450930197841600611503095185600 -> 2.363508739056822846742942599628966 Inexact Rounded
-
--- P=16, within 0-999
-Precision: 16
-logx2101 log10 0.0072067119605184 -> -2.142262835573038 Inexact Rounded
-logx2102 log10 503.6828482226624 -> 2.702157162195652 Inexact Rounded
-logx2103 log10 64.96074447821815 -> 1.812650993464174 Inexact Rounded
-logx2104 log10 48.75408597467246 -> 1.688011018842600 Inexact Rounded
-logx2105 log10 0.0329009839269587 -> -1.482791113975280 Inexact Rounded
-logx2106 log10 223.5320415060633 -> 2.349339784523410 Inexact Rounded
-logx2107 log10 73.12765002292194 -> 1.864081617476268 Inexact Rounded
-logx2108 log10 487.3749378358509 -> 2.687863192802252 Inexact Rounded
-logx2109 log10 0.0000019671987621 -> -5.706151757557926 Inexact Rounded
-logx2110 log10 0.0570680660609784 -> -1.243606844697873 Inexact Rounded
-logx2111 log10 33.10311638788998 -> 1.519868880976773 Inexact Rounded
-logx2112 log10 0.0687382699187077 -> -1.162801402868185 Inexact Rounded
-logx2113 log10 258.9416193626484 -> 2.413201859654145 Inexact Rounded
-logx2114 log10 0.0005306100136736 -> -3.275224558269725 Inexact Rounded
-logx2115 log10 65.78490393408572 -> 1.818126244825109 Inexact Rounded
-logx2116 log10 504.2328842073510 -> 2.702631165346958 Inexact Rounded
-logx2117 log10 9.417432755815027 -> 0.9739325278524503 Inexact Rounded
-logx2118 log10 006.7054835355498 -> 0.8264301004947640 Inexact Rounded
-logx2119 log10 0.0917012272363915 -> -1.037624852133399 Inexact Rounded
-logx2120 log10 5.959404385244921 -> 0.7752028561953401 Inexact Rounded
-logx2121 log10 0.0001209759148486 -> -3.917301084968903 Inexact Rounded
-logx2122 log10 0.0004706112139838 -> -3.327337728428039 Inexact Rounded
-logx2123 log10 0.0069700457377046 -> -2.156764372035771 Inexact Rounded
-logx2124 log10 0.5155584569852619 -> -0.2877220847805025 Inexact Rounded
-logx2125 log10 88.06005885607414 -> 1.944778971389913 Inexact Rounded
-logx2126 log10 0.0448240038219866 -> -1.348489353509709 Inexact Rounded
-logx2127 log10 3.419622484059565 -> 0.5339781639101145 Inexact Rounded
-logx2128 log10 5.171123353858721 -> 0.7135848977142854 Inexact Rounded
-logx2129 log10 0.0002133188319807 -> -3.670970802945872 Inexact Rounded
-logx2130 log10 46.21086703136966 -> 1.664744117045149 Inexact Rounded
-logx2131 log10 0.0000631053714415 -> -4.199933672639880 Inexact Rounded
-logx2132 log10 78.66019196870698 -> 1.895755001962469 Inexact Rounded
-logx2133 log10 0.0007152278351188 -> -3.145555592082297 Inexact Rounded
-logx2134 log10 45.52509819928536 -> 1.658250891256892 Inexact Rounded
-logx2135 log10 0.0000703227795740 -> -4.152903971697183 Inexact Rounded
-logx2136 log10 26.24438641426669 -> 1.419036423550599 Inexact Rounded
-logx2137 log10 0.0000044654829535 -> -5.350131564166817 Inexact Rounded
-logx2138 log10 0.7360702733062529 -> -0.1330807211893611 Inexact Rounded
-logx2139 log10 8.417059176469655 -> 0.9251603805112778 Inexact Rounded
-logx2140 log10 0.0002926570767968 -> -3.533640969664818 Inexact Rounded
-
--- P=7, within 0-99
-Precision: 7
-logx2001 log10 57.26089 -> 1.757858 Inexact Rounded
-logx2002 log10 0.0575421 -> -1.240014 Inexact Rounded
-logx2003 log10 0.5918465 -> -0.2277909 Inexact Rounded
-logx2004 log10 0.0068776 -> -2.162563 Inexact Rounded
-logx2005 log10 0.0066833 -> -2.175009 Inexact Rounded
-logx2006 log10 9.926963 -> 0.9968164 Inexact Rounded
-logx2007 log10 0.0041852 -> -2.378284 Inexact Rounded
-logx2008 log10 84.15412 -> 1.925075 Inexact Rounded
-logx2009 log10 2.466856 -> 0.3921438 Inexact Rounded
-logx2010 log10 0.0058047 -> -2.236220 Inexact Rounded
-logx2011 log10 9.885154 -> 0.9949834 Inexact Rounded
-logx2012 log10 0.6667654 -> -0.1760269 Inexact Rounded
-logx2013 log10 34.65736 -> 1.539795 Inexact Rounded
-logx2014 log10 0.0026884 -> -2.570506 Inexact Rounded
-logx2015 log10 0.0432767 -> -1.363746 Inexact Rounded
-logx2016 log10 66.01407 -> 1.819637 Inexact Rounded
-logx2017 log10 0.0070572 -> -2.151368 Inexact Rounded
-logx2018 log10 0.0731613 -> -1.135719 Inexact Rounded
-logx2019 log10 9.838983 -> 0.9929502 Inexact Rounded
-logx2020 log10 15.89696 -> 1.201314 Inexact Rounded
-logx2021 log10 8.459247 -> 0.9273317 Inexact Rounded
-logx2022 log10 0.0010873 -> -2.963651 Inexact Rounded
-logx2023 log10 0.6498619 -> -0.1871789 Inexact Rounded
-logx2024 log10 0.0847008 -> -1.072112 Inexact Rounded
-logx2025 log10 0.0075489 -> -2.122116 Inexact Rounded
-logx2026 log10 51.11152 -> 1.708519 Inexact Rounded
-logx2027 log10 0.7233866 -> -0.1406295 Inexact Rounded
-logx2028 log10 2.254721 -> 0.3530928 Inexact Rounded
-logx2029 log10 6.568444 -> 0.8174625 Inexact Rounded
-logx2030 log10 83.72639 -> 1.922862 Inexact Rounded
-logx2031 log10 6.720585 -> 0.8274071 Inexact Rounded
-logx2032 log10 87.90366 -> 1.944007 Inexact Rounded
-logx2033 log10 0.0433324 -> -1.363187 Inexact Rounded
-logx2034 log10 34.63912 -> 1.539567 Inexact Rounded
-logx2035 log10 0.8089059 -> -0.09210200 Inexact Rounded
-logx2036 log10 7.793405 -> 0.8917272 Inexact Rounded
-logx2037 log10 0.0041757 -> -2.379271 Inexact Rounded
-logx2038 log10 7.135417 -> 0.8534194 Inexact Rounded
-logx2039 log10 12.49570 -> 1.096761 Inexact Rounded
-logx2040 log10 6.356276 -> 0.8032027 Inexact Rounded
-
---------
-maxExponent: 384
-minExponent: -383
-precision: 16
-rounding: half_even
-
--- special values
-logx820 log10 Infinity -> Infinity
-logx821 log10 0 -> -Infinity
-logx822 log10 NaN -> NaN
-logx823 log10 sNaN -> NaN Invalid_operation
--- propagating NaNs
-logx824 log10 sNaN123 -> NaN123 Invalid_operation
-logx825 log10 -sNaN321 -> -NaN321 Invalid_operation
-logx826 log10 NaN456 -> NaN456
-logx827 log10 -NaN654 -> -NaN654
-logx828 log10 NaN1 -> NaN1
-
-
--- Invalid operations due to restrictions
--- [next two probably skipped by most test harnesses]
-precision: 100000000
-logx901 log10 1 -> NaN Invalid_context
-precision: 99999999
-logx902 log10 0 -> NaN Invalid_context
-
-precision: 9
-maxExponent: 1000000
-minExponent: -999999
-logx903 log10 1 -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999999
-logx904 log10 0 -> -Infinity
-maxExponent: 999999
-minExponent: -1000000
-logx905 log10 1 -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999998
-logx906 log10 0 -> -Infinity
-
--- Null test
-logx900 log10 # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- log10.decTest -- decimal logarithm in base 10 --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This emphasises the testing of notable cases, as they will often
+-- have unusual paths (especially the 10**n results).
+
+extended: 1
+precision: 16
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- examples in specification
+precision: 9
+logxs000 log10 0 -> -Infinity
+logxs001 log10 0.001 -> -3
+logxs002 log10 1 -> 0
+logxs003 log10 2 -> 0.301029996 Inexact Rounded
+logxs004 log10 10 -> 1
+logxs005 log10 70 -> 1.84509804 Inexact Rounded
+logxs006 log10 +Infinity -> Infinity
+
+
+-- basics (examples in specification, etc.)
+precision: 16
+logx0000 log10 0 -> -Infinity
+logx0001 log10 7E-1000 -> -999.1549019599857 Inexact Rounded
+logx0002 log10 1.1E-9 -> -8.958607314841775 Inexact Rounded
+logx0003 log10 0.0007 -> -3.154901959985743 Inexact Rounded
+logx0004 log10 0.11 -> -0.9586073148417750 Inexact Rounded
+logx0005 log10 0.7 -> -0.1549019599857432 Inexact Rounded
+logx0006 log10 1 -> 0
+logx0007 log10 1.5 -> 0.1760912590556812 Inexact Rounded
+logx0008 log10 2 -> 0.3010299956639812 Inexact Rounded
+logx0009 log10 2.718281828459045 -> 0.4342944819032518 Inexact Rounded
+logx0010 log10 2.718281828459046 -> 0.4342944819032519 Inexact Rounded
+logx0011 log10 2.718281828459047 -> 0.4342944819032521 Inexact Rounded
+logx0012 log10 7 -> 0.8450980400142568 Inexact Rounded
+logx0013 log10 10 -> 1
+logx0014 log10 10.5 -> 1.021189299069938 Inexact Rounded
+logx0015 log10 11 -> 1.041392685158225 Inexact Rounded
+logx0016 log10 70 -> 1.845098040014257 Inexact Rounded
+logx0017 log10 9999 -> 3.999956568380192 Inexact Rounded
+logx0018 log10 1.21E6 -> 6.082785370316450 Inexact Rounded
+logx0019 log10 1.1E+9 -> 9.041392685158225 Inexact Rounded
+logx0020 log10 7E+1000 -> 1000.845098040014 Inexact Rounded
+logx0021 log10 +Infinity -> Infinity
+
+-- notable cases
+-- negatives
+logx0031 log10 -1E-9 -> NaN Invalid_operation
+logx0032 log10 -0.0007 -> NaN Invalid_operation
+logx0033 log10 -0.1 -> NaN Invalid_operation
+logx0034 log10 -0.7 -> NaN Invalid_operation
+logx0035 log10 -1 -> NaN Invalid_operation
+logx0036 log10 -1.5 -> NaN Invalid_operation
+logx0037 log10 -2 -> NaN Invalid_operation
+logx0038 log10 -10.5 -> NaN Invalid_operation
+logx0039 log10 -10.5 -> NaN Invalid_operation
+logx0040 log10 -9999 -> NaN Invalid_operation
+logx0041 log10 -10 -> NaN Invalid_operation
+logx0042 log10 -0 -> -Infinity
+logx0043 log10 -0E+17 -> -Infinity
+logx0044 log10 -0E-17 -> -Infinity
+-- other zeros
+logx0051 log10 0 -> -Infinity
+logx0052 log10 0E+17 -> -Infinity
+logx0053 log10 0E-17 -> -Infinity
+-- infinities
+logx0055 log10 -Infinity -> NaN Invalid_operation
+logx0056 log10 +Infinity -> Infinity
+-- ones
+logx0061 log10 1 -> 0
+logx0062 log10 1.0 -> 0
+logx0063 log10 1.000000000000000 -> 0
+logx0064 log10 1.000000000000000000 -> 0
+
+-- notable cases -- exact powers of 10
+logx1100 log10 1 -> 0
+logx1101 log10 10 -> 1
+logx1102 log10 100 -> 2
+logx1103 log10 1000 -> 3
+logx1104 log10 10000 -> 4
+logx1105 log10 100000 -> 5
+logx1106 log10 1000000 -> 6
+logx1107 log10 10000000 -> 7
+logx1108 log10 100000000 -> 8
+logx1109 log10 1000000000 -> 9
+logx1110 log10 10000000000 -> 10
+logx1111 log10 100000000000 -> 11
+logx1112 log10 1000000000000 -> 12
+logx1113 log10 0.00000000001 -> -11
+logx1114 log10 0.0000000001 -> -10
+logx1115 log10 0.000000001 -> -9
+logx1116 log10 0.00000001 -> -8
+logx1117 log10 0.0000001 -> -7
+logx1118 log10 0.000001 -> -6
+logx1119 log10 0.00001 -> -5
+logx1120 log10 0.0001 -> -4
+logx1121 log10 0.001 -> -3
+logx1122 log10 0.01 -> -2
+logx1123 log10 0.1 -> -1
+logx1124 log10 1E-99 -> -99
+logx1125 log10 1E-100 -> -100
+logx1126 log10 1E-383 -> -383
+
+-- check normally exact cases round properly
+precision: 1
+logx1141 log10 10000000000 -> 1E+1 Rounded
+logx1142 log10 1000000000000 -> 1E+1 Inexact Rounded
+logx1143 log10 1E+100 -> 1E+2 Rounded
+logx1144 log10 1E+123 -> 1E+2 Inexact Rounded
+logx1145 log10 1E+126 -> 1E+2 Inexact Rounded
+logx1146 log10 1E+916 -> 9E+2 Inexact Rounded
+logx1147 log10 1E+999 -> 1E+3 Inexact Rounded
+
+precision: 2
+logx1151 log10 10000000000 -> 10
+logx1152 log10 1000000000000 -> 12
+logx1153 log10 1E+100 -> 1.0E+2 Rounded
+logx1154 log10 1E+123 -> 1.2E+2 Inexact Rounded
+logx1155 log10 1E+126 -> 1.3E+2 Inexact Rounded
+logx1156 log10 1E+916 -> 9.2E+2 Inexact Rounded
+logx1157 log10 1E+999 -> 1.0E+3 Inexact Rounded
+-- some half-way point rounds, other cases, and negatives
+logx1158 log10 1E+125 -> 1.2E+2 Inexact Rounded
+logx1159 log10 1E+135 -> 1.4E+2 Inexact Rounded
+logx1160 log10 1E+129 -> 1.3E+2 Inexact Rounded
+logx1161 log10 1E+131 -> 1.3E+2 Inexact Rounded
+logx1162 log10 1E-123 -> -1.2E+2 Inexact Rounded
+logx1163 log10 1E-126 -> -1.3E+2 Inexact Rounded
+logx1164 log10 1E-916 -> -9.2E+2 Inexact Rounded
+logx1165 log10 1E-999 -> -1.0E+3 Inexact Rounded
+logx1166 log10 1E-125 -> -1.2E+2 Inexact Rounded
+logx1167 log10 1E-135 -> -1.4E+2 Inexact Rounded
+logx1168 log10 1E-129 -> -1.3E+2 Inexact Rounded
+logx1169 log10 1E-131 -> -1.3E+2 Inexact Rounded
+
+precision: 3
+logx1171 log10 10000000000 -> 10
+logx1172 log10 1000000000000 -> 12
+logx1173 log10 1E+100 -> 100
+logx1174 log10 1E+123 -> 123
+logx1175 log10 1E+126 -> 126
+logx1176 log10 1E+916 -> 916
+logx1177 log10 1E+999 -> 999
+
+-- log10(2) .. tests both ln(2) and ln(10) constants, too
+precision: 50
+logx1201 log10 2 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
+logx1202 log10 2.000 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
+logx1203 log10 0.2E1 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
+precision: 49
+logx1204 log10 2 -> 0.3010299956639811952137388947244930267681898814621 Inexact Rounded
+precision: 48
+logx1205 log10 2 -> 0.301029995663981195213738894724493026768189881462 Inexact Rounded
+precision: 47
+logx1206 log10 2 -> 0.30102999566398119521373889472449302676818988146 Inexact Rounded
+precision: 46
+logx1207 log10 2 -> 0.3010299956639811952137388947244930267681898815 Inexact Rounded
+precision: 45
+logx1208 log10 2 -> 0.301029995663981195213738894724493026768189881 Inexact Rounded
+precision: 44
+logx1209 log10 2 -> 0.30102999566398119521373889472449302676818988 Inexact Rounded
+precision: 43
+logx1210 log10 2 -> 0.3010299956639811952137388947244930267681899 Inexact Rounded
+precision: 42
+logx1211 log10 2 -> 0.301029995663981195213738894724493026768190 Inexact Rounded
+precision: 41
+logx1212 log10 2 -> 0.30102999566398119521373889472449302676819 Inexact Rounded
+precision: 40
+logx1213 log10 2 -> 0.3010299956639811952137388947244930267682 Inexact Rounded
+precision: 39
+logx1214 log10 2 -> 0.301029995663981195213738894724493026768 Inexact Rounded
+precision: 38
+logx1215 log10 2 -> 0.30102999566398119521373889472449302677 Inexact Rounded
+precision: 37
+logx1216 log10 2 -> 0.3010299956639811952137388947244930268 Inexact Rounded
+precision: 36
+logx1217 log10 2 -> 0.301029995663981195213738894724493027 Inexact Rounded
+precision: 35
+logx1218 log10 2 -> 0.30102999566398119521373889472449303 Inexact Rounded
+precision: 34
+logx1219 log10 2 -> 0.3010299956639811952137388947244930 Inexact Rounded
+precision: 33
+logx1220 log10 2 -> 0.301029995663981195213738894724493 Inexact Rounded
+precision: 32
+logx1221 log10 2 -> 0.30102999566398119521373889472449 Inexact Rounded
+precision: 31
+logx1222 log10 2 -> 0.3010299956639811952137388947245 Inexact Rounded
+precision: 30
+logx1223 log10 2 -> 0.301029995663981195213738894724 Inexact Rounded
+precision: 29
+logx1224 log10 2 -> 0.30102999566398119521373889472 Inexact Rounded
+precision: 28
+logx1225 log10 2 -> 0.3010299956639811952137388947 Inexact Rounded
+precision: 27
+logx1226 log10 2 -> 0.301029995663981195213738895 Inexact Rounded
+precision: 26
+logx1227 log10 2 -> 0.30102999566398119521373889 Inexact Rounded
+precision: 25
+logx1228 log10 2 -> 0.3010299956639811952137389 Inexact Rounded
+precision: 24
+logx1229 log10 2 -> 0.301029995663981195213739 Inexact Rounded
+precision: 23
+logx1230 log10 2 -> 0.30102999566398119521374 Inexact Rounded
+precision: 22
+logx1231 log10 2 -> 0.3010299956639811952137 Inexact Rounded
+precision: 21
+logx1232 log10 2 -> 0.301029995663981195214 Inexact Rounded
+precision: 20
+logx1233 log10 2 -> 0.30102999566398119521 Inexact Rounded
+precision: 19
+logx1234 log10 2 -> 0.3010299956639811952 Inexact Rounded
+precision: 18
+logx1235 log10 2 -> 0.301029995663981195 Inexact Rounded
+precision: 17
+logx1236 log10 2 -> 0.30102999566398120 Inexact Rounded
+precision: 16
+logx1237 log10 2 -> 0.3010299956639812 Inexact Rounded
+precision: 15
+logx1238 log10 2 -> 0.301029995663981 Inexact Rounded
+precision: 14
+logx1239 log10 2 -> 0.30102999566398 Inexact Rounded
+precision: 13
+logx1240 log10 2 -> 0.3010299956640 Inexact Rounded
+precision: 12
+logx1241 log10 2 -> 0.301029995664 Inexact Rounded
+precision: 11
+logx1242 log10 2 -> 0.30102999566 Inexact Rounded
+precision: 10
+logx1243 log10 2 -> 0.3010299957 Inexact Rounded
+precision: 9
+logx1244 log10 2 -> 0.301029996 Inexact Rounded
+precision: 8
+logx1245 log10 2 -> 0.30103000 Inexact Rounded
+precision: 7
+logx1246 log10 2 -> 0.3010300 Inexact Rounded
+precision: 6
+logx1247 log10 2 -> 0.301030 Inexact Rounded
+precision: 5
+logx1248 log10 2 -> 0.30103 Inexact Rounded
+precision: 4
+logx1249 log10 2 -> 0.3010 Inexact Rounded
+precision: 3
+logx1250 log10 2 -> 0.301 Inexact Rounded
+precision: 2
+logx1251 log10 2 -> 0.30 Inexact Rounded
+precision: 1
+logx1252 log10 2 -> 0.3 Inexact Rounded
+
+maxExponent: 384
+minExponent: -383
+precision: 16
+rounding: half_even
+
+-- More close-to-e, etc., tests
+precision: 34
+logx1301 log10 2.718281828459045235360287471352661 -> 0.4342944819032518276511289189166048 Inexact Rounded
+logx1302 log10 2.718281828459045235360287471352662 -> 0.4342944819032518276511289189166050 Inexact Rounded
+logx1303 log10 2.718281828459045235360287471352663 -> 0.4342944819032518276511289189166052 Inexact Rounded
+logx1304 log10 0.99999999999999999999999999999999 -> -4.342944819032518276511289189166073E-33 Inexact Rounded
+logx1305 log10 0.999999999999999999999999999999999 -> -4.342944819032518276511289189166053E-34 Inexact Rounded
+logx1306 log10 0.9999999999999999999999999999999999 -> -4.342944819032518276511289189166051E-35 Inexact Rounded
+logx1307 log10 1.000000000000000000000000000000000 -> 0
+logx1308 log10 1.0000000000000000000000000000000001 -> 4.342944819032518276511289189166051E-35 Inexact Rounded
+logx1309 log10 1.000000000000000000000000000000001 -> 4.342944819032518276511289189166049E-34 Inexact Rounded
+logx1310 log10 1.00000000000000000000000000000001 -> 4.342944819032518276511289189166029E-33 Inexact Rounded
+-- lower p
+precision: 7
+logx1320 log10 0.999999 -> -4.342947E-7 Inexact Rounded
+logx1321 log10 0.9999999 -> -4.342945E-8 Inexact Rounded
+logx1322 log10 0.99999999 -> -4.342945E-9 Inexact Rounded
+logx1323 log10 0.999999999 -> -4.342945E-10 Inexact Rounded
+logx1324 log10 1.00000000 -> 0
+logx1325 log10 1.00000001 -> 4.342945E-9 Inexact Rounded
+logx1326 log10 1.0000001 -> 4.342945E-8 Inexact Rounded
+logx1327 log10 1.000001 -> 4.342943E-7 Inexact Rounded
+
+-- near 10^3
+precision: 9
+logx1331 log10 999.9999998 -> 3.00000000 Inexact Rounded
+logx1332 log10 999.9999999 -> 3.00000000 Inexact Rounded
+logx1333 log10 1000.000000 -> 3
+logx1334 log10 1000.000001 -> 3.00000000 Inexact Rounded
+logx1335 log10 1000.000002 -> 3.00000000 Inexact Rounded
+precision: 16
+logx1341 log10 999.9999998 -> 2.999999999913141 Inexact Rounded
+logx1342 log10 999.9999999 -> 2.999999999956571 Inexact Rounded
+logx1343 log10 1000.000000 -> 3
+logx1344 log10 1000.000001 -> 3.000000000434294 Inexact Rounded
+logx1345 log10 1000.000002 -> 3.000000000868589 Inexact Rounded
+
+-- suggestions from Ilan Nehama
+logx1400 log10 10E-3 -> -2
+logx1401 log10 10E-2 -> -1
+logx1402 log10 100E-2 -> 0
+logx1403 log10 1000E-2 -> 1
+logx1404 log10 10000E-2 -> 2
+logx1405 log10 10E-1 -> 0
+logx1406 log10 100E-1 -> 1
+logx1407 log10 1000E-1 -> 2
+logx1408 log10 10000E-1 -> 3
+logx1409 log10 10E0 -> 1
+logx1410 log10 100E0 -> 2
+logx1411 log10 1000E0 -> 3
+logx1412 log10 10000E0 -> 4
+logx1413 log10 10E1 -> 2
+logx1414 log10 100E1 -> 3
+logx1415 log10 1000E1 -> 4
+logx1416 log10 10000E1 -> 5
+logx1417 log10 10E2 -> 3
+logx1418 log10 100E2 -> 4
+logx1419 log10 1000E2 -> 5
+logx1420 log10 10000E2 -> 6
+
+-- Randoms
+-- P=50, within 0-9999
+Precision: 50
+logx2501 log10 0.00035448001667968141775891246991912655961163345904 -> -3.4504082425411775290864053318247274944685586188505 Inexact Rounded
+logx2502 log10 70.636455726424311228255338637935330826995136597644 -> 1.8490288998408492045793070255302335558140975719247 Inexact Rounded
+logx2503 log10 0.00000000000000233550362473821889060812804063040169 -> -14.631619454343834858023578299142866557717904223667 Inexact Rounded
+logx2504 log10 97.783628621523244679901260358286898958832135433764 -> 1.9902661493224219517897657964362571690592734407330 Inexact Rounded
+logx2505 log10 0062.2377135315858392802612812022807838599572017342 -> 1.7940536293085066199287632725026837018486533544141 Inexact Rounded
+logx2506 log10 6.3767634652071053619977602804724129652981747879532 -> 0.80460030789825961615100163576080761326857374098644 Inexact Rounded
+logx2507 log10 63.297088981313278529306533814195068850532666658798 -> 1.8013837373724427092417170149098614410849353839673 Inexact Rounded
+logx2508 log10 0.00000077239693316881797717820110898167721602299187 -> -6.1121594592718550613773886241951966264826760310047 Inexact Rounded
+logx2509 log10 0.00000003953580359780185534830572461922527831395002 -> -7.4030094293833847136252547069905477213541787177561 Inexact Rounded
+logx2510 log10 754.62905817369989169188998111527272688791544577204 -> 2.8777335243761300047758534304371912099958057545416 Inexact Rounded
+logx2511 log10 0.00000048360378410241428936607147056283282849158312 -> -6.3155103095309353457604038397980091650760346334512 Inexact Rounded
+logx2512 log10 0.00007509037583645612577196104591672080542932166089 -> -4.1244157219700166314012344705538088030592896111026 Inexact Rounded
+logx2513 log10 0.00000000000705475944638915053419839063567898092064 -> -11.151517790256466048553810002525868198178167950377 Inexact Rounded
+logx2514 log10 9.6210300460497657917445410947099633479609165120661 -> 0.98322157093260978206633922877716078683518617768411 Inexact Rounded
+logx2515 log10 0.00000000050150361386555527496607245976120864985611 -> -9.2997259330798261040411086835563234390934934629340 Inexact Rounded
+logx2516 log10 098.24754029731994125797723545333677604490074810751 -> 1.9923216862874337077795278629351060819105679670633 Inexact Rounded
+logx2517 log10 7.5091998150046994320441463854301624742491015752980 -> 0.87559366078005924080766469158763499725414024128781 Inexact Rounded
+logx2518 log10 0.00000000000079540571273330075193668596942268542425 -> -12.099411294165176028817305108475326325006250936963 Inexact Rounded
+logx2519 log10 0.00000042395034799555215782907515074134154915491701 -> -6.3726850039125381134069450802108893075604464135297 Inexact Rounded
+logx2520 log10 56.683376304674355481905023145238799909301732694982 -> 1.7534557107853480435703421826077606250636580091754 Inexact Rounded
+logx2521 log10 48.734033811444195070807606721517169810438049581227 -> 1.6878323602741065190942654710049433808208291564049 Inexact Rounded
+logx2522 log10 0.00074830310930046865009851706989430228561880221063 -> -3.1259224502209974082223667712016445572431791920618 Inexact Rounded
+logx2523 log10 36.677348885111593384020836720396262497122708598359 -> 1.5643979364260796086754530282302605477567469395425 Inexact Rounded
+logx2524 log10 0.00000000000000004495678560480432858812419145833744 -> -16.347204748239740510014320630363244015916029619561 Inexact Rounded
+logx2525 log10 9509.5854013650642799374159131940108748594774307104 -> 3.9781615829916326741100166519726824430945406302661 Inexact Rounded
+logx2526 log10 0.07834891268689177014044454793608715276615743819097 -> -1.1059670262197643147805517398621288897669876996348 Inexact Rounded
+logx2527 log10 0.00000029584529880706128444454688454999032801904794 -> -6.5289353275814043710076526920566721570375026917206 Inexact Rounded
+logx2528 log10 3.0713496544497618098794332787772186176981011904294 -> 0.48732926103896828546424341029492468100431414072994 Inexact Rounded
+logx2529 log10 352.66392670788816474407442785460803833927136413943 -> 2.5473610388199562714709836398243933320284077008314 Inexact Rounded
+logx2530 log10 0.00304743125181876267210516527361742185617091801650 -> -2.5160660830163981967774124745311497447050056400207 Inexact Rounded
+logx2531 log10 0.00000076120535894952136499250364604538117729437183 -> -6.1184981629047051532448413863950776496652483019415 Inexact Rounded
+logx2532 log10 769.88795978534353052965286195053735007473187735815 -> 2.8864275277862652709986498581064117950288798222100 Inexact Rounded
+logx2533 log10 0.00000000000000041297494808612226304619570016336188 -> -15.384076292745415917510668454361868659468669804710 Inexact Rounded
+logx2534 log10 860.88864595714426940247940960258558876903741966974 -> 2.9349469800554277915920278090647283233440859155176 Inexact Rounded
+logx2535 log10 5839.0328812994787235900178587371051096898683972444 -> 3.7663409208972392569269125539438874737147906238543 Inexact Rounded
+logx2536 log10 0.00000028532710151284840471670497112821201598377841 -> -6.5446569753514027675878879843238065488490618159490 Inexact Rounded
+logx2537 log10 0.00000000000000009734490059931638483445631835651581 -> -16.011686794011271135978633880864278692254243106931 Inexact Rounded
+logx2538 log10 5.8610949526439529489252302463450302981511714144330 -> 0.76797875722452549281028552067645732490929361952278 Inexact Rounded
+logx2539 log10 6.6282432221115923372151148990137179611977576327206 -> 0.82139843639227213211012044000785757267155736071361 Inexact Rounded
+logx2540 log10 0.00000000001994071862386846626954819923923344413454 -> -10.700259194632339980266559224447212260115021637626 Inexact Rounded
+
+-- P=34, within 0-9999
+Precision: 34
+logx2201 log10 1.522513203889714179088327328864183 -> 0.1825610677098896250496651330492109 Inexact Rounded
+logx2202 log10 0.171123774769717316154080888930404 -> -0.7666896483548462582461898092764408 Inexact Rounded
+logx2203 log10 0.0000000997467236251714283104963838 -> -7.001101360652518274271569010312115 Inexact Rounded
+logx2204 log10 0.0008856103624122479769647543468633 -> -3.052757310476070891830490327138190 Inexact Rounded
+logx2205 log10 1.938274868738032930709498221236758 -> 0.2874153648259449520201536171714594 Inexact Rounded
+logx2206 log10 479.5667847823826713082613445010097 -> 2.680849095850361068709165157286435 Inexact Rounded
+logx2207 log10 8856.136599178820202141823157336804 -> 3.947244306584767101480454261950559 Inexact Rounded
+logx2208 log10 0.0000911026318801903982642871344858 -> -4.040469076434979398438617464033826 Inexact Rounded
+logx2209 log10 0.0000000000017271112650427414732630 -> -11.76267968314038748995178212654921 Inexact Rounded
+logx2210 log10 6.962605370078885647639503548229695 -> 0.8427717807200322352686396925992250 Inexact Rounded
+logx2211 log10 0.3354804428992793132855923541692781 -> -0.4743327923012159170967636070844834 Inexact Rounded
+logx2212 log10 2.079864257474859008252165836663504 -> 0.3180349916198059046812506741388856 Inexact Rounded
+logx2213 log10 2805.479529292939499220276986621988 -> 3.448007104139974344565978780624744 Inexact Rounded
+logx2214 log10 66.45731133034187374557028537213949 -> 1.822542767005644041661520936223086 Inexact Rounded
+logx2215 log10 0.0000001206521261762681738274822835 -> -6.918465020390216969561494755767318 Inexact Rounded
+logx2216 log10 0.0000000001884891916264401160472381 -> -9.724713548119065386091933007528633 Inexact Rounded
+logx2217 log10 0.0000015467279551726326581314582759 -> -5.810586065070435383755759514608738 Inexact Rounded
+logx2218 log10 0.0090776316728068586744633914135952 -> -2.042027442843745884503280954390114 Inexact Rounded
+logx2219 log10 0.0000000000024541106528713393740030 -> -11.61010585935635713090119156069479 Inexact Rounded
+logx2220 log10 14.12936879385863410081087750645856 -> 1.150122760895466989841057385742662 Inexact Rounded
+logx2221 log10 0.0000036912481831392922922647231392 -> -5.432826753789892283556211380824203 Inexact Rounded
+logx2222 log10 0.0000000004067477525420424270138734 -> -9.390674838050073122857868012475060 Inexact Rounded
+logx2223 log10 7080.122562705399744969319589806194 -> 3.850040775747103318724330047546916 Inexact Rounded
+logx2224 log10 261.3491411363679209175524790255725 -> 2.417221077227536319655699517530855 Inexact Rounded
+logx2225 log10 003.9945581449915240094728380041494 -> 0.6014687471531988260823066997845691 Inexact Rounded
+logx2226 log10 0.0000000000583549164588495206767840 -> -10.23392254834182677023231713519341 Inexact Rounded
+logx2227 log10 9567.961832607240278342761088487484 -> 3.980819434211107631569386147016368 Inexact Rounded
+logx2228 log10 06.26592979160342972777219828867033 -> 0.7969855243966221408595024012574729 Inexact Rounded
+logx2229 log10 0.0000000000589847046598067273287319 -> -10.22926059078206218717755253582907 Inexact Rounded
+logx2230 log10 567.9388648235589204769442863724997 -> 2.754301589058313576472380262907638 Inexact Rounded
+logx2231 log10 039.7790325480037778918162264883415 -> 1.599654216592019199639285308997886 Inexact Rounded
+logx2232 log10 0.0000000005123951921894162149817207 -> -9.290394953898862694847327137242690 Inexact Rounded
+logx2233 log10 0.0000000000038500999723636904276723 -> -11.41452799337924056186867324854691 Inexact Rounded
+logx2234 log10 0.0006726500658977759825616537935864 -> -3.172210810922768725687671849421792 Inexact Rounded
+logx2235 log10 260.2400250475967528429943779126507 -> 2.415374092073799204236801383070064 Inexact Rounded
+logx2236 log10 0.0000000006101942339385102585042548 -> -9.214531900562046557191261226632509 Inexact Rounded
+logx2237 log10 0.0000000010846867501382746760066557 -> -8.964695664883282406359874242387236 Inexact Rounded
+logx2238 log10 60.24078375568814769010333711509928 -> 1.779890613567084253168373266648922 Inexact Rounded
+logx2239 log10 0.0012058738711757669337600252986093 -> -2.918698115012605915753728220896010 Inexact Rounded
+logx2240 log10 230.9450930197841600611503095185600 -> 2.363508739056822846742942599628966 Inexact Rounded
+
+-- P=16, within 0-999
+Precision: 16
+logx2101 log10 0.0072067119605184 -> -2.142262835573038 Inexact Rounded
+logx2102 log10 503.6828482226624 -> 2.702157162195652 Inexact Rounded
+logx2103 log10 64.96074447821815 -> 1.812650993464174 Inexact Rounded
+logx2104 log10 48.75408597467246 -> 1.688011018842600 Inexact Rounded
+logx2105 log10 0.0329009839269587 -> -1.482791113975280 Inexact Rounded
+logx2106 log10 223.5320415060633 -> 2.349339784523410 Inexact Rounded
+logx2107 log10 73.12765002292194 -> 1.864081617476268 Inexact Rounded
+logx2108 log10 487.3749378358509 -> 2.687863192802252 Inexact Rounded
+logx2109 log10 0.0000019671987621 -> -5.706151757557926 Inexact Rounded
+logx2110 log10 0.0570680660609784 -> -1.243606844697873 Inexact Rounded
+logx2111 log10 33.10311638788998 -> 1.519868880976773 Inexact Rounded
+logx2112 log10 0.0687382699187077 -> -1.162801402868185 Inexact Rounded
+logx2113 log10 258.9416193626484 -> 2.413201859654145 Inexact Rounded
+logx2114 log10 0.0005306100136736 -> -3.275224558269725 Inexact Rounded
+logx2115 log10 65.78490393408572 -> 1.818126244825109 Inexact Rounded
+logx2116 log10 504.2328842073510 -> 2.702631165346958 Inexact Rounded
+logx2117 log10 9.417432755815027 -> 0.9739325278524503 Inexact Rounded
+logx2118 log10 006.7054835355498 -> 0.8264301004947640 Inexact Rounded
+logx2119 log10 0.0917012272363915 -> -1.037624852133399 Inexact Rounded
+logx2120 log10 5.959404385244921 -> 0.7752028561953401 Inexact Rounded
+logx2121 log10 0.0001209759148486 -> -3.917301084968903 Inexact Rounded
+logx2122 log10 0.0004706112139838 -> -3.327337728428039 Inexact Rounded
+logx2123 log10 0.0069700457377046 -> -2.156764372035771 Inexact Rounded
+logx2124 log10 0.5155584569852619 -> -0.2877220847805025 Inexact Rounded
+logx2125 log10 88.06005885607414 -> 1.944778971389913 Inexact Rounded
+logx2126 log10 0.0448240038219866 -> -1.348489353509709 Inexact Rounded
+logx2127 log10 3.419622484059565 -> 0.5339781639101145 Inexact Rounded
+logx2128 log10 5.171123353858721 -> 0.7135848977142854 Inexact Rounded
+logx2129 log10 0.0002133188319807 -> -3.670970802945872 Inexact Rounded
+logx2130 log10 46.21086703136966 -> 1.664744117045149 Inexact Rounded
+logx2131 log10 0.0000631053714415 -> -4.199933672639880 Inexact Rounded
+logx2132 log10 78.66019196870698 -> 1.895755001962469 Inexact Rounded
+logx2133 log10 0.0007152278351188 -> -3.145555592082297 Inexact Rounded
+logx2134 log10 45.52509819928536 -> 1.658250891256892 Inexact Rounded
+logx2135 log10 0.0000703227795740 -> -4.152903971697183 Inexact Rounded
+logx2136 log10 26.24438641426669 -> 1.419036423550599 Inexact Rounded
+logx2137 log10 0.0000044654829535 -> -5.350131564166817 Inexact Rounded
+logx2138 log10 0.7360702733062529 -> -0.1330807211893611 Inexact Rounded
+logx2139 log10 8.417059176469655 -> 0.9251603805112778 Inexact Rounded
+logx2140 log10 0.0002926570767968 -> -3.533640969664818 Inexact Rounded
+
+-- P=7, within 0-99
+Precision: 7
+logx2001 log10 57.26089 -> 1.757858 Inexact Rounded
+logx2002 log10 0.0575421 -> -1.240014 Inexact Rounded
+logx2003 log10 0.5918465 -> -0.2277909 Inexact Rounded
+logx2004 log10 0.0068776 -> -2.162563 Inexact Rounded
+logx2005 log10 0.0066833 -> -2.175009 Inexact Rounded
+logx2006 log10 9.926963 -> 0.9968164 Inexact Rounded
+logx2007 log10 0.0041852 -> -2.378284 Inexact Rounded
+logx2008 log10 84.15412 -> 1.925075 Inexact Rounded
+logx2009 log10 2.466856 -> 0.3921438 Inexact Rounded
+logx2010 log10 0.0058047 -> -2.236220 Inexact Rounded
+logx2011 log10 9.885154 -> 0.9949834 Inexact Rounded
+logx2012 log10 0.6667654 -> -0.1760269 Inexact Rounded
+logx2013 log10 34.65736 -> 1.539795 Inexact Rounded
+logx2014 log10 0.0026884 -> -2.570506 Inexact Rounded
+logx2015 log10 0.0432767 -> -1.363746 Inexact Rounded
+logx2016 log10 66.01407 -> 1.819637 Inexact Rounded
+logx2017 log10 0.0070572 -> -2.151368 Inexact Rounded
+logx2018 log10 0.0731613 -> -1.135719 Inexact Rounded
+logx2019 log10 9.838983 -> 0.9929502 Inexact Rounded
+logx2020 log10 15.89696 -> 1.201314 Inexact Rounded
+logx2021 log10 8.459247 -> 0.9273317 Inexact Rounded
+logx2022 log10 0.0010873 -> -2.963651 Inexact Rounded
+logx2023 log10 0.6498619 -> -0.1871789 Inexact Rounded
+logx2024 log10 0.0847008 -> -1.072112 Inexact Rounded
+logx2025 log10 0.0075489 -> -2.122116 Inexact Rounded
+logx2026 log10 51.11152 -> 1.708519 Inexact Rounded
+logx2027 log10 0.7233866 -> -0.1406295 Inexact Rounded
+logx2028 log10 2.254721 -> 0.3530928 Inexact Rounded
+logx2029 log10 6.568444 -> 0.8174625 Inexact Rounded
+logx2030 log10 83.72639 -> 1.922862 Inexact Rounded
+logx2031 log10 6.720585 -> 0.8274071 Inexact Rounded
+logx2032 log10 87.90366 -> 1.944007 Inexact Rounded
+logx2033 log10 0.0433324 -> -1.363187 Inexact Rounded
+logx2034 log10 34.63912 -> 1.539567 Inexact Rounded
+logx2035 log10 0.8089059 -> -0.09210200 Inexact Rounded
+logx2036 log10 7.793405 -> 0.8917272 Inexact Rounded
+logx2037 log10 0.0041757 -> -2.379271 Inexact Rounded
+logx2038 log10 7.135417 -> 0.8534194 Inexact Rounded
+logx2039 log10 12.49570 -> 1.096761 Inexact Rounded
+logx2040 log10 6.356276 -> 0.8032027 Inexact Rounded
+
+--------
+maxExponent: 384
+minExponent: -383
+precision: 16
+rounding: half_even
+
+-- special values
+logx820 log10 Infinity -> Infinity
+logx821 log10 0 -> -Infinity
+logx822 log10 NaN -> NaN
+logx823 log10 sNaN -> NaN Invalid_operation
+-- propagating NaNs
+logx824 log10 sNaN123 -> NaN123 Invalid_operation
+logx825 log10 -sNaN321 -> -NaN321 Invalid_operation
+logx826 log10 NaN456 -> NaN456
+logx827 log10 -NaN654 -> -NaN654
+logx828 log10 NaN1 -> NaN1
+
+
+-- Invalid operations due to restrictions
+-- [next two probably skipped by most test harnesses]
+precision: 100000000
+logx901 log10 1 -> NaN Invalid_context
+precision: 99999999
+logx902 log10 0 -> NaN Invalid_context
+
+precision: 9
+maxExponent: 1000000
+minExponent: -999999
+logx903 log10 1 -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999999
+logx904 log10 0 -> -Infinity
+maxExponent: 999999
+minExponent: -1000000
+logx905 log10 1 -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999998
+logx906 log10 0 -> -Infinity
+
+-- Null test
+logx900 log10 # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/logb.decTest b/Lib/test/decimaltestdata/logb.decTest
index 8b79006257..ff420d0a84 100644
--- a/Lib/test/decimaltestdata/logb.decTest
+++ b/Lib/test/decimaltestdata/logb.decTest
@@ -1,188 +1,188 @@
-------------------------------------------------------------------------
--- logb.decTest -- return integral adjusted exponent as per 754r --
--- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This emphasises the testing of notable cases, as they will often
--- have unusual paths (especially the 10**n results).
-
-extended: 1
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-
--- basics & examples
-precision: 9
-logbx001 logb 0 -> -Infinity Division_by_zero
-logbx002 logb 1E-999 -> -999
-logbx003 logb 9E-999 -> -999
-logbx004 logb 0.001 -> -3
-logbx005 logb 0.03 -> -2
-logbx006 logb 1 -> 0
-logbx007 logb 2 -> 0
-logbx008 logb 2.5 -> 0
-logbx009 logb 2.50 -> 0
-logbx010 logb 10 -> 1
-logbx011 logb 70 -> 1
-logbx012 logb 100 -> 2
-logbx013 logb 250 -> 2
-logbx014 logb +Infinity -> Infinity
-
--- negatives are treated as positives
-logbx021 logb -0 -> -Infinity Division_by_zero
-logbx022 logb -1E-999 -> -999
-logbx023 logb -9E-999 -> -999
-logbx024 logb -0.001 -> -3
-logbx025 logb -1 -> 0
-logbx026 logb -2 -> 0
-logbx027 logb -10 -> 1
-logbx028 logb -70 -> 1
-logbx029 logb -100 -> 2
-logbx030 logb -100000000 -> 8
-logbx031 logb -Infinity -> Infinity
-
--- zeros
-logbx111 logb 0 -> -Infinity Division_by_zero
-logbx112 logb -0 -> -Infinity Division_by_zero
-logbx113 logb 0E+4 -> -Infinity Division_by_zero
-logbx114 logb -0E+4 -> -Infinity Division_by_zero
-logbx115 logb 0.0000 -> -Infinity Division_by_zero
-logbx116 logb -0.0000 -> -Infinity Division_by_zero
-logbx117 logb 0E-141 -> -Infinity Division_by_zero
-logbx118 logb -0E-141 -> -Infinity Division_by_zero
-
--- full coefficients, alternating bits
-logbx121 logb 268268268 -> 8
-logbx122 logb -268268268 -> 8
-logbx123 logb 134134134 -> 8
-logbx124 logb -134134134 -> 8
-
--- Nmax, Nmin, Ntiny
-logbx131 logb 9.99999999E+999 -> 999
-logbx132 logb 1E-999 -> -999
-logbx133 logb 1.00000000E-999 -> -999
-logbx134 logb 1E-1007 -> -1007
-
-logbx135 logb -1E-1007 -> -1007
-logbx136 logb -1.00000000E-999 -> -999
-logbx137 logb -1E-999 -> -999
-logbx138 logb -9.99999999E+999 -> 999
-
--- ones
-logbx0061 logb 1 -> 0
-logbx0062 logb 1.0 -> 0
-logbx0063 logb 1.000000000000000 -> 0
-logbx0064 logb 1.000000000000000000 -> 0
-
--- notable cases -- exact powers of 10
-logbx1100 logb 1 -> 0
-logbx1101 logb 10 -> 1
-logbx1102 logb 100 -> 2
-logbx1103 logb 1000 -> 3
-logbx1104 logb 10000 -> 4
-logbx1105 logb 100000 -> 5
-logbx1106 logb 1000000 -> 6
-logbx1107 logb 10000000 -> 7
-logbx1108 logb 100000000 -> 8
-logbx1109 logb 1000000000 -> 9
-logbx1110 logb 10000000000 -> 10
-logbx1111 logb 100000000000 -> 11
-logbx1112 logb 1000000000000 -> 12
-logbx1113 logb 0.00000000001 -> -11
-logbx1114 logb 0.0000000001 -> -10
-logbx1115 logb 0.000000001 -> -9
-logbx1116 logb 0.00000001 -> -8
-logbx1117 logb 0.0000001 -> -7
-logbx1118 logb 0.000001 -> -6
-logbx1119 logb 0.00001 -> -5
-logbx1120 logb 0.0001 -> -4
-logbx1121 logb 0.001 -> -3
-logbx1122 logb 0.01 -> -2
-logbx1123 logb 0.1 -> -1
-logbx1124 logb 1E-99 -> -99
-logbx1125 logb 1E-100 -> -100
-logbx1126 logb 1E-383 -> -383
-logbx1127 logb 1E-999 -> -999
-
--- suggestions from Ilan Nehama
-logbx1400 logb 10E-3 -> -2
-logbx1401 logb 10E-2 -> -1
-logbx1402 logb 100E-2 -> 0
-logbx1403 logb 1000E-2 -> 1
-logbx1404 logb 10000E-2 -> 2
-logbx1405 logb 10E-1 -> 0
-logbx1406 logb 100E-1 -> 1
-logbx1407 logb 1000E-1 -> 2
-logbx1408 logb 10000E-1 -> 3
-logbx1409 logb 10E0 -> 1
-logbx1410 logb 100E0 -> 2
-logbx1411 logb 1000E0 -> 3
-logbx1412 logb 10000E0 -> 4
-logbx1413 logb 10E1 -> 2
-logbx1414 logb 100E1 -> 3
-logbx1415 logb 1000E1 -> 4
-logbx1416 logb 10000E1 -> 5
-logbx1417 logb 10E2 -> 3
-logbx1418 logb 100E2 -> 4
-logbx1419 logb 1000E2 -> 5
-logbx1420 logb 10000E2 -> 6
-
--- inexacts
-precision: 2
-logbx1500 logb 10000E2 -> 6
-logbx1501 logb 1E+99 -> 99
-logbx1502 logb 1E-99 -> -99
-logbx1503 logb 1E+100 -> 1.0E+2 Rounded
-logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded
-logbx1505 logb 1E-100 -> -1.0E+2 Rounded
-logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded
-logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded
-logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded
-logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded
-logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded
-logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded
-precision: 1
-logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded
-logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded
-logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded
-precision: 8
-logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded
-logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded
-precision: 9
-logbx1523 logb 1E+999999999 -> 999999999
-logbx1524 logb 1E-999999999 -> -999999999
-
--- special values
-precision: 9
-logbx820 logb Infinity -> Infinity
-logbx821 logb -Infinity -> Infinity
-logbx822 logb 0 -> -Infinity Division_by_zero
-logbx823 logb NaN -> NaN
-logbx824 logb sNaN -> NaN Invalid_operation
--- propagating NaNs
-logbx825 logb sNaN123 -> NaN123 Invalid_operation
-logbx826 logb -sNaN321 -> -NaN321 Invalid_operation
-logbx827 logb NaN456 -> NaN456
-logbx828 logb -NaN654 -> -NaN654
-logbx829 logb NaN1 -> NaN1
-
--- Null test
-logbx900 logb # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- logb.decTest -- return integral adjusted exponent as per 754r --
+-- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This emphasises the testing of notable cases, as they will often
+-- have unusual paths (especially the 10**n results).
+
+extended: 1
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+
+-- basics & examples
+precision: 9
+logbx001 logb 0 -> -Infinity Division_by_zero
+logbx002 logb 1E-999 -> -999
+logbx003 logb 9E-999 -> -999
+logbx004 logb 0.001 -> -3
+logbx005 logb 0.03 -> -2
+logbx006 logb 1 -> 0
+logbx007 logb 2 -> 0
+logbx008 logb 2.5 -> 0
+logbx009 logb 2.50 -> 0
+logbx010 logb 10 -> 1
+logbx011 logb 70 -> 1
+logbx012 logb 100 -> 2
+logbx013 logb 250 -> 2
+logbx014 logb +Infinity -> Infinity
+
+-- negatives are treated as positives
+logbx021 logb -0 -> -Infinity Division_by_zero
+logbx022 logb -1E-999 -> -999
+logbx023 logb -9E-999 -> -999
+logbx024 logb -0.001 -> -3
+logbx025 logb -1 -> 0
+logbx026 logb -2 -> 0
+logbx027 logb -10 -> 1
+logbx028 logb -70 -> 1
+logbx029 logb -100 -> 2
+logbx030 logb -100000000 -> 8
+logbx031 logb -Infinity -> Infinity
+
+-- zeros
+logbx111 logb 0 -> -Infinity Division_by_zero
+logbx112 logb -0 -> -Infinity Division_by_zero
+logbx113 logb 0E+4 -> -Infinity Division_by_zero
+logbx114 logb -0E+4 -> -Infinity Division_by_zero
+logbx115 logb 0.0000 -> -Infinity Division_by_zero
+logbx116 logb -0.0000 -> -Infinity Division_by_zero
+logbx117 logb 0E-141 -> -Infinity Division_by_zero
+logbx118 logb -0E-141 -> -Infinity Division_by_zero
+
+-- full coefficients, alternating bits
+logbx121 logb 268268268 -> 8
+logbx122 logb -268268268 -> 8
+logbx123 logb 134134134 -> 8
+logbx124 logb -134134134 -> 8
+
+-- Nmax, Nmin, Ntiny
+logbx131 logb 9.99999999E+999 -> 999
+logbx132 logb 1E-999 -> -999
+logbx133 logb 1.00000000E-999 -> -999
+logbx134 logb 1E-1007 -> -1007
+
+logbx135 logb -1E-1007 -> -1007
+logbx136 logb -1.00000000E-999 -> -999
+logbx137 logb -1E-999 -> -999
+logbx138 logb -9.99999999E+999 -> 999
+
+-- ones
+logbx0061 logb 1 -> 0
+logbx0062 logb 1.0 -> 0
+logbx0063 logb 1.000000000000000 -> 0
+logbx0064 logb 1.000000000000000000 -> 0
+
+-- notable cases -- exact powers of 10
+logbx1100 logb 1 -> 0
+logbx1101 logb 10 -> 1
+logbx1102 logb 100 -> 2
+logbx1103 logb 1000 -> 3
+logbx1104 logb 10000 -> 4
+logbx1105 logb 100000 -> 5
+logbx1106 logb 1000000 -> 6
+logbx1107 logb 10000000 -> 7
+logbx1108 logb 100000000 -> 8
+logbx1109 logb 1000000000 -> 9
+logbx1110 logb 10000000000 -> 10
+logbx1111 logb 100000000000 -> 11
+logbx1112 logb 1000000000000 -> 12
+logbx1113 logb 0.00000000001 -> -11
+logbx1114 logb 0.0000000001 -> -10
+logbx1115 logb 0.000000001 -> -9
+logbx1116 logb 0.00000001 -> -8
+logbx1117 logb 0.0000001 -> -7
+logbx1118 logb 0.000001 -> -6
+logbx1119 logb 0.00001 -> -5
+logbx1120 logb 0.0001 -> -4
+logbx1121 logb 0.001 -> -3
+logbx1122 logb 0.01 -> -2
+logbx1123 logb 0.1 -> -1
+logbx1124 logb 1E-99 -> -99
+logbx1125 logb 1E-100 -> -100
+logbx1126 logb 1E-383 -> -383
+logbx1127 logb 1E-999 -> -999
+
+-- suggestions from Ilan Nehama
+logbx1400 logb 10E-3 -> -2
+logbx1401 logb 10E-2 -> -1
+logbx1402 logb 100E-2 -> 0
+logbx1403 logb 1000E-2 -> 1
+logbx1404 logb 10000E-2 -> 2
+logbx1405 logb 10E-1 -> 0
+logbx1406 logb 100E-1 -> 1
+logbx1407 logb 1000E-1 -> 2
+logbx1408 logb 10000E-1 -> 3
+logbx1409 logb 10E0 -> 1
+logbx1410 logb 100E0 -> 2
+logbx1411 logb 1000E0 -> 3
+logbx1412 logb 10000E0 -> 4
+logbx1413 logb 10E1 -> 2
+logbx1414 logb 100E1 -> 3
+logbx1415 logb 1000E1 -> 4
+logbx1416 logb 10000E1 -> 5
+logbx1417 logb 10E2 -> 3
+logbx1418 logb 100E2 -> 4
+logbx1419 logb 1000E2 -> 5
+logbx1420 logb 10000E2 -> 6
+
+-- inexacts
+precision: 2
+logbx1500 logb 10000E2 -> 6
+logbx1501 logb 1E+99 -> 99
+logbx1502 logb 1E-99 -> -99
+logbx1503 logb 1E+100 -> 1.0E+2 Rounded
+logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded
+logbx1505 logb 1E-100 -> -1.0E+2 Rounded
+logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded
+logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded
+logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded
+logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded
+logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded
+logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded
+precision: 1
+logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded
+logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded
+logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded
+precision: 8
+logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded
+logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded
+precision: 9
+logbx1523 logb 1E+999999999 -> 999999999
+logbx1524 logb 1E-999999999 -> -999999999
+
+-- special values
+precision: 9
+logbx820 logb Infinity -> Infinity
+logbx821 logb -Infinity -> Infinity
+logbx822 logb 0 -> -Infinity Division_by_zero
+logbx823 logb NaN -> NaN
+logbx824 logb sNaN -> NaN Invalid_operation
+-- propagating NaNs
+logbx825 logb sNaN123 -> NaN123 Invalid_operation
+logbx826 logb -sNaN321 -> -NaN321 Invalid_operation
+logbx827 logb NaN456 -> NaN456
+logbx828 logb -NaN654 -> -NaN654
+logbx829 logb NaN1 -> NaN1
+
+-- Null test
+logbx900 logb # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/maxmag.decTest b/Lib/test/decimaltestdata/maxmag.decTest
index 265e912ed4..6b44213079 100644
--- a/Lib/test/decimaltestdata/maxmag.decTest
+++ b/Lib/test/decimaltestdata/maxmag.decTest
@@ -1,404 +1,404 @@
-------------------------------------------------------------------------
--- maxmag.decTest -- decimal maximum by magnitude --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- sanity checks
-mxgx001 maxmag -2 -2 -> -2
-mxgx002 maxmag -2 -1 -> -2
-mxgx003 maxmag -2 0 -> -2
-mxgx004 maxmag -2 1 -> -2
-mxgx005 maxmag -2 2 -> 2
-mxgx006 maxmag -1 -2 -> -2
-mxgx007 maxmag -1 -1 -> -1
-mxgx008 maxmag -1 0 -> -1
-mxgx009 maxmag -1 1 -> 1
-mxgx010 maxmag -1 2 -> 2
-mxgx011 maxmag 0 -2 -> -2
-mxgx012 maxmag 0 -1 -> -1
-mxgx013 maxmag 0 0 -> 0
-mxgx014 maxmag 0 1 -> 1
-mxgx015 maxmag 0 2 -> 2
-mxgx016 maxmag 1 -2 -> -2
-mxgx017 maxmag 1 -1 -> 1
-mxgx018 maxmag 1 0 -> 1
-mxgx019 maxmag 1 1 -> 1
-mxgx020 maxmag 1 2 -> 2
-mxgx021 maxmag 2 -2 -> 2
-mxgx022 maxmag 2 -1 -> 2
-mxgx023 maxmag 2 0 -> 2
-mxgx025 maxmag 2 1 -> 2
-mxgx026 maxmag 2 2 -> 2
-
--- extended zeros
-mxgx030 maxmag 0 0 -> 0
-mxgx031 maxmag 0 -0 -> 0
-mxgx032 maxmag 0 -0.0 -> 0
-mxgx033 maxmag 0 0.0 -> 0
-mxgx034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-mxgx035 maxmag -0 -0 -> -0
-mxgx036 maxmag -0 -0.0 -> -0.0
-mxgx037 maxmag -0 0.0 -> 0.0
-mxgx038 maxmag 0.0 0 -> 0
-mxgx039 maxmag 0.0 -0 -> 0.0
-mxgx040 maxmag 0.0 -0.0 -> 0.0
-mxgx041 maxmag 0.0 0.0 -> 0.0
-mxgx042 maxmag -0.0 0 -> 0
-mxgx043 maxmag -0.0 -0 -> -0.0
-mxgx044 maxmag -0.0 -0.0 -> -0.0
-mxgx045 maxmag -0.0 0.0 -> 0.0
-
-mxgx050 maxmag -0E1 0E1 -> 0E+1
-mxgx051 maxmag -0E2 0E2 -> 0E+2
-mxgx052 maxmag -0E2 0E1 -> 0E+1
-mxgx053 maxmag -0E1 0E2 -> 0E+2
-mxgx054 maxmag 0E1 -0E1 -> 0E+1
-mxgx055 maxmag 0E2 -0E2 -> 0E+2
-mxgx056 maxmag 0E2 -0E1 -> 0E+2
-mxgx057 maxmag 0E1 -0E2 -> 0E+1
-
-mxgx058 maxmag 0E1 0E1 -> 0E+1
-mxgx059 maxmag 0E2 0E2 -> 0E+2
-mxgx060 maxmag 0E2 0E1 -> 0E+2
-mxgx061 maxmag 0E1 0E2 -> 0E+2
-mxgx062 maxmag -0E1 -0E1 -> -0E+1
-mxgx063 maxmag -0E2 -0E2 -> -0E+2
-mxgx064 maxmag -0E2 -0E1 -> -0E+1
-mxgx065 maxmag -0E1 -0E2 -> -0E+1
-
--- Specials
-precision: 9
-mxgx090 maxmag Inf -Inf -> Infinity
-mxgx091 maxmag Inf -1000 -> Infinity
-mxgx092 maxmag Inf -1 -> Infinity
-mxgx093 maxmag Inf -0 -> Infinity
-mxgx094 maxmag Inf 0 -> Infinity
-mxgx095 maxmag Inf 1 -> Infinity
-mxgx096 maxmag Inf 1000 -> Infinity
-mxgx097 maxmag Inf Inf -> Infinity
-mxgx098 maxmag -1000 Inf -> Infinity
-mxgx099 maxmag -Inf Inf -> Infinity
-mxgx100 maxmag -1 Inf -> Infinity
-mxgx101 maxmag -0 Inf -> Infinity
-mxgx102 maxmag 0 Inf -> Infinity
-mxgx103 maxmag 1 Inf -> Infinity
-mxgx104 maxmag 1000 Inf -> Infinity
-mxgx105 maxmag Inf Inf -> Infinity
-
-mxgx120 maxmag -Inf -Inf -> -Infinity
-mxgx121 maxmag -Inf -1000 -> -Infinity
-mxgx122 maxmag -Inf -1 -> -Infinity
-mxgx123 maxmag -Inf -0 -> -Infinity
-mxgx124 maxmag -Inf 0 -> -Infinity
-mxgx125 maxmag -Inf 1 -> -Infinity
-mxgx126 maxmag -Inf 1000 -> -Infinity
-mxgx127 maxmag -Inf Inf -> Infinity
-mxgx128 maxmag -Inf -Inf -> -Infinity
-mxgx129 maxmag -1000 -Inf -> -Infinity
-mxgx130 maxmag -1 -Inf -> -Infinity
-mxgx131 maxmag -0 -Inf -> -Infinity
-mxgx132 maxmag 0 -Inf -> -Infinity
-mxgx133 maxmag 1 -Inf -> -Infinity
-mxgx134 maxmag 1000 -Inf -> -Infinity
-mxgx135 maxmag Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-mxgx141 maxmag NaN -Inf -> -Infinity
-mxgx142 maxmag NaN -1000 -> -1000
-mxgx143 maxmag NaN -1 -> -1
-mxgx144 maxmag NaN -0 -> -0
-mxgx145 maxmag NaN 0 -> 0
-mxgx146 maxmag NaN 1 -> 1
-mxgx147 maxmag NaN 1000 -> 1000
-mxgx148 maxmag NaN Inf -> Infinity
-mxgx149 maxmag NaN NaN -> NaN
-mxgx150 maxmag -Inf NaN -> -Infinity
-mxgx151 maxmag -1000 NaN -> -1000
-mxgx152 maxmag -1 NaN -> -1
-mxgx153 maxmag -0 NaN -> -0
-mxgx154 maxmag 0 NaN -> 0
-mxgx155 maxmag 1 NaN -> 1
-mxgx156 maxmag 1000 NaN -> 1000
-mxgx157 maxmag Inf NaN -> Infinity
-
-mxgx161 maxmag sNaN -Inf -> NaN Invalid_operation
-mxgx162 maxmag sNaN -1000 -> NaN Invalid_operation
-mxgx163 maxmag sNaN -1 -> NaN Invalid_operation
-mxgx164 maxmag sNaN -0 -> NaN Invalid_operation
-mxgx165 maxmag sNaN 0 -> NaN Invalid_operation
-mxgx166 maxmag sNaN 1 -> NaN Invalid_operation
-mxgx167 maxmag sNaN 1000 -> NaN Invalid_operation
-mxgx168 maxmag sNaN NaN -> NaN Invalid_operation
-mxgx169 maxmag sNaN sNaN -> NaN Invalid_operation
-mxgx170 maxmag NaN sNaN -> NaN Invalid_operation
-mxgx171 maxmag -Inf sNaN -> NaN Invalid_operation
-mxgx172 maxmag -1000 sNaN -> NaN Invalid_operation
-mxgx173 maxmag -1 sNaN -> NaN Invalid_operation
-mxgx174 maxmag -0 sNaN -> NaN Invalid_operation
-mxgx175 maxmag 0 sNaN -> NaN Invalid_operation
-mxgx176 maxmag 1 sNaN -> NaN Invalid_operation
-mxgx177 maxmag 1000 sNaN -> NaN Invalid_operation
-mxgx178 maxmag Inf sNaN -> NaN Invalid_operation
-mxgx179 maxmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-mxgx181 maxmag NaN9 -Inf -> -Infinity
-mxgx182 maxmag NaN8 9 -> 9
-mxgx183 maxmag -NaN7 Inf -> Infinity
-
-mxgx184 maxmag -NaN1 NaN11 -> -NaN1
-mxgx185 maxmag NaN2 NaN12 -> NaN2
-mxgx186 maxmag -NaN13 -NaN7 -> -NaN13
-mxgx187 maxmag NaN14 -NaN5 -> NaN14
-
-mxgx188 maxmag -Inf NaN4 -> -Infinity
-mxgx189 maxmag -9 -NaN3 -> -9
-mxgx190 maxmag Inf NaN2 -> Infinity
-
-mxgx191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
-mxgx192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
-mxgx193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
-mxgx194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
-mxgx195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
-mxgx196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
-mxgx197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
-mxgx198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
-mxgx199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
-
--- rounding checks
-maxexponent: 999
-minexponent: -999
-precision: 9
-mxgx201 maxmag 12345678000 1 -> 1.23456780E+10 Rounded
-mxgx202 maxmag 1 12345678000 -> 1.23456780E+10 Rounded
-mxgx203 maxmag 1234567800 1 -> 1.23456780E+9 Rounded
-mxgx204 maxmag 1 1234567800 -> 1.23456780E+9 Rounded
-mxgx205 maxmag 1234567890 1 -> 1.23456789E+9 Rounded
-mxgx206 maxmag 1 1234567890 -> 1.23456789E+9 Rounded
-mxgx207 maxmag 1234567891 1 -> 1.23456789E+9 Inexact Rounded
-mxgx208 maxmag 1 1234567891 -> 1.23456789E+9 Inexact Rounded
-mxgx209 maxmag 12345678901 1 -> 1.23456789E+10 Inexact Rounded
-mxgx210 maxmag 1 12345678901 -> 1.23456789E+10 Inexact Rounded
-mxgx211 maxmag 1234567896 1 -> 1.23456790E+9 Inexact Rounded
-mxgx212 maxmag 1 1234567896 -> 1.23456790E+9 Inexact Rounded
-mxgx213 maxmag -1234567891 1 -> -1.23456789E+9 Inexact Rounded
-mxgx214 maxmag 1 -1234567891 -> -1.23456789E+9 Inexact Rounded
-mxgx215 maxmag -12345678901 1 -> -1.23456789E+10 Inexact Rounded
-mxgx216 maxmag 1 -12345678901 -> -1.23456789E+10 Inexact Rounded
-mxgx217 maxmag -1234567896 1 -> -1.23456790E+9 Inexact Rounded
-mxgx218 maxmag 1 -1234567896 -> -1.23456790E+9 Inexact Rounded
-
-precision: 15
-mxgx221 maxmag 12345678000 1 -> 12345678000
-mxgx222 maxmag 1 12345678000 -> 12345678000
-mxgx223 maxmag 1234567800 1 -> 1234567800
-mxgx224 maxmag 1 1234567800 -> 1234567800
-mxgx225 maxmag 1234567890 1 -> 1234567890
-mxgx226 maxmag 1 1234567890 -> 1234567890
-mxgx227 maxmag 1234567891 1 -> 1234567891
-mxgx228 maxmag 1 1234567891 -> 1234567891
-mxgx229 maxmag 12345678901 1 -> 12345678901
-mxgx230 maxmag 1 12345678901 -> 12345678901
-mxgx231 maxmag 1234567896 1 -> 1234567896
-mxgx232 maxmag 1 1234567896 -> 1234567896
-mxgx233 maxmag -1234567891 1 -> -1234567891
-mxgx234 maxmag 1 -1234567891 -> -1234567891
-mxgx235 maxmag -12345678901 1 -> -12345678901
-mxgx236 maxmag 1 -12345678901 -> -12345678901
-mxgx237 maxmag -1234567896 1 -> -1234567896
-mxgx238 maxmag 1 -1234567896 -> -1234567896
-
--- from examples
-mxgx280 maxmag '3' '2' -> '3'
-mxgx281 maxmag '-10' '3' -> '-10'
-mxgx282 maxmag '1.0' '1' -> '1'
-mxgx283 maxmag '1' '1.0' -> '1'
-mxgx284 maxmag '7' 'NaN' -> '7'
-
--- overflow and underflow tests ...
-maxExponent: 999999999
-minexponent: -999999999
-mxgx330 maxmag +1.23456789012345E-0 9E+999999999 -> 9E+999999999
-mxgx331 maxmag 9E+999999999 +1.23456789012345E-0 -> 9E+999999999
-mxgx332 maxmag +0.100 9E-999999999 -> 0.100
-mxgx333 maxmag 9E-999999999 +0.100 -> 0.100
-mxgx335 maxmag -1.23456789012345E-0 9E+999999999 -> 9E+999999999
-mxgx336 maxmag 9E+999999999 -1.23456789012345E-0 -> 9E+999999999
-mxgx337 maxmag -0.100 9E-999999999 -> -0.100
-mxgx338 maxmag 9E-999999999 -0.100 -> -0.100
-
-mxgx339 maxmag 1e-599999999 1e-400000001 -> 1E-400000001
-mxgx340 maxmag 1e-599999999 1e-400000000 -> 1E-400000000
-mxgx341 maxmag 1e-600000000 1e-400000000 -> 1E-400000000
-mxgx342 maxmag 9e-999999998 0.01 -> 0.01
-mxgx343 maxmag 9e-999999998 0.1 -> 0.1
-mxgx344 maxmag 0.01 9e-999999998 -> 0.01
-mxgx345 maxmag 1e599999999 1e400000001 -> 1E+599999999
-mxgx346 maxmag 1e599999999 1e400000000 -> 1E+599999999
-mxgx347 maxmag 1e600000000 1e400000000 -> 1E+600000000
-mxgx348 maxmag 9e999999998 100 -> 9E+999999998
-mxgx349 maxmag 9e999999998 10 -> 9E+999999998
-mxgx350 maxmag 100 9e999999998 -> 9E+999999998
--- signs
-mxgx351 maxmag 1e+777777777 1e+411111111 -> 1E+777777777
-mxgx352 maxmag 1e+777777777 -1e+411111111 -> 1E+777777777
-mxgx353 maxmag -1e+777777777 1e+411111111 -> -1E+777777777
-mxgx354 maxmag -1e+777777777 -1e+411111111 -> -1E+777777777
-mxgx355 maxmag 1e-777777777 1e-411111111 -> 1E-411111111
-mxgx356 maxmag 1e-777777777 -1e-411111111 -> -1E-411111111
-mxgx357 maxmag -1e-777777777 1e-411111111 -> 1E-411111111
-mxgx358 maxmag -1e-777777777 -1e-411111111 -> -1E-411111111
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-mxgx401 maxmag Inf 1.1 -> Infinity
-mxgx402 maxmag 1.1 1 -> 1.1
-mxgx403 maxmag 1 1.0 -> 1
-mxgx404 maxmag 1.0 0.1 -> 1.0
-mxgx405 maxmag 0.1 0.10 -> 0.1
-mxgx406 maxmag 0.10 0.100 -> 0.10
-mxgx407 maxmag 0.10 0 -> 0.10
-mxgx408 maxmag 0 0.0 -> 0
-mxgx409 maxmag 0.0 -0 -> 0.0
-mxgx410 maxmag 0.0 -0.0 -> 0.0
-mxgx411 maxmag 0.00 -0.0 -> 0.00
-mxgx412 maxmag 0.0 -0.00 -> 0.0
-mxgx413 maxmag 0 -0.0 -> 0
-mxgx414 maxmag 0 -0 -> 0
-mxgx415 maxmag -0.0 -0 -> -0.0
-mxgx416 maxmag -0 -0.100 -> -0.100
-mxgx417 maxmag -0.100 -0.10 -> -0.100
-mxgx418 maxmag -0.10 -0.1 -> -0.10
-mxgx419 maxmag -0.1 -1.0 -> -1.0
-mxgx420 maxmag -1.0 -1 -> -1.0
-mxgx421 maxmag -1 -1.1 -> -1.1
-mxgx423 maxmag -1.1 -Inf -> -Infinity
--- same with operands reversed
-mxgx431 maxmag 1.1 Inf -> Infinity
-mxgx432 maxmag 1 1.1 -> 1.1
-mxgx433 maxmag 1.0 1 -> 1
-mxgx434 maxmag 0.1 1.0 -> 1.0
-mxgx435 maxmag 0.10 0.1 -> 0.1
-mxgx436 maxmag 0.100 0.10 -> 0.10
-mxgx437 maxmag 0 0.10 -> 0.10
-mxgx438 maxmag 0.0 0 -> 0
-mxgx439 maxmag -0 0.0 -> 0.0
-mxgx440 maxmag -0.0 0.0 -> 0.0
-mxgx441 maxmag -0.0 0.00 -> 0.00
-mxgx442 maxmag -0.00 0.0 -> 0.0
-mxgx443 maxmag -0.0 0 -> 0
-mxgx444 maxmag -0 0 -> 0
-mxgx445 maxmag -0 -0.0 -> -0.0
-mxgx446 maxmag -0.100 -0 -> -0.100
-mxgx447 maxmag -0.10 -0.100 -> -0.100
-mxgx448 maxmag -0.1 -0.10 -> -0.10
-mxgx449 maxmag -1.0 -0.1 -> -1.0
-mxgx450 maxmag -1 -1.0 -> -1.0
-mxgx451 maxmag -1.1 -1 -> -1.1
-mxgx453 maxmag -Inf -1.1 -> -Infinity
--- largies
-mxgx460 maxmag 1000 1E+3 -> 1E+3
-mxgx461 maxmag 1E+3 1000 -> 1E+3
-mxgx462 maxmag 1000 -1E+3 -> 1000
-mxgx463 maxmag 1E+3 -1000 -> 1E+3
-mxgx464 maxmag -1000 1E+3 -> 1E+3
-mxgx465 maxmag -1E+3 1000 -> 1000
-mxgx466 maxmag -1000 -1E+3 -> -1000
-mxgx467 maxmag -1E+3 -1000 -> -1000
-
--- rounding (results treated as though plus)
-maxexponent: 999999999
-minexponent: -999999999
-precision: 3
-
-mxgx470 maxmag 1 .5 -> 1
-mxgx471 maxmag 10 5 -> 10
-mxgx472 maxmag 100 50 -> 100
-mxgx473 maxmag 1000 500 -> 1.00E+3 Rounded
-mxgx474 maxmag 10000 5000 -> 1.00E+4 Rounded
-mxgx475 maxmag 6 .5 -> 6
-mxgx476 maxmag 66 5 -> 66
-mxgx477 maxmag 666 50 -> 666
-mxgx478 maxmag 6666 500 -> 6.67E+3 Rounded Inexact
-mxgx479 maxmag 66666 5000 -> 6.67E+4 Rounded Inexact
-mxgx480 maxmag 33333 5000 -> 3.33E+4 Rounded Inexact
-mxgx481 maxmag .5 1 -> 1
-mxgx482 maxmag .5 10 -> 10
-mxgx483 maxmag .5 100 -> 100
-mxgx484 maxmag .5 1000 -> 1.00E+3 Rounded
-mxgx485 maxmag .5 10000 -> 1.00E+4 Rounded
-mxgx486 maxmag .5 6 -> 6
-mxgx487 maxmag .5 66 -> 66
-mxgx488 maxmag .5 666 -> 666
-mxgx489 maxmag .5 6666 -> 6.67E+3 Rounded Inexact
-mxgx490 maxmag .5 66666 -> 6.67E+4 Rounded Inexact
-mxgx491 maxmag .5 33333 -> 3.33E+4 Rounded Inexact
-
--- overflow tests
-maxexponent: 999999999
-minexponent: -999999999
-precision: 3
-mxgx500 maxmag 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded
-mxgx501 maxmag -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded
-
--- subnormals and underflow
-precision: 3
-maxexponent: 999
-minexponent: -999
-mxgx510 maxmag 1.00E-999 0 -> 1.00E-999
-mxgx511 maxmag 0.1E-999 0 -> 1E-1000 Subnormal
-mxgx512 maxmag 0.10E-999 0 -> 1.0E-1000 Subnormal
-mxgx513 maxmag 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded
-mxgx514 maxmag 0.01E-999 0 -> 1E-1001 Subnormal
--- next is rounded to Nmin
-mxgx515 maxmag 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow
-mxgx516 maxmag 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
-mxgx517 maxmag 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow
-mxgx518 maxmag 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-mxgx519 maxmag 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-mxgx520 maxmag 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-
-mxgx530 maxmag -1.00E-999 0 -> -1.00E-999
-mxgx531 maxmag -0.1E-999 0 -> -1E-1000 Subnormal
-mxgx532 maxmag -0.10E-999 0 -> -1.0E-1000 Subnormal
-mxgx533 maxmag -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded
-mxgx534 maxmag -0.01E-999 0 -> -1E-1001 Subnormal
--- next is rounded to -Nmin
-mxgx535 maxmag -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow
-mxgx536 maxmag -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-mxgx537 maxmag -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow
-mxgx538 maxmag -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-mxgx539 maxmag -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-mxgx540 maxmag -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-
--- Null tests
-mxgx900 maxmag 10 # -> NaN Invalid_operation
-mxgx901 maxmag # 10 -> NaN Invalid_operation
-
-
-
+------------------------------------------------------------------------
+-- maxmag.decTest -- decimal maximum by magnitude --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- sanity checks
+mxgx001 maxmag -2 -2 -> -2
+mxgx002 maxmag -2 -1 -> -2
+mxgx003 maxmag -2 0 -> -2
+mxgx004 maxmag -2 1 -> -2
+mxgx005 maxmag -2 2 -> 2
+mxgx006 maxmag -1 -2 -> -2
+mxgx007 maxmag -1 -1 -> -1
+mxgx008 maxmag -1 0 -> -1
+mxgx009 maxmag -1 1 -> 1
+mxgx010 maxmag -1 2 -> 2
+mxgx011 maxmag 0 -2 -> -2
+mxgx012 maxmag 0 -1 -> -1
+mxgx013 maxmag 0 0 -> 0
+mxgx014 maxmag 0 1 -> 1
+mxgx015 maxmag 0 2 -> 2
+mxgx016 maxmag 1 -2 -> -2
+mxgx017 maxmag 1 -1 -> 1
+mxgx018 maxmag 1 0 -> 1
+mxgx019 maxmag 1 1 -> 1
+mxgx020 maxmag 1 2 -> 2
+mxgx021 maxmag 2 -2 -> 2
+mxgx022 maxmag 2 -1 -> 2
+mxgx023 maxmag 2 0 -> 2
+mxgx025 maxmag 2 1 -> 2
+mxgx026 maxmag 2 2 -> 2
+
+-- extended zeros
+mxgx030 maxmag 0 0 -> 0
+mxgx031 maxmag 0 -0 -> 0
+mxgx032 maxmag 0 -0.0 -> 0
+mxgx033 maxmag 0 0.0 -> 0
+mxgx034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+mxgx035 maxmag -0 -0 -> -0
+mxgx036 maxmag -0 -0.0 -> -0.0
+mxgx037 maxmag -0 0.0 -> 0.0
+mxgx038 maxmag 0.0 0 -> 0
+mxgx039 maxmag 0.0 -0 -> 0.0
+mxgx040 maxmag 0.0 -0.0 -> 0.0
+mxgx041 maxmag 0.0 0.0 -> 0.0
+mxgx042 maxmag -0.0 0 -> 0
+mxgx043 maxmag -0.0 -0 -> -0.0
+mxgx044 maxmag -0.0 -0.0 -> -0.0
+mxgx045 maxmag -0.0 0.0 -> 0.0
+
+mxgx050 maxmag -0E1 0E1 -> 0E+1
+mxgx051 maxmag -0E2 0E2 -> 0E+2
+mxgx052 maxmag -0E2 0E1 -> 0E+1
+mxgx053 maxmag -0E1 0E2 -> 0E+2
+mxgx054 maxmag 0E1 -0E1 -> 0E+1
+mxgx055 maxmag 0E2 -0E2 -> 0E+2
+mxgx056 maxmag 0E2 -0E1 -> 0E+2
+mxgx057 maxmag 0E1 -0E2 -> 0E+1
+
+mxgx058 maxmag 0E1 0E1 -> 0E+1
+mxgx059 maxmag 0E2 0E2 -> 0E+2
+mxgx060 maxmag 0E2 0E1 -> 0E+2
+mxgx061 maxmag 0E1 0E2 -> 0E+2
+mxgx062 maxmag -0E1 -0E1 -> -0E+1
+mxgx063 maxmag -0E2 -0E2 -> -0E+2
+mxgx064 maxmag -0E2 -0E1 -> -0E+1
+mxgx065 maxmag -0E1 -0E2 -> -0E+1
+
+-- Specials
+precision: 9
+mxgx090 maxmag Inf -Inf -> Infinity
+mxgx091 maxmag Inf -1000 -> Infinity
+mxgx092 maxmag Inf -1 -> Infinity
+mxgx093 maxmag Inf -0 -> Infinity
+mxgx094 maxmag Inf 0 -> Infinity
+mxgx095 maxmag Inf 1 -> Infinity
+mxgx096 maxmag Inf 1000 -> Infinity
+mxgx097 maxmag Inf Inf -> Infinity
+mxgx098 maxmag -1000 Inf -> Infinity
+mxgx099 maxmag -Inf Inf -> Infinity
+mxgx100 maxmag -1 Inf -> Infinity
+mxgx101 maxmag -0 Inf -> Infinity
+mxgx102 maxmag 0 Inf -> Infinity
+mxgx103 maxmag 1 Inf -> Infinity
+mxgx104 maxmag 1000 Inf -> Infinity
+mxgx105 maxmag Inf Inf -> Infinity
+
+mxgx120 maxmag -Inf -Inf -> -Infinity
+mxgx121 maxmag -Inf -1000 -> -Infinity
+mxgx122 maxmag -Inf -1 -> -Infinity
+mxgx123 maxmag -Inf -0 -> -Infinity
+mxgx124 maxmag -Inf 0 -> -Infinity
+mxgx125 maxmag -Inf 1 -> -Infinity
+mxgx126 maxmag -Inf 1000 -> -Infinity
+mxgx127 maxmag -Inf Inf -> Infinity
+mxgx128 maxmag -Inf -Inf -> -Infinity
+mxgx129 maxmag -1000 -Inf -> -Infinity
+mxgx130 maxmag -1 -Inf -> -Infinity
+mxgx131 maxmag -0 -Inf -> -Infinity
+mxgx132 maxmag 0 -Inf -> -Infinity
+mxgx133 maxmag 1 -Inf -> -Infinity
+mxgx134 maxmag 1000 -Inf -> -Infinity
+mxgx135 maxmag Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+mxgx141 maxmag NaN -Inf -> -Infinity
+mxgx142 maxmag NaN -1000 -> -1000
+mxgx143 maxmag NaN -1 -> -1
+mxgx144 maxmag NaN -0 -> -0
+mxgx145 maxmag NaN 0 -> 0
+mxgx146 maxmag NaN 1 -> 1
+mxgx147 maxmag NaN 1000 -> 1000
+mxgx148 maxmag NaN Inf -> Infinity
+mxgx149 maxmag NaN NaN -> NaN
+mxgx150 maxmag -Inf NaN -> -Infinity
+mxgx151 maxmag -1000 NaN -> -1000
+mxgx152 maxmag -1 NaN -> -1
+mxgx153 maxmag -0 NaN -> -0
+mxgx154 maxmag 0 NaN -> 0
+mxgx155 maxmag 1 NaN -> 1
+mxgx156 maxmag 1000 NaN -> 1000
+mxgx157 maxmag Inf NaN -> Infinity
+
+mxgx161 maxmag sNaN -Inf -> NaN Invalid_operation
+mxgx162 maxmag sNaN -1000 -> NaN Invalid_operation
+mxgx163 maxmag sNaN -1 -> NaN Invalid_operation
+mxgx164 maxmag sNaN -0 -> NaN Invalid_operation
+mxgx165 maxmag sNaN 0 -> NaN Invalid_operation
+mxgx166 maxmag sNaN 1 -> NaN Invalid_operation
+mxgx167 maxmag sNaN 1000 -> NaN Invalid_operation
+mxgx168 maxmag sNaN NaN -> NaN Invalid_operation
+mxgx169 maxmag sNaN sNaN -> NaN Invalid_operation
+mxgx170 maxmag NaN sNaN -> NaN Invalid_operation
+mxgx171 maxmag -Inf sNaN -> NaN Invalid_operation
+mxgx172 maxmag -1000 sNaN -> NaN Invalid_operation
+mxgx173 maxmag -1 sNaN -> NaN Invalid_operation
+mxgx174 maxmag -0 sNaN -> NaN Invalid_operation
+mxgx175 maxmag 0 sNaN -> NaN Invalid_operation
+mxgx176 maxmag 1 sNaN -> NaN Invalid_operation
+mxgx177 maxmag 1000 sNaN -> NaN Invalid_operation
+mxgx178 maxmag Inf sNaN -> NaN Invalid_operation
+mxgx179 maxmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+mxgx181 maxmag NaN9 -Inf -> -Infinity
+mxgx182 maxmag NaN8 9 -> 9
+mxgx183 maxmag -NaN7 Inf -> Infinity
+
+mxgx184 maxmag -NaN1 NaN11 -> -NaN1
+mxgx185 maxmag NaN2 NaN12 -> NaN2
+mxgx186 maxmag -NaN13 -NaN7 -> -NaN13
+mxgx187 maxmag NaN14 -NaN5 -> NaN14
+
+mxgx188 maxmag -Inf NaN4 -> -Infinity
+mxgx189 maxmag -9 -NaN3 -> -9
+mxgx190 maxmag Inf NaN2 -> Infinity
+
+mxgx191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
+mxgx192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
+mxgx193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
+mxgx194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
+mxgx195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
+mxgx196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
+mxgx197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
+mxgx198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
+mxgx199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
+
+-- rounding checks
+maxexponent: 999
+minexponent: -999
+precision: 9
+mxgx201 maxmag 12345678000 1 -> 1.23456780E+10 Rounded
+mxgx202 maxmag 1 12345678000 -> 1.23456780E+10 Rounded
+mxgx203 maxmag 1234567800 1 -> 1.23456780E+9 Rounded
+mxgx204 maxmag 1 1234567800 -> 1.23456780E+9 Rounded
+mxgx205 maxmag 1234567890 1 -> 1.23456789E+9 Rounded
+mxgx206 maxmag 1 1234567890 -> 1.23456789E+9 Rounded
+mxgx207 maxmag 1234567891 1 -> 1.23456789E+9 Inexact Rounded
+mxgx208 maxmag 1 1234567891 -> 1.23456789E+9 Inexact Rounded
+mxgx209 maxmag 12345678901 1 -> 1.23456789E+10 Inexact Rounded
+mxgx210 maxmag 1 12345678901 -> 1.23456789E+10 Inexact Rounded
+mxgx211 maxmag 1234567896 1 -> 1.23456790E+9 Inexact Rounded
+mxgx212 maxmag 1 1234567896 -> 1.23456790E+9 Inexact Rounded
+mxgx213 maxmag -1234567891 1 -> -1.23456789E+9 Inexact Rounded
+mxgx214 maxmag 1 -1234567891 -> -1.23456789E+9 Inexact Rounded
+mxgx215 maxmag -12345678901 1 -> -1.23456789E+10 Inexact Rounded
+mxgx216 maxmag 1 -12345678901 -> -1.23456789E+10 Inexact Rounded
+mxgx217 maxmag -1234567896 1 -> -1.23456790E+9 Inexact Rounded
+mxgx218 maxmag 1 -1234567896 -> -1.23456790E+9 Inexact Rounded
+
+precision: 15
+mxgx221 maxmag 12345678000 1 -> 12345678000
+mxgx222 maxmag 1 12345678000 -> 12345678000
+mxgx223 maxmag 1234567800 1 -> 1234567800
+mxgx224 maxmag 1 1234567800 -> 1234567800
+mxgx225 maxmag 1234567890 1 -> 1234567890
+mxgx226 maxmag 1 1234567890 -> 1234567890
+mxgx227 maxmag 1234567891 1 -> 1234567891
+mxgx228 maxmag 1 1234567891 -> 1234567891
+mxgx229 maxmag 12345678901 1 -> 12345678901
+mxgx230 maxmag 1 12345678901 -> 12345678901
+mxgx231 maxmag 1234567896 1 -> 1234567896
+mxgx232 maxmag 1 1234567896 -> 1234567896
+mxgx233 maxmag -1234567891 1 -> -1234567891
+mxgx234 maxmag 1 -1234567891 -> -1234567891
+mxgx235 maxmag -12345678901 1 -> -12345678901
+mxgx236 maxmag 1 -12345678901 -> -12345678901
+mxgx237 maxmag -1234567896 1 -> -1234567896
+mxgx238 maxmag 1 -1234567896 -> -1234567896
+
+-- from examples
+mxgx280 maxmag '3' '2' -> '3'
+mxgx281 maxmag '-10' '3' -> '-10'
+mxgx282 maxmag '1.0' '1' -> '1'
+mxgx283 maxmag '1' '1.0' -> '1'
+mxgx284 maxmag '7' 'NaN' -> '7'
+
+-- overflow and underflow tests ...
+maxExponent: 999999999
+minexponent: -999999999
+mxgx330 maxmag +1.23456789012345E-0 9E+999999999 -> 9E+999999999
+mxgx331 maxmag 9E+999999999 +1.23456789012345E-0 -> 9E+999999999
+mxgx332 maxmag +0.100 9E-999999999 -> 0.100
+mxgx333 maxmag 9E-999999999 +0.100 -> 0.100
+mxgx335 maxmag -1.23456789012345E-0 9E+999999999 -> 9E+999999999
+mxgx336 maxmag 9E+999999999 -1.23456789012345E-0 -> 9E+999999999
+mxgx337 maxmag -0.100 9E-999999999 -> -0.100
+mxgx338 maxmag 9E-999999999 -0.100 -> -0.100
+
+mxgx339 maxmag 1e-599999999 1e-400000001 -> 1E-400000001
+mxgx340 maxmag 1e-599999999 1e-400000000 -> 1E-400000000
+mxgx341 maxmag 1e-600000000 1e-400000000 -> 1E-400000000
+mxgx342 maxmag 9e-999999998 0.01 -> 0.01
+mxgx343 maxmag 9e-999999998 0.1 -> 0.1
+mxgx344 maxmag 0.01 9e-999999998 -> 0.01
+mxgx345 maxmag 1e599999999 1e400000001 -> 1E+599999999
+mxgx346 maxmag 1e599999999 1e400000000 -> 1E+599999999
+mxgx347 maxmag 1e600000000 1e400000000 -> 1E+600000000
+mxgx348 maxmag 9e999999998 100 -> 9E+999999998
+mxgx349 maxmag 9e999999998 10 -> 9E+999999998
+mxgx350 maxmag 100 9e999999998 -> 9E+999999998
+-- signs
+mxgx351 maxmag 1e+777777777 1e+411111111 -> 1E+777777777
+mxgx352 maxmag 1e+777777777 -1e+411111111 -> 1E+777777777
+mxgx353 maxmag -1e+777777777 1e+411111111 -> -1E+777777777
+mxgx354 maxmag -1e+777777777 -1e+411111111 -> -1E+777777777
+mxgx355 maxmag 1e-777777777 1e-411111111 -> 1E-411111111
+mxgx356 maxmag 1e-777777777 -1e-411111111 -> -1E-411111111
+mxgx357 maxmag -1e-777777777 1e-411111111 -> 1E-411111111
+mxgx358 maxmag -1e-777777777 -1e-411111111 -> -1E-411111111
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+mxgx401 maxmag Inf 1.1 -> Infinity
+mxgx402 maxmag 1.1 1 -> 1.1
+mxgx403 maxmag 1 1.0 -> 1
+mxgx404 maxmag 1.0 0.1 -> 1.0
+mxgx405 maxmag 0.1 0.10 -> 0.1
+mxgx406 maxmag 0.10 0.100 -> 0.10
+mxgx407 maxmag 0.10 0 -> 0.10
+mxgx408 maxmag 0 0.0 -> 0
+mxgx409 maxmag 0.0 -0 -> 0.0
+mxgx410 maxmag 0.0 -0.0 -> 0.0
+mxgx411 maxmag 0.00 -0.0 -> 0.00
+mxgx412 maxmag 0.0 -0.00 -> 0.0
+mxgx413 maxmag 0 -0.0 -> 0
+mxgx414 maxmag 0 -0 -> 0
+mxgx415 maxmag -0.0 -0 -> -0.0
+mxgx416 maxmag -0 -0.100 -> -0.100
+mxgx417 maxmag -0.100 -0.10 -> -0.100
+mxgx418 maxmag -0.10 -0.1 -> -0.10
+mxgx419 maxmag -0.1 -1.0 -> -1.0
+mxgx420 maxmag -1.0 -1 -> -1.0
+mxgx421 maxmag -1 -1.1 -> -1.1
+mxgx423 maxmag -1.1 -Inf -> -Infinity
+-- same with operands reversed
+mxgx431 maxmag 1.1 Inf -> Infinity
+mxgx432 maxmag 1 1.1 -> 1.1
+mxgx433 maxmag 1.0 1 -> 1
+mxgx434 maxmag 0.1 1.0 -> 1.0
+mxgx435 maxmag 0.10 0.1 -> 0.1
+mxgx436 maxmag 0.100 0.10 -> 0.10
+mxgx437 maxmag 0 0.10 -> 0.10
+mxgx438 maxmag 0.0 0 -> 0
+mxgx439 maxmag -0 0.0 -> 0.0
+mxgx440 maxmag -0.0 0.0 -> 0.0
+mxgx441 maxmag -0.0 0.00 -> 0.00
+mxgx442 maxmag -0.00 0.0 -> 0.0
+mxgx443 maxmag -0.0 0 -> 0
+mxgx444 maxmag -0 0 -> 0
+mxgx445 maxmag -0 -0.0 -> -0.0
+mxgx446 maxmag -0.100 -0 -> -0.100
+mxgx447 maxmag -0.10 -0.100 -> -0.100
+mxgx448 maxmag -0.1 -0.10 -> -0.10
+mxgx449 maxmag -1.0 -0.1 -> -1.0
+mxgx450 maxmag -1 -1.0 -> -1.0
+mxgx451 maxmag -1.1 -1 -> -1.1
+mxgx453 maxmag -Inf -1.1 -> -Infinity
+-- largies
+mxgx460 maxmag 1000 1E+3 -> 1E+3
+mxgx461 maxmag 1E+3 1000 -> 1E+3
+mxgx462 maxmag 1000 -1E+3 -> 1000
+mxgx463 maxmag 1E+3 -1000 -> 1E+3
+mxgx464 maxmag -1000 1E+3 -> 1E+3
+mxgx465 maxmag -1E+3 1000 -> 1000
+mxgx466 maxmag -1000 -1E+3 -> -1000
+mxgx467 maxmag -1E+3 -1000 -> -1000
+
+-- rounding (results treated as though plus)
+maxexponent: 999999999
+minexponent: -999999999
+precision: 3
+
+mxgx470 maxmag 1 .5 -> 1
+mxgx471 maxmag 10 5 -> 10
+mxgx472 maxmag 100 50 -> 100
+mxgx473 maxmag 1000 500 -> 1.00E+3 Rounded
+mxgx474 maxmag 10000 5000 -> 1.00E+4 Rounded
+mxgx475 maxmag 6 .5 -> 6
+mxgx476 maxmag 66 5 -> 66
+mxgx477 maxmag 666 50 -> 666
+mxgx478 maxmag 6666 500 -> 6.67E+3 Rounded Inexact
+mxgx479 maxmag 66666 5000 -> 6.67E+4 Rounded Inexact
+mxgx480 maxmag 33333 5000 -> 3.33E+4 Rounded Inexact
+mxgx481 maxmag .5 1 -> 1
+mxgx482 maxmag .5 10 -> 10
+mxgx483 maxmag .5 100 -> 100
+mxgx484 maxmag .5 1000 -> 1.00E+3 Rounded
+mxgx485 maxmag .5 10000 -> 1.00E+4 Rounded
+mxgx486 maxmag .5 6 -> 6
+mxgx487 maxmag .5 66 -> 66
+mxgx488 maxmag .5 666 -> 666
+mxgx489 maxmag .5 6666 -> 6.67E+3 Rounded Inexact
+mxgx490 maxmag .5 66666 -> 6.67E+4 Rounded Inexact
+mxgx491 maxmag .5 33333 -> 3.33E+4 Rounded Inexact
+
+-- overflow tests
+maxexponent: 999999999
+minexponent: -999999999
+precision: 3
+mxgx500 maxmag 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded
+mxgx501 maxmag -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded
+
+-- subnormals and underflow
+precision: 3
+maxexponent: 999
+minexponent: -999
+mxgx510 maxmag 1.00E-999 0 -> 1.00E-999
+mxgx511 maxmag 0.1E-999 0 -> 1E-1000 Subnormal
+mxgx512 maxmag 0.10E-999 0 -> 1.0E-1000 Subnormal
+mxgx513 maxmag 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded
+mxgx514 maxmag 0.01E-999 0 -> 1E-1001 Subnormal
+-- next is rounded to Nmin
+mxgx515 maxmag 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow
+mxgx516 maxmag 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+mxgx517 maxmag 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow
+mxgx518 maxmag 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+mxgx519 maxmag 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+mxgx520 maxmag 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+
+mxgx530 maxmag -1.00E-999 0 -> -1.00E-999
+mxgx531 maxmag -0.1E-999 0 -> -1E-1000 Subnormal
+mxgx532 maxmag -0.10E-999 0 -> -1.0E-1000 Subnormal
+mxgx533 maxmag -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded
+mxgx534 maxmag -0.01E-999 0 -> -1E-1001 Subnormal
+-- next is rounded to -Nmin
+mxgx535 maxmag -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow
+mxgx536 maxmag -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+mxgx537 maxmag -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow
+mxgx538 maxmag -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+mxgx539 maxmag -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+mxgx540 maxmag -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+
+-- Null tests
+mxgx900 maxmag 10 # -> NaN Invalid_operation
+mxgx901 maxmag # 10 -> NaN Invalid_operation
+
+
+
diff --git a/Lib/test/decimaltestdata/minmag.decTest b/Lib/test/decimaltestdata/minmag.decTest
index f1ac3852e8..9e562339eb 100644
--- a/Lib/test/decimaltestdata/minmag.decTest
+++ b/Lib/test/decimaltestdata/minmag.decTest
@@ -1,390 +1,390 @@
-------------------------------------------------------------------------
--- minmag.decTest -- decimal minimum by magnitude --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- sanity checks
-mngx001 minmag -2 -2 -> -2
-mngx002 minmag -2 -1 -> -1
-mngx003 minmag -2 0 -> 0
-mngx004 minmag -2 1 -> 1
-mngx005 minmag -2 2 -> -2
-mngx006 minmag -1 -2 -> -1
-mngx007 minmag -1 -1 -> -1
-mngx008 minmag -1 0 -> 0
-mngx009 minmag -1 1 -> -1
-mngx010 minmag -1 2 -> -1
-mngx011 minmag 0 -2 -> 0
-mngx012 minmag 0 -1 -> 0
-mngx013 minmag 0 0 -> 0
-mngx014 minmag 0 1 -> 0
-mngx015 minmag 0 2 -> 0
-mngx016 minmag 1 -2 -> 1
-mngx017 minmag 1 -1 -> -1
-mngx018 minmag 1 0 -> 0
-mngx019 minmag 1 1 -> 1
-mngx020 minmag 1 2 -> 1
-mngx021 minmag 2 -2 -> -2
-mngx022 minmag 2 -1 -> -1
-mngx023 minmag 2 0 -> 0
-mngx025 minmag 2 1 -> 1
-mngx026 minmag 2 2 -> 2
-
--- extended zeros
-mngx030 minmag 0 0 -> 0
-mngx031 minmag 0 -0 -> -0
-mngx032 minmag 0 -0.0 -> -0.0
-mngx033 minmag 0 0.0 -> 0.0
-mngx034 minmag -0 0 -> -0
-mngx035 minmag -0 -0 -> -0
-mngx036 minmag -0 -0.0 -> -0
-mngx037 minmag -0 0.0 -> -0
-mngx038 minmag 0.0 0 -> 0.0
-mngx039 minmag 0.0 -0 -> -0
-mngx040 minmag 0.0 -0.0 -> -0.0
-mngx041 minmag 0.0 0.0 -> 0.0
-mngx042 minmag -0.0 0 -> -0.0
-mngx043 minmag -0.0 -0 -> -0
-mngx044 minmag -0.0 -0.0 -> -0.0
-mngx045 minmag -0.0 0.0 -> -0.0
-
-mngx046 minmag 0E1 -0E1 -> -0E+1
-mngx047 minmag -0E1 0E2 -> -0E+1
-mngx048 minmag 0E2 0E1 -> 0E+1
-mngx049 minmag 0E1 0E2 -> 0E+1
-mngx050 minmag -0E3 -0E2 -> -0E+3
-mngx051 minmag -0E2 -0E3 -> -0E+3
-
--- Specials
-precision: 9
-mngx090 minmag Inf -Inf -> -Infinity
-mngx091 minmag Inf -1000 -> -1000
-mngx092 minmag Inf -1 -> -1
-mngx093 minmag Inf -0 -> -0
-mngx094 minmag Inf 0 -> 0
-mngx095 minmag Inf 1 -> 1
-mngx096 minmag Inf 1000 -> 1000
-mngx097 minmag Inf Inf -> Infinity
-mngx098 minmag -1000 Inf -> -1000
-mngx099 minmag -Inf Inf -> -Infinity
-mngx100 minmag -1 Inf -> -1
-mngx101 minmag -0 Inf -> -0
-mngx102 minmag 0 Inf -> 0
-mngx103 minmag 1 Inf -> 1
-mngx104 minmag 1000 Inf -> 1000
-mngx105 minmag Inf Inf -> Infinity
-
-mngx120 minmag -Inf -Inf -> -Infinity
-mngx121 minmag -Inf -1000 -> -1000
-mngx122 minmag -Inf -1 -> -1
-mngx123 minmag -Inf -0 -> -0
-mngx124 minmag -Inf 0 -> 0
-mngx125 minmag -Inf 1 -> 1
-mngx126 minmag -Inf 1000 -> 1000
-mngx127 minmag -Inf Inf -> -Infinity
-mngx128 minmag -Inf -Inf -> -Infinity
-mngx129 minmag -1000 -Inf -> -1000
-mngx130 minmag -1 -Inf -> -1
-mngx131 minmag -0 -Inf -> -0
-mngx132 minmag 0 -Inf -> 0
-mngx133 minmag 1 -Inf -> 1
-mngx134 minmag 1000 -Inf -> 1000
-mngx135 minmag Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-mngx141 minmag NaN -Inf -> -Infinity
-mngx142 minmag NaN -1000 -> -1000
-mngx143 minmag NaN -1 -> -1
-mngx144 minmag NaN -0 -> -0
-mngx145 minmag NaN 0 -> 0
-mngx146 minmag NaN 1 -> 1
-mngx147 minmag NaN 1000 -> 1000
-mngx148 minmag NaN Inf -> Infinity
-mngx149 minmag NaN NaN -> NaN
-mngx150 minmag -Inf NaN -> -Infinity
-mngx151 minmag -1000 NaN -> -1000
-mngx152 minmag -1 -NaN -> -1
-mngx153 minmag -0 NaN -> -0
-mngx154 minmag 0 -NaN -> 0
-mngx155 minmag 1 NaN -> 1
-mngx156 minmag 1000 NaN -> 1000
-mngx157 minmag Inf NaN -> Infinity
-
-mngx161 minmag sNaN -Inf -> NaN Invalid_operation
-mngx162 minmag sNaN -1000 -> NaN Invalid_operation
-mngx163 minmag sNaN -1 -> NaN Invalid_operation
-mngx164 minmag sNaN -0 -> NaN Invalid_operation
-mngx165 minmag -sNaN 0 -> -NaN Invalid_operation
-mngx166 minmag -sNaN 1 -> -NaN Invalid_operation
-mngx167 minmag sNaN 1000 -> NaN Invalid_operation
-mngx168 minmag sNaN NaN -> NaN Invalid_operation
-mngx169 minmag sNaN sNaN -> NaN Invalid_operation
-mngx170 minmag NaN sNaN -> NaN Invalid_operation
-mngx171 minmag -Inf sNaN -> NaN Invalid_operation
-mngx172 minmag -1000 sNaN -> NaN Invalid_operation
-mngx173 minmag -1 sNaN -> NaN Invalid_operation
-mngx174 minmag -0 sNaN -> NaN Invalid_operation
-mngx175 minmag 0 sNaN -> NaN Invalid_operation
-mngx176 minmag 1 sNaN -> NaN Invalid_operation
-mngx177 minmag 1000 sNaN -> NaN Invalid_operation
-mngx178 minmag Inf sNaN -> NaN Invalid_operation
-mngx179 minmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-mngx181 minmag NaN9 -Inf -> -Infinity
-mngx182 minmag -NaN8 9990 -> 9990
-mngx183 minmag NaN71 Inf -> Infinity
-
-mngx184 minmag NaN1 NaN54 -> NaN1
-mngx185 minmag NaN22 -NaN53 -> NaN22
-mngx186 minmag -NaN3 NaN6 -> -NaN3
-mngx187 minmag -NaN44 NaN7 -> -NaN44
-
-mngx188 minmag -Inf NaN41 -> -Infinity
-mngx189 minmag -9999 -NaN33 -> -9999
-mngx190 minmag Inf NaN2 -> Infinity
-
-mngx191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
-mngx192 minmag sNaN98 -11 -> NaN98 Invalid_operation
-mngx193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
-mngx194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
-mngx195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
-mngx196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
-mngx197 minmag 088 sNaN91 -> NaN91 Invalid_operation
-mngx198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
-mngx199 minmag NaN sNaN86 -> NaN86 Invalid_operation
-
--- rounding checks -- chosen is rounded, or not
-maxExponent: 999
-minexponent: -999
-precision: 9
-mngx201 minmag -12345678000 1 -> 1
-mngx202 minmag 1 -12345678000 -> 1
-mngx203 minmag -1234567800 1 -> 1
-mngx204 minmag 1 -1234567800 -> 1
-mngx205 minmag -1234567890 1 -> 1
-mngx206 minmag 1 -1234567890 -> 1
-mngx207 minmag -1234567891 1 -> 1
-mngx208 minmag 1 -1234567891 -> 1
-mngx209 minmag -12345678901 1 -> 1
-mngx210 minmag 1 -12345678901 -> 1
-mngx211 minmag -1234567896 1 -> 1
-mngx212 minmag 1 -1234567896 -> 1
-mngx213 minmag 1234567891 1 -> 1
-mngx214 minmag 1 1234567891 -> 1
-mngx215 minmag 12345678901 1 -> 1
-mngx216 minmag 1 12345678901 -> 1
-mngx217 minmag 1234567896 1 -> 1
-mngx218 minmag 1 1234567896 -> 1
-
-precision: 15
-mngx221 minmag -12345678000 1 -> 1
-mngx222 minmag 1 -12345678000 -> 1
-mngx223 minmag -1234567800 1 -> 1
-mngx224 minmag 1 -1234567800 -> 1
-mngx225 minmag -1234567890 1 -> 1
-mngx226 minmag 1 -1234567890 -> 1
-mngx227 minmag -1234567891 1 -> 1
-mngx228 minmag 1 -1234567891 -> 1
-mngx229 minmag -12345678901 1 -> 1
-mngx230 minmag 1 -12345678901 -> 1
-mngx231 minmag -1234567896 1 -> 1
-mngx232 minmag 1 -1234567896 -> 1
-mngx233 minmag 1234567891 1 -> 1
-mngx234 minmag 1 1234567891 -> 1
-mngx235 minmag 12345678901 1 -> 1
-mngx236 minmag 1 12345678901 -> 1
-mngx237 minmag 1234567896 1 -> 1
-mngx238 minmag 1 1234567896 -> 1
-
--- from examples
-mngx280 minmag '3' '2' -> '2'
-mngx281 minmag '-10' '3' -> '3'
-mngx282 minmag '1.0' '1' -> '1.0'
-mngx283 minmag '1' '1.0' -> '1.0'
-mngx284 minmag '7' 'NaN' -> '7'
-
--- overflow and underflow tests .. subnormal results [inputs] now allowed
-maxExponent: 999999999
-minexponent: -999999999
-mngx330 minmag -1.23456789012345E-0 -9E+999999999 -> -1.23456789012345
-mngx331 minmag -9E+999999999 -1.23456789012345E-0 -> -1.23456789012345
-mngx332 minmag -0.100 -9E-999999999 -> -9E-999999999
-mngx333 minmag -9E-999999999 -0.100 -> -9E-999999999
-mngx335 minmag +1.23456789012345E-0 -9E+999999999 -> 1.23456789012345
-mngx336 minmag -9E+999999999 1.23456789012345E-0 -> 1.23456789012345
-mngx337 minmag +0.100 -9E-999999999 -> -9E-999999999
-mngx338 minmag -9E-999999999 0.100 -> -9E-999999999
-
-mngx339 minmag -1e-599999999 -1e-400000001 -> -1E-599999999
-mngx340 minmag -1e-599999999 -1e-400000000 -> -1E-599999999
-mngx341 minmag -1e-600000000 -1e-400000000 -> -1E-600000000
-mngx342 minmag -9e-999999998 -0.01 -> -9E-999999998
-mngx343 minmag -9e-999999998 -0.1 -> -9E-999999998
-mngx344 minmag -0.01 -9e-999999998 -> -9E-999999998
-mngx345 minmag -1e599999999 -1e400000001 -> -1E+400000001
-mngx346 minmag -1e599999999 -1e400000000 -> -1E+400000000
-mngx347 minmag -1e600000000 -1e400000000 -> -1E+400000000
-mngx348 minmag -9e999999998 -100 -> -100
-mngx349 minmag -9e999999998 -10 -> -10
-mngx350 minmag -100 -9e999999998 -> -100
--- signs
-mngx351 minmag -1e+777777777 -1e+411111111 -> -1E+411111111
-mngx352 minmag -1e+777777777 +1e+411111111 -> 1E+411111111
-mngx353 minmag +1e+777777777 -1e+411111111 -> -1E+411111111
-mngx354 minmag +1e+777777777 +1e+411111111 -> 1E+411111111
-mngx355 minmag -1e-777777777 -1e-411111111 -> -1E-777777777
-mngx356 minmag -1e-777777777 +1e-411111111 -> -1E-777777777
-mngx357 minmag +1e-777777777 -1e-411111111 -> 1E-777777777
-mngx358 minmag +1e-777777777 +1e-411111111 -> 1E-777777777
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-mngx401 minmag Inf 1.1 -> 1.1
-mngx402 minmag 1.1 1 -> 1
-mngx403 minmag 1 1.0 -> 1.0
-mngx404 minmag 1.0 0.1 -> 0.1
-mngx405 minmag 0.1 0.10 -> 0.10
-mngx406 minmag 0.10 0.100 -> 0.100
-mngx407 minmag 0.10 0 -> 0
-mngx408 minmag 0 0.0 -> 0.0
-mngx409 minmag 0.0 -0 -> -0
-mngx410 minmag 0.0 -0.0 -> -0.0
-mngx411 minmag 0.00 -0.0 -> -0.0
-mngx412 minmag 0.0 -0.00 -> -0.00
-mngx413 minmag 0 -0.0 -> -0.0
-mngx414 minmag 0 -0 -> -0
-mngx415 minmag -0.0 -0 -> -0
-mngx416 minmag -0 -0.100 -> -0
-mngx417 minmag -0.100 -0.10 -> -0.10
-mngx418 minmag -0.10 -0.1 -> -0.1
-mngx419 minmag -0.1 -1.0 -> -0.1
-mngx420 minmag -1.0 -1 -> -1
-mngx421 minmag -1 -1.1 -> -1
-mngx423 minmag -1.1 -Inf -> -1.1
--- same with operands reversed
-mngx431 minmag 1.1 Inf -> 1.1
-mngx432 minmag 1 1.1 -> 1
-mngx433 minmag 1.0 1 -> 1.0
-mngx434 minmag 0.1 1.0 -> 0.1
-mngx435 minmag 0.10 0.1 -> 0.10
-mngx436 minmag 0.100 0.10 -> 0.100
-mngx437 minmag 0 0.10 -> 0
-mngx438 minmag 0.0 0 -> 0.0
-mngx439 minmag -0 0.0 -> -0
-mngx440 minmag -0.0 0.0 -> -0.0
-mngx441 minmag -0.0 0.00 -> -0.0
-mngx442 minmag -0.00 0.0 -> -0.00
-mngx443 minmag -0.0 0 -> -0.0
-mngx444 minmag -0 0 -> -0
-mngx445 minmag -0 -0.0 -> -0
-mngx446 minmag -0.100 -0 -> -0
-mngx447 minmag -0.10 -0.100 -> -0.10
-mngx448 minmag -0.1 -0.10 -> -0.1
-mngx449 minmag -1.0 -0.1 -> -0.1
-mngx450 minmag -1 -1.0 -> -1
-mngx451 minmag -1.1 -1 -> -1
-mngx453 minmag -Inf -1.1 -> -1.1
--- largies
-mngx460 minmag 1000 1E+3 -> 1000
-mngx461 minmag 1E+3 1000 -> 1000
-mngx462 minmag 1000 -1E+3 -> -1E+3
-mngx463 minmag 1E+3 -1000 -> -1000
-mngx464 minmag -1000 1E+3 -> -1000
-mngx465 minmag -1E+3 1000 -> -1E+3
-mngx466 minmag -1000 -1E+3 -> -1E+3
-mngx467 minmag -1E+3 -1000 -> -1E+3
-
--- rounding (results treated as though plus)
-maxexponent: 999999999
-minexponent: -999999999
-precision: 3
-
-mngx470 minmag 1 5 -> 1
-mngx471 minmag 10 50 -> 10
-mngx472 minmag 100 500 -> 100
-mngx473 minmag 1000 5000 -> 1.00E+3 Rounded
-mngx474 minmag 10000 50000 -> 1.00E+4 Rounded
-mngx475 minmag 6 50 -> 6
-mngx476 minmag 66 500 -> 66
-mngx477 minmag 666 5000 -> 666
-mngx478 minmag 6666 50000 -> 6.67E+3 Rounded Inexact
-mngx479 minmag 66666 500000 -> 6.67E+4 Rounded Inexact
-mngx480 minmag 33333 500000 -> 3.33E+4 Rounded Inexact
-mngx481 minmag 75401 1 -> 1
-mngx482 minmag 75402 10 -> 10
-mngx483 minmag 75403 100 -> 100
-mngx484 minmag 75404 1000 -> 1.00E+3 Rounded
-mngx485 minmag 75405 10000 -> 1.00E+4 Rounded
-mngx486 minmag 75406 6 -> 6
-mngx487 minmag 75407 66 -> 66
-mngx488 minmag 75408 666 -> 666
-mngx489 minmag 75409 6666 -> 6.67E+3 Rounded Inexact
-mngx490 minmag 75410 66666 -> 6.67E+4 Rounded Inexact
-mngx491 minmag 75411 33333 -> 3.33E+4 Rounded Inexact
-
-
--- overflow tests
-maxexponent: 999999999
-minexponent: -999999999
-precision: 3
-mngx500 minmag 9.999E+999999999 0 -> 0
-mngx501 minmag -9.999E+999999999 0 -> 0
-
--- subnormals and underflow
-precision: 3
-maxexponent: 999
-minexponent: -999
-mngx510 minmag 1.00E-999 0 -> 0
-mngx511 minmag 0.1E-999 0 -> 0
-mngx512 minmag 0.10E-999 0 -> 0
-mngx513 minmag 0.100E-999 0 -> 0
-mngx514 minmag 0.01E-999 0 -> 0
-mngx515 minmag 0.999E-999 0 -> 0
-mngx516 minmag 0.099E-999 0 -> 0
-mngx517 minmag 0.009E-999 0 -> 0
-mngx518 minmag 0.001E-999 0 -> 0
-mngx519 minmag 0.0009E-999 0 -> 0
-mngx520 minmag 0.0001E-999 0 -> 0
-
-mngx530 minmag -1.00E-999 0 -> 0
-mngx531 minmag -0.1E-999 0 -> 0
-mngx532 minmag -0.10E-999 0 -> 0
-mngx533 minmag -0.100E-999 0 -> 0
-mngx534 minmag -0.01E-999 0 -> 0
-mngx535 minmag -0.999E-999 0 -> 0
-mngx536 minmag -0.099E-999 0 -> 0
-mngx537 minmag -0.009E-999 0 -> 0
-mngx538 minmag -0.001E-999 0 -> 0
-mngx539 minmag -0.0009E-999 0 -> 0
-mngx540 minmag -0.0001E-999 0 -> 0
-
-
--- Null tests
-mng900 minmag 10 # -> NaN Invalid_operation
-mng901 minmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- minmag.decTest -- decimal minimum by magnitude --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- sanity checks
+mngx001 minmag -2 -2 -> -2
+mngx002 minmag -2 -1 -> -1
+mngx003 minmag -2 0 -> 0
+mngx004 minmag -2 1 -> 1
+mngx005 minmag -2 2 -> -2
+mngx006 minmag -1 -2 -> -1
+mngx007 minmag -1 -1 -> -1
+mngx008 minmag -1 0 -> 0
+mngx009 minmag -1 1 -> -1
+mngx010 minmag -1 2 -> -1
+mngx011 minmag 0 -2 -> 0
+mngx012 minmag 0 -1 -> 0
+mngx013 minmag 0 0 -> 0
+mngx014 minmag 0 1 -> 0
+mngx015 minmag 0 2 -> 0
+mngx016 minmag 1 -2 -> 1
+mngx017 minmag 1 -1 -> -1
+mngx018 minmag 1 0 -> 0
+mngx019 minmag 1 1 -> 1
+mngx020 minmag 1 2 -> 1
+mngx021 minmag 2 -2 -> -2
+mngx022 minmag 2 -1 -> -1
+mngx023 minmag 2 0 -> 0
+mngx025 minmag 2 1 -> 1
+mngx026 minmag 2 2 -> 2
+
+-- extended zeros
+mngx030 minmag 0 0 -> 0
+mngx031 minmag 0 -0 -> -0
+mngx032 minmag 0 -0.0 -> -0.0
+mngx033 minmag 0 0.0 -> 0.0
+mngx034 minmag -0 0 -> -0
+mngx035 minmag -0 -0 -> -0
+mngx036 minmag -0 -0.0 -> -0
+mngx037 minmag -0 0.0 -> -0
+mngx038 minmag 0.0 0 -> 0.0
+mngx039 minmag 0.0 -0 -> -0
+mngx040 minmag 0.0 -0.0 -> -0.0
+mngx041 minmag 0.0 0.0 -> 0.0
+mngx042 minmag -0.0 0 -> -0.0
+mngx043 minmag -0.0 -0 -> -0
+mngx044 minmag -0.0 -0.0 -> -0.0
+mngx045 minmag -0.0 0.0 -> -0.0
+
+mngx046 minmag 0E1 -0E1 -> -0E+1
+mngx047 minmag -0E1 0E2 -> -0E+1
+mngx048 minmag 0E2 0E1 -> 0E+1
+mngx049 minmag 0E1 0E2 -> 0E+1
+mngx050 minmag -0E3 -0E2 -> -0E+3
+mngx051 minmag -0E2 -0E3 -> -0E+3
+
+-- Specials
+precision: 9
+mngx090 minmag Inf -Inf -> -Infinity
+mngx091 minmag Inf -1000 -> -1000
+mngx092 minmag Inf -1 -> -1
+mngx093 minmag Inf -0 -> -0
+mngx094 minmag Inf 0 -> 0
+mngx095 minmag Inf 1 -> 1
+mngx096 minmag Inf 1000 -> 1000
+mngx097 minmag Inf Inf -> Infinity
+mngx098 minmag -1000 Inf -> -1000
+mngx099 minmag -Inf Inf -> -Infinity
+mngx100 minmag -1 Inf -> -1
+mngx101 minmag -0 Inf -> -0
+mngx102 minmag 0 Inf -> 0
+mngx103 minmag 1 Inf -> 1
+mngx104 minmag 1000 Inf -> 1000
+mngx105 minmag Inf Inf -> Infinity
+
+mngx120 minmag -Inf -Inf -> -Infinity
+mngx121 minmag -Inf -1000 -> -1000
+mngx122 minmag -Inf -1 -> -1
+mngx123 minmag -Inf -0 -> -0
+mngx124 minmag -Inf 0 -> 0
+mngx125 minmag -Inf 1 -> 1
+mngx126 minmag -Inf 1000 -> 1000
+mngx127 minmag -Inf Inf -> -Infinity
+mngx128 minmag -Inf -Inf -> -Infinity
+mngx129 minmag -1000 -Inf -> -1000
+mngx130 minmag -1 -Inf -> -1
+mngx131 minmag -0 -Inf -> -0
+mngx132 minmag 0 -Inf -> 0
+mngx133 minmag 1 -Inf -> 1
+mngx134 minmag 1000 -Inf -> 1000
+mngx135 minmag Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+mngx141 minmag NaN -Inf -> -Infinity
+mngx142 minmag NaN -1000 -> -1000
+mngx143 minmag NaN -1 -> -1
+mngx144 minmag NaN -0 -> -0
+mngx145 minmag NaN 0 -> 0
+mngx146 minmag NaN 1 -> 1
+mngx147 minmag NaN 1000 -> 1000
+mngx148 minmag NaN Inf -> Infinity
+mngx149 minmag NaN NaN -> NaN
+mngx150 minmag -Inf NaN -> -Infinity
+mngx151 minmag -1000 NaN -> -1000
+mngx152 minmag -1 -NaN -> -1
+mngx153 minmag -0 NaN -> -0
+mngx154 minmag 0 -NaN -> 0
+mngx155 minmag 1 NaN -> 1
+mngx156 minmag 1000 NaN -> 1000
+mngx157 minmag Inf NaN -> Infinity
+
+mngx161 minmag sNaN -Inf -> NaN Invalid_operation
+mngx162 minmag sNaN -1000 -> NaN Invalid_operation
+mngx163 minmag sNaN -1 -> NaN Invalid_operation
+mngx164 minmag sNaN -0 -> NaN Invalid_operation
+mngx165 minmag -sNaN 0 -> -NaN Invalid_operation
+mngx166 minmag -sNaN 1 -> -NaN Invalid_operation
+mngx167 minmag sNaN 1000 -> NaN Invalid_operation
+mngx168 minmag sNaN NaN -> NaN Invalid_operation
+mngx169 minmag sNaN sNaN -> NaN Invalid_operation
+mngx170 minmag NaN sNaN -> NaN Invalid_operation
+mngx171 minmag -Inf sNaN -> NaN Invalid_operation
+mngx172 minmag -1000 sNaN -> NaN Invalid_operation
+mngx173 minmag -1 sNaN -> NaN Invalid_operation
+mngx174 minmag -0 sNaN -> NaN Invalid_operation
+mngx175 minmag 0 sNaN -> NaN Invalid_operation
+mngx176 minmag 1 sNaN -> NaN Invalid_operation
+mngx177 minmag 1000 sNaN -> NaN Invalid_operation
+mngx178 minmag Inf sNaN -> NaN Invalid_operation
+mngx179 minmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+mngx181 minmag NaN9 -Inf -> -Infinity
+mngx182 minmag -NaN8 9990 -> 9990
+mngx183 minmag NaN71 Inf -> Infinity
+
+mngx184 minmag NaN1 NaN54 -> NaN1
+mngx185 minmag NaN22 -NaN53 -> NaN22
+mngx186 minmag -NaN3 NaN6 -> -NaN3
+mngx187 minmag -NaN44 NaN7 -> -NaN44
+
+mngx188 minmag -Inf NaN41 -> -Infinity
+mngx189 minmag -9999 -NaN33 -> -9999
+mngx190 minmag Inf NaN2 -> Infinity
+
+mngx191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
+mngx192 minmag sNaN98 -11 -> NaN98 Invalid_operation
+mngx193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
+mngx194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
+mngx195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
+mngx196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
+mngx197 minmag 088 sNaN91 -> NaN91 Invalid_operation
+mngx198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
+mngx199 minmag NaN sNaN86 -> NaN86 Invalid_operation
+
+-- rounding checks -- chosen is rounded, or not
+maxExponent: 999
+minexponent: -999
+precision: 9
+mngx201 minmag -12345678000 1 -> 1
+mngx202 minmag 1 -12345678000 -> 1
+mngx203 minmag -1234567800 1 -> 1
+mngx204 minmag 1 -1234567800 -> 1
+mngx205 minmag -1234567890 1 -> 1
+mngx206 minmag 1 -1234567890 -> 1
+mngx207 minmag -1234567891 1 -> 1
+mngx208 minmag 1 -1234567891 -> 1
+mngx209 minmag -12345678901 1 -> 1
+mngx210 minmag 1 -12345678901 -> 1
+mngx211 minmag -1234567896 1 -> 1
+mngx212 minmag 1 -1234567896 -> 1
+mngx213 minmag 1234567891 1 -> 1
+mngx214 minmag 1 1234567891 -> 1
+mngx215 minmag 12345678901 1 -> 1
+mngx216 minmag 1 12345678901 -> 1
+mngx217 minmag 1234567896 1 -> 1
+mngx218 minmag 1 1234567896 -> 1
+
+precision: 15
+mngx221 minmag -12345678000 1 -> 1
+mngx222 minmag 1 -12345678000 -> 1
+mngx223 minmag -1234567800 1 -> 1
+mngx224 minmag 1 -1234567800 -> 1
+mngx225 minmag -1234567890 1 -> 1
+mngx226 minmag 1 -1234567890 -> 1
+mngx227 minmag -1234567891 1 -> 1
+mngx228 minmag 1 -1234567891 -> 1
+mngx229 minmag -12345678901 1 -> 1
+mngx230 minmag 1 -12345678901 -> 1
+mngx231 minmag -1234567896 1 -> 1
+mngx232 minmag 1 -1234567896 -> 1
+mngx233 minmag 1234567891 1 -> 1
+mngx234 minmag 1 1234567891 -> 1
+mngx235 minmag 12345678901 1 -> 1
+mngx236 minmag 1 12345678901 -> 1
+mngx237 minmag 1234567896 1 -> 1
+mngx238 minmag 1 1234567896 -> 1
+
+-- from examples
+mngx280 minmag '3' '2' -> '2'
+mngx281 minmag '-10' '3' -> '3'
+mngx282 minmag '1.0' '1' -> '1.0'
+mngx283 minmag '1' '1.0' -> '1.0'
+mngx284 minmag '7' 'NaN' -> '7'
+
+-- overflow and underflow tests .. subnormal results [inputs] now allowed
+maxExponent: 999999999
+minexponent: -999999999
+mngx330 minmag -1.23456789012345E-0 -9E+999999999 -> -1.23456789012345
+mngx331 minmag -9E+999999999 -1.23456789012345E-0 -> -1.23456789012345
+mngx332 minmag -0.100 -9E-999999999 -> -9E-999999999
+mngx333 minmag -9E-999999999 -0.100 -> -9E-999999999
+mngx335 minmag +1.23456789012345E-0 -9E+999999999 -> 1.23456789012345
+mngx336 minmag -9E+999999999 1.23456789012345E-0 -> 1.23456789012345
+mngx337 minmag +0.100 -9E-999999999 -> -9E-999999999
+mngx338 minmag -9E-999999999 0.100 -> -9E-999999999
+
+mngx339 minmag -1e-599999999 -1e-400000001 -> -1E-599999999
+mngx340 minmag -1e-599999999 -1e-400000000 -> -1E-599999999
+mngx341 minmag -1e-600000000 -1e-400000000 -> -1E-600000000
+mngx342 minmag -9e-999999998 -0.01 -> -9E-999999998
+mngx343 minmag -9e-999999998 -0.1 -> -9E-999999998
+mngx344 minmag -0.01 -9e-999999998 -> -9E-999999998
+mngx345 minmag -1e599999999 -1e400000001 -> -1E+400000001
+mngx346 minmag -1e599999999 -1e400000000 -> -1E+400000000
+mngx347 minmag -1e600000000 -1e400000000 -> -1E+400000000
+mngx348 minmag -9e999999998 -100 -> -100
+mngx349 minmag -9e999999998 -10 -> -10
+mngx350 minmag -100 -9e999999998 -> -100
+-- signs
+mngx351 minmag -1e+777777777 -1e+411111111 -> -1E+411111111
+mngx352 minmag -1e+777777777 +1e+411111111 -> 1E+411111111
+mngx353 minmag +1e+777777777 -1e+411111111 -> -1E+411111111
+mngx354 minmag +1e+777777777 +1e+411111111 -> 1E+411111111
+mngx355 minmag -1e-777777777 -1e-411111111 -> -1E-777777777
+mngx356 minmag -1e-777777777 +1e-411111111 -> -1E-777777777
+mngx357 minmag +1e-777777777 -1e-411111111 -> 1E-777777777
+mngx358 minmag +1e-777777777 +1e-411111111 -> 1E-777777777
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+mngx401 minmag Inf 1.1 -> 1.1
+mngx402 minmag 1.1 1 -> 1
+mngx403 minmag 1 1.0 -> 1.0
+mngx404 minmag 1.0 0.1 -> 0.1
+mngx405 minmag 0.1 0.10 -> 0.10
+mngx406 minmag 0.10 0.100 -> 0.100
+mngx407 minmag 0.10 0 -> 0
+mngx408 minmag 0 0.0 -> 0.0
+mngx409 minmag 0.0 -0 -> -0
+mngx410 minmag 0.0 -0.0 -> -0.0
+mngx411 minmag 0.00 -0.0 -> -0.0
+mngx412 minmag 0.0 -0.00 -> -0.00
+mngx413 minmag 0 -0.0 -> -0.0
+mngx414 minmag 0 -0 -> -0
+mngx415 minmag -0.0 -0 -> -0
+mngx416 minmag -0 -0.100 -> -0
+mngx417 minmag -0.100 -0.10 -> -0.10
+mngx418 minmag -0.10 -0.1 -> -0.1
+mngx419 minmag -0.1 -1.0 -> -0.1
+mngx420 minmag -1.0 -1 -> -1
+mngx421 minmag -1 -1.1 -> -1
+mngx423 minmag -1.1 -Inf -> -1.1
+-- same with operands reversed
+mngx431 minmag 1.1 Inf -> 1.1
+mngx432 minmag 1 1.1 -> 1
+mngx433 minmag 1.0 1 -> 1.0
+mngx434 minmag 0.1 1.0 -> 0.1
+mngx435 minmag 0.10 0.1 -> 0.10
+mngx436 minmag 0.100 0.10 -> 0.100
+mngx437 minmag 0 0.10 -> 0
+mngx438 minmag 0.0 0 -> 0.0
+mngx439 minmag -0 0.0 -> -0
+mngx440 minmag -0.0 0.0 -> -0.0
+mngx441 minmag -0.0 0.00 -> -0.0
+mngx442 minmag -0.00 0.0 -> -0.00
+mngx443 minmag -0.0 0 -> -0.0
+mngx444 minmag -0 0 -> -0
+mngx445 minmag -0 -0.0 -> -0
+mngx446 minmag -0.100 -0 -> -0
+mngx447 minmag -0.10 -0.100 -> -0.10
+mngx448 minmag -0.1 -0.10 -> -0.1
+mngx449 minmag -1.0 -0.1 -> -0.1
+mngx450 minmag -1 -1.0 -> -1
+mngx451 minmag -1.1 -1 -> -1
+mngx453 minmag -Inf -1.1 -> -1.1
+-- largies
+mngx460 minmag 1000 1E+3 -> 1000
+mngx461 minmag 1E+3 1000 -> 1000
+mngx462 minmag 1000 -1E+3 -> -1E+3
+mngx463 minmag 1E+3 -1000 -> -1000
+mngx464 minmag -1000 1E+3 -> -1000
+mngx465 minmag -1E+3 1000 -> -1E+3
+mngx466 minmag -1000 -1E+3 -> -1E+3
+mngx467 minmag -1E+3 -1000 -> -1E+3
+
+-- rounding (results treated as though plus)
+maxexponent: 999999999
+minexponent: -999999999
+precision: 3
+
+mngx470 minmag 1 5 -> 1
+mngx471 minmag 10 50 -> 10
+mngx472 minmag 100 500 -> 100
+mngx473 minmag 1000 5000 -> 1.00E+3 Rounded
+mngx474 minmag 10000 50000 -> 1.00E+4 Rounded
+mngx475 minmag 6 50 -> 6
+mngx476 minmag 66 500 -> 66
+mngx477 minmag 666 5000 -> 666
+mngx478 minmag 6666 50000 -> 6.67E+3 Rounded Inexact
+mngx479 minmag 66666 500000 -> 6.67E+4 Rounded Inexact
+mngx480 minmag 33333 500000 -> 3.33E+4 Rounded Inexact
+mngx481 minmag 75401 1 -> 1
+mngx482 minmag 75402 10 -> 10
+mngx483 minmag 75403 100 -> 100
+mngx484 minmag 75404 1000 -> 1.00E+3 Rounded
+mngx485 minmag 75405 10000 -> 1.00E+4 Rounded
+mngx486 minmag 75406 6 -> 6
+mngx487 minmag 75407 66 -> 66
+mngx488 minmag 75408 666 -> 666
+mngx489 minmag 75409 6666 -> 6.67E+3 Rounded Inexact
+mngx490 minmag 75410 66666 -> 6.67E+4 Rounded Inexact
+mngx491 minmag 75411 33333 -> 3.33E+4 Rounded Inexact
+
+
+-- overflow tests
+maxexponent: 999999999
+minexponent: -999999999
+precision: 3
+mngx500 minmag 9.999E+999999999 0 -> 0
+mngx501 minmag -9.999E+999999999 0 -> 0
+
+-- subnormals and underflow
+precision: 3
+maxexponent: 999
+minexponent: -999
+mngx510 minmag 1.00E-999 0 -> 0
+mngx511 minmag 0.1E-999 0 -> 0
+mngx512 minmag 0.10E-999 0 -> 0
+mngx513 minmag 0.100E-999 0 -> 0
+mngx514 minmag 0.01E-999 0 -> 0
+mngx515 minmag 0.999E-999 0 -> 0
+mngx516 minmag 0.099E-999 0 -> 0
+mngx517 minmag 0.009E-999 0 -> 0
+mngx518 minmag 0.001E-999 0 -> 0
+mngx519 minmag 0.0009E-999 0 -> 0
+mngx520 minmag 0.0001E-999 0 -> 0
+
+mngx530 minmag -1.00E-999 0 -> 0
+mngx531 minmag -0.1E-999 0 -> 0
+mngx532 minmag -0.10E-999 0 -> 0
+mngx533 minmag -0.100E-999 0 -> 0
+mngx534 minmag -0.01E-999 0 -> 0
+mngx535 minmag -0.999E-999 0 -> 0
+mngx536 minmag -0.099E-999 0 -> 0
+mngx537 minmag -0.009E-999 0 -> 0
+mngx538 minmag -0.001E-999 0 -> 0
+mngx539 minmag -0.0009E-999 0 -> 0
+mngx540 minmag -0.0001E-999 0 -> 0
+
+
+-- Null tests
+mng900 minmag 10 # -> NaN Invalid_operation
+mng901 minmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/nextminus.decTest b/Lib/test/decimaltestdata/nextminus.decTest
index 531c5252a5..ba93066b96 100644
--- a/Lib/test/decimaltestdata/nextminus.decTest
+++ b/Lib/test/decimaltestdata/nextminus.decTest
@@ -1,148 +1,148 @@
-------------------------------------------------------------------------
--- nextminus.decTest -- decimal next that is less [754r nextdown] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
-nextm001 nextminus 0.999999995 -> 0.999999994
-nextm002 nextminus 0.999999996 -> 0.999999995
-nextm003 nextminus 0.999999997 -> 0.999999996
-nextm004 nextminus 0.999999998 -> 0.999999997
-nextm005 nextminus 0.999999999 -> 0.999999998
-nextm006 nextminus 1.00000000 -> 0.999999999
-nextm007 nextminus 1.0 -> 0.999999999
-nextm008 nextminus 1 -> 0.999999999
-nextm009 nextminus 1.00000001 -> 1.00000000
-nextm010 nextminus 1.00000002 -> 1.00000001
-nextm011 nextminus 1.00000003 -> 1.00000002
-nextm012 nextminus 1.00000004 -> 1.00000003
-nextm013 nextminus 1.00000005 -> 1.00000004
-nextm014 nextminus 1.00000006 -> 1.00000005
-nextm015 nextminus 1.00000007 -> 1.00000006
-nextm016 nextminus 1.00000008 -> 1.00000007
-nextm017 nextminus 1.00000009 -> 1.00000008
-nextm018 nextminus 1.00000010 -> 1.00000009
-nextm019 nextminus 1.00000011 -> 1.00000010
-nextm020 nextminus 1.00000012 -> 1.00000011
-
-nextm021 nextminus -0.999999995 -> -0.999999996
-nextm022 nextminus -0.999999996 -> -0.999999997
-nextm023 nextminus -0.999999997 -> -0.999999998
-nextm024 nextminus -0.999999998 -> -0.999999999
-nextm025 nextminus -0.999999999 -> -1.00000000
-nextm026 nextminus -1.00000000 -> -1.00000001
-nextm027 nextminus -1.0 -> -1.00000001
-nextm028 nextminus -1 -> -1.00000001
-nextm029 nextminus -1.00000001 -> -1.00000002
-nextm030 nextminus -1.00000002 -> -1.00000003
-nextm031 nextminus -1.00000003 -> -1.00000004
-nextm032 nextminus -1.00000004 -> -1.00000005
-nextm033 nextminus -1.00000005 -> -1.00000006
-nextm034 nextminus -1.00000006 -> -1.00000007
-nextm035 nextminus -1.00000007 -> -1.00000008
-nextm036 nextminus -1.00000008 -> -1.00000009
-nextm037 nextminus -1.00000009 -> -1.00000010
-nextm038 nextminus -1.00000010 -> -1.00000011
-nextm039 nextminus -1.00000011 -> -1.00000012
-
--- input operand is >precision
-nextm041 nextminus 1.00000010998 -> 1.00000010
-nextm042 nextminus 1.00000010999 -> 1.00000010
-nextm043 nextminus 1.00000011000 -> 1.00000010
-nextm044 nextminus 1.00000011001 -> 1.00000011
-nextm045 nextminus 1.00000011002 -> 1.00000011
-nextm046 nextminus 1.00000011002 -> 1.00000011
-nextm047 nextminus 1.00000011052 -> 1.00000011
-nextm048 nextminus 1.00000011552 -> 1.00000011
-nextm049 nextminus -1.00000010998 -> -1.00000011
-nextm050 nextminus -1.00000010999 -> -1.00000011
-nextm051 nextminus -1.00000011000 -> -1.00000012
-nextm052 nextminus -1.00000011001 -> -1.00000012
-nextm053 nextminus -1.00000011002 -> -1.00000012
-nextm054 nextminus -1.00000011002 -> -1.00000012
-nextm055 nextminus -1.00000011052 -> -1.00000012
-nextm056 nextminus -1.00000011552 -> -1.00000012
--- ultra-tiny inputs
-nextm060 nextminus 1E-99999 -> 0E-391
-nextm061 nextminus 1E-999999999 -> 0E-391
-nextm062 nextminus 1E-391 -> 0E-391
-nextm063 nextminus -1E-99999 -> -1E-391
-nextm064 nextminus -1E-999999999 -> -1E-391
-nextm065 nextminus -1E-391 -> -2E-391
-
--- Zeros
-nextm100 nextminus -0 -> -1E-391
-nextm101 nextminus 0 -> -1E-391
-nextm102 nextminus 0.00 -> -1E-391
-nextm103 nextminus -0.00 -> -1E-391
-nextm104 nextminus 0E-300 -> -1E-391
-nextm105 nextminus 0E+300 -> -1E-391
-nextm106 nextminus 0E+30000 -> -1E-391
-nextm107 nextminus -0E+30000 -> -1E-391
-
-precision: 9
-maxExponent: 999
-minexponent: -999
--- specials
-nextm150 nextminus Inf -> 9.99999999E+999
-nextm151 nextminus -Inf -> -Infinity
-nextm152 nextminus NaN -> NaN
-nextm153 nextminus sNaN -> NaN Invalid_operation
-nextm154 nextminus NaN77 -> NaN77
-nextm155 nextminus sNaN88 -> NaN88 Invalid_operation
-nextm156 nextminus -NaN -> -NaN
-nextm157 nextminus -sNaN -> -NaN Invalid_operation
-nextm158 nextminus -NaN77 -> -NaN77
-nextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-nextm170 nextminus 9.99999999E+999 -> 9.99999998E+999
-nextm171 nextminus 9.99999998E+999 -> 9.99999997E+999
-nextm172 nextminus 1E-999 -> 9.9999999E-1000
-nextm173 nextminus 1.00000000E-999 -> 9.9999999E-1000
-nextm174 nextminus 9E-1007 -> 8E-1007
-nextm175 nextminus 9.9E-1006 -> 9.8E-1006
-nextm176 nextminus 9.9999E-1003 -> 9.9998E-1003
-nextm177 nextminus 9.9999999E-1000 -> 9.9999998E-1000
-nextm178 nextminus 9.9999998E-1000 -> 9.9999997E-1000
-nextm179 nextminus 9.9999997E-1000 -> 9.9999996E-1000
-nextm180 nextminus 0E-1007 -> -1E-1007
-nextm181 nextminus 1E-1007 -> 0E-1007
-nextm182 nextminus 2E-1007 -> 1E-1007
-
-nextm183 nextminus -0E-1007 -> -1E-1007
-nextm184 nextminus -1E-1007 -> -2E-1007
-nextm185 nextminus -2E-1007 -> -3E-1007
-nextm186 nextminus -10E-1007 -> -1.1E-1006
-nextm187 nextminus -100E-1007 -> -1.01E-1005
-nextm188 nextminus -100000E-1007 -> -1.00001E-1002
-nextm189 nextminus -1.0000E-999 -> -1.00000001E-999
-nextm190 nextminus -1.00000000E-999 -> -1.00000001E-999
-nextm191 nextminus -1E-999 -> -1.00000001E-999
-nextm192 nextminus -9.99999998E+999 -> -9.99999999E+999
-nextm193 nextminus -9.99999999E+999 -> -Infinity
-
--- Null tests
-nextm900 nextminus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- nextminus.decTest -- decimal next that is less [754r nextdown] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+nextm001 nextminus 0.999999995 -> 0.999999994
+nextm002 nextminus 0.999999996 -> 0.999999995
+nextm003 nextminus 0.999999997 -> 0.999999996
+nextm004 nextminus 0.999999998 -> 0.999999997
+nextm005 nextminus 0.999999999 -> 0.999999998
+nextm006 nextminus 1.00000000 -> 0.999999999
+nextm007 nextminus 1.0 -> 0.999999999
+nextm008 nextminus 1 -> 0.999999999
+nextm009 nextminus 1.00000001 -> 1.00000000
+nextm010 nextminus 1.00000002 -> 1.00000001
+nextm011 nextminus 1.00000003 -> 1.00000002
+nextm012 nextminus 1.00000004 -> 1.00000003
+nextm013 nextminus 1.00000005 -> 1.00000004
+nextm014 nextminus 1.00000006 -> 1.00000005
+nextm015 nextminus 1.00000007 -> 1.00000006
+nextm016 nextminus 1.00000008 -> 1.00000007
+nextm017 nextminus 1.00000009 -> 1.00000008
+nextm018 nextminus 1.00000010 -> 1.00000009
+nextm019 nextminus 1.00000011 -> 1.00000010
+nextm020 nextminus 1.00000012 -> 1.00000011
+
+nextm021 nextminus -0.999999995 -> -0.999999996
+nextm022 nextminus -0.999999996 -> -0.999999997
+nextm023 nextminus -0.999999997 -> -0.999999998
+nextm024 nextminus -0.999999998 -> -0.999999999
+nextm025 nextminus -0.999999999 -> -1.00000000
+nextm026 nextminus -1.00000000 -> -1.00000001
+nextm027 nextminus -1.0 -> -1.00000001
+nextm028 nextminus -1 -> -1.00000001
+nextm029 nextminus -1.00000001 -> -1.00000002
+nextm030 nextminus -1.00000002 -> -1.00000003
+nextm031 nextminus -1.00000003 -> -1.00000004
+nextm032 nextminus -1.00000004 -> -1.00000005
+nextm033 nextminus -1.00000005 -> -1.00000006
+nextm034 nextminus -1.00000006 -> -1.00000007
+nextm035 nextminus -1.00000007 -> -1.00000008
+nextm036 nextminus -1.00000008 -> -1.00000009
+nextm037 nextminus -1.00000009 -> -1.00000010
+nextm038 nextminus -1.00000010 -> -1.00000011
+nextm039 nextminus -1.00000011 -> -1.00000012
+
+-- input operand is >precision
+nextm041 nextminus 1.00000010998 -> 1.00000010
+nextm042 nextminus 1.00000010999 -> 1.00000010
+nextm043 nextminus 1.00000011000 -> 1.00000010
+nextm044 nextminus 1.00000011001 -> 1.00000011
+nextm045 nextminus 1.00000011002 -> 1.00000011
+nextm046 nextminus 1.00000011002 -> 1.00000011
+nextm047 nextminus 1.00000011052 -> 1.00000011
+nextm048 nextminus 1.00000011552 -> 1.00000011
+nextm049 nextminus -1.00000010998 -> -1.00000011
+nextm050 nextminus -1.00000010999 -> -1.00000011
+nextm051 nextminus -1.00000011000 -> -1.00000012
+nextm052 nextminus -1.00000011001 -> -1.00000012
+nextm053 nextminus -1.00000011002 -> -1.00000012
+nextm054 nextminus -1.00000011002 -> -1.00000012
+nextm055 nextminus -1.00000011052 -> -1.00000012
+nextm056 nextminus -1.00000011552 -> -1.00000012
+-- ultra-tiny inputs
+nextm060 nextminus 1E-99999 -> 0E-391
+nextm061 nextminus 1E-999999999 -> 0E-391
+nextm062 nextminus 1E-391 -> 0E-391
+nextm063 nextminus -1E-99999 -> -1E-391
+nextm064 nextminus -1E-999999999 -> -1E-391
+nextm065 nextminus -1E-391 -> -2E-391
+
+-- Zeros
+nextm100 nextminus -0 -> -1E-391
+nextm101 nextminus 0 -> -1E-391
+nextm102 nextminus 0.00 -> -1E-391
+nextm103 nextminus -0.00 -> -1E-391
+nextm104 nextminus 0E-300 -> -1E-391
+nextm105 nextminus 0E+300 -> -1E-391
+nextm106 nextminus 0E+30000 -> -1E-391
+nextm107 nextminus -0E+30000 -> -1E-391
+
+precision: 9
+maxExponent: 999
+minexponent: -999
+-- specials
+nextm150 nextminus Inf -> 9.99999999E+999
+nextm151 nextminus -Inf -> -Infinity
+nextm152 nextminus NaN -> NaN
+nextm153 nextminus sNaN -> NaN Invalid_operation
+nextm154 nextminus NaN77 -> NaN77
+nextm155 nextminus sNaN88 -> NaN88 Invalid_operation
+nextm156 nextminus -NaN -> -NaN
+nextm157 nextminus -sNaN -> -NaN Invalid_operation
+nextm158 nextminus -NaN77 -> -NaN77
+nextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+nextm170 nextminus 9.99999999E+999 -> 9.99999998E+999
+nextm171 nextminus 9.99999998E+999 -> 9.99999997E+999
+nextm172 nextminus 1E-999 -> 9.9999999E-1000
+nextm173 nextminus 1.00000000E-999 -> 9.9999999E-1000
+nextm174 nextminus 9E-1007 -> 8E-1007
+nextm175 nextminus 9.9E-1006 -> 9.8E-1006
+nextm176 nextminus 9.9999E-1003 -> 9.9998E-1003
+nextm177 nextminus 9.9999999E-1000 -> 9.9999998E-1000
+nextm178 nextminus 9.9999998E-1000 -> 9.9999997E-1000
+nextm179 nextminus 9.9999997E-1000 -> 9.9999996E-1000
+nextm180 nextminus 0E-1007 -> -1E-1007
+nextm181 nextminus 1E-1007 -> 0E-1007
+nextm182 nextminus 2E-1007 -> 1E-1007
+
+nextm183 nextminus -0E-1007 -> -1E-1007
+nextm184 nextminus -1E-1007 -> -2E-1007
+nextm185 nextminus -2E-1007 -> -3E-1007
+nextm186 nextminus -10E-1007 -> -1.1E-1006
+nextm187 nextminus -100E-1007 -> -1.01E-1005
+nextm188 nextminus -100000E-1007 -> -1.00001E-1002
+nextm189 nextminus -1.0000E-999 -> -1.00000001E-999
+nextm190 nextminus -1.00000000E-999 -> -1.00000001E-999
+nextm191 nextminus -1E-999 -> -1.00000001E-999
+nextm192 nextminus -9.99999998E+999 -> -9.99999999E+999
+nextm193 nextminus -9.99999999E+999 -> -Infinity
+
+-- Null tests
+nextm900 nextminus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/nextplus.decTest b/Lib/test/decimaltestdata/nextplus.decTest
index c66e328727..44989e50b1 100644
--- a/Lib/test/decimaltestdata/nextplus.decTest
+++ b/Lib/test/decimaltestdata/nextplus.decTest
@@ -1,150 +1,150 @@
-------------------------------------------------------------------------
--- nextplus.decTest -- decimal next that is greater [754r nextup] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
-nextp001 nextplus 0.999999995 -> 0.999999996
-nextp002 nextplus 0.999999996 -> 0.999999997
-nextp003 nextplus 0.999999997 -> 0.999999998
-nextp004 nextplus 0.999999998 -> 0.999999999
-nextp005 nextplus 0.999999999 -> 1.00000000
-nextp006 nextplus 1.00000000 -> 1.00000001
-nextp007 nextplus 1.0 -> 1.00000001
-nextp008 nextplus 1 -> 1.00000001
-nextp009 nextplus 1.00000001 -> 1.00000002
-nextp010 nextplus 1.00000002 -> 1.00000003
-nextp011 nextplus 1.00000003 -> 1.00000004
-nextp012 nextplus 1.00000004 -> 1.00000005
-nextp013 nextplus 1.00000005 -> 1.00000006
-nextp014 nextplus 1.00000006 -> 1.00000007
-nextp015 nextplus 1.00000007 -> 1.00000008
-nextp016 nextplus 1.00000008 -> 1.00000009
-nextp017 nextplus 1.00000009 -> 1.00000010
-nextp018 nextplus 1.00000010 -> 1.00000011
-nextp019 nextplus 1.00000011 -> 1.00000012
-
-nextp021 nextplus -0.999999995 -> -0.999999994
-nextp022 nextplus -0.999999996 -> -0.999999995
-nextp023 nextplus -0.999999997 -> -0.999999996
-nextp024 nextplus -0.999999998 -> -0.999999997
-nextp025 nextplus -0.999999999 -> -0.999999998
-nextp026 nextplus -1.00000000 -> -0.999999999
-nextp027 nextplus -1.0 -> -0.999999999
-nextp028 nextplus -1 -> -0.999999999
-nextp029 nextplus -1.00000001 -> -1.00000000
-nextp030 nextplus -1.00000002 -> -1.00000001
-nextp031 nextplus -1.00000003 -> -1.00000002
-nextp032 nextplus -1.00000004 -> -1.00000003
-nextp033 nextplus -1.00000005 -> -1.00000004
-nextp034 nextplus -1.00000006 -> -1.00000005
-nextp035 nextplus -1.00000007 -> -1.00000006
-nextp036 nextplus -1.00000008 -> -1.00000007
-nextp037 nextplus -1.00000009 -> -1.00000008
-nextp038 nextplus -1.00000010 -> -1.00000009
-nextp039 nextplus -1.00000011 -> -1.00000010
-nextp040 nextplus -1.00000012 -> -1.00000011
-
--- input operand is >precision
-nextp041 nextplus 1.00000010998 -> 1.00000011
-nextp042 nextplus 1.00000010999 -> 1.00000011
-nextp043 nextplus 1.00000011000 -> 1.00000012
-nextp044 nextplus 1.00000011001 -> 1.00000012
-nextp045 nextplus 1.00000011002 -> 1.00000012
-nextp046 nextplus 1.00000011002 -> 1.00000012
-nextp047 nextplus 1.00000011052 -> 1.00000012
-nextp048 nextplus 1.00000011552 -> 1.00000012
-nextp049 nextplus -1.00000010998 -> -1.00000010
-nextp050 nextplus -1.00000010999 -> -1.00000010
-nextp051 nextplus -1.00000011000 -> -1.00000010
-nextp052 nextplus -1.00000011001 -> -1.00000011
-nextp053 nextplus -1.00000011002 -> -1.00000011
-nextp054 nextplus -1.00000011002 -> -1.00000011
-nextp055 nextplus -1.00000011052 -> -1.00000011
-nextp056 nextplus -1.00000011552 -> -1.00000011
--- ultra-tiny inputs
-nextp060 nextplus 1E-99999 -> 1E-391
-nextp061 nextplus 1E-999999999 -> 1E-391
-nextp062 nextplus 1E-391 -> 2E-391
-nextp063 nextplus -1E-99999 -> -0E-391
-nextp064 nextplus -1E-999999999 -> -0E-391
-nextp065 nextplus -1E-391 -> -0E-391
-
--- Zeros
-nextp100 nextplus 0 -> 1E-391
-nextp101 nextplus 0.00 -> 1E-391
-nextp102 nextplus 0E-300 -> 1E-391
-nextp103 nextplus 0E+300 -> 1E-391
-nextp104 nextplus 0E+30000 -> 1E-391
-nextp105 nextplus -0 -> 1E-391
-nextp106 nextplus -0.00 -> 1E-391
-nextp107 nextplus -0E-300 -> 1E-391
-nextp108 nextplus -0E+300 -> 1E-391
-nextp109 nextplus -0E+30000 -> 1E-391
-
-maxExponent: 999
-minexponent: -999
-precision: 9
--- specials
-nextp150 nextplus Inf -> Infinity
-nextp151 nextplus -Inf -> -9.99999999E+999
-nextp152 nextplus NaN -> NaN
-nextp153 nextplus sNaN -> NaN Invalid_operation
-nextp154 nextplus NaN77 -> NaN77
-nextp155 nextplus sNaN88 -> NaN88 Invalid_operation
-nextp156 nextplus -NaN -> -NaN
-nextp157 nextplus -sNaN -> -NaN Invalid_operation
-nextp158 nextplus -NaN77 -> -NaN77
-nextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-nextp170 nextplus 9.99999999E+999 -> Infinity
-nextp171 nextplus 9.99999998E+999 -> 9.99999999E+999
-nextp172 nextplus 1E-999 -> 1.00000001E-999
-nextp173 nextplus 1.00000000E-999 -> 1.00000001E-999
-nextp174 nextplus 9E-1007 -> 1.0E-1006
-nextp175 nextplus 9.9E-1006 -> 1.00E-1005
-nextp176 nextplus 9.9999E-1003 -> 1.00000E-1002
-nextp177 nextplus 9.9999999E-1000 -> 1.00000000E-999
-nextp178 nextplus 9.9999998E-1000 -> 9.9999999E-1000
-nextp179 nextplus 9.9999997E-1000 -> 9.9999998E-1000
-nextp180 nextplus 0E-1007 -> 1E-1007
-nextp181 nextplus 1E-1007 -> 2E-1007
-nextp182 nextplus 2E-1007 -> 3E-1007
-
-nextp183 nextplus -0E-1007 -> 1E-1007
-nextp184 nextplus -1E-1007 -> -0E-1007
-nextp185 nextplus -2E-1007 -> -1E-1007
-nextp186 nextplus -10E-1007 -> -9E-1007
-nextp187 nextplus -100E-1007 -> -9.9E-1006
-nextp188 nextplus -100000E-1007 -> -9.9999E-1003
-nextp189 nextplus -1.0000E-999 -> -9.9999999E-1000
-nextp190 nextplus -1.00000000E-999 -> -9.9999999E-1000
-nextp191 nextplus -1E-999 -> -9.9999999E-1000
-nextp192 nextplus -9.99999998E+999 -> -9.99999997E+999
-nextp193 nextplus -9.99999999E+999 -> -9.99999998E+999
-
--- Null tests
-nextp900 nextplus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- nextplus.decTest -- decimal next that is greater [754r nextup] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+nextp001 nextplus 0.999999995 -> 0.999999996
+nextp002 nextplus 0.999999996 -> 0.999999997
+nextp003 nextplus 0.999999997 -> 0.999999998
+nextp004 nextplus 0.999999998 -> 0.999999999
+nextp005 nextplus 0.999999999 -> 1.00000000
+nextp006 nextplus 1.00000000 -> 1.00000001
+nextp007 nextplus 1.0 -> 1.00000001
+nextp008 nextplus 1 -> 1.00000001
+nextp009 nextplus 1.00000001 -> 1.00000002
+nextp010 nextplus 1.00000002 -> 1.00000003
+nextp011 nextplus 1.00000003 -> 1.00000004
+nextp012 nextplus 1.00000004 -> 1.00000005
+nextp013 nextplus 1.00000005 -> 1.00000006
+nextp014 nextplus 1.00000006 -> 1.00000007
+nextp015 nextplus 1.00000007 -> 1.00000008
+nextp016 nextplus 1.00000008 -> 1.00000009
+nextp017 nextplus 1.00000009 -> 1.00000010
+nextp018 nextplus 1.00000010 -> 1.00000011
+nextp019 nextplus 1.00000011 -> 1.00000012
+
+nextp021 nextplus -0.999999995 -> -0.999999994
+nextp022 nextplus -0.999999996 -> -0.999999995
+nextp023 nextplus -0.999999997 -> -0.999999996
+nextp024 nextplus -0.999999998 -> -0.999999997
+nextp025 nextplus -0.999999999 -> -0.999999998
+nextp026 nextplus -1.00000000 -> -0.999999999
+nextp027 nextplus -1.0 -> -0.999999999
+nextp028 nextplus -1 -> -0.999999999
+nextp029 nextplus -1.00000001 -> -1.00000000
+nextp030 nextplus -1.00000002 -> -1.00000001
+nextp031 nextplus -1.00000003 -> -1.00000002
+nextp032 nextplus -1.00000004 -> -1.00000003
+nextp033 nextplus -1.00000005 -> -1.00000004
+nextp034 nextplus -1.00000006 -> -1.00000005
+nextp035 nextplus -1.00000007 -> -1.00000006
+nextp036 nextplus -1.00000008 -> -1.00000007
+nextp037 nextplus -1.00000009 -> -1.00000008
+nextp038 nextplus -1.00000010 -> -1.00000009
+nextp039 nextplus -1.00000011 -> -1.00000010
+nextp040 nextplus -1.00000012 -> -1.00000011
+
+-- input operand is >precision
+nextp041 nextplus 1.00000010998 -> 1.00000011
+nextp042 nextplus 1.00000010999 -> 1.00000011
+nextp043 nextplus 1.00000011000 -> 1.00000012
+nextp044 nextplus 1.00000011001 -> 1.00000012
+nextp045 nextplus 1.00000011002 -> 1.00000012
+nextp046 nextplus 1.00000011002 -> 1.00000012
+nextp047 nextplus 1.00000011052 -> 1.00000012
+nextp048 nextplus 1.00000011552 -> 1.00000012
+nextp049 nextplus -1.00000010998 -> -1.00000010
+nextp050 nextplus -1.00000010999 -> -1.00000010
+nextp051 nextplus -1.00000011000 -> -1.00000010
+nextp052 nextplus -1.00000011001 -> -1.00000011
+nextp053 nextplus -1.00000011002 -> -1.00000011
+nextp054 nextplus -1.00000011002 -> -1.00000011
+nextp055 nextplus -1.00000011052 -> -1.00000011
+nextp056 nextplus -1.00000011552 -> -1.00000011
+-- ultra-tiny inputs
+nextp060 nextplus 1E-99999 -> 1E-391
+nextp061 nextplus 1E-999999999 -> 1E-391
+nextp062 nextplus 1E-391 -> 2E-391
+nextp063 nextplus -1E-99999 -> -0E-391
+nextp064 nextplus -1E-999999999 -> -0E-391
+nextp065 nextplus -1E-391 -> -0E-391
+
+-- Zeros
+nextp100 nextplus 0 -> 1E-391
+nextp101 nextplus 0.00 -> 1E-391
+nextp102 nextplus 0E-300 -> 1E-391
+nextp103 nextplus 0E+300 -> 1E-391
+nextp104 nextplus 0E+30000 -> 1E-391
+nextp105 nextplus -0 -> 1E-391
+nextp106 nextplus -0.00 -> 1E-391
+nextp107 nextplus -0E-300 -> 1E-391
+nextp108 nextplus -0E+300 -> 1E-391
+nextp109 nextplus -0E+30000 -> 1E-391
+
+maxExponent: 999
+minexponent: -999
+precision: 9
+-- specials
+nextp150 nextplus Inf -> Infinity
+nextp151 nextplus -Inf -> -9.99999999E+999
+nextp152 nextplus NaN -> NaN
+nextp153 nextplus sNaN -> NaN Invalid_operation
+nextp154 nextplus NaN77 -> NaN77
+nextp155 nextplus sNaN88 -> NaN88 Invalid_operation
+nextp156 nextplus -NaN -> -NaN
+nextp157 nextplus -sNaN -> -NaN Invalid_operation
+nextp158 nextplus -NaN77 -> -NaN77
+nextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+nextp170 nextplus 9.99999999E+999 -> Infinity
+nextp171 nextplus 9.99999998E+999 -> 9.99999999E+999
+nextp172 nextplus 1E-999 -> 1.00000001E-999
+nextp173 nextplus 1.00000000E-999 -> 1.00000001E-999
+nextp174 nextplus 9E-1007 -> 1.0E-1006
+nextp175 nextplus 9.9E-1006 -> 1.00E-1005
+nextp176 nextplus 9.9999E-1003 -> 1.00000E-1002
+nextp177 nextplus 9.9999999E-1000 -> 1.00000000E-999
+nextp178 nextplus 9.9999998E-1000 -> 9.9999999E-1000
+nextp179 nextplus 9.9999997E-1000 -> 9.9999998E-1000
+nextp180 nextplus 0E-1007 -> 1E-1007
+nextp181 nextplus 1E-1007 -> 2E-1007
+nextp182 nextplus 2E-1007 -> 3E-1007
+
+nextp183 nextplus -0E-1007 -> 1E-1007
+nextp184 nextplus -1E-1007 -> -0E-1007
+nextp185 nextplus -2E-1007 -> -1E-1007
+nextp186 nextplus -10E-1007 -> -9E-1007
+nextp187 nextplus -100E-1007 -> -9.9E-1006
+nextp188 nextplus -100000E-1007 -> -9.9999E-1003
+nextp189 nextplus -1.0000E-999 -> -9.9999999E-1000
+nextp190 nextplus -1.00000000E-999 -> -9.9999999E-1000
+nextp191 nextplus -1E-999 -> -9.9999999E-1000
+nextp192 nextplus -9.99999998E+999 -> -9.99999997E+999
+nextp193 nextplus -9.99999999E+999 -> -9.99999998E+999
+
+-- Null tests
+nextp900 nextplus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/nexttoward.decTest b/Lib/test/decimaltestdata/nexttoward.decTest
index 562385a00f..da26f651c8 100644
--- a/Lib/test/decimaltestdata/nexttoward.decTest
+++ b/Lib/test/decimaltestdata/nexttoward.decTest
@@ -1,426 +1,426 @@
-------------------------------------------------------------------------
--- nexttoward.decTest -- decimal next toward rhs [754r nextafter] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- Sanity check with a scattering of numerics
-nextt001 nexttoward 10 10 -> 10
-nextt002 nexttoward -10 -10 -> -10
-nextt003 nexttoward 1 10 -> 1.00000001
-nextt004 nexttoward 1 -10 -> 0.999999999
-nextt005 nexttoward -1 10 -> -0.999999999
-nextt006 nexttoward -1 -10 -> -1.00000001
-nextt007 nexttoward 0 10 -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt008 nexttoward 0 -10 -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt009 nexttoward 9.99999999E+384 +Infinity -> Infinity Overflow Inexact Rounded
-nextt010 nexttoward -9.99999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
-
-------- lhs=rhs
--- finites
-nextt101 nexttoward 7 7 -> 7
-nextt102 nexttoward -7 -7 -> -7
-nextt103 nexttoward 75 75 -> 75
-nextt104 nexttoward -75 -75 -> -75
-nextt105 nexttoward 7.50 7.5 -> 7.50
-nextt106 nexttoward -7.50 -7.50 -> -7.50
-nextt107 nexttoward 7.500 7.5000 -> 7.500
-nextt108 nexttoward -7.500 -7.5 -> -7.500
-
--- zeros
-nextt111 nexttoward 0 0 -> 0
-nextt112 nexttoward -0 -0 -> -0
-nextt113 nexttoward 0E+4 0 -> 0E+4
-nextt114 nexttoward -0E+4 -0 -> -0E+4
-nextt115 nexttoward 0.0000 0.00000 -> 0.0000
-nextt116 nexttoward -0.0000 -0.00 -> -0.0000
-nextt117 nexttoward 0E-141 0 -> 0E-141
-nextt118 nexttoward -0E-141 -000 -> -0E-141
-
--- full coefficients, alternating bits
-nextt121 nexttoward 268268268 268268268 -> 268268268
-nextt122 nexttoward -268268268 -268268268 -> -268268268
-nextt123 nexttoward 134134134 134134134 -> 134134134
-nextt124 nexttoward -134134134 -134134134 -> -134134134
-
--- Nmax, Nmin, Ntiny
-nextt131 nexttoward 9.99999999E+384 9.99999999E+384 -> 9.99999999E+384
-nextt132 nexttoward 1E-383 1E-383 -> 1E-383
-nextt133 nexttoward 1.00000000E-383 1.00000000E-383 -> 1.00000000E-383
-nextt134 nexttoward 1E-391 1E-391 -> 1E-391
-
-nextt135 nexttoward -1E-391 -1E-391 -> -1E-391
-nextt136 nexttoward -1.00000000E-383 -1.00000000E-383 -> -1.00000000E-383
-nextt137 nexttoward -1E-383 -1E-383 -> -1E-383
-nextt138 nexttoward -9.99999999E+384 -9.99999999E+384 -> -9.99999999E+384
-
-------- lhs<rhs
-nextt201 nexttoward 0.999999995 Infinity -> 0.999999996
-nextt202 nexttoward 0.999999996 Infinity -> 0.999999997
-nextt203 nexttoward 0.999999997 Infinity -> 0.999999998
-nextt204 nexttoward 0.999999998 Infinity -> 0.999999999
-nextt205 nexttoward 0.999999999 Infinity -> 1.00000000
-nextt206 nexttoward 1.00000000 Infinity -> 1.00000001
-nextt207 nexttoward 1.0 Infinity -> 1.00000001
-nextt208 nexttoward 1 Infinity -> 1.00000001
-nextt209 nexttoward 1.00000001 Infinity -> 1.00000002
-nextt210 nexttoward 1.00000002 Infinity -> 1.00000003
-nextt211 nexttoward 1.00000003 Infinity -> 1.00000004
-nextt212 nexttoward 1.00000004 Infinity -> 1.00000005
-nextt213 nexttoward 1.00000005 Infinity -> 1.00000006
-nextt214 nexttoward 1.00000006 Infinity -> 1.00000007
-nextt215 nexttoward 1.00000007 Infinity -> 1.00000008
-nextt216 nexttoward 1.00000008 Infinity -> 1.00000009
-nextt217 nexttoward 1.00000009 Infinity -> 1.00000010
-nextt218 nexttoward 1.00000010 Infinity -> 1.00000011
-nextt219 nexttoward 1.00000011 Infinity -> 1.00000012
-
-nextt221 nexttoward -0.999999995 Infinity -> -0.999999994
-nextt222 nexttoward -0.999999996 Infinity -> -0.999999995
-nextt223 nexttoward -0.999999997 Infinity -> -0.999999996
-nextt224 nexttoward -0.999999998 Infinity -> -0.999999997
-nextt225 nexttoward -0.999999999 Infinity -> -0.999999998
-nextt226 nexttoward -1.00000000 Infinity -> -0.999999999
-nextt227 nexttoward -1.0 Infinity -> -0.999999999
-nextt228 nexttoward -1 Infinity -> -0.999999999
-nextt229 nexttoward -1.00000001 Infinity -> -1.00000000
-nextt230 nexttoward -1.00000002 Infinity -> -1.00000001
-nextt231 nexttoward -1.00000003 Infinity -> -1.00000002
-nextt232 nexttoward -1.00000004 Infinity -> -1.00000003
-nextt233 nexttoward -1.00000005 Infinity -> -1.00000004
-nextt234 nexttoward -1.00000006 Infinity -> -1.00000005
-nextt235 nexttoward -1.00000007 Infinity -> -1.00000006
-nextt236 nexttoward -1.00000008 Infinity -> -1.00000007
-nextt237 nexttoward -1.00000009 Infinity -> -1.00000008
-nextt238 nexttoward -1.00000010 Infinity -> -1.00000009
-nextt239 nexttoward -1.00000011 Infinity -> -1.00000010
-nextt240 nexttoward -1.00000012 Infinity -> -1.00000011
-
--- input operand is >precision
-nextt241 nexttoward 1.00000010998 Infinity -> 1.00000011
-nextt242 nexttoward 1.00000010999 Infinity -> 1.00000011
-nextt243 nexttoward 1.00000011000 Infinity -> 1.00000012
-nextt244 nexttoward 1.00000011001 Infinity -> 1.00000012
-nextt245 nexttoward 1.00000011002 Infinity -> 1.00000012
-nextt246 nexttoward 1.00000011002 Infinity -> 1.00000012
-nextt247 nexttoward 1.00000011052 Infinity -> 1.00000012
-nextt248 nexttoward 1.00000011552 Infinity -> 1.00000012
-nextt249 nexttoward -1.00000010998 Infinity -> -1.00000010
-nextt250 nexttoward -1.00000010999 Infinity -> -1.00000010
-nextt251 nexttoward -1.00000011000 Infinity -> -1.00000010
-nextt252 nexttoward -1.00000011001 Infinity -> -1.00000011
-nextt253 nexttoward -1.00000011002 Infinity -> -1.00000011
-nextt254 nexttoward -1.00000011002 Infinity -> -1.00000011
-nextt255 nexttoward -1.00000011052 Infinity -> -1.00000011
-nextt256 nexttoward -1.00000011552 Infinity -> -1.00000011
--- ultra-tiny inputs
-nextt260 nexttoward 1E-99999 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt261 nexttoward 1E-999999999 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt262 nexttoward 1E-391 Infinity -> 2E-391 Underflow Subnormal Inexact Rounded
-nextt263 nexttoward -1E-99999 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt264 nexttoward -1E-999999999 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt265 nexttoward -1E-391 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
-
--- Zeros
-nextt300 nexttoward 0 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt301 nexttoward 0.00 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt302 nexttoward 0E-300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt303 nexttoward 0E+300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt304 nexttoward 0E+30000 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt305 nexttoward -0 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt306 nexttoward -0.00 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt307 nexttoward -0E-300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt308 nexttoward -0E+300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt309 nexttoward -0E+30000 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-
--- specials
-nextt350 nexttoward Inf Infinity -> Infinity
-nextt351 nexttoward -Inf Infinity -> -9.99999999E+384
-nextt352 nexttoward NaN Infinity -> NaN
-nextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
-nextt354 nexttoward NaN77 Infinity -> NaN77
-nextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
-nextt356 nexttoward -NaN Infinity -> -NaN
-nextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
-nextt358 nexttoward -NaN77 Infinity -> -NaN77
-nextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-maxExponent: 999
-minexponent: -999
-nextt370 nexttoward 9.99999999E+999 Infinity -> Infinity Overflow Inexact Rounded
-nextt371 nexttoward 9.99999998E+999 Infinity -> 9.99999999E+999
-nextt372 nexttoward 1E-999 Infinity -> 1.00000001E-999
-nextt373 nexttoward 1.00000000E-999 Infinity -> 1.00000001E-999
-nextt374 nexttoward 0.999999999E-999 Infinity -> 1.00000000E-999
-nextt375 nexttoward 0.99999999E-999 Infinity -> 1.00000000E-999
-nextt376 nexttoward 9E-1007 Infinity -> 1.0E-1006 Underflow Subnormal Inexact Rounded
-nextt377 nexttoward 9.9E-1006 Infinity -> 1.00E-1005 Underflow Subnormal Inexact Rounded
-nextt378 nexttoward 9.9999E-1003 Infinity -> 1.00000E-1002 Underflow Subnormal Inexact Rounded
-nextt379 nexttoward 9.9999998E-1000 Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt380 nexttoward 9.9999997E-1000 Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
-nextt381 nexttoward 0E-1007 Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
-nextt382 nexttoward 1E-1007 Infinity -> 2E-1007 Underflow Subnormal Inexact Rounded
-nextt383 nexttoward 2E-1007 Infinity -> 3E-1007 Underflow Subnormal Inexact Rounded
-
-nextt385 nexttoward -0E-1007 Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
-nextt386 nexttoward -1E-1007 Infinity -> -0E-1007 Underflow Subnormal Inexact Rounded Clamped
-nextt387 nexttoward -2E-1007 Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
-nextt388 nexttoward -10E-1007 Infinity -> -9E-1007 Underflow Subnormal Inexact Rounded
-nextt389 nexttoward -100E-1007 Infinity -> -9.9E-1006 Underflow Subnormal Inexact Rounded
-nextt390 nexttoward -100000E-1007 Infinity -> -9.9999E-1003 Underflow Subnormal Inexact Rounded
-nextt391 nexttoward -1.0000E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt392 nexttoward -1.00000000E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt393 nexttoward -1E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt394 nexttoward -9.99999998E+999 Infinity -> -9.99999997E+999
-nextt395 nexttoward -9.99999999E+999 Infinity -> -9.99999998E+999
-
-------- lhs>rhs
-maxExponent: 384
-minexponent: -383
-nextt401 nexttoward 0.999999995 -Infinity -> 0.999999994
-nextt402 nexttoward 0.999999996 -Infinity -> 0.999999995
-nextt403 nexttoward 0.999999997 -Infinity -> 0.999999996
-nextt404 nexttoward 0.999999998 -Infinity -> 0.999999997
-nextt405 nexttoward 0.999999999 -Infinity -> 0.999999998
-nextt406 nexttoward 1.00000000 -Infinity -> 0.999999999
-nextt407 nexttoward 1.0 -Infinity -> 0.999999999
-nextt408 nexttoward 1 -Infinity -> 0.999999999
-nextt409 nexttoward 1.00000001 -Infinity -> 1.00000000
-nextt410 nexttoward 1.00000002 -Infinity -> 1.00000001
-nextt411 nexttoward 1.00000003 -Infinity -> 1.00000002
-nextt412 nexttoward 1.00000004 -Infinity -> 1.00000003
-nextt413 nexttoward 1.00000005 -Infinity -> 1.00000004
-nextt414 nexttoward 1.00000006 -Infinity -> 1.00000005
-nextt415 nexttoward 1.00000007 -Infinity -> 1.00000006
-nextt416 nexttoward 1.00000008 -Infinity -> 1.00000007
-nextt417 nexttoward 1.00000009 -Infinity -> 1.00000008
-nextt418 nexttoward 1.00000010 -Infinity -> 1.00000009
-nextt419 nexttoward 1.00000011 -Infinity -> 1.00000010
-nextt420 nexttoward 1.00000012 -Infinity -> 1.00000011
-
-nextt421 nexttoward -0.999999995 -Infinity -> -0.999999996
-nextt422 nexttoward -0.999999996 -Infinity -> -0.999999997
-nextt423 nexttoward -0.999999997 -Infinity -> -0.999999998
-nextt424 nexttoward -0.999999998 -Infinity -> -0.999999999
-nextt425 nexttoward -0.999999999 -Infinity -> -1.00000000
-nextt426 nexttoward -1.00000000 -Infinity -> -1.00000001
-nextt427 nexttoward -1.0 -Infinity -> -1.00000001
-nextt428 nexttoward -1 -Infinity -> -1.00000001
-nextt429 nexttoward -1.00000001 -Infinity -> -1.00000002
-nextt430 nexttoward -1.00000002 -Infinity -> -1.00000003
-nextt431 nexttoward -1.00000003 -Infinity -> -1.00000004
-nextt432 nexttoward -1.00000004 -Infinity -> -1.00000005
-nextt433 nexttoward -1.00000005 -Infinity -> -1.00000006
-nextt434 nexttoward -1.00000006 -Infinity -> -1.00000007
-nextt435 nexttoward -1.00000007 -Infinity -> -1.00000008
-nextt436 nexttoward -1.00000008 -Infinity -> -1.00000009
-nextt437 nexttoward -1.00000009 -Infinity -> -1.00000010
-nextt438 nexttoward -1.00000010 -Infinity -> -1.00000011
-nextt439 nexttoward -1.00000011 -Infinity -> -1.00000012
-
--- input operand is >precision
-nextt441 nexttoward 1.00000010998 -Infinity -> 1.00000010
-nextt442 nexttoward 1.00000010999 -Infinity -> 1.00000010
-nextt443 nexttoward 1.00000011000 -Infinity -> 1.00000010
-nextt444 nexttoward 1.00000011001 -Infinity -> 1.00000011
-nextt445 nexttoward 1.00000011002 -Infinity -> 1.00000011
-nextt446 nexttoward 1.00000011002 -Infinity -> 1.00000011
-nextt447 nexttoward 1.00000011052 -Infinity -> 1.00000011
-nextt448 nexttoward 1.00000011552 -Infinity -> 1.00000011
-nextt449 nexttoward -1.00000010998 -Infinity -> -1.00000011
-nextt450 nexttoward -1.00000010999 -Infinity -> -1.00000011
-nextt451 nexttoward -1.00000011000 -Infinity -> -1.00000012
-nextt452 nexttoward -1.00000011001 -Infinity -> -1.00000012
-nextt453 nexttoward -1.00000011002 -Infinity -> -1.00000012
-nextt454 nexttoward -1.00000011002 -Infinity -> -1.00000012
-nextt455 nexttoward -1.00000011052 -Infinity -> -1.00000012
-nextt456 nexttoward -1.00000011552 -Infinity -> -1.00000012
--- ultra-tiny inputs
-nextt460 nexttoward 1E-99999 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt461 nexttoward 1E-999999999 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt462 nexttoward 1E-391 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt463 nexttoward -1E-99999 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt464 nexttoward -1E-999999999 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt465 nexttoward -1E-391 -Infinity -> -2E-391 Underflow Subnormal Inexact Rounded
-
--- Zeros
-nextt500 nexttoward -0 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt501 nexttoward 0 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt502 nexttoward 0.00 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt503 nexttoward -0.00 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt504 nexttoward 0E-300 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt505 nexttoward 0E+300 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt506 nexttoward 0E+30000 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt507 nexttoward -0E+30000 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt508 nexttoward 0.00 -0.0000 -> -0.00
-
--- specials
-nextt550 nexttoward Inf -Infinity -> 9.99999999E+384
-nextt551 nexttoward -Inf -Infinity -> -Infinity
-nextt552 nexttoward NaN -Infinity -> NaN
-nextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
-nextt554 nexttoward NaN77 -Infinity -> NaN77
-nextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
-nextt556 nexttoward -NaN -Infinity -> -NaN
-nextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
-nextt558 nexttoward -NaN77 -Infinity -> -NaN77
-nextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-maxExponent: 999
-minexponent: -999
-nextt570 nexttoward 9.99999999E+999 -Infinity -> 9.99999998E+999
-nextt571 nexttoward 9.99999998E+999 -Infinity -> 9.99999997E+999
-nextt572 nexttoward 1E-999 -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt573 nexttoward 1.00000000E-999 -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt574 nexttoward 9E-1007 -Infinity -> 8E-1007 Underflow Subnormal Inexact Rounded
-nextt575 nexttoward 9.9E-1006 -Infinity -> 9.8E-1006 Underflow Subnormal Inexact Rounded
-nextt576 nexttoward 9.9999E-1003 -Infinity -> 9.9998E-1003 Underflow Subnormal Inexact Rounded
-nextt577 nexttoward 9.9999999E-1000 -Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
-nextt578 nexttoward 9.9999998E-1000 -Infinity -> 9.9999997E-1000 Underflow Subnormal Inexact Rounded
-nextt579 nexttoward 9.9999997E-1000 -Infinity -> 9.9999996E-1000 Underflow Subnormal Inexact Rounded
-nextt580 nexttoward 0E-1007 -Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
-nextt581 nexttoward 1E-1007 -Infinity -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
-nextt582 nexttoward 2E-1007 -Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
-
-nextt583 nexttoward -0E-1007 -Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
-nextt584 nexttoward -1E-1007 -Infinity -> -2E-1007 Underflow Subnormal Inexact Rounded
-nextt585 nexttoward -2E-1007 -Infinity -> -3E-1007 Underflow Subnormal Inexact Rounded
-nextt586 nexttoward -10E-1007 -Infinity -> -1.1E-1006 Underflow Subnormal Inexact Rounded
-nextt587 nexttoward -100E-1007 -Infinity -> -1.01E-1005 Underflow Subnormal Inexact Rounded
-nextt588 nexttoward -100000E-1007 -Infinity -> -1.00001E-1002 Underflow Subnormal Inexact Rounded
-nextt589 nexttoward -1.0000E-999 -Infinity -> -1.00000001E-999
-nextt590 nexttoward -1.00000000E-999 -Infinity -> -1.00000001E-999
-nextt591 nexttoward -1E-999 -Infinity -> -1.00000001E-999
-nextt592 nexttoward -9.99999998E+999 -Infinity -> -9.99999999E+999
-nextt593 nexttoward -9.99999999E+999 -Infinity -> -Infinity Overflow Inexact Rounded
-
-
-
-
-------- Specials
-maxExponent: 384
-minexponent: -383
-nextt780 nexttoward -Inf -Inf -> -Infinity
-nextt781 nexttoward -Inf -1000 -> -9.99999999E+384
-nextt782 nexttoward -Inf -1 -> -9.99999999E+384
-nextt783 nexttoward -Inf -0 -> -9.99999999E+384
-nextt784 nexttoward -Inf 0 -> -9.99999999E+384
-nextt785 nexttoward -Inf 1 -> -9.99999999E+384
-nextt786 nexttoward -Inf 1000 -> -9.99999999E+384
-nextt787 nexttoward -1000 -Inf -> -1000.00001
-nextt788 nexttoward -Inf -Inf -> -Infinity
-nextt789 nexttoward -1 -Inf -> -1.00000001
-nextt790 nexttoward -0 -Inf -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt791 nexttoward 0 -Inf -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt792 nexttoward 1 -Inf -> 0.999999999
-nextt793 nexttoward 1000 -Inf -> 999.999999
-nextt794 nexttoward Inf -Inf -> 9.99999999E+384
-
-nextt800 nexttoward Inf -Inf -> 9.99999999E+384
-nextt801 nexttoward Inf -1000 -> 9.99999999E+384
-nextt802 nexttoward Inf -1 -> 9.99999999E+384
-nextt803 nexttoward Inf -0 -> 9.99999999E+384
-nextt804 nexttoward Inf 0 -> 9.99999999E+384
-nextt805 nexttoward Inf 1 -> 9.99999999E+384
-nextt806 nexttoward Inf 1000 -> 9.99999999E+384
-nextt807 nexttoward Inf Inf -> Infinity
-nextt808 nexttoward -1000 Inf -> -999.999999
-nextt809 nexttoward -Inf Inf -> -9.99999999E+384
-nextt810 nexttoward -1 Inf -> -0.999999999
-nextt811 nexttoward -0 Inf -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt812 nexttoward 0 Inf -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt813 nexttoward 1 Inf -> 1.00000001
-nextt814 nexttoward 1000 Inf -> 1000.00001
-nextt815 nexttoward Inf Inf -> Infinity
-
-nextt821 nexttoward NaN -Inf -> NaN
-nextt822 nexttoward NaN -1000 -> NaN
-nextt823 nexttoward NaN -1 -> NaN
-nextt824 nexttoward NaN -0 -> NaN
-nextt825 nexttoward NaN 0 -> NaN
-nextt826 nexttoward NaN 1 -> NaN
-nextt827 nexttoward NaN 1000 -> NaN
-nextt828 nexttoward NaN Inf -> NaN
-nextt829 nexttoward NaN NaN -> NaN
-nextt830 nexttoward -Inf NaN -> NaN
-nextt831 nexttoward -1000 NaN -> NaN
-nextt832 nexttoward -1 NaN -> NaN
-nextt833 nexttoward -0 NaN -> NaN
-nextt834 nexttoward 0 NaN -> NaN
-nextt835 nexttoward 1 NaN -> NaN
-nextt836 nexttoward 1000 NaN -> NaN
-nextt837 nexttoward Inf NaN -> NaN
-
-nextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
-nextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
-nextt843 nexttoward sNaN -1 -> NaN Invalid_operation
-nextt844 nexttoward sNaN -0 -> NaN Invalid_operation
-nextt845 nexttoward sNaN 0 -> NaN Invalid_operation
-nextt846 nexttoward sNaN 1 -> NaN Invalid_operation
-nextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
-nextt848 nexttoward sNaN NaN -> NaN Invalid_operation
-nextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
-nextt850 nexttoward NaN sNaN -> NaN Invalid_operation
-nextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
-nextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
-nextt853 nexttoward -1 sNaN -> NaN Invalid_operation
-nextt854 nexttoward -0 sNaN -> NaN Invalid_operation
-nextt855 nexttoward 0 sNaN -> NaN Invalid_operation
-nextt856 nexttoward 1 sNaN -> NaN Invalid_operation
-nextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
-nextt858 nexttoward Inf sNaN -> NaN Invalid_operation
-nextt859 nexttoward NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-nextt861 nexttoward NaN1 -Inf -> NaN1
-nextt862 nexttoward +NaN2 -1000 -> NaN2
-nextt863 nexttoward NaN3 1000 -> NaN3
-nextt864 nexttoward NaN4 Inf -> NaN4
-nextt865 nexttoward NaN5 +NaN6 -> NaN5
-nextt866 nexttoward -Inf NaN7 -> NaN7
-nextt867 nexttoward -1000 NaN8 -> NaN8
-nextt868 nexttoward 1000 NaN9 -> NaN9
-nextt869 nexttoward Inf +NaN10 -> NaN10
-nextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
-nextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
-nextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
-nextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
-nextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
-nextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
-nextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
-nextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
-nextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
-nextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
-nextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
-nextt882 nexttoward -NaN26 NaN28 -> -NaN26
-nextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-nextt884 nexttoward 1000 -NaN30 -> -NaN30
-nextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Null tests
-nextt900 nexttoward 1 # -> NaN Invalid_operation
-nextt901 nexttoward # 1 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- nexttoward.decTest -- decimal next toward rhs [754r nextafter] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- Sanity check with a scattering of numerics
+nextt001 nexttoward 10 10 -> 10
+nextt002 nexttoward -10 -10 -> -10
+nextt003 nexttoward 1 10 -> 1.00000001
+nextt004 nexttoward 1 -10 -> 0.999999999
+nextt005 nexttoward -1 10 -> -0.999999999
+nextt006 nexttoward -1 -10 -> -1.00000001
+nextt007 nexttoward 0 10 -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt008 nexttoward 0 -10 -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt009 nexttoward 9.99999999E+384 +Infinity -> Infinity Overflow Inexact Rounded
+nextt010 nexttoward -9.99999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
+
+------- lhs=rhs
+-- finites
+nextt101 nexttoward 7 7 -> 7
+nextt102 nexttoward -7 -7 -> -7
+nextt103 nexttoward 75 75 -> 75
+nextt104 nexttoward -75 -75 -> -75
+nextt105 nexttoward 7.50 7.5 -> 7.50
+nextt106 nexttoward -7.50 -7.50 -> -7.50
+nextt107 nexttoward 7.500 7.5000 -> 7.500
+nextt108 nexttoward -7.500 -7.5 -> -7.500
+
+-- zeros
+nextt111 nexttoward 0 0 -> 0
+nextt112 nexttoward -0 -0 -> -0
+nextt113 nexttoward 0E+4 0 -> 0E+4
+nextt114 nexttoward -0E+4 -0 -> -0E+4
+nextt115 nexttoward 0.0000 0.00000 -> 0.0000
+nextt116 nexttoward -0.0000 -0.00 -> -0.0000
+nextt117 nexttoward 0E-141 0 -> 0E-141
+nextt118 nexttoward -0E-141 -000 -> -0E-141
+
+-- full coefficients, alternating bits
+nextt121 nexttoward 268268268 268268268 -> 268268268
+nextt122 nexttoward -268268268 -268268268 -> -268268268
+nextt123 nexttoward 134134134 134134134 -> 134134134
+nextt124 nexttoward -134134134 -134134134 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+nextt131 nexttoward 9.99999999E+384 9.99999999E+384 -> 9.99999999E+384
+nextt132 nexttoward 1E-383 1E-383 -> 1E-383
+nextt133 nexttoward 1.00000000E-383 1.00000000E-383 -> 1.00000000E-383
+nextt134 nexttoward 1E-391 1E-391 -> 1E-391
+
+nextt135 nexttoward -1E-391 -1E-391 -> -1E-391
+nextt136 nexttoward -1.00000000E-383 -1.00000000E-383 -> -1.00000000E-383
+nextt137 nexttoward -1E-383 -1E-383 -> -1E-383
+nextt138 nexttoward -9.99999999E+384 -9.99999999E+384 -> -9.99999999E+384
+
+------- lhs<rhs
+nextt201 nexttoward 0.999999995 Infinity -> 0.999999996
+nextt202 nexttoward 0.999999996 Infinity -> 0.999999997
+nextt203 nexttoward 0.999999997 Infinity -> 0.999999998
+nextt204 nexttoward 0.999999998 Infinity -> 0.999999999
+nextt205 nexttoward 0.999999999 Infinity -> 1.00000000
+nextt206 nexttoward 1.00000000 Infinity -> 1.00000001
+nextt207 nexttoward 1.0 Infinity -> 1.00000001
+nextt208 nexttoward 1 Infinity -> 1.00000001
+nextt209 nexttoward 1.00000001 Infinity -> 1.00000002
+nextt210 nexttoward 1.00000002 Infinity -> 1.00000003
+nextt211 nexttoward 1.00000003 Infinity -> 1.00000004
+nextt212 nexttoward 1.00000004 Infinity -> 1.00000005
+nextt213 nexttoward 1.00000005 Infinity -> 1.00000006
+nextt214 nexttoward 1.00000006 Infinity -> 1.00000007
+nextt215 nexttoward 1.00000007 Infinity -> 1.00000008
+nextt216 nexttoward 1.00000008 Infinity -> 1.00000009
+nextt217 nexttoward 1.00000009 Infinity -> 1.00000010
+nextt218 nexttoward 1.00000010 Infinity -> 1.00000011
+nextt219 nexttoward 1.00000011 Infinity -> 1.00000012
+
+nextt221 nexttoward -0.999999995 Infinity -> -0.999999994
+nextt222 nexttoward -0.999999996 Infinity -> -0.999999995
+nextt223 nexttoward -0.999999997 Infinity -> -0.999999996
+nextt224 nexttoward -0.999999998 Infinity -> -0.999999997
+nextt225 nexttoward -0.999999999 Infinity -> -0.999999998
+nextt226 nexttoward -1.00000000 Infinity -> -0.999999999
+nextt227 nexttoward -1.0 Infinity -> -0.999999999
+nextt228 nexttoward -1 Infinity -> -0.999999999
+nextt229 nexttoward -1.00000001 Infinity -> -1.00000000
+nextt230 nexttoward -1.00000002 Infinity -> -1.00000001
+nextt231 nexttoward -1.00000003 Infinity -> -1.00000002
+nextt232 nexttoward -1.00000004 Infinity -> -1.00000003
+nextt233 nexttoward -1.00000005 Infinity -> -1.00000004
+nextt234 nexttoward -1.00000006 Infinity -> -1.00000005
+nextt235 nexttoward -1.00000007 Infinity -> -1.00000006
+nextt236 nexttoward -1.00000008 Infinity -> -1.00000007
+nextt237 nexttoward -1.00000009 Infinity -> -1.00000008
+nextt238 nexttoward -1.00000010 Infinity -> -1.00000009
+nextt239 nexttoward -1.00000011 Infinity -> -1.00000010
+nextt240 nexttoward -1.00000012 Infinity -> -1.00000011
+
+-- input operand is >precision
+nextt241 nexttoward 1.00000010998 Infinity -> 1.00000011
+nextt242 nexttoward 1.00000010999 Infinity -> 1.00000011
+nextt243 nexttoward 1.00000011000 Infinity -> 1.00000012
+nextt244 nexttoward 1.00000011001 Infinity -> 1.00000012
+nextt245 nexttoward 1.00000011002 Infinity -> 1.00000012
+nextt246 nexttoward 1.00000011002 Infinity -> 1.00000012
+nextt247 nexttoward 1.00000011052 Infinity -> 1.00000012
+nextt248 nexttoward 1.00000011552 Infinity -> 1.00000012
+nextt249 nexttoward -1.00000010998 Infinity -> -1.00000010
+nextt250 nexttoward -1.00000010999 Infinity -> -1.00000010
+nextt251 nexttoward -1.00000011000 Infinity -> -1.00000010
+nextt252 nexttoward -1.00000011001 Infinity -> -1.00000011
+nextt253 nexttoward -1.00000011002 Infinity -> -1.00000011
+nextt254 nexttoward -1.00000011002 Infinity -> -1.00000011
+nextt255 nexttoward -1.00000011052 Infinity -> -1.00000011
+nextt256 nexttoward -1.00000011552 Infinity -> -1.00000011
+-- ultra-tiny inputs
+nextt260 nexttoward 1E-99999 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt261 nexttoward 1E-999999999 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt262 nexttoward 1E-391 Infinity -> 2E-391 Underflow Subnormal Inexact Rounded
+nextt263 nexttoward -1E-99999 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt264 nexttoward -1E-999999999 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt265 nexttoward -1E-391 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
+
+-- Zeros
+nextt300 nexttoward 0 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt301 nexttoward 0.00 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt302 nexttoward 0E-300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt303 nexttoward 0E+300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt304 nexttoward 0E+30000 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt305 nexttoward -0 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt306 nexttoward -0.00 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt307 nexttoward -0E-300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt308 nexttoward -0E+300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt309 nexttoward -0E+30000 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+
+-- specials
+nextt350 nexttoward Inf Infinity -> Infinity
+nextt351 nexttoward -Inf Infinity -> -9.99999999E+384
+nextt352 nexttoward NaN Infinity -> NaN
+nextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
+nextt354 nexttoward NaN77 Infinity -> NaN77
+nextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
+nextt356 nexttoward -NaN Infinity -> -NaN
+nextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
+nextt358 nexttoward -NaN77 Infinity -> -NaN77
+nextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+maxExponent: 999
+minexponent: -999
+nextt370 nexttoward 9.99999999E+999 Infinity -> Infinity Overflow Inexact Rounded
+nextt371 nexttoward 9.99999998E+999 Infinity -> 9.99999999E+999
+nextt372 nexttoward 1E-999 Infinity -> 1.00000001E-999
+nextt373 nexttoward 1.00000000E-999 Infinity -> 1.00000001E-999
+nextt374 nexttoward 0.999999999E-999 Infinity -> 1.00000000E-999
+nextt375 nexttoward 0.99999999E-999 Infinity -> 1.00000000E-999
+nextt376 nexttoward 9E-1007 Infinity -> 1.0E-1006 Underflow Subnormal Inexact Rounded
+nextt377 nexttoward 9.9E-1006 Infinity -> 1.00E-1005 Underflow Subnormal Inexact Rounded
+nextt378 nexttoward 9.9999E-1003 Infinity -> 1.00000E-1002 Underflow Subnormal Inexact Rounded
+nextt379 nexttoward 9.9999998E-1000 Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt380 nexttoward 9.9999997E-1000 Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
+nextt381 nexttoward 0E-1007 Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
+nextt382 nexttoward 1E-1007 Infinity -> 2E-1007 Underflow Subnormal Inexact Rounded
+nextt383 nexttoward 2E-1007 Infinity -> 3E-1007 Underflow Subnormal Inexact Rounded
+
+nextt385 nexttoward -0E-1007 Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
+nextt386 nexttoward -1E-1007 Infinity -> -0E-1007 Underflow Subnormal Inexact Rounded Clamped
+nextt387 nexttoward -2E-1007 Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
+nextt388 nexttoward -10E-1007 Infinity -> -9E-1007 Underflow Subnormal Inexact Rounded
+nextt389 nexttoward -100E-1007 Infinity -> -9.9E-1006 Underflow Subnormal Inexact Rounded
+nextt390 nexttoward -100000E-1007 Infinity -> -9.9999E-1003 Underflow Subnormal Inexact Rounded
+nextt391 nexttoward -1.0000E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt392 nexttoward -1.00000000E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt393 nexttoward -1E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt394 nexttoward -9.99999998E+999 Infinity -> -9.99999997E+999
+nextt395 nexttoward -9.99999999E+999 Infinity -> -9.99999998E+999
+
+------- lhs>rhs
+maxExponent: 384
+minexponent: -383
+nextt401 nexttoward 0.999999995 -Infinity -> 0.999999994
+nextt402 nexttoward 0.999999996 -Infinity -> 0.999999995
+nextt403 nexttoward 0.999999997 -Infinity -> 0.999999996
+nextt404 nexttoward 0.999999998 -Infinity -> 0.999999997
+nextt405 nexttoward 0.999999999 -Infinity -> 0.999999998
+nextt406 nexttoward 1.00000000 -Infinity -> 0.999999999
+nextt407 nexttoward 1.0 -Infinity -> 0.999999999
+nextt408 nexttoward 1 -Infinity -> 0.999999999
+nextt409 nexttoward 1.00000001 -Infinity -> 1.00000000
+nextt410 nexttoward 1.00000002 -Infinity -> 1.00000001
+nextt411 nexttoward 1.00000003 -Infinity -> 1.00000002
+nextt412 nexttoward 1.00000004 -Infinity -> 1.00000003
+nextt413 nexttoward 1.00000005 -Infinity -> 1.00000004
+nextt414 nexttoward 1.00000006 -Infinity -> 1.00000005
+nextt415 nexttoward 1.00000007 -Infinity -> 1.00000006
+nextt416 nexttoward 1.00000008 -Infinity -> 1.00000007
+nextt417 nexttoward 1.00000009 -Infinity -> 1.00000008
+nextt418 nexttoward 1.00000010 -Infinity -> 1.00000009
+nextt419 nexttoward 1.00000011 -Infinity -> 1.00000010
+nextt420 nexttoward 1.00000012 -Infinity -> 1.00000011
+
+nextt421 nexttoward -0.999999995 -Infinity -> -0.999999996
+nextt422 nexttoward -0.999999996 -Infinity -> -0.999999997
+nextt423 nexttoward -0.999999997 -Infinity -> -0.999999998
+nextt424 nexttoward -0.999999998 -Infinity -> -0.999999999
+nextt425 nexttoward -0.999999999 -Infinity -> -1.00000000
+nextt426 nexttoward -1.00000000 -Infinity -> -1.00000001
+nextt427 nexttoward -1.0 -Infinity -> -1.00000001
+nextt428 nexttoward -1 -Infinity -> -1.00000001
+nextt429 nexttoward -1.00000001 -Infinity -> -1.00000002
+nextt430 nexttoward -1.00000002 -Infinity -> -1.00000003
+nextt431 nexttoward -1.00000003 -Infinity -> -1.00000004
+nextt432 nexttoward -1.00000004 -Infinity -> -1.00000005
+nextt433 nexttoward -1.00000005 -Infinity -> -1.00000006
+nextt434 nexttoward -1.00000006 -Infinity -> -1.00000007
+nextt435 nexttoward -1.00000007 -Infinity -> -1.00000008
+nextt436 nexttoward -1.00000008 -Infinity -> -1.00000009
+nextt437 nexttoward -1.00000009 -Infinity -> -1.00000010
+nextt438 nexttoward -1.00000010 -Infinity -> -1.00000011
+nextt439 nexttoward -1.00000011 -Infinity -> -1.00000012
+
+-- input operand is >precision
+nextt441 nexttoward 1.00000010998 -Infinity -> 1.00000010
+nextt442 nexttoward 1.00000010999 -Infinity -> 1.00000010
+nextt443 nexttoward 1.00000011000 -Infinity -> 1.00000010
+nextt444 nexttoward 1.00000011001 -Infinity -> 1.00000011
+nextt445 nexttoward 1.00000011002 -Infinity -> 1.00000011
+nextt446 nexttoward 1.00000011002 -Infinity -> 1.00000011
+nextt447 nexttoward 1.00000011052 -Infinity -> 1.00000011
+nextt448 nexttoward 1.00000011552 -Infinity -> 1.00000011
+nextt449 nexttoward -1.00000010998 -Infinity -> -1.00000011
+nextt450 nexttoward -1.00000010999 -Infinity -> -1.00000011
+nextt451 nexttoward -1.00000011000 -Infinity -> -1.00000012
+nextt452 nexttoward -1.00000011001 -Infinity -> -1.00000012
+nextt453 nexttoward -1.00000011002 -Infinity -> -1.00000012
+nextt454 nexttoward -1.00000011002 -Infinity -> -1.00000012
+nextt455 nexttoward -1.00000011052 -Infinity -> -1.00000012
+nextt456 nexttoward -1.00000011552 -Infinity -> -1.00000012
+-- ultra-tiny inputs
+nextt460 nexttoward 1E-99999 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt461 nexttoward 1E-999999999 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt462 nexttoward 1E-391 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt463 nexttoward -1E-99999 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt464 nexttoward -1E-999999999 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt465 nexttoward -1E-391 -Infinity -> -2E-391 Underflow Subnormal Inexact Rounded
+
+-- Zeros
+nextt500 nexttoward -0 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt501 nexttoward 0 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt502 nexttoward 0.00 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt503 nexttoward -0.00 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt504 nexttoward 0E-300 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt505 nexttoward 0E+300 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt506 nexttoward 0E+30000 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt507 nexttoward -0E+30000 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt508 nexttoward 0.00 -0.0000 -> -0.00
+
+-- specials
+nextt550 nexttoward Inf -Infinity -> 9.99999999E+384
+nextt551 nexttoward -Inf -Infinity -> -Infinity
+nextt552 nexttoward NaN -Infinity -> NaN
+nextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
+nextt554 nexttoward NaN77 -Infinity -> NaN77
+nextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
+nextt556 nexttoward -NaN -Infinity -> -NaN
+nextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
+nextt558 nexttoward -NaN77 -Infinity -> -NaN77
+nextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+maxExponent: 999
+minexponent: -999
+nextt570 nexttoward 9.99999999E+999 -Infinity -> 9.99999998E+999
+nextt571 nexttoward 9.99999998E+999 -Infinity -> 9.99999997E+999
+nextt572 nexttoward 1E-999 -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt573 nexttoward 1.00000000E-999 -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt574 nexttoward 9E-1007 -Infinity -> 8E-1007 Underflow Subnormal Inexact Rounded
+nextt575 nexttoward 9.9E-1006 -Infinity -> 9.8E-1006 Underflow Subnormal Inexact Rounded
+nextt576 nexttoward 9.9999E-1003 -Infinity -> 9.9998E-1003 Underflow Subnormal Inexact Rounded
+nextt577 nexttoward 9.9999999E-1000 -Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
+nextt578 nexttoward 9.9999998E-1000 -Infinity -> 9.9999997E-1000 Underflow Subnormal Inexact Rounded
+nextt579 nexttoward 9.9999997E-1000 -Infinity -> 9.9999996E-1000 Underflow Subnormal Inexact Rounded
+nextt580 nexttoward 0E-1007 -Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
+nextt581 nexttoward 1E-1007 -Infinity -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
+nextt582 nexttoward 2E-1007 -Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
+
+nextt583 nexttoward -0E-1007 -Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
+nextt584 nexttoward -1E-1007 -Infinity -> -2E-1007 Underflow Subnormal Inexact Rounded
+nextt585 nexttoward -2E-1007 -Infinity -> -3E-1007 Underflow Subnormal Inexact Rounded
+nextt586 nexttoward -10E-1007 -Infinity -> -1.1E-1006 Underflow Subnormal Inexact Rounded
+nextt587 nexttoward -100E-1007 -Infinity -> -1.01E-1005 Underflow Subnormal Inexact Rounded
+nextt588 nexttoward -100000E-1007 -Infinity -> -1.00001E-1002 Underflow Subnormal Inexact Rounded
+nextt589 nexttoward -1.0000E-999 -Infinity -> -1.00000001E-999
+nextt590 nexttoward -1.00000000E-999 -Infinity -> -1.00000001E-999
+nextt591 nexttoward -1E-999 -Infinity -> -1.00000001E-999
+nextt592 nexttoward -9.99999998E+999 -Infinity -> -9.99999999E+999
+nextt593 nexttoward -9.99999999E+999 -Infinity -> -Infinity Overflow Inexact Rounded
+
+
+
+
+------- Specials
+maxExponent: 384
+minexponent: -383
+nextt780 nexttoward -Inf -Inf -> -Infinity
+nextt781 nexttoward -Inf -1000 -> -9.99999999E+384
+nextt782 nexttoward -Inf -1 -> -9.99999999E+384
+nextt783 nexttoward -Inf -0 -> -9.99999999E+384
+nextt784 nexttoward -Inf 0 -> -9.99999999E+384
+nextt785 nexttoward -Inf 1 -> -9.99999999E+384
+nextt786 nexttoward -Inf 1000 -> -9.99999999E+384
+nextt787 nexttoward -1000 -Inf -> -1000.00001
+nextt788 nexttoward -Inf -Inf -> -Infinity
+nextt789 nexttoward -1 -Inf -> -1.00000001
+nextt790 nexttoward -0 -Inf -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt791 nexttoward 0 -Inf -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt792 nexttoward 1 -Inf -> 0.999999999
+nextt793 nexttoward 1000 -Inf -> 999.999999
+nextt794 nexttoward Inf -Inf -> 9.99999999E+384
+
+nextt800 nexttoward Inf -Inf -> 9.99999999E+384
+nextt801 nexttoward Inf -1000 -> 9.99999999E+384
+nextt802 nexttoward Inf -1 -> 9.99999999E+384
+nextt803 nexttoward Inf -0 -> 9.99999999E+384
+nextt804 nexttoward Inf 0 -> 9.99999999E+384
+nextt805 nexttoward Inf 1 -> 9.99999999E+384
+nextt806 nexttoward Inf 1000 -> 9.99999999E+384
+nextt807 nexttoward Inf Inf -> Infinity
+nextt808 nexttoward -1000 Inf -> -999.999999
+nextt809 nexttoward -Inf Inf -> -9.99999999E+384
+nextt810 nexttoward -1 Inf -> -0.999999999
+nextt811 nexttoward -0 Inf -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt812 nexttoward 0 Inf -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt813 nexttoward 1 Inf -> 1.00000001
+nextt814 nexttoward 1000 Inf -> 1000.00001
+nextt815 nexttoward Inf Inf -> Infinity
+
+nextt821 nexttoward NaN -Inf -> NaN
+nextt822 nexttoward NaN -1000 -> NaN
+nextt823 nexttoward NaN -1 -> NaN
+nextt824 nexttoward NaN -0 -> NaN
+nextt825 nexttoward NaN 0 -> NaN
+nextt826 nexttoward NaN 1 -> NaN
+nextt827 nexttoward NaN 1000 -> NaN
+nextt828 nexttoward NaN Inf -> NaN
+nextt829 nexttoward NaN NaN -> NaN
+nextt830 nexttoward -Inf NaN -> NaN
+nextt831 nexttoward -1000 NaN -> NaN
+nextt832 nexttoward -1 NaN -> NaN
+nextt833 nexttoward -0 NaN -> NaN
+nextt834 nexttoward 0 NaN -> NaN
+nextt835 nexttoward 1 NaN -> NaN
+nextt836 nexttoward 1000 NaN -> NaN
+nextt837 nexttoward Inf NaN -> NaN
+
+nextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
+nextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
+nextt843 nexttoward sNaN -1 -> NaN Invalid_operation
+nextt844 nexttoward sNaN -0 -> NaN Invalid_operation
+nextt845 nexttoward sNaN 0 -> NaN Invalid_operation
+nextt846 nexttoward sNaN 1 -> NaN Invalid_operation
+nextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
+nextt848 nexttoward sNaN NaN -> NaN Invalid_operation
+nextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
+nextt850 nexttoward NaN sNaN -> NaN Invalid_operation
+nextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
+nextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
+nextt853 nexttoward -1 sNaN -> NaN Invalid_operation
+nextt854 nexttoward -0 sNaN -> NaN Invalid_operation
+nextt855 nexttoward 0 sNaN -> NaN Invalid_operation
+nextt856 nexttoward 1 sNaN -> NaN Invalid_operation
+nextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
+nextt858 nexttoward Inf sNaN -> NaN Invalid_operation
+nextt859 nexttoward NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+nextt861 nexttoward NaN1 -Inf -> NaN1
+nextt862 nexttoward +NaN2 -1000 -> NaN2
+nextt863 nexttoward NaN3 1000 -> NaN3
+nextt864 nexttoward NaN4 Inf -> NaN4
+nextt865 nexttoward NaN5 +NaN6 -> NaN5
+nextt866 nexttoward -Inf NaN7 -> NaN7
+nextt867 nexttoward -1000 NaN8 -> NaN8
+nextt868 nexttoward 1000 NaN9 -> NaN9
+nextt869 nexttoward Inf +NaN10 -> NaN10
+nextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
+nextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
+nextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
+nextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
+nextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
+nextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
+nextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
+nextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
+nextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
+nextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
+nextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
+nextt882 nexttoward -NaN26 NaN28 -> -NaN26
+nextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+nextt884 nexttoward 1000 -NaN30 -> -NaN30
+nextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Null tests
+nextt900 nexttoward 1 # -> NaN Invalid_operation
+nextt901 nexttoward # 1 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/or.decTest b/Lib/test/decimaltestdata/or.decTest
index 1aebff4e00..f471d0b6ce 100644
--- a/Lib/test/decimaltestdata/or.decTest
+++ b/Lib/test/decimaltestdata/or.decTest
@@ -1,334 +1,334 @@
-------------------------------------------------------------------------
--- or.decTest -- digitwise logical OR --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check (truth table)
-orx001 or 0 0 -> 0
-orx002 or 0 1 -> 1
-orx003 or 1 0 -> 1
-orx004 or 1 1 -> 1
-orx005 or 1100 1010 -> 1110
--- and at msd and msd-1
-orx006 or 000000000 000000000 -> 0
-orx007 or 000000000 100000000 -> 100000000
-orx008 or 100000000 000000000 -> 100000000
-orx009 or 100000000 100000000 -> 100000000
-orx010 or 000000000 000000000 -> 0
-orx011 or 000000000 010000000 -> 10000000
-orx012 or 010000000 000000000 -> 10000000
-orx013 or 010000000 010000000 -> 10000000
-
--- Various lengths
--- 123456789 123456789 123456789
-orx021 or 111111111 111111111 -> 111111111
-orx022 or 111111111111 111111111 -> 111111111
-orx023 or 11111111 11111111 -> 11111111
-orx025 or 1111111 1111111 -> 1111111
-orx026 or 111111 111111 -> 111111
-orx027 or 11111 11111 -> 11111
-orx028 or 1111 1111 -> 1111
-orx029 or 111 111 -> 111
-orx031 or 11 11 -> 11
-orx032 or 1 1 -> 1
-orx033 or 111111111111 1111111111 -> 111111111
-orx034 or 11111111111 11111111111 -> 111111111
-orx035 or 1111111111 111111111111 -> 111111111
-orx036 or 111111111 1111111111111 -> 111111111
-
-orx040 or 111111111 111111111111 -> 111111111
-orx041 or 11111111 111111111111 -> 111111111
-orx042 or 11111111 111111111 -> 111111111
-orx043 or 1111111 100000010 -> 101111111
-orx044 or 111111 100000100 -> 100111111
-orx045 or 11111 100001000 -> 100011111
-orx046 or 1111 100010000 -> 100011111
-orx047 or 111 100100000 -> 100100111
-orx048 or 11 101000000 -> 101000011
-orx049 or 1 110000000 -> 110000001
-
-orx050 or 1111111111 1 -> 111111111
-orx051 or 111111111 1 -> 111111111
-orx052 or 11111111 1 -> 11111111
-orx053 or 1111111 1 -> 1111111
-orx054 or 111111 1 -> 111111
-orx055 or 11111 1 -> 11111
-orx056 or 1111 1 -> 1111
-orx057 or 111 1 -> 111
-orx058 or 11 1 -> 11
-orx059 or 1 1 -> 1
-
-orx060 or 1111111111 0 -> 111111111
-orx061 or 111111111 0 -> 111111111
-orx062 or 11111111 0 -> 11111111
-orx063 or 1111111 0 -> 1111111
-orx064 or 111111 0 -> 111111
-orx065 or 11111 0 -> 11111
-orx066 or 1111 0 -> 1111
-orx067 or 111 0 -> 111
-orx068 or 11 0 -> 11
-orx069 or 1 0 -> 1
-
-orx070 or 1 1111111111 -> 111111111
-orx071 or 1 111111111 -> 111111111
-orx072 or 1 11111111 -> 11111111
-orx073 or 1 1111111 -> 1111111
-orx074 or 1 111111 -> 111111
-orx075 or 1 11111 -> 11111
-orx076 or 1 1111 -> 1111
-orx077 or 1 111 -> 111
-orx078 or 1 11 -> 11
-orx079 or 1 1 -> 1
-
-orx080 or 0 1111111111 -> 111111111
-orx081 or 0 111111111 -> 111111111
-orx082 or 0 11111111 -> 11111111
-orx083 or 0 1111111 -> 1111111
-orx084 or 0 111111 -> 111111
-orx085 or 0 11111 -> 11111
-orx086 or 0 1111 -> 1111
-orx087 or 0 111 -> 111
-orx088 or 0 11 -> 11
-orx089 or 0 1 -> 1
-
-orx090 or 011111111 111101111 -> 111111111
-orx091 or 101111111 111101111 -> 111111111
-orx092 or 110111111 111101111 -> 111111111
-orx093 or 111011111 111101111 -> 111111111
-orx094 or 111101111 111101111 -> 111101111
-orx095 or 111110111 111101111 -> 111111111
-orx096 or 111111011 111101111 -> 111111111
-orx097 or 111111101 111101111 -> 111111111
-orx098 or 111111110 111101111 -> 111111111
-
-orx100 or 111101111 011111111 -> 111111111
-orx101 or 111101111 101111111 -> 111111111
-orx102 or 111101111 110111111 -> 111111111
-orx103 or 111101111 111011111 -> 111111111
-orx104 or 111101111 111101111 -> 111101111
-orx105 or 111101111 111110111 -> 111111111
-orx106 or 111101111 111111011 -> 111111111
-orx107 or 111101111 111111101 -> 111111111
-orx108 or 111101111 111111110 -> 111111111
-
--- non-0/1 should not be accepted, nor should signs
-orx220 or 111111112 111111111 -> NaN Invalid_operation
-orx221 or 333333333 333333333 -> NaN Invalid_operation
-orx222 or 555555555 555555555 -> NaN Invalid_operation
-orx223 or 777777777 777777777 -> NaN Invalid_operation
-orx224 or 999999999 999999999 -> NaN Invalid_operation
-orx225 or 222222222 999999999 -> NaN Invalid_operation
-orx226 or 444444444 999999999 -> NaN Invalid_operation
-orx227 or 666666666 999999999 -> NaN Invalid_operation
-orx228 or 888888888 999999999 -> NaN Invalid_operation
-orx229 or 999999999 222222222 -> NaN Invalid_operation
-orx230 or 999999999 444444444 -> NaN Invalid_operation
-orx231 or 999999999 666666666 -> NaN Invalid_operation
-orx232 or 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-orx240 or 567468689 -934981942 -> NaN Invalid_operation
-orx241 or 567367689 934981942 -> NaN Invalid_operation
-orx242 or -631917772 -706014634 -> NaN Invalid_operation
-orx243 or -756253257 138579234 -> NaN Invalid_operation
-orx244 or 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-orx250 or 200000000 100000000 -> NaN Invalid_operation
-orx251 or 700000000 100000000 -> NaN Invalid_operation
-orx252 or 800000000 100000000 -> NaN Invalid_operation
-orx253 or 900000000 100000000 -> NaN Invalid_operation
-orx254 or 200000000 000000000 -> NaN Invalid_operation
-orx255 or 700000000 000000000 -> NaN Invalid_operation
-orx256 or 800000000 000000000 -> NaN Invalid_operation
-orx257 or 900000000 000000000 -> NaN Invalid_operation
-orx258 or 100000000 200000000 -> NaN Invalid_operation
-orx259 or 100000000 700000000 -> NaN Invalid_operation
-orx260 or 100000000 800000000 -> NaN Invalid_operation
-orx261 or 100000000 900000000 -> NaN Invalid_operation
-orx262 or 000000000 200000000 -> NaN Invalid_operation
-orx263 or 000000000 700000000 -> NaN Invalid_operation
-orx264 or 000000000 800000000 -> NaN Invalid_operation
-orx265 or 000000000 900000000 -> NaN Invalid_operation
--- test MSD-1
-orx270 or 020000000 100000000 -> NaN Invalid_operation
-orx271 or 070100000 100000000 -> NaN Invalid_operation
-orx272 or 080010000 100000001 -> NaN Invalid_operation
-orx273 or 090001000 100000010 -> NaN Invalid_operation
-orx274 or 100000100 020010100 -> NaN Invalid_operation
-orx275 or 100000000 070001000 -> NaN Invalid_operation
-orx276 or 100000010 080010100 -> NaN Invalid_operation
-orx277 or 100000000 090000010 -> NaN Invalid_operation
--- test LSD
-orx280 or 001000002 100000000 -> NaN Invalid_operation
-orx281 or 000000007 100000000 -> NaN Invalid_operation
-orx282 or 000000008 100000000 -> NaN Invalid_operation
-orx283 or 000000009 100000000 -> NaN Invalid_operation
-orx284 or 100000000 000100002 -> NaN Invalid_operation
-orx285 or 100100000 001000007 -> NaN Invalid_operation
-orx286 or 100010000 010000008 -> NaN Invalid_operation
-orx287 or 100001000 100000009 -> NaN Invalid_operation
--- test Middie
-orx288 or 001020000 100000000 -> NaN Invalid_operation
-orx289 or 000070001 100000000 -> NaN Invalid_operation
-orx290 or 000080000 100010000 -> NaN Invalid_operation
-orx291 or 000090000 100001000 -> NaN Invalid_operation
-orx292 or 100000010 000020100 -> NaN Invalid_operation
-orx293 or 100100000 000070010 -> NaN Invalid_operation
-orx294 or 100010100 000080001 -> NaN Invalid_operation
-orx295 or 100001000 000090000 -> NaN Invalid_operation
--- signs
-orx296 or -100001000 -000000000 -> NaN Invalid_operation
-orx297 or -100001000 000010000 -> NaN Invalid_operation
-orx298 or 100001000 -000000000 -> NaN Invalid_operation
-orx299 or 100001000 000011000 -> 100011000
-
--- Nmax, Nmin, Ntiny
-orx331 or 2 9.99999999E+999 -> NaN Invalid_operation
-orx332 or 3 1E-999 -> NaN Invalid_operation
-orx333 or 4 1.00000000E-999 -> NaN Invalid_operation
-orx334 or 5 1E-1007 -> NaN Invalid_operation
-orx335 or 6 -1E-1007 -> NaN Invalid_operation
-orx336 or 7 -1.00000000E-999 -> NaN Invalid_operation
-orx337 or 8 -1E-999 -> NaN Invalid_operation
-orx338 or 9 -9.99999999E+999 -> NaN Invalid_operation
-orx341 or 9.99999999E+999 -18 -> NaN Invalid_operation
-orx342 or 1E-999 01 -> NaN Invalid_operation
-orx343 or 1.00000000E-999 -18 -> NaN Invalid_operation
-orx344 or 1E-1007 18 -> NaN Invalid_operation
-orx345 or -1E-1007 -10 -> NaN Invalid_operation
-orx346 or -1.00000000E-999 18 -> NaN Invalid_operation
-orx347 or -1E-999 10 -> NaN Invalid_operation
-orx348 or -9.99999999E+999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-orx361 or 1.0 1 -> NaN Invalid_operation
-orx362 or 1E+1 1 -> NaN Invalid_operation
-orx363 or 0.0 1 -> NaN Invalid_operation
-orx364 or 0E+1 1 -> NaN Invalid_operation
-orx365 or 9.9 1 -> NaN Invalid_operation
-orx366 or 9E+1 1 -> NaN Invalid_operation
-orx371 or 0 1.0 -> NaN Invalid_operation
-orx372 or 0 1E+1 -> NaN Invalid_operation
-orx373 or 0 0.0 -> NaN Invalid_operation
-orx374 or 0 0E+1 -> NaN Invalid_operation
-orx375 or 0 9.9 -> NaN Invalid_operation
-orx376 or 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-orx780 or -Inf -Inf -> NaN Invalid_operation
-orx781 or -Inf -1000 -> NaN Invalid_operation
-orx782 or -Inf -1 -> NaN Invalid_operation
-orx783 or -Inf -0 -> NaN Invalid_operation
-orx784 or -Inf 0 -> NaN Invalid_operation
-orx785 or -Inf 1 -> NaN Invalid_operation
-orx786 or -Inf 1000 -> NaN Invalid_operation
-orx787 or -1000 -Inf -> NaN Invalid_operation
-orx788 or -Inf -Inf -> NaN Invalid_operation
-orx789 or -1 -Inf -> NaN Invalid_operation
-orx790 or -0 -Inf -> NaN Invalid_operation
-orx791 or 0 -Inf -> NaN Invalid_operation
-orx792 or 1 -Inf -> NaN Invalid_operation
-orx793 or 1000 -Inf -> NaN Invalid_operation
-orx794 or Inf -Inf -> NaN Invalid_operation
-
-orx800 or Inf -Inf -> NaN Invalid_operation
-orx801 or Inf -1000 -> NaN Invalid_operation
-orx802 or Inf -1 -> NaN Invalid_operation
-orx803 or Inf -0 -> NaN Invalid_operation
-orx804 or Inf 0 -> NaN Invalid_operation
-orx805 or Inf 1 -> NaN Invalid_operation
-orx806 or Inf 1000 -> NaN Invalid_operation
-orx807 or Inf Inf -> NaN Invalid_operation
-orx808 or -1000 Inf -> NaN Invalid_operation
-orx809 or -Inf Inf -> NaN Invalid_operation
-orx810 or -1 Inf -> NaN Invalid_operation
-orx811 or -0 Inf -> NaN Invalid_operation
-orx812 or 0 Inf -> NaN Invalid_operation
-orx813 or 1 Inf -> NaN Invalid_operation
-orx814 or 1000 Inf -> NaN Invalid_operation
-orx815 or Inf Inf -> NaN Invalid_operation
-
-orx821 or NaN -Inf -> NaN Invalid_operation
-orx822 or NaN -1000 -> NaN Invalid_operation
-orx823 or NaN -1 -> NaN Invalid_operation
-orx824 or NaN -0 -> NaN Invalid_operation
-orx825 or NaN 0 -> NaN Invalid_operation
-orx826 or NaN 1 -> NaN Invalid_operation
-orx827 or NaN 1000 -> NaN Invalid_operation
-orx828 or NaN Inf -> NaN Invalid_operation
-orx829 or NaN NaN -> NaN Invalid_operation
-orx830 or -Inf NaN -> NaN Invalid_operation
-orx831 or -1000 NaN -> NaN Invalid_operation
-orx832 or -1 NaN -> NaN Invalid_operation
-orx833 or -0 NaN -> NaN Invalid_operation
-orx834 or 0 NaN -> NaN Invalid_operation
-orx835 or 1 NaN -> NaN Invalid_operation
-orx836 or 1000 NaN -> NaN Invalid_operation
-orx837 or Inf NaN -> NaN Invalid_operation
-
-orx841 or sNaN -Inf -> NaN Invalid_operation
-orx842 or sNaN -1000 -> NaN Invalid_operation
-orx843 or sNaN -1 -> NaN Invalid_operation
-orx844 or sNaN -0 -> NaN Invalid_operation
-orx845 or sNaN 0 -> NaN Invalid_operation
-orx846 or sNaN 1 -> NaN Invalid_operation
-orx847 or sNaN 1000 -> NaN Invalid_operation
-orx848 or sNaN NaN -> NaN Invalid_operation
-orx849 or sNaN sNaN -> NaN Invalid_operation
-orx850 or NaN sNaN -> NaN Invalid_operation
-orx851 or -Inf sNaN -> NaN Invalid_operation
-orx852 or -1000 sNaN -> NaN Invalid_operation
-orx853 or -1 sNaN -> NaN Invalid_operation
-orx854 or -0 sNaN -> NaN Invalid_operation
-orx855 or 0 sNaN -> NaN Invalid_operation
-orx856 or 1 sNaN -> NaN Invalid_operation
-orx857 or 1000 sNaN -> NaN Invalid_operation
-orx858 or Inf sNaN -> NaN Invalid_operation
-orx859 or NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-orx861 or NaN1 -Inf -> NaN Invalid_operation
-orx862 or +NaN2 -1000 -> NaN Invalid_operation
-orx863 or NaN3 1000 -> NaN Invalid_operation
-orx864 or NaN4 Inf -> NaN Invalid_operation
-orx865 or NaN5 +NaN6 -> NaN Invalid_operation
-orx866 or -Inf NaN7 -> NaN Invalid_operation
-orx867 or -1000 NaN8 -> NaN Invalid_operation
-orx868 or 1000 NaN9 -> NaN Invalid_operation
-orx869 or Inf +NaN10 -> NaN Invalid_operation
-orx871 or sNaN11 -Inf -> NaN Invalid_operation
-orx872 or sNaN12 -1000 -> NaN Invalid_operation
-orx873 or sNaN13 1000 -> NaN Invalid_operation
-orx874 or sNaN14 NaN17 -> NaN Invalid_operation
-orx875 or sNaN15 sNaN18 -> NaN Invalid_operation
-orx876 or NaN16 sNaN19 -> NaN Invalid_operation
-orx877 or -Inf +sNaN20 -> NaN Invalid_operation
-orx878 or -1000 sNaN21 -> NaN Invalid_operation
-orx879 or 1000 sNaN22 -> NaN Invalid_operation
-orx880 or Inf sNaN23 -> NaN Invalid_operation
-orx881 or +NaN25 +sNaN24 -> NaN Invalid_operation
-orx882 or -NaN26 NaN28 -> NaN Invalid_operation
-orx883 or -sNaN27 sNaN29 -> NaN Invalid_operation
-orx884 or 1000 -NaN30 -> NaN Invalid_operation
-orx885 or 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- or.decTest -- digitwise logical OR --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check (truth table)
+orx001 or 0 0 -> 0
+orx002 or 0 1 -> 1
+orx003 or 1 0 -> 1
+orx004 or 1 1 -> 1
+orx005 or 1100 1010 -> 1110
+-- and at msd and msd-1
+orx006 or 000000000 000000000 -> 0
+orx007 or 000000000 100000000 -> 100000000
+orx008 or 100000000 000000000 -> 100000000
+orx009 or 100000000 100000000 -> 100000000
+orx010 or 000000000 000000000 -> 0
+orx011 or 000000000 010000000 -> 10000000
+orx012 or 010000000 000000000 -> 10000000
+orx013 or 010000000 010000000 -> 10000000
+
+-- Various lengths
+-- 123456789 123456789 123456789
+orx021 or 111111111 111111111 -> 111111111
+orx022 or 111111111111 111111111 -> 111111111
+orx023 or 11111111 11111111 -> 11111111
+orx025 or 1111111 1111111 -> 1111111
+orx026 or 111111 111111 -> 111111
+orx027 or 11111 11111 -> 11111
+orx028 or 1111 1111 -> 1111
+orx029 or 111 111 -> 111
+orx031 or 11 11 -> 11
+orx032 or 1 1 -> 1
+orx033 or 111111111111 1111111111 -> 111111111
+orx034 or 11111111111 11111111111 -> 111111111
+orx035 or 1111111111 111111111111 -> 111111111
+orx036 or 111111111 1111111111111 -> 111111111
+
+orx040 or 111111111 111111111111 -> 111111111
+orx041 or 11111111 111111111111 -> 111111111
+orx042 or 11111111 111111111 -> 111111111
+orx043 or 1111111 100000010 -> 101111111
+orx044 or 111111 100000100 -> 100111111
+orx045 or 11111 100001000 -> 100011111
+orx046 or 1111 100010000 -> 100011111
+orx047 or 111 100100000 -> 100100111
+orx048 or 11 101000000 -> 101000011
+orx049 or 1 110000000 -> 110000001
+
+orx050 or 1111111111 1 -> 111111111
+orx051 or 111111111 1 -> 111111111
+orx052 or 11111111 1 -> 11111111
+orx053 or 1111111 1 -> 1111111
+orx054 or 111111 1 -> 111111
+orx055 or 11111 1 -> 11111
+orx056 or 1111 1 -> 1111
+orx057 or 111 1 -> 111
+orx058 or 11 1 -> 11
+orx059 or 1 1 -> 1
+
+orx060 or 1111111111 0 -> 111111111
+orx061 or 111111111 0 -> 111111111
+orx062 or 11111111 0 -> 11111111
+orx063 or 1111111 0 -> 1111111
+orx064 or 111111 0 -> 111111
+orx065 or 11111 0 -> 11111
+orx066 or 1111 0 -> 1111
+orx067 or 111 0 -> 111
+orx068 or 11 0 -> 11
+orx069 or 1 0 -> 1
+
+orx070 or 1 1111111111 -> 111111111
+orx071 or 1 111111111 -> 111111111
+orx072 or 1 11111111 -> 11111111
+orx073 or 1 1111111 -> 1111111
+orx074 or 1 111111 -> 111111
+orx075 or 1 11111 -> 11111
+orx076 or 1 1111 -> 1111
+orx077 or 1 111 -> 111
+orx078 or 1 11 -> 11
+orx079 or 1 1 -> 1
+
+orx080 or 0 1111111111 -> 111111111
+orx081 or 0 111111111 -> 111111111
+orx082 or 0 11111111 -> 11111111
+orx083 or 0 1111111 -> 1111111
+orx084 or 0 111111 -> 111111
+orx085 or 0 11111 -> 11111
+orx086 or 0 1111 -> 1111
+orx087 or 0 111 -> 111
+orx088 or 0 11 -> 11
+orx089 or 0 1 -> 1
+
+orx090 or 011111111 111101111 -> 111111111
+orx091 or 101111111 111101111 -> 111111111
+orx092 or 110111111 111101111 -> 111111111
+orx093 or 111011111 111101111 -> 111111111
+orx094 or 111101111 111101111 -> 111101111
+orx095 or 111110111 111101111 -> 111111111
+orx096 or 111111011 111101111 -> 111111111
+orx097 or 111111101 111101111 -> 111111111
+orx098 or 111111110 111101111 -> 111111111
+
+orx100 or 111101111 011111111 -> 111111111
+orx101 or 111101111 101111111 -> 111111111
+orx102 or 111101111 110111111 -> 111111111
+orx103 or 111101111 111011111 -> 111111111
+orx104 or 111101111 111101111 -> 111101111
+orx105 or 111101111 111110111 -> 111111111
+orx106 or 111101111 111111011 -> 111111111
+orx107 or 111101111 111111101 -> 111111111
+orx108 or 111101111 111111110 -> 111111111
+
+-- non-0/1 should not be accepted, nor should signs
+orx220 or 111111112 111111111 -> NaN Invalid_operation
+orx221 or 333333333 333333333 -> NaN Invalid_operation
+orx222 or 555555555 555555555 -> NaN Invalid_operation
+orx223 or 777777777 777777777 -> NaN Invalid_operation
+orx224 or 999999999 999999999 -> NaN Invalid_operation
+orx225 or 222222222 999999999 -> NaN Invalid_operation
+orx226 or 444444444 999999999 -> NaN Invalid_operation
+orx227 or 666666666 999999999 -> NaN Invalid_operation
+orx228 or 888888888 999999999 -> NaN Invalid_operation
+orx229 or 999999999 222222222 -> NaN Invalid_operation
+orx230 or 999999999 444444444 -> NaN Invalid_operation
+orx231 or 999999999 666666666 -> NaN Invalid_operation
+orx232 or 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+orx240 or 567468689 -934981942 -> NaN Invalid_operation
+orx241 or 567367689 934981942 -> NaN Invalid_operation
+orx242 or -631917772 -706014634 -> NaN Invalid_operation
+orx243 or -756253257 138579234 -> NaN Invalid_operation
+orx244 or 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+orx250 or 200000000 100000000 -> NaN Invalid_operation
+orx251 or 700000000 100000000 -> NaN Invalid_operation
+orx252 or 800000000 100000000 -> NaN Invalid_operation
+orx253 or 900000000 100000000 -> NaN Invalid_operation
+orx254 or 200000000 000000000 -> NaN Invalid_operation
+orx255 or 700000000 000000000 -> NaN Invalid_operation
+orx256 or 800000000 000000000 -> NaN Invalid_operation
+orx257 or 900000000 000000000 -> NaN Invalid_operation
+orx258 or 100000000 200000000 -> NaN Invalid_operation
+orx259 or 100000000 700000000 -> NaN Invalid_operation
+orx260 or 100000000 800000000 -> NaN Invalid_operation
+orx261 or 100000000 900000000 -> NaN Invalid_operation
+orx262 or 000000000 200000000 -> NaN Invalid_operation
+orx263 or 000000000 700000000 -> NaN Invalid_operation
+orx264 or 000000000 800000000 -> NaN Invalid_operation
+orx265 or 000000000 900000000 -> NaN Invalid_operation
+-- test MSD-1
+orx270 or 020000000 100000000 -> NaN Invalid_operation
+orx271 or 070100000 100000000 -> NaN Invalid_operation
+orx272 or 080010000 100000001 -> NaN Invalid_operation
+orx273 or 090001000 100000010 -> NaN Invalid_operation
+orx274 or 100000100 020010100 -> NaN Invalid_operation
+orx275 or 100000000 070001000 -> NaN Invalid_operation
+orx276 or 100000010 080010100 -> NaN Invalid_operation
+orx277 or 100000000 090000010 -> NaN Invalid_operation
+-- test LSD
+orx280 or 001000002 100000000 -> NaN Invalid_operation
+orx281 or 000000007 100000000 -> NaN Invalid_operation
+orx282 or 000000008 100000000 -> NaN Invalid_operation
+orx283 or 000000009 100000000 -> NaN Invalid_operation
+orx284 or 100000000 000100002 -> NaN Invalid_operation
+orx285 or 100100000 001000007 -> NaN Invalid_operation
+orx286 or 100010000 010000008 -> NaN Invalid_operation
+orx287 or 100001000 100000009 -> NaN Invalid_operation
+-- test Middie
+orx288 or 001020000 100000000 -> NaN Invalid_operation
+orx289 or 000070001 100000000 -> NaN Invalid_operation
+orx290 or 000080000 100010000 -> NaN Invalid_operation
+orx291 or 000090000 100001000 -> NaN Invalid_operation
+orx292 or 100000010 000020100 -> NaN Invalid_operation
+orx293 or 100100000 000070010 -> NaN Invalid_operation
+orx294 or 100010100 000080001 -> NaN Invalid_operation
+orx295 or 100001000 000090000 -> NaN Invalid_operation
+-- signs
+orx296 or -100001000 -000000000 -> NaN Invalid_operation
+orx297 or -100001000 000010000 -> NaN Invalid_operation
+orx298 or 100001000 -000000000 -> NaN Invalid_operation
+orx299 or 100001000 000011000 -> 100011000
+
+-- Nmax, Nmin, Ntiny
+orx331 or 2 9.99999999E+999 -> NaN Invalid_operation
+orx332 or 3 1E-999 -> NaN Invalid_operation
+orx333 or 4 1.00000000E-999 -> NaN Invalid_operation
+orx334 or 5 1E-1007 -> NaN Invalid_operation
+orx335 or 6 -1E-1007 -> NaN Invalid_operation
+orx336 or 7 -1.00000000E-999 -> NaN Invalid_operation
+orx337 or 8 -1E-999 -> NaN Invalid_operation
+orx338 or 9 -9.99999999E+999 -> NaN Invalid_operation
+orx341 or 9.99999999E+999 -18 -> NaN Invalid_operation
+orx342 or 1E-999 01 -> NaN Invalid_operation
+orx343 or 1.00000000E-999 -18 -> NaN Invalid_operation
+orx344 or 1E-1007 18 -> NaN Invalid_operation
+orx345 or -1E-1007 -10 -> NaN Invalid_operation
+orx346 or -1.00000000E-999 18 -> NaN Invalid_operation
+orx347 or -1E-999 10 -> NaN Invalid_operation
+orx348 or -9.99999999E+999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+orx361 or 1.0 1 -> NaN Invalid_operation
+orx362 or 1E+1 1 -> NaN Invalid_operation
+orx363 or 0.0 1 -> NaN Invalid_operation
+orx364 or 0E+1 1 -> NaN Invalid_operation
+orx365 or 9.9 1 -> NaN Invalid_operation
+orx366 or 9E+1 1 -> NaN Invalid_operation
+orx371 or 0 1.0 -> NaN Invalid_operation
+orx372 or 0 1E+1 -> NaN Invalid_operation
+orx373 or 0 0.0 -> NaN Invalid_operation
+orx374 or 0 0E+1 -> NaN Invalid_operation
+orx375 or 0 9.9 -> NaN Invalid_operation
+orx376 or 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+orx780 or -Inf -Inf -> NaN Invalid_operation
+orx781 or -Inf -1000 -> NaN Invalid_operation
+orx782 or -Inf -1 -> NaN Invalid_operation
+orx783 or -Inf -0 -> NaN Invalid_operation
+orx784 or -Inf 0 -> NaN Invalid_operation
+orx785 or -Inf 1 -> NaN Invalid_operation
+orx786 or -Inf 1000 -> NaN Invalid_operation
+orx787 or -1000 -Inf -> NaN Invalid_operation
+orx788 or -Inf -Inf -> NaN Invalid_operation
+orx789 or -1 -Inf -> NaN Invalid_operation
+orx790 or -0 -Inf -> NaN Invalid_operation
+orx791 or 0 -Inf -> NaN Invalid_operation
+orx792 or 1 -Inf -> NaN Invalid_operation
+orx793 or 1000 -Inf -> NaN Invalid_operation
+orx794 or Inf -Inf -> NaN Invalid_operation
+
+orx800 or Inf -Inf -> NaN Invalid_operation
+orx801 or Inf -1000 -> NaN Invalid_operation
+orx802 or Inf -1 -> NaN Invalid_operation
+orx803 or Inf -0 -> NaN Invalid_operation
+orx804 or Inf 0 -> NaN Invalid_operation
+orx805 or Inf 1 -> NaN Invalid_operation
+orx806 or Inf 1000 -> NaN Invalid_operation
+orx807 or Inf Inf -> NaN Invalid_operation
+orx808 or -1000 Inf -> NaN Invalid_operation
+orx809 or -Inf Inf -> NaN Invalid_operation
+orx810 or -1 Inf -> NaN Invalid_operation
+orx811 or -0 Inf -> NaN Invalid_operation
+orx812 or 0 Inf -> NaN Invalid_operation
+orx813 or 1 Inf -> NaN Invalid_operation
+orx814 or 1000 Inf -> NaN Invalid_operation
+orx815 or Inf Inf -> NaN Invalid_operation
+
+orx821 or NaN -Inf -> NaN Invalid_operation
+orx822 or NaN -1000 -> NaN Invalid_operation
+orx823 or NaN -1 -> NaN Invalid_operation
+orx824 or NaN -0 -> NaN Invalid_operation
+orx825 or NaN 0 -> NaN Invalid_operation
+orx826 or NaN 1 -> NaN Invalid_operation
+orx827 or NaN 1000 -> NaN Invalid_operation
+orx828 or NaN Inf -> NaN Invalid_operation
+orx829 or NaN NaN -> NaN Invalid_operation
+orx830 or -Inf NaN -> NaN Invalid_operation
+orx831 or -1000 NaN -> NaN Invalid_operation
+orx832 or -1 NaN -> NaN Invalid_operation
+orx833 or -0 NaN -> NaN Invalid_operation
+orx834 or 0 NaN -> NaN Invalid_operation
+orx835 or 1 NaN -> NaN Invalid_operation
+orx836 or 1000 NaN -> NaN Invalid_operation
+orx837 or Inf NaN -> NaN Invalid_operation
+
+orx841 or sNaN -Inf -> NaN Invalid_operation
+orx842 or sNaN -1000 -> NaN Invalid_operation
+orx843 or sNaN -1 -> NaN Invalid_operation
+orx844 or sNaN -0 -> NaN Invalid_operation
+orx845 or sNaN 0 -> NaN Invalid_operation
+orx846 or sNaN 1 -> NaN Invalid_operation
+orx847 or sNaN 1000 -> NaN Invalid_operation
+orx848 or sNaN NaN -> NaN Invalid_operation
+orx849 or sNaN sNaN -> NaN Invalid_operation
+orx850 or NaN sNaN -> NaN Invalid_operation
+orx851 or -Inf sNaN -> NaN Invalid_operation
+orx852 or -1000 sNaN -> NaN Invalid_operation
+orx853 or -1 sNaN -> NaN Invalid_operation
+orx854 or -0 sNaN -> NaN Invalid_operation
+orx855 or 0 sNaN -> NaN Invalid_operation
+orx856 or 1 sNaN -> NaN Invalid_operation
+orx857 or 1000 sNaN -> NaN Invalid_operation
+orx858 or Inf sNaN -> NaN Invalid_operation
+orx859 or NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+orx861 or NaN1 -Inf -> NaN Invalid_operation
+orx862 or +NaN2 -1000 -> NaN Invalid_operation
+orx863 or NaN3 1000 -> NaN Invalid_operation
+orx864 or NaN4 Inf -> NaN Invalid_operation
+orx865 or NaN5 +NaN6 -> NaN Invalid_operation
+orx866 or -Inf NaN7 -> NaN Invalid_operation
+orx867 or -1000 NaN8 -> NaN Invalid_operation
+orx868 or 1000 NaN9 -> NaN Invalid_operation
+orx869 or Inf +NaN10 -> NaN Invalid_operation
+orx871 or sNaN11 -Inf -> NaN Invalid_operation
+orx872 or sNaN12 -1000 -> NaN Invalid_operation
+orx873 or sNaN13 1000 -> NaN Invalid_operation
+orx874 or sNaN14 NaN17 -> NaN Invalid_operation
+orx875 or sNaN15 sNaN18 -> NaN Invalid_operation
+orx876 or NaN16 sNaN19 -> NaN Invalid_operation
+orx877 or -Inf +sNaN20 -> NaN Invalid_operation
+orx878 or -1000 sNaN21 -> NaN Invalid_operation
+orx879 or 1000 sNaN22 -> NaN Invalid_operation
+orx880 or Inf sNaN23 -> NaN Invalid_operation
+orx881 or +NaN25 +sNaN24 -> NaN Invalid_operation
+orx882 or -NaN26 NaN28 -> NaN Invalid_operation
+orx883 or -sNaN27 sNaN29 -> NaN Invalid_operation
+orx884 or 1000 -NaN30 -> NaN Invalid_operation
+orx885 or 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/powersqrt.decTest b/Lib/test/decimaltestdata/powersqrt.decTest
index 260b941537..6c021a0cbb 100644
--- a/Lib/test/decimaltestdata/powersqrt.decTest
+++ b/Lib/test/decimaltestdata/powersqrt.decTest
@@ -1,2970 +1,2970 @@
-------------------------------------------------------------------------
--- powersqrt.decTest -- decimal square root, using power --
--- Copyright (c) IBM Corporation, 2004, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- These testcases are taken from squareroot.decTest but are
--- evaluated using the power operator. The differences in results
--- (153 out of 2856) fall into the following categories:
---
--- x ** 0.5 (x>0) has no preferred exponent, and is Inexact
--- (and hence full precision); almost all differences are
--- in this category
--- 0.00 ** 0.5 becomes 0 (not 0.0), etc.
--- -0 ** 0.5 becomes 0 (never -0)
--- Some exact subnormals become inexact and hence underflows
-
-extended: 1
-precision: 9
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- basics
-pwsx001 power 1 0.5 -> 1.00000000 Inexact Rounded
-pwsx002 power -1 0.5 -> NaN Invalid_operation
-pwsx003 power 1.00 0.5 -> 1.00000000 Inexact Rounded
-pwsx004 power -1.00 0.5 -> NaN Invalid_operation
-pwsx005 power 0 0.5 -> 0
-pwsx006 power 00.0 0.5 -> 0
-pwsx007 power 0.00 0.5 -> 0
-pwsx008 power 00.00 0.5 -> 0
-pwsx009 power 00.000 0.5 -> 0
-pwsx010 power 00.0000 0.5 -> 0
-pwsx011 power 00 0.5 -> 0
-
-pwsx012 power -2 0.5 -> NaN Invalid_operation
-pwsx013 power 2 0.5 -> 1.41421356 Inexact Rounded
-pwsx014 power -2.00 0.5 -> NaN Invalid_operation
-pwsx015 power 2.00 0.5 -> 1.41421356 Inexact Rounded
-pwsx016 power -0 0.5 -> 0
-pwsx017 power -0.0 0.5 -> 0
-pwsx018 power -00.00 0.5 -> 0
-pwsx019 power -00.000 0.5 -> 0
-pwsx020 power -0.0000 0.5 -> 0
-pwsx021 power -0E+9 0.5 -> 0
-pwsx022 power -0E+10 0.5 -> 0
-pwsx023 power -0E+11 0.5 -> 0
-pwsx024 power -0E+12 0.5 -> 0
-pwsx025 power -00 0.5 -> 0
-pwsx026 power 0E+5 0.5 -> 0
-pwsx027 power 4.0 0.5 -> 2.00000000 Inexact Rounded
-pwsx028 power 4.00 0.5 -> 2.00000000 Inexact Rounded
-
-pwsx030 power +0.1 0.5 -> 0.316227766 Inexact Rounded
-pwsx031 power -0.1 0.5 -> NaN Invalid_operation
-pwsx032 power +0.01 0.5 -> 0.100000000 Inexact Rounded
-pwsx033 power -0.01 0.5 -> NaN Invalid_operation
-pwsx034 power +0.001 0.5 -> 0.0316227766 Inexact Rounded
-pwsx035 power -0.001 0.5 -> NaN Invalid_operation
-pwsx036 power +0.000001 0.5 -> 0.00100000000 Inexact Rounded
-pwsx037 power -0.000001 0.5 -> NaN Invalid_operation
-pwsx038 power +0.000000000001 0.5 -> 0.00000100000000 Inexact Rounded
-pwsx039 power -0.000000000001 0.5 -> NaN Invalid_operation
-
-pwsx041 power 1.1 0.5 -> 1.04880885 Inexact Rounded
-pwsx042 power 1.10 0.5 -> 1.04880885 Inexact Rounded
-pwsx043 power 1.100 0.5 -> 1.04880885 Inexact Rounded
-pwsx044 power 1.110 0.5 -> 1.05356538 Inexact Rounded
-pwsx045 power -1.1 0.5 -> NaN Invalid_operation
-pwsx046 power -1.10 0.5 -> NaN Invalid_operation
-pwsx047 power -1.100 0.5 -> NaN Invalid_operation
-pwsx048 power -1.110 0.5 -> NaN Invalid_operation
-pwsx049 power 9.9 0.5 -> 3.14642654 Inexact Rounded
-pwsx050 power 9.90 0.5 -> 3.14642654 Inexact Rounded
-pwsx051 power 9.900 0.5 -> 3.14642654 Inexact Rounded
-pwsx052 power 9.990 0.5 -> 3.16069613 Inexact Rounded
-pwsx053 power -9.9 0.5 -> NaN Invalid_operation
-pwsx054 power -9.90 0.5 -> NaN Invalid_operation
-pwsx055 power -9.900 0.5 -> NaN Invalid_operation
-pwsx056 power -9.990 0.5 -> NaN Invalid_operation
-
-pwsx060 power 1 0.5 -> 1.00000000 Inexact Rounded
-pwsx061 power 1.0 0.5 -> 1.00000000 Inexact Rounded
-pwsx062 power 1.00 0.5 -> 1.00000000 Inexact Rounded
-pwsx063 power 10.0 0.5 -> 3.16227766 Inexact Rounded
-pwsx064 power 10.0 0.5 -> 3.16227766 Inexact Rounded
-pwsx065 power 10.0 0.5 -> 3.16227766 Inexact Rounded
-pwsx066 power 10.00 0.5 -> 3.16227766 Inexact Rounded
-pwsx067 power 100 0.5 -> 10.0000000 Inexact Rounded
-pwsx068 power 100.0 0.5 -> 10.0000000 Inexact Rounded
-pwsx069 power 100.00 0.5 -> 10.0000000 Inexact Rounded
-pwsx070 power 1.1000E+3 0.5 -> 33.1662479 Inexact Rounded
-pwsx071 power 1.10000E+3 0.5 -> 33.1662479 Inexact Rounded
-pwsx072 power -10.0 0.5 -> NaN Invalid_operation
-pwsx073 power -10.00 0.5 -> NaN Invalid_operation
-pwsx074 power -100.0 0.5 -> NaN Invalid_operation
-pwsx075 power -100.00 0.5 -> NaN Invalid_operation
-pwsx076 power -1.1000E+3 0.5 -> NaN Invalid_operation
-pwsx077 power -1.10000E+3 0.5 -> NaN Invalid_operation
-
--- famous squares
-pwsx080 power 1 0.5 -> 1.00000000 Inexact Rounded
-pwsx081 power 4 0.5 -> 2.00000000 Inexact Rounded
-pwsx082 power 9 0.5 -> 3.00000000 Inexact Rounded
-pwsx083 power 16 0.5 -> 4.00000000 Inexact Rounded
-pwsx084 power 25 0.5 -> 5.00000000 Inexact Rounded
-pwsx085 power 36 0.5 -> 6.00000000 Inexact Rounded
-pwsx086 power 49 0.5 -> 7.00000000 Inexact Rounded
-pwsx087 power 64 0.5 -> 8.00000000 Inexact Rounded
-pwsx088 power 81 0.5 -> 9.00000000 Inexact Rounded
-pwsx089 power 100 0.5 -> 10.0000000 Inexact Rounded
-pwsx090 power 121 0.5 -> 11.0000000 Inexact Rounded
-pwsx091 power 144 0.5 -> 12.0000000 Inexact Rounded
-pwsx092 power 169 0.5 -> 13.0000000 Inexact Rounded
-pwsx093 power 256 0.5 -> 16.0000000 Inexact Rounded
-pwsx094 power 1024 0.5 -> 32.0000000 Inexact Rounded
-pwsx095 power 4096 0.5 -> 64.0000000 Inexact Rounded
-pwsx100 power 0.01 0.5 -> 0.100000000 Inexact Rounded
-pwsx101 power 0.04 0.5 -> 0.200000000 Inexact Rounded
-pwsx102 power 0.09 0.5 -> 0.300000000 Inexact Rounded
-pwsx103 power 0.16 0.5 -> 0.400000000 Inexact Rounded
-pwsx104 power 0.25 0.5 -> 0.500000000 Inexact Rounded
-pwsx105 power 0.36 0.5 -> 0.600000000 Inexact Rounded
-pwsx106 power 0.49 0.5 -> 0.700000000 Inexact Rounded
-pwsx107 power 0.64 0.5 -> 0.800000000 Inexact Rounded
-pwsx108 power 0.81 0.5 -> 0.900000000 Inexact Rounded
-pwsx109 power 1.00 0.5 -> 1.00000000 Inexact Rounded
-pwsx110 power 1.21 0.5 -> 1.10000000 Inexact Rounded
-pwsx111 power 1.44 0.5 -> 1.20000000 Inexact Rounded
-pwsx112 power 1.69 0.5 -> 1.30000000 Inexact Rounded
-pwsx113 power 2.56 0.5 -> 1.60000000 Inexact Rounded
-pwsx114 power 10.24 0.5 -> 3.20000000 Inexact Rounded
-pwsx115 power 40.96 0.5 -> 6.40000000 Inexact Rounded
-
--- Precision 1 squareroot tests [exhaustive, plus exponent adjusts]
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-precision: 1
-pwsx1201 power 0.1 0.5 -> 0.3 Inexact Rounded
-pwsx1202 power 0.01 0.5 -> 0.1 Inexact Rounded
-pwsx1203 power 1.0E-1 0.5 -> 0.3 Inexact Rounded
-pwsx1204 power 1.00E-2 0.5 -> 0.1 Inexact Rounded
-pwsx1205 power 1E-3 0.5 -> 0.03 Inexact Rounded
-pwsx1206 power 1E+1 0.5 -> 3 Inexact Rounded
-pwsx1207 power 1E+2 0.5 -> 1E+1 Inexact Rounded
-pwsx1208 power 1E+3 0.5 -> 3E+1 Inexact Rounded
-pwsx1209 power 0.2 0.5 -> 0.4 Inexact Rounded
-pwsx1210 power 0.02 0.5 -> 0.1 Inexact Rounded
-pwsx1211 power 2.0E-1 0.5 -> 0.4 Inexact Rounded
-pwsx1212 power 2.00E-2 0.5 -> 0.1 Inexact Rounded
-pwsx1213 power 2E-3 0.5 -> 0.04 Inexact Rounded
-pwsx1214 power 2E+1 0.5 -> 4 Inexact Rounded
-pwsx1215 power 2E+2 0.5 -> 1E+1 Inexact Rounded
-pwsx1216 power 2E+3 0.5 -> 4E+1 Inexact Rounded
-pwsx1217 power 0.3 0.5 -> 0.5 Inexact Rounded
-pwsx1218 power 0.03 0.5 -> 0.2 Inexact Rounded
-pwsx1219 power 3.0E-1 0.5 -> 0.5 Inexact Rounded
-pwsx1220 power 3.00E-2 0.5 -> 0.2 Inexact Rounded
-pwsx1221 power 3E-3 0.5 -> 0.05 Inexact Rounded
-pwsx1222 power 3E+1 0.5 -> 5 Inexact Rounded
-pwsx1223 power 3E+2 0.5 -> 2E+1 Inexact Rounded
-pwsx1224 power 3E+3 0.5 -> 5E+1 Inexact Rounded
-pwsx1225 power 0.4 0.5 -> 0.6 Inexact Rounded
-pwsx1226 power 0.04 0.5 -> 0.2 Inexact Rounded
-pwsx1227 power 4.0E-1 0.5 -> 0.6 Inexact Rounded
-pwsx1228 power 4.00E-2 0.5 -> 0.2 Inexact Rounded
-pwsx1229 power 4E-3 0.5 -> 0.06 Inexact Rounded
-pwsx1230 power 4E+1 0.5 -> 6 Inexact Rounded
-pwsx1231 power 4E+2 0.5 -> 2E+1 Inexact Rounded
-pwsx1232 power 4E+3 0.5 -> 6E+1 Inexact Rounded
-pwsx1233 power 0.5 0.5 -> 0.7 Inexact Rounded
-pwsx1234 power 0.05 0.5 -> 0.2 Inexact Rounded
-pwsx1235 power 5.0E-1 0.5 -> 0.7 Inexact Rounded
-pwsx1236 power 5.00E-2 0.5 -> 0.2 Inexact Rounded
-pwsx1237 power 5E-3 0.5 -> 0.07 Inexact Rounded
-pwsx1238 power 5E+1 0.5 -> 7 Inexact Rounded
-pwsx1239 power 5E+2 0.5 -> 2E+1 Inexact Rounded
-pwsx1240 power 5E+3 0.5 -> 7E+1 Inexact Rounded
-pwsx1241 power 0.6 0.5 -> 0.8 Inexact Rounded
-pwsx1242 power 0.06 0.5 -> 0.2 Inexact Rounded
-pwsx1243 power 6.0E-1 0.5 -> 0.8 Inexact Rounded
-pwsx1244 power 6.00E-2 0.5 -> 0.2 Inexact Rounded
-pwsx1245 power 6E-3 0.5 -> 0.08 Inexact Rounded
-pwsx1246 power 6E+1 0.5 -> 8 Inexact Rounded
-pwsx1247 power 6E+2 0.5 -> 2E+1 Inexact Rounded
-pwsx1248 power 6E+3 0.5 -> 8E+1 Inexact Rounded
-pwsx1249 power 0.7 0.5 -> 0.8 Inexact Rounded
-pwsx1250 power 0.07 0.5 -> 0.3 Inexact Rounded
-pwsx1251 power 7.0E-1 0.5 -> 0.8 Inexact Rounded
-pwsx1252 power 7.00E-2 0.5 -> 0.3 Inexact Rounded
-pwsx1253 power 7E-3 0.5 -> 0.08 Inexact Rounded
-pwsx1254 power 7E+1 0.5 -> 8 Inexact Rounded
-pwsx1255 power 7E+2 0.5 -> 3E+1 Inexact Rounded
-pwsx1256 power 7E+3 0.5 -> 8E+1 Inexact Rounded
-pwsx1257 power 0.8 0.5 -> 0.9 Inexact Rounded
-pwsx1258 power 0.08 0.5 -> 0.3 Inexact Rounded
-pwsx1259 power 8.0E-1 0.5 -> 0.9 Inexact Rounded
-pwsx1260 power 8.00E-2 0.5 -> 0.3 Inexact Rounded
-pwsx1261 power 8E-3 0.5 -> 0.09 Inexact Rounded
-pwsx1262 power 8E+1 0.5 -> 9 Inexact Rounded
-pwsx1263 power 8E+2 0.5 -> 3E+1 Inexact Rounded
-pwsx1264 power 8E+3 0.5 -> 9E+1 Inexact Rounded
-pwsx1265 power 0.9 0.5 -> 0.9 Inexact Rounded
-pwsx1266 power 0.09 0.5 -> 0.3 Inexact Rounded
-pwsx1267 power 9.0E-1 0.5 -> 0.9 Inexact Rounded
-pwsx1268 power 9.00E-2 0.5 -> 0.3 Inexact Rounded
-pwsx1269 power 9E-3 0.5 -> 0.09 Inexact Rounded
-pwsx1270 power 9E+1 0.5 -> 9 Inexact Rounded
-pwsx1271 power 9E+2 0.5 -> 3E+1 Inexact Rounded
-pwsx1272 power 9E+3 0.5 -> 9E+1 Inexact Rounded
-
--- Precision 2 squareroot tests [exhaustive, plus exponent adjusts]
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-precision: 2
-pwsx2201 power 0.1 0.5 -> 0.32 Inexact Rounded
-pwsx2202 power 0.01 0.5 -> 0.10 Inexact Rounded
-pwsx2203 power 1.0E-1 0.5 -> 0.32 Inexact Rounded
-pwsx2204 power 1.00E-2 0.5 -> 0.10 Inexact Rounded
-pwsx2205 power 1E-3 0.5 -> 0.032 Inexact Rounded
-pwsx2206 power 1E+1 0.5 -> 3.2 Inexact Rounded
-pwsx2207 power 1E+2 0.5 -> 10 Inexact Rounded
-pwsx2208 power 1E+3 0.5 -> 32 Inexact Rounded
-pwsx2209 power 0.2 0.5 -> 0.45 Inexact Rounded
-pwsx2210 power 0.02 0.5 -> 0.14 Inexact Rounded
-pwsx2211 power 2.0E-1 0.5 -> 0.45 Inexact Rounded
-pwsx2212 power 2.00E-2 0.5 -> 0.14 Inexact Rounded
-pwsx2213 power 2E-3 0.5 -> 0.045 Inexact Rounded
-pwsx2214 power 2E+1 0.5 -> 4.5 Inexact Rounded
-pwsx2215 power 2E+2 0.5 -> 14 Inexact Rounded
-pwsx2216 power 2E+3 0.5 -> 45 Inexact Rounded
-pwsx2217 power 0.3 0.5 -> 0.55 Inexact Rounded
-pwsx2218 power 0.03 0.5 -> 0.17 Inexact Rounded
-pwsx2219 power 3.0E-1 0.5 -> 0.55 Inexact Rounded
-pwsx2220 power 3.00E-2 0.5 -> 0.17 Inexact Rounded
-pwsx2221 power 3E-3 0.5 -> 0.055 Inexact Rounded
-pwsx2222 power 3E+1 0.5 -> 5.5 Inexact Rounded
-pwsx2223 power 3E+2 0.5 -> 17 Inexact Rounded
-pwsx2224 power 3E+3 0.5 -> 55 Inexact Rounded
-pwsx2225 power 0.4 0.5 -> 0.63 Inexact Rounded
-pwsx2226 power 0.04 0.5 -> 0.20 Inexact Rounded
-pwsx2227 power 4.0E-1 0.5 -> 0.63 Inexact Rounded
-pwsx2228 power 4.00E-2 0.5 -> 0.20 Inexact Rounded
-pwsx2229 power 4E-3 0.5 -> 0.063 Inexact Rounded
-pwsx2230 power 4E+1 0.5 -> 6.3 Inexact Rounded
-pwsx2231 power 4E+2 0.5 -> 20 Inexact Rounded
-pwsx2232 power 4E+3 0.5 -> 63 Inexact Rounded
-pwsx2233 power 0.5 0.5 -> 0.71 Inexact Rounded
-pwsx2234 power 0.05 0.5 -> 0.22 Inexact Rounded
-pwsx2235 power 5.0E-1 0.5 -> 0.71 Inexact Rounded
-pwsx2236 power 5.00E-2 0.5 -> 0.22 Inexact Rounded
-pwsx2237 power 5E-3 0.5 -> 0.071 Inexact Rounded
-pwsx2238 power 5E+1 0.5 -> 7.1 Inexact Rounded
-pwsx2239 power 5E+2 0.5 -> 22 Inexact Rounded
-pwsx2240 power 5E+3 0.5 -> 71 Inexact Rounded
-pwsx2241 power 0.6 0.5 -> 0.77 Inexact Rounded
-pwsx2242 power 0.06 0.5 -> 0.24 Inexact Rounded
-pwsx2243 power 6.0E-1 0.5 -> 0.77 Inexact Rounded
-pwsx2244 power 6.00E-2 0.5 -> 0.24 Inexact Rounded
-pwsx2245 power 6E-3 0.5 -> 0.077 Inexact Rounded
-pwsx2246 power 6E+1 0.5 -> 7.7 Inexact Rounded
-pwsx2247 power 6E+2 0.5 -> 24 Inexact Rounded
-pwsx2248 power 6E+3 0.5 -> 77 Inexact Rounded
-pwsx2249 power 0.7 0.5 -> 0.84 Inexact Rounded
-pwsx2250 power 0.07 0.5 -> 0.26 Inexact Rounded
-pwsx2251 power 7.0E-1 0.5 -> 0.84 Inexact Rounded
-pwsx2252 power 7.00E-2 0.5 -> 0.26 Inexact Rounded
-pwsx2253 power 7E-3 0.5 -> 0.084 Inexact Rounded
-pwsx2254 power 7E+1 0.5 -> 8.4 Inexact Rounded
-pwsx2255 power 7E+2 0.5 -> 26 Inexact Rounded
-pwsx2256 power 7E+3 0.5 -> 84 Inexact Rounded
-pwsx2257 power 0.8 0.5 -> 0.89 Inexact Rounded
-pwsx2258 power 0.08 0.5 -> 0.28 Inexact Rounded
-pwsx2259 power 8.0E-1 0.5 -> 0.89 Inexact Rounded
-pwsx2260 power 8.00E-2 0.5 -> 0.28 Inexact Rounded
-pwsx2261 power 8E-3 0.5 -> 0.089 Inexact Rounded
-pwsx2262 power 8E+1 0.5 -> 8.9 Inexact Rounded
-pwsx2263 power 8E+2 0.5 -> 28 Inexact Rounded
-pwsx2264 power 8E+3 0.5 -> 89 Inexact Rounded
-pwsx2265 power 0.9 0.5 -> 0.95 Inexact Rounded
-pwsx2266 power 0.09 0.5 -> 0.30 Inexact Rounded
-pwsx2267 power 9.0E-1 0.5 -> 0.95 Inexact Rounded
-pwsx2268 power 9.00E-2 0.5 -> 0.30 Inexact Rounded
-pwsx2269 power 9E-3 0.5 -> 0.095 Inexact Rounded
-pwsx2270 power 9E+1 0.5 -> 9.5 Inexact Rounded
-pwsx2271 power 9E+2 0.5 -> 30 Inexact Rounded
-pwsx2272 power 9E+3 0.5 -> 95 Inexact Rounded
-pwsx2273 power 0.10 0.5 -> 0.32 Inexact Rounded
-pwsx2274 power 0.010 0.5 -> 0.10 Inexact Rounded
-pwsx2275 power 10.0E-1 0.5 -> 1.0 Inexact Rounded
-pwsx2276 power 10.00E-2 0.5 -> 0.32 Inexact Rounded
-pwsx2277 power 10E-3 0.5 -> 0.10 Inexact Rounded
-pwsx2278 power 10E+1 0.5 -> 10 Inexact Rounded
-pwsx2279 power 10E+2 0.5 -> 32 Inexact Rounded
-pwsx2280 power 10E+3 0.5 -> 1.0E+2 Inexact Rounded
-pwsx2281 power 0.11 0.5 -> 0.33 Inexact Rounded
-pwsx2282 power 0.011 0.5 -> 0.10 Inexact Rounded
-pwsx2283 power 11.0E-1 0.5 -> 1.0 Inexact Rounded
-pwsx2284 power 11.00E-2 0.5 -> 0.33 Inexact Rounded
-pwsx2285 power 11E-3 0.5 -> 0.10 Inexact Rounded
-pwsx2286 power 11E+1 0.5 -> 10 Inexact Rounded
-pwsx2287 power 11E+2 0.5 -> 33 Inexact Rounded
-pwsx2288 power 11E+3 0.5 -> 1.0E+2 Inexact Rounded
-pwsx2289 power 0.12 0.5 -> 0.35 Inexact Rounded
-pwsx2290 power 0.012 0.5 -> 0.11 Inexact Rounded
-pwsx2291 power 12.0E-1 0.5 -> 1.1 Inexact Rounded
-pwsx2292 power 12.00E-2 0.5 -> 0.35 Inexact Rounded
-pwsx2293 power 12E-3 0.5 -> 0.11 Inexact Rounded
-pwsx2294 power 12E+1 0.5 -> 11 Inexact Rounded
-pwsx2295 power 12E+2 0.5 -> 35 Inexact Rounded
-pwsx2296 power 12E+3 0.5 -> 1.1E+2 Inexact Rounded
-pwsx2297 power 0.13 0.5 -> 0.36 Inexact Rounded
-pwsx2298 power 0.013 0.5 -> 0.11 Inexact Rounded
-pwsx2299 power 13.0E-1 0.5 -> 1.1 Inexact Rounded
-pwsx2300 power 13.00E-2 0.5 -> 0.36 Inexact Rounded
-pwsx2301 power 13E-3 0.5 -> 0.11 Inexact Rounded
-pwsx2302 power 13E+1 0.5 -> 11 Inexact Rounded
-pwsx2303 power 13E+2 0.5 -> 36 Inexact Rounded
-pwsx2304 power 13E+3 0.5 -> 1.1E+2 Inexact Rounded
-pwsx2305 power 0.14 0.5 -> 0.37 Inexact Rounded
-pwsx2306 power 0.014 0.5 -> 0.12 Inexact Rounded
-pwsx2307 power 14.0E-1 0.5 -> 1.2 Inexact Rounded
-pwsx2308 power 14.00E-2 0.5 -> 0.37 Inexact Rounded
-pwsx2309 power 14E-3 0.5 -> 0.12 Inexact Rounded
-pwsx2310 power 14E+1 0.5 -> 12 Inexact Rounded
-pwsx2311 power 14E+2 0.5 -> 37 Inexact Rounded
-pwsx2312 power 14E+3 0.5 -> 1.2E+2 Inexact Rounded
-pwsx2313 power 0.15 0.5 -> 0.39 Inexact Rounded
-pwsx2314 power 0.015 0.5 -> 0.12 Inexact Rounded
-pwsx2315 power 15.0E-1 0.5 -> 1.2 Inexact Rounded
-pwsx2316 power 15.00E-2 0.5 -> 0.39 Inexact Rounded
-pwsx2317 power 15E-3 0.5 -> 0.12 Inexact Rounded
-pwsx2318 power 15E+1 0.5 -> 12 Inexact Rounded
-pwsx2319 power 15E+2 0.5 -> 39 Inexact Rounded
-pwsx2320 power 15E+3 0.5 -> 1.2E+2 Inexact Rounded
-pwsx2321 power 0.16 0.5 -> 0.40 Inexact Rounded
-pwsx2322 power 0.016 0.5 -> 0.13 Inexact Rounded
-pwsx2323 power 16.0E-1 0.5 -> 1.3 Inexact Rounded
-pwsx2324 power 16.00E-2 0.5 -> 0.40 Inexact Rounded
-pwsx2325 power 16E-3 0.5 -> 0.13 Inexact Rounded
-pwsx2326 power 16E+1 0.5 -> 13 Inexact Rounded
-pwsx2327 power 16E+2 0.5 -> 40 Inexact Rounded
-pwsx2328 power 16E+3 0.5 -> 1.3E+2 Inexact Rounded
-pwsx2329 power 0.17 0.5 -> 0.41 Inexact Rounded
-pwsx2330 power 0.017 0.5 -> 0.13 Inexact Rounded
-pwsx2331 power 17.0E-1 0.5 -> 1.3 Inexact Rounded
-pwsx2332 power 17.00E-2 0.5 -> 0.41 Inexact Rounded
-pwsx2333 power 17E-3 0.5 -> 0.13 Inexact Rounded
-pwsx2334 power 17E+1 0.5 -> 13 Inexact Rounded
-pwsx2335 power 17E+2 0.5 -> 41 Inexact Rounded
-pwsx2336 power 17E+3 0.5 -> 1.3E+2 Inexact Rounded
-pwsx2337 power 0.18 0.5 -> 0.42 Inexact Rounded
-pwsx2338 power 0.018 0.5 -> 0.13 Inexact Rounded
-pwsx2339 power 18.0E-1 0.5 -> 1.3 Inexact Rounded
-pwsx2340 power 18.00E-2 0.5 -> 0.42 Inexact Rounded
-pwsx2341 power 18E-3 0.5 -> 0.13 Inexact Rounded
-pwsx2342 power 18E+1 0.5 -> 13 Inexact Rounded
-pwsx2343 power 18E+2 0.5 -> 42 Inexact Rounded
-pwsx2344 power 18E+3 0.5 -> 1.3E+2 Inexact Rounded
-pwsx2345 power 0.19 0.5 -> 0.44 Inexact Rounded
-pwsx2346 power 0.019 0.5 -> 0.14 Inexact Rounded
-pwsx2347 power 19.0E-1 0.5 -> 1.4 Inexact Rounded
-pwsx2348 power 19.00E-2 0.5 -> 0.44 Inexact Rounded
-pwsx2349 power 19E-3 0.5 -> 0.14 Inexact Rounded
-pwsx2350 power 19E+1 0.5 -> 14 Inexact Rounded
-pwsx2351 power 19E+2 0.5 -> 44 Inexact Rounded
-pwsx2352 power 19E+3 0.5 -> 1.4E+2 Inexact Rounded
-pwsx2353 power 0.20 0.5 -> 0.45 Inexact Rounded
-pwsx2354 power 0.020 0.5 -> 0.14 Inexact Rounded
-pwsx2355 power 20.0E-1 0.5 -> 1.4 Inexact Rounded
-pwsx2356 power 20.00E-2 0.5 -> 0.45 Inexact Rounded
-pwsx2357 power 20E-3 0.5 -> 0.14 Inexact Rounded
-pwsx2358 power 20E+1 0.5 -> 14 Inexact Rounded
-pwsx2359 power 20E+2 0.5 -> 45 Inexact Rounded
-pwsx2360 power 20E+3 0.5 -> 1.4E+2 Inexact Rounded
-pwsx2361 power 0.21 0.5 -> 0.46 Inexact Rounded
-pwsx2362 power 0.021 0.5 -> 0.14 Inexact Rounded
-pwsx2363 power 21.0E-1 0.5 -> 1.4 Inexact Rounded
-pwsx2364 power 21.00E-2 0.5 -> 0.46 Inexact Rounded
-pwsx2365 power 21E-3 0.5 -> 0.14 Inexact Rounded
-pwsx2366 power 21E+1 0.5 -> 14 Inexact Rounded
-pwsx2367 power 21E+2 0.5 -> 46 Inexact Rounded
-pwsx2368 power 21E+3 0.5 -> 1.4E+2 Inexact Rounded
-pwsx2369 power 0.22 0.5 -> 0.47 Inexact Rounded
-pwsx2370 power 0.022 0.5 -> 0.15 Inexact Rounded
-pwsx2371 power 22.0E-1 0.5 -> 1.5 Inexact Rounded
-pwsx2372 power 22.00E-2 0.5 -> 0.47 Inexact Rounded
-pwsx2373 power 22E-3 0.5 -> 0.15 Inexact Rounded
-pwsx2374 power 22E+1 0.5 -> 15 Inexact Rounded
-pwsx2375 power 22E+2 0.5 -> 47 Inexact Rounded
-pwsx2376 power 22E+3 0.5 -> 1.5E+2 Inexact Rounded
-pwsx2377 power 0.23 0.5 -> 0.48 Inexact Rounded
-pwsx2378 power 0.023 0.5 -> 0.15 Inexact Rounded
-pwsx2379 power 23.0E-1 0.5 -> 1.5 Inexact Rounded
-pwsx2380 power 23.00E-2 0.5 -> 0.48 Inexact Rounded
-pwsx2381 power 23E-3 0.5 -> 0.15 Inexact Rounded
-pwsx2382 power 23E+1 0.5 -> 15 Inexact Rounded
-pwsx2383 power 23E+2 0.5 -> 48 Inexact Rounded
-pwsx2384 power 23E+3 0.5 -> 1.5E+2 Inexact Rounded
-pwsx2385 power 0.24 0.5 -> 0.49 Inexact Rounded
-pwsx2386 power 0.024 0.5 -> 0.15 Inexact Rounded
-pwsx2387 power 24.0E-1 0.5 -> 1.5 Inexact Rounded
-pwsx2388 power 24.00E-2 0.5 -> 0.49 Inexact Rounded
-pwsx2389 power 24E-3 0.5 -> 0.15 Inexact Rounded
-pwsx2390 power 24E+1 0.5 -> 15 Inexact Rounded
-pwsx2391 power 24E+2 0.5 -> 49 Inexact Rounded
-pwsx2392 power 24E+3 0.5 -> 1.5E+2 Inexact Rounded
-pwsx2393 power 0.25 0.5 -> 0.50 Inexact Rounded
-pwsx2394 power 0.025 0.5 -> 0.16 Inexact Rounded
-pwsx2395 power 25.0E-1 0.5 -> 1.6 Inexact Rounded
-pwsx2396 power 25.00E-2 0.5 -> 0.50 Inexact Rounded
-pwsx2397 power 25E-3 0.5 -> 0.16 Inexact Rounded
-pwsx2398 power 25E+1 0.5 -> 16 Inexact Rounded
-pwsx2399 power 25E+2 0.5 -> 50 Inexact Rounded
-pwsx2400 power 25E+3 0.5 -> 1.6E+2 Inexact Rounded
-pwsx2401 power 0.26 0.5 -> 0.51 Inexact Rounded
-pwsx2402 power 0.026 0.5 -> 0.16 Inexact Rounded
-pwsx2403 power 26.0E-1 0.5 -> 1.6 Inexact Rounded
-pwsx2404 power 26.00E-2 0.5 -> 0.51 Inexact Rounded
-pwsx2405 power 26E-3 0.5 -> 0.16 Inexact Rounded
-pwsx2406 power 26E+1 0.5 -> 16 Inexact Rounded
-pwsx2407 power 26E+2 0.5 -> 51 Inexact Rounded
-pwsx2408 power 26E+3 0.5 -> 1.6E+2 Inexact Rounded
-pwsx2409 power 0.27 0.5 -> 0.52 Inexact Rounded
-pwsx2410 power 0.027 0.5 -> 0.16 Inexact Rounded
-pwsx2411 power 27.0E-1 0.5 -> 1.6 Inexact Rounded
-pwsx2412 power 27.00E-2 0.5 -> 0.52 Inexact Rounded
-pwsx2413 power 27E-3 0.5 -> 0.16 Inexact Rounded
-pwsx2414 power 27E+1 0.5 -> 16 Inexact Rounded
-pwsx2415 power 27E+2 0.5 -> 52 Inexact Rounded
-pwsx2416 power 27E+3 0.5 -> 1.6E+2 Inexact Rounded
-pwsx2417 power 0.28 0.5 -> 0.53 Inexact Rounded
-pwsx2418 power 0.028 0.5 -> 0.17 Inexact Rounded
-pwsx2419 power 28.0E-1 0.5 -> 1.7 Inexact Rounded
-pwsx2420 power 28.00E-2 0.5 -> 0.53 Inexact Rounded
-pwsx2421 power 28E-3 0.5 -> 0.17 Inexact Rounded
-pwsx2422 power 28E+1 0.5 -> 17 Inexact Rounded
-pwsx2423 power 28E+2 0.5 -> 53 Inexact Rounded
-pwsx2424 power 28E+3 0.5 -> 1.7E+2 Inexact Rounded
-pwsx2425 power 0.29 0.5 -> 0.54 Inexact Rounded
-pwsx2426 power 0.029 0.5 -> 0.17 Inexact Rounded
-pwsx2427 power 29.0E-1 0.5 -> 1.7 Inexact Rounded
-pwsx2428 power 29.00E-2 0.5 -> 0.54 Inexact Rounded
-pwsx2429 power 29E-3 0.5 -> 0.17 Inexact Rounded
-pwsx2430 power 29E+1 0.5 -> 17 Inexact Rounded
-pwsx2431 power 29E+2 0.5 -> 54 Inexact Rounded
-pwsx2432 power 29E+3 0.5 -> 1.7E+2 Inexact Rounded
-pwsx2433 power 0.30 0.5 -> 0.55 Inexact Rounded
-pwsx2434 power 0.030 0.5 -> 0.17 Inexact Rounded
-pwsx2435 power 30.0E-1 0.5 -> 1.7 Inexact Rounded
-pwsx2436 power 30.00E-2 0.5 -> 0.55 Inexact Rounded
-pwsx2437 power 30E-3 0.5 -> 0.17 Inexact Rounded
-pwsx2438 power 30E+1 0.5 -> 17 Inexact Rounded
-pwsx2439 power 30E+2 0.5 -> 55 Inexact Rounded
-pwsx2440 power 30E+3 0.5 -> 1.7E+2 Inexact Rounded
-pwsx2441 power 0.31 0.5 -> 0.56 Inexact Rounded
-pwsx2442 power 0.031 0.5 -> 0.18 Inexact Rounded
-pwsx2443 power 31.0E-1 0.5 -> 1.8 Inexact Rounded
-pwsx2444 power 31.00E-2 0.5 -> 0.56 Inexact Rounded
-pwsx2445 power 31E-3 0.5 -> 0.18 Inexact Rounded
-pwsx2446 power 31E+1 0.5 -> 18 Inexact Rounded
-pwsx2447 power 31E+2 0.5 -> 56 Inexact Rounded
-pwsx2448 power 31E+3 0.5 -> 1.8E+2 Inexact Rounded
-pwsx2449 power 0.32 0.5 -> 0.57 Inexact Rounded
-pwsx2450 power 0.032 0.5 -> 0.18 Inexact Rounded
-pwsx2451 power 32.0E-1 0.5 -> 1.8 Inexact Rounded
-pwsx2452 power 32.00E-2 0.5 -> 0.57 Inexact Rounded
-pwsx2453 power 32E-3 0.5 -> 0.18 Inexact Rounded
-pwsx2454 power 32E+1 0.5 -> 18 Inexact Rounded
-pwsx2455 power 32E+2 0.5 -> 57 Inexact Rounded
-pwsx2456 power 32E+3 0.5 -> 1.8E+2 Inexact Rounded
-pwsx2457 power 0.33 0.5 -> 0.57 Inexact Rounded
-pwsx2458 power 0.033 0.5 -> 0.18 Inexact Rounded
-pwsx2459 power 33.0E-1 0.5 -> 1.8 Inexact Rounded
-pwsx2460 power 33.00E-2 0.5 -> 0.57 Inexact Rounded
-pwsx2461 power 33E-3 0.5 -> 0.18 Inexact Rounded
-pwsx2462 power 33E+1 0.5 -> 18 Inexact Rounded
-pwsx2463 power 33E+2 0.5 -> 57 Inexact Rounded
-pwsx2464 power 33E+3 0.5 -> 1.8E+2 Inexact Rounded
-pwsx2465 power 0.34 0.5 -> 0.58 Inexact Rounded
-pwsx2466 power 0.034 0.5 -> 0.18 Inexact Rounded
-pwsx2467 power 34.0E-1 0.5 -> 1.8 Inexact Rounded
-pwsx2468 power 34.00E-2 0.5 -> 0.58 Inexact Rounded
-pwsx2469 power 34E-3 0.5 -> 0.18 Inexact Rounded
-pwsx2470 power 34E+1 0.5 -> 18 Inexact Rounded
-pwsx2471 power 34E+2 0.5 -> 58 Inexact Rounded
-pwsx2472 power 34E+3 0.5 -> 1.8E+2 Inexact Rounded
-pwsx2473 power 0.35 0.5 -> 0.59 Inexact Rounded
-pwsx2474 power 0.035 0.5 -> 0.19 Inexact Rounded
-pwsx2475 power 35.0E-1 0.5 -> 1.9 Inexact Rounded
-pwsx2476 power 35.00E-2 0.5 -> 0.59 Inexact Rounded
-pwsx2477 power 35E-3 0.5 -> 0.19 Inexact Rounded
-pwsx2478 power 35E+1 0.5 -> 19 Inexact Rounded
-pwsx2479 power 35E+2 0.5 -> 59 Inexact Rounded
-pwsx2480 power 35E+3 0.5 -> 1.9E+2 Inexact Rounded
-pwsx2481 power 0.36 0.5 -> 0.60 Inexact Rounded
-pwsx2482 power 0.036 0.5 -> 0.19 Inexact Rounded
-pwsx2483 power 36.0E-1 0.5 -> 1.9 Inexact Rounded
-pwsx2484 power 36.00E-2 0.5 -> 0.60 Inexact Rounded
-pwsx2485 power 36E-3 0.5 -> 0.19 Inexact Rounded
-pwsx2486 power 36E+1 0.5 -> 19 Inexact Rounded
-pwsx2487 power 36E+2 0.5 -> 60 Inexact Rounded
-pwsx2488 power 36E+3 0.5 -> 1.9E+2 Inexact Rounded
-pwsx2489 power 0.37 0.5 -> 0.61 Inexact Rounded
-pwsx2490 power 0.037 0.5 -> 0.19 Inexact Rounded
-pwsx2491 power 37.0E-1 0.5 -> 1.9 Inexact Rounded
-pwsx2492 power 37.00E-2 0.5 -> 0.61 Inexact Rounded
-pwsx2493 power 37E-3 0.5 -> 0.19 Inexact Rounded
-pwsx2494 power 37E+1 0.5 -> 19 Inexact Rounded
-pwsx2495 power 37E+2 0.5 -> 61 Inexact Rounded
-pwsx2496 power 37E+3 0.5 -> 1.9E+2 Inexact Rounded
-pwsx2497 power 0.38 0.5 -> 0.62 Inexact Rounded
-pwsx2498 power 0.038 0.5 -> 0.19 Inexact Rounded
-pwsx2499 power 38.0E-1 0.5 -> 1.9 Inexact Rounded
-pwsx2500 power 38.00E-2 0.5 -> 0.62 Inexact Rounded
-pwsx2501 power 38E-3 0.5 -> 0.19 Inexact Rounded
-pwsx2502 power 38E+1 0.5 -> 19 Inexact Rounded
-pwsx2503 power 38E+2 0.5 -> 62 Inexact Rounded
-pwsx2504 power 38E+3 0.5 -> 1.9E+2 Inexact Rounded
-pwsx2505 power 0.39 0.5 -> 0.62 Inexact Rounded
-pwsx2506 power 0.039 0.5 -> 0.20 Inexact Rounded
-pwsx2507 power 39.0E-1 0.5 -> 2.0 Inexact Rounded
-pwsx2508 power 39.00E-2 0.5 -> 0.62 Inexact Rounded
-pwsx2509 power 39E-3 0.5 -> 0.20 Inexact Rounded
-pwsx2510 power 39E+1 0.5 -> 20 Inexact Rounded
-pwsx2511 power 39E+2 0.5 -> 62 Inexact Rounded
-pwsx2512 power 39E+3 0.5 -> 2.0E+2 Inexact Rounded
-pwsx2513 power 0.40 0.5 -> 0.63 Inexact Rounded
-pwsx2514 power 0.040 0.5 -> 0.20 Inexact Rounded
-pwsx2515 power 40.0E-1 0.5 -> 2.0 Inexact Rounded
-pwsx2516 power 40.00E-2 0.5 -> 0.63 Inexact Rounded
-pwsx2517 power 40E-3 0.5 -> 0.20 Inexact Rounded
-pwsx2518 power 40E+1 0.5 -> 20 Inexact Rounded
-pwsx2519 power 40E+2 0.5 -> 63 Inexact Rounded
-pwsx2520 power 40E+3 0.5 -> 2.0E+2 Inexact Rounded
-pwsx2521 power 0.41 0.5 -> 0.64 Inexact Rounded
-pwsx2522 power 0.041 0.5 -> 0.20 Inexact Rounded
-pwsx2523 power 41.0E-1 0.5 -> 2.0 Inexact Rounded
-pwsx2524 power 41.00E-2 0.5 -> 0.64 Inexact Rounded
-pwsx2525 power 41E-3 0.5 -> 0.20 Inexact Rounded
-pwsx2526 power 41E+1 0.5 -> 20 Inexact Rounded
-pwsx2527 power 41E+2 0.5 -> 64 Inexact Rounded
-pwsx2528 power 41E+3 0.5 -> 2.0E+2 Inexact Rounded
-pwsx2529 power 0.42 0.5 -> 0.65 Inexact Rounded
-pwsx2530 power 0.042 0.5 -> 0.20 Inexact Rounded
-pwsx2531 power 42.0E-1 0.5 -> 2.0 Inexact Rounded
-pwsx2532 power 42.00E-2 0.5 -> 0.65 Inexact Rounded
-pwsx2533 power 42E-3 0.5 -> 0.20 Inexact Rounded
-pwsx2534 power 42E+1 0.5 -> 20 Inexact Rounded
-pwsx2535 power 42E+2 0.5 -> 65 Inexact Rounded
-pwsx2536 power 42E+3 0.5 -> 2.0E+2 Inexact Rounded
-pwsx2537 power 0.43 0.5 -> 0.66 Inexact Rounded
-pwsx2538 power 0.043 0.5 -> 0.21 Inexact Rounded
-pwsx2539 power 43.0E-1 0.5 -> 2.1 Inexact Rounded
-pwsx2540 power 43.00E-2 0.5 -> 0.66 Inexact Rounded
-pwsx2541 power 43E-3 0.5 -> 0.21 Inexact Rounded
-pwsx2542 power 43E+1 0.5 -> 21 Inexact Rounded
-pwsx2543 power 43E+2 0.5 -> 66 Inexact Rounded
-pwsx2544 power 43E+3 0.5 -> 2.1E+2 Inexact Rounded
-pwsx2545 power 0.44 0.5 -> 0.66 Inexact Rounded
-pwsx2546 power 0.044 0.5 -> 0.21 Inexact Rounded
-pwsx2547 power 44.0E-1 0.5 -> 2.1 Inexact Rounded
-pwsx2548 power 44.00E-2 0.5 -> 0.66 Inexact Rounded
-pwsx2549 power 44E-3 0.5 -> 0.21 Inexact Rounded
-pwsx2550 power 44E+1 0.5 -> 21 Inexact Rounded
-pwsx2551 power 44E+2 0.5 -> 66 Inexact Rounded
-pwsx2552 power 44E+3 0.5 -> 2.1E+2 Inexact Rounded
-pwsx2553 power 0.45 0.5 -> 0.67 Inexact Rounded
-pwsx2554 power 0.045 0.5 -> 0.21 Inexact Rounded
-pwsx2555 power 45.0E-1 0.5 -> 2.1 Inexact Rounded
-pwsx2556 power 45.00E-2 0.5 -> 0.67 Inexact Rounded
-pwsx2557 power 45E-3 0.5 -> 0.21 Inexact Rounded
-pwsx2558 power 45E+1 0.5 -> 21 Inexact Rounded
-pwsx2559 power 45E+2 0.5 -> 67 Inexact Rounded
-pwsx2560 power 45E+3 0.5 -> 2.1E+2 Inexact Rounded
-pwsx2561 power 0.46 0.5 -> 0.68 Inexact Rounded
-pwsx2562 power 0.046 0.5 -> 0.21 Inexact Rounded
-pwsx2563 power 46.0E-1 0.5 -> 2.1 Inexact Rounded
-pwsx2564 power 46.00E-2 0.5 -> 0.68 Inexact Rounded
-pwsx2565 power 46E-3 0.5 -> 0.21 Inexact Rounded
-pwsx2566 power 46E+1 0.5 -> 21 Inexact Rounded
-pwsx2567 power 46E+2 0.5 -> 68 Inexact Rounded
-pwsx2568 power 46E+3 0.5 -> 2.1E+2 Inexact Rounded
-pwsx2569 power 0.47 0.5 -> 0.69 Inexact Rounded
-pwsx2570 power 0.047 0.5 -> 0.22 Inexact Rounded
-pwsx2571 power 47.0E-1 0.5 -> 2.2 Inexact Rounded
-pwsx2572 power 47.00E-2 0.5 -> 0.69 Inexact Rounded
-pwsx2573 power 47E-3 0.5 -> 0.22 Inexact Rounded
-pwsx2574 power 47E+1 0.5 -> 22 Inexact Rounded
-pwsx2575 power 47E+2 0.5 -> 69 Inexact Rounded
-pwsx2576 power 47E+3 0.5 -> 2.2E+2 Inexact Rounded
-pwsx2577 power 0.48 0.5 -> 0.69 Inexact Rounded
-pwsx2578 power 0.048 0.5 -> 0.22 Inexact Rounded
-pwsx2579 power 48.0E-1 0.5 -> 2.2 Inexact Rounded
-pwsx2580 power 48.00E-2 0.5 -> 0.69 Inexact Rounded
-pwsx2581 power 48E-3 0.5 -> 0.22 Inexact Rounded
-pwsx2582 power 48E+1 0.5 -> 22 Inexact Rounded
-pwsx2583 power 48E+2 0.5 -> 69 Inexact Rounded
-pwsx2584 power 48E+3 0.5 -> 2.2E+2 Inexact Rounded
-pwsx2585 power 0.49 0.5 -> 0.70 Inexact Rounded
-pwsx2586 power 0.049 0.5 -> 0.22 Inexact Rounded
-pwsx2587 power 49.0E-1 0.5 -> 2.2 Inexact Rounded
-pwsx2588 power 49.00E-2 0.5 -> 0.70 Inexact Rounded
-pwsx2589 power 49E-3 0.5 -> 0.22 Inexact Rounded
-pwsx2590 power 49E+1 0.5 -> 22 Inexact Rounded
-pwsx2591 power 49E+2 0.5 -> 70 Inexact Rounded
-pwsx2592 power 49E+3 0.5 -> 2.2E+2 Inexact Rounded
-pwsx2593 power 0.50 0.5 -> 0.71 Inexact Rounded
-pwsx2594 power 0.050 0.5 -> 0.22 Inexact Rounded
-pwsx2595 power 50.0E-1 0.5 -> 2.2 Inexact Rounded
-pwsx2596 power 50.00E-2 0.5 -> 0.71 Inexact Rounded
-pwsx2597 power 50E-3 0.5 -> 0.22 Inexact Rounded
-pwsx2598 power 50E+1 0.5 -> 22 Inexact Rounded
-pwsx2599 power 50E+2 0.5 -> 71 Inexact Rounded
-pwsx2600 power 50E+3 0.5 -> 2.2E+2 Inexact Rounded
-pwsx2601 power 0.51 0.5 -> 0.71 Inexact Rounded
-pwsx2602 power 0.051 0.5 -> 0.23 Inexact Rounded
-pwsx2603 power 51.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2604 power 51.00E-2 0.5 -> 0.71 Inexact Rounded
-pwsx2605 power 51E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2606 power 51E+1 0.5 -> 23 Inexact Rounded
-pwsx2607 power 51E+2 0.5 -> 71 Inexact Rounded
-pwsx2608 power 51E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2609 power 0.52 0.5 -> 0.72 Inexact Rounded
-pwsx2610 power 0.052 0.5 -> 0.23 Inexact Rounded
-pwsx2611 power 52.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2612 power 52.00E-2 0.5 -> 0.72 Inexact Rounded
-pwsx2613 power 52E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2614 power 52E+1 0.5 -> 23 Inexact Rounded
-pwsx2615 power 52E+2 0.5 -> 72 Inexact Rounded
-pwsx2616 power 52E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2617 power 0.53 0.5 -> 0.73 Inexact Rounded
-pwsx2618 power 0.053 0.5 -> 0.23 Inexact Rounded
-pwsx2619 power 53.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2620 power 53.00E-2 0.5 -> 0.73 Inexact Rounded
-pwsx2621 power 53E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2622 power 53E+1 0.5 -> 23 Inexact Rounded
-pwsx2623 power 53E+2 0.5 -> 73 Inexact Rounded
-pwsx2624 power 53E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2625 power 0.54 0.5 -> 0.73 Inexact Rounded
-pwsx2626 power 0.054 0.5 -> 0.23 Inexact Rounded
-pwsx2627 power 54.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2628 power 54.00E-2 0.5 -> 0.73 Inexact Rounded
-pwsx2629 power 54E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2630 power 54E+1 0.5 -> 23 Inexact Rounded
-pwsx2631 power 54E+2 0.5 -> 73 Inexact Rounded
-pwsx2632 power 54E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2633 power 0.55 0.5 -> 0.74 Inexact Rounded
-pwsx2634 power 0.055 0.5 -> 0.23 Inexact Rounded
-pwsx2635 power 55.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2636 power 55.00E-2 0.5 -> 0.74 Inexact Rounded
-pwsx2637 power 55E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2638 power 55E+1 0.5 -> 23 Inexact Rounded
-pwsx2639 power 55E+2 0.5 -> 74 Inexact Rounded
-pwsx2640 power 55E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2641 power 0.56 0.5 -> 0.75 Inexact Rounded
-pwsx2642 power 0.056 0.5 -> 0.24 Inexact Rounded
-pwsx2643 power 56.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2644 power 56.00E-2 0.5 -> 0.75 Inexact Rounded
-pwsx2645 power 56E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2646 power 56E+1 0.5 -> 24 Inexact Rounded
-pwsx2647 power 56E+2 0.5 -> 75 Inexact Rounded
-pwsx2648 power 56E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2649 power 0.57 0.5 -> 0.75 Inexact Rounded
-pwsx2650 power 0.057 0.5 -> 0.24 Inexact Rounded
-pwsx2651 power 57.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2652 power 57.00E-2 0.5 -> 0.75 Inexact Rounded
-pwsx2653 power 57E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2654 power 57E+1 0.5 -> 24 Inexact Rounded
-pwsx2655 power 57E+2 0.5 -> 75 Inexact Rounded
-pwsx2656 power 57E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2657 power 0.58 0.5 -> 0.76 Inexact Rounded
-pwsx2658 power 0.058 0.5 -> 0.24 Inexact Rounded
-pwsx2659 power 58.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2660 power 58.00E-2 0.5 -> 0.76 Inexact Rounded
-pwsx2661 power 58E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2662 power 58E+1 0.5 -> 24 Inexact Rounded
-pwsx2663 power 58E+2 0.5 -> 76 Inexact Rounded
-pwsx2664 power 58E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2665 power 0.59 0.5 -> 0.77 Inexact Rounded
-pwsx2666 power 0.059 0.5 -> 0.24 Inexact Rounded
-pwsx2667 power 59.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2668 power 59.00E-2 0.5 -> 0.77 Inexact Rounded
-pwsx2669 power 59E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2670 power 59E+1 0.5 -> 24 Inexact Rounded
-pwsx2671 power 59E+2 0.5 -> 77 Inexact Rounded
-pwsx2672 power 59E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2673 power 0.60 0.5 -> 0.77 Inexact Rounded
-pwsx2674 power 0.060 0.5 -> 0.24 Inexact Rounded
-pwsx2675 power 60.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2676 power 60.00E-2 0.5 -> 0.77 Inexact Rounded
-pwsx2677 power 60E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2678 power 60E+1 0.5 -> 24 Inexact Rounded
-pwsx2679 power 60E+2 0.5 -> 77 Inexact Rounded
-pwsx2680 power 60E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2681 power 0.61 0.5 -> 0.78 Inexact Rounded
-pwsx2682 power 0.061 0.5 -> 0.25 Inexact Rounded
-pwsx2683 power 61.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2684 power 61.00E-2 0.5 -> 0.78 Inexact Rounded
-pwsx2685 power 61E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2686 power 61E+1 0.5 -> 25 Inexact Rounded
-pwsx2687 power 61E+2 0.5 -> 78 Inexact Rounded
-pwsx2688 power 61E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2689 power 0.62 0.5 -> 0.79 Inexact Rounded
-pwsx2690 power 0.062 0.5 -> 0.25 Inexact Rounded
-pwsx2691 power 62.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2692 power 62.00E-2 0.5 -> 0.79 Inexact Rounded
-pwsx2693 power 62E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2694 power 62E+1 0.5 -> 25 Inexact Rounded
-pwsx2695 power 62E+2 0.5 -> 79 Inexact Rounded
-pwsx2696 power 62E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2697 power 0.63 0.5 -> 0.79 Inexact Rounded
-pwsx2698 power 0.063 0.5 -> 0.25 Inexact Rounded
-pwsx2699 power 63.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2700 power 63.00E-2 0.5 -> 0.79 Inexact Rounded
-pwsx2701 power 63E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2702 power 63E+1 0.5 -> 25 Inexact Rounded
-pwsx2703 power 63E+2 0.5 -> 79 Inexact Rounded
-pwsx2704 power 63E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2705 power 0.64 0.5 -> 0.80 Inexact Rounded
-pwsx2706 power 0.064 0.5 -> 0.25 Inexact Rounded
-pwsx2707 power 64.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2708 power 64.00E-2 0.5 -> 0.80 Inexact Rounded
-pwsx2709 power 64E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2710 power 64E+1 0.5 -> 25 Inexact Rounded
-pwsx2711 power 64E+2 0.5 -> 80 Inexact Rounded
-pwsx2712 power 64E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2713 power 0.65 0.5 -> 0.81 Inexact Rounded
-pwsx2714 power 0.065 0.5 -> 0.25 Inexact Rounded
-pwsx2715 power 65.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2716 power 65.00E-2 0.5 -> 0.81 Inexact Rounded
-pwsx2717 power 65E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2718 power 65E+1 0.5 -> 25 Inexact Rounded
-pwsx2719 power 65E+2 0.5 -> 81 Inexact Rounded
-pwsx2720 power 65E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2721 power 0.66 0.5 -> 0.81 Inexact Rounded
-pwsx2722 power 0.066 0.5 -> 0.26 Inexact Rounded
-pwsx2723 power 66.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2724 power 66.00E-2 0.5 -> 0.81 Inexact Rounded
-pwsx2725 power 66E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2726 power 66E+1 0.5 -> 26 Inexact Rounded
-pwsx2727 power 66E+2 0.5 -> 81 Inexact Rounded
-pwsx2728 power 66E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2729 power 0.67 0.5 -> 0.82 Inexact Rounded
-pwsx2730 power 0.067 0.5 -> 0.26 Inexact Rounded
-pwsx2731 power 67.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2732 power 67.00E-2 0.5 -> 0.82 Inexact Rounded
-pwsx2733 power 67E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2734 power 67E+1 0.5 -> 26 Inexact Rounded
-pwsx2735 power 67E+2 0.5 -> 82 Inexact Rounded
-pwsx2736 power 67E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2737 power 0.68 0.5 -> 0.82 Inexact Rounded
-pwsx2738 power 0.068 0.5 -> 0.26 Inexact Rounded
-pwsx2739 power 68.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2740 power 68.00E-2 0.5 -> 0.82 Inexact Rounded
-pwsx2741 power 68E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2742 power 68E+1 0.5 -> 26 Inexact Rounded
-pwsx2743 power 68E+2 0.5 -> 82 Inexact Rounded
-pwsx2744 power 68E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2745 power 0.69 0.5 -> 0.83 Inexact Rounded
-pwsx2746 power 0.069 0.5 -> 0.26 Inexact Rounded
-pwsx2747 power 69.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2748 power 69.00E-2 0.5 -> 0.83 Inexact Rounded
-pwsx2749 power 69E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2750 power 69E+1 0.5 -> 26 Inexact Rounded
-pwsx2751 power 69E+2 0.5 -> 83 Inexact Rounded
-pwsx2752 power 69E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2753 power 0.70 0.5 -> 0.84 Inexact Rounded
-pwsx2754 power 0.070 0.5 -> 0.26 Inexact Rounded
-pwsx2755 power 70.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2756 power 70.00E-2 0.5 -> 0.84 Inexact Rounded
-pwsx2757 power 70E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2758 power 70E+1 0.5 -> 26 Inexact Rounded
-pwsx2759 power 70E+2 0.5 -> 84 Inexact Rounded
-pwsx2760 power 70E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2761 power 0.71 0.5 -> 0.84 Inexact Rounded
-pwsx2762 power 0.071 0.5 -> 0.27 Inexact Rounded
-pwsx2763 power 71.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2764 power 71.00E-2 0.5 -> 0.84 Inexact Rounded
-pwsx2765 power 71E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2766 power 71E+1 0.5 -> 27 Inexact Rounded
-pwsx2767 power 71E+2 0.5 -> 84 Inexact Rounded
-pwsx2768 power 71E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2769 power 0.72 0.5 -> 0.85 Inexact Rounded
-pwsx2770 power 0.072 0.5 -> 0.27 Inexact Rounded
-pwsx2771 power 72.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2772 power 72.00E-2 0.5 -> 0.85 Inexact Rounded
-pwsx2773 power 72E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2774 power 72E+1 0.5 -> 27 Inexact Rounded
-pwsx2775 power 72E+2 0.5 -> 85 Inexact Rounded
-pwsx2776 power 72E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2777 power 0.73 0.5 -> 0.85 Inexact Rounded
-pwsx2778 power 0.073 0.5 -> 0.27 Inexact Rounded
-pwsx2779 power 73.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2780 power 73.00E-2 0.5 -> 0.85 Inexact Rounded
-pwsx2781 power 73E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2782 power 73E+1 0.5 -> 27 Inexact Rounded
-pwsx2783 power 73E+2 0.5 -> 85 Inexact Rounded
-pwsx2784 power 73E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2785 power 0.74 0.5 -> 0.86 Inexact Rounded
-pwsx2786 power 0.074 0.5 -> 0.27 Inexact Rounded
-pwsx2787 power 74.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2788 power 74.00E-2 0.5 -> 0.86 Inexact Rounded
-pwsx2789 power 74E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2790 power 74E+1 0.5 -> 27 Inexact Rounded
-pwsx2791 power 74E+2 0.5 -> 86 Inexact Rounded
-pwsx2792 power 74E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2793 power 0.75 0.5 -> 0.87 Inexact Rounded
-pwsx2794 power 0.075 0.5 -> 0.27 Inexact Rounded
-pwsx2795 power 75.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2796 power 75.00E-2 0.5 -> 0.87 Inexact Rounded
-pwsx2797 power 75E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2798 power 75E+1 0.5 -> 27 Inexact Rounded
-pwsx2799 power 75E+2 0.5 -> 87 Inexact Rounded
-pwsx2800 power 75E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2801 power 0.76 0.5 -> 0.87 Inexact Rounded
-pwsx2802 power 0.076 0.5 -> 0.28 Inexact Rounded
-pwsx2803 power 76.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2804 power 76.00E-2 0.5 -> 0.87 Inexact Rounded
-pwsx2805 power 76E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2806 power 76E+1 0.5 -> 28 Inexact Rounded
-pwsx2807 power 76E+2 0.5 -> 87 Inexact Rounded
-pwsx2808 power 76E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2809 power 0.77 0.5 -> 0.88 Inexact Rounded
-pwsx2810 power 0.077 0.5 -> 0.28 Inexact Rounded
-pwsx2811 power 77.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2812 power 77.00E-2 0.5 -> 0.88 Inexact Rounded
-pwsx2813 power 77E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2814 power 77E+1 0.5 -> 28 Inexact Rounded
-pwsx2815 power 77E+2 0.5 -> 88 Inexact Rounded
-pwsx2816 power 77E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2817 power 0.78 0.5 -> 0.88 Inexact Rounded
-pwsx2818 power 0.078 0.5 -> 0.28 Inexact Rounded
-pwsx2819 power 78.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2820 power 78.00E-2 0.5 -> 0.88 Inexact Rounded
-pwsx2821 power 78E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2822 power 78E+1 0.5 -> 28 Inexact Rounded
-pwsx2823 power 78E+2 0.5 -> 88 Inexact Rounded
-pwsx2824 power 78E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2825 power 0.79 0.5 -> 0.89 Inexact Rounded
-pwsx2826 power 0.079 0.5 -> 0.28 Inexact Rounded
-pwsx2827 power 79.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2828 power 79.00E-2 0.5 -> 0.89 Inexact Rounded
-pwsx2829 power 79E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2830 power 79E+1 0.5 -> 28 Inexact Rounded
-pwsx2831 power 79E+2 0.5 -> 89 Inexact Rounded
-pwsx2832 power 79E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2833 power 0.80 0.5 -> 0.89 Inexact Rounded
-pwsx2834 power 0.080 0.5 -> 0.28 Inexact Rounded
-pwsx2835 power 80.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2836 power 80.00E-2 0.5 -> 0.89 Inexact Rounded
-pwsx2837 power 80E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2838 power 80E+1 0.5 -> 28 Inexact Rounded
-pwsx2839 power 80E+2 0.5 -> 89 Inexact Rounded
-pwsx2840 power 80E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2841 power 0.81 0.5 -> 0.90 Inexact Rounded
-pwsx2842 power 0.081 0.5 -> 0.28 Inexact Rounded
-pwsx2843 power 81.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2844 power 81.00E-2 0.5 -> 0.90 Inexact Rounded
-pwsx2845 power 81E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2846 power 81E+1 0.5 -> 28 Inexact Rounded
-pwsx2847 power 81E+2 0.5 -> 90 Inexact Rounded
-pwsx2848 power 81E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2849 power 0.82 0.5 -> 0.91 Inexact Rounded
-pwsx2850 power 0.082 0.5 -> 0.29 Inexact Rounded
-pwsx2851 power 82.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2852 power 82.00E-2 0.5 -> 0.91 Inexact Rounded
-pwsx2853 power 82E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2854 power 82E+1 0.5 -> 29 Inexact Rounded
-pwsx2855 power 82E+2 0.5 -> 91 Inexact Rounded
-pwsx2856 power 82E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2857 power 0.83 0.5 -> 0.91 Inexact Rounded
-pwsx2858 power 0.083 0.5 -> 0.29 Inexact Rounded
-pwsx2859 power 83.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2860 power 83.00E-2 0.5 -> 0.91 Inexact Rounded
-pwsx2861 power 83E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2862 power 83E+1 0.5 -> 29 Inexact Rounded
-pwsx2863 power 83E+2 0.5 -> 91 Inexact Rounded
-pwsx2864 power 83E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2865 power 0.84 0.5 -> 0.92 Inexact Rounded
-pwsx2866 power 0.084 0.5 -> 0.29 Inexact Rounded
-pwsx2867 power 84.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2868 power 84.00E-2 0.5 -> 0.92 Inexact Rounded
-pwsx2869 power 84E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2870 power 84E+1 0.5 -> 29 Inexact Rounded
-pwsx2871 power 84E+2 0.5 -> 92 Inexact Rounded
-pwsx2872 power 84E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2873 power 0.85 0.5 -> 0.92 Inexact Rounded
-pwsx2874 power 0.085 0.5 -> 0.29 Inexact Rounded
-pwsx2875 power 85.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2876 power 85.00E-2 0.5 -> 0.92 Inexact Rounded
-pwsx2877 power 85E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2878 power 85E+1 0.5 -> 29 Inexact Rounded
-pwsx2879 power 85E+2 0.5 -> 92 Inexact Rounded
-pwsx2880 power 85E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2881 power 0.86 0.5 -> 0.93 Inexact Rounded
-pwsx2882 power 0.086 0.5 -> 0.29 Inexact Rounded
-pwsx2883 power 86.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2884 power 86.00E-2 0.5 -> 0.93 Inexact Rounded
-pwsx2885 power 86E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2886 power 86E+1 0.5 -> 29 Inexact Rounded
-pwsx2887 power 86E+2 0.5 -> 93 Inexact Rounded
-pwsx2888 power 86E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2889 power 0.87 0.5 -> 0.93 Inexact Rounded
-pwsx2890 power 0.087 0.5 -> 0.29 Inexact Rounded
-pwsx2891 power 87.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2892 power 87.00E-2 0.5 -> 0.93 Inexact Rounded
-pwsx2893 power 87E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2894 power 87E+1 0.5 -> 29 Inexact Rounded
-pwsx2895 power 87E+2 0.5 -> 93 Inexact Rounded
-pwsx2896 power 87E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2897 power 0.88 0.5 -> 0.94 Inexact Rounded
-pwsx2898 power 0.088 0.5 -> 0.30 Inexact Rounded
-pwsx2899 power 88.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2900 power 88.00E-2 0.5 -> 0.94 Inexact Rounded
-pwsx2901 power 88E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2902 power 88E+1 0.5 -> 30 Inexact Rounded
-pwsx2903 power 88E+2 0.5 -> 94 Inexact Rounded
-pwsx2904 power 88E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2905 power 0.89 0.5 -> 0.94 Inexact Rounded
-pwsx2906 power 0.089 0.5 -> 0.30 Inexact Rounded
-pwsx2907 power 89.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2908 power 89.00E-2 0.5 -> 0.94 Inexact Rounded
-pwsx2909 power 89E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2910 power 89E+1 0.5 -> 30 Inexact Rounded
-pwsx2911 power 89E+2 0.5 -> 94 Inexact Rounded
-pwsx2912 power 89E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2913 power 0.90 0.5 -> 0.95 Inexact Rounded
-pwsx2914 power 0.090 0.5 -> 0.30 Inexact Rounded
-pwsx2915 power 90.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2916 power 90.00E-2 0.5 -> 0.95 Inexact Rounded
-pwsx2917 power 90E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2918 power 90E+1 0.5 -> 30 Inexact Rounded
-pwsx2919 power 90E+2 0.5 -> 95 Inexact Rounded
-pwsx2920 power 90E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2921 power 0.91 0.5 -> 0.95 Inexact Rounded
-pwsx2922 power 0.091 0.5 -> 0.30 Inexact Rounded
-pwsx2923 power 91.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2924 power 91.00E-2 0.5 -> 0.95 Inexact Rounded
-pwsx2925 power 91E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2926 power 91E+1 0.5 -> 30 Inexact Rounded
-pwsx2927 power 91E+2 0.5 -> 95 Inexact Rounded
-pwsx2928 power 91E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2929 power 0.92 0.5 -> 0.96 Inexact Rounded
-pwsx2930 power 0.092 0.5 -> 0.30 Inexact Rounded
-pwsx2931 power 92.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2932 power 92.00E-2 0.5 -> 0.96 Inexact Rounded
-pwsx2933 power 92E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2934 power 92E+1 0.5 -> 30 Inexact Rounded
-pwsx2935 power 92E+2 0.5 -> 96 Inexact Rounded
-pwsx2936 power 92E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2937 power 0.93 0.5 -> 0.96 Inexact Rounded
-pwsx2938 power 0.093 0.5 -> 0.30 Inexact Rounded
-pwsx2939 power 93.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2940 power 93.00E-2 0.5 -> 0.96 Inexact Rounded
-pwsx2941 power 93E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2942 power 93E+1 0.5 -> 30 Inexact Rounded
-pwsx2943 power 93E+2 0.5 -> 96 Inexact Rounded
-pwsx2944 power 93E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2945 power 0.94 0.5 -> 0.97 Inexact Rounded
-pwsx2946 power 0.094 0.5 -> 0.31 Inexact Rounded
-pwsx2947 power 94.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2948 power 94.00E-2 0.5 -> 0.97 Inexact Rounded
-pwsx2949 power 94E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2950 power 94E+1 0.5 -> 31 Inexact Rounded
-pwsx2951 power 94E+2 0.5 -> 97 Inexact Rounded
-pwsx2952 power 94E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2953 power 0.95 0.5 -> 0.97 Inexact Rounded
-pwsx2954 power 0.095 0.5 -> 0.31 Inexact Rounded
-pwsx2955 power 95.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2956 power 95.00E-2 0.5 -> 0.97 Inexact Rounded
-pwsx2957 power 95E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2958 power 95E+1 0.5 -> 31 Inexact Rounded
-pwsx2959 power 95E+2 0.5 -> 97 Inexact Rounded
-pwsx2960 power 95E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2961 power 0.96 0.5 -> 0.98 Inexact Rounded
-pwsx2962 power 0.096 0.5 -> 0.31 Inexact Rounded
-pwsx2963 power 96.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2964 power 96.00E-2 0.5 -> 0.98 Inexact Rounded
-pwsx2965 power 96E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2966 power 96E+1 0.5 -> 31 Inexact Rounded
-pwsx2967 power 96E+2 0.5 -> 98 Inexact Rounded
-pwsx2968 power 96E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2969 power 0.97 0.5 -> 0.98 Inexact Rounded
-pwsx2970 power 0.097 0.5 -> 0.31 Inexact Rounded
-pwsx2971 power 97.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2972 power 97.00E-2 0.5 -> 0.98 Inexact Rounded
-pwsx2973 power 97E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2974 power 97E+1 0.5 -> 31 Inexact Rounded
-pwsx2975 power 97E+2 0.5 -> 98 Inexact Rounded
-pwsx2976 power 97E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2977 power 0.98 0.5 -> 0.99 Inexact Rounded
-pwsx2978 power 0.098 0.5 -> 0.31 Inexact Rounded
-pwsx2979 power 98.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2980 power 98.00E-2 0.5 -> 0.99 Inexact Rounded
-pwsx2981 power 98E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2982 power 98E+1 0.5 -> 31 Inexact Rounded
-pwsx2983 power 98E+2 0.5 -> 99 Inexact Rounded
-pwsx2984 power 98E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2985 power 0.99 0.5 -> 0.99 Inexact Rounded
-pwsx2986 power 0.099 0.5 -> 0.31 Inexact Rounded
-pwsx2987 power 99.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2988 power 99.00E-2 0.5 -> 0.99 Inexact Rounded
-pwsx2989 power 99E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2990 power 99E+1 0.5 -> 31 Inexact Rounded
-pwsx2991 power 99E+2 0.5 -> 99 Inexact Rounded
-pwsx2992 power 99E+3 0.5 -> 3.1E+2 Inexact Rounded
-
--- Precision 3 squareroot tests [exhaustive, f and f/10]
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-precision: 3
-pwsx3001 power 0.1 0.5 -> 0.316 Inexact Rounded
-pwsx3002 power 0.01 0.5 -> 0.100 Inexact Rounded
-pwsx3003 power 0.2 0.5 -> 0.447 Inexact Rounded
-pwsx3004 power 0.02 0.5 -> 0.141 Inexact Rounded
-pwsx3005 power 0.3 0.5 -> 0.548 Inexact Rounded
-pwsx3006 power 0.03 0.5 -> 0.173 Inexact Rounded
-pwsx3007 power 0.4 0.5 -> 0.632 Inexact Rounded
-pwsx3008 power 0.04 0.5 -> 0.200 Inexact Rounded
-pwsx3009 power 0.5 0.5 -> 0.707 Inexact Rounded
-pwsx3010 power 0.05 0.5 -> 0.224 Inexact Rounded
-pwsx3011 power 0.6 0.5 -> 0.775 Inexact Rounded
-pwsx3012 power 0.06 0.5 -> 0.245 Inexact Rounded
-pwsx3013 power 0.7 0.5 -> 0.837 Inexact Rounded
-pwsx3014 power 0.07 0.5 -> 0.265 Inexact Rounded
-pwsx3015 power 0.8 0.5 -> 0.894 Inexact Rounded
-pwsx3016 power 0.08 0.5 -> 0.283 Inexact Rounded
-pwsx3017 power 0.9 0.5 -> 0.949 Inexact Rounded
-pwsx3018 power 0.09 0.5 -> 0.300 Inexact Rounded
-pwsx3019 power 0.11 0.5 -> 0.332 Inexact Rounded
-pwsx3020 power 0.011 0.5 -> 0.105 Inexact Rounded
-pwsx3021 power 0.12 0.5 -> 0.346 Inexact Rounded
-pwsx3022 power 0.012 0.5 -> 0.110 Inexact Rounded
-pwsx3023 power 0.13 0.5 -> 0.361 Inexact Rounded
-pwsx3024 power 0.013 0.5 -> 0.114 Inexact Rounded
-pwsx3025 power 0.14 0.5 -> 0.374 Inexact Rounded
-pwsx3026 power 0.014 0.5 -> 0.118 Inexact Rounded
-pwsx3027 power 0.15 0.5 -> 0.387 Inexact Rounded
-pwsx3028 power 0.015 0.5 -> 0.122 Inexact Rounded
-pwsx3029 power 0.16 0.5 -> 0.400 Inexact Rounded
-pwsx3030 power 0.016 0.5 -> 0.126 Inexact Rounded
-pwsx3031 power 0.17 0.5 -> 0.412 Inexact Rounded
-pwsx3032 power 0.017 0.5 -> 0.130 Inexact Rounded
-pwsx3033 power 0.18 0.5 -> 0.424 Inexact Rounded
-pwsx3034 power 0.018 0.5 -> 0.134 Inexact Rounded
-pwsx3035 power 0.19 0.5 -> 0.436 Inexact Rounded
-pwsx3036 power 0.019 0.5 -> 0.138 Inexact Rounded
-pwsx3037 power 0.21 0.5 -> 0.458 Inexact Rounded
-pwsx3038 power 0.021 0.5 -> 0.145 Inexact Rounded
-pwsx3039 power 0.22 0.5 -> 0.469 Inexact Rounded
-pwsx3040 power 0.022 0.5 -> 0.148 Inexact Rounded
-pwsx3041 power 0.23 0.5 -> 0.480 Inexact Rounded
-pwsx3042 power 0.023 0.5 -> 0.152 Inexact Rounded
-pwsx3043 power 0.24 0.5 -> 0.490 Inexact Rounded
-pwsx3044 power 0.024 0.5 -> 0.155 Inexact Rounded
-pwsx3045 power 0.25 0.5 -> 0.500 Inexact Rounded
-pwsx3046 power 0.025 0.5 -> 0.158 Inexact Rounded
-pwsx3047 power 0.26 0.5 -> 0.510 Inexact Rounded
-pwsx3048 power 0.026 0.5 -> 0.161 Inexact Rounded
-pwsx3049 power 0.27 0.5 -> 0.520 Inexact Rounded
-pwsx3050 power 0.027 0.5 -> 0.164 Inexact Rounded
-pwsx3051 power 0.28 0.5 -> 0.529 Inexact Rounded
-pwsx3052 power 0.028 0.5 -> 0.167 Inexact Rounded
-pwsx3053 power 0.29 0.5 -> 0.539 Inexact Rounded
-pwsx3054 power 0.029 0.5 -> 0.170 Inexact Rounded
-pwsx3055 power 0.31 0.5 -> 0.557 Inexact Rounded
-pwsx3056 power 0.031 0.5 -> 0.176 Inexact Rounded
-pwsx3057 power 0.32 0.5 -> 0.566 Inexact Rounded
-pwsx3058 power 0.032 0.5 -> 0.179 Inexact Rounded
-pwsx3059 power 0.33 0.5 -> 0.574 Inexact Rounded
-pwsx3060 power 0.033 0.5 -> 0.182 Inexact Rounded
-pwsx3061 power 0.34 0.5 -> 0.583 Inexact Rounded
-pwsx3062 power 0.034 0.5 -> 0.184 Inexact Rounded
-pwsx3063 power 0.35 0.5 -> 0.592 Inexact Rounded
-pwsx3064 power 0.035 0.5 -> 0.187 Inexact Rounded
-pwsx3065 power 0.36 0.5 -> 0.600 Inexact Rounded
-pwsx3066 power 0.036 0.5 -> 0.190 Inexact Rounded
-pwsx3067 power 0.37 0.5 -> 0.608 Inexact Rounded
-pwsx3068 power 0.037 0.5 -> 0.192 Inexact Rounded
-pwsx3069 power 0.38 0.5 -> 0.616 Inexact Rounded
-pwsx3070 power 0.038 0.5 -> 0.195 Inexact Rounded
-pwsx3071 power 0.39 0.5 -> 0.624 Inexact Rounded
-pwsx3072 power 0.039 0.5 -> 0.197 Inexact Rounded
-pwsx3073 power 0.41 0.5 -> 0.640 Inexact Rounded
-pwsx3074 power 0.041 0.5 -> 0.202 Inexact Rounded
-pwsx3075 power 0.42 0.5 -> 0.648 Inexact Rounded
-pwsx3076 power 0.042 0.5 -> 0.205 Inexact Rounded
-pwsx3077 power 0.43 0.5 -> 0.656 Inexact Rounded
-pwsx3078 power 0.043 0.5 -> 0.207 Inexact Rounded
-pwsx3079 power 0.44 0.5 -> 0.663 Inexact Rounded
-pwsx3080 power 0.044 0.5 -> 0.210 Inexact Rounded
-pwsx3081 power 0.45 0.5 -> 0.671 Inexact Rounded
-pwsx3082 power 0.045 0.5 -> 0.212 Inexact Rounded
-pwsx3083 power 0.46 0.5 -> 0.678 Inexact Rounded
-pwsx3084 power 0.046 0.5 -> 0.214 Inexact Rounded
-pwsx3085 power 0.47 0.5 -> 0.686 Inexact Rounded
-pwsx3086 power 0.047 0.5 -> 0.217 Inexact Rounded
-pwsx3087 power 0.48 0.5 -> 0.693 Inexact Rounded
-pwsx3088 power 0.048 0.5 -> 0.219 Inexact Rounded
-pwsx3089 power 0.49 0.5 -> 0.700 Inexact Rounded
-pwsx3090 power 0.049 0.5 -> 0.221 Inexact Rounded
-pwsx3091 power 0.51 0.5 -> 0.714 Inexact Rounded
-pwsx3092 power 0.051 0.5 -> 0.226 Inexact Rounded
-pwsx3093 power 0.52 0.5 -> 0.721 Inexact Rounded
-pwsx3094 power 0.052 0.5 -> 0.228 Inexact Rounded
-pwsx3095 power 0.53 0.5 -> 0.728 Inexact Rounded
-pwsx3096 power 0.053 0.5 -> 0.230 Inexact Rounded
-pwsx3097 power 0.54 0.5 -> 0.735 Inexact Rounded
-pwsx3098 power 0.054 0.5 -> 0.232 Inexact Rounded
-pwsx3099 power 0.55 0.5 -> 0.742 Inexact Rounded
-pwsx3100 power 0.055 0.5 -> 0.235 Inexact Rounded
-pwsx3101 power 0.56 0.5 -> 0.748 Inexact Rounded
-pwsx3102 power 0.056 0.5 -> 0.237 Inexact Rounded
-pwsx3103 power 0.57 0.5 -> 0.755 Inexact Rounded
-pwsx3104 power 0.057 0.5 -> 0.239 Inexact Rounded
-pwsx3105 power 0.58 0.5 -> 0.762 Inexact Rounded
-pwsx3106 power 0.058 0.5 -> 0.241 Inexact Rounded
-pwsx3107 power 0.59 0.5 -> 0.768 Inexact Rounded
-pwsx3108 power 0.059 0.5 -> 0.243 Inexact Rounded
-pwsx3109 power 0.61 0.5 -> 0.781 Inexact Rounded
-pwsx3110 power 0.061 0.5 -> 0.247 Inexact Rounded
-pwsx3111 power 0.62 0.5 -> 0.787 Inexact Rounded
-pwsx3112 power 0.062 0.5 -> 0.249 Inexact Rounded
-pwsx3113 power 0.63 0.5 -> 0.794 Inexact Rounded
-pwsx3114 power 0.063 0.5 -> 0.251 Inexact Rounded
-pwsx3115 power 0.64 0.5 -> 0.800 Inexact Rounded
-pwsx3116 power 0.064 0.5 -> 0.253 Inexact Rounded
-pwsx3117 power 0.65 0.5 -> 0.806 Inexact Rounded
-pwsx3118 power 0.065 0.5 -> 0.255 Inexact Rounded
-pwsx3119 power 0.66 0.5 -> 0.812 Inexact Rounded
-pwsx3120 power 0.066 0.5 -> 0.257 Inexact Rounded
-pwsx3121 power 0.67 0.5 -> 0.819 Inexact Rounded
-pwsx3122 power 0.067 0.5 -> 0.259 Inexact Rounded
-pwsx3123 power 0.68 0.5 -> 0.825 Inexact Rounded
-pwsx3124 power 0.068 0.5 -> 0.261 Inexact Rounded
-pwsx3125 power 0.69 0.5 -> 0.831 Inexact Rounded
-pwsx3126 power 0.069 0.5 -> 0.263 Inexact Rounded
-pwsx3127 power 0.71 0.5 -> 0.843 Inexact Rounded
-pwsx3128 power 0.071 0.5 -> 0.266 Inexact Rounded
-pwsx3129 power 0.72 0.5 -> 0.849 Inexact Rounded
-pwsx3130 power 0.072 0.5 -> 0.268 Inexact Rounded
-pwsx3131 power 0.73 0.5 -> 0.854 Inexact Rounded
-pwsx3132 power 0.073 0.5 -> 0.270 Inexact Rounded
-pwsx3133 power 0.74 0.5 -> 0.860 Inexact Rounded
-pwsx3134 power 0.074 0.5 -> 0.272 Inexact Rounded
-pwsx3135 power 0.75 0.5 -> 0.866 Inexact Rounded
-pwsx3136 power 0.075 0.5 -> 0.274 Inexact Rounded
-pwsx3137 power 0.76 0.5 -> 0.872 Inexact Rounded
-pwsx3138 power 0.076 0.5 -> 0.276 Inexact Rounded
-pwsx3139 power 0.77 0.5 -> 0.877 Inexact Rounded
-pwsx3140 power 0.077 0.5 -> 0.277 Inexact Rounded
-pwsx3141 power 0.78 0.5 -> 0.883 Inexact Rounded
-pwsx3142 power 0.078 0.5 -> 0.279 Inexact Rounded
-pwsx3143 power 0.79 0.5 -> 0.889 Inexact Rounded
-pwsx3144 power 0.079 0.5 -> 0.281 Inexact Rounded
-pwsx3145 power 0.81 0.5 -> 0.900 Inexact Rounded
-pwsx3146 power 0.081 0.5 -> 0.285 Inexact Rounded
-pwsx3147 power 0.82 0.5 -> 0.906 Inexact Rounded
-pwsx3148 power 0.082 0.5 -> 0.286 Inexact Rounded
-pwsx3149 power 0.83 0.5 -> 0.911 Inexact Rounded
-pwsx3150 power 0.083 0.5 -> 0.288 Inexact Rounded
-pwsx3151 power 0.84 0.5 -> 0.917 Inexact Rounded
-pwsx3152 power 0.084 0.5 -> 0.290 Inexact Rounded
-pwsx3153 power 0.85 0.5 -> 0.922 Inexact Rounded
-pwsx3154 power 0.085 0.5 -> 0.292 Inexact Rounded
-pwsx3155 power 0.86 0.5 -> 0.927 Inexact Rounded
-pwsx3156 power 0.086 0.5 -> 0.293 Inexact Rounded
-pwsx3157 power 0.87 0.5 -> 0.933 Inexact Rounded
-pwsx3158 power 0.087 0.5 -> 0.295 Inexact Rounded
-pwsx3159 power 0.88 0.5 -> 0.938 Inexact Rounded
-pwsx3160 power 0.088 0.5 -> 0.297 Inexact Rounded
-pwsx3161 power 0.89 0.5 -> 0.943 Inexact Rounded
-pwsx3162 power 0.089 0.5 -> 0.298 Inexact Rounded
-pwsx3163 power 0.91 0.5 -> 0.954 Inexact Rounded
-pwsx3164 power 0.091 0.5 -> 0.302 Inexact Rounded
-pwsx3165 power 0.92 0.5 -> 0.959 Inexact Rounded
-pwsx3166 power 0.092 0.5 -> 0.303 Inexact Rounded
-pwsx3167 power 0.93 0.5 -> 0.964 Inexact Rounded
-pwsx3168 power 0.093 0.5 -> 0.305 Inexact Rounded
-pwsx3169 power 0.94 0.5 -> 0.970 Inexact Rounded
-pwsx3170 power 0.094 0.5 -> 0.307 Inexact Rounded
-pwsx3171 power 0.95 0.5 -> 0.975 Inexact Rounded
-pwsx3172 power 0.095 0.5 -> 0.308 Inexact Rounded
-pwsx3173 power 0.96 0.5 -> 0.980 Inexact Rounded
-pwsx3174 power 0.096 0.5 -> 0.310 Inexact Rounded
-pwsx3175 power 0.97 0.5 -> 0.985 Inexact Rounded
-pwsx3176 power 0.097 0.5 -> 0.311 Inexact Rounded
-pwsx3177 power 0.98 0.5 -> 0.990 Inexact Rounded
-pwsx3178 power 0.098 0.5 -> 0.313 Inexact Rounded
-pwsx3179 power 0.99 0.5 -> 0.995 Inexact Rounded
-pwsx3180 power 0.099 0.5 -> 0.315 Inexact Rounded
-pwsx3181 power 0.101 0.5 -> 0.318 Inexact Rounded
-pwsx3182 power 0.0101 0.5 -> 0.100 Inexact Rounded
-pwsx3183 power 0.102 0.5 -> 0.319 Inexact Rounded
-pwsx3184 power 0.0102 0.5 -> 0.101 Inexact Rounded
-pwsx3185 power 0.103 0.5 -> 0.321 Inexact Rounded
-pwsx3186 power 0.0103 0.5 -> 0.101 Inexact Rounded
-pwsx3187 power 0.104 0.5 -> 0.322 Inexact Rounded
-pwsx3188 power 0.0104 0.5 -> 0.102 Inexact Rounded
-pwsx3189 power 0.105 0.5 -> 0.324 Inexact Rounded
-pwsx3190 power 0.0105 0.5 -> 0.102 Inexact Rounded
-pwsx3191 power 0.106 0.5 -> 0.326 Inexact Rounded
-pwsx3192 power 0.0106 0.5 -> 0.103 Inexact Rounded
-pwsx3193 power 0.107 0.5 -> 0.327 Inexact Rounded
-pwsx3194 power 0.0107 0.5 -> 0.103 Inexact Rounded
-pwsx3195 power 0.108 0.5 -> 0.329 Inexact Rounded
-pwsx3196 power 0.0108 0.5 -> 0.104 Inexact Rounded
-pwsx3197 power 0.109 0.5 -> 0.330 Inexact Rounded
-pwsx3198 power 0.0109 0.5 -> 0.104 Inexact Rounded
-pwsx3199 power 0.111 0.5 -> 0.333 Inexact Rounded
-pwsx3200 power 0.0111 0.5 -> 0.105 Inexact Rounded
-pwsx3201 power 0.112 0.5 -> 0.335 Inexact Rounded
-pwsx3202 power 0.0112 0.5 -> 0.106 Inexact Rounded
-pwsx3203 power 0.113 0.5 -> 0.336 Inexact Rounded
-pwsx3204 power 0.0113 0.5 -> 0.106 Inexact Rounded
-pwsx3205 power 0.114 0.5 -> 0.338 Inexact Rounded
-pwsx3206 power 0.0114 0.5 -> 0.107 Inexact Rounded
-pwsx3207 power 0.115 0.5 -> 0.339 Inexact Rounded
-pwsx3208 power 0.0115 0.5 -> 0.107 Inexact Rounded
-pwsx3209 power 0.116 0.5 -> 0.341 Inexact Rounded
-pwsx3210 power 0.0116 0.5 -> 0.108 Inexact Rounded
-pwsx3211 power 0.117 0.5 -> 0.342 Inexact Rounded
-pwsx3212 power 0.0117 0.5 -> 0.108 Inexact Rounded
-pwsx3213 power 0.118 0.5 -> 0.344 Inexact Rounded
-pwsx3214 power 0.0118 0.5 -> 0.109 Inexact Rounded
-pwsx3215 power 0.119 0.5 -> 0.345 Inexact Rounded
-pwsx3216 power 0.0119 0.5 -> 0.109 Inexact Rounded
-pwsx3217 power 0.121 0.5 -> 0.348 Inexact Rounded
-pwsx3218 power 0.0121 0.5 -> 0.110 Inexact Rounded
-pwsx3219 power 0.122 0.5 -> 0.349 Inexact Rounded
-pwsx3220 power 0.0122 0.5 -> 0.110 Inexact Rounded
-pwsx3221 power 0.123 0.5 -> 0.351 Inexact Rounded
-pwsx3222 power 0.0123 0.5 -> 0.111 Inexact Rounded
-pwsx3223 power 0.124 0.5 -> 0.352 Inexact Rounded
-pwsx3224 power 0.0124 0.5 -> 0.111 Inexact Rounded
-pwsx3225 power 0.125 0.5 -> 0.354 Inexact Rounded
-pwsx3226 power 0.0125 0.5 -> 0.112 Inexact Rounded
-pwsx3227 power 0.126 0.5 -> 0.355 Inexact Rounded
-pwsx3228 power 0.0126 0.5 -> 0.112 Inexact Rounded
-pwsx3229 power 0.127 0.5 -> 0.356 Inexact Rounded
-pwsx3230 power 0.0127 0.5 -> 0.113 Inexact Rounded
-pwsx3231 power 0.128 0.5 -> 0.358 Inexact Rounded
-pwsx3232 power 0.0128 0.5 -> 0.113 Inexact Rounded
-pwsx3233 power 0.129 0.5 -> 0.359 Inexact Rounded
-pwsx3234 power 0.0129 0.5 -> 0.114 Inexact Rounded
-pwsx3235 power 0.131 0.5 -> 0.362 Inexact Rounded
-pwsx3236 power 0.0131 0.5 -> 0.114 Inexact Rounded
-pwsx3237 power 0.132 0.5 -> 0.363 Inexact Rounded
-pwsx3238 power 0.0132 0.5 -> 0.115 Inexact Rounded
-pwsx3239 power 0.133 0.5 -> 0.365 Inexact Rounded
-pwsx3240 power 0.0133 0.5 -> 0.115 Inexact Rounded
-pwsx3241 power 0.134 0.5 -> 0.366 Inexact Rounded
-pwsx3242 power 0.0134 0.5 -> 0.116 Inexact Rounded
-pwsx3243 power 0.135 0.5 -> 0.367 Inexact Rounded
-pwsx3244 power 0.0135 0.5 -> 0.116 Inexact Rounded
-pwsx3245 power 0.136 0.5 -> 0.369 Inexact Rounded
-pwsx3246 power 0.0136 0.5 -> 0.117 Inexact Rounded
-pwsx3247 power 0.137 0.5 -> 0.370 Inexact Rounded
-pwsx3248 power 0.0137 0.5 -> 0.117 Inexact Rounded
-pwsx3249 power 0.138 0.5 -> 0.371 Inexact Rounded
-pwsx3250 power 0.0138 0.5 -> 0.117 Inexact Rounded
-pwsx3251 power 0.139 0.5 -> 0.373 Inexact Rounded
-pwsx3252 power 0.0139 0.5 -> 0.118 Inexact Rounded
-pwsx3253 power 0.141 0.5 -> 0.375 Inexact Rounded
-pwsx3254 power 0.0141 0.5 -> 0.119 Inexact Rounded
-pwsx3255 power 0.142 0.5 -> 0.377 Inexact Rounded
-pwsx3256 power 0.0142 0.5 -> 0.119 Inexact Rounded
-pwsx3257 power 0.143 0.5 -> 0.378 Inexact Rounded
-pwsx3258 power 0.0143 0.5 -> 0.120 Inexact Rounded
-pwsx3259 power 0.144 0.5 -> 0.379 Inexact Rounded
-pwsx3260 power 0.0144 0.5 -> 0.120 Inexact Rounded
-pwsx3261 power 0.145 0.5 -> 0.381 Inexact Rounded
-pwsx3262 power 0.0145 0.5 -> 0.120 Inexact Rounded
-pwsx3263 power 0.146 0.5 -> 0.382 Inexact Rounded
-pwsx3264 power 0.0146 0.5 -> 0.121 Inexact Rounded
-pwsx3265 power 0.147 0.5 -> 0.383 Inexact Rounded
-pwsx3266 power 0.0147 0.5 -> 0.121 Inexact Rounded
-pwsx3267 power 0.148 0.5 -> 0.385 Inexact Rounded
-pwsx3268 power 0.0148 0.5 -> 0.122 Inexact Rounded
-pwsx3269 power 0.149 0.5 -> 0.386 Inexact Rounded
-pwsx3270 power 0.0149 0.5 -> 0.122 Inexact Rounded
-pwsx3271 power 0.151 0.5 -> 0.389 Inexact Rounded
-pwsx3272 power 0.0151 0.5 -> 0.123 Inexact Rounded
-pwsx3273 power 0.152 0.5 -> 0.390 Inexact Rounded
-pwsx3274 power 0.0152 0.5 -> 0.123 Inexact Rounded
-pwsx3275 power 0.153 0.5 -> 0.391 Inexact Rounded
-pwsx3276 power 0.0153 0.5 -> 0.124 Inexact Rounded
-pwsx3277 power 0.154 0.5 -> 0.392 Inexact Rounded
-pwsx3278 power 0.0154 0.5 -> 0.124 Inexact Rounded
-pwsx3279 power 0.155 0.5 -> 0.394 Inexact Rounded
-pwsx3280 power 0.0155 0.5 -> 0.124 Inexact Rounded
-pwsx3281 power 0.156 0.5 -> 0.395 Inexact Rounded
-pwsx3282 power 0.0156 0.5 -> 0.125 Inexact Rounded
-pwsx3283 power 0.157 0.5 -> 0.396 Inexact Rounded
-pwsx3284 power 0.0157 0.5 -> 0.125 Inexact Rounded
-pwsx3285 power 0.158 0.5 -> 0.397 Inexact Rounded
-pwsx3286 power 0.0158 0.5 -> 0.126 Inexact Rounded
-pwsx3287 power 0.159 0.5 -> 0.399 Inexact Rounded
-pwsx3288 power 0.0159 0.5 -> 0.126 Inexact Rounded
-pwsx3289 power 0.161 0.5 -> 0.401 Inexact Rounded
-pwsx3290 power 0.0161 0.5 -> 0.127 Inexact Rounded
-pwsx3291 power 0.162 0.5 -> 0.402 Inexact Rounded
-pwsx3292 power 0.0162 0.5 -> 0.127 Inexact Rounded
-pwsx3293 power 0.163 0.5 -> 0.404 Inexact Rounded
-pwsx3294 power 0.0163 0.5 -> 0.128 Inexact Rounded
-pwsx3295 power 0.164 0.5 -> 0.405 Inexact Rounded
-pwsx3296 power 0.0164 0.5 -> 0.128 Inexact Rounded
-pwsx3297 power 0.165 0.5 -> 0.406 Inexact Rounded
-pwsx3298 power 0.0165 0.5 -> 0.128 Inexact Rounded
-pwsx3299 power 0.166 0.5 -> 0.407 Inexact Rounded
-pwsx3300 power 0.0166 0.5 -> 0.129 Inexact Rounded
-pwsx3301 power 0.167 0.5 -> 0.409 Inexact Rounded
-pwsx3302 power 0.0167 0.5 -> 0.129 Inexact Rounded
-pwsx3303 power 0.168 0.5 -> 0.410 Inexact Rounded
-pwsx3304 power 0.0168 0.5 -> 0.130 Inexact Rounded
-pwsx3305 power 0.169 0.5 -> 0.411 Inexact Rounded
-pwsx3306 power 0.0169 0.5 -> 0.130 Inexact Rounded
-pwsx3307 power 0.171 0.5 -> 0.414 Inexact Rounded
-pwsx3308 power 0.0171 0.5 -> 0.131 Inexact Rounded
-pwsx3309 power 0.172 0.5 -> 0.415 Inexact Rounded
-pwsx3310 power 0.0172 0.5 -> 0.131 Inexact Rounded
-pwsx3311 power 0.173 0.5 -> 0.416 Inexact Rounded
-pwsx3312 power 0.0173 0.5 -> 0.132 Inexact Rounded
-pwsx3313 power 0.174 0.5 -> 0.417 Inexact Rounded
-pwsx3314 power 0.0174 0.5 -> 0.132 Inexact Rounded
-pwsx3315 power 0.175 0.5 -> 0.418 Inexact Rounded
-pwsx3316 power 0.0175 0.5 -> 0.132 Inexact Rounded
-pwsx3317 power 0.176 0.5 -> 0.420 Inexact Rounded
-pwsx3318 power 0.0176 0.5 -> 0.133 Inexact Rounded
-pwsx3319 power 0.177 0.5 -> 0.421 Inexact Rounded
-pwsx3320 power 0.0177 0.5 -> 0.133 Inexact Rounded
-pwsx3321 power 0.178 0.5 -> 0.422 Inexact Rounded
-pwsx3322 power 0.0178 0.5 -> 0.133 Inexact Rounded
-pwsx3323 power 0.179 0.5 -> 0.423 Inexact Rounded
-pwsx3324 power 0.0179 0.5 -> 0.134 Inexact Rounded
-pwsx3325 power 0.181 0.5 -> 0.425 Inexact Rounded
-pwsx3326 power 0.0181 0.5 -> 0.135 Inexact Rounded
-pwsx3327 power 0.182 0.5 -> 0.427 Inexact Rounded
-pwsx3328 power 0.0182 0.5 -> 0.135 Inexact Rounded
-pwsx3329 power 0.183 0.5 -> 0.428 Inexact Rounded
-pwsx3330 power 0.0183 0.5 -> 0.135 Inexact Rounded
-pwsx3331 power 0.184 0.5 -> 0.429 Inexact Rounded
-pwsx3332 power 0.0184 0.5 -> 0.136 Inexact Rounded
-pwsx3333 power 0.185 0.5 -> 0.430 Inexact Rounded
-pwsx3334 power 0.0185 0.5 -> 0.136 Inexact Rounded
-pwsx3335 power 0.186 0.5 -> 0.431 Inexact Rounded
-pwsx3336 power 0.0186 0.5 -> 0.136 Inexact Rounded
-pwsx3337 power 0.187 0.5 -> 0.432 Inexact Rounded
-pwsx3338 power 0.0187 0.5 -> 0.137 Inexact Rounded
-pwsx3339 power 0.188 0.5 -> 0.434 Inexact Rounded
-pwsx3340 power 0.0188 0.5 -> 0.137 Inexact Rounded
-pwsx3341 power 0.189 0.5 -> 0.435 Inexact Rounded
-pwsx3342 power 0.0189 0.5 -> 0.137 Inexact Rounded
-pwsx3343 power 0.191 0.5 -> 0.437 Inexact Rounded
-pwsx3344 power 0.0191 0.5 -> 0.138 Inexact Rounded
-pwsx3345 power 0.192 0.5 -> 0.438 Inexact Rounded
-pwsx3346 power 0.0192 0.5 -> 0.139 Inexact Rounded
-pwsx3347 power 0.193 0.5 -> 0.439 Inexact Rounded
-pwsx3348 power 0.0193 0.5 -> 0.139 Inexact Rounded
-pwsx3349 power 0.194 0.5 -> 0.440 Inexact Rounded
-pwsx3350 power 0.0194 0.5 -> 0.139 Inexact Rounded
-pwsx3351 power 0.195 0.5 -> 0.442 Inexact Rounded
-pwsx3352 power 0.0195 0.5 -> 0.140 Inexact Rounded
-pwsx3353 power 0.196 0.5 -> 0.443 Inexact Rounded
-pwsx3354 power 0.0196 0.5 -> 0.140 Inexact Rounded
-pwsx3355 power 0.197 0.5 -> 0.444 Inexact Rounded
-pwsx3356 power 0.0197 0.5 -> 0.140 Inexact Rounded
-pwsx3357 power 0.198 0.5 -> 0.445 Inexact Rounded
-pwsx3358 power 0.0198 0.5 -> 0.141 Inexact Rounded
-pwsx3359 power 0.199 0.5 -> 0.446 Inexact Rounded
-pwsx3360 power 0.0199 0.5 -> 0.141 Inexact Rounded
-pwsx3361 power 0.201 0.5 -> 0.448 Inexact Rounded
-pwsx3362 power 0.0201 0.5 -> 0.142 Inexact Rounded
-pwsx3363 power 0.202 0.5 -> 0.449 Inexact Rounded
-pwsx3364 power 0.0202 0.5 -> 0.142 Inexact Rounded
-pwsx3365 power 0.203 0.5 -> 0.451 Inexact Rounded
-pwsx3366 power 0.0203 0.5 -> 0.142 Inexact Rounded
-pwsx3367 power 0.204 0.5 -> 0.452 Inexact Rounded
-pwsx3368 power 0.0204 0.5 -> 0.143 Inexact Rounded
-pwsx3369 power 0.205 0.5 -> 0.453 Inexact Rounded
-pwsx3370 power 0.0205 0.5 -> 0.143 Inexact Rounded
-pwsx3371 power 0.206 0.5 -> 0.454 Inexact Rounded
-pwsx3372 power 0.0206 0.5 -> 0.144 Inexact Rounded
-pwsx3373 power 0.207 0.5 -> 0.455 Inexact Rounded
-pwsx3374 power 0.0207 0.5 -> 0.144 Inexact Rounded
-pwsx3375 power 0.208 0.5 -> 0.456 Inexact Rounded
-pwsx3376 power 0.0208 0.5 -> 0.144 Inexact Rounded
-pwsx3377 power 0.209 0.5 -> 0.457 Inexact Rounded
-pwsx3378 power 0.0209 0.5 -> 0.145 Inexact Rounded
-pwsx3379 power 0.211 0.5 -> 0.459 Inexact Rounded
-pwsx3380 power 0.0211 0.5 -> 0.145 Inexact Rounded
-pwsx3381 power 0.212 0.5 -> 0.460 Inexact Rounded
-pwsx3382 power 0.0212 0.5 -> 0.146 Inexact Rounded
-pwsx3383 power 0.213 0.5 -> 0.462 Inexact Rounded
-pwsx3384 power 0.0213 0.5 -> 0.146 Inexact Rounded
-pwsx3385 power 0.214 0.5 -> 0.463 Inexact Rounded
-pwsx3386 power 0.0214 0.5 -> 0.146 Inexact Rounded
-pwsx3387 power 0.215 0.5 -> 0.464 Inexact Rounded
-pwsx3388 power 0.0215 0.5 -> 0.147 Inexact Rounded
-pwsx3389 power 0.216 0.5 -> 0.465 Inexact Rounded
-pwsx3390 power 0.0216 0.5 -> 0.147 Inexact Rounded
-pwsx3391 power 0.217 0.5 -> 0.466 Inexact Rounded
-pwsx3392 power 0.0217 0.5 -> 0.147 Inexact Rounded
-pwsx3393 power 0.218 0.5 -> 0.467 Inexact Rounded
-pwsx3394 power 0.0218 0.5 -> 0.148 Inexact Rounded
-pwsx3395 power 0.219 0.5 -> 0.468 Inexact Rounded
-pwsx3396 power 0.0219 0.5 -> 0.148 Inexact Rounded
-pwsx3397 power 0.221 0.5 -> 0.470 Inexact Rounded
-pwsx3398 power 0.0221 0.5 -> 0.149 Inexact Rounded
-pwsx3399 power 0.222 0.5 -> 0.471 Inexact Rounded
-pwsx3400 power 0.0222 0.5 -> 0.149 Inexact Rounded
-pwsx3401 power 0.223 0.5 -> 0.472 Inexact Rounded
-pwsx3402 power 0.0223 0.5 -> 0.149 Inexact Rounded
-pwsx3403 power 0.224 0.5 -> 0.473 Inexact Rounded
-pwsx3404 power 0.0224 0.5 -> 0.150 Inexact Rounded
-pwsx3405 power 0.225 0.5 -> 0.474 Inexact Rounded
-pwsx3406 power 0.0225 0.5 -> 0.150 Inexact Rounded
-pwsx3407 power 0.226 0.5 -> 0.475 Inexact Rounded
-pwsx3408 power 0.0226 0.5 -> 0.150 Inexact Rounded
-pwsx3409 power 0.227 0.5 -> 0.476 Inexact Rounded
-pwsx3410 power 0.0227 0.5 -> 0.151 Inexact Rounded
-pwsx3411 power 0.228 0.5 -> 0.477 Inexact Rounded
-pwsx3412 power 0.0228 0.5 -> 0.151 Inexact Rounded
-pwsx3413 power 0.229 0.5 -> 0.479 Inexact Rounded
-pwsx3414 power 0.0229 0.5 -> 0.151 Inexact Rounded
-pwsx3415 power 0.231 0.5 -> 0.481 Inexact Rounded
-pwsx3416 power 0.0231 0.5 -> 0.152 Inexact Rounded
-pwsx3417 power 0.232 0.5 -> 0.482 Inexact Rounded
-pwsx3418 power 0.0232 0.5 -> 0.152 Inexact Rounded
-pwsx3419 power 0.233 0.5 -> 0.483 Inexact Rounded
-pwsx3420 power 0.0233 0.5 -> 0.153 Inexact Rounded
-pwsx3421 power 0.234 0.5 -> 0.484 Inexact Rounded
-pwsx3422 power 0.0234 0.5 -> 0.153 Inexact Rounded
-pwsx3423 power 0.235 0.5 -> 0.485 Inexact Rounded
-pwsx3424 power 0.0235 0.5 -> 0.153 Inexact Rounded
-pwsx3425 power 0.236 0.5 -> 0.486 Inexact Rounded
-pwsx3426 power 0.0236 0.5 -> 0.154 Inexact Rounded
-pwsx3427 power 0.237 0.5 -> 0.487 Inexact Rounded
-pwsx3428 power 0.0237 0.5 -> 0.154 Inexact Rounded
-pwsx3429 power 0.238 0.5 -> 0.488 Inexact Rounded
-pwsx3430 power 0.0238 0.5 -> 0.154 Inexact Rounded
-pwsx3431 power 0.239 0.5 -> 0.489 Inexact Rounded
-pwsx3432 power 0.0239 0.5 -> 0.155 Inexact Rounded
-pwsx3433 power 0.241 0.5 -> 0.491 Inexact Rounded
-pwsx3434 power 0.0241 0.5 -> 0.155 Inexact Rounded
-pwsx3435 power 0.242 0.5 -> 0.492 Inexact Rounded
-pwsx3436 power 0.0242 0.5 -> 0.156 Inexact Rounded
-pwsx3437 power 0.243 0.5 -> 0.493 Inexact Rounded
-pwsx3438 power 0.0243 0.5 -> 0.156 Inexact Rounded
-pwsx3439 power 0.244 0.5 -> 0.494 Inexact Rounded
-pwsx3440 power 0.0244 0.5 -> 0.156 Inexact Rounded
-pwsx3441 power 0.245 0.5 -> 0.495 Inexact Rounded
-pwsx3442 power 0.0245 0.5 -> 0.157 Inexact Rounded
-pwsx3443 power 0.246 0.5 -> 0.496 Inexact Rounded
-pwsx3444 power 0.0246 0.5 -> 0.157 Inexact Rounded
-pwsx3445 power 0.247 0.5 -> 0.497 Inexact Rounded
-pwsx3446 power 0.0247 0.5 -> 0.157 Inexact Rounded
-pwsx3447 power 0.248 0.5 -> 0.498 Inexact Rounded
-pwsx3448 power 0.0248 0.5 -> 0.157 Inexact Rounded
-pwsx3449 power 0.249 0.5 -> 0.499 Inexact Rounded
-pwsx3450 power 0.0249 0.5 -> 0.158 Inexact Rounded
-pwsx3451 power 0.251 0.5 -> 0.501 Inexact Rounded
-pwsx3452 power 0.0251 0.5 -> 0.158 Inexact Rounded
-pwsx3453 power 0.252 0.5 -> 0.502 Inexact Rounded
-pwsx3454 power 0.0252 0.5 -> 0.159 Inexact Rounded
-pwsx3455 power 0.253 0.5 -> 0.503 Inexact Rounded
-pwsx3456 power 0.0253 0.5 -> 0.159 Inexact Rounded
-pwsx3457 power 0.254 0.5 -> 0.504 Inexact Rounded
-pwsx3458 power 0.0254 0.5 -> 0.159 Inexact Rounded
-pwsx3459 power 0.255 0.5 -> 0.505 Inexact Rounded
-pwsx3460 power 0.0255 0.5 -> 0.160 Inexact Rounded
-pwsx3461 power 0.256 0.5 -> 0.506 Inexact Rounded
-pwsx3462 power 0.0256 0.5 -> 0.160 Inexact Rounded
-pwsx3463 power 0.257 0.5 -> 0.507 Inexact Rounded
-pwsx3464 power 0.0257 0.5 -> 0.160 Inexact Rounded
-pwsx3465 power 0.258 0.5 -> 0.508 Inexact Rounded
-pwsx3466 power 0.0258 0.5 -> 0.161 Inexact Rounded
-pwsx3467 power 0.259 0.5 -> 0.509 Inexact Rounded
-pwsx3468 power 0.0259 0.5 -> 0.161 Inexact Rounded
-pwsx3469 power 0.261 0.5 -> 0.511 Inexact Rounded
-pwsx3470 power 0.0261 0.5 -> 0.162 Inexact Rounded
-pwsx3471 power 0.262 0.5 -> 0.512 Inexact Rounded
-pwsx3472 power 0.0262 0.5 -> 0.162 Inexact Rounded
-pwsx3473 power 0.263 0.5 -> 0.513 Inexact Rounded
-pwsx3474 power 0.0263 0.5 -> 0.162 Inexact Rounded
-pwsx3475 power 0.264 0.5 -> 0.514 Inexact Rounded
-pwsx3476 power 0.0264 0.5 -> 0.162 Inexact Rounded
-pwsx3477 power 0.265 0.5 -> 0.515 Inexact Rounded
-pwsx3478 power 0.0265 0.5 -> 0.163 Inexact Rounded
-pwsx3479 power 0.266 0.5 -> 0.516 Inexact Rounded
-pwsx3480 power 0.0266 0.5 -> 0.163 Inexact Rounded
-pwsx3481 power 0.267 0.5 -> 0.517 Inexact Rounded
-pwsx3482 power 0.0267 0.5 -> 0.163 Inexact Rounded
-pwsx3483 power 0.268 0.5 -> 0.518 Inexact Rounded
-pwsx3484 power 0.0268 0.5 -> 0.164 Inexact Rounded
-pwsx3485 power 0.269 0.5 -> 0.519 Inexact Rounded
-pwsx3486 power 0.0269 0.5 -> 0.164 Inexact Rounded
-pwsx3487 power 0.271 0.5 -> 0.521 Inexact Rounded
-pwsx3488 power 0.0271 0.5 -> 0.165 Inexact Rounded
-pwsx3489 power 0.272 0.5 -> 0.522 Inexact Rounded
-pwsx3490 power 0.0272 0.5 -> 0.165 Inexact Rounded
-pwsx3491 power 0.273 0.5 -> 0.522 Inexact Rounded
-pwsx3492 power 0.0273 0.5 -> 0.165 Inexact Rounded
-pwsx3493 power 0.274 0.5 -> 0.523 Inexact Rounded
-pwsx3494 power 0.0274 0.5 -> 0.166 Inexact Rounded
-pwsx3495 power 0.275 0.5 -> 0.524 Inexact Rounded
-pwsx3496 power 0.0275 0.5 -> 0.166 Inexact Rounded
-pwsx3497 power 0.276 0.5 -> 0.525 Inexact Rounded
-pwsx3498 power 0.0276 0.5 -> 0.166 Inexact Rounded
-pwsx3499 power 0.277 0.5 -> 0.526 Inexact Rounded
-pwsx3500 power 0.0277 0.5 -> 0.166 Inexact Rounded
-pwsx3501 power 0.278 0.5 -> 0.527 Inexact Rounded
-pwsx3502 power 0.0278 0.5 -> 0.167 Inexact Rounded
-pwsx3503 power 0.279 0.5 -> 0.528 Inexact Rounded
-pwsx3504 power 0.0279 0.5 -> 0.167 Inexact Rounded
-pwsx3505 power 0.281 0.5 -> 0.530 Inexact Rounded
-pwsx3506 power 0.0281 0.5 -> 0.168 Inexact Rounded
-pwsx3507 power 0.282 0.5 -> 0.531 Inexact Rounded
-pwsx3508 power 0.0282 0.5 -> 0.168 Inexact Rounded
-pwsx3509 power 0.283 0.5 -> 0.532 Inexact Rounded
-pwsx3510 power 0.0283 0.5 -> 0.168 Inexact Rounded
-pwsx3511 power 0.284 0.5 -> 0.533 Inexact Rounded
-pwsx3512 power 0.0284 0.5 -> 0.169 Inexact Rounded
-pwsx3513 power 0.285 0.5 -> 0.534 Inexact Rounded
-pwsx3514 power 0.0285 0.5 -> 0.169 Inexact Rounded
-pwsx3515 power 0.286 0.5 -> 0.535 Inexact Rounded
-pwsx3516 power 0.0286 0.5 -> 0.169 Inexact Rounded
-pwsx3517 power 0.287 0.5 -> 0.536 Inexact Rounded
-pwsx3518 power 0.0287 0.5 -> 0.169 Inexact Rounded
-pwsx3519 power 0.288 0.5 -> 0.537 Inexact Rounded
-pwsx3520 power 0.0288 0.5 -> 0.170 Inexact Rounded
-pwsx3521 power 0.289 0.5 -> 0.538 Inexact Rounded
-pwsx3522 power 0.0289 0.5 -> 0.170 Inexact Rounded
-pwsx3523 power 0.291 0.5 -> 0.539 Inexact Rounded
-pwsx3524 power 0.0291 0.5 -> 0.171 Inexact Rounded
-pwsx3525 power 0.292 0.5 -> 0.540 Inexact Rounded
-pwsx3526 power 0.0292 0.5 -> 0.171 Inexact Rounded
-pwsx3527 power 0.293 0.5 -> 0.541 Inexact Rounded
-pwsx3528 power 0.0293 0.5 -> 0.171 Inexact Rounded
-pwsx3529 power 0.294 0.5 -> 0.542 Inexact Rounded
-pwsx3530 power 0.0294 0.5 -> 0.171 Inexact Rounded
-pwsx3531 power 0.295 0.5 -> 0.543 Inexact Rounded
-pwsx3532 power 0.0295 0.5 -> 0.172 Inexact Rounded
-pwsx3533 power 0.296 0.5 -> 0.544 Inexact Rounded
-pwsx3534 power 0.0296 0.5 -> 0.172 Inexact Rounded
-pwsx3535 power 0.297 0.5 -> 0.545 Inexact Rounded
-pwsx3536 power 0.0297 0.5 -> 0.172 Inexact Rounded
-pwsx3537 power 0.298 0.5 -> 0.546 Inexact Rounded
-pwsx3538 power 0.0298 0.5 -> 0.173 Inexact Rounded
-pwsx3539 power 0.299 0.5 -> 0.547 Inexact Rounded
-pwsx3540 power 0.0299 0.5 -> 0.173 Inexact Rounded
-pwsx3541 power 0.301 0.5 -> 0.549 Inexact Rounded
-pwsx3542 power 0.0301 0.5 -> 0.173 Inexact Rounded
-pwsx3543 power 0.302 0.5 -> 0.550 Inexact Rounded
-pwsx3544 power 0.0302 0.5 -> 0.174 Inexact Rounded
-pwsx3545 power 0.303 0.5 -> 0.550 Inexact Rounded
-pwsx3546 power 0.0303 0.5 -> 0.174 Inexact Rounded
-pwsx3547 power 0.304 0.5 -> 0.551 Inexact Rounded
-pwsx3548 power 0.0304 0.5 -> 0.174 Inexact Rounded
-pwsx3549 power 0.305 0.5 -> 0.552 Inexact Rounded
-pwsx3550 power 0.0305 0.5 -> 0.175 Inexact Rounded
-pwsx3551 power 0.306 0.5 -> 0.553 Inexact Rounded
-pwsx3552 power 0.0306 0.5 -> 0.175 Inexact Rounded
-pwsx3553 power 0.307 0.5 -> 0.554 Inexact Rounded
-pwsx3554 power 0.0307 0.5 -> 0.175 Inexact Rounded
-pwsx3555 power 0.308 0.5 -> 0.555 Inexact Rounded
-pwsx3556 power 0.0308 0.5 -> 0.175 Inexact Rounded
-pwsx3557 power 0.309 0.5 -> 0.556 Inexact Rounded
-pwsx3558 power 0.0309 0.5 -> 0.176 Inexact Rounded
-pwsx3559 power 0.311 0.5 -> 0.558 Inexact Rounded
-pwsx3560 power 0.0311 0.5 -> 0.176 Inexact Rounded
-pwsx3561 power 0.312 0.5 -> 0.559 Inexact Rounded
-pwsx3562 power 0.0312 0.5 -> 0.177 Inexact Rounded
-pwsx3563 power 0.313 0.5 -> 0.559 Inexact Rounded
-pwsx3564 power 0.0313 0.5 -> 0.177 Inexact Rounded
-pwsx3565 power 0.314 0.5 -> 0.560 Inexact Rounded
-pwsx3566 power 0.0314 0.5 -> 0.177 Inexact Rounded
-pwsx3567 power 0.315 0.5 -> 0.561 Inexact Rounded
-pwsx3568 power 0.0315 0.5 -> 0.177 Inexact Rounded
-pwsx3569 power 0.316 0.5 -> 0.562 Inexact Rounded
-pwsx3570 power 0.0316 0.5 -> 0.178 Inexact Rounded
-pwsx3571 power 0.317 0.5 -> 0.563 Inexact Rounded
-pwsx3572 power 0.0317 0.5 -> 0.178 Inexact Rounded
-pwsx3573 power 0.318 0.5 -> 0.564 Inexact Rounded
-pwsx3574 power 0.0318 0.5 -> 0.178 Inexact Rounded
-pwsx3575 power 0.319 0.5 -> 0.565 Inexact Rounded
-pwsx3576 power 0.0319 0.5 -> 0.179 Inexact Rounded
-pwsx3577 power 0.321 0.5 -> 0.567 Inexact Rounded
-pwsx3578 power 0.0321 0.5 -> 0.179 Inexact Rounded
-pwsx3579 power 0.322 0.5 -> 0.567 Inexact Rounded
-pwsx3580 power 0.0322 0.5 -> 0.179 Inexact Rounded
-pwsx3581 power 0.323 0.5 -> 0.568 Inexact Rounded
-pwsx3582 power 0.0323 0.5 -> 0.180 Inexact Rounded
-pwsx3583 power 0.324 0.5 -> 0.569 Inexact Rounded
-pwsx3584 power 0.0324 0.5 -> 0.180 Inexact Rounded
-pwsx3585 power 0.325 0.5 -> 0.570 Inexact Rounded
-pwsx3586 power 0.0325 0.5 -> 0.180 Inexact Rounded
-pwsx3587 power 0.326 0.5 -> 0.571 Inexact Rounded
-pwsx3588 power 0.0326 0.5 -> 0.181 Inexact Rounded
-pwsx3589 power 0.327 0.5 -> 0.572 Inexact Rounded
-pwsx3590 power 0.0327 0.5 -> 0.181 Inexact Rounded
-pwsx3591 power 0.328 0.5 -> 0.573 Inexact Rounded
-pwsx3592 power 0.0328 0.5 -> 0.181 Inexact Rounded
-pwsx3593 power 0.329 0.5 -> 0.574 Inexact Rounded
-pwsx3594 power 0.0329 0.5 -> 0.181 Inexact Rounded
-pwsx3595 power 0.331 0.5 -> 0.575 Inexact Rounded
-pwsx3596 power 0.0331 0.5 -> 0.182 Inexact Rounded
-pwsx3597 power 0.332 0.5 -> 0.576 Inexact Rounded
-pwsx3598 power 0.0332 0.5 -> 0.182 Inexact Rounded
-pwsx3599 power 0.333 0.5 -> 0.577 Inexact Rounded
-pwsx3600 power 0.0333 0.5 -> 0.182 Inexact Rounded
-pwsx3601 power 0.334 0.5 -> 0.578 Inexact Rounded
-pwsx3602 power 0.0334 0.5 -> 0.183 Inexact Rounded
-pwsx3603 power 0.335 0.5 -> 0.579 Inexact Rounded
-pwsx3604 power 0.0335 0.5 -> 0.183 Inexact Rounded
-pwsx3605 power 0.336 0.5 -> 0.580 Inexact Rounded
-pwsx3606 power 0.0336 0.5 -> 0.183 Inexact Rounded
-pwsx3607 power 0.337 0.5 -> 0.581 Inexact Rounded
-pwsx3608 power 0.0337 0.5 -> 0.184 Inexact Rounded
-pwsx3609 power 0.338 0.5 -> 0.581 Inexact Rounded
-pwsx3610 power 0.0338 0.5 -> 0.184 Inexact Rounded
-pwsx3611 power 0.339 0.5 -> 0.582 Inexact Rounded
-pwsx3612 power 0.0339 0.5 -> 0.184 Inexact Rounded
-pwsx3613 power 0.341 0.5 -> 0.584 Inexact Rounded
-pwsx3614 power 0.0341 0.5 -> 0.185 Inexact Rounded
-pwsx3615 power 0.342 0.5 -> 0.585 Inexact Rounded
-pwsx3616 power 0.0342 0.5 -> 0.185 Inexact Rounded
-pwsx3617 power 0.343 0.5 -> 0.586 Inexact Rounded
-pwsx3618 power 0.0343 0.5 -> 0.185 Inexact Rounded
-pwsx3619 power 0.344 0.5 -> 0.587 Inexact Rounded
-pwsx3620 power 0.0344 0.5 -> 0.185 Inexact Rounded
-pwsx3621 power 0.345 0.5 -> 0.587 Inexact Rounded
-pwsx3622 power 0.0345 0.5 -> 0.186 Inexact Rounded
-pwsx3623 power 0.346 0.5 -> 0.588 Inexact Rounded
-pwsx3624 power 0.0346 0.5 -> 0.186 Inexact Rounded
-pwsx3625 power 0.347 0.5 -> 0.589 Inexact Rounded
-pwsx3626 power 0.0347 0.5 -> 0.186 Inexact Rounded
-pwsx3627 power 0.348 0.5 -> 0.590 Inexact Rounded
-pwsx3628 power 0.0348 0.5 -> 0.187 Inexact Rounded
-pwsx3629 power 0.349 0.5 -> 0.591 Inexact Rounded
-pwsx3630 power 0.0349 0.5 -> 0.187 Inexact Rounded
-pwsx3631 power 0.351 0.5 -> 0.592 Inexact Rounded
-pwsx3632 power 0.0351 0.5 -> 0.187 Inexact Rounded
-pwsx3633 power 0.352 0.5 -> 0.593 Inexact Rounded
-pwsx3634 power 0.0352 0.5 -> 0.188 Inexact Rounded
-pwsx3635 power 0.353 0.5 -> 0.594 Inexact Rounded
-pwsx3636 power 0.0353 0.5 -> 0.188 Inexact Rounded
-pwsx3637 power 0.354 0.5 -> 0.595 Inexact Rounded
-pwsx3638 power 0.0354 0.5 -> 0.188 Inexact Rounded
-pwsx3639 power 0.355 0.5 -> 0.596 Inexact Rounded
-pwsx3640 power 0.0355 0.5 -> 0.188 Inexact Rounded
-pwsx3641 power 0.356 0.5 -> 0.597 Inexact Rounded
-pwsx3642 power 0.0356 0.5 -> 0.189 Inexact Rounded
-pwsx3643 power 0.357 0.5 -> 0.597 Inexact Rounded
-pwsx3644 power 0.0357 0.5 -> 0.189 Inexact Rounded
-pwsx3645 power 0.358 0.5 -> 0.598 Inexact Rounded
-pwsx3646 power 0.0358 0.5 -> 0.189 Inexact Rounded
-pwsx3647 power 0.359 0.5 -> 0.599 Inexact Rounded
-pwsx3648 power 0.0359 0.5 -> 0.189 Inexact Rounded
-pwsx3649 power 0.361 0.5 -> 0.601 Inexact Rounded
-pwsx3650 power 0.0361 0.5 -> 0.190 Inexact Rounded
-pwsx3651 power 0.362 0.5 -> 0.602 Inexact Rounded
-pwsx3652 power 0.0362 0.5 -> 0.190 Inexact Rounded
-pwsx3653 power 0.363 0.5 -> 0.602 Inexact Rounded
-pwsx3654 power 0.0363 0.5 -> 0.191 Inexact Rounded
-pwsx3655 power 0.364 0.5 -> 0.603 Inexact Rounded
-pwsx3656 power 0.0364 0.5 -> 0.191 Inexact Rounded
-pwsx3657 power 0.365 0.5 -> 0.604 Inexact Rounded
-pwsx3658 power 0.0365 0.5 -> 0.191 Inexact Rounded
-pwsx3659 power 0.366 0.5 -> 0.605 Inexact Rounded
-pwsx3660 power 0.0366 0.5 -> 0.191 Inexact Rounded
-pwsx3661 power 0.367 0.5 -> 0.606 Inexact Rounded
-pwsx3662 power 0.0367 0.5 -> 0.192 Inexact Rounded
-pwsx3663 power 0.368 0.5 -> 0.607 Inexact Rounded
-pwsx3664 power 0.0368 0.5 -> 0.192 Inexact Rounded
-pwsx3665 power 0.369 0.5 -> 0.607 Inexact Rounded
-pwsx3666 power 0.0369 0.5 -> 0.192 Inexact Rounded
-pwsx3667 power 0.371 0.5 -> 0.609 Inexact Rounded
-pwsx3668 power 0.0371 0.5 -> 0.193 Inexact Rounded
-pwsx3669 power 0.372 0.5 -> 0.610 Inexact Rounded
-pwsx3670 power 0.0372 0.5 -> 0.193 Inexact Rounded
-pwsx3671 power 0.373 0.5 -> 0.611 Inexact Rounded
-pwsx3672 power 0.0373 0.5 -> 0.193 Inexact Rounded
-pwsx3673 power 0.374 0.5 -> 0.612 Inexact Rounded
-pwsx3674 power 0.0374 0.5 -> 0.193 Inexact Rounded
-pwsx3675 power 0.375 0.5 -> 0.612 Inexact Rounded
-pwsx3676 power 0.0375 0.5 -> 0.194 Inexact Rounded
-pwsx3677 power 0.376 0.5 -> 0.613 Inexact Rounded
-pwsx3678 power 0.0376 0.5 -> 0.194 Inexact Rounded
-pwsx3679 power 0.377 0.5 -> 0.614 Inexact Rounded
-pwsx3680 power 0.0377 0.5 -> 0.194 Inexact Rounded
-pwsx3681 power 0.378 0.5 -> 0.615 Inexact Rounded
-pwsx3682 power 0.0378 0.5 -> 0.194 Inexact Rounded
-pwsx3683 power 0.379 0.5 -> 0.616 Inexact Rounded
-pwsx3684 power 0.0379 0.5 -> 0.195 Inexact Rounded
-pwsx3685 power 0.381 0.5 -> 0.617 Inexact Rounded
-pwsx3686 power 0.0381 0.5 -> 0.195 Inexact Rounded
-pwsx3687 power 0.382 0.5 -> 0.618 Inexact Rounded
-pwsx3688 power 0.0382 0.5 -> 0.195 Inexact Rounded
-pwsx3689 power 0.383 0.5 -> 0.619 Inexact Rounded
-pwsx3690 power 0.0383 0.5 -> 0.196 Inexact Rounded
-pwsx3691 power 0.384 0.5 -> 0.620 Inexact Rounded
-pwsx3692 power 0.0384 0.5 -> 0.196 Inexact Rounded
-pwsx3693 power 0.385 0.5 -> 0.620 Inexact Rounded
-pwsx3694 power 0.0385 0.5 -> 0.196 Inexact Rounded
-pwsx3695 power 0.386 0.5 -> 0.621 Inexact Rounded
-pwsx3696 power 0.0386 0.5 -> 0.196 Inexact Rounded
-pwsx3697 power 0.387 0.5 -> 0.622 Inexact Rounded
-pwsx3698 power 0.0387 0.5 -> 0.197 Inexact Rounded
-pwsx3699 power 0.388 0.5 -> 0.623 Inexact Rounded
-pwsx3700 power 0.0388 0.5 -> 0.197 Inexact Rounded
-pwsx3701 power 0.389 0.5 -> 0.624 Inexact Rounded
-pwsx3702 power 0.0389 0.5 -> 0.197 Inexact Rounded
-pwsx3703 power 0.391 0.5 -> 0.625 Inexact Rounded
-pwsx3704 power 0.0391 0.5 -> 0.198 Inexact Rounded
-pwsx3705 power 0.392 0.5 -> 0.626 Inexact Rounded
-pwsx3706 power 0.0392 0.5 -> 0.198 Inexact Rounded
-pwsx3707 power 0.393 0.5 -> 0.627 Inexact Rounded
-pwsx3708 power 0.0393 0.5 -> 0.198 Inexact Rounded
-pwsx3709 power 0.394 0.5 -> 0.628 Inexact Rounded
-pwsx3710 power 0.0394 0.5 -> 0.198 Inexact Rounded
-pwsx3711 power 0.395 0.5 -> 0.628 Inexact Rounded
-pwsx3712 power 0.0395 0.5 -> 0.199 Inexact Rounded
-pwsx3713 power 0.396 0.5 -> 0.629 Inexact Rounded
-pwsx3714 power 0.0396 0.5 -> 0.199 Inexact Rounded
-pwsx3715 power 0.397 0.5 -> 0.630 Inexact Rounded
-pwsx3716 power 0.0397 0.5 -> 0.199 Inexact Rounded
-pwsx3717 power 0.398 0.5 -> 0.631 Inexact Rounded
-pwsx3718 power 0.0398 0.5 -> 0.199 Inexact Rounded
-pwsx3719 power 0.399 0.5 -> 0.632 Inexact Rounded
-pwsx3720 power 0.0399 0.5 -> 0.200 Inexact Rounded
-pwsx3721 power 0.401 0.5 -> 0.633 Inexact Rounded
-pwsx3722 power 0.0401 0.5 -> 0.200 Inexact Rounded
-pwsx3723 power 0.402 0.5 -> 0.634 Inexact Rounded
-pwsx3724 power 0.0402 0.5 -> 0.200 Inexact Rounded
-pwsx3725 power 0.403 0.5 -> 0.635 Inexact Rounded
-pwsx3726 power 0.0403 0.5 -> 0.201 Inexact Rounded
-pwsx3727 power 0.404 0.5 -> 0.636 Inexact Rounded
-pwsx3728 power 0.0404 0.5 -> 0.201 Inexact Rounded
-pwsx3729 power 0.405 0.5 -> 0.636 Inexact Rounded
-pwsx3730 power 0.0405 0.5 -> 0.201 Inexact Rounded
-pwsx3731 power 0.406 0.5 -> 0.637 Inexact Rounded
-pwsx3732 power 0.0406 0.5 -> 0.201 Inexact Rounded
-pwsx3733 power 0.407 0.5 -> 0.638 Inexact Rounded
-pwsx3734 power 0.0407 0.5 -> 0.202 Inexact Rounded
-pwsx3735 power 0.408 0.5 -> 0.639 Inexact Rounded
-pwsx3736 power 0.0408 0.5 -> 0.202 Inexact Rounded
-pwsx3737 power 0.409 0.5 -> 0.640 Inexact Rounded
-pwsx3738 power 0.0409 0.5 -> 0.202 Inexact Rounded
-pwsx3739 power 0.411 0.5 -> 0.641 Inexact Rounded
-pwsx3740 power 0.0411 0.5 -> 0.203 Inexact Rounded
-pwsx3741 power 0.412 0.5 -> 0.642 Inexact Rounded
-pwsx3742 power 0.0412 0.5 -> 0.203 Inexact Rounded
-pwsx3743 power 0.413 0.5 -> 0.643 Inexact Rounded
-pwsx3744 power 0.0413 0.5 -> 0.203 Inexact Rounded
-pwsx3745 power 0.414 0.5 -> 0.643 Inexact Rounded
-pwsx3746 power 0.0414 0.5 -> 0.203 Inexact Rounded
-pwsx3747 power 0.415 0.5 -> 0.644 Inexact Rounded
-pwsx3748 power 0.0415 0.5 -> 0.204 Inexact Rounded
-pwsx3749 power 0.416 0.5 -> 0.645 Inexact Rounded
-pwsx3750 power 0.0416 0.5 -> 0.204 Inexact Rounded
-pwsx3751 power 0.417 0.5 -> 0.646 Inexact Rounded
-pwsx3752 power 0.0417 0.5 -> 0.204 Inexact Rounded
-pwsx3753 power 0.418 0.5 -> 0.647 Inexact Rounded
-pwsx3754 power 0.0418 0.5 -> 0.204 Inexact Rounded
-pwsx3755 power 0.419 0.5 -> 0.647 Inexact Rounded
-pwsx3756 power 0.0419 0.5 -> 0.205 Inexact Rounded
-pwsx3757 power 0.421 0.5 -> 0.649 Inexact Rounded
-pwsx3758 power 0.0421 0.5 -> 0.205 Inexact Rounded
-pwsx3759 power 0.422 0.5 -> 0.650 Inexact Rounded
-pwsx3760 power 0.0422 0.5 -> 0.205 Inexact Rounded
-pwsx3761 power 0.423 0.5 -> 0.650 Inexact Rounded
-pwsx3762 power 0.0423 0.5 -> 0.206 Inexact Rounded
-pwsx3763 power 0.424 0.5 -> 0.651 Inexact Rounded
-pwsx3764 power 0.0424 0.5 -> 0.206 Inexact Rounded
-pwsx3765 power 0.425 0.5 -> 0.652 Inexact Rounded
-pwsx3766 power 0.0425 0.5 -> 0.206 Inexact Rounded
-pwsx3767 power 0.426 0.5 -> 0.653 Inexact Rounded
-pwsx3768 power 0.0426 0.5 -> 0.206 Inexact Rounded
-pwsx3769 power 0.427 0.5 -> 0.653 Inexact Rounded
-pwsx3770 power 0.0427 0.5 -> 0.207 Inexact Rounded
-pwsx3771 power 0.428 0.5 -> 0.654 Inexact Rounded
-pwsx3772 power 0.0428 0.5 -> 0.207 Inexact Rounded
-pwsx3773 power 0.429 0.5 -> 0.655 Inexact Rounded
-pwsx3774 power 0.0429 0.5 -> 0.207 Inexact Rounded
-pwsx3775 power 0.431 0.5 -> 0.657 Inexact Rounded
-pwsx3776 power 0.0431 0.5 -> 0.208 Inexact Rounded
-pwsx3777 power 0.432 0.5 -> 0.657 Inexact Rounded
-pwsx3778 power 0.0432 0.5 -> 0.208 Inexact Rounded
-pwsx3779 power 0.433 0.5 -> 0.658 Inexact Rounded
-pwsx3780 power 0.0433 0.5 -> 0.208 Inexact Rounded
-pwsx3781 power 0.434 0.5 -> 0.659 Inexact Rounded
-pwsx3782 power 0.0434 0.5 -> 0.208 Inexact Rounded
-pwsx3783 power 0.435 0.5 -> 0.660 Inexact Rounded
-pwsx3784 power 0.0435 0.5 -> 0.209 Inexact Rounded
-pwsx3785 power 0.436 0.5 -> 0.660 Inexact Rounded
-pwsx3786 power 0.0436 0.5 -> 0.209 Inexact Rounded
-pwsx3787 power 0.437 0.5 -> 0.661 Inexact Rounded
-pwsx3788 power 0.0437 0.5 -> 0.209 Inexact Rounded
-pwsx3789 power 0.438 0.5 -> 0.662 Inexact Rounded
-pwsx3790 power 0.0438 0.5 -> 0.209 Inexact Rounded
-pwsx3791 power 0.439 0.5 -> 0.663 Inexact Rounded
-pwsx3792 power 0.0439 0.5 -> 0.210 Inexact Rounded
-pwsx3793 power 0.441 0.5 -> 0.664 Inexact Rounded
-pwsx3794 power 0.0441 0.5 -> 0.210 Inexact Rounded
-pwsx3795 power 0.442 0.5 -> 0.665 Inexact Rounded
-pwsx3796 power 0.0442 0.5 -> 0.210 Inexact Rounded
-pwsx3797 power 0.443 0.5 -> 0.666 Inexact Rounded
-pwsx3798 power 0.0443 0.5 -> 0.210 Inexact Rounded
-pwsx3799 power 0.444 0.5 -> 0.666 Inexact Rounded
-pwsx3800 power 0.0444 0.5 -> 0.211 Inexact Rounded
-pwsx3801 power 0.445 0.5 -> 0.667 Inexact Rounded
-pwsx3802 power 0.0445 0.5 -> 0.211 Inexact Rounded
-pwsx3803 power 0.446 0.5 -> 0.668 Inexact Rounded
-pwsx3804 power 0.0446 0.5 -> 0.211 Inexact Rounded
-pwsx3805 power 0.447 0.5 -> 0.669 Inexact Rounded
-pwsx3806 power 0.0447 0.5 -> 0.211 Inexact Rounded
-pwsx3807 power 0.448 0.5 -> 0.669 Inexact Rounded
-pwsx3808 power 0.0448 0.5 -> 0.212 Inexact Rounded
-pwsx3809 power 0.449 0.5 -> 0.670 Inexact Rounded
-pwsx3810 power 0.0449 0.5 -> 0.212 Inexact Rounded
-pwsx3811 power 0.451 0.5 -> 0.672 Inexact Rounded
-pwsx3812 power 0.0451 0.5 -> 0.212 Inexact Rounded
-pwsx3813 power 0.452 0.5 -> 0.672 Inexact Rounded
-pwsx3814 power 0.0452 0.5 -> 0.213 Inexact Rounded
-pwsx3815 power 0.453 0.5 -> 0.673 Inexact Rounded
-pwsx3816 power 0.0453 0.5 -> 0.213 Inexact Rounded
-pwsx3817 power 0.454 0.5 -> 0.674 Inexact Rounded
-pwsx3818 power 0.0454 0.5 -> 0.213 Inexact Rounded
-pwsx3819 power 0.455 0.5 -> 0.675 Inexact Rounded
-pwsx3820 power 0.0455 0.5 -> 0.213 Inexact Rounded
-pwsx3821 power 0.456 0.5 -> 0.675 Inexact Rounded
-pwsx3822 power 0.0456 0.5 -> 0.214 Inexact Rounded
-pwsx3823 power 0.457 0.5 -> 0.676 Inexact Rounded
-pwsx3824 power 0.0457 0.5 -> 0.214 Inexact Rounded
-pwsx3825 power 0.458 0.5 -> 0.677 Inexact Rounded
-pwsx3826 power 0.0458 0.5 -> 0.214 Inexact Rounded
-pwsx3827 power 0.459 0.5 -> 0.677 Inexact Rounded
-pwsx3828 power 0.0459 0.5 -> 0.214 Inexact Rounded
-pwsx3829 power 0.461 0.5 -> 0.679 Inexact Rounded
-pwsx3830 power 0.0461 0.5 -> 0.215 Inexact Rounded
-pwsx3831 power 0.462 0.5 -> 0.680 Inexact Rounded
-pwsx3832 power 0.0462 0.5 -> 0.215 Inexact Rounded
-pwsx3833 power 0.463 0.5 -> 0.680 Inexact Rounded
-pwsx3834 power 0.0463 0.5 -> 0.215 Inexact Rounded
-pwsx3835 power 0.464 0.5 -> 0.681 Inexact Rounded
-pwsx3836 power 0.0464 0.5 -> 0.215 Inexact Rounded
-pwsx3837 power 0.465 0.5 -> 0.682 Inexact Rounded
-pwsx3838 power 0.0465 0.5 -> 0.216 Inexact Rounded
-pwsx3839 power 0.466 0.5 -> 0.683 Inexact Rounded
-pwsx3840 power 0.0466 0.5 -> 0.216 Inexact Rounded
-pwsx3841 power 0.467 0.5 -> 0.683 Inexact Rounded
-pwsx3842 power 0.0467 0.5 -> 0.216 Inexact Rounded
-pwsx3843 power 0.468 0.5 -> 0.684 Inexact Rounded
-pwsx3844 power 0.0468 0.5 -> 0.216 Inexact Rounded
-pwsx3845 power 0.469 0.5 -> 0.685 Inexact Rounded
-pwsx3846 power 0.0469 0.5 -> 0.217 Inexact Rounded
-pwsx3847 power 0.471 0.5 -> 0.686 Inexact Rounded
-pwsx3848 power 0.0471 0.5 -> 0.217 Inexact Rounded
-pwsx3849 power 0.472 0.5 -> 0.687 Inexact Rounded
-pwsx3850 power 0.0472 0.5 -> 0.217 Inexact Rounded
-pwsx3851 power 0.473 0.5 -> 0.688 Inexact Rounded
-pwsx3852 power 0.0473 0.5 -> 0.217 Inexact Rounded
-pwsx3853 power 0.474 0.5 -> 0.688 Inexact Rounded
-pwsx3854 power 0.0474 0.5 -> 0.218 Inexact Rounded
-pwsx3855 power 0.475 0.5 -> 0.689 Inexact Rounded
-pwsx3856 power 0.0475 0.5 -> 0.218 Inexact Rounded
-pwsx3857 power 0.476 0.5 -> 0.690 Inexact Rounded
-pwsx3858 power 0.0476 0.5 -> 0.218 Inexact Rounded
-pwsx3859 power 0.477 0.5 -> 0.691 Inexact Rounded
-pwsx3860 power 0.0477 0.5 -> 0.218 Inexact Rounded
-pwsx3861 power 0.478 0.5 -> 0.691 Inexact Rounded
-pwsx3862 power 0.0478 0.5 -> 0.219 Inexact Rounded
-pwsx3863 power 0.479 0.5 -> 0.692 Inexact Rounded
-pwsx3864 power 0.0479 0.5 -> 0.219 Inexact Rounded
-pwsx3865 power 0.481 0.5 -> 0.694 Inexact Rounded
-pwsx3866 power 0.0481 0.5 -> 0.219 Inexact Rounded
-pwsx3867 power 0.482 0.5 -> 0.694 Inexact Rounded
-pwsx3868 power 0.0482 0.5 -> 0.220 Inexact Rounded
-pwsx3869 power 0.483 0.5 -> 0.695 Inexact Rounded
-pwsx3870 power 0.0483 0.5 -> 0.220 Inexact Rounded
-pwsx3871 power 0.484 0.5 -> 0.696 Inexact Rounded
-pwsx3872 power 0.0484 0.5 -> 0.220 Inexact Rounded
-pwsx3873 power 0.485 0.5 -> 0.696 Inexact Rounded
-pwsx3874 power 0.0485 0.5 -> 0.220 Inexact Rounded
-pwsx3875 power 0.486 0.5 -> 0.697 Inexact Rounded
-pwsx3876 power 0.0486 0.5 -> 0.220 Inexact Rounded
-pwsx3877 power 0.487 0.5 -> 0.698 Inexact Rounded
-pwsx3878 power 0.0487 0.5 -> 0.221 Inexact Rounded
-pwsx3879 power 0.488 0.5 -> 0.699 Inexact Rounded
-pwsx3880 power 0.0488 0.5 -> 0.221 Inexact Rounded
-pwsx3881 power 0.489 0.5 -> 0.699 Inexact Rounded
-pwsx3882 power 0.0489 0.5 -> 0.221 Inexact Rounded
-pwsx3883 power 0.491 0.5 -> 0.701 Inexact Rounded
-pwsx3884 power 0.0491 0.5 -> 0.222 Inexact Rounded
-pwsx3885 power 0.492 0.5 -> 0.701 Inexact Rounded
-pwsx3886 power 0.0492 0.5 -> 0.222 Inexact Rounded
-pwsx3887 power 0.493 0.5 -> 0.702 Inexact Rounded
-pwsx3888 power 0.0493 0.5 -> 0.222 Inexact Rounded
-pwsx3889 power 0.494 0.5 -> 0.703 Inexact Rounded
-pwsx3890 power 0.0494 0.5 -> 0.222 Inexact Rounded
-pwsx3891 power 0.495 0.5 -> 0.704 Inexact Rounded
-pwsx3892 power 0.0495 0.5 -> 0.222 Inexact Rounded
-pwsx3893 power 0.496 0.5 -> 0.704 Inexact Rounded
-pwsx3894 power 0.0496 0.5 -> 0.223 Inexact Rounded
-pwsx3895 power 0.497 0.5 -> 0.705 Inexact Rounded
-pwsx3896 power 0.0497 0.5 -> 0.223 Inexact Rounded
-pwsx3897 power 0.498 0.5 -> 0.706 Inexact Rounded
-pwsx3898 power 0.0498 0.5 -> 0.223 Inexact Rounded
-pwsx3899 power 0.499 0.5 -> 0.706 Inexact Rounded
-pwsx3900 power 0.0499 0.5 -> 0.223 Inexact Rounded
-pwsx3901 power 0.501 0.5 -> 0.708 Inexact Rounded
-pwsx3902 power 0.0501 0.5 -> 0.224 Inexact Rounded
-pwsx3903 power 0.502 0.5 -> 0.709 Inexact Rounded
-pwsx3904 power 0.0502 0.5 -> 0.224 Inexact Rounded
-pwsx3905 power 0.503 0.5 -> 0.709 Inexact Rounded
-pwsx3906 power 0.0503 0.5 -> 0.224 Inexact Rounded
-pwsx3907 power 0.504 0.5 -> 0.710 Inexact Rounded
-pwsx3908 power 0.0504 0.5 -> 0.224 Inexact Rounded
-pwsx3909 power 0.505 0.5 -> 0.711 Inexact Rounded
-pwsx3910 power 0.0505 0.5 -> 0.225 Inexact Rounded
-pwsx3911 power 0.506 0.5 -> 0.711 Inexact Rounded
-pwsx3912 power 0.0506 0.5 -> 0.225 Inexact Rounded
-pwsx3913 power 0.507 0.5 -> 0.712 Inexact Rounded
-pwsx3914 power 0.0507 0.5 -> 0.225 Inexact Rounded
-pwsx3915 power 0.508 0.5 -> 0.713 Inexact Rounded
-pwsx3916 power 0.0508 0.5 -> 0.225 Inexact Rounded
-pwsx3917 power 0.509 0.5 -> 0.713 Inexact Rounded
-pwsx3918 power 0.0509 0.5 -> 0.226 Inexact Rounded
-pwsx3919 power 0.511 0.5 -> 0.715 Inexact Rounded
-pwsx3920 power 0.0511 0.5 -> 0.226 Inexact Rounded
-pwsx3921 power 0.512 0.5 -> 0.716 Inexact Rounded
-pwsx3922 power 0.0512 0.5 -> 0.226 Inexact Rounded
-pwsx3923 power 0.513 0.5 -> 0.716 Inexact Rounded
-pwsx3924 power 0.0513 0.5 -> 0.226 Inexact Rounded
-pwsx3925 power 0.514 0.5 -> 0.717 Inexact Rounded
-pwsx3926 power 0.0514 0.5 -> 0.227 Inexact Rounded
-pwsx3927 power 0.515 0.5 -> 0.718 Inexact Rounded
-pwsx3928 power 0.0515 0.5 -> 0.227 Inexact Rounded
-pwsx3929 power 0.516 0.5 -> 0.718 Inexact Rounded
-pwsx3930 power 0.0516 0.5 -> 0.227 Inexact Rounded
-pwsx3931 power 0.517 0.5 -> 0.719 Inexact Rounded
-pwsx3932 power 0.0517 0.5 -> 0.227 Inexact Rounded
-pwsx3933 power 0.518 0.5 -> 0.720 Inexact Rounded
-pwsx3934 power 0.0518 0.5 -> 0.228 Inexact Rounded
-pwsx3935 power 0.519 0.5 -> 0.720 Inexact Rounded
-pwsx3936 power 0.0519 0.5 -> 0.228 Inexact Rounded
-pwsx3937 power 0.521 0.5 -> 0.722 Inexact Rounded
-pwsx3938 power 0.0521 0.5 -> 0.228 Inexact Rounded
-pwsx3939 power 0.522 0.5 -> 0.722 Inexact Rounded
-pwsx3940 power 0.0522 0.5 -> 0.228 Inexact Rounded
-pwsx3941 power 0.523 0.5 -> 0.723 Inexact Rounded
-pwsx3942 power 0.0523 0.5 -> 0.229 Inexact Rounded
-pwsx3943 power 0.524 0.5 -> 0.724 Inexact Rounded
-pwsx3944 power 0.0524 0.5 -> 0.229 Inexact Rounded
-pwsx3945 power 0.525 0.5 -> 0.725 Inexact Rounded
-pwsx3946 power 0.0525 0.5 -> 0.229 Inexact Rounded
-pwsx3947 power 0.526 0.5 -> 0.725 Inexact Rounded
-pwsx3948 power 0.0526 0.5 -> 0.229 Inexact Rounded
-pwsx3949 power 0.527 0.5 -> 0.726 Inexact Rounded
-pwsx3950 power 0.0527 0.5 -> 0.230 Inexact Rounded
-pwsx3951 power 0.528 0.5 -> 0.727 Inexact Rounded
-pwsx3952 power 0.0528 0.5 -> 0.230 Inexact Rounded
-pwsx3953 power 0.529 0.5 -> 0.727 Inexact Rounded
-pwsx3954 power 0.0529 0.5 -> 0.230 Inexact Rounded
-pwsx3955 power 0.531 0.5 -> 0.729 Inexact Rounded
-pwsx3956 power 0.0531 0.5 -> 0.230 Inexact Rounded
-pwsx3957 power 0.532 0.5 -> 0.729 Inexact Rounded
-pwsx3958 power 0.0532 0.5 -> 0.231 Inexact Rounded
-pwsx3959 power 0.533 0.5 -> 0.730 Inexact Rounded
-pwsx3960 power 0.0533 0.5 -> 0.231 Inexact Rounded
-pwsx3961 power 0.534 0.5 -> 0.731 Inexact Rounded
-pwsx3962 power 0.0534 0.5 -> 0.231 Inexact Rounded
-pwsx3963 power 0.535 0.5 -> 0.731 Inexact Rounded
-pwsx3964 power 0.0535 0.5 -> 0.231 Inexact Rounded
-pwsx3965 power 0.536 0.5 -> 0.732 Inexact Rounded
-pwsx3966 power 0.0536 0.5 -> 0.232 Inexact Rounded
-pwsx3967 power 0.537 0.5 -> 0.733 Inexact Rounded
-pwsx3968 power 0.0537 0.5 -> 0.232 Inexact Rounded
-pwsx3969 power 0.538 0.5 -> 0.733 Inexact Rounded
-pwsx3970 power 0.0538 0.5 -> 0.232 Inexact Rounded
-pwsx3971 power 0.539 0.5 -> 0.734 Inexact Rounded
-pwsx3972 power 0.0539 0.5 -> 0.232 Inexact Rounded
-pwsx3973 power 0.541 0.5 -> 0.736 Inexact Rounded
-pwsx3974 power 0.0541 0.5 -> 0.233 Inexact Rounded
-pwsx3975 power 0.542 0.5 -> 0.736 Inexact Rounded
-pwsx3976 power 0.0542 0.5 -> 0.233 Inexact Rounded
-pwsx3977 power 0.543 0.5 -> 0.737 Inexact Rounded
-pwsx3978 power 0.0543 0.5 -> 0.233 Inexact Rounded
-pwsx3979 power 0.544 0.5 -> 0.738 Inexact Rounded
-pwsx3980 power 0.0544 0.5 -> 0.233 Inexact Rounded
-pwsx3981 power 0.545 0.5 -> 0.738 Inexact Rounded
-pwsx3982 power 0.0545 0.5 -> 0.233 Inexact Rounded
-pwsx3983 power 0.546 0.5 -> 0.739 Inexact Rounded
-pwsx3984 power 0.0546 0.5 -> 0.234 Inexact Rounded
-pwsx3985 power 0.547 0.5 -> 0.740 Inexact Rounded
-pwsx3986 power 0.0547 0.5 -> 0.234 Inexact Rounded
-pwsx3987 power 0.548 0.5 -> 0.740 Inexact Rounded
-pwsx3988 power 0.0548 0.5 -> 0.234 Inexact Rounded
-pwsx3989 power 0.549 0.5 -> 0.741 Inexact Rounded
-pwsx3990 power 0.0549 0.5 -> 0.234 Inexact Rounded
-pwsx3991 power 0.551 0.5 -> 0.742 Inexact Rounded
-pwsx3992 power 0.0551 0.5 -> 0.235 Inexact Rounded
-pwsx3993 power 0.552 0.5 -> 0.743 Inexact Rounded
-pwsx3994 power 0.0552 0.5 -> 0.235 Inexact Rounded
-pwsx3995 power 0.553 0.5 -> 0.744 Inexact Rounded
-pwsx3996 power 0.0553 0.5 -> 0.235 Inexact Rounded
-pwsx3997 power 0.554 0.5 -> 0.744 Inexact Rounded
-pwsx3998 power 0.0554 0.5 -> 0.235 Inexact Rounded
-pwsx3999 power 0.555 0.5 -> 0.745 Inexact Rounded
-pwsx4000 power 0.0555 0.5 -> 0.236 Inexact Rounded
-pwsx4001 power 0.556 0.5 -> 0.746 Inexact Rounded
-pwsx4002 power 0.0556 0.5 -> 0.236 Inexact Rounded
-pwsx4003 power 0.557 0.5 -> 0.746 Inexact Rounded
-pwsx4004 power 0.0557 0.5 -> 0.236 Inexact Rounded
-pwsx4005 power 0.558 0.5 -> 0.747 Inexact Rounded
-pwsx4006 power 0.0558 0.5 -> 0.236 Inexact Rounded
-pwsx4007 power 0.559 0.5 -> 0.748 Inexact Rounded
-pwsx4008 power 0.0559 0.5 -> 0.236 Inexact Rounded
-pwsx4009 power 0.561 0.5 -> 0.749 Inexact Rounded
-pwsx4010 power 0.0561 0.5 -> 0.237 Inexact Rounded
-pwsx4011 power 0.562 0.5 -> 0.750 Inexact Rounded
-pwsx4012 power 0.0562 0.5 -> 0.237 Inexact Rounded
-pwsx4013 power 0.563 0.5 -> 0.750 Inexact Rounded
-pwsx4014 power 0.0563 0.5 -> 0.237 Inexact Rounded
-pwsx4015 power 0.564 0.5 -> 0.751 Inexact Rounded
-pwsx4016 power 0.0564 0.5 -> 0.237 Inexact Rounded
-pwsx4017 power 0.565 0.5 -> 0.752 Inexact Rounded
-pwsx4018 power 0.0565 0.5 -> 0.238 Inexact Rounded
-pwsx4019 power 0.566 0.5 -> 0.752 Inexact Rounded
-pwsx4020 power 0.0566 0.5 -> 0.238 Inexact Rounded
-pwsx4021 power 0.567 0.5 -> 0.753 Inexact Rounded
-pwsx4022 power 0.0567 0.5 -> 0.238 Inexact Rounded
-pwsx4023 power 0.568 0.5 -> 0.754 Inexact Rounded
-pwsx4024 power 0.0568 0.5 -> 0.238 Inexact Rounded
-pwsx4025 power 0.569 0.5 -> 0.754 Inexact Rounded
-pwsx4026 power 0.0569 0.5 -> 0.239 Inexact Rounded
-pwsx4027 power 0.571 0.5 -> 0.756 Inexact Rounded
-pwsx4028 power 0.0571 0.5 -> 0.239 Inexact Rounded
-pwsx4029 power 0.572 0.5 -> 0.756 Inexact Rounded
-pwsx4030 power 0.0572 0.5 -> 0.239 Inexact Rounded
-pwsx4031 power 0.573 0.5 -> 0.757 Inexact Rounded
-pwsx4032 power 0.0573 0.5 -> 0.239 Inexact Rounded
-pwsx4033 power 0.574 0.5 -> 0.758 Inexact Rounded
-pwsx4034 power 0.0574 0.5 -> 0.240 Inexact Rounded
-pwsx4035 power 0.575 0.5 -> 0.758 Inexact Rounded
-pwsx4036 power 0.0575 0.5 -> 0.240 Inexact Rounded
-pwsx4037 power 0.576 0.5 -> 0.759 Inexact Rounded
-pwsx4038 power 0.0576 0.5 -> 0.240 Inexact Rounded
-pwsx4039 power 0.577 0.5 -> 0.760 Inexact Rounded
-pwsx4040 power 0.0577 0.5 -> 0.240 Inexact Rounded
-pwsx4041 power 0.578 0.5 -> 0.760 Inexact Rounded
-pwsx4042 power 0.0578 0.5 -> 0.240 Inexact Rounded
-pwsx4043 power 0.579 0.5 -> 0.761 Inexact Rounded
-pwsx4044 power 0.0579 0.5 -> 0.241 Inexact Rounded
-pwsx4045 power 0.581 0.5 -> 0.762 Inexact Rounded
-pwsx4046 power 0.0581 0.5 -> 0.241 Inexact Rounded
-pwsx4047 power 0.582 0.5 -> 0.763 Inexact Rounded
-pwsx4048 power 0.0582 0.5 -> 0.241 Inexact Rounded
-pwsx4049 power 0.583 0.5 -> 0.764 Inexact Rounded
-pwsx4050 power 0.0583 0.5 -> 0.241 Inexact Rounded
-pwsx4051 power 0.584 0.5 -> 0.764 Inexact Rounded
-pwsx4052 power 0.0584 0.5 -> 0.242 Inexact Rounded
-pwsx4053 power 0.585 0.5 -> 0.765 Inexact Rounded
-pwsx4054 power 0.0585 0.5 -> 0.242 Inexact Rounded
-pwsx4055 power 0.586 0.5 -> 0.766 Inexact Rounded
-pwsx4056 power 0.0586 0.5 -> 0.242 Inexact Rounded
-pwsx4057 power 0.587 0.5 -> 0.766 Inexact Rounded
-pwsx4058 power 0.0587 0.5 -> 0.242 Inexact Rounded
-pwsx4059 power 0.588 0.5 -> 0.767 Inexact Rounded
-pwsx4060 power 0.0588 0.5 -> 0.242 Inexact Rounded
-pwsx4061 power 0.589 0.5 -> 0.767 Inexact Rounded
-pwsx4062 power 0.0589 0.5 -> 0.243 Inexact Rounded
-pwsx4063 power 0.591 0.5 -> 0.769 Inexact Rounded
-pwsx4064 power 0.0591 0.5 -> 0.243 Inexact Rounded
-pwsx4065 power 0.592 0.5 -> 0.769 Inexact Rounded
-pwsx4066 power 0.0592 0.5 -> 0.243 Inexact Rounded
-pwsx4067 power 0.593 0.5 -> 0.770 Inexact Rounded
-pwsx4068 power 0.0593 0.5 -> 0.244 Inexact Rounded
-pwsx4069 power 0.594 0.5 -> 0.771 Inexact Rounded
-pwsx4070 power 0.0594 0.5 -> 0.244 Inexact Rounded
-pwsx4071 power 0.595 0.5 -> 0.771 Inexact Rounded
-pwsx4072 power 0.0595 0.5 -> 0.244 Inexact Rounded
-pwsx4073 power 0.596 0.5 -> 0.772 Inexact Rounded
-pwsx4074 power 0.0596 0.5 -> 0.244 Inexact Rounded
-pwsx4075 power 0.597 0.5 -> 0.773 Inexact Rounded
-pwsx4076 power 0.0597 0.5 -> 0.244 Inexact Rounded
-pwsx4077 power 0.598 0.5 -> 0.773 Inexact Rounded
-pwsx4078 power 0.0598 0.5 -> 0.245 Inexact Rounded
-pwsx4079 power 0.599 0.5 -> 0.774 Inexact Rounded
-pwsx4080 power 0.0599 0.5 -> 0.245 Inexact Rounded
-pwsx4081 power 0.601 0.5 -> 0.775 Inexact Rounded
-pwsx4082 power 0.0601 0.5 -> 0.245 Inexact Rounded
-pwsx4083 power 0.602 0.5 -> 0.776 Inexact Rounded
-pwsx4084 power 0.0602 0.5 -> 0.245 Inexact Rounded
-pwsx4085 power 0.603 0.5 -> 0.777 Inexact Rounded
-pwsx4086 power 0.0603 0.5 -> 0.246 Inexact Rounded
-pwsx4087 power 0.604 0.5 -> 0.777 Inexact Rounded
-pwsx4088 power 0.0604 0.5 -> 0.246 Inexact Rounded
-pwsx4089 power 0.605 0.5 -> 0.778 Inexact Rounded
-pwsx4090 power 0.0605 0.5 -> 0.246 Inexact Rounded
-pwsx4091 power 0.606 0.5 -> 0.778 Inexact Rounded
-pwsx4092 power 0.0606 0.5 -> 0.246 Inexact Rounded
-pwsx4093 power 0.607 0.5 -> 0.779 Inexact Rounded
-pwsx4094 power 0.0607 0.5 -> 0.246 Inexact Rounded
-pwsx4095 power 0.608 0.5 -> 0.780 Inexact Rounded
-pwsx4096 power 0.0608 0.5 -> 0.247 Inexact Rounded
-pwsx4097 power 0.609 0.5 -> 0.780 Inexact Rounded
-pwsx4098 power 0.0609 0.5 -> 0.247 Inexact Rounded
-pwsx4099 power 0.611 0.5 -> 0.782 Inexact Rounded
-pwsx4100 power 0.0611 0.5 -> 0.247 Inexact Rounded
-pwsx4101 power 0.612 0.5 -> 0.782 Inexact Rounded
-pwsx4102 power 0.0612 0.5 -> 0.247 Inexact Rounded
-pwsx4103 power 0.613 0.5 -> 0.783 Inexact Rounded
-pwsx4104 power 0.0613 0.5 -> 0.248 Inexact Rounded
-pwsx4105 power 0.614 0.5 -> 0.784 Inexact Rounded
-pwsx4106 power 0.0614 0.5 -> 0.248 Inexact Rounded
-pwsx4107 power 0.615 0.5 -> 0.784 Inexact Rounded
-pwsx4108 power 0.0615 0.5 -> 0.248 Inexact Rounded
-pwsx4109 power 0.616 0.5 -> 0.785 Inexact Rounded
-pwsx4110 power 0.0616 0.5 -> 0.248 Inexact Rounded
-pwsx4111 power 0.617 0.5 -> 0.785 Inexact Rounded
-pwsx4112 power 0.0617 0.5 -> 0.248 Inexact Rounded
-pwsx4113 power 0.618 0.5 -> 0.786 Inexact Rounded
-pwsx4114 power 0.0618 0.5 -> 0.249 Inexact Rounded
-pwsx4115 power 0.619 0.5 -> 0.787 Inexact Rounded
-pwsx4116 power 0.0619 0.5 -> 0.249 Inexact Rounded
-pwsx4117 power 0.621 0.5 -> 0.788 Inexact Rounded
-pwsx4118 power 0.0621 0.5 -> 0.249 Inexact Rounded
-pwsx4119 power 0.622 0.5 -> 0.789 Inexact Rounded
-pwsx4120 power 0.0622 0.5 -> 0.249 Inexact Rounded
-pwsx4121 power 0.623 0.5 -> 0.789 Inexact Rounded
-pwsx4122 power 0.0623 0.5 -> 0.250 Inexact Rounded
-pwsx4123 power 0.624 0.5 -> 0.790 Inexact Rounded
-pwsx4124 power 0.0624 0.5 -> 0.250 Inexact Rounded
-pwsx4125 power 0.625 0.5 -> 0.791 Inexact Rounded
-pwsx4126 power 0.0625 0.5 -> 0.250 Inexact Rounded
-pwsx4127 power 0.626 0.5 -> 0.791 Inexact Rounded
-pwsx4128 power 0.0626 0.5 -> 0.250 Inexact Rounded
-pwsx4129 power 0.627 0.5 -> 0.792 Inexact Rounded
-pwsx4130 power 0.0627 0.5 -> 0.250 Inexact Rounded
-pwsx4131 power 0.628 0.5 -> 0.792 Inexact Rounded
-pwsx4132 power 0.0628 0.5 -> 0.251 Inexact Rounded
-pwsx4133 power 0.629 0.5 -> 0.793 Inexact Rounded
-pwsx4134 power 0.0629 0.5 -> 0.251 Inexact Rounded
-pwsx4135 power 0.631 0.5 -> 0.794 Inexact Rounded
-pwsx4136 power 0.0631 0.5 -> 0.251 Inexact Rounded
-pwsx4137 power 0.632 0.5 -> 0.795 Inexact Rounded
-pwsx4138 power 0.0632 0.5 -> 0.251 Inexact Rounded
-pwsx4139 power 0.633 0.5 -> 0.796 Inexact Rounded
-pwsx4140 power 0.0633 0.5 -> 0.252 Inexact Rounded
-pwsx4141 power 0.634 0.5 -> 0.796 Inexact Rounded
-pwsx4142 power 0.0634 0.5 -> 0.252 Inexact Rounded
-pwsx4143 power 0.635 0.5 -> 0.797 Inexact Rounded
-pwsx4144 power 0.0635 0.5 -> 0.252 Inexact Rounded
-pwsx4145 power 0.636 0.5 -> 0.797 Inexact Rounded
-pwsx4146 power 0.0636 0.5 -> 0.252 Inexact Rounded
-pwsx4147 power 0.637 0.5 -> 0.798 Inexact Rounded
-pwsx4148 power 0.0637 0.5 -> 0.252 Inexact Rounded
-pwsx4149 power 0.638 0.5 -> 0.799 Inexact Rounded
-pwsx4150 power 0.0638 0.5 -> 0.253 Inexact Rounded
-pwsx4151 power 0.639 0.5 -> 0.799 Inexact Rounded
-pwsx4152 power 0.0639 0.5 -> 0.253 Inexact Rounded
-pwsx4153 power 0.641 0.5 -> 0.801 Inexact Rounded
-pwsx4154 power 0.0641 0.5 -> 0.253 Inexact Rounded
-pwsx4155 power 0.642 0.5 -> 0.801 Inexact Rounded
-pwsx4156 power 0.0642 0.5 -> 0.253 Inexact Rounded
-pwsx4157 power 0.643 0.5 -> 0.802 Inexact Rounded
-pwsx4158 power 0.0643 0.5 -> 0.254 Inexact Rounded
-pwsx4159 power 0.644 0.5 -> 0.802 Inexact Rounded
-pwsx4160 power 0.0644 0.5 -> 0.254 Inexact Rounded
-pwsx4161 power 0.645 0.5 -> 0.803 Inexact Rounded
-pwsx4162 power 0.0645 0.5 -> 0.254 Inexact Rounded
-pwsx4163 power 0.646 0.5 -> 0.804 Inexact Rounded
-pwsx4164 power 0.0646 0.5 -> 0.254 Inexact Rounded
-pwsx4165 power 0.647 0.5 -> 0.804 Inexact Rounded
-pwsx4166 power 0.0647 0.5 -> 0.254 Inexact Rounded
-pwsx4167 power 0.648 0.5 -> 0.805 Inexact Rounded
-pwsx4168 power 0.0648 0.5 -> 0.255 Inexact Rounded
-pwsx4169 power 0.649 0.5 -> 0.806 Inexact Rounded
-pwsx4170 power 0.0649 0.5 -> 0.255 Inexact Rounded
-pwsx4171 power 0.651 0.5 -> 0.807 Inexact Rounded
-pwsx4172 power 0.0651 0.5 -> 0.255 Inexact Rounded
-pwsx4173 power 0.652 0.5 -> 0.807 Inexact Rounded
-pwsx4174 power 0.0652 0.5 -> 0.255 Inexact Rounded
-pwsx4175 power 0.653 0.5 -> 0.808 Inexact Rounded
-pwsx4176 power 0.0653 0.5 -> 0.256 Inexact Rounded
-pwsx4177 power 0.654 0.5 -> 0.809 Inexact Rounded
-pwsx4178 power 0.0654 0.5 -> 0.256 Inexact Rounded
-pwsx4179 power 0.655 0.5 -> 0.809 Inexact Rounded
-pwsx4180 power 0.0655 0.5 -> 0.256 Inexact Rounded
-pwsx4181 power 0.656 0.5 -> 0.810 Inexact Rounded
-pwsx4182 power 0.0656 0.5 -> 0.256 Inexact Rounded
-pwsx4183 power 0.657 0.5 -> 0.811 Inexact Rounded
-pwsx4184 power 0.0657 0.5 -> 0.256 Inexact Rounded
-pwsx4185 power 0.658 0.5 -> 0.811 Inexact Rounded
-pwsx4186 power 0.0658 0.5 -> 0.257 Inexact Rounded
-pwsx4187 power 0.659 0.5 -> 0.812 Inexact Rounded
-pwsx4188 power 0.0659 0.5 -> 0.257 Inexact Rounded
-pwsx4189 power 0.661 0.5 -> 0.813 Inexact Rounded
-pwsx4190 power 0.0661 0.5 -> 0.257 Inexact Rounded
-pwsx4191 power 0.662 0.5 -> 0.814 Inexact Rounded
-pwsx4192 power 0.0662 0.5 -> 0.257 Inexact Rounded
-pwsx4193 power 0.663 0.5 -> 0.814 Inexact Rounded
-pwsx4194 power 0.0663 0.5 -> 0.257 Inexact Rounded
-pwsx4195 power 0.664 0.5 -> 0.815 Inexact Rounded
-pwsx4196 power 0.0664 0.5 -> 0.258 Inexact Rounded
-pwsx4197 power 0.665 0.5 -> 0.815 Inexact Rounded
-pwsx4198 power 0.0665 0.5 -> 0.258 Inexact Rounded
-pwsx4199 power 0.666 0.5 -> 0.816 Inexact Rounded
-pwsx4200 power 0.0666 0.5 -> 0.258 Inexact Rounded
-pwsx4201 power 0.667 0.5 -> 0.817 Inexact Rounded
-pwsx4202 power 0.0667 0.5 -> 0.258 Inexact Rounded
-pwsx4203 power 0.668 0.5 -> 0.817 Inexact Rounded
-pwsx4204 power 0.0668 0.5 -> 0.258 Inexact Rounded
-pwsx4205 power 0.669 0.5 -> 0.818 Inexact Rounded
-pwsx4206 power 0.0669 0.5 -> 0.259 Inexact Rounded
-pwsx4207 power 0.671 0.5 -> 0.819 Inexact Rounded
-pwsx4208 power 0.0671 0.5 -> 0.259 Inexact Rounded
-pwsx4209 power 0.672 0.5 -> 0.820 Inexact Rounded
-pwsx4210 power 0.0672 0.5 -> 0.259 Inexact Rounded
-pwsx4211 power 0.673 0.5 -> 0.820 Inexact Rounded
-pwsx4212 power 0.0673 0.5 -> 0.259 Inexact Rounded
-pwsx4213 power 0.674 0.5 -> 0.821 Inexact Rounded
-pwsx4214 power 0.0674 0.5 -> 0.260 Inexact Rounded
-pwsx4215 power 0.675 0.5 -> 0.822 Inexact Rounded
-pwsx4216 power 0.0675 0.5 -> 0.260 Inexact Rounded
-pwsx4217 power 0.676 0.5 -> 0.822 Inexact Rounded
-pwsx4218 power 0.0676 0.5 -> 0.260 Inexact Rounded
-pwsx4219 power 0.677 0.5 -> 0.823 Inexact Rounded
-pwsx4220 power 0.0677 0.5 -> 0.260 Inexact Rounded
-pwsx4221 power 0.678 0.5 -> 0.823 Inexact Rounded
-pwsx4222 power 0.0678 0.5 -> 0.260 Inexact Rounded
-pwsx4223 power 0.679 0.5 -> 0.824 Inexact Rounded
-pwsx4224 power 0.0679 0.5 -> 0.261 Inexact Rounded
-pwsx4225 power 0.681 0.5 -> 0.825 Inexact Rounded
-pwsx4226 power 0.0681 0.5 -> 0.261 Inexact Rounded
-pwsx4227 power 0.682 0.5 -> 0.826 Inexact Rounded
-pwsx4228 power 0.0682 0.5 -> 0.261 Inexact Rounded
-pwsx4229 power 0.683 0.5 -> 0.826 Inexact Rounded
-pwsx4230 power 0.0683 0.5 -> 0.261 Inexact Rounded
-pwsx4231 power 0.684 0.5 -> 0.827 Inexact Rounded
-pwsx4232 power 0.0684 0.5 -> 0.262 Inexact Rounded
-pwsx4233 power 0.685 0.5 -> 0.828 Inexact Rounded
-pwsx4234 power 0.0685 0.5 -> 0.262 Inexact Rounded
-pwsx4235 power 0.686 0.5 -> 0.828 Inexact Rounded
-pwsx4236 power 0.0686 0.5 -> 0.262 Inexact Rounded
-pwsx4237 power 0.687 0.5 -> 0.829 Inexact Rounded
-pwsx4238 power 0.0687 0.5 -> 0.262 Inexact Rounded
-pwsx4239 power 0.688 0.5 -> 0.829 Inexact Rounded
-pwsx4240 power 0.0688 0.5 -> 0.262 Inexact Rounded
-pwsx4241 power 0.689 0.5 -> 0.830 Inexact Rounded
-pwsx4242 power 0.0689 0.5 -> 0.262 Inexact Rounded
-pwsx4243 power 0.691 0.5 -> 0.831 Inexact Rounded
-pwsx4244 power 0.0691 0.5 -> 0.263 Inexact Rounded
-pwsx4245 power 0.692 0.5 -> 0.832 Inexact Rounded
-pwsx4246 power 0.0692 0.5 -> 0.263 Inexact Rounded
-pwsx4247 power 0.693 0.5 -> 0.832 Inexact Rounded
-pwsx4248 power 0.0693 0.5 -> 0.263 Inexact Rounded
-pwsx4249 power 0.694 0.5 -> 0.833 Inexact Rounded
-pwsx4250 power 0.0694 0.5 -> 0.263 Inexact Rounded
-pwsx4251 power 0.695 0.5 -> 0.834 Inexact Rounded
-pwsx4252 power 0.0695 0.5 -> 0.264 Inexact Rounded
-pwsx4253 power 0.696 0.5 -> 0.834 Inexact Rounded
-pwsx4254 power 0.0696 0.5 -> 0.264 Inexact Rounded
-pwsx4255 power 0.697 0.5 -> 0.835 Inexact Rounded
-pwsx4256 power 0.0697 0.5 -> 0.264 Inexact Rounded
-pwsx4257 power 0.698 0.5 -> 0.835 Inexact Rounded
-pwsx4258 power 0.0698 0.5 -> 0.264 Inexact Rounded
-pwsx4259 power 0.699 0.5 -> 0.836 Inexact Rounded
-pwsx4260 power 0.0699 0.5 -> 0.264 Inexact Rounded
-pwsx4261 power 0.701 0.5 -> 0.837 Inexact Rounded
-pwsx4262 power 0.0701 0.5 -> 0.265 Inexact Rounded
-pwsx4263 power 0.702 0.5 -> 0.838 Inexact Rounded
-pwsx4264 power 0.0702 0.5 -> 0.265 Inexact Rounded
-pwsx4265 power 0.703 0.5 -> 0.838 Inexact Rounded
-pwsx4266 power 0.0703 0.5 -> 0.265 Inexact Rounded
-pwsx4267 power 0.704 0.5 -> 0.839 Inexact Rounded
-pwsx4268 power 0.0704 0.5 -> 0.265 Inexact Rounded
-pwsx4269 power 0.705 0.5 -> 0.840 Inexact Rounded
-pwsx4270 power 0.0705 0.5 -> 0.266 Inexact Rounded
-pwsx4271 power 0.706 0.5 -> 0.840 Inexact Rounded
-pwsx4272 power 0.0706 0.5 -> 0.266 Inexact Rounded
-pwsx4273 power 0.707 0.5 -> 0.841 Inexact Rounded
-pwsx4274 power 0.0707 0.5 -> 0.266 Inexact Rounded
-pwsx4275 power 0.708 0.5 -> 0.841 Inexact Rounded
-pwsx4276 power 0.0708 0.5 -> 0.266 Inexact Rounded
-pwsx4277 power 0.709 0.5 -> 0.842 Inexact Rounded
-pwsx4278 power 0.0709 0.5 -> 0.266 Inexact Rounded
-pwsx4279 power 0.711 0.5 -> 0.843 Inexact Rounded
-pwsx4280 power 0.0711 0.5 -> 0.267 Inexact Rounded
-pwsx4281 power 0.712 0.5 -> 0.844 Inexact Rounded
-pwsx4282 power 0.0712 0.5 -> 0.267 Inexact Rounded
-pwsx4283 power 0.713 0.5 -> 0.844 Inexact Rounded
-pwsx4284 power 0.0713 0.5 -> 0.267 Inexact Rounded
-pwsx4285 power 0.714 0.5 -> 0.845 Inexact Rounded
-pwsx4286 power 0.0714 0.5 -> 0.267 Inexact Rounded
-pwsx4287 power 0.715 0.5 -> 0.846 Inexact Rounded
-pwsx4288 power 0.0715 0.5 -> 0.267 Inexact Rounded
-pwsx4289 power 0.716 0.5 -> 0.846 Inexact Rounded
-pwsx4290 power 0.0716 0.5 -> 0.268 Inexact Rounded
-pwsx4291 power 0.717 0.5 -> 0.847 Inexact Rounded
-pwsx4292 power 0.0717 0.5 -> 0.268 Inexact Rounded
-pwsx4293 power 0.718 0.5 -> 0.847 Inexact Rounded
-pwsx4294 power 0.0718 0.5 -> 0.268 Inexact Rounded
-pwsx4295 power 0.719 0.5 -> 0.848 Inexact Rounded
-pwsx4296 power 0.0719 0.5 -> 0.268 Inexact Rounded
-pwsx4297 power 0.721 0.5 -> 0.849 Inexact Rounded
-pwsx4298 power 0.0721 0.5 -> 0.269 Inexact Rounded
-pwsx4299 power 0.722 0.5 -> 0.850 Inexact Rounded
-pwsx4300 power 0.0722 0.5 -> 0.269 Inexact Rounded
-pwsx4301 power 0.723 0.5 -> 0.850 Inexact Rounded
-pwsx4302 power 0.0723 0.5 -> 0.269 Inexact Rounded
-pwsx4303 power 0.724 0.5 -> 0.851 Inexact Rounded
-pwsx4304 power 0.0724 0.5 -> 0.269 Inexact Rounded
-pwsx4305 power 0.725 0.5 -> 0.851 Inexact Rounded
-pwsx4306 power 0.0725 0.5 -> 0.269 Inexact Rounded
-pwsx4307 power 0.726 0.5 -> 0.852 Inexact Rounded
-pwsx4308 power 0.0726 0.5 -> 0.269 Inexact Rounded
-pwsx4309 power 0.727 0.5 -> 0.853 Inexact Rounded
-pwsx4310 power 0.0727 0.5 -> 0.270 Inexact Rounded
-pwsx4311 power 0.728 0.5 -> 0.853 Inexact Rounded
-pwsx4312 power 0.0728 0.5 -> 0.270 Inexact Rounded
-pwsx4313 power 0.729 0.5 -> 0.854 Inexact Rounded
-pwsx4314 power 0.0729 0.5 -> 0.270 Inexact Rounded
-pwsx4315 power 0.731 0.5 -> 0.855 Inexact Rounded
-pwsx4316 power 0.0731 0.5 -> 0.270 Inexact Rounded
-pwsx4317 power 0.732 0.5 -> 0.856 Inexact Rounded
-pwsx4318 power 0.0732 0.5 -> 0.271 Inexact Rounded
-pwsx4319 power 0.733 0.5 -> 0.856 Inexact Rounded
-pwsx4320 power 0.0733 0.5 -> 0.271 Inexact Rounded
-pwsx4321 power 0.734 0.5 -> 0.857 Inexact Rounded
-pwsx4322 power 0.0734 0.5 -> 0.271 Inexact Rounded
-pwsx4323 power 0.735 0.5 -> 0.857 Inexact Rounded
-pwsx4324 power 0.0735 0.5 -> 0.271 Inexact Rounded
-pwsx4325 power 0.736 0.5 -> 0.858 Inexact Rounded
-pwsx4326 power 0.0736 0.5 -> 0.271 Inexact Rounded
-pwsx4327 power 0.737 0.5 -> 0.858 Inexact Rounded
-pwsx4328 power 0.0737 0.5 -> 0.271 Inexact Rounded
-pwsx4329 power 0.738 0.5 -> 0.859 Inexact Rounded
-pwsx4330 power 0.0738 0.5 -> 0.272 Inexact Rounded
-pwsx4331 power 0.739 0.5 -> 0.860 Inexact Rounded
-pwsx4332 power 0.0739 0.5 -> 0.272 Inexact Rounded
-pwsx4333 power 0.741 0.5 -> 0.861 Inexact Rounded
-pwsx4334 power 0.0741 0.5 -> 0.272 Inexact Rounded
-pwsx4335 power 0.742 0.5 -> 0.861 Inexact Rounded
-pwsx4336 power 0.0742 0.5 -> 0.272 Inexact Rounded
-pwsx4337 power 0.743 0.5 -> 0.862 Inexact Rounded
-pwsx4338 power 0.0743 0.5 -> 0.273 Inexact Rounded
-pwsx4339 power 0.744 0.5 -> 0.863 Inexact Rounded
-pwsx4340 power 0.0744 0.5 -> 0.273 Inexact Rounded
-pwsx4341 power 0.745 0.5 -> 0.863 Inexact Rounded
-pwsx4342 power 0.0745 0.5 -> 0.273 Inexact Rounded
-pwsx4343 power 0.746 0.5 -> 0.864 Inexact Rounded
-pwsx4344 power 0.0746 0.5 -> 0.273 Inexact Rounded
-pwsx4345 power 0.747 0.5 -> 0.864 Inexact Rounded
-pwsx4346 power 0.0747 0.5 -> 0.273 Inexact Rounded
-pwsx4347 power 0.748 0.5 -> 0.865 Inexact Rounded
-pwsx4348 power 0.0748 0.5 -> 0.273 Inexact Rounded
-pwsx4349 power 0.749 0.5 -> 0.865 Inexact Rounded
-pwsx4350 power 0.0749 0.5 -> 0.274 Inexact Rounded
-pwsx4351 power 0.751 0.5 -> 0.867 Inexact Rounded
-pwsx4352 power 0.0751 0.5 -> 0.274 Inexact Rounded
-pwsx4353 power 0.752 0.5 -> 0.867 Inexact Rounded
-pwsx4354 power 0.0752 0.5 -> 0.274 Inexact Rounded
-pwsx4355 power 0.753 0.5 -> 0.868 Inexact Rounded
-pwsx4356 power 0.0753 0.5 -> 0.274 Inexact Rounded
-pwsx4357 power 0.754 0.5 -> 0.868 Inexact Rounded
-pwsx4358 power 0.0754 0.5 -> 0.275 Inexact Rounded
-pwsx4359 power 0.755 0.5 -> 0.869 Inexact Rounded
-pwsx4360 power 0.0755 0.5 -> 0.275 Inexact Rounded
-pwsx4361 power 0.756 0.5 -> 0.869 Inexact Rounded
-pwsx4362 power 0.0756 0.5 -> 0.275 Inexact Rounded
-pwsx4363 power 0.757 0.5 -> 0.870 Inexact Rounded
-pwsx4364 power 0.0757 0.5 -> 0.275 Inexact Rounded
-pwsx4365 power 0.758 0.5 -> 0.871 Inexact Rounded
-pwsx4366 power 0.0758 0.5 -> 0.275 Inexact Rounded
-pwsx4367 power 0.759 0.5 -> 0.871 Inexact Rounded
-pwsx4368 power 0.0759 0.5 -> 0.275 Inexact Rounded
-pwsx4369 power 0.761 0.5 -> 0.872 Inexact Rounded
-pwsx4370 power 0.0761 0.5 -> 0.276 Inexact Rounded
-pwsx4371 power 0.762 0.5 -> 0.873 Inexact Rounded
-pwsx4372 power 0.0762 0.5 -> 0.276 Inexact Rounded
-pwsx4373 power 0.763 0.5 -> 0.873 Inexact Rounded
-pwsx4374 power 0.0763 0.5 -> 0.276 Inexact Rounded
-pwsx4375 power 0.764 0.5 -> 0.874 Inexact Rounded
-pwsx4376 power 0.0764 0.5 -> 0.276 Inexact Rounded
-pwsx4377 power 0.765 0.5 -> 0.875 Inexact Rounded
-pwsx4378 power 0.0765 0.5 -> 0.277 Inexact Rounded
-pwsx4379 power 0.766 0.5 -> 0.875 Inexact Rounded
-pwsx4380 power 0.0766 0.5 -> 0.277 Inexact Rounded
-pwsx4381 power 0.767 0.5 -> 0.876 Inexact Rounded
-pwsx4382 power 0.0767 0.5 -> 0.277 Inexact Rounded
-pwsx4383 power 0.768 0.5 -> 0.876 Inexact Rounded
-pwsx4384 power 0.0768 0.5 -> 0.277 Inexact Rounded
-pwsx4385 power 0.769 0.5 -> 0.877 Inexact Rounded
-pwsx4386 power 0.0769 0.5 -> 0.277 Inexact Rounded
-pwsx4387 power 0.771 0.5 -> 0.878 Inexact Rounded
-pwsx4388 power 0.0771 0.5 -> 0.278 Inexact Rounded
-pwsx4389 power 0.772 0.5 -> 0.879 Inexact Rounded
-pwsx4390 power 0.0772 0.5 -> 0.278 Inexact Rounded
-pwsx4391 power 0.773 0.5 -> 0.879 Inexact Rounded
-pwsx4392 power 0.0773 0.5 -> 0.278 Inexact Rounded
-pwsx4393 power 0.774 0.5 -> 0.880 Inexact Rounded
-pwsx4394 power 0.0774 0.5 -> 0.278 Inexact Rounded
-pwsx4395 power 0.775 0.5 -> 0.880 Inexact Rounded
-pwsx4396 power 0.0775 0.5 -> 0.278 Inexact Rounded
-pwsx4397 power 0.776 0.5 -> 0.881 Inexact Rounded
-pwsx4398 power 0.0776 0.5 -> 0.279 Inexact Rounded
-pwsx4399 power 0.777 0.5 -> 0.881 Inexact Rounded
-pwsx4400 power 0.0777 0.5 -> 0.279 Inexact Rounded
-pwsx4401 power 0.778 0.5 -> 0.882 Inexact Rounded
-pwsx4402 power 0.0778 0.5 -> 0.279 Inexact Rounded
-pwsx4403 power 0.779 0.5 -> 0.883 Inexact Rounded
-pwsx4404 power 0.0779 0.5 -> 0.279 Inexact Rounded
-pwsx4405 power 0.781 0.5 -> 0.884 Inexact Rounded
-pwsx4406 power 0.0781 0.5 -> 0.279 Inexact Rounded
-pwsx4407 power 0.782 0.5 -> 0.884 Inexact Rounded
-pwsx4408 power 0.0782 0.5 -> 0.280 Inexact Rounded
-pwsx4409 power 0.783 0.5 -> 0.885 Inexact Rounded
-pwsx4410 power 0.0783 0.5 -> 0.280 Inexact Rounded
-pwsx4411 power 0.784 0.5 -> 0.885 Inexact Rounded
-pwsx4412 power 0.0784 0.5 -> 0.280 Inexact Rounded
-pwsx4413 power 0.785 0.5 -> 0.886 Inexact Rounded
-pwsx4414 power 0.0785 0.5 -> 0.280 Inexact Rounded
-pwsx4415 power 0.786 0.5 -> 0.887 Inexact Rounded
-pwsx4416 power 0.0786 0.5 -> 0.280 Inexact Rounded
-pwsx4417 power 0.787 0.5 -> 0.887 Inexact Rounded
-pwsx4418 power 0.0787 0.5 -> 0.281 Inexact Rounded
-pwsx4419 power 0.788 0.5 -> 0.888 Inexact Rounded
-pwsx4420 power 0.0788 0.5 -> 0.281 Inexact Rounded
-pwsx4421 power 0.789 0.5 -> 0.888 Inexact Rounded
-pwsx4422 power 0.0789 0.5 -> 0.281 Inexact Rounded
-pwsx4423 power 0.791 0.5 -> 0.889 Inexact Rounded
-pwsx4424 power 0.0791 0.5 -> 0.281 Inexact Rounded
-pwsx4425 power 0.792 0.5 -> 0.890 Inexact Rounded
-pwsx4426 power 0.0792 0.5 -> 0.281 Inexact Rounded
-pwsx4427 power 0.793 0.5 -> 0.891 Inexact Rounded
-pwsx4428 power 0.0793 0.5 -> 0.282 Inexact Rounded
-pwsx4429 power 0.794 0.5 -> 0.891 Inexact Rounded
-pwsx4430 power 0.0794 0.5 -> 0.282 Inexact Rounded
-pwsx4431 power 0.795 0.5 -> 0.892 Inexact Rounded
-pwsx4432 power 0.0795 0.5 -> 0.282 Inexact Rounded
-pwsx4433 power 0.796 0.5 -> 0.892 Inexact Rounded
-pwsx4434 power 0.0796 0.5 -> 0.282 Inexact Rounded
-pwsx4435 power 0.797 0.5 -> 0.893 Inexact Rounded
-pwsx4436 power 0.0797 0.5 -> 0.282 Inexact Rounded
-pwsx4437 power 0.798 0.5 -> 0.893 Inexact Rounded
-pwsx4438 power 0.0798 0.5 -> 0.282 Inexact Rounded
-pwsx4439 power 0.799 0.5 -> 0.894 Inexact Rounded
-pwsx4440 power 0.0799 0.5 -> 0.283 Inexact Rounded
-pwsx4441 power 0.801 0.5 -> 0.895 Inexact Rounded
-pwsx4442 power 0.0801 0.5 -> 0.283 Inexact Rounded
-pwsx4443 power 0.802 0.5 -> 0.896 Inexact Rounded
-pwsx4444 power 0.0802 0.5 -> 0.283 Inexact Rounded
-pwsx4445 power 0.803 0.5 -> 0.896 Inexact Rounded
-pwsx4446 power 0.0803 0.5 -> 0.283 Inexact Rounded
-pwsx4447 power 0.804 0.5 -> 0.897 Inexact Rounded
-pwsx4448 power 0.0804 0.5 -> 0.284 Inexact Rounded
-pwsx4449 power 0.805 0.5 -> 0.897 Inexact Rounded
-pwsx4450 power 0.0805 0.5 -> 0.284 Inexact Rounded
-pwsx4451 power 0.806 0.5 -> 0.898 Inexact Rounded
-pwsx4452 power 0.0806 0.5 -> 0.284 Inexact Rounded
-pwsx4453 power 0.807 0.5 -> 0.898 Inexact Rounded
-pwsx4454 power 0.0807 0.5 -> 0.284 Inexact Rounded
-pwsx4455 power 0.808 0.5 -> 0.899 Inexact Rounded
-pwsx4456 power 0.0808 0.5 -> 0.284 Inexact Rounded
-pwsx4457 power 0.809 0.5 -> 0.899 Inexact Rounded
-pwsx4458 power 0.0809 0.5 -> 0.284 Inexact Rounded
-pwsx4459 power 0.811 0.5 -> 0.901 Inexact Rounded
-pwsx4460 power 0.0811 0.5 -> 0.285 Inexact Rounded
-pwsx4461 power 0.812 0.5 -> 0.901 Inexact Rounded
-pwsx4462 power 0.0812 0.5 -> 0.285 Inexact Rounded
-pwsx4463 power 0.813 0.5 -> 0.902 Inexact Rounded
-pwsx4464 power 0.0813 0.5 -> 0.285 Inexact Rounded
-pwsx4465 power 0.814 0.5 -> 0.902 Inexact Rounded
-pwsx4466 power 0.0814 0.5 -> 0.285 Inexact Rounded
-pwsx4467 power 0.815 0.5 -> 0.903 Inexact Rounded
-pwsx4468 power 0.0815 0.5 -> 0.285 Inexact Rounded
-pwsx4469 power 0.816 0.5 -> 0.903 Inexact Rounded
-pwsx4470 power 0.0816 0.5 -> 0.286 Inexact Rounded
-pwsx4471 power 0.817 0.5 -> 0.904 Inexact Rounded
-pwsx4472 power 0.0817 0.5 -> 0.286 Inexact Rounded
-pwsx4473 power 0.818 0.5 -> 0.904 Inexact Rounded
-pwsx4474 power 0.0818 0.5 -> 0.286 Inexact Rounded
-pwsx4475 power 0.819 0.5 -> 0.905 Inexact Rounded
-pwsx4476 power 0.0819 0.5 -> 0.286 Inexact Rounded
-pwsx4477 power 0.821 0.5 -> 0.906 Inexact Rounded
-pwsx4478 power 0.0821 0.5 -> 0.287 Inexact Rounded
-pwsx4479 power 0.822 0.5 -> 0.907 Inexact Rounded
-pwsx4480 power 0.0822 0.5 -> 0.287 Inexact Rounded
-pwsx4481 power 0.823 0.5 -> 0.907 Inexact Rounded
-pwsx4482 power 0.0823 0.5 -> 0.287 Inexact Rounded
-pwsx4483 power 0.824 0.5 -> 0.908 Inexact Rounded
-pwsx4484 power 0.0824 0.5 -> 0.287 Inexact Rounded
-pwsx4485 power 0.825 0.5 -> 0.908 Inexact Rounded
-pwsx4486 power 0.0825 0.5 -> 0.287 Inexact Rounded
-pwsx4487 power 0.826 0.5 -> 0.909 Inexact Rounded
-pwsx4488 power 0.0826 0.5 -> 0.287 Inexact Rounded
-pwsx4489 power 0.827 0.5 -> 0.909 Inexact Rounded
-pwsx4490 power 0.0827 0.5 -> 0.288 Inexact Rounded
-pwsx4491 power 0.828 0.5 -> 0.910 Inexact Rounded
-pwsx4492 power 0.0828 0.5 -> 0.288 Inexact Rounded
-pwsx4493 power 0.829 0.5 -> 0.910 Inexact Rounded
-pwsx4494 power 0.0829 0.5 -> 0.288 Inexact Rounded
-pwsx4495 power 0.831 0.5 -> 0.912 Inexact Rounded
-pwsx4496 power 0.0831 0.5 -> 0.288 Inexact Rounded
-pwsx4497 power 0.832 0.5 -> 0.912 Inexact Rounded
-pwsx4498 power 0.0832 0.5 -> 0.288 Inexact Rounded
-pwsx4499 power 0.833 0.5 -> 0.913 Inexact Rounded
-pwsx4500 power 0.0833 0.5 -> 0.289 Inexact Rounded
-pwsx4501 power 0.834 0.5 -> 0.913 Inexact Rounded
-pwsx4502 power 0.0834 0.5 -> 0.289 Inexact Rounded
-pwsx4503 power 0.835 0.5 -> 0.914 Inexact Rounded
-pwsx4504 power 0.0835 0.5 -> 0.289 Inexact Rounded
-pwsx4505 power 0.836 0.5 -> 0.914 Inexact Rounded
-pwsx4506 power 0.0836 0.5 -> 0.289 Inexact Rounded
-pwsx4507 power 0.837 0.5 -> 0.915 Inexact Rounded
-pwsx4508 power 0.0837 0.5 -> 0.289 Inexact Rounded
-pwsx4509 power 0.838 0.5 -> 0.915 Inexact Rounded
-pwsx4510 power 0.0838 0.5 -> 0.289 Inexact Rounded
-pwsx4511 power 0.839 0.5 -> 0.916 Inexact Rounded
-pwsx4512 power 0.0839 0.5 -> 0.290 Inexact Rounded
-pwsx4513 power 0.841 0.5 -> 0.917 Inexact Rounded
-pwsx4514 power 0.0841 0.5 -> 0.290 Inexact Rounded
-pwsx4515 power 0.842 0.5 -> 0.918 Inexact Rounded
-pwsx4516 power 0.0842 0.5 -> 0.290 Inexact Rounded
-pwsx4517 power 0.843 0.5 -> 0.918 Inexact Rounded
-pwsx4518 power 0.0843 0.5 -> 0.290 Inexact Rounded
-pwsx4519 power 0.844 0.5 -> 0.919 Inexact Rounded
-pwsx4520 power 0.0844 0.5 -> 0.291 Inexact Rounded
-pwsx4521 power 0.845 0.5 -> 0.919 Inexact Rounded
-pwsx4522 power 0.0845 0.5 -> 0.291 Inexact Rounded
-pwsx4523 power 0.846 0.5 -> 0.920 Inexact Rounded
-pwsx4524 power 0.0846 0.5 -> 0.291 Inexact Rounded
-pwsx4525 power 0.847 0.5 -> 0.920 Inexact Rounded
-pwsx4526 power 0.0847 0.5 -> 0.291 Inexact Rounded
-pwsx4527 power 0.848 0.5 -> 0.921 Inexact Rounded
-pwsx4528 power 0.0848 0.5 -> 0.291 Inexact Rounded
-pwsx4529 power 0.849 0.5 -> 0.921 Inexact Rounded
-pwsx4530 power 0.0849 0.5 -> 0.291 Inexact Rounded
-pwsx4531 power 0.851 0.5 -> 0.922 Inexact Rounded
-pwsx4532 power 0.0851 0.5 -> 0.292 Inexact Rounded
-pwsx4533 power 0.852 0.5 -> 0.923 Inexact Rounded
-pwsx4534 power 0.0852 0.5 -> 0.292 Inexact Rounded
-pwsx4535 power 0.853 0.5 -> 0.924 Inexact Rounded
-pwsx4536 power 0.0853 0.5 -> 0.292 Inexact Rounded
-pwsx4537 power 0.854 0.5 -> 0.924 Inexact Rounded
-pwsx4538 power 0.0854 0.5 -> 0.292 Inexact Rounded
-pwsx4539 power 0.855 0.5 -> 0.925 Inexact Rounded
-pwsx4540 power 0.0855 0.5 -> 0.292 Inexact Rounded
-pwsx4541 power 0.856 0.5 -> 0.925 Inexact Rounded
-pwsx4542 power 0.0856 0.5 -> 0.293 Inexact Rounded
-pwsx4543 power 0.857 0.5 -> 0.926 Inexact Rounded
-pwsx4544 power 0.0857 0.5 -> 0.293 Inexact Rounded
-pwsx4545 power 0.858 0.5 -> 0.926 Inexact Rounded
-pwsx4546 power 0.0858 0.5 -> 0.293 Inexact Rounded
-pwsx4547 power 0.859 0.5 -> 0.927 Inexact Rounded
-pwsx4548 power 0.0859 0.5 -> 0.293 Inexact Rounded
-pwsx4549 power 0.861 0.5 -> 0.928 Inexact Rounded
-pwsx4550 power 0.0861 0.5 -> 0.293 Inexact Rounded
-pwsx4551 power 0.862 0.5 -> 0.928 Inexact Rounded
-pwsx4552 power 0.0862 0.5 -> 0.294 Inexact Rounded
-pwsx4553 power 0.863 0.5 -> 0.929 Inexact Rounded
-pwsx4554 power 0.0863 0.5 -> 0.294 Inexact Rounded
-pwsx4555 power 0.864 0.5 -> 0.930 Inexact Rounded
-pwsx4556 power 0.0864 0.5 -> 0.294 Inexact Rounded
-pwsx4557 power 0.865 0.5 -> 0.930 Inexact Rounded
-pwsx4558 power 0.0865 0.5 -> 0.294 Inexact Rounded
-pwsx4559 power 0.866 0.5 -> 0.931 Inexact Rounded
-pwsx4560 power 0.0866 0.5 -> 0.294 Inexact Rounded
-pwsx4561 power 0.867 0.5 -> 0.931 Inexact Rounded
-pwsx4562 power 0.0867 0.5 -> 0.294 Inexact Rounded
-pwsx4563 power 0.868 0.5 -> 0.932 Inexact Rounded
-pwsx4564 power 0.0868 0.5 -> 0.295 Inexact Rounded
-pwsx4565 power 0.869 0.5 -> 0.932 Inexact Rounded
-pwsx4566 power 0.0869 0.5 -> 0.295 Inexact Rounded
-pwsx4567 power 0.871 0.5 -> 0.933 Inexact Rounded
-pwsx4568 power 0.0871 0.5 -> 0.295 Inexact Rounded
-pwsx4569 power 0.872 0.5 -> 0.934 Inexact Rounded
-pwsx4570 power 0.0872 0.5 -> 0.295 Inexact Rounded
-pwsx4571 power 0.873 0.5 -> 0.934 Inexact Rounded
-pwsx4572 power 0.0873 0.5 -> 0.295 Inexact Rounded
-pwsx4573 power 0.874 0.5 -> 0.935 Inexact Rounded
-pwsx4574 power 0.0874 0.5 -> 0.296 Inexact Rounded
-pwsx4575 power 0.875 0.5 -> 0.935 Inexact Rounded
-pwsx4576 power 0.0875 0.5 -> 0.296 Inexact Rounded
-pwsx4577 power 0.876 0.5 -> 0.936 Inexact Rounded
-pwsx4578 power 0.0876 0.5 -> 0.296 Inexact Rounded
-pwsx4579 power 0.877 0.5 -> 0.936 Inexact Rounded
-pwsx4580 power 0.0877 0.5 -> 0.296 Inexact Rounded
-pwsx4581 power 0.878 0.5 -> 0.937 Inexact Rounded
-pwsx4582 power 0.0878 0.5 -> 0.296 Inexact Rounded
-pwsx4583 power 0.879 0.5 -> 0.938 Inexact Rounded
-pwsx4584 power 0.0879 0.5 -> 0.296 Inexact Rounded
-pwsx4585 power 0.881 0.5 -> 0.939 Inexact Rounded
-pwsx4586 power 0.0881 0.5 -> 0.297 Inexact Rounded
-pwsx4587 power 0.882 0.5 -> 0.939 Inexact Rounded
-pwsx4588 power 0.0882 0.5 -> 0.297 Inexact Rounded
-pwsx4589 power 0.883 0.5 -> 0.940 Inexact Rounded
-pwsx4590 power 0.0883 0.5 -> 0.297 Inexact Rounded
-pwsx4591 power 0.884 0.5 -> 0.940 Inexact Rounded
-pwsx4592 power 0.0884 0.5 -> 0.297 Inexact Rounded
-pwsx4593 power 0.885 0.5 -> 0.941 Inexact Rounded
-pwsx4594 power 0.0885 0.5 -> 0.297 Inexact Rounded
-pwsx4595 power 0.886 0.5 -> 0.941 Inexact Rounded
-pwsx4596 power 0.0886 0.5 -> 0.298 Inexact Rounded
-pwsx4597 power 0.887 0.5 -> 0.942 Inexact Rounded
-pwsx4598 power 0.0887 0.5 -> 0.298 Inexact Rounded
-pwsx4599 power 0.888 0.5 -> 0.942 Inexact Rounded
-pwsx4600 power 0.0888 0.5 -> 0.298 Inexact Rounded
-pwsx4601 power 0.889 0.5 -> 0.943 Inexact Rounded
-pwsx4602 power 0.0889 0.5 -> 0.298 Inexact Rounded
-pwsx4603 power 0.891 0.5 -> 0.944 Inexact Rounded
-pwsx4604 power 0.0891 0.5 -> 0.298 Inexact Rounded
-pwsx4605 power 0.892 0.5 -> 0.944 Inexact Rounded
-pwsx4606 power 0.0892 0.5 -> 0.299 Inexact Rounded
-pwsx4607 power 0.893 0.5 -> 0.945 Inexact Rounded
-pwsx4608 power 0.0893 0.5 -> 0.299 Inexact Rounded
-pwsx4609 power 0.894 0.5 -> 0.946 Inexact Rounded
-pwsx4610 power 0.0894 0.5 -> 0.299 Inexact Rounded
-pwsx4611 power 0.895 0.5 -> 0.946 Inexact Rounded
-pwsx4612 power 0.0895 0.5 -> 0.299 Inexact Rounded
-pwsx4613 power 0.896 0.5 -> 0.947 Inexact Rounded
-pwsx4614 power 0.0896 0.5 -> 0.299 Inexact Rounded
-pwsx4615 power 0.897 0.5 -> 0.947 Inexact Rounded
-pwsx4616 power 0.0897 0.5 -> 0.299 Inexact Rounded
-pwsx4617 power 0.898 0.5 -> 0.948 Inexact Rounded
-pwsx4618 power 0.0898 0.5 -> 0.300 Inexact Rounded
-pwsx4619 power 0.899 0.5 -> 0.948 Inexact Rounded
-pwsx4620 power 0.0899 0.5 -> 0.300 Inexact Rounded
-pwsx4621 power 0.901 0.5 -> 0.949 Inexact Rounded
-pwsx4622 power 0.0901 0.5 -> 0.300 Inexact Rounded
-pwsx4623 power 0.902 0.5 -> 0.950 Inexact Rounded
-pwsx4624 power 0.0902 0.5 -> 0.300 Inexact Rounded
-pwsx4625 power 0.903 0.5 -> 0.950 Inexact Rounded
-pwsx4626 power 0.0903 0.5 -> 0.300 Inexact Rounded
-pwsx4627 power 0.904 0.5 -> 0.951 Inexact Rounded
-pwsx4628 power 0.0904 0.5 -> 0.301 Inexact Rounded
-pwsx4629 power 0.905 0.5 -> 0.951 Inexact Rounded
-pwsx4630 power 0.0905 0.5 -> 0.301 Inexact Rounded
-pwsx4631 power 0.906 0.5 -> 0.952 Inexact Rounded
-pwsx4632 power 0.0906 0.5 -> 0.301 Inexact Rounded
-pwsx4633 power 0.907 0.5 -> 0.952 Inexact Rounded
-pwsx4634 power 0.0907 0.5 -> 0.301 Inexact Rounded
-pwsx4635 power 0.908 0.5 -> 0.953 Inexact Rounded
-pwsx4636 power 0.0908 0.5 -> 0.301 Inexact Rounded
-pwsx4637 power 0.909 0.5 -> 0.953 Inexact Rounded
-pwsx4638 power 0.0909 0.5 -> 0.301 Inexact Rounded
-pwsx4639 power 0.911 0.5 -> 0.954 Inexact Rounded
-pwsx4640 power 0.0911 0.5 -> 0.302 Inexact Rounded
-pwsx4641 power 0.912 0.5 -> 0.955 Inexact Rounded
-pwsx4642 power 0.0912 0.5 -> 0.302 Inexact Rounded
-pwsx4643 power 0.913 0.5 -> 0.956 Inexact Rounded
-pwsx4644 power 0.0913 0.5 -> 0.302 Inexact Rounded
-pwsx4645 power 0.914 0.5 -> 0.956 Inexact Rounded
-pwsx4646 power 0.0914 0.5 -> 0.302 Inexact Rounded
-pwsx4647 power 0.915 0.5 -> 0.957 Inexact Rounded
-pwsx4648 power 0.0915 0.5 -> 0.302 Inexact Rounded
-pwsx4649 power 0.916 0.5 -> 0.957 Inexact Rounded
-pwsx4650 power 0.0916 0.5 -> 0.303 Inexact Rounded
-pwsx4651 power 0.917 0.5 -> 0.958 Inexact Rounded
-pwsx4652 power 0.0917 0.5 -> 0.303 Inexact Rounded
-pwsx4653 power 0.918 0.5 -> 0.958 Inexact Rounded
-pwsx4654 power 0.0918 0.5 -> 0.303 Inexact Rounded
-pwsx4655 power 0.919 0.5 -> 0.959 Inexact Rounded
-pwsx4656 power 0.0919 0.5 -> 0.303 Inexact Rounded
-pwsx4657 power 0.921 0.5 -> 0.960 Inexact Rounded
-pwsx4658 power 0.0921 0.5 -> 0.303 Inexact Rounded
-pwsx4659 power 0.922 0.5 -> 0.960 Inexact Rounded
-pwsx4660 power 0.0922 0.5 -> 0.304 Inexact Rounded
-pwsx4661 power 0.923 0.5 -> 0.961 Inexact Rounded
-pwsx4662 power 0.0923 0.5 -> 0.304 Inexact Rounded
-pwsx4663 power 0.924 0.5 -> 0.961 Inexact Rounded
-pwsx4664 power 0.0924 0.5 -> 0.304 Inexact Rounded
-pwsx4665 power 0.925 0.5 -> 0.962 Inexact Rounded
-pwsx4666 power 0.0925 0.5 -> 0.304 Inexact Rounded
-pwsx4667 power 0.926 0.5 -> 0.962 Inexact Rounded
-pwsx4668 power 0.0926 0.5 -> 0.304 Inexact Rounded
-pwsx4669 power 0.927 0.5 -> 0.963 Inexact Rounded
-pwsx4670 power 0.0927 0.5 -> 0.304 Inexact Rounded
-pwsx4671 power 0.928 0.5 -> 0.963 Inexact Rounded
-pwsx4672 power 0.0928 0.5 -> 0.305 Inexact Rounded
-pwsx4673 power 0.929 0.5 -> 0.964 Inexact Rounded
-pwsx4674 power 0.0929 0.5 -> 0.305 Inexact Rounded
-pwsx4675 power 0.931 0.5 -> 0.965 Inexact Rounded
-pwsx4676 power 0.0931 0.5 -> 0.305 Inexact Rounded
-pwsx4677 power 0.932 0.5 -> 0.965 Inexact Rounded
-pwsx4678 power 0.0932 0.5 -> 0.305 Inexact Rounded
-pwsx4679 power 0.933 0.5 -> 0.966 Inexact Rounded
-pwsx4680 power 0.0933 0.5 -> 0.305 Inexact Rounded
-pwsx4681 power 0.934 0.5 -> 0.966 Inexact Rounded
-pwsx4682 power 0.0934 0.5 -> 0.306 Inexact Rounded
-pwsx4683 power 0.935 0.5 -> 0.967 Inexact Rounded
-pwsx4684 power 0.0935 0.5 -> 0.306 Inexact Rounded
-pwsx4685 power 0.936 0.5 -> 0.967 Inexact Rounded
-pwsx4686 power 0.0936 0.5 -> 0.306 Inexact Rounded
-pwsx4687 power 0.937 0.5 -> 0.968 Inexact Rounded
-pwsx4688 power 0.0937 0.5 -> 0.306 Inexact Rounded
-pwsx4689 power 0.938 0.5 -> 0.969 Inexact Rounded
-pwsx4690 power 0.0938 0.5 -> 0.306 Inexact Rounded
-pwsx4691 power 0.939 0.5 -> 0.969 Inexact Rounded
-pwsx4692 power 0.0939 0.5 -> 0.306 Inexact Rounded
-pwsx4693 power 0.941 0.5 -> 0.970 Inexact Rounded
-pwsx4694 power 0.0941 0.5 -> 0.307 Inexact Rounded
-pwsx4695 power 0.942 0.5 -> 0.971 Inexact Rounded
-pwsx4696 power 0.0942 0.5 -> 0.307 Inexact Rounded
-pwsx4697 power 0.943 0.5 -> 0.971 Inexact Rounded
-pwsx4698 power 0.0943 0.5 -> 0.307 Inexact Rounded
-pwsx4699 power 0.944 0.5 -> 0.972 Inexact Rounded
-pwsx4700 power 0.0944 0.5 -> 0.307 Inexact Rounded
-pwsx4701 power 0.945 0.5 -> 0.972 Inexact Rounded
-pwsx4702 power 0.0945 0.5 -> 0.307 Inexact Rounded
-pwsx4703 power 0.946 0.5 -> 0.973 Inexact Rounded
-pwsx4704 power 0.0946 0.5 -> 0.308 Inexact Rounded
-pwsx4705 power 0.947 0.5 -> 0.973 Inexact Rounded
-pwsx4706 power 0.0947 0.5 -> 0.308 Inexact Rounded
-pwsx4707 power 0.948 0.5 -> 0.974 Inexact Rounded
-pwsx4708 power 0.0948 0.5 -> 0.308 Inexact Rounded
-pwsx4709 power 0.949 0.5 -> 0.974 Inexact Rounded
-pwsx4710 power 0.0949 0.5 -> 0.308 Inexact Rounded
-pwsx4711 power 0.951 0.5 -> 0.975 Inexact Rounded
-pwsx4712 power 0.0951 0.5 -> 0.308 Inexact Rounded
-pwsx4713 power 0.952 0.5 -> 0.976 Inexact Rounded
-pwsx4714 power 0.0952 0.5 -> 0.309 Inexact Rounded
-pwsx4715 power 0.953 0.5 -> 0.976 Inexact Rounded
-pwsx4716 power 0.0953 0.5 -> 0.309 Inexact Rounded
-pwsx4717 power 0.954 0.5 -> 0.977 Inexact Rounded
-pwsx4718 power 0.0954 0.5 -> 0.309 Inexact Rounded
-pwsx4719 power 0.955 0.5 -> 0.977 Inexact Rounded
-pwsx4720 power 0.0955 0.5 -> 0.309 Inexact Rounded
-pwsx4721 power 0.956 0.5 -> 0.978 Inexact Rounded
-pwsx4722 power 0.0956 0.5 -> 0.309 Inexact Rounded
-pwsx4723 power 0.957 0.5 -> 0.978 Inexact Rounded
-pwsx4724 power 0.0957 0.5 -> 0.309 Inexact Rounded
-pwsx4725 power 0.958 0.5 -> 0.979 Inexact Rounded
-pwsx4726 power 0.0958 0.5 -> 0.310 Inexact Rounded
-pwsx4727 power 0.959 0.5 -> 0.979 Inexact Rounded
-pwsx4728 power 0.0959 0.5 -> 0.310 Inexact Rounded
-pwsx4729 power 0.961 0.5 -> 0.980 Inexact Rounded
-pwsx4730 power 0.0961 0.5 -> 0.310 Inexact Rounded
-pwsx4731 power 0.962 0.5 -> 0.981 Inexact Rounded
-pwsx4732 power 0.0962 0.5 -> 0.310 Inexact Rounded
-pwsx4733 power 0.963 0.5 -> 0.981 Inexact Rounded
-pwsx4734 power 0.0963 0.5 -> 0.310 Inexact Rounded
-pwsx4735 power 0.964 0.5 -> 0.982 Inexact Rounded
-pwsx4736 power 0.0964 0.5 -> 0.310 Inexact Rounded
-pwsx4737 power 0.965 0.5 -> 0.982 Inexact Rounded
-pwsx4738 power 0.0965 0.5 -> 0.311 Inexact Rounded
-pwsx4739 power 0.966 0.5 -> 0.983 Inexact Rounded
-pwsx4740 power 0.0966 0.5 -> 0.311 Inexact Rounded
-pwsx4741 power 0.967 0.5 -> 0.983 Inexact Rounded
-pwsx4742 power 0.0967 0.5 -> 0.311 Inexact Rounded
-pwsx4743 power 0.968 0.5 -> 0.984 Inexact Rounded
-pwsx4744 power 0.0968 0.5 -> 0.311 Inexact Rounded
-pwsx4745 power 0.969 0.5 -> 0.984 Inexact Rounded
-pwsx4746 power 0.0969 0.5 -> 0.311 Inexact Rounded
-pwsx4747 power 0.971 0.5 -> 0.985 Inexact Rounded
-pwsx4748 power 0.0971 0.5 -> 0.312 Inexact Rounded
-pwsx4749 power 0.972 0.5 -> 0.986 Inexact Rounded
-pwsx4750 power 0.0972 0.5 -> 0.312 Inexact Rounded
-pwsx4751 power 0.973 0.5 -> 0.986 Inexact Rounded
-pwsx4752 power 0.0973 0.5 -> 0.312 Inexact Rounded
-pwsx4753 power 0.974 0.5 -> 0.987 Inexact Rounded
-pwsx4754 power 0.0974 0.5 -> 0.312 Inexact Rounded
-pwsx4755 power 0.975 0.5 -> 0.987 Inexact Rounded
-pwsx4756 power 0.0975 0.5 -> 0.312 Inexact Rounded
-pwsx4757 power 0.976 0.5 -> 0.988 Inexact Rounded
-pwsx4758 power 0.0976 0.5 -> 0.312 Inexact Rounded
-pwsx4759 power 0.977 0.5 -> 0.988 Inexact Rounded
-pwsx4760 power 0.0977 0.5 -> 0.313 Inexact Rounded
-pwsx4761 power 0.978 0.5 -> 0.989 Inexact Rounded
-pwsx4762 power 0.0978 0.5 -> 0.313 Inexact Rounded
-pwsx4763 power 0.979 0.5 -> 0.989 Inexact Rounded
-pwsx4764 power 0.0979 0.5 -> 0.313 Inexact Rounded
-pwsx4765 power 0.981 0.5 -> 0.990 Inexact Rounded
-pwsx4766 power 0.0981 0.5 -> 0.313 Inexact Rounded
-pwsx4767 power 0.982 0.5 -> 0.991 Inexact Rounded
-pwsx4768 power 0.0982 0.5 -> 0.313 Inexact Rounded
-pwsx4769 power 0.983 0.5 -> 0.991 Inexact Rounded
-pwsx4770 power 0.0983 0.5 -> 0.314 Inexact Rounded
-pwsx4771 power 0.984 0.5 -> 0.992 Inexact Rounded
-pwsx4772 power 0.0984 0.5 -> 0.314 Inexact Rounded
-pwsx4773 power 0.985 0.5 -> 0.992 Inexact Rounded
-pwsx4774 power 0.0985 0.5 -> 0.314 Inexact Rounded
-pwsx4775 power 0.986 0.5 -> 0.993 Inexact Rounded
-pwsx4776 power 0.0986 0.5 -> 0.314 Inexact Rounded
-pwsx4777 power 0.987 0.5 -> 0.993 Inexact Rounded
-pwsx4778 power 0.0987 0.5 -> 0.314 Inexact Rounded
-pwsx4779 power 0.988 0.5 -> 0.994 Inexact Rounded
-pwsx4780 power 0.0988 0.5 -> 0.314 Inexact Rounded
-pwsx4781 power 0.989 0.5 -> 0.994 Inexact Rounded
-pwsx4782 power 0.0989 0.5 -> 0.314 Inexact Rounded
-pwsx4783 power 0.991 0.5 -> 0.995 Inexact Rounded
-pwsx4784 power 0.0991 0.5 -> 0.315 Inexact Rounded
-pwsx4785 power 0.992 0.5 -> 0.996 Inexact Rounded
-pwsx4786 power 0.0992 0.5 -> 0.315 Inexact Rounded
-pwsx4787 power 0.993 0.5 -> 0.996 Inexact Rounded
-pwsx4788 power 0.0993 0.5 -> 0.315 Inexact Rounded
-pwsx4789 power 0.994 0.5 -> 0.997 Inexact Rounded
-pwsx4790 power 0.0994 0.5 -> 0.315 Inexact Rounded
-pwsx4791 power 0.995 0.5 -> 0.997 Inexact Rounded
-pwsx4792 power 0.0995 0.5 -> 0.315 Inexact Rounded
-pwsx4793 power 0.996 0.5 -> 0.998 Inexact Rounded
-pwsx4794 power 0.0996 0.5 -> 0.316 Inexact Rounded
-pwsx4795 power 0.997 0.5 -> 0.998 Inexact Rounded
-pwsx4796 power 0.0997 0.5 -> 0.316 Inexact Rounded
-pwsx4797 power 0.998 0.5 -> 0.999 Inexact Rounded
-pwsx4798 power 0.0998 0.5 -> 0.316 Inexact Rounded
-pwsx4799 power 0.999 0.5 -> 0.999 Inexact Rounded
-pwsx4800 power 0.0999 0.5 -> 0.316 Inexact Rounded
-
--- A group of precision 4 tests where Hull & Abrham adjustments are
--- needed in some cases (both up and down) [see Hull1985b]
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-precision: 4
-pwsx5001 power 0.0118 0.5 -> 0.1086 Inexact Rounded
-pwsx5002 power 0.119 0.5 -> 0.3450 Inexact Rounded
-pwsx5003 power 0.0119 0.5 -> 0.1091 Inexact Rounded
-pwsx5004 power 0.121 0.5 -> 0.3479 Inexact Rounded
-pwsx5005 power 0.0121 0.5 -> 0.1100 Inexact Rounded
-pwsx5006 power 0.122 0.5 -> 0.3493 Inexact Rounded
-pwsx5007 power 0.0122 0.5 -> 0.1105 Inexact Rounded
-pwsx5008 power 0.123 0.5 -> 0.3507 Inexact Rounded
-pwsx5009 power 0.494 0.5 -> 0.7029 Inexact Rounded
-pwsx5010 power 0.0669 0.5 -> 0.2587 Inexact Rounded
-pwsx5011 power 0.9558 0.5 -> 0.9777 Inexact Rounded
-pwsx5012 power 0.9348 0.5 -> 0.9669 Inexact Rounded
-pwsx5013 power 0.9345 0.5 -> 0.9667 Inexact Rounded
-pwsx5014 power 0.09345 0.5 -> 0.3057 Inexact Rounded
-pwsx5015 power 0.9346 0.5 -> 0.9667 Inexact Rounded
-pwsx5016 power 0.09346 0.5 -> 0.3057 Inexact Rounded
-pwsx5017 power 0.9347 0.5 -> 0.9668 Inexact Rounded
-
--- examples from decArith
-precision: 9
-pwsx700 power 0 0.5 -> '0'
-pwsx701 power -0 0.5 -> '0'
-pwsx702 power 0.39 0.5 -> 0.624499800 Inexact Rounded
-pwsx703 power 100 0.5 -> '10.0000000' Inexact Rounded
-pwsx704 power 1.00 0.5 -> '1.00000000' Inexact Rounded
-pwsx705 power 7 0.5 -> '2.64575131' Inexact Rounded
-pwsx706 power 10 0.5 -> 3.16227766 Inexact Rounded
-
--- some one-offs
-precision: 9
-pwsx711 power 0.1 0.5 -> 0.316227766 Inexact Rounded
-pwsx712 power 0.2 0.5 -> 0.447213595 Inexact Rounded
-pwsx713 power 0.3 0.5 -> 0.547722558 Inexact Rounded
-pwsx714 power 0.4 0.5 -> 0.632455532 Inexact Rounded
-pwsx715 power 0.5 0.5 -> 0.707106781 Inexact Rounded
-pwsx716 power 0.6 0.5 -> 0.774596669 Inexact Rounded
-pwsx717 power 0.7 0.5 -> 0.836660027 Inexact Rounded
-pwsx718 power 0.8 0.5 -> 0.894427191 Inexact Rounded
-pwsx719 power 0.9 0.5 -> 0.948683298 Inexact Rounded
-precision: 10 -- note no normalizatoin here
-pwsx720 power +0.1 0.5 -> 0.3162277660 Inexact Rounded
-precision: 11
-pwsx721 power +0.1 0.5 -> 0.31622776602 Inexact Rounded
-precision: 12
-pwsx722 power +0.1 0.5 -> 0.316227766017 Inexact Rounded
-precision: 9
-pwsx723 power 0.39 0.5 -> 0.624499800 Inexact Rounded
-precision: 15
-pwsx724 power 0.39 0.5 -> 0.624499799839840 Inexact Rounded
-
--- discussion cases
-precision: 7
-pwsx731 power 9 0.5 -> 3.000000 Inexact Rounded
-pwsx732 power 100 0.5 -> 10.00000 Inexact Rounded
-pwsx733 power 123 0.5 -> 11.09054 Inexact Rounded
-pwsx734 power 144 0.5 -> 12.00000 Inexact Rounded
-pwsx735 power 156 0.5 -> 12.49000 Inexact Rounded
-pwsx736 power 10000 0.5 -> 100.0000 Inexact Rounded
-
--- values close to overflow (if there were input rounding)
-maxexponent: 99
-minexponent: -99
-precision: 5
-pwsx760 power 9.9997E+99 0.5 -> 9.9998E+49 Inexact Rounded
-pwsx761 power 9.9998E+99 0.5 -> 9.9999E+49 Inexact Rounded
-pwsx762 power 9.9999E+99 0.5 -> 9.9999E+49 Inexact Rounded
-pwsx763 power 9.99991E+99 0.5 -> 1.0000E+50 Inexact Rounded
-pwsx764 power 9.99994E+99 0.5 -> 1.0000E+50 Inexact Rounded
-pwsx765 power 9.99995E+99 0.5 -> 1.0000E+50 Inexact Rounded
-pwsx766 power 9.99999E+99 0.5 -> 1.0000E+50 Inexact Rounded
-precision: 9
-pwsx770 power 9.9997E+99 0.5 -> 9.99985000E+49 Inexact Rounded
-pwsx771 power 9.9998E+99 0.5 -> 9.99990000E+49 Inexact Rounded
-pwsx772 power 9.9999E+99 0.5 -> 9.99995000E+49 Inexact Rounded
-pwsx773 power 9.99991E+99 0.5 -> 9.99995500E+49 Inexact Rounded
-pwsx774 power 9.99994E+99 0.5 -> 9.99997000E+49 Inexact Rounded
-pwsx775 power 9.99995E+99 0.5 -> 9.99997500E+49 Inexact Rounded
-pwsx776 power 9.99999E+99 0.5 -> 9.99999500E+49 Inexact Rounded
-precision: 20
-pwsx780 power 9.9997E+99 0.5 -> '9.9998499988749831247E+49' Inexact Rounded
-pwsx781 power 9.9998E+99 0.5 -> '9.9998999994999949999E+49' Inexact Rounded
-pwsx782 power 9.9999E+99 0.5 -> '9.9999499998749993750E+49' Inexact Rounded
-pwsx783 power 9.99991E+99 0.5 -> '9.9999549998987495444E+49' Inexact Rounded
-pwsx784 power 9.99994E+99 0.5 -> '9.9999699999549998650E+49' Inexact Rounded
-pwsx785 power 9.99995E+99 0.5 -> '9.9999749999687499219E+49' Inexact Rounded
-pwsx786 power 9.99999E+99 0.5 -> '9.9999949999987499994E+49' Inexact Rounded
-
--- subnormals and underflows [these can only result when eMax is < digits+1]
--- Etiny = -(Emax + (precision-1))
--- start with subnormal operands and normal results
-maxexponent: 9
-minexponent: -9
-precision: 9 -- Etiny=-17
-pwsx800 power 1E-17 0.5 -> 3.16227766E-9 Inexact Rounded
-pwsx801 power 10E-17 0.5 -> 1.00000000E-8 Inexact Rounded
-precision: 10 -- Etiny=-18
-pwsx802 power 10E-18 0.5 -> 3.162277660E-9 Inexact Rounded
-pwsx803 power 1E-18 0.5 -> 1.000000000E-9 Inexact Rounded
-
-precision: 11 -- Etiny=-19
-pwsx804 power 1E-19 0.5 -> 3.162277660E-10 Underflow Subnormal Inexact Rounded
--- The next test should be skipped for decNumber
-pwsx805 power 10E-19 0.5 -> 1.0000000000E-9 Inexact Rounded
-precision: 12 -- Etiny=-20
-pwsx806 power 10E-20 0.5 -> 3.1622776602E-10 Underflow Subnormal Inexact Rounded
-pwsx807 power 1E-20 0.5 -> 1.0000000000E-10 Underflow Subnormal Inexact Rounded
-
-precision: 13 -- Etiny=-21
-pwsx808 power 1E-21 0.5 -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded
-pwsx809 power 10E-21 0.5 -> 1.00000000000E-10 Underflow Subnormal Inexact Rounded
-precision: 14 -- Etiny=-22
-pwsx810 power 1E-21 0.5 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
-pwsx811 power 10E-22 0.5 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
-pwsx812 power 1E-22 0.5 -> 1.00000000000E-11 Underflow Subnormal Inexact Rounded
-
-
--- special values
-maxexponent: 999
-minexponent: -999
-pwsx820 power Inf 0.5 -> Infinity
-pwsx821 power -Inf 0.5 -> NaN Invalid_operation
-pwsx822 power NaN 0.5 -> NaN
-pwsx823 power sNaN 0.5 -> NaN Invalid_operation
--- propagating NaNs
-pwsx824 power sNaN123 0.5 -> NaN123 Invalid_operation
-pwsx825 power -sNaN321 0.5 -> -NaN321 Invalid_operation
-pwsx826 power NaN456 0.5 -> NaN456
-pwsx827 power -NaN654 0.5 -> -NaN654
-pwsx828 power NaN1 0.5 -> NaN1
-
--- Null test
-pwsx900 power # 0.5 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- powersqrt.decTest -- decimal square root, using power --
+-- Copyright (c) IBM Corporation, 2004, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- These testcases are taken from squareroot.decTest but are
+-- evaluated using the power operator. The differences in results
+-- (153 out of 2856) fall into the following categories:
+--
+-- x ** 0.5 (x>0) has no preferred exponent, and is Inexact
+-- (and hence full precision); almost all differences are
+-- in this category
+-- 0.00 ** 0.5 becomes 0 (not 0.0), etc.
+-- -0 ** 0.5 becomes 0 (never -0)
+-- Some exact subnormals become inexact and hence underflows
+
+extended: 1
+precision: 9
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- basics
+pwsx001 power 1 0.5 -> 1.00000000 Inexact Rounded
+pwsx002 power -1 0.5 -> NaN Invalid_operation
+pwsx003 power 1.00 0.5 -> 1.00000000 Inexact Rounded
+pwsx004 power -1.00 0.5 -> NaN Invalid_operation
+pwsx005 power 0 0.5 -> 0
+pwsx006 power 00.0 0.5 -> 0
+pwsx007 power 0.00 0.5 -> 0
+pwsx008 power 00.00 0.5 -> 0
+pwsx009 power 00.000 0.5 -> 0
+pwsx010 power 00.0000 0.5 -> 0
+pwsx011 power 00 0.5 -> 0
+
+pwsx012 power -2 0.5 -> NaN Invalid_operation
+pwsx013 power 2 0.5 -> 1.41421356 Inexact Rounded
+pwsx014 power -2.00 0.5 -> NaN Invalid_operation
+pwsx015 power 2.00 0.5 -> 1.41421356 Inexact Rounded
+pwsx016 power -0 0.5 -> 0
+pwsx017 power -0.0 0.5 -> 0
+pwsx018 power -00.00 0.5 -> 0
+pwsx019 power -00.000 0.5 -> 0
+pwsx020 power -0.0000 0.5 -> 0
+pwsx021 power -0E+9 0.5 -> 0
+pwsx022 power -0E+10 0.5 -> 0
+pwsx023 power -0E+11 0.5 -> 0
+pwsx024 power -0E+12 0.5 -> 0
+pwsx025 power -00 0.5 -> 0
+pwsx026 power 0E+5 0.5 -> 0
+pwsx027 power 4.0 0.5 -> 2.00000000 Inexact Rounded
+pwsx028 power 4.00 0.5 -> 2.00000000 Inexact Rounded
+
+pwsx030 power +0.1 0.5 -> 0.316227766 Inexact Rounded
+pwsx031 power -0.1 0.5 -> NaN Invalid_operation
+pwsx032 power +0.01 0.5 -> 0.100000000 Inexact Rounded
+pwsx033 power -0.01 0.5 -> NaN Invalid_operation
+pwsx034 power +0.001 0.5 -> 0.0316227766 Inexact Rounded
+pwsx035 power -0.001 0.5 -> NaN Invalid_operation
+pwsx036 power +0.000001 0.5 -> 0.00100000000 Inexact Rounded
+pwsx037 power -0.000001 0.5 -> NaN Invalid_operation
+pwsx038 power +0.000000000001 0.5 -> 0.00000100000000 Inexact Rounded
+pwsx039 power -0.000000000001 0.5 -> NaN Invalid_operation
+
+pwsx041 power 1.1 0.5 -> 1.04880885 Inexact Rounded
+pwsx042 power 1.10 0.5 -> 1.04880885 Inexact Rounded
+pwsx043 power 1.100 0.5 -> 1.04880885 Inexact Rounded
+pwsx044 power 1.110 0.5 -> 1.05356538 Inexact Rounded
+pwsx045 power -1.1 0.5 -> NaN Invalid_operation
+pwsx046 power -1.10 0.5 -> NaN Invalid_operation
+pwsx047 power -1.100 0.5 -> NaN Invalid_operation
+pwsx048 power -1.110 0.5 -> NaN Invalid_operation
+pwsx049 power 9.9 0.5 -> 3.14642654 Inexact Rounded
+pwsx050 power 9.90 0.5 -> 3.14642654 Inexact Rounded
+pwsx051 power 9.900 0.5 -> 3.14642654 Inexact Rounded
+pwsx052 power 9.990 0.5 -> 3.16069613 Inexact Rounded
+pwsx053 power -9.9 0.5 -> NaN Invalid_operation
+pwsx054 power -9.90 0.5 -> NaN Invalid_operation
+pwsx055 power -9.900 0.5 -> NaN Invalid_operation
+pwsx056 power -9.990 0.5 -> NaN Invalid_operation
+
+pwsx060 power 1 0.5 -> 1.00000000 Inexact Rounded
+pwsx061 power 1.0 0.5 -> 1.00000000 Inexact Rounded
+pwsx062 power 1.00 0.5 -> 1.00000000 Inexact Rounded
+pwsx063 power 10.0 0.5 -> 3.16227766 Inexact Rounded
+pwsx064 power 10.0 0.5 -> 3.16227766 Inexact Rounded
+pwsx065 power 10.0 0.5 -> 3.16227766 Inexact Rounded
+pwsx066 power 10.00 0.5 -> 3.16227766 Inexact Rounded
+pwsx067 power 100 0.5 -> 10.0000000 Inexact Rounded
+pwsx068 power 100.0 0.5 -> 10.0000000 Inexact Rounded
+pwsx069 power 100.00 0.5 -> 10.0000000 Inexact Rounded
+pwsx070 power 1.1000E+3 0.5 -> 33.1662479 Inexact Rounded
+pwsx071 power 1.10000E+3 0.5 -> 33.1662479 Inexact Rounded
+pwsx072 power -10.0 0.5 -> NaN Invalid_operation
+pwsx073 power -10.00 0.5 -> NaN Invalid_operation
+pwsx074 power -100.0 0.5 -> NaN Invalid_operation
+pwsx075 power -100.00 0.5 -> NaN Invalid_operation
+pwsx076 power -1.1000E+3 0.5 -> NaN Invalid_operation
+pwsx077 power -1.10000E+3 0.5 -> NaN Invalid_operation
+
+-- famous squares
+pwsx080 power 1 0.5 -> 1.00000000 Inexact Rounded
+pwsx081 power 4 0.5 -> 2.00000000 Inexact Rounded
+pwsx082 power 9 0.5 -> 3.00000000 Inexact Rounded
+pwsx083 power 16 0.5 -> 4.00000000 Inexact Rounded
+pwsx084 power 25 0.5 -> 5.00000000 Inexact Rounded
+pwsx085 power 36 0.5 -> 6.00000000 Inexact Rounded
+pwsx086 power 49 0.5 -> 7.00000000 Inexact Rounded
+pwsx087 power 64 0.5 -> 8.00000000 Inexact Rounded
+pwsx088 power 81 0.5 -> 9.00000000 Inexact Rounded
+pwsx089 power 100 0.5 -> 10.0000000 Inexact Rounded
+pwsx090 power 121 0.5 -> 11.0000000 Inexact Rounded
+pwsx091 power 144 0.5 -> 12.0000000 Inexact Rounded
+pwsx092 power 169 0.5 -> 13.0000000 Inexact Rounded
+pwsx093 power 256 0.5 -> 16.0000000 Inexact Rounded
+pwsx094 power 1024 0.5 -> 32.0000000 Inexact Rounded
+pwsx095 power 4096 0.5 -> 64.0000000 Inexact Rounded
+pwsx100 power 0.01 0.5 -> 0.100000000 Inexact Rounded
+pwsx101 power 0.04 0.5 -> 0.200000000 Inexact Rounded
+pwsx102 power 0.09 0.5 -> 0.300000000 Inexact Rounded
+pwsx103 power 0.16 0.5 -> 0.400000000 Inexact Rounded
+pwsx104 power 0.25 0.5 -> 0.500000000 Inexact Rounded
+pwsx105 power 0.36 0.5 -> 0.600000000 Inexact Rounded
+pwsx106 power 0.49 0.5 -> 0.700000000 Inexact Rounded
+pwsx107 power 0.64 0.5 -> 0.800000000 Inexact Rounded
+pwsx108 power 0.81 0.5 -> 0.900000000 Inexact Rounded
+pwsx109 power 1.00 0.5 -> 1.00000000 Inexact Rounded
+pwsx110 power 1.21 0.5 -> 1.10000000 Inexact Rounded
+pwsx111 power 1.44 0.5 -> 1.20000000 Inexact Rounded
+pwsx112 power 1.69 0.5 -> 1.30000000 Inexact Rounded
+pwsx113 power 2.56 0.5 -> 1.60000000 Inexact Rounded
+pwsx114 power 10.24 0.5 -> 3.20000000 Inexact Rounded
+pwsx115 power 40.96 0.5 -> 6.40000000 Inexact Rounded
+
+-- Precision 1 squareroot tests [exhaustive, plus exponent adjusts]
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+precision: 1
+pwsx1201 power 0.1 0.5 -> 0.3 Inexact Rounded
+pwsx1202 power 0.01 0.5 -> 0.1 Inexact Rounded
+pwsx1203 power 1.0E-1 0.5 -> 0.3 Inexact Rounded
+pwsx1204 power 1.00E-2 0.5 -> 0.1 Inexact Rounded
+pwsx1205 power 1E-3 0.5 -> 0.03 Inexact Rounded
+pwsx1206 power 1E+1 0.5 -> 3 Inexact Rounded
+pwsx1207 power 1E+2 0.5 -> 1E+1 Inexact Rounded
+pwsx1208 power 1E+3 0.5 -> 3E+1 Inexact Rounded
+pwsx1209 power 0.2 0.5 -> 0.4 Inexact Rounded
+pwsx1210 power 0.02 0.5 -> 0.1 Inexact Rounded
+pwsx1211 power 2.0E-1 0.5 -> 0.4 Inexact Rounded
+pwsx1212 power 2.00E-2 0.5 -> 0.1 Inexact Rounded
+pwsx1213 power 2E-3 0.5 -> 0.04 Inexact Rounded
+pwsx1214 power 2E+1 0.5 -> 4 Inexact Rounded
+pwsx1215 power 2E+2 0.5 -> 1E+1 Inexact Rounded
+pwsx1216 power 2E+3 0.5 -> 4E+1 Inexact Rounded
+pwsx1217 power 0.3 0.5 -> 0.5 Inexact Rounded
+pwsx1218 power 0.03 0.5 -> 0.2 Inexact Rounded
+pwsx1219 power 3.0E-1 0.5 -> 0.5 Inexact Rounded
+pwsx1220 power 3.00E-2 0.5 -> 0.2 Inexact Rounded
+pwsx1221 power 3E-3 0.5 -> 0.05 Inexact Rounded
+pwsx1222 power 3E+1 0.5 -> 5 Inexact Rounded
+pwsx1223 power 3E+2 0.5 -> 2E+1 Inexact Rounded
+pwsx1224 power 3E+3 0.5 -> 5E+1 Inexact Rounded
+pwsx1225 power 0.4 0.5 -> 0.6 Inexact Rounded
+pwsx1226 power 0.04 0.5 -> 0.2 Inexact Rounded
+pwsx1227 power 4.0E-1 0.5 -> 0.6 Inexact Rounded
+pwsx1228 power 4.00E-2 0.5 -> 0.2 Inexact Rounded
+pwsx1229 power 4E-3 0.5 -> 0.06 Inexact Rounded
+pwsx1230 power 4E+1 0.5 -> 6 Inexact Rounded
+pwsx1231 power 4E+2 0.5 -> 2E+1 Inexact Rounded
+pwsx1232 power 4E+3 0.5 -> 6E+1 Inexact Rounded
+pwsx1233 power 0.5 0.5 -> 0.7 Inexact Rounded
+pwsx1234 power 0.05 0.5 -> 0.2 Inexact Rounded
+pwsx1235 power 5.0E-1 0.5 -> 0.7 Inexact Rounded
+pwsx1236 power 5.00E-2 0.5 -> 0.2 Inexact Rounded
+pwsx1237 power 5E-3 0.5 -> 0.07 Inexact Rounded
+pwsx1238 power 5E+1 0.5 -> 7 Inexact Rounded
+pwsx1239 power 5E+2 0.5 -> 2E+1 Inexact Rounded
+pwsx1240 power 5E+3 0.5 -> 7E+1 Inexact Rounded
+pwsx1241 power 0.6 0.5 -> 0.8 Inexact Rounded
+pwsx1242 power 0.06 0.5 -> 0.2 Inexact Rounded
+pwsx1243 power 6.0E-1 0.5 -> 0.8 Inexact Rounded
+pwsx1244 power 6.00E-2 0.5 -> 0.2 Inexact Rounded
+pwsx1245 power 6E-3 0.5 -> 0.08 Inexact Rounded
+pwsx1246 power 6E+1 0.5 -> 8 Inexact Rounded
+pwsx1247 power 6E+2 0.5 -> 2E+1 Inexact Rounded
+pwsx1248 power 6E+3 0.5 -> 8E+1 Inexact Rounded
+pwsx1249 power 0.7 0.5 -> 0.8 Inexact Rounded
+pwsx1250 power 0.07 0.5 -> 0.3 Inexact Rounded
+pwsx1251 power 7.0E-1 0.5 -> 0.8 Inexact Rounded
+pwsx1252 power 7.00E-2 0.5 -> 0.3 Inexact Rounded
+pwsx1253 power 7E-3 0.5 -> 0.08 Inexact Rounded
+pwsx1254 power 7E+1 0.5 -> 8 Inexact Rounded
+pwsx1255 power 7E+2 0.5 -> 3E+1 Inexact Rounded
+pwsx1256 power 7E+3 0.5 -> 8E+1 Inexact Rounded
+pwsx1257 power 0.8 0.5 -> 0.9 Inexact Rounded
+pwsx1258 power 0.08 0.5 -> 0.3 Inexact Rounded
+pwsx1259 power 8.0E-1 0.5 -> 0.9 Inexact Rounded
+pwsx1260 power 8.00E-2 0.5 -> 0.3 Inexact Rounded
+pwsx1261 power 8E-3 0.5 -> 0.09 Inexact Rounded
+pwsx1262 power 8E+1 0.5 -> 9 Inexact Rounded
+pwsx1263 power 8E+2 0.5 -> 3E+1 Inexact Rounded
+pwsx1264 power 8E+3 0.5 -> 9E+1 Inexact Rounded
+pwsx1265 power 0.9 0.5 -> 0.9 Inexact Rounded
+pwsx1266 power 0.09 0.5 -> 0.3 Inexact Rounded
+pwsx1267 power 9.0E-1 0.5 -> 0.9 Inexact Rounded
+pwsx1268 power 9.00E-2 0.5 -> 0.3 Inexact Rounded
+pwsx1269 power 9E-3 0.5 -> 0.09 Inexact Rounded
+pwsx1270 power 9E+1 0.5 -> 9 Inexact Rounded
+pwsx1271 power 9E+2 0.5 -> 3E+1 Inexact Rounded
+pwsx1272 power 9E+3 0.5 -> 9E+1 Inexact Rounded
+
+-- Precision 2 squareroot tests [exhaustive, plus exponent adjusts]
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+precision: 2
+pwsx2201 power 0.1 0.5 -> 0.32 Inexact Rounded
+pwsx2202 power 0.01 0.5 -> 0.10 Inexact Rounded
+pwsx2203 power 1.0E-1 0.5 -> 0.32 Inexact Rounded
+pwsx2204 power 1.00E-2 0.5 -> 0.10 Inexact Rounded
+pwsx2205 power 1E-3 0.5 -> 0.032 Inexact Rounded
+pwsx2206 power 1E+1 0.5 -> 3.2 Inexact Rounded
+pwsx2207 power 1E+2 0.5 -> 10 Inexact Rounded
+pwsx2208 power 1E+3 0.5 -> 32 Inexact Rounded
+pwsx2209 power 0.2 0.5 -> 0.45 Inexact Rounded
+pwsx2210 power 0.02 0.5 -> 0.14 Inexact Rounded
+pwsx2211 power 2.0E-1 0.5 -> 0.45 Inexact Rounded
+pwsx2212 power 2.00E-2 0.5 -> 0.14 Inexact Rounded
+pwsx2213 power 2E-3 0.5 -> 0.045 Inexact Rounded
+pwsx2214 power 2E+1 0.5 -> 4.5 Inexact Rounded
+pwsx2215 power 2E+2 0.5 -> 14 Inexact Rounded
+pwsx2216 power 2E+3 0.5 -> 45 Inexact Rounded
+pwsx2217 power 0.3 0.5 -> 0.55 Inexact Rounded
+pwsx2218 power 0.03 0.5 -> 0.17 Inexact Rounded
+pwsx2219 power 3.0E-1 0.5 -> 0.55 Inexact Rounded
+pwsx2220 power 3.00E-2 0.5 -> 0.17 Inexact Rounded
+pwsx2221 power 3E-3 0.5 -> 0.055 Inexact Rounded
+pwsx2222 power 3E+1 0.5 -> 5.5 Inexact Rounded
+pwsx2223 power 3E+2 0.5 -> 17 Inexact Rounded
+pwsx2224 power 3E+3 0.5 -> 55 Inexact Rounded
+pwsx2225 power 0.4 0.5 -> 0.63 Inexact Rounded
+pwsx2226 power 0.04 0.5 -> 0.20 Inexact Rounded
+pwsx2227 power 4.0E-1 0.5 -> 0.63 Inexact Rounded
+pwsx2228 power 4.00E-2 0.5 -> 0.20 Inexact Rounded
+pwsx2229 power 4E-3 0.5 -> 0.063 Inexact Rounded
+pwsx2230 power 4E+1 0.5 -> 6.3 Inexact Rounded
+pwsx2231 power 4E+2 0.5 -> 20 Inexact Rounded
+pwsx2232 power 4E+3 0.5 -> 63 Inexact Rounded
+pwsx2233 power 0.5 0.5 -> 0.71 Inexact Rounded
+pwsx2234 power 0.05 0.5 -> 0.22 Inexact Rounded
+pwsx2235 power 5.0E-1 0.5 -> 0.71 Inexact Rounded
+pwsx2236 power 5.00E-2 0.5 -> 0.22 Inexact Rounded
+pwsx2237 power 5E-3 0.5 -> 0.071 Inexact Rounded
+pwsx2238 power 5E+1 0.5 -> 7.1 Inexact Rounded
+pwsx2239 power 5E+2 0.5 -> 22 Inexact Rounded
+pwsx2240 power 5E+3 0.5 -> 71 Inexact Rounded
+pwsx2241 power 0.6 0.5 -> 0.77 Inexact Rounded
+pwsx2242 power 0.06 0.5 -> 0.24 Inexact Rounded
+pwsx2243 power 6.0E-1 0.5 -> 0.77 Inexact Rounded
+pwsx2244 power 6.00E-2 0.5 -> 0.24 Inexact Rounded
+pwsx2245 power 6E-3 0.5 -> 0.077 Inexact Rounded
+pwsx2246 power 6E+1 0.5 -> 7.7 Inexact Rounded
+pwsx2247 power 6E+2 0.5 -> 24 Inexact Rounded
+pwsx2248 power 6E+3 0.5 -> 77 Inexact Rounded
+pwsx2249 power 0.7 0.5 -> 0.84 Inexact Rounded
+pwsx2250 power 0.07 0.5 -> 0.26 Inexact Rounded
+pwsx2251 power 7.0E-1 0.5 -> 0.84 Inexact Rounded
+pwsx2252 power 7.00E-2 0.5 -> 0.26 Inexact Rounded
+pwsx2253 power 7E-3 0.5 -> 0.084 Inexact Rounded
+pwsx2254 power 7E+1 0.5 -> 8.4 Inexact Rounded
+pwsx2255 power 7E+2 0.5 -> 26 Inexact Rounded
+pwsx2256 power 7E+3 0.5 -> 84 Inexact Rounded
+pwsx2257 power 0.8 0.5 -> 0.89 Inexact Rounded
+pwsx2258 power 0.08 0.5 -> 0.28 Inexact Rounded
+pwsx2259 power 8.0E-1 0.5 -> 0.89 Inexact Rounded
+pwsx2260 power 8.00E-2 0.5 -> 0.28 Inexact Rounded
+pwsx2261 power 8E-3 0.5 -> 0.089 Inexact Rounded
+pwsx2262 power 8E+1 0.5 -> 8.9 Inexact Rounded
+pwsx2263 power 8E+2 0.5 -> 28 Inexact Rounded
+pwsx2264 power 8E+3 0.5 -> 89 Inexact Rounded
+pwsx2265 power 0.9 0.5 -> 0.95 Inexact Rounded
+pwsx2266 power 0.09 0.5 -> 0.30 Inexact Rounded
+pwsx2267 power 9.0E-1 0.5 -> 0.95 Inexact Rounded
+pwsx2268 power 9.00E-2 0.5 -> 0.30 Inexact Rounded
+pwsx2269 power 9E-3 0.5 -> 0.095 Inexact Rounded
+pwsx2270 power 9E+1 0.5 -> 9.5 Inexact Rounded
+pwsx2271 power 9E+2 0.5 -> 30 Inexact Rounded
+pwsx2272 power 9E+3 0.5 -> 95 Inexact Rounded
+pwsx2273 power 0.10 0.5 -> 0.32 Inexact Rounded
+pwsx2274 power 0.010 0.5 -> 0.10 Inexact Rounded
+pwsx2275 power 10.0E-1 0.5 -> 1.0 Inexact Rounded
+pwsx2276 power 10.00E-2 0.5 -> 0.32 Inexact Rounded
+pwsx2277 power 10E-3 0.5 -> 0.10 Inexact Rounded
+pwsx2278 power 10E+1 0.5 -> 10 Inexact Rounded
+pwsx2279 power 10E+2 0.5 -> 32 Inexact Rounded
+pwsx2280 power 10E+3 0.5 -> 1.0E+2 Inexact Rounded
+pwsx2281 power 0.11 0.5 -> 0.33 Inexact Rounded
+pwsx2282 power 0.011 0.5 -> 0.10 Inexact Rounded
+pwsx2283 power 11.0E-1 0.5 -> 1.0 Inexact Rounded
+pwsx2284 power 11.00E-2 0.5 -> 0.33 Inexact Rounded
+pwsx2285 power 11E-3 0.5 -> 0.10 Inexact Rounded
+pwsx2286 power 11E+1 0.5 -> 10 Inexact Rounded
+pwsx2287 power 11E+2 0.5 -> 33 Inexact Rounded
+pwsx2288 power 11E+3 0.5 -> 1.0E+2 Inexact Rounded
+pwsx2289 power 0.12 0.5 -> 0.35 Inexact Rounded
+pwsx2290 power 0.012 0.5 -> 0.11 Inexact Rounded
+pwsx2291 power 12.0E-1 0.5 -> 1.1 Inexact Rounded
+pwsx2292 power 12.00E-2 0.5 -> 0.35 Inexact Rounded
+pwsx2293 power 12E-3 0.5 -> 0.11 Inexact Rounded
+pwsx2294 power 12E+1 0.5 -> 11 Inexact Rounded
+pwsx2295 power 12E+2 0.5 -> 35 Inexact Rounded
+pwsx2296 power 12E+3 0.5 -> 1.1E+2 Inexact Rounded
+pwsx2297 power 0.13 0.5 -> 0.36 Inexact Rounded
+pwsx2298 power 0.013 0.5 -> 0.11 Inexact Rounded
+pwsx2299 power 13.0E-1 0.5 -> 1.1 Inexact Rounded
+pwsx2300 power 13.00E-2 0.5 -> 0.36 Inexact Rounded
+pwsx2301 power 13E-3 0.5 -> 0.11 Inexact Rounded
+pwsx2302 power 13E+1 0.5 -> 11 Inexact Rounded
+pwsx2303 power 13E+2 0.5 -> 36 Inexact Rounded
+pwsx2304 power 13E+3 0.5 -> 1.1E+2 Inexact Rounded
+pwsx2305 power 0.14 0.5 -> 0.37 Inexact Rounded
+pwsx2306 power 0.014 0.5 -> 0.12 Inexact Rounded
+pwsx2307 power 14.0E-1 0.5 -> 1.2 Inexact Rounded
+pwsx2308 power 14.00E-2 0.5 -> 0.37 Inexact Rounded
+pwsx2309 power 14E-3 0.5 -> 0.12 Inexact Rounded
+pwsx2310 power 14E+1 0.5 -> 12 Inexact Rounded
+pwsx2311 power 14E+2 0.5 -> 37 Inexact Rounded
+pwsx2312 power 14E+3 0.5 -> 1.2E+2 Inexact Rounded
+pwsx2313 power 0.15 0.5 -> 0.39 Inexact Rounded
+pwsx2314 power 0.015 0.5 -> 0.12 Inexact Rounded
+pwsx2315 power 15.0E-1 0.5 -> 1.2 Inexact Rounded
+pwsx2316 power 15.00E-2 0.5 -> 0.39 Inexact Rounded
+pwsx2317 power 15E-3 0.5 -> 0.12 Inexact Rounded
+pwsx2318 power 15E+1 0.5 -> 12 Inexact Rounded
+pwsx2319 power 15E+2 0.5 -> 39 Inexact Rounded
+pwsx2320 power 15E+3 0.5 -> 1.2E+2 Inexact Rounded
+pwsx2321 power 0.16 0.5 -> 0.40 Inexact Rounded
+pwsx2322 power 0.016 0.5 -> 0.13 Inexact Rounded
+pwsx2323 power 16.0E-1 0.5 -> 1.3 Inexact Rounded
+pwsx2324 power 16.00E-2 0.5 -> 0.40 Inexact Rounded
+pwsx2325 power 16E-3 0.5 -> 0.13 Inexact Rounded
+pwsx2326 power 16E+1 0.5 -> 13 Inexact Rounded
+pwsx2327 power 16E+2 0.5 -> 40 Inexact Rounded
+pwsx2328 power 16E+3 0.5 -> 1.3E+2 Inexact Rounded
+pwsx2329 power 0.17 0.5 -> 0.41 Inexact Rounded
+pwsx2330 power 0.017 0.5 -> 0.13 Inexact Rounded
+pwsx2331 power 17.0E-1 0.5 -> 1.3 Inexact Rounded
+pwsx2332 power 17.00E-2 0.5 -> 0.41 Inexact Rounded
+pwsx2333 power 17E-3 0.5 -> 0.13 Inexact Rounded
+pwsx2334 power 17E+1 0.5 -> 13 Inexact Rounded
+pwsx2335 power 17E+2 0.5 -> 41 Inexact Rounded
+pwsx2336 power 17E+3 0.5 -> 1.3E+2 Inexact Rounded
+pwsx2337 power 0.18 0.5 -> 0.42 Inexact Rounded
+pwsx2338 power 0.018 0.5 -> 0.13 Inexact Rounded
+pwsx2339 power 18.0E-1 0.5 -> 1.3 Inexact Rounded
+pwsx2340 power 18.00E-2 0.5 -> 0.42 Inexact Rounded
+pwsx2341 power 18E-3 0.5 -> 0.13 Inexact Rounded
+pwsx2342 power 18E+1 0.5 -> 13 Inexact Rounded
+pwsx2343 power 18E+2 0.5 -> 42 Inexact Rounded
+pwsx2344 power 18E+3 0.5 -> 1.3E+2 Inexact Rounded
+pwsx2345 power 0.19 0.5 -> 0.44 Inexact Rounded
+pwsx2346 power 0.019 0.5 -> 0.14 Inexact Rounded
+pwsx2347 power 19.0E-1 0.5 -> 1.4 Inexact Rounded
+pwsx2348 power 19.00E-2 0.5 -> 0.44 Inexact Rounded
+pwsx2349 power 19E-3 0.5 -> 0.14 Inexact Rounded
+pwsx2350 power 19E+1 0.5 -> 14 Inexact Rounded
+pwsx2351 power 19E+2 0.5 -> 44 Inexact Rounded
+pwsx2352 power 19E+3 0.5 -> 1.4E+2 Inexact Rounded
+pwsx2353 power 0.20 0.5 -> 0.45 Inexact Rounded
+pwsx2354 power 0.020 0.5 -> 0.14 Inexact Rounded
+pwsx2355 power 20.0E-1 0.5 -> 1.4 Inexact Rounded
+pwsx2356 power 20.00E-2 0.5 -> 0.45 Inexact Rounded
+pwsx2357 power 20E-3 0.5 -> 0.14 Inexact Rounded
+pwsx2358 power 20E+1 0.5 -> 14 Inexact Rounded
+pwsx2359 power 20E+2 0.5 -> 45 Inexact Rounded
+pwsx2360 power 20E+3 0.5 -> 1.4E+2 Inexact Rounded
+pwsx2361 power 0.21 0.5 -> 0.46 Inexact Rounded
+pwsx2362 power 0.021 0.5 -> 0.14 Inexact Rounded
+pwsx2363 power 21.0E-1 0.5 -> 1.4 Inexact Rounded
+pwsx2364 power 21.00E-2 0.5 -> 0.46 Inexact Rounded
+pwsx2365 power 21E-3 0.5 -> 0.14 Inexact Rounded
+pwsx2366 power 21E+1 0.5 -> 14 Inexact Rounded
+pwsx2367 power 21E+2 0.5 -> 46 Inexact Rounded
+pwsx2368 power 21E+3 0.5 -> 1.4E+2 Inexact Rounded
+pwsx2369 power 0.22 0.5 -> 0.47 Inexact Rounded
+pwsx2370 power 0.022 0.5 -> 0.15 Inexact Rounded
+pwsx2371 power 22.0E-1 0.5 -> 1.5 Inexact Rounded
+pwsx2372 power 22.00E-2 0.5 -> 0.47 Inexact Rounded
+pwsx2373 power 22E-3 0.5 -> 0.15 Inexact Rounded
+pwsx2374 power 22E+1 0.5 -> 15 Inexact Rounded
+pwsx2375 power 22E+2 0.5 -> 47 Inexact Rounded
+pwsx2376 power 22E+3 0.5 -> 1.5E+2 Inexact Rounded
+pwsx2377 power 0.23 0.5 -> 0.48 Inexact Rounded
+pwsx2378 power 0.023 0.5 -> 0.15 Inexact Rounded
+pwsx2379 power 23.0E-1 0.5 -> 1.5 Inexact Rounded
+pwsx2380 power 23.00E-2 0.5 -> 0.48 Inexact Rounded
+pwsx2381 power 23E-3 0.5 -> 0.15 Inexact Rounded
+pwsx2382 power 23E+1 0.5 -> 15 Inexact Rounded
+pwsx2383 power 23E+2 0.5 -> 48 Inexact Rounded
+pwsx2384 power 23E+3 0.5 -> 1.5E+2 Inexact Rounded
+pwsx2385 power 0.24 0.5 -> 0.49 Inexact Rounded
+pwsx2386 power 0.024 0.5 -> 0.15 Inexact Rounded
+pwsx2387 power 24.0E-1 0.5 -> 1.5 Inexact Rounded
+pwsx2388 power 24.00E-2 0.5 -> 0.49 Inexact Rounded
+pwsx2389 power 24E-3 0.5 -> 0.15 Inexact Rounded
+pwsx2390 power 24E+1 0.5 -> 15 Inexact Rounded
+pwsx2391 power 24E+2 0.5 -> 49 Inexact Rounded
+pwsx2392 power 24E+3 0.5 -> 1.5E+2 Inexact Rounded
+pwsx2393 power 0.25 0.5 -> 0.50 Inexact Rounded
+pwsx2394 power 0.025 0.5 -> 0.16 Inexact Rounded
+pwsx2395 power 25.0E-1 0.5 -> 1.6 Inexact Rounded
+pwsx2396 power 25.00E-2 0.5 -> 0.50 Inexact Rounded
+pwsx2397 power 25E-3 0.5 -> 0.16 Inexact Rounded
+pwsx2398 power 25E+1 0.5 -> 16 Inexact Rounded
+pwsx2399 power 25E+2 0.5 -> 50 Inexact Rounded
+pwsx2400 power 25E+3 0.5 -> 1.6E+2 Inexact Rounded
+pwsx2401 power 0.26 0.5 -> 0.51 Inexact Rounded
+pwsx2402 power 0.026 0.5 -> 0.16 Inexact Rounded
+pwsx2403 power 26.0E-1 0.5 -> 1.6 Inexact Rounded
+pwsx2404 power 26.00E-2 0.5 -> 0.51 Inexact Rounded
+pwsx2405 power 26E-3 0.5 -> 0.16 Inexact Rounded
+pwsx2406 power 26E+1 0.5 -> 16 Inexact Rounded
+pwsx2407 power 26E+2 0.5 -> 51 Inexact Rounded
+pwsx2408 power 26E+3 0.5 -> 1.6E+2 Inexact Rounded
+pwsx2409 power 0.27 0.5 -> 0.52 Inexact Rounded
+pwsx2410 power 0.027 0.5 -> 0.16 Inexact Rounded
+pwsx2411 power 27.0E-1 0.5 -> 1.6 Inexact Rounded
+pwsx2412 power 27.00E-2 0.5 -> 0.52 Inexact Rounded
+pwsx2413 power 27E-3 0.5 -> 0.16 Inexact Rounded
+pwsx2414 power 27E+1 0.5 -> 16 Inexact Rounded
+pwsx2415 power 27E+2 0.5 -> 52 Inexact Rounded
+pwsx2416 power 27E+3 0.5 -> 1.6E+2 Inexact Rounded
+pwsx2417 power 0.28 0.5 -> 0.53 Inexact Rounded
+pwsx2418 power 0.028 0.5 -> 0.17 Inexact Rounded
+pwsx2419 power 28.0E-1 0.5 -> 1.7 Inexact Rounded
+pwsx2420 power 28.00E-2 0.5 -> 0.53 Inexact Rounded
+pwsx2421 power 28E-3 0.5 -> 0.17 Inexact Rounded
+pwsx2422 power 28E+1 0.5 -> 17 Inexact Rounded
+pwsx2423 power 28E+2 0.5 -> 53 Inexact Rounded
+pwsx2424 power 28E+3 0.5 -> 1.7E+2 Inexact Rounded
+pwsx2425 power 0.29 0.5 -> 0.54 Inexact Rounded
+pwsx2426 power 0.029 0.5 -> 0.17 Inexact Rounded
+pwsx2427 power 29.0E-1 0.5 -> 1.7 Inexact Rounded
+pwsx2428 power 29.00E-2 0.5 -> 0.54 Inexact Rounded
+pwsx2429 power 29E-3 0.5 -> 0.17 Inexact Rounded
+pwsx2430 power 29E+1 0.5 -> 17 Inexact Rounded
+pwsx2431 power 29E+2 0.5 -> 54 Inexact Rounded
+pwsx2432 power 29E+3 0.5 -> 1.7E+2 Inexact Rounded
+pwsx2433 power 0.30 0.5 -> 0.55 Inexact Rounded
+pwsx2434 power 0.030 0.5 -> 0.17 Inexact Rounded
+pwsx2435 power 30.0E-1 0.5 -> 1.7 Inexact Rounded
+pwsx2436 power 30.00E-2 0.5 -> 0.55 Inexact Rounded
+pwsx2437 power 30E-3 0.5 -> 0.17 Inexact Rounded
+pwsx2438 power 30E+1 0.5 -> 17 Inexact Rounded
+pwsx2439 power 30E+2 0.5 -> 55 Inexact Rounded
+pwsx2440 power 30E+3 0.5 -> 1.7E+2 Inexact Rounded
+pwsx2441 power 0.31 0.5 -> 0.56 Inexact Rounded
+pwsx2442 power 0.031 0.5 -> 0.18 Inexact Rounded
+pwsx2443 power 31.0E-1 0.5 -> 1.8 Inexact Rounded
+pwsx2444 power 31.00E-2 0.5 -> 0.56 Inexact Rounded
+pwsx2445 power 31E-3 0.5 -> 0.18 Inexact Rounded
+pwsx2446 power 31E+1 0.5 -> 18 Inexact Rounded
+pwsx2447 power 31E+2 0.5 -> 56 Inexact Rounded
+pwsx2448 power 31E+3 0.5 -> 1.8E+2 Inexact Rounded
+pwsx2449 power 0.32 0.5 -> 0.57 Inexact Rounded
+pwsx2450 power 0.032 0.5 -> 0.18 Inexact Rounded
+pwsx2451 power 32.0E-1 0.5 -> 1.8 Inexact Rounded
+pwsx2452 power 32.00E-2 0.5 -> 0.57 Inexact Rounded
+pwsx2453 power 32E-3 0.5 -> 0.18 Inexact Rounded
+pwsx2454 power 32E+1 0.5 -> 18 Inexact Rounded
+pwsx2455 power 32E+2 0.5 -> 57 Inexact Rounded
+pwsx2456 power 32E+3 0.5 -> 1.8E+2 Inexact Rounded
+pwsx2457 power 0.33 0.5 -> 0.57 Inexact Rounded
+pwsx2458 power 0.033 0.5 -> 0.18 Inexact Rounded
+pwsx2459 power 33.0E-1 0.5 -> 1.8 Inexact Rounded
+pwsx2460 power 33.00E-2 0.5 -> 0.57 Inexact Rounded
+pwsx2461 power 33E-3 0.5 -> 0.18 Inexact Rounded
+pwsx2462 power 33E+1 0.5 -> 18 Inexact Rounded
+pwsx2463 power 33E+2 0.5 -> 57 Inexact Rounded
+pwsx2464 power 33E+3 0.5 -> 1.8E+2 Inexact Rounded
+pwsx2465 power 0.34 0.5 -> 0.58 Inexact Rounded
+pwsx2466 power 0.034 0.5 -> 0.18 Inexact Rounded
+pwsx2467 power 34.0E-1 0.5 -> 1.8 Inexact Rounded
+pwsx2468 power 34.00E-2 0.5 -> 0.58 Inexact Rounded
+pwsx2469 power 34E-3 0.5 -> 0.18 Inexact Rounded
+pwsx2470 power 34E+1 0.5 -> 18 Inexact Rounded
+pwsx2471 power 34E+2 0.5 -> 58 Inexact Rounded
+pwsx2472 power 34E+3 0.5 -> 1.8E+2 Inexact Rounded
+pwsx2473 power 0.35 0.5 -> 0.59 Inexact Rounded
+pwsx2474 power 0.035 0.5 -> 0.19 Inexact Rounded
+pwsx2475 power 35.0E-1 0.5 -> 1.9 Inexact Rounded
+pwsx2476 power 35.00E-2 0.5 -> 0.59 Inexact Rounded
+pwsx2477 power 35E-3 0.5 -> 0.19 Inexact Rounded
+pwsx2478 power 35E+1 0.5 -> 19 Inexact Rounded
+pwsx2479 power 35E+2 0.5 -> 59 Inexact Rounded
+pwsx2480 power 35E+3 0.5 -> 1.9E+2 Inexact Rounded
+pwsx2481 power 0.36 0.5 -> 0.60 Inexact Rounded
+pwsx2482 power 0.036 0.5 -> 0.19 Inexact Rounded
+pwsx2483 power 36.0E-1 0.5 -> 1.9 Inexact Rounded
+pwsx2484 power 36.00E-2 0.5 -> 0.60 Inexact Rounded
+pwsx2485 power 36E-3 0.5 -> 0.19 Inexact Rounded
+pwsx2486 power 36E+1 0.5 -> 19 Inexact Rounded
+pwsx2487 power 36E+2 0.5 -> 60 Inexact Rounded
+pwsx2488 power 36E+3 0.5 -> 1.9E+2 Inexact Rounded
+pwsx2489 power 0.37 0.5 -> 0.61 Inexact Rounded
+pwsx2490 power 0.037 0.5 -> 0.19 Inexact Rounded
+pwsx2491 power 37.0E-1 0.5 -> 1.9 Inexact Rounded
+pwsx2492 power 37.00E-2 0.5 -> 0.61 Inexact Rounded
+pwsx2493 power 37E-3 0.5 -> 0.19 Inexact Rounded
+pwsx2494 power 37E+1 0.5 -> 19 Inexact Rounded
+pwsx2495 power 37E+2 0.5 -> 61 Inexact Rounded
+pwsx2496 power 37E+3 0.5 -> 1.9E+2 Inexact Rounded
+pwsx2497 power 0.38 0.5 -> 0.62 Inexact Rounded
+pwsx2498 power 0.038 0.5 -> 0.19 Inexact Rounded
+pwsx2499 power 38.0E-1 0.5 -> 1.9 Inexact Rounded
+pwsx2500 power 38.00E-2 0.5 -> 0.62 Inexact Rounded
+pwsx2501 power 38E-3 0.5 -> 0.19 Inexact Rounded
+pwsx2502 power 38E+1 0.5 -> 19 Inexact Rounded
+pwsx2503 power 38E+2 0.5 -> 62 Inexact Rounded
+pwsx2504 power 38E+3 0.5 -> 1.9E+2 Inexact Rounded
+pwsx2505 power 0.39 0.5 -> 0.62 Inexact Rounded
+pwsx2506 power 0.039 0.5 -> 0.20 Inexact Rounded
+pwsx2507 power 39.0E-1 0.5 -> 2.0 Inexact Rounded
+pwsx2508 power 39.00E-2 0.5 -> 0.62 Inexact Rounded
+pwsx2509 power 39E-3 0.5 -> 0.20 Inexact Rounded
+pwsx2510 power 39E+1 0.5 -> 20 Inexact Rounded
+pwsx2511 power 39E+2 0.5 -> 62 Inexact Rounded
+pwsx2512 power 39E+3 0.5 -> 2.0E+2 Inexact Rounded
+pwsx2513 power 0.40 0.5 -> 0.63 Inexact Rounded
+pwsx2514 power 0.040 0.5 -> 0.20 Inexact Rounded
+pwsx2515 power 40.0E-1 0.5 -> 2.0 Inexact Rounded
+pwsx2516 power 40.00E-2 0.5 -> 0.63 Inexact Rounded
+pwsx2517 power 40E-3 0.5 -> 0.20 Inexact Rounded
+pwsx2518 power 40E+1 0.5 -> 20 Inexact Rounded
+pwsx2519 power 40E+2 0.5 -> 63 Inexact Rounded
+pwsx2520 power 40E+3 0.5 -> 2.0E+2 Inexact Rounded
+pwsx2521 power 0.41 0.5 -> 0.64 Inexact Rounded
+pwsx2522 power 0.041 0.5 -> 0.20 Inexact Rounded
+pwsx2523 power 41.0E-1 0.5 -> 2.0 Inexact Rounded
+pwsx2524 power 41.00E-2 0.5 -> 0.64 Inexact Rounded
+pwsx2525 power 41E-3 0.5 -> 0.20 Inexact Rounded
+pwsx2526 power 41E+1 0.5 -> 20 Inexact Rounded
+pwsx2527 power 41E+2 0.5 -> 64 Inexact Rounded
+pwsx2528 power 41E+3 0.5 -> 2.0E+2 Inexact Rounded
+pwsx2529 power 0.42 0.5 -> 0.65 Inexact Rounded
+pwsx2530 power 0.042 0.5 -> 0.20 Inexact Rounded
+pwsx2531 power 42.0E-1 0.5 -> 2.0 Inexact Rounded
+pwsx2532 power 42.00E-2 0.5 -> 0.65 Inexact Rounded
+pwsx2533 power 42E-3 0.5 -> 0.20 Inexact Rounded
+pwsx2534 power 42E+1 0.5 -> 20 Inexact Rounded
+pwsx2535 power 42E+2 0.5 -> 65 Inexact Rounded
+pwsx2536 power 42E+3 0.5 -> 2.0E+2 Inexact Rounded
+pwsx2537 power 0.43 0.5 -> 0.66 Inexact Rounded
+pwsx2538 power 0.043 0.5 -> 0.21 Inexact Rounded
+pwsx2539 power 43.0E-1 0.5 -> 2.1 Inexact Rounded
+pwsx2540 power 43.00E-2 0.5 -> 0.66 Inexact Rounded
+pwsx2541 power 43E-3 0.5 -> 0.21 Inexact Rounded
+pwsx2542 power 43E+1 0.5 -> 21 Inexact Rounded
+pwsx2543 power 43E+2 0.5 -> 66 Inexact Rounded
+pwsx2544 power 43E+3 0.5 -> 2.1E+2 Inexact Rounded
+pwsx2545 power 0.44 0.5 -> 0.66 Inexact Rounded
+pwsx2546 power 0.044 0.5 -> 0.21 Inexact Rounded
+pwsx2547 power 44.0E-1 0.5 -> 2.1 Inexact Rounded
+pwsx2548 power 44.00E-2 0.5 -> 0.66 Inexact Rounded
+pwsx2549 power 44E-3 0.5 -> 0.21 Inexact Rounded
+pwsx2550 power 44E+1 0.5 -> 21 Inexact Rounded
+pwsx2551 power 44E+2 0.5 -> 66 Inexact Rounded
+pwsx2552 power 44E+3 0.5 -> 2.1E+2 Inexact Rounded
+pwsx2553 power 0.45 0.5 -> 0.67 Inexact Rounded
+pwsx2554 power 0.045 0.5 -> 0.21 Inexact Rounded
+pwsx2555 power 45.0E-1 0.5 -> 2.1 Inexact Rounded
+pwsx2556 power 45.00E-2 0.5 -> 0.67 Inexact Rounded
+pwsx2557 power 45E-3 0.5 -> 0.21 Inexact Rounded
+pwsx2558 power 45E+1 0.5 -> 21 Inexact Rounded
+pwsx2559 power 45E+2 0.5 -> 67 Inexact Rounded
+pwsx2560 power 45E+3 0.5 -> 2.1E+2 Inexact Rounded
+pwsx2561 power 0.46 0.5 -> 0.68 Inexact Rounded
+pwsx2562 power 0.046 0.5 -> 0.21 Inexact Rounded
+pwsx2563 power 46.0E-1 0.5 -> 2.1 Inexact Rounded
+pwsx2564 power 46.00E-2 0.5 -> 0.68 Inexact Rounded
+pwsx2565 power 46E-3 0.5 -> 0.21 Inexact Rounded
+pwsx2566 power 46E+1 0.5 -> 21 Inexact Rounded
+pwsx2567 power 46E+2 0.5 -> 68 Inexact Rounded
+pwsx2568 power 46E+3 0.5 -> 2.1E+2 Inexact Rounded
+pwsx2569 power 0.47 0.5 -> 0.69 Inexact Rounded
+pwsx2570 power 0.047 0.5 -> 0.22 Inexact Rounded
+pwsx2571 power 47.0E-1 0.5 -> 2.2 Inexact Rounded
+pwsx2572 power 47.00E-2 0.5 -> 0.69 Inexact Rounded
+pwsx2573 power 47E-3 0.5 -> 0.22 Inexact Rounded
+pwsx2574 power 47E+1 0.5 -> 22 Inexact Rounded
+pwsx2575 power 47E+2 0.5 -> 69 Inexact Rounded
+pwsx2576 power 47E+3 0.5 -> 2.2E+2 Inexact Rounded
+pwsx2577 power 0.48 0.5 -> 0.69 Inexact Rounded
+pwsx2578 power 0.048 0.5 -> 0.22 Inexact Rounded
+pwsx2579 power 48.0E-1 0.5 -> 2.2 Inexact Rounded
+pwsx2580 power 48.00E-2 0.5 -> 0.69 Inexact Rounded
+pwsx2581 power 48E-3 0.5 -> 0.22 Inexact Rounded
+pwsx2582 power 48E+1 0.5 -> 22 Inexact Rounded
+pwsx2583 power 48E+2 0.5 -> 69 Inexact Rounded
+pwsx2584 power 48E+3 0.5 -> 2.2E+2 Inexact Rounded
+pwsx2585 power 0.49 0.5 -> 0.70 Inexact Rounded
+pwsx2586 power 0.049 0.5 -> 0.22 Inexact Rounded
+pwsx2587 power 49.0E-1 0.5 -> 2.2 Inexact Rounded
+pwsx2588 power 49.00E-2 0.5 -> 0.70 Inexact Rounded
+pwsx2589 power 49E-3 0.5 -> 0.22 Inexact Rounded
+pwsx2590 power 49E+1 0.5 -> 22 Inexact Rounded
+pwsx2591 power 49E+2 0.5 -> 70 Inexact Rounded
+pwsx2592 power 49E+3 0.5 -> 2.2E+2 Inexact Rounded
+pwsx2593 power 0.50 0.5 -> 0.71 Inexact Rounded
+pwsx2594 power 0.050 0.5 -> 0.22 Inexact Rounded
+pwsx2595 power 50.0E-1 0.5 -> 2.2 Inexact Rounded
+pwsx2596 power 50.00E-2 0.5 -> 0.71 Inexact Rounded
+pwsx2597 power 50E-3 0.5 -> 0.22 Inexact Rounded
+pwsx2598 power 50E+1 0.5 -> 22 Inexact Rounded
+pwsx2599 power 50E+2 0.5 -> 71 Inexact Rounded
+pwsx2600 power 50E+3 0.5 -> 2.2E+2 Inexact Rounded
+pwsx2601 power 0.51 0.5 -> 0.71 Inexact Rounded
+pwsx2602 power 0.051 0.5 -> 0.23 Inexact Rounded
+pwsx2603 power 51.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2604 power 51.00E-2 0.5 -> 0.71 Inexact Rounded
+pwsx2605 power 51E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2606 power 51E+1 0.5 -> 23 Inexact Rounded
+pwsx2607 power 51E+2 0.5 -> 71 Inexact Rounded
+pwsx2608 power 51E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2609 power 0.52 0.5 -> 0.72 Inexact Rounded
+pwsx2610 power 0.052 0.5 -> 0.23 Inexact Rounded
+pwsx2611 power 52.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2612 power 52.00E-2 0.5 -> 0.72 Inexact Rounded
+pwsx2613 power 52E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2614 power 52E+1 0.5 -> 23 Inexact Rounded
+pwsx2615 power 52E+2 0.5 -> 72 Inexact Rounded
+pwsx2616 power 52E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2617 power 0.53 0.5 -> 0.73 Inexact Rounded
+pwsx2618 power 0.053 0.5 -> 0.23 Inexact Rounded
+pwsx2619 power 53.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2620 power 53.00E-2 0.5 -> 0.73 Inexact Rounded
+pwsx2621 power 53E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2622 power 53E+1 0.5 -> 23 Inexact Rounded
+pwsx2623 power 53E+2 0.5 -> 73 Inexact Rounded
+pwsx2624 power 53E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2625 power 0.54 0.5 -> 0.73 Inexact Rounded
+pwsx2626 power 0.054 0.5 -> 0.23 Inexact Rounded
+pwsx2627 power 54.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2628 power 54.00E-2 0.5 -> 0.73 Inexact Rounded
+pwsx2629 power 54E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2630 power 54E+1 0.5 -> 23 Inexact Rounded
+pwsx2631 power 54E+2 0.5 -> 73 Inexact Rounded
+pwsx2632 power 54E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2633 power 0.55 0.5 -> 0.74 Inexact Rounded
+pwsx2634 power 0.055 0.5 -> 0.23 Inexact Rounded
+pwsx2635 power 55.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2636 power 55.00E-2 0.5 -> 0.74 Inexact Rounded
+pwsx2637 power 55E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2638 power 55E+1 0.5 -> 23 Inexact Rounded
+pwsx2639 power 55E+2 0.5 -> 74 Inexact Rounded
+pwsx2640 power 55E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2641 power 0.56 0.5 -> 0.75 Inexact Rounded
+pwsx2642 power 0.056 0.5 -> 0.24 Inexact Rounded
+pwsx2643 power 56.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2644 power 56.00E-2 0.5 -> 0.75 Inexact Rounded
+pwsx2645 power 56E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2646 power 56E+1 0.5 -> 24 Inexact Rounded
+pwsx2647 power 56E+2 0.5 -> 75 Inexact Rounded
+pwsx2648 power 56E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2649 power 0.57 0.5 -> 0.75 Inexact Rounded
+pwsx2650 power 0.057 0.5 -> 0.24 Inexact Rounded
+pwsx2651 power 57.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2652 power 57.00E-2 0.5 -> 0.75 Inexact Rounded
+pwsx2653 power 57E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2654 power 57E+1 0.5 -> 24 Inexact Rounded
+pwsx2655 power 57E+2 0.5 -> 75 Inexact Rounded
+pwsx2656 power 57E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2657 power 0.58 0.5 -> 0.76 Inexact Rounded
+pwsx2658 power 0.058 0.5 -> 0.24 Inexact Rounded
+pwsx2659 power 58.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2660 power 58.00E-2 0.5 -> 0.76 Inexact Rounded
+pwsx2661 power 58E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2662 power 58E+1 0.5 -> 24 Inexact Rounded
+pwsx2663 power 58E+2 0.5 -> 76 Inexact Rounded
+pwsx2664 power 58E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2665 power 0.59 0.5 -> 0.77 Inexact Rounded
+pwsx2666 power 0.059 0.5 -> 0.24 Inexact Rounded
+pwsx2667 power 59.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2668 power 59.00E-2 0.5 -> 0.77 Inexact Rounded
+pwsx2669 power 59E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2670 power 59E+1 0.5 -> 24 Inexact Rounded
+pwsx2671 power 59E+2 0.5 -> 77 Inexact Rounded
+pwsx2672 power 59E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2673 power 0.60 0.5 -> 0.77 Inexact Rounded
+pwsx2674 power 0.060 0.5 -> 0.24 Inexact Rounded
+pwsx2675 power 60.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2676 power 60.00E-2 0.5 -> 0.77 Inexact Rounded
+pwsx2677 power 60E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2678 power 60E+1 0.5 -> 24 Inexact Rounded
+pwsx2679 power 60E+2 0.5 -> 77 Inexact Rounded
+pwsx2680 power 60E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2681 power 0.61 0.5 -> 0.78 Inexact Rounded
+pwsx2682 power 0.061 0.5 -> 0.25 Inexact Rounded
+pwsx2683 power 61.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2684 power 61.00E-2 0.5 -> 0.78 Inexact Rounded
+pwsx2685 power 61E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2686 power 61E+1 0.5 -> 25 Inexact Rounded
+pwsx2687 power 61E+2 0.5 -> 78 Inexact Rounded
+pwsx2688 power 61E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2689 power 0.62 0.5 -> 0.79 Inexact Rounded
+pwsx2690 power 0.062 0.5 -> 0.25 Inexact Rounded
+pwsx2691 power 62.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2692 power 62.00E-2 0.5 -> 0.79 Inexact Rounded
+pwsx2693 power 62E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2694 power 62E+1 0.5 -> 25 Inexact Rounded
+pwsx2695 power 62E+2 0.5 -> 79 Inexact Rounded
+pwsx2696 power 62E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2697 power 0.63 0.5 -> 0.79 Inexact Rounded
+pwsx2698 power 0.063 0.5 -> 0.25 Inexact Rounded
+pwsx2699 power 63.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2700 power 63.00E-2 0.5 -> 0.79 Inexact Rounded
+pwsx2701 power 63E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2702 power 63E+1 0.5 -> 25 Inexact Rounded
+pwsx2703 power 63E+2 0.5 -> 79 Inexact Rounded
+pwsx2704 power 63E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2705 power 0.64 0.5 -> 0.80 Inexact Rounded
+pwsx2706 power 0.064 0.5 -> 0.25 Inexact Rounded
+pwsx2707 power 64.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2708 power 64.00E-2 0.5 -> 0.80 Inexact Rounded
+pwsx2709 power 64E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2710 power 64E+1 0.5 -> 25 Inexact Rounded
+pwsx2711 power 64E+2 0.5 -> 80 Inexact Rounded
+pwsx2712 power 64E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2713 power 0.65 0.5 -> 0.81 Inexact Rounded
+pwsx2714 power 0.065 0.5 -> 0.25 Inexact Rounded
+pwsx2715 power 65.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2716 power 65.00E-2 0.5 -> 0.81 Inexact Rounded
+pwsx2717 power 65E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2718 power 65E+1 0.5 -> 25 Inexact Rounded
+pwsx2719 power 65E+2 0.5 -> 81 Inexact Rounded
+pwsx2720 power 65E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2721 power 0.66 0.5 -> 0.81 Inexact Rounded
+pwsx2722 power 0.066 0.5 -> 0.26 Inexact Rounded
+pwsx2723 power 66.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2724 power 66.00E-2 0.5 -> 0.81 Inexact Rounded
+pwsx2725 power 66E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2726 power 66E+1 0.5 -> 26 Inexact Rounded
+pwsx2727 power 66E+2 0.5 -> 81 Inexact Rounded
+pwsx2728 power 66E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2729 power 0.67 0.5 -> 0.82 Inexact Rounded
+pwsx2730 power 0.067 0.5 -> 0.26 Inexact Rounded
+pwsx2731 power 67.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2732 power 67.00E-2 0.5 -> 0.82 Inexact Rounded
+pwsx2733 power 67E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2734 power 67E+1 0.5 -> 26 Inexact Rounded
+pwsx2735 power 67E+2 0.5 -> 82 Inexact Rounded
+pwsx2736 power 67E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2737 power 0.68 0.5 -> 0.82 Inexact Rounded
+pwsx2738 power 0.068 0.5 -> 0.26 Inexact Rounded
+pwsx2739 power 68.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2740 power 68.00E-2 0.5 -> 0.82 Inexact Rounded
+pwsx2741 power 68E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2742 power 68E+1 0.5 -> 26 Inexact Rounded
+pwsx2743 power 68E+2 0.5 -> 82 Inexact Rounded
+pwsx2744 power 68E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2745 power 0.69 0.5 -> 0.83 Inexact Rounded
+pwsx2746 power 0.069 0.5 -> 0.26 Inexact Rounded
+pwsx2747 power 69.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2748 power 69.00E-2 0.5 -> 0.83 Inexact Rounded
+pwsx2749 power 69E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2750 power 69E+1 0.5 -> 26 Inexact Rounded
+pwsx2751 power 69E+2 0.5 -> 83 Inexact Rounded
+pwsx2752 power 69E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2753 power 0.70 0.5 -> 0.84 Inexact Rounded
+pwsx2754 power 0.070 0.5 -> 0.26 Inexact Rounded
+pwsx2755 power 70.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2756 power 70.00E-2 0.5 -> 0.84 Inexact Rounded
+pwsx2757 power 70E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2758 power 70E+1 0.5 -> 26 Inexact Rounded
+pwsx2759 power 70E+2 0.5 -> 84 Inexact Rounded
+pwsx2760 power 70E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2761 power 0.71 0.5 -> 0.84 Inexact Rounded
+pwsx2762 power 0.071 0.5 -> 0.27 Inexact Rounded
+pwsx2763 power 71.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2764 power 71.00E-2 0.5 -> 0.84 Inexact Rounded
+pwsx2765 power 71E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2766 power 71E+1 0.5 -> 27 Inexact Rounded
+pwsx2767 power 71E+2 0.5 -> 84 Inexact Rounded
+pwsx2768 power 71E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2769 power 0.72 0.5 -> 0.85 Inexact Rounded
+pwsx2770 power 0.072 0.5 -> 0.27 Inexact Rounded
+pwsx2771 power 72.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2772 power 72.00E-2 0.5 -> 0.85 Inexact Rounded
+pwsx2773 power 72E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2774 power 72E+1 0.5 -> 27 Inexact Rounded
+pwsx2775 power 72E+2 0.5 -> 85 Inexact Rounded
+pwsx2776 power 72E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2777 power 0.73 0.5 -> 0.85 Inexact Rounded
+pwsx2778 power 0.073 0.5 -> 0.27 Inexact Rounded
+pwsx2779 power 73.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2780 power 73.00E-2 0.5 -> 0.85 Inexact Rounded
+pwsx2781 power 73E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2782 power 73E+1 0.5 -> 27 Inexact Rounded
+pwsx2783 power 73E+2 0.5 -> 85 Inexact Rounded
+pwsx2784 power 73E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2785 power 0.74 0.5 -> 0.86 Inexact Rounded
+pwsx2786 power 0.074 0.5 -> 0.27 Inexact Rounded
+pwsx2787 power 74.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2788 power 74.00E-2 0.5 -> 0.86 Inexact Rounded
+pwsx2789 power 74E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2790 power 74E+1 0.5 -> 27 Inexact Rounded
+pwsx2791 power 74E+2 0.5 -> 86 Inexact Rounded
+pwsx2792 power 74E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2793 power 0.75 0.5 -> 0.87 Inexact Rounded
+pwsx2794 power 0.075 0.5 -> 0.27 Inexact Rounded
+pwsx2795 power 75.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2796 power 75.00E-2 0.5 -> 0.87 Inexact Rounded
+pwsx2797 power 75E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2798 power 75E+1 0.5 -> 27 Inexact Rounded
+pwsx2799 power 75E+2 0.5 -> 87 Inexact Rounded
+pwsx2800 power 75E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2801 power 0.76 0.5 -> 0.87 Inexact Rounded
+pwsx2802 power 0.076 0.5 -> 0.28 Inexact Rounded
+pwsx2803 power 76.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2804 power 76.00E-2 0.5 -> 0.87 Inexact Rounded
+pwsx2805 power 76E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2806 power 76E+1 0.5 -> 28 Inexact Rounded
+pwsx2807 power 76E+2 0.5 -> 87 Inexact Rounded
+pwsx2808 power 76E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2809 power 0.77 0.5 -> 0.88 Inexact Rounded
+pwsx2810 power 0.077 0.5 -> 0.28 Inexact Rounded
+pwsx2811 power 77.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2812 power 77.00E-2 0.5 -> 0.88 Inexact Rounded
+pwsx2813 power 77E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2814 power 77E+1 0.5 -> 28 Inexact Rounded
+pwsx2815 power 77E+2 0.5 -> 88 Inexact Rounded
+pwsx2816 power 77E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2817 power 0.78 0.5 -> 0.88 Inexact Rounded
+pwsx2818 power 0.078 0.5 -> 0.28 Inexact Rounded
+pwsx2819 power 78.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2820 power 78.00E-2 0.5 -> 0.88 Inexact Rounded
+pwsx2821 power 78E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2822 power 78E+1 0.5 -> 28 Inexact Rounded
+pwsx2823 power 78E+2 0.5 -> 88 Inexact Rounded
+pwsx2824 power 78E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2825 power 0.79 0.5 -> 0.89 Inexact Rounded
+pwsx2826 power 0.079 0.5 -> 0.28 Inexact Rounded
+pwsx2827 power 79.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2828 power 79.00E-2 0.5 -> 0.89 Inexact Rounded
+pwsx2829 power 79E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2830 power 79E+1 0.5 -> 28 Inexact Rounded
+pwsx2831 power 79E+2 0.5 -> 89 Inexact Rounded
+pwsx2832 power 79E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2833 power 0.80 0.5 -> 0.89 Inexact Rounded
+pwsx2834 power 0.080 0.5 -> 0.28 Inexact Rounded
+pwsx2835 power 80.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2836 power 80.00E-2 0.5 -> 0.89 Inexact Rounded
+pwsx2837 power 80E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2838 power 80E+1 0.5 -> 28 Inexact Rounded
+pwsx2839 power 80E+2 0.5 -> 89 Inexact Rounded
+pwsx2840 power 80E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2841 power 0.81 0.5 -> 0.90 Inexact Rounded
+pwsx2842 power 0.081 0.5 -> 0.28 Inexact Rounded
+pwsx2843 power 81.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2844 power 81.00E-2 0.5 -> 0.90 Inexact Rounded
+pwsx2845 power 81E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2846 power 81E+1 0.5 -> 28 Inexact Rounded
+pwsx2847 power 81E+2 0.5 -> 90 Inexact Rounded
+pwsx2848 power 81E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2849 power 0.82 0.5 -> 0.91 Inexact Rounded
+pwsx2850 power 0.082 0.5 -> 0.29 Inexact Rounded
+pwsx2851 power 82.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2852 power 82.00E-2 0.5 -> 0.91 Inexact Rounded
+pwsx2853 power 82E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2854 power 82E+1 0.5 -> 29 Inexact Rounded
+pwsx2855 power 82E+2 0.5 -> 91 Inexact Rounded
+pwsx2856 power 82E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2857 power 0.83 0.5 -> 0.91 Inexact Rounded
+pwsx2858 power 0.083 0.5 -> 0.29 Inexact Rounded
+pwsx2859 power 83.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2860 power 83.00E-2 0.5 -> 0.91 Inexact Rounded
+pwsx2861 power 83E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2862 power 83E+1 0.5 -> 29 Inexact Rounded
+pwsx2863 power 83E+2 0.5 -> 91 Inexact Rounded
+pwsx2864 power 83E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2865 power 0.84 0.5 -> 0.92 Inexact Rounded
+pwsx2866 power 0.084 0.5 -> 0.29 Inexact Rounded
+pwsx2867 power 84.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2868 power 84.00E-2 0.5 -> 0.92 Inexact Rounded
+pwsx2869 power 84E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2870 power 84E+1 0.5 -> 29 Inexact Rounded
+pwsx2871 power 84E+2 0.5 -> 92 Inexact Rounded
+pwsx2872 power 84E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2873 power 0.85 0.5 -> 0.92 Inexact Rounded
+pwsx2874 power 0.085 0.5 -> 0.29 Inexact Rounded
+pwsx2875 power 85.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2876 power 85.00E-2 0.5 -> 0.92 Inexact Rounded
+pwsx2877 power 85E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2878 power 85E+1 0.5 -> 29 Inexact Rounded
+pwsx2879 power 85E+2 0.5 -> 92 Inexact Rounded
+pwsx2880 power 85E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2881 power 0.86 0.5 -> 0.93 Inexact Rounded
+pwsx2882 power 0.086 0.5 -> 0.29 Inexact Rounded
+pwsx2883 power 86.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2884 power 86.00E-2 0.5 -> 0.93 Inexact Rounded
+pwsx2885 power 86E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2886 power 86E+1 0.5 -> 29 Inexact Rounded
+pwsx2887 power 86E+2 0.5 -> 93 Inexact Rounded
+pwsx2888 power 86E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2889 power 0.87 0.5 -> 0.93 Inexact Rounded
+pwsx2890 power 0.087 0.5 -> 0.29 Inexact Rounded
+pwsx2891 power 87.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2892 power 87.00E-2 0.5 -> 0.93 Inexact Rounded
+pwsx2893 power 87E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2894 power 87E+1 0.5 -> 29 Inexact Rounded
+pwsx2895 power 87E+2 0.5 -> 93 Inexact Rounded
+pwsx2896 power 87E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2897 power 0.88 0.5 -> 0.94 Inexact Rounded
+pwsx2898 power 0.088 0.5 -> 0.30 Inexact Rounded
+pwsx2899 power 88.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2900 power 88.00E-2 0.5 -> 0.94 Inexact Rounded
+pwsx2901 power 88E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2902 power 88E+1 0.5 -> 30 Inexact Rounded
+pwsx2903 power 88E+2 0.5 -> 94 Inexact Rounded
+pwsx2904 power 88E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2905 power 0.89 0.5 -> 0.94 Inexact Rounded
+pwsx2906 power 0.089 0.5 -> 0.30 Inexact Rounded
+pwsx2907 power 89.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2908 power 89.00E-2 0.5 -> 0.94 Inexact Rounded
+pwsx2909 power 89E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2910 power 89E+1 0.5 -> 30 Inexact Rounded
+pwsx2911 power 89E+2 0.5 -> 94 Inexact Rounded
+pwsx2912 power 89E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2913 power 0.90 0.5 -> 0.95 Inexact Rounded
+pwsx2914 power 0.090 0.5 -> 0.30 Inexact Rounded
+pwsx2915 power 90.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2916 power 90.00E-2 0.5 -> 0.95 Inexact Rounded
+pwsx2917 power 90E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2918 power 90E+1 0.5 -> 30 Inexact Rounded
+pwsx2919 power 90E+2 0.5 -> 95 Inexact Rounded
+pwsx2920 power 90E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2921 power 0.91 0.5 -> 0.95 Inexact Rounded
+pwsx2922 power 0.091 0.5 -> 0.30 Inexact Rounded
+pwsx2923 power 91.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2924 power 91.00E-2 0.5 -> 0.95 Inexact Rounded
+pwsx2925 power 91E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2926 power 91E+1 0.5 -> 30 Inexact Rounded
+pwsx2927 power 91E+2 0.5 -> 95 Inexact Rounded
+pwsx2928 power 91E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2929 power 0.92 0.5 -> 0.96 Inexact Rounded
+pwsx2930 power 0.092 0.5 -> 0.30 Inexact Rounded
+pwsx2931 power 92.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2932 power 92.00E-2 0.5 -> 0.96 Inexact Rounded
+pwsx2933 power 92E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2934 power 92E+1 0.5 -> 30 Inexact Rounded
+pwsx2935 power 92E+2 0.5 -> 96 Inexact Rounded
+pwsx2936 power 92E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2937 power 0.93 0.5 -> 0.96 Inexact Rounded
+pwsx2938 power 0.093 0.5 -> 0.30 Inexact Rounded
+pwsx2939 power 93.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2940 power 93.00E-2 0.5 -> 0.96 Inexact Rounded
+pwsx2941 power 93E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2942 power 93E+1 0.5 -> 30 Inexact Rounded
+pwsx2943 power 93E+2 0.5 -> 96 Inexact Rounded
+pwsx2944 power 93E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2945 power 0.94 0.5 -> 0.97 Inexact Rounded
+pwsx2946 power 0.094 0.5 -> 0.31 Inexact Rounded
+pwsx2947 power 94.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2948 power 94.00E-2 0.5 -> 0.97 Inexact Rounded
+pwsx2949 power 94E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2950 power 94E+1 0.5 -> 31 Inexact Rounded
+pwsx2951 power 94E+2 0.5 -> 97 Inexact Rounded
+pwsx2952 power 94E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2953 power 0.95 0.5 -> 0.97 Inexact Rounded
+pwsx2954 power 0.095 0.5 -> 0.31 Inexact Rounded
+pwsx2955 power 95.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2956 power 95.00E-2 0.5 -> 0.97 Inexact Rounded
+pwsx2957 power 95E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2958 power 95E+1 0.5 -> 31 Inexact Rounded
+pwsx2959 power 95E+2 0.5 -> 97 Inexact Rounded
+pwsx2960 power 95E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2961 power 0.96 0.5 -> 0.98 Inexact Rounded
+pwsx2962 power 0.096 0.5 -> 0.31 Inexact Rounded
+pwsx2963 power 96.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2964 power 96.00E-2 0.5 -> 0.98 Inexact Rounded
+pwsx2965 power 96E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2966 power 96E+1 0.5 -> 31 Inexact Rounded
+pwsx2967 power 96E+2 0.5 -> 98 Inexact Rounded
+pwsx2968 power 96E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2969 power 0.97 0.5 -> 0.98 Inexact Rounded
+pwsx2970 power 0.097 0.5 -> 0.31 Inexact Rounded
+pwsx2971 power 97.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2972 power 97.00E-2 0.5 -> 0.98 Inexact Rounded
+pwsx2973 power 97E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2974 power 97E+1 0.5 -> 31 Inexact Rounded
+pwsx2975 power 97E+2 0.5 -> 98 Inexact Rounded
+pwsx2976 power 97E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2977 power 0.98 0.5 -> 0.99 Inexact Rounded
+pwsx2978 power 0.098 0.5 -> 0.31 Inexact Rounded
+pwsx2979 power 98.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2980 power 98.00E-2 0.5 -> 0.99 Inexact Rounded
+pwsx2981 power 98E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2982 power 98E+1 0.5 -> 31 Inexact Rounded
+pwsx2983 power 98E+2 0.5 -> 99 Inexact Rounded
+pwsx2984 power 98E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2985 power 0.99 0.5 -> 0.99 Inexact Rounded
+pwsx2986 power 0.099 0.5 -> 0.31 Inexact Rounded
+pwsx2987 power 99.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2988 power 99.00E-2 0.5 -> 0.99 Inexact Rounded
+pwsx2989 power 99E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2990 power 99E+1 0.5 -> 31 Inexact Rounded
+pwsx2991 power 99E+2 0.5 -> 99 Inexact Rounded
+pwsx2992 power 99E+3 0.5 -> 3.1E+2 Inexact Rounded
+
+-- Precision 3 squareroot tests [exhaustive, f and f/10]
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+precision: 3
+pwsx3001 power 0.1 0.5 -> 0.316 Inexact Rounded
+pwsx3002 power 0.01 0.5 -> 0.100 Inexact Rounded
+pwsx3003 power 0.2 0.5 -> 0.447 Inexact Rounded
+pwsx3004 power 0.02 0.5 -> 0.141 Inexact Rounded
+pwsx3005 power 0.3 0.5 -> 0.548 Inexact Rounded
+pwsx3006 power 0.03 0.5 -> 0.173 Inexact Rounded
+pwsx3007 power 0.4 0.5 -> 0.632 Inexact Rounded
+pwsx3008 power 0.04 0.5 -> 0.200 Inexact Rounded
+pwsx3009 power 0.5 0.5 -> 0.707 Inexact Rounded
+pwsx3010 power 0.05 0.5 -> 0.224 Inexact Rounded
+pwsx3011 power 0.6 0.5 -> 0.775 Inexact Rounded
+pwsx3012 power 0.06 0.5 -> 0.245 Inexact Rounded
+pwsx3013 power 0.7 0.5 -> 0.837 Inexact Rounded
+pwsx3014 power 0.07 0.5 -> 0.265 Inexact Rounded
+pwsx3015 power 0.8 0.5 -> 0.894 Inexact Rounded
+pwsx3016 power 0.08 0.5 -> 0.283 Inexact Rounded
+pwsx3017 power 0.9 0.5 -> 0.949 Inexact Rounded
+pwsx3018 power 0.09 0.5 -> 0.300 Inexact Rounded
+pwsx3019 power 0.11 0.5 -> 0.332 Inexact Rounded
+pwsx3020 power 0.011 0.5 -> 0.105 Inexact Rounded
+pwsx3021 power 0.12 0.5 -> 0.346 Inexact Rounded
+pwsx3022 power 0.012 0.5 -> 0.110 Inexact Rounded
+pwsx3023 power 0.13 0.5 -> 0.361 Inexact Rounded
+pwsx3024 power 0.013 0.5 -> 0.114 Inexact Rounded
+pwsx3025 power 0.14 0.5 -> 0.374 Inexact Rounded
+pwsx3026 power 0.014 0.5 -> 0.118 Inexact Rounded
+pwsx3027 power 0.15 0.5 -> 0.387 Inexact Rounded
+pwsx3028 power 0.015 0.5 -> 0.122 Inexact Rounded
+pwsx3029 power 0.16 0.5 -> 0.400 Inexact Rounded
+pwsx3030 power 0.016 0.5 -> 0.126 Inexact Rounded
+pwsx3031 power 0.17 0.5 -> 0.412 Inexact Rounded
+pwsx3032 power 0.017 0.5 -> 0.130 Inexact Rounded
+pwsx3033 power 0.18 0.5 -> 0.424 Inexact Rounded
+pwsx3034 power 0.018 0.5 -> 0.134 Inexact Rounded
+pwsx3035 power 0.19 0.5 -> 0.436 Inexact Rounded
+pwsx3036 power 0.019 0.5 -> 0.138 Inexact Rounded
+pwsx3037 power 0.21 0.5 -> 0.458 Inexact Rounded
+pwsx3038 power 0.021 0.5 -> 0.145 Inexact Rounded
+pwsx3039 power 0.22 0.5 -> 0.469 Inexact Rounded
+pwsx3040 power 0.022 0.5 -> 0.148 Inexact Rounded
+pwsx3041 power 0.23 0.5 -> 0.480 Inexact Rounded
+pwsx3042 power 0.023 0.5 -> 0.152 Inexact Rounded
+pwsx3043 power 0.24 0.5 -> 0.490 Inexact Rounded
+pwsx3044 power 0.024 0.5 -> 0.155 Inexact Rounded
+pwsx3045 power 0.25 0.5 -> 0.500 Inexact Rounded
+pwsx3046 power 0.025 0.5 -> 0.158 Inexact Rounded
+pwsx3047 power 0.26 0.5 -> 0.510 Inexact Rounded
+pwsx3048 power 0.026 0.5 -> 0.161 Inexact Rounded
+pwsx3049 power 0.27 0.5 -> 0.520 Inexact Rounded
+pwsx3050 power 0.027 0.5 -> 0.164 Inexact Rounded
+pwsx3051 power 0.28 0.5 -> 0.529 Inexact Rounded
+pwsx3052 power 0.028 0.5 -> 0.167 Inexact Rounded
+pwsx3053 power 0.29 0.5 -> 0.539 Inexact Rounded
+pwsx3054 power 0.029 0.5 -> 0.170 Inexact Rounded
+pwsx3055 power 0.31 0.5 -> 0.557 Inexact Rounded
+pwsx3056 power 0.031 0.5 -> 0.176 Inexact Rounded
+pwsx3057 power 0.32 0.5 -> 0.566 Inexact Rounded
+pwsx3058 power 0.032 0.5 -> 0.179 Inexact Rounded
+pwsx3059 power 0.33 0.5 -> 0.574 Inexact Rounded
+pwsx3060 power 0.033 0.5 -> 0.182 Inexact Rounded
+pwsx3061 power 0.34 0.5 -> 0.583 Inexact Rounded
+pwsx3062 power 0.034 0.5 -> 0.184 Inexact Rounded
+pwsx3063 power 0.35 0.5 -> 0.592 Inexact Rounded
+pwsx3064 power 0.035 0.5 -> 0.187 Inexact Rounded
+pwsx3065 power 0.36 0.5 -> 0.600 Inexact Rounded
+pwsx3066 power 0.036 0.5 -> 0.190 Inexact Rounded
+pwsx3067 power 0.37 0.5 -> 0.608 Inexact Rounded
+pwsx3068 power 0.037 0.5 -> 0.192 Inexact Rounded
+pwsx3069 power 0.38 0.5 -> 0.616 Inexact Rounded
+pwsx3070 power 0.038 0.5 -> 0.195 Inexact Rounded
+pwsx3071 power 0.39 0.5 -> 0.624 Inexact Rounded
+pwsx3072 power 0.039 0.5 -> 0.197 Inexact Rounded
+pwsx3073 power 0.41 0.5 -> 0.640 Inexact Rounded
+pwsx3074 power 0.041 0.5 -> 0.202 Inexact Rounded
+pwsx3075 power 0.42 0.5 -> 0.648 Inexact Rounded
+pwsx3076 power 0.042 0.5 -> 0.205 Inexact Rounded
+pwsx3077 power 0.43 0.5 -> 0.656 Inexact Rounded
+pwsx3078 power 0.043 0.5 -> 0.207 Inexact Rounded
+pwsx3079 power 0.44 0.5 -> 0.663 Inexact Rounded
+pwsx3080 power 0.044 0.5 -> 0.210 Inexact Rounded
+pwsx3081 power 0.45 0.5 -> 0.671 Inexact Rounded
+pwsx3082 power 0.045 0.5 -> 0.212 Inexact Rounded
+pwsx3083 power 0.46 0.5 -> 0.678 Inexact Rounded
+pwsx3084 power 0.046 0.5 -> 0.214 Inexact Rounded
+pwsx3085 power 0.47 0.5 -> 0.686 Inexact Rounded
+pwsx3086 power 0.047 0.5 -> 0.217 Inexact Rounded
+pwsx3087 power 0.48 0.5 -> 0.693 Inexact Rounded
+pwsx3088 power 0.048 0.5 -> 0.219 Inexact Rounded
+pwsx3089 power 0.49 0.5 -> 0.700 Inexact Rounded
+pwsx3090 power 0.049 0.5 -> 0.221 Inexact Rounded
+pwsx3091 power 0.51 0.5 -> 0.714 Inexact Rounded
+pwsx3092 power 0.051 0.5 -> 0.226 Inexact Rounded
+pwsx3093 power 0.52 0.5 -> 0.721 Inexact Rounded
+pwsx3094 power 0.052 0.5 -> 0.228 Inexact Rounded
+pwsx3095 power 0.53 0.5 -> 0.728 Inexact Rounded
+pwsx3096 power 0.053 0.5 -> 0.230 Inexact Rounded
+pwsx3097 power 0.54 0.5 -> 0.735 Inexact Rounded
+pwsx3098 power 0.054 0.5 -> 0.232 Inexact Rounded
+pwsx3099 power 0.55 0.5 -> 0.742 Inexact Rounded
+pwsx3100 power 0.055 0.5 -> 0.235 Inexact Rounded
+pwsx3101 power 0.56 0.5 -> 0.748 Inexact Rounded
+pwsx3102 power 0.056 0.5 -> 0.237 Inexact Rounded
+pwsx3103 power 0.57 0.5 -> 0.755 Inexact Rounded
+pwsx3104 power 0.057 0.5 -> 0.239 Inexact Rounded
+pwsx3105 power 0.58 0.5 -> 0.762 Inexact Rounded
+pwsx3106 power 0.058 0.5 -> 0.241 Inexact Rounded
+pwsx3107 power 0.59 0.5 -> 0.768 Inexact Rounded
+pwsx3108 power 0.059 0.5 -> 0.243 Inexact Rounded
+pwsx3109 power 0.61 0.5 -> 0.781 Inexact Rounded
+pwsx3110 power 0.061 0.5 -> 0.247 Inexact Rounded
+pwsx3111 power 0.62 0.5 -> 0.787 Inexact Rounded
+pwsx3112 power 0.062 0.5 -> 0.249 Inexact Rounded
+pwsx3113 power 0.63 0.5 -> 0.794 Inexact Rounded
+pwsx3114 power 0.063 0.5 -> 0.251 Inexact Rounded
+pwsx3115 power 0.64 0.5 -> 0.800 Inexact Rounded
+pwsx3116 power 0.064 0.5 -> 0.253 Inexact Rounded
+pwsx3117 power 0.65 0.5 -> 0.806 Inexact Rounded
+pwsx3118 power 0.065 0.5 -> 0.255 Inexact Rounded
+pwsx3119 power 0.66 0.5 -> 0.812 Inexact Rounded
+pwsx3120 power 0.066 0.5 -> 0.257 Inexact Rounded
+pwsx3121 power 0.67 0.5 -> 0.819 Inexact Rounded
+pwsx3122 power 0.067 0.5 -> 0.259 Inexact Rounded
+pwsx3123 power 0.68 0.5 -> 0.825 Inexact Rounded
+pwsx3124 power 0.068 0.5 -> 0.261 Inexact Rounded
+pwsx3125 power 0.69 0.5 -> 0.831 Inexact Rounded
+pwsx3126 power 0.069 0.5 -> 0.263 Inexact Rounded
+pwsx3127 power 0.71 0.5 -> 0.843 Inexact Rounded
+pwsx3128 power 0.071 0.5 -> 0.266 Inexact Rounded
+pwsx3129 power 0.72 0.5 -> 0.849 Inexact Rounded
+pwsx3130 power 0.072 0.5 -> 0.268 Inexact Rounded
+pwsx3131 power 0.73 0.5 -> 0.854 Inexact Rounded
+pwsx3132 power 0.073 0.5 -> 0.270 Inexact Rounded
+pwsx3133 power 0.74 0.5 -> 0.860 Inexact Rounded
+pwsx3134 power 0.074 0.5 -> 0.272 Inexact Rounded
+pwsx3135 power 0.75 0.5 -> 0.866 Inexact Rounded
+pwsx3136 power 0.075 0.5 -> 0.274 Inexact Rounded
+pwsx3137 power 0.76 0.5 -> 0.872 Inexact Rounded
+pwsx3138 power 0.076 0.5 -> 0.276 Inexact Rounded
+pwsx3139 power 0.77 0.5 -> 0.877 Inexact Rounded
+pwsx3140 power 0.077 0.5 -> 0.277 Inexact Rounded
+pwsx3141 power 0.78 0.5 -> 0.883 Inexact Rounded
+pwsx3142 power 0.078 0.5 -> 0.279 Inexact Rounded
+pwsx3143 power 0.79 0.5 -> 0.889 Inexact Rounded
+pwsx3144 power 0.079 0.5 -> 0.281 Inexact Rounded
+pwsx3145 power 0.81 0.5 -> 0.900 Inexact Rounded
+pwsx3146 power 0.081 0.5 -> 0.285 Inexact Rounded
+pwsx3147 power 0.82 0.5 -> 0.906 Inexact Rounded
+pwsx3148 power 0.082 0.5 -> 0.286 Inexact Rounded
+pwsx3149 power 0.83 0.5 -> 0.911 Inexact Rounded
+pwsx3150 power 0.083 0.5 -> 0.288 Inexact Rounded
+pwsx3151 power 0.84 0.5 -> 0.917 Inexact Rounded
+pwsx3152 power 0.084 0.5 -> 0.290 Inexact Rounded
+pwsx3153 power 0.85 0.5 -> 0.922 Inexact Rounded
+pwsx3154 power 0.085 0.5 -> 0.292 Inexact Rounded
+pwsx3155 power 0.86 0.5 -> 0.927 Inexact Rounded
+pwsx3156 power 0.086 0.5 -> 0.293 Inexact Rounded
+pwsx3157 power 0.87 0.5 -> 0.933 Inexact Rounded
+pwsx3158 power 0.087 0.5 -> 0.295 Inexact Rounded
+pwsx3159 power 0.88 0.5 -> 0.938 Inexact Rounded
+pwsx3160 power 0.088 0.5 -> 0.297 Inexact Rounded
+pwsx3161 power 0.89 0.5 -> 0.943 Inexact Rounded
+pwsx3162 power 0.089 0.5 -> 0.298 Inexact Rounded
+pwsx3163 power 0.91 0.5 -> 0.954 Inexact Rounded
+pwsx3164 power 0.091 0.5 -> 0.302 Inexact Rounded
+pwsx3165 power 0.92 0.5 -> 0.959 Inexact Rounded
+pwsx3166 power 0.092 0.5 -> 0.303 Inexact Rounded
+pwsx3167 power 0.93 0.5 -> 0.964 Inexact Rounded
+pwsx3168 power 0.093 0.5 -> 0.305 Inexact Rounded
+pwsx3169 power 0.94 0.5 -> 0.970 Inexact Rounded
+pwsx3170 power 0.094 0.5 -> 0.307 Inexact Rounded
+pwsx3171 power 0.95 0.5 -> 0.975 Inexact Rounded
+pwsx3172 power 0.095 0.5 -> 0.308 Inexact Rounded
+pwsx3173 power 0.96 0.5 -> 0.980 Inexact Rounded
+pwsx3174 power 0.096 0.5 -> 0.310 Inexact Rounded
+pwsx3175 power 0.97 0.5 -> 0.985 Inexact Rounded
+pwsx3176 power 0.097 0.5 -> 0.311 Inexact Rounded
+pwsx3177 power 0.98 0.5 -> 0.990 Inexact Rounded
+pwsx3178 power 0.098 0.5 -> 0.313 Inexact Rounded
+pwsx3179 power 0.99 0.5 -> 0.995 Inexact Rounded
+pwsx3180 power 0.099 0.5 -> 0.315 Inexact Rounded
+pwsx3181 power 0.101 0.5 -> 0.318 Inexact Rounded
+pwsx3182 power 0.0101 0.5 -> 0.100 Inexact Rounded
+pwsx3183 power 0.102 0.5 -> 0.319 Inexact Rounded
+pwsx3184 power 0.0102 0.5 -> 0.101 Inexact Rounded
+pwsx3185 power 0.103 0.5 -> 0.321 Inexact Rounded
+pwsx3186 power 0.0103 0.5 -> 0.101 Inexact Rounded
+pwsx3187 power 0.104 0.5 -> 0.322 Inexact Rounded
+pwsx3188 power 0.0104 0.5 -> 0.102 Inexact Rounded
+pwsx3189 power 0.105 0.5 -> 0.324 Inexact Rounded
+pwsx3190 power 0.0105 0.5 -> 0.102 Inexact Rounded
+pwsx3191 power 0.106 0.5 -> 0.326 Inexact Rounded
+pwsx3192 power 0.0106 0.5 -> 0.103 Inexact Rounded
+pwsx3193 power 0.107 0.5 -> 0.327 Inexact Rounded
+pwsx3194 power 0.0107 0.5 -> 0.103 Inexact Rounded
+pwsx3195 power 0.108 0.5 -> 0.329 Inexact Rounded
+pwsx3196 power 0.0108 0.5 -> 0.104 Inexact Rounded
+pwsx3197 power 0.109 0.5 -> 0.330 Inexact Rounded
+pwsx3198 power 0.0109 0.5 -> 0.104 Inexact Rounded
+pwsx3199 power 0.111 0.5 -> 0.333 Inexact Rounded
+pwsx3200 power 0.0111 0.5 -> 0.105 Inexact Rounded
+pwsx3201 power 0.112 0.5 -> 0.335 Inexact Rounded
+pwsx3202 power 0.0112 0.5 -> 0.106 Inexact Rounded
+pwsx3203 power 0.113 0.5 -> 0.336 Inexact Rounded
+pwsx3204 power 0.0113 0.5 -> 0.106 Inexact Rounded
+pwsx3205 power 0.114 0.5 -> 0.338 Inexact Rounded
+pwsx3206 power 0.0114 0.5 -> 0.107 Inexact Rounded
+pwsx3207 power 0.115 0.5 -> 0.339 Inexact Rounded
+pwsx3208 power 0.0115 0.5 -> 0.107 Inexact Rounded
+pwsx3209 power 0.116 0.5 -> 0.341 Inexact Rounded
+pwsx3210 power 0.0116 0.5 -> 0.108 Inexact Rounded
+pwsx3211 power 0.117 0.5 -> 0.342 Inexact Rounded
+pwsx3212 power 0.0117 0.5 -> 0.108 Inexact Rounded
+pwsx3213 power 0.118 0.5 -> 0.344 Inexact Rounded
+pwsx3214 power 0.0118 0.5 -> 0.109 Inexact Rounded
+pwsx3215 power 0.119 0.5 -> 0.345 Inexact Rounded
+pwsx3216 power 0.0119 0.5 -> 0.109 Inexact Rounded
+pwsx3217 power 0.121 0.5 -> 0.348 Inexact Rounded
+pwsx3218 power 0.0121 0.5 -> 0.110 Inexact Rounded
+pwsx3219 power 0.122 0.5 -> 0.349 Inexact Rounded
+pwsx3220 power 0.0122 0.5 -> 0.110 Inexact Rounded
+pwsx3221 power 0.123 0.5 -> 0.351 Inexact Rounded
+pwsx3222 power 0.0123 0.5 -> 0.111 Inexact Rounded
+pwsx3223 power 0.124 0.5 -> 0.352 Inexact Rounded
+pwsx3224 power 0.0124 0.5 -> 0.111 Inexact Rounded
+pwsx3225 power 0.125 0.5 -> 0.354 Inexact Rounded
+pwsx3226 power 0.0125 0.5 -> 0.112 Inexact Rounded
+pwsx3227 power 0.126 0.5 -> 0.355 Inexact Rounded
+pwsx3228 power 0.0126 0.5 -> 0.112 Inexact Rounded
+pwsx3229 power 0.127 0.5 -> 0.356 Inexact Rounded
+pwsx3230 power 0.0127 0.5 -> 0.113 Inexact Rounded
+pwsx3231 power 0.128 0.5 -> 0.358 Inexact Rounded
+pwsx3232 power 0.0128 0.5 -> 0.113 Inexact Rounded
+pwsx3233 power 0.129 0.5 -> 0.359 Inexact Rounded
+pwsx3234 power 0.0129 0.5 -> 0.114 Inexact Rounded
+pwsx3235 power 0.131 0.5 -> 0.362 Inexact Rounded
+pwsx3236 power 0.0131 0.5 -> 0.114 Inexact Rounded
+pwsx3237 power 0.132 0.5 -> 0.363 Inexact Rounded
+pwsx3238 power 0.0132 0.5 -> 0.115 Inexact Rounded
+pwsx3239 power 0.133 0.5 -> 0.365 Inexact Rounded
+pwsx3240 power 0.0133 0.5 -> 0.115 Inexact Rounded
+pwsx3241 power 0.134 0.5 -> 0.366 Inexact Rounded
+pwsx3242 power 0.0134 0.5 -> 0.116 Inexact Rounded
+pwsx3243 power 0.135 0.5 -> 0.367 Inexact Rounded
+pwsx3244 power 0.0135 0.5 -> 0.116 Inexact Rounded
+pwsx3245 power 0.136 0.5 -> 0.369 Inexact Rounded
+pwsx3246 power 0.0136 0.5 -> 0.117 Inexact Rounded
+pwsx3247 power 0.137 0.5 -> 0.370 Inexact Rounded
+pwsx3248 power 0.0137 0.5 -> 0.117 Inexact Rounded
+pwsx3249 power 0.138 0.5 -> 0.371 Inexact Rounded
+pwsx3250 power 0.0138 0.5 -> 0.117 Inexact Rounded
+pwsx3251 power 0.139 0.5 -> 0.373 Inexact Rounded
+pwsx3252 power 0.0139 0.5 -> 0.118 Inexact Rounded
+pwsx3253 power 0.141 0.5 -> 0.375 Inexact Rounded
+pwsx3254 power 0.0141 0.5 -> 0.119 Inexact Rounded
+pwsx3255 power 0.142 0.5 -> 0.377 Inexact Rounded
+pwsx3256 power 0.0142 0.5 -> 0.119 Inexact Rounded
+pwsx3257 power 0.143 0.5 -> 0.378 Inexact Rounded
+pwsx3258 power 0.0143 0.5 -> 0.120 Inexact Rounded
+pwsx3259 power 0.144 0.5 -> 0.379 Inexact Rounded
+pwsx3260 power 0.0144 0.5 -> 0.120 Inexact Rounded
+pwsx3261 power 0.145 0.5 -> 0.381 Inexact Rounded
+pwsx3262 power 0.0145 0.5 -> 0.120 Inexact Rounded
+pwsx3263 power 0.146 0.5 -> 0.382 Inexact Rounded
+pwsx3264 power 0.0146 0.5 -> 0.121 Inexact Rounded
+pwsx3265 power 0.147 0.5 -> 0.383 Inexact Rounded
+pwsx3266 power 0.0147 0.5 -> 0.121 Inexact Rounded
+pwsx3267 power 0.148 0.5 -> 0.385 Inexact Rounded
+pwsx3268 power 0.0148 0.5 -> 0.122 Inexact Rounded
+pwsx3269 power 0.149 0.5 -> 0.386 Inexact Rounded
+pwsx3270 power 0.0149 0.5 -> 0.122 Inexact Rounded
+pwsx3271 power 0.151 0.5 -> 0.389 Inexact Rounded
+pwsx3272 power 0.0151 0.5 -> 0.123 Inexact Rounded
+pwsx3273 power 0.152 0.5 -> 0.390 Inexact Rounded
+pwsx3274 power 0.0152 0.5 -> 0.123 Inexact Rounded
+pwsx3275 power 0.153 0.5 -> 0.391 Inexact Rounded
+pwsx3276 power 0.0153 0.5 -> 0.124 Inexact Rounded
+pwsx3277 power 0.154 0.5 -> 0.392 Inexact Rounded
+pwsx3278 power 0.0154 0.5 -> 0.124 Inexact Rounded
+pwsx3279 power 0.155 0.5 -> 0.394 Inexact Rounded
+pwsx3280 power 0.0155 0.5 -> 0.124 Inexact Rounded
+pwsx3281 power 0.156 0.5 -> 0.395 Inexact Rounded
+pwsx3282 power 0.0156 0.5 -> 0.125 Inexact Rounded
+pwsx3283 power 0.157 0.5 -> 0.396 Inexact Rounded
+pwsx3284 power 0.0157 0.5 -> 0.125 Inexact Rounded
+pwsx3285 power 0.158 0.5 -> 0.397 Inexact Rounded
+pwsx3286 power 0.0158 0.5 -> 0.126 Inexact Rounded
+pwsx3287 power 0.159 0.5 -> 0.399 Inexact Rounded
+pwsx3288 power 0.0159 0.5 -> 0.126 Inexact Rounded
+pwsx3289 power 0.161 0.5 -> 0.401 Inexact Rounded
+pwsx3290 power 0.0161 0.5 -> 0.127 Inexact Rounded
+pwsx3291 power 0.162 0.5 -> 0.402 Inexact Rounded
+pwsx3292 power 0.0162 0.5 -> 0.127 Inexact Rounded
+pwsx3293 power 0.163 0.5 -> 0.404 Inexact Rounded
+pwsx3294 power 0.0163 0.5 -> 0.128 Inexact Rounded
+pwsx3295 power 0.164 0.5 -> 0.405 Inexact Rounded
+pwsx3296 power 0.0164 0.5 -> 0.128 Inexact Rounded
+pwsx3297 power 0.165 0.5 -> 0.406 Inexact Rounded
+pwsx3298 power 0.0165 0.5 -> 0.128 Inexact Rounded
+pwsx3299 power 0.166 0.5 -> 0.407 Inexact Rounded
+pwsx3300 power 0.0166 0.5 -> 0.129 Inexact Rounded
+pwsx3301 power 0.167 0.5 -> 0.409 Inexact Rounded
+pwsx3302 power 0.0167 0.5 -> 0.129 Inexact Rounded
+pwsx3303 power 0.168 0.5 -> 0.410 Inexact Rounded
+pwsx3304 power 0.0168 0.5 -> 0.130 Inexact Rounded
+pwsx3305 power 0.169 0.5 -> 0.411 Inexact Rounded
+pwsx3306 power 0.0169 0.5 -> 0.130 Inexact Rounded
+pwsx3307 power 0.171 0.5 -> 0.414 Inexact Rounded
+pwsx3308 power 0.0171 0.5 -> 0.131 Inexact Rounded
+pwsx3309 power 0.172 0.5 -> 0.415 Inexact Rounded
+pwsx3310 power 0.0172 0.5 -> 0.131 Inexact Rounded
+pwsx3311 power 0.173 0.5 -> 0.416 Inexact Rounded
+pwsx3312 power 0.0173 0.5 -> 0.132 Inexact Rounded
+pwsx3313 power 0.174 0.5 -> 0.417 Inexact Rounded
+pwsx3314 power 0.0174 0.5 -> 0.132 Inexact Rounded
+pwsx3315 power 0.175 0.5 -> 0.418 Inexact Rounded
+pwsx3316 power 0.0175 0.5 -> 0.132 Inexact Rounded
+pwsx3317 power 0.176 0.5 -> 0.420 Inexact Rounded
+pwsx3318 power 0.0176 0.5 -> 0.133 Inexact Rounded
+pwsx3319 power 0.177 0.5 -> 0.421 Inexact Rounded
+pwsx3320 power 0.0177 0.5 -> 0.133 Inexact Rounded
+pwsx3321 power 0.178 0.5 -> 0.422 Inexact Rounded
+pwsx3322 power 0.0178 0.5 -> 0.133 Inexact Rounded
+pwsx3323 power 0.179 0.5 -> 0.423 Inexact Rounded
+pwsx3324 power 0.0179 0.5 -> 0.134 Inexact Rounded
+pwsx3325 power 0.181 0.5 -> 0.425 Inexact Rounded
+pwsx3326 power 0.0181 0.5 -> 0.135 Inexact Rounded
+pwsx3327 power 0.182 0.5 -> 0.427 Inexact Rounded
+pwsx3328 power 0.0182 0.5 -> 0.135 Inexact Rounded
+pwsx3329 power 0.183 0.5 -> 0.428 Inexact Rounded
+pwsx3330 power 0.0183 0.5 -> 0.135 Inexact Rounded
+pwsx3331 power 0.184 0.5 -> 0.429 Inexact Rounded
+pwsx3332 power 0.0184 0.5 -> 0.136 Inexact Rounded
+pwsx3333 power 0.185 0.5 -> 0.430 Inexact Rounded
+pwsx3334 power 0.0185 0.5 -> 0.136 Inexact Rounded
+pwsx3335 power 0.186 0.5 -> 0.431 Inexact Rounded
+pwsx3336 power 0.0186 0.5 -> 0.136 Inexact Rounded
+pwsx3337 power 0.187 0.5 -> 0.432 Inexact Rounded
+pwsx3338 power 0.0187 0.5 -> 0.137 Inexact Rounded
+pwsx3339 power 0.188 0.5 -> 0.434 Inexact Rounded
+pwsx3340 power 0.0188 0.5 -> 0.137 Inexact Rounded
+pwsx3341 power 0.189 0.5 -> 0.435 Inexact Rounded
+pwsx3342 power 0.0189 0.5 -> 0.137 Inexact Rounded
+pwsx3343 power 0.191 0.5 -> 0.437 Inexact Rounded
+pwsx3344 power 0.0191 0.5 -> 0.138 Inexact Rounded
+pwsx3345 power 0.192 0.5 -> 0.438 Inexact Rounded
+pwsx3346 power 0.0192 0.5 -> 0.139 Inexact Rounded
+pwsx3347 power 0.193 0.5 -> 0.439 Inexact Rounded
+pwsx3348 power 0.0193 0.5 -> 0.139 Inexact Rounded
+pwsx3349 power 0.194 0.5 -> 0.440 Inexact Rounded
+pwsx3350 power 0.0194 0.5 -> 0.139 Inexact Rounded
+pwsx3351 power 0.195 0.5 -> 0.442 Inexact Rounded
+pwsx3352 power 0.0195 0.5 -> 0.140 Inexact Rounded
+pwsx3353 power 0.196 0.5 -> 0.443 Inexact Rounded
+pwsx3354 power 0.0196 0.5 -> 0.140 Inexact Rounded
+pwsx3355 power 0.197 0.5 -> 0.444 Inexact Rounded
+pwsx3356 power 0.0197 0.5 -> 0.140 Inexact Rounded
+pwsx3357 power 0.198 0.5 -> 0.445 Inexact Rounded
+pwsx3358 power 0.0198 0.5 -> 0.141 Inexact Rounded
+pwsx3359 power 0.199 0.5 -> 0.446 Inexact Rounded
+pwsx3360 power 0.0199 0.5 -> 0.141 Inexact Rounded
+pwsx3361 power 0.201 0.5 -> 0.448 Inexact Rounded
+pwsx3362 power 0.0201 0.5 -> 0.142 Inexact Rounded
+pwsx3363 power 0.202 0.5 -> 0.449 Inexact Rounded
+pwsx3364 power 0.0202 0.5 -> 0.142 Inexact Rounded
+pwsx3365 power 0.203 0.5 -> 0.451 Inexact Rounded
+pwsx3366 power 0.0203 0.5 -> 0.142 Inexact Rounded
+pwsx3367 power 0.204 0.5 -> 0.452 Inexact Rounded
+pwsx3368 power 0.0204 0.5 -> 0.143 Inexact Rounded
+pwsx3369 power 0.205 0.5 -> 0.453 Inexact Rounded
+pwsx3370 power 0.0205 0.5 -> 0.143 Inexact Rounded
+pwsx3371 power 0.206 0.5 -> 0.454 Inexact Rounded
+pwsx3372 power 0.0206 0.5 -> 0.144 Inexact Rounded
+pwsx3373 power 0.207 0.5 -> 0.455 Inexact Rounded
+pwsx3374 power 0.0207 0.5 -> 0.144 Inexact Rounded
+pwsx3375 power 0.208 0.5 -> 0.456 Inexact Rounded
+pwsx3376 power 0.0208 0.5 -> 0.144 Inexact Rounded
+pwsx3377 power 0.209 0.5 -> 0.457 Inexact Rounded
+pwsx3378 power 0.0209 0.5 -> 0.145 Inexact Rounded
+pwsx3379 power 0.211 0.5 -> 0.459 Inexact Rounded
+pwsx3380 power 0.0211 0.5 -> 0.145 Inexact Rounded
+pwsx3381 power 0.212 0.5 -> 0.460 Inexact Rounded
+pwsx3382 power 0.0212 0.5 -> 0.146 Inexact Rounded
+pwsx3383 power 0.213 0.5 -> 0.462 Inexact Rounded
+pwsx3384 power 0.0213 0.5 -> 0.146 Inexact Rounded
+pwsx3385 power 0.214 0.5 -> 0.463 Inexact Rounded
+pwsx3386 power 0.0214 0.5 -> 0.146 Inexact Rounded
+pwsx3387 power 0.215 0.5 -> 0.464 Inexact Rounded
+pwsx3388 power 0.0215 0.5 -> 0.147 Inexact Rounded
+pwsx3389 power 0.216 0.5 -> 0.465 Inexact Rounded
+pwsx3390 power 0.0216 0.5 -> 0.147 Inexact Rounded
+pwsx3391 power 0.217 0.5 -> 0.466 Inexact Rounded
+pwsx3392 power 0.0217 0.5 -> 0.147 Inexact Rounded
+pwsx3393 power 0.218 0.5 -> 0.467 Inexact Rounded
+pwsx3394 power 0.0218 0.5 -> 0.148 Inexact Rounded
+pwsx3395 power 0.219 0.5 -> 0.468 Inexact Rounded
+pwsx3396 power 0.0219 0.5 -> 0.148 Inexact Rounded
+pwsx3397 power 0.221 0.5 -> 0.470 Inexact Rounded
+pwsx3398 power 0.0221 0.5 -> 0.149 Inexact Rounded
+pwsx3399 power 0.222 0.5 -> 0.471 Inexact Rounded
+pwsx3400 power 0.0222 0.5 -> 0.149 Inexact Rounded
+pwsx3401 power 0.223 0.5 -> 0.472 Inexact Rounded
+pwsx3402 power 0.0223 0.5 -> 0.149 Inexact Rounded
+pwsx3403 power 0.224 0.5 -> 0.473 Inexact Rounded
+pwsx3404 power 0.0224 0.5 -> 0.150 Inexact Rounded
+pwsx3405 power 0.225 0.5 -> 0.474 Inexact Rounded
+pwsx3406 power 0.0225 0.5 -> 0.150 Inexact Rounded
+pwsx3407 power 0.226 0.5 -> 0.475 Inexact Rounded
+pwsx3408 power 0.0226 0.5 -> 0.150 Inexact Rounded
+pwsx3409 power 0.227 0.5 -> 0.476 Inexact Rounded
+pwsx3410 power 0.0227 0.5 -> 0.151 Inexact Rounded
+pwsx3411 power 0.228 0.5 -> 0.477 Inexact Rounded
+pwsx3412 power 0.0228 0.5 -> 0.151 Inexact Rounded
+pwsx3413 power 0.229 0.5 -> 0.479 Inexact Rounded
+pwsx3414 power 0.0229 0.5 -> 0.151 Inexact Rounded
+pwsx3415 power 0.231 0.5 -> 0.481 Inexact Rounded
+pwsx3416 power 0.0231 0.5 -> 0.152 Inexact Rounded
+pwsx3417 power 0.232 0.5 -> 0.482 Inexact Rounded
+pwsx3418 power 0.0232 0.5 -> 0.152 Inexact Rounded
+pwsx3419 power 0.233 0.5 -> 0.483 Inexact Rounded
+pwsx3420 power 0.0233 0.5 -> 0.153 Inexact Rounded
+pwsx3421 power 0.234 0.5 -> 0.484 Inexact Rounded
+pwsx3422 power 0.0234 0.5 -> 0.153 Inexact Rounded
+pwsx3423 power 0.235 0.5 -> 0.485 Inexact Rounded
+pwsx3424 power 0.0235 0.5 -> 0.153 Inexact Rounded
+pwsx3425 power 0.236 0.5 -> 0.486 Inexact Rounded
+pwsx3426 power 0.0236 0.5 -> 0.154 Inexact Rounded
+pwsx3427 power 0.237 0.5 -> 0.487 Inexact Rounded
+pwsx3428 power 0.0237 0.5 -> 0.154 Inexact Rounded
+pwsx3429 power 0.238 0.5 -> 0.488 Inexact Rounded
+pwsx3430 power 0.0238 0.5 -> 0.154 Inexact Rounded
+pwsx3431 power 0.239 0.5 -> 0.489 Inexact Rounded
+pwsx3432 power 0.0239 0.5 -> 0.155 Inexact Rounded
+pwsx3433 power 0.241 0.5 -> 0.491 Inexact Rounded
+pwsx3434 power 0.0241 0.5 -> 0.155 Inexact Rounded
+pwsx3435 power 0.242 0.5 -> 0.492 Inexact Rounded
+pwsx3436 power 0.0242 0.5 -> 0.156 Inexact Rounded
+pwsx3437 power 0.243 0.5 -> 0.493 Inexact Rounded
+pwsx3438 power 0.0243 0.5 -> 0.156 Inexact Rounded
+pwsx3439 power 0.244 0.5 -> 0.494 Inexact Rounded
+pwsx3440 power 0.0244 0.5 -> 0.156 Inexact Rounded
+pwsx3441 power 0.245 0.5 -> 0.495 Inexact Rounded
+pwsx3442 power 0.0245 0.5 -> 0.157 Inexact Rounded
+pwsx3443 power 0.246 0.5 -> 0.496 Inexact Rounded
+pwsx3444 power 0.0246 0.5 -> 0.157 Inexact Rounded
+pwsx3445 power 0.247 0.5 -> 0.497 Inexact Rounded
+pwsx3446 power 0.0247 0.5 -> 0.157 Inexact Rounded
+pwsx3447 power 0.248 0.5 -> 0.498 Inexact Rounded
+pwsx3448 power 0.0248 0.5 -> 0.157 Inexact Rounded
+pwsx3449 power 0.249 0.5 -> 0.499 Inexact Rounded
+pwsx3450 power 0.0249 0.5 -> 0.158 Inexact Rounded
+pwsx3451 power 0.251 0.5 -> 0.501 Inexact Rounded
+pwsx3452 power 0.0251 0.5 -> 0.158 Inexact Rounded
+pwsx3453 power 0.252 0.5 -> 0.502 Inexact Rounded
+pwsx3454 power 0.0252 0.5 -> 0.159 Inexact Rounded
+pwsx3455 power 0.253 0.5 -> 0.503 Inexact Rounded
+pwsx3456 power 0.0253 0.5 -> 0.159 Inexact Rounded
+pwsx3457 power 0.254 0.5 -> 0.504 Inexact Rounded
+pwsx3458 power 0.0254 0.5 -> 0.159 Inexact Rounded
+pwsx3459 power 0.255 0.5 -> 0.505 Inexact Rounded
+pwsx3460 power 0.0255 0.5 -> 0.160 Inexact Rounded
+pwsx3461 power 0.256 0.5 -> 0.506 Inexact Rounded
+pwsx3462 power 0.0256 0.5 -> 0.160 Inexact Rounded
+pwsx3463 power 0.257 0.5 -> 0.507 Inexact Rounded
+pwsx3464 power 0.0257 0.5 -> 0.160 Inexact Rounded
+pwsx3465 power 0.258 0.5 -> 0.508 Inexact Rounded
+pwsx3466 power 0.0258 0.5 -> 0.161 Inexact Rounded
+pwsx3467 power 0.259 0.5 -> 0.509 Inexact Rounded
+pwsx3468 power 0.0259 0.5 -> 0.161 Inexact Rounded
+pwsx3469 power 0.261 0.5 -> 0.511 Inexact Rounded
+pwsx3470 power 0.0261 0.5 -> 0.162 Inexact Rounded
+pwsx3471 power 0.262 0.5 -> 0.512 Inexact Rounded
+pwsx3472 power 0.0262 0.5 -> 0.162 Inexact Rounded
+pwsx3473 power 0.263 0.5 -> 0.513 Inexact Rounded
+pwsx3474 power 0.0263 0.5 -> 0.162 Inexact Rounded
+pwsx3475 power 0.264 0.5 -> 0.514 Inexact Rounded
+pwsx3476 power 0.0264 0.5 -> 0.162 Inexact Rounded
+pwsx3477 power 0.265 0.5 -> 0.515 Inexact Rounded
+pwsx3478 power 0.0265 0.5 -> 0.163 Inexact Rounded
+pwsx3479 power 0.266 0.5 -> 0.516 Inexact Rounded
+pwsx3480 power 0.0266 0.5 -> 0.163 Inexact Rounded
+pwsx3481 power 0.267 0.5 -> 0.517 Inexact Rounded
+pwsx3482 power 0.0267 0.5 -> 0.163 Inexact Rounded
+pwsx3483 power 0.268 0.5 -> 0.518 Inexact Rounded
+pwsx3484 power 0.0268 0.5 -> 0.164 Inexact Rounded
+pwsx3485 power 0.269 0.5 -> 0.519 Inexact Rounded
+pwsx3486 power 0.0269 0.5 -> 0.164 Inexact Rounded
+pwsx3487 power 0.271 0.5 -> 0.521 Inexact Rounded
+pwsx3488 power 0.0271 0.5 -> 0.165 Inexact Rounded
+pwsx3489 power 0.272 0.5 -> 0.522 Inexact Rounded
+pwsx3490 power 0.0272 0.5 -> 0.165 Inexact Rounded
+pwsx3491 power 0.273 0.5 -> 0.522 Inexact Rounded
+pwsx3492 power 0.0273 0.5 -> 0.165 Inexact Rounded
+pwsx3493 power 0.274 0.5 -> 0.523 Inexact Rounded
+pwsx3494 power 0.0274 0.5 -> 0.166 Inexact Rounded
+pwsx3495 power 0.275 0.5 -> 0.524 Inexact Rounded
+pwsx3496 power 0.0275 0.5 -> 0.166 Inexact Rounded
+pwsx3497 power 0.276 0.5 -> 0.525 Inexact Rounded
+pwsx3498 power 0.0276 0.5 -> 0.166 Inexact Rounded
+pwsx3499 power 0.277 0.5 -> 0.526 Inexact Rounded
+pwsx3500 power 0.0277 0.5 -> 0.166 Inexact Rounded
+pwsx3501 power 0.278 0.5 -> 0.527 Inexact Rounded
+pwsx3502 power 0.0278 0.5 -> 0.167 Inexact Rounded
+pwsx3503 power 0.279 0.5 -> 0.528 Inexact Rounded
+pwsx3504 power 0.0279 0.5 -> 0.167 Inexact Rounded
+pwsx3505 power 0.281 0.5 -> 0.530 Inexact Rounded
+pwsx3506 power 0.0281 0.5 -> 0.168 Inexact Rounded
+pwsx3507 power 0.282 0.5 -> 0.531 Inexact Rounded
+pwsx3508 power 0.0282 0.5 -> 0.168 Inexact Rounded
+pwsx3509 power 0.283 0.5 -> 0.532 Inexact Rounded
+pwsx3510 power 0.0283 0.5 -> 0.168 Inexact Rounded
+pwsx3511 power 0.284 0.5 -> 0.533 Inexact Rounded
+pwsx3512 power 0.0284 0.5 -> 0.169 Inexact Rounded
+pwsx3513 power 0.285 0.5 -> 0.534 Inexact Rounded
+pwsx3514 power 0.0285 0.5 -> 0.169 Inexact Rounded
+pwsx3515 power 0.286 0.5 -> 0.535 Inexact Rounded
+pwsx3516 power 0.0286 0.5 -> 0.169 Inexact Rounded
+pwsx3517 power 0.287 0.5 -> 0.536 Inexact Rounded
+pwsx3518 power 0.0287 0.5 -> 0.169 Inexact Rounded
+pwsx3519 power 0.288 0.5 -> 0.537 Inexact Rounded
+pwsx3520 power 0.0288 0.5 -> 0.170 Inexact Rounded
+pwsx3521 power 0.289 0.5 -> 0.538 Inexact Rounded
+pwsx3522 power 0.0289 0.5 -> 0.170 Inexact Rounded
+pwsx3523 power 0.291 0.5 -> 0.539 Inexact Rounded
+pwsx3524 power 0.0291 0.5 -> 0.171 Inexact Rounded
+pwsx3525 power 0.292 0.5 -> 0.540 Inexact Rounded
+pwsx3526 power 0.0292 0.5 -> 0.171 Inexact Rounded
+pwsx3527 power 0.293 0.5 -> 0.541 Inexact Rounded
+pwsx3528 power 0.0293 0.5 -> 0.171 Inexact Rounded
+pwsx3529 power 0.294 0.5 -> 0.542 Inexact Rounded
+pwsx3530 power 0.0294 0.5 -> 0.171 Inexact Rounded
+pwsx3531 power 0.295 0.5 -> 0.543 Inexact Rounded
+pwsx3532 power 0.0295 0.5 -> 0.172 Inexact Rounded
+pwsx3533 power 0.296 0.5 -> 0.544 Inexact Rounded
+pwsx3534 power 0.0296 0.5 -> 0.172 Inexact Rounded
+pwsx3535 power 0.297 0.5 -> 0.545 Inexact Rounded
+pwsx3536 power 0.0297 0.5 -> 0.172 Inexact Rounded
+pwsx3537 power 0.298 0.5 -> 0.546 Inexact Rounded
+pwsx3538 power 0.0298 0.5 -> 0.173 Inexact Rounded
+pwsx3539 power 0.299 0.5 -> 0.547 Inexact Rounded
+pwsx3540 power 0.0299 0.5 -> 0.173 Inexact Rounded
+pwsx3541 power 0.301 0.5 -> 0.549 Inexact Rounded
+pwsx3542 power 0.0301 0.5 -> 0.173 Inexact Rounded
+pwsx3543 power 0.302 0.5 -> 0.550 Inexact Rounded
+pwsx3544 power 0.0302 0.5 -> 0.174 Inexact Rounded
+pwsx3545 power 0.303 0.5 -> 0.550 Inexact Rounded
+pwsx3546 power 0.0303 0.5 -> 0.174 Inexact Rounded
+pwsx3547 power 0.304 0.5 -> 0.551 Inexact Rounded
+pwsx3548 power 0.0304 0.5 -> 0.174 Inexact Rounded
+pwsx3549 power 0.305 0.5 -> 0.552 Inexact Rounded
+pwsx3550 power 0.0305 0.5 -> 0.175 Inexact Rounded
+pwsx3551 power 0.306 0.5 -> 0.553 Inexact Rounded
+pwsx3552 power 0.0306 0.5 -> 0.175 Inexact Rounded
+pwsx3553 power 0.307 0.5 -> 0.554 Inexact Rounded
+pwsx3554 power 0.0307 0.5 -> 0.175 Inexact Rounded
+pwsx3555 power 0.308 0.5 -> 0.555 Inexact Rounded
+pwsx3556 power 0.0308 0.5 -> 0.175 Inexact Rounded
+pwsx3557 power 0.309 0.5 -> 0.556 Inexact Rounded
+pwsx3558 power 0.0309 0.5 -> 0.176 Inexact Rounded
+pwsx3559 power 0.311 0.5 -> 0.558 Inexact Rounded
+pwsx3560 power 0.0311 0.5 -> 0.176 Inexact Rounded
+pwsx3561 power 0.312 0.5 -> 0.559 Inexact Rounded
+pwsx3562 power 0.0312 0.5 -> 0.177 Inexact Rounded
+pwsx3563 power 0.313 0.5 -> 0.559 Inexact Rounded
+pwsx3564 power 0.0313 0.5 -> 0.177 Inexact Rounded
+pwsx3565 power 0.314 0.5 -> 0.560 Inexact Rounded
+pwsx3566 power 0.0314 0.5 -> 0.177 Inexact Rounded
+pwsx3567 power 0.315 0.5 -> 0.561 Inexact Rounded
+pwsx3568 power 0.0315 0.5 -> 0.177 Inexact Rounded
+pwsx3569 power 0.316 0.5 -> 0.562 Inexact Rounded
+pwsx3570 power 0.0316 0.5 -> 0.178 Inexact Rounded
+pwsx3571 power 0.317 0.5 -> 0.563 Inexact Rounded
+pwsx3572 power 0.0317 0.5 -> 0.178 Inexact Rounded
+pwsx3573 power 0.318 0.5 -> 0.564 Inexact Rounded
+pwsx3574 power 0.0318 0.5 -> 0.178 Inexact Rounded
+pwsx3575 power 0.319 0.5 -> 0.565 Inexact Rounded
+pwsx3576 power 0.0319 0.5 -> 0.179 Inexact Rounded
+pwsx3577 power 0.321 0.5 -> 0.567 Inexact Rounded
+pwsx3578 power 0.0321 0.5 -> 0.179 Inexact Rounded
+pwsx3579 power 0.322 0.5 -> 0.567 Inexact Rounded
+pwsx3580 power 0.0322 0.5 -> 0.179 Inexact Rounded
+pwsx3581 power 0.323 0.5 -> 0.568 Inexact Rounded
+pwsx3582 power 0.0323 0.5 -> 0.180 Inexact Rounded
+pwsx3583 power 0.324 0.5 -> 0.569 Inexact Rounded
+pwsx3584 power 0.0324 0.5 -> 0.180 Inexact Rounded
+pwsx3585 power 0.325 0.5 -> 0.570 Inexact Rounded
+pwsx3586 power 0.0325 0.5 -> 0.180 Inexact Rounded
+pwsx3587 power 0.326 0.5 -> 0.571 Inexact Rounded
+pwsx3588 power 0.0326 0.5 -> 0.181 Inexact Rounded
+pwsx3589 power 0.327 0.5 -> 0.572 Inexact Rounded
+pwsx3590 power 0.0327 0.5 -> 0.181 Inexact Rounded
+pwsx3591 power 0.328 0.5 -> 0.573 Inexact Rounded
+pwsx3592 power 0.0328 0.5 -> 0.181 Inexact Rounded
+pwsx3593 power 0.329 0.5 -> 0.574 Inexact Rounded
+pwsx3594 power 0.0329 0.5 -> 0.181 Inexact Rounded
+pwsx3595 power 0.331 0.5 -> 0.575 Inexact Rounded
+pwsx3596 power 0.0331 0.5 -> 0.182 Inexact Rounded
+pwsx3597 power 0.332 0.5 -> 0.576 Inexact Rounded
+pwsx3598 power 0.0332 0.5 -> 0.182 Inexact Rounded
+pwsx3599 power 0.333 0.5 -> 0.577 Inexact Rounded
+pwsx3600 power 0.0333 0.5 -> 0.182 Inexact Rounded
+pwsx3601 power 0.334 0.5 -> 0.578 Inexact Rounded
+pwsx3602 power 0.0334 0.5 -> 0.183 Inexact Rounded
+pwsx3603 power 0.335 0.5 -> 0.579 Inexact Rounded
+pwsx3604 power 0.0335 0.5 -> 0.183 Inexact Rounded
+pwsx3605 power 0.336 0.5 -> 0.580 Inexact Rounded
+pwsx3606 power 0.0336 0.5 -> 0.183 Inexact Rounded
+pwsx3607 power 0.337 0.5 -> 0.581 Inexact Rounded
+pwsx3608 power 0.0337 0.5 -> 0.184 Inexact Rounded
+pwsx3609 power 0.338 0.5 -> 0.581 Inexact Rounded
+pwsx3610 power 0.0338 0.5 -> 0.184 Inexact Rounded
+pwsx3611 power 0.339 0.5 -> 0.582 Inexact Rounded
+pwsx3612 power 0.0339 0.5 -> 0.184 Inexact Rounded
+pwsx3613 power 0.341 0.5 -> 0.584 Inexact Rounded
+pwsx3614 power 0.0341 0.5 -> 0.185 Inexact Rounded
+pwsx3615 power 0.342 0.5 -> 0.585 Inexact Rounded
+pwsx3616 power 0.0342 0.5 -> 0.185 Inexact Rounded
+pwsx3617 power 0.343 0.5 -> 0.586 Inexact Rounded
+pwsx3618 power 0.0343 0.5 -> 0.185 Inexact Rounded
+pwsx3619 power 0.344 0.5 -> 0.587 Inexact Rounded
+pwsx3620 power 0.0344 0.5 -> 0.185 Inexact Rounded
+pwsx3621 power 0.345 0.5 -> 0.587 Inexact Rounded
+pwsx3622 power 0.0345 0.5 -> 0.186 Inexact Rounded
+pwsx3623 power 0.346 0.5 -> 0.588 Inexact Rounded
+pwsx3624 power 0.0346 0.5 -> 0.186 Inexact Rounded
+pwsx3625 power 0.347 0.5 -> 0.589 Inexact Rounded
+pwsx3626 power 0.0347 0.5 -> 0.186 Inexact Rounded
+pwsx3627 power 0.348 0.5 -> 0.590 Inexact Rounded
+pwsx3628 power 0.0348 0.5 -> 0.187 Inexact Rounded
+pwsx3629 power 0.349 0.5 -> 0.591 Inexact Rounded
+pwsx3630 power 0.0349 0.5 -> 0.187 Inexact Rounded
+pwsx3631 power 0.351 0.5 -> 0.592 Inexact Rounded
+pwsx3632 power 0.0351 0.5 -> 0.187 Inexact Rounded
+pwsx3633 power 0.352 0.5 -> 0.593 Inexact Rounded
+pwsx3634 power 0.0352 0.5 -> 0.188 Inexact Rounded
+pwsx3635 power 0.353 0.5 -> 0.594 Inexact Rounded
+pwsx3636 power 0.0353 0.5 -> 0.188 Inexact Rounded
+pwsx3637 power 0.354 0.5 -> 0.595 Inexact Rounded
+pwsx3638 power 0.0354 0.5 -> 0.188 Inexact Rounded
+pwsx3639 power 0.355 0.5 -> 0.596 Inexact Rounded
+pwsx3640 power 0.0355 0.5 -> 0.188 Inexact Rounded
+pwsx3641 power 0.356 0.5 -> 0.597 Inexact Rounded
+pwsx3642 power 0.0356 0.5 -> 0.189 Inexact Rounded
+pwsx3643 power 0.357 0.5 -> 0.597 Inexact Rounded
+pwsx3644 power 0.0357 0.5 -> 0.189 Inexact Rounded
+pwsx3645 power 0.358 0.5 -> 0.598 Inexact Rounded
+pwsx3646 power 0.0358 0.5 -> 0.189 Inexact Rounded
+pwsx3647 power 0.359 0.5 -> 0.599 Inexact Rounded
+pwsx3648 power 0.0359 0.5 -> 0.189 Inexact Rounded
+pwsx3649 power 0.361 0.5 -> 0.601 Inexact Rounded
+pwsx3650 power 0.0361 0.5 -> 0.190 Inexact Rounded
+pwsx3651 power 0.362 0.5 -> 0.602 Inexact Rounded
+pwsx3652 power 0.0362 0.5 -> 0.190 Inexact Rounded
+pwsx3653 power 0.363 0.5 -> 0.602 Inexact Rounded
+pwsx3654 power 0.0363 0.5 -> 0.191 Inexact Rounded
+pwsx3655 power 0.364 0.5 -> 0.603 Inexact Rounded
+pwsx3656 power 0.0364 0.5 -> 0.191 Inexact Rounded
+pwsx3657 power 0.365 0.5 -> 0.604 Inexact Rounded
+pwsx3658 power 0.0365 0.5 -> 0.191 Inexact Rounded
+pwsx3659 power 0.366 0.5 -> 0.605 Inexact Rounded
+pwsx3660 power 0.0366 0.5 -> 0.191 Inexact Rounded
+pwsx3661 power 0.367 0.5 -> 0.606 Inexact Rounded
+pwsx3662 power 0.0367 0.5 -> 0.192 Inexact Rounded
+pwsx3663 power 0.368 0.5 -> 0.607 Inexact Rounded
+pwsx3664 power 0.0368 0.5 -> 0.192 Inexact Rounded
+pwsx3665 power 0.369 0.5 -> 0.607 Inexact Rounded
+pwsx3666 power 0.0369 0.5 -> 0.192 Inexact Rounded
+pwsx3667 power 0.371 0.5 -> 0.609 Inexact Rounded
+pwsx3668 power 0.0371 0.5 -> 0.193 Inexact Rounded
+pwsx3669 power 0.372 0.5 -> 0.610 Inexact Rounded
+pwsx3670 power 0.0372 0.5 -> 0.193 Inexact Rounded
+pwsx3671 power 0.373 0.5 -> 0.611 Inexact Rounded
+pwsx3672 power 0.0373 0.5 -> 0.193 Inexact Rounded
+pwsx3673 power 0.374 0.5 -> 0.612 Inexact Rounded
+pwsx3674 power 0.0374 0.5 -> 0.193 Inexact Rounded
+pwsx3675 power 0.375 0.5 -> 0.612 Inexact Rounded
+pwsx3676 power 0.0375 0.5 -> 0.194 Inexact Rounded
+pwsx3677 power 0.376 0.5 -> 0.613 Inexact Rounded
+pwsx3678 power 0.0376 0.5 -> 0.194 Inexact Rounded
+pwsx3679 power 0.377 0.5 -> 0.614 Inexact Rounded
+pwsx3680 power 0.0377 0.5 -> 0.194 Inexact Rounded
+pwsx3681 power 0.378 0.5 -> 0.615 Inexact Rounded
+pwsx3682 power 0.0378 0.5 -> 0.194 Inexact Rounded
+pwsx3683 power 0.379 0.5 -> 0.616 Inexact Rounded
+pwsx3684 power 0.0379 0.5 -> 0.195 Inexact Rounded
+pwsx3685 power 0.381 0.5 -> 0.617 Inexact Rounded
+pwsx3686 power 0.0381 0.5 -> 0.195 Inexact Rounded
+pwsx3687 power 0.382 0.5 -> 0.618 Inexact Rounded
+pwsx3688 power 0.0382 0.5 -> 0.195 Inexact Rounded
+pwsx3689 power 0.383 0.5 -> 0.619 Inexact Rounded
+pwsx3690 power 0.0383 0.5 -> 0.196 Inexact Rounded
+pwsx3691 power 0.384 0.5 -> 0.620 Inexact Rounded
+pwsx3692 power 0.0384 0.5 -> 0.196 Inexact Rounded
+pwsx3693 power 0.385 0.5 -> 0.620 Inexact Rounded
+pwsx3694 power 0.0385 0.5 -> 0.196 Inexact Rounded
+pwsx3695 power 0.386 0.5 -> 0.621 Inexact Rounded
+pwsx3696 power 0.0386 0.5 -> 0.196 Inexact Rounded
+pwsx3697 power 0.387 0.5 -> 0.622 Inexact Rounded
+pwsx3698 power 0.0387 0.5 -> 0.197 Inexact Rounded
+pwsx3699 power 0.388 0.5 -> 0.623 Inexact Rounded
+pwsx3700 power 0.0388 0.5 -> 0.197 Inexact Rounded
+pwsx3701 power 0.389 0.5 -> 0.624 Inexact Rounded
+pwsx3702 power 0.0389 0.5 -> 0.197 Inexact Rounded
+pwsx3703 power 0.391 0.5 -> 0.625 Inexact Rounded
+pwsx3704 power 0.0391 0.5 -> 0.198 Inexact Rounded
+pwsx3705 power 0.392 0.5 -> 0.626 Inexact Rounded
+pwsx3706 power 0.0392 0.5 -> 0.198 Inexact Rounded
+pwsx3707 power 0.393 0.5 -> 0.627 Inexact Rounded
+pwsx3708 power 0.0393 0.5 -> 0.198 Inexact Rounded
+pwsx3709 power 0.394 0.5 -> 0.628 Inexact Rounded
+pwsx3710 power 0.0394 0.5 -> 0.198 Inexact Rounded
+pwsx3711 power 0.395 0.5 -> 0.628 Inexact Rounded
+pwsx3712 power 0.0395 0.5 -> 0.199 Inexact Rounded
+pwsx3713 power 0.396 0.5 -> 0.629 Inexact Rounded
+pwsx3714 power 0.0396 0.5 -> 0.199 Inexact Rounded
+pwsx3715 power 0.397 0.5 -> 0.630 Inexact Rounded
+pwsx3716 power 0.0397 0.5 -> 0.199 Inexact Rounded
+pwsx3717 power 0.398 0.5 -> 0.631 Inexact Rounded
+pwsx3718 power 0.0398 0.5 -> 0.199 Inexact Rounded
+pwsx3719 power 0.399 0.5 -> 0.632 Inexact Rounded
+pwsx3720 power 0.0399 0.5 -> 0.200 Inexact Rounded
+pwsx3721 power 0.401 0.5 -> 0.633 Inexact Rounded
+pwsx3722 power 0.0401 0.5 -> 0.200 Inexact Rounded
+pwsx3723 power 0.402 0.5 -> 0.634 Inexact Rounded
+pwsx3724 power 0.0402 0.5 -> 0.200 Inexact Rounded
+pwsx3725 power 0.403 0.5 -> 0.635 Inexact Rounded
+pwsx3726 power 0.0403 0.5 -> 0.201 Inexact Rounded
+pwsx3727 power 0.404 0.5 -> 0.636 Inexact Rounded
+pwsx3728 power 0.0404 0.5 -> 0.201 Inexact Rounded
+pwsx3729 power 0.405 0.5 -> 0.636 Inexact Rounded
+pwsx3730 power 0.0405 0.5 -> 0.201 Inexact Rounded
+pwsx3731 power 0.406 0.5 -> 0.637 Inexact Rounded
+pwsx3732 power 0.0406 0.5 -> 0.201 Inexact Rounded
+pwsx3733 power 0.407 0.5 -> 0.638 Inexact Rounded
+pwsx3734 power 0.0407 0.5 -> 0.202 Inexact Rounded
+pwsx3735 power 0.408 0.5 -> 0.639 Inexact Rounded
+pwsx3736 power 0.0408 0.5 -> 0.202 Inexact Rounded
+pwsx3737 power 0.409 0.5 -> 0.640 Inexact Rounded
+pwsx3738 power 0.0409 0.5 -> 0.202 Inexact Rounded
+pwsx3739 power 0.411 0.5 -> 0.641 Inexact Rounded
+pwsx3740 power 0.0411 0.5 -> 0.203 Inexact Rounded
+pwsx3741 power 0.412 0.5 -> 0.642 Inexact Rounded
+pwsx3742 power 0.0412 0.5 -> 0.203 Inexact Rounded
+pwsx3743 power 0.413 0.5 -> 0.643 Inexact Rounded
+pwsx3744 power 0.0413 0.5 -> 0.203 Inexact Rounded
+pwsx3745 power 0.414 0.5 -> 0.643 Inexact Rounded
+pwsx3746 power 0.0414 0.5 -> 0.203 Inexact Rounded
+pwsx3747 power 0.415 0.5 -> 0.644 Inexact Rounded
+pwsx3748 power 0.0415 0.5 -> 0.204 Inexact Rounded
+pwsx3749 power 0.416 0.5 -> 0.645 Inexact Rounded
+pwsx3750 power 0.0416 0.5 -> 0.204 Inexact Rounded
+pwsx3751 power 0.417 0.5 -> 0.646 Inexact Rounded
+pwsx3752 power 0.0417 0.5 -> 0.204 Inexact Rounded
+pwsx3753 power 0.418 0.5 -> 0.647 Inexact Rounded
+pwsx3754 power 0.0418 0.5 -> 0.204 Inexact Rounded
+pwsx3755 power 0.419 0.5 -> 0.647 Inexact Rounded
+pwsx3756 power 0.0419 0.5 -> 0.205 Inexact Rounded
+pwsx3757 power 0.421 0.5 -> 0.649 Inexact Rounded
+pwsx3758 power 0.0421 0.5 -> 0.205 Inexact Rounded
+pwsx3759 power 0.422 0.5 -> 0.650 Inexact Rounded
+pwsx3760 power 0.0422 0.5 -> 0.205 Inexact Rounded
+pwsx3761 power 0.423 0.5 -> 0.650 Inexact Rounded
+pwsx3762 power 0.0423 0.5 -> 0.206 Inexact Rounded
+pwsx3763 power 0.424 0.5 -> 0.651 Inexact Rounded
+pwsx3764 power 0.0424 0.5 -> 0.206 Inexact Rounded
+pwsx3765 power 0.425 0.5 -> 0.652 Inexact Rounded
+pwsx3766 power 0.0425 0.5 -> 0.206 Inexact Rounded
+pwsx3767 power 0.426 0.5 -> 0.653 Inexact Rounded
+pwsx3768 power 0.0426 0.5 -> 0.206 Inexact Rounded
+pwsx3769 power 0.427 0.5 -> 0.653 Inexact Rounded
+pwsx3770 power 0.0427 0.5 -> 0.207 Inexact Rounded
+pwsx3771 power 0.428 0.5 -> 0.654 Inexact Rounded
+pwsx3772 power 0.0428 0.5 -> 0.207 Inexact Rounded
+pwsx3773 power 0.429 0.5 -> 0.655 Inexact Rounded
+pwsx3774 power 0.0429 0.5 -> 0.207 Inexact Rounded
+pwsx3775 power 0.431 0.5 -> 0.657 Inexact Rounded
+pwsx3776 power 0.0431 0.5 -> 0.208 Inexact Rounded
+pwsx3777 power 0.432 0.5 -> 0.657 Inexact Rounded
+pwsx3778 power 0.0432 0.5 -> 0.208 Inexact Rounded
+pwsx3779 power 0.433 0.5 -> 0.658 Inexact Rounded
+pwsx3780 power 0.0433 0.5 -> 0.208 Inexact Rounded
+pwsx3781 power 0.434 0.5 -> 0.659 Inexact Rounded
+pwsx3782 power 0.0434 0.5 -> 0.208 Inexact Rounded
+pwsx3783 power 0.435 0.5 -> 0.660 Inexact Rounded
+pwsx3784 power 0.0435 0.5 -> 0.209 Inexact Rounded
+pwsx3785 power 0.436 0.5 -> 0.660 Inexact Rounded
+pwsx3786 power 0.0436 0.5 -> 0.209 Inexact Rounded
+pwsx3787 power 0.437 0.5 -> 0.661 Inexact Rounded
+pwsx3788 power 0.0437 0.5 -> 0.209 Inexact Rounded
+pwsx3789 power 0.438 0.5 -> 0.662 Inexact Rounded
+pwsx3790 power 0.0438 0.5 -> 0.209 Inexact Rounded
+pwsx3791 power 0.439 0.5 -> 0.663 Inexact Rounded
+pwsx3792 power 0.0439 0.5 -> 0.210 Inexact Rounded
+pwsx3793 power 0.441 0.5 -> 0.664 Inexact Rounded
+pwsx3794 power 0.0441 0.5 -> 0.210 Inexact Rounded
+pwsx3795 power 0.442 0.5 -> 0.665 Inexact Rounded
+pwsx3796 power 0.0442 0.5 -> 0.210 Inexact Rounded
+pwsx3797 power 0.443 0.5 -> 0.666 Inexact Rounded
+pwsx3798 power 0.0443 0.5 -> 0.210 Inexact Rounded
+pwsx3799 power 0.444 0.5 -> 0.666 Inexact Rounded
+pwsx3800 power 0.0444 0.5 -> 0.211 Inexact Rounded
+pwsx3801 power 0.445 0.5 -> 0.667 Inexact Rounded
+pwsx3802 power 0.0445 0.5 -> 0.211 Inexact Rounded
+pwsx3803 power 0.446 0.5 -> 0.668 Inexact Rounded
+pwsx3804 power 0.0446 0.5 -> 0.211 Inexact Rounded
+pwsx3805 power 0.447 0.5 -> 0.669 Inexact Rounded
+pwsx3806 power 0.0447 0.5 -> 0.211 Inexact Rounded
+pwsx3807 power 0.448 0.5 -> 0.669 Inexact Rounded
+pwsx3808 power 0.0448 0.5 -> 0.212 Inexact Rounded
+pwsx3809 power 0.449 0.5 -> 0.670 Inexact Rounded
+pwsx3810 power 0.0449 0.5 -> 0.212 Inexact Rounded
+pwsx3811 power 0.451 0.5 -> 0.672 Inexact Rounded
+pwsx3812 power 0.0451 0.5 -> 0.212 Inexact Rounded
+pwsx3813 power 0.452 0.5 -> 0.672 Inexact Rounded
+pwsx3814 power 0.0452 0.5 -> 0.213 Inexact Rounded
+pwsx3815 power 0.453 0.5 -> 0.673 Inexact Rounded
+pwsx3816 power 0.0453 0.5 -> 0.213 Inexact Rounded
+pwsx3817 power 0.454 0.5 -> 0.674 Inexact Rounded
+pwsx3818 power 0.0454 0.5 -> 0.213 Inexact Rounded
+pwsx3819 power 0.455 0.5 -> 0.675 Inexact Rounded
+pwsx3820 power 0.0455 0.5 -> 0.213 Inexact Rounded
+pwsx3821 power 0.456 0.5 -> 0.675 Inexact Rounded
+pwsx3822 power 0.0456 0.5 -> 0.214 Inexact Rounded
+pwsx3823 power 0.457 0.5 -> 0.676 Inexact Rounded
+pwsx3824 power 0.0457 0.5 -> 0.214 Inexact Rounded
+pwsx3825 power 0.458 0.5 -> 0.677 Inexact Rounded
+pwsx3826 power 0.0458 0.5 -> 0.214 Inexact Rounded
+pwsx3827 power 0.459 0.5 -> 0.677 Inexact Rounded
+pwsx3828 power 0.0459 0.5 -> 0.214 Inexact Rounded
+pwsx3829 power 0.461 0.5 -> 0.679 Inexact Rounded
+pwsx3830 power 0.0461 0.5 -> 0.215 Inexact Rounded
+pwsx3831 power 0.462 0.5 -> 0.680 Inexact Rounded
+pwsx3832 power 0.0462 0.5 -> 0.215 Inexact Rounded
+pwsx3833 power 0.463 0.5 -> 0.680 Inexact Rounded
+pwsx3834 power 0.0463 0.5 -> 0.215 Inexact Rounded
+pwsx3835 power 0.464 0.5 -> 0.681 Inexact Rounded
+pwsx3836 power 0.0464 0.5 -> 0.215 Inexact Rounded
+pwsx3837 power 0.465 0.5 -> 0.682 Inexact Rounded
+pwsx3838 power 0.0465 0.5 -> 0.216 Inexact Rounded
+pwsx3839 power 0.466 0.5 -> 0.683 Inexact Rounded
+pwsx3840 power 0.0466 0.5 -> 0.216 Inexact Rounded
+pwsx3841 power 0.467 0.5 -> 0.683 Inexact Rounded
+pwsx3842 power 0.0467 0.5 -> 0.216 Inexact Rounded
+pwsx3843 power 0.468 0.5 -> 0.684 Inexact Rounded
+pwsx3844 power 0.0468 0.5 -> 0.216 Inexact Rounded
+pwsx3845 power 0.469 0.5 -> 0.685 Inexact Rounded
+pwsx3846 power 0.0469 0.5 -> 0.217 Inexact Rounded
+pwsx3847 power 0.471 0.5 -> 0.686 Inexact Rounded
+pwsx3848 power 0.0471 0.5 -> 0.217 Inexact Rounded
+pwsx3849 power 0.472 0.5 -> 0.687 Inexact Rounded
+pwsx3850 power 0.0472 0.5 -> 0.217 Inexact Rounded
+pwsx3851 power 0.473 0.5 -> 0.688 Inexact Rounded
+pwsx3852 power 0.0473 0.5 -> 0.217 Inexact Rounded
+pwsx3853 power 0.474 0.5 -> 0.688 Inexact Rounded
+pwsx3854 power 0.0474 0.5 -> 0.218 Inexact Rounded
+pwsx3855 power 0.475 0.5 -> 0.689 Inexact Rounded
+pwsx3856 power 0.0475 0.5 -> 0.218 Inexact Rounded
+pwsx3857 power 0.476 0.5 -> 0.690 Inexact Rounded
+pwsx3858 power 0.0476 0.5 -> 0.218 Inexact Rounded
+pwsx3859 power 0.477 0.5 -> 0.691 Inexact Rounded
+pwsx3860 power 0.0477 0.5 -> 0.218 Inexact Rounded
+pwsx3861 power 0.478 0.5 -> 0.691 Inexact Rounded
+pwsx3862 power 0.0478 0.5 -> 0.219 Inexact Rounded
+pwsx3863 power 0.479 0.5 -> 0.692 Inexact Rounded
+pwsx3864 power 0.0479 0.5 -> 0.219 Inexact Rounded
+pwsx3865 power 0.481 0.5 -> 0.694 Inexact Rounded
+pwsx3866 power 0.0481 0.5 -> 0.219 Inexact Rounded
+pwsx3867 power 0.482 0.5 -> 0.694 Inexact Rounded
+pwsx3868 power 0.0482 0.5 -> 0.220 Inexact Rounded
+pwsx3869 power 0.483 0.5 -> 0.695 Inexact Rounded
+pwsx3870 power 0.0483 0.5 -> 0.220 Inexact Rounded
+pwsx3871 power 0.484 0.5 -> 0.696 Inexact Rounded
+pwsx3872 power 0.0484 0.5 -> 0.220 Inexact Rounded
+pwsx3873 power 0.485 0.5 -> 0.696 Inexact Rounded
+pwsx3874 power 0.0485 0.5 -> 0.220 Inexact Rounded
+pwsx3875 power 0.486 0.5 -> 0.697 Inexact Rounded
+pwsx3876 power 0.0486 0.5 -> 0.220 Inexact Rounded
+pwsx3877 power 0.487 0.5 -> 0.698 Inexact Rounded
+pwsx3878 power 0.0487 0.5 -> 0.221 Inexact Rounded
+pwsx3879 power 0.488 0.5 -> 0.699 Inexact Rounded
+pwsx3880 power 0.0488 0.5 -> 0.221 Inexact Rounded
+pwsx3881 power 0.489 0.5 -> 0.699 Inexact Rounded
+pwsx3882 power 0.0489 0.5 -> 0.221 Inexact Rounded
+pwsx3883 power 0.491 0.5 -> 0.701 Inexact Rounded
+pwsx3884 power 0.0491 0.5 -> 0.222 Inexact Rounded
+pwsx3885 power 0.492 0.5 -> 0.701 Inexact Rounded
+pwsx3886 power 0.0492 0.5 -> 0.222 Inexact Rounded
+pwsx3887 power 0.493 0.5 -> 0.702 Inexact Rounded
+pwsx3888 power 0.0493 0.5 -> 0.222 Inexact Rounded
+pwsx3889 power 0.494 0.5 -> 0.703 Inexact Rounded
+pwsx3890 power 0.0494 0.5 -> 0.222 Inexact Rounded
+pwsx3891 power 0.495 0.5 -> 0.704 Inexact Rounded
+pwsx3892 power 0.0495 0.5 -> 0.222 Inexact Rounded
+pwsx3893 power 0.496 0.5 -> 0.704 Inexact Rounded
+pwsx3894 power 0.0496 0.5 -> 0.223 Inexact Rounded
+pwsx3895 power 0.497 0.5 -> 0.705 Inexact Rounded
+pwsx3896 power 0.0497 0.5 -> 0.223 Inexact Rounded
+pwsx3897 power 0.498 0.5 -> 0.706 Inexact Rounded
+pwsx3898 power 0.0498 0.5 -> 0.223 Inexact Rounded
+pwsx3899 power 0.499 0.5 -> 0.706 Inexact Rounded
+pwsx3900 power 0.0499 0.5 -> 0.223 Inexact Rounded
+pwsx3901 power 0.501 0.5 -> 0.708 Inexact Rounded
+pwsx3902 power 0.0501 0.5 -> 0.224 Inexact Rounded
+pwsx3903 power 0.502 0.5 -> 0.709 Inexact Rounded
+pwsx3904 power 0.0502 0.5 -> 0.224 Inexact Rounded
+pwsx3905 power 0.503 0.5 -> 0.709 Inexact Rounded
+pwsx3906 power 0.0503 0.5 -> 0.224 Inexact Rounded
+pwsx3907 power 0.504 0.5 -> 0.710 Inexact Rounded
+pwsx3908 power 0.0504 0.5 -> 0.224 Inexact Rounded
+pwsx3909 power 0.505 0.5 -> 0.711 Inexact Rounded
+pwsx3910 power 0.0505 0.5 -> 0.225 Inexact Rounded
+pwsx3911 power 0.506 0.5 -> 0.711 Inexact Rounded
+pwsx3912 power 0.0506 0.5 -> 0.225 Inexact Rounded
+pwsx3913 power 0.507 0.5 -> 0.712 Inexact Rounded
+pwsx3914 power 0.0507 0.5 -> 0.225 Inexact Rounded
+pwsx3915 power 0.508 0.5 -> 0.713 Inexact Rounded
+pwsx3916 power 0.0508 0.5 -> 0.225 Inexact Rounded
+pwsx3917 power 0.509 0.5 -> 0.713 Inexact Rounded
+pwsx3918 power 0.0509 0.5 -> 0.226 Inexact Rounded
+pwsx3919 power 0.511 0.5 -> 0.715 Inexact Rounded
+pwsx3920 power 0.0511 0.5 -> 0.226 Inexact Rounded
+pwsx3921 power 0.512 0.5 -> 0.716 Inexact Rounded
+pwsx3922 power 0.0512 0.5 -> 0.226 Inexact Rounded
+pwsx3923 power 0.513 0.5 -> 0.716 Inexact Rounded
+pwsx3924 power 0.0513 0.5 -> 0.226 Inexact Rounded
+pwsx3925 power 0.514 0.5 -> 0.717 Inexact Rounded
+pwsx3926 power 0.0514 0.5 -> 0.227 Inexact Rounded
+pwsx3927 power 0.515 0.5 -> 0.718 Inexact Rounded
+pwsx3928 power 0.0515 0.5 -> 0.227 Inexact Rounded
+pwsx3929 power 0.516 0.5 -> 0.718 Inexact Rounded
+pwsx3930 power 0.0516 0.5 -> 0.227 Inexact Rounded
+pwsx3931 power 0.517 0.5 -> 0.719 Inexact Rounded
+pwsx3932 power 0.0517 0.5 -> 0.227 Inexact Rounded
+pwsx3933 power 0.518 0.5 -> 0.720 Inexact Rounded
+pwsx3934 power 0.0518 0.5 -> 0.228 Inexact Rounded
+pwsx3935 power 0.519 0.5 -> 0.720 Inexact Rounded
+pwsx3936 power 0.0519 0.5 -> 0.228 Inexact Rounded
+pwsx3937 power 0.521 0.5 -> 0.722 Inexact Rounded
+pwsx3938 power 0.0521 0.5 -> 0.228 Inexact Rounded
+pwsx3939 power 0.522 0.5 -> 0.722 Inexact Rounded
+pwsx3940 power 0.0522 0.5 -> 0.228 Inexact Rounded
+pwsx3941 power 0.523 0.5 -> 0.723 Inexact Rounded
+pwsx3942 power 0.0523 0.5 -> 0.229 Inexact Rounded
+pwsx3943 power 0.524 0.5 -> 0.724 Inexact Rounded
+pwsx3944 power 0.0524 0.5 -> 0.229 Inexact Rounded
+pwsx3945 power 0.525 0.5 -> 0.725 Inexact Rounded
+pwsx3946 power 0.0525 0.5 -> 0.229 Inexact Rounded
+pwsx3947 power 0.526 0.5 -> 0.725 Inexact Rounded
+pwsx3948 power 0.0526 0.5 -> 0.229 Inexact Rounded
+pwsx3949 power 0.527 0.5 -> 0.726 Inexact Rounded
+pwsx3950 power 0.0527 0.5 -> 0.230 Inexact Rounded
+pwsx3951 power 0.528 0.5 -> 0.727 Inexact Rounded
+pwsx3952 power 0.0528 0.5 -> 0.230 Inexact Rounded
+pwsx3953 power 0.529 0.5 -> 0.727 Inexact Rounded
+pwsx3954 power 0.0529 0.5 -> 0.230 Inexact Rounded
+pwsx3955 power 0.531 0.5 -> 0.729 Inexact Rounded
+pwsx3956 power 0.0531 0.5 -> 0.230 Inexact Rounded
+pwsx3957 power 0.532 0.5 -> 0.729 Inexact Rounded
+pwsx3958 power 0.0532 0.5 -> 0.231 Inexact Rounded
+pwsx3959 power 0.533 0.5 -> 0.730 Inexact Rounded
+pwsx3960 power 0.0533 0.5 -> 0.231 Inexact Rounded
+pwsx3961 power 0.534 0.5 -> 0.731 Inexact Rounded
+pwsx3962 power 0.0534 0.5 -> 0.231 Inexact Rounded
+pwsx3963 power 0.535 0.5 -> 0.731 Inexact Rounded
+pwsx3964 power 0.0535 0.5 -> 0.231 Inexact Rounded
+pwsx3965 power 0.536 0.5 -> 0.732 Inexact Rounded
+pwsx3966 power 0.0536 0.5 -> 0.232 Inexact Rounded
+pwsx3967 power 0.537 0.5 -> 0.733 Inexact Rounded
+pwsx3968 power 0.0537 0.5 -> 0.232 Inexact Rounded
+pwsx3969 power 0.538 0.5 -> 0.733 Inexact Rounded
+pwsx3970 power 0.0538 0.5 -> 0.232 Inexact Rounded
+pwsx3971 power 0.539 0.5 -> 0.734 Inexact Rounded
+pwsx3972 power 0.0539 0.5 -> 0.232 Inexact Rounded
+pwsx3973 power 0.541 0.5 -> 0.736 Inexact Rounded
+pwsx3974 power 0.0541 0.5 -> 0.233 Inexact Rounded
+pwsx3975 power 0.542 0.5 -> 0.736 Inexact Rounded
+pwsx3976 power 0.0542 0.5 -> 0.233 Inexact Rounded
+pwsx3977 power 0.543 0.5 -> 0.737 Inexact Rounded
+pwsx3978 power 0.0543 0.5 -> 0.233 Inexact Rounded
+pwsx3979 power 0.544 0.5 -> 0.738 Inexact Rounded
+pwsx3980 power 0.0544 0.5 -> 0.233 Inexact Rounded
+pwsx3981 power 0.545 0.5 -> 0.738 Inexact Rounded
+pwsx3982 power 0.0545 0.5 -> 0.233 Inexact Rounded
+pwsx3983 power 0.546 0.5 -> 0.739 Inexact Rounded
+pwsx3984 power 0.0546 0.5 -> 0.234 Inexact Rounded
+pwsx3985 power 0.547 0.5 -> 0.740 Inexact Rounded
+pwsx3986 power 0.0547 0.5 -> 0.234 Inexact Rounded
+pwsx3987 power 0.548 0.5 -> 0.740 Inexact Rounded
+pwsx3988 power 0.0548 0.5 -> 0.234 Inexact Rounded
+pwsx3989 power 0.549 0.5 -> 0.741 Inexact Rounded
+pwsx3990 power 0.0549 0.5 -> 0.234 Inexact Rounded
+pwsx3991 power 0.551 0.5 -> 0.742 Inexact Rounded
+pwsx3992 power 0.0551 0.5 -> 0.235 Inexact Rounded
+pwsx3993 power 0.552 0.5 -> 0.743 Inexact Rounded
+pwsx3994 power 0.0552 0.5 -> 0.235 Inexact Rounded
+pwsx3995 power 0.553 0.5 -> 0.744 Inexact Rounded
+pwsx3996 power 0.0553 0.5 -> 0.235 Inexact Rounded
+pwsx3997 power 0.554 0.5 -> 0.744 Inexact Rounded
+pwsx3998 power 0.0554 0.5 -> 0.235 Inexact Rounded
+pwsx3999 power 0.555 0.5 -> 0.745 Inexact Rounded
+pwsx4000 power 0.0555 0.5 -> 0.236 Inexact Rounded
+pwsx4001 power 0.556 0.5 -> 0.746 Inexact Rounded
+pwsx4002 power 0.0556 0.5 -> 0.236 Inexact Rounded
+pwsx4003 power 0.557 0.5 -> 0.746 Inexact Rounded
+pwsx4004 power 0.0557 0.5 -> 0.236 Inexact Rounded
+pwsx4005 power 0.558 0.5 -> 0.747 Inexact Rounded
+pwsx4006 power 0.0558 0.5 -> 0.236 Inexact Rounded
+pwsx4007 power 0.559 0.5 -> 0.748 Inexact Rounded
+pwsx4008 power 0.0559 0.5 -> 0.236 Inexact Rounded
+pwsx4009 power 0.561 0.5 -> 0.749 Inexact Rounded
+pwsx4010 power 0.0561 0.5 -> 0.237 Inexact Rounded
+pwsx4011 power 0.562 0.5 -> 0.750 Inexact Rounded
+pwsx4012 power 0.0562 0.5 -> 0.237 Inexact Rounded
+pwsx4013 power 0.563 0.5 -> 0.750 Inexact Rounded
+pwsx4014 power 0.0563 0.5 -> 0.237 Inexact Rounded
+pwsx4015 power 0.564 0.5 -> 0.751 Inexact Rounded
+pwsx4016 power 0.0564 0.5 -> 0.237 Inexact Rounded
+pwsx4017 power 0.565 0.5 -> 0.752 Inexact Rounded
+pwsx4018 power 0.0565 0.5 -> 0.238 Inexact Rounded
+pwsx4019 power 0.566 0.5 -> 0.752 Inexact Rounded
+pwsx4020 power 0.0566 0.5 -> 0.238 Inexact Rounded
+pwsx4021 power 0.567 0.5 -> 0.753 Inexact Rounded
+pwsx4022 power 0.0567 0.5 -> 0.238 Inexact Rounded
+pwsx4023 power 0.568 0.5 -> 0.754 Inexact Rounded
+pwsx4024 power 0.0568 0.5 -> 0.238 Inexact Rounded
+pwsx4025 power 0.569 0.5 -> 0.754 Inexact Rounded
+pwsx4026 power 0.0569 0.5 -> 0.239 Inexact Rounded
+pwsx4027 power 0.571 0.5 -> 0.756 Inexact Rounded
+pwsx4028 power 0.0571 0.5 -> 0.239 Inexact Rounded
+pwsx4029 power 0.572 0.5 -> 0.756 Inexact Rounded
+pwsx4030 power 0.0572 0.5 -> 0.239 Inexact Rounded
+pwsx4031 power 0.573 0.5 -> 0.757 Inexact Rounded
+pwsx4032 power 0.0573 0.5 -> 0.239 Inexact Rounded
+pwsx4033 power 0.574 0.5 -> 0.758 Inexact Rounded
+pwsx4034 power 0.0574 0.5 -> 0.240 Inexact Rounded
+pwsx4035 power 0.575 0.5 -> 0.758 Inexact Rounded
+pwsx4036 power 0.0575 0.5 -> 0.240 Inexact Rounded
+pwsx4037 power 0.576 0.5 -> 0.759 Inexact Rounded
+pwsx4038 power 0.0576 0.5 -> 0.240 Inexact Rounded
+pwsx4039 power 0.577 0.5 -> 0.760 Inexact Rounded
+pwsx4040 power 0.0577 0.5 -> 0.240 Inexact Rounded
+pwsx4041 power 0.578 0.5 -> 0.760 Inexact Rounded
+pwsx4042 power 0.0578 0.5 -> 0.240 Inexact Rounded
+pwsx4043 power 0.579 0.5 -> 0.761 Inexact Rounded
+pwsx4044 power 0.0579 0.5 -> 0.241 Inexact Rounded
+pwsx4045 power 0.581 0.5 -> 0.762 Inexact Rounded
+pwsx4046 power 0.0581 0.5 -> 0.241 Inexact Rounded
+pwsx4047 power 0.582 0.5 -> 0.763 Inexact Rounded
+pwsx4048 power 0.0582 0.5 -> 0.241 Inexact Rounded
+pwsx4049 power 0.583 0.5 -> 0.764 Inexact Rounded
+pwsx4050 power 0.0583 0.5 -> 0.241 Inexact Rounded
+pwsx4051 power 0.584 0.5 -> 0.764 Inexact Rounded
+pwsx4052 power 0.0584 0.5 -> 0.242 Inexact Rounded
+pwsx4053 power 0.585 0.5 -> 0.765 Inexact Rounded
+pwsx4054 power 0.0585 0.5 -> 0.242 Inexact Rounded
+pwsx4055 power 0.586 0.5 -> 0.766 Inexact Rounded
+pwsx4056 power 0.0586 0.5 -> 0.242 Inexact Rounded
+pwsx4057 power 0.587 0.5 -> 0.766 Inexact Rounded
+pwsx4058 power 0.0587 0.5 -> 0.242 Inexact Rounded
+pwsx4059 power 0.588 0.5 -> 0.767 Inexact Rounded
+pwsx4060 power 0.0588 0.5 -> 0.242 Inexact Rounded
+pwsx4061 power 0.589 0.5 -> 0.767 Inexact Rounded
+pwsx4062 power 0.0589 0.5 -> 0.243 Inexact Rounded
+pwsx4063 power 0.591 0.5 -> 0.769 Inexact Rounded
+pwsx4064 power 0.0591 0.5 -> 0.243 Inexact Rounded
+pwsx4065 power 0.592 0.5 -> 0.769 Inexact Rounded
+pwsx4066 power 0.0592 0.5 -> 0.243 Inexact Rounded
+pwsx4067 power 0.593 0.5 -> 0.770 Inexact Rounded
+pwsx4068 power 0.0593 0.5 -> 0.244 Inexact Rounded
+pwsx4069 power 0.594 0.5 -> 0.771 Inexact Rounded
+pwsx4070 power 0.0594 0.5 -> 0.244 Inexact Rounded
+pwsx4071 power 0.595 0.5 -> 0.771 Inexact Rounded
+pwsx4072 power 0.0595 0.5 -> 0.244 Inexact Rounded
+pwsx4073 power 0.596 0.5 -> 0.772 Inexact Rounded
+pwsx4074 power 0.0596 0.5 -> 0.244 Inexact Rounded
+pwsx4075 power 0.597 0.5 -> 0.773 Inexact Rounded
+pwsx4076 power 0.0597 0.5 -> 0.244 Inexact Rounded
+pwsx4077 power 0.598 0.5 -> 0.773 Inexact Rounded
+pwsx4078 power 0.0598 0.5 -> 0.245 Inexact Rounded
+pwsx4079 power 0.599 0.5 -> 0.774 Inexact Rounded
+pwsx4080 power 0.0599 0.5 -> 0.245 Inexact Rounded
+pwsx4081 power 0.601 0.5 -> 0.775 Inexact Rounded
+pwsx4082 power 0.0601 0.5 -> 0.245 Inexact Rounded
+pwsx4083 power 0.602 0.5 -> 0.776 Inexact Rounded
+pwsx4084 power 0.0602 0.5 -> 0.245 Inexact Rounded
+pwsx4085 power 0.603 0.5 -> 0.777 Inexact Rounded
+pwsx4086 power 0.0603 0.5 -> 0.246 Inexact Rounded
+pwsx4087 power 0.604 0.5 -> 0.777 Inexact Rounded
+pwsx4088 power 0.0604 0.5 -> 0.246 Inexact Rounded
+pwsx4089 power 0.605 0.5 -> 0.778 Inexact Rounded
+pwsx4090 power 0.0605 0.5 -> 0.246 Inexact Rounded
+pwsx4091 power 0.606 0.5 -> 0.778 Inexact Rounded
+pwsx4092 power 0.0606 0.5 -> 0.246 Inexact Rounded
+pwsx4093 power 0.607 0.5 -> 0.779 Inexact Rounded
+pwsx4094 power 0.0607 0.5 -> 0.246 Inexact Rounded
+pwsx4095 power 0.608 0.5 -> 0.780 Inexact Rounded
+pwsx4096 power 0.0608 0.5 -> 0.247 Inexact Rounded
+pwsx4097 power 0.609 0.5 -> 0.780 Inexact Rounded
+pwsx4098 power 0.0609 0.5 -> 0.247 Inexact Rounded
+pwsx4099 power 0.611 0.5 -> 0.782 Inexact Rounded
+pwsx4100 power 0.0611 0.5 -> 0.247 Inexact Rounded
+pwsx4101 power 0.612 0.5 -> 0.782 Inexact Rounded
+pwsx4102 power 0.0612 0.5 -> 0.247 Inexact Rounded
+pwsx4103 power 0.613 0.5 -> 0.783 Inexact Rounded
+pwsx4104 power 0.0613 0.5 -> 0.248 Inexact Rounded
+pwsx4105 power 0.614 0.5 -> 0.784 Inexact Rounded
+pwsx4106 power 0.0614 0.5 -> 0.248 Inexact Rounded
+pwsx4107 power 0.615 0.5 -> 0.784 Inexact Rounded
+pwsx4108 power 0.0615 0.5 -> 0.248 Inexact Rounded
+pwsx4109 power 0.616 0.5 -> 0.785 Inexact Rounded
+pwsx4110 power 0.0616 0.5 -> 0.248 Inexact Rounded
+pwsx4111 power 0.617 0.5 -> 0.785 Inexact Rounded
+pwsx4112 power 0.0617 0.5 -> 0.248 Inexact Rounded
+pwsx4113 power 0.618 0.5 -> 0.786 Inexact Rounded
+pwsx4114 power 0.0618 0.5 -> 0.249 Inexact Rounded
+pwsx4115 power 0.619 0.5 -> 0.787 Inexact Rounded
+pwsx4116 power 0.0619 0.5 -> 0.249 Inexact Rounded
+pwsx4117 power 0.621 0.5 -> 0.788 Inexact Rounded
+pwsx4118 power 0.0621 0.5 -> 0.249 Inexact Rounded
+pwsx4119 power 0.622 0.5 -> 0.789 Inexact Rounded
+pwsx4120 power 0.0622 0.5 -> 0.249 Inexact Rounded
+pwsx4121 power 0.623 0.5 -> 0.789 Inexact Rounded
+pwsx4122 power 0.0623 0.5 -> 0.250 Inexact Rounded
+pwsx4123 power 0.624 0.5 -> 0.790 Inexact Rounded
+pwsx4124 power 0.0624 0.5 -> 0.250 Inexact Rounded
+pwsx4125 power 0.625 0.5 -> 0.791 Inexact Rounded
+pwsx4126 power 0.0625 0.5 -> 0.250 Inexact Rounded
+pwsx4127 power 0.626 0.5 -> 0.791 Inexact Rounded
+pwsx4128 power 0.0626 0.5 -> 0.250 Inexact Rounded
+pwsx4129 power 0.627 0.5 -> 0.792 Inexact Rounded
+pwsx4130 power 0.0627 0.5 -> 0.250 Inexact Rounded
+pwsx4131 power 0.628 0.5 -> 0.792 Inexact Rounded
+pwsx4132 power 0.0628 0.5 -> 0.251 Inexact Rounded
+pwsx4133 power 0.629 0.5 -> 0.793 Inexact Rounded
+pwsx4134 power 0.0629 0.5 -> 0.251 Inexact Rounded
+pwsx4135 power 0.631 0.5 -> 0.794 Inexact Rounded
+pwsx4136 power 0.0631 0.5 -> 0.251 Inexact Rounded
+pwsx4137 power 0.632 0.5 -> 0.795 Inexact Rounded
+pwsx4138 power 0.0632 0.5 -> 0.251 Inexact Rounded
+pwsx4139 power 0.633 0.5 -> 0.796 Inexact Rounded
+pwsx4140 power 0.0633 0.5 -> 0.252 Inexact Rounded
+pwsx4141 power 0.634 0.5 -> 0.796 Inexact Rounded
+pwsx4142 power 0.0634 0.5 -> 0.252 Inexact Rounded
+pwsx4143 power 0.635 0.5 -> 0.797 Inexact Rounded
+pwsx4144 power 0.0635 0.5 -> 0.252 Inexact Rounded
+pwsx4145 power 0.636 0.5 -> 0.797 Inexact Rounded
+pwsx4146 power 0.0636 0.5 -> 0.252 Inexact Rounded
+pwsx4147 power 0.637 0.5 -> 0.798 Inexact Rounded
+pwsx4148 power 0.0637 0.5 -> 0.252 Inexact Rounded
+pwsx4149 power 0.638 0.5 -> 0.799 Inexact Rounded
+pwsx4150 power 0.0638 0.5 -> 0.253 Inexact Rounded
+pwsx4151 power 0.639 0.5 -> 0.799 Inexact Rounded
+pwsx4152 power 0.0639 0.5 -> 0.253 Inexact Rounded
+pwsx4153 power 0.641 0.5 -> 0.801 Inexact Rounded
+pwsx4154 power 0.0641 0.5 -> 0.253 Inexact Rounded
+pwsx4155 power 0.642 0.5 -> 0.801 Inexact Rounded
+pwsx4156 power 0.0642 0.5 -> 0.253 Inexact Rounded
+pwsx4157 power 0.643 0.5 -> 0.802 Inexact Rounded
+pwsx4158 power 0.0643 0.5 -> 0.254 Inexact Rounded
+pwsx4159 power 0.644 0.5 -> 0.802 Inexact Rounded
+pwsx4160 power 0.0644 0.5 -> 0.254 Inexact Rounded
+pwsx4161 power 0.645 0.5 -> 0.803 Inexact Rounded
+pwsx4162 power 0.0645 0.5 -> 0.254 Inexact Rounded
+pwsx4163 power 0.646 0.5 -> 0.804 Inexact Rounded
+pwsx4164 power 0.0646 0.5 -> 0.254 Inexact Rounded
+pwsx4165 power 0.647 0.5 -> 0.804 Inexact Rounded
+pwsx4166 power 0.0647 0.5 -> 0.254 Inexact Rounded
+pwsx4167 power 0.648 0.5 -> 0.805 Inexact Rounded
+pwsx4168 power 0.0648 0.5 -> 0.255 Inexact Rounded
+pwsx4169 power 0.649 0.5 -> 0.806 Inexact Rounded
+pwsx4170 power 0.0649 0.5 -> 0.255 Inexact Rounded
+pwsx4171 power 0.651 0.5 -> 0.807 Inexact Rounded
+pwsx4172 power 0.0651 0.5 -> 0.255 Inexact Rounded
+pwsx4173 power 0.652 0.5 -> 0.807 Inexact Rounded
+pwsx4174 power 0.0652 0.5 -> 0.255 Inexact Rounded
+pwsx4175 power 0.653 0.5 -> 0.808 Inexact Rounded
+pwsx4176 power 0.0653 0.5 -> 0.256 Inexact Rounded
+pwsx4177 power 0.654 0.5 -> 0.809 Inexact Rounded
+pwsx4178 power 0.0654 0.5 -> 0.256 Inexact Rounded
+pwsx4179 power 0.655 0.5 -> 0.809 Inexact Rounded
+pwsx4180 power 0.0655 0.5 -> 0.256 Inexact Rounded
+pwsx4181 power 0.656 0.5 -> 0.810 Inexact Rounded
+pwsx4182 power 0.0656 0.5 -> 0.256 Inexact Rounded
+pwsx4183 power 0.657 0.5 -> 0.811 Inexact Rounded
+pwsx4184 power 0.0657 0.5 -> 0.256 Inexact Rounded
+pwsx4185 power 0.658 0.5 -> 0.811 Inexact Rounded
+pwsx4186 power 0.0658 0.5 -> 0.257 Inexact Rounded
+pwsx4187 power 0.659 0.5 -> 0.812 Inexact Rounded
+pwsx4188 power 0.0659 0.5 -> 0.257 Inexact Rounded
+pwsx4189 power 0.661 0.5 -> 0.813 Inexact Rounded
+pwsx4190 power 0.0661 0.5 -> 0.257 Inexact Rounded
+pwsx4191 power 0.662 0.5 -> 0.814 Inexact Rounded
+pwsx4192 power 0.0662 0.5 -> 0.257 Inexact Rounded
+pwsx4193 power 0.663 0.5 -> 0.814 Inexact Rounded
+pwsx4194 power 0.0663 0.5 -> 0.257 Inexact Rounded
+pwsx4195 power 0.664 0.5 -> 0.815 Inexact Rounded
+pwsx4196 power 0.0664 0.5 -> 0.258 Inexact Rounded
+pwsx4197 power 0.665 0.5 -> 0.815 Inexact Rounded
+pwsx4198 power 0.0665 0.5 -> 0.258 Inexact Rounded
+pwsx4199 power 0.666 0.5 -> 0.816 Inexact Rounded
+pwsx4200 power 0.0666 0.5 -> 0.258 Inexact Rounded
+pwsx4201 power 0.667 0.5 -> 0.817 Inexact Rounded
+pwsx4202 power 0.0667 0.5 -> 0.258 Inexact Rounded
+pwsx4203 power 0.668 0.5 -> 0.817 Inexact Rounded
+pwsx4204 power 0.0668 0.5 -> 0.258 Inexact Rounded
+pwsx4205 power 0.669 0.5 -> 0.818 Inexact Rounded
+pwsx4206 power 0.0669 0.5 -> 0.259 Inexact Rounded
+pwsx4207 power 0.671 0.5 -> 0.819 Inexact Rounded
+pwsx4208 power 0.0671 0.5 -> 0.259 Inexact Rounded
+pwsx4209 power 0.672 0.5 -> 0.820 Inexact Rounded
+pwsx4210 power 0.0672 0.5 -> 0.259 Inexact Rounded
+pwsx4211 power 0.673 0.5 -> 0.820 Inexact Rounded
+pwsx4212 power 0.0673 0.5 -> 0.259 Inexact Rounded
+pwsx4213 power 0.674 0.5 -> 0.821 Inexact Rounded
+pwsx4214 power 0.0674 0.5 -> 0.260 Inexact Rounded
+pwsx4215 power 0.675 0.5 -> 0.822 Inexact Rounded
+pwsx4216 power 0.0675 0.5 -> 0.260 Inexact Rounded
+pwsx4217 power 0.676 0.5 -> 0.822 Inexact Rounded
+pwsx4218 power 0.0676 0.5 -> 0.260 Inexact Rounded
+pwsx4219 power 0.677 0.5 -> 0.823 Inexact Rounded
+pwsx4220 power 0.0677 0.5 -> 0.260 Inexact Rounded
+pwsx4221 power 0.678 0.5 -> 0.823 Inexact Rounded
+pwsx4222 power 0.0678 0.5 -> 0.260 Inexact Rounded
+pwsx4223 power 0.679 0.5 -> 0.824 Inexact Rounded
+pwsx4224 power 0.0679 0.5 -> 0.261 Inexact Rounded
+pwsx4225 power 0.681 0.5 -> 0.825 Inexact Rounded
+pwsx4226 power 0.0681 0.5 -> 0.261 Inexact Rounded
+pwsx4227 power 0.682 0.5 -> 0.826 Inexact Rounded
+pwsx4228 power 0.0682 0.5 -> 0.261 Inexact Rounded
+pwsx4229 power 0.683 0.5 -> 0.826 Inexact Rounded
+pwsx4230 power 0.0683 0.5 -> 0.261 Inexact Rounded
+pwsx4231 power 0.684 0.5 -> 0.827 Inexact Rounded
+pwsx4232 power 0.0684 0.5 -> 0.262 Inexact Rounded
+pwsx4233 power 0.685 0.5 -> 0.828 Inexact Rounded
+pwsx4234 power 0.0685 0.5 -> 0.262 Inexact Rounded
+pwsx4235 power 0.686 0.5 -> 0.828 Inexact Rounded
+pwsx4236 power 0.0686 0.5 -> 0.262 Inexact Rounded
+pwsx4237 power 0.687 0.5 -> 0.829 Inexact Rounded
+pwsx4238 power 0.0687 0.5 -> 0.262 Inexact Rounded
+pwsx4239 power 0.688 0.5 -> 0.829 Inexact Rounded
+pwsx4240 power 0.0688 0.5 -> 0.262 Inexact Rounded
+pwsx4241 power 0.689 0.5 -> 0.830 Inexact Rounded
+pwsx4242 power 0.0689 0.5 -> 0.262 Inexact Rounded
+pwsx4243 power 0.691 0.5 -> 0.831 Inexact Rounded
+pwsx4244 power 0.0691 0.5 -> 0.263 Inexact Rounded
+pwsx4245 power 0.692 0.5 -> 0.832 Inexact Rounded
+pwsx4246 power 0.0692 0.5 -> 0.263 Inexact Rounded
+pwsx4247 power 0.693 0.5 -> 0.832 Inexact Rounded
+pwsx4248 power 0.0693 0.5 -> 0.263 Inexact Rounded
+pwsx4249 power 0.694 0.5 -> 0.833 Inexact Rounded
+pwsx4250 power 0.0694 0.5 -> 0.263 Inexact Rounded
+pwsx4251 power 0.695 0.5 -> 0.834 Inexact Rounded
+pwsx4252 power 0.0695 0.5 -> 0.264 Inexact Rounded
+pwsx4253 power 0.696 0.5 -> 0.834 Inexact Rounded
+pwsx4254 power 0.0696 0.5 -> 0.264 Inexact Rounded
+pwsx4255 power 0.697 0.5 -> 0.835 Inexact Rounded
+pwsx4256 power 0.0697 0.5 -> 0.264 Inexact Rounded
+pwsx4257 power 0.698 0.5 -> 0.835 Inexact Rounded
+pwsx4258 power 0.0698 0.5 -> 0.264 Inexact Rounded
+pwsx4259 power 0.699 0.5 -> 0.836 Inexact Rounded
+pwsx4260 power 0.0699 0.5 -> 0.264 Inexact Rounded
+pwsx4261 power 0.701 0.5 -> 0.837 Inexact Rounded
+pwsx4262 power 0.0701 0.5 -> 0.265 Inexact Rounded
+pwsx4263 power 0.702 0.5 -> 0.838 Inexact Rounded
+pwsx4264 power 0.0702 0.5 -> 0.265 Inexact Rounded
+pwsx4265 power 0.703 0.5 -> 0.838 Inexact Rounded
+pwsx4266 power 0.0703 0.5 -> 0.265 Inexact Rounded
+pwsx4267 power 0.704 0.5 -> 0.839 Inexact Rounded
+pwsx4268 power 0.0704 0.5 -> 0.265 Inexact Rounded
+pwsx4269 power 0.705 0.5 -> 0.840 Inexact Rounded
+pwsx4270 power 0.0705 0.5 -> 0.266 Inexact Rounded
+pwsx4271 power 0.706 0.5 -> 0.840 Inexact Rounded
+pwsx4272 power 0.0706 0.5 -> 0.266 Inexact Rounded
+pwsx4273 power 0.707 0.5 -> 0.841 Inexact Rounded
+pwsx4274 power 0.0707 0.5 -> 0.266 Inexact Rounded
+pwsx4275 power 0.708 0.5 -> 0.841 Inexact Rounded
+pwsx4276 power 0.0708 0.5 -> 0.266 Inexact Rounded
+pwsx4277 power 0.709 0.5 -> 0.842 Inexact Rounded
+pwsx4278 power 0.0709 0.5 -> 0.266 Inexact Rounded
+pwsx4279 power 0.711 0.5 -> 0.843 Inexact Rounded
+pwsx4280 power 0.0711 0.5 -> 0.267 Inexact Rounded
+pwsx4281 power 0.712 0.5 -> 0.844 Inexact Rounded
+pwsx4282 power 0.0712 0.5 -> 0.267 Inexact Rounded
+pwsx4283 power 0.713 0.5 -> 0.844 Inexact Rounded
+pwsx4284 power 0.0713 0.5 -> 0.267 Inexact Rounded
+pwsx4285 power 0.714 0.5 -> 0.845 Inexact Rounded
+pwsx4286 power 0.0714 0.5 -> 0.267 Inexact Rounded
+pwsx4287 power 0.715 0.5 -> 0.846 Inexact Rounded
+pwsx4288 power 0.0715 0.5 -> 0.267 Inexact Rounded
+pwsx4289 power 0.716 0.5 -> 0.846 Inexact Rounded
+pwsx4290 power 0.0716 0.5 -> 0.268 Inexact Rounded
+pwsx4291 power 0.717 0.5 -> 0.847 Inexact Rounded
+pwsx4292 power 0.0717 0.5 -> 0.268 Inexact Rounded
+pwsx4293 power 0.718 0.5 -> 0.847 Inexact Rounded
+pwsx4294 power 0.0718 0.5 -> 0.268 Inexact Rounded
+pwsx4295 power 0.719 0.5 -> 0.848 Inexact Rounded
+pwsx4296 power 0.0719 0.5 -> 0.268 Inexact Rounded
+pwsx4297 power 0.721 0.5 -> 0.849 Inexact Rounded
+pwsx4298 power 0.0721 0.5 -> 0.269 Inexact Rounded
+pwsx4299 power 0.722 0.5 -> 0.850 Inexact Rounded
+pwsx4300 power 0.0722 0.5 -> 0.269 Inexact Rounded
+pwsx4301 power 0.723 0.5 -> 0.850 Inexact Rounded
+pwsx4302 power 0.0723 0.5 -> 0.269 Inexact Rounded
+pwsx4303 power 0.724 0.5 -> 0.851 Inexact Rounded
+pwsx4304 power 0.0724 0.5 -> 0.269 Inexact Rounded
+pwsx4305 power 0.725 0.5 -> 0.851 Inexact Rounded
+pwsx4306 power 0.0725 0.5 -> 0.269 Inexact Rounded
+pwsx4307 power 0.726 0.5 -> 0.852 Inexact Rounded
+pwsx4308 power 0.0726 0.5 -> 0.269 Inexact Rounded
+pwsx4309 power 0.727 0.5 -> 0.853 Inexact Rounded
+pwsx4310 power 0.0727 0.5 -> 0.270 Inexact Rounded
+pwsx4311 power 0.728 0.5 -> 0.853 Inexact Rounded
+pwsx4312 power 0.0728 0.5 -> 0.270 Inexact Rounded
+pwsx4313 power 0.729 0.5 -> 0.854 Inexact Rounded
+pwsx4314 power 0.0729 0.5 -> 0.270 Inexact Rounded
+pwsx4315 power 0.731 0.5 -> 0.855 Inexact Rounded
+pwsx4316 power 0.0731 0.5 -> 0.270 Inexact Rounded
+pwsx4317 power 0.732 0.5 -> 0.856 Inexact Rounded
+pwsx4318 power 0.0732 0.5 -> 0.271 Inexact Rounded
+pwsx4319 power 0.733 0.5 -> 0.856 Inexact Rounded
+pwsx4320 power 0.0733 0.5 -> 0.271 Inexact Rounded
+pwsx4321 power 0.734 0.5 -> 0.857 Inexact Rounded
+pwsx4322 power 0.0734 0.5 -> 0.271 Inexact Rounded
+pwsx4323 power 0.735 0.5 -> 0.857 Inexact Rounded
+pwsx4324 power 0.0735 0.5 -> 0.271 Inexact Rounded
+pwsx4325 power 0.736 0.5 -> 0.858 Inexact Rounded
+pwsx4326 power 0.0736 0.5 -> 0.271 Inexact Rounded
+pwsx4327 power 0.737 0.5 -> 0.858 Inexact Rounded
+pwsx4328 power 0.0737 0.5 -> 0.271 Inexact Rounded
+pwsx4329 power 0.738 0.5 -> 0.859 Inexact Rounded
+pwsx4330 power 0.0738 0.5 -> 0.272 Inexact Rounded
+pwsx4331 power 0.739 0.5 -> 0.860 Inexact Rounded
+pwsx4332 power 0.0739 0.5 -> 0.272 Inexact Rounded
+pwsx4333 power 0.741 0.5 -> 0.861 Inexact Rounded
+pwsx4334 power 0.0741 0.5 -> 0.272 Inexact Rounded
+pwsx4335 power 0.742 0.5 -> 0.861 Inexact Rounded
+pwsx4336 power 0.0742 0.5 -> 0.272 Inexact Rounded
+pwsx4337 power 0.743 0.5 -> 0.862 Inexact Rounded
+pwsx4338 power 0.0743 0.5 -> 0.273 Inexact Rounded
+pwsx4339 power 0.744 0.5 -> 0.863 Inexact Rounded
+pwsx4340 power 0.0744 0.5 -> 0.273 Inexact Rounded
+pwsx4341 power 0.745 0.5 -> 0.863 Inexact Rounded
+pwsx4342 power 0.0745 0.5 -> 0.273 Inexact Rounded
+pwsx4343 power 0.746 0.5 -> 0.864 Inexact Rounded
+pwsx4344 power 0.0746 0.5 -> 0.273 Inexact Rounded
+pwsx4345 power 0.747 0.5 -> 0.864 Inexact Rounded
+pwsx4346 power 0.0747 0.5 -> 0.273 Inexact Rounded
+pwsx4347 power 0.748 0.5 -> 0.865 Inexact Rounded
+pwsx4348 power 0.0748 0.5 -> 0.273 Inexact Rounded
+pwsx4349 power 0.749 0.5 -> 0.865 Inexact Rounded
+pwsx4350 power 0.0749 0.5 -> 0.274 Inexact Rounded
+pwsx4351 power 0.751 0.5 -> 0.867 Inexact Rounded
+pwsx4352 power 0.0751 0.5 -> 0.274 Inexact Rounded
+pwsx4353 power 0.752 0.5 -> 0.867 Inexact Rounded
+pwsx4354 power 0.0752 0.5 -> 0.274 Inexact Rounded
+pwsx4355 power 0.753 0.5 -> 0.868 Inexact Rounded
+pwsx4356 power 0.0753 0.5 -> 0.274 Inexact Rounded
+pwsx4357 power 0.754 0.5 -> 0.868 Inexact Rounded
+pwsx4358 power 0.0754 0.5 -> 0.275 Inexact Rounded
+pwsx4359 power 0.755 0.5 -> 0.869 Inexact Rounded
+pwsx4360 power 0.0755 0.5 -> 0.275 Inexact Rounded
+pwsx4361 power 0.756 0.5 -> 0.869 Inexact Rounded
+pwsx4362 power 0.0756 0.5 -> 0.275 Inexact Rounded
+pwsx4363 power 0.757 0.5 -> 0.870 Inexact Rounded
+pwsx4364 power 0.0757 0.5 -> 0.275 Inexact Rounded
+pwsx4365 power 0.758 0.5 -> 0.871 Inexact Rounded
+pwsx4366 power 0.0758 0.5 -> 0.275 Inexact Rounded
+pwsx4367 power 0.759 0.5 -> 0.871 Inexact Rounded
+pwsx4368 power 0.0759 0.5 -> 0.275 Inexact Rounded
+pwsx4369 power 0.761 0.5 -> 0.872 Inexact Rounded
+pwsx4370 power 0.0761 0.5 -> 0.276 Inexact Rounded
+pwsx4371 power 0.762 0.5 -> 0.873 Inexact Rounded
+pwsx4372 power 0.0762 0.5 -> 0.276 Inexact Rounded
+pwsx4373 power 0.763 0.5 -> 0.873 Inexact Rounded
+pwsx4374 power 0.0763 0.5 -> 0.276 Inexact Rounded
+pwsx4375 power 0.764 0.5 -> 0.874 Inexact Rounded
+pwsx4376 power 0.0764 0.5 -> 0.276 Inexact Rounded
+pwsx4377 power 0.765 0.5 -> 0.875 Inexact Rounded
+pwsx4378 power 0.0765 0.5 -> 0.277 Inexact Rounded
+pwsx4379 power 0.766 0.5 -> 0.875 Inexact Rounded
+pwsx4380 power 0.0766 0.5 -> 0.277 Inexact Rounded
+pwsx4381 power 0.767 0.5 -> 0.876 Inexact Rounded
+pwsx4382 power 0.0767 0.5 -> 0.277 Inexact Rounded
+pwsx4383 power 0.768 0.5 -> 0.876 Inexact Rounded
+pwsx4384 power 0.0768 0.5 -> 0.277 Inexact Rounded
+pwsx4385 power 0.769 0.5 -> 0.877 Inexact Rounded
+pwsx4386 power 0.0769 0.5 -> 0.277 Inexact Rounded
+pwsx4387 power 0.771 0.5 -> 0.878 Inexact Rounded
+pwsx4388 power 0.0771 0.5 -> 0.278 Inexact Rounded
+pwsx4389 power 0.772 0.5 -> 0.879 Inexact Rounded
+pwsx4390 power 0.0772 0.5 -> 0.278 Inexact Rounded
+pwsx4391 power 0.773 0.5 -> 0.879 Inexact Rounded
+pwsx4392 power 0.0773 0.5 -> 0.278 Inexact Rounded
+pwsx4393 power 0.774 0.5 -> 0.880 Inexact Rounded
+pwsx4394 power 0.0774 0.5 -> 0.278 Inexact Rounded
+pwsx4395 power 0.775 0.5 -> 0.880 Inexact Rounded
+pwsx4396 power 0.0775 0.5 -> 0.278 Inexact Rounded
+pwsx4397 power 0.776 0.5 -> 0.881 Inexact Rounded
+pwsx4398 power 0.0776 0.5 -> 0.279 Inexact Rounded
+pwsx4399 power 0.777 0.5 -> 0.881 Inexact Rounded
+pwsx4400 power 0.0777 0.5 -> 0.279 Inexact Rounded
+pwsx4401 power 0.778 0.5 -> 0.882 Inexact Rounded
+pwsx4402 power 0.0778 0.5 -> 0.279 Inexact Rounded
+pwsx4403 power 0.779 0.5 -> 0.883 Inexact Rounded
+pwsx4404 power 0.0779 0.5 -> 0.279 Inexact Rounded
+pwsx4405 power 0.781 0.5 -> 0.884 Inexact Rounded
+pwsx4406 power 0.0781 0.5 -> 0.279 Inexact Rounded
+pwsx4407 power 0.782 0.5 -> 0.884 Inexact Rounded
+pwsx4408 power 0.0782 0.5 -> 0.280 Inexact Rounded
+pwsx4409 power 0.783 0.5 -> 0.885 Inexact Rounded
+pwsx4410 power 0.0783 0.5 -> 0.280 Inexact Rounded
+pwsx4411 power 0.784 0.5 -> 0.885 Inexact Rounded
+pwsx4412 power 0.0784 0.5 -> 0.280 Inexact Rounded
+pwsx4413 power 0.785 0.5 -> 0.886 Inexact Rounded
+pwsx4414 power 0.0785 0.5 -> 0.280 Inexact Rounded
+pwsx4415 power 0.786 0.5 -> 0.887 Inexact Rounded
+pwsx4416 power 0.0786 0.5 -> 0.280 Inexact Rounded
+pwsx4417 power 0.787 0.5 -> 0.887 Inexact Rounded
+pwsx4418 power 0.0787 0.5 -> 0.281 Inexact Rounded
+pwsx4419 power 0.788 0.5 -> 0.888 Inexact Rounded
+pwsx4420 power 0.0788 0.5 -> 0.281 Inexact Rounded
+pwsx4421 power 0.789 0.5 -> 0.888 Inexact Rounded
+pwsx4422 power 0.0789 0.5 -> 0.281 Inexact Rounded
+pwsx4423 power 0.791 0.5 -> 0.889 Inexact Rounded
+pwsx4424 power 0.0791 0.5 -> 0.281 Inexact Rounded
+pwsx4425 power 0.792 0.5 -> 0.890 Inexact Rounded
+pwsx4426 power 0.0792 0.5 -> 0.281 Inexact Rounded
+pwsx4427 power 0.793 0.5 -> 0.891 Inexact Rounded
+pwsx4428 power 0.0793 0.5 -> 0.282 Inexact Rounded
+pwsx4429 power 0.794 0.5 -> 0.891 Inexact Rounded
+pwsx4430 power 0.0794 0.5 -> 0.282 Inexact Rounded
+pwsx4431 power 0.795 0.5 -> 0.892 Inexact Rounded
+pwsx4432 power 0.0795 0.5 -> 0.282 Inexact Rounded
+pwsx4433 power 0.796 0.5 -> 0.892 Inexact Rounded
+pwsx4434 power 0.0796 0.5 -> 0.282 Inexact Rounded
+pwsx4435 power 0.797 0.5 -> 0.893 Inexact Rounded
+pwsx4436 power 0.0797 0.5 -> 0.282 Inexact Rounded
+pwsx4437 power 0.798 0.5 -> 0.893 Inexact Rounded
+pwsx4438 power 0.0798 0.5 -> 0.282 Inexact Rounded
+pwsx4439 power 0.799 0.5 -> 0.894 Inexact Rounded
+pwsx4440 power 0.0799 0.5 -> 0.283 Inexact Rounded
+pwsx4441 power 0.801 0.5 -> 0.895 Inexact Rounded
+pwsx4442 power 0.0801 0.5 -> 0.283 Inexact Rounded
+pwsx4443 power 0.802 0.5 -> 0.896 Inexact Rounded
+pwsx4444 power 0.0802 0.5 -> 0.283 Inexact Rounded
+pwsx4445 power 0.803 0.5 -> 0.896 Inexact Rounded
+pwsx4446 power 0.0803 0.5 -> 0.283 Inexact Rounded
+pwsx4447 power 0.804 0.5 -> 0.897 Inexact Rounded
+pwsx4448 power 0.0804 0.5 -> 0.284 Inexact Rounded
+pwsx4449 power 0.805 0.5 -> 0.897 Inexact Rounded
+pwsx4450 power 0.0805 0.5 -> 0.284 Inexact Rounded
+pwsx4451 power 0.806 0.5 -> 0.898 Inexact Rounded
+pwsx4452 power 0.0806 0.5 -> 0.284 Inexact Rounded
+pwsx4453 power 0.807 0.5 -> 0.898 Inexact Rounded
+pwsx4454 power 0.0807 0.5 -> 0.284 Inexact Rounded
+pwsx4455 power 0.808 0.5 -> 0.899 Inexact Rounded
+pwsx4456 power 0.0808 0.5 -> 0.284 Inexact Rounded
+pwsx4457 power 0.809 0.5 -> 0.899 Inexact Rounded
+pwsx4458 power 0.0809 0.5 -> 0.284 Inexact Rounded
+pwsx4459 power 0.811 0.5 -> 0.901 Inexact Rounded
+pwsx4460 power 0.0811 0.5 -> 0.285 Inexact Rounded
+pwsx4461 power 0.812 0.5 -> 0.901 Inexact Rounded
+pwsx4462 power 0.0812 0.5 -> 0.285 Inexact Rounded
+pwsx4463 power 0.813 0.5 -> 0.902 Inexact Rounded
+pwsx4464 power 0.0813 0.5 -> 0.285 Inexact Rounded
+pwsx4465 power 0.814 0.5 -> 0.902 Inexact Rounded
+pwsx4466 power 0.0814 0.5 -> 0.285 Inexact Rounded
+pwsx4467 power 0.815 0.5 -> 0.903 Inexact Rounded
+pwsx4468 power 0.0815 0.5 -> 0.285 Inexact Rounded
+pwsx4469 power 0.816 0.5 -> 0.903 Inexact Rounded
+pwsx4470 power 0.0816 0.5 -> 0.286 Inexact Rounded
+pwsx4471 power 0.817 0.5 -> 0.904 Inexact Rounded
+pwsx4472 power 0.0817 0.5 -> 0.286 Inexact Rounded
+pwsx4473 power 0.818 0.5 -> 0.904 Inexact Rounded
+pwsx4474 power 0.0818 0.5 -> 0.286 Inexact Rounded
+pwsx4475 power 0.819 0.5 -> 0.905 Inexact Rounded
+pwsx4476 power 0.0819 0.5 -> 0.286 Inexact Rounded
+pwsx4477 power 0.821 0.5 -> 0.906 Inexact Rounded
+pwsx4478 power 0.0821 0.5 -> 0.287 Inexact Rounded
+pwsx4479 power 0.822 0.5 -> 0.907 Inexact Rounded
+pwsx4480 power 0.0822 0.5 -> 0.287 Inexact Rounded
+pwsx4481 power 0.823 0.5 -> 0.907 Inexact Rounded
+pwsx4482 power 0.0823 0.5 -> 0.287 Inexact Rounded
+pwsx4483 power 0.824 0.5 -> 0.908 Inexact Rounded
+pwsx4484 power 0.0824 0.5 -> 0.287 Inexact Rounded
+pwsx4485 power 0.825 0.5 -> 0.908 Inexact Rounded
+pwsx4486 power 0.0825 0.5 -> 0.287 Inexact Rounded
+pwsx4487 power 0.826 0.5 -> 0.909 Inexact Rounded
+pwsx4488 power 0.0826 0.5 -> 0.287 Inexact Rounded
+pwsx4489 power 0.827 0.5 -> 0.909 Inexact Rounded
+pwsx4490 power 0.0827 0.5 -> 0.288 Inexact Rounded
+pwsx4491 power 0.828 0.5 -> 0.910 Inexact Rounded
+pwsx4492 power 0.0828 0.5 -> 0.288 Inexact Rounded
+pwsx4493 power 0.829 0.5 -> 0.910 Inexact Rounded
+pwsx4494 power 0.0829 0.5 -> 0.288 Inexact Rounded
+pwsx4495 power 0.831 0.5 -> 0.912 Inexact Rounded
+pwsx4496 power 0.0831 0.5 -> 0.288 Inexact Rounded
+pwsx4497 power 0.832 0.5 -> 0.912 Inexact Rounded
+pwsx4498 power 0.0832 0.5 -> 0.288 Inexact Rounded
+pwsx4499 power 0.833 0.5 -> 0.913 Inexact Rounded
+pwsx4500 power 0.0833 0.5 -> 0.289 Inexact Rounded
+pwsx4501 power 0.834 0.5 -> 0.913 Inexact Rounded
+pwsx4502 power 0.0834 0.5 -> 0.289 Inexact Rounded
+pwsx4503 power 0.835 0.5 -> 0.914 Inexact Rounded
+pwsx4504 power 0.0835 0.5 -> 0.289 Inexact Rounded
+pwsx4505 power 0.836 0.5 -> 0.914 Inexact Rounded
+pwsx4506 power 0.0836 0.5 -> 0.289 Inexact Rounded
+pwsx4507 power 0.837 0.5 -> 0.915 Inexact Rounded
+pwsx4508 power 0.0837 0.5 -> 0.289 Inexact Rounded
+pwsx4509 power 0.838 0.5 -> 0.915 Inexact Rounded
+pwsx4510 power 0.0838 0.5 -> 0.289 Inexact Rounded
+pwsx4511 power 0.839 0.5 -> 0.916 Inexact Rounded
+pwsx4512 power 0.0839 0.5 -> 0.290 Inexact Rounded
+pwsx4513 power 0.841 0.5 -> 0.917 Inexact Rounded
+pwsx4514 power 0.0841 0.5 -> 0.290 Inexact Rounded
+pwsx4515 power 0.842 0.5 -> 0.918 Inexact Rounded
+pwsx4516 power 0.0842 0.5 -> 0.290 Inexact Rounded
+pwsx4517 power 0.843 0.5 -> 0.918 Inexact Rounded
+pwsx4518 power 0.0843 0.5 -> 0.290 Inexact Rounded
+pwsx4519 power 0.844 0.5 -> 0.919 Inexact Rounded
+pwsx4520 power 0.0844 0.5 -> 0.291 Inexact Rounded
+pwsx4521 power 0.845 0.5 -> 0.919 Inexact Rounded
+pwsx4522 power 0.0845 0.5 -> 0.291 Inexact Rounded
+pwsx4523 power 0.846 0.5 -> 0.920 Inexact Rounded
+pwsx4524 power 0.0846 0.5 -> 0.291 Inexact Rounded
+pwsx4525 power 0.847 0.5 -> 0.920 Inexact Rounded
+pwsx4526 power 0.0847 0.5 -> 0.291 Inexact Rounded
+pwsx4527 power 0.848 0.5 -> 0.921 Inexact Rounded
+pwsx4528 power 0.0848 0.5 -> 0.291 Inexact Rounded
+pwsx4529 power 0.849 0.5 -> 0.921 Inexact Rounded
+pwsx4530 power 0.0849 0.5 -> 0.291 Inexact Rounded
+pwsx4531 power 0.851 0.5 -> 0.922 Inexact Rounded
+pwsx4532 power 0.0851 0.5 -> 0.292 Inexact Rounded
+pwsx4533 power 0.852 0.5 -> 0.923 Inexact Rounded
+pwsx4534 power 0.0852 0.5 -> 0.292 Inexact Rounded
+pwsx4535 power 0.853 0.5 -> 0.924 Inexact Rounded
+pwsx4536 power 0.0853 0.5 -> 0.292 Inexact Rounded
+pwsx4537 power 0.854 0.5 -> 0.924 Inexact Rounded
+pwsx4538 power 0.0854 0.5 -> 0.292 Inexact Rounded
+pwsx4539 power 0.855 0.5 -> 0.925 Inexact Rounded
+pwsx4540 power 0.0855 0.5 -> 0.292 Inexact Rounded
+pwsx4541 power 0.856 0.5 -> 0.925 Inexact Rounded
+pwsx4542 power 0.0856 0.5 -> 0.293 Inexact Rounded
+pwsx4543 power 0.857 0.5 -> 0.926 Inexact Rounded
+pwsx4544 power 0.0857 0.5 -> 0.293 Inexact Rounded
+pwsx4545 power 0.858 0.5 -> 0.926 Inexact Rounded
+pwsx4546 power 0.0858 0.5 -> 0.293 Inexact Rounded
+pwsx4547 power 0.859 0.5 -> 0.927 Inexact Rounded
+pwsx4548 power 0.0859 0.5 -> 0.293 Inexact Rounded
+pwsx4549 power 0.861 0.5 -> 0.928 Inexact Rounded
+pwsx4550 power 0.0861 0.5 -> 0.293 Inexact Rounded
+pwsx4551 power 0.862 0.5 -> 0.928 Inexact Rounded
+pwsx4552 power 0.0862 0.5 -> 0.294 Inexact Rounded
+pwsx4553 power 0.863 0.5 -> 0.929 Inexact Rounded
+pwsx4554 power 0.0863 0.5 -> 0.294 Inexact Rounded
+pwsx4555 power 0.864 0.5 -> 0.930 Inexact Rounded
+pwsx4556 power 0.0864 0.5 -> 0.294 Inexact Rounded
+pwsx4557 power 0.865 0.5 -> 0.930 Inexact Rounded
+pwsx4558 power 0.0865 0.5 -> 0.294 Inexact Rounded
+pwsx4559 power 0.866 0.5 -> 0.931 Inexact Rounded
+pwsx4560 power 0.0866 0.5 -> 0.294 Inexact Rounded
+pwsx4561 power 0.867 0.5 -> 0.931 Inexact Rounded
+pwsx4562 power 0.0867 0.5 -> 0.294 Inexact Rounded
+pwsx4563 power 0.868 0.5 -> 0.932 Inexact Rounded
+pwsx4564 power 0.0868 0.5 -> 0.295 Inexact Rounded
+pwsx4565 power 0.869 0.5 -> 0.932 Inexact Rounded
+pwsx4566 power 0.0869 0.5 -> 0.295 Inexact Rounded
+pwsx4567 power 0.871 0.5 -> 0.933 Inexact Rounded
+pwsx4568 power 0.0871 0.5 -> 0.295 Inexact Rounded
+pwsx4569 power 0.872 0.5 -> 0.934 Inexact Rounded
+pwsx4570 power 0.0872 0.5 -> 0.295 Inexact Rounded
+pwsx4571 power 0.873 0.5 -> 0.934 Inexact Rounded
+pwsx4572 power 0.0873 0.5 -> 0.295 Inexact Rounded
+pwsx4573 power 0.874 0.5 -> 0.935 Inexact Rounded
+pwsx4574 power 0.0874 0.5 -> 0.296 Inexact Rounded
+pwsx4575 power 0.875 0.5 -> 0.935 Inexact Rounded
+pwsx4576 power 0.0875 0.5 -> 0.296 Inexact Rounded
+pwsx4577 power 0.876 0.5 -> 0.936 Inexact Rounded
+pwsx4578 power 0.0876 0.5 -> 0.296 Inexact Rounded
+pwsx4579 power 0.877 0.5 -> 0.936 Inexact Rounded
+pwsx4580 power 0.0877 0.5 -> 0.296 Inexact Rounded
+pwsx4581 power 0.878 0.5 -> 0.937 Inexact Rounded
+pwsx4582 power 0.0878 0.5 -> 0.296 Inexact Rounded
+pwsx4583 power 0.879 0.5 -> 0.938 Inexact Rounded
+pwsx4584 power 0.0879 0.5 -> 0.296 Inexact Rounded
+pwsx4585 power 0.881 0.5 -> 0.939 Inexact Rounded
+pwsx4586 power 0.0881 0.5 -> 0.297 Inexact Rounded
+pwsx4587 power 0.882 0.5 -> 0.939 Inexact Rounded
+pwsx4588 power 0.0882 0.5 -> 0.297 Inexact Rounded
+pwsx4589 power 0.883 0.5 -> 0.940 Inexact Rounded
+pwsx4590 power 0.0883 0.5 -> 0.297 Inexact Rounded
+pwsx4591 power 0.884 0.5 -> 0.940 Inexact Rounded
+pwsx4592 power 0.0884 0.5 -> 0.297 Inexact Rounded
+pwsx4593 power 0.885 0.5 -> 0.941 Inexact Rounded
+pwsx4594 power 0.0885 0.5 -> 0.297 Inexact Rounded
+pwsx4595 power 0.886 0.5 -> 0.941 Inexact Rounded
+pwsx4596 power 0.0886 0.5 -> 0.298 Inexact Rounded
+pwsx4597 power 0.887 0.5 -> 0.942 Inexact Rounded
+pwsx4598 power 0.0887 0.5 -> 0.298 Inexact Rounded
+pwsx4599 power 0.888 0.5 -> 0.942 Inexact Rounded
+pwsx4600 power 0.0888 0.5 -> 0.298 Inexact Rounded
+pwsx4601 power 0.889 0.5 -> 0.943 Inexact Rounded
+pwsx4602 power 0.0889 0.5 -> 0.298 Inexact Rounded
+pwsx4603 power 0.891 0.5 -> 0.944 Inexact Rounded
+pwsx4604 power 0.0891 0.5 -> 0.298 Inexact Rounded
+pwsx4605 power 0.892 0.5 -> 0.944 Inexact Rounded
+pwsx4606 power 0.0892 0.5 -> 0.299 Inexact Rounded
+pwsx4607 power 0.893 0.5 -> 0.945 Inexact Rounded
+pwsx4608 power 0.0893 0.5 -> 0.299 Inexact Rounded
+pwsx4609 power 0.894 0.5 -> 0.946 Inexact Rounded
+pwsx4610 power 0.0894 0.5 -> 0.299 Inexact Rounded
+pwsx4611 power 0.895 0.5 -> 0.946 Inexact Rounded
+pwsx4612 power 0.0895 0.5 -> 0.299 Inexact Rounded
+pwsx4613 power 0.896 0.5 -> 0.947 Inexact Rounded
+pwsx4614 power 0.0896 0.5 -> 0.299 Inexact Rounded
+pwsx4615 power 0.897 0.5 -> 0.947 Inexact Rounded
+pwsx4616 power 0.0897 0.5 -> 0.299 Inexact Rounded
+pwsx4617 power 0.898 0.5 -> 0.948 Inexact Rounded
+pwsx4618 power 0.0898 0.5 -> 0.300 Inexact Rounded
+pwsx4619 power 0.899 0.5 -> 0.948 Inexact Rounded
+pwsx4620 power 0.0899 0.5 -> 0.300 Inexact Rounded
+pwsx4621 power 0.901 0.5 -> 0.949 Inexact Rounded
+pwsx4622 power 0.0901 0.5 -> 0.300 Inexact Rounded
+pwsx4623 power 0.902 0.5 -> 0.950 Inexact Rounded
+pwsx4624 power 0.0902 0.5 -> 0.300 Inexact Rounded
+pwsx4625 power 0.903 0.5 -> 0.950 Inexact Rounded
+pwsx4626 power 0.0903 0.5 -> 0.300 Inexact Rounded
+pwsx4627 power 0.904 0.5 -> 0.951 Inexact Rounded
+pwsx4628 power 0.0904 0.5 -> 0.301 Inexact Rounded
+pwsx4629 power 0.905 0.5 -> 0.951 Inexact Rounded
+pwsx4630 power 0.0905 0.5 -> 0.301 Inexact Rounded
+pwsx4631 power 0.906 0.5 -> 0.952 Inexact Rounded
+pwsx4632 power 0.0906 0.5 -> 0.301 Inexact Rounded
+pwsx4633 power 0.907 0.5 -> 0.952 Inexact Rounded
+pwsx4634 power 0.0907 0.5 -> 0.301 Inexact Rounded
+pwsx4635 power 0.908 0.5 -> 0.953 Inexact Rounded
+pwsx4636 power 0.0908 0.5 -> 0.301 Inexact Rounded
+pwsx4637 power 0.909 0.5 -> 0.953 Inexact Rounded
+pwsx4638 power 0.0909 0.5 -> 0.301 Inexact Rounded
+pwsx4639 power 0.911 0.5 -> 0.954 Inexact Rounded
+pwsx4640 power 0.0911 0.5 -> 0.302 Inexact Rounded
+pwsx4641 power 0.912 0.5 -> 0.955 Inexact Rounded
+pwsx4642 power 0.0912 0.5 -> 0.302 Inexact Rounded
+pwsx4643 power 0.913 0.5 -> 0.956 Inexact Rounded
+pwsx4644 power 0.0913 0.5 -> 0.302 Inexact Rounded
+pwsx4645 power 0.914 0.5 -> 0.956 Inexact Rounded
+pwsx4646 power 0.0914 0.5 -> 0.302 Inexact Rounded
+pwsx4647 power 0.915 0.5 -> 0.957 Inexact Rounded
+pwsx4648 power 0.0915 0.5 -> 0.302 Inexact Rounded
+pwsx4649 power 0.916 0.5 -> 0.957 Inexact Rounded
+pwsx4650 power 0.0916 0.5 -> 0.303 Inexact Rounded
+pwsx4651 power 0.917 0.5 -> 0.958 Inexact Rounded
+pwsx4652 power 0.0917 0.5 -> 0.303 Inexact Rounded
+pwsx4653 power 0.918 0.5 -> 0.958 Inexact Rounded
+pwsx4654 power 0.0918 0.5 -> 0.303 Inexact Rounded
+pwsx4655 power 0.919 0.5 -> 0.959 Inexact Rounded
+pwsx4656 power 0.0919 0.5 -> 0.303 Inexact Rounded
+pwsx4657 power 0.921 0.5 -> 0.960 Inexact Rounded
+pwsx4658 power 0.0921 0.5 -> 0.303 Inexact Rounded
+pwsx4659 power 0.922 0.5 -> 0.960 Inexact Rounded
+pwsx4660 power 0.0922 0.5 -> 0.304 Inexact Rounded
+pwsx4661 power 0.923 0.5 -> 0.961 Inexact Rounded
+pwsx4662 power 0.0923 0.5 -> 0.304 Inexact Rounded
+pwsx4663 power 0.924 0.5 -> 0.961 Inexact Rounded
+pwsx4664 power 0.0924 0.5 -> 0.304 Inexact Rounded
+pwsx4665 power 0.925 0.5 -> 0.962 Inexact Rounded
+pwsx4666 power 0.0925 0.5 -> 0.304 Inexact Rounded
+pwsx4667 power 0.926 0.5 -> 0.962 Inexact Rounded
+pwsx4668 power 0.0926 0.5 -> 0.304 Inexact Rounded
+pwsx4669 power 0.927 0.5 -> 0.963 Inexact Rounded
+pwsx4670 power 0.0927 0.5 -> 0.304 Inexact Rounded
+pwsx4671 power 0.928 0.5 -> 0.963 Inexact Rounded
+pwsx4672 power 0.0928 0.5 -> 0.305 Inexact Rounded
+pwsx4673 power 0.929 0.5 -> 0.964 Inexact Rounded
+pwsx4674 power 0.0929 0.5 -> 0.305 Inexact Rounded
+pwsx4675 power 0.931 0.5 -> 0.965 Inexact Rounded
+pwsx4676 power 0.0931 0.5 -> 0.305 Inexact Rounded
+pwsx4677 power 0.932 0.5 -> 0.965 Inexact Rounded
+pwsx4678 power 0.0932 0.5 -> 0.305 Inexact Rounded
+pwsx4679 power 0.933 0.5 -> 0.966 Inexact Rounded
+pwsx4680 power 0.0933 0.5 -> 0.305 Inexact Rounded
+pwsx4681 power 0.934 0.5 -> 0.966 Inexact Rounded
+pwsx4682 power 0.0934 0.5 -> 0.306 Inexact Rounded
+pwsx4683 power 0.935 0.5 -> 0.967 Inexact Rounded
+pwsx4684 power 0.0935 0.5 -> 0.306 Inexact Rounded
+pwsx4685 power 0.936 0.5 -> 0.967 Inexact Rounded
+pwsx4686 power 0.0936 0.5 -> 0.306 Inexact Rounded
+pwsx4687 power 0.937 0.5 -> 0.968 Inexact Rounded
+pwsx4688 power 0.0937 0.5 -> 0.306 Inexact Rounded
+pwsx4689 power 0.938 0.5 -> 0.969 Inexact Rounded
+pwsx4690 power 0.0938 0.5 -> 0.306 Inexact Rounded
+pwsx4691 power 0.939 0.5 -> 0.969 Inexact Rounded
+pwsx4692 power 0.0939 0.5 -> 0.306 Inexact Rounded
+pwsx4693 power 0.941 0.5 -> 0.970 Inexact Rounded
+pwsx4694 power 0.0941 0.5 -> 0.307 Inexact Rounded
+pwsx4695 power 0.942 0.5 -> 0.971 Inexact Rounded
+pwsx4696 power 0.0942 0.5 -> 0.307 Inexact Rounded
+pwsx4697 power 0.943 0.5 -> 0.971 Inexact Rounded
+pwsx4698 power 0.0943 0.5 -> 0.307 Inexact Rounded
+pwsx4699 power 0.944 0.5 -> 0.972 Inexact Rounded
+pwsx4700 power 0.0944 0.5 -> 0.307 Inexact Rounded
+pwsx4701 power 0.945 0.5 -> 0.972 Inexact Rounded
+pwsx4702 power 0.0945 0.5 -> 0.307 Inexact Rounded
+pwsx4703 power 0.946 0.5 -> 0.973 Inexact Rounded
+pwsx4704 power 0.0946 0.5 -> 0.308 Inexact Rounded
+pwsx4705 power 0.947 0.5 -> 0.973 Inexact Rounded
+pwsx4706 power 0.0947 0.5 -> 0.308 Inexact Rounded
+pwsx4707 power 0.948 0.5 -> 0.974 Inexact Rounded
+pwsx4708 power 0.0948 0.5 -> 0.308 Inexact Rounded
+pwsx4709 power 0.949 0.5 -> 0.974 Inexact Rounded
+pwsx4710 power 0.0949 0.5 -> 0.308 Inexact Rounded
+pwsx4711 power 0.951 0.5 -> 0.975 Inexact Rounded
+pwsx4712 power 0.0951 0.5 -> 0.308 Inexact Rounded
+pwsx4713 power 0.952 0.5 -> 0.976 Inexact Rounded
+pwsx4714 power 0.0952 0.5 -> 0.309 Inexact Rounded
+pwsx4715 power 0.953 0.5 -> 0.976 Inexact Rounded
+pwsx4716 power 0.0953 0.5 -> 0.309 Inexact Rounded
+pwsx4717 power 0.954 0.5 -> 0.977 Inexact Rounded
+pwsx4718 power 0.0954 0.5 -> 0.309 Inexact Rounded
+pwsx4719 power 0.955 0.5 -> 0.977 Inexact Rounded
+pwsx4720 power 0.0955 0.5 -> 0.309 Inexact Rounded
+pwsx4721 power 0.956 0.5 -> 0.978 Inexact Rounded
+pwsx4722 power 0.0956 0.5 -> 0.309 Inexact Rounded
+pwsx4723 power 0.957 0.5 -> 0.978 Inexact Rounded
+pwsx4724 power 0.0957 0.5 -> 0.309 Inexact Rounded
+pwsx4725 power 0.958 0.5 -> 0.979 Inexact Rounded
+pwsx4726 power 0.0958 0.5 -> 0.310 Inexact Rounded
+pwsx4727 power 0.959 0.5 -> 0.979 Inexact Rounded
+pwsx4728 power 0.0959 0.5 -> 0.310 Inexact Rounded
+pwsx4729 power 0.961 0.5 -> 0.980 Inexact Rounded
+pwsx4730 power 0.0961 0.5 -> 0.310 Inexact Rounded
+pwsx4731 power 0.962 0.5 -> 0.981 Inexact Rounded
+pwsx4732 power 0.0962 0.5 -> 0.310 Inexact Rounded
+pwsx4733 power 0.963 0.5 -> 0.981 Inexact Rounded
+pwsx4734 power 0.0963 0.5 -> 0.310 Inexact Rounded
+pwsx4735 power 0.964 0.5 -> 0.982 Inexact Rounded
+pwsx4736 power 0.0964 0.5 -> 0.310 Inexact Rounded
+pwsx4737 power 0.965 0.5 -> 0.982 Inexact Rounded
+pwsx4738 power 0.0965 0.5 -> 0.311 Inexact Rounded
+pwsx4739 power 0.966 0.5 -> 0.983 Inexact Rounded
+pwsx4740 power 0.0966 0.5 -> 0.311 Inexact Rounded
+pwsx4741 power 0.967 0.5 -> 0.983 Inexact Rounded
+pwsx4742 power 0.0967 0.5 -> 0.311 Inexact Rounded
+pwsx4743 power 0.968 0.5 -> 0.984 Inexact Rounded
+pwsx4744 power 0.0968 0.5 -> 0.311 Inexact Rounded
+pwsx4745 power 0.969 0.5 -> 0.984 Inexact Rounded
+pwsx4746 power 0.0969 0.5 -> 0.311 Inexact Rounded
+pwsx4747 power 0.971 0.5 -> 0.985 Inexact Rounded
+pwsx4748 power 0.0971 0.5 -> 0.312 Inexact Rounded
+pwsx4749 power 0.972 0.5 -> 0.986 Inexact Rounded
+pwsx4750 power 0.0972 0.5 -> 0.312 Inexact Rounded
+pwsx4751 power 0.973 0.5 -> 0.986 Inexact Rounded
+pwsx4752 power 0.0973 0.5 -> 0.312 Inexact Rounded
+pwsx4753 power 0.974 0.5 -> 0.987 Inexact Rounded
+pwsx4754 power 0.0974 0.5 -> 0.312 Inexact Rounded
+pwsx4755 power 0.975 0.5 -> 0.987 Inexact Rounded
+pwsx4756 power 0.0975 0.5 -> 0.312 Inexact Rounded
+pwsx4757 power 0.976 0.5 -> 0.988 Inexact Rounded
+pwsx4758 power 0.0976 0.5 -> 0.312 Inexact Rounded
+pwsx4759 power 0.977 0.5 -> 0.988 Inexact Rounded
+pwsx4760 power 0.0977 0.5 -> 0.313 Inexact Rounded
+pwsx4761 power 0.978 0.5 -> 0.989 Inexact Rounded
+pwsx4762 power 0.0978 0.5 -> 0.313 Inexact Rounded
+pwsx4763 power 0.979 0.5 -> 0.989 Inexact Rounded
+pwsx4764 power 0.0979 0.5 -> 0.313 Inexact Rounded
+pwsx4765 power 0.981 0.5 -> 0.990 Inexact Rounded
+pwsx4766 power 0.0981 0.5 -> 0.313 Inexact Rounded
+pwsx4767 power 0.982 0.5 -> 0.991 Inexact Rounded
+pwsx4768 power 0.0982 0.5 -> 0.313 Inexact Rounded
+pwsx4769 power 0.983 0.5 -> 0.991 Inexact Rounded
+pwsx4770 power 0.0983 0.5 -> 0.314 Inexact Rounded
+pwsx4771 power 0.984 0.5 -> 0.992 Inexact Rounded
+pwsx4772 power 0.0984 0.5 -> 0.314 Inexact Rounded
+pwsx4773 power 0.985 0.5 -> 0.992 Inexact Rounded
+pwsx4774 power 0.0985 0.5 -> 0.314 Inexact Rounded
+pwsx4775 power 0.986 0.5 -> 0.993 Inexact Rounded
+pwsx4776 power 0.0986 0.5 -> 0.314 Inexact Rounded
+pwsx4777 power 0.987 0.5 -> 0.993 Inexact Rounded
+pwsx4778 power 0.0987 0.5 -> 0.314 Inexact Rounded
+pwsx4779 power 0.988 0.5 -> 0.994 Inexact Rounded
+pwsx4780 power 0.0988 0.5 -> 0.314 Inexact Rounded
+pwsx4781 power 0.989 0.5 -> 0.994 Inexact Rounded
+pwsx4782 power 0.0989 0.5 -> 0.314 Inexact Rounded
+pwsx4783 power 0.991 0.5 -> 0.995 Inexact Rounded
+pwsx4784 power 0.0991 0.5 -> 0.315 Inexact Rounded
+pwsx4785 power 0.992 0.5 -> 0.996 Inexact Rounded
+pwsx4786 power 0.0992 0.5 -> 0.315 Inexact Rounded
+pwsx4787 power 0.993 0.5 -> 0.996 Inexact Rounded
+pwsx4788 power 0.0993 0.5 -> 0.315 Inexact Rounded
+pwsx4789 power 0.994 0.5 -> 0.997 Inexact Rounded
+pwsx4790 power 0.0994 0.5 -> 0.315 Inexact Rounded
+pwsx4791 power 0.995 0.5 -> 0.997 Inexact Rounded
+pwsx4792 power 0.0995 0.5 -> 0.315 Inexact Rounded
+pwsx4793 power 0.996 0.5 -> 0.998 Inexact Rounded
+pwsx4794 power 0.0996 0.5 -> 0.316 Inexact Rounded
+pwsx4795 power 0.997 0.5 -> 0.998 Inexact Rounded
+pwsx4796 power 0.0997 0.5 -> 0.316 Inexact Rounded
+pwsx4797 power 0.998 0.5 -> 0.999 Inexact Rounded
+pwsx4798 power 0.0998 0.5 -> 0.316 Inexact Rounded
+pwsx4799 power 0.999 0.5 -> 0.999 Inexact Rounded
+pwsx4800 power 0.0999 0.5 -> 0.316 Inexact Rounded
+
+-- A group of precision 4 tests where Hull & Abrham adjustments are
+-- needed in some cases (both up and down) [see Hull1985b]
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+precision: 4
+pwsx5001 power 0.0118 0.5 -> 0.1086 Inexact Rounded
+pwsx5002 power 0.119 0.5 -> 0.3450 Inexact Rounded
+pwsx5003 power 0.0119 0.5 -> 0.1091 Inexact Rounded
+pwsx5004 power 0.121 0.5 -> 0.3479 Inexact Rounded
+pwsx5005 power 0.0121 0.5 -> 0.1100 Inexact Rounded
+pwsx5006 power 0.122 0.5 -> 0.3493 Inexact Rounded
+pwsx5007 power 0.0122 0.5 -> 0.1105 Inexact Rounded
+pwsx5008 power 0.123 0.5 -> 0.3507 Inexact Rounded
+pwsx5009 power 0.494 0.5 -> 0.7029 Inexact Rounded
+pwsx5010 power 0.0669 0.5 -> 0.2587 Inexact Rounded
+pwsx5011 power 0.9558 0.5 -> 0.9777 Inexact Rounded
+pwsx5012 power 0.9348 0.5 -> 0.9669 Inexact Rounded
+pwsx5013 power 0.9345 0.5 -> 0.9667 Inexact Rounded
+pwsx5014 power 0.09345 0.5 -> 0.3057 Inexact Rounded
+pwsx5015 power 0.9346 0.5 -> 0.9667 Inexact Rounded
+pwsx5016 power 0.09346 0.5 -> 0.3057 Inexact Rounded
+pwsx5017 power 0.9347 0.5 -> 0.9668 Inexact Rounded
+
+-- examples from decArith
+precision: 9
+pwsx700 power 0 0.5 -> '0'
+pwsx701 power -0 0.5 -> '0'
+pwsx702 power 0.39 0.5 -> 0.624499800 Inexact Rounded
+pwsx703 power 100 0.5 -> '10.0000000' Inexact Rounded
+pwsx704 power 1.00 0.5 -> '1.00000000' Inexact Rounded
+pwsx705 power 7 0.5 -> '2.64575131' Inexact Rounded
+pwsx706 power 10 0.5 -> 3.16227766 Inexact Rounded
+
+-- some one-offs
+precision: 9
+pwsx711 power 0.1 0.5 -> 0.316227766 Inexact Rounded
+pwsx712 power 0.2 0.5 -> 0.447213595 Inexact Rounded
+pwsx713 power 0.3 0.5 -> 0.547722558 Inexact Rounded
+pwsx714 power 0.4 0.5 -> 0.632455532 Inexact Rounded
+pwsx715 power 0.5 0.5 -> 0.707106781 Inexact Rounded
+pwsx716 power 0.6 0.5 -> 0.774596669 Inexact Rounded
+pwsx717 power 0.7 0.5 -> 0.836660027 Inexact Rounded
+pwsx718 power 0.8 0.5 -> 0.894427191 Inexact Rounded
+pwsx719 power 0.9 0.5 -> 0.948683298 Inexact Rounded
+precision: 10 -- note no normalizatoin here
+pwsx720 power +0.1 0.5 -> 0.3162277660 Inexact Rounded
+precision: 11
+pwsx721 power +0.1 0.5 -> 0.31622776602 Inexact Rounded
+precision: 12
+pwsx722 power +0.1 0.5 -> 0.316227766017 Inexact Rounded
+precision: 9
+pwsx723 power 0.39 0.5 -> 0.624499800 Inexact Rounded
+precision: 15
+pwsx724 power 0.39 0.5 -> 0.624499799839840 Inexact Rounded
+
+-- discussion cases
+precision: 7
+pwsx731 power 9 0.5 -> 3.000000 Inexact Rounded
+pwsx732 power 100 0.5 -> 10.00000 Inexact Rounded
+pwsx733 power 123 0.5 -> 11.09054 Inexact Rounded
+pwsx734 power 144 0.5 -> 12.00000 Inexact Rounded
+pwsx735 power 156 0.5 -> 12.49000 Inexact Rounded
+pwsx736 power 10000 0.5 -> 100.0000 Inexact Rounded
+
+-- values close to overflow (if there were input rounding)
+maxexponent: 99
+minexponent: -99
+precision: 5
+pwsx760 power 9.9997E+99 0.5 -> 9.9998E+49 Inexact Rounded
+pwsx761 power 9.9998E+99 0.5 -> 9.9999E+49 Inexact Rounded
+pwsx762 power 9.9999E+99 0.5 -> 9.9999E+49 Inexact Rounded
+pwsx763 power 9.99991E+99 0.5 -> 1.0000E+50 Inexact Rounded
+pwsx764 power 9.99994E+99 0.5 -> 1.0000E+50 Inexact Rounded
+pwsx765 power 9.99995E+99 0.5 -> 1.0000E+50 Inexact Rounded
+pwsx766 power 9.99999E+99 0.5 -> 1.0000E+50 Inexact Rounded
+precision: 9
+pwsx770 power 9.9997E+99 0.5 -> 9.99985000E+49 Inexact Rounded
+pwsx771 power 9.9998E+99 0.5 -> 9.99990000E+49 Inexact Rounded
+pwsx772 power 9.9999E+99 0.5 -> 9.99995000E+49 Inexact Rounded
+pwsx773 power 9.99991E+99 0.5 -> 9.99995500E+49 Inexact Rounded
+pwsx774 power 9.99994E+99 0.5 -> 9.99997000E+49 Inexact Rounded
+pwsx775 power 9.99995E+99 0.5 -> 9.99997500E+49 Inexact Rounded
+pwsx776 power 9.99999E+99 0.5 -> 9.99999500E+49 Inexact Rounded
+precision: 20
+pwsx780 power 9.9997E+99 0.5 -> '9.9998499988749831247E+49' Inexact Rounded
+pwsx781 power 9.9998E+99 0.5 -> '9.9998999994999949999E+49' Inexact Rounded
+pwsx782 power 9.9999E+99 0.5 -> '9.9999499998749993750E+49' Inexact Rounded
+pwsx783 power 9.99991E+99 0.5 -> '9.9999549998987495444E+49' Inexact Rounded
+pwsx784 power 9.99994E+99 0.5 -> '9.9999699999549998650E+49' Inexact Rounded
+pwsx785 power 9.99995E+99 0.5 -> '9.9999749999687499219E+49' Inexact Rounded
+pwsx786 power 9.99999E+99 0.5 -> '9.9999949999987499994E+49' Inexact Rounded
+
+-- subnormals and underflows [these can only result when eMax is < digits+1]
+-- Etiny = -(Emax + (precision-1))
+-- start with subnormal operands and normal results
+maxexponent: 9
+minexponent: -9
+precision: 9 -- Etiny=-17
+pwsx800 power 1E-17 0.5 -> 3.16227766E-9 Inexact Rounded
+pwsx801 power 10E-17 0.5 -> 1.00000000E-8 Inexact Rounded
+precision: 10 -- Etiny=-18
+pwsx802 power 10E-18 0.5 -> 3.162277660E-9 Inexact Rounded
+pwsx803 power 1E-18 0.5 -> 1.000000000E-9 Inexact Rounded
+
+precision: 11 -- Etiny=-19
+pwsx804 power 1E-19 0.5 -> 3.162277660E-10 Underflow Subnormal Inexact Rounded
+-- The next test should be skipped for decNumber
+pwsx805 power 10E-19 0.5 -> 1.0000000000E-9 Inexact Rounded
+precision: 12 -- Etiny=-20
+pwsx806 power 10E-20 0.5 -> 3.1622776602E-10 Underflow Subnormal Inexact Rounded
+pwsx807 power 1E-20 0.5 -> 1.0000000000E-10 Underflow Subnormal Inexact Rounded
+
+precision: 13 -- Etiny=-21
+pwsx808 power 1E-21 0.5 -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded
+pwsx809 power 10E-21 0.5 -> 1.00000000000E-10 Underflow Subnormal Inexact Rounded
+precision: 14 -- Etiny=-22
+pwsx810 power 1E-21 0.5 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
+pwsx811 power 10E-22 0.5 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
+pwsx812 power 1E-22 0.5 -> 1.00000000000E-11 Underflow Subnormal Inexact Rounded
+
+
+-- special values
+maxexponent: 999
+minexponent: -999
+pwsx820 power Inf 0.5 -> Infinity
+pwsx821 power -Inf 0.5 -> NaN Invalid_operation
+pwsx822 power NaN 0.5 -> NaN
+pwsx823 power sNaN 0.5 -> NaN Invalid_operation
+-- propagating NaNs
+pwsx824 power sNaN123 0.5 -> NaN123 Invalid_operation
+pwsx825 power -sNaN321 0.5 -> -NaN321 Invalid_operation
+pwsx826 power NaN456 0.5 -> NaN456
+pwsx827 power -NaN654 0.5 -> -NaN654
+pwsx828 power NaN1 0.5 -> NaN1
+
+-- Null test
+pwsx900 power # 0.5 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/rotate.decTest b/Lib/test/decimaltestdata/rotate.decTest
index 81ade79c22..12db821317 100644
--- a/Lib/test/decimaltestdata/rotate.decTest
+++ b/Lib/test/decimaltestdata/rotate.decTest
@@ -1,247 +1,247 @@
-------------------------------------------------------------------------
--- rotate.decTest -- rotate coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-rotx001 rotate 0 0 -> 0
-rotx002 rotate 0 2 -> 0
-rotx003 rotate 1 2 -> 100
-rotx004 rotate 34 8 -> 400000003
-rotx005 rotate 1 9 -> 1
-rotx006 rotate 1 -1 -> 100000000
-rotx007 rotate 123456789 -1 -> 912345678
-rotx008 rotate 123456789 -8 -> 234567891
-rotx009 rotate 123456789 -9 -> 123456789
-rotx010 rotate 0 -2 -> 0
-
--- rhs must be an integer
-rotx011 rotate 1 1.5 -> NaN Invalid_operation
-rotx012 rotate 1 1.0 -> NaN Invalid_operation
-rotx013 rotate 1 0.1 -> NaN Invalid_operation
-rotx014 rotate 1 0.0 -> NaN Invalid_operation
-rotx015 rotate 1 1E+1 -> NaN Invalid_operation
-rotx016 rotate 1 1E+99 -> NaN Invalid_operation
-rotx017 rotate 1 Inf -> NaN Invalid_operation
-rotx018 rotate 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-rotx020 rotate 1 -1000 -> NaN Invalid_operation
-rotx021 rotate 1 -10 -> NaN Invalid_operation
-rotx022 rotate 1 10 -> NaN Invalid_operation
-rotx023 rotate 1 1000 -> NaN Invalid_operation
-
--- full pattern
-rotx030 rotate 123456789 -9 -> 123456789
-rotx031 rotate 123456789 -8 -> 234567891
-rotx032 rotate 123456789 -7 -> 345678912
-rotx033 rotate 123456789 -6 -> 456789123
-rotx034 rotate 123456789 -5 -> 567891234
-rotx035 rotate 123456789 -4 -> 678912345
-rotx036 rotate 123456789 -3 -> 789123456
-rotx037 rotate 123456789 -2 -> 891234567
-rotx038 rotate 123456789 -1 -> 912345678
-rotx039 rotate 123456789 -0 -> 123456789
-rotx040 rotate 123456789 +0 -> 123456789
-rotx041 rotate 123456789 +1 -> 234567891
-rotx042 rotate 123456789 +2 -> 345678912
-rotx043 rotate 123456789 +3 -> 456789123
-rotx044 rotate 123456789 +4 -> 567891234
-rotx045 rotate 123456789 +5 -> 678912345
-rotx046 rotate 123456789 +6 -> 789123456
-rotx047 rotate 123456789 +7 -> 891234567
-rotx048 rotate 123456789 +8 -> 912345678
-rotx049 rotate 123456789 +9 -> 123456789
-
--- zeros
-rotx060 rotate 0E-10 +9 -> 0E-10
-rotx061 rotate 0E-10 -9 -> 0E-10
-rotx062 rotate 0.000 +9 -> 0.000
-rotx063 rotate 0.000 -9 -> 0.000
-rotx064 rotate 0E+10 +9 -> 0E+10
-rotx065 rotate 0E+10 -9 -> 0E+10
-rotx066 rotate -0E-10 +9 -> -0E-10
-rotx067 rotate -0E-10 -9 -> -0E-10
-rotx068 rotate -0.000 +9 -> -0.000
-rotx069 rotate -0.000 -9 -> -0.000
-rotx070 rotate -0E+10 +9 -> -0E+10
-rotx071 rotate -0E+10 -9 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-rotx141 rotate 9.99999999E+999 -1 -> 9.99999999E+999
-rotx142 rotate 9.99999999E+999 -8 -> 9.99999999E+999
-rotx143 rotate 9.99999999E+999 1 -> 9.99999999E+999
-rotx144 rotate 9.99999999E+999 8 -> 9.99999999E+999
-rotx145 rotate 1E-999 -1 -> 1.00000000E-991
-rotx146 rotate 1E-999 -8 -> 1.0E-998
-rotx147 rotate 1E-999 1 -> 1.0E-998
-rotx148 rotate 1E-999 8 -> 1.00000000E-991
-rotx151 rotate 1.00000000E-999 -1 -> 1.0000000E-1000
-rotx152 rotate 1.00000000E-999 -8 -> 1E-1007
-rotx153 rotate 1.00000000E-999 1 -> 1E-1007
-rotx154 rotate 1.00000000E-999 8 -> 1.0000000E-1000
-rotx155 rotate 9.00000000E-999 -1 -> 9.0000000E-1000
-rotx156 rotate 9.00000000E-999 -8 -> 9E-1007
-rotx157 rotate 9.00000000E-999 1 -> 9E-1007
-rotx158 rotate 9.00000000E-999 8 -> 9.0000000E-1000
-rotx160 rotate 1E-1007 -1 -> 1.00000000E-999
-rotx161 rotate 1E-1007 -8 -> 1.0E-1006
-rotx162 rotate 1E-1007 1 -> 1.0E-1006
-rotx163 rotate 1E-1007 8 -> 1.00000000E-999
--- negatives
-rotx171 rotate -9.99999999E+999 -1 -> -9.99999999E+999
-rotx172 rotate -9.99999999E+999 -8 -> -9.99999999E+999
-rotx173 rotate -9.99999999E+999 1 -> -9.99999999E+999
-rotx174 rotate -9.99999999E+999 8 -> -9.99999999E+999
-rotx175 rotate -1E-999 -1 -> -1.00000000E-991
-rotx176 rotate -1E-999 -8 -> -1.0E-998
-rotx177 rotate -1E-999 1 -> -1.0E-998
-rotx178 rotate -1E-999 8 -> -1.00000000E-991
-rotx181 rotate -1.00000000E-999 -1 -> -1.0000000E-1000
-rotx182 rotate -1.00000000E-999 -8 -> -1E-1007
-rotx183 rotate -1.00000000E-999 1 -> -1E-1007
-rotx184 rotate -1.00000000E-999 8 -> -1.0000000E-1000
-rotx185 rotate -9.00000000E-999 -1 -> -9.0000000E-1000
-rotx186 rotate -9.00000000E-999 -8 -> -9E-1007
-rotx187 rotate -9.00000000E-999 1 -> -9E-1007
-rotx188 rotate -9.00000000E-999 8 -> -9.0000000E-1000
-rotx190 rotate -1E-1007 -1 -> -1.00000000E-999
-rotx191 rotate -1E-1007 -8 -> -1.0E-1006
-rotx192 rotate -1E-1007 1 -> -1.0E-1006
-rotx193 rotate -1E-1007 8 -> -1.00000000E-999
-
--- more negatives (of sanities)
-rotx201 rotate -0 0 -> -0
-rotx202 rotate -0 2 -> -0
-rotx203 rotate -1 2 -> -100
-rotx204 rotate -1 8 -> -100000000
-rotx205 rotate -1 9 -> -1
-rotx206 rotate -1 -1 -> -100000000
-rotx207 rotate -123456789 -1 -> -912345678
-rotx208 rotate -123456789 -8 -> -234567891
-rotx209 rotate -123456789 -9 -> -123456789
-rotx210 rotate -0 -2 -> -0
-
--- Specials; NaNs are handled as usual
-rotx781 rotate -Inf -8 -> -Infinity
-rotx782 rotate -Inf -1 -> -Infinity
-rotx783 rotate -Inf -0 -> -Infinity
-rotx784 rotate -Inf 0 -> -Infinity
-rotx785 rotate -Inf 1 -> -Infinity
-rotx786 rotate -Inf 8 -> -Infinity
-rotx787 rotate -1000 -Inf -> NaN Invalid_operation
-rotx788 rotate -Inf -Inf -> NaN Invalid_operation
-rotx789 rotate -1 -Inf -> NaN Invalid_operation
-rotx790 rotate -0 -Inf -> NaN Invalid_operation
-rotx791 rotate 0 -Inf -> NaN Invalid_operation
-rotx792 rotate 1 -Inf -> NaN Invalid_operation
-rotx793 rotate 1000 -Inf -> NaN Invalid_operation
-rotx794 rotate Inf -Inf -> NaN Invalid_operation
-
-rotx800 rotate Inf -Inf -> NaN Invalid_operation
-rotx801 rotate Inf -8 -> Infinity
-rotx802 rotate Inf -1 -> Infinity
-rotx803 rotate Inf -0 -> Infinity
-rotx804 rotate Inf 0 -> Infinity
-rotx805 rotate Inf 1 -> Infinity
-rotx806 rotate Inf 8 -> Infinity
-rotx807 rotate Inf Inf -> NaN Invalid_operation
-rotx808 rotate -1000 Inf -> NaN Invalid_operation
-rotx809 rotate -Inf Inf -> NaN Invalid_operation
-rotx810 rotate -1 Inf -> NaN Invalid_operation
-rotx811 rotate -0 Inf -> NaN Invalid_operation
-rotx812 rotate 0 Inf -> NaN Invalid_operation
-rotx813 rotate 1 Inf -> NaN Invalid_operation
-rotx814 rotate 1000 Inf -> NaN Invalid_operation
-rotx815 rotate Inf Inf -> NaN Invalid_operation
-
-rotx821 rotate NaN -Inf -> NaN
-rotx822 rotate NaN -1000 -> NaN
-rotx823 rotate NaN -1 -> NaN
-rotx824 rotate NaN -0 -> NaN
-rotx825 rotate NaN 0 -> NaN
-rotx826 rotate NaN 1 -> NaN
-rotx827 rotate NaN 1000 -> NaN
-rotx828 rotate NaN Inf -> NaN
-rotx829 rotate NaN NaN -> NaN
-rotx830 rotate -Inf NaN -> NaN
-rotx831 rotate -1000 NaN -> NaN
-rotx832 rotate -1 NaN -> NaN
-rotx833 rotate -0 NaN -> NaN
-rotx834 rotate 0 NaN -> NaN
-rotx835 rotate 1 NaN -> NaN
-rotx836 rotate 1000 NaN -> NaN
-rotx837 rotate Inf NaN -> NaN
-
-
-
-rotx841 rotate sNaN -Inf -> NaN Invalid_operation
-rotx842 rotate sNaN -1000 -> NaN Invalid_operation
-rotx843 rotate sNaN -1 -> NaN Invalid_operation
-rotx844 rotate sNaN -0 -> NaN Invalid_operation
-rotx845 rotate sNaN 0 -> NaN Invalid_operation
-rotx846 rotate sNaN 1 -> NaN Invalid_operation
-rotx847 rotate sNaN 1000 -> NaN Invalid_operation
-rotx848 rotate sNaN NaN -> NaN Invalid_operation
-rotx849 rotate sNaN sNaN -> NaN Invalid_operation
-rotx850 rotate NaN sNaN -> NaN Invalid_operation
-rotx851 rotate -Inf sNaN -> NaN Invalid_operation
-rotx852 rotate -1000 sNaN -> NaN Invalid_operation
-rotx853 rotate -1 sNaN -> NaN Invalid_operation
-rotx854 rotate -0 sNaN -> NaN Invalid_operation
-rotx855 rotate 0 sNaN -> NaN Invalid_operation
-rotx856 rotate 1 sNaN -> NaN Invalid_operation
-rotx857 rotate 1000 sNaN -> NaN Invalid_operation
-rotx858 rotate Inf sNaN -> NaN Invalid_operation
-rotx859 rotate NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-rotx861 rotate NaN1 -Inf -> NaN1
-rotx862 rotate +NaN2 -1000 -> NaN2
-rotx863 rotate NaN3 1000 -> NaN3
-rotx864 rotate NaN4 Inf -> NaN4
-rotx865 rotate NaN5 +NaN6 -> NaN5
-rotx866 rotate -Inf NaN7 -> NaN7
-rotx867 rotate -1000 NaN8 -> NaN8
-rotx868 rotate 1000 NaN9 -> NaN9
-rotx869 rotate Inf +NaN10 -> NaN10
-rotx871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
-rotx872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
-rotx873 rotate sNaN13 1000 -> NaN13 Invalid_operation
-rotx874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
-rotx875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
-rotx876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
-rotx877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
-rotx878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
-rotx879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
-rotx880 rotate Inf sNaN23 -> NaN23 Invalid_operation
-rotx881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
-rotx882 rotate -NaN26 NaN28 -> -NaN26
-rotx883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-rotx884 rotate 1000 -NaN30 -> -NaN30
-rotx885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- payload decapitate
-precision: 5
-rotx886 rotate 11 -sNaN1234567890 -> -NaN67890 Invalid_operation
+------------------------------------------------------------------------
+-- rotate.decTest -- rotate coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+rotx001 rotate 0 0 -> 0
+rotx002 rotate 0 2 -> 0
+rotx003 rotate 1 2 -> 100
+rotx004 rotate 34 8 -> 400000003
+rotx005 rotate 1 9 -> 1
+rotx006 rotate 1 -1 -> 100000000
+rotx007 rotate 123456789 -1 -> 912345678
+rotx008 rotate 123456789 -8 -> 234567891
+rotx009 rotate 123456789 -9 -> 123456789
+rotx010 rotate 0 -2 -> 0
+
+-- rhs must be an integer
+rotx011 rotate 1 1.5 -> NaN Invalid_operation
+rotx012 rotate 1 1.0 -> NaN Invalid_operation
+rotx013 rotate 1 0.1 -> NaN Invalid_operation
+rotx014 rotate 1 0.0 -> NaN Invalid_operation
+rotx015 rotate 1 1E+1 -> NaN Invalid_operation
+rotx016 rotate 1 1E+99 -> NaN Invalid_operation
+rotx017 rotate 1 Inf -> NaN Invalid_operation
+rotx018 rotate 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+rotx020 rotate 1 -1000 -> NaN Invalid_operation
+rotx021 rotate 1 -10 -> NaN Invalid_operation
+rotx022 rotate 1 10 -> NaN Invalid_operation
+rotx023 rotate 1 1000 -> NaN Invalid_operation
+
+-- full pattern
+rotx030 rotate 123456789 -9 -> 123456789
+rotx031 rotate 123456789 -8 -> 234567891
+rotx032 rotate 123456789 -7 -> 345678912
+rotx033 rotate 123456789 -6 -> 456789123
+rotx034 rotate 123456789 -5 -> 567891234
+rotx035 rotate 123456789 -4 -> 678912345
+rotx036 rotate 123456789 -3 -> 789123456
+rotx037 rotate 123456789 -2 -> 891234567
+rotx038 rotate 123456789 -1 -> 912345678
+rotx039 rotate 123456789 -0 -> 123456789
+rotx040 rotate 123456789 +0 -> 123456789
+rotx041 rotate 123456789 +1 -> 234567891
+rotx042 rotate 123456789 +2 -> 345678912
+rotx043 rotate 123456789 +3 -> 456789123
+rotx044 rotate 123456789 +4 -> 567891234
+rotx045 rotate 123456789 +5 -> 678912345
+rotx046 rotate 123456789 +6 -> 789123456
+rotx047 rotate 123456789 +7 -> 891234567
+rotx048 rotate 123456789 +8 -> 912345678
+rotx049 rotate 123456789 +9 -> 123456789
+
+-- zeros
+rotx060 rotate 0E-10 +9 -> 0E-10
+rotx061 rotate 0E-10 -9 -> 0E-10
+rotx062 rotate 0.000 +9 -> 0.000
+rotx063 rotate 0.000 -9 -> 0.000
+rotx064 rotate 0E+10 +9 -> 0E+10
+rotx065 rotate 0E+10 -9 -> 0E+10
+rotx066 rotate -0E-10 +9 -> -0E-10
+rotx067 rotate -0E-10 -9 -> -0E-10
+rotx068 rotate -0.000 +9 -> -0.000
+rotx069 rotate -0.000 -9 -> -0.000
+rotx070 rotate -0E+10 +9 -> -0E+10
+rotx071 rotate -0E+10 -9 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+rotx141 rotate 9.99999999E+999 -1 -> 9.99999999E+999
+rotx142 rotate 9.99999999E+999 -8 -> 9.99999999E+999
+rotx143 rotate 9.99999999E+999 1 -> 9.99999999E+999
+rotx144 rotate 9.99999999E+999 8 -> 9.99999999E+999
+rotx145 rotate 1E-999 -1 -> 1.00000000E-991
+rotx146 rotate 1E-999 -8 -> 1.0E-998
+rotx147 rotate 1E-999 1 -> 1.0E-998
+rotx148 rotate 1E-999 8 -> 1.00000000E-991
+rotx151 rotate 1.00000000E-999 -1 -> 1.0000000E-1000
+rotx152 rotate 1.00000000E-999 -8 -> 1E-1007
+rotx153 rotate 1.00000000E-999 1 -> 1E-1007
+rotx154 rotate 1.00000000E-999 8 -> 1.0000000E-1000
+rotx155 rotate 9.00000000E-999 -1 -> 9.0000000E-1000
+rotx156 rotate 9.00000000E-999 -8 -> 9E-1007
+rotx157 rotate 9.00000000E-999 1 -> 9E-1007
+rotx158 rotate 9.00000000E-999 8 -> 9.0000000E-1000
+rotx160 rotate 1E-1007 -1 -> 1.00000000E-999
+rotx161 rotate 1E-1007 -8 -> 1.0E-1006
+rotx162 rotate 1E-1007 1 -> 1.0E-1006
+rotx163 rotate 1E-1007 8 -> 1.00000000E-999
+-- negatives
+rotx171 rotate -9.99999999E+999 -1 -> -9.99999999E+999
+rotx172 rotate -9.99999999E+999 -8 -> -9.99999999E+999
+rotx173 rotate -9.99999999E+999 1 -> -9.99999999E+999
+rotx174 rotate -9.99999999E+999 8 -> -9.99999999E+999
+rotx175 rotate -1E-999 -1 -> -1.00000000E-991
+rotx176 rotate -1E-999 -8 -> -1.0E-998
+rotx177 rotate -1E-999 1 -> -1.0E-998
+rotx178 rotate -1E-999 8 -> -1.00000000E-991
+rotx181 rotate -1.00000000E-999 -1 -> -1.0000000E-1000
+rotx182 rotate -1.00000000E-999 -8 -> -1E-1007
+rotx183 rotate -1.00000000E-999 1 -> -1E-1007
+rotx184 rotate -1.00000000E-999 8 -> -1.0000000E-1000
+rotx185 rotate -9.00000000E-999 -1 -> -9.0000000E-1000
+rotx186 rotate -9.00000000E-999 -8 -> -9E-1007
+rotx187 rotate -9.00000000E-999 1 -> -9E-1007
+rotx188 rotate -9.00000000E-999 8 -> -9.0000000E-1000
+rotx190 rotate -1E-1007 -1 -> -1.00000000E-999
+rotx191 rotate -1E-1007 -8 -> -1.0E-1006
+rotx192 rotate -1E-1007 1 -> -1.0E-1006
+rotx193 rotate -1E-1007 8 -> -1.00000000E-999
+
+-- more negatives (of sanities)
+rotx201 rotate -0 0 -> -0
+rotx202 rotate -0 2 -> -0
+rotx203 rotate -1 2 -> -100
+rotx204 rotate -1 8 -> -100000000
+rotx205 rotate -1 9 -> -1
+rotx206 rotate -1 -1 -> -100000000
+rotx207 rotate -123456789 -1 -> -912345678
+rotx208 rotate -123456789 -8 -> -234567891
+rotx209 rotate -123456789 -9 -> -123456789
+rotx210 rotate -0 -2 -> -0
+
+-- Specials; NaNs are handled as usual
+rotx781 rotate -Inf -8 -> -Infinity
+rotx782 rotate -Inf -1 -> -Infinity
+rotx783 rotate -Inf -0 -> -Infinity
+rotx784 rotate -Inf 0 -> -Infinity
+rotx785 rotate -Inf 1 -> -Infinity
+rotx786 rotate -Inf 8 -> -Infinity
+rotx787 rotate -1000 -Inf -> NaN Invalid_operation
+rotx788 rotate -Inf -Inf -> NaN Invalid_operation
+rotx789 rotate -1 -Inf -> NaN Invalid_operation
+rotx790 rotate -0 -Inf -> NaN Invalid_operation
+rotx791 rotate 0 -Inf -> NaN Invalid_operation
+rotx792 rotate 1 -Inf -> NaN Invalid_operation
+rotx793 rotate 1000 -Inf -> NaN Invalid_operation
+rotx794 rotate Inf -Inf -> NaN Invalid_operation
+
+rotx800 rotate Inf -Inf -> NaN Invalid_operation
+rotx801 rotate Inf -8 -> Infinity
+rotx802 rotate Inf -1 -> Infinity
+rotx803 rotate Inf -0 -> Infinity
+rotx804 rotate Inf 0 -> Infinity
+rotx805 rotate Inf 1 -> Infinity
+rotx806 rotate Inf 8 -> Infinity
+rotx807 rotate Inf Inf -> NaN Invalid_operation
+rotx808 rotate -1000 Inf -> NaN Invalid_operation
+rotx809 rotate -Inf Inf -> NaN Invalid_operation
+rotx810 rotate -1 Inf -> NaN Invalid_operation
+rotx811 rotate -0 Inf -> NaN Invalid_operation
+rotx812 rotate 0 Inf -> NaN Invalid_operation
+rotx813 rotate 1 Inf -> NaN Invalid_operation
+rotx814 rotate 1000 Inf -> NaN Invalid_operation
+rotx815 rotate Inf Inf -> NaN Invalid_operation
+
+rotx821 rotate NaN -Inf -> NaN
+rotx822 rotate NaN -1000 -> NaN
+rotx823 rotate NaN -1 -> NaN
+rotx824 rotate NaN -0 -> NaN
+rotx825 rotate NaN 0 -> NaN
+rotx826 rotate NaN 1 -> NaN
+rotx827 rotate NaN 1000 -> NaN
+rotx828 rotate NaN Inf -> NaN
+rotx829 rotate NaN NaN -> NaN
+rotx830 rotate -Inf NaN -> NaN
+rotx831 rotate -1000 NaN -> NaN
+rotx832 rotate -1 NaN -> NaN
+rotx833 rotate -0 NaN -> NaN
+rotx834 rotate 0 NaN -> NaN
+rotx835 rotate 1 NaN -> NaN
+rotx836 rotate 1000 NaN -> NaN
+rotx837 rotate Inf NaN -> NaN
+
+
+
+rotx841 rotate sNaN -Inf -> NaN Invalid_operation
+rotx842 rotate sNaN -1000 -> NaN Invalid_operation
+rotx843 rotate sNaN -1 -> NaN Invalid_operation
+rotx844 rotate sNaN -0 -> NaN Invalid_operation
+rotx845 rotate sNaN 0 -> NaN Invalid_operation
+rotx846 rotate sNaN 1 -> NaN Invalid_operation
+rotx847 rotate sNaN 1000 -> NaN Invalid_operation
+rotx848 rotate sNaN NaN -> NaN Invalid_operation
+rotx849 rotate sNaN sNaN -> NaN Invalid_operation
+rotx850 rotate NaN sNaN -> NaN Invalid_operation
+rotx851 rotate -Inf sNaN -> NaN Invalid_operation
+rotx852 rotate -1000 sNaN -> NaN Invalid_operation
+rotx853 rotate -1 sNaN -> NaN Invalid_operation
+rotx854 rotate -0 sNaN -> NaN Invalid_operation
+rotx855 rotate 0 sNaN -> NaN Invalid_operation
+rotx856 rotate 1 sNaN -> NaN Invalid_operation
+rotx857 rotate 1000 sNaN -> NaN Invalid_operation
+rotx858 rotate Inf sNaN -> NaN Invalid_operation
+rotx859 rotate NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+rotx861 rotate NaN1 -Inf -> NaN1
+rotx862 rotate +NaN2 -1000 -> NaN2
+rotx863 rotate NaN3 1000 -> NaN3
+rotx864 rotate NaN4 Inf -> NaN4
+rotx865 rotate NaN5 +NaN6 -> NaN5
+rotx866 rotate -Inf NaN7 -> NaN7
+rotx867 rotate -1000 NaN8 -> NaN8
+rotx868 rotate 1000 NaN9 -> NaN9
+rotx869 rotate Inf +NaN10 -> NaN10
+rotx871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
+rotx872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
+rotx873 rotate sNaN13 1000 -> NaN13 Invalid_operation
+rotx874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
+rotx875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
+rotx876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
+rotx877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
+rotx878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
+rotx879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
+rotx880 rotate Inf sNaN23 -> NaN23 Invalid_operation
+rotx881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
+rotx882 rotate -NaN26 NaN28 -> -NaN26
+rotx883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+rotx884 rotate 1000 -NaN30 -> -NaN30
+rotx885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- payload decapitate
+precision: 5
+rotx886 rotate 11 -sNaN1234567890 -> -NaN67890 Invalid_operation
diff --git a/Lib/test/decimaltestdata/scaleb.decTest b/Lib/test/decimaltestdata/scaleb.decTest
index 04a65d6eae..372e3dd4c3 100644
--- a/Lib/test/decimaltestdata/scaleb.decTest
+++ b/Lib/test/decimaltestdata/scaleb.decTest
@@ -1,209 +1,209 @@
-------------------------------------------------------------------------
--- scaleb.decTest -- scale a number by powers of 10 --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Max |rhs| is 2*(999+9) = 2016
-
--- Sanity checks
-scbx001 scaleb 7.50 10 -> 7.50E+10
-scbx002 scaleb 7.50 3 -> 7.50E+3
-scbx003 scaleb 7.50 2 -> 750
-scbx004 scaleb 7.50 1 -> 75.0
-scbx005 scaleb 7.50 0 -> 7.50
-scbx006 scaleb 7.50 -1 -> 0.750
-scbx007 scaleb 7.50 -2 -> 0.0750
-scbx008 scaleb 7.50 -10 -> 7.50E-10
-scbx009 scaleb -7.50 3 -> -7.50E+3
-scbx010 scaleb -7.50 2 -> -750
-scbx011 scaleb -7.50 1 -> -75.0
-scbx012 scaleb -7.50 0 -> -7.50
-scbx013 scaleb -7.50 -1 -> -0.750
-
--- Infinities
-scbx014 scaleb Infinity 1 -> Infinity
-scbx015 scaleb -Infinity 2 -> -Infinity
-scbx016 scaleb Infinity -1 -> Infinity
-scbx017 scaleb -Infinity -2 -> -Infinity
-
--- Next two are somewhat undefined in 754r; treat as non-integer
-scbx018 scaleb 10 Infinity -> NaN Invalid_operation
-scbx019 scaleb 10 -Infinity -> NaN Invalid_operation
-
--- NaNs are undefined in 754r; assume usual processing
--- NaNs, 0 payload
-scbx021 scaleb NaN 1 -> NaN
-scbx022 scaleb -NaN -1 -> -NaN
-scbx023 scaleb sNaN 1 -> NaN Invalid_operation
-scbx024 scaleb -sNaN 1 -> -NaN Invalid_operation
-scbx025 scaleb 4 NaN -> NaN
-scbx026 scaleb -Inf -NaN -> -NaN
-scbx027 scaleb 4 sNaN -> NaN Invalid_operation
-scbx028 scaleb Inf -sNaN -> -NaN Invalid_operation
-
--- non-integer RHS
-scbx030 scaleb 1.23 1 -> 12.3
-scbx031 scaleb 1.23 1.00 -> NaN Invalid_operation
-scbx032 scaleb 1.23 1.1 -> NaN Invalid_operation
-scbx033 scaleb 1.23 1.01 -> NaN Invalid_operation
-scbx034 scaleb 1.23 0.01 -> NaN Invalid_operation
-scbx035 scaleb 1.23 0.11 -> NaN Invalid_operation
-scbx036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
-scbx037 scaleb 1.23 -1 -> 0.123
-scbx038 scaleb 1.23 -1.00 -> NaN Invalid_operation
-scbx039 scaleb 1.23 -1.1 -> NaN Invalid_operation
-scbx040 scaleb 1.23 -1.01 -> NaN Invalid_operation
-scbx041 scaleb 1.23 -0.01 -> NaN Invalid_operation
-scbx042 scaleb 1.23 -0.11 -> NaN Invalid_operation
-scbx043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
-scbx044 scaleb 1.23 0.1 -> NaN Invalid_operation
-scbx045 scaleb 1.23 1E+1 -> NaN Invalid_operation
-scbx046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
-scbx047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
-
-
-scbx120 scaleb 1.23 2015 -> Infinity Overflow Inexact Rounded
-scbx121 scaleb 1.23 2016 -> Infinity Overflow Inexact Rounded
-scbx122 scaleb 1.23 2017 -> NaN Invalid_operation
-scbx123 scaleb 1.23 2018 -> NaN Invalid_operation
-scbx124 scaleb 1.23 -2015 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
-scbx125 scaleb 1.23 -2016 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
-scbx126 scaleb 1.23 -2017 -> NaN Invalid_operation
-scbx127 scaleb 1.23 -2018 -> NaN Invalid_operation
-
--- NaNs, non-0 payload
--- propagating NaNs
-scbx861 scaleb NaN01 -Inf -> NaN1
-scbx862 scaleb -NaN02 -1000 -> -NaN2
-scbx863 scaleb NaN03 1000 -> NaN3
-scbx864 scaleb NaN04 Inf -> NaN4
-scbx865 scaleb NaN05 NaN61 -> NaN5
-scbx866 scaleb -Inf -NaN71 -> -NaN71
-scbx867 scaleb -1000 NaN81 -> NaN81
-scbx868 scaleb 1000 NaN91 -> NaN91
-scbx869 scaleb Inf NaN101 -> NaN101
-scbx871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
-scbx872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
-scbx873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
-scbx874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
-scbx875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
-scbx876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
-scbx877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
-scbx878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
-scbx879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
-scbx880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
-scbx881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- finites
-scbx051 scaleb 7 -2 -> 0.07
-scbx052 scaleb -7 -2 -> -0.07
-scbx053 scaleb 75 -2 -> 0.75
-scbx054 scaleb -75 -2 -> -0.75
-scbx055 scaleb 7.50 -2 -> 0.0750
-scbx056 scaleb -7.50 -2 -> -0.0750
-scbx057 scaleb 7.500 -2 -> 0.07500
-scbx058 scaleb -7.500 -2 -> -0.07500
-scbx061 scaleb 7 -1 -> 0.7
-scbx062 scaleb -7 -1 -> -0.7
-scbx063 scaleb 75 -1 -> 7.5
-scbx064 scaleb -75 -1 -> -7.5
-scbx065 scaleb 7.50 -1 -> 0.750
-scbx066 scaleb -7.50 -1 -> -0.750
-scbx067 scaleb 7.500 -1 -> 0.7500
-scbx068 scaleb -7.500 -1 -> -0.7500
-scbx071 scaleb 7 0 -> 7
-scbx072 scaleb -7 0 -> -7
-scbx073 scaleb 75 0 -> 75
-scbx074 scaleb -75 0 -> -75
-scbx075 scaleb 7.50 0 -> 7.50
-scbx076 scaleb -7.50 0 -> -7.50
-scbx077 scaleb 7.500 0 -> 7.500
-scbx078 scaleb -7.500 0 -> -7.500
-scbx081 scaleb 7 1 -> 7E+1
-scbx082 scaleb -7 1 -> -7E+1
-scbx083 scaleb 75 1 -> 7.5E+2
-scbx084 scaleb -75 1 -> -7.5E+2
-scbx085 scaleb 7.50 1 -> 75.0
-scbx086 scaleb -7.50 1 -> -75.0
-scbx087 scaleb 7.500 1 -> 75.00
-scbx088 scaleb -7.500 1 -> -75.00
-scbx091 scaleb 7 2 -> 7E+2
-scbx092 scaleb -7 2 -> -7E+2
-scbx093 scaleb 75 2 -> 7.5E+3
-scbx094 scaleb -75 2 -> -7.5E+3
-scbx095 scaleb 7.50 2 -> 750
-scbx096 scaleb -7.50 2 -> -750
-scbx097 scaleb 7.500 2 -> 750.0
-scbx098 scaleb -7.500 2 -> -750.0
-
--- zeros
-scbx111 scaleb 0 1 -> 0E+1
-scbx112 scaleb -0 2 -> -0E+2
-scbx113 scaleb 0E+4 3 -> 0E+7
-scbx114 scaleb -0E+4 4 -> -0E+8
-scbx115 scaleb 0.0000 5 -> 0E+1
-scbx116 scaleb -0.0000 6 -> -0E+2
-scbx117 scaleb 0E-141 7 -> 0E-134
-scbx118 scaleb -0E-141 8 -> -0E-133
-
--- Nmax, Nmin, Ntiny
-scbx132 scaleb 9.99999999E+999 +999 -> Infinity Overflow Inexact Rounded
-scbx133 scaleb 9.99999999E+999 +10 -> Infinity Overflow Inexact Rounded
-scbx134 scaleb 9.99999999E+999 +1 -> Infinity Overflow Inexact Rounded
-scbx135 scaleb 9.99999999E+999 0 -> 9.99999999E+999
-scbx136 scaleb 9.99999999E+999 -1 -> 9.99999999E+998
-scbx137 scaleb 1E-999 +1 -> 1E-998
-scbx138 scaleb 1E-999 -0 -> 1E-999
-scbx139 scaleb 1E-999 -1 -> 1E-1000 Subnormal
-scbx140 scaleb 1.00000000E-999 +1 -> 1.00000000E-998
-scbx141 scaleb 1.00000000E-999 0 -> 1.00000000E-999
-scbx142 scaleb 1.00000000E-999 -1 -> 1.0000000E-1000 Subnormal Rounded
-scbx143 scaleb 1E-1007 +1 -> 1E-1006 Subnormal
-scbx144 scaleb 1E-1007 -0 -> 1E-1007 Subnormal
-scbx145 scaleb 1E-1007 -1 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
-
-scbx150 scaleb -1E-1007 +1 -> -1E-1006 Subnormal
-scbx151 scaleb -1E-1007 -0 -> -1E-1007 Subnormal
-scbx152 scaleb -1E-1007 -1 -> -0E-1007 Underflow Subnormal Inexact Rounded Clamped
-scbx153 scaleb -1.00000000E-999 +1 -> -1.00000000E-998
-scbx154 scaleb -1.00000000E-999 +0 -> -1.00000000E-999
-scbx155 scaleb -1.00000000E-999 -1 -> -1.0000000E-1000 Subnormal Rounded
-scbx156 scaleb -1E-999 +1 -> -1E-998
-scbx157 scaleb -1E-999 -0 -> -1E-999
-scbx158 scaleb -1E-999 -1 -> -1E-1000 Subnormal
-scbx159 scaleb -9.99999999E+999 +1 -> -Infinity Overflow Inexact Rounded
-scbx160 scaleb -9.99999999E+999 +0 -> -9.99999999E+999
-scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998
-scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded
-scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded
-
--- Krah examples
-precision: 34
-maxExponent: 999999999
-minExponent: -999999999
--- integer overflow in 3.61 or earlier
-scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation
--- out of range
-scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- scaleb.decTest -- scale a number by powers of 10 --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Max |rhs| is 2*(999+9) = 2016
+
+-- Sanity checks
+scbx001 scaleb 7.50 10 -> 7.50E+10
+scbx002 scaleb 7.50 3 -> 7.50E+3
+scbx003 scaleb 7.50 2 -> 750
+scbx004 scaleb 7.50 1 -> 75.0
+scbx005 scaleb 7.50 0 -> 7.50
+scbx006 scaleb 7.50 -1 -> 0.750
+scbx007 scaleb 7.50 -2 -> 0.0750
+scbx008 scaleb 7.50 -10 -> 7.50E-10
+scbx009 scaleb -7.50 3 -> -7.50E+3
+scbx010 scaleb -7.50 2 -> -750
+scbx011 scaleb -7.50 1 -> -75.0
+scbx012 scaleb -7.50 0 -> -7.50
+scbx013 scaleb -7.50 -1 -> -0.750
+
+-- Infinities
+scbx014 scaleb Infinity 1 -> Infinity
+scbx015 scaleb -Infinity 2 -> -Infinity
+scbx016 scaleb Infinity -1 -> Infinity
+scbx017 scaleb -Infinity -2 -> -Infinity
+
+-- Next two are somewhat undefined in 754r; treat as non-integer
+scbx018 scaleb 10 Infinity -> NaN Invalid_operation
+scbx019 scaleb 10 -Infinity -> NaN Invalid_operation
+
+-- NaNs are undefined in 754r; assume usual processing
+-- NaNs, 0 payload
+scbx021 scaleb NaN 1 -> NaN
+scbx022 scaleb -NaN -1 -> -NaN
+scbx023 scaleb sNaN 1 -> NaN Invalid_operation
+scbx024 scaleb -sNaN 1 -> -NaN Invalid_operation
+scbx025 scaleb 4 NaN -> NaN
+scbx026 scaleb -Inf -NaN -> -NaN
+scbx027 scaleb 4 sNaN -> NaN Invalid_operation
+scbx028 scaleb Inf -sNaN -> -NaN Invalid_operation
+
+-- non-integer RHS
+scbx030 scaleb 1.23 1 -> 12.3
+scbx031 scaleb 1.23 1.00 -> NaN Invalid_operation
+scbx032 scaleb 1.23 1.1 -> NaN Invalid_operation
+scbx033 scaleb 1.23 1.01 -> NaN Invalid_operation
+scbx034 scaleb 1.23 0.01 -> NaN Invalid_operation
+scbx035 scaleb 1.23 0.11 -> NaN Invalid_operation
+scbx036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
+scbx037 scaleb 1.23 -1 -> 0.123
+scbx038 scaleb 1.23 -1.00 -> NaN Invalid_operation
+scbx039 scaleb 1.23 -1.1 -> NaN Invalid_operation
+scbx040 scaleb 1.23 -1.01 -> NaN Invalid_operation
+scbx041 scaleb 1.23 -0.01 -> NaN Invalid_operation
+scbx042 scaleb 1.23 -0.11 -> NaN Invalid_operation
+scbx043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
+scbx044 scaleb 1.23 0.1 -> NaN Invalid_operation
+scbx045 scaleb 1.23 1E+1 -> NaN Invalid_operation
+scbx046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
+scbx047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
+
+
+scbx120 scaleb 1.23 2015 -> Infinity Overflow Inexact Rounded
+scbx121 scaleb 1.23 2016 -> Infinity Overflow Inexact Rounded
+scbx122 scaleb 1.23 2017 -> NaN Invalid_operation
+scbx123 scaleb 1.23 2018 -> NaN Invalid_operation
+scbx124 scaleb 1.23 -2015 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
+scbx125 scaleb 1.23 -2016 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
+scbx126 scaleb 1.23 -2017 -> NaN Invalid_operation
+scbx127 scaleb 1.23 -2018 -> NaN Invalid_operation
+
+-- NaNs, non-0 payload
+-- propagating NaNs
+scbx861 scaleb NaN01 -Inf -> NaN1
+scbx862 scaleb -NaN02 -1000 -> -NaN2
+scbx863 scaleb NaN03 1000 -> NaN3
+scbx864 scaleb NaN04 Inf -> NaN4
+scbx865 scaleb NaN05 NaN61 -> NaN5
+scbx866 scaleb -Inf -NaN71 -> -NaN71
+scbx867 scaleb -1000 NaN81 -> NaN81
+scbx868 scaleb 1000 NaN91 -> NaN91
+scbx869 scaleb Inf NaN101 -> NaN101
+scbx871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
+scbx872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
+scbx873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
+scbx874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
+scbx875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
+scbx876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
+scbx877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
+scbx878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
+scbx879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
+scbx880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
+scbx881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- finites
+scbx051 scaleb 7 -2 -> 0.07
+scbx052 scaleb -7 -2 -> -0.07
+scbx053 scaleb 75 -2 -> 0.75
+scbx054 scaleb -75 -2 -> -0.75
+scbx055 scaleb 7.50 -2 -> 0.0750
+scbx056 scaleb -7.50 -2 -> -0.0750
+scbx057 scaleb 7.500 -2 -> 0.07500
+scbx058 scaleb -7.500 -2 -> -0.07500
+scbx061 scaleb 7 -1 -> 0.7
+scbx062 scaleb -7 -1 -> -0.7
+scbx063 scaleb 75 -1 -> 7.5
+scbx064 scaleb -75 -1 -> -7.5
+scbx065 scaleb 7.50 -1 -> 0.750
+scbx066 scaleb -7.50 -1 -> -0.750
+scbx067 scaleb 7.500 -1 -> 0.7500
+scbx068 scaleb -7.500 -1 -> -0.7500
+scbx071 scaleb 7 0 -> 7
+scbx072 scaleb -7 0 -> -7
+scbx073 scaleb 75 0 -> 75
+scbx074 scaleb -75 0 -> -75
+scbx075 scaleb 7.50 0 -> 7.50
+scbx076 scaleb -7.50 0 -> -7.50
+scbx077 scaleb 7.500 0 -> 7.500
+scbx078 scaleb -7.500 0 -> -7.500
+scbx081 scaleb 7 1 -> 7E+1
+scbx082 scaleb -7 1 -> -7E+1
+scbx083 scaleb 75 1 -> 7.5E+2
+scbx084 scaleb -75 1 -> -7.5E+2
+scbx085 scaleb 7.50 1 -> 75.0
+scbx086 scaleb -7.50 1 -> -75.0
+scbx087 scaleb 7.500 1 -> 75.00
+scbx088 scaleb -7.500 1 -> -75.00
+scbx091 scaleb 7 2 -> 7E+2
+scbx092 scaleb -7 2 -> -7E+2
+scbx093 scaleb 75 2 -> 7.5E+3
+scbx094 scaleb -75 2 -> -7.5E+3
+scbx095 scaleb 7.50 2 -> 750
+scbx096 scaleb -7.50 2 -> -750
+scbx097 scaleb 7.500 2 -> 750.0
+scbx098 scaleb -7.500 2 -> -750.0
+
+-- zeros
+scbx111 scaleb 0 1 -> 0E+1
+scbx112 scaleb -0 2 -> -0E+2
+scbx113 scaleb 0E+4 3 -> 0E+7
+scbx114 scaleb -0E+4 4 -> -0E+8
+scbx115 scaleb 0.0000 5 -> 0E+1
+scbx116 scaleb -0.0000 6 -> -0E+2
+scbx117 scaleb 0E-141 7 -> 0E-134
+scbx118 scaleb -0E-141 8 -> -0E-133
+
+-- Nmax, Nmin, Ntiny
+scbx132 scaleb 9.99999999E+999 +999 -> Infinity Overflow Inexact Rounded
+scbx133 scaleb 9.99999999E+999 +10 -> Infinity Overflow Inexact Rounded
+scbx134 scaleb 9.99999999E+999 +1 -> Infinity Overflow Inexact Rounded
+scbx135 scaleb 9.99999999E+999 0 -> 9.99999999E+999
+scbx136 scaleb 9.99999999E+999 -1 -> 9.99999999E+998
+scbx137 scaleb 1E-999 +1 -> 1E-998
+scbx138 scaleb 1E-999 -0 -> 1E-999
+scbx139 scaleb 1E-999 -1 -> 1E-1000 Subnormal
+scbx140 scaleb 1.00000000E-999 +1 -> 1.00000000E-998
+scbx141 scaleb 1.00000000E-999 0 -> 1.00000000E-999
+scbx142 scaleb 1.00000000E-999 -1 -> 1.0000000E-1000 Subnormal Rounded
+scbx143 scaleb 1E-1007 +1 -> 1E-1006 Subnormal
+scbx144 scaleb 1E-1007 -0 -> 1E-1007 Subnormal
+scbx145 scaleb 1E-1007 -1 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
+
+scbx150 scaleb -1E-1007 +1 -> -1E-1006 Subnormal
+scbx151 scaleb -1E-1007 -0 -> -1E-1007 Subnormal
+scbx152 scaleb -1E-1007 -1 -> -0E-1007 Underflow Subnormal Inexact Rounded Clamped
+scbx153 scaleb -1.00000000E-999 +1 -> -1.00000000E-998
+scbx154 scaleb -1.00000000E-999 +0 -> -1.00000000E-999
+scbx155 scaleb -1.00000000E-999 -1 -> -1.0000000E-1000 Subnormal Rounded
+scbx156 scaleb -1E-999 +1 -> -1E-998
+scbx157 scaleb -1E-999 -0 -> -1E-999
+scbx158 scaleb -1E-999 -1 -> -1E-1000 Subnormal
+scbx159 scaleb -9.99999999E+999 +1 -> -Infinity Overflow Inexact Rounded
+scbx160 scaleb -9.99999999E+999 +0 -> -9.99999999E+999
+scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998
+scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded
+scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded
+
+-- Krah examples
+precision: 34
+maxExponent: 999999999
+minExponent: -999999999
+-- integer overflow in 3.61 or earlier
+scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation
+-- out of range
+scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/shift.decTest b/Lib/test/decimaltestdata/shift.decTest
index 78838cc10d..3fac72f722 100644
--- a/Lib/test/decimaltestdata/shift.decTest
+++ b/Lib/test/decimaltestdata/shift.decTest
@@ -1,250 +1,250 @@
-------------------------------------------------------------------------
--- shift.decTest -- shift coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-shix001 shift 0 0 -> 0
-shix002 shift 0 2 -> 0
-shix003 shift 1 2 -> 100
-shix004 shift 1 8 -> 100000000
-shix005 shift 1 9 -> 0
-shix006 shift 1 -1 -> 0
-shix007 shift 123456789 -1 -> 12345678
-shix008 shift 123456789 -8 -> 1
-shix009 shift 123456789 -9 -> 0
-shix010 shift 0 -2 -> 0
-
--- rhs must be an integer
-shix011 shift 1 1.5 -> NaN Invalid_operation
-shix012 shift 1 1.0 -> NaN Invalid_operation
-shix013 shift 1 0.1 -> NaN Invalid_operation
-shix014 shift 1 0.0 -> NaN Invalid_operation
-shix015 shift 1 1E+1 -> NaN Invalid_operation
-shix016 shift 1 1E+99 -> NaN Invalid_operation
-shix017 shift 1 Inf -> NaN Invalid_operation
-shix018 shift 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-shix020 shift 1 -1000 -> NaN Invalid_operation
-shix021 shift 1 -10 -> NaN Invalid_operation
-shix022 shift 1 10 -> NaN Invalid_operation
-shix023 shift 1 1000 -> NaN Invalid_operation
-
--- full shifting pattern
-shix030 shift 123456789 -9 -> 0
-shix031 shift 123456789 -8 -> 1
-shix032 shift 123456789 -7 -> 12
-shix033 shift 123456789 -6 -> 123
-shix034 shift 123456789 -5 -> 1234
-shix035 shift 123456789 -4 -> 12345
-shix036 shift 123456789 -3 -> 123456
-shix037 shift 123456789 -2 -> 1234567
-shix038 shift 123456789 -1 -> 12345678
-shix039 shift 123456789 -0 -> 123456789
-shix040 shift 123456789 +0 -> 123456789
-shix041 shift 123456789 +1 -> 234567890
-shix042 shift 123456789 +2 -> 345678900
-shix043 shift 123456789 +3 -> 456789000
-shix044 shift 123456789 +4 -> 567890000
-shix045 shift 123456789 +5 -> 678900000
-shix046 shift 123456789 +6 -> 789000000
-shix047 shift 123456789 +7 -> 890000000
-shix048 shift 123456789 +8 -> 900000000
-shix049 shift 123456789 +9 -> 0
-
--- from examples
-shix051 shift 34 8 -> '400000000'
-shix052 shift 12 9 -> '0'
-shix053 shift 123456789 -2 -> '1234567'
-shix054 shift 123456789 0 -> '123456789'
-shix055 shift 123456789 +2 -> '345678900'
-
--- zeros
-shix060 shift 0E-10 +9 -> 0E-10
-shix061 shift 0E-10 -9 -> 0E-10
-shix062 shift 0.000 +9 -> 0.000
-shix063 shift 0.000 -9 -> 0.000
-shix064 shift 0E+10 +9 -> 0E+10
-shix065 shift 0E+10 -9 -> 0E+10
-shix066 shift -0E-10 +9 -> -0E-10
-shix067 shift -0E-10 -9 -> -0E-10
-shix068 shift -0.000 +9 -> -0.000
-shix069 shift -0.000 -9 -> -0.000
-shix070 shift -0E+10 +9 -> -0E+10
-shix071 shift -0E+10 -9 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-shix141 shift 9.99999999E+999 -1 -> 9.9999999E+998
-shix142 shift 9.99999999E+999 -8 -> 9E+991
-shix143 shift 9.99999999E+999 1 -> 9.99999990E+999
-shix144 shift 9.99999999E+999 8 -> 9.00000000E+999
-shix145 shift 1E-999 -1 -> 0E-999
-shix146 shift 1E-999 -8 -> 0E-999
-shix147 shift 1E-999 1 -> 1.0E-998
-shix148 shift 1E-999 8 -> 1.00000000E-991
-shix151 shift 1.00000000E-999 -1 -> 1.0000000E-1000
-shix152 shift 1.00000000E-999 -8 -> 1E-1007
-shix153 shift 1.00000000E-999 1 -> 0E-1007
-shix154 shift 1.00000000E-999 8 -> 0E-1007
-shix155 shift 9.00000000E-999 -1 -> 9.0000000E-1000
-shix156 shift 9.00000000E-999 -8 -> 9E-1007
-shix157 shift 9.00000000E-999 1 -> 0E-1007
-shix158 shift 9.00000000E-999 8 -> 0E-1007
-shix160 shift 1E-1007 -1 -> 0E-1007
-shix161 shift 1E-1007 -8 -> 0E-1007
-shix162 shift 1E-1007 1 -> 1.0E-1006
-shix163 shift 1E-1007 8 -> 1.00000000E-999
--- negatives
-shix171 shift -9.99999999E+999 -1 -> -9.9999999E+998
-shix172 shift -9.99999999E+999 -8 -> -9E+991
-shix173 shift -9.99999999E+999 1 -> -9.99999990E+999
-shix174 shift -9.99999999E+999 8 -> -9.00000000E+999
-shix175 shift -1E-999 -1 -> -0E-999
-shix176 shift -1E-999 -8 -> -0E-999
-shix177 shift -1E-999 1 -> -1.0E-998
-shix178 shift -1E-999 8 -> -1.00000000E-991
-shix181 shift -1.00000000E-999 -1 -> -1.0000000E-1000
-shix182 shift -1.00000000E-999 -8 -> -1E-1007
-shix183 shift -1.00000000E-999 1 -> -0E-1007
-shix184 shift -1.00000000E-999 8 -> -0E-1007
-shix185 shift -9.00000000E-999 -1 -> -9.0000000E-1000
-shix186 shift -9.00000000E-999 -8 -> -9E-1007
-shix187 shift -9.00000000E-999 1 -> -0E-1007
-shix188 shift -9.00000000E-999 8 -> -0E-1007
-shix190 shift -1E-1007 -1 -> -0E-1007
-shix191 shift -1E-1007 -8 -> -0E-1007
-shix192 shift -1E-1007 1 -> -1.0E-1006
-shix193 shift -1E-1007 8 -> -1.00000000E-999
-
--- more negatives (of sanities)
-shix201 shift -0 0 -> -0
-shix202 shift -0 2 -> -0
-shix203 shift -1 2 -> -100
-shix204 shift -1 8 -> -100000000
-shix205 shift -1 9 -> -0
-shix206 shift -1 -1 -> -0
-shix207 shift -123456789 -1 -> -12345678
-shix208 shift -123456789 -8 -> -1
-shix209 shift -123456789 -9 -> -0
-shix210 shift -0 -2 -> -0
-shix211 shift -0 -0 -> -0
-
-
--- Specials; NaNs are handled as usual
-shix781 shift -Inf -8 -> -Infinity
-shix782 shift -Inf -1 -> -Infinity
-shix783 shift -Inf -0 -> -Infinity
-shix784 shift -Inf 0 -> -Infinity
-shix785 shift -Inf 1 -> -Infinity
-shix786 shift -Inf 8 -> -Infinity
-shix787 shift -1000 -Inf -> NaN Invalid_operation
-shix788 shift -Inf -Inf -> NaN Invalid_operation
-shix789 shift -1 -Inf -> NaN Invalid_operation
-shix790 shift -0 -Inf -> NaN Invalid_operation
-shix791 shift 0 -Inf -> NaN Invalid_operation
-shix792 shift 1 -Inf -> NaN Invalid_operation
-shix793 shift 1000 -Inf -> NaN Invalid_operation
-shix794 shift Inf -Inf -> NaN Invalid_operation
-
-shix800 shift Inf -Inf -> NaN Invalid_operation
-shix801 shift Inf -8 -> Infinity
-shix802 shift Inf -1 -> Infinity
-shix803 shift Inf -0 -> Infinity
-shix804 shift Inf 0 -> Infinity
-shix805 shift Inf 1 -> Infinity
-shix806 shift Inf 8 -> Infinity
-shix807 shift Inf Inf -> NaN Invalid_operation
-shix808 shift -1000 Inf -> NaN Invalid_operation
-shix809 shift -Inf Inf -> NaN Invalid_operation
-shix810 shift -1 Inf -> NaN Invalid_operation
-shix811 shift -0 Inf -> NaN Invalid_operation
-shix812 shift 0 Inf -> NaN Invalid_operation
-shix813 shift 1 Inf -> NaN Invalid_operation
-shix814 shift 1000 Inf -> NaN Invalid_operation
-shix815 shift Inf Inf -> NaN Invalid_operation
-
-shix821 shift NaN -Inf -> NaN
-shix822 shift NaN -1000 -> NaN
-shix823 shift NaN -1 -> NaN
-shix824 shift NaN -0 -> NaN
-shix825 shift NaN 0 -> NaN
-shix826 shift NaN 1 -> NaN
-shix827 shift NaN 1000 -> NaN
-shix828 shift NaN Inf -> NaN
-shix829 shift NaN NaN -> NaN
-shix830 shift -Inf NaN -> NaN
-shix831 shift -1000 NaN -> NaN
-shix832 shift -1 NaN -> NaN
-shix833 shift -0 NaN -> NaN
-shix834 shift 0 NaN -> NaN
-shix835 shift 1 NaN -> NaN
-shix836 shift 1000 NaN -> NaN
-shix837 shift Inf NaN -> NaN
-
-shix841 shift sNaN -Inf -> NaN Invalid_operation
-shix842 shift sNaN -1000 -> NaN Invalid_operation
-shix843 shift sNaN -1 -> NaN Invalid_operation
-shix844 shift sNaN -0 -> NaN Invalid_operation
-shix845 shift sNaN 0 -> NaN Invalid_operation
-shix846 shift sNaN 1 -> NaN Invalid_operation
-shix847 shift sNaN 1000 -> NaN Invalid_operation
-shix848 shift sNaN NaN -> NaN Invalid_operation
-shix849 shift sNaN sNaN -> NaN Invalid_operation
-shix850 shift NaN sNaN -> NaN Invalid_operation
-shix851 shift -Inf sNaN -> NaN Invalid_operation
-shix852 shift -1000 sNaN -> NaN Invalid_operation
-shix853 shift -1 sNaN -> NaN Invalid_operation
-shix854 shift -0 sNaN -> NaN Invalid_operation
-shix855 shift 0 sNaN -> NaN Invalid_operation
-shix856 shift 1 sNaN -> NaN Invalid_operation
-shix857 shift 1000 sNaN -> NaN Invalid_operation
-shix858 shift Inf sNaN -> NaN Invalid_operation
-shix859 shift NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-shix861 shift NaN1 -Inf -> NaN1
-shix862 shift +NaN2 -1000 -> NaN2
-shix863 shift NaN3 1000 -> NaN3
-shix864 shift NaN4 Inf -> NaN4
-shix865 shift NaN5 +NaN6 -> NaN5
-shix866 shift -Inf NaN7 -> NaN7
-shix867 shift -1000 NaN8 -> NaN8
-shix868 shift 1000 NaN9 -> NaN9
-shix869 shift Inf +NaN10 -> NaN10
-shix871 shift sNaN11 -Inf -> NaN11 Invalid_operation
-shix872 shift sNaN12 -1000 -> NaN12 Invalid_operation
-shix873 shift sNaN13 1000 -> NaN13 Invalid_operation
-shix874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
-shix875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
-shix876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
-shix877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
-shix878 shift -1000 sNaN21 -> NaN21 Invalid_operation
-shix879 shift 1000 sNaN22 -> NaN22 Invalid_operation
-shix880 shift Inf sNaN23 -> NaN23 Invalid_operation
-shix881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
-shix882 shift -NaN26 NaN28 -> -NaN26
-shix883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-shix884 shift 1000 -NaN30 -> -NaN30
-shix885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- shift.decTest -- shift coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+shix001 shift 0 0 -> 0
+shix002 shift 0 2 -> 0
+shix003 shift 1 2 -> 100
+shix004 shift 1 8 -> 100000000
+shix005 shift 1 9 -> 0
+shix006 shift 1 -1 -> 0
+shix007 shift 123456789 -1 -> 12345678
+shix008 shift 123456789 -8 -> 1
+shix009 shift 123456789 -9 -> 0
+shix010 shift 0 -2 -> 0
+
+-- rhs must be an integer
+shix011 shift 1 1.5 -> NaN Invalid_operation
+shix012 shift 1 1.0 -> NaN Invalid_operation
+shix013 shift 1 0.1 -> NaN Invalid_operation
+shix014 shift 1 0.0 -> NaN Invalid_operation
+shix015 shift 1 1E+1 -> NaN Invalid_operation
+shix016 shift 1 1E+99 -> NaN Invalid_operation
+shix017 shift 1 Inf -> NaN Invalid_operation
+shix018 shift 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+shix020 shift 1 -1000 -> NaN Invalid_operation
+shix021 shift 1 -10 -> NaN Invalid_operation
+shix022 shift 1 10 -> NaN Invalid_operation
+shix023 shift 1 1000 -> NaN Invalid_operation
+
+-- full shifting pattern
+shix030 shift 123456789 -9 -> 0
+shix031 shift 123456789 -8 -> 1
+shix032 shift 123456789 -7 -> 12
+shix033 shift 123456789 -6 -> 123
+shix034 shift 123456789 -5 -> 1234
+shix035 shift 123456789 -4 -> 12345
+shix036 shift 123456789 -3 -> 123456
+shix037 shift 123456789 -2 -> 1234567
+shix038 shift 123456789 -1 -> 12345678
+shix039 shift 123456789 -0 -> 123456789
+shix040 shift 123456789 +0 -> 123456789
+shix041 shift 123456789 +1 -> 234567890
+shix042 shift 123456789 +2 -> 345678900
+shix043 shift 123456789 +3 -> 456789000
+shix044 shift 123456789 +4 -> 567890000
+shix045 shift 123456789 +5 -> 678900000
+shix046 shift 123456789 +6 -> 789000000
+shix047 shift 123456789 +7 -> 890000000
+shix048 shift 123456789 +8 -> 900000000
+shix049 shift 123456789 +9 -> 0
+
+-- from examples
+shix051 shift 34 8 -> '400000000'
+shix052 shift 12 9 -> '0'
+shix053 shift 123456789 -2 -> '1234567'
+shix054 shift 123456789 0 -> '123456789'
+shix055 shift 123456789 +2 -> '345678900'
+
+-- zeros
+shix060 shift 0E-10 +9 -> 0E-10
+shix061 shift 0E-10 -9 -> 0E-10
+shix062 shift 0.000 +9 -> 0.000
+shix063 shift 0.000 -9 -> 0.000
+shix064 shift 0E+10 +9 -> 0E+10
+shix065 shift 0E+10 -9 -> 0E+10
+shix066 shift -0E-10 +9 -> -0E-10
+shix067 shift -0E-10 -9 -> -0E-10
+shix068 shift -0.000 +9 -> -0.000
+shix069 shift -0.000 -9 -> -0.000
+shix070 shift -0E+10 +9 -> -0E+10
+shix071 shift -0E+10 -9 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+shix141 shift 9.99999999E+999 -1 -> 9.9999999E+998
+shix142 shift 9.99999999E+999 -8 -> 9E+991
+shix143 shift 9.99999999E+999 1 -> 9.99999990E+999
+shix144 shift 9.99999999E+999 8 -> 9.00000000E+999
+shix145 shift 1E-999 -1 -> 0E-999
+shix146 shift 1E-999 -8 -> 0E-999
+shix147 shift 1E-999 1 -> 1.0E-998
+shix148 shift 1E-999 8 -> 1.00000000E-991
+shix151 shift 1.00000000E-999 -1 -> 1.0000000E-1000
+shix152 shift 1.00000000E-999 -8 -> 1E-1007
+shix153 shift 1.00000000E-999 1 -> 0E-1007
+shix154 shift 1.00000000E-999 8 -> 0E-1007
+shix155 shift 9.00000000E-999 -1 -> 9.0000000E-1000
+shix156 shift 9.00000000E-999 -8 -> 9E-1007
+shix157 shift 9.00000000E-999 1 -> 0E-1007
+shix158 shift 9.00000000E-999 8 -> 0E-1007
+shix160 shift 1E-1007 -1 -> 0E-1007
+shix161 shift 1E-1007 -8 -> 0E-1007
+shix162 shift 1E-1007 1 -> 1.0E-1006
+shix163 shift 1E-1007 8 -> 1.00000000E-999
+-- negatives
+shix171 shift -9.99999999E+999 -1 -> -9.9999999E+998
+shix172 shift -9.99999999E+999 -8 -> -9E+991
+shix173 shift -9.99999999E+999 1 -> -9.99999990E+999
+shix174 shift -9.99999999E+999 8 -> -9.00000000E+999
+shix175 shift -1E-999 -1 -> -0E-999
+shix176 shift -1E-999 -8 -> -0E-999
+shix177 shift -1E-999 1 -> -1.0E-998
+shix178 shift -1E-999 8 -> -1.00000000E-991
+shix181 shift -1.00000000E-999 -1 -> -1.0000000E-1000
+shix182 shift -1.00000000E-999 -8 -> -1E-1007
+shix183 shift -1.00000000E-999 1 -> -0E-1007
+shix184 shift -1.00000000E-999 8 -> -0E-1007
+shix185 shift -9.00000000E-999 -1 -> -9.0000000E-1000
+shix186 shift -9.00000000E-999 -8 -> -9E-1007
+shix187 shift -9.00000000E-999 1 -> -0E-1007
+shix188 shift -9.00000000E-999 8 -> -0E-1007
+shix190 shift -1E-1007 -1 -> -0E-1007
+shix191 shift -1E-1007 -8 -> -0E-1007
+shix192 shift -1E-1007 1 -> -1.0E-1006
+shix193 shift -1E-1007 8 -> -1.00000000E-999
+
+-- more negatives (of sanities)
+shix201 shift -0 0 -> -0
+shix202 shift -0 2 -> -0
+shix203 shift -1 2 -> -100
+shix204 shift -1 8 -> -100000000
+shix205 shift -1 9 -> -0
+shix206 shift -1 -1 -> -0
+shix207 shift -123456789 -1 -> -12345678
+shix208 shift -123456789 -8 -> -1
+shix209 shift -123456789 -9 -> -0
+shix210 shift -0 -2 -> -0
+shix211 shift -0 -0 -> -0
+
+
+-- Specials; NaNs are handled as usual
+shix781 shift -Inf -8 -> -Infinity
+shix782 shift -Inf -1 -> -Infinity
+shix783 shift -Inf -0 -> -Infinity
+shix784 shift -Inf 0 -> -Infinity
+shix785 shift -Inf 1 -> -Infinity
+shix786 shift -Inf 8 -> -Infinity
+shix787 shift -1000 -Inf -> NaN Invalid_operation
+shix788 shift -Inf -Inf -> NaN Invalid_operation
+shix789 shift -1 -Inf -> NaN Invalid_operation
+shix790 shift -0 -Inf -> NaN Invalid_operation
+shix791 shift 0 -Inf -> NaN Invalid_operation
+shix792 shift 1 -Inf -> NaN Invalid_operation
+shix793 shift 1000 -Inf -> NaN Invalid_operation
+shix794 shift Inf -Inf -> NaN Invalid_operation
+
+shix800 shift Inf -Inf -> NaN Invalid_operation
+shix801 shift Inf -8 -> Infinity
+shix802 shift Inf -1 -> Infinity
+shix803 shift Inf -0 -> Infinity
+shix804 shift Inf 0 -> Infinity
+shix805 shift Inf 1 -> Infinity
+shix806 shift Inf 8 -> Infinity
+shix807 shift Inf Inf -> NaN Invalid_operation
+shix808 shift -1000 Inf -> NaN Invalid_operation
+shix809 shift -Inf Inf -> NaN Invalid_operation
+shix810 shift -1 Inf -> NaN Invalid_operation
+shix811 shift -0 Inf -> NaN Invalid_operation
+shix812 shift 0 Inf -> NaN Invalid_operation
+shix813 shift 1 Inf -> NaN Invalid_operation
+shix814 shift 1000 Inf -> NaN Invalid_operation
+shix815 shift Inf Inf -> NaN Invalid_operation
+
+shix821 shift NaN -Inf -> NaN
+shix822 shift NaN -1000 -> NaN
+shix823 shift NaN -1 -> NaN
+shix824 shift NaN -0 -> NaN
+shix825 shift NaN 0 -> NaN
+shix826 shift NaN 1 -> NaN
+shix827 shift NaN 1000 -> NaN
+shix828 shift NaN Inf -> NaN
+shix829 shift NaN NaN -> NaN
+shix830 shift -Inf NaN -> NaN
+shix831 shift -1000 NaN -> NaN
+shix832 shift -1 NaN -> NaN
+shix833 shift -0 NaN -> NaN
+shix834 shift 0 NaN -> NaN
+shix835 shift 1 NaN -> NaN
+shix836 shift 1000 NaN -> NaN
+shix837 shift Inf NaN -> NaN
+
+shix841 shift sNaN -Inf -> NaN Invalid_operation
+shix842 shift sNaN -1000 -> NaN Invalid_operation
+shix843 shift sNaN -1 -> NaN Invalid_operation
+shix844 shift sNaN -0 -> NaN Invalid_operation
+shix845 shift sNaN 0 -> NaN Invalid_operation
+shix846 shift sNaN 1 -> NaN Invalid_operation
+shix847 shift sNaN 1000 -> NaN Invalid_operation
+shix848 shift sNaN NaN -> NaN Invalid_operation
+shix849 shift sNaN sNaN -> NaN Invalid_operation
+shix850 shift NaN sNaN -> NaN Invalid_operation
+shix851 shift -Inf sNaN -> NaN Invalid_operation
+shix852 shift -1000 sNaN -> NaN Invalid_operation
+shix853 shift -1 sNaN -> NaN Invalid_operation
+shix854 shift -0 sNaN -> NaN Invalid_operation
+shix855 shift 0 sNaN -> NaN Invalid_operation
+shix856 shift 1 sNaN -> NaN Invalid_operation
+shix857 shift 1000 sNaN -> NaN Invalid_operation
+shix858 shift Inf sNaN -> NaN Invalid_operation
+shix859 shift NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+shix861 shift NaN1 -Inf -> NaN1
+shix862 shift +NaN2 -1000 -> NaN2
+shix863 shift NaN3 1000 -> NaN3
+shix864 shift NaN4 Inf -> NaN4
+shix865 shift NaN5 +NaN6 -> NaN5
+shix866 shift -Inf NaN7 -> NaN7
+shix867 shift -1000 NaN8 -> NaN8
+shix868 shift 1000 NaN9 -> NaN9
+shix869 shift Inf +NaN10 -> NaN10
+shix871 shift sNaN11 -Inf -> NaN11 Invalid_operation
+shix872 shift sNaN12 -1000 -> NaN12 Invalid_operation
+shix873 shift sNaN13 1000 -> NaN13 Invalid_operation
+shix874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
+shix875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
+shix876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
+shix877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
+shix878 shift -1000 sNaN21 -> NaN21 Invalid_operation
+shix879 shift 1000 sNaN22 -> NaN22 Invalid_operation
+shix880 shift Inf sNaN23 -> NaN23 Invalid_operation
+shix881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
+shix882 shift -NaN26 NaN28 -> -NaN26
+shix883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+shix884 shift 1000 -NaN30 -> -NaN30
+shix885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/tointegralx.decTest b/Lib/test/decimaltestdata/tointegralx.decTest
index e250e3a06e..0ce0d0935e 100644
--- a/Lib/test/decimaltestdata/tointegralx.decTest
+++ b/Lib/test/decimaltestdata/tointegralx.decTest
@@ -1,255 +1,255 @@
-------------------------------------------------------------------------
--- tointegralx.decTest -- round decimal to integral value, exact --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests tests the extended specification 'round-to-integral
--- value' operation (from IEEE 854, later modified in 754r).
--- All non-zero results are defined as being those from either copy or
--- quantize, so those are assumed to have been tested.
-
--- This tests toIntegraExact, which may set Inexact
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
-intxx001 tointegralx 0 -> 0
-intxx002 tointegralx 0.0 -> 0
-intxx003 tointegralx 0.1 -> 0 Inexact Rounded
-intxx004 tointegralx 0.2 -> 0 Inexact Rounded
-intxx005 tointegralx 0.3 -> 0 Inexact Rounded
-intxx006 tointegralx 0.4 -> 0 Inexact Rounded
-intxx007 tointegralx 0.5 -> 1 Inexact Rounded
-intxx008 tointegralx 0.6 -> 1 Inexact Rounded
-intxx009 tointegralx 0.7 -> 1 Inexact Rounded
-intxx010 tointegralx 0.8 -> 1 Inexact Rounded
-intxx011 tointegralx 0.9 -> 1 Inexact Rounded
-intxx012 tointegralx 1 -> 1
-intxx013 tointegralx 1.0 -> 1 Rounded
-intxx014 tointegralx 1.1 -> 1 Inexact Rounded
-intxx015 tointegralx 1.2 -> 1 Inexact Rounded
-intxx016 tointegralx 1.3 -> 1 Inexact Rounded
-intxx017 tointegralx 1.4 -> 1 Inexact Rounded
-intxx018 tointegralx 1.5 -> 2 Inexact Rounded
-intxx019 tointegralx 1.6 -> 2 Inexact Rounded
-intxx020 tointegralx 1.7 -> 2 Inexact Rounded
-intxx021 tointegralx 1.8 -> 2 Inexact Rounded
-intxx022 tointegralx 1.9 -> 2 Inexact Rounded
--- negatives
-intxx031 tointegralx -0 -> -0
-intxx032 tointegralx -0.0 -> -0
-intxx033 tointegralx -0.1 -> -0 Inexact Rounded
-intxx034 tointegralx -0.2 -> -0 Inexact Rounded
-intxx035 tointegralx -0.3 -> -0 Inexact Rounded
-intxx036 tointegralx -0.4 -> -0 Inexact Rounded
-intxx037 tointegralx -0.5 -> -1 Inexact Rounded
-intxx038 tointegralx -0.6 -> -1 Inexact Rounded
-intxx039 tointegralx -0.7 -> -1 Inexact Rounded
-intxx040 tointegralx -0.8 -> -1 Inexact Rounded
-intxx041 tointegralx -0.9 -> -1 Inexact Rounded
-intxx042 tointegralx -1 -> -1
-intxx043 tointegralx -1.0 -> -1 Rounded
-intxx044 tointegralx -1.1 -> -1 Inexact Rounded
-intxx045 tointegralx -1.2 -> -1 Inexact Rounded
-intxx046 tointegralx -1.3 -> -1 Inexact Rounded
-intxx047 tointegralx -1.4 -> -1 Inexact Rounded
-intxx048 tointegralx -1.5 -> -2 Inexact Rounded
-intxx049 tointegralx -1.6 -> -2 Inexact Rounded
-intxx050 tointegralx -1.7 -> -2 Inexact Rounded
-intxx051 tointegralx -1.8 -> -2 Inexact Rounded
-intxx052 tointegralx -1.9 -> -2 Inexact Rounded
--- next two would be NaN using quantize(x, 0)
-intxx053 tointegralx 10E+30 -> 1.0E+31
-intxx054 tointegralx -10E+30 -> -1.0E+31
-
--- numbers around precision
-precision: 9
-intxx060 tointegralx '56267E-10' -> '0' Inexact Rounded
-intxx061 tointegralx '56267E-5' -> '1' Inexact Rounded
-intxx062 tointegralx '56267E-2' -> '563' Inexact Rounded
-intxx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
-intxx065 tointegralx '56267E-0' -> '56267'
-intxx066 tointegralx '56267E+0' -> '56267'
-intxx067 tointegralx '56267E+1' -> '5.6267E+5'
-intxx068 tointegralx '56267E+2' -> '5.6267E+6'
-intxx069 tointegralx '56267E+3' -> '5.6267E+7'
-intxx070 tointegralx '56267E+4' -> '5.6267E+8'
-intxx071 tointegralx '56267E+5' -> '5.6267E+9'
-intxx072 tointegralx '56267E+6' -> '5.6267E+10'
-intxx073 tointegralx '1.23E+96' -> '1.23E+96'
-intxx074 tointegralx '1.23E+384' -> '1.23E+384'
-intxx075 tointegralx '1.23E+999' -> '1.23E+999'
-
-intxx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
-intxx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
-intxx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
-intxx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
-intxx085 tointegralx '-56267E-0' -> '-56267'
-intxx086 tointegralx '-56267E+0' -> '-56267'
-intxx087 tointegralx '-56267E+1' -> '-5.6267E+5'
-intxx088 tointegralx '-56267E+2' -> '-5.6267E+6'
-intxx089 tointegralx '-56267E+3' -> '-5.6267E+7'
-intxx090 tointegralx '-56267E+4' -> '-5.6267E+8'
-intxx091 tointegralx '-56267E+5' -> '-5.6267E+9'
-intxx092 tointegralx '-56267E+6' -> '-5.6267E+10'
-intxx093 tointegralx '-1.23E+96' -> '-1.23E+96'
-intxx094 tointegralx '-1.23E+384' -> '-1.23E+384'
-intxx095 tointegralx '-1.23E+999' -> '-1.23E+999'
-
--- subnormal inputs
-intxx100 tointegralx 1E-999 -> 0 Inexact Rounded
-intxx101 tointegralx 0.1E-999 -> 0 Inexact Rounded
-intxx102 tointegralx 0.01E-999 -> 0 Inexact Rounded
-intxx103 tointegralx 0E-999 -> 0
-
--- specials and zeros
-intxx120 tointegralx 'Inf' -> Infinity
-intxx121 tointegralx '-Inf' -> -Infinity
-intxx122 tointegralx NaN -> NaN
-intxx123 tointegralx sNaN -> NaN Invalid_operation
-intxx124 tointegralx 0 -> 0
-intxx125 tointegralx -0 -> -0
-intxx126 tointegralx 0.000 -> 0
-intxx127 tointegralx 0.00 -> 0
-intxx128 tointegralx 0.0 -> 0
-intxx129 tointegralx 0 -> 0
-intxx130 tointegralx 0E-3 -> 0
-intxx131 tointegralx 0E-2 -> 0
-intxx132 tointegralx 0E-1 -> 0
-intxx133 tointegralx 0E-0 -> 0
-intxx134 tointegralx 0E+1 -> 0E+1
-intxx135 tointegralx 0E+2 -> 0E+2
-intxx136 tointegralx 0E+3 -> 0E+3
-intxx137 tointegralx 0E+4 -> 0E+4
-intxx138 tointegralx 0E+5 -> 0E+5
-intxx139 tointegralx -0.000 -> -0
-intxx140 tointegralx -0.00 -> -0
-intxx141 tointegralx -0.0 -> -0
-intxx142 tointegralx -0 -> -0
-intxx143 tointegralx -0E-3 -> -0
-intxx144 tointegralx -0E-2 -> -0
-intxx145 tointegralx -0E-1 -> -0
-intxx146 tointegralx -0E-0 -> -0
-intxx147 tointegralx -0E+1 -> -0E+1
-intxx148 tointegralx -0E+2 -> -0E+2
-intxx149 tointegralx -0E+3 -> -0E+3
-intxx150 tointegralx -0E+4 -> -0E+4
-intxx151 tointegralx -0E+5 -> -0E+5
--- propagating NaNs
-intxx152 tointegralx NaN808 -> NaN808
-intxx153 tointegralx sNaN080 -> NaN80 Invalid_operation
-intxx154 tointegralx -NaN808 -> -NaN808
-intxx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
-intxx156 tointegralx -NaN -> -NaN
-intxx157 tointegralx -sNaN -> -NaN Invalid_operation
-
--- examples
-rounding: half_up
-precision: 9
-intxx200 tointegralx 2.1 -> 2 Inexact Rounded
-intxx201 tointegralx 100 -> 100
-intxx202 tointegralx 100.0 -> 100 Rounded
-intxx203 tointegralx 101.5 -> 102 Inexact Rounded
-intxx204 tointegralx -101.5 -> -102 Inexact Rounded
-intxx205 tointegralx 10E+5 -> 1.0E+6
-intxx206 tointegralx 7.89E+77 -> 7.89E+77
-intxx207 tointegralx -Inf -> -Infinity
-
-
--- all rounding modes
-rounding: half_even
-
-intxx210 tointegralx 55.5 -> 56 Inexact Rounded
-intxx211 tointegralx 56.5 -> 56 Inexact Rounded
-intxx212 tointegralx 57.5 -> 58 Inexact Rounded
-intxx213 tointegralx -55.5 -> -56 Inexact Rounded
-intxx214 tointegralx -56.5 -> -56 Inexact Rounded
-intxx215 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_up
-
-intxx220 tointegralx 55.5 -> 56 Inexact Rounded
-intxx221 tointegralx 56.5 -> 57 Inexact Rounded
-intxx222 tointegralx 57.5 -> 58 Inexact Rounded
-intxx223 tointegralx -55.5 -> -56 Inexact Rounded
-intxx224 tointegralx -56.5 -> -57 Inexact Rounded
-intxx225 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_down
-
-intxx230 tointegralx 55.5 -> 55 Inexact Rounded
-intxx231 tointegralx 56.5 -> 56 Inexact Rounded
-intxx232 tointegralx 57.5 -> 57 Inexact Rounded
-intxx233 tointegralx -55.5 -> -55 Inexact Rounded
-intxx234 tointegralx -56.5 -> -56 Inexact Rounded
-intxx235 tointegralx -57.5 -> -57 Inexact Rounded
-
-rounding: up
-
-intxx240 tointegralx 55.3 -> 56 Inexact Rounded
-intxx241 tointegralx 56.3 -> 57 Inexact Rounded
-intxx242 tointegralx 57.3 -> 58 Inexact Rounded
-intxx243 tointegralx -55.3 -> -56 Inexact Rounded
-intxx244 tointegralx -56.3 -> -57 Inexact Rounded
-intxx245 tointegralx -57.3 -> -58 Inexact Rounded
-
-rounding: down
-
-intxx250 tointegralx 55.7 -> 55 Inexact Rounded
-intxx251 tointegralx 56.7 -> 56 Inexact Rounded
-intxx252 tointegralx 57.7 -> 57 Inexact Rounded
-intxx253 tointegralx -55.7 -> -55 Inexact Rounded
-intxx254 tointegralx -56.7 -> -56 Inexact Rounded
-intxx255 tointegralx -57.7 -> -57 Inexact Rounded
-
-rounding: ceiling
-
-intxx260 tointegralx 55.3 -> 56 Inexact Rounded
-intxx261 tointegralx 56.3 -> 57 Inexact Rounded
-intxx262 tointegralx 57.3 -> 58 Inexact Rounded
-intxx263 tointegralx -55.3 -> -55 Inexact Rounded
-intxx264 tointegralx -56.3 -> -56 Inexact Rounded
-intxx265 tointegralx -57.3 -> -57 Inexact Rounded
-
-rounding: floor
-
-intxx270 tointegralx 55.7 -> 55 Inexact Rounded
-intxx271 tointegralx 56.7 -> 56 Inexact Rounded
-intxx272 tointegralx 57.7 -> 57 Inexact Rounded
-intxx273 tointegralx -55.7 -> -56 Inexact Rounded
-intxx274 tointegralx -56.7 -> -57 Inexact Rounded
-intxx275 tointegralx -57.7 -> -58 Inexact Rounded
-
--- Int and uInt32 edge values for testing conversions
-precision: 16
-intxx300 tointegralx -2147483646 -> -2147483646
-intxx301 tointegralx -2147483647 -> -2147483647
-intxx302 tointegralx -2147483648 -> -2147483648
-intxx303 tointegralx -2147483649 -> -2147483649
-intxx304 tointegralx 2147483646 -> 2147483646
-intxx305 tointegralx 2147483647 -> 2147483647
-intxx306 tointegralx 2147483648 -> 2147483648
-intxx307 tointegralx 2147483649 -> 2147483649
-intxx308 tointegralx 4294967294 -> 4294967294
-intxx309 tointegralx 4294967295 -> 4294967295
-intxx310 tointegralx 4294967296 -> 4294967296
-intxx311 tointegralx 4294967297 -> 4294967297
+------------------------------------------------------------------------
+-- tointegralx.decTest -- round decimal to integral value, exact --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests tests the extended specification 'round-to-integral
+-- value' operation (from IEEE 854, later modified in 754r).
+-- All non-zero results are defined as being those from either copy or
+-- quantize, so those are assumed to have been tested.
+
+-- This tests toIntegraExact, which may set Inexact
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+intxx001 tointegralx 0 -> 0
+intxx002 tointegralx 0.0 -> 0
+intxx003 tointegralx 0.1 -> 0 Inexact Rounded
+intxx004 tointegralx 0.2 -> 0 Inexact Rounded
+intxx005 tointegralx 0.3 -> 0 Inexact Rounded
+intxx006 tointegralx 0.4 -> 0 Inexact Rounded
+intxx007 tointegralx 0.5 -> 1 Inexact Rounded
+intxx008 tointegralx 0.6 -> 1 Inexact Rounded
+intxx009 tointegralx 0.7 -> 1 Inexact Rounded
+intxx010 tointegralx 0.8 -> 1 Inexact Rounded
+intxx011 tointegralx 0.9 -> 1 Inexact Rounded
+intxx012 tointegralx 1 -> 1
+intxx013 tointegralx 1.0 -> 1 Rounded
+intxx014 tointegralx 1.1 -> 1 Inexact Rounded
+intxx015 tointegralx 1.2 -> 1 Inexact Rounded
+intxx016 tointegralx 1.3 -> 1 Inexact Rounded
+intxx017 tointegralx 1.4 -> 1 Inexact Rounded
+intxx018 tointegralx 1.5 -> 2 Inexact Rounded
+intxx019 tointegralx 1.6 -> 2 Inexact Rounded
+intxx020 tointegralx 1.7 -> 2 Inexact Rounded
+intxx021 tointegralx 1.8 -> 2 Inexact Rounded
+intxx022 tointegralx 1.9 -> 2 Inexact Rounded
+-- negatives
+intxx031 tointegralx -0 -> -0
+intxx032 tointegralx -0.0 -> -0
+intxx033 tointegralx -0.1 -> -0 Inexact Rounded
+intxx034 tointegralx -0.2 -> -0 Inexact Rounded
+intxx035 tointegralx -0.3 -> -0 Inexact Rounded
+intxx036 tointegralx -0.4 -> -0 Inexact Rounded
+intxx037 tointegralx -0.5 -> -1 Inexact Rounded
+intxx038 tointegralx -0.6 -> -1 Inexact Rounded
+intxx039 tointegralx -0.7 -> -1 Inexact Rounded
+intxx040 tointegralx -0.8 -> -1 Inexact Rounded
+intxx041 tointegralx -0.9 -> -1 Inexact Rounded
+intxx042 tointegralx -1 -> -1
+intxx043 tointegralx -1.0 -> -1 Rounded
+intxx044 tointegralx -1.1 -> -1 Inexact Rounded
+intxx045 tointegralx -1.2 -> -1 Inexact Rounded
+intxx046 tointegralx -1.3 -> -1 Inexact Rounded
+intxx047 tointegralx -1.4 -> -1 Inexact Rounded
+intxx048 tointegralx -1.5 -> -2 Inexact Rounded
+intxx049 tointegralx -1.6 -> -2 Inexact Rounded
+intxx050 tointegralx -1.7 -> -2 Inexact Rounded
+intxx051 tointegralx -1.8 -> -2 Inexact Rounded
+intxx052 tointegralx -1.9 -> -2 Inexact Rounded
+-- next two would be NaN using quantize(x, 0)
+intxx053 tointegralx 10E+30 -> 1.0E+31
+intxx054 tointegralx -10E+30 -> -1.0E+31
+
+-- numbers around precision
+precision: 9
+intxx060 tointegralx '56267E-10' -> '0' Inexact Rounded
+intxx061 tointegralx '56267E-5' -> '1' Inexact Rounded
+intxx062 tointegralx '56267E-2' -> '563' Inexact Rounded
+intxx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
+intxx065 tointegralx '56267E-0' -> '56267'
+intxx066 tointegralx '56267E+0' -> '56267'
+intxx067 tointegralx '56267E+1' -> '5.6267E+5'
+intxx068 tointegralx '56267E+2' -> '5.6267E+6'
+intxx069 tointegralx '56267E+3' -> '5.6267E+7'
+intxx070 tointegralx '56267E+4' -> '5.6267E+8'
+intxx071 tointegralx '56267E+5' -> '5.6267E+9'
+intxx072 tointegralx '56267E+6' -> '5.6267E+10'
+intxx073 tointegralx '1.23E+96' -> '1.23E+96'
+intxx074 tointegralx '1.23E+384' -> '1.23E+384'
+intxx075 tointegralx '1.23E+999' -> '1.23E+999'
+
+intxx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
+intxx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
+intxx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
+intxx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
+intxx085 tointegralx '-56267E-0' -> '-56267'
+intxx086 tointegralx '-56267E+0' -> '-56267'
+intxx087 tointegralx '-56267E+1' -> '-5.6267E+5'
+intxx088 tointegralx '-56267E+2' -> '-5.6267E+6'
+intxx089 tointegralx '-56267E+3' -> '-5.6267E+7'
+intxx090 tointegralx '-56267E+4' -> '-5.6267E+8'
+intxx091 tointegralx '-56267E+5' -> '-5.6267E+9'
+intxx092 tointegralx '-56267E+6' -> '-5.6267E+10'
+intxx093 tointegralx '-1.23E+96' -> '-1.23E+96'
+intxx094 tointegralx '-1.23E+384' -> '-1.23E+384'
+intxx095 tointegralx '-1.23E+999' -> '-1.23E+999'
+
+-- subnormal inputs
+intxx100 tointegralx 1E-999 -> 0 Inexact Rounded
+intxx101 tointegralx 0.1E-999 -> 0 Inexact Rounded
+intxx102 tointegralx 0.01E-999 -> 0 Inexact Rounded
+intxx103 tointegralx 0E-999 -> 0
+
+-- specials and zeros
+intxx120 tointegralx 'Inf' -> Infinity
+intxx121 tointegralx '-Inf' -> -Infinity
+intxx122 tointegralx NaN -> NaN
+intxx123 tointegralx sNaN -> NaN Invalid_operation
+intxx124 tointegralx 0 -> 0
+intxx125 tointegralx -0 -> -0
+intxx126 tointegralx 0.000 -> 0
+intxx127 tointegralx 0.00 -> 0
+intxx128 tointegralx 0.0 -> 0
+intxx129 tointegralx 0 -> 0
+intxx130 tointegralx 0E-3 -> 0
+intxx131 tointegralx 0E-2 -> 0
+intxx132 tointegralx 0E-1 -> 0
+intxx133 tointegralx 0E-0 -> 0
+intxx134 tointegralx 0E+1 -> 0E+1
+intxx135 tointegralx 0E+2 -> 0E+2
+intxx136 tointegralx 0E+3 -> 0E+3
+intxx137 tointegralx 0E+4 -> 0E+4
+intxx138 tointegralx 0E+5 -> 0E+5
+intxx139 tointegralx -0.000 -> -0
+intxx140 tointegralx -0.00 -> -0
+intxx141 tointegralx -0.0 -> -0
+intxx142 tointegralx -0 -> -0
+intxx143 tointegralx -0E-3 -> -0
+intxx144 tointegralx -0E-2 -> -0
+intxx145 tointegralx -0E-1 -> -0
+intxx146 tointegralx -0E-0 -> -0
+intxx147 tointegralx -0E+1 -> -0E+1
+intxx148 tointegralx -0E+2 -> -0E+2
+intxx149 tointegralx -0E+3 -> -0E+3
+intxx150 tointegralx -0E+4 -> -0E+4
+intxx151 tointegralx -0E+5 -> -0E+5
+-- propagating NaNs
+intxx152 tointegralx NaN808 -> NaN808
+intxx153 tointegralx sNaN080 -> NaN80 Invalid_operation
+intxx154 tointegralx -NaN808 -> -NaN808
+intxx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
+intxx156 tointegralx -NaN -> -NaN
+intxx157 tointegralx -sNaN -> -NaN Invalid_operation
+
+-- examples
+rounding: half_up
+precision: 9
+intxx200 tointegralx 2.1 -> 2 Inexact Rounded
+intxx201 tointegralx 100 -> 100
+intxx202 tointegralx 100.0 -> 100 Rounded
+intxx203 tointegralx 101.5 -> 102 Inexact Rounded
+intxx204 tointegralx -101.5 -> -102 Inexact Rounded
+intxx205 tointegralx 10E+5 -> 1.0E+6
+intxx206 tointegralx 7.89E+77 -> 7.89E+77
+intxx207 tointegralx -Inf -> -Infinity
+
+
+-- all rounding modes
+rounding: half_even
+
+intxx210 tointegralx 55.5 -> 56 Inexact Rounded
+intxx211 tointegralx 56.5 -> 56 Inexact Rounded
+intxx212 tointegralx 57.5 -> 58 Inexact Rounded
+intxx213 tointegralx -55.5 -> -56 Inexact Rounded
+intxx214 tointegralx -56.5 -> -56 Inexact Rounded
+intxx215 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_up
+
+intxx220 tointegralx 55.5 -> 56 Inexact Rounded
+intxx221 tointegralx 56.5 -> 57 Inexact Rounded
+intxx222 tointegralx 57.5 -> 58 Inexact Rounded
+intxx223 tointegralx -55.5 -> -56 Inexact Rounded
+intxx224 tointegralx -56.5 -> -57 Inexact Rounded
+intxx225 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_down
+
+intxx230 tointegralx 55.5 -> 55 Inexact Rounded
+intxx231 tointegralx 56.5 -> 56 Inexact Rounded
+intxx232 tointegralx 57.5 -> 57 Inexact Rounded
+intxx233 tointegralx -55.5 -> -55 Inexact Rounded
+intxx234 tointegralx -56.5 -> -56 Inexact Rounded
+intxx235 tointegralx -57.5 -> -57 Inexact Rounded
+
+rounding: up
+
+intxx240 tointegralx 55.3 -> 56 Inexact Rounded
+intxx241 tointegralx 56.3 -> 57 Inexact Rounded
+intxx242 tointegralx 57.3 -> 58 Inexact Rounded
+intxx243 tointegralx -55.3 -> -56 Inexact Rounded
+intxx244 tointegralx -56.3 -> -57 Inexact Rounded
+intxx245 tointegralx -57.3 -> -58 Inexact Rounded
+
+rounding: down
+
+intxx250 tointegralx 55.7 -> 55 Inexact Rounded
+intxx251 tointegralx 56.7 -> 56 Inexact Rounded
+intxx252 tointegralx 57.7 -> 57 Inexact Rounded
+intxx253 tointegralx -55.7 -> -55 Inexact Rounded
+intxx254 tointegralx -56.7 -> -56 Inexact Rounded
+intxx255 tointegralx -57.7 -> -57 Inexact Rounded
+
+rounding: ceiling
+
+intxx260 tointegralx 55.3 -> 56 Inexact Rounded
+intxx261 tointegralx 56.3 -> 57 Inexact Rounded
+intxx262 tointegralx 57.3 -> 58 Inexact Rounded
+intxx263 tointegralx -55.3 -> -55 Inexact Rounded
+intxx264 tointegralx -56.3 -> -56 Inexact Rounded
+intxx265 tointegralx -57.3 -> -57 Inexact Rounded
+
+rounding: floor
+
+intxx270 tointegralx 55.7 -> 55 Inexact Rounded
+intxx271 tointegralx 56.7 -> 56 Inexact Rounded
+intxx272 tointegralx 57.7 -> 57 Inexact Rounded
+intxx273 tointegralx -55.7 -> -56 Inexact Rounded
+intxx274 tointegralx -56.7 -> -57 Inexact Rounded
+intxx275 tointegralx -57.7 -> -58 Inexact Rounded
+
+-- Int and uInt32 edge values for testing conversions
+precision: 16
+intxx300 tointegralx -2147483646 -> -2147483646
+intxx301 tointegralx -2147483647 -> -2147483647
+intxx302 tointegralx -2147483648 -> -2147483648
+intxx303 tointegralx -2147483649 -> -2147483649
+intxx304 tointegralx 2147483646 -> 2147483646
+intxx305 tointegralx 2147483647 -> 2147483647
+intxx306 tointegralx 2147483648 -> 2147483648
+intxx307 tointegralx 2147483649 -> 2147483649
+intxx308 tointegralx 4294967294 -> 4294967294
+intxx309 tointegralx 4294967295 -> 4294967295
+intxx310 tointegralx 4294967296 -> 4294967296
+intxx311 tointegralx 4294967297 -> 4294967297
diff --git a/Lib/test/decimaltestdata/xor.decTest b/Lib/test/decimaltestdata/xor.decTest
index 122976e44c..cd71bbcf86 100644
--- a/Lib/test/decimaltestdata/xor.decTest
+++ b/Lib/test/decimaltestdata/xor.decTest
@@ -1,335 +1,335 @@
-------------------------------------------------------------------------
--- xor.decTest -- digitwise logical XOR --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check (truth table)
-xorx001 xor 0 0 -> 0
-xorx002 xor 0 1 -> 1
-xorx003 xor 1 0 -> 1
-xorx004 xor 1 1 -> 0
-xorx005 xor 1100 1010 -> 110
-xorx006 xor 1111 10 -> 1101
--- and at msd and msd-1
-xorx010 xor 000000000 000000000 -> 0
-xorx011 xor 000000000 100000000 -> 100000000
-xorx012 xor 100000000 000000000 -> 100000000
-xorx013 xor 100000000 100000000 -> 0
-xorx014 xor 000000000 000000000 -> 0
-xorx015 xor 000000000 010000000 -> 10000000
-xorx016 xor 010000000 000000000 -> 10000000
-xorx017 xor 010000000 010000000 -> 0
-
--- Various lengths
--- 123456789 123456789 123456789
-xorx021 xor 111111111 111111111 -> 0
-xorx022 xor 111111111111 111111111 -> 0
-xorx023 xor 11111111 11111111 -> 0
-xorx025 xor 1111111 1111111 -> 0
-xorx026 xor 111111 111111 -> 0
-xorx027 xor 11111 11111 -> 0
-xorx028 xor 1111 1111 -> 0
-xorx029 xor 111 111 -> 0
-xorx031 xor 11 11 -> 0
-xorx032 xor 1 1 -> 0
-xorx033 xor 111111111111 1111111111 -> 0
-xorx034 xor 11111111111 11111111111 -> 0
-xorx035 xor 1111111111 111111111111 -> 0
-xorx036 xor 111111111 1111111111111 -> 0
-
-xorx040 xor 111111111 111111111111 -> 0
-xorx041 xor 11111111 111111111111 -> 100000000
-xorx042 xor 11111111 111111111 -> 100000000
-xorx043 xor 1111111 100000010 -> 101111101
-xorx044 xor 111111 100000100 -> 100111011
-xorx045 xor 11111 100001000 -> 100010111
-xorx046 xor 1111 100010000 -> 100011111
-xorx047 xor 111 100100000 -> 100100111
-xorx048 xor 11 101000000 -> 101000011
-xorx049 xor 1 110000000 -> 110000001
-
-xorx050 xor 1111111111 1 -> 111111110
-xorx051 xor 111111111 1 -> 111111110
-xorx052 xor 11111111 1 -> 11111110
-xorx053 xor 1111111 1 -> 1111110
-xorx054 xor 111111 1 -> 111110
-xorx055 xor 11111 1 -> 11110
-xorx056 xor 1111 1 -> 1110
-xorx057 xor 111 1 -> 110
-xorx058 xor 11 1 -> 10
-xorx059 xor 1 1 -> 0
-
-xorx060 xor 1111111111 0 -> 111111111
-xorx061 xor 111111111 0 -> 111111111
-xorx062 xor 11111111 0 -> 11111111
-xorx063 xor 1111111 0 -> 1111111
-xorx064 xor 111111 0 -> 111111
-xorx065 xor 11111 0 -> 11111
-xorx066 xor 1111 0 -> 1111
-xorx067 xor 111 0 -> 111
-xorx068 xor 11 0 -> 11
-xorx069 xor 1 0 -> 1
-
-xorx070 xor 1 1111111111 -> 111111110
-xorx071 xor 1 111111111 -> 111111110
-xorx072 xor 1 11111111 -> 11111110
-xorx073 xor 1 1111111 -> 1111110
-xorx074 xor 1 111111 -> 111110
-xorx075 xor 1 11111 -> 11110
-xorx076 xor 1 1111 -> 1110
-xorx077 xor 1 111 -> 110
-xorx078 xor 1 11 -> 10
-xorx079 xor 1 1 -> 0
-
-xorx080 xor 0 1111111111 -> 111111111
-xorx081 xor 0 111111111 -> 111111111
-xorx082 xor 0 11111111 -> 11111111
-xorx083 xor 0 1111111 -> 1111111
-xorx084 xor 0 111111 -> 111111
-xorx085 xor 0 11111 -> 11111
-xorx086 xor 0 1111 -> 1111
-xorx087 xor 0 111 -> 111
-xorx088 xor 0 11 -> 11
-xorx089 xor 0 1 -> 1
-
-xorx090 xor 011111111 111101111 -> 100010000
-xorx091 xor 101111111 111101111 -> 10010000
-xorx092 xor 110111111 111101111 -> 1010000
-xorx093 xor 111011111 111101111 -> 110000
-xorx094 xor 111101111 111101111 -> 0
-xorx095 xor 111110111 111101111 -> 11000
-xorx096 xor 111111011 111101111 -> 10100
-xorx097 xor 111111101 111101111 -> 10010
-xorx098 xor 111111110 111101111 -> 10001
-
-xorx100 xor 111101111 011111111 -> 100010000
-xorx101 xor 111101111 101111111 -> 10010000
-xorx102 xor 111101111 110111111 -> 1010000
-xorx103 xor 111101111 111011111 -> 110000
-xorx104 xor 111101111 111101111 -> 0
-xorx105 xor 111101111 111110111 -> 11000
-xorx106 xor 111101111 111111011 -> 10100
-xorx107 xor 111101111 111111101 -> 10010
-xorx108 xor 111101111 111111110 -> 10001
-
--- non-0/1 should not be accepted, nor should signs
-xorx220 xor 111111112 111111111 -> NaN Invalid_operation
-xorx221 xor 333333333 333333333 -> NaN Invalid_operation
-xorx222 xor 555555555 555555555 -> NaN Invalid_operation
-xorx223 xor 777777777 777777777 -> NaN Invalid_operation
-xorx224 xor 999999999 999999999 -> NaN Invalid_operation
-xorx225 xor 222222222 999999999 -> NaN Invalid_operation
-xorx226 xor 444444444 999999999 -> NaN Invalid_operation
-xorx227 xor 666666666 999999999 -> NaN Invalid_operation
-xorx228 xor 888888888 999999999 -> NaN Invalid_operation
-xorx229 xor 999999999 222222222 -> NaN Invalid_operation
-xorx230 xor 999999999 444444444 -> NaN Invalid_operation
-xorx231 xor 999999999 666666666 -> NaN Invalid_operation
-xorx232 xor 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-xorx240 xor 567468689 -934981942 -> NaN Invalid_operation
-xorx241 xor 567367689 934981942 -> NaN Invalid_operation
-xorx242 xor -631917772 -706014634 -> NaN Invalid_operation
-xorx243 xor -756253257 138579234 -> NaN Invalid_operation
-xorx244 xor 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-xorx250 xor 200000000 100000000 -> NaN Invalid_operation
-xorx251 xor 700000000 100000000 -> NaN Invalid_operation
-xorx252 xor 800000000 100000000 -> NaN Invalid_operation
-xorx253 xor 900000000 100000000 -> NaN Invalid_operation
-xorx254 xor 200000000 000000000 -> NaN Invalid_operation
-xorx255 xor 700000000 000000000 -> NaN Invalid_operation
-xorx256 xor 800000000 000000000 -> NaN Invalid_operation
-xorx257 xor 900000000 000000000 -> NaN Invalid_operation
-xorx258 xor 100000000 200000000 -> NaN Invalid_operation
-xorx259 xor 100000000 700000000 -> NaN Invalid_operation
-xorx260 xor 100000000 800000000 -> NaN Invalid_operation
-xorx261 xor 100000000 900000000 -> NaN Invalid_operation
-xorx262 xor 000000000 200000000 -> NaN Invalid_operation
-xorx263 xor 000000000 700000000 -> NaN Invalid_operation
-xorx264 xor 000000000 800000000 -> NaN Invalid_operation
-xorx265 xor 000000000 900000000 -> NaN Invalid_operation
--- test MSD-1
-xorx270 xor 020000000 100000000 -> NaN Invalid_operation
-xorx271 xor 070100000 100000000 -> NaN Invalid_operation
-xorx272 xor 080010000 100000001 -> NaN Invalid_operation
-xorx273 xor 090001000 100000010 -> NaN Invalid_operation
-xorx274 xor 100000100 020010100 -> NaN Invalid_operation
-xorx275 xor 100000000 070001000 -> NaN Invalid_operation
-xorx276 xor 100000010 080010100 -> NaN Invalid_operation
-xorx277 xor 100000000 090000010 -> NaN Invalid_operation
--- test LSD
-xorx280 xor 001000002 100000000 -> NaN Invalid_operation
-xorx281 xor 000000007 100000000 -> NaN Invalid_operation
-xorx282 xor 000000008 100000000 -> NaN Invalid_operation
-xorx283 xor 000000009 100000000 -> NaN Invalid_operation
-xorx284 xor 100000000 000100002 -> NaN Invalid_operation
-xorx285 xor 100100000 001000007 -> NaN Invalid_operation
-xorx286 xor 100010000 010000008 -> NaN Invalid_operation
-xorx287 xor 100001000 100000009 -> NaN Invalid_operation
--- test Middie
-xorx288 xor 001020000 100000000 -> NaN Invalid_operation
-xorx289 xor 000070001 100000000 -> NaN Invalid_operation
-xorx290 xor 000080000 100010000 -> NaN Invalid_operation
-xorx291 xor 000090000 100001000 -> NaN Invalid_operation
-xorx292 xor 100000010 000020100 -> NaN Invalid_operation
-xorx293 xor 100100000 000070010 -> NaN Invalid_operation
-xorx294 xor 100010100 000080001 -> NaN Invalid_operation
-xorx295 xor 100001000 000090000 -> NaN Invalid_operation
--- signs
-xorx296 xor -100001000 -000000000 -> NaN Invalid_operation
-xorx297 xor -100001000 000010000 -> NaN Invalid_operation
-xorx298 xor 100001000 -000000000 -> NaN Invalid_operation
-xorx299 xor 100001000 000011000 -> 100010000
-
--- Nmax, Nmin, Ntiny
-xorx331 xor 2 9.99999999E+999 -> NaN Invalid_operation
-xorx332 xor 3 1E-999 -> NaN Invalid_operation
-xorx333 xor 4 1.00000000E-999 -> NaN Invalid_operation
-xorx334 xor 5 1E-1007 -> NaN Invalid_operation
-xorx335 xor 6 -1E-1007 -> NaN Invalid_operation
-xorx336 xor 7 -1.00000000E-999 -> NaN Invalid_operation
-xorx337 xor 8 -1E-999 -> NaN Invalid_operation
-xorx338 xor 9 -9.99999999E+999 -> NaN Invalid_operation
-xorx341 xor 9.99999999E+999 -18 -> NaN Invalid_operation
-xorx342 xor 1E-999 01 -> NaN Invalid_operation
-xorx343 xor 1.00000000E-999 -18 -> NaN Invalid_operation
-xorx344 xor 1E-1007 18 -> NaN Invalid_operation
-xorx345 xor -1E-1007 -10 -> NaN Invalid_operation
-xorx346 xor -1.00000000E-999 18 -> NaN Invalid_operation
-xorx347 xor -1E-999 10 -> NaN Invalid_operation
-xorx348 xor -9.99999999E+999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-xorx361 xor 1.0 1 -> NaN Invalid_operation
-xorx362 xor 1E+1 1 -> NaN Invalid_operation
-xorx363 xor 0.0 1 -> NaN Invalid_operation
-xorx364 xor 0E+1 1 -> NaN Invalid_operation
-xorx365 xor 9.9 1 -> NaN Invalid_operation
-xorx366 xor 9E+1 1 -> NaN Invalid_operation
-xorx371 xor 0 1.0 -> NaN Invalid_operation
-xorx372 xor 0 1E+1 -> NaN Invalid_operation
-xorx373 xor 0 0.0 -> NaN Invalid_operation
-xorx374 xor 0 0E+1 -> NaN Invalid_operation
-xorx375 xor 0 9.9 -> NaN Invalid_operation
-xorx376 xor 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-xorx780 xor -Inf -Inf -> NaN Invalid_operation
-xorx781 xor -Inf -1000 -> NaN Invalid_operation
-xorx782 xor -Inf -1 -> NaN Invalid_operation
-xorx783 xor -Inf -0 -> NaN Invalid_operation
-xorx784 xor -Inf 0 -> NaN Invalid_operation
-xorx785 xor -Inf 1 -> NaN Invalid_operation
-xorx786 xor -Inf 1000 -> NaN Invalid_operation
-xorx787 xor -1000 -Inf -> NaN Invalid_operation
-xorx788 xor -Inf -Inf -> NaN Invalid_operation
-xorx789 xor -1 -Inf -> NaN Invalid_operation
-xorx790 xor -0 -Inf -> NaN Invalid_operation
-xorx791 xor 0 -Inf -> NaN Invalid_operation
-xorx792 xor 1 -Inf -> NaN Invalid_operation
-xorx793 xor 1000 -Inf -> NaN Invalid_operation
-xorx794 xor Inf -Inf -> NaN Invalid_operation
-
-xorx800 xor Inf -Inf -> NaN Invalid_operation
-xorx801 xor Inf -1000 -> NaN Invalid_operation
-xorx802 xor Inf -1 -> NaN Invalid_operation
-xorx803 xor Inf -0 -> NaN Invalid_operation
-xorx804 xor Inf 0 -> NaN Invalid_operation
-xorx805 xor Inf 1 -> NaN Invalid_operation
-xorx806 xor Inf 1000 -> NaN Invalid_operation
-xorx807 xor Inf Inf -> NaN Invalid_operation
-xorx808 xor -1000 Inf -> NaN Invalid_operation
-xorx809 xor -Inf Inf -> NaN Invalid_operation
-xorx810 xor -1 Inf -> NaN Invalid_operation
-xorx811 xor -0 Inf -> NaN Invalid_operation
-xorx812 xor 0 Inf -> NaN Invalid_operation
-xorx813 xor 1 Inf -> NaN Invalid_operation
-xorx814 xor 1000 Inf -> NaN Invalid_operation
-xorx815 xor Inf Inf -> NaN Invalid_operation
-
-xorx821 xor NaN -Inf -> NaN Invalid_operation
-xorx822 xor NaN -1000 -> NaN Invalid_operation
-xorx823 xor NaN -1 -> NaN Invalid_operation
-xorx824 xor NaN -0 -> NaN Invalid_operation
-xorx825 xor NaN 0 -> NaN Invalid_operation
-xorx826 xor NaN 1 -> NaN Invalid_operation
-xorx827 xor NaN 1000 -> NaN Invalid_operation
-xorx828 xor NaN Inf -> NaN Invalid_operation
-xorx829 xor NaN NaN -> NaN Invalid_operation
-xorx830 xor -Inf NaN -> NaN Invalid_operation
-xorx831 xor -1000 NaN -> NaN Invalid_operation
-xorx832 xor -1 NaN -> NaN Invalid_operation
-xorx833 xor -0 NaN -> NaN Invalid_operation
-xorx834 xor 0 NaN -> NaN Invalid_operation
-xorx835 xor 1 NaN -> NaN Invalid_operation
-xorx836 xor 1000 NaN -> NaN Invalid_operation
-xorx837 xor Inf NaN -> NaN Invalid_operation
-
-xorx841 xor sNaN -Inf -> NaN Invalid_operation
-xorx842 xor sNaN -1000 -> NaN Invalid_operation
-xorx843 xor sNaN -1 -> NaN Invalid_operation
-xorx844 xor sNaN -0 -> NaN Invalid_operation
-xorx845 xor sNaN 0 -> NaN Invalid_operation
-xorx846 xor sNaN 1 -> NaN Invalid_operation
-xorx847 xor sNaN 1000 -> NaN Invalid_operation
-xorx848 xor sNaN NaN -> NaN Invalid_operation
-xorx849 xor sNaN sNaN -> NaN Invalid_operation
-xorx850 xor NaN sNaN -> NaN Invalid_operation
-xorx851 xor -Inf sNaN -> NaN Invalid_operation
-xorx852 xor -1000 sNaN -> NaN Invalid_operation
-xorx853 xor -1 sNaN -> NaN Invalid_operation
-xorx854 xor -0 sNaN -> NaN Invalid_operation
-xorx855 xor 0 sNaN -> NaN Invalid_operation
-xorx856 xor 1 sNaN -> NaN Invalid_operation
-xorx857 xor 1000 sNaN -> NaN Invalid_operation
-xorx858 xor Inf sNaN -> NaN Invalid_operation
-xorx859 xor NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-xorx861 xor NaN1 -Inf -> NaN Invalid_operation
-xorx862 xor +NaN2 -1000 -> NaN Invalid_operation
-xorx863 xor NaN3 1000 -> NaN Invalid_operation
-xorx864 xor NaN4 Inf -> NaN Invalid_operation
-xorx865 xor NaN5 +NaN6 -> NaN Invalid_operation
-xorx866 xor -Inf NaN7 -> NaN Invalid_operation
-xorx867 xor -1000 NaN8 -> NaN Invalid_operation
-xorx868 xor 1000 NaN9 -> NaN Invalid_operation
-xorx869 xor Inf +NaN10 -> NaN Invalid_operation
-xorx871 xor sNaN11 -Inf -> NaN Invalid_operation
-xorx872 xor sNaN12 -1000 -> NaN Invalid_operation
-xorx873 xor sNaN13 1000 -> NaN Invalid_operation
-xorx874 xor sNaN14 NaN17 -> NaN Invalid_operation
-xorx875 xor sNaN15 sNaN18 -> NaN Invalid_operation
-xorx876 xor NaN16 sNaN19 -> NaN Invalid_operation
-xorx877 xor -Inf +sNaN20 -> NaN Invalid_operation
-xorx878 xor -1000 sNaN21 -> NaN Invalid_operation
-xorx879 xor 1000 sNaN22 -> NaN Invalid_operation
-xorx880 xor Inf sNaN23 -> NaN Invalid_operation
-xorx881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
-xorx882 xor -NaN26 NaN28 -> NaN Invalid_operation
-xorx883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
-xorx884 xor 1000 -NaN30 -> NaN Invalid_operation
-xorx885 xor 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- xor.decTest -- digitwise logical XOR --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check (truth table)
+xorx001 xor 0 0 -> 0
+xorx002 xor 0 1 -> 1
+xorx003 xor 1 0 -> 1
+xorx004 xor 1 1 -> 0
+xorx005 xor 1100 1010 -> 110
+xorx006 xor 1111 10 -> 1101
+-- and at msd and msd-1
+xorx010 xor 000000000 000000000 -> 0
+xorx011 xor 000000000 100000000 -> 100000000
+xorx012 xor 100000000 000000000 -> 100000000
+xorx013 xor 100000000 100000000 -> 0
+xorx014 xor 000000000 000000000 -> 0
+xorx015 xor 000000000 010000000 -> 10000000
+xorx016 xor 010000000 000000000 -> 10000000
+xorx017 xor 010000000 010000000 -> 0
+
+-- Various lengths
+-- 123456789 123456789 123456789
+xorx021 xor 111111111 111111111 -> 0
+xorx022 xor 111111111111 111111111 -> 0
+xorx023 xor 11111111 11111111 -> 0
+xorx025 xor 1111111 1111111 -> 0
+xorx026 xor 111111 111111 -> 0
+xorx027 xor 11111 11111 -> 0
+xorx028 xor 1111 1111 -> 0
+xorx029 xor 111 111 -> 0
+xorx031 xor 11 11 -> 0
+xorx032 xor 1 1 -> 0
+xorx033 xor 111111111111 1111111111 -> 0
+xorx034 xor 11111111111 11111111111 -> 0
+xorx035 xor 1111111111 111111111111 -> 0
+xorx036 xor 111111111 1111111111111 -> 0
+
+xorx040 xor 111111111 111111111111 -> 0
+xorx041 xor 11111111 111111111111 -> 100000000
+xorx042 xor 11111111 111111111 -> 100000000
+xorx043 xor 1111111 100000010 -> 101111101
+xorx044 xor 111111 100000100 -> 100111011
+xorx045 xor 11111 100001000 -> 100010111
+xorx046 xor 1111 100010000 -> 100011111
+xorx047 xor 111 100100000 -> 100100111
+xorx048 xor 11 101000000 -> 101000011
+xorx049 xor 1 110000000 -> 110000001
+
+xorx050 xor 1111111111 1 -> 111111110
+xorx051 xor 111111111 1 -> 111111110
+xorx052 xor 11111111 1 -> 11111110
+xorx053 xor 1111111 1 -> 1111110
+xorx054 xor 111111 1 -> 111110
+xorx055 xor 11111 1 -> 11110
+xorx056 xor 1111 1 -> 1110
+xorx057 xor 111 1 -> 110
+xorx058 xor 11 1 -> 10
+xorx059 xor 1 1 -> 0
+
+xorx060 xor 1111111111 0 -> 111111111
+xorx061 xor 111111111 0 -> 111111111
+xorx062 xor 11111111 0 -> 11111111
+xorx063 xor 1111111 0 -> 1111111
+xorx064 xor 111111 0 -> 111111
+xorx065 xor 11111 0 -> 11111
+xorx066 xor 1111 0 -> 1111
+xorx067 xor 111 0 -> 111
+xorx068 xor 11 0 -> 11
+xorx069 xor 1 0 -> 1
+
+xorx070 xor 1 1111111111 -> 111111110
+xorx071 xor 1 111111111 -> 111111110
+xorx072 xor 1 11111111 -> 11111110
+xorx073 xor 1 1111111 -> 1111110
+xorx074 xor 1 111111 -> 111110
+xorx075 xor 1 11111 -> 11110
+xorx076 xor 1 1111 -> 1110
+xorx077 xor 1 111 -> 110
+xorx078 xor 1 11 -> 10
+xorx079 xor 1 1 -> 0
+
+xorx080 xor 0 1111111111 -> 111111111
+xorx081 xor 0 111111111 -> 111111111
+xorx082 xor 0 11111111 -> 11111111
+xorx083 xor 0 1111111 -> 1111111
+xorx084 xor 0 111111 -> 111111
+xorx085 xor 0 11111 -> 11111
+xorx086 xor 0 1111 -> 1111
+xorx087 xor 0 111 -> 111
+xorx088 xor 0 11 -> 11
+xorx089 xor 0 1 -> 1
+
+xorx090 xor 011111111 111101111 -> 100010000
+xorx091 xor 101111111 111101111 -> 10010000
+xorx092 xor 110111111 111101111 -> 1010000
+xorx093 xor 111011111 111101111 -> 110000
+xorx094 xor 111101111 111101111 -> 0
+xorx095 xor 111110111 111101111 -> 11000
+xorx096 xor 111111011 111101111 -> 10100
+xorx097 xor 111111101 111101111 -> 10010
+xorx098 xor 111111110 111101111 -> 10001
+
+xorx100 xor 111101111 011111111 -> 100010000
+xorx101 xor 111101111 101111111 -> 10010000
+xorx102 xor 111101111 110111111 -> 1010000
+xorx103 xor 111101111 111011111 -> 110000
+xorx104 xor 111101111 111101111 -> 0
+xorx105 xor 111101111 111110111 -> 11000
+xorx106 xor 111101111 111111011 -> 10100
+xorx107 xor 111101111 111111101 -> 10010
+xorx108 xor 111101111 111111110 -> 10001
+
+-- non-0/1 should not be accepted, nor should signs
+xorx220 xor 111111112 111111111 -> NaN Invalid_operation
+xorx221 xor 333333333 333333333 -> NaN Invalid_operation
+xorx222 xor 555555555 555555555 -> NaN Invalid_operation
+xorx223 xor 777777777 777777777 -> NaN Invalid_operation
+xorx224 xor 999999999 999999999 -> NaN Invalid_operation
+xorx225 xor 222222222 999999999 -> NaN Invalid_operation
+xorx226 xor 444444444 999999999 -> NaN Invalid_operation
+xorx227 xor 666666666 999999999 -> NaN Invalid_operation
+xorx228 xor 888888888 999999999 -> NaN Invalid_operation
+xorx229 xor 999999999 222222222 -> NaN Invalid_operation
+xorx230 xor 999999999 444444444 -> NaN Invalid_operation
+xorx231 xor 999999999 666666666 -> NaN Invalid_operation
+xorx232 xor 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+xorx240 xor 567468689 -934981942 -> NaN Invalid_operation
+xorx241 xor 567367689 934981942 -> NaN Invalid_operation
+xorx242 xor -631917772 -706014634 -> NaN Invalid_operation
+xorx243 xor -756253257 138579234 -> NaN Invalid_operation
+xorx244 xor 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+xorx250 xor 200000000 100000000 -> NaN Invalid_operation
+xorx251 xor 700000000 100000000 -> NaN Invalid_operation
+xorx252 xor 800000000 100000000 -> NaN Invalid_operation
+xorx253 xor 900000000 100000000 -> NaN Invalid_operation
+xorx254 xor 200000000 000000000 -> NaN Invalid_operation
+xorx255 xor 700000000 000000000 -> NaN Invalid_operation
+xorx256 xor 800000000 000000000 -> NaN Invalid_operation
+xorx257 xor 900000000 000000000 -> NaN Invalid_operation
+xorx258 xor 100000000 200000000 -> NaN Invalid_operation
+xorx259 xor 100000000 700000000 -> NaN Invalid_operation
+xorx260 xor 100000000 800000000 -> NaN Invalid_operation
+xorx261 xor 100000000 900000000 -> NaN Invalid_operation
+xorx262 xor 000000000 200000000 -> NaN Invalid_operation
+xorx263 xor 000000000 700000000 -> NaN Invalid_operation
+xorx264 xor 000000000 800000000 -> NaN Invalid_operation
+xorx265 xor 000000000 900000000 -> NaN Invalid_operation
+-- test MSD-1
+xorx270 xor 020000000 100000000 -> NaN Invalid_operation
+xorx271 xor 070100000 100000000 -> NaN Invalid_operation
+xorx272 xor 080010000 100000001 -> NaN Invalid_operation
+xorx273 xor 090001000 100000010 -> NaN Invalid_operation
+xorx274 xor 100000100 020010100 -> NaN Invalid_operation
+xorx275 xor 100000000 070001000 -> NaN Invalid_operation
+xorx276 xor 100000010 080010100 -> NaN Invalid_operation
+xorx277 xor 100000000 090000010 -> NaN Invalid_operation
+-- test LSD
+xorx280 xor 001000002 100000000 -> NaN Invalid_operation
+xorx281 xor 000000007 100000000 -> NaN Invalid_operation
+xorx282 xor 000000008 100000000 -> NaN Invalid_operation
+xorx283 xor 000000009 100000000 -> NaN Invalid_operation
+xorx284 xor 100000000 000100002 -> NaN Invalid_operation
+xorx285 xor 100100000 001000007 -> NaN Invalid_operation
+xorx286 xor 100010000 010000008 -> NaN Invalid_operation
+xorx287 xor 100001000 100000009 -> NaN Invalid_operation
+-- test Middie
+xorx288 xor 001020000 100000000 -> NaN Invalid_operation
+xorx289 xor 000070001 100000000 -> NaN Invalid_operation
+xorx290 xor 000080000 100010000 -> NaN Invalid_operation
+xorx291 xor 000090000 100001000 -> NaN Invalid_operation
+xorx292 xor 100000010 000020100 -> NaN Invalid_operation
+xorx293 xor 100100000 000070010 -> NaN Invalid_operation
+xorx294 xor 100010100 000080001 -> NaN Invalid_operation
+xorx295 xor 100001000 000090000 -> NaN Invalid_operation
+-- signs
+xorx296 xor -100001000 -000000000 -> NaN Invalid_operation
+xorx297 xor -100001000 000010000 -> NaN Invalid_operation
+xorx298 xor 100001000 -000000000 -> NaN Invalid_operation
+xorx299 xor 100001000 000011000 -> 100010000
+
+-- Nmax, Nmin, Ntiny
+xorx331 xor 2 9.99999999E+999 -> NaN Invalid_operation
+xorx332 xor 3 1E-999 -> NaN Invalid_operation
+xorx333 xor 4 1.00000000E-999 -> NaN Invalid_operation
+xorx334 xor 5 1E-1007 -> NaN Invalid_operation
+xorx335 xor 6 -1E-1007 -> NaN Invalid_operation
+xorx336 xor 7 -1.00000000E-999 -> NaN Invalid_operation
+xorx337 xor 8 -1E-999 -> NaN Invalid_operation
+xorx338 xor 9 -9.99999999E+999 -> NaN Invalid_operation
+xorx341 xor 9.99999999E+999 -18 -> NaN Invalid_operation
+xorx342 xor 1E-999 01 -> NaN Invalid_operation
+xorx343 xor 1.00000000E-999 -18 -> NaN Invalid_operation
+xorx344 xor 1E-1007 18 -> NaN Invalid_operation
+xorx345 xor -1E-1007 -10 -> NaN Invalid_operation
+xorx346 xor -1.00000000E-999 18 -> NaN Invalid_operation
+xorx347 xor -1E-999 10 -> NaN Invalid_operation
+xorx348 xor -9.99999999E+999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+xorx361 xor 1.0 1 -> NaN Invalid_operation
+xorx362 xor 1E+1 1 -> NaN Invalid_operation
+xorx363 xor 0.0 1 -> NaN Invalid_operation
+xorx364 xor 0E+1 1 -> NaN Invalid_operation
+xorx365 xor 9.9 1 -> NaN Invalid_operation
+xorx366 xor 9E+1 1 -> NaN Invalid_operation
+xorx371 xor 0 1.0 -> NaN Invalid_operation
+xorx372 xor 0 1E+1 -> NaN Invalid_operation
+xorx373 xor 0 0.0 -> NaN Invalid_operation
+xorx374 xor 0 0E+1 -> NaN Invalid_operation
+xorx375 xor 0 9.9 -> NaN Invalid_operation
+xorx376 xor 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+xorx780 xor -Inf -Inf -> NaN Invalid_operation
+xorx781 xor -Inf -1000 -> NaN Invalid_operation
+xorx782 xor -Inf -1 -> NaN Invalid_operation
+xorx783 xor -Inf -0 -> NaN Invalid_operation
+xorx784 xor -Inf 0 -> NaN Invalid_operation
+xorx785 xor -Inf 1 -> NaN Invalid_operation
+xorx786 xor -Inf 1000 -> NaN Invalid_operation
+xorx787 xor -1000 -Inf -> NaN Invalid_operation
+xorx788 xor -Inf -Inf -> NaN Invalid_operation
+xorx789 xor -1 -Inf -> NaN Invalid_operation
+xorx790 xor -0 -Inf -> NaN Invalid_operation
+xorx791 xor 0 -Inf -> NaN Invalid_operation
+xorx792 xor 1 -Inf -> NaN Invalid_operation
+xorx793 xor 1000 -Inf -> NaN Invalid_operation
+xorx794 xor Inf -Inf -> NaN Invalid_operation
+
+xorx800 xor Inf -Inf -> NaN Invalid_operation
+xorx801 xor Inf -1000 -> NaN Invalid_operation
+xorx802 xor Inf -1 -> NaN Invalid_operation
+xorx803 xor Inf -0 -> NaN Invalid_operation
+xorx804 xor Inf 0 -> NaN Invalid_operation
+xorx805 xor Inf 1 -> NaN Invalid_operation
+xorx806 xor Inf 1000 -> NaN Invalid_operation
+xorx807 xor Inf Inf -> NaN Invalid_operation
+xorx808 xor -1000 Inf -> NaN Invalid_operation
+xorx809 xor -Inf Inf -> NaN Invalid_operation
+xorx810 xor -1 Inf -> NaN Invalid_operation
+xorx811 xor -0 Inf -> NaN Invalid_operation
+xorx812 xor 0 Inf -> NaN Invalid_operation
+xorx813 xor 1 Inf -> NaN Invalid_operation
+xorx814 xor 1000 Inf -> NaN Invalid_operation
+xorx815 xor Inf Inf -> NaN Invalid_operation
+
+xorx821 xor NaN -Inf -> NaN Invalid_operation
+xorx822 xor NaN -1000 -> NaN Invalid_operation
+xorx823 xor NaN -1 -> NaN Invalid_operation
+xorx824 xor NaN -0 -> NaN Invalid_operation
+xorx825 xor NaN 0 -> NaN Invalid_operation
+xorx826 xor NaN 1 -> NaN Invalid_operation
+xorx827 xor NaN 1000 -> NaN Invalid_operation
+xorx828 xor NaN Inf -> NaN Invalid_operation
+xorx829 xor NaN NaN -> NaN Invalid_operation
+xorx830 xor -Inf NaN -> NaN Invalid_operation
+xorx831 xor -1000 NaN -> NaN Invalid_operation
+xorx832 xor -1 NaN -> NaN Invalid_operation
+xorx833 xor -0 NaN -> NaN Invalid_operation
+xorx834 xor 0 NaN -> NaN Invalid_operation
+xorx835 xor 1 NaN -> NaN Invalid_operation
+xorx836 xor 1000 NaN -> NaN Invalid_operation
+xorx837 xor Inf NaN -> NaN Invalid_operation
+
+xorx841 xor sNaN -Inf -> NaN Invalid_operation
+xorx842 xor sNaN -1000 -> NaN Invalid_operation
+xorx843 xor sNaN -1 -> NaN Invalid_operation
+xorx844 xor sNaN -0 -> NaN Invalid_operation
+xorx845 xor sNaN 0 -> NaN Invalid_operation
+xorx846 xor sNaN 1 -> NaN Invalid_operation
+xorx847 xor sNaN 1000 -> NaN Invalid_operation
+xorx848 xor sNaN NaN -> NaN Invalid_operation
+xorx849 xor sNaN sNaN -> NaN Invalid_operation
+xorx850 xor NaN sNaN -> NaN Invalid_operation
+xorx851 xor -Inf sNaN -> NaN Invalid_operation
+xorx852 xor -1000 sNaN -> NaN Invalid_operation
+xorx853 xor -1 sNaN -> NaN Invalid_operation
+xorx854 xor -0 sNaN -> NaN Invalid_operation
+xorx855 xor 0 sNaN -> NaN Invalid_operation
+xorx856 xor 1 sNaN -> NaN Invalid_operation
+xorx857 xor 1000 sNaN -> NaN Invalid_operation
+xorx858 xor Inf sNaN -> NaN Invalid_operation
+xorx859 xor NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+xorx861 xor NaN1 -Inf -> NaN Invalid_operation
+xorx862 xor +NaN2 -1000 -> NaN Invalid_operation
+xorx863 xor NaN3 1000 -> NaN Invalid_operation
+xorx864 xor NaN4 Inf -> NaN Invalid_operation
+xorx865 xor NaN5 +NaN6 -> NaN Invalid_operation
+xorx866 xor -Inf NaN7 -> NaN Invalid_operation
+xorx867 xor -1000 NaN8 -> NaN Invalid_operation
+xorx868 xor 1000 NaN9 -> NaN Invalid_operation
+xorx869 xor Inf +NaN10 -> NaN Invalid_operation
+xorx871 xor sNaN11 -Inf -> NaN Invalid_operation
+xorx872 xor sNaN12 -1000 -> NaN Invalid_operation
+xorx873 xor sNaN13 1000 -> NaN Invalid_operation
+xorx874 xor sNaN14 NaN17 -> NaN Invalid_operation
+xorx875 xor sNaN15 sNaN18 -> NaN Invalid_operation
+xorx876 xor NaN16 sNaN19 -> NaN Invalid_operation
+xorx877 xor -Inf +sNaN20 -> NaN Invalid_operation
+xorx878 xor -1000 sNaN21 -> NaN Invalid_operation
+xorx879 xor 1000 sNaN22 -> NaN Invalid_operation
+xorx880 xor Inf sNaN23 -> NaN Invalid_operation
+xorx881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
+xorx882 xor -NaN26 NaN28 -> NaN Invalid_operation
+xorx883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
+xorx884 xor 1000 -NaN30 -> NaN Invalid_operation
+xorx885 xor 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/doctest_aliases.py b/Lib/test/doctest_aliases.py
index e5e6b29fec..30cefafa83 100644
--- a/Lib/test/doctest_aliases.py
+++ b/Lib/test/doctest_aliases.py
@@ -10,4 +10,4 @@ class TwoNames:
'''
return 'f'
- g = f # define an alias for f
+ g = f # define an alias for f
diff --git a/Lib/test/encoded_modules/__init__.py b/Lib/test/encoded_modules/__init__.py
new file mode 100644
index 0000000000..ec43252aad
--- /dev/null
+++ b/Lib/test/encoded_modules/__init__.py
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+
+# This is a package that contains a number of modules that are used to
+# test import from the source files that have different encodings.
+# This file (the __init__ module of the package), is encoded in utf-8
+# and contains a list of strings from various unicode planes that are
+# encoded differently to compare them to the same strings encoded
+# differently in submodules. The following list, test_strings,
+# contains a list of tuples. The first element of each tuple is the
+# suffix that should be prepended with 'module_' to arrive at the
+# encoded submodule name, the second item is the encoding and the last
+# is the test string. The same string is assigned to the variable
+# named 'test' inside the submodule. If the decoding of modules works
+# correctly, from module_xyz import test should result in the same
+# string as listed below in the 'xyz' entry.
+
+# module, encoding, test string
+test_strings = (
+ ('iso_8859_1', 'iso-8859-1', "Les hommes ont oublié cette vérité, "
+ "dit le renard. Mais tu ne dois pas l'oublier. Tu deviens "
+ "responsable pour toujours de ce que tu as apprivoisé."),
+ ('koi8_r', 'koi8-r', "Познание беÑконечноÑти требует беÑконечного времени.")
+)
diff --git a/Lib/test/encoded_modules/module_iso_8859_1.py b/Lib/test/encoded_modules/module_iso_8859_1.py
new file mode 100644
index 0000000000..8f4a15c905
--- /dev/null
+++ b/Lib/test/encoded_modules/module_iso_8859_1.py
@@ -0,0 +1,5 @@
+# test iso-8859-1 encoding
+# -*- encoding: iso-8859-1 -*-
+test = ("Les hommes ont oublié cette vérité, "
+ "dit le renard. Mais tu ne dois pas l'oublier. Tu deviens "
+ "responsable pour toujours de ce que tu as apprivoisé.")
diff --git a/Lib/test/encoded_modules/module_koi8_r.py b/Lib/test/encoded_modules/module_koi8_r.py
new file mode 100644
index 0000000000..9b23a5a218
--- /dev/null
+++ b/Lib/test/encoded_modules/module_koi8_r.py
@@ -0,0 +1,3 @@
+# test koi8-r encoding
+# -*- encoding: koi8-r -*-
+test = "ðÏÚÎÁÎÉÅ ÂÅÓËÏÎÅÞÎÏÓÔÉ ÔÒÅÂÕÅÔ ÂÅÓËÏÎÅÞÎÏÇÏ ×ÒÅÍÅÎÉ."
diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt
index 73ccb6674b..5037b335d9 100644
--- a/Lib/test/exception_hierarchy.txt
+++ b/Lib/test/exception_hierarchy.txt
@@ -47,3 +47,4 @@ BaseException
+-- ImportWarning
+-- UnicodeWarning
+-- BytesWarning
+ +-- ResourceWarning
diff --git a/Lib/test/fork_wait.py b/Lib/test/fork_wait.py
index a69653bfa9..1caab1c491 100644
--- a/Lib/test/fork_wait.py
+++ b/Lib/test/fork_wait.py
@@ -1,6 +1,6 @@
"""This test case provides support for checking forking and wait behavior.
-To test different wait behavior, overrise the wait_impl method.
+To test different wait behavior, override the wait_impl method.
We want fork1() semantics -- only the forking thread survives in the
child after a fork().
@@ -9,7 +9,9 @@ On some systems (e.g. Solaris without posix threads) we find that all
active threads survive in the child after a fork(); this is an error.
"""
-import os, sys, time, _thread, unittest
+import os, sys, time, unittest
+import test.support as support
+_thread = support.import_module('_thread')
LONGSLEEP = 2
SHORTSLEEP = 0.5
diff --git a/Lib/test/formatfloat_testcases.txt b/Lib/test/formatfloat_testcases.txt
index 4cf20aa8c9..25c07ba293 100644
--- a/Lib/test/formatfloat_testcases.txt
+++ b/Lib/test/formatfloat_testcases.txt
@@ -279,6 +279,11 @@
%.2g 0.000123 -> 0.00012
%.2g 0.0000123 -> 1.2e-05
+-- bad cases from http://bugs.python.org/issue9980
+%.12g 38210.0 -> 38210
+%.12g 37210.0 -> 37210
+%.12g 36210.0 -> 36210
+
-- alternate g formatting: always include decimal point and
-- exactly <precision> significant digits.
%#.0g 0 -> 0.
@@ -314,43 +319,37 @@
%#.5g 234.56 -> 234.56
%#.6g 234.56 -> 234.560
--- for repr formatting see the separate test_short_repr test in
--- test_float.py. Not all platforms use short repr for floats.
-
--- str formatting. Result always includes decimal point and at
+-- repr formatting. Result always includes decimal point and at
-- least one digit after the point, or an exponent.
-%s 0 -> 0.0
-%s 1 -> 1.0
-
-%s 0.01 -> 0.01
-%s 0.02 -> 0.02
-%s 0.03 -> 0.03
-%s 0.04 -> 0.04
-%s 0.05 -> 0.05
+%r 0 -> 0.0
+%r 1 -> 1.0
--- str truncates to 12 significant digits
-%s 1.234123412341 -> 1.23412341234
-%s 1.23412341234 -> 1.23412341234
-%s 1.2341234123 -> 1.2341234123
+%r 0.01 -> 0.01
+%r 0.02 -> 0.02
+%r 0.03 -> 0.03
+%r 0.04 -> 0.04
+%r 0.05 -> 0.05
--- values >= 1e11 get an exponent
-%s 10 -> 10.0
-%s 100 -> 100.0
-%s 1e10 -> 10000000000.0
-%s 9.999e10 -> 99990000000.0
-%s 99999999999 -> 99999999999.0
-%s 99999999999.9 -> 99999999999.9
-%s 99999999999.99 -> 1e+11
-%s 1e11 -> 1e+11
-%s 1e12 -> 1e+12
+-- values >= 1e16 get an exponent
+%r 10 -> 10.0
+%r 100 -> 100.0
+%r 1e15 -> 1000000000000000.0
+%r 9.999e15 -> 9999000000000000.0
+%r 9999999999999998 -> 9999999999999998.0
+%r 9999999999999999 -> 1e+16
+%r 1e16 -> 1e+16
+%r 1e17 -> 1e+17
-- as do values < 1e-4
-%s 1e-3 -> 0.001
-%s 1.001e-4 -> 0.0001001
-%s 1.000000000001e-4 -> 0.0001
-%s 1.00000000001e-4 -> 0.000100000000001
-%s 1.0000000001e-4 -> 0.00010000000001
-%s 1e-4 -> 0.0001
-%s 0.999999999999e-4 -> 9.99999999999e-05
-%s 0.999e-4 -> 9.99e-05
-%s 1e-5 -> 1e-05
+%r 1e-3 -> 0.001
+%r 1.001e-4 -> 0.0001001
+%r 1.0000000000000001e-4 -> 0.0001
+%r 1.000000000000001e-4 -> 0.0001000000000000001
+%r 1.00000000001e-4 -> 0.000100000000001
+%r 1.0000000001e-4 -> 0.00010000000001
+%r 1e-4 -> 0.0001
+%r 0.99999999999999999e-4 -> 0.0001
+%r 0.9999999999999999e-4 -> 9.999999999999999e-05
+%r 0.999999999999e-4 -> 9.99999999999e-05
+%r 0.999e-4 -> 9.99e-05
+%r 1e-5 -> 1e-05
diff --git a/Lib/test/gdb_sample.py b/Lib/test/gdb_sample.py
new file mode 100644
index 0000000000..cab13fb4da
--- /dev/null
+++ b/Lib/test/gdb_sample.py
@@ -0,0 +1,12 @@
+# Sample script for use by test_gdb.py
+
+def foo(a, b, c):
+ bar(a, b, c)
+
+def bar(a, b, c):
+ baz(a, b, c)
+
+def baz(*args):
+ id(42)
+
+foo(1, 2, 3)
diff --git a/Lib/test/ieee754.txt b/Lib/test/ieee754.txt
index 5a41c8fe50..89bb0c50a3 100644
--- a/Lib/test/ieee754.txt
+++ b/Lib/test/ieee754.txt
@@ -72,7 +72,7 @@ False
>>> NAN >= 0
False
-All operations involving a NaN return a NaN except for the power of *0* and *1*.
+All operations involving a NaN return a NaN except for nan**0 and 1**nan.
>>> 1 + NAN
nan
>>> 1 * NAN
@@ -81,8 +81,10 @@ nan
nan
>>> 1 ** NAN
1.0
+>>> NAN ** 0
+1.0
>>> 0 ** NAN
-0.0
+nan
>>> (1.0 + FI.epsilon) * NAN
nan
diff --git a/Lib/json/tests/__init__.py b/Lib/test/json_tests/__init__.py
index 1a1e3e6d5a..4977468e47 100644
--- a/Lib/json/tests/__init__.py
+++ b/Lib/test/json_tests/__init__.py
@@ -10,7 +10,7 @@ def test_suite():
loader = unittest.TestLoader()
for fn in os.listdir(here):
if fn.startswith("test") and fn.endswith(".py"):
- modname = "json.tests." + fn[:-3]
+ modname = "test.json_tests." + fn[:-3]
__import__(modname)
module = sys.modules[modname]
suite.addTests(loader.loadTestsFromModule(module))
diff --git a/Lib/json/tests/test_decode.py b/Lib/test/json_tests/test_decode.py
index 74d886ac26..f41e5b7223 100644
--- a/Lib/json/tests/test_decode.py
+++ b/Lib/test/json_tests/test_decode.py
@@ -1,10 +1,25 @@
import decimal
from unittest import TestCase
from io import StringIO
+from contextlib import contextmanager
import json
+import json.decoder
+import json.scanner
from collections import OrderedDict
+
+@contextmanager
+def use_python_scanner():
+ py_scanner = json.scanner.py_make_scanner
+ old_scanner = json.decoder.make_scanner
+ json.decoder.make_scanner = py_scanner
+ try:
+ yield
+ finally:
+ json.decoder.make_scanner = old_scanner
+
+
class TestDecode(TestCase):
def test_decimal(self):
rval = json.loads('1.1', parse_float=decimal.Decimal)
@@ -39,3 +54,16 @@ class TestDecode(TestCase):
# exercise the uncommon cases. The array cases are already covered.
rval = json.loads('{ "key" : "value" , "k":"v" }')
self.assertEqual(rval, {"key":"value", "k":"v"})
+
+ def check_keys_reuse(self, source, loads):
+ rval = loads(source)
+ (a, b), (c, d) = sorted(rval[0]), sorted(rval[1])
+ self.assertIs(a, c)
+ self.assertIs(b, d)
+
+ def test_keys_reuse(self):
+ s = '[{"a_key": 1, "b_\xe9": 2}, {"a_key": 3, "b_\xe9": 4}]'
+ self.check_keys_reuse(s, json.loads)
+ # Disabled: the pure Python version of json simply doesn't work
+ with use_python_scanner():
+ self.check_keys_reuse(s, json.decoder.JSONDecoder().decode)
diff --git a/Lib/json/tests/test_default.py b/Lib/test/json_tests/test_default.py
index 6a03eeb834..6a03eeb834 100644
--- a/Lib/json/tests/test_default.py
+++ b/Lib/test/json_tests/test_default.py
diff --git a/Lib/json/tests/test_dump.py b/Lib/test/json_tests/test_dump.py
index 8df234b819..8df234b819 100644
--- a/Lib/json/tests/test_dump.py
+++ b/Lib/test/json_tests/test_dump.py
diff --git a/Lib/json/tests/test_encode_basestring_ascii.py b/Lib/test/json_tests/test_encode_basestring_ascii.py
index 4fddd121c6..4fddd121c6 100644
--- a/Lib/json/tests/test_encode_basestring_ascii.py
+++ b/Lib/test/json_tests/test_encode_basestring_ascii.py
diff --git a/Lib/json/tests/test_fail.py b/Lib/test/json_tests/test_fail.py
index 9768edf19a..9768edf19a 100644
--- a/Lib/json/tests/test_fail.py
+++ b/Lib/test/json_tests/test_fail.py
diff --git a/Lib/json/tests/test_float.py b/Lib/test/json_tests/test_float.py
index ca4a506db4..ca4a506db4 100644
--- a/Lib/json/tests/test_float.py
+++ b/Lib/test/json_tests/test_float.py
diff --git a/Lib/json/tests/test_indent.py b/Lib/test/json_tests/test_indent.py
index cd608d94a5..d8030aaade 100644
--- a/Lib/json/tests/test_indent.py
+++ b/Lib/test/json_tests/test_indent.py
@@ -10,32 +10,36 @@ class TestIndent(TestCase):
expect = textwrap.dedent("""\
[
- [
- "blorpie"
- ],
- [
- "whoops"
- ],
- [],
- "d-shtaeou",
- "d-nthiouh",
- "i-vhbjkhnth",
- {
- "nifty": 87
- },
- {
- "field": "yes",
- "morefield": false
- }
+ \t[
+ \t\t"blorpie"
+ \t],
+ \t[
+ \t\t"whoops"
+ \t],
+ \t[],
+ \t"d-shtaeou",
+ \t"d-nthiouh",
+ \t"i-vhbjkhnth",
+ \t{
+ \t\t"nifty": 87
+ \t},
+ \t{
+ \t\t"field": "yes",
+ \t\t"morefield": false
+ \t}
]""")
d1 = json.dumps(h)
d2 = json.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
+ d3 = json.dumps(h, indent='\t', sort_keys=True, separators=(',', ': '))
h1 = json.loads(d1)
h2 = json.loads(d2)
+ h3 = json.loads(d3)
self.assertEqual(h1, h)
self.assertEqual(h2, h)
- self.assertEqual(d2, expect)
+ self.assertEqual(h3, h)
+ self.assertEqual(d2, expect.expandtabs(2))
+ self.assertEqual(d3, expect)
diff --git a/Lib/json/tests/test_pass1.py b/Lib/test/json_tests/test_pass1.py
index 719c113759..719c113759 100644
--- a/Lib/json/tests/test_pass1.py
+++ b/Lib/test/json_tests/test_pass1.py
diff --git a/Lib/json/tests/test_pass2.py b/Lib/test/json_tests/test_pass2.py
index 379117e905..379117e905 100644
--- a/Lib/json/tests/test_pass2.py
+++ b/Lib/test/json_tests/test_pass2.py
diff --git a/Lib/json/tests/test_pass3.py b/Lib/test/json_tests/test_pass3.py
index 9151c4321c..9151c4321c 100644
--- a/Lib/json/tests/test_pass3.py
+++ b/Lib/test/json_tests/test_pass3.py
diff --git a/Lib/json/tests/test_recursion.py b/Lib/test/json_tests/test_recursion.py
index 1e9b8ab757..1e9b8ab757 100644
--- a/Lib/json/tests/test_recursion.py
+++ b/Lib/test/json_tests/test_recursion.py
diff --git a/Lib/json/tests/test_scanstring.py b/Lib/test/json_tests/test_scanstring.py
index d503851e56..d503851e56 100644
--- a/Lib/json/tests/test_scanstring.py
+++ b/Lib/test/json_tests/test_scanstring.py
diff --git a/Lib/json/tests/test_separators.py b/Lib/test/json_tests/test_separators.py
index d5b92bd65d..d5b92bd65d 100644
--- a/Lib/json/tests/test_separators.py
+++ b/Lib/test/json_tests/test_separators.py
diff --git a/Lib/json/tests/test_speedups.py b/Lib/test/json_tests/test_speedups.py
index 94381548a7..271840978c 100644
--- a/Lib/json/tests/test_speedups.py
+++ b/Lib/test/json_tests/test_speedups.py
@@ -1,4 +1,3 @@
-import decimal
from unittest import TestCase
from json import decoder, encoder, scanner
diff --git a/Lib/json/tests/test_unicode.py b/Lib/test/json_tests/test_unicode.py
index e336c91fa9..e336c91fa9 100644
--- a/Lib/json/tests/test_unicode.py
+++ b/Lib/test/json_tests/test_unicode.py
diff --git a/Lib/test/keycert.pem b/Lib/test/keycert.pem
index 2f46fcf1c6..64318aa2e0 100644
--- a/Lib/test/keycert.pem
+++ b/Lib/test/keycert.pem
@@ -1,32 +1,31 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L
-opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH
-fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB
-AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU
-D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA
-IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM
-oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0
-ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/
-loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j
-oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA
-z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq
-ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV
-q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU=
------END RSA PRIVATE KEY-----
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm
+LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0
+ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP
+USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt
+CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq
+SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK
+UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y
+BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ
+ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5
+oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik
+eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F
+0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS
+x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/
+SPIXQuT8RMPDVNQ=
+-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
-MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD
-VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x
-IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT
-U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1
-NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl
-bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m
-dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj
-aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh
-m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8
-M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn
-fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC
-AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb
-08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx
-CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/
-iHkC6gGdBJhogs4=
+MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV
+BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u
+IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw
+MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH
+Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k
+YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
+gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7
+6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt
+pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw
+FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd
+BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G
+lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1
+CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX
-----END CERTIFICATE-----
diff --git a/Lib/test/keycert2.pem b/Lib/test/keycert2.pem
new file mode 100644
index 0000000000..e8a9e082b3
--- /dev/null
+++ b/Lib/test/keycert2.pem
@@ -0,0 +1,31 @@
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJnsJZVrppL+W5I9
+zGQrrawWwE5QJpBK9nWw17mXrZ03R1cD9BamLGivVISbPlRlAVnZBEyh1ATpsB7d
+CUQ+WHEvALquvx4+Yw5l+fXeiYRjrLRBYZuVy8yNtXzU3iWcGObcYRkUdiXdOyP7
+sLF2YZHRvQZpzgDBKkrraeQ81w21AgMBAAECgYBEm7n07FMHWlE+0kT0sXNsLYfy
+YE+QKZnJw9WkaDN+zFEEPELkhZVt5BjsMraJr6v2fIEqF0gGGJPkbenffVq2B5dC
+lWUOxvJHufMK4sM3Cp6s/gOp3LP+QkzVnvJSfAyZU6l+4PGX5pLdUsXYjPxgzjzL
+S36tF7/2Uv1WePyLUQJBAMsPhYzUXOPRgmbhcJiqi9A9c3GO8kvSDYTCKt3VMnqz
+HBn6MQ4VQasCD1F+7jWTI0FU/3vdw8non/Fj8hhYqZcCQQDCDRdvmZqDiZnpMqDq
+L6ZSrLTVtMvZXZbgwForaAD9uHj51TME7+eYT7EG2YCgJTXJ4YvRJEnPNyskwdKt
+vTSTAkEAtaaN/vyemEJ82BIGStwONNw0ILsSr5cZ9tBHzqiA/tipY+e36HRFiXhP
+QcU9zXlxyWkDH8iz9DSAmE2jbfoqwwJANlMJ65E543cjIlitGcKLMnvtCCLcKpb7
+xSG0XJB6Lo11OKPJ66jp0gcFTSCY1Lx2CXVd+gfJrfwI1Pp562+bhwJBAJ9IfDPU
+R8OpO9v1SGd8x33Owm7uXOpB9d63/T70AD1QOXjKUC4eXYbt0WWfWuny/RNPRuyh
+w7DXSfUF+kPKolU=
+-----END PRIVATE KEY-----
+-----BEGIN CERTIFICATE-----
+MIICXTCCAcagAwIBAgIJAIO3upAG445fMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNV
+BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u
+IFNvZnR3YXJlIEZvdW5kYXRpb24xFTATBgNVBAMTDGZha2Vob3N0bmFtZTAeFw0x
+MDEwMDkxNTAxMDBaFw0yMDEwMDYxNTAxMDBaMGIxCzAJBgNVBAYTAlhZMRcwFQYD
+VQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZv
+dW5kYXRpb24xFTATBgNVBAMTDGZha2Vob3N0bmFtZTCBnzANBgkqhkiG9w0BAQEF
+AAOBjQAwgYkCgYEAmewllWumkv5bkj3MZCutrBbATlAmkEr2dbDXuZetnTdHVwP0
+FqYsaK9UhJs+VGUBWdkETKHUBOmwHt0JRD5YcS8Auq6/Hj5jDmX59d6JhGOstEFh
+m5XLzI21fNTeJZwY5txhGRR2Jd07I/uwsXZhkdG9BmnOAMEqSutp5DzXDbUCAwEA
+AaMbMBkwFwYDVR0RBBAwDoIMZmFrZWhvc3RuYW1lMA0GCSqGSIb3DQEBBQUAA4GB
+AH+iMClLLGSaKWgwXsmdVo4FhTZZHo8Uprrtg3N9FxEeE50btpDVQysgRt5ias3K
+m+bME9zbKwvbVWD5zZdjus4pDgzwF/iHyccL8JyYhxOvS/9zmvAtFXj/APIIbZFp
+IT75d9f88ScIGEtknZQejnrdhB64tYki/EqluiuKBqKD
+-----END CERTIFICATE-----
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
index 04f7422c8d..b6d818e4d4 100644
--- a/Lib/test/lock_tests.py
+++ b/Lib/test/lock_tests.py
@@ -4,7 +4,7 @@ Various tests for synchronization primitives.
import sys
import time
-from _thread import start_new_thread, get_ident
+from _thread import start_new_thread, get_ident, TIMEOUT_MAX
import threading
import unittest
@@ -62,6 +62,14 @@ class BaseTestCase(unittest.TestCase):
support.threading_cleanup(*self._threads)
support.reap_children()
+ def assertTimeout(self, actual, expected):
+ # The waiting and/or time.time() can be imprecise, which
+ # is why comparing to the expected value would sometimes fail
+ # (especially under Windows).
+ self.assertGreaterEqual(actual, expected * 0.6)
+ # Test nothing insane happened
+ self.assertLess(actual, expected * 10.0)
+
class BaseLockTests(BaseTestCase):
"""
@@ -143,6 +151,32 @@ class BaseLockTests(BaseTestCase):
Bunch(f, 15).wait_for_finished()
self.assertEqual(n, len(threading.enumerate()))
+ def test_timeout(self):
+ lock = self.locktype()
+ # Can't set timeout if not blocking
+ self.assertRaises(ValueError, lock.acquire, 0, 1)
+ # Invalid timeout values
+ self.assertRaises(ValueError, lock.acquire, timeout=-100)
+ self.assertRaises(OverflowError, lock.acquire, timeout=1e100)
+ self.assertRaises(OverflowError, lock.acquire, timeout=TIMEOUT_MAX + 1)
+ # TIMEOUT_MAX is ok
+ lock.acquire(timeout=TIMEOUT_MAX)
+ lock.release()
+ t1 = time.time()
+ self.assertTrue(lock.acquire(timeout=5))
+ t2 = time.time()
+ # Just a sanity test that it didn't actually wait for the timeout.
+ self.assertLess(t2 - t1, 5)
+ results = []
+ def f():
+ t1 = time.time()
+ results.append(lock.acquire(timeout=0.5))
+ t2 = time.time()
+ results.append(t2 - t1)
+ Bunch(f, 1).wait_for_finished()
+ self.assertFalse(results[0])
+ self.assertTimeout(results[1], 0.5)
+
class LockTests(BaseLockTests):
"""
@@ -284,14 +318,14 @@ class EventTests(BaseTestCase):
def f():
results1.append(evt.wait(0.0))
t1 = time.time()
- r = evt.wait(0.2)
+ r = evt.wait(0.5)
t2 = time.time()
results2.append((r, t2 - t1))
Bunch(f, N).wait_for_finished()
self.assertEqual(results1, [False] * N)
for r, dt in results2:
self.assertFalse(r)
- self.assertTrue(dt >= 0.2, dt)
+ self.assertTimeout(dt, 0.5)
# The event is set
results1 = []
results2 = []
@@ -341,13 +375,13 @@ class ConditionTests(BaseTestCase):
phase_num = 0
def f():
cond.acquire()
- cond.wait()
+ result = cond.wait()
cond.release()
- results1.append(phase_num)
+ results1.append((result, phase_num))
cond.acquire()
- cond.wait()
+ result = cond.wait()
cond.release()
- results2.append(phase_num)
+ results2.append((result, phase_num))
b = Bunch(f, N)
b.wait_for_started()
_wait()
@@ -360,7 +394,7 @@ class ConditionTests(BaseTestCase):
cond.release()
while len(results1) < 3:
_wait()
- self.assertEqual(results1, [1] * 3)
+ self.assertEqual(results1, [(True, 1)] * 3)
self.assertEqual(results2, [])
# Notify 5 threads: they might be in their first or second wait
cond.acquire()
@@ -370,8 +404,8 @@ class ConditionTests(BaseTestCase):
cond.release()
while len(results1) + len(results2) < 8:
_wait()
- self.assertEqual(results1, [1] * 3 + [2] * 2)
- self.assertEqual(results2, [2] * 3)
+ self.assertEqual(results1, [(True, 1)] * 3 + [(True, 2)] * 2)
+ self.assertEqual(results2, [(True, 2)] * 3)
# Notify all threads: they are all in their second wait
cond.acquire()
cond.notify_all()
@@ -380,8 +414,8 @@ class ConditionTests(BaseTestCase):
cond.release()
while len(results2) < 5:
_wait()
- self.assertEqual(results1, [1] * 3 + [2] * 2)
- self.assertEqual(results2, [2] * 3 + [3] * 2)
+ self.assertEqual(results1, [(True, 1)] * 3 + [(True,2)] * 2)
+ self.assertEqual(results2, [(True, 2)] * 3 + [(True, 3)] * 2)
b.wait_for_finished()
def test_notify(self):
@@ -397,14 +431,60 @@ class ConditionTests(BaseTestCase):
def f():
cond.acquire()
t1 = time.time()
- cond.wait(0.2)
+ result = cond.wait(0.5)
t2 = time.time()
cond.release()
- results.append(t2 - t1)
+ results.append((t2 - t1, result))
Bunch(f, N).wait_for_finished()
- self.assertEqual(len(results), 5)
- for dt in results:
- self.assertTrue(dt >= 0.2, dt)
+ self.assertEqual(len(results), N)
+ for dt, result in results:
+ self.assertTimeout(dt, 0.5)
+ # Note that conceptually (that"s the condition variable protocol)
+ # a wait() may succeed even if no one notifies us and before any
+ # timeout occurs. Spurious wakeups can occur.
+ # This makes it hard to verify the result value.
+ # In practice, this implementation has no spurious wakeups.
+ self.assertFalse(result)
+
+ def test_waitfor(self):
+ cond = self.condtype()
+ state = 0
+ def f():
+ with cond:
+ result = cond.wait_for(lambda : state==4)
+ self.assertTrue(result)
+ self.assertEqual(state, 4)
+ b = Bunch(f, 1)
+ b.wait_for_started()
+ for i in range(5):
+ time.sleep(0.01)
+ with cond:
+ state += 1
+ cond.notify()
+ b.wait_for_finished()
+
+ def test_waitfor_timeout(self):
+ cond = self.condtype()
+ state = 0
+ success = []
+ def f():
+ with cond:
+ dt = time.time()
+ result = cond.wait_for(lambda : state==4, timeout=0.1)
+ dt = time.time() - dt
+ self.assertFalse(result)
+ self.assertTimeout(dt, 0.1)
+ success.append(None)
+ b = Bunch(f, 1)
+ b.wait_for_started()
+ # Only increment 3 times, so state == 4 is never reached.
+ for i in range(3):
+ time.sleep(0.01)
+ with cond:
+ state += 1
+ cond.notify()
+ b.wait_for_finished()
+ self.assertEqual(len(success), 1)
class BaseSemaphoreTests(BaseTestCase):
@@ -487,6 +567,19 @@ class BaseSemaphoreTests(BaseTestCase):
# ordered.
self.assertEqual(sorted(results), [False] * 7 + [True] * 3 )
+ def test_acquire_timeout(self):
+ sem = self.semtype(2)
+ self.assertRaises(ValueError, sem.acquire, False, timeout=1.0)
+ self.assertTrue(sem.acquire(timeout=0.005))
+ self.assertTrue(sem.acquire(timeout=0.005))
+ self.assertFalse(sem.acquire(timeout=0.005))
+ sem.release()
+ self.assertTrue(sem.acquire(timeout=0.005))
+ t = time.time()
+ self.assertFalse(sem.acquire(timeout=0.5))
+ dt = time.time() - t
+ self.assertTimeout(dt, 0.5)
+
def test_default_value(self):
# The default initial value is 1.
sem = self.semtype()
@@ -544,3 +637,196 @@ class BoundedSemaphoreTests(BaseSemaphoreTests):
sem.acquire()
sem.release()
self.assertRaises(ValueError, sem.release)
+
+
+class BarrierTests(BaseTestCase):
+ """
+ Tests for Barrier objects.
+ """
+ N = 5
+ defaultTimeout = 2.0
+
+ def setUp(self):
+ self.barrier = self.barriertype(self.N, timeout=self.defaultTimeout)
+ def tearDown(self):
+ self.barrier.abort()
+
+ def run_threads(self, f):
+ b = Bunch(f, self.N-1)
+ f()
+ b.wait_for_finished()
+
+ def multipass(self, results, n):
+ m = self.barrier.parties
+ self.assertEqual(m, self.N)
+ for i in range(n):
+ results[0].append(True)
+ self.assertEqual(len(results[1]), i * m)
+ self.barrier.wait()
+ results[1].append(True)
+ self.assertEqual(len(results[0]), (i + 1) * m)
+ self.barrier.wait()
+ self.assertEqual(self.barrier.n_waiting, 0)
+ self.assertFalse(self.barrier.broken)
+
+ def test_barrier(self, passes=1):
+ """
+ Test that a barrier is passed in lockstep
+ """
+ results = [[],[]]
+ def f():
+ self.multipass(results, passes)
+ self.run_threads(f)
+
+ def test_barrier_10(self):
+ """
+ Test that a barrier works for 10 consecutive runs
+ """
+ return self.test_barrier(10)
+
+ def test_wait_return(self):
+ """
+ test the return value from barrier.wait
+ """
+ results = []
+ def f():
+ r = self.barrier.wait()
+ results.append(r)
+
+ self.run_threads(f)
+ self.assertEqual(sum(results), sum(range(self.N)))
+
+ def test_action(self):
+ """
+ Test the 'action' callback
+ """
+ results = []
+ def action():
+ results.append(True)
+ barrier = self.barriertype(self.N, action)
+ def f():
+ barrier.wait()
+ self.assertEqual(len(results), 1)
+
+ self.run_threads(f)
+
+ def test_abort(self):
+ """
+ Test that an abort will put the barrier in a broken state
+ """
+ results1 = []
+ results2 = []
+ def f():
+ try:
+ i = self.barrier.wait()
+ if i == self.N//2:
+ raise RuntimeError
+ self.barrier.wait()
+ results1.append(True)
+ except threading.BrokenBarrierError:
+ results2.append(True)
+ except RuntimeError:
+ self.barrier.abort()
+ pass
+
+ self.run_threads(f)
+ self.assertEqual(len(results1), 0)
+ self.assertEqual(len(results2), self.N-1)
+ self.assertTrue(self.barrier.broken)
+
+ def test_reset(self):
+ """
+ Test that a 'reset' on a barrier frees the waiting threads
+ """
+ results1 = []
+ results2 = []
+ results3 = []
+ def f():
+ i = self.barrier.wait()
+ if i == self.N//2:
+ # Wait until the other threads are all in the barrier.
+ while self.barrier.n_waiting < self.N-1:
+ time.sleep(0.001)
+ self.barrier.reset()
+ else:
+ try:
+ self.barrier.wait()
+ results1.append(True)
+ except threading.BrokenBarrierError:
+ results2.append(True)
+ # Now, pass the barrier again
+ self.barrier.wait()
+ results3.append(True)
+
+ self.run_threads(f)
+ self.assertEqual(len(results1), 0)
+ self.assertEqual(len(results2), self.N-1)
+ self.assertEqual(len(results3), self.N)
+
+
+ def test_abort_and_reset(self):
+ """
+ Test that a barrier can be reset after being broken.
+ """
+ results1 = []
+ results2 = []
+ results3 = []
+ barrier2 = self.barriertype(self.N)
+ def f():
+ try:
+ i = self.barrier.wait()
+ if i == self.N//2:
+ raise RuntimeError
+ self.barrier.wait()
+ results1.append(True)
+ except threading.BrokenBarrierError:
+ results2.append(True)
+ except RuntimeError:
+ self.barrier.abort()
+ pass
+ # Synchronize and reset the barrier. Must synchronize first so
+ # that everyone has left it when we reset, and after so that no
+ # one enters it before the reset.
+ if barrier2.wait() == self.N//2:
+ self.barrier.reset()
+ barrier2.wait()
+ self.barrier.wait()
+ results3.append(True)
+
+ self.run_threads(f)
+ self.assertEqual(len(results1), 0)
+ self.assertEqual(len(results2), self.N-1)
+ self.assertEqual(len(results3), self.N)
+
+ def test_timeout(self):
+ """
+ Test wait(timeout)
+ """
+ def f():
+ i = self.barrier.wait()
+ if i == self.N // 2:
+ # One thread is late!
+ time.sleep(1.0)
+ # Default timeout is 2.0, so this is shorter.
+ self.assertRaises(threading.BrokenBarrierError,
+ self.barrier.wait, 0.5)
+ self.run_threads(f)
+
+ def test_default_timeout(self):
+ """
+ Test the barrier's default timeout
+ """
+ #create a barrier with a low default timeout
+ barrier = self.barriertype(self.N, timeout=0.1)
+ def f():
+ i = barrier.wait()
+ if i == self.N // 2:
+ # One thread is later than the default timeout of 0.1s.
+ time.sleep(1.0)
+ self.assertRaises(threading.BrokenBarrierError, barrier.wait)
+ self.run_threads(f)
+
+ def test_single_thread(self):
+ b = self.barriertype(1)
+ b.wait()
+ b.wait()
diff --git a/Lib/test/make_ssl_certs.py b/Lib/test/make_ssl_certs.py
new file mode 100644
index 0000000000..48d2e57f4b
--- /dev/null
+++ b/Lib/test/make_ssl_certs.py
@@ -0,0 +1,64 @@
+"""Make the custom certificate and private key files used by test_ssl
+and friends."""
+
+import os
+import sys
+import tempfile
+from subprocess import *
+
+req_template = """
+ [req]
+ distinguished_name = req_distinguished_name
+ x509_extensions = req_x509_extensions
+ prompt = no
+
+ [req_distinguished_name]
+ C = XY
+ L = Castle Anthrax
+ O = Python Software Foundation
+ CN = {hostname}
+
+ [req_x509_extensions]
+ subjectAltName = DNS:{hostname}
+ """
+
+here = os.path.abspath(os.path.dirname(__file__))
+
+def make_cert_key(hostname):
+ tempnames = []
+ for i in range(3):
+ with tempfile.NamedTemporaryFile(delete=False) as f:
+ tempnames.append(f.name)
+ req_file, cert_file, key_file = tempnames
+ try:
+ with open(req_file, 'w') as f:
+ f.write(req_template.format(hostname=hostname))
+ args = ['req', '-new', '-days', '3650', '-nodes', '-x509',
+ '-newkey', 'rsa:1024', '-keyout', key_file,
+ '-out', cert_file, '-config', req_file]
+ check_call(['openssl'] + args)
+ with open(cert_file, 'r') as f:
+ cert = f.read()
+ with open(key_file, 'r') as f:
+ key = f.read()
+ return cert, key
+ finally:
+ for name in tempnames:
+ os.remove(name)
+
+
+if __name__ == '__main__':
+ os.chdir(here)
+ cert, key = make_cert_key('localhost')
+ with open('ssl_cert.pem', 'w') as f:
+ f.write(cert)
+ with open('ssl_key.pem', 'w') as f:
+ f.write(key)
+ with open('keycert.pem', 'w') as f:
+ f.write(key)
+ f.write(cert)
+ # For certificate matching tests
+ cert, key = make_cert_key('fakehostname')
+ with open('keycert2.pem', 'w') as f:
+ f.write(key)
+ f.write(cert)
diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py
index c34bd59e9c..d2b7a59a30 100644
--- a/Lib/test/mapping_tests.py
+++ b/Lib/test/mapping_tests.py
@@ -56,9 +56,9 @@ class BasicTestMappingProtocol(unittest.TestCase):
self.assertEqual(len(d), len(self.reference))
#__contains__
for k in self.reference:
- self.assertTrue(k in d)
+ self.assertIn(k, d)
for k in self.other:
- self.assertFalse(k in d)
+ self.assertNotIn(k, d)
#cmp
self.assertEqual(p, p)
self.assertEqual(d, d)
@@ -85,7 +85,7 @@ class BasicTestMappingProtocol(unittest.TestCase):
knownkey, knownvalue = next(iter(self.other.items()))
self.assertEqual(d.get(key, knownvalue), value)
self.assertEqual(d.get(knownkey, knownvalue), knownvalue)
- self.assertFalse(knownkey in d)
+ self.assertNotIn(knownkey, d)
def test_write(self):
# Test for write operations on mapping
@@ -115,16 +115,16 @@ class BasicTestMappingProtocol(unittest.TestCase):
self.assertEqual(d[knownkey], knownvalue)
#pop
self.assertEqual(d.pop(knownkey), knownvalue)
- self.assertFalse(knownkey in d)
+ self.assertNotIn(knownkey, d)
self.assertRaises(KeyError, d.pop, knownkey)
default = 909
d[knownkey] = knownvalue
self.assertEqual(d.pop(knownkey, default), knownvalue)
- self.assertFalse(knownkey in d)
+ self.assertNotIn(knownkey, d)
self.assertEqual(d.pop(knownkey, default), default)
#popitem
key, value = d.popitem()
- self.assertFalse(key in d)
+ self.assertNotIn(key, d)
self.assertEqual(value, self.reference[key])
p=self._empty_mapping()
self.assertRaises(KeyError, p.popitem)
@@ -142,8 +142,8 @@ class BasicTestMappingProtocol(unittest.TestCase):
d = self._empty_mapping()
self.assertEqual(list(d.keys()), [])
d = self.reference
- self.assertTrue(list(self.inmapping.keys())[0] in d.keys())
- self.assertTrue(list(self.other.keys())[0] not in d.keys())
+ self.assertIn(list(self.inmapping.keys())[0], d.keys())
+ self.assertNotIn(list(self.other.keys())[0], d.keys())
self.assertRaises(TypeError, d.keys, None)
def test_values(self):
@@ -320,9 +320,9 @@ class TestMappingProtocol(BasicTestMappingProtocol):
self.assertEqual(list(d.keys()), [])
d = self._full_mapping({'a': 1, 'b': 2})
k = d.keys()
- self.assertTrue('a' in k)
- self.assertTrue('b' in k)
- self.assertTrue('c' not in k)
+ self.assertIn('a', k)
+ self.assertIn('b', k)
+ self.assertNotIn('c', k)
def test_values(self):
BasicTestMappingProtocol.test_values(self)
@@ -337,12 +337,13 @@ class TestMappingProtocol(BasicTestMappingProtocol):
def test_contains(self):
d = self._empty_mapping()
+ self.assertNotIn('a', d)
self.assertTrue(not ('a' in d))
self.assertTrue('a' not in d)
d = self._full_mapping({'a': 1, 'b': 2})
- self.assertTrue('a' in d)
- self.assertTrue('b' in d)
- self.assertTrue('c' not in d)
+ self.assertIn('a', d)
+ self.assertIn('b', d)
+ self.assertNotIn('c', d)
self.assertRaises(TypeError, d.__contains__)
@@ -434,15 +435,13 @@ class TestMappingProtocol(BasicTestMappingProtocol):
self.assertEqual(dictlike().fromkeys('a'), {'a':None})
self.assertTrue(dictlike.fromkeys('a').__class__ is dictlike)
self.assertTrue(dictlike().fromkeys('a').__class__ is dictlike)
- # FIXME: the following won't work with UserDict, because it's an old style class
- # self.assertTrue(type(dictlike.fromkeys('a')) is dictlike)
+ self.assertTrue(type(dictlike.fromkeys('a')) is dictlike)
class mydict(self.type2test):
def __new__(cls):
return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
- # FIXME: the following won't work with UserDict, because it's an old style class
- # self.assertTrue(isinstance(ud, collections.UserDict))
+ self.assertIsInstance(ud, collections.UserDict)
self.assertRaises(TypeError, dict.fromkeys)
class Exc(Exception): pass
@@ -472,7 +471,7 @@ class TestMappingProtocol(BasicTestMappingProtocol):
self.assertEqual(d.copy(), {1:1, 2:2, 3:3})
d = self._empty_mapping()
self.assertEqual(d.copy(), d)
- self.assertTrue(isinstance(d.copy(), d.__class__))
+ self.assertIsInstance(d.copy(), d.__class__)
self.assertRaises(TypeError, d.copy, None)
def test_get(self):
@@ -528,13 +527,6 @@ class TestMappingProtocol(BasicTestMappingProtocol):
d = self._empty_mapping()
k, v = 'abc', 'def'
- # verify longs/ints get same value when key > 32 bits (for 64-bit archs)
- # see SF bug #689659
- x = 4503599627370496
- y = 4503599627370496
- h = self._full_mapping({x: 'anything', y: 'something else'})
- self.assertEqual(h[x], h[y])
-
self.assertEqual(d.pop(k, v), v)
d[k] = v
self.assertEqual(d.pop(k, 1), v)
@@ -577,7 +569,7 @@ class TestHashMappingProtocol(TestMappingProtocol):
return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
- self.assertTrue(isinstance(ud, collections.UserDict))
+ self.assertIsInstance(ud, collections.UserDict)
def test_pop(self):
TestMappingProtocol.test_pop(self)
diff --git a/Lib/test/math_testcases.txt b/Lib/test/math_testcases.txt
new file mode 100644
index 0000000000..5e24335a87
--- /dev/null
+++ b/Lib/test/math_testcases.txt
@@ -0,0 +1,519 @@
+-- Testcases for functions in math.
+--
+-- Each line takes the form:
+--
+-- <testid> <function> <input_value> -> <output_value> <flags>
+--
+-- where:
+--
+-- <testid> is a short name identifying the test,
+--
+-- <function> is the function to be tested (exp, cos, asinh, ...),
+--
+-- <input_value> is a string representing a floating-point value
+--
+-- <output_value> is the expected (ideal) output value, again
+-- represented as a string.
+--
+-- <flags> is a list of the floating-point flags required by C99
+--
+-- The possible flags are:
+--
+-- divide-by-zero : raised when a finite input gives a
+-- mathematically infinite result.
+--
+-- overflow : raised when a finite input gives a finite result that
+-- is too large to fit in the usual range of an IEEE 754 double.
+--
+-- invalid : raised for invalid inputs (e.g., sqrt(-1))
+--
+-- ignore-sign : indicates that the sign of the result is
+-- unspecified; e.g., if the result is given as inf,
+-- then both -inf and inf should be accepted as correct.
+--
+-- Flags may appear in any order.
+--
+-- Lines beginning with '--' (like this one) start a comment, and are
+-- ignored. Blank lines, or lines containing only whitespace, are also
+-- ignored.
+
+-- Many of the values below were computed with the help of
+-- version 2.4 of the MPFR library for multiple-precision
+-- floating-point computations with correct rounding. All output
+-- values in this file are (modulo yet-to-be-discovered bugs)
+-- correctly rounded, provided that each input and output decimal
+-- floating-point value below is interpreted as a representation of
+-- the corresponding nearest IEEE 754 double-precision value. See the
+-- MPFR homepage at http://www.mpfr.org for more information about the
+-- MPFR project.
+
+
+-------------------------
+-- erf: error function --
+-------------------------
+
+erf0000 erf 0.0 -> 0.0
+erf0001 erf -0.0 -> -0.0
+erf0002 erf inf -> 1.0
+erf0003 erf -inf -> -1.0
+erf0004 erf nan -> nan
+
+-- tiny values
+erf0010 erf 1e-308 -> 1.1283791670955125e-308
+erf0011 erf 5e-324 -> 4.9406564584124654e-324
+erf0012 erf 1e-10 -> 1.1283791670955126e-10
+
+-- small integers
+erf0020 erf 1 -> 0.84270079294971489
+erf0021 erf 2 -> 0.99532226501895271
+erf0022 erf 3 -> 0.99997790950300136
+erf0023 erf 4 -> 0.99999998458274209
+erf0024 erf 5 -> 0.99999999999846256
+erf0025 erf 6 -> 1.0
+
+erf0030 erf -1 -> -0.84270079294971489
+erf0031 erf -2 -> -0.99532226501895271
+erf0032 erf -3 -> -0.99997790950300136
+erf0033 erf -4 -> -0.99999998458274209
+erf0034 erf -5 -> -0.99999999999846256
+erf0035 erf -6 -> -1.0
+
+-- huge values should all go to +/-1, depending on sign
+erf0040 erf -40 -> -1.0
+erf0041 erf 1e16 -> 1.0
+erf0042 erf -1e150 -> -1.0
+erf0043 erf 1.7e308 -> 1.0
+
+-- Issue 8986: inputs x with exp(-x*x) near the underflow threshold
+-- incorrectly signalled overflow on some platforms.
+erf0100 erf 26.2 -> 1.0
+erf0101 erf 26.4 -> 1.0
+erf0102 erf 26.6 -> 1.0
+erf0103 erf 26.8 -> 1.0
+erf0104 erf 27.0 -> 1.0
+erf0105 erf 27.2 -> 1.0
+erf0106 erf 27.4 -> 1.0
+erf0107 erf 27.6 -> 1.0
+
+erf0110 erf -26.2 -> -1.0
+erf0111 erf -26.4 -> -1.0
+erf0112 erf -26.6 -> -1.0
+erf0113 erf -26.8 -> -1.0
+erf0114 erf -27.0 -> -1.0
+erf0115 erf -27.2 -> -1.0
+erf0116 erf -27.4 -> -1.0
+erf0117 erf -27.6 -> -1.0
+
+----------------------------------------
+-- erfc: complementary error function --
+----------------------------------------
+
+erfc0000 erfc 0.0 -> 1.0
+erfc0001 erfc -0.0 -> 1.0
+erfc0002 erfc inf -> 0.0
+erfc0003 erfc -inf -> 2.0
+erfc0004 erfc nan -> nan
+
+-- tiny values
+erfc0010 erfc 1e-308 -> 1.0
+erfc0011 erfc 5e-324 -> 1.0
+erfc0012 erfc 1e-10 -> 0.99999999988716204
+
+-- small integers
+erfc0020 erfc 1 -> 0.15729920705028513
+erfc0021 erfc 2 -> 0.0046777349810472662
+erfc0022 erfc 3 -> 2.2090496998585441e-05
+erfc0023 erfc 4 -> 1.541725790028002e-08
+erfc0024 erfc 5 -> 1.5374597944280349e-12
+erfc0025 erfc 6 -> 2.1519736712498913e-17
+
+erfc0030 erfc -1 -> 1.8427007929497148
+erfc0031 erfc -2 -> 1.9953222650189528
+erfc0032 erfc -3 -> 1.9999779095030015
+erfc0033 erfc -4 -> 1.9999999845827421
+erfc0034 erfc -5 -> 1.9999999999984626
+erfc0035 erfc -6 -> 2.0
+
+-- as x -> infinity, erfc(x) behaves like exp(-x*x)/x/sqrt(pi)
+erfc0040 erfc 20 -> 5.3958656116079012e-176
+erfc0041 erfc 25 -> 8.3001725711965228e-274
+erfc0042 erfc 27 -> 5.2370464393526292e-319
+erfc0043 erfc 28 -> 0.0
+
+-- huge values
+erfc0050 erfc -40 -> 2.0
+erfc0051 erfc 1e16 -> 0.0
+erfc0052 erfc -1e150 -> 2.0
+erfc0053 erfc 1.7e308 -> 0.0
+
+-- Issue 8986: inputs x with exp(-x*x) near the underflow threshold
+-- incorrectly signalled overflow on some platforms.
+erfc0100 erfc 26.2 -> 1.6432507924389461e-300
+erfc0101 erfc 26.4 -> 4.4017768588035426e-305
+erfc0102 erfc 26.6 -> 1.0885125885442269e-309
+erfc0103 erfc 26.8 -> 2.4849621571966629e-314
+erfc0104 erfc 27.0 -> 5.2370464393526292e-319
+erfc0105 erfc 27.2 -> 9.8813129168249309e-324
+erfc0106 erfc 27.4 -> 0.0
+erfc0107 erfc 27.6 -> 0.0
+
+erfc0110 erfc -26.2 -> 2.0
+erfc0111 erfc -26.4 -> 2.0
+erfc0112 erfc -26.6 -> 2.0
+erfc0113 erfc -26.8 -> 2.0
+erfc0114 erfc -27.0 -> 2.0
+erfc0115 erfc -27.2 -> 2.0
+erfc0116 erfc -27.4 -> 2.0
+erfc0117 erfc -27.6 -> 2.0
+
+---------------------------------------------------------
+-- lgamma: log of absolute value of the gamma function --
+---------------------------------------------------------
+
+-- special values
+lgam0000 lgamma 0.0 -> inf divide-by-zero
+lgam0001 lgamma -0.0 -> inf divide-by-zero
+lgam0002 lgamma inf -> inf
+lgam0003 lgamma -inf -> inf
+lgam0004 lgamma nan -> nan
+
+-- negative integers
+lgam0010 lgamma -1 -> inf divide-by-zero
+lgam0011 lgamma -2 -> inf divide-by-zero
+lgam0012 lgamma -1e16 -> inf divide-by-zero
+lgam0013 lgamma -1e300 -> inf divide-by-zero
+lgam0014 lgamma -1.79e308 -> inf divide-by-zero
+
+-- small positive integers give factorials
+lgam0020 lgamma 1 -> 0.0
+lgam0021 lgamma 2 -> 0.0
+lgam0022 lgamma 3 -> 0.69314718055994529
+lgam0023 lgamma 4 -> 1.791759469228055
+lgam0024 lgamma 5 -> 3.1780538303479458
+lgam0025 lgamma 6 -> 4.7874917427820458
+
+-- half integers
+lgam0030 lgamma 0.5 -> 0.57236494292470008
+lgam0031 lgamma 1.5 -> -0.12078223763524522
+lgam0032 lgamma 2.5 -> 0.28468287047291918
+lgam0033 lgamma 3.5 -> 1.2009736023470743
+lgam0034 lgamma -0.5 -> 1.2655121234846454
+lgam0035 lgamma -1.5 -> 0.86004701537648098
+lgam0036 lgamma -2.5 -> -0.056243716497674054
+lgam0037 lgamma -3.5 -> -1.309006684993042
+
+-- values near 0
+lgam0040 lgamma 0.1 -> 2.252712651734206
+lgam0041 lgamma 0.01 -> 4.5994798780420219
+lgam0042 lgamma 1e-8 -> 18.420680738180209
+lgam0043 lgamma 1e-16 -> 36.841361487904734
+lgam0044 lgamma 1e-30 -> 69.077552789821368
+lgam0045 lgamma 1e-160 -> 368.41361487904732
+lgam0046 lgamma 1e-308 -> 709.19620864216608
+lgam0047 lgamma 5.6e-309 -> 709.77602713741896
+lgam0048 lgamma 5.5e-309 -> 709.79404564292167
+lgam0049 lgamma 1e-309 -> 711.49879373516012
+lgam0050 lgamma 1e-323 -> 743.74692474082133
+lgam0051 lgamma 5e-324 -> 744.44007192138122
+lgam0060 lgamma -0.1 -> 2.3689613327287886
+lgam0061 lgamma -0.01 -> 4.6110249927528013
+lgam0062 lgamma -1e-8 -> 18.420680749724522
+lgam0063 lgamma -1e-16 -> 36.841361487904734
+lgam0064 lgamma -1e-30 -> 69.077552789821368
+lgam0065 lgamma -1e-160 -> 368.41361487904732
+lgam0066 lgamma -1e-308 -> 709.19620864216608
+lgam0067 lgamma -5.6e-309 -> 709.77602713741896
+lgam0068 lgamma -5.5e-309 -> 709.79404564292167
+lgam0069 lgamma -1e-309 -> 711.49879373516012
+lgam0070 lgamma -1e-323 -> 743.74692474082133
+lgam0071 lgamma -5e-324 -> 744.44007192138122
+
+-- values near negative integers
+lgam0080 lgamma -0.99999999999999989 -> 36.736800569677101
+lgam0081 lgamma -1.0000000000000002 -> 36.043653389117154
+lgam0082 lgamma -1.9999999999999998 -> 35.350506208557213
+lgam0083 lgamma -2.0000000000000004 -> 34.657359027997266
+lgam0084 lgamma -100.00000000000001 -> -331.85460524980607
+lgam0085 lgamma -99.999999999999986 -> -331.85460524980596
+
+-- large inputs
+lgam0100 lgamma 170 -> 701.43726380873704
+lgam0101 lgamma 171 -> 706.57306224578736
+lgam0102 lgamma 171.624 -> 709.78077443669895
+lgam0103 lgamma 171.625 -> 709.78591682948365
+lgam0104 lgamma 172 -> 711.71472580228999
+lgam0105 lgamma 2000 -> 13198.923448054265
+lgam0106 lgamma 2.55998332785163e305 -> 1.7976931348623099e+308
+lgam0107 lgamma 2.55998332785164e305 -> inf overflow
+lgam0108 lgamma 1.7e308 -> inf overflow
+
+-- inputs for which gamma(x) is tiny
+lgam0120 lgamma -100.5 -> -364.90096830942736
+lgam0121 lgamma -160.5 -> -656.88005261126432
+lgam0122 lgamma -170.5 -> -707.99843314507882
+lgam0123 lgamma -171.5 -> -713.14301641168481
+lgam0124 lgamma -176.5 -> -738.95247590846486
+lgam0125 lgamma -177.5 -> -744.13144651738037
+lgam0126 lgamma -178.5 -> -749.3160351186001
+
+lgam0130 lgamma -1000.5 -> -5914.4377011168517
+lgam0131 lgamma -30000.5 -> -279278.6629959144
+lgam0132 lgamma -4503599627370495.5 -> -1.5782258434492883e+17
+
+-- results close to 0: positive argument ...
+lgam0150 lgamma 0.99999999999999989 -> 6.4083812134800075e-17
+lgam0151 lgamma 1.0000000000000002 -> -1.2816762426960008e-16
+lgam0152 lgamma 1.9999999999999998 -> -9.3876980655431170e-17
+lgam0153 lgamma 2.0000000000000004 -> 1.8775396131086244e-16
+
+-- ... and negative argument
+lgam0160 lgamma -2.7476826467 -> -5.2477408147689136e-11
+lgam0161 lgamma -2.457024738 -> 3.3464637541912932e-10
+
+
+---------------------------
+-- gamma: Gamma function --
+---------------------------
+
+-- special values
+gam0000 gamma 0.0 -> inf divide-by-zero
+gam0001 gamma -0.0 -> -inf divide-by-zero
+gam0002 gamma inf -> inf
+gam0003 gamma -inf -> nan invalid
+gam0004 gamma nan -> nan
+
+-- negative integers inputs are invalid
+gam0010 gamma -1 -> nan invalid
+gam0011 gamma -2 -> nan invalid
+gam0012 gamma -1e16 -> nan invalid
+gam0013 gamma -1e300 -> nan invalid
+
+-- small positive integers give factorials
+gam0020 gamma 1 -> 1
+gam0021 gamma 2 -> 1
+gam0022 gamma 3 -> 2
+gam0023 gamma 4 -> 6
+gam0024 gamma 5 -> 24
+gam0025 gamma 6 -> 120
+
+-- half integers
+gam0030 gamma 0.5 -> 1.7724538509055161
+gam0031 gamma 1.5 -> 0.88622692545275805
+gam0032 gamma 2.5 -> 1.3293403881791370
+gam0033 gamma 3.5 -> 3.3233509704478426
+gam0034 gamma -0.5 -> -3.5449077018110322
+gam0035 gamma -1.5 -> 2.3632718012073548
+gam0036 gamma -2.5 -> -0.94530872048294190
+gam0037 gamma -3.5 -> 0.27008820585226911
+
+-- values near 0
+gam0040 gamma 0.1 -> 9.5135076986687306
+gam0041 gamma 0.01 -> 99.432585119150602
+gam0042 gamma 1e-8 -> 99999999.422784343
+gam0043 gamma 1e-16 -> 10000000000000000
+gam0044 gamma 1e-30 -> 9.9999999999999988e+29
+gam0045 gamma 1e-160 -> 1.0000000000000000e+160
+gam0046 gamma 1e-308 -> 1.0000000000000000e+308
+gam0047 gamma 5.6e-309 -> 1.7857142857142848e+308
+gam0048 gamma 5.5e-309 -> inf overflow
+gam0049 gamma 1e-309 -> inf overflow
+gam0050 gamma 1e-323 -> inf overflow
+gam0051 gamma 5e-324 -> inf overflow
+gam0060 gamma -0.1 -> -10.686287021193193
+gam0061 gamma -0.01 -> -100.58719796441078
+gam0062 gamma -1e-8 -> -100000000.57721567
+gam0063 gamma -1e-16 -> -10000000000000000
+gam0064 gamma -1e-30 -> -9.9999999999999988e+29
+gam0065 gamma -1e-160 -> -1.0000000000000000e+160
+gam0066 gamma -1e-308 -> -1.0000000000000000e+308
+gam0067 gamma -5.6e-309 -> -1.7857142857142848e+308
+gam0068 gamma -5.5e-309 -> -inf overflow
+gam0069 gamma -1e-309 -> -inf overflow
+gam0070 gamma -1e-323 -> -inf overflow
+gam0071 gamma -5e-324 -> -inf overflow
+
+-- values near negative integers
+gam0080 gamma -0.99999999999999989 -> -9007199254740992.0
+gam0081 gamma -1.0000000000000002 -> 4503599627370495.5
+gam0082 gamma -1.9999999999999998 -> 2251799813685248.5
+gam0083 gamma -2.0000000000000004 -> -1125899906842623.5
+gam0084 gamma -100.00000000000001 -> -7.5400833348831090e-145
+gam0085 gamma -99.999999999999986 -> 7.5400833348840962e-145
+
+-- large inputs
+gam0100 gamma 170 -> 4.2690680090047051e+304
+gam0101 gamma 171 -> 7.2574156153079990e+306
+gam0102 gamma 171.624 -> 1.7942117599248104e+308
+gam0103 gamma 171.625 -> inf overflow
+gam0104 gamma 172 -> inf overflow
+gam0105 gamma 2000 -> inf overflow
+gam0106 gamma 1.7e308 -> inf overflow
+
+-- inputs for which gamma(x) is tiny
+gam0120 gamma -100.5 -> -3.3536908198076787e-159
+gam0121 gamma -160.5 -> -5.2555464470078293e-286
+gam0122 gamma -170.5 -> -3.3127395215386074e-308
+gam0123 gamma -171.5 -> 1.9316265431711902e-310
+gam0124 gamma -176.5 -> -1.1956388629358166e-321
+gam0125 gamma -177.5 -> 4.9406564584124654e-324
+gam0126 gamma -178.5 -> -0.0
+gam0127 gamma -179.5 -> 0.0
+gam0128 gamma -201.0001 -> 0.0
+gam0129 gamma -202.9999 -> -0.0
+gam0130 gamma -1000.5 -> -0.0
+gam0131 gamma -1000000000.3 -> -0.0
+gam0132 gamma -4503599627370495.5 -> 0.0
+
+-- inputs that cause problems for the standard reflection formula,
+-- thanks to loss of accuracy in 1-x
+gam0140 gamma -63.349078729022985 -> 4.1777971677761880e-88
+gam0141 gamma -127.45117632943295 -> 1.1831110896236810e-214
+
+
+-----------------------------------------------------------
+-- log1p: log(1 + x), without precision loss for small x --
+-----------------------------------------------------------
+
+-- special values
+log1p0000 log1p 0.0 -> 0.0
+log1p0001 log1p -0.0 -> -0.0
+log1p0002 log1p inf -> inf
+log1p0003 log1p -inf -> nan invalid
+log1p0004 log1p nan -> nan
+
+-- singularity at -1.0
+log1p0010 log1p -1.0 -> -inf divide-by-zero
+log1p0011 log1p -0.9999999999999999 -> -36.736800569677101
+
+-- finite values < 1.0 are invalid
+log1p0020 log1p -1.0000000000000002 -> nan invalid
+log1p0021 log1p -1.1 -> nan invalid
+log1p0022 log1p -2.0 -> nan invalid
+log1p0023 log1p -1e300 -> nan invalid
+
+-- tiny x: log1p(x) ~ x
+log1p0110 log1p 5e-324 -> 5e-324
+log1p0111 log1p 1e-320 -> 1e-320
+log1p0112 log1p 1e-300 -> 1e-300
+log1p0113 log1p 1e-150 -> 1e-150
+log1p0114 log1p 1e-20 -> 1e-20
+
+log1p0120 log1p -5e-324 -> -5e-324
+log1p0121 log1p -1e-320 -> -1e-320
+log1p0122 log1p -1e-300 -> -1e-300
+log1p0123 log1p -1e-150 -> -1e-150
+log1p0124 log1p -1e-20 -> -1e-20
+
+-- some (mostly) random small and moderate-sized values
+log1p0200 log1p -0.89156889782277482 -> -2.2216403106762863
+log1p0201 log1p -0.23858496047770464 -> -0.27257668276980057
+log1p0202 log1p -0.011641726191307515 -> -0.011710021654495657
+log1p0203 log1p -0.0090126398571693817 -> -0.0090534993825007650
+log1p0204 log1p -0.00023442805985712781 -> -0.00023445554240995693
+log1p0205 log1p -1.5672870980936349e-5 -> -1.5672993801662046e-5
+log1p0206 log1p -7.9650013274825295e-6 -> -7.9650330482740401e-6
+log1p0207 log1p -2.5202948343227410e-7 -> -2.5202951519170971e-7
+log1p0208 log1p -8.2446372820745855e-11 -> -8.2446372824144559e-11
+log1p0209 log1p -8.1663670046490789e-12 -> -8.1663670046824230e-12
+log1p0210 log1p 7.0351735084656292e-18 -> 7.0351735084656292e-18
+log1p0211 log1p 5.2732161907375226e-12 -> 5.2732161907236188e-12
+log1p0212 log1p 1.0000000000000000e-10 -> 9.9999999995000007e-11
+log1p0213 log1p 2.1401273266000197e-9 -> 2.1401273243099470e-9
+log1p0214 log1p 1.2668914653979560e-8 -> 1.2668914573728861e-8
+log1p0215 log1p 1.6250007816299069e-6 -> 1.6249994613175672e-6
+log1p0216 log1p 8.3740495645839399e-6 -> 8.3740145024266269e-6
+log1p0217 log1p 3.0000000000000001e-5 -> 2.9999550008999799e-5
+log1p0218 log1p 0.0070000000000000001 -> 0.0069756137364252423
+log1p0219 log1p 0.013026235315053002 -> 0.012942123564008787
+log1p0220 log1p 0.013497160797236184 -> 0.013406885521915038
+log1p0221 log1p 0.027625599078135284 -> 0.027250897463483054
+log1p0222 log1p 0.14179687245544870 -> 0.13260322540908789
+
+-- large values
+log1p0300 log1p 1.7976931348623157e+308 -> 709.78271289338397
+log1p0301 log1p 1.0000000000000001e+300 -> 690.77552789821368
+log1p0302 log1p 1.0000000000000001e+70 -> 161.18095650958321
+log1p0303 log1p 10000000000.000000 -> 23.025850930040455
+
+-- other values transferred from testLog1p in test_math
+log1p0400 log1p -0.63212055882855767 -> -1.0000000000000000
+log1p0401 log1p 1.7182818284590451 -> 1.0000000000000000
+log1p0402 log1p 1.0000000000000000 -> 0.69314718055994529
+log1p0403 log1p 1.2379400392853803e+27 -> 62.383246250395075
+
+
+-----------------------------------------------------------
+-- expm1: exp(x) - 1, without precision loss for small x --
+-----------------------------------------------------------
+
+-- special values
+expm10000 expm1 0.0 -> 0.0
+expm10001 expm1 -0.0 -> -0.0
+expm10002 expm1 inf -> inf
+expm10003 expm1 -inf -> -1.0
+expm10004 expm1 nan -> nan
+
+-- expm1(x) ~ x for tiny x
+expm10010 expm1 5e-324 -> 5e-324
+expm10011 expm1 1e-320 -> 1e-320
+expm10012 expm1 1e-300 -> 1e-300
+expm10013 expm1 1e-150 -> 1e-150
+expm10014 expm1 1e-20 -> 1e-20
+
+expm10020 expm1 -5e-324 -> -5e-324
+expm10021 expm1 -1e-320 -> -1e-320
+expm10022 expm1 -1e-300 -> -1e-300
+expm10023 expm1 -1e-150 -> -1e-150
+expm10024 expm1 -1e-20 -> -1e-20
+
+-- moderate sized values, where direct evaluation runs into trouble
+expm10100 expm1 1e-10 -> 1.0000000000500000e-10
+expm10101 expm1 -9.9999999999999995e-08 -> -9.9999995000000163e-8
+expm10102 expm1 3.0000000000000001e-05 -> 3.0000450004500034e-5
+expm10103 expm1 -0.0070000000000000001 -> -0.0069755570667648951
+expm10104 expm1 -0.071499208740094633 -> -0.069002985744820250
+expm10105 expm1 -0.063296004180116799 -> -0.061334416373633009
+expm10106 expm1 0.02390954035597756 -> 0.024197665143819942
+expm10107 expm1 0.085637352649044901 -> 0.089411184580357767
+expm10108 expm1 0.5966174947411006 -> 0.81596588596501485
+expm10109 expm1 0.30247206212075139 -> 0.35319987035848677
+expm10110 expm1 0.74574727375889516 -> 1.1080161116737459
+expm10111 expm1 0.97767512926555711 -> 1.6582689207372185
+expm10112 expm1 0.8450154566787712 -> 1.3280137976535897
+expm10113 expm1 -0.13979260323125264 -> -0.13046144381396060
+expm10114 expm1 -0.52899322039643271 -> -0.41080213643695923
+expm10115 expm1 -0.74083261478900631 -> -0.52328317124797097
+expm10116 expm1 -0.93847766984546055 -> -0.60877704724085946
+expm10117 expm1 10.0 -> 22025.465794806718
+expm10118 expm1 27.0 -> 532048240600.79865
+expm10119 expm1 123 -> 2.6195173187490626e+53
+expm10120 expm1 -12.0 -> -0.99999385578764666
+expm10121 expm1 -35.100000000000001 -> -0.99999999999999944
+
+-- extreme negative values
+expm10201 expm1 -37.0 -> -0.99999999999999989
+expm10200 expm1 -38.0 -> -1.0
+expm10210 expm1 -710.0 -> -1.0
+-- the formula expm1(x) = 2 * sinh(x/2) * exp(x/2) doesn't work so
+-- well when exp(x/2) is subnormal or underflows to zero; check we're
+-- not using it!
+expm10211 expm1 -1420.0 -> -1.0
+expm10212 expm1 -1450.0 -> -1.0
+expm10213 expm1 -1500.0 -> -1.0
+expm10214 expm1 -1e50 -> -1.0
+expm10215 expm1 -1.79e308 -> -1.0
+
+-- extreme positive values
+expm10300 expm1 300 -> 1.9424263952412558e+130
+expm10301 expm1 700 -> 1.0142320547350045e+304
+-- the next test (expm10302) is disabled because it causes failure on
+-- OS X 10.4/Intel: apparently all values over 709.78 produce an
+-- overflow on that platform. See issue #7575.
+-- expm10302 expm1 709.78271289328393 -> 1.7976931346824240e+308
+expm10303 expm1 709.78271289348402 -> inf overflow
+expm10304 expm1 1000 -> inf overflow
+expm10305 expm1 1e50 -> inf overflow
+expm10306 expm1 1.79e308 -> inf overflow
+
+-- weaker version of expm10302
+expm10307 expm1 709.5 -> 1.3549863193146328e+308
diff --git a/Lib/test/mock_socket.py b/Lib/test/mock_socket.py
new file mode 100644
index 0000000000..803693283b
--- /dev/null
+++ b/Lib/test/mock_socket.py
@@ -0,0 +1,154 @@
+"""Mock socket module used by the smtpd and smtplib tests.
+"""
+
+# imported for _GLOBAL_DEFAULT_TIMEOUT
+import socket as socket_module
+
+# Mock socket module
+_defaulttimeout = None
+_reply_data = None
+
+# This is used to queue up data to be read through socket.makefile, typically
+# *before* the socket object is even created. It is intended to handle a single
+# line which the socket will feed on recv() or makefile().
+def reply_with(line):
+ global _reply_data
+ _reply_data = line
+
+
+class MockFile:
+ """Mock file object returned by MockSocket.makefile().
+ """
+ def __init__(self, lines):
+ self.lines = lines
+ def readline(self):
+ return self.lines.pop(0) + b'\r\n'
+ def close(self):
+ pass
+
+
+class MockSocket:
+ """Mock socket object used by smtpd and smtplib tests.
+ """
+ def __init__(self):
+ global _reply_data
+ self.output = []
+ self.lines = []
+ if _reply_data:
+ self.lines.append(_reply_data)
+ _reply_data = None
+ self.conn = None
+ self.timeout = None
+
+ def queue_recv(self, line):
+ self.lines.append(line)
+
+ def recv(self, bufsize, flags=None):
+ data = self.lines.pop(0) + b'\r\n'
+ return data
+
+ def fileno(self):
+ return 0
+
+ def settimeout(self, timeout):
+ if timeout is None:
+ self.timeout = _defaulttimeout
+ else:
+ self.timeout = timeout
+
+ def gettimeout(self):
+ return self.timeout
+
+ def setsockopt(self, level, optname, value):
+ pass
+
+ def getsockopt(self, level, optname, buflen=None):
+ return 0
+
+ def bind(self, address):
+ pass
+
+ def accept(self):
+ self.conn = MockSocket()
+ return self.conn, 'c'
+
+ def getsockname(self):
+ return ('0.0.0.0', 0)
+
+ def setblocking(self, flag):
+ pass
+
+ def listen(self, backlog):
+ pass
+
+ def makefile(self, mode='r', bufsize=-1):
+ handle = MockFile(self.lines)
+ return handle
+
+ def sendall(self, buffer, flags=None):
+ self.last = data
+ self.output.append(data)
+ return len(data)
+
+ def send(self, data, flags=None):
+ self.last = data
+ self.output.append(data)
+ return len(data)
+
+ def getpeername(self):
+ return 'peer'
+
+ def close(self):
+ pass
+
+
+def socket(family=None, type=None, proto=None):
+ return MockSocket()
+
+
+def create_connection(address, timeout=socket_module._GLOBAL_DEFAULT_TIMEOUT):
+ try:
+ int_port = int(address[1])
+ except ValueError:
+ raise error
+ ms = MockSocket()
+ if timeout is socket_module._GLOBAL_DEFAULT_TIMEOUT:
+ timeout = getdefaulttimeout()
+ ms.settimeout(timeout)
+ return ms
+
+
+def setdefaulttimeout(timeout):
+ global _defaulttimeout
+ _defaulttimeout = timeout
+
+
+def getdefaulttimeout():
+ return _defaulttimeout
+
+
+def getfqdn():
+ return ""
+
+
+def gethostname():
+ pass
+
+
+def gethostbyname(name):
+ return ""
+
+
+class gaierror(Exception):
+ pass
+
+
+class error(Exception):
+ pass
+
+
+# Constants
+AF_INET = None
+SOCK_STREAM = None
+SOL_SOCKET = None
+SO_REUSEADDR = None
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 06789cda91..a843486a42 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -30,6 +30,21 @@ def count_opcode(code, pickle):
n += 1
return n
+
+class UnseekableIO(io.BytesIO):
+ def peek(self, *args):
+ raise NotImplementedError
+
+ def seekable(self):
+ return False
+
+ def seek(self, *args):
+ raise io.UnsupportedOperation
+
+ def tell(self):
+ raise io.UnsupportedOperation
+
+
# We can't very well test the extension registry without putting known stuff
# in it, but we have to be careful to restore its original state. Code
# should do this:
@@ -841,8 +856,8 @@ class AbstractPickleTests(unittest.TestCase):
# Dump using protocol 1 for comparison.
s1 = self.dumps(x, 1)
- self.assertTrue(__name__.encode("utf-8") in s1)
- self.assertTrue(b"MyList" in s1)
+ self.assertIn(__name__.encode("utf-8"), s1)
+ self.assertIn(b"MyList", s1)
self.assertEqual(opcode_in_pickle(opcode, s1), False)
y = self.loads(s1)
@@ -851,8 +866,8 @@ class AbstractPickleTests(unittest.TestCase):
# Dump using protocol 2 for test.
s2 = self.dumps(x, 2)
- self.assertTrue(__name__.encode("utf-8") not in s2)
- self.assertTrue(b"MyList" not in s2)
+ self.assertNotIn(__name__.encode("utf-8"), s2)
+ self.assertNotIn(b"MyList", s2)
self.assertEqual(opcode_in_pickle(opcode, s2), True, repr(s2))
y = self.loads(s2)
@@ -903,7 +918,7 @@ class AbstractPickleTests(unittest.TestCase):
x = dict.fromkeys(range(n))
for proto in protocols:
s = self.dumps(x, proto)
- assert isinstance(s, bytes_types)
+ self.assertIsInstance(s, bytes_types)
y = self.loads(s)
self.assertEqual(x, y)
num_setitems = count_opcode(pickle.SETITEMS, s)
@@ -1068,6 +1083,20 @@ class AbstractPickleTests(unittest.TestCase):
dumped = self.dumps(set([3]), 2)
self.assertEqual(dumped, DATA6)
+ def test_large_pickles(self):
+ # Test the correctness of internal buffering routines when handling
+ # large data.
+ for proto in protocols:
+ data = (1, min, b'xy' * (30 * 1024), len)
+ dumped = self.dumps(data, proto)
+ loaded = self.loads(dumped)
+ self.assertEqual(len(loaded), len(data))
+ self.assertEqual(loaded, data)
+
+ def test_empty_bytestring(self):
+ # issue 11286
+ empty = self.loads(b'\x80\x03U\x00q\x00.', encoding='koi8-r')
+ self.assertEqual(empty, '')
# Test classes for reduce_ex
@@ -1112,9 +1141,6 @@ class REX_five(object):
class MyInt(int):
sample = 1
-class MyLong(int):
- sample = 1
-
class MyFloat(float):
sample = 1.0
@@ -1136,7 +1162,7 @@ class MyList(list):
class MyDict(dict):
sample = {"a": 1, "b": 2}
-myclasses = [MyInt, MyLong, MyFloat,
+myclasses = [MyInt, MyFloat,
MyComplex,
MyStr, MyUnicode,
MyTuple, MyList, MyDict]
@@ -1367,6 +1393,31 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
f.seek(0)
self.assertEqual(unpickler.load(), data2)
+ def _check_multiple_unpicklings(self, ioclass):
+ for proto in protocols:
+ data1 = [(x, str(x)) for x in range(2000)] + [b"abcde", len]
+ f = ioclass()
+ pickler = self.pickler_class(f, protocol=proto)
+ pickler.dump(data1)
+ pickled = f.getvalue()
+
+ N = 5
+ f = ioclass(pickled * N)
+ unpickler = self.unpickler_class(f)
+ for i in range(N):
+ if f.seekable():
+ pos = f.tell()
+ self.assertEqual(unpickler.load(), data1)
+ if f.seekable():
+ self.assertEqual(f.tell(), pos + len(pickled))
+ self.assertRaises(EOFError, unpickler.load)
+
+ def test_multiple_unpicklings_seekable(self):
+ self._check_multiple_unpicklings(io.BytesIO)
+
+ def test_multiple_unpicklings_unseekable(self):
+ self._check_multiple_unpicklings(UnseekableIO)
+
if __name__ == "__main__":
# Print some stuff that can be used to rewrite DATA{0,1,2}
diff --git a/Lib/test/pstats.pck b/Lib/test/pstats.pck
new file mode 100644
index 0000000000..c48ccb73a9
--- /dev/null
+++ b/Lib/test/pstats.pck
Binary files differ
diff --git a/Lib/test/pystone.py b/Lib/test/pystone.py
index 614551ff64..d7f1ec9b6c 100755
--- a/Lib/test/pystone.py
+++ b/Lib/test/pystone.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""
"PYSTONE" Benchmark Program
@@ -72,7 +72,7 @@ BoolGlob = FALSE
Char1Glob = '\0'
Char2Glob = '\0'
Array1Glob = [0]*51
-Array2Glob = list(map(lambda x: x[:], [Array1Glob]*51))
+Array2Glob = [x[:] for x in [Array1Glob]*51]
PtrGlb = None
PtrGlbNext = None
diff --git a/Lib/test/re_tests.py b/Lib/test/re_tests.py
index d314e200bb..5d16e3d183 100755
--- a/Lib/test/re_tests.py
+++ b/Lib/test/re_tests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- mode: python -*-
# Re test suite and benchmark suite v1.5
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 71cc866e52..b5288b5072 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1,14 +1,21 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
-"""Regression test.
+"""
+Usage:
+
+python -m test [options] [test_name1 [test_name2 ...]]
+python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]]
+
+
+If no arguments or options are provided, finds all files matching
+the pattern "test_*" in the Lib/test subdirectory and runs
+them in alphabetical order (but see -M and -u, below, for exceptions).
+
+For more rigorous testing, it is useful to use the following
+command line:
-This will find all modules whose name is "test_*" in the test
-directory, and run them. Various command line options provide
-additional facilities.
+python -E -Wd -m test [options] [test_name1 ...]
-If non-option arguments are present, they are names for tests to run,
-unless -x is given, in which case they are names for tests not to run.
-If no test names are given, all tests are run.
Options:
@@ -18,6 +25,7 @@ Verbosity
-v/--verbose -- run tests in verbose mode with output to stdout
-w/--verbose2 -- re-run failed tests in verbose mode
+-W/--verbose3 -- re-run failed tests in verbose mode immediately
-d/--debug -- print traceback for failed tests
-q/--quiet -- no output unless one or more tests fail
-S/--slow -- print the slowest 10 tests
@@ -41,6 +49,8 @@ Special runs
-L/--runleaks -- run the leaks(1) command just before exit
-R/--huntrleaks RUNCOUNTS
-- search for reference leaks (needs debug build, v. slow)
+-j/--multiprocess PROCESSES
+ -- run PROCESSES processes at once
-T/--coverage -- turn on code coverage tracing using the trace module
-D/--coverdir DIRECTORY
-- Directory where coverage files are put
@@ -48,6 +58,7 @@ Special runs
-t/--threshold THRESHOLD
-- call gc.set_threshold(THRESHOLD)
-n/--nowindows -- suppress error message boxes on Windows
+-F/--forever -- run the specified tests in a loop, until an error happens
Additional Option Details:
@@ -56,19 +67,16 @@ Additional Option Details:
int seed value for the randomizer; this is useful for reproducing troublesome
test orders.
--T turns on code coverage tracing with the trace module.
-
--D specifies the directory where coverage files are put.
-
--N Put coverage files alongside modules.
-
--s means to run only a single test and exit. This is useful when
-doing memory analysis on the Python interpreter (which tend to consume
-too many resources to run the full regression test non-stop). The
-file /tmp/pynexttest is read to find the next test to run. If this
-file is missing, the first test_*.py file in testdir or on the command
-line is used. (actually tempfile.gettempdir() is used instead of
-/tmp).
+-s On the first invocation of regrtest using -s, the first test file found
+or the first test file given on the command line is run, and the name of
+the next test is recorded in a file named pynexttest. If run from the
+Python build directory, pynexttest is located in the 'build' subdirectory,
+otherwise it is located in tempfile.gettempdir(). On subsequent runs,
+the test in pynexttest is run, and the next test is written to pynexttest.
+When the last test has been run, pynexttest is deleted. In this way it
+is possible to single step through the test files. This is useful when
+doing memory analysis on the Python interpreter, which process tends to
+consume too many resources to run the full regression test non-stop.
-S is used to continue running tests after an aborted run. It will
maintain the order a standard run (ie, this assumes -r is not used).
@@ -145,36 +153,41 @@ example, to run all the tests except for the gui tests, give the
option '-uall,-gui'.
"""
+import builtins
import getopt
+import json
import os
import random
import re
import io
import sys
import time
-import platform
import traceback
import warnings
import unittest
from inspect import isabstract
+import tempfile
+import platform
+import sysconfig
+import logging
+
+
+# Some times __path__ and __file__ are not absolute (e.g. while running from
+# Lib/) and, if we change the CWD to run the tests in a temporary dir, some
+# imports might fail. This affects only the modules imported before os.chdir().
+# These modules are searched first in sys.path[0] (so '' -- the CWD) and if
+# they are found in the CWD their __file__ and __path__ will be relative (this
+# happens before the chdir). All the modules imported after the chdir, are
+# not found in the CWD, and since the other paths in sys.path[1:] are absolute
+# (site.py absolutize them), the __file__ and __path__ will be absolute too.
+# Therefore it is necessary to absolutize manually the __file__ and __path__ of
+# the packages to prevent later imports to fail when the CWD is different.
+for module in sys.modules.values():
+ if hasattr(module, '__path__'):
+ module.__path__ = [os.path.abspath(path) for path in module.__path__]
+ if hasattr(module, '__file__'):
+ module.__file__ = os.path.abspath(module.__file__)
-# I see no other way to suppress these warnings;
-# putting them in test_grammar.py has no effect:
-warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
- ".*test.test_grammar$")
-if sys.maxsize > 0x7fffffff:
- # Also suppress them in <string>, because for 64-bit platforms,
- # that's where test_grammar.py hides them.
- warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
- "<string>")
-
-# Ignore ImportWarnings that only occur in the source tree,
-# (because of modules with the same name as source-directories in Modules/)
-for mod in ("ctypes", "gzip", "zipfile", "tarfile", "encodings.zlib_codec",
- "test.test_zipimport", "test.test_zlib", "test.test_zipfile",
- "test.test_codecs", "test.string_tests"):
- warnings.filterwarnings(module=".*%s$" % (mod,),
- action="ignore", category=ImportWarning)
# MacOSX (a.k.a. Darwin) has a default stack size that is too small
# for deeply recursive regular expressions. We see this as crashes in
@@ -192,11 +205,20 @@ if sys.platform == 'darwin':
newsoft = min(hard, max(soft, 1024*2048))
resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
+# Test result constants.
+PASSED = 1
+FAILED = 0
+ENV_CHANGED = -1
+SKIPPED = -2
+RESOURCE_DENIED = -3
+INTERRUPTED = -4
+
from test import support
RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network',
'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui')
+TEMPDIR = os.path.abspath(tempfile.gettempdir())
def usage(msg):
print(msg, file=sys.stderr)
@@ -204,11 +226,12 @@ def usage(msg):
sys.exit(2)
-def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
+def main(tests=None, testdir=None, verbose=0, quiet=False,
exclude=False, single=False, randomize=False, fromfile=None,
findleaks=False, use_resources=None, trace=False, coverdir='coverage',
runleaks=False, huntrleaks=False, verbose2=False, print_slow=False,
- random_seed=None, header=False):
+ random_seed=None, use_mp=None, verbose3=False, forever=False,
+ header=False):
"""Execute a test suite.
This also parses command-line options and modifies its behavior
@@ -225,7 +248,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
command-line will be used. If that's empty, too, then all *.py
files beginning with test_ will be used.
- The other default arguments (verbose, quiet, generate, exclude,
+ The other default arguments (verbose, quiet, exclude,
single, randomize, findleaks, use_resources, trace, coverdir,
print_slow, and random_seed) allow programmers calling main()
directly to set the values that would normally be set by flags
@@ -236,14 +259,13 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
support.record_original_stdout(sys.stdout)
try:
- opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsSrf:lu:t:TD:NLR:wM:n',
- ['help', 'verbose', 'quiet', 'exclude',
- 'single', 'slow', 'random', 'fromfile',
- 'findleaks', 'use=', 'threshold=', 'trace',
- 'coverdir=', 'nocoverdir', 'runleaks',
- 'huntrleaks=', 'verbose2', 'memlimit=',
- 'debug', 'start=', 'nowindows',
- 'randseed=', 'header'])
+ opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:',
+ ['help', 'verbose', 'verbose2', 'verbose3', 'quiet',
+ 'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks',
+ 'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir',
+ 'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=',
+ 'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug',
+ 'start=', 'nowindows', 'header'])
except getopt.error as msg:
usage(msg)
@@ -264,6 +286,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
verbose2 = True
elif o in ('-d', '--debug'):
debug = True
+ elif o in ('-W', '--verbose3'):
+ verbose3 = True
elif o in ('-q', '--quiet'):
quiet = True;
verbose = 0
@@ -346,30 +370,39 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]:
msvcrt.CrtSetReportMode(m, msvcrt.CRTDBG_MODE_FILE)
msvcrt.CrtSetReportFile(m, msvcrt.CRTDBG_FILE_STDERR)
+ elif o in ('-F', '--forever'):
+ forever = True
+ elif o in ('-j', '--multiprocess'):
+ use_mp = int(a)
elif o == '--header':
header = True
+ elif o == '--slaveargs':
+ args, kwargs = json.loads(a)
+ try:
+ result = runtest(*args, **kwargs)
+ except BaseException as e:
+ result = INTERRUPTED, e.__class__.__name__
+ sys.stdout.flush()
+ print() # Force a newline (just in case)
+ print(json.dumps(result))
+ sys.exit(0)
else:
print(("No handler for option {}. Please report this as a bug "
- "at http://bugs.python.org.").format(o), file=sys.stderr)
+ "at http://bugs.python.org.").format(o), file=sys.stderr)
sys.exit(1)
- if generate and verbose:
- usage("-g and -v don't go together!")
if single and fromfile:
usage("-s and -f don't go together!")
+ if use_mp and trace:
+ usage("-T and -j don't go together!")
+ if use_mp and findleaks:
+ usage("-l and -j don't go together!")
good = []
bad = []
skipped = []
resource_denieds = []
-
- # For a partial run, we do not need to clutter the output.
- if verbose or header or not (quiet or single or tests or args):
- # Print basic platform information
- print("==", platform.python_implementation(), *sys.version.split())
- print("== ", platform.platform(aliased=True),
- "%s-endian" % sys.byteorder)
- print("== ", os.getcwd())
- print("Testing with flags:", sys.flags)
+ environment_changed = []
+ interrupted = False
if findleaks:
try:
@@ -385,30 +418,29 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
found_garbage = []
if single:
- from tempfile import gettempdir
- filename = os.path.join(gettempdir(), 'pynexttest')
+ filename = os.path.join(TEMPDIR, 'pynexttest')
try:
fp = open(filename, 'r')
- next = fp.read().strip()
- tests = [next]
+ next_test = fp.read().strip()
+ tests = [next_test]
fp.close()
except IOError:
pass
if fromfile:
tests = []
- fp = open(fromfile)
+ fp = open(os.path.join(support.SAVEDCWD, fromfile))
+ count_pat = re.compile(r'\[\s*\d+/\s*\d+\]')
for line in fp:
+ line = count_pat.sub('', line)
guts = line.split() # assuming no test has whitespace in its name
if guts and not guts[0].startswith('#'):
tests.extend(guts)
fp.close()
# Strip .py extensions.
- if args:
- args = list(map(removepy, args))
- if tests:
- tests = list(map(removepy, tests))
+ removepy(args)
+ removepy(tests)
stdtests = STDTESTS[:]
nottests = NOTTESTS.copy()
@@ -418,9 +450,24 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
stdtests.remove(arg)
nottests.add(arg)
args = []
- tests = tests or args or findtests(testdir, stdtests, nottests)
+
+ # For a partial run, we do not need to clutter the output.
+ if verbose or header or not (quiet or single or tests or args):
+ # Print basic platform information
+ print("==", platform.python_implementation(), *sys.version.split())
+ print("== ", platform.platform(aliased=True),
+ "%s-endian" % sys.byteorder)
+ print("== ", os.getcwd())
+ print("Testing with flags:", sys.flags)
+
+ alltests = findtests(testdir, stdtests, nottests)
+ selected = tests or args or alltests
if single:
- tests = tests[:1]
+ selected = selected[:1]
+ try:
+ next_single_test = alltests[alltests.index(selected[0])+1]
+ except IndexError:
+ next_single_test = None
# Remove all the tests that precede start if it's set.
if start:
try:
@@ -430,73 +477,187 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
if randomize:
random.seed(random_seed)
print("Using random seed", random_seed)
- random.shuffle(tests)
+ random.shuffle(selected)
if trace:
import trace, tempfile
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,
tempfile.gettempdir()],
trace=False, count=True)
+
test_times = []
support.verbose = verbose # Tell tests to be moderately quiet
support.use_resources = use_resources
save_modules = sys.modules.keys()
- for test in tests:
- if not quiet:
- print(test)
- sys.stdout.flush()
- if trace:
- # If we're tracing code coverage, then we don't exit with status
- # if on a false return value from main.
- tracer.runctx('runtest(test, generate, verbose, quiet,'
- ' test_times, testdir)',
- globals=globals(), locals=vars())
- else:
+
+ def accumulate_result(test, result):
+ ok, test_time = result
+ test_times.append((test_time, test))
+ if ok == PASSED:
+ good.append(test)
+ elif ok == FAILED:
+ bad.append(test)
+ elif ok == ENV_CHANGED:
+ bad.append(test)
+ environment_changed.append(test)
+ elif ok == SKIPPED:
+ skipped.append(test)
+ elif ok == RESOURCE_DENIED:
+ skipped.append(test)
+ resource_denieds.append(test)
+
+ if forever:
+ def test_forever(tests=list(selected)):
+ while True:
+ for test in tests:
+ yield test
+ if bad:
+ return
+ tests = test_forever()
+ test_count = ''
+ test_count_width = 3
+ else:
+ tests = iter(selected)
+ test_count = '/{}'.format(len(selected))
+ test_count_width = len(test_count) - 1
+
+ if use_mp:
+ try:
+ from threading import Thread
+ except ImportError:
+ print("Multiprocess option requires thread support")
+ sys.exit(2)
+ from queue import Queue
+ from subprocess import Popen, PIPE
+ debug_output_pat = re.compile(r"\[\d+ refs\]$")
+ output = Queue()
+ def tests_and_args():
+ for test in tests:
+ args_tuple = (
+ (test, verbose, quiet),
+ dict(huntrleaks=huntrleaks, use_resources=use_resources,
+ debug=debug)
+ )
+ yield (test, args_tuple)
+ pending = tests_and_args()
+ opt_args = support.args_from_interpreter_flags()
+ base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest']
+ def work():
+ # A worker thread.
try:
- ok = runtest(test, generate, verbose, quiet, test_times,
- testdir, huntrleaks)
- except KeyboardInterrupt:
- # print a newline separate from the ^C
- print()
- break
- except:
+ while True:
+ try:
+ test, args_tuple = next(pending)
+ except StopIteration:
+ output.put((None, None, None, None))
+ return
+ # -E is needed by some tests, e.g. test_import
+ popen = Popen(base_cmd + ['--slaveargs', json.dumps(args_tuple)],
+ stdout=PIPE, stderr=PIPE,
+ universal_newlines=True,
+ close_fds=(os.name != 'nt'))
+ stdout, stderr = popen.communicate()
+ # Strip last refcount output line if it exists, since it
+ # comes from the shutdown of the interpreter in the subcommand.
+ stderr = debug_output_pat.sub("", stderr)
+ stdout, _, result = stdout.strip().rpartition("\n")
+ if not result:
+ output.put((None, None, None, None))
+ return
+ result = json.loads(result)
+ output.put((test, stdout.rstrip(), stderr.rstrip(), result))
+ except BaseException:
+ output.put((None, None, None, None))
raise
- if ok > 0:
- good.append(test)
- elif ok == 0:
- bad.append(test)
+ workers = [Thread(target=work) for i in range(use_mp)]
+ for worker in workers:
+ worker.start()
+ finished = 0
+ test_index = 1
+ try:
+ while finished < use_mp:
+ test, stdout, stderr, result = output.get()
+ if test is None:
+ finished += 1
+ continue
+ if not quiet:
+ print("[{1:{0}}{2}] {3}".format(
+ test_count_width, test_index, test_count, test))
+ if stdout:
+ print(stdout)
+ if stderr:
+ print(stderr, file=sys.stderr)
+ if result[0] == INTERRUPTED:
+ assert result[1] == 'KeyboardInterrupt'
+ raise KeyboardInterrupt # What else?
+ accumulate_result(test, result)
+ test_index += 1
+ except KeyboardInterrupt:
+ interrupted = True
+ pending.close()
+ for worker in workers:
+ worker.join()
+ else:
+ for test_index, test in enumerate(tests, 1):
+ if not quiet:
+ print("[{1:{0}}{2}] {3}".format(
+ test_count_width, test_index, test_count, test))
+ sys.stdout.flush()
+ if trace:
+ # If we're tracing code coverage, then we don't exit with status
+ # if on a false return value from main.
+ tracer.runctx('runtest(test, verbose, quiet)',
+ globals=globals(), locals=vars())
else:
- skipped.append(test)
- if ok == -2:
- resource_denieds.append(test)
- if findleaks:
- gc.collect()
- if gc.garbage:
- print("Warning: test created", len(gc.garbage), end=' ')
- print("uncollectable object(s).")
- # move the uncollectable objects somewhere so we don't see
- # them again
- found_garbage.extend(gc.garbage)
- del gc.garbage[:]
- # Unload the newly imported modules (best effort finalization)
- for module in sys.modules.keys():
- if module not in save_modules and module.startswith("test."):
- support.unload(module)
-
+ try:
+ result = runtest(test, verbose, quiet, huntrleaks, debug)
+ accumulate_result(test, result)
+ if verbose3 and result[0] == FAILED:
+ print("Re-running test {} in verbose mode".format(test))
+ runtest(test, True, quiet, huntrleaks, debug)
+ except KeyboardInterrupt:
+ interrupted = True
+ break
+ except:
+ raise
+ if findleaks:
+ gc.collect()
+ if gc.garbage:
+ print("Warning: test created", len(gc.garbage), end=' ')
+ print("uncollectable object(s).")
+ # move the uncollectable objects somewhere so we don't see
+ # them again
+ found_garbage.extend(gc.garbage)
+ del gc.garbage[:]
+ # Unload the newly imported modules (best effort finalization)
+ for module in sys.modules.keys():
+ if module not in save_modules and module.startswith("test."):
+ support.unload(module)
+
+ if interrupted:
+ # print a newline after ^C
+ print()
+ print("Test suite interrupted by signal SIGINT.")
+ omitted = set(selected) - set(good) - set(bad) - set(skipped)
+ print(count(len(omitted), "test"), "omitted:")
+ printlist(omitted)
if good and not quiet:
- if not bad and not skipped and len(good) > 1:
+ if not bad and not skipped and not interrupted and len(good) > 1:
print("All", end=' ')
print(count(len(good), "test"), "OK.")
- if verbose:
- print("CAUTION: stdout isn't compared in verbose mode:")
- print("a test that passes in verbose mode may fail without it.")
if print_slow:
test_times.sort(reverse=True)
print("10 slowest tests:")
for time, test in test_times[:10]:
print("%s: %.1fs" % (test, time))
if bad:
- print(count(len(bad), "test"), "failed:")
- printlist(bad)
+ bad = sorted(set(bad) - set(environment_changed))
+ if bad:
+ print(count(len(bad), "test"), "failed:")
+ printlist(bad)
+ if environment_changed:
+ print("{} altered the execution environment:".format(
+ count(len(environment_changed), "test")))
+ printlist(environment_changed)
if skipped and not quiet:
print(count(len(skipped), "test"), "skipped:")
printlist(skipped)
@@ -521,9 +682,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
print("Re-running test %r in verbose mode" % test)
sys.stdout.flush()
try:
- support.verbose = True
- ok = runtest(test, generate, True, quiet, test_times, testdir,
- huntrleaks, debug)
+ verbose = True
+ ok = runtest(test, True, quiet, huntrleaks, debug)
except KeyboardInterrupt:
# print a newline separate from the ^C
print()
@@ -532,16 +692,9 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
raise
if single:
- alltests = findtests(testdir, stdtests, nottests)
- for i in range(len(alltests)):
- if tests[0] == alltests[i]:
- if i == len(alltests) - 1:
- os.unlink(filename)
- else:
- fp = open(filename, 'w')
- fp.write(alltests[i+1] + '\n')
- fp.close()
- break
+ if next_single_test:
+ with open(filename, 'w') as fp:
+ fp.write(next_single_test + '\n')
else:
os.unlink(filename)
@@ -552,7 +705,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
if runleaks:
os.system("leaks %d" % os.getpid())
- sys.exit(len(bad) > 0)
+ sys.exit(len(bad) > 0 or interrupted)
STDTESTS = [
@@ -574,16 +727,15 @@ NOTTESTS = {
def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
"""Return a list of all applicable test modules."""
- if not testdir: testdir = findtestdir()
+ testdir = findtestdir(testdir)
names = os.listdir(testdir)
tests = []
+ others = set(stdtests) | nottests
for name in names:
- if name[:5] == "test_" and name[-3:] == ".py":
- modname = name[:-3]
- if modname not in stdtests and modname not in nottests:
- tests.append(modname)
- tests.sort()
- return stdtests + tests
+ modname, ext = os.path.splitext(name)
+ if modname[:5] == "test_" and ext == ".py" and modname not in others:
+ tests.append(modname)
+ return stdtests + sorted(tests)
def replace_stdout():
"""Set stdout encoder error handler to backslashreplace (as stderr error
@@ -591,63 +743,221 @@ def replace_stdout():
if os.name == "nt":
# Replace sys.stdout breaks the stdout newlines on Windows: issue #8533
return
+
+ import atexit
+
stdout = sys.stdout
sys.stdout = open(stdout.fileno(), 'w',
encoding=stdout.encoding,
- errors="backslashreplace")
+ errors="backslashreplace",
+ closefd=False)
-def runtest(test, generate, verbose, quiet, test_times,
- testdir=None, huntrleaks=False, debug=False):
+ def restore_stdout():
+ sys.stdout.close()
+ sys.stdout = stdout
+ atexit.register(restore_stdout)
+
+def runtest(test, verbose, quiet,
+ huntrleaks=False, debug=False, use_resources=None):
"""Run a single test.
test -- the name of the test
verbose -- if true, print more messages
quiet -- if true, don't print 'skipped' messages (probably redundant)
test_times -- a list of (time, test_name) pairs
- testdir -- test directory
huntrleaks -- run multiple times to test for leaks; requires a debug
build; a triple corresponding to -R's three arguments
- debug -- if true, print tracebacks for failed tests regardless of
- verbose setting
- Return:
- -2 test skipped because resource denied
- -1 test skipped for some other reason
- 0 test failed
- 1 test passed
+
+ Returns one of the test result constants:
+ INTERRUPTED KeyboardInterrupt when run under -j
+ RESOURCE_DENIED test skipped because resource denied
+ SKIPPED test skipped for some other reason
+ ENV_CHANGED test failed because it changed the execution environment
+ FAILED test failed
+ PASSED test passed
"""
+ support.verbose = verbose # Tell tests to be moderately quiet
+ if use_resources is not None:
+ support.use_resources = use_resources
try:
- return runtest_inner(test, generate, verbose, quiet, test_times,
- testdir, huntrleaks)
+ return runtest_inner(test, verbose, quiet, huntrleaks, debug)
finally:
cleanup_test_droppings(test, verbose)
-def runtest_inner(test, generate, verbose, quiet, test_times,
- testdir=None, huntrleaks=False, debug=False):
+# Unit tests are supposed to leave the execution environment unchanged
+# once they complete. But sometimes tests have bugs, especially when
+# tests fail, and the changes to environment go on to mess up other
+# tests. This can cause issues with buildbot stability, since tests
+# are run in random order and so problems may appear to come and go.
+# There are a few things we can save and restore to mitigate this, and
+# the following context manager handles this task.
+
+class saved_test_environment:
+ """Save bits of the test environment and restore them at block exit.
+
+ with saved_test_environment(testname, verbose, quiet):
+ #stuff
+
+ Unless quiet is True, a warning is printed to stderr if any of
+ the saved items was changed by the test. The attribute 'changed'
+ is initially False, but is set to True if a change is detected.
+
+ If verbose is more than 1, the before and after state of changed
+ items is also printed.
+ """
+
+ changed = False
+
+ def __init__(self, testname, verbose=0, quiet=False):
+ self.testname = testname
+ self.verbose = verbose
+ self.quiet = quiet
+
+ # To add things to save and restore, add a name XXX to the resources list
+ # and add corresponding get_XXX/restore_XXX functions. get_XXX should
+ # return the value to be saved and compared against a second call to the
+ # get function when test execution completes. restore_XXX should accept
+ # the saved value and restore the resource using it. It will be called if
+ # and only if a change in the value is detected.
+ #
+ # Note: XXX will have any '.' replaced with '_' characters when determining
+ # the corresponding method names.
+
+ resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr',
+ 'os.environ', 'sys.path', 'sys.path_hooks', '__import__',
+ 'warnings.filters', 'asyncore.socket_map',
+ 'logging._handlers', 'logging._handlerList')
+
+ def get_sys_argv(self):
+ return id(sys.argv), sys.argv, sys.argv[:]
+ def restore_sys_argv(self, saved_argv):
+ sys.argv = saved_argv[1]
+ sys.argv[:] = saved_argv[2]
+
+ def get_cwd(self):
+ return os.getcwd()
+ def restore_cwd(self, saved_cwd):
+ os.chdir(saved_cwd)
+
+ def get_sys_stdout(self):
+ return sys.stdout
+ def restore_sys_stdout(self, saved_stdout):
+ sys.stdout = saved_stdout
+
+ def get_sys_stderr(self):
+ return sys.stderr
+ def restore_sys_stderr(self, saved_stderr):
+ sys.stderr = saved_stderr
+
+ def get_sys_stdin(self):
+ return sys.stdin
+ def restore_sys_stdin(self, saved_stdin):
+ sys.stdin = saved_stdin
+
+ def get_os_environ(self):
+ return id(os.environ), os.environ, dict(os.environ)
+ def restore_os_environ(self, saved_environ):
+ os.environ = saved_environ[1]
+ os.environ.clear()
+ os.environ.update(saved_environ[2])
+
+ def get_sys_path(self):
+ return id(sys.path), sys.path, sys.path[:]
+ def restore_sys_path(self, saved_path):
+ sys.path = saved_path[1]
+ sys.path[:] = saved_path[2]
+
+ def get_sys_path_hooks(self):
+ return id(sys.path_hooks), sys.path_hooks, sys.path_hooks[:]
+ def restore_sys_path_hooks(self, saved_hooks):
+ sys.path_hooks = saved_hooks[1]
+ sys.path_hooks[:] = saved_hooks[2]
+
+ def get___import__(self):
+ return builtins.__import__
+ def restore___import__(self, import_):
+ builtins.__import__ = import_
+
+ def get_warnings_filters(self):
+ return id(warnings.filters), warnings.filters, warnings.filters[:]
+ def restore_warnings_filters(self, saved_filters):
+ warnings.filters = saved_filters[1]
+ warnings.filters[:] = saved_filters[2]
+
+ def get_asyncore_socket_map(self):
+ asyncore = sys.modules.get('asyncore')
+ # XXX Making a copy keeps objects alive until __exit__ gets called.
+ return asyncore and asyncore.socket_map.copy() or {}
+ def restore_asyncore_socket_map(self, saved_map):
+ asyncore = sys.modules.get('asyncore')
+ if asyncore is not None:
+ asyncore.close_all(ignore_all=True)
+ asyncore.socket_map.update(saved_map)
+
+ def get_logging__handlers(self):
+ # _handlers is a WeakValueDictionary
+ return id(logging._handlers), logging._handlers, logging._handlers.copy()
+ def restore_logging__handlers(self, saved_handlers):
+ # Can't easily revert the logging state
+ pass
+
+ def get_logging__handlerList(self):
+ # _handlerList is a list of weakrefs to handlers
+ return id(logging._handlerList), logging._handlerList, logging._handlerList[:]
+ def restore_logging__handlerList(self, saved_handlerList):
+ # Can't easily revert the logging state
+ pass
+
+ def resource_info(self):
+ for name in self.resources:
+ method_suffix = name.replace('.', '_')
+ get_name = 'get_' + method_suffix
+ restore_name = 'restore_' + method_suffix
+ yield name, getattr(self, get_name), getattr(self, restore_name)
+
+ def __enter__(self):
+ self.saved_values = dict((name, get()) for name, get, restore
+ in self.resource_info())
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ saved_values = self.saved_values
+ del self.saved_values
+ for name, get, restore in self.resource_info():
+ current = get()
+ original = saved_values.pop(name)
+ # Check for changes to the resource's value
+ if current != original:
+ self.changed = True
+ restore(original)
+ if not self.quiet:
+ print("Warning -- {} was modified by {}".format(
+ name, self.testname),
+ file=sys.stderr)
+ if self.verbose > 1:
+ print(" Before: {}\n After: {} ".format(
+ original, current),
+ file=sys.stderr)
+ return False
+
+
+def runtest_inner(test, verbose, quiet, huntrleaks=False, debug=False):
support.unload(test)
- if not testdir:
- testdir = findtestdir()
if verbose:
- cfp = None
+ capture_stdout = None
else:
- cfp = io.StringIO() # XXX Should use io.StringIO()
+ capture_stdout = io.StringIO()
+ test_time = 0.0
refleak = False # True if the test leaked references.
try:
- save_stdout = sys.stdout
- # Save various things that tests may mess up so we can restore
- # them afterward.
- save_environ = dict(os.environ)
- save_argv = sys.argv[:]
- try:
- if cfp:
- sys.stdout = cfp
- print(test) # Output file starts with test name
- if test.startswith('test.'):
- abstest = test
- else:
- # Always import it from the test package
- abstest = 'test.' + test
+ if test.startswith('test.'):
+ abstest = test
+ else:
+ # Always import it from the test package
+ abstest = 'test.' + test
+ with saved_test_environment(test, verbose, quiet) as environment:
start_time = time.time()
the_package = __import__(abstest, globals(), locals(), [])
the_module = getattr(the_package, test)
@@ -658,38 +968,25 @@ def runtest_inner(test, generate, verbose, quiet, test_times,
if indirect_test is not None:
indirect_test()
if huntrleaks:
- refleak = dash_R(the_module, test, indirect_test, huntrleaks)
+ refleak = dash_R(the_module, test, indirect_test,
+ huntrleaks)
test_time = time.time() - start_time
- test_times.append((test_time, test))
- finally:
- sys.stdout = save_stdout
- # Restore what we saved if needed, but also complain if the test
- # changed it so that the test may eventually get fixed.
- if not os.environ == save_environ:
- if not quiet:
- print("Warning: os.environ was modified by", test)
- os.environ.clear()
- os.environ.update(save_environ)
- if not sys.argv == save_argv:
- if not quiet:
- print("Warning: argv was modified by", test)
- sys.argv[:] = save_argv
except support.ResourceDenied as msg:
if not quiet:
print(test, "skipped --", msg)
sys.stdout.flush()
- return -2
+ return RESOURCE_DENIED, test_time
except unittest.SkipTest as msg:
if not quiet:
print(test, "skipped --", msg)
sys.stdout.flush()
- return -1
+ return SKIPPED, test_time
except KeyboardInterrupt:
raise
except support.TestFailed as msg:
print("test", test, "failed --", msg, file=sys.stderr)
sys.stderr.flush()
- return 0
+ return FAILED, test_time
except:
type, value = sys.exc_info()[:2]
print("test", test, "crashed --", str(type) + ":", value, file=sys.stderr)
@@ -697,21 +994,13 @@ def runtest_inner(test, generate, verbose, quiet, test_times,
if verbose or debug:
traceback.print_exc(file=sys.stderr)
sys.stderr.flush()
- return 0
+ return FAILED, test_time
else:
if refleak:
- return 0
- if not cfp:
- return 1
- output = cfp.getvalue()
- expected = test + "\n"
- if output == expected or huntrleaks:
- return 1
- print("test", test, "produced unexpected output:")
- sys.stdout.flush()
- reportdiff(expected, output)
- sys.stdout.flush()
- return 0
+ return FAILED, test_time
+ if environment.changed:
+ return ENV_CHANGED, test_time
+ return PASSED, test_time
def cleanup_test_droppings(testname, verbose):
import shutil
@@ -719,6 +1008,8 @@ def cleanup_test_droppings(testname, verbose):
import gc
# First kill any dangling references to open files etc.
+ # This can also issue some ResourceWarnings which would otherwise get
+ # triggered during the following test run, and possibly produce failures.
gc.collect()
# Try to clean up junk commonly left behind. While tests shouldn't leave
@@ -770,6 +1061,12 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
fs = warnings.filters[:]
ps = copyreg.dispatch_table.copy()
pic = sys.path_importer_cache.copy()
+ try:
+ import zipimport
+ except ImportError:
+ zdc = None # Run unmodified on platforms without zipimport support
+ else:
+ zdc = zipimport._zip_directory_cache.copy()
abcs = {}
for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]:
if not isabstract(abc):
@@ -787,29 +1084,33 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
deltas = []
nwarmup, ntracked, fname = huntrleaks
+ fname = os.path.join(support.SAVEDCWD, fname)
repcount = nwarmup + ntracked
print("beginning", repcount, "repetitions", file=sys.stderr)
print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr)
- dash_R_cleanup(fs, ps, pic, abcs)
+ sys.stderr.flush()
+ dash_R_cleanup(fs, ps, pic, zdc, abcs)
for i in range(repcount):
- rc = sys.gettotalrefcount()
+ rc_before = sys.gettotalrefcount()
run_the_test()
sys.stderr.write('.')
sys.stderr.flush()
- dash_R_cleanup(fs, ps, pic, abcs)
+ dash_R_cleanup(fs, ps, pic, zdc, abcs)
+ rc_after = sys.gettotalrefcount()
if i >= nwarmup:
- deltas.append(sys.gettotalrefcount() - rc - 2)
+ deltas.append(rc_after - rc_before)
print(file=sys.stderr)
if any(deltas):
msg = '%s leaked %s references, sum=%s' % (test, deltas, sum(deltas))
print(msg, file=sys.stderr)
- refrep = open(fname, "a")
- print(msg, file=refrep)
- refrep.close()
+ sys.stderr.flush()
+ with open(fname, "a") as refrep:
+ print(msg, file=refrep)
+ refrep.flush()
return True
return False
-def dash_R_cleanup(fs, ps, pic, abcs):
+def dash_R_cleanup(fs, ps, pic, zdc, abcs):
import gc, copyreg
import _strptime, linecache
import urllib.parse, urllib.request, mimetypes, doctest
@@ -828,6 +1129,13 @@ def dash_R_cleanup(fs, ps, pic, abcs):
copyreg.dispatch_table.update(ps)
sys.path_importer_cache.clear()
sys.path_importer_cache.update(pic)
+ try:
+ import zipimport
+ except ImportError:
+ pass # Run unmodified on platforms without zipimport support
+ else:
+ zipimport._zip_directory_cache.clear()
+ zipimport._zip_directory_cache.update(zdc)
# clear type cache
sys._clear_type_cache()
@@ -841,6 +1149,12 @@ def dash_R_cleanup(fs, ps, pic, abcs):
obj._abc_cache.clear()
obj._abc_negative_cache.clear()
+ # Flush standard output, so that buffered data is sent to the OS and
+ # associated Python objects are reclaimed.
+ for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__):
+ if stream is not None:
+ stream.flush()
+
# Clear assorted module caches.
_path_created.clear()
re.purge()
@@ -861,60 +1175,16 @@ def warm_char_cache():
for i in range(256):
s[i:i+1]
-def reportdiff(expected, output):
- import difflib
- print("*" * 70)
- a = expected.splitlines(1)
- b = output.splitlines(1)
- sm = difflib.SequenceMatcher(a=a, b=b)
- tuples = sm.get_opcodes()
-
- def pair(x0, x1):
- # x0:x1 are 0-based slice indices; convert to 1-based line indices.
- x0 += 1
- if x0 >= x1:
- return "line " + str(x0)
- else:
- return "lines %d-%d" % (x0, x1)
-
- for op, a0, a1, b0, b1 in tuples:
- if op == 'equal':
- pass
-
- elif op == 'delete':
- print("***", pair(a0, a1), "of expected output missing:")
- for line in a[a0:a1]:
- print("-", line, end='')
+def findtestdir(path=None):
+ return path or os.path.dirname(__file__) or os.curdir
- elif op == 'replace':
- print("*** mismatch between", pair(a0, a1), "of expected", \
- "output and", pair(b0, b1), "of actual output:")
- for line in difflib.ndiff(a[a0:a1], b[b0:b1]):
- print(line, end='')
-
- elif op == 'insert':
- print("***", pair(b0, b1), "of actual output doesn't appear", \
- "in expected output after line", str(a1)+":")
- for line in b[b0:b1]:
- print("+", line, end='')
-
- else:
- print("get_opcodes() returned bad tuple?!?!", (op, a0, a1, b0, b1))
-
- print("*" * 70)
-
-def findtestdir():
- if __name__ == '__main__':
- file = sys.argv[0]
- else:
- file = __file__
- testdir = os.path.dirname(file) or os.curdir
- return testdir
-
-def removepy(name):
- if name.endswith(".py"):
- name = name[:-3]
- return name
+def removepy(names):
+ if not names:
+ return
+ for idx, name in enumerate(names):
+ basename, ext = os.path.splitext(name)
+ if ext == '.py':
+ names[idx] = basename
def count(n, word):
if n == 1:
@@ -987,34 +1257,6 @@ _expectations = {
test_kqueue
test_ossaudiodev
""",
- 'mac':
- """
- test_atexit
- test_bz2
- test_crypt
- test_curses
- test_dbm
- test_fcntl
- test_fork1
- test_epoll
- test_grp
- test_ioctl
- test_largefile
- test_locale
- test_kqueue
- test_mmap
- test_openpty
- test_ossaudiodev
- test_poll
- test_popen
- test_posix
- test_pty
- test_pwd
- test_resource
- test_signal
- test_sundry
- test_tarfile
- """,
'unixware7':
"""
test_epoll
@@ -1063,6 +1305,7 @@ _expectations = {
test_curses
test_epoll
test_dbm_gnu
+ test_gdb
test_largefile
test_locale
test_minidom
@@ -1097,19 +1340,6 @@ _expectations = {
test_zipfile
test_zlib
""",
- 'atheos':
- """
- test_curses
- test_dbm_gnu
- test_epoll
- test_largefile
- test_locale
- test_kqueue
- test_mhlib
- test_mmap
- test_poll
- test_resource
- """,
'cygwin':
"""
test_curses
@@ -1237,15 +1467,17 @@ class _ExpectedSkips:
if sys.platform != "win32":
# test_sqlite is only reliable on Windows where the library
# is distributed with Python
- WIN_ONLY = ["test_unicode_file", "test_winreg",
+ WIN_ONLY = {"test_unicode_file", "test_winreg",
"test_winsound", "test_startfile",
- "test_sqlite"]
- for skip in WIN_ONLY:
- self.expected.add(skip)
+ "test_sqlite"}
+ self.expected |= WIN_ONLY
if sys.platform != 'sunos5':
self.expected.add('test_nis')
+ if support.python_is_optimized():
+ self.expected.add("test_gdb")
+
self.valid = True
def isvalid(self):
@@ -1261,17 +1493,51 @@ class _ExpectedSkips:
assert self.isvalid()
return self.expected
+def _make_temp_dir_for_build(TEMPDIR):
+ # When tests are run from the Python build directory, it is best practice
+ # to keep the test files in a subfolder. It eases the cleanup of leftover
+ # files using command "make distclean".
+ if sysconfig.is_python_build():
+ TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
+ TEMPDIR = os.path.abspath(TEMPDIR)
+ if not os.path.exists(TEMPDIR):
+ os.mkdir(TEMPDIR)
+
+ # Define a writable temp dir that will be used as cwd while running
+ # the tests. The name of the dir includes the pid to allow parallel
+ # testing (see the -j option).
+ TESTCWD = 'test_python_{}'.format(os.getpid())
+
+ TESTCWD = os.path.join(TEMPDIR, TESTCWD)
+ return TEMPDIR, TESTCWD
+
if __name__ == '__main__':
- # Remove regrtest.py's own directory from the module search path. This
- # prevents relative imports from working, and relative imports will screw
- # up the testing framework. E.g. if both test.support and
- # support are imported, they will not contain the same globals, and
- # much of the testing framework relies on the globals in the
- # test.support module.
+ # Remove regrtest.py's own directory from the module search path. Despite
+ # the elimination of implicit relative imports, this is still needed to
+ # ensure that submodules of the test package do not inappropriately appear
+ # as top-level modules even when people (or buildbots!) invoke regrtest.py
+ # directly instead of using the -m switch
mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
i = len(sys.path)
while i >= 0:
i -= 1
if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
del sys.path[i]
- main()
+
+ # findtestdir() gets the dirname out of __file__, so we have to make it
+ # absolute before changing the working directory.
+ # For example __file__ may be relative when running trace or profile.
+ # See issue #9323.
+ __file__ = os.path.abspath(__file__)
+
+ # sanity check
+ assert __file__ == os.path.abspath(sys.argv[0])
+
+ TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR)
+
+ # Run the tests in a context manager that temporary changes the CWD to a
+ # temporary and writable directory. If it's not possible to create or
+ # change the CWD, the original CWD will be used. The original CWD is
+ # available from support.SAVEDCWD.
+ with support.temp_cwd(TESTCWD, quiet=True):
+ main()
diff --git a/Lib/test/script_helper.py b/Lib/test/script_helper.py
index 0699cf61a2..371c33d138 100644
--- a/Lib/test/script_helper.py
+++ b/Lib/test/script_helper.py
@@ -12,7 +12,8 @@ import contextlib
import shutil
import zipfile
-from test.support import strip_python_stderr
+from imp import source_from_cache
+from test.support import make_legacy_pyc, strip_python_stderr
# Executing the interpreter in a subprocess
def _assert_python(expected_success, *args, **env_vars):
@@ -90,6 +91,27 @@ def make_script(script_dir, script_basename, source):
script_file.close()
return script_name
+def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
+ zip_filename = zip_basename+os.extsep+'zip'
+ zip_name = os.path.join(zip_dir, zip_filename)
+ zip_file = zipfile.ZipFile(zip_name, 'w')
+ if name_in_zip is None:
+ parts = script_name.split(os.sep)
+ if len(parts) >= 2 and parts[-2] == '__pycache__':
+ legacy_pyc = make_legacy_pyc(source_from_cache(script_name))
+ name_in_zip = os.path.basename(legacy_pyc)
+ script_name = legacy_pyc
+ else:
+ name_in_zip = os.path.basename(script_name)
+ zip_file.write(script_name, name_in_zip)
+ zip_file.close()
+ #if test.support.verbose:
+ # zip_file = zipfile.ZipFile(zip_name, 'r')
+ # print 'Contents of %r:' % zip_name
+ # zip_file.printdir()
+ # zip_file.close()
+ return zip_name, os.path.join(zip_name, name_in_zip)
+
def make_pkg(pkg_dir, init_source=''):
os.mkdir(pkg_dir)
make_script(pkg_dir, '__init__', init_source)
diff --git a/Lib/test/ssl_cert.pem b/Lib/test/ssl_cert.pem
index 9d7ac238d8..47a7d7e37e 100644
--- a/Lib/test/ssl_cert.pem
+++ b/Lib/test/ssl_cert.pem
@@ -1,14 +1,15 @@
-----BEGIN CERTIFICATE-----
-MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD
-VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv
-bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy
-dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X
-DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw
-EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l
-dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT
-EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp
-MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw
-L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN
-BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX
-9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4=
+MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV
+BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u
+IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw
+MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH
+Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k
+YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
+gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7
+6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt
+pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw
+FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd
+BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G
+lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1
+CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX
-----END CERTIFICATE-----
diff --git a/Lib/test/ssl_key.pem b/Lib/test/ssl_key.pem
index 239ad66f99..3fd3bbd54a 100644
--- a/Lib/test/ssl_key.pem
+++ b/Lib/test/ssl_key.pem
@@ -1,9 +1,16 @@
------BEGIN RSA PRIVATE KEY-----
-MIIBPAIBAAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNwL4lYKbpzzlmC5beaQXeQ
-2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAAQJBALjkK+jc2+iihI98riEF
-oudmkNziSRTYjnwjx8mCoAjPWviB3c742eO3FG4/soi1jD9A5alihEOXfUzloenr
-8IECIQD3B5+0l+68BA/6d76iUNqAAV8djGTzvxnCxycnxPQydQIhAMXt4trUI3nc
-a+U8YL2HPFA3gmhBsSICbq2OptOCnM7hAiEA6Xi3JIQECob8YwkRj29DU3/4WYD7
-WLPgsQpwo1GuSpECICGsnWH5oaeD9t9jbFoSfhJvv0IZmxdcLpRcpslpeWBBAiEA
-6/5B8J0GHdJq89FHwEG/H2eVVUYu5y/aD6sgcm+0Avg=
------END RSA PRIVATE KEY-----
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm
+LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0
+ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP
+USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt
+CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq
+SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK
+UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y
+BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ
+ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5
+oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik
+eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F
+0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS
+x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/
+SPIXQuT8RMPDVNQ=
+-----END PRIVATE KEY-----
diff --git a/Lib/test/ssl_servers.py b/Lib/test/ssl_servers.py
new file mode 100644
index 0000000000..77c0542610
--- /dev/null
+++ b/Lib/test/ssl_servers.py
@@ -0,0 +1,189 @@
+import os
+import sys
+import ssl
+import pprint
+import socket
+import urllib.parse
+# Rename HTTPServer to _HTTPServer so as to avoid confusion with HTTPSServer.
+from http.server import (HTTPServer as _HTTPServer,
+ SimpleHTTPRequestHandler, BaseHTTPRequestHandler)
+
+from test import support
+threading = support.import_module("threading")
+
+here = os.path.dirname(__file__)
+
+HOST = support.HOST
+CERTFILE = os.path.join(here, 'keycert.pem')
+
+# This one's based on HTTPServer, which is based on SocketServer
+
+class HTTPSServer(_HTTPServer):
+
+ def __init__(self, server_address, handler_class, context):
+ _HTTPServer.__init__(self, server_address, handler_class)
+ self.context = context
+
+ def __str__(self):
+ return ('<%s %s:%s>' %
+ (self.__class__.__name__,
+ self.server_name,
+ self.server_port))
+
+ def get_request(self):
+ # override this to wrap socket with SSL
+ try:
+ sock, addr = self.socket.accept()
+ sslconn = self.context.wrap_socket(sock, server_side=True)
+ except socket.error as e:
+ # socket errors are silenced by the caller, print them here
+ if support.verbose:
+ sys.stderr.write("Got an error:\n%s\n" % e)
+ raise
+ return sslconn, addr
+
+class RootedHTTPRequestHandler(SimpleHTTPRequestHandler):
+ # need to override translate_path to get a known root,
+ # instead of using os.curdir, since the test could be
+ # run from anywhere
+
+ server_version = "TestHTTPS/1.0"
+ root = here
+ # Avoid hanging when a request gets interrupted by the client
+ timeout = 5
+
+ def translate_path(self, path):
+ """Translate a /-separated PATH to the local filename syntax.
+
+ Components that mean special things to the local file system
+ (e.g. drive or directory names) are ignored. (XXX They should
+ probably be diagnosed.)
+
+ """
+ # abandon query parameters
+ path = urllib.parse.urlparse(path)[2]
+ path = os.path.normpath(urllib.parse.unquote(path))
+ words = path.split('/')
+ words = filter(None, words)
+ path = self.root
+ for word in words:
+ drive, word = os.path.splitdrive(word)
+ head, word = os.path.split(word)
+ path = os.path.join(path, word)
+ return path
+
+ def log_message(self, format, *args):
+ # we override this to suppress logging unless "verbose"
+ if support.verbose:
+ sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" %
+ (self.server.server_address,
+ self.server.server_port,
+ self.request.cipher(),
+ self.log_date_time_string(),
+ format%args))
+
+
+class StatsRequestHandler(BaseHTTPRequestHandler):
+ """Example HTTP request handler which returns SSL statistics on GET
+ requests.
+ """
+
+ server_version = "StatsHTTPS/1.0"
+
+ def do_GET(self, send_body=True):
+ """Serve a GET request."""
+ sock = self.rfile.raw._sock
+ context = sock.context
+ body = pprint.pformat(context.session_stats())
+ body = body.encode('utf-8')
+ self.send_response(200)
+ self.send_header("Content-type", "text/plain; charset=utf-8")
+ self.send_header("Content-Length", str(len(body)))
+ self.end_headers()
+ if send_body:
+ self.wfile.write(body)
+
+ def do_HEAD(self):
+ """Serve a HEAD request."""
+ self.do_GET(send_body=False)
+
+ def log_request(self, format, *args):
+ if support.verbose:
+ BaseHTTPRequestHandler.log_request(self, format, *args)
+
+
+class HTTPSServerThread(threading.Thread):
+
+ def __init__(self, context, host=HOST, handler_class=None):
+ self.flag = None
+ self.server = HTTPSServer((host, 0),
+ handler_class or RootedHTTPRequestHandler,
+ context)
+ self.port = self.server.server_port
+ threading.Thread.__init__(self)
+ self.daemon = True
+
+ def __str__(self):
+ return "<%s %s>" % (self.__class__.__name__, self.server)
+
+ def start(self, flag=None):
+ self.flag = flag
+ threading.Thread.start(self)
+
+ def run(self):
+ if self.flag:
+ self.flag.set()
+ try:
+ self.server.serve_forever(0.05)
+ finally:
+ self.server.server_close()
+
+ def stop(self):
+ self.server.shutdown()
+
+
+def make_https_server(case, certfile=CERTFILE, host=HOST, handler_class=None):
+ # we assume the certfile contains both private key and certificate
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.load_cert_chain(certfile)
+ server = HTTPSServerThread(context, host, handler_class)
+ flag = threading.Event()
+ server.start(flag)
+ flag.wait()
+ def cleanup():
+ if support.verbose:
+ sys.stdout.write('stopping HTTPS server\n')
+ server.stop()
+ if support.verbose:
+ sys.stdout.write('joining HTTPS thread\n')
+ server.join()
+ case.addCleanup(cleanup)
+ return server
+
+
+if __name__ == "__main__":
+ import argparse
+ parser = argparse.ArgumentParser(
+ description='Run a test HTTPS server. '
+ 'By default, the current directory is served.')
+ parser.add_argument('-p', '--port', type=int, default=4433,
+ help='port to listen on (default: %(default)s)')
+ parser.add_argument('-q', '--quiet', dest='verbose', default=True,
+ action='store_false', help='be less verbose')
+ parser.add_argument('-s', '--stats', dest='use_stats_handler', default=False,
+ action='store_true', help='always return stats page')
+ args = parser.parse_args()
+
+ support.verbose = args.verbose
+ if args.use_stats_handler:
+ handler_class = StatsRequestHandler
+ else:
+ handler_class = RootedHTTPRequestHandler
+ handler_class.root = os.getcwd()
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.load_cert_chain(CERTFILE)
+
+ server = HTTPSServer(("", args.port), handler_class, context)
+ if args.verbose:
+ print("Listening on https://localhost:{0.port}".format(args))
+ server.serve_forever(0.1)
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index a813616879..1cc36d836b 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -172,6 +172,9 @@ class BaseTest(unittest.TestCase):
self.checkequal(-1, '', 'find', 'xx', 1, 1)
self.checkequal(-1, '', 'find', 'xx', sys.maxsize, 0)
+ # issue 7458
+ self.checkequal(-1, 'ab', 'find', 'xxx', sys.maxsize + 1, 0)
+
# For a variety of combinations,
# verify that str.find() matches __contains__
# and that the found substring is really at that location
@@ -191,8 +194,7 @@ class BaseTest(unittest.TestCase):
loc = i.find(j)
r1 = (loc != -1)
r2 = j in i
- if r1 != r2:
- self.assertEqual(r1, r2)
+ self.assertEqual(r1, r2)
if loc != -1:
self.assertEqual(i[loc:loc+len(j)], j)
@@ -216,6 +218,32 @@ class BaseTest(unittest.TestCase):
self.checkraises(TypeError, 'hello', 'rfind')
self.checkraises(TypeError, 'hello', 'rfind', 42)
+ # For a variety of combinations,
+ # verify that str.rfind() matches __contains__
+ # and that the found substring is really at that location
+ charset = ['', 'a', 'b', 'c']
+ digits = 5
+ base = len(charset)
+ teststrings = set()
+ for i in range(base ** digits):
+ entry = []
+ for j in range(digits):
+ i, m = divmod(i, base)
+ entry.append(charset[m])
+ teststrings.add(''.join(entry))
+ teststrings = [self.fixtype(ts) for ts in teststrings]
+ for i in teststrings:
+ for j in teststrings:
+ loc = i.rfind(j)
+ r1 = (loc != -1)
+ r2 = j in i
+ self.assertEqual(r1, r2)
+ if loc != -1:
+ self.assertEqual(i[loc:loc+len(j)], j)
+
+ # issue 7458
+ self.checkequal(-1, 'ab', 'rfind', 'xxx', sys.maxsize + 1, 0)
+
def test_index(self):
self.checkequal(0, 'abcdefghiabc', 'index', '')
self.checkequal(3, 'abcdefghiabc', 'index', 'def')
@@ -1071,7 +1099,6 @@ class MixinStrUnicodeUserStringTest:
longvalue = sys.maxsize + 10
slongvalue = str(longvalue)
- if slongvalue[-1] in ("L","l"): slongvalue = slongvalue[:-1]
self.checkequal(' 42', '%3ld', '__mod__', 42)
self.checkequal('42', '%d', '__mod__', 42.0)
self.checkequal(slongvalue, '%d', '__mod__', longvalue)
@@ -1086,7 +1113,7 @@ class MixinStrUnicodeUserStringTest:
self.checkraises(ValueError, '%(foo', '__mod__', {})
self.checkraises(TypeError, '%(foo)s %(bar)s', '__mod__', ('foo', 42))
self.checkraises(TypeError, '%d', '__mod__', "42") # not numeric
- self.checkraises(TypeError, '%d', '__mod__', (42+0j)) # no int/long conversion provided
+ self.checkraises(TypeError, '%d', '__mod__', (42+0j)) # no int conversion provided
# argument names with properly nested brackets are supported
self.checkequal('bar', '%((foo))s', '__mod__', {'(foo)': 'bar'})
@@ -1104,7 +1131,7 @@ class MixinStrUnicodeUserStringTest:
format = '%%.%if' % prec
value = 0.01
for x in range(60):
- value = value * 3.141592655 / 3.0 * 10.0
+ value = value * 3.14159265359 / 3.0 * 10.0
self.checkcall(format, "__mod__", value)
def test_inplace_rewrites(self):
diff --git a/Lib/test/subprocessdata/fd_status.py b/Lib/test/subprocessdata/fd_status.py
new file mode 100644
index 0000000000..1f61e13a34
--- /dev/null
+++ b/Lib/test/subprocessdata/fd_status.py
@@ -0,0 +1,24 @@
+"""When called as a script, print a comma-separated list of the open
+file descriptors on stdout."""
+
+import errno
+import os
+
+try:
+ _MAXFD = os.sysconf("SC_OPEN_MAX")
+except:
+ _MAXFD = 256
+
+if __name__ == "__main__":
+ fds = []
+ for fd in range(0, _MAXFD):
+ try:
+ st = os.fstat(fd)
+ except OSError as e:
+ if e.errno == errno.EBADF:
+ continue
+ raise
+ # Ignore Solaris door files
+ if st.st_mode & 0xF000 != 0xd000:
+ fds.append(fd)
+ print(','.join(map(str, fds)))
diff --git a/Lib/test/subprocessdata/input_reader.py b/Lib/test/subprocessdata/input_reader.py
new file mode 100644
index 0000000000..1dc3191ad1
--- /dev/null
+++ b/Lib/test/subprocessdata/input_reader.py
@@ -0,0 +1,7 @@
+"""When called as a script, consumes the input"""
+
+import sys
+
+if __name__ == "__main__":
+ for line in sys.stdin:
+ pass
diff --git a/Lib/test/subprocessdata/qcat.py b/Lib/test/subprocessdata/qcat.py
new file mode 100644
index 0000000000..fe6f9db25c
--- /dev/null
+++ b/Lib/test/subprocessdata/qcat.py
@@ -0,0 +1,7 @@
+"""When ran as a script, simulates cat with no arguments."""
+
+import sys
+
+if __name__ == "__main__":
+ for line in sys.stdin:
+ sys.stdout.write(line)
diff --git a/Lib/test/subprocessdata/qgrep.py b/Lib/test/subprocessdata/qgrep.py
new file mode 100644
index 0000000000..69906379a9
--- /dev/null
+++ b/Lib/test/subprocessdata/qgrep.py
@@ -0,0 +1,10 @@
+"""When called with a single argument, simulated fgrep with a single
+argument and no options."""
+
+import sys
+
+if __name__ == "__main__":
+ pattern = sys.argv[1]
+ for line in sys.stdin:
+ if pattern in line:
+ sys.stdout.write(line)
diff --git a/Lib/test/support.py b/Lib/test/support.py
index bef7161e9a..8d8e18735e 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -10,29 +10,41 @@ import gc
import socket
import sys
import os
-import re
import platform
import shutil
import warnings
import unittest
import importlib
import collections
+import re
+import subprocess
+import imp
+import time
+import sysconfig
+import logging.handlers
+
+try:
+ import _thread
+except ImportError:
+ _thread = None
__all__ = [
"Error", "TestFailed", "ResourceDenied", "import_module",
"verbose", "use_resources", "max_memuse", "record_original_stdout",
"get_original_stdout", "unload", "unlink", "rmtree", "forget",
"is_resource_enabled", "requires", "find_unused_port", "bind_port",
- "fcmp", "is_jython", "TESTFN", "HOST", "FUZZ", "findfile", "verify",
- "vereq", "sortdict", "check_syntax_error", "open_urlresource",
+ "fcmp", "is_jython", "TESTFN", "HOST", "FUZZ", "SAVEDCWD", "temp_cwd",
+ "findfile", "sortdict", "check_syntax_error", "open_urlresource",
"check_warnings", "CleanImport", "EnvironmentVarGuard",
"TransientResource", "captured_output", "captured_stdout",
"time_out", "socket_peer_reset", "ioerror_peer_reset",
- "run_with_locale", "transient_internet",
+ "run_with_locale", 'temp_umask', "transient_internet",
"set_memlimit", "bigmemtest", "bigaddrspacetest", "BasicTestRunner",
"run_unittest", "run_doctest", "threading_setup", "threading_cleanup",
"reap_children", "cpython_only", "check_impl_detail", "get_attribute",
- ]
+ "swap_item", "swap_attr", "requires_IEEE_754",
+ "TestHandler", "Matcher", "can_symlink", "skip_unless_symlink"]
+
class Error(Exception):
"""Base class for regression test exceptions."""
@@ -176,27 +188,50 @@ def unload(name):
def unlink(filename):
try:
os.unlink(filename)
- except OSError:
- pass
+ except OSError as error:
+ # The filename need not exist.
+ if error.errno not in (errno.ENOENT, errno.ENOTDIR):
+ raise
def rmtree(path):
try:
shutil.rmtree(path)
- except OSError as e:
+ except OSError as error:
# Unix returns ENOENT, Windows returns ESRCH.
- if e.errno not in (errno.ENOENT, errno.ESRCH):
+ if error.errno not in (errno.ENOENT, errno.ESRCH):
raise
+def make_legacy_pyc(source):
+ """Move a PEP 3147 pyc/pyo file to its legacy pyc/pyo location.
+
+ The choice of .pyc or .pyo extension is done based on the __debug__ flag
+ value.
+
+ :param source: The file system path to the source file. The source file
+ does not need to exist, however the PEP 3147 pyc file must exist.
+ :return: The file system path to the legacy pyc file.
+ """
+ pyc_file = imp.cache_from_source(source)
+ up_one = os.path.dirname(os.path.abspath(source))
+ legacy_pyc = os.path.join(up_one, source + ('c' if __debug__ else 'o'))
+ os.rename(pyc_file, legacy_pyc)
+ return legacy_pyc
+
def forget(modname):
- '''"Forget" a module was ever imported by removing it from sys.modules and
- deleting any .pyc and .pyo files.'''
+ """'Forget' a module was ever imported.
+
+ This removes the module from sys.modules and deletes any PEP 3147 or
+ legacy .pyc and .pyo files.
+ """
unload(modname)
for dirname in sys.path:
- unlink(os.path.join(dirname, modname + '.pyc'))
- # Deleting the .pyo file cannot be within the 'try' for the .pyc since
- # the chance exists that there is no .pyc (and thus the 'try' statement
- # is exited) but there is a .pyo file.
- unlink(os.path.join(dirname, modname + '.pyo'))
+ source = os.path.join(dirname, modname + '.py')
+ # It doesn't matter if they exist or not, unlink all possible
+ # combinations of PEP 3147 and legacy pyc and pyo files.
+ unlink(source + 'c')
+ unlink(source + 'o')
+ unlink(imp.cache_from_source(source, debug_override=True))
+ unlink(imp.cache_from_source(source, debug_override=False))
# On some platforms, should not run gui test even if it is allowed
# in `use_resources'.
@@ -237,7 +272,9 @@ def requires(resource, msg=None):
"""Raise ResourceDenied if the specified resource is not available.
If the caller's module is __main__ then automatically return True. The
- possibility of False being returned occurs when regrtest.py is executing."""
+ possibility of False being returned occurs when regrtest.py is
+ executing.
+ """
if resource == 'gui' and not _is_gui_available():
raise unittest.SkipTest("Cannot use the 'gui' resource")
# see if the caller's module is __main__ - if so, treat as if
@@ -362,6 +399,11 @@ def fcmp(x, y): # fuzzy comparison function
return (len(x) > len(y)) - (len(x) < len(y))
return (x > y) - (x < y)
+# decorator for skipping tests on non-IEEE 754 platforms
+requires_IEEE_754 = unittest.skipUnless(
+ float.__getformat__("double").startswith("IEEE"),
+ "test requires IEEE 754 doubles")
+
is_jython = sys.platform.startswith('java')
# Filename used for testing
@@ -371,57 +413,106 @@ if os.name == 'java':
else:
TESTFN = '@test'
- # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding()
- # TESTFN_UNICODE is a filename that can be encoded using the
- # file system encoding, but *not* with the default (ascii) encoding
- TESTFN_UNICODE = "@test-\xe0\xf2"
- TESTFN_ENCODING = sys.getfilesystemencoding()
- # TESTFN_UNENCODABLE is a filename that should *not* be
- # able to be encoded by *either* the default or filesystem encoding.
- # This test really only makes sense on Windows NT platforms
- # which have special Unicode support in posixmodule.
- if (not hasattr(sys, "getwindowsversion") or
- sys.getwindowsversion()[3] < 2): # 0=win32s or 1=9x/ME
- TESTFN_UNENCODABLE = None
- else:
+# Disambiguate TESTFN for parallel testing, while letting it remain a valid
+# module name.
+TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())
+
+
+# TESTFN_UNICODE is a non-ascii filename
+TESTFN_UNICODE = TESTFN + "-\xe0\xf2\u0258\u0141\u011f"
+if sys.platform == 'darwin':
+ # In Mac OS X's VFS API file names are, by definition, canonically
+ # decomposed Unicode, encoded using UTF-8. See QA1173:
+ # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
+ import unicodedata
+ TESTFN_UNICODE = unicodedata.normalize('NFD', TESTFN_UNICODE)
+TESTFN_ENCODING = sys.getfilesystemencoding()
+
+# TESTFN_UNENCODABLE is a filename (str type) that should *not* be able to be
+# encoded by the filesystem encoding (in strict mode). It can be None if we
+# cannot generate such filename.
+TESTFN_UNENCODABLE = None
+if os.name in ('nt', 'ce'):
+ # skip win32s (0) or Windows 9x/ME (1)
+ if sys.getwindowsversion().platform >= 2:
# Different kinds of characters from various languages to minimize the
# probability that the whole name is encodable to MBCS (issue #9819)
TESTFN_UNENCODABLE = TESTFN + "-\u5171\u0141\u2661\u0363\uDC80"
try:
- # XXX - Note - should be using TESTFN_ENCODING here - but for
- # Windows, "mbcs" currently always operates as if in
- # errors=ignore' mode - hence we get '?' characters rather than
- # the exception. 'Latin1' operates as we expect - ie, fails.
- # See [ 850997 ] mbcs encoding ignores errors
- TESTFN_UNENCODABLE.encode("Latin1")
+ TESTFN_UNENCODABLE.encode(TESTFN_ENCODING)
except UnicodeEncodeError:
pass
else:
- print('WARNING: The filename %r CAN be encoded by the filesystem. '
+ print('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
'Unicode filename tests may not be effective'
- % TESTFN_UNENCODABLE)
+ % (TESTFN_UNENCODABLE, TESTFN_ENCODING))
+ TESTFN_UNENCODABLE = None
+# Mac OS X denies unencodable filenames (invalid utf-8)
+elif sys.platform != 'darwin':
+ try:
+ # ascii and utf-8 cannot encode the byte 0xff
+ b'\xff'.decode(TESTFN_ENCODING)
+ except UnicodeDecodeError:
+ # 0xff will be encoded using the surrogate character u+DCFF
+ TESTFN_UNENCODABLE = TESTFN \
+ + b'-\xff'.decode(TESTFN_ENCODING, 'surrogateescape')
+ else:
+ # File system encoding (eg. ISO-8859-* encodings) can encode
+ # the byte 0xff. Skip some unicode filename tests.
+ pass
-if os.path.isdir(TESTFN):
- # a test failed (eg. test_os) without removing TESTFN directory
- shutil.rmtree(TESTFN)
+# Save the initial cwd
+SAVEDCWD = os.getcwd()
-# Make sure we can write to TESTFN, try in /tmp if we can't
-fp = None
-try:
- fp = open(TESTFN, 'w+')
-except IOError:
- TMP_TESTFN = os.path.join('/tmp', TESTFN)
+@contextlib.contextmanager
+def temp_cwd(name='tempcwd', quiet=False, path=None):
+ """
+ Context manager that temporarily changes the CWD.
+
+ An existing path may be provided as *path*, in which case this
+ function makes no changes to the file system.
+
+ Otherwise, the new CWD is created in the current directory and it's
+ named *name*. If *quiet* is False (default) and it's not possible to
+ create or change the CWD, an error is raised. If it's True, only a
+ warning is raised and the original CWD is used.
+ """
+ saved_dir = os.getcwd()
+ is_temporary = False
+ if path is None:
+ path = name
+ try:
+ os.mkdir(name)
+ is_temporary = True
+ except OSError:
+ if not quiet:
+ raise
+ warnings.warn('tests may fail, unable to create temp CWD ' + name,
+ RuntimeWarning, stacklevel=3)
+ try:
+ os.chdir(path)
+ except OSError:
+ if not quiet:
+ raise
+ warnings.warn('tests may fail, unable to change the CWD to ' + name,
+ RuntimeWarning, stacklevel=3)
try:
- fp = open(TMP_TESTFN, 'w+')
- TESTFN = TMP_TESTFN
- del TMP_TESTFN
- except IOError:
- print(('WARNING: tests will fail, unable to write to: %s or %s' %
- (TESTFN, TMP_TESTFN)))
-if fp is not None:
- fp.close()
- unlink(TESTFN)
-del fp
+ yield os.getcwd()
+ finally:
+ os.chdir(saved_dir)
+ if is_temporary:
+ rmtree(name)
+
+
+@contextlib.contextmanager
+def temp_umask(umask):
+ """Context manager that temporarily sets the process umask."""
+ oldmask = os.umask(umask)
+ try:
+ yield
+ finally:
+ os.umask(oldmask)
+
def findfile(file, here=__file__, subdir=None):
"""Try to find a file on sys.path and the working directory. If it is not
@@ -438,30 +529,6 @@ def findfile(file, here=__file__, subdir=None):
if os.path.exists(fn): return fn
return file
-def verify(condition, reason='test failed'):
- """Verify that condition is true. If not, raise TestFailed.
-
- The optional argument reason can be given to provide
- a better error text.
- """
-
- if not condition:
- raise TestFailed(reason)
-
-def vereq(a, b):
- """Raise TestFailed if a == b is false.
-
- This is better than verify(a == b) because, in case of failure, the
- error message incorporates repr(a) and repr(b) so you can see the
- inputs.
-
- Note that "not (a == b)" isn't necessarily the same as "a != b"; the
- former is tested.
- """
-
- if not (a == b):
- raise TestFailed("%r == %r" % (a, b))
-
def sortdict(dict):
"Like repr(dict), but in sorted order."
items = sorted(dict.items())
@@ -488,47 +555,131 @@ def check_syntax_error(testcase, statement):
def open_urlresource(url, *args, **kw):
import urllib.request, urllib.parse
- requires('urlfetch')
+ check = kw.pop('check', None)
+
filename = urllib.parse.urlparse(url)[2].split('/')[-1] # '/': it's URL!
- for path in [os.path.curdir, os.path.pardir]:
- fn = os.path.join(path, filename)
- if os.path.exists(fn):
- return open(fn, *args, **kw)
+ fn = os.path.join(os.path.dirname(__file__), "data", filename)
+
+ def check_valid_file(fn):
+ f = open(fn, *args, **kw)
+ if check is None:
+ return f
+ elif check(f):
+ f.seek(0)
+ return f
+ f.close()
+
+ if os.path.exists(fn):
+ f = check_valid_file(fn)
+ if f is not None:
+ return f
+ unlink(fn)
+
+ # Verify the requirement before downloading the file
+ requires('urlfetch')
print('\tfetching %s ...' % url, file=get_original_stdout())
f = urllib.request.urlopen(url, timeout=15)
try:
- with open(filename, "wb") as out:
+ with open(fn, "wb") as out:
s = f.read()
while s:
out.write(s)
s = f.read()
finally:
f.close()
- return open(filename, *args, **kw)
+
+ f = check_valid_file(fn)
+ if f is not None:
+ return f
+ raise TestFailed('invalid resource "%s"' % fn)
+
class WarningsRecorder(object):
"""Convenience wrapper for the warnings list returned on
entry to the warnings.catch_warnings() context manager.
"""
def __init__(self, warnings_list):
- self.warnings = warnings_list
+ self._warnings = warnings_list
+ self._last = 0
def __getattr__(self, attr):
- if self.warnings:
- return getattr(self.warnings[-1], attr)
+ if len(self._warnings) > self._last:
+ return getattr(self._warnings[-1], attr)
elif attr in warnings.WarningMessage._WARNING_DETAILS:
return None
raise AttributeError("%r has no attribute %r" % (self, attr))
+ @property
+ def warnings(self):
+ return self._warnings[self._last:]
+
def reset(self):
- del self.warnings[:]
+ self._last = len(self._warnings)
-@contextlib.contextmanager
-def check_warnings():
+
+def _filterwarnings(filters, quiet=False):
+ """Catch the warnings, then check if all the expected
+ warnings have been raised and re-raise unexpected warnings.
+ If 'quiet' is True, only re-raise the unexpected warnings.
+ """
+ # Clear the warning registry of the calling module
+ # in order to re-raise the warnings.
+ frame = sys._getframe(2)
+ registry = frame.f_globals.get('__warningregistry__')
+ if registry:
+ registry.clear()
with warnings.catch_warnings(record=True) as w:
+ # Set filter "always" to record all warnings. Because
+ # test_warnings swap the module, we need to look up in
+ # the sys.modules dictionary.
+ sys.modules['warnings'].simplefilter("always")
yield WarningsRecorder(w)
+ # Filter the recorded warnings
+ reraise = list(w)
+ missing = []
+ for msg, cat in filters:
+ seen = False
+ for w in reraise[:]:
+ warning = w.message
+ # Filter out the matching messages
+ if (re.match(msg, str(warning), re.I) and
+ issubclass(warning.__class__, cat)):
+ seen = True
+ reraise.remove(w)
+ if not seen and not quiet:
+ # This filter caught nothing
+ missing.append((msg, cat.__name__))
+ if reraise:
+ raise AssertionError("unhandled warning %s" % reraise[0])
+ if missing:
+ raise AssertionError("filter (%r, %s) did not catch any warning" %
+ missing[0])
+
+
+@contextlib.contextmanager
+def check_warnings(*filters, **kwargs):
+ """Context manager to silence warnings.
+
+ Accept 2-tuples as positional arguments:
+ ("message regexp", WarningCategory)
+
+ Optional argument:
+ - if 'quiet' is True, it does not fail if a filter catches nothing
+ (default True without argument,
+ default False if some filters are defined)
+
+ Without argument, it defaults to:
+ check_warnings(("", Warning), quiet=True)
+ """
+ quiet = kwargs.get('quiet')
+ if not filters:
+ filters = (("", Warning),)
+ # Preserve backward compatibility
+ if quiet is None:
+ quiet = True
+ return _filterwarnings(filters, quiet)
class CleanImport(object):
@@ -540,7 +691,7 @@ class CleanImport(object):
Use like this:
with CleanImport("foo"):
- __import__("foo") # new reference
+ importlib.import_module("foo") # new reference
"""
def __init__(self, *module_names):
@@ -613,6 +764,32 @@ class EnvironmentVarGuard(collections.MutableMapping):
del self._environ[k]
else:
self._environ[k] = v
+ os.environ = self._environ
+
+
+class DirsOnSysPath(object):
+ """Context manager to temporarily add directories to sys.path.
+
+ This makes a copy of sys.path, appends any directories given
+ as positional arguments, then reverts sys.path to the copied
+ settings when the context ends.
+
+ Note that *all* sys.path modifications in the body of the
+ context manager, including replacement of the object,
+ will be reverted at the end of the block.
+ """
+
+ def __init__(self, *paths):
+ self.original_value = sys.path[:]
+ self.original_object = sys.path
+ sys.path.extend(paths)
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *ignore_exc):
+ sys.path = self.original_object
+ sys.path[:] = self.original_value
class TransientResource(object):
@@ -730,6 +907,12 @@ def captured_output(stream_name):
def captured_stdout():
return captured_output("stdout")
+def captured_stderr():
+ return captured_output("stderr")
+
+def captured_stdin():
+ return captured_output("stdin")
+
def gc_collect():
"""Force as many objects as possible to be collected.
@@ -741,10 +924,22 @@ def gc_collect():
objects to disappear.
"""
gc.collect()
+ if is_jython:
+ time.sleep(0.1)
gc.collect()
gc.collect()
+def python_is_optimized():
+ """Find if Python was built with optimizations."""
+ cflags = sysconfig.get_config_var('PY_CFLAGS') or ''
+ final_opt = ""
+ for opt in cflags.split():
+ if opt.startswith('-O'):
+ final_opt = opt
+ return final_opt and final_opt != '-O0'
+
+
#=======================================================================
# Decorator for running a function in a different locale, correctly resetting
# it afterwards.
@@ -795,7 +990,6 @@ _4G = 4 * _1G
MAX_Py_ssize_t = sys.maxsize
def set_memlimit(limit):
- import re
global max_memuse
global real_max_memuse
sizes = {
@@ -1033,31 +1227,50 @@ def modules_cleanup(oldmodules):
if k.startswith('encodings.')]
sys.modules.clear()
sys.modules.update(encodings)
+ # XXX: This kind of problem can affect more than just encodings. In particular
+ # extension modules (such as _ssl) don't cope with reloading properly.
+ # Really, test modules should be cleaning out the test specific modules they
+ # know they added (ala test_runpy) rather than relying on this function (as
+ # test_importhooks and test_pkg do currently).
+ # Implicitly imported *real* modules should be left alone (see issue 10556).
sys.modules.update(oldmodules)
#=======================================================================
# Threading support to prevent reporting refleaks when running regrtest.py -R
-def threading_setup():
- import threading
- return len(threading._active), len(threading._limbo)
+# NOTE: we use thread._count() rather than threading.enumerate() (or the
+# moral equivalent thereof) because a threading.Thread object is still alive
+# until its __bootstrap() method has returned, even after it has been
+# unregistered from the threading module.
+# thread._count(), on the other hand, only gets decremented *after* the
+# __bootstrap() method has returned, which gives us reliable reference counts
+# at the end of a test run.
-def threading_cleanup(num_active, num_limbo):
- import threading
- import time
+def threading_setup():
+ if _thread:
+ return _thread._count(),
+ else:
+ return 1,
+def threading_cleanup(nb_threads):
+ if not _thread:
+ return
_MAX_COUNT = 10
- count = 0
- while len(threading._active) != num_active and count < _MAX_COUNT:
- count += 1
- time.sleep(0.1)
-
- count = 0
- while len(threading._limbo) != num_limbo and count < _MAX_COUNT:
- count += 1
+ for count in range(_MAX_COUNT):
+ n = _thread._count()
+ if n == nb_threads:
+ break
time.sleep(0.1)
+ # XXX print a warning in case of failure?
def reap_threads(func):
+ """Use this function when threads are being used. This will
+ ensure that the threads are cleaned up even when the test fails.
+ If threading is unavailable this function does nothing.
+ """
+ if not _thread:
+ return func
+
@functools.wraps(func)
def decorator(*args):
key = threading_setup()
@@ -1087,6 +1300,60 @@ def reap_children():
except:
break
+@contextlib.contextmanager
+def swap_attr(obj, attr, new_val):
+ """Temporary swap out an attribute with a new object.
+
+ Usage:
+ with swap_attr(obj, "attr", 5):
+ ...
+
+ This will set obj.attr to 5 for the duration of the with: block,
+ restoring the old value at the end of the block. If `attr` doesn't
+ exist on `obj`, it will be created and then deleted at the end of the
+ block.
+ """
+ if hasattr(obj, attr):
+ real_val = getattr(obj, attr)
+ setattr(obj, attr, new_val)
+ try:
+ yield
+ finally:
+ setattr(obj, attr, real_val)
+ else:
+ setattr(obj, attr, new_val)
+ try:
+ yield
+ finally:
+ delattr(obj, attr)
+
+@contextlib.contextmanager
+def swap_item(obj, item, new_val):
+ """Temporary swap out an item with a new object.
+
+ Usage:
+ with swap_item(obj, "item", 5):
+ ...
+
+ This will set obj["item"] to 5 for the duration of the with: block,
+ restoring the old value at the end of the block. If `item` doesn't
+ exist on `obj`, it will be created and then deleted at the end of the
+ block.
+ """
+ if item in obj:
+ real_val = obj[item]
+ obj[item] = new_val
+ try:
+ yield
+ finally:
+ obj[item] = real_val
+ else:
+ obj[item] = new_val
+ try:
+ yield
+ finally:
+ del obj[item]
+
def strip_python_stderr(stderr):
"""Strip the stderr of a Python process from potential debug output
emitted by the interpreter.
@@ -1097,6 +1364,110 @@ def strip_python_stderr(stderr):
stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip()
return stderr
+def args_from_interpreter_flags():
+ """Return a list of command-line arguments reproducing the current
+ settings in sys.flags."""
+ flag_opt_map = {
+ 'bytes_warning': 'b',
+ 'dont_write_bytecode': 'B',
+ 'ignore_environment': 'E',
+ 'no_user_site': 's',
+ 'no_site': 'S',
+ 'optimize': 'O',
+ 'verbose': 'v',
+ }
+ args = []
+ for flag, opt in flag_opt_map.items():
+ v = getattr(sys.flags, flag)
+ if v > 0:
+ args.append('-' + opt * v)
+ return args
+
+#============================================================
+# Support for assertions about logging.
+#============================================================
+
+class TestHandler(logging.handlers.BufferingHandler):
+ def __init__(self, matcher):
+ # BufferingHandler takes a "capacity" argument
+ # so as to know when to flush. As we're overriding
+ # shouldFlush anyway, we can set a capacity of zero.
+ # You can call flush() manually to clear out the
+ # buffer.
+ logging.handlers.BufferingHandler.__init__(self, 0)
+ self.matcher = matcher
+
+ def shouldFlush(self):
+ return False
+
+ def emit(self, record):
+ self.format(record)
+ self.buffer.append(record.__dict__)
+
+ def matches(self, **kwargs):
+ """
+ Look for a saved dict whose keys/values match the supplied arguments.
+ """
+ result = False
+ for d in self.buffer:
+ if self.matcher.matches(d, **kwargs):
+ result = True
+ break
+ return result
+
+class Matcher(object):
+
+ _partial_matches = ('msg', 'message')
+
+ def matches(self, d, **kwargs):
+ """
+ Try to match a single dict with the supplied arguments.
+
+ Keys whose values are strings and which are in self._partial_matches
+ will be checked for partial (i.e. substring) matches. You can extend
+ this scheme to (for example) do regular expression matching, etc.
+ """
+ result = True
+ for k in kwargs:
+ v = kwargs[k]
+ dv = d.get(k)
+ if not self.match_value(k, dv, v):
+ result = False
+ break
+ return result
+
+ def match_value(self, k, dv, v):
+ """
+ Try to match a single stored value (dv) with a supplied value (v).
+ """
+ if type(v) != type(dv):
+ result = False
+ elif type(dv) is not str or k not in self._partial_matches:
+ result = (v == dv)
+ else:
+ result = dv.find(v) >= 0
+ return result
+
+
+_can_symlink = None
+def can_symlink():
+ global _can_symlink
+ if _can_symlink is not None:
+ return _can_symlink
+ try:
+ os.symlink(TESTFN, TESTFN + "can_symlink")
+ can = True
+ except (OSError, NotImplementedError):
+ can = False
+ _can_symlink = can
+ return can
+
+def skip_unless_symlink(test):
+ """Skip decorator for tests that require functional symlink"""
+ ok = can_symlink()
+ msg = "Requires functional symlink implementation"
+ return test if ok else unittest.skip(msg)(test)
+
def patch(test_instance, object_to_patch, attr_name, new_value):
"""Override 'object_to_patch'.'attr_name' with 'new_value'.
diff --git a/Lib/test/test_SimpleHTTPServer.py b/Lib/test/test_SimpleHTTPServer.py
deleted file mode 100644
index bca9bd6abb..0000000000
--- a/Lib/test/test_SimpleHTTPServer.py
+++ /dev/null
@@ -1,41 +0,0 @@
-"""
-These tests only check url parsing for now.
-We don't want to require the 'network' resource.
-"""
-
-import os, unittest
-from http.server import SimpleHTTPRequestHandler
-from test import support
-
-
-class SocketlessRequestHandler(SimpleHTTPRequestHandler):
- def __init__(self):
- pass
-
-class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
- """ Test url parsing """
- def setUp (self):
- self.translated = os.getcwd()
- self.translated = os.path.join(self.translated, 'filename')
- self.handler = SocketlessRequestHandler ()
-
- def test_queryArguments (self):
- path = self.handler.translate_path ('/filename')
- self.assertEqual (path, self.translated)
- path = self.handler.translate_path ('/filename?foo=bar')
- self.assertEqual (path, self.translated)
- path = self.handler.translate_path ('/filename?a=b&spam=eggs#zot')
- self.assertEqual (path, self.translated)
-
- def test_startWithDoubleSlash (self):
- path = self.handler.translate_path ('//filename')
- self.assertEqual (path, self.translated)
- path = self.handler.translate_path ('//filename?foo=bar')
- self.assertEqual (path, self.translated)
-
-
-def test_main():
- support.run_unittest(SimpleHTTPRequestHandlerTestCase)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 200db5cfa2..608ec01f14 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -2,7 +2,6 @@ import unittest
from test import support
import os
import sys
-import warnings
class NoAll(RuntimeError):
@@ -16,9 +15,10 @@ class AllTest(unittest.TestCase):
def check_all(self, modname):
names = {}
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", ".* (module|package)",
- DeprecationWarning)
+ with support.check_warnings(
+ (".* (module|package)", DeprecationWarning),
+ ("", ResourceWarning),
+ quiet=True):
try:
exec("import %s" % modname, names)
except:
diff --git a/Lib/test/test___future__.py b/Lib/test/test___future__.py
index f41b8799b4..9ae4ce40ad 100644
--- a/Lib/test/test___future__.py
+++ b/Lib/test/test___future__.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import unittest
from test import support
import __future__
diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py
index 02942d17ba..3fadb575f2 100644
--- a/Lib/test/test__locale.py
+++ b/Lib/test/test__locale.py
@@ -1,4 +1,4 @@
-from test.support import verbose, run_unittest
+from test.support import run_unittest
from _locale import (setlocale, LC_ALL, LC_CTYPE, LC_NUMERIC, localeconv, Error)
try:
from _locale import (RADIXCHAR, THOUSEP, nl_langinfo)
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index 3aef4a00f2..d86f97c068 100644
--- a/Lib/test/test_abc.py
+++ b/Lib/test/test_abc.py
@@ -34,8 +34,46 @@ class TestABC(unittest.TestCase):
def foo(self): return super().foo
self.assertEqual(D().foo, 3)
+ def test_abstractclassmethod_basics(self):
+ @abc.abstractclassmethod
+ def foo(cls): pass
+ self.assertTrue(foo.__isabstractmethod__)
+ @classmethod
+ def bar(cls): pass
+ self.assertFalse(hasattr(bar, "__isabstractmethod__"))
+
+ class C(metaclass=abc.ABCMeta):
+ @abc.abstractclassmethod
+ def foo(cls): return cls.__name__
+ self.assertRaises(TypeError, C)
+ class D(C):
+ @classmethod
+ def foo(cls): return super().foo()
+ self.assertEqual(D.foo(), 'D')
+ self.assertEqual(D().foo(), 'D')
+
+ def test_abstractstaticmethod_basics(self):
+ @abc.abstractstaticmethod
+ def foo(): pass
+ self.assertTrue(foo.__isabstractmethod__)
+ @staticmethod
+ def bar(): pass
+ self.assertFalse(hasattr(bar, "__isabstractmethod__"))
+
+ class C(metaclass=abc.ABCMeta):
+ @abc.abstractstaticmethod
+ def foo(): return 3
+ self.assertRaises(TypeError, C)
+ class D(C):
+ @staticmethod
+ def foo(): return 4
+ self.assertEqual(D.foo(), 4)
+ self.assertEqual(D().foo(), 4)
+
def test_abstractmethod_integration(self):
- for abstractthing in [abc.abstractmethod, abc.abstractproperty]:
+ for abstractthing in [abc.abstractmethod, abc.abstractproperty,
+ abc.abstractclassmethod,
+ abc.abstractstaticmethod]:
class C(metaclass=abc.ABCMeta):
@abstractthing
def foo(self): pass # abstract
@@ -81,20 +119,20 @@ class TestABC(unittest.TestCase):
b = B()
self.assertFalse(issubclass(B, A))
self.assertFalse(issubclass(B, (A,)))
- self.assertEqual(isinstance(b, A), False)
- self.assertEqual(isinstance(b, (A,)), False)
+ self.assertNotIsInstance(b, A)
+ self.assertNotIsInstance(b, (A,))
A.register(B)
self.assertTrue(issubclass(B, A))
self.assertTrue(issubclass(B, (A,)))
- self.assertEqual(isinstance(b, A), True)
- self.assertEqual(isinstance(b, (A,)), True)
+ self.assertIsInstance(b, A)
+ self.assertIsInstance(b, (A,))
class C(B):
pass
c = C()
self.assertTrue(issubclass(C, A))
self.assertTrue(issubclass(C, (A,)))
- self.assertEqual(isinstance(c, A), True)
- self.assertEqual(isinstance(c, (A,)), True)
+ self.assertIsInstance(c, A)
+ self.assertIsInstance(c, (A,))
def test_isinstance_invalidation(self):
class A(metaclass=abc.ABCMeta):
@@ -112,16 +150,16 @@ class TestABC(unittest.TestCase):
class A(metaclass=abc.ABCMeta):
pass
A.register(int)
- self.assertEqual(isinstance(42, A), True)
- self.assertEqual(isinstance(42, (A,)), True)
+ self.assertIsInstance(42, A)
+ self.assertIsInstance(42, (A,))
self.assertTrue(issubclass(int, A))
self.assertTrue(issubclass(int, (A,)))
class B(A):
pass
B.register(str)
class C(str): pass
- self.assertEqual(isinstance("", A), True)
- self.assertEqual(isinstance("", (A,)), True)
+ self.assertIsInstance("", A)
+ self.assertIsInstance("", (A,))
self.assertTrue(issubclass(str, A))
self.assertTrue(issubclass(str, (A,)))
self.assertTrue(issubclass(C, A))
@@ -147,8 +185,8 @@ class TestABC(unittest.TestCase):
def test_register_non_class(self):
class A(metaclass=abc.ABCMeta):
pass
- self.assertRaisesRegexp(TypeError, "Can only register classes",
- A.register, 4)
+ self.assertRaisesRegex(TypeError, "Can only register classes",
+ A.register, 4)
def test_registration_transitiveness(self):
class A(metaclass=abc.ABCMeta):
@@ -186,8 +224,8 @@ class TestABC(unittest.TestCase):
pass
self.assertTrue(issubclass(MyInt, A))
self.assertTrue(issubclass(MyInt, (A,)))
- self.assertTrue(isinstance(42, A))
- self.assertTrue(isinstance(42, (A,)))
+ self.assertIsInstance(42, A)
+ self.assertIsInstance(42, (A,))
def test_all_new_methods_are_called(self):
class A(metaclass=abc.ABCMeta):
diff --git a/Lib/test/test_abstract_numbers.py b/Lib/test/test_abstract_numbers.py
index d0164c07b8..2a396cdad1 100644
--- a/Lib/test/test_abstract_numbers.py
+++ b/Lib/test/test_abstract_numbers.py
@@ -4,7 +4,6 @@ import math
import operator
import unittest
from numbers import Complex, Real, Rational, Integral
-from numbers import Number
from test import support
class TestNumbers(unittest.TestCase):
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
new file mode 100644
index 0000000000..03c95fade4
--- /dev/null
+++ b/Lib/test/test_argparse.py
@@ -0,0 +1,4431 @@
+# Author: Steven J. Bethard <steven.bethard@gmail.com>.
+
+import codecs
+import inspect
+import os
+import shutil
+import stat
+import sys
+import textwrap
+import tempfile
+import unittest
+import argparse
+
+from io import StringIO
+
+from test import support
+class StdIOBuffer(StringIO):
+ pass
+
+class TestCase(unittest.TestCase):
+
+ def assertEqual(self, obj1, obj2):
+ if obj1 != obj2:
+ print('')
+ print(repr(obj1))
+ print(repr(obj2))
+ print(obj1)
+ print(obj2)
+ super(TestCase, self).assertEqual(obj1, obj2)
+
+ def setUp(self):
+ # The tests assume that line wrapping occurs at 80 columns, but this
+ # behaviour can be overridden by setting the COLUMNS environment
+ # variable. To ensure that this assumption is true, unset COLUMNS.
+ env = support.EnvironmentVarGuard()
+ env.unset("COLUMNS")
+ self.addCleanup(env.__exit__)
+
+
+class TempDirMixin(object):
+
+ def setUp(self):
+ self.temp_dir = tempfile.mkdtemp()
+ self.old_dir = os.getcwd()
+ os.chdir(self.temp_dir)
+
+ def tearDown(self):
+ os.chdir(self.old_dir)
+ shutil.rmtree(self.temp_dir, True)
+
+ def create_readonly_file(self, filename):
+ file_path = os.path.join(self.temp_dir, filename)
+ with open(file_path, 'w') as file:
+ file.write(filename)
+ os.chmod(file_path, stat.S_IREAD)
+
+class Sig(object):
+
+ def __init__(self, *args, **kwargs):
+ self.args = args
+ self.kwargs = kwargs
+
+
+class NS(object):
+
+ def __init__(self, **kwargs):
+ self.__dict__.update(kwargs)
+
+ def __repr__(self):
+ sorted_items = sorted(self.__dict__.items())
+ kwarg_str = ', '.join(['%s=%r' % tup for tup in sorted_items])
+ return '%s(%s)' % (type(self).__name__, kwarg_str)
+
+ def __eq__(self, other):
+ return vars(self) == vars(other)
+
+ def __ne__(self, other):
+ return not (self == other)
+
+
+class ArgumentParserError(Exception):
+
+ def __init__(self, message, stdout=None, stderr=None, error_code=None):
+ Exception.__init__(self, message, stdout, stderr)
+ self.message = message
+ self.stdout = stdout
+ self.stderr = stderr
+ self.error_code = error_code
+
+
+def stderr_to_parser_error(parse_args, *args, **kwargs):
+ # if this is being called recursively and stderr or stdout is already being
+ # redirected, simply call the function and let the enclosing function
+ # catch the exception
+ if isinstance(sys.stderr, StdIOBuffer) or isinstance(sys.stdout, StdIOBuffer):
+ return parse_args(*args, **kwargs)
+
+ # if this is not being called recursively, redirect stderr and
+ # use it as the ArgumentParserError message
+ old_stdout = sys.stdout
+ old_stderr = sys.stderr
+ sys.stdout = StdIOBuffer()
+ sys.stderr = StdIOBuffer()
+ try:
+ try:
+ result = parse_args(*args, **kwargs)
+ for key in list(vars(result)):
+ if getattr(result, key) is sys.stdout:
+ setattr(result, key, old_stdout)
+ if getattr(result, key) is sys.stderr:
+ setattr(result, key, old_stderr)
+ return result
+ except SystemExit:
+ code = sys.exc_info()[1].code
+ stdout = sys.stdout.getvalue()
+ stderr = sys.stderr.getvalue()
+ raise ArgumentParserError("SystemExit", stdout, stderr, code)
+ finally:
+ sys.stdout = old_stdout
+ sys.stderr = old_stderr
+
+
+class ErrorRaisingArgumentParser(argparse.ArgumentParser):
+
+ def parse_args(self, *args, **kwargs):
+ parse_args = super(ErrorRaisingArgumentParser, self).parse_args
+ return stderr_to_parser_error(parse_args, *args, **kwargs)
+
+ def exit(self, *args, **kwargs):
+ exit = super(ErrorRaisingArgumentParser, self).exit
+ return stderr_to_parser_error(exit, *args, **kwargs)
+
+ def error(self, *args, **kwargs):
+ error = super(ErrorRaisingArgumentParser, self).error
+ return stderr_to_parser_error(error, *args, **kwargs)
+
+
+class ParserTesterMetaclass(type):
+ """Adds parser tests using the class attributes.
+
+ Classes of this type should specify the following attributes:
+
+ argument_signatures -- a list of Sig objects which specify
+ the signatures of Argument objects to be created
+ failures -- a list of args lists that should cause the parser
+ to fail
+ successes -- a list of (initial_args, options, remaining_args) tuples
+ where initial_args specifies the string args to be parsed,
+ options is a dict that should match the vars() of the options
+ parsed out of initial_args, and remaining_args should be any
+ remaining unparsed arguments
+ """
+
+ def __init__(cls, name, bases, bodydict):
+ if name == 'ParserTestCase':
+ return
+
+ # default parser signature is empty
+ if not hasattr(cls, 'parser_signature'):
+ cls.parser_signature = Sig()
+ if not hasattr(cls, 'parser_class'):
+ cls.parser_class = ErrorRaisingArgumentParser
+
+ # ---------------------------------------
+ # functions for adding optional arguments
+ # ---------------------------------------
+ def no_groups(parser, argument_signatures):
+ """Add all arguments directly to the parser"""
+ for sig in argument_signatures:
+ parser.add_argument(*sig.args, **sig.kwargs)
+
+ def one_group(parser, argument_signatures):
+ """Add all arguments under a single group in the parser"""
+ group = parser.add_argument_group('foo')
+ for sig in argument_signatures:
+ group.add_argument(*sig.args, **sig.kwargs)
+
+ def many_groups(parser, argument_signatures):
+ """Add each argument in its own group to the parser"""
+ for i, sig in enumerate(argument_signatures):
+ group = parser.add_argument_group('foo:%i' % i)
+ group.add_argument(*sig.args, **sig.kwargs)
+
+ # --------------------------
+ # functions for parsing args
+ # --------------------------
+ def listargs(parser, args):
+ """Parse the args by passing in a list"""
+ return parser.parse_args(args)
+
+ def sysargs(parser, args):
+ """Parse the args by defaulting to sys.argv"""
+ old_sys_argv = sys.argv
+ sys.argv = [old_sys_argv[0]] + args
+ try:
+ return parser.parse_args()
+ finally:
+ sys.argv = old_sys_argv
+
+ # class that holds the combination of one optional argument
+ # addition method and one arg parsing method
+ class AddTests(object):
+
+ def __init__(self, tester_cls, add_arguments, parse_args):
+ self._add_arguments = add_arguments
+ self._parse_args = parse_args
+
+ add_arguments_name = self._add_arguments.__name__
+ parse_args_name = self._parse_args.__name__
+ for test_func in [self.test_failures, self.test_successes]:
+ func_name = test_func.__name__
+ names = func_name, add_arguments_name, parse_args_name
+ test_name = '_'.join(names)
+
+ def wrapper(self, test_func=test_func):
+ test_func(self)
+ try:
+ wrapper.__name__ = test_name
+ except TypeError:
+ pass
+ setattr(tester_cls, test_name, wrapper)
+
+ def _get_parser(self, tester):
+ args = tester.parser_signature.args
+ kwargs = tester.parser_signature.kwargs
+ parser = tester.parser_class(*args, **kwargs)
+ self._add_arguments(parser, tester.argument_signatures)
+ return parser
+
+ def test_failures(self, tester):
+ parser = self._get_parser(tester)
+ for args_str in tester.failures:
+ args = args_str.split()
+ raises = tester.assertRaises
+ raises(ArgumentParserError, parser.parse_args, args)
+
+ def test_successes(self, tester):
+ parser = self._get_parser(tester)
+ for args, expected_ns in tester.successes:
+ if isinstance(args, str):
+ args = args.split()
+ result_ns = self._parse_args(parser, args)
+ tester.assertEqual(expected_ns, result_ns)
+
+ # add tests for each combination of an optionals adding method
+ # and an arg parsing method
+ for add_arguments in [no_groups, one_group, many_groups]:
+ for parse_args in [listargs, sysargs]:
+ AddTests(cls, add_arguments, parse_args)
+
+bases = TestCase,
+ParserTestCase = ParserTesterMetaclass('ParserTestCase', bases, {})
+
+# ===============
+# Optionals tests
+# ===============
+
+class TestOptionalsSingleDash(ParserTestCase):
+ """Test an Optional with a single-dash option string"""
+
+ argument_signatures = [Sig('-x')]
+ failures = ['-x', 'a', '--foo', '-x --foo', '-x -y']
+ successes = [
+ ('', NS(x=None)),
+ ('-x a', NS(x='a')),
+ ('-xa', NS(x='a')),
+ ('-x -1', NS(x='-1')),
+ ('-x-1', NS(x='-1')),
+ ]
+
+
+class TestOptionalsSingleDashCombined(ParserTestCase):
+ """Test an Optional with a single-dash option string"""
+
+ argument_signatures = [
+ Sig('-x', action='store_true'),
+ Sig('-yyy', action='store_const', const=42),
+ Sig('-z'),
+ ]
+ failures = ['a', '--foo', '-xa', '-x --foo', '-x -z', '-z -x',
+ '-yx', '-yz a', '-yyyx', '-yyyza', '-xyza']
+ successes = [
+ ('', NS(x=False, yyy=None, z=None)),
+ ('-x', NS(x=True, yyy=None, z=None)),
+ ('-za', NS(x=False, yyy=None, z='a')),
+ ('-z a', NS(x=False, yyy=None, z='a')),
+ ('-xza', NS(x=True, yyy=None, z='a')),
+ ('-xz a', NS(x=True, yyy=None, z='a')),
+ ('-x -za', NS(x=True, yyy=None, z='a')),
+ ('-x -z a', NS(x=True, yyy=None, z='a')),
+ ('-y', NS(x=False, yyy=42, z=None)),
+ ('-yyy', NS(x=False, yyy=42, z=None)),
+ ('-x -yyy -za', NS(x=True, yyy=42, z='a')),
+ ('-x -yyy -z a', NS(x=True, yyy=42, z='a')),
+ ]
+
+
+class TestOptionalsSingleDashLong(ParserTestCase):
+ """Test an Optional with a multi-character single-dash option string"""
+
+ argument_signatures = [Sig('-foo')]
+ failures = ['-foo', 'a', '--foo', '-foo --foo', '-foo -y', '-fooa']
+ successes = [
+ ('', NS(foo=None)),
+ ('-foo a', NS(foo='a')),
+ ('-foo -1', NS(foo='-1')),
+ ('-fo a', NS(foo='a')),
+ ('-f a', NS(foo='a')),
+ ]
+
+
+class TestOptionalsSingleDashSubsetAmbiguous(ParserTestCase):
+ """Test Optionals where option strings are subsets of each other"""
+
+ argument_signatures = [Sig('-f'), Sig('-foobar'), Sig('-foorab')]
+ failures = ['-f', '-foo', '-fo', '-foo b', '-foob', '-fooba', '-foora']
+ successes = [
+ ('', NS(f=None, foobar=None, foorab=None)),
+ ('-f a', NS(f='a', foobar=None, foorab=None)),
+ ('-fa', NS(f='a', foobar=None, foorab=None)),
+ ('-foa', NS(f='oa', foobar=None, foorab=None)),
+ ('-fooa', NS(f='ooa', foobar=None, foorab=None)),
+ ('-foobar a', NS(f=None, foobar='a', foorab=None)),
+ ('-foorab a', NS(f=None, foobar=None, foorab='a')),
+ ]
+
+
+class TestOptionalsSingleDashAmbiguous(ParserTestCase):
+ """Test Optionals that partially match but are not subsets"""
+
+ argument_signatures = [Sig('-foobar'), Sig('-foorab')]
+ failures = ['-f', '-f a', '-fa', '-foa', '-foo', '-fo', '-foo b']
+ successes = [
+ ('', NS(foobar=None, foorab=None)),
+ ('-foob a', NS(foobar='a', foorab=None)),
+ ('-foor a', NS(foobar=None, foorab='a')),
+ ('-fooba a', NS(foobar='a', foorab=None)),
+ ('-foora a', NS(foobar=None, foorab='a')),
+ ('-foobar a', NS(foobar='a', foorab=None)),
+ ('-foorab a', NS(foobar=None, foorab='a')),
+ ]
+
+
+class TestOptionalsNumeric(ParserTestCase):
+ """Test an Optional with a short opt string"""
+
+ argument_signatures = [Sig('-1', dest='one')]
+ failures = ['-1', 'a', '-1 --foo', '-1 -y', '-1 -1', '-1 -2']
+ successes = [
+ ('', NS(one=None)),
+ ('-1 a', NS(one='a')),
+ ('-1a', NS(one='a')),
+ ('-1-2', NS(one='-2')),
+ ]
+
+
+class TestOptionalsDoubleDash(ParserTestCase):
+ """Test an Optional with a double-dash option string"""
+
+ argument_signatures = [Sig('--foo')]
+ failures = ['--foo', '-f', '-f a', 'a', '--foo -x', '--foo --bar']
+ successes = [
+ ('', NS(foo=None)),
+ ('--foo a', NS(foo='a')),
+ ('--foo=a', NS(foo='a')),
+ ('--foo -2.5', NS(foo='-2.5')),
+ ('--foo=-2.5', NS(foo='-2.5')),
+ ]
+
+
+class TestOptionalsDoubleDashPartialMatch(ParserTestCase):
+ """Tests partial matching with a double-dash option string"""
+
+ argument_signatures = [
+ Sig('--badger', action='store_true'),
+ Sig('--bat'),
+ ]
+ failures = ['--bar', '--b', '--ba', '--b=2', '--ba=4', '--badge 5']
+ successes = [
+ ('', NS(badger=False, bat=None)),
+ ('--bat X', NS(badger=False, bat='X')),
+ ('--bad', NS(badger=True, bat=None)),
+ ('--badg', NS(badger=True, bat=None)),
+ ('--badge', NS(badger=True, bat=None)),
+ ('--badger', NS(badger=True, bat=None)),
+ ]
+
+
+class TestOptionalsDoubleDashPrefixMatch(ParserTestCase):
+ """Tests when one double-dash option string is a prefix of another"""
+
+ argument_signatures = [
+ Sig('--badger', action='store_true'),
+ Sig('--ba'),
+ ]
+ failures = ['--bar', '--b', '--ba', '--b=2', '--badge 5']
+ successes = [
+ ('', NS(badger=False, ba=None)),
+ ('--ba X', NS(badger=False, ba='X')),
+ ('--ba=X', NS(badger=False, ba='X')),
+ ('--bad', NS(badger=True, ba=None)),
+ ('--badg', NS(badger=True, ba=None)),
+ ('--badge', NS(badger=True, ba=None)),
+ ('--badger', NS(badger=True, ba=None)),
+ ]
+
+
+class TestOptionalsSingleDoubleDash(ParserTestCase):
+ """Test an Optional with single- and double-dash option strings"""
+
+ argument_signatures = [
+ Sig('-f', action='store_true'),
+ Sig('--bar'),
+ Sig('-baz', action='store_const', const=42),
+ ]
+ failures = ['--bar', '-fbar', '-fbaz', '-bazf', '-b B', 'B']
+ successes = [
+ ('', NS(f=False, bar=None, baz=None)),
+ ('-f', NS(f=True, bar=None, baz=None)),
+ ('--ba B', NS(f=False, bar='B', baz=None)),
+ ('-f --bar B', NS(f=True, bar='B', baz=None)),
+ ('-f -b', NS(f=True, bar=None, baz=42)),
+ ('-ba -f', NS(f=True, bar=None, baz=42)),
+ ]
+
+
+class TestOptionalsAlternatePrefixChars(ParserTestCase):
+ """Test an Optional with option strings with custom prefixes"""
+
+ parser_signature = Sig(prefix_chars='+:/', add_help=False)
+ argument_signatures = [
+ Sig('+f', action='store_true'),
+ Sig('::bar'),
+ Sig('/baz', action='store_const', const=42),
+ ]
+ failures = ['--bar', '-fbar', '-b B', 'B', '-f', '--bar B', '-baz', '-h', '--help', '+h', '::help', '/help']
+ successes = [
+ ('', NS(f=False, bar=None, baz=None)),
+ ('+f', NS(f=True, bar=None, baz=None)),
+ ('::ba B', NS(f=False, bar='B', baz=None)),
+ ('+f ::bar B', NS(f=True, bar='B', baz=None)),
+ ('+f /b', NS(f=True, bar=None, baz=42)),
+ ('/ba +f', NS(f=True, bar=None, baz=42)),
+ ]
+
+
+class TestOptionalsAlternatePrefixCharsAddedHelp(ParserTestCase):
+ """When ``-`` not in prefix_chars, default operators created for help
+ should use the prefix_chars in use rather than - or --
+ http://bugs.python.org/issue9444"""
+
+ parser_signature = Sig(prefix_chars='+:/', add_help=True)
+ argument_signatures = [
+ Sig('+f', action='store_true'),
+ Sig('::bar'),
+ Sig('/baz', action='store_const', const=42),
+ ]
+ failures = ['--bar', '-fbar', '-b B', 'B', '-f', '--bar B', '-baz']
+ successes = [
+ ('', NS(f=False, bar=None, baz=None)),
+ ('+f', NS(f=True, bar=None, baz=None)),
+ ('::ba B', NS(f=False, bar='B', baz=None)),
+ ('+f ::bar B', NS(f=True, bar='B', baz=None)),
+ ('+f /b', NS(f=True, bar=None, baz=42)),
+ ('/ba +f', NS(f=True, bar=None, baz=42))
+ ]
+
+
+class TestOptionalsAlternatePrefixCharsMultipleShortArgs(ParserTestCase):
+ """Verify that Optionals must be called with their defined prefixes"""
+
+ parser_signature = Sig(prefix_chars='+-', add_help=False)
+ argument_signatures = [
+ Sig('-x', action='store_true'),
+ Sig('+y', action='store_true'),
+ Sig('+z', action='store_true'),
+ ]
+ failures = ['-w',
+ '-xyz',
+ '+x',
+ '-y',
+ '+xyz',
+ ]
+ successes = [
+ ('', NS(x=False, y=False, z=False)),
+ ('-x', NS(x=True, y=False, z=False)),
+ ('+y -x', NS(x=True, y=True, z=False)),
+ ('+yz -x', NS(x=True, y=True, z=True)),
+ ]
+
+
+class TestOptionalsShortLong(ParserTestCase):
+ """Test a combination of single- and double-dash option strings"""
+
+ argument_signatures = [
+ Sig('-v', '--verbose', '-n', '--noisy', action='store_true'),
+ ]
+ failures = ['--x --verbose', '-N', 'a', '-v x']
+ successes = [
+ ('', NS(verbose=False)),
+ ('-v', NS(verbose=True)),
+ ('--verbose', NS(verbose=True)),
+ ('-n', NS(verbose=True)),
+ ('--noisy', NS(verbose=True)),
+ ]
+
+
+class TestOptionalsDest(ParserTestCase):
+ """Tests various means of setting destination"""
+
+ argument_signatures = [Sig('--foo-bar'), Sig('--baz', dest='zabbaz')]
+ failures = ['a']
+ successes = [
+ ('--foo-bar f', NS(foo_bar='f', zabbaz=None)),
+ ('--baz g', NS(foo_bar=None, zabbaz='g')),
+ ('--foo-bar h --baz i', NS(foo_bar='h', zabbaz='i')),
+ ('--baz j --foo-bar k', NS(foo_bar='k', zabbaz='j')),
+ ]
+
+
+class TestOptionalsDefault(ParserTestCase):
+ """Tests specifying a default for an Optional"""
+
+ argument_signatures = [Sig('-x'), Sig('-y', default=42)]
+ failures = ['a']
+ successes = [
+ ('', NS(x=None, y=42)),
+ ('-xx', NS(x='x', y=42)),
+ ('-yy', NS(x=None, y='y')),
+ ]
+
+
+class TestOptionalsNargsDefault(ParserTestCase):
+ """Tests not specifying the number of args for an Optional"""
+
+ argument_signatures = [Sig('-x')]
+ failures = ['a', '-x']
+ successes = [
+ ('', NS(x=None)),
+ ('-x a', NS(x='a')),
+ ]
+
+
+class TestOptionalsNargs1(ParserTestCase):
+ """Tests specifying the 1 arg for an Optional"""
+
+ argument_signatures = [Sig('-x', nargs=1)]
+ failures = ['a', '-x']
+ successes = [
+ ('', NS(x=None)),
+ ('-x a', NS(x=['a'])),
+ ]
+
+
+class TestOptionalsNargs3(ParserTestCase):
+ """Tests specifying the 3 args for an Optional"""
+
+ argument_signatures = [Sig('-x', nargs=3)]
+ failures = ['a', '-x', '-x a', '-x a b', 'a -x', 'a -x b']
+ successes = [
+ ('', NS(x=None)),
+ ('-x a b c', NS(x=['a', 'b', 'c'])),
+ ]
+
+
+class TestOptionalsNargsOptional(ParserTestCase):
+ """Tests specifying an Optional arg for an Optional"""
+
+ argument_signatures = [
+ Sig('-w', nargs='?'),
+ Sig('-x', nargs='?', const=42),
+ Sig('-y', nargs='?', default='spam'),
+ Sig('-z', nargs='?', type=int, const='42', default='84'),
+ ]
+ failures = ['2']
+ successes = [
+ ('', NS(w=None, x=None, y='spam', z=84)),
+ ('-w', NS(w=None, x=None, y='spam', z=84)),
+ ('-w 2', NS(w='2', x=None, y='spam', z=84)),
+ ('-x', NS(w=None, x=42, y='spam', z=84)),
+ ('-x 2', NS(w=None, x='2', y='spam', z=84)),
+ ('-y', NS(w=None, x=None, y=None, z=84)),
+ ('-y 2', NS(w=None, x=None, y='2', z=84)),
+ ('-z', NS(w=None, x=None, y='spam', z=42)),
+ ('-z 2', NS(w=None, x=None, y='spam', z=2)),
+ ]
+
+
+class TestOptionalsNargsZeroOrMore(ParserTestCase):
+ """Tests specifying an args for an Optional that accepts zero or more"""
+
+ argument_signatures = [
+ Sig('-x', nargs='*'),
+ Sig('-y', nargs='*', default='spam'),
+ ]
+ failures = ['a']
+ successes = [
+ ('', NS(x=None, y='spam')),
+ ('-x', NS(x=[], y='spam')),
+ ('-x a', NS(x=['a'], y='spam')),
+ ('-x a b', NS(x=['a', 'b'], y='spam')),
+ ('-y', NS(x=None, y=[])),
+ ('-y a', NS(x=None, y=['a'])),
+ ('-y a b', NS(x=None, y=['a', 'b'])),
+ ]
+
+
+class TestOptionalsNargsOneOrMore(ParserTestCase):
+ """Tests specifying an args for an Optional that accepts one or more"""
+
+ argument_signatures = [
+ Sig('-x', nargs='+'),
+ Sig('-y', nargs='+', default='spam'),
+ ]
+ failures = ['a', '-x', '-y', 'a -x', 'a -y b']
+ successes = [
+ ('', NS(x=None, y='spam')),
+ ('-x a', NS(x=['a'], y='spam')),
+ ('-x a b', NS(x=['a', 'b'], y='spam')),
+ ('-y a', NS(x=None, y=['a'])),
+ ('-y a b', NS(x=None, y=['a', 'b'])),
+ ]
+
+
+class TestOptionalsChoices(ParserTestCase):
+ """Tests specifying the choices for an Optional"""
+
+ argument_signatures = [
+ Sig('-f', choices='abc'),
+ Sig('-g', type=int, choices=range(5))]
+ failures = ['a', '-f d', '-fad', '-ga', '-g 6']
+ successes = [
+ ('', NS(f=None, g=None)),
+ ('-f a', NS(f='a', g=None)),
+ ('-f c', NS(f='c', g=None)),
+ ('-g 0', NS(f=None, g=0)),
+ ('-g 03', NS(f=None, g=3)),
+ ('-fb -g4', NS(f='b', g=4)),
+ ]
+
+
+class TestOptionalsRequired(ParserTestCase):
+ """Tests the an optional action that is required"""
+
+ argument_signatures = [
+ Sig('-x', type=int, required=True),
+ ]
+ failures = ['a', '']
+ successes = [
+ ('-x 1', NS(x=1)),
+ ('-x42', NS(x=42)),
+ ]
+
+
+class TestOptionalsActionStore(ParserTestCase):
+ """Tests the store action for an Optional"""
+
+ argument_signatures = [Sig('-x', action='store')]
+ failures = ['a', 'a -x']
+ successes = [
+ ('', NS(x=None)),
+ ('-xfoo', NS(x='foo')),
+ ]
+
+
+class TestOptionalsActionStoreConst(ParserTestCase):
+ """Tests the store_const action for an Optional"""
+
+ argument_signatures = [Sig('-y', action='store_const', const=object)]
+ failures = ['a']
+ successes = [
+ ('', NS(y=None)),
+ ('-y', NS(y=object)),
+ ]
+
+
+class TestOptionalsActionStoreFalse(ParserTestCase):
+ """Tests the store_false action for an Optional"""
+
+ argument_signatures = [Sig('-z', action='store_false')]
+ failures = ['a', '-za', '-z a']
+ successes = [
+ ('', NS(z=True)),
+ ('-z', NS(z=False)),
+ ]
+
+
+class TestOptionalsActionStoreTrue(ParserTestCase):
+ """Tests the store_true action for an Optional"""
+
+ argument_signatures = [Sig('--apple', action='store_true')]
+ failures = ['a', '--apple=b', '--apple b']
+ successes = [
+ ('', NS(apple=False)),
+ ('--apple', NS(apple=True)),
+ ]
+
+
+class TestOptionalsActionAppend(ParserTestCase):
+ """Tests the append action for an Optional"""
+
+ argument_signatures = [Sig('--baz', action='append')]
+ failures = ['a', '--baz', 'a --baz', '--baz a b']
+ successes = [
+ ('', NS(baz=None)),
+ ('--baz a', NS(baz=['a'])),
+ ('--baz a --baz b', NS(baz=['a', 'b'])),
+ ]
+
+
+class TestOptionalsActionAppendWithDefault(ParserTestCase):
+ """Tests the append action for an Optional"""
+
+ argument_signatures = [Sig('--baz', action='append', default=['X'])]
+ failures = ['a', '--baz', 'a --baz', '--baz a b']
+ successes = [
+ ('', NS(baz=['X'])),
+ ('--baz a', NS(baz=['X', 'a'])),
+ ('--baz a --baz b', NS(baz=['X', 'a', 'b'])),
+ ]
+
+
+class TestOptionalsActionAppendConst(ParserTestCase):
+ """Tests the append_const action for an Optional"""
+
+ argument_signatures = [
+ Sig('-b', action='append_const', const=Exception),
+ Sig('-c', action='append', dest='b'),
+ ]
+ failures = ['a', '-c', 'a -c', '-bx', '-b x']
+ successes = [
+ ('', NS(b=None)),
+ ('-b', NS(b=[Exception])),
+ ('-b -cx -b -cyz', NS(b=[Exception, 'x', Exception, 'yz'])),
+ ]
+
+
+class TestOptionalsActionAppendConstWithDefault(ParserTestCase):
+ """Tests the append_const action for an Optional"""
+
+ argument_signatures = [
+ Sig('-b', action='append_const', const=Exception, default=['X']),
+ Sig('-c', action='append', dest='b'),
+ ]
+ failures = ['a', '-c', 'a -c', '-bx', '-b x']
+ successes = [
+ ('', NS(b=['X'])),
+ ('-b', NS(b=['X', Exception])),
+ ('-b -cx -b -cyz', NS(b=['X', Exception, 'x', Exception, 'yz'])),
+ ]
+
+
+class TestOptionalsActionCount(ParserTestCase):
+ """Tests the count action for an Optional"""
+
+ argument_signatures = [Sig('-x', action='count')]
+ failures = ['a', '-x a', '-x b', '-x a -x b']
+ successes = [
+ ('', NS(x=None)),
+ ('-x', NS(x=1)),
+ ]
+
+
+# ================
+# Positional tests
+# ================
+
+class TestPositionalsNargsNone(ParserTestCase):
+ """Test a Positional that doesn't specify nargs"""
+
+ argument_signatures = [Sig('foo')]
+ failures = ['', '-x', 'a b']
+ successes = [
+ ('a', NS(foo='a')),
+ ]
+
+
+class TestPositionalsNargs1(ParserTestCase):
+ """Test a Positional that specifies an nargs of 1"""
+
+ argument_signatures = [Sig('foo', nargs=1)]
+ failures = ['', '-x', 'a b']
+ successes = [
+ ('a', NS(foo=['a'])),
+ ]
+
+
+class TestPositionalsNargs2(ParserTestCase):
+ """Test a Positional that specifies an nargs of 2"""
+
+ argument_signatures = [Sig('foo', nargs=2)]
+ failures = ['', 'a', '-x', 'a b c']
+ successes = [
+ ('a b', NS(foo=['a', 'b'])),
+ ]
+
+
+class TestPositionalsNargsZeroOrMore(ParserTestCase):
+ """Test a Positional that specifies unlimited nargs"""
+
+ argument_signatures = [Sig('foo', nargs='*')]
+ failures = ['-x']
+ successes = [
+ ('', NS(foo=[])),
+ ('a', NS(foo=['a'])),
+ ('a b', NS(foo=['a', 'b'])),
+ ]
+
+
+class TestPositionalsNargsZeroOrMoreDefault(ParserTestCase):
+ """Test a Positional that specifies unlimited nargs and a default"""
+
+ argument_signatures = [Sig('foo', nargs='*', default='bar')]
+ failures = ['-x']
+ successes = [
+ ('', NS(foo='bar')),
+ ('a', NS(foo=['a'])),
+ ('a b', NS(foo=['a', 'b'])),
+ ]
+
+
+class TestPositionalsNargsOneOrMore(ParserTestCase):
+ """Test a Positional that specifies one or more nargs"""
+
+ argument_signatures = [Sig('foo', nargs='+')]
+ failures = ['', '-x']
+ successes = [
+ ('a', NS(foo=['a'])),
+ ('a b', NS(foo=['a', 'b'])),
+ ]
+
+
+class TestPositionalsNargsOptional(ParserTestCase):
+ """Tests an Optional Positional"""
+
+ argument_signatures = [Sig('foo', nargs='?')]
+ failures = ['-x', 'a b']
+ successes = [
+ ('', NS(foo=None)),
+ ('a', NS(foo='a')),
+ ]
+
+
+class TestPositionalsNargsOptionalDefault(ParserTestCase):
+ """Tests an Optional Positional with a default value"""
+
+ argument_signatures = [Sig('foo', nargs='?', default=42)]
+ failures = ['-x', 'a b']
+ successes = [
+ ('', NS(foo=42)),
+ ('a', NS(foo='a')),
+ ]
+
+
+class TestPositionalsNargsOptionalConvertedDefault(ParserTestCase):
+ """Tests an Optional Positional with a default value
+ that needs to be converted to the appropriate type.
+ """
+
+ argument_signatures = [
+ Sig('foo', nargs='?', type=int, default='42'),
+ ]
+ failures = ['-x', 'a b', '1 2']
+ successes = [
+ ('', NS(foo=42)),
+ ('1', NS(foo=1)),
+ ]
+
+
+class TestPositionalsNargsNoneNone(ParserTestCase):
+ """Test two Positionals that don't specify nargs"""
+
+ argument_signatures = [Sig('foo'), Sig('bar')]
+ failures = ['', '-x', 'a', 'a b c']
+ successes = [
+ ('a b', NS(foo='a', bar='b')),
+ ]
+
+
+class TestPositionalsNargsNone1(ParserTestCase):
+ """Test a Positional with no nargs followed by one with 1"""
+
+ argument_signatures = [Sig('foo'), Sig('bar', nargs=1)]
+ failures = ['', '--foo', 'a', 'a b c']
+ successes = [
+ ('a b', NS(foo='a', bar=['b'])),
+ ]
+
+
+class TestPositionalsNargs2None(ParserTestCase):
+ """Test a Positional with 2 nargs followed by one with none"""
+
+ argument_signatures = [Sig('foo', nargs=2), Sig('bar')]
+ failures = ['', '--foo', 'a', 'a b', 'a b c d']
+ successes = [
+ ('a b c', NS(foo=['a', 'b'], bar='c')),
+ ]
+
+
+class TestPositionalsNargsNoneZeroOrMore(ParserTestCase):
+ """Test a Positional with no nargs followed by one with unlimited"""
+
+ argument_signatures = [Sig('foo'), Sig('bar', nargs='*')]
+ failures = ['', '--foo']
+ successes = [
+ ('a', NS(foo='a', bar=[])),
+ ('a b', NS(foo='a', bar=['b'])),
+ ('a b c', NS(foo='a', bar=['b', 'c'])),
+ ]
+
+
+class TestPositionalsNargsNoneOneOrMore(ParserTestCase):
+ """Test a Positional with no nargs followed by one with one or more"""
+
+ argument_signatures = [Sig('foo'), Sig('bar', nargs='+')]
+ failures = ['', '--foo', 'a']
+ successes = [
+ ('a b', NS(foo='a', bar=['b'])),
+ ('a b c', NS(foo='a', bar=['b', 'c'])),
+ ]
+
+
+class TestPositionalsNargsNoneOptional(ParserTestCase):
+ """Test a Positional with no nargs followed by one with an Optional"""
+
+ argument_signatures = [Sig('foo'), Sig('bar', nargs='?')]
+ failures = ['', '--foo', 'a b c']
+ successes = [
+ ('a', NS(foo='a', bar=None)),
+ ('a b', NS(foo='a', bar='b')),
+ ]
+
+
+class TestPositionalsNargsZeroOrMoreNone(ParserTestCase):
+ """Test a Positional with unlimited nargs followed by one with none"""
+
+ argument_signatures = [Sig('foo', nargs='*'), Sig('bar')]
+ failures = ['', '--foo']
+ successes = [
+ ('a', NS(foo=[], bar='a')),
+ ('a b', NS(foo=['a'], bar='b')),
+ ('a b c', NS(foo=['a', 'b'], bar='c')),
+ ]
+
+
+class TestPositionalsNargsOneOrMoreNone(ParserTestCase):
+ """Test a Positional with one or more nargs followed by one with none"""
+
+ argument_signatures = [Sig('foo', nargs='+'), Sig('bar')]
+ failures = ['', '--foo', 'a']
+ successes = [
+ ('a b', NS(foo=['a'], bar='b')),
+ ('a b c', NS(foo=['a', 'b'], bar='c')),
+ ]
+
+
+class TestPositionalsNargsOptionalNone(ParserTestCase):
+ """Test a Positional with an Optional nargs followed by one with none"""
+
+ argument_signatures = [Sig('foo', nargs='?', default=42), Sig('bar')]
+ failures = ['', '--foo', 'a b c']
+ successes = [
+ ('a', NS(foo=42, bar='a')),
+ ('a b', NS(foo='a', bar='b')),
+ ]
+
+
+class TestPositionalsNargs2ZeroOrMore(ParserTestCase):
+ """Test a Positional with 2 nargs followed by one with unlimited"""
+
+ argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='*')]
+ failures = ['', '--foo', 'a']
+ successes = [
+ ('a b', NS(foo=['a', 'b'], bar=[])),
+ ('a b c', NS(foo=['a', 'b'], bar=['c'])),
+ ]
+
+
+class TestPositionalsNargs2OneOrMore(ParserTestCase):
+ """Test a Positional with 2 nargs followed by one with one or more"""
+
+ argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='+')]
+ failures = ['', '--foo', 'a', 'a b']
+ successes = [
+ ('a b c', NS(foo=['a', 'b'], bar=['c'])),
+ ]
+
+
+class TestPositionalsNargs2Optional(ParserTestCase):
+ """Test a Positional with 2 nargs followed by one optional"""
+
+ argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='?')]
+ failures = ['', '--foo', 'a', 'a b c d']
+ successes = [
+ ('a b', NS(foo=['a', 'b'], bar=None)),
+ ('a b c', NS(foo=['a', 'b'], bar='c')),
+ ]
+
+
+class TestPositionalsNargsZeroOrMore1(ParserTestCase):
+ """Test a Positional with unlimited nargs followed by one with 1"""
+
+ argument_signatures = [Sig('foo', nargs='*'), Sig('bar', nargs=1)]
+ failures = ['', '--foo', ]
+ successes = [
+ ('a', NS(foo=[], bar=['a'])),
+ ('a b', NS(foo=['a'], bar=['b'])),
+ ('a b c', NS(foo=['a', 'b'], bar=['c'])),
+ ]
+
+
+class TestPositionalsNargsOneOrMore1(ParserTestCase):
+ """Test a Positional with one or more nargs followed by one with 1"""
+
+ argument_signatures = [Sig('foo', nargs='+'), Sig('bar', nargs=1)]
+ failures = ['', '--foo', 'a']
+ successes = [
+ ('a b', NS(foo=['a'], bar=['b'])),
+ ('a b c', NS(foo=['a', 'b'], bar=['c'])),
+ ]
+
+
+class TestPositionalsNargsOptional1(ParserTestCase):
+ """Test a Positional with an Optional nargs followed by one with 1"""
+
+ argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs=1)]
+ failures = ['', '--foo', 'a b c']
+ successes = [
+ ('a', NS(foo=None, bar=['a'])),
+ ('a b', NS(foo='a', bar=['b'])),
+ ]
+
+
+class TestPositionalsNargsNoneZeroOrMore1(ParserTestCase):
+ """Test three Positionals: no nargs, unlimited nargs and 1 nargs"""
+
+ argument_signatures = [
+ Sig('foo'),
+ Sig('bar', nargs='*'),
+ Sig('baz', nargs=1),
+ ]
+ failures = ['', '--foo', 'a']
+ successes = [
+ ('a b', NS(foo='a', bar=[], baz=['b'])),
+ ('a b c', NS(foo='a', bar=['b'], baz=['c'])),
+ ]
+
+
+class TestPositionalsNargsNoneOneOrMore1(ParserTestCase):
+ """Test three Positionals: no nargs, one or more nargs and 1 nargs"""
+
+ argument_signatures = [
+ Sig('foo'),
+ Sig('bar', nargs='+'),
+ Sig('baz', nargs=1),
+ ]
+ failures = ['', '--foo', 'a', 'b']
+ successes = [
+ ('a b c', NS(foo='a', bar=['b'], baz=['c'])),
+ ('a b c d', NS(foo='a', bar=['b', 'c'], baz=['d'])),
+ ]
+
+
+class TestPositionalsNargsNoneOptional1(ParserTestCase):
+ """Test three Positionals: no nargs, optional narg and 1 nargs"""
+
+ argument_signatures = [
+ Sig('foo'),
+ Sig('bar', nargs='?', default=0.625),
+ Sig('baz', nargs=1),
+ ]
+ failures = ['', '--foo', 'a']
+ successes = [
+ ('a b', NS(foo='a', bar=0.625, baz=['b'])),
+ ('a b c', NS(foo='a', bar='b', baz=['c'])),
+ ]
+
+
+class TestPositionalsNargsOptionalOptional(ParserTestCase):
+ """Test two optional nargs"""
+
+ argument_signatures = [
+ Sig('foo', nargs='?'),
+ Sig('bar', nargs='?', default=42),
+ ]
+ failures = ['--foo', 'a b c']
+ successes = [
+ ('', NS(foo=None, bar=42)),
+ ('a', NS(foo='a', bar=42)),
+ ('a b', NS(foo='a', bar='b')),
+ ]
+
+
+class TestPositionalsNargsOptionalZeroOrMore(ParserTestCase):
+ """Test an Optional narg followed by unlimited nargs"""
+
+ argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs='*')]
+ failures = ['--foo']
+ successes = [
+ ('', NS(foo=None, bar=[])),
+ ('a', NS(foo='a', bar=[])),
+ ('a b', NS(foo='a', bar=['b'])),
+ ('a b c', NS(foo='a', bar=['b', 'c'])),
+ ]
+
+
+class TestPositionalsNargsOptionalOneOrMore(ParserTestCase):
+ """Test an Optional narg followed by one or more nargs"""
+
+ argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs='+')]
+ failures = ['', '--foo']
+ successes = [
+ ('a', NS(foo=None, bar=['a'])),
+ ('a b', NS(foo='a', bar=['b'])),
+ ('a b c', NS(foo='a', bar=['b', 'c'])),
+ ]
+
+
+class TestPositionalsChoicesString(ParserTestCase):
+ """Test a set of single-character choices"""
+
+ argument_signatures = [Sig('spam', choices=set('abcdefg'))]
+ failures = ['', '--foo', 'h', '42', 'ef']
+ successes = [
+ ('a', NS(spam='a')),
+ ('g', NS(spam='g')),
+ ]
+
+
+class TestPositionalsChoicesInt(ParserTestCase):
+ """Test a set of integer choices"""
+
+ argument_signatures = [Sig('spam', type=int, choices=range(20))]
+ failures = ['', '--foo', 'h', '42', 'ef']
+ successes = [
+ ('4', NS(spam=4)),
+ ('15', NS(spam=15)),
+ ]
+
+
+class TestPositionalsActionAppend(ParserTestCase):
+ """Test the 'append' action"""
+
+ argument_signatures = [
+ Sig('spam', action='append'),
+ Sig('spam', action='append', nargs=2),
+ ]
+ failures = ['', '--foo', 'a', 'a b', 'a b c d']
+ successes = [
+ ('a b c', NS(spam=['a', ['b', 'c']])),
+ ]
+
+# ========================================
+# Combined optionals and positionals tests
+# ========================================
+
+class TestOptionalsNumericAndPositionals(ParserTestCase):
+ """Tests negative number args when numeric options are present"""
+
+ argument_signatures = [
+ Sig('x', nargs='?'),
+ Sig('-4', dest='y', action='store_true'),
+ ]
+ failures = ['-2', '-315']
+ successes = [
+ ('', NS(x=None, y=False)),
+ ('a', NS(x='a', y=False)),
+ ('-4', NS(x=None, y=True)),
+ ('-4 a', NS(x='a', y=True)),
+ ]
+
+
+class TestOptionalsAlmostNumericAndPositionals(ParserTestCase):
+ """Tests negative number args when almost numeric options are present"""
+
+ argument_signatures = [
+ Sig('x', nargs='?'),
+ Sig('-k4', dest='y', action='store_true'),
+ ]
+ failures = ['-k3']
+ successes = [
+ ('', NS(x=None, y=False)),
+ ('-2', NS(x='-2', y=False)),
+ ('a', NS(x='a', y=False)),
+ ('-k4', NS(x=None, y=True)),
+ ('-k4 a', NS(x='a', y=True)),
+ ]
+
+
+class TestEmptyAndSpaceContainingArguments(ParserTestCase):
+
+ argument_signatures = [
+ Sig('x', nargs='?'),
+ Sig('-y', '--yyy', dest='y'),
+ ]
+ failures = ['-y']
+ successes = [
+ ([''], NS(x='', y=None)),
+ (['a badger'], NS(x='a badger', y=None)),
+ (['-a badger'], NS(x='-a badger', y=None)),
+ (['-y', ''], NS(x=None, y='')),
+ (['-y', 'a badger'], NS(x=None, y='a badger')),
+ (['-y', '-a badger'], NS(x=None, y='-a badger')),
+ (['--yyy=a badger'], NS(x=None, y='a badger')),
+ (['--yyy=-a badger'], NS(x=None, y='-a badger')),
+ ]
+
+
+class TestPrefixCharacterOnlyArguments(ParserTestCase):
+
+ parser_signature = Sig(prefix_chars='-+')
+ argument_signatures = [
+ Sig('-', dest='x', nargs='?', const='badger'),
+ Sig('+', dest='y', type=int, default=42),
+ Sig('-+-', dest='z', action='store_true'),
+ ]
+ failures = ['-y', '+ -']
+ successes = [
+ ('', NS(x=None, y=42, z=False)),
+ ('-', NS(x='badger', y=42, z=False)),
+ ('- X', NS(x='X', y=42, z=False)),
+ ('+ -3', NS(x=None, y=-3, z=False)),
+ ('-+-', NS(x=None, y=42, z=True)),
+ ('- ===', NS(x='===', y=42, z=False)),
+ ]
+
+
+class TestNargsZeroOrMore(ParserTestCase):
+ """Tests specifying an args for an Optional that accepts zero or more"""
+
+ argument_signatures = [Sig('-x', nargs='*'), Sig('y', nargs='*')]
+ failures = []
+ successes = [
+ ('', NS(x=None, y=[])),
+ ('-x', NS(x=[], y=[])),
+ ('-x a', NS(x=['a'], y=[])),
+ ('-x a -- b', NS(x=['a'], y=['b'])),
+ ('a', NS(x=None, y=['a'])),
+ ('a -x', NS(x=[], y=['a'])),
+ ('a -x b', NS(x=['b'], y=['a'])),
+ ]
+
+
+class TestNargsRemainder(ParserTestCase):
+ """Tests specifying a positional with nargs=REMAINDER"""
+
+ argument_signatures = [Sig('x'), Sig('y', nargs='...'), Sig('-z')]
+ failures = ['', '-z', '-z Z']
+ successes = [
+ ('X', NS(x='X', y=[], z=None)),
+ ('-z Z X', NS(x='X', y=[], z='Z')),
+ ('X A B -z Z', NS(x='X', y=['A', 'B', '-z', 'Z'], z=None)),
+ ('X Y --foo', NS(x='X', y=['Y', '--foo'], z=None)),
+ ]
+
+
+class TestOptionLike(ParserTestCase):
+ """Tests options that may or may not be arguments"""
+
+ argument_signatures = [
+ Sig('-x', type=float),
+ Sig('-3', type=float, dest='y'),
+ Sig('z', nargs='*'),
+ ]
+ failures = ['-x', '-y2.5', '-xa', '-x -a',
+ '-x -3', '-x -3.5', '-3 -3.5',
+ '-x -2.5', '-x -2.5 a', '-3 -.5',
+ 'a x -1', '-x -1 a', '-3 -1 a']
+ successes = [
+ ('', NS(x=None, y=None, z=[])),
+ ('-x 2.5', NS(x=2.5, y=None, z=[])),
+ ('-x 2.5 a', NS(x=2.5, y=None, z=['a'])),
+ ('-3.5', NS(x=None, y=0.5, z=[])),
+ ('-3-.5', NS(x=None, y=-0.5, z=[])),
+ ('-3 .5', NS(x=None, y=0.5, z=[])),
+ ('a -3.5', NS(x=None, y=0.5, z=['a'])),
+ ('a', NS(x=None, y=None, z=['a'])),
+ ('a -x 1', NS(x=1.0, y=None, z=['a'])),
+ ('-x 1 a', NS(x=1.0, y=None, z=['a'])),
+ ('-3 1 a', NS(x=None, y=1.0, z=['a'])),
+ ]
+
+
+class TestDefaultSuppress(ParserTestCase):
+ """Test actions with suppressed defaults"""
+
+ argument_signatures = [
+ Sig('foo', nargs='?', default=argparse.SUPPRESS),
+ Sig('bar', nargs='*', default=argparse.SUPPRESS),
+ Sig('--baz', action='store_true', default=argparse.SUPPRESS),
+ ]
+ failures = ['-x']
+ successes = [
+ ('', NS()),
+ ('a', NS(foo='a')),
+ ('a b', NS(foo='a', bar=['b'])),
+ ('--baz', NS(baz=True)),
+ ('a --baz', NS(foo='a', baz=True)),
+ ('--baz a b', NS(foo='a', bar=['b'], baz=True)),
+ ]
+
+
+class TestParserDefaultSuppress(ParserTestCase):
+ """Test actions with a parser-level default of SUPPRESS"""
+
+ parser_signature = Sig(argument_default=argparse.SUPPRESS)
+ argument_signatures = [
+ Sig('foo', nargs='?'),
+ Sig('bar', nargs='*'),
+ Sig('--baz', action='store_true'),
+ ]
+ failures = ['-x']
+ successes = [
+ ('', NS()),
+ ('a', NS(foo='a')),
+ ('a b', NS(foo='a', bar=['b'])),
+ ('--baz', NS(baz=True)),
+ ('a --baz', NS(foo='a', baz=True)),
+ ('--baz a b', NS(foo='a', bar=['b'], baz=True)),
+ ]
+
+
+class TestParserDefault42(ParserTestCase):
+ """Test actions with a parser-level default of 42"""
+
+ parser_signature = Sig(argument_default=42, version='1.0')
+ argument_signatures = [
+ Sig('foo', nargs='?'),
+ Sig('bar', nargs='*'),
+ Sig('--baz', action='store_true'),
+ ]
+ failures = ['-x']
+ successes = [
+ ('', NS(foo=42, bar=42, baz=42)),
+ ('a', NS(foo='a', bar=42, baz=42)),
+ ('a b', NS(foo='a', bar=['b'], baz=42)),
+ ('--baz', NS(foo=42, bar=42, baz=True)),
+ ('a --baz', NS(foo='a', bar=42, baz=True)),
+ ('--baz a b', NS(foo='a', bar=['b'], baz=True)),
+ ]
+
+
+class TestArgumentsFromFile(TempDirMixin, ParserTestCase):
+ """Test reading arguments from a file"""
+
+ def setUp(self):
+ super(TestArgumentsFromFile, self).setUp()
+ file_texts = [
+ ('hello', 'hello world!\n'),
+ ('recursive', '-a\n'
+ 'A\n'
+ '@hello'),
+ ('invalid', '@no-such-path\n'),
+ ]
+ for path, text in file_texts:
+ file = open(path, 'w')
+ file.write(text)
+ file.close()
+
+ parser_signature = Sig(fromfile_prefix_chars='@')
+ argument_signatures = [
+ Sig('-a'),
+ Sig('x'),
+ Sig('y', nargs='+'),
+ ]
+ failures = ['', '-b', 'X', '@invalid', '@missing']
+ successes = [
+ ('X Y', NS(a=None, x='X', y=['Y'])),
+ ('X -a A Y Z', NS(a='A', x='X', y=['Y', 'Z'])),
+ ('@hello X', NS(a=None, x='hello world!', y=['X'])),
+ ('X @hello', NS(a=None, x='X', y=['hello world!'])),
+ ('-a B @recursive Y Z', NS(a='A', x='hello world!', y=['Y', 'Z'])),
+ ('X @recursive Z -a B', NS(a='B', x='X', y=['hello world!', 'Z'])),
+ ]
+
+
+class TestArgumentsFromFileConverter(TempDirMixin, ParserTestCase):
+ """Test reading arguments from a file"""
+
+ def setUp(self):
+ super(TestArgumentsFromFileConverter, self).setUp()
+ file_texts = [
+ ('hello', 'hello world!\n'),
+ ]
+ for path, text in file_texts:
+ file = open(path, 'w')
+ file.write(text)
+ file.close()
+
+ class FromFileConverterArgumentParser(ErrorRaisingArgumentParser):
+
+ def convert_arg_line_to_args(self, arg_line):
+ for arg in arg_line.split():
+ if not arg.strip():
+ continue
+ yield arg
+ parser_class = FromFileConverterArgumentParser
+ parser_signature = Sig(fromfile_prefix_chars='@')
+ argument_signatures = [
+ Sig('y', nargs='+'),
+ ]
+ failures = []
+ successes = [
+ ('@hello X', NS(y=['hello', 'world!', 'X'])),
+ ]
+
+
+# =====================
+# Type conversion tests
+# =====================
+
+class TestFileTypeRepr(TestCase):
+
+ def test_r(self):
+ type = argparse.FileType('r')
+ self.assertEqual("FileType('r')", repr(type))
+
+ def test_wb_1(self):
+ type = argparse.FileType('wb', 1)
+ self.assertEqual("FileType('wb', 1)", repr(type))
+
+
+class RFile(object):
+ seen = {}
+
+ def __init__(self, name):
+ self.name = name
+
+ def __eq__(self, other):
+ if other in self.seen:
+ text = self.seen[other]
+ else:
+ text = self.seen[other] = other.read()
+ other.close()
+ if not isinstance(text, str):
+ text = text.decode('ascii')
+ return self.name == other.name == text
+
+
+class TestFileTypeR(TempDirMixin, ParserTestCase):
+ """Test the FileType option/argument type for reading files"""
+
+ def setUp(self):
+ super(TestFileTypeR, self).setUp()
+ for file_name in ['foo', 'bar']:
+ file = open(os.path.join(self.temp_dir, file_name), 'w')
+ file.write(file_name)
+ file.close()
+ self.create_readonly_file('readonly')
+
+ argument_signatures = [
+ Sig('-x', type=argparse.FileType()),
+ Sig('spam', type=argparse.FileType('r')),
+ ]
+ failures = ['-x', '', 'non-existent-file.txt']
+ successes = [
+ ('foo', NS(x=None, spam=RFile('foo'))),
+ ('-x foo bar', NS(x=RFile('foo'), spam=RFile('bar'))),
+ ('bar -x foo', NS(x=RFile('foo'), spam=RFile('bar'))),
+ ('-x - -', NS(x=sys.stdin, spam=sys.stdin)),
+ ('readonly', NS(x=None, spam=RFile('readonly'))),
+ ]
+
+
+class TestFileTypeRB(TempDirMixin, ParserTestCase):
+ """Test the FileType option/argument type for reading files"""
+
+ def setUp(self):
+ super(TestFileTypeRB, self).setUp()
+ for file_name in ['foo', 'bar']:
+ file = open(os.path.join(self.temp_dir, file_name), 'w')
+ file.write(file_name)
+ file.close()
+
+ argument_signatures = [
+ Sig('-x', type=argparse.FileType('rb')),
+ Sig('spam', type=argparse.FileType('rb')),
+ ]
+ failures = ['-x', '']
+ successes = [
+ ('foo', NS(x=None, spam=RFile('foo'))),
+ ('-x foo bar', NS(x=RFile('foo'), spam=RFile('bar'))),
+ ('bar -x foo', NS(x=RFile('foo'), spam=RFile('bar'))),
+ ('-x - -', NS(x=sys.stdin, spam=sys.stdin)),
+ ]
+
+
+class WFile(object):
+ seen = set()
+
+ def __init__(self, name):
+ self.name = name
+
+ def __eq__(self, other):
+ if other not in self.seen:
+ text = 'Check that file is writable.'
+ if 'b' in other.mode:
+ text = text.encode('ascii')
+ other.write(text)
+ other.close()
+ self.seen.add(other)
+ return self.name == other.name
+
+
+class TestFileTypeW(TempDirMixin, ParserTestCase):
+ """Test the FileType option/argument type for writing files"""
+
+ def setUp(self):
+ super(TestFileTypeW, self).setUp()
+ self.create_readonly_file('readonly')
+
+ argument_signatures = [
+ Sig('-x', type=argparse.FileType('w')),
+ Sig('spam', type=argparse.FileType('w')),
+ ]
+ failures = ['-x', '', 'readonly']
+ successes = [
+ ('foo', NS(x=None, spam=WFile('foo'))),
+ ('-x foo bar', NS(x=WFile('foo'), spam=WFile('bar'))),
+ ('bar -x foo', NS(x=WFile('foo'), spam=WFile('bar'))),
+ ('-x - -', NS(x=sys.stdout, spam=sys.stdout)),
+ ]
+
+
+class TestFileTypeWB(TempDirMixin, ParserTestCase):
+
+ argument_signatures = [
+ Sig('-x', type=argparse.FileType('wb')),
+ Sig('spam', type=argparse.FileType('wb')),
+ ]
+ failures = ['-x', '']
+ successes = [
+ ('foo', NS(x=None, spam=WFile('foo'))),
+ ('-x foo bar', NS(x=WFile('foo'), spam=WFile('bar'))),
+ ('bar -x foo', NS(x=WFile('foo'), spam=WFile('bar'))),
+ ('-x - -', NS(x=sys.stdout, spam=sys.stdout)),
+ ]
+
+
+class TestTypeCallable(ParserTestCase):
+ """Test some callables as option/argument types"""
+
+ argument_signatures = [
+ Sig('--eggs', type=complex),
+ Sig('spam', type=float),
+ ]
+ failures = ['a', '42j', '--eggs a', '--eggs 2i']
+ successes = [
+ ('--eggs=42 42', NS(eggs=42, spam=42.0)),
+ ('--eggs 2j -- -1.5', NS(eggs=2j, spam=-1.5)),
+ ('1024.675', NS(eggs=None, spam=1024.675)),
+ ]
+
+
+class TestTypeUserDefined(ParserTestCase):
+ """Test a user-defined option/argument type"""
+
+ class MyType(TestCase):
+
+ def __init__(self, value):
+ self.value = value
+
+ def __eq__(self, other):
+ return (type(self), self.value) == (type(other), other.value)
+
+ argument_signatures = [
+ Sig('-x', type=MyType),
+ Sig('spam', type=MyType),
+ ]
+ failures = []
+ successes = [
+ ('a -x b', NS(x=MyType('b'), spam=MyType('a'))),
+ ('-xf g', NS(x=MyType('f'), spam=MyType('g'))),
+ ]
+
+
+class TestTypeClassicClass(ParserTestCase):
+ """Test a classic class type"""
+
+ class C:
+
+ def __init__(self, value):
+ self.value = value
+
+ def __eq__(self, other):
+ return (type(self), self.value) == (type(other), other.value)
+
+ argument_signatures = [
+ Sig('-x', type=C),
+ Sig('spam', type=C),
+ ]
+ failures = []
+ successes = [
+ ('a -x b', NS(x=C('b'), spam=C('a'))),
+ ('-xf g', NS(x=C('f'), spam=C('g'))),
+ ]
+
+
+class TestTypeRegistration(TestCase):
+ """Test a user-defined type by registering it"""
+
+ def test(self):
+
+ def get_my_type(string):
+ return 'my_type{%s}' % string
+
+ parser = argparse.ArgumentParser()
+ parser.register('type', 'my_type', get_my_type)
+ parser.add_argument('-x', type='my_type')
+ parser.add_argument('y', type='my_type')
+
+ self.assertEqual(parser.parse_args('1'.split()),
+ NS(x=None, y='my_type{1}'))
+ self.assertEqual(parser.parse_args('-x 1 42'.split()),
+ NS(x='my_type{1}', y='my_type{42}'))
+
+
+# ============
+# Action tests
+# ============
+
+class TestActionUserDefined(ParserTestCase):
+ """Test a user-defined option/argument action"""
+
+ class OptionalAction(argparse.Action):
+
+ def __call__(self, parser, namespace, value, option_string=None):
+ try:
+ # check destination and option string
+ assert self.dest == 'spam', 'dest: %s' % self.dest
+ assert option_string == '-s', 'flag: %s' % option_string
+ # when option is before argument, badger=2, and when
+ # option is after argument, badger=<whatever was set>
+ expected_ns = NS(spam=0.25)
+ if value in [0.125, 0.625]:
+ expected_ns.badger = 2
+ elif value in [2.0]:
+ expected_ns.badger = 84
+ else:
+ raise AssertionError('value: %s' % value)
+ assert expected_ns == namespace, ('expected %s, got %s' %
+ (expected_ns, namespace))
+ except AssertionError:
+ e = sys.exc_info()[1]
+ raise ArgumentParserError('opt_action failed: %s' % e)
+ setattr(namespace, 'spam', value)
+
+ class PositionalAction(argparse.Action):
+
+ def __call__(self, parser, namespace, value, option_string=None):
+ try:
+ assert option_string is None, ('option_string: %s' %
+ option_string)
+ # check destination
+ assert self.dest == 'badger', 'dest: %s' % self.dest
+ # when argument is before option, spam=0.25, and when
+ # option is after argument, spam=<whatever was set>
+ expected_ns = NS(badger=2)
+ if value in [42, 84]:
+ expected_ns.spam = 0.25
+ elif value in [1]:
+ expected_ns.spam = 0.625
+ elif value in [2]:
+ expected_ns.spam = 0.125
+ else:
+ raise AssertionError('value: %s' % value)
+ assert expected_ns == namespace, ('expected %s, got %s' %
+ (expected_ns, namespace))
+ except AssertionError:
+ e = sys.exc_info()[1]
+ raise ArgumentParserError('arg_action failed: %s' % e)
+ setattr(namespace, 'badger', value)
+
+ argument_signatures = [
+ Sig('-s', dest='spam', action=OptionalAction,
+ type=float, default=0.25),
+ Sig('badger', action=PositionalAction,
+ type=int, nargs='?', default=2),
+ ]
+ failures = []
+ successes = [
+ ('-s0.125', NS(spam=0.125, badger=2)),
+ ('42', NS(spam=0.25, badger=42)),
+ ('-s 0.625 1', NS(spam=0.625, badger=1)),
+ ('84 -s2', NS(spam=2.0, badger=84)),
+ ]
+
+
+class TestActionRegistration(TestCase):
+ """Test a user-defined action supplied by registering it"""
+
+ class MyAction(argparse.Action):
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ setattr(namespace, self.dest, 'foo[%s]' % values)
+
+ def test(self):
+
+ parser = argparse.ArgumentParser()
+ parser.register('action', 'my_action', self.MyAction)
+ parser.add_argument('badger', action='my_action')
+
+ self.assertEqual(parser.parse_args(['1']), NS(badger='foo[1]'))
+ self.assertEqual(parser.parse_args(['42']), NS(badger='foo[42]'))
+
+
+# ================
+# Subparsers tests
+# ================
+
+class TestAddSubparsers(TestCase):
+ """Test the add_subparsers method"""
+
+ def assertArgumentParserError(self, *args, **kwargs):
+ self.assertRaises(ArgumentParserError, *args, **kwargs)
+
+ def _get_parser(self, subparser_help=False, prefix_chars=None,
+ aliases=False):
+ # create a parser with a subparsers argument
+ if prefix_chars:
+ parser = ErrorRaisingArgumentParser(
+ prog='PROG', description='main description', prefix_chars=prefix_chars)
+ parser.add_argument(
+ prefix_chars[0] * 2 + 'foo', action='store_true', help='foo help')
+ else:
+ parser = ErrorRaisingArgumentParser(
+ prog='PROG', description='main description')
+ parser.add_argument(
+ '--foo', action='store_true', help='foo help')
+ parser.add_argument(
+ 'bar', type=float, help='bar help')
+
+ # check that only one subparsers argument can be added
+ subparsers_kwargs = {}
+ if aliases:
+ subparsers_kwargs['metavar'] = 'COMMAND'
+ subparsers_kwargs['title'] = 'commands'
+ else:
+ subparsers_kwargs['help'] = 'command help'
+ subparsers = parser.add_subparsers(**subparsers_kwargs)
+ self.assertArgumentParserError(parser.add_subparsers)
+
+ # add first sub-parser
+ parser1_kwargs = dict(description='1 description')
+ if subparser_help:
+ parser1_kwargs['help'] = '1 help'
+ if aliases:
+ parser1_kwargs['aliases'] = ['1alias1', '1alias2']
+ parser1 = subparsers.add_parser('1', **parser1_kwargs)
+ parser1.add_argument('-w', type=int, help='w help')
+ parser1.add_argument('x', choices='abc', help='x help')
+
+ # add second sub-parser
+ parser2_kwargs = dict(description='2 description')
+ if subparser_help:
+ parser2_kwargs['help'] = '2 help'
+ parser2 = subparsers.add_parser('2', **parser2_kwargs)
+ parser2.add_argument('-y', choices='123', help='y help')
+ parser2.add_argument('z', type=complex, nargs='*', help='z help')
+
+ # return the main parser
+ return parser
+
+ def setUp(self):
+ super().setUp()
+ self.parser = self._get_parser()
+ self.command_help_parser = self._get_parser(subparser_help=True)
+
+ def test_parse_args_failures(self):
+ # check some failure cases:
+ for args_str in ['', 'a', 'a a', '0.5 a', '0.5 1',
+ '0.5 1 -y', '0.5 2 -w']:
+ args = args_str.split()
+ self.assertArgumentParserError(self.parser.parse_args, args)
+
+ def test_parse_args(self):
+ # check some non-failure cases:
+ self.assertEqual(
+ self.parser.parse_args('0.5 1 b -w 7'.split()),
+ NS(foo=False, bar=0.5, w=7, x='b'),
+ )
+ self.assertEqual(
+ self.parser.parse_args('0.25 --foo 2 -y 2 3j -- -1j'.split()),
+ NS(foo=True, bar=0.25, y='2', z=[3j, -1j]),
+ )
+ self.assertEqual(
+ self.parser.parse_args('--foo 0.125 1 c'.split()),
+ NS(foo=True, bar=0.125, w=None, x='c'),
+ )
+
+ def test_parse_known_args(self):
+ self.assertEqual(
+ self.parser.parse_known_args('0.5 1 b -w 7'.split()),
+ (NS(foo=False, bar=0.5, w=7, x='b'), []),
+ )
+ self.assertEqual(
+ self.parser.parse_known_args('0.5 -p 1 b -w 7'.split()),
+ (NS(foo=False, bar=0.5, w=7, x='b'), ['-p']),
+ )
+ self.assertEqual(
+ self.parser.parse_known_args('0.5 1 b -w 7 -p'.split()),
+ (NS(foo=False, bar=0.5, w=7, x='b'), ['-p']),
+ )
+ self.assertEqual(
+ self.parser.parse_known_args('0.5 1 b -q -rs -w 7'.split()),
+ (NS(foo=False, bar=0.5, w=7, x='b'), ['-q', '-rs']),
+ )
+ self.assertEqual(
+ self.parser.parse_known_args('0.5 -W 1 b -X Y -w 7 Z'.split()),
+ (NS(foo=False, bar=0.5, w=7, x='b'), ['-W', '-X', 'Y', 'Z']),
+ )
+
+ def test_dest(self):
+ parser = ErrorRaisingArgumentParser()
+ parser.add_argument('--foo', action='store_true')
+ subparsers = parser.add_subparsers(dest='bar')
+ parser1 = subparsers.add_parser('1')
+ parser1.add_argument('baz')
+ self.assertEqual(NS(foo=False, bar='1', baz='2'),
+ parser.parse_args('1 2'.split()))
+
+ def test_help(self):
+ self.assertEqual(self.parser.format_usage(),
+ 'usage: PROG [-h] [--foo] bar {1,2} ...\n')
+ self.assertEqual(self.parser.format_help(), textwrap.dedent('''\
+ usage: PROG [-h] [--foo] bar {1,2} ...
+
+ main description
+
+ positional arguments:
+ bar bar help
+ {1,2} command help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo foo help
+ '''))
+
+ def test_help_extra_prefix_chars(self):
+ # Make sure - is still used for help if it is a non-first prefix char
+ parser = self._get_parser(prefix_chars='+:-')
+ self.assertEqual(parser.format_usage(),
+ 'usage: PROG [-h] [++foo] bar {1,2} ...\n')
+ self.assertEqual(parser.format_help(), textwrap.dedent('''\
+ usage: PROG [-h] [++foo] bar {1,2} ...
+
+ main description
+
+ positional arguments:
+ bar bar help
+ {1,2} command help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ ++foo foo help
+ '''))
+
+
+ def test_help_alternate_prefix_chars(self):
+ parser = self._get_parser(prefix_chars='+:/')
+ self.assertEqual(parser.format_usage(),
+ 'usage: PROG [+h] [++foo] bar {1,2} ...\n')
+ self.assertEqual(parser.format_help(), textwrap.dedent('''\
+ usage: PROG [+h] [++foo] bar {1,2} ...
+
+ main description
+
+ positional arguments:
+ bar bar help
+ {1,2} command help
+
+ optional arguments:
+ +h, ++help show this help message and exit
+ ++foo foo help
+ '''))
+
+ def test_parser_command_help(self):
+ self.assertEqual(self.command_help_parser.format_usage(),
+ 'usage: PROG [-h] [--foo] bar {1,2} ...\n')
+ self.assertEqual(self.command_help_parser.format_help(),
+ textwrap.dedent('''\
+ usage: PROG [-h] [--foo] bar {1,2} ...
+
+ main description
+
+ positional arguments:
+ bar bar help
+ {1,2} command help
+ 1 1 help
+ 2 2 help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo foo help
+ '''))
+
+ def test_subparser_title_help(self):
+ parser = ErrorRaisingArgumentParser(prog='PROG',
+ description='main description')
+ parser.add_argument('--foo', action='store_true', help='foo help')
+ parser.add_argument('bar', help='bar help')
+ subparsers = parser.add_subparsers(title='subcommands',
+ description='command help',
+ help='additional text')
+ parser1 = subparsers.add_parser('1')
+ parser2 = subparsers.add_parser('2')
+ self.assertEqual(parser.format_usage(),
+ 'usage: PROG [-h] [--foo] bar {1,2} ...\n')
+ self.assertEqual(parser.format_help(), textwrap.dedent('''\
+ usage: PROG [-h] [--foo] bar {1,2} ...
+
+ main description
+
+ positional arguments:
+ bar bar help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo foo help
+
+ subcommands:
+ command help
+
+ {1,2} additional text
+ '''))
+
+ def _test_subparser_help(self, args_str, expected_help):
+ try:
+ self.parser.parse_args(args_str.split())
+ except ArgumentParserError:
+ err = sys.exc_info()[1]
+ if err.stdout != expected_help:
+ print(repr(expected_help))
+ print(repr(err.stdout))
+ self.assertEqual(err.stdout, expected_help)
+
+ def test_subparser1_help(self):
+ self._test_subparser_help('5.0 1 -h', textwrap.dedent('''\
+ usage: PROG bar 1 [-h] [-w W] {a,b,c}
+
+ 1 description
+
+ positional arguments:
+ {a,b,c} x help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -w W w help
+ '''))
+
+ def test_subparser2_help(self):
+ self._test_subparser_help('5.0 2 -h', textwrap.dedent('''\
+ usage: PROG bar 2 [-h] [-y {1,2,3}] [z [z ...]]
+
+ 2 description
+
+ positional arguments:
+ z z help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -y {1,2,3} y help
+ '''))
+
+ def test_alias_invocation(self):
+ parser = self._get_parser(aliases=True)
+ self.assertEqual(
+ parser.parse_known_args('0.5 1alias1 b'.split()),
+ (NS(foo=False, bar=0.5, w=None, x='b'), []),
+ )
+ self.assertEqual(
+ parser.parse_known_args('0.5 1alias2 b'.split()),
+ (NS(foo=False, bar=0.5, w=None, x='b'), []),
+ )
+
+ def test_error_alias_invocation(self):
+ parser = self._get_parser(aliases=True)
+ self.assertArgumentParserError(parser.parse_args,
+ '0.5 1alias3 b'.split())
+
+ def test_alias_help(self):
+ parser = self._get_parser(aliases=True, subparser_help=True)
+ self.maxDiff = None
+ self.assertEqual(parser.format_help(), textwrap.dedent("""\
+ usage: PROG [-h] [--foo] bar COMMAND ...
+
+ main description
+
+ positional arguments:
+ bar bar help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo foo help
+
+ commands:
+ COMMAND
+ 1 (1alias1, 1alias2)
+ 1 help
+ 2 2 help
+ """))
+
+# ============
+# Groups tests
+# ============
+
+class TestPositionalsGroups(TestCase):
+ """Tests that order of group positionals matches construction order"""
+
+ def test_nongroup_first(self):
+ parser = ErrorRaisingArgumentParser()
+ parser.add_argument('foo')
+ group = parser.add_argument_group('g')
+ group.add_argument('bar')
+ parser.add_argument('baz')
+ expected = NS(foo='1', bar='2', baz='3')
+ result = parser.parse_args('1 2 3'.split())
+ self.assertEqual(expected, result)
+
+ def test_group_first(self):
+ parser = ErrorRaisingArgumentParser()
+ group = parser.add_argument_group('xxx')
+ group.add_argument('foo')
+ parser.add_argument('bar')
+ parser.add_argument('baz')
+ expected = NS(foo='1', bar='2', baz='3')
+ result = parser.parse_args('1 2 3'.split())
+ self.assertEqual(expected, result)
+
+ def test_interleaved_groups(self):
+ parser = ErrorRaisingArgumentParser()
+ group = parser.add_argument_group('xxx')
+ parser.add_argument('foo')
+ group.add_argument('bar')
+ parser.add_argument('baz')
+ group = parser.add_argument_group('yyy')
+ group.add_argument('frell')
+ expected = NS(foo='1', bar='2', baz='3', frell='4')
+ result = parser.parse_args('1 2 3 4'.split())
+ self.assertEqual(expected, result)
+
+# ===================
+# Parent parser tests
+# ===================
+
+class TestParentParsers(TestCase):
+ """Tests that parsers can be created with parent parsers"""
+
+ def assertArgumentParserError(self, *args, **kwargs):
+ self.assertRaises(ArgumentParserError, *args, **kwargs)
+
+ def setUp(self):
+ super().setUp()
+ self.wxyz_parent = ErrorRaisingArgumentParser(add_help=False)
+ self.wxyz_parent.add_argument('--w')
+ x_group = self.wxyz_parent.add_argument_group('x')
+ x_group.add_argument('-y')
+ self.wxyz_parent.add_argument('z')
+
+ self.abcd_parent = ErrorRaisingArgumentParser(add_help=False)
+ self.abcd_parent.add_argument('a')
+ self.abcd_parent.add_argument('-b')
+ c_group = self.abcd_parent.add_argument_group('c')
+ c_group.add_argument('--d')
+
+ self.w_parent = ErrorRaisingArgumentParser(add_help=False)
+ self.w_parent.add_argument('--w')
+
+ self.z_parent = ErrorRaisingArgumentParser(add_help=False)
+ self.z_parent.add_argument('z')
+
+ # parents with mutually exclusive groups
+ self.ab_mutex_parent = ErrorRaisingArgumentParser(add_help=False)
+ group = self.ab_mutex_parent.add_mutually_exclusive_group()
+ group.add_argument('-a', action='store_true')
+ group.add_argument('-b', action='store_true')
+
+ self.main_program = os.path.basename(sys.argv[0])
+
+ def test_single_parent(self):
+ parser = ErrorRaisingArgumentParser(parents=[self.wxyz_parent])
+ self.assertEqual(parser.parse_args('-y 1 2 --w 3'.split()),
+ NS(w='3', y='1', z='2'))
+
+ def test_single_parent_mutex(self):
+ self._test_mutex_ab(self.ab_mutex_parent.parse_args)
+ parser = ErrorRaisingArgumentParser(parents=[self.ab_mutex_parent])
+ self._test_mutex_ab(parser.parse_args)
+
+ def test_single_granparent_mutex(self):
+ parents = [self.ab_mutex_parent]
+ parser = ErrorRaisingArgumentParser(add_help=False, parents=parents)
+ parser = ErrorRaisingArgumentParser(parents=[parser])
+ self._test_mutex_ab(parser.parse_args)
+
+ def _test_mutex_ab(self, parse_args):
+ self.assertEqual(parse_args([]), NS(a=False, b=False))
+ self.assertEqual(parse_args(['-a']), NS(a=True, b=False))
+ self.assertEqual(parse_args(['-b']), NS(a=False, b=True))
+ self.assertArgumentParserError(parse_args, ['-a', '-b'])
+ self.assertArgumentParserError(parse_args, ['-b', '-a'])
+ self.assertArgumentParserError(parse_args, ['-c'])
+ self.assertArgumentParserError(parse_args, ['-a', '-c'])
+ self.assertArgumentParserError(parse_args, ['-b', '-c'])
+
+ def test_multiple_parents(self):
+ parents = [self.abcd_parent, self.wxyz_parent]
+ parser = ErrorRaisingArgumentParser(parents=parents)
+ self.assertEqual(parser.parse_args('--d 1 --w 2 3 4'.split()),
+ NS(a='3', b=None, d='1', w='2', y=None, z='4'))
+
+ def test_multiple_parents_mutex(self):
+ parents = [self.ab_mutex_parent, self.wxyz_parent]
+ parser = ErrorRaisingArgumentParser(parents=parents)
+ self.assertEqual(parser.parse_args('-a --w 2 3'.split()),
+ NS(a=True, b=False, w='2', y=None, z='3'))
+ self.assertArgumentParserError(
+ parser.parse_args, '-a --w 2 3 -b'.split())
+ self.assertArgumentParserError(
+ parser.parse_args, '-a -b --w 2 3'.split())
+
+ def test_conflicting_parents(self):
+ self.assertRaises(
+ argparse.ArgumentError,
+ argparse.ArgumentParser,
+ parents=[self.w_parent, self.wxyz_parent])
+
+ def test_conflicting_parents_mutex(self):
+ self.assertRaises(
+ argparse.ArgumentError,
+ argparse.ArgumentParser,
+ parents=[self.abcd_parent, self.ab_mutex_parent])
+
+ def test_same_argument_name_parents(self):
+ parents = [self.wxyz_parent, self.z_parent]
+ parser = ErrorRaisingArgumentParser(parents=parents)
+ self.assertEqual(parser.parse_args('1 2'.split()),
+ NS(w=None, y=None, z='2'))
+
+ def test_subparser_parents(self):
+ parser = ErrorRaisingArgumentParser()
+ subparsers = parser.add_subparsers()
+ abcde_parser = subparsers.add_parser('bar', parents=[self.abcd_parent])
+ abcde_parser.add_argument('e')
+ self.assertEqual(parser.parse_args('bar -b 1 --d 2 3 4'.split()),
+ NS(a='3', b='1', d='2', e='4'))
+
+ def test_subparser_parents_mutex(self):
+ parser = ErrorRaisingArgumentParser()
+ subparsers = parser.add_subparsers()
+ parents = [self.ab_mutex_parent]
+ abc_parser = subparsers.add_parser('foo', parents=parents)
+ c_group = abc_parser.add_argument_group('c_group')
+ c_group.add_argument('c')
+ parents = [self.wxyz_parent, self.ab_mutex_parent]
+ wxyzabe_parser = subparsers.add_parser('bar', parents=parents)
+ wxyzabe_parser.add_argument('e')
+ self.assertEqual(parser.parse_args('foo -a 4'.split()),
+ NS(a=True, b=False, c='4'))
+ self.assertEqual(parser.parse_args('bar -b --w 2 3 4'.split()),
+ NS(a=False, b=True, w='2', y=None, z='3', e='4'))
+ self.assertArgumentParserError(
+ parser.parse_args, 'foo -a -b 4'.split())
+ self.assertArgumentParserError(
+ parser.parse_args, 'bar -b -a 4'.split())
+
+ def test_parent_help(self):
+ parents = [self.abcd_parent, self.wxyz_parent]
+ parser = ErrorRaisingArgumentParser(parents=parents)
+ parser_help = parser.format_help()
+ self.assertEqual(parser_help, textwrap.dedent('''\
+ usage: {} [-h] [-b B] [--d D] [--w W] [-y Y] a z
+
+ positional arguments:
+ a
+ z
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -b B
+ --w W
+
+ c:
+ --d D
+
+ x:
+ -y Y
+ '''.format(self.main_program)))
+
+ def test_groups_parents(self):
+ parent = ErrorRaisingArgumentParser(add_help=False)
+ g = parent.add_argument_group(title='g', description='gd')
+ g.add_argument('-w')
+ g.add_argument('-x')
+ m = parent.add_mutually_exclusive_group()
+ m.add_argument('-y')
+ m.add_argument('-z')
+ parser = ErrorRaisingArgumentParser(parents=[parent])
+
+ self.assertRaises(ArgumentParserError, parser.parse_args,
+ ['-y', 'Y', '-z', 'Z'])
+
+ parser_help = parser.format_help()
+ self.assertEqual(parser_help, textwrap.dedent('''\
+ usage: {} [-h] [-w W] [-x X] [-y Y | -z Z]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -y Y
+ -z Z
+
+ g:
+ gd
+
+ -w W
+ -x X
+ '''.format(self.main_program)))
+
+# ==============================
+# Mutually exclusive group tests
+# ==============================
+
+class TestMutuallyExclusiveGroupErrors(TestCase):
+
+ def test_invalid_add_argument_group(self):
+ parser = ErrorRaisingArgumentParser()
+ raises = self.assertRaises
+ raises(TypeError, parser.add_mutually_exclusive_group, title='foo')
+
+ def test_invalid_add_argument(self):
+ parser = ErrorRaisingArgumentParser()
+ group = parser.add_mutually_exclusive_group()
+ add_argument = group.add_argument
+ raises = self.assertRaises
+ raises(ValueError, add_argument, '--foo', required=True)
+ raises(ValueError, add_argument, 'bar')
+ raises(ValueError, add_argument, 'bar', nargs='+')
+ raises(ValueError, add_argument, 'bar', nargs=1)
+ raises(ValueError, add_argument, 'bar', nargs=argparse.PARSER)
+
+ def test_help(self):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ group1 = parser.add_mutually_exclusive_group()
+ group1.add_argument('--foo', action='store_true')
+ group1.add_argument('--bar', action='store_false')
+ group2 = parser.add_mutually_exclusive_group()
+ group2.add_argument('--soup', action='store_true')
+ group2.add_argument('--nuts', action='store_false')
+ expected = '''\
+ usage: PROG [-h] [--foo | --bar] [--soup | --nuts]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo
+ --bar
+ --soup
+ --nuts
+ '''
+ self.assertEqual(parser.format_help(), textwrap.dedent(expected))
+
+class MEMixin(object):
+
+ def test_failures_when_not_required(self):
+ parse_args = self.get_parser(required=False).parse_args
+ error = ArgumentParserError
+ for args_string in self.failures:
+ self.assertRaises(error, parse_args, args_string.split())
+
+ def test_failures_when_required(self):
+ parse_args = self.get_parser(required=True).parse_args
+ error = ArgumentParserError
+ for args_string in self.failures + ['']:
+ self.assertRaises(error, parse_args, args_string.split())
+
+ def test_successes_when_not_required(self):
+ parse_args = self.get_parser(required=False).parse_args
+ successes = self.successes + self.successes_when_not_required
+ for args_string, expected_ns in successes:
+ actual_ns = parse_args(args_string.split())
+ self.assertEqual(actual_ns, expected_ns)
+
+ def test_successes_when_required(self):
+ parse_args = self.get_parser(required=True).parse_args
+ for args_string, expected_ns in self.successes:
+ actual_ns = parse_args(args_string.split())
+ self.assertEqual(actual_ns, expected_ns)
+
+ def test_usage_when_not_required(self):
+ format_usage = self.get_parser(required=False).format_usage
+ expected_usage = self.usage_when_not_required
+ self.assertEqual(format_usage(), textwrap.dedent(expected_usage))
+
+ def test_usage_when_required(self):
+ format_usage = self.get_parser(required=True).format_usage
+ expected_usage = self.usage_when_required
+ self.assertEqual(format_usage(), textwrap.dedent(expected_usage))
+
+ def test_help_when_not_required(self):
+ format_help = self.get_parser(required=False).format_help
+ help = self.usage_when_not_required + self.help
+ self.assertEqual(format_help(), textwrap.dedent(help))
+
+ def test_help_when_required(self):
+ format_help = self.get_parser(required=True).format_help
+ help = self.usage_when_required + self.help
+ self.assertEqual(format_help(), textwrap.dedent(help))
+
+
+class TestMutuallyExclusiveSimple(MEMixin, TestCase):
+
+ def get_parser(self, required=None):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ group = parser.add_mutually_exclusive_group(required=required)
+ group.add_argument('--bar', help='bar help')
+ group.add_argument('--baz', nargs='?', const='Z', help='baz help')
+ return parser
+
+ failures = ['--bar X --baz Y', '--bar X --baz']
+ successes = [
+ ('--bar X', NS(bar='X', baz=None)),
+ ('--bar X --bar Z', NS(bar='Z', baz=None)),
+ ('--baz Y', NS(bar=None, baz='Y')),
+ ('--baz', NS(bar=None, baz='Z')),
+ ]
+ successes_when_not_required = [
+ ('', NS(bar=None, baz=None)),
+ ]
+
+ usage_when_not_required = '''\
+ usage: PROG [-h] [--bar BAR | --baz [BAZ]]
+ '''
+ usage_when_required = '''\
+ usage: PROG [-h] (--bar BAR | --baz [BAZ])
+ '''
+ help = '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --bar BAR bar help
+ --baz [BAZ] baz help
+ '''
+
+
+class TestMutuallyExclusiveLong(MEMixin, TestCase):
+
+ def get_parser(self, required=None):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ parser.add_argument('--abcde', help='abcde help')
+ parser.add_argument('--fghij', help='fghij help')
+ group = parser.add_mutually_exclusive_group(required=required)
+ group.add_argument('--klmno', help='klmno help')
+ group.add_argument('--pqrst', help='pqrst help')
+ return parser
+
+ failures = ['--klmno X --pqrst Y']
+ successes = [
+ ('--klmno X', NS(abcde=None, fghij=None, klmno='X', pqrst=None)),
+ ('--abcde Y --klmno X',
+ NS(abcde='Y', fghij=None, klmno='X', pqrst=None)),
+ ('--pqrst X', NS(abcde=None, fghij=None, klmno=None, pqrst='X')),
+ ('--pqrst X --fghij Y',
+ NS(abcde=None, fghij='Y', klmno=None, pqrst='X')),
+ ]
+ successes_when_not_required = [
+ ('', NS(abcde=None, fghij=None, klmno=None, pqrst=None)),
+ ]
+
+ usage_when_not_required = '''\
+ usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ]
+ [--klmno KLMNO | --pqrst PQRST]
+ '''
+ usage_when_required = '''\
+ usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ]
+ (--klmno KLMNO | --pqrst PQRST)
+ '''
+ help = '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --abcde ABCDE abcde help
+ --fghij FGHIJ fghij help
+ --klmno KLMNO klmno help
+ --pqrst PQRST pqrst help
+ '''
+
+
+class TestMutuallyExclusiveFirstSuppressed(MEMixin, TestCase):
+
+ def get_parser(self, required):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ group = parser.add_mutually_exclusive_group(required=required)
+ group.add_argument('-x', help=argparse.SUPPRESS)
+ group.add_argument('-y', action='store_false', help='y help')
+ return parser
+
+ failures = ['-x X -y']
+ successes = [
+ ('-x X', NS(x='X', y=True)),
+ ('-x X -x Y', NS(x='Y', y=True)),
+ ('-y', NS(x=None, y=False)),
+ ]
+ successes_when_not_required = [
+ ('', NS(x=None, y=True)),
+ ]
+
+ usage_when_not_required = '''\
+ usage: PROG [-h] [-y]
+ '''
+ usage_when_required = '''\
+ usage: PROG [-h] -y
+ '''
+ help = '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -y y help
+ '''
+
+
+class TestMutuallyExclusiveManySuppressed(MEMixin, TestCase):
+
+ def get_parser(self, required):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ group = parser.add_mutually_exclusive_group(required=required)
+ add = group.add_argument
+ add('--spam', action='store_true', help=argparse.SUPPRESS)
+ add('--badger', action='store_false', help=argparse.SUPPRESS)
+ add('--bladder', help=argparse.SUPPRESS)
+ return parser
+
+ failures = [
+ '--spam --badger',
+ '--badger --bladder B',
+ '--bladder B --spam',
+ ]
+ successes = [
+ ('--spam', NS(spam=True, badger=True, bladder=None)),
+ ('--badger', NS(spam=False, badger=False, bladder=None)),
+ ('--bladder B', NS(spam=False, badger=True, bladder='B')),
+ ('--spam --spam', NS(spam=True, badger=True, bladder=None)),
+ ]
+ successes_when_not_required = [
+ ('', NS(spam=False, badger=True, bladder=None)),
+ ]
+
+ usage_when_required = usage_when_not_required = '''\
+ usage: PROG [-h]
+ '''
+ help = '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ '''
+
+
+class TestMutuallyExclusiveOptionalAndPositional(MEMixin, TestCase):
+
+ def get_parser(self, required):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ group = parser.add_mutually_exclusive_group(required=required)
+ group.add_argument('--foo', action='store_true', help='FOO')
+ group.add_argument('--spam', help='SPAM')
+ group.add_argument('badger', nargs='*', default='X', help='BADGER')
+ return parser
+
+ failures = [
+ '--foo --spam S',
+ '--spam S X',
+ 'X --foo',
+ 'X Y Z --spam S',
+ '--foo X Y',
+ ]
+ successes = [
+ ('--foo', NS(foo=True, spam=None, badger='X')),
+ ('--spam S', NS(foo=False, spam='S', badger='X')),
+ ('X', NS(foo=False, spam=None, badger=['X'])),
+ ('X Y Z', NS(foo=False, spam=None, badger=['X', 'Y', 'Z'])),
+ ]
+ successes_when_not_required = [
+ ('', NS(foo=False, spam=None, badger='X')),
+ ]
+
+ usage_when_not_required = '''\
+ usage: PROG [-h] [--foo | --spam SPAM | badger [badger ...]]
+ '''
+ usage_when_required = '''\
+ usage: PROG [-h] (--foo | --spam SPAM | badger [badger ...])
+ '''
+ help = '''\
+
+ positional arguments:
+ badger BADGER
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO
+ --spam SPAM SPAM
+ '''
+
+
+class TestMutuallyExclusiveOptionalsMixed(MEMixin, TestCase):
+
+ def get_parser(self, required):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ parser.add_argument('-x', action='store_true', help='x help')
+ group = parser.add_mutually_exclusive_group(required=required)
+ group.add_argument('-a', action='store_true', help='a help')
+ group.add_argument('-b', action='store_true', help='b help')
+ parser.add_argument('-y', action='store_true', help='y help')
+ group.add_argument('-c', action='store_true', help='c help')
+ return parser
+
+ failures = ['-a -b', '-b -c', '-a -c', '-a -b -c']
+ successes = [
+ ('-a', NS(a=True, b=False, c=False, x=False, y=False)),
+ ('-b', NS(a=False, b=True, c=False, x=False, y=False)),
+ ('-c', NS(a=False, b=False, c=True, x=False, y=False)),
+ ('-a -x', NS(a=True, b=False, c=False, x=True, y=False)),
+ ('-y -b', NS(a=False, b=True, c=False, x=False, y=True)),
+ ('-x -y -c', NS(a=False, b=False, c=True, x=True, y=True)),
+ ]
+ successes_when_not_required = [
+ ('', NS(a=False, b=False, c=False, x=False, y=False)),
+ ('-x', NS(a=False, b=False, c=False, x=True, y=False)),
+ ('-y', NS(a=False, b=False, c=False, x=False, y=True)),
+ ]
+
+ usage_when_required = usage_when_not_required = '''\
+ usage: PROG [-h] [-x] [-a] [-b] [-y] [-c]
+ '''
+ help = '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x x help
+ -a a help
+ -b b help
+ -y y help
+ -c c help
+ '''
+
+
+class TestMutuallyExclusiveInGroup(MEMixin, TestCase):
+
+ def get_parser(self, required=None):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ titled_group = parser.add_argument_group(
+ title='Titled group', description='Group description')
+ mutex_group = \
+ titled_group.add_mutually_exclusive_group(required=required)
+ mutex_group.add_argument('--bar', help='bar help')
+ mutex_group.add_argument('--baz', help='baz help')
+ return parser
+
+ failures = ['--bar X --baz Y', '--baz X --bar Y']
+ successes = [
+ ('--bar X', NS(bar='X', baz=None)),
+ ('--baz Y', NS(bar=None, baz='Y')),
+ ]
+ successes_when_not_required = [
+ ('', NS(bar=None, baz=None)),
+ ]
+
+ usage_when_not_required = '''\
+ usage: PROG [-h] [--bar BAR | --baz BAZ]
+ '''
+ usage_when_required = '''\
+ usage: PROG [-h] (--bar BAR | --baz BAZ)
+ '''
+ help = '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+
+ Titled group:
+ Group description
+
+ --bar BAR bar help
+ --baz BAZ baz help
+ '''
+
+
+class TestMutuallyExclusiveOptionalsAndPositionalsMixed(MEMixin, TestCase):
+
+ def get_parser(self, required):
+ parser = ErrorRaisingArgumentParser(prog='PROG')
+ parser.add_argument('x', help='x help')
+ parser.add_argument('-y', action='store_true', help='y help')
+ group = parser.add_mutually_exclusive_group(required=required)
+ group.add_argument('a', nargs='?', help='a help')
+ group.add_argument('-b', action='store_true', help='b help')
+ group.add_argument('-c', action='store_true', help='c help')
+ return parser
+
+ failures = ['X A -b', '-b -c', '-c X A']
+ successes = [
+ ('X A', NS(a='A', b=False, c=False, x='X', y=False)),
+ ('X -b', NS(a=None, b=True, c=False, x='X', y=False)),
+ ('X -c', NS(a=None, b=False, c=True, x='X', y=False)),
+ ('X A -y', NS(a='A', b=False, c=False, x='X', y=True)),
+ ('X -y -b', NS(a=None, b=True, c=False, x='X', y=True)),
+ ]
+ successes_when_not_required = [
+ ('X', NS(a=None, b=False, c=False, x='X', y=False)),
+ ('X -y', NS(a=None, b=False, c=False, x='X', y=True)),
+ ]
+
+ usage_when_required = usage_when_not_required = '''\
+ usage: PROG [-h] [-y] [-b] [-c] x [a]
+ '''
+ help = '''\
+
+ positional arguments:
+ x x help
+ a a help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -y y help
+ -b b help
+ -c c help
+ '''
+
+# =================================================
+# Mutually exclusive group in parent parser tests
+# =================================================
+
+class MEPBase(object):
+
+ def get_parser(self, required=None):
+ parent = super(MEPBase, self).get_parser(required=required)
+ parser = ErrorRaisingArgumentParser(
+ prog=parent.prog, add_help=False, parents=[parent])
+ return parser
+
+
+class TestMutuallyExclusiveGroupErrorsParent(
+ MEPBase, TestMutuallyExclusiveGroupErrors):
+ pass
+
+
+class TestMutuallyExclusiveSimpleParent(
+ MEPBase, TestMutuallyExclusiveSimple):
+ pass
+
+
+class TestMutuallyExclusiveLongParent(
+ MEPBase, TestMutuallyExclusiveLong):
+ pass
+
+
+class TestMutuallyExclusiveFirstSuppressedParent(
+ MEPBase, TestMutuallyExclusiveFirstSuppressed):
+ pass
+
+
+class TestMutuallyExclusiveManySuppressedParent(
+ MEPBase, TestMutuallyExclusiveManySuppressed):
+ pass
+
+
+class TestMutuallyExclusiveOptionalAndPositionalParent(
+ MEPBase, TestMutuallyExclusiveOptionalAndPositional):
+ pass
+
+
+class TestMutuallyExclusiveOptionalsMixedParent(
+ MEPBase, TestMutuallyExclusiveOptionalsMixed):
+ pass
+
+
+class TestMutuallyExclusiveOptionalsAndPositionalsMixedParent(
+ MEPBase, TestMutuallyExclusiveOptionalsAndPositionalsMixed):
+ pass
+
+# =================
+# Set default tests
+# =================
+
+class TestSetDefaults(TestCase):
+
+ def test_set_defaults_no_args(self):
+ parser = ErrorRaisingArgumentParser()
+ parser.set_defaults(x='foo')
+ parser.set_defaults(y='bar', z=1)
+ self.assertEqual(NS(x='foo', y='bar', z=1),
+ parser.parse_args([]))
+ self.assertEqual(NS(x='foo', y='bar', z=1),
+ parser.parse_args([], NS()))
+ self.assertEqual(NS(x='baz', y='bar', z=1),
+ parser.parse_args([], NS(x='baz')))
+ self.assertEqual(NS(x='baz', y='bar', z=2),
+ parser.parse_args([], NS(x='baz', z=2)))
+
+ def test_set_defaults_with_args(self):
+ parser = ErrorRaisingArgumentParser()
+ parser.set_defaults(x='foo', y='bar')
+ parser.add_argument('-x', default='xfoox')
+ self.assertEqual(NS(x='xfoox', y='bar'),
+ parser.parse_args([]))
+ self.assertEqual(NS(x='xfoox', y='bar'),
+ parser.parse_args([], NS()))
+ self.assertEqual(NS(x='baz', y='bar'),
+ parser.parse_args([], NS(x='baz')))
+ self.assertEqual(NS(x='1', y='bar'),
+ parser.parse_args('-x 1'.split()))
+ self.assertEqual(NS(x='1', y='bar'),
+ parser.parse_args('-x 1'.split(), NS()))
+ self.assertEqual(NS(x='1', y='bar'),
+ parser.parse_args('-x 1'.split(), NS(x='baz')))
+
+ def test_set_defaults_subparsers(self):
+ parser = ErrorRaisingArgumentParser()
+ parser.set_defaults(x='foo')
+ subparsers = parser.add_subparsers()
+ parser_a = subparsers.add_parser('a')
+ parser_a.set_defaults(y='bar')
+ self.assertEqual(NS(x='foo', y='bar'),
+ parser.parse_args('a'.split()))
+
+ def test_set_defaults_parents(self):
+ parent = ErrorRaisingArgumentParser(add_help=False)
+ parent.set_defaults(x='foo')
+ parser = ErrorRaisingArgumentParser(parents=[parent])
+ self.assertEqual(NS(x='foo'), parser.parse_args([]))
+
+ def test_set_defaults_same_as_add_argument(self):
+ parser = ErrorRaisingArgumentParser()
+ parser.set_defaults(w='W', x='X', y='Y', z='Z')
+ parser.add_argument('-w')
+ parser.add_argument('-x', default='XX')
+ parser.add_argument('y', nargs='?')
+ parser.add_argument('z', nargs='?', default='ZZ')
+
+ # defaults set previously
+ self.assertEqual(NS(w='W', x='XX', y='Y', z='ZZ'),
+ parser.parse_args([]))
+
+ # reset defaults
+ parser.set_defaults(w='WW', x='X', y='YY', z='Z')
+ self.assertEqual(NS(w='WW', x='X', y='YY', z='Z'),
+ parser.parse_args([]))
+
+ def test_set_defaults_same_as_add_argument_group(self):
+ parser = ErrorRaisingArgumentParser()
+ parser.set_defaults(w='W', x='X', y='Y', z='Z')
+ group = parser.add_argument_group('foo')
+ group.add_argument('-w')
+ group.add_argument('-x', default='XX')
+ group.add_argument('y', nargs='?')
+ group.add_argument('z', nargs='?', default='ZZ')
+
+
+ # defaults set previously
+ self.assertEqual(NS(w='W', x='XX', y='Y', z='ZZ'),
+ parser.parse_args([]))
+
+ # reset defaults
+ parser.set_defaults(w='WW', x='X', y='YY', z='Z')
+ self.assertEqual(NS(w='WW', x='X', y='YY', z='Z'),
+ parser.parse_args([]))
+
+# =================
+# Get default tests
+# =================
+
+class TestGetDefault(TestCase):
+
+ def test_get_default(self):
+ parser = ErrorRaisingArgumentParser()
+ self.assertEqual(None, parser.get_default("foo"))
+ self.assertEqual(None, parser.get_default("bar"))
+
+ parser.add_argument("--foo")
+ self.assertEqual(None, parser.get_default("foo"))
+ self.assertEqual(None, parser.get_default("bar"))
+
+ parser.add_argument("--bar", type=int, default=42)
+ self.assertEqual(None, parser.get_default("foo"))
+ self.assertEqual(42, parser.get_default("bar"))
+
+ parser.set_defaults(foo="badger")
+ self.assertEqual("badger", parser.get_default("foo"))
+ self.assertEqual(42, parser.get_default("bar"))
+
+# ==========================
+# Namespace 'contains' tests
+# ==========================
+
+class TestNamespaceContainsSimple(TestCase):
+
+ def test_empty(self):
+ ns = argparse.Namespace()
+ self.assertEqual('' in ns, False)
+ self.assertEqual('' not in ns, True)
+ self.assertEqual('x' in ns, False)
+
+ def test_non_empty(self):
+ ns = argparse.Namespace(x=1, y=2)
+ self.assertEqual('x' in ns, True)
+ self.assertEqual('x' not in ns, False)
+ self.assertEqual('y' in ns, True)
+ self.assertEqual('' in ns, False)
+ self.assertEqual('xx' in ns, False)
+ self.assertEqual('z' in ns, False)
+
+# =====================
+# Help formatting tests
+# =====================
+
+class TestHelpFormattingMetaclass(type):
+
+ def __init__(cls, name, bases, bodydict):
+ if name == 'HelpTestCase':
+ return
+
+ class AddTests(object):
+
+ def __init__(self, test_class, func_suffix, std_name):
+ self.func_suffix = func_suffix
+ self.std_name = std_name
+
+ for test_func in [self.test_format,
+ self.test_print,
+ self.test_print_file]:
+ test_name = '%s_%s' % (test_func.__name__, func_suffix)
+
+ def test_wrapper(self, test_func=test_func):
+ test_func(self)
+ try:
+ test_wrapper.__name__ = test_name
+ except TypeError:
+ pass
+ setattr(test_class, test_name, test_wrapper)
+
+ def _get_parser(self, tester):
+ parser = argparse.ArgumentParser(
+ *tester.parser_signature.args,
+ **tester.parser_signature.kwargs)
+ for argument_sig in tester.argument_signatures:
+ parser.add_argument(*argument_sig.args,
+ **argument_sig.kwargs)
+ group_signatures = tester.argument_group_signatures
+ for group_sig, argument_sigs in group_signatures:
+ group = parser.add_argument_group(*group_sig.args,
+ **group_sig.kwargs)
+ for argument_sig in argument_sigs:
+ group.add_argument(*argument_sig.args,
+ **argument_sig.kwargs)
+ return parser
+
+ def _test(self, tester, parser_text):
+ expected_text = getattr(tester, self.func_suffix)
+ expected_text = textwrap.dedent(expected_text)
+ if expected_text != parser_text:
+ print(repr(expected_text))
+ print(repr(parser_text))
+ for char1, char2 in zip(expected_text, parser_text):
+ if char1 != char2:
+ print('first diff: %r %r' % (char1, char2))
+ break
+ tester.assertEqual(expected_text, parser_text)
+
+ def test_format(self, tester):
+ parser = self._get_parser(tester)
+ format = getattr(parser, 'format_%s' % self.func_suffix)
+ self._test(tester, format())
+
+ def test_print(self, tester):
+ parser = self._get_parser(tester)
+ print_ = getattr(parser, 'print_%s' % self.func_suffix)
+ old_stream = getattr(sys, self.std_name)
+ setattr(sys, self.std_name, StdIOBuffer())
+ try:
+ print_()
+ parser_text = getattr(sys, self.std_name).getvalue()
+ finally:
+ setattr(sys, self.std_name, old_stream)
+ self._test(tester, parser_text)
+
+ def test_print_file(self, tester):
+ parser = self._get_parser(tester)
+ print_ = getattr(parser, 'print_%s' % self.func_suffix)
+ sfile = StdIOBuffer()
+ print_(sfile)
+ parser_text = sfile.getvalue()
+ self._test(tester, parser_text)
+
+ # add tests for {format,print}_{usage,help,version}
+ for func_suffix, std_name in [('usage', 'stdout'),
+ ('help', 'stdout'),
+ ('version', 'stderr')]:
+ AddTests(cls, func_suffix, std_name)
+
+bases = TestCase,
+HelpTestCase = TestHelpFormattingMetaclass('HelpTestCase', bases, {})
+
+
+class TestHelpBiggerOptionals(HelpTestCase):
+ """Make sure that argument help aligns when options are longer"""
+
+ parser_signature = Sig(prog='PROG', description='DESCRIPTION',
+ epilog='EPILOG', version='0.1')
+ argument_signatures = [
+ Sig('-x', action='store_true', help='X HELP'),
+ Sig('--y', help='Y HELP'),
+ Sig('foo', help='FOO HELP'),
+ Sig('bar', help='BAR HELP'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [-v] [-x] [--y Y] foo bar
+ '''
+ help = usage + '''\
+
+ DESCRIPTION
+
+ positional arguments:
+ foo FOO HELP
+ bar BAR HELP
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -v, --version show program's version number and exit
+ -x X HELP
+ --y Y Y HELP
+
+ EPILOG
+ '''
+ version = '''\
+ 0.1
+ '''
+
+
+class TestHelpBiggerOptionalGroups(HelpTestCase):
+ """Make sure that argument help aligns when options are longer"""
+
+ parser_signature = Sig(prog='PROG', description='DESCRIPTION',
+ epilog='EPILOG', version='0.1')
+ argument_signatures = [
+ Sig('-x', action='store_true', help='X HELP'),
+ Sig('--y', help='Y HELP'),
+ Sig('foo', help='FOO HELP'),
+ Sig('bar', help='BAR HELP'),
+ ]
+ argument_group_signatures = [
+ (Sig('GROUP TITLE', description='GROUP DESCRIPTION'), [
+ Sig('baz', help='BAZ HELP'),
+ Sig('-z', nargs='+', help='Z HELP')]),
+ ]
+ usage = '''\
+ usage: PROG [-h] [-v] [-x] [--y Y] [-z Z [Z ...]] foo bar baz
+ '''
+ help = usage + '''\
+
+ DESCRIPTION
+
+ positional arguments:
+ foo FOO HELP
+ bar BAR HELP
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -v, --version show program's version number and exit
+ -x X HELP
+ --y Y Y HELP
+
+ GROUP TITLE:
+ GROUP DESCRIPTION
+
+ baz BAZ HELP
+ -z Z [Z ...] Z HELP
+
+ EPILOG
+ '''
+ version = '''\
+ 0.1
+ '''
+
+
+class TestHelpBiggerPositionals(HelpTestCase):
+ """Make sure that help aligns when arguments are longer"""
+
+ parser_signature = Sig(usage='USAGE', description='DESCRIPTION')
+ argument_signatures = [
+ Sig('-x', action='store_true', help='X HELP'),
+ Sig('--y', help='Y HELP'),
+ Sig('ekiekiekifekang', help='EKI HELP'),
+ Sig('bar', help='BAR HELP'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: USAGE
+ '''
+ help = usage + '''\
+
+ DESCRIPTION
+
+ positional arguments:
+ ekiekiekifekang EKI HELP
+ bar BAR HELP
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x X HELP
+ --y Y Y HELP
+ '''
+
+ version = ''
+
+
+class TestHelpReformatting(HelpTestCase):
+ """Make sure that text after short names starts on the first line"""
+
+ parser_signature = Sig(
+ prog='PROG',
+ description=' oddly formatted\n'
+ 'description\n'
+ '\n'
+ 'that is so long that it should go onto multiple '
+ 'lines when wrapped')
+ argument_signatures = [
+ Sig('-x', metavar='XX', help='oddly\n'
+ ' formatted -x help'),
+ Sig('y', metavar='yyy', help='normal y help'),
+ ]
+ argument_group_signatures = [
+ (Sig('title', description='\n'
+ ' oddly formatted group\n'
+ '\n'
+ 'description'),
+ [Sig('-a', action='store_true',
+ help=' oddly \n'
+ 'formatted -a help \n'
+ ' again, so long that it should be wrapped over '
+ 'multiple lines')]),
+ ]
+ usage = '''\
+ usage: PROG [-h] [-x XX] [-a] yyy
+ '''
+ help = usage + '''\
+
+ oddly formatted description that is so long that it should go onto \
+multiple
+ lines when wrapped
+
+ positional arguments:
+ yyy normal y help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x XX oddly formatted -x help
+
+ title:
+ oddly formatted group description
+
+ -a oddly formatted -a help again, so long that it should \
+be wrapped
+ over multiple lines
+ '''
+ version = ''
+
+
+class TestHelpWrappingShortNames(HelpTestCase):
+ """Make sure that text after short names starts on the first line"""
+
+ parser_signature = Sig(prog='PROG', description= 'D\nD' * 30)
+ argument_signatures = [
+ Sig('-x', metavar='XX', help='XHH HX' * 20),
+ Sig('y', metavar='yyy', help='YH YH' * 20),
+ ]
+ argument_group_signatures = [
+ (Sig('ALPHAS'), [
+ Sig('-a', action='store_true', help='AHHH HHA' * 10)]),
+ ]
+ usage = '''\
+ usage: PROG [-h] [-x XX] [-a] yyy
+ '''
+ help = usage + '''\
+
+ D DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD \
+DD DD DD
+ DD DD DD DD D
+
+ positional arguments:
+ yyy YH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH \
+YHYH YHYH
+ YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x XX XHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH \
+HXXHH HXXHH
+ HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HX
+
+ ALPHAS:
+ -a AHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH \
+HHAAHHH
+ HHAAHHH HHAAHHH HHA
+ '''
+ version = ''
+
+
+class TestHelpWrappingLongNames(HelpTestCase):
+ """Make sure that text after long names starts on the next line"""
+
+ parser_signature = Sig(usage='USAGE', description= 'D D' * 30,
+ version='V V'*30)
+ argument_signatures = [
+ Sig('-x', metavar='X' * 25, help='XH XH' * 20),
+ Sig('y', metavar='y' * 25, help='YH YH' * 20),
+ ]
+ argument_group_signatures = [
+ (Sig('ALPHAS'), [
+ Sig('-a', metavar='A' * 25, help='AH AH' * 20),
+ Sig('z', metavar='z' * 25, help='ZH ZH' * 20)]),
+ ]
+ usage = '''\
+ usage: USAGE
+ '''
+ help = usage + '''\
+
+ D DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD \
+DD DD DD
+ DD DD DD DD D
+
+ positional arguments:
+ yyyyyyyyyyyyyyyyyyyyyyyyy
+ YH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH \
+YHYH YHYH
+ YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -v, --version show program's version number and exit
+ -x XXXXXXXXXXXXXXXXXXXXXXXXX
+ XH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH \
+XHXH XHXH
+ XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XH
+
+ ALPHAS:
+ -a AAAAAAAAAAAAAAAAAAAAAAAAA
+ AH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH \
+AHAH AHAH
+ AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AH
+ zzzzzzzzzzzzzzzzzzzzzzzzz
+ ZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH \
+ZHZH ZHZH
+ ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZH
+ '''
+ version = '''\
+ V VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV \
+VV VV VV
+ VV VV VV VV V
+ '''
+
+
+class TestHelpUsage(HelpTestCase):
+ """Test basic usage messages"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('-w', nargs='+', help='w'),
+ Sig('-x', nargs='*', help='x'),
+ Sig('a', help='a'),
+ Sig('b', help='b', nargs=2),
+ Sig('c', help='c', nargs='?'),
+ ]
+ argument_group_signatures = [
+ (Sig('group'), [
+ Sig('-y', nargs='?', help='y'),
+ Sig('-z', nargs=3, help='z'),
+ Sig('d', help='d', nargs='*'),
+ Sig('e', help='e', nargs='+'),
+ ])
+ ]
+ usage = '''\
+ usage: PROG [-h] [-w W [W ...]] [-x [X [X ...]]] [-y [Y]] [-z Z Z Z]
+ a b b [c] [d [d ...]] e [e ...]
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ a a
+ b b
+ c c
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -w W [W ...] w
+ -x [X [X ...]] x
+
+ group:
+ -y [Y] y
+ -z Z Z Z z
+ d d
+ e e
+ '''
+ version = ''
+
+
+class TestHelpOnlyUserGroups(HelpTestCase):
+ """Test basic usage messages"""
+
+ parser_signature = Sig(prog='PROG', add_help=False)
+ argument_signatures = []
+ argument_group_signatures = [
+ (Sig('xxxx'), [
+ Sig('-x', help='x'),
+ Sig('a', help='a'),
+ ]),
+ (Sig('yyyy'), [
+ Sig('b', help='b'),
+ Sig('-y', help='y'),
+ ]),
+ ]
+ usage = '''\
+ usage: PROG [-x X] [-y Y] a b
+ '''
+ help = usage + '''\
+
+ xxxx:
+ -x X x
+ a a
+
+ yyyy:
+ b b
+ -y Y y
+ '''
+ version = ''
+
+
+class TestHelpUsageLongProg(HelpTestCase):
+ """Test usage messages where the prog is long"""
+
+ parser_signature = Sig(prog='P' * 60)
+ argument_signatures = [
+ Sig('-w', metavar='W'),
+ Sig('-x', metavar='X'),
+ Sig('a'),
+ Sig('b'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+ [-h] [-w W] [-x X] a b
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ a
+ b
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -w W
+ -x X
+ '''
+ version = ''
+
+
+class TestHelpUsageLongProgOptionsWrap(HelpTestCase):
+ """Test usage messages where the prog is long and the optionals wrap"""
+
+ parser_signature = Sig(prog='P' * 60)
+ argument_signatures = [
+ Sig('-w', metavar='W' * 25),
+ Sig('-x', metavar='X' * 25),
+ Sig('-y', metavar='Y' * 25),
+ Sig('-z', metavar='Z' * 25),
+ Sig('a'),
+ Sig('b'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+ [-h] [-w WWWWWWWWWWWWWWWWWWWWWWWWW] \
+[-x XXXXXXXXXXXXXXXXXXXXXXXXX]
+ [-y YYYYYYYYYYYYYYYYYYYYYYYYY] [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
+ a b
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ a
+ b
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -w WWWWWWWWWWWWWWWWWWWWWWWWW
+ -x XXXXXXXXXXXXXXXXXXXXXXXXX
+ -y YYYYYYYYYYYYYYYYYYYYYYYYY
+ -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
+ '''
+ version = ''
+
+
+class TestHelpUsageLongProgPositionalsWrap(HelpTestCase):
+ """Test usage messages where the prog is long and the positionals wrap"""
+
+ parser_signature = Sig(prog='P' * 60, add_help=False)
+ argument_signatures = [
+ Sig('a' * 25),
+ Sig('b' * 25),
+ Sig('c' * 25),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
+ aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ aaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+ '''
+ version = ''
+
+
+class TestHelpUsageOptionalsWrap(HelpTestCase):
+ """Test usage messages where the optionals wrap"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('-w', metavar='W' * 25),
+ Sig('-x', metavar='X' * 25),
+ Sig('-y', metavar='Y' * 25),
+ Sig('-z', metavar='Z' * 25),
+ Sig('a'),
+ Sig('b'),
+ Sig('c'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [-w WWWWWWWWWWWWWWWWWWWWWWWWW] \
+[-x XXXXXXXXXXXXXXXXXXXXXXXXX]
+ [-y YYYYYYYYYYYYYYYYYYYYYYYYY] \
+[-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
+ a b c
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ a
+ b
+ c
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -w WWWWWWWWWWWWWWWWWWWWWWWWW
+ -x XXXXXXXXXXXXXXXXXXXXXXXXX
+ -y YYYYYYYYYYYYYYYYYYYYYYYYY
+ -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
+ '''
+ version = ''
+
+
+class TestHelpUsagePositionalsWrap(HelpTestCase):
+ """Test usage messages where the positionals wrap"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('-x'),
+ Sig('-y'),
+ Sig('-z'),
+ Sig('a' * 25),
+ Sig('b' * 25),
+ Sig('c' * 25),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [-x X] [-y Y] [-z Z]
+ aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ aaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x X
+ -y Y
+ -z Z
+ '''
+ version = ''
+
+
+class TestHelpUsageOptionalsPositionalsWrap(HelpTestCase):
+ """Test usage messages where the optionals and positionals wrap"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('-x', metavar='X' * 25),
+ Sig('-y', metavar='Y' * 25),
+ Sig('-z', metavar='Z' * 25),
+ Sig('a' * 25),
+ Sig('b' * 25),
+ Sig('c' * 25),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [-x XXXXXXXXXXXXXXXXXXXXXXXXX] \
+[-y YYYYYYYYYYYYYYYYYYYYYYYYY]
+ [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
+ aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ aaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x XXXXXXXXXXXXXXXXXXXXXXXXX
+ -y YYYYYYYYYYYYYYYYYYYYYYYYY
+ -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
+ '''
+ version = ''
+
+
+class TestHelpUsageOptionalsOnlyWrap(HelpTestCase):
+ """Test usage messages where there are only optionals and they wrap"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('-x', metavar='X' * 25),
+ Sig('-y', metavar='Y' * 25),
+ Sig('-z', metavar='Z' * 25),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [-x XXXXXXXXXXXXXXXXXXXXXXXXX] \
+[-y YYYYYYYYYYYYYYYYYYYYYYYYY]
+ [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
+ '''
+ help = usage + '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x XXXXXXXXXXXXXXXXXXXXXXXXX
+ -y YYYYYYYYYYYYYYYYYYYYYYYYY
+ -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
+ '''
+ version = ''
+
+
+class TestHelpUsagePositionalsOnlyWrap(HelpTestCase):
+ """Test usage messages where there are only positionals and they wrap"""
+
+ parser_signature = Sig(prog='PROG', add_help=False)
+ argument_signatures = [
+ Sig('a' * 25),
+ Sig('b' * 25),
+ Sig('c' * 25),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ aaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccccccccccccccccccccc
+ '''
+ version = ''
+
+
+class TestHelpVariableExpansion(HelpTestCase):
+ """Test that variables are expanded properly in help messages"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('-x', type=int,
+ help='x %(prog)s %(default)s %(type)s %%'),
+ Sig('-y', action='store_const', default=42, const='XXX',
+ help='y %(prog)s %(default)s %(const)s'),
+ Sig('--foo', choices='abc',
+ help='foo %(prog)s %(default)s %(choices)s'),
+ Sig('--bar', default='baz', choices=[1, 2], metavar='BBB',
+ help='bar %(prog)s %(default)s %(dest)s'),
+ Sig('spam', help='spam %(prog)s %(default)s'),
+ Sig('badger', default=0.5, help='badger %(prog)s %(default)s'),
+ ]
+ argument_group_signatures = [
+ (Sig('group'), [
+ Sig('-a', help='a %(prog)s %(default)s'),
+ Sig('-b', default=-1, help='b %(prog)s %(default)s'),
+ ])
+ ]
+ usage = ('''\
+ usage: PROG [-h] [-x X] [-y] [--foo {a,b,c}] [--bar BBB] [-a A] [-b B]
+ spam badger
+ ''')
+ help = usage + '''\
+
+ positional arguments:
+ spam spam PROG None
+ badger badger PROG 0.5
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x X x PROG None int %
+ -y y PROG 42 XXX
+ --foo {a,b,c} foo PROG None a, b, c
+ --bar BBB bar PROG baz bar
+
+ group:
+ -a A a PROG None
+ -b B b PROG -1
+ '''
+ version = ''
+
+
+class TestHelpVariableExpansionUsageSupplied(HelpTestCase):
+ """Test that variables are expanded properly when usage= is present"""
+
+ parser_signature = Sig(prog='PROG', usage='%(prog)s FOO')
+ argument_signatures = []
+ argument_group_signatures = []
+ usage = ('''\
+ usage: PROG FOO
+ ''')
+ help = usage + '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ '''
+ version = ''
+
+
+class TestHelpVariableExpansionNoArguments(HelpTestCase):
+ """Test that variables are expanded properly with no arguments"""
+
+ parser_signature = Sig(prog='PROG', add_help=False)
+ argument_signatures = []
+ argument_group_signatures = []
+ usage = ('''\
+ usage: PROG
+ ''')
+ help = usage
+ version = ''
+
+
+class TestHelpSuppressUsage(HelpTestCase):
+ """Test that items can be suppressed in usage messages"""
+
+ parser_signature = Sig(prog='PROG', usage=argparse.SUPPRESS)
+ argument_signatures = [
+ Sig('--foo', help='foo help'),
+ Sig('spam', help='spam help'),
+ ]
+ argument_group_signatures = []
+ help = '''\
+ positional arguments:
+ spam spam help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help
+ '''
+ usage = ''
+ version = ''
+
+
+class TestHelpSuppressOptional(HelpTestCase):
+ """Test that optional arguments can be suppressed in help messages"""
+
+ parser_signature = Sig(prog='PROG', add_help=False)
+ argument_signatures = [
+ Sig('--foo', help=argparse.SUPPRESS),
+ Sig('spam', help='spam help'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG spam
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ spam spam help
+ '''
+ version = ''
+
+
+class TestHelpSuppressOptionalGroup(HelpTestCase):
+ """Test that optional groups can be suppressed in help messages"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('--foo', help='foo help'),
+ Sig('spam', help='spam help'),
+ ]
+ argument_group_signatures = [
+ (Sig('group'), [Sig('--bar', help=argparse.SUPPRESS)]),
+ ]
+ usage = '''\
+ usage: PROG [-h] [--foo FOO] spam
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ spam spam help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help
+ '''
+ version = ''
+
+
+class TestHelpSuppressPositional(HelpTestCase):
+ """Test that positional arguments can be suppressed in help messages"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('--foo', help='foo help'),
+ Sig('spam', help=argparse.SUPPRESS),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [--foo FOO]
+ '''
+ help = usage + '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help
+ '''
+ version = ''
+
+
+class TestHelpRequiredOptional(HelpTestCase):
+ """Test that required options don't look optional"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('--foo', required=True, help='foo help'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] --foo FOO
+ '''
+ help = usage + '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help
+ '''
+ version = ''
+
+
+class TestHelpAlternatePrefixChars(HelpTestCase):
+ """Test that options display with different prefix characters"""
+
+ parser_signature = Sig(prog='PROG', prefix_chars='^;', add_help=False)
+ argument_signatures = [
+ Sig('^^foo', action='store_true', help='foo help'),
+ Sig(';b', ';;bar', help='bar help'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [^^foo] [;b BAR]
+ '''
+ help = usage + '''\
+
+ optional arguments:
+ ^^foo foo help
+ ;b BAR, ;;bar BAR bar help
+ '''
+ version = ''
+
+
+class TestHelpNoHelpOptional(HelpTestCase):
+ """Test that the --help argument can be suppressed help messages"""
+
+ parser_signature = Sig(prog='PROG', add_help=False)
+ argument_signatures = [
+ Sig('--foo', help='foo help'),
+ Sig('spam', help='spam help'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [--foo FOO] spam
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ spam spam help
+
+ optional arguments:
+ --foo FOO foo help
+ '''
+ version = ''
+
+
+class TestHelpVersionOptional(HelpTestCase):
+ """Test that the --version argument can be suppressed help messages"""
+
+ parser_signature = Sig(prog='PROG', version='1.0')
+ argument_signatures = [
+ Sig('--foo', help='foo help'),
+ Sig('spam', help='spam help'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [-v] [--foo FOO] spam
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ spam spam help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -v, --version show program's version number and exit
+ --foo FOO foo help
+ '''
+ version = '''\
+ 1.0
+ '''
+
+
+class TestHelpNone(HelpTestCase):
+ """Test that no errors occur if no help is specified"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('--foo'),
+ Sig('spam'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [--foo FOO] spam
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ spam
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO
+ '''
+ version = ''
+
+
+class TestHelpTupleMetavar(HelpTestCase):
+ """Test specifying metavar as a tuple"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('-w', help='w', nargs='+', metavar=('W1', 'W2')),
+ Sig('-x', help='x', nargs='*', metavar=('X1', 'X2')),
+ Sig('-y', help='y', nargs=3, metavar=('Y1', 'Y2', 'Y3')),
+ Sig('-z', help='z', nargs='?', metavar=('Z1', )),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [-w W1 [W2 ...]] [-x [X1 [X2 ...]]] [-y Y1 Y2 Y3] \
+[-z [Z1]]
+ '''
+ help = usage + '''\
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -w W1 [W2 ...] w
+ -x [X1 [X2 ...]] x
+ -y Y1 Y2 Y3 y
+ -z [Z1] z
+ '''
+ version = ''
+
+
+class TestHelpRawText(HelpTestCase):
+ """Test the RawTextHelpFormatter"""
+
+ parser_signature = Sig(
+ prog='PROG', formatter_class=argparse.RawTextHelpFormatter,
+ description='Keep the formatting\n'
+ ' exactly as it is written\n'
+ '\n'
+ 'here\n')
+
+ argument_signatures = [
+ Sig('--foo', help=' foo help should also\n'
+ 'appear as given here'),
+ Sig('spam', help='spam help'),
+ ]
+ argument_group_signatures = [
+ (Sig('title', description=' This text\n'
+ ' should be indented\n'
+ ' exactly like it is here\n'),
+ [Sig('--bar', help='bar help')]),
+ ]
+ usage = '''\
+ usage: PROG [-h] [--foo FOO] [--bar BAR] spam
+ '''
+ help = usage + '''\
+
+ Keep the formatting
+ exactly as it is written
+
+ here
+
+ positional arguments:
+ spam spam help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help should also
+ appear as given here
+
+ title:
+ This text
+ should be indented
+ exactly like it is here
+
+ --bar BAR bar help
+ '''
+ version = ''
+
+
+class TestHelpRawDescription(HelpTestCase):
+ """Test the RawTextHelpFormatter"""
+
+ parser_signature = Sig(
+ prog='PROG', formatter_class=argparse.RawDescriptionHelpFormatter,
+ description='Keep the formatting\n'
+ ' exactly as it is written\n'
+ '\n'
+ 'here\n')
+
+ argument_signatures = [
+ Sig('--foo', help=' foo help should not\n'
+ ' retain this odd formatting'),
+ Sig('spam', help='spam help'),
+ ]
+ argument_group_signatures = [
+ (Sig('title', description=' This text\n'
+ ' should be indented\n'
+ ' exactly like it is here\n'),
+ [Sig('--bar', help='bar help')]),
+ ]
+ usage = '''\
+ usage: PROG [-h] [--foo FOO] [--bar BAR] spam
+ '''
+ help = usage + '''\
+
+ Keep the formatting
+ exactly as it is written
+
+ here
+
+ positional arguments:
+ spam spam help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help should not retain this odd formatting
+
+ title:
+ This text
+ should be indented
+ exactly like it is here
+
+ --bar BAR bar help
+ '''
+ version = ''
+
+
+class TestHelpArgumentDefaults(HelpTestCase):
+ """Test the ArgumentDefaultsHelpFormatter"""
+
+ parser_signature = Sig(
+ prog='PROG', formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+ description='description')
+
+ argument_signatures = [
+ Sig('--foo', help='foo help - oh and by the way, %(default)s'),
+ Sig('--bar', action='store_true', help='bar help'),
+ Sig('spam', help='spam help'),
+ Sig('badger', nargs='?', default='wooden', help='badger help'),
+ ]
+ argument_group_signatures = [
+ (Sig('title', description='description'),
+ [Sig('--baz', type=int, default=42, help='baz help')]),
+ ]
+ usage = '''\
+ usage: PROG [-h] [--foo FOO] [--bar] [--baz BAZ] spam [badger]
+ '''
+ help = usage + '''\
+
+ description
+
+ positional arguments:
+ spam spam help
+ badger badger help (default: wooden)
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help - oh and by the way, None
+ --bar bar help (default: False)
+
+ title:
+ description
+
+ --baz BAZ baz help (default: 42)
+ '''
+ version = ''
+
+class TestHelpVersionAction(HelpTestCase):
+ """Test the default help for the version action"""
+
+ parser_signature = Sig(prog='PROG', description='description')
+ argument_signatures = [Sig('-V', '--version', action='version', version='3.6')]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [-V]
+ '''
+ help = usage + '''\
+
+ description
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -V, --version show program's version number and exit
+ '''
+ version = ''
+
+# =====================================
+# Optional/Positional constructor tests
+# =====================================
+
+class TestInvalidArgumentConstructors(TestCase):
+ """Test a bunch of invalid Argument constructors"""
+
+ def assertTypeError(self, *args, **kwargs):
+ parser = argparse.ArgumentParser()
+ self.assertRaises(TypeError, parser.add_argument,
+ *args, **kwargs)
+
+ def assertValueError(self, *args, **kwargs):
+ parser = argparse.ArgumentParser()
+ self.assertRaises(ValueError, parser.add_argument,
+ *args, **kwargs)
+
+ def test_invalid_keyword_arguments(self):
+ self.assertTypeError('-x', bar=None)
+ self.assertTypeError('-y', callback='foo')
+ self.assertTypeError('-y', callback_args=())
+ self.assertTypeError('-y', callback_kwargs={})
+
+ def test_missing_destination(self):
+ self.assertTypeError()
+ for action in ['append', 'store']:
+ self.assertTypeError(action=action)
+
+ def test_invalid_option_strings(self):
+ self.assertValueError('--')
+ self.assertValueError('---')
+
+ def test_invalid_type(self):
+ self.assertValueError('--foo', type='int')
+
+ def test_invalid_action(self):
+ self.assertValueError('-x', action='foo')
+ self.assertValueError('foo', action='baz')
+ parser = argparse.ArgumentParser()
+ try:
+ parser.add_argument("--foo", action="store-true")
+ except ValueError:
+ e = sys.exc_info()[1]
+ expected = 'unknown action'
+ msg = 'expected %r, found %r' % (expected, e)
+ self.assertTrue(expected in str(e), msg)
+
+ def test_multiple_dest(self):
+ parser = argparse.ArgumentParser()
+ parser.add_argument(dest='foo')
+ try:
+ parser.add_argument('bar', dest='baz')
+ except ValueError:
+ e = sys.exc_info()[1]
+ expected = 'dest supplied twice for positional argument'
+ msg = 'expected %r, found %r' % (expected, e)
+ self.assertTrue(expected in str(e), msg)
+
+ def test_no_argument_actions(self):
+ for action in ['store_const', 'store_true', 'store_false',
+ 'append_const', 'count']:
+ for attrs in [dict(type=int), dict(nargs='+'),
+ dict(choices='ab')]:
+ self.assertTypeError('-x', action=action, **attrs)
+
+ def test_no_argument_no_const_actions(self):
+ # options with zero arguments
+ for action in ['store_true', 'store_false', 'count']:
+
+ # const is always disallowed
+ self.assertTypeError('-x', const='foo', action=action)
+
+ # nargs is always disallowed
+ self.assertTypeError('-x', nargs='*', action=action)
+
+ def test_more_than_one_argument_actions(self):
+ for action in ['store', 'append']:
+
+ # nargs=0 is disallowed
+ self.assertValueError('-x', nargs=0, action=action)
+ self.assertValueError('spam', nargs=0, action=action)
+
+ # const is disallowed with non-optional arguments
+ for nargs in [1, '*', '+']:
+ self.assertValueError('-x', const='foo',
+ nargs=nargs, action=action)
+ self.assertValueError('spam', const='foo',
+ nargs=nargs, action=action)
+
+ def test_required_const_actions(self):
+ for action in ['store_const', 'append_const']:
+
+ # nargs is always disallowed
+ self.assertTypeError('-x', nargs='+', action=action)
+
+ def test_parsers_action_missing_params(self):
+ self.assertTypeError('command', action='parsers')
+ self.assertTypeError('command', action='parsers', prog='PROG')
+ self.assertTypeError('command', action='parsers',
+ parser_class=argparse.ArgumentParser)
+
+ def test_required_positional(self):
+ self.assertTypeError('foo', required=True)
+
+ def test_user_defined_action(self):
+
+ class Success(Exception):
+ pass
+
+ class Action(object):
+
+ def __init__(self,
+ option_strings,
+ dest,
+ const,
+ default,
+ required=False):
+ if dest == 'spam':
+ if const is Success:
+ if default is Success:
+ raise Success()
+
+ def __call__(self, *args, **kwargs):
+ pass
+
+ parser = argparse.ArgumentParser()
+ self.assertRaises(Success, parser.add_argument, '--spam',
+ action=Action, default=Success, const=Success)
+ self.assertRaises(Success, parser.add_argument, 'spam',
+ action=Action, default=Success, const=Success)
+
+# ================================
+# Actions returned by add_argument
+# ================================
+
+class TestActionsReturned(TestCase):
+
+ def test_dest(self):
+ parser = argparse.ArgumentParser()
+ action = parser.add_argument('--foo')
+ self.assertEqual(action.dest, 'foo')
+ action = parser.add_argument('-b', '--bar')
+ self.assertEqual(action.dest, 'bar')
+ action = parser.add_argument('-x', '-y')
+ self.assertEqual(action.dest, 'x')
+
+ def test_misc(self):
+ parser = argparse.ArgumentParser()
+ action = parser.add_argument('--foo', nargs='?', const=42,
+ default=84, type=int, choices=[1, 2],
+ help='FOO', metavar='BAR', dest='baz')
+ self.assertEqual(action.nargs, '?')
+ self.assertEqual(action.const, 42)
+ self.assertEqual(action.default, 84)
+ self.assertEqual(action.type, int)
+ self.assertEqual(action.choices, [1, 2])
+ self.assertEqual(action.help, 'FOO')
+ self.assertEqual(action.metavar, 'BAR')
+ self.assertEqual(action.dest, 'baz')
+
+
+# ================================
+# Argument conflict handling tests
+# ================================
+
+class TestConflictHandling(TestCase):
+
+ def test_bad_type(self):
+ self.assertRaises(ValueError, argparse.ArgumentParser,
+ conflict_handler='foo')
+
+ def test_conflict_error(self):
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-x')
+ self.assertRaises(argparse.ArgumentError,
+ parser.add_argument, '-x')
+ parser.add_argument('--spam')
+ self.assertRaises(argparse.ArgumentError,
+ parser.add_argument, '--spam')
+
+ def test_resolve_error(self):
+ get_parser = argparse.ArgumentParser
+ parser = get_parser(prog='PROG', conflict_handler='resolve')
+
+ parser.add_argument('-x', help='OLD X')
+ parser.add_argument('-x', help='NEW X')
+ self.assertEqual(parser.format_help(), textwrap.dedent('''\
+ usage: PROG [-h] [-x X]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x X NEW X
+ '''))
+
+ parser.add_argument('--spam', metavar='OLD_SPAM')
+ parser.add_argument('--spam', metavar='NEW_SPAM')
+ self.assertEqual(parser.format_help(), textwrap.dedent('''\
+ usage: PROG [-h] [-x X] [--spam NEW_SPAM]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x X NEW X
+ --spam NEW_SPAM
+ '''))
+
+
+# =============================
+# Help and Version option tests
+# =============================
+
+class TestOptionalsHelpVersionActions(TestCase):
+ """Test the help and version actions"""
+
+ def _get_error(self, func, *args, **kwargs):
+ try:
+ func(*args, **kwargs)
+ except ArgumentParserError:
+ return sys.exc_info()[1]
+ else:
+ self.assertRaises(ArgumentParserError, func, *args, **kwargs)
+
+ def assertPrintHelpExit(self, parser, args_str):
+ self.assertEqual(
+ parser.format_help(),
+ self._get_error(parser.parse_args, args_str.split()).stdout)
+
+ def assertPrintVersionExit(self, parser, args_str):
+ self.assertEqual(
+ parser.format_version(),
+ self._get_error(parser.parse_args, args_str.split()).stderr)
+
+ def assertArgumentParserError(self, parser, *args):
+ self.assertRaises(ArgumentParserError, parser.parse_args, args)
+
+ def test_version(self):
+ parser = ErrorRaisingArgumentParser(version='1.0')
+ self.assertPrintHelpExit(parser, '-h')
+ self.assertPrintHelpExit(parser, '--help')
+ self.assertPrintVersionExit(parser, '-v')
+ self.assertPrintVersionExit(parser, '--version')
+
+ def test_version_format(self):
+ parser = ErrorRaisingArgumentParser(prog='PPP', version='%(prog)s 3.5')
+ msg = self._get_error(parser.parse_args, ['-v']).stderr
+ self.assertEqual('PPP 3.5\n', msg)
+
+ def test_version_no_help(self):
+ parser = ErrorRaisingArgumentParser(add_help=False, version='1.0')
+ self.assertArgumentParserError(parser, '-h')
+ self.assertArgumentParserError(parser, '--help')
+ self.assertPrintVersionExit(parser, '-v')
+ self.assertPrintVersionExit(parser, '--version')
+
+ def test_version_action(self):
+ parser = ErrorRaisingArgumentParser(prog='XXX')
+ parser.add_argument('-V', action='version', version='%(prog)s 3.7')
+ msg = self._get_error(parser.parse_args, ['-V']).stderr
+ self.assertEqual('XXX 3.7\n', msg)
+
+ def test_no_help(self):
+ parser = ErrorRaisingArgumentParser(add_help=False)
+ self.assertArgumentParserError(parser, '-h')
+ self.assertArgumentParserError(parser, '--help')
+ self.assertArgumentParserError(parser, '-v')
+ self.assertArgumentParserError(parser, '--version')
+
+ def test_alternate_help_version(self):
+ parser = ErrorRaisingArgumentParser()
+ parser.add_argument('-x', action='help')
+ parser.add_argument('-y', action='version')
+ self.assertPrintHelpExit(parser, '-x')
+ self.assertPrintVersionExit(parser, '-y')
+ self.assertArgumentParserError(parser, '-v')
+ self.assertArgumentParserError(parser, '--version')
+
+ def test_help_version_extra_arguments(self):
+ parser = ErrorRaisingArgumentParser(version='1.0')
+ parser.add_argument('-x', action='store_true')
+ parser.add_argument('y')
+
+ # try all combinations of valid prefixes and suffixes
+ valid_prefixes = ['', '-x', 'foo', '-x bar', 'baz -x']
+ valid_suffixes = valid_prefixes + ['--bad-option', 'foo bar baz']
+ for prefix in valid_prefixes:
+ for suffix in valid_suffixes:
+ format = '%s %%s %s' % (prefix, suffix)
+ self.assertPrintHelpExit(parser, format % '-h')
+ self.assertPrintHelpExit(parser, format % '--help')
+ self.assertPrintVersionExit(parser, format % '-v')
+ self.assertPrintVersionExit(parser, format % '--version')
+
+
+# ======================
+# str() and repr() tests
+# ======================
+
+class TestStrings(TestCase):
+ """Test str() and repr() on Optionals and Positionals"""
+
+ def assertStringEqual(self, obj, result_string):
+ for func in [str, repr]:
+ self.assertEqual(func(obj), result_string)
+
+ def test_optional(self):
+ option = argparse.Action(
+ option_strings=['--foo', '-a', '-b'],
+ dest='b',
+ type='int',
+ nargs='+',
+ default=42,
+ choices=[1, 2, 3],
+ help='HELP',
+ metavar='METAVAR')
+ string = (
+ "Action(option_strings=['--foo', '-a', '-b'], dest='b', "
+ "nargs='+', const=None, default=42, type='int', "
+ "choices=[1, 2, 3], help='HELP', metavar='METAVAR')")
+ self.assertStringEqual(option, string)
+
+ def test_argument(self):
+ argument = argparse.Action(
+ option_strings=[],
+ dest='x',
+ type=float,
+ nargs='?',
+ default=2.5,
+ choices=[0.5, 1.5, 2.5],
+ help='H HH H',
+ metavar='MV MV MV')
+ string = (
+ "Action(option_strings=[], dest='x', nargs='?', "
+ "const=None, default=2.5, type=%r, choices=[0.5, 1.5, 2.5], "
+ "help='H HH H', metavar='MV MV MV')" % float)
+ self.assertStringEqual(argument, string)
+
+ def test_namespace(self):
+ ns = argparse.Namespace(foo=42, bar='spam')
+ string = "Namespace(bar='spam', foo=42)"
+ self.assertStringEqual(ns, string)
+
+ def test_parser(self):
+ parser = argparse.ArgumentParser(prog='PROG')
+ string = (
+ "ArgumentParser(prog='PROG', usage=None, description=None, "
+ "version=None, formatter_class=%r, conflict_handler='error', "
+ "add_help=True)" % argparse.HelpFormatter)
+ self.assertStringEqual(parser, string)
+
+# ===============
+# Namespace tests
+# ===============
+
+class TestNamespace(TestCase):
+
+ def test_constructor(self):
+ ns = argparse.Namespace()
+ self.assertRaises(AttributeError, getattr, ns, 'x')
+
+ ns = argparse.Namespace(a=42, b='spam')
+ self.assertEqual(ns.a, 42)
+ self.assertEqual(ns.b, 'spam')
+
+ def test_equality(self):
+ ns1 = argparse.Namespace(a=1, b=2)
+ ns2 = argparse.Namespace(b=2, a=1)
+ ns3 = argparse.Namespace(a=1)
+ ns4 = argparse.Namespace(b=2)
+
+ self.assertEqual(ns1, ns2)
+ self.assertNotEqual(ns1, ns3)
+ self.assertNotEqual(ns1, ns4)
+ self.assertNotEqual(ns2, ns3)
+ self.assertNotEqual(ns2, ns4)
+ self.assertTrue(ns1 != ns3)
+ self.assertTrue(ns1 != ns4)
+ self.assertTrue(ns2 != ns3)
+ self.assertTrue(ns2 != ns4)
+
+
+# ===================
+# File encoding tests
+# ===================
+
+class TestEncoding(TestCase):
+
+ def _test_module_encoding(self, path):
+ path, _ = os.path.splitext(path)
+ path += ".py"
+ with codecs.open(path, 'r', 'utf8') as f:
+ f.read()
+
+ def test_argparse_module_encoding(self):
+ self._test_module_encoding(argparse.__file__)
+
+ def test_test_argparse_module_encoding(self):
+ self._test_module_encoding(__file__)
+
+# ===================
+# ArgumentError tests
+# ===================
+
+class TestArgumentError(TestCase):
+
+ def test_argument_error(self):
+ msg = "my error here"
+ error = argparse.ArgumentError(None, msg)
+ self.assertEqual(str(error), msg)
+
+# =======================
+# ArgumentTypeError tests
+# =======================
+
+class TestArgumentTypeError(TestCase):
+
+ def test_argument_type_error(self):
+
+ def spam(string):
+ raise argparse.ArgumentTypeError('spam!')
+
+ parser = ErrorRaisingArgumentParser(prog='PROG', add_help=False)
+ parser.add_argument('x', type=spam)
+ try:
+ parser.parse_args(['XXX'])
+ except ArgumentParserError:
+ expected = 'usage: PROG x\nPROG: error: argument x: spam!\n'
+ msg = sys.exc_info()[1].stderr
+ self.assertEqual(expected, msg)
+ else:
+ self.fail()
+
+# ======================
+# parse_known_args tests
+# ======================
+
+class TestParseKnownArgs(TestCase):
+
+ def test_optionals(self):
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--foo')
+ args, extras = parser.parse_known_args('--foo F --bar --baz'.split())
+ self.assertEqual(NS(foo='F'), args)
+ self.assertEqual(['--bar', '--baz'], extras)
+
+ def test_mixed(self):
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-v', nargs='?', const=1, type=int)
+ parser.add_argument('--spam', action='store_false')
+ parser.add_argument('badger')
+
+ argv = ["B", "C", "--foo", "-v", "3", "4"]
+ args, extras = parser.parse_known_args(argv)
+ self.assertEqual(NS(v=3, spam=True, badger="B"), args)
+ self.assertEqual(["C", "--foo", "4"], extras)
+
+# ============================
+# from argparse import * tests
+# ============================
+
+class TestImportStar(TestCase):
+
+ def test(self):
+ for name in argparse.__all__:
+ self.assertTrue(hasattr(argparse, name))
+
+ def test_all_exports_everything_but_modules(self):
+ items = [
+ name
+ for name, value in vars(argparse).items()
+ if not (name.startswith("_") or name == 'ngettext')
+ if not inspect.ismodule(value)
+ ]
+ self.assertEqual(sorted(items), sorted(argparse.__all__))
+
+def test_main():
+ # silence warnings about version argument - these are expected
+ with support.check_warnings(
+ ('The "version" argument to ArgumentParser is deprecated.',
+ DeprecationWarning),
+ ('The (format|print)_version method is deprecated',
+ DeprecationWarning)):
+ support.run_unittest(__name__)
+ # Remove global references to avoid looking like we have refleaks.
+ RFile.seen = {}
+ WFile.seen = set()
+
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 62997d7300..5190c357ea 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -1,21 +1,28 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test the arraymodule.
Roger E. Masse
"""
import unittest
from test import support
-from weakref import proxy
-import array, io, math
-from pickle import loads, dumps, HIGHEST_PROTOCOL
+import weakref
+import pickle
import operator
+import io
+import math
+import struct
+import warnings
+
+import array
+from array import _array_reconstructor as array_reconstructor
+
class ArraySubclass(array.array):
pass
class ArraySubclassWithKwargs(array.array):
def __init__(self, typecode, newarg=None):
- array.array.__init__(self, typecode)
+ array.array.__init__(self)
tests = [] # list to accumulate all tests
typecodes = "ubBhHiIlLfd"
@@ -30,6 +37,137 @@ class BadConstructorTest(unittest.TestCase):
tests.append(BadConstructorTest)
+# Machine format codes.
+#
+# Search for "enum machine_format_code" in Modules/arraymodule.c to get the
+# authoritative values.
+UNKNOWN_FORMAT = -1
+UNSIGNED_INT8 = 0
+SIGNED_INT8 = 1
+UNSIGNED_INT16_LE = 2
+UNSIGNED_INT16_BE = 3
+SIGNED_INT16_LE = 4
+SIGNED_INT16_BE = 5
+UNSIGNED_INT32_LE = 6
+UNSIGNED_INT32_BE = 7
+SIGNED_INT32_LE = 8
+SIGNED_INT32_BE = 9
+UNSIGNED_INT64_LE = 10
+UNSIGNED_INT64_BE = 11
+SIGNED_INT64_LE = 12
+SIGNED_INT64_BE = 13
+IEEE_754_FLOAT_LE = 14
+IEEE_754_FLOAT_BE = 15
+IEEE_754_DOUBLE_LE = 16
+IEEE_754_DOUBLE_BE = 17
+UTF16_LE = 18
+UTF16_BE = 19
+UTF32_LE = 20
+UTF32_BE = 21
+
+class ArrayReconstructorTest(unittest.TestCase):
+
+ def test_error(self):
+ self.assertRaises(TypeError, array_reconstructor,
+ "", "b", 0, b"")
+ self.assertRaises(TypeError, array_reconstructor,
+ str, "b", 0, b"")
+ self.assertRaises(TypeError, array_reconstructor,
+ array.array, "b", '', b"")
+ self.assertRaises(TypeError, array_reconstructor,
+ array.array, "b", 0, "")
+ self.assertRaises(ValueError, array_reconstructor,
+ array.array, "?", 0, b"")
+ self.assertRaises(ValueError, array_reconstructor,
+ array.array, "b", UNKNOWN_FORMAT, b"")
+ self.assertRaises(ValueError, array_reconstructor,
+ array.array, "b", 22, b"")
+ self.assertRaises(ValueError, array_reconstructor,
+ array.array, "d", 16, b"a")
+
+ def test_numbers(self):
+ testcases = (
+ (['B', 'H', 'I', 'L'], UNSIGNED_INT8, '=BBBB',
+ [0x80, 0x7f, 0, 0xff]),
+ (['b', 'h', 'i', 'l'], SIGNED_INT8, '=bbb',
+ [-0x80, 0x7f, 0]),
+ (['H', 'I', 'L'], UNSIGNED_INT16_LE, '<HHHH',
+ [0x8000, 0x7fff, 0, 0xffff]),
+ (['H', 'I', 'L'], UNSIGNED_INT16_BE, '>HHHH',
+ [0x8000, 0x7fff, 0, 0xffff]),
+ (['h', 'i', 'l'], SIGNED_INT16_LE, '<hhh',
+ [-0x8000, 0x7fff, 0]),
+ (['h', 'i', 'l'], SIGNED_INT16_BE, '>hhh',
+ [-0x8000, 0x7fff, 0]),
+ (['I', 'L'], UNSIGNED_INT32_LE, '<IIII',
+ [1<<31, (1<<31)-1, 0, (1<<32)-1]),
+ (['I', 'L'], UNSIGNED_INT32_BE, '>IIII',
+ [1<<31, (1<<31)-1, 0, (1<<32)-1]),
+ (['i', 'l'], SIGNED_INT32_LE, '<iii',
+ [-1<<31, (1<<31)-1, 0]),
+ (['i', 'l'], SIGNED_INT32_BE, '>iii',
+ [-1<<31, (1<<31)-1, 0]),
+ (['L'], UNSIGNED_INT64_LE, '<QQQQ',
+ [1<<31, (1<<31)-1, 0, (1<<32)-1]),
+ (['L'], UNSIGNED_INT64_BE, '>QQQQ',
+ [1<<31, (1<<31)-1, 0, (1<<32)-1]),
+ (['l'], SIGNED_INT64_LE, '<qqq',
+ [-1<<31, (1<<31)-1, 0]),
+ (['l'], SIGNED_INT64_BE, '>qqq',
+ [-1<<31, (1<<31)-1, 0]),
+ # The following tests for INT64 will raise an OverflowError
+ # when run on a 32-bit machine. The tests are simply skipped
+ # in that case.
+ (['L'], UNSIGNED_INT64_LE, '<QQQQ',
+ [1<<63, (1<<63)-1, 0, (1<<64)-1]),
+ (['L'], UNSIGNED_INT64_BE, '>QQQQ',
+ [1<<63, (1<<63)-1, 0, (1<<64)-1]),
+ (['l'], SIGNED_INT64_LE, '<qqq',
+ [-1<<63, (1<<63)-1, 0]),
+ (['l'], SIGNED_INT64_BE, '>qqq',
+ [-1<<63, (1<<63)-1, 0]),
+ (['f'], IEEE_754_FLOAT_LE, '<ffff',
+ [16711938.0, float('inf'), float('-inf'), -0.0]),
+ (['f'], IEEE_754_FLOAT_BE, '>ffff',
+ [16711938.0, float('inf'), float('-inf'), -0.0]),
+ (['d'], IEEE_754_DOUBLE_LE, '<dddd',
+ [9006104071832581.0, float('inf'), float('-inf'), -0.0]),
+ (['d'], IEEE_754_DOUBLE_BE, '>dddd',
+ [9006104071832581.0, float('inf'), float('-inf'), -0.0])
+ )
+ for testcase in testcases:
+ valid_typecodes, mformat_code, struct_fmt, values = testcase
+ arraystr = struct.pack(struct_fmt, *values)
+ for typecode in valid_typecodes:
+ try:
+ a = array.array(typecode, values)
+ except OverflowError:
+ continue # Skip this test case.
+ b = array_reconstructor(
+ array.array, typecode, mformat_code, arraystr)
+ self.assertEqual(a, b,
+ msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
+
+ def test_unicode(self):
+ teststr = "Bonne Journ\xe9e \U0002030a\U00020347"
+ testcases = (
+ (UTF16_LE, "UTF-16-LE"),
+ (UTF16_BE, "UTF-16-BE"),
+ (UTF32_LE, "UTF-32-LE"),
+ (UTF32_BE, "UTF-32-BE")
+ )
+ for testcase in testcases:
+ mformat_code, encoding = testcase
+ a = array.array('u', teststr)
+ b = array_reconstructor(
+ array.array, 'u', mformat_code, teststr.encode(encoding))
+ self.assertEqual(a, b,
+ msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
+
+
+tests.append(ArrayReconstructorTest)
+
+
class BaseTest(unittest.TestCase):
# Required class attributes (provided by subclasses
# typecode: the typecode to test
@@ -64,10 +202,10 @@ class BaseTest(unittest.TestCase):
a = array.array(self.typecode, self.example)
self.assertRaises(TypeError, a.buffer_info, 42)
bi = a.buffer_info()
- self.assertTrue(isinstance(bi, tuple))
+ self.assertIsInstance(bi, tuple)
self.assertEqual(len(bi), 2)
- self.assertTrue(isinstance(bi[0], int))
- self.assertTrue(isinstance(bi[1], int))
+ self.assertIsInstance(bi[0], int)
+ self.assertIsInstance(bi[1], int)
self.assertEqual(bi[1], len(a))
def test_byteswap(self):
@@ -97,31 +235,38 @@ class BaseTest(unittest.TestCase):
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
+ def test_reduce_ex(self):
+ a = array.array(self.typecode, self.example)
+ for protocol in range(3):
+ self.assertIs(a.__reduce_ex__(protocol)[0], array.array)
+ for protocol in range(3, pickle.HIGHEST_PROTOCOL):
+ self.assertIs(a.__reduce_ex__(protocol)[0], array_reconstructor)
+
def test_pickle(self):
- for protocol in range(HIGHEST_PROTOCOL + 1):
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
a = array.array(self.typecode, self.example)
- b = loads(dumps(a, protocol))
+ b = pickle.loads(pickle.dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
a = ArraySubclass(self.typecode, self.example)
a.x = 10
- b = loads(dumps(a, protocol))
+ b = pickle.loads(pickle.dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
self.assertEqual(a.x, b.x)
self.assertEqual(type(a), type(b))
def test_pickle_for_empty_array(self):
- for protocol in range(HIGHEST_PROTOCOL + 1):
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
a = array.array(self.typecode)
- b = loads(dumps(a, protocol))
+ b = pickle.loads(pickle.dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
a = ArraySubclass(self.typecode)
a.x = 10
- b = loads(dumps(a, protocol))
+ b = pickle.loads(pickle.dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
self.assertEqual(a.x, b.x)
@@ -193,6 +338,25 @@ class BaseTest(unittest.TestCase):
f.close()
support.unlink(support.TESTFN)
+ def test_filewrite(self):
+ a = array.array(self.typecode, 2*self.example)
+ f = open(support.TESTFN, 'wb')
+ try:
+ f.write(a)
+ f.close()
+ b = array.array(self.typecode)
+ f = open(support.TESTFN, 'rb')
+ b.fromfile(f, len(self.example))
+ self.assertEqual(b, array.array(self.typecode, self.example))
+ self.assertNotEqual(a, b)
+ b.fromfile(f, len(self.example))
+ self.assertEqual(a, b)
+ f.close()
+ finally:
+ if not f.closed:
+ f.close()
+ support.unlink(support.TESTFN)
+
def test_tofromlist(self):
a = array.array(self.typecode, 2*self.example)
b = array.array(self.typecode)
@@ -204,15 +368,40 @@ class BaseTest(unittest.TestCase):
self.assertEqual(a, b)
def test_tofromstring(self):
+ nb_warnings = 4
+ with warnings.catch_warnings(record=True) as r:
+ warnings.filterwarnings("always",
+ message=r"(to|from)string\(\) is deprecated",
+ category=DeprecationWarning)
+ a = array.array(self.typecode, 2*self.example)
+ b = array.array(self.typecode)
+ self.assertRaises(TypeError, a.tostring, 42)
+ self.assertRaises(TypeError, b.fromstring)
+ self.assertRaises(TypeError, b.fromstring, 42)
+ b.fromstring(a.tostring())
+ self.assertEqual(a, b)
+ if a.itemsize>1:
+ self.assertRaises(ValueError, b.fromstring, "x")
+ nb_warnings += 1
+ self.assertEqual(len(r), nb_warnings)
+
+ def test_tofrombytes(self):
a = array.array(self.typecode, 2*self.example)
b = array.array(self.typecode)
- self.assertRaises(TypeError, a.tostring, 42)
- self.assertRaises(TypeError, b.fromstring)
- self.assertRaises(TypeError, b.fromstring, 42)
- b.fromstring(a.tostring())
+ self.assertRaises(TypeError, a.tobytes, 42)
+ self.assertRaises(TypeError, b.frombytes)
+ self.assertRaises(TypeError, b.frombytes, 42)
+ b.frombytes(a.tobytes())
+ c = array.array(self.typecode, bytearray(a.tobytes()))
self.assertEqual(a, b)
+ self.assertEqual(a, c)
if a.itemsize>1:
- self.assertRaises(ValueError, b.fromstring, "x")
+ self.assertRaises(ValueError, b.frombytes, b"x")
+
+ def test_fromarray(self):
+ a = array.array(self.typecode, self.example)
+ b = array.array(self.typecode, a)
+ self.assertEqual(a, b)
def test_repr(self):
a = array.array(self.typecode, 2*self.example)
@@ -320,6 +509,12 @@ class BaseTest(unittest.TestCase):
array.array(self.typecode)
)
+ a = 5 * array.array(self.typecode, self.example[:1])
+ self.assertEqual(
+ a,
+ array.array(self.typecode, [a[0]] * 5)
+ )
+
self.assertRaises(TypeError, a.__mul__, "bad")
def test_imul(self):
@@ -735,8 +930,8 @@ class BaseTest(unittest.TestCase):
a = array.array(self.typecode, self.example)
m = memoryview(a)
expected = m.tobytes()
- self.assertEqual(a.tostring(), expected)
- self.assertEqual(a.tostring()[0], expected[0])
+ self.assertEqual(a.tobytes(), expected)
+ self.assertEqual(a.tobytes()[0], expected[0])
# Resizing is forbidden when there are buffer exports.
# For issue 4509, we also check after each error that
# the array was not modified.
@@ -750,7 +945,7 @@ class BaseTest(unittest.TestCase):
self.assertEqual(m.tobytes(), expected)
self.assertRaises(BufferError, a.fromlist, a.tolist())
self.assertEqual(m.tobytes(), expected)
- self.assertRaises(BufferError, a.fromstring, a.tostring())
+ self.assertRaises(BufferError, a.frombytes, a.tobytes())
self.assertEqual(m.tobytes(), expected)
if self.typecode == 'u':
self.assertRaises(BufferError, a.fromunicode, a.tounicode())
@@ -768,8 +963,8 @@ class BaseTest(unittest.TestCase):
def test_weakref(self):
s = array.array(self.typecode, self.example)
- p = proxy(s)
- self.assertEqual(p.tostring(), s.tostring())
+ p = weakref.proxy(s)
+ self.assertEqual(p.tobytes(), s.tobytes())
s = None
self.assertRaises(ReferenceError, len, p)
@@ -923,6 +1118,11 @@ class NumberTest(BaseTest):
self.assertRaises(AttributeError, setattr, a, "color", "blue")
+ def test_frombytearray(self):
+ a = array.array('b', range(10))
+ b = array.array(self.typecode, a)
+ self.assertEqual(a, b)
+
class SignedNumberTest(NumberTest):
example = [-1, 0, 1, 42, 0x7f]
smallerexample = [-1, 0, 1, 42, 0x7e]
@@ -947,6 +1147,23 @@ class UnsignedNumberTest(NumberTest):
upper = int(pow(2, a.itemsize * 8)) - 1
self.check_overflow(lower, upper)
+ def test_bytes_extend(self):
+ s = bytes(self.example)
+
+ a = array.array(self.typecode, self.example)
+ a.extend(s)
+ self.assertEqual(
+ a,
+ array.array(self.typecode, self.example+self.example)
+ )
+
+ a = array.array(self.typecode, self.example)
+ a.extend(bytearray(reversed(s)))
+ self.assertEqual(
+ a,
+ array.array(self.typecode, self.example+self.example[::-1])
+ )
+
class ByteTest(SignedNumberTest):
typecode = 'b'
@@ -1009,7 +1226,7 @@ class FPTest(NumberTest):
# On alphas treating the byte swapped bit patters as
# floats/doubles results in floating point exceptions
# => compare the 8bit string values instead
- self.assertNotEqual(a.tostring(), b.tostring())
+ self.assertNotEqual(a.tobytes(), b.tobytes())
b.byteswap()
self.assertEqual(a, b)
diff --git a/Lib/test/test_ascii_formatd.py b/Lib/test/test_ascii_formatd.py
deleted file mode 100644
index 65d8608585..0000000000
--- a/Lib/test/test_ascii_formatd.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# PyOS_ascii_formatd is deprecated and not called from anywhere in
-# Python itself. So this module is the only place it gets tested.
-# Test that it works, and test that it's deprecated.
-
-import unittest
-from test.support import check_warnings, run_unittest, cpython_only, import_module
-
-import_module('ctypes')
-
-class FormatDeprecationTests(unittest.TestCase):
-
- @cpython_only
- def testFormatDeprecation(self):
- # delay importing ctypes until we know we're in CPython
- from ctypes import (pythonapi, create_string_buffer, sizeof, byref,
- c_double)
- PyOS_ascii_formatd = pythonapi.PyOS_ascii_formatd
- buf = create_string_buffer(100)
-
- with check_warnings() as w:
- PyOS_ascii_formatd(byref(buf), sizeof(buf), b'%+.10f',
- c_double(10.0))
- self.assertEqual(buf.value, b'+10.0000000000')
-
- self.assertEqual(str(w.message), 'PyOS_ascii_formatd is deprecated, '
- 'use PyOS_double_to_string instead')
-
-class FormatTests(unittest.TestCase):
- # ensure that, for the restricted set of format codes,
- # %-formatting returns the same values os PyOS_ascii_formatd
- @cpython_only
- def testFormat(self):
- # delay importing ctypes until we know we're in CPython
- from ctypes import (pythonapi, create_string_buffer, sizeof, byref,
- c_double)
- PyOS_ascii_formatd = pythonapi.PyOS_ascii_formatd
- buf = create_string_buffer(100)
-
- tests = [
- ('%f', 100.0),
- ('%g', 100.0),
- ('%#g', 100.0),
- ('%#.2g', 100.0),
- ('%#.2g', 123.4567),
- ('%#.2g', 1.234567e200),
- ('%e', 1.234567e200),
- ('%e', 1.234),
- ('%+e', 1.234),
- ('%-e', 1.234),
- ]
-
- with check_warnings():
- for format, val in tests:
- PyOS_ascii_formatd(byref(buf), sizeof(buf),
- bytes(format, 'ascii'),
- c_double(val))
- self.assertEqual(buf.value, bytes(format % val, 'ascii'))
-
-
-def test_main():
- run_unittest(FormatDeprecationTests, FormatTests)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index de19c8a391..da07060194 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -60,6 +60,10 @@ exec_tests = [
"break",
# Continue
"continue",
+ # for statements with naked tuples (see http://bugs.python.org/issue6704)
+ "for a,b in c: pass",
+ "[(a,b) for a,b in c]",
+ "((a,b) for a,b in c)",
]
# These are compiled through "single"
@@ -140,6 +144,16 @@ class AST_Tests(unittest.TestCase):
self.assertEqual(to_tuple(ast_tree), o)
self._assertTrueorder(ast_tree, (0, 0))
+ def test_slice(self):
+ slc = ast.parse("x[::]").body[0].value.slice
+ self.assertIsNone(slc.upper)
+ self.assertIsNone(slc.lower)
+ self.assertIsNone(slc.step)
+
+ def test_from_import(self):
+ im = ast.parse("from . import y").body[0]
+ self.assertIsNone(im.module)
+
def test_base_classes(self):
self.assertTrue(issubclass(ast.For, ast.stmt))
self.assertTrue(issubclass(ast.Name, ast.expr))
@@ -186,12 +200,9 @@ class AST_Tests(unittest.TestCase):
def test_invalid_sum(self):
pos = dict(lineno=2, col_offset=3)
m = ast.Module([ast.Expr(ast.expr(**pos), **pos)])
- try:
+ with self.assertRaises(TypeError) as cm:
compile(m, "<test>", "exec")
- except TypeError as exc:
- self.assertIn("but got <_ast.expr", str(exc))
- else:
- self.fail("needed TypeError")
+ self.assertIn("but got <_ast.expr", str(cm.exception))
class ASTHelpers_Test(unittest.TestCase):
@@ -289,13 +300,17 @@ class ASTHelpers_Test(unittest.TestCase):
self.assertEqual(ast.literal_eval('[1, 2, 3]'), [1, 2, 3])
self.assertEqual(ast.literal_eval('{"foo": 42}'), {"foo": 42})
self.assertEqual(ast.literal_eval('(True, False, None)'), (True, False, None))
+ self.assertEqual(ast.literal_eval('{1, 2, 3}'), {1, 2, 3})
+ self.assertEqual(ast.literal_eval('b"hi"'), b"hi")
self.assertRaises(ValueError, ast.literal_eval, 'foo()')
+ self.assertEqual(ast.literal_eval('-6'), -6)
+ self.assertEqual(ast.literal_eval('-6j+3'), 3-6j)
+ self.assertEqual(ast.literal_eval('3.25'), 3.25)
def test_literal_eval_issue4907(self):
self.assertEqual(ast.literal_eval('2j'), 2j)
self.assertEqual(ast.literal_eval('10 + 2j'), 10 + 2j)
self.assertEqual(ast.literal_eval('1.5 - 2j'), 1.5 - 2j)
- self.assertRaises(ValueError, ast.literal_eval, '2 + (3 + 4j)')
def test_main():
@@ -337,6 +352,9 @@ exec_results = [
('Module', [('Pass', (1, 0))]),
('Module', [('Break', (1, 0))]),
('Module', [('Continue', (1, 0))]),
+('Module', [('For', (1, 0), ('Tuple', (1, 4), [('Name', (1, 4), 'a', ('Store',)), ('Name', (1, 6), 'b', ('Store',))], ('Store',)), ('Name', (1, 11), 'c', ('Load',)), [('Pass', (1, 14))], [])]),
+('Module', [('Expr', (1, 0), ('ListComp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]),
+('Module', [('Expr', (1, 0), ('GeneratorExp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]),
]
single_results = [
('Interactive', [('Expr', (1, 0), ('BinOp', (1, 0), ('Num', (1, 0), 1), ('Add',), ('Num', (1, 2), 2)))]),
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
index f49701fd84..c79fe6f613 100644
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -5,98 +5,109 @@ from test import support
# If this fails, the test will be skipped.
thread = support.import_module('_thread')
-import asyncore, asynchat, socket, threading, time
+import asyncore, asynchat, socket, time
import unittest
import sys
+try:
+ import threading
+except ImportError:
+ threading = None
HOST = support.HOST
SERVER_QUIT = b'QUIT\n'
-class echo_server(threading.Thread):
- # parameter to determine the number of bytes passed back to the
- # client each send
- chunk_size = 1
-
- def __init__(self, event):
- threading.Thread.__init__(self)
- self.event = event
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.port = support.bind_port(self.sock)
-
- def run(self):
- self.sock.listen(1)
- self.event.set()
- conn, client = self.sock.accept()
- self.buffer = b""
- # collect data until quit message is seen
- while SERVER_QUIT not in self.buffer:
- data = conn.recv(1)
- if not data:
- break
- self.buffer = self.buffer + data
-
- # remove the SERVER_QUIT message
- self.buffer = self.buffer.replace(SERVER_QUIT, b'')
-
- # re-send entire set of collected data
- try:
- # this may fail on some tests, such as test_close_when_done, since
- # the client closes the channel when it's done sending
- while self.buffer:
- n = conn.send(self.buffer[:self.chunk_size])
- time.sleep(0.001)
- self.buffer = self.buffer[n:]
- except:
- pass
-
- conn.close()
- self.sock.close()
-
-class echo_client(asynchat.async_chat):
-
- def __init__(self, terminator, server_port):
- asynchat.async_chat.__init__(self)
- self.contents = []
- self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
- self.connect((HOST, server_port))
- self.set_terminator(terminator)
- self.buffer = b""
-
- def handle_connect(self):
- pass
-
- if sys.platform == 'darwin':
- # select.poll returns a select.POLLHUP at the end of the tests
- # on darwin, so just ignore it
- def handle_expt(self):
- pass
-
- def collect_incoming_data(self, data):
- self.buffer += data
-
- def found_terminator(self):
- self.contents.append(self.buffer)
- self.buffer = b""
-
-
-def start_echo_server():
- event = threading.Event()
- s = echo_server(event)
- s.start()
- event.wait()
- event.clear()
- time.sleep(0.01) # Give server time to start accepting.
- return s, event
+if threading:
+ class echo_server(threading.Thread):
+ # parameter to determine the number of bytes passed back to the
+ # client each send
+ chunk_size = 1
+
+ def __init__(self, event):
+ threading.Thread.__init__(self)
+ self.event = event
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.port = support.bind_port(self.sock)
+ # This will be set if the client wants us to wait before echoing data
+ # back.
+ self.start_resend_event = None
+
+ def run(self):
+ self.sock.listen(1)
+ self.event.set()
+ conn, client = self.sock.accept()
+ self.buffer = b""
+ # collect data until quit message is seen
+ while SERVER_QUIT not in self.buffer:
+ data = conn.recv(1)
+ if not data:
+ break
+ self.buffer = self.buffer + data
+
+ # remove the SERVER_QUIT message
+ self.buffer = self.buffer.replace(SERVER_QUIT, b'')
+
+ if self.start_resend_event:
+ self.start_resend_event.wait()
+
+ # re-send entire set of collected data
+ try:
+ # this may fail on some tests, such as test_close_when_done, since
+ # the client closes the channel when it's done sending
+ while self.buffer:
+ n = conn.send(self.buffer[:self.chunk_size])
+ time.sleep(0.001)
+ self.buffer = self.buffer[n:]
+ except:
+ pass
+
+ conn.close()
+ self.sock.close()
+
+ class echo_client(asynchat.async_chat):
+
+ def __init__(self, terminator, server_port):
+ asynchat.async_chat.__init__(self)
+ self.contents = []
+ self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.connect((HOST, server_port))
+ self.set_terminator(terminator)
+ self.buffer = b""
+
+ def handle_connect(self):
+ pass
+
+ if sys.platform == 'darwin':
+ # select.poll returns a select.POLLHUP at the end of the tests
+ # on darwin, so just ignore it
+ def handle_expt(self):
+ pass
+
+ def collect_incoming_data(self, data):
+ self.buffer += data
+
+ def found_terminator(self):
+ self.contents.append(self.buffer)
+ self.buffer = b""
+
+ def start_echo_server():
+ event = threading.Event()
+ s = echo_server(event)
+ s.start()
+ event.wait()
+ event.clear()
+ time.sleep(0.01) # Give server time to start accepting.
+ return s, event
+@unittest.skipUnless(threading, 'Threading required for this test.')
class TestAsynchat(unittest.TestCase):
usepoll = False
def setUp (self):
- pass
+ self._threads = support.threading_setup()
def tearDown (self):
- pass
+ support.threading_cleanup(*self._threads)
def line_terminator_check(self, term, server_chunk):
event = threading.Event()
@@ -203,11 +214,18 @@ class TestAsynchat(unittest.TestCase):
def test_close_when_done(self):
s, event = start_echo_server()
+ s.start_resend_event = threading.Event()
c = echo_client(b'\n', s.port)
c.push(b"hello world\nI'm not dead yet!\n")
c.push(SERVER_QUIT)
c.close_when_done()
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
+
+ # Only allow the server to start echoing data back to the client after
+ # the client has closed its connection. This prevents a race condition
+ # where the server echoes all of its data before we can check that it
+ # got any down below.
+ s.start_resend_event.set()
s.join()
self.assertEqual(c.contents, [])
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index fc1d1666d4..53c49a803b 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -3,9 +3,9 @@ import unittest
import select
import os
import socket
-import threading
import sys
import time
+import warnings
import errno
from test import support
@@ -13,6 +13,11 @@ from test.support import TESTFN, run_unittest, unlink
from io import BytesIO
from io import StringIO
+try:
+ import threading
+except ImportError:
+ threading = None
+
HOST = support.HOST
class dummysocket:
@@ -113,65 +118,65 @@ class HelperFunctionTests(unittest.TestCase):
# http://mail.python.org/pipermail/python-list/2001-October/109973.html)
# These constants should be present as long as poll is available
- if hasattr(select, 'poll'):
- def test_readwrite(self):
- # Check that correct methods are called by readwrite()
-
- attributes = ('read', 'expt', 'write', 'closed', 'error_handled')
-
- expected = (
- (select.POLLIN, 'read'),
- (select.POLLPRI, 'expt'),
- (select.POLLOUT, 'write'),
- (select.POLLERR, 'closed'),
- (select.POLLHUP, 'closed'),
- (select.POLLNVAL, 'closed'),
- )
-
- class testobj:
- def __init__(self):
- self.read = False
- self.write = False
- self.closed = False
- self.expt = False
- self.error_handled = False
-
- def handle_read_event(self):
- self.read = True
-
- def handle_write_event(self):
- self.write = True
-
- def handle_close(self):
- self.closed = True
-
- def handle_expt_event(self):
- self.expt = True
-
- def handle_error(self):
- self.error_handled = True
-
- for flag, expectedattr in expected:
- tobj = testobj()
- self.assertEqual(getattr(tobj, expectedattr), False)
- asyncore.readwrite(tobj, flag)
-
- # Only the attribute modified by the routine we expect to be
- # called should be True.
- for attr in attributes:
- self.assertEqual(getattr(tobj, attr), attr==expectedattr)
-
- # check that ExitNow exceptions in the object handler method
- # bubbles all the way up through asyncore readwrite call
- tr1 = exitingdummy()
- self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag)
-
- # check that an exception other than ExitNow in the object handler
- # method causes the handle_error method to get called
- tr2 = crashingdummy()
- self.assertEqual(tr2.error_handled, False)
- asyncore.readwrite(tr2, flag)
- self.assertEqual(tr2.error_handled, True)
+ @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required')
+ def test_readwrite(self):
+ # Check that correct methods are called by readwrite()
+
+ attributes = ('read', 'expt', 'write', 'closed', 'error_handled')
+
+ expected = (
+ (select.POLLIN, 'read'),
+ (select.POLLPRI, 'expt'),
+ (select.POLLOUT, 'write'),
+ (select.POLLERR, 'closed'),
+ (select.POLLHUP, 'closed'),
+ (select.POLLNVAL, 'closed'),
+ )
+
+ class testobj:
+ def __init__(self):
+ self.read = False
+ self.write = False
+ self.closed = False
+ self.expt = False
+ self.error_handled = False
+
+ def handle_read_event(self):
+ self.read = True
+
+ def handle_write_event(self):
+ self.write = True
+
+ def handle_close(self):
+ self.closed = True
+
+ def handle_expt_event(self):
+ self.expt = True
+
+ def handle_error(self):
+ self.error_handled = True
+
+ for flag, expectedattr in expected:
+ tobj = testobj()
+ self.assertEqual(getattr(tobj, expectedattr), False)
+ asyncore.readwrite(tobj, flag)
+
+ # Only the attribute modified by the routine we expect to be
+ # called should be True.
+ for attr in attributes:
+ self.assertEqual(getattr(tobj, attr), attr==expectedattr)
+
+ # check that ExitNow exceptions in the object handler method
+ # bubbles all the way up through asyncore readwrite call
+ tr1 = exitingdummy()
+ self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag)
+
+ # check that an exception other than ExitNow in the object handler
+ # method causes the handle_error method to get called
+ tr2 = crashingdummy()
+ self.assertEqual(tr2.error_handled, False)
+ asyncore.readwrite(tr2, flag)
+ self.assertEqual(tr2.error_handled, True)
def test_closeall(self):
self.closeall_check(False)
@@ -291,7 +296,6 @@ class DispatcherTests(unittest.TestCase):
d.handle_read()
d.handle_write()
d.handle_connect()
- d.handle_accept()
finally:
sys.stdout = stdout
@@ -299,22 +303,25 @@ class DispatcherTests(unittest.TestCase):
expected = ['warning: unhandled incoming priority event',
'warning: unhandled read event',
'warning: unhandled write event',
- 'warning: unhandled connect event',
- 'warning: unhandled accept event']
+ 'warning: unhandled connect event']
self.assertEqual(lines, expected)
def test_issue_8594(self):
+ # XXX - this test is supposed to be removed in next major Python
+ # version
d = asyncore.dispatcher(socket.socket())
# make sure the error message no longer refers to the socket
# object but the dispatcher instance instead
- try:
- d.foo
- except AttributeError as err:
- self.assertTrue('dispatcher instance' in str(err))
- else:
- self.fail("exception not raised")
- # test cheap inheritance with the underlying socket
- self.assertEqual(d.family, socket.AF_INET)
+ self.assertRaisesRegex(AttributeError, 'dispatcher instance',
+ getattr, d, 'foo')
+ # cheap inheritance with the underlying socket is supposed
+ # to still work but a DeprecationWarning is expected
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ family = d.family
+ self.assertEqual(family, socket.AF_INET)
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[0].category, DeprecationWarning))
def test_strerror(self):
# refers to bug #8573
@@ -322,7 +329,7 @@ class DispatcherTests(unittest.TestCase):
if hasattr(os, 'strerror'):
self.assertEqual(err, os.strerror(errno.EPERM))
err = asyncore._strerror(-1)
- self.assertTrue("unknown error" in err.lower())
+ self.assertTrue(err != "")
class dispatcherwithsend_noread(asyncore.dispatcher_with_send):
@@ -341,98 +348,401 @@ class DispatcherWithSendTests(unittest.TestCase):
def tearDown(self):
asyncore.close_all()
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ @support.reap_threads
def test_send(self):
- self.evt = threading.Event()
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.settimeout(3)
- self.port = support.bind_port(self.sock)
+ evt = threading.Event()
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.settimeout(3)
+ port = support.bind_port(sock)
cap = BytesIO()
- args = (self.evt, cap, self.sock)
- threading.Thread(target=capture_server, args=args).start()
-
- # wait a little longer for the server to initialize (it sometimes
- # refuses connections on slow machines without this wait)
- time.sleep(0.2)
+ args = (evt, cap, sock)
+ t = threading.Thread(target=capture_server, args=args)
+ t.start()
+ try:
+ # wait a little longer for the server to initialize (it sometimes
+ # refuses connections on slow machines without this wait)
+ time.sleep(0.2)
- data = b"Suppose there isn't a 16-ton weight?"
- d = dispatcherwithsend_noread()
- d.create_socket(socket.AF_INET, socket.SOCK_STREAM)
- d.connect((HOST, self.port))
+ data = b"Suppose there isn't a 16-ton weight?"
+ d = dispatcherwithsend_noread()
+ d.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ d.connect((HOST, port))
- # give time for socket to connect
- time.sleep(0.1)
+ # give time for socket to connect
+ time.sleep(0.1)
- d.send(data)
- d.send(data)
- d.send(b'\n')
+ d.send(data)
+ d.send(data)
+ d.send(b'\n')
- n = 1000
- while d.out_buffer and n > 0:
- asyncore.poll()
- n -= 1
+ n = 1000
+ while d.out_buffer and n > 0:
+ asyncore.poll()
+ n -= 1
- self.evt.wait()
+ evt.wait()
- self.assertEqual(cap.getvalue(), data*2)
+ self.assertEqual(cap.getvalue(), data*2)
+ finally:
+ t.join()
class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
usepoll = True
-if hasattr(asyncore, 'file_wrapper'):
- class FileWrapperTest(unittest.TestCase):
- def setUp(self):
- self.d = b"It's not dead, it's sleeping!"
- open(TESTFN, 'wb').write(self.d)
-
- def tearDown(self):
- unlink(TESTFN)
-
- def test_recv(self):
- fd = os.open(TESTFN, os.O_RDONLY)
- w = asyncore.file_wrapper(fd)
- os.close(fd)
-
- self.assertNotEqual(w.fd, fd)
- self.assertNotEqual(w.fileno(), fd)
- self.assertEqual(w.recv(13), b"It's not dead")
- self.assertEqual(w.read(6), b", it's")
- w.close()
- self.assertRaises(OSError, w.read, 1)
-
- def test_send(self):
- d1 = b"Come again?"
- d2 = b"I want to buy some cheese."
- fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND)
- w = asyncore.file_wrapper(fd)
- os.close(fd)
-
- w.write(d1)
- w.send(d2)
- w.close()
- self.assertEqual(open(TESTFN, 'rb').read(), self.d + d1 + d2)
-
- @unittest.skipUnless(hasattr(asyncore, 'file_dispatcher'),
- ' asyncore.file_dispatcher required')
- def test_dispatcher(self):
- fd = os.open(TESTFN, os.O_RDONLY)
- data = []
- class FileDispatcher(asyncore.file_dispatcher):
- def handle_read(self):
- data.append(self.recv(29))
- s = FileDispatcher(fd)
- os.close(fd)
- asyncore.loop(timeout=0.01, use_poll=True, count=2)
- self.assertEqual(b"".join(data), self.d)
+@unittest.skipUnless(hasattr(asyncore, 'file_wrapper'),
+ 'asyncore.file_wrapper required')
+class FileWrapperTest(unittest.TestCase):
+ def setUp(self):
+ self.d = b"It's not dead, it's sleeping!"
+ with open(TESTFN, 'wb') as file:
+ file.write(self.d)
+
+ def tearDown(self):
+ unlink(TESTFN)
+
+ def test_recv(self):
+ fd = os.open(TESTFN, os.O_RDONLY)
+ w = asyncore.file_wrapper(fd)
+ os.close(fd)
+
+ self.assertNotEqual(w.fd, fd)
+ self.assertNotEqual(w.fileno(), fd)
+ self.assertEqual(w.recv(13), b"It's not dead")
+ self.assertEqual(w.read(6), b", it's")
+ w.close()
+ self.assertRaises(OSError, w.read, 1)
+
+ def test_send(self):
+ d1 = b"Come again?"
+ d2 = b"I want to buy some cheese."
+ fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND)
+ w = asyncore.file_wrapper(fd)
+ os.close(fd)
+
+ w.write(d1)
+ w.send(d2)
+ w.close()
+ with open(TESTFN, 'rb') as file:
+ self.assertEqual(file.read(), self.d + d1 + d2)
+
+ @unittest.skipUnless(hasattr(asyncore, 'file_dispatcher'),
+ 'asyncore.file_dispatcher required')
+ def test_dispatcher(self):
+ fd = os.open(TESTFN, os.O_RDONLY)
+ data = []
+ class FileDispatcher(asyncore.file_dispatcher):
+ def handle_read(self):
+ data.append(self.recv(29))
+ s = FileDispatcher(fd)
+ os.close(fd)
+ asyncore.loop(timeout=0.01, use_poll=True, count=2)
+ self.assertEqual(b"".join(data), self.d)
+
+
+class BaseTestHandler(asyncore.dispatcher):
+
+ def __init__(self, sock=None):
+ asyncore.dispatcher.__init__(self, sock)
+ self.flag = False
+
+ def handle_accept(self):
+ raise Exception("handle_accept not supposed to be called")
+
+ def handle_accepted(self):
+ raise Exception("handle_accepted not supposed to be called")
+
+ def handle_connect(self):
+ raise Exception("handle_connect not supposed to be called")
+
+ def handle_expt(self):
+ raise Exception("handle_expt not supposed to be called")
+
+ def handle_close(self):
+ raise Exception("handle_close not supposed to be called")
+
+ def handle_error(self):
+ raise
+
+
+class TCPServer(asyncore.dispatcher):
+ """A server which listens on an address and dispatches the
+ connection to a handler.
+ """
+
+ def __init__(self, handler=BaseTestHandler, host=HOST, port=0):
+ asyncore.dispatcher.__init__(self)
+ self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.set_reuse_addr()
+ self.bind((host, port))
+ self.listen(5)
+ self.handler = handler
+
+ @property
+ def address(self):
+ return self.socket.getsockname()[:2]
+
+ def handle_accepted(self, sock, addr):
+ self.handler(sock)
+
+ def handle_error(self):
+ raise
+
+
+class BaseClient(BaseTestHandler):
+
+ def __init__(self, address):
+ BaseTestHandler.__init__(self)
+ self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.connect(address)
+
+ def handle_connect(self):
+ pass
+
+
+class BaseTestAPI(unittest.TestCase):
+
+ def tearDown(self):
+ asyncore.close_all()
+
+ def loop_waiting_for_flag(self, instance, timeout=5):
+ timeout = float(timeout) / 100
+ count = 100
+ while asyncore.socket_map and count > 0:
+ asyncore.loop(timeout=0.01, count=1, use_poll=self.use_poll)
+ if instance.flag:
+ return
+ count -= 1
+ time.sleep(timeout)
+ self.fail("flag not set")
+
+ def test_handle_connect(self):
+ # make sure handle_connect is called on connect()
+
+ class TestClient(BaseClient):
+ def handle_connect(self):
+ self.flag = True
+
+ server = TCPServer()
+ client = TestClient(server.address)
+ self.loop_waiting_for_flag(client)
+
+ def test_handle_accept(self):
+ # make sure handle_accept() is called when a client connects
+
+ class TestListener(BaseTestHandler):
+
+ def __init__(self):
+ BaseTestHandler.__init__(self)
+ self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.bind((HOST, 0))
+ self.listen(5)
+ self.address = self.socket.getsockname()[:2]
+
+ def handle_accept(self):
+ self.flag = True
+
+ server = TestListener()
+ client = BaseClient(server.address)
+ self.loop_waiting_for_flag(server)
+
+ def test_handle_accepted(self):
+ # make sure handle_accepted() is called when a client connects
+
+ class TestListener(BaseTestHandler):
+
+ def __init__(self):
+ BaseTestHandler.__init__(self)
+ self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.bind((HOST, 0))
+ self.listen(5)
+ self.address = self.socket.getsockname()[:2]
+
+ def handle_accept(self):
+ asyncore.dispatcher.handle_accept(self)
+
+ def handle_accepted(self, sock, addr):
+ sock.close()
+ self.flag = True
+
+ server = TestListener()
+ client = BaseClient(server.address)
+ self.loop_waiting_for_flag(server)
+
+
+ def test_handle_read(self):
+ # make sure handle_read is called on data received
+
+ class TestClient(BaseClient):
+ def handle_read(self):
+ self.flag = True
+
+ class TestHandler(BaseTestHandler):
+ def __init__(self, conn):
+ BaseTestHandler.__init__(self, conn)
+ self.send(b'x' * 1024)
+
+ server = TCPServer(TestHandler)
+ client = TestClient(server.address)
+ self.loop_waiting_for_flag(client)
+
+ def test_handle_write(self):
+ # make sure handle_write is called
+
+ class TestClient(BaseClient):
+ def handle_write(self):
+ self.flag = True
+
+ server = TCPServer()
+ client = TestClient(server.address)
+ self.loop_waiting_for_flag(client)
+
+ def test_handle_close(self):
+ # make sure handle_close is called when the other end closes
+ # the connection
+
+ class TestClient(BaseClient):
+
+ def handle_read(self):
+ # in order to make handle_close be called we are supposed
+ # to make at least one recv() call
+ self.recv(1024)
+
+ def handle_close(self):
+ self.flag = True
+ self.close()
+
+ class TestHandler(BaseTestHandler):
+ def __init__(self, conn):
+ BaseTestHandler.__init__(self, conn)
+ self.close()
+
+ server = TCPServer(TestHandler)
+ client = TestClient(server.address)
+ self.loop_waiting_for_flag(client)
+
+ @unittest.skipIf(sys.platform.startswith("sunos"),
+ "OOB support is broken on Solaris")
+ def test_handle_expt(self):
+ # Make sure handle_expt is called on OOB data received.
+ # Note: this might fail on some platforms as OOB data is
+ # tenuously supported and rarely used.
+
+ class TestClient(BaseClient):
+ def handle_expt(self):
+ self.flag = True
+
+ class TestHandler(BaseTestHandler):
+ def __init__(self, conn):
+ BaseTestHandler.__init__(self, conn)
+ self.socket.send(bytes(chr(244), 'latin-1'), socket.MSG_OOB)
+
+ server = TCPServer(TestHandler)
+ client = TestClient(server.address)
+ self.loop_waiting_for_flag(client)
+
+ def test_handle_error(self):
+
+ class TestClient(BaseClient):
+ def handle_write(self):
+ 1.0 / 0
+ def handle_error(self):
+ self.flag = True
+ try:
+ raise
+ except ZeroDivisionError:
+ pass
+ else:
+ raise Exception("exception not raised")
+
+ server = TCPServer()
+ client = TestClient(server.address)
+ self.loop_waiting_for_flag(client)
+
+ def test_connection_attributes(self):
+ server = TCPServer()
+ client = BaseClient(server.address)
+
+ # we start disconnected
+ self.assertFalse(server.connected)
+ self.assertTrue(server.accepting)
+ # this can't be taken for granted across all platforms
+ #self.assertFalse(client.connected)
+ self.assertFalse(client.accepting)
+
+ # execute some loops so that client connects to server
+ asyncore.loop(timeout=0.01, use_poll=self.use_poll, count=100)
+ self.assertFalse(server.connected)
+ self.assertTrue(server.accepting)
+ self.assertTrue(client.connected)
+ self.assertFalse(client.accepting)
+
+ # disconnect the client
+ client.close()
+ self.assertFalse(server.connected)
+ self.assertTrue(server.accepting)
+ self.assertFalse(client.connected)
+ self.assertFalse(client.accepting)
+
+ # stop serving
+ server.close()
+ self.assertFalse(server.connected)
+ self.assertFalse(server.accepting)
+
+ def test_create_socket(self):
+ s = asyncore.dispatcher()
+ s.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.assertEqual(s.socket.family, socket.AF_INET)
+ SOCK_NONBLOCK = getattr(socket, 'SOCK_NONBLOCK', 0)
+ self.assertEqual(s.socket.type, socket.SOCK_STREAM | SOCK_NONBLOCK)
+
+ def test_bind(self):
+ s1 = asyncore.dispatcher()
+ s1.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ s1.bind((HOST, 0))
+ s1.listen(5)
+ port = s1.socket.getsockname()[1]
+
+ s2 = asyncore.dispatcher()
+ s2.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ # EADDRINUSE indicates the socket was correctly bound
+ self.assertRaises(socket.error, s2.bind, (HOST, port))
+
+ def test_set_reuse_addr(self):
+ sock = socket.socket()
+ try:
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ except socket.error:
+ unittest.skip("SO_REUSEADDR not supported on this platform")
+ else:
+ # if SO_REUSEADDR succeeded for sock we expect asyncore
+ # to do the same
+ s = asyncore.dispatcher(socket.socket())
+ self.assertFalse(s.socket.getsockopt(socket.SOL_SOCKET,
+ socket.SO_REUSEADDR))
+ s.socket.close()
+ s.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.set_reuse_addr()
+ self.assertTrue(s.socket.getsockopt(socket.SOL_SOCKET,
+ socket.SO_REUSEADDR))
+ finally:
+ sock.close()
+
+
+class TestAPI_UseSelect(BaseTestAPI):
+ use_poll = False
+
+@unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required')
+class TestAPI_UsePoll(BaseTestAPI):
+ use_poll = True
def test_main():
tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests,
- DispatcherWithSendTests_UsePoll]
- if hasattr(asyncore, 'file_wrapper'):
- tests.append(FileWrapperTest)
-
+ DispatcherWithSendTests_UsePoll, TestAPI_UseSelect,
+ TestAPI_UsePoll, FileWrapperTest]
run_unittest(*tests)
if __name__ == "__main__":
diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py
index 8a71036fde..5200af7ed9 100644
--- a/Lib/test/test_atexit.py
+++ b/Lib/test/test_atexit.py
@@ -25,8 +25,9 @@ def raise2():
class TestCase(unittest.TestCase):
def setUp(self):
+ self.save_stdout = sys.stdout
+ self.save_stderr = sys.stderr
self.stream = io.StringIO()
- self.save_stdout, self.save_stderr = sys.stderr, sys.stdout
sys.stdout = sys.stderr = self.stream
atexit._clear()
@@ -65,6 +66,14 @@ class TestCase(unittest.TestCase):
self.assertRaises(TypeError, atexit._run_exitfuncs)
+ def test_raise_unnormalized(self):
+ # Issue #10756: Make sure that an unnormalized exception is
+ # handled properly
+ atexit.register(lambda: 1 / 0)
+
+ self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
+ self.assertIn("ZeroDivisionError", self.stream.getvalue())
+
def test_stress(self):
a = [0]
def inc():
diff --git a/Lib/test/test_augassign.py b/Lib/test/test_augassign.py
index 612666705a..9a59c58ec0 100644
--- a/Lib/test/test_augassign.py
+++ b/Lib/test/test_augassign.py
@@ -88,7 +88,7 @@ class AugAssignTest(unittest.TestCase):
y = x
x += 10
- self.assertTrue(isinstance(x, aug_test))
+ self.assertIsInstance(x, aug_test)
self.assertTrue(y is not x)
self.assertEqual(x.val, 11)
@@ -103,7 +103,7 @@ class AugAssignTest(unittest.TestCase):
y = x
x += 10
- self.assertTrue(isinstance(x, aug_test3))
+ self.assertIsInstance(x, aug_test3)
self.assertTrue(y is not x)
self.assertEqual(x.val, 13)
diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py
index 33aacd6fab..93c623cc8a 100644
--- a/Lib/test/test_base64.py
+++ b/Lib/test/test_base64.py
@@ -138,9 +138,25 @@ class BaseXYTestCase(unittest.TestCase):
eq(base64.urlsafe_b64decode(b'01a-b_cd'), b'\xd3V\xbeo\xf7\x1d')
self.assertRaises(TypeError, base64.urlsafe_b64decode, "")
- def test_b64decode_error(self):
+ def test_b64decode_padding_error(self):
self.assertRaises(binascii.Error, base64.b64decode, b'abc')
+ def test_b64decode_invalid_chars(self):
+ # issue 1466065: Test some invalid characters.
+ tests = ((b'%3d==', b'\xdd'),
+ (b'$3d==', b'\xdd'),
+ (b'[==', b''),
+ (b'YW]3=', b'am'),
+ (b'3{d==', b'\xdd'),
+ (b'3d}==', b'\xdd'),
+ (b'@@', b''),
+ (b'!', b''),
+ (b'YWJj\nYWI=', b'abcab'))
+ for bstr, res in tests:
+ self.assertEqual(base64.b64decode(bstr), res)
+ with self.assertRaises(binascii.Error):
+ base64.b64decode(bstr, validate=True)
+
def test_b32encode(self):
eq = self.assertEqual
eq(base64.b32encode(b''), b'')
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py
index aec3778d53..ac6b1096e1 100644
--- a/Lib/test/test_bigmem.py
+++ b/Lib/test/test_bigmem.py
@@ -519,12 +519,12 @@ class BaseStrTest:
edge = _('-') * (size // 2)
s = _('').join([edge, SUBSTR, edge])
del edge
- self.assertTrue(SUBSTR in s)
- self.assertFalse(SUBSTR * 2 in s)
- self.assertTrue(_('-') in s)
- self.assertFalse(_('a') in s)
+ self.assertIn(SUBSTR, s)
+ self.assertNotIn(SUBSTR * 2, s)
+ self.assertIn(_('-'), s)
+ self.assertNotIn(_('a'), s)
s += _('a')
- self.assertTrue(_('a') in s)
+ self.assertIn(_('a'), s)
@bigmemtest(minsize=_2G + 10, memuse=2)
def test_compare(self, size):
@@ -622,7 +622,7 @@ class StrTest(unittest.TestCase, BaseStrTest):
@precisionbigmemtest(size=_4G // 5, memuse=character_size * (6 + 1))
def test_unicode_repr_overflow(self, size):
try:
- s = "\uAAAA"*size
+ s = "\uDCBA"*size
r = repr(s)
except MemoryError:
pass # acceptable on 32-bit
@@ -683,22 +683,24 @@ class StrTest(unittest.TestCase, BaseStrTest):
@bigmemtest(minsize=2**32 / 5, memuse=character_size * 7)
def test_unicode_repr(self, size):
- s = "\uAAAA" * size
+ # Use an assigned, but not printable code point.
+ # It is in the range of the low surrogates \uDC00-\uDFFF.
+ s = "\uDCBA" * size
for f in (repr, ascii):
r = f(s)
self.assertTrue(len(r) > size)
- self.assertTrue(r.endswith(r"\uaaaa'"), r[-10:])
+ self.assertTrue(r.endswith(r"\udcba'"), r[-10:])
del r
# The character takes 4 bytes even in UCS-2 builds because it will
# be decomposed into surrogates.
@bigmemtest(minsize=2**32 / 5, memuse=4 + character_size * 9)
def test_unicode_repr_wide(self, size):
- s = "\U0001AAAA" * size
+ s = "\U0001DCBA" * size
for f in (repr, ascii):
r = f(s)
self.assertTrue(len(r) > size)
- self.assertTrue(r.endswith(r"\U0001aaaa'"), r[-12:])
+ self.assertTrue(r.endswith(r"\U0001dcba'"), r[-12:])
del r
@@ -772,9 +774,9 @@ class TupleTest(unittest.TestCase):
def test_contains(self, size):
t = (1, 2, 3, 4, 5) * size
self.assertEqual(len(t), size * 5)
- self.assertTrue(5 in t)
- self.assertFalse((1, 2, 3, 4, 5) in t)
- self.assertFalse(0 in t)
+ self.assertIn(5, t)
+ self.assertNotIn((1, 2, 3, 4, 5), t)
+ self.assertNotIn(0, t)
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_hash(self, size):
@@ -823,6 +825,7 @@ class TupleTest(unittest.TestCase):
@precisionbigmemtest(size=_1G - 1, memuse=9)
def test_from_2G_generator(self, size):
+ self.skipTest("test needs much more memory than advertised, see issue5438")
try:
t = tuple(range(size))
except MemoryError:
@@ -836,6 +839,7 @@ class TupleTest(unittest.TestCase):
@precisionbigmemtest(size=_1G - 25, memuse=9)
def test_from_almost_2G_generator(self, size):
+ self.skipTest("test needs much more memory than advertised, see issue5438")
try:
t = tuple(range(size))
count = 0
@@ -856,11 +860,11 @@ class TupleTest(unittest.TestCase):
self.assertEqual(s[-5:], '0, 0)')
self.assertEqual(s.count('0'), size)
- @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3)
+ @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3 * character_size)
def test_repr_small(self, size):
return self.basic_test_repr(size)
- @bigmemtest(minsize=_2G + 2, memuse=8 + 3)
+ @bigmemtest(minsize=_2G + 2, memuse=8 + 3 * character_size)
def test_repr_large(self, size):
return self.basic_test_repr(size)
@@ -921,9 +925,9 @@ class ListTest(unittest.TestCase):
def test_contains(self, size):
l = [1, 2, 3, 4, 5] * size
self.assertEqual(len(l), size * 5)
- self.assertTrue(5 in l)
- self.assertFalse([1, 2, 3, 4, 5] in l)
- self.assertFalse(0 in l)
+ self.assertIn(5, l)
+ self.assertNotIn([1, 2, 3, 4, 5], l)
+ self.assertNotIn(0, l)
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_hash(self, size):
@@ -1031,11 +1035,11 @@ class ListTest(unittest.TestCase):
self.assertEqual(s[-5:], '0, 0]')
self.assertEqual(s.count('0'), size)
- @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3)
+ @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3 * character_size)
def test_repr_small(self, size):
return self.basic_test_repr(size)
- @bigmemtest(minsize=_2G + 2, memuse=8 + 3)
+ @bigmemtest(minsize=_2G + 2, memuse=8 + 3 * character_size)
def test_repr_large(self, size):
return self.basic_test_repr(size)
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py
index a35ec05633..1e9e888f28 100755..100644
--- a/Lib/test/test_binascii.py
+++ b/Lib/test/test_binascii.py
@@ -3,14 +3,27 @@
from test import support
import unittest
import binascii
+import array
+
+# Note: "*_hex" functions are aliases for "(un)hexlify"
+b2a_functions = ['b2a_base64', 'b2a_hex', 'b2a_hqx', 'b2a_qp', 'b2a_uu',
+ 'hexlify', 'rlecode_hqx']
+a2b_functions = ['a2b_base64', 'a2b_hex', 'a2b_hqx', 'a2b_qp', 'a2b_uu',
+ 'unhexlify', 'rledecode_hqx']
+all_functions = a2b_functions + b2a_functions + ['crc32', 'crc_hqx']
+
class BinASCIITest(unittest.TestCase):
+ type2test = bytes
# Create binary test data
- data = b"The quick brown fox jumps over the lazy dog.\r\n"
+ rawdata = b"The quick brown fox jumps over the lazy dog.\r\n"
# Be slow so we don't depend on other modules
- data += bytes(range(256))
- data += b"\r\nHello world.\n"
+ rawdata += bytes(range(256))
+ rawdata += b"\r\nHello world.\n"
+
+ def setUp(self):
+ self.data = self.type2test(self.rawdata)
def test_exceptions(self):
# Check module exceptions
@@ -19,32 +32,47 @@ class BinASCIITest(unittest.TestCase):
def test_functions(self):
# Check presence of all functions
- funcs = []
- for suffix in "base64", "hqx", "uu", "hex":
- prefixes = ["a2b_", "b2a_"]
- if suffix == "hqx":
- prefixes.extend(["crc_", "rlecode_", "rledecode_"])
- for prefix in prefixes:
- name = prefix + suffix
- self.assertTrue(hasattr(getattr(binascii, name), '__call__'))
- self.assertRaises(TypeError, getattr(binascii, name))
- for name in ("hexlify", "unhexlify"):
+ for name in all_functions:
self.assertTrue(hasattr(getattr(binascii, name), '__call__'))
self.assertRaises(TypeError, getattr(binascii, name))
+ def test_returned_value(self):
+ # Limit to the minimum of all limits (b2a_uu)
+ MAX_ALL = 45
+ raw = self.rawdata[:MAX_ALL]
+ for fa, fb in zip(a2b_functions, b2a_functions):
+ a2b = getattr(binascii, fa)
+ b2a = getattr(binascii, fb)
+ try:
+ a = b2a(self.type2test(raw))
+ res = a2b(self.type2test(a))
+ except Exception as err:
+ self.fail("{}/{} conversion raises {!r}".format(fb, fa, err))
+ if fb == 'b2a_hqx':
+ # b2a_hqx returns a tuple
+ res, _ = res
+ self.assertEqual(res, raw, "{}/{} conversion: "
+ "{!r} != {!r}".format(fb, fa, res, raw))
+ self.assertIsInstance(res, bytes)
+ self.assertIsInstance(a, bytes)
+ self.assertLess(max(a), 128)
+ self.assertIsInstance(binascii.crc_hqx(raw, 0), int)
+ self.assertIsInstance(binascii.crc32(raw), int)
+
def test_base64valid(self):
# Test base64 with valid data
MAX_BASE64 = 57
lines = []
- for i in range(0, len(self.data), MAX_BASE64):
- b = self.data[i:i+MAX_BASE64]
+ for i in range(0, len(self.rawdata), MAX_BASE64):
+ b = self.type2test(self.rawdata[i:i+MAX_BASE64])
a = binascii.b2a_base64(b)
lines.append(a)
res = bytes()
for line in lines:
- b = binascii.a2b_base64(line)
+ a = self.type2test(line)
+ b = binascii.a2b_base64(a)
res += b
- self.assertEqual(res, self.data)
+ self.assertEqual(res, self.rawdata)
def test_base64invalid(self):
# Test base64 with random invalid characters sprinkled throughout
@@ -52,7 +80,7 @@ class BinASCIITest(unittest.TestCase):
MAX_BASE64 = 57
lines = []
for i in range(0, len(self.data), MAX_BASE64):
- b = self.data[i:i+MAX_BASE64]
+ b = self.type2test(self.rawdata[i:i+MAX_BASE64])
a = binascii.b2a_base64(b)
lines.append(a)
@@ -74,26 +102,28 @@ class BinASCIITest(unittest.TestCase):
return res + noise + line
res = bytearray()
for line in map(addnoise, lines):
- b = binascii.a2b_base64(line)
+ a = self.type2test(line)
+ b = binascii.a2b_base64(a)
res += b
- self.assertEqual(res, self.data)
+ self.assertEqual(res, self.rawdata)
# Test base64 with just invalid characters, which should return
# empty strings. TBD: shouldn't it raise an exception instead ?
- self.assertEqual(binascii.a2b_base64(fillers), b'')
+ self.assertEqual(binascii.a2b_base64(self.type2test(fillers)), b'')
def test_uu(self):
MAX_UU = 45
lines = []
for i in range(0, len(self.data), MAX_UU):
- b = self.data[i:i+MAX_UU]
+ b = self.type2test(self.rawdata[i:i+MAX_UU])
a = binascii.b2a_uu(b)
lines.append(a)
res = bytes()
for line in lines:
- b = binascii.a2b_uu(line)
+ a = self.type2test(line)
+ b = binascii.a2b_uu(a)
res += b
- self.assertEqual(res, self.data)
+ self.assertEqual(res, self.rawdata)
self.assertEqual(binascii.a2b_uu(b"\x7f"), b"\x00"*31)
self.assertEqual(binascii.a2b_uu(b"\x80"), b"\x00"*32)
@@ -107,19 +137,27 @@ class BinASCIITest(unittest.TestCase):
self.assertEqual(binascii.b2a_uu(b'x'), b'!> \n')
def test_crc32(self):
- crc = binascii.crc32(b"Test the CRC-32 of")
- crc = binascii.crc32(b" this string.", crc)
+ crc = binascii.crc32(self.type2test(b"Test the CRC-32 of"))
+ crc = binascii.crc32(self.type2test(b" this string."), crc)
self.assertEqual(crc, 1571220330)
self.assertRaises(TypeError, binascii.crc32)
- # The hqx test is in test_binhex.py
+ def test_hqx(self):
+ # Perform binhex4 style RLE-compression
+ # Then calculate the hexbin4 binary-to-ASCII translation
+ rle = binascii.rlecode_hqx(self.data)
+ a = binascii.b2a_hqx(self.type2test(rle))
+ b, _ = binascii.a2b_hqx(self.type2test(a))
+ res = binascii.rledecode_hqx(b)
+
+ self.assertEqual(res, self.rawdata)
def test_hex(self):
# test hexlification
s = b'{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000'
- t = binascii.b2a_hex(s)
- u = binascii.a2b_hex(t)
+ t = binascii.b2a_hex(self.type2test(s))
+ u = binascii.a2b_hex(self.type2test(t))
self.assertEqual(s, u)
self.assertRaises(binascii.Error, binascii.a2b_hex, t[:-1])
self.assertRaises(binascii.Error, binascii.a2b_hex, t[:-1] + b'q')
@@ -129,7 +167,7 @@ class BinASCIITest(unittest.TestCase):
def test_qp(self):
# A test for SF bug 534347 (segfaults without the proper fix)
try:
- binascii.a2b_qp("", **{1:1})
+ binascii.a2b_qp(b"", **{1:1})
except TypeError:
pass
else:
@@ -141,12 +179,10 @@ class BinASCIITest(unittest.TestCase):
self.assertEqual(binascii.a2b_qp(b"=00\r\n=00"), b"\x00\r\n\x00")
self.assertEqual(
binascii.b2a_qp(b"\xff\r\n\xff\n\xff"),
- b"=FF\r\n=FF\r\n=FF"
- )
+ b"=FF\r\n=FF\r\n=FF")
self.assertEqual(
binascii.b2a_qp(b"0"*75+b"\xff\r\n\xff\r\n\xff"),
- b"0"*75+b"=\r\n=FF\r\n=FF\r\n=FF"
- )
+ b"0"*75+b"=\r\n=FF\r\n=FF\r\n=FF")
self.assertEqual(binascii.b2a_qp(b'\0\n'), b'=00\n')
self.assertEqual(binascii.b2a_qp(b'\0\n', quotetabs=True), b'=00\n')
@@ -160,27 +196,47 @@ class BinASCIITest(unittest.TestCase):
def test_empty_string(self):
# A test for SF bug #1022953. Make sure SystemError is not raised.
- for n in ['b2a_qp', 'a2b_hex', 'b2a_base64', 'a2b_uu', 'a2b_qp',
- 'b2a_hex', 'unhexlify', 'hexlify', 'crc32', 'b2a_hqx',
- 'a2b_hqx', 'a2b_base64', 'rlecode_hqx', 'b2a_uu',
- 'rledecode_hqx']:
- f = getattr(binascii, n)
+ empty = self.type2test(b'')
+ for func in all_functions:
+ if func == 'crc_hqx':
+ # crc_hqx needs 2 arguments
+ binascii.crc_hqx(empty, 0)
+ continue
+ f = getattr(binascii, func)
+ try:
+ f(empty)
+ except Exception as err:
+ self.fail("{}({!r}) raises {!r}".format(func, empty, err))
+
+ def test_unicode_strings(self):
+ # Unicode strings are not accepted.
+ for func in all_functions:
try:
- f(b'')
- except SystemError as err:
- self.fail("%s(b'') raises SystemError: %s" % (n, err))
- binascii.crc_hqx(b'', 0)
-
- def test_no_binary_strings(self):
- # b2a_ must not accept strings
- for f in (binascii.b2a_uu, binascii.b2a_base64,
- binascii.b2a_hqx, binascii.b2a_qp,
- binascii.hexlify, binascii.rlecode_hqx,
- binascii.crc_hqx, binascii.crc32):
- self.assertRaises(TypeError, f, "test")
+ self.assertRaises(TypeError, getattr(binascii, func), "test")
+ except Exception as err:
+ self.fail('{}("test") raises {!r}'.format(func, err))
+ # crc_hqx needs 2 arguments
+ self.assertRaises(TypeError, binascii.crc_hqx, "test", 0)
+
+
+class ArrayBinASCIITest(BinASCIITest):
+ def type2test(self, s):
+ return array.array('B', list(s))
+
+
+class BytearrayBinASCIITest(BinASCIITest):
+ type2test = bytearray
+
+
+class MemoryviewBinASCIITest(BinASCIITest):
+ type2test = memoryview
+
def test_main():
- support.run_unittest(BinASCIITest)
+ support.run_unittest(BinASCIITest,
+ ArrayBinASCIITest,
+ BytearrayBinASCIITest,
+ MemoryviewBinASCIITest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_binhex.py b/Lib/test/test_binhex.py
index 06fd98aa64..d6ef84a5e0 100755
--- a/Lib/test/test_binhex.py
+++ b/Lib/test/test_binhex.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test script for the binhex C module
Uses the mechanism of the python binhex module
diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py
index 523ecbe298..84179167e2 100644
--- a/Lib/test/test_binop.py
+++ b/Lib/test/test_binop.py
@@ -2,6 +2,7 @@
import unittest
from test import support
+from operator import eq, ne, lt, gt, le, ge
def gcd(a, b):
"""Greatest common divisor using Euclid's algorithm."""
@@ -10,8 +11,8 @@ def gcd(a, b):
return b
def isint(x):
- """Test whether an object is an instance of int or long."""
- return isinstance(x, int) or isinstance(x, int)
+ """Test whether an object is an instance of int."""
+ return isinstance(x, int)
def isnum(x):
"""Test whether an object is an instance of a built-in numeric type."""
@@ -26,18 +27,18 @@ def isRat(x):
class Rat(object):
- """Rational number implemented as a normalized pair of longs."""
+ """Rational number implemented as a normalized pair of ints."""
__slots__ = ['_Rat__num', '_Rat__den']
def __init__(self, num=0, den=1):
"""Constructor: Rat([num[, den]]).
- The arguments must be ints or longs, and default to (0, 1)."""
+ The arguments must be ints, and default to (0, 1)."""
if not isint(num):
- raise TypeError("Rat numerator must be int or long (%r)" % num)
+ raise TypeError("Rat numerator must be int (%r)" % num)
if not isint(den):
- raise TypeError("Rat denominator must be int or long (%r)" % den)
+ raise TypeError("Rat denominator must be int (%r)" % den)
# But the zero is always on
if den == 0:
raise ZeroDivisionError("zero denominator")
@@ -219,9 +220,6 @@ class RatTestCase(unittest.TestCase):
a = Rat(10, 15)
self.assertEqual(a.num, 2)
self.assertEqual(a.den, 3)
- a = Rat(10, 15)
- self.assertEqual(a.num, 2)
- self.assertEqual(a.den, 3)
a = Rat(10, -15)
self.assertEqual(a.num, -2)
self.assertEqual(a.den, 3)
@@ -305,9 +303,78 @@ class RatTestCase(unittest.TestCase):
# XXX Ran out of steam; TO DO: divmod, div, future division
-def test_main():
- support.run_unittest(RatTestCase)
+class OperationLogger:
+ """Base class for classes with operation logging."""
+ def __init__(self, logger):
+ self.logger = logger
+ def log_operation(self, *args):
+ self.logger(*args)
+
+def op_sequence(op, *classes):
+ """Return the sequence of operations that results from applying
+ the operation `op` to instances of the given classes."""
+ log = []
+ instances = []
+ for c in classes:
+ instances.append(c(log.append))
+
+ try:
+ op(*instances)
+ except TypeError:
+ pass
+ return log
+
+class A(OperationLogger):
+ def __eq__(self, other):
+ self.log_operation('A.__eq__')
+ return NotImplemented
+ def __le__(self, other):
+ self.log_operation('A.__le__')
+ return NotImplemented
+ def __ge__(self, other):
+ self.log_operation('A.__ge__')
+ return NotImplemented
+
+class B(OperationLogger):
+ def __eq__(self, other):
+ self.log_operation('B.__eq__')
+ return NotImplemented
+ def __le__(self, other):
+ self.log_operation('B.__le__')
+ return NotImplemented
+ def __ge__(self, other):
+ self.log_operation('B.__ge__')
+ return NotImplemented
+
+class C(B):
+ def __eq__(self, other):
+ self.log_operation('C.__eq__')
+ return NotImplemented
+ def __le__(self, other):
+ self.log_operation('C.__le__')
+ return NotImplemented
+ def __ge__(self, other):
+ self.log_operation('C.__ge__')
+ return NotImplemented
+
+class OperationOrderTests(unittest.TestCase):
+ def test_comparison_orders(self):
+ self.assertEqual(op_sequence(eq, A, A), ['A.__eq__', 'A.__eq__'])
+ self.assertEqual(op_sequence(eq, A, B), ['A.__eq__', 'B.__eq__'])
+ self.assertEqual(op_sequence(eq, B, A), ['B.__eq__', 'A.__eq__'])
+ # C is a subclass of B, so C.__eq__ is called first
+ self.assertEqual(op_sequence(eq, B, C), ['C.__eq__', 'B.__eq__'])
+ self.assertEqual(op_sequence(eq, C, B), ['C.__eq__', 'B.__eq__'])
+
+ self.assertEqual(op_sequence(le, A, A), ['A.__le__', 'A.__ge__'])
+ self.assertEqual(op_sequence(le, A, B), ['A.__le__', 'B.__ge__'])
+ self.assertEqual(op_sequence(le, B, A), ['B.__le__', 'A.__ge__'])
+ self.assertEqual(op_sequence(le, B, C), ['C.__ge__', 'B.__le__'])
+ self.assertEqual(op_sequence(le, C, B), ['C.__le__', 'B.__ge__'])
+
+def test_main():
+ support.run_unittest(RatTestCase, OperationOrderTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_bool.py b/Lib/test/test_bool.py
index 3a68dfce22..b296870b09 100644
--- a/Lib/test/test_bool.py
+++ b/Lib/test/test_bool.py
@@ -7,12 +7,6 @@ import os
class BoolTest(unittest.TestCase):
- def assertIs(self, a, b):
- self.assertTrue(a is b)
-
- def assertIsNot(self, a, b):
- self.assertTrue(a is not b)
-
def test_subclass(self):
try:
class C(bool):
@@ -51,6 +45,12 @@ class BoolTest(unittest.TestCase):
self.assertEqual(int(True), 1)
self.assertIsNot(int(True), True)
+ def test_float(self):
+ self.assertEqual(float(False), 0.0)
+ self.assertIsNot(float(False), False)
+ self.assertEqual(float(True), 1.0)
+ self.assertIsNot(float(True), True)
+
def test_math(self):
self.assertEqual(+False, 0)
self.assertIsNot(+False, False)
@@ -174,8 +174,8 @@ class BoolTest(unittest.TestCase):
self.assertIs(hasattr([], "wobble"), False)
def test_callable(self):
- self.assertIs(hasattr(len, '__call__'), True)
- self.assertIs(hasattr(1, '__call__'), False)
+ self.assertIs(callable(len), True)
+ self.assertIs(callable(1), False)
def test_isinstance(self):
self.assertIs(isinstance(True, bool), True)
@@ -221,15 +221,15 @@ class BoolTest(unittest.TestCase):
def test_boolean(self):
self.assertEqual(True & 1, 1)
- self.assertTrue(not isinstance(True & 1, bool))
+ self.assertNotIsInstance(True & 1, bool)
self.assertIs(True & True, True)
self.assertEqual(True | 1, 1)
- self.assertTrue(not isinstance(True | 1, bool))
+ self.assertNotIsInstance(True | 1, bool)
self.assertIs(True | True, True)
self.assertEqual(True ^ 1, 0)
- self.assertTrue(not isinstance(True ^ 1, bool))
+ self.assertNotIsInstance(True ^ 1, bool)
self.assertIs(True ^ True, False)
def test_fileclosed(self):
@@ -241,6 +241,12 @@ class BoolTest(unittest.TestCase):
finally:
os.remove(support.TESTFN)
+ def test_types(self):
+ # types are always true.
+ for t in [bool, complex, dict, float, int, list, object,
+ set, str, tuple, type]:
+ self.assertIs(bool(t), True)
+
def test_operator(self):
import operator
self.assertIs(operator.truth(0), False)
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 420a17f201..1469e36847 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1,17 +1,18 @@
# Python test set -- built-in functions
import platform
-import test.support, unittest
-from test.support import fcmp, TESTFN, unlink, run_unittest, \
- run_with_locale
+import unittest
+import sys
+import warnings
+import collections
+import io
+import ast
+import types
+import builtins
+import random
+from test.support import fcmp, TESTFN, unlink, run_unittest, check_warnings
from operator import neg
-import sys, warnings, random, collections, io, fractions
-warnings.filterwarnings("ignore", "hex../oct.. of negative int",
- FutureWarning, __name__)
-warnings.filterwarnings("ignore", "integer argument expected",
- DeprecationWarning, "unittest")
-import builtins
class Squares:
@@ -126,12 +127,18 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(abs(0.0), 0.0)
self.assertEqual(abs(3.14), 3.14)
self.assertEqual(abs(-3.14), 3.14)
- # long
- self.assertEqual(abs(0), 0)
- self.assertEqual(abs(1234), 1234)
- self.assertEqual(abs(-1234), 1234)
# str
self.assertRaises(TypeError, abs, 'a')
+ # bool
+ self.assertEqual(abs(True), 1)
+ self.assertEqual(abs(False), 0)
+ # other
+ self.assertRaises(TypeError, abs)
+ self.assertRaises(TypeError, abs, None)
+ class AbsClass(object):
+ def __abs__(self):
+ return -5
+ self.assertEqual(abs(AbsClass()), -5)
def test_all(self):
self.assertEqual(all([2, 4, 6]), True)
@@ -164,7 +171,6 @@ class BuiltinTest(unittest.TestCase):
def test_ascii(self):
self.assertEqual(ascii(''), '\'\'')
self.assertEqual(ascii(0), '0')
- self.assertEqual(ascii(0), '0')
self.assertEqual(ascii(()), '()')
self.assertEqual(ascii([]), '[]')
self.assertEqual(ascii({}), '{}')
@@ -202,22 +208,39 @@ class BuiltinTest(unittest.TestCase):
self.assertTrue(isinstance(x, int))
self.assertEqual(-x, sys.maxsize+1)
- # XXX(nnorwitz): This test case for callable should probably be removed.
def test_callable(self):
- self.assertTrue(hasattr(len, '__call__'))
+ self.assertTrue(callable(len))
+ self.assertFalse(callable("a"))
+ self.assertTrue(callable(callable))
+ self.assertTrue(callable(lambda x, y: x + y))
+ self.assertFalse(callable(__builtins__))
def f(): pass
- self.assertTrue(hasattr(f, '__call__'))
- class C:
+ self.assertTrue(callable(f))
+
+ class C1:
def meth(self): pass
- self.assertTrue(hasattr(C, '__call__'))
- x = C()
- self.assertTrue(hasattr(x.meth, '__call__'))
- self.assertTrue(not hasattr(x, '__call__'))
- class D(C):
+ self.assertTrue(callable(C1))
+ c = C1()
+ self.assertTrue(callable(c.meth))
+ self.assertFalse(callable(c))
+
+ # __call__ is looked up on the class, not the instance
+ c.__call__ = None
+ self.assertFalse(callable(c))
+ c.__call__ = lambda self: 0
+ self.assertFalse(callable(c))
+ del c.__call__
+ self.assertFalse(callable(c))
+
+ class C2(object):
def __call__(self): pass
- y = D()
- self.assertTrue(hasattr(y, '__call__'))
- y()
+ c2 = C2()
+ self.assertTrue(callable(c2))
+ c2.__call__ = None
+ self.assertTrue(callable(c2))
+ class C3(C2): pass
+ c3 = C3()
+ self.assertTrue(callable(c3))
def test_chr(self):
self.assertEqual(chr(32), ' ')
@@ -263,8 +286,35 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, compile, chr(0), 'f', 'exec')
self.assertRaises(ValueError, compile, str('a = 1'), 'f', 'bad')
+ # test the optimize argument
+
+ codestr = '''def f():
+ """doc"""
+ try:
+ assert False
+ except AssertionError:
+ return (True, f.__doc__)
+ else:
+ return (False, f.__doc__)
+ '''
+ def f(): """doc"""
+ values = [(-1, __debug__, f.__doc__),
+ (0, True, 'doc'),
+ (1, False, 'doc'),
+ (2, False, None)]
+ for optval, debugval, docstring in values:
+ # test both direct compilation and compilation via AST
+ codeobjs = []
+ codeobjs.append(compile(codestr, "<test>", "exec", optimize=optval))
+ tree = ast.parse(codestr)
+ codeobjs.append(compile(tree, "<test>", "exec", optimize=optval))
+ for code in codeobjs:
+ ns = {}
+ exec(code, ns)
+ rv = ns['f']()
+ self.assertEqual(rv, (debugval, docstring))
+
def test_delattr(self):
- import sys
sys.spam = 1
delattr(sys, 'spam')
self.assertRaises(TypeError, delattr)
@@ -275,22 +325,20 @@ class BuiltinTest(unittest.TestCase):
# dir() - local scope
local_var = 1
- self.assertTrue('local_var' in dir())
+ self.assertIn('local_var', dir())
# dir(module)
- import sys
- self.assertTrue('exit' in dir(sys))
+ self.assertIn('exit', dir(sys))
# dir(module_with_invalid__dict__)
- import types
class Foo(types.ModuleType):
__dict__ = 8
f = Foo("foo")
self.assertRaises(TypeError, dir, f)
# dir(type)
- self.assertTrue("strip" in dir(str))
- self.assertTrue("__mro__" not in dir(str))
+ self.assertIn("strip", dir(str))
+ self.assertNotIn("__mro__", dir(str))
# dir(obj)
class Foo(object):
@@ -299,13 +347,13 @@ class BuiltinTest(unittest.TestCase):
self.y = 8
self.z = 9
f = Foo()
- self.assertTrue("y" in dir(f))
+ self.assertIn("y", dir(f))
# dir(obj_no__dict__)
class Foo(object):
__slots__ = []
f = Foo()
- self.assertTrue("__repr__" in dir(f))
+ self.assertIn("__repr__", dir(f))
# dir(obj_no__class__with__dict__)
# (an ugly trick to cause getattr(f, "__class__") to fail)
@@ -314,8 +362,8 @@ class BuiltinTest(unittest.TestCase):
def __init__(self):
self.bar = "wow"
f = Foo()
- self.assertTrue("__repr__" not in dir(f))
- self.assertTrue("bar" in dir(f))
+ self.assertNotIn("__repr__", dir(f))
+ self.assertIn("bar", dir(f))
# dir(obj_using __dir__)
class Foo(object):
@@ -344,18 +392,7 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(divmod(12, -7), (-2, -2))
self.assertEqual(divmod(-12, -7), (1, -5))
- self.assertEqual(divmod(12, 7), (1, 5))
- self.assertEqual(divmod(-12, 7), (-2, 2))
- self.assertEqual(divmod(12, -7), (-2, -2))
- self.assertEqual(divmod(-12, -7), (1, -5))
-
- self.assertEqual(divmod(12, 7), (1, 5))
- self.assertEqual(divmod(-12, 7), (-2, 2))
- self.assertEqual(divmod(12, -7), (-2, -2))
- self.assertEqual(divmod(-12, -7), (1, -5))
-
- self.assertEqual(divmod(-sys.maxsize-1, -1),
- (sys.maxsize+1, 0))
+ self.assertEqual(divmod(-sys.maxsize-1, -1), (sys.maxsize+1, 0))
self.assertTrue(not fcmp(divmod(3.25, 1.0), (3.0, 0.25)))
self.assertTrue(not fcmp(divmod(-3.25, 1.0), (-4.0, 0.75)))
@@ -465,9 +502,10 @@ class BuiltinTest(unittest.TestCase):
g = {}
l = {}
- import warnings
- warnings.filterwarnings("ignore", "global statement", module="<string>")
- exec('global a; a = 1; b = 2', g, l)
+ with check_warnings():
+ warnings.filterwarnings("ignore", "global statement",
+ module="<string>")
+ exec('global a; a = 1; b = 2', g, l)
if '__builtins__' in g:
del g['__builtins__']
if '__builtins__' in l:
@@ -511,7 +549,6 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, list, filter(42, (1, 2)))
def test_getattr(self):
- import sys
self.assertTrue(getattr(sys, 'stdout') is sys.stdout)
self.assertRaises(TypeError, getattr, sys, 1)
self.assertRaises(TypeError, getattr, sys, 1, "foo")
@@ -521,21 +558,21 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(AttributeError, getattr, 1, "\uDAD1\uD51E")
def test_hasattr(self):
- import sys
self.assertTrue(hasattr(sys, 'stdout'))
self.assertRaises(TypeError, hasattr, sys, 1)
self.assertRaises(TypeError, hasattr)
self.assertEqual(False, hasattr(sys, chr(sys.maxunicode)))
- # Check that hasattr allows SystemExit and KeyboardInterrupts by
+ # Check that hasattr propagates all exceptions outside of
+ # AttributeError.
class A:
def __getattr__(self, what):
- raise KeyboardInterrupt
- self.assertRaises(KeyboardInterrupt, hasattr, A(), "b")
+ raise SystemExit
+ self.assertRaises(SystemExit, hasattr, A(), "b")
class B:
def __getattr__(self, what):
- raise SystemExit
- self.assertRaises(SystemExit, hasattr, B(), "b")
+ raise ValueError
+ self.assertRaises(ValueError, hasattr, B(), "b")
def test_hash(self):
hash(None)
@@ -552,10 +589,6 @@ class BuiltinTest(unittest.TestCase):
def __hash__(self):
return 2**100
self.assertEqual(type(hash(X())), int)
- class Y(object):
- def __hash__(self):
- return 2**100
- self.assertEqual(type(hash(Y())), int)
class Z(int):
def __hash__(self):
return self
@@ -563,15 +596,12 @@ class BuiltinTest(unittest.TestCase):
def test_hex(self):
self.assertEqual(hex(16), '0x10')
- self.assertEqual(hex(16), '0x10')
- self.assertEqual(hex(-16), '-0x10')
self.assertEqual(hex(-16), '-0x10')
self.assertRaises(TypeError, hex, {})
def test_id(self):
id(None)
id(1)
- id(1)
id(1.0)
id('spam')
id((0,1,2,3))
@@ -648,6 +678,8 @@ class BuiltinTest(unittest.TestCase):
def __len__(self):
return sys.maxsize + 1
self.assertRaises(OverflowError, len, HugeLen())
+ class NoLenMethod(object): pass
+ self.assertRaises(TypeError, len, NoLenMethod())
def test_map(self):
self.assertEqual(
@@ -814,8 +846,6 @@ class BuiltinTest(unittest.TestCase):
def test_oct(self):
self.assertEqual(oct(100), '0o144')
- self.assertEqual(oct(100), '0o144')
- self.assertEqual(oct(-100), '-0o144')
self.assertEqual(oct(-100), '-0o144')
self.assertRaises(TypeError, oct, ())
@@ -824,7 +854,6 @@ class BuiltinTest(unittest.TestCase):
fp = open(TESTFN, 'w')
try:
fp.write('1+1\n')
- fp.write('1+1\n')
fp.write('The quick brown fox jumps over the lazy dog')
fp.write('.\n')
fp.write('Dear John\n')
@@ -838,7 +867,6 @@ class BuiltinTest(unittest.TestCase):
fp = open(TESTFN, 'r')
try:
self.assertEqual(fp.readline(4), '1+1\n')
- self.assertEqual(fp.readline(4), '1+1\n')
self.assertEqual(fp.readline(), 'The quick brown fox jumps over the lazy dog.\n')
self.assertEqual(fp.readline(4), 'Dear')
self.assertEqual(fp.readline(100), ' John\n')
@@ -891,21 +919,6 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(pow(-2,2), 4)
self.assertEqual(pow(-2,3), -8)
- self.assertEqual(pow(0,0), 1)
- self.assertEqual(pow(0,1), 0)
- self.assertEqual(pow(1,0), 1)
- self.assertEqual(pow(1,1), 1)
-
- self.assertEqual(pow(2,0), 1)
- self.assertEqual(pow(2,10), 1024)
- self.assertEqual(pow(2,20), 1024*1024)
- self.assertEqual(pow(2,30), 1024*1024*1024)
-
- self.assertEqual(pow(-2,0), 1)
- self.assertEqual(pow(-2,1), -2)
- self.assertEqual(pow(-2,2), 4)
- self.assertEqual(pow(-2,3), -8)
-
self.assertAlmostEqual(pow(0.,0), 1.)
self.assertAlmostEqual(pow(0.,1), 0.)
self.assertAlmostEqual(pow(1.,0), 1.)
@@ -921,9 +934,9 @@ class BuiltinTest(unittest.TestCase):
self.assertAlmostEqual(pow(-2.,2), 4.)
self.assertAlmostEqual(pow(-2.,3), -8.)
- for x in 2, 2, 2.0:
- for y in 10, 10, 10.0:
- for z in 1000, 1000, 1000.0:
+ for x in 2, 2.0:
+ for y in 10, 10.0:
+ for z in 1000, 1000.0:
if isinstance(x, float) or \
isinstance(y, float) or \
isinstance(z, float):
@@ -936,93 +949,9 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, pow, -1, -2, 3)
self.assertRaises(ValueError, pow, 1, 2, 0)
- self.assertRaises(TypeError, pow, -1, -2, 3)
- self.assertRaises(ValueError, pow, 1, 2, 0)
self.assertRaises(TypeError, pow)
- def test_range(self):
- self.assertEqual(list(range(3)), [0, 1, 2])
- self.assertEqual(list(range(1, 5)), [1, 2, 3, 4])
- self.assertEqual(list(range(0)), [])
- self.assertEqual(list(range(-3)), [])
- self.assertEqual(list(range(1, 10, 3)), [1, 4, 7])
- #self.assertEqual(list(range(5, -5, -3)), [5, 2, -1, -4])
-
- #issue 6334: the internal stored range length was being
- #computed incorrectly in some cases involving large arguments.
- x = range(10**20, 10**20+10, 3)
- self.assertEqual(len(x), 4)
- self.assertEqual(len(list(x)), 4)
-
- x = range(10**20+10, 10**20, 3)
- self.assertEqual(len(x), 0)
- self.assertEqual(len(list(x)), 0)
-
- x = range(10**20, 10**20+10, -3)
- self.assertEqual(len(x), 0)
- self.assertEqual(len(list(x)), 0)
-
- x = range(10**20+10, 10**20, -3)
- self.assertEqual(len(x), 4)
- self.assertEqual(len(list(x)), 4)
-
- """ XXX(nnorwitz):
- # Now test range() with longs
- self.assertEqual(list(range(-2**100)), [])
- self.assertEqual(list(range(0, -2**100)), [])
- self.assertEqual(list(range(0, 2**100, -1)), [])
- self.assertEqual(list(range(0, 2**100, -1)), [])
-
- a = int(10 * sys.maxsize)
- b = int(100 * sys.maxsize)
- c = int(50 * sys.maxsize)
-
- self.assertEqual(list(range(a, a+2)), [a, a+1])
- self.assertEqual(list(range(a+2, a, -1)), [a+2, a+1])
- self.assertEqual(list(range(a+4, a, -2)), [a+4, a+2])
-
- seq = list(range(a, b, c))
- self.assertTrue(a in seq)
- self.assertTrue(b not in seq)
- self.assertEqual(len(seq), 2)
-
- seq = list(range(b, a, -c))
- self.assertTrue(b in seq)
- self.assertTrue(a not in seq)
- self.assertEqual(len(seq), 2)
-
- seq = list(range(-a, -b, -c))
- self.assertTrue(-a in seq)
- self.assertTrue(-b not in seq)
- self.assertEqual(len(seq), 2)
-
- self.assertRaises(TypeError, range)
- self.assertRaises(TypeError, range, 1, 2, 3, 4)
- self.assertRaises(ValueError, range, 1, 2, 0)
- self.assertRaises(ValueError, range, a, a + 1, int(0))
-
- class badzero(int):
- def __eq__(self, other):
- raise RuntimeError
- __ne__ = __lt__ = __gt__ = __le__ = __ge__ = __eq__
-
- # XXX This won't (but should!) raise RuntimeError if a is an int...
- self.assertRaises(RuntimeError, range, a, a + 1, badzero(1))
- """
-
- # Reject floats when it would require PyLongs to represent.
- # (smaller floats still accepted, but deprecated)
- self.assertRaises(TypeError, range, 1e100, 1e101, 1e101)
-
- self.assertRaises(TypeError, range, 0, "spam")
- self.assertRaises(TypeError, range, 0, 42, "spam")
-
- #NEAL self.assertRaises(OverflowError, range, -sys.maxsize, sys.maxsize)
- #NEAL self.assertRaises(OverflowError, range, 0, 2*sys.maxsize)
-
- self.assertRaises(OverflowError, len, range(0, sys.maxsize**10))
-
def test_input(self):
self.write_testfile()
fp = open(TESTFN, 'r')
@@ -1032,7 +961,6 @@ class BuiltinTest(unittest.TestCase):
sys.stdin = fp
sys.stdout = BitBucket()
self.assertEqual(input(), "1+1")
- self.assertEqual(input('testing\n'), "1+1")
self.assertEqual(input(), 'The quick brown fox jumps over the lazy dog.')
self.assertEqual(input('testing\n'), 'Dear John')
@@ -1063,7 +991,6 @@ class BuiltinTest(unittest.TestCase):
def test_repr(self):
self.assertEqual(repr(''), '\'\'')
self.assertEqual(repr(0), '0')
- self.assertEqual(repr(0), '0')
self.assertEqual(repr(()), '()')
self.assertEqual(repr([]), '[]')
self.assertEqual(repr({}), '{}')
@@ -1197,6 +1124,10 @@ class BuiltinTest(unittest.TestCase):
raise ValueError
self.assertRaises(ValueError, sum, BadSeq())
+ empty = []
+ sum(([x] for x in range(10)), empty)
+ self.assertEqual(empty, [])
+
def test_type(self):
self.assertEqual(type(''), type('123'))
self.assertNotEqual(type(''), type(()))
@@ -1214,14 +1145,19 @@ class BuiltinTest(unittest.TestCase):
b = 2
return vars()
+ class C_get_vars(object):
+ def getDict(self):
+ return {'a':2}
+ __dict__ = property(fget=getDict)
+
def test_vars(self):
self.assertEqual(set(vars()), set(dir()))
- import sys
self.assertEqual(set(vars(sys)), set(dir(sys)))
self.assertEqual(self.get_vars_f0(), {})
self.assertEqual(self.get_vars_f2(), {'a': 1, 'b': 2})
self.assertRaises(TypeError, vars, 42, 42)
self.assertRaises(TypeError, vars, 42)
+ self.assertEqual(vars(self.C_get_vars()), {'a':2})
def test_zip(self):
a = (1, 2, 3)
@@ -1267,6 +1203,116 @@ class BuiltinTest(unittest.TestCase):
return i
self.assertRaises(ValueError, list, zip(BadSeq(), BadSeq()))
+ def test_format(self):
+ # Test the basic machinery of the format() builtin. Don't test
+ # the specifics of the various formatters
+ self.assertEqual(format(3, ''), '3')
+
+ # Returns some classes to use for various tests. There's
+ # an old-style version, and a new-style version
+ def classes_new():
+ class A(object):
+ def __init__(self, x):
+ self.x = x
+ def __format__(self, format_spec):
+ return str(self.x) + format_spec
+ class DerivedFromA(A):
+ pass
+
+ class Simple(object): pass
+ class DerivedFromSimple(Simple):
+ def __init__(self, x):
+ self.x = x
+ def __format__(self, format_spec):
+ return str(self.x) + format_spec
+ class DerivedFromSimple2(DerivedFromSimple): pass
+ return A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2
+
+ def class_test(A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2):
+ self.assertEqual(format(A(3), 'spec'), '3spec')
+ self.assertEqual(format(DerivedFromA(4), 'spec'), '4spec')
+ self.assertEqual(format(DerivedFromSimple(5), 'abc'), '5abc')
+ self.assertEqual(format(DerivedFromSimple2(10), 'abcdef'),
+ '10abcdef')
+
+ class_test(*classes_new())
+
+ def empty_format_spec(value):
+ # test that:
+ # format(x, '') == str(x)
+ # format(x) == str(x)
+ self.assertEqual(format(value, ""), str(value))
+ self.assertEqual(format(value), str(value))
+
+ # for builtin types, format(x, "") == str(x)
+ empty_format_spec(17**13)
+ empty_format_spec(1.0)
+ empty_format_spec(3.1415e104)
+ empty_format_spec(-3.1415e104)
+ empty_format_spec(3.1415e-104)
+ empty_format_spec(-3.1415e-104)
+ empty_format_spec(object)
+ empty_format_spec(None)
+
+ # TypeError because self.__format__ returns the wrong type
+ class BadFormatResult:
+ def __format__(self, format_spec):
+ return 1.0
+ self.assertRaises(TypeError, format, BadFormatResult(), "")
+
+ # TypeError because format_spec is not unicode or str
+ self.assertRaises(TypeError, format, object(), 4)
+ self.assertRaises(TypeError, format, object(), object())
+
+ # tests for object.__format__ really belong elsewhere, but
+ # there's no good place to put them
+ x = object().__format__('')
+ self.assertTrue(x.startswith('<object object at'))
+
+ # first argument to object.__format__ must be string
+ self.assertRaises(TypeError, object().__format__, 3)
+ self.assertRaises(TypeError, object().__format__, object())
+ self.assertRaises(TypeError, object().__format__, None)
+
+ # --------------------------------------------------------------------
+ # Issue #7994: object.__format__ with a non-empty format string is
+ # pending deprecated
+ def test_deprecated_format_string(obj, fmt_str, should_raise_warning):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always", PendingDeprecationWarning)
+ format(obj, fmt_str)
+ if should_raise_warning:
+ self.assertEqual(len(w), 1)
+ self.assertIsInstance(w[0].message, PendingDeprecationWarning)
+ self.assertIn('object.__format__ with a non-empty format '
+ 'string', str(w[0].message))
+ else:
+ self.assertEqual(len(w), 0)
+
+ fmt_strs = ['', 's']
+
+ class A:
+ def __format__(self, fmt_str):
+ return format('', fmt_str)
+
+ for fmt_str in fmt_strs:
+ test_deprecated_format_string(A(), fmt_str, False)
+
+ class B:
+ pass
+
+ class C(object):
+ pass
+
+ for cls in [object, B, C]:
+ for fmt_str in fmt_strs:
+ test_deprecated_format_string(cls(), fmt_str, len(fmt_str) != 0)
+ # --------------------------------------------------------------------
+
+ # make sure we can take a subclass of str as a format spec
+ class DerivedFromStr(str): pass
+ self.assertEqual(format(0, DerivedFromStr('10')), ' 0')
+
def test_bin(self):
self.assertEqual(bin(0), '0b0')
self.assertEqual(bin(1), '0b1')
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 8b964ca89f..9be1008c36 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -9,15 +9,28 @@ import os
import re
import sys
import copy
-import operator
+import functools
import pickle
import tempfile
import unittest
-import warnings
import test.support
import test.string_tests
import test.buffer_tests
+
+if sys.flags.bytes_warning:
+ def check_bytes_warnings(func):
+ @functools.wraps(func)
+ def wrapper(*args, **kw):
+ with test.support.check_warnings(('', BytesWarning)):
+ return func(*args, **kw)
+ return wrapper
+else:
+ # no-op
+ def check_bytes_warnings(func):
+ return func
+
+
class Indexable:
def __init__(self, value=0):
self.value = value
@@ -27,17 +40,18 @@ class Indexable:
class BaseBytesTest(unittest.TestCase):
- def setUp(self):
- self.warning_filters = warnings.filters[:]
-
- def tearDown(self):
- warnings.filters = self.warning_filters
-
def test_basics(self):
b = self.type2test()
self.assertEqual(type(b), self.type2test)
self.assertEqual(b.__class__, self.type2test)
+ def test_copy(self):
+ a = self.type2test(b"abcd")
+ for copy_method in (copy.copy, copy.deepcopy):
+ b = copy_method(a)
+ self.assertEqual(a, b)
+ self.assertEqual(type(a), type(b))
+
def test_empty_sequence(self):
b = self.type2test()
self.assertEqual(len(b), 0)
@@ -120,14 +134,17 @@ class BaseBytesTest(unittest.TestCase):
self.assertFalse(b3 < b2)
self.assertFalse(b3 <= b2)
+ @check_bytes_warnings
def test_compare_to_str(self):
- warnings.simplefilter('ignore', BytesWarning)
# Byte comparisons with unicode should always fail!
- # Test this for all expected byte orders and Unicode character sizes
+ # Test this for all expected byte orders and Unicode character
+ # sizes.
self.assertEqual(self.type2test(b"\0a\0b\0c") == "abc", False)
- self.assertEqual(self.type2test(b"\0\0\0a\0\0\0b\0\0\0c") == "abc", False)
+ self.assertEqual(self.type2test(b"\0\0\0a\0\0\0b\0\0\0c") == "abc",
+ False)
self.assertEqual(self.type2test(b"a\0b\0c\0") == "abc", False)
- self.assertEqual(self.type2test(b"a\0\0\0b\0\0\0c\0\0\0") == "abc", False)
+ self.assertEqual(self.type2test(b"a\0\0\0b\0\0\0c\0\0\0") == "abc",
+ False)
self.assertEqual(self.type2test() == str(), False)
self.assertEqual(self.type2test() != str(), True)
@@ -187,6 +204,8 @@ class BaseBytesTest(unittest.TestCase):
b = self.type2test(sample, "latin1")
self.assertRaises(UnicodeDecodeError, b.decode, "utf8")
self.assertEqual(b.decode("utf8", "ignore"), "Hello world\n")
+ self.assertEqual(b.decode(errors="ignore", encoding="utf8"),
+ "Hello world\n")
def test_from_int(self):
b = self.type2test(0)
@@ -213,35 +232,36 @@ class BaseBytesTest(unittest.TestCase):
self.assertRaises(TypeError, lambda: b * 3.14)
self.assertRaises(TypeError, lambda: 3.14 * b)
# XXX Shouldn't bytes and bytearray agree on what to raise?
- self.assertRaises((OverflowError, MemoryError),
- lambda: b * sys.maxsize)
+ with self.assertRaises((OverflowError, MemoryError)):
+ c = b * sys.maxsize
+ with self.assertRaises((OverflowError, MemoryError)):
+ b *= sys.maxsize
def test_repeat_1char(self):
self.assertEqual(self.type2test(b'x')*100, self.type2test([ord('x')]*100))
def test_contains(self):
b = self.type2test(b"abc")
- self.assertTrue(ord('a') in b)
- self.assertTrue(int(ord('a')) in b)
- self.assertFalse(200 in b)
- self.assertFalse(200 in b)
+ self.assertIn(ord('a'), b)
+ self.assertIn(int(ord('a')), b)
+ self.assertNotIn(200, b)
self.assertRaises(ValueError, lambda: 300 in b)
self.assertRaises(ValueError, lambda: -1 in b)
self.assertRaises(TypeError, lambda: None in b)
self.assertRaises(TypeError, lambda: float(ord('a')) in b)
self.assertRaises(TypeError, lambda: "a" in b)
for f in bytes, bytearray:
- self.assertTrue(f(b"") in b)
- self.assertTrue(f(b"a") in b)
- self.assertTrue(f(b"b") in b)
- self.assertTrue(f(b"c") in b)
- self.assertTrue(f(b"ab") in b)
- self.assertTrue(f(b"bc") in b)
- self.assertTrue(f(b"abc") in b)
- self.assertFalse(f(b"ac") in b)
- self.assertFalse(f(b"d") in b)
- self.assertFalse(f(b"dab") in b)
- self.assertFalse(f(b"abd") in b)
+ self.assertIn(f(b""), b)
+ self.assertIn(f(b"a"), b)
+ self.assertIn(f(b"b"), b)
+ self.assertIn(f(b"c"), b)
+ self.assertIn(f(b"ab"), b)
+ self.assertIn(f(b"bc"), b)
+ self.assertIn(f(b"abc"), b)
+ self.assertNotIn(f(b"ac"), b)
+ self.assertNotIn(f(b"d"), b)
+ self.assertNotIn(f(b"dab"), b)
+ self.assertNotIn(f(b"abd"), b)
def test_fromhex(self):
self.assertRaises(TypeError, self.type2test.fromhex)
@@ -269,13 +289,6 @@ class BaseBytesTest(unittest.TestCase):
self.assertEqual(self.type2test(b".").join([b"ab", b"cd"]), b"ab.cd")
# XXX more...
- def test_index(self):
- b = self.type2test(b'parrot')
- self.assertEqual(b.index('p'), 0)
- self.assertEqual(b.index('rr'), 2)
- self.assertEqual(b.index('t'), 5)
- self.assertRaises(ValueError, lambda: b.index('w'))
-
def test_count(self):
b = self.type2test(b'mississippi')
self.assertEqual(b.count(b'i'), 4)
@@ -361,6 +374,10 @@ class BaseBytesTest(unittest.TestCase):
def test_split_string_error(self):
self.assertRaises(TypeError, self.type2test(b'a b').split, ' ')
+ def test_split_unicodewhitespace(self):
+ b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F")
+ self.assertEqual(b.split(), [b'\x1c\x1d\x1e\x1f'])
+
def test_rsplit(self):
b = self.type2test(b'mississippi')
self.assertEqual(b.rsplit(b'i'), [b'm', b'ss', b'ss', b'pp', b''])
@@ -384,18 +401,18 @@ class BaseBytesTest(unittest.TestCase):
def test_rsplit_unicodewhitespace(self):
b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F")
- self.assertEqual(b.split(), [b'\x1c\x1d\x1e\x1f'])
self.assertEqual(b.rsplit(), [b'\x1c\x1d\x1e\x1f'])
def test_partition(self):
b = self.type2test(b'mississippi')
self.assertEqual(b.partition(b'ss'), (b'mi', b'ss', b'issippi'))
- self.assertEqual(b.rpartition(b'w'), (b'', b'', b'mississippi'))
+ self.assertEqual(b.partition(b'w'), (b'mississippi', b'', b''))
def test_rpartition(self):
b = self.type2test(b'mississippi')
self.assertEqual(b.rpartition(b'ss'), (b'missi', b'ss', b'ippi'))
self.assertEqual(b.rpartition(b'i'), (b'mississipp', b'i', b''))
+ self.assertEqual(b.rpartition(b'w'), (b'', b'', b'mississippi'))
def test_pickling(self):
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
@@ -480,6 +497,27 @@ class BytesTest(BaseBytesTest):
return None
self.assertRaises(TypeError, bytes, A())
+ # Test PyBytes_FromFormat()
+ def test_from_format(self):
+ test.support.import_module('ctypes')
+ from ctypes import pythonapi, py_object, c_int, c_char_p
+ PyBytes_FromFormat = pythonapi.PyBytes_FromFormat
+ PyBytes_FromFormat.restype = py_object
+
+ self.assertEqual(PyBytes_FromFormat(b'format'),
+ b'format')
+
+ self.assertEqual(PyBytes_FromFormat(b'%'), b'%')
+ self.assertEqual(PyBytes_FromFormat(b'%%'), b'%')
+ self.assertEqual(PyBytes_FromFormat(b'%%s'), b'%s')
+ self.assertEqual(PyBytes_FromFormat(b'[%%]'), b'[%]')
+ self.assertEqual(PyBytes_FromFormat(b'%%%c', c_int(ord('_'))), b'%_')
+
+ self.assertEqual(PyBytes_FromFormat(b'c:%c', c_int(255)),
+ b'c:\xff')
+ self.assertEqual(PyBytes_FromFormat(b's:%s', c_char_p(b'cstr')),
+ b's:cstr')
+
class ByteArrayTest(BaseBytesTest):
type2test = bytearray
@@ -717,7 +755,7 @@ class ByteArrayTest(BaseBytesTest):
self.assertEqual(b.pop(0), ord('w'))
self.assertEqual(b.pop(-2), ord('r'))
self.assertRaises(IndexError, lambda: b.pop(10))
- self.assertRaises(OverflowError, lambda: bytearray().pop())
+ self.assertRaises(IndexError, lambda: bytearray().pop())
# test for issue #6846
self.assertEqual(bytearray(b'\xff').pop(), 0xff)
@@ -812,27 +850,14 @@ class ByteArrayTest(BaseBytesTest):
self.assertRaises(BufferError, delslice)
self.assertEqual(b, orig)
- def test_empty_bytearray(self):
- # Issue #7561: operations on empty bytearrays could crash in many
- # situations, due to a fragile implementation of the
- # PyByteArray_AS_STRING() C macro.
- self.assertRaises(ValueError, int, bytearray(b''))
- self.assertRaises((ValueError, OSError), os.mkdir, bytearray(b''))
-
class AssortedBytesTest(unittest.TestCase):
#
# Test various combinations of bytes and bytearray
#
- def setUp(self):
- self.warning_filters = warnings.filters[:]
-
- def tearDown(self):
- warnings.filters = self.warning_filters
-
+ @check_bytes_warnings
def test_repr_str(self):
- warnings.simplefilter('ignore', BytesWarning)
for f in str, repr:
self.assertEqual(f(bytearray()), "bytearray(b'')")
self.assertEqual(f(bytearray([0])), "bytearray(b'\\x00')")
@@ -872,9 +897,9 @@ class AssortedBytesTest(unittest.TestCase):
self.assertEqual(bytes(b"abc") <= b"ab", False)
def test_doc(self):
- self.assertTrue(bytearray.__doc__ != None)
+ self.assertIsNotNone(bytearray.__doc__)
self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__)
- self.assertTrue(bytes.__doc__ != None)
+ self.assertIsNotNone(bytes.__doc__)
self.assertTrue(bytes.__doc__.startswith("bytes("), bytes.__doc__)
def test_from_bytearray(self):
@@ -883,8 +908,8 @@ class AssortedBytesTest(unittest.TestCase):
b = bytearray(buf)
self.assertEqual(b, bytearray(sample))
+ @check_bytes_warnings
def test_to_str(self):
- warnings.simplefilter('ignore', BytesWarning)
self.assertEqual(str(b''), "b''")
self.assertEqual(str(b'x'), "b'x'")
self.assertEqual(str(b'\x80'), "b'\\x80'")
@@ -936,14 +961,18 @@ class AssortedBytesTest(unittest.TestCase):
def test_compare(self):
if sys.flags.bytes_warning:
- warnings.simplefilter('error', BytesWarning)
- self.assertRaises(BytesWarning, operator.eq, b'', '')
- self.assertRaises(BytesWarning, operator.ne, b'', '')
- self.assertRaises(BytesWarning, operator.eq, bytearray(b''), '')
- self.assertRaises(BytesWarning, operator.ne, bytearray(b''), '')
+ def bytes_warning():
+ return test.support.check_warnings(('', BytesWarning))
+ with bytes_warning():
+ b'' == ''
+ with bytes_warning():
+ b'' != ''
+ with bytes_warning():
+ bytearray(b'') == ''
+ with bytes_warning():
+ bytearray(b'') != ''
else:
- # self.skipTest("BytesWarning is needed for this test: use -bb option")
- pass
+ self.skipTest("BytesWarning is needed for this test: use -bb option")
# Optimizations:
# __iter__? (optimization)
@@ -975,7 +1004,13 @@ class BytearrayPEP3137Test(unittest.TestCase,
self.assertEqual(val, newval)
self.assertTrue(val is not newval,
methname+' returned self on a mutable object')
-
+ for expr in ('val.split()[0]', 'val.rsplit()[0]',
+ 'val.partition(b".")[0]', 'val.rpartition(b".")[2]',
+ 'val.splitlines()[0]', 'val.replace(b"", b"")'):
+ newval = eval(expr)
+ self.assertEqual(val, newval)
+ self.assertTrue(val is not newval,
+ expr+' returned val on a mutable object')
class FixedStringTest(test.string_tests.BaseTest):
@@ -1003,17 +1038,14 @@ class BytesAsStringTest(FixedStringTest):
type2test = bytes
-class ByteArraySubclass(bytearray):
- pass
-
-class ByteArraySubclassTest(unittest.TestCase):
+class SubclassTest(unittest.TestCase):
def test_basic(self):
- self.assertTrue(issubclass(ByteArraySubclass, bytearray))
- self.assertTrue(isinstance(ByteArraySubclass(), bytearray))
+ self.assertTrue(issubclass(self.subclass2test, self.type2test))
+ self.assertIsInstance(self.subclass2test(), self.type2test)
a, b = b"abcd", b"efgh"
- _a, _b = ByteArraySubclass(a), ByteArraySubclass(b)
+ _a, _b = self.subclass2test(a), self.subclass2test(b)
# test comparison operators with subclass instances
self.assertTrue(_a == _a)
@@ -1036,19 +1068,19 @@ class ByteArraySubclassTest(unittest.TestCase):
# Make sure join returns a NEW object for single item sequences
# involving a subclass.
# Make sure that it is of the appropriate type.
- s1 = ByteArraySubclass(b"abcd")
- s2 = bytearray().join([s1])
+ s1 = self.subclass2test(b"abcd")
+ s2 = self.type2test().join([s1])
self.assertTrue(s1 is not s2)
- self.assertTrue(type(s2) is bytearray, type(s2))
+ self.assertTrue(type(s2) is self.type2test, type(s2))
# Test reverse, calling join on subclass
s3 = s1.join([b"abcd"])
- self.assertTrue(type(s3) is bytearray)
+ self.assertTrue(type(s3) is self.type2test)
def test_pickle(self):
- a = ByteArraySubclass(b"abcd")
+ a = self.subclass2test(b"abcd")
a.x = 10
- a.y = ByteArraySubclass(b"efgh")
+ a.y = self.subclass2test(b"efgh")
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
b = pickle.loads(pickle.dumps(a, proto))
self.assertNotEqual(id(a), id(b))
@@ -1059,9 +1091,9 @@ class ByteArraySubclassTest(unittest.TestCase):
self.assertEqual(type(a.y), type(b.y))
def test_copy(self):
- a = ByteArraySubclass(b"abcd")
+ a = self.subclass2test(b"abcd")
a.x = 10
- a.y = ByteArraySubclass(b"efgh")
+ a.y = self.subclass2test(b"efgh")
for copy_method in (copy.copy, copy.deepcopy):
b = copy_method(a)
self.assertNotEqual(id(a), id(b))
@@ -1071,21 +1103,38 @@ class ByteArraySubclassTest(unittest.TestCase):
self.assertEqual(type(a), type(b))
self.assertEqual(type(a.y), type(b.y))
+
+class ByteArraySubclass(bytearray):
+ pass
+
+class BytesSubclass(bytes):
+ pass
+
+class ByteArraySubclassTest(SubclassTest):
+ type2test = bytearray
+ subclass2test = ByteArraySubclass
+
def test_init_override(self):
class subclass(bytearray):
- def __init__(self, newarg=1, *args, **kwargs):
- bytearray.__init__(self, *args, **kwargs)
+ def __init__(me, newarg=1, *args, **kwargs):
+ bytearray.__init__(me, *args, **kwargs)
+ x = subclass(4, b"abcd")
x = subclass(4, source=b"abcd")
self.assertEqual(x, b"abcd")
x = subclass(newarg=4, source=b"abcd")
self.assertEqual(x, b"abcd")
+class BytesSubclassTest(SubclassTest):
+ type2test = bytes
+ subclass2test = BytesSubclass
+
+
def test_main():
test.support.run_unittest(
BytesTest, AssortedBytesTest, BytesAsStringTest,
- ByteArrayTest, ByteArrayAsStringTest, ByteArraySubclassTest,
- BytearrayPEP3137Test)
+ ByteArrayTest, ByteArrayAsStringTest, BytesSubclassTest,
+ ByteArraySubclassTest, BytearrayPEP3137Test)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index fbf8fff47c..be3558050b 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
from test import support
from test.support import TESTFN
@@ -7,11 +7,14 @@ from io import BytesIO
import os
import subprocess
import sys
-import threading
+
+try:
+ import threading
+except ImportError:
+ threading = None
# Skip tests if the bz2 module doesn't exist.
bz2 = support.import_module('bz2')
-
from bz2 import BZ2File, BZ2Compressor, BZ2Decompressor
has_cmdline_bunzip2 = sys.platform not in ("win32", "os2emx")
@@ -52,76 +55,68 @@ class BZ2FileTest(BaseTest):
os.unlink(self.filename)
def createTempFile(self, crlf=0):
- f = open(self.filename, "wb")
- if crlf:
- data = self.DATA_CRLF
- else:
- data = self.DATA
- f.write(data)
- f.close()
+ with open(self.filename, "wb") as f:
+ if crlf:
+ data = self.DATA_CRLF
+ else:
+ data = self.DATA
+ f.write(data)
def testRead(self):
# "Test BZ2File.read()"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- self.assertRaises(TypeError, bz2f.read, None)
- self.assertEqual(bz2f.read(), self.TEXT)
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ self.assertRaises(TypeError, bz2f.read, None)
+ self.assertEqual(bz2f.read(), self.TEXT)
def testRead0(self):
# Test BBZ2File.read(0)"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- self.assertRaises(TypeError, bz2f.read, None)
- self.assertEqual(bz2f.read(0), b"")
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ self.assertRaises(TypeError, bz2f.read, None)
+ self.assertEqual(bz2f.read(0), b"")
def testReadChunk10(self):
# "Test BZ2File.read() in chunks of 10 bytes"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- text = b''
- while 1:
- str = bz2f.read(10)
- if not str:
- break
- text += str
- self.assertEqual(text, self.TEXT)
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ text = b''
+ while 1:
+ str = bz2f.read(10)
+ if not str:
+ break
+ text += str
+ self.assertEqual(text, self.TEXT)
def testRead100(self):
# "Test BZ2File.read(100)"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- self.assertEqual(bz2f.read(100), self.TEXT[:100])
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ self.assertEqual(bz2f.read(100), self.TEXT[:100])
def testReadLine(self):
# "Test BZ2File.readline()"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- self.assertRaises(TypeError, bz2f.readline, None)
- sio = BytesIO(self.TEXT)
- for line in sio.readlines():
- self.assertEqual(bz2f.readline(), line)
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ self.assertRaises(TypeError, bz2f.readline, None)
+ sio = BytesIO(self.TEXT)
+ for line in sio.readlines():
+ self.assertEqual(bz2f.readline(), line)
def testReadLines(self):
# "Test BZ2File.readlines()"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- self.assertRaises(TypeError, bz2f.readlines, None)
- sio = BytesIO(self.TEXT)
- self.assertEqual(bz2f.readlines(), sio.readlines())
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ self.assertRaises(TypeError, bz2f.readlines, None)
+ sio = BytesIO(self.TEXT)
+ self.assertEqual(bz2f.readlines(), sio.readlines())
def testIterator(self):
# "Test iter(BZ2File)"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- sio = BytesIO(self.TEXT)
- self.assertEqual(list(iter(bz2f)), sio.readlines())
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ sio = BytesIO(self.TEXT)
+ self.assertEqual(list(iter(bz2f)), sio.readlines())
def testClosedIteratorDeadlock(self):
# "Test that iteration on a closed bz2file releases the lock."
@@ -136,104 +131,91 @@ class BZ2FileTest(BaseTest):
def testWrite(self):
# "Test BZ2File.write()"
- bz2f = BZ2File(self.filename, "w")
- self.assertRaises(TypeError, bz2f.write)
- bz2f.write(self.TEXT)
- bz2f.close()
- f = open(self.filename, 'rb')
- self.assertEqual(self.decompress(f.read()), self.TEXT)
- f.close()
+ with BZ2File(self.filename, "w") as bz2f:
+ self.assertRaises(TypeError, bz2f.write)
+ bz2f.write(self.TEXT)
+ with open(self.filename, 'rb') as f:
+ self.assertEqual(self.decompress(f.read()), self.TEXT)
def testWriteChunks10(self):
# "Test BZ2File.write() with chunks of 10 bytes"
- bz2f = BZ2File(self.filename, "w")
- n = 0
- while 1:
- str = self.TEXT[n*10:(n+1)*10]
- if not str:
- break
- bz2f.write(str)
- n += 1
- bz2f.close()
- f = open(self.filename, 'rb')
- self.assertEqual(self.decompress(f.read()), self.TEXT)
- f.close()
+ with BZ2File(self.filename, "w") as bz2f:
+ n = 0
+ while 1:
+ str = self.TEXT[n*10:(n+1)*10]
+ if not str:
+ break
+ bz2f.write(str)
+ n += 1
+ with open(self.filename, 'rb') as f:
+ self.assertEqual(self.decompress(f.read()), self.TEXT)
def testWriteLines(self):
# "Test BZ2File.writelines()"
- bz2f = BZ2File(self.filename, "w")
- self.assertRaises(TypeError, bz2f.writelines)
- sio = BytesIO(self.TEXT)
- bz2f.writelines(sio.readlines())
- bz2f.close()
+ with BZ2File(self.filename, "w") as bz2f:
+ self.assertRaises(TypeError, bz2f.writelines)
+ sio = BytesIO(self.TEXT)
+ bz2f.writelines(sio.readlines())
# patch #1535500
self.assertRaises(ValueError, bz2f.writelines, ["a"])
- f = open(self.filename, 'rb')
- self.assertEqual(self.decompress(f.read()), self.TEXT)
- f.close()
+ with open(self.filename, 'rb') as f:
+ self.assertEqual(self.decompress(f.read()), self.TEXT)
def testWriteMethodsOnReadOnlyFile(self):
- bz2f = BZ2File(self.filename, "w")
- bz2f.write(b"abc")
- bz2f.close()
+ with BZ2File(self.filename, "w") as bz2f:
+ bz2f.write(b"abc")
- bz2f = BZ2File(self.filename, "r")
- self.assertRaises(IOError, bz2f.write, b"a")
- self.assertRaises(IOError, bz2f.writelines, [b"a"])
+ with BZ2File(self.filename, "r") as bz2f:
+ self.assertRaises(IOError, bz2f.write, b"a")
+ self.assertRaises(IOError, bz2f.writelines, [b"a"])
def testSeekForward(self):
# "Test BZ2File.seek(150, 0)"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- self.assertRaises(TypeError, bz2f.seek)
- bz2f.seek(150)
- self.assertEqual(bz2f.read(), self.TEXT[150:])
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ self.assertRaises(TypeError, bz2f.seek)
+ bz2f.seek(150)
+ self.assertEqual(bz2f.read(), self.TEXT[150:])
def testSeekBackwards(self):
# "Test BZ2File.seek(-150, 1)"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- bz2f.read(500)
- bz2f.seek(-150, 1)
- self.assertEqual(bz2f.read(), self.TEXT[500-150:])
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ bz2f.read(500)
+ bz2f.seek(-150, 1)
+ self.assertEqual(bz2f.read(), self.TEXT[500-150:])
def testSeekBackwardsFromEnd(self):
# "Test BZ2File.seek(-150, 2)"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- bz2f.seek(-150, 2)
- self.assertEqual(bz2f.read(), self.TEXT[len(self.TEXT)-150:])
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ bz2f.seek(-150, 2)
+ self.assertEqual(bz2f.read(), self.TEXT[len(self.TEXT)-150:])
def testSeekPostEnd(self):
# "Test BZ2File.seek(150000)"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- bz2f.seek(150000)
- self.assertEqual(bz2f.tell(), len(self.TEXT))
- self.assertEqual(bz2f.read(), b"")
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ bz2f.seek(150000)
+ self.assertEqual(bz2f.tell(), len(self.TEXT))
+ self.assertEqual(bz2f.read(), b"")
def testSeekPostEndTwice(self):
# "Test BZ2File.seek(150000) twice"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- bz2f.seek(150000)
- bz2f.seek(150000)
- self.assertEqual(bz2f.tell(), len(self.TEXT))
- self.assertEqual(bz2f.read(), b"")
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ bz2f.seek(150000)
+ bz2f.seek(150000)
+ self.assertEqual(bz2f.tell(), len(self.TEXT))
+ self.assertEqual(bz2f.read(), b"")
def testSeekPreStart(self):
# "Test BZ2File.seek(-150, 0)"
self.createTempFile()
- bz2f = BZ2File(self.filename)
- bz2f.seek(-150)
- self.assertEqual(bz2f.tell(), 0)
- self.assertEqual(bz2f.read(), self.TEXT)
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ bz2f.seek(-150)
+ self.assertEqual(bz2f.tell(), 0)
+ self.assertEqual(bz2f.read(), self.TEXT)
def testOpenDel(self):
# "Test opening and deleting a file many times"
@@ -249,16 +231,13 @@ class BZ2FileTest(BaseTest):
def testBug1191043(self):
# readlines() for files containing no newline
data = b'BZh91AY&SY\xd9b\x89]\x00\x00\x00\x03\x80\x04\x00\x02\x00\x0c\x00 \x00!\x9ah3M\x13<]\xc9\x14\xe1BCe\x8a%t'
- f = open(self.filename, "wb")
- f.write(data)
- f.close()
- bz2f = BZ2File(self.filename)
- lines = bz2f.readlines()
- bz2f.close()
+ with open(self.filename, "wb") as f:
+ f.write(data)
+ with BZ2File(self.filename) as bz2f:
+ lines = bz2f.readlines()
self.assertEqual(lines, [b'Test'])
- bz2f = BZ2File(self.filename)
- xlines = list(bz2f.readlines())
- bz2f.close()
+ with BZ2File(self.filename) as bz2f:
+ xlines = list(bz2f.readlines())
self.assertEqual(xlines, [b'Test'])
def testContextProtocol(self):
@@ -283,12 +262,12 @@ class BZ2FileTest(BaseTest):
else:
self.fail("1/0 didn't raise an exception")
+ @unittest.skipUnless(threading, 'Threading required for this test.')
def testThreading(self):
# Using a BZ2File from several threads doesn't deadlock (issue #7205).
data = b"1" * 2**20
nthreads = 10
- f = bz2.BZ2File(self.filename, 'wb')
- try:
+ with bz2.BZ2File(self.filename, 'wb') as f:
def comp():
for i in range(5):
f.write(data)
@@ -297,27 +276,19 @@ class BZ2FileTest(BaseTest):
t.start()
for t in threads:
t.join()
- finally:
- f.close()
def testMixedIterationReads(self):
# Issue #8397: mixed iteration and reads should be forbidden.
- f = bz2.BZ2File(self.filename, 'wb')
- try:
+ with bz2.BZ2File(self.filename, 'wb') as f:
# The internal buffer size is hard-wired to 8192 bytes, we must
# write out more than that for the test to stop half through
# the buffer.
f.write(self.TEXT * 100)
- finally:
- f.close()
- f = bz2.BZ2File(self.filename, 'rb')
- try:
+ with bz2.BZ2File(self.filename, 'rb') as f:
next(f)
self.assertRaises(ValueError, f.read)
self.assertRaises(ValueError, f.readline)
self.assertRaises(ValueError, f.readlines)
- finally:
- f.close()
class BZ2CompressorTest(BaseTest):
def testCompress(self):
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index f2969e285d..4bd758b641 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -2,9 +2,9 @@ import calendar
import unittest
from test import support
+import time
import locale
-
result_2004_text = """
2004
@@ -262,7 +262,7 @@ class CalendarTestCase(unittest.TestCase):
return
calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10)
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
- self.assertEquals(old_october, new_october)
+ self.assertEqual(old_october, new_october)
class MonthCalendarTestCase(unittest.TestCase):
@@ -395,6 +395,13 @@ class SundayTestCase(MonthCalendarTestCase):
# A 31-day december starting on friday (2+7+7+7+7+1 days)
self.check_weeks(1995, 12, (2, 7, 7, 7, 7, 1))
+class TimegmTestCase(unittest.TestCase):
+ TIMESTAMPS = [0, 10, 100, 1000, 10000, 100000, 1000000,
+ 1234567890, 1262304000, 1275785153,]
+ def test_timegm(self):
+ for secs in self.TIMESTAMPS:
+ tuple = time.gmtime(secs)
+ self.assertEqual(secs, calendar.timegm(tuple))
class MonthRangeTestCase(unittest.TestCase):
def test_january(self):
@@ -450,6 +457,7 @@ def test_main():
CalendarTestCase,
MondayTestCase,
SundayTestCase,
+ TimegmTestCase,
MonthRangeTestCase,
LeapdaysTestCase,
)
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 3f1d63c490..f9133474e1 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -2,12 +2,16 @@
# these are all functions _testcapi exports whose name begins with 'test_'.
from __future__ import with_statement
+import random
+import subprocess
import sys
import time
-import random
import unittest
-import threading
from test import support
+try:
+ import threading
+except ImportError:
+ threading = None
import _testcapi
@@ -32,7 +36,24 @@ class CAPITest(unittest.TestCase):
self.assertEqual(testfunction.attribute, "test")
self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute", "test")
-
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ def test_no_FatalError_infinite_loop(self):
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import _testcapi;'
+ '_testcapi.crash_no_current_thread()'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ (out, err) = p.communicate()
+ self.assertEqual(out, b'')
+ # This used to cause an infinite loop.
+ self.assertEqual(err.rstrip(),
+ b'Fatal Python error:'
+ b' PyThreadState_Get: no current thread')
+
+ def test_memoryview_from_NULL_pointer(self):
+ self.assertRaises(ValueError, _testcapi.make_memoryview_from_NULL_pointer)
+
+@unittest.skipUnless(threading, 'Threading required for this test.')
class TestPendingCalls(unittest.TestCase):
def pendingcalls_submit(self, l, n):
@@ -148,17 +169,10 @@ def test_main():
raise support.TestFailed(
"Couldn't find main thread correctly in the list")
- try:
- _testcapi._test_thread_state
- have_thread_state = True
- except AttributeError:
- have_thread_state = False
-
- if have_thread_state:
+ if threading:
import _thread
import time
TestThreadState()
- import threading
t = threading.Thread(target=TestThreadState)
t.start()
t.join()
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index 299870c4e4..f7d9a26e89 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -1,11 +1,16 @@
+import collections
import configparser
import io
+import os
+import sys
+import textwrap
import unittest
-import collections
+import warnings
from test import support
class SortedDict(collections.UserDict):
+
def items(self):
return sorted(self.data.items())
@@ -20,67 +25,219 @@ class SortedDict(collections.UserDict):
__iter__ = iterkeys
def itervalues(self): return iter(self.values())
-class TestCaseBase(unittest.TestCase):
+
+class CfgParserTestCaseClass(unittest.TestCase):
+ allow_no_value = False
+ delimiters = ('=', ':')
+ comment_prefixes = (';', '#')
+ inline_comment_prefixes = (';', '#')
+ empty_lines_in_values = True
+ dict_type = configparser._default_dict
+ strict = False
+ default_section = configparser.DEFAULTSECT
+ interpolation = configparser._UNSET
+
def newconfig(self, defaults=None):
- if defaults is None:
- self.cf = self.config_class()
- else:
- self.cf = self.config_class(defaults)
- return self.cf
+ arguments = dict(
+ defaults=defaults,
+ allow_no_value=self.allow_no_value,
+ delimiters=self.delimiters,
+ comment_prefixes=self.comment_prefixes,
+ inline_comment_prefixes=self.inline_comment_prefixes,
+ empty_lines_in_values=self.empty_lines_in_values,
+ dict_type=self.dict_type,
+ strict=self.strict,
+ default_section=self.default_section,
+ interpolation=self.interpolation,
+ )
+ instance = self.config_class(**arguments)
+ return instance
def fromstring(self, string, defaults=None):
cf = self.newconfig(defaults)
- sio = io.StringIO(string)
- cf.readfp(sio)
+ cf.read_string(string)
return cf
- def test_basic(self):
- cf = self.fromstring(
- "[Foo Bar]\n"
- "foo=bar\n"
- "[Spacey Bar]\n"
- "foo = bar\n"
- "[Commented Bar]\n"
- "foo: bar ; comment\n"
- "[Long Line]\n"
- "foo: this line is much, much longer than my editor\n"
- " likes it.\n"
- "[Section\\with$weird%characters[\t]\n"
- "[Internationalized Stuff]\n"
- "foo[bg]: Bulgarian\n"
- "foo=Default\n"
- "foo[en]=English\n"
- "foo[de]=Deutsch\n"
- "[Spaces]\n"
- "key with spaces : value\n"
- "another with spaces = splat!\n"
- )
+class BasicTestCase(CfgParserTestCaseClass):
+
+ def basic_test(self, cf):
+ E = ['Commented Bar',
+ 'Foo Bar',
+ 'Internationalized Stuff',
+ 'Long Line',
+ 'Section\\with$weird%characters[\t',
+ 'Spaces',
+ 'Spacey Bar',
+ 'Spacey Bar From The Beginning',
+ 'Types',
+ ]
+
+ if self.allow_no_value:
+ E.append('NoValue')
+ E.sort()
+ F = [('baz', 'qwe'), ('foo', 'bar3')]
+
+ # API access
L = cf.sections()
L.sort()
eq = self.assertEqual
- eq(L, [r'Commented Bar',
- r'Foo Bar',
- r'Internationalized Stuff',
- r'Long Line',
- r'Section\with$weird%characters[' '\t',
- r'Spaces',
- r'Spacey Bar',
- ])
+ eq(L, E)
+ L = cf.items('Spacey Bar From The Beginning')
+ L.sort()
+ eq(L, F)
+
+ # mapping access
+ L = [section for section in cf]
+ L.sort()
+ E.append(self.default_section)
+ E.sort()
+ eq(L, E)
+ L = cf['Spacey Bar From The Beginning'].items()
+ L = sorted(list(L))
+ eq(L, F)
+ L = cf.items()
+ L = sorted(list(L))
+ self.assertEqual(len(L), len(E))
+ for name, section in L:
+ eq(name, section.name)
+ eq(cf.defaults(), cf[self.default_section])
# The use of spaces in the section names serves as a
# regression test for SourceForge bug #583248:
# http://www.python.org/sf/583248
- eq(cf.get('Foo Bar', 'foo'), 'bar')
- eq(cf.get('Spacey Bar', 'foo'), 'bar')
- eq(cf.get('Commented Bar', 'foo'), 'bar')
+
+ # API access
+ eq(cf.get('Foo Bar', 'foo'), 'bar1')
+ eq(cf.get('Spacey Bar', 'foo'), 'bar2')
+ eq(cf.get('Spacey Bar From The Beginning', 'foo'), 'bar3')
+ eq(cf.get('Spacey Bar From The Beginning', 'baz'), 'qwe')
+ eq(cf.get('Commented Bar', 'foo'), 'bar4')
+ eq(cf.get('Commented Bar', 'baz'), 'qwe')
eq(cf.get('Spaces', 'key with spaces'), 'value')
eq(cf.get('Spaces', 'another with spaces'), 'splat!')
+ eq(cf.getint('Types', 'int'), 42)
+ eq(cf.get('Types', 'int'), "42")
+ self.assertAlmostEqual(cf.getfloat('Types', 'float'), 0.44)
+ eq(cf.get('Types', 'float'), "0.44")
+ eq(cf.getboolean('Types', 'boolean'), False)
+ eq(cf.get('Types', '123'), 'strange but acceptable')
+ if self.allow_no_value:
+ eq(cf.get('NoValue', 'option-without-value'), None)
- self.assertFalse('__name__' in cf.options("Foo Bar"),
- '__name__ "option" should not be exposed by the API!')
+ # test vars= and fallback=
+ eq(cf.get('Foo Bar', 'foo', fallback='baz'), 'bar1')
+ eq(cf.get('Foo Bar', 'foo', vars={'foo': 'baz'}), 'baz')
+ with self.assertRaises(configparser.NoSectionError):
+ cf.get('No Such Foo Bar', 'foo')
+ with self.assertRaises(configparser.NoOptionError):
+ cf.get('Foo Bar', 'no-such-foo')
+ eq(cf.get('No Such Foo Bar', 'foo', fallback='baz'), 'baz')
+ eq(cf.get('Foo Bar', 'no-such-foo', fallback='baz'), 'baz')
+ eq(cf.get('Spacey Bar', 'foo', fallback=None), 'bar2')
+ eq(cf.get('No Such Spacey Bar', 'foo', fallback=None), None)
+ eq(cf.getint('Types', 'int', fallback=18), 42)
+ eq(cf.getint('Types', 'no-such-int', fallback=18), 18)
+ eq(cf.getint('Types', 'no-such-int', fallback="18"), "18") # sic!
+ with self.assertRaises(configparser.NoOptionError):
+ cf.getint('Types', 'no-such-int')
+ self.assertAlmostEqual(cf.getfloat('Types', 'float',
+ fallback=0.0), 0.44)
+ self.assertAlmostEqual(cf.getfloat('Types', 'no-such-float',
+ fallback=0.0), 0.0)
+ eq(cf.getfloat('Types', 'no-such-float', fallback="0.0"), "0.0") # sic!
+ with self.assertRaises(configparser.NoOptionError):
+ cf.getfloat('Types', 'no-such-float')
+ eq(cf.getboolean('Types', 'boolean', fallback=True), False)
+ eq(cf.getboolean('Types', 'no-such-boolean', fallback="yes"),
+ "yes") # sic!
+ eq(cf.getboolean('Types', 'no-such-boolean', fallback=True), True)
+ with self.assertRaises(configparser.NoOptionError):
+ cf.getboolean('Types', 'no-such-boolean')
+ eq(cf.getboolean('No Such Types', 'boolean', fallback=True), True)
+ if self.allow_no_value:
+ eq(cf.get('NoValue', 'option-without-value', fallback=False), None)
+ eq(cf.get('NoValue', 'no-such-option-without-value',
+ fallback=False), False)
- # Make sure the right things happen for remove_option();
- # added to include check for SourceForge bug #123324:
+ # mapping access
+ eq(cf['Foo Bar']['foo'], 'bar1')
+ eq(cf['Spacey Bar']['foo'], 'bar2')
+ section = cf['Spacey Bar From The Beginning']
+ eq(section.name, 'Spacey Bar From The Beginning')
+ self.assertIs(section.parser, cf)
+ with self.assertRaises(AttributeError):
+ section.name = 'Name is read-only'
+ with self.assertRaises(AttributeError):
+ section.parser = 'Parser is read-only'
+ eq(section['foo'], 'bar3')
+ eq(section['baz'], 'qwe')
+ eq(cf['Commented Bar']['foo'], 'bar4')
+ eq(cf['Commented Bar']['baz'], 'qwe')
+ eq(cf['Spaces']['key with spaces'], 'value')
+ eq(cf['Spaces']['another with spaces'], 'splat!')
+ eq(cf['Long Line']['foo'],
+ 'this line is much, much longer than my editor\nlikes it.')
+ if self.allow_no_value:
+ eq(cf['NoValue']['option-without-value'], None)
+ # test vars= and fallback=
+ eq(cf['Foo Bar'].get('foo', 'baz'), 'bar1')
+ eq(cf['Foo Bar'].get('foo', fallback='baz'), 'bar1')
+ eq(cf['Foo Bar'].get('foo', vars={'foo': 'baz'}), 'baz')
+ with self.assertRaises(KeyError):
+ cf['No Such Foo Bar']['foo']
+ with self.assertRaises(KeyError):
+ cf['Foo Bar']['no-such-foo']
+ with self.assertRaises(KeyError):
+ cf['No Such Foo Bar'].get('foo', fallback='baz')
+ eq(cf['Foo Bar'].get('no-such-foo', 'baz'), 'baz')
+ eq(cf['Foo Bar'].get('no-such-foo', fallback='baz'), 'baz')
+ eq(cf['Foo Bar'].get('no-such-foo'), None)
+ eq(cf['Spacey Bar'].get('foo', None), 'bar2')
+ eq(cf['Spacey Bar'].get('foo', fallback=None), 'bar2')
+ with self.assertRaises(KeyError):
+ cf['No Such Spacey Bar'].get('foo', None)
+ eq(cf['Types'].getint('int', 18), 42)
+ eq(cf['Types'].getint('int', fallback=18), 42)
+ eq(cf['Types'].getint('no-such-int', 18), 18)
+ eq(cf['Types'].getint('no-such-int', fallback=18), 18)
+ eq(cf['Types'].getint('no-such-int', "18"), "18") # sic!
+ eq(cf['Types'].getint('no-such-int', fallback="18"), "18") # sic!
+ eq(cf['Types'].getint('no-such-int'), None)
+ self.assertAlmostEqual(cf['Types'].getfloat('float', 0.0), 0.44)
+ self.assertAlmostEqual(cf['Types'].getfloat('float',
+ fallback=0.0), 0.44)
+ self.assertAlmostEqual(cf['Types'].getfloat('no-such-float', 0.0), 0.0)
+ self.assertAlmostEqual(cf['Types'].getfloat('no-such-float',
+ fallback=0.0), 0.0)
+ eq(cf['Types'].getfloat('no-such-float', "0.0"), "0.0") # sic!
+ eq(cf['Types'].getfloat('no-such-float', fallback="0.0"), "0.0") # sic!
+ eq(cf['Types'].getfloat('no-such-float'), None)
+ eq(cf['Types'].getboolean('boolean', True), False)
+ eq(cf['Types'].getboolean('boolean', fallback=True), False)
+ eq(cf['Types'].getboolean('no-such-boolean', "yes"), "yes") # sic!
+ eq(cf['Types'].getboolean('no-such-boolean', fallback="yes"),
+ "yes") # sic!
+ eq(cf['Types'].getboolean('no-such-boolean', True), True)
+ eq(cf['Types'].getboolean('no-such-boolean', fallback=True), True)
+ eq(cf['Types'].getboolean('no-such-boolean'), None)
+ if self.allow_no_value:
+ eq(cf['NoValue'].get('option-without-value', False), None)
+ eq(cf['NoValue'].get('option-without-value', fallback=False), None)
+ eq(cf['NoValue'].get('no-such-option-without-value', False), False)
+ eq(cf['NoValue'].get('no-such-option-without-value',
+ fallback=False), False)
+
+ # Make sure the right things happen for remove_section() and
+ # remove_option(); added to include check for SourceForge bug #123324.
+
+ cf[self.default_section]['this_value'] = '1'
+ cf[self.default_section]['that_value'] = '2'
+
+ # API access
+ self.assertTrue(cf.remove_section('Spaces'))
+ self.assertFalse(cf.has_option('Spaces', 'key with spaces'))
+ self.assertFalse(cf.remove_section('Spaces'))
+ self.assertFalse(cf.remove_section(self.default_section))
self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report existence of option")
self.assertFalse(cf.has_option('Foo Bar', 'foo'),
@@ -88,26 +245,199 @@ class TestCaseBase(unittest.TestCase):
self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report non-existence of option"
" that was removed")
+ self.assertTrue(cf.has_option('Foo Bar', 'this_value'))
+ self.assertFalse(cf.remove_option('Foo Bar', 'this_value'))
+ self.assertTrue(cf.remove_option(self.default_section, 'this_value'))
+ self.assertFalse(cf.has_option('Foo Bar', 'this_value'))
+ self.assertFalse(cf.remove_option(self.default_section, 'this_value'))
- self.assertRaises(configparser.NoSectionError,
- cf.remove_option, 'No Such Section', 'foo')
+ with self.assertRaises(configparser.NoSectionError) as cm:
+ cf.remove_option('No Such Section', 'foo')
+ self.assertEqual(cm.exception.args, ('No Such Section',))
eq(cf.get('Long Line', 'foo'),
'this line is much, much longer than my editor\nlikes it.')
+ # mapping access
+ del cf['Types']
+ self.assertFalse('Types' in cf)
+ with self.assertRaises(KeyError):
+ del cf['Types']
+ with self.assertRaises(ValueError):
+ del cf[self.default_section]
+ del cf['Spacey Bar']['foo']
+ self.assertFalse('foo' in cf['Spacey Bar'])
+ with self.assertRaises(KeyError):
+ del cf['Spacey Bar']['foo']
+ self.assertTrue('that_value' in cf['Spacey Bar'])
+ with self.assertRaises(KeyError):
+ del cf['Spacey Bar']['that_value']
+ del cf[self.default_section]['that_value']
+ self.assertFalse('that_value' in cf['Spacey Bar'])
+ with self.assertRaises(KeyError):
+ del cf[self.default_section]['that_value']
+ with self.assertRaises(KeyError):
+ del cf['No Such Section']['foo']
+
+ # Don't add new asserts below in this method as most of the options
+ # and sections are now removed.
+
+ def test_basic(self):
+ config_string = """\
+[Foo Bar]
+foo{0[0]}bar1
+[Spacey Bar]
+foo {0[0]} bar2
+[Spacey Bar From The Beginning]
+ foo {0[0]} bar3
+ baz {0[0]} qwe
+[Commented Bar]
+foo{0[1]} bar4 {1[1]} comment
+baz{0[0]}qwe {1[0]}another one
+[Long Line]
+foo{0[1]} this line is much, much longer than my editor
+ likes it.
+[Section\\with$weird%characters[\t]
+[Internationalized Stuff]
+foo[bg]{0[1]} Bulgarian
+foo{0[0]}Default
+foo[en]{0[0]}English
+foo[de]{0[0]}Deutsch
+[Spaces]
+key with spaces {0[1]} value
+another with spaces {0[0]} splat!
+[Types]
+int {0[1]} 42
+float {0[0]} 0.44
+boolean {0[0]} NO
+123 {0[1]} strange but acceptable
+""".format(self.delimiters, self.comment_prefixes)
+ if self.allow_no_value:
+ config_string += (
+ "[NoValue]\n"
+ "option-without-value\n"
+ )
+ cf = self.fromstring(config_string)
+ self.basic_test(cf)
+ if self.strict:
+ with self.assertRaises(configparser.DuplicateOptionError):
+ cf.read_string(textwrap.dedent("""\
+ [Duplicate Options Here]
+ option {0[0]} with a value
+ option {0[1]} with another value
+ """.format(self.delimiters)))
+ with self.assertRaises(configparser.DuplicateSectionError):
+ cf.read_string(textwrap.dedent("""\
+ [And Now For Something]
+ completely different {0[0]} True
+ [And Now For Something]
+ the larch {0[1]} 1
+ """.format(self.delimiters)))
+ else:
+ cf.read_string(textwrap.dedent("""\
+ [Duplicate Options Here]
+ option {0[0]} with a value
+ option {0[1]} with another value
+ """.format(self.delimiters)))
+
+ cf.read_string(textwrap.dedent("""\
+ [And Now For Something]
+ completely different {0[0]} True
+ [And Now For Something]
+ the larch {0[1]} 1
+ """.format(self.delimiters)))
+
+ def test_basic_from_dict(self):
+ config = {
+ "Foo Bar": {
+ "foo": "bar1",
+ },
+ "Spacey Bar": {
+ "foo": "bar2",
+ },
+ "Spacey Bar From The Beginning": {
+ "foo": "bar3",
+ "baz": "qwe",
+ },
+ "Commented Bar": {
+ "foo": "bar4",
+ "baz": "qwe",
+ },
+ "Long Line": {
+ "foo": "this line is much, much longer than my editor\nlikes "
+ "it.",
+ },
+ "Section\\with$weird%characters[\t": {
+ },
+ "Internationalized Stuff": {
+ "foo[bg]": "Bulgarian",
+ "foo": "Default",
+ "foo[en]": "English",
+ "foo[de]": "Deutsch",
+ },
+ "Spaces": {
+ "key with spaces": "value",
+ "another with spaces": "splat!",
+ },
+ "Types": {
+ "int": 42,
+ "float": 0.44,
+ "boolean": False,
+ 123: "strange but acceptable",
+ },
+ }
+ if self.allow_no_value:
+ config.update({
+ "NoValue": {
+ "option-without-value": None,
+ }
+ })
+ cf = self.newconfig()
+ cf.read_dict(config)
+ self.basic_test(cf)
+ if self.strict:
+ with self.assertRaises(configparser.DuplicateSectionError):
+ cf.read_dict({
+ '1': {'key': 'value'},
+ 1: {'key2': 'value2'},
+ })
+ with self.assertRaises(configparser.DuplicateOptionError):
+ cf.read_dict({
+ "Duplicate Options Here": {
+ 'option': 'with a value',
+ 'OPTION': 'with another value',
+ },
+ })
+ else:
+ cf.read_dict({
+ 'section': {'key': 'value'},
+ 'SECTION': {'key2': 'value2'},
+ })
+ cf.read_dict({
+ "Duplicate Options Here": {
+ 'option': 'with a value',
+ 'OPTION': 'with another value',
+ },
+ })
+
def test_case_sensitivity(self):
cf = self.newconfig()
cf.add_section("A")
cf.add_section("a")
+ cf.add_section("B")
L = cf.sections()
L.sort()
eq = self.assertEqual
- eq(L, ["A", "a"])
+ eq(L, ["A", "B", "a"])
cf.set("a", "B", "value")
eq(cf.options("a"), ["b"])
eq(cf.get("a", "b"), "value",
"could not locate option, expecting case-insensitive option names")
+ with self.assertRaises(configparser.NoSectionError):
+ # section names are case-sensitive
+ cf.set("b", "A", "value")
self.assertTrue(cf.has_option("a", "b"))
+ self.assertFalse(cf.has_option("b", "b"))
cf.set("A", "A-B", "A-B value")
for opt in ("a-b", "A-b", "a-B", "A-B"):
self.assertTrue(
@@ -120,62 +450,125 @@ class TestCaseBase(unittest.TestCase):
# SF bug #432369:
cf = self.fromstring(
- "[MySection]\nOption: first line\n\tsecond line\n")
+ "[MySection]\nOption{} first line \n\tsecond line \n".format(
+ self.delimiters[0]))
eq(cf.options("MySection"), ["option"])
eq(cf.get("MySection", "Option"), "first line\nsecond line")
# SF bug #561822:
- cf = self.fromstring("[section]\nnekey=nevalue\n",
+ cf = self.fromstring("[section]\n"
+ "nekey{}nevalue\n".format(self.delimiters[0]),
defaults={"key":"value"})
self.assertTrue(cf.has_option("section", "Key"))
+ def test_case_sensitivity_mapping_access(self):
+ cf = self.newconfig()
+ cf["A"] = {}
+ cf["a"] = {"B": "value"}
+ cf["B"] = {}
+ L = [section for section in cf]
+ L.sort()
+ eq = self.assertEqual
+ elem_eq = self.assertCountEqual
+ eq(L, sorted(["A", "B", self.default_section, "a"]))
+ eq(cf["a"].keys(), {"b"})
+ eq(cf["a"]["b"], "value",
+ "could not locate option, expecting case-insensitive option names")
+ with self.assertRaises(KeyError):
+ # section names are case-sensitive
+ cf["b"]["A"] = "value"
+ self.assertTrue("b" in cf["a"])
+ cf["A"]["A-B"] = "A-B value"
+ for opt in ("a-b", "A-b", "a-B", "A-B"):
+ self.assertTrue(
+ opt in cf["A"],
+ "has_option() returned false for option which should exist")
+ eq(cf["A"].keys(), {"a-b"})
+ eq(cf["a"].keys(), {"b"})
+ del cf["a"]["B"]
+ elem_eq(cf["a"].keys(), {})
+
+ # SF bug #432369:
+ cf = self.fromstring(
+ "[MySection]\nOption{} first line \n\tsecond line \n".format(
+ self.delimiters[0]))
+ eq(cf["MySection"].keys(), {"option"})
+ eq(cf["MySection"]["Option"], "first line\nsecond line")
+
+ # SF bug #561822:
+ cf = self.fromstring("[section]\n"
+ "nekey{}nevalue\n".format(self.delimiters[0]),
+ defaults={"key":"value"})
+ self.assertTrue("Key" in cf["section"])
+
def test_default_case_sensitivity(self):
cf = self.newconfig({"foo": "Bar"})
self.assertEqual(
- cf.get("DEFAULT", "Foo"), "Bar",
+ cf.get(self.default_section, "Foo"), "Bar",
"could not locate option, expecting case-insensitive option names")
cf = self.newconfig({"Foo": "Bar"})
self.assertEqual(
- cf.get("DEFAULT", "Foo"), "Bar",
+ cf.get(self.default_section, "Foo"), "Bar",
"could not locate option, expecting case-insensitive defaults")
def test_parse_errors(self):
- self.newconfig()
- self.parse_error(configparser.ParsingError,
- "[Foo]\n extra-spaces: splat\n")
- self.parse_error(configparser.ParsingError,
- "[Foo]\n extra-spaces= splat\n")
- self.parse_error(configparser.ParsingError,
- "[Foo]\noption-without-value\n")
- self.parse_error(configparser.ParsingError,
- "[Foo]\n:value-without-option-name\n")
- self.parse_error(configparser.ParsingError,
- "[Foo]\n=value-without-option-name\n")
- self.parse_error(configparser.MissingSectionHeaderError,
- "No Section!\n")
-
- def parse_error(self, exc, src):
- sio = io.StringIO(src)
- self.assertRaises(exc, self.cf.readfp, sio)
+ cf = self.newconfig()
+ self.parse_error(cf, configparser.ParsingError,
+ "[Foo]\n"
+ "{}val-without-opt-name\n".format(self.delimiters[0]))
+ self.parse_error(cf, configparser.ParsingError,
+ "[Foo]\n"
+ "{}val-without-opt-name\n".format(self.delimiters[1]))
+ e = self.parse_error(cf, configparser.MissingSectionHeaderError,
+ "No Section!\n")
+ self.assertEqual(e.args, ('<???>', 1, "No Section!\n"))
+ if not self.allow_no_value:
+ e = self.parse_error(cf, configparser.ParsingError,
+ "[Foo]\n wrong-indent\n")
+ self.assertEqual(e.args, ('<???>',))
+ # read_file on a real file
+ tricky = support.findfile("cfgparser.3")
+ if self.delimiters[0] == '=':
+ error = configparser.ParsingError
+ expected = (tricky,)
+ else:
+ error = configparser.MissingSectionHeaderError
+ expected = (tricky, 1,
+ ' # INI with as many tricky parts as possible\n')
+ with open(tricky, encoding='utf-8') as f:
+ e = self.parse_error(cf, error, f)
+ self.assertEqual(e.args, expected)
+
+ def parse_error(self, cf, exc, src):
+ if hasattr(src, 'readline'):
+ sio = src
+ else:
+ sio = io.StringIO(src)
+ with self.assertRaises(exc) as cm:
+ cf.read_file(sio)
+ return cm.exception
def test_query_errors(self):
cf = self.newconfig()
self.assertEqual(cf.sections(), [],
"new ConfigParser should have no defined sections")
self.assertFalse(cf.has_section("Foo"),
- "new ConfigParser should have no acknowledged sections")
- self.assertRaises(configparser.NoSectionError,
- cf.options, "Foo")
- self.assertRaises(configparser.NoSectionError,
- cf.set, "foo", "bar", "value")
- self.get_error(configparser.NoSectionError, "foo", "bar")
+ "new ConfigParser should have no acknowledged "
+ "sections")
+ with self.assertRaises(configparser.NoSectionError):
+ cf.options("Foo")
+ with self.assertRaises(configparser.NoSectionError):
+ cf.set("foo", "bar", "value")
+ e = self.get_error(cf, configparser.NoSectionError, "foo", "bar")
+ self.assertEqual(e.args, ("foo",))
cf.add_section("foo")
- self.get_error(configparser.NoOptionError, "foo", "bar")
+ e = self.get_error(cf, configparser.NoOptionError, "foo", "bar")
+ self.assertEqual(e.args, ("bar", "foo"))
- def get_error(self, exc, section, option):
+ def get_error(self, cf, exc, section, option):
try:
- self.cf.get(section, option)
+ cf.get(section, option)
except exc as e:
return e
else:
@@ -185,21 +578,21 @@ class TestCaseBase(unittest.TestCase):
def test_boolean(self):
cf = self.fromstring(
"[BOOLTEST]\n"
- "T1=1\n"
- "T2=TRUE\n"
- "T3=True\n"
- "T4=oN\n"
- "T5=yes\n"
- "F1=0\n"
- "F2=FALSE\n"
- "F3=False\n"
- "F4=oFF\n"
- "F5=nO\n"
- "E1=2\n"
- "E2=foo\n"
- "E3=-1\n"
- "E4=0.1\n"
- "E5=FALSE AND MORE"
+ "T1{equals}1\n"
+ "T2{equals}TRUE\n"
+ "T3{equals}True\n"
+ "T4{equals}oN\n"
+ "T5{equals}yes\n"
+ "F1{equals}0\n"
+ "F2{equals}FALSE\n"
+ "F3{equals}False\n"
+ "F4{equals}oFF\n"
+ "F5{equals}nO\n"
+ "E1{equals}2\n"
+ "E2{equals}foo\n"
+ "E3{equals}-1\n"
+ "E4{equals}0.1\n"
+ "E5{equals}FALSE AND MORE".format(equals=self.delimiters[0])
)
for x in range(1, 5):
self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
@@ -210,35 +603,91 @@ class TestCaseBase(unittest.TestCase):
def test_weird_errors(self):
cf = self.newconfig()
cf.add_section("Foo")
- self.assertRaises(configparser.DuplicateSectionError,
- cf.add_section, "Foo")
+ with self.assertRaises(configparser.DuplicateSectionError) as cm:
+ cf.add_section("Foo")
+ e = cm.exception
+ self.assertEqual(str(e), "Section 'Foo' already exists")
+ self.assertEqual(e.args, ("Foo", None, None))
+
+ if self.strict:
+ with self.assertRaises(configparser.DuplicateSectionError) as cm:
+ cf.read_string(textwrap.dedent("""\
+ [Foo]
+ will this be added{equals}True
+ [Bar]
+ what about this{equals}True
+ [Foo]
+ oops{equals}this won't
+ """.format(equals=self.delimiters[0])), source='<foo-bar>')
+ e = cm.exception
+ self.assertEqual(str(e), "While reading from <foo-bar> [line 5]: "
+ "section 'Foo' already exists")
+ self.assertEqual(e.args, ("Foo", '<foo-bar>', 5))
+
+ with self.assertRaises(configparser.DuplicateOptionError) as cm:
+ cf.read_dict({'Bar': {'opt': 'val', 'OPT': 'is really `opt`'}})
+ e = cm.exception
+ self.assertEqual(str(e), "While reading from <dict>: option 'opt' "
+ "in section 'Bar' already exists")
+ self.assertEqual(e.args, ("Bar", "opt", "<dict>", None))
def test_write(self):
- cf = self.fromstring(
+ config_string = (
"[Long Line]\n"
- "foo: this line is much, much longer than my editor\n"
+ "foo{0[0]} this line is much, much longer than my editor\n"
" likes it.\n"
- "[DEFAULT]\n"
- "foo: another very\n"
- " long line"
+ "[{default_section}]\n"
+ "foo{0[1]} another very\n"
+ " long line\n"
+ "[Long Line - With Comments!]\n"
+ "test {0[1]} we {comment} can\n"
+ " also {comment} place\n"
+ " comments {comment} in\n"
+ " multiline {comment} values"
+ "\n".format(self.delimiters, comment=self.comment_prefixes[0],
+ default_section=self.default_section)
)
- output = io.StringIO()
- cf.write(output)
- self.assertEqual(
- output.getvalue(),
- "[DEFAULT]\n"
- "foo = another very\n"
- "\tlong line\n"
- "\n"
- "[Long Line]\n"
- "foo = this line is much, much longer than my editor\n"
- "\tlikes it.\n"
- "\n"
+ if self.allow_no_value:
+ config_string += (
+ "[Valueless]\n"
+ "option-without-value\n"
)
+ cf = self.fromstring(config_string)
+ for space_around_delimiters in (True, False):
+ output = io.StringIO()
+ cf.write(output, space_around_delimiters=space_around_delimiters)
+ delimiter = self.delimiters[0]
+ if space_around_delimiters:
+ delimiter = " {} ".format(delimiter)
+ expect_string = (
+ "[{default_section}]\n"
+ "foo{equals}another very\n"
+ "\tlong line\n"
+ "\n"
+ "[Long Line]\n"
+ "foo{equals}this line is much, much longer than my editor\n"
+ "\tlikes it.\n"
+ "\n"
+ "[Long Line - With Comments!]\n"
+ "test{equals}we\n"
+ "\talso\n"
+ "\tcomments\n"
+ "\tmultiline\n"
+ "\n".format(equals=delimiter,
+ default_section=self.default_section)
+ )
+ if self.allow_no_value:
+ expect_string += (
+ "[Valueless]\n"
+ "option-without-value\n"
+ "\n"
+ )
+ self.assertEqual(output.getvalue(), expect_string)
+
def test_set_string_types(self):
cf = self.fromstring("[sect]\n"
- "option1=foo\n")
+ "option1{eq}foo\n".format(eq=self.delimiters[0]))
# Check that we don't get an exception when setting values in
# an existing section using strings:
class mystr(str):
@@ -251,6 +700,9 @@ class TestCaseBase(unittest.TestCase):
cf.set("sect", "option2", "splat")
def test_read_returns_file_list(self):
+ if self.delimiters[0] != '=':
+ # skip reading the file if we're using an incompatible format
+ return
file1 = support.findfile("cfgparser.1")
# check when we pass a mix of readable and non-readable files:
cf = self.newconfig()
@@ -275,102 +727,200 @@ class TestCaseBase(unittest.TestCase):
def get_interpolation_config(self):
return self.fromstring(
"[Foo]\n"
- "bar=something %(with1)s interpolation (1 step)\n"
- "bar9=something %(with9)s lots of interpolation (9 steps)\n"
- "bar10=something %(with10)s lots of interpolation (10 steps)\n"
- "bar11=something %(with11)s lots of interpolation (11 steps)\n"
- "with11=%(with10)s\n"
- "with10=%(with9)s\n"
- "with9=%(with8)s\n"
- "with8=%(With7)s\n"
- "with7=%(WITH6)s\n"
- "with6=%(with5)s\n"
- "With5=%(with4)s\n"
- "WITH4=%(with3)s\n"
- "with3=%(with2)s\n"
- "with2=%(with1)s\n"
- "with1=with\n"
+ "bar{equals}something %(with1)s interpolation (1 step)\n"
+ "bar9{equals}something %(with9)s lots of interpolation (9 steps)\n"
+ "bar10{equals}something %(with10)s lots of interpolation (10 steps)\n"
+ "bar11{equals}something %(with11)s lots of interpolation (11 steps)\n"
+ "with11{equals}%(with10)s\n"
+ "with10{equals}%(with9)s\n"
+ "with9{equals}%(with8)s\n"
+ "with8{equals}%(With7)s\n"
+ "with7{equals}%(WITH6)s\n"
+ "with6{equals}%(with5)s\n"
+ "With5{equals}%(with4)s\n"
+ "WITH4{equals}%(with3)s\n"
+ "with3{equals}%(with2)s\n"
+ "with2{equals}%(with1)s\n"
+ "with1{equals}with\n"
"\n"
"[Mutual Recursion]\n"
- "foo=%(bar)s\n"
- "bar=%(foo)s\n"
+ "foo{equals}%(bar)s\n"
+ "bar{equals}%(foo)s\n"
"\n"
"[Interpolation Error]\n"
- "name=%(reference)s\n",
# no definition for 'reference'
- defaults={"getname": "%(__name__)s"})
+ "name{equals}%(reference)s\n".format(equals=self.delimiters[0]))
def check_items_config(self, expected):
- cf = self.fromstring(
- "[section]\n"
- "name = value\n"
- "key: |%(name)s| \n"
- "getdefault: |%(default)s|\n"
- "getname: |%(__name__)s|",
- defaults={"default": "<default>"})
- L = list(cf.items("section"))
+ cf = self.fromstring("""
+ [section]
+ name {0[0]} %(value)s
+ key{0[1]} |%(name)s|
+ getdefault{0[1]} |%(default)s|
+ """.format(self.delimiters), defaults={"default": "<default>"})
+ L = list(cf.items("section", vars={'value': 'value'}))
L.sort()
self.assertEqual(L, expected)
+ with self.assertRaises(configparser.NoSectionError):
+ cf.items("no such section")
+
+
+class StrictTestCase(BasicTestCase):
+ config_class = configparser.RawConfigParser
+ strict = True
-class ConfigParserTestCase(TestCaseBase):
+class ConfigParserTestCase(BasicTestCase):
config_class = configparser.ConfigParser
def test_interpolation(self):
cf = self.get_interpolation_config()
eq = self.assertEqual
- eq(cf.get("Foo", "getname"), "Foo")
eq(cf.get("Foo", "bar"), "something with interpolation (1 step)")
eq(cf.get("Foo", "bar9"),
"something with lots of interpolation (9 steps)")
eq(cf.get("Foo", "bar10"),
"something with lots of interpolation (10 steps)")
- self.get_error(configparser.InterpolationDepthError, "Foo", "bar11")
+ e = self.get_error(cf, configparser.InterpolationDepthError, "Foo", "bar11")
+ if self.interpolation == configparser._UNSET:
+ self.assertEqual(e.args, ("bar11", "Foo", "%(with1)s"))
+ elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+ self.assertEqual(e.args, ("bar11", "Foo",
+ "something %(with11)s lots of interpolation (11 steps)"))
def test_interpolation_missing_value(self):
cf = self.get_interpolation_config()
- e = self.get_error(configparser.InterpolationError,
+ e = self.get_error(cf, configparser.InterpolationMissingOptionError,
"Interpolation Error", "name")
self.assertEqual(e.reference, "reference")
self.assertEqual(e.section, "Interpolation Error")
self.assertEqual(e.option, "name")
+ if self.interpolation == configparser._UNSET:
+ self.assertEqual(e.args, ('name', 'Interpolation Error',
+ '', 'reference'))
+ elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+ self.assertEqual(e.args, ('name', 'Interpolation Error',
+ '%(reference)s', 'reference'))
def test_items(self):
self.check_items_config([('default', '<default>'),
('getdefault', '|<default>|'),
- ('getname', '|section|'),
('key', '|value|'),
- ('name', 'value')])
+ ('name', 'value'),
+ ('value', 'value')])
+
+ def test_safe_interpolation(self):
+ # See http://www.python.org/sf/511737
+ cf = self.fromstring("[section]\n"
+ "option1{eq}xxx\n"
+ "option2{eq}%(option1)s/xxx\n"
+ "ok{eq}%(option1)s/%%s\n"
+ "not_ok{eq}%(option2)s/%%s".format(
+ eq=self.delimiters[0]))
+ self.assertEqual(cf.get("section", "ok"), "xxx/%s")
+ if self.interpolation == configparser._UNSET:
+ self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
+ elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+ with self.assertRaises(TypeError):
+ cf.get("section", "not_ok")
+
+ def test_set_malformatted_interpolation(self):
+ cf = self.fromstring("[sect]\n"
+ "option1{eq}foo\n".format(eq=self.delimiters[0]))
+
+ self.assertEqual(cf.get('sect', "option1"), "foo")
+
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
+
+ self.assertEqual(cf.get('sect', "option1"), "foo")
+
+ # bug #5741: double percents are *not* malformed
+ cf.set("sect", "option2", "foo%%bar")
+ self.assertEqual(cf.get("sect", "option2"), "foo%bar")
def test_set_nonstring_types(self):
+ cf = self.fromstring("[sect]\n"
+ "option1{eq}foo\n".format(eq=self.delimiters[0]))
+ # Check that we get a TypeError when setting non-string values
+ # in an existing section:
+ self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
+ self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
+ self.assertRaises(TypeError, cf.set, "sect", "option1", object())
+ self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
+ self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
+ self.assertRaises(TypeError, cf.set, "sect", "option2", object())
+ self.assertRaises(TypeError, cf.set, "sect", 123, "invalid opt name!")
+ self.assertRaises(TypeError, cf.add_section, 123)
+
+ def test_add_section_default(self):
cf = self.newconfig()
- cf.add_section('non-string')
- cf.set('non-string', 'int', 1)
- cf.set('non-string', 'list', [0, 1, 1, 2, 3, 5, 8, 13, '%('])
- cf.set('non-string', 'dict', {'pi': 3.14159, '%(': 1,
- '%(list)': '%(list)'})
- cf.set('non-string', 'string_with_interpolation', '%(list)s')
- self.assertEqual(cf.get('non-string', 'int', raw=True), 1)
- self.assertRaises(TypeError, cf.get, 'non-string', 'int')
- self.assertEqual(cf.get('non-string', 'list', raw=True),
- [0, 1, 1, 2, 3, 5, 8, 13, '%('])
- self.assertRaises(TypeError, cf.get, 'non-string', 'list')
- self.assertEqual(cf.get('non-string', 'dict', raw=True),
- {'pi': 3.14159, '%(': 1, '%(list)': '%(list)'})
- self.assertRaises(TypeError, cf.get, 'non-string', 'dict')
- self.assertEqual(cf.get('non-string', 'string_with_interpolation',
- raw=True), '%(list)s')
- self.assertRaises(ValueError, cf.get, 'non-string',
- 'string_with_interpolation', raw=False)
-
-
-class RawConfigParserTestCase(TestCaseBase):
+ self.assertRaises(ValueError, cf.add_section, self.default_section)
+
+class ConfigParserTestCaseLegacyInterpolation(ConfigParserTestCase):
+ config_class = configparser.ConfigParser
+ interpolation = configparser.LegacyInterpolation()
+
+ def test_set_malformatted_interpolation(self):
+ cf = self.fromstring("[sect]\n"
+ "option1{eq}foo\n".format(eq=self.delimiters[0]))
+
+ self.assertEqual(cf.get('sect', "option1"), "foo")
+
+ cf.set("sect", "option1", "%foo")
+ self.assertEqual(cf.get('sect', "option1"), "%foo")
+ cf.set("sect", "option1", "foo%")
+ self.assertEqual(cf.get('sect', "option1"), "foo%")
+ cf.set("sect", "option1", "f%oo")
+ self.assertEqual(cf.get('sect', "option1"), "f%oo")
+
+ # bug #5741: double percents are *not* malformed
+ cf.set("sect", "option2", "foo%%bar")
+ self.assertEqual(cf.get("sect", "option2"), "foo%%bar")
+
+class ConfigParserTestCaseNonStandardDelimiters(ConfigParserTestCase):
+ delimiters = (':=', '$')
+ comment_prefixes = ('//', '"')
+ inline_comment_prefixes = ('//', '"')
+
+class ConfigParserTestCaseNonStandardDefaultSection(ConfigParserTestCase):
+ default_section = 'general'
+
+class MultilineValuesTestCase(BasicTestCase):
+ config_class = configparser.ConfigParser
+ wonderful_spam = ("I'm having spam spam spam spam "
+ "spam spam spam beaked beans spam "
+ "spam spam and spam!").replace(' ', '\t\n')
+
+ def setUp(self):
+ cf = self.newconfig()
+ for i in range(100):
+ s = 'section{}'.format(i)
+ cf.add_section(s)
+ for j in range(10):
+ cf.set(s, 'lovely_spam{}'.format(j), self.wonderful_spam)
+ with open(support.TESTFN, 'w') as f:
+ cf.write(f)
+
+ def tearDown(self):
+ os.unlink(support.TESTFN)
+
+ def test_dominating_multiline_values(self):
+ # We're reading from file because this is where the code changed
+ # during performance updates in Python 3.2
+ cf_from_file = self.newconfig()
+ with open(support.TESTFN) as f:
+ cf_from_file.read_file(f)
+ self.assertEqual(cf_from_file.get('section8', 'lovely_spam4'),
+ self.wonderful_spam.replace('\t\n', '\n'))
+
+class RawConfigParserTestCase(BasicTestCase):
config_class = configparser.RawConfigParser
def test_interpolation(self):
cf = self.get_interpolation_config()
eq = self.assertEqual
- eq(cf.get("Foo", "getname"), "%(__name__)s")
eq(cf.get("Foo", "bar"),
"something %(with1)s interpolation (1 step)")
eq(cf.get("Foo", "bar9"),
@@ -383,9 +933,9 @@ class RawConfigParserTestCase(TestCaseBase):
def test_items(self):
self.check_items_config([('default', '<default>'),
('getdefault', '|%(default)s|'),
- ('getname', '|%(__name__)s|'),
('key', '|%(name)s|'),
- ('name', 'value')])
+ ('name', '%(value)s'),
+ ('value', 'value')])
def test_set_nonstring_types(self):
cf = self.newconfig()
@@ -397,72 +947,244 @@ class RawConfigParserTestCase(TestCaseBase):
self.assertEqual(cf.get('non-string', 'list'),
[0, 1, 1, 2, 3, 5, 8, 13])
self.assertEqual(cf.get('non-string', 'dict'), {'pi': 3.14159})
+ cf.add_section(123)
+ cf.set(123, 'this is sick', True)
+ self.assertEqual(cf.get(123, 'this is sick'), True)
+ if cf._dict.__class__ is configparser._default_dict:
+ # would not work for SortedDict; only checking for the most common
+ # default dictionary (OrderedDict)
+ cf.optionxform = lambda x: x
+ cf.set('non-string', 1, 1)
+ self.assertEqual(cf.get('non-string', 1), 1)
+class RawConfigParserTestCaseNonStandardDelimiters(RawConfigParserTestCase):
+ delimiters = (':=', '$')
+ comment_prefixes = ('//', '"')
+ inline_comment_prefixes = ('//', '"')
-class SafeConfigParserTestCase(ConfigParserTestCase):
- config_class = configparser.SafeConfigParser
+class RawConfigParserTestSambaConf(CfgParserTestCaseClass):
+ config_class = configparser.RawConfigParser
+ comment_prefixes = ('#', ';', '----')
+ inline_comment_prefixes = ('//',)
+ empty_lines_in_values = False
- def test_safe_interpolation(self):
- # See http://www.python.org/sf/511737
- cf = self.fromstring("[section]\n"
- "option1=xxx\n"
- "option2=%(option1)s/xxx\n"
- "ok=%(option1)s/%%s\n"
- "not_ok=%(option2)s/%%s")
- self.assertEqual(cf.get("section", "ok"), "xxx/%s")
- self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
+ def test_reading(self):
+ smbconf = support.findfile("cfgparser.2")
+ # check when we pass a mix of readable and non-readable files:
+ cf = self.newconfig()
+ parsed_files = cf.read([smbconf, "nonexistent-file"], encoding='utf-8')
+ self.assertEqual(parsed_files, [smbconf])
+ sections = ['global', 'homes', 'printers',
+ 'print$', 'pdf-generator', 'tmp', 'Agustin']
+ self.assertEqual(cf.sections(), sections)
+ self.assertEqual(cf.get("global", "workgroup"), "MDKGROUP")
+ self.assertEqual(cf.getint("global", "max log size"), 50)
+ self.assertEqual(cf.get("global", "hosts allow"), "127.")
+ self.assertEqual(cf.get("tmp", "echo command"), "cat %s; rm %s")
- def test_set_malformatted_interpolation(self):
- cf = self.fromstring("[sect]\n"
- "option1=foo\n")
+class ConfigParserTestCaseExtendedInterpolation(BasicTestCase):
+ config_class = configparser.ConfigParser
+ interpolation = configparser.ExtendedInterpolation()
+ default_section = 'common'
- self.assertEqual(cf.get('sect', "option1"), "foo")
+ def test_extended_interpolation(self):
+ cf = self.fromstring(textwrap.dedent("""
+ [common]
+ favourite Beatle = Paul
+ favourite color = green
- self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
- self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
- self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
+ [tom]
+ favourite band = ${favourite color} day
+ favourite pope = John ${favourite Beatle} II
+ sequel = ${favourite pope}I
- self.assertEqual(cf.get('sect', "option1"), "foo")
+ [ambv]
+ favourite Beatle = George
+ son of Edward VII = ${favourite Beatle} V
+ son of George V = ${son of Edward VII}I
- # bug #5741: double percents are *not* malformed
- cf.set("sect", "option2", "foo%%bar")
- self.assertEqual(cf.get("sect", "option2"), "foo%bar")
+ [stanley]
+ favourite Beatle = ${ambv:favourite Beatle}
+ favourite pope = ${tom:favourite pope}
+ favourite color = black
+ favourite state of mind = paranoid
+ favourite movie = soylent ${common:favourite color}
+ favourite song = ${favourite color} sabbath - ${favourite state of mind}
+ """).strip())
+
+ eq = self.assertEqual
+ eq(cf['common']['favourite Beatle'], 'Paul')
+ eq(cf['common']['favourite color'], 'green')
+ eq(cf['tom']['favourite Beatle'], 'Paul')
+ eq(cf['tom']['favourite color'], 'green')
+ eq(cf['tom']['favourite band'], 'green day')
+ eq(cf['tom']['favourite pope'], 'John Paul II')
+ eq(cf['tom']['sequel'], 'John Paul III')
+ eq(cf['ambv']['favourite Beatle'], 'George')
+ eq(cf['ambv']['favourite color'], 'green')
+ eq(cf['ambv']['son of Edward VII'], 'George V')
+ eq(cf['ambv']['son of George V'], 'George VI')
+ eq(cf['stanley']['favourite Beatle'], 'George')
+ eq(cf['stanley']['favourite color'], 'black')
+ eq(cf['stanley']['favourite state of mind'], 'paranoid')
+ eq(cf['stanley']['favourite movie'], 'soylent green')
+ eq(cf['stanley']['favourite pope'], 'John Paul II')
+ eq(cf['stanley']['favourite song'],
+ 'black sabbath - paranoid')
+
+ def test_endless_loop(self):
+ cf = self.fromstring(textwrap.dedent("""
+ [one for you]
+ ping = ${one for me:pong}
+
+ [one for me]
+ pong = ${one for you:ping}
+
+ [selfish]
+ me = ${me}
+ """).strip())
+
+ with self.assertRaises(configparser.InterpolationDepthError):
+ cf['one for you']['ping']
+ with self.assertRaises(configparser.InterpolationDepthError):
+ cf['selfish']['me']
+
+ def test_strange_options(self):
+ cf = self.fromstring("""
+ [dollars]
+ $var = $$value
+ $var2 = ${$var}
+ ${sick} = cannot interpolate me
+
+ [interpolated]
+ $other = ${dollars:$var}
+ $trying = ${dollars:${sick}}
+ """)
+
+ self.assertEqual(cf['dollars']['$var'], '$value')
+ self.assertEqual(cf['interpolated']['$other'], '$value')
+ self.assertEqual(cf['dollars']['${sick}'], 'cannot interpolate me')
+ exception_class = configparser.InterpolationMissingOptionError
+ with self.assertRaises(exception_class) as cm:
+ cf['interpolated']['$trying']
+ self.assertEqual(cm.exception.reference, 'dollars:${sick')
+ self.assertEqual(cm.exception.args[2], '}') #rawval
- def test_set_nonstring_types(self):
- cf = self.fromstring("[sect]\n"
- "option1=foo\n")
- # Check that we get a TypeError when setting non-string values
- # in an existing section:
- self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
- self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
- self.assertRaises(TypeError, cf.set, "sect", "option1", object())
- self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
- self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
- self.assertRaises(TypeError, cf.set, "sect", "option2", object())
- def test_add_section_default_1(self):
+ def test_other_errors(self):
+ cf = self.fromstring("""
+ [interpolation fail]
+ case1 = ${where's the brace
+ case2 = ${does_not_exist}
+ case3 = ${wrong_section:wrong_value}
+ case4 = ${i:like:colon:characters}
+ case5 = $100 for Fail No 5!
+ """)
+
+ with self.assertRaises(configparser.InterpolationSyntaxError):
+ cf['interpolation fail']['case1']
+ with self.assertRaises(configparser.InterpolationMissingOptionError):
+ cf['interpolation fail']['case2']
+ with self.assertRaises(configparser.InterpolationMissingOptionError):
+ cf['interpolation fail']['case3']
+ with self.assertRaises(configparser.InterpolationSyntaxError):
+ cf['interpolation fail']['case4']
+ with self.assertRaises(configparser.InterpolationSyntaxError):
+ cf['interpolation fail']['case5']
+ with self.assertRaises(ValueError):
+ cf['interpolation fail']['case6'] = "BLACK $ABBATH"
+
+
+class ConfigParserTestCaseNoValue(ConfigParserTestCase):
+ allow_no_value = True
+
+class ConfigParserTestCaseTrickyFile(CfgParserTestCaseClass):
+ config_class = configparser.ConfigParser
+ delimiters = {'='}
+ comment_prefixes = {'#'}
+ allow_no_value = True
+
+ def test_cfgparser_dot_3(self):
+ tricky = support.findfile("cfgparser.3")
cf = self.newconfig()
- self.assertRaises(ValueError, cf.add_section, "default")
+ self.assertEqual(len(cf.read(tricky, encoding='utf-8')), 1)
+ self.assertEqual(cf.sections(), ['strange',
+ 'corruption',
+ 'yeah, sections can be '
+ 'indented as well',
+ 'another one!',
+ 'no values here',
+ 'tricky interpolation',
+ 'more interpolation'])
+ self.assertEqual(cf.getint(self.default_section, 'go',
+ vars={'interpolate': '-1'}), -1)
+ with self.assertRaises(ValueError):
+ # no interpolation will happen
+ cf.getint(self.default_section, 'go', raw=True,
+ vars={'interpolate': '-1'})
+ self.assertEqual(len(cf.get('strange', 'other').split('\n')), 4)
+ self.assertEqual(len(cf.get('corruption', 'value').split('\n')), 10)
+ longname = 'yeah, sections can be indented as well'
+ self.assertFalse(cf.getboolean(longname, 'are they subsections'))
+ self.assertEqual(cf.get(longname, 'lets use some Unicode'), '片仮å')
+ self.assertEqual(len(cf.items('another one!')), 5) # 4 in section and
+ # `go` from DEFAULT
+ with self.assertRaises(configparser.InterpolationMissingOptionError):
+ cf.items('no values here')
+ self.assertEqual(cf.get('tricky interpolation', 'lets'), 'do this')
+ self.assertEqual(cf.get('tricky interpolation', 'lets'),
+ cf.get('tricky interpolation', 'go'))
+ self.assertEqual(cf.get('more interpolation', 'lets'), 'go shopping')
- def test_add_section_default_2(self):
+ def test_unicode_failure(self):
+ tricky = support.findfile("cfgparser.3")
cf = self.newconfig()
- self.assertRaises(ValueError, cf.add_section, "DEFAULT")
+ with self.assertRaises(UnicodeDecodeError):
+ cf.read(tricky, encoding='ascii')
+
+
+class Issue7005TestCase(unittest.TestCase):
+ """Test output when None is set() as a value and allow_no_value == False.
+
+ http://bugs.python.org/issue7005
+
+ """
+
+ expected_output = "[section]\noption = None\n\n"
+
+ def prepare(self, config_class):
+ # This is the default, but that's the point.
+ cp = config_class(allow_no_value=False)
+ cp.add_section("section")
+ cp.set("section", "option", None)
+ sio = io.StringIO()
+ cp.write(sio)
+ return sio.getvalue()
+
+ def test_none_as_value_stringified(self):
+ cp = configparser.ConfigParser(allow_no_value=False)
+ cp.add_section("section")
+ with self.assertRaises(TypeError):
+ cp.set("section", "option", None)
+
+ def test_none_as_value_stringified_raw(self):
+ output = self.prepare(configparser.RawConfigParser)
+ self.assertEqual(output, self.expected_output)
+
class SortedTestCase(RawConfigParserTestCase):
- def newconfig(self, defaults=None):
- self.cf = self.config_class(defaults=defaults, dict_type=SortedDict)
- return self.cf
+ dict_type = SortedDict
def test_sorted(self):
- self.fromstring("[b]\n"
- "o4=1\n"
- "o3=2\n"
- "o2=3\n"
- "o1=4\n"
- "[a]\n"
- "k=v\n")
+ cf = self.fromstring("[b]\n"
+ "o4=1\n"
+ "o3=2\n"
+ "o2=3\n"
+ "o1=4\n"
+ "[a]\n"
+ "k=v\n")
output = io.StringIO()
- self.cf.write(output)
+ cf.write(output)
self.assertEqual(output.getvalue(),
"[a]\n"
"k = v\n\n"
@@ -472,13 +1194,149 @@ class SortedTestCase(RawConfigParserTestCase):
"o3 = 2\n"
"o4 = 1\n\n")
+
+class CompatibleTestCase(CfgParserTestCaseClass):
+ config_class = configparser.RawConfigParser
+ comment_prefixes = '#;'
+ inline_comment_prefixes = ';'
+
+ def test_comment_handling(self):
+ config_string = textwrap.dedent("""\
+ [Commented Bar]
+ baz=qwe ; a comment
+ foo: bar # not a comment!
+ # but this is a comment
+ ; another comment
+ quirk: this;is not a comment
+ ; a space must precede an inline comment
+ """)
+ cf = self.fromstring(config_string)
+ self.assertEqual(cf.get('Commented Bar', 'foo'),
+ 'bar # not a comment!')
+ self.assertEqual(cf.get('Commented Bar', 'baz'), 'qwe')
+ self.assertEqual(cf.get('Commented Bar', 'quirk'),
+ 'this;is not a comment')
+
+class CopyTestCase(BasicTestCase):
+ config_class = configparser.ConfigParser
+
+ def fromstring(self, string, defaults=None):
+ cf = self.newconfig(defaults)
+ cf.read_string(string)
+ cf_copy = self.newconfig()
+ cf_copy.read_dict(cf)
+ # we have to clean up option duplicates that appeared because of
+ # the magic DEFAULTSECT behaviour.
+ for section in cf_copy.values():
+ if section.name == self.default_section:
+ continue
+ for default, value in cf[self.default_section].items():
+ if section[default] == value:
+ del section[default]
+ return cf_copy
+
+class CoverageOneHundredTestCase(unittest.TestCase):
+ """Covers edge cases in the codebase."""
+
+ def test_duplicate_option_error(self):
+ error = configparser.DuplicateOptionError('section', 'option')
+ self.assertEqual(error.section, 'section')
+ self.assertEqual(error.option, 'option')
+ self.assertEqual(error.source, None)
+ self.assertEqual(error.lineno, None)
+ self.assertEqual(error.args, ('section', 'option', None, None))
+ self.assertEqual(str(error), "Option 'option' in section 'section' "
+ "already exists")
+
+ def test_interpolation_depth_error(self):
+ error = configparser.InterpolationDepthError('option', 'section',
+ 'rawval')
+ self.assertEqual(error.args, ('option', 'section', 'rawval'))
+ self.assertEqual(error.option, 'option')
+ self.assertEqual(error.section, 'section')
+
+ def test_parsing_error(self):
+ with self.assertRaises(ValueError) as cm:
+ configparser.ParsingError()
+ self.assertEqual(str(cm.exception), "Required argument `source' not "
+ "given.")
+ with self.assertRaises(ValueError) as cm:
+ configparser.ParsingError(source='source', filename='filename')
+ self.assertEqual(str(cm.exception), "Cannot specify both `filename' "
+ "and `source'. Use `source'.")
+ error = configparser.ParsingError(filename='source')
+ self.assertEqual(error.source, 'source')
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always", DeprecationWarning)
+ self.assertEqual(error.filename, 'source')
+ error.filename = 'filename'
+ self.assertEqual(error.source, 'filename')
+ for warning in w:
+ self.assertTrue(warning.category is DeprecationWarning)
+
+ def test_interpolation_validation(self):
+ parser = configparser.ConfigParser()
+ parser.read_string("""
+ [section]
+ invalid_percent = %
+ invalid_reference = %(()
+ invalid_variable = %(does_not_exist)s
+ """)
+ with self.assertRaises(configparser.InterpolationSyntaxError) as cm:
+ parser['section']['invalid_percent']
+ self.assertEqual(str(cm.exception), "'%' must be followed by '%' or "
+ "'(', found: '%'")
+ with self.assertRaises(configparser.InterpolationSyntaxError) as cm:
+ parser['section']['invalid_reference']
+ self.assertEqual(str(cm.exception), "bad interpolation variable "
+ "reference '%(()'")
+
+ def test_readfp_deprecation(self):
+ sio = io.StringIO("""
+ [section]
+ option = value
+ """)
+ parser = configparser.ConfigParser()
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always", DeprecationWarning)
+ parser.readfp(sio, filename='StringIO')
+ for warning in w:
+ self.assertTrue(warning.category is DeprecationWarning)
+ self.assertEqual(len(parser), 2)
+ self.assertEqual(parser['section']['option'], 'value')
+
+ def test_safeconfigparser_deprecation(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always", DeprecationWarning)
+ parser = configparser.SafeConfigParser()
+ for warning in w:
+ self.assertTrue(warning.category is DeprecationWarning)
+
+ def test_sectionproxy_repr(self):
+ parser = configparser.ConfigParser()
+ parser.read_string("""
+ [section]
+ key = value
+ """)
+ self.assertEqual(repr(parser['section']), '<Section: section>')
+
def test_main():
support.run_unittest(
ConfigParserTestCase,
+ ConfigParserTestCaseNonStandardDelimiters,
+ ConfigParserTestCaseNoValue,
+ ConfigParserTestCaseExtendedInterpolation,
+ ConfigParserTestCaseLegacyInterpolation,
+ ConfigParserTestCaseTrickyFile,
+ MultilineValuesTestCase,
RawConfigParserTestCase,
- SafeConfigParserTestCase,
- SortedTestCase
- )
-
-if __name__ == "__main__":
- test_main()
+ RawConfigParserTestCaseNonStandardDelimiters,
+ RawConfigParserTestSambaConf,
+ SortedTestCase,
+ Issue7005TestCase,
+ StrictTestCase,
+ CompatibleTestCase,
+ CopyTestCase,
+ ConfigParserTestCaseNonStandardDefaultSection,
+ CoverageOneHundredTestCase,
+ )
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index 16c6204125..d745199464 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -1,11 +1,10 @@
-from test.support import run_unittest
+from test.support import run_unittest, check_warnings
import cgi
import os
import sys
import tempfile
import unittest
-from io import StringIO
-from warnings import catch_warnings, filterwarnings
+from io import StringIO, BytesIO
class HackedSysModule:
# The regression test will have real values in sys.argv, which
@@ -15,11 +14,6 @@ class HackedSysModule:
cgi.sys = HackedSysModule()
-try:
- from io import StringIO
-except ImportError:
- from io import StringIO
-
class ComparableException:
def __init__(self, err):
self.err = err
@@ -43,7 +37,7 @@ def do_test(buf, method):
env['REQUEST_METHOD'] = 'GET'
env['QUERY_STRING'] = buf
elif method == "POST":
- fp = StringIO(buf)
+ fp = BytesIO(buf.encode('latin-1')) # FieldStorage expects bytes
env['REQUEST_METHOD'] = 'POST'
env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
env['CONTENT_LENGTH'] = str(len(buf))
@@ -111,13 +105,14 @@ def first_second_elts(list):
return [(p[0], p[1][0]) for p in list]
def gen_result(data, environ):
- fake_stdin = StringIO(data)
+ encoding = 'latin-1'
+ fake_stdin = BytesIO(data.encode(encoding))
fake_stdin.seek(0)
- form = cgi.FieldStorage(fp=fake_stdin, environ=environ)
+ form = cgi.FieldStorage(fp=fake_stdin, environ=environ, encoding=encoding)
result = {}
for k, v in dict(form).items():
- result[k] = type(v) is list and form.getlist(k) or v.value
+ result[k] = isinstance(v, list) and form.getlist(k) or v.value
return result
@@ -127,23 +122,23 @@ class CgiTests(unittest.TestCase):
for orig, expect in parse_strict_test_cases:
# Test basic parsing
d = do_test(orig, "GET")
- self.assertEqual(d, expect, "Error parsing %s" % repr(orig))
+ self.assertEqual(d, expect, "Error parsing %s method GET" % repr(orig))
d = do_test(orig, "POST")
- self.assertEqual(d, expect, "Error parsing %s" % repr(orig))
+ self.assertEqual(d, expect, "Error parsing %s method POST" % repr(orig))
env = {'QUERY_STRING': orig}
fs = cgi.FieldStorage(environ=env)
- if type(expect) == type({}):
+ if isinstance(expect, dict):
# test dict interface
self.assertEqual(len(expect), len(fs))
- self.assertEqual(norm(expect.keys()), norm(fs.keys()))
+ self.assertCountEqual(expect.keys(), fs.keys())
##self.assertEqual(norm(expect.values()), norm(fs.values()))
##self.assertEqual(norm(expect.items()), norm(fs.items()))
self.assertEqual(fs.getvalue("nonexistent field", "default"), "default")
# test individual fields
for key in expect.keys():
expect_val = expect[key]
- self.assertTrue(key in fs)
+ self.assertIn(key, fs)
if len(expect_val) > 1:
self.assertEqual(fs.getvalue(key), expect_val)
else:
@@ -160,6 +155,7 @@ class CgiTests(unittest.TestCase):
cgi.logfp = None
cgi.logfile = "/dev/null"
cgi.initlog("%s", "Testing log 3")
+ self.addCleanup(cgi.logfp.close)
cgi.log("Testing log 4")
def test_fieldstorage_readline(self):
@@ -186,50 +182,52 @@ class CgiTests(unittest.TestCase):
setattr(self, name, a)
return a
- f = TestReadlineFile(tempfile.TemporaryFile("w+"))
- f.write('x' * 256 * 1024)
+ f = TestReadlineFile(tempfile.TemporaryFile("wb+"))
+ self.addCleanup(f.close)
+ f.write(b'x' * 256 * 1024)
f.seek(0)
env = {'REQUEST_METHOD':'PUT'}
fs = cgi.FieldStorage(fp=f, environ=env)
+ self.addCleanup(fs.file.close)
# if we're not chunking properly, readline is only called twice
# (by read_binary); if we are chunking properly, it will be called 5 times
# as long as the chunksize is 1 << 16.
self.assertTrue(f.numcalls > 2)
+ f.close()
def test_fieldstorage_multipart(self):
#Test basic FieldStorage multipart parsing
- env = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE':'multipart/form-data; boundary=---------------------------721837373350705526688164684', 'CONTENT_LENGTH':'558'}
- postdata = """-----------------------------721837373350705526688164684
-Content-Disposition: form-data; name="id"
-
-1234
------------------------------721837373350705526688164684
-Content-Disposition: form-data; name="title"
-
-
------------------------------721837373350705526688164684
-Content-Disposition: form-data; name="file"; filename="test.txt"
-Content-Type: text/plain
-
-Testing 123.
-
------------------------------721837373350705526688164684
-Content-Disposition: form-data; name="submit"
-
- Add\x20
------------------------------721837373350705526688164684--
-"""
- fs = cgi.FieldStorage(fp=StringIO(postdata), environ=env)
+ env = {
+ 'REQUEST_METHOD': 'POST',
+ 'CONTENT_TYPE': 'multipart/form-data; boundary={}'.format(BOUNDARY),
+ 'CONTENT_LENGTH': '558'}
+ fp = BytesIO(POSTDATA.encode('latin-1'))
+ fs = cgi.FieldStorage(fp, environ=env, encoding="latin-1")
self.assertEqual(len(fs.list), 4)
expect = [{'name':'id', 'filename':None, 'value':'1234'},
{'name':'title', 'filename':None, 'value':''},
- {'name':'file', 'filename':'test.txt', 'value':'Testing 123.'},
+ {'name':'file', 'filename':'test.txt', 'value':b'Testing 123.\n'},
{'name':'submit', 'filename':None, 'value':' Add '}]
for x in range(len(fs.list)):
for k, exp in expect[x].items():
got = getattr(fs.list[x], k)
self.assertEqual(got, exp)
+ def test_fieldstorage_multipart_non_ascii(self):
+ #Test basic FieldStorage multipart parsing
+ env = {'REQUEST_METHOD':'POST',
+ 'CONTENT_TYPE': 'multipart/form-data; boundary={}'.format(BOUNDARY),
+ 'CONTENT_LENGTH':'558'}
+ for encoding in ['iso-8859-1','utf-8']:
+ fp = BytesIO(POSTDATA_NON_ASCII.encode(encoding))
+ fs = cgi.FieldStorage(fp, environ=env,encoding=encoding)
+ self.assertEqual(len(fs.list), 1)
+ expect = [{'name':'id', 'filename':None, 'value':'\xe7\xf1\x80'}]
+ for x in range(len(fs.list)):
+ for k, exp in expect[x].items():
+ got = getattr(fs.list[x], k)
+ self.assertEqual(got, exp)
+
_qs_result = {
'key1': 'value1',
'key2': ['value2x', 'value2y'],
@@ -248,8 +246,7 @@ Content-Disposition: form-data; name="submit"
self.assertEqual(self._qs_result, v)
def testQSAndFormData(self):
- data = """
----123
+ data = """---123
Content-Disposition: form-data; name="key2"
value2y
@@ -273,8 +270,7 @@ value4
self.assertEqual(self._qs_result, v)
def testQSAndFormDataFile(self):
- data = """
----123
+ data = """---123
Content-Disposition: form-data; name="key2"
value2y
@@ -302,26 +298,22 @@ this is the content of the fake file
}
result = self._qs_result.copy()
result.update({
- 'upload': 'this is the content of the fake file'
+ 'upload': b'this is the content of the fake file\n'
})
v = gen_result(data, environ)
self.assertEqual(result, v)
def test_deprecated_parse_qs(self):
- # this func is moved to urlparse, this is just a sanity check
- with catch_warnings():
- filterwarnings('ignore',
- 'cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead',
- DeprecationWarning)
+ # this func is moved to urllib.parse, this is just a sanity check
+ with check_warnings(('cgi.parse_qs is deprecated, use urllib.parse.'
+ 'parse_qs instead', DeprecationWarning)):
self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']},
cgi.parse_qs('a=A1&b=B2&B=B3'))
def test_deprecated_parse_qsl(self):
- # this func is moved to urlparse, this is just a sanity check
- with catch_warnings():
- filterwarnings('ignore',
- 'cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl instead',
- DeprecationWarning)
+ # this func is moved to urllib.parse, this is just a sanity check
+ with check_warnings(('cgi.parse_qsl is deprecated, use urllib.parse.'
+ 'parse_qsl instead', DeprecationWarning)):
self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')],
cgi.parse_qsl('a=A1&b=B2&B=B3'))
@@ -351,6 +343,36 @@ this is the content of the fake file
cgi.parse_header('attachment; filename="strange;name";size=123;'),
("attachment", {"filename": "strange;name", "size": "123"}))
+BOUNDARY = "---------------------------721837373350705526688164684"
+
+POSTDATA = """-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="id"
+
+1234
+-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="title"
+
+
+-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="file"; filename="test.txt"
+Content-Type: text/plain
+
+Testing 123.
+
+-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="submit"
+
+ Add\x20
+-----------------------------721837373350705526688164684--
+"""
+
+POSTDATA_NON_ASCII = """-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="id"
+
+\xe7\xf1\x80
+-----------------------------721837373350705526688164684
+"""
+
def test_main():
run_unittest(CgiTests)
diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py
index 2ab5a78a22..4e93be47ad 100755..100644
--- a/Lib/test/test_cmath.py
+++ b/Lib/test/test_cmath.py
@@ -1,9 +1,9 @@
-from test.support import run_unittest
+from test.support import run_unittest, requires_IEEE_754
from test.test_math import parse_testfile, test_file
import unittest
-import os, sys
import cmath, math
from cmath import phase, polar, rect, pi
+import sysconfig
INF = float('inf')
NAN = float('nan')
@@ -46,37 +46,6 @@ complex_nans = [complex(x, y) for x, y in [
(INF, NAN)
]]
-def almostEqualF(a, b, rel_err=2e-15, abs_err = 5e-323):
- """Determine whether floating-point values a and b are equal to within
- a (small) rounding error. The default values for rel_err and
- abs_err are chosen to be suitable for platforms where a float is
- represented by an IEEE 754 double. They allow an error of between
- 9 and 19 ulps."""
-
- # special values testing
- if math.isnan(a):
- return math.isnan(b)
- if math.isinf(a):
- return a == b
-
- # if both a and b are zero, check whether they have the same sign
- # (in theory there are examples where it would be legitimate for a
- # and b to have opposite signs; in practice these hardly ever
- # occur).
- if not a and not b:
- return math.copysign(1., a) == math.copysign(1., b)
-
- # if a-b overflows, or b is infinite, return False. Again, in
- # theory there are examples where a is within a few ulps of the
- # max representable float, and then b could legitimately be
- # infinite. In practice these examples are rare.
- try:
- absolute_error = abs(b-a)
- except OverflowError:
- return False
- else:
- return absolute_error <= max(abs_err, rel_err * abs(a))
-
class CMathTests(unittest.TestCase):
# list of all functions in cmath
test_functions = [getattr(cmath, fname) for fname in [
@@ -93,47 +62,96 @@ class CMathTests(unittest.TestCase):
def tearDown(self):
self.test_values.close()
- def rAssertAlmostEqual(self, a, b, rel_err = 2e-15, abs_err = 5e-323):
- """Check that two floating-point numbers are almost equal."""
+ def assertFloatIdentical(self, x, y):
+ """Fail unless floats x and y are identical, in the sense that:
+ (1) both x and y are nans, or
+ (2) both x and y are infinities, with the same sign, or
+ (3) both x and y are zeros, with the same sign, or
+ (4) x and y are both finite and nonzero, and x == y
+
+ """
+ msg = 'floats {!r} and {!r} are not identical'
+
+ if math.isnan(x) or math.isnan(y):
+ if math.isnan(x) and math.isnan(y):
+ return
+ elif x == y:
+ if x != 0.0:
+ return
+ # both zero; check that signs match
+ elif math.copysign(1.0, x) == math.copysign(1.0, y):
+ return
+ else:
+ msg += ': zeros have different signs'
+ self.fail(msg.format(x, y))
+
+ def assertComplexIdentical(self, x, y):
+ """Fail unless complex numbers x and y have equal values and signs.
+
+ In particular, if x and y both have real (or imaginary) part
+ zero, but the zeros have different signs, this test will fail.
+
+ """
+ self.assertFloatIdentical(x.real, y.real)
+ self.assertFloatIdentical(x.imag, y.imag)
+
+ def rAssertAlmostEqual(self, a, b, rel_err = 2e-15, abs_err = 5e-323,
+ msg=None):
+ """Fail if the two floating-point numbers are not almost equal.
+
+ Determine whether floating-point values a and b are equal to within
+ a (small) rounding error. The default values for rel_err and
+ abs_err are chosen to be suitable for platforms where a float is
+ represented by an IEEE 754 double. They allow an error of between
+ 9 and 19 ulps.
+ """
# special values testing
if math.isnan(a):
if math.isnan(b):
return
- self.fail("%s should be nan" % repr(b))
+ self.fail(msg or '{!r} should be nan'.format(b))
if math.isinf(a):
if a == b:
return
- self.fail("finite result where infinity excpected: "
- "expected %s, got %s" % (repr(a), repr(b)))
+ self.fail(msg or 'finite result where infinity expected: '
+ 'expected {!r}, got {!r}'.format(a, b))
+ # if both a and b are zero, check whether they have the same sign
+ # (in theory there are examples where it would be legitimate for a
+ # and b to have opposite signs; in practice these hardly ever
+ # occur).
if not a and not b:
- if math.atan2(a, -1.) != math.atan2(b, -1.):
- self.fail("zero has wrong sign: expected %s, got %s" %
- (repr(a), repr(b)))
-
- # test passes if either the absolute error or the relative
- # error is sufficiently small. The defaults amount to an
- # error of between 9 ulps and 19 ulps on an IEEE-754 compliant
- # machine.
-
+ if math.copysign(1., a) != math.copysign(1., b):
+ self.fail(msg or 'zero has wrong sign: expected {!r}, '
+ 'got {!r}'.format(a, b))
+
+ # if a-b overflows, or b is infinite, return False. Again, in
+ # theory there are examples where a is within a few ulps of the
+ # max representable float, and then b could legitimately be
+ # infinite. In practice these examples are rare.
try:
absolute_error = abs(b-a)
except OverflowError:
pass
else:
+ # test passes if either the absolute error or the relative
+ # error is sufficiently small. The defaults amount to an
+ # error of between 9 ulps and 19 ulps on an IEEE-754 compliant
+ # machine.
if absolute_error <= max(abs_err, rel_err * abs(a)):
return
- self.fail("%s and %s are not sufficiently close" % (repr(a), repr(b)))
+ self.fail(msg or
+ '{!r} and {!r} are not sufficiently close'.format(a, b))
def test_constants(self):
e_expected = 2.71828182845904523536
pi_expected = 3.14159265358979323846
self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
- msg="cmath.pi is %s; should be %s" % (cmath.pi, pi_expected))
+ msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
self.assertAlmostEqual(cmath.e, e_expected, places=9,
- msg="cmath.e is %s; should be %s" % (cmath.e, e_expected))
+ msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
def test_user_object(self):
# Test automatic calling of __complex__ and __float__ by cmath
@@ -294,10 +312,8 @@ class CMathTests(unittest.TestCase):
self.rAssertAlmostEqual(math.log(v, base), z.real)
self.assertEqual(0., z.imag)
+ @requires_IEEE_754
def test_specific_values(self):
- if not float.__getformat__("double").startswith("IEEE"):
- return
-
def rect_complex(z):
"""Wrapped version of rect that accepts a complex number instead of
two float arguments."""
@@ -323,8 +339,8 @@ class CMathTests(unittest.TestCase):
except ValueError:
continue
else:
- test_str = "%s: %s(complex(%r, %r))" % (id, fn, ar, ai)
- self.fail('ValueError not raised in test %s' % test_str)
+ self.fail('ValueError not raised in test '
+ '{}: {}(complex({!r}, {!r}))'.format(id, fn, ar, ai))
if 'overflow' in flags:
try:
@@ -332,8 +348,8 @@ class CMathTests(unittest.TestCase):
except OverflowError:
continue
else:
- test_str = "%s: %s(complex(%r, %r))" % (id, fn, ar, ai)
- self.fail('OverflowError not raised in test %s' % test_str)
+ self.fail('OverflowError not raised in test '
+ '{}: {}(complex({!r}, {!r}))'.format(id, fn, ar, ai))
actual = function(arg)
@@ -351,17 +367,19 @@ class CMathTests(unittest.TestCase):
else:
real_abs_err = 5e-323
- if not (almostEqualF(expected.real, actual.real,
- abs_err = real_abs_err) and
- almostEqualF(expected.imag, actual.imag)):
- error_message = (
- "%s: %s(complex(%r, %r))\n" % (id, fn, ar, ai) +
- "Expected: complex(%r, %r)\n" %
- (expected.real, expected.imag) +
- "Received: complex(%r, %r)\n" %
- (actual.real, actual.imag) +
- "Received value insufficiently close to expected value.")
- self.fail(error_message)
+ error_message = (
+ '{}: {}(complex({!r}, {!r}))\n'
+ 'Expected: complex({!r}, {!r})\n'
+ 'Received: complex({!r}, {!r})\n'
+ 'Received value insufficiently close to expected value.'
+ ).format(id, fn, ar, ai,
+ expected.real, expected.imag,
+ actual.real, actual.imag)
+ self.rAssertAlmostEqual(expected.real, actual.real,
+ abs_err=real_abs_err,
+ msg=error_message)
+ self.rAssertAlmostEqual(expected.imag, actual.imag,
+ msg=error_message)
def assertCISEqual(self, a, b):
eps = 1E-7
@@ -440,9 +458,11 @@ class CMathTests(unittest.TestCase):
self.assertEqual(abs(complex(INF, NAN)), INF)
self.assertTrue(math.isnan(abs(complex(NAN, NAN))))
+
+ @requires_IEEE_754
+ def test_abs_overflows(self):
# result overflows
- if float.__getformat__("double").startswith("IEEE"):
- self.assertRaises(OverflowError, abs, complex(1.4e308, 1.4e308))
+ self.assertRaises(OverflowError, abs, complex(1.4e308, 1.4e308))
def assertCEqual(self, a, b):
eps = 1E-7
@@ -456,6 +476,15 @@ class CMathTests(unittest.TestCase):
self.assertCEqual(rect(1, pi/2), (0, 1.))
self.assertCEqual(rect(1, -pi/2), (0, -1.))
+ def test_isfinite(self):
+ real_vals = [float('-inf'), -2.3, -0.0,
+ 0.0, 2.3, float('inf'), float('nan')]
+ for x in real_vals:
+ for y in real_vals:
+ z = complex(x, y)
+ self.assertEqual(cmath.isfinite(z),
+ math.isfinite(x) and math.isfinite(y))
+
def test_isnan(self):
self.assertFalse(cmath.isnan(1))
self.assertFalse(cmath.isnan(1j))
@@ -478,6 +507,31 @@ class CMathTests(unittest.TestCase):
self.assertTrue(cmath.isinf(complex(NAN, INF)))
self.assertTrue(cmath.isinf(complex(INF, NAN)))
+ @requires_IEEE_754
+ @unittest.skipIf(sysconfig.get_config_var('TANH_PRESERVES_ZERO_SIGN') == 0,
+ "system tanh() function doesn't copy the sign")
+ def testTanhSign(self):
+ for z in complex_zeros:
+ self.assertComplexIdentical(cmath.tanh(z), z)
+
+ # The algorithm used for atan and atanh makes use of the system
+ # log1p function; If that system function doesn't respect the sign
+ # of zero, then atan and atanh will also have difficulties with
+ # the sign of complex zeros.
+ @requires_IEEE_754
+ @unittest.skipIf(sysconfig.get_config_var('LOG1P_DROPS_ZERO_SIGN'),
+ "system log1p() function doesn't preserve the sign")
+ def testAtanSign(self):
+ for z in complex_zeros:
+ self.assertComplexIdentical(cmath.atan(z), z)
+
+ @requires_IEEE_754
+ @unittest.skipIf(sysconfig.get_config_var('LOG1P_DROPS_ZERO_SIGN'),
+ "system log1p() function doesn't preserve the sign")
+ def testAtanhSign(self):
+ for z in complex_zeros:
+ self.assertComplexIdentical(cmath.atanh(z), z)
+
def test_main():
run_unittest(CMathTests)
diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py
index 7a13d27e15..a1799f915f 100644
--- a/Lib/test/test_cmd.py
+++ b/Lib/test/test_cmd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
Test script for the 'cmd' module
Original by Michael Schneider
@@ -7,10 +7,10 @@ Original by Michael Schneider
import cmd
import sys
-import trace
import re
import unittest
import io
+from test import support
class samplecmdclass(cmd.Cmd):
"""
@@ -61,15 +61,17 @@ class samplecmdclass(cmd.Cmd):
>>> mycmd.completenames("12")
[]
>>> mycmd.completenames("help")
- ['help', 'help']
+ ['help']
Test for the function complete_help():
>>> mycmd.complete_help("a")
['add']
>>> mycmd.complete_help("he")
- ['help', 'help']
+ ['help']
>>> mycmd.complete_help("12")
[]
+ >>> sorted(mycmd.complete_help(""))
+ ['add', 'exit', 'help', 'shell']
Test for the function do_help():
>>> mycmd.do_help("testet")
@@ -82,11 +84,11 @@ class samplecmdclass(cmd.Cmd):
<BLANKLINE>
Documented commands (type help <topic>):
========================================
- add
+ add help
<BLANKLINE>
Undocumented commands:
======================
- exit help shell
+ exit shell
<BLANKLINE>
Test for the function print_topics():
@@ -123,11 +125,11 @@ class samplecmdclass(cmd.Cmd):
<BLANKLINE>
Documented commands (type help <topic>):
========================================
- add
+ add help
<BLANKLINE>
Undocumented commands:
======================
- exit help shell
+ exit shell
<BLANKLINE>
help text for add
Hello from postloop
@@ -145,7 +147,7 @@ class samplecmdclass(cmd.Cmd):
def complete_command(self):
print("complete command")
- def do_shell(self):
+ def do_shell(self, s):
pass
def do_add(self, s):
@@ -191,11 +193,12 @@ class TestAlternateInput(unittest.TestCase):
def test_main(verbose=None):
- from test import support, test_cmd
+ from test import test_cmd
support.run_doctest(test_cmd, verbose)
support.run_unittest(TestAlternateInput)
def test_coverage(coverdir):
+ trace = support.import_module('trace')
tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
trace=0, count=1)
tracer.run('reload(cmd);test_main()')
@@ -206,5 +209,7 @@ def test_coverage(coverdir):
if __name__ == "__main__":
if "-c" in sys.argv:
test_coverage('/tmp/cmd.cover')
+ elif "-i" in sys.argv:
+ samplecmdclass().cmdloop()
else:
test_main()
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index c4b8be5f6c..c4e3adfb53 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -1,58 +1,31 @@
# Tests invocation of the interpreter with various command line arguments
-# All tests are executed with environment variables ignored
+# Most tests are executed with environment variables ignored
# See test_cmd_line_script.py for testing of script execution
-import os
import test.support, unittest
import os
import sys
import subprocess
+import tempfile
+from test.script_helper import spawn_python, kill_python, assert_python_ok, assert_python_failure
-def _spawn_python(*args):
- cmd_line = [sys.executable]
- # When testing -S, we need PYTHONPATH to work (see test_site_flag())
- if '-S' not in args:
- cmd_line.append('-E')
- cmd_line.extend(args)
- return subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-
-def _kill_python(p):
- return _kill_python_and_exit_code(p)[0]
+# XXX (ncoghlan): Move to script_helper and make consistent with run_python
def _kill_python_and_exit_code(p):
- p.stdin.close()
- data = p.stdout.read()
- p.stdout.close()
- # try to cleanup the child so we don't appear to leak when running
- # with regrtest -R. This should be a no-op on Windows.
- subprocess._cleanup()
+ data = kill_python(p)
returncode = p.wait()
return data, returncode
class CmdLineTest(unittest.TestCase):
- def start_python(self, *args):
- return self.start_python_and_exit_code(*args)[0]
-
- def start_python_and_exit_code(self, *args):
- p = _spawn_python(*args)
- return _kill_python_and_exit_code(p)
-
- def exit_code(self, *args):
- cmd_line = [sys.executable, '-E']
- cmd_line.extend(args)
- with open(os.devnull, 'w') as devnull:
- return subprocess.call(cmd_line, stdout=devnull,
- stderr=subprocess.STDOUT)
-
def test_directories(self):
- self.assertNotEqual(self.exit_code('.'), 0)
- self.assertNotEqual(self.exit_code('< .'), 0)
+ assert_python_failure('.')
+ assert_python_failure('< .')
def verify_valid_flag(self, cmd_line):
- data = self.start_python(cmd_line)
- self.assertTrue(data == b'' or data.endswith(b'\n'))
- self.assertTrue(b'Traceback' not in data)
+ rc, out, err = assert_python_ok(*cmd_line)
+ self.assertTrue(out == b'' or out.endswith(b'\n'))
+ self.assertNotIn(b'Traceback', out)
+ self.assertNotIn(b'Traceback', err)
def test_optimize(self):
self.verify_valid_flag('-O')
@@ -65,84 +38,147 @@ class CmdLineTest(unittest.TestCase):
self.verify_valid_flag('-Qwarnall')
def test_site_flag(self):
- if os.name == 'posix':
- # Workaround bug #586680 by adding the extension dir to PYTHONPATH
- from distutils.util import get_platform
- s = "./build/lib.%s-%.3s" % (get_platform(), sys.version)
- if hasattr(sys, 'gettotalrefcount'):
- s += '-pydebug'
- p = os.environ.get('PYTHONPATH', '')
- if p:
- p += ':'
- os.environ['PYTHONPATH'] = p + s
self.verify_valid_flag('-S')
def test_usage(self):
- self.assertTrue(b'usage' in self.start_python('-h'))
+ rc, out, err = assert_python_ok('-h')
+ self.assertIn(b'usage', out)
def test_version(self):
version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
- self.assertTrue(self.start_python('-V').startswith(version))
+ rc, out, err = assert_python_ok('-V')
+ self.assertTrue(err.startswith(version))
def test_verbose(self):
# -v causes imports to write to stderr. If the write to
# stderr itself causes an import to happen (for the output
# codec), a recursion loop can occur.
- data, rc = self.start_python_and_exit_code('-v')
- self.assertEqual(rc, 0)
- self.assertTrue(b'stack overflow' not in data)
- data, rc = self.start_python_and_exit_code('-vv')
- self.assertEqual(rc, 0)
- self.assertTrue(b'stack overflow' not in data)
+ rc, out, err = assert_python_ok('-v')
+ self.assertNotIn(b'stack overflow', err)
+ rc, out, err = assert_python_ok('-vv')
+ self.assertNotIn(b'stack overflow', err)
+
+ def test_xoptions(self):
+ rc, out, err = assert_python_ok('-c', 'import sys; print(sys._xoptions)')
+ opts = eval(out.splitlines()[0])
+ self.assertEqual(opts, {})
+ rc, out, err = assert_python_ok(
+ '-Xa', '-Xb=c,d=e', '-c', 'import sys; print(sys._xoptions)')
+ opts = eval(out.splitlines()[0])
+ self.assertEqual(opts, {'a': True, 'b': 'c,d=e'})
def test_run_module(self):
# Test expected operation of the '-m' switch
# Switch needs an argument
- self.assertNotEqual(self.exit_code('-m'), 0)
+ assert_python_failure('-m')
# Check we get an error for a nonexistent module
- self.assertNotEqual(
- self.exit_code('-m', 'fnord43520xyz'),
- 0)
+ assert_python_failure('-m', 'fnord43520xyz')
# Check the runpy module also gives an error for
# a nonexistent module
- self.assertNotEqual(
- self.exit_code('-m', 'runpy', 'fnord43520xyz'),
- 0)
+ assert_python_failure('-m', 'runpy', 'fnord43520xyz'),
# All good if module is located and run successfully
- self.assertEqual(
- self.exit_code('-m', 'timeit', '-n', '1'),
- 0)
+ assert_python_ok('-m', 'timeit', '-n', '1'),
def test_run_module_bug1764407(self):
# -m and -i need to play well together
# Runs the timeit module and checks the __main__
# namespace has been populated appropriately
- p = _spawn_python('-i', '-m', 'timeit', '-n', '1')
+ p = spawn_python('-i', '-m', 'timeit', '-n', '1')
p.stdin.write(b'Timer\n')
p.stdin.write(b'exit()\n')
- data = _kill_python(p)
+ data = kill_python(p)
self.assertTrue(data.find(b'1 loop') != -1)
self.assertTrue(data.find(b'__main__.Timer') != -1)
def test_run_code(self):
# Test expected operation of the '-c' switch
# Switch needs an argument
- self.assertNotEqual(self.exit_code('-c'), 0)
+ assert_python_failure('-c')
# Check we get an error for an uncaught exception
- self.assertNotEqual(
- self.exit_code('-c', 'raise Exception'),
- 0)
+ assert_python_failure('-c', 'raise Exception')
# All good if execution is successful
- self.assertEqual(
- self.exit_code('-c', 'pass'),
- 0)
+ assert_python_ok('-c', 'pass')
+ @unittest.skipIf(sys.getfilesystemencoding() == 'ascii',
+ 'need a filesystem encoding different than ASCII')
+ def test_non_ascii(self):
# Test handling of non-ascii data
- if sys.getfilesystemencoding() != 'ascii':
- command = "assert(ord('\xe9') == 0xe9)"
- self.assertEqual(
- self.exit_code('-c', command),
- 0)
+ if test.support.verbose:
+ import locale
+ print('locale encoding = %s, filesystem encoding = %s'
+ % (locale.getpreferredencoding(), sys.getfilesystemencoding()))
+ command = "assert(ord('\xe9') == 0xe9)"
+ assert_python_ok('-c', command)
+
+ # On Windows, pass bytes to subprocess doesn't test how Python decodes the
+ # command line, but how subprocess does decode bytes to unicode. Python
+ # doesn't decode the command line because Windows provides directly the
+ # arguments as unicode (using wmain() instead of main()).
+ @unittest.skipIf(sys.platform == 'win32',
+ 'Windows has a native unicode API')
+ def test_undecodable_code(self):
+ undecodable = b"\xff"
+ env = os.environ.copy()
+ # Use C locale to get ascii for the locale encoding
+ env['LC_ALL'] = 'C'
+ code = (
+ b'import locale; '
+ b'print(ascii("' + undecodable + b'"), '
+ b'locale.getpreferredencoding())')
+ p = subprocess.Popen(
+ [sys.executable, "-c", code],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ env=env)
+ stdout, stderr = p.communicate()
+ if p.returncode == 1:
+ # _Py_char2wchar() decoded b'\xff' as '\udcff' (b'\xff' is not
+ # decodable from ASCII) and run_command() failed on
+ # PyUnicode_AsUTF8String(). This is the expected behaviour on
+ # Linux.
+ pattern = b"Unable to decode the command from the command line:"
+ elif p.returncode == 0:
+ # _Py_char2wchar() decoded b'\xff' as '\xff' even if the locale is
+ # C and the locale encoding is ASCII. It occurs on FreeBSD, Solaris
+ # and Mac OS X.
+ pattern = b"'\\xff' "
+ # The output is followed by the encoding name, an alias to ASCII.
+ # Examples: "US-ASCII" or "646" (ISO 646, on Solaris).
+ else:
+ raise AssertionError("Unknown exit code: %s, output=%a" % (p.returncode, stdout))
+ if not stdout.startswith(pattern):
+ raise AssertionError("%a doesn't start with %a" % (stdout, pattern))
+
+ @unittest.skipUnless(sys.platform == 'darwin', 'test specific to Mac OS X')
+ def test_osx_utf8(self):
+ def check_output(text):
+ decoded = text.decode('utf8', 'surrogateescape')
+ expected = ascii(decoded).encode('ascii') + b'\n'
+
+ env = os.environ.copy()
+ # C locale gives ASCII locale encoding, but Python uses UTF-8
+ # to parse the command line arguments on Mac OS X
+ env['LC_ALL'] = 'C'
+
+ p = subprocess.Popen(
+ (sys.executable, "-c", "import sys; print(ascii(sys.argv[1]))", text),
+ stdout=subprocess.PIPE,
+ env=env)
+ stdout, stderr = p.communicate()
+ self.assertEqual(stdout, expected)
+ self.assertEqual(p.returncode, 0)
+
+ # test valid utf-8
+ text = 'e:\xe9, euro:\u20ac, non-bmp:\U0010ffff'.encode('utf-8')
+ check_output(text)
+
+ # test invalid utf-8
+ text = (
+ b'\xff' # invalid byte
+ b'\xc3\xa9' # valid utf-8 character
+ b'\xc3\xff' # invalid byte sequence
+ b'\xed\xa0\x80' # lone surrogate character (invalid)
+ )
+ check_output(text)
def test_unbuffered_output(self):
# Test expected operation of the '-u' switch
@@ -150,21 +186,21 @@ class CmdLineTest(unittest.TestCase):
# Binary is unbuffered
code = ("import os, sys; sys.%s.buffer.write(b'x'); os._exit(0)"
% stream)
- data, rc = self.start_python_and_exit_code('-u', '-c', code)
- self.assertEqual(rc, 0)
+ rc, out, err = assert_python_ok('-u', '-c', code)
+ data = err if stream == 'stderr' else out
self.assertEqual(data, b'x', "binary %s not unbuffered" % stream)
# Text is line-buffered
code = ("import os, sys; sys.%s.write('x\\n'); os._exit(0)"
% stream)
- data, rc = self.start_python_and_exit_code('-u', '-c', code)
- self.assertEqual(rc, 0)
+ rc, out, err = assert_python_ok('-u', '-c', code)
+ data = err if stream == 'stderr' else out
self.assertEqual(data.strip(), b'x',
"text %s not line-buffered" % stream)
def test_unbuffered_input(self):
# sys.stdin still works with '-u'
code = ("import sys; sys.stdout.write(sys.stdin.read(1))")
- p = _spawn_python('-u', '-c', code)
+ p = spawn_python('-u', '-c', code)
p.stdin.write(b'x')
p.stdin.flush()
data, rc = _kill_python_and_exit_code(p)
@@ -172,23 +208,62 @@ class CmdLineTest(unittest.TestCase):
self.assertTrue(data.startswith(b'x'), data)
def test_large_PYTHONPATH(self):
- with test.support.EnvironmentVarGuard() as env:
- path1 = "ABCDE" * 100
- path2 = "FGHIJ" * 100
- env['PYTHONPATH'] = path1 + os.pathsep + path2
+ path1 = "ABCDE" * 100
+ path2 = "FGHIJ" * 100
+ path = path1 + os.pathsep + path2
- code = """
-import sys
-path = ":".join(sys.path)
-path = path.encode("ascii", "backslashreplace")
-sys.stdout.buffer.write(path)"""
- code = code.strip().splitlines()
- code = '; '.join(code)
- p = _spawn_python('-S', '-c', code)
- stdout, _ = p.communicate()
- p.stdout.close()
- self.assertTrue(path1.encode('ascii') in stdout)
- self.assertTrue(path2.encode('ascii') in stdout)
+ code = """if 1:
+ import sys
+ path = ":".join(sys.path)
+ path = path.encode("ascii", "backslashreplace")
+ sys.stdout.buffer.write(path)"""
+ rc, out, err = assert_python_ok('-S', '-c', code,
+ PYTHONPATH=path)
+ self.assertIn(path1.encode('ascii'), out)
+ self.assertIn(path2.encode('ascii'), out)
+
+ def test_displayhook_unencodable(self):
+ for encoding in ('ascii', 'latin1', 'utf8'):
+ env = os.environ.copy()
+ env['PYTHONIOENCODING'] = encoding
+ p = subprocess.Popen(
+ [sys.executable, '-i'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ env=env)
+ # non-ascii, surrogate, non-BMP printable, non-BMP unprintable
+ text = "a=\xe9 b=\uDC80 c=\U00010000 d=\U0010FFFF"
+ p.stdin.write(ascii(text).encode('ascii') + b"\n")
+ p.stdin.write(b'exit()\n')
+ data = kill_python(p)
+ escaped = repr(text).encode(encoding, 'backslashreplace')
+ self.assertIn(escaped, data)
+
+ def check_input(self, code, expected):
+ with tempfile.NamedTemporaryFile("wb+") as stdin:
+ sep = os.linesep.encode('ASCII')
+ stdin.write(sep.join((b'abc', b'def')))
+ stdin.flush()
+ stdin.seek(0)
+ with subprocess.Popen(
+ (sys.executable, "-c", code),
+ stdin=stdin, stdout=subprocess.PIPE) as proc:
+ stdout, stderr = proc.communicate()
+ self.assertEqual(stdout.rstrip(), expected)
+
+ def test_stdin_readline(self):
+ # Issue #11272: check that sys.stdin.readline() replaces '\r\n' by '\n'
+ # on Windows (sys.stdin is opened in binary mode)
+ self.check_input(
+ "import sys; print(repr(sys.stdin.readline()))",
+ b"'abc\\n'")
+
+ def test_builtin_input(self):
+ # Issue #11272: check that input() strips newlines ('\n' or '\r\n')
+ self.check_input(
+ "print(repr(input()))",
+ b"'abc'")
def test_main():
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index bc87a22d6d..921c5f3df4 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -1,38 +1,17 @@
-# Tests command line execution of scripts
+# tests command line execution of scripts
import unittest
+import sys
import os
import os.path
-import sys
-import test.support
-import tempfile
-import subprocess
import py_compile
-import contextlib
-import shutil
-import zipfile
-
-verbose = test.support.verbose
-# XXX ncoghlan: Should we consider moving these to support?
-from test.test_cmd_line import _spawn_python, _kill_python
+from test import support
+from test.script_helper import (
+ make_pkg, make_script, make_zip_pkg, make_zip_script,
+ assert_python_ok, assert_python_failure, temp_dir)
-def _run_python(*args):
- if __debug__:
- p = _spawn_python(*args)
- else:
- p = _spawn_python('-O', *args)
- stdout_data = _kill_python(p)
- return p.wait(), stdout_data.decode()
-
-@contextlib.contextmanager
-def temp_dir():
- dirname = tempfile.mkdtemp()
- dirname = os.path.realpath(dirname)
- try:
- yield dirname
- finally:
- shutil.rmtree(dirname)
+verbose = support.verbose
test_source = """\
# Script may be run with optimisation enabled, so don't rely on assert
@@ -51,73 +30,26 @@ f()
assertEqual(result, ['Top level assignment', 'Lower level reference'])
# Check population of magic variables
assertEqual(__name__, '__main__')
-print('__file__==%r' % __file__)
+print('__file__==%a' % __file__)
+assertEqual(__cached__, None)
print('__package__==%r' % __package__)
# Check the sys module
import sys
assertIdentical(globals(), sys.modules[__name__].__dict__)
-print('sys.argv[0]==%r' % sys.argv[0])
+print('sys.argv[0]==%a' % sys.argv[0])
+print('sys.path[0]==%a' % sys.path[0])
+# Check the working directory
+import os
+print('cwd==%a' % os.getcwd())
"""
def _make_test_script(script_dir, script_basename, source=test_source):
- script_filename = script_basename+os.path.extsep+'py'
- script_name = os.path.join(script_dir, script_filename)
- # The script should be encoded to UTF-8, the default string encoding
- script_file = open(script_name, 'w', encoding='utf-8')
- script_file.write(source)
- script_file.close()
- return script_name
-
-def _compile_test_script(script_name):
- py_compile.compile(script_name, doraise=True)
- if __debug__:
- compiled_name = script_name + 'c'
- else:
- compiled_name = script_name + 'o'
- return compiled_name
-
-def _make_test_zip(zip_dir, zip_basename, script_name, name_in_zip=None):
- zip_filename = zip_basename+os.path.extsep+"zip"
- zip_name = os.path.join(zip_dir, zip_filename)
- zip_file = zipfile.ZipFile(zip_name, 'w')
- if name_in_zip is None:
- name_in_zip = os.path.basename(script_name)
- zip_file.write(script_name, name_in_zip)
- zip_file.close()
- #if verbose:
- # zip_file = zipfile.ZipFile(zip_name, 'r')
- # print("Contents of %r:" % zip_name)
- # zip_file.printdir()
- # zip_file.close()
- return zip_name, os.path.join(zip_name, name_in_zip)
-
-def _make_test_pkg(pkg_dir):
- os.mkdir(pkg_dir)
- _make_test_script(pkg_dir, '__init__', '')
+ return make_script(script_dir, script_basename, source)
def _make_test_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
source=test_source, depth=1):
- init_name = _make_test_script(zip_dir, '__init__', '')
- init_basename = os.path.basename(init_name)
- script_name = _make_test_script(zip_dir, script_basename, source)
- pkg_names = [os.sep.join([pkg_name]*i) for i in range(1, depth+1)]
- script_name_in_zip = os.path.join(pkg_names[-1], os.path.basename(script_name))
- zip_filename = zip_basename+os.extsep+'zip'
- zip_name = os.path.join(zip_dir, zip_filename)
- zip_file = zipfile.ZipFile(zip_name, 'w')
- for name in pkg_names:
- init_name_in_zip = os.path.join(name, init_basename)
- zip_file.write(init_name, init_name_in_zip)
- zip_file.write(script_name, script_name_in_zip)
- zip_file.close()
- os.unlink(init_name)
- os.unlink(script_name)
- #if verbose:
- # zip_file = zipfile.ZipFile(zip_name, 'r')
- # print('Contents of %r:' % zip_name)
- # zip_file.printdir()
- # zip_file.close()
- return zip_name, os.path.join(zip_name, script_name_in_zip)
+ return make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
+ source, depth)
# There's no easy way to pass the script directory in to get
# -m to work (avoiding that is the whole point of making
@@ -135,133 +67,154 @@ def _make_launch_script(script_dir, script_basename, module_name, path=None):
else:
path = repr(path)
source = launch_source % (path, module_name)
- return _make_test_script(script_dir, script_basename, source)
+ return make_script(script_dir, script_basename, source)
class CmdLineTest(unittest.TestCase):
- def _check_script(self, script_name, expected_file,
- expected_argv0, expected_package,
- *cmd_line_switches):
- run_args = cmd_line_switches + (script_name,)
- exit_code, data = _run_python(*run_args)
- if verbose:
+ def _check_output(self, script_name, exit_code, data,
+ expected_file, expected_argv0,
+ expected_path0, expected_package):
+ if verbose > 1:
print("Output from test script %r:" % script_name)
print(data)
self.assertEqual(exit_code, 0)
- printed_file = '__file__==%r' % expected_file
- printed_argv0 = 'sys.argv[0]==%r' % expected_argv0
+ printed_file = '__file__==%a' % expected_file
printed_package = '__package__==%r' % expected_package
- if verbose:
+ printed_argv0 = 'sys.argv[0]==%a' % expected_argv0
+ printed_path0 = 'sys.path[0]==%a' % expected_path0
+ printed_cwd = 'cwd==%a' % os.getcwd()
+ if verbose > 1:
print('Expected output:')
print(printed_file)
print(printed_package)
print(printed_argv0)
- self.assertTrue(printed_file in data)
- self.assertTrue(printed_package in data)
- self.assertTrue(printed_argv0 in data)
+ print(printed_cwd)
+ self.assertIn(printed_file.encode('utf-8'), data)
+ self.assertIn(printed_package.encode('utf-8'), data)
+ self.assertIn(printed_argv0.encode('utf-8'), data)
+ self.assertIn(printed_path0.encode('utf-8'), data)
+ self.assertIn(printed_cwd.encode('utf-8'), data)
+
+ def _check_script(self, script_name, expected_file,
+ expected_argv0, expected_path0,
+ expected_package,
+ *cmd_line_switches):
+ if not __debug__:
+ cmd_line_switches += ('-' + 'O' * sys.flags.optimize,)
+ run_args = cmd_line_switches + (script_name,)
+ rc, out, err = assert_python_ok(*run_args)
+ self._check_output(script_name, rc, out + err, expected_file,
+ expected_argv0, expected_path0, expected_package)
def _check_import_error(self, script_name, expected_msg,
*cmd_line_switches):
run_args = cmd_line_switches + (script_name,)
- exit_code, data = _run_python(*run_args)
- if verbose:
+ rc, out, err = assert_python_failure(*run_args)
+ if verbose > 1:
print('Output from test script %r:' % script_name)
- print(data)
+ print(err)
print('Expected output: %r' % expected_msg)
- self.assertTrue(expected_msg in data)
+ self.assertIn(expected_msg.encode('utf-8'), err)
def test_basic_script(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script')
- self._check_script(script_name, script_name, script_name, None)
+ self._check_script(script_name, script_name, script_name,
+ script_dir, None)
def test_script_compiled(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script')
- compiled_name = _compile_test_script(script_name)
+ py_compile.compile(script_name, doraise=True)
os.remove(script_name)
- self._check_script(compiled_name, compiled_name, compiled_name, None)
+ pyc_file = support.make_legacy_pyc(script_name)
+ self._check_script(pyc_file, pyc_file,
+ pyc_file, script_dir, None)
def test_directory(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
- self._check_script(script_dir, script_name, script_dir, '')
+ self._check_script(script_dir, script_name, script_dir,
+ script_dir, '')
def test_directory_compiled(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
- compiled_name = _compile_test_script(script_name)
+ py_compile.compile(script_name, doraise=True)
os.remove(script_name)
- self._check_script(script_dir, compiled_name, script_dir, '')
+ pyc_file = support.make_legacy_pyc(script_name)
+ self._check_script(script_dir, pyc_file, script_dir,
+ script_dir, '')
def test_directory_error(self):
with temp_dir() as script_dir:
- msg = "can't find '__main__.py' in %r" % script_dir
+ msg = "can't find '__main__' module in %r" % script_dir
self._check_import_error(script_dir, msg)
def test_zipfile(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
- zip_name, run_name = _make_test_zip(script_dir, 'test_zip', script_name)
- self._check_script(zip_name, run_name, zip_name, '')
+ zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name)
+ self._check_script(zip_name, run_name, zip_name, zip_name, '')
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
- compiled_name = _compile_test_script(script_name)
- zip_name, run_name = _make_test_zip(script_dir, 'test_zip', compiled_name)
- self._check_script(zip_name, run_name, zip_name, '')
+ compiled_name = py_compile.compile(script_name, doraise=True)
+ zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
+ self._check_script(zip_name, run_name, zip_name, zip_name, '')
def test_zipfile_error(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'not_main')
- zip_name, run_name = _make_test_zip(script_dir, 'test_zip', script_name)
- msg = "can't find '__main__.py' in %r" % zip_name
+ zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name)
+ msg = "can't find '__main__' module in %r" % zip_name
self._check_import_error(zip_name, msg)
def test_module_in_package(self):
with temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
- _make_test_pkg(pkg_dir)
+ make_pkg(pkg_dir)
script_name = _make_test_script(pkg_dir, 'script')
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script')
- self._check_script(launch_name, script_name, script_name, 'test_pkg')
+ self._check_script(launch_name, script_name, script_name, script_dir, 'test_pkg')
def test_module_in_package_in_zipfile(self):
with temp_dir() as script_dir:
zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script')
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script', zip_name)
- self._check_script(launch_name, run_name, run_name, 'test_pkg')
+ self._check_script(launch_name, run_name, run_name, zip_name, 'test_pkg')
def test_module_in_subpackage_in_zipfile(self):
with temp_dir() as script_dir:
zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script', depth=2)
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.test_pkg.script', zip_name)
- self._check_script(launch_name, run_name, run_name, 'test_pkg.test_pkg')
+ self._check_script(launch_name, run_name, run_name, zip_name, 'test_pkg.test_pkg')
def test_package(self):
with temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
- _make_test_pkg(pkg_dir)
+ make_pkg(pkg_dir)
script_name = _make_test_script(pkg_dir, '__main__')
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
self._check_script(launch_name, script_name,
- script_name, 'test_pkg')
+ script_name, script_dir, 'test_pkg')
def test_package_compiled(self):
with temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
- _make_test_pkg(pkg_dir)
+ make_pkg(pkg_dir)
script_name = _make_test_script(pkg_dir, '__main__')
- compiled_name = _compile_test_script(script_name)
+ compiled_name = py_compile.compile(script_name, doraise=True)
os.remove(script_name)
+ pyc_file = support.make_legacy_pyc(script_name)
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
- self._check_script(launch_name, compiled_name,
- compiled_name, 'test_pkg')
+ self._check_script(launch_name, pyc_file,
+ pyc_file, script_dir, 'test_pkg')
def test_package_error(self):
with temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
- _make_test_pkg(pkg_dir)
+ make_pkg(pkg_dir)
msg = ("'test_pkg' is a package and cannot "
"be directly executed")
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
@@ -270,19 +223,60 @@ class CmdLineTest(unittest.TestCase):
def test_package_recursion(self):
with temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
- _make_test_pkg(pkg_dir)
+ make_pkg(pkg_dir)
main_dir = os.path.join(pkg_dir, '__main__')
- _make_test_pkg(main_dir)
+ make_pkg(main_dir)
msg = ("Cannot use package as __main__ module; "
"'test_pkg' is a package and cannot "
"be directly executed")
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
self._check_import_error(launch_name, msg)
+ def test_issue8202(self):
+ # Make sure package __init__ modules see "-m" in sys.argv0 while
+ # searching for the module to execute
+ with temp_dir() as script_dir:
+ with support.temp_cwd(path=script_dir):
+ pkg_dir = os.path.join(script_dir, 'test_pkg')
+ make_pkg(pkg_dir, "import sys; print('init_argv0==%r' % sys.argv[0])")
+ script_name = _make_test_script(pkg_dir, 'script')
+ rc, out, err = assert_python_ok('-m', 'test_pkg.script')
+ if verbose > 1:
+ print(data)
+ expected = "init_argv0==%r" % '-m'
+ self.assertIn(expected.encode('utf-8'), out)
+ self._check_output(script_name, rc, out,
+ script_name, script_name, '', 'test_pkg')
+
+ def test_issue8202_dash_c_file_ignored(self):
+ # Make sure a "-c" file in the current directory
+ # does not alter the value of sys.path[0]
+ with temp_dir() as script_dir:
+ with support.temp_cwd(path=script_dir):
+ with open("-c", "w") as f:
+ f.write("data")
+ rc, out, err = assert_python_ok('-c',
+ 'import sys; print("sys.path[0]==%r" % sys.path[0])')
+ if verbose > 1:
+ print(out)
+ expected = "sys.path[0]==%r" % ''
+ self.assertIn(expected.encode('utf-8'), out)
+
+ def test_issue8202_dash_m_file_ignored(self):
+ # Make sure a "-m" file in the current directory
+ # does not alter the value of sys.path[0]
+ with temp_dir() as script_dir:
+ script_name = _make_test_script(script_dir, 'other')
+ with support.temp_cwd(path=script_dir):
+ with open("-m", "w") as f:
+ f.write("data")
+ rc, out, err = assert_python_ok('-m', 'other')
+ self._check_output(script_name, rc, out,
+ script_name, script_name, '', '')
def test_main():
- test.support.run_unittest(CmdLineTest)
- test.support.reap_children()
+ support.run_unittest(CmdLineTest)
+ support.reap_children()
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index c8fa2a138b..e1c7a783de 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -102,6 +102,11 @@ consts: ('None',)
"""
+import unittest
+import weakref
+import _testcapi
+
+
def consts(t):
"""Yield a doctest-safe sequence of object reprs."""
for elt in t:
@@ -118,11 +123,47 @@ def dump(co):
print("%s: %s" % (attr, getattr(co, "co_" + attr)))
print("consts:", tuple(consts(co.co_consts)))
+
+class CodeTest(unittest.TestCase):
+
+ def test_newempty(self):
+ co = _testcapi.code_newempty("filename", "funcname", 15)
+ self.assertEqual(co.co_filename, "filename")
+ self.assertEqual(co.co_name, "funcname")
+ self.assertEqual(co.co_firstlineno, 15)
+
+
+class CodeWeakRefTest(unittest.TestCase):
+
+ def test_basic(self):
+ # Create a code object in a clean environment so that we know we have
+ # the only reference to it left.
+ namespace = {}
+ exec("def f(): pass", globals(), namespace)
+ f = namespace["f"]
+ del namespace
+
+ self.called = False
+ def callback(code):
+ self.called = True
+
+ # f is now the last reference to the function, and through it, the code
+ # object. While we hold it, check that we can create a weakref and
+ # deref it. Then delete it, and check that the callback gets called and
+ # the reference dies.
+ coderef = weakref.ref(f.__code__, callback)
+ self.assertTrue(bool(coderef()))
+ del f
+ self.assertFalse(bool(coderef()))
+ self.assertTrue(self.called)
+
+
def test_main(verbose=None):
- from test.support import run_doctest
+ from test.support import run_doctest, run_unittest
from test import test_code
run_doctest(test_code, verbose)
+ run_unittest(CodeTest, CodeWeakRefTest)
-if __name__ == '__main__':
+if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecencodings_cn.py b/Lib/test/test_codecencodings_cn.py
index 77bac139cf..a2d9718497 100644
--- a/Lib/test/test_codecencodings_cn.py
+++ b/Lib/test/test_codecencodings_cn.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_cn.py
# Codec encoding tests for PRC encodings.
diff --git a/Lib/test/test_codecencodings_hk.py b/Lib/test/test_codecencodings_hk.py
index b1deb715a5..ccdc0b4c55 100644
--- a/Lib/test/test_codecencodings_hk.py
+++ b/Lib/test/test_codecencodings_hk.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_hk.py
# Codec encoding tests for HongKong encodings.
diff --git a/Lib/test/test_codecencodings_jp.py b/Lib/test/test_codecencodings_jp.py
index e2cd7d7020..f56a373896 100644
--- a/Lib/test/test_codecencodings_jp.py
+++ b/Lib/test/test_codecencodings_jp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_jp.py
# Codec encoding tests for Japanese encodings.
diff --git a/Lib/test/test_codecencodings_kr.py b/Lib/test/test_codecencodings_kr.py
index 34fade923e..de4da7f5b6 100644
--- a/Lib/test/test_codecencodings_kr.py
+++ b/Lib/test/test_codecencodings_kr.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_kr.py
# Codec encoding tests for ROK encodings.
diff --git a/Lib/test/test_codecencodings_tw.py b/Lib/test/test_codecencodings_tw.py
index 6b840d36ce..12d3c9fa04 100644
--- a/Lib/test/test_codecencodings_tw.py
+++ b/Lib/test/test_codecencodings_tw.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_tw.py
# Codec encoding tests for ROC encodings.
diff --git a/Lib/test/test_codecmaps_cn.py b/Lib/test/test_codecmaps_cn.py
index 34a910d876..063919d6d8 100644
--- a/Lib/test/test_codecmaps_cn.py
+++ b/Lib/test/test_codecmaps_cn.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_cn.py
# Codec mapping tests for PRC encodings
diff --git a/Lib/test/test_codecmaps_hk.py b/Lib/test/test_codecmaps_hk.py
index ddb1208b3d..bbe1f2f905 100644
--- a/Lib/test/test_codecmaps_hk.py
+++ b/Lib/test/test_codecmaps_hk.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_hk.py
# Codec mapping tests for HongKong encodings
diff --git a/Lib/test/test_codecmaps_jp.py b/Lib/test/test_codecmaps_jp.py
index 75db00c602..652bd81515 100644
--- a/Lib/test/test_codecmaps_jp.py
+++ b/Lib/test/test_codecmaps_jp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_jp.py
# Codec mapping tests for Japanese encodings
diff --git a/Lib/test/test_codecmaps_kr.py b/Lib/test/test_codecmaps_kr.py
index 0da9d1ce95..d909c8bd58 100644
--- a/Lib/test/test_codecmaps_kr.py
+++ b/Lib/test/test_codecmaps_kr.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_kr.py
# Codec mapping tests for ROK encodings
diff --git a/Lib/test/test_codecmaps_tw.py b/Lib/test/test_codecmaps_tw.py
index e6df3a72fc..6db5091fc3 100644
--- a/Lib/test/test_codecmaps_tw.py
+++ b/Lib/test/test_codecmaps_tw.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_tw.py
# Codec mapping tests for ROC encodings
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 93cdf915b8..d560d7aa46 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -29,7 +29,7 @@ class MixInCheckStateHandling:
d = codecs.getincrementaldecoder(encoding)()
part1 = d.decode(s[:i])
state = d.getstate()
- self.assertTrue(isinstance(state[1], int))
+ self.assertIsInstance(state[1], int)
# Check that the condition stated in the documentation for
# IncrementalDecoder.getstate() holds
if not state[1]:
@@ -72,7 +72,6 @@ class ReadTest(unittest.TestCase, MixInCheckStateHandling):
# check that there's nothing left in the buffers
self.assertEqual(r.read(), "")
self.assertEqual(r.bytebuffer, b"")
- self.assertEqual(r.charbuffer, "")
# do the check again, this time using a incremental decoder
d = codecs.getincrementaldecoder(self.encoding)()
@@ -545,6 +544,12 @@ class UTF16LETest(ReadTest):
self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode,
b"\xff", "strict", True)
+ def test_nonbmp(self):
+ self.assertEqual("\U00010203".encode(self.encoding),
+ b'\x00\xd8\x03\xde')
+ self.assertEqual(b'\x00\xd8\x03\xde'.decode(self.encoding),
+ "\U00010203")
+
class UTF16BETest(ReadTest):
encoding = "utf-16-be"
@@ -567,6 +572,12 @@ class UTF16BETest(ReadTest):
self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode,
b"\xff", "strict", True)
+ def test_nonbmp(self):
+ self.assertEqual("\U00010203".encode(self.encoding),
+ b'\xd8\x00\xde\x03')
+ self.assertEqual(b'\xd8\x00\xde\x03'.decode(self.encoding),
+ "\U00010203")
+
class UTF8Test(ReadTest):
encoding = "utf-8"
@@ -653,18 +664,6 @@ class ReadBufferTest(unittest.TestCase):
self.assertRaises(TypeError, codecs.readbuffer_encode)
self.assertRaises(TypeError, codecs.readbuffer_encode, 42)
-class CharBufferTest(unittest.TestCase):
-
- def test_string(self):
- self.assertEqual(codecs.charbuffer_encode(b"spam"), (b"spam", 4))
-
- def test_empty(self):
- self.assertEqual(codecs.charbuffer_encode(b""), (b"", 0))
-
- def test_bad_args(self):
- self.assertRaises(TypeError, codecs.charbuffer_encode)
- self.assertRaises(TypeError, codecs.charbuffer_encode, 42)
-
class UTF8SigTest(ReadTest):
encoding = "utf-8-sig"
@@ -1276,6 +1275,7 @@ all_unicode_encodings = [
"cp424",
"cp437",
"cp500",
+ "cp720",
"cp737",
"cp775",
"cp850",
@@ -1283,6 +1283,7 @@ all_unicode_encodings = [
"cp855",
"cp856",
"cp857",
+ "cp858",
"cp860",
"cp861",
"cp862",
@@ -1371,11 +1372,6 @@ broken_incremental_coders = broken_unicode_with_streams + [
"idna",
]
-# The following encodings only support "strict" mode
-only_strict_mode = [
- "idna",
-]
-
class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling):
def test_basics(self):
s = "abc123" # all codecs should be able to encode these
@@ -1450,7 +1446,7 @@ class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling):
result = "".join(codecs.iterdecode(codecs.iterencode("", encoding), encoding))
self.assertEqual(result, "")
- if encoding not in only_strict_mode:
+ if encoding not in ("idna", "mbcs"):
# check incremental decoder/encoder with errors argument
try:
encoder = codecs.getincrementalencoder(encoding)("ignore")
@@ -1675,6 +1671,54 @@ class BomTest(unittest.TestCase):
self.assertEqual(f.read(), data * 2)
+bytes_transform_encodings = [
+ "base64_codec",
+ "uu_codec",
+ "quopri_codec",
+ "hex_codec",
+]
+try:
+ import zlib
+except ImportError:
+ pass
+else:
+ bytes_transform_encodings.append("zlib_codec")
+try:
+ import bz2
+except ImportError:
+ pass
+else:
+ bytes_transform_encodings.append("bz2_codec")
+
+class TransformCodecTest(unittest.TestCase):
+
+ def test_basics(self):
+ binput = bytes(range(256))
+ for encoding in bytes_transform_encodings:
+ # generic codecs interface
+ (o, size) = codecs.getencoder(encoding)(binput)
+ self.assertEqual(size, len(binput))
+ (i, size) = codecs.getdecoder(encoding)(o)
+ self.assertEqual(size, len(o))
+ self.assertEqual(i, binput)
+
+ def test_read(self):
+ for encoding in bytes_transform_encodings:
+ sin = codecs.encode(b"\x80", encoding)
+ reader = codecs.getreader(encoding)(io.BytesIO(sin))
+ sout = reader.read()
+ self.assertEqual(sout, b"\x80")
+
+ def test_readline(self):
+ for encoding in bytes_transform_encodings:
+ if encoding in ['uu_codec', 'zlib_codec']:
+ continue
+ sin = codecs.encode(b"\x80", encoding)
+ reader = codecs.getreader(encoding)(io.BytesIO(sin))
+ sout = reader.readline()
+ self.assertEqual(sout, b"\x80")
+
+
def test_main():
support.run_unittest(
UTF32Test,
@@ -1688,7 +1732,6 @@ def test_main():
UTF7Test,
UTF16ExTest,
ReadBufferTest,
- CharBufferTest,
RecodingTest,
PunycodeTest,
UnicodeInternalTest,
@@ -1703,6 +1746,7 @@ def test_main():
TypesTest,
SurrogateEscapeTest,
BomTest,
+ TransformCodecTest,
)
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py
index ffbcd34026..d096293648 100644
--- a/Lib/test/test_codeop.py
+++ b/Lib/test/test_codeop.py
@@ -295,10 +295,6 @@ class CodeopTests(unittest.TestCase):
self.assertNotEqual(compile_command("a = 1\n", "abc").co_filename,
compile("a = 1\n", "def", 'single').co_filename)
- def test_no_universal_newlines(self):
- code = compile_command("'\rfoo\r'", symbol='eval')
- self.assertEqual(eval(code), '\rfoo\r')
-
def test_main():
run_unittest(CodeopTests)
diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py
index 9d368c5e96..f9db0b40f0 100644
--- a/Lib/test/test_coding.py
+++ b/Lib/test/test_coding.py
@@ -1,6 +1,6 @@
import test.support, unittest
-from test.support import TESTFN, unlink
+from test.support import TESTFN, unlink, unload
import os, sys
class CodingTest(unittest.TestCase):
@@ -17,9 +17,8 @@ class CodingTest(unittest.TestCase):
path = os.path.dirname(__file__)
filename = os.path.join(path, module_name + '.py')
- fp = open(filename, "rb")
- bytes = fp.read()
- fp.close()
+ with open(filename, "rb") as fp:
+ bytes = fp.read()
self.assertRaises(SyntaxError, compile, bytes, filename, 'exec')
def test_exec_valid_coding(self):
@@ -30,9 +29,8 @@ class CodingTest(unittest.TestCase):
def test_file_parse(self):
# issue1134: all encodings outside latin-1 and utf-8 fail on
# multiline strings and long lines (>512 columns)
- if TESTFN in sys.modules:
- del sys.modules[TESTFN]
- sys.path.insert(0, ".")
+ unload(TESTFN)
+ sys.path.insert(0, os.curdir)
filename = TESTFN + ".py"
f = open(filename, "w")
try:
@@ -45,21 +43,20 @@ class CodingTest(unittest.TestCase):
__import__(TESTFN)
finally:
f.close()
- unlink(TESTFN+".py")
- unlink(TESTFN+".pyc")
- sys.path.pop(0)
+ unlink(filename)
+ unlink(filename + "c")
+ unload(TESTFN)
+ del sys.path[0]
def test_error_from_string(self):
# See http://bugs.python.org/issue6289
input = "# coding: ascii\n\N{SNOWMAN}".encode('utf-8')
- try:
+ with self.assertRaises(SyntaxError) as c:
compile(input, "<string>", "exec")
- except SyntaxError as e:
- expected = "'ascii' codec can't decode byte 0xe2 in position 16: " \
- "ordinal not in range(128)"
- self.assertTrue(str(e).startswith(expected))
- else:
- self.fail("didn't raise")
+ expected = "'ascii' codec can't decode byte 0xe2 in position 16: " \
+ "ordinal not in range(128)"
+ self.assertTrue(c.exception.args[0].startswith(expected))
+
def test_main():
test.support.run_unittest(CodingTest)
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 8989ac35c8..b3e0907b33 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -3,13 +3,14 @@
import unittest, doctest, operator
import inspect
from test import support
-from collections import namedtuple, Counter, OrderedDict
+from collections import namedtuple, Counter, OrderedDict, _count_elements
from test import mapping_tests
import pickle, copy
from random import randrange, shuffle
-import operator
import keyword
import re
+import sys
+from collections import _ChainMap as ChainMap
from collections import Hashable, Iterable, Iterator
from collections import Sized, Container, Callable
from collections import Set, MutableSet
@@ -17,6 +18,97 @@ from collections import Mapping, MutableMapping, KeysView, ItemsView, UserDict
from collections import Sequence, MutableSequence
from collections import ByteString
+
+################################################################################
+### _ChainMap (helper class for configparser)
+################################################################################
+
+class TestChainMap(unittest.TestCase):
+
+ def test_basics(self):
+ c = ChainMap()
+ c['a'] = 1
+ c['b'] = 2
+ d = c.new_child()
+ d['b'] = 20
+ d['c'] = 30
+ self.assertEqual(d.maps, [{'b':20, 'c':30}, {'a':1, 'b':2}]) # check internal state
+ self.assertEqual(d.items(), dict(a=1, b=20, c=30).items()) # check items/iter/getitem
+ self.assertEqual(len(d), 3) # check len
+ for key in 'abc': # check contains
+ self.assertIn(key, d)
+ for k, v in dict(a=1, b=20, c=30, z=100).items(): # check get
+ self.assertEqual(d.get(k, 100), v)
+
+ del d['b'] # unmask a value
+ self.assertEqual(d.maps, [{'c':30}, {'a':1, 'b':2}]) # check internal state
+ self.assertEqual(d.items(), dict(a=1, b=2, c=30).items()) # check items/iter/getitem
+ self.assertEqual(len(d), 3) # check len
+ for key in 'abc': # check contains
+ self.assertIn(key, d)
+ for k, v in dict(a=1, b=2, c=30, z=100).items(): # check get
+ self.assertEqual(d.get(k, 100), v)
+ self.assertIn(repr(d), [ # check repr
+ type(d).__name__ + "({'c': 30}, {'a': 1, 'b': 2})",
+ type(d).__name__ + "({'c': 30}, {'b': 2, 'a': 1})"
+ ])
+
+ for e in d.copy(), copy.copy(d): # check shallow copies
+ self.assertEqual(d, e)
+ self.assertEqual(d.maps, e.maps)
+ self.assertIsNot(d, e)
+ self.assertIsNot(d.maps[0], e.maps[0])
+ for m1, m2 in zip(d.maps[1:], e.maps[1:]):
+ self.assertIs(m1, m2)
+
+ for e in [pickle.loads(pickle.dumps(d)),
+ copy.deepcopy(d),
+ eval(repr(d))
+ ]: # check deep copies
+ self.assertEqual(d, e)
+ self.assertEqual(d.maps, e.maps)
+ self.assertIsNot(d, e)
+ for m1, m2 in zip(d.maps, e.maps):
+ self.assertIsNot(m1, m2, e)
+
+ d.new_child()
+ d['b'] = 5
+ self.assertEqual(d.maps, [{'b': 5}, {'c':30}, {'a':1, 'b':2}])
+ self.assertEqual(d.parents.maps, [{'c':30}, {'a':1, 'b':2}]) # check parents
+ self.assertEqual(d['b'], 5) # find first in chain
+ self.assertEqual(d.parents['b'], 2) # look beyond maps[0]
+
+ def test_contructor(self):
+ self.assertEqual(ChainedContext().maps, [{}]) # no-args --> one new dict
+ self.assertEqual(ChainMap({1:2}).maps, [{1:2}]) # 1 arg --> list
+
+ def test_missing(self):
+ class DefaultChainMap(ChainMap):
+ def __missing__(self, key):
+ return 999
+ d = DefaultChainMap(dict(a=1, b=2), dict(b=20, c=30))
+ for k, v in dict(a=1, b=2, c=30, d=999).items():
+ self.assertEqual(d[k], v) # check __getitem__ w/missing
+ for k, v in dict(a=1, b=2, c=30, d=77).items():
+ self.assertEqual(d.get(k, 77), v) # check get() w/ missing
+ for k, v in dict(a=True, b=True, c=True, d=False).items():
+ self.assertEqual(k in d, v) # check __contains__ w/missing
+ self.assertEqual(d.pop('a', 1001), 1, d)
+ self.assertEqual(d.pop('a', 1002), 1002) # check pop() w/missing
+ self.assertEqual(d.popitem(), ('b', 2)) # check popitem() w/missing
+ with self.assertRaises(KeyError):
+ d.popitem()
+
+ def test_dict_coercion(self):
+ d = ChainMap(dict(a=1, b=2), dict(b=20, c=30))
+ self.assertEqual(dict(d), dict(a=1, b=2, c=30))
+ self.assertEqual(dict(d.items()), dict(a=1, b=2, c=30))
+
+
+################################################################################
+### Named Tuples
+################################################################################
+
TestNT = namedtuple('TestNT', 'x y z') # type used for pickle tests
class TestNamedTuple(unittest.TestCase):
@@ -24,7 +116,6 @@ class TestNamedTuple(unittest.TestCase):
def test_factory(self):
Point = namedtuple('Point', 'x y')
self.assertEqual(Point.__name__, 'Point')
- self.assertEqual(Point.__doc__, 'Point(x, y)')
self.assertEqual(Point.__slots__, ())
self.assertEqual(Point.__module__, __name__)
self.assertEqual(Point.__getitem__, tuple.__getitem__)
@@ -44,13 +135,19 @@ class TestNamedTuple(unittest.TestCase):
namedtuple('_', 'a b c') # Test leading underscores in a typename
nt = namedtuple('nt', 'the quick brown fox') # check unicode input
- self.assertTrue("u'" not in repr(nt._fields))
+ self.assertNotIn("u'", repr(nt._fields))
nt = namedtuple('nt', ('the', 'quick')) # check unicode input
- self.assertTrue("u'" not in repr(nt._fields))
+ self.assertNotIn("u'", repr(nt._fields))
self.assertRaises(TypeError, Point._make, [11]) # catch too few args
self.assertRaises(TypeError, Point._make, [11, 22, 33]) # catch too many args
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_factory_doc_attr(self):
+ Point = namedtuple('Point', 'x y')
+ self.assertEqual(Point.__doc__, 'Point(x, y)')
+
def test_name_fixer(self):
for spec, renamed in [
[('efg', 'g%hi'), ('efg', '_1')], # field with non-alpha char
@@ -75,8 +172,8 @@ class TestNamedTuple(unittest.TestCase):
self.assertRaises(TypeError, eval, 'Point(XXX=1, y=2)', locals()) # wrong keyword argument
self.assertRaises(TypeError, eval, 'Point(x=1)', locals()) # missing keyword argument
self.assertEqual(repr(p), 'Point(x=11, y=22)')
- self.assertTrue('__dict__' not in dir(p)) # verify instance has no dict
- self.assertTrue('__weakref__' not in dir(p))
+ self.assertNotIn('__dict__', dir(p)) # verify instance has no dict
+ self.assertNotIn('__weakref__', dir(p))
self.assertEqual(p, Point._make([11, 22])) # test _make classmethod
self.assertEqual(p._fields, ('x', 'y')) # test _fields attribute
self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method
@@ -103,7 +200,7 @@ class TestNamedTuple(unittest.TestCase):
Point = namedtuple('Point', 'x y')
p = Point(11, 22)
- self.assertTrue(isinstance(p, tuple))
+ self.assertIsInstance(p, tuple)
self.assertEqual(p, (11, 22)) # matches a real tuple
self.assertEqual(tuple(p), (11, 22)) # coercable to a real tuple
self.assertEqual(list(p), [11, 22]) # coercable to a list
@@ -213,6 +310,20 @@ class TestNamedTuple(unittest.TestCase):
# test __getnewargs__
self.assertEqual(t.__getnewargs__(), values)
+ def test_repr(self):
+ with support.captured_stdout() as template:
+ A = namedtuple('A', 'x', verbose=True)
+ self.assertEqual(repr(A(1)), 'A(x=1)')
+ # repr should show the name of the subclass
+ class B(A):
+ pass
+ self.assertEqual(repr(B(1)), 'B(x=1)')
+
+
+################################################################################
+### Abstract Base Classes
+################################################################################
+
class ABCTestCase(unittest.TestCase):
def validate_abstract_methods(self, abc, *names):
@@ -229,6 +340,17 @@ class ABCTestCase(unittest.TestCase):
C = type('C', (abc,), stubs)
self.assertRaises(TypeError, C, name)
+ def validate_isinstance(self, abc, name):
+ stub = lambda s, *args: 0
+
+ C = type('C', (object,), {'__hash__': None})
+ setattr(C, name, stub)
+ self.assertIsInstance(C(), abc)
+ self.assertTrue(issubclass(C, abc))
+
+ C = type('C', (object,), {'__hash__': None})
+ self.assertNotIsInstance(C(), abc)
+ self.assertFalse(issubclass(C, abc))
def validate_comparison(self, instance):
ops = ['lt', 'gt', 'le', 'ge', 'ne', 'or', 'and', 'xor', 'sub']
@@ -267,7 +389,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
# Check some non-hashables
non_samples = [bytearray(), list(), set(), dict()]
for x in non_samples:
- self.assertFalse(isinstance(x, Hashable), repr(x))
+ self.assertNotIsInstance(x, Hashable)
self.assertFalse(issubclass(type(x), Hashable), repr(type(x)))
# Check some hashables
samples = [None,
@@ -277,7 +399,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
int, list, object, type, bytes()
]
for x in samples:
- self.assertTrue(isinstance(x, Hashable), repr(x))
+ self.assertIsInstance(x, Hashable)
self.assertTrue(issubclass(type(x), Hashable), repr(type(x)))
self.assertRaises(TypeError, Hashable)
# Check direct subclassing
@@ -287,12 +409,13 @@ class TestOneTrickPonyABCs(ABCTestCase):
self.assertEqual(hash(H()), 0)
self.assertFalse(issubclass(int, H))
self.validate_abstract_methods(Hashable, '__hash__')
+ self.validate_isinstance(Hashable, '__hash__')
def test_Iterable(self):
# Check some non-iterables
non_samples = [None, 42, 3.14, 1j]
for x in non_samples:
- self.assertFalse(isinstance(x, Iterable), repr(x))
+ self.assertNotIsInstance(x, Iterable)
self.assertFalse(issubclass(type(x), Iterable), repr(type(x)))
# Check some iterables
samples = [bytes(), str(),
@@ -302,7 +425,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
(x for x in []),
]
for x in samples:
- self.assertTrue(isinstance(x, Iterable), repr(x))
+ self.assertIsInstance(x, Iterable)
self.assertTrue(issubclass(type(x), Iterable), repr(type(x)))
# Check direct subclassing
class I(Iterable):
@@ -311,11 +434,12 @@ class TestOneTrickPonyABCs(ABCTestCase):
self.assertEqual(list(I()), [])
self.assertFalse(issubclass(str, I))
self.validate_abstract_methods(Iterable, '__iter__')
+ self.validate_isinstance(Iterable, '__iter__')
def test_Iterator(self):
non_samples = [None, 42, 3.14, 1j, b"", "", (), [], {}, set()]
for x in non_samples:
- self.assertFalse(isinstance(x, Iterator), repr(x))
+ self.assertNotIsInstance(x, Iterator)
self.assertFalse(issubclass(type(x), Iterator), repr(type(x)))
samples = [iter(bytes()), iter(str()),
iter(tuple()), iter(list()), iter(dict()),
@@ -326,7 +450,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
(x for x in []),
]
for x in samples:
- self.assertTrue(isinstance(x, Iterator), repr(x))
+ self.assertIsInstance(x, Iterator)
self.assertTrue(issubclass(type(x), Iterator), repr(type(x)))
self.validate_abstract_methods(Iterator, '__next__', '__iter__')
@@ -335,7 +459,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
def __next__(self):
yield 1
raise StopIteration
- self.assertFalse(isinstance(NextOnly(), Iterator))
+ self.assertNotIsInstance(NextOnly(), Iterator)
def test_Sized(self):
non_samples = [None, 42, 3.14, 1j,
@@ -343,16 +467,17 @@ class TestOneTrickPonyABCs(ABCTestCase):
(x for x in []),
]
for x in non_samples:
- self.assertFalse(isinstance(x, Sized), repr(x))
+ self.assertNotIsInstance(x, Sized)
self.assertFalse(issubclass(type(x), Sized), repr(type(x)))
samples = [bytes(), str(),
tuple(), list(), set(), frozenset(), dict(),
dict().keys(), dict().items(), dict().values(),
]
for x in samples:
- self.assertTrue(isinstance(x, Sized), repr(x))
+ self.assertIsInstance(x, Sized)
self.assertTrue(issubclass(type(x), Sized), repr(type(x)))
self.validate_abstract_methods(Sized, '__len__')
+ self.validate_isinstance(Sized, '__len__')
def test_Container(self):
non_samples = [None, 42, 3.14, 1j,
@@ -360,16 +485,17 @@ class TestOneTrickPonyABCs(ABCTestCase):
(x for x in []),
]
for x in non_samples:
- self.assertFalse(isinstance(x, Container), repr(x))
+ self.assertNotIsInstance(x, Container)
self.assertFalse(issubclass(type(x), Container), repr(type(x)))
samples = [bytes(), str(),
tuple(), list(), set(), frozenset(), dict(),
dict().keys(), dict().items(),
]
for x in samples:
- self.assertTrue(isinstance(x, Container), repr(x))
+ self.assertIsInstance(x, Container)
self.assertTrue(issubclass(type(x), Container), repr(type(x)))
self.validate_abstract_methods(Container, '__contains__')
+ self.validate_isinstance(Container, '__contains__')
def test_Callable(self):
non_samples = [None, 42, 3.14, 1j,
@@ -378,7 +504,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
(x for x in []),
]
for x in non_samples:
- self.assertFalse(isinstance(x, Callable), repr(x))
+ self.assertNotIsInstance(x, Callable)
self.assertFalse(issubclass(type(x), Callable), repr(type(x)))
samples = [lambda: None,
type, int, object,
@@ -386,9 +512,10 @@ class TestOneTrickPonyABCs(ABCTestCase):
list.append, [].append,
]
for x in samples:
- self.assertTrue(isinstance(x, Callable), repr(x))
+ self.assertIsInstance(x, Callable)
self.assertTrue(issubclass(type(x), Callable), repr(type(x)))
self.validate_abstract_methods(Callable, '__call__')
+ self.validate_isinstance(Callable, '__call__')
def test_direct_subclassing(self):
for B in Hashable, Iterable, Iterator, Sized, Container, Callable:
@@ -433,7 +560,7 @@ class TestCollectionABCs(ABCTestCase):
def test_Set(self):
for sample in [set, frozenset]:
- self.assertTrue(isinstance(sample(), Set))
+ self.assertIsInstance(sample(), Set)
self.assertTrue(issubclass(sample, Set))
self.validate_abstract_methods(Set, '__contains__', '__iter__', '__len__')
class MySet(Set):
@@ -461,9 +588,9 @@ class TestCollectionABCs(ABCTestCase):
self.assertTrue(hash(a) == hash(b))
def test_MutableSet(self):
- self.assertTrue(isinstance(set(), MutableSet))
+ self.assertIsInstance(set(), MutableSet)
self.assertTrue(issubclass(set, MutableSet))
- self.assertFalse(isinstance(frozenset(), MutableSet))
+ self.assertNotIsInstance(frozenset(), MutableSet)
self.assertFalse(issubclass(frozenset, MutableSet))
self.validate_abstract_methods(MutableSet, '__contains__', '__iter__', '__len__',
'add', 'discard')
@@ -476,7 +603,7 @@ class TestCollectionABCs(ABCTestCase):
def test_issue_4920(self):
# MutableSet.pop() method did not work
- class MySet(collections.MutableSet):
+ class MySet(MutableSet):
__slots__=['__s']
def __init__(self,items=None):
if items is None:
@@ -518,11 +645,11 @@ class TestCollectionABCs(ABCTestCase):
def test_Mapping(self):
for sample in [dict]:
- self.assertTrue(isinstance(sample(), Mapping))
+ self.assertIsInstance(sample(), Mapping)
self.assertTrue(issubclass(sample, Mapping))
self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__',
'__getitem__')
- class MyMapping(collections.Mapping):
+ class MyMapping(Mapping):
def __len__(self):
return 0
def __getitem__(self, i):
@@ -533,7 +660,7 @@ class TestCollectionABCs(ABCTestCase):
def test_MutableMapping(self):
for sample in [dict]:
- self.assertTrue(isinstance(sample(), MutableMapping))
+ self.assertIsInstance(sample(), MutableMapping)
self.assertTrue(issubclass(sample, MutableMapping))
self.validate_abstract_methods(MutableMapping, '__contains__', '__iter__', '__len__',
'__getitem__', '__setitem__', '__delitem__')
@@ -542,15 +669,15 @@ class TestCollectionABCs(ABCTestCase):
# Test issue 9214
mymap = UserDict()
mymap['red'] = 5
- self.assertTrue(isinstance(mymap.keys(), Set))
- self.assertTrue(isinstance(mymap.keys(), KeysView))
- self.assertTrue(isinstance(mymap.items(), Set))
- self.assertTrue(isinstance(mymap.items(), ItemsView))
+ self.assertIsInstance(mymap.keys(), Set)
+ self.assertIsInstance(mymap.keys(), KeysView)
+ self.assertIsInstance(mymap.items(), Set)
+ self.assertIsInstance(mymap.items(), ItemsView)
mymap = UserDict()
mymap['red'] = 5
z = mymap.keys() | {'orange'}
- self.assertEqual(type(z), set)
+ self.assertIsInstance(z, set)
list(z)
mymap['blue'] = 7 # Shouldn't affect 'z'
self.assertEqual(sorted(z), ['orange', 'red'])
@@ -558,16 +685,16 @@ class TestCollectionABCs(ABCTestCase):
mymap = UserDict()
mymap['red'] = 5
z = mymap.items() | {('orange', 3)}
- self.assertEqual(type(z), set)
+ self.assertIsInstance(z, set)
list(z)
mymap['blue'] = 7 # Shouldn't affect 'z'
self.assertEqual(sorted(z), [('orange', 3), ('red', 5)])
def test_Sequence(self):
for sample in [tuple, list, bytes, str]:
- self.assertTrue(isinstance(sample(), Sequence))
+ self.assertIsInstance(sample(), Sequence)
self.assertTrue(issubclass(sample, Sequence))
- self.assertTrue(isinstance(range(10), Sequence))
+ self.assertIsInstance(range(10), Sequence)
self.assertTrue(issubclass(range, Sequence))
self.assertTrue(issubclass(str, Sequence))
self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__',
@@ -575,33 +702,38 @@ class TestCollectionABCs(ABCTestCase):
def test_ByteString(self):
for sample in [bytes, bytearray]:
- self.assertTrue(isinstance(sample(), ByteString))
+ self.assertIsInstance(sample(), ByteString)
self.assertTrue(issubclass(sample, ByteString))
for sample in [str, list, tuple]:
- self.assertFalse(isinstance(sample(), ByteString))
+ self.assertNotIsInstance(sample(), ByteString)
self.assertFalse(issubclass(sample, ByteString))
- self.assertFalse(isinstance(memoryview(b""), ByteString))
+ self.assertNotIsInstance(memoryview(b""), ByteString)
self.assertFalse(issubclass(memoryview, ByteString))
def test_MutableSequence(self):
for sample in [tuple, str, bytes]:
- self.assertFalse(isinstance(sample(), MutableSequence))
+ self.assertNotIsInstance(sample(), MutableSequence)
self.assertFalse(issubclass(sample, MutableSequence))
for sample in [list, bytearray]:
- self.assertTrue(isinstance(sample(), MutableSequence))
+ self.assertIsInstance(sample(), MutableSequence)
self.assertTrue(issubclass(sample, MutableSequence))
self.assertFalse(issubclass(str, MutableSequence))
self.validate_abstract_methods(MutableSequence, '__contains__', '__iter__',
'__len__', '__getitem__', '__setitem__', '__delitem__', 'insert')
+
+################################################################################
+### Counter
+################################################################################
+
class TestCounter(unittest.TestCase):
def test_basics(self):
c = Counter('abcaba')
self.assertEqual(c, Counter({'a':3 , 'b': 2, 'c': 1}))
self.assertEqual(c, Counter(a=3, b=2, c=1))
- self.assertTrue(isinstance(c, dict))
- self.assertTrue(isinstance(c, Mapping))
+ self.assertIsInstance(c, dict)
+ self.assertIsInstance(c, Mapping)
self.assertTrue(issubclass(Counter, dict))
self.assertTrue(issubclass(Counter, Mapping))
self.assertEqual(len(c), 3)
@@ -634,10 +766,10 @@ class TestCounter(unittest.TestCase):
self.assertEqual(c, dict(a=4, b=0, d=-2, e=-5, f=4))
self.assertEqual(''.join(sorted(c.elements())), 'aaaaffff')
self.assertEqual(c.pop('f'), 4)
- self.assertEqual('f' in c, False)
+ self.assertNotIn('f', c)
for i in range(3):
elem, cnt = c.popitem()
- self.assertEqual(elem in c, False)
+ self.assertNotIn(elem, c)
c.clear()
self.assertEqual(c, {})
self.assertEqual(repr(c), 'Counter()')
@@ -692,6 +824,7 @@ class TestCounter(unittest.TestCase):
c = Counter(a=10, b=-2, c=0)
for elem in c:
self.assertTrue(elem in c)
+ self.assertIn(elem, c)
def test_multiset_operations(self):
# Verify that adding a zero counter will strip zeros and negatives
@@ -732,6 +865,34 @@ class TestCounter(unittest.TestCase):
set_result = setop(set(p.elements()), set(q.elements()))
self.assertEqual(counter_result, dict.fromkeys(set_result, 1))
+ def test_subtract(self):
+ c = Counter(a=-5, b=0, c=5, d=10, e=15,g=40)
+ c.subtract(a=1, b=2, c=-3, d=10, e=20, f=30, h=-50)
+ self.assertEqual(c, Counter(a=-6, b=-2, c=8, d=0, e=-5, f=-30, g=40, h=50))
+ c = Counter(a=-5, b=0, c=5, d=10, e=15,g=40)
+ c.subtract(Counter(a=1, b=2, c=-3, d=10, e=20, f=30, h=-50))
+ self.assertEqual(c, Counter(a=-6, b=-2, c=8, d=0, e=-5, f=-30, g=40, h=50))
+ c = Counter('aaabbcd')
+ c.subtract('aaaabbcce')
+ self.assertEqual(c, Counter(a=-1, b=0, c=-1, d=1, e=-1))
+
+ def test_helper_function(self):
+ # two paths, one for real dicts and one for other mappings
+ elems = list('abracadabra')
+
+ d = dict()
+ _count_elements(d, elems)
+ self.assertEqual(d, {'a': 5, 'r': 2, 'b': 2, 'c': 1, 'd': 1})
+
+ m = OrderedDict()
+ _count_elements(m, elems)
+ self.assertEqual(m,
+ OrderedDict([('a', 5), ('b', 2), ('r', 2), ('c', 1), ('d', 1)]))
+
+
+################################################################################
+### OrderedDict
+################################################################################
class TestOrderedDict(unittest.TestCase):
@@ -793,7 +954,7 @@ class TestOrderedDict(unittest.TestCase):
[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6), ('g', 7)])
def test_abc(self):
- self.assertTrue(isinstance(OrderedDict(), MutableMapping))
+ self.assertIsInstance(OrderedDict(), MutableMapping)
self.assertTrue(issubclass(OrderedDict, MutableMapping))
def test_clear(self):
@@ -808,7 +969,7 @@ class TestOrderedDict(unittest.TestCase):
pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
od = OrderedDict(pairs)
del od['a']
- self.assertTrue('a' not in od)
+ self.assertNotIn('a', od)
with self.assertRaises(KeyError):
del od['a']
self.assertEqual(list(od.items()), pairs[:2] + pairs[3:])
@@ -965,6 +1126,25 @@ class TestOrderedDict(unittest.TestCase):
od['a'] = 1
self.assertEqual(list(od.items()), [('b', 2), ('a', 1)])
+ def test_move_to_end(self):
+ od = OrderedDict.fromkeys('abcde')
+ self.assertEqual(list(od), list('abcde'))
+ od.move_to_end('c')
+ self.assertEqual(list(od), list('abdec'))
+ od.move_to_end('c', 0)
+ self.assertEqual(list(od), list('cabde'))
+ od.move_to_end('c', 0)
+ self.assertEqual(list(od), list('cabde'))
+ od.move_to_end('e')
+ self.assertEqual(list(od), list('cabde'))
+ with self.assertRaises(KeyError):
+ od.move_to_end('x')
+
+ def test_sizeof(self):
+ # Wimpy test: Just verify the reported size is larger than a regular dict
+ d = dict(a=1)
+ od = OrderedDict(**d)
+ self.assertGreater(sys.getsizeof(od), sys.getsizeof(d))
def test_override_update(self):
# Verify that subclasses can override update() without breaking __init__()
@@ -992,6 +1172,10 @@ class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol):
self.assertRaises(KeyError, d.popitem)
+################################################################################
+### Run tests
+################################################################################
+
import doctest, collections
def test_main(verbose=None):
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 749a5517b1..58ef2979a0 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -5,6 +5,19 @@ from test import support
class TestSpecifics(unittest.TestCase):
+ def test_no_ending_newline(self):
+ compile("hi", "<test>", "exec")
+ compile("hi\r", "<test>", "exec")
+
+ def test_empty(self):
+ compile("", "<test>", "exec")
+
+ def test_other_newlines(self):
+ compile("\r\n", "<test>", "exec")
+ compile("\r", "<test>", "exec")
+ compile("hi\r\nstuff\r\ndef f():\n pass\r", "<test>", "exec")
+ compile("this_is\rreally_old_mac\rdef f():\n pass", "<test>", "exec")
+
def test_debug_assignment(self):
# catch assignments to __debug__
self.assertRaises(SyntaxError, compile, '__debug__ = 1', '?', 'single')
@@ -179,8 +192,8 @@ if 1:
self.fail("How many bits *does* this machine have???")
# Verify treatment of constant folding on -(sys.maxsize+1)
# i.e. -2147483648 on 32 bit platforms. Should return int, not long.
- self.assertTrue(isinstance(eval("%s" % (-sys.maxsize - 1)), int))
- self.assertTrue(isinstance(eval("%s" % (-sys.maxsize - 2)), int))
+ self.assertIsInstance(eval("%s" % (-sys.maxsize - 1)), int)
+ self.assertIsInstance(eval("%s" % (-sys.maxsize - 2)), int)
if sys.maxsize == 9223372036854775807:
def test_32_63_bit_values(self):
@@ -195,7 +208,7 @@ if 1:
for variable in self.test_32_63_bit_values.__code__.co_consts:
if variable is not None:
- self.assertTrue(isinstance(variable, int))
+ self.assertIsInstance(variable, int)
def test_sequence_unpacking_error(self):
# Verify sequence packing/unpacking with "or". SF bug #757818
@@ -213,6 +226,10 @@ if 1:
'(a, None) = 0, 0',
'for None in range(10): pass',
'def f(None): pass',
+ 'import None',
+ 'import x as None',
+ 'from x import None',
+ 'from x import y as None'
]
for stmt in stmts:
stmt += "\n"
@@ -275,6 +292,10 @@ if 1:
f1, f2 = f()
self.assertNotEqual(id(f1.__code__), id(f2.__code__))
+ def test_lambda_doc(self):
+ l = lambda: "foo"
+ self.assertIsNone(l.__doc__)
+
## def test_unicode_encoding(self):
## code = "# -*- coding: utf-8 -*-\npass\n"
## self.assertRaises(SyntaxError, compile, code, "tmp", "exec")
@@ -300,56 +321,56 @@ if 1:
d[1] += 1
self.assertEqual(d[1], 2)
del d[1]
- self.assertEqual(1 in d, False)
+ self.assertNotIn(1, d)
# Tuple of indices
d[1, 1] = 1
self.assertEqual(d[1, 1], 1)
d[1, 1] += 1
self.assertEqual(d[1, 1], 2)
del d[1, 1]
- self.assertEqual((1, 1) in d, False)
+ self.assertNotIn((1, 1), d)
# Simple slice
d[1:2] = 1
self.assertEqual(d[1:2], 1)
d[1:2] += 1
self.assertEqual(d[1:2], 2)
del d[1:2]
- self.assertEqual(slice(1, 2) in d, False)
+ self.assertNotIn(slice(1, 2), d)
# Tuple of simple slices
d[1:2, 1:2] = 1
self.assertEqual(d[1:2, 1:2], 1)
d[1:2, 1:2] += 1
self.assertEqual(d[1:2, 1:2], 2)
del d[1:2, 1:2]
- self.assertEqual((slice(1, 2), slice(1, 2)) in d, False)
+ self.assertNotIn((slice(1, 2), slice(1, 2)), d)
# Extended slice
d[1:2:3] = 1
self.assertEqual(d[1:2:3], 1)
d[1:2:3] += 1
self.assertEqual(d[1:2:3], 2)
del d[1:2:3]
- self.assertEqual(slice(1, 2, 3) in d, False)
+ self.assertNotIn(slice(1, 2, 3), d)
# Tuple of extended slices
d[1:2:3, 1:2:3] = 1
self.assertEqual(d[1:2:3, 1:2:3], 1)
d[1:2:3, 1:2:3] += 1
self.assertEqual(d[1:2:3, 1:2:3], 2)
del d[1:2:3, 1:2:3]
- self.assertEqual((slice(1, 2, 3), slice(1, 2, 3)) in d, False)
+ self.assertNotIn((slice(1, 2, 3), slice(1, 2, 3)), d)
# Ellipsis
d[...] = 1
self.assertEqual(d[...], 1)
d[...] += 1
self.assertEqual(d[...], 2)
del d[...]
- self.assertEqual(Ellipsis in d, False)
+ self.assertNotIn(Ellipsis, d)
# Tuple of Ellipses
d[..., ...] = 1
self.assertEqual(d[..., ...], 1)
d[..., ...] += 1
self.assertEqual(d[..., ...], 2)
del d[..., ...]
- self.assertEqual((Ellipsis, Ellipsis) in d, False)
+ self.assertNotIn((Ellipsis, Ellipsis), d)
def test_annotation_limit(self):
# 16 bits are available for # of annotations, but only 8 bits are
@@ -372,10 +393,10 @@ if 1:
import __mangled_mod
import __package__.module
- self.assertTrue("_A__mangled" in A.f.__code__.co_varnames)
- self.assertTrue("__not_mangled__" in A.f.__code__.co_varnames)
- self.assertTrue("_A__mangled_mod" in A.f.__code__.co_varnames)
- self.assertTrue("__package__" in A.f.__code__.co_varnames)
+ self.assertIn("_A__mangled", A.f.__code__.co_varnames)
+ self.assertIn("__not_mangled__", A.f.__code__.co_varnames)
+ self.assertIn("_A__mangled_mod", A.f.__code__.co_varnames)
+ self.assertIn("__package__", A.f.__code__.co_varnames)
def test_compile_ast(self):
fname = __file__
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
index fe1dcf7a72..250d31b42e 100644
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -5,22 +5,29 @@ import os
import py_compile
import shutil
import struct
-import sys
+import subprocess
import tempfile
import time
-from test import support
import unittest
import io
+from test import support, script_helper
class CompileallTests(unittest.TestCase):
def setUp(self):
self.directory = tempfile.mkdtemp()
self.source_path = os.path.join(self.directory, '_test.py')
- self.bc_path = self.source_path + ('c' if __debug__ else 'o')
+ self.bc_path = imp.cache_from_source(self.source_path)
with open(self.source_path, 'w') as file:
file.write('x = 123\n')
+ self.source_path2 = os.path.join(self.directory, '_test2.py')
+ self.bc_path2 = imp.cache_from_source(self.source_path2)
+ shutil.copyfile(self.source_path, self.source_path2)
+ self.subdirectory = os.path.join(self.directory, '_subdir')
+ os.mkdir(self.subdirectory)
+ self.source_path3 = os.path.join(self.subdirectory, '_test3.py')
+ shutil.copyfile(self.source_path, self.source_path3)
def tearDown(self):
shutil.rmtree(self.directory)
@@ -56,9 +63,54 @@ class CompileallTests(unittest.TestCase):
# Test a change in mtime leads to a new .pyc.
self.recreation_check(b'\0\0\0\0')
+ def test_compile_files(self):
+ # Test compiling a single file, and complete directory
+ for fn in (self.bc_path, self.bc_path2):
+ try:
+ os.unlink(fn)
+ except:
+ pass
+ compileall.compile_file(self.source_path, force=False, quiet=True)
+ self.assertTrue(os.path.isfile(self.bc_path) and
+ not os.path.isfile(self.bc_path2))
+ os.unlink(self.bc_path)
+ compileall.compile_dir(self.directory, force=False, quiet=True)
+ self.assertTrue(os.path.isfile(self.bc_path) and
+ os.path.isfile(self.bc_path2))
+ os.unlink(self.bc_path)
+ os.unlink(self.bc_path2)
+
+ def test_no_pycache_in_non_package(self):
+ # Bug 8563 reported that __pycache__ directories got created by
+ # compile_file() for non-.py files.
+ data_dir = os.path.join(self.directory, 'data')
+ data_file = os.path.join(data_dir, 'file')
+ os.mkdir(data_dir)
+ # touch data/file
+ with open(data_file, 'w'):
+ pass
+ compileall.compile_file(data_file)
+ self.assertFalse(os.path.exists(os.path.join(data_dir, '__pycache__')))
+
+ def test_optimize(self):
+ # make sure compiling with different optimization settings than the
+ # interpreter's creates the correct file names
+ optimize = 1 if __debug__ else 0
+ compileall.compile_dir(self.directory, quiet=True, optimize=optimize)
+ cached = imp.cache_from_source(self.source_path,
+ debug_override=not optimize)
+ self.assertTrue(os.path.isfile(cached))
+ cached2 = imp.cache_from_source(self.source_path2,
+ debug_override=not optimize)
+ self.assertTrue(os.path.isfile(cached2))
+ cached3 = imp.cache_from_source(self.source_path3,
+ debug_override=not optimize)
+ self.assertTrue(os.path.isfile(cached3))
+
class EncodingTest(unittest.TestCase):
- 'Issue 6716: compileall should escape source code when printing errors to stdout.'
+ """Issue 6716: compileall should escape source code when printing errors
+ to stdout."""
def setUp(self):
self.directory = tempfile.mkdtemp()
@@ -78,9 +130,230 @@ class EncodingTest(unittest.TestCase):
finally:
sys.stdout = orig_stdout
+
+class CommandLineTests(unittest.TestCase):
+ """Test compileall's CLI."""
+
+ def assertRunOK(self, *args, **env_vars):
+ rc, out, err = script_helper.assert_python_ok(
+ '-S', '-m', 'compileall', *args, **env_vars)
+ self.assertEqual(b'', err)
+ return out
+
+ def assertRunNotOK(self, *args, **env_vars):
+ rc, out, err = script_helper.assert_python_failure(
+ '-S', '-m', 'compileall', *args, **env_vars)
+ return rc, out, err
+
+ def assertCompiled(self, fn):
+ self.assertTrue(os.path.exists(imp.cache_from_source(fn)))
+
+ def assertNotCompiled(self, fn):
+ self.assertFalse(os.path.exists(imp.cache_from_source(fn)))
+
+ def setUp(self):
+ self.addCleanup(self._cleanup)
+ self.directory = tempfile.mkdtemp()
+ self.pkgdir = os.path.join(self.directory, 'foo')
+ os.mkdir(self.pkgdir)
+ self.pkgdir_cachedir = os.path.join(self.pkgdir, '__pycache__')
+ # Create the __init__.py and a package module.
+ self.initfn = script_helper.make_script(self.pkgdir, '__init__', '')
+ self.barfn = script_helper.make_script(self.pkgdir, 'bar', '')
+
+ def _cleanup(self):
+ support.rmtree(self.directory)
+
+ def test_no_args_compiles_path(self):
+ # Note that -l is implied for the no args case.
+ bazfn = script_helper.make_script(self.directory, 'baz', '')
+ self.assertRunOK(PYTHONPATH=self.directory)
+ self.assertCompiled(bazfn)
+ self.assertNotCompiled(self.initfn)
+ self.assertNotCompiled(self.barfn)
+
+ # Ensure that the default behavior of compileall's CLI is to create
+ # PEP 3147 pyc/pyo files.
+ for name, ext, switch in [
+ ('normal', 'pyc', []),
+ ('optimize', 'pyo', ['-O']),
+ ('doubleoptimize', 'pyo', ['-OO']),
+ ]:
+ def f(self, ext=ext, switch=switch):
+ script_helper.assert_python_ok(*(switch +
+ ['-m', 'compileall', '-q', self.pkgdir]))
+ # Verify the __pycache__ directory contents.
+ self.assertTrue(os.path.exists(self.pkgdir_cachedir))
+ expected = sorted(base.format(imp.get_tag(), ext) for base in
+ ('__init__.{}.{}', 'bar.{}.{}'))
+ self.assertEqual(sorted(os.listdir(self.pkgdir_cachedir)), expected)
+ # Make sure there are no .pyc files in the source directory.
+ self.assertFalse([fn for fn in os.listdir(self.pkgdir)
+ if fn.endswith(ext)])
+ locals()['test_pep3147_paths_' + name] = f
+
+ def test_legacy_paths(self):
+ # Ensure that with the proper switch, compileall leaves legacy
+ # pyc/pyo files, and no __pycache__ directory.
+ self.assertRunOK('-b', '-q', self.pkgdir)
+ # Verify the __pycache__ directory contents.
+ self.assertFalse(os.path.exists(self.pkgdir_cachedir))
+ expected = sorted(['__init__.py', '__init__.pyc', 'bar.py', 'bar.pyc'])
+ self.assertEqual(sorted(os.listdir(self.pkgdir)), expected)
+
+ def test_multiple_runs(self):
+ # Bug 8527 reported that multiple calls produced empty
+ # __pycache__/__pycache__ directories.
+ self.assertRunOK('-q', self.pkgdir)
+ # Verify the __pycache__ directory contents.
+ self.assertTrue(os.path.exists(self.pkgdir_cachedir))
+ cachecachedir = os.path.join(self.pkgdir_cachedir, '__pycache__')
+ self.assertFalse(os.path.exists(cachecachedir))
+ # Call compileall again.
+ self.assertRunOK('-q', self.pkgdir)
+ self.assertTrue(os.path.exists(self.pkgdir_cachedir))
+ self.assertFalse(os.path.exists(cachecachedir))
+
+ def test_force(self):
+ self.assertRunOK('-q', self.pkgdir)
+ pycpath = imp.cache_from_source(self.barfn)
+ # set atime/mtime backward to avoid file timestamp resolution issues
+ os.utime(pycpath, (time.time()-60,)*2)
+ mtime = os.stat(pycpath).st_mtime
+ # without force, no recompilation
+ self.assertRunOK('-q', self.pkgdir)
+ mtime2 = os.stat(pycpath).st_mtime
+ self.assertEqual(mtime, mtime2)
+ # now force it.
+ self.assertRunOK('-q', '-f', self.pkgdir)
+ mtime2 = os.stat(pycpath).st_mtime
+ self.assertNotEqual(mtime, mtime2)
+
+ def test_recursion_control(self):
+ subpackage = os.path.join(self.pkgdir, 'spam')
+ os.mkdir(subpackage)
+ subinitfn = script_helper.make_script(subpackage, '__init__', '')
+ hamfn = script_helper.make_script(subpackage, 'ham', '')
+ self.assertRunOK('-q', '-l', self.pkgdir)
+ self.assertNotCompiled(subinitfn)
+ self.assertFalse(os.path.exists(os.path.join(subpackage, '__pycache__')))
+ self.assertRunOK('-q', self.pkgdir)
+ self.assertCompiled(subinitfn)
+ self.assertCompiled(hamfn)
+
+ def test_quiet(self):
+ noisy = self.assertRunOK(self.pkgdir)
+ quiet = self.assertRunOK('-q', self.pkgdir)
+ self.assertNotEqual(b'', noisy)
+ self.assertEqual(b'', quiet)
+
+ def test_regexp(self):
+ self.assertRunOK('-q', '-x', 'ba.*', self.pkgdir)
+ self.assertNotCompiled(self.barfn)
+ self.assertCompiled(self.initfn)
+
+ def test_multiple_dirs(self):
+ pkgdir2 = os.path.join(self.directory, 'foo2')
+ os.mkdir(pkgdir2)
+ init2fn = script_helper.make_script(pkgdir2, '__init__', '')
+ bar2fn = script_helper.make_script(pkgdir2, 'bar2', '')
+ self.assertRunOK('-q', self.pkgdir, pkgdir2)
+ self.assertCompiled(self.initfn)
+ self.assertCompiled(self.barfn)
+ self.assertCompiled(init2fn)
+ self.assertCompiled(bar2fn)
+
+ def test_d_takes_exactly_one_dir(self):
+ rc, out, err = self.assertRunNotOK('-d', 'foo')
+ self.assertEqual(out, b'')
+ self.assertRegex(err, b'-d')
+ rc, out, err = self.assertRunNotOK('-d', 'foo', 'bar')
+ self.assertEqual(out, b'')
+ self.assertRegex(err, b'-d')
+
+ def test_d_compile_error(self):
+ script_helper.make_script(self.pkgdir, 'crunchyfrog', 'bad(syntax')
+ rc, out, err = self.assertRunNotOK('-q', '-d', 'dinsdale', self.pkgdir)
+ self.assertRegex(out, b'File "dinsdale')
+
+ def test_d_runtime_error(self):
+ bazfn = script_helper.make_script(self.pkgdir, 'baz', 'raise Exception')
+ self.assertRunOK('-q', '-d', 'dinsdale', self.pkgdir)
+ fn = script_helper.make_script(self.pkgdir, 'bing', 'import baz')
+ pyc = imp.cache_from_source(bazfn)
+ os.rename(pyc, os.path.join(self.pkgdir, 'baz.pyc'))
+ os.remove(bazfn)
+ rc, out, err = script_helper.assert_python_failure(fn)
+ self.assertRegex(err, b'File "dinsdale')
+
+ def test_include_bad_file(self):
+ rc, out, err = self.assertRunNotOK(
+ '-i', os.path.join(self.directory, 'nosuchfile'), self.pkgdir)
+ self.assertRegex(out, b'rror.*nosuchfile')
+ self.assertNotRegex(err, b'Traceback')
+ self.assertFalse(os.path.exists(imp.cache_from_source(
+ self.pkgdir_cachedir)))
+
+ def test_include_file_with_arg(self):
+ f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+ f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+ f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+ f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+ with open(os.path.join(self.directory, 'l1'), 'w') as l1:
+ l1.write(os.path.join(self.pkgdir, 'f1.py')+os.linesep)
+ l1.write(os.path.join(self.pkgdir, 'f2.py')+os.linesep)
+ self.assertRunOK('-i', os.path.join(self.directory, 'l1'), f4)
+ self.assertCompiled(f1)
+ self.assertCompiled(f2)
+ self.assertNotCompiled(f3)
+ self.assertCompiled(f4)
+
+ def test_include_file_no_arg(self):
+ f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+ f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+ f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+ f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+ with open(os.path.join(self.directory, 'l1'), 'w') as l1:
+ l1.write(os.path.join(self.pkgdir, 'f2.py')+os.linesep)
+ self.assertRunOK('-i', os.path.join(self.directory, 'l1'))
+ self.assertNotCompiled(f1)
+ self.assertCompiled(f2)
+ self.assertNotCompiled(f3)
+ self.assertNotCompiled(f4)
+
+ def test_include_on_stdin(self):
+ f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+ f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+ f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+ f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+ p = script_helper.spawn_python('-m', 'compileall', '-i', '-')
+ p.stdin.write((f3+os.linesep).encode('ascii'))
+ script_helper.kill_python(p)
+ self.assertNotCompiled(f1)
+ self.assertNotCompiled(f2)
+ self.assertCompiled(f3)
+ self.assertNotCompiled(f4)
+
+ def test_compiles_as_much_as_possible(self):
+ bingfn = script_helper.make_script(self.pkgdir, 'bing', 'syntax(error')
+ rc, out, err = self.assertRunNotOK('nosuchfile', self.initfn,
+ bingfn, self.barfn)
+ self.assertRegex(out, b'rror')
+ self.assertNotCompiled(bingfn)
+ self.assertCompiled(self.initfn)
+ self.assertCompiled(self.barfn)
+
+ def test_invalid_arg_produces_message(self):
+ out = self.assertRunOK('badfilename')
+ self.assertRegex(out, b"Can't list badfilename")
+
+
def test_main():
- support.run_unittest(CompileallTests,
- EncodingTest)
+ support.run_unittest(
+ CommandLineTests,
+ CompileallTests,
+ EncodingTest,
+ )
if __name__ == "__main__":
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index 5173494b59..6b34ddc0a6 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -1,8 +1,9 @@
-import unittest, os
+import unittest
from test import support
from random import random
from math import atan2, isnan, copysign
+import operator
INF = float("inf")
NAN = float("nan")
@@ -65,9 +66,6 @@ class ComplexTest(unittest.TestCase):
self.assertCloseAbs(x.real, y.real, eps)
self.assertCloseAbs(x.imag, y.imag, eps)
- def assertIs(self, a, b):
- self.assertTrue(a is b)
-
def check_div(self, x, y):
"""Compute complex z=x*y, and check that z/x==y and z/y==x."""
z = x * y
@@ -112,16 +110,47 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 0+0j)
def test_richcompare(self):
- self.assertRaises(OverflowError, complex.__eq__, 1+1j, 1<<10000)
- self.assertEqual(complex.__lt__(1+1j, None), NotImplemented)
+ self.assertIs(complex.__eq__(1+1j, 1<<10000), False)
+ self.assertIs(complex.__lt__(1+1j, None), NotImplemented)
self.assertIs(complex.__eq__(1+1j, 1+1j), True)
self.assertIs(complex.__eq__(1+1j, 2+2j), False)
self.assertIs(complex.__ne__(1+1j, 1+1j), False)
self.assertIs(complex.__ne__(1+1j, 2+2j), True)
- self.assertRaises(TypeError, complex.__lt__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__le__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__gt__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__ge__, 1+1j, 2+2j)
+ for i in range(1, 100):
+ f = i / 100.0
+ self.assertIs(complex.__eq__(f+0j, f), True)
+ self.assertIs(complex.__ne__(f+0j, f), False)
+ self.assertIs(complex.__eq__(complex(f, f), f), False)
+ self.assertIs(complex.__ne__(complex(f, f), f), True)
+ self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__ge__(1+1j, 2+2j), NotImplemented)
+ self.assertRaises(TypeError, operator.lt, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.le, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.gt, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.ge, 1+1j, 2+2j)
+ self.assertIs(operator.eq(1+1j, 1+1j), True)
+ self.assertIs(operator.eq(1+1j, 2+2j), False)
+ self.assertIs(operator.ne(1+1j, 1+1j), False)
+ self.assertIs(operator.ne(1+1j, 2+2j), True)
+
+ def test_richcompare_boundaries(self):
+ def check(n, deltas, is_equal, imag = 0.0):
+ for delta in deltas:
+ i = n + delta
+ z = complex(i, imag)
+ self.assertIs(complex.__eq__(z, i), is_equal(delta))
+ self.assertIs(complex.__ne__(z, i), not is_equal(delta))
+ # For IEEE-754 doubles the following should hold:
+ # x in [2 ** (52 + i), 2 ** (53 + i + 1)] -> x mod 2 ** i == 0
+ # where the interval is representable, of course.
+ for i in range(1, 10):
+ pow = 52 + i
+ mult = 2 ** i
+ check(2 ** pow, range(1, 101), lambda delta: delta % mult == 0)
+ check(2 ** pow, range(1, 101), lambda delta: False, float(i))
+ check(2 ** 53, range(-100, 0), lambda delta: True)
def test_mod(self):
# % is no longer supported on complex numbers
@@ -191,6 +220,7 @@ class ComplexTest(unittest.TestCase):
self.assertEqual(complex(NS(1+10j)), 1+10j)
self.assertRaises(TypeError, complex, OS(None))
self.assertRaises(TypeError, complex, NS(None))
+ self.assertRaises(TypeError, complex, {})
self.assertAlmostEqual(complex("1+10j"), 1+10j)
self.assertAlmostEqual(complex(10), 10+0j)
@@ -284,7 +314,6 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(ValueError, complex, "1+2j)")
self.assertRaises(ValueError, complex, "1+(2j)")
self.assertRaises(ValueError, complex, "(1+2j)123")
- self.assertRaises(ValueError, complex, "1"*500)
self.assertRaises(ValueError, complex, "x")
self.assertRaises(ValueError, complex, "1j+2")
self.assertRaises(ValueError, complex, "1e1ej")
@@ -295,6 +324,11 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(ValueError, complex, "1.11.1j")
self.assertRaises(ValueError, complex, "1e1.1j")
+ # check that complex accepts long unicode strings
+ self.assertEqual(type(complex("1"*500)), complex)
+ # check whitespace processing
+ self.assertEqual(complex('\N{EM SPACE}(\N{EN SPACE}1+1j ) '), 1+1j)
+
class EvilExc(Exception):
pass
@@ -347,28 +381,48 @@ class ComplexTest(unittest.TestCase):
for num in nums:
self.assertAlmostEqual((num.real**2 + num.imag**2) ** 0.5, abs(num))
- def test_repr(self):
- self.assertEqual(repr(1+6j), '(1+6j)')
- self.assertEqual(repr(1-6j), '(1-6j)')
+ def test_repr_str(self):
+ def test(v, expected, test_fn=self.assertEqual):
+ test_fn(repr(v), expected)
+ test_fn(str(v), expected)
+
+ test(1+6j, '(1+6j)')
+ test(1-6j, '(1-6j)')
- self.assertNotEqual(repr(-(1+0j)), '(-1+-0j)')
+ test(-(1+0j), '(-1+-0j)', test_fn=self.assertNotEqual)
+
+ test(complex(1., INF), "(1+infj)")
+ test(complex(1., -INF), "(1-infj)")
+ test(complex(INF, 1), "(inf+1j)")
+ test(complex(-INF, INF), "(-inf+infj)")
+ test(complex(NAN, 1), "(nan+1j)")
+ test(complex(1, NAN), "(1+nanj)")
+ test(complex(NAN, NAN), "(nan+nanj)")
+
+ test(complex(0, INF), "infj")
+ test(complex(0, -INF), "-infj")
+ test(complex(0, NAN), "nanj")
self.assertEqual(1-6j,complex(repr(1-6j)))
self.assertEqual(1+6j,complex(repr(1+6j)))
self.assertEqual(-6j,complex(repr(-6j)))
self.assertEqual(6j,complex(repr(6j)))
- self.assertEqual(repr(complex(1., INF)), "(1+infj)")
- self.assertEqual(repr(complex(1., -INF)), "(1-infj)")
- self.assertEqual(repr(complex(INF, 1)), "(inf+1j)")
- self.assertEqual(repr(complex(-INF, INF)), "(-inf+infj)")
- self.assertEqual(repr(complex(NAN, 1)), "(nan+1j)")
- self.assertEqual(repr(complex(1, NAN)), "(1+nanj)")
- self.assertEqual(repr(complex(NAN, NAN)), "(nan+nanj)")
+ @support.requires_IEEE_754
+ def test_negative_zero_repr_str(self):
+ def test(v, expected, test_fn=self.assertEqual):
+ test_fn(repr(v), expected)
+ test_fn(str(v), expected)
+
+ test(complex(0., 1.), "1j")
+ test(complex(-0., 1.), "(-0+1j)")
+ test(complex(0., -1.), "-1j")
+ test(complex(-0., -1.), "(-0-1j)")
- self.assertEqual(repr(complex(0, INF)), "infj")
- self.assertEqual(repr(complex(0, -INF)), "-infj")
- self.assertEqual(repr(complex(0, NAN)), "nanj")
+ test(complex(0., 0.), "0j")
+ test(complex(0., -0.), "-0j")
+ test(complex(-0., 0.), "(-0+0j)")
+ test(complex(-0., -0.), "(-0-0j)")
def test_neg(self):
self.assertEqual(-(1+6j), -1-6j)
@@ -387,10 +441,7 @@ class ComplexTest(unittest.TestCase):
finally:
if (fo is not None) and (not fo.closed):
fo.close()
- try:
- os.remove(support.TESTFN)
- except (OSError, IOError):
- pass
+ support.unlink(support.TESTFN)
def test_getnewargs(self):
self.assertEqual((1+2j).__getnewargs__(), (1.0, 2.0))
@@ -400,41 +451,36 @@ class ComplexTest(unittest.TestCase):
self.assertEqual(complex(0, INF).__getnewargs__(), (0.0, INF))
self.assertEqual(complex(INF, 0).__getnewargs__(), (INF, 0.0))
- if float.__getformat__("double").startswith("IEEE"):
- def test_plus_minus_0j(self):
- # test that -0j and 0j literals are not identified
- z1, z2 = 0j, -0j
- self.assertEqual(atan2(z1.imag, -1.), atan2(0., -1.))
- self.assertEqual(atan2(z2.imag, -1.), atan2(-0., -1.))
+ @support.requires_IEEE_754
+ def test_plus_minus_0j(self):
+ # test that -0j and 0j literals are not identified
+ z1, z2 = 0j, -0j
+ self.assertEqual(atan2(z1.imag, -1.), atan2(0., -1.))
+ self.assertEqual(atan2(z2.imag, -1.), atan2(-0., -1.))
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @support.requires_IEEE_754
def test_negated_imaginary_literal(self):
z0 = -0j
z1 = -7j
z2 = -1e1000j
- # This behaviour is actually incorrect: the real part of a negated
- # imaginary literal should be -0.0, not 0.0. It's fixed in Python 3.2.
- # However, the behaviour is already out in the wild in Python 2.x and
- # Python <= 3.1.2, and it would be too disruptive to change it in a
- # bugfix release, so we call it a 'feature' of Python 3.1, and test to
- # ensure that the behaviour remains consistent across 3.1.x releases.
- self.assertFloatsAreIdentical(z0.real, 0.0)
+ # Note: In versions of Python < 3.2, a negated imaginary literal
+ # accidentally ended up with real part 0.0 instead of -0.0, thanks to a
+ # modification during CST -> AST translation (see issue #9011). That's
+ # fixed in Python 3.2.
+ self.assertFloatsAreIdentical(z0.real, -0.0)
self.assertFloatsAreIdentical(z0.imag, -0.0)
- self.assertFloatsAreIdentical(z1.real, 0.0)
+ self.assertFloatsAreIdentical(z1.real, -0.0)
self.assertFloatsAreIdentical(z1.imag, -7.0)
- self.assertFloatsAreIdentical(z2.real, 0.0)
+ self.assertFloatsAreIdentical(z2.real, -0.0)
self.assertFloatsAreIdentical(z2.imag, -INF)
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @support.requires_IEEE_754
def test_overflow(self):
self.assertEqual(complex("1e500"), complex(INF, 0.0))
self.assertEqual(complex("-1e500j"), complex(0.0, -INF))
self.assertEqual(complex("-1e500+1.8e308j"), complex(-INF, INF))
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @support.requires_IEEE_754
def test_repr_roundtrip(self):
vals = [0.0, 1e-500, 1e-315, 1e-200, 0.0123, 3.1415, 1e50, INF, NAN]
vals += [-v for v in vals]
@@ -529,8 +575,28 @@ class ComplexTest(unittest.TestCase):
self.assertEqual(format(1.5e21+3j, '^40,.2f'), ' 1,500,000,000,000,000,000,000.00+3.00j ')
self.assertEqual(format(1.5e21+3000j, ',.2f'), '1,500,000,000,000,000,000,000.00+3,000.00j')
- # alternate is invalid
- self.assertRaises(ValueError, (1.5+0.5j).__format__, '#f')
+ # Issue 7094: Alternate formatting (specified by #)
+ self.assertEqual(format(1+1j, '.0e'), '1e+00+1e+00j')
+ self.assertEqual(format(1+1j, '#.0e'), '1.e+00+1.e+00j')
+ self.assertEqual(format(1+1j, '.0f'), '1+1j')
+ self.assertEqual(format(1+1j, '#.0f'), '1.+1.j')
+ self.assertEqual(format(1.1+1.1j, 'g'), '1.1+1.1j')
+ self.assertEqual(format(1.1+1.1j, '#g'), '1.10000+1.10000j')
+
+ # Alternate doesn't make a difference for these, they format the same with or without it
+ self.assertEqual(format(1+1j, '.1e'), '1.0e+00+1.0e+00j')
+ self.assertEqual(format(1+1j, '#.1e'), '1.0e+00+1.0e+00j')
+ self.assertEqual(format(1+1j, '.1f'), '1.0+1.0j')
+ self.assertEqual(format(1+1j, '#.1f'), '1.0+1.0j')
+
+ # Misc. other alternate tests
+ self.assertEqual(format((-1.5+0.5j), '#f'), '-1.500000+0.500000j')
+ self.assertEqual(format((-1.5+0.5j), '#.0f'), '-2.+0.j')
+ self.assertEqual(format((-1.5+0.5j), '#e'), '-1.500000e+00+5.000000e-01j')
+ self.assertEqual(format((-1.5+0.5j), '#.0e'), '-2.e+00+5.e-01j')
+ self.assertEqual(format((-1.5+0.5j), '#g'), '-1.50000+0.500000j')
+ self.assertEqual(format((-1.5+0.5j), '.0g'), '-2+0.5j')
+ self.assertEqual(format((-1.5+0.5j), '#.0g'), '-2.+0.5j')
# zero padding is invalid
self.assertRaises(ValueError, (1.5+0.5j).__format__, '010f')
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
new file mode 100644
index 0000000000..06cdf0b0e8
--- /dev/null
+++ b/Lib/test/test_concurrent_futures.py
@@ -0,0 +1,588 @@
+import test.support
+
+# Skip tests if _multiprocessing wasn't built.
+test.support.import_module('_multiprocessing')
+# Skip tests if sem_open implementation is broken.
+test.support.import_module('multiprocessing.synchronize')
+# import threading after _multiprocessing to raise a more revelant error
+# message: "No module named _multiprocessing". _multiprocessing is not compiled
+# without thread support.
+test.support.import_module('threading')
+
+import threading
+import time
+import unittest
+
+from concurrent import futures
+from concurrent.futures._base import (
+ PENDING, RUNNING, CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED, Future)
+import concurrent.futures.process
+
+
+def create_future(state=PENDING, exception=None, result=None):
+ f = Future()
+ f._state = state
+ f._exception = exception
+ f._result = result
+ return f
+
+
+PENDING_FUTURE = create_future(state=PENDING)
+RUNNING_FUTURE = create_future(state=RUNNING)
+CANCELLED_FUTURE = create_future(state=CANCELLED)
+CANCELLED_AND_NOTIFIED_FUTURE = create_future(state=CANCELLED_AND_NOTIFIED)
+EXCEPTION_FUTURE = create_future(state=FINISHED, exception=IOError())
+SUCCESSFUL_FUTURE = create_future(state=FINISHED, result=42)
+
+
+def mul(x, y):
+ return x * y
+
+
+def sleep_and_raise(t):
+ time.sleep(t)
+ raise Exception('this is an exception')
+
+
+class ExecutorMixin:
+ worker_count = 5
+ def _prime_executor(self):
+ # Make sure that the executor is ready to do work before running the
+ # tests. This should reduce the probability of timeouts in the tests.
+ futures = [self.executor.submit(time.sleep, 0.1)
+ for _ in range(self.worker_count)]
+
+ for f in futures:
+ f.result()
+
+
+class ThreadPoolMixin(ExecutorMixin):
+ def setUp(self):
+ self.executor = futures.ThreadPoolExecutor(max_workers=5)
+ self._prime_executor()
+
+ def tearDown(self):
+ self.executor.shutdown(wait=True)
+
+
+class ProcessPoolMixin(ExecutorMixin):
+ def setUp(self):
+ try:
+ self.executor = futures.ProcessPoolExecutor(max_workers=5)
+ except NotImplementedError as e:
+ self.skipTest(str(e))
+ self._prime_executor()
+
+ def tearDown(self):
+ self.executor.shutdown(wait=True)
+
+
+class ExecutorShutdownTest(unittest.TestCase):
+ def test_run_after_shutdown(self):
+ self.executor.shutdown()
+ self.assertRaises(RuntimeError,
+ self.executor.submit,
+ pow, 2, 5)
+
+
+class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest):
+ def _prime_executor(self):
+ pass
+
+ def test_threads_terminate(self):
+ self.executor.submit(mul, 21, 2)
+ self.executor.submit(mul, 6, 7)
+ self.executor.submit(mul, 3, 14)
+ self.assertEqual(len(self.executor._threads), 3)
+ self.executor.shutdown()
+ for t in self.executor._threads:
+ t.join()
+
+ def test_context_manager_shutdown(self):
+ with futures.ThreadPoolExecutor(max_workers=5) as e:
+ executor = e
+ self.assertEqual(list(e.map(abs, range(-5, 5))),
+ [5, 4, 3, 2, 1, 0, 1, 2, 3, 4])
+
+ for t in executor._threads:
+ t.join()
+
+ def test_del_shutdown(self):
+ executor = futures.ThreadPoolExecutor(max_workers=5)
+ executor.map(abs, range(-5, 5))
+ threads = executor._threads
+ del executor
+
+ for t in threads:
+ t.join()
+
+
+class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest):
+ def _prime_executor(self):
+ pass
+
+ def test_processes_terminate(self):
+ self.executor.submit(mul, 21, 2)
+ self.executor.submit(mul, 6, 7)
+ self.executor.submit(mul, 3, 14)
+ self.assertEqual(len(self.executor._processes), 5)
+ processes = self.executor._processes
+ self.executor.shutdown()
+
+ for p in processes:
+ p.join()
+
+ def test_context_manager_shutdown(self):
+ with futures.ProcessPoolExecutor(max_workers=5) as e:
+ processes = e._processes
+ self.assertEqual(list(e.map(abs, range(-5, 5))),
+ [5, 4, 3, 2, 1, 0, 1, 2, 3, 4])
+
+ for p in processes:
+ p.join()
+
+ def test_del_shutdown(self):
+ executor = futures.ProcessPoolExecutor(max_workers=5)
+ list(executor.map(abs, range(-5, 5)))
+ queue_management_thread = executor._queue_management_thread
+ processes = executor._processes
+ del executor
+
+ queue_management_thread.join()
+ for p in processes:
+ p.join()
+
+class WaitTests(unittest.TestCase):
+ def test_first_completed(self):
+ future1 = self.executor.submit(mul, 21, 2)
+ future2 = self.executor.submit(time.sleep, 5)
+
+ done, not_done = futures.wait(
+ [CANCELLED_FUTURE, future1, future2],
+ return_when=futures.FIRST_COMPLETED)
+
+ self.assertEqual(set([future1]), done)
+ self.assertEqual(set([CANCELLED_FUTURE, future2]), not_done)
+
+ def test_first_completed_some_already_completed(self):
+ future1 = self.executor.submit(time.sleep, 2)
+
+ finished, pending = futures.wait(
+ [CANCELLED_AND_NOTIFIED_FUTURE, SUCCESSFUL_FUTURE, future1],
+ return_when=futures.FIRST_COMPLETED)
+
+ self.assertEqual(
+ set([CANCELLED_AND_NOTIFIED_FUTURE, SUCCESSFUL_FUTURE]),
+ finished)
+ self.assertEqual(set([future1]), pending)
+
+ def test_first_exception(self):
+ future1 = self.executor.submit(mul, 2, 21)
+ future2 = self.executor.submit(sleep_and_raise, 5)
+ future3 = self.executor.submit(time.sleep, 10)
+
+ finished, pending = futures.wait(
+ [future1, future2, future3],
+ return_when=futures.FIRST_EXCEPTION)
+
+ self.assertEqual(set([future1, future2]), finished)
+ self.assertEqual(set([future3]), pending)
+
+ def test_first_exception_some_already_complete(self):
+ future1 = self.executor.submit(divmod, 21, 0)
+ future2 = self.executor.submit(time.sleep, 5)
+
+ finished, pending = futures.wait(
+ [SUCCESSFUL_FUTURE,
+ CANCELLED_FUTURE,
+ CANCELLED_AND_NOTIFIED_FUTURE,
+ future1, future2],
+ return_when=futures.FIRST_EXCEPTION)
+
+ self.assertEqual(set([SUCCESSFUL_FUTURE,
+ CANCELLED_AND_NOTIFIED_FUTURE,
+ future1]), finished)
+ self.assertEqual(set([CANCELLED_FUTURE, future2]), pending)
+
+ def test_first_exception_one_already_failed(self):
+ future1 = self.executor.submit(time.sleep, 2)
+
+ finished, pending = futures.wait(
+ [EXCEPTION_FUTURE, future1],
+ return_when=futures.FIRST_EXCEPTION)
+
+ self.assertEqual(set([EXCEPTION_FUTURE]), finished)
+ self.assertEqual(set([future1]), pending)
+
+ def test_all_completed(self):
+ future1 = self.executor.submit(divmod, 2, 0)
+ future2 = self.executor.submit(mul, 2, 21)
+
+ finished, pending = futures.wait(
+ [SUCCESSFUL_FUTURE,
+ CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ future1,
+ future2],
+ return_when=futures.ALL_COMPLETED)
+
+ self.assertEqual(set([SUCCESSFUL_FUTURE,
+ CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ future1,
+ future2]), finished)
+ self.assertEqual(set(), pending)
+
+ def test_timeout(self):
+ future1 = self.executor.submit(mul, 6, 7)
+ future2 = self.executor.submit(time.sleep, 10)
+
+ finished, pending = futures.wait(
+ [CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1, future2],
+ timeout=5,
+ return_when=futures.ALL_COMPLETED)
+
+ self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1]), finished)
+ self.assertEqual(set([future2]), pending)
+
+
+class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests):
+ pass
+
+
+class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests):
+ pass
+
+
+class AsCompletedTests(unittest.TestCase):
+ # TODO(brian@sweetapp.com): Should have a test with a non-zero timeout.
+ def test_no_timeout(self):
+ future1 = self.executor.submit(mul, 2, 21)
+ future2 = self.executor.submit(mul, 7, 6)
+
+ completed = set(futures.as_completed(
+ [CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1, future2]))
+ self.assertEqual(set(
+ [CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1, future2]),
+ completed)
+
+ def test_zero_timeout(self):
+ future1 = self.executor.submit(time.sleep, 2)
+ completed_futures = set()
+ try:
+ for future in futures.as_completed(
+ [CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1],
+ timeout=0):
+ completed_futures.add(future)
+ except futures.TimeoutError:
+ pass
+
+ self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE]),
+ completed_futures)
+
+
+class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests):
+ pass
+
+
+class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests):
+ pass
+
+
+class ExecutorTest(unittest.TestCase):
+ # Executor.shutdown() and context manager usage is tested by
+ # ExecutorShutdownTest.
+ def test_submit(self):
+ future = self.executor.submit(pow, 2, 8)
+ self.assertEqual(256, future.result())
+
+ def test_submit_keyword(self):
+ future = self.executor.submit(mul, 2, y=8)
+ self.assertEqual(16, future.result())
+
+ def test_map(self):
+ self.assertEqual(
+ list(self.executor.map(pow, range(10), range(10))),
+ list(map(pow, range(10), range(10))))
+
+ def test_map_exception(self):
+ i = self.executor.map(divmod, [1, 1, 1, 1], [2, 3, 0, 5])
+ self.assertEqual(i.__next__(), (0, 1))
+ self.assertEqual(i.__next__(), (0, 1))
+ self.assertRaises(ZeroDivisionError, i.__next__)
+
+ def test_map_timeout(self):
+ results = []
+ try:
+ for i in self.executor.map(time.sleep,
+ [0, 0, 10],
+ timeout=5):
+ results.append(i)
+ except futures.TimeoutError:
+ pass
+ else:
+ self.fail('expected TimeoutError')
+
+ self.assertEqual([None, None], results)
+
+
+class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest):
+ pass
+
+
+class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest):
+ pass
+
+
+class FutureTests(unittest.TestCase):
+ def test_done_callback_with_result(self):
+ callback_result = None
+ def fn(callback_future):
+ nonlocal callback_result
+ callback_result = callback_future.result()
+
+ f = Future()
+ f.add_done_callback(fn)
+ f.set_result(5)
+ self.assertEqual(5, callback_result)
+
+ def test_done_callback_with_exception(self):
+ callback_exception = None
+ def fn(callback_future):
+ nonlocal callback_exception
+ callback_exception = callback_future.exception()
+
+ f = Future()
+ f.add_done_callback(fn)
+ f.set_exception(Exception('test'))
+ self.assertEqual(('test',), callback_exception.args)
+
+ def test_done_callback_with_cancel(self):
+ was_cancelled = None
+ def fn(callback_future):
+ nonlocal was_cancelled
+ was_cancelled = callback_future.cancelled()
+
+ f = Future()
+ f.add_done_callback(fn)
+ self.assertTrue(f.cancel())
+ self.assertTrue(was_cancelled)
+
+ def test_done_callback_raises(self):
+ with test.support.captured_stderr() as stderr:
+ raising_was_called = False
+ fn_was_called = False
+
+ def raising_fn(callback_future):
+ nonlocal raising_was_called
+ raising_was_called = True
+ raise Exception('doh!')
+
+ def fn(callback_future):
+ nonlocal fn_was_called
+ fn_was_called = True
+
+ f = Future()
+ f.add_done_callback(raising_fn)
+ f.add_done_callback(fn)
+ f.set_result(5)
+ self.assertTrue(raising_was_called)
+ self.assertTrue(fn_was_called)
+ self.assertIn('Exception: doh!', stderr.getvalue())
+
+ def test_done_callback_already_successful(self):
+ callback_result = None
+ def fn(callback_future):
+ nonlocal callback_result
+ callback_result = callback_future.result()
+
+ f = Future()
+ f.set_result(5)
+ f.add_done_callback(fn)
+ self.assertEqual(5, callback_result)
+
+ def test_done_callback_already_failed(self):
+ callback_exception = None
+ def fn(callback_future):
+ nonlocal callback_exception
+ callback_exception = callback_future.exception()
+
+ f = Future()
+ f.set_exception(Exception('test'))
+ f.add_done_callback(fn)
+ self.assertEqual(('test',), callback_exception.args)
+
+ def test_done_callback_already_cancelled(self):
+ was_cancelled = None
+ def fn(callback_future):
+ nonlocal was_cancelled
+ was_cancelled = callback_future.cancelled()
+
+ f = Future()
+ self.assertTrue(f.cancel())
+ f.add_done_callback(fn)
+ self.assertTrue(was_cancelled)
+
+ def test_repr(self):
+ self.assertRegex(repr(PENDING_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=pending>')
+ self.assertRegex(repr(RUNNING_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=running>')
+ self.assertRegex(repr(CANCELLED_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=cancelled>')
+ self.assertRegex(repr(CANCELLED_AND_NOTIFIED_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=cancelled>')
+ self.assertRegex(
+ repr(EXCEPTION_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=finished raised IOError>')
+ self.assertRegex(
+ repr(SUCCESSFUL_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=finished returned int>')
+
+
+ def test_cancel(self):
+ f1 = create_future(state=PENDING)
+ f2 = create_future(state=RUNNING)
+ f3 = create_future(state=CANCELLED)
+ f4 = create_future(state=CANCELLED_AND_NOTIFIED)
+ f5 = create_future(state=FINISHED, exception=IOError())
+ f6 = create_future(state=FINISHED, result=5)
+
+ self.assertTrue(f1.cancel())
+ self.assertEqual(f1._state, CANCELLED)
+
+ self.assertFalse(f2.cancel())
+ self.assertEqual(f2._state, RUNNING)
+
+ self.assertTrue(f3.cancel())
+ self.assertEqual(f3._state, CANCELLED)
+
+ self.assertTrue(f4.cancel())
+ self.assertEqual(f4._state, CANCELLED_AND_NOTIFIED)
+
+ self.assertFalse(f5.cancel())
+ self.assertEqual(f5._state, FINISHED)
+
+ self.assertFalse(f6.cancel())
+ self.assertEqual(f6._state, FINISHED)
+
+ def test_cancelled(self):
+ self.assertFalse(PENDING_FUTURE.cancelled())
+ self.assertFalse(RUNNING_FUTURE.cancelled())
+ self.assertTrue(CANCELLED_FUTURE.cancelled())
+ self.assertTrue(CANCELLED_AND_NOTIFIED_FUTURE.cancelled())
+ self.assertFalse(EXCEPTION_FUTURE.cancelled())
+ self.assertFalse(SUCCESSFUL_FUTURE.cancelled())
+
+ def test_done(self):
+ self.assertFalse(PENDING_FUTURE.done())
+ self.assertFalse(RUNNING_FUTURE.done())
+ self.assertTrue(CANCELLED_FUTURE.done())
+ self.assertTrue(CANCELLED_AND_NOTIFIED_FUTURE.done())
+ self.assertTrue(EXCEPTION_FUTURE.done())
+ self.assertTrue(SUCCESSFUL_FUTURE.done())
+
+ def test_running(self):
+ self.assertFalse(PENDING_FUTURE.running())
+ self.assertTrue(RUNNING_FUTURE.running())
+ self.assertFalse(CANCELLED_FUTURE.running())
+ self.assertFalse(CANCELLED_AND_NOTIFIED_FUTURE.running())
+ self.assertFalse(EXCEPTION_FUTURE.running())
+ self.assertFalse(SUCCESSFUL_FUTURE.running())
+
+ def test_result_with_timeout(self):
+ self.assertRaises(futures.TimeoutError,
+ PENDING_FUTURE.result, timeout=0)
+ self.assertRaises(futures.TimeoutError,
+ RUNNING_FUTURE.result, timeout=0)
+ self.assertRaises(futures.CancelledError,
+ CANCELLED_FUTURE.result, timeout=0)
+ self.assertRaises(futures.CancelledError,
+ CANCELLED_AND_NOTIFIED_FUTURE.result, timeout=0)
+ self.assertRaises(IOError, EXCEPTION_FUTURE.result, timeout=0)
+ self.assertEqual(SUCCESSFUL_FUTURE.result(timeout=0), 42)
+
+ def test_result_with_success(self):
+ # TODO(brian@sweetapp.com): This test is timing dependant.
+ def notification():
+ # Wait until the main thread is waiting for the result.
+ time.sleep(1)
+ f1.set_result(42)
+
+ f1 = create_future(state=PENDING)
+ t = threading.Thread(target=notification)
+ t.start()
+
+ self.assertEqual(f1.result(timeout=5), 42)
+
+ def test_result_with_cancel(self):
+ # TODO(brian@sweetapp.com): This test is timing dependant.
+ def notification():
+ # Wait until the main thread is waiting for the result.
+ time.sleep(1)
+ f1.cancel()
+
+ f1 = create_future(state=PENDING)
+ t = threading.Thread(target=notification)
+ t.start()
+
+ self.assertRaises(futures.CancelledError, f1.result, timeout=5)
+
+ def test_exception_with_timeout(self):
+ self.assertRaises(futures.TimeoutError,
+ PENDING_FUTURE.exception, timeout=0)
+ self.assertRaises(futures.TimeoutError,
+ RUNNING_FUTURE.exception, timeout=0)
+ self.assertRaises(futures.CancelledError,
+ CANCELLED_FUTURE.exception, timeout=0)
+ self.assertRaises(futures.CancelledError,
+ CANCELLED_AND_NOTIFIED_FUTURE.exception, timeout=0)
+ self.assertTrue(isinstance(EXCEPTION_FUTURE.exception(timeout=0),
+ IOError))
+ self.assertEqual(SUCCESSFUL_FUTURE.exception(timeout=0), None)
+
+ def test_exception_with_success(self):
+ def notification():
+ # Wait until the main thread is waiting for the exception.
+ time.sleep(1)
+ with f1._condition:
+ f1._state = FINISHED
+ f1._exception = IOError()
+ f1._condition.notify_all()
+
+ f1 = create_future(state=PENDING)
+ t = threading.Thread(target=notification)
+ t.start()
+
+ self.assertTrue(isinstance(f1.exception(timeout=5), IOError))
+
+def test_main():
+ test.support.run_unittest(ProcessPoolExecutorTest,
+ ThreadPoolExecutorTest,
+ ProcessPoolWaitTests,
+ ThreadPoolWaitTests,
+ ProcessPoolAsCompletedTests,
+ ThreadPoolAsCompletedTests,
+ FutureTests,
+ ProcessPoolShutdownTest,
+ ThreadPoolShutdownTest)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_contains.py b/Lib/test/test_contains.py
index 622dfd46d1..a667a16d8c 100644
--- a/Lib/test/test_contains.py
+++ b/Lib/test/test_contains.py
@@ -20,19 +20,19 @@ class TestContains(unittest.TestCase):
a = base_set(1)
b = myset(1)
c = seq(1)
- self.assertTrue(1 in b)
- self.assertTrue(0 not in b)
- self.assertTrue(1 in c)
- self.assertTrue(0 not in c)
+ self.assertIn(1, b)
+ self.assertNotIn(0, b)
+ self.assertIn(1, c)
+ self.assertNotIn(0, c)
self.assertRaises(TypeError, lambda: 1 in a)
self.assertRaises(TypeError, lambda: 1 not in a)
# test char in string
- self.assertTrue('c' in 'abc')
- self.assertTrue('d' not in 'abc')
+ self.assertIn('c', 'abc')
+ self.assertNotIn('d', 'abc')
- self.assertTrue('' in '')
- self.assertTrue('' in 'abc')
+ self.assertIn('', '')
+ self.assertIn('', 'abc')
self.assertRaises(TypeError, lambda: None in 'abc')
@@ -40,15 +40,15 @@ class TestContains(unittest.TestCase):
# a collection of tests on builtin sequence types
a = range(10)
for i in a:
- self.assertTrue(i in a)
- self.assertTrue(16 not in a)
- self.assertTrue(a not in a)
+ self.assertIn(i, a)
+ self.assertNotIn(16, a)
+ self.assertNotIn(a, a)
a = tuple(a)
for i in a:
- self.assertTrue(i in a)
- self.assertTrue(16 not in a)
- self.assertTrue(a not in a)
+ self.assertIn(i, a)
+ self.assertNotIn(16, a)
+ self.assertNotIn(a, a)
class Deviant1:
"""Behaves strangely when compared
@@ -64,7 +64,7 @@ class TestContains(unittest.TestCase):
self.aList.remove(14)
return 0
- self.assertTrue(Deviant1() not in Deviant1.aList)
+ self.assertNotIn(Deviant1(), Deviant1.aList)
def test_nonreflexive(self):
# containment and equality tests involving elements that are
@@ -81,7 +81,7 @@ class TestContains(unittest.TestCase):
for constructor in constructors:
container = constructor(values)
for elem in container:
- self.assertTrue(elem in container)
+ self.assertIn(elem, container)
self.assertTrue(container == constructor(values))
self.assertTrue(container == container)
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index 015a0c5195..d6bb5b818e 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -1,15 +1,15 @@
"""Unit tests for contextlib.py, and other context managers."""
-
import sys
-import os
-import decimal
import tempfile
import unittest
-import threading
from contextlib import * # Tests __all__
from test import support
-import warnings
+try:
+ import threading
+except ImportError:
+ threading = None
+
class ContextManagerTestCase(unittest.TestCase):
@@ -35,16 +35,12 @@ class ContextManagerTestCase(unittest.TestCase):
yield 42
finally:
state.append(999)
- try:
+ with self.assertRaises(ZeroDivisionError):
with woohoo() as x:
self.assertEqual(state, [1])
self.assertEqual(x, 42)
state.append(x)
raise ZeroDivisionError()
- except ZeroDivisionError:
- pass
- else:
- self.fail("Expected ZeroDivisionError")
self.assertEqual(state, [1, 42, 999])
def test_contextmanager_no_reraise(self):
@@ -86,7 +82,7 @@ class ContextManagerTestCase(unittest.TestCase):
raise ZeroDivisionError(999)
self.assertEqual(state, [1, 42, 999])
- def test_contextmanager_attribs(self):
+ def _create_contextmanager_attribs(self):
def attribs(**kw):
def decorate(func):
for k,v in kw.items():
@@ -97,131 +93,18 @@ class ContextManagerTestCase(unittest.TestCase):
@attribs(foo='bar')
def baz(spam):
"""Whee!"""
+ return baz
+
+ def test_contextmanager_attribs(self):
+ baz = self._create_contextmanager_attribs()
self.assertEqual(baz.__name__,'baz')
self.assertEqual(baz.foo, 'bar')
- self.assertEqual(baz.__doc__, "Whee!")
-class NestedTestCase(unittest.TestCase):
-
- # XXX This needs more work
-
- def test_nested(self):
- @contextmanager
- def a():
- yield 1
- @contextmanager
- def b():
- yield 2
- @contextmanager
- def c():
- yield 3
- with nested(a(), b(), c()) as (x, y, z):
- self.assertEqual(x, 1)
- self.assertEqual(y, 2)
- self.assertEqual(z, 3)
-
- def test_nested_cleanup(self):
- state = []
- @contextmanager
- def a():
- state.append(1)
- try:
- yield 2
- finally:
- state.append(3)
- @contextmanager
- def b():
- state.append(4)
- try:
- yield 5
- finally:
- state.append(6)
- try:
- with nested(a(), b()) as (x, y):
- state.append(x)
- state.append(y)
- 1/0
- except ZeroDivisionError:
- self.assertEqual(state, [1, 4, 2, 5, 6, 3])
- else:
- self.fail("Didn't raise ZeroDivisionError")
-
- def test_nested_right_exception(self):
- state = []
- @contextmanager
- def a():
- yield 1
- class b(object):
- def __enter__(self):
- return 2
- def __exit__(self, *exc_info):
- try:
- raise Exception()
- except:
- pass
- try:
- with nested(a(), b()) as (x, y):
- 1/0
- except ZeroDivisionError:
- self.assertEqual((x, y), (1, 2))
- except Exception:
- self.fail("Reraised wrong exception")
- else:
- self.fail("Didn't raise ZeroDivisionError")
-
- def test_nested_b_swallows(self):
- @contextmanager
- def a():
- yield
- @contextmanager
- def b():
- try:
- yield
- except:
- # Swallow the exception
- pass
- try:
- with nested(a(), b()):
- 1/0
- except ZeroDivisionError:
- self.fail("Didn't swallow ZeroDivisionError")
-
- def test_nested_break(self):
- @contextmanager
- def a():
- yield
- state = 0
- while True:
- state += 1
- with nested(a(), a()):
- break
- state += 10
- self.assertEqual(state, 1)
-
- def test_nested_continue(self):
- @contextmanager
- def a():
- yield
- state = 0
- while state < 3:
- state += 1
- with nested(a(), a()):
- continue
- state += 10
- self.assertEqual(state, 3)
-
- def test_nested_return(self):
- @contextmanager
- def a():
- try:
- yield
- except:
- pass
- def foo():
- with nested(a(), a()):
- return 1
- return 10
- self.assertEqual(foo(), 1)
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_contextmanager_doc_attrib(self):
+ baz = self._create_contextmanager_attribs()
+ self.assertEqual(baz.__doc__, "Whee!")
class ClosingTestCase(unittest.TestCase):
@@ -245,14 +128,11 @@ class ClosingTestCase(unittest.TestCase):
state.append(1)
x = C()
self.assertEqual(state, [])
- try:
+ with self.assertRaises(ZeroDivisionError):
with closing(x) as y:
self.assertEqual(x, y)
- 1/0
- except ZeroDivisionError:
- self.assertEqual(state, [1])
- else:
- self.fail("Didn't raise ZeroDivisionError")
+ 1 / 0
+ self.assertEqual(state, [1])
class FileContextTestCase(unittest.TestCase):
@@ -265,21 +145,16 @@ class FileContextTestCase(unittest.TestCase):
f.write("Booh\n")
self.assertTrue(f.closed)
f = None
- try:
+ with self.assertRaises(ZeroDivisionError):
with open(tfn, "r") as f:
self.assertFalse(f.closed)
self.assertEqual(f.read(), "Booh\n")
- 1/0
- except ZeroDivisionError:
- self.assertTrue(f.closed)
- else:
- self.fail("Didn't raise ZeroDivisionError")
+ 1 / 0
+ self.assertTrue(f.closed)
finally:
- try:
- os.remove(tfn)
- except os.error:
- pass
+ support.unlink(tfn)
+@unittest.skipUnless(threading, 'Threading required for this test.')
class LockContextTestCase(unittest.TestCase):
def boilerPlate(self, lock, locked):
@@ -287,14 +162,11 @@ class LockContextTestCase(unittest.TestCase):
with lock:
self.assertTrue(locked())
self.assertFalse(locked())
- try:
+ with self.assertRaises(ZeroDivisionError):
with lock:
self.assertTrue(locked())
- 1/0
- except ZeroDivisionError:
- self.assertFalse(locked())
- else:
- self.fail("Didn't raise ZeroDivisionError")
+ 1 / 0
+ self.assertFalse(locked())
def testWithLock(self):
lock = threading.Lock()
@@ -330,11 +202,172 @@ class LockContextTestCase(unittest.TestCase):
return True
self.boilerPlate(lock, locked)
+
+class mycontext(ContextDecorator):
+ started = False
+ exc = None
+ catch = False
+
+ def __enter__(self):
+ self.started = True
+ return self
+
+ def __exit__(self, *exc):
+ self.exc = exc
+ return self.catch
+
+
+class TestContextDecorator(unittest.TestCase):
+
+ def test_contextdecorator(self):
+ context = mycontext()
+ with context as result:
+ self.assertIs(result, context)
+ self.assertTrue(context.started)
+
+ self.assertEqual(context.exc, (None, None, None))
+
+
+ def test_contextdecorator_with_exception(self):
+ context = mycontext()
+
+ with self.assertRaisesRegex(NameError, 'foo'):
+ with context:
+ raise NameError('foo')
+ self.assertIsNotNone(context.exc)
+ self.assertIs(context.exc[0], NameError)
+
+ context = mycontext()
+ context.catch = True
+ with context:
+ raise NameError('foo')
+ self.assertIsNotNone(context.exc)
+ self.assertIs(context.exc[0], NameError)
+
+
+ def test_decorator(self):
+ context = mycontext()
+
+ @context
+ def test():
+ self.assertIsNone(context.exc)
+ self.assertTrue(context.started)
+ test()
+ self.assertEqual(context.exc, (None, None, None))
+
+
+ def test_decorator_with_exception(self):
+ context = mycontext()
+
+ @context
+ def test():
+ self.assertIsNone(context.exc)
+ self.assertTrue(context.started)
+ raise NameError('foo')
+
+ with self.assertRaisesRegex(NameError, 'foo'):
+ test()
+ self.assertIsNotNone(context.exc)
+ self.assertIs(context.exc[0], NameError)
+
+
+ def test_decorating_method(self):
+ context = mycontext()
+
+ class Test(object):
+
+ @context
+ def method(self, a, b, c=None):
+ self.a = a
+ self.b = b
+ self.c = c
+
+ # these tests are for argument passing when used as a decorator
+ test = Test()
+ test.method(1, 2)
+ self.assertEqual(test.a, 1)
+ self.assertEqual(test.b, 2)
+ self.assertEqual(test.c, None)
+
+ test = Test()
+ test.method('a', 'b', 'c')
+ self.assertEqual(test.a, 'a')
+ self.assertEqual(test.b, 'b')
+ self.assertEqual(test.c, 'c')
+
+ test = Test()
+ test.method(a=1, b=2)
+ self.assertEqual(test.a, 1)
+ self.assertEqual(test.b, 2)
+
+
+ def test_typo_enter(self):
+ class mycontext(ContextDecorator):
+ def __unter__(self):
+ pass
+ def __exit__(self, *exc):
+ pass
+
+ with self.assertRaises(AttributeError):
+ with mycontext():
+ pass
+
+
+ def test_typo_exit(self):
+ class mycontext(ContextDecorator):
+ def __enter__(self):
+ pass
+ def __uxit__(self, *exc):
+ pass
+
+ with self.assertRaises(AttributeError):
+ with mycontext():
+ pass
+
+
+ def test_contextdecorator_as_mixin(self):
+ class somecontext(object):
+ started = False
+ exc = None
+
+ def __enter__(self):
+ self.started = True
+ return self
+
+ def __exit__(self, *exc):
+ self.exc = exc
+
+ class mycontext(somecontext, ContextDecorator):
+ pass
+
+ context = mycontext()
+ @context
+ def test():
+ self.assertIsNone(context.exc)
+ self.assertTrue(context.started)
+ test()
+ self.assertEqual(context.exc, (None, None, None))
+
+
+ def test_contextmanager_as_decorator(self):
+ state = []
+ @contextmanager
+ def woohoo(y):
+ state.append(y)
+ yield
+ state.append(999)
+
+ @woohoo(1)
+ def test(x):
+ self.assertEqual(state, [1])
+ state.append(x)
+ test('something')
+ self.assertEqual(state, [1, 'something', 999])
+
+
# This is needed to make the test actually run under regrtest.py!
def test_main():
- with warnings.catch_warnings():
- warnings.simplefilter('ignore')
- support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index f4ca6b343f..a84c109b87 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -647,7 +647,7 @@ class TestCopy(unittest.TestCase):
x, y = C(), C()
# The underlying containers are decoupled
v[x] = y
- self.assertFalse(x in u)
+ self.assertNotIn(x, u)
def test_copy_weakkeydict(self):
self._check_copy_weakdict(weakref.WeakKeyDictionary)
@@ -697,6 +697,17 @@ class TestCopy(unittest.TestCase):
del d
self.assertEqual(len(v), 1)
+ def test_deepcopy_bound_method(self):
+ class Foo(object):
+ def m(self):
+ pass
+ f = Foo()
+ f.b = f.m
+ g = copy.deepcopy(f)
+ self.assertEqual(g.m, g.b)
+ self.assertTrue(g.b.__self__ is g)
+ g.b()
+
def global_foo(x, y): return x+y
diff --git a/Lib/test/test_copyreg.py b/Lib/test/test_copyreg.py
index bb3651eb55..abe0748f85 100644
--- a/Lib/test/test_copyreg.py
+++ b/Lib/test/test_copyreg.py
@@ -54,7 +54,7 @@ class CopyRegTestCase(unittest.TestCase):
self.assertTrue(copyreg._extension_registry[mod, func] == code)
self.assertTrue(copyreg._inverted_registry[code] == (mod, func))
# Shouldn't be in the cache.
- self.assertTrue(code not in copyreg._extension_cache)
+ self.assertNotIn(code, copyreg._extension_cache)
# Redundant registration should be OK.
copyreg.add_extension(mod, func, code) # shouldn't blow up
# Conflicting code.
@@ -81,7 +81,7 @@ class CopyRegTestCase(unittest.TestCase):
e.restore()
# Shouldn't be there anymore.
- self.assertTrue((mod, func) not in copyreg._extension_registry)
+ self.assertNotIn((mod, func), copyreg._extension_registry)
# The code *may* be in copyreg._extension_registry, though, if
# we happened to pick on a registered code. So don't check for
# that.
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py
index 4586b36deb..ae17c2b694 100644
--- a/Lib/test/test_cprofile.py
+++ b/Lib/test/test_cprofile.py
@@ -18,15 +18,16 @@ class CProfileTest(ProfileTest):
def test_bad_counter_during_dealloc(self):
import _lsprof
# Must use a file as StringIO doesn't trigger the bug.
- sys.stderr = open(TESTFN, 'w')
- try:
- obj = _lsprof.Profiler(lambda: int)
- obj.enable()
- obj = _lsprof.Profiler(1)
- obj.disable()
- finally:
- sys.stderr = sys.__stderr__
- unlink(TESTFN)
+ with open(TESTFN, 'w') as file:
+ sys.stderr = file
+ try:
+ obj = _lsprof.Profiler(lambda: int)
+ obj.enable()
+ obj = _lsprof.Profiler(1)
+ obj.disable()
+ finally:
+ sys.stderr = sys.__stderr__
+ unlink(TESTFN)
def test_main():
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index d553a78bbc..8ca1e62c4a 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2001,2002 Python Software Foundation
# csv package unit tests
@@ -483,10 +482,10 @@ hammer and saw"
def test_null(self):
self.writerAssertEqual([], '')
- def test_single(self):
+ def test_single_writer(self):
self.writerAssertEqual([['abc']], 'abc\r\n')
- def test_simple(self):
+ def test_simple_writer(self):
self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n')
def test_quotes(self):
@@ -511,6 +510,15 @@ class TestEscapedExcel(TestCsvBase):
def test_read_escape_fieldsep(self):
self.readerAssertEqual('abc\\,def\r\n', [['abc,def']])
+class TestDialectUnix(TestCsvBase):
+ dialect = 'unix'
+
+ def test_simple_writer(self):
+ self.writerAssertEqual([[1, 'abc def', 'abc']], '"1","abc def","abc"\n')
+
+ def test_simple_reader(self):
+ self.readerAssertEqual('"1","abc def","abc"\n', [['1', 'abc def', 'abc']])
+
class QuotedEscapedExcel(csv.excel):
quoting = csv.QUOTE_NONNUMERIC
escapechar = '\\'
@@ -530,8 +538,12 @@ class TestDictFields(unittest.TestCase):
def test_write_simple_dict(self):
with TemporaryFile("w+", newline='') as fileobj:
writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
+ writer.writeheader()
+ fileobj.seek(0)
+ self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n")
writer.writerow({"f1": 10, "f3": "abc"})
fileobj.seek(0)
+ fileobj.readline() # header
self.assertEqual(fileobj.read(), "10,,abc\r\n")
def test_write_no_fields(self):
@@ -806,7 +818,7 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back
# given that all three lines in sample3 are equal,
# I think that any character could have been 'guessed' as the
# delimiter, depending on dictionary order
- self.assertTrue(dialect.delimiter in self.sample3)
+ self.assertIn(dialect.delimiter, self.sample3)
dialect = sniffer.sniff(self.sample3, delimiters="?,")
self.assertEqual(dialect.delimiter, "?")
dialect = sniffer.sniff(self.sample3, delimiters="/,")
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index ea1e4d51b6..ded2aa93ab 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -1,3385 +1,42 @@
-"""Test date/time type.
-
-See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
-"""
-
-import sys
-import pickle
import unittest
-
-from operator import lt, le, gt, ge, eq, ne
-
-from test import support
-
-from datetime import MINYEAR, MAXYEAR
-from datetime import timedelta
-from datetime import tzinfo
-from datetime import time
-from datetime import date, datetime
-
-pickle_choices = [(pickle, pickle, proto) for proto in range(3)]
-assert len(pickle_choices) == 3
-
-# An arbitrary collection of objects of non-datetime types, for testing
-# mixed-type comparisons.
-OTHERSTUFF = (10, 10, 34.5, "abc", {}, [], ())
-
-
-#############################################################################
-# module tests
-
-class TestModule(unittest.TestCase):
-
- def test_constants(self):
- import datetime
- self.assertEqual(datetime.MINYEAR, 1)
- self.assertEqual(datetime.MAXYEAR, 9999)
-
-#############################################################################
-# tzinfo tests
-
-class FixedOffset(tzinfo):
- def __init__(self, offset, name, dstoffset=42):
- if isinstance(offset, int):
- offset = timedelta(minutes=offset)
- if isinstance(dstoffset, int):
- dstoffset = timedelta(minutes=dstoffset)
- self.__offset = offset
- self.__name = name
- self.__dstoffset = dstoffset
- def __repr__(self):
- return self.__name.lower()
- def utcoffset(self, dt):
- return self.__offset
- def tzname(self, dt):
- return self.__name
- def dst(self, dt):
- return self.__dstoffset
-
-class PicklableFixedOffset(FixedOffset):
- def __init__(self, offset=None, name=None, dstoffset=None):
- FixedOffset.__init__(self, offset, name, dstoffset)
-
-class TestTZInfo(unittest.TestCase):
-
- def test_non_abstractness(self):
- # In order to allow subclasses to get pickled, the C implementation
- # wasn't able to get away with having __init__ raise
- # NotImplementedError.
- useless = tzinfo()
- dt = datetime.max
- self.assertRaises(NotImplementedError, useless.tzname, dt)
- self.assertRaises(NotImplementedError, useless.utcoffset, dt)
- self.assertRaises(NotImplementedError, useless.dst, dt)
-
- def test_subclass_must_override(self):
- class NotEnough(tzinfo):
- def __init__(self, offset, name):
- self.__offset = offset
- self.__name = name
- self.assertTrue(issubclass(NotEnough, tzinfo))
- ne = NotEnough(3, "NotByALongShot")
- self.assertTrue(isinstance(ne, tzinfo))
-
- dt = datetime.now()
- self.assertRaises(NotImplementedError, ne.tzname, dt)
- self.assertRaises(NotImplementedError, ne.utcoffset, dt)
- self.assertRaises(NotImplementedError, ne.dst, dt)
-
- def test_normal(self):
- fo = FixedOffset(3, "Three")
- self.assertTrue(isinstance(fo, tzinfo))
- for dt in datetime.now(), None:
- self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
- self.assertEqual(fo.tzname(dt), "Three")
- self.assertEqual(fo.dst(dt), timedelta(minutes=42))
-
- def test_pickling_base(self):
- # There's no point to pickling tzinfo objects on their own (they
- # carry no data), but they need to be picklable anyway else
- # concrete subclasses can't be pickled.
- orig = tzinfo.__new__(tzinfo)
- self.assertTrue(type(orig) is tzinfo)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertTrue(type(derived) is tzinfo)
-
- def test_pickling_subclass(self):
- # Make sure we can pickle/unpickle an instance of a subclass.
- offset = timedelta(minutes=-300)
- orig = PicklableFixedOffset(offset, 'cookie')
- self.assertTrue(isinstance(orig, tzinfo))
- self.assertTrue(type(orig) is PicklableFixedOffset)
- self.assertEqual(orig.utcoffset(None), offset)
- self.assertEqual(orig.tzname(None), 'cookie')
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertTrue(isinstance(derived, tzinfo))
- self.assertTrue(type(derived) is PicklableFixedOffset)
- self.assertEqual(derived.utcoffset(None), offset)
- self.assertEqual(derived.tzname(None), 'cookie')
-
-#############################################################################
-# Base clase for testing a particular aspect of timedelta, time, date and
-# datetime comparisons.
-
-class HarmlessMixedComparison:
- # Test that __eq__ and __ne__ don't complain for mixed-type comparisons.
-
- # Subclasses must define 'theclass', and theclass(1, 1, 1) must be a
- # legit constructor.
-
- def test_harmless_mixed_comparison(self):
- me = self.theclass(1, 1, 1)
-
- self.assertFalse(me == ())
- self.assertTrue(me != ())
- self.assertFalse(() == me)
- self.assertTrue(() != me)
-
- self.assertTrue(me in [1, 20, [], me])
- self.assertFalse(me not in [1, 20, [], me])
-
- self.assertTrue([] in [me, 1, 20, []])
- self.assertFalse([] not in [me, 1, 20, []])
-
- def test_harmful_mixed_comparison(self):
- me = self.theclass(1, 1, 1)
-
- self.assertRaises(TypeError, lambda: me < ())
- self.assertRaises(TypeError, lambda: me <= ())
- self.assertRaises(TypeError, lambda: me > ())
- self.assertRaises(TypeError, lambda: me >= ())
-
- self.assertRaises(TypeError, lambda: () < me)
- self.assertRaises(TypeError, lambda: () <= me)
- self.assertRaises(TypeError, lambda: () > me)
- self.assertRaises(TypeError, lambda: () >= me)
-
-#############################################################################
-# timedelta tests
-
-class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
-
- theclass = timedelta
-
- def test_constructor(self):
- eq = self.assertEqual
- td = timedelta
-
- # Check keyword args to constructor
- eq(td(), td(weeks=0, days=0, hours=0, minutes=0, seconds=0,
- milliseconds=0, microseconds=0))
- eq(td(1), td(days=1))
- eq(td(0, 1), td(seconds=1))
- eq(td(0, 0, 1), td(microseconds=1))
- eq(td(weeks=1), td(days=7))
- eq(td(days=1), td(hours=24))
- eq(td(hours=1), td(minutes=60))
- eq(td(minutes=1), td(seconds=60))
- eq(td(seconds=1), td(milliseconds=1000))
- eq(td(milliseconds=1), td(microseconds=1000))
-
- # Check float args to constructor
- eq(td(weeks=1.0/7), td(days=1))
- eq(td(days=1.0/24), td(hours=1))
- eq(td(hours=1.0/60), td(minutes=1))
- eq(td(minutes=1.0/60), td(seconds=1))
- eq(td(seconds=0.001), td(milliseconds=1))
- eq(td(milliseconds=0.001), td(microseconds=1))
-
- def test_computations(self):
- eq = self.assertEqual
- td = timedelta
-
- a = td(7) # One week
- b = td(0, 60) # One minute
- c = td(0, 0, 1000) # One millisecond
- eq(a+b+c, td(7, 60, 1000))
- eq(a-b, td(6, 24*3600 - 60))
- eq(b.__rsub__(a), td(6, 24*3600 - 60))
- eq(-a, td(-7))
- eq(+a, td(7))
- eq(-b, td(-1, 24*3600 - 60))
- eq(-c, td(-1, 24*3600 - 1, 999000))
- eq(abs(a), a)
- eq(abs(-a), a)
- eq(td(6, 24*3600), a)
- eq(td(0, 0, 60*1000000), b)
- eq(a*10, td(70))
- eq(a*10, 10*a)
- eq(a*10, 10*a)
- eq(b*10, td(0, 600))
- eq(10*b, td(0, 600))
- eq(b*10, td(0, 600))
- eq(c*10, td(0, 0, 10000))
- eq(10*c, td(0, 0, 10000))
- eq(c*10, td(0, 0, 10000))
- eq(a*-1, -a)
- eq(b*-2, -b-b)
- eq(c*-2, -c+-c)
- eq(b*(60*24), (b*60)*24)
- eq(b*(60*24), (60*b)*24)
- eq(c*1000, td(0, 1))
- eq(1000*c, td(0, 1))
- eq(a//7, td(1))
- eq(b//10, td(0, 6))
- eq(c//1000, td(0, 0, 1))
- eq(a//10, td(0, 7*24*360))
- eq(a//3600000, td(0, 0, 7*24*1000))
-
- def test_disallowed_computations(self):
- a = timedelta(42)
-
- # Add/sub ints, longs, floats should be illegal
- for i in 1, 1, 1.0:
- self.assertRaises(TypeError, lambda: a+i)
- self.assertRaises(TypeError, lambda: a-i)
- self.assertRaises(TypeError, lambda: i+a)
- self.assertRaises(TypeError, lambda: i-a)
-
- # Mul/div by float isn't supported.
- x = 2.3
- self.assertRaises(TypeError, lambda: a*x)
- self.assertRaises(TypeError, lambda: x*a)
- self.assertRaises(TypeError, lambda: a/x)
- self.assertRaises(TypeError, lambda: x/a)
- self.assertRaises(TypeError, lambda: a // x)
- self.assertRaises(TypeError, lambda: x // a)
-
- # Division of int by timedelta doesn't make sense.
- # Division by zero doesn't make sense.
- for zero in 0, 0:
- self.assertRaises(TypeError, lambda: zero // a)
- self.assertRaises(ZeroDivisionError, lambda: a // zero)
- self.assertRaises(TypeError, lambda: a / '')
-
- def test_basic_attributes(self):
- days, seconds, us = 1, 7, 31
- td = timedelta(days, seconds, us)
- self.assertEqual(td.days, days)
- self.assertEqual(td.seconds, seconds)
- self.assertEqual(td.microseconds, us)
-
- def test_carries(self):
- t1 = timedelta(days=100,
- weeks=-7,
- hours=-24*(100-49),
- minutes=-3,
- seconds=12,
- microseconds=(3*60 - 12) * 1e6 + 1)
- t2 = timedelta(microseconds=1)
- self.assertEqual(t1, t2)
-
- def test_hash_equality(self):
- t1 = timedelta(days=100,
- weeks=-7,
- hours=-24*(100-49),
- minutes=-3,
- seconds=12,
- microseconds=(3*60 - 12) * 1000000)
- t2 = timedelta()
- self.assertEqual(hash(t1), hash(t2))
-
- t1 += timedelta(weeks=7)
- t2 += timedelta(days=7*7)
- self.assertEqual(t1, t2)
- self.assertEqual(hash(t1), hash(t2))
-
- d = {t1: 1}
- d[t2] = 2
- self.assertEqual(len(d), 1)
- self.assertEqual(d[t1], 2)
-
- def test_pickling(self):
- args = 12, 34, 56
- orig = timedelta(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_compare(self):
- t1 = timedelta(2, 3, 4)
- t2 = timedelta(2, 3, 4)
- self.assertEqual(t1, t2)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t1 >= t2)
- self.assertTrue(not t1 != t2)
- self.assertTrue(not t1 < t2)
- self.assertTrue(not t1 > t2)
-
- for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
- t2 = timedelta(*args) # this is larger than t1
- self.assertTrue(t1 < t2)
- self.assertTrue(t2 > t1)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t2 >= t1)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 != t1)
- self.assertTrue(not t1 == t2)
- self.assertTrue(not t2 == t1)
- self.assertTrue(not t1 > t2)
- self.assertTrue(not t2 < t1)
- self.assertTrue(not t1 >= t2)
- self.assertTrue(not t2 <= t1)
-
- for badarg in OTHERSTUFF:
- self.assertEqual(t1 == badarg, False)
- self.assertEqual(t1 != badarg, True)
- self.assertEqual(badarg == t1, False)
- self.assertEqual(badarg != t1, True)
-
- self.assertRaises(TypeError, lambda: t1 <= badarg)
- self.assertRaises(TypeError, lambda: t1 < badarg)
- self.assertRaises(TypeError, lambda: t1 > badarg)
- self.assertRaises(TypeError, lambda: t1 >= badarg)
- self.assertRaises(TypeError, lambda: badarg <= t1)
- self.assertRaises(TypeError, lambda: badarg < t1)
- self.assertRaises(TypeError, lambda: badarg > t1)
- self.assertRaises(TypeError, lambda: badarg >= t1)
-
- def test_str(self):
- td = timedelta
- eq = self.assertEqual
-
- eq(str(td(1)), "1 day, 0:00:00")
- eq(str(td(-1)), "-1 day, 0:00:00")
- eq(str(td(2)), "2 days, 0:00:00")
- eq(str(td(-2)), "-2 days, 0:00:00")
-
- eq(str(td(hours=12, minutes=58, seconds=59)), "12:58:59")
- eq(str(td(hours=2, minutes=3, seconds=4)), "2:03:04")
- eq(str(td(weeks=-30, hours=23, minutes=12, seconds=34)),
- "-210 days, 23:12:34")
-
- eq(str(td(milliseconds=1)), "0:00:00.001000")
- eq(str(td(microseconds=3)), "0:00:00.000003")
-
- eq(str(td(days=999999999, hours=23, minutes=59, seconds=59,
- microseconds=999999)),
- "999999999 days, 23:59:59.999999")
-
- def test_repr(self):
- name = 'datetime.' + self.theclass.__name__
- self.assertEqual(repr(self.theclass(1)),
- "%s(1)" % name)
- self.assertEqual(repr(self.theclass(10, 2)),
- "%s(10, 2)" % name)
- self.assertEqual(repr(self.theclass(-10, 2, 400000)),
- "%s(-10, 2, 400000)" % name)
-
- def test_roundtrip(self):
- for td in (timedelta(days=999999999, hours=23, minutes=59,
- seconds=59, microseconds=999999),
- timedelta(days=-999999999),
- timedelta(days=-999999999, seconds=1),
- timedelta(days=1, seconds=2, microseconds=3)):
-
- # Verify td -> string -> td identity.
- s = repr(td)
- self.assertTrue(s.startswith('datetime.'))
- s = s[9:]
- td2 = eval(s)
- self.assertEqual(td, td2)
-
- # Verify identity via reconstructing from pieces.
- td2 = timedelta(td.days, td.seconds, td.microseconds)
- self.assertEqual(td, td2)
-
- def test_resolution_info(self):
- self.assertTrue(isinstance(timedelta.min, timedelta))
- self.assertTrue(isinstance(timedelta.max, timedelta))
- self.assertTrue(isinstance(timedelta.resolution, timedelta))
- self.assertTrue(timedelta.max > timedelta.min)
- self.assertEqual(timedelta.min, timedelta(-999999999))
- self.assertEqual(timedelta.max, timedelta(999999999, 24*3600-1, 1e6-1))
- self.assertEqual(timedelta.resolution, timedelta(0, 0, 1))
-
- def test_overflow(self):
- tiny = timedelta.resolution
-
- td = timedelta.min + tiny
- td -= tiny # no problem
- self.assertRaises(OverflowError, td.__sub__, tiny)
- self.assertRaises(OverflowError, td.__add__, -tiny)
-
- td = timedelta.max - tiny
- td += tiny # no problem
- self.assertRaises(OverflowError, td.__add__, tiny)
- self.assertRaises(OverflowError, td.__sub__, -tiny)
-
- self.assertRaises(OverflowError, lambda: -timedelta.max)
-
- def test_microsecond_rounding(self):
- td = timedelta
- eq = self.assertEqual
-
- # Single-field rounding.
- eq(td(milliseconds=0.4/1000), td(0)) # rounds to 0
- eq(td(milliseconds=-0.4/1000), td(0)) # rounds to 0
- eq(td(milliseconds=0.6/1000), td(microseconds=1))
- eq(td(milliseconds=-0.6/1000), td(microseconds=-1))
-
- # Rounding due to contributions from more than one field.
- us_per_hour = 3600e6
- us_per_day = us_per_hour * 24
- eq(td(days=.4/us_per_day), td(0))
- eq(td(hours=.2/us_per_hour), td(0))
- eq(td(days=.4/us_per_day, hours=.2/us_per_hour), td(microseconds=1))
-
- eq(td(days=-.4/us_per_day), td(0))
- eq(td(hours=-.2/us_per_hour), td(0))
- eq(td(days=-.4/us_per_day, hours=-.2/us_per_hour), td(microseconds=-1))
-
- def test_massive_normalization(self):
- td = timedelta(microseconds=-1)
- self.assertEqual((td.days, td.seconds, td.microseconds),
- (-1, 24*3600-1, 999999))
-
- def test_bool(self):
- self.assertTrue(timedelta(1))
- self.assertTrue(timedelta(0, 1))
- self.assertTrue(timedelta(0, 0, 1))
- self.assertTrue(timedelta(microseconds=1))
- self.assertTrue(not timedelta(0))
-
- def test_subclass_timedelta(self):
-
- class T(timedelta):
- @staticmethod
- def from_td(td):
- return T(td.days, td.seconds, td.microseconds)
-
- def as_hours(self):
- sum = (self.days * 24 +
- self.seconds / 3600.0 +
- self.microseconds / 3600e6)
- return round(sum)
-
- t1 = T(days=1)
- self.assertTrue(type(t1) is T)
- self.assertEqual(t1.as_hours(), 24)
-
- t2 = T(days=-1, seconds=-3600)
- self.assertTrue(type(t2) is T)
- self.assertEqual(t2.as_hours(), -25)
-
- t3 = t1 + t2
- self.assertTrue(type(t3) is timedelta)
- t4 = T.from_td(t3)
- self.assertTrue(type(t4) is T)
- self.assertEqual(t3.days, t4.days)
- self.assertEqual(t3.seconds, t4.seconds)
- self.assertEqual(t3.microseconds, t4.microseconds)
- self.assertEqual(str(t3), str(t4))
- self.assertEqual(t4.as_hours(), -1)
-
-#############################################################################
-# date tests
-
-class TestDateOnly(unittest.TestCase):
- # Tests here won't pass if also run on datetime objects, so don't
- # subclass this to test datetimes too.
-
- def test_delta_non_days_ignored(self):
- dt = date(2000, 1, 2)
- delta = timedelta(days=1, hours=2, minutes=3, seconds=4,
- microseconds=5)
- days = timedelta(delta.days)
- self.assertEqual(days, timedelta(1))
-
- dt2 = dt + delta
- self.assertEqual(dt2, dt + days)
-
- dt2 = delta + dt
- self.assertEqual(dt2, dt + days)
-
- dt2 = dt - delta
- self.assertEqual(dt2, dt - days)
-
- delta = -delta
- days = timedelta(delta.days)
- self.assertEqual(days, timedelta(-2))
-
- dt2 = dt + delta
- self.assertEqual(dt2, dt + days)
-
- dt2 = delta + dt
- self.assertEqual(dt2, dt + days)
-
- dt2 = dt - delta
- self.assertEqual(dt2, dt - days)
-
-class SubclassDate(date):
- sub_var = 1
-
-class TestDate(HarmlessMixedComparison, unittest.TestCase):
- # Tests here should pass for both dates and datetimes, except for a
- # few tests that TestDateTime overrides.
-
- theclass = date
-
- def test_basic_attributes(self):
- dt = self.theclass(2002, 3, 1)
- self.assertEqual(dt.year, 2002)
- self.assertEqual(dt.month, 3)
- self.assertEqual(dt.day, 1)
-
- def test_roundtrip(self):
- for dt in (self.theclass(1, 2, 3),
- self.theclass.today()):
- # Verify dt -> string -> date identity.
- s = repr(dt)
- self.assertTrue(s.startswith('datetime.'))
- s = s[9:]
- dt2 = eval(s)
- self.assertEqual(dt, dt2)
-
- # Verify identity via reconstructing from pieces.
- dt2 = self.theclass(dt.year, dt.month, dt.day)
- self.assertEqual(dt, dt2)
-
- def test_ordinal_conversions(self):
- # Check some fixed values.
- for y, m, d, n in [(1, 1, 1, 1), # calendar origin
- (1, 12, 31, 365),
- (2, 1, 1, 366),
- # first example from "Calendrical Calculations"
- (1945, 11, 12, 710347)]:
- d = self.theclass(y, m, d)
- self.assertEqual(n, d.toordinal())
- fromord = self.theclass.fromordinal(n)
- self.assertEqual(d, fromord)
- if hasattr(fromord, "hour"):
- # if we're checking something fancier than a date, verify
- # the extra fields have been zeroed out
- self.assertEqual(fromord.hour, 0)
- self.assertEqual(fromord.minute, 0)
- self.assertEqual(fromord.second, 0)
- self.assertEqual(fromord.microsecond, 0)
-
- # Check first and last days of year spottily across the whole
- # range of years supported.
- for year in range(MINYEAR, MAXYEAR+1, 7):
- # Verify (year, 1, 1) -> ordinal -> y, m, d is identity.
- d = self.theclass(year, 1, 1)
- n = d.toordinal()
- d2 = self.theclass.fromordinal(n)
- self.assertEqual(d, d2)
- # Verify that moving back a day gets to the end of year-1.
- if year > 1:
- d = self.theclass.fromordinal(n-1)
- d2 = self.theclass(year-1, 12, 31)
- self.assertEqual(d, d2)
- self.assertEqual(d2.toordinal(), n-1)
-
- # Test every day in a leap-year and a non-leap year.
- dim = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- for year, isleap in (2000, True), (2002, False):
- n = self.theclass(year, 1, 1).toordinal()
- for month, maxday in zip(range(1, 13), dim):
- if month == 2 and isleap:
- maxday += 1
- for day in range(1, maxday+1):
- d = self.theclass(year, month, day)
- self.assertEqual(d.toordinal(), n)
- self.assertEqual(d, self.theclass.fromordinal(n))
- n += 1
-
- def test_extreme_ordinals(self):
- a = self.theclass.min
- a = self.theclass(a.year, a.month, a.day) # get rid of time parts
- aord = a.toordinal()
- b = a.fromordinal(aord)
- self.assertEqual(a, b)
-
- self.assertRaises(ValueError, lambda: a.fromordinal(aord - 1))
-
- b = a + timedelta(days=1)
- self.assertEqual(b.toordinal(), aord + 1)
- self.assertEqual(b, self.theclass.fromordinal(aord + 1))
-
- a = self.theclass.max
- a = self.theclass(a.year, a.month, a.day) # get rid of time parts
- aord = a.toordinal()
- b = a.fromordinal(aord)
- self.assertEqual(a, b)
-
- self.assertRaises(ValueError, lambda: a.fromordinal(aord + 1))
-
- b = a - timedelta(days=1)
- self.assertEqual(b.toordinal(), aord - 1)
- self.assertEqual(b, self.theclass.fromordinal(aord - 1))
-
- def test_bad_constructor_arguments(self):
- # bad years
- self.theclass(MINYEAR, 1, 1) # no exception
- self.theclass(MAXYEAR, 1, 1) # no exception
- self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
- self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
- # bad months
- self.theclass(2000, 1, 1) # no exception
- self.theclass(2000, 12, 1) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
- self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
- # bad days
- self.theclass(2000, 2, 29) # no exception
- self.theclass(2004, 2, 29) # no exception
- self.theclass(2400, 2, 29) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
- self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
- self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
- self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 32)
-
- def test_hash_equality(self):
- d = self.theclass(2000, 12, 31)
- # same thing
- e = self.theclass(2000, 12, 31)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- d = self.theclass(2001, 1, 1)
- # same thing
- e = self.theclass(2001, 1, 1)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- def test_computations(self):
- a = self.theclass(2002, 1, 31)
- b = self.theclass(1956, 1, 31)
-
- diff = a-b
- self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4)))
- self.assertEqual(diff.seconds, 0)
- self.assertEqual(diff.microseconds, 0)
-
- day = timedelta(1)
- week = timedelta(7)
- a = self.theclass(2002, 3, 2)
- self.assertEqual(a + day, self.theclass(2002, 3, 3))
- self.assertEqual(day + a, self.theclass(2002, 3, 3))
- self.assertEqual(a - day, self.theclass(2002, 3, 1))
- self.assertEqual(-day + a, self.theclass(2002, 3, 1))
- self.assertEqual(a + week, self.theclass(2002, 3, 9))
- self.assertEqual(a - week, self.theclass(2002, 2, 23))
- self.assertEqual(a + 52*week, self.theclass(2003, 3, 1))
- self.assertEqual(a - 52*week, self.theclass(2001, 3, 3))
- self.assertEqual((a + week) - a, week)
- self.assertEqual((a + day) - a, day)
- self.assertEqual((a - week) - a, -week)
- self.assertEqual((a - day) - a, -day)
- self.assertEqual(a - (a + week), -week)
- self.assertEqual(a - (a + day), -day)
- self.assertEqual(a - (a - week), week)
- self.assertEqual(a - (a - day), day)
-
- # Add/sub ints, longs, floats should be illegal
- for i in 1, 1, 1.0:
- self.assertRaises(TypeError, lambda: a+i)
- self.assertRaises(TypeError, lambda: a-i)
- self.assertRaises(TypeError, lambda: i+a)
- self.assertRaises(TypeError, lambda: i-a)
-
- # delta - date is senseless.
- self.assertRaises(TypeError, lambda: day - a)
- # mixing date and (delta or date) via * or // is senseless
- self.assertRaises(TypeError, lambda: day * a)
- self.assertRaises(TypeError, lambda: a * day)
- self.assertRaises(TypeError, lambda: day // a)
- self.assertRaises(TypeError, lambda: a // day)
- self.assertRaises(TypeError, lambda: a * a)
- self.assertRaises(TypeError, lambda: a // a)
- # date + date is senseless
- self.assertRaises(TypeError, lambda: a + a)
-
- def test_overflow(self):
- tiny = self.theclass.resolution
-
- for delta in [tiny, timedelta(1), timedelta(2)]:
- dt = self.theclass.min + delta
- dt -= delta # no problem
- self.assertRaises(OverflowError, dt.__sub__, delta)
- self.assertRaises(OverflowError, dt.__add__, -delta)
-
- dt = self.theclass.max - delta
- dt += delta # no problem
- self.assertRaises(OverflowError, dt.__add__, delta)
- self.assertRaises(OverflowError, dt.__sub__, -delta)
-
- def test_fromtimestamp(self):
- import time
-
- # Try an arbitrary fixed value.
- year, month, day = 1999, 9, 19
- ts = time.mktime((year, month, day, 0, 0, 0, 0, 0, -1))
- d = self.theclass.fromtimestamp(ts)
- self.assertEqual(d.year, year)
- self.assertEqual(d.month, month)
- self.assertEqual(d.day, day)
-
- def test_insane_fromtimestamp(self):
- # It's possible that some platform maps time_t to double,
- # and that this test will fail there. This test should
- # exempt such platforms (provided they return reasonable
- # results!).
- for insane in -1e200, 1e200:
- self.assertRaises(ValueError, self.theclass.fromtimestamp,
- insane)
-
- def test_today(self):
- import time
-
- # We claim that today() is like fromtimestamp(time.time()), so
- # prove it.
- for dummy in range(3):
- today = self.theclass.today()
- ts = time.time()
- todayagain = self.theclass.fromtimestamp(ts)
- if today == todayagain:
- break
- # There are several legit reasons that could fail:
- # 1. It recently became midnight, between the today() and the
- # time() calls.
- # 2. The platform time() has such fine resolution that we'll
- # never get the same value twice.
- # 3. The platform time() has poor resolution, and we just
- # happened to call today() right before a resolution quantum
- # boundary.
- # 4. The system clock got fiddled between calls.
- # In any case, wait a little while and try again.
- time.sleep(0.1)
-
- # It worked or it didn't. If it didn't, assume it's reason #2, and
- # let the test pass if they're within half a second of each other.
- self.assertTrue(today == todayagain or
- abs(todayagain - today) < timedelta(seconds=0.5))
-
- def test_weekday(self):
- for i in range(7):
- # March 4, 2002 is a Monday
- self.assertEqual(self.theclass(2002, 3, 4+i).weekday(), i)
- self.assertEqual(self.theclass(2002, 3, 4+i).isoweekday(), i+1)
- # January 2, 1956 is a Monday
- self.assertEqual(self.theclass(1956, 1, 2+i).weekday(), i)
- self.assertEqual(self.theclass(1956, 1, 2+i).isoweekday(), i+1)
-
- def test_isocalendar(self):
- # Check examples from
- # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
- for i in range(7):
- d = self.theclass(2003, 12, 22+i)
- self.assertEqual(d.isocalendar(), (2003, 52, i+1))
- d = self.theclass(2003, 12, 29) + timedelta(i)
- self.assertEqual(d.isocalendar(), (2004, 1, i+1))
- d = self.theclass(2004, 1, 5+i)
- self.assertEqual(d.isocalendar(), (2004, 2, i+1))
- d = self.theclass(2009, 12, 21+i)
- self.assertEqual(d.isocalendar(), (2009, 52, i+1))
- d = self.theclass(2009, 12, 28) + timedelta(i)
- self.assertEqual(d.isocalendar(), (2009, 53, i+1))
- d = self.theclass(2010, 1, 4+i)
- self.assertEqual(d.isocalendar(), (2010, 1, i+1))
-
- def test_iso_long_years(self):
- # Calculate long ISO years and compare to table from
- # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
- ISO_LONG_YEARS_TABLE = """
- 4 32 60 88
- 9 37 65 93
- 15 43 71 99
- 20 48 76
- 26 54 82
-
- 105 133 161 189
- 111 139 167 195
- 116 144 172
- 122 150 178
- 128 156 184
-
- 201 229 257 285
- 207 235 263 291
- 212 240 268 296
- 218 246 274
- 224 252 280
-
- 303 331 359 387
- 308 336 364 392
- 314 342 370 398
- 320 348 376
- 325 353 381
- """
- iso_long_years = sorted(map(int, ISO_LONG_YEARS_TABLE.split()))
- L = []
- for i in range(400):
- d = self.theclass(2000+i, 12, 31)
- d1 = self.theclass(1600+i, 12, 31)
- self.assertEqual(d.isocalendar()[1:], d1.isocalendar()[1:])
- if d.isocalendar()[1] == 53:
- L.append(i)
- self.assertEqual(L, iso_long_years)
-
- def test_isoformat(self):
- t = self.theclass(2, 3, 2)
- self.assertEqual(t.isoformat(), "0002-03-02")
-
- def test_ctime(self):
- t = self.theclass(2002, 3, 2)
- self.assertEqual(t.ctime(), "Sat Mar 2 00:00:00 2002")
-
- def test_strftime(self):
- t = self.theclass(2005, 3, 2)
- self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05")
- self.assertEqual(t.strftime(""), "") # SF bug #761337
- self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784
-
- self.assertRaises(TypeError, t.strftime) # needs an arg
- self.assertRaises(TypeError, t.strftime, "one", "two") # too many args
- self.assertRaises(TypeError, t.strftime, 42) # arg wrong type
-
- # test that unicode input is allowed (issue 2782)
- self.assertEqual(t.strftime("%m"), "03")
-
- # A naive object replaces %z and %Z w/ empty strings.
- self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
-
- #make sure that invalid format specifiers are handled correctly
- #self.assertRaises(ValueError, t.strftime, "%e")
- #self.assertRaises(ValueError, t.strftime, "%")
- #self.assertRaises(ValueError, t.strftime, "%#")
-
- #oh well, some systems just ignore those invalid ones.
- #at least, excercise them to make sure that no crashes
- #are generated
- for f in ["%e", "%", "%#"]:
- try:
- t.strftime(f)
- except ValueError:
- pass
-
- #check that this standard extension works
- t.strftime("%f")
-
-
- def test_format(self):
- dt = self.theclass(2007, 9, 10)
- self.assertEqual(dt.__format__(''), str(dt))
-
- # check that a derived class's __str__() gets called
- class A(self.theclass):
- def __str__(self):
- return 'A'
- a = A(2007, 9, 10)
- self.assertEqual(a.__format__(''), 'A')
-
- # check that a derived class's strftime gets called
- class B(self.theclass):
- def strftime(self, format_spec):
- return 'B'
- b = B(2007, 9, 10)
- self.assertEqual(b.__format__(''), str(dt))
-
- for fmt in ["m:%m d:%d y:%y",
- "m:%m d:%d y:%y H:%H M:%M S:%S",
- "%z %Z",
- ]:
- self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
- self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
- self.assertEqual(b.__format__(fmt), 'B')
-
- def test_resolution_info(self):
- self.assertTrue(isinstance(self.theclass.min, self.theclass))
- self.assertTrue(isinstance(self.theclass.max, self.theclass))
- self.assertTrue(isinstance(self.theclass.resolution, timedelta))
- self.assertTrue(self.theclass.max > self.theclass.min)
-
- def test_extreme_timedelta(self):
- big = self.theclass.max - self.theclass.min
- # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds
- n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds
- # n == 315537897599999999 ~= 2**58.13
- justasbig = timedelta(0, 0, n)
- self.assertEqual(big, justasbig)
- self.assertEqual(self.theclass.min + big, self.theclass.max)
- self.assertEqual(self.theclass.max - big, self.theclass.min)
-
- def test_timetuple(self):
- for i in range(7):
- # January 2, 1956 is a Monday (0)
- d = self.theclass(1956, 1, 2+i)
- t = d.timetuple()
- self.assertEqual(t, (1956, 1, 2+i, 0, 0, 0, i, 2+i, -1))
- # February 1, 1956 is a Wednesday (2)
- d = self.theclass(1956, 2, 1+i)
- t = d.timetuple()
- self.assertEqual(t, (1956, 2, 1+i, 0, 0, 0, (2+i)%7, 32+i, -1))
- # March 1, 1956 is a Thursday (3), and is the 31+29+1 = 61st day
- # of the year.
- d = self.theclass(1956, 3, 1+i)
- t = d.timetuple()
- self.assertEqual(t, (1956, 3, 1+i, 0, 0, 0, (3+i)%7, 61+i, -1))
- self.assertEqual(t.tm_year, 1956)
- self.assertEqual(t.tm_mon, 3)
- self.assertEqual(t.tm_mday, 1+i)
- self.assertEqual(t.tm_hour, 0)
- self.assertEqual(t.tm_min, 0)
- self.assertEqual(t.tm_sec, 0)
- self.assertEqual(t.tm_wday, (3+i)%7)
- self.assertEqual(t.tm_yday, 61+i)
- self.assertEqual(t.tm_isdst, -1)
-
- def test_pickling(self):
- args = 6, 7, 23
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_compare(self):
- t1 = self.theclass(2, 3, 4)
- t2 = self.theclass(2, 3, 4)
- self.assertEqual(t1, t2)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t1 >= t2)
- self.assertTrue(not t1 != t2)
- self.assertTrue(not t1 < t2)
- self.assertTrue(not t1 > t2)
-
- for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
- t2 = self.theclass(*args) # this is larger than t1
- self.assertTrue(t1 < t2)
- self.assertTrue(t2 > t1)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t2 >= t1)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 != t1)
- self.assertTrue(not t1 == t2)
- self.assertTrue(not t2 == t1)
- self.assertTrue(not t1 > t2)
- self.assertTrue(not t2 < t1)
- self.assertTrue(not t1 >= t2)
- self.assertTrue(not t2 <= t1)
-
- for badarg in OTHERSTUFF:
- self.assertEqual(t1 == badarg, False)
- self.assertEqual(t1 != badarg, True)
- self.assertEqual(badarg == t1, False)
- self.assertEqual(badarg != t1, True)
-
- self.assertRaises(TypeError, lambda: t1 < badarg)
- self.assertRaises(TypeError, lambda: t1 > badarg)
- self.assertRaises(TypeError, lambda: t1 >= badarg)
- self.assertRaises(TypeError, lambda: badarg <= t1)
- self.assertRaises(TypeError, lambda: badarg < t1)
- self.assertRaises(TypeError, lambda: badarg > t1)
- self.assertRaises(TypeError, lambda: badarg >= t1)
-
- def test_mixed_compare(self):
- our = self.theclass(2000, 4, 5)
-
- # Our class can be compared for equality to other classes
- self.assertEqual(our == 1, False)
- self.assertEqual(1 == our, False)
- self.assertEqual(our != 1, True)
- self.assertEqual(1 != our, True)
-
- # But the ordering is undefined
- self.assertRaises(TypeError, lambda: our < 1)
- self.assertRaises(TypeError, lambda: 1 < our)
-
- # Repeat those tests with a different class
-
- class SomeClass:
- pass
-
- their = SomeClass()
- self.assertEqual(our == their, False)
- self.assertEqual(their == our, False)
- self.assertEqual(our != their, True)
- self.assertEqual(their != our, True)
- self.assertRaises(TypeError, lambda: our < their)
- self.assertRaises(TypeError, lambda: their < our)
-
- # However, if the other class explicitly defines ordering
- # relative to our class, it is allowed to do so
-
- class LargerThanAnything:
- def __lt__(self, other):
- return False
- def __le__(self, other):
- return isinstance(other, LargerThanAnything)
- def __eq__(self, other):
- return isinstance(other, LargerThanAnything)
- def __ne__(self, other):
- return not isinstance(other, LargerThanAnything)
- def __gt__(self, other):
- return not isinstance(other, LargerThanAnything)
- def __ge__(self, other):
- return True
-
- their = LargerThanAnything()
- self.assertEqual(our == their, False)
- self.assertEqual(their == our, False)
- self.assertEqual(our != their, True)
- self.assertEqual(their != our, True)
- self.assertEqual(our < their, True)
- self.assertEqual(their < our, False)
-
- def test_bool(self):
- # All dates are considered true.
- self.assertTrue(self.theclass.min)
- self.assertTrue(self.theclass.max)
-
- def test_strftime_out_of_range(self):
- # For nasty technical reasons, we can't handle years before 1900.
- cls = self.theclass
- self.assertEqual(cls(1900, 1, 1).strftime("%Y"), "1900")
- for y in 1, 49, 51, 99, 100, 1000, 1899:
- self.assertRaises(ValueError, cls(y, 1, 1).strftime, "%Y")
-
- def test_replace(self):
- cls = self.theclass
- args = [1, 2, 3]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("year", 2),
- ("month", 3),
- ("day", 4)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Out of bounds.
- base = cls(2000, 2, 29)
- self.assertRaises(ValueError, base.replace, year=2001)
-
- def test_subclass_date(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.year + self.month
-
- args = 2003, 4, 14
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.toordinal(), dt2.toordinal())
- self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month - 7)
-
- def test_pickling_subclass_date(self):
-
- args = 6, 7, 23
- orig = SubclassDate(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_backdoor_resistance(self):
- # For fast unpickling, the constructor accepts a pickle byte string.
- # This is a low-overhead backdoor. A user can (by intent or
- # mistake) pass a string directly, which (if it's the right length)
- # will get treated like a pickle, and bypass the normal sanity
- # checks in the constructor. This can create insane objects.
- # The constructor doesn't want to burn the time to validate all
- # fields, but does check the month field. This stops, e.g.,
- # datetime.datetime('1995-03-25') from yielding an insane object.
- base = b'1995-03-25'
- if not issubclass(self.theclass, datetime):
- base = base[:4]
- for month_byte in b'9', b'\0', b'\r', b'\xff':
- self.assertRaises(TypeError, self.theclass,
- base[:2] + month_byte + base[3:])
- for ord_byte in range(1, 13):
- # This shouldn't blow up because of the month byte alone. If
- # the implementation changes to do more-careful checking, it may
- # blow up because other fields are insane.
- self.theclass(base[:2] + bytes([ord_byte]) + base[3:])
-
-#############################################################################
-# datetime tests
-
-class SubclassDatetime(datetime):
- sub_var = 1
-
-class TestDateTime(TestDate):
-
- theclass = datetime
-
- def test_basic_attributes(self):
- dt = self.theclass(2002, 3, 1, 12, 0)
- self.assertEqual(dt.year, 2002)
- self.assertEqual(dt.month, 3)
- self.assertEqual(dt.day, 1)
- self.assertEqual(dt.hour, 12)
- self.assertEqual(dt.minute, 0)
- self.assertEqual(dt.second, 0)
- self.assertEqual(dt.microsecond, 0)
-
- def test_basic_attributes_nonzero(self):
- # Make sure all attributes are non-zero so bugs in
- # bit-shifting access show up.
- dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000)
- self.assertEqual(dt.year, 2002)
- self.assertEqual(dt.month, 3)
- self.assertEqual(dt.day, 1)
- self.assertEqual(dt.hour, 12)
- self.assertEqual(dt.minute, 59)
- self.assertEqual(dt.second, 59)
- self.assertEqual(dt.microsecond, 8000)
-
- def test_roundtrip(self):
- for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7),
- self.theclass.now()):
- # Verify dt -> string -> datetime identity.
- s = repr(dt)
- self.assertTrue(s.startswith('datetime.'))
- s = s[9:]
- dt2 = eval(s)
- self.assertEqual(dt, dt2)
-
- # Verify identity via reconstructing from pieces.
- dt2 = self.theclass(dt.year, dt.month, dt.day,
- dt.hour, dt.minute, dt.second,
- dt.microsecond)
- self.assertEqual(dt, dt2)
-
- def test_isoformat(self):
- t = self.theclass(2, 3, 2, 4, 5, 1, 123)
- self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
- # str is ISO format with the separator forced to a blank.
- self.assertEqual(str(t), "0002-03-02 04:05:01.000123")
-
- t = self.theclass(2, 3, 2)
- self.assertEqual(t.isoformat(), "0002-03-02T00:00:00")
- self.assertEqual(t.isoformat('T'), "0002-03-02T00:00:00")
- self.assertEqual(t.isoformat(' '), "0002-03-02 00:00:00")
- # str is ISO format with the separator forced to a blank.
- self.assertEqual(str(t), "0002-03-02 00:00:00")
-
- def test_format(self):
- dt = self.theclass(2007, 9, 10, 4, 5, 1, 123)
- self.assertEqual(dt.__format__(''), str(dt))
-
- # check that a derived class's __str__() gets called
- class A(self.theclass):
- def __str__(self):
- return 'A'
- a = A(2007, 9, 10, 4, 5, 1, 123)
- self.assertEqual(a.__format__(''), 'A')
-
- # check that a derived class's strftime gets called
- class B(self.theclass):
- def strftime(self, format_spec):
- return 'B'
- b = B(2007, 9, 10, 4, 5, 1, 123)
- self.assertEqual(b.__format__(''), str(dt))
-
- for fmt in ["m:%m d:%d y:%y",
- "m:%m d:%d y:%y H:%H M:%M S:%S",
- "%z %Z",
- ]:
- self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
- self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
- self.assertEqual(b.__format__(fmt), 'B')
-
- def test_more_ctime(self):
- # Test fields that TestDate doesn't touch.
- import time
-
- t = self.theclass(2002, 3, 2, 18, 3, 5, 123)
- self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002")
- # Oops! The next line fails on Win2K under MSVC 6, so it's commented
- # out. The difference is that t.ctime() produces " 2" for the day,
- # but platform ctime() produces "02" for the day. According to
- # C99, t.ctime() is correct here.
- # self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
-
- # So test a case where that difference doesn't matter.
- t = self.theclass(2002, 3, 22, 18, 3, 5, 123)
- self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
-
- def test_tz_independent_comparing(self):
- dt1 = self.theclass(2002, 3, 1, 9, 0, 0)
- dt2 = self.theclass(2002, 3, 1, 10, 0, 0)
- dt3 = self.theclass(2002, 3, 1, 9, 0, 0)
- self.assertEqual(dt1, dt3)
- self.assertTrue(dt2 > dt3)
-
- # Make sure comparison doesn't forget microseconds, and isn't done
- # via comparing a float timestamp (an IEEE double doesn't have enough
- # precision to span microsecond resolution across years 1 thru 9999,
- # so comparing via timestamp necessarily calls some distinct values
- # equal).
- dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998)
- us = timedelta(microseconds=1)
- dt2 = dt1 + us
- self.assertEqual(dt2 - dt1, us)
- self.assertTrue(dt1 < dt2)
-
- def test_strftime_with_bad_tzname_replace(self):
- # verify ok if tzinfo.tzname().replace() returns a non-string
- class MyTzInfo(FixedOffset):
- def tzname(self, dt):
- class MyStr(str):
- def replace(self, *args):
- return None
- return MyStr('name')
- t = self.theclass(2005, 3, 2, 0, 0, 0, 0, MyTzInfo(3, 'name'))
- self.assertRaises(TypeError, t.strftime, '%Z')
-
- def test_bad_constructor_arguments(self):
- # bad years
- self.theclass(MINYEAR, 1, 1) # no exception
- self.theclass(MAXYEAR, 1, 1) # no exception
- self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
- self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
- # bad months
- self.theclass(2000, 1, 1) # no exception
- self.theclass(2000, 12, 1) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
- self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
- # bad days
- self.theclass(2000, 2, 29) # no exception
- self.theclass(2004, 2, 29) # no exception
- self.theclass(2400, 2, 29) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
- self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
- self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
- self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 32)
- # bad hours
- self.theclass(2000, 1, 31, 0) # no exception
- self.theclass(2000, 1, 31, 23) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, -1)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 24)
- # bad minutes
- self.theclass(2000, 1, 31, 23, 0) # no exception
- self.theclass(2000, 1, 31, 23, 59) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, -1)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 60)
- # bad seconds
- self.theclass(2000, 1, 31, 23, 59, 0) # no exception
- self.theclass(2000, 1, 31, 23, 59, 59) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, -1)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, 60)
- # bad microseconds
- self.theclass(2000, 1, 31, 23, 59, 59, 0) # no exception
- self.theclass(2000, 1, 31, 23, 59, 59, 999999) # no exception
- self.assertRaises(ValueError, self.theclass,
- 2000, 1, 31, 23, 59, 59, -1)
- self.assertRaises(ValueError, self.theclass,
- 2000, 1, 31, 23, 59, 59,
- 1000000)
-
- def test_hash_equality(self):
- d = self.theclass(2000, 12, 31, 23, 30, 17)
- e = self.theclass(2000, 12, 31, 23, 30, 17)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- d = self.theclass(2001, 1, 1, 0, 5, 17)
- e = self.theclass(2001, 1, 1, 0, 5, 17)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- def test_computations(self):
- a = self.theclass(2002, 1, 31)
- b = self.theclass(1956, 1, 31)
- diff = a-b
- self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4)))
- self.assertEqual(diff.seconds, 0)
- self.assertEqual(diff.microseconds, 0)
- a = self.theclass(2002, 3, 2, 17, 6)
- millisec = timedelta(0, 0, 1000)
- hour = timedelta(0, 3600)
- day = timedelta(1)
- week = timedelta(7)
- self.assertEqual(a + hour, self.theclass(2002, 3, 2, 18, 6))
- self.assertEqual(hour + a, self.theclass(2002, 3, 2, 18, 6))
- self.assertEqual(a + 10*hour, self.theclass(2002, 3, 3, 3, 6))
- self.assertEqual(a - hour, self.theclass(2002, 3, 2, 16, 6))
- self.assertEqual(-hour + a, self.theclass(2002, 3, 2, 16, 6))
- self.assertEqual(a - hour, a + -hour)
- self.assertEqual(a - 20*hour, self.theclass(2002, 3, 1, 21, 6))
- self.assertEqual(a + day, self.theclass(2002, 3, 3, 17, 6))
- self.assertEqual(a - day, self.theclass(2002, 3, 1, 17, 6))
- self.assertEqual(a + week, self.theclass(2002, 3, 9, 17, 6))
- self.assertEqual(a - week, self.theclass(2002, 2, 23, 17, 6))
- self.assertEqual(a + 52*week, self.theclass(2003, 3, 1, 17, 6))
- self.assertEqual(a - 52*week, self.theclass(2001, 3, 3, 17, 6))
- self.assertEqual((a + week) - a, week)
- self.assertEqual((a + day) - a, day)
- self.assertEqual((a + hour) - a, hour)
- self.assertEqual((a + millisec) - a, millisec)
- self.assertEqual((a - week) - a, -week)
- self.assertEqual((a - day) - a, -day)
- self.assertEqual((a - hour) - a, -hour)
- self.assertEqual((a - millisec) - a, -millisec)
- self.assertEqual(a - (a + week), -week)
- self.assertEqual(a - (a + day), -day)
- self.assertEqual(a - (a + hour), -hour)
- self.assertEqual(a - (a + millisec), -millisec)
- self.assertEqual(a - (a - week), week)
- self.assertEqual(a - (a - day), day)
- self.assertEqual(a - (a - hour), hour)
- self.assertEqual(a - (a - millisec), millisec)
- self.assertEqual(a + (week + day + hour + millisec),
- self.theclass(2002, 3, 10, 18, 6, 0, 1000))
- self.assertEqual(a + (week + day + hour + millisec),
- (((a + week) + day) + hour) + millisec)
- self.assertEqual(a - (week + day + hour + millisec),
- self.theclass(2002, 2, 22, 16, 5, 59, 999000))
- self.assertEqual(a - (week + day + hour + millisec),
- (((a - week) - day) - hour) - millisec)
- # Add/sub ints, longs, floats should be illegal
- for i in 1, 1, 1.0:
- self.assertRaises(TypeError, lambda: a+i)
- self.assertRaises(TypeError, lambda: a-i)
- self.assertRaises(TypeError, lambda: i+a)
- self.assertRaises(TypeError, lambda: i-a)
-
- # delta - datetime is senseless.
- self.assertRaises(TypeError, lambda: day - a)
- # mixing datetime and (delta or datetime) via * or // is senseless
- self.assertRaises(TypeError, lambda: day * a)
- self.assertRaises(TypeError, lambda: a * day)
- self.assertRaises(TypeError, lambda: day // a)
- self.assertRaises(TypeError, lambda: a // day)
- self.assertRaises(TypeError, lambda: a * a)
- self.assertRaises(TypeError, lambda: a // a)
- # datetime + datetime is senseless
- self.assertRaises(TypeError, lambda: a + a)
-
- def test_pickling(self):
- args = 6, 7, 23, 20, 59, 1, 64**2
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_more_pickling(self):
- a = self.theclass(2003, 2, 7, 16, 48, 37, 444116)
- s = pickle.dumps(a)
- b = pickle.loads(s)
- self.assertEqual(b.year, 2003)
- self.assertEqual(b.month, 2)
- self.assertEqual(b.day, 7)
-
- def test_pickling_subclass_datetime(self):
- args = 6, 7, 23, 20, 59, 1, 64**2
- orig = SubclassDatetime(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_more_compare(self):
- # The test_compare() inherited from TestDate covers the error cases.
- # We just want to test lexicographic ordering on the members datetime
- # has that date lacks.
- args = [2000, 11, 29, 20, 58, 16, 999998]
- t1 = self.theclass(*args)
- t2 = self.theclass(*args)
- self.assertEqual(t1, t2)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t1 >= t2)
- self.assertTrue(not t1 != t2)
- self.assertTrue(not t1 < t2)
- self.assertTrue(not t1 > t2)
-
- for i in range(len(args)):
- newargs = args[:]
- newargs[i] = args[i] + 1
- t2 = self.theclass(*newargs) # this is larger than t1
- self.assertTrue(t1 < t2)
- self.assertTrue(t2 > t1)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t2 >= t1)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 != t1)
- self.assertTrue(not t1 == t2)
- self.assertTrue(not t2 == t1)
- self.assertTrue(not t1 > t2)
- self.assertTrue(not t2 < t1)
- self.assertTrue(not t1 >= t2)
- self.assertTrue(not t2 <= t1)
-
-
- # A helper for timestamp constructor tests.
- def verify_field_equality(self, expected, got):
- self.assertEqual(expected.tm_year, got.year)
- self.assertEqual(expected.tm_mon, got.month)
- self.assertEqual(expected.tm_mday, got.day)
- self.assertEqual(expected.tm_hour, got.hour)
- self.assertEqual(expected.tm_min, got.minute)
- self.assertEqual(expected.tm_sec, got.second)
-
- def test_fromtimestamp(self):
- import time
-
- ts = time.time()
- expected = time.localtime(ts)
- got = self.theclass.fromtimestamp(ts)
- self.verify_field_equality(expected, got)
-
- def test_utcfromtimestamp(self):
- import time
-
- ts = time.time()
- expected = time.gmtime(ts)
- got = self.theclass.utcfromtimestamp(ts)
- self.verify_field_equality(expected, got)
-
- def test_microsecond_rounding(self):
- # Test whether fromtimestamp "rounds up" floats that are less
- # than one microsecond smaller than an integer.
- self.assertEqual(self.theclass.fromtimestamp(0.9999999),
- self.theclass.fromtimestamp(1))
-
- def test_insane_fromtimestamp(self):
- # It's possible that some platform maps time_t to double,
- # and that this test will fail there. This test should
- # exempt such platforms (provided they return reasonable
- # results!).
- for insane in -1e200, 1e200:
- self.assertRaises(ValueError, self.theclass.fromtimestamp,
- insane)
-
- def test_insane_utcfromtimestamp(self):
- # It's possible that some platform maps time_t to double,
- # and that this test will fail there. This test should
- # exempt such platforms (provided they return reasonable
- # results!).
- for insane in -1e200, 1e200:
- self.assertRaises(ValueError, self.theclass.utcfromtimestamp,
- insane)
- @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
- def test_negative_float_fromtimestamp(self):
- # The result is tz-dependent; at least test that this doesn't
- # fail (like it did before bug 1646728 was fixed).
- self.theclass.fromtimestamp(-1.05)
-
- @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
- def test_negative_float_utcfromtimestamp(self):
- d = self.theclass.utcfromtimestamp(-1.05)
- self.assertEqual(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000))
-
- def test_utcnow(self):
- import time
-
- # Call it a success if utcnow() and utcfromtimestamp() are within
- # a second of each other.
- tolerance = timedelta(seconds=1)
- for dummy in range(3):
- from_now = self.theclass.utcnow()
- from_timestamp = self.theclass.utcfromtimestamp(time.time())
- if abs(from_timestamp - from_now) <= tolerance:
- break
- # Else try again a few times.
- self.assertTrue(abs(from_timestamp - from_now) <= tolerance)
-
- def test_strptime(self):
- import _strptime
-
- string = '2004-12-01 13:02:47.197'
- format = '%Y-%m-%d %H:%M:%S.%f'
- result, frac = _strptime._strptime(string, format)
- expected = self.theclass(*(result[0:6]+(frac,)))
- got = self.theclass.strptime(string, format)
- self.assertEqual(expected, got)
-
- def test_more_timetuple(self):
- # This tests fields beyond those tested by the TestDate.test_timetuple.
- t = self.theclass(2004, 12, 31, 6, 22, 33)
- self.assertEqual(t.timetuple(), (2004, 12, 31, 6, 22, 33, 4, 366, -1))
- self.assertEqual(t.timetuple(),
- (t.year, t.month, t.day,
- t.hour, t.minute, t.second,
- t.weekday(),
- t.toordinal() - date(t.year, 1, 1).toordinal() + 1,
- -1))
- tt = t.timetuple()
- self.assertEqual(tt.tm_year, t.year)
- self.assertEqual(tt.tm_mon, t.month)
- self.assertEqual(tt.tm_mday, t.day)
- self.assertEqual(tt.tm_hour, t.hour)
- self.assertEqual(tt.tm_min, t.minute)
- self.assertEqual(tt.tm_sec, t.second)
- self.assertEqual(tt.tm_wday, t.weekday())
- self.assertEqual(tt.tm_yday, t.toordinal() -
- date(t.year, 1, 1).toordinal() + 1)
- self.assertEqual(tt.tm_isdst, -1)
-
- def test_more_strftime(self):
- # This tests fields beyond those tested by the TestDate.test_strftime.
- t = self.theclass(2004, 12, 31, 6, 22, 33, 47)
- self.assertEqual(t.strftime("%m %d %y %f %S %M %H %j"),
- "12 31 04 000047 33 22 06 366")
-
- def test_extract(self):
- dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
- self.assertEqual(dt.date(), date(2002, 3, 4))
- self.assertEqual(dt.time(), time(18, 45, 3, 1234))
-
- def test_combine(self):
- d = date(2002, 3, 4)
- t = time(18, 45, 3, 1234)
- expected = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
- combine = self.theclass.combine
- dt = combine(d, t)
- self.assertEqual(dt, expected)
-
- dt = combine(time=t, date=d)
- self.assertEqual(dt, expected)
-
- self.assertEqual(d, dt.date())
- self.assertEqual(t, dt.time())
- self.assertEqual(dt, combine(dt.date(), dt.time()))
-
- self.assertRaises(TypeError, combine) # need an arg
- self.assertRaises(TypeError, combine, d) # need two args
- self.assertRaises(TypeError, combine, t, d) # args reversed
- self.assertRaises(TypeError, combine, d, t, 1) # too many args
- self.assertRaises(TypeError, combine, "date", "time") # wrong types
-
- def test_replace(self):
- cls = self.theclass
- args = [1, 2, 3, 4, 5, 6, 7]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("year", 2),
- ("month", 3),
- ("day", 4),
- ("hour", 5),
- ("minute", 6),
- ("second", 7),
- ("microsecond", 8)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Out of bounds.
- base = cls(2000, 2, 29)
- self.assertRaises(ValueError, base.replace, year=2001)
-
- def test_astimezone(self):
- # Pretty boring! The TZ test is more interesting here. astimezone()
- # simply can't be applied to a naive object.
- dt = self.theclass.now()
- f = FixedOffset(44, "")
- self.assertRaises(TypeError, dt.astimezone) # not enough args
- self.assertRaises(TypeError, dt.astimezone, f, f) # too many args
- self.assertRaises(TypeError, dt.astimezone, dt) # arg wrong type
- self.assertRaises(ValueError, dt.astimezone, f) # naive
- self.assertRaises(ValueError, dt.astimezone, tz=f) # naive
-
- class Bogus(tzinfo):
- def utcoffset(self, dt): return None
- def dst(self, dt): return timedelta(0)
- bog = Bogus()
- self.assertRaises(ValueError, dt.astimezone, bog) # naive
-
- class AlsoBogus(tzinfo):
- def utcoffset(self, dt): return timedelta(0)
- def dst(self, dt): return None
- alsobog = AlsoBogus()
- self.assertRaises(ValueError, dt.astimezone, alsobog) # also naive
-
- def test_subclass_datetime(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.year + self.month + self.second
-
- args = 2003, 4, 14, 12, 13, 41
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.toordinal(), dt2.toordinal())
- self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month +
- dt1.second - 7)
-
-class SubclassTime(time):
- sub_var = 1
-
-class TestTime(HarmlessMixedComparison, unittest.TestCase):
-
- theclass = time
-
- def test_basic_attributes(self):
- t = self.theclass(12, 0)
- self.assertEqual(t.hour, 12)
- self.assertEqual(t.minute, 0)
- self.assertEqual(t.second, 0)
- self.assertEqual(t.microsecond, 0)
-
- def test_basic_attributes_nonzero(self):
- # Make sure all attributes are non-zero so bugs in
- # bit-shifting access show up.
- t = self.theclass(12, 59, 59, 8000)
- self.assertEqual(t.hour, 12)
- self.assertEqual(t.minute, 59)
- self.assertEqual(t.second, 59)
- self.assertEqual(t.microsecond, 8000)
-
- def test_roundtrip(self):
- t = self.theclass(1, 2, 3, 4)
-
- # Verify t -> string -> time identity.
- s = repr(t)
- self.assertTrue(s.startswith('datetime.'))
- s = s[9:]
- t2 = eval(s)
- self.assertEqual(t, t2)
-
- # Verify identity via reconstructing from pieces.
- t2 = self.theclass(t.hour, t.minute, t.second,
- t.microsecond)
- self.assertEqual(t, t2)
-
- def test_comparing(self):
- args = [1, 2, 3, 4]
- t1 = self.theclass(*args)
- t2 = self.theclass(*args)
- self.assertEqual(t1, t2)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t1 >= t2)
- self.assertTrue(not t1 != t2)
- self.assertTrue(not t1 < t2)
- self.assertTrue(not t1 > t2)
-
- for i in range(len(args)):
- newargs = args[:]
- newargs[i] = args[i] + 1
- t2 = self.theclass(*newargs) # this is larger than t1
- self.assertTrue(t1 < t2)
- self.assertTrue(t2 > t1)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t2 >= t1)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 != t1)
- self.assertTrue(not t1 == t2)
- self.assertTrue(not t2 == t1)
- self.assertTrue(not t1 > t2)
- self.assertTrue(not t2 < t1)
- self.assertTrue(not t1 >= t2)
- self.assertTrue(not t2 <= t1)
-
- for badarg in OTHERSTUFF:
- self.assertEqual(t1 == badarg, False)
- self.assertEqual(t1 != badarg, True)
- self.assertEqual(badarg == t1, False)
- self.assertEqual(badarg != t1, True)
-
- self.assertRaises(TypeError, lambda: t1 <= badarg)
- self.assertRaises(TypeError, lambda: t1 < badarg)
- self.assertRaises(TypeError, lambda: t1 > badarg)
- self.assertRaises(TypeError, lambda: t1 >= badarg)
- self.assertRaises(TypeError, lambda: badarg <= t1)
- self.assertRaises(TypeError, lambda: badarg < t1)
- self.assertRaises(TypeError, lambda: badarg > t1)
- self.assertRaises(TypeError, lambda: badarg >= t1)
-
- def test_bad_constructor_arguments(self):
- # bad hours
- self.theclass(0, 0) # no exception
- self.theclass(23, 0) # no exception
- self.assertRaises(ValueError, self.theclass, -1, 0)
- self.assertRaises(ValueError, self.theclass, 24, 0)
- # bad minutes
- self.theclass(23, 0) # no exception
- self.theclass(23, 59) # no exception
- self.assertRaises(ValueError, self.theclass, 23, -1)
- self.assertRaises(ValueError, self.theclass, 23, 60)
- # bad seconds
- self.theclass(23, 59, 0) # no exception
- self.theclass(23, 59, 59) # no exception
- self.assertRaises(ValueError, self.theclass, 23, 59, -1)
- self.assertRaises(ValueError, self.theclass, 23, 59, 60)
- # bad microseconds
- self.theclass(23, 59, 59, 0) # no exception
- self.theclass(23, 59, 59, 999999) # no exception
- self.assertRaises(ValueError, self.theclass, 23, 59, 59, -1)
- self.assertRaises(ValueError, self.theclass, 23, 59, 59, 1000000)
-
- def test_hash_equality(self):
- d = self.theclass(23, 30, 17)
- e = self.theclass(23, 30, 17)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- d = self.theclass(0, 5, 17)
- e = self.theclass(0, 5, 17)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- def test_isoformat(self):
- t = self.theclass(4, 5, 1, 123)
- self.assertEqual(t.isoformat(), "04:05:01.000123")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass()
- self.assertEqual(t.isoformat(), "00:00:00")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=1)
- self.assertEqual(t.isoformat(), "00:00:00.000001")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=10)
- self.assertEqual(t.isoformat(), "00:00:00.000010")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=100)
- self.assertEqual(t.isoformat(), "00:00:00.000100")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=1000)
- self.assertEqual(t.isoformat(), "00:00:00.001000")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=10000)
- self.assertEqual(t.isoformat(), "00:00:00.010000")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=100000)
- self.assertEqual(t.isoformat(), "00:00:00.100000")
- self.assertEqual(t.isoformat(), str(t))
-
- def test_1653736(self):
- # verify it doesn't accept extra keyword arguments
- t = self.theclass(second=1)
- self.assertRaises(TypeError, t.isoformat, foo=3)
-
- def test_strftime(self):
- t = self.theclass(1, 2, 3, 4)
- self.assertEqual(t.strftime('%H %M %S %f'), "01 02 03 000004")
- # A naive object replaces %z and %Z with empty strings.
- self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
-
- def test_format(self):
- t = self.theclass(1, 2, 3, 4)
- self.assertEqual(t.__format__(''), str(t))
-
- # check that a derived class's __str__() gets called
- class A(self.theclass):
- def __str__(self):
- return 'A'
- a = A(1, 2, 3, 4)
- self.assertEqual(a.__format__(''), 'A')
-
- # check that a derived class's strftime gets called
- class B(self.theclass):
- def strftime(self, format_spec):
- return 'B'
- b = B(1, 2, 3, 4)
- self.assertEqual(b.__format__(''), str(t))
-
- for fmt in ['%H %M %S',
- ]:
- self.assertEqual(t.__format__(fmt), t.strftime(fmt))
- self.assertEqual(a.__format__(fmt), t.strftime(fmt))
- self.assertEqual(b.__format__(fmt), 'B')
-
- def test_str(self):
- self.assertEqual(str(self.theclass(1, 2, 3, 4)), "01:02:03.000004")
- self.assertEqual(str(self.theclass(10, 2, 3, 4000)), "10:02:03.004000")
- self.assertEqual(str(self.theclass(0, 2, 3, 400000)), "00:02:03.400000")
- self.assertEqual(str(self.theclass(12, 2, 3, 0)), "12:02:03")
- self.assertEqual(str(self.theclass(23, 15, 0, 0)), "23:15:00")
-
- def test_repr(self):
- name = 'datetime.' + self.theclass.__name__
- self.assertEqual(repr(self.theclass(1, 2, 3, 4)),
- "%s(1, 2, 3, 4)" % name)
- self.assertEqual(repr(self.theclass(10, 2, 3, 4000)),
- "%s(10, 2, 3, 4000)" % name)
- self.assertEqual(repr(self.theclass(0, 2, 3, 400000)),
- "%s(0, 2, 3, 400000)" % name)
- self.assertEqual(repr(self.theclass(12, 2, 3, 0)),
- "%s(12, 2, 3)" % name)
- self.assertEqual(repr(self.theclass(23, 15, 0, 0)),
- "%s(23, 15)" % name)
-
- def test_resolution_info(self):
- self.assertTrue(isinstance(self.theclass.min, self.theclass))
- self.assertTrue(isinstance(self.theclass.max, self.theclass))
- self.assertTrue(isinstance(self.theclass.resolution, timedelta))
- self.assertTrue(self.theclass.max > self.theclass.min)
-
- def test_pickling(self):
- args = 20, 59, 16, 64**2
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_pickling_subclass_time(self):
- args = 20, 59, 16, 64**2
- orig = SubclassTime(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_bool(self):
- cls = self.theclass
- self.assertTrue(cls(1))
- self.assertTrue(cls(0, 1))
- self.assertTrue(cls(0, 0, 1))
- self.assertTrue(cls(0, 0, 0, 1))
- self.assertTrue(not cls(0))
- self.assertTrue(not cls())
-
- def test_replace(self):
- cls = self.theclass
- args = [1, 2, 3, 4]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("hour", 5),
- ("minute", 6),
- ("second", 7),
- ("microsecond", 8)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Out of bounds.
- base = cls(1)
- self.assertRaises(ValueError, base.replace, hour=24)
- self.assertRaises(ValueError, base.replace, minute=-1)
- self.assertRaises(ValueError, base.replace, second=100)
- self.assertRaises(ValueError, base.replace, microsecond=1000000)
-
- def test_subclass_time(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.hour + self.second
-
- args = 4, 5, 6
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.isoformat(), dt2.isoformat())
- self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
-
- def test_backdoor_resistance(self):
- # see TestDate.test_backdoor_resistance().
- base = '2:59.0'
- for hour_byte in ' ', '9', chr(24), '\xff':
- self.assertRaises(TypeError, self.theclass,
- hour_byte + base[1:])
-
-# A mixin for classes with a tzinfo= argument. Subclasses must define
-# theclass as a class atribute, and theclass(1, 1, 1, tzinfo=whatever)
-# must be legit (which is true for time and datetime).
-class TZInfoBase:
-
- def test_argument_passing(self):
- cls = self.theclass
- # A datetime passes itself on, a time passes None.
- class introspective(tzinfo):
- def tzname(self, dt): return dt and "real" or "none"
- def utcoffset(self, dt):
- return timedelta(minutes = dt and 42 or -42)
- dst = utcoffset
-
- obj = cls(1, 2, 3, tzinfo=introspective())
-
- expected = cls is time and "none" or "real"
- self.assertEqual(obj.tzname(), expected)
-
- expected = timedelta(minutes=(cls is time and -42 or 42))
- self.assertEqual(obj.utcoffset(), expected)
- self.assertEqual(obj.dst(), expected)
-
- def test_bad_tzinfo_classes(self):
- cls = self.theclass
- self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=12)
-
- class NiceTry(object):
- def __init__(self): pass
- def utcoffset(self, dt): pass
- self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=NiceTry)
-
- class BetterTry(tzinfo):
- def __init__(self): pass
- def utcoffset(self, dt): pass
- b = BetterTry()
- t = cls(1, 1, 1, tzinfo=b)
- self.assertTrue(t.tzinfo is b)
-
- def test_utc_offset_out_of_bounds(self):
- class Edgy(tzinfo):
- def __init__(self, offset):
- self.offset = timedelta(minutes=offset)
- def utcoffset(self, dt):
- return self.offset
-
- cls = self.theclass
- for offset, legit in ((-1440, False),
- (-1439, True),
- (1439, True),
- (1440, False)):
- if cls is time:
- t = cls(1, 2, 3, tzinfo=Edgy(offset))
- elif cls is datetime:
- t = cls(6, 6, 6, 1, 2, 3, tzinfo=Edgy(offset))
- else:
- assert 0, "impossible"
- if legit:
- aofs = abs(offset)
- h, m = divmod(aofs, 60)
- tag = "%c%02d:%02d" % (offset < 0 and '-' or '+', h, m)
- if isinstance(t, datetime):
- t = t.timetz()
- self.assertEqual(str(t), "01:02:03" + tag)
- else:
- self.assertRaises(ValueError, str, t)
-
- def test_tzinfo_classes(self):
- cls = self.theclass
- class C1(tzinfo):
- def utcoffset(self, dt): return None
- def dst(self, dt): return None
- def tzname(self, dt): return None
- for t in (cls(1, 1, 1),
- cls(1, 1, 1, tzinfo=None),
- cls(1, 1, 1, tzinfo=C1())):
- self.assertTrue(t.utcoffset() is None)
- self.assertTrue(t.dst() is None)
- self.assertTrue(t.tzname() is None)
-
- class C3(tzinfo):
- def utcoffset(self, dt): return timedelta(minutes=-1439)
- def dst(self, dt): return timedelta(minutes=1439)
- def tzname(self, dt): return "aname"
- t = cls(1, 1, 1, tzinfo=C3())
- self.assertEqual(t.utcoffset(), timedelta(minutes=-1439))
- self.assertEqual(t.dst(), timedelta(minutes=1439))
- self.assertEqual(t.tzname(), "aname")
-
- # Wrong types.
- class C4(tzinfo):
- def utcoffset(self, dt): return "aname"
- def dst(self, dt): return 7
- def tzname(self, dt): return 0
- t = cls(1, 1, 1, tzinfo=C4())
- self.assertRaises(TypeError, t.utcoffset)
- self.assertRaises(TypeError, t.dst)
- self.assertRaises(TypeError, t.tzname)
-
- # Offset out of range.
- class C6(tzinfo):
- def utcoffset(self, dt): return timedelta(hours=-24)
- def dst(self, dt): return timedelta(hours=24)
- t = cls(1, 1, 1, tzinfo=C6())
- self.assertRaises(ValueError, t.utcoffset)
- self.assertRaises(ValueError, t.dst)
-
- # Not a whole number of minutes.
- class C7(tzinfo):
- def utcoffset(self, dt): return timedelta(seconds=61)
- def dst(self, dt): return timedelta(microseconds=-81)
- t = cls(1, 1, 1, tzinfo=C7())
- self.assertRaises(ValueError, t.utcoffset)
- self.assertRaises(ValueError, t.dst)
-
- def test_aware_compare(self):
- cls = self.theclass
-
- # Ensure that utcoffset() gets ignored if the comparands have
- # the same tzinfo member.
- class OperandDependentOffset(tzinfo):
- def utcoffset(self, t):
- if t.minute < 10:
- # d0 and d1 equal after adjustment
- return timedelta(minutes=t.minute)
- else:
- # d2 off in the weeds
- return timedelta(minutes=59)
-
- base = cls(8, 9, 10, tzinfo=OperandDependentOffset())
- d0 = base.replace(minute=3)
- d1 = base.replace(minute=9)
- d2 = base.replace(minute=11)
- for x in d0, d1, d2:
- for y in d0, d1, d2:
- for op in lt, le, gt, ge, eq, ne:
- got = op(x, y)
- expected = op(x.minute, y.minute)
- self.assertEqual(got, expected)
-
- # However, if they're different members, uctoffset is not ignored.
- # Note that a time can't actually have an operand-depedent offset,
- # though (and time.utcoffset() passes None to tzinfo.utcoffset()),
- # so skip this test for time.
- if cls is not time:
- d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
- d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
- d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
- for x in d0, d1, d2:
- for y in d0, d1, d2:
- got = (x > y) - (x < y)
- if (x is d0 or x is d1) and (y is d0 or y is d1):
- expected = 0
- elif x is y is d2:
- expected = 0
- elif x is d2:
- expected = -1
- else:
- assert y is d2
- expected = 1
- self.assertEqual(got, expected)
-
-
-# Testing time objects with a non-None tzinfo.
-class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
- theclass = time
-
- def test_empty(self):
- t = self.theclass()
- self.assertEqual(t.hour, 0)
- self.assertEqual(t.minute, 0)
- self.assertEqual(t.second, 0)
- self.assertEqual(t.microsecond, 0)
- self.assertTrue(t.tzinfo is None)
-
- def test_zones(self):
- est = FixedOffset(-300, "EST", 1)
- utc = FixedOffset(0, "UTC", -2)
- met = FixedOffset(60, "MET", 3)
- t1 = time( 7, 47, tzinfo=est)
- t2 = time(12, 47, tzinfo=utc)
- t3 = time(13, 47, tzinfo=met)
- t4 = time(microsecond=40)
- t5 = time(microsecond=40, tzinfo=utc)
-
- self.assertEqual(t1.tzinfo, est)
- self.assertEqual(t2.tzinfo, utc)
- self.assertEqual(t3.tzinfo, met)
- self.assertTrue(t4.tzinfo is None)
- self.assertEqual(t5.tzinfo, utc)
-
- self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
- self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
- self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
- self.assertTrue(t4.utcoffset() is None)
- self.assertRaises(TypeError, t1.utcoffset, "no args")
-
- self.assertEqual(t1.tzname(), "EST")
- self.assertEqual(t2.tzname(), "UTC")
- self.assertEqual(t3.tzname(), "MET")
- self.assertTrue(t4.tzname() is None)
- self.assertRaises(TypeError, t1.tzname, "no args")
-
- self.assertEqual(t1.dst(), timedelta(minutes=1))
- self.assertEqual(t2.dst(), timedelta(minutes=-2))
- self.assertEqual(t3.dst(), timedelta(minutes=3))
- self.assertTrue(t4.dst() is None)
- self.assertRaises(TypeError, t1.dst, "no args")
-
- self.assertEqual(hash(t1), hash(t2))
- self.assertEqual(hash(t1), hash(t3))
- self.assertEqual(hash(t2), hash(t3))
-
- self.assertEqual(t1, t2)
- self.assertEqual(t1, t3)
- self.assertEqual(t2, t3)
- self.assertRaises(TypeError, lambda: t4 == t5) # mixed tz-aware & naive
- self.assertRaises(TypeError, lambda: t4 < t5) # mixed tz-aware & naive
- self.assertRaises(TypeError, lambda: t5 < t4) # mixed tz-aware & naive
-
- self.assertEqual(str(t1), "07:47:00-05:00")
- self.assertEqual(str(t2), "12:47:00+00:00")
- self.assertEqual(str(t3), "13:47:00+01:00")
- self.assertEqual(str(t4), "00:00:00.000040")
- self.assertEqual(str(t5), "00:00:00.000040+00:00")
-
- self.assertEqual(t1.isoformat(), "07:47:00-05:00")
- self.assertEqual(t2.isoformat(), "12:47:00+00:00")
- self.assertEqual(t3.isoformat(), "13:47:00+01:00")
- self.assertEqual(t4.isoformat(), "00:00:00.000040")
- self.assertEqual(t5.isoformat(), "00:00:00.000040+00:00")
-
- d = 'datetime.time'
- self.assertEqual(repr(t1), d + "(7, 47, tzinfo=est)")
- self.assertEqual(repr(t2), d + "(12, 47, tzinfo=utc)")
- self.assertEqual(repr(t3), d + "(13, 47, tzinfo=met)")
- self.assertEqual(repr(t4), d + "(0, 0, 0, 40)")
- self.assertEqual(repr(t5), d + "(0, 0, 0, 40, tzinfo=utc)")
-
- self.assertEqual(t1.strftime("%H:%M:%S %%Z=%Z %%z=%z"),
- "07:47:00 %Z=EST %z=-0500")
- self.assertEqual(t2.strftime("%H:%M:%S %Z %z"), "12:47:00 UTC +0000")
- self.assertEqual(t3.strftime("%H:%M:%S %Z %z"), "13:47:00 MET +0100")
-
- yuck = FixedOffset(-1439, "%z %Z %%z%%Z")
- t1 = time(23, 59, tzinfo=yuck)
- self.assertEqual(t1.strftime("%H:%M %%Z='%Z' %%z='%z'"),
- "23:59 %Z='%z %Z %%z%%Z' %z='-2359'")
-
- # Check that an invalid tzname result raises an exception.
- class Badtzname(tzinfo):
- def tzname(self, dt): return 42
- t = time(2, 3, 4, tzinfo=Badtzname())
- self.assertEqual(t.strftime("%H:%M:%S"), "02:03:04")
- self.assertRaises(TypeError, t.strftime, "%Z")
-
- def test_hash_edge_cases(self):
- # Offsets that overflow a basic time.
- t1 = self.theclass(0, 1, 2, 3, tzinfo=FixedOffset(1439, ""))
- t2 = self.theclass(0, 0, 2, 3, tzinfo=FixedOffset(1438, ""))
- self.assertEqual(hash(t1), hash(t2))
-
- t1 = self.theclass(23, 58, 6, 100, tzinfo=FixedOffset(-1000, ""))
- t2 = self.theclass(23, 48, 6, 100, tzinfo=FixedOffset(-1010, ""))
- self.assertEqual(hash(t1), hash(t2))
-
- def test_pickling(self):
- # Try one without a tzinfo.
- args = 20, 59, 16, 64**2
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- # Try one with a tzinfo.
- tinfo = PicklableFixedOffset(-300, 'cookie')
- orig = self.theclass(5, 6, 7, tzinfo=tinfo)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
- self.assertTrue(isinstance(derived.tzinfo, PicklableFixedOffset))
- self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
- self.assertEqual(derived.tzname(), 'cookie')
-
- def test_more_bool(self):
- # Test cases with non-None tzinfo.
- cls = self.theclass
-
- t = cls(0, tzinfo=FixedOffset(-300, ""))
- self.assertTrue(t)
-
- t = cls(5, tzinfo=FixedOffset(-300, ""))
- self.assertTrue(t)
-
- t = cls(5, tzinfo=FixedOffset(300, ""))
- self.assertTrue(not t)
-
- t = cls(23, 59, tzinfo=FixedOffset(23*60 + 59, ""))
- self.assertTrue(not t)
-
- # Mostly ensuring this doesn't overflow internally.
- t = cls(0, tzinfo=FixedOffset(23*60 + 59, ""))
- self.assertTrue(t)
-
- # But this should yield a value error -- the utcoffset is bogus.
- t = cls(0, tzinfo=FixedOffset(24*60, ""))
- self.assertRaises(ValueError, lambda: bool(t))
-
- # Likewise.
- t = cls(0, tzinfo=FixedOffset(-24*60, ""))
- self.assertRaises(ValueError, lambda: bool(t))
-
- def test_replace(self):
- cls = self.theclass
- z100 = FixedOffset(100, "+100")
- zm200 = FixedOffset(timedelta(minutes=-200), "-200")
- args = [1, 2, 3, 4, z100]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("hour", 5),
- ("minute", 6),
- ("second", 7),
- ("microsecond", 8),
- ("tzinfo", zm200)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Ensure we can get rid of a tzinfo.
- self.assertEqual(base.tzname(), "+100")
- base2 = base.replace(tzinfo=None)
- self.assertTrue(base2.tzinfo is None)
- self.assertTrue(base2.tzname() is None)
-
- # Ensure we can add one.
- base3 = base2.replace(tzinfo=z100)
- self.assertEqual(base, base3)
- self.assertTrue(base.tzinfo is base3.tzinfo)
-
- # Out of bounds.
- base = cls(1)
- self.assertRaises(ValueError, base.replace, hour=24)
- self.assertRaises(ValueError, base.replace, minute=-1)
- self.assertRaises(ValueError, base.replace, second=100)
- self.assertRaises(ValueError, base.replace, microsecond=1000000)
-
- def test_mixed_compare(self):
- t1 = time(1, 2, 3)
- t2 = time(1, 2, 3)
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=None)
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=FixedOffset(None, ""))
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=FixedOffset(0, ""))
- self.assertRaises(TypeError, lambda: t1 == t2)
-
- # In time w/ identical tzinfo objects, utcoffset is ignored.
- class Varies(tzinfo):
- def __init__(self):
- self.offset = timedelta(minutes=22)
- def utcoffset(self, t):
- self.offset += timedelta(minutes=1)
- return self.offset
-
- v = Varies()
- t1 = t2.replace(tzinfo=v)
- t2 = t2.replace(tzinfo=v)
- self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
- self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
- self.assertEqual(t1, t2)
-
- # But if they're not identical, it isn't ignored.
- t2 = t2.replace(tzinfo=Varies())
- self.assertTrue(t1 < t2) # t1's offset counter still going up
-
- def test_subclass_timetz(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.hour + self.second
-
- args = 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
- self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
-
-
-# Testing datetime objects with a non-None tzinfo.
-
-class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
- theclass = datetime
-
- def test_trivial(self):
- dt = self.theclass(1, 2, 3, 4, 5, 6, 7)
- self.assertEqual(dt.year, 1)
- self.assertEqual(dt.month, 2)
- self.assertEqual(dt.day, 3)
- self.assertEqual(dt.hour, 4)
- self.assertEqual(dt.minute, 5)
- self.assertEqual(dt.second, 6)
- self.assertEqual(dt.microsecond, 7)
- self.assertEqual(dt.tzinfo, None)
-
- def test_even_more_compare(self):
- # The test_compare() and test_more_compare() inherited from TestDate
- # and TestDateTime covered non-tzinfo cases.
-
- # Smallest possible after UTC adjustment.
- t1 = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
- # Largest possible after UTC adjustment.
- t2 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
- tzinfo=FixedOffset(-1439, ""))
-
- # Make sure those compare correctly, and w/o overflow.
- self.assertTrue(t1 < t2)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 > t1)
-
- self.assertEqual(t1, t1)
- self.assertEqual(t2, t2)
-
- # Equal afer adjustment.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""))
- t2 = self.theclass(2, 1, 1, 3, 13, tzinfo=FixedOffset(3*60+13+2, ""))
- self.assertEqual(t1, t2)
-
- # Change t1 not to subtract a minute, and t1 should be larger.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(0, ""))
- self.assertTrue(t1 > t2)
-
- # Change t1 to subtract 2 minutes, and t1 should be smaller.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(2, ""))
- self.assertTrue(t1 < t2)
-
- # Back to the original t1, but make seconds resolve it.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
- second=1)
- self.assertTrue(t1 > t2)
-
- # Likewise, but make microseconds resolve it.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
- microsecond=1)
- self.assertTrue(t1 > t2)
-
- # Make t2 naive and it should fail.
- t2 = self.theclass.min
- self.assertRaises(TypeError, lambda: t1 == t2)
- self.assertEqual(t2, t2)
-
- # It's also naive if it has tzinfo but tzinfo.utcoffset() is None.
- class Naive(tzinfo):
- def utcoffset(self, dt): return None
- t2 = self.theclass(5, 6, 7, tzinfo=Naive())
- self.assertRaises(TypeError, lambda: t1 == t2)
- self.assertEqual(t2, t2)
-
- # OTOH, it's OK to compare two of these mixing the two ways of being
- # naive.
- t1 = self.theclass(5, 6, 7)
- self.assertEqual(t1, t2)
-
- # Try a bogus uctoffset.
- class Bogus(tzinfo):
- def utcoffset(self, dt):
- return timedelta(minutes=1440) # out of bounds
- t1 = self.theclass(2, 2, 2, tzinfo=Bogus())
- t2 = self.theclass(2, 2, 2, tzinfo=FixedOffset(0, ""))
- self.assertRaises(ValueError, lambda: t1 == t2)
-
- def test_pickling(self):
- # Try one without a tzinfo.
- args = 6, 7, 23, 20, 59, 1, 64**2
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- # Try one with a tzinfo.
- tinfo = PicklableFixedOffset(-300, 'cookie')
- orig = self.theclass(*args, **{'tzinfo': tinfo})
- derived = self.theclass(1, 1, 1, tzinfo=FixedOffset(0, "", 0))
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
- self.assertTrue(isinstance(derived.tzinfo,
- PicklableFixedOffset))
- self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
- self.assertEqual(derived.tzname(), 'cookie')
-
- def test_extreme_hashes(self):
- # If an attempt is made to hash these via subtracting the offset
- # then hashing a datetime object, OverflowError results. The
- # Python implementation used to blow up here.
- t = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
- hash(t)
- t = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
- tzinfo=FixedOffset(-1439, ""))
- hash(t)
-
- # OTOH, an OOB offset should blow up.
- t = self.theclass(5, 5, 5, tzinfo=FixedOffset(-1440, ""))
- self.assertRaises(ValueError, hash, t)
-
- def test_zones(self):
- est = FixedOffset(-300, "EST")
- utc = FixedOffset(0, "UTC")
- met = FixedOffset(60, "MET")
- t1 = datetime(2002, 3, 19, 7, 47, tzinfo=est)
- t2 = datetime(2002, 3, 19, 12, 47, tzinfo=utc)
- t3 = datetime(2002, 3, 19, 13, 47, tzinfo=met)
- self.assertEqual(t1.tzinfo, est)
- self.assertEqual(t2.tzinfo, utc)
- self.assertEqual(t3.tzinfo, met)
- self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
- self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
- self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
- self.assertEqual(t1.tzname(), "EST")
- self.assertEqual(t2.tzname(), "UTC")
- self.assertEqual(t3.tzname(), "MET")
- self.assertEqual(hash(t1), hash(t2))
- self.assertEqual(hash(t1), hash(t3))
- self.assertEqual(hash(t2), hash(t3))
- self.assertEqual(t1, t2)
- self.assertEqual(t1, t3)
- self.assertEqual(t2, t3)
- self.assertEqual(str(t1), "2002-03-19 07:47:00-05:00")
- self.assertEqual(str(t2), "2002-03-19 12:47:00+00:00")
- self.assertEqual(str(t3), "2002-03-19 13:47:00+01:00")
- d = 'datetime.datetime(2002, 3, 19, '
- self.assertEqual(repr(t1), d + "7, 47, tzinfo=est)")
- self.assertEqual(repr(t2), d + "12, 47, tzinfo=utc)")
- self.assertEqual(repr(t3), d + "13, 47, tzinfo=met)")
-
- def test_combine(self):
- met = FixedOffset(60, "MET")
- d = date(2002, 3, 4)
- tz = time(18, 45, 3, 1234, tzinfo=met)
- dt = datetime.combine(d, tz)
- self.assertEqual(dt, datetime(2002, 3, 4, 18, 45, 3, 1234,
- tzinfo=met))
-
- def test_extract(self):
- met = FixedOffset(60, "MET")
- dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234, tzinfo=met)
- self.assertEqual(dt.date(), date(2002, 3, 4))
- self.assertEqual(dt.time(), time(18, 45, 3, 1234))
- self.assertEqual(dt.timetz(), time(18, 45, 3, 1234, tzinfo=met))
-
- def test_tz_aware_arithmetic(self):
- import random
-
- now = self.theclass.now()
- tz55 = FixedOffset(-330, "west 5:30")
- timeaware = now.time().replace(tzinfo=tz55)
- nowaware = self.theclass.combine(now.date(), timeaware)
- self.assertTrue(nowaware.tzinfo is tz55)
- self.assertEqual(nowaware.timetz(), timeaware)
-
- # Can't mix aware and non-aware.
- self.assertRaises(TypeError, lambda: now - nowaware)
- self.assertRaises(TypeError, lambda: nowaware - now)
-
- # And adding datetime's doesn't make sense, aware or not.
- self.assertRaises(TypeError, lambda: now + nowaware)
- self.assertRaises(TypeError, lambda: nowaware + now)
- self.assertRaises(TypeError, lambda: nowaware + nowaware)
-
- # Subtracting should yield 0.
- self.assertEqual(now - now, timedelta(0))
- self.assertEqual(nowaware - nowaware, timedelta(0))
-
- # Adding a delta should preserve tzinfo.
- delta = timedelta(weeks=1, minutes=12, microseconds=5678)
- nowawareplus = nowaware + delta
- self.assertTrue(nowaware.tzinfo is tz55)
- nowawareplus2 = delta + nowaware
- self.assertTrue(nowawareplus2.tzinfo is tz55)
- self.assertEqual(nowawareplus, nowawareplus2)
-
- # that - delta should be what we started with, and that - what we
- # started with should be delta.
- diff = nowawareplus - delta
- self.assertTrue(diff.tzinfo is tz55)
- self.assertEqual(nowaware, diff)
- self.assertRaises(TypeError, lambda: delta - nowawareplus)
- self.assertEqual(nowawareplus - nowaware, delta)
-
- # Make up a random timezone.
- tzr = FixedOffset(random.randrange(-1439, 1440), "randomtimezone")
- # Attach it to nowawareplus.
- nowawareplus = nowawareplus.replace(tzinfo=tzr)
- self.assertTrue(nowawareplus.tzinfo is tzr)
- # Make sure the difference takes the timezone adjustments into account.
- got = nowaware - nowawareplus
- # Expected: (nowaware base - nowaware offset) -
- # (nowawareplus base - nowawareplus offset) =
- # (nowaware base - nowawareplus base) +
- # (nowawareplus offset - nowaware offset) =
- # -delta + nowawareplus offset - nowaware offset
- expected = nowawareplus.utcoffset() - nowaware.utcoffset() - delta
- self.assertEqual(got, expected)
-
- # Try max possible difference.
- min = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, "min"))
- max = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
- tzinfo=FixedOffset(-1439, "max"))
- maxdiff = max - min
- self.assertEqual(maxdiff, self.theclass.max - self.theclass.min +
- timedelta(minutes=2*1439))
-
- def test_tzinfo_now(self):
- meth = self.theclass.now
- # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
- base = meth()
- # Try with and without naming the keyword.
- off42 = FixedOffset(42, "42")
- another = meth(off42)
- again = meth(tz=off42)
- self.assertTrue(another.tzinfo is again.tzinfo)
- self.assertEqual(another.utcoffset(), timedelta(minutes=42))
- # Bad argument with and w/o naming the keyword.
- self.assertRaises(TypeError, meth, 16)
- self.assertRaises(TypeError, meth, tzinfo=16)
- # Bad keyword name.
- self.assertRaises(TypeError, meth, tinfo=off42)
- # Too many args.
- self.assertRaises(TypeError, meth, off42, off42)
-
- # We don't know which time zone we're in, and don't have a tzinfo
- # class to represent it, so seeing whether a tz argument actually
- # does a conversion is tricky.
- weirdtz = FixedOffset(timedelta(hours=15, minutes=58), "weirdtz", 0)
- utc = FixedOffset(0, "utc", 0)
- for dummy in range(3):
- now = datetime.now(weirdtz)
- self.assertTrue(now.tzinfo is weirdtz)
- utcnow = datetime.utcnow().replace(tzinfo=utc)
- now2 = utcnow.astimezone(weirdtz)
- if abs(now - now2) < timedelta(seconds=30):
- break
- # Else the code is broken, or more than 30 seconds passed between
- # calls; assuming the latter, just try again.
- else:
- # Three strikes and we're out.
- self.fail("utcnow(), now(tz), or astimezone() may be broken")
-
- def test_tzinfo_fromtimestamp(self):
- import time
- meth = self.theclass.fromtimestamp
- ts = time.time()
- # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
- base = meth(ts)
- # Try with and without naming the keyword.
- off42 = FixedOffset(42, "42")
- another = meth(ts, off42)
- again = meth(ts, tz=off42)
- self.assertTrue(another.tzinfo is again.tzinfo)
- self.assertEqual(another.utcoffset(), timedelta(minutes=42))
- # Bad argument with and w/o naming the keyword.
- self.assertRaises(TypeError, meth, ts, 16)
- self.assertRaises(TypeError, meth, ts, tzinfo=16)
- # Bad keyword name.
- self.assertRaises(TypeError, meth, ts, tinfo=off42)
- # Too many args.
- self.assertRaises(TypeError, meth, ts, off42, off42)
- # Too few args.
- self.assertRaises(TypeError, meth)
-
- # Try to make sure tz= actually does some conversion.
- timestamp = 1000000000
- utcdatetime = datetime.utcfromtimestamp(timestamp)
- # In POSIX (epoch 1970), that's 2001-09-09 01:46:40 UTC, give or take.
- # But on some flavor of Mac, it's nowhere near that. So we can't have
- # any idea here what time that actually is, we can only test that
- # relative changes match.
- utcoffset = timedelta(hours=-15, minutes=39) # arbitrary, but not zero
- tz = FixedOffset(utcoffset, "tz", 0)
- expected = utcdatetime + utcoffset
- got = datetime.fromtimestamp(timestamp, tz)
- self.assertEqual(expected, got.replace(tzinfo=None))
-
- def test_tzinfo_utcnow(self):
- meth = self.theclass.utcnow
- # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
- base = meth()
- # Try with and without naming the keyword; for whatever reason,
- # utcnow() doesn't accept a tzinfo argument.
- off42 = FixedOffset(42, "42")
- self.assertRaises(TypeError, meth, off42)
- self.assertRaises(TypeError, meth, tzinfo=off42)
-
- def test_tzinfo_utcfromtimestamp(self):
- import time
- meth = self.theclass.utcfromtimestamp
- ts = time.time()
- # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
- base = meth(ts)
- # Try with and without naming the keyword; for whatever reason,
- # utcfromtimestamp() doesn't accept a tzinfo argument.
- off42 = FixedOffset(42, "42")
- self.assertRaises(TypeError, meth, ts, off42)
- self.assertRaises(TypeError, meth, ts, tzinfo=off42)
-
- def test_tzinfo_timetuple(self):
- # TestDateTime tested most of this. datetime adds a twist to the
- # DST flag.
- class DST(tzinfo):
- def __init__(self, dstvalue):
- if isinstance(dstvalue, int):
- dstvalue = timedelta(minutes=dstvalue)
- self.dstvalue = dstvalue
- def dst(self, dt):
- return self.dstvalue
-
- cls = self.theclass
- for dstvalue, flag in (-33, 1), (33, 1), (0, 0), (None, -1):
- d = cls(1, 1, 1, 10, 20, 30, 40, tzinfo=DST(dstvalue))
- t = d.timetuple()
- self.assertEqual(1, t.tm_year)
- self.assertEqual(1, t.tm_mon)
- self.assertEqual(1, t.tm_mday)
- self.assertEqual(10, t.tm_hour)
- self.assertEqual(20, t.tm_min)
- self.assertEqual(30, t.tm_sec)
- self.assertEqual(0, t.tm_wday)
- self.assertEqual(1, t.tm_yday)
- self.assertEqual(flag, t.tm_isdst)
-
- # dst() returns wrong type.
- self.assertRaises(TypeError, cls(1, 1, 1, tzinfo=DST("x")).timetuple)
-
- # dst() at the edge.
- self.assertEqual(cls(1,1,1, tzinfo=DST(1439)).timetuple().tm_isdst, 1)
- self.assertEqual(cls(1,1,1, tzinfo=DST(-1439)).timetuple().tm_isdst, 1)
-
- # dst() out of range.
- self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(1440)).timetuple)
- self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(-1440)).timetuple)
-
- def test_utctimetuple(self):
- class DST(tzinfo):
- def __init__(self, dstvalue=0):
- if isinstance(dstvalue, int):
- dstvalue = timedelta(minutes=dstvalue)
- self.dstvalue = dstvalue
- def dst(self, dt):
- return self.dstvalue
-
- cls = self.theclass
- # This can't work: DST didn't implement utcoffset.
- self.assertRaises(NotImplementedError,
- cls(1, 1, 1, tzinfo=DST(0)).utcoffset)
-
- class UOFS(DST):
- def __init__(self, uofs, dofs=None):
- DST.__init__(self, dofs)
- self.uofs = timedelta(minutes=uofs)
- def utcoffset(self, dt):
- return self.uofs
-
- # Ensure tm_isdst is 0 regardless of what dst() says: DST is never
- # in effect for a UTC time.
- for dstvalue in -33, 33, 0, None:
- d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=UOFS(-53, dstvalue))
- t = d.utctimetuple()
- self.assertEqual(d.year, t.tm_year)
- self.assertEqual(d.month, t.tm_mon)
- self.assertEqual(d.day, t.tm_mday)
- self.assertEqual(11, t.tm_hour) # 20mm + 53mm = 1hn + 13mm
- self.assertEqual(13, t.tm_min)
- self.assertEqual(d.second, t.tm_sec)
- self.assertEqual(d.weekday(), t.tm_wday)
- self.assertEqual(d.toordinal() - date(1, 1, 1).toordinal() + 1,
- t.tm_yday)
- self.assertEqual(0, t.tm_isdst)
- # For naive datetime, utctimetuple == timetuple except for isdst
- d = cls(1, 2, 3, 10, 20, 30, 40)
- t = d.utctimetuple()
- self.assertEqual(t[:-1], d.timetuple()[:-1])
- self.assertEqual(0, t.tm_isdst)
- # Same if utcoffset is None
- class NOFS(DST):
- def utcoffset(self, dt):
- return None
- d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=NOFS())
- t = d.utctimetuple()
- self.assertEqual(t[:-1], d.timetuple()[:-1])
- self.assertEqual(0, t.tm_isdst)
- # Check that bad tzinfo is detected
- class BOFS(DST):
- def utcoffset(self, dt):
- return "EST"
- d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=BOFS())
- self.assertRaises(TypeError, d.utctimetuple)
-
- # At the edges, UTC adjustment can normalize into years out-of-range
- # for a datetime object. Ensure that a correct timetuple is
- # created anyway.
- tiny = cls(MINYEAR, 1, 1, 0, 0, 37, tzinfo=UOFS(1439))
- # That goes back 1 minute less than a full day.
- t = tiny.utctimetuple()
- self.assertEqual(t.tm_year, MINYEAR-1)
- self.assertEqual(t.tm_mon, 12)
- self.assertEqual(t.tm_mday, 31)
- self.assertEqual(t.tm_hour, 0)
- self.assertEqual(t.tm_min, 1)
- self.assertEqual(t.tm_sec, 37)
- self.assertEqual(t.tm_yday, 366) # "year 0" is a leap year
- self.assertEqual(t.tm_isdst, 0)
-
- huge = cls(MAXYEAR, 12, 31, 23, 59, 37, 999999, tzinfo=UOFS(-1439))
- # That goes forward 1 minute less than a full day.
- t = huge.utctimetuple()
- self.assertEqual(t.tm_year, MAXYEAR+1)
- self.assertEqual(t.tm_mon, 1)
- self.assertEqual(t.tm_mday, 1)
- self.assertEqual(t.tm_hour, 23)
- self.assertEqual(t.tm_min, 58)
- self.assertEqual(t.tm_sec, 37)
- self.assertEqual(t.tm_yday, 1)
- self.assertEqual(t.tm_isdst, 0)
-
- def test_tzinfo_isoformat(self):
- zero = FixedOffset(0, "+00:00")
- plus = FixedOffset(220, "+03:40")
- minus = FixedOffset(-231, "-03:51")
- unknown = FixedOffset(None, "")
-
- cls = self.theclass
- datestr = '0001-02-03'
- for ofs in None, zero, plus, minus, unknown:
- for us in 0, 987001:
- d = cls(1, 2, 3, 4, 5, 59, us, tzinfo=ofs)
- timestr = '04:05:59' + (us and '.987001' or '')
- ofsstr = ofs is not None and d.tzname() or ''
- tailstr = timestr + ofsstr
- iso = d.isoformat()
- self.assertEqual(iso, datestr + 'T' + tailstr)
- self.assertEqual(iso, d.isoformat('T'))
- self.assertEqual(d.isoformat('k'), datestr + 'k' + tailstr)
- self.assertEqual(d.isoformat('\u1234'), datestr + '\u1234' + tailstr)
- self.assertEqual(str(d), datestr + ' ' + tailstr)
-
- def test_replace(self):
- cls = self.theclass
- z100 = FixedOffset(100, "+100")
- zm200 = FixedOffset(timedelta(minutes=-200), "-200")
- args = [1, 2, 3, 4, 5, 6, 7, z100]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("year", 2),
- ("month", 3),
- ("day", 4),
- ("hour", 5),
- ("minute", 6),
- ("second", 7),
- ("microsecond", 8),
- ("tzinfo", zm200)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Ensure we can get rid of a tzinfo.
- self.assertEqual(base.tzname(), "+100")
- base2 = base.replace(tzinfo=None)
- self.assertTrue(base2.tzinfo is None)
- self.assertTrue(base2.tzname() is None)
-
- # Ensure we can add one.
- base3 = base2.replace(tzinfo=z100)
- self.assertEqual(base, base3)
- self.assertTrue(base.tzinfo is base3.tzinfo)
-
- # Out of bounds.
- base = cls(2000, 2, 29)
- self.assertRaises(ValueError, base.replace, year=2001)
-
- def test_more_astimezone(self):
- # The inherited test_astimezone covered some trivial and error cases.
- fnone = FixedOffset(None, "None")
- f44m = FixedOffset(44, "44")
- fm5h = FixedOffset(-timedelta(hours=5), "m300")
-
- dt = self.theclass.now(tz=f44m)
- self.assertTrue(dt.tzinfo is f44m)
- # Replacing with degenerate tzinfo raises an exception.
- self.assertRaises(ValueError, dt.astimezone, fnone)
- # Ditto with None tz.
- self.assertRaises(TypeError, dt.astimezone, None)
- # Replacing with same tzinfo makes no change.
- x = dt.astimezone(dt.tzinfo)
- self.assertTrue(x.tzinfo is f44m)
- self.assertEqual(x.date(), dt.date())
- self.assertEqual(x.time(), dt.time())
-
- # Replacing with different tzinfo does adjust.
- got = dt.astimezone(fm5h)
- self.assertTrue(got.tzinfo is fm5h)
- self.assertEqual(got.utcoffset(), timedelta(hours=-5))
- expected = dt - dt.utcoffset() # in effect, convert to UTC
- expected += fm5h.utcoffset(dt) # and from there to local time
- expected = expected.replace(tzinfo=fm5h) # and attach new tzinfo
- self.assertEqual(got.date(), expected.date())
- self.assertEqual(got.time(), expected.time())
- self.assertEqual(got.timetz(), expected.timetz())
- self.assertTrue(got.tzinfo is expected.tzinfo)
- self.assertEqual(got, expected)
-
- def test_aware_subtract(self):
- cls = self.theclass
-
- # Ensure that utcoffset() is ignored when the operands have the
- # same tzinfo member.
- class OperandDependentOffset(tzinfo):
- def utcoffset(self, t):
- if t.minute < 10:
- # d0 and d1 equal after adjustment
- return timedelta(minutes=t.minute)
- else:
- # d2 off in the weeds
- return timedelta(minutes=59)
-
- base = cls(8, 9, 10, 11, 12, 13, 14, tzinfo=OperandDependentOffset())
- d0 = base.replace(minute=3)
- d1 = base.replace(minute=9)
- d2 = base.replace(minute=11)
- for x in d0, d1, d2:
- for y in d0, d1, d2:
- got = x - y
- expected = timedelta(minutes=x.minute - y.minute)
- self.assertEqual(got, expected)
-
- # OTOH, if the tzinfo members are distinct, utcoffsets aren't
- # ignored.
- base = cls(8, 9, 10, 11, 12, 13, 14)
- d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
- d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
- d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
- for x in d0, d1, d2:
- for y in d0, d1, d2:
- got = x - y
- if (x is d0 or x is d1) and (y is d0 or y is d1):
- expected = timedelta(0)
- elif x is y is d2:
- expected = timedelta(0)
- elif x is d2:
- expected = timedelta(minutes=(11-59)-0)
- else:
- assert y is d2
- expected = timedelta(minutes=0-(11-59))
- self.assertEqual(got, expected)
-
- def test_mixed_compare(self):
- t1 = datetime(1, 2, 3, 4, 5, 6, 7)
- t2 = datetime(1, 2, 3, 4, 5, 6, 7)
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=None)
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=FixedOffset(None, ""))
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=FixedOffset(0, ""))
- self.assertRaises(TypeError, lambda: t1 == t2)
-
- # In datetime w/ identical tzinfo objects, utcoffset is ignored.
- class Varies(tzinfo):
- def __init__(self):
- self.offset = timedelta(minutes=22)
- def utcoffset(self, t):
- self.offset += timedelta(minutes=1)
- return self.offset
-
- v = Varies()
- t1 = t2.replace(tzinfo=v)
- t2 = t2.replace(tzinfo=v)
- self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
- self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
- self.assertEqual(t1, t2)
-
- # But if they're not identical, it isn't ignored.
- t2 = t2.replace(tzinfo=Varies())
- self.assertTrue(t1 < t2) # t1's offset counter still going up
-
- def test_subclass_datetimetz(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.hour + self.year
-
- args = 2002, 12, 31, 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
- self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.year - 7)
-
-# Pain to set up DST-aware tzinfo classes.
-
-def first_sunday_on_or_after(dt):
- days_to_go = 6 - dt.weekday()
- if days_to_go:
- dt += timedelta(days_to_go)
- return dt
-
-ZERO = timedelta(0)
-HOUR = timedelta(hours=1)
-DAY = timedelta(days=1)
-# In the US, DST starts at 2am (standard time) on the first Sunday in April.
-DSTSTART = datetime(1, 4, 1, 2)
-# and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct,
-# which is the first Sunday on or after Oct 25. Because we view 1:MM as
-# being standard time on that day, there is no spelling in local time of
-# the last hour of DST (that's 1:MM DST, but 1:MM is taken as standard time).
-DSTEND = datetime(1, 10, 25, 1)
-
-class USTimeZone(tzinfo):
-
- def __init__(self, hours, reprname, stdname, dstname):
- self.stdoffset = timedelta(hours=hours)
- self.reprname = reprname
- self.stdname = stdname
- self.dstname = dstname
-
- def __repr__(self):
- return self.reprname
-
- def tzname(self, dt):
- if self.dst(dt):
- return self.dstname
- else:
- return self.stdname
-
- def utcoffset(self, dt):
- return self.stdoffset + self.dst(dt)
-
- def dst(self, dt):
- if dt is None or dt.tzinfo is None:
- # An exception instead may be sensible here, in one or more of
- # the cases.
- return ZERO
- assert dt.tzinfo is self
-
- # Find first Sunday in April.
- start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
- assert start.weekday() == 6 and start.month == 4 and start.day <= 7
-
- # Find last Sunday in October.
- end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
- assert end.weekday() == 6 and end.month == 10 and end.day >= 25
-
- # Can't compare naive to aware objects, so strip the timezone from
- # dt first.
- if start <= dt.replace(tzinfo=None) < end:
- return HOUR
- else:
- return ZERO
-
-Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
-Central = USTimeZone(-6, "Central", "CST", "CDT")
-Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
-Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")
-utc_real = FixedOffset(0, "UTC", 0)
-# For better test coverage, we want another flavor of UTC that's west of
-# the Eastern and Pacific timezones.
-utc_fake = FixedOffset(-12*60, "UTCfake", 0)
-
-class TestTimezoneConversions(unittest.TestCase):
- # The DST switch times for 2002, in std time.
- dston = datetime(2002, 4, 7, 2)
- dstoff = datetime(2002, 10, 27, 1)
-
- theclass = datetime
-
- # Check a time that's inside DST.
- def checkinside(self, dt, tz, utc, dston, dstoff):
- self.assertEqual(dt.dst(), HOUR)
-
- # Conversion to our own timezone is always an identity.
- self.assertEqual(dt.astimezone(tz), dt)
-
- asutc = dt.astimezone(utc)
- there_and_back = asutc.astimezone(tz)
-
- # Conversion to UTC and back isn't always an identity here,
- # because there are redundant spellings (in local time) of
- # UTC time when DST begins: the clock jumps from 1:59:59
- # to 3:00:00, and a local time of 2:MM:SS doesn't really
- # make sense then. The classes above treat 2:MM:SS as
- # daylight time then (it's "after 2am"), really an alias
- # for 1:MM:SS standard time. The latter form is what
- # conversion back from UTC produces.
- if dt.date() == dston.date() and dt.hour == 2:
- # We're in the redundant hour, and coming back from
- # UTC gives the 1:MM:SS standard-time spelling.
- self.assertEqual(there_and_back + HOUR, dt)
- # Although during was considered to be in daylight
- # time, there_and_back is not.
- self.assertEqual(there_and_back.dst(), ZERO)
- # They're the same times in UTC.
- self.assertEqual(there_and_back.astimezone(utc),
- dt.astimezone(utc))
- else:
- # We're not in the redundant hour.
- self.assertEqual(dt, there_and_back)
-
- # Because we have a redundant spelling when DST begins, there is
- # (unfortunately) an hour when DST ends that can't be spelled at all in
- # local time. When DST ends, the clock jumps from 1:59 back to 1:00
- # again. The hour 1:MM DST has no spelling then: 1:MM is taken to be
- # standard time. 1:MM DST == 0:MM EST, but 0:MM is taken to be
- # daylight time. The hour 1:MM daylight == 0:MM standard can't be
- # expressed in local time. Nevertheless, we want conversion back
- # from UTC to mimic the local clock's "repeat an hour" behavior.
- nexthour_utc = asutc + HOUR
- nexthour_tz = nexthour_utc.astimezone(tz)
- if dt.date() == dstoff.date() and dt.hour == 0:
- # We're in the hour before the last DST hour. The last DST hour
- # is ineffable. We want the conversion back to repeat 1:MM.
- self.assertEqual(nexthour_tz, dt.replace(hour=1))
- nexthour_utc += HOUR
- nexthour_tz = nexthour_utc.astimezone(tz)
- self.assertEqual(nexthour_tz, dt.replace(hour=1))
- else:
- self.assertEqual(nexthour_tz - dt, HOUR)
-
- # Check a time that's outside DST.
- def checkoutside(self, dt, tz, utc):
- self.assertEqual(dt.dst(), ZERO)
-
- # Conversion to our own timezone is always an identity.
- self.assertEqual(dt.astimezone(tz), dt)
-
- # Converting to UTC and back is an identity too.
- asutc = dt.astimezone(utc)
- there_and_back = asutc.astimezone(tz)
- self.assertEqual(dt, there_and_back)
-
- def convert_between_tz_and_utc(self, tz, utc):
- dston = self.dston.replace(tzinfo=tz)
- # Because 1:MM on the day DST ends is taken as being standard time,
- # there is no spelling in tz for the last hour of daylight time.
- # For purposes of the test, the last hour of DST is 0:MM, which is
- # taken as being daylight time (and 1:MM is taken as being standard
- # time).
- dstoff = self.dstoff.replace(tzinfo=tz)
- for delta in (timedelta(weeks=13),
- DAY,
- HOUR,
- timedelta(minutes=1),
- timedelta(microseconds=1)):
-
- self.checkinside(dston, tz, utc, dston, dstoff)
- for during in dston + delta, dstoff - delta:
- self.checkinside(during, tz, utc, dston, dstoff)
-
- self.checkoutside(dstoff, tz, utc)
- for outside in dston - delta, dstoff + delta:
- self.checkoutside(outside, tz, utc)
-
- def test_easy(self):
- # Despite the name of this test, the endcases are excruciating.
- self.convert_between_tz_and_utc(Eastern, utc_real)
- self.convert_between_tz_and_utc(Pacific, utc_real)
- self.convert_between_tz_and_utc(Eastern, utc_fake)
- self.convert_between_tz_and_utc(Pacific, utc_fake)
- # The next is really dancing near the edge. It works because
- # Pacific and Eastern are far enough apart that their "problem
- # hours" don't overlap.
- self.convert_between_tz_and_utc(Eastern, Pacific)
- self.convert_between_tz_and_utc(Pacific, Eastern)
- # OTOH, these fail! Don't enable them. The difficulty is that
- # the edge case tests assume that every hour is representable in
- # the "utc" class. This is always true for a fixed-offset tzinfo
- # class (lke utc_real and utc_fake), but not for Eastern or Central.
- # For these adjacent DST-aware time zones, the range of time offsets
- # tested ends up creating hours in the one that aren't representable
- # in the other. For the same reason, we would see failures in the
- # Eastern vs Pacific tests too if we added 3*HOUR to the list of
- # offset deltas in convert_between_tz_and_utc().
- #
- # self.convert_between_tz_and_utc(Eastern, Central) # can't work
- # self.convert_between_tz_and_utc(Central, Eastern) # can't work
-
- def test_tricky(self):
- # 22:00 on day before daylight starts.
- fourback = self.dston - timedelta(hours=4)
- ninewest = FixedOffset(-9*60, "-0900", 0)
- fourback = fourback.replace(tzinfo=ninewest)
- # 22:00-0900 is 7:00 UTC == 2:00 EST == 3:00 DST. Since it's "after
- # 2", we should get the 3 spelling.
- # If we plug 22:00 the day before into Eastern, it "looks like std
- # time", so its offset is returned as -5, and -5 - -9 = 4. Adding 4
- # to 22:00 lands on 2:00, which makes no sense in local time (the
- # local clock jumps from 1 to 3). The point here is to make sure we
- # get the 3 spelling.
- expected = self.dston.replace(hour=3)
- got = fourback.astimezone(Eastern).replace(tzinfo=None)
- self.assertEqual(expected, got)
-
- # Similar, but map to 6:00 UTC == 1:00 EST == 2:00 DST. In that
- # case we want the 1:00 spelling.
- sixutc = self.dston.replace(hour=6, tzinfo=utc_real)
- # Now 6:00 "looks like daylight", so the offset wrt Eastern is -4,
- # and adding -4-0 == -4 gives the 2:00 spelling. We want the 1:00 EST
- # spelling.
- expected = self.dston.replace(hour=1)
- got = sixutc.astimezone(Eastern).replace(tzinfo=None)
- self.assertEqual(expected, got)
-
- # Now on the day DST ends, we want "repeat an hour" behavior.
- # UTC 4:MM 5:MM 6:MM 7:MM checking these
- # EST 23:MM 0:MM 1:MM 2:MM
- # EDT 0:MM 1:MM 2:MM 3:MM
- # wall 0:MM 1:MM 1:MM 2:MM against these
- for utc in utc_real, utc_fake:
- for tz in Eastern, Pacific:
- first_std_hour = self.dstoff - timedelta(hours=2) # 23:MM
- # Convert that to UTC.
- first_std_hour -= tz.utcoffset(None)
- # Adjust for possibly fake UTC.
- asutc = first_std_hour + utc.utcoffset(None)
- # First UTC hour to convert; this is 4:00 when utc=utc_real &
- # tz=Eastern.
- asutcbase = asutc.replace(tzinfo=utc)
- for tzhour in (0, 1, 1, 2):
- expectedbase = self.dstoff.replace(hour=tzhour)
- for minute in 0, 30, 59:
- expected = expectedbase.replace(minute=minute)
- asutc = asutcbase.replace(minute=minute)
- astz = asutc.astimezone(tz)
- self.assertEqual(astz.replace(tzinfo=None), expected)
- asutcbase += HOUR
-
-
- def test_bogus_dst(self):
- class ok(tzinfo):
- def utcoffset(self, dt): return HOUR
- def dst(self, dt): return HOUR
-
- now = self.theclass.now().replace(tzinfo=utc_real)
- # Doesn't blow up.
- now.astimezone(ok())
-
- # Does blow up.
- class notok(ok):
- def dst(self, dt): return None
- self.assertRaises(ValueError, now.astimezone, notok())
-
- # Sometimes blow up. In the following, tzinfo.dst()
- # implementation may return None or not Nonedepending on
- # whether DST is assumed to be in effect. In this situation,
- # a ValueError should be raised by astimezone().
- class tricky_notok(ok):
- def dst(self, dt):
- if dt.year == 2000:
- return None
- else:
- return 10*HOUR
- dt = self.theclass(2001, 1, 1).replace(tzinfo=utc_real)
- self.assertRaises(ValueError, dt.astimezone, tricky_notok())
-
- def test_fromutc(self):
- self.assertRaises(TypeError, Eastern.fromutc) # not enough args
- now = datetime.utcnow().replace(tzinfo=utc_real)
- self.assertRaises(ValueError, Eastern.fromutc, now) # wrong tzinfo
- now = now.replace(tzinfo=Eastern) # insert correct tzinfo
- enow = Eastern.fromutc(now) # doesn't blow up
- self.assertEqual(enow.tzinfo, Eastern) # has right tzinfo member
- self.assertRaises(TypeError, Eastern.fromutc, now, now) # too many args
- self.assertRaises(TypeError, Eastern.fromutc, date.today()) # wrong type
-
- # Always converts UTC to standard time.
- class FauxUSTimeZone(USTimeZone):
- def fromutc(self, dt):
- return dt + self.stdoffset
- FEastern = FauxUSTimeZone(-5, "FEastern", "FEST", "FEDT")
-
- # UTC 4:MM 5:MM 6:MM 7:MM 8:MM 9:MM
- # EST 23:MM 0:MM 1:MM 2:MM 3:MM 4:MM
- # EDT 0:MM 1:MM 2:MM 3:MM 4:MM 5:MM
-
- # Check around DST start.
- start = self.dston.replace(hour=4, tzinfo=Eastern)
- fstart = start.replace(tzinfo=FEastern)
- for wall in 23, 0, 1, 3, 4, 5:
- expected = start.replace(hour=wall)
- if wall == 23:
- expected -= timedelta(days=1)
- got = Eastern.fromutc(start)
- self.assertEqual(expected, got)
-
- expected = fstart + FEastern.stdoffset
- got = FEastern.fromutc(fstart)
- self.assertEqual(expected, got)
-
- # Ensure astimezone() calls fromutc() too.
- got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
- self.assertEqual(expected, got)
-
- start += HOUR
- fstart += HOUR
-
- # Check around DST end.
- start = self.dstoff.replace(hour=4, tzinfo=Eastern)
- fstart = start.replace(tzinfo=FEastern)
- for wall in 0, 1, 1, 2, 3, 4:
- expected = start.replace(hour=wall)
- got = Eastern.fromutc(start)
- self.assertEqual(expected, got)
-
- expected = fstart + FEastern.stdoffset
- got = FEastern.fromutc(fstart)
- self.assertEqual(expected, got)
-
- # Ensure astimezone() calls fromutc() too.
- got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
- self.assertEqual(expected, got)
-
- start += HOUR
- fstart += HOUR
-
-
-#############################################################################
-# oddballs
-
-class Oddballs(unittest.TestCase):
-
- def test_bug_1028306(self):
- # Trying to compare a date to a datetime should act like a mixed-
- # type comparison, despite that datetime is a subclass of date.
- as_date = date.today()
- as_datetime = datetime.combine(as_date, time())
- self.assertTrue(as_date != as_datetime)
- self.assertTrue(as_datetime != as_date)
- self.assertTrue(not as_date == as_datetime)
- self.assertTrue(not as_datetime == as_date)
- self.assertRaises(TypeError, lambda: as_date < as_datetime)
- self.assertRaises(TypeError, lambda: as_datetime < as_date)
- self.assertRaises(TypeError, lambda: as_date <= as_datetime)
- self.assertRaises(TypeError, lambda: as_datetime <= as_date)
- self.assertRaises(TypeError, lambda: as_date > as_datetime)
- self.assertRaises(TypeError, lambda: as_datetime > as_date)
- self.assertRaises(TypeError, lambda: as_date >= as_datetime)
- self.assertRaises(TypeError, lambda: as_datetime >= as_date)
-
- # Neverthelss, comparison should work with the base-class (date)
- # projection if use of a date method is forced.
- self.assertEqual(as_date.__eq__(as_datetime), True)
- different_day = (as_date.day + 1) % 20 + 1
- as_different = as_datetime.replace(day= different_day)
- self.assertEqual(as_date.__eq__(as_different), False)
-
- # And date should compare with other subclasses of date. If a
- # subclass wants to stop this, it's up to the subclass to do so.
- date_sc = SubclassDate(as_date.year, as_date.month, as_date.day)
- self.assertEqual(as_date, date_sc)
- self.assertEqual(date_sc, as_date)
-
- # Ditto for datetimes.
- datetime_sc = SubclassDatetime(as_datetime.year, as_datetime.month,
- as_date.day, 0, 0, 0)
- self.assertEqual(as_datetime, datetime_sc)
- self.assertEqual(datetime_sc, as_datetime)
+import sys
+from test.support import import_fresh_module, run_unittest
+TESTS = 'test.datetimetester'
+# XXX: import_fresh_module() is supposed to leave sys.module cache untouched,
+# XXX: but it does not, so we have to save and restore it ourselves.
+save_sys_modules = sys.modules.copy()
+try:
+ pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'],
+ blocked=['_datetime'])
+ fast_tests = import_fresh_module(TESTS, fresh=['datetime',
+ '_datetime', '_strptime'])
+finally:
+ sys.modules.clear()
+ sys.modules.update(save_sys_modules)
+test_modules = [pure_tests, fast_tests]
+test_suffixes = ["_Pure", "_Fast"]
+
+for module, suffix in zip(test_modules, test_suffixes):
+ for name, cls in module.__dict__.items():
+ if isinstance(cls, type) and issubclass(cls, unittest.TestCase):
+ name += suffix
+ cls.__name__ = name
+ globals()[name] = cls
+ def setUp(self, module=module, setup=cls.setUp):
+ self._save_sys_modules = sys.modules.copy()
+ sys.modules[TESTS] = module
+ sys.modules['datetime'] = module.datetime_module
+ sys.modules['_strptime'] = module._strptime
+ setup(self)
+ def tearDown(self, teardown=cls.tearDown):
+ teardown(self)
+ sys.modules.clear()
+ sys.modules.update(self._save_sys_modules)
+ cls.setUp = setUp
+ cls.tearDown = tearDown
def test_main():
- support.run_unittest(__name__)
+ run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index ce48cfd5ce..26d4c14623 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test script for the dbm.open function based on testdumbdbm.py"""
import os
@@ -101,7 +101,7 @@ class AnyDBMTestCase(unittest.TestCase):
self.init_db()
f = dbm.open(_fname, 'r')
key = "a".encode("ascii")
- assert(key in f)
+ self.assertIn(key, f)
assert(f[key] == b"Python:")
f.close()
@@ -131,7 +131,7 @@ class WhichDBTestCase(unittest.TestCase):
name = module.__name__
if name == 'dbm.dumb':
continue # whichdb can't support dbm.dumb
- test.support.unlink(_fname)
+ delete_files()
f = module.open(_fname, 'c')
f.close()
self.assertEqual(name, dbm.whichdb(_fname))
@@ -139,7 +139,7 @@ class WhichDBTestCase(unittest.TestCase):
f = module.open(_fname, 'w')
f[b"1"] = b"1"
# and test that we can find it
- self.assertTrue(b"1" in f)
+ self.assertIn(b"1", f)
# and read it
self.assertTrue(f[b"1"] == b"1")
f.close()
@@ -162,9 +162,9 @@ class WhichDBTestCase(unittest.TestCase):
self.d[k] = v
self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a))
for k, v in a:
- self.assertTrue(k in self.d)
+ self.assertIn(k, self.d)
self.assertEqual(self.d[k], v)
- self.assertTrue(b'xxx' not in self.d)
+ self.assertNotIn(b'xxx', self.d)
self.assertRaises(KeyError, lambda: self.d[b'xxx'])
self.d.close()
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
index 956eec6312..6b981c429d 100644
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test script for the dumbdbm module
Original by Roger E. Masse
"""
@@ -93,7 +93,7 @@ class DumbDBMTestCase(unittest.TestCase):
def test_write_contains(self):
f = dumbdbm.open(_fname)
f[b'1'] = b'hello'
- self.assertTrue(b'1' in f)
+ self.assertIn(b'1', f)
f.close()
def test_write_write_read(self):
@@ -118,7 +118,7 @@ class DumbDBMTestCase(unittest.TestCase):
f['1'] = 'a'
f.close()
f = dumbdbm.open(_fname, 'r')
- self.assertTrue('\u00fc' in f)
+ self.assertIn('\u00fc', f)
self.assertEqual(f['\u00fc'.encode('utf-8')],
self._dict['\u00fc'.encode('utf-8')])
self.assertEqual(f[b'1'], b'a')
@@ -132,12 +132,14 @@ class DumbDBMTestCase(unittest.TestCase):
f.close()
# Mangle the file by changing the line separator to Windows or Unix
- data = io.open(_fname + '.dir', 'rb').read()
+ with io.open(_fname + '.dir', 'rb') as file:
+ data = file.read()
if os.linesep == '\n':
data = data.replace(b'\n', b'\r\n')
else:
data = data.replace(b'\r\n', b'\n')
- io.open(_fname + '.dir', 'wb').write(data)
+ with io.open(_fname + '.dir', 'wb') as file:
+ file.write(data)
f = dumbdbm.open(_fname)
self.assertEqual(f[b'1'], b'hello')
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py
index 2173b92afa..ce96ce465e 100755
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -24,14 +24,18 @@ class TestGdbm(unittest.TestCase):
self.g[b'bytes'] = b'data'
key_set = set(self.g.keys())
self.assertEqual(key_set, set([b'a', b'bytes', b'12345678910']))
- self.assertTrue(b'a' in self.g)
+ self.assertIn(b'a', self.g)
self.assertEqual(self.g[b'bytes'], b'data')
key = self.g.firstkey()
while key:
- self.assertTrue(key in key_set)
+ self.assertIn(key, key_set)
key_set.remove(key)
key = self.g.nextkey(key)
self.assertRaises(KeyError, lambda: self.g['xxx'])
+ # get() and setdefault() work as in the dict interface
+ self.assertEqual(self.g.get(b'xxx', b'foo'), b'foo')
+ self.assertEqual(self.g.setdefault(b'xxx', b'foo'), b'foo')
+ self.assertEqual(self.g[b'xxx'], b'foo')
def test_error_conditions(self):
# Try to open a non-existent database.
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
index 141d4b3034..00dcbd2160 100755
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -24,7 +24,7 @@ class DbmTestCase(unittest.TestCase):
self.d[b'bytes'] = b'data'
self.d['12345678910'] = '019237410982340912840198242'
self.d.keys()
- self.assertTrue(b'a' in self.d)
+ self.assertIn(b'a', self.d)
self.assertEqual(self.d[b'bytes'], b'data')
self.d.close()
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index ec381e4139..e46cd91e5e 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -24,14 +24,17 @@ you're working through IDLE, you can import this test module and call test_main(
with the corresponding argument.
"""
-import glob
import math
import os, sys
+import operator
+import warnings
import pickle, copy
import unittest
from decimal import *
import numbers
-from test.support import run_unittest, run_doctest, is_resource_enabled
+from test.support import (run_unittest, run_doctest, is_resource_enabled,
+ requires_IEEE_754)
+from test.support import check_warnings
import random
try:
import threading
@@ -402,7 +405,7 @@ class DecimalTest(unittest.TestCase):
def change_max_exponent(self, exp):
self.context.Emax = exp
def change_clamp(self, clamp):
- self.context._clamp = clamp
+ self.context.clamp = clamp
@@ -493,6 +496,12 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
self.assertRaises(ValueError, Decimal, (1, (4, 10, 4, 9, 1), 2) )
self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 'a', 1), 2) )
+ def test_explicit_from_bool(self):
+ self.assertIs(bool(Decimal(0)), False)
+ self.assertIs(bool(Decimal(1)), True)
+ self.assertEqual(Decimal(False), Decimal(0))
+ self.assertEqual(Decimal(True), Decimal(1))
+
def test_explicit_from_Decimal(self):
#positive
@@ -519,6 +528,27 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
self.assertEqual(str(e), '0')
self.assertNotEqual(id(d), id(e))
+ @requires_IEEE_754
+ def test_explicit_from_float(self):
+ r = Decimal(0.1)
+ self.assertEqual(type(r), Decimal)
+ self.assertEqual(str(r),
+ '0.1000000000000000055511151231257827021181583404541015625')
+ self.assertTrue(Decimal(float('nan')).is_qnan())
+ self.assertTrue(Decimal(float('inf')).is_infinite())
+ self.assertTrue(Decimal(float('-inf')).is_infinite())
+ self.assertEqual(str(Decimal(float('nan'))),
+ str(Decimal('NaN')))
+ self.assertEqual(str(Decimal(float('inf'))),
+ str(Decimal('Infinity')))
+ self.assertEqual(str(Decimal(float('-inf'))),
+ str(Decimal('-Infinity')))
+ self.assertEqual(str(Decimal(float('-0.0'))),
+ str(Decimal('-0')))
+ for i in range(200):
+ x = random.expovariate(0.01) * (random.random() * 2.0 - 1.0)
+ self.assertEqual(x, float(Decimal(x))) # roundtrip
+
def test_explicit_context_create_decimal(self):
nc = copy.copy(getcontext())
@@ -535,7 +565,7 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
# from int
d = nc.create_decimal(456)
- self.assertTrue(isinstance(d, Decimal))
+ self.assertIsInstance(d, Decimal)
self.assertEqual(nc.create_decimal(45678),
nc.create_decimal('457E+2'))
@@ -732,6 +762,7 @@ class DecimalFormatTest(unittest.TestCase):
('', '1.00', '1.00'),
# test alignment and padding
+ ('6', '123', ' 123'),
('<6', '123', '123 '),
('>6', '123', ' 123'),
('^6', '123', ' 123 '),
@@ -761,7 +792,7 @@ class DecimalFormatTest(unittest.TestCase):
(',', '-1234567', '-1,234,567'),
(',', '-123456', '-123,456'),
('7,', '123456', '123,456'),
- ('8,', '123456', '123,456 '),
+ ('8,', '123456', ' 123,456'),
('08,', '123456', '0,123,456'), # special case: extra 0 needed
('+08,', '123456', '+123,456'), # but not if there's a sign
(' 08,', '123456', ' 123,456'),
@@ -783,6 +814,18 @@ class DecimalFormatTest(unittest.TestCase):
# issue 6850
('a=-7.0', '0.12345', 'aaaa0.1'),
+
+ # Issue 7094: Alternate formatting (specified by #)
+ ('.0e', '1.0', '1e+0'),
+ ('#.0e', '1.0', '1.e+0'),
+ ('.0f', '1.0', '1'),
+ ('#.0f', '1.0', '1.'),
+ ('g', '1.1', '1.1'),
+ ('#g', '1.1', '1.1'),
+ ('.0g', '1', '1'),
+ ('#.0g', '1', '1.'),
+ ('.0%', '1.0', '100%'),
+ ('#.0%', '1.0', '100.%'),
]
for fmt, d, result in test_values:
self.assertEqual(format(Decimal(d), fmt), result)
@@ -1084,18 +1127,62 @@ class DecimalArithmeticOperatorsTest(unittest.TestCase):
self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) # abs
def test_nan_comparisons(self):
+ # comparisons involving signaling nans signal InvalidOperation
+
+ # order comparisons (<, <=, >, >=) involving only quiet nans
+ # also signal InvalidOperation
+
+ # equality comparisons (==, !=) involving only quiet nans
+ # don't signal, but return False or True respectively.
+
n = Decimal('NaN')
s = Decimal('sNaN')
i = Decimal('Inf')
f = Decimal('2')
- for x, y in [(n, n), (n, i), (i, n), (n, f), (f, n),
- (s, n), (n, s), (s, i), (i, s), (s, f), (f, s), (s, s)]:
- self.assertTrue(x != y)
- self.assertTrue(not (x == y))
- self.assertTrue(not (x < y))
- self.assertTrue(not (x <= y))
- self.assertTrue(not (x > y))
- self.assertTrue(not (x >= y))
+
+ qnan_pairs = (n, n), (n, i), (i, n), (n, f), (f, n)
+ snan_pairs = (s, n), (n, s), (s, i), (i, s), (s, f), (f, s), (s, s)
+ order_ops = operator.lt, operator.le, operator.gt, operator.ge
+ equality_ops = operator.eq, operator.ne
+
+ # results when InvalidOperation is not trapped
+ for x, y in qnan_pairs + snan_pairs:
+ for op in order_ops + equality_ops:
+ got = op(x, y)
+ expected = True if op is operator.ne else False
+ self.assertIs(expected, got,
+ "expected {0!r} for operator.{1}({2!r}, {3!r}); "
+ "got {4!r}".format(
+ expected, op.__name__, x, y, got))
+
+ # repeat the above, but this time trap the InvalidOperation
+ with localcontext() as ctx:
+ ctx.traps[InvalidOperation] = 1
+
+ for x, y in qnan_pairs:
+ for op in equality_ops:
+ got = op(x, y)
+ expected = True if op is operator.ne else False
+ self.assertIs(expected, got,
+ "expected {0!r} for "
+ "operator.{1}({2!r}, {3!r}); "
+ "got {4!r}".format(
+ expected, op.__name__, x, y, got))
+
+ for x, y in snan_pairs:
+ for op in equality_ops:
+ self.assertRaises(InvalidOperation, operator.eq, x, y)
+ self.assertRaises(InvalidOperation, operator.ne, x, y)
+
+ for x, y in qnan_pairs + snan_pairs:
+ for op in order_ops:
+ self.assertRaises(InvalidOperation, op, x, y)
+
+ def test_copy_sign(self):
+ d = Decimal(1).copy_sign(Decimal(-2))
+
+ self.assertEqual(Decimal(1).copy_sign(-2), d)
+ self.assertRaises(TypeError, Decimal(1).copy_sign, '-2')
# The following are two functions used to test threading in the next class
@@ -1168,18 +1255,18 @@ class DecimalUsabilityTest(unittest.TestCase):
dc = Decimal('45')
#two Decimals
- self.assertTrue(dc > da)
- self.assertTrue(dc >= da)
- self.assertTrue(da < dc)
- self.assertTrue(da <= dc)
+ self.assertGreater(dc, da)
+ self.assertGreaterEqual(dc, da)
+ self.assertLess(da, dc)
+ self.assertLessEqual(da, dc)
self.assertEqual(da, db)
- self.assertTrue(da != dc)
- self.assertTrue(da <= db)
- self.assertTrue(da >= db)
+ self.assertNotEqual(da, dc)
+ self.assertLessEqual(da, db)
+ self.assertGreaterEqual(da, db)
#a Decimal and an int
- self.assertTrue(dc > 23)
- self.assertTrue(23 < dc)
+ self.assertGreater(dc, 23)
+ self.assertLess(23, dc)
self.assertEqual(dc, 45)
#a Decimal and uncomparable
@@ -1195,6 +1282,23 @@ class DecimalUsabilityTest(unittest.TestCase):
a.sort()
self.assertEqual(a, b)
+ def test_decimal_float_comparison(self):
+ da = Decimal('0.25')
+ db = Decimal('3.0')
+ self.assertLess(da, 3.0)
+ self.assertLessEqual(da, 3.0)
+ self.assertGreater(db, 0.25)
+ self.assertGreaterEqual(db, 0.25)
+ self.assertNotEqual(da, 1.5)
+ self.assertEqual(da, 0.25)
+ self.assertGreater(3.0, da)
+ self.assertGreaterEqual(3.0, da)
+ self.assertLess(0.25, db)
+ self.assertLessEqual(0.25, db)
+ self.assertNotEqual(0.25, db)
+ self.assertEqual(3.0, db)
+ self.assertNotEqual(0.1, Decimal('0.1'))
+
def test_copy_and_deepcopy_methods(self):
d = Decimal('43.24')
c = copy.copy(d)
@@ -1203,15 +1307,26 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertEqual(id(dc), id(d))
def test_hash_method(self):
+ def hashit(d):
+ a = hash(d)
+ b = d.__hash__()
+ self.assertEqual(a, b)
+ return a
+
#just that it's hashable
- hash(Decimal(23))
+ hashit(Decimal(23))
+ hashit(Decimal('Infinity'))
+ hashit(Decimal('-Infinity'))
+ hashit(Decimal('nan123'))
+ hashit(Decimal('-NaN'))
test_values = [Decimal(sign*(2**m + n))
for m in [0, 14, 15, 16, 17, 30, 31,
- 32, 33, 62, 63, 64, 65, 66]
+ 32, 33, 61, 62, 63, 64, 65, 66]
for n in range(-10, 10)
for sign in [-1, 1]]
test_values.extend([
+ Decimal("-1"), # ==> -2
Decimal("-0"), # zeros
Decimal("0.00"),
Decimal("-0.000"),
@@ -1235,13 +1350,22 @@ class DecimalUsabilityTest(unittest.TestCase):
# check that hash(d) == hash(int(d)) for integral values
for value in test_values:
- self.assertEqual(hash(value), hash(int(value)))
+ self.assertEqual(hashit(value), hashit(int(value)))
#the same hash that to an int
- self.assertEqual(hash(Decimal(23)), hash(23))
- self.assertRaises(TypeError, hash, Decimal('NaN'))
- self.assertTrue(hash(Decimal('Inf')))
- self.assertTrue(hash(Decimal('-Inf')))
+ self.assertEqual(hashit(Decimal(23)), hashit(23))
+ self.assertRaises(TypeError, hash, Decimal('sNaN'))
+ self.assertTrue(hashit(Decimal('Inf')))
+ self.assertTrue(hashit(Decimal('-Inf')))
+
+ # check that the hashes of a Decimal float match when they
+ # represent exactly the same values
+ test_strings = ['inf', '-Inf', '0.0', '-.0e1',
+ '34.0', '2.5', '112390.625', '-0.515625']
+ for s in test_strings:
+ f = float(s)
+ d = Decimal(s)
+ self.assertEqual(hashit(f), hashit(d))
# check that the value of the hash doesn't depend on the
# current context (issue #1757)
@@ -1250,11 +1374,11 @@ class DecimalUsabilityTest(unittest.TestCase):
x = Decimal("123456789.1")
c.prec = 6
- h1 = hash(x)
+ h1 = hashit(x)
c.prec = 10
- h2 = hash(x)
+ h2 = hashit(x)
c.prec = 16
- h3 = hash(x)
+ h3 = hashit(x)
self.assertEqual(h1, h2)
self.assertEqual(h1, h3)
@@ -1268,16 +1392,16 @@ class DecimalUsabilityTest(unittest.TestCase):
l2 = 28
#between Decimals
- self.assertTrue(min(d1,d2) is d1)
- self.assertTrue(min(d2,d1) is d1)
- self.assertTrue(max(d1,d2) is d2)
- self.assertTrue(max(d2,d1) is d2)
+ self.assertIs(min(d1,d2), d1)
+ self.assertIs(min(d2,d1), d1)
+ self.assertIs(max(d1,d2), d2)
+ self.assertIs(max(d2,d1), d2)
#between Decimal and long
- self.assertTrue(min(d1,l2) is d1)
- self.assertTrue(min(l2,d1) is d1)
- self.assertTrue(max(l1,d2) is d2)
- self.assertTrue(max(d2,l1) is d2)
+ self.assertIs(min(d1,l2), d1)
+ self.assertIs(min(l2,d1), d1)
+ self.assertIs(max(l1,d2), d2)
+ self.assertIs(max(d2,l1), d2)
def test_as_nonzero(self):
#as false
@@ -1293,7 +1417,7 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertEqual(repr(d), "Decimal('15.32')") # repr
def test_tonum_methods(self):
- #Test float, int and long methods.
+ #Test float and int methods.
d1 = Decimal('66')
d2 = Decimal('15.32')
@@ -1302,10 +1426,6 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertEqual(int(d1), 66)
self.assertEqual(int(d2), 15)
- #long
- self.assertEqual(int(d1), 66)
- self.assertEqual(int(d2), 15)
-
#float
self.assertEqual(float(d1), 66)
self.assertEqual(float(d2), 15.32)
@@ -1538,10 +1658,10 @@ class DecimalUsabilityTest(unittest.TestCase):
d1 = MyDecimal(1)
d2 = MyDecimal(2)
d = d1 + d2
- self.assertTrue(type(d) is Decimal)
+ self.assertIs(type(d), Decimal)
d = d1.max(d2)
- self.assertTrue(type(d) is Decimal)
+ self.assertIs(type(d), Decimal)
def test_implicit_context(self):
# Check results when context given implicitly. (Issue 2478)
@@ -1601,9 +1721,9 @@ class DecimalPythonAPItests(unittest.TestCase):
def test_abc(self):
self.assertTrue(issubclass(Decimal, numbers.Number))
- self.assertTrue(not issubclass(Decimal, numbers.Real))
- self.assertTrue(isinstance(Decimal(0), numbers.Number))
- self.assertTrue(not isinstance(Decimal(0), numbers.Real))
+ self.assertFalse(issubclass(Decimal, numbers.Real))
+ self.assertIsInstance(Decimal(0), numbers.Number)
+ self.assertNotIsInstance(Decimal(0), numbers.Real)
def test_pickle(self):
d = Decimal('-3.141590000')
@@ -1696,8 +1816,8 @@ class ContextAPItests(unittest.TestCase):
self.assertEqual(v1, v2)
def test_equality_with_other_types(self):
- self.assertTrue(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}])
- self.assertTrue(Decimal(10) not in ['a', 1.0, (1,2), {}])
+ self.assertIn(Decimal(10), ['a', 1.0, Decimal(10), (1,2), {}])
+ self.assertNotIn(Decimal(10), ['a', 1.0, (1,2), {}])
def test_copy(self):
# All copies should be deep
@@ -1707,6 +1827,458 @@ class ContextAPItests(unittest.TestCase):
self.assertNotEqual(id(c.flags), id(d.flags))
self.assertNotEqual(id(c.traps), id(d.traps))
+ def test__clamp(self):
+ # In Python 3.2, the private attribute `_clamp` was made
+ # public (issue 8540), with the old `_clamp` becoming a
+ # property wrapping `clamp`. For the duration of Python 3.2
+ # only, the attribute should be gettable/settable via both
+ # `clamp` and `_clamp`; in Python 3.3, `_clamp` should be
+ # removed.
+ c = Context(clamp = 0)
+ self.assertEqual(c.clamp, 0)
+
+ with check_warnings(("", DeprecationWarning)):
+ c._clamp = 1
+ self.assertEqual(c.clamp, 1)
+ with check_warnings(("", DeprecationWarning)):
+ self.assertEqual(c._clamp, 1)
+ c.clamp = 0
+ self.assertEqual(c.clamp, 0)
+ with check_warnings(("", DeprecationWarning)):
+ self.assertEqual(c._clamp, 0)
+
+ def test_abs(self):
+ c = Context()
+ d = c.abs(Decimal(-1))
+ self.assertEqual(c.abs(-1), d)
+ self.assertRaises(TypeError, c.abs, '-1')
+
+ def test_add(self):
+ c = Context()
+ d = c.add(Decimal(1), Decimal(1))
+ self.assertEqual(c.add(1, 1), d)
+ self.assertEqual(c.add(Decimal(1), 1), d)
+ self.assertEqual(c.add(1, Decimal(1)), d)
+ self.assertRaises(TypeError, c.add, '1', 1)
+ self.assertRaises(TypeError, c.add, 1, '1')
+
+ def test_compare(self):
+ c = Context()
+ d = c.compare(Decimal(1), Decimal(1))
+ self.assertEqual(c.compare(1, 1), d)
+ self.assertEqual(c.compare(Decimal(1), 1), d)
+ self.assertEqual(c.compare(1, Decimal(1)), d)
+ self.assertRaises(TypeError, c.compare, '1', 1)
+ self.assertRaises(TypeError, c.compare, 1, '1')
+
+ def test_compare_signal(self):
+ c = Context()
+ d = c.compare_signal(Decimal(1), Decimal(1))
+ self.assertEqual(c.compare_signal(1, 1), d)
+ self.assertEqual(c.compare_signal(Decimal(1), 1), d)
+ self.assertEqual(c.compare_signal(1, Decimal(1)), d)
+ self.assertRaises(TypeError, c.compare_signal, '1', 1)
+ self.assertRaises(TypeError, c.compare_signal, 1, '1')
+
+ def test_compare_total(self):
+ c = Context()
+ d = c.compare_total(Decimal(1), Decimal(1))
+ self.assertEqual(c.compare_total(1, 1), d)
+ self.assertEqual(c.compare_total(Decimal(1), 1), d)
+ self.assertEqual(c.compare_total(1, Decimal(1)), d)
+ self.assertRaises(TypeError, c.compare_total, '1', 1)
+ self.assertRaises(TypeError, c.compare_total, 1, '1')
+
+ def test_compare_total_mag(self):
+ c = Context()
+ d = c.compare_total_mag(Decimal(1), Decimal(1))
+ self.assertEqual(c.compare_total_mag(1, 1), d)
+ self.assertEqual(c.compare_total_mag(Decimal(1), 1), d)
+ self.assertEqual(c.compare_total_mag(1, Decimal(1)), d)
+ self.assertRaises(TypeError, c.compare_total_mag, '1', 1)
+ self.assertRaises(TypeError, c.compare_total_mag, 1, '1')
+
+ def test_copy_abs(self):
+ c = Context()
+ d = c.copy_abs(Decimal(-1))
+ self.assertEqual(c.copy_abs(-1), d)
+ self.assertRaises(TypeError, c.copy_abs, '-1')
+
+ def test_copy_decimal(self):
+ c = Context()
+ d = c.copy_decimal(Decimal(-1))
+ self.assertEqual(c.copy_decimal(-1), d)
+ self.assertRaises(TypeError, c.copy_decimal, '-1')
+
+ def test_copy_negate(self):
+ c = Context()
+ d = c.copy_negate(Decimal(-1))
+ self.assertEqual(c.copy_negate(-1), d)
+ self.assertRaises(TypeError, c.copy_negate, '-1')
+
+ def test_copy_sign(self):
+ c = Context()
+ d = c.copy_sign(Decimal(1), Decimal(-2))
+ self.assertEqual(c.copy_sign(1, -2), d)
+ self.assertEqual(c.copy_sign(Decimal(1), -2), d)
+ self.assertEqual(c.copy_sign(1, Decimal(-2)), d)
+ self.assertRaises(TypeError, c.copy_sign, '1', -2)
+ self.assertRaises(TypeError, c.copy_sign, 1, '-2')
+
+ def test_divide(self):
+ c = Context()
+ d = c.divide(Decimal(1), Decimal(2))
+ self.assertEqual(c.divide(1, 2), d)
+ self.assertEqual(c.divide(Decimal(1), 2), d)
+ self.assertEqual(c.divide(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.divide, '1', 2)
+ self.assertRaises(TypeError, c.divide, 1, '2')
+
+ def test_divide_int(self):
+ c = Context()
+ d = c.divide_int(Decimal(1), Decimal(2))
+ self.assertEqual(c.divide_int(1, 2), d)
+ self.assertEqual(c.divide_int(Decimal(1), 2), d)
+ self.assertEqual(c.divide_int(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.divide_int, '1', 2)
+ self.assertRaises(TypeError, c.divide_int, 1, '2')
+
+ def test_divmod(self):
+ c = Context()
+ d = c.divmod(Decimal(1), Decimal(2))
+ self.assertEqual(c.divmod(1, 2), d)
+ self.assertEqual(c.divmod(Decimal(1), 2), d)
+ self.assertEqual(c.divmod(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.divmod, '1', 2)
+ self.assertRaises(TypeError, c.divmod, 1, '2')
+
+ def test_exp(self):
+ c = Context()
+ d = c.exp(Decimal(10))
+ self.assertEqual(c.exp(10), d)
+ self.assertRaises(TypeError, c.exp, '10')
+
+ def test_fma(self):
+ c = Context()
+ d = c.fma(Decimal(2), Decimal(3), Decimal(4))
+ self.assertEqual(c.fma(2, 3, 4), d)
+ self.assertEqual(c.fma(Decimal(2), 3, 4), d)
+ self.assertEqual(c.fma(2, Decimal(3), 4), d)
+ self.assertEqual(c.fma(2, 3, Decimal(4)), d)
+ self.assertEqual(c.fma(Decimal(2), Decimal(3), 4), d)
+ self.assertRaises(TypeError, c.fma, '2', 3, 4)
+ self.assertRaises(TypeError, c.fma, 2, '3', 4)
+ self.assertRaises(TypeError, c.fma, 2, 3, '4')
+
+ def test_is_finite(self):
+ c = Context()
+ d = c.is_finite(Decimal(10))
+ self.assertEqual(c.is_finite(10), d)
+ self.assertRaises(TypeError, c.is_finite, '10')
+
+ def test_is_infinite(self):
+ c = Context()
+ d = c.is_infinite(Decimal(10))
+ self.assertEqual(c.is_infinite(10), d)
+ self.assertRaises(TypeError, c.is_infinite, '10')
+
+ def test_is_nan(self):
+ c = Context()
+ d = c.is_nan(Decimal(10))
+ self.assertEqual(c.is_nan(10), d)
+ self.assertRaises(TypeError, c.is_nan, '10')
+
+ def test_is_normal(self):
+ c = Context()
+ d = c.is_normal(Decimal(10))
+ self.assertEqual(c.is_normal(10), d)
+ self.assertRaises(TypeError, c.is_normal, '10')
+
+ def test_is_qnan(self):
+ c = Context()
+ d = c.is_qnan(Decimal(10))
+ self.assertEqual(c.is_qnan(10), d)
+ self.assertRaises(TypeError, c.is_qnan, '10')
+
+ def test_is_signed(self):
+ c = Context()
+ d = c.is_signed(Decimal(10))
+ self.assertEqual(c.is_signed(10), d)
+ self.assertRaises(TypeError, c.is_signed, '10')
+
+ def test_is_snan(self):
+ c = Context()
+ d = c.is_snan(Decimal(10))
+ self.assertEqual(c.is_snan(10), d)
+ self.assertRaises(TypeError, c.is_snan, '10')
+
+ def test_is_subnormal(self):
+ c = Context()
+ d = c.is_subnormal(Decimal(10))
+ self.assertEqual(c.is_subnormal(10), d)
+ self.assertRaises(TypeError, c.is_subnormal, '10')
+
+ def test_is_zero(self):
+ c = Context()
+ d = c.is_zero(Decimal(10))
+ self.assertEqual(c.is_zero(10), d)
+ self.assertRaises(TypeError, c.is_zero, '10')
+
+ def test_ln(self):
+ c = Context()
+ d = c.ln(Decimal(10))
+ self.assertEqual(c.ln(10), d)
+ self.assertRaises(TypeError, c.ln, '10')
+
+ def test_log10(self):
+ c = Context()
+ d = c.log10(Decimal(10))
+ self.assertEqual(c.log10(10), d)
+ self.assertRaises(TypeError, c.log10, '10')
+
+ def test_logb(self):
+ c = Context()
+ d = c.logb(Decimal(10))
+ self.assertEqual(c.logb(10), d)
+ self.assertRaises(TypeError, c.logb, '10')
+
+ def test_logical_and(self):
+ c = Context()
+ d = c.logical_and(Decimal(1), Decimal(1))
+ self.assertEqual(c.logical_and(1, 1), d)
+ self.assertEqual(c.logical_and(Decimal(1), 1), d)
+ self.assertEqual(c.logical_and(1, Decimal(1)), d)
+ self.assertRaises(TypeError, c.logical_and, '1', 1)
+ self.assertRaises(TypeError, c.logical_and, 1, '1')
+
+ def test_logical_invert(self):
+ c = Context()
+ d = c.logical_invert(Decimal(1000))
+ self.assertEqual(c.logical_invert(1000), d)
+ self.assertRaises(TypeError, c.logical_invert, '1000')
+
+ def test_logical_or(self):
+ c = Context()
+ d = c.logical_or(Decimal(1), Decimal(1))
+ self.assertEqual(c.logical_or(1, 1), d)
+ self.assertEqual(c.logical_or(Decimal(1), 1), d)
+ self.assertEqual(c.logical_or(1, Decimal(1)), d)
+ self.assertRaises(TypeError, c.logical_or, '1', 1)
+ self.assertRaises(TypeError, c.logical_or, 1, '1')
+
+ def test_logical_xor(self):
+ c = Context()
+ d = c.logical_xor(Decimal(1), Decimal(1))
+ self.assertEqual(c.logical_xor(1, 1), d)
+ self.assertEqual(c.logical_xor(Decimal(1), 1), d)
+ self.assertEqual(c.logical_xor(1, Decimal(1)), d)
+ self.assertRaises(TypeError, c.logical_xor, '1', 1)
+ self.assertRaises(TypeError, c.logical_xor, 1, '1')
+
+ def test_max(self):
+ c = Context()
+ d = c.max(Decimal(1), Decimal(2))
+ self.assertEqual(c.max(1, 2), d)
+ self.assertEqual(c.max(Decimal(1), 2), d)
+ self.assertEqual(c.max(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.max, '1', 2)
+ self.assertRaises(TypeError, c.max, 1, '2')
+
+ def test_max_mag(self):
+ c = Context()
+ d = c.max_mag(Decimal(1), Decimal(2))
+ self.assertEqual(c.max_mag(1, 2), d)
+ self.assertEqual(c.max_mag(Decimal(1), 2), d)
+ self.assertEqual(c.max_mag(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.max_mag, '1', 2)
+ self.assertRaises(TypeError, c.max_mag, 1, '2')
+
+ def test_min(self):
+ c = Context()
+ d = c.min(Decimal(1), Decimal(2))
+ self.assertEqual(c.min(1, 2), d)
+ self.assertEqual(c.min(Decimal(1), 2), d)
+ self.assertEqual(c.min(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.min, '1', 2)
+ self.assertRaises(TypeError, c.min, 1, '2')
+
+ def test_min_mag(self):
+ c = Context()
+ d = c.min_mag(Decimal(1), Decimal(2))
+ self.assertEqual(c.min_mag(1, 2), d)
+ self.assertEqual(c.min_mag(Decimal(1), 2), d)
+ self.assertEqual(c.min_mag(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.min_mag, '1', 2)
+ self.assertRaises(TypeError, c.min_mag, 1, '2')
+
+ def test_minus(self):
+ c = Context()
+ d = c.minus(Decimal(10))
+ self.assertEqual(c.minus(10), d)
+ self.assertRaises(TypeError, c.minus, '10')
+
+ def test_multiply(self):
+ c = Context()
+ d = c.multiply(Decimal(1), Decimal(2))
+ self.assertEqual(c.multiply(1, 2), d)
+ self.assertEqual(c.multiply(Decimal(1), 2), d)
+ self.assertEqual(c.multiply(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.multiply, '1', 2)
+ self.assertRaises(TypeError, c.multiply, 1, '2')
+
+ def test_next_minus(self):
+ c = Context()
+ d = c.next_minus(Decimal(10))
+ self.assertEqual(c.next_minus(10), d)
+ self.assertRaises(TypeError, c.next_minus, '10')
+
+ def test_next_plus(self):
+ c = Context()
+ d = c.next_plus(Decimal(10))
+ self.assertEqual(c.next_plus(10), d)
+ self.assertRaises(TypeError, c.next_plus, '10')
+
+ def test_next_toward(self):
+ c = Context()
+ d = c.next_toward(Decimal(1), Decimal(2))
+ self.assertEqual(c.next_toward(1, 2), d)
+ self.assertEqual(c.next_toward(Decimal(1), 2), d)
+ self.assertEqual(c.next_toward(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.next_toward, '1', 2)
+ self.assertRaises(TypeError, c.next_toward, 1, '2')
+
+ def test_normalize(self):
+ c = Context()
+ d = c.normalize(Decimal(10))
+ self.assertEqual(c.normalize(10), d)
+ self.assertRaises(TypeError, c.normalize, '10')
+
+ def test_number_class(self):
+ c = Context()
+ self.assertEqual(c.number_class(123), c.number_class(Decimal(123)))
+ self.assertEqual(c.number_class(0), c.number_class(Decimal(0)))
+ self.assertEqual(c.number_class(-45), c.number_class(Decimal(-45)))
+
+ def test_power(self):
+ c = Context()
+ d = c.power(Decimal(1), Decimal(4), Decimal(2))
+ self.assertEqual(c.power(1, 4, 2), d)
+ self.assertEqual(c.power(Decimal(1), 4, 2), d)
+ self.assertEqual(c.power(1, Decimal(4), 2), d)
+ self.assertEqual(c.power(1, 4, Decimal(2)), d)
+ self.assertEqual(c.power(Decimal(1), Decimal(4), 2), d)
+ self.assertRaises(TypeError, c.power, '1', 4, 2)
+ self.assertRaises(TypeError, c.power, 1, '4', 2)
+ self.assertRaises(TypeError, c.power, 1, 4, '2')
+
+ def test_plus(self):
+ c = Context()
+ d = c.plus(Decimal(10))
+ self.assertEqual(c.plus(10), d)
+ self.assertRaises(TypeError, c.plus, '10')
+
+ def test_quantize(self):
+ c = Context()
+ d = c.quantize(Decimal(1), Decimal(2))
+ self.assertEqual(c.quantize(1, 2), d)
+ self.assertEqual(c.quantize(Decimal(1), 2), d)
+ self.assertEqual(c.quantize(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.quantize, '1', 2)
+ self.assertRaises(TypeError, c.quantize, 1, '2')
+
+ def test_remainder(self):
+ c = Context()
+ d = c.remainder(Decimal(1), Decimal(2))
+ self.assertEqual(c.remainder(1, 2), d)
+ self.assertEqual(c.remainder(Decimal(1), 2), d)
+ self.assertEqual(c.remainder(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.remainder, '1', 2)
+ self.assertRaises(TypeError, c.remainder, 1, '2')
+
+ def test_remainder_near(self):
+ c = Context()
+ d = c.remainder_near(Decimal(1), Decimal(2))
+ self.assertEqual(c.remainder_near(1, 2), d)
+ self.assertEqual(c.remainder_near(Decimal(1), 2), d)
+ self.assertEqual(c.remainder_near(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.remainder_near, '1', 2)
+ self.assertRaises(TypeError, c.remainder_near, 1, '2')
+
+ def test_rotate(self):
+ c = Context()
+ d = c.rotate(Decimal(1), Decimal(2))
+ self.assertEqual(c.rotate(1, 2), d)
+ self.assertEqual(c.rotate(Decimal(1), 2), d)
+ self.assertEqual(c.rotate(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.rotate, '1', 2)
+ self.assertRaises(TypeError, c.rotate, 1, '2')
+
+ def test_sqrt(self):
+ c = Context()
+ d = c.sqrt(Decimal(10))
+ self.assertEqual(c.sqrt(10), d)
+ self.assertRaises(TypeError, c.sqrt, '10')
+
+ def test_same_quantum(self):
+ c = Context()
+ d = c.same_quantum(Decimal(1), Decimal(2))
+ self.assertEqual(c.same_quantum(1, 2), d)
+ self.assertEqual(c.same_quantum(Decimal(1), 2), d)
+ self.assertEqual(c.same_quantum(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.same_quantum, '1', 2)
+ self.assertRaises(TypeError, c.same_quantum, 1, '2')
+
+ def test_scaleb(self):
+ c = Context()
+ d = c.scaleb(Decimal(1), Decimal(2))
+ self.assertEqual(c.scaleb(1, 2), d)
+ self.assertEqual(c.scaleb(Decimal(1), 2), d)
+ self.assertEqual(c.scaleb(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.scaleb, '1', 2)
+ self.assertRaises(TypeError, c.scaleb, 1, '2')
+
+ def test_shift(self):
+ c = Context()
+ d = c.shift(Decimal(1), Decimal(2))
+ self.assertEqual(c.shift(1, 2), d)
+ self.assertEqual(c.shift(Decimal(1), 2), d)
+ self.assertEqual(c.shift(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.shift, '1', 2)
+ self.assertRaises(TypeError, c.shift, 1, '2')
+
+ def test_subtract(self):
+ c = Context()
+ d = c.subtract(Decimal(1), Decimal(2))
+ self.assertEqual(c.subtract(1, 2), d)
+ self.assertEqual(c.subtract(Decimal(1), 2), d)
+ self.assertEqual(c.subtract(1, Decimal(2)), d)
+ self.assertRaises(TypeError, c.subtract, '1', 2)
+ self.assertRaises(TypeError, c.subtract, 1, '2')
+
+ def test_to_eng_string(self):
+ c = Context()
+ d = c.to_eng_string(Decimal(10))
+ self.assertEqual(c.to_eng_string(10), d)
+ self.assertRaises(TypeError, c.to_eng_string, '10')
+
+ def test_to_sci_string(self):
+ c = Context()
+ d = c.to_sci_string(Decimal(10))
+ self.assertEqual(c.to_sci_string(10), d)
+ self.assertRaises(TypeError, c.to_sci_string, '10')
+
+ def test_to_integral_exact(self):
+ c = Context()
+ d = c.to_integral_exact(Decimal(10))
+ self.assertEqual(c.to_integral_exact(10), d)
+ self.assertRaises(TypeError, c.to_integral_exact, '10')
+
+ def test_to_integral_value(self):
+ c = Context()
+ d = c.to_integral_value(Decimal(10))
+ self.assertEqual(c.to_integral_value(10), d)
+ self.assertRaises(TypeError, c.to_integral_value, '10')
+
class WithStatementTest(unittest.TestCase):
# Can't do these as docstrings until Python 2.6
# as doctest can't handle __future__ statements
@@ -1717,9 +2289,9 @@ class WithStatementTest(unittest.TestCase):
with localcontext() as enter_ctx:
set_ctx = getcontext()
final_ctx = getcontext()
- self.assertTrue(orig_ctx is final_ctx, 'did not restore context correctly')
- self.assertTrue(orig_ctx is not set_ctx, 'did not copy the context')
- self.assertTrue(set_ctx is enter_ctx, '__enter__ returned wrong context')
+ self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly')
+ self.assertIsNot(orig_ctx, set_ctx, 'did not copy the context')
+ self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context')
def test_localcontextarg(self):
# Use a copy of the supplied context in the block
@@ -1728,10 +2300,10 @@ class WithStatementTest(unittest.TestCase):
with localcontext(new_ctx) as enter_ctx:
set_ctx = getcontext()
final_ctx = getcontext()
- self.assertTrue(orig_ctx is final_ctx, 'did not restore context correctly')
- self.assertTrue(set_ctx.prec == new_ctx.prec, 'did not set correct context')
- self.assertTrue(new_ctx is not set_ctx, 'did not copy the context')
- self.assertTrue(set_ctx is enter_ctx, '__enter__ returned wrong context')
+ self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly')
+ self.assertEqual(set_ctx.prec, new_ctx.prec, 'did not set correct context')
+ self.assertIsNot(new_ctx, set_ctx, 'did not copy the context')
+ self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context')
class ContextFlags(unittest.TestCase):
def test_flags_irrelevant(self):
diff --git a/Lib/test/test_defaultdict.py b/Lib/test/test_defaultdict.py
index e5a9bd5df7..da2608a548 100644
--- a/Lib/test/test_defaultdict.py
+++ b/Lib/test/test_defaultdict.py
@@ -32,14 +32,14 @@ class TestDefaultDict(unittest.TestCase):
self.assertEqual(d2["foo"], 1)
self.assertEqual(d2["bar"], 2)
self.assertEqual(d2[42], [])
- self.assertTrue("foo" in d2)
- self.assertTrue("foo" in d2.keys())
- self.assertTrue("bar" in d2)
- self.assertTrue("bar" in d2.keys())
- self.assertTrue(42 in d2)
- self.assertTrue(42 in d2.keys())
- self.assertTrue(12 not in d2)
- self.assertTrue(12 not in d2.keys())
+ self.assertIn("foo", d2)
+ self.assertIn("foo", d2.keys())
+ self.assertIn("bar", d2)
+ self.assertIn("bar", d2.keys())
+ self.assertIn(42, d2)
+ self.assertIn(42, d2.keys())
+ self.assertNotIn(12, d2)
+ self.assertNotIn(12, d2.keys())
d2.default_factory = None
self.assertEqual(d2.default_factory, None)
try:
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index 67e41d681a..0dcadeb3c5 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -7,7 +7,6 @@ import copy
import pickle
from io import StringIO
import random
-import os
BIG = 100000
@@ -115,6 +114,39 @@ class TestBasic(unittest.TestCase):
d = deque('abc')
d.maxlen = 10
+ def test_count(self):
+ for s in ('', 'abracadabra', 'simsalabim'*500+'abc'):
+ s = list(s)
+ d = deque(s)
+ for letter in 'abcdefghijklmnopqrstuvwxyz':
+ self.assertEqual(s.count(letter), d.count(letter), (s, d, letter))
+ self.assertRaises(TypeError, d.count) # too few args
+ self.assertRaises(TypeError, d.count, 1, 2) # too many args
+ class BadCompare:
+ def __eq__(self, other):
+ raise ArithmeticError
+ d = deque([1, 2, BadCompare(), 3])
+ self.assertRaises(ArithmeticError, d.count, 2)
+ d = deque([1, 2, 3])
+ self.assertRaises(ArithmeticError, d.count, BadCompare())
+ class MutatingCompare:
+ def __eq__(self, other):
+ self.d.pop()
+ return True
+ m = MutatingCompare()
+ d = deque([1, 2, 3, m, 4, 5])
+ m.d = d
+ self.assertRaises(RuntimeError, d.count, 3)
+
+ # test issue11004
+ # block advance failed after rotation aligned elements on right side of block
+ d = deque([None]*16)
+ for i in range(len(d)):
+ d.rotate(-1)
+ d.rotate(1)
+ self.assertEqual(d.count(1), 0)
+ self.assertEqual(d.count(None), 16)
+
def test_comparisons(self):
d = deque('xabc'); d.popleft()
for e in [d, deque('abc'), deque('ab'), deque(), list(d)]:
@@ -199,11 +231,23 @@ class TestBasic(unittest.TestCase):
self.assertEqual(len(d), n-i)
j = random.randrange(-len(d), len(d))
val = d[j]
- self.assertTrue(val in d)
+ self.assertIn(val, d)
del d[j]
- self.assertTrue(val not in d)
+ self.assertNotIn(val, d)
self.assertEqual(len(d), 0)
+ def test_reverse(self):
+ n = 500 # O(n**2) test, don't make this too big
+ data = [random.random() for i in range(n)]
+ for i in range(n):
+ d = deque(data[:i])
+ r = d.reverse()
+ self.assertEqual(list(d), list(reversed(data[:i])))
+ self.assertIs(r, None)
+ d.reverse()
+ self.assertEqual(list(d), data[:i])
+ self.assertRaises(TypeError, d.reverse, 1) # Arity is zero
+
def test_rotate(self):
s = tuple('abcde')
n = len(s)
@@ -316,7 +360,7 @@ class TestBasic(unittest.TestCase):
e = eval(repr(d))
self.assertEqual(list(d), list(e))
d.append(d)
- self.assertTrue('...' in repr(d))
+ self.assertIn('...', repr(d))
def test_print(self):
d = deque(range(200))
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index bd88f45337..41dfa70e55 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1,8 +1,8 @@
import builtins
import sys
import types
+import math
import unittest
-import warnings
from copy import deepcopy
from test import support
@@ -248,10 +248,6 @@ class OperatorsTest(unittest.TestCase):
else:
self.fail("NotImplemented should have caused TypeError")
- def test_longs(self):
- # Testing long operations...
- self.number_operators(100, 3)
-
def test_floats(self):
# Testing float operations...
self.number_operators(100.0, 3.0)
@@ -259,7 +255,7 @@ class OperatorsTest(unittest.TestCase):
def test_complexes(self):
# Testing complex operations...
self.number_operators(100.0j, 3.0j, skip=['lt', 'le', 'gt', 'ge',
- 'int', 'long', 'float',
+ 'int', 'float',
'divmod', 'mod'])
class Number(complex):
@@ -393,11 +389,11 @@ class ClassPropertiesAndMethods(unittest.TestCase):
def test_python_dicts(self):
# Testing Python subclass of dict...
self.assertTrue(issubclass(dict, dict))
- self.assertTrue(isinstance({}, dict))
+ self.assertIsInstance({}, dict)
d = dict()
self.assertEqual(d, {})
self.assertTrue(d.__class__ is dict)
- self.assertTrue(isinstance(d, dict))
+ self.assertIsInstance(d, dict)
class C(dict):
state = -1
def __init__(self_local, *a, **kw):
@@ -410,7 +406,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
def __getitem__(self, key):
return self.get(key, 0)
def __setitem__(self_local, key, value):
- self.assertTrue(isinstance(key, type(0)))
+ self.assertIsInstance(key, type(0))
dict.__setitem__(self_local, key, value)
def setstate(self, state):
self.state = state
@@ -509,7 +505,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
return 42
self.assertEqual(C.name, 'C')
self.assertEqual(C.bases, ())
- self.assertTrue('spam' in C.dict)
+ self.assertIn('spam', C.dict)
c = C()
self.assertEqual(c.spam(), 42)
@@ -633,7 +629,6 @@ class ClassPropertiesAndMethods(unittest.TestCase):
def test_module_subclasses(self):
# Testing Python subclass of module...
log = []
- import types, sys
MT = type(sys)
class MM(MT):
def __init__(self, name):
@@ -1015,7 +1010,6 @@ order (MRO) for bases """
# Test cyclical leaks [SF bug 519621]
class F(object):
__slots__ = ['a', 'b']
- log = []
s = F()
s.a = [Counted(), s]
self.assertEqual(Counted.counter, 1)
@@ -1024,11 +1018,11 @@ order (MRO) for bases """
self.assertEqual(Counted.counter, 0)
# Test lookup leaks [SF bug 572567]
- import sys,gc
+ import gc
if hasattr(gc, 'get_objects'):
class G(object):
- def __cmp__(self, other):
- return 0
+ def __eq__(self, other):
+ return False
g = G()
orig_objects = len(gc.get_objects())
for i in range(10):
@@ -1104,7 +1098,7 @@ order (MRO) for bases """
MyABC.register(Unrelated)
u = Unrelated()
- self.assertTrue(isinstance(u, MyABC))
+ self.assertIsInstance(u, MyABC)
# This used to crash
self.assertRaises(TypeError, MyABC.a.__set__, u, 3)
@@ -1172,15 +1166,6 @@ order (MRO) for bases """
self.assertEqual(I(3)*2, 6)
self.assertEqual(I(3)*I(2), 6)
- # Test handling of long*seq and seq*long
- class L(int):
- pass
- self.assertEqual("a"*L(2), "aa")
- self.assertEqual(L(2)*"a", "aa")
- self.assertEqual(2*L(3), 6)
- self.assertEqual(L(3)*2, 6)
- self.assertEqual(L(3)*L(2), 6)
-
# Test comparison of classes with dynamic metaclasses
class dynamicmetaclass(type):
pass
@@ -1560,6 +1545,8 @@ order (MRO) for bases """
return []
def zero(self):
return 0
+ def complex_num(self):
+ return 1j
def stop(self):
raise StopIteration
def return_true(self, thing=None):
@@ -1575,6 +1562,9 @@ order (MRO) for bases """
def some_number(self_, key):
self.assertEqual(key, "hi")
return 4
+ def swallow(*args): pass
+ def format_impl(self, spec):
+ return "hello"
# It would be nice to have every special method tested here, but I'm
# only listing the ones I can remember outside of typeobject.c, since it
@@ -1590,11 +1580,13 @@ order (MRO) for bases """
set(("__class__",)), {}),
("__subclasscheck__", do_issubclass, return_true,
set(("__bases__",)), {}),
- # These two fail because the compiler generates LOAD_ATTR to look
- # them up. We'd have to add a new opcode to fix this, and it's
- # probably not worth it.
- # ("__enter__", run_context, iden),
- # ("__exit__", run_context, iden),
+ ("__enter__", run_context, iden, set(), {"__exit__" : swallow}),
+ ("__exit__", run_context, swallow, set(), {"__enter__" : iden}),
+ ("__complex__", complex, complex_num, set(), {}),
+ ("__format__", format, format_impl, set(), {}),
+ ("__floor__", math.floor, zero, set(), {}),
+ ("__trunc__", math.trunc, zero, set(), {}),
+ ("__ceil__", math.ceil, zero, set(), {}),
]
class Checker(object):
@@ -1668,10 +1660,10 @@ order (MRO) for bases """
# depending on whether this test is run standalone or from a framework.
self.assertTrue(str(c1).find('C object at ') >= 0)
self.assertEqual(str(c1), repr(c1))
- self.assertTrue(-1 not in c1)
+ self.assertNotIn(-1, c1)
for i in range(10):
- self.assertTrue(i in c1)
- self.assertFalse(10 in c1)
+ self.assertIn(i, c1)
+ self.assertNotIn(10, c1)
# Test the default behavior for dynamic classes
class D(object):
def __getitem__(self, i):
@@ -1691,10 +1683,10 @@ order (MRO) for bases """
# depending on whether this test is run standalone or from a framework.
self.assertTrue(str(d1).find('D object at ') >= 0)
self.assertEqual(str(d1), repr(d1))
- self.assertTrue(-1 not in d1)
+ self.assertNotIn(-1, d1)
for i in range(10):
- self.assertTrue(i in d1)
- self.assertFalse(10 in d1)
+ self.assertIn(i, d1)
+ self.assertNotIn(10, d1)
# Test overridden behavior
class Proxy(object):
def __init__(self, x):
@@ -1738,10 +1730,10 @@ order (MRO) for bases """
self.assertEqual(str(p0), "Proxy:0")
self.assertEqual(repr(p0), "Proxy(0)")
p10 = Proxy(range(10))
- self.assertFalse(-1 in p10)
+ self.assertNotIn(-1, p10)
for i in range(10):
- self.assertTrue(i in p10)
- self.assertFalse(10 in p10)
+ self.assertIn(i, p10)
+ self.assertNotIn(10, p10)
def test_weakrefs(self):
# Testing weak references...
@@ -1798,13 +1790,13 @@ order (MRO) for bases """
self.assertFalse(hasattr(a, "x"))
raw = C.__dict__['x']
- self.assertTrue(isinstance(raw, property))
+ self.assertIsInstance(raw, property)
attrs = dir(raw)
- self.assertTrue("__doc__" in attrs)
- self.assertTrue("fget" in attrs)
- self.assertTrue("fset" in attrs)
- self.assertTrue("fdel" in attrs)
+ self.assertIn("__doc__", attrs)
+ self.assertIn("fget", attrs)
+ self.assertIn("fset", attrs)
+ self.assertIn("fdel", attrs)
self.assertEqual(raw.__doc__, "I'm the x property.")
self.assertTrue(raw.fget is C.__dict__['getx'])
@@ -1834,6 +1826,9 @@ order (MRO) for bases """
else:
self.fail("expected ZeroDivisionError from bad property")
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_properties_doc_attrib(self):
class E(object):
def getter(self):
"getter method"
@@ -1846,6 +1841,7 @@ order (MRO) for bases """
prop2 = property(fset=setter)
self.assertEqual(prop2.__doc__, None)
+ def test_testcapi_no_segfault(self):
# this segfaulted in 2.5b2
try:
import _testcapi
@@ -2029,12 +2025,12 @@ order (MRO) for bases """
c = C()
self.assertEqual(interesting(dir(c)), cstuff)
- ## self.assertTrue('__self__' in dir(C.Cmethod))
+ ## self.assertIn('__self__', dir(C.Cmethod))
c.cdata = 2
c.cmethod = lambda self: 0
self.assertEqual(interesting(dir(c)), cstuff + ['cdata', 'cmethod'])
- ## self.assertTrue('__self__' in dir(c.Cmethod))
+ ## self.assertIn('__self__', dir(c.Cmethod))
class A(C):
Adata = 1
@@ -2042,16 +2038,15 @@ order (MRO) for bases """
astuff = ['Adata', 'Amethod'] + cstuff
self.assertEqual(interesting(dir(A)), astuff)
- ## self.assertTrue('__self__' in dir(A.Amethod))
+ ## self.assertIn('__self__', dir(A.Amethod))
a = A()
self.assertEqual(interesting(dir(a)), astuff)
a.adata = 42
a.amethod = lambda self: 3
self.assertEqual(interesting(dir(a)), astuff + ['adata', 'amethod'])
- ## self.assertTrue('__self__' in dir(a.Amethod))
+ ## self.assertIn('__self__', dir(a.Amethod))
# Try a module subclass.
- import sys
class M(type(sys)):
pass
minstance = M("m")
@@ -2243,10 +2238,7 @@ order (MRO) for bases """
class octlong(int):
__slots__ = []
def __str__(self):
- s = oct(self)
- if s[-1] == 'L':
- s = s[:-1]
- return s
+ return oct(self)
def __add__(self, other):
return self.__class__(super(octlong, self).__add__(other))
__radd__ = __add__
@@ -2603,7 +2595,7 @@ order (MRO) for bases """
self.assertEqual(d[cistr('one')], 1)
self.assertEqual(d[cistr('tWo')], 2)
self.assertEqual(d[cistr('THrEE')], 3)
- self.assertTrue(cistr('ONe') in d)
+ self.assertIn(cistr('ONe'), d)
self.assertEqual(d.get(cistr('thrEE')), 3)
def test_classic_comparisons(self):
@@ -3222,7 +3214,6 @@ order (MRO) for bases """
self.fail("d.foo should be undefined now")
# Test a nasty bug in recurse_down_subclasses()
- import gc
class A(object):
pass
class B(A):
@@ -3427,10 +3418,10 @@ order (MRO) for bases """
d = D(None)
self.assertEqual(d.foo, None)
d = C(1)
- self.assertEqual(isinstance(d, D), True)
+ self.assertIsInstance(d, D)
self.assertEqual(d.foo, 1)
d = D(1)
- self.assertEqual(isinstance(d, D), True)
+ self.assertIsInstance(d, D)
self.assertEqual(d.foo, 1)
def test_imul_bug(self):
@@ -3922,29 +3913,29 @@ order (MRO) for bases """
pass
a = C()
pa = Proxy(a)
- self.assertTrue(isinstance(a, C)) # Baseline
- self.assertTrue(isinstance(pa, C)) # Test
+ self.assertIsInstance(a, C) # Baseline
+ self.assertIsInstance(pa, C) # Test
# Test with a classic subclass
class D(C):
pass
a = D()
pa = Proxy(a)
- self.assertTrue(isinstance(a, C)) # Baseline
- self.assertTrue(isinstance(pa, C)) # Test
+ self.assertIsInstance(a, C) # Baseline
+ self.assertIsInstance(pa, C) # Test
# Test with a new-style class
class C(object):
pass
a = C()
pa = Proxy(a)
- self.assertTrue(isinstance(a, C)) # Baseline
- self.assertTrue(isinstance(pa, C)) # Test
+ self.assertIsInstance(a, C) # Baseline
+ self.assertIsInstance(pa, C) # Test
# Test with a new-style subclass
class D(C):
pass
a = D()
pa = Proxy(a)
- self.assertTrue(isinstance(a, C)) # Baseline
- self.assertTrue(isinstance(pa, C)) # Test
+ self.assertIsInstance(a, C) # Baseline
+ self.assertIsInstance(pa, C) # Test
def test_proxy_super(self):
# Testing super() for a proxy object...
@@ -4012,7 +4003,7 @@ order (MRO) for bases """
def test_file_fault(self):
# Testing sys.stdout is changed in getattr...
- import sys
+ test_stdout = sys.stdout
class StdoutGuard:
def __getattr__(self, attr):
sys.stdout = sys.__stdout__
@@ -4022,6 +4013,8 @@ order (MRO) for bases """
print("Oops!")
except RuntimeError:
pass
+ finally:
+ sys.stdout = test_stdout
def test_vicious_descriptor_nonsense(self):
# Testing vicious_descriptor_nonsense...
@@ -4100,8 +4093,6 @@ order (MRO) for bases """
def test_not_implemented(self):
# Testing NotImplemented...
# all binary methods should be able to return a NotImplemented
- import sys
- import types
import operator
def specialmethod(self, other):
@@ -4184,6 +4175,15 @@ order (MRO) for bases """
x.a = 42
self.assertEqual(x.a, 42)
+ # Also check type_getattro for correctness.
+ class Meta(type):
+ pass
+ class X(object):
+ __metaclass__ = Meta
+ X.a = 42
+ Meta.a = Descr("a")
+ self.assertEqual(X.a, 42)
+
def test_getattr_hooks(self):
# issue 4230
@@ -4244,20 +4244,26 @@ class DictProxyTests(unittest.TestCase):
self.C = C
def test_iter_keys(self):
- # Testing dict-proxy iterkeys...
- keys = [ key for key in self.C.__dict__.keys() ]
+ # Testing dict-proxy keys...
+ it = self.C.__dict__.keys()
+ self.assertNotIsInstance(it, list)
+ keys = list(it)
keys.sort()
self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
'__weakref__', 'meth'])
def test_iter_values(self):
- # Testing dict-proxy itervalues...
- values = [ values for values in self.C.__dict__.values() ]
+ # Testing dict-proxy values...
+ it = self.C.__dict__.values()
+ self.assertNotIsInstance(it, list)
+ values = list(it)
self.assertEqual(len(values), 5)
def test_iter_items(self):
# Testing dict-proxy iteritems...
- keys = [ key for (key, value) in self.C.__dict__.items() ]
+ it = self.C.__dict__.items()
+ self.assertNotIsInstance(it, list)
+ keys = [item[0] for item in it]
keys.sort()
self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
'__weakref__', 'meth'])
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index d1b103787d..1507e42053 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1,41 +1,50 @@
import unittest
from test import support
-import sys, collections, random, string
+import collections, random, string
import gc, weakref
class DictTest(unittest.TestCase):
+ def test_invalid_keyword_arguments(self):
+ class Custom(dict):
+ pass
+ for invalid in {1 : 2}, Custom({1 : 2}):
+ with self.assertRaises(TypeError):
+ dict(**invalid)
+ with self.assertRaises(TypeError):
+ {}.update(**invalid)
+
def test_constructor(self):
# calling built-in types without argument must return empty
self.assertEqual(dict(), {})
- self.assertTrue(dict() is not {})
+ self.assertIsNot(dict(), {})
def test_literal_constructor(self):
- # check literal constructor for different sized dicts (to exercise the BUILD_MAP oparg
+ # check literal constructor for different sized dicts
+ # (to exercise the BUILD_MAP oparg).
for n in (0, 1, 6, 256, 400):
- items = [(''.join([random.choice(string.ascii_letters)
- for j in range(8)]),
- i)
+ items = [(''.join(random.sample(string.ascii_letters, 8)), i)
for i in range(n)]
random.shuffle(items)
- dictliteral = '{' + ', '.join('%r: %d' % item for item in items) + '}'
+ formatted_items = ('{!r}: {:d}'.format(k, v) for k, v in items)
+ dictliteral = '{' + ', '.join(formatted_items) + '}'
self.assertEqual(eval(dictliteral), dict(items))
def test_bool(self):
- self.assertTrue(not {})
+ self.assertIs(not {}, True)
self.assertTrue({1: 2})
- self.assertTrue(bool({}) is False)
- self.assertTrue(bool({1: 2}) is True)
+ self.assertIs(bool({}), False)
+ self.assertIs(bool({1: 2}), True)
def test_keys(self):
d = {}
self.assertEqual(set(d.keys()), set())
d = {'a': 1, 'b': 2}
k = d.keys()
- self.assertTrue('a' in d)
- self.assertTrue('b' in d)
+ self.assertIn('a', d)
+ self.assertIn('b', d)
self.assertRaises(TypeError, d.keys, None)
self.assertEqual(repr(dict(a=1).keys()), "dict_keys(['a'])")
@@ -58,12 +67,13 @@ class DictTest(unittest.TestCase):
def test_contains(self):
d = {}
- self.assertTrue(not ('a' in d))
+ self.assertNotIn('a', d)
+ self.assertFalse('a' in d)
self.assertTrue('a' not in d)
d = {'a': 1, 'b': 2}
- self.assertTrue('a' in d)
- self.assertTrue('b' in d)
- self.assertTrue('c' not in d)
+ self.assertIn('a', d)
+ self.assertIn('b', d)
+ self.assertNotIn('c', d)
self.assertRaises(TypeError, d.__contains__)
@@ -197,7 +207,7 @@ class DictTest(unittest.TestCase):
def test_fromkeys(self):
self.assertEqual(dict.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
d = {}
- self.assertTrue(not(d.fromkeys('abc') is d))
+ self.assertIsNot(d.fromkeys('abc'), d)
self.assertEqual(d.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
self.assertEqual(d.fromkeys((4,5),0), {4:0, 5:0})
self.assertEqual(d.fromkeys([]), {})
@@ -208,14 +218,14 @@ class DictTest(unittest.TestCase):
class dictlike(dict): pass
self.assertEqual(dictlike.fromkeys('a'), {'a':None})
self.assertEqual(dictlike().fromkeys('a'), {'a':None})
- self.assertTrue(type(dictlike.fromkeys('a')) is dictlike)
- self.assertTrue(type(dictlike().fromkeys('a')) is dictlike)
+ self.assertIsInstance(dictlike.fromkeys('a'), dictlike)
+ self.assertIsInstance(dictlike().fromkeys('a'), dictlike)
class mydict(dict):
def __new__(cls):
return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
- self.assertTrue(isinstance(ud, collections.UserDict))
+ self.assertIsInstance(ud, collections.UserDict)
self.assertRaises(TypeError, dict.fromkeys)
class Exc(Exception): pass
@@ -252,10 +262,10 @@ class DictTest(unittest.TestCase):
def test_get(self):
d = {}
- self.assertTrue(d.get('c') is None)
+ self.assertIs(d.get('c'), None)
self.assertEqual(d.get('c', 3), 3)
- d = {'a' : 1, 'b' : 2}
- self.assertTrue(d.get('c') is None)
+ d = {'a': 1, 'b': 2}
+ self.assertIs(d.get('c'), None)
self.assertEqual(d.get('c', 3), 3)
self.assertEqual(d.get('a'), 1)
self.assertEqual(d.get('a', 3), 1)
@@ -265,9 +275,9 @@ class DictTest(unittest.TestCase):
def test_setdefault(self):
# dict.setdefault()
d = {}
- self.assertTrue(d.setdefault('key0') is None)
+ self.assertIs(d.setdefault('key0'), None)
d.setdefault('key0', [])
- self.assertTrue(d.setdefault('key0') is None)
+ self.assertIs(d.setdefault('key0'), None)
d.setdefault('key', []).append(3)
self.assertEqual(d['key'][0], 3)
d.setdefault('key', []).append(4)
@@ -309,9 +319,9 @@ class DictTest(unittest.TestCase):
self.assertEqual(va, int(ka))
kb, vb = tb = b.popitem()
self.assertEqual(vb, int(kb))
- self.assertTrue(not(copymode < 0 and ta != tb))
- self.assertTrue(not a)
- self.assertTrue(not b)
+ self.assertFalse(copymode < 0 and ta != tb)
+ self.assertFalse(a)
+ self.assertFalse(b)
d = {}
self.assertRaises(KeyError, d.popitem)
@@ -328,13 +338,6 @@ class DictTest(unittest.TestCase):
self.assertRaises(KeyError, d.pop, k)
- # verify longs/ints get same value when key > 32 bits (for 64-bit archs)
- # see SF bug #689659
- x = 4503599627370496
- y = 4503599627370496
- h = {x: 'anything', y: 'something else'}
- self.assertEqual(h[x], h[y])
-
self.assertEqual(d.pop(k, v), v)
d[k] = v
self.assertEqual(d.pop(k, 1), v)
@@ -357,15 +360,12 @@ class DictTest(unittest.TestCase):
self.assertRaises(Exc, d.pop, x)
def test_mutatingiteration(self):
+ # changing dict size during iteration
d = {}
d[1] = 1
- try:
+ with self.assertRaises(RuntimeError):
for i in d:
d[i+1] = 1
- except RuntimeError:
- pass
- else:
- self.fail("changing dict size during iteration doesn't raise Error")
def test_repr(self):
d = {}
@@ -399,12 +399,9 @@ class DictTest(unittest.TestCase):
d1 = {BadCmp(): 1}
d2 = {1: 1}
- try:
+
+ with self.assertRaises(Exc):
d1 == d2
- except Exc:
- pass
- else:
- self.fail("< didn't raise Exc")
def test_keys_contained(self):
self.helper_keys_contained(lambda x: x.keys())
@@ -458,15 +455,23 @@ class DictTest(unittest.TestCase):
class C:
def __eq__(self, other):
raise RuntimeError
+
d1 = {1: C()}
d2 = {1: C()}
- self.assertRaises(RuntimeError, lambda: d1.items() == d2.items())
- self.assertRaises(RuntimeError, lambda: d1.items() != d2.items())
- self.assertRaises(RuntimeError, lambda: d1.items() <= d2.items())
- self.assertRaises(RuntimeError, lambda: d1.items() >= d2.items())
+ with self.assertRaises(RuntimeError):
+ d1.items() == d2.items()
+ with self.assertRaises(RuntimeError):
+ d1.items() != d2.items()
+ with self.assertRaises(RuntimeError):
+ d1.items() <= d2.items()
+ with self.assertRaises(RuntimeError):
+ d1.items() >= d2.items()
+
d3 = {1: C(), 2: C()}
- self.assertRaises(RuntimeError, lambda: d2.items() < d3.items())
- self.assertRaises(RuntimeError, lambda: d3.items() > d2.items())
+ with self.assertRaises(RuntimeError):
+ d2.items() < d3.items()
+ with self.assertRaises(RuntimeError):
+ d3.items() > d2.items()
def test_dictview_set_operations_on_keys(self):
k1 = {1:1, 2:2}.keys()
@@ -512,8 +517,8 @@ class DictTest(unittest.TestCase):
def test_missing(self):
# Make sure dict doesn't have a __missing__ method
- self.assertEqual(hasattr(dict, "__missing__"), False)
- self.assertEqual(hasattr({}, "__missing__"), False)
+ self.assertFalse(hasattr(dict, "__missing__"))
+ self.assertFalse(hasattr({}, "__missing__"))
# Test several cases:
# (D) subclass defines __missing__ method returning a value
# (E) subclass defines __missing__ method raising RuntimeError
@@ -525,49 +530,40 @@ class DictTest(unittest.TestCase):
d = D({1: 2, 3: 4})
self.assertEqual(d[1], 2)
self.assertEqual(d[3], 4)
- self.assertTrue(2 not in d)
- self.assertTrue(2 not in d.keys())
+ self.assertNotIn(2, d)
+ self.assertNotIn(2, d.keys())
self.assertEqual(d[2], 42)
+
class E(dict):
def __missing__(self, key):
raise RuntimeError(key)
e = E()
- try:
+ with self.assertRaises(RuntimeError) as c:
e[42]
- except RuntimeError as err:
- self.assertEqual(err.args, (42,))
- else:
- self.fail("e[42] didn't raise RuntimeError")
+ self.assertEqual(c.exception.args, (42,))
+
class F(dict):
def __init__(self):
# An instance variable __missing__ should have no effect
self.__missing__ = lambda key: None
f = F()
- try:
+ with self.assertRaises(KeyError) as c:
f[42]
- except KeyError as err:
- self.assertEqual(err.args, (42,))
- else:
- self.fail("f[42] didn't raise KeyError")
+ self.assertEqual(c.exception.args, (42,))
+
class G(dict):
pass
g = G()
- try:
+ with self.assertRaises(KeyError) as c:
g[42]
- except KeyError as err:
- self.assertEqual(err.args, (42,))
- else:
- self.fail("g[42] didn't raise KeyError")
+ self.assertEqual(c.exception.args, (42,))
def test_tuple_keyerror(self):
# SF #1576657
d = {}
- try:
+ with self.assertRaises(KeyError) as c:
d[(1,)]
- except KeyError as e:
- self.assertEqual(e.args, ((1,),))
- else:
- self.fail("missing KeyError")
+ self.assertEqual(c.exception.args, ((1,),))
def test_bad_key(self):
# Dictionary lookups should fail if __eq__() raises an exception.
@@ -594,12 +590,8 @@ class DictTest(unittest.TestCase):
'd.setdefault(x2, 42)',
'd.pop(x2)',
'd.update({x2: 2})']:
- try:
+ with self.assertRaises(CustomException):
exec(stmt, locals())
- except CustomException:
- pass
- else:
- self.fail("Statement %r didn't raise exception" % stmt)
def test_resize1(self):
# Dict resizing bug, found by Jack Jansen in 2.2 CVS development.
@@ -642,11 +634,9 @@ class DictTest(unittest.TestCase):
def test_empty_presized_dict_in_freelist(self):
# Bug #3537: if an empty but presized dict with a size larger
# than 7 was in the freelist, it triggered an assertion failure
- try:
- d = {'a': 1/0, 'b': None, 'c': None, 'd': None, 'e': None,
+ with self.assertRaises(ZeroDivisionError):
+ d = {'a': 1 // 0, 'b': None, 'c': None, 'd': None, 'e': None,
'f': None, 'g': None, 'h': None}
- except ZeroDivisionError:
- pass
d = {}
def test_container_iterator(self):
@@ -663,7 +653,7 @@ class DictTest(unittest.TestCase):
obj.x = iter(obj.v)
del obj, container
gc.collect()
- self.assertTrue(ref() is None, "Cycle was not collected")
+ self.assertIs(ref(), None, "Cycle was not collected")
def _not_tracked(self, t):
# Nested containers can take several collections to untrack
@@ -677,6 +667,7 @@ class DictTest(unittest.TestCase):
gc.collect()
self.assertTrue(gc.is_tracked(t), t)
+ @support.cpython_only
def test_track_literals(self):
# Test GC-optimization of dict literals
x, y, z, w = 1.5, "a", (1, None), []
@@ -694,6 +685,7 @@ class DictTest(unittest.TestCase):
self._tracked({1: {}})
self._tracked({1: set()})
+ @support.cpython_only
def test_track_dynamic(self):
# Test GC-optimization of dynamically-created dicts
class MyObject(object):
@@ -757,6 +749,7 @@ class DictTest(unittest.TestCase):
d.update([(x, y), (z, w)])
self._tracked(d)
+ @support.cpython_only
def test_track_subtypes(self):
# Dict subtypes are always tracked
class MyDict(dict):
diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py
index 4fee755da4..4c040796f5 100644
--- a/Lib/test/test_dictviews.py
+++ b/Lib/test/test_dictviews.py
@@ -24,10 +24,10 @@ class DictSetTest(unittest.TestCase):
self.assertNotEqual(keys, {1, "b"})
self.assertNotEqual(keys, {1})
self.assertNotEqual(keys, 42)
- self.assertTrue(1 in keys)
- self.assertTrue("a" in keys)
- self.assertTrue(10 not in keys)
- self.assertTrue("Z" not in keys)
+ self.assertIn(1, keys)
+ self.assertIn("a", keys)
+ self.assertNotIn(10, keys)
+ self.assertNotIn("Z", keys)
self.assertEqual(d.keys(), d.keys())
e = {1: 11, "a": "def"}
self.assertEqual(d.keys(), e.keys())
@@ -44,13 +44,13 @@ class DictSetTest(unittest.TestCase):
self.assertNotEqual(items, {(1, 10), ("a", "def")})
self.assertNotEqual(items, {(1, 10)})
self.assertNotEqual(items, 42)
- self.assertTrue((1, 10) in items)
- self.assertTrue(("a", "ABC") in items)
- self.assertTrue((1, 11) not in items)
- self.assertTrue(1 not in items)
- self.assertTrue(() not in items)
- self.assertTrue((1,) not in items)
- self.assertTrue((1, 2, 3) not in items)
+ self.assertIn((1, 10), items)
+ self.assertIn(("a", "ABC"), items)
+ self.assertNotIn((1, 11), items)
+ self.assertNotIn(1, items)
+ self.assertNotIn((), items)
+ self.assertNotIn((1,), items)
+ self.assertNotIn((1, 2, 3), items)
self.assertEqual(d.items(), d.items())
e = d.copy()
self.assertEqual(d.items(), e.items())
@@ -69,6 +69,117 @@ class DictSetTest(unittest.TestCase):
self.assertEqual(set(values), {10, "ABC"})
self.assertEqual(len(values), 2)
+ def test_dict_repr(self):
+ d = {1: 10, "a": "ABC"}
+ self.assertIsInstance(repr(d), str)
+ r = repr(d.items())
+ self.assertIsInstance(r, str)
+ self.assertTrue(r == "dict_items([('a', 'ABC'), (1, 10)])" or
+ r == "dict_items([(1, 10), ('a', 'ABC')])")
+ r = repr(d.keys())
+ self.assertIsInstance(r, str)
+ self.assertTrue(r == "dict_keys(['a', 1])" or
+ r == "dict_keys([1, 'a'])")
+ r = repr(d.values())
+ self.assertIsInstance(r, str)
+ self.assertTrue(r == "dict_values(['ABC', 10])" or
+ r == "dict_values([10, 'ABC'])")
+
+ def test_keys_set_operations(self):
+ d1 = {'a': 1, 'b': 2}
+ d2 = {'b': 3, 'c': 2}
+ d3 = {'d': 4, 'e': 5}
+ self.assertEqual(d1.keys() & d1.keys(), {'a', 'b'})
+ self.assertEqual(d1.keys() & d2.keys(), {'b'})
+ self.assertEqual(d1.keys() & d3.keys(), set())
+ self.assertEqual(d1.keys() & set(d1.keys()), {'a', 'b'})
+ self.assertEqual(d1.keys() & set(d2.keys()), {'b'})
+ self.assertEqual(d1.keys() & set(d3.keys()), set())
+
+ self.assertEqual(d1.keys() | d1.keys(), {'a', 'b'})
+ self.assertEqual(d1.keys() | d2.keys(), {'a', 'b', 'c'})
+ self.assertEqual(d1.keys() | d3.keys(), {'a', 'b', 'd', 'e'})
+ self.assertEqual(d1.keys() | set(d1.keys()), {'a', 'b'})
+ self.assertEqual(d1.keys() | set(d2.keys()), {'a', 'b', 'c'})
+ self.assertEqual(d1.keys() | set(d3.keys()),
+ {'a', 'b', 'd', 'e'})
+
+ self.assertEqual(d1.keys() ^ d1.keys(), set())
+ self.assertEqual(d1.keys() ^ d2.keys(), {'a', 'c'})
+ self.assertEqual(d1.keys() ^ d3.keys(), {'a', 'b', 'd', 'e'})
+ self.assertEqual(d1.keys() ^ set(d1.keys()), set())
+ self.assertEqual(d1.keys() ^ set(d2.keys()), {'a', 'c'})
+ self.assertEqual(d1.keys() ^ set(d3.keys()),
+ {'a', 'b', 'd', 'e'})
+
+ self.assertFalse(d1.keys().isdisjoint(d1.keys()))
+ self.assertFalse(d1.keys().isdisjoint(d2.keys()))
+ self.assertFalse(d1.keys().isdisjoint(list(d2.keys())))
+ self.assertFalse(d1.keys().isdisjoint(set(d2.keys())))
+ self.assertTrue(d1.keys().isdisjoint({'x', 'y', 'z'}))
+ self.assertTrue(d1.keys().isdisjoint(['x', 'y', 'z']))
+ self.assertTrue(d1.keys().isdisjoint(set(['x', 'y', 'z'])))
+ self.assertTrue(d1.keys().isdisjoint(set(['x', 'y'])))
+ self.assertTrue(d1.keys().isdisjoint(['x', 'y']))
+ self.assertTrue(d1.keys().isdisjoint({}))
+ self.assertTrue(d1.keys().isdisjoint(d3.keys()))
+
+ de = {}
+ self.assertTrue(de.keys().isdisjoint(set()))
+ self.assertTrue(de.keys().isdisjoint([]))
+ self.assertTrue(de.keys().isdisjoint(de.keys()))
+ self.assertTrue(de.keys().isdisjoint([1]))
+
+ def test_items_set_operations(self):
+ d1 = {'a': 1, 'b': 2}
+ d2 = {'a': 2, 'b': 2}
+ d3 = {'d': 4, 'e': 5}
+ self.assertEqual(
+ d1.items() & d1.items(), {('a', 1), ('b', 2)})
+ self.assertEqual(d1.items() & d2.items(), {('b', 2)})
+ self.assertEqual(d1.items() & d3.items(), set())
+ self.assertEqual(d1.items() & set(d1.items()),
+ {('a', 1), ('b', 2)})
+ self.assertEqual(d1.items() & set(d2.items()), {('b', 2)})
+ self.assertEqual(d1.items() & set(d3.items()), set())
+
+ self.assertEqual(d1.items() | d1.items(),
+ {('a', 1), ('b', 2)})
+ self.assertEqual(d1.items() | d2.items(),
+ {('a', 1), ('a', 2), ('b', 2)})
+ self.assertEqual(d1.items() | d3.items(),
+ {('a', 1), ('b', 2), ('d', 4), ('e', 5)})
+ self.assertEqual(d1.items() | set(d1.items()),
+ {('a', 1), ('b', 2)})
+ self.assertEqual(d1.items() | set(d2.items()),
+ {('a', 1), ('a', 2), ('b', 2)})
+ self.assertEqual(d1.items() | set(d3.items()),
+ {('a', 1), ('b', 2), ('d', 4), ('e', 5)})
+
+ self.assertEqual(d1.items() ^ d1.items(), set())
+ self.assertEqual(d1.items() ^ d2.items(),
+ {('a', 1), ('a', 2)})
+ self.assertEqual(d1.items() ^ d3.items(),
+ {('a', 1), ('b', 2), ('d', 4), ('e', 5)})
+
+ self.assertFalse(d1.items().isdisjoint(d1.items()))
+ self.assertFalse(d1.items().isdisjoint(d2.items()))
+ self.assertFalse(d1.items().isdisjoint(list(d2.items())))
+ self.assertFalse(d1.items().isdisjoint(set(d2.items())))
+ self.assertTrue(d1.items().isdisjoint({'x', 'y', 'z'}))
+ self.assertTrue(d1.items().isdisjoint(['x', 'y', 'z']))
+ self.assertTrue(d1.items().isdisjoint(set(['x', 'y', 'z'])))
+ self.assertTrue(d1.items().isdisjoint(set(['x', 'y'])))
+ self.assertTrue(d1.items().isdisjoint({}))
+ self.assertTrue(d1.items().isdisjoint(d3.items()))
+
+ de = {}
+ self.assertTrue(de.items().isdisjoint(set()))
+ self.assertTrue(de.items().isdisjoint([]))
+ self.assertTrue(de.items().isdisjoint(de.items()))
+ self.assertTrue(de.items().isdisjoint([1]))
+
+
def test_main():
support.run_unittest(DictSetTest)
diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py
index 852aae9b31..a263ee6c73 100644
--- a/Lib/test/test_difflib.py
+++ b/Lib/test/test_difflib.py
@@ -4,8 +4,64 @@ import unittest
import doctest
import sys
-class TestSFbugs(unittest.TestCase):
+class TestWithAscii(unittest.TestCase):
+ def test_one_insert(self):
+ sm = difflib.SequenceMatcher(None, 'b' * 100, 'a' + 'b' * 100)
+ self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
+ self.assertEqual(list(sm.get_opcodes()),
+ [ ('insert', 0, 0, 0, 1),
+ ('equal', 0, 100, 1, 101)])
+ self.assertEqual(sm.bpopular, set())
+ sm = difflib.SequenceMatcher(None, 'b' * 100, 'b' * 50 + 'a' + 'b' * 50)
+ self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
+ self.assertEqual(list(sm.get_opcodes()),
+ [ ('equal', 0, 50, 0, 50),
+ ('insert', 50, 50, 50, 51),
+ ('equal', 50, 100, 51, 101)])
+ self.assertEqual(sm.bpopular, set())
+
+ def test_one_delete(self):
+ sm = difflib.SequenceMatcher(None, 'a' * 40 + 'c' + 'b' * 40, 'a' * 40 + 'b' * 40)
+ self.assertAlmostEqual(sm.ratio(), 0.994, places=3)
+ self.assertEqual(list(sm.get_opcodes()),
+ [ ('equal', 0, 40, 0, 40),
+ ('delete', 40, 41, 40, 40),
+ ('equal', 41, 81, 40, 80)])
+
+ def test_bjunk(self):
+ sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ',
+ a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40)
+ self.assertEqual(sm.bjunk, set())
+
+ sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ',
+ a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40 + ' ' * 20)
+ self.assertEqual(sm.bjunk, {' '})
+
+ sm = difflib.SequenceMatcher(isjunk=lambda x: x in [' ', 'b'],
+ a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40 + ' ' * 20)
+ self.assertEqual(sm.bjunk, {' ', 'b'})
+
+
+class TestAutojunk(unittest.TestCase):
+ """Tests for the autojunk parameter added in 2.7"""
+ def test_one_insert_homogenous_sequence(self):
+ # By default autojunk=True and the heuristic kicks in for a sequence
+ # of length 200+
+ seq1 = 'b' * 200
+ seq2 = 'a' + 'b' * 200
+
+ sm = difflib.SequenceMatcher(None, seq1, seq2)
+ self.assertAlmostEqual(sm.ratio(), 0, places=3)
+ self.assertEqual(sm.bpopular, {'b'})
+
+ # Now turn the heuristic off
+ sm = difflib.SequenceMatcher(None, seq1, seq2, autojunk=False)
+ self.assertAlmostEqual(sm.ratio(), 0.9975, places=3)
+ self.assertEqual(sm.bpopular, set())
+
+
+class TestSFbugs(unittest.TestCase):
def test_ratio_for_null_seqn(self):
# Check clearing of SF bug 763023
s = difflib.SequenceMatcher(None, [], [])
@@ -159,10 +215,34 @@ class TestSFpatches(unittest.TestCase):
difflib.SequenceMatcher(None, old, new).get_opcodes()
+class TestOutputFormat(unittest.TestCase):
+ def test_tab_delimiter(self):
+ args = ['one', 'two', 'Original', 'Current',
+ '2005-01-26 23:30:50', '2010-04-02 10:20:52']
+ ud = difflib.unified_diff(*args, lineterm='')
+ self.assertEqual(list(ud)[0:2], [
+ "--- Original\t2005-01-26 23:30:50",
+ "+++ Current\t2010-04-02 10:20:52"])
+ cd = difflib.context_diff(*args, lineterm='')
+ self.assertEqual(list(cd)[0:2], [
+ "*** Original\t2005-01-26 23:30:50",
+ "--- Current\t2010-04-02 10:20:52"])
+
+ def test_no_trailing_tab_on_empty_filedate(self):
+ args = ['one', 'two', 'Original', 'Current']
+ ud = difflib.unified_diff(*args, lineterm='')
+ self.assertEqual(list(ud)[0:2], ["--- Original", "+++ Current"])
+
+ cd = difflib.context_diff(*args, lineterm='')
+ self.assertEqual(list(cd)[0:2], ["*** Original", "--- Current"])
+
+
def test_main():
difflib.HtmlDiff._default_prefix = 0
Doctests = doctest.DocTestSuite(difflib)
- run_unittest(TestSFpatches, TestSFbugs, Doctests)
+ run_unittest(
+ TestWithAscii, TestAutojunk, TestSFpatches, TestSFbugs,
+ TestOutputFormat, Doctests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index d82dc5a1e2..7a61493c10 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -1,6 +1,6 @@
# Minimal tests for dis module
-from test.support import run_unittest
+from test.support import run_unittest, captured_stdout
import unittest
import sys
import dis
@@ -19,8 +19,8 @@ dis_f = """\
%-4d 10 LOAD_CONST 1 (1)
13 RETURN_VALUE
-"""%(_f.__code__.co_firstlineno + 1,
- _f.__code__.co_firstlineno + 2)
+""" % (_f.__code__.co_firstlineno + 1,
+ _f.__code__.co_firstlineno + 2)
def bug708901():
@@ -43,9 +43,9 @@ dis_bug708901 = """\
>> 25 POP_BLOCK
>> 26 LOAD_CONST 0 (None)
29 RETURN_VALUE
-"""%(bug708901.__code__.co_firstlineno + 1,
- bug708901.__code__.co_firstlineno + 2,
- bug708901.__code__.co_firstlineno + 3)
+""" % (bug708901.__code__.co_firstlineno + 1,
+ bug708901.__code__.co_firstlineno + 2,
+ bug708901.__code__.co_firstlineno + 3)
def bug1333982(x=[]):
@@ -74,9 +74,9 @@ dis_bug1333982 = """\
%-4d 40 LOAD_CONST 0 (None)
43 RETURN_VALUE
-"""%(bug1333982.__code__.co_firstlineno + 1,
- bug1333982.__code__.co_firstlineno + 2,
- bug1333982.__code__.co_firstlineno + 3)
+""" % (bug1333982.__code__.co_firstlineno + 1,
+ bug1333982.__code__.co_firstlineno + 2,
+ bug1333982.__code__.co_firstlineno + 3)
_BIG_LINENO_FORMAT = """\
%3d 0 LOAD_GLOBAL 0 (spam)
@@ -96,6 +96,46 @@ Disassembly of g:
"""
+expr_str = "x + 1"
+
+dis_expr_str = """\
+ 1 0 LOAD_NAME 0 (x)
+ 3 LOAD_CONST 0 (1)
+ 6 BINARY_ADD
+ 7 RETURN_VALUE
+"""
+
+simple_stmt_str = "x = x + 1"
+
+dis_simple_stmt_str = """\
+ 1 0 LOAD_NAME 0 (x)
+ 3 LOAD_CONST 0 (1)
+ 6 BINARY_ADD
+ 7 STORE_NAME 0 (x)
+ 10 LOAD_CONST 1 (None)
+ 13 RETURN_VALUE
+"""
+
+compound_stmt_str = """\
+x = 0
+while 1:
+ x += 1"""
+# Trailing newline has been deliberately omitted
+
+dis_compound_stmt_str = """\
+ 1 0 LOAD_CONST 0 (0)
+ 3 STORE_NAME 0 (x)
+
+ 2 6 SETUP_LOOP 13 (to 22)
+
+ 3 >> 9 LOAD_NAME 0 (x)
+ 12 LOAD_CONST 1 (1)
+ 15 INPLACE_ADD
+ 16 STORE_NAME 0 (x)
+ 19 JUMP_ABSOLUTE 9
+ >> 22 LOAD_CONST 2 (None)
+ 25 RETURN_VALUE
+"""
class DisTests(unittest.TestCase):
def do_disassembly_test(self, func, expected):
@@ -118,8 +158,8 @@ class DisTests(unittest.TestCase):
def test_opmap(self):
self.assertEqual(dis.opmap["STOP_CODE"], 0)
- self.assertEqual(dis.opmap["LOAD_CONST"] in dis.hasconst, True)
- self.assertEqual(dis.opmap["STORE_NAME"] in dis.hasname, True)
+ self.assertIn(dis.opmap["LOAD_CONST"], dis.hasconst)
+ self.assertIn(dis.opmap["STORE_NAME"], dis.hasname)
def test_opname(self):
self.assertEqual(dis.opname[dis.opmap["LOAD_FAST"]], "LOAD_FAST")
@@ -166,8 +206,165 @@ class DisTests(unittest.TestCase):
from test import dis_module
self.do_disassembly_test(dis_module, dis_module_expected_results)
+ def test_disassemble_str(self):
+ self.do_disassembly_test(expr_str, dis_expr_str)
+ self.do_disassembly_test(simple_stmt_str, dis_simple_stmt_str)
+ self.do_disassembly_test(compound_stmt_str, dis_compound_stmt_str)
+
+code_info_code_info = """\
+Name: code_info
+Filename: (.*)
+Argument count: 1
+Kw-only arguments: 0
+Number of locals: 1
+Stack size: 4
+Flags: OPTIMIZED, NEWLOCALS, NOFREE
+Constants:
+ 0: %r
+ 1: '__func__'
+ 2: '__code__'
+ 3: '<code_info>'
+ 4: 'co_code'
+ 5: "don't know how to disassemble %%s objects"
+%sNames:
+ 0: hasattr
+ 1: __func__
+ 2: __code__
+ 3: isinstance
+ 4: str
+ 5: _try_compile
+ 6: _format_code_info
+ 7: TypeError
+ 8: type
+ 9: __name__
+Variable names:
+ 0: x""" % (('Formatted details of methods, functions, or code.', ' 6: None\n')
+ if sys.flags.optimize < 2 else (None, ''))
+
+@staticmethod
+def tricky(x, y, z=True, *args, c, d, e=[], **kwds):
+ def f(c=c):
+ print(x, y, z, c, d, e, f)
+ yield x, y, z, c, d, e, f
+
+code_info_tricky = """\
+Name: tricky
+Filename: (.*)
+Argument count: 3
+Kw-only arguments: 3
+Number of locals: 8
+Stack size: 7
+Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, GENERATOR
+Constants:
+ 0: None
+ 1: <code object f at (.*), file "(.*)", line (.*)>
+Variable names:
+ 0: x
+ 1: y
+ 2: z
+ 3: c
+ 4: d
+ 5: e
+ 6: args
+ 7: kwds
+Cell variables:
+ 0: e
+ 1: d
+ 2: f
+ 3: y
+ 4: x
+ 5: z"""
+
+co_tricky_nested_f = tricky.__func__.__code__.co_consts[1]
+
+code_info_tricky_nested_f = """\
+Name: f
+Filename: (.*)
+Argument count: 1
+Kw-only arguments: 0
+Number of locals: 1
+Stack size: 8
+Flags: OPTIMIZED, NEWLOCALS, NESTED
+Constants:
+ 0: None
+Names:
+ 0: print
+Variable names:
+ 0: c
+Free variables:
+ 0: e
+ 1: d
+ 2: f
+ 3: y
+ 4: x
+ 5: z"""
+
+code_info_expr_str = """\
+Name: <module>
+Filename: <code_info>
+Argument count: 0
+Kw-only arguments: 0
+Number of locals: 0
+Stack size: 2
+Flags: NOFREE
+Constants:
+ 0: 1
+Names:
+ 0: x"""
+
+code_info_simple_stmt_str = """\
+Name: <module>
+Filename: <code_info>
+Argument count: 0
+Kw-only arguments: 0
+Number of locals: 0
+Stack size: 2
+Flags: NOFREE
+Constants:
+ 0: 1
+ 1: None
+Names:
+ 0: x"""
+
+code_info_compound_stmt_str = """\
+Name: <module>
+Filename: <code_info>
+Argument count: 0
+Kw-only arguments: 0
+Number of locals: 0
+Stack size: 2
+Flags: NOFREE
+Constants:
+ 0: 0
+ 1: 1
+ 2: None
+Names:
+ 0: x"""
+
+class CodeInfoTests(unittest.TestCase):
+ test_pairs = [
+ (dis.code_info, code_info_code_info),
+ (tricky, code_info_tricky),
+ (co_tricky_nested_f, code_info_tricky_nested_f),
+ (expr_str, code_info_expr_str),
+ (simple_stmt_str, code_info_simple_stmt_str),
+ (compound_stmt_str, code_info_compound_stmt_str),
+ ]
+
+ def test_code_info(self):
+ self.maxDiff = 1000
+ for x, expected in self.test_pairs:
+ self.assertRegex(dis.code_info(x), expected)
+
+ def test_show_code(self):
+ self.maxDiff = 1000
+ for x, expected in self.test_pairs:
+ with captured_stdout() as output:
+ dis.show_code(x)
+ self.assertRegex(output.getvalue(), expected+"\n")
+
def test_main():
- run_unittest(DisTests)
+ run_unittest(DisTests, CodeInfoTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_distutils.py b/Lib/test/test_distutils.py
index 94e59bc58a..d613abe453 100644
--- a/Lib/test/test_distutils.py
+++ b/Lib/test/test_distutils.py
@@ -11,6 +11,7 @@ import test.support
def test_main():
test.support.run_unittest(distutils.tests.test_suite())
+ test.support.reap_children()
if __name__ == "__main__":
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index de85758ac5..13836bafa0 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -4,7 +4,8 @@ Test script for doctest.
from test import support
import doctest
-import warnings
+import os
+
# NOTE: There are some additional tests relating to interaction with
# zipimport in the test_zipimport_support test module.
@@ -372,7 +373,7 @@ We'll simulate a __file__ attr that ends in pyc:
>>> tests = finder.find(sample_func)
>>> print(tests) # doctest: +ELLIPSIS
- [<DocTest sample_func from ...:16 (1 example)>]
+ [<DocTest sample_func from ...:17 (1 example)>]
The exact name depends on how test_doctest was invoked, so allow for
leading path components.
@@ -498,6 +499,8 @@ If a single object is listed twice (under different names), then tests
will only be generated for it once:
>>> from test import doctest_aliases
+ >>> assert doctest_aliases.TwoNames.f
+ >>> assert doctest_aliases.TwoNames.g
>>> tests = excl_empty_finder.find(doctest_aliases)
>>> print(len(tests))
2
@@ -862,6 +865,77 @@ detail:
>>> doctest.DocTestRunner(verbose=False).run(test)
TestResults(failed=0, attempted=1)
+IGNORE_EXCEPTION_DETAIL also ignores difference in exception formatting
+between Python versions. For example, in Python 2.x, the module path of
+the exception is not in the output, but this will fail under Python 3:
+
+ >>> def f(x):
+ ... r'''
+ ... >>> from http.client import HTTPException
+ ... >>> raise HTTPException('message')
+ ... Traceback (most recent call last):
+ ... HTTPException: message
+ ... '''
+ >>> test = doctest.DocTestFinder().find(f)[0]
+ >>> doctest.DocTestRunner(verbose=False).run(test)
+ ... # doctest: +ELLIPSIS
+ **********************************************************************
+ File ..., line 4, in f
+ Failed example:
+ raise HTTPException('message')
+ Expected:
+ Traceback (most recent call last):
+ HTTPException: message
+ Got:
+ Traceback (most recent call last):
+ ...
+ http.client.HTTPException: message
+ TestResults(failed=1, attempted=2)
+
+But in Python 3 the module path is included, and therefore a test must look
+like the following test to succeed in Python 3. But that test will fail under
+Python 2.
+
+ >>> def f(x):
+ ... r'''
+ ... >>> from http.client import HTTPException
+ ... >>> raise HTTPException('message')
+ ... Traceback (most recent call last):
+ ... http.client.HTTPException: message
+ ... '''
+ >>> test = doctest.DocTestFinder().find(f)[0]
+ >>> doctest.DocTestRunner(verbose=False).run(test)
+ TestResults(failed=0, attempted=2)
+
+However, with IGNORE_EXCEPTION_DETAIL, the module name of the exception
+(or its unexpected absence) will be ignored:
+
+ >>> def f(x):
+ ... r'''
+ ... >>> from http.client import HTTPException
+ ... >>> raise HTTPException('message') #doctest: +IGNORE_EXCEPTION_DETAIL
+ ... Traceback (most recent call last):
+ ... HTTPException: message
+ ... '''
+ >>> test = doctest.DocTestFinder().find(f)[0]
+ >>> doctest.DocTestRunner(verbose=False).run(test)
+ TestResults(failed=0, attempted=2)
+
+The module path will be completely ignored, so two different module paths will
+still pass if IGNORE_EXCEPTION_DETAIL is given. This is intentional, so it can
+be used when exceptions have changed module.
+
+ >>> def f(x):
+ ... r'''
+ ... >>> from http.client import HTTPException
+ ... >>> raise HTTPException('message') #doctest: +IGNORE_EXCEPTION_DETAIL
+ ... Traceback (most recent call last):
+ ... foo.bar.HTTPException: message
+ ... '''
+ >>> test = doctest.DocTestFinder().find(f)[0]
+ >>> doctest.DocTestRunner(verbose=False).run(test)
+ TestResults(failed=0, attempted=2)
+
But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
>>> def f(x):
@@ -1624,10 +1698,13 @@ def test_pdb_set_trace():
>>> doc = '''
... >>> x = 42
+ ... >>> raise Exception('clé')
+ ... Traceback (most recent call last):
+ ... Exception: clé
... >>> import pdb; pdb.set_trace()
... '''
>>> parser = doctest.DocTestParser()
- >>> test = parser.get_doctest(doc, {}, "foo", "foo.py", 0)
+ >>> test = parser.get_doctest(doc, {}, "foo-bar@baz", "foo-bar@baz.py", 0)
>>> runner = doctest.DocTestRunner(verbose=False)
To demonstrate this, we'll create a fake standard input that
@@ -1643,12 +1720,12 @@ def test_pdb_set_trace():
>>> try: runner.run(test)
... finally: sys.stdin = real_stdin
--Return--
- > <doctest foo[1]>(1)<module>()->None
+ > <doctest foo-bar@baz[2]>(1)<module>()->None
-> import pdb; pdb.set_trace()
(Pdb) print(x)
42
(Pdb) continue
- TestResults(failed=0, attempted=2)
+ TestResults(failed=0, attempted=3)
You can also put pdb.set_trace in a function called from a test:
@@ -1660,7 +1737,7 @@ def test_pdb_set_trace():
... >>> x=1
... >>> calls_set_trace()
... '''
- >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
+ >>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
... 'print(y)', # print data defined in the function
@@ -1679,7 +1756,7 @@ def test_pdb_set_trace():
(Pdb) print(y)
2
(Pdb) up
- > <doctest foo[1]>(1)<module>()
+ > <doctest foo-bar@baz[1]>(1)<module>()
-> calls_set_trace()
(Pdb) print(x)
1
@@ -1697,7 +1774,7 @@ def test_pdb_set_trace():
... ... import pdb; pdb.set_trace()
... >>> f(3)
... '''
- >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
+ >>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
... 'list', # list source from example 2
@@ -1711,7 +1788,7 @@ def test_pdb_set_trace():
... finally: sys.stdin = real_stdin
... # doctest: +NORMALIZE_WHITESPACE
--Return--
- > <doctest foo[1]>(3)g()->None
+ > <doctest foo-bar@baz[1]>(3)g()->None
-> import pdb; pdb.set_trace()
(Pdb) list
1 def g(x):
@@ -1720,7 +1797,7 @@ def test_pdb_set_trace():
[EOF]
(Pdb) next
--Return--
- > <doctest foo[0]>(2)f()->None
+ > <doctest foo-bar@baz[0]>(2)f()->None
-> g(x*2)
(Pdb) list
1 def f(x):
@@ -1728,14 +1805,14 @@ def test_pdb_set_trace():
[EOF]
(Pdb) next
--Return--
- > <doctest foo[2]>(1)<module>()->None
+ > <doctest foo-bar@baz[2]>(1)<module>()->None
-> f(3)
(Pdb) list
1 -> f(3)
[EOF]
(Pdb) continue
**********************************************************************
- File "foo.py", line 7, in foo
+ File "foo-bar@baz.py", line 7, in foo-bar@baz
Failed example:
f(3)
Expected nothing
@@ -1769,7 +1846,7 @@ def test_pdb_set_trace_nested():
... '''
>>> parser = doctest.DocTestParser()
>>> runner = doctest.DocTestRunner(verbose=False)
- >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
+ >>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
... 'print(y)', # print data defined in the function
@@ -1822,10 +1899,10 @@ def test_pdb_set_trace_nested():
(Pdb) print(y)
1
(Pdb) up
- > <doctest foo[1]>(1)<module>()
+ > <doctest foo-bar@baz[1]>(1)<module>()
-> calls_set_trace()
(Pdb) print(foo)
- *** NameError: NameError("name 'foo' is not defined",)
+ *** NameError: name 'foo' is not defined
(Pdb) continue
TestResults(failed=0, attempted=2)
"""
@@ -1840,19 +1917,19 @@ def test_DocTestSuite():
>>> import test.sample_doctest
>>> suite = doctest.DocTestSuite(test.sample_doctest)
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=9 errors=0 failures=4>
+ <unittest.result.TestResult run=9 errors=0 failures=4>
We can also supply the module by name:
>>> suite = doctest.DocTestSuite('test.sample_doctest')
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=9 errors=0 failures=4>
+ <unittest.result.TestResult run=9 errors=0 failures=4>
We can use the current module:
>>> suite = test.sample_doctest.test_suite()
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=9 errors=0 failures=4>
+ <unittest.result.TestResult run=9 errors=0 failures=4>
We can supply global variables. If we pass globs, they will be
used instead of the module globals. Here we'll pass an empty
@@ -1860,7 +1937,7 @@ def test_DocTestSuite():
>>> suite = doctest.DocTestSuite('test.sample_doctest', globs={})
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=9 errors=0 failures=5>
+ <unittest.result.TestResult run=9 errors=0 failures=5>
Alternatively, we can provide extra globals. Here we'll make an
error go away by providing an extra global variable:
@@ -1868,7 +1945,7 @@ def test_DocTestSuite():
>>> suite = doctest.DocTestSuite('test.sample_doctest',
... extraglobs={'y': 1})
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=9 errors=0 failures=3>
+ <unittest.result.TestResult run=9 errors=0 failures=3>
You can pass option flags. Here we'll cause an extra error
by disabling the blank-line feature:
@@ -1876,7 +1953,7 @@ def test_DocTestSuite():
>>> suite = doctest.DocTestSuite('test.sample_doctest',
... optionflags=doctest.DONT_ACCEPT_BLANKLINE)
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=9 errors=0 failures=5>
+ <unittest.result.TestResult run=9 errors=0 failures=5>
You can supply setUp and tearDown functions:
@@ -1893,7 +1970,7 @@ def test_DocTestSuite():
>>> suite = doctest.DocTestSuite('test.sample_doctest',
... setUp=setUp, tearDown=tearDown)
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=9 errors=0 failures=3>
+ <unittest.result.TestResult run=9 errors=0 failures=3>
But the tearDown restores sanity:
@@ -1911,7 +1988,7 @@ def test_DocTestSuite():
>>> suite = doctest.DocTestSuite('test.sample_doctest', setUp=setUp)
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=9 errors=0 failures=3>
+ <unittest.result.TestResult run=9 errors=0 failures=3>
Here, we didn't need to use a tearDown function because we
modified the test globals, which are a copy of the
@@ -1930,7 +2007,7 @@ def test_DocFileSuite():
... 'test_doctest2.txt',
... 'test_doctest4.txt')
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=3 errors=0 failures=2>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
The test files are looked for in the directory containing the
calling module. A package keyword argument can be provided to
@@ -1942,7 +2019,7 @@ def test_DocFileSuite():
... 'test_doctest4.txt',
... package='test')
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=3 errors=0 failures=2>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
Support for using a package's __loader__.get_data() is also
provided.
@@ -1961,14 +2038,14 @@ def test_DocFileSuite():
... finally:
... if added_loader:
... del test.__loader__
- <unittest.TestResult run=3 errors=0 failures=2>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
'/' should be used as a path separator. It will be converted
to a native separator at run time:
>>> suite = doctest.DocFileSuite('../test/test_doctest.txt')
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=1 errors=0 failures=1>
+ <unittest.result.TestResult run=1 errors=0 failures=1>
If DocFileSuite is used from an interactive session, then files
are resolved relative to the directory of sys.argv[0]:
@@ -1993,7 +2070,7 @@ def test_DocFileSuite():
>>> suite = doctest.DocFileSuite(test_file, module_relative=False)
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=1 errors=0 failures=1>
+ <unittest.result.TestResult run=1 errors=0 failures=1>
It is an error to specify `package` when `module_relative=False`:
@@ -2009,7 +2086,7 @@ def test_DocFileSuite():
... 'test_doctest4.txt',
... globs={'favorite_color': 'blue'})
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=3 errors=0 failures=1>
+ <unittest.result.TestResult run=3 errors=0 failures=1>
In this case, we supplied a missing favorite color. You can
provide doctest options:
@@ -2020,7 +2097,7 @@ def test_DocFileSuite():
... optionflags=doctest.DONT_ACCEPT_BLANKLINE,
... globs={'favorite_color': 'blue'})
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=3 errors=0 failures=2>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
And, you can provide setUp and tearDown functions:
@@ -2039,7 +2116,7 @@ def test_DocFileSuite():
... 'test_doctest4.txt',
... setUp=setUp, tearDown=tearDown)
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=3 errors=0 failures=1>
+ <unittest.result.TestResult run=3 errors=0 failures=1>
But the tearDown restores sanity:
@@ -2058,7 +2135,7 @@ def test_DocFileSuite():
>>> suite = doctest.DocFileSuite('test_doctest.txt', setUp=setUp)
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=1 errors=0 failures=0>
+ <unittest.result.TestResult run=1 errors=0 failures=0>
Here, we didn't need to use a tearDown function because we
modified the test globals. The test globals are
@@ -2070,7 +2147,7 @@ def test_DocFileSuite():
>>> suite = doctest.DocFileSuite('test_doctest3.txt')
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=1 errors=0 failures=0>
+ <unittest.result.TestResult run=1 errors=0 failures=0>
If the tests contain non-ASCII characters, we have to specify which
encoding the file is encoded with. We do so by using the `encoding`
@@ -2081,7 +2158,7 @@ def test_DocFileSuite():
... 'test_doctest4.txt',
... encoding='utf-8')
>>> suite.run(unittest.TestResult())
- <unittest.TestResult run=3 errors=0 failures=2>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
"""
@@ -2357,6 +2434,39 @@ out of the binary module.
TestResults(failed=0, attempted=0)
"""
+try:
+ os.fsencode("foo-bär@baz.py")
+except UnicodeEncodeError:
+ # Skip the test: the filesystem encoding is unable to encode the filename
+ pass
+else:
+ def test_unicode(): """
+Check doctest with a non-ascii filename:
+
+ >>> doc = '''
+ ... >>> raise Exception('clé')
+ ... '''
+ ...
+ >>> parser = doctest.DocTestParser()
+ >>> test = parser.get_doctest(doc, {}, "foo-bär@baz", "foo-bär@baz.py", 0)
+ >>> test
+ <DocTest foo-bär@baz from foo-bär@baz.py:0 (1 example)>
+ >>> runner = doctest.DocTestRunner(verbose=False)
+ >>> runner.run(test) # doctest: +ELLIPSIS
+ **********************************************************************
+ File "foo-bär@baz.py", line 2, in foo-bär@baz
+ Failed example:
+ raise Exception('clé')
+ Exception raised:
+ Traceback (most recent call last):
+ File ...
+ compileflags, 1), test.globs)
+ File "<doctest foo-bär@baz[0]>", line 1, in <module>
+ raise Exception('clé')
+ Exception: clé
+ TestResults(failed=1, attempted=1)
+ """
+
######################################################################
## Main
######################################################################
@@ -2368,8 +2478,10 @@ def test_main():
from test import test_doctest
support.run_doctest(test_doctest, verbosity=True)
-import trace, sys, re, io
+import sys, re, io
+
def test_coverage(coverdir):
+ trace = support.import_module('trace')
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
trace=0, count=1)
tracer.run('test_main()')
diff --git a/Lib/test/test_doctest2.py b/Lib/test/test_doctest2.py
index 86334d70d8..347a143641 100644
--- a/Lib/test/test_doctest2.py
+++ b/Lib/test/test_doctest2.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""A module to test whether doctest recognizes some 2.2 features,
like static and class methods.
@@ -12,7 +11,11 @@ the example. It should be ignored:
"""
+import sys
+import unittest
from test import support
+if sys.flags.optimize >= 2:
+ raise unittest.SkipTest("Cannot test docstrings with -O2")
class C(object):
"""Class C.
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
index 7bffa48388..60a69dd91f 100644
--- a/Lib/test/test_docxmlrpc.py
+++ b/Lib/test/test_docxmlrpc.py
@@ -1,12 +1,28 @@
from xmlrpc.server import DocXMLRPCServer
import http.client
+import sys
from test import support
-import threading
+threading = support.import_module('threading')
import time
+import socket
import unittest
PORT = None
+def make_request_and_skipIf(condition, reason):
+ # If we skip the test, we have to make a request because the
+ # the server created in setUp blocks expecting one to come in.
+ if not condition:
+ return lambda func: func
+ def decorator(func):
+ def make_request_and_skip(self):
+ self.client.request("GET", "/")
+ self.client.getresponse()
+ raise unittest.SkipTest(reason)
+ return make_request_and_skip
+ return decorator
+
+
def server(evt, numrequests):
serv = DocXMLRPCServer(("localhost", 0), logRequests=False)
@@ -18,8 +34,8 @@ def server(evt, numrequests):
serv.set_server_title("DocXMLRPCServer Test Documentation")
serv.set_server_name("DocXMLRPCServer Test Docs")
serv.set_server_documentation(
-"""This is an XML-RPC server's documentation, but the server can be used by
-POSTing to /RPC2. Try self.add, too.""")
+ "This is an XML-RPC server's documentation, but the server "
+ "can be used by POSTing to /RPC2. Try self.add, too.")
# Create and register classes and functions
class TestClass(object):
@@ -53,6 +69,7 @@ POSTing to /RPC2. Try self.add, too.""")
class DocXMLRPCHTTPGETServer(unittest.TestCase):
def setUp(self):
+ self._threads = support.threading_setup()
# Enable server feedback
DocXMLRPCServer._send_traceback_header = True
@@ -74,6 +91,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
# Disable server feedback
DocXMLRPCServer._send_traceback_header = False
+ support.threading_cleanup(*self._threads)
def test_valid_get_response(self):
self.client.request("GET", "/")
@@ -104,35 +122,65 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
self.client.request("GET", "/")
response = self.client.getresponse()
- self.assertTrue(
-b"""<dl><dt><a name="-&lt;lambda&gt;"><strong>&lt;lambda&gt;</strong></a>(x, y)</dt></dl>"""
- in response.read())
+ self.assertIn((b'<dl><dt><a name="-&lt;lambda&gt;"><strong>'
+ b'&lt;lambda&gt;</strong></a>(x, y)</dt></dl>'),
+ response.read())
+ @make_request_and_skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_autolinking(self):
- """Test that the server correctly automatically wraps references to PEPS
- and RFCs with links, and that it linkifies text starting with http or
- ftp protocol prefixes.
+ """Test that the server correctly automatically wraps references to
+ PEPS and RFCs with links, and that it linkifies text starting with
+ http or ftp protocol prefixes.
The documentation for the "add" method contains the test material.
"""
self.client.request("GET", "/")
response = self.client.getresponse().read()
- self.assertTrue( # This is ugly ... how can it be made better?
-b"""<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd><tt>Add&nbsp;two&nbsp;instances&nbsp;together.&nbsp;This&nbsp;follows&nbsp;<a href="http://www.python.org/dev/peps/pep-0008/">PEP008</a>,&nbsp;but&nbsp;has&nbsp;nothing<br>\nto&nbsp;do&nbsp;with&nbsp;<a href="http://www.rfc-editor.org/rfc/rfc1952.txt">RFC1952</a>.&nbsp;Case&nbsp;should&nbsp;matter:&nbsp;pEp008&nbsp;and&nbsp;rFC1952.&nbsp;&nbsp;Things<br>\nthat&nbsp;start&nbsp;with&nbsp;http&nbsp;and&nbsp;ftp&nbsp;should&nbsp;be&nbsp;auto-linked,&nbsp;too:<br>\n<a href="http://google.com">http://google.com</a>.</tt></dd></dl>"""
- in response, response)
-
+ self.assertIn(
+ (b'<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd>'
+ b'<tt>Add&nbsp;two&nbsp;instances&nbsp;together.&nbsp;This&nbsp;'
+ b'follows&nbsp;<a href="http://www.python.org/dev/peps/pep-0008/">'
+ b'PEP008</a>,&nbsp;but&nbsp;has&nbsp;nothing<br>\nto&nbsp;do&nbsp;'
+ b'with&nbsp;<a href="http://www.rfc-editor.org/rfc/rfc1952.txt">'
+ b'RFC1952</a>.&nbsp;Case&nbsp;should&nbsp;matter:&nbsp;pEp008&nbsp;'
+ b'and&nbsp;rFC1952.&nbsp;&nbsp;Things<br>\nthat&nbsp;start&nbsp;'
+ b'with&nbsp;http&nbsp;and&nbsp;ftp&nbsp;should&nbsp;be&nbsp;'
+ b'auto-linked,&nbsp;too:<br>\n<a href="http://google.com">'
+ b'http://google.com</a>.</tt></dd></dl>'), response)
+
+ @make_request_and_skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_system_methods(self):
"""Test the precense of three consecutive system.* methods.
- This also tests their use of parameter type recognition and the systems
- related to that process.
+ This also tests their use of parameter type recognition and the
+ systems related to that process.
"""
self.client.request("GET", "/")
response = self.client.getresponse().read()
- self.assertTrue(
-b"""<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp</strong></a>(method_name)</dt><dd><tt><a href="#-system.methodHelp">system.methodHelp</a>(\'add\')&nbsp;=&gt;&nbsp;"Adds&nbsp;two&nbsp;integers&nbsp;together"<br>\n&nbsp;<br>\nReturns&nbsp;a&nbsp;string&nbsp;containing&nbsp;documentation&nbsp;for&nbsp;the&nbsp;specified&nbsp;method.</tt></dd></dl>\n<dl><dt><a name="-system.methodSignature"><strong>system.methodSignature</strong></a>(method_name)</dt><dd><tt><a href="#-system.methodSignature">system.methodSignature</a>(\'add\')&nbsp;=&gt;&nbsp;[double,&nbsp;int,&nbsp;int]<br>\n&nbsp;<br>\nReturns&nbsp;a&nbsp;list&nbsp;describing&nbsp;the&nbsp;signature&nbsp;of&nbsp;the&nbsp;method.&nbsp;In&nbsp;the<br>\nabove&nbsp;example,&nbsp;the&nbsp;add&nbsp;method&nbsp;takes&nbsp;two&nbsp;integers&nbsp;as&nbsp;arguments<br>\nand&nbsp;returns&nbsp;a&nbsp;double&nbsp;result.<br>\n&nbsp;<br>\nThis&nbsp;server&nbsp;does&nbsp;NOT&nbsp;support&nbsp;system.methodSignature.</tt></dd></dl>\n<dl><dt><a name="-test_method"><strong>test_method</strong></a>(arg)</dt><dd><tt>Test&nbsp;method\'s&nbsp;docs.&nbsp;This&nbsp;method&nbsp;truly&nbsp;does&nbsp;very&nbsp;little.</tt></dd></dl>""" in response)
+ self.assertIn(
+ (b'<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp'
+ b'</strong></a>(method_name)</dt><dd><tt><a href="#-system.method'
+ b'Help">system.methodHelp</a>(\'add\')&nbsp;=&gt;&nbsp;"Adds&nbsp;'
+ b'two&nbsp;integers&nbsp;together"<br>\n&nbsp;<br>\nReturns&nbsp;a'
+ b'&nbsp;string&nbsp;containing&nbsp;documentation&nbsp;for&nbsp;'
+ b'the&nbsp;specified&nbsp;method.</tt></dd></dl>\n<dl><dt><a name'
+ b'="-system.methodSignature"><strong>system.methodSignature</strong>'
+ b'</a>(method_name)</dt><dd><tt><a href="#-system.methodSignature">'
+ b'system.methodSignature</a>(\'add\')&nbsp;=&gt;&nbsp;[double,&nbsp;'
+ b'int,&nbsp;int]<br>\n&nbsp;<br>\nReturns&nbsp;a&nbsp;list&nbsp;'
+ b'describing&nbsp;the&nbsp;signature&nbsp;of&nbsp;the&nbsp;method.'
+ b'&nbsp;In&nbsp;the<br>\nabove&nbsp;example,&nbsp;the&nbsp;add&nbsp;'
+ b'method&nbsp;takes&nbsp;two&nbsp;integers&nbsp;as&nbsp;arguments'
+ b'<br>\nand&nbsp;returns&nbsp;a&nbsp;double&nbsp;result.<br>\n&nbsp;'
+ b'<br>\nThis&nbsp;server&nbsp;does&nbsp;NOT&nbsp;support&nbsp;system'
+ b'.methodSignature.</tt></dd></dl>\n<dl><dt><a name="-test_method">'
+ b'<strong>test_method</strong></a>(arg)</dt><dd><tt>Test&nbsp;'
+ b'method\'s&nbsp;docs.&nbsp;This&nbsp;method&nbsp;truly&nbsp;does'
+ b'&nbsp;very&nbsp;little.</tt></dd></dl>'), response)
def test_autolink_dotted_methods(self):
"""Test that selfdot values are made strong automatically in the
@@ -140,8 +188,8 @@ b"""<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp</strong></a>(
self.client.request("GET", "/")
response = self.client.getresponse()
- self.assertTrue(b"""Try&nbsp;self.<strong>add</strong>,&nbsp;too.""" in
- response.read())
+ self.assertIn(b"""Try&nbsp;self.<strong>add</strong>,&nbsp;too.""",
+ response.read())
def test_main():
support.run_unittest(DocXMLRPCHTTPGETServer)
diff --git a/Lib/test/test_dummy_thread.py b/Lib/test/test_dummy_thread.py
index 240b61ad83..c61078d620 100644
--- a/Lib/test/test_dummy_thread.py
+++ b/Lib/test/test_dummy_thread.py
@@ -92,16 +92,16 @@ class MiscTests(unittest.TestCase):
def test_ident(self):
#Test sanity of _thread.get_ident()
- self.assertTrue(isinstance(_thread.get_ident(), int),
- "_thread.get_ident() returned a non-integer")
+ self.assertIsInstance(_thread.get_ident(), int,
+ "_thread.get_ident() returned a non-integer")
self.assertTrue(_thread.get_ident() != 0,
"_thread.get_ident() returned 0")
def test_LockType(self):
#Make sure _thread.LockType is the same type as _thread.allocate_locke()
- self.assertTrue(isinstance(_thread.allocate_lock(), _thread.LockType),
- "_thread.LockType is not an instance of what is "
- "returned by _thread.allocate_lock()")
+ self.assertIsInstance(_thread.allocate_lock(), _thread.LockType,
+ "_thread.LockType is not an instance of what "
+ "is returned by _thread.allocate_lock()")
def test_interrupt_main(self):
#Calling start_new_thread with a function that executes interrupt_main
diff --git a/Lib/test/test_dynamic.py b/Lib/test/test_dynamic.py
new file mode 100644
index 0000000000..beb7b1cdf1
--- /dev/null
+++ b/Lib/test/test_dynamic.py
@@ -0,0 +1,143 @@
+# Test the most dynamic corner cases of Python's runtime semantics.
+
+import builtins
+import contextlib
+import unittest
+
+from test.support import run_unittest, swap_item, swap_attr
+
+
+class RebindBuiltinsTests(unittest.TestCase):
+
+ """Test all the ways that we can change/shadow globals/builtins."""
+
+ def configure_func(self, func, *args):
+ """Perform TestCase-specific configuration on a function before testing.
+
+ By default, this does nothing. Example usage: spinning a function so
+ that a JIT will optimize it. Subclasses should override this as needed.
+
+ Args:
+ func: function to configure.
+ *args: any arguments that should be passed to func, if calling it.
+
+ Returns:
+ Nothing. Work will be performed on func in-place.
+ """
+ pass
+
+ def test_globals_shadow_builtins(self):
+ # Modify globals() to shadow an entry in builtins.
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ self.assertEqual(foo(), 3)
+ with swap_item(globals(), "len", lambda x: 7):
+ self.assertEqual(foo(), 7)
+
+ def test_modify_builtins(self):
+ # Modify the builtins module directly.
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ self.assertEqual(foo(), 3)
+ with swap_attr(builtins, "len", lambda x: 7):
+ self.assertEqual(foo(), 7)
+
+ def test_modify_builtins_while_generator_active(self):
+ # Modify the builtins out from under a live generator.
+ def foo():
+ x = range(3)
+ yield len(x)
+ yield len(x)
+ self.configure_func(foo)
+
+ g = foo()
+ self.assertEqual(next(g), 3)
+ with swap_attr(builtins, "len", lambda x: 7):
+ self.assertEqual(next(g), 7)
+
+ def test_modify_builtins_from_leaf_function(self):
+ # Verify that modifications made by leaf functions percolate up the
+ # callstack.
+ with swap_attr(builtins, "len", len):
+ def bar():
+ builtins.len = lambda x: 4
+
+ def foo(modifier):
+ l = []
+ l.append(len(range(7)))
+ modifier()
+ l.append(len(range(7)))
+ return l
+ self.configure_func(foo, lambda: None)
+
+ self.assertEqual(foo(bar), [7, 4])
+
+ def test_cannot_change_globals_or_builtins_with_eval(self):
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ # Note that this *doesn't* change the definition of len() seen by foo().
+ builtins_dict = {"len": lambda x: 7}
+ globals_dict = {"foo": foo, "__builtins__": builtins_dict,
+ "len": lambda x: 8}
+ self.assertEqual(eval("foo()", globals_dict), 3)
+
+ self.assertEqual(eval("foo()", {"foo": foo}), 3)
+
+ def test_cannot_change_globals_or_builtins_with_exec(self):
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ globals_dict = {"foo": foo}
+ exec("x = foo()", globals_dict)
+ self.assertEqual(globals_dict["x"], 3)
+
+ # Note that this *doesn't* change the definition of len() seen by foo().
+ builtins_dict = {"len": lambda x: 7}
+ globals_dict = {"foo": foo, "__builtins__": builtins_dict,
+ "len": lambda x: 8}
+
+ exec("x = foo()", globals_dict)
+ self.assertEqual(globals_dict["x"], 3)
+
+ def test_cannot_replace_builtins_dict_while_active(self):
+ def foo():
+ x = range(3)
+ yield len(x)
+ yield len(x)
+ self.configure_func(foo)
+
+ g = foo()
+ self.assertEqual(next(g), 3)
+ with swap_item(globals(), "__builtins__", {"len": lambda x: 7}):
+ self.assertEqual(next(g), 3)
+
+ def test_cannot_replace_builtins_dict_between_calls(self):
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ self.assertEqual(foo(), 3)
+ with swap_item(globals(), "__builtins__", {"len": lambda x: 7}):
+ self.assertEqual(foo(), 3)
+
+ def test_eval_gives_lambda_custom_globals(self):
+ globals_dict = {"len": lambda x: 7}
+ foo = eval("lambda: len([])", globals_dict)
+ self.configure_func(foo)
+
+ self.assertEqual(foo(), 7)
+
+
+def test_main():
+ run_unittest(RebindBuiltinsTests)
+
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py
index f0a18e71d0..5eebba5590 100644
--- a/Lib/test/test_email.py
+++ b/Lib/test/test_email.py
@@ -3,10 +3,12 @@
# The specific tests now live in Lib/email/test
from email.test.test_email import suite
+from email.test.test_email_codecs import suite as codecs_suite
from test import support
def test_main():
support.run_unittest(suite())
+ support.run_unittest(codecs_suite())
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py
index 4dc9a124cf..095820b45f 100644
--- a/Lib/test/test_enumerate.py
+++ b/Lib/test/test_enumerate.py
@@ -103,6 +103,7 @@ class EnumerateTestCase(unittest.TestCase):
self.assertRaises(TypeError, self.enum, 'abc', 'a') # wrong type
self.assertRaises(TypeError, self.enum, 'abc', 2, 3) # too many arguments
+ @support.cpython_only
def test_tuple_reuse(self):
# Tests an implementation detail where tuple is reused
# whenever nothing else holds a reference to it
@@ -145,6 +146,7 @@ class TestReversed(unittest.TestCase):
x = range(1)
self.assertEqual(type(reversed(x)), type(iter(x)))
+ @support.cpython_only
def test_len(self):
# This is an implementation detail, not an interface requirement
from test.test_iterlen import len
@@ -198,6 +200,18 @@ class TestReversed(unittest.TestCase):
self.fail("non-callable __reversed__ didn't raise!")
self.assertEqual(rc, sys.getrefcount(r))
+ def test_objmethods(self):
+ # Objects must have __len__() and __getitem__() implemented.
+ class NoLen(object):
+ def __getitem__(self): return 1
+ nl = NoLen()
+ self.assertRaises(TypeError, reversed, nl)
+
+ class NoGetItem(object):
+ def __len__(self): return 2
+ ngi = NoGetItem()
+ self.assertRaises(TypeError, reversed, ngi)
+
class EnumerateStartTestCase(EnumerateTestCase):
diff --git a/Lib/test/test_eof.py b/Lib/test/test_eof.py
index 4e37560a3d..fb4ac9a639 100644
--- a/Lib/test/test_eof.py
+++ b/Lib/test/test_eof.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""test script for a few new invalid token catches"""
import unittest
diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py
index 14ac2d5975..275e59834c 100644
--- a/Lib/test/test_epoll.py
+++ b/Lib/test/test_epoll.py
@@ -21,12 +21,10 @@
"""
Tests for epoll wrapper.
"""
-import os
import socket
import errno
import time
import select
-import tempfile
import unittest
from test import support
diff --git a/Lib/test/test_errno.py b/Lib/test/test_errno.py
index 80edcc680a..f414a87796 100755
--- a/Lib/test/test_errno.py
+++ b/Lib/test/test_errno.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test the errno module
Roger E. Masse
"""
@@ -20,7 +20,8 @@ class ErrnoAttributeTests(unittest.TestCase):
def test_using_errorcode(self):
# Every key value in errno.errorcode should be on the module.
for value in errno.errorcode.values():
- self.assertTrue(hasattr(errno, value), 'no %s attr in errno' % value)
+ self.assertTrue(hasattr(errno, value),
+ 'no %s attr in errno' % value)
class ErrorcodeTests(unittest.TestCase):
@@ -28,8 +29,8 @@ class ErrorcodeTests(unittest.TestCase):
def test_attributes_in_errorcode(self):
for attribute in errno.__dict__.keys():
if attribute.isupper():
- self.assertTrue(getattr(errno, attribute) in errno.errorcode,
- 'no %s attr in errno.errorcode' % attribute)
+ self.assertIn(getattr(errno, attribute), errno.errorcode,
+ 'no %s attr in errno.errorcode' % attribute)
def test_main():
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 5b36186fa3..76f4249490 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -7,7 +7,7 @@ import pickle
import weakref
from test.support import (TESTFN, unlink, run_unittest, captured_output,
- gc_collect)
+ gc_collect, cpython_only)
# XXX This is not really enough, each *operation* should be tested!
@@ -137,6 +137,7 @@ class ExceptionTests(unittest.TestCase):
ckmsg(s, "'continue' not properly in loop")
ckmsg("continue\n", "'continue' not properly in loop")
+ @cpython_only
def testSettingException(self):
# test that setting an exception at the C level works even if the
# exception object can't be constructed.
@@ -319,25 +320,25 @@ class ExceptionTests(unittest.TestCase):
tb = sys.exc_info()[2]
e = BaseException().with_traceback(tb)
- self.assertTrue(isinstance(e, BaseException))
+ self.assertIsInstance(e, BaseException)
self.assertEqual(e.__traceback__, tb)
e = IndexError(5).with_traceback(tb)
- self.assertTrue(isinstance(e, IndexError))
+ self.assertIsInstance(e, IndexError)
self.assertEqual(e.__traceback__, tb)
class MyException(Exception):
pass
e = MyException().with_traceback(tb)
- self.assertTrue(isinstance(e, MyException))
+ self.assertIsInstance(e, MyException)
self.assertEqual(e.__traceback__, tb)
def testInvalidTraceback(self):
try:
Exception().__traceback__ = 5
except TypeError as e:
- self.assertTrue("__traceback__ must be a traceback" in str(e))
+ self.assertIn("__traceback__ must be a traceback", str(e))
else:
self.fail("No exception raised")
@@ -413,7 +414,7 @@ class ExceptionTests(unittest.TestCase):
except Exception as e:
self.assertTrue(e)
del e
- self.assertFalse('e' in locals())
+ self.assertNotIn('e', locals())
def testExceptionCleanupState(self):
# Make sure exception state is cleaned up as soon as the except
@@ -524,6 +525,17 @@ class ExceptionTests(unittest.TestCase):
obj = wr()
self.assertTrue(obj is None, "%s" % obj)
+ def test_exception_target_in_nested_scope(self):
+ # issue 4617: This used to raise a SyntaxError
+ # "can not delete variable 'e' referenced in nested scope"
+ def print_error():
+ e
+ try:
+ something
+ except Exception as e:
+ print_error()
+ # implicit "del e" here
+
def test_generator_leaking(self):
# Test that generator exception state doesn't leak into the calling
# frame
@@ -647,7 +659,7 @@ class ExceptionTests(unittest.TestCase):
return sys.exc_info()
e, v, tb = g()
self.assertTrue(isinstance(v, RuntimeError), type(v))
- self.assertTrue("maximum recursion depth exceeded" in str(v), str(v))
+ self.assertIn("maximum recursion depth exceeded", str(v))
def test_MemoryError(self):
@@ -668,6 +680,46 @@ class ExceptionTests(unittest.TestCase):
tb2 = raiseMemError()
self.assertEqual(tb1, tb2)
+ @cpython_only
+ def test_exception_with_doc(self):
+ import _testcapi
+ doc2 = "This is a test docstring."
+ doc4 = "This is another test docstring."
+
+ self.assertRaises(SystemError, _testcapi.make_exception_with_doc,
+ "error1")
+
+ # test basic usage of PyErr_NewException
+ error1 = _testcapi.make_exception_with_doc("_testcapi.error1")
+ self.assertIs(type(error1), type)
+ self.assertTrue(issubclass(error1, Exception))
+ self.assertIsNone(error1.__doc__)
+
+ # test with given docstring
+ error2 = _testcapi.make_exception_with_doc("_testcapi.error2", doc2)
+ self.assertEqual(error2.__doc__, doc2)
+
+ # test with explicit base (without docstring)
+ error3 = _testcapi.make_exception_with_doc("_testcapi.error3",
+ base=error2)
+ self.assertTrue(issubclass(error3, error2))
+
+ # test with explicit base tuple
+ class C(object):
+ pass
+ error4 = _testcapi.make_exception_with_doc("_testcapi.error4", doc4,
+ (error3, C))
+ self.assertTrue(issubclass(error4, error3))
+ self.assertTrue(issubclass(error4, C))
+ self.assertEqual(error4.__doc__, doc4)
+
+ # test with explicit dictionary
+ error5 = _testcapi.make_exception_with_doc("_testcapi.error5", "",
+ error4, {'a': 1})
+ self.assertTrue(issubclass(error5, error4))
+ self.assertEqual(error5.a, 1)
+ self.assertEqual(error5.__doc__, "")
+
def test_memory_error_cleanup(self):
# Issue #5437: preallocated MemoryError instances should not keep
# traceback objects alive.
diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py
index ce9ac5ea02..1f7f63042e 100644
--- a/Lib/test/test_extcall.py
+++ b/Lib/test/test_extcall.py
@@ -1,3 +1,4 @@
+
"""Doctest for method/function calls.
We're going the use these types for extra testing
@@ -65,17 +66,17 @@ Verify clearing of SF bug #733667
>>> g()
Traceback (most recent call last):
...
- TypeError: g() takes at least 1 positional argument (0 given)
+ TypeError: g() takes at least 1 argument (0 given)
>>> g(*())
Traceback (most recent call last):
...
- TypeError: g() takes at least 1 positional argument (0 given)
+ TypeError: g() takes at least 1 argument (0 given)
>>> g(*(), **{})
Traceback (most recent call last):
...
- TypeError: g() takes at least 1 positional argument (0 given)
+ TypeError: g() takes at least 1 argument (0 given)
>>> g(1)
1 () {}
@@ -261,13 +262,37 @@ the function call setup. See <http://bugs.python.org/issue2016>.
... print(a,b)
>>> f(**x)
1 2
+
+A obscure message:
+
+ >>> def f(a, b):
+ ... pass
+ >>> f(b=1)
+ Traceback (most recent call last):
+ ...
+ TypeError: f() takes exactly 2 arguments (1 given)
+
+The number of arguments passed in includes keywords:
+
+ >>> def f(a):
+ ... pass
+ >>> f(6, a=4, *(1, 2, 3))
+ Traceback (most recent call last):
+ ...
+ TypeError: f() takes exactly 1 positional argument (5 given)
+ >>> def f(a, *, kw):
+ ... pass
+ >>> f(6, 4, kw=4)
+ Traceback (most recent call last):
+ ...
+ TypeError: f() takes exactly 1 positional argument (3 given)
"""
+import sys
from test import support
def test_main():
- from test import test_extcall # self import
- support.run_doctest(test_extcall, True)
+ support.run_doctest(sys.modules[__name__], True)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
index 3c18f1d66d..e8eeaaa7bf 100755..100644
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -16,15 +16,12 @@ fcntl = import_module('fcntl')
# TODO - Write tests for flock() and lockf().
def get_lockdata():
- if sys.platform.startswith('atheos'):
- start_len = "qq"
+ try:
+ os.O_LARGEFILE
+ except AttributeError:
+ start_len = "ll"
else:
- try:
- os.O_LARGEFILE
- except AttributeError:
- start_len = "ll"
- else:
- start_len = "qq"
+ start_len = "qq"
if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3',
'Darwin1.2', 'darwin',
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index 30c6ed1108..bb0da792f5 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -7,7 +7,7 @@ from weakref import proxy
import io
import _pyio as pyio
-from test.support import TESTFN, findfile, run_unittest
+from test.support import TESTFN, run_unittest
from collections import UserList
class AutoFileTests(unittest.TestCase):
@@ -44,7 +44,7 @@ class AutoFileTests(unittest.TestCase):
a = array('b', b'x'*10)
self.f = self.open(TESTFN, 'rb')
n = self.f.readinto(a)
- self.assertEqual(b'12', a.tostring()[:n])
+ self.assertEqual(b'12', a.tobytes()[:n])
def testReadinto_text(self):
# verify readinto refuses text files
@@ -106,8 +106,7 @@ class AutoFileTests(unittest.TestCase):
('writelines', ([],)),
('__iter__', ()),
]
- if not sys.platform.startswith('atheos'):
- methods.append(('truncate', ()))
+ methods.append(('truncate', ()))
# __exit__ should close the file
self.f.__exit__(None, None, None)
@@ -167,7 +166,7 @@ class OtherFileTests(unittest.TestCase):
except ValueError as msg:
if msg.args[0] != 0:
s = str(msg)
- if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
+ if TESTFN in s or bad_mode not in s:
self.fail("bad error message for invalid mode: %s" % s)
# if msg.args[0] == 0, we're probably on Windows where there may be
# no obvious way to discover why open() failed.
@@ -282,7 +281,7 @@ class OtherFileTests(unittest.TestCase):
except ValueError:
self.fail("readinto() after next() with supposedly empty "
"iteration-buffer failed anyway")
- line = buf.tostring()
+ line = buf.tobytes()
if line != testline:
self.fail("readinto() after next() with empty buffer "
"failed. Got %r, expected %r" % (line, testline))
@@ -304,6 +303,8 @@ class OtherFileTests(unittest.TestCase):
if lines != testlines:
self.fail("readlines() after next() with empty buffer "
"failed. Got %r, expected %r" % (line, testline))
+ f.close()
+
# Reading after iteration hit EOF shouldn't hurt either
f = self.open(TESTFN, 'rb')
try:
diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py
index c71a27a5b9..9b5725d023 100644
--- a/Lib/test/test_filecmp.py
+++ b/Lib/test/test_filecmp.py
@@ -1,5 +1,5 @@
-import os, filecmp, shutil, tempfile, shutil
+import os, filecmp, shutil, tempfile
import unittest
from test import support
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index aae16eadfe..f312882b2a 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -231,6 +231,30 @@ class FileInputTests(unittest.TestCase):
## finally:
## remove_tempfiles(t1)
+ def test_context_manager(self):
+ try:
+ t1 = writeTmp(1, ["A\nB\nC"])
+ t2 = writeTmp(2, ["D\nE\nF"])
+ with FileInput(files=(t1, t2)) as fi:
+ lines = list(fi)
+ self.assertEqual(lines, ["A\n", "B\n", "C", "D\n", "E\n", "F"])
+ self.assertEqual(fi.filelineno(), 3)
+ self.assertEqual(fi.lineno(), 6)
+ self.assertEqual(fi._files, ())
+ finally:
+ remove_tempfiles(t1, t2)
+
+ def test_close_on_exception(self):
+ try:
+ t1 = writeTmp(1, [""])
+ with FileInput(files=t1) as fi:
+ raise IOError
+ except IOError:
+ self.assertEqual(fi._files, ())
+ finally:
+ remove_tempfiles(t1)
+
+
def test_main():
run_unittest(BufferSizesTests, FileInputTests)
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index 2a8e05de89..103365d8f2 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -8,9 +8,7 @@ from array import array
from weakref import proxy
from functools import wraps
-from test.support import (TESTFN, findfile, check_warnings, run_unittest,
- make_bad_fd)
-from collections import UserList
+from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd
from _io import FileIO as _FileIO
@@ -108,8 +106,6 @@ class AutoFileTests(unittest.TestCase):
methods = ['fileno', 'isatty', 'read', 'readinto',
'seek', 'tell', 'truncate', 'write', 'seekable',
'readable', 'writable']
- if sys.platform.startswith('atheos'):
- methods.remove('truncate')
self.f.close()
self.assertTrue(self.f.closed)
@@ -324,7 +320,7 @@ class OtherFileTests(unittest.TestCase):
except ValueError as msg:
if msg.args[0] != 0:
s = str(msg)
- if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
+ if TESTFN in s or bad_mode not in s:
self.fail("bad error message for invalid mode: %s" % s)
# if msg.args[0] == 0, we're probably on Windows where there may be
# no obvious way to discover why open() failed.
@@ -395,7 +391,7 @@ class OtherFileTests(unittest.TestCase):
self.assertRaises(TypeError, _FileIO, "1", 0, 0)
def testWarnings(self):
- with check_warnings() as w:
+ with check_warnings(quiet=True) as w:
self.assertEqual(w.warnings, [])
self.assertRaises(TypeError, _FileIO, [])
self.assertEqual(w.warnings, [])
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index 2b250df75f..1968b8ae78 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -7,7 +7,6 @@ import math
from math import isinf, isnan, copysign, ldexp
import operator
import random, fractions
-import re
INF = float("inf")
NAN = float("nan")
@@ -17,83 +16,11 @@ requires_getformat = unittest.skipUnless(have_getformat,
"requires __getformat__")
requires_setformat = unittest.skipUnless(hasattr(float, "__setformat__"),
"requires __setformat__")
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(have_getformat and
- float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
#locate file with float format test values
test_dir = os.path.dirname(__file__) or os.curdir
format_testfile = os.path.join(test_dir, 'formatfloat_testcases.txt')
-finite_decimal_parser = re.compile(r""" # A numeric string consists of:
- (?P<sign>[-+])? # an optional sign, followed by
- (?=\d|\.\d) # a number with at least one digit
- (?P<int>\d*) # having a (possibly empty) integer part
- (?:\.(?P<frac>\d*))? # followed by an optional fractional part
- (?:E(?P<exp>[-+]?\d+))? # and an optional exponent
- \Z
-""", re.VERBOSE | re.IGNORECASE | re.UNICODE).match
-
-# Pure Python version of correctly rounded string->float conversion.
-# Avoids any use of floating-point by returning the result as a hex string.
-def strtod(s, mant_dig=53, min_exp = -1021, max_exp = 1024):
- """Convert a finite decimal string to a hex string representing an
- IEEE 754 binary64 float. Return 'inf' or '-inf' on overflow.
- This function makes no use of floating-point arithmetic at any
- stage."""
-
- # parse string into a pair of integers 'a' and 'b' such that
- # abs(decimal value) = a/b, and a boolean 'negative'.
- m = finite_decimal_parser(s)
- if m is None:
- raise ValueError('invalid numeric string')
- fraction = m.group('frac') or ''
- intpart = int(m.group('int') + fraction)
- exp = int(m.group('exp') or '0') - len(fraction)
- negative = m.group('sign') == '-'
- a, b = intpart*10**max(exp, 0), 10**max(0, -exp)
-
- # quick return for zeros
- if not a:
- return '-0x0.0p+0' if negative else '0x0.0p+0'
-
- # compute exponent e for result; may be one too small in the case
- # that the rounded value of a/b lies in a different binade from a/b
- d = a.bit_length() - b.bit_length()
- d += (a >> d if d >= 0 else a << -d) >= b
- e = max(d, min_exp) - mant_dig
-
- # approximate a/b by number of the form q * 2**e; adjust e if necessary
- a, b = a << max(-e, 0), b << max(e, 0)
- q, r = divmod(a, b)
- if 2*r > b or 2*r == b and q & 1:
- q += 1
- if q.bit_length() == mant_dig+1:
- q //= 2
- e += 1
-
- # double check that (q, e) has the right form
- assert q.bit_length() <= mant_dig and e >= min_exp - mant_dig
- assert q.bit_length() == mant_dig or e == min_exp - mant_dig
-
- # check for overflow and underflow
- if e + q.bit_length() > max_exp:
- return '-inf' if negative else 'inf'
- if not q:
- return '-0x0.0p+0' if negative else '0x0.0p+0'
-
- # for hex representation, shift so # bits after point is a multiple of 4
- hexdigs = 1 + (mant_dig-2)//4
- shift = 3 - (mant_dig-2)%4
- q, e = q << shift, e - shift
- return '{}0x{:x}.{:0{}x}p{:+d}'.format(
- '-' if negative else '',
- q // 16**hexdigs,
- q % 16**hexdigs,
- hexdigs,
- e + 4*hexdigs)
-
class GeneralFloatCases(unittest.TestCase):
def test_float(self):
@@ -112,11 +39,30 @@ class GeneralFloatCases(unittest.TestCase):
self.assertRaises(ValueError, float, "+.inf")
self.assertRaises(ValueError, float, ".")
self.assertRaises(ValueError, float, "-.")
- self.assertEqual(float(b" \u0663.\u0661\u0664 ".decode('raw-unicode-escape')), 3.14)
+ self.assertRaises(ValueError, float, b"-")
+ self.assertRaises(TypeError, float, {})
+ # Lone surrogate
+ self.assertRaises(UnicodeEncodeError, float, '\uD8F0')
+ # check that we don't accept alternate exponent markers
+ self.assertRaises(ValueError, float, "-1.7d29")
+ self.assertRaises(ValueError, float, "3D-14")
+ self.assertEqual(float(" \u0663.\u0661\u0664 "), 3.14)
+ self.assertEqual(float("\N{EM SPACE}3.14\N{EN SPACE}"), 3.14)
# extra long strings should not be a problem
float(b'.' + b'1'*1000)
float('.' + '1'*1000)
+ def test_error_message(self):
+ testlist = ('\xbd', '123\xbd', ' 123 456 ')
+ for s in testlist:
+ try:
+ float(s)
+ except ValueError as e:
+ self.assertIn(s.strip(), e.args[0])
+ else:
+ self.fail("Expected int(%r) to raise a ValueError", s)
+
+
@support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
def test_float_with_comma(self):
# set locale to something that doesn't use '.' for the decimal point
@@ -218,12 +164,12 @@ class GeneralFloatCases(unittest.TestCase):
def test_float_containment(self):
floats = (INF, -INF, 0.0, 1.0, NAN)
for f in floats:
- self.assertTrue(f in [f], "'%r' not in []" % f)
- self.assertTrue(f in (f,), "'%r' not in ()" % f)
- self.assertTrue(f in {f}, "'%r' not in set()" % f)
- self.assertTrue(f in {f: None}, "'%r' not in {}" % f)
+ self.assertIn(f, [f])
+ self.assertIn(f, (f,))
+ self.assertIn(f, {f})
+ self.assertIn(f, {f: None})
self.assertEqual([f].count(f), 1, "[].count('%r') != 1" % f)
- self.assertTrue(f in floats, "'%r' not in container" % f)
+ self.assertIn(f, floats)
for f in floats:
# nonidentical containers, same type, same contents
@@ -246,7 +192,7 @@ class GeneralFloatCases(unittest.TestCase):
# distinguishes -0.0 and 0.0.
self.assertEqual((a, copysign(1.0, a)), (b, copysign(1.0, b)))
- @requires_IEEE_754
+ @support.requires_IEEE_754
def test_float_mod(self):
# Check behaviour of % operator for IEEE 754 special cases.
# In particular, check signs of zeros.
@@ -266,7 +212,209 @@ class GeneralFloatCases(unittest.TestCase):
self.assertEqualAndEqualSign(mod(1e-100, -1.0), -1.0)
self.assertEqualAndEqualSign(mod(1.0, -1.0), -0.0)
-
+ @support.requires_IEEE_754
+ def test_float_pow(self):
+ # test builtin pow and ** operator for IEEE 754 special cases.
+ # Special cases taken from section F.9.4.4 of the C99 specification
+
+ for pow_op in pow, operator.pow:
+ # x**NAN is NAN for any x except 1
+ self.assertTrue(isnan(pow_op(-INF, NAN)))
+ self.assertTrue(isnan(pow_op(-2.0, NAN)))
+ self.assertTrue(isnan(pow_op(-1.0, NAN)))
+ self.assertTrue(isnan(pow_op(-0.5, NAN)))
+ self.assertTrue(isnan(pow_op(-0.0, NAN)))
+ self.assertTrue(isnan(pow_op(0.0, NAN)))
+ self.assertTrue(isnan(pow_op(0.5, NAN)))
+ self.assertTrue(isnan(pow_op(2.0, NAN)))
+ self.assertTrue(isnan(pow_op(INF, NAN)))
+ self.assertTrue(isnan(pow_op(NAN, NAN)))
+
+ # NAN**y is NAN for any y except +-0
+ self.assertTrue(isnan(pow_op(NAN, -INF)))
+ self.assertTrue(isnan(pow_op(NAN, -2.0)))
+ self.assertTrue(isnan(pow_op(NAN, -1.0)))
+ self.assertTrue(isnan(pow_op(NAN, -0.5)))
+ self.assertTrue(isnan(pow_op(NAN, 0.5)))
+ self.assertTrue(isnan(pow_op(NAN, 1.0)))
+ self.assertTrue(isnan(pow_op(NAN, 2.0)))
+ self.assertTrue(isnan(pow_op(NAN, INF)))
+
+ # (+-0)**y raises ZeroDivisionError for y a negative odd integer
+ self.assertRaises(ZeroDivisionError, pow_op, -0.0, -1.0)
+ self.assertRaises(ZeroDivisionError, pow_op, 0.0, -1.0)
+
+ # (+-0)**y raises ZeroDivisionError for y finite and negative
+ # but not an odd integer
+ self.assertRaises(ZeroDivisionError, pow_op, -0.0, -2.0)
+ self.assertRaises(ZeroDivisionError, pow_op, -0.0, -0.5)
+ self.assertRaises(ZeroDivisionError, pow_op, 0.0, -2.0)
+ self.assertRaises(ZeroDivisionError, pow_op, 0.0, -0.5)
+
+ # (+-0)**y is +-0 for y a positive odd integer
+ self.assertEqualAndEqualSign(pow_op(-0.0, 1.0), -0.0)
+ self.assertEqualAndEqualSign(pow_op(0.0, 1.0), 0.0)
+
+ # (+-0)**y is 0 for y finite and positive but not an odd integer
+ self.assertEqualAndEqualSign(pow_op(-0.0, 0.5), 0.0)
+ self.assertEqualAndEqualSign(pow_op(-0.0, 2.0), 0.0)
+ self.assertEqualAndEqualSign(pow_op(0.0, 0.5), 0.0)
+ self.assertEqualAndEqualSign(pow_op(0.0, 2.0), 0.0)
+
+ # (-1)**+-inf is 1
+ self.assertEqualAndEqualSign(pow_op(-1.0, -INF), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, INF), 1.0)
+
+ # 1**y is 1 for any y, even if y is an infinity or nan
+ self.assertEqualAndEqualSign(pow_op(1.0, -INF), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, -2.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, -1.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, -0.5), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, 0.5), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, 1.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, 2.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, INF), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, NAN), 1.0)
+
+ # x**+-0 is 1 for any x, even if x is a zero, infinity, or nan
+ self.assertEqualAndEqualSign(pow_op(-INF, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-2.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-0.5, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-0.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(0.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(0.5, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(INF, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(NAN, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-INF, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-2.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-0.5, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-0.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(0.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(0.5, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(INF, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(NAN, -0.0), 1.0)
+
+ # x**y defers to complex pow for finite negative x and
+ # non-integral y.
+ self.assertEqual(type(pow_op(-2.0, -0.5)), complex)
+ self.assertEqual(type(pow_op(-2.0, 0.5)), complex)
+ self.assertEqual(type(pow_op(-1.0, -0.5)), complex)
+ self.assertEqual(type(pow_op(-1.0, 0.5)), complex)
+ self.assertEqual(type(pow_op(-0.5, -0.5)), complex)
+ self.assertEqual(type(pow_op(-0.5, 0.5)), complex)
+
+ # x**-INF is INF for abs(x) < 1
+ self.assertEqualAndEqualSign(pow_op(-0.5, -INF), INF)
+ self.assertEqualAndEqualSign(pow_op(-0.0, -INF), INF)
+ self.assertEqualAndEqualSign(pow_op(0.0, -INF), INF)
+ self.assertEqualAndEqualSign(pow_op(0.5, -INF), INF)
+
+ # x**-INF is 0 for abs(x) > 1
+ self.assertEqualAndEqualSign(pow_op(-INF, -INF), 0.0)
+ self.assertEqualAndEqualSign(pow_op(-2.0, -INF), 0.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, -INF), 0.0)
+ self.assertEqualAndEqualSign(pow_op(INF, -INF), 0.0)
+
+ # x**INF is 0 for abs(x) < 1
+ self.assertEqualAndEqualSign(pow_op(-0.5, INF), 0.0)
+ self.assertEqualAndEqualSign(pow_op(-0.0, INF), 0.0)
+ self.assertEqualAndEqualSign(pow_op(0.0, INF), 0.0)
+ self.assertEqualAndEqualSign(pow_op(0.5, INF), 0.0)
+
+ # x**INF is INF for abs(x) > 1
+ self.assertEqualAndEqualSign(pow_op(-INF, INF), INF)
+ self.assertEqualAndEqualSign(pow_op(-2.0, INF), INF)
+ self.assertEqualAndEqualSign(pow_op(2.0, INF), INF)
+ self.assertEqualAndEqualSign(pow_op(INF, INF), INF)
+
+ # (-INF)**y is -0.0 for y a negative odd integer
+ self.assertEqualAndEqualSign(pow_op(-INF, -1.0), -0.0)
+
+ # (-INF)**y is 0.0 for y negative but not an odd integer
+ self.assertEqualAndEqualSign(pow_op(-INF, -0.5), 0.0)
+ self.assertEqualAndEqualSign(pow_op(-INF, -2.0), 0.0)
+
+ # (-INF)**y is -INF for y a positive odd integer
+ self.assertEqualAndEqualSign(pow_op(-INF, 1.0), -INF)
+
+ # (-INF)**y is INF for y positive but not an odd integer
+ self.assertEqualAndEqualSign(pow_op(-INF, 0.5), INF)
+ self.assertEqualAndEqualSign(pow_op(-INF, 2.0), INF)
+
+ # INF**y is INF for y positive
+ self.assertEqualAndEqualSign(pow_op(INF, 0.5), INF)
+ self.assertEqualAndEqualSign(pow_op(INF, 1.0), INF)
+ self.assertEqualAndEqualSign(pow_op(INF, 2.0), INF)
+
+ # INF**y is 0.0 for y negative
+ self.assertEqualAndEqualSign(pow_op(INF, -2.0), 0.0)
+ self.assertEqualAndEqualSign(pow_op(INF, -1.0), 0.0)
+ self.assertEqualAndEqualSign(pow_op(INF, -0.5), 0.0)
+
+ # basic checks not covered by the special cases above
+ self.assertEqualAndEqualSign(pow_op(-2.0, -2.0), 0.25)
+ self.assertEqualAndEqualSign(pow_op(-2.0, -1.0), -0.5)
+ self.assertEqualAndEqualSign(pow_op(-2.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-2.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-2.0, 1.0), -2.0)
+ self.assertEqualAndEqualSign(pow_op(-2.0, 2.0), 4.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, -2.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, -1.0), -1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, 1.0), -1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, 2.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, -2.0), 0.25)
+ self.assertEqualAndEqualSign(pow_op(2.0, -1.0), 0.5)
+ self.assertEqualAndEqualSign(pow_op(2.0, -0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, 0.0), 1.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, 1.0), 2.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, 2.0), 4.0)
+
+ # 1 ** large and -1 ** large; some libms apparently
+ # have problems with these
+ self.assertEqualAndEqualSign(pow_op(1.0, -1e100), 1.0)
+ self.assertEqualAndEqualSign(pow_op(1.0, 1e100), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, -1e100), 1.0)
+ self.assertEqualAndEqualSign(pow_op(-1.0, 1e100), 1.0)
+
+ # check sign for results that underflow to 0
+ self.assertEqualAndEqualSign(pow_op(-2.0, -2000.0), 0.0)
+ self.assertEqual(type(pow_op(-2.0, -2000.5)), complex)
+ self.assertEqualAndEqualSign(pow_op(-2.0, -2001.0), -0.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, -2000.0), 0.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, -2000.5), 0.0)
+ self.assertEqualAndEqualSign(pow_op(2.0, -2001.0), 0.0)
+ self.assertEqualAndEqualSign(pow_op(-0.5, 2000.0), 0.0)
+ self.assertEqual(type(pow_op(-0.5, 2000.5)), complex)
+ self.assertEqualAndEqualSign(pow_op(-0.5, 2001.0), -0.0)
+ self.assertEqualAndEqualSign(pow_op(0.5, 2000.0), 0.0)
+ self.assertEqualAndEqualSign(pow_op(0.5, 2000.5), 0.0)
+ self.assertEqualAndEqualSign(pow_op(0.5, 2001.0), 0.0)
+
+ # check we don't raise an exception for subnormal results,
+ # and validate signs. Tests currently disabled, since
+ # they fail on systems where a subnormal result from pow
+ # is flushed to zero (e.g. Debian/ia64.)
+ #self.assertTrue(0.0 < pow_op(0.5, 1048) < 1e-315)
+ #self.assertTrue(0.0 < pow_op(-0.5, 1048) < 1e-315)
+ #self.assertTrue(0.0 < pow_op(0.5, 1047) < 1e-315)
+ #self.assertTrue(0.0 > pow_op(-0.5, 1047) > -1e-315)
+ #self.assertTrue(0.0 < pow_op(2.0, -1048) < 1e-315)
+ #self.assertTrue(0.0 < pow_op(-2.0, -1048) < 1e-315)
+ #self.assertTrue(0.0 < pow_op(2.0, -1047) < 1e-315)
+ #self.assertTrue(0.0 > pow_op(-2.0, -1047) > -1e-315)
+
+
+@requires_setformat
class FormatFunctionsTestCase(unittest.TestCase):
def setUp(self):
@@ -278,10 +426,10 @@ class FormatFunctionsTestCase(unittest.TestCase):
float.__setformat__('float', self.save_formats['float'])
def test_getformat(self):
- self.assertTrue(float.__getformat__('double') in
- ['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
- self.assertTrue(float.__getformat__('float') in
- ['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
+ self.assertIn(float.__getformat__('double'),
+ ['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
+ self.assertIn(float.__getformat__('float'),
+ ['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
self.assertRaises(ValueError, float.__getformat__, 'chicken')
self.assertRaises(TypeError, float.__getformat__, 1)
@@ -317,6 +465,7 @@ LE_FLOAT_NAN = bytes(reversed(BE_FLOAT_NAN))
# on non-IEEE platforms, attempting to unpack a bit pattern
# representing an infinity or a NaN should raise an exception.
+@requires_setformat
class UnknownFormatTestCase(unittest.TestCase):
def setUp(self):
self.save_formats = {'double':float.__getformat__('double'),
@@ -349,37 +498,25 @@ class UnknownFormatTestCase(unittest.TestCase):
# let's also try to guarantee that -0.0 and 0.0 don't get confused.
class IEEEFormatTestCase(unittest.TestCase):
- if float.__getformat__("double").startswith("IEEE"):
- def test_double_specials_do_unpack(self):
- for fmt, data in [('>d', BE_DOUBLE_INF),
- ('>d', BE_DOUBLE_NAN),
- ('<d', LE_DOUBLE_INF),
- ('<d', LE_DOUBLE_NAN)]:
- struct.unpack(fmt, data)
-
- if float.__getformat__("float").startswith("IEEE"):
- def test_float_specials_do_unpack(self):
- for fmt, data in [('>f', BE_FLOAT_INF),
- ('>f', BE_FLOAT_NAN),
- ('<f', LE_FLOAT_INF),
- ('<f', LE_FLOAT_NAN)]:
- struct.unpack(fmt, data)
-
- if float.__getformat__("double").startswith("IEEE"):
- def test_negative_zero(self):
- import math
- def pos_pos():
- return 0.0, math.atan2(0.0, -1)
- def pos_neg():
- return 0.0, math.atan2(-0.0, -1)
- def neg_pos():
- return -0.0, math.atan2(0.0, -1)
- def neg_neg():
- return -0.0, math.atan2(-0.0, -1)
- self.assertEqual(pos_pos(), neg_pos())
- self.assertEqual(pos_neg(), neg_neg())
+
+ @support.requires_IEEE_754
+ def test_double_specials_do_unpack(self):
+ for fmt, data in [('>d', BE_DOUBLE_INF),
+ ('>d', BE_DOUBLE_NAN),
+ ('<d', LE_DOUBLE_INF),
+ ('<d', LE_DOUBLE_NAN)]:
+ struct.unpack(fmt, data)
+
+ @support.requires_IEEE_754
+ def test_float_specials_do_unpack(self):
+ for fmt, data in [('>f', BE_FLOAT_INF),
+ ('>f', BE_FLOAT_NAN),
+ ('<f', LE_FLOAT_INF),
+ ('<f', LE_FLOAT_NAN)]:
+ struct.unpack(fmt, data)
class FormatTestCase(unittest.TestCase):
+
def test_format(self):
# these should be rewritten to use both format(x, spec) and
# x.__format__(spec)
@@ -433,8 +570,7 @@ class FormatTestCase(unittest.TestCase):
self.assertEqual(format(INF, 'f'), 'inf')
self.assertEqual(format(INF, 'F'), 'INF')
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @support.requires_IEEE_754
def test_format_testfile(self):
with open(format_testfile) as testfile:
for line in testfile:
@@ -514,10 +650,13 @@ class ReprTestCase(unittest.TestCase):
negs = '-'+s
self.assertEqual(s, repr(float(s)))
self.assertEqual(negs, repr(float(negs)))
+ # Since Python 3.2, repr and str are identical
+ self.assertEqual(repr(float(s)), str(float(s)))
+ self.assertEqual(repr(float(negs)), str(float(negs)))
+@support.requires_IEEE_754
class RoundTestCase(unittest.TestCase):
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+
def test_inf_nan(self):
self.assertRaises(OverflowError, round, INF)
self.assertRaises(OverflowError, round, -INF)
@@ -527,8 +666,6 @@ class RoundTestCase(unittest.TestCase):
self.assertRaises(TypeError, round, NAN, "ceci n'est pas un integer")
self.assertRaises(TypeError, round, -0.0, 1j)
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
def test_large_n(self):
for n in [324, 325, 400, 2**31-1, 2**31, 2**32, 2**100]:
self.assertEqual(round(123.456, n), 123.456)
@@ -541,8 +678,6 @@ class RoundTestCase(unittest.TestCase):
self.assertEqual(round(1e150, 309), 1e150)
self.assertEqual(round(1.4e-315, 315), 1e-315)
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
def test_small_n(self):
for n in [-308, -309, -400, 1-2**31, -2**31, -2**31-1, -2**100]:
self.assertEqual(round(123.456, n), 0.0)
@@ -550,8 +685,6 @@ class RoundTestCase(unittest.TestCase):
self.assertEqual(round(1e300, n), 0.0)
self.assertEqual(round(1e-320, n), 0.0)
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
def test_overflow(self):
self.assertRaises(OverflowError, round, 1.6e308, -308)
self.assertRaises(OverflowError, round, -1.7e308, -308)
@@ -599,6 +732,35 @@ class RoundTestCase(unittest.TestCase):
self.assertEqual(float(format(x, '.2f')), round(x, 2))
self.assertEqual(float(format(x, '.3f')), round(x, 3))
+ def test_format_specials(self):
+ # Test formatting of nans and infs.
+
+ def test(fmt, value, expected):
+ # Test with both % and format().
+ self.assertEqual(fmt % value, expected, fmt)
+ fmt = fmt[1:] # strip off the %
+ self.assertEqual(format(value, fmt), expected, fmt)
+
+ for fmt in ['%e', '%f', '%g', '%.0e', '%.6f', '%.20g',
+ '%#e', '%#f', '%#g', '%#.20e', '%#.15f', '%#.3g']:
+ pfmt = '%+' + fmt[1:]
+ sfmt = '% ' + fmt[1:]
+ test(fmt, INF, 'inf')
+ test(fmt, -INF, '-inf')
+ test(fmt, NAN, 'nan')
+ test(fmt, -NAN, 'nan')
+ # When asking for a sign, it's always provided. nans are
+ # always positive.
+ test(pfmt, INF, '+inf')
+ test(pfmt, -INF, '-inf')
+ test(pfmt, NAN, '+nan')
+ test(pfmt, -NAN, '+nan')
+ # When using ' ' for a sign code, only infs can be negative.
+ # Others have a space.
+ test(sfmt, INF, ' inf')
+ test(sfmt, -INF, '-inf')
+ test(sfmt, NAN, ' nan')
+ test(sfmt, -NAN, ' nan')
# Beginning with Python 2.6 float has cross platform compatible
@@ -1122,38 +1284,6 @@ class HexFloatTestCase(unittest.TestCase):
else:
self.identical(x, fromHex(toHex(x)))
-class StrtodTestCase(unittest.TestCase):
- def check_string(self, s):
- expected = strtod(s)
- try:
- fs = float(s)
- except OverflowError:
- got = '-inf' if s[0] == '-' else 'inf'
- else:
- got = fs.hex()
- self.assertEqual(expected, got,
- "Incorrectly rounded str->float conversion for "
- "{}: expected {}, got {}".format(s, expected, got))
-
- @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
- "applies only when using short float repr style")
- def test_bug7632(self):
- # check a few particular values that gave incorrectly rounded
- # results with previous versions of dtoa.c
- test_strings = [
- '94393431193180696942841837085033647913224148539854e-358',
- '12579816049008305546974391768996369464963024663104e-357',
- '17489628565202117263145367596028389348922981857013e-357',
- '18487398785991994634182916638542680759613590482273e-357',
- '32002864200581033134358724675198044527469366773928e-358',
- '73608278998966969345824653500136787876436005957953e-358',
- '64774478836417299491718435234611299336288082136054e-358',
- '13704940134126574534878641876947980878824688451169e-357',
- '46697445774047060960624497964425416610480524760471e-358',
- ]
- for s in test_strings:
- self.check_string(s)
-
def test_main():
support.run_unittest(
@@ -1166,7 +1296,6 @@ def test_main():
RoundTestCase,
InfNanTest,
HexFloatTestCase,
- StrtodTestCase,
)
if __name__ == '__main__':
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py
index bde4ee8097..482835d42e 100644
--- a/Lib/test/test_fnmatch.py
+++ b/Lib/test/test_fnmatch.py
@@ -3,14 +3,10 @@
from test import support
import unittest
-from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache, _cacheb, _purge
-
+from fnmatch import fnmatch, fnmatchcase, translate, filter
class FnmatchTestCase(unittest.TestCase):
- def tearDown(self):
- _purge()
-
def check_match(self, filename, pattern, should_match=1, fn=fnmatch):
if should_match:
self.assertTrue(fn(filename, pattern),
@@ -64,24 +60,29 @@ class FnmatchTestCase(unittest.TestCase):
self.check_match(b'test\xff', b'te*\xff')
self.check_match(b'foo\nbar', b'foo*')
- def test_cache_clearing(self):
- # check that caches do not grow too large
- # http://bugs.python.org/issue7846
+class TranslateTestCase(unittest.TestCase):
+
+ def test_translate(self):
+ self.assertEqual(translate('*'), '.*\Z(?ms)')
+ self.assertEqual(translate('?'), '.\Z(?ms)')
+ self.assertEqual(translate('a?b*'), 'a.b.*\Z(?ms)')
+ self.assertEqual(translate('[abc]'), '[abc]\Z(?ms)')
+ self.assertEqual(translate('[]]'), '[]]\Z(?ms)')
+ self.assertEqual(translate('[!x]'), '[^x]\Z(?ms)')
+ self.assertEqual(translate('[^x]'), '[\\^x]\Z(?ms)')
+ self.assertEqual(translate('[x'), '\\[x\Z(?ms)')
- # string pattern cache
- for i in range(_MAXCACHE + 1):
- fnmatch('foo', '?' * i)
- self.assertLessEqual(len(_cache), _MAXCACHE)
+class FilterTestCase(unittest.TestCase):
- # bytes pattern cache
- for i in range(_MAXCACHE + 1):
- fnmatch(b'foo', b'?' * i)
- self.assertLessEqual(len(_cacheb), _MAXCACHE)
+ def test_filter(self):
+ self.assertEqual(filter(['a', 'b'], 'a'), ['a'])
def test_main():
- support.run_unittest(FnmatchTestCase)
+ support.run_unittest(FnmatchTestCase,
+ TranslateTestCase,
+ FilterTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py
index 88f9fe9735..8192c38a44 100644
--- a/Lib/test/test_fork1.py
+++ b/Lib/test/test_fork1.py
@@ -1,21 +1,21 @@
"""This test checks for correct fork() behavior.
"""
-import errno
import imp
import os
import signal
import sys
import time
-import threading
from test.fork_wait import ForkWait
-from test.support import run_unittest, reap_children, get_attribute
+from test.support import (run_unittest, reap_children, get_attribute,
+ import_module, verbose)
+
+threading = import_module('threading')
# Skip test if fork does not exist.
get_attribute(os, 'fork')
-
class ForkTest(ForkWait):
def wait_impl(self, cpid):
for i in range(10):
@@ -29,7 +29,8 @@ class ForkTest(ForkWait):
self.assertEqual(spid, cpid)
self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
- def test_import_lock_fork(self):
+ def test_threaded_import_lock_fork(self):
+ """Check fork() in main thread works while a subthread is doing an import"""
import_started = threading.Event()
fake_module_name = "fake test module"
partial_module = "partial"
@@ -46,11 +47,16 @@ class ForkTest(ForkWait):
import_started.wait()
pid = os.fork()
try:
+ # PyOS_BeforeFork should have waited for the import to complete
+ # before forking, so the child can recreate the import lock
+ # correctly, but also won't see a partially initialised module
if not pid:
m = __import__(fake_module_name)
if m == complete_module:
os._exit(0)
else:
+ if verbose > 1:
+ print("Child encountered partial module")
os._exit(1)
else:
t.join()
@@ -64,6 +70,39 @@ class ForkTest(ForkWait):
except OSError:
pass
+
+ def test_nested_import_lock_fork(self):
+ """Check fork() in main thread works while the main thread is doing an import"""
+ # Issue 9573: this used to trigger RuntimeError in the child process
+ def fork_with_import_lock(level):
+ release = 0
+ in_child = False
+ try:
+ try:
+ for i in range(level):
+ imp.acquire_lock()
+ release += 1
+ pid = os.fork()
+ in_child = not pid
+ finally:
+ for i in range(release):
+ imp.release_lock()
+ except RuntimeError:
+ if in_child:
+ if verbose > 1:
+ print("RuntimeError in child")
+ os._exit(1)
+ raise
+ if in_child:
+ os._exit(0)
+ self.wait_impl(pid)
+
+ # Check this works with various levels of nested
+ # import in the main thread
+ for level in range(5):
+ fork_with_import_lock(level)
+
+
def test_main():
run_unittest(ForkTest)
reap_children()
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index 054baf612d..7fa950d9ef 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -10,10 +10,7 @@ maxsize = support.MAX_Py_ssize_t
# they crash python)
# test on unicode strings as well
-overflowok = 1
-overflowrequired = 0
-
-def testformat(formatstr, args, output=None, limit=None):
+def testformat(formatstr, args, output=None, limit=None, overflowok=False):
if verbose:
if output:
print("%r %% %r =? %r ..." %\
@@ -28,15 +25,9 @@ def testformat(formatstr, args, output=None, limit=None):
if verbose:
print('overflow (this is fine)')
else:
- if overflowrequired:
- if verbose:
- print('no')
- print("overflow expected on %r %% %r" % (formatstr, args))
- elif output and limit is None and result != output:
+ if output and limit is None and result != output:
if verbose:
print('no')
- #print("%r %% %r == %r != %r" %\
- # (formatstr, args, result, output))
raise AssertionError("%r %% %r == %r != %r" %
(formatstr, args, result, output))
# when 'limit' is specified, it determines how many characters
@@ -58,10 +49,18 @@ def testformat(formatstr, args, output=None, limit=None):
class FormatTest(unittest.TestCase):
def test_format(self):
testformat("%.1d", (1,), "1")
- testformat("%.*d", (sys.maxsize,1)) # expect overflow
- testformat("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
- testformat("%#.117x", (1,), '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
- testformat("%#.118x", (1,), '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
+ testformat("%.*d", (sys.maxsize,1), overflowok=True) # expect overflow
+ testformat("%.100d", (1,), '00000000000000000000000000000000000000'
+ '000000000000000000000000000000000000000000000000000000'
+ '00000001', overflowok=True)
+ testformat("%#.117x", (1,), '0x00000000000000000000000000000000000'
+ '000000000000000000000000000000000000000000000000000000'
+ '0000000000000000000000000001',
+ overflowok=True)
+ testformat("%#.118x", (1,), '0x00000000000000000000000000000000000'
+ '000000000000000000000000000000000000000000000000000000'
+ '00000000000000000000000000001',
+ overflowok=True)
testformat("%f", (1.0,), "1.000000")
# these are trying to test the limits of the internal magic-number-length
@@ -72,15 +71,15 @@ class FormatTest(unittest.TestCase):
testformat("%#.*g", (110, -1.e+100/3.))
# test some ridiculously large precision, expect overflow
testformat('%12.*f', (123456, 1.0))
+
# check for internal overflow validation on length of precision
- overflowrequired = 1
+ # these tests should no longer cause overflow in Python
+ # 2.7/3.1 and later.
testformat("%#.*g", (110, -1.e+100/3.))
testformat("%#.*G", (110, -1.e+100/3.))
testformat("%#.*f", (110, -1.e+100/3.))
testformat("%#.*F", (110, -1.e+100/3.))
- overflowrequired = 0
# Formatting of integers. Overflow is not ok
- overflowok = 0
testformat("%x", 10, "a")
testformat("%x", 100000000000, "174876e800")
testformat("%o", 10, "12")
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py
index 17fdb7f6ea..26e132f4e5 100644
--- a/Lib/test/test_fractions.py
+++ b/Lib/test/test_fractions.py
@@ -1,7 +1,7 @@
"""Tests for Lib/fractions.py."""
from decimal import Decimal
-from test.support import run_unittest
+from test.support import run_unittest, requires_IEEE_754
import math
import numbers
import operator
@@ -130,13 +130,33 @@ class FractionTest(unittest.TestCase):
self.assertRaisesMessage(ZeroDivisionError, "Fraction(12, 0)",
F, 12, 0)
- self.assertRaises(TypeError, F, 1.5)
self.assertRaises(TypeError, F, 1.5 + 3j)
self.assertRaises(TypeError, F, "3/2", 3)
self.assertRaises(TypeError, F, 3, 0j)
self.assertRaises(TypeError, F, 3, 1j)
+ @requires_IEEE_754
+ def testInitFromFloat(self):
+ self.assertEqual((5, 2), _components(F(2.5)))
+ self.assertEqual((0, 1), _components(F(-0.0)))
+ self.assertEqual((3602879701896397, 36028797018963968),
+ _components(F(0.1)))
+ self.assertRaises(TypeError, F, float('nan'))
+ self.assertRaises(TypeError, F, float('inf'))
+ self.assertRaises(TypeError, F, float('-inf'))
+
+ def testInitFromDecimal(self):
+ self.assertEqual((11, 10),
+ _components(F(Decimal('1.1'))))
+ self.assertEqual((7, 200),
+ _components(F(Decimal('3.5e-2'))))
+ self.assertEqual((0, 1),
+ _components(F(Decimal('.000e20'))))
+ self.assertRaises(TypeError, F, Decimal('nan'))
+ self.assertRaises(TypeError, F, Decimal('snan'))
+ self.assertRaises(TypeError, F, Decimal('inf'))
+ self.assertRaises(TypeError, F, Decimal('-inf'))
def testFromString(self):
self.assertEqual((5, 1), _components(F("5")))
@@ -216,10 +236,10 @@ class FractionTest(unittest.TestCase):
self.assertEqual((10, 1), _components(F.from_float(10.0)))
self.assertEqual((-5, 2), _components(F.from_float(-2.5)))
self.assertEqual((99999999999999991611392, 1),
- _components(F.from_float(1e23)))
+ _components(F.from_float(1e23)))
self.assertEqual(float(10**23), float(F.from_float(1e23)))
self.assertEqual((3602879701896397, 1125899906842624),
- _components(F.from_float(3.2)))
+ _components(F.from_float(3.2)))
self.assertEqual(3.2, float(F.from_float(3.2)))
inf = 1e1000
@@ -370,12 +390,11 @@ class FractionTest(unittest.TestCase):
self.assertTypedEquals(1.0 + 0j, (1.0 + 0j) ** F(1, 10))
def testMixingWithDecimal(self):
- # Decimal refuses mixed comparisons.
+ # Decimal refuses mixed arithmetic (but not mixed comparisons)
self.assertRaisesMessage(
TypeError,
"unsupported operand type(s) for +: 'Fraction' and 'Decimal'",
operator.add, F(3,11), Decimal('3.1415926'))
- self.assertNotEqual(F(5, 2), Decimal('2.5'))
def testComparisons(self):
self.assertTrue(F(1, 2) < F(2, 3))
@@ -479,8 +498,21 @@ class FractionTest(unittest.TestCase):
def testBigComplexComparisons(self):
self.assertFalse(F(10**23) == complex(10**23))
- self.assertTrue(F(10**23) > complex(10**23))
- self.assertFalse(F(10**23) <= complex(10**23))
+ self.assertRaises(TypeError, operator.gt, F(10**23), complex(10**23))
+ self.assertRaises(TypeError, operator.le, F(10**23), complex(10**23))
+
+ x = F(3, 8)
+ z = complex(0.375, 0.0)
+ w = complex(0.375, 0.2)
+ self.assertTrue(x == z)
+ self.assertFalse(x != z)
+ self.assertFalse(x == w)
+ self.assertTrue(x != w)
+ for op in operator.lt, operator.le, operator.gt, operator.ge:
+ self.assertRaises(TypeError, op, x, z)
+ self.assertRaises(TypeError, op, z, x)
+ self.assertRaises(TypeError, op, x, w)
+ self.assertRaises(TypeError, op, w, x)
def testMixedEqual(self):
self.assertTrue(0.5 == F(1, 2))
@@ -499,9 +531,9 @@ class FractionTest(unittest.TestCase):
def testStringification(self):
self.assertEqual("Fraction(7, 3)", repr(F(7, 3)))
self.assertEqual("Fraction(6283185307, 2000000000)",
- repr(F('3.1415926535')))
+ repr(F('3.1415926535')))
self.assertEqual("Fraction(-1, 100000000000000000000)",
- repr(F(1, -10**20)))
+ repr(F(1, -10**20)))
self.assertEqual("7/3", str(F(7, 3)))
self.assertEqual("7", str(F(7, 1)))
@@ -509,6 +541,9 @@ class FractionTest(unittest.TestCase):
self.assertEqual(hash(2.5), hash(F(5, 2)))
self.assertEqual(hash(10**50), hash(F(10**50)))
self.assertNotEqual(hash(float(10**23)), hash(F(10**23)))
+ # Check that __hash__ produces the same value as hash(), for
+ # consistency with int and Decimal. (See issue #10356.)
+ self.assertEqual(hash(F(-1)), F(-1).__hash__())
def testApproximatePi(self):
# Algorithm borrowed from
diff --git a/Lib/test/test_frozen.py b/Lib/test/test_frozen.py
index d0721450a1..07131af1cc 100644
--- a/Lib/test/test_frozen.py
+++ b/Lib/test/test_frozen.py
@@ -2,7 +2,7 @@
from test.support import captured_stdout, run_unittest
import unittest
-import sys, os
+import sys
class FrozenTests(unittest.TestCase):
def test_frozen(self):
@@ -11,7 +11,7 @@ class FrozenTests(unittest.TestCase):
except ImportError as x:
self.fail("import __hello__ failed:" + str(x))
self.assertEqual(__hello__.initialized, True)
- self.assertEqual(len(dir(__hello__)), 6, dir(__hello__))
+ self.assertEqual(len(dir(__hello__)), 7, dir(__hello__))
try:
import __phello__
@@ -19,9 +19,9 @@ class FrozenTests(unittest.TestCase):
self.fail("import __phello__ failed:" + str(x))
self.assertEqual(__phello__.initialized, True)
if not "__phello__.spam" in sys.modules:
- self.assertEqual(len(dir(__phello__)), 7, dir(__phello__))
- else:
self.assertEqual(len(dir(__phello__)), 8, dir(__phello__))
+ else:
+ self.assertEqual(len(dir(__phello__)), 9, dir(__phello__))
self.assertEqual(__phello__.__path__, [__phello__.__name__])
try:
@@ -29,8 +29,8 @@ class FrozenTests(unittest.TestCase):
except ImportError as x:
self.fail("import __phello__.spam failed:" + str(x))
self.assertEqual(__phello__.spam.initialized, True)
- self.assertEqual(len(dir(__phello__.spam)), 6)
- self.assertEqual(len(dir(__phello__)), 8)
+ self.assertEqual(len(dir(__phello__.spam)), 7)
+ self.assertEqual(len(dir(__phello__)), 9)
try:
import __phello__.foo
@@ -39,13 +39,12 @@ class FrozenTests(unittest.TestCase):
else:
self.fail("import __phello__.foo should have failed")
- if sys.platform != "mac": # On the Mac this import does succeed.
- try:
- import __phello__.foo
- except ImportError:
- pass
- else:
- self.fail("import __phello__.foo should have failed")
+ try:
+ import __phello__.foo
+ except ImportError:
+ pass
+ else:
+ self.fail("import __phello__.foo should have failed")
del sys.modules['__hello__']
del sys.modules['__phello__']
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index fa1079f788..9d2eab7fa3 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -1,17 +1,25 @@
"""Test script for ftplib module."""
-# Modified by Giampaolo Rodola' to test FTP class and IPv6 environment
+# Modified by Giampaolo Rodola' to test FTP class, IPv6 and TLS
+# environment
import ftplib
-import threading
import asyncore
import asynchat
import socket
import io
+import errno
+import os
+import time
+try:
+ import ssl
+except ImportError:
+ ssl = None
from unittest import TestCase
from test import support
from test.support import HOST
+threading = support.import_module('threading')
# the dummy data returned by server over the data channel when
# RETR, LIST and NLST commands are issued
@@ -21,6 +29,7 @@ NLST_DATA = 'foo\r\nbar\r\n'
class DummyDTPHandler(asynchat.async_chat):
+ dtp_conn_closed = False
def __init__(self, conn, baseclass):
asynchat.async_chat.__init__(self, conn)
@@ -31,15 +40,25 @@ class DummyDTPHandler(asynchat.async_chat):
self.baseclass.last_received_data += self.recv(1024).decode('ascii')
def handle_close(self):
- self.baseclass.push('226 transfer complete')
- self.close()
+ # XXX: this method can be called many times in a row for a single
+ # connection, including in clear-text (non-TLS) mode.
+ # (behaviour witnessed with test_data_connection)
+ if not self.dtp_conn_closed:
+ self.baseclass.push('226 transfer complete')
+ self.close()
+ self.dtp_conn_closed = True
def push(self, what):
super(DummyDTPHandler, self).push(what.encode('ascii'))
+ def handle_error(self):
+ raise
+
class DummyFTPHandler(asynchat.async_chat):
+ dtp_handler = DummyDTPHandler
+
def __init__(self, conn):
asynchat.async_chat.__init__(self, conn)
self.set_terminator(b"\r\n")
@@ -48,6 +67,7 @@ class DummyFTPHandler(asynchat.async_chat):
self.last_received_cmd = None
self.last_received_data = ''
self.next_response = ''
+ self.rest = None
self.push('220 welcome')
def collect_incoming_data(self, data):
@@ -83,41 +103,44 @@ class DummyFTPHandler(asynchat.async_chat):
ip = '%d.%d.%d.%d' %tuple(addr[:4])
port = (addr[4] * 256) + addr[5]
s = socket.create_connection((ip, port), timeout=10)
- self.dtp = DummyDTPHandler(s, baseclass=self)
+ self.dtp = self.dtp_handler(s, baseclass=self)
self.push('200 active data connection established')
def cmd_pasv(self, arg):
- sock = socket.socket()
- sock.bind((self.socket.getsockname()[0], 0))
- sock.listen(5)
- sock.settimeout(10)
- ip, port = sock.getsockname()[:2]
- ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256
- self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2))
- conn, addr = sock.accept()
- self.dtp = DummyDTPHandler(conn, baseclass=self)
+ with socket.socket() as sock:
+ sock.bind((self.socket.getsockname()[0], 0))
+ sock.listen(5)
+ sock.settimeout(10)
+ ip, port = sock.getsockname()[:2]
+ ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256
+ self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2))
+ conn, addr = sock.accept()
+ self.dtp = self.dtp_handler(conn, baseclass=self)
def cmd_eprt(self, arg):
af, ip, port = arg.split(arg[0])[1:-1]
port = int(port)
s = socket.create_connection((ip, port), timeout=10)
- self.dtp = DummyDTPHandler(s, baseclass=self)
+ self.dtp = self.dtp_handler(s, baseclass=self)
self.push('200 active data connection established')
def cmd_epsv(self, arg):
- sock = socket.socket(socket.AF_INET6)
- sock.bind((self.socket.getsockname()[0], 0))
- sock.listen(5)
- sock.settimeout(10)
- port = sock.getsockname()[1]
- self.push('229 entering extended passive mode (|||%d|)' %port)
- conn, addr = sock.accept()
- self.dtp = DummyDTPHandler(conn, baseclass=self)
+ with socket.socket(socket.AF_INET6) as sock:
+ sock.bind((self.socket.getsockname()[0], 0))
+ sock.listen(5)
+ sock.settimeout(10)
+ port = sock.getsockname()[1]
+ self.push('229 entering extended passive mode (|||%d|)' %port)
+ conn, addr = sock.accept()
+ self.dtp = self.dtp_handler(conn, baseclass=self)
def cmd_echo(self, arg):
# sends back the received string (used by the test suite)
self.push(arg)
+ def cmd_noop(self, arg):
+ self.push('200 noop ok')
+
def cmd_user(self, arg):
self.push('331 username ok')
@@ -161,10 +184,19 @@ class DummyFTPHandler(asynchat.async_chat):
def cmd_stor(self, arg):
self.push('125 stor ok')
+ def cmd_rest(self, arg):
+ self.rest = arg
+ self.push('350 rest ok')
+
def cmd_retr(self, arg):
self.push('125 retr ok')
- self.dtp.push(RETR_DATA)
+ if self.rest is not None:
+ offset = int(self.rest)
+ else:
+ offset = 0
+ self.dtp.push(RETR_DATA[offset:])
self.dtp.close_when_done()
+ self.rest = None
def cmd_list(self, arg):
self.push('125 list ok')
@@ -190,6 +222,7 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread):
self.active = False
self.active_lock = threading.Lock()
self.host, self.port = self.socket.getsockname()[:2]
+ self.handler_instance = None
def start(self):
assert not self.active
@@ -211,10 +244,8 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread):
self.active = False
self.join()
- def handle_accept(self):
- conn, addr = self.accept()
- self.handler = self.handler(conn)
- self.close()
+ def handle_accepted(self, conn, addr):
+ self.handler_instance = self.handler(conn)
def handle_connect(self):
self.close()
@@ -227,6 +258,154 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread):
raise
+if ssl is not None:
+
+ CERTFILE = os.path.join(os.path.dirname(__file__), "keycert.pem")
+
+ class SSLConnection(asyncore.dispatcher):
+ """An asyncore.dispatcher subclass supporting TLS/SSL."""
+
+ _ssl_accepting = False
+ _ssl_closing = False
+
+ def secure_connection(self):
+ self.del_channel()
+ socket = ssl.wrap_socket(self.socket, suppress_ragged_eofs=False,
+ certfile=CERTFILE, server_side=True,
+ do_handshake_on_connect=False,
+ ssl_version=ssl.PROTOCOL_SSLv23)
+ self.set_socket(socket)
+ self._ssl_accepting = True
+
+ def _do_ssl_handshake(self):
+ try:
+ self.socket.do_handshake()
+ except ssl.SSLError as err:
+ if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
+ ssl.SSL_ERROR_WANT_WRITE):
+ return
+ elif err.args[0] == ssl.SSL_ERROR_EOF:
+ return self.handle_close()
+ raise
+ except socket.error as err:
+ if err.args[0] == errno.ECONNABORTED:
+ return self.handle_close()
+ else:
+ self._ssl_accepting = False
+
+ def _do_ssl_shutdown(self):
+ self._ssl_closing = True
+ try:
+ self.socket = self.socket.unwrap()
+ except ssl.SSLError as err:
+ if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
+ ssl.SSL_ERROR_WANT_WRITE):
+ return
+ except socket.error as err:
+ # Any "socket error" corresponds to a SSL_ERROR_SYSCALL return
+ # from OpenSSL's SSL_shutdown(), corresponding to a
+ # closed socket condition. See also:
+ # http://www.mail-archive.com/openssl-users@openssl.org/msg60710.html
+ pass
+ self._ssl_closing = False
+ super(SSLConnection, self).close()
+
+ def handle_read_event(self):
+ if self._ssl_accepting:
+ self._do_ssl_handshake()
+ elif self._ssl_closing:
+ self._do_ssl_shutdown()
+ else:
+ super(SSLConnection, self).handle_read_event()
+
+ def handle_write_event(self):
+ if self._ssl_accepting:
+ self._do_ssl_handshake()
+ elif self._ssl_closing:
+ self._do_ssl_shutdown()
+ else:
+ super(SSLConnection, self).handle_write_event()
+
+ def send(self, data):
+ try:
+ return super(SSLConnection, self).send(data)
+ except ssl.SSLError as err:
+ if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN,
+ ssl.SSL_ERROR_WANT_READ,
+ ssl.SSL_ERROR_WANT_WRITE):
+ return 0
+ raise
+
+ def recv(self, buffer_size):
+ try:
+ return super(SSLConnection, self).recv(buffer_size)
+ except ssl.SSLError as err:
+ if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
+ ssl.SSL_ERROR_WANT_WRITE):
+ return b''
+ if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN):
+ self.handle_close()
+ return b''
+ raise
+
+ def handle_error(self):
+ raise
+
+ def close(self):
+ if (isinstance(self.socket, ssl.SSLSocket) and
+ self.socket._sslobj is not None):
+ self._do_ssl_shutdown()
+ else:
+ super(SSLConnection, self).close()
+
+
+ class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler):
+ """A DummyDTPHandler subclass supporting TLS/SSL."""
+
+ def __init__(self, conn, baseclass):
+ DummyDTPHandler.__init__(self, conn, baseclass)
+ if self.baseclass.secure_data_channel:
+ self.secure_connection()
+
+
+ class DummyTLS_FTPHandler(SSLConnection, DummyFTPHandler):
+ """A DummyFTPHandler subclass supporting TLS/SSL."""
+
+ dtp_handler = DummyTLS_DTPHandler
+
+ def __init__(self, conn):
+ DummyFTPHandler.__init__(self, conn)
+ self.secure_data_channel = False
+
+ def cmd_auth(self, line):
+ """Set up secure control channel."""
+ self.push('234 AUTH TLS successful')
+ self.secure_connection()
+
+ def cmd_pbsz(self, line):
+ """Negotiate size of buffer for secure data transfer.
+ For TLS/SSL the only valid value for the parameter is '0'.
+ Any other value is accepted but ignored.
+ """
+ self.push('200 PBSZ=0 successful.')
+
+ def cmd_prot(self, line):
+ """Setup un/secure data channel."""
+ arg = line.upper()
+ if arg == 'C':
+ self.push('200 Protection set to Clear')
+ self.secure_data_channel = False
+ elif arg == 'P':
+ self.push('200 Protection set to Private')
+ self.secure_data_channel = True
+ else:
+ self.push("502 Unrecognized PROT type (use C or P).")
+
+
+ class DummyTLS_FTPServer(DummyFTPServer):
+ handler = DummyTLS_FTPHandler
+
+
class TestFTPClass(TestCase):
def setUp(self):
@@ -285,12 +464,12 @@ class TestFTPClass(TestCase):
def test_rename(self):
self.client.rename('a', 'b')
- self.server.handler.next_response = '200'
+ self.server.handler_instance.next_response = '200'
self.assertRaises(ftplib.error_reply, self.client.rename, 'a', 'b')
def test_delete(self):
self.client.delete('foo')
- self.server.handler.next_response = '199'
+ self.server.handler_instance.next_response = '199'
self.assertRaises(ftplib.error_reply, self.client.delete, 'foo')
def test_size(self):
@@ -319,6 +498,17 @@ class TestFTPClass(TestCase):
self.client.retrbinary('retr', callback)
self.assertEqual(''.join(received), RETR_DATA)
+ def test_retrbinary_rest(self):
+ def callback(data):
+ received.append(data.decode('ascii'))
+ for rest in (0, 10, 20):
+ received = []
+ self.client.retrbinary('retr', callback, rest=rest)
+ self.assertEqual(''.join(received), RETR_DATA[rest:],
+ msg='rest test case %d %d %d' % (rest,
+ len(''.join(received)),
+ len(RETR_DATA[rest:])))
+
def test_retrlines(self):
received = []
self.client.retrlines('retr', received.append)
@@ -327,17 +517,24 @@ class TestFTPClass(TestCase):
def test_storbinary(self):
f = io.BytesIO(RETR_DATA.encode('ascii'))
self.client.storbinary('stor', f)
- self.assertEqual(self.server.handler.last_received_data, RETR_DATA)
+ self.assertEqual(self.server.handler_instance.last_received_data, RETR_DATA)
# test new callback arg
flag = []
f.seek(0)
self.client.storbinary('stor', f, callback=lambda x: flag.append(None))
self.assertTrue(flag)
+ def test_storbinary_rest(self):
+ f = io.BytesIO(RETR_DATA.replace('\r\n', '\n').encode('ascii'))
+ for r in (30, '30'):
+ f.seek(0)
+ self.client.storbinary('stor', f, rest=r)
+ self.assertEqual(self.server.handler_instance.rest, str(r))
+
def test_storlines(self):
f = io.BytesIO(RETR_DATA.replace('\r\n', '\n').encode('ascii'))
self.client.storlines('stor', f)
- self.assertEqual(self.server.handler.last_received_data, RETR_DATA)
+ self.assertEqual(self.server.handler_instance.last_received_data, RETR_DATA)
# test new callback arg
flag = []
f.seek(0)
@@ -354,16 +551,74 @@ class TestFTPClass(TestCase):
self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', ''))
def test_makeport(self):
- self.client.makeport()
- # IPv4 is in use, just make sure send_eprt has not been used
- self.assertEqual(self.server.handler.last_received_cmd, 'port')
+ with self.client.makeport():
+ # IPv4 is in use, just make sure send_eprt has not been used
+ self.assertEqual(self.server.handler_instance.last_received_cmd,
+ 'port')
def test_makepasv(self):
host, port = self.client.makepasv()
conn = socket.create_connection((host, port), 10)
conn.close()
# IPv4 is in use, just make sure send_epsv has not been used
- self.assertEqual(self.server.handler.last_received_cmd, 'pasv')
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'pasv')
+
+ def test_with_statement(self):
+ self.client.quit()
+
+ def is_client_connected():
+ if self.client.sock is None:
+ return False
+ try:
+ self.client.sendcmd('noop')
+ except (socket.error, EOFError):
+ return False
+ return True
+
+ # base test
+ with ftplib.FTP(timeout=10) as self.client:
+ self.client.connect(self.server.host, self.server.port)
+ self.client.sendcmd('noop')
+ self.assertTrue(is_client_connected())
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit')
+ self.assertFalse(is_client_connected())
+
+ # QUIT sent inside the with block
+ with ftplib.FTP(timeout=10) as self.client:
+ self.client.connect(self.server.host, self.server.port)
+ self.client.sendcmd('noop')
+ self.client.quit()
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit')
+ self.assertFalse(is_client_connected())
+
+ # force a wrong response code to be sent on QUIT: error_perm
+ # is expected and the connection is supposed to be closed
+ try:
+ with ftplib.FTP(timeout=10) as self.client:
+ self.client.connect(self.server.host, self.server.port)
+ self.client.sendcmd('noop')
+ self.server.handler_instance.next_response = '550 error on quit'
+ except ftplib.error_perm as err:
+ self.assertEqual(str(err), '550 error on quit')
+ else:
+ self.fail('Exception not raised')
+ # needed to give the threaded server some time to set the attribute
+ # which otherwise would still be == 'noop'
+ time.sleep(0.1)
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit')
+ self.assertFalse(is_client_connected())
+
+ def test_parse257(self):
+ self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar')
+ self.assertEqual(ftplib.parse257('257 "/foo/bar" created'), '/foo/bar')
+ self.assertEqual(ftplib.parse257('257 ""'), '')
+ self.assertEqual(ftplib.parse257('257 "" created'), '')
+ self.assertRaises(ftplib.error_reply, ftplib.parse257, '250 "/foo/bar"')
+ # The 257 response is supposed to include the directory
+ # name and in case it contains embedded double-quotes
+ # they must be doubled (see RFC-959, chapter 7, appendix 2).
+ self.assertEqual(ftplib.parse257('257 "/foo/b""ar"'), '/foo/b"ar')
+ self.assertEqual(ftplib.parse257('257 "/foo/b""ar" created'), '/foo/b"ar')
class TestIPv6Environment(TestCase):
@@ -382,14 +637,15 @@ class TestIPv6Environment(TestCase):
self.assertEqual(self.client.af, socket.AF_INET6)
def test_makeport(self):
- self.client.makeport()
- self.assertEqual(self.server.handler.last_received_cmd, 'eprt')
+ with self.client.makeport():
+ self.assertEqual(self.server.handler_instance.last_received_cmd,
+ 'eprt')
def test_makepasv(self):
host, port = self.client.makepasv()
conn = socket.create_connection((host, port), 10)
conn.close()
- self.assertEqual(self.server.handler.last_received_cmd, 'epsv')
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'epsv')
def test_transfer(self):
def retr():
@@ -404,6 +660,100 @@ class TestIPv6Environment(TestCase):
retr()
+class TestTLS_FTPClassMixin(TestFTPClass):
+ """Repeat TestFTPClass tests starting the TLS layer for both control
+ and data connections first.
+ """
+
+ def setUp(self):
+ self.server = DummyTLS_FTPServer((HOST, 0))
+ self.server.start()
+ self.client = ftplib.FTP_TLS(timeout=10)
+ self.client.connect(self.server.host, self.server.port)
+ # enable TLS
+ self.client.auth()
+ self.client.prot_p()
+
+
+class TestTLS_FTPClass(TestCase):
+ """Specific TLS_FTP class tests."""
+
+ def setUp(self):
+ self.server = DummyTLS_FTPServer((HOST, 0))
+ self.server.start()
+ self.client = ftplib.FTP_TLS(timeout=10)
+ self.client.connect(self.server.host, self.server.port)
+
+ def tearDown(self):
+ self.client.close()
+ self.server.stop()
+
+ def test_control_connection(self):
+ self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
+ self.client.auth()
+ self.assertIsInstance(self.client.sock, ssl.SSLSocket)
+
+ def test_data_connection(self):
+ # clear text
+ with self.client.transfercmd('list') as sock:
+ self.assertNotIsInstance(sock, ssl.SSLSocket)
+ self.assertEqual(self.client.voidresp(), "226 transfer complete")
+
+ # secured, after PROT P
+ self.client.prot_p()
+ with self.client.transfercmd('list') as sock:
+ self.assertIsInstance(sock, ssl.SSLSocket)
+ self.assertEqual(self.client.voidresp(), "226 transfer complete")
+
+ # PROT C is issued, the connection must be in cleartext again
+ self.client.prot_c()
+ with self.client.transfercmd('list') as sock:
+ self.assertNotIsInstance(sock, ssl.SSLSocket)
+ self.assertEqual(self.client.voidresp(), "226 transfer complete")
+
+ def test_login(self):
+ # login() is supposed to implicitly secure the control connection
+ self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
+ self.client.login()
+ self.assertIsInstance(self.client.sock, ssl.SSLSocket)
+ # make sure that AUTH TLS doesn't get issued again
+ self.client.login()
+
+ def test_auth_issued_twice(self):
+ self.client.auth()
+ self.assertRaises(ValueError, self.client.auth)
+
+ def test_auth_ssl(self):
+ try:
+ self.client.ssl_version = ssl.PROTOCOL_SSLv3
+ self.client.auth()
+ self.assertRaises(ValueError, self.client.auth)
+ finally:
+ self.client.ssl_version = ssl.PROTOCOL_TLSv1
+
+ def test_context(self):
+ self.client.quit()
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
+ context=ctx)
+ self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
+ context=ctx)
+ self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
+ keyfile=CERTFILE, context=ctx)
+
+ self.client = ftplib.FTP_TLS(context=ctx, timeout=10)
+ self.client.connect(self.server.host, self.server.port)
+ self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
+ self.client.auth()
+ self.assertIs(self.client.sock.context, ctx)
+ self.assertIsInstance(self.client.sock, ssl.SSLSocket)
+
+ self.client.prot_p()
+ with self.client.transfercmd('list') as sock:
+ self.assertIs(sock.context, ctx)
+ self.assertIsInstance(sock, ssl.SSLSocket)
+
+
class TestTimeouts(TestCase):
def setUp(self):
@@ -419,6 +769,7 @@ class TestTimeouts(TestCase):
def tearDown(self):
self.evt.wait()
+ self.sock.close()
def server(self, evt, serv):
# This method sets the evt 3 times:
@@ -505,6 +856,10 @@ def test_main():
pass
else:
tests.append(TestIPv6Environment)
+
+ if ssl is not None:
+ tests.extend([TestTLS_FTPClassMixin, TestTLS_FTPClass])
+
thread_info = support.threading_setup()
try:
support.run_unittest(*tests)
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py
index d1d03a32cd..4d1936879e 100644
--- a/Lib/test/test_funcattrs.py
+++ b/Lib/test/test_funcattrs.py
@@ -35,11 +35,11 @@ class FunctionPropertiesTest(FuncAttrsTest):
def test_dir_includes_correct_attrs(self):
self.b.known_attr = 7
- self.assertTrue('known_attr' in dir(self.b),
+ self.assertIn('known_attr', dir(self.b),
"set attributes not in dir listing of method")
# Test on underlying function object of method
self.F.a.known_attr = 7
- self.assertTrue('known_attr' in dir(self.fi.a), "set attribute on function "
+ self.assertIn('known_attr', dir(self.fi.a), "set attribute on function "
"implementations, should show up in next dir")
def test_duplicate_function_equality(self):
@@ -64,7 +64,7 @@ class FunctionPropertiesTest(FuncAttrsTest):
a = 12
def f(): print(a)
c = f.__closure__
- self.assertTrue(isinstance(c, tuple))
+ self.assertIsInstance(c, tuple)
self.assertEqual(len(c), 1)
# don't have a type object handy
self.assertEqual(c[0].__class__.__name__, "cell")
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index d20bafe7dc..73a77d63f2 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1,8 +1,10 @@
import functools
+import sys
import unittest
from test import support
from weakref import proxy
import pickle
+from random import choice
@staticmethod
def PythonPartial(func, *args, **keywords):
@@ -44,9 +46,17 @@ class TestPartial(unittest.TestCase):
# attributes should not be writable
if not isinstance(self.thetype, type):
return
- self.assertRaises(TypeError, setattr, p, 'func', map)
- self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
- self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))
+ self.assertRaises(AttributeError, setattr, p, 'func', map)
+ self.assertRaises(AttributeError, setattr, p, 'args', (1, 2))
+ self.assertRaises(AttributeError, setattr, p, 'keywords', dict(a=1, b=2))
+
+ p = self.thetype(hex)
+ try:
+ del p.__dict__
+ except TypeError:
+ pass
+ else:
+ self.fail('partial object allowed __dict__ to be deleted')
def test_argument_checking(self):
self.assertRaises(TypeError, self.thetype) # need at least a func arg
@@ -122,15 +132,6 @@ class TestPartial(unittest.TestCase):
self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0)
self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1)
- def test_attributes(self):
- p = self.thetype(hex)
- try:
- del p.__dict__
- except TypeError:
- pass
- else:
- self.fail('partial object allowed __dict__ to be deleted')
-
def test_weakref(self):
f = self.thetype(int, base=16)
p = proxy(f)
@@ -145,6 +146,32 @@ class TestPartial(unittest.TestCase):
join = self.thetype(''.join)
self.assertEqual(join(data), '0123456789')
+ def test_repr(self):
+ args = (object(), object())
+ args_repr = ', '.join(repr(a) for a in args)
+ kwargs = {'a': object(), 'b': object()}
+ kwargs_repr = ', '.join("%s=%r" % (k, v) for k, v in kwargs.items())
+ if self.thetype is functools.partial:
+ name = 'functools.partial'
+ else:
+ name = self.thetype.__name__
+
+ f = self.thetype(capture)
+ self.assertEqual('{}({!r})'.format(name, capture),
+ repr(f))
+
+ f = self.thetype(capture, *args)
+ self.assertEqual('{}({!r}, {})'.format(name, capture, args_repr),
+ repr(f))
+
+ f = self.thetype(capture, **kwargs)
+ self.assertEqual('{}({!r}, {})'.format(name, capture, kwargs_repr),
+ repr(f))
+
+ f = self.thetype(capture, *args, **kwargs)
+ self.assertEqual('{}({!r}, {}, {})'.format(name, capture, args_repr, kwargs_repr),
+ repr(f))
+
def test_pickle(self):
f = self.thetype(signature, 'asdf', bar=True)
f.add_something_to__dict__ = True
@@ -162,6 +189,9 @@ class TestPythonPartial(TestPartial):
thetype = PythonPartial
+ # the python version hasn't a nice repr
+ def test_repr(self): pass
+
# the python version isn't picklable
def test_pickle(self): pass
@@ -180,7 +210,7 @@ class TestUpdateWrapper(unittest.TestCase):
for key in wrapped_attr:
self.assertTrue(wrapped_attr[key] is wrapper_attr[key])
- def test_default_update(self):
+ def _default_update(self):
def f(a:'This is a new annotation'):
"""This is a test"""
pass
@@ -188,13 +218,23 @@ class TestUpdateWrapper(unittest.TestCase):
def wrapper(b:'This is the prior annotation'):
pass
functools.update_wrapper(wrapper, f)
+ return wrapper, f
+
+ def test_default_update(self):
+ wrapper, f = self._default_update()
self.check_wrapper(wrapper, f)
+ self.assertIs(wrapper.__wrapped__, f)
self.assertEqual(wrapper.__name__, 'f')
- self.assertEqual(wrapper.__doc__, 'This is a test')
self.assertEqual(wrapper.attr, 'This is also a test')
self.assertEqual(wrapper.__annotations__['a'], 'This is a new annotation')
self.assertNotIn('b', wrapper.__annotations__)
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_default_update_doc(self):
+ wrapper, f = self._default_update()
+ self.assertEqual(wrapper.__doc__, 'This is a test')
+
def test_no_update(self):
def f():
"""This is a test"""
@@ -226,6 +266,28 @@ class TestUpdateWrapper(unittest.TestCase):
self.assertEqual(wrapper.attr, 'This is a different test')
self.assertEqual(wrapper.dict_attr, f.dict_attr)
+ def test_missing_attributes(self):
+ def f():
+ pass
+ def wrapper():
+ pass
+ wrapper.dict_attr = {}
+ assign = ('attr',)
+ update = ('dict_attr',)
+ # Missing attributes on wrapped object are ignored
+ functools.update_wrapper(wrapper, f, assign, update)
+ self.assertNotIn('attr', wrapper.__dict__)
+ self.assertEqual(wrapper.dict_attr, {})
+ # Wrapper must have expected attributes for updating
+ del wrapper.dict_attr
+ with self.assertRaises(AttributeError):
+ functools.update_wrapper(wrapper, f, assign, update)
+ wrapper.dict_attr = 1
+ with self.assertRaises(AttributeError):
+ functools.update_wrapper(wrapper, f, assign, update)
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_builtin_update(self):
# Test for bug #1576241
def wrapper():
@@ -237,7 +299,7 @@ class TestUpdateWrapper(unittest.TestCase):
class TestWraps(TestUpdateWrapper):
- def test_default_update(self):
+ def _default_update(self):
def f():
"""This is a test"""
pass
@@ -246,10 +308,19 @@ class TestWraps(TestUpdateWrapper):
def wrapper():
pass
self.check_wrapper(wrapper, f)
+ return wrapper
+
+ def test_default_update(self):
+ wrapper = self._default_update()
self.assertEqual(wrapper.__name__, 'f')
- self.assertEqual(wrapper.__doc__, 'This is a test')
self.assertEqual(wrapper.attr, 'This is also a test')
+ @unittest.skipIf(not sys.flags.optimize <= 1,
+ "Docstrings are omitted with -O2 and above")
+ def test_default_update_doc(self):
+ wrapper = self._default_update()
+ self.assertEqual(wrapper.__doc__, 'This is a test')
+
def test_no_update(self):
def f():
"""This is a test"""
@@ -363,18 +434,235 @@ class TestReduce(unittest.TestCase):
d = {"one": 1, "two": 2, "three": 3}
self.assertEqual(self.func(add, d), "".join(d.keys()))
-
-
+class TestCmpToKey(unittest.TestCase):
+ def test_cmp_to_key(self):
+ def mycmp(x, y):
+ return y - x
+ self.assertEqual(sorted(range(5), key=functools.cmp_to_key(mycmp)),
+ [4, 3, 2, 1, 0])
+
+ def test_hash(self):
+ def mycmp(x, y):
+ return y - x
+ key = functools.cmp_to_key(mycmp)
+ k = key(10)
+ self.assertRaises(TypeError, hash(k))
+
+class TestTotalOrdering(unittest.TestCase):
+
+ def test_total_ordering_lt(self):
+ @functools.total_ordering
+ class A:
+ def __init__(self, value):
+ self.value = value
+ def __lt__(self, other):
+ return self.value < other.value
+ def __eq__(self, other):
+ return self.value == other.value
+ self.assertTrue(A(1) < A(2))
+ self.assertTrue(A(2) > A(1))
+ self.assertTrue(A(1) <= A(2))
+ self.assertTrue(A(2) >= A(1))
+ self.assertTrue(A(2) <= A(2))
+ self.assertTrue(A(2) >= A(2))
+
+ def test_total_ordering_le(self):
+ @functools.total_ordering
+ class A:
+ def __init__(self, value):
+ self.value = value
+ def __le__(self, other):
+ return self.value <= other.value
+ def __eq__(self, other):
+ return self.value == other.value
+ self.assertTrue(A(1) < A(2))
+ self.assertTrue(A(2) > A(1))
+ self.assertTrue(A(1) <= A(2))
+ self.assertTrue(A(2) >= A(1))
+ self.assertTrue(A(2) <= A(2))
+ self.assertTrue(A(2) >= A(2))
+
+ def test_total_ordering_gt(self):
+ @functools.total_ordering
+ class A:
+ def __init__(self, value):
+ self.value = value
+ def __gt__(self, other):
+ return self.value > other.value
+ def __eq__(self, other):
+ return self.value == other.value
+ self.assertTrue(A(1) < A(2))
+ self.assertTrue(A(2) > A(1))
+ self.assertTrue(A(1) <= A(2))
+ self.assertTrue(A(2) >= A(1))
+ self.assertTrue(A(2) <= A(2))
+ self.assertTrue(A(2) >= A(2))
+
+ def test_total_ordering_ge(self):
+ @functools.total_ordering
+ class A:
+ def __init__(self, value):
+ self.value = value
+ def __ge__(self, other):
+ return self.value >= other.value
+ def __eq__(self, other):
+ return self.value == other.value
+ self.assertTrue(A(1) < A(2))
+ self.assertTrue(A(2) > A(1))
+ self.assertTrue(A(1) <= A(2))
+ self.assertTrue(A(2) >= A(1))
+ self.assertTrue(A(2) <= A(2))
+ self.assertTrue(A(2) >= A(2))
+
+ def test_total_ordering_no_overwrite(self):
+ # new methods should not overwrite existing
+ @functools.total_ordering
+ class A(int):
+ pass
+ self.assertTrue(A(1) < A(2))
+ self.assertTrue(A(2) > A(1))
+ self.assertTrue(A(1) <= A(2))
+ self.assertTrue(A(2) >= A(1))
+ self.assertTrue(A(2) <= A(2))
+ self.assertTrue(A(2) >= A(2))
+
+ def test_no_operations_defined(self):
+ with self.assertRaises(ValueError):
+ @functools.total_ordering
+ class A:
+ pass
+
+ def test_bug_10042(self):
+ @functools.total_ordering
+ class TestTO:
+ def __init__(self, value):
+ self.value = value
+ def __eq__(self, other):
+ if isinstance(other, TestTO):
+ return self.value == other.value
+ return False
+ def __lt__(self, other):
+ if isinstance(other, TestTO):
+ return self.value < other.value
+ raise TypeError
+ with self.assertRaises(TypeError):
+ TestTO(8) <= ()
+
+class TestLRU(unittest.TestCase):
+
+ def test_lru(self):
+ def orig(x, y):
+ return 3*x+y
+ f = functools.lru_cache(maxsize=20)(orig)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(maxsize, 20)
+ self.assertEqual(currsize, 0)
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 0)
+
+ domain = range(5)
+ for i in range(1000):
+ x, y = choice(domain), choice(domain)
+ actual = f(x, y)
+ expected = orig(x, y)
+ self.assertEqual(actual, expected)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertTrue(hits > misses)
+ self.assertEqual(hits + misses, 1000)
+ self.assertEqual(currsize, 20)
+
+ f.cache_clear() # test clearing
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 0)
+ self.assertEqual(currsize, 0)
+ f(x, y)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 1)
+ self.assertEqual(currsize, 1)
+
+ # Test bypassing the cache
+ self.assertIs(f.__wrapped__, orig)
+ f.__wrapped__(x, y)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 1)
+ self.assertEqual(currsize, 1)
+
+ # test size zero (which means "never-cache")
+ @functools.lru_cache(0)
+ def f():
+ nonlocal f_cnt
+ f_cnt += 1
+ return 20
+ self.assertEqual(f.cache_info().maxsize, 0)
+ f_cnt = 0
+ for i in range(5):
+ self.assertEqual(f(), 20)
+ self.assertEqual(f_cnt, 5)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 5)
+ self.assertEqual(currsize, 0)
+
+ # test size one
+ @functools.lru_cache(1)
+ def f():
+ nonlocal f_cnt
+ f_cnt += 1
+ return 20
+ self.assertEqual(f.cache_info().maxsize, 1)
+ f_cnt = 0
+ for i in range(5):
+ self.assertEqual(f(), 20)
+ self.assertEqual(f_cnt, 1)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 4)
+ self.assertEqual(misses, 1)
+ self.assertEqual(currsize, 1)
+
+ # test size two
+ @functools.lru_cache(2)
+ def f(x):
+ nonlocal f_cnt
+ f_cnt += 1
+ return x*10
+ self.assertEqual(f.cache_info().maxsize, 2)
+ f_cnt = 0
+ for x in 7, 9, 7, 9, 7, 9, 8, 8, 8, 9, 9, 9, 8, 8, 8, 7:
+ # * * * *
+ self.assertEqual(f(x), x*10)
+ self.assertEqual(f_cnt, 4)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 12)
+ self.assertEqual(misses, 4)
+ self.assertEqual(currsize, 2)
+
+ def test_lru_with_maxsize_none(self):
+ @functools.lru_cache(maxsize=None)
+ def fib(n):
+ if n < 2:
+ return n
+ return fib(n-1) + fib(n-2)
+ self.assertEqual([fib(n) for n in range(16)],
+ [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610])
+ self.assertEqual(fib.cache_info(),
+ functools._CacheInfo(hits=28, misses=16, maxsize=None, currsize=16))
+ fib.cache_clear()
+ self.assertEqual(fib.cache_info(),
+ functools._CacheInfo(hits=0, misses=0, maxsize=None, currsize=0))
def test_main(verbose=None):
- import sys
test_classes = (
TestPartial,
TestPartialSubclass,
TestPythonPartial,
TestUpdateWrapper,
+ TestTotalOrdering,
TestWraps,
- TestReduce
+ TestReduce,
+ TestLRU,
)
support.run_unittest(*test_classes)
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py
index 1cede70eeb..c6689a1a18 100644
--- a/Lib/test/test_future.py
+++ b/Lib/test/test_future.py
@@ -109,7 +109,7 @@ class FutureTest(unittest.TestCase):
def test_unicode_literals_exec(self):
scope = {}
exec("from __future__ import unicode_literals; x = ''", {}, scope)
- self.assertTrue(isinstance(scope["x"], str))
+ self.assertIsInstance(scope["x"], str)
def test_main():
diff --git a/Lib/test/test_future5.py b/Lib/test/test_future5.py
index 57cbe9f0d5..9ca3a364f7 100644
--- a/Lib/test/test_future5.py
+++ b/Lib/test/test_future5.py
@@ -9,7 +9,7 @@ from . import support
class TestMultipleFeatures(unittest.TestCase):
def test_unicode_literals(self):
- self.assertTrue(isinstance("", str))
+ self.assertIsInstance("", str)
def test_print_function(self):
with support.captured_output("stderr") as s:
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index 3b7df992d8..0e5a397746 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -1,5 +1,5 @@
import unittest
-from test.support import verbose, run_unittest
+from test.support import verbose, run_unittest, strip_python_stderr
import sys
import gc
import weakref
@@ -466,6 +466,53 @@ class GCTests(unittest.TestCase):
# would be damaged, with an empty __dict__.
self.assertEqual(x, None)
+ def test_garbage_at_shutdown(self):
+ import subprocess
+ code = """if 1:
+ import gc
+ class X:
+ def __init__(self, name):
+ self.name = name
+ def __repr__(self):
+ return "<X %%r>" %% self.name
+ def __del__(self):
+ pass
+
+ x = X('first')
+ x.x = x
+ x.y = X('second')
+ del x
+ gc.set_debug(%s)
+ """
+ def run_command(code):
+ p = subprocess.Popen([sys.executable, "-Wd", "-c", code],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ p.stdout.close()
+ p.stderr.close()
+ self.assertEqual(p.returncode, 0)
+ self.assertEqual(stdout.strip(), b"")
+ return strip_python_stderr(stderr)
+
+ stderr = run_command(code % "0")
+ self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
+ b"shutdown; use", stderr)
+ self.assertNotIn(b"<X 'first'>", stderr)
+ # With DEBUG_UNCOLLECTABLE, the garbage list gets printed
+ stderr = run_command(code % "gc.DEBUG_UNCOLLECTABLE")
+ self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
+ b"shutdown", stderr)
+ self.assertTrue(
+ (b"[<X 'first'>, <X 'second'>]" in stderr) or
+ (b"[<X 'second'>, <X 'first'>]" in stderr), stderr)
+ # With DEBUG_SAVEALL, no additional message should get printed
+ # (because gc.garbage also contains normally reclaimable cyclic
+ # references, and its elements get printed at runtime anyway).
+ stderr = run_command(code % "gc.DEBUG_SAVEALL")
+ self.assertNotIn(b"uncollectable objects at shutdown", stderr)
+
+
class GCTogglingTests(unittest.TestCase):
def setUp(self):
gc.enable()
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
new file mode 100644
index 0000000000..17b44ea354
--- /dev/null
+++ b/Lib/test/test_gdb.py
@@ -0,0 +1,681 @@
+# Verify that gdb can pretty-print the various PyObject* types
+#
+# The code for testing gdb was adapted from similar work in Unladen Swallow's
+# Lib/test/test_jit_gdb.py
+
+import os
+import re
+import subprocess
+import sys
+import unittest
+import locale
+
+from test.support import run_unittest, findfile, python_is_optimized
+
+try:
+ gdb_version, _ = subprocess.Popen(["gdb", "--version"],
+ stdout=subprocess.PIPE).communicate()
+except OSError:
+ # This is what "no gdb" looks like. There may, however, be other
+ # errors that manifest this way too.
+ raise unittest.SkipTest("Couldn't find gdb on the path")
+gdb_version_number = re.search(b"^GNU gdb [^\d]*(\d+)\.", gdb_version)
+if int(gdb_version_number.group(1)) < 7:
+ raise unittest.SkipTest("gdb versions before 7.0 didn't support python embedding"
+ " Saw:\n" + gdb_version.decode('ascii', 'replace'))
+
+# Verify that "gdb" was built with the embedded python support enabled:
+cmd = "--eval-command=python import sys; print sys.version_info"
+p = subprocess.Popen(["gdb", "--batch", cmd],
+ stdout=subprocess.PIPE)
+gdbpy_version, _ = p.communicate()
+if gdbpy_version == b'':
+ raise unittest.SkipTest("gdb not built with embedded python support")
+
+def gdb_has_frame_select():
+ # Does this build of gdb have gdb.Frame.select ?
+ cmd = "--eval-command=python print(dir(gdb.Frame))"
+ p = subprocess.Popen(["gdb", "--batch", cmd],
+ stdout=subprocess.PIPE)
+ stdout, _ = p.communicate()
+ m = re.match(br'.*\[(.*)\].*', stdout)
+ if not m:
+ raise unittest.SkipTest("Unable to parse output from gdb.Frame.select test")
+ gdb_frame_dir = m.group(1).split(b', ')
+ return b"'select'" in gdb_frame_dir
+
+HAS_PYUP_PYDOWN = gdb_has_frame_select()
+
+BREAKPOINT_FN='builtin_id'
+
+class DebuggerTests(unittest.TestCase):
+
+ """Test that the debugger can debug Python."""
+
+ def run_gdb(self, *args):
+ """Runs gdb with the command line given by *args.
+
+ Returns its stdout, stderr
+ """
+ out, err = subprocess.Popen(
+ args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ ).communicate()
+ return out.decode('utf-8', 'replace'), err.decode('utf-8', 'replace')
+
+ def get_stack_trace(self, source=None, script=None,
+ breakpoint=BREAKPOINT_FN,
+ cmds_after_breakpoint=None,
+ import_site=False):
+ '''
+ Run 'python -c SOURCE' under gdb with a breakpoint.
+
+ Support injecting commands after the breakpoint is reached
+
+ Returns the stdout from gdb
+
+ cmds_after_breakpoint: if provided, a list of strings: gdb commands
+ '''
+ # We use "set breakpoint pending yes" to avoid blocking with a:
+ # Function "foo" not defined.
+ # Make breakpoint pending on future shared library load? (y or [n])
+ # error, which typically happens python is dynamically linked (the
+ # breakpoints of interest are to be found in the shared library)
+ # When this happens, we still get:
+ # Function "textiowrapper_write" not defined.
+ # emitted to stderr each time, alas.
+
+ # Initially I had "--eval-command=continue" here, but removed it to
+ # avoid repeated print breakpoints when traversing hierarchical data
+ # structures
+
+ # Generate a list of commands in gdb's language:
+ commands = ['set breakpoint pending yes',
+ 'break %s' % breakpoint,
+ 'run']
+ if cmds_after_breakpoint:
+ commands += cmds_after_breakpoint
+ else:
+ commands += ['backtrace']
+
+ # print commands
+
+ # Use "commands" to generate the arguments with which to invoke "gdb":
+ args = ["gdb", "--batch"]
+ args += ['--eval-command=%s' % cmd for cmd in commands]
+ args += ["--args",
+ sys.executable]
+
+ if not import_site:
+ # -S suppresses the default 'import site'
+ args += ["-S"]
+
+ if source:
+ args += ["-c", source]
+ elif script:
+ args += [script]
+
+ # print args
+ # print ' '.join(args)
+
+ # Use "args" to invoke gdb, capturing stdout, stderr:
+ out, err = self.run_gdb(*args)
+
+ # Ignore some noise on stderr due to the pending breakpoint:
+ err = err.replace('Function "%s" not defined.\n' % breakpoint, '')
+ # Ignore some other noise on stderr (http://bugs.python.org/issue8600)
+ err = err.replace("warning: Unable to find libthread_db matching"
+ " inferior's thread library, thread debugging will"
+ " not be available.\n",
+ '')
+ err = err.replace("warning: Cannot initialize thread debugging"
+ " library: Debugger service failed\n",
+ '')
+
+ # Ensure no unexpected error messages:
+ self.assertEqual(err, '')
+
+ return out
+
+ def get_gdb_repr(self, source,
+ cmds_after_breakpoint=None,
+ import_site=False):
+ # Given an input python source representation of data,
+ # run "python -c'id(DATA)'" under gdb with a breakpoint on
+ # builtin_id and scrape out gdb's representation of the "op"
+ # parameter, and verify that the gdb displays the same string
+ #
+ # Verify that the gdb displays the expected string
+ #
+ # For a nested structure, the first time we hit the breakpoint will
+ # give us the top-level structure
+ gdb_output = self.get_stack_trace(source, breakpoint=BREAKPOINT_FN,
+ cmds_after_breakpoint=cmds_after_breakpoint,
+ import_site=import_site)
+ # gdb can insert additional '\n' and space characters in various places
+ # in its output, depending on the width of the terminal it's connected
+ # to (using its "wrap_here" function)
+ m = re.match('.*#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)\)\s+at\s+Python/bltinmodule.c.*',
+ gdb_output, re.DOTALL)
+ if not m:
+ self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output))
+ return m.group(1), gdb_output
+
+ def assertEndsWith(self, actual, exp_end):
+ '''Ensure that the given "actual" string ends with "exp_end"'''
+ self.assertTrue(actual.endswith(exp_end),
+ msg='%r did not end with %r' % (actual, exp_end))
+
+ def assertMultilineMatches(self, actual, pattern):
+ m = re.match(pattern, actual, re.DOTALL)
+ if not m:
+ self.fail(msg='%r did not match %r' % (actual, pattern))
+
+ def get_sample_script(self):
+ return findfile('gdb_sample.py')
+
+class PrettyPrintTests(DebuggerTests):
+ def test_getting_backtrace(self):
+ gdb_output = self.get_stack_trace('id(42)')
+ self.assertTrue(BREAKPOINT_FN in gdb_output)
+
+ def assertGdbRepr(self, val, exp_repr=None, cmds_after_breakpoint=None):
+ # Ensure that gdb's rendering of the value in a debugged process
+ # matches repr(value) in this process:
+ gdb_repr, gdb_output = self.get_gdb_repr('id(' + ascii(val) + ')',
+ cmds_after_breakpoint)
+ if not exp_repr:
+ exp_repr = repr(val)
+ self.assertEqual(gdb_repr, exp_repr,
+ ('%r did not equal expected %r; full output was:\n%s'
+ % (gdb_repr, exp_repr, gdb_output)))
+
+ def test_int(self):
+ 'Verify the pretty-printing of various "int"/long values'
+ self.assertGdbRepr(42)
+ self.assertGdbRepr(0)
+ self.assertGdbRepr(-7)
+ self.assertGdbRepr(1000000000000)
+ self.assertGdbRepr(-1000000000000000)
+
+ def test_singletons(self):
+ 'Verify the pretty-printing of True, False and None'
+ self.assertGdbRepr(True)
+ self.assertGdbRepr(False)
+ self.assertGdbRepr(None)
+
+ def test_dicts(self):
+ 'Verify the pretty-printing of dictionaries'
+ self.assertGdbRepr({})
+ self.assertGdbRepr({'foo': 'bar'})
+ self.assertGdbRepr({'foo': 'bar', 'douglas':42})
+
+ def test_lists(self):
+ 'Verify the pretty-printing of lists'
+ self.assertGdbRepr([])
+ self.assertGdbRepr(list(range(5)))
+
+ def test_bytes(self):
+ 'Verify the pretty-printing of bytes'
+ self.assertGdbRepr(b'')
+ self.assertGdbRepr(b'And now for something hopefully the same')
+ self.assertGdbRepr(b'string with embedded NUL here \0 and then some more text')
+ self.assertGdbRepr(b'this is a tab:\t'
+ b' this is a slash-N:\n'
+ b' this is a slash-R:\r'
+ )
+
+ self.assertGdbRepr(b'this is byte 255:\xff and byte 128:\x80')
+
+ self.assertGdbRepr(bytes([b for b in range(255)]))
+
+ def test_strings(self):
+ 'Verify the pretty-printing of unicode strings'
+ encoding = locale.getpreferredencoding()
+ def check_repr(text):
+ try:
+ text.encode(encoding)
+ printable = True
+ except UnicodeEncodeError:
+ self.assertGdbRepr(text, ascii(text))
+ else:
+ self.assertGdbRepr(text)
+
+ self.assertGdbRepr('')
+ self.assertGdbRepr('And now for something hopefully the same')
+ self.assertGdbRepr('string with embedded NUL here \0 and then some more text')
+
+ # Test printing a single character:
+ # U+2620 SKULL AND CROSSBONES
+ check_repr('\u2620')
+
+ # Test printing a Japanese unicode string
+ # (I believe this reads "mojibake", using 3 characters from the CJK
+ # Unified Ideographs area, followed by U+3051 HIRAGANA LETTER KE)
+ check_repr('\u6587\u5b57\u5316\u3051')
+
+ # Test a character outside the BMP:
+ # U+1D121 MUSICAL SYMBOL C CLEF
+ # This is:
+ # UTF-8: 0xF0 0x9D 0x84 0xA1
+ # UTF-16: 0xD834 0xDD21
+ check_repr(chr(0x1D121))
+
+ def test_tuples(self):
+ 'Verify the pretty-printing of tuples'
+ self.assertGdbRepr(tuple())
+ self.assertGdbRepr((1,), '(1,)')
+ self.assertGdbRepr(('foo', 'bar', 'baz'))
+
+ def test_sets(self):
+ 'Verify the pretty-printing of sets'
+ self.assertGdbRepr(set())
+ self.assertGdbRepr(set(['a', 'b']))
+ self.assertGdbRepr(set([4, 5, 6]))
+
+ # Ensure that we handle sets containing the "dummy" key value,
+ # which happens on deletion:
+ gdb_repr, gdb_output = self.get_gdb_repr('''s = set(['a','b'])
+s.pop()
+id(s)''')
+ self.assertEqual(gdb_repr, "{'b'}")
+
+ def test_frozensets(self):
+ 'Verify the pretty-printing of frozensets'
+ self.assertGdbRepr(frozenset())
+ self.assertGdbRepr(frozenset(['a', 'b']))
+ self.assertGdbRepr(frozenset([4, 5, 6]))
+
+ def test_exceptions(self):
+ # Test a RuntimeError
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+try:
+ raise RuntimeError("I am an error")
+except RuntimeError as e:
+ id(e)
+''')
+ self.assertEqual(gdb_repr,
+ "RuntimeError('I am an error',)")
+
+
+ # Test division by zero:
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+try:
+ a = 1 / 0
+except ZeroDivisionError as e:
+ id(e)
+''')
+ self.assertEqual(gdb_repr,
+ "ZeroDivisionError('division by zero',)")
+
+ def test_modern_class(self):
+ 'Verify the pretty-printing of new-style class instances'
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+class Foo:
+ pass
+foo = Foo()
+foo.an_int = 42
+id(foo)''')
+ m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+ self.assertTrue(m,
+ msg='Unexpected new-style class rendering %r' % gdb_repr)
+
+ def test_subclassing_list(self):
+ 'Verify the pretty-printing of an instance of a list subclass'
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+class Foo(list):
+ pass
+foo = Foo()
+foo += [1, 2, 3]
+foo.an_int = 42
+id(foo)''')
+ m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+
+ self.assertTrue(m,
+ msg='Unexpected new-style class rendering %r' % gdb_repr)
+
+ def test_subclassing_tuple(self):
+ 'Verify the pretty-printing of an instance of a tuple subclass'
+ # This should exercise the negative tp_dictoffset code in the
+ # new-style class support
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+class Foo(tuple):
+ pass
+foo = Foo((1, 2, 3))
+foo.an_int = 42
+id(foo)''')
+ m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+
+ self.assertTrue(m,
+ msg='Unexpected new-style class rendering %r' % gdb_repr)
+
+ def assertSane(self, source, corruption, exprepr=None):
+ '''Run Python under gdb, corrupting variables in the inferior process
+ immediately before taking a backtrace.
+
+ Verify that the variable's representation is the expected failsafe
+ representation'''
+ if corruption:
+ cmds_after_breakpoint=[corruption, 'backtrace']
+ else:
+ cmds_after_breakpoint=['backtrace']
+
+ gdb_repr, gdb_output = \
+ self.get_gdb_repr(source,
+ cmds_after_breakpoint=cmds_after_breakpoint)
+ if exprepr:
+ if gdb_repr == exprepr:
+ # gdb managed to print the value in spite of the corruption;
+ # this is good (see http://bugs.python.org/issue8330)
+ return
+
+ # Match anything for the type name; 0xDEADBEEF could point to
+ # something arbitrary (see http://bugs.python.org/issue8330)
+ pattern = '<.* at remote 0x[0-9a-f]+>'
+
+ m = re.match(pattern, gdb_repr)
+ if not m:
+ self.fail('Unexpected gdb representation: %r\n%s' % \
+ (gdb_repr, gdb_output))
+
+ def test_NULL_ptr(self):
+ 'Ensure that a NULL PyObject* is handled gracefully'
+ gdb_repr, gdb_output = (
+ self.get_gdb_repr('id(42)',
+ cmds_after_breakpoint=['set variable v=0',
+ 'backtrace'])
+ )
+
+ self.assertEqual(gdb_repr, '0x0')
+
+ def test_NULL_ob_type(self):
+ 'Ensure that a PyObject* with NULL ob_type is handled gracefully'
+ self.assertSane('id(42)',
+ 'set v->ob_type=0')
+
+ def test_corrupt_ob_type(self):
+ 'Ensure that a PyObject* with a corrupt ob_type is handled gracefully'
+ self.assertSane('id(42)',
+ 'set v->ob_type=0xDEADBEEF',
+ exprepr='42')
+
+ def test_corrupt_tp_flags(self):
+ 'Ensure that a PyObject* with a type with corrupt tp_flags is handled'
+ self.assertSane('id(42)',
+ 'set v->ob_type->tp_flags=0x0',
+ exprepr='42')
+
+ def test_corrupt_tp_name(self):
+ 'Ensure that a PyObject* with a type with corrupt tp_name is handled'
+ self.assertSane('id(42)',
+ 'set v->ob_type->tp_name=0xDEADBEEF',
+ exprepr='42')
+
+ def test_builtins_help(self):
+ 'Ensure that the new-style class _Helper in site.py can be handled'
+ # (this was the issue causing tracebacks in
+ # http://bugs.python.org/issue8032#msg100537 )
+ gdb_repr, gdb_output = self.get_gdb_repr('id(__builtins__.help)', import_site=True)
+
+ m = re.match(r'<_Helper at remote 0x[0-9a-f]+>', gdb_repr)
+ self.assertTrue(m,
+ msg='Unexpected rendering %r' % gdb_repr)
+
+ def test_selfreferential_list(self):
+ '''Ensure that a reference loop involving a list doesn't lead proxyval
+ into an infinite loop:'''
+ gdb_repr, gdb_output = \
+ self.get_gdb_repr("a = [3, 4, 5] ; a.append(a) ; id(a)")
+ self.assertEqual(gdb_repr, '[3, 4, 5, [...]]')
+
+ gdb_repr, gdb_output = \
+ self.get_gdb_repr("a = [3, 4, 5] ; b = [a] ; a.append(b) ; id(a)")
+ self.assertEqual(gdb_repr, '[3, 4, 5, [[...]]]')
+
+ def test_selfreferential_dict(self):
+ '''Ensure that a reference loop involving a dict doesn't lead proxyval
+ into an infinite loop:'''
+ gdb_repr, gdb_output = \
+ self.get_gdb_repr("a = {} ; b = {'bar':a} ; a['foo'] = b ; id(a)")
+
+ self.assertEqual(gdb_repr, "{'foo': {'bar': {...}}}")
+
+ def test_selfreferential_old_style_instance(self):
+ gdb_repr, gdb_output = \
+ self.get_gdb_repr('''
+class Foo:
+ pass
+foo = Foo()
+foo.an_attr = foo
+id(foo)''')
+ self.assertTrue(re.match('<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>',
+ gdb_repr),
+ 'Unexpected gdb representation: %r\n%s' % \
+ (gdb_repr, gdb_output))
+
+ def test_selfreferential_new_style_instance(self):
+ gdb_repr, gdb_output = \
+ self.get_gdb_repr('''
+class Foo(object):
+ pass
+foo = Foo()
+foo.an_attr = foo
+id(foo)''')
+ self.assertTrue(re.match('<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>',
+ gdb_repr),
+ 'Unexpected gdb representation: %r\n%s' % \
+ (gdb_repr, gdb_output))
+
+ gdb_repr, gdb_output = \
+ self.get_gdb_repr('''
+class Foo(object):
+ pass
+a = Foo()
+b = Foo()
+a.an_attr = b
+b.an_attr = a
+id(a)''')
+ self.assertTrue(re.match('<Foo\(an_attr=<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>\) at remote 0x[0-9a-f]+>',
+ gdb_repr),
+ 'Unexpected gdb representation: %r\n%s' % \
+ (gdb_repr, gdb_output))
+
+ def test_truncation(self):
+ 'Verify that very long output is truncated'
+ gdb_repr, gdb_output = self.get_gdb_repr('id(list(range(1000)))')
+ self.assertEqual(gdb_repr,
+ "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, "
+ "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, "
+ "27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, "
+ "40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, "
+ "53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, "
+ "66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, "
+ "79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, "
+ "92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, "
+ "104, 105, 106, 107, 108, 109, 110, 111, 112, 113, "
+ "114, 115, 116, 117, 118, 119, 120, 121, 122, 123, "
+ "124, 125, 126, 127, 128, 129, 130, 131, 132, 133, "
+ "134, 135, 136, 137, 138, 139, 140, 141, 142, 143, "
+ "144, 145, 146, 147, 148, 149, 150, 151, 152, 153, "
+ "154, 155, 156, 157, 158, 159, 160, 161, 162, 163, "
+ "164, 165, 166, 167, 168, 169, 170, 171, 172, 173, "
+ "174, 175, 176, 177, 178, 179, 180, 181, 182, 183, "
+ "184, 185, 186, 187, 188, 189, 190, 191, 192, 193, "
+ "194, 195, 196, 197, 198, 199, 200, 201, 202, 203, "
+ "204, 205, 206, 207, 208, 209, 210, 211, 212, 213, "
+ "214, 215, 216, 217, 218, 219, 220, 221, 222, 223, "
+ "224, 225, 226...(truncated)")
+ self.assertEqual(len(gdb_repr),
+ 1024 + len('...(truncated)'))
+
+ def test_builtin_method(self):
+ gdb_repr, gdb_output = self.get_gdb_repr('import sys; id(sys.stdout.readlines)')
+ self.assertTrue(re.match('<built-in method readlines of _io.TextIOWrapper object at remote 0x[0-9a-f]+>',
+ gdb_repr),
+ 'Unexpected gdb representation: %r\n%s' % \
+ (gdb_repr, gdb_output))
+
+ def test_frames(self):
+ gdb_output = self.get_stack_trace('''
+def foo(a, b, c):
+ pass
+
+foo(3, 4, 5)
+id(foo.__code__)''',
+ breakpoint='builtin_id',
+ cmds_after_breakpoint=['print (PyFrameObject*)(((PyCodeObject*)v)->co_zombieframe)']
+ )
+ self.assertTrue(re.match('.*\s+\$1 =\s+Frame 0x[0-9a-f]+, for file <string>, line 3, in foo \(\)\s+.*',
+ gdb_output,
+ re.DOTALL),
+ 'Unexpected gdb representation: %r\n%s' % (gdb_output, gdb_output))
+
+class PyListTests(DebuggerTests):
+ def assertListing(self, expected, actual):
+ self.assertEndsWith(actual, expected)
+
+ def test_basic_command(self):
+ 'Verify that the "py-list" command works'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-list'])
+
+ self.assertListing(' 5 \n'
+ ' 6 def bar(a, b, c):\n'
+ ' 7 baz(a, b, c)\n'
+ ' 8 \n'
+ ' 9 def baz(*args):\n'
+ ' >10 id(42)\n'
+ ' 11 \n'
+ ' 12 foo(1, 2, 3)\n',
+ bt)
+
+ def test_one_abs_arg(self):
+ 'Verify the "py-list" command with one absolute argument'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-list 9'])
+
+ self.assertListing(' 9 def baz(*args):\n'
+ ' >10 id(42)\n'
+ ' 11 \n'
+ ' 12 foo(1, 2, 3)\n',
+ bt)
+
+ def test_two_abs_args(self):
+ 'Verify the "py-list" command with two absolute arguments'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-list 1,3'])
+
+ self.assertListing(' 1 # Sample script for use by test_gdb.py\n'
+ ' 2 \n'
+ ' 3 def foo(a, b, c):\n',
+ bt)
+
+class StackNavigationTests(DebuggerTests):
+ @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
+ def test_pyup_command(self):
+ 'Verify that the "py-up" command works'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-up'])
+ self.assertMultilineMatches(bt,
+ r'''^.*
+#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
+ baz\(a, b, c\)
+$''')
+
+ @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
+ def test_down_at_bottom(self):
+ 'Verify handling of "py-down" at the bottom of the stack'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-down'])
+ self.assertEndsWith(bt,
+ 'Unable to find a newer python frame\n')
+
+ @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
+ def test_up_at_top(self):
+ 'Verify handling of "py-up" at the top of the stack'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-up'] * 4)
+ self.assertEndsWith(bt,
+ 'Unable to find an older python frame\n')
+
+ @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
+ def test_up_then_down(self):
+ 'Verify "py-up" followed by "py-down"'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-up', 'py-down'])
+ self.assertMultilineMatches(bt,
+ r'''^.*
+#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
+ baz\(a, b, c\)
+#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
+ id\(42\)
+$''')
+
+class PyBtTests(DebuggerTests):
+ def test_basic_command(self):
+ 'Verify that the "py-bt" command works'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-bt'])
+ self.assertMultilineMatches(bt,
+ r'''^.*
+#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
+ baz\(a, b, c\)
+#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
+ bar\(a, b, c\)
+#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
+foo\(1, 2, 3\)
+''')
+
+class PyPrintTests(DebuggerTests):
+ def test_basic_command(self):
+ 'Verify that the "py-print" command works'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-print args'])
+ self.assertMultilineMatches(bt,
+ r".*\nlocal 'args' = \(1, 2, 3\)\n.*")
+
+ @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
+ def test_print_after_up(self):
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-up', 'py-print c', 'py-print b', 'py-print a'])
+ self.assertMultilineMatches(bt,
+ r".*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*")
+
+ def test_printing_global(self):
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-print __name__'])
+ self.assertMultilineMatches(bt,
+ r".*\nglobal '__name__' = '__main__'\n.*")
+
+ def test_printing_builtin(self):
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-print len'])
+ self.assertMultilineMatches(bt,
+ r".*\nbuiltin 'len' = <built-in method len of module object at remote 0x[0-9a-f]+>\n.*")
+
+class PyLocalsTests(DebuggerTests):
+ def test_basic_command(self):
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-locals'])
+ self.assertMultilineMatches(bt,
+ r".*\nargs = \(1, 2, 3\)\n.*")
+
+ @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
+ def test_locals_after_up(self):
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-up', 'py-locals'])
+ self.assertMultilineMatches(bt,
+ r".*\na = 1\nb = 2\nc = 3\n.*")
+
+def test_main():
+ if python_is_optimized():
+ raise unittest.SkipTest("Python was compiled with optimizations")
+ run_unittest(PrettyPrintTests,
+ PyListTests,
+ StackNavigationTests,
+ PyBtTests,
+ PyPrintTests,
+ PyLocalsTests
+ )
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 84028e8538..3ec209ba87 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -458,30 +458,30 @@ Subject: Re: PEP 255: Simple Generators
... else:
... break
A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M
-merged I into A
- A->A B->B C->C D->D E->E F->F G->G H->H I->A J->J K->K L->L M->M
-merged D into C
- A->A B->B C->C D->C E->E F->F G->G H->H I->A J->J K->K L->L M->M
-merged K into H
- A->A B->B C->C D->C E->E F->F G->G H->H I->A J->J K->H L->L M->M
-merged L into A
- A->A B->B C->C D->C E->E F->F G->G H->H I->A J->J K->H L->A M->M
-merged E into A
- A->A B->B C->C D->C E->A F->F G->G H->H I->A J->J K->H L->A M->M
-merged B into G
- A->A B->G C->C D->C E->A F->F G->G H->H I->A J->J K->H L->A M->M
+merged K into B
+ A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M
merged A into F
- A->F B->G C->C D->C E->F F->F G->G H->H I->F J->J K->H L->F M->M
-merged H into G
- A->F B->G C->C D->C E->F F->F G->G H->G I->F J->J K->G L->F M->M
-merged F into J
- A->J B->G C->C D->C E->J F->J G->G H->G I->J J->J K->G L->J M->M
+ A->F B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M
+merged E into F
+ A->F B->B C->C D->D E->F F->F G->G H->H I->I J->J K->B L->L M->M
+merged D into C
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->M
merged M into C
- A->J B->G C->C D->C E->J F->J G->G H->G I->J J->J K->G L->J M->C
-merged J into G
- A->G B->G C->C D->C E->G F->G G->G H->G I->G J->G K->G L->G M->C
-merged C into G
- A->G B->G C->G D->G E->G F->G G->G H->G I->G J->G K->G L->G M->G
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->C
+merged J into B
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->B K->B L->L M->C
+merged B into C
+ A->F B->C C->C D->C E->F F->F G->G H->H I->I J->C K->C L->L M->C
+merged F into G
+ A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->L M->C
+merged L into C
+ A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->C M->C
+merged G into I
+ A->I B->C C->C D->C E->I F->I G->I H->H I->I J->C K->C L->C M->C
+merged I into H
+ A->H B->C C->C D->C E->H F->H G->H H->H I->H J->C K->C L->C M->C
+merged C into H
+ A->H B->H C->H D->H E->H F->H G->H H->H I->H J->H K->H L->H M->H
"""
# Emacs turd '
@@ -960,11 +960,11 @@ Lambdas shouldn't have their usual return behavior.
# iterators have side-effects, so that which values *can* be generated at
# each slot depend on the values iterated at previous slots.
-def conjoin(gs):
+def simple_conjoin(gs):
values = [None] * len(gs)
- def gen(i, values=values):
+ def gen(i):
if i >= len(gs):
yield values
else:
@@ -989,7 +989,7 @@ def conjoin(gs):
# Do one loop nest at time recursively, until the # of loop nests
# remaining is divisible by 3.
- def gen(i, values=values):
+ def gen(i):
if i >= n:
yield values
@@ -1007,7 +1007,7 @@ def conjoin(gs):
# remain. Don't call directly: this is an internal optimization for
# gen's use.
- def _gen3(i, values=values):
+ def _gen3(i):
assert i < n and (n-i) % 3 == 0
ip1, ip2, ip3 = i+1, i+2, i+3
g, g1, g2 = gs[i : ip3]
diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py
index 089477c736..50638a1cf0 100644
--- a/Lib/test/test_genericpath.py
+++ b/Lib/test/test_genericpath.py
@@ -1,41 +1,112 @@
+"""
+Tests common to genericpath, macpath, ntpath and posixpath
+"""
+
import unittest
from test import support
import os
import genericpath
+import sys
+
+
+def safe_rmdir(dirname):
+ try:
+ os.rmdir(dirname)
+ except OSError:
+ pass
+
-class AllCommonTest(unittest.TestCase):
+class GenericTest(unittest.TestCase):
+ # The path module to be tested
+ pathmodule = genericpath
+ common_attributes = ['commonprefix', 'getsize', 'getatime', 'getctime',
+ 'getmtime', 'exists', 'isdir', 'isfile']
+ attributes = []
- def assertIs(self, a, b):
- self.assertTrue(a is b)
+ def test_no_argument(self):
+ for attr in self.common_attributes + self.attributes:
+ with self.assertRaises(TypeError):
+ getattr(self.pathmodule, attr)()
+ raise self.fail("{}.{}() did not raise a TypeError"
+ .format(self.pathmodule.__name__, attr))
def test_commonprefix(self):
+ commonprefix = self.pathmodule.commonprefix
self.assertEqual(
- genericpath.commonprefix([]),
+ commonprefix([]),
""
)
self.assertEqual(
- genericpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"]),
+ commonprefix(["/home/swenson/spam", "/home/swen/spam"]),
"/home/swen"
)
self.assertEqual(
- genericpath.commonprefix(["/home/swen/spam", "/home/swen/eggs"]),
+ commonprefix(["/home/swen/spam", "/home/swen/eggs"]),
"/home/swen/"
)
self.assertEqual(
- genericpath.commonprefix(["/home/swen/spam", "/home/swen/spam"]),
+ commonprefix(["/home/swen/spam", "/home/swen/spam"]),
"/home/swen/spam"
)
+ self.assertEqual(
+ commonprefix(["home:swenson:spam", "home:swen:spam"]),
+ "home:swen"
+ )
+ self.assertEqual(
+ commonprefix([":home:swen:spam", ":home:swen:eggs"]),
+ ":home:swen:"
+ )
+ self.assertEqual(
+ commonprefix([":home:swen:spam", ":home:swen:spam"]),
+ ":home:swen:spam"
+ )
+
+ self.assertEqual(
+ commonprefix([b"/home/swenson/spam", b"/home/swen/spam"]),
+ b"/home/swen"
+ )
+ self.assertEqual(
+ commonprefix([b"/home/swen/spam", b"/home/swen/eggs"]),
+ b"/home/swen/"
+ )
+ self.assertEqual(
+ commonprefix([b"/home/swen/spam", b"/home/swen/spam"]),
+ b"/home/swen/spam"
+ )
+ self.assertEqual(
+ commonprefix([b"home:swenson:spam", b"home:swen:spam"]),
+ b"home:swen"
+ )
+ self.assertEqual(
+ commonprefix([b":home:swen:spam", b":home:swen:eggs"]),
+ b":home:swen:"
+ )
+ self.assertEqual(
+ commonprefix([b":home:swen:spam", b":home:swen:spam"]),
+ b":home:swen:spam"
+ )
+
+ testlist = ['', 'abc', 'Xbcd', 'Xb', 'XY', 'abcd',
+ 'aXc', 'abd', 'ab', 'aX', 'abcX']
+ for s1 in testlist:
+ for s2 in testlist:
+ p = commonprefix([s1, s2])
+ self.assertTrue(s1.startswith(p))
+ self.assertTrue(s2.startswith(p))
+ if s1 != s2:
+ n = len(p)
+ self.assertNotEqual(s1[n:n+1], s2[n:n+1])
def test_getsize(self):
f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertEqual(genericpath.getsize(support.TESTFN), 3)
+ self.assertEqual(self.pathmodule.getsize(support.TESTFN), 3)
finally:
if not f.closed:
f.close()
- os.remove(support.TESTFN)
+ support.unlink(support.TESTFN)
def test_time(self):
f = open(support.TESTFN, "wb")
@@ -51,134 +122,187 @@ class AllCommonTest(unittest.TestCase):
self.assertEqual(d, b"foobar")
self.assertLessEqual(
- genericpath.getctime(support.TESTFN),
- genericpath.getmtime(support.TESTFN)
+ self.pathmodule.getctime(support.TESTFN),
+ self.pathmodule.getmtime(support.TESTFN)
)
finally:
if not f.closed:
f.close()
- os.remove(support.TESTFN)
+ support.unlink(support.TESTFN)
def test_exists(self):
- self.assertIs(genericpath.exists(support.TESTFN), False)
+ self.assertIs(self.pathmodule.exists(support.TESTFN), False)
f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(genericpath.exists(support.TESTFN), True)
+ self.assertIs(self.pathmodule.exists(support.TESTFN), True)
+ if not self.pathmodule == genericpath:
+ self.assertIs(self.pathmodule.lexists(support.TESTFN),
+ True)
finally:
if not f.close():
f.close()
- try:
- os.remove(support.TESTFN)
- except os.error:
- pass
-
- self.assertRaises(TypeError, genericpath.exists)
+ support.unlink(support.TESTFN)
def test_isdir(self):
- self.assertIs(genericpath.isdir(support.TESTFN), False)
+ self.assertIs(self.pathmodule.isdir(support.TESTFN), False)
f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(genericpath.isdir(support.TESTFN), False)
+ self.assertIs(self.pathmodule.isdir(support.TESTFN), False)
os.remove(support.TESTFN)
os.mkdir(support.TESTFN)
- self.assertIs(genericpath.isdir(support.TESTFN), True)
+ self.assertIs(self.pathmodule.isdir(support.TESTFN), True)
os.rmdir(support.TESTFN)
finally:
if not f.close():
f.close()
- try:
- os.remove(support.TESTFN)
- except os.error:
- pass
- try:
- os.rmdir(support.TESTFN)
- except os.error:
- pass
-
- self.assertRaises(TypeError, genericpath.isdir)
+ support.unlink(support.TESTFN)
+ safe_rmdir(support.TESTFN)
def test_isfile(self):
- self.assertIs(genericpath.isfile(support.TESTFN), False)
+ self.assertIs(self.pathmodule.isfile(support.TESTFN), False)
f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(genericpath.isfile(support.TESTFN), True)
+ self.assertIs(self.pathmodule.isfile(support.TESTFN), True)
os.remove(support.TESTFN)
os.mkdir(support.TESTFN)
- self.assertIs(genericpath.isfile(support.TESTFN), False)
+ self.assertIs(self.pathmodule.isfile(support.TESTFN), False)
os.rmdir(support.TESTFN)
finally:
if not f.close():
f.close()
- try:
- os.remove(support.TESTFN)
- except os.error:
- pass
- try:
- os.rmdir(support.TESTFN)
- except os.error:
- pass
-
- self.assertRaises(TypeError, genericpath.isdir)
-
- def test_samefile(self):
- f = open(support.TESTFN + "1", "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertIs(
- genericpath.samefile(
- support.TESTFN + "1",
- support.TESTFN + "1"
- ),
- True
- )
- # If we don't have links, assume that os.stat doesn't return resonable
- # inode information and thus, that samefile() doesn't work
- if hasattr(os, "symlink"):
- os.symlink(
- support.TESTFN + "1",
- support.TESTFN + "2"
- )
- self.assertIs(
- genericpath.samefile(
- support.TESTFN + "1",
- support.TESTFN + "2"
- ),
- True
- )
- os.remove(support.TESTFN + "2")
- f = open(support.TESTFN + "2", "wb")
- f.write(b"bar")
- f.close()
- self.assertIs(
- genericpath.samefile(
- support.TESTFN + "1",
- support.TESTFN + "2"
- ),
- False
- )
- finally:
- if not f.close():
- f.close()
- try:
- os.remove(support.TESTFN + "1")
- except os.error:
- pass
- try:
- os.remove(support.TESTFN + "2")
- except os.error:
- pass
-
- self.assertRaises(TypeError, genericpath.samefile)
+ support.unlink(support.TESTFN)
+ safe_rmdir(support.TESTFN)
+
+
+# Following TestCase is not supposed to be run from test_genericpath.
+# It is inherited by other test modules (macpath, ntpath, posixpath).
+
+class CommonTest(GenericTest):
+ # The path module to be tested
+ pathmodule = None
+ common_attributes = GenericTest.common_attributes + [
+ # Properties
+ 'curdir', 'pardir', 'extsep', 'sep',
+ 'pathsep', 'defpath', 'altsep', 'devnull',
+ # Methods
+ 'normcase', 'splitdrive', 'expandvars', 'normpath', 'abspath',
+ 'join', 'split', 'splitext', 'isabs', 'basename', 'dirname',
+ 'lexists', 'islink', 'ismount', 'expanduser', 'normpath', 'realpath',
+ ]
+
+ def test_normcase(self):
+ normcase = self.pathmodule.normcase
+ # check that normcase() is idempotent
+ for p in ["FoO/./BaR", b"FoO/./BaR"]:
+ p = normcase(p)
+ self.assertEqual(p, normcase(p))
+
+ self.assertEqual(normcase(''), '')
+ self.assertEqual(normcase(b''), b'')
+
+ # check that normcase raises a TypeError for invalid types
+ for path in (None, True, 0, 2.5, [], bytearray(b''), {'o','o'}):
+ self.assertRaises(TypeError, normcase, path)
+
+ def test_splitdrive(self):
+ # splitdrive for non-NT paths
+ splitdrive = self.pathmodule.splitdrive
+ self.assertEqual(splitdrive("/foo/bar"), ("", "/foo/bar"))
+ self.assertEqual(splitdrive("foo:bar"), ("", "foo:bar"))
+ self.assertEqual(splitdrive(":foo:bar"), ("", ":foo:bar"))
+
+ self.assertEqual(splitdrive(b"/foo/bar"), (b"", b"/foo/bar"))
+ self.assertEqual(splitdrive(b"foo:bar"), (b"", b"foo:bar"))
+ self.assertEqual(splitdrive(b":foo:bar"), (b"", b":foo:bar"))
+
+ def test_expandvars(self):
+ if self.pathmodule.__name__ == 'macpath':
+ self.skipTest('macpath.expandvars is a stub')
+ expandvars = self.pathmodule.expandvars
+ with support.EnvironmentVarGuard() as env:
+ env.clear()
+ env["foo"] = "bar"
+ env["{foo"] = "baz1"
+ env["{foo}"] = "baz2"
+ self.assertEqual(expandvars("foo"), "foo")
+ self.assertEqual(expandvars("$foo bar"), "bar bar")
+ self.assertEqual(expandvars("${foo}bar"), "barbar")
+ self.assertEqual(expandvars("$[foo]bar"), "$[foo]bar")
+ self.assertEqual(expandvars("$bar bar"), "$bar bar")
+ self.assertEqual(expandvars("$?bar"), "$?bar")
+ self.assertEqual(expandvars("${foo}bar"), "barbar")
+ self.assertEqual(expandvars("$foo}bar"), "bar}bar")
+ self.assertEqual(expandvars("${foo"), "${foo")
+ self.assertEqual(expandvars("${{foo}}"), "baz1}")
+ self.assertEqual(expandvars("$foo$foo"), "barbar")
+ self.assertEqual(expandvars("$bar$bar"), "$bar$bar")
+
+ self.assertEqual(expandvars(b"foo"), b"foo")
+ self.assertEqual(expandvars(b"$foo bar"), b"bar bar")
+ self.assertEqual(expandvars(b"${foo}bar"), b"barbar")
+ self.assertEqual(expandvars(b"$[foo]bar"), b"$[foo]bar")
+ self.assertEqual(expandvars(b"$bar bar"), b"$bar bar")
+ self.assertEqual(expandvars(b"$?bar"), b"$?bar")
+ self.assertEqual(expandvars(b"${foo}bar"), b"barbar")
+ self.assertEqual(expandvars(b"$foo}bar"), b"bar}bar")
+ self.assertEqual(expandvars(b"${foo"), b"${foo")
+ self.assertEqual(expandvars(b"${{foo}}"), b"baz1}")
+ self.assertEqual(expandvars(b"$foo$foo"), b"barbar")
+ self.assertEqual(expandvars(b"$bar$bar"), b"$bar$bar")
+
+ def test_abspath(self):
+ self.assertIn("foo", self.pathmodule.abspath("foo"))
+ self.assertIn(b"foo", self.pathmodule.abspath(b"foo"))
+
+ # Abspath returns bytes when the arg is bytes
+ for path in (b'', b'foo', b'f\xf2\xf2', b'/foo', b'C:\\'):
+ self.assertIsInstance(self.pathmodule.abspath(path), bytes)
+
+ def test_realpath(self):
+ self.assertIn("foo", self.pathmodule.realpath("foo"))
+ self.assertIn(b"foo", self.pathmodule.realpath(b"foo"))
+
+ def test_normpath_issue5827(self):
+ # Make sure normpath preserves unicode
+ for path in ('', '.', '/', '\\', '///foo/.//bar//'):
+ self.assertIsInstance(self.pathmodule.normpath(path), str)
+
+ def test_abspath_issue3426(self):
+ # Check that abspath returns unicode when the arg is unicode
+ # with both ASCII and non-ASCII cwds.
+ abspath = self.pathmodule.abspath
+ for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'):
+ self.assertIsInstance(abspath(path), str)
+
+ unicwd = '\xe7w\xf0'
+ try:
+ fsencoding = support.TESTFN_ENCODING or "ascii"
+ unicwd.encode(fsencoding)
+ except (AttributeError, UnicodeEncodeError):
+ # FS encoding is probably ASCII
+ pass
+ else:
+ with support.temp_cwd(unicwd):
+ for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'):
+ self.assertIsInstance(abspath(path), str)
+
+ @unittest.skipIf(sys.platform == 'darwin',
+ "Mac OS X denies the creation of a directory with an invalid utf8 name")
+ def test_nonascii_abspath(self):
+ # Test non-ASCII, non-UTF8 bytes in the path.
+ with support.temp_cwd(b'\xe7w\xf0'):
+ self.test_abspath()
+
def test_main():
- support.run_unittest(AllCommonTest)
+ support.run_unittest(GenericTest)
+
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index 1e88a34816..3d9c06a460 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -2,16 +2,6 @@ import unittest
from test import support
from _testcapi import getargs_keywords
-import warnings
-warnings.filterwarnings("ignore",
- category=DeprecationWarning,
- message=".*integer argument expected, got float",
- module=__name__)
-warnings.filterwarnings("ignore",
- category=DeprecationWarning,
- message=".*integer argument expected, got float",
- module="unittest")
-
"""
> How about the following counterproposal. This also changes some of
> the other format codes to be a little more regular.
@@ -48,17 +38,14 @@ LARGE = 0x7FFFFFFF
VERY_LARGE = 0xFF0000121212121212121242
from _testcapi import UCHAR_MAX, USHRT_MAX, UINT_MAX, ULONG_MAX, INT_MAX, \
- INT_MIN, LONG_MIN, LONG_MAX, PY_SSIZE_T_MIN, PY_SSIZE_T_MAX
+ INT_MIN, LONG_MIN, LONG_MAX, PY_SSIZE_T_MIN, PY_SSIZE_T_MAX, \
+ SHRT_MIN, SHRT_MAX
# fake, they are not defined in Python's header files
LLONG_MAX = 2**63-1
LLONG_MIN = -2**63
ULLONG_MAX = 2**64-1
-class Long:
- def __int__(self):
- return 99
-
class Int:
def __int__(self):
return 99
@@ -68,7 +55,6 @@ class Unsigned_TestCase(unittest.TestCase):
from _testcapi import getargs_b
# b returns 'unsigned char', and does range checking (0 ... UCHAR_MAX)
self.assertRaises(TypeError, getargs_b, 3.14)
- self.assertEqual(99, getargs_b(Long()))
self.assertEqual(99, getargs_b(Int()))
self.assertRaises(OverflowError, getargs_b, -1)
@@ -77,31 +63,26 @@ class Unsigned_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_b, UCHAR_MAX + 1)
self.assertEqual(42, getargs_b(42))
- self.assertEqual(42, getargs_b(42))
self.assertRaises(OverflowError, getargs_b, VERY_LARGE)
def test_B(self):
from _testcapi import getargs_B
# B returns 'unsigned char', no range checking
self.assertRaises(TypeError, getargs_B, 3.14)
- self.assertEqual(99, getargs_B(Long()))
self.assertEqual(99, getargs_B(Int()))
self.assertEqual(UCHAR_MAX, getargs_B(-1))
- self.assertEqual(UCHAR_MAX, getargs_B(-1))
self.assertEqual(0, getargs_B(0))
self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
self.assertEqual(0, getargs_B(UCHAR_MAX+1))
self.assertEqual(42, getargs_B(42))
- self.assertEqual(42, getargs_B(42))
self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
def test_H(self):
from _testcapi import getargs_H
# H returns 'unsigned short', no range checking
self.assertRaises(TypeError, getargs_H, 3.14)
- self.assertEqual(99, getargs_H(Long()))
self.assertEqual(99, getargs_H(Int()))
self.assertEqual(USHRT_MAX, getargs_H(-1))
@@ -110,7 +91,6 @@ class Unsigned_TestCase(unittest.TestCase):
self.assertEqual(0, getargs_H(USHRT_MAX+1))
self.assertEqual(42, getargs_H(42))
- self.assertEqual(42, getargs_H(42))
self.assertEqual(VERY_LARGE & USHRT_MAX, getargs_H(VERY_LARGE))
@@ -118,7 +98,6 @@ class Unsigned_TestCase(unittest.TestCase):
from _testcapi import getargs_I
# I returns 'unsigned int', no range checking
self.assertRaises(TypeError, getargs_I, 3.14)
- self.assertEqual(99, getargs_I(Long()))
self.assertEqual(99, getargs_I(Int()))
self.assertEqual(UINT_MAX, getargs_I(-1))
@@ -127,7 +106,6 @@ class Unsigned_TestCase(unittest.TestCase):
self.assertEqual(0, getargs_I(UINT_MAX+1))
self.assertEqual(42, getargs_I(42))
- self.assertEqual(42, getargs_I(42))
self.assertEqual(VERY_LARGE & UINT_MAX, getargs_I(VERY_LARGE))
@@ -136,7 +114,6 @@ class Unsigned_TestCase(unittest.TestCase):
# k returns 'unsigned long', no range checking
# it does not accept float, or instances with __int__
self.assertRaises(TypeError, getargs_k, 3.14)
- self.assertRaises(TypeError, getargs_k, Long())
self.assertRaises(TypeError, getargs_k, Int())
self.assertEqual(ULONG_MAX, getargs_k(-1))
@@ -145,16 +122,28 @@ class Unsigned_TestCase(unittest.TestCase):
self.assertEqual(0, getargs_k(ULONG_MAX+1))
self.assertEqual(42, getargs_k(42))
- self.assertEqual(42, getargs_k(42))
self.assertEqual(VERY_LARGE & ULONG_MAX, getargs_k(VERY_LARGE))
class Signed_TestCase(unittest.TestCase):
+ def test_h(self):
+ from _testcapi import getargs_h
+ # h returns 'short', and does range checking (SHRT_MIN ... SHRT_MAX)
+ self.assertRaises(TypeError, getargs_h, 3.14)
+ self.assertEqual(99, getargs_h(Int()))
+
+ self.assertRaises(OverflowError, getargs_h, SHRT_MIN-1)
+ self.assertEqual(SHRT_MIN, getargs_h(SHRT_MIN))
+ self.assertEqual(SHRT_MAX, getargs_h(SHRT_MAX))
+ self.assertRaises(OverflowError, getargs_h, SHRT_MAX+1)
+
+ self.assertEqual(42, getargs_h(42))
+ self.assertRaises(OverflowError, getargs_h, VERY_LARGE)
+
def test_i(self):
from _testcapi import getargs_i
# i returns 'int', and does range checking (INT_MIN ... INT_MAX)
self.assertRaises(TypeError, getargs_i, 3.14)
- self.assertEqual(99, getargs_i(Long()))
self.assertEqual(99, getargs_i(Int()))
self.assertRaises(OverflowError, getargs_i, INT_MIN-1)
@@ -163,14 +152,12 @@ class Signed_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_i, INT_MAX+1)
self.assertEqual(42, getargs_i(42))
- self.assertEqual(42, getargs_i(42))
self.assertRaises(OverflowError, getargs_i, VERY_LARGE)
def test_l(self):
from _testcapi import getargs_l
# l returns 'long', and does range checking (LONG_MIN ... LONG_MAX)
self.assertRaises(TypeError, getargs_l, 3.14)
- self.assertEqual(99, getargs_l(Long()))
self.assertEqual(99, getargs_l(Int()))
self.assertRaises(OverflowError, getargs_l, LONG_MIN-1)
@@ -179,7 +166,6 @@ class Signed_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_l, LONG_MAX+1)
self.assertEqual(42, getargs_l(42))
- self.assertEqual(42, getargs_l(42))
self.assertRaises(OverflowError, getargs_l, VERY_LARGE)
def test_n(self):
@@ -187,7 +173,6 @@ class Signed_TestCase(unittest.TestCase):
# n returns 'Py_ssize_t', and does range checking
# (PY_SSIZE_T_MIN ... PY_SSIZE_T_MAX)
self.assertRaises(TypeError, getargs_n, 3.14)
- self.assertRaises(TypeError, getargs_n, Long())
self.assertRaises(TypeError, getargs_n, Int())
self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN-1)
@@ -196,17 +181,16 @@ class Signed_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MAX+1)
self.assertEqual(42, getargs_n(42))
- self.assertEqual(42, getargs_n(42))
self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
class LongLong_TestCase(unittest.TestCase):
def test_L(self):
from _testcapi import getargs_L
- # L returns 'long long', and does range checking (LLONG_MIN ... LLONG_MAX)
+ # L returns 'long long', and does range checking (LLONG_MIN
+ # ... LLONG_MAX)
+ self.assertRaises(TypeError, getargs_L, 3.14)
self.assertRaises(TypeError, getargs_L, "Hello")
- self.assertEqual(3, getargs_L(3.14))
- self.assertEqual(99, getargs_L(Long()))
self.assertEqual(99, getargs_L(Int()))
self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1)
@@ -215,21 +199,18 @@ class LongLong_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_L, LLONG_MAX+1)
self.assertEqual(42, getargs_L(42))
- self.assertEqual(42, getargs_L(42))
self.assertRaises(OverflowError, getargs_L, VERY_LARGE)
def test_K(self):
from _testcapi import getargs_K
# K return 'unsigned long long', no range checking
self.assertRaises(TypeError, getargs_K, 3.14)
- self.assertRaises(TypeError, getargs_K, Long())
self.assertRaises(TypeError, getargs_K, Int())
self.assertEqual(ULLONG_MAX, getargs_K(ULLONG_MAX))
self.assertEqual(0, getargs_K(0))
self.assertEqual(0, getargs_K(ULLONG_MAX+1))
self.assertEqual(42, getargs_K(42))
- self.assertEqual(42, getargs_K(42))
self.assertEqual(VERY_LARGE & ULLONG_MAX, getargs_K(VERY_LARGE))
@@ -256,24 +237,28 @@ class Keywords_TestCase(unittest.TestCase):
getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), 10),
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
)
+
def test_mixed_args(self):
# positional and keyword args
self.assertEqual(
getargs_keywords((1,2), 3, (4,(5,6)), arg4=(7,8,9), arg5=10),
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
)
+
def test_keyword_args(self):
# all keywords
self.assertEqual(
getargs_keywords(arg1=(1,2), arg2=3, arg3=(4,(5,6)), arg4=(7,8,9), arg5=10),
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
)
+
def test_optional_args(self):
# missing optional keyword args, skipping tuples
self.assertEqual(
getargs_keywords(arg1=(1,2), arg2=3, arg5=10),
(1, 2, 3, -1, -1, -1, -1, -1, -1, 10)
)
+
def test_required_args(self):
# required arg missing
try:
@@ -282,6 +267,7 @@ class Keywords_TestCase(unittest.TestCase):
self.assertEqual(str(err), "Required argument 'arg2' (pos 2) not found")
else:
self.fail('TypeError should have been raised')
+
def test_too_many_args(self):
try:
getargs_keywords((1,2),3,(4,(5,6)),(7,8,9),10,111)
@@ -289,6 +275,7 @@ class Keywords_TestCase(unittest.TestCase):
self.assertEqual(str(err), "function takes at most 5 arguments (6 given)")
else:
self.fail('TypeError should have been raised')
+
def test_invalid_keyword(self):
# extraneous keyword arg
try:
@@ -298,8 +285,156 @@ class Keywords_TestCase(unittest.TestCase):
else:
self.fail('TypeError should have been raised')
+ def test_surrogate_keyword(self):
+ try:
+ getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), **{'\uDC80': 10})
+ except TypeError as err:
+ self.assertEqual(str(err), "'\udc80' is an invalid keyword argument for this function")
+ else:
+ self.fail('TypeError should have been raised')
+
+class Bytes_TestCase(unittest.TestCase):
+ def test_s(self):
+ from _testcapi import getargs_s
+ self.assertEqual(getargs_s('abc\xe9'), b'abc\xc3\xa9')
+ self.assertRaises(TypeError, getargs_s, 'nul:\0')
+ self.assertRaises(TypeError, getargs_s, b'bytes')
+ self.assertRaises(TypeError, getargs_s, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_s, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_s, None)
+
+ def test_s_star(self):
+ from _testcapi import getargs_s_star
+ self.assertEqual(getargs_s_star('abc\xe9'), b'abc\xc3\xa9')
+ self.assertEqual(getargs_s_star('nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_s_star(b'bytes'), b'bytes')
+ self.assertEqual(getargs_s_star(bytearray(b'bytearray')), b'bytearray')
+ self.assertEqual(getargs_s_star(memoryview(b'memoryview')), b'memoryview')
+ self.assertRaises(TypeError, getargs_s_star, None)
+
+ def test_s_hash(self):
+ from _testcapi import getargs_s_hash
+ self.assertEqual(getargs_s_hash('abc\xe9'), b'abc\xc3\xa9')
+ self.assertEqual(getargs_s_hash('nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_s_hash(b'bytes'), b'bytes')
+ self.assertRaises(TypeError, getargs_s_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_s_hash, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_s_hash, None)
+
+ def test_z(self):
+ from _testcapi import getargs_z
+ self.assertEqual(getargs_z('abc\xe9'), b'abc\xc3\xa9')
+ self.assertRaises(TypeError, getargs_z, 'nul:\0')
+ self.assertRaises(TypeError, getargs_z, b'bytes')
+ self.assertRaises(TypeError, getargs_z, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_z, memoryview(b'memoryview'))
+ self.assertIsNone(getargs_z(None))
+
+ def test_z_star(self):
+ from _testcapi import getargs_z_star
+ self.assertEqual(getargs_z_star('abc\xe9'), b'abc\xc3\xa9')
+ self.assertEqual(getargs_z_star('nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_z_star(b'bytes'), b'bytes')
+ self.assertEqual(getargs_z_star(bytearray(b'bytearray')), b'bytearray')
+ self.assertEqual(getargs_z_star(memoryview(b'memoryview')), b'memoryview')
+ self.assertIsNone(getargs_z_star(None))
+
+ def test_z_hash(self):
+ from _testcapi import getargs_z_hash
+ self.assertEqual(getargs_z_hash('abc\xe9'), b'abc\xc3\xa9')
+ self.assertEqual(getargs_z_hash('nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_z_hash(b'bytes'), b'bytes')
+ self.assertRaises(TypeError, getargs_z_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_z_hash, memoryview(b'memoryview'))
+ self.assertIsNone(getargs_z_hash(None))
+
+ def test_y(self):
+ from _testcapi import getargs_y
+ self.assertRaises(TypeError, getargs_y, 'abc\xe9')
+ self.assertEqual(getargs_y(b'bytes'), b'bytes')
+ self.assertRaises(TypeError, getargs_y, b'nul:\0')
+ self.assertRaises(TypeError, getargs_y, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_y, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_y, None)
+
+ def test_y_star(self):
+ from _testcapi import getargs_y_star
+ self.assertRaises(TypeError, getargs_y_star, 'abc\xe9')
+ self.assertEqual(getargs_y_star(b'bytes'), b'bytes')
+ self.assertEqual(getargs_y_star(b'nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_y_star(bytearray(b'bytearray')), b'bytearray')
+ self.assertEqual(getargs_y_star(memoryview(b'memoryview')), b'memoryview')
+ self.assertRaises(TypeError, getargs_y_star, None)
+
+ def test_y_hash(self):
+ from _testcapi import getargs_y_hash
+ self.assertRaises(TypeError, getargs_y_hash, 'abc\xe9')
+ self.assertEqual(getargs_y_hash(b'bytes'), b'bytes')
+ self.assertEqual(getargs_y_hash(b'nul:\0'), b'nul:\0')
+ self.assertRaises(TypeError, getargs_y_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_y_hash, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_y_hash, None)
+
+ def test_w_star(self):
+ # getargs_w_star() modifies first and last byte
+ from _testcapi import getargs_w_star
+ self.assertRaises(TypeError, getargs_w_star, 'abc\xe9')
+ self.assertRaises(TypeError, getargs_w_star, b'bytes')
+ self.assertRaises(TypeError, getargs_w_star, b'nul:\0')
+ self.assertRaises(TypeError, getargs_w_star, memoryview(b'bytes'))
+ self.assertEqual(getargs_w_star(bytearray(b'bytearray')), b'[ytearra]')
+ self.assertEqual(getargs_w_star(memoryview(bytearray(b'memoryview'))),
+ b'[emoryvie]')
+ self.assertRaises(TypeError, getargs_w_star, None)
+
+
+class Unicode_TestCase(unittest.TestCase):
+ def test_u(self):
+ from _testcapi import getargs_u
+ self.assertEqual(getargs_u('abc\xe9'), 'abc\xe9')
+ self.assertRaises(TypeError, getargs_u, 'nul:\0')
+ self.assertRaises(TypeError, getargs_u, b'bytes')
+ self.assertRaises(TypeError, getargs_u, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_u, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_u, None)
+
+ def test_u_hash(self):
+ from _testcapi import getargs_u_hash
+ self.assertEqual(getargs_u_hash('abc\xe9'), 'abc\xe9')
+ self.assertEqual(getargs_u_hash('nul:\0'), 'nul:\0')
+ self.assertRaises(TypeError, getargs_u_hash, b'bytes')
+ self.assertRaises(TypeError, getargs_u_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_u_hash, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_u_hash, None)
+
+ def test_Z(self):
+ from _testcapi import getargs_Z
+ self.assertEqual(getargs_Z('abc\xe9'), 'abc\xe9')
+ self.assertRaises(TypeError, getargs_Z, 'nul:\0')
+ self.assertRaises(TypeError, getargs_Z, b'bytes')
+ self.assertRaises(TypeError, getargs_Z, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_Z, memoryview(b'memoryview'))
+ self.assertIsNone(getargs_Z(None))
+
+ def test_Z_hash(self):
+ from _testcapi import getargs_Z_hash
+ self.assertEqual(getargs_Z_hash('abc\xe9'), 'abc\xe9')
+ self.assertEqual(getargs_Z_hash('nul:\0'), 'nul:\0')
+ self.assertRaises(TypeError, getargs_Z_hash, b'bytes')
+ self.assertRaises(TypeError, getargs_Z_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_Z_hash, memoryview(b'memoryview'))
+ self.assertIsNone(getargs_Z_hash(None))
+
+
def test_main():
- tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase, Keywords_TestCase]
+ tests = [
+ Signed_TestCase,
+ Unsigned_TestCase,
+ Tuple_TestCase,
+ Keywords_TestCase,
+ Bytes_TestCase,
+ Unicode_TestCase,
+ ]
try:
from _testcapi import getargs_L, getargs_K
except ImportError:
diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py
index 0f47fcb38d..fa5701f310 100644
--- a/Lib/test/test_getopt.py
+++ b/Lib/test/test_getopt.py
@@ -5,7 +5,6 @@ from test.support import verbose, run_doctest, run_unittest, EnvironmentVarGuard
import unittest
import getopt
-import os
sentinel = object()
diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py
index f92d30480c..1560a6bbf0 100644
--- a/Lib/test/test_glob.py
+++ b/Lib/test/test_glob.py
@@ -1,5 +1,5 @@
import unittest
-from test.support import run_unittest, TESTFN
+from test.support import run_unittest, TESTFN, skip_unless_symlink, can_symlink
import glob
import os
import shutil
@@ -25,7 +25,7 @@ class GlobTests(unittest.TestCase):
self.mktemp('ZZZ')
self.mktemp('a', 'bcd', 'EF')
self.mktemp('a', 'bcd', 'efg', 'ha')
- if hasattr(os, 'symlink'):
+ if can_symlink():
os.symlink(self.norm('broken'), self.norm('sym1'))
os.symlink(self.norm('broken'), self.norm('sym2'))
@@ -96,14 +96,14 @@ class GlobTests(unittest.TestCase):
res = glob.glob(self.tempdir + '*' + os.sep)
self.assertEqual(len(res), 1)
# either of these results are reasonable
- self.assertTrue(res[0] in [self.tempdir, self.tempdir + os.sep])
+ self.assertIn(res[0], [self.tempdir, self.tempdir + os.sep])
+ @skip_unless_symlink
def test_glob_broken_symlinks(self):
- if hasattr(os, 'symlink'):
- eq = self.assertSequencesEqual_noorder
- eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2')])
- eq(self.glob('sym1'), [self.norm('sym1')])
- eq(self.glob('sym2'), [self.norm('sym2')])
+ eq = self.assertSequencesEqual_noorder
+ eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2')])
+ eq(self.glob('sym1'), [self.norm('sym1')])
+ eq(self.glob('sym2'), [self.norm('sym2')])
def test_main():
diff --git a/Lib/test/test_global.py b/Lib/test/test_global.py
index 823f2c544d..37ec67255a 100644
--- a/Lib/test/test_global.py
+++ b/Lib/test/test_global.py
@@ -1,13 +1,21 @@
"""Verify that warnings are issued for global statements following use."""
-from test.support import run_unittest, check_syntax_error
+from test.support import run_unittest, check_syntax_error, check_warnings
import unittest
-
import warnings
-warnings.filterwarnings("error", module="<test string>")
+
class GlobalTests(unittest.TestCase):
+ def setUp(self):
+ self._warnings_manager = check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings("error", module="<test string>")
+
+ def tearDown(self):
+ self._warnings_manager.__exit__(None, None, None)
+
+
def test1(self):
prog_text_1 = """\
def wrong1():
@@ -45,7 +53,9 @@ x = 2
def test_main():
- run_unittest(GlobalTests)
+ with warnings.catch_warnings():
+ warnings.filterwarnings("error", module="<test string>")
+ run_unittest(GlobalTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index df224fd330..329b25807f 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -1,19 +1,13 @@
# Python test set -- part 1, grammar.
# This just tests whether the parser accepts them all.
-# NOTE: When you run this test as a script from the command line, you
-# get warnings about certain hex/oct constants. Since those are
-# issued by the parser, you can't suppress them by adding a
-# filterwarnings() call to this module. Therefore, to shut up the
-# regression test, the filterwarnings() call has been added to
-# regrtest.py.
-
from test.support import run_unittest, check_syntax_error
import unittest
import sys
# testing import *
from sys import *
+
class TokenTests(unittest.TestCase):
def testBackslash(self):
@@ -307,12 +301,12 @@ class GrammarTests(unittest.TestCase):
self.assertEqual(f.__annotations__, {'b': 1, 'c': 2})
def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass
self.assertEqual(f.__annotations__,
- {'b': 1, 'c': 2, 'e': 3, 'g': 6})
+ {'b': 1, 'c': 2, 'e': 3, 'g': 6})
def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10,
**k:11) -> 12: pass
self.assertEqual(f.__annotations__,
- {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
- 'k': 11, 'return': 12})
+ {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
+ 'k': 11, 'return': 12})
# Check for SF Bug #1697248 - mixing decorators and a return annotation
def null(x): return x
@null
@@ -915,6 +909,14 @@ class GrammarTests(unittest.TestCase):
self.assertEqual((6 / 2 if 1 else 3), 3)
self.assertEqual((6 < 4 if 0 else 2), 2)
+ def test_paren_evaluation(self):
+ self.assertEqual(16 // (4 // 2), 8)
+ self.assertEqual((16 // 4) // 2, 2)
+ self.assertEqual(16 // 4 // 2, 2)
+ self.assertTrue(False is (2 is 3))
+ self.assertFalse((False is 2) is 3)
+ self.assertFalse(False is 2 is 3)
+
def test_main():
run_unittest(TokenTests, GrammarTests)
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index 8acc97c638..04a8af6ac9 100755..100644
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -12,13 +12,13 @@ class GroupDatabaseTestCase(unittest.TestCase):
# attributes promised by the docs
self.assertEqual(len(value), 4)
self.assertEqual(value[0], value.gr_name)
- self.assertTrue(isinstance(value.gr_name, str))
+ self.assertIsInstance(value.gr_name, str)
self.assertEqual(value[1], value.gr_passwd)
- self.assertTrue(isinstance(value.gr_passwd, str))
+ self.assertIsInstance(value.gr_passwd, str)
self.assertEqual(value[2], value.gr_gid)
- self.assertTrue(isinstance(value.gr_gid, int))
+ self.assertIsInstance(value.gr_gid, int)
self.assertEqual(value[3], value.gr_mem)
- self.assertTrue(isinstance(value.gr_mem, list))
+ self.assertIsInstance(value.gr_mem, list)
def test_values(self):
entries = grp.getgrall()
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py
index b9923840e1..2b0ac36c23 100644
--- a/Lib/test/test_gzip.py
+++ b/Lib/test/test_gzip.py
@@ -1,13 +1,13 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test script for the gzip module.
"""
import unittest
from test import support
import os
-import gzip
+import io
import struct
-
+gzip = support.import_module('gzip')
data1 = b""" int length=DEFAULTALLOC, err = Z_OK;
PyObject *RetVal;
@@ -22,6 +22,17 @@ data2 = b"""/* zlibmodule.c -- gzip-compatible data compression */
"""
+class UnseekableIO(io.BytesIO):
+ def seekable(self):
+ return False
+
+ def tell(self):
+ raise io.UnsupportedOperation
+
+ def seek(self, *args):
+ raise io.UnsupportedOperation
+
+
class TestGzip(unittest.TestCase):
filename = support.TESTFN
@@ -33,14 +44,15 @@ class TestGzip(unittest.TestCase):
def test_write(self):
- f = gzip.GzipFile(self.filename, 'wb') ; f.write(data1 * 50)
+ with gzip.GzipFile(self.filename, 'wb') as f:
+ f.write(data1 * 50)
- # Try flush and fileno.
- f.flush()
- f.fileno()
- if hasattr(os, 'fsync'):
- os.fsync(f.fileno())
- f.close()
+ # Try flush and fileno.
+ f.flush()
+ f.fileno()
+ if hasattr(os, 'fsync'):
+ os.fsync(f.fileno())
+ f.close()
# Test multiple close() calls.
f.close()
@@ -48,7 +60,8 @@ class TestGzip(unittest.TestCase):
def test_read(self):
self.test_write()
# Try reading.
- f = gzip.GzipFile(self.filename, 'r') ; d = f.read() ; f.close()
+ with gzip.GzipFile(self.filename, 'r') as f:
+ d = f.read()
self.assertEqual(d, data1*50)
def test_io_on_closed_object(self):
@@ -76,173 +89,174 @@ class TestGzip(unittest.TestCase):
def test_append(self):
self.test_write()
# Append to the previous file
- f = gzip.GzipFile(self.filename, 'ab') ; f.write(data2 * 15) ; f.close()
+ with gzip.GzipFile(self.filename, 'ab') as f:
+ f.write(data2 * 15)
- f = gzip.GzipFile(self.filename, 'rb') ; d = f.read() ; f.close()
+ with gzip.GzipFile(self.filename, 'rb') as f:
+ d = f.read()
self.assertEqual(d, (data1*50) + (data2*15))
def test_many_append(self):
# Bug #1074261 was triggered when reading a file that contained
# many, many members. Create such a file and verify that reading it
# works.
- f = gzip.open(self.filename, 'wb', 9)
- f.write(b'a')
- f.close()
- for i in range(0, 200):
- f = gzip.open(self.filename, "ab", 9) # append
+ with gzip.open(self.filename, 'wb', 9) as f:
f.write(b'a')
- f.close()
+ for i in range(0, 200):
+ with gzip.open(self.filename, "ab", 9) as f: # append
+ f.write(b'a')
# Try reading the file
- zgfile = gzip.open(self.filename, "rb")
- contents = b""
- while 1:
- ztxt = zgfile.read(8192)
- contents += ztxt
- if not ztxt: break
- zgfile.close()
+ with gzip.open(self.filename, "rb") as zgfile:
+ contents = b""
+ while 1:
+ ztxt = zgfile.read(8192)
+ contents += ztxt
+ if not ztxt: break
self.assertEqual(contents, b'a'*201)
+ def test_buffered_reader(self):
+ # Issue #7471: a GzipFile can be wrapped in a BufferedReader for
+ # performance.
+ self.test_write()
+
+ with gzip.GzipFile(self.filename, 'rb') as f:
+ with io.BufferedReader(f) as r:
+ lines = [line for line in r]
+
+ self.assertEqual(lines, 50 * data1.splitlines(True))
def test_readline(self):
self.test_write()
# Try .readline() with varying line lengths
- f = gzip.GzipFile(self.filename, 'rb')
- line_length = 0
- while 1:
- L = f.readline(line_length)
- if not L and line_length != 0: break
- self.assertTrue(len(L) <= line_length)
- line_length = (line_length + 1) % 50
- f.close()
+ with gzip.GzipFile(self.filename, 'rb') as f:
+ line_length = 0
+ while 1:
+ L = f.readline(line_length)
+ if not L and line_length != 0: break
+ self.assertTrue(len(L) <= line_length)
+ line_length = (line_length + 1) % 50
def test_readlines(self):
self.test_write()
# Try .readlines()
- f = gzip.GzipFile(self.filename, 'rb')
- L = f.readlines()
- f.close()
+ with gzip.GzipFile(self.filename, 'rb') as f:
+ L = f.readlines()
- f = gzip.GzipFile(self.filename, 'rb')
- while 1:
- L = f.readlines(150)
- if L == []: break
- f.close()
+ with gzip.GzipFile(self.filename, 'rb') as f:
+ while 1:
+ L = f.readlines(150)
+ if L == []: break
def test_seek_read(self):
self.test_write()
# Try seek, read test
- f = gzip.GzipFile(self.filename)
- while 1:
- oldpos = f.tell()
- line1 = f.readline()
- if not line1: break
- newpos = f.tell()
- f.seek(oldpos) # negative seek
- if len(line1)>10:
- amount = 10
- else:
- amount = len(line1)
- line2 = f.read(amount)
- self.assertEqual(line1[:amount], line2)
- f.seek(newpos) # positive seek
- f.close()
+ with gzip.GzipFile(self.filename) as f:
+ while 1:
+ oldpos = f.tell()
+ line1 = f.readline()
+ if not line1: break
+ newpos = f.tell()
+ f.seek(oldpos) # negative seek
+ if len(line1)>10:
+ amount = 10
+ else:
+ amount = len(line1)
+ line2 = f.read(amount)
+ self.assertEqual(line1[:amount], line2)
+ f.seek(newpos) # positive seek
def test_seek_whence(self):
self.test_write()
# Try seek(whence=1), read test
- f = gzip.GzipFile(self.filename)
- f.read(10)
- f.seek(10, whence=1)
- y = f.read(10)
- f.close()
+ with gzip.GzipFile(self.filename) as f:
+ f.read(10)
+ f.seek(10, whence=1)
+ y = f.read(10)
self.assertEqual(y, data1[20:30])
def test_seek_write(self):
# Try seek, write test
- f = gzip.GzipFile(self.filename, 'w')
- for pos in range(0, 256, 16):
- f.seek(pos)
- f.write(b'GZ\n')
- f.close()
+ with gzip.GzipFile(self.filename, 'w') as f:
+ for pos in range(0, 256, 16):
+ f.seek(pos)
+ f.write(b'GZ\n')
def test_mode(self):
self.test_write()
- f = gzip.GzipFile(self.filename, 'r')
- self.assertEqual(f.myfileobj.mode, 'rb')
- f.close()
+ with gzip.GzipFile(self.filename, 'r') as f:
+ self.assertEqual(f.myfileobj.mode, 'rb')
def test_1647484(self):
for mode in ('wb', 'rb'):
- f = gzip.GzipFile(self.filename, mode)
- self.assertTrue(hasattr(f, "name"))
- self.assertEqual(f.name, self.filename)
- f.close()
+ with gzip.GzipFile(self.filename, mode) as f:
+ self.assertTrue(hasattr(f, "name"))
+ self.assertEqual(f.name, self.filename)
+
+ def test_paddedfile_getattr(self):
+ self.test_write()
+ with gzip.GzipFile(self.filename, 'rb') as f:
+ self.assertTrue(hasattr(f.fileobj, "name"))
+ self.assertEqual(f.fileobj.name, self.filename)
def test_mtime(self):
mtime = 123456789
- fWrite = gzip.GzipFile(self.filename, 'w', mtime = mtime)
- fWrite.write(data1)
- fWrite.close()
- fRead = gzip.GzipFile(self.filename)
- dataRead = fRead.read()
- self.assertEqual(dataRead, data1)
- self.assertTrue(hasattr(fRead, 'mtime'))
- self.assertEqual(fRead.mtime, mtime)
- fRead.close()
+ with gzip.GzipFile(self.filename, 'w', mtime = mtime) as fWrite:
+ fWrite.write(data1)
+ with gzip.GzipFile(self.filename) as fRead:
+ dataRead = fRead.read()
+ self.assertEqual(dataRead, data1)
+ self.assertTrue(hasattr(fRead, 'mtime'))
+ self.assertEqual(fRead.mtime, mtime)
def test_metadata(self):
mtime = 123456789
- fWrite = gzip.GzipFile(self.filename, 'w', mtime = mtime)
- fWrite.write(data1)
- fWrite.close()
-
- fRead = open(self.filename, 'rb')
+ with gzip.GzipFile(self.filename, 'w', mtime = mtime) as fWrite:
+ fWrite.write(data1)
- # see RFC 1952: http://www.faqs.org/rfcs/rfc1952.html
+ with open(self.filename, 'rb') as fRead:
+ # see RFC 1952: http://www.faqs.org/rfcs/rfc1952.html
- idBytes = fRead.read(2)
- self.assertEqual(idBytes, b'\x1f\x8b') # gzip ID
+ idBytes = fRead.read(2)
+ self.assertEqual(idBytes, b'\x1f\x8b') # gzip ID
- cmByte = fRead.read(1)
- self.assertEqual(cmByte, b'\x08') # deflate
+ cmByte = fRead.read(1)
+ self.assertEqual(cmByte, b'\x08') # deflate
- flagsByte = fRead.read(1)
- self.assertEqual(flagsByte, b'\x08') # only the FNAME flag is set
+ flagsByte = fRead.read(1)
+ self.assertEqual(flagsByte, b'\x08') # only the FNAME flag is set
- mtimeBytes = fRead.read(4)
- self.assertEqual(mtimeBytes, struct.pack('<i', mtime)) # little-endian
+ mtimeBytes = fRead.read(4)
+ self.assertEqual(mtimeBytes, struct.pack('<i', mtime)) # little-endian
- xflByte = fRead.read(1)
- self.assertEqual(xflByte, b'\x02') # maximum compression
+ xflByte = fRead.read(1)
+ self.assertEqual(xflByte, b'\x02') # maximum compression
- osByte = fRead.read(1)
- self.assertEqual(osByte, b'\xff') # OS "unknown" (OS-independent)
+ osByte = fRead.read(1)
+ self.assertEqual(osByte, b'\xff') # OS "unknown" (OS-independent)
- # Since the FNAME flag is set, the zero-terminated filename follows.
- # RFC 1952 specifies that this is the name of the input file, if any.
- # However, the gzip module defaults to storing the name of the output
- # file in this field.
- expected = self.filename.encode('Latin-1') + b'\x00'
- nameBytes = fRead.read(len(expected))
- self.assertEqual(nameBytes, expected)
+ # Since the FNAME flag is set, the zero-terminated filename follows.
+ # RFC 1952 specifies that this is the name of the input file, if any.
+ # However, the gzip module defaults to storing the name of the output
+ # file in this field.
+ expected = self.filename.encode('Latin-1') + b'\x00'
+ nameBytes = fRead.read(len(expected))
+ self.assertEqual(nameBytes, expected)
- # Since no other flags were set, the header ends here.
- # Rather than process the compressed data, let's seek to the trailer.
- fRead.seek(os.stat(self.filename).st_size - 8)
+ # Since no other flags were set, the header ends here.
+ # Rather than process the compressed data, let's seek to the trailer.
+ fRead.seek(os.stat(self.filename).st_size - 8)
- crc32Bytes = fRead.read(4) # CRC32 of uncompressed data [data1]
- self.assertEqual(crc32Bytes, b'\xaf\xd7d\x83')
+ crc32Bytes = fRead.read(4) # CRC32 of uncompressed data [data1]
+ self.assertEqual(crc32Bytes, b'\xaf\xd7d\x83')
- isizeBytes = fRead.read(4)
- self.assertEqual(isizeBytes, struct.pack('<i', len(data1)))
-
- fRead.close()
+ isizeBytes = fRead.read(4)
+ self.assertEqual(isizeBytes, struct.pack('<i', len(data1)))
def test_with_open(self):
# GzipFile supports the context management protocol
@@ -265,6 +279,70 @@ class TestGzip(unittest.TestCase):
else:
self.fail("1/0 didn't raise an exception")
+ def test_zero_padded_file(self):
+ with gzip.GzipFile(self.filename, "wb") as f:
+ f.write(data1 * 50)
+
+ # Pad the file with zeroes
+ with open(self.filename, "ab") as f:
+ f.write(b"\x00" * 50)
+
+ with gzip.GzipFile(self.filename, "rb") as f:
+ d = f.read()
+ self.assertEqual(d, data1 * 50, "Incorrect data in file")
+
+ def test_non_seekable_file(self):
+ uncompressed = data1 * 50
+ buf = UnseekableIO()
+ with gzip.GzipFile(fileobj=buf, mode="wb") as f:
+ f.write(uncompressed)
+ compressed = buf.getvalue()
+ buf = UnseekableIO(compressed)
+ with gzip.GzipFile(fileobj=buf, mode="rb") as f:
+ self.assertEqual(f.read(), uncompressed)
+
+ def test_peek(self):
+ uncompressed = data1 * 200
+ with gzip.GzipFile(self.filename, "wb") as f:
+ f.write(uncompressed)
+
+ def sizes():
+ while True:
+ for n in range(5, 50, 10):
+ yield n
+
+ with gzip.GzipFile(self.filename, "rb") as f:
+ f.max_read_chunk = 33
+ nread = 0
+ for n in sizes():
+ s = f.peek(n)
+ if s == b'':
+ break
+ self.assertEqual(f.read(len(s)), s)
+ nread += len(s)
+ self.assertEqual(f.read(100), b'')
+ self.assertEqual(nread, len(uncompressed))
+
+ # Testing compress/decompress shortcut functions
+
+ def test_compress(self):
+ for data in [data1, data2]:
+ for args in [(), (1,), (6,), (9,)]:
+ datac = gzip.compress(data, *args)
+ self.assertEqual(type(datac), bytes)
+ with gzip.GzipFile(fileobj=io.BytesIO(datac), mode="rb") as f:
+ self.assertEqual(f.read(), data)
+
+ def test_decompress(self):
+ for data in (data1, data2):
+ buf = io.BytesIO()
+ with gzip.GzipFile(fileobj=buf, mode="wb") as f:
+ f.write(data)
+ self.assertEqual(gzip.decompress(buf.getvalue()), data)
+ # Roundtrip with compress
+ datac = gzip.compress(data)
+ self.assertEqual(gzip.decompress(datac), data)
+
def test_main(verbose=None):
support.run_unittest(TestGzip)
diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py
index 569e5e054c..fea1025e91 100644
--- a/Lib/test/test_hash.py
+++ b/Lib/test/test_hash.py
@@ -91,11 +91,11 @@ class HashInheritanceTestCase(unittest.TestCase):
objects = (self.default_expected +
self.fixed_expected)
for obj in objects:
- self.assertTrue(isinstance(obj, Hashable), repr(obj))
+ self.assertIsInstance(obj, Hashable)
def test_not_hashable(self):
for obj in self.error_expected:
- self.assertFalse(isinstance(obj, Hashable), repr(obj))
+ self.assertNotIsInstance(obj, Hashable)
# Issue #4701: Check that some builtin types are correctly hashable
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index dca23cf95a..fe316fdd39 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -6,16 +6,23 @@
# Licensed to PSF under a Contributor Agreement.
#
+import array
import hashlib
-from io import StringIO
+import itertools
+import sys
try:
import threading
except ImportError:
threading = None
import unittest
+import warnings
from test import support
from test.support import _4G, precisionbigmemtest
+# Were we compiled --with-pydebug or with #define Py_DEBUG?
+COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
+
+
def hexstr(s):
assert isinstance(s, bytes), repr(s)
h = "0123456789abcdef"
@@ -30,6 +37,79 @@ class HashLibTestCase(unittest.TestCase):
'sha224', 'SHA224', 'sha256', 'SHA256',
'sha384', 'SHA384', 'sha512', 'SHA512' )
+ _warn_on_extension_import = COMPILED_WITH_PYDEBUG
+
+ def _conditional_import_module(self, module_name):
+ """Import a module and return a reference to it or None on failure."""
+ try:
+ exec('import '+module_name)
+ except ImportError as error:
+ if self._warn_on_extension_import:
+ warnings.warn('Did a C extension fail to compile? %s' % error)
+ return locals().get(module_name)
+
+ def __init__(self, *args, **kwargs):
+ algorithms = set()
+ for algorithm in self.supported_hash_names:
+ algorithms.add(algorithm.lower())
+ self.constructors_to_test = {}
+ for algorithm in algorithms:
+ self.constructors_to_test[algorithm] = set()
+
+ # For each algorithm, test the direct constructor and the use
+ # of hashlib.new given the algorithm name.
+ for algorithm, constructors in self.constructors_to_test.items():
+ constructors.add(getattr(hashlib, algorithm))
+ def _test_algorithm_via_hashlib_new(data=None, _alg=algorithm):
+ if data is None:
+ return hashlib.new(_alg)
+ return hashlib.new(_alg, data)
+ constructors.add(_test_algorithm_via_hashlib_new)
+
+ _hashlib = self._conditional_import_module('_hashlib')
+ if _hashlib:
+ # These two algorithms should always be present when this module
+ # is compiled. If not, something was compiled wrong.
+ assert hasattr(_hashlib, 'openssl_md5')
+ assert hasattr(_hashlib, 'openssl_sha1')
+ for algorithm, constructors in self.constructors_to_test.items():
+ constructor = getattr(_hashlib, 'openssl_'+algorithm, None)
+ if constructor:
+ constructors.add(constructor)
+
+ _md5 = self._conditional_import_module('_md5')
+ if _md5:
+ self.constructors_to_test['md5'].add(_md5.md5)
+ _sha1 = self._conditional_import_module('_sha1')
+ if _sha1:
+ self.constructors_to_test['sha1'].add(_sha1.sha1)
+ _sha256 = self._conditional_import_module('_sha256')
+ if _sha256:
+ self.constructors_to_test['sha224'].add(_sha256.sha224)
+ self.constructors_to_test['sha256'].add(_sha256.sha256)
+ _sha512 = self._conditional_import_module('_sha512')
+ if _sha512:
+ self.constructors_to_test['sha384'].add(_sha512.sha384)
+ self.constructors_to_test['sha512'].add(_sha512.sha512)
+
+ super(HashLibTestCase, self).__init__(*args, **kwargs)
+
+ def test_hash_array(self):
+ a = array.array("b", range(10))
+ constructors = self.constructors_to_test.values()
+ for cons in itertools.chain.from_iterable(constructors):
+ c = cons(a)
+ c.hexdigest()
+
+ def test_algorithms_guaranteed(self):
+ self.assertEqual(hashlib.algorithms_guaranteed,
+ set(_algo for _algo in self.supported_hash_names
+ if _algo.islower()))
+
+ def test_algorithms_available(self):
+ self.assertTrue(set(hashlib.algorithms_guaranteed).
+ issubset(hashlib.algorithms_available))
+
def test_unknown_hash(self):
try:
hashlib.new('spam spam spam spam spam')
@@ -61,17 +141,23 @@ class HashLibTestCase(unittest.TestCase):
self.assertEqual(m1.digest(), m2.digest())
def check(self, name, data, digest):
- # test the direct constructors
- computed = getattr(hashlib, name)(data).hexdigest()
- self.assertEqual(computed, digest)
- # test the general new() interface
- computed = hashlib.new(name, data).hexdigest()
- self.assertEqual(computed, digest)
+ constructors = self.constructors_to_test[name]
+ # 2 is for hashlib.name(...) and hashlib.new(name, ...)
+ self.assertGreaterEqual(len(constructors), 2)
+ for hash_object_constructor in constructors:
+ computed = hash_object_constructor(data).hexdigest()
+ self.assertEqual(
+ computed, digest,
+ "Hash algorithm %s constructed using %s returned hexdigest"
+ " %r for %d byte input data that should have hashed to %r."
+ % (name, hash_object_constructor,
+ computed, len(data), digest))
def check_no_unicode(self, algorithm_name):
# Unicode objects are not allowed as input.
- self.assertRaises(TypeError, getattr(hashlib, algorithm_name), 'spam')
- self.assertRaises(TypeError, hashlib.new, algorithm_name, 'spam')
+ constructors = self.constructors_to_test[algorithm_name]
+ for hash_object_constructor in constructors:
+ self.assertRaises(TypeError, hash_object_constructor, 'spam')
def test_no_unicode(self):
self.check_no_unicode('md5')
@@ -229,10 +315,9 @@ class HashLibTestCase(unittest.TestCase):
m = hashlib.md5(b'x' * gil_minsize)
self.assertEqual(m.hexdigest(), 'cfb767f225d58469c5de3632a8803958')
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ @support.reap_threads
def test_threaded_hashing(self):
- if not threading:
- raise unittest.SkipTest('No threading module.')
-
# Updating the same hash object from several threads at once
# using data chunk sizes containing the same byte sequences.
#
@@ -267,7 +352,6 @@ class HashLibTestCase(unittest.TestCase):
self.assertEqual(expected_hash, hasher.hexdigest())
-@support.reap_threads
def test_main():
support.run_unittest(HashLibTestCase)
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index 5e3b0ee981..3295869668 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -370,8 +370,6 @@ class TestErrorHandling(unittest.TestCase):
def test_main(verbose=None):
- from types import BuiltinFunctionType
-
test_classes = [TestHeapPython, TestHeapC, TestErrorHandling]
support.run_unittest(*test_classes)
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index fb78eba552..4de0620e1a 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -213,19 +213,13 @@ class TestVectorsTestCase(unittest.TestCase):
with warnings.catch_warnings():
warnings.simplefilter('error', RuntimeWarning)
- try:
+ with self.assertRaises(RuntimeWarning):
hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash)
- except RuntimeWarning:
- pass
- else:
self.fail('Expected warning about missing block_size')
MockCrazyHash.block_size = 1
- try:
+ with self.assertRaises(RuntimeWarning):
hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash)
- except RuntimeWarning:
- pass
- else:
self.fail('Expected warning about small block_size')
diff --git a/Lib/test/test_html.py b/Lib/test/test_html.py
new file mode 100644
index 0000000000..30dac58e6d
--- /dev/null
+++ b/Lib/test/test_html.py
@@ -0,0 +1,24 @@
+"""
+Tests for the html module functions.
+"""
+
+import html
+import unittest
+from test.support import run_unittest
+
+
+class HtmlTests(unittest.TestCase):
+ def test_escape(self):
+ self.assertEqual(
+ html.escape('\'<script>"&foo;"</script>\''),
+ '&#x27;&lt;script&gt;&quot;&amp;foo;&quot;&lt;/script&gt;&#x27;')
+ self.assertEqual(
+ html.escape('\'<script>"&foo;"</script>\'', False),
+ '\'&lt;script&gt;"&amp;foo;"&lt;/script&gt;\'')
+
+
+def test_main():
+ run_unittest(HtmlTests)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
index 661d41dce9..5ecd016084 100755..100644
--- a/Lib/test/test_htmlparser.py
+++ b/Lib/test/test_htmlparser.py
@@ -8,10 +8,10 @@ from test import support
class EventCollector(html.parser.HTMLParser):
- def __init__(self):
+ def __init__(self, *args, **kw):
self.events = []
self.append = self.events.append
- html.parser.HTMLParser.__init__(self)
+ html.parser.HTMLParser.__init__(self, *args, **kw)
def get_events(self):
# Normalize the list of events so that buffer artefacts don't
@@ -72,8 +72,10 @@ class EventCollectorExtra(EventCollector):
class TestCaseBase(unittest.TestCase):
- def _run_check(self, source, expected_events, collector=EventCollector):
- parser = collector()
+ def _run_check(self, source, expected_events, collector=None):
+ if collector is None:
+ collector = EventCollector()
+ parser = collector
for s in source:
parser.feed(s)
parser.close()
@@ -84,7 +86,7 @@ class TestCaseBase(unittest.TestCase):
"\nReceived:\n" + pprint.pformat(events))
def _run_check_extra(self, source, events):
- self._run_check(source, events, EventCollectorExtra)
+ self._run_check(source, events, EventCollectorExtra())
def _parse_error(self, source):
def parse(source=source):
@@ -319,6 +321,41 @@ DOCTYPE html [
self._run_check("<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>", [
("starttag", "html", [("foo", "\u20AC&aa&unsupported;")])
])
+
+
+class HTMLParserTolerantTestCase(TestCaseBase):
+
+ def setUp(self):
+ self.collector = EventCollector(strict=False)
+
+ def test_tolerant_parsing(self):
+ self._run_check('<html <html>te>>xt&a<<bc</a></html>\n'
+ '<img src="URL><//img></html</html>', [
+ ('data', '<html '),
+ ('starttag', 'html', []),
+ ('data', 'te>>xt'),
+ ('entityref', 'a'),
+ ('data', '<<bc'),
+ ('endtag', 'a'),
+ ('endtag', 'html'),
+ ('data', '\n<img src="URL><//img></html'),
+ ('endtag', 'html')],
+ collector = self.collector)
+
+ def test_comma_between_attributes(self):
+ self._run_check('<form action="/xxx.php?a=1&amp;b=2&amp", '
+ 'method="post">', [
+ ('starttag', 'form',
+ [('action', '/xxx.php?a=1&b=2&amp'),
+ ('method', 'post')])],
+ collector = self.collector)
+
+ def test_weird_chars_in_unquoted_attribute_values(self):
+ self._run_check('<form action=bogus|&#()value>', [
+ ('starttag', 'form',
+ [('action', 'bogus|&#()value')])],
+ collector = self.collector)
+
def test_unescape_function(self):
p = html.parser.HTMLParser()
self.assertEqual(p.unescape('&#bad;'),'&#bad;')
@@ -326,7 +363,7 @@ DOCTYPE html [
def test_main():
- support.run_unittest(HTMLParserTestCase)
+ support.run_unittest(HTMLParserTestCase, HTMLParserTolerantTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
index 3e85f62f36..712a4ae639 100644
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -29,7 +29,7 @@ class DateTimeTests(unittest.TestCase):
bz = time2isoz(500000)
for text in (az, bz):
self.assertTrue(re.search(r"^\d{4}-\d\d-\d\d \d\d:\d\d:\d\dZ$", text),
- "bad time2isoz format: %s %s" % (az, bz))
+ "bad time2isoz format: %s %s" % (az, bz))
def test_http2time(self):
def parse_date(text):
@@ -100,6 +100,7 @@ class DateTimeTests(unittest.TestCase):
class HeaderTests(unittest.TestCase):
+
def test_parse_ns_headers(self):
# quotes should be stripped
expected = [[('foo', 'bar'), ('expires', 2209069412), ('version', '0')]]
@@ -109,6 +110,16 @@ class HeaderTests(unittest.TestCase):
]:
self.assertEqual(parse_ns_headers([hdr]), expected)
+ def test_parse_ns_headers_version(self):
+
+ # quotes should be stripped
+ expected = [[('foo', 'bar'), ('version', '1')]]
+ for hdr in [
+ 'foo=bar; version="1"',
+ 'foo=bar; Version="1"',
+ ]:
+ self.assertEqual(parse_ns_headers([hdr]), expected)
+
def test_parse_ns_headers_special_names(self):
# names such as 'expires' are not special in first name=value pair
# of Set-Cookie: header
@@ -252,11 +263,11 @@ class FileCookieJarTests(unittest.TestCase):
# Invalid contents of cookies file (eg. bad magic string)
# causes a LoadError.
try:
- f = open(filename, "w")
- f.write("oops\n")
- for cookiejar_class in LWPCookieJar, MozillaCookieJar:
- c = cookiejar_class()
- self.assertRaises(LoadError, c.load, filename)
+ with open(filename, "w") as f:
+ f.write("oops\n")
+ for cookiejar_class in LWPCookieJar, MozillaCookieJar:
+ c = cookiejar_class()
+ self.assertRaises(LoadError, c.load, filename)
finally:
try: os.unlink(filename)
except OSError: pass
@@ -444,8 +455,8 @@ class CookieTests(unittest.TestCase):
interact_netscape(c, "http://www.acme.com/", 'version=eggs; spam=eggs')
cookies = c._cookies["www.acme.com"]["/"]
- self.assertTrue('expires' in cookies)
- self.assertTrue('version' in cookies)
+ self.assertIn('expires', cookies)
+ self.assertIn('version', cookies)
def test_expires(self):
# if expires is in future, keep cookie...
@@ -460,7 +471,8 @@ class CookieTests(unittest.TestCase):
now)
h = interact_netscape(c, "http://www.acme.com/")
self.assertEqual(len(c), 1)
- self.assertTrue('spam="bar"' in h and "foo" not in h)
+ self.assertIn('spam="bar"', h)
+ self.assertNotIn("foo", h)
# max-age takes precedence over expires, and zero max-age is request to
# delete both new cookie and any old matching cookie
@@ -481,7 +493,7 @@ class CookieTests(unittest.TestCase):
self.assertEqual(len(c), 2)
c.clear_session_cookies()
self.assertEqual(len(c), 1)
- self.assertTrue('spam="bar"' in h)
+ self.assertIn('spam="bar"', h)
# XXX RFC 2965 expiry rules (some apply to V0 too)
@@ -491,39 +503,39 @@ class CookieTests(unittest.TestCase):
c = CookieJar(pol)
interact_2965(c, "http://www.acme.com/", 'spam="bar"; Version="1"')
- self.assertTrue("/" in c._cookies["www.acme.com"])
+ self.assertIn("/", c._cookies["www.acme.com"])
c = CookieJar(pol)
interact_2965(c, "http://www.acme.com/blah", 'eggs="bar"; Version="1"')
- self.assertTrue("/" in c._cookies["www.acme.com"])
+ self.assertIn("/", c._cookies["www.acme.com"])
c = CookieJar(pol)
interact_2965(c, "http://www.acme.com/blah/rhubarb",
'eggs="bar"; Version="1"')
- self.assertTrue("/blah/" in c._cookies["www.acme.com"])
+ self.assertIn("/blah/", c._cookies["www.acme.com"])
c = CookieJar(pol)
interact_2965(c, "http://www.acme.com/blah/rhubarb/",
'eggs="bar"; Version="1"')
- self.assertTrue("/blah/rhubarb/" in c._cookies["www.acme.com"])
+ self.assertIn("/blah/rhubarb/", c._cookies["www.acme.com"])
# Netscape
c = CookieJar()
interact_netscape(c, "http://www.acme.com/", 'spam="bar"')
- self.assertTrue("/" in c._cookies["www.acme.com"])
+ self.assertIn("/", c._cookies["www.acme.com"])
c = CookieJar()
interact_netscape(c, "http://www.acme.com/blah", 'eggs="bar"')
- self.assertTrue("/" in c._cookies["www.acme.com"])
+ self.assertIn("/", c._cookies["www.acme.com"])
c = CookieJar()
interact_netscape(c, "http://www.acme.com/blah/rhubarb", 'eggs="bar"')
- self.assertTrue("/blah" in c._cookies["www.acme.com"])
+ self.assertIn("/blah", c._cookies["www.acme.com"])
c = CookieJar()
interact_netscape(c, "http://www.acme.com/blah/rhubarb/", 'eggs="bar"')
- self.assertTrue("/blah/rhubarb" in c._cookies["www.acme.com"])
+ self.assertIn("/blah/rhubarb", c._cookies["www.acme.com"])
def test_default_path_with_query(self):
cj = CookieJar()
@@ -566,7 +578,7 @@ class CookieTests(unittest.TestCase):
"http://www.example.com/rheum/rhaponticum;"
"foo=bar;sing=song?apples=pears&spam=eggs#ni")
self.assertEqual(request_path(req),
- "/rheum/rhaponticum;foo=bar;sing=song")
+ "/rheum/rhaponticum;foo=bar;sing=song")
# without parameters
req = urllib.request.Request(
"http://www.example.com/rheum/rhaponticum?"
@@ -889,21 +901,21 @@ class CookieTests(unittest.TestCase):
url = "http://foo.bar.com/"
interact_2965(c, url, "spam=eggs; Version=1")
h = interact_2965(c, url)
- self.assertTrue("Domain" not in h,
+ self.assertNotIn("Domain", h,
"absent domain returned with domain present")
c = CookieJar(pol)
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; Domain=.bar.com')
h = interact_2965(c, url)
- self.assertTrue('$Domain=".bar.com"' in h, "domain not returned")
+ self.assertIn('$Domain=".bar.com"', h, "domain not returned")
c = CookieJar(pol)
url = "http://foo.bar.com/"
# note missing initial dot in Domain
interact_2965(c, url, 'spam=eggs; Version=1; Domain=bar.com')
h = interact_2965(c, url)
- self.assertTrue('$Domain="bar.com"' in h, "domain not returned")
+ self.assertIn('$Domain="bar.com"', h, "domain not returned")
def test_path_mirror(self):
pol = DefaultCookiePolicy(rfc2965=True)
@@ -912,14 +924,13 @@ class CookieTests(unittest.TestCase):
url = "http://foo.bar.com/"
interact_2965(c, url, "spam=eggs; Version=1")
h = interact_2965(c, url)
- self.assertTrue("Path" not in h,
- "absent path returned with path present")
+ self.assertNotIn("Path", h, "absent path returned with path present")
c = CookieJar(pol)
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; Path=/')
h = interact_2965(c, url)
- self.assertTrue('$Path="/"' in h, "path not returned")
+ self.assertIn('$Path="/"', h, "path not returned")
def test_port_mirror(self):
pol = DefaultCookiePolicy(rfc2965=True)
@@ -928,8 +939,7 @@ class CookieTests(unittest.TestCase):
url = "http://foo.bar.com/"
interact_2965(c, url, "spam=eggs; Version=1")
h = interact_2965(c, url)
- self.assertTrue("Port" not in h,
- "absent port returned with port present")
+ self.assertNotIn("Port", h, "absent port returned with port present")
c = CookieJar(pol)
url = "http://foo.bar.com/"
@@ -942,16 +952,16 @@ class CookieTests(unittest.TestCase):
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; Port="80"')
h = interact_2965(c, url)
- self.assertTrue('$Port="80"' in h,
- "port with single value not returned with single value")
+ self.assertIn('$Port="80"', h,
+ "port with single value not returned with single value")
c = CookieJar(pol)
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; Port="80,8080"')
h = interact_2965(c, url)
- self.assertTrue('$Port="80,8080"' in h,
- "port with multiple values not returned with multiple "
- "values")
+ self.assertIn('$Port="80,8080"', h,
+ "port with multiple values not returned with multiple "
+ "values")
def test_no_return_comment(self):
c = CookieJar(DefaultCookiePolicy(rfc2965=True))
@@ -1033,6 +1043,8 @@ class CookieTests(unittest.TestCase):
["Set-Cookie2: a=foo; path=/; Version=1; domain"],
# bad max-age
["Set-Cookie: b=foo; max-age=oops"],
+ # bad version
+ ["Set-Cookie: b=foo; version=spam"],
]:
c = cookiejar_from_cookie_headers(headers)
# these bad cookies shouldn't be set
@@ -1116,8 +1128,8 @@ class LWPCookieTests(unittest.TestCase):
c.add_cookie_header(req)
h = req.get_header("Cookie")
- self.assertTrue("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
- "CUSTOMER=WILE_E_COYOTE" in h)
+ self.assertIn("PART_NUMBER=ROCKET_LAUNCHER_0001", h)
+ self.assertIn("CUSTOMER=WILE_E_COYOTE", h)
headers.append('Set-Cookie: SHIPPING=FEDEX; path=/foo')
res = FakeResponse(headers, "http://www.acme.com")
@@ -1127,17 +1139,17 @@ class LWPCookieTests(unittest.TestCase):
c.add_cookie_header(req)
h = req.get_header("Cookie")
- self.assertTrue("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
- "CUSTOMER=WILE_E_COYOTE" in h and
- "SHIPPING=FEDEX" not in h)
+ self.assertIn("PART_NUMBER=ROCKET_LAUNCHER_0001", h)
+ self.assertIn("CUSTOMER=WILE_E_COYOTE", h)
+ self.assertNotIn("SHIPPING=FEDEX", h)
req = urllib.request.Request("http://www.acme.com/foo/")
c.add_cookie_header(req)
h = req.get_header("Cookie")
- self.assertTrue(("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
- "CUSTOMER=WILE_E_COYOTE" in h and
- h.startswith("SHIPPING=FEDEX;")))
+ self.assertIn("PART_NUMBER=ROCKET_LAUNCHER_0001", h)
+ self.assertIn("CUSTOMER=WILE_E_COYOTE", h)
+ self.assertTrue(h.startswith("SHIPPING=FEDEX;"))
def test_netscape_example_2(self):
# Second Example transaction sequence:
@@ -1355,8 +1367,8 @@ class LWPCookieTests(unittest.TestCase):
# the server.
cookie = interact_2965(c, "http://www.acme.com/acme/parts/")
- self.assertTrue("Rocket_Launcher_0001" in cookie and
- "Riding_Rocket_0023" not in cookie)
+ self.assertIn("Rocket_Launcher_0001", cookie)
+ self.assertNotIn("Riding_Rocket_0023", cookie)
def test_rejection(self):
# Test rejection of Set-Cookie2 responses based on domain, path, port.
@@ -1461,7 +1473,8 @@ class LWPCookieTests(unittest.TestCase):
c, "http://www.acme.com/foo%2f%25/<<%0anew\345/\346\370\345",
'bar=baz; path="/foo/"; version=1');
version_re = re.compile(r'^\$version=\"?1\"?', re.I)
- self.assertTrue("foo=bar" in cookie and version_re.search(cookie))
+ self.assertIn("foo=bar", cookie)
+ self.assertTrue(version_re.search(cookie))
cookie = interact_2965(
c, "http://www.acme.com/foo/%25/<<%0anew\345/\346\370\345")
@@ -1505,11 +1518,11 @@ class LWPCookieTests(unittest.TestCase):
new_c = save_and_restore(c, True)
self.assertEqual(len(new_c), 6) # none discarded
- self.assertTrue("name='foo1', value='bar'" in repr(new_c))
+ self.assertIn("name='foo1', value='bar'", repr(new_c))
new_c = save_and_restore(c, False)
self.assertEqual(len(new_c), 4) # 2 of them discarded on save
- self.assertTrue("name='foo1', value='bar'" in repr(new_c))
+ self.assertIn("name='foo1', value='bar'", repr(new_c))
def test_netscape_misc(self):
# Some additional Netscape cookies tests.
@@ -1531,9 +1544,8 @@ class LWPCookieTests(unittest.TestCase):
req = urllib.request.Request("http://foo.bar.acme.com/foo")
c.add_cookie_header(req)
- self.assertTrue(
- "PART_NUMBER=3,4" in req.get_header("Cookie") and
- "Customer=WILE_E_COYOTE" in req.get_header("Cookie"))
+ self.assertIn("PART_NUMBER=3,4", req.get_header("Cookie"))
+ self.assertIn("Customer=WILE_E_COYOTE",req.get_header("Cookie"))
def test_intranet_domains_2965(self):
# Test handling of local intranet hostnames without a dot.
@@ -1542,11 +1554,12 @@ class LWPCookieTests(unittest.TestCase):
"foo1=bar; PORT; Discard; Version=1;")
cookie = interact_2965(c, "http://example/",
'foo2=bar; domain=".local"; Version=1')
- self.assertTrue("foo1=bar" in cookie)
+ self.assertIn("foo1=bar", cookie)
interact_2965(c, "http://example/", 'foo3=bar; Version=1')
cookie = interact_2965(c, "http://example/")
- self.assertTrue("foo2=bar" in cookie and len(c) == 3)
+ self.assertIn("foo2=bar", cookie)
+ self.assertEqual(len(c), 3)
def test_intranet_domains_ns(self):
c = CookieJar(DefaultCookiePolicy(rfc2965 = False))
@@ -1554,10 +1567,10 @@ class LWPCookieTests(unittest.TestCase):
cookie = interact_netscape(c, "http://example/",
'foo2=bar; domain=.local')
self.assertEqual(len(c), 2)
- self.assertTrue("foo1=bar" in cookie)
+ self.assertIn("foo1=bar", cookie)
cookie = interact_netscape(c, "http://example/")
- self.assertTrue("foo2=bar" in cookie)
+ self.assertIn("foo2=bar", cookie)
self.assertEqual(len(c), 2)
def test_empty_path(self):
diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py
index cc225cd49d..f9a98c4ae1 100644
--- a/Lib/test/test_http_cookies.py
+++ b/Lib/test/test_http_cookies.py
@@ -1,35 +1,39 @@
# Simple test suite for http/cookies.py
-from test.support import run_unittest, run_doctest
+from test.support import run_unittest, run_doctest, check_warnings
import unittest
from http import cookies
import warnings
-warnings.filterwarnings("ignore",
- ".* class is insecure.*",
- DeprecationWarning)
class CookieTests(unittest.TestCase):
+
+ def setUp(self):
+ self._warnings_manager = check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings("ignore", ".* class is insecure.*",
+ DeprecationWarning)
+
+ def tearDown(self):
+ self._warnings_manager.__exit__(None, None, None)
+
def test_basic(self):
cases = [
- { 'data': 'chips=ahoy; vienna=finger',
- 'dict': {'chips':'ahoy', 'vienna':'finger'},
- 'repr': "<SimpleCookie: chips='ahoy' vienna='finger'>",
- 'output': 'Set-Cookie: chips=ahoy\nSet-Cookie: vienna=finger',
- },
-
- { 'data': 'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
- 'dict': {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'},
- 'repr': '''<SimpleCookie: keebler='E=mc2; L="Loves"; fudge=\\n;'>''',
- 'output': 'Set-Cookie: keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
- },
+ {'data': 'chips=ahoy; vienna=finger',
+ 'dict': {'chips':'ahoy', 'vienna':'finger'},
+ 'repr': "<SimpleCookie: chips='ahoy' vienna='finger'>",
+ 'output': 'Set-Cookie: chips=ahoy\nSet-Cookie: vienna=finger'},
+
+ {'data': 'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
+ 'dict': {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'},
+ 'repr': '''<SimpleCookie: keebler='E=mc2; L="Loves"; fudge=\\n;'>''',
+ 'output': 'Set-Cookie: keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"'},
# Check illegal cookies that have an '=' char in an unquoted value
- { 'data': 'keebler=E=mc2',
- 'dict': {'keebler' : 'E=mc2'},
- 'repr': "<SimpleCookie: keebler='E=mc2'>",
- 'output': 'Set-Cookie: keebler=E=mc2',
- }
+ {'data': 'keebler=E=mc2',
+ 'dict': {'keebler' : 'E=mc2'},
+ 'repr': "<SimpleCookie: keebler='E=mc2'>",
+ 'output': 'Set-Cookie: keebler=E=mc2'},
]
for case in cases:
@@ -111,8 +115,72 @@ class CookieTests(unittest.TestCase):
self.assertEqual(C['Customer']['version'], '1')
self.assertEqual(C['Customer']['path'], '/acme')
+ self.assertEqual(C.output(['path']),
+ 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme')
+ self.assertEqual(C.js_output(), r"""
+ <script type="text/javascript">
+ <!-- begin hiding
+ document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1";
+ // end hiding -->
+ </script>
+ """)
+ self.assertEqual(C.js_output(['path']), r"""
+ <script type="text/javascript">
+ <!-- begin hiding
+ document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme";
+ // end hiding -->
+ </script>
+ """)
+
+class MorselTests(unittest.TestCase):
+ """Tests for the Morsel object."""
+
+ def test_reserved_keys(self):
+ M = cookies.Morsel()
+ # tests valid and invalid reserved keys for Morsels
+ for i in M._reserved:
+ # Test that all valid keys are reported as reserved and set them
+ self.assertTrue(M.isReservedKey(i))
+ M[i] = '%s_value' % i
+ for i in M._reserved:
+ # Test that valid key values come out fine
+ self.assertEqual(M[i], '%s_value' % i)
+ for i in "the holy hand grenade".split():
+ # Test that invalid keys raise CookieError
+ self.assertRaises(cookies.CookieError,
+ M.__setitem__, i, '%s_value' % i)
+
+ def test_setter(self):
+ M = cookies.Morsel()
+ # tests the .set method to set keys and their values
+ for i in M._reserved:
+ # Makes sure that all reserved keys can't be set this way
+ self.assertRaises(cookies.CookieError,
+ M.set, i, '%s_value' % i, '%s_value' % i)
+ for i in "thou cast _the- !holy! ^hand| +*grenade~".split():
+ # Try typical use case. Setting decent values.
+ # Check output and js_output.
+ M['path'] = '/foo' # Try a reserved key as well
+ M.set(i, "%s_val" % i, "%s_coded_val" % i)
+ self.assertEqual(
+ M.output(),
+ "Set-Cookie: %s=%s; Path=/foo" % (i, "%s_coded_val" % i))
+ expected_js_output = """
+ <script type="text/javascript">
+ <!-- begin hiding
+ document.cookie = "%s=%s; Path=/foo";
+ // end hiding -->
+ </script>
+ """ % (i, "%s_coded_val" % i)
+ self.assertEqual(M.js_output(), expected_js_output)
+ for i in ["foo bar", "foo@bar"]:
+ # Try some illegal characters
+ self.assertRaises(cookies.CookieError,
+ M.set, i, '%s_value' % i, '%s_value' % i)
+
+
def test_main():
- run_unittest(CookieTests)
+ run_unittest(CookieTests, MorselTests)
run_doctest(cookies)
if __name__ == '__main__':
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 43985a6652..890b1b9028 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1,13 +1,23 @@
import errno
from http import client
import io
+import os
import array
import socket
-from unittest import TestCase
+import unittest
+TestCase = unittest.TestCase
from test import support
+here = os.path.dirname(__file__)
+# Self-signed cert file for 'localhost'
+CERT_localhost = os.path.join(here, 'keycert.pem')
+# Self-signed cert file for 'fakehostname'
+CERT_fakehostname = os.path.join(here, 'keycert2.pem')
+# Root cert file (CA) for svn.python.org's cert
+CACERT_svn_python_org = os.path.join(here, 'https_svn_python_org_root.pem')
+
HOST = support.HOST
class FakeSocket:
@@ -132,6 +142,10 @@ class BasicTest(TestCase):
resp = client.HTTPResponse(sock)
self.assertRaises(client.BadStatusLine, resp.begin)
+ def test_bad_status_repr(self):
+ exc = client.BadStatusLine('')
+ self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''')
+
def test_partial_reads(self):
# if we have a lenght, the system knows when to close itself
# same behaviour than when we read the whole thing with read()
@@ -194,13 +208,13 @@ class BasicTest(TestCase):
expected = (b'GET /foo HTTP/1.1\r\nHost: example.com\r\n'
b'Accept-Encoding: identity\r\nContent-Length:')
- body = open(__file__, 'rb')
- conn = client.HTTPConnection('example.com')
- sock = FakeSocket(body)
- conn.sock = sock
- conn.request('GET', '/foo', body)
- self.assertTrue(sock.data.startswith(expected), '%r != %r' %
- (sock.data[:len(expected)], expected))
+ with open(__file__, 'rb') as body:
+ conn = client.HTTPConnection('example.com')
+ sock = FakeSocket(body)
+ conn.sock = sock
+ conn.request('GET', '/foo', body)
+ self.assertTrue(sock.data.startswith(expected), '%r != %r' %
+ (sock.data[:len(expected)], expected))
def test_send(self):
expected = b'this is a test this is only a test'
@@ -216,6 +230,22 @@ class BasicTest(TestCase):
conn.send(io.BytesIO(expected))
self.assertEqual(expected, sock.data)
+ def test_send_iter(self):
+ expected = b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \
+ b'Accept-Encoding: identity\r\nContent-Length: 11\r\n' \
+ b'\r\nonetwothree'
+
+ def body():
+ yield b"one"
+ yield b"two"
+ yield b"three"
+
+ conn = client.HTTPConnection('example.com')
+ sock = FakeSocket("")
+ conn.sock = sock
+ conn.request('GET', '/foo', body(), {'Content-Length': '11'})
+ self.assertEqual(sock.data, expected)
+
def test_chunked(self):
chunked_start = (
'HTTP/1.1 200 OK\r\n'
@@ -306,7 +336,6 @@ class BasicTest(TestCase):
# Test lines overflowing the max line size (_MAXLINE in http.client)
def test_overflowing_status_line(self):
- self.skipTest("disabled for HTTP 0.9 support")
body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n"
resp = client.HTTPResponse(FakeSocket(body))
self.assertRaises((client.LineTooLong, client.BadStatusLine), resp.begin)
@@ -335,6 +364,38 @@ class OfflineTest(TestCase):
def test_responses(self):
self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")
+
+class SourceAddressTest(TestCase):
+ def setUp(self):
+ self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.port = support.bind_port(self.serv)
+ self.source_port = support.find_unused_port()
+ self.serv.listen(5)
+ self.conn = None
+
+ def tearDown(self):
+ if self.conn:
+ self.conn.close()
+ self.conn = None
+ self.serv.close()
+ self.serv = None
+
+ def testHTTPConnectionSourceAddress(self):
+ self.conn = client.HTTPConnection(HOST, self.port,
+ source_address=('', self.source_port))
+ self.conn.connect()
+ self.assertEqual(self.conn.sock.getsockname()[1], self.source_port)
+
+ @unittest.skipIf(not hasattr(client, 'HTTPSConnection'),
+ 'http.client.HTTPSConnection not defined')
+ def testHTTPSConnectionSourceAddress(self):
+ self.conn = client.HTTPSConnection(HOST, self.port,
+ source_address=('', self.source_port))
+ # We don't test anything here other the constructor not barfing as
+ # this code doesn't deal with setting up an active running SSL server
+ # for an ssl_wrapped connect() to actually return from.
+
+
class TimeoutTest(TestCase):
PORT = None
@@ -380,14 +441,97 @@ class TimeoutTest(TestCase):
self.assertEqual(httpConn.sock.gettimeout(), 30)
httpConn.close()
-class HTTPSTimeoutTest(TestCase):
-# XXX Here should be tests for HTTPS, there isn't any right now!
+
+class HTTPSTest(TestCase):
+
+ def setUp(self):
+ if not hasattr(client, 'HTTPSConnection'):
+ self.skipTest('ssl support required')
+
+ def make_server(self, certfile):
+ from test.ssl_servers import make_https_server
+ return make_https_server(self, certfile)
def test_attributes(self):
- # simple test to check it's storing it
- if hasattr(client, 'HTTPSConnection'):
- h = client.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
- self.assertEqual(h.timeout, 30)
+ # simple test to check it's storing the timeout
+ h = client.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
+ self.assertEqual(h.timeout, 30)
+
+ def _check_svn_python_org(self, resp):
+ # Just a simple check that everything went fine
+ server_string = resp.getheader('server')
+ self.assertIn('Apache', server_string)
+
+ def test_networked(self):
+ # Default settings: no cert verification is done
+ support.requires('network')
+ with support.transient_internet('svn.python.org'):
+ h = client.HTTPSConnection('svn.python.org', 443)
+ h.request('GET', '/')
+ resp = h.getresponse()
+ self._check_svn_python_org(resp)
+
+ def test_networked_good_cert(self):
+ # We feed a CA cert that validates the server's cert
+ import ssl
+ support.requires('network')
+ with support.transient_internet('svn.python.org'):
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CACERT_svn_python_org)
+ h = client.HTTPSConnection('svn.python.org', 443, context=context)
+ h.request('GET', '/')
+ resp = h.getresponse()
+ self._check_svn_python_org(resp)
+
+ def test_networked_bad_cert(self):
+ # We feed a "CA" cert that is unrelated to the server's cert
+ import ssl
+ support.requires('network')
+ with support.transient_internet('svn.python.org'):
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERT_localhost)
+ h = client.HTTPSConnection('svn.python.org', 443, context=context)
+ with self.assertRaises(ssl.SSLError):
+ h.request('GET', '/')
+
+ def test_local_good_hostname(self):
+ # The (valid) cert validates the HTTP hostname
+ import ssl
+ from test.ssl_servers import make_https_server
+ server = make_https_server(self, CERT_localhost)
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERT_localhost)
+ h = client.HTTPSConnection('localhost', server.port, context=context)
+ h.request('GET', '/nonexistent')
+ resp = h.getresponse()
+ self.assertEqual(resp.status, 404)
+
+ def test_local_bad_hostname(self):
+ # The (valid) cert doesn't validate the HTTP hostname
+ import ssl
+ from test.ssl_servers import make_https_server
+ server = make_https_server(self, CERT_fakehostname)
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERT_fakehostname)
+ h = client.HTTPSConnection('localhost', server.port, context=context)
+ with self.assertRaises(ssl.CertificateError):
+ h.request('GET', '/')
+ # Same with explicit check_hostname=True
+ h = client.HTTPSConnection('localhost', server.port, context=context,
+ check_hostname=True)
+ with self.assertRaises(ssl.CertificateError):
+ h.request('GET', '/')
+ # With check_hostname=False, the mismatching is ignored
+ h = client.HTTPSConnection('localhost', server.port, context=context,
+ check_hostname=False)
+ h.request('GET', '/nonexistent')
+ resp = h.getresponse()
+ self.assertEqual(resp.status, 404)
+
class RequestBodyTest(TestCase):
"""Test cases where a request includes a message body."""
@@ -416,7 +560,7 @@ class RequestBodyTest(TestCase):
self.conn.request("PUT", "/url", "body")
message, f = self.get_headers_and_fp()
self.assertEqual("text/plain", message.get_content_type())
- self.assertEqual(None, message.get_charset())
+ self.assertIsNone(message.get_charset())
self.assertEqual("4", message.get("content-length"))
self.assertEqual(b'body', f.read())
@@ -424,7 +568,7 @@ class RequestBodyTest(TestCase):
self.conn.request("PUT", "/url", "body\xc1")
message, f = self.get_headers_and_fp()
self.assertEqual("text/plain", message.get_content_type())
- self.assertEqual(None, message.get_charset())
+ self.assertIsNone(message.get_charset())
self.assertEqual("5", message.get("content-length"))
self.assertEqual(b'body\xc1', f.read())
@@ -432,33 +576,31 @@ class RequestBodyTest(TestCase):
self.conn.request("PUT", "/url", b"body\xc1")
message, f = self.get_headers_and_fp()
self.assertEqual("text/plain", message.get_content_type())
- self.assertEqual(None, message.get_charset())
+ self.assertIsNone(message.get_charset())
self.assertEqual("5", message.get("content-length"))
self.assertEqual(b'body\xc1', f.read())
def test_file_body(self):
- f = open(support.TESTFN, "w")
- f.write("body")
- f.close()
- f = open(support.TESTFN)
- self.conn.request("PUT", "/url", f)
- message, f = self.get_headers_and_fp()
- self.assertEqual("text/plain", message.get_content_type())
- self.assertEqual(None, message.get_charset())
- self.assertEqual("4", message.get("content-length"))
- self.assertEqual(b'body', f.read())
+ with open(support.TESTFN, "w") as f:
+ f.write("body")
+ with open(support.TESTFN) as f:
+ self.conn.request("PUT", "/url", f)
+ message, f = self.get_headers_and_fp()
+ self.assertEqual("text/plain", message.get_content_type())
+ self.assertIsNone(message.get_charset())
+ self.assertEqual("4", message.get("content-length"))
+ self.assertEqual(b'body', f.read())
def test_binary_file_body(self):
- f = open(support.TESTFN, "wb")
- f.write(b"body\xc1")
- f.close()
- f = open(support.TESTFN, "rb")
- self.conn.request("PUT", "/url", f)
- message, f = self.get_headers_and_fp()
- self.assertEqual("text/plain", message.get_content_type())
- self.assertEqual(None, message.get_charset())
- self.assertEqual("5", message.get("content-length"))
- self.assertEqual(b'body\xc1', f.read())
+ with open(support.TESTFN, "wb") as f:
+ f.write(b"body\xc1")
+ with open(support.TESTFN, "rb") as f:
+ self.conn.request("PUT", "/url", f)
+ message, f = self.get_headers_and_fp()
+ self.assertEqual("text/plain", message.get_content_type())
+ self.assertIsNone(message.get_charset())
+ self.assertEqual("5", message.get("content-length"))
+ self.assertEqual(b'body\xc1', f.read())
class HTTPResponseTest(TestCase):
@@ -498,7 +640,8 @@ class HTTPResponseTest(TestCase):
def test_main(verbose=None):
support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
- HTTPSTimeoutTest, RequestBodyTest, HTTPResponseTest)
+ HTTPSTest, RequestBodyTest, SourceAddressTest,
+ HTTPResponseTest)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 28256975a0..a16e0e32b8 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -16,12 +16,11 @@ import shutil
import urllib.parse
import http.client
import tempfile
-import threading
+from io import BytesIO
import unittest
-
-from io import BytesIO
from test import support
+threading = support.import_module('threading')
class NoLogRequestHandler:
def log_message(self, *args):
@@ -32,21 +31,6 @@ class NoLogRequestHandler:
return ''
-class SocketlessRequestHandler(SimpleHTTPRequestHandler):
- def __init__(self):
- self.get_called = False
- self.protocol_version = "HTTP/1.1"
-
- def do_GET(self):
- self.get_called = True
- self.send_response(200)
- self.send_header('Content-Type', 'text/html')
- self.end_headers()
- self.wfile.write(b'<html><body>Data</body></html>\r\n')
-
- def log_message(self, format, *args):
- pass
-
class TestServerThread(threading.Thread):
def __init__(self, test_object, request_handler):
threading.Thread.__init__(self)
@@ -69,6 +53,8 @@ class TestServerThread(threading.Thread):
class BaseTestCase(unittest.TestCase):
def setUp(self):
+ self._threads = support.threading_setup()
+ os.environ = support.EnvironmentVarGuard()
self.server_started = threading.Event()
self.thread = TestServerThread(self, self.request_handler)
self.thread.start()
@@ -76,81 +62,14 @@ class BaseTestCase(unittest.TestCase):
def tearDown(self):
self.thread.stop()
+ os.environ.__exit__()
+ support.threading_cleanup(*self._threads)
def request(self, uri, method='GET', body=None, headers={}):
self.connection = http.client.HTTPConnection('localhost', self.PORT)
self.connection.request(method, uri, body, headers)
return self.connection.getresponse()
-class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
- """Test the functionality of the BaseHTTPServer."""
-
- HTTPResponseMatch = re.compile(b'HTTP/1.[0-9]+ 200 OK')
-
- def setUp (self):
- self.handler = SocketlessRequestHandler()
-
- def send_typical_request(self, message):
- input = BytesIO(message)
- output = BytesIO()
- self.handler.rfile = input
- self.handler.wfile = output
- self.handler.handle_one_request()
- output.seek(0)
- return output.readlines()
-
- def verify_get_called(self):
- self.assertTrue(self.handler.get_called)
-
- def verify_expected_headers(self, headers):
- for fieldName in b'Server: ', b'Date: ', b'Content-Type: ':
- self.assertEqual(sum(h.startswith(fieldName) for h in headers), 1)
-
- def verify_http_server_response(self, response):
- match = self.HTTPResponseMatch.search(response)
- self.assertTrue(match is not None)
-
- def test_http_1_1(self):
- result = self.send_typical_request(b'GET / HTTP/1.1\r\n\r\n')
- self.verify_http_server_response(result[0])
- self.verify_expected_headers(result[1:-1])
- self.verify_get_called()
- self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
-
- def test_http_1_0(self):
- result = self.send_typical_request(b'GET / HTTP/1.0\r\n\r\n')
- self.verify_http_server_response(result[0])
- self.verify_expected_headers(result[1:-1])
- self.verify_get_called()
- self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
-
- def test_http_0_9(self):
- result = self.send_typical_request(b'GET / HTTP/0.9\r\n\r\n')
- self.assertEqual(len(result), 1)
- self.assertEqual(result[0], b'<html><body>Data</body></html>\r\n')
- self.verify_get_called()
-
- def test_with_continue_1_0(self):
- result = self.send_typical_request(b'GET / HTTP/1.0\r\nExpect: 100-continue\r\n\r\n')
- self.verify_http_server_response(result[0])
- self.verify_expected_headers(result[1:-1])
- self.verify_get_called()
- self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
-
- def test_request_length(self):
- # Issue #10714: huge request lines are discarded, to avoid Denial
- # of Service attacks.
- result = self.send_typical_request(b'GET ' + b'x' * 65537)
- self.assertEqual(result[0], b'HTTP/1.1 414 Request-URI Too Long\r\n')
- self.assertFalse(self.handler.get_called)
-
- def test_header_length(self):
- # Issue #6791: same for headers
- result = self.send_typical_request(
- b'GET / HTTP/1.1\r\nX-Foo: bar' + b'r' * 65537 + b'\r\n\r\n')
- self.assertEqual(result[0], b'HTTP/1.1 400 Line too long\r\n')
- self.assertFalse(self.handler.get_called)
-
class BaseHTTPServerTestCase(BaseTestCase):
class request_handler(NoLogRequestHandler, BaseHTTPRequestHandler):
@@ -178,6 +97,14 @@ class BaseHTTPServerTestCase(BaseTestCase):
self.send_header('Connection', 'close')
self.end_headers()
+ def do_LATINONEHEADER(self):
+ self.send_response(999)
+ self.send_header('X-Special', 'Dängerous Mind')
+ self.send_header('Connection', 'close')
+ self.end_headers()
+ body = self.headers['x-special-incoming'].encode('utf-8')
+ self.wfile.write(body)
+
def setUp(self):
BaseTestCase.setUp(self)
self.con = http.client.HTTPConnection('localhost', self.PORT)
@@ -263,6 +190,7 @@ class BaseHTTPServerTestCase(BaseTestCase):
res = self.con.getresponse()
self.assertEqual(res.getheader('Connection'), 'keep-alive')
self.con.request('TEST', '/')
+ self.addCleanup(self.con.close)
def test_internal_key_error(self):
self.con.request('KEYERROR', '/')
@@ -274,6 +202,14 @@ class BaseHTTPServerTestCase(BaseTestCase):
res = self.con.getresponse()
self.assertEqual(res.status, 999)
+ def test_latin1_header(self):
+ self.con.request('LATINONEHEADER', '/', headers={
+ 'X-Special-Incoming': 'Ärger mit Unicode'
+ })
+ res = self.con.getresponse()
+ self.assertEqual(res.getheader('X-Special'), 'Dängerous Mind')
+ self.assertEqual(res.read(), 'Ärger mit Unicode'.encode('utf-8'))
+
class SimpleHTTPServerTestCase(BaseTestCase):
class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler):
@@ -287,9 +223,8 @@ class SimpleHTTPServerTestCase(BaseTestCase):
self.data = b'We are the knights who say Ni!'
self.tempdir = tempfile.mkdtemp(dir=basetempdir)
self.tempdir_name = os.path.basename(self.tempdir)
- temp = open(os.path.join(self.tempdir, 'test'), 'wb')
- temp.write(self.data)
- temp.close()
+ with open(os.path.join(self.tempdir, 'test'), 'wb') as temp:
+ temp.write(self.data)
def tearDown(self):
try:
@@ -305,7 +240,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
body = response.read()
self.assertTrue(response)
self.assertEqual(response.status, status)
- self.assertTrue(response.reason != None)
+ self.assertIsNotNone(response.reason)
if data:
self.assertEqual(data, body)
@@ -321,15 +256,15 @@ class SimpleHTTPServerTestCase(BaseTestCase):
self.check_status_and_reason(response, 404)
response = self.request('/' + 'ThisDoesNotExist' + '/')
self.check_status_and_reason(response, 404)
- f = open(os.path.join(self.tempdir_name, 'index.html'), 'w')
- response = self.request('/' + self.tempdir_name + '/')
- self.check_status_and_reason(response, 200)
- if os.name == 'posix':
- # chmod won't work as expected on Windows platforms
- os.chmod(self.tempdir, 0)
- response = self.request(self.tempdir_name + '/')
- self.check_status_and_reason(response, 404)
- os.chmod(self.tempdir, 0o755)
+ with open(os.path.join(self.tempdir_name, 'index.html'), 'w') as f:
+ response = self.request('/' + self.tempdir_name + '/')
+ self.check_status_and_reason(response, 200)
+ if os.name == 'posix':
+ # chmod won't work as expected on Windows platforms
+ os.chmod(self.tempdir, 0)
+ response = self.request(self.tempdir_name + '/')
+ self.check_status_and_reason(response, 404)
+ os.chmod(self.tempdir, 0o755)
def test_head(self):
response = self.request(
@@ -366,8 +301,8 @@ print("Content-type: text/html")
print()
form = cgi.FieldStorage()
-print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),\
- form.getfirst("bacon")))
+print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),
+ form.getfirst("bacon")))
"""
class CGIHTTPServerTestCase(BaseTestCase):
@@ -376,29 +311,41 @@ class CGIHTTPServerTestCase(BaseTestCase):
def setUp(self):
BaseTestCase.setUp(self)
+ self.cwd = os.getcwd()
self.parent_dir = tempfile.mkdtemp()
self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin')
os.mkdir(self.cgi_dir)
+ self.file1_path = None
+ self.file2_path = None
# The shebang line should be pure ASCII: use symlink if possible.
# See issue #7668.
- if hasattr(os, 'symlink'):
+ if support.can_symlink():
self.pythonexe = os.path.join(self.parent_dir, 'python')
os.symlink(sys.executable, self.pythonexe)
else:
self.pythonexe = sys.executable
+ try:
+ # The python executable path is written as the first line of the
+ # CGI Python script. The encoding cookie cannot be used, and so the
+ # path should be encodable to the default script encoding (utf-8)
+ self.pythonexe.encode('utf-8')
+ except UnicodeEncodeError:
+ self.tearDown()
+ raise self.skipTest(
+ "Python executable path is not encodable to utf-8")
+
self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
- with open(self.file1_path, 'w') as file1:
+ with open(self.file1_path, 'w', encoding='utf-8') as file1:
file1.write(cgi_file1 % self.pythonexe)
os.chmod(self.file1_path, 0o777)
self.file2_path = os.path.join(self.cgi_dir, 'file2.py')
- with open(self.file2_path, 'w') as file2:
+ with open(self.file2_path, 'w', encoding='utf-8') as file2:
file2.write(cgi_file2 % self.pythonexe)
os.chmod(self.file2_path, 0o777)
- self.cwd = os.getcwd()
os.chdir(self.parent_dir)
def tearDown(self):
@@ -406,8 +353,10 @@ class CGIHTTPServerTestCase(BaseTestCase):
os.chdir(self.cwd)
if self.pythonexe != sys.executable:
os.remove(self.pythonexe)
- os.remove(self.file1_path)
- os.remove(self.file2_path)
+ if self.file1_path:
+ os.remove(self.file1_path)
+ if self.file2_path:
+ os.remove(self.file2_path)
os.rmdir(self.cgi_dir)
os.rmdir(self.parent_dir)
finally:
@@ -449,13 +398,13 @@ class CGIHTTPServerTestCase(BaseTestCase):
else:
actual = server._url_collapse_path_split(path)
self.assertEqual(expected, actual,
- msg='path = %r\nGot: %r\nWanted: %r' % (
- path, actual, expected))
+ msg='path = %r\nGot: %r\nWanted: %r' %
+ (path, actual, expected))
def test_headers_and_content(self):
res = self.request('/cgi-bin/file1.py')
- self.assertEqual((b'Hello World\n', 'text/html', 200), \
- (res.read(), res.getheader('Content-type'), res.status))
+ self.assertEqual((b'Hello World\n', 'text/html', 200),
+ (res.read(), res.getheader('Content-type'), res.status))
def test_post(self):
params = urllib.parse.urlencode(
@@ -474,8 +423,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
headers = {b'Authorization' : b'Basic ' +
base64.b64encode(b'username:pass')}
res = self.request('/cgi-bin/file1.py', 'GET', headers=headers)
- self.assertEqual((b'Hello World\n', 'text/html', 200), \
- (res.read(), res.getheader('Content-type'), res.status))
+ self.assertEqual((b'Hello World\n', 'text/html', 200),
+ (res.read(), res.getheader('Content-type'), res.status))
def test_no_leading_slash(self):
# http://bugs.python.org/issue2254
@@ -492,6 +441,161 @@ class CGIHTTPServerTestCase(BaseTestCase):
self.assertEqual(os.environ['SERVER_SOFTWARE'], signature)
+class SocketlessRequestHandler(SimpleHTTPRequestHandler):
+ def __init__(self):
+ self.get_called = False
+ self.protocol_version = "HTTP/1.1"
+
+ def do_GET(self):
+ self.get_called = True
+ self.send_response(200)
+ self.send_header('Content-Type', 'text/html')
+ self.end_headers()
+ self.wfile.write(b'<html><body>Data</body></html>\r\n')
+
+ def log_message(self, format, *args):
+ pass
+
+class RejectingSocketlessRequestHandler(SocketlessRequestHandler):
+ def handle_expect_100(self):
+ self.send_error(417)
+ return False
+
+class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
+ """Test the functionality of the BaseHTTPServer.
+
+ Test the support for the Expect 100-continue header.
+ """
+
+ HTTPResponseMatch = re.compile(b'HTTP/1.[0-9]+ 200 OK')
+
+ def setUp (self):
+ self.handler = SocketlessRequestHandler()
+
+ def send_typical_request(self, message):
+ input = BytesIO(message)
+ output = BytesIO()
+ self.handler.rfile = input
+ self.handler.wfile = output
+ self.handler.handle_one_request()
+ output.seek(0)
+ return output.readlines()
+
+ def verify_get_called(self):
+ self.assertTrue(self.handler.get_called)
+
+ def verify_expected_headers(self, headers):
+ for fieldName in b'Server: ', b'Date: ', b'Content-Type: ':
+ self.assertEqual(sum(h.startswith(fieldName) for h in headers), 1)
+
+ def verify_http_server_response(self, response):
+ match = self.HTTPResponseMatch.search(response)
+ self.assertTrue(match is not None)
+
+ def test_http_1_1(self):
+ result = self.send_typical_request(b'GET / HTTP/1.1\r\n\r\n')
+ self.verify_http_server_response(result[0])
+ self.verify_expected_headers(result[1:-1])
+ self.verify_get_called()
+ self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
+
+ def test_http_1_0(self):
+ result = self.send_typical_request(b'GET / HTTP/1.0\r\n\r\n')
+ self.verify_http_server_response(result[0])
+ self.verify_expected_headers(result[1:-1])
+ self.verify_get_called()
+ self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
+
+ def test_http_0_9(self):
+ result = self.send_typical_request(b'GET / HTTP/0.9\r\n\r\n')
+ self.assertEqual(len(result), 1)
+ self.assertEqual(result[0], b'<html><body>Data</body></html>\r\n')
+ self.verify_get_called()
+
+ def test_with_continue_1_0(self):
+ result = self.send_typical_request(b'GET / HTTP/1.0\r\nExpect: 100-continue\r\n\r\n')
+ self.verify_http_server_response(result[0])
+ self.verify_expected_headers(result[1:-1])
+ self.verify_get_called()
+ self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
+
+ def test_with_continue_1_1(self):
+ result = self.send_typical_request(b'GET / HTTP/1.1\r\nExpect: 100-continue\r\n\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 100 Continue\r\n')
+ self.assertEqual(result[1], b'HTTP/1.1 200 OK\r\n')
+ self.verify_expected_headers(result[2:-1])
+ self.verify_get_called()
+ self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
+
+ def test_header_buffering(self):
+
+ def _readAndReseek(f):
+ pos = f.tell()
+ f.seek(0)
+ data = f.read()
+ f.seek(pos)
+ return data
+
+ input = BytesIO(b'GET / HTTP/1.1\r\n\r\n')
+ output = BytesIO()
+ self.handler.rfile = input
+ self.handler.wfile = output
+ self.handler.request_version = 'HTTP/1.1'
+
+ self.handler.send_header('Foo', 'foo')
+ self.handler.send_header('bar', 'bar')
+ self.assertEqual(_readAndReseek(output), b'')
+ self.handler.end_headers()
+ self.assertEqual(_readAndReseek(output),
+ b'Foo: foo\r\nbar: bar\r\n\r\n')
+
+ def test_header_unbuffered_when_continue(self):
+
+ def _readAndReseek(f):
+ pos = f.tell()
+ f.seek(0)
+ data = f.read()
+ f.seek(pos)
+ return data
+
+ input = BytesIO(b'GET / HTTP/1.1\r\nExpect: 100-continue\r\n\r\n')
+ output = BytesIO()
+ self.handler.rfile = input
+ self.handler.wfile = output
+ self.handler.request_version = 'HTTP/1.1'
+
+ self.handler.handle_one_request()
+ self.assertNotEqual(_readAndReseek(output), b'')
+ result = _readAndReseek(output).split(b'\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 100 Continue')
+ self.assertEqual(result[1], b'HTTP/1.1 200 OK')
+
+ def test_with_continue_rejected(self):
+ usual_handler = self.handler # Save to avoid breaking any subsequent tests.
+ self.handler = RejectingSocketlessRequestHandler()
+ result = self.send_typical_request(b'GET / HTTP/1.1\r\nExpect: 100-continue\r\n\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 417 Expectation Failed\r\n')
+ self.verify_expected_headers(result[1:-1])
+ # The expect handler should short circuit the usual get method by
+ # returning false here, so get_called should be false
+ self.assertFalse(self.handler.get_called)
+ self.assertEqual(sum(r == b'Connection: close\r\n' for r in result[1:-1]), 1)
+ self.handler = usual_handler # Restore to avoid breaking any subsequent tests.
+
+ def test_request_length(self):
+ # Issue #10714: huge request lines are discarded, to avoid Denial
+ # of Service attacks.
+ result = self.send_typical_request(b'GET ' + b'x' * 65537)
+ self.assertEqual(result[0], b'HTTP/1.1 414 Request-URI Too Long\r\n')
+ self.assertFalse(self.handler.get_called)
+
+ def test_header_length(self):
+ # Issue #6791: same for headers
+ result = self.send_typical_request(
+ b'GET / HTTP/1.1\r\nX-Foo: bar' + b'r' * 65537 + b'\r\n\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 400 Line too long\r\n')
+ self.assertFalse(self.handler.get_called)
+
class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
""" Test url parsing """
def setUp(self):
@@ -515,14 +619,15 @@ class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
def test_main(verbose=None):
+ cwd = os.getcwd()
try:
- cwd = os.getcwd()
- support.run_unittest(BaseHTTPRequestHandlerTestCase,
- SimpleHTTPRequestHandlerTestCase,
- BaseHTTPServerTestCase,
- SimpleHTTPServerTestCase,
- CGIHTTPServerTestCase
- )
+ support.run_unittest(
+ BaseHTTPRequestHandlerTestCase,
+ BaseHTTPServerTestCase,
+ SimpleHTTPServerTestCase,
+ CGIHTTPServerTestCase,
+ SimpleHTTPRequestHandlerTestCase,
+ )
finally:
os.chdir(cwd)
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 6116c8bc96..4ece1bf741 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -7,10 +7,7 @@ threading = support.import_module('threading')
from contextlib import contextmanager
import imaplib
import os.path
-import select
-import socket
import socketserver
-import sys
import time
import calendar
@@ -76,7 +73,7 @@ class SimpleIMAPHandler(socketserver.StreamRequestHandler):
timeout = 1
def _send(self, message):
- if verbose: print("SENT:", message.strip())
+ if verbose: print("SENT: %r" % message.strip())
self.wfile.write(message)
def handle(self):
@@ -100,7 +97,7 @@ class SimpleIMAPHandler(socketserver.StreamRequestHandler):
if line.endswith(b'\r\n'):
break
- if verbose: print('GOT:', line.strip())
+ if verbose: print('GOT: %r' % line.strip())
splitline = line.split()
tag = splitline[0].decode('ASCII')
cmd = splitline[1].decode('ASCII')
@@ -151,6 +148,7 @@ class BaseThreadedNetworkedTests(unittest.TestCase):
def reap_server(self, server, thread):
if verbose: print("waiting for server")
server.shutdown()
+ server.server_close()
thread.join()
if verbose: print("done")
@@ -224,9 +222,9 @@ class RemoteIMAPTest(unittest.TestCase):
self.server.logout()
def test_logincapa(self):
+ for cap in self.server.capabilities:
+ self.assertIsInstance(cap, str)
self.assertTrue('LOGINDISABLED' in self.server.capabilities)
-
- def test_anonlogin(self):
self.assertTrue('AUTH=ANONYMOUS' in self.server.capabilities)
rs = self.server.login(self.username, self.password)
self.assertEqual(rs[0], 'OK')
@@ -238,11 +236,27 @@ class RemoteIMAPTest(unittest.TestCase):
@unittest.skipUnless(ssl, "SSL not available")
+class RemoteIMAP_STARTTLSTest(RemoteIMAPTest):
+
+ def setUp(self):
+ super().setUp()
+ rs = self.server.starttls()
+ self.assertEqual(rs[0], 'OK')
+
+ def test_logincapa(self):
+ for cap in self.server.capabilities:
+ self.assertIsInstance(cap, str)
+ self.assertFalse('LOGINDISABLED' in self.server.capabilities)
+
+
+@unittest.skipUnless(ssl, "SSL not available")
class RemoteIMAP_SSLTest(RemoteIMAPTest):
port = 993
imap_class = IMAP4_SSL
def test_logincapa(self):
+ for cap in self.server.capabilities:
+ self.assertIsInstance(cap, str)
self.assertFalse('LOGINDISABLED' in self.server.capabilities)
self.assertTrue('AUTH=PLAIN' in self.server.capabilities)
@@ -259,7 +273,7 @@ def test_main():
raise support.TestFailed("Can't read certificate files!")
tests.extend([
ThreadedNetworkedTests, ThreadedNetworkedTestsSSL,
- RemoteIMAPTest, RemoteIMAP_SSLTest,
+ RemoteIMAPTest, RemoteIMAP_SSLTest, RemoteIMAP_STARTTLSTest,
])
support.run_unittest(*tests)
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 1671e487d9..d745ae9cc3 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -1,10 +1,11 @@
import imp
import os
import os.path
+import shutil
import sys
import unittest
from test import support
-
+import importlib
class LockTests(unittest.TestCase):
@@ -41,26 +42,40 @@ class LockTests(unittest.TestCase):
"RuntimeError")
class ImportTests(unittest.TestCase):
+ def setUp(self):
+ mod = importlib.import_module('test.encoded_modules')
+ self.test_strings = mod.test_strings
+ self.test_path = mod.__path__
+
+ def test_import_encoded_module(self):
+ for modname, encoding, teststr in self.test_strings:
+ mod = importlib.import_module('test.encoded_modules.'
+ 'module_' + modname)
+ self.assertEqual(teststr, mod.test)
def test_find_module_encoding(self):
- fd = imp.find_module("heapq")[0]
- self.assertEqual(fd.encoding, "iso-8859-1")
+ for mod, encoding, _ in self.test_strings:
+ with imp.find_module('module_' + mod, self.test_path)[0] as fd:
+ self.assertEqual(fd.encoding, encoding)
def test_issue1267(self):
- fp, filename, info = imp.find_module("pydoc")
- self.assertNotEqual(fp, None)
- self.assertEqual(fp.encoding, "iso-8859-1")
- self.assertEqual(fp.tell(), 0)
- self.assertEqual(fp.readline(), '#!/usr/bin/env python\n')
- fp.close()
+ for mod, encoding, _ in self.test_strings:
+ fp, filename, info = imp.find_module('module_' + mod,
+ self.test_path)
+ with fp:
+ self.assertNotEqual(fp, None)
+ self.assertEqual(fp.encoding, encoding)
+ self.assertEqual(fp.tell(), 0)
+ self.assertEqual(fp.readline(), '# test %s encoding\n'
+ % encoding)
fp, filename, info = imp.find_module("tokenize")
- self.assertNotEqual(fp, None)
- self.assertEqual(fp.encoding, "utf-8")
- self.assertEqual(fp.tell(), 0)
- self.assertEqual(fp.readline(),
- '"""Tokenization help for Python programs.\n')
- fp.close()
+ with fp:
+ self.assertNotEqual(fp, None)
+ self.assertEqual(fp.encoding, "utf-8")
+ self.assertEqual(fp.tell(), 0)
+ self.assertEqual(fp.readline(),
+ '"""Tokenization help for Python programs.\n')
def test_issue3594(self):
temp_mod_name = 'test_imp_helper'
@@ -86,7 +101,6 @@ class ImportTests(unittest.TestCase):
# the return encoding could be uppercase or None
fs_encoding = sys.getfilesystemencoding()
- fs_encoding = fs_encoding.lower() if fs_encoding else 'ascii'
# covers utf-8 and Windows ANSI code pages
# one non-space symbol from every page
@@ -126,20 +140,21 @@ class ImportTests(unittest.TestCase):
with open(temp_mod_name + '.py', 'w') as file:
file.write('a = 1\n')
file, filename, info = imp.find_module(temp_mod_name)
- self.assertIsNotNone(file)
- self.assertTrue(filename[:-3].endswith(temp_mod_name))
- self.assertEqual(info[0], '.py')
- self.assertEqual(info[1], 'U')
- self.assertEqual(info[2], imp.PY_SOURCE)
+ with file:
+ self.assertIsNotNone(file)
+ self.assertTrue(filename[:-3].endswith(temp_mod_name))
+ self.assertEqual(info[0], '.py')
+ self.assertEqual(info[1], 'U')
+ self.assertEqual(info[2], imp.PY_SOURCE)
- mod = imp.load_module(temp_mod_name, file, filename, info)
- self.assertEqual(mod.a, 1)
- file.close()
+ mod = imp.load_module(temp_mod_name, file, filename, info)
+ self.assertEqual(mod.a, 1)
mod = imp.load_source(temp_mod_name, temp_mod_name + '.py')
self.assertEqual(mod.a, 1)
- mod = imp.load_compiled(temp_mod_name, temp_mod_name + '.pyc')
+ mod = imp.load_compiled(
+ temp_mod_name, imp.cache_from_source(temp_mod_name + '.py'))
self.assertEqual(mod.a, 1)
if not os.path.exists(test_package_name):
@@ -156,19 +171,173 @@ class ImportTests(unittest.TestCase):
support.rmtree(test_package_name)
- def test_reload(self):
- import marshal
- imp.reload(marshal)
- import string
- imp.reload(string)
- ## import sys
- ## self.assertRaises(ImportError, reload, sys)
+class ReloadTests(unittest.TestCase):
+
+ """Very basic tests to make sure that imp.reload() operates just like
+ reload()."""
+
+ def test_source(self):
+ # XXX (ncoghlan): It would be nice to use test.support.CleanImport
+ # here, but that breaks because the os module registers some
+ # handlers in copy_reg on import. Since CleanImport doesn't
+ # revert that registration, the module is left in a broken
+ # state after reversion. Reinitialising the module contents
+ # and just reverting os.environ to its previous state is an OK
+ # workaround
+ with support.EnvironmentVarGuard():
+ import os
+ imp.reload(os)
+
+ def test_extension(self):
+ with support.CleanImport('time'):
+ import time
+ imp.reload(time)
+
+ def test_builtin(self):
+ with support.CleanImport('marshal'):
+ import marshal
+ imp.reload(marshal)
+
+
+class PEP3147Tests(unittest.TestCase):
+ """Tests of PEP 3147."""
+
+ tag = imp.get_tag()
+
+ def test_cache_from_source(self):
+ # Given the path to a .py file, return the path to its PEP 3147
+ # defined .pyc file (i.e. under __pycache__).
+ self.assertEqual(
+ imp.cache_from_source('/foo/bar/baz/qux.py', True),
+ '/foo/bar/baz/__pycache__/qux.{}.pyc'.format(self.tag))
+
+ def test_cache_from_source_optimized(self):
+ # Given the path to a .py file, return the path to its PEP 3147
+ # defined .pyo file (i.e. under __pycache__).
+ self.assertEqual(
+ imp.cache_from_source('/foo/bar/baz/qux.py', False),
+ '/foo/bar/baz/__pycache__/qux.{}.pyo'.format(self.tag))
+
+ def test_cache_from_source_cwd(self):
+ self.assertEqual(imp.cache_from_source('foo.py', True),
+ os.sep.join(('__pycache__',
+ 'foo.{}.pyc'.format(self.tag))))
+
+ def test_cache_from_source_override(self):
+ # When debug_override is not None, it can be any true-ish or false-ish
+ # value.
+ self.assertEqual(
+ imp.cache_from_source('/foo/bar/baz.py', []),
+ '/foo/bar/__pycache__/baz.{}.pyo'.format(self.tag))
+ self.assertEqual(
+ imp.cache_from_source('/foo/bar/baz.py', [17]),
+ '/foo/bar/__pycache__/baz.{}.pyc'.format(self.tag))
+ # However if the bool-ishness can't be determined, the exception
+ # propagates.
+ class Bearish:
+ def __bool__(self): raise RuntimeError
+ self.assertRaises(
+ RuntimeError,
+ imp.cache_from_source, '/foo/bar/baz.py', Bearish())
+
+ @unittest.skipIf(os.altsep is None,
+ 'test meaningful only where os.altsep is defined')
+ def test_altsep_cache_from_source(self):
+ # Windows path and PEP 3147.
+ self.assertEqual(
+ imp.cache_from_source('\\foo\\bar\\baz\\qux.py', True),
+ '\\foo\\bar\\baz\\__pycache__\\qux.{}.pyc'.format(self.tag))
+
+ @unittest.skipIf(os.altsep is None,
+ 'test meaningful only where os.altsep is defined')
+ def test_altsep_and_sep_cache_from_source(self):
+ # Windows path and PEP 3147 where altsep is right of sep.
+ self.assertEqual(
+ imp.cache_from_source('\\foo\\bar/baz\\qux.py', True),
+ '\\foo\\bar/baz\\__pycache__\\qux.{}.pyc'.format(self.tag))
+
+ @unittest.skipIf(os.altsep is None,
+ 'test meaningful only where os.altsep is defined')
+ def test_sep_altsep_and_sep_cache_from_source(self):
+ # Windows path and PEP 3147 where sep is right of altsep.
+ self.assertEqual(
+ imp.cache_from_source('\\foo\\bar\\baz/qux.py', True),
+ '\\foo\\bar\\baz/__pycache__/qux.{}.pyc'.format(self.tag))
+
+ def test_source_from_cache(self):
+ # Given the path to a PEP 3147 defined .pyc file, return the path to
+ # its source. This tests the good path.
+ self.assertEqual(imp.source_from_cache(
+ '/foo/bar/baz/__pycache__/qux.{}.pyc'.format(self.tag)),
+ '/foo/bar/baz/qux.py')
+
+ def test_source_from_cache_bad_path(self):
+ # When the path to a pyc file is not in PEP 3147 format, a ValueError
+ # is raised.
+ self.assertRaises(
+ ValueError, imp.source_from_cache, '/foo/bar/bazqux.pyc')
+
+ def test_source_from_cache_no_slash(self):
+ # No slashes at all in path -> ValueError
+ self.assertRaises(
+ ValueError, imp.source_from_cache, 'foo.cpython-32.pyc')
+
+ def test_source_from_cache_too_few_dots(self):
+ # Too few dots in final path component -> ValueError
+ self.assertRaises(
+ ValueError, imp.source_from_cache, '__pycache__/foo.pyc')
+
+ def test_source_from_cache_too_many_dots(self):
+ # Too many dots in final path component -> ValueError
+ self.assertRaises(
+ ValueError, imp.source_from_cache,
+ '__pycache__/foo.cpython-32.foo.pyc')
+
+ def test_source_from_cache_no__pycache__(self):
+ # Another problem with the path -> ValueError
+ self.assertRaises(
+ ValueError, imp.source_from_cache,
+ '/foo/bar/foo.cpython-32.foo.pyc')
+
+ def test_package___file__(self):
+ # Test that a package's __file__ points to the right source directory.
+ os.mkdir('pep3147')
+ sys.path.insert(0, os.curdir)
+ def cleanup():
+ if sys.path[0] == os.curdir:
+ del sys.path[0]
+ shutil.rmtree('pep3147')
+ self.addCleanup(cleanup)
+ # Touch the __init__.py file.
+ with open('pep3147/__init__.py', 'w'):
+ pass
+ m = __import__('pep3147')
+ # Ensure we load the pyc file.
+ support.forget('pep3147')
+ m = __import__('pep3147')
+ self.assertEqual(m.__file__,
+ os.sep.join(('.', 'pep3147', '__init__.py')))
+
+
+class NullImporterTests(unittest.TestCase):
+ @unittest.skipIf(support.TESTFN_UNENCODABLE is None,
+ "Need an undecodeable filename")
+ def test_unencodeable(self):
+ name = support.TESTFN_UNENCODABLE
+ os.mkdir(name)
+ try:
+ self.assertRaises(ImportError, imp.NullImporter, name)
+ finally:
+ os.rmdir(name)
def test_main():
tests = [
ImportTests,
- ]
+ PEP3147Tests,
+ ReloadTests,
+ NullImporterTests,
+ ]
try:
import _thread
except ImportError:
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 6f935c7581..cf17c9615d 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -1,3 +1,4 @@
+import builtins
import imp
from importlib.test.import_ import test_relative_imports
from importlib.test.import_ import util as importlib_util
@@ -8,12 +9,12 @@ import random
import stat
import sys
import unittest
-import warnings
import textwrap
from test.support import (
- EnvironmentVarGuard, TESTFN, forget, is_jython,
- rmtree, run_unittest, unlink, unload)
+ EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython,
+ make_legacy_pyc, rmtree, run_unittest, swap_attr, swap_item, temp_umask,
+ unlink, unload)
from test import script_helper
@@ -37,12 +38,8 @@ class ImportTests(unittest.TestCase):
def test_case_sensitivity(self):
# Brief digression to test that import is case-sensitive: if we got
# this far, we know for sure that "random" exists.
- try:
+ with self.assertRaises(ImportError):
import RAnDoM
- except ImportError:
- pass
- else:
- self.fail("import of RAnDoM should have failed (case mismatch)")
def test_double_const(self):
# Another brief digression to test the accuracy of manifest float
@@ -99,31 +96,29 @@ class ImportTests(unittest.TestCase):
def test_execute_bit_not_copied(self):
# Issue 6070: under posix .pyc files got their execute bit set if
# the .py file had the execute bit set, but they aren't executable.
- oldmask = os.umask(0o022)
- sys.path.insert(0, os.curdir)
- try:
- fname = TESTFN + os.extsep + "py"
- f = open(fname, 'w').close()
- os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
- stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
- __import__(TESTFN)
- fn = fname + 'c'
- if not os.path.exists(fn):
- fn = fname + 'o'
- if not os.path.exists(fn): raise TestFailed("__import__ did "
- "not result in creation of either a .pyc or .pyo file")
- s = os.stat(fn)
- self.assertEqual(stat.S_IMODE(s.st_mode),
- stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
- finally:
- os.umask(oldmask)
- remove_files(TESTFN)
- if TESTFN in sys.modules: del sys.modules[TESTFN]
- del sys.path[0]
+ with temp_umask(0o022):
+ sys.path.insert(0, os.curdir)
+ try:
+ fname = TESTFN + os.extsep + "py"
+ open(fname, 'w').close()
+ os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
+ stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
+ __import__(TESTFN)
+ fn = imp.cache_from_source(fname)
+ if not os.path.exists(fn):
+ self.fail("__import__ did not result in creation of "
+ "either a .pyc or .pyo file")
+ s = os.stat(fn)
+ self.assertEqual(
+ stat.S_IMODE(s.st_mode),
+ stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
+ finally:
+ del sys.path[0]
+ remove_files(TESTFN)
+ unload(TESTFN)
def test_imp_module(self):
# Verify that the imp module can correctly load and find .py files
- import imp, os
# XXX (ncoghlan): It would be nice to use support.CleanImport
# here, but that breaks because the os module registers some
# handlers in copy_reg on import. Since CleanImport doesn't
@@ -135,6 +130,7 @@ class ImportTests(unittest.TestCase):
orig_getenv = os.getenv
with EnvironmentVarGuard():
x = imp.find_module("os")
+ self.addCleanup(x[0].close)
new_os = imp.load_module("os", *x)
self.assertIs(os, new_os)
self.assertIs(orig_path, new_os.path)
@@ -153,6 +149,7 @@ class ImportTests(unittest.TestCase):
try:
# Compile & remove .py file; we only need .pyc (or .pyo).
+ # Bytecode must be relocated from the PEP 3147 bytecode-only location.
py_compile.compile(filename)
finally:
unlink(filename)
@@ -161,6 +158,7 @@ class ImportTests(unittest.TestCase):
sys.path.append('')
try:
+ make_legacy_pyc(filename)
# This used to crash.
exec('import ' + module)
finally:
@@ -199,13 +197,6 @@ class ImportTests(unittest.TestCase):
import test.support as y
self.assertTrue(y is test.support, y.__name__)
- def test_import_initless_directory_warning(self):
- with warnings.catch_warnings():
- # Just a random non-package directory we always expect to be
- # somewhere in sys.path...
- warnings.simplefilter('error', ImportWarning)
- self.assertRaises(ImportWarning, __import__, "site-packages")
-
def test_failing_reload(self):
# A failing reload should leave the module object in sys.modules.
source = TESTFN + os.extsep + "py"
@@ -256,6 +247,7 @@ class ImportTests(unittest.TestCase):
self.assertTrue(mod.__file__.endswith('.py'))
os.remove(source)
del sys.modules[TESTFN]
+ make_legacy_pyc(source)
mod = __import__(TESTFN)
base, ext = os.path.splitext(mod.__file__)
self.assertIn(ext, ('.pyc', '.pyo'))
@@ -276,15 +268,23 @@ class ImportTests(unittest.TestCase):
import test.support as y
self.assertIs(y, test.support, y.__name__)
+ def test_import_initless_directory_warning(self):
+ with check_warnings(('', ImportWarning)):
+ # Just a random non-package directory we always expect to be
+ # somewhere in sys.path...
+ self.assertRaises(ImportError, __import__, "site-packages")
+
def test_import_by_filename(self):
path = os.path.abspath(TESTFN)
+ encoding = sys.getfilesystemencoding()
try:
+ path.encode(encoding)
+ except UnicodeEncodeError:
+ self.skipTest('path is not encodable to {}'.format(encoding))
+ with self.assertRaises(ImportError) as c:
__import__(path)
- except ImportError as err:
- self.assertEqual("Import by filename is not supported.",
- err.args[0])
- else:
- self.fail("import by path didn't raise an exception")
+ self.assertEqual("Import by filename is not supported.",
+ c.exception.args[0])
def test_import_in_del_does_not_crash(self):
# Issue 4236
@@ -315,7 +315,7 @@ func_filename = func.__code__.co_filename
"""
dir_name = os.path.abspath(TESTFN)
file_name = os.path.join(dir_name, module_name) + os.extsep + "py"
- compiled_name = file_name + ("c" if __debug__ else "o")
+ compiled_name = imp.cache_from_source(file_name)
def setUp(self):
self.sys_path = sys.path[:]
@@ -362,8 +362,9 @@ func_filename = func.__code__.co_filename
target = "another_module.py"
py_compile.compile(self.file_name, dfile=target)
os.remove(self.file_name)
+ pyc_file = make_legacy_pyc(self.file_name)
mod = self.import_module()
- self.assertEqual(mod.module_filename, self.compiled_name)
+ self.assertEqual(mod.module_filename, pyc_file)
self.assertEqual(mod.code_filename, target)
self.assertEqual(mod.func_filename, target)
@@ -481,6 +482,158 @@ class RelativeImportTests(unittest.TestCase):
"implicit absolute import")
+class OverridingImportBuiltinTests(unittest.TestCase):
+ def test_override_builtin(self):
+ # Test that overriding builtins.__import__ can bypass sys.modules.
+ import os
+
+ def foo():
+ import os
+ return os
+ self.assertEqual(foo(), os) # Quick sanity check.
+
+ with swap_attr(builtins, "__import__", lambda *x: 5):
+ self.assertEqual(foo(), 5)
+
+ # Test what happens when we shadow __import__ in globals(); this
+ # currently does not impact the import process, but if this changes,
+ # other code will need to change, so keep this test as a tripwire.
+ with swap_item(globals(), "__import__", lambda *x: 5):
+ self.assertEqual(foo(), os)
+
+
+class PycacheTests(unittest.TestCase):
+ # Test the various PEP 3147 related behaviors.
+
+ tag = imp.get_tag()
+
+ def _clean(self):
+ forget(TESTFN)
+ rmtree('__pycache__')
+ unlink(self.source)
+
+ def setUp(self):
+ self.source = TESTFN + '.py'
+ self._clean()
+ with open(self.source, 'w') as fp:
+ print('# This is a test file written by test_import.py', file=fp)
+ sys.path.insert(0, os.curdir)
+
+ def tearDown(self):
+ assert sys.path[0] == os.curdir, 'Unexpected sys.path[0]'
+ del sys.path[0]
+ self._clean()
+
+ def test_import_pyc_path(self):
+ self.assertFalse(os.path.exists('__pycache__'))
+ __import__(TESTFN)
+ self.assertTrue(os.path.exists('__pycache__'))
+ self.assertTrue(os.path.exists(os.path.join(
+ '__pycache__', '{}.{}.py{}'.format(
+ TESTFN, self.tag, __debug__ and 'c' or 'o'))))
+
+ @unittest.skipUnless(os.name == 'posix',
+ "test meaningful only on posix systems")
+ def test_unwritable_directory(self):
+ # When the umask causes the new __pycache__ directory to be
+ # unwritable, the import still succeeds but no .pyc file is written.
+ with temp_umask(0o222):
+ __import__(TESTFN)
+ self.assertTrue(os.path.exists('__pycache__'))
+ self.assertFalse(os.path.exists(os.path.join(
+ '__pycache__', '{}.{}.pyc'.format(TESTFN, self.tag))))
+
+ def test_missing_source(self):
+ # With PEP 3147 cache layout, removing the source but leaving the pyc
+ # file does not satisfy the import.
+ __import__(TESTFN)
+ pyc_file = imp.cache_from_source(self.source)
+ self.assertTrue(os.path.exists(pyc_file))
+ os.remove(self.source)
+ forget(TESTFN)
+ self.assertRaises(ImportError, __import__, TESTFN)
+
+ def test_missing_source_legacy(self):
+ # Like test_missing_source() except that for backward compatibility,
+ # when the pyc file lives where the py file would have been (and named
+ # without the tag), it is importable. The __file__ of the imported
+ # module is the pyc location.
+ __import__(TESTFN)
+ # pyc_file gets removed in _clean() via tearDown().
+ pyc_file = make_legacy_pyc(self.source)
+ os.remove(self.source)
+ unload(TESTFN)
+ m = __import__(TESTFN)
+ self.assertEqual(m.__file__,
+ os.path.join(os.curdir, os.path.relpath(pyc_file)))
+
+ def test___cached__(self):
+ # Modules now also have an __cached__ that points to the pyc file.
+ m = __import__(TESTFN)
+ pyc_file = imp.cache_from_source(TESTFN + '.py')
+ self.assertEqual(m.__cached__, os.path.join(os.curdir, pyc_file))
+
+ def test___cached___legacy_pyc(self):
+ # Like test___cached__() except that for backward compatibility,
+ # when the pyc file lives where the py file would have been (and named
+ # without the tag), it is importable. The __cached__ of the imported
+ # module is the pyc location.
+ __import__(TESTFN)
+ # pyc_file gets removed in _clean() via tearDown().
+ pyc_file = make_legacy_pyc(self.source)
+ os.remove(self.source)
+ unload(TESTFN)
+ m = __import__(TESTFN)
+ self.assertEqual(m.__cached__,
+ os.path.join(os.curdir, os.path.relpath(pyc_file)))
+
+ def test_package___cached__(self):
+ # Like test___cached__ but for packages.
+ def cleanup():
+ rmtree('pep3147')
+ os.mkdir('pep3147')
+ self.addCleanup(cleanup)
+ # Touch the __init__.py
+ with open(os.path.join('pep3147', '__init__.py'), 'w'):
+ pass
+ with open(os.path.join('pep3147', 'foo.py'), 'w'):
+ pass
+ unload('pep3147.foo')
+ unload('pep3147')
+ m = __import__('pep3147.foo')
+ init_pyc = imp.cache_from_source(
+ os.path.join('pep3147', '__init__.py'))
+ self.assertEqual(m.__cached__, os.path.join(os.curdir, init_pyc))
+ foo_pyc = imp.cache_from_source(os.path.join('pep3147', 'foo.py'))
+ self.assertEqual(sys.modules['pep3147.foo'].__cached__,
+ os.path.join(os.curdir, foo_pyc))
+
+ def test_package___cached___from_pyc(self):
+ # Like test___cached__ but ensuring __cached__ when imported from a
+ # PEP 3147 pyc file.
+ def cleanup():
+ rmtree('pep3147')
+ os.mkdir('pep3147')
+ self.addCleanup(cleanup)
+ unload('pep3147.foo')
+ unload('pep3147')
+ # Touch the __init__.py
+ with open(os.path.join('pep3147', '__init__.py'), 'w'):
+ pass
+ with open(os.path.join('pep3147', 'foo.py'), 'w'):
+ pass
+ m = __import__('pep3147.foo')
+ unload('pep3147.foo')
+ unload('pep3147')
+ m = __import__('pep3147.foo')
+ init_pyc = imp.cache_from_source(
+ os.path.join('pep3147', '__init__.py'))
+ self.assertEqual(m.__cached__, os.path.join(os.curdir, init_pyc))
+ foo_pyc = imp.cache_from_source(os.path.join('pep3147', 'foo.py'))
+ self.assertEqual(sys.modules['pep3147.foo'].__cached__,
+ os.path.join(os.curdir, foo_pyc))
+
+
class RelativeImportFromImportlibTests(test_relative_imports.RelativeImports):
def setUp(self):
@@ -492,8 +645,9 @@ class RelativeImportFromImportlibTests(test_relative_imports.RelativeImports):
def test_main(verbose=None):
- run_unittest(ImportTests,
+ run_unittest(ImportTests, PycacheTests,
PycRewritingTests, PathsTests, RelativeImportTests,
+ OverridingImportBuiltinTests,
RelativeImportFromImportlibTests)
diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py
index 1da30b7c77..ec6730e9ba 100644
--- a/Lib/test/test_importhooks.py
+++ b/Lib/test/test_importhooks.py
@@ -221,15 +221,9 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
def testBlocker(self):
mname = "exceptions" # an arbitrary harmless builtin module
- if mname in sys.modules:
- del sys.modules[mname]
+ support.unload(mname)
sys.meta_path.append(ImportBlocker(mname))
- try:
- __import__(mname)
- except ImportError:
- pass
- else:
- self.fail("'%s' was not supposed to be importable" % mname)
+ self.assertRaises(ImportError, __import__, mname)
def testImpWrapper(self):
i = ImpWrapper()
diff --git a/Lib/test/test_importlib.py b/Lib/test/test_importlib.py
index cd13e329ed..6ed05859c9 100644
--- a/Lib/test/test_importlib.py
+++ b/Lib/test/test_importlib.py
@@ -1,9 +1,4 @@
-from test.support import run_unittest
-import importlib.test
-
-
-def test_main():
- run_unittest(importlib.test.test_suite('importlib.test'))
+from importlib.test.__main__ import test_main
if __name__ == '__main__':
diff --git a/Lib/test/test_index.py b/Lib/test/test_index.py
index ae905c2663..7a94af1b0a 100644
--- a/Lib/test/test_index.py
+++ b/Lib/test/test_index.py
@@ -2,13 +2,8 @@ import unittest
from test import support
import operator
maxsize = support.MAX_Py_ssize_t
-minsize = -maxsize-1
-class oldstyle:
- def __index__(self):
- return self.ind
-
-class newstyle(object):
+class newstyle:
def __index__(self):
return self.ind
@@ -16,13 +11,9 @@ class TrapInt(int):
def __index__(self):
return self
-class TrapLong(int):
- def __index__(self):
- return self
-
class BaseTestCase(unittest.TestCase):
def setUp(self):
- self.o = oldstyle()
+ self.o = newstyle()
self.n = newstyle()
def test_basic(self):
@@ -48,13 +39,13 @@ class BaseTestCase(unittest.TestCase):
self.assertEqual(-7 .__index__(), -7)
self.assertEqual(self.o.__index__(), 4)
self.assertEqual(self.n.__index__(), 5)
+ self.assertEqual(True.__index__(), 1)
+ self.assertEqual(False.__index__(), 0)
def test_subclasses(self):
r = list(range(10))
self.assertEqual(r[TrapInt(5):TrapInt(10)], r[5:10])
- self.assertEqual(r[TrapLong(5):TrapLong(10)], r[5:10])
self.assertEqual(slice(TrapInt()).indices(0), (0,0,1))
- self.assertEqual(slice(TrapLong(0)).indices(0), (0,0,1))
def test_error(self):
self.o.ind = 'dumb'
@@ -69,9 +60,9 @@ class SeqTestCase(unittest.TestCase):
# This test case isn't run directly. It just defines common tests
# to the different sequence types below
def setUp(self):
- self.o = oldstyle()
+ self.o = newstyle()
self.n = newstyle()
- self.o2 = oldstyle()
+ self.o2 = newstyle()
self.n2 = newstyle()
def test_index(self):
@@ -88,6 +79,21 @@ class SeqTestCase(unittest.TestCase):
self.assertEqual(self.seq[self.o:self.o2], self.seq[1:3])
self.assertEqual(self.seq[self.n:self.n2], self.seq[2:4])
+ def test_slice_bug7532(self):
+ seqlen = len(self.seq)
+ self.o.ind = int(seqlen * 1.5)
+ self.n.ind = seqlen + 2
+ self.assertEqual(self.seq[self.o:], self.seq[0:0])
+ self.assertEqual(self.seq[:self.o], self.seq)
+ self.assertEqual(self.seq[self.n:], self.seq[0:0])
+ self.assertEqual(self.seq[:self.n], self.seq)
+ self.o2.ind = -seqlen - 2
+ self.n2.ind = -int(seqlen * 1.5)
+ self.assertEqual(self.seq[self.o2:], self.seq)
+ self.assertEqual(self.seq[:self.o2], self.seq[0:0])
+ self.assertEqual(self.seq[self.n2:], self.seq)
+ self.assertEqual(self.seq[:self.n2], self.seq[0:0])
+
def test_repeat(self):
self.o.ind = 3
self.n.ind = 2
@@ -108,7 +114,6 @@ class SeqTestCase(unittest.TestCase):
def test_subclasses(self):
self.assertEqual(self.seq[TrapInt()], self.seq[0])
- self.assertEqual(self.seq[TrapLong()], self.seq[0])
def test_error(self):
self.o.ind = 'dumb'
@@ -151,18 +156,56 @@ class ListTestCase(SeqTestCase):
lst = [5, 6, 7, 8, 9, 11]
l2 = lst.__imul__(self.n)
- self.assertTrue(l2 is lst)
+ self.assertIs(l2, lst)
self.assertEqual(lst, [5, 6, 7, 8, 9, 11] * 3)
+class NewSeq:
+
+ def __init__(self, iterable):
+ self._list = list(iterable)
+
+ def __repr__(self):
+ return repr(self._list)
+
+ def __eq__(self, other):
+ return self._list == other
+
+ def __len__(self):
+ return len(self._list)
+
+ def __mul__(self, n):
+ return self.__class__(self._list*n)
+ __rmul__ = __mul__
+
+ def __getitem__(self, index):
+ return self._list[index]
+
+
class TupleTestCase(SeqTestCase):
seq = (0,10,20,30,40,50)
+class ByteArrayTestCase(SeqTestCase):
+ seq = bytearray(b"this is a test")
+
+class BytesTestCase(SeqTestCase):
+ seq = b"this is a test"
+
class StringTestCase(SeqTestCase):
seq = "this is a test"
-class UnicodeTestCase(SeqTestCase):
- seq = "this is a test"
+class NewSeqTestCase(SeqTestCase):
+ seq = NewSeq((0,10,20,30,40,50))
+
+
+
+class RangeTestCase(unittest.TestCase):
+
+ def test_range(self):
+ n = newstyle()
+ n.ind = 5
+ self.assertEqual(range(1, 20)[n], 6)
+ self.assertEqual(range(1, 20).__getitem__(n), 6)
class OverflowTestCase(unittest.TestCase):
@@ -176,9 +219,9 @@ class OverflowTestCase(unittest.TestCase):
self.assertEqual(self.neg.__index__(), self.neg)
def test_getitem(self):
- class GetItem(object):
+ class GetItem:
def __len__(self):
- return sys.maxsize
+ assert False, "__len__ should not be invoked"
def __getitem__(self, key):
return key
x = GetItem()
@@ -186,6 +229,8 @@ class OverflowTestCase(unittest.TestCase):
self.assertEqual(x[self.neg], self.neg)
self.assertEqual(x[self.neg:self.pos].indices(maxsize),
(0, maxsize, 1))
+ self.assertEqual(x[self.neg:self.pos:1].indices(maxsize),
+ (0, maxsize, 1))
def test_sequence_repeat(self):
self.assertRaises(OverflowError, lambda: "a" * self.pos)
@@ -197,8 +242,11 @@ def test_main():
BaseTestCase,
ListTestCase,
TupleTestCase,
+ BytesTestCase,
+ ByteArrayTestCase,
StringTestCase,
- UnicodeTestCase,
+ NewSeqTestCase,
+ RangeTestCase,
OverflowTestCase,
)
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 34e0a9a824..331d247500 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -1,3 +1,4 @@
+import re
import sys
import types
import unittest
@@ -5,9 +6,11 @@ import inspect
import linecache
import datetime
import collections
+import os
+import shutil
from os.path import normcase
-from test.support import TESTFN, run_unittest
+from test.support import run_unittest, TESTFN, DirsOnSysPath
from test import inspect_fodder as mod
from test import inspect_fodder2 as mod2
@@ -118,8 +121,8 @@ class TestPredicates(IsTestBase):
x = C()
x.a = 42
members = dict(inspect.getmembers(x))
- self.assertTrue('a' in members)
- self.assertTrue('b' not in members)
+ self.assertIn('a', members)
+ self.assertNotIn('b', members)
def test_isabstract(self):
from abc import ABCMeta, abstractmethod
@@ -193,12 +196,12 @@ class TestInterpreterStack(IsTestBase):
class GetSourceBase(unittest.TestCase):
# Subclasses must override.
- fodderFile = None
+ fodderModule = None
def __init__(self, *args, **kwargs):
unittest.TestCase.__init__(self, *args, **kwargs)
- with open(inspect.getsourcefile(self.fodderFile)) as fp:
+ with open(inspect.getsourcefile(self.fodderModule)) as fp:
self.source = fp.read()
def sourcerange(self, top, bottom):
@@ -210,7 +213,7 @@ class GetSourceBase(unittest.TestCase):
self.sourcerange(top, bottom))
class TestRetrievingSourceCode(GetSourceBase):
- fodderFile = mod
+ fodderModule = mod
def test_getclasses(self):
classes = inspect.getmembers(mod, inspect.isclass)
@@ -237,6 +240,8 @@ class TestRetrievingSourceCode(GetSourceBase):
self.assertEqual(functions, [('eggs', mod.eggs),
('spam', mod.spam)])
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_getdoc(self):
self.assertEqual(inspect.getdoc(mod), 'A module docstring.')
self.assertEqual(inspect.getdoc(mod.StupidGit),
@@ -294,7 +299,7 @@ class TestRetrievingSourceCode(GetSourceBase):
inspect.getmodule(compile('a=10','','single'))
class TestDecorators(GetSourceBase):
- fodderFile = mod2
+ fodderModule = mod2
def test_wrapped_decorator(self):
self.assertSourceEqual(mod2.wrapped, 14, 17)
@@ -303,7 +308,7 @@ class TestDecorators(GetSourceBase):
self.assertSourceEqual(mod2.gone, 9, 10)
class TestOneliners(GetSourceBase):
- fodderFile = mod2
+ fodderModule = mod2
def test_oneline_lambda(self):
# Test inspect.getsource with a one-line lambda function.
self.assertSourceEqual(mod2.oll, 25, 25)
@@ -345,7 +350,7 @@ class TestOneliners(GetSourceBase):
self.assertSourceEqual(mod2.anonymous, 55, 55)
class TestBuggyCases(GetSourceBase):
- fodderFile = mod2
+ fodderModule = mod2
def test_with_comment(self):
self.assertSourceEqual(mod2.with_comment, 58, 59)
@@ -385,6 +390,24 @@ class TestBuggyCases(GetSourceBase):
self.assertEqual(inspect.findsource(co), (lines,0))
self.assertEqual(inspect.getsource(co), lines[0])
+class TestNoEOL(GetSourceBase):
+ def __init__(self, *args, **kwargs):
+ self.tempdir = TESTFN + '_dir'
+ os.mkdir(self.tempdir)
+ with open(os.path.join(self.tempdir,
+ 'inspect_fodder3%spy' % os.extsep), 'w') as f:
+ f.write("class X:\n pass # No EOL")
+ with DirsOnSysPath(self.tempdir):
+ import inspect_fodder3 as mod3
+ self.fodderModule = mod3
+ GetSourceBase.__init__(self, *args, **kwargs)
+
+ def tearDown(self):
+ shutil.rmtree(self.tempdir)
+
+ def test_class(self):
+ self.assertSourceEqual(self.fodderModule.X, 1, 2)
+
# Helper for testing classify_class_attrs.
def attrs_wo_objs(cls):
return [t[:3] for t in inspect.classify_class_attrs(cls)]
@@ -486,25 +509,25 @@ class TestClassesAndFunctions(unittest.TestCase):
datablob = '1'
attrs = attrs_wo_objs(A)
- self.assertTrue(('s', 'static method', A) in attrs, 'missing static method')
- self.assertTrue(('c', 'class method', A) in attrs, 'missing class method')
- self.assertTrue(('p', 'property', A) in attrs, 'missing property')
- self.assertTrue(('m', 'method', A) in attrs,
- 'missing plain method: %r' % attrs)
- self.assertTrue(('m1', 'method', A) in attrs, 'missing plain method')
- self.assertTrue(('datablob', 'data', A) in attrs, 'missing data')
+ self.assertIn(('s', 'static method', A), attrs, 'missing static method')
+ self.assertIn(('c', 'class method', A), attrs, 'missing class method')
+ self.assertIn(('p', 'property', A), attrs, 'missing property')
+ self.assertIn(('m', 'method', A), attrs,
+ 'missing plain method: %r' % attrs)
+ self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
+ self.assertIn(('datablob', 'data', A), attrs, 'missing data')
class B(A):
def m(self): pass
attrs = attrs_wo_objs(B)
- self.assertTrue(('s', 'static method', A) in attrs, 'missing static method')
- self.assertTrue(('c', 'class method', A) in attrs, 'missing class method')
- self.assertTrue(('p', 'property', A) in attrs, 'missing property')
- self.assertTrue(('m', 'method', B) in attrs, 'missing plain method')
- self.assertTrue(('m1', 'method', A) in attrs, 'missing plain method')
- self.assertTrue(('datablob', 'data', A) in attrs, 'missing data')
+ self.assertIn(('s', 'static method', A), attrs, 'missing static method')
+ self.assertIn(('c', 'class method', A), attrs, 'missing class method')
+ self.assertIn(('p', 'property', A), attrs, 'missing property')
+ self.assertIn(('m', 'method', B), attrs, 'missing plain method')
+ self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
+ self.assertIn(('datablob', 'data', A), attrs, 'missing data')
class C(A):
@@ -513,29 +536,485 @@ class TestClassesAndFunctions(unittest.TestCase):
def c(self): pass
attrs = attrs_wo_objs(C)
- self.assertTrue(('s', 'static method', A) in attrs, 'missing static method')
- self.assertTrue(('c', 'method', C) in attrs, 'missing plain method')
- self.assertTrue(('p', 'property', A) in attrs, 'missing property')
- self.assertTrue(('m', 'method', C) in attrs, 'missing plain method')
- self.assertTrue(('m1', 'method', A) in attrs, 'missing plain method')
- self.assertTrue(('datablob', 'data', A) in attrs, 'missing data')
+ self.assertIn(('s', 'static method', A), attrs, 'missing static method')
+ self.assertIn(('c', 'method', C), attrs, 'missing plain method')
+ self.assertIn(('p', 'property', A), attrs, 'missing property')
+ self.assertIn(('m', 'method', C), attrs, 'missing plain method')
+ self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
+ self.assertIn(('datablob', 'data', A), attrs, 'missing data')
class D(B, C):
def m1(self): pass
attrs = attrs_wo_objs(D)
- self.assertTrue(('s', 'static method', A) in attrs, 'missing static method')
- self.assertTrue(('c', 'method', C) in attrs, 'missing plain method')
- self.assertTrue(('p', 'property', A) in attrs, 'missing property')
- self.assertTrue(('m', 'method', B) in attrs, 'missing plain method')
- self.assertTrue(('m1', 'method', D) in attrs, 'missing plain method')
- self.assertTrue(('datablob', 'data', A) in attrs, 'missing data')
+ self.assertIn(('s', 'static method', A), attrs, 'missing static method')
+ self.assertIn(('c', 'method', C), attrs, 'missing plain method')
+ self.assertIn(('p', 'property', A), attrs, 'missing property')
+ self.assertIn(('m', 'method', B), attrs, 'missing plain method')
+ self.assertIn(('m1', 'method', D), attrs, 'missing plain method')
+ self.assertIn(('datablob', 'data', A), attrs, 'missing data')
+
+class TestGetcallargsFunctions(unittest.TestCase):
+
+ def assertEqualCallArgs(self, func, call_params_string, locs=None):
+ locs = dict(locs or {}, func=func)
+ r1 = eval('func(%s)' % call_params_string, None, locs)
+ r2 = eval('inspect.getcallargs(func, %s)' % call_params_string, None,
+ locs)
+ self.assertEqual(r1, r2)
+
+ def assertEqualException(self, func, call_param_string, locs=None):
+ locs = dict(locs or {}, func=func)
+ try:
+ eval('func(%s)' % call_param_string, None, locs)
+ except Exception as e:
+ ex1 = e
+ else:
+ self.fail('Exception not raised')
+ try:
+ eval('inspect.getcallargs(func, %s)' % call_param_string, None,
+ locs)
+ except Exception as e:
+ ex2 = e
+ else:
+ self.fail('Exception not raised')
+ self.assertIs(type(ex1), type(ex2))
+ self.assertEqual(str(ex1), str(ex2))
+ del ex1, ex2
+
+ def makeCallable(self, signature):
+ """Create a function that returns its locals()"""
+ code = "lambda %s: locals()"
+ return eval(code % signature)
+
+ def test_plain(self):
+ f = self.makeCallable('a, b=1')
+ self.assertEqualCallArgs(f, '2')
+ self.assertEqualCallArgs(f, '2, 3')
+ self.assertEqualCallArgs(f, 'a=2')
+ self.assertEqualCallArgs(f, 'b=3, a=2')
+ self.assertEqualCallArgs(f, '2, b=3')
+ # expand *iterable / **mapping
+ self.assertEqualCallArgs(f, '*(2,)')
+ self.assertEqualCallArgs(f, '*[2]')
+ self.assertEqualCallArgs(f, '*(2, 3)')
+ self.assertEqualCallArgs(f, '*[2, 3]')
+ self.assertEqualCallArgs(f, '**{"a":2}')
+ self.assertEqualCallArgs(f, 'b=3, **{"a":2}')
+ self.assertEqualCallArgs(f, '2, **{"b":3}')
+ self.assertEqualCallArgs(f, '**{"b":3, "a":2}')
+ # expand UserList / UserDict
+ self.assertEqualCallArgs(f, '*collections.UserList([2])')
+ self.assertEqualCallArgs(f, '*collections.UserList([2, 3])')
+ self.assertEqualCallArgs(f, '**collections.UserDict(a=2)')
+ self.assertEqualCallArgs(f, '2, **collections.UserDict(b=3)')
+ self.assertEqualCallArgs(f, 'b=2, **collections.UserDict(a=3)')
+
+ def test_varargs(self):
+ f = self.makeCallable('a, b=1, *c')
+ self.assertEqualCallArgs(f, '2')
+ self.assertEqualCallArgs(f, '2, 3')
+ self.assertEqualCallArgs(f, '2, 3, 4')
+ self.assertEqualCallArgs(f, '*(2,3,4)')
+ self.assertEqualCallArgs(f, '2, *[3,4]')
+ self.assertEqualCallArgs(f, '2, 3, *collections.UserList([4])')
+
+ def test_varkw(self):
+ f = self.makeCallable('a, b=1, **c')
+ self.assertEqualCallArgs(f, 'a=2')
+ self.assertEqualCallArgs(f, '2, b=3, c=4')
+ self.assertEqualCallArgs(f, 'b=3, a=2, c=4')
+ self.assertEqualCallArgs(f, 'c=4, **{"a":2, "b":3}')
+ self.assertEqualCallArgs(f, '2, c=4, **{"b":3}')
+ self.assertEqualCallArgs(f, 'b=2, **{"a":3, "c":4}')
+ self.assertEqualCallArgs(f, '**collections.UserDict(a=2, b=3, c=4)')
+ self.assertEqualCallArgs(f, '2, c=4, **collections.UserDict(b=3)')
+ self.assertEqualCallArgs(f, 'b=2, **collections.UserDict(a=3, c=4)')
+
+ def test_keyword_only(self):
+ f = self.makeCallable('a=3, *, c, d=2')
+ self.assertEqualCallArgs(f, 'c=3')
+ self.assertEqualCallArgs(f, 'c=3, a=3')
+ self.assertEqualCallArgs(f, 'a=2, c=4')
+ self.assertEqualCallArgs(f, '4, c=4')
+ self.assertEqualException(f, '')
+ self.assertEqualException(f, '3')
+ self.assertEqualException(f, 'a=3')
+ self.assertEqualException(f, 'd=4')
+
+ def test_multiple_features(self):
+ f = self.makeCallable('a, b=2, *f, **g')
+ self.assertEqualCallArgs(f, '2, 3, 7')
+ self.assertEqualCallArgs(f, '2, 3, x=8')
+ self.assertEqualCallArgs(f, '2, 3, x=8, *[(4,[5,6]), 7]')
+ self.assertEqualCallArgs(f, '2, x=8, *[3, (4,[5,6]), 7], y=9')
+ self.assertEqualCallArgs(f, 'x=8, *[2, 3, (4,[5,6])], y=9')
+ self.assertEqualCallArgs(f, 'x=8, *collections.UserList('
+ '[2, 3, (4,[5,6])]), **{"y":9, "z":10}')
+ self.assertEqualCallArgs(f, '2, x=8, *collections.UserList([3, '
+ '(4,[5,6])]), **collections.UserDict('
+ 'y=9, z=10)')
+
+ def test_errors(self):
+ f0 = self.makeCallable('')
+ f1 = self.makeCallable('a, b')
+ f2 = self.makeCallable('a, b=1')
+ # f0 takes no arguments
+ self.assertEqualException(f0, '1')
+ self.assertEqualException(f0, 'x=1')
+ self.assertEqualException(f0, '1,x=1')
+ # f1 takes exactly 2 arguments
+ self.assertEqualException(f1, '')
+ self.assertEqualException(f1, '1')
+ self.assertEqualException(f1, 'a=2')
+ self.assertEqualException(f1, 'b=3')
+ # f2 takes at least 1 argument
+ self.assertEqualException(f2, '')
+ self.assertEqualException(f2, 'b=3')
+ for f in f1, f2:
+ # f1/f2 takes exactly/at most 2 arguments
+ self.assertEqualException(f, '2, 3, 4')
+ self.assertEqualException(f, '1, 2, 3, a=1')
+ self.assertEqualException(f, '2, 3, 4, c=5')
+ self.assertEqualException(f, '2, 3, 4, a=1, c=5')
+ # f got an unexpected keyword argument
+ self.assertEqualException(f, 'c=2')
+ self.assertEqualException(f, '2, c=3')
+ self.assertEqualException(f, '2, 3, c=4')
+ self.assertEqualException(f, '2, c=4, b=3')
+ self.assertEqualException(f, '**{u"\u03c0\u03b9": 4}')
+ # f got multiple values for keyword argument
+ self.assertEqualException(f, '1, a=2')
+ self.assertEqualException(f, '1, **{"a":2}')
+ self.assertEqualException(f, '1, 2, b=3')
+ # XXX: Python inconsistency
+ # - for functions and bound methods: unexpected keyword 'c'
+ # - for unbound methods: multiple values for keyword 'a'
+ #self.assertEqualException(f, '1, c=3, a=2')
+
+class TestGetcallargsMethods(TestGetcallargsFunctions):
+
+ def setUp(self):
+ class Foo(object):
+ pass
+ self.cls = Foo
+ self.inst = Foo()
+
+ def makeCallable(self, signature):
+ assert 'self' not in signature
+ mk = super(TestGetcallargsMethods, self).makeCallable
+ self.cls.method = mk('self, ' + signature)
+ return self.inst.method
+
+class TestGetcallargsUnboundMethods(TestGetcallargsMethods):
+
+ def makeCallable(self, signature):
+ super(TestGetcallargsUnboundMethods, self).makeCallable(signature)
+ return self.cls.method
+
+ def assertEqualCallArgs(self, func, call_params_string, locs=None):
+ return super(TestGetcallargsUnboundMethods, self).assertEqualCallArgs(
+ *self._getAssertEqualParams(func, call_params_string, locs))
+
+ def assertEqualException(self, func, call_params_string, locs=None):
+ return super(TestGetcallargsUnboundMethods, self).assertEqualException(
+ *self._getAssertEqualParams(func, call_params_string, locs))
+
+ def _getAssertEqualParams(self, func, call_params_string, locs=None):
+ assert 'inst' not in call_params_string
+ locs = dict(locs or {}, inst=self.inst)
+ return (func, 'inst,' + call_params_string, locs)
+
+
+class TestGetattrStatic(unittest.TestCase):
+
+ def test_basic(self):
+ class Thing(object):
+ x = object()
+
+ thing = Thing()
+ self.assertEqual(inspect.getattr_static(thing, 'x'), Thing.x)
+ self.assertEqual(inspect.getattr_static(thing, 'x', None), Thing.x)
+ with self.assertRaises(AttributeError):
+ inspect.getattr_static(thing, 'y')
+
+ self.assertEqual(inspect.getattr_static(thing, 'y', 3), 3)
+
+ def test_inherited(self):
+ class Thing(object):
+ x = object()
+ class OtherThing(Thing):
+ pass
+
+ something = OtherThing()
+ self.assertEqual(inspect.getattr_static(something, 'x'), Thing.x)
+
+ def test_instance_attr(self):
+ class Thing(object):
+ x = 2
+ def __init__(self, x):
+ self.x = x
+ thing = Thing(3)
+ self.assertEqual(inspect.getattr_static(thing, 'x'), 3)
+ del thing.x
+ self.assertEqual(inspect.getattr_static(thing, 'x'), 2)
+
+ def test_property(self):
+ class Thing(object):
+ @property
+ def x(self):
+ raise AttributeError("I'm pretending not to exist")
+ thing = Thing()
+ self.assertEqual(inspect.getattr_static(thing, 'x'), Thing.x)
+
+ def test_descriptor(self):
+ class descriptor(object):
+ def __get__(*_):
+ raise AttributeError("I'm pretending not to exist")
+ desc = descriptor()
+ class Thing(object):
+ x = desc
+ thing = Thing()
+ self.assertEqual(inspect.getattr_static(thing, 'x'), desc)
+
+ def test_classAttribute(self):
+ class Thing(object):
+ x = object()
+
+ self.assertEqual(inspect.getattr_static(Thing, 'x'), Thing.x)
+
+ def test_inherited_classattribute(self):
+ class Thing(object):
+ x = object()
+ class OtherThing(Thing):
+ pass
+
+ self.assertEqual(inspect.getattr_static(OtherThing, 'x'), Thing.x)
+
+ def test_slots(self):
+ class Thing(object):
+ y = 'bar'
+ __slots__ = ['x']
+ def __init__(self):
+ self.x = 'foo'
+ thing = Thing()
+ self.assertEqual(inspect.getattr_static(thing, 'x'), Thing.x)
+ self.assertEqual(inspect.getattr_static(thing, 'y'), 'bar')
+
+ del thing.x
+ self.assertEqual(inspect.getattr_static(thing, 'x'), Thing.x)
+
+ def test_metaclass(self):
+ class meta(type):
+ attr = 'foo'
+ class Thing(object, metaclass=meta):
+ pass
+ self.assertEqual(inspect.getattr_static(Thing, 'attr'), 'foo')
+
+ class sub(meta):
+ pass
+ class OtherThing(object, metaclass=sub):
+ x = 3
+ self.assertEqual(inspect.getattr_static(OtherThing, 'attr'), 'foo')
+
+ class OtherOtherThing(OtherThing):
+ pass
+ # this test is odd, but it was added as it exposed a bug
+ self.assertEqual(inspect.getattr_static(OtherOtherThing, 'x'), 3)
+
+ def test_no_dict_no_slots(self):
+ self.assertEqual(inspect.getattr_static(1, 'foo', None), None)
+ self.assertNotEqual(inspect.getattr_static('foo', 'lower'), None)
+
+ def test_no_dict_no_slots_instance_member(self):
+ # returns descriptor
+ with open(__file__) as handle:
+ self.assertEqual(inspect.getattr_static(handle, 'name'), type(handle).name)
+
+ def test_inherited_slots(self):
+ # returns descriptor
+ class Thing(object):
+ __slots__ = ['x']
+ def __init__(self):
+ self.x = 'foo'
+
+ class OtherThing(Thing):
+ pass
+ # it would be nice if this worked...
+ # we get the descriptor instead of the instance attribute
+ self.assertEqual(inspect.getattr_static(OtherThing(), 'x'), Thing.x)
+
+ def test_descriptor(self):
+ class descriptor(object):
+ def __get__(self, instance, owner):
+ return 3
+ class Foo(object):
+ d = descriptor()
+
+ foo = Foo()
+
+ # for a non data descriptor we return the instance attribute
+ foo.__dict__['d'] = 1
+ self.assertEqual(inspect.getattr_static(foo, 'd'), 1)
+
+ # if the descriptor is a data-desciptor we should return the
+ # descriptor
+ descriptor.__set__ = lambda s, i, v: None
+ self.assertEqual(inspect.getattr_static(foo, 'd'), Foo.__dict__['d'])
+
+
+ def test_metaclass_with_descriptor(self):
+ class descriptor(object):
+ def __get__(self, instance, owner):
+ return 3
+ class meta(type):
+ d = descriptor()
+ class Thing(object, metaclass=meta):
+ pass
+ self.assertEqual(inspect.getattr_static(Thing, 'd'), meta.__dict__['d'])
+
+
+ def test_class_as_property(self):
+ class Base(object):
+ foo = 3
+
+ class Something(Base):
+ executed = False
+ @property
+ def __class__(self):
+ self.executed = True
+ return object
+
+ instance = Something()
+ self.assertEqual(inspect.getattr_static(instance, 'foo'), 3)
+ self.assertFalse(instance.executed)
+ self.assertEqual(inspect.getattr_static(Something, 'foo'), 3)
+
+ def test_mro_as_property(self):
+ class Meta(type):
+ @property
+ def __mro__(self):
+ return (object,)
+
+ class Base(object):
+ foo = 3
+
+ class Something(Base, metaclass=Meta):
+ pass
+
+ self.assertEqual(inspect.getattr_static(Something(), 'foo'), 3)
+ self.assertEqual(inspect.getattr_static(Something, 'foo'), 3)
+
+ def test_dict_as_property(self):
+ test = self
+ test.called = False
+
+ class Foo(dict):
+ a = 3
+ @property
+ def __dict__(self):
+ test.called = True
+ return {}
+
+ foo = Foo()
+ foo.a = 4
+ self.assertEqual(inspect.getattr_static(foo, 'a'), 3)
+ self.assertFalse(test.called)
+
+ def test_custom_object_dict(self):
+ test = self
+ test.called = False
+
+ class Custom(dict):
+ def get(self, key, default=None):
+ test.called = True
+ super().get(key, default)
+
+ class Foo(object):
+ a = 3
+ foo = Foo()
+ foo.__dict__ = Custom()
+ self.assertEqual(inspect.getattr_static(foo, 'a'), 3)
+ self.assertFalse(test.called)
+
+ def test_metaclass_dict_as_property(self):
+ class Meta(type):
+ @property
+ def __dict__(self):
+ self.executed = True
+
+ class Thing(metaclass=Meta):
+ executed = False
+
+ def __init__(self):
+ self.spam = 42
+
+ instance = Thing()
+ self.assertEqual(inspect.getattr_static(instance, "spam"), 42)
+ self.assertFalse(Thing.executed)
+
+class TestGetGeneratorState(unittest.TestCase):
+
+ def setUp(self):
+ def number_generator():
+ for number in range(5):
+ yield number
+ self.generator = number_generator()
+
+ def _generatorstate(self):
+ return inspect.getgeneratorstate(self.generator)
+
+ def test_created(self):
+ self.assertEqual(self._generatorstate(), inspect.GEN_CREATED)
+
+ def test_suspended(self):
+ next(self.generator)
+ self.assertEqual(self._generatorstate(), inspect.GEN_SUSPENDED)
+
+ def test_closed_after_exhaustion(self):
+ for i in self.generator:
+ pass
+ self.assertEqual(self._generatorstate(), inspect.GEN_CLOSED)
+
+ def test_closed_after_immediate_exception(self):
+ with self.assertRaises(RuntimeError):
+ self.generator.throw(RuntimeError)
+ self.assertEqual(self._generatorstate(), inspect.GEN_CLOSED)
+
+ def test_running(self):
+ # As mentioned on issue #10220, checking for the RUNNING state only
+ # makes sense inside the generator itself.
+ # The following generator checks for this by using the closure's
+ # reference to self and the generator state checking helper method
+ def running_check_generator():
+ for number in range(5):
+ self.assertEqual(self._generatorstate(), inspect.GEN_RUNNING)
+ yield number
+ self.assertEqual(self._generatorstate(), inspect.GEN_RUNNING)
+ self.generator = running_check_generator()
+ # Running up to the first yield
+ next(self.generator)
+ # Running after the first yield
+ next(self.generator)
+
+ def test_easy_debugging(self):
+ # repr() and str() of a generator state should contain the state name
+ names = 'GEN_CREATED GEN_RUNNING GEN_SUSPENDED GEN_CLOSED'.split()
+ for name in names:
+ state = getattr(inspect, name)
+ self.assertIn(name, repr(state))
+ self.assertIn(name, str(state))
+
def test_main():
- run_unittest(TestDecorators, TestRetrievingSourceCode, TestOneliners,
- TestBuggyCases,
- TestInterpreterStack, TestClassesAndFunctions, TestPredicates)
+ run_unittest(
+ TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBuggyCases,
+ TestInterpreterStack, TestClassesAndFunctions, TestPredicates,
+ TestGetcallargsFunctions, TestGetcallargsMethods,
+ TestGetcallargsUnboundMethods, TestGetattrStatic, TestGetGeneratorState,
+ TestNoEOL
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
index f7d2318686..437e323cbc 100644
--- a/Lib/test/test_int.py
+++ b/Lib/test/test_int.py
@@ -20,7 +20,8 @@ L = [
(' 1\02 ', ValueError),
('', ValueError),
(' ', ValueError),
- (' \t\t ', ValueError)
+ (' \t\t ', ValueError),
+ ("\u0200", ValueError)
]
class IntTestCases(unittest.TestCase):
@@ -34,6 +35,9 @@ class IntTestCases(unittest.TestCase):
self.assertEqual(int(-3.9), -3)
self.assertEqual(int(3.5), 3)
self.assertEqual(int(-3.5), -3)
+ self.assertEqual(int("-3"), -3)
+ self.assertEqual(int(" -3 "), -3)
+ self.assertEqual(int("\N{EM SPACE}-3\N{EN SPACE}"), -3)
# Different base:
self.assertEqual(int("10",16), 16)
# Test conversion from strings and various anomalies
@@ -52,15 +56,15 @@ class IntTestCases(unittest.TestCase):
s = repr(-1-sys.maxsize)
x = int(s)
self.assertEqual(x+1, -sys.maxsize)
- self.assertTrue(isinstance(x, int))
- # should return long
+ self.assertIsInstance(x, int)
+ # should return int
self.assertEqual(int(s[1:]), sys.maxsize+1)
- # should return long
+ # should return int
x = int(1e100)
- self.assertTrue(isinstance(x, int))
+ self.assertIsInstance(x, int)
x = int(-1e100)
- self.assertTrue(isinstance(x, int))
+ self.assertIsInstance(x, int)
# SF bug 434186: 0x80000000/2 != 0x80000000>>1.
@@ -78,7 +82,8 @@ class IntTestCases(unittest.TestCase):
self.assertRaises(ValueError, int, '123\x00 245', 20)
x = int('1' * 600)
- self.assertTrue(isinstance(x, int))
+ self.assertIsInstance(x, int)
+
self.assertRaises(TypeError, int, 1, 12)
@@ -300,6 +305,16 @@ class IntTestCases(unittest.TestCase):
self.fail("Failed to raise TypeError with %s" %
((base, trunc_result_base),))
+ def test_error_message(self):
+ testlist = ('\xbd', '123\xbd', ' 123 456 ')
+ for s in testlist:
+ try:
+ int(s)
+ except ValueError as e:
+ self.assertIn(s.strip(), e.args[0])
+ else:
+ self.fail("Expected int(%r) to raise a ValueError", s)
+
def test_main():
run_unittest(IntTestCases)
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 5f62494e63..b665a6cd49 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -23,22 +23,25 @@ import os
import sys
import time
import array
-import threading
import random
import unittest
-import warnings
import weakref
-import gc
import abc
import signal
import errno
-from itertools import chain, cycle, count
+import warnings
+import pickle
+from itertools import cycle, count
from collections import deque
from test import support
import codecs
import io # C implementation of io
import _pyio as pyio # Python implementation of io
+try:
+ import threading
+except ImportError:
+ threading = None
def _default_chunk_size():
@@ -189,6 +192,23 @@ class PyMockFileIO(MockFileIO, pyio.BytesIO):
pass
+class MockUnseekableIO:
+ def seekable(self):
+ return False
+
+ def seek(self, *args):
+ raise self.UnsupportedOperation("not seekable")
+
+ def tell(self, *args):
+ raise self.UnsupportedOperation("not seekable")
+
+class CMockUnseekableIO(MockUnseekableIO, io.BytesIO):
+ UnsupportedOperation = io.UnsupportedOperation
+
+class PyMockUnseekableIO(MockUnseekableIO, pyio.BytesIO):
+ UnsupportedOperation = pyio.UnsupportedOperation
+
+
class MockNonBlockWriterIO:
def __init__(self):
@@ -314,16 +334,26 @@ class IOTest(unittest.TestCase):
def test_invalid_operations(self):
# Try writing on a file opened in read mode and vice-versa.
+ exc = self.UnsupportedOperation
for mode in ("w", "wb"):
with self.open(support.TESTFN, mode) as fp:
- self.assertRaises(IOError, fp.read)
- self.assertRaises(IOError, fp.readline)
+ self.assertRaises(exc, fp.read)
+ self.assertRaises(exc, fp.readline)
+ with self.open(support.TESTFN, "wb", buffering=0) as fp:
+ self.assertRaises(exc, fp.read)
+ self.assertRaises(exc, fp.readline)
+ with self.open(support.TESTFN, "rb", buffering=0) as fp:
+ self.assertRaises(exc, fp.write, b"blah")
+ self.assertRaises(exc, fp.writelines, [b"blah\n"])
with self.open(support.TESTFN, "rb") as fp:
- self.assertRaises(IOError, fp.write, b"blah")
- self.assertRaises(IOError, fp.writelines, [b"blah\n"])
+ self.assertRaises(exc, fp.write, b"blah")
+ self.assertRaises(exc, fp.writelines, [b"blah\n"])
with self.open(support.TESTFN, "r") as fp:
- self.assertRaises(IOError, fp.write, "blah")
- self.assertRaises(IOError, fp.writelines, ["blah\n"])
+ self.assertRaises(exc, fp.write, "blah")
+ self.assertRaises(exc, fp.writelines, ["blah\n"])
+ # Non-zero seeking from current or end pos
+ self.assertRaises(exc, fp.seek, 1, self.SEEK_CUR)
+ self.assertRaises(exc, fp.seek, -1, self.SEEK_END)
def test_raw_file_io(self):
with self.open(support.TESTFN, "wb", buffering=0) as f:
@@ -432,13 +462,14 @@ class IOTest(unittest.TestCase):
def flush(self):
record.append(3)
super().flush()
- f = MyFileIO(support.TESTFN, "wb")
- f.write(b"xxx")
- del f
- support.gc_collect()
- self.assertEqual(record, [1, 2, 3])
- with self.open(support.TESTFN, "rb") as f:
- self.assertEqual(f.read(), b"xxx")
+ with support.check_warnings(('', ResourceWarning)):
+ f = MyFileIO(support.TESTFN, "wb")
+ f.write(b"xxx")
+ del f
+ support.gc_collect()
+ self.assertEqual(record, [1, 2, 3])
+ with self.open(support.TESTFN, "rb") as f:
+ self.assertEqual(f.read(), b"xxx")
def _check_base_destructor(self, base):
record = []
@@ -490,7 +521,7 @@ class IOTest(unittest.TestCase):
def test_array_writes(self):
a = array.array('i', range(10))
- n = len(a.tostring())
+ n = len(a.tobytes())
with self.open(support.TESTFN, "wb", 0) as f:
self.assertEqual(f.write(a), n)
with self.open(support.TESTFN, "wb") as f:
@@ -525,12 +556,13 @@ class IOTest(unittest.TestCase):
def test_garbage_collection(self):
# FileIO objects are collected, and collecting them flushes
# all data to disk.
- f = self.FileIO(support.TESTFN, "wb")
- f.write(b"abcxxx")
- f.f = f
- wr = weakref.ref(f)
- del f
- support.gc_collect()
+ with support.check_warnings(('', ResourceWarning)):
+ f = self.FileIO(support.TESTFN, "wb")
+ f.write(b"abcxxx")
+ f.f = f
+ wr = weakref.ref(f)
+ del f
+ support.gc_collect()
self.assertTrue(wr() is None, wr)
with self.open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"abcxxx")
@@ -693,6 +725,11 @@ class CommonBufferedTests:
b.close()
self.assertRaises(ValueError, b.flush)
+ def test_unseekable(self):
+ bufio = self.tp(self.MockUnseekableIO(b"A" * 10))
+ self.assertRaises(self.UnsupportedOperation, bufio.tell)
+ self.assertRaises(self.UnsupportedOperation, bufio.seek, 0)
+
def test_readonly_attributes(self):
raw = self.MockRawIO()
buf = self.tp(raw)
@@ -810,6 +847,7 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
self.assertEqual(b"abcdefg", bufio.read())
+ @unittest.skipUnless(threading, 'Threading required for this test.')
@support.requires_resource('cpu')
def test_threads(self):
try:
@@ -1078,6 +1116,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
with self.open(support.TESTFN, "rb", buffering=0) as f:
self.assertEqual(f.read(), b"abc")
+ @unittest.skipUnless(threading, 'Threading required for this test.')
@support.requires_resource('cpu')
def test_threads(self):
try:
@@ -1136,14 +1175,9 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
self.assertRaises(IOError, bufio.write, b"abcdef")
def test_max_buffer_size_deprecation(self):
- with support.check_warnings() as w:
- warnings.simplefilter("always", DeprecationWarning)
+ with support.check_warnings(("max_buffer_size is deprecated",
+ DeprecationWarning)):
self.tp(self.MockRawIO(), 8, 12)
- self.assertEqual(len(w.warnings), 1)
- warning = w.warnings[0]
- self.assertTrue(warning.category is DeprecationWarning)
- self.assertEqual(str(warning.message),
- "max_buffer_size is deprecated")
class CBufferedWriterTest(BufferedWriterTest):
@@ -1199,14 +1233,9 @@ class BufferedRWPairTest(unittest.TestCase):
self.assertRaises(self.UnsupportedOperation, pair.detach)
def test_constructor_max_buffer_size_deprecation(self):
- with support.check_warnings() as w:
- warnings.simplefilter("always", DeprecationWarning)
+ with support.check_warnings(("max_buffer_size is deprecated",
+ DeprecationWarning)):
self.tp(self.MockRawIO(), self.MockRawIO(), 8, 12)
- self.assertEqual(len(w.warnings), 1)
- warning = w.warnings[0]
- self.assertTrue(warning.category is DeprecationWarning)
- self.assertEqual(str(warning.message),
- "max_buffer_size is deprecated")
def test_constructor_with_not_readable(self):
class NotReadable(MockRawIO):
@@ -1473,6 +1502,9 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
BufferedReaderTest.test_misbehaved_io(self)
BufferedWriterTest.test_misbehaved_io(self)
+ # You can't construct a BufferedRandom over a non-seekable stream.
+ test_unseekable = None
+
class CBufferedRandomTest(BufferedRandomTest):
tp = io.BufferedRandom
@@ -1685,9 +1717,12 @@ class TextIOWrapperTest(unittest.TestCase):
raw.name = "dummy"
self.assertEqual(repr(t),
"<%s.TextIOWrapper name='dummy' encoding='utf-8'>" % modname)
+ t.mode = "r"
+ self.assertEqual(repr(t),
+ "<%s.TextIOWrapper name='dummy' mode='r' encoding='utf-8'>" % modname)
raw.name = b"dummy"
self.assertEqual(repr(t),
- "<%s.TextIOWrapper name=b'dummy' encoding='utf-8'>" % modname)
+ "<%s.TextIOWrapper name=b'dummy' mode='r' encoding='utf-8'>" % modname)
def test_line_buffering(self):
r = self.BytesIO()
@@ -1961,26 +1996,24 @@ class TextIOWrapperTest(unittest.TestCase):
u_suffix = "\u8888\n"
suffix = bytes(u_suffix.encode("utf-8"))
line = prefix + suffix
- f = self.open(support.TESTFN, "wb")
- f.write(line*2)
- f.close()
- f = self.open(support.TESTFN, "r", encoding="utf-8")
- s = f.read(prefix_size)
- self.assertEqual(s, str(prefix, "ascii"))
- self.assertEqual(f.tell(), prefix_size)
- self.assertEqual(f.readline(), u_suffix)
+ with self.open(support.TESTFN, "wb") as f:
+ f.write(line*2)
+ with self.open(support.TESTFN, "r", encoding="utf-8") as f:
+ s = f.read(prefix_size)
+ self.assertEqual(s, str(prefix, "ascii"))
+ self.assertEqual(f.tell(), prefix_size)
+ self.assertEqual(f.readline(), u_suffix)
def test_seeking_too(self):
# Regression test for a specific bug
data = b'\xe0\xbf\xbf\n'
- f = self.open(support.TESTFN, "wb")
- f.write(data)
- f.close()
- f = self.open(support.TESTFN, "r", encoding="utf-8")
- f._CHUNK_SIZE # Just test that it exists
- f._CHUNK_SIZE = 2
- f.readline()
- f.tell()
+ with self.open(support.TESTFN, "wb") as f:
+ f.write(data)
+ with self.open(support.TESTFN, "r", encoding="utf-8") as f:
+ f._CHUNK_SIZE # Just test that it exists
+ f._CHUNK_SIZE = 2
+ f.readline()
+ f.tell()
def test_seek_and_tell(self):
#Test seek/tell using the StatefulIncrementalDecoder.
@@ -2181,7 +2214,7 @@ class TextIOWrapperTest(unittest.TestCase):
with self.open(support.TESTFN, "w", errors="replace") as f:
self.assertEqual(f.errors, "replace")
-
+ @unittest.skipUnless(threading, 'Threading required for this test.')
def test_threads_write(self):
# Issue6750: concurrent writes could duplicate data
event = threading.Event()
@@ -2217,6 +2250,11 @@ class TextIOWrapperTest(unittest.TestCase):
txt.close()
self.assertRaises(ValueError, txt.flush)
+ def test_unseekable(self):
+ txt = self.TextIOWrapper(self.MockUnseekableIO(self.testdata))
+ self.assertRaises(self.UnsupportedOperation, txt.tell)
+ self.assertRaises(self.UnsupportedOperation, txt.seek, 0)
+
def test_readonly_attributes(self):
txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
buf = self.BytesIO(self.testdata)
@@ -2474,27 +2512,27 @@ class MiscIOTest(unittest.TestCase):
def test_abcs(self):
# Test the visible base classes are ABCs.
- self.assertTrue(isinstance(self.IOBase, abc.ABCMeta))
- self.assertTrue(isinstance(self.RawIOBase, abc.ABCMeta))
- self.assertTrue(isinstance(self.BufferedIOBase, abc.ABCMeta))
- self.assertTrue(isinstance(self.TextIOBase, abc.ABCMeta))
+ self.assertIsInstance(self.IOBase, abc.ABCMeta)
+ self.assertIsInstance(self.RawIOBase, abc.ABCMeta)
+ self.assertIsInstance(self.BufferedIOBase, abc.ABCMeta)
+ self.assertIsInstance(self.TextIOBase, abc.ABCMeta)
def _check_abc_inheritance(self, abcmodule):
with self.open(support.TESTFN, "wb", buffering=0) as f:
- self.assertTrue(isinstance(f, abcmodule.IOBase))
- self.assertTrue(isinstance(f, abcmodule.RawIOBase))
- self.assertFalse(isinstance(f, abcmodule.BufferedIOBase))
- self.assertFalse(isinstance(f, abcmodule.TextIOBase))
+ self.assertIsInstance(f, abcmodule.IOBase)
+ self.assertIsInstance(f, abcmodule.RawIOBase)
+ self.assertNotIsInstance(f, abcmodule.BufferedIOBase)
+ self.assertNotIsInstance(f, abcmodule.TextIOBase)
with self.open(support.TESTFN, "wb") as f:
- self.assertTrue(isinstance(f, abcmodule.IOBase))
- self.assertFalse(isinstance(f, abcmodule.RawIOBase))
- self.assertTrue(isinstance(f, abcmodule.BufferedIOBase))
- self.assertFalse(isinstance(f, abcmodule.TextIOBase))
+ self.assertIsInstance(f, abcmodule.IOBase)
+ self.assertNotIsInstance(f, abcmodule.RawIOBase)
+ self.assertIsInstance(f, abcmodule.BufferedIOBase)
+ self.assertNotIsInstance(f, abcmodule.TextIOBase)
with self.open(support.TESTFN, "w") as f:
- self.assertTrue(isinstance(f, abcmodule.IOBase))
- self.assertFalse(isinstance(f, abcmodule.RawIOBase))
- self.assertFalse(isinstance(f, abcmodule.BufferedIOBase))
- self.assertTrue(isinstance(f, abcmodule.TextIOBase))
+ self.assertIsInstance(f, abcmodule.IOBase)
+ self.assertNotIsInstance(f, abcmodule.RawIOBase)
+ self.assertNotIsInstance(f, abcmodule.BufferedIOBase)
+ self.assertIsInstance(f, abcmodule.TextIOBase)
def test_abc_inheritance(self):
# Test implementations inherit from their respective ABCs
@@ -2505,6 +2543,63 @@ class MiscIOTest(unittest.TestCase):
# baseline "io" module.
self._check_abc_inheritance(io)
+ def _check_warn_on_dealloc(self, *args, **kwargs):
+ f = open(*args, **kwargs)
+ r = repr(f)
+ with self.assertWarns(ResourceWarning) as cm:
+ f = None
+ support.gc_collect()
+ self.assertIn(r, str(cm.warning.args[0]))
+
+ def test_warn_on_dealloc(self):
+ self._check_warn_on_dealloc(support.TESTFN, "wb", buffering=0)
+ self._check_warn_on_dealloc(support.TESTFN, "wb")
+ self._check_warn_on_dealloc(support.TESTFN, "w")
+
+ def _check_warn_on_dealloc_fd(self, *args, **kwargs):
+ fds = []
+ def cleanup_fds():
+ for fd in fds:
+ try:
+ os.close(fd)
+ except EnvironmentError as e:
+ if e.errno != errno.EBADF:
+ raise
+ self.addCleanup(cleanup_fds)
+ r, w = os.pipe()
+ fds += r, w
+ self._check_warn_on_dealloc(r, *args, **kwargs)
+ # When using closefd=False, there's no warning
+ r, w = os.pipe()
+ fds += r, w
+ with warnings.catch_warnings(record=True) as recorded:
+ open(r, *args, closefd=False, **kwargs)
+ support.gc_collect()
+ self.assertEqual(recorded, [])
+
+ def test_warn_on_dealloc_fd(self):
+ self._check_warn_on_dealloc_fd("rb", buffering=0)
+ self._check_warn_on_dealloc_fd("rb")
+ self._check_warn_on_dealloc_fd("r")
+
+
+ def test_pickling(self):
+ # Pickling file objects is forbidden
+ for kwargs in [
+ {"mode": "w"},
+ {"mode": "wb"},
+ {"mode": "wb", "buffering": 0},
+ {"mode": "r"},
+ {"mode": "rb"},
+ {"mode": "rb", "buffering": 0},
+ {"mode": "w+"},
+ {"mode": "w+b"},
+ {"mode": "w+b", "buffering": 0},
+ ]:
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
+ with self.open(support.TESTFN, **kwargs) as f:
+ self.assertRaises(TypeError, pickle.dumps, f, protocol)
+
class CMiscIOTest(MiscIOTest):
io = io
@@ -2527,7 +2622,8 @@ class SignalsTest(unittest.TestCase):
@unittest.skipUnless(threading, 'Threading required for this test.')
def check_interrupted_write(self, item, bytes, **fdopen_kwargs):
"""Check that a partial write, when it gets interrupted, properly
- invokes the signal handler."""
+ invokes the signal handler, and bubbles up the exception raised
+ in the latter."""
read_results = []
def _read():
s = os.read(r, 1)
@@ -2535,6 +2631,7 @@ class SignalsTest(unittest.TestCase):
t = threading.Thread(target=_read)
t.daemon = True
r, w = os.pipe()
+ fdopen_kwargs["closefd"] = False
try:
wio = self.io.open(w, **fdopen_kwargs)
t.start()
@@ -2592,6 +2689,9 @@ class SignalsTest(unittest.TestCase):
wio.flush()
# Make sure the buffer doesn't fill up and block further writes
os.read(r, len(data) * 100)
+ exc = cm.exception
+ if isinstance(exc, RuntimeError):
+ self.assertTrue(str(exc).startswith("reentrant call"), str(exc))
finally:
wio.close()
os.close(r)
@@ -2602,6 +2702,98 @@ class SignalsTest(unittest.TestCase):
def test_reentrant_write_text(self):
self.check_reentrant_write("xy", mode="w", encoding="ascii")
+ def check_interrupted_read_retry(self, decode, **fdopen_kwargs):
+ """Check that a buffered read, when it gets interrupted (either
+ returning a partial result or EINTR), properly invokes the signal
+ handler and retries if the latter returned successfully."""
+ r, w = os.pipe()
+ fdopen_kwargs["closefd"] = False
+ def alarm_handler(sig, frame):
+ os.write(w, b"bar")
+ signal.signal(signal.SIGALRM, alarm_handler)
+ try:
+ rio = self.io.open(r, **fdopen_kwargs)
+ os.write(w, b"foo")
+ signal.alarm(1)
+ # Expected behaviour:
+ # - first raw read() returns partial b"foo"
+ # - second raw read() returns EINTR
+ # - third raw read() returns b"bar"
+ self.assertEqual(decode(rio.read(6)), "foobar")
+ finally:
+ rio.close()
+ os.close(w)
+ os.close(r)
+
+ def test_interrupterd_read_retry_buffered(self):
+ self.check_interrupted_read_retry(lambda x: x.decode('latin1'),
+ mode="rb")
+
+ def test_interrupterd_read_retry_text(self):
+ self.check_interrupted_read_retry(lambda x: x,
+ mode="r")
+
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ def check_interrupted_write_retry(self, item, **fdopen_kwargs):
+ """Check that a buffered write, when it gets interrupted (either
+ returning a partial result or EINTR), properly invokes the signal
+ handler and retries if the latter returned successfully."""
+ select = support.import_module("select")
+ # A quantity that exceeds the buffer size of an anonymous pipe's
+ # write end.
+ N = 1024 * 1024
+ r, w = os.pipe()
+ fdopen_kwargs["closefd"] = False
+ # We need a separate thread to read from the pipe and allow the
+ # write() to finish. This thread is started after the SIGALRM is
+ # received (forcing a first EINTR in write()).
+ read_results = []
+ write_finished = False
+ def _read():
+ while not write_finished:
+ while r in select.select([r], [], [], 1.0)[0]:
+ s = os.read(r, 1024)
+ read_results.append(s)
+ t = threading.Thread(target=_read)
+ t.daemon = True
+ def alarm1(sig, frame):
+ signal.signal(signal.SIGALRM, alarm2)
+ signal.alarm(1)
+ def alarm2(sig, frame):
+ t.start()
+ signal.signal(signal.SIGALRM, alarm1)
+ try:
+ wio = self.io.open(w, **fdopen_kwargs)
+ signal.alarm(1)
+ # Expected behaviour:
+ # - first raw write() is partial (because of the limited pipe buffer
+ # and the first alarm)
+ # - second raw write() returns EINTR (because of the second alarm)
+ # - subsequent write()s are successful (either partial or complete)
+ self.assertEqual(N, wio.write(item * N))
+ wio.flush()
+ write_finished = True
+ t.join()
+ self.assertEqual(N, sum(len(x) for x in read_results))
+ finally:
+ write_finished = True
+ os.close(w)
+ os.close(r)
+ # This is deliberate. If we didn't close the file descriptor
+ # before closing wio, wio would try to flush its internal
+ # buffer, and could block (in case of failure).
+ try:
+ wio.close()
+ except IOError as e:
+ if e.errno != errno.EBADF:
+ raise
+
+ def test_interrupterd_write_retry_buffered(self):
+ self.check_interrupted_write_retry(b"x", mode="wb")
+
+ def test_interrupterd_write_retry_text(self):
+ self.check_interrupted_write_retry("x", mode="w", encoding="latin1")
+
class CSignalsTest(SignalsTest):
io = io
@@ -2631,7 +2823,7 @@ def test_main():
# Put the namespaces of the IO module we are testing and some useful mock
# classes in the __dict__ of each test.
mocks = (MockRawIO, MisbehavedRawIO, MockFileIO, CloseFailureIO,
- MockNonBlockWriterIO, MockRawIOWithoutRead)
+ MockNonBlockWriterIO, MockUnseekableIO, MockRawIOWithoutRead)
all_members = io.__all__ + ["IncrementalNewlineDecoder"]
c_io_ns = {name : getattr(io, name) for name in all_members}
py_io_ns = {name : getattr(pyio, name) for name in all_members}
diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py
index 26c0d05875..d4d5a22a88 100644
--- a/Lib/test/test_ioctl.py
+++ b/Lib/test/test_ioctl.py
@@ -30,10 +30,10 @@ class IoctlTests(unittest.TestCase):
# If this process has been put into the background, TIOCGPGRP returns
# the session ID instead of the process group id.
ids = (os.getpgrp(), os.getsid(0))
- tty = open("/dev/tty", "r")
- r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
- rpgrp = struct.unpack("i", r)[0]
- self.assertTrue(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
+ with open("/dev/tty", "r") as tty:
+ r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
+ rpgrp = struct.unpack("i", r)[0]
+ self.assertIn(rpgrp, ids)
def _check_ioctl_mutate_len(self, nbytes=None):
buf = array.array('i')
@@ -51,7 +51,7 @@ class IoctlTests(unittest.TestCase):
r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
rpgrp = buf[0]
self.assertEqual(r, 0)
- self.assertTrue(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
+ self.assertIn(rpgrp, ids)
def test_ioctl_mutate(self):
self._check_ioctl_mutate_len()
diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py
index 9482e75438..dc2d07467a 100644
--- a/Lib/test/test_isinstance.py
+++ b/Lib/test/test_isinstance.py
@@ -81,6 +81,20 @@ class TestIsInstanceExceptions(unittest.TestCase):
self.assertRaises(TypeError, isinstance, I(), C())
+ # check that we don't mask non AttributeErrors
+ # see: http://bugs.python.org/issue1574217
+ def test_isinstance_dont_mask_non_attribute_error(self):
+ class C(object):
+ def getclass(self):
+ raise RuntimeError
+ __class__ = property(getclass)
+
+ c = C()
+ self.assertRaises(RuntimeError, isinstance, c, bool)
+
+ # test another code path
+ class D: pass
+ self.assertRaises(RuntimeError, isinstance, c, D)
# These tests are similar to above, but tickle certain code paths in
diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py
index a826598215..e424303305 100644
--- a/Lib/test/test_iter.py
+++ b/Lib/test/test_iter.py
@@ -1,7 +1,7 @@
# Test iterators.
import unittest
-from test.support import run_unittest, TESTFN, unlink
+from test.support import run_unittest, TESTFN, unlink, cpython_only
# Test result of triple loop (too big to inline)
TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2),
@@ -542,23 +542,23 @@ class TestCase(unittest.TestCase):
def test_in_and_not_in(self):
for sc5 in IteratingSequenceClass(5), SequenceClass(5):
for i in range(5):
- self.assertTrue(i in sc5)
+ self.assertIn(i, sc5)
for i in "abc", -1, 5, 42.42, (3, 4), [], {1: 1}, 3-12j, sc5:
- self.assertTrue(i not in sc5)
+ self.assertNotIn(i, sc5)
self.assertRaises(TypeError, lambda: 3 in 12)
self.assertRaises(TypeError, lambda: 3 not in map)
d = {"one": 1, "two": 2, "three": 3, 1j: 2j}
for k in d:
- self.assertTrue(k in d)
- self.assertTrue(k not in d.values())
+ self.assertIn(k, d)
+ self.assertNotIn(k, d.values())
for v in d.values():
- self.assertTrue(v in d.values())
- self.assertTrue(v not in d)
+ self.assertIn(v, d.values())
+ self.assertNotIn(v, d)
for k, v in d.items():
- self.assertTrue((k, v) in d.items())
- self.assertTrue((v, k) not in d.items())
+ self.assertIn((k, v), d.items())
+ self.assertNotIn((v, k), d.items())
f = open(TESTFN, "w")
try:
@@ -569,9 +569,9 @@ class TestCase(unittest.TestCase):
try:
for chunk in "abc":
f.seek(0, 0)
- self.assertTrue(chunk not in f)
+ self.assertNotIn(chunk, f)
f.seek(0, 0)
- self.assertTrue((chunk + "\n") in f)
+ self.assertIn((chunk + "\n"), f)
finally:
f.close()
try:
@@ -761,8 +761,9 @@ class TestCase(unittest.TestCase):
(a, b), (c,) = IteratingSequenceClass(2), {42: 24}
self.assertEqual((a, b, c), (0, 1, 42))
- # Test reference count behavior
+ @cpython_only
+ def test_ref_counting_behavior(self):
class C(object):
count = 0
def __new__(cls):
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index da101e11ab..5e4bf1ba89 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -56,6 +56,24 @@ def fact(n):
return prod(range(1, n+1))
class TestBasicOps(unittest.TestCase):
+
+ def test_accumulate(self):
+ self.assertEqual(list(accumulate(range(10))), # one positional arg
+ [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])
+ self.assertEqual(list(accumulate(iterable=range(10))), # kw arg
+ [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])
+ for typ in int, complex, Decimal, Fraction: # multiple types
+ self.assertEqual(
+ list(accumulate(map(typ, range(10)))),
+ list(map(typ, [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])))
+ self.assertEqual(list(accumulate('abc')), ['a', 'ab', 'abc']) # works with non-numeric
+ self.assertEqual(list(accumulate([])), []) # empty iterable
+ self.assertEqual(list(accumulate([7])), [7]) # iterable of length one
+ self.assertRaises(TypeError, accumulate, range(10), 5) # too many args
+ self.assertRaises(TypeError, accumulate) # too few args
+ self.assertRaises(TypeError, accumulate, x=range(10)) # unexpected kwd arg
+ self.assertRaises(TypeError, list, accumulate([1, []])) # args that don't add
+
def test_chain(self):
def chain2(*iterables):
@@ -932,6 +950,9 @@ class TestBasicOps(unittest.TestCase):
class TestExamples(unittest.TestCase):
+ def test_accumlate(self):
+ self.assertEqual(list(accumulate([1,2,3,4,5])), [1, 3, 6, 10, 15])
+
def test_chain(self):
self.assertEqual(''.join(chain('ABC', 'DEF')), 'ABCDEF')
@@ -1019,6 +1040,10 @@ class TestGC(unittest.TestCase):
next(iterator)
del container, iterator
+ def test_accumulate(self):
+ a = []
+ self.makecycle(accumulate([1,2,a,3]), a)
+
def test_chain(self):
a = []
self.makecycle(chain(a), a)
@@ -1188,6 +1213,17 @@ def L(seqn):
class TestVariousIteratorArgs(unittest.TestCase):
+ def test_accumulate(self):
+ s = [1,2,3,4,5]
+ r = [1,3,6,10,15]
+ n = len(s)
+ for g in (G, I, Ig, L, R):
+ self.assertEqual(list(accumulate(g(s))), r)
+ self.assertEqual(list(accumulate(S(s))), [])
+ self.assertRaises(TypeError, accumulate, X(s))
+ self.assertRaises(TypeError, accumulate, N(s))
+ self.assertRaises(ZeroDivisionError, list, accumulate(E(s)))
+
def test_chain(self):
for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
@@ -1410,7 +1446,7 @@ class SubclassWithKwargsTest(unittest.TestCase):
Subclass(newarg=1)
except TypeError as err:
# we expect type errors because of wrong argument count
- self.assertFalse("does not take keyword arguments" in err.args[0])
+ self.assertNotIn("does not take keyword arguments", err.args[0])
libreftest = """ Doctest for examples in the library reference: libitertools.tex
diff --git a/Lib/test/test_json.py b/Lib/test/test_json.py
index a4b6e7a829..41ff8974fc 100644
--- a/Lib/test/test_json.py
+++ b/Lib/test/test_json.py
@@ -5,12 +5,12 @@ the test_suite() function there returns a test suite that's ready to
be run.
"""
-import json.tests
+from test import json_tests
import test.support
def test_main():
- test.support.run_unittest(json.tests.test_suite())
+ test.support.run_unittest(json_tests.test_suite())
if __name__ == "__main__":
diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py
index e10dfce2ad..d7f7541837 100644
--- a/Lib/test/test_keywordonlyarg.py
+++ b/Lib/test/test_keywordonlyarg.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Unit tests for the keyword only argument specified in PEP 3102."""
@@ -73,6 +73,14 @@ class KeywordOnlyArgTestCase(unittest.TestCase):
fundef3 += "lastarg):\n pass\n"
compile(fundef3, "<test>", "single")
+ def testTooManyPositionalErrorMessage(self):
+ def f(a, b=None, *, c=None):
+ pass
+ with self.assertRaises(TypeError) as exc:
+ f(1, 2, 3)
+ expected = "f() takes at most 2 positional arguments (3 given)"
+ self.assertEqual(str(exc.exception), expected)
+
def testSyntaxErrorForFunctionCall(self):
self.assertRaisesSyntaxError("f(p, k=1, p2)")
self.assertRaisesSyntaxError("f(p, k1=50, *(1,2), k1=100)")
diff --git a/Lib/test/test_kqueue.py b/Lib/test/test_kqueue.py
index a90f12cfe1..9cb0a85166 100644
--- a/Lib/test/test_kqueue.py
+++ b/Lib/test/test_kqueue.py
@@ -71,6 +71,17 @@ class TestKQueue(unittest.TestCase):
self.assertEqual(ev, ev)
self.assertNotEqual(ev, other)
+ bignum = sys.maxsize * 2 + 1
+ ev = select.kevent(bignum, 1, 2, 3, sys.maxsize, bignum)
+ self.assertEqual(ev.ident, bignum)
+ self.assertEqual(ev.filter, 1)
+ self.assertEqual(ev.flags, 2)
+ self.assertEqual(ev.fflags, 3)
+ self.assertEqual(ev.data, sys.maxsize)
+ self.assertEqual(ev.udata, bignum)
+ self.assertEqual(ev, ev)
+ self.assertNotEqual(ev, other)
+
def test_queue_event(self):
serverSocket = socket.socket()
serverSocket.bind(('127.0.0.1', 0))
diff --git a/Lib/test/test_linecache.py b/Lib/test/test_linecache.py
index 8e225d522b..fcc390a17b 100644
--- a/Lib/test/test_linecache.py
+++ b/Lib/test/test_linecache.py
@@ -12,7 +12,7 @@ EMPTY = ''
TESTS = 'cjkencodings_test inspect_fodder inspect_fodder2 mapping_tests'
TESTS = TESTS.split()
TEST_PATH = os.path.dirname(support.__file__)
-MODULES = "linecache unittest".split()
+MODULES = "linecache abc".split()
MODULE_PATH = os.path.dirname(FILENAME)
SOURCE_1 = '''
@@ -55,14 +55,16 @@ class LineCacheTests(unittest.TestCase):
# Check whether lines correspond to those from file iteration
for entry in TESTS:
filename = os.path.join(TEST_PATH, entry) + '.py'
- for index, line in enumerate(open(filename)):
- self.assertEqual(line, getline(filename, index + 1))
+ with open(filename) as file:
+ for index, line in enumerate(file):
+ self.assertEqual(line, getline(filename, index + 1))
# Check module loading
for entry in MODULES:
filename = os.path.join(MODULE_PATH, entry) + '.py'
- for index, line in enumerate(open(filename)):
- self.assertEqual(line, getline(filename, index + 1))
+ with open(filename) as file:
+ for index, line in enumerate(file):
+ self.assertEqual(line, getline(filename, index + 1))
# Check that bogus data isn't returned (issue #1309567)
empty = linecache.getlines('a/b/c/__init__.py')
@@ -99,6 +101,7 @@ class LineCacheTests(unittest.TestCase):
with open(source_name, 'w') as source:
source.write(SOURCE_1)
getline(source_name, 1)
+
# Keep a copy of the old contents
source_list = []
with open(source_name) as source:
@@ -123,7 +126,6 @@ class LineCacheTests(unittest.TestCase):
self.assertEqual(line, getline(source_name, index + 1))
source_list.append(line)
-
def test_main():
support.run_unittest(LineCacheTests)
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 9b36350fbe..b62545c815 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2011 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
@@ -18,7 +18,7 @@
"""Test harness for the logging module. Run all tests.
-Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2011 Vinay Sajip. All Rights Reserved.
"""
import logging
@@ -26,27 +26,29 @@ import logging.handlers
import logging.config
import codecs
-import copy
+import datetime
import pickle
import io
import gc
+import json
import os
+import queue
import re
import select
import socket
from socketserver import ThreadingTCPServer, StreamRequestHandler
-import string
import struct
import sys
import tempfile
from test.support import captured_stdout, run_with_locale, run_unittest
import textwrap
-import threading
-import time
-import types
import unittest
import warnings
import weakref
+try:
+ import threading
+except ImportError:
+ threading = None
class BaseTest(unittest.TestCase):
@@ -65,11 +67,21 @@ class BaseTest(unittest.TestCase):
try:
self.saved_handlers = logging._handlers.copy()
self.saved_handler_list = logging._handlerList[:]
- self.saved_loggers = logger_dict.copy()
+ self.saved_loggers = saved_loggers = logger_dict.copy()
self.saved_level_names = logging._levelNames.copy()
+ self.logger_states = logger_states = {}
+ for name in saved_loggers:
+ logger_states[name] = getattr(saved_loggers[name],
+ 'disabled', None)
finally:
logging._releaseLock()
+ # Set two unused loggers: one non-ASCII and one Unicode.
+ # This is to test correct operation when sorting existing
+ # loggers in the configuration code. See issue 8201.
+ self.logger1 = logging.getLogger("\xab\xd7\xbb")
+ self.logger2 = logging.getLogger("\u013f\u00d6\u0047")
+
self.root_logger = logging.getLogger("")
self.original_logging_level = self.root_logger.getEffectiveLevel()
@@ -78,13 +90,25 @@ class BaseTest(unittest.TestCase):
self.root_hdlr = logging.StreamHandler(self.stream)
self.root_formatter = logging.Formatter(self.log_format)
self.root_hdlr.setFormatter(self.root_formatter)
+ if self.logger1.hasHandlers():
+ hlist = self.logger1.handlers + self.root_logger.handlers
+ raise AssertionError('Unexpected handlers: %s' % hlist)
+ if self.logger2.hasHandlers():
+ hlist = self.logger2.handlers + self.root_logger.handlers
+ raise AssertionError('Unexpected handlers: %s' % hlist)
self.root_logger.addHandler(self.root_hdlr)
+ self.assertTrue(self.logger1.hasHandlers())
+ self.assertTrue(self.logger2.hasHandlers())
def tearDown(self):
"""Remove our logging stream, and restore the original logging
level."""
self.stream.close()
self.root_logger.removeHandler(self.root_hdlr)
+ while self.root_logger.handlers:
+ h = self.root_logger.handlers[0]
+ self.root_logger.removeHandler(h)
+ h.close()
self.root_logger.setLevel(self.original_logging_level)
logging._acquireLock()
try:
@@ -96,6 +120,10 @@ class BaseTest(unittest.TestCase):
loggerDict = logging.getLogger().manager.loggerDict
loggerDict.clear()
loggerDict.update(self.saved_loggers)
+ logger_states = self.logger_states
+ for name in self.logger_states:
+ if logger_states[name] is not None:
+ self.saved_loggers[name].disabled = logger_states[name]
finally:
logging._releaseLock()
@@ -111,7 +139,8 @@ class BaseTest(unittest.TestCase):
except AttributeError:
# StringIO.StringIO lacks a reset() method.
actual_lines = stream.getvalue().splitlines()
- self.assertEqual(len(actual_lines), len(expected_values))
+ self.assertEqual(len(actual_lines), len(expected_values),
+ '%s vs. %s' % (actual_lines, expected_values))
for actual, expected in zip(actual_lines, expected_values):
match = pat.search(actual)
if not match:
@@ -138,7 +167,7 @@ class BuiltinLevelsTest(BaseTest):
ERR = logging.getLogger("ERR")
ERR.setLevel(logging.ERROR)
- INF = logging.getLogger("INF")
+ INF = logging.LoggerAdapter(logging.getLogger("INF"), {})
INF.setLevel(logging.INFO)
DEB = logging.getLogger("DEB")
DEB.setLevel(logging.DEBUG)
@@ -292,6 +321,35 @@ class BasicFilterTest(BaseTest):
finally:
handler.removeFilter(filter_)
+ def test_callable_filter(self):
+ # Only messages satisfying the specified criteria pass through the
+ # filter.
+
+ def filterfunc(record):
+ parts = record.name.split('.')
+ prefix = '.'.join(parts[:2])
+ return prefix == 'spam.eggs'
+
+ handler = self.root_logger.handlers[0]
+ try:
+ handler.addFilter(filterfunc)
+ spam = logging.getLogger("spam")
+ spam_eggs = logging.getLogger("spam.eggs")
+ spam_eggs_fish = logging.getLogger("spam.eggs.fish")
+ spam_bakedbeans = logging.getLogger("spam.bakedbeans")
+
+ spam.info(self.next_message())
+ spam_eggs.info(self.next_message()) # Good.
+ spam_eggs_fish.info(self.next_message()) # Good.
+ spam_bakedbeans.info(self.next_message())
+
+ self.assert_log_lines([
+ ('spam.eggs', 'INFO', '2'),
+ ('spam.eggs.fish', 'INFO', '3'),
+ ])
+ finally:
+ handler.removeFilter(filterfunc)
+
#
# First, we define our levels. There can be as many as you want - the only
@@ -355,7 +413,7 @@ class CustomLevelsAndFiltersTest(BaseTest):
def setUp(self):
BaseTest.setUp(self)
- for k, v in list(my_logging_levels.items()):
+ for k, v in my_logging_levels.items():
logging.addLevelName(k, v)
def log_at_all_levels(self, logger):
@@ -702,14 +760,8 @@ class ConfigFileTest(BaseTest):
"""
def apply_config(self, conf):
- try:
- fn = tempfile.mktemp(".ini")
- f = open(fn, "w")
- f.write(textwrap.dedent(conf))
- f.close()
- logging.config.fileConfig(fn)
- finally:
- os.remove(fn)
+ file = io.StringIO(textwrap.dedent(conf))
+ logging.config.fileConfig(file)
def test_config0_ok(self):
# A simple config file which overrides the default settings.
@@ -876,6 +928,7 @@ class LogRecordSocketReceiver(ThreadingTCPServer):
self.server_close()
+@unittest.skipUnless(threading, 'Threading required for this test.')
class SocketHandlerTest(BaseTest):
"""Test for SocketHandler objects."""
@@ -944,7 +997,7 @@ class MemoryTest(BaseTest):
# Trigger cycle breaking.
gc.collect()
dead = []
- for (id_, repr_), ref in list(self._survivors.items()):
+ for (id_, repr_), ref in self._survivors.items():
if ref() is None:
dead.append(repr_)
if dead:
@@ -979,11 +1032,12 @@ class EncodingTest(BaseTest):
def test_encoding_plain_file(self):
# In Python 2.x, a plain file object is treated as having no encoding.
log = logging.getLogger("test")
- fn = tempfile.mktemp(".log")
+ fd, fn = tempfile.mkstemp(".log", "test_logging-1-")
+ os.close(fd)
# the non-ascii data we write to the log.
data = "foo\x80"
try:
- handler = logging.FileHandler(fn, encoding="utf8")
+ handler = logging.FileHandler(fn, encoding="utf-8")
log.addHandler(handler)
try:
# write non-ascii data to the log.
@@ -992,7 +1046,7 @@ class EncodingTest(BaseTest):
log.removeHandler(handler)
handler.close()
# check we wrote exactly those bytes, ignoring trailing \n etc
- f = open(fn, encoding="utf8")
+ f = open(fn, encoding="utf-8")
try:
self.assertEqual(f.read().rstrip(), data)
finally:
@@ -1051,15 +1105,1224 @@ class WarningsTest(BaseTest):
finally:
logging.captureWarnings(False)
+
+def formatFunc(format, datefmt=None):
+ return logging.Formatter(format, datefmt)
+
+def handlerFunc():
+ return logging.StreamHandler()
+
+class CustomHandler(logging.StreamHandler):
+ pass
+
+class ConfigDictTest(BaseTest):
+
+ """Reading logging config from a dictionary."""
+
+ expected_log_pat = r"^([\w]+) \+\+ ([\w]+)$"
+
+ # config0 is a standard configuration.
+ config0 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ 'handlers' : ['hand1'],
+ },
+ }
+
+ # config1 adds a little to the standard configuration.
+ config1 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ # config1a moves the handler to the root. Used with config8a
+ config1a = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ 'handlers' : ['hand1'],
+ },
+ }
+
+ # config2 has a subtle configuration error that should be reported
+ config2 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdbout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ #As config1 but with a misspelt level on a handler
+ config2a = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NTOSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+
+ #As config1 but with a misspelt level on a logger
+ config2b = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WRANING',
+ },
+ }
+
+ # config3 has a less subtle configuration error
+ config3 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'misspelled_name',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ # config4 specifies a custom formatter class to be loaded
+ config4 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ '()' : __name__ + '.ExceptionFormatter',
+ 'format' : '%(levelname)s:%(name)s:%(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'root' : {
+ 'level' : 'NOTSET',
+ 'handlers' : ['hand1'],
+ },
+ }
+
+ # As config4 but using an actual callable rather than a string
+ config4a = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ '()' : ExceptionFormatter,
+ 'format' : '%(levelname)s:%(name)s:%(message)s',
+ },
+ 'form2' : {
+ '()' : __name__ + '.formatFunc',
+ 'format' : '%(levelname)s:%(name)s:%(message)s',
+ },
+ 'form3' : {
+ '()' : formatFunc,
+ 'format' : '%(levelname)s:%(name)s:%(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ 'hand2' : {
+ '()' : handlerFunc,
+ },
+ },
+ 'root' : {
+ 'level' : 'NOTSET',
+ 'handlers' : ['hand1'],
+ },
+ }
+
+ # config5 specifies a custom handler class to be loaded
+ config5 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : __name__ + '.CustomHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ # config6 specifies a custom handler class to be loaded
+ # but has bad arguments
+ config6 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : __name__ + '.CustomHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ '9' : 'invalid parameter name',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ #config 7 does not define compiler.parser but defines compiler.lexer
+ #so compiler.parser should be disabled after applying it
+ config7 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.lexer' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ # config8 defines both compiler and compiler.lexer
+ # so compiler.parser should not be disabled (since
+ # compiler is defined)
+ config8 = {
+ 'version': 1,
+ 'disable_existing_loggers' : False,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ 'compiler.lexer' : {
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ # config8a disables existing loggers
+ config8a = {
+ 'version': 1,
+ 'disable_existing_loggers' : True,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ 'compiler.lexer' : {
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ config9 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'WARNING',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'WARNING',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'NOTSET',
+ },
+ }
+
+ config9a = {
+ 'version': 1,
+ 'incremental' : True,
+ 'handlers' : {
+ 'hand1' : {
+ 'level' : 'WARNING',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'INFO',
+ },
+ },
+ }
+
+ config9b = {
+ 'version': 1,
+ 'incremental' : True,
+ 'handlers' : {
+ 'hand1' : {
+ 'level' : 'INFO',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'INFO',
+ },
+ },
+ }
+
+ #As config1 but with a filter added
+ config10 = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'filters' : {
+ 'filt1' : {
+ 'name' : 'compiler.parser',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ 'filters' : ['filt1'],
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'filters' : ['filt1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ 'handlers' : ['hand1'],
+ },
+ }
+
+ #As config1 but using cfg:// references
+ config11 = {
+ 'version': 1,
+ 'true_formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handler_configs': {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'formatters' : 'cfg://true_formatters',
+ 'handlers' : {
+ 'hand1' : 'cfg://handler_configs[hand1]',
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ #As config11 but missing the version key
+ config12 = {
+ 'true_formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handler_configs': {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'formatters' : 'cfg://true_formatters',
+ 'handlers' : {
+ 'hand1' : 'cfg://handler_configs[hand1]',
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ #As config11 but using an unsupported version
+ config13 = {
+ 'version': 2,
+ 'true_formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handler_configs': {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'formatters' : 'cfg://true_formatters',
+ 'handlers' : {
+ 'hand1' : 'cfg://handler_configs[hand1]',
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ def apply_config(self, conf):
+ logging.config.dictConfig(conf)
+
+ def test_config0_ok(self):
+ # A simple config which overrides the default settings.
+ with captured_stdout() as output:
+ self.apply_config(self.config0)
+ logger = logging.getLogger()
+ # Won't output anything
+ logger.info(self.next_message())
+ # Outputs a message
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('ERROR', '2'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+
+ def test_config1_ok(self, config=config1):
+ # A config defining a sub-parser as well.
+ with captured_stdout() as output:
+ self.apply_config(config)
+ logger = logging.getLogger("compiler.parser")
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '1'),
+ ('ERROR', '2'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+
+ def test_config2_failure(self):
+ # A simple config which overrides the default settings.
+ self.assertRaises(Exception, self.apply_config, self.config2)
+
+ def test_config2a_failure(self):
+ # A simple config which overrides the default settings.
+ self.assertRaises(Exception, self.apply_config, self.config2a)
+
+ def test_config2b_failure(self):
+ # A simple config which overrides the default settings.
+ self.assertRaises(Exception, self.apply_config, self.config2b)
+
+ def test_config3_failure(self):
+ # A simple config which overrides the default settings.
+ self.assertRaises(Exception, self.apply_config, self.config3)
+
+ def test_config4_ok(self):
+ # A config specifying a custom formatter class.
+ with captured_stdout() as output:
+ self.apply_config(self.config4)
+ #logger = logging.getLogger()
+ try:
+ raise RuntimeError()
+ except RuntimeError:
+ logging.exception("just testing")
+ sys.stdout.seek(0)
+ self.assertEqual(output.getvalue(),
+ "ERROR:root:just testing\nGot a [RuntimeError]\n")
+ # Original logger output is empty
+ self.assert_log_lines([])
+
+ def test_config4a_ok(self):
+ # A config specifying a custom formatter class.
+ with captured_stdout() as output:
+ self.apply_config(self.config4a)
+ #logger = logging.getLogger()
+ try:
+ raise RuntimeError()
+ except RuntimeError:
+ logging.exception("just testing")
+ sys.stdout.seek(0)
+ self.assertEqual(output.getvalue(),
+ "ERROR:root:just testing\nGot a [RuntimeError]\n")
+ # Original logger output is empty
+ self.assert_log_lines([])
+
+ def test_config5_ok(self):
+ self.test_config1_ok(config=self.config5)
+
+ def test_config6_failure(self):
+ self.assertRaises(Exception, self.apply_config, self.config6)
+
+ def test_config7_ok(self):
+ with captured_stdout() as output:
+ self.apply_config(self.config1)
+ logger = logging.getLogger("compiler.parser")
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '1'),
+ ('ERROR', '2'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+ with captured_stdout() as output:
+ self.apply_config(self.config7)
+ logger = logging.getLogger("compiler.parser")
+ self.assertTrue(logger.disabled)
+ logger = logging.getLogger("compiler.lexer")
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '3'),
+ ('ERROR', '4'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+
+ #Same as test_config_7_ok but don't disable old loggers.
+ def test_config_8_ok(self):
+ with captured_stdout() as output:
+ self.apply_config(self.config1)
+ logger = logging.getLogger("compiler.parser")
+ # All will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '1'),
+ ('ERROR', '2'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+ with captured_stdout() as output:
+ self.apply_config(self.config8)
+ logger = logging.getLogger("compiler.parser")
+ self.assertFalse(logger.disabled)
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ logger = logging.getLogger("compiler.lexer")
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '3'),
+ ('ERROR', '4'),
+ ('INFO', '5'),
+ ('ERROR', '6'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+
+ def test_config_8a_ok(self):
+ with captured_stdout() as output:
+ self.apply_config(self.config1a)
+ logger = logging.getLogger("compiler.parser")
+ # See issue #11424. compiler-hyphenated sorts
+ # between compiler and compiler.xyz and this
+ # was preventing compiler.xyz from being included
+ # in the child loggers of compiler because of an
+ # overzealous loop termination condition.
+ hyphenated = logging.getLogger('compiler-hyphenated')
+ # All will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ hyphenated.critical(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '1'),
+ ('ERROR', '2'),
+ ('CRITICAL', '3'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+ with captured_stdout() as output:
+ self.apply_config(self.config8a)
+ logger = logging.getLogger("compiler.parser")
+ self.assertFalse(logger.disabled)
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ logger = logging.getLogger("compiler.lexer")
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ # Will not appear
+ hyphenated.critical(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '4'),
+ ('ERROR', '5'),
+ ('INFO', '6'),
+ ('ERROR', '7'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+
+ def test_config_9_ok(self):
+ with captured_stdout() as output:
+ self.apply_config(self.config9)
+ logger = logging.getLogger("compiler.parser")
+ #Nothing will be output since both handler and logger are set to WARNING
+ logger.info(self.next_message())
+ self.assert_log_lines([], stream=output)
+ self.apply_config(self.config9a)
+ #Nothing will be output since both handler is still set to WARNING
+ logger.info(self.next_message())
+ self.assert_log_lines([], stream=output)
+ self.apply_config(self.config9b)
+ #Message should now be output
+ logger.info(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '3'),
+ ], stream=output)
+
+ def test_config_10_ok(self):
+ with captured_stdout() as output:
+ self.apply_config(self.config10)
+ logger = logging.getLogger("compiler.parser")
+ logger.warning(self.next_message())
+ logger = logging.getLogger('compiler')
+ #Not output, because filtered
+ logger.warning(self.next_message())
+ logger = logging.getLogger('compiler.lexer')
+ #Not output, because filtered
+ logger.warning(self.next_message())
+ logger = logging.getLogger("compiler.parser.codegen")
+ #Output, as not filtered
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('WARNING', '1'),
+ ('ERROR', '4'),
+ ], stream=output)
+
+ def test_config11_ok(self):
+ self.test_config1_ok(self.config11)
+
+ def test_config12_failure(self):
+ self.assertRaises(Exception, self.apply_config, self.config12)
+
+ def test_config13_failure(self):
+ self.assertRaises(Exception, self.apply_config, self.config13)
+
+ @unittest.skipUnless(threading, 'listen() needs threading to work')
+ def setup_via_listener(self, text):
+ text = text.encode("utf-8")
+ # Ask for a randomly assigned port (by using port 0)
+ t = logging.config.listen(0)
+ t.start()
+ t.ready.wait()
+ # Now get the port allocated
+ port = t.port
+ t.ready.clear()
+ try:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.settimeout(2.0)
+ sock.connect(('localhost', port))
+
+ slen = struct.pack('>L', len(text))
+ s = slen + text
+ sentsofar = 0
+ left = len(s)
+ while left > 0:
+ sent = sock.send(s[sentsofar:])
+ sentsofar += sent
+ left -= sent
+ sock.close()
+ finally:
+ t.ready.wait(2.0)
+ logging.config.stopListening()
+ t.join(2.0)
+
+ def test_listen_config_10_ok(self):
+ with captured_stdout() as output:
+ self.setup_via_listener(json.dumps(self.config10))
+ logger = logging.getLogger("compiler.parser")
+ logger.warning(self.next_message())
+ logger = logging.getLogger('compiler')
+ #Not output, because filtered
+ logger.warning(self.next_message())
+ logger = logging.getLogger('compiler.lexer')
+ #Not output, because filtered
+ logger.warning(self.next_message())
+ logger = logging.getLogger("compiler.parser.codegen")
+ #Output, as not filtered
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('WARNING', '1'),
+ ('ERROR', '4'),
+ ], stream=output)
+
+ def test_listen_config_1_ok(self):
+ with captured_stdout() as output:
+ self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1))
+ logger = logging.getLogger("compiler.parser")
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '1'),
+ ('ERROR', '2'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+
+
+class ManagerTest(BaseTest):
+ def test_manager_loggerclass(self):
+ logged = []
+
+ class MyLogger(logging.Logger):
+ def _log(self, level, msg, args, exc_info=None, extra=None):
+ logged.append(msg)
+
+ man = logging.Manager(None)
+ self.assertRaises(TypeError, man.setLoggerClass, int)
+ man.setLoggerClass(MyLogger)
+ logger = man.getLogger('test')
+ logger.warning('should appear in logged')
+ logging.warning('should not appear in logged')
+
+ self.assertEqual(logged, ['should appear in logged'])
+
+
+class ChildLoggerTest(BaseTest):
+ def test_child_loggers(self):
+ r = logging.getLogger()
+ l1 = logging.getLogger('abc')
+ l2 = logging.getLogger('def.ghi')
+ c1 = r.getChild('xyz')
+ c2 = r.getChild('uvw.xyz')
+ self.assertTrue(c1 is logging.getLogger('xyz'))
+ self.assertTrue(c2 is logging.getLogger('uvw.xyz'))
+ c1 = l1.getChild('def')
+ c2 = c1.getChild('ghi')
+ c3 = l1.getChild('def.ghi')
+ self.assertTrue(c1 is logging.getLogger('abc.def'))
+ self.assertTrue(c2 is logging.getLogger('abc.def.ghi'))
+ self.assertTrue(c2 is c3)
+
+
+class DerivedLogRecord(logging.LogRecord):
+ pass
+
+class LogRecordFactoryTest(BaseTest):
+
+ def setUp(self):
+ class CheckingFilter(logging.Filter):
+ def __init__(self, cls):
+ self.cls = cls
+
+ def filter(self, record):
+ t = type(record)
+ if t is not self.cls:
+ msg = 'Unexpected LogRecord type %s, expected %s' % (t,
+ self.cls)
+ raise TypeError(msg)
+ return True
+
+ BaseTest.setUp(self)
+ self.filter = CheckingFilter(DerivedLogRecord)
+ self.root_logger.addFilter(self.filter)
+ self.orig_factory = logging.getLogRecordFactory()
+
+ def tearDown(self):
+ self.root_logger.removeFilter(self.filter)
+ BaseTest.tearDown(self)
+ logging.setLogRecordFactory(self.orig_factory)
+
+ def test_logrecord_class(self):
+ self.assertRaises(TypeError, self.root_logger.warning,
+ self.next_message())
+ logging.setLogRecordFactory(DerivedLogRecord)
+ self.root_logger.error(self.next_message())
+ self.assert_log_lines([
+ ('root', 'ERROR', '2'),
+ ])
+
+
+class QueueHandlerTest(BaseTest):
+ # Do not bother with a logger name group.
+ expected_log_pat = r"^[\w.]+ -> ([\w]+): ([\d]+)$"
+
+ def setUp(self):
+ BaseTest.setUp(self)
+ self.queue = queue.Queue(-1)
+ self.que_hdlr = logging.handlers.QueueHandler(self.queue)
+ self.que_logger = logging.getLogger('que')
+ self.que_logger.propagate = False
+ self.que_logger.setLevel(logging.WARNING)
+ self.que_logger.addHandler(self.que_hdlr)
+
+ def tearDown(self):
+ self.que_hdlr.close()
+ BaseTest.tearDown(self)
+
+ def test_queue_handler(self):
+ self.que_logger.debug(self.next_message())
+ self.assertRaises(queue.Empty, self.queue.get_nowait)
+ self.que_logger.info(self.next_message())
+ self.assertRaises(queue.Empty, self.queue.get_nowait)
+ msg = self.next_message()
+ self.que_logger.warning(msg)
+ data = self.queue.get_nowait()
+ self.assertTrue(isinstance(data, logging.LogRecord))
+ self.assertEqual(data.name, self.que_logger.name)
+ self.assertEqual((data.msg, data.args), (msg, None))
+
+class FormatterTest(unittest.TestCase):
+ def setUp(self):
+ self.common = {
+ 'name': 'formatter.test',
+ 'level': logging.DEBUG,
+ 'pathname': os.path.join('path', 'to', 'dummy.ext'),
+ 'lineno': 42,
+ 'exc_info': None,
+ 'func': None,
+ 'msg': 'Message with %d %s',
+ 'args': (2, 'placeholders'),
+ }
+ self.variants = {
+ }
+
+ def get_record(self, name=None):
+ result = dict(self.common)
+ if name is not None:
+ result.update(self.variants[name])
+ return logging.makeLogRecord(result)
+
+ def test_percent(self):
+ # Test %-formatting
+ r = self.get_record()
+ f = logging.Formatter('${%(message)s}')
+ self.assertEqual(f.format(r), '${Message with 2 placeholders}')
+ f = logging.Formatter('%(random)s')
+ self.assertRaises(KeyError, f.format, r)
+ self.assertFalse(f.usesTime())
+ f = logging.Formatter('%(asctime)s')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('%(asctime)-15s')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('asctime')
+ self.assertFalse(f.usesTime())
+
+ def test_braces(self):
+ # Test {}-formatting
+ r = self.get_record()
+ f = logging.Formatter('$%{message}%$', style='{')
+ self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
+ f = logging.Formatter('{random}', style='{')
+ self.assertRaises(KeyError, f.format, r)
+ self.assertFalse(f.usesTime())
+ f = logging.Formatter('{asctime}', style='{')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('{asctime!s:15}', style='{')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('{asctime:15}', style='{')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('asctime', style='{')
+ self.assertFalse(f.usesTime())
+
+ def test_dollars(self):
+ # Test $-formatting
+ r = self.get_record()
+ f = logging.Formatter('$message', style='$')
+ self.assertEqual(f.format(r), 'Message with 2 placeholders')
+ f = logging.Formatter('$$%${message}%$$', style='$')
+ self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
+ f = logging.Formatter('${random}', style='$')
+ self.assertRaises(KeyError, f.format, r)
+ self.assertFalse(f.usesTime())
+ f = logging.Formatter('${asctime}', style='$')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('${asctime', style='$')
+ self.assertFalse(f.usesTime())
+ f = logging.Formatter('$asctime', style='$')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('asctime', style='$')
+ self.assertFalse(f.usesTime())
+
+class LastResortTest(BaseTest):
+ def test_last_resort(self):
+ # Test the last resort handler
+ root = self.root_logger
+ root.removeHandler(self.root_hdlr)
+ old_stderr = sys.stderr
+ old_lastresort = logging.lastResort
+ old_raise_exceptions = logging.raiseExceptions
+ try:
+ sys.stderr = sio = io.StringIO()
+ root.warning('This is your final chance!')
+ self.assertEqual(sio.getvalue(), 'This is your final chance!\n')
+ #No handlers and no last resort, so 'No handlers' message
+ logging.lastResort = None
+ sys.stderr = sio = io.StringIO()
+ root.warning('This is your final chance!')
+ self.assertEqual(sio.getvalue(), 'No handlers could be found for logger "root"\n')
+ # 'No handlers' message only printed once
+ sys.stderr = sio = io.StringIO()
+ root.warning('This is your final chance!')
+ self.assertEqual(sio.getvalue(), '')
+ root.manager.emittedNoHandlerWarning = False
+ #If raiseExceptions is False, no message is printed
+ logging.raiseExceptions = False
+ sys.stderr = sio = io.StringIO()
+ root.warning('This is your final chance!')
+ self.assertEqual(sio.getvalue(), '')
+ finally:
+ sys.stderr = old_stderr
+ root.addHandler(self.root_hdlr)
+ logging.lastResort = old_lastresort
+ logging.raiseExceptions = old_raise_exceptions
+
+
+class BaseFileTest(BaseTest):
+ "Base class for handler tests that write log files"
+
+ def setUp(self):
+ BaseTest.setUp(self)
+ fd, self.fn = tempfile.mkstemp(".log", "test_logging-2-")
+ os.close(fd)
+ self.rmfiles = []
+
+ def tearDown(self):
+ for fn in self.rmfiles:
+ os.unlink(fn)
+ if os.path.exists(self.fn):
+ os.unlink(self.fn)
+ BaseTest.tearDown(self)
+
+ def assertLogFile(self, filename):
+ "Assert a log file is there and register it for deletion"
+ self.assertTrue(os.path.exists(filename),
+ msg="Log file %r does not exist")
+ self.rmfiles.append(filename)
+
+
+class RotatingFileHandlerTest(BaseFileTest):
+ def next_rec(self):
+ return logging.LogRecord('n', logging.DEBUG, 'p', 1,
+ self.next_message(), None, None, None)
+
+ def test_should_not_rollover(self):
+ # If maxbytes is zero rollover never occurs
+ rh = logging.handlers.RotatingFileHandler(self.fn, maxBytes=0)
+ self.assertFalse(rh.shouldRollover(None))
+ rh.close()
+
+ def test_should_rollover(self):
+ rh = logging.handlers.RotatingFileHandler(self.fn, maxBytes=1)
+ self.assertTrue(rh.shouldRollover(self.next_rec()))
+ rh.close()
+
+ def test_file_created(self):
+ # checks that the file is created and assumes it was created
+ # by us
+ rh = logging.handlers.RotatingFileHandler(self.fn)
+ rh.emit(self.next_rec())
+ self.assertLogFile(self.fn)
+ rh.close()
+
+ def test_rollover_filenames(self):
+ rh = logging.handlers.RotatingFileHandler(
+ self.fn, backupCount=2, maxBytes=1)
+ rh.emit(self.next_rec())
+ self.assertLogFile(self.fn)
+ rh.emit(self.next_rec())
+ self.assertLogFile(self.fn + ".1")
+ rh.emit(self.next_rec())
+ self.assertLogFile(self.fn + ".2")
+ self.assertFalse(os.path.exists(self.fn + ".3"))
+ rh.close()
+
+class TimedRotatingFileHandlerTest(BaseFileTest):
+ # test methods added below
+ pass
+
+def secs(**kw):
+ return datetime.timedelta(**kw) // datetime.timedelta(seconds=1)
+
+for when, exp in (('S', 1),
+ ('M', 60),
+ ('H', 60 * 60),
+ ('D', 60 * 60 * 24),
+ ('MIDNIGHT', 60 * 60 * 24),
+ # current time (epoch start) is a Thursday, W0 means Monday
+ ('W0', secs(days=4, hours=24)),
+ ):
+ def test_compute_rollover(self, when=when, exp=exp):
+ rh = logging.handlers.TimedRotatingFileHandler(
+ self.fn, when=when, interval=1, backupCount=0, utc=True)
+ currentTime = 0.0
+ actual = rh.computeRollover(currentTime)
+ if exp != actual:
+ # Failures occur on some systems for MIDNIGHT and W0.
+ # Print detailed calculation for MIDNIGHT so we can try to see
+ # what's going on
+ import time
+ if when == 'MIDNIGHT':
+ try:
+ if rh.utc:
+ t = time.gmtime(currentTime)
+ else:
+ t = time.localtime(currentTime)
+ currentHour = t[3]
+ currentMinute = t[4]
+ currentSecond = t[5]
+ # r is the number of seconds left between now and midnight
+ r = logging.handlers._MIDNIGHT - ((currentHour * 60 +
+ currentMinute) * 60 +
+ currentSecond)
+ result = currentTime + r
+ print('t: %s (%s)' % (t, rh.utc), file=sys.stderr)
+ print('currentHour: %s' % currentHour, file=sys.stderr)
+ print('currentMinute: %s' % currentMinute, file=sys.stderr)
+ print('currentSecond: %s' % currentSecond, file=sys.stderr)
+ print('r: %s' % r, file=sys.stderr)
+ print('result: %s' % result, file=sys.stderr)
+ except Exception:
+ print('exception in diagnostic code: %s' % sys.exc_info()[1], file=sys.stderr)
+ self.assertEqual(exp, actual)
+ rh.close()
+ setattr(TimedRotatingFileHandlerTest, "test_compute_rollover_%s" % when, test_compute_rollover)
+
# Set the locale to the platform-dependent default. I have no idea
# why the test does this, but in any case we save the current locale
# first and restore it at the end.
@run_with_locale('LC_ALL', '')
def test_main():
run_unittest(BuiltinLevelsTest, BasicFilterTest,
- CustomLevelsAndFiltersTest, MemoryHandlerTest,
- ConfigFileTest, SocketHandlerTest, MemoryTest,
- EncodingTest, WarningsTest)
+ CustomLevelsAndFiltersTest, MemoryHandlerTest,
+ ConfigFileTest, SocketHandlerTest, MemoryTest,
+ EncodingTest, WarningsTest, ConfigDictTest, ManagerTest,
+ FormatterTest,
+ LogRecordFactoryTest, ChildLoggerTest, QueueHandlerTest,
+ RotatingFileHandlerTest,
+ LastResortTest,
+ TimedRotatingFileHandlerTest
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index 9c2bac735d..04066ec1e7 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -1,9 +1,11 @@
import unittest
from test import support
+
import sys
import random
import math
+import array
# Used for lazy formatting of failure messages
class Frm(object):
@@ -35,25 +37,41 @@ del p2
# add complements & negations
special += [~x for x in special] + [-x for x in special]
-L = [
- ('0', 0),
- ('1', 1),
- ('9', 9),
- ('10', 10),
- ('99', 99),
- ('100', 100),
- ('314', 314),
- (' 314', 314),
- ('314 ', 314),
- (' \t\t 314 \t\t ', 314),
- (repr(sys.maxsize), sys.maxsize),
- (' 1x', ValueError),
- (' 1 ', 1),
- (' 1\02 ', ValueError),
- ('', ValueError),
- (' ', ValueError),
- (' \t\t ', ValueError)
-]
+DBL_MAX = sys.float_info.max
+DBL_MAX_EXP = sys.float_info.max_exp
+DBL_MIN_EXP = sys.float_info.min_exp
+DBL_MANT_DIG = sys.float_info.mant_dig
+DBL_MIN_OVERFLOW = 2**DBL_MAX_EXP - 2**(DBL_MAX_EXP - DBL_MANT_DIG - 1)
+
+# pure Python version of correctly-rounded true division
+def truediv(a, b):
+ """Correctly-rounded true division for integers."""
+ negative = a^b < 0
+ a, b = abs(a), abs(b)
+
+ # exceptions: division by zero, overflow
+ if not b:
+ raise ZeroDivisionError("division by zero")
+ if a >= DBL_MIN_OVERFLOW * b:
+ raise OverflowError("int/int too large to represent as a float")
+
+ # find integer d satisfying 2**(d - 1) <= a/b < 2**d
+ d = a.bit_length() - b.bit_length()
+ if d >= 0 and a >= 2**d * b or d < 0 and a * 2**-d >= b:
+ d += 1
+
+ # compute 2**-exp * a / b for suitable exp
+ exp = max(d, DBL_MIN_EXP) - DBL_MANT_DIG
+ a, b = a << max(-exp, 0), b << max(exp, 0)
+ q, r = divmod(a, b)
+
+ # round-half-to-even: fractional part is r/b, which is > 0.5 iff
+ # 2*r > b, and == 0.5 iff 2*r == b.
+ if 2*r > b or 2*r == b and q % 2 == 1:
+ q += 1
+
+ result = math.ldexp(q, exp)
+ return -result if negative else result
class LongTest(unittest.TestCase):
@@ -254,7 +272,7 @@ class LongTest(unittest.TestCase):
digits = digits or [0]
return '-'[:sign] + \
{2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \
- "".join(map(lambda i: "0123456789abcdef"[i], digits))
+ "".join("0123456789abcdef"[i] for i in digits)
def check_format_1(self, x):
for base, mapper in (8, oct), (10, repr), (16, hex):
@@ -263,7 +281,7 @@ class LongTest(unittest.TestCase):
msg = Frm("%s returned %r but expected %r for %r",
mapper.__name__, got, expected, x)
self.assertEqual(got, expected, msg)
- self.assertEqual(int(got, 0), x, Frm('long("%s", 0) != %r', got, x))
+ self.assertEqual(int(got, 0), x, Frm('int("%s", 0) != %r', got, x))
# str() has to be checked a little differently since there's no
# trailing "L"
got = str(x)
@@ -281,25 +299,12 @@ class LongTest(unittest.TestCase):
self.check_format_1(x)
def test_long(self):
- self.assertEqual(int(314), 314)
- self.assertEqual(int(3.14), 3)
- self.assertEqual(int(314), 314)
- # Check that conversion from float truncates towards zero
- self.assertEqual(int(-3.14), -3)
- self.assertEqual(int(3.9), 3)
- self.assertEqual(int(-3.9), -3)
- self.assertEqual(int(3.5), 3)
- self.assertEqual(int(-3.5), -3)
- self.assertEqual(int("-3"), -3)
- # Different base:
- self.assertEqual(int("10",16), 16)
- # Check conversions from string (same test set as for int(), and then some)
+ # Check conversions from string
LL = [
('1' + '0'*20, 10**20),
('1' + '0'*100, 10**100)
]
- L2 = L[:]
- for s, v in L2 + LL:
+ for s, v in LL:
for sign in "", "+", "-":
for prefix in "", " ", "\t", " \t\t ":
ss = prefix + sign + s
@@ -307,12 +312,10 @@ class LongTest(unittest.TestCase):
if sign == "-" and v is not ValueError:
vv = -v
try:
- self.assertEqual(int(ss), int(vv))
+ self.assertEqual(int(ss), vv)
except ValueError:
pass
- self.assertRaises(ValueError, int, '123\0')
- self.assertRaises(ValueError, int, '53', 40)
# trailing L should no longer be accepted...
self.assertRaises(ValueError, int, '123L')
self.assertRaises(ValueError, int, '123l')
@@ -323,87 +326,6 @@ class LongTest(unittest.TestCase):
# ... but it's just a normal digit if base >= 22
self.assertEqual(int('1L', 22), 43)
- self.assertRaises(TypeError, int, 1, 12)
-
- # SF patch #1638879: embedded NULs were not detected with
- # explicit base
- self.assertRaises(ValueError, int, '123\0', 10)
- self.assertRaises(ValueError, int, '123\x00 245', 20)
-
- self.assertEqual(int('100000000000000000000000000000000', 2),
- 4294967296)
- self.assertEqual(int('102002022201221111211', 3), 4294967296)
- self.assertEqual(int('10000000000000000', 4), 4294967296)
- self.assertEqual(int('32244002423141', 5), 4294967296)
- self.assertEqual(int('1550104015504', 6), 4294967296)
- self.assertEqual(int('211301422354', 7), 4294967296)
- self.assertEqual(int('40000000000', 8), 4294967296)
- self.assertEqual(int('12068657454', 9), 4294967296)
- self.assertEqual(int('4294967296', 10), 4294967296)
- self.assertEqual(int('1904440554', 11), 4294967296)
- self.assertEqual(int('9ba461594', 12), 4294967296)
- self.assertEqual(int('535a79889', 13), 4294967296)
- self.assertEqual(int('2ca5b7464', 14), 4294967296)
- self.assertEqual(int('1a20dcd81', 15), 4294967296)
- self.assertEqual(int('100000000', 16), 4294967296)
- self.assertEqual(int('a7ffda91', 17), 4294967296)
- self.assertEqual(int('704he7g4', 18), 4294967296)
- self.assertEqual(int('4f5aff66', 19), 4294967296)
- self.assertEqual(int('3723ai4g', 20), 4294967296)
- self.assertEqual(int('281d55i4', 21), 4294967296)
- self.assertEqual(int('1fj8b184', 22), 4294967296)
- self.assertEqual(int('1606k7ic', 23), 4294967296)
- self.assertEqual(int('mb994ag', 24), 4294967296)
- self.assertEqual(int('hek2mgl', 25), 4294967296)
- self.assertEqual(int('dnchbnm', 26), 4294967296)
- self.assertEqual(int('b28jpdm', 27), 4294967296)
- self.assertEqual(int('8pfgih4', 28), 4294967296)
- self.assertEqual(int('76beigg', 29), 4294967296)
- self.assertEqual(int('5qmcpqg', 30), 4294967296)
- self.assertEqual(int('4q0jto4', 31), 4294967296)
- self.assertEqual(int('4000000', 32), 4294967296)
- self.assertEqual(int('3aokq94', 33), 4294967296)
- self.assertEqual(int('2qhxjli', 34), 4294967296)
- self.assertEqual(int('2br45qb', 35), 4294967296)
- self.assertEqual(int('1z141z4', 36), 4294967296)
-
- self.assertEqual(int('100000000000000000000000000000001', 2),
- 4294967297)
- self.assertEqual(int('102002022201221111212', 3), 4294967297)
- self.assertEqual(int('10000000000000001', 4), 4294967297)
- self.assertEqual(int('32244002423142', 5), 4294967297)
- self.assertEqual(int('1550104015505', 6), 4294967297)
- self.assertEqual(int('211301422355', 7), 4294967297)
- self.assertEqual(int('40000000001', 8), 4294967297)
- self.assertEqual(int('12068657455', 9), 4294967297)
- self.assertEqual(int('4294967297', 10), 4294967297)
- self.assertEqual(int('1904440555', 11), 4294967297)
- self.assertEqual(int('9ba461595', 12), 4294967297)
- self.assertEqual(int('535a7988a', 13), 4294967297)
- self.assertEqual(int('2ca5b7465', 14), 4294967297)
- self.assertEqual(int('1a20dcd82', 15), 4294967297)
- self.assertEqual(int('100000001', 16), 4294967297)
- self.assertEqual(int('a7ffda92', 17), 4294967297)
- self.assertEqual(int('704he7g5', 18), 4294967297)
- self.assertEqual(int('4f5aff67', 19), 4294967297)
- self.assertEqual(int('3723ai4h', 20), 4294967297)
- self.assertEqual(int('281d55i5', 21), 4294967297)
- self.assertEqual(int('1fj8b185', 22), 4294967297)
- self.assertEqual(int('1606k7id', 23), 4294967297)
- self.assertEqual(int('mb994ah', 24), 4294967297)
- self.assertEqual(int('hek2mgm', 25), 4294967297)
- self.assertEqual(int('dnchbnn', 26), 4294967297)
- self.assertEqual(int('b28jpdn', 27), 4294967297)
- self.assertEqual(int('8pfgih5', 28), 4294967297)
- self.assertEqual(int('76beigh', 29), 4294967297)
- self.assertEqual(int('5qmcpqh', 30), 4294967297)
- self.assertEqual(int('4q0jto5', 31), 4294967297)
- self.assertEqual(int('4000001', 32), 4294967297)
- self.assertEqual(int('3aokq95', 33), 4294967297)
- self.assertEqual(int('2qhxjlj', 34), 4294967297)
- self.assertEqual(int('2br45qc', 35), 4294967297)
- self.assertEqual(int('1z141z5', 36), 4294967297)
-
# tests with base 0
self.assertEqual(int('000', 0), 0)
self.assertEqual(int('0o123', 0), 83)
@@ -419,228 +341,34 @@ class LongTest(unittest.TestCase):
self.assertRaises(ValueError, int, '08', 0)
self.assertRaises(ValueError, int, '-012395', 0)
- def test_conversion(self):
- # Test __int__()
- class ClassicMissingMethods:
- pass
- self.assertRaises(TypeError, int, ClassicMissingMethods())
-
- class MissingMethods(object):
- pass
- self.assertRaises(TypeError, int, MissingMethods())
+ # invalid bases
+ invalid_bases = [-909,
+ 2**31-1, 2**31, -2**31, -2**31-1,
+ 2**63-1, 2**63, -2**63, -2**63-1,
+ 2**100, -2**100,
+ ]
+ for base in invalid_bases:
+ self.assertRaises(ValueError, int, '42', base)
- class Foo0:
- def __int__(self):
- return 42
- class Foo1(object):
- def __int__(self):
- return 42
+ def test_conversion(self):
- class Foo2(int):
- def __int__(self):
+ class JustLong:
+ # test that __long__ no longer used in 3.x
+ def __long__(self):
return 42
+ self.assertRaises(TypeError, int, JustLong())
- class Foo3(int):
- def __int__(self):
- return self
-
- class Foo4(int):
- def __int__(self):
+ class LongTrunc:
+ # __long__ should be ignored in 3.x
+ def __long__(self):
return 42
+ def __trunc__(self):
+ return 1729
+ self.assertEqual(int(LongTrunc()), 1729)
- class Foo5(int):
- def __int__(self):
- return 42.
-
- self.assertEqual(int(Foo0()), 42)
- self.assertEqual(int(Foo1()), 42)
- self.assertEqual(int(Foo2()), 42)
- self.assertEqual(int(Foo3()), 0)
- self.assertEqual(int(Foo4()), 42)
- self.assertRaises(TypeError, int, Foo5())
-
- class Classic:
- pass
- for base in (object, Classic):
- class IntOverridesTrunc(base):
- def __int__(self):
- return 42
- def __trunc__(self):
- return -12
- self.assertEqual(int(IntOverridesTrunc()), 42)
-
- class JustTrunc(base):
- def __trunc__(self):
- return 42
- self.assertEqual(int(JustTrunc()), 42)
-
- class JustLong(base):
- # test that __long__ no longer used in 3.x
- def __long__(self):
- return 42
- self.assertRaises(TypeError, int, JustLong())
-
- class LongTrunc(base):
- # __long__ should be ignored in 3.x
- def __long__(self):
- return 42
- def __trunc__(self):
- return 1729
- self.assertEqual(int(LongTrunc()), 1729)
-
- for trunc_result_base in (object, Classic):
- class Integral(trunc_result_base):
- def __int__(self):
- return 42
-
- class TruncReturnsNonLong(base):
- def __trunc__(self):
- return Integral()
- self.assertEqual(int(TruncReturnsNonLong()), 42)
-
- class NonIntegral(trunc_result_base):
- def __trunc__(self):
- # Check that we avoid infinite recursion.
- return NonIntegral()
-
- class TruncReturnsNonIntegral(base):
- def __trunc__(self):
- return NonIntegral()
- try:
- int(TruncReturnsNonIntegral())
- except TypeError as e:
- self.assertEqual(str(e),
- "__trunc__ returned non-Integral"
- " (type NonIntegral)")
- else:
- self.fail("Failed to raise TypeError with %s" %
- ((base, trunc_result_base),))
-
- def test_misc(self):
-
- # check the extremes in int<->long conversion
- hugepos = sys.maxsize
- hugeneg = -hugepos - 1
- hugepos_aslong = int(hugepos)
- hugeneg_aslong = int(hugeneg)
- self.assertEqual(hugepos, hugepos_aslong, "long(sys.maxsize) != sys.maxsize")
- self.assertEqual(hugeneg, hugeneg_aslong,
- "long(-sys.maxsize-1) != -sys.maxsize-1")
-
- # long -> int should not fail for hugepos_aslong or hugeneg_aslong
- x = int(hugepos_aslong)
- try:
- self.assertEqual(x, hugepos,
- "converting sys.maxsize to long and back to int fails")
- except OverflowError:
- self.fail("int(long(sys.maxsize)) overflowed!")
- if not isinstance(x, int):
- raise TestFailed("int(long(sys.maxsize)) should have returned int")
- x = int(hugeneg_aslong)
- try:
- self.assertEqual(x, hugeneg,
- "converting -sys.maxsize-1 to long and back to int fails")
- except OverflowError:
- self.fail("int(long(-sys.maxsize-1)) overflowed!")
- if not isinstance(x, int):
- raise TestFailed("int(long(-sys.maxsize-1)) should have "
- "returned int")
- # but long -> int should overflow for hugepos+1 and hugeneg-1
- x = hugepos_aslong + 1
- try:
- y = int(x)
- except OverflowError:
- self.fail("int(long(sys.maxsize) + 1) mustn't overflow")
- self.assertTrue(isinstance(y, int),
- "int(long(sys.maxsize) + 1) should have returned long")
-
- x = hugeneg_aslong - 1
- try:
- y = int(x)
- except OverflowError:
- self.fail("int(long(-sys.maxsize-1) - 1) mustn't overflow")
- self.assertTrue(isinstance(y, int),
- "int(long(-sys.maxsize-1) - 1) should have returned long")
-
- class long2(int):
- pass
- x = long2(1<<100)
- y = int(x)
- self.assertTrue(type(y) is int,
- "overflowing int conversion must return long not long subtype")
-
-# ----------------------------------- tests of auto int->long conversion
-
- def test_auto_overflow(self):
- import math, sys
-
- special = [0, 1, 2, 3, sys.maxsize-1, sys.maxsize, sys.maxsize+1]
- sqrt = int(math.sqrt(sys.maxsize))
- special.extend([sqrt-1, sqrt, sqrt+1])
- special.extend([-i for i in special])
-
- def checkit(*args):
- # Heavy use of nested scopes here!
- self.assertEqual(got, expected,
- Frm("for %r expected %r got %r", args, expected, got))
-
- for x in special:
- longx = int(x)
-
- expected = -longx
- got = -x
- checkit('-', x)
-
- for y in special:
- longy = int(y)
-
- expected = longx + longy
- got = x + y
- checkit(x, '+', y)
-
- expected = longx - longy
- got = x - y
- checkit(x, '-', y)
-
- expected = longx * longy
- got = x * y
- checkit(x, '*', y)
-
- if y:
- expected = longx / longy
- got = x / y
- checkit(x, '/', y)
-
- expected = longx // longy
- got = x // y
- checkit(x, '//', y)
-
- expected = divmod(longx, longy)
- got = divmod(longx, longy)
- checkit(x, 'divmod', y)
-
- if abs(y) < 5 and not (x == 0 and y < 0):
- expected = longx ** longy
- got = x ** y
- checkit(x, '**', y)
-
- for z in special:
- if z != 0 :
- if y >= 0:
- expected = pow(longx, longy, int(z))
- got = pow(x, y, z)
- checkit('pow', x, y, '%', z)
- else:
- self.assertRaises(TypeError, pow,longx, longy, int(z))
-
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @support.requires_IEEE_754
def test_float_conversion(self):
- import sys
- DBL_MAX = sys.float_info.max
- DBL_MAX_EXP = sys.float_info.max_exp
- DBL_MANT_DIG = sys.float_info.mant_dig
exact_values = [0, 1, 2,
2**53-3,
@@ -694,8 +422,6 @@ class LongTest(unittest.TestCase):
self.assertEqual(int(float(x)), y)
def test_float_overflow(self):
- import math
-
for x in -2.0, -1.0, 0.0, 1.0, 2.0:
self.assertEqual(float(int(x)), x)
@@ -721,14 +447,12 @@ class LongTest(unittest.TestCase):
self.assertRaises(OverflowError, eval, test, namespace)
- # XXX Perhaps float(shuge) can raise OverflowError on some box?
- # The comparison should not.
- self.assertNotEqual(float(shuge), int(shuge),
- "float(shuge) should not equal int(shuge)")
+ # XXX Perhaps float(shuge) can raise OverflowError on some box?
+ # The comparison should not.
+ self.assertNotEqual(float(shuge), int(shuge),
+ "float(shuge) should not equal int(shuge)")
def test_logs(self):
- import math
-
LOG10E = math.log10(math.e)
for exp in list(range(10)) + [100, 1000, 10000]:
@@ -748,7 +472,6 @@ class LongTest(unittest.TestCase):
def test_mixed_compares(self):
eq = self.assertEqual
- import math
# We're mostly concerned with that mixing floats and longs does the
# right stuff, even when longs are too large to fit in a float.
@@ -794,7 +517,7 @@ class LongTest(unittest.TestCase):
self.d = d
assert float(n) / float(d) == value
else:
- raise TypeError("can't deal with %r" % val)
+ raise TypeError("can't deal with %r" % value)
def _cmp__(self, other):
if not isinstance(other, Rat):
@@ -821,7 +544,7 @@ class LongTest(unittest.TestCase):
cases.extend([t - 1.0, t - 0.3, t, t + 0.3, t + 1.0,
int(t-1), int(t), int(t+1)])
cases.extend([0, 1, 2, sys.maxsize, float(sys.maxsize)])
- # 1L<<20000 should exceed all double formats. long(1e200) is to
+ # 1 << 20000 should exceed all double formats. int(1e200) is to
# check that we get equality with 1e200 above.
t = int(1e200)
cases.extend([0, 1, 2, 1 << 20000, t-1, t, t+1])
@@ -945,6 +668,127 @@ class LongTest(unittest.TestCase):
for zero in ["huge / 0", "mhuge / 0"]:
self.assertRaises(ZeroDivisionError, eval, zero, namespace)
+ def check_truediv(self, a, b, skip_small=True):
+ """Verify that the result of a/b is correctly rounded, by
+ comparing it with a pure Python implementation of correctly
+ rounded division. b should be nonzero."""
+
+ # skip check for small a and b: in this case, the current
+ # implementation converts the arguments to float directly and
+ # then applies a float division. This can give doubly-rounded
+ # results on x87-using machines (particularly 32-bit Linux).
+ if skip_small and max(abs(a), abs(b)) < 2**DBL_MANT_DIG:
+ return
+
+ try:
+ # use repr so that we can distinguish between -0.0 and 0.0
+ expected = repr(truediv(a, b))
+ except OverflowError:
+ expected = 'overflow'
+ except ZeroDivisionError:
+ expected = 'zerodivision'
+
+ try:
+ got = repr(a / b)
+ except OverflowError:
+ got = 'overflow'
+ except ZeroDivisionError:
+ got = 'zerodivision'
+
+ self.assertEqual(expected, got, "Incorrectly rounded division {}/{}: "
+ "expected {}, got {}".format(a, b, expected, got))
+
+ @support.requires_IEEE_754
+ def test_correctly_rounded_true_division(self):
+ # more stringent tests than those above, checking that the
+ # result of true division of ints is always correctly rounded.
+ # This test should probably be considered CPython-specific.
+
+ # Exercise all the code paths not involving Gb-sized ints.
+ # ... divisions involving zero
+ self.check_truediv(123, 0)
+ self.check_truediv(-456, 0)
+ self.check_truediv(0, 3)
+ self.check_truediv(0, -3)
+ self.check_truediv(0, 0)
+ # ... overflow or underflow by large margin
+ self.check_truediv(671 * 12345 * 2**DBL_MAX_EXP, 12345)
+ self.check_truediv(12345, 345678 * 2**(DBL_MANT_DIG - DBL_MIN_EXP))
+ # ... a much larger or smaller than b
+ self.check_truediv(12345*2**100, 98765)
+ self.check_truediv(12345*2**30, 98765*7**81)
+ # ... a / b near a boundary: one of 1, 2**DBL_MANT_DIG, 2**DBL_MIN_EXP,
+ # 2**DBL_MAX_EXP, 2**(DBL_MIN_EXP-DBL_MANT_DIG)
+ bases = (0, DBL_MANT_DIG, DBL_MIN_EXP,
+ DBL_MAX_EXP, DBL_MIN_EXP - DBL_MANT_DIG)
+ for base in bases:
+ for exp in range(base - 15, base + 15):
+ self.check_truediv(75312*2**max(exp, 0), 69187*2**max(-exp, 0))
+ self.check_truediv(69187*2**max(exp, 0), 75312*2**max(-exp, 0))
+
+ # overflow corner case
+ for m in [1, 2, 7, 17, 12345, 7**100,
+ -1, -2, -5, -23, -67891, -41**50]:
+ for n in range(-10, 10):
+ self.check_truediv(m*DBL_MIN_OVERFLOW + n, m)
+ self.check_truediv(m*DBL_MIN_OVERFLOW + n, -m)
+
+ # check detection of inexactness in shifting stage
+ for n in range(250):
+ # (2**DBL_MANT_DIG+1)/(2**DBL_MANT_DIG) lies halfway
+ # between two representable floats, and would usually be
+ # rounded down under round-half-to-even. The tiniest of
+ # additions to the numerator should cause it to be rounded
+ # up instead.
+ self.check_truediv((2**DBL_MANT_DIG + 1)*12345*2**200 + 2**n,
+ 2**DBL_MANT_DIG*12345)
+
+ # 1/2731 is one of the smallest division cases that's subject
+ # to double rounding on IEEE 754 machines working internally with
+ # 64-bit precision. On such machines, the next check would fail,
+ # were it not explicitly skipped in check_truediv.
+ self.check_truediv(1, 2731)
+
+ # a particularly bad case for the old algorithm: gives an
+ # error of close to 3.5 ulps.
+ self.check_truediv(295147931372582273023, 295147932265116303360)
+ for i in range(1000):
+ self.check_truediv(10**(i+1), 10**i)
+ self.check_truediv(10**i, 10**(i+1))
+
+ # test round-half-to-even behaviour, normal result
+ for m in [1, 2, 4, 7, 8, 16, 17, 32, 12345, 7**100,
+ -1, -2, -5, -23, -67891, -41**50]:
+ for n in range(-10, 10):
+ self.check_truediv(2**DBL_MANT_DIG*m + n, m)
+
+ # test round-half-to-even, subnormal result
+ for n in range(-20, 20):
+ self.check_truediv(n, 2**1076)
+
+ # largeish random divisions: a/b where |a| <= |b| <=
+ # 2*|a|; |ans| is between 0.5 and 1.0, so error should
+ # always be bounded by 2**-54 with equality possible only
+ # if the least significant bit of q=ans*2**53 is zero.
+ for M in [10**10, 10**100, 10**1000]:
+ for i in range(1000):
+ a = random.randrange(1, M)
+ b = random.randrange(a, 2*a+1)
+ self.check_truediv(a, b)
+ self.check_truediv(-a, b)
+ self.check_truediv(a, -b)
+ self.check_truediv(-a, -b)
+
+ # and some (genuinely) random tests
+ for _ in range(10000):
+ a_bits = random.randrange(1000)
+ b_bits = random.randrange(1, 1000)
+ x = random.randrange(2**a_bits)
+ y = random.randrange(1, 2**b_bits)
+ self.check_truediv(x, y)
+ self.check_truediv(x, -y)
+ self.check_truediv(-x, y)
+ self.check_truediv(-x, -y)
def test_small_ints(self):
for i in range(-5, 257):
@@ -1072,6 +916,237 @@ class LongTest(unittest.TestCase):
for e in bad_exponents:
self.assertRaises(TypeError, round, 3, e)
+ def test_to_bytes(self):
+ def check(tests, byteorder, signed=False):
+ for test, expected in tests.items():
+ try:
+ self.assertEqual(
+ test.to_bytes(len(expected), byteorder, signed=signed),
+ expected)
+ except Exception as err:
+ raise AssertionError(
+ "failed to convert {0} with byteorder={1} and signed={2}"
+ .format(test, byteorder, signed)) from err
+
+ # Convert integers to signed big-endian byte arrays.
+ tests1 = {
+ 0: b'\x00',
+ 1: b'\x01',
+ -1: b'\xff',
+ -127: b'\x81',
+ -128: b'\x80',
+ -129: b'\xff\x7f',
+ 127: b'\x7f',
+ 129: b'\x00\x81',
+ -255: b'\xff\x01',
+ -256: b'\xff\x00',
+ 255: b'\x00\xff',
+ 256: b'\x01\x00',
+ 32767: b'\x7f\xff',
+ -32768: b'\xff\x80\x00',
+ 65535: b'\x00\xff\xff',
+ -65536: b'\xff\x00\x00',
+ -8388608: b'\x80\x00\x00'
+ }
+ check(tests1, 'big', signed=True)
+
+ # Convert integers to signed little-endian byte arrays.
+ tests2 = {
+ 0: b'\x00',
+ 1: b'\x01',
+ -1: b'\xff',
+ -127: b'\x81',
+ -128: b'\x80',
+ -129: b'\x7f\xff',
+ 127: b'\x7f',
+ 129: b'\x81\x00',
+ -255: b'\x01\xff',
+ -256: b'\x00\xff',
+ 255: b'\xff\x00',
+ 256: b'\x00\x01',
+ 32767: b'\xff\x7f',
+ -32768: b'\x00\x80',
+ 65535: b'\xff\xff\x00',
+ -65536: b'\x00\x00\xff',
+ -8388608: b'\x00\x00\x80'
+ }
+ check(tests2, 'little', signed=True)
+
+ # Convert integers to unsigned big-endian byte arrays.
+ tests3 = {
+ 0: b'\x00',
+ 1: b'\x01',
+ 127: b'\x7f',
+ 128: b'\x80',
+ 255: b'\xff',
+ 256: b'\x01\x00',
+ 32767: b'\x7f\xff',
+ 32768: b'\x80\x00',
+ 65535: b'\xff\xff',
+ 65536: b'\x01\x00\x00'
+ }
+ check(tests3, 'big', signed=False)
+
+ # Convert integers to unsigned little-endian byte arrays.
+ tests4 = {
+ 0: b'\x00',
+ 1: b'\x01',
+ 127: b'\x7f',
+ 128: b'\x80',
+ 255: b'\xff',
+ 256: b'\x00\x01',
+ 32767: b'\xff\x7f',
+ 32768: b'\x00\x80',
+ 65535: b'\xff\xff',
+ 65536: b'\x00\x00\x01'
+ }
+ check(tests4, 'little', signed=False)
+
+ self.assertRaises(OverflowError, (256).to_bytes, 1, 'big', signed=False)
+ self.assertRaises(OverflowError, (256).to_bytes, 1, 'big', signed=True)
+ self.assertRaises(OverflowError, (256).to_bytes, 1, 'little', signed=False)
+ self.assertRaises(OverflowError, (256).to_bytes, 1, 'little', signed=True)
+ self.assertRaises(OverflowError, (-1).to_bytes, 2, 'big', signed=False),
+ self.assertRaises(OverflowError, (-1).to_bytes, 2, 'little', signed=False)
+ self.assertEqual((0).to_bytes(0, 'big'), b'')
+ self.assertEqual((1).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x01')
+ self.assertEqual((0).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x00')
+ self.assertEqual((-1).to_bytes(5, 'big', signed=True),
+ b'\xff\xff\xff\xff\xff')
+ self.assertRaises(OverflowError, (1).to_bytes, 0, 'big')
+
+ def test_from_bytes(self):
+ def check(tests, byteorder, signed=False):
+ for test, expected in tests.items():
+ try:
+ self.assertEqual(
+ int.from_bytes(test, byteorder, signed=signed),
+ expected)
+ except Exception as err:
+ raise AssertionError(
+ "failed to convert {0} with byteorder={1!r} and signed={2}"
+ .format(test, byteorder, signed)) from err
+
+ # Convert signed big-endian byte arrays to integers.
+ tests1 = {
+ b'': 0,
+ b'\x00': 0,
+ b'\x00\x00': 0,
+ b'\x01': 1,
+ b'\x00\x01': 1,
+ b'\xff': -1,
+ b'\xff\xff': -1,
+ b'\x81': -127,
+ b'\x80': -128,
+ b'\xff\x7f': -129,
+ b'\x7f': 127,
+ b'\x00\x81': 129,
+ b'\xff\x01': -255,
+ b'\xff\x00': -256,
+ b'\x00\xff': 255,
+ b'\x01\x00': 256,
+ b'\x7f\xff': 32767,
+ b'\x80\x00': -32768,
+ b'\x00\xff\xff': 65535,
+ b'\xff\x00\x00': -65536,
+ b'\x80\x00\x00': -8388608
+ }
+ check(tests1, 'big', signed=True)
+
+ # Convert signed little-endian byte arrays to integers.
+ tests2 = {
+ b'': 0,
+ b'\x00': 0,
+ b'\x00\x00': 0,
+ b'\x01': 1,
+ b'\x00\x01': 256,
+ b'\xff': -1,
+ b'\xff\xff': -1,
+ b'\x81': -127,
+ b'\x80': -128,
+ b'\x7f\xff': -129,
+ b'\x7f': 127,
+ b'\x81\x00': 129,
+ b'\x01\xff': -255,
+ b'\x00\xff': -256,
+ b'\xff\x00': 255,
+ b'\x00\x01': 256,
+ b'\xff\x7f': 32767,
+ b'\x00\x80': -32768,
+ b'\xff\xff\x00': 65535,
+ b'\x00\x00\xff': -65536,
+ b'\x00\x00\x80': -8388608
+ }
+ check(tests2, 'little', signed=True)
+
+ # Convert unsigned big-endian byte arrays to integers.
+ tests3 = {
+ b'': 0,
+ b'\x00': 0,
+ b'\x01': 1,
+ b'\x7f': 127,
+ b'\x80': 128,
+ b'\xff': 255,
+ b'\x01\x00': 256,
+ b'\x7f\xff': 32767,
+ b'\x80\x00': 32768,
+ b'\xff\xff': 65535,
+ b'\x01\x00\x00': 65536,
+ }
+ check(tests3, 'big', signed=False)
+
+ # Convert integers to unsigned little-endian byte arrays.
+ tests4 = {
+ b'': 0,
+ b'\x00': 0,
+ b'\x01': 1,
+ b'\x7f': 127,
+ b'\x80': 128,
+ b'\xff': 255,
+ b'\x00\x01': 256,
+ b'\xff\x7f': 32767,
+ b'\x00\x80': 32768,
+ b'\xff\xff': 65535,
+ b'\x00\x00\x01': 65536,
+ }
+ check(tests4, 'little', signed=False)
+
+ class myint(int):
+ pass
+
+ self.assertTrue(type(myint.from_bytes(b'\x00', 'big')) is myint)
+ self.assertEqual(myint.from_bytes(b'\x01', 'big'), 1)
+ self.assertTrue(
+ type(myint.from_bytes(b'\x00', 'big', signed=False)) is myint)
+ self.assertEqual(myint.from_bytes(b'\x01', 'big', signed=False), 1)
+ self.assertTrue(type(myint.from_bytes(b'\x00', 'little')) is myint)
+ self.assertEqual(myint.from_bytes(b'\x01', 'little'), 1)
+ self.assertTrue(type(myint.from_bytes(
+ b'\x00', 'little', signed=False)) is myint)
+ self.assertEqual(myint.from_bytes(b'\x01', 'little', signed=False), 1)
+ self.assertEqual(
+ int.from_bytes([255, 0, 0], 'big', signed=True), -65536)
+ self.assertEqual(
+ int.from_bytes((255, 0, 0), 'big', signed=True), -65536)
+ self.assertEqual(int.from_bytes(
+ bytearray(b'\xff\x00\x00'), 'big', signed=True), -65536)
+ self.assertEqual(int.from_bytes(
+ bytearray(b'\xff\x00\x00'), 'big', signed=True), -65536)
+ self.assertEqual(int.from_bytes(
+ array.array('B', b'\xff\x00\x00'), 'big', signed=True), -65536)
+ self.assertEqual(int.from_bytes(
+ memoryview(b'\xff\x00\x00'), 'big', signed=True), -65536)
+ self.assertRaises(ValueError, int.from_bytes, [256], 'big')
+ self.assertRaises(ValueError, int.from_bytes, [0], 'big\x00')
+ self.assertRaises(ValueError, int.from_bytes, [0], 'little\x00')
+ self.assertRaises(TypeError, int.from_bytes, "", 'big')
+ self.assertRaises(TypeError, int.from_bytes, "\x00", 'big')
+ self.assertRaises(TypeError, int.from_bytes, 0, 'big')
+ self.assertRaises(TypeError, int.from_bytes, 0, 'big', True)
+ self.assertRaises(TypeError, myint.from_bytes, "", 'big')
+ self.assertRaises(TypeError, myint.from_bytes, "\x00", 'big')
+ self.assertRaises(TypeError, myint.from_bytes, 0, 'big')
+ self.assertRaises(TypeError, int.from_bytes, 0, 'big', True)
def test_main():
diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py
index b5157bf6e9..d732e14a3a 100644
--- a/Lib/test/test_macpath.py
+++ b/Lib/test/test_macpath.py
@@ -1,5 +1,5 @@
import macpath
-from test import support
+from test import support, test_genericpath
import unittest
@@ -26,42 +26,25 @@ class MacPathTestCase(unittest.TestCase):
self.assertFalse(isabs(b":foo:bar"))
self.assertFalse(isabs(b":foo:bar:"))
-
- def test_commonprefix(self):
- commonprefix = macpath.commonprefix
- self.assertTrue(commonprefix(["home:swenson:spam", "home:swen:spam"])
- == "home:swen")
- self.assertTrue(commonprefix([":home:swen:spam", ":home:swen:eggs"])
- == ":home:swen:")
- self.assertTrue(commonprefix([":home:swen:spam", ":home:swen:spam"])
- == ":home:swen:spam")
-
- self.assertTrue(commonprefix([b"home:swenson:spam", b"home:swen:spam"])
- == b"home:swen")
- self.assertTrue(commonprefix([b":home:swen:spam", b":home:swen:eggs"])
- == b":home:swen:")
- self.assertTrue(commonprefix([b":home:swen:spam", b":home:swen:spam"])
- == b":home:swen:spam")
-
def test_split(self):
split = macpath.split
self.assertEqual(split("foo:bar"),
- ('foo:', 'bar'))
+ ('foo:', 'bar'))
self.assertEqual(split("conky:mountpoint:foo:bar"),
- ('conky:mountpoint:foo', 'bar'))
+ ('conky:mountpoint:foo', 'bar'))
self.assertEqual(split(":"), ('', ''))
self.assertEqual(split(":conky:mountpoint:"),
- (':conky:mountpoint', ''))
+ (':conky:mountpoint', ''))
self.assertEqual(split(b"foo:bar"),
- (b'foo:', b'bar'))
+ (b'foo:', b'bar'))
self.assertEqual(split(b"conky:mountpoint:foo:bar"),
- (b'conky:mountpoint:foo', b'bar'))
+ (b'conky:mountpoint:foo', b'bar'))
self.assertEqual(split(b":"), (b'', b''))
self.assertEqual(split(b":conky:mountpoint:"),
- (b':conky:mountpoint', b''))
+ (b':conky:mountpoint', b''))
def test_join(self):
join = macpath.join
@@ -77,14 +60,6 @@ class MacPathTestCase(unittest.TestCase):
self.assertEqual(join(b'a:b', b':c'), b'a:b:c')
self.assertEqual(join(b'a', b':b', b':c'), b':a:b:c')
- def test_splitdrive(self):
- splitdrive = macpath.splitdrive
- self.assertEqual(splitdrive("foo:bar"), ('', 'foo:bar'))
- self.assertEqual(splitdrive(":foo:bar"), ('', ':foo:bar'))
-
- self.assertEqual(splitdrive(b"foo:bar"), (b'', b'foo:bar'))
- self.assertEqual(splitdrive(b":foo:bar"), (b'', b':foo:bar'))
-
def test_splitext(self):
splitext = macpath.splitext
self.assertEqual(splitext(":foo.ext"), (':foo', '.ext'))
@@ -139,8 +114,13 @@ class MacPathTestCase(unittest.TestCase):
self.assertEqual(normpath(b"a:"), b"a:")
self.assertEqual(normpath(b"a:b:"), b"a:b")
+
+class MacCommonTest(test_genericpath.CommonTest):
+ pathmodule = macpath
+
+
def test_main():
- support.run_unittest(MacPathTestCase)
+ support.run_unittest(MacPathTestCase, MacCommonTest)
if __name__ == "__main__":
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 9a43f8843d..1e4f88759b 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -7,8 +7,10 @@ import email
import email.message
import re
import io
+import tempfile
from test import support
import unittest
+import textwrap
import mailbox
import glob
try:
@@ -21,16 +23,16 @@ class TestBase(unittest.TestCase):
def _check_sample(self, msg):
# Inspect a mailbox.Message representation of the sample message
- self.assertTrue(isinstance(msg, email.message.Message))
- self.assertTrue(isinstance(msg, mailbox.Message))
+ self.assertIsInstance(msg, email.message.Message)
+ self.assertIsInstance(msg, mailbox.Message)
for key, value in _sample_headers.items():
self.assertIn(value, msg.get_all(key))
self.assertTrue(msg.is_multipart())
self.assertEqual(len(msg.get_payload()), len(_sample_payloads))
for i, payload in enumerate(_sample_payloads):
part = msg.get_payload(i)
- self.assertTrue(isinstance(part, email.message.Message))
- self.assertFalse(isinstance(part, mailbox.Message))
+ self.assertIsInstance(part, email.message.Message)
+ self.assertNotIsInstance(part, mailbox.Message)
self.assertEqual(part.get_payload(), payload)
def _delete_recursively(self, target):
@@ -48,6 +50,8 @@ class TestBase(unittest.TestCase):
class TestMailbox(TestBase):
+ maxDiff = None
+
_factory = None # Overridden by subclasses to reuse tests
_template = 'From: foo\n\n%s'
@@ -69,14 +73,124 @@ class TestMailbox(TestBase):
self.assertEqual(len(self._box), 2)
keys.append(self._box.add(email.message_from_string(_sample_message)))
self.assertEqual(len(self._box), 3)
- keys.append(self._box.add(io.StringIO(_sample_message)))
+ keys.append(self._box.add(io.BytesIO(_bytes_sample_message)))
self.assertEqual(len(self._box), 4)
keys.append(self._box.add(_sample_message))
self.assertEqual(len(self._box), 5)
+ keys.append(self._box.add(_bytes_sample_message))
+ self.assertEqual(len(self._box), 6)
+ with self.assertWarns(DeprecationWarning):
+ keys.append(self._box.add(
+ io.TextIOWrapper(io.BytesIO(_bytes_sample_message))))
+ self.assertEqual(len(self._box), 7)
self.assertEqual(self._box.get_string(keys[0]), self._template % 0)
- for i in (1, 2, 3, 4):
+ for i in (1, 2, 3, 4, 5, 6):
self._check_sample(self._box[keys[i]])
+ _nonascii_msg = textwrap.dedent("""\
+ From: foo
+ Subject: Falinaptár házhozszállítással. Már rendeltél?
+
+ 0
+ """)
+
+ def test_add_invalid_8bit_bytes_header(self):
+ key = self._box.add(self._nonascii_msg.encode('latin1'))
+ self.assertEqual(len(self._box), 1)
+ self.assertEqual(self._box.get_bytes(key),
+ self._nonascii_msg.encode('latin1'))
+
+ def test_invalid_nonascii_header_as_string(self):
+ subj = self._nonascii_msg.splitlines()[1]
+ key = self._box.add(subj.encode('latin1'))
+ self.assertEqual(self._box.get_string(key),
+ 'Subject: =?unknown-8bit?b?RmFsaW5hcHThciBo4Xpob3pzeuFsbO104XNz'
+ 'YWwuIE3hciByZW5kZWx06Ww/?=\n\n')
+
+ def test_add_nonascii_string_header_raises(self):
+ with self.assertRaisesRegex(ValueError, "ASCII-only"):
+ self._box.add(self._nonascii_msg)
+ self._box.flush()
+ self.assertEqual(len(self._box), 0)
+ self.assertMailboxEmpty()
+
+ def test_add_that_raises_leaves_mailbox_empty(self):
+ # XXX This test will start failing when Message learns to handle
+ # non-ASCII string headers, and a different internal failure will
+ # need to be found or manufactured.
+ with self.assertRaises(ValueError):
+ self._box.add(email.message_from_string("From: Alphöso"))
+ self.assertEqual(len(self._box), 0)
+ self._box.close()
+ self.assertMailboxEmpty()
+
+ _non_latin_bin_msg = textwrap.dedent("""\
+ From: foo@bar.com
+ To: báz
+ Subject: Maintenant je vous présente mon collègue, le pouf célèbre
+ \tJean de Baddie
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="utf-8"
+ Content-Transfer-Encoding: 8bit
+
+ Да, они летÑÑ‚.
+ """).encode('utf-8')
+
+ def test_add_8bit_body(self):
+ key = self._box.add(self._non_latin_bin_msg)
+ self.assertEqual(self._box.get_bytes(key),
+ self._non_latin_bin_msg)
+ with self._box.get_file(key) as f:
+ self.assertEqual(f.read(),
+ self._non_latin_bin_msg.replace(b'\n',
+ os.linesep.encode()))
+ self.assertEqual(self._box[key].get_payload(),
+ "Да, они летÑÑ‚.\n")
+
+ def test_add_binary_file(self):
+ with tempfile.TemporaryFile('wb+') as f:
+ f.write(_bytes_sample_message)
+ f.seek(0)
+ key = self._box.add(f)
+ # See issue 11062
+ if not isinstance(self._box, mailbox.Babyl):
+ self.assertEqual(self._box.get_bytes(key).split(b'\n'),
+ _bytes_sample_message.split(b'\n'))
+
+ def test_add_binary_nonascii_file(self):
+ with tempfile.TemporaryFile('wb+') as f:
+ f.write(self._non_latin_bin_msg)
+ f.seek(0)
+ key = self._box.add(f)
+ # See issue 11062
+ if not isinstance(self._box, mailbox.Babyl):
+ self.assertEqual(self._box.get_bytes(key).split(b'\n'),
+ self._non_latin_bin_msg.split(b'\n'))
+
+ def test_add_text_file_warns(self):
+ with tempfile.TemporaryFile('w+') as f:
+ f.write(_sample_message)
+ f.seek(0)
+ with self.assertWarns(DeprecationWarning):
+ key = self._box.add(f)
+ # See issue 11062
+ if not isinstance(self._box, mailbox.Babyl):
+ self.assertEqual(self._box.get_bytes(key).split(b'\n'),
+ _bytes_sample_message.split(b'\n'))
+
+ def test_add_StringIO_warns(self):
+ with self.assertWarns(DeprecationWarning):
+ key = self._box.add(io.StringIO(self._template % "0"))
+ self.assertEqual(self._box.get_string(key), self._template % "0")
+
+ def test_add_nonascii_StringIO_raises(self):
+ with self.assertWarns(DeprecationWarning):
+ with self.assertRaisesRegex(ValueError, "ASCII-only"):
+ self._box.add(io.StringIO(self._nonascii_msg))
+ self.assertEqual(len(self._box), 0)
+ self._box.close()
+ self.assertMailboxEmpty()
+
def test_remove(self):
# Remove messages using remove()
self._test_remove_or_delitem(self._box.remove)
@@ -149,27 +263,38 @@ class TestMailbox(TestBase):
key0 = self._box.add(self._template % 0)
key1 = self._box.add(_sample_message)
msg0 = self._box.get_message(key0)
- self.assertTrue(isinstance(msg0, mailbox.Message))
+ self.assertIsInstance(msg0, mailbox.Message)
self.assertEqual(msg0['from'], 'foo')
self.assertEqual(msg0.get_payload(), '0')
self._check_sample(self._box.get_message(key1))
+ def test_get_bytes(self):
+ # Get bytes representations of messages
+ key0 = self._box.add(self._template % 0)
+ key1 = self._box.add(_sample_message)
+ self.assertEqual(self._box.get_bytes(key0),
+ (self._template % 0).encode('ascii'))
+ self.assertEqual(self._box.get_bytes(key1), _bytes_sample_message)
+
def test_get_string(self):
# Get string representations of messages
key0 = self._box.add(self._template % 0)
key1 = self._box.add(_sample_message)
self.assertEqual(self._box.get_string(key0), self._template % 0)
- self.assertEqual(self._box.get_string(key1), _sample_message)
+ self.assertEqual(self._box.get_string(key1).split('\n'),
+ _sample_message.split('\n'))
def test_get_file(self):
# Get file representations of messages
key0 = self._box.add(self._template % 0)
key1 = self._box.add(_sample_message)
- data0 = self._box.get_file(key0).read()
- data1 = self._box.get_file(key1).read()
- self.assertEqual(data0.replace(os.linesep, '\n'),
+ with self._box.get_file(key0) as file:
+ data0 = file.read()
+ with self._box.get_file(key1) as file:
+ data1 = file.read()
+ self.assertEqual(data0.decode('ascii').replace(os.linesep, '\n'),
self._template % 0)
- self.assertEqual(data1.replace(os.linesep, '\n'),
+ self.assertEqual(data1.decode('ascii').replace(os.linesep, '\n'),
_sample_message)
def test_iterkeys(self):
@@ -403,11 +528,12 @@ class TestMailbox(TestBase):
def test_dump_message(self):
# Write message representations to disk
for input in (email.message_from_string(_sample_message),
- _sample_message, io.StringIO(_sample_message)):
- output = io.StringIO()
+ _sample_message, io.BytesIO(_bytes_sample_message)):
+ output = io.BytesIO()
self._box._dump_message(input, output)
- self.assertEqual(output.getvalue(), _sample_message)
- output = io.StringIO()
+ self.assertEqual(output.getvalue(),
+ _bytes_sample_message.replace(b'\n', os.linesep.encode()))
+ output = io.BytesIO()
self.assertRaises(TypeError,
lambda: self._box._dump_message(None, output))
@@ -437,6 +563,7 @@ class TestMailboxSuperclass(TestBase):
self.assertRaises(NotImplementedError, lambda: box.__getitem__(''))
self.assertRaises(NotImplementedError, lambda: box.get_message(''))
self.assertRaises(NotImplementedError, lambda: box.get_string(''))
+ self.assertRaises(NotImplementedError, lambda: box.get_bytes(''))
self.assertRaises(NotImplementedError, lambda: box.get_file(''))
self.assertRaises(NotImplementedError, lambda: '' in box)
self.assertRaises(NotImplementedError, lambda: box.__contains__(''))
@@ -460,6 +587,9 @@ class TestMaildir(TestMailbox):
if os.name in ('nt', 'os2') or sys.platform == 'cygwin':
self._box.colon = '!'
+ def assertMailboxEmpty(self):
+ self.assertEqual(os.listdir(os.path.join(self._path, 'tmp')), [])
+
def test_add_MM(self):
# Add a MaildirMessage instance
msg = mailbox.MaildirMessage(self._template % 0)
@@ -476,7 +606,7 @@ class TestMaildir(TestMailbox):
msg.set_flags('RF')
key = self._box.add(msg)
msg_returned = self._box.get_message(key)
- self.assertTrue(isinstance(msg_returned, mailbox.MaildirMessage))
+ self.assertIsInstance(msg_returned, mailbox.MaildirMessage)
self.assertEqual(msg_returned.get_subdir(), 'cur')
self.assertEqual(msg_returned.get_flags(), 'FR')
@@ -516,7 +646,7 @@ class TestMaildir(TestMailbox):
box = mailbox.Maildir(self._path, factory=FakeMessage)
box.colon = self._box.colon
msg2 = box.get_message(key)
- self.assertTrue(isinstance(msg2, FakeMessage))
+ self.assertIsInstance(msg2, FakeMessage)
def test_initialize_new(self):
# Initialize a non-existent mailbox
@@ -586,12 +716,10 @@ class TestMaildir(TestMailbox):
# Remove old files from 'tmp'
foo_path = os.path.join(self._path, 'tmp', 'foo')
bar_path = os.path.join(self._path, 'tmp', 'bar')
- f = open(foo_path, 'w')
- f.write("@")
- f.close()
- f = open(bar_path, 'w')
- f.write("@")
- f.close()
+ with open(foo_path, 'w') as f:
+ f.write("@")
+ with open(bar_path, 'w') as f:
+ f.write("@")
self._box.clean()
self.assertTrue(os.path.exists(foo_path))
self.assertTrue(os.path.exists(bar_path))
@@ -640,9 +768,9 @@ class TestMaildir(TestMailbox):
"Host name mismatch: '%s' should be '%s'" %
(groups[4], hostname))
previous_groups = groups
- tmp_file.write(_sample_message)
+ tmp_file.write(_bytes_sample_message)
tmp_file.seek(0)
- self.assertEqual(tmp_file.read(), _sample_message)
+ self.assertEqual(tmp_file.read(), _bytes_sample_message)
tmp_file.close()
file_count = len(os.listdir(os.path.join(self._path, "tmp")))
self.assertEqual(file_count, repetitions,
@@ -775,17 +903,28 @@ class TestMaildir(TestMailbox):
class _TestMboxMMDF(TestMailbox):
def tearDown(self):
+ super().tearDown()
self._box.close()
self._delete_recursively(self._path)
for lock_remnant in glob.glob(self._path + '.*'):
support.unlink(lock_remnant)
+ def assertMailboxEmpty(self):
+ with open(self._path) as f:
+ self.assertEqual(f.readlines(), [])
+
def test_add_from_string(self):
# Add a string starting with 'From ' to the mailbox
key = self._box.add('From foo@bar blah\nFrom: foo\n\n0')
self.assertEqual(self._box[key].get_from(), 'foo@bar blah')
self.assertEqual(self._box[key].get_payload(), '0')
+ def test_add_from_bytes(self):
+ # Add a byte string starting with 'From ' to the mailbox
+ key = self._box.add(b'From foo@bar blah\nFrom: foo\n\n0')
+ self.assertEqual(self._box[key].get_from(), 'foo@bar blah')
+ self.assertEqual(self._box[key].get_payload(), '0')
+
def test_add_mbox_or_mmdf_message(self):
# Add an mboxMessage or MMDFMessage
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
@@ -816,7 +955,8 @@ class _TestMboxMMDF(TestMailbox):
self._box._file.seek(0)
contents = self._box._file.read()
self._box.close()
- self.assertEqual(contents, open(self._path, 'r', newline='').read())
+ with open(self._path, 'rb') as f:
+ self.assertEqual(contents, f.read())
self._box = self._factory(self._path)
def test_lock_conflict(self):
@@ -895,6 +1035,9 @@ class TestMH(TestMailbox):
_factory = lambda self, path, factory=None: mailbox.MH(path, factory)
+ def assertMailboxEmpty(self):
+ self.assertEqual(os.listdir(self._path), ['.mh_sequences'])
+
def test_list_folders(self):
# List folders
self._box.add_folder('one')
@@ -968,6 +1111,13 @@ class TestMH(TestMailbox):
key0 = self._box.add(msg0)
refmsg0 = self._box.get_message(key0)
+ def test_issue7627(self):
+ msg0 = mailbox.MHMessage(self._template % 0)
+ key0 = self._box.add(msg0)
+ self._box.lock()
+ self._box.remove(key0)
+ self._box.unlock()
+
def test_pack(self):
# Pack the contents of the mailbox
msg0 = mailbox.MHMessage(self._template % 0)
@@ -1020,7 +1170,12 @@ class TestBabyl(TestMailbox):
_factory = lambda self, path, factory=None: mailbox.Babyl(path, factory)
+ def assertMailboxEmpty(self):
+ with open(self._path) as f:
+ self.assertEqual(f.readlines(), [])
+
def tearDown(self):
+ super().tearDown()
self._box.close()
self._delete_recursively(self._path)
for lock_remnant in glob.glob(self._path + '.*'):
@@ -1070,21 +1225,29 @@ class TestMessage(TestBase):
def test_initialize_with_file(self):
# Initialize based on contents of file
- f = open(self._path, 'w+')
- f.write(_sample_message)
- f.seek(0)
- msg = self._factory(f)
- self._post_initialize_hook(msg)
- self._check_sample(msg)
- f.close()
+ with open(self._path, 'w+') as f:
+ f.write(_sample_message)
+ f.seek(0)
+ msg = self._factory(f)
+ self._post_initialize_hook(msg)
+ self._check_sample(msg)
+
+ def test_initialize_with_binary_file(self):
+ # Initialize based on contents of binary file
+ with open(self._path, 'wb+') as f:
+ f.write(_bytes_sample_message)
+ f.seek(0)
+ msg = self._factory(f)
+ self._post_initialize_hook(msg)
+ self._check_sample(msg)
def test_initialize_with_nothing(self):
# Initialize without arguments
msg = self._factory()
self._post_initialize_hook(msg)
- self.assertTrue(isinstance(msg, email.message.Message))
- self.assertTrue(isinstance(msg, mailbox.Message))
- self.assertTrue(isinstance(msg, self._factory))
+ self.assertIsInstance(msg, email.message.Message)
+ self.assertIsInstance(msg, mailbox.Message)
+ self.assertIsInstance(msg, self._factory)
self.assertEqual(msg.keys(), [])
self.assertFalse(msg.is_multipart())
self.assertEqual(msg.get_payload(), None)
@@ -1354,6 +1517,14 @@ class TestMessageConversion(TestBase):
msg_plain = mailbox.Message(msg)
self._check_sample(msg_plain)
+ def test_x_from_bytes(self):
+ # Convert all formats to Message
+ for class_ in (mailbox.Message, mailbox.MaildirMessage,
+ mailbox.mboxMessage, mailbox.MHMessage,
+ mailbox.BabylMessage, mailbox.MMDFMessage):
+ msg = class_(_bytes_sample_message)
+ self._check_sample(msg)
+
def test_x_to_invalid(self):
# Convert all formats to an invalid format
for class_ in (mailbox.Message, mailbox.MaildirMessage,
@@ -1800,18 +1971,16 @@ class MaildirTestCase(unittest.TestCase):
filename = ".".join((str(t), str(pid), "myhostname", "mydomain"))
tmpname = os.path.join(self._dir, "tmp", filename)
newname = os.path.join(self._dir, dir, filename)
- fp = open(tmpname, "w")
- self._msgfiles.append(tmpname)
- if mbox:
- fp.write(FROM_)
- fp.write(DUMMY_MESSAGE)
- fp.close()
+ with open(tmpname, "w") as fp:
+ self._msgfiles.append(tmpname)
+ if mbox:
+ fp.write(FROM_)
+ fp.write(DUMMY_MESSAGE)
if hasattr(os, "link"):
os.link(tmpname, newname)
else:
- fp = open(newname, "w")
- fp.write(DUMMY_MESSAGE)
- fp.close()
+ with open(newname, "w") as fp:
+ fp.write(DUMMY_MESSAGE)
self._msgfiles.append(newname)
return tmpname
@@ -1901,6 +2070,8 @@ H4sICM2D1UIAA3RleHQAC8nILFYAokSFktSKEoW0zJxUPa7wzJIMhZLyfIWczLzUYj0uAHTs
--NMuMz9nt05w80d4+--
"""
+_bytes_sample_message = _sample_message.encode('ascii')
+
_sample_headers = {
"Return-Path":"<gkj@gregorykjohnson.com>",
"X-Original-To":"gkj+person@localhost",
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index 5e1cdd5052..81cf598402 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from test import support
import marshal
@@ -11,16 +11,10 @@ class HelperMixin:
new = marshal.loads(marshal.dumps(sample, *extra))
self.assertEqual(sample, new)
try:
- f = open(support.TESTFN, "wb")
- try:
+ with open(support.TESTFN, "wb") as f:
marshal.dump(sample, f, *extra)
- finally:
- f.close()
- f = open(support.TESTFN, "rb")
- try:
+ with open(support.TESTFN, "rb") as f:
new = marshal.load(f)
- finally:
- f.close()
self.assertEqual(sample, new)
finally:
support.unlink(support.TESTFN)
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 9a87d5d307..dddc889375 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -1,12 +1,14 @@
# Python test set -- math module
# XXXX Should not do tests around zero only
-from test.support import run_unittest, verbose
+from test.support import run_unittest, verbose, requires_IEEE_754
import unittest
import math
import os
import sys
import random
+import struct
+import sysconfig
eps = 1E-05
NAN = float('nan')
@@ -24,8 +26,130 @@ if __name__ == '__main__':
else:
file = __file__
test_dir = os.path.dirname(file) or os.curdir
+math_testcases = os.path.join(test_dir, 'math_testcases.txt')
test_file = os.path.join(test_dir, 'cmath_testcases.txt')
+def to_ulps(x):
+ """Convert a non-NaN float x to an integer, in such a way that
+ adjacent floats are converted to adjacent integers. Then
+ abs(ulps(x) - ulps(y)) gives the difference in ulps between two
+ floats.
+
+ The results from this function will only make sense on platforms
+ where C doubles are represented in IEEE 754 binary64 format.
+
+ """
+ n = struct.unpack('<q', struct.pack('<d', x))[0]
+ if n < 0:
+ n = ~(n+2**63)
+ return n
+
+def ulps_check(expected, got, ulps=20):
+ """Given non-NaN floats `expected` and `got`,
+ check that they're equal to within the given number of ulps.
+
+ Returns None on success and an error message on failure."""
+
+ ulps_error = to_ulps(got) - to_ulps(expected)
+ if abs(ulps_error) <= ulps:
+ return None
+ return "error = {} ulps; permitted error = {} ulps".format(ulps_error,
+ ulps)
+
+# Here's a pure Python version of the math.factorial algorithm, for
+# documentation and comparison purposes.
+#
+# Formula:
+#
+# factorial(n) = factorial_odd_part(n) << (n - count_set_bits(n))
+#
+# where
+#
+# factorial_odd_part(n) = product_{i >= 0} product_{0 < j <= n >> i; j odd} j
+#
+# The outer product above is an infinite product, but once i >= n.bit_length,
+# (n >> i) < 1 and the corresponding term of the product is empty. So only the
+# finitely many terms for 0 <= i < n.bit_length() contribute anything.
+#
+# We iterate downwards from i == n.bit_length() - 1 to i == 0. The inner
+# product in the formula above starts at 1 for i == n.bit_length(); for each i
+# < n.bit_length() we get the inner product for i from that for i + 1 by
+# multiplying by all j in {n >> i+1 < j <= n >> i; j odd}. In Python terms,
+# this set is range((n >> i+1) + 1 | 1, (n >> i) + 1 | 1, 2).
+
+def count_set_bits(n):
+ """Number of '1' bits in binary expansion of a nonnnegative integer."""
+ return 1 + count_set_bits(n & n - 1) if n else 0
+
+def partial_product(start, stop):
+ """Product of integers in range(start, stop, 2), computed recursively.
+ start and stop should both be odd, with start <= stop.
+
+ """
+ numfactors = (stop - start) >> 1
+ if not numfactors:
+ return 1
+ elif numfactors == 1:
+ return start
+ else:
+ mid = (start + numfactors) | 1
+ return partial_product(start, mid) * partial_product(mid, stop)
+
+def py_factorial(n):
+ """Factorial of nonnegative integer n, via "Binary Split Factorial Formula"
+ described at http://www.luschny.de/math/factorial/binarysplitfact.html
+
+ """
+ inner = outer = 1
+ for i in reversed(range(n.bit_length())):
+ inner *= partial_product((n >> i + 1) + 1 | 1, (n >> i) + 1 | 1)
+ outer *= inner
+ return outer << (n - count_set_bits(n))
+
+def acc_check(expected, got, rel_err=2e-15, abs_err = 5e-323):
+ """Determine whether non-NaN floats a and b are equal to within a
+ (small) rounding error. The default values for rel_err and
+ abs_err are chosen to be suitable for platforms where a float is
+ represented by an IEEE 754 double. They allow an error of between
+ 9 and 19 ulps."""
+
+ # need to special case infinities, since inf - inf gives nan
+ if math.isinf(expected) and got == expected:
+ return None
+
+ error = got - expected
+
+ permitted_error = max(abs_err, rel_err * abs(expected))
+ if abs(error) < permitted_error:
+ return None
+ return "error = {}; permitted error = {}".format(error,
+ permitted_error)
+
+def parse_mtestfile(fname):
+ """Parse a file with test values
+
+ -- starts a comment
+ blank lines, or lines containing only a comment, are ignored
+ other lines are expected to have the form
+ id fn arg -> expected [flag]*
+
+ """
+ with open(fname) as fp:
+ for line in fp:
+ # strip comments, and skip blank lines
+ if '--' in line:
+ line = line[:line.index('--')]
+ if not line.strip():
+ continue
+
+ lhs, rhs = line.split('->')
+ id, fn, arg = lhs.split()
+ rhs_pieces = rhs.split()
+ exp = rhs_pieces[0]
+ flags = rhs_pieces[1:]
+
+ yield (id, fn, float(arg), float(exp), flags)
+
def parse_testfile(fname):
"""Parse a file with test values
@@ -209,39 +333,39 @@ class MathTests(unittest.TestCase):
self.assertRaises(TypeError, math.ceil, t)
self.assertRaises(TypeError, math.ceil, t, 0)
- if float.__getformat__("double").startswith("IEEE"):
- def testCopysign(self):
- self.assertEqual(math.copysign(1, 42), 1.0)
- self.assertEqual(math.copysign(0., 42), 0.0)
- self.assertEqual(math.copysign(1., -42), -1.0)
- self.assertEqual(math.copysign(3, 0.), 3.0)
- self.assertEqual(math.copysign(4., -0.), -4.0)
-
- self.assertRaises(TypeError, math.copysign)
- # copysign should let us distinguish signs of zeros
- self.assertEqual(math.copysign(1., 0.), 1.)
- self.assertEqual(math.copysign(1., -0.), -1.)
- self.assertEqual(math.copysign(INF, 0.), INF)
- self.assertEqual(math.copysign(INF, -0.), NINF)
- self.assertEqual(math.copysign(NINF, 0.), INF)
- self.assertEqual(math.copysign(NINF, -0.), NINF)
- # and of infinities
- self.assertEqual(math.copysign(1., INF), 1.)
- self.assertEqual(math.copysign(1., NINF), -1.)
- self.assertEqual(math.copysign(INF, INF), INF)
- self.assertEqual(math.copysign(INF, NINF), NINF)
- self.assertEqual(math.copysign(NINF, INF), INF)
- self.assertEqual(math.copysign(NINF, NINF), NINF)
- self.assertTrue(math.isnan(math.copysign(NAN, 1.)))
- self.assertTrue(math.isnan(math.copysign(NAN, INF)))
- self.assertTrue(math.isnan(math.copysign(NAN, NINF)))
- self.assertTrue(math.isnan(math.copysign(NAN, NAN)))
- # copysign(INF, NAN) may be INF or it may be NINF, since
- # we don't know whether the sign bit of NAN is set on any
- # given platform.
- self.assertTrue(math.isinf(math.copysign(INF, NAN)))
- # similarly, copysign(2., NAN) could be 2. or -2.
- self.assertEqual(abs(math.copysign(2., NAN)), 2.)
+ @requires_IEEE_754
+ def testCopysign(self):
+ self.assertEqual(math.copysign(1, 42), 1.0)
+ self.assertEqual(math.copysign(0., 42), 0.0)
+ self.assertEqual(math.copysign(1., -42), -1.0)
+ self.assertEqual(math.copysign(3, 0.), 3.0)
+ self.assertEqual(math.copysign(4., -0.), -4.0)
+
+ self.assertRaises(TypeError, math.copysign)
+ # copysign should let us distinguish signs of zeros
+ self.assertEqual(math.copysign(1., 0.), 1.)
+ self.assertEqual(math.copysign(1., -0.), -1.)
+ self.assertEqual(math.copysign(INF, 0.), INF)
+ self.assertEqual(math.copysign(INF, -0.), NINF)
+ self.assertEqual(math.copysign(NINF, 0.), INF)
+ self.assertEqual(math.copysign(NINF, -0.), NINF)
+ # and of infinities
+ self.assertEqual(math.copysign(1., INF), 1.)
+ self.assertEqual(math.copysign(1., NINF), -1.)
+ self.assertEqual(math.copysign(INF, INF), INF)
+ self.assertEqual(math.copysign(INF, NINF), NINF)
+ self.assertEqual(math.copysign(NINF, INF), INF)
+ self.assertEqual(math.copysign(NINF, NINF), NINF)
+ self.assertTrue(math.isnan(math.copysign(NAN, 1.)))
+ self.assertTrue(math.isnan(math.copysign(NAN, INF)))
+ self.assertTrue(math.isnan(math.copysign(NAN, NINF)))
+ self.assertTrue(math.isnan(math.copysign(NAN, NAN)))
+ # copysign(INF, NAN) may be INF or it may be NINF, since
+ # we don't know whether the sign bit of NAN is set on any
+ # given platform.
+ self.assertTrue(math.isinf(math.copysign(INF, NAN)))
+ # similarly, copysign(2., NAN) could be 2. or -2.
+ self.assertEqual(abs(math.copysign(2., NAN)), 2.)
def testCos(self):
self.assertRaises(TypeError, math.cos)
@@ -287,18 +411,19 @@ class MathTests(unittest.TestCase):
self.ftest('fabs(1)', math.fabs(1), 1)
def testFactorial(self):
- def fact(n):
- result = 1
- for i in range(1, int(n)+1):
- result *= i
- return result
- values = list(range(10)) + [50, 100, 500]
- random.shuffle(values)
- for x in values:
- for cast in (int, float):
- self.assertEqual(math.factorial(cast(x)), fact(x), (x, fact(x), math.factorial(x)))
+ self.assertEqual(math.factorial(0), 1)
+ self.assertEqual(math.factorial(0.0), 1)
+ total = 1
+ for i in range(1, 1000):
+ total *= i
+ self.assertEqual(math.factorial(i), total)
+ self.assertEqual(math.factorial(float(i)), total)
+ self.assertEqual(math.factorial(i), py_factorial(i))
self.assertRaises(ValueError, math.factorial, -1)
+ self.assertRaises(ValueError, math.factorial, -1.0)
self.assertRaises(ValueError, math.factorial, math.pi)
+ self.assertRaises(OverflowError, math.factorial, sys.maxsize+1)
+ self.assertRaises(OverflowError, math.factorial, 10e100)
def testFloor(self):
self.assertRaises(TypeError, math.floor)
@@ -370,8 +495,7 @@ class MathTests(unittest.TestCase):
self.assertEqual(math.frexp(NINF)[0], NINF)
self.assertTrue(math.isnan(math.frexp(NAN)[0]))
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @requires_IEEE_754
@unittest.skipIf(HAVE_DOUBLE_ROUNDING,
"fsum is not exact on machines with double rounding")
def testFsum(self):
@@ -513,21 +637,17 @@ class MathTests(unittest.TestCase):
self.ftest('log(32,2)', math.log(32,2), 5)
self.ftest('log(10**40, 10)', math.log(10**40, 10), 40)
self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2)
- self.assertEqual(math.log(INF), INF)
+ self.ftest('log(10**1000)', math.log(10**1000),
+ 2302.5850929940457)
+ self.assertRaises(ValueError, math.log, -1.5)
+ self.assertRaises(ValueError, math.log, -10**1000)
self.assertRaises(ValueError, math.log, NINF)
+ self.assertEqual(math.log(INF), INF)
self.assertTrue(math.isnan(math.log(NAN)))
def testLog1p(self):
self.assertRaises(TypeError, math.log1p)
- self.ftest('log1p(1/e -1)', math.log1p(1/math.e-1), -1)
- self.ftest('log1p(0)', math.log1p(0), 0)
- self.ftest('log1p(e-1)', math.log1p(math.e-1), 1)
- self.ftest('log1p(1)', math.log1p(1), math.log(2))
- self.assertEqual(math.log1p(INF), INF)
- self.assertRaises(ValueError, math.log1p, NINF)
- self.assertTrue(math.isnan(math.log1p(NAN)))
n= 2**90
- self.assertAlmostEqual(math.log1p(n), 62.383246250395075)
self.assertAlmostEqual(math.log1p(n), math.log1p(float(n)))
def testLog10(self):
@@ -535,8 +655,11 @@ class MathTests(unittest.TestCase):
self.ftest('log10(0.1)', math.log10(0.1), -1)
self.ftest('log10(1)', math.log10(1), 0)
self.ftest('log10(10)', math.log10(10), 1)
- self.assertEqual(math.log(INF), INF)
+ self.ftest('log10(10**1000)', math.log10(10**1000), 1000.0)
+ self.assertRaises(ValueError, math.log10, -1.5)
+ self.assertRaises(ValueError, math.log10, -10**1000)
self.assertRaises(ValueError, math.log10, NINF)
+ self.assertEqual(math.log(INF), INF)
self.assertTrue(math.isnan(math.log10(NAN)))
def testModf(self):
@@ -764,11 +887,15 @@ class MathTests(unittest.TestCase):
self.ftest('tanh(inf)', math.tanh(INF), 1)
self.ftest('tanh(-inf)', math.tanh(NINF), -1)
self.assertTrue(math.isnan(math.tanh(NAN)))
+
+ @requires_IEEE_754
+ @unittest.skipIf(sysconfig.get_config_var('TANH_PRESERVES_ZERO_SIGN') == 0,
+ "system tanh() function doesn't copy the sign")
+ def testTanhSign(self):
# check that tanh(-0.) == -0. on IEEE 754 systems
- if float.__getformat__("double").startswith("IEEE"):
- self.assertEqual(math.tanh(-0.), -0.)
- self.assertEqual(math.copysign(1., math.tanh(-0.)),
- math.copysign(1., -0.))
+ self.assertEqual(math.tanh(-0.), -0.)
+ self.assertEqual(math.copysign(1., math.tanh(-0.)),
+ math.copysign(1., -0.))
def test_trunc(self):
self.assertEqual(math.trunc(1), 1)
@@ -795,12 +922,14 @@ class MathTests(unittest.TestCase):
self.assertRaises(TypeError, math.trunc, 1, 2)
self.assertRaises(TypeError, math.trunc, TestNoTrunc())
- # XXX Doesn't work because the method is looked up on
- # the type only.
- #t = TestNoTrunc()
- #t.__trunc__ = lambda *args: args
- #self.assertEqual((), math.trunc(t))
- #self.assertRaises(TypeError, math.trunc, t, 0)
+ def testIsfinite(self):
+ self.assertTrue(math.isfinite(0.0))
+ self.assertTrue(math.isfinite(-0.0))
+ self.assertTrue(math.isfinite(1.0))
+ self.assertTrue(math.isfinite(-1.0))
+ self.assertFalse(math.isfinite(float("nan")))
+ self.assertFalse(math.isfinite(float("inf")))
+ self.assertFalse(math.isfinite(float("-inf")))
def testIsnan(self):
self.assertTrue(math.isnan(float("nan")))
@@ -856,9 +985,8 @@ class MathTests(unittest.TestCase):
else:
self.fail("sqrt(-1) didn't raise ValueError")
+ @requires_IEEE_754
def test_testfile(self):
- if not float.__getformat__("double").startswith("IEEE"):
- return
for id, fn, ar, ai, er, ei, flags in parse_testfile(test_file):
# Skip if either the input or result is complex, or if
# flags is nonempty
@@ -880,6 +1008,68 @@ class MathTests(unittest.TestCase):
self.fail(message)
self.ftest("%s:%s(%r)" % (id, fn, ar), result, er)
+ @requires_IEEE_754
+ def test_mtestfile(self):
+ ALLOWED_ERROR = 20 # permitted error, in ulps
+ fail_fmt = "{}:{}({!r}): expected {!r}, got {!r}"
+
+ failures = []
+ for id, fn, arg, expected, flags in parse_mtestfile(math_testcases):
+ func = getattr(math, fn)
+
+ if 'invalid' in flags or 'divide-by-zero' in flags:
+ expected = 'ValueError'
+ elif 'overflow' in flags:
+ expected = 'OverflowError'
+
+ try:
+ got = func(arg)
+ except ValueError:
+ got = 'ValueError'
+ except OverflowError:
+ got = 'OverflowError'
+
+ accuracy_failure = None
+ if isinstance(got, float) and isinstance(expected, float):
+ if math.isnan(expected) and math.isnan(got):
+ continue
+ if not math.isnan(expected) and not math.isnan(got):
+ if fn == 'lgamma':
+ # we use a weaker accuracy test for lgamma;
+ # lgamma only achieves an absolute error of
+ # a few multiples of the machine accuracy, in
+ # general.
+ accuracy_failure = acc_check(expected, got,
+ rel_err = 5e-15,
+ abs_err = 5e-15)
+ elif fn == 'erfc':
+ # erfc has less-than-ideal accuracy for large
+ # arguments (x ~ 25 or so), mainly due to the
+ # error involved in computing exp(-x*x).
+ #
+ # XXX Would be better to weaken this test only
+ # for large x, instead of for all x.
+ accuracy_failure = ulps_check(expected, got, 2000)
+
+ else:
+ accuracy_failure = ulps_check(expected, got, 20)
+ if accuracy_failure is None:
+ continue
+
+ if isinstance(got, str) and isinstance(expected, str):
+ if got == expected:
+ continue
+
+ fail_msg = fail_fmt.format(id, fn, arg, expected, got)
+ if accuracy_failure is not None:
+ fail_msg += ' ({})'.format(accuracy_failure)
+ failures.append(fail_msg)
+
+ if failures:
+ self.fail('Failures in test_mtestfile:\n ' +
+ '\n '.join(failures))
+
+
def test_main():
from doctest import DocFileSuite
suite = unittest.TestSuite()
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
index b45845d6bf..49ca44f102 100644
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -8,7 +8,7 @@ from test import support
import io
import _pyio as pyio
-import sys
+import pickle
class MemorySeekTestMixin:
@@ -347,8 +347,68 @@ class MemoryTestMixin:
memio = self.ioclass()
memio.foo = 1
-
-class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
+ def test_pickling(self):
+ buf = self.buftype("1234567890")
+ memio = self.ioclass(buf)
+ memio.foo = 42
+ memio.seek(2)
+
+ class PickleTestMemIO(self.ioclass):
+ def __init__(me, initvalue, foo):
+ self.ioclass.__init__(me, initvalue)
+ me.foo = foo
+ # __getnewargs__ is undefined on purpose. This checks that PEP 307
+ # is used to provide pickling support.
+
+ # Pickle expects the class to be on the module level. Here we use a
+ # little hack to allow the PickleTestMemIO class to derive from
+ # self.ioclass without having to define all combinations explictly on
+ # the module-level.
+ import __main__
+ PickleTestMemIO.__module__ = '__main__'
+ __main__.PickleTestMemIO = PickleTestMemIO
+ submemio = PickleTestMemIO(buf, 80)
+ submemio.seek(2)
+
+ # We only support pickle protocol 2 and onward since we use extended
+ # __reduce__ API of PEP 307 to provide pickling support.
+ for proto in range(2, pickle.HIGHEST_PROTOCOL):
+ for obj in (memio, submemio):
+ obj2 = pickle.loads(pickle.dumps(obj, protocol=proto))
+ self.assertEqual(obj.getvalue(), obj2.getvalue())
+ self.assertEqual(obj.__class__, obj2.__class__)
+ self.assertEqual(obj.foo, obj2.foo)
+ self.assertEqual(obj.tell(), obj2.tell())
+ obj.close()
+ self.assertRaises(ValueError, pickle.dumps, obj, proto)
+ del __main__.PickleTestMemIO
+
+
+class BytesIOMixin:
+
+ def test_getbuffer(self):
+ memio = self.ioclass(b"1234567890")
+ buf = memio.getbuffer()
+ self.assertEqual(bytes(buf), b"1234567890")
+ memio.seek(5)
+ buf = memio.getbuffer()
+ self.assertEqual(bytes(buf), b"1234567890")
+ # Trying to change the size of the BytesIO while a buffer is exported
+ # raises a BufferError.
+ self.assertRaises(BufferError, memio.write, b'x' * 100)
+ self.assertRaises(BufferError, memio.truncate)
+ # Mutating the buffer updates the BytesIO
+ buf[3:6] = b"abc"
+ self.assertEqual(bytes(buf), b"123abc7890")
+ self.assertEqual(memio.getvalue(), b"123abc7890")
+ # After the buffer gets released, we can resize the BytesIO again
+ del buf
+ support.gc_collect()
+ memio.truncate()
+
+
+class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin,
+ BytesIOMixin, unittest.TestCase):
UnsupportedOperation = pyio.UnsupportedOperation
@@ -389,7 +449,7 @@ class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
a = array.array('b', b"hello world")
memio = self.ioclass(buf)
memio.readinto(a)
- self.assertEqual(a.tostring(), b"1234567890d")
+ self.assertEqual(a.tobytes(), b"1234567890d")
memio.close()
self.assertRaises(ValueError, memio.readinto, b)
memio = self.ioclass(b"123")
@@ -435,13 +495,8 @@ class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
self.ioclass(initial_bytes=buf)
self.assertRaises(TypeError, self.ioclass, buf, foo=None)
-class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
- buftype = str
- ioclass = pyio.StringIO
- UnsupportedOperation = pyio.UnsupportedOperation
- EOF = ""
- # TextIO-specific behaviour.
+class TextIOTestMixin:
def test_newlines_property(self):
memio = self.ioclass(newline=None)
@@ -523,7 +578,6 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
def test_newline_cr(self):
# newline="\r"
memio = self.ioclass("a\nb\r\nc\rd", newline="\r")
- memio.seek(0)
self.assertEqual(memio.read(), "a\rb\r\rc\rd")
memio.seek(0)
self.assertEqual(list(memio), ["a\r", "b\r", "\r", "c\r", "d"])
@@ -531,7 +585,6 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
def test_newline_crlf(self):
# newline="\r\n"
memio = self.ioclass("a\nb\r\nc\rd", newline="\r\n")
- memio.seek(0)
self.assertEqual(memio.read(), "a\r\nb\r\r\nc\rd")
memio.seek(0)
self.assertEqual(list(memio), ["a\r\n", "b\r\r\n", "c\rd"])
@@ -549,10 +602,59 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
self.ioclass(newline=newline)
+class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin,
+ TextIOTestMixin, unittest.TestCase):
+ buftype = str
+ ioclass = pyio.StringIO
+ UnsupportedOperation = pyio.UnsupportedOperation
+ EOF = ""
+
+
+class PyStringIOPickleTest(TextIOTestMixin, unittest.TestCase):
+ """Test if pickle restores properly the internal state of StringIO.
+ """
+ buftype = str
+ UnsupportedOperation = pyio.UnsupportedOperation
+ EOF = ""
+
+ class ioclass(pyio.StringIO):
+ def __new__(cls, *args, **kwargs):
+ return pickle.loads(pickle.dumps(pyio.StringIO(*args, **kwargs)))
+ def __init__(self, *args, **kwargs):
+ pass
+
+
class CBytesIOTest(PyBytesIOTest):
ioclass = io.BytesIO
UnsupportedOperation = io.UnsupportedOperation
+ def test_getstate(self):
+ memio = self.ioclass()
+ state = memio.__getstate__()
+ self.assertEqual(len(state), 3)
+ bytearray(state[0]) # Check if state[0] supports the buffer interface.
+ self.assertIsInstance(state[1], int)
+ self.assertTrue(isinstance(state[2], dict) or state[2] is None)
+ memio.close()
+ self.assertRaises(ValueError, memio.__getstate__)
+
+ def test_setstate(self):
+ # This checks whether __setstate__ does proper input validation.
+ memio = self.ioclass()
+ memio.__setstate__((b"no error", 0, None))
+ memio.__setstate__((bytearray(b"no error"), 0, None))
+ memio.__setstate__((b"no error", 0, {'spam': 3}))
+ self.assertRaises(ValueError, memio.__setstate__, (b"", -1, None))
+ self.assertRaises(TypeError, memio.__setstate__, ("unicode", 0, None))
+ self.assertRaises(TypeError, memio.__setstate__, (b"", 0.0, None))
+ self.assertRaises(TypeError, memio.__setstate__, (b"", 0, 0))
+ self.assertRaises(TypeError, memio.__setstate__, (b"len-test", 0))
+ self.assertRaises(TypeError, memio.__setstate__)
+ self.assertRaises(TypeError, memio.__setstate__, 0)
+ memio.close()
+ self.assertRaises(ValueError, memio.__setstate__, (b"closed", 0, None))
+
+
class CStringIOTest(PyStringIOTest):
ioclass = io.StringIO
UnsupportedOperation = io.UnsupportedOperation
@@ -571,9 +673,48 @@ class CStringIOTest(PyStringIOTest):
self.assertEqual(memio.tell(), len(buf) * 2)
self.assertEqual(memio.getvalue(), buf + buf)
+ def test_getstate(self):
+ memio = self.ioclass()
+ state = memio.__getstate__()
+ self.assertEqual(len(state), 4)
+ self.assertIsInstance(state[0], str)
+ self.assertIsInstance(state[1], str)
+ self.assertIsInstance(state[2], int)
+ self.assertTrue(isinstance(state[3], dict) or state[3] is None)
+ memio.close()
+ self.assertRaises(ValueError, memio.__getstate__)
+
+ def test_setstate(self):
+ # This checks whether __setstate__ does proper input validation.
+ memio = self.ioclass()
+ memio.__setstate__(("no error", "\n", 0, None))
+ memio.__setstate__(("no error", "", 0, {'spam': 3}))
+ self.assertRaises(ValueError, memio.__setstate__, ("", "f", 0, None))
+ self.assertRaises(ValueError, memio.__setstate__, ("", "", -1, None))
+ self.assertRaises(TypeError, memio.__setstate__, (b"", "", 0, None))
+ self.assertRaises(TypeError, memio.__setstate__, ("", b"", 0, None))
+ self.assertRaises(TypeError, memio.__setstate__, ("", "", 0.0, None))
+ self.assertRaises(TypeError, memio.__setstate__, ("", "", 0, 0))
+ self.assertRaises(TypeError, memio.__setstate__, ("len-test", 0))
+ self.assertRaises(TypeError, memio.__setstate__)
+ self.assertRaises(TypeError, memio.__setstate__, 0)
+ memio.close()
+ self.assertRaises(ValueError, memio.__setstate__, ("closed", "", 0, None))
+
+
+class CStringIOPickleTest(PyStringIOPickleTest):
+ UnsupportedOperation = io.UnsupportedOperation
+
+ class ioclass(io.StringIO):
+ def __new__(cls, *args, **kwargs):
+ return pickle.loads(pickle.dumps(io.StringIO(*args, **kwargs)))
+ def __init__(self, *args, **kwargs):
+ pass
+
def test_main():
- tests = [PyBytesIOTest, PyStringIOTest, CBytesIOTest, CStringIOTest]
+ tests = [PyBytesIOTest, PyStringIOTest, CBytesIOTest, CStringIOTest,
+ PyStringIOPickleTest, CStringIOPickleTest]
support.run_unittest(*tests)
if __name__ == '__main__':
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py
index 52fa3a935f..0bfddd97ed 100644
--- a/Lib/test/test_memoryview.py
+++ b/Lib/test/test_memoryview.py
@@ -29,7 +29,7 @@ class AbstractMemoryTests:
oldrefcount = sys.getrefcount(b)
m = self._view(b)
self.assertEqual(m[0], item(b"a"))
- self.assertTrue(isinstance(m[0], bytes), type(m[0]))
+ self.assertIsInstance(m[0], bytes)
self.assertEqual(m[5], item(b"f"))
self.assertEqual(m[-1], item(b"f"))
self.assertEqual(m[-6], item(b"a"))
@@ -129,7 +129,7 @@ class AbstractMemoryTests:
expected = b"".join(
self.getitem_type(bytes([c])) for c in b"abcdef")
self.assertEqual(b, expected)
- self.assertTrue(isinstance(b, bytes), type(b))
+ self.assertIsInstance(b, bytes)
def test_tolist(self):
for tp in self._types:
@@ -226,6 +226,52 @@ class AbstractMemoryTests:
gc.collect()
self.assertTrue(wr() is None, wr())
+ def _check_released(self, m, tp):
+ check = self.assertRaisesRegex(ValueError, "released")
+ with check: bytes(m)
+ with check: m.tobytes()
+ with check: m.tolist()
+ with check: m[0]
+ with check: m[0] = b'x'
+ with check: len(m)
+ with check: m.format
+ with check: m.itemsize
+ with check: m.ndim
+ with check: m.readonly
+ with check: m.shape
+ with check: m.strides
+ with check:
+ with m:
+ pass
+ # str() and repr() still function
+ self.assertIn("released memory", str(m))
+ self.assertIn("released memory", repr(m))
+ self.assertEqual(m, m)
+ self.assertNotEqual(m, memoryview(tp(self._source)))
+ self.assertNotEqual(m, tp(self._source))
+
+ def test_contextmanager(self):
+ for tp in self._types:
+ b = tp(self._source)
+ m = self._view(b)
+ with m as cm:
+ self.assertIs(cm, m)
+ self._check_released(m, tp)
+ m = self._view(b)
+ # Can release explicitly inside the context manager
+ with m:
+ m.release()
+
+ def test_release(self):
+ for tp in self._types:
+ b = tp(self._source)
+ m = self._view(b)
+ m.release()
+ self._check_released(m, tp)
+ # Can be called a second time (it's a no-op)
+ m.release()
+ self._check_released(m, tp)
+
def test_writable_readonly(self):
# Issue #10451: memoryview incorrectly exposes a readonly
# buffer as writable causing a segfault if using mmap
@@ -251,7 +297,7 @@ class BaseBytesMemoryTests(AbstractMemoryTests):
class BaseArrayMemoryTests(AbstractMemoryTests):
ro_type = None
rw_type = lambda self, b: array.array('i', list(b))
- getitem_type = lambda self, b: array.array('i', list(b)).tostring()
+ getitem_type = lambda self, b: array.array('i', list(b)).tobytes()
itemsize = array.array('i').itemsize
format = 'i'
diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py
index 7918de6a57..2caa7aa21d 100644
--- a/Lib/test/test_mimetypes.py
+++ b/Lib/test/test_mimetypes.py
@@ -1,6 +1,7 @@
import mimetypes
import io
import unittest
+import sys
from test import support
@@ -62,8 +63,32 @@ class MimeTypesTestCase(unittest.TestCase):
eq(all, [])
+@unittest.skipUnless(sys.platform.startswith("win"), "Windows only")
+class Win32MimeTypesTestCase(unittest.TestCase):
+ def setUp(self):
+ # ensure all entries actually come from the Windows registry
+ self.original_types_map = mimetypes.types_map.copy()
+ mimetypes.types_map.clear()
+ mimetypes.init()
+ self.db = mimetypes.MimeTypes()
+
+ def tearDown(self):
+ # restore default settings
+ mimetypes.types_map.clear()
+ mimetypes.types_map.update(self.original_types_map)
+
+ def test_registry_parsing(self):
+ # the original, minimum contents of the MIME database in the
+ # Windows registry is undocumented AFAIK.
+ # Use file types that should *always* exist:
+ eq = self.assertEqual
+ eq(self.db.guess_type("foo.txt"), ("text/plain", None))
+
+
def test_main():
- support.run_unittest(MimeTypesTestCase)
+ support.run_unittest(MimeTypesTestCase,
+ Win32MimeTypesTestCase
+ )
if __name__ == "__main__":
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index c58d17dbd7..4c2b34a748 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1,9 +1,7 @@
# test for xml.dom.minidom
-import os
-import sys
import pickle
-from test.support import verbose, run_unittest
+from test.support import verbose, run_unittest, findfile
import unittest
import xml.dom
@@ -14,12 +12,8 @@ from xml.dom.minidom import parse, Node, Document, parseString
from xml.dom.minidom import getDOMImplementation
-if __name__ == "__main__":
- base = sys.argv[0]
-else:
- base = __file__
-tstfile = os.path.join(os.path.dirname(base), "test.xml")
-del base
+tstfile = findfile("test.xml", subdir="xmltestdata")
+
# The tests of DocumentType importing use these helpers to construct
# the documents to work with, since not all DOM builders actually
@@ -79,9 +73,10 @@ class MinidomTest(unittest.TestCase):
self.confirm(t == s, "looking for %s, found %s" % (repr(s), repr(t)))
def testParseFromFile(self):
- dom = parse(open(tstfile))
- dom.unlink()
- self.confirm(isinstance(dom, Document))
+ with open(tstfile) as file:
+ dom = parse(file)
+ dom.unlink()
+ self.confirm(isinstance(dom, Document))
def testGetElementsByTagName(self):
dom = parse(tstfile)
@@ -234,7 +229,14 @@ class MinidomTest(unittest.TestCase):
def testUnlink(self):
dom = parse(tstfile)
+ self.assertTrue(dom.childNodes)
dom.unlink()
+ self.assertFalse(dom.childNodes)
+
+ def testContext(self):
+ with parse(tstfile) as dom:
+ self.assertTrue(dom.childNodes)
+ self.assertFalse(dom.childNodes)
def testElement(self):
dom = Document()
@@ -438,7 +440,7 @@ class MinidomTest(unittest.TestCase):
string1 = repr(el)
string2 = str(el)
self.confirm(string1 == string2)
- self.confirm(string1.find("slash:abc") != -1)
+ self.confirm("slash:abc" in string1)
dom.unlink()
def testAttributeRepr(self):
@@ -950,12 +952,20 @@ class MinidomTest(unittest.TestCase):
doc.unlink()
+ def testBug0777884(self):
+ doc = parseString("<o>text</o>")
+ text = doc.documentElement.childNodes[0]
+ self.assertEqual(text.nodeType, Node.TEXT_NODE)
+ # Should run quietly, doing nothing.
+ text.normalize()
+ doc.unlink()
+
def testBug1433694(self):
doc = parseString("<o><i/>t</o>")
node = doc.documentElement
node.childNodes[1].nodeValue = ""
node.normalize()
- self.confirm(node.childNodes[-1].nextSibling == None,
+ self.confirm(node.childNodes[-1].nextSibling is None,
"Final child's .nextSibling should be None")
def testSiblings(self):
@@ -1455,12 +1465,13 @@ class MinidomTest(unittest.TestCase):
self.confirm(len(n1.entities) == len(n2.entities)
and len(n1.notations) == len(n2.notations))
for i in range(len(n1.notations)):
+ # XXX this loop body doesn't seem to be executed?
no1 = n1.notations.item(i)
no2 = n1.notations.item(i)
self.confirm(no1.name == no2.name
and no1.publicId == no2.publicId
and no1.systemId == no2.systemId)
- statck.append((no1, no2))
+ stack.append((no1, no2))
for i in range(len(n1.entities)):
e1 = n1.entities.item(i)
e2 = n2.entities.item(i)
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 7c51085a99..e62a046c01 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -1,6 +1,10 @@
from test.support import TESTFN, run_unittest, import_module, unlink, requires
import unittest
-import os, re, itertools, socket, sys
+import os
+import re
+import itertools
+import socket
+import sys
# Skip test if we can't import mmap.
mmap = import_module('mmap')
@@ -116,126 +120,119 @@ class MmapTests(unittest.TestCase):
def test_access_parameter(self):
# Test for "access" keyword parameter
mapsize = 10
- open(TESTFN, "wb").write(b"a"*mapsize)
- f = open(TESTFN, "rb")
- m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ)
- self.assertEqual(m[:], b'a'*mapsize, "Readonly memory map data incorrect.")
+ with open(TESTFN, "wb") as fp:
+ fp.write(b"a"*mapsize)
+ with open(TESTFN, "rb") as f:
+ m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ)
+ self.assertEqual(m[:], b'a'*mapsize, "Readonly memory map data incorrect.")
- # Ensuring that readonly mmap can't be slice assigned
- try:
- m[:] = b'b'*mapsize
- except TypeError:
- pass
- else:
- self.fail("Able to write to readonly memory map")
+ # Ensuring that readonly mmap can't be slice assigned
+ try:
+ m[:] = b'b'*mapsize
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to write to readonly memory map")
- # Ensuring that readonly mmap can't be item assigned
- try:
- m[0] = b'b'
- except TypeError:
- pass
- else:
- self.fail("Able to write to readonly memory map")
+ # Ensuring that readonly mmap can't be item assigned
+ try:
+ m[0] = b'b'
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to write to readonly memory map")
- # Ensuring that readonly mmap can't be write() to
- try:
- m.seek(0,0)
- m.write(b'abc')
- except TypeError:
- pass
- else:
- self.fail("Able to write to readonly memory map")
+ # Ensuring that readonly mmap can't be write() to
+ try:
+ m.seek(0,0)
+ m.write(b'abc')
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to write to readonly memory map")
- # Ensuring that readonly mmap can't be write_byte() to
- try:
- m.seek(0,0)
- m.write_byte(b'd')
- except TypeError:
- pass
- else:
- self.fail("Able to write to readonly memory map")
+ # Ensuring that readonly mmap can't be write_byte() to
+ try:
+ m.seek(0,0)
+ m.write_byte(b'd')
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to write to readonly memory map")
- # Ensuring that readonly mmap can't be resized
- try:
- m.resize(2*mapsize)
- except SystemError: # resize is not universally supported
- pass
- except TypeError:
- pass
- else:
- self.fail("Able to resize readonly memory map")
- f.close()
- del m, f
- self.assertEqual(open(TESTFN, "rb").read(), b'a'*mapsize,
- "Readonly memory map data file was modified")
+ # Ensuring that readonly mmap can't be resized
+ try:
+ m.resize(2*mapsize)
+ except SystemError: # resize is not universally supported
+ pass
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to resize readonly memory map")
+ with open(TESTFN, "rb") as fp:
+ self.assertEqual(fp.read(), b'a'*mapsize,
+ "Readonly memory map data file was modified")
# Opening mmap with size too big
- import sys
- f = open(TESTFN, "r+b")
- try:
- m = mmap.mmap(f.fileno(), mapsize+1)
- except ValueError:
- # we do not expect a ValueError on Windows
- # CAUTION: This also changes the size of the file on disk, and
- # later tests assume that the length hasn't changed. We need to
- # repair that.
+ with open(TESTFN, "r+b") as f:
+ try:
+ m = mmap.mmap(f.fileno(), mapsize+1)
+ except ValueError:
+ # we do not expect a ValueError on Windows
+ # CAUTION: This also changes the size of the file on disk, and
+ # later tests assume that the length hasn't changed. We need to
+ # repair that.
+ if sys.platform.startswith('win'):
+ self.fail("Opening mmap with size+1 should work on Windows.")
+ else:
+ # we expect a ValueError on Unix, but not on Windows
+ if not sys.platform.startswith('win'):
+ self.fail("Opening mmap with size+1 should raise ValueError.")
+ m.close()
if sys.platform.startswith('win'):
- self.fail("Opening mmap with size+1 should work on Windows.")
- else:
- # we expect a ValueError on Unix, but not on Windows
- if not sys.platform.startswith('win'):
- self.fail("Opening mmap with size+1 should raise ValueError.")
- m.close()
- f.close()
- if sys.platform.startswith('win'):
- # Repair damage from the resizing test.
- f = open(TESTFN, 'r+b')
- f.truncate(mapsize)
- f.close()
+ # Repair damage from the resizing test.
+ with open(TESTFN, 'r+b') as f:
+ f.truncate(mapsize)
# Opening mmap with access=ACCESS_WRITE
- f = open(TESTFN, "r+b")
- m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE)
- # Modifying write-through memory map
- m[:] = b'c'*mapsize
- self.assertEqual(m[:], b'c'*mapsize,
- "Write-through memory map memory not updated properly.")
- m.flush()
- m.close()
- f.close()
- f = open(TESTFN, 'rb')
- stuff = f.read()
- f.close()
+ with open(TESTFN, "r+b") as f:
+ m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE)
+ # Modifying write-through memory map
+ m[:] = b'c'*mapsize
+ self.assertEqual(m[:], b'c'*mapsize,
+ "Write-through memory map memory not updated properly.")
+ m.flush()
+ m.close()
+ with open(TESTFN, 'rb') as f:
+ stuff = f.read()
self.assertEqual(stuff, b'c'*mapsize,
"Write-through memory map data file not updated properly.")
# Opening mmap with access=ACCESS_COPY
- f = open(TESTFN, "r+b")
- m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_COPY)
- # Modifying copy-on-write memory map
- m[:] = b'd'*mapsize
- self.assertEqual(m[:], b'd' * mapsize,
- "Copy-on-write memory map data not written correctly.")
- m.flush()
- self.assertEqual(open(TESTFN, "rb").read(), b'c'*mapsize,
- "Copy-on-write test data file should not be modified.")
- # Ensuring copy-on-write maps cannot be resized
- self.assertRaises(TypeError, m.resize, 2*mapsize)
- f.close()
- del m, f
+ with open(TESTFN, "r+b") as f:
+ m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_COPY)
+ # Modifying copy-on-write memory map
+ m[:] = b'd'*mapsize
+ self.assertEqual(m[:], b'd' * mapsize,
+ "Copy-on-write memory map data not written correctly.")
+ m.flush()
+ with open(TESTFN, "rb") as fp:
+ self.assertEqual(fp.read(), b'c'*mapsize,
+ "Copy-on-write test data file should not be modified.")
+ # Ensuring copy-on-write maps cannot be resized
+ self.assertRaises(TypeError, m.resize, 2*mapsize)
+ m.close()
# Ensuring invalid access parameter raises exception
- f = open(TESTFN, "r+b")
- self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access=4)
- f.close()
+ with open(TESTFN, "r+b") as f:
+ self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access=4)
if os.name == "posix":
# Try incompatible flags, prot and access parameters.
- f = open(TESTFN, "r+b")
- self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize,
- flags=mmap.MAP_PRIVATE,
- prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE)
- f.close()
+ with open(TESTFN, "r+b") as f:
+ self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize,
+ flags=mmap.MAP_PRIVATE,
+ prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE)
# Try writing with PROT_EXEC and without PROT_WRITE
prot = mmap.PROT_READ | getattr(mmap, 'PROT_EXEC', 0)
@@ -252,14 +249,13 @@ class MmapTests(unittest.TestCase):
def test_tougher_find(self):
# Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2,
# searching for data with embedded \0 bytes didn't work.
- f = open(TESTFN, 'wb+')
+ with open(TESTFN, 'wb+') as f:
- data = b'aabaac\x00deef\x00\x00aa\x00'
- n = len(data)
- f.write(data)
- f.flush()
- m = mmap.mmap(f.fileno(), n)
- f.close()
+ data = b'aabaac\x00deef\x00\x00aa\x00'
+ n = len(data)
+ f.write(data)
+ f.flush()
+ m = mmap.mmap(f.fileno(), n)
for start in range(n+1):
for finish in range(start, n+1):
@@ -343,11 +339,8 @@ class MmapTests(unittest.TestCase):
f.write((65536 * 2) * b'm') # Arbitrary character
with open(TESTFN, "rb") as f:
- mf = mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ)
- try:
+ with mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ) as mf:
self.assertRaises(IndexError, mf.__getitem__, 80000)
- finally:
- mf.close()
def test_length_0_large_offset(self):
# Issue #10959: test mapping of a file by passing 0 for
@@ -532,7 +525,8 @@ class MmapTests(unittest.TestCase):
if not hasattr(mmap, 'PROT_READ'):
return
mapsize = 10
- open(TESTFN, "wb").write(b"a"*mapsize)
+ with open(TESTFN, "wb") as fp:
+ fp.write(b"a"*mapsize)
f = open(TESTFN, "rb")
m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ)
self.assertRaises(TypeError, m.write, "foo")
@@ -540,11 +534,12 @@ class MmapTests(unittest.TestCase):
def test_error(self):
self.assertTrue(issubclass(mmap.error, EnvironmentError))
- self.assertTrue("mmap.error" in str(mmap.error))
+ self.assertIn("mmap.error", str(mmap.error))
def test_io_methods(self):
data = b"0123456789"
- open(TESTFN, "wb").write(b"x"*len(data))
+ with open(TESTFN, "wb") as fp:
+ fp.write(b"x"*len(data))
f = open(TESTFN, "r+b")
m = mmap.mmap(f.fileno(), len(data))
f.close()
@@ -619,7 +614,8 @@ class MmapTests(unittest.TestCase):
m.close()
# Should not crash (Issue 5385)
- open(TESTFN, "wb").write(b"x"*10)
+ with open(TESTFN, "wb") as fp:
+ fp.write(b"x"*10)
f = open(TESTFN, "r+b")
m = mmap.mmap(f.fileno(), 0)
f.close()
@@ -644,6 +640,19 @@ class MmapTests(unittest.TestCase):
finally:
s.close()
+ def test_context_manager(self):
+ with mmap.mmap(-1, 10) as m:
+ self.assertFalse(m.closed)
+ self.assertTrue(m.closed)
+
+ def test_context_manager_exception(self):
+ # Test that the IOError gets passed through
+ with self.assertRaises(Exception) as exc:
+ with mmap.mmap(-1, 10) as m:
+ raise IOError
+ self.assertIsInstance(exc.exception, IOError,
+ "wrong exception raised in context manager")
+ self.assertTrue(m.closed, "context manager failed")
class LargeMmapTests(unittest.TestCase):
@@ -676,11 +685,8 @@ class LargeMmapTests(unittest.TestCase):
f.write(b" ")
with open(TESTFN, 'rb') as f:
- m = mmap.mmap(f.fileno(), 0, offset=0x140000000, access=mmap.ACCESS_READ)
- try:
+ with mmap.mmap(f.fileno(), 0, offset=0x140000000, access=mmap.ACCESS_READ) as m:
self.assertEqual(m[0xFFFFFFF], 32)
- finally:
- m.close()
def test_large_filesize(self):
if sys.platform[:3] == 'win' or sys.platform == 'darwin':
@@ -692,11 +698,8 @@ class LargeMmapTests(unittest.TestCase):
f.write(b" ")
with open(TESTFN, 'rb') as f:
- m = mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ)
- try:
+ with mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ) as m:
self.assertEqual(m.size(), 0x180000000)
- finally:
- m.close()
def test_main():
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index f3c8c615c2..fe772e14bd 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -1,11 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_multibytecodec.py
# Unit test for multibytecodec itself
#
from test import support
-from test import test_multibytecodec_support
from test.support import TESTFN
import unittest, io, codecs, sys, os
import _multibytecodec
@@ -242,7 +241,7 @@ class Test_ISO2022(unittest.TestCase):
self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni)
def test_iso2022_jp_g0(self):
- self.assertFalse(b'\x0e' in '\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
+ self.assertNotIn(b'\x0e', '\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
e = '\u3406'.encode(encoding)
self.assertFalse(any(x > 0x80 for x in e))
diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py
index d28c6530e3..ed15ce1d3d 100644
--- a/Lib/test/test_multibytecodec_support.py
+++ b/Lib/test/test_multibytecodec_support.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_multibytecodec_support.py
# Common Unittest Routines for CJK codecs
@@ -6,6 +6,7 @@
import sys, codecs
import unittest, re
+from http.client import HTTPException
from test import support
from io import BytesIO
@@ -278,7 +279,7 @@ class TestBase_Mapping(unittest.TestCase):
unittest.TestCase.__init__(self, *args, **kw)
try:
self.open_mapping_file().close() # test it to report the error early
- except IOError:
+ except (IOError, HTTPException):
self.skipTest("Could not retrieve "+self.mapfileurl)
def open_mapping_file(self):
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index d1ac4b7c44..91e2cbb027 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1,11 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Unit tests for the multiprocessing package
#
import unittest
-import threading
import queue as pyqueue
import time
import io
@@ -24,6 +23,10 @@ import test.support
_multiprocessing = test.support.import_module('_multiprocessing')
# Skip tests if sem_open implementation is broken.
test.support.import_module('multiprocessing.synchronize')
+# import threading after _multiprocessing to raise a more revelant error
+# message: "No module named _multiprocessing". _multiprocessing is not compiled
+# without thread support.
+import threading
import multiprocessing.dummy
import multiprocessing.connection
@@ -51,7 +54,7 @@ def latin(s):
#
LOG_LEVEL = util.SUBWARNING
-#LOG_LEVEL = logging.WARNING
+#LOG_LEVEL = logging.DEBUG
DELTA = 0.1
CHECK_TIMINGS = False # making true makes tests take a lot longer
@@ -155,7 +158,7 @@ class _TestProcess(BaseTestCase):
self.assertTrue(current.is_alive())
self.assertTrue(not current.daemon)
- self.assertTrue(isinstance(authkey, bytes))
+ self.assertIsInstance(authkey, bytes)
self.assertTrue(len(authkey) > 0)
self.assertEqual(current.ident, os.getpid())
self.assertEqual(current.exitcode, None)
@@ -186,7 +189,7 @@ class _TestProcess(BaseTestCase):
self.assertEqual(p.authkey, current.authkey)
self.assertEqual(p.is_alive(), False)
self.assertEqual(p.daemon, True)
- self.assertTrue(p not in self.active_children())
+ self.assertNotIn(p, self.active_children())
self.assertTrue(type(self.active_children()) is list)
self.assertEqual(p.exitcode, None)
@@ -194,7 +197,7 @@ class _TestProcess(BaseTestCase):
self.assertEqual(p.exitcode, None)
self.assertEqual(p.is_alive(), True)
- self.assertTrue(p in self.active_children())
+ self.assertIn(p, self.active_children())
self.assertEqual(q.get(), args[1:])
self.assertEqual(q.get(), kwargs)
@@ -207,7 +210,7 @@ class _TestProcess(BaseTestCase):
self.assertEqual(p.exitcode, 0)
self.assertEqual(p.is_alive(), False)
- self.assertTrue(p not in self.active_children())
+ self.assertNotIn(p, self.active_children())
@classmethod
def _test_terminate(cls):
@@ -222,7 +225,7 @@ class _TestProcess(BaseTestCase):
p.start()
self.assertEqual(p.is_alive(), True)
- self.assertTrue(p in self.active_children())
+ self.assertIn(p, self.active_children())
self.assertEqual(p.exitcode, None)
p.terminate()
@@ -232,7 +235,7 @@ class _TestProcess(BaseTestCase):
self.assertTimingAlmostEqual(join.elapsed, 0.0)
self.assertEqual(p.is_alive(), False)
- self.assertTrue(p not in self.active_children())
+ self.assertNotIn(p, self.active_children())
p.join()
@@ -251,13 +254,13 @@ class _TestProcess(BaseTestCase):
self.assertEqual(type(self.active_children()), list)
p = self.Process(target=time.sleep, args=(DELTA,))
- self.assertTrue(p not in self.active_children())
+ self.assertNotIn(p, self.active_children())
p.start()
- self.assertTrue(p in self.active_children())
+ self.assertIn(p, self.active_children())
p.join()
- self.assertTrue(p not in self.active_children())
+ self.assertNotIn(p, self.active_children())
@classmethod
def _test_recursion(cls, wconn, id):
@@ -765,7 +768,7 @@ class _TestCondition(BaseTestCase):
cond.acquire()
res = wait(TIMEOUT1)
cond.release()
- self.assertEqual(res, None)
+ self.assertEqual(res, False)
self.assertTimingAlmostEqual(wait.elapsed, TIMEOUT1)
@@ -1010,6 +1013,7 @@ class _TestContainers(BaseTestCase):
def sqr(x, wait=0.0):
time.sleep(wait)
return x*x
+
class _TestPool(BaseTestCase):
def test_apply(self):
@@ -1085,6 +1089,84 @@ class _TestPool(BaseTestCase):
join = TimingWrapper(self.pool.join)
join()
self.assertTrue(join.elapsed < 0.2)
+
+def raising():
+ raise KeyError("key")
+
+def unpickleable_result():
+ return lambda: 42
+
+class _TestPoolWorkerErrors(BaseTestCase):
+ ALLOWED_TYPES = ('processes', )
+
+ def test_async_error_callback(self):
+ p = multiprocessing.Pool(2)
+
+ scratchpad = [None]
+ def errback(exc):
+ scratchpad[0] = exc
+
+ res = p.apply_async(raising, error_callback=errback)
+ self.assertRaises(KeyError, res.get)
+ self.assertTrue(scratchpad[0])
+ self.assertIsInstance(scratchpad[0], KeyError)
+
+ p.close()
+ p.join()
+
+ def test_unpickleable_result(self):
+ from multiprocessing.pool import MaybeEncodingError
+ p = multiprocessing.Pool(2)
+
+ # Make sure we don't lose pool processes because of encoding errors.
+ for iteration in range(20):
+
+ scratchpad = [None]
+ def errback(exc):
+ scratchpad[0] = exc
+
+ res = p.apply_async(unpickleable_result, error_callback=errback)
+ self.assertRaises(MaybeEncodingError, res.get)
+ wrapped = scratchpad[0]
+ self.assertTrue(wrapped)
+ self.assertIsInstance(scratchpad[0], MaybeEncodingError)
+ self.assertIsNotNone(wrapped.exc)
+ self.assertIsNotNone(wrapped.value)
+
+ p.close()
+ p.join()
+
+class _TestPoolWorkerLifetime(BaseTestCase):
+ ALLOWED_TYPES = ('processes', )
+
+ def test_pool_worker_lifetime(self):
+ p = multiprocessing.Pool(3, maxtasksperchild=10)
+ self.assertEqual(3, len(p._pool))
+ origworkerpids = [w.pid for w in p._pool]
+ # Run many tasks so each worker gets replaced (hopefully)
+ results = []
+ for i in range(100):
+ results.append(p.apply_async(sqr, (i, )))
+ # Fetch the results and verify we got the right answers,
+ # also ensuring all the tasks have completed.
+ for (j, res) in enumerate(results):
+ self.assertEqual(res.get(), sqr(j))
+ # Refill the pool
+ p._repopulate_pool()
+ # Wait until all workers are alive
+ countdown = 5
+ while countdown and not all(w.is_alive() for w in p._pool):
+ countdown -= 1
+ time.sleep(DELTA)
+ finalworkerpids = [w.pid for w in p._pool]
+ # All pids should be assigned. See issue #7805.
+ self.assertNotIn(None, origworkerpids)
+ self.assertNotIn(None, finalworkerpids)
+ # Finally, check that the worker pids have changed
+ self.assertNotEqual(sorted(origworkerpids), sorted(finalworkerpids))
+ p.close()
+ p.join()
+
#
# Test that manager has expected number of shared objects left
#
@@ -1761,6 +1843,26 @@ class _TestLogging(BaseTestCase):
root_logger.setLevel(root_level)
logger.setLevel(level=LOG_LEVEL)
+
+# class _TestLoggingProcessName(BaseTestCase):
+#
+# def handle(self, record):
+# assert record.processName == multiprocessing.current_process().name
+# self.__handled = True
+#
+# def test_logging(self):
+# handler = logging.Handler()
+# handler.handle = self.handle
+# self.__handled = False
+# # Bypass getLogger() and side-effects
+# logger = logging.getLoggerClass()(
+# 'multiprocessing.test.TestLoggingProcessName')
+# logger.addHandler(handler)
+# logger.propagate = False
+#
+# logger.warn('foo')
+# assert self.__handled
+
#
# Test to verify handle verification, see issue 3321
#
diff --git a/Lib/test/test_nis.py b/Lib/test/test_nis.py
index 1fb5434dca..830c24d781 100644
--- a/Lib/test/test_nis.py
+++ b/Lib/test/test_nis.py
@@ -1,5 +1,6 @@
from test import support
import unittest
+import sys
# Skip test if nis module does not exist.
nis = support.import_module('nis')
diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py
new file mode 100644
index 0000000000..a387f61f1e
--- /dev/null
+++ b/Lib/test/test_nntplib.py
@@ -0,0 +1,1243 @@
+import io
+import datetime
+import textwrap
+import unittest
+import functools
+import contextlib
+import collections
+from test import support
+from nntplib import NNTP, GroupInfo, _have_ssl
+import nntplib
+if _have_ssl:
+ import ssl
+
+TIMEOUT = 30
+
+# TODO:
+# - test the `file` arg to more commands
+# - test error conditions
+# - test auth and `usenetrc`
+
+
+class NetworkedNNTPTestsMixin:
+
+ def test_welcome(self):
+ welcome = self.server.getwelcome()
+ self.assertEqual(str, type(welcome))
+
+ def test_help(self):
+ resp, lines = self.server.help()
+ self.assertTrue(resp.startswith("100 "), resp)
+ for line in lines:
+ self.assertEqual(str, type(line))
+
+ def test_list(self):
+ resp, groups = self.server.list()
+ if len(groups) > 0:
+ self.assertEqual(GroupInfo, type(groups[0]))
+ self.assertEqual(str, type(groups[0].group))
+
+ def test_list_active(self):
+ resp, groups = self.server.list(self.GROUP_PAT)
+ if len(groups) > 0:
+ self.assertEqual(GroupInfo, type(groups[0]))
+ self.assertEqual(str, type(groups[0].group))
+
+ def test_unknown_command(self):
+ with self.assertRaises(nntplib.NNTPPermanentError) as cm:
+ self.server._shortcmd("XYZZY")
+ resp = cm.exception.response
+ self.assertTrue(resp.startswith("500 "), resp)
+
+ def test_newgroups(self):
+ # gmane gets a constant influx of new groups. In order not to stress
+ # the server too much, we choose a recent date in the past.
+ dt = datetime.date.today() - datetime.timedelta(days=7)
+ resp, groups = self.server.newgroups(dt)
+ if len(groups) > 0:
+ self.assertIsInstance(groups[0], GroupInfo)
+ self.assertIsInstance(groups[0].group, str)
+
+ def test_description(self):
+ def _check_desc(desc):
+ # Sanity checks
+ self.assertIsInstance(desc, str)
+ self.assertNotIn(self.GROUP_NAME, desc)
+ desc = self.server.description(self.GROUP_NAME)
+ _check_desc(desc)
+ # Another sanity check
+ self.assertIn("Python", desc)
+ # With a pattern
+ desc = self.server.description(self.GROUP_PAT)
+ _check_desc(desc)
+ # Shouldn't exist
+ desc = self.server.description("zk.brrtt.baz")
+ self.assertEqual(desc, '')
+
+ def test_descriptions(self):
+ resp, descs = self.server.descriptions(self.GROUP_PAT)
+ # 215 for LIST NEWSGROUPS, 282 for XGTITLE
+ self.assertTrue(
+ resp.startswith("215 ") or resp.startswith("282 "), resp)
+ self.assertIsInstance(descs, dict)
+ desc = descs[self.GROUP_NAME]
+ self.assertEqual(desc, self.server.description(self.GROUP_NAME))
+
+ def test_group(self):
+ result = self.server.group(self.GROUP_NAME)
+ self.assertEqual(5, len(result))
+ resp, count, first, last, group = result
+ self.assertEqual(group, self.GROUP_NAME)
+ self.assertIsInstance(count, int)
+ self.assertIsInstance(first, int)
+ self.assertIsInstance(last, int)
+ self.assertLessEqual(first, last)
+ self.assertTrue(resp.startswith("211 "), resp)
+
+ def test_date(self):
+ resp, date = self.server.date()
+ self.assertIsInstance(date, datetime.datetime)
+ # Sanity check
+ self.assertGreaterEqual(date.year, 1995)
+ self.assertLessEqual(date.year, 2030)
+
+ def _check_art_dict(self, art_dict):
+ # Some sanity checks for a field dictionary returned by OVER / XOVER
+ self.assertIsInstance(art_dict, dict)
+ # NNTP has 7 mandatory fields
+ self.assertGreaterEqual(art_dict.keys(),
+ {"subject", "from", "date", "message-id",
+ "references", ":bytes", ":lines"}
+ )
+ for v in art_dict.values():
+ self.assertIsInstance(v, (str, type(None)))
+
+ def test_xover(self):
+ resp, count, first, last, name = self.server.group(self.GROUP_NAME)
+ resp, lines = self.server.xover(last - 5, last)
+ if len(lines) == 0:
+ self.skipTest("no articles retrieved")
+ # The 'last' article is not necessarily part of the output (cancelled?)
+ art_num, art_dict = lines[0]
+ self.assertGreaterEqual(art_num, last - 5)
+ self.assertLessEqual(art_num, last)
+ self._check_art_dict(art_dict)
+
+ def test_over(self):
+ resp, count, first, last, name = self.server.group(self.GROUP_NAME)
+ start = last - 10
+ # The "start-" article range form
+ resp, lines = self.server.over((start, None))
+ art_num, art_dict = lines[0]
+ self._check_art_dict(art_dict)
+ # The "start-end" article range form
+ resp, lines = self.server.over((start, last))
+ art_num, art_dict = lines[-1]
+ # The 'last' article is not necessarily part of the output (cancelled?)
+ self.assertGreaterEqual(art_num, start)
+ self.assertLessEqual(art_num, last)
+ self._check_art_dict(art_dict)
+ # XXX The "message_id" form is unsupported by gmane
+ # 503 Overview by message-ID unsupported
+
+ def test_xhdr(self):
+ resp, count, first, last, name = self.server.group(self.GROUP_NAME)
+ resp, lines = self.server.xhdr('subject', last)
+ for line in lines:
+ self.assertEqual(str, type(line[1]))
+
+ def check_article_resp(self, resp, article, art_num=None):
+ self.assertIsInstance(article, nntplib.ArticleInfo)
+ if art_num is not None:
+ self.assertEqual(article.number, art_num)
+ for line in article.lines:
+ self.assertIsInstance(line, bytes)
+ # XXX this could exceptionally happen...
+ self.assertNotIn(article.lines[-1], (b".", b".\n", b".\r\n"))
+
+ def test_article_head_body(self):
+ resp, count, first, last, name = self.server.group(self.GROUP_NAME)
+ # Try to find an available article
+ for art_num in (last, first, last - 1):
+ try:
+ resp, head = self.server.head(art_num)
+ except nntplib.NNTPTemporaryError as e:
+ if not e.response.startswith("423 "):
+ raise
+ # "423 No such article" => choose another one
+ continue
+ break
+ else:
+ self.skipTest("could not find a suitable article number")
+ self.assertTrue(resp.startswith("221 "), resp)
+ self.check_article_resp(resp, head, art_num)
+ resp, body = self.server.body(art_num)
+ self.assertTrue(resp.startswith("222 "), resp)
+ self.check_article_resp(resp, body, art_num)
+ resp, article = self.server.article(art_num)
+ self.assertTrue(resp.startswith("220 "), resp)
+ self.check_article_resp(resp, article, art_num)
+ self.assertEqual(article.lines, head.lines + [b''] + body.lines)
+
+ def test_capabilities(self):
+ # The server under test implements NNTP version 2 and has a
+ # couple of well-known capabilities. Just sanity check that we
+ # got them.
+ def _check_caps(caps):
+ caps_list = caps['LIST']
+ self.assertIsInstance(caps_list, (list, tuple))
+ self.assertIn('OVERVIEW.FMT', caps_list)
+ self.assertGreaterEqual(self.server.nntp_version, 2)
+ _check_caps(self.server.getcapabilities())
+ # This re-emits the command
+ resp, caps = self.server.capabilities()
+ _check_caps(caps)
+
+ if _have_ssl:
+ def test_starttls(self):
+ file = self.server.file
+ sock = self.server.sock
+ try:
+ self.server.starttls()
+ except nntplib.NNTPPermanentError:
+ self.skipTest("STARTTLS not supported by server.")
+ else:
+ # Check that the socket and internal pseudo-file really were
+ # changed.
+ self.assertNotEqual(file, self.server.file)
+ self.assertNotEqual(sock, self.server.sock)
+ # Check that the new socket really is an SSL one
+ self.assertIsInstance(self.server.sock, ssl.SSLSocket)
+ # Check that trying starttls when it's already active fails.
+ self.assertRaises(ValueError, self.server.starttls)
+
+ def test_zlogin(self):
+ # This test must be the penultimate because further commands will be
+ # refused.
+ baduser = "notarealuser"
+ badpw = "notarealpassword"
+ # Check that bogus credentials cause failure
+ self.assertRaises(nntplib.NNTPError, self.server.login,
+ user=baduser, password=badpw, usenetrc=False)
+ # FIXME: We should check that correct credentials succeed, but that
+ # would require valid details for some server somewhere to be in the
+ # test suite, I think. Gmane is anonymous, at least as used for the
+ # other tests.
+
+ def test_zzquit(self):
+ # This test must be called last, hence the name
+ cls = type(self)
+ try:
+ self.server.quit()
+ finally:
+ cls.server = None
+
+ @classmethod
+ def wrap_methods(cls):
+ # Wrap all methods in a transient_internet() exception catcher
+ # XXX put a generic version in test.support?
+ def wrap_meth(meth):
+ @functools.wraps(meth)
+ def wrapped(self):
+ with support.transient_internet(self.NNTP_HOST):
+ meth(self)
+ return wrapped
+ for name in dir(cls):
+ if not name.startswith('test_'):
+ continue
+ meth = getattr(cls, name)
+ if not isinstance(meth, collections.Callable):
+ continue
+ # Need to use a closure so that meth remains bound to its current
+ # value
+ setattr(cls, name, wrap_meth(meth))
+
+NetworkedNNTPTestsMixin.wrap_methods()
+
+
+class NetworkedNNTPTests(NetworkedNNTPTestsMixin, unittest.TestCase):
+ # This server supports STARTTLS (gmane doesn't)
+ NNTP_HOST = 'news.trigofacile.com'
+ GROUP_NAME = 'fr.comp.lang.python'
+ GROUP_PAT = 'fr.comp.lang.*'
+
+ NNTP_CLASS = NNTP
+
+ @classmethod
+ def setUpClass(cls):
+ support.requires("network")
+ with support.transient_internet(cls.NNTP_HOST):
+ cls.server = cls.NNTP_CLASS(cls.NNTP_HOST, timeout=TIMEOUT, usenetrc=False)
+
+ @classmethod
+ def tearDownClass(cls):
+ if cls.server is not None:
+ cls.server.quit()
+
+
+if _have_ssl:
+ class NetworkedNNTP_SSLTests(NetworkedNNTPTests):
+
+ # Technical limits for this public NNTP server (see http://www.aioe.org):
+ # "Only two concurrent connections per IP address are allowed and
+ # 400 connections per day are accepted from each IP address."
+
+ NNTP_HOST = 'nntp.aioe.org'
+ GROUP_NAME = 'comp.lang.python'
+ GROUP_PAT = 'comp.lang.*'
+
+ NNTP_CLASS = nntplib.NNTP_SSL
+
+ # Disabled as it produces too much data
+ test_list = None
+
+ # Disabled as the connection will already be encrypted.
+ test_starttls = None
+
+
+#
+# Non-networked tests using a local server (or something mocking it).
+#
+
+class _NNTPServerIO(io.RawIOBase):
+ """A raw IO object allowing NNTP commands to be received and processed
+ by a handler. The handler can push responses which can then be read
+ from the IO object."""
+
+ def __init__(self, handler):
+ io.RawIOBase.__init__(self)
+ # The channel from the client
+ self.c2s = io.BytesIO()
+ # The channel to the client
+ self.s2c = io.BytesIO()
+ self.handler = handler
+ self.handler.start(self.c2s.readline, self.push_data)
+
+ def readable(self):
+ return True
+
+ def writable(self):
+ return True
+
+ def push_data(self, data):
+ """Push (buffer) some data to send to the client."""
+ pos = self.s2c.tell()
+ self.s2c.seek(0, 2)
+ self.s2c.write(data)
+ self.s2c.seek(pos)
+
+ def write(self, b):
+ """The client sends us some data"""
+ pos = self.c2s.tell()
+ self.c2s.write(b)
+ self.c2s.seek(pos)
+ self.handler.process_pending()
+ return len(b)
+
+ def readinto(self, buf):
+ """The client wants to read a response"""
+ self.handler.process_pending()
+ b = self.s2c.read(len(buf))
+ n = len(b)
+ buf[:n] = b
+ return n
+
+
+class MockedNNTPTestsMixin:
+ # Override in derived classes
+ handler_class = None
+
+ def setUp(self):
+ super().setUp()
+ self.make_server()
+
+ def tearDown(self):
+ super().tearDown()
+ del self.server
+
+ def make_server(self, *args, **kwargs):
+ self.handler = self.handler_class()
+ self.sio = _NNTPServerIO(self.handler)
+ # Using BufferedRWPair instead of BufferedRandom ensures the file
+ # isn't seekable.
+ file = io.BufferedRWPair(self.sio, self.sio)
+ self.server = nntplib._NNTPBase(file, 'test.server', *args, **kwargs)
+ return self.server
+
+
+class NNTPv1Handler:
+ """A handler for RFC 977"""
+
+ welcome = "200 NNTP mock server"
+
+ def start(self, readline, push_data):
+ self.in_body = False
+ self.allow_posting = True
+ self._readline = readline
+ self._push_data = push_data
+ # Our welcome
+ self.handle_welcome()
+
+ def _decode(self, data):
+ return str(data, "utf-8", "surrogateescape")
+
+ def process_pending(self):
+ if self.in_body:
+ while True:
+ line = self._readline()
+ if not line:
+ return
+ self.body.append(line)
+ if line == b".\r\n":
+ break
+ try:
+ meth, tokens = self.body_callback
+ meth(*tokens, body=self.body)
+ finally:
+ self.body_callback = None
+ self.body = None
+ self.in_body = False
+ while True:
+ line = self._decode(self._readline())
+ if not line:
+ return
+ if not line.endswith("\r\n"):
+ raise ValueError("line doesn't end with \\r\\n: {!r}".format(line))
+ line = line[:-2]
+ cmd, *tokens = line.split()
+ #meth = getattr(self.handler, "handle_" + cmd.upper(), None)
+ meth = getattr(self, "handle_" + cmd.upper(), None)
+ if meth is None:
+ self.handle_unknown()
+ else:
+ try:
+ meth(*tokens)
+ except Exception as e:
+ raise ValueError("command failed: {!r}".format(line)) from e
+ else:
+ if self.in_body:
+ self.body_callback = meth, tokens
+ self.body = []
+
+ def expect_body(self):
+ """Flag that the client is expected to post a request body"""
+ self.in_body = True
+
+ def push_data(self, data):
+ """Push some binary data"""
+ self._push_data(data)
+
+ def push_lit(self, lit):
+ """Push a string literal"""
+ lit = textwrap.dedent(lit)
+ lit = "\r\n".join(lit.splitlines()) + "\r\n"
+ lit = lit.encode('utf-8')
+ self.push_data(lit)
+
+ def handle_unknown(self):
+ self.push_lit("500 What?")
+
+ def handle_welcome(self):
+ self.push_lit(self.welcome)
+
+ def handle_QUIT(self):
+ self.push_lit("205 Bye!")
+
+ def handle_DATE(self):
+ self.push_lit("111 20100914001155")
+
+ def handle_GROUP(self, group):
+ if group == "fr.comp.lang.python":
+ self.push_lit("211 486 761 1265 fr.comp.lang.python")
+ else:
+ self.push_lit("411 No such group {}".format(group))
+
+ def handle_HELP(self):
+ self.push_lit("""\
+ 100 Legal commands
+ authinfo user Name|pass Password|generic <prog> <args>
+ date
+ help
+ Report problems to <root@example.org>
+ .""")
+
+ def handle_STAT(self, message_spec=None):
+ if message_spec is None:
+ self.push_lit("412 No newsgroup selected")
+ elif message_spec == "3000234":
+ self.push_lit("223 3000234 <45223423@example.com>")
+ elif message_spec == "<45223423@example.com>":
+ self.push_lit("223 0 <45223423@example.com>")
+ else:
+ self.push_lit("430 No Such Article Found")
+
+ def handle_NEXT(self):
+ self.push_lit("223 3000237 <668929@example.org> retrieved")
+
+ def handle_LAST(self):
+ self.push_lit("223 3000234 <45223423@example.com> retrieved")
+
+ def handle_LIST(self, action=None, param=None):
+ if action is None:
+ self.push_lit("""\
+ 215 Newsgroups in form "group high low flags".
+ comp.lang.python 0000052340 0000002828 y
+ comp.lang.python.announce 0000001153 0000000993 m
+ free.it.comp.lang.python 0000000002 0000000002 y
+ fr.comp.lang.python 0000001254 0000000760 y
+ free.it.comp.lang.python.learner 0000000000 0000000001 y
+ tw.bbs.comp.lang.python 0000000304 0000000304 y
+ .""")
+ elif action == "ACTIVE":
+ if param == "*distutils*":
+ self.push_lit("""\
+ 215 Newsgroups in form "group high low flags"
+ gmane.comp.python.distutils.devel 0000014104 0000000001 m
+ gmane.comp.python.distutils.cvs 0000000000 0000000001 m
+ .""")
+ else:
+ self.push_lit("""\
+ 215 Newsgroups in form "group high low flags"
+ .""")
+ elif action == "OVERVIEW.FMT":
+ self.push_lit("""\
+ 215 Order of fields in overview database.
+ Subject:
+ From:
+ Date:
+ Message-ID:
+ References:
+ Bytes:
+ Lines:
+ Xref:full
+ .""")
+ elif action == "NEWSGROUPS":
+ assert param is not None
+ if param == "comp.lang.python":
+ self.push_lit("""\
+ 215 Descriptions in form "group description".
+ comp.lang.python\tThe Python computer language.
+ .""")
+ elif param == "comp.lang.python*":
+ self.push_lit("""\
+ 215 Descriptions in form "group description".
+ comp.lang.python.announce\tAnnouncements about the Python language. (Moderated)
+ comp.lang.python\tThe Python computer language.
+ .""")
+ else:
+ self.push_lit("""\
+ 215 Descriptions in form "group description".
+ .""")
+ else:
+ self.push_lit('501 Unknown LIST keyword')
+
+ def handle_NEWNEWS(self, group, date_str, time_str):
+ # We hard code different return messages depending on passed
+ # argument and date syntax.
+ if (group == "comp.lang.python" and date_str == "20100913"
+ and time_str == "082004"):
+ # Date was passed in RFC 3977 format (NNTP "v2")
+ self.push_lit("""\
+ 230 list of newsarticles (NNTP v2) created after Mon Sep 13 08:20:04 2010 follows
+ <a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>
+ <f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>
+ .""")
+ elif (group == "comp.lang.python" and date_str == "100913"
+ and time_str == "082004"):
+ # Date was passed in RFC 977 format (NNTP "v1")
+ self.push_lit("""\
+ 230 list of newsarticles (NNTP v1) created after Mon Sep 13 08:20:04 2010 follows
+ <a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>
+ <f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>
+ .""")
+ else:
+ self.push_lit("""\
+ 230 An empty list of newsarticles follows
+ .""")
+ # (Note for experiments: many servers disable NEWNEWS.
+ # As of this writing, sicinfo3.epfl.ch doesn't.)
+
+ def handle_XOVER(self, message_spec):
+ if message_spec == "57-59":
+ self.push_lit(
+ "224 Overview information for 57-58 follows\n"
+ "57\tRe: ANN: New Plone book with strong Python (and Zope) themes throughout"
+ "\tDoug Hellmann <doug.hellmann-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>"
+ "\tSat, 19 Jun 2010 18:04:08 -0400"
+ "\t<4FD05F05-F98B-44DC-8111-C6009C925F0C@gmail.com>"
+ "\t<hvalf7$ort$1@dough.gmane.org>\t7103\t16"
+ "\tXref: news.gmane.org gmane.comp.python.authors:57"
+ "\n"
+ "58\tLooking for a few good bloggers"
+ "\tDoug Hellmann <doug.hellmann-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>"
+ "\tThu, 22 Jul 2010 09:14:14 -0400"
+ "\t<A29863FA-F388-40C3-AA25-0FD06B09B5BF@gmail.com>"
+ "\t\t6683\t16"
+ "\t"
+ "\n"
+ # An UTF-8 overview line from fr.comp.lang.python
+ "59\tRe: Message d'erreur incompréhensible (par moi)"
+ "\tEric Brunel <eric.brunel@pragmadev.nospam.com>"
+ "\tWed, 15 Sep 2010 18:09:15 +0200"
+ "\t<eric.brunel-2B8B56.18091515092010@news.wanadoo.fr>"
+ "\t<4c90ec87$0$32425$ba4acef3@reader.news.orange.fr>\t1641\t27"
+ "\tXref: saria.nerim.net fr.comp.lang.python:1265"
+ "\n"
+ ".\n")
+ else:
+ self.push_lit("""\
+ 224 No articles
+ .""")
+
+ def handle_POST(self, *, body=None):
+ if body is None:
+ if self.allow_posting:
+ self.push_lit("340 Input article; end with <CR-LF>.<CR-LF>")
+ self.expect_body()
+ else:
+ self.push_lit("440 Posting not permitted")
+ else:
+ assert self.allow_posting
+ self.push_lit("240 Article received OK")
+ self.posted_body = body
+
+ def handle_IHAVE(self, message_id, *, body=None):
+ if body is None:
+ if (self.allow_posting and
+ message_id == "<i.am.an.article.you.will.want@example.com>"):
+ self.push_lit("335 Send it; end with <CR-LF>.<CR-LF>")
+ self.expect_body()
+ else:
+ self.push_lit("435 Article not wanted")
+ else:
+ assert self.allow_posting
+ self.push_lit("235 Article transferred OK")
+ self.posted_body = body
+
+ sample_head = """\
+ From: "Demo User" <nobody@example.net>
+ Subject: I am just a test article
+ Content-Type: text/plain; charset=UTF-8; format=flowed
+ Message-ID: <i.am.an.article.you.will.want@example.com>"""
+
+ sample_body = """\
+ This is just a test article.
+ ..Here is a dot-starting line.
+
+ -- Signed by Andr\xe9."""
+
+ sample_article = sample_head + "\n\n" + sample_body
+
+ def handle_ARTICLE(self, message_spec=None):
+ if message_spec is None:
+ self.push_lit("220 3000237 <45223423@example.com>")
+ elif message_spec == "<45223423@example.com>":
+ self.push_lit("220 0 <45223423@example.com>")
+ elif message_spec == "3000234":
+ self.push_lit("220 3000234 <45223423@example.com>")
+ else:
+ self.push_lit("430 No Such Article Found")
+ return
+ self.push_lit(self.sample_article)
+ self.push_lit(".")
+
+ def handle_HEAD(self, message_spec=None):
+ if message_spec is None:
+ self.push_lit("221 3000237 <45223423@example.com>")
+ elif message_spec == "<45223423@example.com>":
+ self.push_lit("221 0 <45223423@example.com>")
+ elif message_spec == "3000234":
+ self.push_lit("221 3000234 <45223423@example.com>")
+ else:
+ self.push_lit("430 No Such Article Found")
+ return
+ self.push_lit(self.sample_head)
+ self.push_lit(".")
+
+ def handle_BODY(self, message_spec=None):
+ if message_spec is None:
+ self.push_lit("222 3000237 <45223423@example.com>")
+ elif message_spec == "<45223423@example.com>":
+ self.push_lit("222 0 <45223423@example.com>")
+ elif message_spec == "3000234":
+ self.push_lit("222 3000234 <45223423@example.com>")
+ else:
+ self.push_lit("430 No Such Article Found")
+ return
+ self.push_lit(self.sample_body)
+ self.push_lit(".")
+
+
+class NNTPv2Handler(NNTPv1Handler):
+ """A handler for RFC 3977 (NNTP "v2")"""
+
+ def handle_CAPABILITIES(self):
+ self.push_lit("""\
+ 101 Capability list:
+ VERSION 2 3
+ IMPLEMENTATION INN 2.5.1
+ AUTHINFO USER
+ HDR
+ LIST ACTIVE ACTIVE.TIMES DISTRIB.PATS HEADERS NEWSGROUPS OVERVIEW.FMT
+ OVER
+ POST
+ READER
+ .""")
+
+ def handle_OVER(self, message_spec=None):
+ return self.handle_XOVER(message_spec)
+
+
+class NNTPv1v2TestsMixin:
+
+ def setUp(self):
+ super().setUp()
+
+ def test_welcome(self):
+ self.assertEqual(self.server.welcome, self.handler.welcome)
+
+ def test_date(self):
+ resp, date = self.server.date()
+ self.assertEqual(resp, "111 20100914001155")
+ self.assertEqual(date, datetime.datetime(2010, 9, 14, 0, 11, 55))
+
+ def test_quit(self):
+ self.assertFalse(self.sio.closed)
+ resp = self.server.quit()
+ self.assertEqual(resp, "205 Bye!")
+ self.assertTrue(self.sio.closed)
+
+ def test_help(self):
+ resp, help = self.server.help()
+ self.assertEqual(resp, "100 Legal commands")
+ self.assertEqual(help, [
+ ' authinfo user Name|pass Password|generic <prog> <args>',
+ ' date',
+ ' help',
+ 'Report problems to <root@example.org>',
+ ])
+
+ def test_list(self):
+ resp, groups = self.server.list()
+ self.assertEqual(len(groups), 6)
+ g = groups[1]
+ self.assertEqual(g,
+ GroupInfo("comp.lang.python.announce", "0000001153",
+ "0000000993", "m"))
+ resp, groups = self.server.list("*distutils*")
+ self.assertEqual(len(groups), 2)
+ g = groups[0]
+ self.assertEqual(g,
+ GroupInfo("gmane.comp.python.distutils.devel", "0000014104",
+ "0000000001", "m"))
+
+ def test_stat(self):
+ resp, art_num, message_id = self.server.stat(3000234)
+ self.assertEqual(resp, "223 3000234 <45223423@example.com>")
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ resp, art_num, message_id = self.server.stat("<45223423@example.com>")
+ self.assertEqual(resp, "223 0 <45223423@example.com>")
+ self.assertEqual(art_num, 0)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.stat("<non.existent.id>")
+ self.assertEqual(cm.exception.response, "430 No Such Article Found")
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.stat()
+ self.assertEqual(cm.exception.response, "412 No newsgroup selected")
+
+ def test_next(self):
+ resp, art_num, message_id = self.server.next()
+ self.assertEqual(resp, "223 3000237 <668929@example.org> retrieved")
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<668929@example.org>")
+
+ def test_last(self):
+ resp, art_num, message_id = self.server.last()
+ self.assertEqual(resp, "223 3000234 <45223423@example.com> retrieved")
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+
+ def test_description(self):
+ desc = self.server.description("comp.lang.python")
+ self.assertEqual(desc, "The Python computer language.")
+ desc = self.server.description("comp.lang.pythonx")
+ self.assertEqual(desc, "")
+
+ def test_descriptions(self):
+ resp, groups = self.server.descriptions("comp.lang.python")
+ self.assertEqual(resp, '215 Descriptions in form "group description".')
+ self.assertEqual(groups, {
+ "comp.lang.python": "The Python computer language.",
+ })
+ resp, groups = self.server.descriptions("comp.lang.python*")
+ self.assertEqual(groups, {
+ "comp.lang.python": "The Python computer language.",
+ "comp.lang.python.announce": "Announcements about the Python language. (Moderated)",
+ })
+ resp, groups = self.server.descriptions("comp.lang.pythonx")
+ self.assertEqual(groups, {})
+
+ def test_group(self):
+ resp, count, first, last, group = self.server.group("fr.comp.lang.python")
+ self.assertTrue(resp.startswith("211 "), resp)
+ self.assertEqual(first, 761)
+ self.assertEqual(last, 1265)
+ self.assertEqual(count, 486)
+ self.assertEqual(group, "fr.comp.lang.python")
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.group("comp.lang.python.devel")
+ exc = cm.exception
+ self.assertTrue(exc.response.startswith("411 No such group"),
+ exc.response)
+
+ def test_newnews(self):
+ # NEWNEWS comp.lang.python [20]100913 082004
+ dt = datetime.datetime(2010, 9, 13, 8, 20, 4)
+ resp, ids = self.server.newnews("comp.lang.python", dt)
+ expected = (
+ "230 list of newsarticles (NNTP v{0}) "
+ "created after Mon Sep 13 08:20:04 2010 follows"
+ ).format(self.nntp_version)
+ self.assertEqual(resp, expected)
+ self.assertEqual(ids, [
+ "<a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>",
+ "<f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>",
+ ])
+ # NEWNEWS fr.comp.lang.python [20]100913 082004
+ dt = datetime.datetime(2010, 9, 13, 8, 20, 4)
+ resp, ids = self.server.newnews("fr.comp.lang.python", dt)
+ self.assertEqual(resp, "230 An empty list of newsarticles follows")
+ self.assertEqual(ids, [])
+
+ def _check_article_body(self, lines):
+ self.assertEqual(len(lines), 4)
+ self.assertEqual(lines[-1].decode('utf8'), "-- Signed by André.")
+ self.assertEqual(lines[-2], b"")
+ self.assertEqual(lines[-3], b".Here is a dot-starting line.")
+ self.assertEqual(lines[-4], b"This is just a test article.")
+
+ def _check_article_head(self, lines):
+ self.assertEqual(len(lines), 4)
+ self.assertEqual(lines[0], b'From: "Demo User" <nobody@example.net>')
+ self.assertEqual(lines[3], b"Message-ID: <i.am.an.article.you.will.want@example.com>")
+
+ def _check_article_data(self, lines):
+ self.assertEqual(len(lines), 9)
+ self._check_article_head(lines[:4])
+ self._check_article_body(lines[-4:])
+ self.assertEqual(lines[4], b"")
+
+ def test_article(self):
+ # ARTICLE
+ resp, info = self.server.article()
+ self.assertEqual(resp, "220 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_data(lines)
+ # ARTICLE num
+ resp, info = self.server.article(3000234)
+ self.assertEqual(resp, "220 3000234 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_data(lines)
+ # ARTICLE id
+ resp, info = self.server.article("<45223423@example.com>")
+ self.assertEqual(resp, "220 0 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 0)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_data(lines)
+ # Non-existent id
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.article("<non-existent@example.com>")
+ self.assertEqual(cm.exception.response, "430 No Such Article Found")
+
+ def test_article_file(self):
+ # With a "file" argument
+ f = io.BytesIO()
+ resp, info = self.server.article(file=f)
+ self.assertEqual(resp, "220 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self.assertEqual(lines, [])
+ data = f.getvalue()
+ self.assertTrue(data.startswith(
+ b'From: "Demo User" <nobody@example.net>\r\n'
+ b'Subject: I am just a test article\r\n'
+ ), ascii(data))
+ self.assertTrue(data.endswith(
+ b'This is just a test article.\r\n'
+ b'.Here is a dot-starting line.\r\n'
+ b'\r\n'
+ b'-- Signed by Andr\xc3\xa9.\r\n'
+ ), ascii(data))
+
+ def test_head(self):
+ # HEAD
+ resp, info = self.server.head()
+ self.assertEqual(resp, "221 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_head(lines)
+ # HEAD num
+ resp, info = self.server.head(3000234)
+ self.assertEqual(resp, "221 3000234 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_head(lines)
+ # HEAD id
+ resp, info = self.server.head("<45223423@example.com>")
+ self.assertEqual(resp, "221 0 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 0)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_head(lines)
+ # Non-existent id
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.head("<non-existent@example.com>")
+ self.assertEqual(cm.exception.response, "430 No Such Article Found")
+
+ def test_body(self):
+ # BODY
+ resp, info = self.server.body()
+ self.assertEqual(resp, "222 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_body(lines)
+ # BODY num
+ resp, info = self.server.body(3000234)
+ self.assertEqual(resp, "222 3000234 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_body(lines)
+ # BODY id
+ resp, info = self.server.body("<45223423@example.com>")
+ self.assertEqual(resp, "222 0 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 0)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_body(lines)
+ # Non-existent id
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.body("<non-existent@example.com>")
+ self.assertEqual(cm.exception.response, "430 No Such Article Found")
+
+ def check_over_xover_resp(self, resp, overviews):
+ self.assertTrue(resp.startswith("224 "), resp)
+ self.assertEqual(len(overviews), 3)
+ art_num, over = overviews[0]
+ self.assertEqual(art_num, 57)
+ self.assertEqual(over, {
+ "from": "Doug Hellmann <doug.hellmann-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>",
+ "subject": "Re: ANN: New Plone book with strong Python (and Zope) themes throughout",
+ "date": "Sat, 19 Jun 2010 18:04:08 -0400",
+ "message-id": "<4FD05F05-F98B-44DC-8111-C6009C925F0C@gmail.com>",
+ "references": "<hvalf7$ort$1@dough.gmane.org>",
+ ":bytes": "7103",
+ ":lines": "16",
+ "xref": "news.gmane.org gmane.comp.python.authors:57"
+ })
+ art_num, over = overviews[1]
+ self.assertEqual(over["xref"], None)
+ art_num, over = overviews[2]
+ self.assertEqual(over["subject"],
+ "Re: Message d'erreur incompréhensible (par moi)")
+
+ def test_xover(self):
+ resp, overviews = self.server.xover(57, 59)
+ self.check_over_xover_resp(resp, overviews)
+
+ def test_over(self):
+ # In NNTP "v1", this will fallback on XOVER
+ resp, overviews = self.server.over((57, 59))
+ self.check_over_xover_resp(resp, overviews)
+
+ sample_post = (
+ b'From: "Demo User" <nobody@example.net>\r\n'
+ b'Subject: I am just a test article\r\n'
+ b'Content-Type: text/plain; charset=UTF-8; format=flowed\r\n'
+ b'Message-ID: <i.am.an.article.you.will.want@example.com>\r\n'
+ b'\r\n'
+ b'This is just a test article.\r\n'
+ b'.Here is a dot-starting line.\r\n'
+ b'\r\n'
+ b'-- Signed by Andr\xc3\xa9.\r\n'
+ )
+
+ def _check_posted_body(self):
+ # Check the raw body as received by the server
+ lines = self.handler.posted_body
+ # One additional line for the "." terminator
+ self.assertEqual(len(lines), 10)
+ self.assertEqual(lines[-1], b'.\r\n')
+ self.assertEqual(lines[-2], b'-- Signed by Andr\xc3\xa9.\r\n')
+ self.assertEqual(lines[-3], b'\r\n')
+ self.assertEqual(lines[-4], b'..Here is a dot-starting line.\r\n')
+ self.assertEqual(lines[0], b'From: "Demo User" <nobody@example.net>\r\n')
+
+ def _check_post_ihave_sub(self, func, *args, file_factory):
+ # First the prepared post with CRLF endings
+ post = self.sample_post
+ func_args = args + (file_factory(post),)
+ self.handler.posted_body = None
+ resp = func(*func_args)
+ self._check_posted_body()
+ # Then the same post with "normal" line endings - they should be
+ # converted by NNTP.post and NNTP.ihave.
+ post = self.sample_post.replace(b"\r\n", b"\n")
+ func_args = args + (file_factory(post),)
+ self.handler.posted_body = None
+ resp = func(*func_args)
+ self._check_posted_body()
+ return resp
+
+ def check_post_ihave(self, func, success_resp, *args):
+ # With a bytes object
+ resp = self._check_post_ihave_sub(func, *args, file_factory=bytes)
+ self.assertEqual(resp, success_resp)
+ # With a bytearray object
+ resp = self._check_post_ihave_sub(func, *args, file_factory=bytearray)
+ self.assertEqual(resp, success_resp)
+ # With a file object
+ resp = self._check_post_ihave_sub(func, *args, file_factory=io.BytesIO)
+ self.assertEqual(resp, success_resp)
+ # With an iterable of terminated lines
+ def iterlines(b):
+ return iter(b.splitlines(True))
+ resp = self._check_post_ihave_sub(func, *args, file_factory=iterlines)
+ self.assertEqual(resp, success_resp)
+ # With an iterable of non-terminated lines
+ def iterlines(b):
+ return iter(b.splitlines(False))
+ resp = self._check_post_ihave_sub(func, *args, file_factory=iterlines)
+ self.assertEqual(resp, success_resp)
+
+ def test_post(self):
+ self.check_post_ihave(self.server.post, "240 Article received OK")
+ self.handler.allow_posting = False
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.post(self.sample_post)
+ self.assertEqual(cm.exception.response,
+ "440 Posting not permitted")
+
+ def test_ihave(self):
+ self.check_post_ihave(self.server.ihave, "235 Article transferred OK",
+ "<i.am.an.article.you.will.want@example.com>")
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.ihave("<another.message.id>", self.sample_post)
+ self.assertEqual(cm.exception.response,
+ "435 Article not wanted")
+
+
+class NNTPv1Tests(NNTPv1v2TestsMixin, MockedNNTPTestsMixin, unittest.TestCase):
+ """Tests an NNTP v1 server (no capabilities)."""
+
+ nntp_version = 1
+ handler_class = NNTPv1Handler
+
+ def test_caps(self):
+ caps = self.server.getcapabilities()
+ self.assertEqual(caps, {})
+ self.assertEqual(self.server.nntp_version, 1)
+ self.assertEqual(self.server.nntp_implementation, None)
+
+
+class NNTPv2Tests(NNTPv1v2TestsMixin, MockedNNTPTestsMixin, unittest.TestCase):
+ """Tests an NNTP v2 server (with capabilities)."""
+
+ nntp_version = 2
+ handler_class = NNTPv2Handler
+
+ def test_caps(self):
+ caps = self.server.getcapabilities()
+ self.assertEqual(caps, {
+ 'VERSION': ['2', '3'],
+ 'IMPLEMENTATION': ['INN', '2.5.1'],
+ 'AUTHINFO': ['USER'],
+ 'HDR': [],
+ 'LIST': ['ACTIVE', 'ACTIVE.TIMES', 'DISTRIB.PATS',
+ 'HEADERS', 'NEWSGROUPS', 'OVERVIEW.FMT'],
+ 'OVER': [],
+ 'POST': [],
+ 'READER': [],
+ })
+ self.assertEqual(self.server.nntp_version, 3)
+ self.assertEqual(self.server.nntp_implementation, 'INN 2.5.1')
+
+
+class MiscTests(unittest.TestCase):
+
+ def test_decode_header(self):
+ def gives(a, b):
+ self.assertEqual(nntplib.decode_header(a), b)
+ gives("" , "")
+ gives("a plain header", "a plain header")
+ gives(" with extra spaces ", " with extra spaces ")
+ gives("=?ISO-8859-15?Q?D=E9buter_en_Python?=", "Débuter en Python")
+ gives("=?utf-8?q?Re=3A_=5Bsqlite=5D_probl=C3=A8me_avec_ORDER_BY_sur_des_cha?="
+ " =?utf-8?q?=C3=AEnes_de_caract=C3=A8res_accentu=C3=A9es?=",
+ "Re: [sqlite] problème avec ORDER BY sur des chaînes de caractères accentuées")
+ gives("Re: =?UTF-8?B?cHJvYmzDqG1lIGRlIG1hdHJpY2U=?=",
+ "Re: problème de matrice")
+ # A natively utf-8 header (found in the real world!)
+ gives("Re: Message d'erreur incompréhensible (par moi)",
+ "Re: Message d'erreur incompréhensible (par moi)")
+
+ def test_parse_overview_fmt(self):
+ # The minimal (default) response
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", ":bytes", ":lines"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines"])
+ # The minimal response using alternative names
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", "Bytes:", "Lines:"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines"])
+ # Variations in casing
+ lines = ["subject:", "FROM:", "DaTe:", "message-ID:",
+ "References:", "BYTES:", "Lines:"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines"])
+ # First example from RFC 3977
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", ":bytes", ":lines", "Xref:full",
+ "Distribution:full"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines", "xref", "distribution"])
+ # Second example from RFC 3977
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", "Bytes:", "Lines:", "Xref:FULL",
+ "Distribution:FULL"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines", "xref", "distribution"])
+ # A classic response from INN
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", "Bytes:", "Lines:", "Xref:full"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines", "xref"])
+
+ def test_parse_overview(self):
+ fmt = nntplib._DEFAULT_OVERVIEW_FMT + ["xref"]
+ # First example from RFC 3977
+ lines = [
+ '3000234\tI am just a test article\t"Demo User" '
+ '<nobody@example.com>\t6 Oct 1998 04:38:40 -0500\t'
+ '<45223423@example.com>\t<45454@example.net>\t1234\t'
+ '17\tXref: news.example.com misc.test:3000363',
+ ]
+ overview = nntplib._parse_overview(lines, fmt)
+ (art_num, fields), = overview
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(fields, {
+ 'subject': 'I am just a test article',
+ 'from': '"Demo User" <nobody@example.com>',
+ 'date': '6 Oct 1998 04:38:40 -0500',
+ 'message-id': '<45223423@example.com>',
+ 'references': '<45454@example.net>',
+ ':bytes': '1234',
+ ':lines': '17',
+ 'xref': 'news.example.com misc.test:3000363',
+ })
+ # Second example; here the "Xref" field is totally absent (including
+ # the header name) and comes out as None
+ lines = [
+ '3000234\tI am just a test article\t"Demo User" '
+ '<nobody@example.com>\t6 Oct 1998 04:38:40 -0500\t'
+ '<45223423@example.com>\t<45454@example.net>\t1234\t'
+ '17\t\t',
+ ]
+ overview = nntplib._parse_overview(lines, fmt)
+ (art_num, fields), = overview
+ self.assertEqual(fields['xref'], None)
+ # Third example; the "Xref" is an empty string, while "references"
+ # is a single space.
+ lines = [
+ '3000234\tI am just a test article\t"Demo User" '
+ '<nobody@example.com>\t6 Oct 1998 04:38:40 -0500\t'
+ '<45223423@example.com>\t \t1234\t'
+ '17\tXref: \t',
+ ]
+ overview = nntplib._parse_overview(lines, fmt)
+ (art_num, fields), = overview
+ self.assertEqual(fields['references'], ' ')
+ self.assertEqual(fields['xref'], '')
+
+ def test_parse_datetime(self):
+ def gives(a, b, *c):
+ self.assertEqual(nntplib._parse_datetime(a, b),
+ datetime.datetime(*c))
+ # Output of DATE command
+ gives("19990623135624", None, 1999, 6, 23, 13, 56, 24)
+ # Variations
+ gives("19990623", "135624", 1999, 6, 23, 13, 56, 24)
+ gives("990623", "135624", 1999, 6, 23, 13, 56, 24)
+ gives("090623", "135624", 2009, 6, 23, 13, 56, 24)
+
+ def test_unparse_datetime(self):
+ # Test non-legacy mode
+ # 1) with a datetime
+ def gives(y, M, d, h, m, s, date_str, time_str):
+ dt = datetime.datetime(y, M, d, h, m, s)
+ self.assertEqual(nntplib._unparse_datetime(dt),
+ (date_str, time_str))
+ self.assertEqual(nntplib._unparse_datetime(dt, False),
+ (date_str, time_str))
+ gives(1999, 6, 23, 13, 56, 24, "19990623", "135624")
+ gives(2000, 6, 23, 13, 56, 24, "20000623", "135624")
+ gives(2010, 6, 5, 1, 2, 3, "20100605", "010203")
+ # 2) with a date
+ def gives(y, M, d, date_str, time_str):
+ dt = datetime.date(y, M, d)
+ self.assertEqual(nntplib._unparse_datetime(dt),
+ (date_str, time_str))
+ self.assertEqual(nntplib._unparse_datetime(dt, False),
+ (date_str, time_str))
+ gives(1999, 6, 23, "19990623", "000000")
+ gives(2000, 6, 23, "20000623", "000000")
+ gives(2010, 6, 5, "20100605", "000000")
+
+ def test_unparse_datetime_legacy(self):
+ # Test legacy mode (RFC 977)
+ # 1) with a datetime
+ def gives(y, M, d, h, m, s, date_str, time_str):
+ dt = datetime.datetime(y, M, d, h, m, s)
+ self.assertEqual(nntplib._unparse_datetime(dt, True),
+ (date_str, time_str))
+ gives(1999, 6, 23, 13, 56, 24, "990623", "135624")
+ gives(2000, 6, 23, 13, 56, 24, "000623", "135624")
+ gives(2010, 6, 5, 1, 2, 3, "100605", "010203")
+ # 2) with a date
+ def gives(y, M, d, date_str, time_str):
+ dt = datetime.date(y, M, d)
+ self.assertEqual(nntplib._unparse_datetime(dt, True),
+ (date_str, time_str))
+ gives(1999, 6, 23, "990623", "000000")
+ gives(2000, 6, 23, "000623", "000000")
+ gives(2010, 6, 5, "100605", "000000")
+
+
+def test_main():
+ tests = [MiscTests, NNTPv1Tests, NNTPv2Tests, NetworkedNNTPTests]
+ if _have_ssl:
+ tests.append(NetworkedNNTP_SSLTests)
+ support.run_unittest(*tests)
+
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
index b6743712a7..e3e2560356 100644
--- a/Lib/test/test_normalization.py
+++ b/Lib/test/test_normalization.py
@@ -1,6 +1,7 @@
from test.support import run_unittest, open_urlresource
import unittest
+from http.client import HTTPException
import sys
import os
from unicodedata import normalize, unidata_version
@@ -8,12 +9,9 @@ from unicodedata import normalize, unidata_version
TESTDATAFILE = "NormalizationTest.txt"
TESTDATAURL = "http://www.unicode.org/Public/" + unidata_version + "/ucd/" + TESTDATAFILE
-if os.path.exists(TESTDATAFILE):
- f = open(TESTDATAFILE, encoding='utf-8')
- l = f.readline()
- f.close()
- if not unidata_version in l:
- os.unlink(TESTDATAFILE)
+def check_version(testfile):
+ hdr = testfile.readline()
+ return unidata_version in hdr
class RangeError(Exception):
pass
@@ -39,13 +37,16 @@ def unistr(data):
class NormalizationTest(unittest.TestCase):
def test_main(self):
+ part = None
part1_data = {}
# Hit the exception early
try:
- open_urlresource(TESTDATAURL, encoding="utf-8")
- except IOError:
+ testdata = open_urlresource(TESTDATAURL, encoding="utf-8",
+ check=check_version)
+ except (IOError, HTTPException):
self.skipTest("Could not retrieve " + TESTDATAURL)
- for line in open_urlresource(TESTDATAURL, encoding="utf-8"):
+ self.addCleanup(testdata.close)
+ for line in testdata:
if '#' in line:
line = line.split('#')[0]
line = line.strip()
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 3d18527243..6464950982 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -1,7 +1,9 @@
import ntpath
import os
-from test.support import verbose, TestFailed
-import test.support as support
+import sys
+from test.support import TestFailed
+from test import support, test_genericpath
+from tempfile import TemporaryFile
import unittest
@@ -238,9 +240,27 @@ class TestNtpath(unittest.TestCase):
tester('ntpath.relpath("/a/b", "/a/b")', '.')
tester('ntpath.relpath("c:/foo", "C:/FOO")', '.')
+ def test_sameopenfile(self):
+ with TemporaryFile() as tf1, TemporaryFile() as tf2:
+ # Make sure the same file is really the same
+ self.assertTrue(ntpath.sameopenfile(tf1.fileno(), tf1.fileno()))
+ # Make sure different files are really different
+ self.assertFalse(ntpath.sameopenfile(tf1.fileno(), tf2.fileno()))
+ # Make sure invalid values don't cause issues on win32
+ if sys.platform == "win32":
+ with self.assertRaises(OSError):
+ # Invalid file descriptors shouldn't display assert
+ # dialogs (#4804)
+ ntpath.sameopenfile(-1, -1)
+
+
+class NtCommonTest(test_genericpath.CommonTest):
+ pathmodule = ntpath
+ attributes = ['relpath', 'splitunc']
+
def test_main():
- support.run_unittest(TestNtpath)
+ support.run_unittest(TestNtpath, NtCommonTest)
if __name__ == "__main__":
diff --git a/Lib/test/test_numeric_tower.py b/Lib/test/test_numeric_tower.py
new file mode 100644
index 0000000000..bef3d4c35d
--- /dev/null
+++ b/Lib/test/test_numeric_tower.py
@@ -0,0 +1,206 @@
+# test interactions between int, float, Decimal and Fraction
+
+import unittest
+import random
+import math
+import sys
+import operator
+from test.support import run_unittest
+
+from decimal import Decimal as D
+from fractions import Fraction as F
+
+# Constants related to the hash implementation; hash(x) is based
+# on the reduction of x modulo the prime _PyHASH_MODULUS.
+_PyHASH_MODULUS = sys.hash_info.modulus
+_PyHASH_INF = sys.hash_info.inf
+
+class HashTest(unittest.TestCase):
+ def check_equal_hash(self, x, y):
+ # check both that x and y are equal and that their hashes are equal
+ self.assertEqual(hash(x), hash(y),
+ "got different hashes for {!r} and {!r}".format(x, y))
+ self.assertEqual(x, y)
+
+ def test_bools(self):
+ self.check_equal_hash(False, 0)
+ self.check_equal_hash(True, 1)
+
+ def test_integers(self):
+ # check that equal values hash equal
+
+ # exact integers
+ for i in range(-1000, 1000):
+ self.check_equal_hash(i, float(i))
+ self.check_equal_hash(i, D(i))
+ self.check_equal_hash(i, F(i))
+
+ # the current hash is based on reduction modulo 2**n-1 for some
+ # n, so pay special attention to numbers of the form 2**n and 2**n-1.
+ for i in range(100):
+ n = 2**i - 1
+ if n == int(float(n)):
+ self.check_equal_hash(n, float(n))
+ self.check_equal_hash(-n, -float(n))
+ self.check_equal_hash(n, D(n))
+ self.check_equal_hash(n, F(n))
+ self.check_equal_hash(-n, D(-n))
+ self.check_equal_hash(-n, F(-n))
+
+ n = 2**i
+ self.check_equal_hash(n, float(n))
+ self.check_equal_hash(-n, -float(n))
+ self.check_equal_hash(n, D(n))
+ self.check_equal_hash(n, F(n))
+ self.check_equal_hash(-n, D(-n))
+ self.check_equal_hash(-n, F(-n))
+
+ # random values of various sizes
+ for _ in range(1000):
+ e = random.randrange(300)
+ n = random.randrange(-10**e, 10**e)
+ self.check_equal_hash(n, D(n))
+ self.check_equal_hash(n, F(n))
+ if n == int(float(n)):
+ self.check_equal_hash(n, float(n))
+
+ def test_binary_floats(self):
+ # check that floats hash equal to corresponding Fractions and Decimals
+
+ # floats that are distinct but numerically equal should hash the same
+ self.check_equal_hash(0.0, -0.0)
+
+ # zeros
+ self.check_equal_hash(0.0, D(0))
+ self.check_equal_hash(-0.0, D(0))
+ self.check_equal_hash(-0.0, D('-0.0'))
+ self.check_equal_hash(0.0, F(0))
+
+ # infinities and nans
+ self.check_equal_hash(float('inf'), D('inf'))
+ self.check_equal_hash(float('-inf'), D('-inf'))
+
+ for _ in range(1000):
+ x = random.random() * math.exp(random.random()*200.0 - 100.0)
+ self.check_equal_hash(x, D.from_float(x))
+ self.check_equal_hash(x, F.from_float(x))
+
+ def test_complex(self):
+ # complex numbers with zero imaginary part should hash equal to
+ # the corresponding float
+
+ test_values = [0.0, -0.0, 1.0, -1.0, 0.40625, -5136.5,
+ float('inf'), float('-inf')]
+
+ for zero in -0.0, 0.0:
+ for value in test_values:
+ self.check_equal_hash(value, complex(value, zero))
+
+ def test_decimals(self):
+ # check that Decimal instances that have different representations
+ # but equal values give the same hash
+ zeros = ['0', '-0', '0.0', '-0.0e10', '000e-10']
+ for zero in zeros:
+ self.check_equal_hash(D(zero), D(0))
+
+ self.check_equal_hash(D('1.00'), D(1))
+ self.check_equal_hash(D('1.00000'), D(1))
+ self.check_equal_hash(D('-1.00'), D(-1))
+ self.check_equal_hash(D('-1.00000'), D(-1))
+ self.check_equal_hash(D('123e2'), D(12300))
+ self.check_equal_hash(D('1230e1'), D(12300))
+ self.check_equal_hash(D('12300'), D(12300))
+ self.check_equal_hash(D('12300.0'), D(12300))
+ self.check_equal_hash(D('12300.00'), D(12300))
+ self.check_equal_hash(D('12300.000'), D(12300))
+
+ def test_fractions(self):
+ # check special case for fractions where either the numerator
+ # or the denominator is a multiple of _PyHASH_MODULUS
+ self.assertEqual(hash(F(1, _PyHASH_MODULUS)), _PyHASH_INF)
+ self.assertEqual(hash(F(-1, 3*_PyHASH_MODULUS)), -_PyHASH_INF)
+ self.assertEqual(hash(F(7*_PyHASH_MODULUS, 1)), 0)
+ self.assertEqual(hash(F(-_PyHASH_MODULUS, 1)), 0)
+
+ def test_hash_normalization(self):
+ # Test for a bug encountered while changing long_hash.
+ #
+ # Given objects x and y, it should be possible for y's
+ # __hash__ method to return hash(x) in order to ensure that
+ # hash(x) == hash(y). But hash(x) is not exactly equal to the
+ # result of x.__hash__(): there's some internal normalization
+ # to make sure that the result fits in a C long, and is not
+ # equal to the invalid hash value -1. This internal
+ # normalization must therefore not change the result of
+ # hash(x) for any x.
+
+ class HalibutProxy:
+ def __hash__(self):
+ return hash('halibut')
+ def __eq__(self, other):
+ return other == 'halibut'
+
+ x = {'halibut', HalibutProxy()}
+ self.assertEqual(len(x), 1)
+
+class ComparisonTest(unittest.TestCase):
+ def test_mixed_comparisons(self):
+
+ # ordered list of distinct test values of various types:
+ # int, float, Fraction, Decimal
+ test_values = [
+ float('-inf'),
+ D('-1e999999999'),
+ -1e308,
+ F(-22, 7),
+ -3.14,
+ -2,
+ 0.0,
+ 1e-320,
+ True,
+ F('1.2'),
+ D('1.3'),
+ float('1.4'),
+ F(275807, 195025),
+ D('1.414213562373095048801688724'),
+ F(114243, 80782),
+ F(473596569, 84615),
+ 7e200,
+ D('infinity'),
+ ]
+ for i, first in enumerate(test_values):
+ for second in test_values[i+1:]:
+ self.assertLess(first, second)
+ self.assertLessEqual(first, second)
+ self.assertGreater(second, first)
+ self.assertGreaterEqual(second, first)
+
+ def test_complex(self):
+ # comparisons with complex are special: equality and inequality
+ # comparisons should always succeed, but order comparisons should
+ # raise TypeError.
+ z = 1.0 + 0j
+ w = -3.14 + 2.7j
+
+ for v in 1, 1.0, F(1), D(1), complex(1):
+ self.assertEqual(z, v)
+ self.assertEqual(v, z)
+
+ for v in 2, 2.0, F(2), D(2), complex(2):
+ self.assertNotEqual(z, v)
+ self.assertNotEqual(v, z)
+ self.assertNotEqual(w, v)
+ self.assertNotEqual(v, w)
+
+ for v in (1, 1.0, F(1), D(1), complex(1),
+ 2, 2.0, F(2), D(2), complex(2), w):
+ for op in operator.le, operator.lt, operator.ge, operator.gt:
+ self.assertRaises(TypeError, op, z, v)
+ self.assertRaises(TypeError, op, v, z)
+
+
+def test_main():
+ run_unittest(HashTest, ComparisonTest)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py
index 9707e84c7e..f510bac9f0 100644
--- a/Lib/test/test_opcodes.py
+++ b/Lib/test/test_opcodes.py
@@ -60,7 +60,7 @@ class OpcodeTest(unittest.TestCase):
try: raise DClass(a)
except DClass as v:
- self.assertTrue(isinstance(v, DClass))
+ self.assertIsInstance(v, DClass)
else:
self.fail("no exception")
diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py
index 531f56e4a6..fa608b9a52 100644
--- a/Lib/test/test_operator.py
+++ b/Lib/test/test_operator.py
@@ -275,8 +275,7 @@ class OperatorTestCase(unittest.TestCase):
self.assertEqual(f(a), 'arthur')
f = operator.attrgetter('rank')
self.assertRaises(AttributeError, f, a)
- f = operator.attrgetter(2)
- self.assertRaises(TypeError, f, a)
+ self.assertRaises(TypeError, operator.attrgetter, 2)
self.assertRaises(TypeError, operator.attrgetter)
# multiple gets
@@ -285,7 +284,7 @@ class OperatorTestCase(unittest.TestCase):
record.y = 'Y'
record.z = 'Z'
self.assertEqual(operator.attrgetter('x','z','y')(record), ('X', 'Z', 'Y'))
- self.assertRaises(TypeError, operator.attrgetter('x', (), 'y'), record)
+ self.assertRaises(TypeError, operator.attrgetter, ('x', (), 'y'))
class C(object):
def __getattr__(self, name):
@@ -304,6 +303,10 @@ class OperatorTestCase(unittest.TestCase):
self.assertEqual(f(a), ('arthur', 'thomas'))
f = operator.attrgetter('name', 'child.name', 'child.child.name')
self.assertRaises(AttributeError, f, a)
+ f = operator.attrgetter('child.')
+ self.assertRaises(AttributeError, f, a)
+ f = operator.attrgetter('.child')
+ self.assertRaises(AttributeError, f, a)
a.child.child = A()
a.child.child.name = 'johnson'
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 4ad4c0ff5e..7b95612024 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-
#
# Test suite for Optik. Supplied by Johannes Gijsbers
# (taradino@softhome.net) -- translated from the original Optik
@@ -18,9 +16,9 @@ from io import StringIO
from test import support
-from optparse import make_option, Option, IndentedHelpFormatter, \
- TitledHelpFormatter, OptionParser, OptionContainer, OptionGroup, \
- SUPPRESS_HELP, SUPPRESS_USAGE, OptionError, OptionConflictError, \
+from optparse import make_option, Option, \
+ TitledHelpFormatter, OptionParser, OptionGroup, \
+ SUPPRESS_USAGE, OptionError, OptionConflictError, \
BadOptionError, OptionValueError, Values
from optparse import _match_abbrev
from optparse import _parse_num
@@ -338,7 +336,7 @@ class TestOptionParser(BaseTest):
def test_get_option(self):
opt1 = self.parser.get_option("-v")
- self.assertTrue(isinstance(opt1, Option))
+ self.assertIsInstance(opt1, Option)
self.assertEqual(opt1._short_opts, ["-v", "-n"])
self.assertEqual(opt1._long_opts, ["--verbose", "--noisy"])
self.assertEqual(opt1.action, "store_true")
@@ -443,7 +441,7 @@ def _check_duration(option, opt, value):
return int(value)
else:
return int(value[:-1]) * _time_units[value[-1]]
- except ValueError as IndexError:
+ except (ValueError, IndexError):
raise OptionValueError(
'option %s: invalid duration: %r' % (opt, value))
@@ -1229,7 +1227,6 @@ class TestCallbackVarArgs(BaseTest):
def variable_args(self, option, opt, value, parser):
self.assertTrue(value is None)
- done = 0
value = []
rargs = parser.rargs
while rargs:
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index cbf0c1647d..77fcbafed0 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -7,8 +7,14 @@ import errno
import unittest
import warnings
import sys
+import signal
+import subprocess
+import time
import shutil
from test import support
+import contextlib
+import mmap
+import uuid
# Detect whether we're on a Linux system that uses the (now outdated
# and unmaintained) linuxthreads threading library. There's an issue
@@ -54,6 +60,7 @@ class FileTests(unittest.TestCase):
os.closerange(first, first + 2)
self.assertRaises(OSError, os.write, first, b"a")
+ @support.cpython_only
def test_rename(self):
path = support.TESTFN
old = sys.getrefcount(path)
@@ -165,7 +172,6 @@ class TemporaryFileTests(unittest.TestCase):
self.assertTrue(s == "foobar")
def test_tmpnam(self):
- import sys
if not hasattr(os, "tmpnam"):
return
warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
@@ -215,19 +221,17 @@ class StatAttributeTests(unittest.TestCase):
os.unlink(self.fname)
os.rmdir(support.TESTFN)
- def test_stat_attributes(self):
+ def check_stat_attributes(self, fname):
if not hasattr(os, "stat"):
return
import stat
- result = os.stat(self.fname)
+ result = os.stat(fname)
# Make sure direct access works
self.assertEqual(result[stat.ST_SIZE], 3)
self.assertEqual(result.st_size, 3)
- import sys
-
# Make sure all the attributes are there
members = dir(result)
for name in dir(stat):
@@ -238,8 +242,8 @@ class StatAttributeTests(unittest.TestCase):
else:
def trunc(x): return x
self.assertEqual(trunc(getattr(result, attr)),
- result[getattr(stat, name)])
- self.assertTrue(attr in members)
+ result[getattr(stat, name)])
+ self.assertIn(attr, members)
try:
result[200]
@@ -279,6 +283,15 @@ class StatAttributeTests(unittest.TestCase):
except TypeError:
pass
+ def test_stat_attributes(self):
+ self.check_stat_attributes(self.fname)
+
+ def test_stat_attributes_bytes(self):
+ try:
+ fname = self.fname.encode(sys.getfilesystemencoding())
+ except UnicodeEncodeError:
+ self.skipTest("cannot encode %a for the filesystem" % self.fname)
+ self.check_stat_attributes(fname)
def test_statvfs_attributes(self):
if not hasattr(os, "statvfs"):
@@ -374,12 +387,17 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
def setUp(self):
self.__save = dict(os.environ)
+ if os.supports_bytes_environ:
+ self.__saveb = dict(os.environb)
for key, value in self._reference().items():
os.environ[key] = value
def tearDown(self):
os.environ.clear()
os.environ.update(self.__save)
+ if os.supports_bytes_environ:
+ os.environb.clear()
+ os.environb.update(self.__saveb)
def _reference(self):
return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
@@ -422,9 +440,73 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
def test___repr__(self):
"""Check that the repr() of os.environ looks like environ({...})."""
env = os.environ
- self.assertTrue(isinstance(env.data, dict))
- self.assertEqual(repr(env), 'environ({!r})'.format(env.data))
+ self.assertEqual(repr(env), 'environ({{{}}})'.format(', '.join(
+ '{!r}: {!r}'.format(key, value)
+ for key, value in env.items())))
+
+ def test_get_exec_path(self):
+ defpath_list = os.defpath.split(os.pathsep)
+ test_path = ['/monty', '/python', '', '/flying/circus']
+ test_env = {'PATH': os.pathsep.join(test_path)}
+
+ saved_environ = os.environ
+ try:
+ os.environ = dict(test_env)
+ # Test that defaulting to os.environ works.
+ self.assertSequenceEqual(test_path, os.get_exec_path())
+ self.assertSequenceEqual(test_path, os.get_exec_path(env=None))
+ finally:
+ os.environ = saved_environ
+ # No PATH environment variable
+ self.assertSequenceEqual(defpath_list, os.get_exec_path({}))
+ # Empty PATH environment variable
+ self.assertSequenceEqual(('',), os.get_exec_path({'PATH':''}))
+ # Supplied PATH environment variable
+ self.assertSequenceEqual(test_path, os.get_exec_path(test_env))
+
+ if os.supports_bytes_environ:
+ # env cannot contain 'PATH' and b'PATH' keys
+ try:
+ # ignore BytesWarning warning
+ with warnings.catch_warnings(record=True):
+ mixed_env = {'PATH': '1', b'PATH': b'2'}
+ except BytesWarning:
+ # mixed_env cannot be created with python -bb
+ pass
+ else:
+ self.assertRaises(ValueError, os.get_exec_path, mixed_env)
+
+ # bytes key and/or value
+ self.assertSequenceEqual(os.get_exec_path({b'PATH': b'abc'}),
+ ['abc'])
+ self.assertSequenceEqual(os.get_exec_path({b'PATH': 'abc'}),
+ ['abc'])
+ self.assertSequenceEqual(os.get_exec_path({'PATH': b'abc'}),
+ ['abc'])
+
+ @unittest.skipUnless(os.supports_bytes_environ,
+ "os.environb required for this test.")
+ def test_environb(self):
+ # os.environ -> os.environb
+ value = 'euro\u20ac'
+ try:
+ value_bytes = value.encode(sys.getfilesystemencoding(),
+ 'surrogateescape')
+ except UnicodeEncodeError:
+ msg = "U+20AC character is not encodable to %s" % (
+ sys.getfilesystemencoding(),)
+ self.skipTest(msg)
+ os.environ['unicode'] = value
+ self.assertEqual(os.environ['unicode'], value)
+ self.assertEqual(os.environb[b'unicode'], value_bytes)
+
+ # os.environb -> os.environ
+ value = b'\xff'
+ os.environb[b'bytes'] = value
+ self.assertEqual(os.environb[b'bytes'], value)
+ value_str = value.decode(sys.getfilesystemencoding(), 'surrogateescape')
+ self.assertEqual(os.environ['bytes'], value_str)
class WalkTests(unittest.TestCase):
"""Tests for os.walk()."""
@@ -464,7 +546,7 @@ class WalkTests(unittest.TestCase):
f = open(path, "w")
f.write("I'm " + path + " and proud of it. Blame test_os.\n")
f.close()
- if hasattr(os, "symlink"):
+ if support.can_symlink():
os.symlink(os.path.abspath(t2_path), link_path)
sub2_tree = (sub2_path, ["link"], ["tmp3"])
else:
@@ -508,7 +590,7 @@ class WalkTests(unittest.TestCase):
self.assertEqual(all[flipped + 1], (sub1_path, ["SUB11"], ["tmp2"]))
self.assertEqual(all[2 - 2 * flipped], sub2_tree)
- if hasattr(os, "symlink"):
+ if support.can_symlink():
# Walk, following symlinks.
for root, dirs, files in os.walk(walk_path, followlinks=True):
if root == link_path:
@@ -553,6 +635,28 @@ class MakedirTests(unittest.TestCase):
'dir5', 'dir6')
os.makedirs(path)
+ def test_exist_ok_existing_directory(self):
+ path = os.path.join(support.TESTFN, 'dir1')
+ mode = 0o777
+ old_mask = os.umask(0o022)
+ os.makedirs(path, mode)
+ self.assertRaises(OSError, os.makedirs, path, mode)
+ self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False)
+ self.assertRaises(OSError, os.makedirs, path, 0o776, exist_ok=True)
+ os.makedirs(path, mode=mode, exist_ok=True)
+ os.umask(old_mask)
+
+ def test_exist_ok_existing_regular_file(self):
+ base = support.TESTFN
+ path = os.path.join(support.TESTFN, 'dir1')
+ f = open(path, 'w')
+ f.write('abc')
+ f.close()
+ self.assertRaises(OSError, os.makedirs, path)
+ self.assertRaises(OSError, os.makedirs, path, exist_ok=False)
+ self.assertRaises(OSError, os.makedirs, path, exist_ok=True)
+ os.remove(path)
+
def tearDown(self):
path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3',
'dir4', 'dir5', 'dir6')
@@ -583,6 +687,39 @@ class URandomTests(unittest.TestCase):
except NotImplementedError:
pass
+@contextlib.contextmanager
+def _execvpe_mockup(defpath=None):
+ """
+ Stubs out execv and execve functions when used as context manager.
+ Records exec calls. The mock execv and execve functions always raise an
+ exception as they would normally never return.
+ """
+ # A list of tuples containing (function name, first arg, args)
+ # of calls to execv or execve that have been made.
+ calls = []
+
+ def mock_execv(name, *args):
+ calls.append(('execv', name, args))
+ raise RuntimeError("execv called")
+
+ def mock_execve(name, *args):
+ calls.append(('execve', name, args))
+ raise OSError(errno.ENOTDIR, "execve called")
+
+ try:
+ orig_execv = os.execv
+ orig_execve = os.execve
+ orig_defpath = os.defpath
+ os.execv = mock_execv
+ os.execve = mock_execve
+ if defpath is not None:
+ os.defpath = defpath
+ yield calls
+ finally:
+ os.execv = orig_execv
+ os.execve = orig_execve
+ os.defpath = orig_defpath
+
class ExecTests(unittest.TestCase):
@unittest.skipIf(USING_LINUXTHREADS,
"avoid triggering a linuxthreads bug: see issue #4970")
@@ -593,13 +730,60 @@ class ExecTests(unittest.TestCase):
def test_execvpe_with_bad_arglist(self):
self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
-class ArgTests(unittest.TestCase):
- def test_bytearray(self):
- # Issue #7561: posix module didn't release bytearray exports properly.
- b = bytearray(os.sep.encode('ascii'))
- self.assertRaises(OSError, os.mkdir, b)
- # Check object is still resizable.
- b[:] = b''
+ @unittest.skipUnless(hasattr(os, '_execvpe'),
+ "No internal os._execvpe function to test.")
+ def _test_internal_execvpe(self, test_type):
+ program_path = os.sep + 'absolutepath'
+ if test_type is bytes:
+ program = b'executable'
+ fullpath = os.path.join(os.fsencode(program_path), program)
+ native_fullpath = fullpath
+ arguments = [b'progname', 'arg1', 'arg2']
+ else:
+ program = 'executable'
+ arguments = ['progname', 'arg1', 'arg2']
+ fullpath = os.path.join(program_path, program)
+ if os.name != "nt":
+ native_fullpath = os.fsencode(fullpath)
+ else:
+ native_fullpath = fullpath
+ env = {'spam': 'beans'}
+
+ # test os._execvpe() with an absolute path
+ with _execvpe_mockup() as calls:
+ self.assertRaises(RuntimeError,
+ os._execvpe, fullpath, arguments)
+ self.assertEqual(len(calls), 1)
+ self.assertEqual(calls[0], ('execv', fullpath, (arguments,)))
+
+ # test os._execvpe() with a relative path:
+ # os.get_exec_path() returns defpath
+ with _execvpe_mockup(defpath=program_path) as calls:
+ self.assertRaises(OSError,
+ os._execvpe, program, arguments, env=env)
+ self.assertEqual(len(calls), 1)
+ self.assertSequenceEqual(calls[0],
+ ('execve', native_fullpath, (arguments, env)))
+
+ # test os._execvpe() with a relative path:
+ # os.get_exec_path() reads the 'PATH' variable
+ with _execvpe_mockup() as calls:
+ env_path = env.copy()
+ if test_type is bytes:
+ env_path[b'PATH'] = program_path
+ else:
+ env_path['PATH'] = program_path
+ self.assertRaises(OSError,
+ os._execvpe, program, arguments, env=env_path)
+ self.assertEqual(len(calls), 1)
+ self.assertSequenceEqual(calls[0],
+ ('execve', native_fullpath, (arguments, env_path)))
+
+ def test_internal_execvpe_str(self):
+ self._test_internal_execvpe(str)
+ if os.name != "nt":
+ self._test_internal_execvpe(bytes)
+
class Win32ErrorTests(unittest.TestCase):
def test_rename(self):
@@ -703,6 +887,42 @@ class TestInvalidFD(unittest.TestCase):
if hasattr(os, "write"):
self.check(os.write, b" ")
+
+class LinkTests(unittest.TestCase):
+ def setUp(self):
+ self.file1 = support.TESTFN
+ self.file2 = os.path.join(support.TESTFN + "2")
+
+ def tearDown(self):
+ for file in (self.file1, self.file2):
+ if os.path.exists(file):
+ os.unlink(file)
+
+ def _test_link(self, file1, file2):
+ with open(file1, "w") as f1:
+ f1.write("test")
+
+ os.link(file1, file2)
+ with open(file1, "r") as f1, open(file2, "r") as f2:
+ self.assertTrue(os.path.sameopenfile(f1.fileno(), f2.fileno()))
+
+ def test_link(self):
+ self._test_link(self.file1, self.file2)
+
+ def test_link_bytes(self):
+ self._test_link(bytes(self.file1, sys.getfilesystemencoding()),
+ bytes(self.file2, sys.getfilesystemencoding()))
+
+ def test_unicode_name(self):
+ try:
+ os.fsencode("\xf1")
+ except UnicodeError:
+ raise unittest.SkipTest("Unable to encode for this platform.")
+
+ self.file1 += "\xf1"
+ self.file2 = self.file1 + "2"
+ self._test_link(self.file1, self.file2)
+
if sys.platform != 'win32':
class Win32ErrorTests(unittest.TestCase):
pass
@@ -742,7 +962,6 @@ if sys.platform != 'win32':
def test_setreuid_neg1(self):
# Needs to accept -1. We run this in a subprocess to avoid
# altering the test runner's process state (issue8045).
- import subprocess
subprocess.check_call([
sys.executable, '-c',
'import os,sys;os.setreuid(-1,-1);sys.exit(0)'])
@@ -757,34 +976,51 @@ if sys.platform != 'win32':
def test_setregid_neg1(self):
# Needs to accept -1. We run this in a subprocess to avoid
# altering the test runner's process state (issue8045).
- import subprocess
subprocess.check_call([
sys.executable, '-c',
'import os,sys;os.setregid(-1,-1);sys.exit(0)'])
- @unittest.skipIf(sys.platform == 'darwin', "tests don't apply to OS X")
class Pep383Tests(unittest.TestCase):
- filenames = [b'foo\xf6bar', 'foo\xf6bar'.encode("utf-8")]
-
def setUp(self):
- self.fsencoding = sys.getfilesystemencoding()
- sys.setfilesystemencoding("utf-8")
- self.dir = support.TESTFN
- self.bdir = self.dir.encode("utf-8", "surrogateescape")
+ if support.TESTFN_UNENCODABLE:
+ self.dir = support.TESTFN_UNENCODABLE
+ else:
+ self.dir = support.TESTFN
+ self.bdir = os.fsencode(self.dir)
+
+ bytesfn = []
+ def add_filename(fn):
+ try:
+ fn = os.fsencode(fn)
+ except UnicodeEncodeError:
+ return
+ bytesfn.append(fn)
+ add_filename(support.TESTFN_UNICODE)
+ if support.TESTFN_UNENCODABLE:
+ add_filename(support.TESTFN_UNENCODABLE)
+ if not bytesfn:
+ self.skipTest("couldn't create any non-ascii filename")
+
+ self.unicodefn = set()
os.mkdir(self.dir)
- self.unicodefn = []
- for fn in self.filenames:
- f = open(os.path.join(self.bdir, fn), "w")
- f.close()
- self.unicodefn.append(fn.decode("utf-8", "surrogateescape"))
+ try:
+ for fn in bytesfn:
+ f = open(os.path.join(self.bdir, fn), "w")
+ f.close()
+ fn = os.fsdecode(fn)
+ if fn in self.unicodefn:
+ raise ValueError("duplicate filename")
+ self.unicodefn.add(fn)
+ except:
+ shutil.rmtree(self.dir)
+ raise
def tearDown(self):
shutil.rmtree(self.dir)
- sys.setfilesystemencoding(self.fsencoding)
def test_listdir(self):
- expected = set(self.unicodefn)
- found = set(os.listdir(support.TESTFN))
+ expected = self.unicodefn
+ found = set(os.listdir(self.dir))
self.assertEqual(found, expected)
def test_open(self):
@@ -801,9 +1037,232 @@ else:
class Pep383Tests(unittest.TestCase):
pass
+@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
+class Win32KillTests(unittest.TestCase):
+ def _kill(self, sig):
+ # Start sys.executable as a subprocess and communicate from the
+ # subprocess to the parent that the interpreter is ready. When it
+ # becomes ready, send *sig* via os.kill to the subprocess and check
+ # that the return code is equal to *sig*.
+ import ctypes
+ from ctypes import wintypes
+ import msvcrt
+
+ # Since we can't access the contents of the process' stdout until the
+ # process has exited, use PeekNamedPipe to see what's inside stdout
+ # without waiting. This is done so we can tell that the interpreter
+ # is started and running at a point where it could handle a signal.
+ PeekNamedPipe = ctypes.windll.kernel32.PeekNamedPipe
+ PeekNamedPipe.restype = wintypes.BOOL
+ PeekNamedPipe.argtypes = (wintypes.HANDLE, # Pipe handle
+ ctypes.POINTER(ctypes.c_char), # stdout buf
+ wintypes.DWORD, # Buffer size
+ ctypes.POINTER(wintypes.DWORD), # bytes read
+ ctypes.POINTER(wintypes.DWORD), # bytes avail
+ ctypes.POINTER(wintypes.DWORD)) # bytes left
+ msg = "running"
+ proc = subprocess.Popen([sys.executable, "-c",
+ "import sys;"
+ "sys.stdout.write('{}');"
+ "sys.stdout.flush();"
+ "input()".format(msg)],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ stdin=subprocess.PIPE)
+ self.addCleanup(proc.stdout.close)
+ self.addCleanup(proc.stderr.close)
+ self.addCleanup(proc.stdin.close)
+
+ count, max = 0, 100
+ while count < max and proc.poll() is None:
+ # Create a string buffer to store the result of stdout from the pipe
+ buf = ctypes.create_string_buffer(len(msg))
+ # Obtain the text currently in proc.stdout
+ # Bytes read/avail/left are left as NULL and unused
+ rslt = PeekNamedPipe(msvcrt.get_osfhandle(proc.stdout.fileno()),
+ buf, ctypes.sizeof(buf), None, None, None)
+ self.assertNotEqual(rslt, 0, "PeekNamedPipe failed")
+ if buf.value:
+ self.assertEqual(msg, buf.value.decode())
+ break
+ time.sleep(0.1)
+ count += 1
+ else:
+ self.fail("Did not receive communication from the subprocess")
+
+ os.kill(proc.pid, sig)
+ self.assertEqual(proc.wait(), sig)
+
+ def test_kill_sigterm(self):
+ # SIGTERM doesn't mean anything special, but make sure it works
+ self._kill(signal.SIGTERM)
+
+ def test_kill_int(self):
+ # os.kill on Windows can take an int which gets set as the exit code
+ self._kill(100)
+
+ def _kill_with_event(self, event, name):
+ tagname = "test_os_%s" % uuid.uuid1()
+ m = mmap.mmap(-1, 1, tagname)
+ m[0] = 0
+ # Run a script which has console control handling enabled.
+ proc = subprocess.Popen([sys.executable,
+ os.path.join(os.path.dirname(__file__),
+ "win_console_handler.py"), tagname],
+ creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
+ # Let the interpreter startup before we send signals. See #3137.
+ count, max = 0, 100
+ while count < max and proc.poll() is None:
+ if m[0] == 1:
+ break
+ time.sleep(0.1)
+ count += 1
+ else:
+ # Forcefully kill the process if we weren't able to signal it.
+ os.kill(proc.pid, signal.SIGINT)
+ self.fail("Subprocess didn't finish initialization")
+ os.kill(proc.pid, event)
+ # proc.send_signal(event) could also be done here.
+ # Allow time for the signal to be passed and the process to exit.
+ time.sleep(0.5)
+ if not proc.poll():
+ # Forcefully kill the process if we weren't able to signal it.
+ os.kill(proc.pid, signal.SIGINT)
+ self.fail("subprocess did not stop on {}".format(name))
+
+ @unittest.skip("subprocesses aren't inheriting CTRL+C property")
+ def test_CTRL_C_EVENT(self):
+ from ctypes import wintypes
+ import ctypes
+
+ # Make a NULL value by creating a pointer with no argument.
+ NULL = ctypes.POINTER(ctypes.c_int)()
+ SetConsoleCtrlHandler = ctypes.windll.kernel32.SetConsoleCtrlHandler
+ SetConsoleCtrlHandler.argtypes = (ctypes.POINTER(ctypes.c_int),
+ wintypes.BOOL)
+ SetConsoleCtrlHandler.restype = wintypes.BOOL
+
+ # Calling this with NULL and FALSE causes the calling process to
+ # handle CTRL+C, rather than ignore it. This property is inherited
+ # by subprocesses.
+ SetConsoleCtrlHandler(NULL, 0)
+
+ self._kill_with_event(signal.CTRL_C_EVENT, "CTRL_C_EVENT")
+
+ def test_CTRL_BREAK_EVENT(self):
+ self._kill_with_event(signal.CTRL_BREAK_EVENT, "CTRL_BREAK_EVENT")
+
+
+@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
+@support.skip_unless_symlink
+class Win32SymlinkTests(unittest.TestCase):
+ filelink = 'filelinktest'
+ filelink_target = os.path.abspath(__file__)
+ dirlink = 'dirlinktest'
+ dirlink_target = os.path.dirname(filelink_target)
+ missing_link = 'missing link'
+
+ def setUp(self):
+ assert os.path.exists(self.dirlink_target)
+ assert os.path.exists(self.filelink_target)
+ assert not os.path.exists(self.dirlink)
+ assert not os.path.exists(self.filelink)
+ assert not os.path.exists(self.missing_link)
+
+ def tearDown(self):
+ if os.path.exists(self.filelink):
+ os.remove(self.filelink)
+ if os.path.exists(self.dirlink):
+ os.rmdir(self.dirlink)
+ if os.path.lexists(self.missing_link):
+ os.remove(self.missing_link)
+
+ def test_directory_link(self):
+ os.symlink(self.dirlink_target, self.dirlink)
+ self.assertTrue(os.path.exists(self.dirlink))
+ self.assertTrue(os.path.isdir(self.dirlink))
+ self.assertTrue(os.path.islink(self.dirlink))
+ self.check_stat(self.dirlink, self.dirlink_target)
+
+ def test_file_link(self):
+ os.symlink(self.filelink_target, self.filelink)
+ self.assertTrue(os.path.exists(self.filelink))
+ self.assertTrue(os.path.isfile(self.filelink))
+ self.assertTrue(os.path.islink(self.filelink))
+ self.check_stat(self.filelink, self.filelink_target)
+
+ def _create_missing_dir_link(self):
+ 'Create a "directory" link to a non-existent target'
+ linkname = self.missing_link
+ if os.path.lexists(linkname):
+ os.remove(linkname)
+ target = r'c:\\target does not exist.29r3c740'
+ assert not os.path.exists(target)
+ target_is_dir = True
+ os.symlink(target, linkname, target_is_dir)
+
+ def test_remove_directory_link_to_missing_target(self):
+ self._create_missing_dir_link()
+ # For compatibility with Unix, os.remove will check the
+ # directory status and call RemoveDirectory if the symlink
+ # was created with target_is_dir==True.
+ os.remove(self.missing_link)
+
+ @unittest.skip("currently fails; consider for improvement")
+ def test_isdir_on_directory_link_to_missing_target(self):
+ self._create_missing_dir_link()
+ # consider having isdir return true for directory links
+ self.assertTrue(os.path.isdir(self.missing_link))
+
+ @unittest.skip("currently fails; consider for improvement")
+ def test_rmdir_on_directory_link_to_missing_target(self):
+ self._create_missing_dir_link()
+ # consider allowing rmdir to remove directory links
+ os.rmdir(self.missing_link)
+
+ def check_stat(self, link, target):
+ self.assertEqual(os.stat(link), os.stat(target))
+ self.assertNotEqual(os.lstat(link), os.stat(link))
+
+
+class FSEncodingTests(unittest.TestCase):
+ def test_nop(self):
+ self.assertEqual(os.fsencode(b'abc\xff'), b'abc\xff')
+ self.assertEqual(os.fsdecode('abc\u0141'), 'abc\u0141')
+
+ def test_identity(self):
+ # assert fsdecode(fsencode(x)) == x
+ for fn in ('unicode\u0141', 'latin\xe9', 'ascii'):
+ try:
+ bytesfn = os.fsencode(fn)
+ except UnicodeEncodeError:
+ continue
+ self.assertEqual(os.fsdecode(bytesfn), fn)
+
+
+class PidTests(unittest.TestCase):
+ @unittest.skipUnless(hasattr(os, 'getppid'), "test needs os.getppid")
+ def test_getppid(self):
+ p = subprocess.Popen([sys.executable, '-c',
+ 'import os; print(os.getppid())'],
+ stdout=subprocess.PIPE)
+ stdout, _ = p.communicate()
+ # We are the parent of our subprocess
+ self.assertEqual(int(stdout), os.getpid())
+
+
+# The introduction of this TestCase caused at least two different errors on
+# *nix buildbots. Temporarily skip this to let the buildbots move along.
+@unittest.skip("Skip due to platform/environment differences on *NIX buildbots")
+@unittest.skipUnless(hasattr(os, 'getlogin'), "test needs os.getlogin")
+class LoginTests(unittest.TestCase):
+ def test_getlogin(self):
+ user_name = os.getlogin()
+ self.assertNotEqual(len(user_name), 0)
+
+
def test_main():
support.run_unittest(
- ArgTests,
FileTests,
StatAttributeTests,
EnvironTests,
@@ -815,7 +1274,13 @@ def test_main():
Win32ErrorTests,
TestInvalidFD,
PosixUidGidTests,
- Pep383Tests
+ Pep383Tests,
+ Win32KillTests,
+ Win32SymlinkTests,
+ FSEncodingTests,
+ PidTests,
+ LoginTests,
+ LinkTests,
)
if __name__ == "__main__":
diff --git a/Lib/test/test_ossaudiodev.py b/Lib/test/test_ossaudiodev.py
index 5dea640d89..9cb89d69a6 100644
--- a/Lib/test/test_ossaudiodev.py
+++ b/Lib/test/test_ossaudiodev.py
@@ -162,11 +162,13 @@ class OSSAudioDevTests(unittest.TestCase):
def test_mixer_methods(self):
# Issue #8139: ossaudiodev didn't initialize its types properly,
# therefore some methods were unavailable.
- mixer = ossaudiodev.openmixer()
- try:
+ with ossaudiodev.openmixer() as mixer:
self.assertGreaterEqual(mixer.fileno(), 0)
- finally:
- mixer.close()
+
+ def test_with(self):
+ with ossaudiodev.open('w') as dsp:
+ pass
+ self.assertTrue(dsp.closed)
def test_main():
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 9ab4171bda..020acd500f 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -1,5 +1,4 @@
import parser
-import os
import unittest
import sys
import operator
@@ -34,7 +33,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
code = suite.compile()
scope = {}
exec(code, {}, scope)
- self.assertTrue(isinstance(scope["x"], str))
+ self.assertIsInstance(scope["x"], str)
def check_suite(self, s):
self.roundtrip(parser.suite, s)
@@ -227,7 +226,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
def test_position(self):
# An absolutely minimal test of position information. Better
# tests would be a big project.
- code = "def f(x):\n return x + 1\n"
+ code = "def f(x):\n return x + 1"
st1 = parser.suite(code)
st2 = st1.totuple(line_info=1, col_info=1)
@@ -261,6 +260,12 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
(0, '', 2, -1)],
terminals)
+ def test_extended_unpacking(self):
+ self.check_suite("*a = y")
+ self.check_suite("x, *b, = m")
+ self.check_suite("[*a, *b] = y")
+ self.check_suite("for [*x, b] in x: pass")
+
#
# Second, we take *invalid* trees and make sure we get ParserError
@@ -512,6 +517,16 @@ class CompileTestCase(unittest.TestCase):
st = parser.suite('a = "\\u1"')
self.assertRaises(SyntaxError, parser.compilest, st)
+ def test_issue_9011(self):
+ # Issue 9011: compilation of an unary minus expression changed
+ # the meaning of the ST, so that a second compilation produced
+ # incorrect results.
+ st = parser.expr('-3')
+ code1 = parser.compilest(st)
+ self.assertEqual(eval(code1), -3)
+ code2 = parser.compilest(st)
+ self.assertEqual(eval(code2), -3)
+
class ParserStackLimitTestCase(unittest.TestCase):
"""try to push the parser to/over its limits.
see http://bugs.python.org/issue1881 for a discussion
@@ -529,6 +544,7 @@ class ParserStackLimitTestCase(unittest.TestCase):
e = self._nested_expression(100)
print("Expecting 's_push: parser stack overflow' in next line",
file=sys.stderr)
+ sys.stderr.flush()
self.assertRaises(MemoryError, parser.expr, e)
class STObjectTestCase(unittest.TestCase):
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 2589141615..d861df52bb 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1,11 +1,10 @@
-# A test suite for pdb; at the moment, this only validates skipping of
-# specified test modules (RFE #5142).
+# A test suite for pdb; not very comprehensive at the moment.
import imp
-import os
+import pdb
import sys
-import doctest
-import tempfile
+import unittest
+import subprocess
from test import support
# This little helper class is essential for testing pdb under doctest.
@@ -30,7 +29,7 @@ def test_pdb_displayhook():
"""This tests the custom displayhook for pdb.
>>> def test_function(foo, bar):
- ... import pdb; pdb.Pdb().set_trace()
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
... pass
>>> with PdbTestInput([
@@ -54,11 +53,122 @@ def test_pdb_displayhook():
(Pdb) continue
"""
+
+def test_pdb_basic_commands():
+ """Test the basic commands of pdb.
+
+ >>> def test_function_2(foo, bar='default'):
+ ... print(foo)
+ ... for i in range(5):
+ ... print(i)
+ ... print(bar)
+ ... for i in range(10):
+ ... never_executed
+ ... print('after for')
+ ... print('...')
+ ... return foo.upper()
+
+ >>> def test_function():
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
+ ... ret = test_function_2('baz')
+ ... print(ret)
+
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+ ... 'step', # entering the function call
+ ... 'args', # display function args
+ ... 'list', # list function source
+ ... 'bt', # display backtrace
+ ... 'up', # step up to test_function()
+ ... 'down', # step down to test_function_2() again
+ ... 'next', # stepping to print(foo)
+ ... 'next', # stepping to the for loop
+ ... 'step', # stepping into the for loop
+ ... 'until', # continuing until out of the for loop
+ ... 'next', # executing the print(bar)
+ ... 'jump 8', # jump over second for loop
+ ... 'return', # return out of function
+ ... 'retval', # display return value
+ ... 'continue',
+ ... ]):
+ ... test_function()
+ > <doctest test.test_pdb.test_pdb_basic_commands[1]>(3)test_function()
+ -> ret = test_function_2('baz')
+ (Pdb) step
+ --Call--
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(1)test_function_2()
+ -> def test_function_2(foo, bar='default'):
+ (Pdb) args
+ foo = 'baz'
+ bar = 'default'
+ (Pdb) list
+ 1 -> def test_function_2(foo, bar='default'):
+ 2 print(foo)
+ 3 for i in range(5):
+ 4 print(i)
+ 5 print(bar)
+ 6 for i in range(10):
+ 7 never_executed
+ 8 print('after for')
+ 9 print('...')
+ 10 return foo.upper()
+ [EOF]
+ (Pdb) bt
+ ...
+ <doctest test.test_pdb.test_pdb_basic_commands[2]>(18)<module>()
+ -> test_function()
+ <doctest test.test_pdb.test_pdb_basic_commands[1]>(3)test_function()
+ -> ret = test_function_2('baz')
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(1)test_function_2()
+ -> def test_function_2(foo, bar='default'):
+ (Pdb) up
+ > <doctest test.test_pdb.test_pdb_basic_commands[1]>(3)test_function()
+ -> ret = test_function_2('baz')
+ (Pdb) down
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(1)test_function_2()
+ -> def test_function_2(foo, bar='default'):
+ (Pdb) next
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(2)test_function_2()
+ -> print(foo)
+ (Pdb) next
+ baz
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(3)test_function_2()
+ -> for i in range(5):
+ (Pdb) step
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(4)test_function_2()
+ -> print(i)
+ (Pdb) until
+ 0
+ 1
+ 2
+ 3
+ 4
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(5)test_function_2()
+ -> print(bar)
+ (Pdb) next
+ default
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(6)test_function_2()
+ -> for i in range(10):
+ (Pdb) jump 8
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(8)test_function_2()
+ -> print('after for')
+ (Pdb) return
+ after for
+ ...
+ --Return--
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(10)test_function_2()->'BAZ'
+ -> return foo.upper()
+ (Pdb) retval
+ 'BAZ'
+ (Pdb) continue
+ BAZ
+ """
+
+
def test_pdb_breakpoint_commands():
"""Test basic commands related to breakpoints.
>>> def test_function():
- ... import pdb; pdb.Pdb().set_trace()
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
... print(1)
... print(2)
... print(3)
@@ -106,9 +216,11 @@ def test_pdb_breakpoint_commands():
(Pdb) break 3
Breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) disable 1
+ Disabled breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) ignore 1 10
Will ignore next 10 crossings of breakpoint 1.
(Pdb) condition 1 1 < 2
+ New condition set for breakpoint 1.
(Pdb) break 4
Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) break 4
@@ -121,7 +233,7 @@ def test_pdb_breakpoint_commands():
2 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
3 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) clear 3
- Deleted breakpoint 3
+ Deleted breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep no at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
@@ -131,8 +243,9 @@ def test_pdb_breakpoint_commands():
(Pdb) condition 1
Breakpoint 1 is now unconditional.
(Pdb) enable 1
+ Enabled breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) clear 1
- Deleted breakpoint 1
+ Deleted breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) commands 2
(com) print 42
(com) end
@@ -143,11 +256,12 @@ def test_pdb_breakpoint_commands():
-> print(2)
(Pdb) clear
Clear all breaks? y
+ Deleted breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) tbreak 5
Breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5
(Pdb) continue
2
- Deleted breakpoint 4
+ Deleted breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5
> <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(5)test_function()
-> print(3)
(Pdb) break
@@ -156,12 +270,177 @@ def test_pdb_breakpoint_commands():
4
"""
+
+def do_nothing():
+ pass
+
+def do_something():
+ print(42)
+
+def test_list_commands():
+ """Test the list and source commands of pdb.
+
+ >>> def test_function_2(foo):
+ ... import test.test_pdb
+ ... test.test_pdb.do_nothing()
+ ... 'some...'
+ ... 'more...'
+ ... 'code...'
+ ... 'to...'
+ ... 'make...'
+ ... 'a...'
+ ... 'long...'
+ ... 'listing...'
+ ... 'useful...'
+ ... '...'
+ ... '...'
+ ... return foo
+
+ >>> def test_function():
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
+ ... ret = test_function_2('baz')
+
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+ ... 'list', # list first function
+ ... 'step', # step into second function
+ ... 'list', # list second function
+ ... 'list', # continue listing to EOF
+ ... 'list 1,3', # list specific lines
+ ... 'list x', # invalid argument
+ ... 'next', # step to import
+ ... 'next', # step over import
+ ... 'step', # step into do_nothing
+ ... 'longlist', # list all lines
+ ... 'source do_something', # list all lines of function
+ ... 'source fooxxx', # something that doesn't exit
+ ... 'continue',
+ ... ]):
+ ... test_function()
+ > <doctest test.test_pdb.test_list_commands[1]>(3)test_function()
+ -> ret = test_function_2('baz')
+ (Pdb) list
+ 1 def test_function():
+ 2 import pdb; pdb.Pdb(nosigint=True).set_trace()
+ 3 -> ret = test_function_2('baz')
+ [EOF]
+ (Pdb) step
+ --Call--
+ > <doctest test.test_pdb.test_list_commands[0]>(1)test_function_2()
+ -> def test_function_2(foo):
+ (Pdb) list
+ 1 -> def test_function_2(foo):
+ 2 import test.test_pdb
+ 3 test.test_pdb.do_nothing()
+ 4 'some...'
+ 5 'more...'
+ 6 'code...'
+ 7 'to...'
+ 8 'make...'
+ 9 'a...'
+ 10 'long...'
+ 11 'listing...'
+ (Pdb) list
+ 12 'useful...'
+ 13 '...'
+ 14 '...'
+ 15 return foo
+ [EOF]
+ (Pdb) list 1,3
+ 1 -> def test_function_2(foo):
+ 2 import test.test_pdb
+ 3 test.test_pdb.do_nothing()
+ (Pdb) list x
+ *** ...
+ (Pdb) next
+ > <doctest test.test_pdb.test_list_commands[0]>(2)test_function_2()
+ -> import test.test_pdb
+ (Pdb) next
+ > <doctest test.test_pdb.test_list_commands[0]>(3)test_function_2()
+ -> test.test_pdb.do_nothing()
+ (Pdb) step
+ --Call--
+ > ...test_pdb.py(...)do_nothing()
+ -> def do_nothing():
+ (Pdb) longlist
+ ... -> def do_nothing():
+ ... pass
+ (Pdb) source do_something
+ ... def do_something():
+ ... print(42)
+ (Pdb) source fooxxx
+ *** ...
+ (Pdb) continue
+ """
+
+
+def test_post_mortem():
+ """Test post mortem traceback debugging.
+
+ >>> def test_function_2():
+ ... try:
+ ... 1/0
+ ... finally:
+ ... print('Exception!')
+
+ >>> def test_function():
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
+ ... test_function_2()
+ ... print('Not reached.')
+
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+ ... 'next', # step over exception-raising call
+ ... 'bt', # get a backtrace
+ ... 'list', # list code of test_function()
+ ... 'down', # step into test_function_2()
+ ... 'list', # list code of test_function_2()
+ ... 'continue',
+ ... ]):
+ ... try:
+ ... test_function()
+ ... except ZeroDivisionError:
+ ... print('Correctly reraised.')
+ > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function()
+ -> test_function_2()
+ (Pdb) next
+ Exception!
+ ZeroDivisionError: division by zero
+ > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function()
+ -> test_function_2()
+ (Pdb) bt
+ ...
+ <doctest test.test_pdb.test_post_mortem[2]>(10)<module>()
+ -> test_function()
+ > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function()
+ -> test_function_2()
+ <doctest test.test_pdb.test_post_mortem[0]>(3)test_function_2()
+ -> 1/0
+ (Pdb) list
+ 1 def test_function():
+ 2 import pdb; pdb.Pdb(nosigint=True).set_trace()
+ 3 -> test_function_2()
+ 4 print('Not reached.')
+ [EOF]
+ (Pdb) down
+ > <doctest test.test_pdb.test_post_mortem[0]>(3)test_function_2()
+ -> 1/0
+ (Pdb) list
+ 1 def test_function_2():
+ 2 try:
+ 3 >> 1/0
+ 4 finally:
+ 5 -> print('Exception!')
+ [EOF]
+ (Pdb) continue
+ Correctly reraised.
+ """
+
+
def test_pdb_skip_modules():
"""This illustrates the simple case of module skipping.
>>> def skip_module():
... import string
- ... import pdb; pdb.Pdb(skip=['stri*']).set_trace()
+ ... import pdb; pdb.Pdb(skip=['stri*'], nosigint=True).set_trace()
... string.capwords('FOO')
>>> with PdbTestInput([
@@ -190,7 +469,7 @@ def test_pdb_skip_modules_with_callback():
>>> def skip_module():
... def callback():
... return None
- ... import pdb; pdb.Pdb(skip=['module_to_skip*']).set_trace()
+ ... import pdb; pdb.Pdb(skip=['module_to_skip*'], nosigint=True).set_trace()
... mod.foo_pony(callback)
>>> with PdbTestInput([
@@ -231,7 +510,7 @@ def test_pdb_continue_in_bottomframe():
"""Test that "continue" and "next" work properly in bottom frame (issue #5294).
>>> def test_function():
- ... import pdb, sys; inst = pdb.Pdb()
+ ... import pdb, sys; inst = pdb.Pdb(nosigint=True)
... inst.set_trace()
... inst.botframe = sys._getframe() # hackery to get the right botframe
... print(1)
@@ -239,15 +518,7 @@ def test_pdb_continue_in_bottomframe():
... print(3)
... print(4)
- First, need to clear bdb state that might be left over from previous tests.
- Otherwise, the new breakpoints might get assigned different numbers.
-
- >>> from bdb import Breakpoint
- >>> Breakpoint.next = 1
- >>> Breakpoint.bplist = {}
- >>> Breakpoint.bpbynumber = [None]
-
- >>> with PdbTestInput([
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS
... 'next',
... 'break 7',
... 'continue',
@@ -262,7 +533,7 @@ def test_pdb_continue_in_bottomframe():
> <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(5)test_function()
-> print(1)
(Pdb) break 7
- Breakpoint 1 at <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>:7
+ Breakpoint ... at <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>:7
(Pdb) continue
1
2
@@ -277,10 +548,76 @@ def test_pdb_continue_in_bottomframe():
"""
+def pdb_invoke(method, arg):
+ """Run pdb.method(arg)."""
+ import pdb
+ getattr(pdb.Pdb(nosigint=True), method)(arg)
+
+
+def test_pdb_run_with_incorrect_argument():
+ """Testing run and runeval with incorrect first argument.
+
+ >>> pti = PdbTestInput(['continue',])
+ >>> with pti:
+ ... pdb_invoke('run', lambda x: x)
+ Traceback (most recent call last):
+ TypeError: exec() arg 1 must be a string, bytes or code object
+
+ >>> with pti:
+ ... pdb_invoke('runeval', lambda x: x)
+ Traceback (most recent call last):
+ TypeError: eval() arg 1 must be a string, bytes or code object
+ """
+
+
+def test_pdb_run_with_code_object():
+ """Testing run and runeval with code object as a first argument.
+
+ >>> with PdbTestInput(['step','x', 'continue']): # doctest: +ELLIPSIS
+ ... pdb_invoke('run', compile('x=1', '<string>', 'exec'))
+ > <string>(1)<module>()...
+ (Pdb) step
+ --Return--
+ > <string>(1)<module>()->None
+ (Pdb) x
+ 1
+ (Pdb) continue
+
+ >>> with PdbTestInput(['x', 'continue']):
+ ... x=0
+ ... pdb_invoke('runeval', compile('x+1', '<string>', 'eval'))
+ > <string>(1)<module>()->None
+ (Pdb) x
+ 1
+ (Pdb) continue
+ """
+
+
+class PdbTestCase(unittest.TestCase):
+
+ def test_issue7964(self):
+ # open the file as binary so we can force \r\n newline
+ with open(support.TESTFN, 'wb') as f:
+ f.write(b'print("testing my pdb")\r\n')
+ cmd = [sys.executable, '-m', 'pdb', support.TESTFN]
+ proc = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ )
+ self.addCleanup(proc.stdout.close)
+ stdout, stderr = proc.communicate(b'quit\n')
+ self.assertNotIn(b'SyntaxError', stdout,
+ "Got a syntax error running test script under PDB")
+
+ def tearDown(self):
+ support.unlink(support.TESTFN)
+
def test_main():
from test import test_pdb
support.run_doctest(test_pdb, verbosity=True)
+ support.run_unittest(PdbTestCase)
if __name__ == '__main__':
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 569650035c..b7d446fdd0 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -1,4 +1,5 @@
import dis
+import re
import sys
from io import StringIO
import unittest
@@ -25,9 +26,9 @@ class TestTranforms(unittest.TestCase):
del x
asm = disassemble(unot)
for elem in ('UNARY_NOT', 'POP_JUMP_IF_FALSE'):
- self.assertTrue(elem not in asm)
+ self.assertNotIn(elem, asm)
for elem in ('POP_JUMP_IF_TRUE',):
- self.assertTrue(elem in asm)
+ self.assertIn(elem, asm)
def test_elim_inversion_of_is_or_in(self):
for line, elem in (
@@ -37,7 +38,7 @@ class TestTranforms(unittest.TestCase):
('not a not in b', '(in)',),
):
asm = dis_single(line)
- self.assertTrue(elem in asm)
+ self.assertIn(elem, asm)
def test_global_as_constant(self):
# LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False
@@ -54,14 +55,14 @@ class TestTranforms(unittest.TestCase):
for func, name in ((f, 'None'), (g, 'True'), (h, 'False')):
asm = disassemble(func)
for elem in ('LOAD_GLOBAL',):
- self.assertTrue(elem not in asm)
+ self.assertNotIn(elem, asm)
for elem in ('LOAD_CONST', '('+name+')'):
- self.assertTrue(elem in asm)
+ self.assertIn(elem, asm)
def f():
'Adding a docstring made this test fail in Py2.5.0'
return None
- self.assertTrue('LOAD_CONST' in disassemble(f))
- self.assertTrue('LOAD_GLOBAL' not in disassemble(f))
+ self.assertIn('LOAD_CONST', disassemble(f))
+ self.assertNotIn('LOAD_GLOBAL', disassemble(f))
def test_while_one(self):
# Skip over: LOAD_CONST trueconst POP_JUMP_IF_FALSE xx
@@ -71,9 +72,9 @@ class TestTranforms(unittest.TestCase):
return list
asm = disassemble(f)
for elem in ('LOAD_CONST', 'POP_JUMP_IF_FALSE'):
- self.assertTrue(elem not in asm)
+ self.assertNotIn(elem, asm)
for elem in ('JUMP_ABSOLUTE',):
- self.assertTrue(elem in asm)
+ self.assertIn(elem, asm)
def test_pack_unpack(self):
for line, elem in (
@@ -82,9 +83,9 @@ class TestTranforms(unittest.TestCase):
('a, b, c = a, b, c', 'ROT_THREE',),
):
asm = dis_single(line)
- self.assertTrue(elem in asm)
- self.assertTrue('BUILD_TUPLE' not in asm)
- self.assertTrue('UNPACK_TUPLE' not in asm)
+ self.assertIn(elem, asm)
+ self.assertNotIn('BUILD_TUPLE', asm)
+ self.assertNotIn('UNPACK_TUPLE', asm)
def test_folding_of_tuples_of_constants(self):
for line, elem in (
@@ -95,8 +96,8 @@ class TestTranforms(unittest.TestCase):
('((1, 2), 3, 4)', '(((1, 2), 3, 4))'),
):
asm = dis_single(line)
- self.assertTrue(elem in asm)
- self.assertTrue('BUILD_TUPLE' not in asm)
+ self.assertIn(elem, asm)
+ self.assertNotIn('BUILD_TUPLE', asm)
# Bug 1053819: Tuple of constants misidentified when presented with:
# . . . opcode_with_arg 100 unary_opcode BUILD_TUPLE 1 . . .
@@ -115,6 +116,54 @@ class TestTranforms(unittest.TestCase):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
],)
+ def test_folding_of_lists_of_constants(self):
+ for line, elem in (
+ # in/not in constants with BUILD_LIST should be folded to a tuple:
+ ('a in [1,2,3]', '(1, 2, 3)'),
+ ('a not in ["a","b","c"]', "(('a', 'b', 'c'))"),
+ ('a in [None, 1, None]', '((None, 1, None))'),
+ ('a not in [(1, 2), 3, 4]', '(((1, 2), 3, 4))'),
+ ):
+ asm = dis_single(line)
+ self.assertIn(elem, asm)
+ self.assertNotIn('BUILD_LIST', asm)
+
+ def test_folding_of_sets_of_constants(self):
+ for line, elem in (
+ # in/not in constants with BUILD_SET should be folded to a frozenset:
+ ('a in {1,2,3}', frozenset({1, 2, 3})),
+ ('a not in {"a","b","c"}', frozenset({'a', 'c', 'b'})),
+ ('a in {None, 1, None}', frozenset({1, None})),
+ ('a not in {(1, 2), 3, 4}', frozenset({(1, 2), 3, 4})),
+ ('a in {1, 2, 3, 3, 2, 1}', frozenset({1, 2, 3})),
+ ):
+ asm = dis_single(line)
+ self.assertNotIn('BUILD_SET', asm)
+
+ # Verify that the frozenset 'elem' is in the disassembly
+ # The ordering of the elements in repr( frozenset ) isn't
+ # guaranteed, so we jump through some hoops to ensure that we have
+ # the frozenset we expect:
+ self.assertIn('frozenset', asm)
+ # Extract the frozenset literal from the disassembly:
+ m = re.match(r'.*(frozenset\({.*}\)).*', asm, re.DOTALL)
+ self.assertTrue(m)
+ self.assertEqual(eval(m.group(1)), elem)
+
+ # Ensure that the resulting code actually works:
+ def f(a):
+ return a in {1, 2, 3}
+
+ def g(a):
+ return a not in {1, 2, 3}
+
+ self.assertTrue(f(3))
+ self.assertTrue(not f(4))
+
+ self.assertTrue(not g(3))
+ self.assertTrue(g(4))
+
+
def test_folding_of_binops_on_constants(self):
for line, elem in (
('a = 2+3+4', '(9)'), # chained fold
@@ -134,26 +183,27 @@ class TestTranforms(unittest.TestCase):
('a = 13 | 7', '(15)'), # binary or
):
asm = dis_single(line)
- self.assertTrue(elem in asm, asm)
- self.assertTrue('BINARY_' not in asm)
+ self.assertIn(elem, asm, asm)
+ self.assertNotIn('BINARY_', asm)
# Verify that unfoldables are skipped
asm = dis_single('a=2+"b"')
- self.assertTrue('(2)' in asm)
- self.assertTrue("('b')" in asm)
+ self.assertIn('(2)', asm)
+ self.assertIn("('b')", asm)
# Verify that large sequences do not result from folding
asm = dis_single('a="x"*1000')
- self.assertTrue('(1000)' in asm)
+ self.assertIn('(1000)', asm)
def test_folding_of_unaryops_on_constants(self):
for line, elem in (
('-0.5', '(-0.5)'), # unary negative
('~-2', '(1)'), # unary invert
+ ('+1', '(1)'), # unary positive
):
asm = dis_single(line)
- self.assertTrue(elem in asm, asm)
- self.assertTrue('UNARY_' not in asm)
+ self.assertIn(elem, asm, asm)
+ self.assertNotIn('UNARY_', asm)
# Verify that unfoldables are skipped
for line, elem in (
@@ -161,16 +211,16 @@ class TestTranforms(unittest.TestCase):
('~"abc"', "('abc')"), # unary invert
):
asm = dis_single(line)
- self.assertTrue(elem in asm, asm)
- self.assertTrue('UNARY_' in asm)
+ self.assertIn(elem, asm, asm)
+ self.assertIn('UNARY_', asm)
def test_elim_extra_return(self):
# RETURN LOAD_CONST None RETURN --> RETURN
def f(x):
return x
asm = disassemble(f)
- self.assertTrue('LOAD_CONST' not in asm)
- self.assertTrue('(None)' not in asm)
+ self.assertNotIn('LOAD_CONST', asm)
+ self.assertNotIn('(None)', asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 1)
def test_elim_jump_to_return(self):
@@ -178,8 +228,8 @@ class TestTranforms(unittest.TestCase):
def f(cond, true_value, false_value):
return true_value if cond else false_value
asm = disassemble(f)
- self.assertTrue('JUMP_FORWARD' not in asm)
- self.assertTrue('JUMP_ABSOLUTE' not in asm)
+ self.assertNotIn('JUMP_FORWARD', asm)
+ self.assertNotIn('JUMP_ABSOLUTE', asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 2)
def test_elim_jump_after_return1(self):
@@ -194,8 +244,8 @@ class TestTranforms(unittest.TestCase):
return 5
return 6
asm = disassemble(f)
- self.assertTrue('JUMP_FORWARD' not in asm)
- self.assertTrue('JUMP_ABSOLUTE' not in asm)
+ self.assertNotIn('JUMP_FORWARD', asm)
+ self.assertNotIn('JUMP_ABSOLUTE', asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 6)
def test_elim_jump_after_return2(self):
@@ -204,7 +254,7 @@ class TestTranforms(unittest.TestCase):
while 1:
if cond1: return 4
asm = disassemble(f)
- self.assertTrue('JUMP_FORWARD' not in asm)
+ self.assertNotIn('JUMP_FORWARD', asm)
# There should be one jump for the while loop.
self.assertEqual(asm.split().count('JUMP_ABSOLUTE'), 1)
self.assertEqual(asm.split().count('RETURN_VALUE'), 2)
@@ -215,13 +265,25 @@ class TestTranforms(unittest.TestCase):
pass
return g
asm = disassemble(f)
- self.assertTrue('BINARY_ADD' not in asm)
+ self.assertNotIn('BINARY_ADD', asm)
+
+class TestBuglets(unittest.TestCase):
+
+ def test_bug_11510(self):
+ # folded constant set optimization was commingled with the tuple
+ # unpacking optimization which would fail if the set had duplicate
+ # elements so that the set length was unexpected
+ def f():
+ x, y = {1, 1}
+ return x, y
+ with self.assertRaises(ValueError):
+ f()
def test_main(verbose=None):
import sys
from test import support
- test_classes = (TestTranforms,)
+ test_classes = (TestTranforms, TestBuglets)
support.run_unittest(*test_classes)
# verify reference counting
diff --git a/Lib/test/test_pep263.py b/Lib/test/test_pep263.py
index c159af96e6..598d980b2a 100644
--- a/Lib/test/test_pep263.py
+++ b/Lib/test/test_pep263.py
@@ -26,7 +26,7 @@ class PEP263Test(unittest.TestCase):
try:
compile(b"# coding: cp932\nprint '\x94\x4e'", "dummy", "exec")
except SyntaxError as v:
- self.assertEqual(v.text, "print '\u5e74'")
+ self.assertEqual(v.text, "print '\u5e74'\n")
else:
self.fail()
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py
index 11039acc32..6d891e541e 100644
--- a/Lib/test/test_pep277.py
+++ b/Lib/test/test_pep277.py
@@ -1,22 +1,58 @@
# Test the Unicode versions of normal file functions
# open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir
import sys, os, unittest
+from unicodedata import normalize
from test import support
-if not os.path.supports_unicode_filenames:
- raise unittest.SkipTest("test works only on NT+")
filenames = [
- 'abc',
- 'ascii',
- 'Gr\xfc\xdf-Gott',
- '\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2',
- '\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435',
- '\u306b\u307d\u3093',
- '\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1',
- '\u66e8\u66e9\u66eb',
- '\u66e8\u05e9\u3093\u0434\u0393\xdf',
+ '1_abc',
+ '2_ascii',
+ '3_Gr\xfc\xdf-Gott',
+ '4_\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2',
+ '5_\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435',
+ '6_\u306b\u307d\u3093',
+ '7_\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1',
+ '8_\u66e8\u66e9\u66eb',
+ '9_\u66e8\u05e9\u3093\u0434\u0393\xdf',
+ # Specific code points: fn, NFC(fn) and NFKC(fn) all differents
+ '10_\u1fee\u1ffd',
]
+# Mac OS X decomposes Unicode names, using Normal Form D.
+# http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
+# "However, most volume formats do not follow the exact specification for
+# these normal forms. For example, HFS Plus uses a variant of Normal Form D
+# in which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through
+# U+2FAFF are not decomposed."
+if sys.platform != 'darwin':
+ filenames.extend([
+ # Specific code points: NFC(fn), NFD(fn), NFKC(fn) and NFKD(fn) all differents
+ '11_\u0385\u03d3\u03d4',
+ '12_\u00a8\u0301\u03d2\u0301\u03d2\u0308', # == NFD('\u0385\u03d3\u03d4')
+ '13_\u0020\u0308\u0301\u038e\u03ab', # == NFKC('\u0385\u03d3\u03d4')
+ '14_\u1e9b\u1fc1\u1fcd\u1fce\u1fcf\u1fdd\u1fde\u1fdf\u1fed',
+
+ # Specific code points: fn, NFC(fn) and NFKC(fn) all differents
+ '15_\u1fee\u1ffd\ufad1',
+ '16_\u2000\u2000\u2000A',
+ '17_\u2001\u2001\u2001A',
+ '18_\u2003\u2003\u2003A', # == NFC('\u2001\u2001\u2001A')
+ '19_\u0020\u0020\u0020A', # '\u0020' == ' ' == NFKC('\u2000') ==
+ # NFKC('\u2001') == NFKC('\u2003')
+])
+
+
+# Is it Unicode-friendly?
+if not os.path.supports_unicode_filenames:
+ fsencoding = sys.getfilesystemencoding()
+ try:
+ for name in filenames:
+ name.encode(fsencoding)
+ except UnicodeEncodeError:
+ raise unittest.SkipTest("only NT+ and systems with "
+ "Unicode-friendly filesystem encoding")
+
+
# Destroy directory dirname and all files under it, to one level.
def deltree(dirname):
# Don't hide legitimate errors: if one of these suckers exists, it's
@@ -27,35 +63,45 @@ def deltree(dirname):
os.unlink(os.path.join(dirname, fname))
os.rmdir(dirname)
+
class UnicodeFileTests(unittest.TestCase):
- files = [os.path.join(support.TESTFN, f) for f in filenames]
+ files = set(filenames)
+ normal_form = None
def setUp(self):
try:
os.mkdir(support.TESTFN)
except OSError:
pass
+ files = set()
for name in self.files:
- f = open(name, 'wb')
- f.write((name+'\n').encode("utf-8"))
- f.close()
+ name = os.path.join(support.TESTFN, self.norm(name))
+ with open(name, 'wb') as f:
+ f.write((name+'\n').encode("utf-8"))
os.stat(name)
+ files.add(name)
+ self.files = files
def tearDown(self):
deltree(support.TESTFN)
+ def norm(self, s):
+ if self.normal_form:
+ return normalize(self.normal_form, s)
+ return s
+
def _apply_failure(self, fn, filename, expected_exception,
check_fn_in_exception = True):
- try:
+ with self.assertRaises(expected_exception) as c:
fn(filename)
- raise support.TestFailed("Expected to fail calling '%s(%r)'"
- % (fn.__name__, filename))
- except expected_exception as details:
- if check_fn_in_exception and details.filename != filename:
- raise support.TestFailed("Function '%s(%r) failed with "
- "bad filename in the exception: %r"
- % (fn.__name__, filename,
- details.filename))
+ exc_filename = c.exception.filename
+ # the "filename" exception attribute may be encoded
+ if isinstance(exc_filename, bytes):
+ filename = filename.encode(sys.getfilesystemencoding())
+ if check_fn_in_exception:
+ self.assertEqual(exc_filename, filename, "Function '%s(%a) failed "
+ "with bad filename in the exception: %a" %
+ (fn.__name__, filename, exc_filename))
def test_failures(self):
# Pass non-existing Unicode filenames all over the place.
@@ -76,39 +122,87 @@ class UnicodeFileTests(unittest.TestCase):
f.close()
os.stat(name)
+ # Skip the test on darwin, because darwin does normalize the filename to
+ # NFD (a variant of Unicode NFD form). Normalize the filename to NFC, NFKC,
+ # NFKD in Python is useless, because darwin will normalize it later and so
+ # open(), os.stat(), etc. don't raise any exception.
+ @unittest.skipIf(sys.platform == 'darwin', 'irrevelant test on Mac OS X')
+ def test_normalize(self):
+ files = set(self.files)
+ others = set()
+ for nf in set(['NFC', 'NFD', 'NFKC', 'NFKD']):
+ others |= set(normalize(nf, file) for file in files)
+ others -= files
+ for name in others:
+ self._apply_failure(open, name, IOError)
+ self._apply_failure(os.stat, name, OSError)
+ self._apply_failure(os.chdir, name, OSError)
+ self._apply_failure(os.rmdir, name, OSError)
+ self._apply_failure(os.remove, name, OSError)
+ # listdir may append a wildcard to the filename, so dont check
+ self._apply_failure(os.listdir, name, OSError, False)
+
+ # Skip the test on darwin, because darwin uses a normalization different
+ # than Python NFD normalization: filenames are different even if we use
+ # Python NFD normalization.
+ @unittest.skipIf(sys.platform == 'darwin', 'irrevelant test on Mac OS X')
def test_listdir(self):
- f1 = os.listdir(support.TESTFN)
- f2 = os.listdir(str(support.TESTFN.encode("utf-8"),
- sys.getfilesystemencoding()))
- sf2 = set("\\".join((str(support.TESTFN), f))
- for f in f2)
- self.assertEqual(len(f1), len(self.files))
- self.assertEqual(sf2, set(self.files))
+ sf0 = set(self.files)
+ f1 = os.listdir(support.TESTFN.encode(sys.getfilesystemencoding()))
+ f2 = os.listdir(support.TESTFN)
+ sf2 = set(os.path.join(support.TESTFN, f) for f in f2)
+ self.assertEqual(sf0, sf2, "%a != %a" % (sf0, sf2))
+ self.assertEqual(len(f1), len(f2))
def test_rename(self):
for name in self.files:
- os.rename(name,"tmp")
- os.rename("tmp",name)
+ os.rename(name, "tmp")
+ os.rename("tmp", name)
def test_directory(self):
- dirname = os.path.join(support.TESTFN,'Gr\xfc\xdf-\u66e8\u66e9\u66eb')
+ dirname = os.path.join(support.TESTFN, 'Gr\xfc\xdf-\u66e8\u66e9\u66eb')
filename = '\xdf-\u66e8\u66e9\u66eb'
oldwd = os.getcwd()
os.mkdir(dirname)
os.chdir(dirname)
- f = open(filename, 'wb')
- f.write((filename + '\n').encode("utf-8"))
- f.close()
- os.access(filename,os.R_OK)
- os.remove(filename)
- os.chdir(oldwd)
- os.rmdir(dirname)
+ try:
+ with open(filename, 'wb') as f:
+ f.write((filename + '\n').encode("utf-8"))
+ os.access(filename,os.R_OK)
+ os.remove(filename)
+ finally:
+ os.chdir(oldwd)
+ os.rmdir(dirname)
+
+
+class UnicodeNFCFileTests(UnicodeFileTests):
+ normal_form = 'NFC'
+
+
+class UnicodeNFDFileTests(UnicodeFileTests):
+ normal_form = 'NFD'
+
+
+class UnicodeNFKCFileTests(UnicodeFileTests):
+ normal_form = 'NFKC'
+
+
+class UnicodeNFKDFileTests(UnicodeFileTests):
+ normal_form = 'NFKD'
+
def test_main():
try:
- support.run_unittest(UnicodeFileTests)
+ support.run_unittest(
+ UnicodeFileTests,
+ UnicodeNFCFileTests,
+ UnicodeNFDFileTests,
+ UnicodeNFKCFileTests,
+ UnicodeNFKDFileTests,
+ )
finally:
deltree(support.TESTFN)
+
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_pep292.py b/Lib/test/test_pep292.py
index ce9b66363b..119c7ea8a1 100644
--- a/Lib/test/test_pep292.py
+++ b/Lib/test/test_pep292.py
@@ -42,6 +42,19 @@ class TestTemplate(unittest.TestCase):
s = Template('$who likes $$')
eq(s.substitute(dict(who='tim', what='ham')), 'tim likes $')
+ def test_invalid(self):
+ class MyPattern(Template):
+ pattern = r"""
+ (?:
+ (?P<invalid>) |
+ (?P<escaped>%(delim)s) |
+ @(?P<named>%(id)s) |
+ @{(?P<braced>%(id)s)}
+ )
+ """
+ s = MyPattern('$')
+ self.assertRaises(ValueError, s.substitute, dict())
+
def test_percents(self):
eq = self.assertEqual
s = Template('%(foo)s $foo ${foo}')
@@ -86,13 +99,6 @@ class TestTemplate(unittest.TestCase):
s = Template('$who likes $100')
raises(ValueError, s.substitute, dict(who='tim'))
- def test_delimiter_override(self):
- class PieDelims(Template):
- delimiter = '@'
- s = PieDelims('@who likes to eat a bag of @{what} worth $100')
- self.assertEqual(s.substitute(dict(who='tim', what='ham')),
- 'tim likes to eat a bag of ham worth $100')
-
def test_idpattern_override(self):
class PathPattern(Template):
idpattern = r'[_a-z][._a-z0-9]*'
@@ -132,6 +138,40 @@ class TestTemplate(unittest.TestCase):
self.assertRaises(ValueError, s.substitute, {})
self.assertRaises(ValueError, s.safe_substitute, {})
+ def test_braced_override(self):
+ class MyTemplate(Template):
+ pattern = r"""
+ \$(?:
+ (?P<escaped>$) |
+ (?P<named>[_a-z][_a-z0-9]*) |
+ @@(?P<braced>[_a-z][_a-z0-9]*)@@ |
+ (?P<invalid>) |
+ )
+ """
+
+ tmpl = 'PyCon in $@@location@@'
+ t = MyTemplate(tmpl)
+ self.assertRaises(KeyError, t.substitute, {})
+ val = t.substitute({'location': 'Cleveland'})
+ self.assertEqual(val, 'PyCon in Cleveland')
+
+ def test_braced_override_safe(self):
+ class MyTemplate(Template):
+ pattern = r"""
+ \$(?:
+ (?P<escaped>$) |
+ (?P<named>[_a-z][_a-z0-9]*) |
+ @@(?P<braced>[_a-z][_a-z0-9]*)@@ |
+ (?P<invalid>) |
+ )
+ """
+
+ tmpl = 'PyCon in $@@location@@'
+ t = MyTemplate(tmpl)
+ self.assertEqual(t.safe_substitute(), tmpl)
+ val = t.safe_substitute({'location': 'Cleveland'})
+ self.assertEqual(val, 'PyCon in Cleveland')
+
def test_unicode_values(self):
s = Template('$who likes $what')
d = dict(who='t\xffm', what='f\xfe\fed')
@@ -183,6 +223,12 @@ class TestTemplate(unittest.TestCase):
raises(ValueError, s.substitute, dict(gift='bud', who='you'))
eq(s.safe_substitute(), 'this &gift is for &{who} &')
+ class PieDelims(Template):
+ delimiter = '@'
+ s = PieDelims('@who likes to eat a bag of @{what} worth $100')
+ self.assertEqual(s.substitute(dict(who='tim', what='ham')),
+ 'tim likes to eat a bag of ham worth $100')
+
def test_main():
from test import support
diff --git a/Lib/test/test_pep3120.py b/Lib/test/test_pep3120.py
index 85da048a7d..09fedf0d54 100644
--- a/Lib/test/test_pep3120.py
+++ b/Lib/test/test_pep3120.py
@@ -19,7 +19,8 @@ class PEP3120Test(unittest.TestCase):
try:
import test.badsyntax_pep3120
except SyntaxError as msg:
- self.assertTrue(str(msg).find("Non-UTF-8 code starting with") >= 0)
+ msg = str(msg)
+ self.assertTrue('UTF-8' in msg or 'utf8' in msg)
else:
self.fail("expected exception didn't occur")
diff --git a/Lib/test/test_pep3131.py b/Lib/test/test_pep3131.py
index 3d09ad1f5a..9d5f217165 100644
--- a/Lib/test/test_pep3131.py
+++ b/Lib/test/test_pep3131.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import unittest
from test import support
diff --git a/Lib/test/test_pep352.py b/Lib/test/test_pep352.py
index b9645d5cf9..558cdb56d2 100644
--- a/Lib/test/test_pep352.py
+++ b/Lib/test/test_pep352.py
@@ -38,8 +38,8 @@ class ExceptionClassTests(unittest.TestCase):
last_exc = getattr(builtins, superclass_name)
except AttributeError:
self.fail("base class %s not a built-in" % superclass_name)
- self.assertTrue(superclass_name in exc_set,
- '%s not found' % superclass_name)
+ self.assertIn(superclass_name, exc_set,
+ '%s not found' % superclass_name)
exc_set.discard(superclass_name)
superclasses = [] # Loop will insert base exception
last_depth = 0
@@ -73,7 +73,7 @@ class ExceptionClassTests(unittest.TestCase):
self.verify_instance_interface(exc())
except TypeError:
pass
- self.assertTrue(exc_name in exc_set)
+ self.assertIn(exc_name, exc_set)
exc_set.discard(exc_name)
last_exc = exc
last_depth = depth
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index bb681bfb14..a3878fd62a 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -31,12 +31,24 @@ class PyPicklerTests(AbstractPickleTests):
f.seek(0)
return bytes(f.read())
- def loads(self, buf):
+ def loads(self, buf, **kwds):
f = io.BytesIO(buf)
- u = self.unpickler(f)
+ u = self.unpickler(f, **kwds)
return u.load()
+class InMemoryPickleTests(AbstractPickleTests):
+
+ pickler = pickle._Pickler
+ unpickler = pickle._Unpickler
+
+ def dumps(self, arg, proto=None):
+ return pickle.dumps(arg, proto)
+
+ def loads(self, buf, **kwds):
+ return pickle.loads(buf, **kwds)
+
+
class PyPersPicklerTests(AbstractPersistentPicklerTests):
pickler = pickle._Pickler
@@ -52,12 +64,12 @@ class PyPersPicklerTests(AbstractPersistentPicklerTests):
f.seek(0)
return f.read()
- def loads(self, buf):
+ def loads(self, buf, **kwds):
class PersUnpickler(self.unpickler):
def persistent_load(subself, obj):
return self.persistent_load(obj)
f = io.BytesIO(buf)
- u = PersUnpickler(f)
+ u = PersUnpickler(f, **kwds)
return u.load()
@@ -95,7 +107,8 @@ def test_main():
tests.extend([CPicklerTests, CPersPicklerTests,
CDumpPickle_LoadPickle, DumpPickle_CLoadPickle,
PyPicklerUnpicklerObjectTests,
- CPicklerUnpicklerObjectTests])
+ CPicklerUnpicklerObjectTests,
+ InMemoryPickleTests])
support.run_unittest(*tests)
support.run_doctest(pickle)
diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py
index 823b0c2621..d37ac263c4 100644
--- a/Lib/test/test_pickletools.py
+++ b/Lib/test/test_pickletools.py
@@ -9,8 +9,8 @@ class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
def dumps(self, arg, proto=None):
return pickletools.optimize(pickle.dumps(arg, proto))
- def loads(self, buf):
- return pickle.loads(buf)
+ def loads(self, buf, **kwds):
+ return pickle.loads(buf, **kwds)
# Test relies on precise output of dumps()
test_pickle_to_2x = None
diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py
index b816a3b81b..f2b58d5e3d 100644
--- a/Lib/test/test_pipes.py
+++ b/Lib/test/test_pipes.py
@@ -2,7 +2,7 @@ import pipes
import os
import string
import unittest
-from test.support import TESTFN, run_unittest, unlink
+from test.support import TESTFN, run_unittest, unlink, reap_children
if os.name != 'posix':
raise unittest.SkipTest('pipes module only works on posix')
@@ -40,7 +40,11 @@ class SimplePipeTests(unittest.TestCase):
f.write('hello world #2')
t = pipes.Template()
t.append(s_command + ' < $IN', pipes.FILEIN_STDOUT)
- self.assertEqual(t.open(TESTFN, 'r').read(), 'HELLO WORLD #2')
+ f = t.open(TESTFN, 'r')
+ try:
+ self.assertEqual(f.read(), 'HELLO WORLD #2')
+ finally:
+ f.close()
def testEmptyPipeline1(self):
# copy through empty pipe
@@ -60,7 +64,11 @@ class SimplePipeTests(unittest.TestCase):
with open(TESTFN, 'w') as f:
f.write(d)
t=pipes.Template()
- self.assertEqual(t.open(TESTFN, 'r').read(), d)
+ f = t.open(TESTFN, 'r')
+ try:
+ self.assertEqual(f.read(), d)
+ finally:
+ f.close()
def testEmptyPipeline3(self):
# write through empty pipe
@@ -196,6 +204,7 @@ class SimplePipeTests(unittest.TestCase):
def test_main():
run_unittest(SimplePipeTests)
+ reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py
index 4b48c04307..a4ddb15875 100644
--- a/Lib/test/test_pkg.py
+++ b/Lib/test/test_pkg.py
@@ -53,7 +53,8 @@ class TestPkg(unittest.TestCase):
def tearDown(self):
sys.path[:] = self.syspath
support.modules_cleanup(*self.modules_before)
- cleanout(self.root)
+ if self.root: # Only clean if the test was actually run
+ cleanout(self.root)
# delete all modules concerning the tested hierarchy
if self.pkgname:
@@ -103,9 +104,6 @@ class TestPkg(unittest.TestCase):
]
self.mkhier(hier)
- import t2
- self.assertEqual(t2.__doc__, "doc for t2")
-
import t2.sub
import t2.sub.subsub
self.assertEqual(t2.__name__, "t2")
@@ -198,14 +196,14 @@ class TestPkg(unittest.TestCase):
import t5
self.assertEqual(fixdir(dir(t5)),
- ['__doc__', '__file__', '__name__',
+ ['__cached__', '__doc__', '__file__', '__name__',
'__package__', '__path__', 'foo', 'string', 't5'])
self.assertEqual(fixdir(dir(t5.foo)),
- ['__doc__', '__file__', '__name__', '__package__',
- 'string'])
+ ['__cached__', '__doc__', '__file__', '__name__',
+ '__package__', 'string'])
self.assertEqual(fixdir(dir(t5.string)),
- ['__doc__', '__file__', '__name__','__package__',
- 'spam'])
+ ['__cached__', '__doc__', '__file__', '__name__',
+ '__package__', 'spam'])
def test_6(self):
hier = [
@@ -220,13 +218,13 @@ class TestPkg(unittest.TestCase):
import t6
self.assertEqual(fixdir(dir(t6)),
- ['__all__', '__doc__', '__file__',
+ ['__all__', '__cached__', '__doc__', '__file__',
'__name__', '__package__', '__path__'])
s = """
import t6
from t6 import *
self.assertEqual(fixdir(dir(t6)),
- ['__all__', '__doc__', '__file__',
+ ['__all__', '__cached__', '__doc__', '__file__',
'__name__', '__package__', '__path__',
'eggs', 'ham', 'spam'])
self.assertEqual(dir(), ['eggs', 'ham', 'self', 'spam', 't6'])
@@ -254,18 +252,18 @@ class TestPkg(unittest.TestCase):
t7, sub, subsub = None, None, None
import t7 as tas
self.assertEqual(fixdir(dir(tas)),
- ['__doc__', '__file__', '__name__',
+ ['__cached__', '__doc__', '__file__', '__name__',
'__package__', '__path__'])
self.assertFalse(t7)
from t7 import sub as subpar
self.assertEqual(fixdir(dir(subpar)),
- ['__doc__', '__file__', '__name__',
+ ['__cached__', '__doc__', '__file__', '__name__',
'__package__', '__path__'])
self.assertFalse(t7)
self.assertFalse(sub)
from t7.sub import subsub as subsubsub
self.assertEqual(fixdir(dir(subsubsub)),
- ['__doc__', '__file__', '__name__',
+ ['__cached__', '__doc__', '__file__', '__name__',
'__package__', '__path__', 'spam'])
self.assertFalse(t7)
self.assertFalse(sub)
@@ -276,6 +274,17 @@ class TestPkg(unittest.TestCase):
self.assertFalse(sub)
self.assertFalse(subsub)
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_8(self):
+ hier = [
+ ("t8", None),
+ ("t8 __init__"+os.extsep+"py", "'doc for t8'"),
+ ]
+ self.mkhier(hier)
+
+ import t8
+ self.assertEqual(t8.__doc__, "doc for t8")
def test_main():
support.run_unittest(__name__)
diff --git a/Lib/test/test_pkgimport.py b/Lib/test/test_pkgimport.py
index 803aa2b695..c37e9362b0 100644
--- a/Lib/test/test_pkgimport.py
+++ b/Lib/test/test_pkgimport.py
@@ -1,5 +1,12 @@
-import os, sys, string, random, tempfile, unittest
-
+import os
+import sys
+import shutil
+import string
+import random
+import tempfile
+import unittest
+
+from imp import cache_from_source
from test.support import run_unittest
class TestImport(unittest.TestCase):
@@ -26,22 +33,17 @@ class TestImport(unittest.TestCase):
self.module_path = os.path.join(self.package_dir, 'foo.py')
def tearDown(self):
- for file in os.listdir(self.package_dir):
- os.remove(os.path.join(self.package_dir, file))
- os.rmdir(self.package_dir)
- os.rmdir(self.test_dir)
+ shutil.rmtree(self.test_dir)
self.assertNotEqual(sys.path.count(self.test_dir), 0)
sys.path.remove(self.test_dir)
self.remove_modules()
def rewrite_file(self, contents):
- for extension in "co":
- compiled_path = self.module_path + extension
- if os.path.exists(compiled_path):
- os.remove(compiled_path)
- f = open(self.module_path, 'w')
- f.write(contents)
- f.close()
+ compiled_path = cache_from_source(self.module_path)
+ if os.path.exists(compiled_path):
+ os.remove(compiled_path)
+ with open(self.module_path, 'w') as f:
+ f.write(contents)
def test_package_import__semantics(self):
@@ -51,9 +53,9 @@ class TestImport(unittest.TestCase):
self.rewrite_file('for')
try: __import__(self.module_name)
except SyntaxError: pass
- else: raise RuntimeError('Failed to induce SyntaxError')
- self.assertTrue(self.module_name not in sys.modules and
- not hasattr(sys.modules[self.package_name], 'foo'))
+ else: raise RuntimeError('Failed to induce SyntaxError') # self.fail()?
+ self.assertNotIn(self.module_name, sys.modules)
+ self.assertFalse(hasattr(sys.modules[self.package_name], 'foo'))
# ...make up a variable name that isn't bound in __builtins__
var = 'a'
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 2f688a4f18..ec134a17e0 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -10,20 +10,26 @@ class PlatformTest(unittest.TestCase):
def test_architecture(self):
res = platform.architecture()
- if hasattr(os, "symlink"):
- def test_architecture_via_symlink(self): # issue3762
- def get(python):
- cmd = [python, '-c',
- 'import platform; print(platform.architecture())']
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- return p.communicate()
- real = os.path.realpath(sys.executable)
- link = os.path.abspath(support.TESTFN)
- os.symlink(real, link)
- try:
- self.assertEqual(get(real), get(link))
- finally:
- os.remove(link)
+ @support.skip_unless_symlink
+ def test_architecture_via_symlink(self): # issue3762
+ # On Windows, the EXE needs to know where pythonXY.dll is at so we have
+ # to add the directory to the path.
+ if sys.platform == "win32":
+ os.environ["Path"] = "{};{}".format(
+ os.path.dirname(sys.executable), os.environ["Path"])
+
+ def get(python):
+ cmd = [python, '-c',
+ 'import platform; print(platform.architecture())']
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ return p.communicate()
+ real = os.path.realpath(sys.executable)
+ link = os.path.abspath(support.TESTFN)
+ os.symlink(real, link)
+ try:
+ self.assertEqual(get(real), get(link))
+ finally:
+ os.remove(link)
def test_platform(self):
for aliased in (False, True):
@@ -131,6 +137,27 @@ class PlatformTest(unittest.TestCase):
res = platform.uname()
self.assertTrue(any(res))
+ @unittest.skipUnless(sys.platform.startswith('win'), "windows only test")
+ def test_uname_win32_ARCHITEW6432(self):
+ # Issue 7860: make sure we get architecture from the correct variable
+ # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
+ # using it, per
+ # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
+ try:
+ with support.EnvironmentVarGuard() as environ:
+ if 'PROCESSOR_ARCHITEW6432' in environ:
+ del environ['PROCESSOR_ARCHITEW6432']
+ environ['PROCESSOR_ARCHITECTURE'] = 'foo'
+ platform._uname_cache = None
+ system, node, release, version, machine, processor = platform.uname()
+ self.assertEqual(machine, 'foo')
+ environ['PROCESSOR_ARCHITEW6432'] = 'bar'
+ platform._uname_cache = None
+ system, node, release, version, machine, processor = platform.uname()
+ self.assertEqual(machine, 'bar')
+ finally:
+ platform._uname_cache = None
+
def test_java_ver(self):
res = platform.java_ver()
if sys.platform == 'java':
@@ -198,8 +225,10 @@ class PlatformTest(unittest.TestCase):
if os.path.isdir(sys.executable) and \
os.path.exists(sys.executable+'.exe'):
# Cygwin horror
- executable = executable + '.exe'
- res = platform.libc_ver(sys.executable)
+ executable = sys.executable + '.exe'
+ else:
+ executable = sys.executable
+ res = platform.libc_ver(executable)
def test_parse_release_file(self):
diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py
index b9a46b74a0..dfa4725c32 100644
--- a/Lib/test/test_plistlib.py
+++ b/Lib/test/test_plistlib.py
@@ -9,7 +9,7 @@ from test import support
# This test data was generated through Cocoa's NSDictionary class
TESTDATA = b"""<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py
index 24fb846bef..accf187b54 100644
--- a/Lib/test/test_popen.py
+++ b/Lib/test/test_popen.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Basic tests for os.popen()
Particularly useful for platforms that fake popen.
@@ -22,7 +22,8 @@ class PopenTest(unittest.TestCase):
def _do_test_commandline(self, cmdline, expected):
cmd = '%s -c "import sys; print(sys.argv)" %s'
cmd = cmd % (python, cmdline)
- data = os.popen(cmd).read()
+ with os.popen(cmd) as p:
+ data = p.read()
got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected)
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py
index 5659b78628..81af56989f 100644
--- a/Lib/test/test_poplib.py
+++ b/Lib/test/test_poplib.py
@@ -4,7 +4,6 @@
# a real test suite
import poplib
-import threading
import asyncore
import asynchat
import socket
@@ -14,6 +13,7 @@ import errno
from unittest import TestCase
from test import support as test_support
+threading = test_support.import_module('threading')
HOST = test_support.HOST
PORT = 0
@@ -122,6 +122,7 @@ class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
self.active = False
self.active_lock = threading.Lock()
self.host, self.port = self.socket.getsockname()[:2]
+ self.handler_instance = None
def start(self):
assert not self.active
@@ -143,10 +144,8 @@ class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
self.active = False
self.join()
- def handle_accept(self):
- conn, addr = self.accept()
- self.handler = self.handler(conn)
- self.close()
+ def handle_accepted(self, conn, addr):
+ self.handler_instance = self.handler(conn)
def handle_connect(self):
self.close()
@@ -285,7 +284,24 @@ if hasattr(poplib, 'POP3_SSL'):
self.client = poplib.POP3_SSL(self.server.host, self.server.port)
def test__all__(self):
- self.assertTrue('POP3_SSL' in poplib.__all__)
+ self.assertIn('POP3_SSL', poplib.__all__)
+
+ def test_context(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
+ self.server.port, keyfile=CERTFILE, context=ctx)
+ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
+ self.server.port, certfile=CERTFILE, context=ctx)
+ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
+ self.server.port, keyfile=CERTFILE,
+ certfile=CERTFILE, context=ctx)
+
+ self.client.quit()
+ self.client = poplib.POP3_SSL(self.server.host, self.server.port,
+ context=ctx)
+ self.assertIsInstance(self.client.sock, ssl.SSLSocket)
+ self.assertIs(self.client.sock.context, ctx)
+ self.assertTrue(self.client.noop().startswith(b'+OK'))
class TestTimeouts(TestCase):
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 51cc23ce05..45b3afc72d 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -5,16 +5,16 @@ from test import support
# Skip these tests if there is no posix module.
posix = support.import_module('posix')
+import errno
import sys
import time
import os
import pwd
import shutil
+import stat
import unittest
import warnings
-warnings.filterwarnings('ignore', '.* potential security risk .*',
- RuntimeWarning)
class PosixTester(unittest.TestCase):
@@ -22,9 +22,14 @@ class PosixTester(unittest.TestCase):
# create empty file
fp = open(support.TESTFN, 'w+')
fp.close()
+ self._warnings_manager = support.check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings('ignore', '.* potential security risk .*',
+ RuntimeWarning)
def tearDown(self):
support.unlink(support.TESTFN)
+ self._warnings_manager.__exit__(None, None, None)
def testNoArgFunctions(self):
# test posix functions which take no arguments and have
@@ -41,6 +46,69 @@ class PosixTester(unittest.TestCase):
posix_func()
self.assertRaises(TypeError, posix_func, 1)
+ if hasattr(posix, 'getresuid'):
+ def test_getresuid(self):
+ user_ids = posix.getresuid()
+ self.assertEqual(len(user_ids), 3)
+ for val in user_ids:
+ self.assertGreaterEqual(val, 0)
+
+ if hasattr(posix, 'getresgid'):
+ def test_getresgid(self):
+ group_ids = posix.getresgid()
+ self.assertEqual(len(group_ids), 3)
+ for val in group_ids:
+ self.assertGreaterEqual(val, 0)
+
+ if hasattr(posix, 'setresuid'):
+ def test_setresuid(self):
+ current_user_ids = posix.getresuid()
+ self.assertIsNone(posix.setresuid(*current_user_ids))
+ # -1 means don't change that value.
+ self.assertIsNone(posix.setresuid(-1, -1, -1))
+
+ def test_setresuid_exception(self):
+ # Don't do this test if someone is silly enough to run us as root.
+ current_user_ids = posix.getresuid()
+ if 0 not in current_user_ids:
+ new_user_ids = (current_user_ids[0]+1, -1, -1)
+ self.assertRaises(OSError, posix.setresuid, *new_user_ids)
+
+ if hasattr(posix, 'setresgid'):
+ def test_setresgid(self):
+ current_group_ids = posix.getresgid()
+ self.assertIsNone(posix.setresgid(*current_group_ids))
+ # -1 means don't change that value.
+ self.assertIsNone(posix.setresgid(-1, -1, -1))
+
+ def test_setresgid_exception(self):
+ # Don't do this test if someone is silly enough to run us as root.
+ current_group_ids = posix.getresgid()
+ if 0 not in current_group_ids:
+ new_group_ids = (current_group_ids[0]+1, -1, -1)
+ self.assertRaises(OSError, posix.setresgid, *new_group_ids)
+
+ @unittest.skipUnless(hasattr(posix, 'initgroups'),
+ "test needs os.initgroups()")
+ def test_initgroups(self):
+ # It takes a string and an integer; check that it raises a TypeError
+ # for other argument lists.
+ self.assertRaises(TypeError, posix.initgroups)
+ self.assertRaises(TypeError, posix.initgroups, None)
+ self.assertRaises(TypeError, posix.initgroups, 3, "foo")
+ self.assertRaises(TypeError, posix.initgroups, "foo", 3, object())
+
+ # If a non-privileged user invokes it, it should fail with OSError
+ # EPERM.
+ if os.getuid() != 0:
+ name = pwd.getpwuid(posix.getuid()).pw_name
+ try:
+ posix.initgroups(name, 13)
+ except OSError as e:
+ self.assertEqual(e.errno, errno.EPERM)
+ else:
+ self.fail("Expected OSError to be raised by initgroups")
+
def test_statvfs(self):
if hasattr(posix, 'statvfs'):
self.assertTrue(posix.statvfs(os.curdir))
@@ -69,7 +137,7 @@ class PosixTester(unittest.TestCase):
fp = open(support.TESTFN)
try:
fd = posix.dup(fp.fileno())
- self.assertTrue(isinstance(fd, int))
+ self.assertIsInstance(fd, int)
os.close(fd)
finally:
fp.close()
@@ -132,6 +200,28 @@ class PosixTester(unittest.TestCase):
if hasattr(posix, 'stat'):
self.assertTrue(posix.stat(support.TESTFN))
+ @unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()")
+ def test_mkfifo(self):
+ support.unlink(support.TESTFN)
+ posix.mkfifo(support.TESTFN, stat.S_IRUSR | stat.S_IWUSR)
+ self.assertTrue(stat.S_ISFIFO(posix.stat(support.TESTFN).st_mode))
+
+ @unittest.skipUnless(hasattr(posix, 'mknod') and hasattr(stat, 'S_IFIFO'),
+ "don't have mknod()/S_IFIFO")
+ def test_mknod(self):
+ # Test using mknod() to create a FIFO (the only use specified
+ # by POSIX).
+ support.unlink(support.TESTFN)
+ mode = stat.S_IFIFO | stat.S_IRUSR | stat.S_IWUSR
+ try:
+ posix.mknod(support.TESTFN, mode, 0)
+ except OSError as e:
+ # Some old systems don't allow unprivileged users to use
+ # mknod(), or only support creating device nodes.
+ self.assertIn(e.errno, (errno.EPERM, errno.EINVAL))
+ else:
+ self.assertTrue(stat.S_ISFIFO(posix.stat(support.TESTFN).st_mode))
+
def _test_all_chown_common(self, chown_func, first_param):
"""Common code for chown, fchown and lchown tests."""
if os.getuid() == 0:
@@ -186,9 +276,14 @@ class PosixTester(unittest.TestCase):
posix.chdir(os.curdir)
self.assertRaises(OSError, posix.chdir, support.TESTFN)
- def test_lsdir(self):
- if hasattr(posix, 'lsdir'):
- self.assertTrue(support.TESTFN in posix.lsdir(os.curdir))
+ def test_listdir(self):
+ if hasattr(posix, 'listdir'):
+ self.assertTrue(support.TESTFN in posix.listdir(os.curdir))
+
+ def test_listdir_default(self):
+ # When listdir is called without argument, it's the same as listdir(os.curdir)
+ if hasattr(posix, 'listdir'):
+ self.assertTrue(support.TESTFN in posix.listdir())
def test_access(self):
if hasattr(posix, 'access'):
@@ -197,7 +292,7 @@ class PosixTester(unittest.TestCase):
def test_umask(self):
if hasattr(posix, 'umask'):
old_mask = posix.umask(0)
- self.assertTrue(isinstance(old_mask, int))
+ self.assertIsInstance(old_mask, int)
posix.umask(old_mask)
def test_strerror(self):
@@ -233,9 +328,13 @@ class PosixTester(unittest.TestCase):
posix.lchflags(support.TESTFN, st.st_flags)
def test_environ(self):
+ if os.name == "nt":
+ item_type = str
+ else:
+ item_type = bytes
for k, v in posix.environ.items():
- self.assertEqual(type(k), str)
- self.assertEqual(type(v), str)
+ self.assertEqual(type(k), item_type)
+ self.assertEqual(type(v), item_type)
def test_getcwd_long_pathnames(self):
if hasattr(posix, 'getcwd'):
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 14146db4b2..bb4559c4ab 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -1,14 +1,31 @@
import unittest
-from test import support
+from test import support, test_genericpath
-import posixpath, os
-from posixpath import realpath, abspath, join, dirname, basename, relpath
+import posixpath
+import os
+import sys
+from posixpath import realpath, abspath, dirname, basename
+
+try:
+ import posix
+except ImportError:
+ posix = None
# An absolute path to a temporary filename for testing. We can't rely on TESTFN
# being an absolute path, so we need this.
ABSTFN = abspath(support.TESTFN)
+def skip_if_ABSTFN_contains_backslash(test):
+ """
+ On Windows, posixpath.abspath still returns paths with backslashes
+ instead of posix forward slashes. If this is the case, several tests
+ fail, so skip them.
+ """
+ found_backslash = '\\' in ABSTFN
+ msg = "ABSTFN is not a posix path - tests fail"
+ return [test, unittest.skip(msg)(test)][found_backslash]
+
def safe_rmdir(dirname):
try:
os.rmdir(dirname)
@@ -25,19 +42,6 @@ class PosixPathTest(unittest.TestCase):
support.unlink(support.TESTFN + suffix)
safe_rmdir(support.TESTFN + suffix)
- def assertIs(self, a, b):
- self.assertTrue(a is b)
-
- def test_normcase(self):
- # Check that normcase() is idempotent
- p = "FoO/./BaR"
- self.assertEqual(p, posixpath.normcase(p))
-
- p = b"FoO/./BaR"
- self.assertEqual(p, posixpath.normcase(p))
-
- self.assertRaises(TypeError, posixpath.normcase)
-
def test_join(self):
self.assertEqual(posixpath.join("/foo", "bar", "/bar", "baz"),
"/bar/baz")
@@ -52,16 +56,9 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.join(b"/foo/", b"bar/", b"baz/"),
b"/foo/bar/baz/")
- self.assertRaises(TypeError, posixpath.join)
self.assertRaises(TypeError, posixpath.join, b"bytes", "str")
self.assertRaises(TypeError, posixpath.join, "str", b"bytes")
- def test_splitdrive(self):
- self.assertEqual(posixpath.splitdrive("/foo/bar"), ("", "/foo/bar"))
- self.assertEqual(posixpath.splitdrive(b"/foo/bar"), (b"", b"/foo/bar"))
-
- self.assertRaises(TypeError, posixpath.splitdrive)
-
def test_split(self):
self.assertEqual(posixpath.split("/foo/bar"), ("/foo", "bar"))
self.assertEqual(posixpath.split("/"), ("/", ""))
@@ -75,8 +72,6 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.split(b"////foo"), (b"////", b"foo"))
self.assertEqual(posixpath.split(b"//foo//bar"), (b"//foo", b"bar"))
- self.assertRaises(TypeError, posixpath.split)
-
def splitextTest(self, path, filename, ext):
self.assertEqual(posixpath.splitext(path), (filename, ext))
self.assertEqual(posixpath.splitext("/" + path), ("/" + filename, ext))
@@ -118,7 +113,6 @@ class PosixPathTest(unittest.TestCase):
self.splitextTest("..", "..", "")
self.splitextTest("........", "........", "")
self.splitextTest("", "", "")
- self.assertRaises(TypeError, posixpath.splitext)
def test_isabs(self):
self.assertIs(posixpath.isabs(""), False)
@@ -133,8 +127,6 @@ class PosixPathTest(unittest.TestCase):
self.assertIs(posixpath.isabs(b"/foo/bar"), True)
self.assertIs(posixpath.isabs(b"foo/bar"), False)
- self.assertRaises(TypeError, posixpath.isabs)
-
def test_basename(self):
self.assertEqual(posixpath.basename("/foo/bar"), "bar")
self.assertEqual(posixpath.basename("/"), "")
@@ -148,8 +140,6 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.basename(b"////foo"), b"foo")
self.assertEqual(posixpath.basename(b"//foo//bar"), b"bar")
- self.assertRaises(TypeError, posixpath.basename)
-
def test_dirname(self):
self.assertEqual(posixpath.dirname("/foo/bar"), "/foo")
self.assertEqual(posixpath.dirname("/"), "/")
@@ -163,88 +153,15 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.dirname(b"////foo"), b"////")
self.assertEqual(posixpath.dirname(b"//foo//bar"), b"//foo")
- self.assertRaises(TypeError, posixpath.dirname)
-
- def test_commonprefix(self):
- self.assertEqual(
- posixpath.commonprefix([]),
- ""
- )
- self.assertEqual(
- posixpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"]),
- "/home/swen"
- )
- self.assertEqual(
- posixpath.commonprefix(["/home/swen/spam", "/home/swen/eggs"]),
- "/home/swen/"
- )
- self.assertEqual(
- posixpath.commonprefix(["/home/swen/spam", "/home/swen/spam"]),
- "/home/swen/spam"
- )
-
- self.assertEqual(
- posixpath.commonprefix([b"/home/swenson/spam", b"/home/swen/spam"]),
- b"/home/swen"
- )
- self.assertEqual(
- posixpath.commonprefix([b"/home/swen/spam", b"/home/swen/eggs"]),
- b"/home/swen/"
- )
- self.assertEqual(
- posixpath.commonprefix([b"/home/swen/spam", b"/home/swen/spam"]),
- b"/home/swen/spam"
- )
-
- testlist = ['', 'abc', 'Xbcd', 'Xb', 'XY', 'abcd', 'aXc', 'abd', 'ab', 'aX', 'abcX']
- for s1 in testlist:
- for s2 in testlist:
- p = posixpath.commonprefix([s1, s2])
- self.assertTrue(s1.startswith(p))
- self.assertTrue(s2.startswith(p))
- if s1 != s2:
- n = len(p)
- self.assertNotEqual(s1[n:n+1], s2[n:n+1])
-
- def test_getsize(self):
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertEqual(posixpath.getsize(support.TESTFN), 3)
- finally:
- if not f.closed:
- f.close()
-
- def test_time(self):
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- f = open(support.TESTFN, "ab")
- f.write(b"bar")
- f.close()
- f = open(support.TESTFN, "rb")
- d = f.read()
- f.close()
- self.assertEqual(d, b"foobar")
-
- self.assertLessEqual(
- posixpath.getctime(support.TESTFN),
- posixpath.getmtime(support.TESTFN)
- )
- finally:
- if not f.closed:
- f.close()
-
def test_islink(self):
self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
+ self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
f = open(support.TESTFN + "1", "wb")
try:
f.write(b"foo")
f.close()
self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
- if hasattr(os, "symlink"):
+ if support.can_symlink():
os.symlink(support.TESTFN + "1", support.TESTFN + "2")
self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
os.remove(support.TESTFN + "1")
@@ -255,144 +172,103 @@ class PosixPathTest(unittest.TestCase):
if not f.close():
f.close()
- self.assertRaises(TypeError, posixpath.islink)
+ @staticmethod
+ def _create_file(filename):
+ with open(filename, 'wb') as f:
+ f.write(b'foo')
- def test_exists(self):
- self.assertIs(posixpath.exists(support.TESTFN), False)
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertIs(posixpath.exists(support.TESTFN), True)
- self.assertIs(posixpath.lexists(support.TESTFN), True)
- finally:
- if not f.close():
- f.close()
+ def test_samefile(self):
+ test_fn = support.TESTFN + "1"
+ self._create_file(test_fn)
+ self.assertTrue(posixpath.samefile(test_fn, test_fn))
+ self.assertRaises(TypeError, posixpath.samefile)
- self.assertRaises(TypeError, posixpath.exists)
+ @unittest.skipIf(
+ sys.platform.startswith('win'),
+ "posixpath.samefile does not work on links in Windows")
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ def test_samefile_on_links(self):
+ test_fn1 = support.TESTFN + "1"
+ test_fn2 = support.TESTFN + "2"
+ self._create_file(test_fn1)
- def test_isdir(self):
- self.assertIs(posixpath.isdir(support.TESTFN), False)
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertIs(posixpath.isdir(support.TESTFN), False)
- os.remove(support.TESTFN)
- os.mkdir(support.TESTFN)
- self.assertIs(posixpath.isdir(support.TESTFN), True)
- os.rmdir(support.TESTFN)
- finally:
- if not f.close():
- f.close()
-
- self.assertRaises(TypeError, posixpath.isdir)
+ os.symlink(test_fn1, test_fn2)
+ self.assertTrue(posixpath.samefile(test_fn1, test_fn2))
+ os.remove(test_fn2)
- def test_isfile(self):
- self.assertIs(posixpath.isfile(support.TESTFN), False)
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertIs(posixpath.isfile(support.TESTFN), True)
- os.remove(support.TESTFN)
- os.mkdir(support.TESTFN)
- self.assertIs(posixpath.isfile(support.TESTFN), False)
- os.rmdir(support.TESTFN)
- finally:
- if not f.close():
- f.close()
+ self._create_file(test_fn2)
+ self.assertFalse(posixpath.samefile(test_fn1, test_fn2))
- self.assertRaises(TypeError, posixpath.isdir)
-
- def test_samefile(self):
- f = open(support.TESTFN + "1", "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertIs(
- posixpath.samefile(
- support.TESTFN + "1",
- support.TESTFN + "1"
- ),
- True
- )
- # If we don't have links, assume that os.stat doesn't return resonable
- # inode information and thus, that samefile() doesn't work
- if hasattr(os, "symlink"):
- os.symlink(
- support.TESTFN + "1",
- support.TESTFN + "2"
- )
- self.assertIs(
- posixpath.samefile(
- support.TESTFN + "1",
- support.TESTFN + "2"
- ),
- True
- )
- os.remove(support.TESTFN + "2")
- f = open(support.TESTFN + "2", "wb")
- f.write(b"bar")
- f.close()
- self.assertIs(
- posixpath.samefile(
- support.TESTFN + "1",
- support.TESTFN + "2"
- ),
- False
- )
- finally:
- if not f.close():
- f.close()
-
- self.assertRaises(TypeError, posixpath.samefile)
def test_samestat(self):
- f = open(support.TESTFN + "1", "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertIs(
- posixpath.samestat(
- os.stat(support.TESTFN + "1"),
- os.stat(support.TESTFN + "1")
- ),
- True
- )
- # If we don't have links, assume that os.stat() doesn't return resonable
- # inode information and thus, that samefile() doesn't work
- if hasattr(os, "symlink"):
- if hasattr(os, "symlink"):
- os.symlink(support.TESTFN + "1", support.TESTFN + "2")
- self.assertIs(
- posixpath.samestat(
- os.stat(support.TESTFN + "1"),
- os.stat(support.TESTFN + "2")
- ),
- True
- )
- os.remove(support.TESTFN + "2")
- f = open(support.TESTFN + "2", "wb")
- f.write(b"bar")
- f.close()
- self.assertIs(
- posixpath.samestat(
- os.stat(support.TESTFN + "1"),
- os.stat(support.TESTFN + "2")
- ),
- False
- )
- finally:
- if not f.close():
- f.close()
+ test_fn = support.TESTFN + "1"
+ self._create_file(test_fn)
+ test_fns = [test_fn]*2
+ stats = map(os.stat, test_fns)
+ self.assertTrue(posixpath.samestat(*stats))
+
+ @unittest.skipIf(
+ sys.platform.startswith('win'),
+ "posixpath.samestat does not work on links in Windows")
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ def test_samestat_on_links(self):
+ test_fn1 = support.TESTFN + "1"
+ test_fn2 = support.TESTFN + "2"
+ self._create_file(test_fn1)
+ test_fns = (test_fn1, test_fn2)
+ os.symlink(*test_fns)
+ stats = map(os.stat, test_fns)
+ self.assertTrue(posixpath.samestat(*stats))
+ os.remove(test_fn2)
+
+ self._create_file(test_fn2)
+ stats = map(os.stat, test_fns)
+ self.assertFalse(posixpath.samestat(*stats))
self.assertRaises(TypeError, posixpath.samestat)
def test_ismount(self):
self.assertIs(posixpath.ismount("/"), True)
+ self.assertIs(posixpath.ismount(b"/"), True)
- self.assertRaises(TypeError, posixpath.ismount)
+ def test_ismount_non_existent(self):
+ # Non-existent mountpoint.
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ try:
+ os.mkdir(ABSTFN)
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ finally:
+ safe_rmdir(ABSTFN)
+
+ @unittest.skipUnless(support.can_symlink(),
+ "Test requires symlink support")
+ def test_ismount_symlinks(self):
+ # Symlinks are never mountpoints.
+ try:
+ os.symlink("/", ABSTFN)
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ finally:
+ os.unlink(ABSTFN)
+
+ @unittest.skipIf(posix is None, "Test requires posix module")
+ def test_ismount_different_device(self):
+ # Simulate the path being on a different device from its parent by
+ # mocking out st_dev.
+ save_lstat = os.lstat
+ def fake_lstat(path):
+ st_ino = 0
+ st_dev = 0
+ if path == ABSTFN:
+ st_dev = 1
+ st_ino = 1
+ return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0))
+ try:
+ os.lstat = fake_lstat
+ self.assertIs(posixpath.ismount(ABSTFN), True)
+ finally:
+ os.lstat = save_lstat
def test_expanduser(self):
self.assertEqual(posixpath.expanduser("foo"), "foo")
@@ -402,8 +278,8 @@ class PosixPathTest(unittest.TestCase):
except ImportError:
pass
else:
- self.assertTrue(isinstance(posixpath.expanduser("~/"), str))
- self.assertTrue(isinstance(posixpath.expanduser(b"~/"), bytes))
+ self.assertIsInstance(posixpath.expanduser("~/"), str)
+ self.assertIsInstance(posixpath.expanduser(b"~/"), bytes)
# if home directory == root directory, this test makes no sense
if posixpath.expanduser("~") != '/':
self.assertEqual(
@@ -414,49 +290,18 @@ class PosixPathTest(unittest.TestCase):
posixpath.expanduser(b"~") + b"/",
posixpath.expanduser(b"~/")
)
- self.assertTrue(isinstance(posixpath.expanduser("~root/"), str))
- self.assertTrue(isinstance(posixpath.expanduser("~foo/"), str))
- self.assertTrue(isinstance(posixpath.expanduser(b"~root/"), bytes))
- self.assertTrue(isinstance(posixpath.expanduser(b"~foo/"), bytes))
+ self.assertIsInstance(posixpath.expanduser("~root/"), str)
+ self.assertIsInstance(posixpath.expanduser("~foo/"), str)
+ self.assertIsInstance(posixpath.expanduser(b"~root/"), bytes)
+ self.assertIsInstance(posixpath.expanduser(b"~foo/"), bytes)
with support.EnvironmentVarGuard() as env:
env['HOME'] = '/'
self.assertEqual(posixpath.expanduser("~"), "/")
-
- self.assertRaises(TypeError, posixpath.expanduser)
-
- def test_expandvars(self):
- with support.EnvironmentVarGuard() as env:
- env.clear()
- env["foo"] = "bar"
- env["{foo"] = "baz1"
- env["{foo}"] = "baz2"
- self.assertEqual(posixpath.expandvars("foo"), "foo")
- self.assertEqual(posixpath.expandvars("$foo bar"), "bar bar")
- self.assertEqual(posixpath.expandvars("${foo}bar"), "barbar")
- self.assertEqual(posixpath.expandvars("$[foo]bar"), "$[foo]bar")
- self.assertEqual(posixpath.expandvars("$bar bar"), "$bar bar")
- self.assertEqual(posixpath.expandvars("$?bar"), "$?bar")
- self.assertEqual(posixpath.expandvars("${foo}bar"), "barbar")
- self.assertEqual(posixpath.expandvars("$foo}bar"), "bar}bar")
- self.assertEqual(posixpath.expandvars("${foo"), "${foo")
- self.assertEqual(posixpath.expandvars("${{foo}}"), "baz1}")
- self.assertEqual(posixpath.expandvars("$foo$foo"), "barbar")
- self.assertEqual(posixpath.expandvars("$bar$bar"), "$bar$bar")
-
- self.assertEqual(posixpath.expandvars(b"foo"), b"foo")
- self.assertEqual(posixpath.expandvars(b"$foo bar"), b"bar bar")
- self.assertEqual(posixpath.expandvars(b"${foo}bar"), b"barbar")
- self.assertEqual(posixpath.expandvars(b"$[foo]bar"), b"$[foo]bar")
- self.assertEqual(posixpath.expandvars(b"$bar bar"), b"$bar bar")
- self.assertEqual(posixpath.expandvars(b"$?bar"), b"$?bar")
- self.assertEqual(posixpath.expandvars(b"${foo}bar"), b"barbar")
- self.assertEqual(posixpath.expandvars(b"$foo}bar"), b"bar}bar")
- self.assertEqual(posixpath.expandvars(b"${foo"), b"${foo")
- self.assertEqual(posixpath.expandvars(b"${{foo}}"), b"baz1}")
- self.assertEqual(posixpath.expandvars(b"$foo$foo"), b"barbar")
- self.assertEqual(posixpath.expandvars(b"$bar$bar"), b"$bar$bar")
- self.assertRaises(TypeError, posixpath.expandvars)
+ # expanduser should fall back to using the password database
+ del env['HOME']
+ home = pwd.getpwuid(os.getuid()).pw_dir
+ self.assertEqual(posixpath.expanduser("~"), home)
def test_normpath(self):
self.assertEqual(posixpath.normpath(""), ".")
@@ -478,115 +323,127 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.normpath(b"///..//./foo/.//bar"),
b"/foo/bar")
- self.assertRaises(TypeError, posixpath.normpath)
-
- def test_abspath(self):
- self.assertTrue("foo" in posixpath.abspath("foo"))
- self.assertTrue(b"foo" in posixpath.abspath(b"foo"))
-
- self.assertRaises(TypeError, posixpath.abspath)
-
- def test_realpath(self):
- self.assertTrue("foo" in realpath("foo"))
- self.assertTrue(b"foo" in realpath(b"foo"))
- self.assertRaises(TypeError, posixpath.realpath)
-
- if hasattr(os, "symlink"):
- def test_realpath_basic(self):
- # Basic operation.
- try:
- os.symlink(ABSTFN+"1", ABSTFN)
- self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
- finally:
- support.unlink(ABSTFN)
-
- def test_realpath_symlink_loops(self):
- # Bug #930024, return the path unchanged if we get into an infinite
- # symlink loop.
- try:
- old_path = abspath('.')
- os.symlink(ABSTFN, ABSTFN)
- self.assertEqual(realpath(ABSTFN), ABSTFN)
-
- os.symlink(ABSTFN+"1", ABSTFN+"2")
- os.symlink(ABSTFN+"2", ABSTFN+"1")
- self.assertEqual(realpath(ABSTFN+"1"), ABSTFN+"1")
- self.assertEqual(realpath(ABSTFN+"2"), ABSTFN+"2")
-
- # Test using relative path as well.
- os.chdir(dirname(ABSTFN))
- self.assertEqual(realpath(basename(ABSTFN)), ABSTFN)
- finally:
- os.chdir(old_path)
- support.unlink(ABSTFN)
- support.unlink(ABSTFN+"1")
- support.unlink(ABSTFN+"2")
-
- def test_realpath_resolve_parents(self):
- # We also need to resolve any symlinks in the parents of a relative
- # path passed to realpath. E.g.: current working directory is
- # /usr/doc with 'doc' being a symlink to /usr/share/doc. We call
- # realpath("a"). This should return /usr/share/doc/a/.
- try:
- old_path = abspath('.')
- os.mkdir(ABSTFN)
- os.mkdir(ABSTFN + "/y")
- os.symlink(ABSTFN + "/y", ABSTFN + "/k")
-
- os.chdir(ABSTFN + "/k")
- self.assertEqual(realpath("a"), ABSTFN + "/y/a")
- finally:
- os.chdir(old_path)
- support.unlink(ABSTFN + "/k")
- safe_rmdir(ABSTFN + "/y")
- safe_rmdir(ABSTFN)
-
- def test_realpath_resolve_before_normalizing(self):
- # Bug #990669: Symbolic links should be resolved before we
- # normalize the path. E.g.: if we have directories 'a', 'k' and 'y'
- # in the following hierarchy:
- # a/k/y
- #
- # and a symbolic link 'link-y' pointing to 'y' in directory 'a',
- # then realpath("link-y/..") should return 'k', not 'a'.
- try:
- old_path = abspath('.')
- os.mkdir(ABSTFN)
- os.mkdir(ABSTFN + "/k")
- os.mkdir(ABSTFN + "/k/y")
- os.symlink(ABSTFN + "/k/y", ABSTFN + "/link-y")
-
- # Absolute path.
- self.assertEqual(realpath(ABSTFN + "/link-y/.."), ABSTFN + "/k")
- # Relative path.
- os.chdir(dirname(ABSTFN))
- self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."), ABSTFN + "/k")
- finally:
- os.chdir(old_path)
- support.unlink(ABSTFN + "/link-y")
- safe_rmdir(ABSTFN + "/k/y")
- safe_rmdir(ABSTFN + "/k")
- safe_rmdir(ABSTFN)
-
- def test_realpath_resolve_first(self):
- # Bug #1213894: The first component of the path, if not absolute,
- # must be resolved too.
-
- try:
- old_path = abspath('.')
- os.mkdir(ABSTFN)
- os.mkdir(ABSTFN + "/k")
- os.symlink(ABSTFN, ABSTFN + "link")
- os.chdir(dirname(ABSTFN))
-
- base = basename(ABSTFN)
- self.assertEqual(realpath(base + "link"), ABSTFN)
- self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k")
- finally:
- os.chdir(old_path)
- support.unlink(ABSTFN + "link")
- safe_rmdir(ABSTFN + "/k")
- safe_rmdir(ABSTFN)
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_basic(self):
+ # Basic operation.
+ try:
+ os.symlink(ABSTFN+"1", ABSTFN)
+ self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
+ finally:
+ support.unlink(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_relative(self):
+ try:
+ os.symlink(posixpath.relpath(ABSTFN+"1"), ABSTFN)
+ self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
+ finally:
+ support.unlink(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_symlink_loops(self):
+ # Bug #930024, return the path unchanged if we get into an infinite
+ # symlink loop.
+ try:
+ old_path = abspath('.')
+ os.symlink(ABSTFN, ABSTFN)
+ self.assertEqual(realpath(ABSTFN), ABSTFN)
+
+ os.symlink(ABSTFN+"1", ABSTFN+"2")
+ os.symlink(ABSTFN+"2", ABSTFN+"1")
+ self.assertEqual(realpath(ABSTFN+"1"), ABSTFN+"1")
+ self.assertEqual(realpath(ABSTFN+"2"), ABSTFN+"2")
+
+ # Test using relative path as well.
+ os.chdir(dirname(ABSTFN))
+ self.assertEqual(realpath(basename(ABSTFN)), ABSTFN)
+ finally:
+ os.chdir(old_path)
+ support.unlink(ABSTFN)
+ support.unlink(ABSTFN+"1")
+ support.unlink(ABSTFN+"2")
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_resolve_parents(self):
+ # We also need to resolve any symlinks in the parents of a relative
+ # path passed to realpath. E.g.: current working directory is
+ # /usr/doc with 'doc' being a symlink to /usr/share/doc. We call
+ # realpath("a"). This should return /usr/share/doc/a/.
+ try:
+ old_path = abspath('.')
+ os.mkdir(ABSTFN)
+ os.mkdir(ABSTFN + "/y")
+ os.symlink(ABSTFN + "/y", ABSTFN + "/k")
+
+ os.chdir(ABSTFN + "/k")
+ self.assertEqual(realpath("a"), ABSTFN + "/y/a")
+ finally:
+ os.chdir(old_path)
+ support.unlink(ABSTFN + "/k")
+ safe_rmdir(ABSTFN + "/y")
+ safe_rmdir(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_resolve_before_normalizing(self):
+ # Bug #990669: Symbolic links should be resolved before we
+ # normalize the path. E.g.: if we have directories 'a', 'k' and 'y'
+ # in the following hierarchy:
+ # a/k/y
+ #
+ # and a symbolic link 'link-y' pointing to 'y' in directory 'a',
+ # then realpath("link-y/..") should return 'k', not 'a'.
+ try:
+ old_path = abspath('.')
+ os.mkdir(ABSTFN)
+ os.mkdir(ABSTFN + "/k")
+ os.mkdir(ABSTFN + "/k/y")
+ os.symlink(ABSTFN + "/k/y", ABSTFN + "/link-y")
+
+ # Absolute path.
+ self.assertEqual(realpath(ABSTFN + "/link-y/.."), ABSTFN + "/k")
+ # Relative path.
+ os.chdir(dirname(ABSTFN))
+ self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."),
+ ABSTFN + "/k")
+ finally:
+ os.chdir(old_path)
+ support.unlink(ABSTFN + "/link-y")
+ safe_rmdir(ABSTFN + "/k/y")
+ safe_rmdir(ABSTFN + "/k")
+ safe_rmdir(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_resolve_first(self):
+ # Bug #1213894: The first component of the path, if not absolute,
+ # must be resolved too.
+
+ try:
+ old_path = abspath('.')
+ os.mkdir(ABSTFN)
+ os.mkdir(ABSTFN + "/k")
+ os.symlink(ABSTFN, ABSTFN + "link")
+ os.chdir(dirname(ABSTFN))
+
+ base = basename(ABSTFN)
+ self.assertEqual(realpath(base + "link"), ABSTFN)
+ self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k")
+ finally:
+ os.chdir(old_path)
+ support.unlink(ABSTFN + "link")
+ safe_rmdir(ABSTFN + "/k")
+ safe_rmdir(ABSTFN)
def test_relpath(self):
(real_getcwd, os.getcwd) = (os.getcwd, lambda: r"/home/user/bar")
@@ -644,8 +501,20 @@ class PosixPathTest(unittest.TestCase):
finally:
os.getcwdb = real_getcwdb
+ def test_sameopenfile(self):
+ fname = support.TESTFN + "1"
+ with open(fname, "wb") as a, open(fname, "wb") as b:
+ self.assertTrue(posixpath.sameopenfile(a.fileno(), b.fileno()))
+
+
+class PosixCommonTest(test_genericpath.CommonTest):
+ pathmodule = posixpath
+ attributes = ['relpath', 'samefile', 'sameopenfile', 'samestat']
+
+
def test_main():
- support.run_unittest(PosixPathTest)
+ support.run_unittest(PosixPathTest, PosixCommonTest)
+
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index ad3a19396a..4e53cd8a01 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -3,6 +3,8 @@ import test.support
import unittest
import test.test_set
import random
+import collections
+import itertools
# list, tuple and dict subclasses that do or don't overwrite __repr__
class list2(list):
@@ -195,6 +197,20 @@ class QueryTestCase(unittest.TestCase):
self.assertEqual(pprint.pformat({"xy\tab\n": (3,), 5: [[]], (): {}}),
r"{5: [[]], 'xy\tab\n': (3,), (): {}}")
+ def test_ordered_dict(self):
+ words = 'the quick brown fox jumped over a lazy dog'.split()
+ d = collections.OrderedDict(zip(words, itertools.count()))
+ self.assertEqual(pprint.pformat(d),
+"""\
+{'the': 0,
+ 'quick': 1,
+ 'brown': 2,
+ 'fox': 3,
+ 'jumped': 4,
+ 'over': 5,
+ 'a': 6,
+ 'lazy': 7,
+ 'dog': 8}""")
def test_subclassing(self):
o = {'names with spaces': 'should be presented using repr()',
'others.should.not.be': 'like.this'}
@@ -203,7 +219,29 @@ class QueryTestCase(unittest.TestCase):
others.should.not.be: like.this}"""
self.assertEqual(DottedPrettyPrinter().pformat(o), exp)
+ @test.support.cpython_only
def test_set_reprs(self):
+ # This test creates a complex arrangement of frozensets and
+ # compares the pretty-printed repr against a string hard-coded in
+ # the test. The hard-coded repr depends on the sort order of
+ # frozensets.
+ #
+ # However, as the docs point out: "Since sets only define
+ # partial ordering (subset relationships), the output of the
+ # list.sort() method is undefined for lists of sets."
+ #
+ # In a nutshell, the test assumes frozenset({0}) will always
+ # sort before frozenset({1}), but:
+ #
+ # >>> frozenset({0}) < frozenset({1})
+ # False
+ # >>> frozenset({1}) < frozenset({0})
+ # False
+ #
+ # Consequently, this test is fragile and
+ # implementation-dependent. Small changes to Python's sort
+ # algorithm cause the test to fail when it should pass.
+
self.assertEqual(pprint.pformat(set()), 'set()')
self.assertEqual(pprint.pformat(set(range(3))), '{0, 1, 2}')
self.assertEqual(pprint.pformat(frozenset()), 'frozenset()')
diff --git a/Lib/test/test_print.py b/Lib/test/test_print.py
index b1ace4dc2c..8d37bbc4d6 100644
--- a/Lib/test/test_print.py
+++ b/Lib/test/test_print.py
@@ -8,7 +8,6 @@ from __future__ import print_function
import unittest
from test import support
-import sys
try:
# 3.x
from io import StringIO
diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py
index 243a322582..cd7ec58e23 100755..100644
--- a/Lib/test/test_profile.py
+++ b/Lib/test/test_profile.py
@@ -1,6 +1,5 @@
"""Test suite for the profile module."""
-import os
import sys
import pstats
import unittest
@@ -72,7 +71,7 @@ class ProfileTest(unittest.TestCase):
stats = pstats.Stats(prof, stream=s)
stats.print_stats()
res = s.getvalue()
- self.assertTrue(self.expected_max_output in res,
+ self.assertIn(self.expected_max_output, res,
"Profiling {0!r} didn't report max:\n{1}".format(stmt, res))
diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py
index d9469d97d0..cc6a872179 100644
--- a/Lib/test/test_property.py
+++ b/Lib/test/test_property.py
@@ -1,6 +1,7 @@
# Test case for property
# more tests are in test_descr
+import sys
import unittest
from test.support import run_unittest
@@ -91,7 +92,6 @@ class PropertyTests(unittest.TestCase):
base.spam = 20
self.assertEqual(base.spam, 20)
self.assertEqual(base._spam, 20)
- self.assertEqual(base.__class__.spam.__doc__, "BaseClass.getter")
def test_property_decorator_subclass(self):
# see #1620
@@ -99,14 +99,27 @@ class PropertyTests(unittest.TestCase):
self.assertRaises(PropertyGet, getattr, sub, "spam")
self.assertRaises(PropertySet, setattr, sub, "spam", None)
self.assertRaises(PropertyDel, delattr, sub, "spam")
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_property_decorator_subclass_doc(self):
+ sub = SubClass()
self.assertEqual(sub.__class__.spam.__doc__, "SubClass.getter")
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_property_decorator_baseclass_doc(self):
+ base = BaseClass()
+ self.assertEqual(base.__class__.spam.__doc__, "BaseClass.getter")
+
def test_property_decorator_doc(self):
base = PropertyDocBase()
sub = PropertyDocSub()
self.assertEqual(base.__class__.spam.__doc__, "spam spam spam")
self.assertEqual(sub.__class__.spam.__doc__, "spam spam spam")
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_property_getter_doc_override(self):
newgettersub = PropertySubNewGetter()
self.assertEqual(newgettersub.spam, 5)
@@ -126,16 +139,6 @@ class PropertySubSlots(property):
class PropertySubclassTests(unittest.TestCase):
- def test_docstring_copy(self):
- class Foo(object):
- @PropertySub
- def spam(self):
- """spam wrapped in property subclass"""
- return 1
- self.assertEqual(
- Foo.spam.__doc__,
- "spam wrapped in property subclass")
-
def test_slots_docstring_copy_exception(self):
try:
class Foo(object):
@@ -148,6 +151,20 @@ class PropertySubclassTests(unittest.TestCase):
else:
raise Exception("AttributeError not raised")
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_docstring_copy(self):
+ class Foo(object):
+ @PropertySub
+ def spam(self):
+ """spam wrapped in property subclass"""
+ return 1
+ self.assertEqual(
+ Foo.spam.__doc__,
+ "spam wrapped in property subclass")
+
+ @unittest.skipIf(sys.flags.optimize <= 2,
+ "Docstrings are omitted with -O2 and above")
def test_property_setter_copies_getter_docstring(self):
class Foo(object):
def __init__(self): self._spam = 1
@@ -179,6 +196,8 @@ class PropertySubclassTests(unittest.TestCase):
FooSub.spam.__doc__,
"spam wrapped in property subclass")
+ @unittest.skipIf(sys.flags.optimize <= 2,
+ "Docstrings are omitted with -O2 and above")
def test_property_new_getter_new_docstring(self):
class Foo(object):
diff --git a/Lib/test/test_pstats.py b/Lib/test/test_pstats.py
index 7c28465c3b..9ebeebbfee 100644
--- a/Lib/test/test_pstats.py
+++ b/Lib/test/test_pstats.py
@@ -1,5 +1,6 @@
import unittest
from test import support
+from io import StringIO
import pstats
@@ -8,8 +9,8 @@ class AddCallersTestCase(unittest.TestCase):
"""Tests for pstats.add_callers helper."""
def test_combine_results(self):
- """pstats.add_callers should combine the call results of both target
- and source by adding the call time. See issue1269."""
+ # pstats.add_callers should combine the call results of both target
+ # and source by adding the call time. See issue1269.
# new format: used by the cProfile module
target = {"a": (1, 2, 3, 4)}
source = {"a": (1, 2, 3, 4), "b": (5, 6, 7, 8)}
@@ -22,9 +23,21 @@ class AddCallersTestCase(unittest.TestCase):
self.assertEqual(new_callers, {'a': 2, 'b': 5})
+class StatsTestCase(unittest.TestCase):
+ def setUp(self):
+ stats_file = support.findfile('pstats.pck')
+ self.stats = pstats.Stats(stats_file)
+
+ def test_add(self):
+ stream = StringIO()
+ stats = pstats.Stats(stream=stream)
+ stats.add(self.stats, self.stats)
+
+
def test_main():
support.run_unittest(
- AddCallersTestCase
+ AddCallersTestCase,
+ StatsTestCase,
)
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index 406578a70d..ae1c8feca6 100644
--- a/Lib/test/test_pwd.py
+++ b/Lib/test/test_pwd.py
@@ -1,3 +1,4 @@
+import sys
import unittest
from test import support
@@ -13,19 +14,19 @@ class PwdTest(unittest.TestCase):
for e in entries:
self.assertEqual(len(e), 7)
self.assertEqual(e[0], e.pw_name)
- self.assertTrue(isinstance(e.pw_name, str))
+ self.assertIsInstance(e.pw_name, str)
self.assertEqual(e[1], e.pw_passwd)
- self.assertTrue(isinstance(e.pw_passwd, str))
+ self.assertIsInstance(e.pw_passwd, str)
self.assertEqual(e[2], e.pw_uid)
- self.assertTrue(isinstance(e.pw_uid, int))
+ self.assertIsInstance(e.pw_uid, int)
self.assertEqual(e[3], e.pw_gid)
- self.assertTrue(isinstance(e.pw_gid, int))
+ self.assertIsInstance(e.pw_gid, int)
self.assertEqual(e[4], e.pw_gecos)
- self.assertTrue(isinstance(e.pw_gecos, str))
+ self.assertIsInstance(e.pw_gecos, str)
self.assertEqual(e[5], e.pw_dir)
- self.assertTrue(isinstance(e.pw_dir, str))
+ self.assertIsInstance(e.pw_dir, str)
self.assertEqual(e[6], e.pw_shell)
- self.assertTrue(isinstance(e.pw_shell, str))
+ self.assertIsInstance(e.pw_shell, str)
# The following won't work, because of duplicate entries
# for one uid
@@ -43,8 +44,8 @@ class PwdTest(unittest.TestCase):
for e in entries:
if not e[0] or e[0] == '+':
continue # skip NIS entries etc.
- self.assertTrue(pwd.getpwnam(e.pw_name) in entriesbyname[e.pw_name])
- self.assertTrue(pwd.getpwuid(e.pw_uid) in entriesbyuid[e.pw_uid])
+ self.assertIn(pwd.getpwnam(e.pw_name), entriesbyname[e.pw_name])
+ self.assertIn(pwd.getpwuid(e.pw_uid), entriesbyuid[e.pw_uid])
def test_errors(self):
self.assertRaises(TypeError, pwd.getpwuid)
@@ -83,11 +84,13 @@ class PwdTest(unittest.TestCase):
self.assertRaises(KeyError, pwd.getpwnam, fakename)
- # Choose a non-existent uid.
- fakeuid = 4127
- while fakeuid in byuids:
- fakeuid = (fakeuid * 3) % 0x10000
-
+ # In some cases, byuids isn't a complete list of all users in the
+ # system, so if we try to pick a value not in byuids (via a perturbing
+ # loop, say), pwd.getpwuid() might still be able to find data for that
+ # uid. Using sys.maxint may provoke the same problems, but hopefully
+ # it will be a more repeatable failure.
+ fakeuid = sys.maxsize
+ self.assertNotIn(fakeuid, byuids)
self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
def test_main():
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 5b6fcb0330..3082b29dbc 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -40,7 +40,7 @@ class PyclbrTest(TestCase):
if key in ignore: return
if key not in obj:
print("***",key, file=sys.stderr)
- self.assertTrue(key in obj, "%r in %r" % (key, obj))
+ self.assertIn(key, obj)
def assertEqualsOrIgnored(self, a, b, ignore):
''' succeed iff a == b or a in ignore or b in ignore '''
@@ -84,12 +84,12 @@ class PyclbrTest(TestCase):
self.assertHasattr(module, name, ignore)
py_item = getattr(module, name)
if isinstance(value, pyclbr.Function):
- self.assertTrue(isinstance(py_item, (FunctionType, BuiltinFunctionType)))
+ self.assertIsInstance(py_item, (FunctionType, BuiltinFunctionType))
if py_item.__module__ != moduleName:
continue # skip functions that came from somewhere else
self.assertEqual(py_item.__module__, value.module)
else:
- self.assertTrue(isinstance(py_item, type))
+ self.assertIsInstance(py_item, type)
if py_item.__module__ != moduleName:
continue # skip classes that came from somewhere else
@@ -141,7 +141,8 @@ class PyclbrTest(TestCase):
def test_easy(self):
self.checkModule('pyclbr')
self.checkModule('ast')
- self.checkModule('doctest', ignore=("TestResults", "_SpoofOut"))
+ self.checkModule('doctest', ignore=("TestResults", "_SpoofOut",
+ "DocTestCase"))
self.checkModule('difflib', ignore=("Match",))
def test_decorators(self):
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index f7aa487580..1d575cd433 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -1,21 +1,28 @@
-import sys
import os
-import os.path
+import sys
import difflib
-import subprocess
-import re
-import pydoc
import inspect
-import unittest
+import pydoc
+import re
+import string
+import subprocess
import test.support
+import time
+import unittest
import xml.etree
+import textwrap
+from io import StringIO
from contextlib import contextmanager
-from test.support import TESTFN, forget, rmtree, EnvironmentVarGuard
+from test.support import TESTFN, forget, rmtree, EnvironmentVarGuard, \
+ reap_children, captured_output
from test import pydoc_mod
-expected_text_pattern = \
-"""
+# Just in case sys.modules["test"] has the optional attribute __loader__.
+if hasattr(pydoc_mod, "__loader__"):
+ del pydoc_mod.__loader__
+
+expected_text_pattern = """
NAME
test.pydoc_mod - This is a test module for test_pydoc
%s
@@ -80,8 +87,7 @@ FILE
%s
""".strip()
-expected_html_pattern = \
-"""
+expected_html_pattern = """
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
@@ -177,7 +183,7 @@ war</tt></dd></dl>
\x20\x20\x20\x20
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Nobody</td></tr></table>
-""".strip()
+""".strip() # ' <- emacs turd
# output pattern for missing module
@@ -192,8 +198,11 @@ def run_pydoc(module_name, *args):
output of pydoc.
"""
cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name]
- output = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.read()
- return output.strip()
+ try:
+ output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
+ return output.strip()
+ finally:
+ reap_children()
def get_pydoc_html(module):
"Returns pydoc generated output as html"
@@ -213,22 +222,32 @@ def get_pydoc_text(module):
output = doc.docmodule(module)
- # cleanup the extra text formatting that pydoc preforms
+ # clean up the extra text formatting that pydoc performs
patt = re.compile('\b.')
output = patt.sub('', output)
return output.strip(), loc
def print_diffs(text1, text2):
"Prints unified diffs for two texts"
+ # XXX now obsolete, use unittest built-in support
lines1 = text1.splitlines(True)
lines2 = text2.splitlines(True)
diffs = difflib.unified_diff(lines1, lines2, n=0, fromfile='expected',
tofile='got')
print('\n' + ''.join(diffs))
+def get_html_title(text):
+ # Bit of hack, but good enough for test purposes
+ header, _, _ = text.partition("</head>")
+ _, _, title = header.partition("<title>")
+ title, _, _ = title.partition("</title>")
+ return title
-class PyDocDocTest(unittest.TestCase):
+class PydocDocTest(unittest.TestCase):
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_html_doc(self):
result, doc_loc = get_pydoc_html(pydoc_mod)
mod_file = inspect.getabsfile(pydoc_mod)
@@ -242,6 +261,8 @@ class PyDocDocTest(unittest.TestCase):
print_diffs(expected_html, result)
self.fail("outputs are not equal, see diff above")
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_text_doc(self):
result, doc_loc = get_pydoc_text(pydoc_mod)
expected_text = expected_text_pattern % \
@@ -271,7 +292,8 @@ class PyDocDocTest(unittest.TestCase):
('i_am_not_here', 'i_am_not_here'),
('test.i_am_not_here_either', 'i_am_not_here_either'),
('test.i_am_not_here.neither_am_i', 'i_am_not_here.neither_am_i'),
- ('i_am_not_here.{}'.format(modname), 'i_am_not_here.{}'.format(modname)),
+ ('i_am_not_here.{}'.format(modname),
+ 'i_am_not_here.{}'.format(modname)),
('test.{}'.format(modname), modname),
)
@@ -288,9 +310,8 @@ class PyDocDocTest(unittest.TestCase):
fullmodname = os.path.join(TESTFN, modname)
sourcefn = fullmodname + os.extsep + "py"
for importstring, expectedinmsg in testpairs:
- f = open(sourcefn, 'w')
- f.write("import {}\n".format(importstring))
- f.close()
+ with open(sourcefn, 'w') as f:
+ f.write("import {}\n".format(importstring))
try:
result = run_pydoc(modname).decode("ascii")
finally:
@@ -317,6 +338,41 @@ class PyDocDocTest(unittest.TestCase):
self.assertEqual(stripid("<type 'exceptions.Exception'>"),
"<type 'exceptions.Exception'>")
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ 'Docstrings are omitted with -O2 and above')
+ def test_help_output_redirect(self):
+ # issue 940286, if output is set in Helper, then all output from
+ # Helper.help should be redirected
+ old_pattern = expected_text_pattern
+ getpager_old = pydoc.getpager
+ getpager_new = lambda: (lambda x: x)
+ self.maxDiff = None
+
+ buf = StringIO()
+ helper = pydoc.Helper(output=buf)
+ unused, doc_loc = get_pydoc_text(pydoc_mod)
+ module = "test.pydoc_mod"
+ help_header = """
+ Help on module test.pydoc_mod in test:
+
+ """.lstrip()
+ help_header = textwrap.dedent(help_header)
+ expected_help_pattern = help_header + expected_text_pattern
+
+ pydoc.getpager = getpager_new
+ try:
+ with captured_output('stdout') as output, \
+ captured_output('stderr') as err:
+ helper.help(module)
+ result = buf.getvalue().strip()
+ expected_text = expected_help_pattern % \
+ (doc_loc, inspect.getabsfile(pydoc_mod))
+ self.assertEqual('', output.getvalue())
+ self.assertEqual('', err.getvalue())
+ self.assertEqual(expected_text, result)
+ finally:
+ pydoc.getpager = getpager_old
+
class TestDescriptions(unittest.TestCase):
@@ -324,28 +380,87 @@ class TestDescriptions(unittest.TestCase):
# Check that pydocfodder module can be described
from test import pydocfodder
doc = pydoc.render_doc(pydocfodder)
- self.assertTrue("pydocfodder" in doc)
-
- def test_classic_class(self):
- class C: "Classic class"
- c = C()
- self.assertEqual(pydoc.describe(C), 'class C')
- self.assertEqual(pydoc.describe(c), 'C')
- expected = 'C in module %s' % __name__
- self.assertTrue(expected in pydoc.render_doc(c))
+ self.assertIn("pydocfodder", doc)
def test_class(self):
- class C(object): "New-style class"
+ class C: "New-style class"
c = C()
self.assertEqual(pydoc.describe(C), 'class C')
self.assertEqual(pydoc.describe(c), 'C')
expected = 'C in module %s object' % __name__
- self.assertTrue(expected in pydoc.render_doc(c))
+ self.assertIn(expected, pydoc.render_doc(c))
+
+
+class PydocServerTest(unittest.TestCase):
+ """Tests for pydoc._start_server"""
+
+ def test_server(self):
+
+ # Minimal test that starts the server, then stops it.
+ def my_url_handler(url, content_type):
+ text = 'the URL sent was: (%s, %s)' % (url, content_type)
+ return text
+
+ serverthread = pydoc._start_server(my_url_handler, port=0)
+ starttime = time.time()
+ timeout = 1 #seconds
+
+ while serverthread.serving:
+ time.sleep(.01)
+ if serverthread.serving and time.time() - starttime > timeout:
+ serverthread.stop()
+ break
+
+ self.assertEqual(serverthread.error, None)
+
+
+class PydocUrlHandlerTest(unittest.TestCase):
+ """Tests for pydoc._url_handler"""
+
+ def test_content_type_err(self):
+ f = pydoc._url_handler
+ self.assertRaises(TypeError, f, 'A', '')
+ self.assertRaises(TypeError, f, 'B', 'foobar')
+
+ def test_url_requests(self):
+ # Test for the correct title in the html pages returned.
+ # This tests the different parts of the URL handler without
+ # getting too picky about the exact html.
+ requests = [
+ ("", "Pydoc: Index of Modules"),
+ ("get?key=", "Pydoc: Index of Modules"),
+ ("index", "Pydoc: Index of Modules"),
+ ("topics", "Pydoc: Topics"),
+ ("keywords", "Pydoc: Keywords"),
+ ("pydoc", "Pydoc: module pydoc"),
+ ("get?key=pydoc", "Pydoc: module pydoc"),
+ ("search?key=pydoc", "Pydoc: Search Results"),
+ ("topic?key=def", "Pydoc: KEYWORD def"),
+ ("topic?key=STRINGS", "Pydoc: TOPIC STRINGS"),
+ ("foobar", "Pydoc: Error - foobar"),
+ ("getfile?key=foobar", "Pydoc: Error - getfile?key=foobar"),
+ ]
+
+ for url, title in requests:
+ text = pydoc._url_handler(url, "text/html")
+ result = get_html_title(text)
+ self.assertEqual(result, title)
+
+ path = string.__file__
+ title = "Pydoc: getfile " + path
+ url = "getfile?key=" + path
+ text = pydoc._url_handler(url, "text/html")
+ result = get_html_title(text)
+ self.assertEqual(result, title)
def test_main():
- test.support.run_unittest(PyDocDocTest, TestDescriptions)
+ test.support.run_unittest(PydocDocTest,
+ TestDescriptions,
+ PydocServerTest,
+ PydocUrlHandlerTest,
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py
index 133c02b5ba..27eecb8d83 100644
--- a/Lib/test/test_pyexpat.py
+++ b/Lib/test/test_pyexpat.py
@@ -2,11 +2,10 @@
# handler, are obscure and unhelpful.
from io import BytesIO
-import sys
import unittest
-import pyexpat
from xml.parsers import expat
+from xml.parsers.expat import errors
from test.support import sortdict, run_unittest
@@ -38,6 +37,7 @@ data = b'''\
<!-- comment data -->
<!DOCTYPE quotations SYSTEM "quotations.dtd" [
<!ELEMENT root ANY>
+<!ATTLIST root attr1 CDATA #REQUIRED attr2 CDATA #IMPLIED>
<!NOTATION notation SYSTEM "notation.jpeg">
<!ENTITY acirc "&#226;">
<!ENTITY external_entity SYSTEM "entity.file">
@@ -51,6 +51,7 @@ data = b'''\
</myns:subelement>
<sub2><![CDATA[contents of CDATA section]]></sub2>
&external_entity;
+&skipped_entity;
</root>
'''
@@ -99,7 +100,7 @@ class ParseTest(unittest.TestCase):
entityName, base, systemId, publicId, notationName = args
self.out.append('Unparsed entity decl: %s' %(args,))
- def NotStandaloneHandler(self, userData):
+ def NotStandaloneHandler(self):
self.out.append('Not standalone')
return 1
@@ -108,6 +109,34 @@ class ParseTest(unittest.TestCase):
self.out.append('External entity ref: %s' %(args[1:],))
return 1
+ def StartDoctypeDeclHandler(self, *args):
+ self.out.append(('Start doctype', args))
+ return 1
+
+ def EndDoctypeDeclHandler(self):
+ self.out.append("End doctype")
+ return 1
+
+ def EntityDeclHandler(self, *args):
+ self.out.append(('Entity declaration', args))
+ return 1
+
+ def XmlDeclHandler(self, *args):
+ self.out.append(('XML declaration', args))
+ return 1
+
+ def ElementDeclHandler(self, *args):
+ self.out.append(('Element declaration', args))
+ return 1
+
+ def AttlistDeclHandler(self, *args):
+ self.out.append(('Attribute list declaration', args))
+ return 1
+
+ def SkippedEntityHandler(self, *args):
+ self.out.append(("Skipped entity", args))
+ return 1
+
def DefaultHandler(self, userData):
pass
@@ -115,61 +144,86 @@ class ParseTest(unittest.TestCase):
pass
handler_names = [
- 'StartElementHandler', 'EndElementHandler',
- 'CharacterDataHandler', 'ProcessingInstructionHandler',
- 'UnparsedEntityDeclHandler', 'NotationDeclHandler',
- 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler',
- 'CommentHandler', 'StartCdataSectionHandler',
- 'EndCdataSectionHandler',
- 'DefaultHandler', 'DefaultHandlerExpand',
- #'NotStandaloneHandler',
- 'ExternalEntityRefHandler'
+ 'StartElementHandler', 'EndElementHandler', 'CharacterDataHandler',
+ 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler',
+ 'NotationDeclHandler', 'StartNamespaceDeclHandler',
+ 'EndNamespaceDeclHandler', 'CommentHandler',
+ 'StartCdataSectionHandler', 'EndCdataSectionHandler', 'DefaultHandler',
+ 'DefaultHandlerExpand', 'NotStandaloneHandler',
+ 'ExternalEntityRefHandler', 'StartDoctypeDeclHandler',
+ 'EndDoctypeDeclHandler', 'EntityDeclHandler', 'XmlDeclHandler',
+ 'ElementDeclHandler', 'AttlistDeclHandler', 'SkippedEntityHandler',
]
- def _verify_parse_output(self, op):
- self.assertEqual(op[0], 'PI: \'xml-stylesheet\' \'href="stylesheet.css"\'')
- self.assertEqual(op[1], "Comment: ' comment data '")
- self.assertEqual(op[2], "Notation declared: ('notation', None, 'notation.jpeg', None)")
- self.assertEqual(op[3], "Unparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation')")
- self.assertEqual(op[4], "Start element: 'root' {'attr1': 'value1', 'attr2': 'value2\u1f40'}")
- self.assertEqual(op[5], "NS decl: 'myns' 'http://www.python.org/namespace'")
- self.assertEqual(op[6], "Start element: 'http://www.python.org/namespace!subelement' {}")
- self.assertEqual(op[7], "Character data: 'Contents of subelements'")
- self.assertEqual(op[8], "End element: 'http://www.python.org/namespace!subelement'")
- self.assertEqual(op[9], "End of NS decl: 'myns'")
- self.assertEqual(op[10], "Start element: 'sub2' {}")
- self.assertEqual(op[11], 'Start of CDATA section')
- self.assertEqual(op[12], "Character data: 'contents of CDATA section'")
- self.assertEqual(op[13], 'End of CDATA section')
- self.assertEqual(op[14], "End element: 'sub2'")
- self.assertEqual(op[15], "External entity ref: (None, 'entity.file', None)")
- self.assertEqual(op[16], "End element: 'root'")
-
+ def _hookup_callbacks(self, parser, handler):
+ """
+ Set each of the callbacks defined on handler and named in
+ self.handler_names on the given parser.
+ """
+ for name in self.handler_names:
+ setattr(parser, name, getattr(handler, name))
+
+ def _verify_parse_output(self, operations):
+ expected_operations = [
+ ('XML declaration', ('1.0', 'iso-8859-1', 0)),
+ 'PI: \'xml-stylesheet\' \'href="stylesheet.css"\'',
+ "Comment: ' comment data '",
+ "Not standalone",
+ ("Start doctype", ('quotations', 'quotations.dtd', None, 1)),
+ ('Element declaration', ('root', (2, 0, None, ()))),
+ ('Attribute list declaration', ('root', 'attr1', 'CDATA', None,
+ 1)),
+ ('Attribute list declaration', ('root', 'attr2', 'CDATA', None,
+ 0)),
+ "Notation declared: ('notation', None, 'notation.jpeg', None)",
+ ('Entity declaration', ('acirc', 0, '\xe2', None, None, None, None)),
+ ('Entity declaration', ('external_entity', 0, None, None,
+ 'entity.file', None, None)),
+ "Unparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation')",
+ "Not standalone",
+ "End doctype",
+ "Start element: 'root' {'attr1': 'value1', 'attr2': 'value2\u1f40'}",
+ "NS decl: 'myns' 'http://www.python.org/namespace'",
+ "Start element: 'http://www.python.org/namespace!subelement' {}",
+ "Character data: 'Contents of subelements'",
+ "End element: 'http://www.python.org/namespace!subelement'",
+ "End of NS decl: 'myns'",
+ "Start element: 'sub2' {}",
+ 'Start of CDATA section',
+ "Character data: 'contents of CDATA section'",
+ 'End of CDATA section',
+ "End element: 'sub2'",
+ "External entity ref: (None, 'entity.file', None)",
+ ('Skipped entity', ('skipped_entity', 0)),
+ "End element: 'root'",
+ ]
+ for operation, expected_operation in zip(operations, expected_operations):
+ self.assertEqual(operation, expected_operation)
def test_unicode(self):
# Try the parse again, this time producing Unicode output
out = self.Outputter()
parser = expat.ParserCreate(namespace_separator='!')
- for name in self.handler_names:
- setattr(parser, name, getattr(out, name))
+ self._hookup_callbacks(parser, out)
parser.Parse(data, 1)
- op = out.out
- self._verify_parse_output(op)
+ operations = out.out
+ self._verify_parse_output(operations)
+ # Issue #6697.
+ self.assertRaises(AttributeError, getattr, parser, '\uD800')
def test_parse_file(self):
# Try parsing a file
out = self.Outputter()
parser = expat.ParserCreate(namespace_separator='!')
- for name in self.handler_names:
- setattr(parser, name, getattr(out, name))
+ self._hookup_callbacks(parser, out)
file = BytesIO(data)
parser.ParseFile(file)
- op = out.out
- self._verify_parse_output(op)
+ operations = out.out
+ self._verify_parse_output(operations)
class NamespaceSeparatorTest(unittest.TestCase):
def test_legal(self):
@@ -185,7 +239,7 @@ class NamespaceSeparatorTest(unittest.TestCase):
self.fail()
except TypeError as e:
self.assertEqual(str(e),
- 'ParserCreate() argument 2 must be string or None, not int')
+ 'ParserCreate() argument 2 must be str or None, not int')
try:
expat.ParserCreate(namespace_separator='too long')
@@ -222,6 +276,25 @@ class InterningTest(unittest.TestCase):
# L should have the same string repeated over and over.
self.assertTrue(tag is entry)
+ def test_issue9402(self):
+ # create an ExternalEntityParserCreate with buffer text
+ class ExternalOutputter:
+ def __init__(self, parser):
+ self.parser = parser
+ self.parser_result = None
+
+ def ExternalEntityRefHandler(self, context, base, sysId, pubId):
+ external_parser = self.parser.ExternalEntityParserCreate("")
+ self.parser_result = external_parser.Parse("", 1)
+ return 1
+
+ parser = expat.ParserCreate(namespace_separator='!')
+ parser.buffer_text = 1
+ out = ExternalOutputter(parser)
+ parser.ExternalEntityRefHandler = out.ExternalEntityRefHandler
+ parser.Parse(data, 1)
+ self.assertEqual(out.parser_result, 1)
+
class BufferTextTest(unittest.TestCase):
def setUp(self):
@@ -510,7 +583,7 @@ class ChardataBufferTest(unittest.TestCase):
parser.Parse(xml2, 1)
self.assertEqual(self.n, 4)
-class MalformedInputText(unittest.TestCase):
+class MalformedInputTest(unittest.TestCase):
def test1(self):
xml = "\0\r\n"
parser = expat.ParserCreate()
@@ -529,6 +602,65 @@ class MalformedInputText(unittest.TestCase):
except expat.ExpatError as e:
self.assertEqual(str(e), 'XML declaration not well-formed: line 1, column 14')
+class ErrorMessageTest(unittest.TestCase):
+ def test_codes(self):
+ # verify mapping of errors.codes and errors.messages
+ self.assertEqual(errors.XML_ERROR_SYNTAX,
+ errors.messages[errors.codes[errors.XML_ERROR_SYNTAX]])
+
+ def test_expaterror(self):
+ xml = '<'
+ parser = expat.ParserCreate()
+ try:
+ parser.Parse(xml, True)
+ self.fail()
+ except expat.ExpatError as e:
+ self.assertEqual(e.code,
+ errors.codes[errors.XML_ERROR_UNCLOSED_TOKEN])
+
+
+class ForeignDTDTests(unittest.TestCase):
+ """
+ Tests for the UseForeignDTD method of expat parser objects.
+ """
+ def test_use_foreign_dtd(self):
+ """
+ If UseForeignDTD is passed True and a document without an external
+ entity reference is parsed, ExternalEntityRefHandler is first called
+ with None for the public and system ids.
+ """
+ handler_call_args = []
+ def resolve_entity(context, base, system_id, public_id):
+ handler_call_args.append((public_id, system_id))
+ return 1
+
+ parser = expat.ParserCreate()
+ parser.UseForeignDTD(True)
+ parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS)
+ parser.ExternalEntityRefHandler = resolve_entity
+ parser.Parse("<?xml version='1.0'?><element/>")
+ self.assertEqual(handler_call_args, [(None, None)])
+
+ def test_ignore_use_foreign_dtd(self):
+ """
+ If UseForeignDTD is passed True and a document with an external
+ entity reference is parsed, ExternalEntityRefHandler is called with
+ the public and system ids from the document.
+ """
+ handler_call_args = []
+ def resolve_entity(context, base, system_id, public_id):
+ handler_call_args.append((public_id, system_id))
+ return 1
+
+ parser = expat.ParserCreate()
+ parser.UseForeignDTD(True)
+ parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS)
+ parser.ExternalEntityRefHandler = resolve_entity
+ parser.Parse(
+ "<?xml version='1.0'?><!DOCTYPE foo PUBLIC 'bar' 'baz'><element/>")
+ self.assertEqual(handler_call_args, [("bar", "baz")])
+
+
def test_main():
run_unittest(SetAttributeTest,
ParseTest,
@@ -539,7 +671,9 @@ def test_main():
PositionTest,
sf1296433Test,
ChardataBufferTest,
- MalformedInputText)
+ MalformedInputTest,
+ ErrorMessageTest,
+ ForeignDTDTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py
index c65827d942..8287a5ddf6 100644
--- a/Lib/test/test_queue.py
+++ b/Lib/test/test_queue.py
@@ -1,11 +1,10 @@
# Some simple queue module tests, plus some failure conditions
# to ensure the Queue locks remain stable.
import queue
-import sys
-import threading
import time
import unittest
from test import support
+threading = support.import_module('threading')
QUEUE_SIZE = 5
@@ -91,6 +90,8 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
def simple_queue_test(self, q):
if q.qsize():
raise RuntimeError("Call this function with an empty queue")
+ self.assertTrue(q.empty())
+ self.assertFalse(q.full())
# I guess we better check things actually queue correctly a little :)
q.put(111)
q.put(333)
@@ -109,6 +110,8 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
full = 3 * 2 * QUEUE_SIZE
q.put(last)
self.assertTrue(qfull(q), "Queue should be full")
+ self.assertFalse(q.empty())
+ self.assertTrue(q.full())
try:
q.put(full, block=0)
self.fail("Didn't appear to block with a full queue")
@@ -194,6 +197,37 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
self.simple_queue_test(q)
self.simple_queue_test(q)
+ def test_negative_timeout_raises_exception(self):
+ q = self.type2test(QUEUE_SIZE)
+ with self.assertRaises(ValueError):
+ q.put(1, timeout=-1)
+ with self.assertRaises(ValueError):
+ q.get(1, timeout=-1)
+
+ def test_nowait(self):
+ q = self.type2test(QUEUE_SIZE)
+ for i in range(QUEUE_SIZE):
+ q.put_nowait(1)
+ with self.assertRaises(queue.Full):
+ q.put_nowait(1)
+
+ for i in range(QUEUE_SIZE):
+ q.get_nowait()
+ with self.assertRaises(queue.Empty):
+ q.get_nowait()
+
+ def test_shrinking_queue(self):
+ # issue 10110
+ q = self.type2test(3)
+ q.put(1)
+ q.put(2)
+ q.put(3)
+ with self.assertRaises(queue.Full):
+ q.put_nowait(4)
+ self.assertEqual(q.qsize(), 3)
+ q.maxsize = 2 # shrink the queue
+ with self.assertRaises(queue.Full):
+ q.put_nowait(4)
class QueueTest(BaseQueueTest):
type2test = queue.Queue
diff --git a/Lib/test/test_quopri.py b/Lib/test/test_quopri.py
index 2c52a3c025..583fd456a4 100644
--- a/Lib/test/test_quopri.py
+++ b/Lib/test/test_quopri.py
@@ -178,6 +178,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
(p, e) = self.STRINGS[-1]
process = subprocess.Popen([sys.executable, "-mquopri"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.addCleanup(process.stdout.close)
cout, cerr = process.communicate(p)
# On Windows, Python will output the result to stdout using
# CRLF, as the mode of stdout is text mode. To compare this
@@ -193,6 +194,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
(p, e) = self.STRINGS[-1]
process = subprocess.Popen([sys.executable, "-mquopri", "-d"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.addCleanup(process.stdout.close)
cout, cerr = process.communicate(e)
cout = cout.decode('latin-1')
p = p.decode('latin-1')
diff --git a/Lib/test/test_raise.py b/Lib/test/test_raise.py
index ff4800b954..d120dc1afa 100644
--- a/Lib/test/test_raise.py
+++ b/Lib/test/test_raise.py
@@ -28,7 +28,7 @@ class TestRaise(unittest.TestCase):
try:
raise
except RuntimeError as e:
- self.assertTrue("No active exception" in str(e))
+ self.assertIn("No active exception", str(e))
else:
self.fail("No exception raised")
@@ -127,7 +127,7 @@ class TestCause(unittest.TestCase):
try:
raise IndexError from 5
except TypeError as e:
- self.assertTrue("exception cause" in str(e))
+ self.assertIn("exception cause", str(e))
else:
self.fail("No exception raised")
@@ -135,7 +135,7 @@ class TestCause(unittest.TestCase):
try:
raise IndexError from KeyError
except IndexError as e:
- self.assertTrue(isinstance(e.__cause__, KeyError))
+ self.assertIsInstance(e.__cause__, KeyError)
else:
self.fail("No exception raised")
@@ -166,7 +166,7 @@ class TestTraceback(unittest.TestCase):
try:
raise IndexError()
except IndexError as e:
- self.assertTrue(isinstance(e.__traceback__, types.TracebackType))
+ self.assertIsInstance(e.__traceback__, types.TracebackType)
else:
self.fail("No exception raised")
@@ -203,7 +203,7 @@ class TestContext(unittest.TestCase):
raise OSError()
except OSError as e:
self.assertNotEqual(e.__context__, context)
- self.assertTrue(isinstance(e.__context__, context))
+ self.assertIsInstance(e.__context__, context)
else:
self.fail("No exception raised")
@@ -216,7 +216,7 @@ class TestContext(unittest.TestCase):
raise OSError
except OSError as e:
self.assertNotEqual(e.__context__, context)
- self.assertTrue(isinstance(e.__context__, context))
+ self.assertIsInstance(e.__context__, context)
else:
self.fail("No exception raised")
@@ -227,7 +227,7 @@ class TestContext(unittest.TestCase):
except:
raise OSError
except OSError as e:
- self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
+ self.assertIsInstance(e.__context__, ZeroDivisionError)
else:
self.fail("No exception raised")
@@ -238,7 +238,7 @@ class TestContext(unittest.TestCase):
except:
xyzzy
except NameError as e:
- self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
+ self.assertIsInstance(e.__context__, ZeroDivisionError)
else:
self.fail("No exception raised")
@@ -260,7 +260,7 @@ class TestContext(unittest.TestCase):
finally:
raise OSError
except OSError as e:
- self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
+ self.assertIsInstance(e.__context__, ZeroDivisionError)
else:
self.fail("No exception raised")
@@ -274,7 +274,7 @@ class TestContext(unittest.TestCase):
with ContextManager():
1/0
except NameError as e:
- self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
+ self.assertIsInstance(e.__context__, ZeroDivisionError)
else:
self.fail("No exception raised")
@@ -320,7 +320,7 @@ class TestContext(unittest.TestCase):
del g
raise KeyError
except Exception as e:
- self.assertTrue(isinstance(e.__context__, ValueError))
+ self.assertIsInstance(e.__context__, ValueError)
f()
@@ -344,7 +344,7 @@ class TestContext(unittest.TestCase):
raise TypeError
except Exception as e:
self.assertNotEqual(e.__context__, None)
- self.assertTrue(isinstance(e.__context__, AttributeError))
+ self.assertIsInstance(e.__context__, AttributeError)
with support.captured_output("stderr"):
f()
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index df07b76c0e..776d0c4163 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -1,11 +1,11 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
import random
import time
import pickle
import warnings
-from math import log, exp, sqrt, pi, fsum, sin
+from math import log, exp, pi, fsum, sin
from test import support
class TestBasicOps(unittest.TestCase):
@@ -39,9 +39,16 @@ class TestBasicOps(unittest.TestCase):
self.gen.seed(arg)
for arg in [list(range(3)), dict(one=1)]:
self.assertRaises(TypeError, self.gen.seed, arg)
- self.assertRaises(TypeError, self.gen.seed, 1, 2)
+ self.assertRaises(TypeError, self.gen.seed, 1, 2, 3, 4)
self.assertRaises(TypeError, type(self.gen), [])
+ def test_choice(self):
+ choice = self.gen.choice
+ with self.assertRaises(IndexError):
+ choice([])
+ self.assertEqual(choice([50]), 50)
+ self.assertIn(choice([25, 75]), [25, 75])
+
def test_sample(self):
# For the entire allowable range of 0 <= k <= N, validate that
# the sample is of the correct length and contains only unique items
@@ -121,7 +128,15 @@ class TestBasicOps(unittest.TestCase):
f = open(support.findfile(file),"rb")
r = pickle.load(f)
f.close()
- self.assertEqual(r.randrange(1000), value)
+ self.assertEqual(int(r.random()*1000), value)
+
+ def test_bug_9025(self):
+ # Had problem with an uneven distribution in int(n*random())
+ # Verify the fix by checking that distributions fall within expectations.
+ n = 100000
+ randrange = self.gen.randrange
+ k = sum(randrange(6755399441055744) % 3 == 2 for i in range(n))
+ self.assertTrue(0.30 < k/n < .37, (k/n))
class SystemRandom_TestBasicOps(TestBasicOps):
gen = random.SystemRandom()
@@ -211,7 +226,7 @@ class SystemRandom_TestBasicOps(TestBasicOps):
n += n - 1 # check 1 below the next power of two
k = int(1.00001 + _log(n, 2))
- self.assertTrue(k in [numbits, numbits+1])
+ self.assertIn(k, [numbits, numbits+1])
self.assertTrue(2**k > n > 2**(k-2))
n -= n >> 15 # check a little farther below the next power of two
@@ -223,6 +238,17 @@ class SystemRandom_TestBasicOps(TestBasicOps):
class MersenneTwister_TestBasicOps(TestBasicOps):
gen = random.Random()
+ def test_guaranteed_stable(self):
+ # These sequences are guaranteed to stay the same across versions of python
+ self.gen.seed(3456147, version=1)
+ self.assertEqual([self.gen.random().hex() for i in range(4)],
+ ['0x1.ac362300d90d2p-1', '0x1.9d16f74365005p-1',
+ '0x1.1ebb4352e4c4dp-1', '0x1.1a7422abf9c11p-1'])
+ self.gen.seed("the quick brown fox", version=2)
+ self.assertEqual([self.gen.random().hex() for i in range(4)],
+ ['0x1.1239ddfb11b7cp-3', '0x1.b3cbb5c51b120p-4',
+ '0x1.8c4f55116b60fp-1', '0x1.63eb525174a27p-1'])
+
def test_setstate_first_arg(self):
self.assertRaises(ValueError, self.gen.setstate, (1, None, None))
@@ -367,7 +393,7 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
n += n - 1 # check 1 below the next power of two
k = int(1.00001 + _log(n, 2))
- self.assertTrue(k in [numbits, numbits+1])
+ self.assertIn(k, [numbits, numbits+1])
self.assertTrue(2**k > n > 2**(k-2))
n -= n >> 15 # check a little farther below the next power of two
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index c082fd1756..fc310c1534 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -5,10 +5,6 @@ import sys
import pickle
import itertools
-import warnings
-warnings.filterwarnings("ignore", "integer argument expected",
- DeprecationWarning, "unittest")
-
# pure Python implementations (3 args only), for comparison
def pyrange(start, stop, step):
if (start - stop) // step < 0:
@@ -63,18 +59,18 @@ class RangeTest(unittest.TestCase):
self.assertEqual(list(range(a+4, a, -2)), [a+4, a+2])
seq = list(range(a, b, c))
- self.assertTrue(a in seq)
- self.assertTrue(b not in seq)
+ self.assertIn(a, seq)
+ self.assertNotIn(b, seq)
self.assertEqual(len(seq), 2)
seq = list(range(b, a, -c))
- self.assertTrue(b in seq)
- self.assertTrue(a not in seq)
+ self.assertIn(b, seq)
+ self.assertNotIn(a, seq)
self.assertEqual(len(seq), 2)
seq = list(range(-a, -b, -c))
- self.assertTrue(-a in seq)
- self.assertTrue(-b not in seq)
+ self.assertIn(-a, seq)
+ self.assertNotIn(-b, seq)
self.assertEqual(len(seq), 2)
self.assertRaises(TypeError, range)
@@ -94,6 +90,250 @@ class RangeTest(unittest.TestCase):
r = range(-sys.maxsize, sys.maxsize, 2)
self.assertEqual(len(r), sys.maxsize)
+ def test_large_operands(self):
+ x = range(10**20, 10**20+10, 3)
+ self.assertEqual(len(x), 4)
+ self.assertEqual(len(list(x)), 4)
+
+ x = range(10**20+10, 10**20, 3)
+ self.assertEqual(len(x), 0)
+ self.assertEqual(len(list(x)), 0)
+
+ x = range(10**20, 10**20+10, -3)
+ self.assertEqual(len(x), 0)
+ self.assertEqual(len(list(x)), 0)
+
+ x = range(10**20+10, 10**20, -3)
+ self.assertEqual(len(x), 4)
+ self.assertEqual(len(list(x)), 4)
+
+ # Now test range() with longs
+ self.assertEqual(list(range(-2**100)), [])
+ self.assertEqual(list(range(0, -2**100)), [])
+ self.assertEqual(list(range(0, 2**100, -1)), [])
+ self.assertEqual(list(range(0, 2**100, -1)), [])
+
+ a = int(10 * sys.maxsize)
+ b = int(100 * sys.maxsize)
+ c = int(50 * sys.maxsize)
+
+ self.assertEqual(list(range(a, a+2)), [a, a+1])
+ self.assertEqual(list(range(a+2, a, -1)), [a+2, a+1])
+ self.assertEqual(list(range(a+4, a, -2)), [a+4, a+2])
+
+ seq = list(range(a, b, c))
+ self.assertIn(a, seq)
+ self.assertNotIn(b, seq)
+ self.assertEqual(len(seq), 2)
+ self.assertEqual(seq[0], a)
+ self.assertEqual(seq[-1], a+c)
+
+ seq = list(range(b, a, -c))
+ self.assertIn(b, seq)
+ self.assertNotIn(a, seq)
+ self.assertEqual(len(seq), 2)
+ self.assertEqual(seq[0], b)
+ self.assertEqual(seq[-1], b-c)
+
+ seq = list(range(-a, -b, -c))
+ self.assertIn(-a, seq)
+ self.assertNotIn(-b, seq)
+ self.assertEqual(len(seq), 2)
+ self.assertEqual(seq[0], -a)
+ self.assertEqual(seq[-1], -a-c)
+
+ def test_large_range(self):
+ # Check long ranges (len > sys.maxsize)
+ # len() is expected to fail due to limitations of the __len__ protocol
+ def _range_len(x):
+ try:
+ length = len(x)
+ except OverflowError:
+ step = x[1] - x[0]
+ length = 1 + ((x[-1] - x[0]) // step)
+ return length
+ a = -sys.maxsize
+ b = sys.maxsize
+ expected_len = b - a
+ x = range(a, b)
+ self.assertIn(a, x)
+ self.assertNotIn(b, x)
+ self.assertRaises(OverflowError, len, x)
+ self.assertEqual(_range_len(x), expected_len)
+ self.assertEqual(x[0], a)
+ idx = sys.maxsize+1
+ self.assertEqual(x[idx], a+idx)
+ self.assertEqual(x[idx:idx+1][0], a+idx)
+ with self.assertRaises(IndexError):
+ x[-expected_len-1]
+ with self.assertRaises(IndexError):
+ x[expected_len]
+
+ a = 0
+ b = 2 * sys.maxsize
+ expected_len = b - a
+ x = range(a, b)
+ self.assertIn(a, x)
+ self.assertNotIn(b, x)
+ self.assertRaises(OverflowError, len, x)
+ self.assertEqual(_range_len(x), expected_len)
+ self.assertEqual(x[0], a)
+ idx = sys.maxsize+1
+ self.assertEqual(x[idx], a+idx)
+ self.assertEqual(x[idx:idx+1][0], a+idx)
+ with self.assertRaises(IndexError):
+ x[-expected_len-1]
+ with self.assertRaises(IndexError):
+ x[expected_len]
+
+ a = 0
+ b = sys.maxsize**10
+ c = 2*sys.maxsize
+ expected_len = 1 + (b - a) // c
+ x = range(a, b, c)
+ self.assertIn(a, x)
+ self.assertNotIn(b, x)
+ self.assertRaises(OverflowError, len, x)
+ self.assertEqual(_range_len(x), expected_len)
+ self.assertEqual(x[0], a)
+ idx = sys.maxsize+1
+ self.assertEqual(x[idx], a+(idx*c))
+ self.assertEqual(x[idx:idx+1][0], a+(idx*c))
+ with self.assertRaises(IndexError):
+ x[-expected_len-1]
+ with self.assertRaises(IndexError):
+ x[expected_len]
+
+ a = sys.maxsize**10
+ b = 0
+ c = -2*sys.maxsize
+ expected_len = 1 + (b - a) // c
+ x = range(a, b, c)
+ self.assertIn(a, x)
+ self.assertNotIn(b, x)
+ self.assertRaises(OverflowError, len, x)
+ self.assertEqual(_range_len(x), expected_len)
+ self.assertEqual(x[0], a)
+ idx = sys.maxsize+1
+ self.assertEqual(x[idx], a+(idx*c))
+ self.assertEqual(x[idx:idx+1][0], a+(idx*c))
+ with self.assertRaises(IndexError):
+ x[-expected_len-1]
+ with self.assertRaises(IndexError):
+ x[expected_len]
+
+ def test_invalid_invocation(self):
+ self.assertRaises(TypeError, range)
+ self.assertRaises(TypeError, range, 1, 2, 3, 4)
+ self.assertRaises(ValueError, range, 1, 2, 0)
+ a = int(10 * sys.maxsize)
+ self.assertRaises(ValueError, range, a, a + 1, int(0))
+ self.assertRaises(TypeError, range, 1., 1., 1.)
+ self.assertRaises(TypeError, range, 1e100, 1e101, 1e101)
+ self.assertRaises(TypeError, range, 0, "spam")
+ self.assertRaises(TypeError, range, 0, 42, "spam")
+ # Exercise various combinations of bad arguments, to check
+ # refcounting logic
+ self.assertRaises(TypeError, range, 0.0)
+ self.assertRaises(TypeError, range, 0, 0.0)
+ self.assertRaises(TypeError, range, 0.0, 0)
+ self.assertRaises(TypeError, range, 0.0, 0.0)
+ self.assertRaises(TypeError, range, 0, 0, 1.0)
+ self.assertRaises(TypeError, range, 0, 0.0, 1)
+ self.assertRaises(TypeError, range, 0, 0.0, 1.0)
+ self.assertRaises(TypeError, range, 0.0, 0, 1)
+ self.assertRaises(TypeError, range, 0.0, 0, 1.0)
+ self.assertRaises(TypeError, range, 0.0, 0.0, 1)
+ self.assertRaises(TypeError, range, 0.0, 0.0, 1.0)
+
+ def test_index(self):
+ u = range(2)
+ self.assertEqual(u.index(0), 0)
+ self.assertEqual(u.index(1), 1)
+ self.assertRaises(ValueError, u.index, 2)
+
+ u = range(-2, 3)
+ self.assertEqual(u.count(0), 1)
+ self.assertEqual(u.index(0), 2)
+ self.assertRaises(TypeError, u.index)
+
+ class BadExc(Exception):
+ pass
+
+ class BadCmp:
+ def __eq__(self, other):
+ if other == 2:
+ raise BadExc()
+ return False
+
+ a = range(4)
+ self.assertRaises(BadExc, a.index, BadCmp())
+
+ a = range(-2, 3)
+ self.assertEqual(a.index(0), 2)
+ self.assertEqual(range(1, 10, 3).index(4), 1)
+ self.assertEqual(range(1, -10, -3).index(-5), 2)
+
+ self.assertEqual(range(10**20).index(1), 1)
+ self.assertEqual(range(10**20).index(10**20 - 1), 10**20 - 1)
+
+ self.assertRaises(ValueError, range(1, 2**100, 2).index, 2**87)
+ self.assertEqual(range(1, 2**100, 2).index(2**87+1), 2**86)
+
+ class AlwaysEqual(object):
+ def __eq__(self, other):
+ return True
+ always_equal = AlwaysEqual()
+ self.assertEqual(range(10).index(always_equal), 0)
+
+ def test_user_index_method(self):
+ bignum = 2*sys.maxsize
+ smallnum = 42
+
+ # User-defined class with an __index__ method
+ class I:
+ def __init__(self, n):
+ self.n = int(n)
+ def __index__(self):
+ return self.n
+ self.assertEqual(list(range(I(bignum), I(bignum + 1))), [bignum])
+ self.assertEqual(list(range(I(smallnum), I(smallnum + 1))), [smallnum])
+
+ # User-defined class with a failing __index__ method
+ class IX:
+ def __index__(self):
+ raise RuntimeError
+ self.assertRaises(RuntimeError, range, IX())
+
+ # User-defined class with an invalid __index__ method
+ class IN:
+ def __index__(self):
+ return "not a number"
+
+ self.assertRaises(TypeError, range, IN())
+
+ def test_count(self):
+ self.assertEqual(range(3).count(-1), 0)
+ self.assertEqual(range(3).count(0), 1)
+ self.assertEqual(range(3).count(1), 1)
+ self.assertEqual(range(3).count(2), 1)
+ self.assertEqual(range(3).count(3), 0)
+ self.assertIs(type(range(3).count(-1)), int)
+ self.assertIs(type(range(3).count(1)), int)
+ self.assertEqual(range(10**20).count(1), 1)
+ self.assertEqual(range(10**20).count(10**20), 0)
+ self.assertEqual(range(3).index(1), 1)
+ self.assertEqual(range(1, 2**100, 2).count(2**87), 0)
+ self.assertEqual(range(1, 2**100, 2).count(2**87+1), 1)
+
+ class AlwaysEqual(object):
+ def __eq__(self, other):
+ return True
+ always_equal = AlwaysEqual()
+ self.assertEqual(range(10).count(always_equal), 10)
+
+ self.assertEqual(len(range(sys.maxsize, sys.maxsize+10)), 10)
+
def test_repr(self):
self.assertEqual(repr(range(1)), 'range(0, 1)')
self.assertEqual(repr(range(1, 2)), 'range(1, 2)')
@@ -115,6 +355,62 @@ class RangeTest(unittest.TestCase):
with self.assertRaises(TypeError):
range([], 1, -1)
+ def test_types(self):
+ # Non-integer objects *equal* to any of the range's items are supposed
+ # to be contained in the range.
+ self.assertIn(1.0, range(3))
+ self.assertIn(True, range(3))
+ self.assertIn(1+0j, range(3))
+
+ class C1:
+ def __eq__(self, other): return True
+ self.assertIn(C1(), range(3))
+
+ # Objects are never coerced into other types for comparison.
+ class C2:
+ def __int__(self): return 1
+ def __index__(self): return 1
+ self.assertNotIn(C2(), range(3))
+ # ..except if explicitly told so.
+ self.assertIn(int(C2()), range(3))
+
+ # Check that the range.__contains__ optimization is only
+ # used for ints, not for instances of subclasses of int.
+ class C3(int):
+ def __eq__(self, other): return True
+ self.assertIn(C3(11), range(10))
+ self.assertIn(C3(11), list(range(10)))
+
+ def test_strided_limits(self):
+ r = range(0, 101, 2)
+ self.assertIn(0, r)
+ self.assertNotIn(1, r)
+ self.assertIn(2, r)
+ self.assertNotIn(99, r)
+ self.assertIn(100, r)
+ self.assertNotIn(101, r)
+
+ r = range(0, -20, -1)
+ self.assertIn(0, r)
+ self.assertIn(-1, r)
+ self.assertIn(-19, r)
+ self.assertNotIn(-20, r)
+
+ r = range(0, -20, -2)
+ self.assertIn(-18, r)
+ self.assertNotIn(-19, r)
+ self.assertNotIn(-20, r)
+
+ def test_empty(self):
+ r = range(0)
+ self.assertNotIn(0, r)
+ self.assertNotIn(1, r)
+
+ r = range(0, -10)
+ self.assertNotIn(0, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(1, r)
+
def test_range_iterators(self):
# exercise 'fast' iterators, that use a rangeiterobject internally.
# see issue 7298
@@ -139,6 +435,70 @@ class RangeTest(unittest.TestCase):
test_id = "reversed(range({}, {}, {}))".format(start, end, step)
self.assert_iterators_equal(iter1, iter2, test_id, limit=100)
+ def test_slice(self):
+ def check(start, stop, step=None):
+ i = slice(start, stop, step)
+ self.assertEqual(list(r[i]), list(r)[i])
+ self.assertEqual(len(r[i]), len(list(r)[i]))
+ for r in [range(10),
+ range(0),
+ range(1, 9, 3),
+ range(8, 0, -3),
+ range(sys.maxsize+1, sys.maxsize+10),
+ ]:
+ check(0, 2)
+ check(0, 20)
+ check(1, 2)
+ check(20, 30)
+ check(-30, -20)
+ check(-1, 100, 2)
+ check(0, -1)
+ check(-1, -3, -1)
+
+ def test_contains(self):
+ r = range(10)
+ self.assertIn(0, r)
+ self.assertIn(1, r)
+ self.assertIn(5.0, r)
+ self.assertNotIn(5.1, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(10, r)
+ self.assertNotIn("", r)
+ r = range(9, -1, -1)
+ self.assertIn(0, r)
+ self.assertIn(1, r)
+ self.assertIn(5.0, r)
+ self.assertNotIn(5.1, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(10, r)
+ self.assertNotIn("", r)
+ r = range(0, 10, 2)
+ self.assertIn(0, r)
+ self.assertNotIn(1, r)
+ self.assertNotIn(5.0, r)
+ self.assertNotIn(5.1, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(10, r)
+ self.assertNotIn("", r)
+ r = range(9, -1, -2)
+ self.assertNotIn(0, r)
+ self.assertIn(1, r)
+ self.assertIn(5.0, r)
+ self.assertNotIn(5.1, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(10, r)
+ self.assertNotIn("", r)
+
+ def test_reverse_iteration(self):
+ for r in [range(10),
+ range(0),
+ range(1, 9, 3),
+ range(8, 0, -3),
+ range(sys.maxsize+1, sys.maxsize+10),
+ ]:
+ self.assertEqual(list(reversed(r)), list(r)[::-1])
+
+
def test_main():
test.support.run_unittest(RangeTest)
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 268d66d31a..e4b33c9ae5 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1,7 +1,7 @@
from test.support import verbose, run_unittest
import re
from re import Scanner
-import sys, os, traceback
+import sys, traceback
from weakref import proxy
# Misc tests from Tim Peters' re.doc
@@ -605,6 +605,27 @@ class ReTests(unittest.TestCase):
self.assertEqual(next(iter).span(), (4, 4))
self.assertRaises(StopIteration, next, iter)
+ def test_bug_6561(self):
+ # '\d' should match characters in Unicode category 'Nd'
+ # (Number, Decimal Digit), but not those in 'Nl' (Number,
+ # Letter) or 'No' (Number, Other).
+ decimal_digits = [
+ '\u0037', # '\N{DIGIT SEVEN}', category 'Nd'
+ '\u0e58', # '\N{THAI DIGIT SIX}', category 'Nd'
+ '\uff10', # '\N{FULLWIDTH DIGIT ZERO}', category 'Nd'
+ ]
+ for x in decimal_digits:
+ self.assertEqual(re.match('^\d$', x).group(0), x)
+
+ not_decimal_digits = [
+ '\u2165', # '\N{ROMAN NUMERAL SIX}', category 'Nl'
+ '\u3039', # '\N{HANGZHOU NUMERAL TWENTY}', category 'Nl'
+ '\u2082', # '\N{SUBSCRIPT TWO}', category 'No'
+ '\u32b4', # '\N{CIRCLED NUMBER THIRTY NINE}', category 'No'
+ ]
+ for x in not_decimal_digits:
+ self.assertIsNone(re.match('^\d$', x))
+
def test_empty_array(self):
# SF buf 1647541
import array
@@ -727,7 +748,7 @@ class ReTests(unittest.TestCase):
self.assertRaises(TypeError, _sre.compile, {}, 0, [])
def run_re_tests():
- from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR
+ from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose:
print('Running re_tests test suite')
else:
@@ -853,6 +874,7 @@ def run_re_tests():
if result is None:
print('=== Fails on unicode-sensitive match', t)
+
def test_main():
run_unittest(ReTests)
run_re_tests()
diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py
new file mode 100644
index 0000000000..5483dd31b8
--- /dev/null
+++ b/Lib/test/test_readline.py
@@ -0,0 +1,47 @@
+"""
+Very minimal unittests for parts of the readline module.
+
+These tests were added to check that the libedit emulation on OSX and
+the "real" readline have the same interface for history manipulation. That's
+why the tests cover only a small subset of the interface.
+"""
+import unittest
+from test.support import run_unittest, import_module
+
+# Skip tests if there is no readline module
+readline = import_module('readline')
+
+class TestHistoryManipulation (unittest.TestCase):
+
+ @unittest.skipIf(not hasattr(readline, 'clear_history'),
+ "The history update test cannot be run because the "
+ "clear_history method is not available.")
+ def testHistoryUpdates(self):
+ readline.clear_history()
+
+ readline.add_history("first line")
+ readline.add_history("second line")
+
+ self.assertEqual(readline.get_history_item(0), None)
+ self.assertEqual(readline.get_history_item(1), "first line")
+ self.assertEqual(readline.get_history_item(2), "second line")
+
+ readline.replace_history_item(0, "replaced line")
+ self.assertEqual(readline.get_history_item(0), None)
+ self.assertEqual(readline.get_history_item(1), "replaced line")
+ self.assertEqual(readline.get_history_item(2), "second line")
+
+ self.assertEqual(readline.get_current_history_length(), 2)
+
+ readline.remove_history_item(0)
+ self.assertEqual(readline.get_history_item(0), None)
+ self.assertEqual(readline.get_history_item(1), "second line")
+
+ self.assertEqual(readline.get_current_history_length(), 1)
+
+
+def test_main():
+ run_unittest(TestHistoryManipulation)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py
index ce6ecb67f7..b0dc4d7813 100644
--- a/Lib/test/test_reprlib.py
+++ b/Lib/test/test_reprlib.py
@@ -11,6 +11,7 @@ import unittest
from test.support import run_unittest
from reprlib import repr as r # Don't shadow builtin repr
from reprlib import Repr
+from reprlib import recursive_repr
def nestedTuple(nesting):
@@ -125,7 +126,7 @@ class ReprTests(unittest.TestCase):
s = r(ClassWithFailingRepr)
self.assertTrue(s.startswith("<class "))
self.assertTrue(s.endswith(">"))
- self.assertTrue(s.find("...") in [12, 13])
+ self.assertIn(s.find("..."), [12, 13])
def test_lambda(self):
self.assertTrue(repr(lambda x: x).startswith(
@@ -301,11 +302,38 @@ class ClassWithFailingRepr:
def __repr__(self):
raise Exception("This should be caught by Repr.repr_instance")
+class MyContainer:
+ 'Helper class for TestRecursiveRepr'
+ def __init__(self, values):
+ self.values = list(values)
+ def append(self, value):
+ self.values.append(value)
+ @recursive_repr()
+ def __repr__(self):
+ return '<' + ', '.join(map(str, self.values)) + '>'
+
+class MyContainer2(MyContainer):
+ @recursive_repr('+++')
+ def __repr__(self):
+ return '<' + ', '.join(map(str, self.values)) + '>'
+
+class TestRecursiveRepr(unittest.TestCase):
+ def test_recursive_repr(self):
+ m = MyContainer(list('abcde'))
+ m.append(m)
+ m.append('x')
+ m.append(m)
+ self.assertEqual(repr(m), '<a, b, c, d, e, ..., x, ...>')
+ m = MyContainer2(list('abcde'))
+ m.append(m)
+ m.append('x')
+ m.append(m)
+ self.assertEqual(repr(m), '<a, b, c, d, e, +++, x, +++>')
def test_main():
run_unittest(ReprTests)
- if os.name != 'mac':
- run_unittest(LongReprTest)
+ run_unittest(LongReprTest)
+ run_unittest(TestRecursiveRepr)
if __name__ == "__main__":
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 454634922b..3c9b620702 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -102,6 +102,10 @@ class ResourceTest(unittest.TestCase):
usageboth = resource.getrusage(resource.RUSAGE_BOTH)
except (ValueError, AttributeError):
pass
+ try:
+ usage_thread = resource.getrusage(resource.RUSAGE_THREAD)
+ except (ValueError, AttributeError):
+ pass
def test_main(verbose=None):
support.run_unittest(ResourceTest)
diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py
index a788c60dc4..f8f3717b64 100644
--- a/Lib/test/test_richcmp.py
+++ b/Lib/test/test_richcmp.py
@@ -192,12 +192,12 @@ class MiscTest(unittest.TestCase):
def test_misbehavin(self):
class Misb:
- def __lt__(self, other): return 0
- def __gt__(self, other): return 0
- def __eq__(self, other): return 0
- def __le__(self, other): raise TestFailed("This shouldn't happen")
- def __ge__(self, other): raise TestFailed("This shouldn't happen")
- def __ne__(self, other): raise TestFailed("This shouldn't happen")
+ def __lt__(self_, other): return 0
+ def __gt__(self_, other): return 0
+ def __eq__(self_, other): return 0
+ def __le__(self_, other): self.fail("This shouldn't happen")
+ def __ge__(self_, other): self.fail("This shouldn't happen")
+ def __ne__(self_, other): self.fail("This shouldn't happen")
a = Misb()
b = Misb()
self.assertEqual(a<b, 0)
@@ -279,9 +279,6 @@ class DictTest(unittest.TestCase):
class ListTest(unittest.TestCase):
- def assertIs(self, a, b):
- self.assertTrue(a is b)
-
def test_coverage(self):
# exercise all comparisons for lists
x = [42]
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py
index 43141e5817..ad3ab397f4 100644
--- a/Lib/test/test_runpy.py
+++ b/Lib/test/test_runpy.py
@@ -3,10 +3,15 @@ import unittest
import os
import os.path
import sys
+import re
import tempfile
-from test.support import verbose, run_unittest, forget
-from runpy import _run_code, _run_module_code, run_module
+import py_compile
+from test.support import forget, make_legacy_pyc, run_unittest, unload, verbose
+from test.script_helper import (
+ make_pkg, make_script, make_zip_pkg, make_zip_script, temp_dir)
+
+from runpy import _run_code, _run_module_code, run_module, run_path
# Note: This module can't safely test _run_module_as_main as it
# runs its tests in the current process, which would mess with the
# real __main__ module (usually test.regrtest)
@@ -15,6 +20,7 @@ from runpy import _run_code, _run_module_code, run_module
# Set up the test code and expected results
class RunModuleCodeTest(unittest.TestCase):
+ """Unit tests for runpy._run_code and runpy._run_module_code"""
expected_result = ["Top level assignment", "Lower level reference"]
test_source = (
@@ -37,14 +43,15 @@ class RunModuleCodeTest(unittest.TestCase):
def test_run_code(self):
saved_argv0 = sys.argv[0]
d = _run_code(self.test_source, {})
- self.assertTrue(d["result"] == self.expected_result)
- self.assertTrue(d["__name__"] is None)
- self.assertTrue(d["__file__"] is None)
- self.assertTrue(d["__loader__"] is None)
- self.assertTrue(d["__package__"] is None)
- self.assertTrue(d["run_argv0"] is saved_argv0)
- self.assertTrue("run_name" not in d)
- self.assertTrue(sys.argv[0] is saved_argv0)
+ self.assertEqual(d["result"], self.expected_result)
+ self.assertIs(d["__name__"], None)
+ self.assertIs(d["__file__"], None)
+ self.assertIs(d["__cached__"], None)
+ self.assertIs(d["__loader__"], None)
+ self.assertIs(d["__package__"], None)
+ self.assertIs(d["run_argv0"], saved_argv0)
+ self.assertNotIn("run_name", d)
+ self.assertIs(sys.argv[0], saved_argv0)
def test_run_module_code(self):
initial = object()
@@ -60,22 +67,24 @@ class RunModuleCodeTest(unittest.TestCase):
file,
loader,
package)
- self.assertTrue("result" not in d1)
- self.assertTrue(d2["initial"] is initial)
+ self.assertNotIn("result", d1)
+ self.assertIs(d2["initial"], initial)
self.assertEqual(d2["result"], self.expected_result)
self.assertEqual(d2["nested"]["x"], 1)
- self.assertTrue(d2["__name__"] is name)
+ self.assertIs(d2["__name__"], name)
self.assertTrue(d2["run_name_in_sys_modules"])
self.assertTrue(d2["module_in_sys_modules"])
- self.assertTrue(d2["__file__"] is file)
- self.assertTrue(d2["run_argv0"] is file)
- self.assertTrue(d2["__loader__"] is loader)
- self.assertTrue(d2["__package__"] is package)
- self.assertTrue(sys.argv[0] is saved_argv0)
- self.assertTrue(name not in sys.modules)
+ self.assertIs(d2["__file__"], file)
+ self.assertIs(d2["__cached__"], None)
+ self.assertIs(d2["run_argv0"], file)
+ self.assertIs(d2["__loader__"], loader)
+ self.assertIs(d2["__package__"], package)
+ self.assertIs(sys.argv[0], saved_argv0)
+ self.assertNotIn(name, sys.modules)
class RunModuleTest(unittest.TestCase):
+ """Unit tests for runpy.run_module"""
def expect_import_error(self, mod_name):
try:
@@ -94,8 +103,8 @@ class RunModuleTest(unittest.TestCase):
self.expect_import_error("a.bee")
self.expect_import_error(".howard")
self.expect_import_error("..eaten")
- # Package
- self.expect_import_error("logging")
+ # Package without __main__.py
+ self.expect_import_error("multiprocessing")
def test_library_module(self):
run_module("runpy")
@@ -107,9 +116,9 @@ class RunModuleTest(unittest.TestCase):
pkg_file.close()
return pkg_fname
- def _make_pkg(self, source, depth):
+ def _make_pkg(self, source, depth, mod_base="runpy_test"):
pkg_name = "__runpy_pkg__"
- test_fname = "runpy_test.py"
+ test_fname = mod_base+os.extsep+"py"
pkg_dir = sub_dir = tempfile.mkdtemp()
if verbose: print(" Package tree in:", sub_dir)
sys.path.insert(0, pkg_dir)
@@ -124,7 +133,7 @@ class RunModuleTest(unittest.TestCase):
mod_file.write(source)
mod_file.close()
if verbose: print(" Created:", mod_fname)
- mod_name = (pkg_name+".")*depth + "runpy_test"
+ mod_name = (pkg_name+".")*depth + mod_base
return pkg_dir, mod_fname, mod_name
def _del_pkg(self, top, depth, mod_name):
@@ -159,20 +168,46 @@ class RunModuleTest(unittest.TestCase):
try:
if verbose: print("Running from source:", mod_name)
d1 = run_module(mod_name) # Read from source
- self.assertTrue("x" in d1)
+ self.assertIn("x", d1)
self.assertEqual(d1["x"], 1)
del d1 # Ensure __loader__ entry doesn't keep file open
__import__(mod_name)
os.remove(mod_fname)
+ make_legacy_pyc(mod_fname)
+ unload(mod_name) # In case loader caches paths
if verbose: print("Running from compiled:", mod_name)
d2 = run_module(mod_name) # Read from bytecode
- self.assertTrue("x" in d2)
+ self.assertIn("x", d2)
self.assertEqual(d2["x"], 1)
del d2 # Ensure __loader__ entry doesn't keep file open
finally:
self._del_pkg(pkg_dir, depth, mod_name)
if verbose: print("Module executed successfully")
+ def _check_package(self, depth):
+ pkg_dir, mod_fname, mod_name = (
+ self._make_pkg("x=1\n", depth, "__main__"))
+ pkg_name, _, _ = mod_name.rpartition(".")
+ forget(mod_name)
+ try:
+ if verbose: print("Running from source:", pkg_name)
+ d1 = run_module(pkg_name) # Read from source
+ self.assertIn("x", d1)
+ self.assertTrue(d1["x"] == 1)
+ del d1 # Ensure __loader__ entry doesn't keep file open
+ __import__(mod_name)
+ os.remove(mod_fname)
+ make_legacy_pyc(mod_fname)
+ unload(mod_name) # In case loader caches paths
+ if verbose: print("Running from compiled:", pkg_name)
+ d2 = run_module(pkg_name) # Read from bytecode
+ self.assertIn("x", d2)
+ self.assertTrue(d2["x"] == 1)
+ del d2 # Ensure __loader__ entry doesn't keep file open
+ finally:
+ self._del_pkg(pkg_dir, depth, pkg_name)
+ if verbose: print("Package executed successfully")
+
def _add_relative_modules(self, base_dir, source, depth):
if depth <= 1:
raise ValueError("Relative module test needs depth > 1")
@@ -211,19 +246,21 @@ from ..uncle.cousin import nephew
pkg_name = mod_name.rpartition('.')[0]
if verbose: print("Running from source:", mod_name)
d1 = run_module(mod_name, run_name=run_name) # Read from source
- self.assertTrue("__package__" in d1)
+ self.assertIn("__package__", d1)
self.assertTrue(d1["__package__"] == pkg_name)
- self.assertTrue("sibling" in d1)
- self.assertTrue("nephew" in d1)
+ self.assertIn("sibling", d1)
+ self.assertIn("nephew", d1)
del d1 # Ensure __loader__ entry doesn't keep file open
__import__(mod_name)
os.remove(mod_fname)
+ make_legacy_pyc(mod_fname)
+ unload(mod_name) # In case the loader caches paths
if verbose: print("Running from compiled:", mod_name)
d2 = run_module(mod_name, run_name=run_name) # Read from bytecode
- self.assertTrue("__package__" in d2)
+ self.assertIn("__package__", d2)
self.assertTrue(d2["__package__"] == pkg_name)
- self.assertTrue("sibling" in d2)
- self.assertTrue("nephew" in d2)
+ self.assertIn("sibling", d2)
+ self.assertIn("nephew", d2)
del d2 # Ensure __loader__ entry doesn't keep file open
finally:
self._del_pkg(pkg_dir, depth, mod_name)
@@ -234,6 +271,11 @@ from ..uncle.cousin import nephew
if verbose: print("Testing package depth:", depth)
self._check_module(depth)
+ def test_run_package(self):
+ for depth in range(1, 4):
+ if verbose: print("Testing package depth:", depth)
+ self._check_package(depth)
+
def test_explicit_relative_import(self):
for depth in range(2, 5):
if verbose: print("Testing relative imports at depth:", depth)
@@ -245,9 +287,132 @@ from ..uncle.cousin import nephew
self._check_relative_imports(depth, "__main__")
+class RunPathTest(unittest.TestCase):
+ """Unit tests for runpy.run_path"""
+ # Based on corresponding tests in test_cmd_line_script
+
+ test_source = """\
+# Script may be run with optimisation enabled, so don't rely on assert
+# statements being executed
+def assertEqual(lhs, rhs):
+ if lhs != rhs:
+ raise AssertionError('%r != %r' % (lhs, rhs))
+def assertIs(lhs, rhs):
+ if lhs is not rhs:
+ raise AssertionError('%r is not %r' % (lhs, rhs))
+# Check basic code execution
+result = ['Top level assignment']
+def f():
+ result.append('Lower level reference')
+f()
+assertEqual(result, ['Top level assignment', 'Lower level reference'])
+# Check the sys module
+import sys
+assertIs(globals(), sys.modules[__name__].__dict__)
+argv0 = sys.argv[0]
+"""
+
+ def _make_test_script(self, script_dir, script_basename, source=None):
+ if source is None:
+ source = self.test_source
+ return make_script(script_dir, script_basename, source)
+
+ def _check_script(self, script_name, expected_name, expected_file,
+ expected_argv0, expected_package):
+ result = run_path(script_name)
+ self.assertEqual(result["__name__"], expected_name)
+ self.assertEqual(result["__file__"], expected_file)
+ self.assertEqual(result["__cached__"], None)
+ self.assertIn("argv0", result)
+ self.assertEqual(result["argv0"], expected_argv0)
+ self.assertEqual(result["__package__"], expected_package)
+
+ def _check_import_error(self, script_name, msg):
+ msg = re.escape(msg)
+ self.assertRaisesRegex(ImportError, msg, run_path, script_name)
+
+ def test_basic_script(self):
+ with temp_dir() as script_dir:
+ mod_name = 'script'
+ script_name = self._make_test_script(script_dir, mod_name)
+ self._check_script(script_name, "<run_path>", script_name,
+ script_name, None)
+
+ def test_script_compiled(self):
+ with temp_dir() as script_dir:
+ mod_name = 'script'
+ script_name = self._make_test_script(script_dir, mod_name)
+ compiled_name = py_compile.compile(script_name, doraise=True)
+ os.remove(script_name)
+ self._check_script(compiled_name, "<run_path>", compiled_name,
+ compiled_name, None)
+
+ def test_directory(self):
+ with temp_dir() as script_dir:
+ mod_name = '__main__'
+ script_name = self._make_test_script(script_dir, mod_name)
+ self._check_script(script_dir, "<run_path>", script_name,
+ script_dir, '')
+
+ def test_directory_compiled(self):
+ with temp_dir() as script_dir:
+ mod_name = '__main__'
+ script_name = self._make_test_script(script_dir, mod_name)
+ compiled_name = py_compile.compile(script_name, doraise=True)
+ os.remove(script_name)
+ legacy_pyc = make_legacy_pyc(script_name)
+ self._check_script(script_dir, "<run_path>", legacy_pyc,
+ script_dir, '')
+
+ def test_directory_error(self):
+ with temp_dir() as script_dir:
+ mod_name = 'not_main'
+ script_name = self._make_test_script(script_dir, mod_name)
+ msg = "can't find '__main__' module in %r" % script_dir
+ self._check_import_error(script_dir, msg)
+
+ def test_zipfile(self):
+ with temp_dir() as script_dir:
+ mod_name = '__main__'
+ script_name = self._make_test_script(script_dir, mod_name)
+ zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
+ self._check_script(zip_name, "<run_path>", fname, zip_name, '')
+
+ def test_zipfile_compiled(self):
+ with temp_dir() as script_dir:
+ mod_name = '__main__'
+ script_name = self._make_test_script(script_dir, mod_name)
+ compiled_name = py_compile.compile(script_name, doraise=True)
+ zip_name, fname = make_zip_script(script_dir, 'test_zip',
+ compiled_name)
+ self._check_script(zip_name, "<run_path>", fname, zip_name, '')
+
+ def test_zipfile_error(self):
+ with temp_dir() as script_dir:
+ mod_name = 'not_main'
+ script_name = self._make_test_script(script_dir, mod_name)
+ zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
+ msg = "can't find '__main__' module in %r" % zip_name
+ self._check_import_error(zip_name, msg)
+
+ def test_main_recursion_error(self):
+ with temp_dir() as script_dir, temp_dir() as dummy_dir:
+ mod_name = '__main__'
+ source = ("import runpy\n"
+ "runpy.run_path(%r)\n") % dummy_dir
+ script_name = self._make_test_script(script_dir, mod_name, source)
+ zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
+ msg = "recursion depth exceeded"
+ self.assertRaisesRegex(RuntimeError, msg, run_path, zip_name)
+
+
+
def test_main():
- run_unittest(RunModuleCodeTest)
- run_unittest(RunModuleTest)
+ run_unittest(
+ RunModuleCodeTest,
+ RunModuleTest,
+ RunPathTest
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index 6c9147a852..0f6a1ca96c 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -16,7 +16,14 @@ from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
from io import StringIO
from test.support import findfile, run_unittest
import unittest
-import os
+
+TEST_XMLFILE = findfile("test.xml", subdir="xmltestdata")
+TEST_XMLFILE_OUT = findfile("test.xml.out", subdir="xmltestdata")
+try:
+ TEST_XMLFILE.encode("utf8")
+ TEST_XMLFILE_OUT.encode("utf8")
+except UnicodeEncodeError:
+ raise unittest.SkipTest("filename is not encodable to utf8")
ns_uri = "http://www.python.org/xml-ns/saxtest/"
@@ -31,7 +38,7 @@ class XmlTestBase(unittest.TestCase):
self.assertEqual(attrs.getNames(), [])
self.assertEqual(attrs.getQNames(), [])
self.assertEqual(len(attrs), 0)
- self.assertFalse("attr" in attrs)
+ self.assertNotIn("attr", attrs)
self.assertEqual(list(attrs.keys()), [])
self.assertEqual(attrs.get("attrs"), None)
self.assertEqual(attrs.get("attrs", 25), 25)
@@ -48,7 +55,7 @@ class XmlTestBase(unittest.TestCase):
self.assertEqual(attrs.getNames(), [])
self.assertEqual(attrs.getQNames(), [])
self.assertEqual(len(attrs), 0)
- self.assertFalse((ns_uri, "attr") in attrs)
+ self.assertNotIn((ns_uri, "attr"), attrs)
self.assertEqual(list(attrs.keys()), [])
self.assertEqual(attrs.get((ns_uri, "attr")), None)
self.assertEqual(attrs.get((ns_uri, "attr"), 25), 25)
@@ -60,7 +67,7 @@ class XmlTestBase(unittest.TestCase):
self.assertEqual(attrs.getNames(), ["attr"])
self.assertEqual(attrs.getQNames(), ["attr"])
self.assertEqual(len(attrs), 1)
- self.assertTrue("attr" in attrs)
+ self.assertIn("attr", attrs)
self.assertEqual(list(attrs.keys()), ["attr"])
self.assertEqual(attrs.get("attr"), "val")
self.assertEqual(attrs.get("attr", 25), "val")
@@ -140,7 +147,7 @@ class SaxutilsTest(unittest.TestCase):
def test_single_double_quoteattr(self):
self.assertEqual(quoteattr("Includes 'single' and \"double\" quotes"),
- "\"Includes 'single' and &quot;double&quot; quotes\"")
+ "\"Includes 'single' and &quot;double&quot; quotes\"")
# ===== make_parser
def test_make_parser(self):
@@ -164,6 +171,16 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start + "<doc></doc>")
+ def test_xmlgen_basic_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+ gen.startDocument()
+ gen.startElement("doc", {})
+ gen.endElement("doc")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start + "<doc/>")
+
def test_xmlgen_content(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -176,6 +193,18 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start + "<doc>huhei</doc>")
+ def test_xmlgen_content_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startElement("doc", {})
+ gen.characters("huhei")
+ gen.endElement("doc")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start + "<doc>huhei</doc>")
+
def test_xmlgen_pi(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -233,6 +262,18 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start + "<doc> </doc>")
+ def test_xmlgen_ignorable_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startElement("doc", {})
+ gen.ignorableWhitespace(" ")
+ gen.endElement("doc")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start + "<doc> </doc>")
+
def test_xmlgen_ns(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -251,6 +292,24 @@ class XmlgenTest(unittest.TestCase):
('<ns1:doc xmlns:ns1="%s"><udoc></udoc></ns1:doc>' %
ns_uri))
+ def test_xmlgen_ns_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startPrefixMapping("ns1", ns_uri)
+ gen.startElementNS((ns_uri, "doc"), "ns1:doc", {})
+ # add an unqualified name
+ gen.startElementNS((None, "udoc"), None, {})
+ gen.endElementNS((None, "udoc"), None)
+ gen.endElementNS((ns_uri, "doc"), "ns1:doc")
+ gen.endPrefixMapping("ns1")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start + \
+ ('<ns1:doc xmlns:ns1="%s"><udoc/></ns1:doc>' %
+ ns_uri))
+
def test_1463026_1(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -262,6 +321,17 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start+'<a b="c"></a>')
+ def test_1463026_1_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startElementNS((None, 'a'), 'a', {(None, 'b'):'c'})
+ gen.endElementNS((None, 'a'), 'a')
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start+'<a b="c"/>')
+
def test_1463026_2(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -275,6 +345,19 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start+'<a xmlns="qux"></a>')
+ def test_1463026_2_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startPrefixMapping(None, 'qux')
+ gen.startElementNS(('qux', 'a'), 'a', {})
+ gen.endElementNS(('qux', 'a'), 'a')
+ gen.endPrefixMapping(None)
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start+'<a xmlns="qux"/>')
+
def test_1463026_3(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -289,6 +372,20 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(),
start+'<my:a xmlns:my="qux" b="c"></my:a>')
+ def test_1463026_3_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startPrefixMapping('my', 'qux')
+ gen.startElementNS(('qux', 'a'), 'a', {(None, 'b'):'c'})
+ gen.endElementNS(('qux', 'a'), 'a')
+ gen.endPrefixMapping('my')
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(),
+ start+'<my:a xmlns:my="qux" b="c"/>')
+
def test_5027_1(self):
# The xml prefix (as in xml:lang below) is reserved and bound by
# definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had
@@ -366,7 +463,8 @@ class XMLFilterBaseTest(unittest.TestCase):
#
# ===========================================================================
-xml_test_out = open(findfile("test.xml.out")).read()
+with open(TEST_XMLFILE_OUT) as f:
+ xml_test_out = f.read()
class ExpatReaderTest(XmlTestBase):
@@ -378,7 +476,8 @@ class ExpatReaderTest(XmlTestBase):
xmlgen = XMLGenerator(result)
parser.setContentHandler(xmlgen)
- parser.parse(open(findfile("test.xml")))
+ with open(TEST_XMLFILE) as f:
+ parser.parse(f)
self.assertEqual(result.getvalue(), xml_test_out)
@@ -491,7 +590,7 @@ class ExpatReaderTest(XmlTestBase):
self.assertTrue((attrs.getQNames() == [] or
attrs.getQNames() == ["ns:attr"]))
self.assertEqual(len(attrs), 1)
- self.assertTrue((ns_uri, "attr") in attrs)
+ self.assertIn((ns_uri, "attr"), attrs)
self.assertEqual(attrs.get((ns_uri, "attr")), "val")
self.assertEqual(attrs.get((ns_uri, "attr"), 25), "val")
self.assertEqual(list(attrs.items()), [((ns_uri, "attr"), "val")])
@@ -507,7 +606,7 @@ class ExpatReaderTest(XmlTestBase):
xmlgen = XMLGenerator(result)
parser.setContentHandler(xmlgen)
- parser.parse(findfile("test.xml"))
+ parser.parse(TEST_XMLFILE)
self.assertEqual(result.getvalue(), xml_test_out)
@@ -517,7 +616,7 @@ class ExpatReaderTest(XmlTestBase):
xmlgen = XMLGenerator(result)
parser.setContentHandler(xmlgen)
- parser.parse(InputSource(findfile("test.xml")))
+ parser.parse(InputSource(TEST_XMLFILE))
self.assertEqual(result.getvalue(), xml_test_out)
@@ -528,8 +627,9 @@ class ExpatReaderTest(XmlTestBase):
parser.setContentHandler(xmlgen)
inpsrc = InputSource()
- inpsrc.setByteStream(open(findfile("test.xml")))
- parser.parse(inpsrc)
+ with open(TEST_XMLFILE) as f:
+ inpsrc.setByteStream(f)
+ parser.parse(inpsrc)
self.assertEqual(result.getvalue(), xml_test_out)
@@ -589,9 +689,9 @@ class ExpatReaderTest(XmlTestBase):
xmlgen = XMLGenerator(result)
parser = create_parser()
parser.setContentHandler(xmlgen)
- parser.parse(findfile("test.xml"))
+ parser.parse(TEST_XMLFILE)
- self.assertEqual(parser.getSystemId(), findfile("test.xml"))
+ self.assertEqual(parser.getSystemId(), TEST_XMLFILE)
self.assertEqual(parser.getPublicId(), None)
@@ -681,7 +781,7 @@ class XmlReaderTest(XmlTestBase):
self.assertEqual(attrs.getNames(), [(ns_uri, "attr")])
self.assertEqual(attrs.getQNames(), ["ns:attr"])
self.assertEqual(len(attrs), 1)
- self.assertTrue((ns_uri, "attr") in attrs)
+ self.assertIn((ns_uri, "attr"), attrs)
self.assertEqual(list(attrs.keys()), [(ns_uri, "attr")])
self.assertEqual(attrs.get((ns_uri, "attr")), "val")
self.assertEqual(attrs.get((ns_uri, "attr"), 25), "val")
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py
new file mode 100644
index 0000000000..29fd277746
--- /dev/null
+++ b/Lib/test/test_sched.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+
+import sched
+import time
+import unittest
+from test import support
+
+
+class TestCase(unittest.TestCase):
+
+ def test_enter(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
+ z = scheduler.enter(x, 1, fun, (x,))
+ scheduler.run()
+ self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])
+
+ def test_enterabs(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
+ z = scheduler.enterabs(x, 1, fun, (x,))
+ scheduler.run()
+ self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])
+
+ def test_priority(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ for priority in [1, 2, 3, 4, 5]:
+ z = scheduler.enter(0.01, priority, fun, (priority,))
+ scheduler.run()
+ self.assertEqual(l, [1, 2, 3, 4, 5])
+
+ def test_cancel(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ event1 = scheduler.enter(0.01, 1, fun, (0.01,))
+ event2 = scheduler.enter(0.02, 1, fun, (0.02,))
+ event3 = scheduler.enter(0.03, 1, fun, (0.03,))
+ event4 = scheduler.enter(0.04, 1, fun, (0.04,))
+ event5 = scheduler.enter(0.05, 1, fun, (0.05,))
+ scheduler.cancel(event1)
+ scheduler.cancel(event5)
+ scheduler.run()
+ self.assertEqual(l, [0.02, 0.03, 0.04])
+
+ def test_empty(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ self.assertTrue(scheduler.empty())
+ for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
+ z = scheduler.enterabs(x, 1, fun, (x,))
+ self.assertFalse(scheduler.empty())
+ scheduler.run()
+ self.assertTrue(scheduler.empty())
+
+ def test_queue(self):
+ l = []
+ events = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ self.assertEqual(scheduler._queue, [])
+ for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
+ events.append(scheduler.enterabs(x, 1, fun, (x,)))
+ self.assertEqual(scheduler._queue.sort(), events.sort())
+ scheduler.run()
+ self.assertEqual(scheduler._queue, [])
+
+
+def test_main():
+ support.run_unittest(TestCase)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index fb97f1b793..fbc87aa80c 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -1,9 +1,6 @@
import unittest
from test.support import check_syntax_error, run_unittest
-import warnings
-warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<test string>")
-warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>")
class ScopeTests(unittest.TestCase):
@@ -195,44 +192,37 @@ class ScopeTests(unittest.TestCase):
def testUnoptimizedNamespaces(self):
- check_syntax_error(self, """\
-def unoptimized_clash1(strip):
- def f(s):
- from sys import *
- return getrefcount(s) # ambiguity: free or local
- return f
-""")
-
- check_syntax_error(self, """\
-def unoptimized_clash2():
- from sys import *
- def f(s):
- return getrefcount(s) # ambiguity: global or local
- return f
-""")
-
- check_syntax_error(self, """\
-def unoptimized_clash2():
- from sys import *
- def g():
- def f(s):
- return getrefcount(s) # ambiguity: global or local
- return f
-""")
-
- check_syntax_error(self, """\
-def f(x):
- def g():
- return x
- del x # can't del name
-""")
-
- check_syntax_error(self, """\
-def f():
- def g():
- from sys import *
- return getrefcount # global or local?
-""")
+ check_syntax_error(self, """if 1:
+ def unoptimized_clash1(strip):
+ def f(s):
+ from sys import *
+ return getrefcount(s) # ambiguity: free or local
+ return f
+ """)
+
+ check_syntax_error(self, """if 1:
+ def unoptimized_clash2():
+ from sys import *
+ def f(s):
+ return getrefcount(s) # ambiguity: global or local
+ return f
+ """)
+
+ check_syntax_error(self, """if 1:
+ def unoptimized_clash2():
+ from sys import *
+ def g():
+ def f(s):
+ return getrefcount(s) # ambiguity: global or local
+ return f
+ """)
+
+ check_syntax_error(self, """if 1:
+ def f():
+ def g():
+ from sys import *
+ return getrefcount # global or local?
+ """)
def testLambdas(self):
@@ -275,18 +265,40 @@ def f():
self.assertRaises(UnboundLocalError, errorInOuter)
self.assertRaises(NameError, errorInInner)
+ def testUnboundLocal_AfterDel(self):
+ # #4617: It is now legal to delete a cell variable.
+ # The following functions must obviously compile,
+ # and give the correct error when accessing the deleted name.
+ def errorInOuter():
+ y = 1
+ del y
+ print(y)
+ def inner():
+ return y
+
+ def errorInInner():
+ def inner():
+ return y
+ y = 1
+ del y
+ inner()
+
+ self.assertRaises(UnboundLocalError, errorInOuter)
+ self.assertRaises(NameError, errorInInner)
+
+ def testUnboundLocal_AugAssign(self):
# test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation
- exec("""
-global_x = 1
-def f():
- global_x += 1
-try:
- f()
-except UnboundLocalError:
- pass
-else:
- fail('scope of global_x not correctly determined')
-""", {'fail': self.fail})
+ exec("""if 1:
+ global_x = 1
+ def f():
+ global_x += 1
+ try:
+ f()
+ except UnboundLocalError:
+ pass
+ else:
+ fail('scope of global_x not correctly determined')
+ """, {'fail': self.fail})
def testComplexDefinitions(self):
@@ -305,88 +317,88 @@ else:
self.assertEqual(makeReturner2(a=11)()['a'], 11)
def testScopeOfGlobalStmt(self):
-# Examples posted by Samuele Pedroni to python-dev on 3/1/2001
-
- exec("""\
-# I
-x = 7
-def f():
- x = 1
- def g():
- global x
- def i():
- def h():
- return x
- return h()
- return i()
- return g()
-self.assertEqual(f(), 7)
-self.assertEqual(x, 7)
-
-# II
-x = 7
-def f():
- x = 1
- def g():
- x = 2
- def i():
- def h():
- return x
- return h()
- return i()
- return g()
-self.assertEqual(f(), 2)
-self.assertEqual(x, 7)
-
-# III
-x = 7
-def f():
- x = 1
- def g():
- global x
- x = 2
- def i():
- def h():
- return x
- return h()
- return i()
- return g()
-self.assertEqual(f(), 2)
-self.assertEqual(x, 2)
-
-# IV
-x = 7
-def f():
- x = 3
- def g():
- global x
- x = 2
- def i():
- def h():
- return x
- return h()
- return i()
- return g()
-self.assertEqual(f(), 2)
-self.assertEqual(x, 2)
-
-# XXX what about global statements in class blocks?
-# do they affect methods?
-
-x = 12
-class Global:
- global x
- x = 13
- def set(self, val):
- x = val
- def get(self):
- return x
-
-g = Global()
-self.assertEqual(g.get(), 13)
-g.set(15)
-self.assertEqual(g.get(), 13)
-""")
+ # Examples posted by Samuele Pedroni to python-dev on 3/1/2001
+
+ exec("""if 1:
+ # I
+ x = 7
+ def f():
+ x = 1
+ def g():
+ global x
+ def i():
+ def h():
+ return x
+ return h()
+ return i()
+ return g()
+ self.assertEqual(f(), 7)
+ self.assertEqual(x, 7)
+
+ # II
+ x = 7
+ def f():
+ x = 1
+ def g():
+ x = 2
+ def i():
+ def h():
+ return x
+ return h()
+ return i()
+ return g()
+ self.assertEqual(f(), 2)
+ self.assertEqual(x, 7)
+
+ # III
+ x = 7
+ def f():
+ x = 1
+ def g():
+ global x
+ x = 2
+ def i():
+ def h():
+ return x
+ return h()
+ return i()
+ return g()
+ self.assertEqual(f(), 2)
+ self.assertEqual(x, 2)
+
+ # IV
+ x = 7
+ def f():
+ x = 3
+ def g():
+ global x
+ x = 2
+ def i():
+ def h():
+ return x
+ return h()
+ return i()
+ return g()
+ self.assertEqual(f(), 2)
+ self.assertEqual(x, 2)
+
+ # XXX what about global statements in class blocks?
+ # do they affect methods?
+
+ x = 12
+ class Global:
+ global x
+ x = 13
+ def set(self, val):
+ x = val
+ def get(self):
+ return x
+
+ g = Global()
+ self.assertEqual(g.get(), 13)
+ g.set(15)
+ self.assertEqual(g.get(), 13)
+ """)
def testLeaks(self):
@@ -412,28 +424,28 @@ self.assertEqual(g.get(), 13)
def testClassAndGlobal(self):
- exec("""\
-def test(x):
- class Foo:
- global x
- def __call__(self, y):
- return x + y
- return Foo()
-
-x = 0
-self.assertEqual(test(6)(2), 8)
-x = -1
-self.assertEqual(test(3)(2), 5)
-
-looked_up_by_load_name = False
-class X:
- # Implicit globals inside classes are be looked up by LOAD_NAME, not
- # LOAD_GLOBAL.
- locals()['looked_up_by_load_name'] = True
- passed = looked_up_by_load_name
-
-self.assertTrue(X.passed)
-""")
+ exec("""if 1:
+ def test(x):
+ class Foo:
+ global x
+ def __call__(self, y):
+ return x + y
+ return Foo()
+
+ x = 0
+ self.assertEqual(test(6)(2), 8)
+ x = -1
+ self.assertEqual(test(3)(2), 5)
+
+ looked_up_by_load_name = False
+ class X:
+ # Implicit globals inside classes are be looked up by LOAD_NAME, not
+ # LOAD_GLOBAL.
+ locals()['looked_up_by_load_name'] = True
+ passed = looked_up_by_load_name
+
+ self.assertTrue(X.passed)
+ """)
def testLocalsFunction(self):
@@ -447,7 +459,7 @@ self.assertTrue(X.passed)
return g
d = f(2)(4)
- self.assertTrue('h' in d)
+ self.assertIn('h', d)
del d['h']
self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6})
@@ -481,8 +493,8 @@ self.assertTrue(X.passed)
return C
varnames = f(1).z
- self.assertTrue("x" not in varnames)
- self.assertTrue("y" in varnames)
+ self.assertNotIn("x", varnames)
+ self.assertIn("y", varnames)
def testLocalsClass_WithTrace(self):
# Issue23728: after the trace function returns, the locals()
@@ -629,22 +641,22 @@ self.assertTrue(X.passed)
# function to other nested functions in the same block.
# This test verifies that a global statement in the first
# function does not affect the second function.
- CODE = """def f():
- y = 1
- def g():
- global y
- return y
- def h():
- return y + 1
- return g, h
-y = 9
-g, h = f()
-result9 = g()
-result2 = h()
-"""
local_ns = {}
global_ns = {}
- exec(CODE, local_ns, global_ns)
+ exec("""if 1:
+ def f():
+ y = 1
+ def g():
+ global y
+ return y
+ def h():
+ return y + 1
+ return g, h
+ y = 9
+ g, h = f()
+ result9 = g()
+ result2 = h()
+ """, local_ns, global_ns)
self.assertEqual(2, global_ns["result2"])
self.assertEqual(9, global_ns["result9"])
@@ -660,7 +672,7 @@ result2 = h()
c = f(0)
self.assertEqual(c.get(), 1)
- self.assertTrue("x" not in c.__class__.__dict__)
+ self.assertNotIn("x", c.__class__.__dict__)
def testNonLocalGenerator(self):
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
index 8813c6ed1b..fe92f45145 100644
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -4,7 +4,7 @@ import select
import os
import sys
-@unittest.skipIf(sys.platform[:3] in ('win', 'mac', 'os2', 'riscos'),
+@unittest.skipIf(sys.platform[:3] in ('win', 'os2', 'riscos'),
"can't easily test on this system")
class SelectTestCase(unittest.TestCase):
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index fdbfe19c91..07bfe0657e 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -5,7 +5,6 @@ import weakref
import operator
import copy
import pickle
-import os
from random import randrange, shuffle
import sys
import warnings
@@ -66,7 +65,7 @@ class TestJointOps(unittest.TestCase):
self.assertEqual(c in self.s, c in self.d)
self.assertRaises(TypeError, self.s.__contains__, [[]])
s = self.thetype([frozenset(self.letters)])
- self.assertTrue(self.thetype(self.letters) in s)
+ self.assertIn(self.thetype(self.letters), s)
def test_union(self):
u = self.s.union(self.otherword)
@@ -270,7 +269,7 @@ class TestJointOps(unittest.TestCase):
s=H()
f=set()
f.add(s)
- self.assertTrue(s in f)
+ self.assertIn(s, f)
f.remove(s)
f.add(s)
f.discard(s)
@@ -380,7 +379,7 @@ class TestSet(TestJointOps):
def test_add(self):
self.s.add('Q')
- self.assertTrue('Q' in self.s)
+ self.assertIn('Q', self.s)
dup = self.s.copy()
self.s.add('Q')
self.assertEqual(self.s, dup)
@@ -388,13 +387,13 @@ class TestSet(TestJointOps):
def test_remove(self):
self.s.remove('a')
- self.assertTrue('a' not in self.s)
+ self.assertNotIn('a', self.s)
self.assertRaises(KeyError, self.s.remove, 'Q')
self.assertRaises(TypeError, self.s.remove, [])
s = self.thetype([frozenset(self.word)])
- self.assertTrue(self.thetype(self.word) in s)
+ self.assertIn(self.thetype(self.word), s)
s.remove(self.thetype(self.word))
- self.assertTrue(self.thetype(self.word) not in s)
+ self.assertNotIn(self.thetype(self.word), s)
self.assertRaises(KeyError, self.s.remove, self.thetype(self.word))
def test_remove_keyerror_unpacking(self):
@@ -421,26 +420,26 @@ class TestSet(TestJointOps):
def test_discard(self):
self.s.discard('a')
- self.assertTrue('a' not in self.s)
+ self.assertNotIn('a', self.s)
self.s.discard('Q')
self.assertRaises(TypeError, self.s.discard, [])
s = self.thetype([frozenset(self.word)])
- self.assertTrue(self.thetype(self.word) in s)
+ self.assertIn(self.thetype(self.word), s)
s.discard(self.thetype(self.word))
- self.assertTrue(self.thetype(self.word) not in s)
+ self.assertNotIn(self.thetype(self.word), s)
s.discard(self.thetype(self.word))
def test_pop(self):
for i in range(len(self.s)):
elem = self.s.pop()
- self.assertTrue(elem not in self.s)
+ self.assertNotIn(elem, self.s)
self.assertRaises(KeyError, self.s.pop)
def test_update(self):
retval = self.s.update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
self.assertRaises(PassThru, self.s.update, check_pass_thru())
self.assertRaises(TypeError, self.s.update, [[]])
for p, q in (('cdc', 'abcd'), ('efgfe', 'abcefg'), ('ccb', 'abc'), ('ef', 'abcef')):
@@ -458,16 +457,16 @@ class TestSet(TestJointOps):
def test_ior(self):
self.s |= set(self.otherword)
for c in (self.word + self.otherword):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
def test_intersection_update(self):
retval = self.s.intersection_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if c in self.otherword and c in self.word:
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru())
self.assertRaises(TypeError, self.s.intersection_update, [[]])
for p, q in (('cdc', 'c'), ('efgfe', ''), ('ccb', 'bc'), ('ef', '')):
@@ -485,18 +484,18 @@ class TestSet(TestJointOps):
self.s &= set(self.otherword)
for c in (self.word + self.otherword):
if c in self.otherword and c in self.word:
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
def test_difference_update(self):
retval = self.s.difference_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if c in self.word and c not in self.otherword:
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
self.assertRaises(PassThru, self.s.difference_update, check_pass_thru())
self.assertRaises(TypeError, self.s.difference_update, [[]])
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
@@ -522,18 +521,18 @@ class TestSet(TestJointOps):
self.s -= set(self.otherword)
for c in (self.word + self.otherword):
if c in self.word and c not in self.otherword:
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
def test_symmetric_difference_update(self):
retval = self.s.symmetric_difference_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if (c in self.word) ^ (c in self.otherword):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru())
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
for p, q in (('cdc', 'abd'), ('efgfe', 'abcefg'), ('ccb', 'a'), ('ef', 'abcef')):
@@ -546,9 +545,9 @@ class TestSet(TestJointOps):
self.s ^= set(self.otherword)
for c in (self.word + self.otherword):
if (c in self.word) ^ (c in self.otherword):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
def test_inplace_on_self(self):
t = self.s.copy()
@@ -608,7 +607,7 @@ class TestSet(TestJointOps):
# C API test only available in a debug build
if hasattr(set, "test_c_api"):
def test_c_api(self):
- self.assertEqual(set('abc').test_c_api(), True)
+ self.assertEqual(set().test_c_api(), True)
class SetSubclass(set):
pass
@@ -815,7 +814,7 @@ class TestBasicOps(unittest.TestCase):
def test_iteration(self):
for v in self.set:
- self.assertTrue(v in self.values)
+ self.assertIn(v, self.values)
setiter = iter(self.set)
# note: __length_hint__ is an internal undocumented API,
# don't rely on it in your own programs
@@ -850,10 +849,10 @@ class TestBasicOpsSingleton(TestBasicOps):
self.repr = "{3}"
def test_in(self):
- self.assertTrue(3 in self.set)
+ self.assertIn(3, self.set)
def test_not_in(self):
- self.assertTrue(2 not in self.set)
+ self.assertNotIn(2, self.set)
#------------------------------------------------------------------------------
@@ -867,10 +866,10 @@ class TestBasicOpsTuple(TestBasicOps):
self.repr = "{(0, 'zero')}"
def test_in(self):
- self.assertTrue((0, "zero") in self.set)
+ self.assertIn((0, "zero"), self.set)
def test_not_in(self):
- self.assertTrue(9 not in self.set)
+ self.assertNotIn(9, self.set)
#------------------------------------------------------------------------------
@@ -909,7 +908,8 @@ class TestBasicOpsBytes(TestBasicOps):
class TestBasicOpsMixedStringBytes(TestBasicOps):
def setUp(self):
- self.warning_filters = warnings.filters[:]
+ self._warning_filters = support.check_warnings()
+ self._warning_filters.__enter__()
warnings.simplefilter('ignore', BytesWarning)
self.case = "string and bytes set"
self.values = ["a", "b", b"a", b"b"]
@@ -919,7 +919,7 @@ class TestBasicOpsMixedStringBytes(TestBasicOps):
self.repr = "{'a', b'a', 'b', b'b'}"
def tearDown(self):
- warnings.filters = self.warning_filters
+ self._warning_filters.__exit__(None, None, None)
#==============================================================================
@@ -1187,7 +1187,7 @@ class TestMutate(unittest.TestCase):
popped[self.set.pop()] = None
self.assertEqual(len(popped), len(self.values))
for v in self.values:
- self.assertTrue(v in popped)
+ self.assertIn(v, popped)
def test_update_empty_tuple(self):
self.set.update(())
@@ -1660,6 +1660,39 @@ class TestVariousIteratorArgs(unittest.TestCase):
self.assertRaises(TypeError, getattr(set('january'), methname), N(data))
self.assertRaises(ZeroDivisionError, getattr(set('january'), methname), E(data))
+class bad_eq:
+ def __eq__(self, other):
+ if be_bad:
+ set2.clear()
+ raise ZeroDivisionError
+ return self is other
+ def __hash__(self):
+ return 0
+
+class bad_dict_clear:
+ def __eq__(self, other):
+ if be_bad:
+ dict2.clear()
+ return self is other
+ def __hash__(self):
+ return 0
+
+class TestWeirdBugs(unittest.TestCase):
+ def test_8420_set_merge(self):
+ # This used to segfault
+ global be_bad, set2, dict2
+ be_bad = False
+ set1 = {bad_eq()}
+ set2 = {bad_eq() for i in range(75)}
+ be_bad = True
+ self.assertRaises(ZeroDivisionError, set1.update, set2)
+
+ be_bad = False
+ set1 = {bad_dict_clear()}
+ dict2 = {bad_dict_clear(): None}
+ be_bad = True
+ set1.symmetric_difference_update(dict2)
+
# Application tests (based on David Eppstein's graph recipes ====================================
def powerset(U):
@@ -1761,7 +1794,7 @@ class TestGraphs(unittest.TestCase):
edge = vertex # Cuboctahedron vertices are edges in Cube
self.assertEqual(len(edge), 2) # Two cube vertices define an edge
for cubevert in edge:
- self.assertTrue(cubevert in g)
+ self.assertIn(cubevert, g)
#==============================================================================
@@ -1804,6 +1837,7 @@ def test_main(verbose=None):
TestIdentities,
TestVariousIteratorArgs,
TestGraphs,
+ TestWeirdBugs,
)
support.run_unittest(*test_classes)
diff --git a/Lib/test/test_shelve.py b/Lib/test/test_shelve.py
index 066208a1c0..3e73f52b87 100644
--- a/Lib/test/test_shelve.py
+++ b/Lib/test/test_shelve.py
@@ -122,6 +122,19 @@ class TestCase(unittest.TestCase):
self.assertEqual(len(d1), 1)
self.assertEqual(len(d2), 1)
+ def test_keyencoding(self):
+ d = {}
+ key = 'Pöp'
+ # the default keyencoding is utf-8
+ shelve.Shelf(d)[key] = [1]
+ self.assertIn(key.encode('utf-8'), d)
+ # but a different one can be given
+ shelve.Shelf(d, keyencoding='latin1')[key] = [1]
+ self.assertIn(key.encode('latin1'), d)
+ # with all consequences
+ s = shelve.Shelf(d, keyencoding='ascii')
+ self.assertRaises(UnicodeEncodeError, s.__setitem__, key, [1])
+
def test_writeback_also_writes_immediately(self):
# Issue 5754
d = {}
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index becd91c56f..5252d4dff3 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -7,11 +7,98 @@ import sys
import stat
import os
import os.path
+import functools
from test import support
from test.support import TESTFN
+from os.path import splitdrive
+from distutils.spawn import find_executable, spawn
+from shutil import (_make_tarball, _make_zipfile, make_archive,
+ register_archive_format, unregister_archive_format,
+ get_archive_formats, Error, unpack_archive,
+ register_unpack_format, RegistryError,
+ unregister_unpack_format, get_unpack_formats)
+import tarfile
+import warnings
+
+from test import support
+from test.support import TESTFN, check_warnings, captured_stdout
+
+try:
+ import bz2
+ BZ2_SUPPORTED = True
+except ImportError:
+ BZ2_SUPPORTED = False
+
TESTFN2 = TESTFN + "2"
+try:
+ import grp
+ import pwd
+ UID_GID_SUPPORT = True
+except ImportError:
+ UID_GID_SUPPORT = False
+
+try:
+ import zlib
+except ImportError:
+ zlib = None
+
+try:
+ import zipfile
+ ZIP_SUPPORT = True
+except ImportError:
+ ZIP_SUPPORT = find_executable('zip')
+
+def _fake_rename(*args, **kwargs):
+ # Pretend the destination path is on a different filesystem.
+ raise OSError()
+
+def mock_rename(func):
+ @functools.wraps(func)
+ def wrap(*args, **kwargs):
+ try:
+ builtin_rename = os.rename
+ os.rename = _fake_rename
+ return func(*args, **kwargs)
+ finally:
+ os.rename = builtin_rename
+ return wrap
+
class TestShutil(unittest.TestCase):
+
+ def setUp(self):
+ super(TestShutil, self).setUp()
+ self.tempdirs = []
+
+ def tearDown(self):
+ super(TestShutil, self).tearDown()
+ while self.tempdirs:
+ d = self.tempdirs.pop()
+ shutil.rmtree(d, os.name in ('nt', 'cygwin'))
+
+ def write_file(self, path, content='xxx'):
+ """Writes a file in the given path.
+
+
+ path can be a string or a sequence.
+ """
+ if isinstance(path, (list, tuple)):
+ path = os.path.join(*path)
+ f = open(path, 'w')
+ try:
+ f.write(content)
+ finally:
+ f.close()
+
+ def mkdtemp(self):
+ """Create a temporary directory that will be cleaned up.
+
+ Returns the path of the directory.
+ """
+ d = tempfile.mkdtemp()
+ self.tempdirs.append(d)
+ return d
+
def test_rmtree_errors(self):
# filename is guaranteed not to exist
filename = tempfile.mktemp()
@@ -78,11 +165,12 @@ class TestShutil(unittest.TestCase):
self.assertRaises(OSError, shutil.rmtree, path)
os.remove(path)
+ def _write_data(self, path, data):
+ f = open(path, "w")
+ f.write(data)
+ f.close()
+
def test_copytree_simple(self):
- def write_data(path, data):
- f = open(path, "w")
- f.write(data)
- f.close()
def read_data(path):
f = open(path)
@@ -92,11 +180,9 @@ class TestShutil(unittest.TestCase):
src_dir = tempfile.mkdtemp()
dst_dir = os.path.join(tempfile.mkdtemp(), 'destination')
-
- write_data(os.path.join(src_dir, 'test.txt'), '123')
-
+ self._write_data(os.path.join(src_dir, 'test.txt'), '123')
os.mkdir(os.path.join(src_dir, 'test_dir'))
- write_data(os.path.join(src_dir, 'test_dir', 'test.txt'), '456')
+ self._write_data(os.path.join(src_dir, 'test_dir', 'test.txt'), '456')
try:
shutil.copytree(src_dir, dst_dir)
@@ -125,11 +211,6 @@ class TestShutil(unittest.TestCase):
def test_copytree_with_exclude(self):
- def write_data(path, data):
- f = open(path, "w")
- f.write(data)
- f.close()
-
def read_data(path):
f = open(path)
data = f.read()
@@ -142,16 +223,18 @@ class TestShutil(unittest.TestCase):
src_dir = tempfile.mkdtemp()
try:
dst_dir = join(tempfile.mkdtemp(), 'destination')
- write_data(join(src_dir, 'test.txt'), '123')
- write_data(join(src_dir, 'test.tmp'), '123')
+ self._write_data(join(src_dir, 'test.txt'), '123')
+ self._write_data(join(src_dir, 'test.tmp'), '123')
os.mkdir(join(src_dir, 'test_dir'))
- write_data(join(src_dir, 'test_dir', 'test.txt'), '456')
+ self._write_data(join(src_dir, 'test_dir', 'test.txt'), '456')
os.mkdir(join(src_dir, 'test_dir2'))
- write_data(join(src_dir, 'test_dir2', 'test.txt'), '456')
+ self._write_data(join(src_dir, 'test_dir2', 'test.txt'), '456')
os.mkdir(join(src_dir, 'test_dir2', 'subdir'))
os.mkdir(join(src_dir, 'test_dir2', 'subdir2'))
- write_data(join(src_dir, 'test_dir2', 'subdir', 'test.txt'), '456')
- write_data(join(src_dir, 'test_dir2', 'subdir2', 'test.py'), '456')
+ self._write_data(join(src_dir, 'test_dir2', 'subdir', 'test.txt'),
+ '456')
+ self._write_data(join(src_dir, 'test_dir2', 'subdir2', 'test.py'),
+ '456')
# testing glob-like patterns
@@ -204,48 +287,58 @@ class TestShutil(unittest.TestCase):
shutil.rmtree(src_dir)
shutil.rmtree(os.path.dirname(dst_dir))
- if hasattr(os, "symlink"):
- def test_dont_copy_file_onto_link_to_itself(self):
- # bug 851123.
- os.mkdir(TESTFN)
- src = os.path.join(TESTFN, 'cheese')
- dst = os.path.join(TESTFN, 'shop')
- try:
- f = open(src, 'w')
+ @unittest.skipUnless(hasattr(os, 'link'), 'requires os.link')
+ def test_dont_copy_file_onto_link_to_itself(self):
+ # Temporarily disable test on Windows.
+ if os.name == 'nt':
+ return
+ # bug 851123.
+ os.mkdir(TESTFN)
+ src = os.path.join(TESTFN, 'cheese')
+ dst = os.path.join(TESTFN, 'shop')
+ try:
+ with open(src, 'w') as f:
f.write('cheddar')
- f.close()
-
- os.link(src, dst)
- self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
- with open(src, 'r') as f:
- self.assertEqual(f.read(), 'cheddar')
- os.remove(dst)
-
- # Using `src` here would mean we end up with a symlink pointing
- # to TESTFN/TESTFN/cheese, while it should point at
- # TESTFN/cheese.
- os.symlink('cheese', dst)
- self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
- with open(src, 'r') as f:
- self.assertEqual(f.read(), 'cheddar')
- os.remove(dst)
- finally:
- try:
- shutil.rmtree(TESTFN)
- except OSError:
- pass
+ os.link(src, dst)
+ self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+ with open(src, 'r') as f:
+ self.assertEqual(f.read(), 'cheddar')
+ os.remove(dst)
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
- def test_rmtree_on_symlink(self):
- # bug 1669.
- os.mkdir(TESTFN)
- try:
- src = os.path.join(TESTFN, 'cheese')
- dst = os.path.join(TESTFN, 'shop')
- os.mkdir(src)
- os.symlink(src, dst)
- self.assertRaises(OSError, shutil.rmtree, dst)
- finally:
- shutil.rmtree(TESTFN, ignore_errors=True)
+ @support.skip_unless_symlink
+ def test_dont_copy_file_onto_symlink_to_itself(self):
+ # bug 851123.
+ os.mkdir(TESTFN)
+ src = os.path.join(TESTFN, 'cheese')
+ dst = os.path.join(TESTFN, 'shop')
+ try:
+ with open(src, 'w') as f:
+ f.write('cheddar')
+ # Using `src` here would mean we end up with a symlink pointing
+ # to TESTFN/TESTFN/cheese, while it should point at
+ # TESTFN/cheese.
+ os.symlink('cheese', dst)
+ self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+ with open(src, 'r') as f:
+ self.assertEqual(f.read(), 'cheddar')
+ os.remove(dst)
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
+
+ @support.skip_unless_symlink
+ def test_rmtree_on_symlink(self):
+ # bug 1669.
+ os.mkdir(TESTFN)
+ try:
+ src = os.path.join(TESTFN, 'cheese')
+ dst = os.path.join(TESTFN, 'shop')
+ os.mkdir(src)
+ os.symlink(src, dst)
+ self.assertRaises(OSError, shutil.rmtree, dst)
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
if hasattr(os, "mkfifo"):
# Issue #3002: copyfile and copytree block indefinitely on named pipes
@@ -259,6 +352,7 @@ class TestShutil(unittest.TestCase):
finally:
os.remove(TESTFN)
+ @support.skip_unless_symlink
def test_copytree_named_pipe(self):
os.mkdir(TESTFN)
try:
@@ -279,6 +373,367 @@ class TestShutil(unittest.TestCase):
shutil.rmtree(TESTFN, ignore_errors=True)
shutil.rmtree(TESTFN2, ignore_errors=True)
+ def test_copytree_special_func(self):
+
+ src_dir = self.mkdtemp()
+ dst_dir = os.path.join(self.mkdtemp(), 'destination')
+ self._write_data(os.path.join(src_dir, 'test.txt'), '123')
+ os.mkdir(os.path.join(src_dir, 'test_dir'))
+ self._write_data(os.path.join(src_dir, 'test_dir', 'test.txt'), '456')
+
+ copied = []
+ def _copy(src, dst):
+ copied.append((src, dst))
+
+ shutil.copytree(src_dir, dst_dir, copy_function=_copy)
+ self.assertEqual(len(copied), 2)
+
+ @support.skip_unless_symlink
+ def test_copytree_dangling_symlinks(self):
+
+ # a dangling symlink raises an error at the end
+ src_dir = self.mkdtemp()
+ dst_dir = os.path.join(self.mkdtemp(), 'destination')
+ os.symlink('IDONTEXIST', os.path.join(src_dir, 'test.txt'))
+ os.mkdir(os.path.join(src_dir, 'test_dir'))
+ self._write_data(os.path.join(src_dir, 'test_dir', 'test.txt'), '456')
+ self.assertRaises(Error, shutil.copytree, src_dir, dst_dir)
+
+ # a dangling symlink is ignored with the proper flag
+ dst_dir = os.path.join(self.mkdtemp(), 'destination2')
+ shutil.copytree(src_dir, dst_dir, ignore_dangling_symlinks=True)
+ self.assertNotIn('test.txt', os.listdir(dst_dir))
+
+ # a dangling symlink is copied if symlinks=True
+ dst_dir = os.path.join(self.mkdtemp(), 'destination3')
+ shutil.copytree(src_dir, dst_dir, symlinks=True)
+ self.assertIn('test.txt', os.listdir(dst_dir))
+
+ def _copy_file(self, method):
+ fname = 'test.txt'
+ tmpdir = self.mkdtemp()
+ self.write_file([tmpdir, fname])
+ file1 = os.path.join(tmpdir, fname)
+ tmpdir2 = self.mkdtemp()
+ method(file1, tmpdir2)
+ file2 = os.path.join(tmpdir2, fname)
+ return (file1, file2)
+
+ @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod')
+ def test_copy(self):
+ # Ensure that the copied file exists and has the same mode bits.
+ file1, file2 = self._copy_file(shutil.copy)
+ self.assertTrue(os.path.exists(file2))
+ self.assertEqual(os.stat(file1).st_mode, os.stat(file2).st_mode)
+
+ @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod')
+ @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.utime')
+ def test_copy2(self):
+ # Ensure that the copied file exists and has the same mode and
+ # modification time bits.
+ file1, file2 = self._copy_file(shutil.copy2)
+ self.assertTrue(os.path.exists(file2))
+ file1_stat = os.stat(file1)
+ file2_stat = os.stat(file2)
+ self.assertEqual(file1_stat.st_mode, file2_stat.st_mode)
+ for attr in 'st_atime', 'st_mtime':
+ # The modification times may be truncated in the new file.
+ self.assertLessEqual(getattr(file1_stat, attr),
+ getattr(file2_stat, attr) + 1)
+ if hasattr(os, 'chflags') and hasattr(file1_stat, 'st_flags'):
+ self.assertEqual(getattr(file1_stat, 'st_flags'),
+ getattr(file2_stat, 'st_flags'))
+
+ @unittest.skipUnless(zlib, "requires zlib")
+ def test_make_tarball(self):
+ # creating something to tar
+ tmpdir = self.mkdtemp()
+ self.write_file([tmpdir, 'file1'], 'xxx')
+ self.write_file([tmpdir, 'file2'], 'xxx')
+ os.mkdir(os.path.join(tmpdir, 'sub'))
+ self.write_file([tmpdir, 'sub', 'file3'], 'xxx')
+
+ tmpdir2 = self.mkdtemp()
+ # force shutil to create the directory
+ os.rmdir(tmpdir2)
+ unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
+ "source and target should be on same drive")
+
+ base_name = os.path.join(tmpdir2, 'archive')
+
+ # working with relative paths to avoid tar warnings
+ old_dir = os.getcwd()
+ os.chdir(tmpdir)
+ try:
+ _make_tarball(splitdrive(base_name)[1], '.')
+ finally:
+ os.chdir(old_dir)
+
+ # check if the compressed tarball was created
+ tarball = base_name + '.tar.gz'
+ self.assertTrue(os.path.exists(tarball))
+
+ # trying an uncompressed one
+ base_name = os.path.join(tmpdir2, 'archive')
+ old_dir = os.getcwd()
+ os.chdir(tmpdir)
+ try:
+ _make_tarball(splitdrive(base_name)[1], '.', compress=None)
+ finally:
+ os.chdir(old_dir)
+ tarball = base_name + '.tar'
+ self.assertTrue(os.path.exists(tarball))
+
+ def _tarinfo(self, path):
+ tar = tarfile.open(path)
+ try:
+ names = tar.getnames()
+ names.sort()
+ return tuple(names)
+ finally:
+ tar.close()
+
+ def _create_files(self):
+ # creating something to tar
+ tmpdir = self.mkdtemp()
+ dist = os.path.join(tmpdir, 'dist')
+ os.mkdir(dist)
+ self.write_file([dist, 'file1'], 'xxx')
+ self.write_file([dist, 'file2'], 'xxx')
+ os.mkdir(os.path.join(dist, 'sub'))
+ self.write_file([dist, 'sub', 'file3'], 'xxx')
+ os.mkdir(os.path.join(dist, 'sub2'))
+ tmpdir2 = self.mkdtemp()
+ base_name = os.path.join(tmpdir2, 'archive')
+ return tmpdir, tmpdir2, base_name
+
+ @unittest.skipUnless(zlib, "Requires zlib")
+ @unittest.skipUnless(find_executable('tar') and find_executable('gzip'),
+ 'Need the tar command to run')
+ def test_tarfile_vs_tar(self):
+ tmpdir, tmpdir2, base_name = self._create_files()
+ old_dir = os.getcwd()
+ os.chdir(tmpdir)
+ try:
+ _make_tarball(base_name, 'dist')
+ finally:
+ os.chdir(old_dir)
+
+ # check if the compressed tarball was created
+ tarball = base_name + '.tar.gz'
+ self.assertTrue(os.path.exists(tarball))
+
+ # now create another tarball using `tar`
+ tarball2 = os.path.join(tmpdir, 'archive2.tar.gz')
+ tar_cmd = ['tar', '-cf', 'archive2.tar', 'dist']
+ gzip_cmd = ['gzip', '-f9', 'archive2.tar']
+ old_dir = os.getcwd()
+ os.chdir(tmpdir)
+ try:
+ with captured_stdout() as s:
+ spawn(tar_cmd)
+ spawn(gzip_cmd)
+ finally:
+ os.chdir(old_dir)
+
+ self.assertTrue(os.path.exists(tarball2))
+ # let's compare both tarballs
+ self.assertEqual(self._tarinfo(tarball), self._tarinfo(tarball2))
+
+ # trying an uncompressed one
+ base_name = os.path.join(tmpdir2, 'archive')
+ old_dir = os.getcwd()
+ os.chdir(tmpdir)
+ try:
+ _make_tarball(base_name, 'dist', compress=None)
+ finally:
+ os.chdir(old_dir)
+ tarball = base_name + '.tar'
+ self.assertTrue(os.path.exists(tarball))
+
+ # now for a dry_run
+ base_name = os.path.join(tmpdir2, 'archive')
+ old_dir = os.getcwd()
+ os.chdir(tmpdir)
+ try:
+ _make_tarball(base_name, 'dist', compress=None, dry_run=True)
+ finally:
+ os.chdir(old_dir)
+ tarball = base_name + '.tar'
+ self.assertTrue(os.path.exists(tarball))
+
+ @unittest.skipUnless(zlib, "Requires zlib")
+ @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
+ def test_make_zipfile(self):
+ # creating something to tar
+ tmpdir = self.mkdtemp()
+ self.write_file([tmpdir, 'file1'], 'xxx')
+ self.write_file([tmpdir, 'file2'], 'xxx')
+
+ tmpdir2 = self.mkdtemp()
+ # force shutil to create the directory
+ os.rmdir(tmpdir2)
+ base_name = os.path.join(tmpdir2, 'archive')
+ _make_zipfile(base_name, tmpdir)
+
+ # check if the compressed tarball was created
+ tarball = base_name + '.zip'
+ self.assertTrue(os.path.exists(tarball))
+
+
+ def test_make_archive(self):
+ tmpdir = self.mkdtemp()
+ base_name = os.path.join(tmpdir, 'archive')
+ self.assertRaises(ValueError, make_archive, base_name, 'xxx')
+
+ @unittest.skipUnless(zlib, "Requires zlib")
+ def test_make_archive_owner_group(self):
+ # testing make_archive with owner and group, with various combinations
+ # this works even if there's not gid/uid support
+ if UID_GID_SUPPORT:
+ group = grp.getgrgid(0)[0]
+ owner = pwd.getpwuid(0)[0]
+ else:
+ group = owner = 'root'
+
+ base_dir, root_dir, base_name = self._create_files()
+ base_name = os.path.join(self.mkdtemp() , 'archive')
+ res = make_archive(base_name, 'zip', root_dir, base_dir, owner=owner,
+ group=group)
+ self.assertTrue(os.path.exists(res))
+
+ res = make_archive(base_name, 'zip', root_dir, base_dir)
+ self.assertTrue(os.path.exists(res))
+
+ res = make_archive(base_name, 'tar', root_dir, base_dir,
+ owner=owner, group=group)
+ self.assertTrue(os.path.exists(res))
+
+ res = make_archive(base_name, 'tar', root_dir, base_dir,
+ owner='kjhkjhkjg', group='oihohoh')
+ self.assertTrue(os.path.exists(res))
+
+
+ @unittest.skipUnless(zlib, "Requires zlib")
+ @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+ def test_tarfile_root_owner(self):
+ tmpdir, tmpdir2, base_name = self._create_files()
+ old_dir = os.getcwd()
+ os.chdir(tmpdir)
+ group = grp.getgrgid(0)[0]
+ owner = pwd.getpwuid(0)[0]
+ try:
+ archive_name = _make_tarball(base_name, 'dist', compress=None,
+ owner=owner, group=group)
+ finally:
+ os.chdir(old_dir)
+
+ # check if the compressed tarball was created
+ self.assertTrue(os.path.exists(archive_name))
+
+ # now checks the rights
+ archive = tarfile.open(archive_name)
+ try:
+ for member in archive.getmembers():
+ self.assertEqual(member.uid, 0)
+ self.assertEqual(member.gid, 0)
+ finally:
+ archive.close()
+
+ def test_make_archive_cwd(self):
+ current_dir = os.getcwd()
+ def _breaks(*args, **kw):
+ raise RuntimeError()
+
+ register_archive_format('xxx', _breaks, [], 'xxx file')
+ try:
+ try:
+ make_archive('xxx', 'xxx', root_dir=self.mkdtemp())
+ except Exception:
+ pass
+ self.assertEqual(os.getcwd(), current_dir)
+ finally:
+ unregister_archive_format('xxx')
+
+ def test_register_archive_format(self):
+
+ self.assertRaises(TypeError, register_archive_format, 'xxx', 1)
+ self.assertRaises(TypeError, register_archive_format, 'xxx', lambda: x,
+ 1)
+ self.assertRaises(TypeError, register_archive_format, 'xxx', lambda: x,
+ [(1, 2), (1, 2, 3)])
+
+ register_archive_format('xxx', lambda: x, [(1, 2)], 'xxx file')
+ formats = [name for name, params in get_archive_formats()]
+ self.assertIn('xxx', formats)
+
+ unregister_archive_format('xxx')
+ formats = [name for name, params in get_archive_formats()]
+ self.assertNotIn('xxx', formats)
+
+ def _compare_dirs(self, dir1, dir2):
+ # check that dir1 and dir2 are equivalent,
+ # return the diff
+ diff = []
+ for root, dirs, files in os.walk(dir1):
+ for file_ in files:
+ path = os.path.join(root, file_)
+ target_path = os.path.join(dir2, os.path.split(path)[-1])
+ if not os.path.exists(target_path):
+ diff.append(file_)
+ return diff
+
+ @unittest.skipUnless(zlib, "Requires zlib")
+ def test_unpack_archive(self):
+ formats = ['tar', 'gztar', 'zip']
+ if BZ2_SUPPORTED:
+ formats.append('bztar')
+
+ for format in formats:
+ tmpdir = self.mkdtemp()
+ base_dir, root_dir, base_name = self._create_files()
+ tmpdir2 = self.mkdtemp()
+ filename = make_archive(base_name, format, root_dir, base_dir)
+
+ # let's try to unpack it now
+ unpack_archive(filename, tmpdir2)
+ diff = self._compare_dirs(tmpdir, tmpdir2)
+ self.assertEqual(diff, [])
+
+ # and again, this time with the format specified
+ tmpdir3 = self.mkdtemp()
+ unpack_archive(filename, tmpdir3, format=format)
+ diff = self._compare_dirs(tmpdir, tmpdir3)
+ self.assertEqual(diff, [])
+ self.assertRaises(shutil.ReadError, unpack_archive, TESTFN)
+ self.assertRaises(ValueError, unpack_archive, TESTFN, format='xxx')
+
+ def test_unpack_registery(self):
+
+ formats = get_unpack_formats()
+
+ def _boo(filename, extract_dir, extra):
+ self.assertEqual(extra, 1)
+ self.assertEqual(filename, 'stuff.boo')
+ self.assertEqual(extract_dir, 'xx')
+
+ register_unpack_format('Boo', ['.boo', '.b2'], _boo, [('extra', 1)])
+ unpack_archive('stuff.boo', 'xx')
+
+ # trying to register a .boo unpacker again
+ self.assertRaises(RegistryError, register_unpack_format, 'Boo2',
+ ['.boo'], _boo)
+
+ # should work now
+ unregister_unpack_format('Boo')
+ register_unpack_format('Boo2', ['.boo'], _boo)
+ self.assertIn(('Boo2', ['.boo'], ''), get_unpack_formats())
+ self.assertNotIn(('Boo', ['.boo'], ''), get_unpack_formats())
+
+ # let's leave a clean state
+ unregister_unpack_format('Boo2')
+ self.assertEqual(get_unpack_formats(), formats)
+
class TestMove(unittest.TestCase):
@@ -288,20 +743,11 @@ class TestMove(unittest.TestCase):
self.dst_dir = tempfile.mkdtemp()
self.src_file = os.path.join(self.src_dir, filename)
self.dst_file = os.path.join(self.dst_dir, filename)
- # Try to create a dir in the current directory, hoping that it is
- # not located on the same filesystem as the system tmp dir.
- try:
- self.dir_other_fs = tempfile.mkdtemp(
- dir=os.path.dirname(__file__))
- self.file_other_fs = os.path.join(self.dir_other_fs,
- filename)
- except OSError:
- self.dir_other_fs = None
with open(self.src_file, "wb") as f:
f.write(b"spam")
def tearDown(self):
- for d in (self.src_dir, self.dst_dir, self.dir_other_fs):
+ for d in (self.src_dir, self.dst_dir):
try:
if d:
shutil.rmtree(d)
@@ -330,21 +776,15 @@ class TestMove(unittest.TestCase):
# Move a file inside an existing dir on the same filesystem.
self._check_move_file(self.src_file, self.dst_dir, self.dst_file)
+ @mock_rename
def test_move_file_other_fs(self):
# Move a file to an existing dir on another filesystem.
- if not self.dir_other_fs:
- # skip
- return
- self._check_move_file(self.src_file, self.file_other_fs,
- self.file_other_fs)
+ self.test_move_file()
+ @mock_rename
def test_move_file_to_dir_other_fs(self):
# Move a file to another location on another filesystem.
- if not self.dir_other_fs:
- # skip
- return
- self._check_move_file(self.src_file, self.dir_other_fs,
- self.file_other_fs)
+ self.test_move_file_to_dir()
def test_move_dir(self):
# Move a dir to another location on the same filesystem.
@@ -357,32 +797,20 @@ class TestMove(unittest.TestCase):
except:
pass
+ @mock_rename
def test_move_dir_other_fs(self):
# Move a dir to another location on another filesystem.
- if not self.dir_other_fs:
- # skip
- return
- dst_dir = tempfile.mktemp(dir=self.dir_other_fs)
- try:
- self._check_move_dir(self.src_dir, dst_dir, dst_dir)
- finally:
- try:
- shutil.rmtree(dst_dir)
- except:
- pass
+ self.test_move_dir()
def test_move_dir_to_dir(self):
# Move a dir inside an existing dir on the same filesystem.
self._check_move_dir(self.src_dir, self.dst_dir,
os.path.join(self.dst_dir, os.path.basename(self.src_dir)))
+ @mock_rename
def test_move_dir_to_dir_other_fs(self):
# Move a dir inside an existing dir on another filesystem.
- if not self.dir_other_fs:
- # skip
- return
- self._check_move_dir(self.src_dir, self.dir_other_fs,
- os.path.join(self.dir_other_fs, os.path.basename(self.src_dir)))
+ self.test_move_dir_to_dir()
def test_existing_file_inside_dest_dir(self):
# A file with the same name inside the destination dir already exists.
@@ -419,6 +847,7 @@ class TestMove(unittest.TestCase):
finally:
shutil.rmtree(TESTFN, ignore_errors=True)
+
class TestCopyFile(unittest.TestCase):
_delete = False
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 6231a6bab1..8168d7ed92 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -6,13 +6,16 @@ executing have not been removed.
"""
import unittest
from test.support import run_unittest, TESTFN, EnvironmentVarGuard
-from test.support import captured_output
+from test.support import captured_stderr
import builtins
import os
import sys
import re
import encodings
import subprocess
+import sysconfig
+from copy import copy
+
# Need to make sure to not import 'site' if someone specified ``-S`` at the
# command-line. Detect this by just making sure 'site' has not been imported
# already.
@@ -28,19 +31,23 @@ if not os.path.isdir(site.USER_SITE):
class HelperFunctionsTests(unittest.TestCase):
"""Tests for helper functions.
-
- The setting of the encoding (set using sys.setdefaultencoding) used by
- the Unicode implementation is not tested.
-
"""
def setUp(self):
"""Save a copy of sys.path"""
self.sys_path = sys.path[:]
+ self.old_base = site.USER_BASE
+ self.old_site = site.USER_SITE
+ self.old_prefixes = site.PREFIXES
+ self.old_vars = copy(sysconfig._CONFIG_VARS)
def tearDown(self):
"""Restore sys.path"""
- sys.path = self.sys_path
+ sys.path[:] = self.sys_path
+ site.USER_BASE = self.old_base
+ site.USER_SITE = self.old_site
+ site.PREFIXES = self.old_prefixes
+ sysconfig._CONFIG_VARS = self.old_vars
def test_makepath(self):
# Test makepath() have an absolute path for its first return value
@@ -59,16 +66,16 @@ class HelperFunctionsTests(unittest.TestCase):
dir_set = site._init_pathinfo()
for entry in [site.makepath(path)[1] for path in sys.path
if path and os.path.isdir(path)]:
- self.assertTrue(entry in dir_set,
- "%s from sys.path not found in set returned "
- "by _init_pathinfo(): %s" % (entry, dir_set))
+ self.assertIn(entry, dir_set,
+ "%s from sys.path not found in set returned "
+ "by _init_pathinfo(): %s" % (entry, dir_set))
def pth_file_tests(self, pth_file):
"""Contain common code for testing results of reading a .pth file"""
- self.assertTrue(pth_file.imported in sys.modules,
- "%s not in sys.path" % pth_file.imported)
- self.assertTrue(site.makepath(pth_file.good_dir_path)[0] in sys.path)
- self.assertTrue(not os.path.exists(pth_file.bad_dir_path))
+ self.assertIn(pth_file.imported, sys.modules,
+ "%s not in sys.modules" % pth_file.imported)
+ self.assertIn(site.makepath(pth_file.good_dir_path)[0], sys.path)
+ self.assertFalse(os.path.exists(pth_file.bad_dir_path))
def test_addpackage(self):
# Make sure addpackage() imports if the line starts with 'import',
@@ -99,43 +106,43 @@ class HelperFunctionsTests(unittest.TestCase):
def test_addpackage_import_bad_syntax(self):
# Issue 10642
pth_dir, pth_fn = self.make_pth("import bad)syntax\n")
- with captured_output("stderr") as err_out:
+ with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
- self.assertRegexpMatches(err_out.getvalue(), "line 1")
- self.assertRegexpMatches(err_out.getvalue(),
+ self.assertRegex(err_out.getvalue(), "line 1")
+ self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: the previous two should be independent checks so that the
# order doesn't matter. The next three could be a single check
# but my regex foo isn't good enough to write it.
- self.assertRegexpMatches(err_out.getvalue(), 'Traceback')
- self.assertRegexpMatches(err_out.getvalue(), r'import bad\)syntax')
- self.assertRegexpMatches(err_out.getvalue(), 'SyntaxError')
+ self.assertRegex(err_out.getvalue(), 'Traceback')
+ self.assertRegex(err_out.getvalue(), r'import bad\)syntax')
+ self.assertRegex(err_out.getvalue(), 'SyntaxError')
def test_addpackage_import_bad_exec(self):
# Issue 10642
pth_dir, pth_fn = self.make_pth("randompath\nimport nosuchmodule\n")
- with captured_output("stderr") as err_out:
+ with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
- self.assertRegexpMatches(err_out.getvalue(), "line 2")
- self.assertRegexpMatches(err_out.getvalue(),
+ self.assertRegex(err_out.getvalue(), "line 2")
+ self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: ditto previous XXX comment.
- self.assertRegexpMatches(err_out.getvalue(), 'Traceback')
- self.assertRegexpMatches(err_out.getvalue(), 'ImportError')
+ self.assertRegex(err_out.getvalue(), 'Traceback')
+ self.assertRegex(err_out.getvalue(), 'ImportError')
@unittest.skipIf(sys.platform == "win32", "Windows does not raise an "
"error for file paths containing null characters")
def test_addpackage_import_bad_pth_file(self):
# Issue 5258
pth_dir, pth_fn = self.make_pth("abc\x00def\n")
- with captured_output("stderr") as err_out:
+ with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
- self.assertRegexpMatches(err_out.getvalue(), "line 1")
- self.assertRegexpMatches(err_out.getvalue(),
+ self.assertRegex(err_out.getvalue(), "line 1")
+ self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: ditto previous XXX comment.
- self.assertRegexpMatches(err_out.getvalue(), 'Traceback')
- self.assertRegexpMatches(err_out.getvalue(), 'TypeError')
+ self.assertRegex(err_out.getvalue(), 'Traceback')
+ self.assertRegex(err_out.getvalue(), 'TypeError')
def test_addsitedir(self):
# Same tests for test_addpackage since addsitedir() essentially just
@@ -152,7 +159,7 @@ class HelperFunctionsTests(unittest.TestCase):
def test_s_option(self):
usersite = site.USER_SITE
- self.assertTrue(usersite in sys.path)
+ self.assertIn(usersite, sys.path)
env = os.environ.copy()
rc = subprocess.call([sys.executable, '-c',
@@ -180,6 +187,62 @@ class HelperFunctionsTests(unittest.TestCase):
env=env)
self.assertEqual(rc, 1)
+ def test_getuserbase(self):
+ site.USER_BASE = None
+ user_base = site.getuserbase()
+
+ # the call sets site.USER_BASE
+ self.assertEqual(site.USER_BASE, user_base)
+
+ # let's set PYTHONUSERBASE and see if it uses it
+ site.USER_BASE = None
+ import sysconfig
+ sysconfig._CONFIG_VARS = None
+
+ with EnvironmentVarGuard() as environ:
+ environ['PYTHONUSERBASE'] = 'xoxo'
+ self.assertTrue(site.getuserbase().startswith('xoxo'),
+ site.getuserbase())
+
+ def test_getusersitepackages(self):
+ site.USER_SITE = None
+ site.USER_BASE = None
+ user_site = site.getusersitepackages()
+
+ # the call sets USER_BASE *and* USER_SITE
+ self.assertEqual(site.USER_SITE, user_site)
+ self.assertTrue(user_site.startswith(site.USER_BASE), user_site)
+
+ def test_getsitepackages(self):
+ site.PREFIXES = ['xoxo']
+ dirs = site.getsitepackages()
+
+ if sys.platform in ('os2emx', 'riscos'):
+ self.assertEqual(len(dirs), 1)
+ wanted = os.path.join('xoxo', 'Lib', 'site-packages')
+ self.assertEqual(dirs[0], wanted)
+ elif os.sep == '/':
+ self.assertEqual(len(dirs), 2)
+ wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
+ 'site-packages')
+ self.assertEqual(dirs[0], wanted)
+ wanted = os.path.join('xoxo', 'lib', 'site-python')
+ self.assertEqual(dirs[1], wanted)
+ else:
+ self.assertEqual(len(dirs), 2)
+ self.assertEqual(dirs[0], 'xoxo')
+ wanted = os.path.join('xoxo', 'lib', 'site-packages')
+ self.assertEqual(dirs[1], wanted)
+
+ # let's try the specific Apple location
+ if (sys.platform == "darwin" and
+ sysconfig.get_config_var("PYTHONFRAMEWORK")):
+ site.PREFIXES = ['Python.framework']
+ dirs = site.getsitepackages()
+ self.assertEqual(len(dirs), 3)
+ wanted = os.path.join('/Library', 'Python', sys.version[:3],
+ 'site-packages')
+ self.assertEqual(dirs[2], wanted)
class PthFile(object):
"""Helper class for handling testing of .pth files"""
@@ -245,21 +308,45 @@ class ImportSideEffectTests(unittest.TestCase):
def tearDown(self):
"""Restore sys.path"""
- sys.path = self.sys_path
-
- def test_abs__file__(self):
- # Make sure all imported modules have their __file__ attribute
- # as an absolute path.
- # Handled by abs__file__()
- site.abs__file__()
- for module in (sys, os, builtins):
- try:
- self.assertTrue(os.path.isabs(module.__file__), repr(module))
- except AttributeError:
- continue
- # We could try everything in sys.modules; however, when regrtest.py
- # runs something like test_frozen before test_site, then we will
- # be testing things loaded *after* test_site did path normalization
+ sys.path[:] = self.sys_path
+
+ def test_abs_paths(self):
+ # Make sure all imported modules have their __file__ and __cached__
+ # attributes as absolute paths. Arranging to put the Lib directory on
+ # PYTHONPATH would cause the os module to have a relative path for
+ # __file__ if abs_paths() does not get run. sys and builtins (the
+ # only other modules imported before site.py runs) do not have
+ # __file__ or __cached__ because they are built-in.
+ parent = os.path.relpath(os.path.dirname(os.__file__))
+ env = os.environ.copy()
+ env['PYTHONPATH'] = parent
+ code = ('import os, sys',
+ # use ASCII to avoid locale issues with non-ASCII directories
+ 'os_file = os.__file__.encode("ascii", "backslashreplace")',
+ r'sys.stdout.buffer.write(os_file + b"\n")',
+ 'os_cached = os.__cached__.encode("ascii", "backslashreplace")',
+ r'sys.stdout.buffer.write(os_cached + b"\n")')
+ command = '\n'.join(code)
+ # First, prove that with -S (no 'import site'), the paths are
+ # relative.
+ proc = subprocess.Popen([sys.executable, '-S', '-c', command],
+ env=env,
+ stdout=subprocess.PIPE)
+ stdout, stderr = proc.communicate()
+
+ self.assertEqual(proc.returncode, 0)
+ os__file__, os__cached__ = stdout.splitlines()[:2]
+ self.assertFalse(os.path.isabs(os__file__))
+ self.assertFalse(os.path.isabs(os__cached__))
+ # Now, with 'import site', it works.
+ proc = subprocess.Popen([sys.executable, '-c', command],
+ env=env,
+ stdout=subprocess.PIPE)
+ stdout, stderr = proc.communicate()
+ self.assertEqual(proc.returncode, 0)
+ os__file__, os__cached__ = stdout.splitlines()[:2]
+ self.assertTrue(os.path.isabs(os__file__))
+ self.assertTrue(os.path.isabs(os__cached__))
def test_no_duplicate_paths(self):
# No duplicate paths should exist in sys.path
@@ -267,7 +354,7 @@ class ImportSideEffectTests(unittest.TestCase):
site.removeduppaths()
seen_paths = set()
for path in sys.path:
- self.assertTrue(path not in seen_paths)
+ self.assertNotIn(path, seen_paths)
seen_paths.add(path)
def test_add_build_dir(self):
@@ -300,10 +387,6 @@ class ImportSideEffectTests(unittest.TestCase):
else:
self.fail("did not alias mbcs")
- def test_setdefaultencoding_removed(self):
- # Make sure sys.setdefaultencoding is gone
- self.assertTrue(not hasattr(sys, "setdefaultencoding"))
-
def test_sitecustomize_executed(self):
# If sitecustomize is available, it should have been imported.
if "sitecustomize" not in sys.modules:
diff --git a/Lib/test/test_smtpd.py b/Lib/test/test_smtpd.py
new file mode 100644
index 0000000000..a4cd6707ba
--- /dev/null
+++ b/Lib/test/test_smtpd.py
@@ -0,0 +1,289 @@
+from unittest import TestCase
+from test import support, mock_socket
+import socket
+import io
+import smtpd
+import asyncore
+
+
+class DummyServer(smtpd.SMTPServer):
+ def __init__(self, localaddr, remoteaddr):
+ smtpd.SMTPServer.__init__(self, localaddr, remoteaddr)
+ self.messages = []
+
+ def process_message(self, peer, mailfrom, rcpttos, data):
+ self.messages.append((peer, mailfrom, rcpttos, data))
+ if data == 'return status':
+ return '250 Okish'
+
+
+class DummyDispatcherBroken(Exception):
+ pass
+
+
+class BrokenDummyServer(DummyServer):
+ def listen(self, num):
+ raise DummyDispatcherBroken()
+
+
+class SMTPDServerTest(TestCase):
+ def setUp(self):
+ smtpd.socket = asyncore.socket = mock_socket
+
+ def test_process_message_unimplemented(self):
+ server = smtpd.SMTPServer('a', 'b')
+ conn, addr = server.accept()
+ channel = smtpd.SMTPChannel(server, conn, addr)
+
+ def write_line(line):
+ channel.socket.queue_recv(line)
+ channel.handle_read()
+
+ write_line(b'MAIL From:eggs@example')
+ write_line(b'RCPT To:spam@example')
+ write_line(b'DATA')
+ self.assertRaises(NotImplementedError, write_line, b'spam\r\n.\r\n')
+
+ def tearDown(self):
+ asyncore.close_all()
+ asyncore.socket = smtpd.socket = socket
+
+
+class SMTPDChannelTest(TestCase):
+ def setUp(self):
+ smtpd.socket = asyncore.socket = mock_socket
+ self.debug = smtpd.DEBUGSTREAM = io.StringIO()
+ self.server = DummyServer('a', 'b')
+ conn, addr = self.server.accept()
+ self.channel = smtpd.SMTPChannel(self.server, conn, addr)
+
+ def tearDown(self):
+ asyncore.close_all()
+ asyncore.socket = smtpd.socket = socket
+
+ def write_line(self, line):
+ self.channel.socket.queue_recv(line)
+ self.channel.handle_read()
+
+ def test_broken_connect(self):
+ self.assertRaises(DummyDispatcherBroken, BrokenDummyServer, 'a', 'b')
+
+ def test_server_accept(self):
+ self.server.handle_accept()
+
+ def test_missing_data(self):
+ self.write_line(b'')
+ self.assertEqual(self.channel.socket.last,
+ b'500 Error: bad syntax\r\n')
+
+ def test_EHLO_not_implemented(self):
+ self.write_line(b'EHLO test.example')
+ self.assertEqual(self.channel.socket.last,
+ b'502 Error: command "EHLO" not implemented\r\n')
+
+ def test_HELO(self):
+ name = smtpd.socket.getfqdn()
+ self.write_line(b'HELO test.example')
+ self.assertEqual(self.channel.socket.last,
+ '250 {}\r\n'.format(name).encode('ascii'))
+
+ def test_HELO_bad_syntax(self):
+ self.write_line(b'HELO')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: HELO hostname\r\n')
+
+ def test_HELO_duplicate(self):
+ self.write_line(b'HELO test.example')
+ self.write_line(b'HELO test.example')
+ self.assertEqual(self.channel.socket.last,
+ b'503 Duplicate HELO/EHLO\r\n')
+
+ def test_NOOP(self):
+ self.write_line(b'NOOP')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+
+ def test_NOOP_bad_syntax(self):
+ self.write_line(b'NOOP hi')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: NOOP\r\n')
+
+ def test_QUIT(self):
+ self.write_line(b'QUIT')
+ self.assertEqual(self.channel.socket.last, b'221 Bye\r\n')
+
+ def test_QUIT_arg_ignored(self):
+ self.write_line(b'QUIT bye bye')
+ self.assertEqual(self.channel.socket.last, b'221 Bye\r\n')
+
+ def test_bad_state(self):
+ self.channel.smtp_state = 'BAD STATE'
+ self.write_line(b'HELO')
+ self.assertEqual(self.channel.socket.last,
+ b'451 Internal confusion\r\n')
+
+ def test_command_too_long(self):
+ self.write_line(b'MAIL from ' +
+ b'a' * self.channel.command_size_limit +
+ b'@example')
+ self.assertEqual(self.channel.socket.last,
+ b'500 Error: line too long\r\n')
+
+ def test_data_too_long(self):
+ # Small hack. Setting limit to 2K octets here will save us some time.
+ self.channel.data_size_limit = 2048
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'DATA')
+ self.write_line(b'A' * self.channel.data_size_limit +
+ b'A\r\n.')
+ self.assertEqual(self.channel.socket.last,
+ b'552 Error: Too much mail data\r\n')
+
+ def test_need_MAIL(self):
+ self.write_line(b'RCPT to:spam@example')
+ self.assertEqual(self.channel.socket.last,
+ b'503 Error: need MAIL command\r\n')
+
+ def test_MAIL_syntax(self):
+ self.write_line(b'MAIL from eggs@example')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: MAIL FROM:<address>\r\n')
+
+ def test_MAIL_missing_from(self):
+ self.write_line(b'MAIL from:')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: MAIL FROM:<address>\r\n')
+
+ def test_MAIL_chevrons(self):
+ self.write_line(b'MAIL from:<eggs@example>')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+
+ def test_nested_MAIL(self):
+ self.write_line(b'MAIL from:eggs@example')
+ self.write_line(b'MAIL from:spam@example')
+ self.assertEqual(self.channel.socket.last,
+ b'503 Error: nested MAIL command\r\n')
+
+ def test_need_RCPT(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'DATA')
+ self.assertEqual(self.channel.socket.last,
+ b'503 Error: need RCPT command\r\n')
+
+ def test_RCPT_syntax(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT to eggs@example')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: RCPT TO: <address>\r\n')
+
+ def test_data_dialog(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+ self.write_line(b'RCPT To:spam@example')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+
+ self.write_line(b'DATA')
+ self.assertEqual(self.channel.socket.last,
+ b'354 End data with <CR><LF>.<CR><LF>\r\n')
+ self.write_line(b'data\r\nmore\r\n.')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+ self.assertEqual(self.server.messages,
+ [('peer', 'eggs@example', ['spam@example'], 'data\nmore')])
+
+ def test_DATA_syntax(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'DATA spam')
+ self.assertEqual(self.channel.socket.last, b'501 Syntax: DATA\r\n')
+
+ def test_data_transparency_section_4_5_2(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'DATA')
+ self.write_line(b'..\r\n.\r\n')
+ self.assertEqual(self.channel.received_data, '.')
+
+ def test_multiple_RCPT(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'RCPT To:ham@example')
+ self.write_line(b'DATA')
+ self.write_line(b'data\r\n.')
+ self.assertEqual(self.server.messages,
+ [('peer', 'eggs@example', ['spam@example','ham@example'], 'data')])
+
+ def test_manual_status(self):
+ # checks that the Channel is able to return a custom status message
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'DATA')
+ self.write_line(b'return status\r\n.')
+ self.assertEqual(self.channel.socket.last, b'250 Okish\r\n')
+
+ def test_RSET(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'RSET')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+ self.write_line(b'MAIL From:foo@example')
+ self.write_line(b'RCPT To:eggs@example')
+ self.write_line(b'DATA')
+ self.write_line(b'data\r\n.')
+ self.assertEqual(self.server.messages,
+ [('peer', 'foo@example', ['eggs@example'], 'data')])
+
+ def test_RSET_syntax(self):
+ self.write_line(b'RSET hi')
+ self.assertEqual(self.channel.socket.last, b'501 Syntax: RSET\r\n')
+
+ def test_attribute_deprecations(self):
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__server
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__server = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__line
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__line = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__state
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__state = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__greeting
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__greeting = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__mailfrom
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__mailfrom = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__rcpttos
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__rcpttos = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__data
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__data = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__fqdn
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__fqdn = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__peer
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__peer = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__conn
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__conn = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__addr
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__addr = 'spam'
+
+def test_main():
+ support.run_unittest(SMTPDServerTest, SMTPDChannelTest)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 727ef834f3..4651f376f6 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -1,16 +1,22 @@
import asyncore
+import email.mime.text
import email.utils
import socket
-import threading
import smtpd
import smtplib
import io
+import re
import sys
import time
import select
-from unittest import TestCase
-from test import support
+import unittest
+from test import support, mock_socket
+
+try:
+ import threading
+except ImportError:
+ threading = None
HOST = support.HOST
@@ -44,48 +50,55 @@ def server(evt, buf, serv):
serv.close()
evt.set()
-class GeneralTests(TestCase):
+class GeneralTests(unittest.TestCase):
def setUp(self):
- self.evt = threading.Event()
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.settimeout(15)
- self.port = support.bind_port(self.sock)
- servargs = (self.evt, b"220 Hola mundo\n", self.sock)
- threading.Thread(target=server, args=servargs).start()
- self.evt.wait()
- self.evt.clear()
+ smtplib.socket = mock_socket
+ self.port = 25
def tearDown(self):
- self.evt.wait()
+ smtplib.socket = socket
+
+ # This method is no longer used but is retained for backward compatibility,
+ # so test to make sure it still works.
+ def testQuoteData(self):
+ teststr = "abc\n.jkl\rfoo\r\n..blue"
+ expected = "abc\r\n..jkl\r\nfoo\r\n...blue"
+ self.assertEqual(expected, smtplib.quotedata(teststr))
def testBasic1(self):
+ mock_socket.reply_with(b"220 Hola mundo")
# connects
smtp = smtplib.SMTP(HOST, self.port)
smtp.close()
def testBasic2(self):
+ mock_socket.reply_with(b"220 Hola mundo")
# connects, include port in host name
smtp = smtplib.SMTP("%s:%s" % (HOST, self.port))
smtp.close()
def testLocalHostName(self):
+ mock_socket.reply_with(b"220 Hola mundo")
# check that supplied local_hostname is used
smtp = smtplib.SMTP(HOST, self.port, local_hostname="testhost")
self.assertEqual(smtp.local_hostname, "testhost")
smtp.close()
def testTimeoutDefault(self):
- self.assertTrue(socket.getdefaulttimeout() is None)
- socket.setdefaulttimeout(30)
+ mock_socket.reply_with(b"220 Hola mundo")
+ self.assertTrue(mock_socket.getdefaulttimeout() is None)
+ mock_socket.setdefaulttimeout(30)
+ self.assertEqual(mock_socket.getdefaulttimeout(), 30)
try:
smtp = smtplib.SMTP(HOST, self.port)
finally:
- socket.setdefaulttimeout(None)
+ mock_socket.setdefaulttimeout(None)
self.assertEqual(smtp.sock.gettimeout(), 30)
smtp.close()
def testTimeoutNone(self):
+ mock_socket.reply_with(b"220 Hola mundo")
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
@@ -96,6 +109,7 @@ class GeneralTests(TestCase):
smtp.close()
def testTimeoutValue(self):
+ mock_socket.reply_with(b"220 Hola mundo")
smtp = smtplib.SMTP(HOST, self.port, timeout=30)
self.assertEqual(smtp.sock.gettimeout(), 30)
smtp.close()
@@ -142,34 +156,50 @@ MSG_END = '------------ END MESSAGE ------------\n'
# test server times out, causing the test to fail.
# Test behavior of smtpd.DebuggingServer
-class DebuggingServerTests(TestCase):
+@unittest.skipUnless(threading, 'Threading required for this test.')
+class DebuggingServerTests(unittest.TestCase):
+
+ maxDiff = None
def setUp(self):
+ self.real_getfqdn = socket.getfqdn
+ socket.getfqdn = mock_socket.getfqdn
# temporarily replace sys.stdout to capture DebuggingServer output
self.old_stdout = sys.stdout
self.output = io.StringIO()
sys.stdout = self.output
+ self._threads = support.threading_setup()
self.serv_evt = threading.Event()
self.client_evt = threading.Event()
+ # Capture SMTPChannel debug output
+ self.old_DEBUGSTREAM = smtpd.DEBUGSTREAM
+ smtpd.DEBUGSTREAM = io.StringIO()
# Pick a random unused port by passing 0 for the port number
self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1))
# Keep a note of what port was assigned
self.port = self.serv.socket.getsockname()[1]
serv_args = (self.serv, self.serv_evt, self.client_evt)
- threading.Thread(target=debugging_server, args=serv_args).start()
+ self.thread = threading.Thread(target=debugging_server, args=serv_args)
+ self.thread.start()
# wait until server thread has assigned a port number
self.serv_evt.wait()
self.serv_evt.clear()
def tearDown(self):
+ socket.getfqdn = self.real_getfqdn
# indicate that the client is finished
self.client_evt.set()
# wait for the server thread to terminate
self.serv_evt.wait()
+ self.thread.join()
+ support.threading_cleanup(*self._threads)
# restore sys.stdout
sys.stdout = self.old_stdout
+ # restore DEBUGSTREAM
+ smtpd.DEBUGSTREAM.close()
+ smtpd.DEBUGSTREAM = self.old_DEBUGSTREAM
def testBasic(self):
# connect
@@ -234,8 +264,103 @@ class DebuggingServerTests(TestCase):
mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END)
self.assertEqual(self.output.getvalue(), mexpect)
+ def testSendBinary(self):
+ m = b'A test message'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.sendmail('John', 'Sally', m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.decode('ascii'), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+
+ def testSendMessage(self):
+ m = email.mime.text.MIMEText('A test message')
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m, from_addr='John', to_addrs='Sally')
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # Add the X-Peer header that DebuggingServer adds
+ # XXX: I'm not sure hardcoding this IP will work on linux-vserver.
+ m['X-Peer'] = '127.0.0.1'
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+
+ def testSendMessageWithAddresses(self):
+ m = email.mime.text.MIMEText('A test message')
+ m['From'] = 'foo@bar.com'
+ m['To'] = 'John'
+ m['CC'] = 'Sally, Fred'
+ m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # Add the X-Peer header that DebuggingServer adds
+ # XXX: I'm not sure hardcoding this IP will work on linux-vserver.
+ m['X-Peer'] = '127.0.0.1'
+ # The Bcc header is deleted before serialization.
+ del m['Bcc']
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+ debugout = smtpd.DEBUGSTREAM.getvalue()
+ sender = re.compile("^sender: foo@bar.com$", re.MULTILINE)
+ self.assertRegex(debugout, sender)
+ for addr in ('John', 'Sally', 'Fred', 'root@localhost',
+ 'warped@silly.walks.com'):
+ to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
+ re.MULTILINE)
+ self.assertRegex(debugout, to_addr)
+
+ def testSendMessageWithSomeAddresses(self):
+ # Make sure nothing breaks if not all of the three 'to' headers exist
+ m = email.mime.text.MIMEText('A test message')
+ m['From'] = 'foo@bar.com'
+ m['To'] = 'John, Dinsdale'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # Add the X-Peer header that DebuggingServer adds
+ # XXX: I'm not sure hardcoding this IP will work on linux-vserver.
+ m['X-Peer'] = '127.0.0.1'
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+ debugout = smtpd.DEBUGSTREAM.getvalue()
+ sender = re.compile("^sender: foo@bar.com$", re.MULTILINE)
+ self.assertRegex(debugout, sender)
+ for addr in ('John', 'Dinsdale'):
+ to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
+ re.MULTILINE)
+ self.assertRegex(debugout, to_addr)
+
+
+class NonConnectingTests(unittest.TestCase):
-class NonConnectingTests(TestCase):
+ def setUp(self):
+ smtplib.socket = mock_socket
+
+ def tearDown(self):
+ smtplib.socket = socket
def testNotConnected(self):
# Test various operations on an unconnected SMTP object that
@@ -249,31 +374,26 @@ class NonConnectingTests(TestCase):
def testNonnumericPort(self):
# check that non-numeric port raises socket.error
- self.assertRaises(socket.error, smtplib.SMTP,
+ self.assertRaises(mock_socket.error, smtplib.SMTP,
"localhost", "bogus")
- self.assertRaises(socket.error, smtplib.SMTP,
+ self.assertRaises(mock_socket.error, smtplib.SMTP,
"localhost:bogus")
# test response of client to a non-successful HELO message
-class BadHELOServerTests(TestCase):
+@unittest.skipUnless(threading, 'Threading required for this test.')
+class BadHELOServerTests(unittest.TestCase):
def setUp(self):
+ smtplib.socket = mock_socket
+ mock_socket.reply_with(b"199 no hello for you!")
self.old_stdout = sys.stdout
self.output = io.StringIO()
sys.stdout = self.output
-
- self.evt = threading.Event()
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.settimeout(15)
- self.port = support.bind_port(self.sock)
- servargs = (self.evt, b"199 no hello for you!\n", self.sock)
- threading.Thread(target=server, args=servargs).start()
- self.evt.wait()
- self.evt.clear()
+ self.port = 25
def tearDown(self):
- self.evt.wait()
+ smtplib.socket = socket
sys.stdout = self.old_stdout
def testFailingHELO(self):
@@ -355,6 +475,9 @@ class SimSMTPChannel(smtpd.SMTPChannel):
else:
self.push('550 No access for you!')
+ def handle_error(self):
+ raise
+
class SimSMTPServer(smtpd.SMTPServer):
@@ -362,8 +485,7 @@ class SimSMTPServer(smtpd.SMTPServer):
self._extra_features = []
smtpd.SMTPServer.__init__(self, *args, **kw)
- def handle_accept(self):
- conn, addr = self.accept()
+ def handle_accepted(self, conn, addr):
self._SMTPchannel = SimSMTPChannel(self._extra_features,
self, conn, addr)
@@ -373,12 +495,19 @@ class SimSMTPServer(smtpd.SMTPServer):
def add_feature(self, feature):
self._extra_features.append(feature)
+ def handle_error(self):
+ raise
+
# Test various SMTP & ESMTP commands/behaviors that require a simulated server
# (i.e., something with more features than DebuggingServer)
-class SMTPSimTests(TestCase):
+@unittest.skipUnless(threading, 'Threading required for this test.')
+class SMTPSimTests(unittest.TestCase):
def setUp(self):
+ self.real_getfqdn = socket.getfqdn
+ socket.getfqdn = mock_socket.getfqdn
+ self._threads = support.threading_setup()
self.serv_evt = threading.Event()
self.client_evt = threading.Event()
# Pick a random unused port by passing 0 for the port number
@@ -386,17 +515,21 @@ class SMTPSimTests(TestCase):
# Keep a note of what port was assigned
self.port = self.serv.socket.getsockname()[1]
serv_args = (self.serv, self.serv_evt, self.client_evt)
- threading.Thread(target=debugging_server, args=serv_args).start()
+ self.thread = threading.Thread(target=debugging_server, args=serv_args)
+ self.thread.start()
# wait until server thread has assigned a port number
self.serv_evt.wait()
self.serv_evt.clear()
def tearDown(self):
+ socket.getfqdn = self.real_getfqdn
# indicate that the client is finished
self.client_evt.set()
# wait for the server thread to terminate
self.serv_evt.wait()
+ self.thread.join()
+ support.threading_cleanup(*self._threads)
def testBasic(self):
# smoke test
@@ -460,6 +593,7 @@ class SMTPSimTests(TestCase):
expected_auth_ok = (235, b'plain auth ok')
self.assertEqual(smtp.login(sim_auth[0], sim_auth[1]), expected_auth_ok)
+ smtp.close()
# SimSMTPChannel doesn't fully support LOGIN or CRAM-MD5 auth because they
# require a synchronous read to obtain the credentials...so instead smtpd
@@ -474,8 +608,8 @@ class SMTPSimTests(TestCase):
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
try: smtp.login(sim_auth[0], sim_auth[1])
except smtplib.SMTPAuthenticationError as err:
- if sim_auth_login_password not in str(err):
- raise "expected encoded password not found in error message"
+ self.assertIn(sim_auth_login_password, str(err))
+ smtp.close()
def testAUTH_CRAM_MD5(self):
self.serv.add_feature("AUTH CRAM-MD5")
@@ -483,8 +617,8 @@ class SMTPSimTests(TestCase):
try: smtp.login(sim_auth[0], sim_auth[1])
except smtplib.SMTPAuthenticationError as err:
- if sim_auth_credentials['cram-md5'] not in str(err):
- raise "expected encoded credentials not found in error message"
+ self.assertIn(sim_auth_credentials['cram-md5'], str(err))
+ smtp.close()
#TODO: add tests for correct AUTH method fallback now that the
#test infrastructure can support it.
diff --git a/Lib/test/test_smtpnet.py b/Lib/test/test_smtpnet.py
index 6634df783b..f0f1edd127 100644
--- a/Lib/test/test_smtpnet.py
+++ b/Lib/test/test_smtpnet.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
from test import support
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 67c541388b..9ba391e7cb 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1,23 +1,27 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
from test import support
import errno
+import io
import socket
import select
-import _thread as thread
-import threading
import time
import traceback
import queue
import sys
import os
import array
+import platform
import contextlib
from weakref import proxy
import signal
import math
+try:
+ import fcntl
+except ImportError:
+ fcntl = False
def try_address(host, port=0, family=socket.AF_INET):
"""Try to bind a socket on the given host:port and return True
@@ -31,10 +35,25 @@ def try_address(host, port=0, family=socket.AF_INET):
sock.close()
return True
+def linux_version():
+ try:
+ # platform.release() is something like '2.6.33.7-desktop-2mnb'
+ version_string = platform.release().split('-')[0]
+ return tuple(map(int, version_string.split('.')))
+ except ValueError:
+ return 0, 0, 0
+
HOST = support.HOST
MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf8') ## test unicode string and carriage return
SUPPORTS_IPV6 = socket.has_ipv6 and try_address('::1', family=socket.AF_INET6)
+try:
+ import _thread as thread
+ import threading
+except ImportError:
+ thread = None
+ threading = None
+
class SocketTCPTest(unittest.TestCase):
def setUp(self):
@@ -132,8 +151,8 @@ class ThreadableTest:
self.done.wait()
if self.queue.qsize():
- msg = self.queue.get()
- self.fail(msg)
+ exc = self.queue.get()
+ raise exc
def clientRun(self, test_func):
self.server_ready.wait()
@@ -143,9 +162,10 @@ class ThreadableTest:
raise TypeError("test_func must be a callable function")
try:
test_func()
- except Exception as strerror:
- self.queue.put(strerror)
- self.clientTearDown()
+ except BaseException as e:
+ self.queue.put(e)
+ finally:
+ self.clientTearDown()
def clientSetUp(self):
raise NotImplementedError("clientSetUp must be implemented.")
@@ -244,6 +264,7 @@ class GeneralModuleTests(unittest.TestCase):
def test_repr(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.addCleanup(s.close)
self.assertTrue(repr(s).startswith("<socket.socket object"))
def test_weakref(self):
@@ -517,6 +538,7 @@ class GeneralModuleTests(unittest.TestCase):
# Testing getsockname()
port = self._get_unused_port()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.addCleanup(sock.close)
sock.bind(("0.0.0.0", port))
name = sock.getsockname()
# XXX(nnorwitz): http://tinyurl.com/os5jz seems to indicate
@@ -527,19 +549,21 @@ class GeneralModuleTests(unittest.TestCase):
except socket.error:
# Probably name lookup wasn't set up right; skip this test
return
- self.assertTrue(name[0] in ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
+ self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
self.assertEqual(name[1], port)
def testGetSockOpt(self):
# Testing getsockopt()
# We know a socket should start without reuse==0
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.addCleanup(sock.close)
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
self.assertFalse(reuse != 0, "initial mode is reuse")
def testSetSockOpt(self):
# Testing setsockopt()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.addCleanup(sock.close)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
self.assertFalse(reuse == 0, "failed to set reuse mode")
@@ -572,13 +596,17 @@ class GeneralModuleTests(unittest.TestCase):
finally:
sock.close()
+ @unittest.skipUnless(os.name == "nt", "Windows specific")
def test_sock_ioctl(self):
- if os.name != "nt":
- return
self.assertTrue(hasattr(socket.socket, 'ioctl'))
self.assertTrue(hasattr(socket, 'SIO_RCVALL'))
self.assertTrue(hasattr(socket, 'RCVALL_ON'))
self.assertTrue(hasattr(socket, 'RCVALL_OFF'))
+ self.assertTrue(hasattr(socket, 'SIO_KEEPALIVE_VALS'))
+ s = socket.socket()
+ self.addCleanup(s.close)
+ self.assertRaises(ValueError, s.ioctl, -1, None)
+ s.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 100, 100))
def testGetaddrinfo(self):
try:
@@ -617,7 +645,46 @@ class GeneralModuleTests(unittest.TestCase):
# usually do this
socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0,
socket.AI_PASSIVE)
-
+ # test keyword arguments
+ a = socket.getaddrinfo(HOST, None)
+ b = socket.getaddrinfo(host=HOST, port=None)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(HOST, None, socket.AF_INET)
+ b = socket.getaddrinfo(HOST, None, family=socket.AF_INET)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(HOST, None, 0, socket.SOCK_STREAM)
+ b = socket.getaddrinfo(HOST, None, type=socket.SOCK_STREAM)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(HOST, None, 0, 0, socket.SOL_TCP)
+ b = socket.getaddrinfo(HOST, None, proto=socket.SOL_TCP)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(HOST, None, 0, 0, 0, socket.AI_PASSIVE)
+ b = socket.getaddrinfo(HOST, None, flags=socket.AI_PASSIVE)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0,
+ socket.AI_PASSIVE)
+ b = socket.getaddrinfo(host=None, port=0, family=socket.AF_UNSPEC,
+ type=socket.SOCK_STREAM, proto=0,
+ flags=socket.AI_PASSIVE)
+ self.assertEqual(a, b)
+ # Issue #6697.
+ self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800')
+
+ def test_getnameinfo(self):
+ # only IP addresses are allowed
+ self.assertRaises(socket.error, socket.getnameinfo, ('mail.python.org',0), 0)
+
+ @unittest.skipUnless(support.is_resource_enabled('network'),
+ 'network is not enabled')
+ def test_idna(self):
+ support.requires('network')
+ # these should all be successful
+ socket.gethostbyname('иÑпытание.python.org')
+ socket.gethostbyname_ex('иÑпытание.python.org')
+ socket.getaddrinfo('иÑпытание.python.org',0,socket.AF_UNSPEC,socket.SOCK_STREAM)
+ # this may not work if the forward lookup choses the IPv6 address, as that doesn't
+ # have a reverse entry yet
+ # socket.gethostbyaddr('иÑпытание.python.org')
def check_sendall_interrupted(self, with_timeout):
# socketpair() is not stricly required, but it makes things easier.
@@ -654,7 +721,31 @@ class GeneralModuleTests(unittest.TestCase):
def test_sendall_interrupted_with_timeout(self):
self.check_sendall_interrupted(True)
-
+ def test_dealloc_warn(self):
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ r = repr(sock)
+ with self.assertWarns(ResourceWarning) as cm:
+ sock = None
+ support.gc_collect()
+ self.assertIn(r, str(cm.warning.args[0]))
+ # An open socket file object gets dereferenced after the socket
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ f = sock.makefile('rb')
+ r = repr(sock)
+ sock = None
+ support.gc_collect()
+ with self.assertWarns(ResourceWarning):
+ f = None
+ support.gc_collect()
+
+ def test_name_closed_socketio(self):
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
+ fp = sock.makefile("rb")
+ fp.close()
+ self.assertEqual(repr(fp), "<_io.BufferedReader name=-1>")
+
+
+@unittest.skipUnless(thread, 'Threading required for this test.')
class BasicTCPTest(SocketConnectedTest):
def __init__(self, methodName='runTest'):
@@ -712,10 +803,10 @@ class BasicTCPTest(SocketConnectedTest):
def testFromFd(self):
# Testing fromfd()
- if not hasattr(socket, "fromfd"):
- return # On Windows, this doesn't exist
fd = self.cli_conn.fileno()
sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
+ self.addCleanup(sock.close)
+ self.assertIsInstance(sock, socket.socket)
msg = sock.recv(1024)
self.assertEqual(msg, MSG)
@@ -725,6 +816,7 @@ class BasicTCPTest(SocketConnectedTest):
def testDup(self):
# Testing dup()
sock = self.cli_conn.dup()
+ self.addCleanup(sock.close)
msg = sock.recv(1024)
self.assertEqual(msg, MSG)
@@ -744,6 +836,25 @@ class BasicTCPTest(SocketConnectedTest):
self.serv_conn.send(MSG)
self.serv_conn.shutdown(2)
+ def testDetach(self):
+ # Testing detach()
+ fileno = self.cli_conn.fileno()
+ f = self.cli_conn.detach()
+ self.assertEqual(f, fileno)
+ # cli_conn cannot be used anymore...
+ self.assertRaises(socket.error, self.cli_conn.recv, 1024)
+ self.cli_conn.close()
+ # ...but we can create another socket using the (still open)
+ # file descriptor
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f)
+ self.addCleanup(sock.close)
+ msg = sock.recv(1024)
+ self.assertEqual(msg, MSG)
+
+ def _testDetach(self):
+ self.serv_conn.send(MSG)
+
+@unittest.skipUnless(thread, 'Threading required for this test.')
class BasicUDPTest(ThreadedUDPSocketTest):
def __init__(self, methodName='runTest'):
@@ -772,6 +883,7 @@ class BasicUDPTest(ThreadedUDPSocketTest):
def _testRecvFromNegative(self):
self.cli.sendto(MSG, 0, (HOST, self.port))
+@unittest.skipUnless(thread, 'Threading required for this test.')
class TCPCloserTest(ThreadedTCPSocketTest):
def testClose(self):
@@ -791,11 +903,27 @@ class TCPCloserTest(ThreadedTCPSocketTest):
self.cli.connect((HOST, self.port))
time.sleep(1.0)
+@unittest.skipUnless(thread, 'Threading required for this test.')
class BasicSocketPairTest(SocketPairTest):
def __init__(self, methodName='runTest'):
SocketPairTest.__init__(self, methodName=methodName)
+ def _check_defaults(self, sock):
+ self.assertIsInstance(sock, socket.socket)
+ if hasattr(socket, 'AF_UNIX'):
+ self.assertEqual(sock.family, socket.AF_UNIX)
+ else:
+ self.assertEqual(sock.family, socket.AF_INET)
+ self.assertEqual(sock.type, socket.SOCK_STREAM)
+ self.assertEqual(sock.proto, 0)
+
+ def _testDefaults(self):
+ self._check_defaults(self.cli)
+
+ def testDefaults(self):
+ self._check_defaults(self.serv)
+
def testRecv(self):
msg = self.serv.recv(1024)
self.assertEqual(msg, MSG)
@@ -810,6 +938,7 @@ class BasicSocketPairTest(SocketPairTest):
msg = self.cli.recv(1024)
self.assertEqual(msg, MSG)
+@unittest.skipUnless(thread, 'Threading required for this test.')
class NonBlockingTCPTests(ThreadedTCPSocketTest):
def __init__(self, methodName='runTest'):
@@ -829,6 +958,47 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
def _testSetBlocking(self):
pass
+ if hasattr(socket, "SOCK_NONBLOCK"):
+ def testInitNonBlocking(self):
+ v = linux_version()
+ if v < (2, 6, 28):
+ self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
+ % ".".join(map(str, v)))
+ # reinit server socket
+ self.serv.close()
+ self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM |
+ socket.SOCK_NONBLOCK)
+ self.port = support.bind_port(self.serv)
+ self.serv.listen(1)
+ # actual testing
+ start = time.time()
+ try:
+ self.serv.accept()
+ except socket.error:
+ pass
+ end = time.time()
+ self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.")
+
+ def _testInitNonBlocking(self):
+ pass
+
+ def testInheritFlags(self):
+ # Issue #7995: when calling accept() on a listening socket with a
+ # timeout, the resulting socket should not be non-blocking.
+ self.serv.settimeout(10)
+ try:
+ conn, addr = self.serv.accept()
+ message = conn.recv(len(MSG))
+ finally:
+ conn.close()
+ self.serv.settimeout(None)
+
+ def _testInheritFlags(self):
+ time.sleep(0.1)
+ self.cli.connect((HOST, self.port))
+ time.sleep(0.5)
+ self.cli.send(MSG)
+
def testAccept(self):
# Testing non-blocking accept
self.serv.setblocking(0)
@@ -841,6 +1011,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
read, write, err = select.select([self.serv], [], [])
if self.serv in read:
conn, addr = self.serv.accept()
+ conn.close()
else:
self.fail("Error trying to do accept after select.")
@@ -851,6 +1022,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
def testConnect(self):
# Testing non-blocking connect
conn, addr = self.serv.accept()
+ conn.close()
def _testConnect(self):
self.cli.settimeout(10)
@@ -869,6 +1041,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
read, write, err = select.select([conn], [], [])
if conn in read:
msg = conn.recv(len(MSG))
+ conn.close()
self.assertEqual(msg, MSG)
else:
self.fail("Error during select call to non-blocking socket.")
@@ -878,6 +1051,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
time.sleep(0.1)
self.cli.send(MSG)
+@unittest.skipUnless(thread, 'Threading required for this test.')
class FileObjectClassTestCase(SocketConnectedTest):
"""Unit tests for the object returned by socket.makefile()
@@ -904,6 +1078,8 @@ class FileObjectClassTestCase(SocketConnectedTest):
SocketConnectedTest.__init__(self, methodName=methodName)
def setUp(self):
+ self.evt1, self.evt2, self.serv_finished, self.cli_finished = [
+ threading.Event() for i in range(4)]
SocketConnectedTest.setUp(self)
self.read_file = self.cli_conn.makefile(
self.read_mode, self.bufsize,
@@ -912,6 +1088,7 @@ class FileObjectClassTestCase(SocketConnectedTest):
newline = self.newline)
def tearDown(self):
+ self.serv_finished.set()
self.read_file.close()
self.assertTrue(self.read_file.closed)
self.read_file = None
@@ -926,11 +1103,29 @@ class FileObjectClassTestCase(SocketConnectedTest):
newline = self.newline)
def clientTearDown(self):
+ self.cli_finished.set()
self.write_file.close()
self.assertTrue(self.write_file.closed)
self.write_file = None
SocketConnectedTest.clientTearDown(self)
+ def testReadAfterTimeout(self):
+ # Issue #7322: A file object must disallow further reads
+ # after a timeout has occurred.
+ self.cli_conn.settimeout(1)
+ self.read_file.read(3)
+ # First read raises a timeout
+ self.assertRaises(socket.timeout, self.read_file.read, 1)
+ # Second read is disallowed
+ with self.assertRaises(IOError) as ctx:
+ self.read_file.read(1)
+ self.assertIn("cannot read from timed out object", str(ctx.exception))
+
+ def _testReadAfterTimeout(self):
+ self.write_file.write(self.write_msg[0:3])
+ self.write_file.flush()
+ self.serv_finished.wait()
+
def testSmallRead(self):
# Performing small file read test
first_seg = self.read_file.read(len(self.read_msg)-3)
@@ -1020,6 +1215,117 @@ class FileObjectClassTestCase(SocketConnectedTest):
pass
+class FileObjectInterruptedTestCase(unittest.TestCase):
+ """Test that the file object correctly handles EINTR internally."""
+
+ class MockSocket(object):
+ def __init__(self, recv_funcs=()):
+ # A generator that returns callables that we'll call for each
+ # call to recv().
+ self._recv_step = iter(recv_funcs)
+
+ def recv_into(self, buffer):
+ data = next(self._recv_step)()
+ assert len(buffer) >= len(data)
+ buffer[:len(data)] = data
+ return len(data)
+
+ def _decref_socketios(self):
+ pass
+
+ def _textiowrap_for_test(self, buffering=-1):
+ raw = socket.SocketIO(self, "r")
+ if buffering < 0:
+ buffering = io.DEFAULT_BUFFER_SIZE
+ if buffering == 0:
+ return raw
+ buffer = io.BufferedReader(raw, buffering)
+ text = io.TextIOWrapper(buffer, None, None)
+ text.mode = "rb"
+ return text
+
+ @staticmethod
+ def _raise_eintr():
+ raise socket.error(errno.EINTR)
+
+ def _textiowrap_mock_socket(self, mock, buffering=-1):
+ raw = socket.SocketIO(mock, "r")
+ if buffering < 0:
+ buffering = io.DEFAULT_BUFFER_SIZE
+ if buffering == 0:
+ return raw
+ buffer = io.BufferedReader(raw, buffering)
+ text = io.TextIOWrapper(buffer, None, None)
+ text.mode = "rb"
+ return text
+
+ def _test_readline(self, size=-1, buffering=-1):
+ mock_sock = self.MockSocket(recv_funcs=[
+ lambda : b"This is the first line\nAnd the sec",
+ self._raise_eintr,
+ lambda : b"ond line is here\n",
+ lambda : b"",
+ lambda : b"", # XXX(gps): io library does an extra EOF read
+ ])
+ fo = mock_sock._textiowrap_for_test(buffering=buffering)
+ self.assertEqual(fo.readline(size), "This is the first line\n")
+ self.assertEqual(fo.readline(size), "And the second line is here\n")
+
+ def _test_read(self, size=-1, buffering=-1):
+ mock_sock = self.MockSocket(recv_funcs=[
+ lambda : b"This is the first line\nAnd the sec",
+ self._raise_eintr,
+ lambda : b"ond line is here\n",
+ lambda : b"",
+ lambda : b"", # XXX(gps): io library does an extra EOF read
+ ])
+ expecting = (b"This is the first line\n"
+ b"And the second line is here\n")
+ fo = mock_sock._textiowrap_for_test(buffering=buffering)
+ if buffering == 0:
+ data = b''
+ else:
+ data = ''
+ expecting = expecting.decode('utf8')
+ while len(data) != len(expecting):
+ part = fo.read(size)
+ if not part:
+ break
+ data += part
+ self.assertEqual(data, expecting)
+
+ def test_default(self):
+ self._test_readline()
+ self._test_readline(size=100)
+ self._test_read()
+ self._test_read(size=100)
+
+ def test_with_1k_buffer(self):
+ self._test_readline(buffering=1024)
+ self._test_readline(size=100, buffering=1024)
+ self._test_read(buffering=1024)
+ self._test_read(size=100, buffering=1024)
+
+ def _test_readline_no_buffer(self, size=-1):
+ mock_sock = self.MockSocket(recv_funcs=[
+ lambda : b"a",
+ lambda : b"\n",
+ lambda : b"B",
+ self._raise_eintr,
+ lambda : b"b",
+ lambda : b"",
+ ])
+ fo = mock_sock._textiowrap_for_test(buffering=0)
+ self.assertEqual(fo.readline(size), b"a\n")
+ self.assertEqual(fo.readline(size), b"Bb")
+
+ def test_no_buffer(self):
+ self._test_readline_no_buffer()
+ self._test_readline_no_buffer(size=4)
+ self._test_read(buffering=0)
+ self._test_read(size=100, buffering=0)
+
+
class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase):
"""Repeat the tests from FileObjectClassTestCase with bufsize==0.
@@ -1067,6 +1373,62 @@ class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase):
def _testMakefileCloseSocketDestroy(self):
pass
+ # Non-blocking ops
+ # NOTE: to set `read_file` as non-blocking, we must call
+ # `cli_conn.setblocking` and vice-versa (see setUp / clientSetUp).
+
+ def testSmallReadNonBlocking(self):
+ self.cli_conn.setblocking(False)
+ self.assertEqual(self.read_file.readinto(bytearray(10)), None)
+ self.assertEqual(self.read_file.read(len(self.read_msg) - 3), None)
+ self.evt1.set()
+ self.evt2.wait(1.0)
+ first_seg = self.read_file.read(len(self.read_msg) - 3)
+ buf = bytearray(10)
+ n = self.read_file.readinto(buf)
+ self.assertEqual(n, 3)
+ msg = first_seg + buf[:n]
+ self.assertEqual(msg, self.read_msg)
+ self.assertEqual(self.read_file.readinto(bytearray(16)), None)
+ self.assertEqual(self.read_file.read(1), None)
+
+ def _testSmallReadNonBlocking(self):
+ self.evt1.wait(1.0)
+ self.write_file.write(self.write_msg)
+ self.write_file.flush()
+ self.evt2.set()
+ # Avoid cloding the socket before the server test has finished,
+ # otherwise system recv() will return 0 instead of EWOULDBLOCK.
+ self.serv_finished.wait(5.0)
+
+ def testWriteNonBlocking(self):
+ self.cli_finished.wait(5.0)
+ # The client thread can't skip directly - the SkipTest exception
+ # would appear as a failure.
+ if self.serv_skipped:
+ self.skipTest(self.serv_skipped)
+
+ def _testWriteNonBlocking(self):
+ self.serv_skipped = None
+ self.serv_conn.setblocking(False)
+ # Try to saturate the socket buffer pipe with repeated large writes.
+ BIG = b"x" * (1024 ** 2)
+ LIMIT = 10
+ # The first write() succeeds since a chunk of data can be buffered
+ n = self.write_file.write(BIG)
+ self.assertGreater(n, 0)
+ for i in range(LIMIT):
+ n = self.write_file.write(BIG)
+ if n is None:
+ # Succeeded
+ break
+ self.assertGreater(n, 0)
+ else:
+ # Let us know that this test didn't manage to establish
+ # the expected conditions. This is not a failure in itself but,
+ # if it happens repeatedly, the test should be fixed.
+ self.serv_skipped = "failed to saturate the socket buffer"
+
class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase):
@@ -1140,23 +1502,18 @@ class NetworkConnectionNoServer(unittest.TestCase):
def test_connect(self):
port = support.find_unused_port()
cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- try:
+ self.addCleanup(cli.close)
+ with self.assertRaises(socket.error) as cm:
cli.connect((HOST, port))
- except socket.error as err:
- self.assertEqual(err.errno, errno.ECONNREFUSED)
- else:
- self.fail("socket.error not raised")
+ self.assertEqual(cm.exception.errno, errno.ECONNREFUSED)
def test_create_connection(self):
# Issue #9792: errors raised by create_connection() should have
# a proper errno attribute.
port = support.find_unused_port()
- try:
+ with self.assertRaises(socket.error) as cm:
socket.create_connection((HOST, port))
- except socket.error as err:
- self.assertEqual(err.errno, errno.ECONNREFUSED)
- else:
- self.fail("socket.error not raised")
+ self.assertEqual(cm.exception.errno, errno.ECONNREFUSED)
def test_create_connection_timeout(self):
# Issue #9792: create_connection() should not recast timeout errors
@@ -1166,6 +1523,7 @@ class NetworkConnectionNoServer(unittest.TestCase):
socket.create_connection((HOST, 1234))
+@unittest.skipUnless(thread, 'Threading required for this test.')
class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
def __init__(self, methodName='runTest'):
@@ -1173,7 +1531,7 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
ThreadableTest.__init__(self)
def clientSetUp(self):
- pass
+ self.source_port = support.find_unused_port()
def clientTearDown(self):
self.cli.close()
@@ -1182,12 +1540,23 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
def _justAccept(self):
conn, addr = self.serv.accept()
+ conn.close()
testFamily = _justAccept
def _testFamily(self):
self.cli = socket.create_connection((HOST, self.port), timeout=30)
+ self.addCleanup(self.cli.close)
self.assertEqual(self.cli.family, 2)
+ testSourceAddress = _justAccept
+ def _testSourceAddress(self):
+ self.cli = socket.create_connection((HOST, self.port), timeout=30,
+ source_address=('', self.source_port))
+ self.addCleanup(self.cli.close)
+ self.assertEqual(self.cli.getsockname()[1], self.source_port)
+ # The port number being used is sufficient to show that the bind()
+ # call happened.
+
testTimeoutDefault = _justAccept
def _testTimeoutDefault(self):
# passing no explicit timeout uses socket's global default
@@ -1195,6 +1564,7 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
socket.setdefaulttimeout(42)
try:
self.cli = socket.create_connection((HOST, self.port))
+ self.addCleanup(self.cli.close)
finally:
socket.setdefaulttimeout(None)
self.assertEqual(self.cli.gettimeout(), 42)
@@ -1206,6 +1576,7 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
socket.setdefaulttimeout(30)
try:
self.cli = socket.create_connection((HOST, self.port), timeout=None)
+ self.addCleanup(self.cli.close)
finally:
socket.setdefaulttimeout(None)
self.assertEqual(self.cli.gettimeout(), None)
@@ -1218,8 +1589,10 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
testTimeoutValueNonamed = _justAccept
def _testTimeoutValueNonamed(self):
self.cli = socket.create_connection((HOST, self.port), 30)
+ self.addCleanup(self.cli.close)
self.assertEqual(self.cli.gettimeout(), 30)
+@unittest.skipUnless(thread, 'Threading required for this test.')
class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest):
def __init__(self, methodName='runTest'):
@@ -1236,6 +1609,7 @@ class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest):
def testInsideTimeout(self):
conn, addr = self.serv.accept()
+ self.addCleanup(conn.close)
time.sleep(3)
conn.send(b"done!")
testOutsideTimeout = testInsideTimeout
@@ -1344,27 +1718,28 @@ class TestLinuxAbstractNamespace(unittest.TestCase):
def testLinuxAbstractNamespace(self):
address = b"\x00python-test-hello\x00\xff"
- s1 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s1.bind(address)
- s1.listen(1)
- s2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s2.connect(s1.getsockname())
- s1.accept()
- self.assertEqual(s1.getsockname(), address)
- self.assertEqual(s2.getpeername(), address)
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s1:
+ s1.bind(address)
+ s1.listen(1)
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s2:
+ s2.connect(s1.getsockname())
+ with s1.accept()[0] as s3:
+ self.assertEqual(s1.getsockname(), address)
+ self.assertEqual(s2.getpeername(), address)
def testMaxName(self):
address = b"\x00" + b"h" * (self.UNIX_PATH_MAX - 1)
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.bind(address)
- self.assertEqual(s.getsockname(), address)
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
+ s.bind(address)
+ self.assertEqual(s.getsockname(), address)
def testNameOverflow(self):
address = "\x00" + "h" * self.UNIX_PATH_MAX
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- self.assertRaises(socket.error, s.bind, address)
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
+ self.assertRaises(socket.error, s.bind, address)
+@unittest.skipUnless(thread, 'Threading required for this test.')
class BufferIOTest(SocketConnectedTest):
"""
Test the buffer versions of socket.recv() and socket.send().
@@ -1372,28 +1747,64 @@ class BufferIOTest(SocketConnectedTest):
def __init__(self, methodName='runTest'):
SocketConnectedTest.__init__(self, methodName=methodName)
- def testRecvInto(self):
+ def testRecvIntoArray(self):
buf = bytearray(1024)
nbytes = self.cli_conn.recv_into(buf)
self.assertEqual(nbytes, len(MSG))
msg = buf[:len(MSG)]
self.assertEqual(msg, MSG)
- def _testRecvInto(self):
+ def _testRecvIntoArray(self):
buf = bytes(MSG)
self.serv_conn.send(buf)
- def testRecvFromInto(self):
+ def testRecvIntoBytearray(self):
+ buf = bytearray(1024)
+ nbytes = self.cli_conn.recv_into(buf)
+ self.assertEqual(nbytes, len(MSG))
+ msg = buf[:len(MSG)]
+ self.assertEqual(msg, MSG)
+
+ _testRecvIntoBytearray = _testRecvIntoArray
+
+ def testRecvIntoMemoryview(self):
+ buf = bytearray(1024)
+ nbytes = self.cli_conn.recv_into(memoryview(buf))
+ self.assertEqual(nbytes, len(MSG))
+ msg = buf[:len(MSG)]
+ self.assertEqual(msg, MSG)
+
+ _testRecvIntoMemoryview = _testRecvIntoArray
+
+ def testRecvFromIntoArray(self):
buf = bytearray(1024)
nbytes, addr = self.cli_conn.recvfrom_into(buf)
self.assertEqual(nbytes, len(MSG))
msg = buf[:len(MSG)]
self.assertEqual(msg, MSG)
- def _testRecvFromInto(self):
+ def _testRecvFromIntoArray(self):
buf = bytes(MSG)
self.serv_conn.send(buf)
+ def testRecvFromIntoBytearray(self):
+ buf = bytearray(1024)
+ nbytes, addr = self.cli_conn.recvfrom_into(buf)
+ self.assertEqual(nbytes, len(MSG))
+ msg = buf[:len(MSG)]
+ self.assertEqual(msg, MSG)
+
+ _testRecvFromIntoBytearray = _testRecvFromIntoArray
+
+ def testRecvFromIntoMemoryview(self):
+ buf = bytearray(1024)
+ nbytes, addr = self.cli_conn.recvfrom_into(memoryview(buf))
+ self.assertEqual(nbytes, len(MSG))
+ msg = buf[:len(MSG)]
+ self.assertEqual(msg, MSG)
+
+ _testRecvFromIntoMemoryview = _testRecvFromIntoArray
+
TIPC_STYPE = 2000
TIPC_LOWER = 200
@@ -1473,15 +1884,122 @@ class TIPCThreadableTest (unittest.TestCase, ThreadableTest):
self.cli.close()
+@unittest.skipUnless(thread, 'Threading required for this test.')
+class ContextManagersTest(ThreadedTCPSocketTest):
+
+ def _testSocketClass(self):
+ # base test
+ with socket.socket() as sock:
+ self.assertFalse(sock._closed)
+ self.assertTrue(sock._closed)
+ # close inside with block
+ with socket.socket() as sock:
+ sock.close()
+ self.assertTrue(sock._closed)
+ # exception inside with block
+ with socket.socket() as sock:
+ self.assertRaises(socket.error, sock.sendall, b'foo')
+ self.assertTrue(sock._closed)
+
+ def testCreateConnectionBase(self):
+ conn, addr = self.serv.accept()
+ self.addCleanup(conn.close)
+ data = conn.recv(1024)
+ conn.sendall(data)
+
+ def _testCreateConnectionBase(self):
+ address = self.serv.getsockname()
+ with socket.create_connection(address) as sock:
+ self.assertFalse(sock._closed)
+ sock.sendall(b'foo')
+ self.assertEqual(sock.recv(1024), b'foo')
+ self.assertTrue(sock._closed)
+
+ def testCreateConnectionClose(self):
+ conn, addr = self.serv.accept()
+ self.addCleanup(conn.close)
+ data = conn.recv(1024)
+ conn.sendall(data)
+
+ def _testCreateConnectionClose(self):
+ address = self.serv.getsockname()
+ with socket.create_connection(address) as sock:
+ sock.close()
+ self.assertTrue(sock._closed)
+ self.assertRaises(socket.error, sock.sendall, b'foo')
+
+
+@unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"),
+ "SOCK_CLOEXEC not defined")
+@unittest.skipUnless(fcntl, "module fcntl not available")
+class CloexecConstantTest(unittest.TestCase):
+ def test_SOCK_CLOEXEC(self):
+ v = linux_version()
+ if v < (2, 6, 28):
+ self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
+ % ".".join(map(str, v)))
+ with socket.socket(socket.AF_INET,
+ socket.SOCK_STREAM | socket.SOCK_CLOEXEC) as s:
+ self.assertTrue(s.type & socket.SOCK_CLOEXEC)
+ self.assertTrue(fcntl.fcntl(s, fcntl.F_GETFD) & fcntl.FD_CLOEXEC)
+
+
+@unittest.skipUnless(hasattr(socket, "SOCK_NONBLOCK"),
+ "SOCK_NONBLOCK not defined")
+class NonblockConstantTest(unittest.TestCase):
+ def checkNonblock(self, s, nonblock=True, timeout=0.0):
+ if nonblock:
+ self.assertTrue(s.type & socket.SOCK_NONBLOCK)
+ self.assertEqual(s.gettimeout(), timeout)
+ else:
+ self.assertFalse(s.type & socket.SOCK_NONBLOCK)
+ self.assertEqual(s.gettimeout(), None)
+
+ def test_SOCK_NONBLOCK(self):
+ v = linux_version()
+ if v < (2, 6, 28):
+ self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
+ % ".".join(map(str, v)))
+ # a lot of it seems silly and redundant, but I wanted to test that
+ # changing back and forth worked ok
+ with socket.socket(socket.AF_INET,
+ socket.SOCK_STREAM | socket.SOCK_NONBLOCK) as s:
+ self.checkNonblock(s)
+ s.setblocking(1)
+ self.checkNonblock(s, False)
+ s.setblocking(0)
+ self.checkNonblock(s)
+ s.settimeout(None)
+ self.checkNonblock(s, False)
+ s.settimeout(2.0)
+ self.checkNonblock(s, timeout=2.0)
+ s.setblocking(1)
+ self.checkNonblock(s, False)
+ # defaulttimeout
+ t = socket.getdefaulttimeout()
+ socket.setdefaulttimeout(0.0)
+ with socket.socket() as s:
+ self.checkNonblock(s)
+ socket.setdefaulttimeout(None)
+ with socket.socket() as s:
+ self.checkNonblock(s, False)
+ socket.setdefaulttimeout(2.0)
+ with socket.socket() as s:
+ self.checkNonblock(s, timeout=2.0)
+ socket.setdefaulttimeout(None)
+ with socket.socket() as s:
+ self.checkNonblock(s, False)
+ socket.setdefaulttimeout(t)
+
+
def test_main():
tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest,
- TestExceptions, BufferIOTest, BasicTCPTest2]
- if sys.platform != 'mac':
- tests.extend([ BasicUDPTest, UDPTimeoutTest ])
+ TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ]
tests.extend([
NonBlockingTCPTests,
FileObjectClassTestCase,
+ FileObjectInterruptedTestCase,
UnbufferedFileObjectClassTestCase,
LineBufferedFileObjectClassTestCase,
SmallBufferedFileObjectClassTestCase,
@@ -1491,6 +2009,9 @@ def test_main():
NetworkConnectionNoServer,
NetworkConnectionAttributesTest,
NetworkConnectionBehaviourTest,
+ ContextManagersTest,
+ CloexecConstantTest,
+ NonblockConstantTest
])
if hasattr(socket, "socketpair"):
tests.append(BasicSocketPairTest)
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index a098edd8f1..d4c3621b79 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -3,21 +3,21 @@ Test suite for socketserver.
"""
import contextlib
-import errno
import imp
import os
import select
import signal
import socket
import tempfile
-import threading
-import time
import unittest
import socketserver
import test.support
-from test.support import reap_children, verbose
-from test.support import TESTFN as TEST_FILE
+from test.support import reap_children, reap_threads, verbose
+try:
+ import threading
+except ImportError:
+ threading = None
test.support.requires("network")
@@ -123,6 +123,8 @@ class SocketServerTest(unittest.TestCase):
self.assertEqual(server.server_address, server.socket.getsockname())
return server
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ @reap_threads
def run_server(self, svrcls, hdlrbase, testfunc):
server = self.make_server(self.pickaddr(svrcls.address_family),
svrcls, hdlrbase)
@@ -149,6 +151,7 @@ class SocketServerTest(unittest.TestCase):
if verbose: print("waiting for server")
server.shutdown()
t.join()
+ server.server_close()
if verbose: print("done")
def stream_examine(self, proto, addr):
@@ -244,6 +247,7 @@ class SocketServerTest(unittest.TestCase):
# socketserver.DatagramRequestHandler,
# self.dgram_examine)
+ @reap_threads
def test_shutdown(self):
# Issue #2302: shutdown() should always succeed in making an
# other thread leave serve_forever().
@@ -267,6 +271,7 @@ class SocketServerTest(unittest.TestCase):
s.shutdown()
for t, s in threads:
t.join()
+ s.server_close()
def test_main():
diff --git a/Lib/test/test_sqlite.py b/Lib/test/test_sqlite.py
index ec6f634592..1086330ab0 100644
--- a/Lib/test/test_sqlite.py
+++ b/Lib/test/test_sqlite.py
@@ -1,17 +1,23 @@
-import unittest
-from test.support import run_unittest, import_module
+import test.support
# Skip test if _sqlite3 module not installed
-import_module('_sqlite3')
+test.support.import_module('_sqlite3')
+import sqlite3
from sqlite3.test import (dbapi, types, userfunctions,
factory, transactions, hooks, regression,
dump)
def test_main():
- run_unittest(dbapi.suite(), types.suite(), userfunctions.suite(),
- factory.suite(), transactions.suite(),
- hooks.suite(), regression.suite(), dump.suite())
+ if test.support.verbose:
+ print("test_sqlite: testing with version",
+ "{!r}, sqlite_version {!r}".format(sqlite3.version,
+ sqlite3.sqlite_version))
+ test.support.run_unittest(dbapi.suite(), types.suite(),
+ userfunctions.suite(),
+ factory.suite(), transactions.suite(),
+ hooks.suite(), regression.suite(),
+ dump.suite())
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index bb38890b65..164b6c262a 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -5,39 +5,81 @@ import unittest
from test import support
import socket
import select
-import errno
-import subprocess
import time
import gc
import os
import errno
import pprint
-import urllib.parse, urllib.request
-import shutil
+import tempfile
+import urllib.request
import traceback
import asyncore
import weakref
+import platform
+import functools
-from http.server import HTTPServer, SimpleHTTPRequestHandler
+ssl = support.import_module("ssl")
-# Optionally test SSL support, if we have it in the tested platform
-skip_expected = False
-try:
- import ssl
-except ImportError:
- skip_expected = True
+PROTOCOLS = [
+ ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3,
+ ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1
+]
HOST = support.HOST
-CERTFILE = None
-SVN_PYTHON_ORG_ROOT_CERT = None
+
+data_file = lambda name: os.path.join(os.path.dirname(__file__), name)
+
+# The custom key and certificate files used in test_ssl are generated
+# using Lib/test/make_ssl_certs.py.
+# Other certificates are simply fetched from the Internet servers they
+# are meant to authenticate.
+
+CERTFILE = data_file("keycert.pem")
+BYTES_CERTFILE = os.fsencode(CERTFILE)
+ONLYCERT = data_file("ssl_cert.pem")
+ONLYKEY = data_file("ssl_key.pem")
+BYTES_ONLYCERT = os.fsencode(ONLYCERT)
+BYTES_ONLYKEY = os.fsencode(ONLYKEY)
+CAPATH = data_file("capath")
+BYTES_CAPATH = os.fsencode(CAPATH)
+
+SVN_PYTHON_ORG_ROOT_CERT = data_file("https_svn_python_org_root.pem")
+
+EMPTYCERT = data_file("nullcert.pem")
+BADCERT = data_file("badcert.pem")
+WRONGCERT = data_file("XXXnonexisting.pem")
+BADKEY = data_file("badkey.pem")
+
def handle_error(prefix):
exc_format = ' '.join(traceback.format_exception(*sys.exc_info()))
if support.verbose:
sys.stdout.write(prefix + exc_format)
+def can_clear_options():
+ # 0.9.8m or higher
+ return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 13, 15)
+
+def no_sslv2_implies_sslv3_hello():
+ # 0.9.7h or higher
+ return ssl.OPENSSL_VERSION_INFO >= (0, 9, 7, 8, 15)
-class BasicTests(unittest.TestCase):
+
+# Issue #9415: Ubuntu hijacks their OpenSSL and forcefully disables SSLv2
+def skip_if_broken_ubuntu_ssl(func):
+ @functools.wraps(func)
+ def f(*args, **kwargs):
+ try:
+ ssl.SSLContext(ssl.PROTOCOL_SSLv2)
+ except ssl.SSLError:
+ if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and
+ platform.linux_distribution() == ('debian', 'squeeze/sid', '')):
+ raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour")
+ return func(*args, **kwargs)
+ return f
+
+
+class BasicSocketTests(unittest.TestCase):
def test_constants(self):
ssl.PROTOCOL_SSLv2
@@ -47,6 +89,7 @@ class BasicTests(unittest.TestCase):
ssl.CERT_NONE
ssl.CERT_OPTIONAL
ssl.CERT_REQUIRED
+ self.assertIn(ssl.HAS_SNI, {True, False})
def test_random(self):
v = ssl.RAND_status()
@@ -66,7 +109,7 @@ class BasicTests(unittest.TestCase):
# note that this uses an 'unofficial' function in _ssl.c,
# provided solely for this test, to exercise the certificate
# parsing code
- p = ssl._ssl._test_decode_cert(CERTFILE, False)
+ p = ssl._ssl._test_decode_cert(CERTFILE)
if support.verbose:
sys.stdout.write("\n" + pprint.pformat(p) + "\n")
@@ -82,6 +125,33 @@ class BasicTests(unittest.TestCase):
if not p2.endswith('\n' + ssl.PEM_FOOTER + '\n'):
self.fail("DER-to-PEM didn't include correct footer:\n%r\n" % p2)
+ def test_openssl_version(self):
+ n = ssl.OPENSSL_VERSION_NUMBER
+ t = ssl.OPENSSL_VERSION_INFO
+ s = ssl.OPENSSL_VERSION
+ self.assertIsInstance(n, int)
+ self.assertIsInstance(t, tuple)
+ self.assertIsInstance(s, str)
+ # Some sanity checks follow
+ # >= 0.9
+ self.assertGreaterEqual(n, 0x900000)
+ # < 2.0
+ self.assertLess(n, 0x20000000)
+ major, minor, fix, patch, status = t
+ self.assertGreaterEqual(major, 0)
+ self.assertLess(major, 2)
+ self.assertGreaterEqual(minor, 0)
+ self.assertLess(minor, 256)
+ self.assertGreaterEqual(fix, 0)
+ self.assertLess(fix, 256)
+ self.assertGreaterEqual(patch, 0)
+ self.assertLessEqual(patch, 26)
+ self.assertGreaterEqual(status, 0)
+ self.assertLessEqual(status, 15)
+ # Version string as returned by OpenSSL, the format might change
+ self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)),
+ (s, t))
+
@support.cpython_only
def test_refcycle(self):
# Issue #7943: an SSL object doesn't create reference cycles with
@@ -113,6 +183,244 @@ class BasicTests(unittest.TestCase):
ss = ssl.wrap_socket(s)
self.assertEqual(timeout, ss.gettimeout())
+ def test_errors(self):
+ sock = socket.socket()
+ self.assertRaisesRegex(ValueError,
+ "certfile must be specified",
+ ssl.wrap_socket, sock, keyfile=CERTFILE)
+ self.assertRaisesRegex(ValueError,
+ "certfile must be specified for server-side operations",
+ ssl.wrap_socket, sock, server_side=True)
+ self.assertRaisesRegex(ValueError,
+ "certfile must be specified for server-side operations",
+ ssl.wrap_socket, sock, server_side=True, certfile="")
+ s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE)
+ self.assertRaisesRegex(ValueError, "can't connect in server-side mode",
+ s.connect, (HOST, 8080))
+ with self.assertRaises(IOError) as cm:
+ with socket.socket() as sock:
+ ssl.wrap_socket(sock, certfile=WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ with self.assertRaises(IOError) as cm:
+ with socket.socket() as sock:
+ ssl.wrap_socket(sock, certfile=CERTFILE, keyfile=WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ with self.assertRaises(IOError) as cm:
+ with socket.socket() as sock:
+ ssl.wrap_socket(sock, certfile=WRONGCERT, keyfile=WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+
+ def test_match_hostname(self):
+ def ok(cert, hostname):
+ ssl.match_hostname(cert, hostname)
+ def fail(cert, hostname):
+ self.assertRaises(ssl.CertificateError,
+ ssl.match_hostname, cert, hostname)
+
+ cert = {'subject': ((('commonName', 'example.com'),),)}
+ ok(cert, 'example.com')
+ ok(cert, 'ExAmple.cOm')
+ fail(cert, 'www.example.com')
+ fail(cert, '.example.com')
+ fail(cert, 'example.org')
+ fail(cert, 'exampleXcom')
+
+ cert = {'subject': ((('commonName', '*.a.com'),),)}
+ ok(cert, 'foo.a.com')
+ fail(cert, 'bar.foo.a.com')
+ fail(cert, 'a.com')
+ fail(cert, 'Xa.com')
+ fail(cert, '.a.com')
+
+ cert = {'subject': ((('commonName', 'a.*.com'),),)}
+ ok(cert, 'a.foo.com')
+ fail(cert, 'a..com')
+ fail(cert, 'a.com')
+
+ cert = {'subject': ((('commonName', 'f*.com'),),)}
+ ok(cert, 'foo.com')
+ ok(cert, 'f.com')
+ fail(cert, 'bar.com')
+ fail(cert, 'foo.a.com')
+ fail(cert, 'bar.foo.com')
+
+ # Slightly fake real-world example
+ cert = {'notAfter': 'Jun 26 21:41:46 2011 GMT',
+ 'subject': ((('commonName', 'linuxfrz.org'),),),
+ 'subjectAltName': (('DNS', 'linuxfr.org'),
+ ('DNS', 'linuxfr.com'),
+ ('othername', '<unsupported>'))}
+ ok(cert, 'linuxfr.org')
+ ok(cert, 'linuxfr.com')
+ # Not a "DNS" entry
+ fail(cert, '<unsupported>')
+ # When there is a subjectAltName, commonName isn't used
+ fail(cert, 'linuxfrz.org')
+
+ # A pristine real-world example
+ cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT',
+ 'subject': ((('countryName', 'US'),),
+ (('stateOrProvinceName', 'California'),),
+ (('localityName', 'Mountain View'),),
+ (('organizationName', 'Google Inc'),),
+ (('commonName', 'mail.google.com'),))}
+ ok(cert, 'mail.google.com')
+ fail(cert, 'gmail.com')
+ # Only commonName is considered
+ fail(cert, 'California')
+
+ # Neither commonName nor subjectAltName
+ cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT',
+ 'subject': ((('countryName', 'US'),),
+ (('stateOrProvinceName', 'California'),),
+ (('localityName', 'Mountain View'),),
+ (('organizationName', 'Google Inc'),))}
+ fail(cert, 'mail.google.com')
+
+ # Empty cert / no cert
+ self.assertRaises(ValueError, ssl.match_hostname, None, 'example.com')
+ self.assertRaises(ValueError, ssl.match_hostname, {}, 'example.com')
+
+ def test_server_side(self):
+ # server_hostname doesn't work for server sockets
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ with socket.socket() as sock:
+ self.assertRaises(ValueError, ctx.wrap_socket, sock, True,
+ server_hostname="some.hostname")
+
+class ContextTests(unittest.TestCase):
+
+ @skip_if_broken_ubuntu_ssl
+ def test_constructor(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv2)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv3)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ self.assertRaises(TypeError, ssl.SSLContext)
+ self.assertRaises(ValueError, ssl.SSLContext, -1)
+ self.assertRaises(ValueError, ssl.SSLContext, 42)
+
+ @skip_if_broken_ubuntu_ssl
+ def test_protocol(self):
+ for proto in PROTOCOLS:
+ ctx = ssl.SSLContext(proto)
+ self.assertEqual(ctx.protocol, proto)
+
+ def test_ciphers(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.set_ciphers("ALL")
+ ctx.set_ciphers("DEFAULT")
+ with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
+ ctx.set_ciphers("^$:,;?*'dorothyx")
+
+ @skip_if_broken_ubuntu_ssl
+ def test_options(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ # OP_ALL is the default value
+ self.assertEqual(ssl.OP_ALL, ctx.options)
+ ctx.options |= ssl.OP_NO_SSLv2
+ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2,
+ ctx.options)
+ ctx.options |= ssl.OP_NO_SSLv3
+ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3,
+ ctx.options)
+ if can_clear_options():
+ ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1
+ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3,
+ ctx.options)
+ ctx.options = 0
+ self.assertEqual(0, ctx.options)
+ else:
+ with self.assertRaises(ValueError):
+ ctx.options = 0
+
+ def test_verify(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ # Default value
+ self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
+ ctx.verify_mode = ssl.CERT_OPTIONAL
+ self.assertEqual(ctx.verify_mode, ssl.CERT_OPTIONAL)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED)
+ ctx.verify_mode = ssl.CERT_NONE
+ self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
+ with self.assertRaises(TypeError):
+ ctx.verify_mode = None
+ with self.assertRaises(ValueError):
+ ctx.verify_mode = 42
+
+ def test_load_cert_chain(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ # Combined key and cert in a single file
+ ctx.load_cert_chain(CERTFILE)
+ ctx.load_cert_chain(CERTFILE, keyfile=CERTFILE)
+ self.assertRaises(TypeError, ctx.load_cert_chain, keyfile=CERTFILE)
+ with self.assertRaises(IOError) as cm:
+ ctx.load_cert_chain(WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(BADCERT)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(EMPTYCERT)
+ # Separate key and cert
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.load_cert_chain(ONLYCERT, ONLYKEY)
+ ctx.load_cert_chain(certfile=ONLYCERT, keyfile=ONLYKEY)
+ ctx.load_cert_chain(certfile=BYTES_ONLYCERT, keyfile=BYTES_ONLYKEY)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(ONLYCERT)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(ONLYKEY)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(certfile=ONLYKEY, keyfile=ONLYCERT)
+ # Mismatching key and cert
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ with self.assertRaisesRegex(ssl.SSLError, "key values mismatch"):
+ ctx.load_cert_chain(SVN_PYTHON_ORG_ROOT_CERT, ONLYKEY)
+
+ def test_load_verify_locations(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.load_verify_locations(CERTFILE)
+ ctx.load_verify_locations(cafile=CERTFILE, capath=None)
+ ctx.load_verify_locations(BYTES_CERTFILE)
+ ctx.load_verify_locations(cafile=BYTES_CERTFILE, capath=None)
+ self.assertRaises(TypeError, ctx.load_verify_locations)
+ self.assertRaises(TypeError, ctx.load_verify_locations, None, None)
+ with self.assertRaises(IOError) as cm:
+ ctx.load_verify_locations(WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_verify_locations(BADCERT)
+ ctx.load_verify_locations(CERTFILE, CAPATH)
+ ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH)
+
+ # Issue #10989: crash if the second argument type is invalid
+ self.assertRaises(TypeError, ctx.load_verify_locations, None, True)
+
+ @skip_if_broken_ubuntu_ssl
+ def test_session_stats(self):
+ for proto in PROTOCOLS:
+ ctx = ssl.SSLContext(proto)
+ self.assertEqual(ctx.session_stats(), {
+ 'number': 0,
+ 'connect': 0,
+ 'connect_good': 0,
+ 'connect_renegotiate': 0,
+ 'accept': 0,
+ 'accept_good': 0,
+ 'accept_renegotiate': 0,
+ 'hits': 0,
+ 'misses': 0,
+ 'timeouts': 0,
+ 'cache_full': 0,
+ })
+
+ def test_set_default_verify_paths(self):
+ # There's not much we can do to test that it acts as expected,
+ # so just check it doesn't crash or raise an exception.
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.set_default_verify_paths()
+
class NetworkedTests(unittest.TestCase):
@@ -120,28 +428,133 @@ class NetworkedTests(unittest.TestCase):
with support.transient_internet("svn.python.org"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_NONE)
- s.connect(("svn.python.org", 443))
- c = s.getpeercert()
- if c:
- self.fail("Peer cert %s shouldn't be here!")
- s.close()
+ try:
+ s.connect(("svn.python.org", 443))
+ self.assertEqual({}, s.getpeercert())
+ finally:
+ s.close()
# this should fail because we have no verification certs
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_REQUIRED)
+ self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
+ s.connect, ("svn.python.org", 443))
+ s.close()
+
+ # this should succeed because we specify the root cert
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
try:
s.connect(("svn.python.org", 443))
- except ssl.SSLError:
- pass
+ self.assertTrue(s.getpeercert())
finally:
s.close()
- # this should succeed because we specify the root cert
+ def test_connect_ex(self):
+ # Issue #11326: check connect_ex() implementation
+ with support.transient_internet("svn.python.org"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
try:
+ self.assertEqual(0, s.connect_ex(("svn.python.org", 443)))
+ self.assertTrue(s.getpeercert())
+ finally:
+ s.close()
+
+ def test_non_blocking_connect_ex(self):
+ # Issue #11326: non-blocking connect_ex() should allow handshake
+ # to proceed after the socket gets ready.
+ with support.transient_internet("svn.python.org"):
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=SVN_PYTHON_ORG_ROOT_CERT,
+ do_handshake_on_connect=False)
+ try:
+ s.setblocking(False)
+ rc = s.connect_ex(('svn.python.org', 443))
+ # EWOULDBLOCK under Windows, EINPROGRESS elsewhere
+ self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK))
+ # Wait for connect to finish
+ select.select([], [s], [], 5.0)
+ # Non-blocking handshake
+ while True:
+ try:
+ s.do_handshake()
+ break
+ except ssl.SSLError as err:
+ if err.args[0] == ssl.SSL_ERROR_WANT_READ:
+ select.select([s], [], [], 5.0)
+ elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
+ select.select([], [s], [], 5.0)
+ else:
+ raise
+ # SSL established
+ self.assertTrue(s.getpeercert())
+ finally:
+ s.close()
+
+ def test_connect_with_context(self):
+ with support.transient_internet("svn.python.org"):
+ # Same as test_connect, but with a separately created context
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ s.connect(("svn.python.org", 443))
+ try:
+ self.assertEqual({}, s.getpeercert())
+ finally:
+ s.close()
+ # Same with a server hostname
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET),
+ server_hostname="svn.python.org")
+ if ssl.HAS_SNI:
s.connect(("svn.python.org", 443))
+ s.close()
+ else:
+ self.assertRaises(ValueError, s.connect, ("svn.python.org", 443))
+ # This should fail because we have no verification certs
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
+ s.connect, ("svn.python.org", 443))
+ s.close()
+ # This should succeed because we specify the root cert
+ ctx.load_verify_locations(SVN_PYTHON_ORG_ROOT_CERT)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ s.connect(("svn.python.org", 443))
+ try:
+ cert = s.getpeercert()
+ self.assertTrue(cert)
+ finally:
+ s.close()
+
+ def test_connect_capath(self):
+ # Verify server certificates using the `capath` argument
+ # NOTE: the subject hashing algorithm has been changed between
+ # OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must
+ # contain both versions of each certificate (same content, different
+ # filename) for this test to be portable across OpenSSL releases.
+ with support.transient_internet("svn.python.org"):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(capath=CAPATH)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ s.connect(("svn.python.org", 443))
+ try:
+ cert = s.getpeercert()
+ self.assertTrue(cert)
+ finally:
+ s.close()
+ # Same with a bytes `capath` argument
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(capath=BYTES_CAPATH)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ s.connect(("svn.python.org", 443))
+ try:
+ cert = s.getpeercert()
+ self.assertTrue(cert)
finally:
s.close()
@@ -161,12 +574,9 @@ class NetworkedTests(unittest.TestCase):
# Closing the SSL socket should close the fd too
ss.close()
gc.collect()
- try:
+ with self.assertRaises(OSError) as e:
os.read(fd, 0)
- except OSError as e:
- self.assertEqual(e.errno, errno.EBADF)
- else:
- self.fail("OSError wasn't raised")
+ self.assertEqual(e.exception.errno, errno.EBADF)
def test_non_blocking_handshake(self):
with support.transient_internet("svn.python.org"):
@@ -214,19 +624,30 @@ class NetworkedTests(unittest.TestCase):
if support.verbose:
sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem)
- # Test disabled: OPENSSL_VERSION* not available in Python 3.1
+ def test_ciphers(self):
+ remote = ("svn.python.org", 443)
+ with support.transient_internet(remote[0]):
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_NONE, ciphers="ALL")
+ s.connect(remote)
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT")
+ s.connect(remote)
+ # Error checking can happen at instantiation or when connecting
+ with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
+ with socket.socket(socket.AF_INET) as sock:
+ s = ssl.wrap_socket(sock,
+ cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
+ s.connect(remote)
+
def test_algorithms(self):
- if support.verbose:
- sys.stdout.write("test_algorithms disabled, "
- "as it fails on some old OpenSSL versions")
- return
# Issue #8484: all algorithms should be available when verifying a
# certificate.
# SHA256 was added in OpenSSL 0.9.8
if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15):
self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION)
- # NOTE: https://sha256.tbs-internet.com is another possible test host
- remote = ("sha2.hboeck.de", 443)
+ # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host)
+ remote = ("sha256.tbs-internet.com", 443)
sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem")
with support.transient_internet("sha256.tbs-internet.com"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
@@ -250,6 +671,8 @@ except ImportError:
else:
_have_threads = True
+ from test.ssl_servers import make_https_server
+
class ThreadedEchoServer(threading.Thread):
class ConnectionHandler(threading.Thread):
@@ -270,11 +693,8 @@ else:
def wrap_conn(self):
try:
- self.sslconn = ssl.wrap_socket(self.sock, server_side=True,
- certfile=self.server.certificate,
- ssl_version=self.server.protocol,
- ca_certs=self.server.cacerts,
- cert_reqs=self.server.certreqs)
+ self.sslconn = self.server.context.wrap_socket(
+ self.sock, server_side=True)
except ssl.SSLError:
# XXX Various errors can have happened here, for example
# a mismatching protocol version, an invalid certificate,
@@ -286,7 +706,7 @@ else:
self.close()
return False
else:
- if self.server.certreqs == ssl.CERT_REQUIRED:
+ if self.server.context.verify_mode == ssl.CERT_REQUIRED:
cert = self.sslconn.getpeercert()
if support.verbose and self.server.chatty:
sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n")
@@ -366,17 +786,24 @@ else:
# harness, we want to stop the server
self.server.stop()
- def __init__(self, certificate, ssl_version=None,
+ def __init__(self, certificate=None, ssl_version=None,
certreqs=None, cacerts=None,
- chatty=True, connectionchatty=False, starttls_server=False):
- if ssl_version is None:
- ssl_version = ssl.PROTOCOL_TLSv1
- if certreqs is None:
- certreqs = ssl.CERT_NONE
- self.certificate = certificate
- self.protocol = ssl_version
- self.certreqs = certreqs
- self.cacerts = cacerts
+ chatty=True, connectionchatty=False, starttls_server=False,
+ ciphers=None, context=None):
+ if context:
+ self.context = context
+ else:
+ self.context = ssl.SSLContext(ssl_version
+ if ssl_version is not None
+ else ssl.PROTOCOL_TLSv1)
+ self.context.verify_mode = (certreqs if certreqs is not None
+ else ssl.CERT_NONE)
+ if cacerts:
+ self.context.load_verify_locations(cacerts)
+ if certificate:
+ self.context.load_cert_chain(certificate)
+ if ciphers:
+ self.context.set_ciphers(ciphers)
self.chatty = chatty
self.connectionchatty = connectionchatty
self.starttls_server = starttls_server
@@ -415,98 +842,6 @@ else:
def stop(self):
self.active = False
- class OurHTTPSServer(threading.Thread):
-
- # This one's based on HTTPServer, which is based on SocketServer
-
- class HTTPSServer(HTTPServer):
-
- def __init__(self, server_address, RequestHandlerClass, certfile):
- HTTPServer.__init__(self, server_address, RequestHandlerClass)
- # we assume the certfile contains both private key and certificate
- self.certfile = certfile
- self.allow_reuse_address = True
-
- def __str__(self):
- return ('<%s %s:%s>' %
- (self.__class__.__name__,
- self.server_name,
- self.server_port))
-
- def get_request(self):
- # override this to wrap socket with SSL
- sock, addr = self.socket.accept()
- sslconn = ssl.wrap_socket(sock, server_side=True,
- certfile=self.certfile)
- return sslconn, addr
-
- class RootedHTTPRequestHandler(SimpleHTTPRequestHandler):
- # need to override translate_path to get a known root,
- # instead of using os.curdir, since the test could be
- # run from anywhere
-
- server_version = "TestHTTPS/1.0"
-
- root = None
-
- def translate_path(self, path):
- """Translate a /-separated PATH to the local filename syntax.
-
- Components that mean special things to the local file system
- (e.g. drive or directory names) are ignored. (XXX They should
- probably be diagnosed.)
-
- """
- # abandon query parameters
- path = urllib.parse.urlparse(path)[2]
- path = os.path.normpath(urllib.parse.unquote(path))
- words = path.split('/')
- words = filter(None, words)
- path = self.root
- for word in words:
- drive, word = os.path.splitdrive(word)
- head, word = os.path.split(word)
- if word in self.root: continue
- path = os.path.join(path, word)
- return path
-
- def log_message(self, format, *args):
- # we override this to suppress logging unless "verbose"
-
- if support.verbose:
- sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" %
- (self.server.server_address,
- self.server.server_port,
- self.request.cipher(),
- self.log_date_time_string(),
- format%args))
-
-
- def __init__(self, certfile):
- self.flag = None
- self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0]
- self.server = self.HTTPSServer(
- (HOST, 0), self.RootedHTTPRequestHandler, certfile)
- self.port = self.server.server_port
- threading.Thread.__init__(self)
- self.daemon = True
-
- def __str__(self):
- return "<%s %s>" % (self.__class__.__name__, self.server)
-
- def start(self, flag=None):
- self.flag = flag
- threading.Thread.start(self)
-
- def run(self):
- if self.flag:
- self.flag.set()
- self.server.serve_forever(0.05)
-
- def stop(self):
- self.server.shutdown()
-
-
class AsyncoreEchoServer(threading.Thread):
# this one's based on asyncore.dispatcher
@@ -572,8 +907,7 @@ else:
asyncore.dispatcher.__init__(self, sock)
self.listen(5)
- def handle_accept(self):
- sock_obj, addr = self.accept()
+ def handle_accepted(self, sock_obj, addr):
if support.verbose:
sys.stdout.write(" server: new connection from %s:%s\n" %addr)
self.ConnectionHandler(sock_obj, self.certfile)
@@ -626,33 +960,35 @@ else:
# try to connect
try:
try:
- s = ssl.wrap_socket(socket.socket(),
- certfile=certfile,
- ssl_version=ssl.PROTOCOL_TLSv1)
- s.connect((HOST, server.port))
+ with socket.socket() as sock:
+ s = ssl.wrap_socket(sock,
+ certfile=certfile,
+ ssl_version=ssl.PROTOCOL_TLSv1)
+ s.connect((HOST, server.port))
except ssl.SSLError as x:
if support.verbose:
sys.stdout.write("\nSSLError is %s\n" % x.args[1])
except socket.error as x:
if support.verbose:
sys.stdout.write("\nsocket.error is %s\n" % x.args[1])
+ except IOError as x:
+ if x.errno != errno.ENOENT:
+ raise
+ if support.verbose:
+ sys.stdout.write("\IOError is %s\n" % str(x))
else:
- self.fail("Use of invalid cert should have failed!")
+ raise AssertionError("Use of invalid cert should have failed!")
finally:
server.stop()
server.join()
- def server_params_test(certfile, protocol, certreqs, cacertsfile,
- client_certfile, client_protocol=None, indata=b"FOO\n",
+ def server_params_test(client_context, server_context, indata=b"FOO\n",
chatty=True, connectionchatty=False):
"""
Launch a server, connect a client to it and try various reads
and writes.
"""
- server = ThreadedEchoServer(certfile,
- certreqs=certreqs,
- ssl_version=protocol,
- cacerts=cacertsfile,
+ server = ThreadedEchoServer(context=server_context,
chatty=chatty,
connectionchatty=False)
flag = threading.Event()
@@ -660,30 +996,24 @@ else:
# wait for it to start
flag.wait()
# try to connect
- if client_protocol is None:
- client_protocol = protocol
try:
- s = ssl.wrap_socket(socket.socket(),
- certfile=client_certfile,
- ca_certs=cacertsfile,
- cert_reqs=certreqs,
- ssl_version=client_protocol)
+ s = client_context.wrap_socket(socket.socket())
s.connect((HOST, server.port))
- arg = indata
- if connectionchatty:
- if support.verbose:
- sys.stdout.write(
- " client: sending %r...\n" % indata)
- s.write(arg)
- outdata = s.read()
- if connectionchatty:
- if support.verbose:
- sys.stdout.write(" client: read %r\n" % outdata)
- if outdata != indata.lower():
- self.fail(
- "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
- % (outdata[:20], len(outdata),
- indata[:20].lower(), len(indata)))
+ for arg in [indata, bytearray(indata), memoryview(indata)]:
+ if connectionchatty:
+ if support.verbose:
+ sys.stdout.write(
+ " client: sending %r...\n" % indata)
+ s.write(arg)
+ outdata = s.read()
+ if connectionchatty:
+ if support.verbose:
+ sys.stdout.write(" client: read %r\n" % outdata)
+ if outdata != indata.lower():
+ raise AssertionError(
+ "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
+ % (outdata[:20], len(outdata),
+ indata[:20].lower(), len(indata)))
s.write(b"over\n")
if connectionchatty:
if support.verbose:
@@ -693,10 +1023,8 @@ else:
server.stop()
server.join()
- def try_protocol_combo(server_protocol,
- client_protocol,
- expect_success,
- certsreqs=None):
+ def try_protocol_combo(server_protocol, client_protocol, expect_success,
+ certsreqs=None, server_options=0, client_options=0):
if certsreqs is None:
certsreqs = ssl.CERT_NONE
certtype = {
@@ -710,11 +1038,21 @@ else:
(ssl.get_protocol_name(client_protocol),
ssl.get_protocol_name(server_protocol),
certtype))
+ client_context = ssl.SSLContext(client_protocol)
+ client_context.options = ssl.OP_ALL | client_options
+ server_context = ssl.SSLContext(server_protocol)
+ server_context.options = ssl.OP_ALL | server_options
+ for ctx in (client_context, server_context):
+ ctx.verify_mode = certsreqs
+ # NOTE: we must enable "ALL" ciphers, otherwise an SSLv23 client
+ # will send an SSLv3 hello (rather than SSLv2) starting from
+ # OpenSSL 1.0.0 (see issue #8322).
+ ctx.set_ciphers("ALL")
+ ctx.load_cert_chain(CERTFILE)
+ ctx.load_verify_locations(CERTFILE)
try:
- server_params_test(CERTFILE, server_protocol, certsreqs,
- CERTFILE, CERTFILE, client_protocol,
- chatty=False,
- connectionchatty=False)
+ server_params_test(client_context, server_context,
+ chatty=False, connectionchatty=False)
# Protocol mismatch can result in either an SSLError, or a
# "Connection reset by peer" error.
except ssl.SSLError:
@@ -733,34 +1071,32 @@ else:
class ThreadedTests(unittest.TestCase):
+ @skip_if_broken_ubuntu_ssl
def test_echo(self):
"""Basic test of an SSL client connecting to a server"""
if support.verbose:
sys.stdout.write("\n")
- server_params_test(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE,
- CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1,
- chatty=True, connectionchatty=True)
+ for protocol in PROTOCOLS:
+ context = ssl.SSLContext(protocol)
+ context.load_cert_chain(CERTFILE)
+ server_params_test(context, context,
+ chatty=True, connectionchatty=True)
def test_getpeercert(self):
if support.verbose:
sys.stdout.write("\n")
- s2 = socket.socket()
- server = ThreadedEchoServer(CERTFILE,
- certreqs=ssl.CERT_NONE,
- ssl_version=ssl.PROTOCOL_SSLv23,
- cacerts=CERTFILE,
- chatty=False)
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERTFILE)
+ context.load_cert_chain(CERTFILE)
+ server = ThreadedEchoServer(context=context, chatty=False)
flag = threading.Event()
server.start(flag)
# wait for it to start
flag.wait()
# try to connect
try:
- s = ssl.wrap_socket(socket.socket(),
- certfile=CERTFILE,
- ca_certs=CERTFILE,
- cert_reqs=ssl.CERT_REQUIRED,
- ssl_version=ssl.PROTOCOL_SSLv23)
+ s = context.wrap_socket(socket.socket())
s.connect((HOST, server.port))
cert = s.getpeercert()
self.assertTrue(cert, "Can't get peer certificate.")
@@ -776,6 +1112,11 @@ else:
self.fail(
"Missing or invalid 'organizationName' field in certificate subject; "
"should be 'Python Software Foundation'.")
+ self.assertIn('notBefore', cert)
+ self.assertIn('notAfter', cert)
+ before = ssl.cert_time_to_seconds(cert['notBefore'])
+ after = ssl.cert_time_to_seconds(cert['notAfter'])
+ self.assertLess(before, after)
s.close()
finally:
server.stop()
@@ -815,21 +1156,22 @@ else:
def listener():
s.listen(5)
listener_ready.set()
- s.accept()
+ newsock, addr = s.accept()
+ newsock.close()
s.close()
listener_gone.set()
def connector():
listener_ready.wait()
- c = socket.socket()
- c.connect((HOST, port))
- listener_gone.wait()
- try:
- ssl_sock = ssl.wrap_socket(c)
- except IOError:
- pass
- else:
- self.fail('connecting to closed SSL socket should have failed')
+ with socket.socket() as c:
+ c.connect((HOST, port))
+ listener_gone.wait()
+ try:
+ ssl_sock = ssl.wrap_socket(c)
+ except IOError:
+ pass
+ else:
+ self.fail('connecting to closed SSL socket should have failed')
t = threading.Thread(target=listener)
t.start()
@@ -838,25 +1180,32 @@ else:
finally:
t.join()
+ @skip_if_broken_ubuntu_ssl
def test_protocol_sslv2(self):
"""Connecting to an SSLv2 server with various client options"""
if support.verbose:
- sys.stdout.write("\ntest_protocol_sslv2 disabled, "
- "as it fails on OpenSSL 1.0.0+")
- return
+ sys.stdout.write("\n")
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False)
-
+ # SSLv23 client with specific SSL options
+ if no_sslv2_implies_sslv3_hello():
+ # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
+ try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False,
+ client_options=ssl.OP_NO_SSLv2)
+ try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True,
+ client_options=ssl.OP_NO_SSLv3)
+ try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True,
+ client_options=ssl.OP_NO_TLSv1)
+
+ @skip_if_broken_ubuntu_ssl
def test_protocol_sslv23(self):
"""Connecting to an SSLv23 server with various client options"""
if support.verbose:
- sys.stdout.write("\ntest_protocol_sslv23 disabled, "
- "as it fails on OpenSSL 1.0.0+")
- return
+ sys.stdout.write("\n")
try:
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True)
except (ssl.SSLError, socket.error) as x:
@@ -877,25 +1226,37 @@ else:
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED)
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED)
+ # Server with specific SSL options
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False,
+ server_options=ssl.OP_NO_SSLv3)
+ # Will choose TLSv1
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True,
+ server_options=ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3)
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, False,
+ server_options=ssl.OP_NO_TLSv1)
+
+
+ @skip_if_broken_ubuntu_ssl
def test_protocol_sslv3(self):
"""Connecting to an SSLv3 server with various client options"""
if support.verbose:
- sys.stdout.write("\ntest_protocol_sslv3 disabled, "
- "as it fails on OpenSSL 1.0.0+")
- return
+ sys.stdout.write("\n")
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True)
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL)
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED)
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False)
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False)
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
+ if no_sslv2_implies_sslv3_hello():
+ # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
+ try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, True,
+ client_options=ssl.OP_NO_SSLv2)
+ @skip_if_broken_ubuntu_ssl
def test_protocol_tlsv1(self):
"""Connecting to a TLSv1 server with various client options"""
if support.verbose:
- sys.stdout.write("\ntest_protocol_tlsv1 disabled, "
- "as it fails on OpenSSL 1.0.0+")
- return
+ sys.stdout.write("\n")
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True)
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL)
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED)
@@ -971,22 +1332,18 @@ else:
def test_socketserver(self):
"""Using a SocketServer to create and manage SSL connections."""
- server = OurHTTPSServer(CERTFILE)
- flag = threading.Event()
- server.start(flag)
- # wait for it to start
- flag.wait()
+ server = make_https_server(self, CERTFILE)
# try to connect
+ if support.verbose:
+ sys.stdout.write('\n')
+ with open(CERTFILE, 'rb') as f:
+ d1 = f.read()
+ d2 = ''
+ # now fetch the same data from the HTTPS server
+ url = 'https://%s:%d/%s' % (
+ HOST, server.port, os.path.split(CERTFILE)[1])
+ f = urllib.request.urlopen(url)
try:
- if support.verbose:
- sys.stdout.write('\n')
- with open(CERTFILE, 'rb') as f:
- d1 = f.read()
- d2 = ''
- # now fetch the same data from the HTTPS server
- url = 'https://%s:%d/%s' % (
- HOST, server.port, os.path.split(CERTFILE)[1])
- f = urllib.request.urlopen(url)
dlen = f.info().get("content-length")
if dlen and (int(dlen) > 0):
d2 = f.read(int(dlen))
@@ -994,15 +1351,9 @@ else:
sys.stdout.write(
" client: read %d bytes from remote server '%s'\n"
% (len(d2), server))
- f.close()
- self.assertEqual(d1, d2)
finally:
- if support.verbose:
- sys.stdout.write('stopping server\n')
- server.stop()
- if support.verbose:
- sys.stdout.write('joining thread\n')
- server.join()
+ f.close()
+ self.assertEqual(d1, d2)
def test_asyncore_server(self):
"""Check the example asyncore integration."""
@@ -1037,9 +1388,17 @@ else:
if support.verbose:
sys.stdout.write(" client: closing connection.\n")
s.close()
+ if support.verbose:
+ sys.stdout.write(" client: connection closed.\n")
finally:
+ if support.verbose:
+ sys.stdout.write(" cleanup: stopping server.\n")
server.stop()
+ if support.verbose:
+ sys.stdout.write(" cleanup: joining server thread.\n")
server.join()
+ if support.verbose:
+ sys.stdout.write(" cleanup: successfully joined.\n")
def test_recv_send(self):
"""Test recv(), send() and friends."""
@@ -1096,7 +1455,7 @@ else:
send_meth(indata, *args)
outdata = s.read()
if outdata != indata.lower():
- raise support.TestFailed(
+ self.fail(
"While sending with <<{name:s}>> bad data "
"<<{outdata:r}>> ({nout:d}) received; "
"expected <<{indata:r}>> ({nin:d})\n".format(
@@ -1107,12 +1466,12 @@ else:
)
except ValueError as e:
if expect_success:
- raise support.TestFailed(
+ self.fail(
"Failed to send with method <<{name:s}>>; "
"expected to succeed.\n".format(name=meth_name)
)
if not str(e).startswith(meth_name):
- raise support.TestFailed(
+ self.fail(
"Method <<{name:s}>> failed with unexpected "
"exception message: {exp:s}\n".format(
name=meth_name, exp=e
@@ -1125,7 +1484,7 @@ else:
s.send(indata)
outdata = recv_meth(*args)
if outdata != indata.lower():
- raise support.TestFailed(
+ self.fail(
"While receiving with <<{name:s}>> bad data "
"<<{outdata:r}>> ({nout:d}) received; "
"expected <<{indata:r}>> ({nin:d})\n".format(
@@ -1136,12 +1495,12 @@ else:
)
except ValueError as e:
if expect_success:
- raise support.TestFailed(
+ self.fail(
"Failed to receive with method <<{name:s}>>; "
"expected to succeed.\n".format(name=meth_name)
)
if not str(e).startswith(meth_name):
- raise support.TestFailed(
+ self.fail(
"Method <<{name:s}>> failed with unexpected "
"exception message: {exp:s}\n".format(
name=meth_name, exp=e
@@ -1174,6 +1533,8 @@ else:
# Let the socket hang around rather than having
# it closed by garbage collection.
conns.append(server.accept()[0])
+ for sock in conns:
+ sock.close()
t = threading.Thread(target=serve)
t.start()
@@ -1185,8 +1546,8 @@ else:
c.settimeout(0.2)
c.connect((host, port))
# Will attempt handshake and time out
- self.assertRaisesRegexp(ssl.SSLError, "timed out",
- ssl.wrap_socket, c)
+ self.assertRaisesRegex(socket.timeout, "timed out",
+ ssl.wrap_socket, c)
finally:
c.close()
try:
@@ -1194,8 +1555,8 @@ else:
c = ssl.wrap_socket(c)
c.settimeout(0.2)
# Will attempt handshake and time out
- self.assertRaisesRegexp(ssl.SSLError, "timed out",
- c.connect, (host, port))
+ self.assertRaisesRegex(socket.timeout, "timed out",
+ c.connect, (host, port))
finally:
c.close()
finally:
@@ -1205,21 +1566,32 @@ else:
def test_main(verbose=False):
- if skip_expected:
- raise unittest.SkipTest("No SSL support")
-
- global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
- CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
- "keycert.pem")
- SVN_PYTHON_ORG_ROOT_CERT = os.path.join(
- os.path.dirname(__file__) or os.curdir,
- "https_svn_python_org_root.pem")
-
- if (not os.path.exists(CERTFILE) or
- not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)):
- raise support.TestFailed("Can't read certificate files!")
-
- tests = [BasicTests]
+ if support.verbose:
+ plats = {
+ 'Linux': platform.linux_distribution,
+ 'Mac': platform.mac_ver,
+ 'Windows': platform.win32_ver,
+ }
+ for name, func in plats.items():
+ plat = func()
+ if plat and plat[0]:
+ plat = '%s %r' % (name, plat)
+ break
+ else:
+ plat = repr(platform.platform())
+ print("test_ssl: testing with %r %r" %
+ (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO))
+ print(" under %s" % plat)
+ print(" HAS_SNI = %r" % ssl.HAS_SNI)
+
+ for filename in [
+ CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, BYTES_CERTFILE,
+ ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY,
+ BADCERT, BADKEY, EMPTYCERT]:
+ if not os.path.exists(filename):
+ raise support.TestFailed("Can't read certificate file %r" % filename)
+
+ tests = [ContextTests, BasicSocketTests]
if support.is_resource_enabled('network'):
tests.append(NetworkedTests)
diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py
index 5b94bbe210..14057eb34a 100755..100644
--- a/Lib/test/test_strftime.py
+++ b/Lib/test/test_strftime.py
@@ -4,7 +4,6 @@ Unittest for time.strftime
import calendar
import sys
-import os
import re
from test import support
import time
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py
index f46be631ed..a352ee3560 100644
--- a/Lib/test/test_string.py
+++ b/Lib/test/test_string.py
@@ -112,6 +112,30 @@ class ModuleTest(unittest.TestCase):
self.assertRaises(ValueError, fmt.format, "{0}", 10, 20, i=100)
self.assertRaises(ValueError, fmt.format, "{i}", 10, 20, i=100)
+ def test_vformat_assert(self):
+ cls = string.Formatter()
+ kwargs = {
+ "i": 100
+ }
+ self.assertRaises(ValueError, cls._vformat,
+ cls.format, "{0}", kwargs, set(), -2)
+
+ def test_convert_field(self):
+ cls = string.Formatter()
+ self.assertEqual(cls.format("{0!s}", 'foo'), 'foo')
+ self.assertRaises(ValueError, cls.format, "{0!h}", 'foo')
+
+ def test_get_field(self):
+ cls = string.Formatter()
+ class MyClass:
+ name = 'lumberjack'
+ x = MyClass()
+ self.assertEqual(cls.format("{0.name}", x), 'lumberjack')
+
+ lookup = ["eggs", "and", "spam"]
+ self.assertEqual(cls.format("{0[2]}", lookup), 'spam')
+
+
def test_main():
support.run_unittest(ModuleTest)
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index f150546287..89c08ede7b 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -36,8 +36,8 @@ class LocaleTime_Tests(unittest.TestCase):
"""
strftime_output = time.strftime(directive, self.time_tuple).lower()
comparison = testing[self.time_tuple[tuple_position]]
- self.assertTrue(strftime_output in testing, "%s: not found in tuple" %
- error_msg)
+ self.assertIn(strftime_output, testing,
+ "%s: not found in tuple" % error_msg)
self.assertTrue(comparison == strftime_output,
"%s: position within tuple incorrect; %s != %s" %
(error_msg, comparison, strftime_output))
@@ -61,8 +61,8 @@ class LocaleTime_Tests(unittest.TestCase):
def test_am_pm(self):
# Make sure AM/PM representation done properly
strftime_output = time.strftime("%p", self.time_tuple).lower()
- self.assertTrue(strftime_output in self.LT_ins.am_pm,
- "AM/PM representation not in tuple")
+ self.assertIn(strftime_output, self.LT_ins.am_pm,
+ "AM/PM representation not in tuple")
if self.time_tuple[3] < 12: position = 0
else: position = 1
self.assertTrue(strftime_output == self.LT_ins.am_pm[position],
@@ -72,7 +72,7 @@ class LocaleTime_Tests(unittest.TestCase):
# Make sure timezone is correct
timezone = time.strftime("%Z", self.time_tuple).lower()
if timezone:
- self.assertTrue(timezone in self.LT_ins.timezone[0] or \
+ self.assertTrue(timezone in self.LT_ins.timezone[0] or
timezone in self.LT_ins.timezone[1],
"timezone %s not found in %s" %
(timezone, self.LT_ins.timezone))
@@ -133,9 +133,9 @@ class TimeRETests(unittest.TestCase):
# Make sure any characters in the format string that might be taken as
# regex syntax is escaped.
pattern_string = self.time_re.pattern("\d+")
- self.assertTrue(r"\\d\+" in pattern_string,
- "%s does not have re characters escaped properly" %
- pattern_string)
+ self.assertIn(r"\\d\+", pattern_string,
+ "%s does not have re characters escaped properly" %
+ pattern_string)
def test_compile(self):
# Check that compiled regex is correct
@@ -298,9 +298,6 @@ class StrptimeTests(unittest.TestCase):
self.assertEqual(strp_output.tm_isdst, 0)
strp_output = _strptime._strptime_time("GMT", "%Z")
self.assertEqual(strp_output.tm_isdst, 0)
- if sys.platform == "mac":
- # Timezones don't really work on MacOS9
- return
time_tuple = time.localtime()
strf_output = time.strftime("%Z") #UTC does not have a timezone
strp_output = _strptime._strptime_time(strf_output, "%Z")
@@ -317,8 +314,6 @@ class StrptimeTests(unittest.TestCase):
def test_bad_timezone(self):
# Explicitly test possibility of bad timezone;
# when time.tzname[0] == time.tzname[1] and time.daylight
- if sys.platform == "mac":
- return #MacOS9 has severely broken timezone support.
tz_name = time.tzname[0]
if tz_name.upper() in ("UTC", "GMT"):
return
diff --git a/Lib/test/test_strtod.py b/Lib/test/test_strtod.py
index e39558a2f6..7a42a893b1 100644
--- a/Lib/test/test_strtod.py
+++ b/Lib/test/test_strtod.py
@@ -2,12 +2,15 @@
# introduced in Python 2.7 and 3.1.
import random
-import struct
import unittest
import re
import sys
import test.support
+if getattr(sys, 'float_repr_style', '') != 'short':
+ raise unittest.SkipTest('correctly-rounded string->float conversions '
+ 'not available on this system')
+
# Correctly rounded str -> float in pure Python, for comparison.
strtod_parser = re.compile(r""" # A numeric string consists of:
@@ -19,6 +22,8 @@ strtod_parser = re.compile(r""" # A numeric string consists of:
\Z
""", re.VERBOSE | re.IGNORECASE).match
+# Pure Python version of correctly rounded string->float conversion.
+# Avoids any use of floating-point by returning the result as a hex string.
def strtod(s, mant_dig=53, min_exp = -1021, max_exp = 1024):
"""Convert a finite decimal string to a hex string representing an
IEEE 754 binary64 float. Return 'inf' or '-inf' on overflow.
@@ -78,8 +83,6 @@ def strtod(s, mant_dig=53, min_exp = -1021, max_exp = 1024):
TEST_SIZE = 10
-@unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
- "applies only when using short float repr style")
class StrtodTests(unittest.TestCase):
def check_strtod(self, s):
"""Compare the result of Python's builtin correctly rounded
@@ -257,6 +260,10 @@ class StrtodTests(unittest.TestCase):
'18487398785991994634182916638542680759613590482273e-357',
'32002864200581033134358724675198044527469366773928e-358',
'94393431193180696942841837085033647913224148539854e-358',
+ '73608278998966969345824653500136787876436005957953e-358',
+ '64774478836417299491718435234611299336288082136054e-358',
+ '13704940134126574534878641876947980878824688451169e-357',
+ '46697445774047060960624497964425416610480524760471e-358',
# failing case for bug introduced by METD in r77451 (attempted
# fix for issue 7632, bug 2), and fixed in r77482.
'28639097178261763178489759107321392745108491825303e-311',
@@ -380,6 +387,13 @@ class StrtodTests(unittest.TestCase):
'999999999999999944488848768742172978818416595458984375e-54',
'9999999999999999444888487687421729788184165954589843749999999e-54',
'9999999999999999444888487687421729788184165954589843750000001e-54',
+ # Value found by Rick Regan that gives a result of 2**-968
+ # under Gay's dtoa.c (as of Nov 04, 2010); since fixed.
+ # (Fixed some time ago in Python's dtoa.c.)
+ '0.0000000000000000000000000000000000000000100000000' #...
+ '000000000576129113423785429971690421191214034235435' #...
+ '087147763178149762956868991692289869941246658073194' #...
+ '51982237978882039897143840789794921875',
]
for s in test_strings:
self.check_strtod(s)
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 9ed3220e8b..2ccaad29c0 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -8,6 +8,18 @@ from test.support import run_unittest
ISBIGENDIAN = sys.byteorder == "big"
IS32BIT = sys.maxsize == 0x7fffffff
+integer_codes = 'b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q'
+byteorders = '', '@', '=', '<', '>', '!'
+
+# Native 'q' packing isn't available on systems that don't have the C
+# long long type.
+try:
+ struct.pack('q', 5)
+except struct.error:
+ HAVE_LONG_LONG = False
+else:
+ HAVE_LONG_LONG = True
+
def string_reverse(s):
return s[::-1]
@@ -35,8 +47,8 @@ class StructTest(unittest.TestCase):
self.assertRaises(struct.error, struct.pack, 'iii', 3)
self.assertRaises(struct.error, struct.pack, 'i', 3, 3, 3)
- self.assertRaises(struct.error, struct.pack, 'i', 'foo')
- self.assertRaises(struct.error, struct.pack, 'P', 'foo')
+ self.assertRaises((TypeError, struct.error), struct.pack, 'i', 'foo')
+ self.assertRaises((TypeError, struct.error), struct.pack, 'P', 'foo')
self.assertRaises(struct.error, struct.unpack, 'd', b'flap')
s = struct.pack('ii', 1, 2)
self.assertRaises(struct.error, struct.unpack, 'iii', s)
@@ -70,177 +82,139 @@ class StructTest(unittest.TestCase):
# Test some of the new features in detail
# (format, argument, big-endian result, little-endian result, asymmetric)
tests = [
- ('c', 'a', 'a', 'a', 0),
- ('xc', 'a', '\0a', '\0a', 0),
- ('cx', 'a', 'a\0', 'a\0', 0),
- ('s', 'a', 'a', 'a', 0),
- ('0s', 'helloworld', '', '', 1),
- ('1s', 'helloworld', 'h', 'h', 1),
- ('9s', 'helloworld', 'helloworl', 'helloworl', 1),
- ('10s', 'helloworld', 'helloworld', 'helloworld', 0),
- ('11s', 'helloworld', 'helloworld\0', 'helloworld\0', 1),
- ('20s', 'helloworld', 'helloworld'+10*'\0', 'helloworld'+10*'\0', 1),
- ('b', 7, '\7', '\7', 0),
- ('b', -7, '\371', '\371', 0),
- ('B', 7, '\7', '\7', 0),
- ('B', 249, '\371', '\371', 0),
- ('h', 700, '\002\274', '\274\002', 0),
- ('h', -700, '\375D', 'D\375', 0),
- ('H', 700, '\002\274', '\274\002', 0),
- ('H', 0x10000-700, '\375D', 'D\375', 0),
- ('i', 70000000, '\004,\035\200', '\200\035,\004', 0),
- ('i', -70000000, '\373\323\342\200', '\200\342\323\373', 0),
- ('I', 70000000, '\004,\035\200', '\200\035,\004', 0),
- ('I', 0x100000000-70000000, '\373\323\342\200', '\200\342\323\373', 0),
- ('l', 70000000, '\004,\035\200', '\200\035,\004', 0),
- ('l', -70000000, '\373\323\342\200', '\200\342\323\373', 0),
- ('L', 70000000, '\004,\035\200', '\200\035,\004', 0),
- ('L', 0x100000000-70000000, '\373\323\342\200', '\200\342\323\373', 0),
- ('f', 2.0, '@\000\000\000', '\000\000\000@', 0),
- ('d', 2.0, '@\000\000\000\000\000\000\000',
- '\000\000\000\000\000\000\000@', 0),
- ('f', -2.0, '\300\000\000\000', '\000\000\000\300', 0),
- ('d', -2.0, '\300\000\000\000\000\000\000\000',
- '\000\000\000\000\000\000\000\300', 0),
- ('?', 0, '\0', '\0', 0),
- ('?', 3, '\1', '\1', 1),
- ('?', True, '\1', '\1', 0),
- ('?', [], '\0', '\0', 1),
- ('?', (1,), '\1', '\1', 1),
+ ('c', b'a', b'a', b'a', 0),
+ ('xc', b'a', b'\0a', b'\0a', 0),
+ ('cx', b'a', b'a\0', b'a\0', 0),
+ ('s', b'a', b'a', b'a', 0),
+ ('0s', b'helloworld', b'', b'', 1),
+ ('1s', b'helloworld', b'h', b'h', 1),
+ ('9s', b'helloworld', b'helloworl', b'helloworl', 1),
+ ('10s', b'helloworld', b'helloworld', b'helloworld', 0),
+ ('11s', b'helloworld', b'helloworld\0', b'helloworld\0', 1),
+ ('20s', b'helloworld', b'helloworld'+10*b'\0', b'helloworld'+10*b'\0', 1),
+ ('b', 7, b'\7', b'\7', 0),
+ ('b', -7, b'\371', b'\371', 0),
+ ('B', 7, b'\7', b'\7', 0),
+ ('B', 249, b'\371', b'\371', 0),
+ ('h', 700, b'\002\274', b'\274\002', 0),
+ ('h', -700, b'\375D', b'D\375', 0),
+ ('H', 700, b'\002\274', b'\274\002', 0),
+ ('H', 0x10000-700, b'\375D', b'D\375', 0),
+ ('i', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+ ('i', -70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+ ('I', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+ ('I', 0x100000000-70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+ ('l', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+ ('l', -70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+ ('L', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+ ('L', 0x100000000-70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+ ('f', 2.0, b'@\000\000\000', b'\000\000\000@', 0),
+ ('d', 2.0, b'@\000\000\000\000\000\000\000',
+ b'\000\000\000\000\000\000\000@', 0),
+ ('f', -2.0, b'\300\000\000\000', b'\000\000\000\300', 0),
+ ('d', -2.0, b'\300\000\000\000\000\000\000\000',
+ b'\000\000\000\000\000\000\000\300', 0),
+ ('?', 0, b'\0', b'\0', 0),
+ ('?', 3, b'\1', b'\1', 1),
+ ('?', True, b'\1', b'\1', 0),
+ ('?', [], b'\0', b'\0', 1),
+ ('?', (1,), b'\1', b'\1', 1),
]
for fmt, arg, big, lil, asy in tests:
- big = bytes(big, "latin-1")
- lil = bytes(lil, "latin-1")
for (xfmt, exp) in [('>'+fmt, big), ('!'+fmt, big), ('<'+fmt, lil),
('='+fmt, ISBIGENDIAN and big or lil)]:
res = struct.pack(xfmt, arg)
self.assertEqual(res, exp)
self.assertEqual(struct.calcsize(xfmt), len(res))
rev = struct.unpack(xfmt, res)[0]
- if isinstance(arg, str):
- # Strings are returned as bytes since you can't know the
- # encoding of the string when packed.
- arg = bytes(arg, 'latin1')
if rev != arg:
self.assertTrue(asy)
- def test_native_qQ(self):
- # can't pack -1 as unsigned regardless
- self.assertRaises((struct.error, OverflowError), struct.pack, "Q", -1)
- # can't pack string as 'q' regardless
- self.assertRaises(struct.error, struct.pack, "q", "a")
- # ditto, but 'Q'
- self.assertRaises(struct.error, struct.pack, "Q", "a")
-
- try:
- struct.pack("q", 5)
- except struct.error:
- # does not have native q/Q
- pass
- else:
- nbytes = struct.calcsize('q')
- # The expected values here are in big-endian format, primarily
- # because I'm on a little-endian machine and so this is the
- # clearest way (for me) to force the code to get exercised.
- for format, input, expected in (
- ('q', -1, '\xff' * nbytes),
- ('q', 0, '\x00' * nbytes),
- ('Q', 0, '\x00' * nbytes),
- ('q', 1, '\x00' * (nbytes-1) + '\x01'),
- ('Q', (1 << (8*nbytes))-1, '\xff' * nbytes),
- ('q', (1 << (8*nbytes-1))-1, '\x7f' + '\xff' * (nbytes - 1))):
- expected = bytes(expected, "latin-1")
- got = struct.pack(format, input)
- native_expected = bigendian_to_native(expected)
- self.assertEqual(got, native_expected)
- retrieved = struct.unpack(format, got)[0]
- self.assertEqual(retrieved, input)
-
- def test_standard_integers(self):
- # Standard integer tests (bBhHiIlLqQ).
+ def test_calcsize(self):
+ expected_size = {
+ 'b': 1, 'B': 1,
+ 'h': 2, 'H': 2,
+ 'i': 4, 'I': 4,
+ 'l': 4, 'L': 4,
+ 'q': 8, 'Q': 8,
+ }
+
+ # standard integer sizes
+ for code in integer_codes:
+ for byteorder in '=', '<', '>', '!':
+ format = byteorder+code
+ size = struct.calcsize(format)
+ self.assertEqual(size, expected_size[code])
+
+ # native integer sizes
+ native_pairs = 'bB', 'hH', 'iI', 'lL'
+ if HAVE_LONG_LONG:
+ native_pairs += 'qQ',
+ for format_pair in native_pairs:
+ for byteorder in '', '@':
+ signed_size = struct.calcsize(byteorder + format_pair[0])
+ unsigned_size = struct.calcsize(byteorder + format_pair[1])
+ self.assertEqual(signed_size, unsigned_size)
+
+ # bounds for native integer sizes
+ self.assertEqual(struct.calcsize('b'), 1)
+ self.assertLessEqual(2, struct.calcsize('h'))
+ self.assertLessEqual(4, struct.calcsize('l'))
+ self.assertLessEqual(struct.calcsize('h'), struct.calcsize('i'))
+ self.assertLessEqual(struct.calcsize('i'), struct.calcsize('l'))
+ if HAVE_LONG_LONG:
+ self.assertLessEqual(8, struct.calcsize('q'))
+ self.assertLessEqual(struct.calcsize('l'), struct.calcsize('q'))
+
+ def test_integers(self):
+ # Integer tests (bBhHiIlLqQ).
import binascii
class IntTester(unittest.TestCase):
-
- def __init__(self, formatpair, bytesize):
+ def __init__(self, format):
super(IntTester, self).__init__(methodName='test_one')
- self.assertEqual(len(formatpair), 2)
- self.formatpair = formatpair
- for direction in "<>!=":
- for code in formatpair:
- format = direction + code
- self.assertEqual(struct.calcsize(format), bytesize)
- self.bytesize = bytesize
- self.bitsize = bytesize * 8
- self.signed_code, self.unsigned_code = formatpair
- self.unsigned_min = 0
- self.unsigned_max = 2**self.bitsize - 1
- self.signed_min = -(2**(self.bitsize-1))
- self.signed_max = 2**(self.bitsize-1) - 1
+ self.format = format
+ self.code = format[-1]
+ self.byteorder = format[:-1]
+ if not self.byteorder in byteorders:
+ raise ValueError("unrecognized packing byteorder: %s" %
+ self.byteorder)
+ self.bytesize = struct.calcsize(format)
+ self.bitsize = self.bytesize * 8
+ if self.code in tuple('bhilq'):
+ self.signed = True
+ self.min_value = -(2**(self.bitsize-1))
+ self.max_value = 2**(self.bitsize-1) - 1
+ elif self.code in tuple('BHILQ'):
+ self.signed = False
+ self.min_value = 0
+ self.max_value = 2**self.bitsize - 1
+ else:
+ raise ValueError("unrecognized format code: %s" %
+ self.code)
def test_one(self, x, pack=struct.pack,
unpack=struct.unpack,
unhexlify=binascii.unhexlify):
- # Try signed.
- code = self.signed_code
- if self.signed_min <= x <= self.signed_max:
- # Try big-endian.
- expected = x
- if x < 0:
- expected += 1 << self.bitsize
- self.assertTrue(expected > 0)
- expected = hex(expected)[2:] # chop "0x"
- if len(expected) & 1:
- expected = "0" + expected
- expected = unhexlify(expected)
- expected = b"\x00" * (self.bytesize - len(expected)) + expected
-
- # Pack work?
- format = ">" + code
- got = pack(format, x)
- self.assertEqual(got, expected)
-
- # Unpack work?
- retrieved = unpack(format, got)[0]
- self.assertEqual(x, retrieved)
- # Adding any byte should cause a "too big" error.
- self.assertRaises((struct.error, TypeError),
- unpack, format, b'\x01' + got)
-
- # Try little-endian.
- format = "<" + code
- expected = string_reverse(expected)
-
- # Pack work?
- got = pack(format, x)
- self.assertEqual(got, expected)
-
- # Unpack work?
- retrieved = unpack(format, got)[0]
- self.assertEqual(x, retrieved)
-
- # Adding any byte should cause a "too big" error.
- self.assertRaises((struct.error, TypeError),
- unpack, format, b'\x01' + got)
-
- else:
- # x is out of range -- verify pack realizes that.
- self.assertRaises(struct.error, pack, ">" + code, x)
- self.assertRaises(struct.error, pack, "<" + code, x)
-
- # Much the same for unsigned.
- code = self.unsigned_code
- if self.unsigned_min <= x <= self.unsigned_max:
- # Try big-endian.
- format = ">" + code
+ format = self.format
+ if self.min_value <= x <= self.max_value:
expected = x
- expected = hex(expected)[2:] # chop "0x"
+ if self.signed and x < 0:
+ expected += 1 << self.bitsize
+ self.assertGreaterEqual(expected, 0)
+ expected = '%x' % expected
if len(expected) & 1:
expected = "0" + expected
+ expected = expected.encode('ascii')
expected = unhexlify(expected)
- expected = b"\x00" * (self.bytesize - len(expected)) + expected
+ expected = (b"\x00" * (self.bytesize - len(expected)) +
+ expected)
+ if (self.byteorder == '<' or
+ self.byteorder in ('', '@', '=') and not ISBIGENDIAN):
+ expected = string_reverse(expected)
+ self.assertEqual(len(expected), self.bytesize)
# Pack work?
got = pack(format, x)
@@ -251,29 +225,12 @@ class StructTest(unittest.TestCase):
self.assertEqual(x, retrieved)
# Adding any byte should cause a "too big" error.
- self.assertRaises((struct.error, TypeError),
- unpack, format, b'\x01' + got)
-
- # Try little-endian.
- format = "<" + code
- expected = string_reverse(expected)
-
- # Pack work?
- got = pack(format, x)
- self.assertEqual(got, expected)
-
- # Unpack work?
- retrieved = unpack(format, got)[0]
- self.assertEqual(x, retrieved)
-
- # Adding any byte should cause a "too big" error.
- self.assertRaises((struct.error, TypeError),
- unpack, format, b'\x01' + got)
-
+ self.assertRaises((struct.error, TypeError), unpack, format,
+ b'\x01' + got)
else:
# x is out of range -- verify pack realizes that.
- self.assertRaises(struct.error, pack, ">" + code, x)
- self.assertRaises(struct.error, pack, "<" + code, x)
+ self.assertRaises((OverflowError, ValueError, struct.error),
+ pack, format, x)
def run(self):
from random import randrange
@@ -290,47 +247,95 @@ class StructTest(unittest.TestCase):
val = (val << 8) | randrange(256)
values.append(val)
- # Try all those, and their negations, and +-1 from them. Note
- # that this tests all power-of-2 boundaries in range, and a few out
- # of range, plus +-(2**n +- 1).
+ # Values absorbed from other tests
+ values.extend([300, 700000, sys.maxsize*4])
+
+ # Try all those, and their negations, and +-1 from
+ # them. Note that this tests all power-of-2
+ # boundaries in range, and a few out of range, plus
+ # +-(2**n +- 1).
for base in values:
for val in -base, base:
for incr in -1, 0, 1:
x = val + incr
- try:
- x = int(x)
- except OverflowError:
- pass
self.test_one(x)
# Some error cases.
- for direction in "<>":
- for code in self.formatpair:
- for badobject in "a string", 3+42j, randrange, -1729.0:
- self.assertRaises(struct.error,
- struct.pack, direction + code,
- badobject)
-
- for args in [("bB", 1),
- ("hH", 2),
- ("iI", 4),
- ("lL", 4),
- ("qQ", 8)]:
- t = IntTester(*args)
- t.run()
+ class NotAnInt:
+ def __int__(self):
+ return 42
+
+ # Objects with an '__index__' method should be allowed
+ # to pack as integers. That is assuming the implemented
+ # '__index__' method returns and 'int' or 'long'.
+ class Indexable(object):
+ def __init__(self, value):
+ self._value = value
+
+ def __index__(self):
+ return self._value
+
+ # If the '__index__' method raises a type error, then
+ # '__int__' should be used with a deprecation warning.
+ class BadIndex(object):
+ def __index__(self):
+ raise TypeError
+
+ def __int__(self):
+ return 42
+
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ "a string")
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ randrange)
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ 3+42j)
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ NotAnInt())
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ BadIndex())
+
+ # Check for legitimate values from '__index__'.
+ for obj in (Indexable(0), Indexable(10), Indexable(17),
+ Indexable(42), Indexable(100), Indexable(127)):
+ try:
+ struct.pack(format, obj)
+ except:
+ self.fail("integer code pack failed on object "
+ "with '__index__' method")
+
+ # Check for bogus values from '__index__'.
+ for obj in (Indexable(b'a'), Indexable('b'), Indexable(None),
+ Indexable({'a': 1}), Indexable([1, 2, 3])):
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ obj)
+
+ for code in integer_codes:
+ for byteorder in byteorders:
+ if (byteorder in ('', '@') and code in ('q', 'Q') and
+ not HAVE_LONG_LONG):
+ continue
+ format = byteorder+code
+ t = IntTester(format)
+ t.run()
def test_p_code(self):
# Test p ("Pascal string") code.
for code, input, expected, expectedback in [
- ('p','abc', '\x00', b''),
- ('1p', 'abc', '\x00', b''),
- ('2p', 'abc', '\x01a', b'a'),
- ('3p', 'abc', '\x02ab', b'ab'),
- ('4p', 'abc', '\x03abc', b'abc'),
- ('5p', 'abc', '\x03abc\x00', b'abc'),
- ('6p', 'abc', '\x03abc\x00\x00', b'abc'),
- ('1000p', 'x'*1000, '\xff' + 'x'*999, b'x'*255)]:
- expected = bytes(expected, "latin-1")
+ ('p', b'abc', b'\x00', b''),
+ ('1p', b'abc', b'\x00', b''),
+ ('2p', b'abc', b'\x01a', b'a'),
+ ('3p', b'abc', b'\x02ab', b'ab'),
+ ('4p', b'abc', b'\x03abc', b'abc'),
+ ('5p', b'abc', b'\x03abc\x00', b'abc'),
+ ('6p', b'abc', b'\x03abc\x00\x00', b'abc'),
+ ('1000p', b'x'*1000, b'\xff' + b'x'*999, b'x'*255)]:
got = struct.pack(code, input)
self.assertEqual(got, expected)
(got,) = struct.unpack(code, got)
@@ -371,48 +376,29 @@ class StructTest(unittest.TestCase):
big = math.ldexp(big, 127 - 24)
self.assertRaises(OverflowError, struct.pack, ">f", big)
- def test_1229380(self):
- # SF bug 1229380. No struct.pack exception for some out of
- # range integers
- for endian in ('', '>', '<'):
- for fmt in ('B', 'H', 'I', 'L'):
- self.assertRaises((struct.error, OverflowError), struct.pack,
- endian + fmt, -1)
-
- self.assertRaises((struct.error, OverflowError), struct.pack,
- endian + 'B', 300)
- self.assertRaises((struct.error, OverflowError), struct.pack,
- endian + 'H', 70000)
-
- self.assertRaises((struct.error, OverflowError), struct.pack,
- endian + 'I', sys.maxsize * 4)
- self.assertRaises((struct.error, OverflowError), struct.pack,
- endian + 'L', sys.maxsize * 4)
-
def test_1530559(self):
- for endian in ('', '>', '<'):
- for fmt in ('B', 'H', 'I', 'L', 'Q', 'b', 'h', 'i', 'l', 'q'):
- self.assertRaises(struct.error, struct.pack, endian + fmt, 1.0)
- self.assertRaises(struct.error, struct.pack, endian + fmt, 1.5)
+ for byteorder in '', '@', '=', '<', '>', '!':
+ for code in integer_codes:
+ if (byteorder in ('', '@') and code in ('q', 'Q') and
+ not HAVE_LONG_LONG):
+ continue
+ format = byteorder + code
+ self.assertRaises(struct.error, struct.pack, format, 1.0)
+ self.assertRaises(struct.error, struct.pack, format, 1.5)
self.assertRaises(struct.error, struct.pack, 'P', 1.0)
self.assertRaises(struct.error, struct.pack, 'P', 1.5)
-
def test_unpack_from(self):
test_string = b'abcd01234'
fmt = '4s'
s = struct.Struct(fmt)
for cls in (bytes, bytearray):
data = cls(test_string)
- if not isinstance(data, (bytes, bytearray)):
- bytes_data = bytes(data, 'latin1')
- else:
- bytes_data = data
self.assertEqual(s.unpack_from(data), (b'abcd',))
self.assertEqual(s.unpack_from(data, 2), (b'cd01',))
self.assertEqual(s.unpack_from(data, 4), (b'0123',))
for i in range(6):
- self.assertEqual(s.unpack_from(data, i), (bytes_data[i:i+4],))
+ self.assertEqual(s.unpack_from(data, i), (data[i:i+4],))
for i in range(6, len(test_string) + 1):
self.assertRaises(struct.error, s.unpack_from, data, i)
for cls in (bytes, bytearray):
@@ -433,12 +419,12 @@ class StructTest(unittest.TestCase):
# Test without offset
s.pack_into(writable_buf, 0, test_string)
- from_buf = writable_buf.tostring()[:len(test_string)]
+ from_buf = writable_buf.tobytes()[:len(test_string)]
self.assertEqual(from_buf, test_string)
# Test with offset.
s.pack_into(writable_buf, 10, test_string)
- from_buf = writable_buf.tostring()[:len(test_string)+10]
+ from_buf = writable_buf.tobytes()[:len(test_string)+10]
self.assertEqual(from_buf, test_string[:10] + test_string)
# Go beyond boundaries.
@@ -450,7 +436,8 @@ class StructTest(unittest.TestCase):
# Test bogus offset (issue 3694)
sb = small_buf
- self.assertRaises(TypeError, struct.pack_into, b'1', sb, None)
+ self.assertRaises((TypeError, struct.error), struct.pack_into, b'', sb,
+ None)
def test_pack_into_fn(self):
test_string = b'Reykjavik rocks, eow!'
@@ -460,12 +447,12 @@ class StructTest(unittest.TestCase):
# Test without offset.
pack_into(writable_buf, 0, test_string)
- from_buf = writable_buf.tostring()[:len(test_string)]
+ from_buf = writable_buf.tobytes()[:len(test_string)]
self.assertEqual(from_buf, test_string)
# Test with offset.
pack_into(writable_buf, 10, test_string)
- from_buf = writable_buf.tostring()[:len(test_string)+10]
+ from_buf = writable_buf.tobytes()[:len(test_string)+10]
self.assertEqual(from_buf, test_string[:10] + test_string)
# Go beyond boundaries.
@@ -515,8 +502,13 @@ class StructTest(unittest.TestCase):
self.assertFalse(prefix, msg='encoded bool is not one byte: %r'
%packed)
- self.assertRaises(IOError, struct.pack, prefix + '?',
- ExplodingBool())
+ try:
+ struct.pack(prefix + '?', ExplodingBool())
+ except IOError:
+ pass
+ else:
+ self.fail("Expected IOError: struct.pack(%r, "
+ "ExplodingBool())" % (prefix + '?'))
for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']:
self.assertTrue(struct.unpack('>?', c)[0])
@@ -532,6 +524,37 @@ class StructTest(unittest.TestCase):
def test_crasher(self):
self.assertRaises(MemoryError, struct.pack, "357913941b", "a")
+ def test_trailing_counter(self):
+ store = array.array('b', b' '*100)
+
+ # format lists containing only count spec should result in an error
+ self.assertRaises(struct.error, struct.pack, '12345')
+ self.assertRaises(struct.error, struct.unpack, '12345', '')
+ self.assertRaises(struct.error, struct.pack_into, '12345', store, 0)
+ self.assertRaises(struct.error, struct.unpack_from, '12345', store, 0)
+
+ # Format lists with trailing count spec should result in an error
+ self.assertRaises(struct.error, struct.pack, 'c12345', 'x')
+ self.assertRaises(struct.error, struct.unpack, 'c12345', 'x')
+ self.assertRaises(struct.error, struct.pack_into, 'c12345', store, 0,
+ 'x')
+ self.assertRaises(struct.error, struct.unpack_from, 'c12345', store,
+ 0)
+
+ # Mixed format tests
+ self.assertRaises(struct.error, struct.pack, '14s42', 'spam and eggs')
+ self.assertRaises(struct.error, struct.unpack, '14s42',
+ 'spam and eggs')
+ self.assertRaises(struct.error, struct.pack_into, '14s42', store, 0,
+ 'spam and eggs')
+ self.assertRaises(struct.error, struct.unpack_from, '14s42', store, 0)
+
+ def test_Struct_reinitialization(self):
+ # Issue 9422: there was a memory leak when reinitializing a
+ # Struct instance. This test can be used to detect the leak
+ # when running with regrtest -L.
+ s = struct.Struct('i')
+ s.__init__('ii')
def test_main():
run_unittest(StructTest)
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py
index 41bcac9163..18fecc3829 100644
--- a/Lib/test/test_structmembers.py
+++ b/Lib/test/test_structmembers.py
@@ -6,7 +6,7 @@ from _testcapi import _test_structmembersType, \
LLONG_MAX, LLONG_MIN, ULLONG_MAX, \
PY_SSIZE_T_MAX, PY_SSIZE_T_MIN
-import warnings, unittest, sys
+import unittest
from test import support
ts=_test_structmembersType(False, # T_BOOL
@@ -112,39 +112,30 @@ class ReadWriteTests(unittest.TestCase):
class TestWarnings(unittest.TestCase):
- def has_warned(self, w):
- self.assertEqual(w.category, RuntimeWarning)
def test_byte_max(self):
- with support.check_warnings() as w:
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_BYTE = CHAR_MAX+1
- self.has_warned(w)
def test_byte_min(self):
- with support.check_warnings() as w:
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_BYTE = CHAR_MIN-1
- self.has_warned(w)
def test_ubyte_max(self):
- with support.check_warnings() as w:
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_UBYTE = UCHAR_MAX+1
- self.has_warned(w)
def test_short_max(self):
- with support.check_warnings() as w:
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_SHORT = SHRT_MAX+1
- self.has_warned(w)
def test_short_min(self):
- with support.check_warnings() as w:
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_SHORT = SHRT_MIN-1
- self.has_warned(w)
def test_ushort_max(self):
- with support.check_warnings() as w:
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_USHORT = USHRT_MAX+1
- self.has_warned(w)
-
def test_main(verbose=None):
diff --git a/Lib/test/test_structseq.py b/Lib/test/test_structseq.py
index 7adca53400..d6c63b792f 100644
--- a/Lib/test/test_structseq.py
+++ b/Lib/test/test_structseq.py
@@ -1,12 +1,14 @@
+import os
+import time
import unittest
from test import support
-import time
class StructSeqTest(unittest.TestCase):
def test_tuple(self):
t = time.gmtime()
+ self.assertIsInstance(t, tuple)
astuple = tuple(t)
self.assertEqual(len(t), len(astuple))
self.assertEqual(t, astuple)
@@ -33,6 +35,13 @@ class StructSeqTest(unittest.TestCase):
self.assertEqual(repr(t),
"time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, "
"tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)")
+ # os.stat() gives a complicated struct sequence.
+ st = os.stat(__file__)
+ rep = repr(st)
+ self.assertTrue(rep.startswith(os.name + ".stat_result"))
+ self.assertIn("st_mode=", rep)
+ self.assertIn("st_ino=", rep)
+ self.assertIn("st_dev=", rep)
def test_concat(self):
t1 = time.gmtime()
@@ -50,8 +59,8 @@ class StructSeqTest(unittest.TestCase):
def test_contains(self):
t1 = time.gmtime()
for item in t1:
- self.assertTrue(item in t1)
- self.assertTrue(-42 not in t1)
+ self.assertIn(item, t1)
+ self.assertNotIn(-42, t1)
def test_hash(self):
t1 = time.gmtime()
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index c781904ed9..3cc387b6a3 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -3,12 +3,20 @@ from test import support
import subprocess
import sys
import signal
+import io
import os
import errno
import tempfile
import time
import re
+import sysconfig
+import warnings
+import select
import shutil
+try:
+ import gc
+except ImportError:
+ gc = None
mswindows = (sys.platform == "win32")
@@ -22,38 +30,39 @@ if mswindows:
else:
SETBINARY = ''
-# In a debug build, stuff like "[6580 refs]" is printed to stderr at
-# shutdown time. That frustrates tests trying to check stderr produced
-# from a spawned Python process.
-def remove_stderr_debug_decorations(stderr):
- return re.sub("\[\d+ refs\]\r?\n?$", "", stderr.decode()).encode()
- #return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
+
+try:
+ mkstemp = tempfile.mkstemp
+except AttributeError:
+ # tempfile.mkstemp is not available
+ def mkstemp():
+ """Replacement for mkstemp, calling mktemp."""
+ fname = tempfile.mktemp()
+ return os.open(fname, os.O_RDWR|os.O_CREAT), fname
+
class BaseTestCase(unittest.TestCase):
def setUp(self):
# Try to minimize the number of children we have so this test
# doesn't crash on some buildbots (Alphas in particular).
- if hasattr(support, "reap_children"):
- support.reap_children()
+ support.reap_children()
def tearDown(self):
- # Try to minimize the number of children we have so this test
- # doesn't crash on some buildbots (Alphas in particular).
- if hasattr(support, "reap_children"):
- support.reap_children()
+ for inst in subprocess._active:
+ inst.wait()
+ subprocess._cleanup()
+ self.assertFalse(subprocess._active, "subprocess._active not empty")
+
+ def assertStderrEqual(self, stderr, expected, msg=None):
+ # In a debug build, stuff like "[6580 refs]" is printed to stderr at
+ # shutdown time. That frustrates tests trying to check stderr produced
+ # from a spawned Python process.
+ actual = support.strip_python_stderr(stderr)
+ self.assertEqual(actual, expected, msg)
- def mkstemp(self, *args, **kwargs):
- """wrapper for mkstemp, calling mktemp if mkstemp is not available"""
- if hasattr(tempfile, "mkstemp"):
- return tempfile.mkstemp(*args, **kwargs)
- else:
- fname = tempfile.mktemp(*args, **kwargs)
- return os.open(fname, os.O_RDWR|os.O_CREAT), fname
class ProcessTestCase(BaseTestCase):
- #
- # Generic tests
- #
+
def test_call_seq(self):
# call() function with sequence argument
rc = subprocess.call([sys.executable, "-c",
@@ -68,47 +77,39 @@ class ProcessTestCase(BaseTestCase):
def test_check_call_nonzero(self):
# check_call() function with non-zero return code
- try:
+ with self.assertRaises(subprocess.CalledProcessError) as c:
subprocess.check_call([sys.executable, "-c",
"import sys; sys.exit(47)"])
- except subprocess.CalledProcessError as e:
- self.assertEqual(e.returncode, 47)
- else:
- self.fail("Expected CalledProcessError")
+ self.assertEqual(c.exception.returncode, 47)
def test_check_output(self):
# check_output() function with zero return code
output = subprocess.check_output(
[sys.executable, "-c", "print('BDFL')"])
- self.assertTrue(b'BDFL' in output)
+ self.assertIn(b'BDFL', output)
def test_check_output_nonzero(self):
# check_call() function with non-zero return code
- try:
+ with self.assertRaises(subprocess.CalledProcessError) as c:
subprocess.check_output(
[sys.executable, "-c", "import sys; sys.exit(5)"])
- except subprocess.CalledProcessError as e:
- self.assertEqual(e.returncode, 5)
- else:
- self.fail("Expected CalledProcessError")
+ self.assertEqual(c.exception.returncode, 5)
def test_check_output_stderr(self):
# check_output() function stderr redirected to stdout
output = subprocess.check_output(
[sys.executable, "-c", "import sys; sys.stderr.write('BDFL')"],
stderr=subprocess.STDOUT)
- self.assertTrue(b'BDFL' in output)
+ self.assertIn(b'BDFL', output)
def test_check_output_stdout_arg(self):
# check_output() function stderr redirected to stdout
- try:
+ with self.assertRaises(ValueError) as c:
output = subprocess.check_output(
[sys.executable, "-c", "print('will not be run')"],
stdout=sys.stdout)
- except ValueError as e:
- self.assertTrue('stdout' in e.args[0])
- else:
self.fail("Expected ValueError when stdout arg supplied.")
+ self.assertIn('stdout', c.exception.args[0])
def test_call_kwargs(self):
# call() function with keyword args
@@ -124,6 +125,8 @@ class ProcessTestCase(BaseTestCase):
# .stdin is None when not redirected
p = subprocess.Popen([sys.executable, "-c", 'print("banana")'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
p.wait()
self.assertEqual(p.stdin, None)
@@ -134,6 +137,8 @@ class ProcessTestCase(BaseTestCase):
'test of stdout in a different '
'process ...")'],
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
+ self.addCleanup(p.stdin.close)
+ self.addCleanup(p.stderr.close)
p.wait()
self.assertEqual(p.stdout, None)
@@ -141,13 +146,26 @@ class ProcessTestCase(BaseTestCase):
# .stderr is None when not redirected
p = subprocess.Popen([sys.executable, "-c", 'print("banana")'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stdin.close)
p.wait()
self.assertEqual(p.stderr, None)
- def test_executable(self):
- arg0 = os.path.join(os.path.dirname(sys.executable),
- "somethingyoudonthave")
- p = subprocess.Popen([arg0, "-c", "import sys; sys.exit(47)"],
+ def test_executable_with_cwd(self):
+ python_dir = os.path.dirname(os.path.realpath(sys.executable))
+ p = subprocess.Popen(["somethingyoudonthave", "-c",
+ "import sys; sys.exit(47)"],
+ executable=sys.executable, cwd=python_dir)
+ p.wait()
+ self.assertEqual(p.returncode, 47)
+
+ @unittest.skipIf(sysconfig.is_python_build(),
+ "need an installed Python. See #7774")
+ def test_executable_without_cwd(self):
+ # For a normal installation, it should work without 'cwd'
+ # argument. For test runs in the build directory, see #7774.
+ p = subprocess.Popen(["somethingyoudonthave", "-c",
+ "import sys; sys.exit(47)"],
executable=sys.executable)
p.wait()
self.assertEqual(p.returncode, 47)
@@ -165,6 +183,7 @@ class ProcessTestCase(BaseTestCase):
def test_stdin_filedes(self):
# stdin is set to open file descriptor
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
d = tf.fileno()
os.write(d, b"pear")
os.lseek(d, 0, 0)
@@ -177,6 +196,7 @@ class ProcessTestCase(BaseTestCase):
def test_stdin_fileobj(self):
# stdin is set to open file object
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
tf.write(b"pear")
tf.seek(0)
p = subprocess.Popen([sys.executable, "-c",
@@ -190,11 +210,13 @@ class ProcessTestCase(BaseTestCase):
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stdout.write("orange")'],
stdout=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
self.assertEqual(p.stdout.read(), b"orange")
def test_stdout_filedes(self):
# stdout is set to open file descriptor
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
d = tf.fileno()
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stdout.write("orange")'],
@@ -206,6 +228,7 @@ class ProcessTestCase(BaseTestCase):
def test_stdout_fileobj(self):
# stdout is set to open file object
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stdout.write("orange")'],
stdout=tf)
@@ -218,31 +241,31 @@ class ProcessTestCase(BaseTestCase):
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stderr.write("strawberry")'],
stderr=subprocess.PIPE)
- self.assertEqual(remove_stderr_debug_decorations(p.stderr.read()),
- b"strawberry")
+ self.addCleanup(p.stderr.close)
+ self.assertStderrEqual(p.stderr.read(), b"strawberry")
def test_stderr_filedes(self):
# stderr is set to open file descriptor
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
d = tf.fileno()
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stderr.write("strawberry")'],
stderr=d)
p.wait()
os.lseek(d, 0, 0)
- self.assertEqual(remove_stderr_debug_decorations(os.read(d, 1024)),
- b"strawberry")
+ self.assertStderrEqual(os.read(d, 1024), b"strawberry")
def test_stderr_fileobj(self):
# stderr is set to open file object
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stderr.write("strawberry")'],
stderr=tf)
p.wait()
tf.seek(0)
- self.assertEqual(remove_stderr_debug_decorations(tf.read()),
- b"strawberry")
+ self.assertStderrEqual(tf.read(), b"strawberry")
def test_stdout_stderr_pipe(self):
# capture stdout and stderr to the same pipe
@@ -253,13 +276,13 @@ class ProcessTestCase(BaseTestCase):
'sys.stderr.write("orange")'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
- output = p.stdout.read()
- stripped = remove_stderr_debug_decorations(output)
- self.assertEqual(stripped, b"appleorange")
+ self.addCleanup(p.stdout.close)
+ self.assertStderrEqual(p.stdout.read(), b"appleorange")
def test_stdout_stderr_file(self):
# capture stdout and stderr to the same open file
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
p = subprocess.Popen([sys.executable, "-c",
'import sys;'
'sys.stdout.write("apple");'
@@ -269,9 +292,7 @@ class ProcessTestCase(BaseTestCase):
stderr=tf)
p.wait()
tf.seek(0)
- output = tf.read()
- stripped = remove_stderr_debug_decorations(output)
- self.assertEqual(stripped, b"appleorange")
+ self.assertStderrEqual(tf.read(), b"appleorange")
def test_stdout_filedes_of_stdout(self):
# stdout is set to 1 (#1531862).
@@ -292,6 +313,7 @@ class ProcessTestCase(BaseTestCase):
'sys.stdout.write(os.getcwd())'],
stdout=subprocess.PIPE,
cwd=tmpdir)
+ self.addCleanup(p.stdout.close)
normcase = os.path.normcase
self.assertEqual(normcase(p.stdout.read().decode("utf-8")),
normcase(tmpdir))
@@ -304,6 +326,7 @@ class ProcessTestCase(BaseTestCase):
'sys.stdout.write(os.getenv("FRUIT"))'],
stdout=subprocess.PIPE,
env=newenv)
+ self.addCleanup(p.stdout.close)
self.assertEqual(p.stdout.read(), b"orange")
def test_communicate_stdin(self):
@@ -328,9 +351,7 @@ class ProcessTestCase(BaseTestCase):
stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
self.assertEqual(stdout, None)
- # When running with a pydebug build, the # of references is outputted
- # to stderr, so just check if stderr at least started with "pinapple"
- self.assertEqual(remove_stderr_debug_decorations(stderr), b"pineapple")
+ self.assertStderrEqual(stderr, b"pineapple")
def test_communicate(self):
p = subprocess.Popen([sys.executable, "-c",
@@ -340,26 +361,35 @@ class ProcessTestCase(BaseTestCase):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ self.addCleanup(p.stdin.close)
(stdout, stderr) = p.communicate(b"banana")
self.assertEqual(stdout, b"banana")
- self.assertEqual(remove_stderr_debug_decorations(stderr),
- b"pineapple")
-
- # This test is Linux specific for simplicity to at least have
- # some coverage. It is not a platform specific bug.
- if os.path.isdir('/proc/%d/fd' % os.getpid()):
- # Test for the fd leak reported in http://bugs.python.org/issue2791.
- def test_communicate_pipe_fd_leak(self):
- fd_directory = '/proc/%d/fd' % os.getpid()
- num_fds_before_popen = len(os.listdir(fd_directory))
- p = subprocess.Popen([sys.executable, '-c', 'print()'],
- stdout=subprocess.PIPE)
- p.communicate()
- num_fds_after_communicate = len(os.listdir(fd_directory))
- del p
- num_fds_after_destruction = len(os.listdir(fd_directory))
- self.assertEqual(num_fds_before_popen, num_fds_after_destruction)
- self.assertEqual(num_fds_before_popen, num_fds_after_communicate)
+ self.assertStderrEqual(stderr, b"pineapple")
+
+ # Test for the fd leak reported in http://bugs.python.org/issue2791.
+ def test_communicate_pipe_fd_leak(self):
+ for stdin_pipe in (False, True):
+ for stdout_pipe in (False, True):
+ for stderr_pipe in (False, True):
+ options = {}
+ if stdin_pipe:
+ options['stdin'] = subprocess.PIPE
+ if stdout_pipe:
+ options['stdout'] = subprocess.PIPE
+ if stderr_pipe:
+ options['stderr'] = subprocess.PIPE
+ if not options:
+ continue
+ p = subprocess.Popen((sys.executable, "-c", "pass"), **options)
+ p.communicate()
+ if p.stdin is not None:
+ self.assertTrue(p.stdin.closed)
+ if p.stdout is not None:
+ self.assertTrue(p.stdout.closed)
+ if p.stderr is not None:
+ self.assertTrue(p.stderr.closed)
def test_communicate_returns(self):
# communicate() should return None if no redirection is active
@@ -388,6 +418,9 @@ class ProcessTestCase(BaseTestCase):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ self.addCleanup(p.stdin.close)
string_to_write = b"abc"*pipe_buf
(stdout, stderr) = p.communicate(string_to_write)
self.assertEqual(stdout, string_to_write)
@@ -400,10 +433,13 @@ class ProcessTestCase(BaseTestCase):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ self.addCleanup(p.stdin.close)
p.stdin.write(b"banana")
(stdout, stderr) = p.communicate(b"split")
self.assertEqual(stdout, b"bananasplit")
- self.assertEqual(remove_stderr_debug_decorations(stderr), b"")
+ self.assertStderrEqual(stderr, b"")
def test_universal_newlines(self):
p = subprocess.Popen([sys.executable, "-c",
@@ -421,6 +457,7 @@ class ProcessTestCase(BaseTestCase):
'sys.stdout.write("\\nline6");'],
stdout=subprocess.PIPE,
universal_newlines=1)
+ self.addCleanup(p.stdout.close)
stdout = p.stdout.read()
self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6")
@@ -441,6 +478,8 @@ class ProcessTestCase(BaseTestCase):
'sys.stdout.write("\\nline6");'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=1)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
(stdout, stderr) = p.communicate()
self.assertEqual(stdout, "line1\nline2\nline3\nline4\nline5\nline6")
@@ -513,7 +552,7 @@ class ProcessTestCase(BaseTestCase):
# but, based on system scheduling we can't control, it's possible
# poll() never returned None. It "should be" very rare that it
# didn't go around at least twice.
- self.assertTrue(count >= 2)
+ self.assertGreaterEqual(count, 2)
# Subsequent invocations should just return the returncode
self.assertEqual(p.poll(), 0)
@@ -529,12 +568,8 @@ class ProcessTestCase(BaseTestCase):
def test_invalid_bufsize(self):
# an invalid type of the bufsize argument should raise
# TypeError.
- try:
+ with self.assertRaises(TypeError):
subprocess.Popen([sys.executable, "-c", "pass"], "orange")
- except TypeError:
- pass
- else:
- self.fail("Expected TypeError")
def test_bufsize_is_none(self):
# bufsize=None should be the same as bufsize=0.
@@ -551,15 +586,14 @@ class ProcessTestCase(BaseTestCase):
# value for that limit, but Windows has 2048, so we loop
# 1024 times (each call leaked two fds).
for i in range(1024):
- try:
+ # Windows raises IOError. Others raise OSError.
+ with self.assertRaises(EnvironmentError) as c:
subprocess.Popen(['nonexisting_i_hope'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- # Windows raises IOError
- except (IOError, OSError) as err:
- # ignore errors that indicate the command was not found
- if err.errno not in (errno.ENOENT, errno.EACCES):
- raise
+ # ignore errors that indicate the command was not found
+ if c.exception.errno not in (errno.ENOENT, errno.EACCES):
+ raise c.exception
def test_issue8780(self):
# Ensure that stdout is inherited from the parent
@@ -575,9 +609,9 @@ class ProcessTestCase(BaseTestCase):
def test_handles_closed_on_exception(self):
# If CreateProcess exits with an error, ensure the
# duplicate output handles are released
- ifhandle, ifname = self.mkstemp()
- ofhandle, ofname = self.mkstemp()
- efhandle, efname = self.mkstemp()
+ ifhandle, ifname = mkstemp()
+ ofhandle, ofname = mkstemp()
+ efhandle, efname = mkstemp()
try:
subprocess.Popen (["*"], stdin=ifhandle, stdout=ofhandle,
stderr=efhandle)
@@ -592,460 +626,752 @@ class ProcessTestCase(BaseTestCase):
self.assertFalse(os.path.exists(ofname))
self.assertFalse(os.path.exists(efname))
- #
- # POSIX tests
- #
- if not mswindows:
- def test_exceptions(self):
- # caught & re-raised exceptions
- try:
- p = subprocess.Popen([sys.executable, "-c", ""],
- cwd="/this/path/does/not/exist")
- except OSError as e:
- # The attribute child_traceback should contain "os.chdir"
- # somewhere.
- self.assertNotEqual(e.child_traceback.find("os.chdir"), -1)
- else:
- self.fail("Expected OSError")
-
- def _suppress_core_files(self):
- """Try to prevent core files from being created.
- Returns previous ulimit if successful, else None.
- """
- if sys.platform == 'darwin':
- # Check if the 'Crash Reporter' on OSX was configured
- # in 'Developer' mode and warn that it will get triggered
- # when it is.
- #
- # This assumes that this context manager is used in tests
- # that might trigger the next manager.
- value = subprocess.Popen(['/usr/bin/defaults', 'read',
+
+# context manager
+class _SuppressCoreFiles(object):
+ """Try to prevent core files from being created."""
+ old_limit = None
+
+ def __enter__(self):
+ """Try to save previous ulimit, then set it to (0, 0)."""
+ try:
+ import resource
+ self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
+ resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
+ except (ImportError, ValueError, resource.error):
+ pass
+
+ if sys.platform == 'darwin':
+ # Check if the 'Crash Reporter' on OSX was configured
+ # in 'Developer' mode and warn that it will get triggered
+ # when it is.
+ #
+ # This assumes that this context manager is used in tests
+ # that might trigger the next manager.
+ value = subprocess.Popen(['/usr/bin/defaults', 'read',
'com.apple.CrashReporter', 'DialogType'],
stdout=subprocess.PIPE).communicate()[0]
- if value.strip() == b'developer':
- print("this tests triggers the Crash Reporter, "
- "that is intentional", end='')
- sys.stdout.flush()
+ if value.strip() == b'developer':
+ print("this tests triggers the Crash Reporter, "
+ "that is intentional", end='')
+ sys.stdout.flush()
+
+ def __exit__(self, *args):
+ """Return core file behavior to default."""
+ if self.old_limit is None:
+ return
+ try:
+ import resource
+ resource.setrlimit(resource.RLIMIT_CORE, self.old_limit)
+ except (ImportError, ValueError, resource.error):
+ pass
- try:
- import resource
- old_limit = resource.getrlimit(resource.RLIMIT_CORE)
- resource.setrlimit(resource.RLIMIT_CORE, (0,0))
- return old_limit
- except (ImportError, ValueError, resource.error):
- return None
+@unittest.skipIf(mswindows, "POSIX specific tests")
+class POSIXProcessTestCase(BaseTestCase):
+ def test_exceptions(self):
+ nonexistent_dir = "/_this/pa.th/does/not/exist"
+ try:
+ os.chdir(nonexistent_dir)
+ except OSError as e:
+ # This avoids hard coding the errno value or the OS perror()
+ # string and instead capture the exception that we want to see
+ # below for comparison.
+ desired_exception = e
+ desired_exception.strerror += ': ' + repr(sys.executable)
+ else:
+ self.fail("chdir to nonexistant directory %s succeeded." %
+ nonexistent_dir)
- def _unsuppress_core_files(self, old_limit):
- """Return core file behavior to default."""
- if old_limit is None:
- return
- try:
- import resource
- resource.setrlimit(resource.RLIMIT_CORE, old_limit)
- except (ImportError, ValueError, resource.error):
- return
-
- def test_run_abort(self):
- # returncode handles signal termination
- old_limit = self._suppress_core_files()
- try:
- p = subprocess.Popen([sys.executable,
- "-c", "import os; os.abort()"])
- finally:
- self._unsuppress_core_files(old_limit)
- p.wait()
- self.assertEqual(-p.returncode, signal.SIGABRT)
+ # Error in the child re-raised in the parent.
+ try:
+ p = subprocess.Popen([sys.executable, "-c", ""],
+ cwd=nonexistent_dir)
+ except OSError as e:
+ # Test that the child process chdir failure actually makes
+ # it up to the parent process as the correct exception.
+ self.assertEqual(desired_exception.errno, e.errno)
+ self.assertEqual(desired_exception.strerror, e.strerror)
+ else:
+ self.fail("Expected OSError: %s" % desired_exception)
+
+ def test_restore_signals(self):
+ # Code coverage for both values of restore_signals to make sure it
+ # at least does not blow up.
+ # A test for behavior would be complex. Contributions welcome.
+ subprocess.call([sys.executable, "-c", ""], restore_signals=True)
+ subprocess.call([sys.executable, "-c", ""], restore_signals=False)
+
+ def test_start_new_session(self):
+ # For code coverage of calling setsid(). We don't care if we get an
+ # EPERM error from it depending on the test execution environment, that
+ # still indicates that it was called.
+ try:
+ output = subprocess.check_output(
+ [sys.executable, "-c",
+ "import os; print(os.getpgid(os.getpid()))"],
+ start_new_session=True)
+ except OSError as e:
+ if e.errno != errno.EPERM:
+ raise
+ else:
+ parent_pgid = os.getpgid(os.getpid())
+ child_pgid = int(output)
+ self.assertNotEqual(parent_pgid, child_pgid)
- def test_preexec(self):
- # preexec function
+ def test_run_abort(self):
+ # returncode handles signal termination
+ with _SuppressCoreFiles():
p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;'
- 'sys.stdout.write(os.getenv("FRUIT"))'],
- stdout=subprocess.PIPE,
- preexec_fn=lambda: os.putenv("FRUIT",
- "apple"))
- self.assertEqual(p.stdout.read(), b"apple")
-
- def test_args_string(self):
- # args is a string
- fd, fname = self.mkstemp()
- # reopen in text mode
- with open(fd, "w") as fobj:
- fobj.write("#!/bin/sh\n")
- fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
- sys.executable)
- os.chmod(fname, 0o700)
- p = subprocess.Popen(fname)
+ 'import os; os.abort()'])
p.wait()
- os.remove(fname)
- self.assertEqual(p.returncode, 47)
-
- def test_invalid_args(self):
- # invalid arguments should raise ValueError
- self.assertRaises(ValueError, subprocess.call,
- [sys.executable,
- "-c", "import sys; sys.exit(47)"],
- startupinfo=47)
- self.assertRaises(ValueError, subprocess.call,
- [sys.executable,
- "-c", "import sys; sys.exit(47)"],
- creationflags=47)
-
- def test_shell_sequence(self):
- # Run command through the shell (sequence)
- newenv = os.environ.copy()
- newenv["FRUIT"] = "apple"
- p = subprocess.Popen(["echo $FRUIT"], shell=1,
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
-
- def test_shell_string(self):
- # Run command through the shell (string)
- newenv = os.environ.copy()
- newenv["FRUIT"] = "apple"
- p = subprocess.Popen("echo $FRUIT", shell=1,
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
-
- def test_call_string(self):
- # call() function with string argument on UNIX
- fd, fname = self.mkstemp()
- # reopen in text mode
- with open(fd, "w") as fobj:
- fobj.write("#!/bin/sh\n")
- fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
- sys.executable)
- os.chmod(fname, 0o700)
- rc = subprocess.call(fname)
- os.remove(fname)
- self.assertEqual(rc, 47)
-
- def test_specific_shell(self):
- # Issue #9265: Incorrect name passed as arg[0].
- shells = []
- for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']:
- for name in ['bash', 'ksh']:
- sh = os.path.join(prefix, name)
- if os.path.isfile(sh):
- shells.append(sh)
- if not shells: # Will probably work for any shell but csh.
- self.skipTest("bash or ksh required for this test")
- sh = '/bin/sh'
- if os.path.isfile(sh) and not os.path.islink(sh):
- # Test will fail if /bin/sh is a symlink to csh.
- shells.append(sh)
- for sh in shells:
- p = subprocess.Popen("echo $0", executable=sh, shell=True,
- stdout=subprocess.PIPE)
- self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii'))
-
- def DISABLED_test_send_signal(self):
- p = subprocess.Popen([sys.executable,
- "-c", "input()"])
-
- self.assertTrue(p.poll() is None, p.poll())
- p.send_signal(signal.SIGINT)
- self.assertNotEqual(p.wait(), 0)
-
- def DISABLED_test_kill(self):
- p = subprocess.Popen([sys.executable,
- "-c", "input()"])
-
- self.assertTrue(p.poll() is None, p.poll())
- p.kill()
- self.assertEqual(p.wait(), -signal.SIGKILL)
-
- def DISABLED_test_terminate(self):
- p = subprocess.Popen([sys.executable,
- "-c", "input()"])
-
- self.assertTrue(p.poll() is None, p.poll())
- p.terminate()
- self.assertEqual(p.wait(), -signal.SIGTERM)
-
- def test_undecodable_env(self):
- for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')):
- value_repr = ascii(value).encode("ascii")
-
- # test str with surrogates
- script = "import os; print(ascii(os.getenv(%s)))" % repr(key)
- env = os.environ.copy()
- env[key] = value
- # Force surrogate-escaping of \xFF in the child process;
- # otherwise it can be decoded as-is if the default locale
- # is latin-1.
- env['PYTHONFSENCODING'] = 'ascii'
- stdout = subprocess.check_output(
- [sys.executable, "-c", script],
- env=env)
- stdout = stdout.rstrip(b'\n\r')
- self.assertEqual(stdout, value_repr)
-
- # test bytes
- key = key.encode("ascii", "surrogateescape")
- value = value.encode("ascii", "surrogateescape")
- script = "import os; print(ascii(os.getenv(%s)))" % repr(key)
- env = os.environ.copy()
- env[key] = value
- stdout = subprocess.check_output(
- [sys.executable, "-c", script],
- env=env)
- stdout = stdout.rstrip(b'\n\r')
- self.assertEqual(stdout, value_repr)
-
- def test_wait_when_sigchild_ignored(self):
- # NOTE: sigchild_ignore.py may not be an effective test on all OSes.
- sigchild_ignore = support.findfile("sigchild_ignore.py",
- subdir="subprocessdata")
- p = subprocess.Popen([sys.executable, sigchild_ignore],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- stdout, stderr = p.communicate()
- self.assertEqual(0, p.returncode, "sigchild_ignore.py exited"
- " non-zero with this error:\n%s" %
- stderr.decode('utf8'))
-
- def check_close_std_fds(self, fds):
- # Issue #9905: test that subprocess pipes still work properly with
- # some standard fds closed
- stdin = 0
- newfds = []
- for a in fds:
- b = os.dup(a)
- newfds.append(b)
- if a == 0:
- stdin = b
- try:
- for fd in fds:
- os.close(fd)
- out, err = subprocess.Popen([sys.executable, "-c",
- 'import sys;'
- 'sys.stdout.write("apple");'
- 'sys.stdout.flush();'
- 'sys.stderr.write("orange")'],
- stdin=stdin,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE).communicate()
- err = support.strip_python_stderr(err)
- self.assertEqual((out, err), (b'apple', b'orange'))
- finally:
- for b, a in zip(newfds, fds):
- os.dup2(b, a)
- for b in newfds:
- os.close(b)
-
- def test_close_fd_0(self):
- self.check_close_std_fds([0])
-
- def test_close_fd_1(self):
- self.check_close_std_fds([1])
-
- def test_close_fd_2(self):
- self.check_close_std_fds([2])
-
- def test_close_fds_0_1(self):
- self.check_close_std_fds([0, 1])
-
- def test_close_fds_0_2(self):
- self.check_close_std_fds([0, 2])
-
- def test_close_fds_1_2(self):
- self.check_close_std_fds([1, 2])
-
- def test_close_fds_0_1_2(self):
- # Issue #10806: test that subprocess pipes still work properly with
- # all standard fds closed.
- self.check_close_std_fds([0, 1, 2])
-
- def test_surrogates_error_message(self):
- def prepare():
- raise ValueError("surrogate:\uDCff")
-
-
- #
- # Windows tests
- #
- if mswindows:
- def test_startupinfo(self):
- # startupinfo argument
- # We uses hardcoded constants, because we do not want to
- # depend on win32all.
- STARTF_USESHOWWINDOW = 1
- SW_MAXIMIZE = 3
- startupinfo = subprocess.STARTUPINFO()
- startupinfo.dwFlags = STARTF_USESHOWWINDOW
- startupinfo.wShowWindow = SW_MAXIMIZE
- # Since Python is a console process, it won't be affected
- # by wShowWindow, but the argument should be silently
- # ignored
- subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"],
- startupinfo=startupinfo)
+ self.assertEqual(-p.returncode, signal.SIGABRT)
- def test_creationflags(self):
- # creationflags argument
- CREATE_NEW_CONSOLE = 16
- sys.stderr.write(" a DOS box should flash briefly ...\n")
- subprocess.call(sys.executable +
- ' -c "import time; time.sleep(0.25)"',
- creationflags=CREATE_NEW_CONSOLE)
-
- def test_invalid_args(self):
- # invalid arguments should raise ValueError
- self.assertRaises(ValueError, subprocess.call,
- [sys.executable,
- "-c", "import sys; sys.exit(47)"],
- preexec_fn=lambda: 1)
- self.assertRaises(ValueError, subprocess.call,
- [sys.executable,
- "-c", "import sys; sys.exit(47)"],
- stdout=subprocess.PIPE,
- close_fds=True)
+ def test_preexec(self):
+ # DISCLAIMER: Setting environment variables is *not* a good use
+ # of a preexec_fn. This is merely a test.
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys,os;'
+ 'sys.stdout.write(os.getenv("FRUIT"))'],
+ stdout=subprocess.PIPE,
+ preexec_fn=lambda: os.putenv("FRUIT", "apple"))
+ self.addCleanup(p.stdout.close)
+ self.assertEqual(p.stdout.read(), b"apple")
- def test_close_fds(self):
- # close file descriptors
- rc = subprocess.call([sys.executable, "-c",
- "import sys; sys.exit(47)"],
- close_fds=True)
- self.assertEqual(rc, 47)
-
- def test_shell_sequence(self):
- # Run command through the shell (sequence)
- newenv = os.environ.copy()
- newenv["FRUIT"] = "physalis"
- p = subprocess.Popen(["set"], shell=1,
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertNotEqual(p.stdout.read().find(b"physalis"), -1)
-
- def test_shell_string(self):
- # Run command through the shell (string)
- newenv = os.environ.copy()
- newenv["FRUIT"] = "physalis"
- p = subprocess.Popen("set", shell=1,
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertNotEqual(p.stdout.read().find(b"physalis"), -1)
+ def test_preexec_exception(self):
+ def raise_it():
+ raise ValueError("What if two swallows carried a coconut?")
+ try:
+ p = subprocess.Popen([sys.executable, "-c", ""],
+ preexec_fn=raise_it)
+ except RuntimeError as e:
+ self.assertTrue(
+ subprocess._posixsubprocess,
+ "Expected a ValueError from the preexec_fn")
+ except ValueError as e:
+ self.assertIn("coconut", e.args[0])
+ else:
+ self.fail("Exception raised by preexec_fn did not make it "
+ "to the parent process.")
+
+ @unittest.skipUnless(gc, "Requires a gc module.")
+ def test_preexec_gc_module_failure(self):
+ # This tests the code that disables garbage collection if the child
+ # process will execute any Python.
+ def raise_runtime_error():
+ raise RuntimeError("this shouldn't escape")
+ enabled = gc.isenabled()
+ orig_gc_disable = gc.disable
+ orig_gc_isenabled = gc.isenabled
+ try:
+ gc.disable()
+ self.assertFalse(gc.isenabled())
+ subprocess.call([sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+ self.assertFalse(gc.isenabled(),
+ "Popen enabled gc when it shouldn't.")
+
+ gc.enable()
+ self.assertTrue(gc.isenabled())
+ subprocess.call([sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+ self.assertTrue(gc.isenabled(), "Popen left gc disabled.")
+
+ gc.disable = raise_runtime_error
+ self.assertRaises(RuntimeError, subprocess.Popen,
+ [sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+
+ del gc.isenabled # force an AttributeError
+ self.assertRaises(AttributeError, subprocess.Popen,
+ [sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+ finally:
+ gc.disable = orig_gc_disable
+ gc.isenabled = orig_gc_isenabled
+ if not enabled:
+ gc.disable()
+
+ def test_args_string(self):
+ # args is a string
+ fd, fname = mkstemp()
+ # reopen in text mode
+ with open(fd, "w", errors="surrogateescape") as fobj:
+ fobj.write("#!/bin/sh\n")
+ fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
+ sys.executable)
+ os.chmod(fname, 0o700)
+ p = subprocess.Popen(fname)
+ p.wait()
+ os.remove(fname)
+ self.assertEqual(p.returncode, 47)
- def test_call_string(self):
- # call() function with string argument on Windows
- rc = subprocess.call(sys.executable +
- ' -c "import sys; sys.exit(47)"')
- self.assertEqual(rc, 47)
+ def test_invalid_args(self):
+ # invalid arguments should raise ValueError
+ self.assertRaises(ValueError, subprocess.call,
+ [sys.executable, "-c",
+ "import sys; sys.exit(47)"],
+ startupinfo=47)
+ self.assertRaises(ValueError, subprocess.call,
+ [sys.executable, "-c",
+ "import sys; sys.exit(47)"],
+ creationflags=47)
+
+ def test_shell_sequence(self):
+ # Run command through the shell (sequence)
+ newenv = os.environ.copy()
+ newenv["FRUIT"] = "apple"
+ p = subprocess.Popen(["echo $FRUIT"], shell=1,
+ stdout=subprocess.PIPE,
+ env=newenv)
+ self.addCleanup(p.stdout.close)
+ self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
- def DISABLED_test_send_signal(self):
- p = subprocess.Popen([sys.executable,
- "-c", "input()"])
+ def test_shell_string(self):
+ # Run command through the shell (string)
+ newenv = os.environ.copy()
+ newenv["FRUIT"] = "apple"
+ p = subprocess.Popen("echo $FRUIT", shell=1,
+ stdout=subprocess.PIPE,
+ env=newenv)
+ self.addCleanup(p.stdout.close)
+ self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
+
+ def test_call_string(self):
+ # call() function with string argument on UNIX
+ fd, fname = mkstemp()
+ # reopen in text mode
+ with open(fd, "w", errors="surrogateescape") as fobj:
+ fobj.write("#!/bin/sh\n")
+ fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
+ sys.executable)
+ os.chmod(fname, 0o700)
+ rc = subprocess.call(fname)
+ os.remove(fname)
+ self.assertEqual(rc, 47)
- self.assertTrue(p.poll() is None, p.poll())
- p.send_signal(signal.SIGTERM)
- self.assertNotEqual(p.wait(), 0)
+ def test_specific_shell(self):
+ # Issue #9265: Incorrect name passed as arg[0].
+ shells = []
+ for prefix in ['/bin', '/usr/bin/', '/usr/local/bin']:
+ for name in ['bash', 'ksh']:
+ sh = os.path.join(prefix, name)
+ if os.path.isfile(sh):
+ shells.append(sh)
+ if not shells: # Will probably work for any shell but csh.
+ self.skipTest("bash or ksh required for this test")
+ sh = '/bin/sh'
+ if os.path.isfile(sh) and not os.path.islink(sh):
+ # Test will fail if /bin/sh is a symlink to csh.
+ shells.append(sh)
+ for sh in shells:
+ p = subprocess.Popen("echo $0", executable=sh, shell=True,
+ stdout=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii'))
+
+ def _kill_process(self, method, *args):
+ # Do not inherit file handles from the parent.
+ # It should fix failures on some platforms.
+ p = subprocess.Popen([sys.executable, "-c", """if 1:
+ import sys, time
+ sys.stdout.write('x\\n')
+ sys.stdout.flush()
+ time.sleep(30)
+ """],
+ close_fds=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ # Wait for the interpreter to be completely initialized before
+ # sending any signal.
+ p.stdout.read(1)
+ getattr(p, method)(*args)
+ return p
+
+ def test_send_signal(self):
+ p = self._kill_process('send_signal', signal.SIGINT)
+ _, stderr = p.communicate()
+ self.assertIn(b'KeyboardInterrupt', stderr)
+ self.assertNotEqual(p.wait(), 0)
+
+ def test_kill(self):
+ p = self._kill_process('kill')
+ _, stderr = p.communicate()
+ self.assertStderrEqual(stderr, b'')
+ self.assertEqual(p.wait(), -signal.SIGKILL)
+
+ def test_terminate(self):
+ p = self._kill_process('terminate')
+ _, stderr = p.communicate()
+ self.assertStderrEqual(stderr, b'')
+ self.assertEqual(p.wait(), -signal.SIGTERM)
+
+ def check_close_std_fds(self, fds):
+ # Issue #9905: test that subprocess pipes still work properly with
+ # some standard fds closed
+ stdin = 0
+ newfds = []
+ for a in fds:
+ b = os.dup(a)
+ newfds.append(b)
+ if a == 0:
+ stdin = b
+ try:
+ for fd in fds:
+ os.close(fd)
+ out, err = subprocess.Popen([sys.executable, "-c",
+ 'import sys;'
+ 'sys.stdout.write("apple");'
+ 'sys.stdout.flush();'
+ 'sys.stderr.write("orange")'],
+ stdin=stdin,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE).communicate()
+ err = support.strip_python_stderr(err)
+ self.assertEqual((out, err), (b'apple', b'orange'))
+ finally:
+ for b, a in zip(newfds, fds):
+ os.dup2(b, a)
+ for b in newfds:
+ os.close(b)
- def DISABLED_test_kill(self):
- p = subprocess.Popen([sys.executable,
- "-c", "input()"])
+ def test_close_fd_0(self):
+ self.check_close_std_fds([0])
- self.assertTrue(p.poll() is None, p.poll())
- p.kill()
- self.assertNotEqual(p.wait(), 0)
+ def test_close_fd_1(self):
+ self.check_close_std_fds([1])
- def DISABLED_test_terminate(self):
- p = subprocess.Popen([sys.executable,
- "-c", "input()"])
+ def test_close_fd_2(self):
+ self.check_close_std_fds([2])
- self.assertTrue(p.poll() is None, p.poll())
- p.terminate()
- self.assertNotEqual(p.wait(), 0)
+ def test_close_fds_0_1(self):
+ self.check_close_std_fds([0, 1])
+ def test_close_fds_0_2(self):
+ self.check_close_std_fds([0, 2])
-class CommandTests(unittest.TestCase):
-# The module says:
-# "NB This only works (and is only relevant) for UNIX."
-#
-# Actually, getoutput should work on any platform with an os.popen, but
-# I'll take the comment as given, and skip this suite.
- if os.name == 'posix':
+ def test_close_fds_1_2(self):
+ self.check_close_std_fds([1, 2])
+
+ def test_close_fds_0_1_2(self):
+ # Issue #10806: test that subprocess pipes still work properly with
+ # all standard fds closed.
+ self.check_close_std_fds([0, 1, 2])
+
+ def test_remapping_std_fds(self):
+ # open up some temporary files
+ temps = [mkstemp() for i in range(3)]
+ try:
+ temp_fds = [fd for fd, fname in temps]
- def test_getoutput(self):
- self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy')
- self.assertEqual(subprocess.getstatusoutput('echo xyzzy'),
- (0, 'xyzzy'))
+ # unlink the files -- we won't need to reopen them
+ for fd, fname in temps:
+ os.unlink(fname)
- # we use mkdtemp in the next line to create an empty directory
- # under our exclusive control; from that, we can invent a pathname
- # that we _know_ won't exist. This is guaranteed to fail.
- dir = None
+ # write some data to what will become stdin, and rewind
+ os.write(temp_fds[1], b"STDIN")
+ os.lseek(temp_fds[1], 0, 0)
+
+ # move the standard file descriptors out of the way
+ saved_fds = [os.dup(fd) for fd in range(3)]
try:
- dir = tempfile.mkdtemp()
- name = os.path.join(dir, "foo")
+ # duplicate the file objects over the standard fd's
+ for fd, temp_fd in enumerate(temp_fds):
+ os.dup2(temp_fd, fd)
- status, output = subprocess.getstatusoutput('cat ' + name)
- self.assertNotEqual(status, 0)
+ # now use those files in the "wrong" order, so that subprocess
+ # has to rearrange them in the child
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys; got = sys.stdin.read();'
+ 'sys.stdout.write("got %s"%got); sys.stderr.write("err")'],
+ stdin=temp_fds[1],
+ stdout=temp_fds[2],
+ stderr=temp_fds[0])
+ p.wait()
finally:
- if dir is not None:
- os.rmdir(dir)
+ # restore the original fd's underneath sys.stdin, etc.
+ for std, saved in enumerate(saved_fds):
+ os.dup2(saved, std)
+ os.close(saved)
+ for fd in temp_fds:
+ os.lseek(fd, 0, 0)
-unit_tests = [ProcessTestCase, CommandTests]
+ out = os.read(temp_fds[2], 1024)
+ err = support.strip_python_stderr(os.read(temp_fds[0], 1024))
+ self.assertEqual(out, b"got STDIN")
+ self.assertEqual(err, b"err")
-if mswindows:
- class CommandsWithSpaces (BaseTestCase):
-
- def setUp(self):
- super().setUp()
- f, fname = self.mkstemp(".py", "te st")
- self.fname = fname.lower ()
- os.write(f, b"import sys;"
- b"sys.stdout.write('%d %s' % (len(sys.argv), [a.lower () for a in sys.argv]))"
- )
- os.close(f)
-
- def tearDown(self):
- os.remove(self.fname)
- super().tearDown()
-
- def with_spaces(self, *args, **kwargs):
- kwargs['stdout'] = subprocess.PIPE
- p = subprocess.Popen(*args, **kwargs)
- self.assertEqual(
- p.stdout.read ().decode("mbcs"),
- "2 [%r, 'ab cd']" % self.fname
- )
-
- def test_shell_string_with_spaces(self):
- # call() function with string argument with spaces on Windows
- self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname,
- "ab cd"), shell=1)
+ finally:
+ for fd in temp_fds:
+ os.close(fd)
+
+ def test_surrogates_error_message(self):
+ def prepare():
+ raise ValueError("surrogate:\uDCff")
+
+ try:
+ subprocess.call(
+ [sys.executable, "-c", "pass"],
+ preexec_fn=prepare)
+ except ValueError as err:
+ # Pure Python implementations keeps the message
+ self.assertIsNone(subprocess._posixsubprocess)
+ self.assertEqual(str(err), "surrogate:\uDCff")
+ except RuntimeError as err:
+ # _posixsubprocess uses a default message
+ self.assertIsNotNone(subprocess._posixsubprocess)
+ self.assertEqual(str(err), "Exception occurred in preexec_fn.")
+ else:
+ self.fail("Expected ValueError or RuntimeError")
+
+ def test_undecodable_env(self):
+ for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')):
+ # test str with surrogates
+ script = "import os; print(ascii(os.getenv(%s)))" % repr(key)
+ env = os.environ.copy()
+ env[key] = value
+ # Use C locale to get ascii for the locale encoding to force
+ # surrogate-escaping of \xFF in the child process; otherwise it can
+ # be decoded as-is if the default locale is latin-1.
+ env['LC_ALL'] = 'C'
+ stdout = subprocess.check_output(
+ [sys.executable, "-c", script],
+ env=env)
+ stdout = stdout.rstrip(b'\n\r')
+ self.assertEqual(stdout.decode('ascii'), ascii(value))
+
+ # test bytes
+ key = key.encode("ascii", "surrogateescape")
+ value = value.encode("ascii", "surrogateescape")
+ script = "import os; print(ascii(os.getenvb(%s)))" % repr(key)
+ env = os.environ.copy()
+ env[key] = value
+ stdout = subprocess.check_output(
+ [sys.executable, "-c", script],
+ env=env)
+ stdout = stdout.rstrip(b'\n\r')
+ self.assertEqual(stdout.decode('ascii'), ascii(value))
+
+ def test_bytes_program(self):
+ abs_program = os.fsencode(sys.executable)
+ path, program = os.path.split(sys.executable)
+ program = os.fsencode(program)
+
+ # absolute bytes path
+ exitcode = subprocess.call([abs_program, "-c", "pass"])
+ self.assertEqual(exitcode, 0)
+
+ # bytes program, unicode PATH
+ env = os.environ.copy()
+ env["PATH"] = path
+ exitcode = subprocess.call([program, "-c", "pass"], env=env)
+ self.assertEqual(exitcode, 0)
+
+ # bytes program, bytes PATH
+ envb = os.environb.copy()
+ envb[b"PATH"] = os.fsencode(path)
+ exitcode = subprocess.call([program, "-c", "pass"], env=envb)
+ self.assertEqual(exitcode, 0)
+
+ def test_pipe_cloexec(self):
+ sleeper = support.findfile("input_reader.py", subdir="subprocessdata")
+ fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+ p1 = subprocess.Popen([sys.executable, sleeper],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=False)
+
+ self.addCleanup(p1.communicate, b'')
+
+ p2 = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=False)
+
+ output, error = p2.communicate()
+ result_fds = set(map(int, output.split(b',')))
+ unwanted_fds = set([p1.stdin.fileno(), p1.stdout.fileno(),
+ p1.stderr.fileno()])
+
+ self.assertFalse(result_fds & unwanted_fds,
+ "Expected no fds from %r to be open in child, "
+ "found %r" %
+ (unwanted_fds, result_fds & unwanted_fds))
+
+ def test_pipe_cloexec_real_tools(self):
+ qcat = support.findfile("qcat.py", subdir="subprocessdata")
+ qgrep = support.findfile("qgrep.py", subdir="subprocessdata")
+
+ subdata = b'zxcvbn'
+ data = subdata * 4 + b'\n'
+
+ p1 = subprocess.Popen([sys.executable, qcat],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ close_fds=False)
+
+ p2 = subprocess.Popen([sys.executable, qgrep, subdata],
+ stdin=p1.stdout, stdout=subprocess.PIPE,
+ close_fds=False)
+
+ self.addCleanup(p1.wait)
+ self.addCleanup(p2.wait)
+ self.addCleanup(p1.terminate)
+ self.addCleanup(p2.terminate)
+
+ p1.stdin.write(data)
+ p1.stdin.close()
+
+ readfiles, ignored1, ignored2 = select.select([p2.stdout], [], [], 10)
+
+ self.assertTrue(readfiles, "The child hung")
+ self.assertEqual(p2.stdout.read(), data)
+
+ p1.stdout.close()
+ p2.stdout.close()
+
+ def test_close_fds(self):
+ fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+ fds = os.pipe()
+ self.addCleanup(os.close, fds[0])
+ self.addCleanup(os.close, fds[1])
+
+ open_fds = set(fds)
+
+ p = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=False)
+ output, ignored = p.communicate()
+ remaining_fds = set(map(int, output.split(b',')))
+
+ self.assertEqual(remaining_fds & open_fds, open_fds,
+ "Some fds were closed")
+
+ p = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=True)
+ output, ignored = p.communicate()
+ remaining_fds = set(map(int, output.split(b',')))
+
+ self.assertFalse(remaining_fds & open_fds,
+ "Some fds were left open")
+ self.assertIn(1, remaining_fds, "Subprocess failed")
+
+ def test_pass_fds(self):
+ fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+ open_fds = set()
+
+ for x in range(5):
+ fds = os.pipe()
+ self.addCleanup(os.close, fds[0])
+ self.addCleanup(os.close, fds[1])
+ open_fds.update(fds)
+
+ for fd in open_fds:
+ p = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=True,
+ pass_fds=(fd, ))
+ output, ignored = p.communicate()
+
+ remaining_fds = set(map(int, output.split(b',')))
+ to_be_closed = open_fds - {fd}
+
+ self.assertIn(fd, remaining_fds, "fd to be passed not passed")
+ self.assertFalse(remaining_fds & to_be_closed,
+ "fd to be closed passed")
+
+ # pass_fds overrides close_fds with a warning.
+ with self.assertWarns(RuntimeWarning) as context:
+ self.assertFalse(subprocess.call(
+ [sys.executable, "-c", "import sys; sys.exit(0)"],
+ close_fds=False, pass_fds=(fd, )))
+ self.assertIn('overriding close_fds', str(context.warning))
+
+ def test_stdout_stdin_are_single_inout_fd(self):
+ with io.open(os.devnull, "r+") as inout:
+ p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+ stdout=inout, stdin=inout)
+ p.wait()
+
+ def test_stdout_stderr_are_single_inout_fd(self):
+ with io.open(os.devnull, "r+") as inout:
+ p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+ stdout=inout, stderr=inout)
+ p.wait()
+
+ def test_stderr_stdin_are_single_inout_fd(self):
+ with io.open(os.devnull, "r+") as inout:
+ p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+ stderr=inout, stdin=inout)
+ p.wait()
+
+ def test_wait_when_sigchild_ignored(self):
+ # NOTE: sigchild_ignore.py may not be an effective test on all OSes.
+ sigchild_ignore = support.findfile("sigchild_ignore.py",
+ subdir="subprocessdata")
+ p = subprocess.Popen([sys.executable, sigchild_ignore],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(0, p.returncode, "sigchild_ignore.py exited"
+ " non-zero with this error:\n%s" %
+ stderr.decode('utf8'))
+
+
+@unittest.skipUnless(mswindows, "Windows specific tests")
+class Win32ProcessTestCase(BaseTestCase):
+
+ def test_startupinfo(self):
+ # startupinfo argument
+ # We uses hardcoded constants, because we do not want to
+ # depend on win32all.
+ STARTF_USESHOWWINDOW = 1
+ SW_MAXIMIZE = 3
+ startupinfo = subprocess.STARTUPINFO()
+ startupinfo.dwFlags = STARTF_USESHOWWINDOW
+ startupinfo.wShowWindow = SW_MAXIMIZE
+ # Since Python is a console process, it won't be affected
+ # by wShowWindow, but the argument should be silently
+ # ignored
+ subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"],
+ startupinfo=startupinfo)
+
+ def test_creationflags(self):
+ # creationflags argument
+ CREATE_NEW_CONSOLE = 16
+ sys.stderr.write(" a DOS box should flash briefly ...\n")
+ subprocess.call(sys.executable +
+ ' -c "import time; time.sleep(0.25)"',
+ creationflags=CREATE_NEW_CONSOLE)
+
+ def test_invalid_args(self):
+ # invalid arguments should raise ValueError
+ self.assertRaises(ValueError, subprocess.call,
+ [sys.executable, "-c",
+ "import sys; sys.exit(47)"],
+ preexec_fn=lambda: 1)
+ self.assertRaises(ValueError, subprocess.call,
+ [sys.executable, "-c",
+ "import sys; sys.exit(47)"],
+ stdout=subprocess.PIPE,
+ close_fds=True)
+
+ def test_close_fds(self):
+ # close file descriptors
+ rc = subprocess.call([sys.executable, "-c",
+ "import sys; sys.exit(47)"],
+ close_fds=True)
+ self.assertEqual(rc, 47)
+
+ def test_shell_sequence(self):
+ # Run command through the shell (sequence)
+ newenv = os.environ.copy()
+ newenv["FRUIT"] = "physalis"
+ p = subprocess.Popen(["set"], shell=1,
+ stdout=subprocess.PIPE,
+ env=newenv)
+ self.addCleanup(p.stdout.close)
+ self.assertIn(b"physalis", p.stdout.read())
+
+ def test_shell_string(self):
+ # Run command through the shell (string)
+ newenv = os.environ.copy()
+ newenv["FRUIT"] = "physalis"
+ p = subprocess.Popen("set", shell=1,
+ stdout=subprocess.PIPE,
+ env=newenv)
+ self.addCleanup(p.stdout.close)
+ self.assertIn(b"physalis", p.stdout.read())
+
+ def test_call_string(self):
+ # call() function with string argument on Windows
+ rc = subprocess.call(sys.executable +
+ ' -c "import sys; sys.exit(47)"')
+ self.assertEqual(rc, 47)
- def test_shell_sequence_with_spaces(self):
- # call() function with sequence argument with spaces on Windows
- self.with_spaces([sys.executable, self.fname, "ab cd"], shell=1)
+ def _kill_process(self, method, *args):
+ # Some win32 buildbot raises EOFError if stdin is inherited
+ p = subprocess.Popen([sys.executable, "-c", """if 1:
+ import sys, time
+ sys.stdout.write('x\\n')
+ sys.stdout.flush()
+ time.sleep(30)
+ """],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ self.addCleanup(p.stdin.close)
+ # Wait for the interpreter to be completely initialized before
+ # sending any signal.
+ p.stdout.read(1)
+ getattr(p, method)(*args)
+ _, stderr = p.communicate()
+ self.assertStderrEqual(stderr, b'')
+ returncode = p.wait()
+ self.assertNotEqual(returncode, 0)
- def test_noshell_string_with_spaces(self):
- # call() function with string argument with spaces on Windows
- self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname,
- "ab cd"))
+ def test_send_signal(self):
+ self._kill_process('send_signal', signal.SIGTERM)
- def test_noshell_sequence_with_spaces(self):
- # call() function with sequence argument with spaces on Windows
- self.with_spaces([sys.executable, self.fname, "ab cd"])
+ def test_kill(self):
+ self._kill_process('kill')
- unit_tests.append(CommandsWithSpaces)
+ def test_terminate(self):
+ self._kill_process('terminate')
-if getattr(subprocess, '_has_poll', False):
- class ProcessTestCaseNoPoll(ProcessTestCase):
- def setUp(self):
- subprocess._has_poll = False
- ProcessTestCase.setUp(self)
+# The module says:
+# "NB This only works (and is only relevant) for UNIX."
+#
+# Actually, getoutput should work on any platform with an os.popen, but
+# I'll take the comment as given, and skip this suite.
+@unittest.skipUnless(os.name == 'posix', "only relevant for UNIX")
+class CommandTests(unittest.TestCase):
+ def test_getoutput(self):
+ self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy')
+ self.assertEqual(subprocess.getstatusoutput('echo xyzzy'),
+ (0, 'xyzzy'))
+
+ # we use mkdtemp in the next line to create an empty directory
+ # under our exclusive control; from that, we can invent a pathname
+ # that we _know_ won't exist. This is guaranteed to fail.
+ dir = None
+ try:
+ dir = tempfile.mkdtemp()
+ name = os.path.join(dir, "foo")
+
+ status, output = subprocess.getstatusoutput('cat ' + name)
+ self.assertNotEqual(status, 0)
+ finally:
+ if dir is not None:
+ os.rmdir(dir)
+
+
+@unittest.skipUnless(getattr(subprocess, '_has_poll', False),
+ "poll system call not supported")
+class ProcessTestCaseNoPoll(ProcessTestCase):
+ def setUp(self):
+ subprocess._has_poll = False
+ ProcessTestCase.setUp(self)
+
+ def tearDown(self):
+ subprocess._has_poll = True
+ ProcessTestCase.tearDown(self)
- def tearDown(self):
- subprocess._has_poll = True
- ProcessTestCase.tearDown(self)
- unit_tests.append(ProcessTestCaseNoPoll)
+@unittest.skipUnless(getattr(subprocess, '_posixsubprocess', False),
+ "_posixsubprocess extension module not found.")
+class ProcessTestCasePOSIXPurePython(ProcessTestCase, POSIXProcessTestCase):
+ def setUp(self):
+ subprocess._posixsubprocess = None
+ ProcessTestCase.setUp(self)
+ POSIXProcessTestCase.setUp(self)
+
+ def tearDown(self):
+ subprocess._posixsubprocess = sys.modules['_posixsubprocess']
+ POSIXProcessTestCase.tearDown(self)
+ ProcessTestCase.tearDown(self)
class HelperFunctionTests(unittest.TestCase):
@@ -1066,11 +1392,104 @@ class HelperFunctionTests(unittest.TestCase):
subprocess._eintr_retry_call(fake_os_func, 666))
self.assertEqual([(256, 999), (666,), (666,)], record_calls)
-unit_tests.append(HelperFunctionTests)
+
+@unittest.skipUnless(mswindows, "Windows-specific tests")
+class CommandsWithSpaces (BaseTestCase):
+
+ def setUp(self):
+ super().setUp()
+ f, fname = mkstemp(".py", "te st")
+ self.fname = fname.lower ()
+ os.write(f, b"import sys;"
+ b"sys.stdout.write('%d %s' % (len(sys.argv), [a.lower () for a in sys.argv]))"
+ )
+ os.close(f)
+
+ def tearDown(self):
+ os.remove(self.fname)
+ super().tearDown()
+
+ def with_spaces(self, *args, **kwargs):
+ kwargs['stdout'] = subprocess.PIPE
+ p = subprocess.Popen(*args, **kwargs)
+ self.addCleanup(p.stdout.close)
+ self.assertEqual(
+ p.stdout.read ().decode("mbcs"),
+ "2 [%r, 'ab cd']" % self.fname
+ )
+
+ def test_shell_string_with_spaces(self):
+ # call() function with string argument with spaces on Windows
+ self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname,
+ "ab cd"), shell=1)
+
+ def test_shell_sequence_with_spaces(self):
+ # call() function with sequence argument with spaces on Windows
+ self.with_spaces([sys.executable, self.fname, "ab cd"], shell=1)
+
+ def test_noshell_string_with_spaces(self):
+ # call() function with string argument with spaces on Windows
+ self.with_spaces('"%s" "%s" "%s"' % (sys.executable, self.fname,
+ "ab cd"))
+
+ def test_noshell_sequence_with_spaces(self):
+ # call() function with sequence argument with spaces on Windows
+ self.with_spaces([sys.executable, self.fname, "ab cd"])
+
+
+class ContextManagerTests(ProcessTestCase):
+
+ def test_pipe(self):
+ with subprocess.Popen([sys.executable, "-c",
+ "import sys;"
+ "sys.stdout.write('stdout');"
+ "sys.stderr.write('stderr');"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE) as proc:
+ self.assertEqual(proc.stdout.read(), b"stdout")
+ self.assertStderrEqual(proc.stderr.read(), b"stderr")
+
+ self.assertTrue(proc.stdout.closed)
+ self.assertTrue(proc.stderr.closed)
+
+ def test_returncode(self):
+ with subprocess.Popen([sys.executable, "-c",
+ "import sys; sys.exit(100)"]) as proc:
+ proc.wait()
+ self.assertEqual(proc.returncode, 100)
+
+ def test_communicate_stdin(self):
+ with subprocess.Popen([sys.executable, "-c",
+ "import sys;"
+ "sys.exit(sys.stdin.read() == 'context')"],
+ stdin=subprocess.PIPE) as proc:
+ proc.communicate(b"context")
+ self.assertEqual(proc.returncode, 1)
+
+ def test_invalid_args(self):
+ with self.assertRaises(EnvironmentError) as c:
+ with subprocess.Popen(['nonexisting_i_hope'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE) as proc:
+ pass
+
+ if c.exception.errno != errno.ENOENT: # ignore "no such file"
+ raise c.exception
+
def test_main():
+ unit_tests = (ProcessTestCase,
+ POSIXProcessTestCase,
+ Win32ProcessTestCase,
+ ProcessTestCasePOSIXPurePython,
+ CommandTests,
+ ProcessTestCaseNoPoll,
+ HelperFunctionTests,
+ CommandsWithSpaces,
+ ContextManagerTests)
+
support.run_unittest(*unit_tests)
support.reap_children()
if __name__ == "__main__":
- test_main()
+ unittest.main()
diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py
index 919fb844cf..07802d6263 100644
--- a/Lib/test/test_sundry.py
+++ b/Lib/test/test_sundry.py
@@ -3,16 +3,13 @@
from test import support
import sys
import unittest
-import warnings
class TestUntestedModules(unittest.TestCase):
def test_at_least_import_untested_modules(self):
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
+ with support.check_warnings(quiet=True):
import bdb
import cgitb
import code
- import compileall
import distutils.bcppcompiler
import distutils.ccompiler
@@ -49,29 +46,19 @@ class TestUntestedModules(unittest.TestCase):
import html.entities
import imghdr
import keyword
- import linecache
import macurl2path
import mailcap
- import nntplib
import nturl2path
- import opcode
import os2emxpath
- import pdb
import pstats
import py_compile
- import sched
import sndhdr
- import symbol
import tabnanny
- import timeit
- import token
try:
import tty # not available on Windows
except ImportError:
if support.verbose:
print("skipping tty")
- import webbrowser
- import xml
def test_main():
diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py
index 3e62d9628b..7fb368abc2 100644
--- a/Lib/test/test_symtable.py
+++ b/Lib/test/test_symtable.py
@@ -82,7 +82,7 @@ class SymtableTest(unittest.TestCase):
func = self.spam
self.assertEqual(func.get_parameters(), ("a", "b", "kw", "var"))
self.assertEqual(func.get_locals(),
- ("a", "b", "bar", "glob", "internal", "kw", "var", "x"))
+ ("a", "b", "internal", "kw", "var", "x"))
self.assertEqual(func.get_globals(), ("bar", "glob"))
self.assertEqual(self.internal.get_frees(), ("x",))
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 202770afa6..02372baf82 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -476,24 +476,42 @@ Traceback (most recent call last):
...
SyntaxError: keyword argument repeated
+>>> del ()
+Traceback (most recent call last):
+SyntaxError: can't delete ()
+
+>>> {1, 2, 3} = 42
+Traceback (most recent call last):
+SyntaxError: can't assign to literal
+
Corner-cases that used to fail to raise the correct error:
- >>> def f(*, x=lambda *:0): pass
+ >>> def f(*, x=lambda __debug__:0): pass
Traceback (most recent call last):
- SyntaxError: named arguments must follow bare *
+ SyntaxError: assignment to keyword
- >>> def f(*args:(lambda *:0)): pass
+ >>> def f(*args:(lambda __debug__:0)): pass
Traceback (most recent call last):
- SyntaxError: named arguments must follow bare *
+ SyntaxError: assignment to keyword
- >>> def f(**kwargs:(lambda *:0)): pass
+ >>> def f(**kwargs:(lambda __debug__:0)): pass
Traceback (most recent call last):
- SyntaxError: named arguments must follow bare *
+ SyntaxError: assignment to keyword
>>> with (lambda *:0): pass
Traceback (most recent call last):
SyntaxError: named arguments must follow bare *
+Corner-cases that used to crash:
+
+ >>> def f(**__debug__): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> def f(*xx, __debug__): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
"""
import re
@@ -532,13 +550,13 @@ class SyntaxTestCase(unittest.TestCase):
def test_global_err_then_warn(self):
# Bug tickler: The SyntaxError raised for one global statement
# shouldn't be clobbered by a SyntaxWarning issued for a later one.
- source = re.sub('(?m)^ *:', '', """\
- :def error(a):
- : global a # SyntaxError
- :def warning():
- : b = 1
- : global b # SyntaxWarning
- :""")
+ source = """if 1:
+ def error(a):
+ global a # SyntaxError
+ def warning():
+ b = 1
+ global b # SyntaxWarning
+ """
warnings.filterwarnings(action='ignore', category=SyntaxWarning)
self._check_error(source, "global")
warnings.filters.pop(0)
@@ -546,15 +564,6 @@ class SyntaxTestCase(unittest.TestCase):
def test_break_outside_loop(self):
self._check_error("break", "outside loop")
- def test_delete_deref(self):
- source = re.sub('(?m)^ *:', '', """\
- :def foo(x):
- : def bar():
- : print(x)
- : del x
- :""")
- self._check_error(source, "nested scope")
-
def test_unexpected_indent(self):
self._check_error("foo()\n bar()\n", "unexpected indent",
subclass=IndentationError)
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 11685a4202..db27cdf347 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -1,14 +1,20 @@
-# -*- coding: iso-8859-1 -*-
import unittest, test.support
import sys, io, os
import struct
import subprocess
import textwrap
+import warnings
+import operator
+import codecs
# count the number of test runs, used to create unique
# strings to intern in test_intern()
numruns = 0
+try:
+ import threading
+except ImportError:
+ threading = None
class SysModuleTest(unittest.TestCase):
@@ -21,6 +27,7 @@ class SysModuleTest(unittest.TestCase):
sys.stdout = self.orig_stdout
sys.stderr = self.orig_stderr
sys.displayhook = self.orig_displayhook
+ test.support.reap_children()
def test_original_displayhook(self):
import builtins
@@ -138,9 +145,9 @@ class SysModuleTest(unittest.TestCase):
"raise SystemExit(47)"])
self.assertEqual(rc, 47)
- def check_exit_message(code, expected):
+ def check_exit_message(code, expected, env=None):
process = subprocess.Popen([sys.executable, "-c", code],
- stderr=subprocess.PIPE)
+ stderr=subprocess.PIPE, env=env)
stdout, stderr = process.communicate()
self.assertEqual(process.returncode, 1)
self.assertTrue(stderr.startswith(expected),
@@ -158,20 +165,46 @@ class SysModuleTest(unittest.TestCase):
r'import sys; sys.exit("surrogates:\uDCFF")',
b"surrogates:\\udcff")
+ # test that the unicode message is encoded to the stderr encoding
+ # instead of the default encoding (utf8)
+ env = os.environ.copy()
+ env['PYTHONIOENCODING'] = 'latin-1'
+ check_exit_message(
+ r'import sys; sys.exit("h\xe9")',
+ b"h\xe9", env=env)
+
def test_getdefaultencoding(self):
self.assertRaises(TypeError, sys.getdefaultencoding, 42)
# can't check more than the type, as the user might have changed it
- self.assertTrue(isinstance(sys.getdefaultencoding(), str))
+ self.assertIsInstance(sys.getdefaultencoding(), str)
# testing sys.settrace() is done in test_sys_settrace.py
# testing sys.setprofile() is done in test_sys_setprofile.py
def test_setcheckinterval(self):
- self.assertRaises(TypeError, sys.setcheckinterval)
- orig = sys.getcheckinterval()
- for n in 0, 100, 120, orig: # orig last to restore starting state
- sys.setcheckinterval(n)
- self.assertEqual(sys.getcheckinterval(), n)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ self.assertRaises(TypeError, sys.setcheckinterval)
+ orig = sys.getcheckinterval()
+ for n in 0, 100, 120, orig: # orig last to restore starting state
+ sys.setcheckinterval(n)
+ self.assertEqual(sys.getcheckinterval(), n)
+
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ def test_switchinterval(self):
+ self.assertRaises(TypeError, sys.setswitchinterval)
+ self.assertRaises(TypeError, sys.setswitchinterval, "a")
+ self.assertRaises(ValueError, sys.setswitchinterval, -1.0)
+ self.assertRaises(ValueError, sys.setswitchinterval, 0.0)
+ orig = sys.getswitchinterval()
+ # sanity check
+ self.assertTrue(orig < 0.5, orig)
+ try:
+ for n in 0.00001, 0.05, 3.0, orig:
+ sys.setswitchinterval(n)
+ self.assertAlmostEqual(sys.getswitchinterval(), n)
+ finally:
+ sys.setswitchinterval(orig)
def test_recursionlimit(self):
self.assertRaises(TypeError, sys.getrecursionlimit, 42)
@@ -182,6 +215,8 @@ class SysModuleTest(unittest.TestCase):
self.assertEqual(sys.getrecursionlimit(), 10000)
sys.setrecursionlimit(oldlimit)
+ @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(),
+ 'fatal error if run with a trace function')
def test_recursionlimit_recovery(self):
# NOTE: this test is slightly fragile in that it depends on the current
# recursion count when executing the test being low enough so as to
@@ -226,15 +261,34 @@ class SysModuleTest(unittest.TestCase):
err)
def test_getwindowsversion(self):
- if hasattr(sys, "getwindowsversion"):
- v = sys.getwindowsversion()
- self.assertTrue(isinstance(v, tuple))
- self.assertEqual(len(v), 5)
- self.assertTrue(isinstance(v[0], int))
- self.assertTrue(isinstance(v[1], int))
- self.assertTrue(isinstance(v[2], int))
- self.assertTrue(isinstance(v[3], int))
- self.assertTrue(isinstance(v[4], str))
+ # Raise SkipTest if sys doesn't have getwindowsversion attribute
+ test.support.get_attribute(sys, "getwindowsversion")
+ v = sys.getwindowsversion()
+ self.assertEqual(len(v), 5)
+ self.assertIsInstance(v[0], int)
+ self.assertIsInstance(v[1], int)
+ self.assertIsInstance(v[2], int)
+ self.assertIsInstance(v[3], int)
+ self.assertIsInstance(v[4], str)
+ self.assertRaises(IndexError, operator.getitem, v, 5)
+ self.assertIsInstance(v.major, int)
+ self.assertIsInstance(v.minor, int)
+ self.assertIsInstance(v.build, int)
+ self.assertIsInstance(v.platform, int)
+ self.assertIsInstance(v.service_pack, str)
+ self.assertIsInstance(v.service_pack_minor, int)
+ self.assertIsInstance(v.service_pack_major, int)
+ self.assertIsInstance(v.suite_mask, int)
+ self.assertIsInstance(v.product_type, int)
+ self.assertEqual(v[0], v.major)
+ self.assertEqual(v[1], v.minor)
+ self.assertEqual(v[2], v.build)
+ self.assertEqual(v[3], v.platform)
+ self.assertEqual(v[4], v.service_pack)
+
+ # This is how platform.py calls it. Make sure tuple
+ # still has 5 elements
+ maj, min, buildno, plat, csd = sys.getwindowsversion()
def test_call_tracing(self):
self.assertRaises(TypeError, sys.call_tracing, type, 2)
@@ -262,7 +316,7 @@ class SysModuleTest(unittest.TestCase):
del n
self.assertEqual(sys.getrefcount(None), c)
if hasattr(sys, "gettotalrefcount"):
- self.assertTrue(isinstance(sys.gettotalrefcount(), int))
+ self.assertIsInstance(sys.gettotalrefcount(), int)
def test_getframe(self):
self.assertRaises(TypeError, sys._getframe, 42, 42)
@@ -286,6 +340,7 @@ class SysModuleTest(unittest.TestCase):
self.current_frames_without_threads()
# Test sys._current_frames() in a WITH_THREADS build.
+ @test.support.reap_threads
def current_frames_with_threads(self):
import threading, _thread
import traceback
@@ -318,8 +373,8 @@ class SysModuleTest(unittest.TestCase):
d = sys._current_frames()
main_id = _thread.get_ident()
- self.assertTrue(main_id in d)
- self.assertTrue(thread_id in d)
+ self.assertIn(main_id, d)
+ self.assertIn(thread_id, d)
# Verify that the captured main-thread frame is _this_ frame.
frame = d.pop(main_id)
@@ -341,7 +396,7 @@ class SysModuleTest(unittest.TestCase):
# And the next record must be for g456().
filename, lineno, funcname, sourceline = stack[i+1]
self.assertEqual(funcname, "g456")
- self.assertTrue(sourceline in ["leave_g.wait()", "entered_g.set()"])
+ self.assertIn(sourceline, ["leave_g.wait()", "entered_g.set()"])
# Reap the spawned thread.
leave_g.set()
@@ -353,17 +408,17 @@ class SysModuleTest(unittest.TestCase):
# "thread id" 0.
d = sys._current_frames()
self.assertEqual(len(d), 1)
- self.assertTrue(0 in d)
+ self.assertIn(0, d)
self.assertTrue(d[0] is sys._getframe())
def test_attributes(self):
- self.assertTrue(isinstance(sys.api_version, int))
- self.assertTrue(isinstance(sys.argv, list))
- self.assertTrue(sys.byteorder in ("little", "big"))
- self.assertTrue(isinstance(sys.builtin_module_names, tuple))
- self.assertTrue(isinstance(sys.copyright, str))
- self.assertTrue(isinstance(sys.exec_prefix, str))
- self.assertTrue(isinstance(sys.executable, str))
+ self.assertIsInstance(sys.api_version, int)
+ self.assertIsInstance(sys.argv, list)
+ self.assertIn(sys.byteorder, ("little", "big"))
+ self.assertIsInstance(sys.builtin_module_names, tuple)
+ self.assertIsInstance(sys.copyright, str)
+ self.assertIsInstance(sys.exec_prefix, str)
+ self.assertIsInstance(sys.executable, str)
self.assertEqual(len(sys.float_info), 11)
self.assertEqual(sys.float_info.radix, 2)
self.assertEqual(len(sys.int_info), 2)
@@ -371,32 +426,52 @@ class SysModuleTest(unittest.TestCase):
self.assertTrue(sys.int_info.sizeof_digit >= 1)
self.assertEqual(type(sys.int_info.bits_per_digit), int)
self.assertEqual(type(sys.int_info.sizeof_digit), int)
- self.assertTrue(isinstance(sys.hexversion, int))
- self.assertTrue(isinstance(sys.maxsize, int))
- self.assertTrue(isinstance(sys.maxunicode, int))
- self.assertTrue(isinstance(sys.platform, str))
- self.assertTrue(isinstance(sys.prefix, str))
- self.assertTrue(isinstance(sys.version, str))
+ self.assertIsInstance(sys.hexversion, int)
+
+ self.assertEqual(len(sys.hash_info), 5)
+ self.assertLess(sys.hash_info.modulus, 2**sys.hash_info.width)
+ # sys.hash_info.modulus should be a prime; we do a quick
+ # probable primality test (doesn't exclude the possibility of
+ # a Carmichael number)
+ for x in range(1, 100):
+ self.assertEqual(
+ pow(x, sys.hash_info.modulus-1, sys.hash_info.modulus),
+ 1,
+ "sys.hash_info.modulus {} is a non-prime".format(
+ sys.hash_info.modulus)
+ )
+ self.assertIsInstance(sys.hash_info.inf, int)
+ self.assertIsInstance(sys.hash_info.nan, int)
+ self.assertIsInstance(sys.hash_info.imag, int)
+
+ self.assertIsInstance(sys.maxsize, int)
+ self.assertIsInstance(sys.maxunicode, int)
+ self.assertIsInstance(sys.platform, str)
+ self.assertIsInstance(sys.prefix, str)
+ self.assertIsInstance(sys.version, str)
vi = sys.version_info
- self.assertTrue(isinstance(vi[:], tuple))
+ self.assertIsInstance(vi[:], tuple)
self.assertEqual(len(vi), 5)
- self.assertTrue(isinstance(vi[0], int))
- self.assertTrue(isinstance(vi[1], int))
- self.assertTrue(isinstance(vi[2], int))
- self.assertTrue(vi[3] in ("alpha", "beta", "candidate", "final"))
- self.assertTrue(isinstance(vi[4], int))
- self.assertTrue(isinstance(vi.major, int))
- self.assertTrue(isinstance(vi.minor, int))
- self.assertTrue(isinstance(vi.micro, int))
- self.assertTrue(vi.releaselevel in
- ("alpha", "beta", "candidate", "final"))
- self.assertTrue(isinstance(vi.serial, int))
+ self.assertIsInstance(vi[0], int)
+ self.assertIsInstance(vi[1], int)
+ self.assertIsInstance(vi[2], int)
+ self.assertIn(vi[3], ("alpha", "beta", "candidate", "final"))
+ self.assertIsInstance(vi[4], int)
+ self.assertIsInstance(vi.major, int)
+ self.assertIsInstance(vi.minor, int)
+ self.assertIsInstance(vi.micro, int)
+ self.assertIn(vi.releaselevel, ("alpha", "beta", "candidate", "final"))
+ self.assertIsInstance(vi.serial, int)
self.assertEqual(vi[0], vi.major)
self.assertEqual(vi[1], vi.minor)
self.assertEqual(vi[2], vi.micro)
self.assertEqual(vi[3], vi.releaselevel)
self.assertEqual(vi[4], vi.serial)
self.assertTrue(vi > (1,0,0))
+ self.assertIsInstance(sys.float_repr_style, str)
+ self.assertIn(sys.float_repr_style, ('short', 'legacy'))
+ if not sys.platform.startswith('win'):
+ self.assertIsInstance(sys.abiflags, str)
def test_43581(self):
# Can't use sys.stdout, as this is a StringIO object when
@@ -423,30 +498,12 @@ class SysModuleTest(unittest.TestCase):
self.assertRaises(TypeError, sys.intern, S("abc"))
- def test_main_invalid_unicode(self):
- import locale
- non_decodable = b"\xff"
- encoding = locale.getpreferredencoding()
- try:
- non_decodable.decode(encoding)
- except UnicodeDecodeError:
- pass
- else:
- self.skipTest('%r is decodable with encoding %s'
- % (non_decodable, encoding))
- code = b'print("' + non_decodable + b'")'
- p = subprocess.Popen([sys.executable, "-c", code], stderr=subprocess.PIPE)
- stdout, stderr = p.communicate()
- self.assertEqual(p.returncode, 1)
- self.assertTrue(b"UnicodeEncodeError:" in stderr,
- "%r not in %s" % (b"UnicodeEncodeError:", ascii(stderr)))
-
def test_sys_flags(self):
self.assertTrue(sys.flags)
attrs = ("debug", "division_warning",
"inspect", "interactive", "optimize", "dont_write_bytecode",
"no_user_site", "no_site", "ignore_environment", "verbose",
- "bytes_warning")
+ "bytes_warning", "quiet")
for attr in attrs:
self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
@@ -465,13 +522,13 @@ class SysModuleTest(unittest.TestCase):
env["PYTHONIOENCODING"] = "cp424"
p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
stdout = subprocess.PIPE, env=env)
- out = p.stdout.read()
+ out = p.communicate()[0].strip()
self.assertEqual(out, "\xa2\n".encode("cp424"))
env["PYTHONIOENCODING"] = "ascii:replace"
p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
stdout = subprocess.PIPE, env=env)
- out = p.stdout.read().strip()
+ out = p.communicate()[0].strip()
self.assertEqual(out, b'?')
def test_executable(self):
@@ -491,6 +548,22 @@ class SysModuleTest(unittest.TestCase):
p.wait()
self.assertIn(executable, ["b''", repr(sys.executable.encode("ascii", "backslashreplace"))])
+ def check_fsencoding(self, fs_encoding, expected=None):
+ self.assertIsNotNone(fs_encoding)
+ codecs.lookup(fs_encoding)
+ if expected:
+ self.assertEqual(fs_encoding, expected)
+
+ def test_getfilesystemencoding(self):
+ fs_encoding = sys.getfilesystemencoding()
+ if sys.platform == 'darwin':
+ expected = 'utf-8'
+ elif sys.platform == 'win32':
+ expected = 'mbcs'
+ else:
+ expected = None
+ self.check_fsencoding(fs_encoding, expected)
+
class SizeofTest(unittest.TestCase):
@@ -498,7 +571,7 @@ class SizeofTest(unittest.TestCase):
TPFLAGS_HEAPTYPE = 1<<9
def setUp(self):
- self.c = len(struct.pack('c', ' '))
+ self.c = len(struct.pack('c', b' '))
self.H = len(struct.pack('H', 0))
self.i = len(struct.pack('i', 0))
self.l = len(struct.pack('l', 0))
@@ -583,7 +656,7 @@ class SizeofTest(unittest.TestCase):
return inner
check(get_cell().__closure__[0], size(h + 'P'))
# code
- check(get_cell().__code__, size(h + '5i8Pi2P'))
+ check(get_cell().__code__, size(h + '5i8Pi3P'))
# complex
check(complex(0,1), size(h + '2d'))
# method_descriptor (descriptor object)
@@ -688,7 +761,7 @@ class SizeofTest(unittest.TestCase):
check(int(PyLong_BASE**2-1), size(vh) + 2*self.longdigit)
check(int(PyLong_BASE**2), size(vh) + 3*self.longdigit)
# memory
- check(memoryview(b''), size(h + 'P PP2P2i7P'))
+ check(memoryview(b''), size(h + 'PP2P2i7P'))
# module
check(unittest, size(h + '3P'))
# None
@@ -711,8 +784,8 @@ class SizeofTest(unittest.TestCase):
# reverse
check(reversed(''), size(h + 'PP'))
# range
- check(range(1), size(h + '3P'))
- check(range(66000), size(h + '3P'))
+ check(range(1), size(h + '4P'))
+ check(range(66000), size(h + '4P'))
# set
# frozenset
PySet_MINSIZE = 8
@@ -756,7 +829,7 @@ class SizeofTest(unittest.TestCase):
# we need to test for both sizes, because we don't know if the string
# has been cached
for s in samples:
- basicsize = size(h + 'PPliP') + usize * (len(s) + 1)
+ basicsize = size(h + 'PPPiP') + usize * (len(s) + 1)
check(s, basicsize)
# weakref
import weakref
@@ -790,47 +863,6 @@ class SizeofTest(unittest.TestCase):
# sys.flags
check(sys.flags, size(vh) + self.P * len(sys.flags))
- def test_getfilesystemencoding(self):
- import codecs
-
- def check_fsencoding(fs_encoding):
- if sys.platform == 'darwin':
- self.assertEqual(fs_encoding, 'utf-8')
- elif fs_encoding is None:
- return
- codecs.lookup(fs_encoding)
-
- fs_encoding = sys.getfilesystemencoding()
- check_fsencoding(fs_encoding)
-
- # Even in C locale
- try:
- sys.executable.encode('ascii')
- except UnicodeEncodeError:
- # Python doesn't start with ASCII locale if its path is not ASCII,
- # see issue #8611
- pass
- else:
- env = os.environ.copy()
- env['LANG'] = 'C'
- output = subprocess.check_output(
- [sys.executable, "-c",
- "import sys; print(sys.getfilesystemencoding())"],
- env=env)
- fs_encoding = output.rstrip().decode('ascii')
- check_fsencoding(fs_encoding)
-
- def test_setfilesystemencoding(self):
- old = sys.getfilesystemencoding()
- try:
- sys.setfilesystemencoding("iso-8859-1")
- self.assertEqual(sys.getfilesystemencoding(), "iso-8859-1")
- finally:
- sys.setfilesystemencoding(old)
- try:
- self.assertRaises(LookupError, sys.setfilesystemencoding, "xxx")
- finally:
- sys.setfilesystemencoding(old)
def test_main():
test.support.run_unittest(SysModuleTest, SizeofTest)
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
new file mode 100644
index 0000000000..193b5f00c4
--- /dev/null
+++ b/Lib/test/test_sysconfig.py
@@ -0,0 +1,298 @@
+"""Tests for 'site'.
+
+Tests assume the initial paths in sys.path once the interpreter has begun
+executing have not been removed.
+
+"""
+import unittest
+import sys
+import os
+import subprocess
+import shutil
+from copy import copy, deepcopy
+
+from test.support import (run_unittest, TESTFN, unlink, get_attribute,
+ captured_stdout, skip_unless_symlink)
+
+import sysconfig
+from sysconfig import (get_paths, get_platform, get_config_vars,
+ get_path, get_path_names, _INSTALL_SCHEMES,
+ _get_default_scheme, _expand_vars,
+ get_scheme_names, get_config_var, _main)
+
+class TestSysConfig(unittest.TestCase):
+
+ def setUp(self):
+ """Make a copy of sys.path"""
+ super(TestSysConfig, self).setUp()
+ self.sys_path = sys.path[:]
+ self.makefile = None
+ # patching os.uname
+ if hasattr(os, 'uname'):
+ self.uname = os.uname
+ self._uname = os.uname()
+ else:
+ self.uname = None
+ self._uname = None
+ os.uname = self._get_uname
+ # saving the environment
+ self.name = os.name
+ self.platform = sys.platform
+ self.version = sys.version
+ self.sep = os.sep
+ self.join = os.path.join
+ self.isabs = os.path.isabs
+ self.splitdrive = os.path.splitdrive
+ self._config_vars = copy(sysconfig._CONFIG_VARS)
+ self.old_environ = deepcopy(os.environ)
+
+ def tearDown(self):
+ """Restore sys.path"""
+ sys.path[:] = self.sys_path
+ if self.makefile is not None:
+ os.unlink(self.makefile)
+ self._cleanup_testfn()
+ if self.uname is not None:
+ os.uname = self.uname
+ else:
+ del os.uname
+ os.name = self.name
+ sys.platform = self.platform
+ sys.version = self.version
+ os.sep = self.sep
+ os.path.join = self.join
+ os.path.isabs = self.isabs
+ os.path.splitdrive = self.splitdrive
+ sysconfig._CONFIG_VARS = copy(self._config_vars)
+ for key, value in self.old_environ.items():
+ if os.environ.get(key) != value:
+ os.environ[key] = value
+
+ for key in list(os.environ.keys()):
+ if key not in self.old_environ:
+ del os.environ[key]
+
+ super(TestSysConfig, self).tearDown()
+
+ def _set_uname(self, uname):
+ self._uname = uname
+
+ def _get_uname(self):
+ return self._uname
+
+ def _cleanup_testfn(self):
+ path = TESTFN
+ if os.path.isfile(path):
+ os.remove(path)
+ elif os.path.isdir(path):
+ shutil.rmtree(path)
+
+ def test_get_path_names(self):
+ self.assertEqual(get_path_names(), sysconfig._SCHEME_KEYS)
+
+ def test_get_paths(self):
+ scheme = get_paths()
+ default_scheme = _get_default_scheme()
+ wanted = _expand_vars(default_scheme, None)
+ wanted = list(wanted.items())
+ wanted.sort()
+ scheme = list(scheme.items())
+ scheme.sort()
+ self.assertEqual(scheme, wanted)
+
+ def test_get_path(self):
+ # xxx make real tests here
+ for scheme in _INSTALL_SCHEMES:
+ for name in _INSTALL_SCHEMES[scheme]:
+ res = get_path(name, scheme)
+
+ def test_get_config_vars(self):
+ cvars = get_config_vars()
+ self.assertTrue(isinstance(cvars, dict))
+ self.assertTrue(cvars)
+
+ def test_get_platform(self):
+ # windows XP, 32bits
+ os.name = 'nt'
+ sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+ '[MSC v.1310 32 bit (Intel)]')
+ sys.platform = 'win32'
+ self.assertEqual(get_platform(), 'win32')
+
+ # windows XP, amd64
+ os.name = 'nt'
+ sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+ '[MSC v.1310 32 bit (Amd64)]')
+ sys.platform = 'win32'
+ self.assertEqual(get_platform(), 'win-amd64')
+
+ # windows XP, itanium
+ os.name = 'nt'
+ sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+ '[MSC v.1310 32 bit (Itanium)]')
+ sys.platform = 'win32'
+ self.assertEqual(get_platform(), 'win-ia64')
+
+ # macbook
+ os.name = 'posix'
+ sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) '
+ '\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]')
+ sys.platform = 'darwin'
+ self._set_uname(('Darwin', 'macziade', '8.11.1',
+ ('Darwin Kernel Version 8.11.1: '
+ 'Wed Oct 10 18:23:28 PDT 2007; '
+ 'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC'))
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
+
+ get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
+ '-fwrapv -O3 -Wall -Wstrict-prototypes')
+
+ maxint = sys.maxsize
+ try:
+ sys.maxsize = 2147483647
+ self.assertEqual(get_platform(), 'macosx-10.3-ppc')
+ sys.maxsize = 9223372036854775807
+ self.assertEqual(get_platform(), 'macosx-10.3-ppc64')
+ finally:
+ sys.maxsize = maxint
+
+
+ self._set_uname(('Darwin', 'macziade', '8.11.1',
+ ('Darwin Kernel Version 8.11.1: '
+ 'Wed Oct 10 18:23:28 PDT 2007; '
+ 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
+ get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
+
+ get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
+ '-fwrapv -O3 -Wall -Wstrict-prototypes')
+ maxint = sys.maxsize
+ try:
+ sys.maxsize = 2147483647
+ self.assertEqual(get_platform(), 'macosx-10.3-i386')
+ sys.maxsize = 9223372036854775807
+ self.assertEqual(get_platform(), 'macosx-10.3-x86_64')
+ finally:
+ sys.maxsize = maxint
+
+ # macbook with fat binaries (fat, universal or fat64)
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
+ get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+
+ self.assertEqual(get_platform(), 'macosx-10.4-fat')
+
+ get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+
+ self.assertEqual(get_platform(), 'macosx-10.4-intel')
+
+ get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+ self.assertEqual(get_platform(), 'macosx-10.4-fat3')
+
+ get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+ self.assertEqual(get_platform(), 'macosx-10.4-universal')
+
+ get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+
+ self.assertEqual(get_platform(), 'macosx-10.4-fat64')
+
+ for arch in ('ppc', 'i386', 'x86_64', 'ppc64'):
+ get_config_vars()['CFLAGS'] = ('-arch %s -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3'%(arch,))
+
+ self.assertEqual(get_platform(), 'macosx-10.4-%s'%(arch,))
+
+ # linux debian sarge
+ os.name = 'posix'
+ sys.version = ('2.3.5 (#1, Jul 4 2007, 17:28:59) '
+ '\n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]')
+ sys.platform = 'linux2'
+ self._set_uname(('Linux', 'aglae', '2.6.21.1dedibox-r7',
+ '#1 Mon Apr 30 17:25:38 CEST 2007', 'i686'))
+
+ self.assertEqual(get_platform(), 'linux-i686')
+
+ # XXX more platforms to tests here
+
+ def test_get_config_h_filename(self):
+ config_h = sysconfig.get_config_h_filename()
+ self.assertTrue(os.path.isfile(config_h), config_h)
+
+ @unittest.skipIf(sys.platform.startswith('win'),
+ 'Test is not Windows compatible')
+ def test_get_makefile_filename(self):
+ makefile = sysconfig.get_makefile_filename()
+ self.assertTrue(os.path.isfile(makefile), makefile)
+
+ def test_get_scheme_names(self):
+ wanted = ('nt', 'nt_user', 'os2', 'os2_home', 'osx_framework_user',
+ 'posix_home', 'posix_prefix', 'posix_user')
+ self.assertEqual(get_scheme_names(), wanted)
+
+ @skip_unless_symlink
+ def test_symlink(self):
+ # On Windows, the EXE needs to know where pythonXY.dll is at so we have
+ # to add the directory to the path.
+ if sys.platform == "win32":
+ os.environ["Path"] = "{};{}".format(
+ os.path.dirname(sys.executable), os.environ["Path"])
+
+ # Issue 7880
+ def get(python):
+ cmd = [python, '-c',
+ 'import sysconfig; print(sysconfig.get_platform())']
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=os.environ)
+ return p.communicate()
+ real = os.path.realpath(sys.executable)
+ link = os.path.abspath(TESTFN)
+ os.symlink(real, link)
+ try:
+ self.assertEqual(get(real), get(link))
+ finally:
+ unlink(link)
+
+ def test_user_similar(self):
+ # Issue 8759 : make sure the posix scheme for the users
+ # is similar to the global posix_prefix one
+ base = get_config_var('base')
+ user = get_config_var('userbase')
+ for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
+ global_path = get_path(name, 'posix_prefix')
+ user_path = get_path(name, 'posix_user')
+ self.assertEqual(user_path, global_path.replace(base, user))
+
+ def test_main(self):
+ # just making sure _main() runs and returns things in the stdout
+ with captured_stdout() as output:
+ _main()
+ self.assertTrue(len(output.getvalue().split('\n')) > 0)
+
+ @unittest.skipIf(sys.platform == "win32", "Does not apply to Windows")
+ def test_ldshared_value(self):
+ ldflags = sysconfig.get_config_var('LDFLAGS')
+ ldshared = sysconfig.get_config_var('LDSHARED')
+
+ self.assertIn(ldflags, ldshared)
+
+
+def test_main():
+ run_unittest(TestSysConfig)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_syslog.py b/Lib/test/test_syslog.py
index 028dcb49aa..4e7621e5ec 100644
--- a/Lib/test/test_syslog.py
+++ b/Lib/test/test_syslog.py
@@ -11,6 +11,8 @@ class Test(unittest.TestCase):
def test_openlog(self):
syslog.openlog('python')
+ # Issue #6697.
+ self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
def test_syslog(self):
syslog.openlog('python')
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 124f0e97f8..68e094d5db 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -2,7 +2,6 @@ import sys
import os
import io
import shutil
-import tempfile
import io
from hashlib import md5
import errno
@@ -26,7 +25,7 @@ except ImportError:
def md5sum(data):
return md5(data).hexdigest()
-TEMPDIR = os.path.abspath(support.TESTFN)
+TEMPDIR = os.path.abspath(support.TESTFN) + "-tardir"
tarname = support.findfile("testtar.tar")
gzipname = os.path.join(TEMPDIR, "testtar.tar.gz")
bz2name = os.path.join(TEMPDIR, "testtar.tar.bz2")
@@ -53,41 +52,50 @@ class UstarReadTest(ReadTest):
def test_fileobj_regular_file(self):
tarinfo = self.tar.getmember("ustar/regtype")
fobj = self.tar.extractfile(tarinfo)
- data = fobj.read()
- self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
- "regular file extraction failed")
+ try:
+ data = fobj.read()
+ self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
+ "regular file extraction failed")
+ finally:
+ fobj.close()
def test_fileobj_readlines(self):
self.tar.extract("ustar/regtype", TEMPDIR)
tarinfo = self.tar.getmember("ustar/regtype")
- fobj1 = open(os.path.join(TEMPDIR, "ustar/regtype"), "r")
- fobj2 = io.TextIOWrapper(self.tar.extractfile(tarinfo))
-
- lines1 = fobj1.readlines()
- lines2 = fobj2.readlines()
- self.assertTrue(lines1 == lines2,
- "fileobj.readlines() failed")
- self.assertTrue(len(lines2) == 114,
- "fileobj.readlines() failed")
- self.assertTrue(lines2[83] == \
- "I will gladly admit that Python is not the fastest running scripting language.\n",
- "fileobj.readlines() failed")
+ with open(os.path.join(TEMPDIR, "ustar/regtype"), "r") as fobj1:
+ lines1 = fobj1.readlines()
+
+ fobj = self.tar.extractfile(tarinfo)
+ try:
+ fobj2 = io.TextIOWrapper(fobj)
+ lines2 = fobj2.readlines()
+ self.assertTrue(lines1 == lines2,
+ "fileobj.readlines() failed")
+ self.assertTrue(len(lines2) == 114,
+ "fileobj.readlines() failed")
+ self.assertTrue(lines2[83] ==
+ "I will gladly admit that Python is not the fastest running scripting language.\n",
+ "fileobj.readlines() failed")
+ finally:
+ fobj.close()
def test_fileobj_iter(self):
self.tar.extract("ustar/regtype", TEMPDIR)
tarinfo = self.tar.getmember("ustar/regtype")
- fobj1 = open(os.path.join(TEMPDIR, "ustar/regtype"), "rU")
+ with open(os.path.join(TEMPDIR, "ustar/regtype"), "rU") as fobj1:
+ lines1 = fobj1.readlines()
fobj2 = self.tar.extractfile(tarinfo)
- lines1 = fobj1.readlines()
- lines2 = list(io.TextIOWrapper(fobj2))
- self.assertTrue(lines1 == lines2,
- "fileobj.__iter__() failed")
+ try:
+ lines2 = list(io.TextIOWrapper(fobj2))
+ self.assertTrue(lines1 == lines2,
+ "fileobj.__iter__() failed")
+ finally:
+ fobj2.close()
def test_fileobj_seek(self):
self.tar.extract("ustar/regtype", TEMPDIR)
- fobj = open(os.path.join(TEMPDIR, "ustar/regtype"), "rb")
- data = fobj.read()
- fobj.close()
+ with open(os.path.join(TEMPDIR, "ustar/regtype"), "rb") as fobj:
+ data = fobj.read()
tarinfo = self.tar.getmember("ustar/regtype")
fobj = self.tar.extractfile(tarinfo)
@@ -134,38 +142,120 @@ class UstarReadTest(ReadTest):
"read() after readline() failed")
fobj.close()
+ # Test if symbolic and hard links are resolved by extractfile(). The
+ # test link members each point to a regular member whose data is
+ # supposed to be exported.
+ def _test_fileobj_link(self, lnktype, regtype):
+ a = self.tar.extractfile(lnktype)
+ b = self.tar.extractfile(regtype)
+ try:
+ self.assertEqual(a.name, b.name)
+ finally:
+ a.close()
+ b.close()
+
+ def test_fileobj_link1(self):
+ self._test_fileobj_link("ustar/lnktype", "ustar/regtype")
+
+ def test_fileobj_link2(self):
+ self._test_fileobj_link("./ustar/linktest2/lnktype", "ustar/linktest1/regtype")
+
+ def test_fileobj_symlink1(self):
+ self._test_fileobj_link("ustar/symtype", "ustar/regtype")
+
+ def test_fileobj_symlink2(self):
+ self._test_fileobj_link("./ustar/linktest2/symtype", "ustar/linktest1/regtype")
+
+
+class CommonReadTest(ReadTest):
+
+ def test_empty_tarfile(self):
+ # Test for issue6123: Allow opening empty archives.
+ # This test checks if tarfile.open() is able to open an empty tar
+ # archive successfully. Note that an empty tar archive is not the
+ # same as an empty file!
+ with tarfile.open(tmpname, self.mode.replace("r", "w")):
+ pass
+ try:
+ tar = tarfile.open(tmpname, self.mode)
+ tar.getnames()
+ except tarfile.ReadError:
+ self.fail("tarfile.open() failed on empty archive")
+ else:
+ self.assertListEqual(tar.getmembers(), [])
+ finally:
+ tar.close()
+
+ def test_null_tarfile(self):
+ # Test for issue6123: Allow opening empty archives.
+ # This test guarantees that tarfile.open() does not treat an empty
+ # file as an empty tar archive.
+ with open(tmpname, "wb"):
+ pass
+ self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, self.mode)
+ self.assertRaises(tarfile.ReadError, tarfile.open, tmpname)
+
+ def test_ignore_zeros(self):
+ # Test TarFile's ignore_zeros option.
+ if self.mode.endswith(":gz"):
+ _open = gzip.GzipFile
+ elif self.mode.endswith(":bz2"):
+ _open = bz2.BZ2File
+ else:
+ _open = open
+
+ for char in (b'\0', b'a'):
+ # Test if EOFHeaderError ('\0') and InvalidHeaderError ('a')
+ # are ignored correctly.
+ with _open(tmpname, "wb") as fobj:
+ fobj.write(char * 1024)
+ fobj.write(tarfile.TarInfo("foo").tobuf())
+
+ tar = tarfile.open(tmpname, mode="r", ignore_zeros=True)
+ try:
+ self.assertListEqual(tar.getnames(), ["foo"],
+ "ignore_zeros=True should have skipped the %r-blocks" % char)
+ finally:
+ tar.close()
+
-class MiscReadTest(ReadTest):
+class MiscReadTest(CommonReadTest):
def test_no_name_argument(self):
- fobj = open(self.tarname, "rb")
- tar = tarfile.open(fileobj=fobj, mode=self.mode)
- self.assertEqual(tar.name, os.path.abspath(fobj.name))
+ with open(self.tarname, "rb") as fobj:
+ tar = tarfile.open(fileobj=fobj, mode=self.mode)
+ self.assertEqual(tar.name, os.path.abspath(fobj.name))
def test_no_name_attribute(self):
- data = open(self.tarname, "rb").read()
+ with open(self.tarname, "rb") as fobj:
+ data = fobj.read()
fobj = io.BytesIO(data)
self.assertRaises(AttributeError, getattr, fobj, "name")
tar = tarfile.open(fileobj=fobj, mode=self.mode)
self.assertEqual(tar.name, None)
def test_empty_name_attribute(self):
- data = open(self.tarname, "rb").read()
+ with open(self.tarname, "rb") as fobj:
+ data = fobj.read()
fobj = io.BytesIO(data)
fobj.name = ""
- tar = tarfile.open(fileobj=fobj, mode=self.mode)
- self.assertEqual(tar.name, None)
+ with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
+ self.assertEqual(tar.name, None)
def test_fileobj_with_offset(self):
# Skip the first member and store values from the second member
# of the testtar.
tar = tarfile.open(self.tarname, mode=self.mode)
- tar.next()
- t = tar.next()
- name = t.name
- offset = t.offset
- data = tar.extractfile(t).read()
- tar.close()
+ try:
+ tar.next()
+ t = tar.next()
+ name = t.name
+ offset = t.offset
+ f = tar.extractfile(t)
+ data = f.read()
+ f.close()
+ finally:
+ tar.close()
# Open the testtar and seek to the offset of the second member.
if self.mode.endswith(":gz"):
@@ -175,26 +265,30 @@ class MiscReadTest(ReadTest):
else:
_open = open
fobj = _open(self.tarname, "rb")
- fobj.seek(offset)
-
- # Test if the tarfile starts with the second member.
- tar = tar.open(self.tarname, mode="r:", fileobj=fobj)
- t = tar.next()
- self.assertEqual(t.name, name)
- # Read to the end of fileobj and test if seeking back to the
- # beginning works.
- tar.getmembers()
- self.assertEqual(tar.extractfile(t).read(), data,
- "seek back did not work")
- tar.close()
+ try:
+ fobj.seek(offset)
+
+ # Test if the tarfile starts with the second member.
+ tar = tar.open(self.tarname, mode="r:", fileobj=fobj)
+ t = tar.next()
+ self.assertEqual(t.name, name)
+ # Read to the end of fileobj and test if seeking back to the
+ # beginning works.
+ tar.getmembers()
+ self.assertEqual(tar.extractfile(t).read(), data,
+ "seek back did not work")
+ tar.close()
+ finally:
+ fobj.close()
def test_fail_comp(self):
# For Gzip and Bz2 Tests: fail with a ReadError on an uncompressed file.
if self.mode == "r:":
return
self.assertRaises(tarfile.ReadError, tarfile.open, tarname, self.mode)
- fobj = open(tarname, "rb")
- self.assertRaises(tarfile.ReadError, tarfile.open, fileobj=fobj, mode=self.mode)
+ with open(tarname, "rb") as fobj:
+ self.assertRaises(tarfile.ReadError, tarfile.open,
+ fileobj=fobj, mode=self.mode)
def test_v7_dirtype(self):
# Test old style dirtype member (bug #1336623):
@@ -226,66 +320,121 @@ class MiscReadTest(ReadTest):
self.assertTrue(self.tar.getmembers()[-1].name == "misc/eof",
"could not find all members")
+ @unittest.skipUnless(hasattr(os, "link"),
+ "Missing hardlink implementation")
+ @support.skip_unless_symlink
def test_extract_hardlink(self):
# Test hardlink extraction (e.g. bug #857297).
tar = tarfile.open(tarname, errorlevel=1, encoding="iso8859-1")
- tar.extract("ustar/regtype", TEMPDIR)
try:
- tar.extract("ustar/lnktype", TEMPDIR)
- except EnvironmentError as e:
- if e.errno == errno.ENOENT:
- self.fail("hardlink not extracted properly")
+ tar.extract("ustar/regtype", TEMPDIR)
+ try:
+ tar.extract("ustar/lnktype", TEMPDIR)
+ except EnvironmentError as e:
+ if e.errno == errno.ENOENT:
+ self.fail("hardlink not extracted properly")
- data = open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb").read()
- self.assertEqual(md5sum(data), md5_regtype)
+ with open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb") as f:
+ data = f.read()
+ self.assertEqual(md5sum(data), md5_regtype)
- try:
- tar.extract("ustar/symtype", TEMPDIR)
- except EnvironmentError as e:
- if e.errno == errno.ENOENT:
- self.fail("symlink not extracted properly")
-
- data = open(os.path.join(TEMPDIR, "ustar/symtype"), "rb").read()
- self.assertEqual(md5sum(data), md5_regtype)
+ try:
+ tar.extract("ustar/symtype", TEMPDIR)
+ except EnvironmentError as e:
+ if e.errno == errno.ENOENT:
+ self.fail("symlink not extracted properly")
+
+ with open(os.path.join(TEMPDIR, "ustar/symtype"), "rb") as f:
+ data = f.read()
+ self.assertEqual(md5sum(data), md5_regtype)
+ finally:
+ tar.close()
def test_extractall(self):
# Test if extractall() correctly restores directory permissions
# and times (see issue1735).
tar = tarfile.open(tarname, encoding="iso8859-1")
- directories = [t for t in tar if t.isdir()]
- tar.extractall(TEMPDIR, directories)
- for tarinfo in directories:
- path = os.path.join(TEMPDIR, tarinfo.name)
- if sys.platform != "win32":
- # Win32 has no support for fine grained permissions.
- self.assertEqual(tarinfo.mode & 0o777, os.stat(path).st_mode & 0o777)
- self.assertEqual(tarinfo.mtime, os.path.getmtime(path))
- tar.close()
+ DIR = os.path.join(TEMPDIR, "extractall")
+ os.mkdir(DIR)
+ try:
+ directories = [t for t in tar if t.isdir()]
+ tar.extractall(DIR, directories)
+ for tarinfo in directories:
+ path = os.path.join(DIR, tarinfo.name)
+ if sys.platform != "win32":
+ # Win32 has no support for fine grained permissions.
+ self.assertEqual(tarinfo.mode & 0o777, os.stat(path).st_mode & 0o777)
+ def format_mtime(mtime):
+ if isinstance(mtime, float):
+ return "{} ({})".format(mtime, mtime.hex())
+ else:
+ return "{!r} (int)".format(mtime)
+ file_mtime = os.path.getmtime(path)
+ errmsg = "tar mtime {0} != file time {1} of path {2!a}".format(
+ format_mtime(tarinfo.mtime),
+ format_mtime(file_mtime),
+ path)
+ self.assertEqual(tarinfo.mtime, file_mtime, errmsg)
+ finally:
+ tar.close()
+ shutil.rmtree(DIR)
+
+ def test_extract_directory(self):
+ dirtype = "ustar/dirtype"
+ DIR = os.path.join(TEMPDIR, "extractdir")
+ os.mkdir(DIR)
+ try:
+ with tarfile.open(tarname, encoding="iso8859-1") as tar:
+ tarinfo = tar.getmember(dirtype)
+ tar.extract(tarinfo, path=DIR)
+ extracted = os.path.join(DIR, dirtype)
+ self.assertEqual(os.path.getmtime(extracted), tarinfo.mtime)
+ if sys.platform != "win32":
+ self.assertEqual(os.stat(extracted).st_mode & 0o777, 0o755)
+ finally:
+ shutil.rmtree(DIR)
def test_init_close_fobj(self):
# Issue #7341: Close the internal file object in the TarFile
# constructor in case of an error. For the test we rely on
- # the fact that opening an invalid file raises a ReadError.
- invalid = os.path.join(TEMPDIR, "invalid")
- open(invalid, "wb").write(b"foo")
+ # the fact that opening an empty file raises a ReadError.
+ empty = os.path.join(TEMPDIR, "empty")
+ with open(empty, "wb") as fobj:
+ fobj.write(b"")
try:
tar = object.__new__(tarfile.TarFile)
try:
- tar.__init__(invalid)
+ tar.__init__(empty)
except tarfile.ReadError:
self.assertTrue(tar.fileobj.closed)
else:
self.fail("ReadError not raised")
finally:
- os.remove(invalid)
+ support.unlink(empty)
-class StreamReadTest(ReadTest):
+class StreamReadTest(CommonReadTest):
mode="r|"
+ def test_read_through(self):
+ # Issue #11224: A poorly designed _FileInFile.read() method
+ # caused seeking errors with stream tar files.
+ for tarinfo in self.tar:
+ if not tarinfo.isreg():
+ continue
+ fobj = self.tar.extractfile(tarinfo)
+ while True:
+ try:
+ buf = fobj.read(512)
+ except tarfile.StreamError:
+ self.fail("simple read-through using TarFile.extractfile() failed")
+ if not buf:
+ break
+ fobj.close()
+
def test_fileobj_regular_file(self):
tarinfo = self.tar.next() # get "regtype" (can't use getmember)
fobj = self.tar.extractfile(tarinfo)
@@ -300,42 +449,48 @@ class StreamReadTest(ReadTest):
def test_compare_members(self):
tar1 = tarfile.open(tarname, encoding="iso8859-1")
- tar2 = self.tar
-
- while True:
- t1 = tar1.next()
- t2 = tar2.next()
- if t1 is None:
- break
- self.assertTrue(t2 is not None, "stream.next() failed.")
-
- if t2.islnk() or t2.issym():
- self.assertRaises(tarfile.StreamError, tar2.extractfile, t2)
- continue
-
- v1 = tar1.extractfile(t1)
- v2 = tar2.extractfile(t2)
- if v1 is None:
- continue
- self.assertTrue(v2 is not None, "stream.extractfile() failed")
- self.assertEqual(v1.read(), v2.read(), "stream extraction failed")
-
- tar1.close()
+ try:
+ tar2 = self.tar
+
+ while True:
+ t1 = tar1.next()
+ t2 = tar2.next()
+ if t1 is None:
+ break
+ self.assertTrue(t2 is not None, "stream.next() failed.")
+
+ if t2.islnk() or t2.issym():
+ self.assertRaises(tarfile.StreamError, tar2.extractfile, t2)
+ continue
+
+ v1 = tar1.extractfile(t1)
+ v2 = tar2.extractfile(t2)
+ if v1 is None:
+ continue
+ self.assertTrue(v2 is not None, "stream.extractfile() failed")
+ self.assertEqual(v1.read(), v2.read(), "stream extraction failed")
+ finally:
+ tar1.close()
class DetectReadTest(unittest.TestCase):
def _testfunc_file(self, name, mode):
try:
- tarfile.open(name, mode)
+ tar = tarfile.open(name, mode)
except tarfile.ReadError as e:
self.fail()
+ else:
+ tar.close()
def _testfunc_fileobj(self, name, mode):
try:
- tarfile.open(name, mode, fileobj=open(name, "rb"))
+ with open(name, "rb") as f:
+ tar = tarfile.open(name, mode, fileobj=f)
except tarfile.ReadError as e:
self.fail()
+ else:
+ tar.close()
def _test_modes(self, testfunc):
testfunc(tarname, "r")
@@ -433,19 +588,36 @@ class MemberReadTest(ReadTest):
tarinfo = self.tar.getmember("ustar/sparse")
self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+ def test_find_gnusparse(self):
+ tarinfo = self.tar.getmember("gnu/sparse")
+ self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+
+ def test_find_gnusparse_00(self):
+ tarinfo = self.tar.getmember("gnu/sparse-0.0")
+ self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+
+ def test_find_gnusparse_01(self):
+ tarinfo = self.tar.getmember("gnu/sparse-0.1")
+ self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+
+ def test_find_gnusparse_10(self):
+ tarinfo = self.tar.getmember("gnu/sparse-1.0")
+ self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+
def test_find_umlauts(self):
tarinfo = self.tar.getmember("ustar/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
self._test_member(tarinfo, size=7011, chksum=md5_regtype)
def test_find_ustar_longname(self):
name = "ustar/" + "12345/" * 39 + "1234567/longname"
- self.assertTrue(name in self.tar.getnames())
+ self.assertIn(name, self.tar.getnames())
def test_find_regtype_oldv7(self):
tarinfo = self.tar.getmember("misc/regtype-old-v7")
self._test_member(tarinfo, size=7011, chksum=md5_regtype)
def test_find_pax_umlauts(self):
+ self.tar.close()
self.tar = tarfile.open(self.tarname, mode=self.mode, encoding="iso8859-1")
tarinfo = self.tar.getmember("pax/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
self._test_member(tarinfo, size=7011, chksum=md5_regtype)
@@ -484,10 +656,10 @@ class LongnameTest(ReadTest):
# the preceding extended header.
longname = self.subdir + "/" + "123/" * 125 + "longname"
offset = self.tar.getmember(longname).offset
- fobj = open(tarname, "rb")
- fobj.seek(offset)
- tarinfo = tarfile.TarInfo.frombuf(fobj.read(512), "iso8859-1", "strict")
- self.assertEqual(tarinfo.type, self.longnametype)
+ with open(tarname, "rb") as fobj:
+ fobj.seek(offset)
+ tarinfo = tarfile.TarInfo.frombuf(fobj.read(512), "iso8859-1", "strict")
+ self.assertEqual(tarinfo.type, self.longnametype)
class GNUReadTest(LongnameTest):
@@ -495,13 +667,53 @@ class GNUReadTest(LongnameTest):
subdir = "gnu"
longnametype = tarfile.GNUTYPE_LONGNAME
- def test_sparse_file(self):
- tarinfo1 = self.tar.getmember("ustar/sparse")
- fobj1 = self.tar.extractfile(tarinfo1)
- tarinfo2 = self.tar.getmember("gnu/sparse")
- fobj2 = self.tar.extractfile(tarinfo2)
- self.assertEqual(fobj1.read(), fobj2.read(),
- "sparse file extraction failed")
+ # Since 3.2 tarfile is supposed to accurately restore sparse members and
+ # produce files with holes. This is what we actually want to test here.
+ # Unfortunately, not all platforms/filesystems support sparse files, and
+ # even on platforms that do it is non-trivial to make reliable assertions
+ # about holes in files. Therefore, we first do one basic test which works
+ # an all platforms, and after that a test that will work only on
+ # platforms/filesystems that prove to support sparse files.
+ def _test_sparse_file(self, name):
+ self.tar.extract(name, TEMPDIR)
+ filename = os.path.join(TEMPDIR, name)
+ with open(filename, "rb") as fobj:
+ data = fobj.read()
+ self.assertEqual(md5sum(data), md5_sparse,
+ "wrong md5sum for %s" % name)
+
+ if self._fs_supports_holes():
+ s = os.stat(filename)
+ self.assertTrue(s.st_blocks * 512 < s.st_size)
+
+ def test_sparse_file_old(self):
+ self._test_sparse_file("gnu/sparse")
+
+ def test_sparse_file_00(self):
+ self._test_sparse_file("gnu/sparse-0.0")
+
+ def test_sparse_file_01(self):
+ self._test_sparse_file("gnu/sparse-0.1")
+
+ def test_sparse_file_10(self):
+ self._test_sparse_file("gnu/sparse-1.0")
+
+ @staticmethod
+ def _fs_supports_holes():
+ # Return True if the platform knows the st_blocks stat attribute and
+ # uses st_blocks units of 512 bytes, and if the filesystem is able to
+ # store holes in files.
+ if sys.platform == "linux2":
+ # Linux evidentially has 512 byte st_blocks units.
+ name = os.path.join(TEMPDIR, "sparse-test")
+ with open(name, "wb") as fobj:
+ fobj.seek(4096)
+ fobj.truncate()
+ s = os.stat(name)
+ os.remove(name)
+ return s.st_blocks == 0
+ else:
+ return False
class PaxReadTest(LongnameTest):
@@ -511,33 +723,38 @@ class PaxReadTest(LongnameTest):
def test_pax_global_headers(self):
tar = tarfile.open(tarname, encoding="iso8859-1")
-
- tarinfo = tar.getmember("pax/regtype1")
- self.assertEqual(tarinfo.uname, "foo")
- self.assertEqual(tarinfo.gname, "bar")
- self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
-
- tarinfo = tar.getmember("pax/regtype2")
- self.assertEqual(tarinfo.uname, "")
- self.assertEqual(tarinfo.gname, "bar")
- self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
-
- tarinfo = tar.getmember("pax/regtype3")
- self.assertEqual(tarinfo.uname, "tarfile")
- self.assertEqual(tarinfo.gname, "tarfile")
- self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
+ try:
+ tarinfo = tar.getmember("pax/regtype1")
+ self.assertEqual(tarinfo.uname, "foo")
+ self.assertEqual(tarinfo.gname, "bar")
+ self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
+
+ tarinfo = tar.getmember("pax/regtype2")
+ self.assertEqual(tarinfo.uname, "")
+ self.assertEqual(tarinfo.gname, "bar")
+ self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
+
+ tarinfo = tar.getmember("pax/regtype3")
+ self.assertEqual(tarinfo.uname, "tarfile")
+ self.assertEqual(tarinfo.gname, "tarfile")
+ self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
+ finally:
+ tar.close()
def test_pax_number_fields(self):
# All following number fields are read from the pax header.
tar = tarfile.open(tarname, encoding="iso8859-1")
- tarinfo = tar.getmember("pax/regtype4")
- self.assertEqual(tarinfo.size, 7011)
- self.assertEqual(tarinfo.uid, 123)
- self.assertEqual(tarinfo.gid, 123)
- self.assertEqual(tarinfo.mtime, 1041808783.0)
- self.assertEqual(type(tarinfo.mtime), float)
- self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
- self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
+ try:
+ tarinfo = tar.getmember("pax/regtype4")
+ self.assertEqual(tarinfo.size, 7011)
+ self.assertEqual(tarinfo.uid, 123)
+ self.assertEqual(tarinfo.gid, 123)
+ self.assertEqual(tarinfo.mtime, 1041808783.0)
+ self.assertEqual(type(tarinfo.mtime), float)
+ self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
+ self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
+ finally:
+ tar.close()
class WriteTestBase(unittest.TestCase):
@@ -563,52 +780,59 @@ class WriteTest(WriteTestBase):
# a trailing '\0'.
name = "0123456789" * 10
tar = tarfile.open(tmpname, self.mode)
- t = tarfile.TarInfo(name)
- tar.addfile(t)
- tar.close()
+ try:
+ t = tarfile.TarInfo(name)
+ tar.addfile(t)
+ finally:
+ tar.close()
tar = tarfile.open(tmpname)
- self.assertTrue(tar.getnames()[0] == name,
- "failed to store 100 char filename")
- tar.close()
+ try:
+ self.assertTrue(tar.getnames()[0] == name,
+ "failed to store 100 char filename")
+ finally:
+ tar.close()
def test_tar_size(self):
# Test for bug #1013882.
tar = tarfile.open(tmpname, self.mode)
- path = os.path.join(TEMPDIR, "file")
- fobj = open(path, "wb")
- fobj.write(b"aaa")
- fobj.close()
- tar.add(path)
- tar.close()
+ try:
+ path = os.path.join(TEMPDIR, "file")
+ with open(path, "wb") as fobj:
+ fobj.write(b"aaa")
+ tar.add(path)
+ finally:
+ tar.close()
self.assertTrue(os.path.getsize(tmpname) > 0,
"tarfile is empty")
# The test_*_size tests test for bug #1167128.
def test_file_size(self):
tar = tarfile.open(tmpname, self.mode)
+ try:
+ path = os.path.join(TEMPDIR, "file")
+ with open(path, "wb"):
+ pass
+ tarinfo = tar.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 0)
- path = os.path.join(TEMPDIR, "file")
- fobj = open(path, "wb")
- fobj.close()
- tarinfo = tar.gettarinfo(path)
- self.assertEqual(tarinfo.size, 0)
-
- fobj = open(path, "wb")
- fobj.write(b"aaa")
- fobj.close()
- tarinfo = tar.gettarinfo(path)
- self.assertEqual(tarinfo.size, 3)
-
- tar.close()
+ with open(path, "wb") as fobj:
+ fobj.write(b"aaa")
+ tarinfo = tar.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 3)
+ finally:
+ tar.close()
def test_directory_size(self):
path = os.path.join(TEMPDIR, "directory")
os.mkdir(path)
try:
tar = tarfile.open(tmpname, self.mode)
- tarinfo = tar.gettarinfo(path)
- self.assertEqual(tarinfo.size, 0)
+ try:
+ tarinfo = tar.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 0)
+ finally:
+ tar.close()
finally:
os.rmdir(path)
@@ -616,46 +840,52 @@ class WriteTest(WriteTestBase):
if hasattr(os, "link"):
link = os.path.join(TEMPDIR, "link")
target = os.path.join(TEMPDIR, "link_target")
- fobj = open(target, "wb")
- fobj.write(b"aaa")
- fobj.close()
+ with open(target, "wb") as fobj:
+ fobj.write(b"aaa")
os.link(target, link)
try:
tar = tarfile.open(tmpname, self.mode)
- # Record the link target in the inodes list.
- tar.gettarinfo(target)
- tarinfo = tar.gettarinfo(link)
- self.assertEqual(tarinfo.size, 0)
+ try:
+ # Record the link target in the inodes list.
+ tar.gettarinfo(target)
+ tarinfo = tar.gettarinfo(link)
+ self.assertEqual(tarinfo.size, 0)
+ finally:
+ tar.close()
finally:
os.remove(target)
os.remove(link)
+ @support.skip_unless_symlink
def test_symlink_size(self):
- if hasattr(os, "symlink"):
- path = os.path.join(TEMPDIR, "symlink")
- os.symlink("link_target", path)
+ path = os.path.join(TEMPDIR, "symlink")
+ os.symlink("link_target", path)
+ try:
+ tar = tarfile.open(tmpname, self.mode)
try:
- tar = tarfile.open(tmpname, self.mode)
tarinfo = tar.gettarinfo(path)
self.assertEqual(tarinfo.size, 0)
finally:
- os.remove(path)
+ tar.close()
+ finally:
+ os.remove(path)
def test_add_self(self):
# Test for #1257255.
dstname = os.path.abspath(tmpname)
-
tar = tarfile.open(tmpname, self.mode)
- self.assertTrue(tar.name == dstname, "archive name must be absolute")
-
- tar.add(dstname)
- self.assertTrue(tar.getnames() == [], "added the archive to itself")
-
- cwd = os.getcwd()
- os.chdir(TEMPDIR)
- tar.add(dstname)
- os.chdir(cwd)
- self.assertTrue(tar.getnames() == [], "added the archive to itself")
+ try:
+ self.assertTrue(tar.name == dstname, "archive name must be absolute")
+ tar.add(dstname)
+ self.assertTrue(tar.getnames() == [], "added the archive to itself")
+
+ cwd = os.getcwd()
+ os.chdir(TEMPDIR)
+ tar.add(dstname)
+ os.chdir(cwd)
+ self.assertTrue(tar.getnames() == [], "added the archive to itself")
+ finally:
+ tar.close()
def test_exclude(self):
tempdir = os.path.join(TEMPDIR, "exclude")
@@ -665,19 +895,137 @@ class WriteTest(WriteTestBase):
name = os.path.join(tempdir, name)
open(name, "wb").close()
- def exclude(name):
- return os.path.isfile(name)
+ exclude = os.path.isfile
tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
- tar.add(tempdir, arcname="empty_dir", exclude=exclude)
- tar.close()
+ try:
+ with support.check_warnings(("use the filter argument",
+ DeprecationWarning)):
+ tar.add(tempdir, arcname="empty_dir", exclude=exclude)
+ finally:
+ tar.close()
+
+ tar = tarfile.open(tmpname, "r")
+ try:
+ self.assertEqual(len(tar.getmembers()), 1)
+ self.assertEqual(tar.getnames()[0], "empty_dir")
+ finally:
+ tar.close()
+ finally:
+ shutil.rmtree(tempdir)
+
+ def test_filter(self):
+ tempdir = os.path.join(TEMPDIR, "filter")
+ os.mkdir(tempdir)
+ try:
+ for name in ("foo", "bar", "baz"):
+ name = os.path.join(tempdir, name)
+ open(name, "wb").close()
+
+ def filter(tarinfo):
+ if os.path.basename(tarinfo.name) == "bar":
+ return
+ tarinfo.uid = 123
+ tarinfo.uname = "foo"
+ return tarinfo
+
+ tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
+ try:
+ tar.add(tempdir, arcname="empty_dir", filter=filter)
+ finally:
+ tar.close()
+
+ # Verify that filter is a keyword-only argument
+ with self.assertRaises(TypeError):
+ tar.add(tempdir, "empty_dir", True, None, filter)
tar = tarfile.open(tmpname, "r")
- self.assertEqual(len(tar.getmembers()), 1)
- self.assertEqual(tar.getnames()[0], "empty_dir")
+ try:
+ for tarinfo in tar:
+ self.assertEqual(tarinfo.uid, 123)
+ self.assertEqual(tarinfo.uname, "foo")
+ self.assertEqual(len(tar.getmembers()), 3)
+ finally:
+ tar.close()
finally:
shutil.rmtree(tempdir)
+ # Guarantee that stored pathnames are not modified. Don't
+ # remove ./ or ../ or double slashes. Still make absolute
+ # pathnames relative.
+ # For details see bug #6054.
+ def _test_pathname(self, path, cmp_path=None, dir=False):
+ # Create a tarfile with an empty member named path
+ # and compare the stored name with the original.
+ foo = os.path.join(TEMPDIR, "foo")
+ if not dir:
+ open(foo, "w").close()
+ else:
+ os.mkdir(foo)
+
+ tar = tarfile.open(tmpname, self.mode)
+ try:
+ tar.add(foo, arcname=path)
+ finally:
+ tar.close()
+
+ tar = tarfile.open(tmpname, "r")
+ try:
+ t = tar.next()
+ finally:
+ tar.close()
+
+ if not dir:
+ os.remove(foo)
+ else:
+ os.rmdir(foo)
+
+ self.assertEqual(t.name, cmp_path or path.replace(os.sep, "/"))
+
+ def test_pathnames(self):
+ self._test_pathname("foo")
+ self._test_pathname(os.path.join("foo", ".", "bar"))
+ self._test_pathname(os.path.join("foo", "..", "bar"))
+ self._test_pathname(os.path.join(".", "foo"))
+ self._test_pathname(os.path.join(".", "foo", "."))
+ self._test_pathname(os.path.join(".", "foo", ".", "bar"))
+ self._test_pathname(os.path.join(".", "foo", "..", "bar"))
+ self._test_pathname(os.path.join(".", "foo", "..", "bar"))
+ self._test_pathname(os.path.join("..", "foo"))
+ self._test_pathname(os.path.join("..", "foo", ".."))
+ self._test_pathname(os.path.join("..", "foo", ".", "bar"))
+ self._test_pathname(os.path.join("..", "foo", "..", "bar"))
+
+ self._test_pathname("foo" + os.sep + os.sep + "bar")
+ self._test_pathname("foo" + os.sep + os.sep, "foo", dir=True)
+
+ def test_abs_pathnames(self):
+ if sys.platform == "win32":
+ self._test_pathname("C:\\foo", "foo")
+ else:
+ self._test_pathname("/foo", "foo")
+ self._test_pathname("///foo", "foo")
+
+ def test_cwd(self):
+ # Test adding the current working directory.
+ cwd = os.getcwd()
+ os.chdir(TEMPDIR)
+ try:
+ tar = tarfile.open(tmpname, self.mode)
+ try:
+ tar.add(".")
+ finally:
+ tar.close()
+
+ tar = tarfile.open(tmpname, "r")
+ try:
+ for t in tar:
+ self.assertTrue(t.name == "." or t.name.startswith("./"))
+ finally:
+ tar.close()
+ finally:
+ os.chdir(cwd)
+
class StreamWriteTest(WriteTestBase):
@@ -689,19 +1037,18 @@ class StreamWriteTest(WriteTestBase):
tar.close()
if self.mode.endswith("gz"):
- fobj = gzip.GzipFile(tmpname)
- data = fobj.read()
- fobj.close()
+ with gzip.GzipFile(tmpname) as fobj:
+ data = fobj.read()
elif self.mode.endswith("bz2"):
dec = bz2.BZ2Decompressor()
- data = open(tmpname, "rb").read()
+ with open(tmpname, "rb") as fobj:
+ data = fobj.read()
data = dec.decompress(data)
self.assertTrue(len(dec.unused_data) == 0,
"found trailing data")
else:
- fobj = open(tmpname, "rb")
- data = fobj.read()
- fobj.close()
+ with open(tmpname, "rb") as fobj:
+ data = fobj.read()
self.assertTrue(data.count(b"\0") == tarfile.RECORDSIZE,
"incorrect zero padding")
@@ -756,21 +1103,27 @@ class GNUWriteTest(unittest.TestCase):
tarinfo.type = tarfile.LNKTYPE
tar = tarfile.open(tmpname, "w")
- tar.format = tarfile.GNU_FORMAT
- tar.addfile(tarinfo)
-
- v1 = self._calc_size(name, link)
- v2 = tar.offset
- self.assertTrue(v1 == v2, "GNU longname/longlink creation failed")
+ try:
+ tar.format = tarfile.GNU_FORMAT
+ tar.addfile(tarinfo)
- tar.close()
+ v1 = self._calc_size(name, link)
+ v2 = tar.offset
+ self.assertTrue(v1 == v2, "GNU longname/longlink creation failed")
+ finally:
+ tar.close()
tar = tarfile.open(tmpname)
- member = tar.next()
- self.assertFalse(member is None, "unable to read longname member")
- self.assertTrue(tarinfo.name == member.name and \
- tarinfo.linkname == member.linkname, \
- "unable to read longname member")
+ try:
+ member = tar.next()
+ self.assertIsNotNone(member,
+ "unable to read longname member")
+ self.assertEqual(tarinfo.name, member.name,
+ "unable to read longname member")
+ self.assertEqual(tarinfo.linkname, member.linkname,
+ "unable to read longname member")
+ finally:
+ tar.close()
def test_longname_1023(self):
self._test(("longnam/" * 127) + "longnam")
@@ -810,9 +1163,8 @@ class HardlinkTest(unittest.TestCase):
self.foo = os.path.join(TEMPDIR, "foo")
self.bar = os.path.join(TEMPDIR, "bar")
- fobj = open(self.foo, "wb")
- fobj.write(b"foo")
- fobj.close()
+ with open(self.foo, "wb") as fobj:
+ fobj.write(b"foo")
os.link(self.foo, self.bar)
@@ -821,8 +1173,8 @@ class HardlinkTest(unittest.TestCase):
def tearDown(self):
self.tar.close()
- os.remove(self.foo)
- os.remove(self.bar)
+ support.unlink(self.foo)
+ support.unlink(self.bar)
def test_add_twice(self):
# The same name will be added as a REGTYPE every
@@ -853,16 +1205,21 @@ class PaxWriteTest(GNUWriteTest):
tarinfo.type = tarfile.LNKTYPE
tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT)
- tar.addfile(tarinfo)
- tar.close()
+ try:
+ tar.addfile(tarinfo)
+ finally:
+ tar.close()
tar = tarfile.open(tmpname)
- if link:
- l = tar.getmembers()[0].linkname
- self.assertTrue(link == l, "PAX longlink creation failed")
- else:
- n = tar.getmembers()[0].name
- self.assertTrue(name == n, "PAX longname creation failed")
+ try:
+ if link:
+ l = tar.getmembers()[0].linkname
+ self.assertTrue(link == l, "PAX longlink creation failed")
+ else:
+ n = tar.getmembers()[0].name
+ self.assertTrue(name == n, "PAX longname creation failed")
+ finally:
+ tar.close()
def test_pax_global_header(self):
pax_headers = {
@@ -872,25 +1229,29 @@ class PaxWriteTest(GNUWriteTest):
"test": "\xe4\xf6\xfc",
"\xe4\xf6\xfc": "test"}
- tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, \
+ tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
pax_headers=pax_headers)
- tar.addfile(tarfile.TarInfo("test"))
- tar.close()
+ try:
+ tar.addfile(tarfile.TarInfo("test"))
+ finally:
+ tar.close()
# Test if the global header was written correctly.
tar = tarfile.open(tmpname, encoding="iso8859-1")
- self.assertEqual(tar.pax_headers, pax_headers)
- self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers)
-
- # Test if all the fields are strings.
- for key, val in tar.pax_headers.items():
- self.assertTrue(type(key) is not bytes)
- self.assertTrue(type(val) is not bytes)
- if key in tarfile.PAX_NUMBER_FIELDS:
- try:
- tarfile.PAX_NUMBER_FIELDS[key](val)
- except (TypeError, ValueError):
- self.fail("unable to convert pax header field")
+ try:
+ self.assertEqual(tar.pax_headers, pax_headers)
+ self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers)
+ # Test if all the fields are strings.
+ for key, val in tar.pax_headers.items():
+ self.assertTrue(type(key) is not bytes)
+ self.assertTrue(type(val) is not bytes)
+ if key in tarfile.PAX_NUMBER_FIELDS:
+ try:
+ tarfile.PAX_NUMBER_FIELDS[key](val)
+ except (TypeError, ValueError):
+ self.fail("unable to convert pax header field")
+ finally:
+ tar.close()
def test_pax_extended_header(self):
# The fields from the pax header have priority over the
@@ -898,18 +1259,23 @@ class PaxWriteTest(GNUWriteTest):
pax_headers = {"path": "foo", "uid": "123"}
tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, encoding="iso8859-1")
- t = tarfile.TarInfo()
- t.name = "\xe4\xf6\xfc" # non-ASCII
- t.uid = 8**8 # too large
- t.pax_headers = pax_headers
- tar.addfile(t)
- tar.close()
+ try:
+ t = tarfile.TarInfo()
+ t.name = "\xe4\xf6\xfc" # non-ASCII
+ t.uid = 8**8 # too large
+ t.pax_headers = pax_headers
+ tar.addfile(t)
+ finally:
+ tar.close()
tar = tarfile.open(tmpname, encoding="iso8859-1")
- t = tar.getmembers()[0]
- self.assertEqual(t.pax_headers, pax_headers)
- self.assertEqual(t.name, "foo")
- self.assertEqual(t.uid, 123)
+ try:
+ t = tar.getmembers()[0]
+ self.assertEqual(t.pax_headers, pax_headers)
+ self.assertEqual(t.name, "foo")
+ self.assertEqual(t.uid, 123)
+ finally:
+ tar.close()
class UstarUnicodeTest(unittest.TestCase):
@@ -927,13 +1293,17 @@ class UstarUnicodeTest(unittest.TestCase):
def _test_unicode_filename(self, encoding):
tar = tarfile.open(tmpname, "w", format=self.format, encoding=encoding, errors="strict")
- name = "\xe4\xf6\xfc"
- tar.addfile(tarfile.TarInfo(name))
- tar.close()
+ try:
+ name = "\xe4\xf6\xfc"
+ tar.addfile(tarfile.TarInfo(name))
+ finally:
+ tar.close()
tar = tarfile.open(tmpname, encoding=encoding)
- self.assertEqual(tar.getmembers()[0].name, name)
- tar.close()
+ try:
+ self.assertEqual(tar.getmembers()[0].name, name)
+ finally:
+ tar.close()
def test_unicode_filename_error(self):
if self.format == tarfile.PAX_FORMAT:
@@ -941,23 +1311,28 @@ class UstarUnicodeTest(unittest.TestCase):
return
tar = tarfile.open(tmpname, "w", format=self.format, encoding="ascii", errors="strict")
- tarinfo = tarfile.TarInfo()
+ try:
+ tarinfo = tarfile.TarInfo()
- tarinfo.name = "\xe4\xf6\xfc"
- self.assertRaises(UnicodeError, tar.addfile, tarinfo)
+ tarinfo.name = "\xe4\xf6\xfc"
+ self.assertRaises(UnicodeError, tar.addfile, tarinfo)
- tarinfo.name = "foo"
- tarinfo.uname = "\xe4\xf6\xfc"
- self.assertRaises(UnicodeError, tar.addfile, tarinfo)
+ tarinfo.name = "foo"
+ tarinfo.uname = "\xe4\xf6\xfc"
+ self.assertRaises(UnicodeError, tar.addfile, tarinfo)
+ finally:
+ tar.close()
def test_unicode_argument(self):
tar = tarfile.open(tarname, "r", encoding="iso8859-1", errors="strict")
- for t in tar:
- self.assertTrue(type(t.name) is str)
- self.assertTrue(type(t.linkname) is str)
- self.assertTrue(type(t.uname) is str)
- self.assertTrue(type(t.gname) is str)
- tar.close()
+ try:
+ for t in tar:
+ self.assertTrue(type(t.name) is str)
+ self.assertTrue(type(t.linkname) is str)
+ self.assertTrue(type(t.uname) is str)
+ self.assertTrue(type(t.gname) is str)
+ finally:
+ tar.close()
def test_uname_unicode(self):
t = tarfile.TarInfo("foo")
@@ -965,30 +1340,57 @@ class UstarUnicodeTest(unittest.TestCase):
t.gname = "\xe4\xf6\xfc"
tar = tarfile.open(tmpname, mode="w", format=self.format, encoding="iso8859-1")
- tar.addfile(t)
- tar.close()
+ try:
+ tar.addfile(t)
+ finally:
+ tar.close()
tar = tarfile.open(tmpname, encoding="iso8859-1")
- t = tar.getmember("foo")
- self.assertEqual(t.uname, "\xe4\xf6\xfc")
- self.assertEqual(t.gname, "\xe4\xf6\xfc")
-
- if self.format != tarfile.PAX_FORMAT:
- tar = tarfile.open(tmpname, encoding="ascii")
+ try:
t = tar.getmember("foo")
- self.assertEqual(t.uname, "\ufffd\ufffd\ufffd")
- self.assertEqual(t.gname, "\ufffd\ufffd\ufffd")
+ self.assertEqual(t.uname, "\xe4\xf6\xfc")
+ self.assertEqual(t.gname, "\xe4\xf6\xfc")
+
+ if self.format != tarfile.PAX_FORMAT:
+ tar.close()
+ tar = tarfile.open(tmpname, encoding="ascii")
+ t = tar.getmember("foo")
+ self.assertEqual(t.uname, "\udce4\udcf6\udcfc")
+ self.assertEqual(t.gname, "\udce4\udcf6\udcfc")
+ finally:
+ tar.close()
class GNUUnicodeTest(UstarUnicodeTest):
format = tarfile.GNU_FORMAT
+ def test_bad_pax_header(self):
+ # Test for issue #8633. GNU tar <= 1.23 creates raw binary fields
+ # without a hdrcharset=BINARY header.
+ for encoding, name in (("utf8", "pax/bad-pax-\udce4\udcf6\udcfc"),
+ ("iso8859-1", "pax/bad-pax-\xe4\xf6\xfc"),):
+ with tarfile.open(tarname, encoding=encoding, errors="surrogateescape") as tar:
+ try:
+ t = tar.getmember(name)
+ except KeyError:
+ self.fail("unable to read bad GNU tar pax header")
+
class PAXUnicodeTest(UstarUnicodeTest):
format = tarfile.PAX_FORMAT
+ def test_binary_header(self):
+ # Test a POSIX.1-2008 compatible header with a hdrcharset=BINARY field.
+ for encoding, name in (("utf8", "pax/hdrcharset-\udce4\udcf6\udcfc"),
+ ("iso8859-1", "pax/hdrcharset-\xe4\xf6\xfc"),):
+ with tarfile.open(tarname, encoding=encoding, errors="surrogateescape") as tar:
+ try:
+ t = tar.getmember(name)
+ except KeyError:
+ self.fail("unable to read POSIX.1-2008 binary header")
+
class AppendTest(unittest.TestCase):
# Test append mode (cp. patch #1652681).
@@ -999,41 +1401,43 @@ class AppendTest(unittest.TestCase):
os.remove(self.tarname)
def _add_testfile(self, fileobj=None):
- tar = tarfile.open(self.tarname, "a", fileobj=fileobj)
- tar.addfile(tarfile.TarInfo("bar"))
- tar.close()
+ with tarfile.open(self.tarname, "a", fileobj=fileobj) as tar:
+ tar.addfile(tarfile.TarInfo("bar"))
def _create_testtar(self, mode="w:"):
- src = tarfile.open(tarname, encoding="iso8859-1")
- t = src.getmember("ustar/regtype")
- t.name = "foo"
- f = src.extractfile(t)
- tar = tarfile.open(self.tarname, mode)
- tar.addfile(t, f)
- tar.close()
+ with tarfile.open(tarname, encoding="iso8859-1") as src:
+ t = src.getmember("ustar/regtype")
+ t.name = "foo"
+ f = src.extractfile(t)
+ try:
+ with tarfile.open(self.tarname, mode) as tar:
+ tar.addfile(t, f)
+ finally:
+ f.close()
def _test(self, names=["bar"], fileobj=None):
- tar = tarfile.open(self.tarname, fileobj=fileobj)
- self.assertEqual(tar.getnames(), names)
+ with tarfile.open(self.tarname, fileobj=fileobj) as tar:
+ self.assertEqual(tar.getnames(), names)
def test_non_existing(self):
self._add_testfile()
self._test()
def test_empty(self):
- open(self.tarname, "w").close()
+ tarfile.open(self.tarname, "w:").close()
self._add_testfile()
self._test()
def test_empty_fileobj(self):
- fobj = io.BytesIO()
+ fobj = io.BytesIO(b"\0" * 1024)
self._add_testfile(fobj)
fobj.seek(0)
self._test(fileobj=fobj)
def test_fileobj(self):
self._create_testtar()
- data = open(self.tarname, "rb").read()
+ with open(self.tarname, "rb") as fobj:
+ data = fobj.read()
fobj = io.BytesIO(data)
self._add_testfile(fobj)
fobj.seek(0)
@@ -1056,6 +1460,30 @@ class AppendTest(unittest.TestCase):
self._create_testtar("w:bz2")
self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, "a")
+ # Append mode is supposed to fail if the tarfile to append to
+ # does not end with a zero block.
+ def _test_error(self, data):
+ with open(self.tarname, "wb") as fobj:
+ fobj.write(data)
+ self.assertRaises(tarfile.ReadError, self._add_testfile)
+
+ def test_null(self):
+ self._test_error(b"")
+
+ def test_incomplete(self):
+ self._test_error(b"\0" * 13)
+
+ def test_premature_eof(self):
+ data = tarfile.TarInfo("foo").tobuf()
+ self._test_error(data)
+
+ def test_trailing_garbage(self):
+ data = tarfile.TarInfo("foo").tobuf()
+ self._test_error(data + b"\0" * 13)
+
+ def test_invalid(self):
+ self._test_error(b"a" * 512)
+
class LimitsTest(unittest.TestCase):
@@ -1129,6 +1557,98 @@ class MiscTest(unittest.TestCase):
self.assertEqual(tarfile.itn(0xffffffff), b"\x80\x00\x00\x00\xff\xff\xff\xff")
+class ContextManagerTest(unittest.TestCase):
+
+ def test_basic(self):
+ with tarfile.open(tarname) as tar:
+ self.assertFalse(tar.closed, "closed inside runtime context")
+ self.assertTrue(tar.closed, "context manager failed")
+
+ def test_closed(self):
+ # The __enter__() method is supposed to raise IOError
+ # if the TarFile object is already closed.
+ tar = tarfile.open(tarname)
+ tar.close()
+ with self.assertRaises(IOError):
+ with tar:
+ pass
+
+ def test_exception(self):
+ # Test if the IOError exception is passed through properly.
+ with self.assertRaises(Exception) as exc:
+ with tarfile.open(tarname) as tar:
+ raise IOError
+ self.assertIsInstance(exc.exception, IOError,
+ "wrong exception raised in context manager")
+ self.assertTrue(tar.closed, "context manager failed")
+
+ def test_no_eof(self):
+ # __exit__() must not write end-of-archive blocks if an
+ # exception was raised.
+ try:
+ with tarfile.open(tmpname, "w") as tar:
+ raise Exception
+ except:
+ pass
+ self.assertEqual(os.path.getsize(tmpname), 0,
+ "context manager wrote an end-of-archive block")
+ self.assertTrue(tar.closed, "context manager failed")
+
+ def test_eof(self):
+ # __exit__() must write end-of-archive blocks, i.e. call
+ # TarFile.close() if there was no error.
+ with tarfile.open(tmpname, "w"):
+ pass
+ self.assertNotEqual(os.path.getsize(tmpname), 0,
+ "context manager wrote no end-of-archive block")
+
+ def test_fileobj(self):
+ # Test that __exit__() did not close the external file
+ # object.
+ with open(tmpname, "wb") as fobj:
+ try:
+ with tarfile.open(fileobj=fobj, mode="w") as tar:
+ raise Exception
+ except:
+ pass
+ self.assertFalse(fobj.closed, "external file object was closed")
+ self.assertTrue(tar.closed, "context manager failed")
+
+
+class LinkEmulationTest(ReadTest):
+
+ # Test for issue #8741 regression. On platforms that do not support
+ # symbolic or hard links tarfile tries to extract these types of members as
+ # the regular files they point to.
+ def _test_link_extraction(self, name):
+ self.tar.extract(name, TEMPDIR)
+ data = open(os.path.join(TEMPDIR, name), "rb").read()
+ self.assertEqual(md5sum(data), md5_regtype)
+
+ # When 8879 gets fixed, this will need to change. Currently on Windows
+ # we have os.path.islink but no os.link, so these tests fail without the
+ # following skip until link is completed.
+ @unittest.skipIf(hasattr(os.path, "islink"),
+ "Skip emulation - has os.path.islink but not os.link")
+ def test_hardlink_extraction1(self):
+ self._test_link_extraction("ustar/lnktype")
+
+ @unittest.skipIf(hasattr(os.path, "islink"),
+ "Skip emulation - has os.path.islink but not os.link")
+ def test_hardlink_extraction2(self):
+ self._test_link_extraction("./ustar/linktest2/lnktype")
+
+ @unittest.skipIf(hasattr(os, "symlink"),
+ "Skip emulation if symlink exists")
+ def test_symlink_extraction1(self):
+ self._test_link_extraction("ustar/symtype")
+
+ @unittest.skipIf(hasattr(os, "symlink"),
+ "Skip emulation if symlink exists")
+ def test_symlink_extraction2(self):
+ self._test_link_extraction("./ustar/linktest2/symtype")
+
+
class GzipMiscReadTest(MiscReadTest):
tarname = gzipname
mode = "r:gz"
@@ -1170,10 +1690,16 @@ class Bz2PartialReadTest(unittest.TestCase):
raise AssertionError("infinite loop detected in tarfile.open()")
self.hit_eof = self.tell() == len(self.getvalue())
return super(MyBytesIO, self).read(n)
+ def seek(self, *args):
+ self.hit_eof = False
+ return super(MyBytesIO, self).seek(*args)
data = bz2.compress(tarfile.TarInfo("foo").tobuf())
for x in range(len(data) + 1):
- tarfile.open(fileobj=MyBytesIO(data[:x]), mode=mode)
+ try:
+ tarfile.open(fileobj=MyBytesIO(data[:x]), mode=mode)
+ except tarfile.ReadError:
+ pass # we have no interest in ReadErrors
def test_partial_input(self):
self._test_partial_input("r")
@@ -1183,6 +1709,7 @@ class Bz2PartialReadTest(unittest.TestCase):
def test_main():
+ support.unlink(TEMPDIR)
os.makedirs(TEMPDIR)
tests = [
@@ -1203,20 +1730,22 @@ def test_main():
AppendTest,
LimitsTest,
MiscTest,
+ ContextManagerTest,
]
if hasattr(os, "link"):
tests.append(HardlinkTest)
+ else:
+ tests.append(LinkEmulationTest)
- fobj = open(tarname, "rb")
- data = fobj.read()
- fobj.close()
+ with open(tarname, "rb") as fobj:
+ data = fobj.read()
if gzip:
# Create testtar.tar.gz and add gzip-specific tests.
- tar = gzip.open(gzipname, "wb")
- tar.write(data)
- tar.close()
+ support.unlink(gzipname)
+ with gzip.open(gzipname, "wb") as tar:
+ tar.write(data)
tests += [
GzipMiscReadTest,
@@ -1228,9 +1757,12 @@ def test_main():
if bz2:
# Create testtar.tar.bz2 and add bz2-specific tests.
+ support.unlink(bz2name)
tar = bz2.BZ2File(bz2name, "wb")
- tar.write(data)
- tar.close()
+ try:
+ tar.write(data)
+ finally:
+ tar.close()
tests += [
Bz2MiscReadTest,
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index 632d5e3b50..d86246cbfb 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -1,6 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
+import sys
import os
from test import support
@@ -127,21 +128,20 @@ class TclTest(unittest.TestCase):
tcl = self.interp
self.assertRaises(TclError,tcl.eval,'package require DNE')
+ @unittest.skipUnless(sys.platform == 'win32', 'Requires Windows')
def testLoadWithUNC(self):
- import sys
- if sys.platform != 'win32':
- return
-
# Build a UNC path from the regular path.
# Something like
# \\%COMPUTERNAME%\c$\python27\python.exe
fullname = os.path.abspath(sys.executable)
if fullname[1] != ':':
- return
+ raise unittest.SkipTest('Absolute path should have drive part')
unc_name = r'\\%s\%s$\%s' % (os.environ['COMPUTERNAME'],
fullname[0],
fullname[3:])
+ if not os.path.exists(unc_name):
+ raise unittest.SkipTest('Cannot connect to UNC Path')
with support.EnvironmentVarGuard() as env:
env.unset("TCL_LIBRARY")
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index c1eea06571..a78b938b86 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -1,12 +1,12 @@
import socket
import select
-import threading
import telnetlib
import time
import contextlib
from unittest import TestCase
from test import support
+threading = support.import_module('threading')
HOST = support.HOST
@@ -17,9 +17,10 @@ def server(evt, serv):
conn, addr = serv.accept()
except socket.timeout:
pass
+ else:
+ conn.close()
finally:
serv.close()
- conn.close()
evt.set()
class GeneralTests(TestCase):
@@ -285,7 +286,7 @@ class OptionTests(TestCase):
txt = telnet.read_all()
cmd = nego.seen
self.assertTrue(len(cmd) > 0) # we expect at least one command
- self.assertTrue(cmd[:1] in self.cmds)
+ self.assertIn(cmd[:1], self.cmds)
self.assertEqual(cmd[1:2], tl.NOOPT)
self.assertEqual(data_len, len(txt + cmd))
nego.sb_getter = None # break the nego => telnet cycle
@@ -332,7 +333,7 @@ class OptionTests(TestCase):
telnet = test_telnet([a])
telnet.set_debuglevel(1)
txt = telnet.read_all()
- self.assertTrue(b in telnet._messages)
+ self.assertIn(b, telnet._messages)
return
def test_debuglevel_write(self):
@@ -340,7 +341,7 @@ class OptionTests(TestCase):
telnet.set_debuglevel(1)
telnet.write(b'xxx')
expected = "send b'xxx'\n"
- self.assertTrue(expected in telnet._messages)
+ self.assertIn(expected, telnet._messages)
def test_debug_accepts_str_port(self):
# Issue 10695
@@ -349,7 +350,7 @@ class OptionTests(TestCase):
telnet._messages = ''
telnet.set_debuglevel(1)
telnet.msg('test')
- self.assertRegexpMatches(telnet._messages, r'0.*test')
+ self.assertRegex(telnet._messages, r'0.*test')
def test_main(verbose=None):
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index f72b0b19c4..2d298857b2 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -3,15 +3,11 @@ import tempfile
import os
import sys
import re
-import errno
import warnings
import unittest
from test import support
-warnings.filterwarnings("ignore",
- category=RuntimeWarning,
- message="mktemp", module=__name__)
if hasattr(os, 'stat'):
import stat
@@ -24,9 +20,7 @@ has_spawnl = hasattr(os, 'spawnl')
# TEST_FILES may need to be tweaked for systems depending on the maximum
# number of files that can be opened at one time (see ulimit -n)
-if sys.platform == 'mac':
- TEST_FILES = 32
-elif sys.platform in ('openbsd3', 'openbsd4'):
+if sys.platform in ('openbsd3', 'openbsd4'):
TEST_FILES = 48
else:
TEST_FILES = 100
@@ -40,6 +34,16 @@ class TC(unittest.TestCase):
str_check = re.compile(r"[a-zA-Z0-9_-]{6}$")
+ def setUp(self):
+ self._warnings_manager = support.check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings("ignore", category=RuntimeWarning,
+ message="mktemp", module=__name__)
+
+ def tearDown(self):
+ self._warnings_manager.__exit__(None, None, None)
+
+
def failOnException(self, what, ei=None):
if ei is None:
ei = sys.exc_info()
@@ -81,7 +85,8 @@ class test_exports(TC):
"gettempdir" : 1,
"tempdir" : 1,
"template" : 1,
- "SpooledTemporaryFile" : 1
+ "SpooledTemporaryFile" : 1,
+ "TemporaryDirectory" : 1,
}
unexp = []
@@ -99,6 +104,7 @@ class test__RandomNameSequence(TC):
def setUp(self):
self.r = tempfile._RandomNameSequence()
+ super().setUp()
def test_get_six_char_str(self):
# _RandomNameSequence returns a six-character string
@@ -113,7 +119,7 @@ class test__RandomNameSequence(TC):
for i in range(TEST_FILES):
s = next(r)
self.nameCheck(s, '', '', '')
- self.assertFalse(s in dict)
+ self.assertNotIn(s, dict)
dict[s] = 1
def supports_iter(self):
@@ -127,7 +133,7 @@ class test__RandomNameSequence(TC):
if i == 20:
break
except:
- failOnException("iteration")
+ self.failOnException("iteration")
test_classes.append(test__RandomNameSequence)
@@ -142,8 +148,7 @@ class test__candidate_tempdir_list(TC):
self.assertFalse(len(cand) == 0)
for c in cand:
- self.assertTrue(isinstance(c, str),
- "%s is not a string" % c)
+ self.assertIsInstance(c, str)
def test_wanted_dirs(self):
# _candidate_tempdir_list contains the expected directories
@@ -160,14 +165,14 @@ class test__candidate_tempdir_list(TC):
for envname in 'TMPDIR', 'TEMP', 'TMP':
dirname = os.getenv(envname)
if not dirname: raise ValueError
- self.assertTrue(dirname in cand)
+ self.assertIn(dirname, cand)
try:
dirname = os.getcwd()
except (AttributeError, os.error):
dirname = os.curdir
- self.assertTrue(dirname in cand)
+ self.assertIn(dirname, cand)
# Not practical to try to verify the presence of OS-specific
# paths in this list.
@@ -184,7 +189,7 @@ class test__get_candidate_names(TC):
def test_retval(self):
# _get_candidate_names returns a _RandomNameSequence object
obj = tempfile._get_candidate_names()
- self.assertTrue(isinstance(obj, tempfile._RandomNameSequence))
+ self.assertIsInstance(obj, tempfile._RandomNameSequence)
def test_same_thing(self):
# _get_candidate_names always returns the same object
@@ -259,7 +264,7 @@ class test__mkstemp_inner(TC):
file = self.do_create()
mode = stat.S_IMODE(os.stat(file.name).st_mode)
expected = 0o600
- if sys.platform in ('win32', 'os2emx', 'mac'):
+ if sys.platform in ('win32', 'os2emx'):
# There's no distinction among 'user', 'group' and 'world';
# replicate the 'user' bits.
user = expected >> 6
@@ -326,7 +331,7 @@ class test_gettempprefix(TC):
# gettempprefix returns a nonempty prefix string
p = tempfile.gettempprefix()
- self.assertTrue(isinstance(p, str))
+ self.assertIsInstance(p, str)
self.assertTrue(len(p) > 0)
def test_usable_template(self):
@@ -482,7 +487,7 @@ class test_mkdtemp(TC):
mode = stat.S_IMODE(os.stat(dir).st_mode)
mode &= 0o777 # Mask off sticky bits inherited from /tmp
expected = 0o700
- if sys.platform in ('win32', 'os2emx', 'mac'):
+ if sys.platform in ('win32', 'os2emx'):
# There's no distinction among 'user', 'group' and 'world';
# replicate the 'user' bits.
user = expected >> 6
@@ -501,11 +506,13 @@ class test_mktemp(TC):
# We must also suppress the RuntimeWarning it generates.
def setUp(self):
self.dir = tempfile.mkdtemp()
+ super().setUp()
def tearDown(self):
if self.dir:
os.rmdir(self.dir)
self.dir = None
+ super().tearDown()
class mktemped:
_unlink = os.unlink
@@ -900,6 +907,152 @@ class test_TemporaryFile(TC):
if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile:
test_classes.append(test_TemporaryFile)
+
+# Helper for test_del_on_shutdown
+class NulledModules:
+ def __init__(self, *modules):
+ self.refs = [mod.__dict__ for mod in modules]
+ self.contents = [ref.copy() for ref in self.refs]
+
+ def __enter__(self):
+ for d in self.refs:
+ for key in d:
+ d[key] = None
+
+ def __exit__(self, *exc_info):
+ for d, c in zip(self.refs, self.contents):
+ d.clear()
+ d.update(c)
+
+class test_TemporaryDirectory(TC):
+ """Test TemporaryDirectory()."""
+
+ def do_create(self, dir=None, pre="", suf="", recurse=1):
+ if dir is None:
+ dir = tempfile.gettempdir()
+ try:
+ tmp = tempfile.TemporaryDirectory(dir=dir, prefix=pre, suffix=suf)
+ except:
+ self.failOnException("TemporaryDirectory")
+ self.nameCheck(tmp.name, dir, pre, suf)
+ # Create a subdirectory and some files
+ if recurse:
+ self.do_create(tmp.name, pre, suf, recurse-1)
+ with open(os.path.join(tmp.name, "test.txt"), "wb") as f:
+ f.write(b"Hello world!")
+ return tmp
+
+ def test_mkdtemp_failure(self):
+ # Check no additional exception if mkdtemp fails
+ # Previously would raise AttributeError instead
+ # (noted as part of Issue #10188)
+ with tempfile.TemporaryDirectory() as nonexistent:
+ pass
+ with self.assertRaises(os.error):
+ tempfile.TemporaryDirectory(dir=nonexistent)
+
+ def test_explicit_cleanup(self):
+ # A TemporaryDirectory is deleted when cleaned up
+ dir = tempfile.mkdtemp()
+ try:
+ d = self.do_create(dir=dir)
+ self.assertTrue(os.path.exists(d.name),
+ "TemporaryDirectory %s does not exist" % d.name)
+ d.cleanup()
+ self.assertFalse(os.path.exists(d.name),
+ "TemporaryDirectory %s exists after cleanup" % d.name)
+ finally:
+ os.rmdir(dir)
+
+ @support.cpython_only
+ def test_del_on_collection(self):
+ # A TemporaryDirectory is deleted when garbage collected
+ dir = tempfile.mkdtemp()
+ try:
+ d = self.do_create(dir=dir)
+ name = d.name
+ del d # Rely on refcounting to invoke __del__
+ self.assertFalse(os.path.exists(name),
+ "TemporaryDirectory %s exists after __del__" % name)
+ finally:
+ os.rmdir(dir)
+
+ @unittest.expectedFailure # See issue #10188
+ def test_del_on_shutdown(self):
+ # A TemporaryDirectory may be cleaned up during shutdown
+ # Make sure it works with the relevant modules nulled out
+ with self.do_create() as dir:
+ d = self.do_create(dir=dir)
+ # Mimic the nulling out of modules that
+ # occurs during system shutdown
+ modules = [os, os.path]
+ if has_stat:
+ modules.append(stat)
+ # Currently broken, so suppress the warning
+ # that is otherwise emitted on stdout
+ with support.captured_stderr() as err:
+ with NulledModules(*modules):
+ d.cleanup()
+ # Currently broken, so stop spurious exception by
+ # indicating the object has already been closed
+ d._closed = True
+ # And this assert will fail, as expected by the
+ # unittest decorator...
+ self.assertFalse(os.path.exists(d.name),
+ "TemporaryDirectory %s exists after cleanup" % d.name)
+
+ def test_warnings_on_cleanup(self):
+ # Two kinds of warning on shutdown
+ # Issue 10888: may write to stderr if modules are nulled out
+ # ResourceWarning will be triggered by __del__
+ with self.do_create() as dir:
+ if os.sep != '\\':
+ # Embed a backslash in order to make sure string escaping
+ # in the displayed error message is dealt with correctly
+ suffix = '\\check_backslash_handling'
+ else:
+ suffix = ''
+ d = self.do_create(dir=dir, suf=suffix)
+
+ #Check for the Issue 10888 message
+ modules = [os, os.path]
+ if has_stat:
+ modules.append(stat)
+ with support.captured_stderr() as err:
+ with NulledModules(*modules):
+ d.cleanup()
+ message = err.getvalue().replace('\\\\', '\\')
+ self.assertIn("while cleaning up", message)
+ self.assertIn(d.name, message)
+
+ # Check for the resource warning
+ with support.check_warnings(('Implicitly', ResourceWarning), quiet=False):
+ warnings.filterwarnings("always", category=ResourceWarning)
+ d.__del__()
+ self.assertFalse(os.path.exists(d.name),
+ "TemporaryDirectory %s exists after __del__" % d.name)
+
+ def test_multiple_close(self):
+ # Can be cleaned-up many times without error
+ d = self.do_create()
+ d.cleanup()
+ try:
+ d.cleanup()
+ d.cleanup()
+ except:
+ self.failOnException("cleanup")
+
+ def test_context_manager(self):
+ # Can be used as a context manager
+ d = self.do_create()
+ with d as name:
+ self.assertTrue(os.path.exists(name))
+ self.assertEqual(name, d.name)
+ self.assertFalse(os.path.exists(name))
+
+
+test_classes.append(test_TemporaryDirectory)
+
def test_main():
support.run_unittest(*test_classes)
diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py
index a86f86bd5f..894a49392e 100644
--- a/Lib/test/test_thread.py
+++ b/Lib/test/test_thread.py
@@ -2,8 +2,10 @@ import os
import unittest
import random
from test import support
-import _thread as thread
+thread = support.import_module('_thread')
import time
+import sys
+import weakref
from test import lock_tests
@@ -61,7 +63,7 @@ class ThreadRunningTests(BasicThreadTest):
def test_stack_size(self):
# Various stack size tests.
- self.assertEqual(thread.stack_size(), 0, "intial stack size is not 0")
+ self.assertEqual(thread.stack_size(), 0, "initial stack size is not 0")
thread.stack_size(0)
self.assertEqual(thread.stack_size(), 0, "stack_size not reset to default")
@@ -100,6 +102,32 @@ class ThreadRunningTests(BasicThreadTest):
thread.stack_size(0)
+ def test__count(self):
+ # Test the _count() function.
+ orig = thread._count()
+ mut = thread.allocate_lock()
+ mut.acquire()
+ started = []
+ def task():
+ started.append(None)
+ mut.acquire()
+ mut.release()
+ thread.start_new_thread(task, ())
+ while not started:
+ time.sleep(0.01)
+ self.assertEqual(thread._count(), orig + 1)
+ # Allow the task to finish.
+ mut.release()
+ # The only reliable way to be sure that the thread ended from the
+ # interpreter's point of view is to wait for the function object to be
+ # destroyed.
+ done = []
+ wr = weakref.ref(task, lambda _: done.append(None))
+ del task
+ while not done:
+ time.sleep(0.01)
+ self.assertEqual(thread._count(), orig)
+
class Barrier:
def __init__(self, num_threads):
@@ -166,8 +194,48 @@ class LockTests(lock_tests.LockTests):
locktype = thread.allocate_lock
+class TestForkInThread(unittest.TestCase):
+ def setUp(self):
+ self.read_fd, self.write_fd = os.pipe()
+
+ @unittest.skipIf(sys.platform.startswith('win'),
+ "This test is only appropriate for POSIX-like systems.")
+ @support.reap_threads
+ def test_forkinthread(self):
+ def thread1():
+ try:
+ pid = os.fork() # fork in a thread
+ except RuntimeError:
+ os._exit(1) # exit the child
+
+ if pid == 0: # child
+ try:
+ os.close(self.read_fd)
+ os.write(self.write_fd, b"OK")
+ finally:
+ os._exit(0)
+ else: # parent
+ os.close(self.write_fd)
+
+ thread.start_new_thread(thread1, ())
+ self.assertEqual(os.read(self.read_fd, 2), b"OK",
+ "Unable to fork() in thread")
+
+ def tearDown(self):
+ try:
+ os.close(self.read_fd)
+ except OSError:
+ pass
+
+ try:
+ os.close(self.write_fd)
+ except OSError:
+ pass
+
+
def test_main():
- support.run_unittest(ThreadRunningTests, BarrierTest, LockTests)
+ support.run_unittest(ThreadRunningTests, BarrierTest, LockTests,
+ TestForkInThread)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py
index e4d1882eae..7791935fdf 100644
--- a/Lib/test/test_threaded_import.py
+++ b/Lib/test/test_threaded_import.py
@@ -10,10 +10,6 @@ import imp
import sys
import time
import shutil
-# HACK: preloading tempfile is necessary to avoid failures when test_tempfile
-# is run after test_threaded_import. This has to do with dark secrets of
-# the import machinery and phantom copies of the random module.
-import tempfile
import unittest
from test.support import verbose, import_module, run_unittest, TESTFN
thread = import_module('_thread')
diff --git a/Lib/test/test_threadedtempfile.py b/Lib/test/test_threadedtempfile.py
index 745c6022ed..2dfd3a08db 100644
--- a/Lib/test/test_threadedtempfile.py
+++ b/Lib/test/test_threadedtempfile.py
@@ -16,11 +16,10 @@ provoking a 2.0 failure under Linux.
NUM_THREADS = 20
FILES_PER_THREAD = 50
-import _thread as thread # If this fails, we can't test this module
-import threading
import tempfile
-from test.support import threading_setup, threading_cleanup, run_unittest
+from test.support import threading_setup, threading_cleanup, run_unittest, import_module
+threading = import_module('threading')
import unittest
import io
from traceback import print_exc
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index f977a7fbbe..5f99b2ea9f 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -1,16 +1,16 @@
# Very rudimentary test of threading module
import test.support
-from test.support import verbose
-import os
+from test.support import verbose, strip_python_stderr
import random
import re
import sys
-import threading
-import _thread
+_thread = test.support.import_module('_thread')
+threading = test.support.import_module('threading')
import time
import unittest
import weakref
+import os
import subprocess
from test import lock_tests
@@ -59,7 +59,16 @@ class TestThread(threading.Thread):
(self.name, self.nrunning.get()))
-class ThreadTests(unittest.TestCase):
+class BaseTestCase(unittest.TestCase):
+ def setUp(self):
+ self._threads = test.support.threading_setup()
+
+ def tearDown(self):
+ test.support.threading_cleanup(*self._threads)
+ test.support.reap_children()
+
+
+class ThreadTests(BaseTestCase):
# Create a bunch of threads, let each do some work, wait until all are
# done.
@@ -89,7 +98,8 @@ class ThreadTests(unittest.TestCase):
self.assertTrue(not t.is_alive())
self.assertNotEqual(t.ident, 0)
self.assertFalse(t.ident is None)
- self.assertTrue(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
+ self.assertTrue(re.match('<TestThread\(.*, stopped -?\d+\)>',
+ repr(t)))
if verbose:
print('all tasks done')
self.assertEqual(numrunning.get(), 0)
@@ -115,9 +125,8 @@ class ThreadTests(unittest.TestCase):
try:
threading.stack_size(262144)
except _thread.error:
- if verbose:
- print('platform does not support changing thread stack size')
- return
+ raise unittest.SkipTest(
+ 'platform does not support changing thread stack size')
self.test_various_ops()
threading.stack_size(0)
@@ -128,9 +137,8 @@ class ThreadTests(unittest.TestCase):
try:
threading.stack_size(0x100000)
except _thread.error:
- if verbose:
- print('platform does not support changing thread stack size')
- return
+ raise unittest.SkipTest(
+ 'platform does not support changing thread stack size')
self.test_various_ops()
threading.stack_size(0)
@@ -147,9 +155,8 @@ class ThreadTests(unittest.TestCase):
tid = _thread.start_new_thread(f, (mutex,))
# Wait for the thread to finish.
mutex.acquire()
- self.assertTrue(tid in threading._active)
- self.assertTrue(isinstance(threading._active[tid],
- threading._DummyThread))
+ self.assertIn(tid, threading._active)
+ self.assertIsInstance(threading._active[tid], threading._DummyThread)
del threading._active[tid]
# PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently)
@@ -158,9 +165,7 @@ class ThreadTests(unittest.TestCase):
try:
import ctypes
except ImportError:
- if verbose:
- print("test_PyThreadState_SetAsyncExc can't import ctypes")
- return # can't do anything
+ raise unittest.SkipTest("cannot import ctypes")
set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc
@@ -169,6 +174,27 @@ class ThreadTests(unittest.TestCase):
exception = ctypes.py_object(AsyncExc)
+ # First check it works when setting the exception from the same thread.
+ tid = _thread.get_ident()
+
+ try:
+ result = set_async_exc(ctypes.c_long(tid), exception)
+ # The exception is async, so we might have to keep the VM busy until
+ # it notices.
+ while True:
+ pass
+ except AsyncExc:
+ pass
+ else:
+ # This code is unreachable but it reflects the intent. If we wanted
+ # to be smarter the above loop wouldn't be infinite.
+ self.fail("AsyncExc not raised")
+ try:
+ self.assertEqual(result, 1) # one thread state modified
+ except UnboundLocalError:
+ # The exception was raised too quickly for us to get the result.
+ pass
+
# `worker_started` is set by the thread when it's inside a try/except
# block waiting to catch the asynchronously set AsyncExc exception.
# `worker_saw_exception` is set by the thread upon catching that
@@ -245,9 +271,7 @@ class ThreadTests(unittest.TestCase):
try:
import ctypes
except ImportError:
- if verbose:
- print("test_finalize_with_runnning_thread can't import ctypes")
- return # can't do anything
+ raise unittest.SkipTest("cannot import ctypes")
rc = subprocess.call([sys.executable, "-c", """if 1:
import ctypes, sys, time, _thread
@@ -302,6 +326,8 @@ class ThreadTests(unittest.TestCase):
"""],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
stdout, stderr = p.communicate()
rc = p.returncode
self.assertFalse(rc == 2, "interpreted was blocked")
@@ -326,30 +352,30 @@ class ThreadTests(unittest.TestCase):
"""],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
stdout, stderr = p.communicate()
self.assertEqual(stdout.strip(),
b"Woke up, sleep function is: <built-in function sleep>")
- stderr = re.sub(br"^\[\d+ refs\]", b"", stderr, re.MULTILINE).strip()
+ stderr = strip_python_stderr(stderr)
self.assertEqual(stderr, b"")
def test_enumerate_after_join(self):
# Try hard to trigger #1703448: a thread is still returned in
# threading.enumerate() after it has been join()ed.
enum = threading.enumerate
- old_interval = sys.getcheckinterval()
+ old_interval = sys.getswitchinterval()
try:
for i in range(1, 100):
- # Try a couple times at each thread-switching interval
- # to get more interleavings.
- sys.setcheckinterval(i // 5)
+ sys.setswitchinterval(i * 0.0002)
t = threading.Thread(target=lambda: None)
t.start()
t.join()
l = enum()
- self.assertFalse(t in l,
+ self.assertNotIn(t, l,
"#1703448 triggered after %d trials: %s" % (i, l))
finally:
- sys.setcheckinterval(old_interval)
+ sys.setswitchinterval(old_interval)
def test_no_refcycle_through_target(self):
class RunSelfFunction(object):
@@ -370,7 +396,7 @@ class ThreadTests(unittest.TestCase):
weak_cyclic_object = weakref.ref(cyclic_object)
cyclic_object.thread.join()
del cyclic_object
- self.assertEqual(None, weak_cyclic_object(),
+ self.assertIsNone(weak_cyclic_object(),
msg=('%d references still around' %
sys.getrefcount(weak_cyclic_object())))
@@ -378,7 +404,7 @@ class ThreadTests(unittest.TestCase):
weak_raising_cyclic_object = weakref.ref(raising_cyclic_object)
raising_cyclic_object.thread.join()
del raising_cyclic_object
- self.assertEqual(None, weak_raising_cyclic_object(),
+ self.assertIsNone(weak_raising_cyclic_object(),
msg=('%d references still around' %
sys.getrefcount(weak_raising_cyclic_object())))
@@ -395,8 +421,14 @@ class ThreadTests(unittest.TestCase):
e.isSet()
threading.activeCount()
+ def test_repr_daemon(self):
+ t = threading.Thread()
+ self.assertFalse('daemon' in repr(t))
+ t.daemon = True
+ self.assertTrue('daemon' in repr(t))
+
-class ThreadJoinOnShutdown(unittest.TestCase):
+class ThreadJoinOnShutdown(BaseTestCase):
def _run_and_join(self, script):
script = """if 1:
@@ -432,11 +464,9 @@ class ThreadJoinOnShutdown(unittest.TestCase):
self._run_and_join(script)
+ @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
def test_2_join_in_forked_process(self):
# Like the test above, but from a forked interpreter
- import os
- if not hasattr(os, 'fork'):
- return
script = """if 1:
childpid = os.fork()
if childpid != 0:
@@ -450,19 +480,16 @@ class ThreadJoinOnShutdown(unittest.TestCase):
"""
self._run_and_join(script)
+ @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
def test_3_join_in_forked_from_thread(self):
# Like the test above, but fork() was called from a worker thread
# In the forked process, the main Thread object must be marked as stopped.
- import os
- if not hasattr(os, 'fork'):
- return
+
# Skip platforms with known problems forking from a worker thread.
# See http://bugs.python.org/issue3863.
if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5',
'os2emx'):
- print('Skipping test_3_join_in_forked_from_thread'
- ' due to known OS bugs on', sys.platform, file=sys.stderr)
- return
+ raise unittest.SkipTest('due to known OS bugs on ' + sys.platform)
script = """if 1:
main_thread = threading.current_thread()
def worker():
@@ -485,9 +512,9 @@ class ThreadJoinOnShutdown(unittest.TestCase):
def assertScriptHasOutput(self, script, expected_output):
p = subprocess.Popen([sys.executable, "-c", script],
stdout=subprocess.PIPE)
- rc = p.wait()
- data = p.stdout.read().decode().replace('\r', '')
- self.assertEqual(rc, 0, "Unexpected error")
+ stdout, stderr = p.communicate()
+ data = stdout.decode().replace('\r', '')
+ self.assertEqual(p.returncode, 0, "Unexpected error")
self.assertEqual(data, expected_output)
@unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
@@ -629,7 +656,7 @@ class ThreadJoinOnShutdown(unittest.TestCase):
self.assertScriptHasOutput(script, output)
-class ThreadingExceptionTests(unittest.TestCase):
+class ThreadingExceptionTests(BaseTestCase):
# A RuntimeError should be raised if Thread.start() is called
# multiple times.
def test_start_thread_again(self):
@@ -654,8 +681,11 @@ class ThreadingExceptionTests(unittest.TestCase):
class LockTests(lock_tests.LockTests):
locktype = staticmethod(threading.Lock)
-class RLockTests(lock_tests.RLockTests):
- locktype = staticmethod(threading.RLock)
+class PyRLockTests(lock_tests.RLockTests):
+ locktype = staticmethod(threading._PyRLock)
+
+class CRLockTests(lock_tests.RLockTests):
+ locktype = staticmethod(threading._CRLock)
class EventTests(lock_tests.EventTests):
eventtype = staticmethod(threading.Event)
@@ -673,14 +703,17 @@ class SemaphoreTests(lock_tests.SemaphoreTests):
class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests):
semtype = staticmethod(threading.BoundedSemaphore)
+class BarrierTests(lock_tests.BarrierTests):
+ barriertype = staticmethod(threading.Barrier)
def test_main():
- test.support.run_unittest(LockTests, RLockTests, EventTests,
+ test.support.run_unittest(LockTests, PyRLockTests, CRLockTests, EventTests,
ConditionAsRLockTests, ConditionTests,
SemaphoreTests, BoundedSemaphoreTests,
ThreadTests,
ThreadJoinOnShutdown,
ThreadingExceptionTests,
+ BarrierTests
)
if __name__ == "__main__":
diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py
index c9d0fddf2f..c886a25d8a 100644
--- a/Lib/test/test_threading_local.py
+++ b/Lib/test/test_threading_local.py
@@ -46,7 +46,7 @@ class BaseLocalTest:
local.someothervar = None
gc.collect()
deadlist = [weak for weak in weaklist if weak() is None]
- self.assertTrue(len(deadlist) in (n-1, n), (n, len(deadlist)))
+ self.assertIn(len(deadlist), (n-1, n), (n, len(deadlist)))
def test_derived(self):
# Issue 3088: if there is a threads switch inside the __init__
@@ -112,6 +112,17 @@ class BaseLocalTest:
self.assertTrue(passed)
+ def test_arguments(self):
+ # Issue 1522237
+ class MyLocal(self._local):
+ def __init__(self, *args, **kwargs):
+ pass
+
+ MyLocal(a=1)
+ MyLocal(1)
+ self.assertRaises(TypeError, self._local, a=1)
+ self.assertRaises(TypeError, self._local, 1)
+
def _test_one_class(self, c):
self._failed = "No error message set or cleared."
obj = c()
@@ -173,11 +184,6 @@ class BaseLocalTest:
"""To test that subclasses behave properly."""
self._test_dict_attribute(LocalSubclass)
-
-class ThreadLocalTest(unittest.TestCase, BaseLocalTest):
- _local = _thread._local
-
- # Fails for the pure Python implementation
def test_cycle_collection(self):
class X:
pass
@@ -190,6 +196,10 @@ class ThreadLocalTest(unittest.TestCase, BaseLocalTest):
gc.collect()
self.assertIs(wr(), None)
+
+class ThreadLocalTest(unittest.TestCase, BaseLocalTest):
+ _local = _thread._local
+
class PyThreadingLocalTest(unittest.TestCase, BaseLocalTest):
_local = _threading_local.local
diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py
index 7959e917eb..46e405ab81 100644
--- a/Lib/test/test_threadsignals.py
+++ b/Lib/test/test_threadsignals.py
@@ -1,11 +1,12 @@
"""PyUnit testing that threads honor our signal semantics"""
import unittest
-import _thread as thread
import signal
import os
import sys
-from test.support import run_unittest
+from test.support import run_unittest, import_module
+thread = import_module('_thread')
+import time
if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos':
raise unittest.SkipTest("Can't test signal on %s" % sys.platform)
@@ -34,12 +35,12 @@ def send_signals():
signalled_all.release()
class ThreadSignals(unittest.TestCase):
- """Test signal handling semantics of threads.
- We spawn a thread, have the thread send two signals, and
- wait for it to finish. Check that we got both signals
- and that they were run by the main thread.
- """
+
def test_signals(self):
+ # Test signal handling semantics of threads.
+ # We spawn a thread, have the thread send two signals, and
+ # wait for it to finish. Check that we got both signals
+ # and that they were run by the main thread.
signalled_all.acquire()
self.spawnSignallingThread()
signalled_all.acquire()
@@ -66,6 +67,136 @@ class ThreadSignals(unittest.TestCase):
def spawnSignallingThread(self):
thread.start_new_thread(send_signals, ())
+ def alarm_interrupt(self, sig, frame):
+ raise KeyboardInterrupt
+
+ def test_lock_acquire_interruption(self):
+ # Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
+ # in a deadlock.
+ # XXX this test can fail when the legacy (non-semaphore) implementation
+ # of locks is used in thread_pthread.h, see issue #11223.
+ oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt)
+ try:
+ lock = thread.allocate_lock()
+ lock.acquire()
+ signal.alarm(1)
+ t1 = time.time()
+ self.assertRaises(KeyboardInterrupt, lock.acquire, timeout=5)
+ dt = time.time() - t1
+ # Checking that KeyboardInterrupt was raised is not sufficient.
+ # We want to assert that lock.acquire() was interrupted because
+ # of the signal, not that the signal handler was called immediately
+ # after timeout return of lock.acquire() (which can fool assertRaises).
+ self.assertLess(dt, 3.0)
+ finally:
+ signal.signal(signal.SIGALRM, oldalrm)
+
+ def test_rlock_acquire_interruption(self):
+ # Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
+ # in a deadlock.
+ # XXX this test can fail when the legacy (non-semaphore) implementation
+ # of locks is used in thread_pthread.h, see issue #11223.
+ oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt)
+ try:
+ rlock = thread.RLock()
+ # For reentrant locks, the initial acquisition must be in another
+ # thread.
+ def other_thread():
+ rlock.acquire()
+ thread.start_new_thread(other_thread, ())
+ # Wait until we can't acquire it without blocking...
+ while rlock.acquire(blocking=False):
+ rlock.release()
+ time.sleep(0.01)
+ signal.alarm(1)
+ t1 = time.time()
+ self.assertRaises(KeyboardInterrupt, rlock.acquire, timeout=5)
+ dt = time.time() - t1
+ # See rationale above in test_lock_acquire_interruption
+ self.assertLess(dt, 3.0)
+ finally:
+ signal.signal(signal.SIGALRM, oldalrm)
+
+ def acquire_retries_on_intr(self, lock):
+ self.sig_recvd = False
+ def my_handler(signal, frame):
+ self.sig_recvd = True
+ old_handler = signal.signal(signal.SIGUSR1, my_handler)
+ try:
+ def other_thread():
+ # Acquire the lock in a non-main thread, so this test works for
+ # RLocks.
+ lock.acquire()
+ # Wait until the main thread is blocked in the lock acquire, and
+ # then wake it up with this.
+ time.sleep(0.5)
+ os.kill(process_pid, signal.SIGUSR1)
+ # Let the main thread take the interrupt, handle it, and retry
+ # the lock acquisition. Then we'll let it run.
+ time.sleep(0.5)
+ lock.release()
+ thread.start_new_thread(other_thread, ())
+ # Wait until we can't acquire it without blocking...
+ while lock.acquire(blocking=False):
+ lock.release()
+ time.sleep(0.01)
+ result = lock.acquire() # Block while we receive a signal.
+ self.assertTrue(self.sig_recvd)
+ self.assertTrue(result)
+ finally:
+ signal.signal(signal.SIGUSR1, old_handler)
+
+ def test_lock_acquire_retries_on_intr(self):
+ self.acquire_retries_on_intr(thread.allocate_lock())
+
+ def test_rlock_acquire_retries_on_intr(self):
+ self.acquire_retries_on_intr(thread.RLock())
+
+ def test_interrupted_timed_acquire(self):
+ # Test to make sure we recompute lock acquisition timeouts when we
+ # receive a signal. Check this by repeatedly interrupting a lock
+ # acquire in the main thread, and make sure that the lock acquire times
+ # out after the right amount of time.
+ # NOTE: this test only behaves as expected if C signals get delivered
+ # to the main thread. Otherwise lock.acquire() itself doesn't get
+ # interrupted and the test trivially succeeds.
+ self.start = None
+ self.end = None
+ self.sigs_recvd = 0
+ done = thread.allocate_lock()
+ done.acquire()
+ lock = thread.allocate_lock()
+ lock.acquire()
+ def my_handler(signum, frame):
+ self.sigs_recvd += 1
+ old_handler = signal.signal(signal.SIGUSR1, my_handler)
+ try:
+ def timed_acquire():
+ self.start = time.time()
+ lock.acquire(timeout=0.5)
+ self.end = time.time()
+ def send_signals():
+ for _ in range(40):
+ time.sleep(0.02)
+ os.kill(process_pid, signal.SIGUSR1)
+ done.release()
+
+ # Send the signals from the non-main thread, since the main thread
+ # is the only one that can process signals.
+ thread.start_new_thread(send_signals, ())
+ timed_acquire()
+ # Wait for thread to finish
+ done.acquire()
+ # This allows for some timing and scheduling imprecision
+ self.assertLess(self.end - self.start, 2.0)
+ self.assertGreater(self.end - self.start, 0.3)
+ # If the signal is received several times before PyErr_CheckSignals()
+ # is called, the handler will get called less than 40 times. Just
+ # check it's been called at least once.
+ self.assertGreater(self.sigs_recvd, 0)
+ finally:
+ signal.signal(signal.SIGUSR1, old_handler)
+
def test_main():
global signal_blackboard
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index b68cd6a744..7266e27295 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -2,6 +2,8 @@ from test import support
import time
import unittest
import locale
+import sysconfig
+import warnings
class TimeTestCase(unittest.TestCase):
@@ -18,10 +20,10 @@ class TimeTestCase(unittest.TestCase):
time.clock()
def test_conversions(self):
- self.assertTrue(time.ctime(self.t)
- == time.asctime(time.localtime(self.t)))
- self.assertTrue(int(time.mktime(time.localtime(self.t)))
- == int(self.t))
+ self.assertEqual(time.ctime(self.t),
+ time.asctime(time.localtime(self.t)))
+ self.assertEqual(int(time.mktime(time.localtime(self.t))),
+ int(self.t))
def test_sleep(self):
time.sleep(1.2)
@@ -37,68 +39,61 @@ class TimeTestCase(unittest.TestCase):
except ValueError:
self.fail('conversion specifier: %r failed.' % format)
- def test_strftime_bounds_checking(self):
+ def _bounds_checking(self, func=time.strftime):
# Make sure that strftime() checks the bounds of the various parts
#of the time tuple (0 is valid for *all* values).
- # Check year [1900, max(int)]
- self.assertRaises(ValueError, time.strftime, '',
- (1899, 1, 1, 0, 0, 0, 0, 1, -1))
- if time.accept2dyear:
- self.assertRaises(ValueError, time.strftime, '',
- (-1, 1, 1, 0, 0, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
- (100, 1, 1, 0, 0, 0, 0, 1, -1))
+ # The year field is tested by other test cases above
+
# Check month [1, 12] + zero support
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, -1, 1, 0, 0, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 13, 1, 0, 0, 0, 0, 1, -1))
# Check day of month [1, 31] + zero support
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, -1, 0, 0, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 32, 0, 0, 0, 0, 1, -1))
# Check hour [0, 23]
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, -1, 0, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 24, 0, 0, 0, 1, -1))
# Check minute [0, 59]
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, -1, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 60, 0, 0, 1, -1))
# Check second [0, 61]
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, -1, 0, 1, -1))
# C99 only requires allowing for one leap second, but Python's docs say
# allow two leap seconds (0..61)
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 62, 0, 1, -1))
# No check for upper-bound day of week;
# value forced into range by a ``% 7`` calculation.
# Start check at -2 since gettmarg() increments value before taking
# modulo.
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 0, -2, 1, -1))
# Check day of the year [1, 366] + zero support
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 0, 0, -1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 0, 0, 367, -1))
- # Check daylight savings flag [-1, 1]
- self.assertRaises(ValueError, time.strftime, '',
- (1900, 1, 1, 0, 0, 0, 0, 1, -2))
- self.assertRaises(ValueError, time.strftime, '',
- (1900, 1, 1, 0, 0, 0, 0, 1, 2))
+
+ def test_strftime_bounding_check(self):
+ self._bounds_checking(lambda tup: time.strftime('', tup))
def test_default_values_for_zero(self):
# Make sure that using all zeros uses the proper default values.
# No test for daylight savings since strftime() does not change output
# based on its value.
expected = "2000 01 01 00 00 00 1 001"
- result = time.strftime("%Y %m %d %H %M %S %w %j", (0,)*9)
+ with support.check_warnings():
+ result = time.strftime("%Y %m %d %H %M %S %w %j", (0,)*9)
self.assertEqual(expected, result)
def test_strptime(self):
@@ -123,17 +118,34 @@ class TimeTestCase(unittest.TestCase):
def test_asctime(self):
time.asctime(time.gmtime(self.t))
+
+ # Max year is only limited by the size of C int.
+ sizeof_int = sysconfig.get_config_var('SIZEOF_INT') or 4
+ bigyear = (1 << 8 * sizeof_int - 1) - 1
+ asc = time.asctime((bigyear, 6, 1) + (0,)*6)
+ self.assertEqual(asc[-len(str(bigyear)):], str(bigyear))
+ self.assertRaises(OverflowError, time.asctime, (bigyear + 1,) + (0,)*8)
self.assertRaises(TypeError, time.asctime, 0)
self.assertRaises(TypeError, time.asctime, ())
- # XXX: Posix compiant asctime should refuse to convert
- # year > 9999, but Linux implementation does not.
- # self.assertRaises(ValueError, time.asctime,
- # (12345, 1, 0, 0, 0, 0, 0, 0, 0))
- # XXX: For now, just make sure we don't have a crash:
- try:
- time.asctime((12345, 1, 1, 0, 0, 0, 0, 1, 0))
- except ValueError:
- pass
+ self.assertRaises(TypeError, time.asctime, (0,) * 10)
+
+ def test_asctime_bounding_check(self):
+ self._bounds_checking(time.asctime)
+
+ def test_ctime(self):
+ t = time.mktime((1973, 9, 16, 1, 3, 52, 0, 0, -1))
+ self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
+ t = time.mktime((2000, 1, 1, 0, 0, 0, 0, 0, -1))
+ self.assertEqual(time.ctime(t), 'Sat Jan 1 00:00:00 2000')
+ for year in [-100, 100, 1000, 2000, 10000]:
+ try:
+ testval = time.mktime((year, 1, 10) + (0,)*6)
+ except (ValueError, OverflowError):
+ # If mktime fails, ctime will fail too. This may happen
+ # on some platforms.
+ pass
+ else:
+ self.assertEqual(time.ctime(testval)[20:], str(year))
@unittest.skipIf(not hasattr(time, "tzset"),
"time module has no attribute tzset")
@@ -224,24 +236,14 @@ class TimeTestCase(unittest.TestCase):
gt1 = time.gmtime(None)
t0 = time.mktime(gt0)
t1 = time.mktime(gt1)
- self.assertTrue(0 <= (t1-t0) < 0.2)
+ self.assertAlmostEqual(t1, t0, delta=0.2)
def test_localtime_without_arg(self):
lt0 = time.localtime()
lt1 = time.localtime(None)
t0 = time.mktime(lt0)
t1 = time.mktime(lt1)
- self.assertTrue(0 <= (t1-t0) < 0.2)
-
- def test_mktime(self):
- # Issue #1726687
- for t in (-2, -1, 0, 1):
- try:
- tt = time.localtime(t)
- except (OverflowError, ValueError):
- pass
- else:
- self.assertEqual(time.mktime(tt), t)
+ self.assertAlmostEqual(t1, t0, delta=0.2)
class TestLocale(unittest.TestCase):
def setUp(self):
@@ -259,8 +261,142 @@ class TestLocale(unittest.TestCase):
# This should not cause an exception
time.strftime("%B", (2009,2,1,0,0,0,0,0,0))
+
+class _BaseYearTest(unittest.TestCase):
+ accept2dyear = None
+
+ def setUp(self):
+ self.saved_accept2dyear = time.accept2dyear
+ time.accept2dyear = self.accept2dyear
+
+ def tearDown(self):
+ time.accept2dyear = self.saved_accept2dyear
+
+ def yearstr(self, y):
+ raise NotImplementedError()
+
+class _TestAsctimeYear:
+ def yearstr(self, y):
+ return time.asctime((y,) + (0,) * 8).split()[-1]
+
+ def test_large_year(self):
+ # Check that it doesn't crash for year > 9999
+ self.assertEqual(self.yearstr(12345), '12345')
+ self.assertEqual(self.yearstr(123456789), '123456789')
+
+class _TestStrftimeYear:
+ def yearstr(self, y):
+ return time.strftime('%Y', (y,) + (0,) * 8).split()[-1]
+
+ def test_large_year(self):
+ # Check that it doesn't crash for year > 9999
+ try:
+ text = self.yearstr(12345)
+ except ValueError:
+ # strftime() is limited to [1; 9999] with Visual Studio
+ return
+ # Issue #10864: OpenIndiana is limited to 4 digits,
+ # but Python doesn't raise a ValueError
+ #self.assertEqual(text, '12345')
+ #self.assertEqual(self.yearstr(123456789), '123456789')
+ self.assertIn(text, ('2345', '12345'))
+ self.assertIn(self.yearstr(123456789), ('123456789', '6789'))
+
+class _Test2dYear(_BaseYearTest):
+ accept2dyear = 1
+
+ def test_year(self):
+ with support.check_warnings():
+ self.assertEqual(self.yearstr(0), '2000')
+ self.assertEqual(self.yearstr(69), '1969')
+ self.assertEqual(self.yearstr(68), '2068')
+ self.assertEqual(self.yearstr(99), '1999')
+
+ def test_invalid(self):
+ self.assertRaises(ValueError, self.yearstr, -1)
+ self.assertRaises(ValueError, self.yearstr, 100)
+ self.assertRaises(ValueError, self.yearstr, 999)
+
+class _Test4dYear(_BaseYearTest):
+ accept2dyear = 0
+
+ def test_year(self):
+ self.assertIn(self.yearstr(1), ('1', '0001'))
+ self.assertIn(self.yearstr(68), ('68', '0068'))
+ self.assertIn(self.yearstr(69), ('69', '0069'))
+ self.assertIn(self.yearstr(99), ('99', '0099'))
+ self.assertIn(self.yearstr(999), ('999', '0999'))
+ self.assertEqual(self.yearstr(9999), '9999')
+
+ def test_negative(self):
+ try:
+ text = self.yearstr(-1)
+ except ValueError:
+ # strftime() is limited to [1; 9999] with Visual Studio
+ return
+ self.assertIn(text, ('-1', '-001'))
+
+ self.assertEqual(self.yearstr(-1234), '-1234')
+ self.assertEqual(self.yearstr(-123456), '-123456')
+
+
+ def test_mktime(self):
+ # Issue #1726687
+ for t in (-2, -1, 0, 1):
+ try:
+ tt = time.localtime(t)
+ except (OverflowError, ValueError):
+ pass
+ else:
+ self.assertEqual(time.mktime(tt), t)
+ # It may not be possible to reliably make mktime return error
+ # on all platfom. This will make sure that no other exception
+ # than OverflowError is raised for an extreme value.
+ try:
+ time.mktime((-1, 1, 1, 0, 0, 0, -1, -1, -1))
+ except OverflowError:
+ pass
+
+class TestAsctimeAccept2dYear(_TestAsctimeYear, _Test2dYear):
+ pass
+
+class TestStrftimeAccept2dYear(_TestStrftimeYear, _Test2dYear):
+ pass
+
+class TestAsctime4dyear(_TestAsctimeYear, _Test4dYear):
+ pass
+
+class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear):
+ pass
+
+class Test2dyearBool(_TestAsctimeYear, _Test2dYear):
+ accept2dyear = True
+
+class Test4dyearBool(_TestAsctimeYear, _Test4dYear):
+ accept2dyear = False
+
+class TestAccept2YearBad(_TestAsctimeYear, _BaseYearTest):
+ class X:
+ def __bool__(self):
+ raise RuntimeError('boo')
+ accept2dyear = X()
+ def test_2dyear(self):
+ pass
+ def test_invalid(self):
+ self.assertRaises(RuntimeError, self.yearstr, 200)
+
+
def test_main():
- support.run_unittest(TimeTestCase, TestLocale)
+ support.run_unittest(
+ TimeTestCase,
+ TestLocale,
+ TestAsctimeAccept2dYear,
+ TestStrftimeAccept2dYear,
+ TestAsctime4dyear,
+ TestStrftime4dyear,
+ Test2dyearBool,
+ Test4dyearBool,
+ TestAccept2YearBad)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_timeit.py b/Lib/test/test_timeit.py
new file mode 100644
index 0000000000..eb3b1a156b
--- /dev/null
+++ b/Lib/test/test_timeit.py
@@ -0,0 +1,305 @@
+import timeit
+import unittest
+import sys
+import io
+import time
+from textwrap import dedent
+
+from test.support import run_unittest
+from test.support import captured_stdout
+from test.support import captured_stderr
+
+# timeit's default number of iterations.
+DEFAULT_NUMBER = 1000000
+
+# timeit's default number of repetitions.
+DEFAULT_REPEAT = 3
+
+# XXX: some tests are commented out that would improve the coverage but take a
+# long time to run because they test the default number of loops, which is
+# large. The tests could be enabled if there was a way to override the default
+# number of loops during testing, but this would require changing the signature
+# of some functions that use the default as a default argument.
+
+class FakeTimer:
+ BASE_TIME = 42.0
+ def __init__(self, seconds_per_increment=1.0):
+ self.count = 0
+ self.setup_calls = 0
+ self.seconds_per_increment=seconds_per_increment
+ timeit._fake_timer = self
+
+ def __call__(self):
+ return self.BASE_TIME + self.count * self.seconds_per_increment
+
+ def inc(self):
+ self.count += 1
+
+ def setup(self):
+ self.setup_calls += 1
+
+ def wrap_timer(self, timer):
+ """Records 'timer' and returns self as callable timer."""
+ self.saved_timer = timer
+ return self
+
+class TestTimeit(unittest.TestCase):
+
+ def tearDown(self):
+ try:
+ del timeit._fake_timer
+ except AttributeError:
+ pass
+
+ def test_reindent_empty(self):
+ self.assertEqual(timeit.reindent("", 0), "")
+ self.assertEqual(timeit.reindent("", 4), "")
+
+ def test_reindent_single(self):
+ self.assertEqual(timeit.reindent("pass", 0), "pass")
+ self.assertEqual(timeit.reindent("pass", 4), "pass")
+
+ def test_reindent_multi_empty(self):
+ self.assertEqual(timeit.reindent("\n\n", 0), "\n\n")
+ self.assertEqual(timeit.reindent("\n\n", 4), "\n \n ")
+
+ def test_reindent_multi(self):
+ self.assertEqual(timeit.reindent(
+ "print()\npass\nbreak", 0),
+ "print()\npass\nbreak")
+ self.assertEqual(timeit.reindent(
+ "print()\npass\nbreak", 4),
+ "print()\n pass\n break")
+
+ def test_timer_invalid_stmt(self):
+ self.assertRaises(ValueError, timeit.Timer, stmt=None)
+
+ def test_timer_invalid_setup(self):
+ self.assertRaises(ValueError, timeit.Timer, setup=None)
+
+ fake_setup = "import timeit; timeit._fake_timer.setup()"
+ fake_stmt = "import timeit; timeit._fake_timer.inc()"
+
+ def fake_callable_setup(self):
+ self.fake_timer.setup()
+
+ def fake_callable_stmt(self):
+ self.fake_timer.inc()
+
+ def timeit(self, stmt, setup, number=None):
+ self.fake_timer = FakeTimer()
+ t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer)
+ kwargs = {}
+ if number is None:
+ number = DEFAULT_NUMBER
+ else:
+ kwargs['number'] = number
+ delta_time = t.timeit(**kwargs)
+ self.assertEqual(self.fake_timer.setup_calls, 1)
+ self.assertEqual(self.fake_timer.count, number)
+ self.assertEqual(delta_time, number)
+
+ # Takes too long to run in debug build.
+ #def test_timeit_default_iters(self):
+ # self.timeit(self.fake_stmt, self.fake_setup)
+
+ def test_timeit_zero_iters(self):
+ self.timeit(self.fake_stmt, self.fake_setup, number=0)
+
+ def test_timeit_few_iters(self):
+ self.timeit(self.fake_stmt, self.fake_setup, number=3)
+
+ def test_timeit_callable_stmt(self):
+ self.timeit(self.fake_callable_stmt, self.fake_setup, number=3)
+
+ def test_timeit_callable_stmt_and_setup(self):
+ self.timeit(self.fake_callable_stmt,
+ self.fake_callable_setup, number=3)
+
+ # Takes too long to run in debug build.
+ #def test_timeit_function(self):
+ # delta_time = timeit.timeit(self.fake_stmt, self.fake_setup,
+ # timer=FakeTimer())
+ # self.assertEqual(delta_time, DEFAULT_NUMBER)
+
+ def test_timeit_function_zero_iters(self):
+ delta_time = timeit.timeit(self.fake_stmt, self.fake_setup, number=0,
+ timer=FakeTimer())
+ self.assertEqual(delta_time, 0)
+
+ def repeat(self, stmt, setup, repeat=None, number=None):
+ self.fake_timer = FakeTimer()
+ t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer)
+ kwargs = {}
+ if repeat is None:
+ repeat = DEFAULT_REPEAT
+ else:
+ kwargs['repeat'] = repeat
+ if number is None:
+ number = DEFAULT_NUMBER
+ else:
+ kwargs['number'] = number
+ delta_times = t.repeat(**kwargs)
+ self.assertEqual(self.fake_timer.setup_calls, repeat)
+ self.assertEqual(self.fake_timer.count, repeat * number)
+ self.assertEqual(delta_times, repeat * [float(number)])
+
+ # Takes too long to run in debug build.
+ #def test_repeat_default(self):
+ # self.repeat(self.fake_stmt, self.fake_setup)
+
+ def test_repeat_zero_reps(self):
+ self.repeat(self.fake_stmt, self.fake_setup, repeat=0)
+
+ def test_repeat_zero_iters(self):
+ self.repeat(self.fake_stmt, self.fake_setup, number=0)
+
+ def test_repeat_few_reps_and_iters(self):
+ self.repeat(self.fake_stmt, self.fake_setup, repeat=3, number=5)
+
+ def test_repeat_callable_stmt(self):
+ self.repeat(self.fake_callable_stmt, self.fake_setup,
+ repeat=3, number=5)
+
+ def test_repeat_callable_stmt_and_setup(self):
+ self.repeat(self.fake_callable_stmt, self.fake_callable_setup,
+ repeat=3, number=5)
+
+ # Takes too long to run in debug build.
+ #def test_repeat_function(self):
+ # delta_times = timeit.repeat(self.fake_stmt, self.fake_setup,
+ # timer=FakeTimer())
+ # self.assertEqual(delta_times, DEFAULT_REPEAT * [float(DEFAULT_NUMBER)])
+
+ def test_repeat_function_zero_reps(self):
+ delta_times = timeit.repeat(self.fake_stmt, self.fake_setup, repeat=0,
+ timer=FakeTimer())
+ self.assertEqual(delta_times, [])
+
+ def test_repeat_function_zero_iters(self):
+ delta_times = timeit.repeat(self.fake_stmt, self.fake_setup, number=0,
+ timer=FakeTimer())
+ self.assertEqual(delta_times, DEFAULT_REPEAT * [0.0])
+
+ def assert_exc_string(self, exc_string, expected_exc_name):
+ exc_lines = exc_string.splitlines()
+ self.assertGreater(len(exc_lines), 2)
+ self.assertTrue(exc_lines[0].startswith('Traceback'))
+ self.assertTrue(exc_lines[-1].startswith(expected_exc_name))
+
+ def test_print_exc(self):
+ s = io.StringIO()
+ t = timeit.Timer("1/0")
+ try:
+ t.timeit()
+ except:
+ t.print_exc(s)
+ self.assert_exc_string(s.getvalue(), 'ZeroDivisionError')
+
+ MAIN_DEFAULT_OUTPUT = "10 loops, best of 3: 1 sec per loop\n"
+
+ def run_main(self, seconds_per_increment=1.0, switches=None, timer=None):
+ if timer is None:
+ timer = FakeTimer(seconds_per_increment=seconds_per_increment)
+ if switches is None:
+ args = []
+ else:
+ args = switches[:]
+ args.append(self.fake_stmt)
+ # timeit.main() modifies sys.path, so save and restore it.
+ orig_sys_path = sys.path[:]
+ with captured_stdout() as s:
+ timeit.main(args=args, _wrap_timer=timer.wrap_timer)
+ sys.path[:] = orig_sys_path[:]
+ return s.getvalue()
+
+ def test_main_bad_switch(self):
+ s = self.run_main(switches=['--bad-switch'])
+ self.assertEqual(s, dedent("""\
+ option --bad-switch not recognized
+ use -h/--help for command line help
+ """))
+
+ def test_main_seconds(self):
+ s = self.run_main(seconds_per_increment=5.5)
+ self.assertEqual(s, "10 loops, best of 3: 5.5 sec per loop\n")
+
+ def test_main_milliseconds(self):
+ s = self.run_main(seconds_per_increment=0.0055)
+ self.assertEqual(s, "100 loops, best of 3: 5.5 msec per loop\n")
+
+ def test_main_microseconds(self):
+ s = self.run_main(seconds_per_increment=0.0000025, switches=['-n100'])
+ self.assertEqual(s, "100 loops, best of 3: 2.5 usec per loop\n")
+
+ def test_main_fixed_iters(self):
+ s = self.run_main(seconds_per_increment=2.0, switches=['-n35'])
+ self.assertEqual(s, "35 loops, best of 3: 2 sec per loop\n")
+
+ def test_main_setup(self):
+ s = self.run_main(seconds_per_increment=2.0,
+ switches=['-n35', '-s', 'print("CustomSetup")'])
+ self.assertEqual(s, "CustomSetup\n" * 3 +
+ "35 loops, best of 3: 2 sec per loop\n")
+
+ def test_main_fixed_reps(self):
+ s = self.run_main(seconds_per_increment=60.0, switches=['-r9'])
+ self.assertEqual(s, "10 loops, best of 9: 60 sec per loop\n")
+
+ def test_main_negative_reps(self):
+ s = self.run_main(seconds_per_increment=60.0, switches=['-r-5'])
+ self.assertEqual(s, "10 loops, best of 1: 60 sec per loop\n")
+
+ def test_main_help(self):
+ s = self.run_main(switches=['-h'])
+ # Note: It's not clear that the trailing space was intended as part of
+ # the help text, but since it's there, check for it.
+ self.assertEqual(s, timeit.__doc__ + ' ')
+
+ def test_main_using_time(self):
+ fake_timer = FakeTimer()
+ s = self.run_main(switches=['-t'], timer=fake_timer)
+ self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)
+ self.assertIs(fake_timer.saved_timer, time.time)
+
+ def test_main_using_clock(self):
+ fake_timer = FakeTimer()
+ s = self.run_main(switches=['-c'], timer=fake_timer)
+ self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)
+ self.assertIs(fake_timer.saved_timer, time.clock)
+
+ def test_main_verbose(self):
+ s = self.run_main(switches=['-v'])
+ self.assertEqual(s, dedent("""\
+ 10 loops -> 10 secs
+ raw times: 10 10 10
+ 10 loops, best of 3: 1 sec per loop
+ """))
+
+ def test_main_very_verbose(self):
+ s = self.run_main(seconds_per_increment=0.000050, switches=['-vv'])
+ self.assertEqual(s, dedent("""\
+ 10 loops -> 0.0005 secs
+ 100 loops -> 0.005 secs
+ 1000 loops -> 0.05 secs
+ 10000 loops -> 0.5 secs
+ raw times: 0.5 0.5 0.5
+ 10000 loops, best of 3: 50 usec per loop
+ """))
+
+ def test_main_exception(self):
+ with captured_stderr() as error_stringio:
+ s = self.run_main(switches=['1/0'])
+ self.assert_exc_string(error_stringio.getvalue(), 'ZeroDivisionError')
+
+ def test_main_exception_fixed_reps(self):
+ with captured_stderr() as error_stringio:
+ s = self.run_main(switches=['-n1', '1/0'])
+ self.assert_exc_string(error_stringio.getvalue(), 'ZeroDivisionError')
+
+
+def test_main():
+ run_unittest(TestTimeit)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py
index bbcdc25672..4cad49926d 100644
--- a/Lib/test/test_timeout.py
+++ b/Lib/test/test_timeout.py
@@ -7,6 +7,7 @@ from test import support
skip_expected = not support.is_resource_enabled('network')
import time
+import errno
import socket
@@ -88,8 +89,6 @@ class CreationTestCase(unittest.TestCase):
class TimeoutTestCase(unittest.TestCase):
- """Test case for socket.socket() timeout functions"""
-
# There are a number of tests here trying to make sure that an operation
# doesn't take too much longer than expected. But competing machine
# activity makes it inevitable that such tests will fail at times.
@@ -98,10 +97,42 @@ class TimeoutTestCase(unittest.TestCase):
# solution.
fuzz = 2.0
+ localhost = '127.0.0.1'
+
+ def setUp(self):
+ raise NotImplementedError()
+
+ tearDown = setUp
+
+ def _sock_operation(self, count, timeout, method, *args):
+ """
+ Test the specified socket method.
+
+ The method is run at most `count` times and must raise a socket.timeout
+ within `timeout` + self.fuzz seconds.
+ """
+ self.sock.settimeout(timeout)
+ method = getattr(self.sock, method)
+ for i in range(count):
+ t1 = time.time()
+ try:
+ method(*args)
+ except socket.timeout as e:
+ delta = time.time() - t1
+ break
+ else:
+ self.fail('socket.timeout was not raised')
+ # These checks should account for timing unprecision
+ self.assertLess(delta, timeout + self.fuzz)
+ self.assertGreater(delta, timeout - 1.0)
+
+
+class TCPTimeoutTestCase(TimeoutTestCase):
+ """TCP test case for socket.socket() timeout functions"""
+
def setUp(self):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.addr_remote = ('www.python.org.', 80)
- self.localhost = '127.0.0.1'
def tearDown(self):
self.sock.close()
@@ -113,90 +144,73 @@ class TimeoutTestCase(unittest.TestCase):
# with the connect time. This avoids failing the assertion that
# the timeout occurred fast enough.
addr = ('10.0.0.0', 12345)
-
- # Test connect() timeout
- _timeout = 0.001
- self.sock.settimeout(_timeout)
-
- _t1 = time.time()
- self.assertRaises(socket.error, self.sock.connect, addr)
- _t2 = time.time()
-
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is more than %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
+ with support.transient_internet(addr[0]):
+ self._sock_operation(1, 0.001, 'connect', addr)
def testRecvTimeout(self):
# Test recv() timeout
- _timeout = 0.02
-
with support.transient_internet(self.addr_remote[0]):
self.sock.connect(self.addr_remote)
- self.sock.settimeout(_timeout)
-
- _t1 = time.time()
- self.assertRaises(socket.timeout, self.sock.recv, 1024)
- _t2 = time.time()
-
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
+ self._sock_operation(1, 1.5, 'recv', 1024)
def testAcceptTimeout(self):
# Test accept() timeout
- _timeout = 2
- self.sock.settimeout(_timeout)
- # Prevent "Address already in use" socket exceptions
support.bind_port(self.sock, self.localhost)
self.sock.listen(5)
-
- _t1 = time.time()
- self.assertRaises(socket.error, self.sock.accept)
- _t2 = time.time()
-
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
-
- def testRecvfromTimeout(self):
- # Test recvfrom() timeout
- _timeout = 2
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- self.sock.settimeout(_timeout)
- # Prevent "Address already in use" socket exceptions
- support.bind_port(self.sock, self.localhost)
-
- _t1 = time.time()
- self.assertRaises(socket.error, self.sock.recvfrom, 8192)
- _t2 = time.time()
-
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
+ self._sock_operation(1, 1.5, 'accept')
def testSend(self):
# Test send() timeout
- # couldn't figure out how to test it
- pass
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
+ support.bind_port(serv, self.localhost)
+ serv.listen(5)
+ self.sock.connect(serv.getsockname())
+ # Send a lot of data in order to bypass buffering in the TCP stack.
+ self._sock_operation(100, 1.5, 'send', b"X" * 200000)
def testSendto(self):
# Test sendto() timeout
- # couldn't figure out how to test it
- pass
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
+ support.bind_port(serv, self.localhost)
+ serv.listen(5)
+ self.sock.connect(serv.getsockname())
+ # The address argument is ignored since we already connected.
+ self._sock_operation(100, 1.5, 'sendto', b"X" * 200000,
+ serv.getsockname())
def testSendall(self):
# Test sendall() timeout
- # couldn't figure out how to test it
- pass
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
+ support.bind_port(serv, self.localhost)
+ serv.listen(5)
+ self.sock.connect(serv.getsockname())
+ # Send a lot of data in order to bypass buffering in the TCP stack.
+ self._sock_operation(100, 1.5, 'sendall', b"X" * 200000)
+
+
+class UDPTimeoutTestCase(TimeoutTestCase):
+ """UDP test case for socket.socket() timeout functions"""
+
+ def setUp(self):
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+
+ def tearDown(self):
+ self.sock.close()
+
+ def testRecvfromTimeout(self):
+ # Test recvfrom() timeout
+ # Prevent "Address already in use" socket exceptions
+ support.bind_port(self.sock, self.localhost)
+ self._sock_operation(1, 1.5, 'recvfrom', 1024)
def test_main():
support.requires('network')
- support.run_unittest(CreationTestCase, TimeoutTestCase)
+ support.run_unittest(
+ CreationTestCase,
+ TCPTimeoutTestCase,
+ UDPTimeoutTestCase,
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index 510e632565..11e6fb4596 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
doctests = """
Tests for the tokenize module.
@@ -42,7 +40,7 @@ brevity.
...
IndentationError: unindent does not match any outer indentation level
-There are some standard formattig practises that are easy to get right.
+There are some standard formatting practices that are easy to get right.
>>> roundtrip("if x == 1:\\n"
... " print(x)\\n")
@@ -566,7 +564,8 @@ Non-ascii identifiers
from test import support
from tokenize import (tokenize, _tokenize, untokenize, NUMBER, NAME, OP,
- STRING, ENDMARKER, tok_name, detect_encoding)
+ STRING, ENDMARKER, tok_name, detect_encoding,
+ open as tokenize_open)
from io import BytesIO
from unittest import TestCase
import os, sys, glob
@@ -613,11 +612,11 @@ def decistmt(s):
The format of the exponent is inherited from the platform C library.
Known cases are "e-007" (Windows) and "e-07" (not Windows). Since
- we're only showing 12 digits, and the 13th isn't close to 5, the
+ we're only showing 11 digits, and the 12th isn't close to 5, the
rest of the output should be platform-independent.
>>> exec(s) #doctest: +ELLIPSIS
- -3.21716034272e-0...7
+ -3.2171603427...e-0...7
Output from calculations with Decimal should be identical across all
platforms.
@@ -741,7 +740,7 @@ class TestDetectEncoding(TestCase):
b'do_something(else)\n'
)
encoding, consumed_lines = detect_encoding(self.get_readline(lines))
- self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(encoding, 'utf-8-sig')
self.assertEqual(consumed_lines,
[b'# something\n', b'print(something)\n'])
@@ -762,7 +761,7 @@ class TestDetectEncoding(TestCase):
b'do_something(else)\n'
)
encoding, consumed_lines = detect_encoding(self.get_readline(lines))
- self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(encoding, 'utf-8-sig')
self.assertEqual(consumed_lines, [b'# coding=utf-8\n'])
def test_mismatched_bom_and_cookie_first_line_raises_syntaxerror(self):
@@ -794,7 +793,7 @@ class TestDetectEncoding(TestCase):
b'do_something(else)\n'
)
encoding, consumed_lines = detect_encoding(self.get_readline(lines))
- self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(encoding, 'utf-8-sig')
self.assertEqual(consumed_lines,
[b'#! something\n', b'f# coding=utf-8\n'])
@@ -848,17 +847,37 @@ class TestDetectEncoding(TestCase):
readline = self.get_readline((b'\xef\xbb\xbfprint(something)\n',))
encoding, consumed_lines = detect_encoding(readline)
- self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(encoding, 'utf-8-sig')
self.assertEqual(consumed_lines, [b'print(something)\n'])
readline = self.get_readline((b'\xef\xbb\xbf',))
encoding, consumed_lines = detect_encoding(readline)
- self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(encoding, 'utf-8-sig')
self.assertEqual(consumed_lines, [])
readline = self.get_readline((b'# coding: bad\n',))
self.assertRaises(SyntaxError, detect_encoding, readline)
+ def test_open(self):
+ filename = support.TESTFN + '.py'
+ self.addCleanup(support.unlink, filename)
+
+ # test coding cookie
+ for encoding in ('iso-8859-15', 'utf-8'):
+ with open(filename, 'w', encoding=encoding) as fp:
+ print("# coding: %s" % encoding, file=fp)
+ print("print('euro:\u20ac')", file=fp)
+ with tokenize_open(filename) as fp:
+ self.assertEqual(fp.encoding, encoding)
+ self.assertEqual(fp.mode, 'r')
+
+ # test BOM (no coding cookie)
+ with open(filename, 'w', encoding='utf-8-sig') as fp:
+ print("print('euro:\u20ac')", file=fp)
+ with tokenize_open(filename) as fp:
+ self.assertEqual(fp.encoding, 'utf-8-sig')
+ self.assertEqual(fp.mode, 'r')
+
class TestTokenize(TestCase):
def test_tokenize(self):
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 3697cbf5bb..461d1d8e6a 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -70,6 +70,12 @@ def traced_func_calling_generator():
def traced_doubler(num):
return num * 2
+def traced_caller_list_comprehension():
+ k = 10
+ mylist = [traced_doubler(i) for i in range(k)]
+ return mylist
+
+
class TracedClass(object):
def __init__(self, x):
self.a = x
@@ -150,6 +156,22 @@ class TestLineCounts(unittest.TestCase):
}
self.assertEqual(self.tracer.results().counts, expected)
+ def test_trace_list_comprehension(self):
+ self.tracer.runfunc(traced_caller_list_comprehension)
+
+ firstlineno_calling = get_firstlineno(traced_caller_list_comprehension)
+ firstlineno_called = get_firstlineno(traced_doubler)
+ expected = {
+ (self.my_py_filename, firstlineno_calling + 1): 1,
+ # List compehentions work differently in 3.x, so the count
+ # below changed compared to 2.x.
+ (self.my_py_filename, firstlineno_calling + 2): 12,
+ (self.my_py_filename, firstlineno_calling + 3): 1,
+ (self.my_py_filename, firstlineno_called + 1): 10,
+ }
+ self.assertEqual(self.tracer.results().counts, expected)
+
+
def test_linear_methods(self):
# XXX todo: later add 'static_method_linear' and 'class_method_linear'
# here, once issue1764286 is resolved
@@ -274,10 +296,10 @@ class TestCoverage(unittest.TestCase):
self._coverage(tracer)
stdout = stdout.getvalue()
self.assertTrue("pprint.py" in stdout)
- self.assertTrue("unittest.py" in stdout)
+ self.assertTrue("case.py" in stdout) # from unittest
files = os.listdir(TESTFN)
self.assertTrue("pprint.cover" in files)
- self.assertTrue("unittest.cover" in files)
+ self.assertTrue("unittest.case.cover" in files)
def test_coverage_ignore(self):
# Ignore all files, nothing should be traced nor printed
@@ -308,10 +330,25 @@ class TestCoverage(unittest.TestCase):
lines, cov, module = line.split()[:3]
coverage[module] = (int(lines), int(cov[:-1]))
# XXX This is needed to run regrtest.py as a script
- modname = trace.fullmodname(sys.modules[modname].__file__)
+ modname = trace._fullmodname(sys.modules[modname].__file__)
self.assertIn(modname, coverage)
self.assertEqual(coverage[modname], (5, 100))
+### Tests that don't mess with sys.settrace and can be traced
+### themselves TODO: Skip tests that do mess with sys.settrace when
+### regrtest is invoked with -T option.
+class Test_Ignore(unittest.TestCase):
+ def test_ignored(self):
+ jn = os.path.join
+ ignore = trace._Ignore(['x', 'y.z'], [jn('foo', 'bar')])
+ self.assertTrue(ignore.names('x.py', 'x'))
+ self.assertFalse(ignore.names('xy.py', 'xy'))
+ self.assertFalse(ignore.names('y.py', 'y'))
+ self.assertTrue(ignore.names(jn('foo', 'bar', 'baz.py'), 'baz'))
+ self.assertFalse(ignore.names(jn('bar', 'z.py'), 'z'))
+ # Matched before.
+ self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
+
def test_main():
run_unittest(__name__)
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index f9e4458220..4752d37e5b 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -5,7 +5,7 @@ from io import StringIO
import sys
import unittest
import re
-from test.support import run_unittest, is_jython, Error, captured_output
+from test.support import run_unittest, Error, captured_output
from test.support import TESTFN, unlink
import traceback
@@ -29,10 +29,6 @@ class SyntaxTracebackCases(unittest.TestCase):
def syntax_error_with_caret_2(self):
compile("1 +\n", "?", "exec")
- def syntax_error_without_caret(self):
- # XXX why doesn't compile raise the same traceback?
- import test.badsyntax_nocaret
-
def syntax_error_bad_indentation(self):
compile("def spam():\n print(1)\n print(2)", "?", "exec")
@@ -41,30 +37,27 @@ class SyntaxTracebackCases(unittest.TestCase):
SyntaxError)
self.assertEqual(len(err), 4)
self.assertTrue(err[1].strip() == "return x!")
- self.assertTrue("^" in err[2]) # third line has caret
+ self.assertIn("^", err[2]) # third line has caret
self.assertEqual(err[1].find("!"), err[2].find("^")) # in the right place
err = self.get_exception_format(self.syntax_error_with_caret_2,
SyntaxError)
- self.assertTrue("^" in err[2]) # third line has caret
+ self.assertIn("^", err[2]) # third line has caret
self.assertTrue(err[2].count('\n') == 1) # and no additional newline
self.assertTrue(err[1].find("+") == err[2].find("^")) # in the right place
def test_nocaret(self):
- if is_jython:
- # jython adds a caret in this case (why shouldn't it?)
- return
- err = self.get_exception_format(self.syntax_error_without_caret,
- SyntaxError)
+ exc = SyntaxError("error", ("x.py", 23, None, "bad syntax"))
+ err = traceback.format_exception_only(SyntaxError, exc)
self.assertEqual(len(err), 3)
- self.assertTrue(err[1].strip() == "[x for x in x] = x")
+ self.assertEqual(err[1].strip(), "bad syntax")
def test_bad_indentation(self):
err = self.get_exception_format(self.syntax_error_bad_indentation,
IndentationError)
self.assertEqual(len(err), 4)
self.assertEqual(err[1].strip(), "print(2)")
- self.assertTrue("^" in err[2])
+ self.assertIn("^", err[2])
self.assertEqual(err[1].find(")"), err[2].find("^"))
def test_base_exception(self):
@@ -131,7 +124,7 @@ class SyntaxTracebackCases(unittest.TestCase):
err_line = "raise RuntimeError('{0}')".format(message_ascii)
err_msg = "RuntimeError: {0}".format(message_ascii)
- self.assertTrue(("line %s" % lineno) in stdout[1],
+ self.assertIn(("line %s" % lineno), stdout[1],
"Invalid line number: {0!r} instead of {1}".format(
stdout[1], lineno))
self.assertTrue(stdout[2].endswith(err_line),
@@ -210,7 +203,7 @@ class BaseExceptionReportingTests:
def check_zero_div(self, msg):
lines = msg.splitlines()
self.assertTrue(lines[-3].startswith(' File'))
- self.assertTrue('1/0 # In zero_div' in lines[-2], lines[-2])
+ self.assertIn('1/0 # In zero_div', lines[-2])
self.assertTrue(lines[-1].startswith('ZeroDivisionError'), lines[-1])
def test_simple(self):
@@ -222,7 +215,7 @@ class BaseExceptionReportingTests:
self.assertEqual(len(lines), 4)
self.assertTrue(lines[0].startswith('Traceback'))
self.assertTrue(lines[1].startswith(' File'))
- self.assertTrue('1/0 # Marker' in lines[2])
+ self.assertIn('1/0 # Marker', lines[2])
self.assertTrue(lines[3].startswith('ZeroDivisionError'))
def test_cause(self):
@@ -237,7 +230,7 @@ class BaseExceptionReportingTests:
self.assertEqual(len(blocks), 3)
self.assertEqual(blocks[1], cause_message)
self.check_zero_div(blocks[0])
- self.assertTrue('inner_raise() # Marker' in blocks[2])
+ self.assertIn('inner_raise() # Marker', blocks[2])
def test_context(self):
def inner_raise():
@@ -251,7 +244,7 @@ class BaseExceptionReportingTests:
self.assertEqual(len(blocks), 3)
self.assertEqual(blocks[1], context_message)
self.check_zero_div(blocks[0])
- self.assertTrue('inner_raise() # Marker' in blocks[2])
+ self.assertIn('inner_raise() # Marker', blocks[2])
def test_cause_and_context(self):
# When both a cause and a context are set, only the cause should be
@@ -289,11 +282,11 @@ class BaseExceptionReportingTests:
self.assertEqual(len(blocks), 3)
self.assertEqual(blocks[1], cause_message)
# The first block is the KeyError raised from the ZeroDivisionError
- self.assertTrue('raise KeyError from e' in blocks[0])
- self.assertTrue('1/0' not in blocks[0])
+ self.assertIn('raise KeyError from e', blocks[0])
+ self.assertNotIn('1/0', blocks[0])
# The second block (apart from the boundary) is the ZeroDivisionError
# re-raised from the KeyError
- self.assertTrue('inner_raise() # Marker' in blocks[2])
+ self.assertIn('inner_raise() # Marker', blocks[2])
self.check_zero_div(blocks[2])
def test_syntax_error_offset_at_eol(self):
diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk_guionly.py
index d70863a287..bff4fc168b 100644
--- a/Lib/test/test_ttk_guionly.py
+++ b/Lib/test/test_ttk_guionly.py
@@ -1,5 +1,4 @@
import os
-import sys
import unittest
from test import support
diff --git a/Lib/test/test_ttk_textonly.py b/Lib/test/test_ttk_textonly.py
index b99625a189..566fc9d09a 100644
--- a/Lib/test/test_ttk_textonly.py
+++ b/Lib/test/test_ttk_textonly.py
@@ -1,5 +1,4 @@
import os
-import sys
from test import support
# Skip this test if _tkinter does not exist.
diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py
index f5837479ea..75fbe45ec4 100644
--- a/Lib/test/test_tuple.py
+++ b/Lib/test/test_tuple.py
@@ -96,6 +96,7 @@ class TupleTest(seq_tests.CommonTest):
gc.collect()
self.assertTrue(gc.is_tracked(t), t)
+ @support.cpython_only
def test_track_literals(self):
# Test GC-optimization of tuple literals
x, y, z = 1.5, "a", []
@@ -136,16 +137,19 @@ class TupleTest(seq_tests.CommonTest):
self._tracked(tp(tuple([obj]) for obj in [x, y, z]))
self._tracked(tuple(tp([obj]) for obj in [x, y, z]))
+ @support.cpython_only
def test_track_dynamic(self):
# Test GC-optimization of dynamically constructed tuples.
self.check_track_dynamic(tuple, False)
+ @support.cpython_only
def test_track_subtypes(self):
# Tuple subtypes must always be tracked
class MyTuple(tuple):
pass
self.check_track_dynamic(MyTuple, True)
+ @support.cpython_only
def test_bug7466(self):
# Trying to untrack an unfinished tuple could crash Python
self._not_tracked(tuple(gc.collect() for i in range(101)))
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index d227ab1e2b..8a98a03567 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -10,17 +10,14 @@ class TypesTests(unittest.TestCase):
def test_truth_values(self):
if None: self.fail('None is true instead of false')
if 0: self.fail('0 is true instead of false')
- if 0: self.fail('0L is true instead of false')
if 0.0: self.fail('0.0 is true instead of false')
if '': self.fail('\'\' is true instead of false')
if not 1: self.fail('1 is false instead of true')
- if not 1: self.fail('1L is false instead of true')
if not 1.0: self.fail('1.0 is false instead of true')
if not 'x': self.fail('\'x\' is false instead of true')
if not {'x': 1}: self.fail('{\'x\': 1} is false instead of true')
def f(): pass
class C: pass
- import sys
x = C()
if not f: self.fail('f is false instead of true')
if not C: self.fail('C is false instead of true')
@@ -36,8 +33,6 @@ class TypesTests(unittest.TestCase):
def test_comparisons(self):
if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass
else: self.fail('int comparisons failed')
- if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass
- else: self.fail('long int comparisons failed')
if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass
else: self.fail('float comparisons failed')
if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass
@@ -75,18 +70,13 @@ class TypesTests(unittest.TestCase):
else: self.fail("5 % 0 didn't raise ZeroDivisionError")
def test_numeric_types(self):
- if 0 != 0 or 0 != 0.0 or 0 != 0.0: self.fail('mixed comparisons')
- if 1 != 1 or 1 != 1.0 or 1 != 1.0: self.fail('mixed comparisons')
- if -1 != -1 or -1 != -1.0 or -1 != -1.0:
- self.fail('int/long/float value not equal')
+ if 0 != 0.0 or 1 != 1.0 or -1 != -1.0:
+ self.fail('int/float value not equal')
# calling built-in types without argument must return 0
if int() != 0: self.fail('int() does not return 0')
- if int() != 0: self.fail('long() does not return 0')
if float() != 0.0: self.fail('float() does not return 0.0')
if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass
else: self.fail('int() does not round properly')
- if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass
- else: self.fail('long() does not round properly')
if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass
else: self.fail('float() does not work properly')
@@ -141,58 +131,38 @@ class TypesTests(unittest.TestCase):
if type(prod) is not int:
self.fail("expected type(prod) to be int, not %r" %
type(prod))
- # Check for expected * overflow to long.
+ # Check for unified integral type
for divisor in 1, 2, 4, 8, 16, 32:
j = m // divisor - 1
prod = divisor * j
if type(prod) is not int:
- self.fail("expected type(%r) to be long, not %r" %
+ self.fail("expected type(%r) to be int, not %r" %
(prod, type(prod)))
- # Check for expected * overflow to long.
+ # Check for unified integral type
m = sys.maxsize
for divisor in 1, 2, 4, 8, 16, 32:
j = m // divisor + 1
prod = divisor * j
if type(prod) is not int:
- self.fail("expected type(%r) to be long, not %r" %
+ self.fail("expected type(%r) to be int, not %r" %
(prod, type(prod)))
- def test_long_integers(self):
- if 12 + 24 != 36: self.fail('long op')
- if 12 + (-24) != -12: self.fail('long op')
- if (-12) + 24 != 12: self.fail('long op')
- if (-12) + (-24) != -36: self.fail('long op')
- if not 12 < 24: self.fail('long op')
- if not -24 < -12: self.fail('long op')
x = sys.maxsize
- if int(int(x)) != x: self.fail('long op')
- try: y = int(int(x)+1)
- except OverflowError: self.fail('long op')
- if not isinstance(y, int): self.fail('long op')
- x = -x
- if int(int(x)) != x: self.fail('long op')
- x = x-1
- if int(int(x)) != x: self.fail('long op')
- try: y = int(int(x)-1)
- except OverflowError: self.fail('long op')
- if not isinstance(y, int): self.fail('long op')
+ self.assertIsInstance(x + 1, int,
+ "(sys.maxsize + 1) should have returned int")
+ self.assertIsInstance(-x - 1, int,
+ "(-sys.maxsize - 1) should have returned int")
+ self.assertIsInstance(-x - 2, int,
+ "(-sys.maxsize - 2) should have returned int")
try: 5 << -5
except ValueError: pass
else: self.fail('int negative shift <<')
- try: 5 << -5
- except ValueError: pass
- else: self.fail('long negative shift <<')
-
try: 5 >> -5
except ValueError: pass
else: self.fail('int negative shift >>')
- try: 5 >> -5
- except ValueError: pass
- else: self.fail('long negative shift >>')
-
def test_floats(self):
if 12.0 + 24.0 != 36.0: self.fail('float op')
if 12.0 + (-24.0) != -12.0: self.fail('float op')
@@ -232,7 +202,7 @@ class TypesTests(unittest.TestCase):
def test_int__format__(self):
def test(i, format_spec, result):
- # just make sure I'm not accidentally checking longs
+ # just make sure we have the unified type for integers
assert type(i) == int
assert type(format_spec) == str
self.assertEqual(i.__format__(format_spec), result)
@@ -353,6 +323,10 @@ class TypesTests(unittest.TestCase):
# issue 5782, commas with no specifier type
test(1234, '010,', '00,001,234')
+ # Unified type for integers
+ test(10**100, 'd', '1' + '0' * 100)
+ test(10**100+100, 'd', '1' + '0' * 97 + '100')
+
# make sure these are errors
# precision disallowed
@@ -393,96 +367,6 @@ class TypesTests(unittest.TestCase):
test(123456, "1=20", '11111111111111123456')
test(123456, "*=20", '**************123456')
- def test_long__format__(self):
- def test(i, format_spec, result):
- # make sure we're not accidentally checking ints
- assert type(i) == int
- assert type(format_spec) == str
- self.assertEqual(i.__format__(format_spec), result)
-
- test(10**100, 'd', '1' + '0' * 100)
- test(10**100+100, 'd', '1' + '0' * 97 + '100')
-
- test(123456789, 'd', '123456789')
- test(123456789, 'd', '123456789')
-
- # sign and aligning are interdependent
- test(1, "-", '1')
- test(-1, "-", '-1')
- test(1, "-3", ' 1')
- test(-1, "-3", ' -1')
- test(1, "+3", ' +1')
- test(-1, "+3", ' -1')
- test(1, " 3", ' 1')
- test(-1, " 3", ' -1')
- test(1, " ", ' 1')
- test(-1, " ", '-1')
-
- test(1, 'c', '\01')
-
- # hex
- test(3, "x", "3")
- test(3, "X", "3")
- test(1234, "x", "4d2")
- test(-1234, "x", "-4d2")
- test(1234, "8x", " 4d2")
- test(-1234, "8x", " -4d2")
- test(1234, "x", "4d2")
- test(-1234, "x", "-4d2")
- test(-3, "x", "-3")
- test(-3, "X", "-3")
-
- # octal
- test(3, "o", "3")
- test(-3, "o", "-3")
- test(65, "o", "101")
- test(-65, "o", "-101")
- test(1234, "o", "2322")
- test(-1234, "o", "-2322")
- test(1234, "-o", "2322")
- test(-1234, "-o", "-2322")
- test(1234, " o", " 2322")
- test(-1234, " o", "-2322")
- test(1234, "+o", "+2322")
- test(-1234, "+o", "-2322")
-
- # binary
- test(3, "b", "11")
- test(-3, "b", "-11")
- test(1234, "b", "10011010010")
- test(-1234, "b", "-10011010010")
- test(1234, "-b", "10011010010")
- test(-1234, "-b", "-10011010010")
- test(1234, " b", " 10011010010")
- test(-1234, " b", "-10011010010")
- test(1234, "+b", "+10011010010")
- test(-1234, "+b", "-10011010010")
-
- # make sure these are errors
-
- # precision disallowed
- self.assertRaises(ValueError, 3 .__format__, "1.3")
- # sign not allowed with 'c'
- self.assertRaises(ValueError, 3 .__format__, "+c")
- # format spec must be string
- self.assertRaises(TypeError, 3 .__format__, None)
- self.assertRaises(TypeError, 3 .__format__, 0)
-
- # ensure that only int and float type specifiers work
- for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
- [chr(x) for x in range(ord('A'), ord('Z')+1)]):
- if not format_spec in 'bcdoxXeEfFgGn%':
- self.assertRaises(ValueError, 0 .__format__, format_spec)
- self.assertRaises(ValueError, 1 .__format__, format_spec)
- self.assertRaises(ValueError, (-1) .__format__, format_spec)
-
- # ensure that float type specifiers work; format converts
- # the long to a float
- for format_spec in 'eEfFgG%':
- for value in [0, 1, -1, 100, -100, 1234567890, -1234567890]:
- self.assertEqual(value.__format__(format_spec),
- float(value).__format__(format_spec))
-
@run_with_locale('LC_NUMERIC', 'en_US.UTF8')
def test_float__format__locale(self):
# test locale support for __format__ code 'n'
@@ -512,13 +396,9 @@ class TypesTests(unittest.TestCase):
self.assertEqual(len(format(0, cfmt)), len(format(x, cfmt)))
def test_float__format__(self):
- # these should be rewritten to use both format(x, spec) and
- # x.__format__(spec)
-
def test(f, format_spec, result):
- assert type(f) == float
- assert type(format_spec) == str
self.assertEqual(f.__format__(format_spec), result)
+ self.assertEqual(format(f, format_spec), result)
test(0.0, 'f', '0.000000')
@@ -560,13 +440,13 @@ class TypesTests(unittest.TestCase):
result = f.__format__(fmt)
self.assertEqual(len(result), 98)
self.assertEqual(result[-7], '.')
- self.assertTrue(result[:12] in ('112340000000', '112339999999'))
+ self.assertIn(result[:12], ('112340000000', '112339999999'))
f = 1.1234e200
for fmt in 'f', 'F':
result = f.__format__(fmt)
self.assertEqual(len(result), 208)
self.assertEqual(result[-7], '.')
- self.assertTrue(result[:12] in ('112340000000', '112339999999'))
+ self.assertIn(result[:12], ('112340000000', '112339999999'))
test( 1.0, 'e', '1.000000e+00')
@@ -632,9 +512,27 @@ class TypesTests(unittest.TestCase):
self.assertRaises(ValueError, format, 1e-100, format_spec)
self.assertRaises(ValueError, format, -1e-100, format_spec)
- # Alternate formatting is not supported
- self.assertRaises(ValueError, format, 0.0, '#')
- self.assertRaises(ValueError, format, 0.0, '#20f')
+ # Alternate float formatting
+ test(1.0, '.0e', '1e+00')
+ test(1.0, '#.0e', '1.e+00')
+ test(1.0, '.0f', '1')
+ test(1.0, '#.0f', '1.')
+ test(1.1, 'g', '1.1')
+ test(1.1, '#g', '1.10000')
+ test(1.0, '.0%', '100%')
+ test(1.0, '#.0%', '100.%')
+
+ # Issue 7094: Alternate formatting (specified by #)
+ test(1.0, '0e', '1.000000e+00')
+ test(1.0, '#0e', '1.000000e+00')
+ test(1.0, '0f', '1.000000' )
+ test(1.0, '#0f', '1.000000')
+ test(1.0, '.1e', '1.0e+00')
+ test(1.0, '#.1e', '1.0e+00')
+ test(1.0, '.1f', '1.0')
+ test(1.0, '#.1f', '1.0')
+ test(1.0, '.1%', '100.0%')
+ test(1.0, '#.1%', '100.0%')
# Issue 6902
test(12345.6, "0<20", '12345.60000000000000')
diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py
index 2d48179c59..fd620f01e4 100644
--- a/Lib/test/test_ucn.py
+++ b/Lib/test/test_ucn.py
@@ -88,9 +88,13 @@ class UnicodeNamesTest(unittest.TestCase):
self.checkletter("CJK UNIFIED IDEOGRAPH-3400", "\u3400")
self.checkletter("CJK UNIFIED IDEOGRAPH-4DB5", "\u4db5")
self.checkletter("CJK UNIFIED IDEOGRAPH-4E00", "\u4e00")
- self.checkletter("CJK UNIFIED IDEOGRAPH-9FA5", "\u9fa5")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-9FCB", "\u9fCB")
self.checkletter("CJK UNIFIED IDEOGRAPH-20000", "\U00020000")
self.checkletter("CJK UNIFIED IDEOGRAPH-2A6D6", "\U0002a6d6")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2A700", "\U0002A700")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2B734", "\U0002B734")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2B740", "\U0002B740")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2B81D", "\U0002B81D")
def test_bmp_characters(self):
import unicodedata
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 4793707ac9..65b26c55b2 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -11,6 +11,7 @@ import sys
import unittest
import warnings
from test import support, string_tests
+import _string
# Error handling (bad decoder return)
def search_function(encoding):
@@ -30,18 +31,11 @@ def search_function(encoding):
return None
codecs.register(search_function)
-class UnicodeTest(
- string_tests.CommonTest,
- string_tests.MixinStrUnicodeUserStringTest,
- string_tests.MixinStrUnicodeTest,
- ):
- type2test = str
-
- def setUp(self):
- self.warning_filters = warnings.filters[:]
+class UnicodeTest(string_tests.CommonTest,
+ string_tests.MixinStrUnicodeUserStringTest,
+ string_tests.MixinStrUnicodeTest):
- def tearDown(self):
- warnings.filters = self.warning_filters
+ type2test = str
def checkequalnofix(self, result, object, methodname, *args):
method = getattr(object, methodname)
@@ -282,23 +276,18 @@ class UnicodeTest(
self.assertRaises(TypeError, 'replace'.replace, "r", 42)
def test_bytes_comparison(self):
- warnings.simplefilter('ignore', BytesWarning)
- self.assertEqual('abc' == b'abc', False)
- self.assertEqual('abc' != b'abc', True)
- self.assertEqual('abc' == bytearray(b'abc'), False)
- self.assertEqual('abc' != bytearray(b'abc'), True)
+ with support.check_warnings():
+ warnings.simplefilter('ignore', BytesWarning)
+ self.assertEqual('abc' == b'abc', False)
+ self.assertEqual('abc' != b'abc', True)
+ self.assertEqual('abc' == bytearray(b'abc'), False)
+ self.assertEqual('abc' != bytearray(b'abc'), True)
def test_comparison(self):
# Comparisons:
self.assertEqual('abc', 'abc')
- self.assertEqual('abc', 'abc')
- self.assertEqual('abc', 'abc')
- self.assertTrue('abcd' > 'abc')
- self.assertTrue('abcd' > 'abc')
self.assertTrue('abcd' > 'abc')
self.assertTrue('abc' < 'abcd')
- self.assertTrue('abc' < 'abcd')
- self.assertTrue('abc' < 'abcd')
if 0:
# Move these tests to a Unicode collation module test...
@@ -435,32 +424,32 @@ class UnicodeTest(
def test_contains(self):
# Testing Unicode contains method
- self.assertTrue('a' in 'abdb')
- self.assertTrue('a' in 'bdab')
- self.assertTrue('a' in 'bdaba')
- self.assertTrue('a' in 'bdba')
- self.assertTrue('a' not in 'bdb')
- self.assertTrue('a' in 'bdba')
- self.assertTrue('a' in ('a',1,None))
- self.assertTrue('a' in (1,None,'a'))
- self.assertTrue('a' in ('a',1,None))
- self.assertTrue('a' in (1,None,'a'))
- self.assertTrue('a' not in ('x',1,'y'))
- self.assertTrue('a' not in ('x',1,None))
- self.assertTrue('abcd' not in 'abcxxxx')
- self.assertTrue('ab' in 'abcd')
- self.assertTrue('ab' in 'abc')
- self.assertTrue('ab' in (1,None,'ab'))
- self.assertTrue('' in 'abc')
- self.assertTrue('' in '')
- self.assertTrue('' in 'abc')
- self.assertTrue('\0' not in 'abc')
- self.assertTrue('\0' in '\0abc')
- self.assertTrue('\0' in 'abc\0')
- self.assertTrue('a' in '\0abc')
- self.assertTrue('asdf' in 'asdf')
- self.assertTrue('asdf' not in 'asd')
- self.assertTrue('asdf' not in '')
+ self.assertIn('a', 'abdb')
+ self.assertIn('a', 'bdab')
+ self.assertIn('a', 'bdaba')
+ self.assertIn('a', 'bdba')
+ self.assertNotIn('a', 'bdb')
+ self.assertIn('a', 'bdba')
+ self.assertIn('a', ('a',1,None))
+ self.assertIn('a', (1,None,'a'))
+ self.assertIn('a', ('a',1,None))
+ self.assertIn('a', (1,None,'a'))
+ self.assertNotIn('a', ('x',1,'y'))
+ self.assertNotIn('a', ('x',1,None))
+ self.assertNotIn('abcd', 'abcxxxx')
+ self.assertIn('ab', 'abcd')
+ self.assertIn('ab', 'abc')
+ self.assertIn('ab', (1,None,'ab'))
+ self.assertIn('', 'abc')
+ self.assertIn('', '')
+ self.assertIn('', 'abc')
+ self.assertNotIn('\0', 'abc')
+ self.assertIn('\0', '\0abc')
+ self.assertIn('\0', 'abc\0')
+ self.assertIn('a', '\0abc')
+ self.assertIn('asdf', 'asdf')
+ self.assertNotIn('asdf', 'asd')
+ self.assertNotIn('asdf', '')
self.assertRaises(TypeError, "abc".__contains__)
@@ -620,13 +609,16 @@ class UnicodeTest(
self.assertEqual('{0}'.format({}), '{}')
self.assertEqual('{0}'.format([]), '[]')
self.assertEqual('{0}'.format([1]), '[1]')
- self.assertEqual('{0}'.format(E('data')), 'E(data)')
- self.assertEqual('{0:^10}'.format(E('data')), ' E(data) ')
- self.assertEqual('{0:^10s}'.format(E('data')), ' E(data) ')
+
self.assertEqual('{0:d}'.format(G('data')), 'G(data)')
- self.assertEqual('{0:>15s}'.format(G('data')), ' string is data')
self.assertEqual('{0!s}'.format(G('data')), 'string is data')
+ msg = 'object.__format__ with a non-empty format string is deprecated'
+ with support.check_warnings((msg, PendingDeprecationWarning)):
+ self.assertEqual('{0:^10}'.format(E('data')), ' E(data) ')
+ self.assertEqual('{0:^10s}'.format(E('data')), ' E(data) ')
+ self.assertEqual('{0:>15s}'.format(G('data')), ' string is data')
+
self.assertEqual("{0:date: %Y-%m-%d}".format(I(year=2007,
month=8,
day=27)),
@@ -657,8 +649,6 @@ class UnicodeTest(
self.assertRaises(IndexError, '{1}'.format, 'abc')
self.assertRaises(KeyError, '{x}'.format)
self.assertRaises(ValueError, "}{".format)
- self.assertRaises(ValueError, "{".format)
- self.assertRaises(ValueError, "}".format)
self.assertRaises(ValueError, "abc{0:{}".format)
self.assertRaises(ValueError, "{0".format)
self.assertRaises(IndexError, "{0.}".format)
@@ -706,6 +696,46 @@ class UnicodeTest(
self.assertRaises(ValueError, format, '', '#')
self.assertRaises(ValueError, format, '', '#20')
+ def test_format_map(self):
+ self.assertEqual(''.format_map({}), '')
+ self.assertEqual('a'.format_map({}), 'a')
+ self.assertEqual('ab'.format_map({}), 'ab')
+ self.assertEqual('a{{'.format_map({}), 'a{')
+ self.assertEqual('a}}'.format_map({}), 'a}')
+ self.assertEqual('{{b'.format_map({}), '{b')
+ self.assertEqual('}}b'.format_map({}), '}b')
+ self.assertEqual('a{{b'.format_map({}), 'a{b')
+
+ # using mappings
+ class Mapping(dict):
+ def __missing__(self, key):
+ return key
+ self.assertEqual('{hello}'.format_map(Mapping()), 'hello')
+ self.assertEqual('{a} {world}'.format_map(Mapping(a='hello')), 'hello world')
+
+ class InternalMapping:
+ def __init__(self):
+ self.mapping = {'a': 'hello'}
+ def __getitem__(self, key):
+ return self.mapping[key]
+ self.assertEqual('{a}'.format_map(InternalMapping()), 'hello')
+
+
+ class C:
+ def __init__(self, x=100):
+ self._x = x
+ def __format__(self, spec):
+ return spec
+ self.assertEqual('{foo._x}'.format_map({'foo': C(20)}), '20')
+
+ # test various errors
+ self.assertRaises(TypeError, '{'.format_map)
+ self.assertRaises(TypeError, '}'.format_map)
+ self.assertRaises(TypeError, 'a{'.format_map)
+ self.assertRaises(TypeError, 'a}'.format_map)
+ self.assertRaises(TypeError, '{a'.format_map)
+ self.assertRaises(TypeError, '}a'.format_map)
+
def test_format_auto_numbering(self):
class C:
def __init__(self, x=100):
@@ -1106,6 +1136,10 @@ class UnicodeTest(
self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii','strict')
self.assertEqual('Andr\202 x'.encode('ascii','ignore'), b"Andr x")
self.assertEqual('Andr\202 x'.encode('ascii','replace'), b"Andr? x")
+ self.assertEqual('Andr\202 x'.encode('ascii', 'replace'),
+ 'Andr\202 x'.encode('ascii', errors='replace'))
+ self.assertEqual('Andr\202 x'.encode('ascii', 'ignore'),
+ 'Andr\202 x'.encode(encoding='ascii', errors='ignore'))
# Error handling (decoding)
self.assertRaises(UnicodeError, str, b'Andr\202 x', 'ascii')
@@ -1135,8 +1169,13 @@ class UnicodeTest(
# Error handling (wrong arguments)
self.assertRaises(TypeError, "hello".encode, 42, 42, 42)
- # Error handling (PyUnicode_EncodeDecimal())
- self.assertRaises(UnicodeError, int, "\u0200")
+ # Error handling (lone surrogate in PyUnicode_TransformDecimalToASCII())
+ self.assertRaises(UnicodeError, int, "\ud800")
+ self.assertRaises(UnicodeError, int, "\udf00")
+ self.assertRaises(UnicodeError, float, "\ud800")
+ self.assertRaises(UnicodeError, float, "\udf00")
+ self.assertRaises(UnicodeError, complex, "\ud800")
+ self.assertRaises(UnicodeError, complex, "\udf00")
def test_codecs(self):
# Encoding
@@ -1189,8 +1228,8 @@ class UnicodeTest(
s = bytes(range(128))
for encoding in (
'cp037', 'cp1026',
- 'cp437', 'cp500', 'cp737', 'cp775', 'cp850',
- 'cp852', 'cp855', 'cp860', 'cp861', 'cp862',
+ 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850',
+ 'cp852', 'cp855', 'cp858', 'cp860', 'cp861', 'cp862',
'cp863', 'cp865', 'cp866',
'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15',
'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6',
@@ -1217,8 +1256,8 @@ class UnicodeTest(
s = bytes(range(128, 256))
for encoding in (
'cp037', 'cp1026',
- 'cp437', 'cp500', 'cp737', 'cp775', 'cp850',
- 'cp852', 'cp855', 'cp860', 'cp861', 'cp862',
+ 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850',
+ 'cp852', 'cp855', 'cp858', 'cp860', 'cp861', 'cp862',
'cp863', 'cp865', 'cp866',
'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15',
'iso8859_2', 'iso8859_4', 'iso8859_5',
@@ -1266,21 +1305,20 @@ class UnicodeTest(
y = x.encode("raw-unicode-escape").decode("raw-unicode-escape")
self.assertEqual(x, y)
- # FIXME
- #y = r'\U00100000'
- #x = y.encode("raw-unicode-escape").decode("raw-unicode-escape")
- #self.assertEqual(x, y)
- #y = r'\U00010000'
- #x = y.encode("raw-unicode-escape").decode("raw-unicode-escape")
- #self.assertEqual(x, y)
-
- #try:
- # '\U11111111'.decode("raw-unicode-escape")
- #except UnicodeDecodeError as e:
- # self.assertEqual(e.start, 0)
- # self.assertEqual(e.end, 10)
- #else:
- # self.fail("Should have raised UnicodeDecodeError")
+ y = br'\U00100000'
+ x = y.decode("raw-unicode-escape").encode("raw-unicode-escape")
+ self.assertEqual(x, y)
+ y = br'\U00010000'
+ x = y.decode("raw-unicode-escape").encode("raw-unicode-escape")
+ self.assertEqual(x, y)
+
+ try:
+ br'\U11111111'.decode("raw-unicode-escape")
+ except UnicodeDecodeError as e:
+ self.assertEqual(e.start, 0)
+ self.assertEqual(e.end, 10)
+ else:
+ self.fail("Should have raised UnicodeDecodeError")
def test_conversion(self):
# Make sure __unicode__() works properly
@@ -1354,6 +1392,10 @@ class UnicodeTest(
self.assertEqual(repr(s1()), '\\n')
self.assertEqual(repr(s2()), '\\n')
+ def test_printable_repr(self):
+ self.assertEqual(repr('\U00010000'), "'%c'" % (0x10000,)) # printable
+ self.assertEqual(repr('\U00014000'), "'\\U00014000'") # nonprintable
+
def test_expandtabs_overflows_gracefully(self):
# This test only affects 32-bit platforms because expandtabs can only take
# an int as the max value, not a 64-bit C long. If expandtabs is changed
@@ -1382,6 +1424,165 @@ class UnicodeTest(
self.assertEqual("%s" % s, '__str__ overridden')
self.assertEqual("{}".format(s), '__str__ overridden')
+ # Test PyUnicode_FromFormat()
+ def test_from_format(self):
+ support.import_module('ctypes')
+ from ctypes import pythonapi, py_object, c_int
+ if sys.maxunicode == 65535:
+ name = "PyUnicodeUCS2_FromFormat"
+ else:
+ name = "PyUnicodeUCS4_FromFormat"
+ _PyUnicode_FromFormat = getattr(pythonapi, name)
+ _PyUnicode_FromFormat.restype = py_object
+
+ def PyUnicode_FromFormat(format, *args):
+ cargs = tuple(
+ py_object(arg) if isinstance(arg, str) else arg
+ for arg in args)
+ return _PyUnicode_FromFormat(format, *cargs)
+
+ # ascii format, non-ascii argument
+ text = PyUnicode_FromFormat(b'ascii\x7f=%U', 'unicode\xe9')
+ self.assertEqual(text, 'ascii\x7f=unicode\xe9')
+
+ # non-ascii format, ascii argument: ensure that PyUnicode_FromFormatV()
+ # raises an error
+ self.assertRaisesRegex(ValueError,
+ '^PyUnicode_FromFormatV\(\) expects an ASCII-encoded format '
+ 'string, got a non-ASCII byte: 0xe9$',
+ PyUnicode_FromFormat, b'unicode\xe9=%s', 'ascii')
+
+ self.assertEqual(PyUnicode_FromFormat(b'%c', c_int(0xabcd)), '\uabcd')
+ self.assertEqual(PyUnicode_FromFormat(b'%c', c_int(0x10ffff)), '\U0010ffff')
+
+ # other tests
+ text = PyUnicode_FromFormat(b'%%A:%A', 'abc\xe9\uabcd\U0010ffff')
+ self.assertEqual(text, r"%A:'abc\xe9\uabcd\U0010ffff'")
+
+ text = PyUnicode_FromFormat(b'repr=%V', 'abc', b'xyz')
+ self.assertEqual(text, 'repr=abc')
+
+ # Test string decode from parameter of %s using utf-8.
+ # b'\xe4\xba\xba\xe6\xb0\x91' is utf-8 encoded byte sequence of
+ # '\u4eba\u6c11'
+ text = PyUnicode_FromFormat(b'repr=%V', None, b'\xe4\xba\xba\xe6\xb0\x91')
+ self.assertEqual(text, 'repr=\u4eba\u6c11')
+
+ #Test replace error handler.
+ text = PyUnicode_FromFormat(b'repr=%V', None, b'abc\xff')
+ self.assertEqual(text, 'repr=abc\ufffd')
+
+ # Test PyUnicode_AsWideChar()
+ def test_aswidechar(self):
+ from _testcapi import unicode_aswidechar
+ support.import_module('ctypes')
+ from ctypes import c_wchar, sizeof
+
+ wchar, size = unicode_aswidechar('abcdef', 2)
+ self.assertEqual(size, 2)
+ self.assertEqual(wchar, 'ab')
+
+ wchar, size = unicode_aswidechar('abc', 3)
+ self.assertEqual(size, 3)
+ self.assertEqual(wchar, 'abc')
+
+ wchar, size = unicode_aswidechar('abc', 4)
+ self.assertEqual(size, 3)
+ self.assertEqual(wchar, 'abc\0')
+
+ wchar, size = unicode_aswidechar('abc', 10)
+ self.assertEqual(size, 3)
+ self.assertEqual(wchar, 'abc\0')
+
+ wchar, size = unicode_aswidechar('abc\0def', 20)
+ self.assertEqual(size, 7)
+ self.assertEqual(wchar, 'abc\0def\0')
+
+ nonbmp = chr(0x10ffff)
+ if sizeof(c_wchar) == 2:
+ buflen = 3
+ nchar = 2
+ else: # sizeof(c_wchar) == 4
+ buflen = 2
+ nchar = 1
+ wchar, size = unicode_aswidechar(nonbmp, buflen)
+ self.assertEqual(size, nchar)
+ self.assertEqual(wchar, nonbmp + '\0')
+
+ # Test PyUnicode_AsWideCharString()
+ def test_aswidecharstring(self):
+ from _testcapi import unicode_aswidecharstring
+ support.import_module('ctypes')
+ from ctypes import c_wchar, sizeof
+
+ wchar, size = unicode_aswidecharstring('abc')
+ self.assertEqual(size, 3)
+ self.assertEqual(wchar, 'abc\0')
+
+ wchar, size = unicode_aswidecharstring('abc\0def')
+ self.assertEqual(size, 7)
+ self.assertEqual(wchar, 'abc\0def\0')
+
+ nonbmp = chr(0x10ffff)
+ if sizeof(c_wchar) == 2:
+ nchar = 2
+ else: # sizeof(c_wchar) == 4
+ nchar = 1
+ wchar, size = unicode_aswidecharstring(nonbmp)
+ self.assertEqual(size, nchar)
+ self.assertEqual(wchar, nonbmp + '\0')
+
+
+class StringModuleTest(unittest.TestCase):
+ def test_formatter_parser(self):
+ def parse(format):
+ return list(_string.formatter_parser(format))
+
+ formatter = parse("prefix {2!s}xxx{0:^+10.3f}{obj.attr!s} {z[0]!s:10}")
+ self.assertEqual(formatter, [
+ ('prefix ', '2', '', 's'),
+ ('xxx', '0', '^+10.3f', None),
+ ('', 'obj.attr', '', 's'),
+ (' ', 'z[0]', '10', 's'),
+ ])
+
+ formatter = parse("prefix {} suffix")
+ self.assertEqual(formatter, [
+ ('prefix ', '', '', None),
+ (' suffix', None, None, None),
+ ])
+
+ formatter = parse("str")
+ self.assertEqual(formatter, [
+ ('str', None, None, None),
+ ])
+
+ formatter = parse("")
+ self.assertEqual(formatter, [])
+
+ formatter = parse("{0}")
+ self.assertEqual(formatter, [
+ ('', '0', '', None),
+ ])
+
+ self.assertRaises(TypeError, _string.formatter_parser, 1)
+
+ def test_formatter_field_name_split(self):
+ def split(name):
+ items = list(_string.formatter_field_name_split(name))
+ items[1] = list(items[1])
+ return items
+ self.assertEqual(split("obj"), ["obj", []])
+ self.assertEqual(split("obj.arg"), ["obj", [(True, 'arg')]])
+ self.assertEqual(split("obj[key]"), ["obj", [(False, 'key')]])
+ self.assertEqual(split("obj.arg[key1][key2]"), [
+ "obj",
+ [(True, 'arg'),
+ (False, 'key1'),
+ (False, 'key2'),
+ ]])
+ self.assertRaises(TypeError, _string.formatter_field_name_split, 1)
+
def test_main():
support.run_unittest(__name__)
diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py
index 59ab85e3ad..6c2011ace8 100644
--- a/Lib/test/test_unicode_file.py
+++ b/Lib/test/test_unicode_file.py
@@ -5,14 +5,16 @@ import os, glob, time, shutil
import unicodedata
import unittest
-from test.support import run_unittest, TESTFN_UNICODE, rmtree
-from test.support import TESTFN_ENCODING, TESTFN_UNENCODABLE
-try:
- TESTFN_UNICODE.encode(TESTFN_ENCODING)
-except (UnicodeError, TypeError):
- # Either the file system encoding is None, or the file name
- # cannot be encoded in the file system encoding.
- raise unittest.SkipTest("No Unicode filesystem semantics on this platform.")
+from test.support import (run_unittest, rmtree,
+ TESTFN_ENCODING, TESTFN_UNICODE, TESTFN_UNENCODABLE)
+
+if not os.path.supports_unicode_filenames:
+ try:
+ TESTFN_UNICODE.encode(TESTFN_ENCODING)
+ except (UnicodeError, TypeError):
+ # Either the file system encoding is None, or the file name
+ # cannot be encoded in the file system encoding.
+ raise unittest.SkipTest("No Unicode filesystem semantics on this platform.")
def remove_if_exists(filename):
if os.path.exists(filename):
@@ -47,23 +49,7 @@ class TestUnicodeFiles(unittest.TestCase):
base = unicodedata.normalize("NFD", base)
file_list = [unicodedata.normalize("NFD", f) for f in file_list]
- self.assertTrue(base in file_list)
-
- # Do as many "equivalancy' tests as we can - ie, check that although we
- # have different types for the filename, they refer to the same file.
- def _do_equivalent(self, filename1, filename2):
- # Note we only check "filename1 against filename2" - we don't bother
- # checking "filename2 against 1", as we assume we are called again with
- # the args reversed.
- self.assertTrue(type(filename1)!=type(filename2),
- "No point checking equivalent filenames of the same type")
- # stat and lstat should return the same results.
- self.assertEqual(os.stat(filename1),
- os.stat(filename2))
- self.assertEqual(os.lstat(filename1),
- os.lstat(filename2))
- # Copy/rename etc tests using equivalent filename
- self._do_copyish(filename1, filename2)
+ self.assertIn(base, file_list)
# Tests that copy, move, etc one file to another.
def _do_copyish(self, filename1, filename2):
@@ -89,7 +75,7 @@ class TestUnicodeFiles(unittest.TestCase):
shutil.copy2(filename1, filename2 + ".new")
os.unlink(filename1 + ".new")
- def _do_directory(self, make_name, chdir_name, encoded):
+ def _do_directory(self, make_name, chdir_name):
cwd = os.getcwdb()
if os.path.isdir(make_name):
rmtree(make_name)
@@ -97,12 +83,8 @@ class TestUnicodeFiles(unittest.TestCase):
try:
os.chdir(chdir_name)
try:
- if not encoded:
- cwd_result = os.getcwd()
- name_result = make_name
- else:
- cwd_result = os.getcwdb().decode(TESTFN_ENCODING)
- name_result = make_name.decode(TESTFN_ENCODING)
+ cwd_result = os.getcwd()
+ name_result = make_name
cwd_result = unicodedata.normalize("NFD", cwd_result)
name_result = unicodedata.normalize("NFD", name_result)
@@ -132,16 +114,6 @@ class TestUnicodeFiles(unittest.TestCase):
finally:
os.unlink(filename)
- def _test_equivalent(self, filename1, filename2):
- remove_if_exists(filename1)
- self.assertTrue(not os.path.exists(filename2))
- f = file(filename1, "w")
- f.close()
- try:
- self._do_equivalent(filename1, filename2)
- finally:
- os.unlink(filename1)
-
# The 'test' functions are unittest entry points, and simply call our
# _test functions with each of the filename combinations we wish to test
def test_single_files(self):
@@ -154,12 +126,11 @@ class TestUnicodeFiles(unittest.TestCase):
# Make dir with encoded, chdir with unicode, checkdir with encoded
# (or unicode/encoded/unicode, etc
ext = ".dir"
- self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext, False)
+ self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext)
# Our directory name that can't use a non-unicode name.
if TESTFN_UNENCODABLE is not None:
self._do_directory(TESTFN_UNENCODABLE+ext,
- TESTFN_UNENCODABLE+ext,
- False)
+ TESTFN_UNENCODABLE+ext)
def test_main():
run_unittest(__name__)
diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
index 0862c9bef4..97442564e7 100644
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -21,11 +21,11 @@ errors = 'surrogatepass'
class UnicodeMethodsTest(unittest.TestCase):
# update this, if the database changes
- expectedchecksum = '6ec65b65835614ec00634c674bba0e50cd32c189'
+ expectedchecksum = '21b90f1aed00081b81ca7942b22196af090015a0'
def test_method_checksum(self):
h = hashlib.sha1()
- for i in range(65536):
+ for i in range(0x10000):
char = chr(i)
data = [
# Predicates (single char)
@@ -80,8 +80,7 @@ class UnicodeDatabaseTest(unittest.TestCase):
class UnicodeFunctionsTest(UnicodeDatabaseTest):
# update this, if the database changes
- expectedchecksum = '3136d5afd787dc2bcb1bdcac95e385349fbebbca'
-
+ expectedchecksum = 'c23dfc0b5eaf3ca2aad32d733de96bb182ccda50'
def test_function_checksum(self):
data = []
h = hashlib.sha1()
@@ -90,9 +89,9 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
char = chr(i)
data = [
# Properties
- str(self.db.digit(char, -1)),
- str(self.db.numeric(char, -1)),
- str(self.db.decimal(char, -1)),
+ format(self.db.digit(char, -1), '.12g'),
+ format(self.db.numeric(char, -1), '.12g'),
+ format(self.db.decimal(char, -1), '.12g'),
self.db.category(char),
self.db.bidirectional(char),
self.db.decomposition(char),
@@ -119,6 +118,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
self.assertEqual(self.db.numeric('9'), 9)
self.assertEqual(self.db.numeric('\u215b'), 0.125)
self.assertEqual(self.db.numeric('\u2468'), 9.0)
+ self.assertEqual(self.db.numeric('\ua627'), 7.0)
self.assertEqual(self.db.numeric('\U00020000', None), None)
self.assertRaises(TypeError, self.db.numeric)
@@ -237,7 +237,8 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
self.assertEqual(popen.returncode, 1)
error = "SyntaxError: (unicode error) \\N escapes not supported " \
"(can't load unicodedata module)"
- self.assertTrue(error in popen.stderr.read().decode("ascii"))
+ self.assertIn(error, popen.stderr.read().decode("ascii"))
+ popen.stderr.close()
def test_decimal_numeric_consistent(self):
# Test that decimal and numeric are consistent,
@@ -296,6 +297,25 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
self.assertEqual("\u01c5".title(), "\u01c5")
self.assertEqual("\u01c6".title(), "\u01c5")
+ def test_linebreak_7643(self):
+ for i in range(0x10000):
+ lines = (chr(i) + 'A').splitlines()
+ if i in (0x0a, 0x0b, 0x0c, 0x0d, 0x85,
+ 0x1c, 0x1d, 0x1e, 0x2028, 0x2029):
+ self.assertEqual(len(lines), 2,
+ r"\u%.4x should be a linebreak" % i)
+ else:
+ self.assertEqual(len(lines), 1,
+ r"\u%.4x should not be a linebreak" % i)
+
+ def test_UCS4(self):
+ # unicodedata should work with code points outside the BMP
+ # even on a narrow Unicode build
+ self.assertEqual(self.db.category("\U0001012A"), "No")
+ self.assertEqual(self.db.numeric("\U0001012A"), 9000)
+ self.assertEqual(self.db.decimal("\U0001D7FD"), 7)
+ self.assertEqual(self.db.digit("\U0001D7FD"), 7)
+
def test_main():
test.support.run_unittest(
UnicodeMiscTest,
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
index 21e0806a31..bfc3ded6f1 100644
--- a/Lib/test/test_unittest.py
+++ b/Lib/test/test_unittest.py
@@ -1,3361 +1,16 @@
-"""Test script for unittest.
+import unittest.test
-By Collin Winter <collinw at gmail.com>
-
-Still need testing:
- TestCase.{assert,fail}* methods (some are tested implicitly)
-"""
-
-import re
from test import support
-import unittest
-from unittest import TestCase, TestProgram
-import types
-from copy import deepcopy
-import io
-
-### Support code
-################################################################
-
-class LoggingResult(unittest.TestResult):
- def __init__(self, log):
- self._events = log
- super().__init__()
-
- def startTest(self, test):
- self._events.append('startTest')
- super().startTest(test)
-
- def startTestRun(self):
- self._events.append('startTestRun')
- super(LoggingResult, self).startTestRun()
-
- def stopTest(self, test):
- self._events.append('stopTest')
- super().stopTest(test)
-
- def stopTestRun(self):
- self._events.append('stopTestRun')
- super(LoggingResult, self).stopTestRun()
-
- def addFailure(self, *args):
- self._events.append('addFailure')
- super().addFailure(*args)
-
- def addSuccess(self, *args):
- self._events.append('addSuccess')
- super(LoggingResult, self).addSuccess(*args)
-
- def addError(self, *args):
- self._events.append('addError')
- super().addError(*args)
-
- def addSkip(self, *args):
- self._events.append('addSkip')
- super(LoggingResult, self).addSkip(*args)
-
- def addExpectedFailure(self, *args):
- self._events.append('addExpectedFailure')
- super(LoggingResult, self).addExpectedFailure(*args)
-
- def addUnexpectedSuccess(self, *args):
- self._events.append('addUnexpectedSuccess')
- super(LoggingResult, self).addUnexpectedSuccess(*args)
-
-
-class TestEquality(object):
- """Used as a mixin for TestCase"""
-
- # Check for a valid __eq__ implementation
- def test_eq(self):
- for obj_1, obj_2 in self.eq_pairs:
- self.assertEqual(obj_1, obj_2)
- self.assertEqual(obj_2, obj_1)
-
- # Check for a valid __ne__ implementation
- def test_ne(self):
- for obj_1, obj_2 in self.ne_pairs:
- self.assertNotEqual(obj_1, obj_2)
- self.assertNotEqual(obj_2, obj_1)
-
-class TestHashing(object):
- """Used as a mixin for TestCase"""
-
- # Check for a valid __hash__ implementation
- def test_hash(self):
- for obj_1, obj_2 in self.eq_pairs:
- try:
- if not hash(obj_1) == hash(obj_2):
- self.fail("%r and %r do not hash equal" % (obj_1, obj_2))
- except KeyboardInterrupt:
- raise
- except Exception as e:
- self.fail("Problem hashing %r and %r: %s" % (obj_1, obj_2, e))
-
- for obj_1, obj_2 in self.ne_pairs:
- try:
- if hash(obj_1) == hash(obj_2):
- self.fail("%s and %s hash equal, but shouldn't" %
- (obj_1, obj_2))
- except KeyboardInterrupt:
- raise
- except Exception as e:
- self.fail("Problem hashing %s and %s: %s" % (obj_1, obj_2, e))
-
-
-# List subclass we can add attributes to.
-class MyClassSuite(list):
-
- def __init__(self, tests):
- super(MyClassSuite, self).__init__(tests)
-
-
-################################################################
-### /Support code
-
-class Test_TestLoader(TestCase):
-
- ### Tests for TestLoader.loadTestsFromTestCase
- ################################################################
-
- # "Return a suite of all tests cases contained in the TestCase-derived
- # class testCaseClass"
- def test_loadTestsFromTestCase(self):
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
-
- tests = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
-
- loader = unittest.TestLoader()
- self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
-
- # "Return a suite of all tests cases contained in the TestCase-derived
- # class testCaseClass"
- #
- # Make sure it does the right thing even if no tests were found
- def test_loadTestsFromTestCase__no_matches(self):
- class Foo(unittest.TestCase):
- def foo_bar(self): pass
-
- empty_suite = unittest.TestSuite()
-
- loader = unittest.TestLoader()
- self.assertEqual(loader.loadTestsFromTestCase(Foo), empty_suite)
-
- # "Return a suite of all tests cases contained in the TestCase-derived
- # class testCaseClass"
- #
- # What happens if loadTestsFromTestCase() is given an object
- # that isn't a subclass of TestCase? Specifically, what happens
- # if testCaseClass is a subclass of TestSuite?
- #
- # This is checked for specifically in the code, so we better add a
- # test for it.
- def test_loadTestsFromTestCase__TestSuite_subclass(self):
- class NotATestCase(unittest.TestSuite):
- pass
-
- loader = unittest.TestLoader()
- try:
- loader.loadTestsFromTestCase(NotATestCase)
- except TypeError:
- pass
- else:
- self.fail('Should raise TypeError')
-
- # "Return a suite of all tests cases contained in the TestCase-derived
- # class testCaseClass"
- #
- # Make sure loadTestsFromTestCase() picks up the default test method
- # name (as specified by TestCase), even though the method name does
- # not match the default TestLoader.testMethodPrefix string
- def test_loadTestsFromTestCase__default_method_name(self):
- class Foo(unittest.TestCase):
- def runTest(self):
- pass
-
- loader = unittest.TestLoader()
- # This has to be false for the test to succeed
- self.assertFalse('runTest'.startswith(loader.testMethodPrefix))
-
- suite = loader.loadTestsFromTestCase(Foo)
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [Foo('runTest')])
-
- ################################################################
- ### /Tests for TestLoader.loadTestsFromTestCase
-
- ### Tests for TestLoader.loadTestsFromModule
- ################################################################
-
- # "This method searches `module` for classes derived from TestCase"
- def test_loadTestsFromModule__TestCase_subclass(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testcase_1 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromModule(m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- expected = [loader.suiteClass([MyTestCase('test')])]
- self.assertEqual(list(suite), expected)
-
- # "This method searches `module` for classes derived from TestCase"
- #
- # What happens if no tests are found (no TestCase instances)?
- def test_loadTestsFromModule__no_TestCase_instances(self):
- m = types.ModuleType('m')
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromModule(m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [])
-
- # "This method searches `module` for classes derived from TestCase"
- #
- # What happens if no tests are found (TestCases instances, but no tests)?
- def test_loadTestsFromModule__no_TestCase_tests(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- pass
- m.testcase_1 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromModule(m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- self.assertEqual(list(suite), [loader.suiteClass()])
-
- # "This method searches `module` for classes derived from TestCase"s
- #
- # What happens if loadTestsFromModule() is given something other
- # than a module?
- #
- # XXX Currently, it succeeds anyway. This flexibility
- # should either be documented or loadTestsFromModule() should
- # raise a TypeError
- #
- # XXX Certain people are using this behaviour. We'll add a test for it
- def test_loadTestsFromModule__not_a_module(self):
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
-
- class NotAModule(object):
- test_2 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromModule(NotAModule)
-
- reference = [unittest.TestSuite([MyTestCase('test')])]
- self.assertEqual(list(suite), reference)
-
- ################################################################
- ### /Tests for TestLoader.loadTestsFromModule()
-
- ### Tests for TestLoader.loadTestsFromName()
- ################################################################
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # Is ValueError raised in response to an empty name?
- def test_loadTestsFromName__empty_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromName('')
- except ValueError as e:
- self.assertEqual(str(e), "Empty module name")
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # What happens when the name contains invalid characters?
- def test_loadTestsFromName__malformed_name(self):
- loader = unittest.TestLoader()
-
- # XXX Should this raise ValueError or ImportError?
- try:
- loader.loadTestsFromName('abc () //')
- except ValueError:
- pass
- except ImportError:
- pass
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
-
- # "The specifier name is a ``dotted name'' that may resolve ... to a
- # module"
- #
- # What happens when a module by that name can't be found?
- def test_loadTestsFromName__unknown_module_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromName('sdasfasfasdf')
- except ImportError as e:
- self.assertEqual(str(e), "No module named sdasfasfasdf")
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise ImportError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # What happens when the module is found, but the attribute can't?
- def test_loadTestsFromName__unknown_attr_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromName('unittest.sdasfasfasdf')
- except AttributeError as e:
- self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # What happens when we provide the module, but the attribute can't be
- # found?
- def test_loadTestsFromName__relative_unknown_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromName('sdasfasfasdf', unittest)
- except AttributeError as e:
- self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- # ...
- # "The method optionally resolves name relative to the given module"
- #
- # Does loadTestsFromName raise ValueError when passed an empty
- # name relative to a provided module?
- #
- # XXX Should probably raise a ValueError instead of an AttributeError
- def test_loadTestsFromName__relative_empty_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromName('', unittest)
- except AttributeError as e:
- pass
- else:
- self.fail("Failed to raise AttributeError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- # ...
- # "The method optionally resolves name relative to the given module"
- #
- # What happens when an impossible name is given, relative to the provided
- # `module`?
- def test_loadTestsFromName__relative_malformed_name(self):
- loader = unittest.TestLoader()
-
- # XXX Should this raise AttributeError or ValueError?
- try:
- loader.loadTestsFromName('abc () //', unittest)
- except ValueError:
- pass
- except AttributeError:
- pass
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
-
- # "The method optionally resolves name relative to the given module"
- #
- # Does loadTestsFromName raise TypeError when the `module` argument
- # isn't a module object?
- #
- # XXX Accepts the not-a-module object, ignorning the object's type
- # This should raise an exception or the method name should be changed
- #
- # XXX Some people are relying on this, so keep it for now
- def test_loadTestsFromName__relative_not_a_module(self):
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
-
- class NotAModule(object):
- test_2 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromName('test_2', NotAModule)
-
- reference = [MyTestCase('test')]
- self.assertEqual(list(suite), reference)
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # Does it raise an exception if the name resolves to an invalid
- # object?
- def test_loadTestsFromName__relative_bad_object(self):
- m = types.ModuleType('m')
- m.testcase_1 = object()
-
- loader = unittest.TestLoader()
- try:
- loader.loadTestsFromName('testcase_1', m)
- except TypeError:
- pass
- else:
- self.fail("Should have raised TypeError")
-
- # "The specifier name is a ``dotted name'' that may
- # resolve either to ... a test case class"
- def test_loadTestsFromName__relative_TestCase_subclass(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testcase_1 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromName('testcase_1', m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [MyTestCase('test')])
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- def test_loadTestsFromName__relative_TestSuite(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testsuite = unittest.TestSuite([MyTestCase('test')])
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromName('testsuite', m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- self.assertEqual(list(suite), [MyTestCase('test')])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a test method within a test case class"
- def test_loadTestsFromName__relative_testmethod(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testcase_1 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromName('testcase_1.test', m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- self.assertEqual(list(suite), [MyTestCase('test')])
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # Does loadTestsFromName() raise the proper exception when trying to
- # resolve "a test method within a test case class" that doesn't exist
- # for the given name (relative to a provided module)?
- def test_loadTestsFromName__relative_invalid_testmethod(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testcase_1 = MyTestCase
-
- loader = unittest.TestLoader()
- try:
- loader.loadTestsFromName('testcase_1.testfoo', m)
- except AttributeError as e:
- self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
- else:
- self.fail("Failed to raise AttributeError")
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a callable object which returns a ... TestSuite instance"
- def test_loadTestsFromName__callable__TestSuite(self):
- m = types.ModuleType('m')
- testcase_1 = unittest.FunctionTestCase(lambda: None)
- testcase_2 = unittest.FunctionTestCase(lambda: None)
- def return_TestSuite():
- return unittest.TestSuite([testcase_1, testcase_2])
- m.return_TestSuite = return_TestSuite
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromName('return_TestSuite', m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [testcase_1, testcase_2])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a callable object which returns a TestCase ... instance"
- def test_loadTestsFromName__callable__TestCase_instance(self):
- m = types.ModuleType('m')
- testcase_1 = unittest.FunctionTestCase(lambda: None)
- def return_TestCase():
- return testcase_1
- m.return_TestCase = return_TestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromName('return_TestCase', m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [testcase_1])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a callable object which returns a TestCase or TestSuite instance"
- #
- # What happens if the callable returns something else?
- def test_loadTestsFromName__callable__wrong_type(self):
- m = types.ModuleType('m')
- def return_wrong():
- return 6
- m.return_wrong = return_wrong
-
- loader = unittest.TestLoader()
- try:
- suite = loader.loadTestsFromName('return_wrong', m)
- except TypeError:
- pass
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise TypeError")
-
- # "The specifier can refer to modules and packages which have not been
- # imported; they will be imported as a side-effect"
- def test_loadTestsFromName__module_not_loaded(self):
- # We're going to try to load this module as a side-effect, so it
- # better not be loaded before we try.
- #
- # Why pick audioop? Google shows it isn't used very often, so there's
- # a good chance that it won't be imported when this test is run
- module_name = 'audioop'
-
- import sys
- if module_name in sys.modules:
- del sys.modules[module_name]
-
- loader = unittest.TestLoader()
- try:
- suite = loader.loadTestsFromName(module_name)
-
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [])
-
- # audioop should now be loaded, thanks to loadTestsFromName()
- self.assertTrue(module_name in sys.modules)
- finally:
- if module_name in sys.modules:
- del sys.modules[module_name]
-
- ################################################################
- ### Tests for TestLoader.loadTestsFromName()
-
- ### Tests for TestLoader.loadTestsFromNames()
- ################################################################
-
- # "Similar to loadTestsFromName(), but takes a sequence of names rather
- # than a single name."
- #
- # What happens if that sequence of names is empty?
- def test_loadTestsFromNames__empty_name_list(self):
- loader = unittest.TestLoader()
-
- suite = loader.loadTestsFromNames([])
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [])
-
- # "Similar to loadTestsFromName(), but takes a sequence of names rather
- # than a single name."
- # ...
- # "The method optionally resolves name relative to the given module"
- #
- # What happens if that sequence of names is empty?
- #
- # XXX Should this raise a ValueError or just return an empty TestSuite?
- def test_loadTestsFromNames__relative_empty_name_list(self):
- loader = unittest.TestLoader()
-
- suite = loader.loadTestsFromNames([], unittest)
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [])
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # Is ValueError raised in response to an empty name?
- def test_loadTestsFromNames__empty_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromNames([''])
- except ValueError as e:
- self.assertEqual(str(e), "Empty module name")
- else:
- self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # What happens when presented with an impossible module name?
- def test_loadTestsFromNames__malformed_name(self):
- loader = unittest.TestLoader()
-
- # XXX Should this raise ValueError or ImportError?
- try:
- loader.loadTestsFromNames(['abc () //'])
- except ValueError:
- pass
- except ImportError:
- pass
- else:
- self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # What happens when no module can be found for the given name?
- def test_loadTestsFromNames__unknown_module_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromNames(['sdasfasfasdf'])
- except ImportError as e:
- self.assertEqual(str(e), "No module named sdasfasfasdf")
- else:
- self.fail("TestLoader.loadTestsFromNames failed to raise ImportError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # What happens when the module can be found, but not the attribute?
- def test_loadTestsFromNames__unknown_attr_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromNames(['unittest.sdasfasfasdf', 'unittest'])
- except AttributeError as e:
- self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
- else:
- self.fail("TestLoader.loadTestsFromNames failed to raise AttributeError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- # ...
- # "The method optionally resolves name relative to the given module"
- #
- # What happens when given an unknown attribute on a specified `module`
- # argument?
- def test_loadTestsFromNames__unknown_name_relative_1(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromNames(['sdasfasfasdf'], unittest)
- except AttributeError as e:
- self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- # ...
- # "The method optionally resolves name relative to the given module"
- #
- # Do unknown attributes (relative to a provided module) still raise an
- # exception even in the presence of valid attribute names?
- def test_loadTestsFromNames__unknown_name_relative_2(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromNames(['TestCase', 'sdasfasfasdf'], unittest)
- except AttributeError as e:
- self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
- else:
- self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- # ...
- # "The method optionally resolves name relative to the given module"
- #
- # What happens when faced with the empty string?
- #
- # XXX This currently raises AttributeError, though ValueError is probably
- # more appropriate
- def test_loadTestsFromNames__relative_empty_name(self):
- loader = unittest.TestLoader()
-
- try:
- loader.loadTestsFromNames([''], unittest)
- except AttributeError:
- pass
- else:
- self.fail("Failed to raise ValueError")
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- # ...
- # "The method optionally resolves name relative to the given module"
- #
- # What happens when presented with an impossible attribute name?
- def test_loadTestsFromNames__relative_malformed_name(self):
- loader = unittest.TestLoader()
-
- # XXX Should this raise AttributeError or ValueError?
- try:
- loader.loadTestsFromNames(['abc () //'], unittest)
- except AttributeError:
- pass
- except ValueError:
- pass
- else:
- self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
-
- # "The method optionally resolves name relative to the given module"
- #
- # Does loadTestsFromNames() make sure the provided `module` is in fact
- # a module?
- #
- # XXX This validation is currently not done. This flexibility should
- # either be documented or a TypeError should be raised.
- def test_loadTestsFromNames__relative_not_a_module(self):
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
-
- class NotAModule(object):
- test_2 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromNames(['test_2'], NotAModule)
-
- reference = [unittest.TestSuite([MyTestCase('test')])]
- self.assertEqual(list(suite), reference)
-
- # "The specifier name is a ``dotted name'' that may resolve either to
- # a module, a test case class, a TestSuite instance, a test method
- # within a test case class, or a callable object which returns a
- # TestCase or TestSuite instance."
- #
- # Does it raise an exception if the name resolves to an invalid
- # object?
- def test_loadTestsFromNames__relative_bad_object(self):
- m = types.ModuleType('m')
- m.testcase_1 = object()
-
- loader = unittest.TestLoader()
- try:
- loader.loadTestsFromNames(['testcase_1'], m)
- except TypeError:
- pass
- else:
- self.fail("Should have raised TypeError")
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a test case class"
- def test_loadTestsFromNames__relative_TestCase_subclass(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testcase_1 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromNames(['testcase_1'], m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- expected = loader.suiteClass([MyTestCase('test')])
- self.assertEqual(list(suite), [expected])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a TestSuite instance"
- def test_loadTestsFromNames__relative_TestSuite(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testsuite = unittest.TestSuite([MyTestCase('test')])
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromNames(['testsuite'], m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- self.assertEqual(list(suite), [m.testsuite])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to ... a
- # test method within a test case class"
- def test_loadTestsFromNames__relative_testmethod(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testcase_1 = MyTestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromNames(['testcase_1.test'], m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- ref_suite = unittest.TestSuite([MyTestCase('test')])
- self.assertEqual(list(suite), [ref_suite])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to ... a
- # test method within a test case class"
- #
- # Does the method gracefully handle names that initially look like they
- # resolve to "a test method within a test case class" but don't?
- def test_loadTestsFromNames__relative_invalid_testmethod(self):
- m = types.ModuleType('m')
- class MyTestCase(unittest.TestCase):
- def test(self):
- pass
- m.testcase_1 = MyTestCase
-
- loader = unittest.TestLoader()
- try:
- loader.loadTestsFromNames(['testcase_1.testfoo'], m)
- except AttributeError as e:
- self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
- else:
- self.fail("Failed to raise AttributeError")
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a callable object which returns a ... TestSuite instance"
- def test_loadTestsFromNames__callable__TestSuite(self):
- m = types.ModuleType('m')
- testcase_1 = unittest.FunctionTestCase(lambda: None)
- testcase_2 = unittest.FunctionTestCase(lambda: None)
- def return_TestSuite():
- return unittest.TestSuite([testcase_1, testcase_2])
- m.return_TestSuite = return_TestSuite
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromNames(['return_TestSuite'], m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- expected = unittest.TestSuite([testcase_1, testcase_2])
- self.assertEqual(list(suite), [expected])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a callable object which returns a TestCase ... instance"
- def test_loadTestsFromNames__callable__TestCase_instance(self):
- m = types.ModuleType('m')
- testcase_1 = unittest.FunctionTestCase(lambda: None)
- def return_TestCase():
- return testcase_1
- m.return_TestCase = return_TestCase
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromNames(['return_TestCase'], m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- ref_suite = unittest.TestSuite([testcase_1])
- self.assertEqual(list(suite), [ref_suite])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a callable object which returns a TestCase or TestSuite instance"
- #
- # Are staticmethods handled correctly?
- def test_loadTestsFromNames__callable__call_staticmethod(self):
- m = types.ModuleType('m')
- class Test1(unittest.TestCase):
- def test(self):
- pass
-
- testcase_1 = Test1('test')
- class Foo(unittest.TestCase):
- @staticmethod
- def foo():
- return testcase_1
- m.Foo = Foo
-
- loader = unittest.TestLoader()
- suite = loader.loadTestsFromNames(['Foo.foo'], m)
- self.assertTrue(isinstance(suite, loader.suiteClass))
-
- ref_suite = unittest.TestSuite([testcase_1])
- self.assertEqual(list(suite), [ref_suite])
-
- # "The specifier name is a ``dotted name'' that may resolve ... to
- # ... a callable object which returns a TestCase or TestSuite instance"
- #
- # What happens when the callable returns something else?
- def test_loadTestsFromNames__callable__wrong_type(self):
- m = types.ModuleType('m')
- def return_wrong():
- return 6
- m.return_wrong = return_wrong
-
- loader = unittest.TestLoader()
- try:
- suite = loader.loadTestsFromNames(['return_wrong'], m)
- except TypeError:
- pass
- else:
- self.fail("TestLoader.loadTestsFromNames failed to raise TypeError")
-
- # "The specifier can refer to modules and packages which have not been
- # imported; they will be imported as a side-effect"
- def test_loadTestsFromNames__module_not_loaded(self):
- # We're going to try to load this module as a side-effect, so it
- # better not be loaded before we try.
- #
- # Why pick audioop? Google shows it isn't used very often, so there's
- # a good chance that it won't be imported when this test is run
- module_name = 'audioop'
-
- import sys
- if module_name in sys.modules:
- del sys.modules[module_name]
-
- loader = unittest.TestLoader()
- try:
- suite = loader.loadTestsFromNames([module_name])
-
- self.assertTrue(isinstance(suite, loader.suiteClass))
- self.assertEqual(list(suite), [unittest.TestSuite()])
-
- # audioop should now be loaded, thanks to loadTestsFromName()
- self.assertTrue(module_name in sys.modules)
- finally:
- if module_name in sys.modules:
- del sys.modules[module_name]
-
- ################################################################
- ### /Tests for TestLoader.loadTestsFromNames()
-
- ### Tests for TestLoader.getTestCaseNames()
- ################################################################
-
- # "Return a sorted sequence of method names found within testCaseClass"
- #
- # Test.foobar is defined to make sure getTestCaseNames() respects
- # loader.testMethodPrefix
- def test_getTestCaseNames(self):
- class Test(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foobar(self): pass
-
- loader = unittest.TestLoader()
-
- self.assertEqual(loader.getTestCaseNames(Test), ['test_1', 'test_2'])
-
- # "Return a sorted sequence of method names found within testCaseClass"
- #
- # Does getTestCaseNames() behave appropriately if no tests are found?
- def test_getTestCaseNames__no_tests(self):
- class Test(unittest.TestCase):
- def foobar(self): pass
-
- loader = unittest.TestLoader()
-
- self.assertEqual(loader.getTestCaseNames(Test), [])
-
- # "Return a sorted sequence of method names found within testCaseClass"
- #
- # Are not-TestCases handled gracefully?
- #
- # XXX This should raise a TypeError, not return a list
- #
- # XXX It's too late in the 2.5 release cycle to fix this, but it should
- # probably be revisited for 2.6
- def test_getTestCaseNames__not_a_TestCase(self):
- class BadCase(int):
- def test_foo(self):
- pass
-
- loader = unittest.TestLoader()
- names = loader.getTestCaseNames(BadCase)
-
- self.assertEqual(names, ['test_foo'])
-
- # "Return a sorted sequence of method names found within testCaseClass"
- #
- # Make sure inherited names are handled.
- #
- # TestP.foobar is defined to make sure getTestCaseNames() respects
- # loader.testMethodPrefix
- def test_getTestCaseNames__inheritance(self):
- class TestP(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foobar(self): pass
-
- class TestC(TestP):
- def test_1(self): pass
- def test_3(self): pass
-
- loader = unittest.TestLoader()
-
- names = ['test_1', 'test_2', 'test_3']
- self.assertEqual(loader.getTestCaseNames(TestC), names)
-
- ################################################################
- ### /Tests for TestLoader.getTestCaseNames()
-
- ### Tests for TestLoader.testMethodPrefix
- ################################################################
-
- # "String giving the prefix of method names which will be interpreted as
- # test methods"
- #
- # Implicit in the documentation is that testMethodPrefix is respected by
- # all loadTestsFrom* methods.
- def test_testMethodPrefix__loadTestsFromTestCase(self):
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
-
- tests_1 = unittest.TestSuite([Foo('foo_bar')])
- tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
-
- loader = unittest.TestLoader()
- loader.testMethodPrefix = 'foo'
- self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_1)
-
- loader.testMethodPrefix = 'test'
- self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_2)
-
- # "String giving the prefix of method names which will be interpreted as
- # test methods"
- #
- # Implicit in the documentation is that testMethodPrefix is respected by
- # all loadTestsFrom* methods.
- def test_testMethodPrefix__loadTestsFromModule(self):
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
- m.Foo = Foo
-
- tests_1 = [unittest.TestSuite([Foo('foo_bar')])]
- tests_2 = [unittest.TestSuite([Foo('test_1'), Foo('test_2')])]
-
- loader = unittest.TestLoader()
- loader.testMethodPrefix = 'foo'
- self.assertEqual(list(loader.loadTestsFromModule(m)), tests_1)
-
- loader.testMethodPrefix = 'test'
- self.assertEqual(list(loader.loadTestsFromModule(m)), tests_2)
-
- # "String giving the prefix of method names which will be interpreted as
- # test methods"
- #
- # Implicit in the documentation is that testMethodPrefix is respected by
- # all loadTestsFrom* methods.
- def test_testMethodPrefix__loadTestsFromName(self):
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
- m.Foo = Foo
-
- tests_1 = unittest.TestSuite([Foo('foo_bar')])
- tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
-
- loader = unittest.TestLoader()
- loader.testMethodPrefix = 'foo'
- self.assertEqual(loader.loadTestsFromName('Foo', m), tests_1)
-
- loader.testMethodPrefix = 'test'
- self.assertEqual(loader.loadTestsFromName('Foo', m), tests_2)
-
- # "String giving the prefix of method names which will be interpreted as
- # test methods"
- #
- # Implicit in the documentation is that testMethodPrefix is respected by
- # all loadTestsFrom* methods.
- def test_testMethodPrefix__loadTestsFromNames(self):
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
- m.Foo = Foo
-
- tests_1 = unittest.TestSuite([unittest.TestSuite([Foo('foo_bar')])])
- tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
- tests_2 = unittest.TestSuite([tests_2])
-
- loader = unittest.TestLoader()
- loader.testMethodPrefix = 'foo'
- self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_1)
-
- loader.testMethodPrefix = 'test'
- self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_2)
-
- # "The default value is 'test'"
- def test_testMethodPrefix__default_value(self):
- loader = unittest.TestLoader()
- self.assertEqual(loader.testMethodPrefix, 'test')
-
- ################################################################
- ### /Tests for TestLoader.testMethodPrefix
-
- ### Tests for TestLoader.sortTestMethodsUsing
- ################################################################
-
- # "Function to be used to compare method names when sorting them in
- # getTestCaseNames() and all the loadTestsFromX() methods"
- def test_sortTestMethodsUsing__loadTestsFromTestCase(self):
- def reversed_cmp(x, y):
- return -((x > y) - (x < y))
-
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
-
- loader = unittest.TestLoader()
- loader.sortTestMethodsUsing = reversed_cmp
-
- tests = loader.suiteClass([Foo('test_2'), Foo('test_1')])
- self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
-
- # "Function to be used to compare method names when sorting them in
- # getTestCaseNames() and all the loadTestsFromX() methods"
- def test_sortTestMethodsUsing__loadTestsFromModule(self):
- def reversed_cmp(x, y):
- return -((x > y) - (x < y))
-
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- m.Foo = Foo
-
- loader = unittest.TestLoader()
- loader.sortTestMethodsUsing = reversed_cmp
-
- tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])]
- self.assertEqual(list(loader.loadTestsFromModule(m)), tests)
-
- # "Function to be used to compare method names when sorting them in
- # getTestCaseNames() and all the loadTestsFromX() methods"
- def test_sortTestMethodsUsing__loadTestsFromName(self):
- def reversed_cmp(x, y):
- return -((x > y) - (x < y))
-
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- m.Foo = Foo
-
- loader = unittest.TestLoader()
- loader.sortTestMethodsUsing = reversed_cmp
-
- tests = loader.suiteClass([Foo('test_2'), Foo('test_1')])
- self.assertEqual(loader.loadTestsFromName('Foo', m), tests)
-
- # "Function to be used to compare method names when sorting them in
- # getTestCaseNames() and all the loadTestsFromX() methods"
- def test_sortTestMethodsUsing__loadTestsFromNames(self):
- def reversed_cmp(x, y):
- return -((x > y) - (x < y))
-
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- m.Foo = Foo
-
- loader = unittest.TestLoader()
- loader.sortTestMethodsUsing = reversed_cmp
-
- tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])]
- self.assertEqual(list(loader.loadTestsFromNames(['Foo'], m)), tests)
-
- # "Function to be used to compare method names when sorting them in
- # getTestCaseNames()"
- #
- # Does it actually affect getTestCaseNames()?
- def test_sortTestMethodsUsing__getTestCaseNames(self):
- def reversed_cmp(x, y):
- return -((x > y) - (x < y))
-
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
-
- loader = unittest.TestLoader()
- loader.sortTestMethodsUsing = reversed_cmp
-
- test_names = ['test_2', 'test_1']
- self.assertEqual(loader.getTestCaseNames(Foo), test_names)
-
- # "The default value is the built-in cmp() function"
- # Since cmp is now defunct, we simply verify that the results
- # occur in the same order as they would with the default sort.
- def test_sortTestMethodsUsing__default_value(self):
- loader = unittest.TestLoader()
-
- class Foo(unittest.TestCase):
- def test_2(self): pass
- def test_3(self): pass
- def test_1(self): pass
-
- test_names = ['test_2', 'test_3', 'test_1']
- self.assertEqual(loader.getTestCaseNames(Foo), sorted(test_names))
-
-
- # "it can be set to None to disable the sort."
- #
- # XXX How is this different from reassigning cmp? Are the tests returned
- # in a random order or something? This behaviour should die
- def test_sortTestMethodsUsing__None(self):
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
-
- loader = unittest.TestLoader()
- loader.sortTestMethodsUsing = None
-
- test_names = ['test_2', 'test_1']
- self.assertEqual(set(loader.getTestCaseNames(Foo)), set(test_names))
-
- ################################################################
- ### /Tests for TestLoader.sortTestMethodsUsing
-
- ### Tests for TestLoader.suiteClass
- ################################################################
-
- # "Callable object that constructs a test suite from a list of tests."
- def test_suiteClass__loadTestsFromTestCase(self):
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
-
- tests = [Foo('test_1'), Foo('test_2')]
-
- loader = unittest.TestLoader()
- loader.suiteClass = list
- self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
-
- # It is implicit in the documentation for TestLoader.suiteClass that
- # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
- def test_suiteClass__loadTestsFromModule(self):
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
- m.Foo = Foo
-
- tests = [[Foo('test_1'), Foo('test_2')]]
-
- loader = unittest.TestLoader()
- loader.suiteClass = list
- self.assertEqual(loader.loadTestsFromModule(m), tests)
-
- # It is implicit in the documentation for TestLoader.suiteClass that
- # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
- def test_suiteClass__loadTestsFromName(self):
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
- m.Foo = Foo
-
- tests = [Foo('test_1'), Foo('test_2')]
-
- loader = unittest.TestLoader()
- loader.suiteClass = list
- self.assertEqual(loader.loadTestsFromName('Foo', m), tests)
-
- # It is implicit in the documentation for TestLoader.suiteClass that
- # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
- def test_suiteClass__loadTestsFromNames(self):
- m = types.ModuleType('m')
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def foo_bar(self): pass
- m.Foo = Foo
-
- tests = [[Foo('test_1'), Foo('test_2')]]
-
- loader = unittest.TestLoader()
- loader.suiteClass = list
- self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests)
-
- # "The default value is the TestSuite class"
- def test_suiteClass__default_value(self):
- loader = unittest.TestLoader()
- self.assertTrue(loader.suiteClass is unittest.TestSuite)
-
- ################################################################
- ### /Tests for TestLoader.suiteClass
-
-### Support code for Test_TestSuite
-################################################################
-
-class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
- def test_3(self): pass
- def runTest(self): pass
-
-def _mk_TestSuite(*names):
- return unittest.TestSuite(Foo(n) for n in names)
-
-################################################################
-### /Support code for Test_TestSuite
-
-class Test_TestSuite(TestCase, TestEquality):
-
- ### Set up attributes needed by inherited tests
- ################################################################
-
- # Used by TestEquality.test_eq
- eq_pairs = [(unittest.TestSuite(), unittest.TestSuite())
- ,(unittest.TestSuite(), unittest.TestSuite([]))
- ,(_mk_TestSuite('test_1'), _mk_TestSuite('test_1'))]
-
- # Used by TestEquality.test_ne
- ne_pairs = [(unittest.TestSuite(), _mk_TestSuite('test_1'))
- ,(unittest.TestSuite([]), _mk_TestSuite('test_1'))
- ,(_mk_TestSuite('test_1', 'test_2'), _mk_TestSuite('test_1', 'test_3'))
- ,(_mk_TestSuite('test_1'), _mk_TestSuite('test_2'))]
-
- ################################################################
- ### /Set up attributes needed by inherited tests
-
- ### Tests for TestSuite.__init__
- ################################################################
-
- # "class TestSuite([tests])"
- #
- # The tests iterable should be optional
- def test_init__tests_optional(self):
- suite = unittest.TestSuite()
-
- self.assertEqual(suite.countTestCases(), 0)
-
- # "class TestSuite([tests])"
- # ...
- # "If tests is given, it must be an iterable of individual test cases
- # or other test suites that will be used to build the suite initially"
- #
- # TestSuite should deal with empty tests iterables by allowing the
- # creation of an empty suite
- def test_init__empty_tests(self):
- suite = unittest.TestSuite([])
-
- self.assertEqual(suite.countTestCases(), 0)
-
- # "class TestSuite([tests])"
- # ...
- # "If tests is given, it must be an iterable of individual test cases
- # or other test suites that will be used to build the suite initially"
- #
- # TestSuite should allow any iterable to provide tests
- def test_init__tests_from_any_iterable(self):
- def tests():
- yield unittest.FunctionTestCase(lambda: None)
- yield unittest.FunctionTestCase(lambda: None)
-
- suite_1 = unittest.TestSuite(tests())
- self.assertEqual(suite_1.countTestCases(), 2)
-
- suite_2 = unittest.TestSuite(suite_1)
- self.assertEqual(suite_2.countTestCases(), 2)
-
- suite_3 = unittest.TestSuite(set(suite_1))
- self.assertEqual(suite_3.countTestCases(), 2)
-
- # "class TestSuite([tests])"
- # ...
- # "If tests is given, it must be an iterable of individual test cases
- # or other test suites that will be used to build the suite initially"
- #
- # Does TestSuite() also allow other TestSuite() instances to be present
- # in the tests iterable?
- def test_init__TestSuite_instances_in_tests(self):
- def tests():
- ftc = unittest.FunctionTestCase(lambda: None)
- yield unittest.TestSuite([ftc])
- yield unittest.FunctionTestCase(lambda: None)
-
- suite = unittest.TestSuite(tests())
- self.assertEqual(suite.countTestCases(), 2)
-
- ################################################################
- ### /Tests for TestSuite.__init__
-
- # Container types should support the iter protocol
- def test_iter(self):
- test1 = unittest.FunctionTestCase(lambda: None)
- test2 = unittest.FunctionTestCase(lambda: None)
- suite = unittest.TestSuite((test1, test2))
-
- self.assertEqual(list(suite), [test1, test2])
-
- # "Return the number of tests represented by the this test object.
- # ...this method is also implemented by the TestSuite class, which can
- # return larger [greater than 1] values"
- #
- # Presumably an empty TestSuite returns 0?
- def test_countTestCases_zero_simple(self):
- suite = unittest.TestSuite()
-
- self.assertEqual(suite.countTestCases(), 0)
-
- # "Return the number of tests represented by the this test object.
- # ...this method is also implemented by the TestSuite class, which can
- # return larger [greater than 1] values"
- #
- # Presumably an empty TestSuite (even if it contains other empty
- # TestSuite instances) returns 0?
- def test_countTestCases_zero_nested(self):
- class Test1(unittest.TestCase):
- def test(self):
- pass
-
- suite = unittest.TestSuite([unittest.TestSuite()])
-
- self.assertEqual(suite.countTestCases(), 0)
-
- # "Return the number of tests represented by the this test object.
- # ...this method is also implemented by the TestSuite class, which can
- # return larger [greater than 1] values"
- def test_countTestCases_simple(self):
- test1 = unittest.FunctionTestCase(lambda: None)
- test2 = unittest.FunctionTestCase(lambda: None)
- suite = unittest.TestSuite((test1, test2))
-
- self.assertEqual(suite.countTestCases(), 2)
-
- # "Return the number of tests represented by the this test object.
- # ...this method is also implemented by the TestSuite class, which can
- # return larger [greater than 1] values"
- #
- # Make sure this holds for nested TestSuite instances, too
- def test_countTestCases_nested(self):
- class Test1(unittest.TestCase):
- def test1(self): pass
- def test2(self): pass
-
- test2 = unittest.FunctionTestCase(lambda: None)
- test3 = unittest.FunctionTestCase(lambda: None)
- child = unittest.TestSuite((Test1('test2'), test2))
- parent = unittest.TestSuite((test3, child, Test1('test1')))
-
- self.assertEqual(parent.countTestCases(), 4)
-
- # "Run the tests associated with this suite, collecting the result into
- # the test result object passed as result."
- #
- # And if there are no tests? What then?
- def test_run__empty_suite(self):
- events = []
- result = LoggingResult(events)
-
- suite = unittest.TestSuite()
-
- suite.run(result)
-
- self.assertEqual(events, [])
-
- # "Note that unlike TestCase.run(), TestSuite.run() requires the
- # "result object to be passed in."
- def test_run__requires_result(self):
- suite = unittest.TestSuite()
-
- try:
- suite.run()
- except TypeError:
- pass
- else:
- self.fail("Failed to raise TypeError")
-
- # "Run the tests associated with this suite, collecting the result into
- # the test result object passed as result."
- def test_run(self):
- events = []
- result = LoggingResult(events)
-
- class LoggingCase(unittest.TestCase):
- def run(self, result):
- events.append('run %s' % self._testMethodName)
-
- def test1(self): pass
- def test2(self): pass
-
- tests = [LoggingCase('test1'), LoggingCase('test2')]
-
- unittest.TestSuite(tests).run(result)
-
- self.assertEqual(events, ['run test1', 'run test2'])
-
- # "Add a TestCase ... to the suite"
- def test_addTest__TestCase(self):
- class Foo(unittest.TestCase):
- def test(self): pass
-
- test = Foo('test')
- suite = unittest.TestSuite()
-
- suite.addTest(test)
-
- self.assertEqual(suite.countTestCases(), 1)
- self.assertEqual(list(suite), [test])
-
- # "Add a ... TestSuite to the suite"
- def test_addTest__TestSuite(self):
- class Foo(unittest.TestCase):
- def test(self): pass
-
- suite_2 = unittest.TestSuite([Foo('test')])
-
- suite = unittest.TestSuite()
- suite.addTest(suite_2)
-
- self.assertEqual(suite.countTestCases(), 1)
- self.assertEqual(list(suite), [suite_2])
-
- # "Add all the tests from an iterable of TestCase and TestSuite
- # instances to this test suite."
- #
- # "This is equivalent to iterating over tests, calling addTest() for
- # each element"
- def test_addTests(self):
- class Foo(unittest.TestCase):
- def test_1(self): pass
- def test_2(self): pass
-
- test_1 = Foo('test_1')
- test_2 = Foo('test_2')
- inner_suite = unittest.TestSuite([test_2])
-
- def gen():
- yield test_1
- yield test_2
- yield inner_suite
-
- suite_1 = unittest.TestSuite()
- suite_1.addTests(gen())
-
- self.assertEqual(list(suite_1), list(gen()))
-
- # "This is equivalent to iterating over tests, calling addTest() for
- # each element"
- suite_2 = unittest.TestSuite()
- for t in gen():
- suite_2.addTest(t)
-
- self.assertEqual(suite_1, suite_2)
-
- # "Add all the tests from an iterable of TestCase and TestSuite
- # instances to this test suite."
- #
- # What happens if it doesn't get an iterable?
- def test_addTest__noniterable(self):
- suite = unittest.TestSuite()
-
- try:
- suite.addTests(5)
- except TypeError:
- pass
- else:
- self.fail("Failed to raise TypeError")
-
- def test_addTest__noncallable(self):
- suite = unittest.TestSuite()
- self.assertRaises(TypeError, suite.addTest, 5)
-
- def test_addTest__casesuiteclass(self):
- suite = unittest.TestSuite()
- self.assertRaises(TypeError, suite.addTest, Test_TestSuite)
- self.assertRaises(TypeError, suite.addTest, unittest.TestSuite)
-
- def test_addTests__string(self):
- suite = unittest.TestSuite()
- self.assertRaises(TypeError, suite.addTests, "foo")
-
-
-class Test_FunctionTestCase(TestCase):
-
- # "Return the number of tests represented by the this test object. For
- # TestCase instances, this will always be 1"
- def test_countTestCases(self):
- test = unittest.FunctionTestCase(lambda: None)
-
- self.assertEqual(test.countTestCases(), 1)
-
- # "When a setUp() method is defined, the test runner will run that method
- # prior to each test. Likewise, if a tearDown() method is defined, the
- # test runner will invoke that method after each test. In the example,
- # setUp() was used to create a fresh sequence for each test."
- #
- # Make sure the proper call order is maintained, even if setUp() raises
- # an exception.
- def test_run_call_order__error_in_setUp(self):
- events = []
- result = LoggingResult(events)
-
- def setUp():
- events.append('setUp')
- raise RuntimeError('raised by setUp')
-
- def test():
- events.append('test')
-
- def tearDown():
- events.append('tearDown')
-
- expected = ['startTest', 'setUp', 'addError', 'stopTest']
- unittest.FunctionTestCase(test, setUp, tearDown).run(result)
- self.assertEqual(events, expected)
-
- # "When a setUp() method is defined, the test runner will run that method
- # prior to each test. Likewise, if a tearDown() method is defined, the
- # test runner will invoke that method after each test. In the example,
- # setUp() was used to create a fresh sequence for each test."
- #
- # Make sure the proper call order is maintained, even if the test raises
- # an error (as opposed to a failure).
- def test_run_call_order__error_in_test(self):
- events = []
- result = LoggingResult(events)
-
- def setUp():
- events.append('setUp')
-
- def test():
- events.append('test')
- raise RuntimeError('raised by test')
-
- def tearDown():
- events.append('tearDown')
-
- expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
- 'stopTest']
- unittest.FunctionTestCase(test, setUp, tearDown).run(result)
- self.assertEqual(events, expected)
-
- # "When a setUp() method is defined, the test runner will run that method
- # prior to each test. Likewise, if a tearDown() method is defined, the
- # test runner will invoke that method after each test. In the example,
- # setUp() was used to create a fresh sequence for each test."
- #
- # Make sure the proper call order is maintained, even if the test signals
- # a failure (as opposed to an error).
- def test_run_call_order__failure_in_test(self):
- events = []
- result = LoggingResult(events)
-
- def setUp():
- events.append('setUp')
-
- def test():
- events.append('test')
- self.fail('raised by test')
- def tearDown():
- events.append('tearDown')
-
- expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
- 'stopTest']
- unittest.FunctionTestCase(test, setUp, tearDown).run(result)
- self.assertEqual(events, expected)
-
- # "When a setUp() method is defined, the test runner will run that method
- # prior to each test. Likewise, if a tearDown() method is defined, the
- # test runner will invoke that method after each test. In the example,
- # setUp() was used to create a fresh sequence for each test."
- #
- # Make sure the proper call order is maintained, even if tearDown() raises
- # an exception.
- def test_run_call_order__error_in_tearDown(self):
- events = []
- result = LoggingResult(events)
-
- def setUp():
- events.append('setUp')
-
- def test():
- events.append('test')
-
- def tearDown():
- events.append('tearDown')
- raise RuntimeError('raised by tearDown')
-
- expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
- 'stopTest']
- unittest.FunctionTestCase(test, setUp, tearDown).run(result)
- self.assertEqual(events, expected)
-
- # "Return a string identifying the specific test case."
- #
- # Because of the vague nature of the docs, I'm not going to lock this
- # test down too much. Really all that can be asserted is that the id()
- # will be a string (either 8-byte or unicode -- again, because the docs
- # just say "string")
- def test_id(self):
- test = unittest.FunctionTestCase(lambda: None)
-
- self.assertTrue(isinstance(test.id(), str))
-
- # "Returns a one-line description of the test, or None if no description
- # has been provided. The default implementation of this method returns
- # the first line of the test method's docstring, if available, or None."
- def test_shortDescription__no_docstring(self):
- test = unittest.FunctionTestCase(lambda: None)
-
- self.assertEqual(test.shortDescription(), None)
-
- # "Returns a one-line description of the test, or None if no description
- # has been provided. The default implementation of this method returns
- # the first line of the test method's docstring, if available, or None."
- def test_shortDescription__singleline_docstring(self):
- desc = "this tests foo"
- test = unittest.FunctionTestCase(lambda: None, description=desc)
-
- self.assertEqual(test.shortDescription(), "this tests foo")
-
-class Test_TestResult(TestCase):
- # Note: there are not separate tests for TestResult.wasSuccessful(),
- # TestResult.errors, TestResult.failures, TestResult.testsRun or
- # TestResult.shouldStop because these only have meaning in terms of
- # other TestResult methods.
- #
- # Accordingly, tests for the aforenamed attributes are incorporated
- # in with the tests for the defining methods.
- ################################################################
-
- def test_init(self):
- result = unittest.TestResult()
-
- self.assertTrue(result.wasSuccessful())
- self.assertEqual(len(result.errors), 0)
- self.assertEqual(len(result.failures), 0)
- self.assertEqual(result.testsRun, 0)
- self.assertEqual(result.shouldStop, False)
-
- # "This method can be called to signal that the set of tests being
- # run should be aborted by setting the TestResult's shouldStop
- # attribute to True."
- def test_stop(self):
- result = unittest.TestResult()
-
- result.stop()
-
- self.assertEqual(result.shouldStop, True)
-
- # "Called when the test case test is about to be run. The default
- # implementation simply increments the instance's testsRun counter."
- def test_startTest(self):
- class Foo(unittest.TestCase):
- def test_1(self):
- pass
-
- test = Foo('test_1')
-
- result = unittest.TestResult()
-
- result.startTest(test)
-
- self.assertTrue(result.wasSuccessful())
- self.assertEqual(len(result.errors), 0)
- self.assertEqual(len(result.failures), 0)
- self.assertEqual(result.testsRun, 1)
- self.assertEqual(result.shouldStop, False)
-
- result.stopTest(test)
-
- # "Called after the test case test has been executed, regardless of
- # the outcome. The default implementation does nothing."
- def test_stopTest(self):
- class Foo(unittest.TestCase):
- def test_1(self):
- pass
-
- test = Foo('test_1')
-
- result = unittest.TestResult()
-
- result.startTest(test)
-
- self.assertTrue(result.wasSuccessful())
- self.assertEqual(len(result.errors), 0)
- self.assertEqual(len(result.failures), 0)
- self.assertEqual(result.testsRun, 1)
- self.assertEqual(result.shouldStop, False)
-
- result.stopTest(test)
-
- # Same tests as above; make sure nothing has changed
- self.assertTrue(result.wasSuccessful())
- self.assertEqual(len(result.errors), 0)
- self.assertEqual(len(result.failures), 0)
- self.assertEqual(result.testsRun, 1)
- self.assertEqual(result.shouldStop, False)
-
- # "Called before and after tests are run. The default implementation does nothing."
- def test_startTestRun_stopTestRun(self):
- result = unittest.TestResult()
- result.startTestRun()
- result.stopTestRun()
-
- # "addSuccess(test)"
- # ...
- # "Called when the test case test succeeds"
- # ...
- # "wasSuccessful() - Returns True if all tests run so far have passed,
- # otherwise returns False"
- # ...
- # "testsRun - The total number of tests run so far."
- # ...
- # "errors - A list containing 2-tuples of TestCase instances and
- # formatted tracebacks. Each tuple represents a test which raised an
- # unexpected exception. Contains formatted
- # tracebacks instead of sys.exc_info() results."
- # ...
- # "failures - A list containing 2-tuples of TestCase instances and
- # formatted tracebacks. Each tuple represents a test where a failure was
- # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
- # methods. Contains formatted tracebacks instead
- # of sys.exc_info() results."
- def test_addSuccess(self):
- class Foo(unittest.TestCase):
- def test_1(self):
- pass
-
- test = Foo('test_1')
-
- result = unittest.TestResult()
-
- result.startTest(test)
- result.addSuccess(test)
- result.stopTest(test)
-
- self.assertTrue(result.wasSuccessful())
- self.assertEqual(len(result.errors), 0)
- self.assertEqual(len(result.failures), 0)
- self.assertEqual(result.testsRun, 1)
- self.assertEqual(result.shouldStop, False)
-
- # "addFailure(test, err)"
- # ...
- # "Called when the test case test signals a failure. err is a tuple of
- # the form returned by sys.exc_info(): (type, value, traceback)"
- # ...
- # "wasSuccessful() - Returns True if all tests run so far have passed,
- # otherwise returns False"
- # ...
- # "testsRun - The total number of tests run so far."
- # ...
- # "errors - A list containing 2-tuples of TestCase instances and
- # formatted tracebacks. Each tuple represents a test which raised an
- # unexpected exception. Contains formatted
- # tracebacks instead of sys.exc_info() results."
- # ...
- # "failures - A list containing 2-tuples of TestCase instances and
- # formatted tracebacks. Each tuple represents a test where a failure was
- # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
- # methods. Contains formatted tracebacks instead
- # of sys.exc_info() results."
- def test_addFailure(self):
- import sys
-
- class Foo(unittest.TestCase):
- def test_1(self):
- pass
-
- test = Foo('test_1')
- try:
- test.fail("foo")
- except:
- exc_info_tuple = sys.exc_info()
-
- result = unittest.TestResult()
-
- result.startTest(test)
- result.addFailure(test, exc_info_tuple)
- result.stopTest(test)
-
- self.assertFalse(result.wasSuccessful())
- self.assertEqual(len(result.errors), 0)
- self.assertEqual(len(result.failures), 1)
- self.assertEqual(result.testsRun, 1)
- self.assertEqual(result.shouldStop, False)
-
- test_case, formatted_exc = result.failures[0]
- self.assertTrue(test_case is test)
- self.assertTrue(isinstance(formatted_exc, str))
-
- # "addError(test, err)"
- # ...
- # "Called when the test case test raises an unexpected exception err
- # is a tuple of the form returned by sys.exc_info():
- # (type, value, traceback)"
- # ...
- # "wasSuccessful() - Returns True if all tests run so far have passed,
- # otherwise returns False"
- # ...
- # "testsRun - The total number of tests run so far."
- # ...
- # "errors - A list containing 2-tuples of TestCase instances and
- # formatted tracebacks. Each tuple represents a test which raised an
- # unexpected exception. Contains formatted
- # tracebacks instead of sys.exc_info() results."
- # ...
- # "failures - A list containing 2-tuples of TestCase instances and
- # formatted tracebacks. Each tuple represents a test where a failure was
- # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
- # methods. Contains formatted tracebacks instead
- # of sys.exc_info() results."
- def test_addError(self):
- import sys
-
- class Foo(unittest.TestCase):
- def test_1(self):
- pass
-
- test = Foo('test_1')
- try:
- raise TypeError()
- except:
- exc_info_tuple = sys.exc_info()
-
- result = unittest.TestResult()
-
- result.startTest(test)
- result.addError(test, exc_info_tuple)
- result.stopTest(test)
-
- self.assertFalse(result.wasSuccessful())
- self.assertEqual(len(result.errors), 1)
- self.assertEqual(len(result.failures), 0)
- self.assertEqual(result.testsRun, 1)
- self.assertEqual(result.shouldStop, False)
-
- test_case, formatted_exc = result.errors[0]
- self.assertTrue(test_case is test)
- self.assertTrue(isinstance(formatted_exc, str))
-
-### Support code for Test_TestCase
-################################################################
-
-class Foo(unittest.TestCase):
- def runTest(self): pass
- def test1(self): pass
-
-class Bar(Foo):
- def test2(self): pass
-
-class LoggingTestCase(unittest.TestCase):
- """A test case which logs its calls."""
-
- def __init__(self, events):
- super(LoggingTestCase, self).__init__('test')
- self.events = events
-
- def setUp(self):
- self.events.append('setUp')
-
- def test(self):
- self.events.append('test')
-
- def tearDown(self):
- self.events.append('tearDown')
-
-class ResultWithNoStartTestRunStopTestRun(object):
- """An object honouring TestResult before startTestRun/stopTestRun."""
-
- def __init__(self):
- self.failures = []
- self.errors = []
- self.testsRun = 0
- self.skipped = []
- self.expectedFailures = []
- self.unexpectedSuccesses = []
- self.shouldStop = False
-
- def startTest(self, test):
- pass
-
- def stopTest(self, test):
- pass
-
- def addError(self, test):
- pass
-
- def addFailure(self, test):
- pass
-
- def addSuccess(self, test):
- pass
-
- def wasSuccessful(self):
- return True
-
-
-################################################################
-### /Support code for Test_TestCase
-
-class Test_TestCase(TestCase, TestEquality, TestHashing):
-
- ### Set up attributes used by inherited tests
- ################################################################
-
- # Used by TestHashing.test_hash and TestEquality.test_eq
- eq_pairs = [(Foo('test1'), Foo('test1'))]
-
- # Used by TestEquality.test_ne
- ne_pairs = [(Foo('test1'), Foo('runTest'))
- ,(Foo('test1'), Bar('test1'))
- ,(Foo('test1'), Bar('test2'))]
-
- ################################################################
- ### /Set up attributes used by inherited tests
-
-
- # "class TestCase([methodName])"
- # ...
- # "Each instance of TestCase will run a single test method: the
- # method named methodName."
- # ...
- # "methodName defaults to "runTest"."
- #
- # Make sure it really is optional, and that it defaults to the proper
- # thing.
- def test_init__no_test_name(self):
- class Test(unittest.TestCase):
- def runTest(self): raise MyException()
- def test(self): pass
-
- self.assertEqual(Test().id()[-13:], '.Test.runTest')
-
- # "class TestCase([methodName])"
- # ...
- # "Each instance of TestCase will run a single test method: the
- # method named methodName."
- def test_init__test_name__valid(self):
- class Test(unittest.TestCase):
- def runTest(self): raise MyException()
- def test(self): pass
-
- self.assertEqual(Test('test').id()[-10:], '.Test.test')
-
- # "class TestCase([methodName])"
- # ...
- # "Each instance of TestCase will run a single test method: the
- # method named methodName."
- def test_init__test_name__invalid(self):
- class Test(unittest.TestCase):
- def runTest(self): raise MyException()
- def test(self): pass
-
- try:
- Test('testfoo')
- except ValueError:
- pass
- else:
- self.fail("Failed to raise ValueError")
-
- # "Return the number of tests represented by the this test object. For
- # TestCase instances, this will always be 1"
- def test_countTestCases(self):
- class Foo(unittest.TestCase):
- def test(self): pass
-
- self.assertEqual(Foo('test').countTestCases(), 1)
-
- # "Return the default type of test result object to be used to run this
- # test. For TestCase instances, this will always be
- # unittest.TestResult; subclasses of TestCase should
- # override this as necessary."
- def test_defaultTestResult(self):
- class Foo(unittest.TestCase):
- def runTest(self):
- pass
-
- result = Foo().defaultTestResult()
- self.assertEqual(type(result), unittest.TestResult)
-
- # "When a setUp() method is defined, the test runner will run that method
- # prior to each test. Likewise, if a tearDown() method is defined, the
- # test runner will invoke that method after each test. In the example,
- # setUp() was used to create a fresh sequence for each test."
- #
- # Make sure the proper call order is maintained, even if setUp() raises
- # an exception.
- def test_run_call_order__error_in_setUp(self):
- events = []
- result = LoggingResult(events)
-
- class Foo(LoggingTestCase):
- def setUp(self):
- super(Foo, self).setUp()
- raise RuntimeError('raised by Foo.setUp')
-
- Foo(events).run(result)
- expected = ['startTest', 'setUp', 'addError', 'stopTest']
- self.assertEqual(events, expected)
-
- # "With a temporary result stopTestRun is called when setUp errors.
- def test_run_call_order__error_in_setUp_default_result(self):
- events = []
-
- class Foo(LoggingTestCase):
- def defaultTestResult(self):
- return LoggingResult(self.events)
-
- def setUp(self):
- super(Foo, self).setUp()
- raise RuntimeError('raised by Foo.setUp')
-
- Foo(events).run()
- expected = ['startTestRun', 'startTest', 'setUp', 'addError',
- 'stopTest', 'stopTestRun']
- self.assertEqual(events, expected)
-
- # "When a setUp() method is defined, the test runner will run that method
- # prior to each test. Likewise, if a tearDown() method is defined, the
- # test runner will invoke that method after each test. In the example,
- # setUp() was used to create a fresh sequence for each test."
- #
- # Make sure the proper call order is maintained, even if the test raises
- # an error (as opposed to a failure).
- def test_run_call_order__error_in_test(self):
- events = []
- result = LoggingResult(events)
-
- class Foo(LoggingTestCase):
- def test(self):
- super(Foo, self).test()
- raise RuntimeError('raised by Foo.test')
-
- expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
- 'stopTest']
- Foo(events).run(result)
- self.assertEqual(events, expected)
-
- # "With a default result, an error in the test still results in stopTestRun
- # being called."
- def test_run_call_order__error_in_test_default_result(self):
- events = []
-
- class Foo(LoggingTestCase):
- def defaultTestResult(self):
- return LoggingResult(self.events)
-
- def test(self):
- super(Foo, self).test()
- raise RuntimeError('raised by Foo.test')
-
- expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addError',
- 'tearDown', 'stopTest', 'stopTestRun']
- Foo(events).run()
- self.assertEqual(events, expected)
-
- # "When a setUp() method is defined, the test runner will run that method
- # prior to each test. Likewise, if a tearDown() method is defined, the
- # test runner will invoke that method after each test. In the example,
- # setUp() was used to create a fresh sequence for each test."
- #
- # Make sure the proper call order is maintained, even if the test signals
- # a failure (as opposed to an error).
- def test_run_call_order__failure_in_test(self):
- events = []
- result = LoggingResult(events)
-
- class Foo(LoggingTestCase):
- def test(self):
- super(Foo, self).test()
- self.fail('raised by Foo.test')
-
- expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
- 'stopTest']
- Foo(events).run(result)
- self.assertEqual(events, expected)
-
- # "When a test fails with a default result stopTestRun is still called."
- def test_run_call_order__failure_in_test_default_result(self):
-
- class Foo(LoggingTestCase):
- def defaultTestResult(self):
- return LoggingResult(self.events)
- def test(self):
- super(Foo, self).test()
- self.fail('raised by Foo.test')
-
- expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addFailure',
- 'tearDown', 'stopTest', 'stopTestRun']
- events = []
- Foo(events).run()
- self.assertEqual(events, expected)
-
- # "When a setUp() method is defined, the test runner will run that method
- # prior to each test. Likewise, if a tearDown() method is defined, the
- # test runner will invoke that method after each test. In the example,
- # setUp() was used to create a fresh sequence for each test."
- #
- # Make sure the proper call order is maintained, even if tearDown() raises
- # an exception.
- def test_run_call_order__error_in_tearDown(self):
- events = []
- result = LoggingResult(events)
-
- class Foo(LoggingTestCase):
- def tearDown(self):
- super(Foo, self).tearDown()
- raise RuntimeError('raised by Foo.tearDown')
-
- Foo(events).run(result)
- expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
- 'stopTest']
- self.assertEqual(events, expected)
-
- # "When tearDown errors with a default result stopTestRun is still called."
- def test_run_call_order__error_in_tearDown_default_result(self):
-
- class Foo(LoggingTestCase):
- def defaultTestResult(self):
- return LoggingResult(self.events)
- def tearDown(self):
- super(Foo, self).tearDown()
- raise RuntimeError('raised by Foo.tearDown')
-
- events = []
- Foo(events).run()
- expected = ['startTestRun', 'startTest', 'setUp', 'test', 'tearDown',
- 'addError', 'stopTest', 'stopTestRun']
- self.assertEqual(events, expected)
-
- # "TestCase.run() still works when the defaultTestResult is a TestResult
- # that does not support startTestRun and stopTestRun.
- def test_run_call_order_default_result(self):
-
- class Foo(unittest.TestCase):
- def defaultTestResult(self):
- return ResultWithNoStartTestRunStopTestRun()
- def test(self):
- pass
-
- Foo('test').run()
-
- # "This class attribute gives the exception raised by the test() method.
- # If a test framework needs to use a specialized exception, possibly to
- # carry additional information, it must subclass this exception in
- # order to ``play fair'' with the framework. The initial value of this
- # attribute is AssertionError"
- def test_failureException__default(self):
- class Foo(unittest.TestCase):
- def test(self):
- pass
-
- self.assertTrue(Foo('test').failureException is AssertionError)
-
- # "This class attribute gives the exception raised by the test() method.
- # If a test framework needs to use a specialized exception, possibly to
- # carry additional information, it must subclass this exception in
- # order to ``play fair'' with the framework."
- #
- # Make sure TestCase.run() respects the designated failureException
- def test_failureException__subclassing__explicit_raise(self):
- events = []
- result = LoggingResult(events)
-
- class Foo(unittest.TestCase):
- def test(self):
- raise RuntimeError()
-
- failureException = RuntimeError
-
- self.assertTrue(Foo('test').failureException is RuntimeError)
-
-
- Foo('test').run(result)
- expected = ['startTest', 'addFailure', 'stopTest']
- self.assertEqual(events, expected)
-
- # "This class attribute gives the exception raised by the test() method.
- # If a test framework needs to use a specialized exception, possibly to
- # carry additional information, it must subclass this exception in
- # order to ``play fair'' with the framework."
- #
- # Make sure TestCase.run() respects the designated failureException
- def test_failureException__subclassing__implicit_raise(self):
- events = []
- result = LoggingResult(events)
-
- class Foo(unittest.TestCase):
- def test(self):
- self.fail("foo")
-
- failureException = RuntimeError
-
- self.assertTrue(Foo('test').failureException is RuntimeError)
-
-
- Foo('test').run(result)
- expected = ['startTest', 'addFailure', 'stopTest']
- self.assertEqual(events, expected)
-
- # "The default implementation does nothing."
- def test_setUp(self):
- class Foo(unittest.TestCase):
- def runTest(self):
- pass
-
- # ... and nothing should happen
- Foo().setUp()
-
- # "The default implementation does nothing."
- def test_tearDown(self):
- class Foo(unittest.TestCase):
- def runTest(self):
- pass
-
- # ... and nothing should happen
- Foo().tearDown()
-
- # "Return a string identifying the specific test case."
- #
- # Because of the vague nature of the docs, I'm not going to lock this
- # test down too much. Really all that can be asserted is that the id()
- # will be a string (either 8-byte or unicode -- again, because the docs
- # just say "string")
- def test_id(self):
- class Foo(unittest.TestCase):
- def runTest(self):
- pass
-
- self.assertTrue(isinstance(Foo().id(), str))
-
- # "If result is omitted or None, a temporary result object is created
- # and used, but is not made available to the caller. As TestCase owns the
- # temporary result startTestRun and stopTestRun are called.
-
- def test_run__uses_defaultTestResult(self):
- events = []
-
- class Foo(unittest.TestCase):
- def test(self):
- events.append('test')
-
- def defaultTestResult(self):
- return LoggingResult(events)
-
- # Make run() find a result object on its own
- Foo('test').run()
-
- expected = ['startTestRun', 'startTest', 'test', 'addSuccess',
- 'stopTest', 'stopTestRun']
- self.assertEqual(events, expected)
-
- def testShortDescriptionWithoutDocstring(self):
- self.assertEqual(
- self.shortDescription(),
- 'testShortDescriptionWithoutDocstring (' + __name__ +
- '.Test_TestCase)')
-
- def testShortDescriptionWithOneLineDocstring(self):
- """Tests shortDescription() for a method with a docstring."""
- self.assertEqual(
- self.shortDescription(),
- ('testShortDescriptionWithOneLineDocstring '
- '(' + __name__ + '.Test_TestCase)\n'
- 'Tests shortDescription() for a method with a docstring.'))
-
- def testShortDescriptionWithMultiLineDocstring(self):
- """Tests shortDescription() for a method with a longer docstring.
-
- This method ensures that only the first line of a docstring is
- returned used in the short description, no matter how long the
- whole thing is.
- """
- self.assertEqual(
- self.shortDescription(),
- ('testShortDescriptionWithMultiLineDocstring '
- '(' + __name__ + '.Test_TestCase)\n'
- 'Tests shortDescription() for a method with a longer '
- 'docstring.'))
-
- def testAddTypeEqualityFunc(self):
- class SadSnake(object):
- """Dummy class for test_addTypeEqualityFunc."""
- s1, s2 = SadSnake(), SadSnake()
- self.assertFalse(s1 == s2)
- def AllSnakesCreatedEqual(a, b, msg=None):
- return type(a) == type(b) == SadSnake
- self.addTypeEqualityFunc(SadSnake, AllSnakesCreatedEqual)
- self.assertEqual(s1, s2)
- # No this doesn't clean up and remove the SadSnake equality func
- # from this TestCase instance but since its a local nothing else
- # will ever notice that.
-
- def testAssertIs(self):
- thing = object()
- self.assertIs(thing, thing)
- self.assertRaises(self.failureException, self.assertIs, thing, object())
-
- def testAssertIsNot(self):
- thing = object()
- self.assertIsNot(thing, object())
- self.assertRaises(self.failureException, self.assertIsNot, thing, thing)
-
- def testAssertIn(self):
- animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'}
-
- self.assertIn('a', 'abc')
- self.assertIn(2, [1, 2, 3])
- self.assertIn('monkey', animals)
-
- self.assertNotIn('d', 'abc')
- self.assertNotIn(0, [1, 2, 3])
- self.assertNotIn('otter', animals)
-
- self.assertRaises(self.failureException, self.assertIn, 'x', 'abc')
- self.assertRaises(self.failureException, self.assertIn, 4, [1, 2, 3])
- self.assertRaises(self.failureException, self.assertIn, 'elephant',
- animals)
-
- self.assertRaises(self.failureException, self.assertNotIn, 'c', 'abc')
- self.assertRaises(self.failureException, self.assertNotIn, 1, [1, 2, 3])
- self.assertRaises(self.failureException, self.assertNotIn, 'cow',
- animals)
-
- def testAssertDictContainsSubset(self):
- self.assertDictContainsSubset({}, {})
- self.assertDictContainsSubset({}, {'a': 1})
- self.assertDictContainsSubset({'a': 1}, {'a': 1})
- self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
- self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})
-
- self.assertRaises(unittest.TestCase.failureException,
- self.assertDictContainsSubset, {'a': 2}, {'a': 1},
- '.*Mismatched values:.*')
-
- self.assertRaises(unittest.TestCase.failureException,
- self.assertDictContainsSubset, {'c': 1}, {'a': 1},
- '.*Missing:.*')
-
- self.assertRaises(unittest.TestCase.failureException,
- self.assertDictContainsSubset, {'a': 1, 'c': 1},
- {'a': 1}, '.*Missing:.*')
-
- self.assertRaises(unittest.TestCase.failureException,
- self.assertDictContainsSubset, {'a': 1, 'c': 1},
- {'a': 1}, '.*Missing:.*Mismatched values:.*')
-
- def testAssertEqual(self):
- equal_pairs = [
- ((), ()),
- ({}, {}),
- ([], []),
- (set(), set()),
- (frozenset(), frozenset())]
- for a, b in equal_pairs:
- # This mess of try excepts is to test the assertEqual behavior
- # itself.
- try:
- self.assertEqual(a, b)
- except self.failureException:
- self.fail('assertEqual(%r, %r) failed' % (a, b))
- try:
- self.assertEqual(a, b, msg='foo')
- except self.failureException:
- self.fail('assertEqual(%r, %r) with msg= failed' % (a, b))
- try:
- self.assertEqual(a, b, 'foo')
- except self.failureException:
- self.fail('assertEqual(%r, %r) with third parameter failed' %
- (a, b))
-
- unequal_pairs = [
- ((), []),
- ({}, set()),
- (set([4,1]), frozenset([4,2])),
- (frozenset([4,5]), set([2,3])),
- (set([3,4]), set([5,4]))]
- for a, b in unequal_pairs:
- self.assertRaises(self.failureException, self.assertEqual, a, b)
- self.assertRaises(self.failureException, self.assertEqual, a, b,
- 'foo')
- self.assertRaises(self.failureException, self.assertEqual, a, b,
- msg='foo')
-
- def testEquality(self):
- self.assertListEqual([], [])
- self.assertTupleEqual((), ())
- self.assertSequenceEqual([], ())
-
- a = [0, 'a', []]
- b = []
- self.assertRaises(unittest.TestCase.failureException,
- self.assertListEqual, a, b)
- self.assertRaises(unittest.TestCase.failureException,
- self.assertListEqual, tuple(a), tuple(b))
- self.assertRaises(unittest.TestCase.failureException,
- self.assertSequenceEqual, a, tuple(b))
-
- b.extend(a)
- self.assertListEqual(a, b)
- self.assertTupleEqual(tuple(a), tuple(b))
- self.assertSequenceEqual(a, tuple(b))
- self.assertSequenceEqual(tuple(a), b)
-
- self.assertRaises(self.failureException, self.assertListEqual,
- a, tuple(b))
- self.assertRaises(self.failureException, self.assertTupleEqual,
- tuple(a), b)
- self.assertRaises(self.failureException, self.assertListEqual, None, b)
- self.assertRaises(self.failureException, self.assertTupleEqual, None,
- tuple(b))
- self.assertRaises(self.failureException, self.assertSequenceEqual,
- None, tuple(b))
- self.assertRaises(self.failureException, self.assertListEqual, 1, 1)
- self.assertRaises(self.failureException, self.assertTupleEqual, 1, 1)
- self.assertRaises(self.failureException, self.assertSequenceEqual,
- 1, 1)
-
- self.assertDictEqual({}, {})
-
- c = { 'x': 1 }
- d = {}
- self.assertRaises(unittest.TestCase.failureException,
- self.assertDictEqual, c, d)
-
- d.update(c)
- self.assertDictEqual(c, d)
-
- d['x'] = 0
- self.assertRaises(unittest.TestCase.failureException,
- self.assertDictEqual, c, d, 'These are unequal')
-
- self.assertRaises(self.failureException, self.assertDictEqual, None, d)
- self.assertRaises(self.failureException, self.assertDictEqual, [], d)
- self.assertRaises(self.failureException, self.assertDictEqual, 1, 1)
-
- self.assertSameElements([1, 2, 3], [3, 2, 1])
- self.assertSameElements([1, 2] + [3] * 100, [1] * 100 + [2, 3])
- self.assertSameElements(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
- self.assertRaises(self.failureException, self.assertSameElements,
- [10], [10, 11])
- self.assertRaises(self.failureException, self.assertSameElements,
- [10, 11], [10])
-
- # Test that sequences of unhashable objects can be tested for sameness:
- self.assertSameElements([[1, 2], [3, 4]], [[3, 4], [1, 2]])
-
- self.assertSameElements([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
- self.assertRaises(self.failureException, self.assertSameElements,
- [[1]], [[2]])
- self.assertRaises(self.failureException, self.assertSameElements,
- [{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 2}])
-
- def testAssertSetEqual(self):
- set1 = set()
- set2 = set()
- self.assertSetEqual(set1, set2)
-
- self.assertRaises(self.failureException, self.assertSetEqual, None, set2)
- self.assertRaises(self.failureException, self.assertSetEqual, [], set2)
- self.assertRaises(self.failureException, self.assertSetEqual, set1, None)
- self.assertRaises(self.failureException, self.assertSetEqual, set1, [])
-
- set1 = set(['a'])
- set2 = set()
- self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
-
- set1 = set(['a'])
- set2 = set(['a'])
- self.assertSetEqual(set1, set2)
-
- set1 = set(['a'])
- set2 = set(['a', 'b'])
- self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
-
- set1 = set(['a'])
- set2 = frozenset(['a', 'b'])
- self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
-
- set1 = set(['a', 'b'])
- set2 = frozenset(['a', 'b'])
- self.assertSetEqual(set1, set2)
-
- set1 = set()
- set2 = "foo"
- self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
- self.assertRaises(self.failureException, self.assertSetEqual, set2, set1)
-
- # make sure any string formatting is tuple-safe
- set1 = set([(0, 1), (2, 3)])
- set2 = set([(4, 5)])
- self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
-
- def testInequality(self):
- # Try ints
- self.assertGreater(2, 1)
- self.assertGreaterEqual(2, 1)
- self.assertGreaterEqual(1, 1)
- self.assertLess(1, 2)
- self.assertLessEqual(1, 2)
- self.assertLessEqual(1, 1)
- self.assertRaises(self.failureException, self.assertGreater, 1, 2)
- self.assertRaises(self.failureException, self.assertGreater, 1, 1)
- self.assertRaises(self.failureException, self.assertGreaterEqual, 1, 2)
- self.assertRaises(self.failureException, self.assertLess, 2, 1)
- self.assertRaises(self.failureException, self.assertLess, 1, 1)
- self.assertRaises(self.failureException, self.assertLessEqual, 2, 1)
-
- # Try Floats
- self.assertGreater(1.1, 1.0)
- self.assertGreaterEqual(1.1, 1.0)
- self.assertGreaterEqual(1.0, 1.0)
- self.assertLess(1.0, 1.1)
- self.assertLessEqual(1.0, 1.1)
- self.assertLessEqual(1.0, 1.0)
- self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.1)
- self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.0)
- self.assertRaises(self.failureException, self.assertGreaterEqual, 1.0, 1.1)
- self.assertRaises(self.failureException, self.assertLess, 1.1, 1.0)
- self.assertRaises(self.failureException, self.assertLess, 1.0, 1.0)
- self.assertRaises(self.failureException, self.assertLessEqual, 1.1, 1.0)
-
- # Try Strings
- self.assertGreater('bug', 'ant')
- self.assertGreaterEqual('bug', 'ant')
- self.assertGreaterEqual('ant', 'ant')
- self.assertLess('ant', 'bug')
- self.assertLessEqual('ant', 'bug')
- self.assertLessEqual('ant', 'ant')
- self.assertRaises(self.failureException, self.assertGreater, 'ant', 'bug')
- self.assertRaises(self.failureException, self.assertGreater, 'ant', 'ant')
- self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant', 'bug')
- self.assertRaises(self.failureException, self.assertLess, 'bug', 'ant')
- self.assertRaises(self.failureException, self.assertLess, 'ant', 'ant')
- self.assertRaises(self.failureException, self.assertLessEqual, 'bug', 'ant')
-
- # Try bytes
- self.assertGreater(b'bug', b'ant')
- self.assertGreaterEqual(b'bug', b'ant')
- self.assertGreaterEqual(b'ant', b'ant')
- self.assertLess(b'ant', b'bug')
- self.assertLessEqual(b'ant', b'bug')
- self.assertLessEqual(b'ant', b'ant')
- self.assertRaises(self.failureException, self.assertGreater, b'ant', b'bug')
- self.assertRaises(self.failureException, self.assertGreater, b'ant', b'ant')
- self.assertRaises(self.failureException, self.assertGreaterEqual, b'ant',
- b'bug')
- self.assertRaises(self.failureException, self.assertLess, b'bug', b'ant')
- self.assertRaises(self.failureException, self.assertLess, b'ant', b'ant')
- self.assertRaises(self.failureException, self.assertLessEqual, b'bug', b'ant')
-
- def testAssertMultiLineEqual(self):
- sample_text = """\
-http://www.python.org/doc/2.3/lib/module-unittest.html
-test case
- A test case is the smallest unit of testing. [...]
-"""
- revised_sample_text = """\
-http://www.python.org/doc/2.4.1/lib/module-unittest.html
-test case
- A test case is the smallest unit of testing. [...] You may provide your
- own implementation that does not subclass from TestCase, of course.
-"""
- sample_text_error = """
-- http://www.python.org/doc/2.3/lib/module-unittest.html
-? ^
-+ http://www.python.org/doc/2.4.1/lib/module-unittest.html
-? ^^^
- test case
-- A test case is the smallest unit of testing. [...]
-+ A test case is the smallest unit of testing. [...] You may provide your
-? +++++++++++++++++++++
-+ own implementation that does not subclass from TestCase, of course.
-"""
-
- try:
- self.assertMultiLineEqual(sample_text, revised_sample_text)
- except self.failureException as e:
- # no fair testing ourself with ourself, use assertEqual..
- self.assertEqual(sample_text_error, str(e))
-
- def testAssertIsNone(self):
- self.assertIsNone(None)
- self.assertRaises(self.failureException, self.assertIsNone, False)
- self.assertIsNotNone('DjZoPloGears on Rails')
- self.assertRaises(self.failureException, self.assertIsNotNone, None)
-
- def testAssertRegexpMatches(self):
- self.assertRegexpMatches('asdfabasdf', r'ab+')
- self.assertRaises(self.failureException, self.assertRegexpMatches,
- 'saaas', r'aaaa')
-
- def testAssertRaisesRegexp(self):
- class ExceptionMock(Exception):
- pass
-
- def Stub():
- raise ExceptionMock('We expect')
-
- self.assertRaisesRegexp(ExceptionMock, re.compile('expect$'), Stub)
- self.assertRaisesRegexp(ExceptionMock, 'expect$', Stub)
-
- def testAssertNotRaisesRegexp(self):
- self.assertRaisesRegexp(
- self.failureException, '^Exception not raised by <lambda>$',
- self.assertRaisesRegexp, Exception, re.compile('x'),
- lambda: None)
- self.assertRaisesRegexp(
- self.failureException, '^Exception not raised by <lambda>$',
- self.assertRaisesRegexp, Exception, 'x',
- lambda: None)
-
- def testAssertRaisesRegexpMismatch(self):
- def Stub():
- raise Exception('Unexpected')
-
- self.assertRaisesRegexp(
- self.failureException,
- r'"\^Expected\$" does not match "Unexpected"',
- self.assertRaisesRegexp, Exception, '^Expected$',
- Stub)
- self.assertRaisesRegexp(
- self.failureException,
- r'"\^Expected\$" does not match "Unexpected"',
- self.assertRaisesRegexp, Exception,
- re.compile('^Expected$'), Stub)
-
- def testSynonymAssertMethodNames(self):
- """Test undocumented method name synonyms.
-
- Please do not use these methods names in your own code.
-
- This test confirms their continued existence and functionality
- in order to avoid breaking existing code.
- """
- self.assertNotEquals(3, 5)
- self.assertEquals(3, 3)
- self.assertAlmostEquals(2.0, 2.0)
- self.assertNotAlmostEquals(3.0, 5.0)
- self.assert_(True)
-
- def testPendingDeprecationMethodNames(self):
- """Test fail* methods pending deprecation, they will warn in 3.2.
-
- Do not use these methods. They will go away in 3.3.
- """
- self.failIfEqual(3, 5)
- self.failUnlessEqual(3, 3)
- self.failUnlessAlmostEqual(2.0, 2.0)
- self.failIfAlmostEqual(3.0, 5.0)
- self.failUnless(True)
- self.failUnlessRaises(TypeError, lambda _: 3.14 + 'spam')
- self.failIf(False)
-
- def testDeepcopy(self):
- # Issue: 5660
- class TestableTest(TestCase):
- def testNothing(self):
- pass
-
- test = TestableTest('testNothing')
-
- # This shouldn't blow up
- deepcopy(test)
-
-
-class Test_TestSkipping(TestCase):
-
- def test_skipping(self):
- class Foo(unittest.TestCase):
- def test_skip_me(self):
- self.skipTest("skip")
- events = []
- result = LoggingResult(events)
- test = Foo("test_skip_me")
- test.run(result)
- self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
- self.assertEqual(result.skipped, [(test, "skip")])
-
- # Try letting setUp skip the test now.
- class Foo(unittest.TestCase):
- def setUp(self):
- self.skipTest("testing")
- def test_nothing(self): pass
- events = []
- result = LoggingResult(events)
- test = Foo("test_nothing")
- test.run(result)
- self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
- self.assertEqual(result.skipped, [(test, "testing")])
- self.assertEqual(result.testsRun, 1)
-
- def test_skipping_decorators(self):
- op_table = ((unittest.skipUnless, False, True),
- (unittest.skipIf, True, False))
- for deco, do_skip, dont_skip in op_table:
- class Foo(unittest.TestCase):
- @deco(do_skip, "testing")
- def test_skip(self): pass
-
- @deco(dont_skip, "testing")
- def test_dont_skip(self): pass
- test_do_skip = Foo("test_skip")
- test_dont_skip = Foo("test_dont_skip")
- suite = unittest.TestSuite([test_do_skip, test_dont_skip])
- events = []
- result = LoggingResult(events)
- suite.run(result)
- self.assertEqual(len(result.skipped), 1)
- expected = ['startTest', 'addSkip', 'stopTest',
- 'startTest', 'addSuccess', 'stopTest']
- self.assertEqual(events, expected)
- self.assertEqual(result.testsRun, 2)
- self.assertEqual(result.skipped, [(test_do_skip, "testing")])
- self.assertTrue(result.wasSuccessful())
-
- def test_skip_class(self):
- @unittest.skip("testing")
- class Foo(unittest.TestCase):
- def test_1(self):
- record.append(1)
- record = []
- result = unittest.TestResult()
- test = Foo("test_1")
- suite = unittest.TestSuite([test])
- suite.run(result)
- self.assertEqual(result.skipped, [(test, "testing")])
- self.assertEqual(record, [])
-
- def test_expected_failure(self):
- class Foo(unittest.TestCase):
- @unittest.expectedFailure
- def test_die(self):
- self.fail("help me!")
- events = []
- result = LoggingResult(events)
- test = Foo("test_die")
- test.run(result)
- self.assertEqual(events,
- ['startTest', 'addExpectedFailure', 'stopTest'])
- self.assertEqual(result.expectedFailures[0][0], test)
- self.assertTrue(result.wasSuccessful())
-
- def test_unexpected_success(self):
- class Foo(unittest.TestCase):
- @unittest.expectedFailure
- def test_die(self):
- pass
- events = []
- result = LoggingResult(events)
- test = Foo("test_die")
- test.run(result)
- self.assertEqual(events,
- ['startTest', 'addUnexpectedSuccess', 'stopTest'])
- self.assertFalse(result.failures)
- self.assertEqual(result.unexpectedSuccesses, [test])
- self.assertTrue(result.wasSuccessful())
-
-
-
-class Test_Assertions(TestCase):
- def test_AlmostEqual(self):
- self.assertAlmostEqual(1.00000001, 1.0)
- self.assertNotAlmostEqual(1.0000001, 1.0)
- self.assertRaises(self.failureException,
- self.assertAlmostEqual, 1.0000001, 1.0)
- self.assertRaises(self.failureException,
- self.assertNotAlmostEqual, 1.00000001, 1.0)
-
- self.assertAlmostEqual(1.1, 1.0, places=0)
- self.assertRaises(self.failureException,
- self.assertAlmostEqual, 1.1, 1.0, places=1)
-
- self.assertAlmostEqual(0, .1+.1j, places=0)
- self.assertNotAlmostEqual(0, .1+.1j, places=1)
- self.assertRaises(self.failureException,
- self.assertAlmostEqual, 0, .1+.1j, places=1)
- self.assertRaises(self.failureException,
- self.assertNotAlmostEqual, 0, .1+.1j, places=0)
-
- def test_assertRaises(self):
- def _raise(e):
- raise e
- self.assertRaises(KeyError, _raise, KeyError)
- self.assertRaises(KeyError, _raise, KeyError("key"))
- try:
- self.assertRaises(KeyError, lambda: None)
- except self.failureException as e:
- self.assertIn("KeyError not raised", str(e))
- else:
- self.fail("assertRaises() didn't fail")
- try:
- self.assertRaises(KeyError, _raise, ValueError)
- except ValueError:
- pass
- else:
- self.fail("assertRaises() didn't let exception pass through")
- with self.assertRaises(KeyError):
- raise KeyError
- with self.assertRaises(KeyError):
- raise KeyError("key")
- try:
- with self.assertRaises(KeyError):
- pass
- except self.failureException as e:
- self.assertIn("KeyError not raised", str(e))
- else:
- self.fail("assertRaises() didn't fail")
- try:
- with self.assertRaises(KeyError):
- raise ValueError
- except ValueError:
- pass
- else:
- self.fail("assertRaises() didn't let exception pass through")
-
-
-class TestLongMessage(TestCase):
- """Test that the individual asserts honour longMessage.
- This actually tests all the message behaviour for
- asserts that use longMessage."""
-
- def setUp(self):
- class TestableTestFalse(TestCase):
- longMessage = False
- failureException = self.failureException
-
- def testTest(self):
- pass
-
- class TestableTestTrue(TestCase):
- longMessage = True
- failureException = self.failureException
-
- def testTest(self):
- pass
-
- self.testableTrue = TestableTestTrue('testTest')
- self.testableFalse = TestableTestFalse('testTest')
-
- def testDefault(self):
- self.assertFalse(TestCase.longMessage)
-
- def test_formatMsg(self):
- self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo")
- self.assertEqual(self.testableFalse._formatMessage("foo", "bar"), "foo")
-
- self.assertEqual(self.testableTrue._formatMessage(None, "foo"), "foo")
- self.assertEqual(self.testableTrue._formatMessage("foo", "bar"), "bar : foo")
-
- def assertMessages(self, methodName, args, errors):
- def getMethod(i):
- useTestableFalse = i < 2
- if useTestableFalse:
- test = self.testableFalse
- else:
- test = self.testableTrue
- return getattr(test, methodName)
-
- for i, expected_regexp in enumerate(errors):
- testMethod = getMethod(i)
- kwargs = {}
- withMsg = i % 2
- if withMsg:
- kwargs = {"msg": "oops"}
-
- with self.assertRaisesRegexp(self.failureException,
- expected_regexp=expected_regexp):
- testMethod(*args, **kwargs)
-
- def testAssertTrue(self):
- self.assertMessages('assertTrue', (False,),
- ["^False is not true$", "^oops$", "^False is not true$",
- "^False is not true : oops$"])
-
- def testAssertFalse(self):
- self.assertMessages('assertFalse', (True,),
- ["^True is not false$", "^oops$", "^True is not false$",
- "^True is not false : oops$"])
-
- def testNotEqual(self):
- self.assertMessages('assertNotEqual', (1, 1),
- ["^1 == 1$", "^oops$", "^1 == 1$",
- "^1 == 1 : oops$"])
-
- def testAlmostEqual(self):
- self.assertMessages('assertAlmostEqual', (1, 2),
- ["^1 != 2 within 7 places$", "^oops$",
- "^1 != 2 within 7 places$", "^1 != 2 within 7 places : oops$"])
-
- def testNotAlmostEqual(self):
- self.assertMessages('assertNotAlmostEqual', (1, 1),
- ["^1 == 1 within 7 places$", "^oops$",
- "^1 == 1 within 7 places$", "^1 == 1 within 7 places : oops$"])
-
- def test_baseAssertEqual(self):
- self.assertMessages('_baseAssertEqual', (1, 2),
- ["^1 != 2$", "^oops$", "^1 != 2$", "^1 != 2 : oops$"])
-
- def testAssertSequenceEqual(self):
- # Error messages are multiline so not testing on full message
- # assertTupleEqual and assertListEqual delegate to this method
- self.assertMessages('assertSequenceEqual', ([], [None]),
- ["\+ \[None\]$", "^oops$", r"\+ \[None\]$",
- r"\+ \[None\] : oops$"])
-
- def testAssertSetEqual(self):
- self.assertMessages('assertSetEqual', (set(), set([None])),
- ["None$", "^oops$", "None$",
- "None : oops$"])
-
- def testAssertIn(self):
- self.assertMessages('assertIn', (None, []),
- ['^None not found in \[\]$', "^oops$",
- '^None not found in \[\]$',
- '^None not found in \[\] : oops$'])
-
- def testAssertNotIn(self):
- self.assertMessages('assertNotIn', (None, [None]),
- ['^None unexpectedly found in \[None\]$', "^oops$",
- '^None unexpectedly found in \[None\]$',
- '^None unexpectedly found in \[None\] : oops$'])
-
- def testAssertDictEqual(self):
- self.assertMessages('assertDictEqual', ({}, {'key': 'value'}),
- [r"\+ \{'key': 'value'\}$", "^oops$",
- "\+ \{'key': 'value'\}$",
- "\+ \{'key': 'value'\} : oops$"])
-
- def testAssertDictContainsSubset(self):
- self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}),
- ["^Missing: 'key'$", "^oops$",
- "^Missing: 'key'$",
- "^Missing: 'key' : oops$"])
-
- def testAssertSameElements(self):
- self.assertMessages('assertSameElements', ([], [None]),
- [r"\[None\]$", "^oops$",
- r"\[None\]$",
- r"\[None\] : oops$"])
-
- def testAssertMultiLineEqual(self):
- self.assertMessages('assertMultiLineEqual', ("", "foo"),
- [r"\+ foo$", "^oops$",
- r"\+ foo$",
- r"\+ foo : oops$"])
-
- def testAssertLess(self):
- self.assertMessages('assertLess', (2, 1),
- ["^2 not less than 1$", "^oops$",
- "^2 not less than 1$", "^2 not less than 1 : oops$"])
-
- def testAssertLessEqual(self):
- self.assertMessages('assertLessEqual', (2, 1),
- ["^2 not less than or equal to 1$", "^oops$",
- "^2 not less than or equal to 1$",
- "^2 not less than or equal to 1 : oops$"])
-
- def testAssertGreater(self):
- self.assertMessages('assertGreater', (1, 2),
- ["^1 not greater than 2$", "^oops$",
- "^1 not greater than 2$",
- "^1 not greater than 2 : oops$"])
-
- def testAssertGreaterEqual(self):
- self.assertMessages('assertGreaterEqual', (1, 2),
- ["^1 not greater than or equal to 2$", "^oops$",
- "^1 not greater than or equal to 2$",
- "^1 not greater than or equal to 2 : oops$"])
-
- def testAssertIsNone(self):
- self.assertMessages('assertIsNone', ('not None',),
- ["^'not None' is not None$", "^oops$",
- "^'not None' is not None$",
- "^'not None' is not None : oops$"])
-
- def testAssertIsNotNone(self):
- self.assertMessages('assertIsNotNone', (None,),
- ["^unexpectedly None$", "^oops$",
- "^unexpectedly None$",
- "^unexpectedly None : oops$"])
-
- def testAssertIs(self):
- self.assertMessages('assertIs', (None, 'foo'),
- ["^None is not 'foo'$", "^oops$",
- "^None is not 'foo'$",
- "^None is not 'foo' : oops$"])
-
- def testAssertIsNot(self):
- self.assertMessages('assertIsNot', (None, None),
- ["^unexpectedly identical: None$", "^oops$",
- "^unexpectedly identical: None$",
- "^unexpectedly identical: None : oops$"])
-
-
-class TestCleanUp(TestCase):
-
- def testCleanUp(self):
- class TestableTest(TestCase):
- def testNothing(self):
- pass
-
- test = TestableTest('testNothing')
- self.assertEqual(test._cleanups, [])
-
- cleanups = []
-
- def cleanup1(*args, **kwargs):
- cleanups.append((1, args, kwargs))
-
- def cleanup2(*args, **kwargs):
- cleanups.append((2, args, kwargs))
-
- test.addCleanup(cleanup1, 1, 2, 3, four='hello', five='goodbye')
- test.addCleanup(cleanup2)
-
- self.assertEqual(test._cleanups,
- [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')),
- (cleanup2, (), {})])
-
- result = test.doCleanups()
- self.assertTrue(result)
-
- self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))])
-
- def testCleanUpWithErrors(self):
- class TestableTest(TestCase):
- def testNothing(self):
- pass
-
- class MockResult(object):
- errors = []
- def addError(self, test, exc_info):
- self.errors.append((test, exc_info))
-
- result = MockResult()
- test = TestableTest('testNothing')
- test._resultForDoCleanups = result
-
- exc1 = Exception('foo')
- exc2 = Exception('bar')
- def cleanup1():
- raise exc1
-
- def cleanup2():
- raise exc2
-
- test.addCleanup(cleanup1)
- test.addCleanup(cleanup2)
-
- self.assertFalse(test.doCleanups())
-
- (test1, (Type1, instance1, _)), (test2, (Type2, instance2, _)) = reversed(MockResult.errors)
- self.assertEqual((test1, Type1, instance1), (test, Exception, exc1))
- self.assertEqual((test2, Type2, instance2), (test, Exception, exc2))
-
- def testCleanupInRun(self):
- blowUp = False
- ordering = []
-
- class TestableTest(TestCase):
- def setUp(self):
- ordering.append('setUp')
- if blowUp:
- raise Exception('foo')
-
- def testNothing(self):
- ordering.append('test')
-
- def tearDown(self):
- ordering.append('tearDown')
-
- test = TestableTest('testNothing')
-
- def cleanup1():
- ordering.append('cleanup1')
- def cleanup2():
- ordering.append('cleanup2')
- test.addCleanup(cleanup1)
- test.addCleanup(cleanup2)
-
- def success(some_test):
- self.assertEqual(some_test, test)
- ordering.append('success')
-
- result = unittest.TestResult()
- result.addSuccess = success
-
- test.run(result)
- self.assertEqual(ordering, ['setUp', 'test', 'tearDown',
- 'cleanup2', 'cleanup1', 'success'])
-
- blowUp = True
- ordering = []
- test = TestableTest('testNothing')
- test.addCleanup(cleanup1)
- test.run(result)
- self.assertEqual(ordering, ['setUp', 'cleanup1'])
-
-
-class Test_TestProgram(TestCase):
-
- # Horrible white box test
- def testNoExit(self):
- result = object()
- test = object()
-
- class FakeRunner(object):
- def run(self, test):
- self.test = test
- return result
-
- runner = FakeRunner()
-
- try:
- oldParseArgs = TestProgram.parseArgs
- TestProgram.parseArgs = lambda *args: None
- TestProgram.test = test
-
- program = TestProgram(testRunner=runner, exit=False)
-
- self.assertEqual(program.result, result)
- self.assertEqual(runner.test, test)
-
- finally:
- TestProgram.parseArgs = oldParseArgs
- del TestProgram.test
-
-
- class FooBar(unittest.TestCase):
- def testPass(self):
- assert True
- def testFail(self):
- assert False
-
- class FooBarLoader(unittest.TestLoader):
- """Test loader that returns a suite containing FooBar."""
- def loadTestsFromModule(self, module):
- return self.suiteClass(
- [self.loadTestsFromTestCase(Test_TestProgram.FooBar)])
-
-
- def test_NonExit(self):
- program = unittest.main(exit=False,
- argv=["foobar"],
- testRunner=unittest.TextTestRunner(stream=io.StringIO()),
- testLoader=self.FooBarLoader())
- self.assertTrue(hasattr(program, 'result'))
-
-
- def test_Exit(self):
- self.assertRaises(
- SystemExit,
- unittest.main,
- argv=["foobar"],
- testRunner=unittest.TextTestRunner(stream=io.StringIO()),
- exit=True,
- testLoader=self.FooBarLoader())
-
-
- def test_ExitAsDefault(self):
- self.assertRaises(
- SystemExit,
- unittest.main,
- argv=["foobar"],
- testRunner=unittest.TextTestRunner(stream=io.StringIO()),
- testLoader=self.FooBarLoader())
-
-
-class Test_TextTestRunner(TestCase):
- """Tests for TextTestRunner."""
-
- def test_works_with_result_without_startTestRun_stopTestRun(self):
- class OldTextResult(ResultWithNoStartTestRunStopTestRun):
- separator2 = ''
- def printErrors(self):
- pass
-
- class Runner(unittest.TextTestRunner):
- def __init__(self):
- super(Runner, self).__init__(io.StringIO())
-
- def _makeResult(self):
- return OldTextResult()
-
- runner = Runner()
- runner.run(unittest.TestSuite())
-
- def test_startTestRun_stopTestRun_called(self):
- class LoggingTextResult(LoggingResult):
- separator2 = ''
- def printErrors(self):
- pass
-
- class LoggingRunner(unittest.TextTestRunner):
- def __init__(self, events):
- super(LoggingRunner, self).__init__(io.StringIO())
- self._events = events
-
- def _makeResult(self):
- return LoggingTextResult(self._events)
-
- events = []
- runner = LoggingRunner(events)
- runner.run(unittest.TestSuite())
- expected = ['startTestRun', 'stopTestRun']
- self.assertEqual(events, expected)
-
-
-######################################################################
-## Main
-######################################################################
def test_main():
- support.run_unittest(Test_TestCase, Test_TestLoader,
- Test_TestSuite, Test_TestResult, Test_FunctionTestCase,
- Test_TestSkipping, Test_Assertions, TestLongMessage,
- Test_TestProgram, TestCleanUp)
+ # used by regrtest
+ support.run_unittest(unittest.test.suite())
+ support.reap_children()
+
+def load_tests(*_):
+ # used by unittest
+ return unittest.test.suite()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py
index b1531f306d..b1c483d4d5 100644
--- a/Lib/test/test_unpack.py
+++ b/Lib/test/test_unpack.py
@@ -62,14 +62,14 @@ Unpacking tuple of wrong size
>>> a, b = t
Traceback (most recent call last):
...
- ValueError: too many values to unpack
+ ValueError: too many values to unpack (expected 2)
Unpacking tuple of wrong size
>>> a, b = l
Traceback (most recent call last):
...
- ValueError: too many values to unpack
+ ValueError: too many values to unpack (expected 2)
Unpacking sequence too short
@@ -83,7 +83,7 @@ Unpacking sequence too long
>>> a, b = Seq()
Traceback (most recent call last):
...
- ValueError: too many values to unpack
+ ValueError: too many values to unpack (expected 2)
Unpacking a sequence where the test for too long raises a different kind of
error
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 422831e35f..673afc42a6 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -9,7 +9,6 @@ import unittest
from test import support
import os
import tempfile
-import warnings
def hexescape(char):
"""Escape char as RFC 2396 specifies"""
@@ -86,8 +85,7 @@ class urlopen_FileTests(unittest.TestCase):
def test_fileno(self):
file_num = self.returned_obj.fileno()
- self.assertTrue(isinstance(file_num, int),
- "fileno() did not return an int")
+ self.assertIsInstance(file_num, int, "fileno() did not return an int")
self.assertEqual(os.read(file_num, len(self.text)), self.text,
"Reading on the file descriptor returned by fileno() "
"did not return the expected text")
@@ -98,7 +96,7 @@ class urlopen_FileTests(unittest.TestCase):
self.returned_obj.close()
def test_info(self):
- self.assertTrue(isinstance(self.returned_obj.info(), email.message.Message))
+ self.assertIsInstance(self.returned_obj.info(), email.message.Message)
def test_geturl(self):
self.assertEqual(self.returned_obj.geturl(), self.pathname)
@@ -141,8 +139,10 @@ class urlopen_HttpTests(unittest.TestCase):
def fakehttp(self, fakedata):
class FakeSocket(io.BytesIO):
+ io_refs = 1
def sendall(self, str): pass
def makefile(self, *args, **kwds):
+ self.io_refs += 1
return self
def read(self, amt=None):
if self.closed: return b""
@@ -150,6 +150,10 @@ class urlopen_HttpTests(unittest.TestCase):
def readline(self, length=None):
if self.closed: return b""
return io.BytesIO.readline(self, length)
+ def close(self):
+ self.io_refs -= 1
+ if self.io_refs == 0:
+ io.BytesIO.close(self)
class FakeHTTPConnection(http.client.HTTPConnection):
def connect(self):
self.sock = FakeSocket(fakedata)
@@ -159,8 +163,8 @@ class urlopen_HttpTests(unittest.TestCase):
def unfakehttp(self):
http.client.HTTPConnection = self._connection_class
- def test_read(self):
- self.fakehttp(b"Hello!")
+ def check_read(self, ver):
+ self.fakehttp(b"HTTP/" + ver + b" 200 OK\r\n\r\nHello!")
try:
fp = urlopen("http://python.org/")
self.assertEqual(fp.readline(), b"Hello!")
@@ -170,6 +174,17 @@ class urlopen_HttpTests(unittest.TestCase):
finally:
self.unfakehttp()
+ def test_read_0_9(self):
+ # "0.9" response accepted (but not "simple responses" without
+ # a status line)
+ self.check_read(b"0.9")
+
+ def test_read_1_0(self):
+ self.check_read(b"1.0")
+
+ def test_read_1_1(self):
+ self.check_read(b"1.1")
+
def test_read_bogus(self):
# urlopen() should raise IOError for many error codes.
self.fakehttp(b'''HTTP/1.1 401 Authentication Required
@@ -193,7 +208,7 @@ Content-Type: text/html; charset=iso-8859-1
self.unfakehttp()
def test_userpass_inurl(self):
- self.fakehttp(b"Hello!")
+ self.fakehttp(b"HTTP/1.0 200 OK\r\n\r\nHello!")
try:
fp = urlopen("http://user:pass@python.org/")
self.assertEqual(fp.readline(), b"Hello!")
@@ -234,8 +249,12 @@ class urlretrieve_FileTests(unittest.TestCase):
except: pass
def constructLocalFileUrl(self, filePath):
- return "file://%s" % urllib.request.pathname2url(
- os.path.abspath(filePath))
+ filePath = os.path.abspath(filePath)
+ try:
+ filePath.encode("utf8")
+ except UnicodeEncodeError:
+ raise unittest.SkipTest("filePath is not encodable to utf8")
+ return "file://%s" % urllib.request.pathname2url(filePath)
def createNewTempFile(self, data=b""):
"""Creates a new temporary file containing the specified data,
@@ -261,9 +280,9 @@ class urlretrieve_FileTests(unittest.TestCase):
# a headers value is returned.
result = urllib.request.urlretrieve("file:%s" % support.TESTFN)
self.assertEqual(result[0], support.TESTFN)
- self.assertTrue(isinstance(result[1], email.message.Message),
- "did not get a email.message.Message instance "
- "as second returned value")
+ self.assertIsInstance(result[1], email.message.Message,
+ "did not get a email.message.Message instance "
+ "as second returned value")
def test_copy(self):
# Test that setting the filename argument works.
@@ -286,9 +305,9 @@ class urlretrieve_FileTests(unittest.TestCase):
def test_reporthook(self):
# Make sure that the reporthook works.
def hooktester(count, block_size, total_size, count_holder=[0]):
- self.assertTrue(isinstance(count, int))
- self.assertTrue(isinstance(block_size, int))
- self.assertTrue(isinstance(total_size, int))
+ self.assertIsInstance(count, int)
+ self.assertIsInstance(block_size, int)
+ self.assertIsInstance(total_size, int)
self.assertEqual(count, count_holder[0])
count_holder[0] = count_holder[0] + 1
second_temp = "%s.2" % support.TESTFN
@@ -570,8 +589,7 @@ class UnquotingTests(unittest.TestCase):
"%s" % result)
self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, None)
self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, ())
- with warnings.catch_warnings():
- warnings.simplefilter('ignore', BytesWarning)
+ with support.check_warnings(('', BytesWarning), quiet=True):
self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, b'')
def test_unquoting_badpercent(self):
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 1704683b4d..69bcfa25cc 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -4,6 +4,7 @@ from test import support
import os
import io
import socket
+import array
import urllib.request
# The proxy bypass method imported below has logic specific to the OSX
@@ -24,11 +25,6 @@ class TrivialTests(unittest.TestCase):
# XXX Name hacking to get this to work on Windows.
fname = os.path.abspath(urllib.request.__file__).replace('\\', '/')
- # And more hacking to get it to work on MacOS. This assumes
- # urllib.pathname2url works, unfortunately...
- if os.name == 'mac':
- fname = '/' + fname.replace(':', '/')
-
if os.name == 'nt':
file_url = "file:///%s" % fname
else:
@@ -298,7 +294,7 @@ class MockHTTPClass:
def set_debuglevel(self, level):
self.level = level
- def _set_tunnel(self, host, port=None, headers=None):
+ def set_tunnel(self, host, port=None, headers=None):
self._tunnel_host = host
self._tunnel_port = port
if headers:
@@ -591,12 +587,12 @@ class OpenerDirectorTests(unittest.TestCase):
# *_request
self.assertEqual((handler, name), calls[i])
self.assertEqual(len(args), 1)
- self.assertTrue(isinstance(args[0], Request))
+ self.assertIsInstance(args[0], Request)
else:
# *_response
self.assertEqual((handler, name), calls[i])
self.assertEqual(len(args), 2)
- self.assertTrue(isinstance(args[0], Request))
+ self.assertIsInstance(args[0], Request)
# response from opener.open is None, because there's no
# handler that defines http_open to handle it
self.assertTrue(args[1] is None or
@@ -604,6 +600,10 @@ class OpenerDirectorTests(unittest.TestCase):
def sanepathname2url(path):
+ try:
+ path.encode("utf8")
+ except UnicodeEncodeError:
+ raise unittest.SkipTest("path is not encodable to utf8")
urlpath = urllib.request.pathname2url(path)
if os.name == "nt" and urlpath.startswith("///"):
urlpath = urlpath[2:]
@@ -744,11 +744,11 @@ class HandlerTests(unittest.TestCase):
# file:///blah.txt (a file)
# file://ftp.example.com/blah.txt (an ftp URL)
for url, ftp in [
- ("file://ftp.example.com//foo.txt", True),
+ ("file://ftp.example.com//foo.txt", False),
("file://ftp.example.com///foo.txt", False),
# XXXX bug: fails with OSError, should be URLError
("file://ftp.example.com/foo.txt", False),
- ("file://somehost//foo/something.txt", True),
+ ("file://somehost//foo/something.txt", False),
("file://localhost//foo/something.txt", False),
]:
req = Request(url)
@@ -768,7 +768,7 @@ class HandlerTests(unittest.TestCase):
o = h.parent = MockOpener()
url = "http://example.com/"
- for method, data in [("GET", None), ("POST", "blah")]:
+ for method, data in [("GET", None), ("POST", b"blah")]:
req = Request(url, data, {"Foo": "bar"})
req.timeout = None
req.add_unredirected_header("Spam", "eggs")
@@ -796,15 +796,19 @@ class HandlerTests(unittest.TestCase):
http.raise_on_endheaders = True
self.assertRaises(urllib.error.URLError, h.do_open, http, req)
+ # Check for TypeError on POST data which is str.
+ req = Request("http://example.com/","badpost")
+ self.assertRaises(TypeError, h.do_request_, req)
+
# check adding of standard headers
o.addheaders = [("Spam", "eggs")]
- for data in "", None: # POST, GET
+ for data in b"", None: # POST, GET
req = Request("http://example.com/", data)
r = MockResponse(200, "OK", {}, "")
newreq = h.do_request_(req)
if data is None: # GET
- self.assertTrue("Content-length" not in req.unredirected_hdrs)
- self.assertTrue("Content-type" not in req.unredirected_hdrs)
+ self.assertNotIn("Content-length", req.unredirected_hdrs)
+ self.assertNotIn("Content-type", req.unredirected_hdrs)
else: # POST
self.assertEqual(req.unredirected_hdrs["Content-length"], "0")
self.assertEqual(req.unredirected_hdrs["Content-type"],
@@ -824,6 +828,48 @@ class HandlerTests(unittest.TestCase):
self.assertEqual(req.unredirected_hdrs["Host"], "baz")
self.assertEqual(req.unredirected_hdrs["Spam"], "foo")
+ # Check iterable body support
+ def iterable_body():
+ yield b"one"
+ yield b"two"
+ yield b"three"
+
+ for headers in {}, {"Content-Length": 11}:
+ req = Request("http://example.com/", iterable_body(), headers)
+ if not headers:
+ # Having an iterable body without a Content-Length should
+ # raise an exception
+ self.assertRaises(ValueError, h.do_request_, req)
+ else:
+ newreq = h.do_request_(req)
+
+ # A file object.
+ # Test only Content-Length attribute of request.
+
+ file_obj = io.BytesIO()
+ file_obj.write(b"Something\nSomething\nSomething\n")
+
+ for headers in {}, {"Content-Length": 30}:
+ req = Request("http://example.com/", file_obj, headers)
+ if not headers:
+ # Having an iterable body without a Content-Length should
+ # raise an exception
+ self.assertRaises(ValueError, h.do_request_, req)
+ else:
+ newreq = h.do_request_(req)
+ self.assertEqual(int(newreq.get_header('Content-length')),30)
+
+ file_obj.close()
+
+ # array.array Iterable - Content Length is calculated
+
+ iterable_array = array.array("I",[1,2,3,4])
+
+ for headers in {}, {"Content-Length": 16}:
+ req = Request("http://example.com/", iterable_array, headers)
+ newreq = h.do_request_(req)
+ self.assertEqual(int(newreq.get_header('Content-length')),16)
+
def test_http_doubleslash(self):
# Checks the presence of any unnecessary double slash in url does not
# break anything. Previously, a double slash directly after the host
@@ -831,7 +877,7 @@ class HandlerTests(unittest.TestCase):
h = urllib.request.AbstractHTTPHandler()
o = h.parent = MockOpener()
- data = ""
+ data = b""
ds_urls = [
"http://example.com/foo/bar/baz.html",
"http://example.com//foo/bar/baz.html",
@@ -944,13 +990,13 @@ class HandlerTests(unittest.TestCase):
# now it's a GET, there should not be headers regarding content
# (possibly dragged from before being a POST)
headers = [x.lower() for x in o.req.headers]
- self.assertTrue("content-length" not in headers)
- self.assertTrue("content-type" not in headers)
+ self.assertNotIn("content-length", headers)
+ self.assertNotIn("content-type", headers)
self.assertEqual(o.req.headers["Nonsense"],
"viking=withhold")
- self.assertTrue("Spam" not in o.req.headers)
- self.assertTrue("Spam" not in o.req.unredirected_hdrs)
+ self.assertNotIn("Spam", o.req.headers)
+ self.assertNotIn("Spam", o.req.unredirected_hdrs)
# loop detection
req = Request(from_url)
@@ -1075,10 +1121,10 @@ class HandlerTests(unittest.TestCase):
# Verify Proxy-Authorization gets tunneled to request.
# httpsconn req_headers do not have the Proxy-Authorization header but
# the req will have.
- self.assertFalse(("Proxy-Authorization","FooBar") in
+ self.assertNotIn(("Proxy-Authorization","FooBar"),
https_handler.httpconn.req_headers)
- self.assertTrue(("User-Agent","Grail") in
- https_handler.httpconn.req_headers)
+ self.assertIn(("User-Agent","Grail"),
+ https_handler.httpconn.req_headers)
self.assertIsNotNone(req._tunnel_host)
self.assertEqual(req.get_host(), "proxy.example.com:3128")
self.assertEqual(req.get_header("Proxy-authorization"),"FooBar")
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index fbd21d2912..9e1ce5bb9e 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -1,13 +1,21 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+import os
import email
-import threading
import urllib.parse
import urllib.request
import http.server
import unittest
import hashlib
from test import support
+threading = support.import_module('threading')
+
+
+here = os.path.dirname(__file__)
+# Self-signed cert file for 'localhost'
+CERT_localhost = os.path.join(here, 'keycert.pem')
+# Self-signed cert file for 'fakehostname'
+CERT_fakehostname = os.path.join(here, 'keycert2.pem')
# Loopback http server infrastructure
@@ -23,7 +31,7 @@ class LoopbackHttpServer(http.server.HTTPServer):
# Set the timeout of our listening socket really low so
# that we can stop the server easily.
- self.socket.settimeout(1.0)
+ self.socket.settimeout(0.1)
def get_request(self):
"""HTTPServer method, overridden."""
@@ -58,6 +66,7 @@ class LoopbackHttpServerThread(threading.Thread):
self._stop_server = True
self.join()
+ self.httpd.server_close()
def run(self):
self.ready.set()
@@ -229,6 +238,7 @@ class ProxyAuthTests(unittest.TestCase):
REALM = "TestRealm"
def setUp(self):
+ super(ProxyAuthTests, self).setUp()
self.digest_auth_handler = DigestAuthHandler()
self.digest_auth_handler.set_users({self.USER: self.PASSWD})
self.digest_auth_handler.set_realm(self.REALM)
@@ -246,6 +256,7 @@ class ProxyAuthTests(unittest.TestCase):
def tearDown(self):
self.server.stop()
+ super(ProxyAuthTests, self).tearDown()
def test_proxy_with_bad_password_raises_httperror(self):
self.proxy_digest_handler.add_password(self.REALM, self.URL,
@@ -340,15 +351,17 @@ class TestUrlopen(unittest.TestCase):
"""
def setUp(self):
+ super(TestUrlopen, self).setUp()
self.server = None
def tearDown(self):
if self.server is not None:
self.server.stop()
+ super(TestUrlopen, self).tearDown()
- def urlopen(self, url, data=None):
+ def urlopen(self, url, data=None, **kwargs):
l = []
- f = urllib.request.urlopen(url, data)
+ f = urllib.request.urlopen(url, data, **kwargs)
try:
# Exercise various methods
l.extend(f.readlines(200))
@@ -371,6 +384,17 @@ class TestUrlopen(unittest.TestCase):
handler.port = port
return handler
+ def start_https_server(self, responses=None, certfile=CERT_localhost):
+ if not hasattr(urllib.request, 'HTTPSHandler'):
+ self.skipTest('ssl support required')
+ from test.ssl_servers import make_https_server
+ if responses is None:
+ responses = [(200, [], b"we care a bit")]
+ handler = GetRequestHandler(responses)
+ server = make_https_server(self, certfile=certfile, handler_class=handler)
+ handler.port = server.port
+ return handler
+
def test_redirection(self):
expected_response = b"We got here..."
responses = [
@@ -428,6 +452,28 @@ class TestUrlopen(unittest.TestCase):
self.assertEqual(data, expected_response)
self.assertEqual(handler.requests, ["/bizarre", b"get=with_feeling"])
+ def test_https(self):
+ handler = self.start_https_server()
+ data = self.urlopen("https://localhost:%s/bizarre" % handler.port)
+ self.assertEqual(data, b"we care a bit")
+
+ def test_https_with_cafile(self):
+ handler = self.start_https_server(certfile=CERT_localhost)
+ import ssl
+ # Good cert
+ data = self.urlopen("https://localhost:%s/bizarre" % handler.port,
+ cafile=CERT_localhost)
+ self.assertEqual(data, b"we care a bit")
+ # Bad cert
+ with self.assertRaises(urllib.error.URLError) as cm:
+ self.urlopen("https://localhost:%s/bizarre" % handler.port,
+ cafile=CERT_fakehostname)
+ # Good cert, but mismatching hostname
+ handler = self.start_https_server(certfile=CERT_fakehostname)
+ with self.assertRaises(ssl.CertificateError) as cm:
+ self.urlopen("https://localhost:%s/bizarre" % handler.port,
+ cafile=CERT_fakehostname)
+
def test_sending_headers(self):
handler = self.start_server()
req = urllib.request.Request("http://localhost:%s/" % handler.port,
@@ -452,9 +498,9 @@ class TestUrlopen(unittest.TestCase):
open_url = urllib.request.urlopen(
"http://localhost:%s" % handler.port)
info_obj = open_url.info()
- self.assertTrue(isinstance(info_obj, email.message.Message),
- "object returned by 'info' is not an instance of "
- "email.message.Message")
+ self.assertIsInstance(info_obj, email.message.Message,
+ "object returned by 'info' is not an "
+ "instance of email.message.Message")
self.assertEqual(info_obj.get_content_subtype(), "plain")
finally:
self.server.stop()
@@ -509,6 +555,8 @@ class TestUrlopen(unittest.TestCase):
(index, len(lines[index]), len(line)))
self.assertEqual(index + 1, len(lines))
+
+@support.reap_threads
def test_main():
support.run_unittest(ProxyAuthTests, TestUrlopen)
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index 63e25b4b69..eab15735de 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
from test import support
@@ -6,10 +6,13 @@ from test.test_urllib2 import sanepathname2url
import os
import socket
-import sys
import urllib.error
import urllib.request
import sys
+try:
+ import ssl
+except ImportError:
+ ssl = None
TIMEOUT = 60 # seconds
@@ -78,8 +81,6 @@ class AuthTests(unittest.TestCase):
class CloseSocketTest(unittest.TestCase):
def test_close(self):
- import socket, http.client, gc
-
# calling .close() on urllib2's response objects should close the
# underlying socket
@@ -174,7 +175,6 @@ class OtherNetworkTests(unittest.TestCase):
self.assertEqual(request.get_header('User-agent'),'Test-Agent')
def _test_urls(self, urls, handlers, retry=True):
- import socket
import time
import logging
debug = logging.getLogger("test_urllib2").debug
@@ -188,6 +188,7 @@ class OtherNetworkTests(unittest.TestCase):
url, req, expected_err = url
else:
req = expected_err = None
+
with support.transient_internet(url):
debug(url)
try:
@@ -197,7 +198,7 @@ class OtherNetworkTests(unittest.TestCase):
if expected_err:
msg = ("Didn't get expected error(s) %s for %s %s, got %s: %s" %
(expected_err, url, req, type(err), err))
- self.assertTrue(isinstance(err, expected_err), msg)
+ self.assertIsInstance(err, expected_err, msg)
except urllib.error.URLError as err:
if isinstance(err[0], socket.timeout):
print("<timeout: %s>" % url, file=sys.stderr)
@@ -263,7 +264,7 @@ class TimeoutTest(unittest.TestCase):
u = _urlopen_with_retry(url, timeout=120)
self.assertEqual(u.fp.raw._sock.gettimeout(), 120)
- FTP_HOST = "ftp://ftp.mirror.nl/pub/mirror/gnu/"
+ FTP_HOST = "ftp://ftp.mirror.nl/pub/gnu/"
def test_ftp_basic(self):
self.assertTrue(socket.getdefaulttimeout() is None)
@@ -297,13 +298,35 @@ class TimeoutTest(unittest.TestCase):
self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60)
+@unittest.skipUnless(ssl, "requires SSL support")
+class HTTPSTests(unittest.TestCase):
+
+ def test_sni(self):
+ self.skipTest("test disabled - test server needed")
+ # Checks that Server Name Indication works, if supported by the
+ # OpenSSL linked to.
+ # The ssl module itself doesn't have server-side support for SNI,
+ # so we rely on a third-party test site.
+ expect_sni = ssl.HAS_SNI
+ with support.transient_internet("XXX"):
+ u = urllib.request.urlopen("XXX")
+ contents = u.readall()
+ if expect_sni:
+ self.assertIn(b"Great", contents)
+ self.assertNotIn(b"Unfortunately", contents)
+ else:
+ self.assertNotIn(b"Great", contents)
+ self.assertIn(b"Unfortunately", contents)
+
+
def test_main():
support.requires("network")
support.run_unittest(AuthTests,
- OtherNetworkTests,
- CloseSocketTest,
- TimeoutTest,
- )
+ HTTPSTests,
+ OtherNetworkTests,
+ CloseSocketTest,
+ TimeoutTest,
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index bac2049161..c8851031e8 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
from test import support
@@ -13,7 +13,7 @@ import time
class URLTimeoutTest(unittest.TestCase):
- TIMEOUT = 10.0
+ TIMEOUT = 30.0
def setUp(self):
socket.setdefaulttimeout(self.TIMEOUT)
@@ -62,10 +62,10 @@ class urlopenNetworkTests(unittest.TestCase):
# Test both readline and readlines.
open_url = self.urlopen("http://www.python.org/")
try:
- self.assertTrue(isinstance(open_url.readline(), bytes),
- "readline did not return bytes")
- self.assertTrue(isinstance(open_url.readlines(), list),
- "readlines did not return a list")
+ self.assertIsInstance(open_url.readline(), bytes,
+ "readline did not return a string")
+ self.assertIsInstance(open_url.readlines(), list,
+ "readlines did not return a list")
finally:
open_url.close()
@@ -76,9 +76,9 @@ class urlopenNetworkTests(unittest.TestCase):
info_obj = open_url.info()
finally:
open_url.close()
- self.assertTrue(isinstance(info_obj, email.message.Message),
- "object returned by 'info' is not an instance of "
- "email.message.Message")
+ self.assertIsInstance(info_obj, email.message.Message,
+ "object returned by 'info' is not an "
+ "instance of email.message.Message")
self.assertEqual(info_obj.get_content_subtype(), "html")
def test_geturl(self):
@@ -168,8 +168,8 @@ class urlretrieveNetworkTests(unittest.TestCase):
# Make sure header returned as 2nd value from urlretrieve is good.
file_location, header = self.urlretrieve("http://www.python.org/")
os.unlink(file_location)
- self.assertTrue(isinstance(header, email.message.Message),
- "header is not an instance of email.message.Message")
+ self.assertIsInstance(header, email.message.Message,
+ "header is not an instance of email.message.Message")
def test_data_header(self):
logo = "http://www.python.org/community/logos/python-logo-master-v3-TM.png"
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index 1c6c501d67..628b8ec04a 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
from test import support
import unittest
@@ -24,6 +24,17 @@ parse_qsl_test_cases = [
("&a=b", [('a', 'b')]),
("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]),
("a=1&a=2", [('a', '1'), ('a', '2')]),
+ (b"", []),
+ (b"&", []),
+ (b"&&", []),
+ (b"=", [(b'', b'')]),
+ (b"=a", [(b'', b'a')]),
+ (b"a", [(b'a', b'')]),
+ (b"a=", [(b'a', b'')]),
+ (b"a=", [(b'a', b'')]),
+ (b"&a=b", [(b'a', b'b')]),
+ (b"a=a+b&b=b+c", [(b'a', b'a b'), (b'b', b'b c')]),
+ (b"a=1&a=2", [(b'a', b'1'), (b'a', b'2')]),
]
class UrlParseTestCase(unittest.TestCase):
@@ -86,7 +97,7 @@ class UrlParseTestCase(unittest.TestCase):
def test_roundtrips(self):
- testcases = [
+ str_cases = [
('file:///tmp/junk.txt',
('file', '', '/tmp/junk.txt', '', '', ''),
('file', '', '/tmp/junk.txt', '', '')),
@@ -110,16 +121,21 @@ class UrlParseTestCase(unittest.TestCase):
('git+ssh', 'git@github.com','/user/project.git',
'','',''),
('git+ssh', 'git@github.com','/user/project.git',
- '', ''))
+ '', '')),
]
- for url, parsed, split in testcases:
+ def _encode(t):
+ return (t[0].encode('ascii'),
+ tuple(x.encode('ascii') for x in t[1]),
+ tuple(x.encode('ascii') for x in t[2]))
+ bytes_cases = [_encode(x) for x in str_cases]
+ for url, parsed, split in str_cases + bytes_cases:
self.checkRoundtrips(url, parsed, split)
def test_http_roundtrips(self):
# urllib.parse.urlsplit treats 'http:' as an optimized special case,
# so we test both 'http:' and 'https:' in all the following.
# Three cheers for white box knowledge!
- testcases = [
+ str_cases = [
('://www.python.org',
('www.python.org', '', '', '', ''),
('www.python.org', '', '', '')),
@@ -136,19 +152,34 @@ class UrlParseTestCase(unittest.TestCase):
('a', '/b/c/d', 'p', 'q', 'f'),
('a', '/b/c/d;p', 'q', 'f')),
]
- for scheme in ('http', 'https'):
- for url, parsed, split in testcases:
- url = scheme + url
- parsed = (scheme,) + parsed
- split = (scheme,) + split
- self.checkRoundtrips(url, parsed, split)
+ def _encode(t):
+ return (t[0].encode('ascii'),
+ tuple(x.encode('ascii') for x in t[1]),
+ tuple(x.encode('ascii') for x in t[2]))
+ bytes_cases = [_encode(x) for x in str_cases]
+ str_schemes = ('http', 'https')
+ bytes_schemes = (b'http', b'https')
+ str_tests = str_schemes, str_cases
+ bytes_tests = bytes_schemes, bytes_cases
+ for schemes, test_cases in (str_tests, bytes_tests):
+ for scheme in schemes:
+ for url, parsed, split in test_cases:
+ url = scheme + url
+ parsed = (scheme,) + parsed
+ split = (scheme,) + split
+ self.checkRoundtrips(url, parsed, split)
def checkJoin(self, base, relurl, expected):
- self.assertEqual(urllib.parse.urljoin(base, relurl), expected,
- (base, relurl, expected))
+ str_components = (base, relurl, expected)
+ self.assertEqual(urllib.parse.urljoin(base, relurl), expected)
+ bytes_components = baseb, relurlb, expectedb = [
+ x.encode('ascii') for x in str_components]
+ self.assertEqual(urllib.parse.urljoin(baseb, relurlb), expectedb)
def test_unparse_parse(self):
- for u in ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]:
+ str_cases = ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]
+ bytes_cases = [x.encode('ascii') for x in str_cases]
+ for u in str_cases + bytes_cases:
self.assertEqual(urllib.parse.urlunsplit(urllib.parse.urlsplit(u)), u)
self.assertEqual(urllib.parse.urlunparse(urllib.parse.urlparse(u)), u)
@@ -199,6 +230,8 @@ class UrlParseTestCase(unittest.TestCase):
def test_RFC2396(self):
# cases from RFC 2396
+
+
self.checkJoin(RFC2396_BASE, 'g:h', 'g:h')
self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g')
self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g')
@@ -268,6 +301,7 @@ class UrlParseTestCase(unittest.TestCase):
self.checkJoin(RFC3986_BASE, '../../g','http://a/g')
#Abnormal Examples
+
# The 'abnormal scenarios' are incompatible with RFC2986 parsing
# Tests are here for reference.
@@ -327,8 +361,48 @@ class UrlParseTestCase(unittest.TestCase):
self.checkJoin(SIMPLE_BASE, 'http:g?y','http://a/b/c/g?y')
self.checkJoin(SIMPLE_BASE, 'http:g?y/./x','http://a/b/c/g?y/./x')
+ def test_RFC2732(self):
+ str_cases = [
+ ('http://Test.python.org:5432/foo/', 'test.python.org', 5432),
+ ('http://12.34.56.78:5432/foo/', '12.34.56.78', 5432),
+ ('http://[::1]:5432/foo/', '::1', 5432),
+ ('http://[dead:beef::1]:5432/foo/', 'dead:beef::1', 5432),
+ ('http://[dead:beef::]:5432/foo/', 'dead:beef::', 5432),
+ ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/',
+ 'dead:beef:cafe:5417:affe:8fa3:deaf:feed', 5432),
+ ('http://[::12.34.56.78]:5432/foo/', '::12.34.56.78', 5432),
+ ('http://[::ffff:12.34.56.78]:5432/foo/',
+ '::ffff:12.34.56.78', 5432),
+ ('http://Test.python.org/foo/', 'test.python.org', None),
+ ('http://12.34.56.78/foo/', '12.34.56.78', None),
+ ('http://[::1]/foo/', '::1', None),
+ ('http://[dead:beef::1]/foo/', 'dead:beef::1', None),
+ ('http://[dead:beef::]/foo/', 'dead:beef::', None),
+ ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/',
+ 'dead:beef:cafe:5417:affe:8fa3:deaf:feed', None),
+ ('http://[::12.34.56.78]/foo/', '::12.34.56.78', None),
+ ('http://[::ffff:12.34.56.78]/foo/',
+ '::ffff:12.34.56.78', None),
+ ]
+ def _encode(t):
+ return t[0].encode('ascii'), t[1].encode('ascii'), t[2]
+ bytes_cases = [_encode(x) for x in str_cases]
+ for url, hostname, port in str_cases + bytes_cases:
+ urlparsed = urllib.parse.urlparse(url)
+ self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port))
+
+ str_cases = [
+ 'http://::12.34.56.78]/',
+ 'http://[::1/foo/',
+ 'ftp://[::1/foo/bad]/bad',
+ 'http://[::1/foo/bad]/bad',
+ 'http://[::ffff:12.34.56.78']
+ bytes_cases = [x.encode('ascii') for x in str_cases]
+ for invalid_url in str_cases + bytes_cases:
+ self.assertRaises(ValueError, urllib.parse.urlparse, invalid_url)
+
def test_urldefrag(self):
- for url, defrag, frag in [
+ str_cases = [
('http://python.org#frag', 'http://python.org', 'frag'),
('http://python.org', 'http://python.org', ''),
('http://python.org/#frag', 'http://python.org/', 'frag'),
@@ -339,8 +413,16 @@ class UrlParseTestCase(unittest.TestCase):
('http://python.org/p?q', 'http://python.org/p?q', ''),
(RFC1808_BASE, 'http://a/b/c/d;p?q', 'f'),
(RFC2396_BASE, 'http://a/b/c/d;p?q', ''),
- ]:
- self.assertEqual(urllib.parse.urldefrag(url), (defrag, frag))
+ ]
+ def _encode(t):
+ return type(t)(x.encode('ascii') for x in t)
+ bytes_cases = [_encode(x) for x in str_cases]
+ for url, defrag, frag in str_cases + bytes_cases:
+ result = urllib.parse.urldefrag(url)
+ self.assertEqual(result.geturl(), url)
+ self.assertEqual(result, (defrag, frag))
+ self.assertEqual(result.url, defrag)
+ self.assertEqual(result.fragment, frag)
def test_urlsplit_attributes(self):
url = "HTTP://WWW.PYTHON.ORG/doc/#frag"
@@ -356,7 +438,8 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(p.port, None)
# geturl() won't return exactly the original URL in this case
# since the scheme is always case-normalized
- #self.assertEqual(p.geturl(), url)
+ # We handle this by ignoring the first 4 characters of the URL
+ self.assertEqual(p.geturl()[4:], url[4:])
url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag"
p = urllib.parse.urlsplit(url)
@@ -388,6 +471,45 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(p.port, 80)
self.assertEqual(p.geturl(), url)
+ # And check them all again, only with bytes this time
+ url = b"HTTP://WWW.PYTHON.ORG/doc/#frag"
+ p = urllib.parse.urlsplit(url)
+ self.assertEqual(p.scheme, b"http")
+ self.assertEqual(p.netloc, b"WWW.PYTHON.ORG")
+ self.assertEqual(p.path, b"/doc/")
+ self.assertEqual(p.query, b"")
+ self.assertEqual(p.fragment, b"frag")
+ self.assertEqual(p.username, None)
+ self.assertEqual(p.password, None)
+ self.assertEqual(p.hostname, b"www.python.org")
+ self.assertEqual(p.port, None)
+ self.assertEqual(p.geturl()[4:], url[4:])
+
+ url = b"http://User:Pass@www.python.org:080/doc/?query=yes#frag"
+ p = urllib.parse.urlsplit(url)
+ self.assertEqual(p.scheme, b"http")
+ self.assertEqual(p.netloc, b"User:Pass@www.python.org:080")
+ self.assertEqual(p.path, b"/doc/")
+ self.assertEqual(p.query, b"query=yes")
+ self.assertEqual(p.fragment, b"frag")
+ self.assertEqual(p.username, b"User")
+ self.assertEqual(p.password, b"Pass")
+ self.assertEqual(p.hostname, b"www.python.org")
+ self.assertEqual(p.port, 80)
+ self.assertEqual(p.geturl(), url)
+
+ url = b"http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag"
+ p = urllib.parse.urlsplit(url)
+ self.assertEqual(p.scheme, b"http")
+ self.assertEqual(p.netloc, b"User@example.com:Pass@www.python.org:080")
+ self.assertEqual(p.path, b"/doc/")
+ self.assertEqual(p.query, b"query=yes")
+ self.assertEqual(p.fragment, b"frag")
+ self.assertEqual(p.username, b"User@example.com")
+ self.assertEqual(p.password, b"Pass")
+ self.assertEqual(p.hostname, b"www.python.org")
+ self.assertEqual(p.port, 80)
+ self.assertEqual(p.geturl(), url)
def test_attributes_bad_port(self):
"""Check handling of non-integer ports."""
@@ -399,6 +521,15 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(p.netloc, "www.example.net:foo")
self.assertRaises(ValueError, lambda: p.port)
+ # Once again, repeat ourselves to test bytes
+ p = urllib.parse.urlsplit(b"http://www.example.net:foo")
+ self.assertEqual(p.netloc, b"www.example.net:foo")
+ self.assertRaises(ValueError, lambda: p.port)
+
+ p = urllib.parse.urlparse(b"http://www.example.net:foo")
+ self.assertEqual(p.netloc, b"www.example.net:foo")
+ self.assertRaises(ValueError, lambda: p.port)
+
def test_attributes_without_netloc(self):
# This example is straight from RFC 3261. It looks like it
# should allow the username, hostname, and port to be filled
@@ -422,10 +553,30 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(p.port, None)
self.assertEqual(p.geturl(), uri)
+ # You guessed it, repeating the test with bytes input
+ uri = b"sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15"
+ p = urllib.parse.urlsplit(uri)
+ self.assertEqual(p.netloc, b"")
+ self.assertEqual(p.username, None)
+ self.assertEqual(p.password, None)
+ self.assertEqual(p.hostname, None)
+ self.assertEqual(p.port, None)
+ self.assertEqual(p.geturl(), uri)
+
+ p = urllib.parse.urlparse(uri)
+ self.assertEqual(p.netloc, b"")
+ self.assertEqual(p.username, None)
+ self.assertEqual(p.password, None)
+ self.assertEqual(p.hostname, None)
+ self.assertEqual(p.port, None)
+ self.assertEqual(p.geturl(), uri)
+
def test_noslash(self):
# Issue 1637: http://foo.com?query is legal
self.assertEqual(urllib.parse.urlparse("http://example.com?blahblah=/foo"),
('http', 'example.com', '', '', 'blahblah=/foo', ''))
+ self.assertEqual(urllib.parse.urlparse(b"http://example.com?blahblah=/foo"),
+ (b'http', b'example.com', b'', b'', b'blahblah=/foo', b''))
def test_withoutscheme(self):
# Test urlparse without scheme
@@ -438,6 +589,13 @@ class UrlParseTestCase(unittest.TestCase):
('','www.python.org:80','','','',''))
self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
('http','www.python.org:80','','','',''))
+ # Repeat for bytes input
+ self.assertEqual(urllib.parse.urlparse(b"path"),
+ (b'',b'',b'path',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"//www.python.org:80"),
+ (b'',b'www.python.org:80',b'',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
+ (b'http',b'www.python.org:80',b'',b'',b'',b''))
def test_portseparator(self):
# Issue 754016 makes changes for port separator ':' from scheme separator
@@ -447,6 +605,13 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(urllib.parse.urlparse("https:"),('https','','','','',''))
self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
('http','www.python.org:80','','','',''))
+ # As usual, need to check bytes input as well
+ self.assertEqual(urllib.parse.urlparse(b"path:80"),
+ (b'',b'',b'path:80',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
+ (b'http',b'www.python.org:80',b'',b'',b'',b''))
def test_usingsys(self):
# Issue 3314: sys module is used in the error
@@ -458,6 +623,98 @@ class UrlParseTestCase(unittest.TestCase):
('s3', 'foo.com', '/stuff', '', '', ''))
self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"),
('x-newscheme', 'foo.com', '/stuff', '', '', ''))
+ # And for bytes...
+ self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"),
+ (b's3', b'foo.com', b'/stuff', b'', b'', b''))
+ self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"),
+ (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b''))
+
+ def test_mixed_types_rejected(self):
+ # Several functions that process either strings or ASCII encoded bytes
+ # accept multiple arguments. Check they reject mixed type input
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlparse("www.python.org", b"http")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlparse(b"www.python.org", "http")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlsplit("www.python.org", b"http")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlsplit(b"www.python.org", "http")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlunparse(( b"http", "www.python.org","","","",""))
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlunparse(("http", b"www.python.org","","","",""))
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlunsplit((b"http", "www.python.org","","",""))
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlunsplit(("http", b"www.python.org","","",""))
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urljoin("http://python.org", b"http://python.org")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urljoin(b"http://python.org", "http://python.org")
+
+ def _check_result_type(self, str_type):
+ num_args = len(str_type._fields)
+ bytes_type = str_type._encoded_counterpart
+ self.assertIs(bytes_type._decoded_counterpart, str_type)
+ str_args = ('',) * num_args
+ bytes_args = (b'',) * num_args
+ str_result = str_type(*str_args)
+ bytes_result = bytes_type(*bytes_args)
+ encoding = 'ascii'
+ errors = 'strict'
+ self.assertEqual(str_result, str_args)
+ self.assertEqual(bytes_result.decode(), str_args)
+ self.assertEqual(bytes_result.decode(), str_result)
+ self.assertEqual(bytes_result.decode(encoding), str_args)
+ self.assertEqual(bytes_result.decode(encoding), str_result)
+ self.assertEqual(bytes_result.decode(encoding, errors), str_args)
+ self.assertEqual(bytes_result.decode(encoding, errors), str_result)
+ self.assertEqual(bytes_result, bytes_args)
+ self.assertEqual(str_result.encode(), bytes_args)
+ self.assertEqual(str_result.encode(), bytes_result)
+ self.assertEqual(str_result.encode(encoding), bytes_args)
+ self.assertEqual(str_result.encode(encoding), bytes_result)
+ self.assertEqual(str_result.encode(encoding, errors), bytes_args)
+ self.assertEqual(str_result.encode(encoding, errors), bytes_result)
+
+ def test_result_pairs(self):
+ # Check encoding and decoding between result pairs
+ result_types = [
+ urllib.parse.DefragResult,
+ urllib.parse.SplitResult,
+ urllib.parse.ParseResult,
+ ]
+ for result_type in result_types:
+ self._check_result_type(result_type)
+
+ def test_parse_qs_encoding(self):
+ result = urllib.parse.parse_qs("key=\u0141%E9", encoding="latin-1")
+ self.assertEqual(result, {'key': ['\u0141\xE9']})
+ result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="utf-8")
+ self.assertEqual(result, {'key': ['\u0141\xE9']})
+ result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="ascii")
+ self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']})
+ result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii")
+ self.assertEqual(result, {'key': ['\u0141\ufffd-']})
+ result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii",
+ errors="ignore")
+ self.assertEqual(result, {'key': ['\u0141-']})
+
+ def test_parse_qsl_encoding(self):
+ result = urllib.parse.parse_qsl("key=\u0141%E9", encoding="latin-1")
+ self.assertEqual(result, [('key', '\u0141\xE9')])
+ result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="utf-8")
+ self.assertEqual(result, [('key', '\u0141\xE9')])
+ result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="ascii")
+ self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')])
+ result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii")
+ self.assertEqual(result, [('key', '\u0141\ufffd-')])
+ result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii",
+ errors="ignore")
+ self.assertEqual(result, [('key', '\u0141-')])
+
+
def test_main():
support.run_unittest(UrlParseTestCase)
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py
index 9d0a8b118d..137c445eae 100644
--- a/Lib/test/test_userdict.py
+++ b/Lib/test/test_userdict.py
@@ -39,8 +39,8 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
self.assertEqual(collections.UserDict.fromkeys('one two'.split(), 1), d5)
self.assertEqual(collections.UserDict().fromkeys('one two'.split(), 1), d5)
self.assertTrue(u1.fromkeys('one two'.split()) is not u1)
- self.assertTrue(isinstance(u1.fromkeys('one two'.split()), collections.UserDict))
- self.assertTrue(isinstance(u2.fromkeys('one two'.split()), collections.UserDict))
+ self.assertIsInstance(u1.fromkeys('one two'.split()), collections.UserDict)
+ self.assertIsInstance(u2.fromkeys('one two'.split()), collections.UserDict)
# Test __repr__
self.assertEqual(str(u0), str(d0))
@@ -95,7 +95,7 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
# Test "in".
for i in u2.keys():
- self.assertTrue(i in u2)
+ self.assertIn(i, u2)
self.assertEqual(i in u1, i in d1)
self.assertEqual(i in u0, i in d0)
@@ -122,7 +122,7 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
# Test setdefault
t = collections.UserDict()
self.assertEqual(t.setdefault("x", 42), 42)
- self.assertTrue("x" in t)
+ self.assertIn("x", t)
self.assertEqual(t.setdefault("x", 23), 42)
# Test pop
@@ -152,8 +152,8 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
d = D({1: 2, 3: 4})
self.assertEqual(d[1], 2)
self.assertEqual(d[3], 4)
- self.assertTrue(2 not in d)
- self.assertTrue(2 not in d.keys())
+ self.assertNotIn(2, d)
+ self.assertNotIn(2, d.keys())
self.assertEqual(d[2], 42)
class E(collections.UserDict):
def __missing__(self, key):
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index 05381384bf..7a8b9323f8 100755
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# UserString is a wrapper around the native builtin string type.
# UserString instances should behave similar to builtin string objects.
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 65a1a28726..dbf30e985c 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -4,7 +4,6 @@ import os
from io import StringIO
import sys
import unittest
-import tempfile
import subprocess
from test import support
from test.script_helper import assert_python_ok
@@ -508,7 +507,7 @@ class _WarningsTests(BaseTest):
with support.captured_output('stderr') as stream:
self.module.warn(text)
result = stream.getvalue()
- self.assertTrue(text in result)
+ self.assertIn(text, result)
def test_showwarning_not_callable(self):
with original_warnings.catch_warnings(module=self.module):
@@ -669,18 +668,33 @@ class CatchWarningTests(BaseTest):
def test_check_warnings(self):
# Explicit tests for the test.support convenience wrapper
wmod = self.module
- if wmod is sys.modules['warnings']:
- with support.check_warnings() as w:
- self.assertEqual(w.warnings, [])
- wmod.simplefilter("always")
+ if wmod is not sys.modules['warnings']:
+ return
+ with support.check_warnings(quiet=False) as w:
+ self.assertEqual(w.warnings, [])
+ wmod.simplefilter("always")
+ wmod.warn("foo")
+ self.assertEqual(str(w.message), "foo")
+ wmod.warn("bar")
+ self.assertEqual(str(w.message), "bar")
+ self.assertEqual(str(w.warnings[0].message), "foo")
+ self.assertEqual(str(w.warnings[1].message), "bar")
+ w.reset()
+ self.assertEqual(w.warnings, [])
+
+ with support.check_warnings():
+ # defaults to quiet=True without argument
+ pass
+ with support.check_warnings(('foo', UserWarning)):
+ wmod.warn("foo")
+
+ with self.assertRaises(AssertionError):
+ with support.check_warnings(('', RuntimeWarning)):
+ # defaults to quiet=False with argument
+ pass
+ with self.assertRaises(AssertionError):
+ with support.check_warnings(('foo', RuntimeWarning)):
wmod.warn("foo")
- self.assertEqual(str(w.message), "foo")
- wmod.warn("bar")
- self.assertEqual(str(w.message), "bar")
- self.assertEqual(str(w.warnings[0].message), "foo")
- self.assertEqual(str(w.warnings[1].message), "bar")
- w.reset()
- self.assertEqual(w.warnings, [])
class CCatchWarningTests(CatchWarningTests):
module = c_warnings
@@ -689,32 +703,76 @@ class PyCatchWarningTests(CatchWarningTests):
module = py_warnings
+class EnvironmentVariableTests(BaseTest):
+
+ def test_single_warning(self):
+ newenv = os.environ.copy()
+ newenv["PYTHONWARNINGS"] = "ignore::DeprecationWarning"
+ p = subprocess.Popen([sys.executable,
+ "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
+ stdout=subprocess.PIPE, env=newenv)
+ self.assertEqual(p.communicate()[0], b"['ignore::DeprecationWarning']")
+ self.assertEqual(p.wait(), 0)
+
+ def test_comma_separated_warnings(self):
+ newenv = os.environ.copy()
+ newenv["PYTHONWARNINGS"] = ("ignore::DeprecationWarning,"
+ "ignore::UnicodeWarning")
+ p = subprocess.Popen([sys.executable,
+ "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
+ stdout=subprocess.PIPE, env=newenv)
+ self.assertEqual(p.communicate()[0],
+ b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")
+ self.assertEqual(p.wait(), 0)
+
+ def test_envvar_and_command_line(self):
+ newenv = os.environ.copy()
+ newenv["PYTHONWARNINGS"] = "ignore::DeprecationWarning"
+ p = subprocess.Popen([sys.executable, "-W" "ignore::UnicodeWarning",
+ "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
+ stdout=subprocess.PIPE, env=newenv)
+ self.assertEqual(p.communicate()[0],
+ b"['ignore::UnicodeWarning', 'ignore::DeprecationWarning']")
+ self.assertEqual(p.wait(), 0)
+
+ @unittest.skipUnless(sys.getfilesystemencoding() != 'ascii',
+ 'requires non-ascii filesystemencoding')
+ def test_nonascii(self):
+ newenv = os.environ.copy()
+ newenv["PYTHONWARNINGS"] = "ignore:DeprecaciónWarning"
+ newenv["PYTHONIOENCODING"] = "utf-8"
+ p = subprocess.Popen([sys.executable,
+ "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
+ stdout=subprocess.PIPE, env=newenv)
+ self.assertEqual(p.communicate()[0],
+ "['ignore:DeprecaciónWarning']".encode('utf-8'))
+ self.assertEqual(p.wait(), 0)
+
+class CEnvironmentVariableTests(EnvironmentVariableTests):
+ module = c_warnings
+
+class PyEnvironmentVariableTests(EnvironmentVariableTests):
+ module = py_warnings
+
+
class BootstrapTest(unittest.TestCase):
def test_issue_8766(self):
# "import encodings" emits a warning whereas the warnings is not loaded
# or not completely loaded (warnings imports indirectly encodings by
# importing linecache) yet
- cwd = tempfile.mkdtemp()
- try:
- encodings = os.path.join(cwd, 'encodings')
- os.mkdir(encodings)
- try:
- env = os.environ.copy()
- env['PYTHONPATH'] = cwd
-
- # encodings loaded by initfsencoding()
- retcode = subprocess.call([sys.executable, '-c', 'pass'], env=env)
- self.assertEqual(retcode, 0)
-
- # Use -W to load warnings module at startup
- retcode = subprocess.call(
- [sys.executable, '-c', 'pass', '-W', 'always'],
- env=env)
- self.assertEqual(retcode, 0)
- finally:
- os.rmdir(encodings)
- finally:
- os.rmdir(cwd)
+ with support.temp_cwd() as cwd, support.temp_cwd('encodings'):
+ env = os.environ.copy()
+ env['PYTHONPATH'] = cwd
+
+ # encodings loaded by initfsencoding()
+ retcode = subprocess.call([sys.executable, '-c', 'pass'], env=env)
+ self.assertEqual(retcode, 0)
+
+ # Use -W to load warnings module at startup
+ retcode = subprocess.call(
+ [sys.executable, '-c', 'pass', '-W', 'always'],
+ env=env)
+ self.assertEqual(retcode, 0)
def test_main():
py_warnings.onceregistry.clear()
@@ -726,6 +784,7 @@ def test_main():
_WarningsTests,
CWarningsDisplayTests, PyWarningsDisplayTests,
CCatchWarningTests, PyCatchWarningTests,
+ CEnvironmentVariableTests, PyEnvironmentVariableTests,
BootstrapTest,
)
diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py
index 1bcaa242c0..e0aace495c 100644
--- a/Lib/test/test_wave.py
+++ b/Lib/test/test_wave.py
@@ -22,11 +22,14 @@ class TestWave(unittest.TestCase):
except OSError:
pass
- def test_it(self):
+ def test_it(self, test_rounding=False):
self.f = wave.open(TESTFN, 'wb')
self.f.setnchannels(nchannels)
self.f.setsampwidth(sampwidth)
- self.f.setframerate(framerate)
+ if test_rounding:
+ self.f.setframerate(framerate - 0.1)
+ else:
+ self.f.setframerate(framerate)
self.f.setnframes(nframes)
output = b'\0' * nframes * nchannels * sampwidth
self.f.writeframes(output)
@@ -39,6 +42,13 @@ class TestWave(unittest.TestCase):
self.assertEqual(nframes, self.f.getnframes())
self.assertEqual(self.f.readframes(nframes), output)
+ def test_fractional_framerate(self):
+ """
+ Addresses [ 1512791 ] module wave does no rounding
+ Floating point framerates should be rounded, rather than truncated.
+ """
+ self.test_it(test_rounding=True)
+
def test_issue7681(self):
self.f = wave.open(TESTFN, 'wb')
self.f.setnchannels(nchannels)
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 028b418298..8b5bbc3d36 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -169,8 +169,7 @@ class ReferencesTestCase(TestBase):
p[:] = [2, 3]
self.assertEqual(len(L), 2)
self.assertEqual(len(p), 2)
- self.assertTrue(3 in p,
- "proxy didn't support __contains__() properly")
+ self.assertIn(3, p, "proxy didn't support __contains__() properly")
p[1] = 5
self.assertEqual(L[1], 5)
self.assertEqual(p[1], 5)
@@ -193,7 +192,7 @@ class ReferencesTestCase(TestBase):
def __bytes__(self):
return b"bytes"
instance = C()
- self.assertTrue("__bytes__" in dir(weakref.proxy(instance)))
+ self.assertIn("__bytes__", dir(weakref.proxy(instance)))
self.assertEqual(bytes(weakref.proxy(instance)), b"bytes")
def test_proxy_index(self):
@@ -681,6 +680,18 @@ class ReferencesTestCase(TestBase):
# No exception should be raised here
gc.collect()
+ def test_classes(self):
+ # Check that classes are weakrefable.
+ class A(object):
+ pass
+ l = []
+ weakref.ref(int)
+ a = weakref.ref(A, l.append)
+ A = None
+ gc.collect()
+ self.assertEqual(a(), None)
+ self.assertEqual(l, [a])
+
class SubclassableWeakrefTestCase(TestBase):
@@ -715,8 +726,8 @@ class SubclassableWeakrefTestCase(TestBase):
refs = weakref.getweakrefs(o)
self.assertEqual(len(refs), 3)
self.assertTrue(r2 is refs[0])
- self.assertTrue(r1 in refs[1:])
- self.assertTrue(r3 in refs[1:])
+ self.assertIn(r1, refs[1:])
+ self.assertIn(r3, refs[1:])
def test_subclass_refs_dont_conflate_callbacks(self):
class MyRef(weakref.ref):
@@ -726,8 +737,8 @@ class SubclassableWeakrefTestCase(TestBase):
r2 = MyRef(o, str)
self.assertTrue(r1 is not r2)
refs = weakref.getweakrefs(o)
- self.assertTrue(r1 in refs)
- self.assertTrue(r2 in refs)
+ self.assertIn(r1, refs)
+ self.assertIn(r2, refs)
def test_subclass_refs_with_slots(self):
class MyRef(weakref.ref):
@@ -860,8 +871,8 @@ class MappingTestCase(TestBase):
"deleting the keys did not clear the dictionary")
o = Object(42)
dict[o] = "What is the meaning of the universe?"
- self.assertTrue(o in dict)
- self.assertTrue(34 not in dict)
+ self.assertIn(o, dict)
+ self.assertNotIn(34, dict)
def test_weak_keyed_iters(self):
dict, objects = self.make_weak_keyed_dict()
@@ -873,8 +884,8 @@ class MappingTestCase(TestBase):
objects2 = list(objects)
for wr in refs:
ob = wr()
- self.assertTrue(ob in dict)
- self.assertTrue(ob in dict)
+ self.assertIn(ob, dict)
+ self.assertIn(ob, dict)
self.assertEqual(ob.arg, dict[ob])
objects2.remove(ob)
self.assertEqual(len(objects2), 0)
@@ -884,8 +895,8 @@ class MappingTestCase(TestBase):
self.assertEqual(len(list(dict.keyrefs())), len(objects))
for wr in dict.keyrefs():
ob = wr()
- self.assertTrue(ob in dict)
- self.assertTrue(ob in dict)
+ self.assertIn(ob, dict)
+ self.assertIn(ob, dict)
self.assertEqual(ob.arg, dict[ob])
objects2.remove(ob)
self.assertEqual(len(objects2), 0)
@@ -961,13 +972,13 @@ class MappingTestCase(TestBase):
# weakref'ed objects and then return a new key/value pair corresponding
# to the destroyed object.
with testcontext() as (k, v):
- self.assertFalse(k in dict)
+ self.assertNotIn(k, dict)
with testcontext() as (k, v):
self.assertRaises(KeyError, dict.__delitem__, k)
- self.assertFalse(k in dict)
+ self.assertNotIn(k, dict)
with testcontext() as (k, v):
self.assertRaises(KeyError, dict.pop, k)
- self.assertFalse(k in dict)
+ self.assertNotIn(k, dict)
with testcontext() as (k, v):
dict[k] = v
self.assertEqual(dict[k], v)
@@ -1091,13 +1102,13 @@ class MappingTestCase(TestBase):
weakdict = klass()
o = weakdict.setdefault(key, value1)
self.assertTrue(o is value1)
- self.assertTrue(key in weakdict)
+ self.assertIn(key, weakdict)
self.assertTrue(weakdict.get(key) is value1)
self.assertTrue(weakdict[key] is value1)
o = weakdict.setdefault(key, value2)
self.assertTrue(o is value1)
- self.assertTrue(key in weakdict)
+ self.assertIn(key, weakdict)
self.assertTrue(weakdict.get(key) is value1)
self.assertTrue(weakdict[key] is value1)
@@ -1118,14 +1129,12 @@ class MappingTestCase(TestBase):
weakdict.update(dict)
self.assertEqual(len(weakdict), len(dict))
for k in weakdict.keys():
- self.assertTrue(k in dict,
- "mysterious new key appeared in weak dict")
+ self.assertIn(k, dict, "mysterious new key appeared in weak dict")
v = dict.get(k)
self.assertTrue(v is weakdict[k])
self.assertTrue(v is weakdict.get(k))
for k in dict.keys():
- self.assertTrue(k in weakdict,
- "original key disappeared in weak dict")
+ self.assertIn(k, weakdict, "original key disappeared in weak dict")
v = dict[k]
self.assertTrue(v is weakdict[k])
self.assertTrue(v is weakdict.get(k))
diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py
index e587898d13..58a1f8790a 100644
--- a/Lib/test/test_weakset.py
+++ b/Lib/test/test_weakset.py
@@ -35,7 +35,7 @@ class TestWeakSet(unittest.TestCase):
for method in dir(set):
if method == 'test_c_api' or method.startswith('_'):
continue
- self.assertTrue(method in weaksetmethods,
+ self.assertIn(method, weaksetmethods,
"WeakSet missing method " + method)
def test_new_or_init(self):
@@ -52,9 +52,9 @@ class TestWeakSet(unittest.TestCase):
self.assertEqual(c in self.s, c in self.d)
# 1 is not weakref'able, but that TypeError is caught by __contains__
self.assertNotIn(1, self.s)
- self.assertTrue(self.obj in self.fs)
+ self.assertIn(self.obj, self.fs)
del self.obj
- self.assertTrue(ustr('F') not in self.fs)
+ self.assertNotIn(ustr('F'), self.fs)
def test_union(self):
u = self.s.union(self.items2)
@@ -151,7 +151,7 @@ class TestWeakSet(unittest.TestCase):
s=H()
f=set()
f.add(s)
- self.assertTrue(s in f)
+ self.assertIn(s, f)
f.remove(s)
f.add(s)
f.discard(s)
@@ -186,7 +186,7 @@ class TestWeakSet(unittest.TestCase):
def test_add(self):
x = ustr('Q')
self.s.add(x)
- self.assertTrue(x in self.s)
+ self.assertIn(x, self.s)
dup = self.s.copy()
self.s.add(x)
self.assertEqual(self.s, dup)
@@ -199,66 +199,66 @@ class TestWeakSet(unittest.TestCase):
def test_remove(self):
x = ustr('a')
self.s.remove(x)
- self.assertTrue(x not in self.s)
+ self.assertNotIn(x, self.s)
self.assertRaises(KeyError, self.s.remove, x)
self.assertRaises(TypeError, self.s.remove, [])
def test_discard(self):
a, q = ustr('a'), ustr('Q')
self.s.discard(a)
- self.assertTrue(a not in self.s)
+ self.assertNotIn(a, self.s)
self.s.discard(q)
self.assertRaises(TypeError, self.s.discard, [])
def test_pop(self):
for i in range(len(self.s)):
elem = self.s.pop()
- self.assertTrue(elem not in self.s)
+ self.assertNotIn(elem, self.s)
self.assertRaises(KeyError, self.s.pop)
def test_update(self):
retval = self.s.update(self.items2)
self.assertEqual(retval, None)
for c in (self.items + self.items2):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
self.assertRaises(TypeError, self.s.update, [[]])
def test_update_set(self):
self.s.update(set(self.items2))
for c in (self.items + self.items2):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
def test_ior(self):
self.s |= set(self.items2)
for c in (self.items + self.items2):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
def test_intersection_update(self):
retval = self.s.intersection_update(self.items2)
self.assertEqual(retval, None)
for c in (self.items + self.items2):
if c in self.items2 and c in self.items:
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
self.assertRaises(TypeError, self.s.intersection_update, [[]])
def test_iand(self):
self.s &= set(self.items2)
for c in (self.items + self.items2):
if c in self.items2 and c in self.items:
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
def test_difference_update(self):
retval = self.s.difference_update(self.items2)
self.assertEqual(retval, None)
for c in (self.items + self.items2):
if c in self.items and c not in self.items2:
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
self.assertRaises(TypeError, self.s.difference_update, [[]])
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
@@ -266,27 +266,27 @@ class TestWeakSet(unittest.TestCase):
self.s -= set(self.items2)
for c in (self.items + self.items2):
if c in self.items and c not in self.items2:
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
def test_symmetric_difference_update(self):
retval = self.s.symmetric_difference_update(self.items2)
self.assertEqual(retval, None)
for c in (self.items + self.items2):
if (c in self.items) ^ (c in self.items2):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
def test_ixor(self):
self.s ^= set(self.items2)
for c in (self.items + self.items2):
if (c in self.items) ^ (c in self.items2):
- self.assertTrue(c in self.s)
+ self.assertIn(c, self.s)
else:
- self.assertTrue(c not in self.s)
+ self.assertNotIn(c, self.s)
def test_inplace_on_self(self):
t = self.s.copy()
@@ -343,13 +343,13 @@ class TestWeakSet(unittest.TestCase):
it = None # should commit all removals
with testcontext() as u:
- self.assertFalse(u in s)
+ self.assertNotIn(u, s)
with testcontext() as u:
self.assertRaises(KeyError, s.remove, u)
- self.assertFalse(u in s)
+ self.assertNotIn(u, s)
with testcontext() as u:
s.add(u)
- self.assertTrue(u in s)
+ self.assertIn(u, s)
t = s.copy()
with testcontext() as u:
s.update(t)
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
index f898bf7405..0c1bf29463 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Test the windows specific win32reg module.
# Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey
@@ -6,13 +5,32 @@ import os, sys
import unittest
from test import support
threading = support.import_module("threading")
+from platform import machine
# Do this first so test will be skipped if module doesn't exist
support.import_module('winreg')
# Now import everything
from winreg import *
+try:
+ REMOTE_NAME = sys.argv[sys.argv.index("--remote")+1]
+except (IndexError, ValueError):
+ REMOTE_NAME = None
+
+# tuple of (major, minor)
+WIN_VER = sys.getwindowsversion()[:2]
+# Some tests should only run on 64-bit architectures where WOW64 will be.
+WIN64_MACHINE = True if machine() == "AMD64" else False
+
+# Starting with Windows 7 and Windows Server 2008 R2, WOW64 no longer uses
+# registry reflection and formerly reflected keys are shared instead.
+# Windows 7 and Windows Server 2008 R2 are version 6.1. Due to this, some
+# tests are only valid up until 6.1
+HAS_REFLECTION = True if WIN_VER < (6, 1) else False
+
test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me"
+# On OS'es that support reflection we should test with a reflected key
+test_reflect_key_name = "SOFTWARE\\Classes\\Python Test Key - Delete Me"
test_data = [
("Int Value", 45, REG_DWORD),
@@ -26,8 +44,7 @@ test_data = [
("Japanese 日本", "日本語", REG_SZ),
]
-class WinregTests(unittest.TestCase):
- remote_name = None
+class BaseWinregTests(unittest.TestCase):
def setUp(self):
# Make sure that the test key is absent when the test
@@ -50,7 +67,8 @@ class WinregTests(unittest.TestCase):
CloseKey(hkey)
DeleteKey(root, subkey)
- def WriteTestData(self, root_key, subkeystr="sub_key"):
+ def _write_test_data(self, root_key, subkeystr="sub_key",
+ CreateKey=CreateKey):
# Set the default value for this key.
SetValue(root_key, test_key_name, REG_SZ, "Default value")
key = CreateKey(root_key, test_key_name)
@@ -91,7 +109,7 @@ class WinregTests(unittest.TestCase):
except EnvironmentError:
pass
- def ReadTestData(self, root_key, subkeystr="sub_key"):
+ def _read_test_data(self, root_key, subkeystr="sub_key", OpenKey=OpenKey):
# Check we can get default value for this key.
val = QueryValue(root_key, test_key_name)
self.assertEqual(val, "Default value",
@@ -131,7 +149,7 @@ class WinregTests(unittest.TestCase):
key.Close()
- def DeleteTestData(self, root_key, subkeystr="sub_key"):
+ def _delete_test_data(self, root_key, subkeystr="sub_key"):
key = OpenKey(root_key, test_key_name, 0, KEY_ALL_ACCESS)
sub_key = OpenKey(key, subkeystr, 0, KEY_ALL_ACCESS)
# It is not necessary to delete the values before deleting
@@ -161,31 +179,70 @@ class WinregTests(unittest.TestCase):
except WindowsError: # Use this error name this time
pass
- def TestAll(self, root_key, subkeystr="sub_key"):
- self.WriteTestData(root_key, subkeystr)
- self.ReadTestData(root_key, subkeystr)
- self.DeleteTestData(root_key, subkeystr)
+ def _test_all(self, root_key, subkeystr="sub_key"):
+ self._write_test_data(root_key, subkeystr)
+ self._read_test_data(root_key, subkeystr)
+ self._delete_test_data(root_key, subkeystr)
+
+ def _test_named_args(self, key, sub_key):
+ with CreateKeyEx(key=key, sub_key=sub_key, reserved=0,
+ access=KEY_ALL_ACCESS) as ckey:
+ self.assertTrue(ckey.handle != 0)
+
+ with OpenKeyEx(key=key, sub_key=sub_key, reserved=0,
+ access=KEY_ALL_ACCESS) as okey:
+ self.assertTrue(okey.handle != 0)
+
+
+class LocalWinregTests(BaseWinregTests):
+
+ def test_registry_works(self):
+ self._test_all(HKEY_CURRENT_USER)
+ self._test_all(HKEY_CURRENT_USER, "日本-subkey")
+
+ def test_registry_works_extended_functions(self):
+ # Substitute the regular CreateKey and OpenKey calls with their
+ # extended counterparts.
+ # Note: DeleteKeyEx is not used here because it is platform dependent
+ cke = lambda key, sub_key: CreateKeyEx(key, sub_key, 0, KEY_ALL_ACCESS)
+ self._write_test_data(HKEY_CURRENT_USER, CreateKey=cke)
+
+ oke = lambda key, sub_key: OpenKeyEx(key, sub_key, 0, KEY_READ)
+ self._read_test_data(HKEY_CURRENT_USER, OpenKey=oke)
+
+ self._delete_test_data(HKEY_CURRENT_USER)
- def testLocalMachineRegistryWorks(self):
- self.TestAll(HKEY_CURRENT_USER)
- self.TestAll(HKEY_CURRENT_USER, "日本-subkey")
+ def test_named_arguments(self):
+ self._test_named_args(HKEY_CURRENT_USER, test_key_name)
+ # Use the regular DeleteKey to clean up
+ # DeleteKeyEx takes named args and is tested separately
+ DeleteKey(HKEY_CURRENT_USER, test_key_name)
- def testConnectRegistryToLocalMachineWorks(self):
+ def test_connect_registry_to_local_machine_works(self):
# perform minimal ConnectRegistry test which just invokes it
h = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
+ self.assertNotEqual(h.handle, 0)
h.Close()
+ self.assertEqual(h.handle, 0)
- def testRemoteMachineRegistryWorks(self):
- if not self.remote_name:
- return # remote machine name not specified
- remote_key = ConnectRegistry(self.remote_name, HKEY_CURRENT_USER)
- self.TestAll(remote_key)
+ def test_inexistant_remote_registry(self):
+ connect = lambda: ConnectRegistry("abcdefghijkl", HKEY_CURRENT_USER)
+ self.assertRaises(WindowsError, connect)
def testExpandEnvironmentStrings(self):
r = ExpandEnvironmentStrings("%windir%\\test")
self.assertEqual(type(r), str)
self.assertEqual(r, os.environ["windir"] + "\\test")
+ def test_context_manager(self):
+ # ensure that the handle is closed if an exception occurs
+ try:
+ with ConnectRegistry(None, HKEY_LOCAL_MACHINE) as h:
+ self.assertNotEqual(h.handle, 0)
+ raise WindowsError
+ except WindowsError:
+ self.assertEqual(h.handle, 0)
+
def test_changing_value(self):
# Issue2810: A race condition in 2.6 and 3.1 may cause
# EnumValue or QueryValue to throw "WindowsError: More data is
@@ -238,15 +295,137 @@ class WinregTests(unittest.TestCase):
EnumValue(HKEY_PERFORMANCE_DATA, 0)
QueryValueEx(HKEY_PERFORMANCE_DATA, "")
+ # Reflection requires XP x64/Vista at a minimum. XP doesn't have this stuff
+ # or DeleteKeyEx so make sure their use raises NotImplementedError
+ @unittest.skipUnless(WIN_VER < (5, 2), "Requires Windows XP")
+ def test_reflection_unsupported(self):
+ try:
+ with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck:
+ self.assertNotEqual(ck.handle, 0)
+
+ key = OpenKey(HKEY_CURRENT_USER, test_key_name)
+ self.assertNotEqual(key.handle, 0)
+
+ with self.assertRaises(NotImplementedError):
+ DisableReflectionKey(key)
+ with self.assertRaises(NotImplementedError):
+ EnableReflectionKey(key)
+ with self.assertRaises(NotImplementedError):
+ QueryReflectionKey(key)
+ with self.assertRaises(NotImplementedError):
+ DeleteKeyEx(HKEY_CURRENT_USER, test_key_name)
+ finally:
+ DeleteKey(HKEY_CURRENT_USER, test_key_name)
+
+
+@unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests")
+class RemoteWinregTests(BaseWinregTests):
+
+ def test_remote_registry_works(self):
+ remote_key = ConnectRegistry(REMOTE_NAME, HKEY_CURRENT_USER)
+ self._test_all(remote_key)
+
+
+@unittest.skipUnless(WIN64_MACHINE, "x64 specific registry tests")
+class Win64WinregTests(BaseWinregTests):
+
+ def test_named_arguments(self):
+ self._test_named_args(HKEY_CURRENT_USER, test_key_name)
+ # Clean up and also exercise the named arguments
+ DeleteKeyEx(key=HKEY_CURRENT_USER, sub_key=test_key_name,
+ access=KEY_ALL_ACCESS, reserved=0)
+
+ def test_reflection_functions(self):
+ # Test that we can call the query, enable, and disable functions
+ # on a key which isn't on the reflection list with no consequences.
+ with OpenKey(HKEY_LOCAL_MACHINE, "Software") as key:
+ # HKLM\Software is redirected but not reflected in all OSes
+ self.assertTrue(QueryReflectionKey(key))
+ self.assertIsNone(EnableReflectionKey(key))
+ self.assertIsNone(DisableReflectionKey(key))
+ self.assertTrue(QueryReflectionKey(key))
+
+ @unittest.skipUnless(HAS_REFLECTION, "OS doesn't support reflection")
+ def test_reflection(self):
+ # Test that we can create, open, and delete keys in the 32-bit
+ # area. Because we are doing this in a key which gets reflected,
+ # test the differences of 32 and 64-bit keys before and after the
+ # reflection occurs (ie. when the created key is closed).
+ try:
+ with CreateKeyEx(HKEY_CURRENT_USER, test_reflect_key_name, 0,
+ KEY_ALL_ACCESS | KEY_WOW64_32KEY) as created_key:
+ self.assertNotEqual(created_key.handle, 0)
+
+ # The key should now be available in the 32-bit area
+ with OpenKey(HKEY_CURRENT_USER, test_reflect_key_name, 0,
+ KEY_ALL_ACCESS | KEY_WOW64_32KEY) as key:
+ self.assertNotEqual(key.handle, 0)
+
+ # Write a value to what currently is only in the 32-bit area
+ SetValueEx(created_key, "", 0, REG_SZ, "32KEY")
+
+ # The key is not reflected until created_key is closed.
+ # The 64-bit version of the key should not be available yet.
+ open_fail = lambda: OpenKey(HKEY_CURRENT_USER,
+ test_reflect_key_name, 0,
+ KEY_READ | KEY_WOW64_64KEY)
+ self.assertRaises(WindowsError, open_fail)
+
+ # Now explicitly open the 64-bit version of the key
+ with OpenKey(HKEY_CURRENT_USER, test_reflect_key_name, 0,
+ KEY_ALL_ACCESS | KEY_WOW64_64KEY) as key:
+ self.assertNotEqual(key.handle, 0)
+ # Make sure the original value we set is there
+ self.assertEqual("32KEY", QueryValue(key, ""))
+ # Set a new value, which will get reflected to 32-bit
+ SetValueEx(key, "", 0, REG_SZ, "64KEY")
+
+ # Reflection uses a "last-writer wins policy, so the value we set
+ # on the 64-bit key should be the same on 32-bit
+ with OpenKey(HKEY_CURRENT_USER, test_reflect_key_name, 0,
+ KEY_READ | KEY_WOW64_32KEY) as key:
+ self.assertEqual("64KEY", QueryValue(key, ""))
+ finally:
+ DeleteKeyEx(HKEY_CURRENT_USER, test_reflect_key_name,
+ KEY_WOW64_32KEY, 0)
+
+ @unittest.skipUnless(HAS_REFLECTION, "OS doesn't support reflection")
+ def test_disable_reflection(self):
+ # Make use of a key which gets redirected and reflected
+ try:
+ with CreateKeyEx(HKEY_CURRENT_USER, test_reflect_key_name, 0,
+ KEY_ALL_ACCESS | KEY_WOW64_32KEY) as created_key:
+ # QueryReflectionKey returns whether or not the key is disabled
+ disabled = QueryReflectionKey(created_key)
+ self.assertEqual(type(disabled), bool)
+ # HKCU\Software\Classes is reflected by default
+ self.assertFalse(disabled)
+
+ DisableReflectionKey(created_key)
+ self.assertTrue(QueryReflectionKey(created_key))
+
+ # The key is now closed and would normally be reflected to the
+ # 64-bit area, but let's make sure that didn't happen.
+ open_fail = lambda: OpenKeyEx(HKEY_CURRENT_USER,
+ test_reflect_key_name, 0,
+ KEY_READ | KEY_WOW64_64KEY)
+ self.assertRaises(WindowsError, open_fail)
+
+ # Make sure the 32-bit key is actually there
+ with OpenKeyEx(HKEY_CURRENT_USER, test_reflect_key_name, 0,
+ KEY_READ | KEY_WOW64_32KEY) as key:
+ self.assertNotEqual(key.handle, 0)
+ finally:
+ DeleteKeyEx(HKEY_CURRENT_USER, test_reflect_key_name,
+ KEY_WOW64_32KEY, 0)
+
def test_main():
- support.run_unittest(WinregTests)
+ support.run_unittest(LocalWinregTests, RemoteWinregTests,
+ Win64WinregTests)
if __name__ == "__main__":
- try:
- WinregTests.remote_name = sys.argv[sys.argv.index("--remote")+1]
- except (IndexError, ValueError):
+ if not REMOTE_NAME:
print("Remote registry calls can be tested using",
"'test_winreg.py --remote \\\\machine_name'")
- WinregTests.remote_name = None
test_main()
diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py
index be0e625629..34c3deaf7e 100644
--- a/Lib/test/test_winsound.py
+++ b/Lib/test/test_winsound.py
@@ -249,6 +249,7 @@ def _have_soundcard():
p = subprocess.Popen([cscript_path, check_script],
stdout=subprocess.PIPE)
__have_soundcard_cache = not p.wait()
+ p.stdout.close()
return __have_soundcard_cache
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index 66ff3b21f3..a9d374b324 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Unit tests for the with statement specified in PEP 343."""
@@ -9,26 +9,26 @@ __email__ = "mbland at acm dot org"
import sys
import unittest
from collections import deque
-from contextlib import GeneratorContextManager, contextmanager
+from contextlib import _GeneratorContextManager, contextmanager
from test.support import run_unittest
-class MockContextManager(GeneratorContextManager):
+class MockContextManager(_GeneratorContextManager):
def __init__(self, gen):
- GeneratorContextManager.__init__(self, gen)
+ _GeneratorContextManager.__init__(self, gen)
self.enter_called = False
self.exit_called = False
self.exit_args = None
def __enter__(self):
self.enter_called = True
- return GeneratorContextManager.__enter__(self)
+ return _GeneratorContextManager.__enter__(self)
def __exit__(self, type, value, traceback):
self.exit_called = True
self.exit_args = (type, value, traceback)
- return GeneratorContextManager.__exit__(self, type,
- value, traceback)
+ return _GeneratorContextManager.__exit__(self, type,
+ value, traceback)
def mock_contextmanager(func):
@@ -215,11 +215,17 @@ class ContextmanagerAssertionMixin(object):
def raiseTestException(self):
raise self.TEST_EXCEPTION
- def assertAfterWithManagerInvariantsWithError(self, mock_manager):
+ def assertAfterWithManagerInvariantsWithError(self, mock_manager,
+ exc_type=None):
self.assertTrue(mock_manager.enter_called)
self.assertTrue(mock_manager.exit_called)
- self.assertEqual(mock_manager.exit_args[0], RuntimeError)
- self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION)
+ if exc_type is None:
+ self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION)
+ exc_type = type(self.TEST_EXCEPTION)
+ self.assertEqual(mock_manager.exit_args[0], exc_type)
+ # Test the __exit__ arguments. Issue #7853
+ self.assertIsInstance(mock_manager.exit_args[1], exc_type)
+ self.assertIsNot(mock_manager.exit_args[2], None)
def assertAfterWithGeneratorInvariantsWithError(self, mock_generator):
self.assertTrue(mock_generator.yielded)
@@ -285,15 +291,6 @@ class NestedNonexceptionalTestCase(unittest.TestCase,
with Nested(mock_contextmanager_generator()):
pass
- def testSingleArgUnbound(self):
- mock_contextmanager = mock_contextmanager_generator()
- mock_nested = MockNested(mock_contextmanager)
- with mock_nested:
- self.assertInWithManagerInvariants(mock_contextmanager)
- self.assertInWithManagerInvariants(mock_nested)
- self.assertAfterWithManagerInvariantsNoError(mock_contextmanager)
- self.assertAfterWithManagerInvariantsNoError(mock_nested)
-
def testSingleArgBoundToNonTuple(self):
m = mock_contextmanager_generator()
# This will bind all the arguments to nested() into a single list
@@ -366,6 +363,16 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
self.assertAfterWithManagerInvariantsWithError(cm)
self.assertAfterWithGeneratorInvariantsWithError(self.resource)
+ def testExceptionNormalized(self):
+ cm = mock_contextmanager_generator()
+ def shouldThrow():
+ with cm as self.resource:
+ # Note this relies on the fact that 1 // 0 produces an exception
+ # that is not normalized immediately.
+ 1 // 0
+ self.assertRaises(ZeroDivisionError, shouldThrow)
+ self.assertAfterWithManagerInvariantsWithError(cm, ZeroDivisionError)
+
def testNestedSingleStatements(self):
mock_a = mock_contextmanager_generator()
mock_b = mock_contextmanager_generator()
@@ -721,6 +728,7 @@ class NestedWith(unittest.TestCase):
body_executed = True
self.assertTrue(a.enter_called)
self.assertTrue(a.exit_called)
+ self.assertTrue(body_executed)
self.assertNotEqual(a.exc_info[0], None)
def testEnterReturnsTuple(self):
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py
index 3450163997..a08f66b7b4 100755..100644
--- a/Lib/test/test_wsgiref.py
+++ b/Lib/test/test_wsgiref.py
@@ -47,7 +47,7 @@ def hello_app(environ,start_response):
('Content-Type','text/plain'),
('Date','Mon, 05 Jun 2006 18:49:54 GMT')
])
- return ["Hello, world!"]
+ return [b"Hello, world!"]
def run_amock(app=hello_app, data=b"GET / HTTP/1.0\n\n"):
server = make_server("", 80, app, MockServer, MockHandler)
@@ -131,7 +131,7 @@ class IntegrationTests(TestCase):
def check_hello(self, out, has_length=True):
self.assertEqual(out,
("HTTP/1.0 200 OK\r\n"
- "Server: WSGIServer/0.1 Python/"+sys.version.split()[0]+"\r\n"
+ "Server: WSGIServer/0.2 Python/"+sys.version.split()[0]+"\r\n"
"Content-Type: text/plain\r\n"
"Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" +
(has_length and "Content-Length: 13\r\n" or "") +
@@ -165,7 +165,7 @@ class IntegrationTests(TestCase):
def test_wsgi_input(self):
def bad_app(e,s):
e["wsgi.input"].read()
- s(b"200 OK", [(b"Content-Type", b"text/plain; charset=utf-8")])
+ s("200 OK", [("Content-Type", "text/plain; charset=utf-8")])
return [b"data"]
out, err = run_amock(validator(bad_app))
self.assertTrue(out.endswith(
@@ -177,8 +177,8 @@ class IntegrationTests(TestCase):
def test_bytes_validation(self):
def app(e, s):
- s(b"200 OK", [
- (b"Content-Type", b"text/plain; charset=utf-8"),
+ s("200 OK", [
+ ("Content-Type", "text/plain; charset=utf-8"),
("Date", "Wed, 24 Dec 2008 13:29:32 GMT"),
])
return [b"data"]
@@ -187,7 +187,7 @@ class IntegrationTests(TestCase):
ver = sys.version.split()[0].encode('ascii')
self.assertEqual(
b"HTTP/1.0 200 OK\r\n"
- b"Server: WSGIServer/0.1 Python/" + ver + b"\r\n"
+ b"Server: WSGIServer/0.2 Python/" + ver + b"\r\n"
b"Content-Type: text/plain; charset=utf-8\r\n"
b"Date: Wed, 24 Dec 2008 13:29:32 GMT\r\n"
b"\r\n"
@@ -211,12 +211,12 @@ class UtilityTests(TestCase):
# Check defaulting when empty
env = {}
util.setup_testing_defaults(env)
- if isinstance(value,StringIO):
- self.assertTrue(isinstance(env[key],StringIO))
+ if isinstance(value, StringIO):
+ self.assertIsInstance(env[key], StringIO)
elif isinstance(value,BytesIO):
- self.assertTrue(isinstance(env[key],BytesIO))
+ self.assertIsInstance(env[key],BytesIO)
else:
- self.assertEqual(env[key],value)
+ self.assertEqual(env[key], value)
# Check existing value
env = {key:alt}
@@ -424,29 +424,6 @@ class HeaderTests(TestCase):
'\r\n'
)
- def testBytes(self):
- h = Headers([
- (b"Content-Type", b"text/plain; charset=utf-8"),
- ])
- self.assertEqual("text/plain; charset=utf-8", h.get("Content-Type"))
-
- h[b"Foo"] = bytes(b"bar")
- self.assertEqual("bar", h.get("Foo"))
- self.assertEqual("bar", h.get(b"Foo"))
-
- h.setdefault(b"Bar", b"foo")
- self.assertEqual("foo", h.get("Bar"))
- self.assertEqual("foo", h.get(b"Bar"))
-
- h.add_header(b'content-disposition', b'attachment',
- filename=b'bud.gif')
- self.assertEqual('attachment; filename="bud.gif"',
- h.get("content-disposition"))
-
- del h['content-disposition']
- self.assertTrue(b'content-disposition' not in h)
-
-
class ErrorHandler(BaseCGIHandler):
"""Simple handler subclass for testing BaseHandler"""
@@ -497,7 +474,7 @@ class HandlerTests(TestCase):
if k not in empty:
self.assertEqual(env[k],v)
for k,v in empty.items():
- self.assertTrue(k in env)
+ self.assertIn(k, env)
def testEnviron(self):
h = TestHandler(X="Y")
@@ -510,7 +487,7 @@ class HandlerTests(TestCase):
h = BaseCGIHandler(None,None,None,{})
h.setup_environ()
for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors':
- self.assertTrue(key in h.environ)
+ self.assertIn(key, h.environ)
def testScheme(self):
h=TestHandler(HTTPS="on"); h.setup_environ()
@@ -533,10 +510,10 @@ class HandlerTests(TestCase):
def trivial_app1(e,s):
s('200 OK',[])
- return [e['wsgi.url_scheme']]
+ return [e['wsgi.url_scheme'].encode('iso-8859-1')]
def trivial_app2(e,s):
- s('200 OK',[])(e['wsgi.url_scheme'])
+ s('200 OK',[])(e['wsgi.url_scheme'].encode('iso-8859-1'))
return []
def trivial_app3(e,s):
@@ -601,13 +578,13 @@ class HandlerTests(TestCase):
("Status: %s\r\n"
"Content-Type: text/plain\r\n"
"Content-Length: %d\r\n"
- "\r\n%s" % (h.error_status,len(h.error_body),h.error_body)
- ).encode("iso-8859-1"))
+ "\r\n" % (h.error_status,len(h.error_body))).encode('iso-8859-1')
+ + h.error_body)
- self.assertTrue("AssertionError" in h.stderr.getvalue())
+ self.assertIn("AssertionError", h.stderr.getvalue())
def testErrorAfterOutput(self):
- MSG = "Some output has been sent"
+ MSG = b"Some output has been sent"
def error_app(e,s):
s("200 OK",[])(MSG)
raise AssertionError("This should be caught by handler")
@@ -616,8 +593,8 @@ class HandlerTests(TestCase):
h.run(error_app)
self.assertEqual(h.stdout.getvalue(),
("Status: 200 OK\r\n"
- "\r\n"+MSG).encode("iso-8859-1"))
- self.assertTrue("AssertionError" in h.stderr.getvalue())
+ "\r\n".encode("iso-8859-1")+MSG))
+ self.assertIn("AssertionError", h.stderr.getvalue())
def testHeaderFormats(self):
@@ -665,8 +642,8 @@ class HandlerTests(TestCase):
def testBytesData(self):
def app(e, s):
- s(b"200 OK", [
- (b"Content-Type", b"text/plain; charset=utf-8"),
+ s("200 OK", [
+ ("Content-Type", "text/plain; charset=utf-8"),
])
return [b"data"]
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index f2551d6d6b..22fafa9a2e 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1,22 +1,52 @@
# xml.etree test. This file contains enough tests to make sure that
-# all included components work as they should. For a more extensive
-# test suite, see the selftest script in the ElementTree distribution.
+# all included components work as they should.
+# Large parts are extracted from the upstream test suite.
+
+# IMPORTANT: the same doctests are run from "test_xml_etree_c" in
+# order to ensure consistency between the C implementation and the
+# Python implementation.
+#
+# For this purpose, the module-level "ET" symbol is temporarily
+# monkey-patched when running the "test_xml_etree_c" test suite.
+# Don't re-import "xml.etree.ElementTree" module in the docstring,
+# except if the test is specific to the Python implementation.
-import doctest
import sys
+import html
+import unittest
from test import support
+from test.support import findfile
+
+from xml.etree import ElementTree as ET
-SAMPLE_XML = """
+SIMPLE_XMLFILE = findfile("simple.xml", subdir="xmltestdata")
+try:
+ SIMPLE_XMLFILE.encode("utf8")
+except UnicodeEncodeError:
+ raise unittest.SkipTest("filename is not encodable to utf8")
+SIMPLE_NS_XMLFILE = findfile("simple-ns.xml", subdir="xmltestdata")
+
+SAMPLE_XML = """\
<body>
- <tag>text</tag>
- <tag />
+ <tag class='a'>text</tag>
+ <tag class='b' />
<section>
- <tag>subtext</tag>
+ <tag class='b' id='inner'>subtext</tag>
</section>
</body>
"""
+SAMPLE_SECTION = """\
+<section>
+ <tag class='b' id='inner'>subtext</tag>
+ <nexttag />
+ <nextsection>
+ <tag />
+ </nextsection>
+</section>
+"""
+
SAMPLE_XML_NS = """
<body xmlns="http://effbot.org/ns">
<tag>text</tag>
@@ -27,6 +57,7 @@ SAMPLE_XML_NS = """
</body>
"""
+
def sanity():
"""
Import sanity.
@@ -40,35 +71,110 @@ def check_method(method):
if not hasattr(method, '__call__'):
print(method, "not callable")
-def serialize(ET, elem):
+def serialize(elem, to_string=True, encoding='unicode', **options):
import io
+ if encoding != 'unicode':
+ file = io.BytesIO()
+ else:
+ file = io.StringIO()
tree = ET.ElementTree(elem)
- file = io.StringIO()
- tree.write(file)
- return file.getvalue()
+ tree.write(file, encoding=encoding, **options)
+ if to_string:
+ return file.getvalue()
+ else:
+ file.seek(0)
+ return file
def summarize(elem):
+ if elem.tag == ET.Comment:
+ return "<Comment>"
return elem.tag
def summarize_list(seq):
- return list(map(summarize, seq))
+ return [summarize(elem) for elem in seq]
+
+def normalize_crlf(tree):
+ for elem in tree.iter():
+ if elem.text:
+ elem.text = elem.text.replace("\r\n", "\n")
+ if elem.tail:
+ elem.tail = elem.tail.replace("\r\n", "\n")
+
+def normalize_exception(func, *args, **kwargs):
+ # Ignore the exception __module__
+ try:
+ func(*args, **kwargs)
+ except Exception as err:
+ print("Traceback (most recent call last):")
+ print("{}: {}".format(err.__class__.__name__, err))
+
+def check_string(string):
+ len(string)
+ for char in string:
+ if len(char) != 1:
+ print("expected one-character string, got %r" % char)
+ new_string = string + ""
+ new_string = string + " "
+ string[:0]
+
+def check_mapping(mapping):
+ len(mapping)
+ keys = mapping.keys()
+ items = mapping.items()
+ for key in keys:
+ item = mapping[key]
+ mapping["key"] = "value"
+ if mapping["key"] != "value":
+ print("expected value string, got %r" % mapping["key"])
+
+def check_element(element):
+ if not ET.iselement(element):
+ print("not an element")
+ if not hasattr(element, "tag"):
+ print("no tag member")
+ if not hasattr(element, "attrib"):
+ print("no attrib member")
+ if not hasattr(element, "text"):
+ print("no text member")
+ if not hasattr(element, "tail"):
+ print("no tail member")
+
+ check_string(element.tag)
+ check_mapping(element.attrib)
+ if element.text is not None:
+ check_string(element.text)
+ if element.tail is not None:
+ check_string(element.tail)
+ for elem in element:
+ check_element(elem)
+
+# --------------------------------------------------------------------
+# element tree tests
def interface():
"""
Test element tree interface.
- >>> from xml.etree import ElementTree as ET
+ >>> element = ET.Element("tag")
+ >>> check_element(element)
+ >>> tree = ET.ElementTree(element)
+ >>> check_element(tree.getroot())
- >>> element = ET.Element("tag", key="value")
+ >>> element = ET.Element("t\\xe4g", key="value")
>>> tree = ET.ElementTree(element)
+ >>> repr(element) # doctest: +ELLIPSIS
+ "<Element 't\\xe4g' at 0x...>"
+ >>> element = ET.Element("tag", key="value")
Make sure all standard element methods exist.
>>> check_method(element.append)
+ >>> check_method(element.extend)
>>> check_method(element.insert)
>>> check_method(element.remove)
>>> check_method(element.getchildren)
>>> check_method(element.find)
+ >>> check_method(element.iterfind)
>>> check_method(element.findall)
>>> check_method(element.findtext)
>>> check_method(element.clear)
@@ -76,112 +182,134 @@ def interface():
>>> check_method(element.set)
>>> check_method(element.keys)
>>> check_method(element.items)
+ >>> check_method(element.iter)
+ >>> check_method(element.itertext)
>>> check_method(element.getiterator)
+ These methods return an iterable. See bug 6472.
+
+ >>> check_method(element.iter("tag").__next__)
+ >>> check_method(element.iterfind("tag").__next__)
+ >>> check_method(element.iterfind("*").__next__)
+ >>> check_method(tree.iter("tag").__next__)
+ >>> check_method(tree.iterfind("tag").__next__)
+ >>> check_method(tree.iterfind("*").__next__)
+
+ These aliases are provided:
+
+ >>> assert ET.XML == ET.fromstring
+ >>> assert ET.PI == ET.ProcessingInstruction
+ >>> assert ET.XMLParser == ET.XMLTreeBuilder
+ """
+
+def simpleops():
+ """
Basic method sanity checks.
- >>> serialize(ET, element) # 1
+ >>> elem = ET.XML("<body><tag/></body>")
+ >>> serialize(elem)
+ '<body><tag /></body>'
+ >>> e = ET.Element("tag2")
+ >>> elem.append(e)
+ >>> serialize(elem)
+ '<body><tag /><tag2 /></body>'
+ >>> elem.remove(e)
+ >>> serialize(elem)
+ '<body><tag /></body>'
+ >>> elem.insert(0, e)
+ >>> serialize(elem)
+ '<body><tag2 /><tag /></body>'
+ >>> elem.remove(e)
+ >>> elem.extend([e])
+ >>> serialize(elem)
+ '<body><tag /><tag2 /></body>'
+ >>> elem.remove(e)
+
+ >>> element = ET.Element("tag", key="value")
+ >>> serialize(element) # 1
'<tag key="value" />'
>>> subelement = ET.Element("subtag")
>>> element.append(subelement)
- >>> serialize(ET, element) # 2
+ >>> serialize(element) # 2
'<tag key="value"><subtag /></tag>'
>>> element.insert(0, subelement)
- >>> serialize(ET, element) # 3
+ >>> serialize(element) # 3
'<tag key="value"><subtag /><subtag /></tag>'
>>> element.remove(subelement)
- >>> serialize(ET, element) # 4
+ >>> serialize(element) # 4
'<tag key="value"><subtag /></tag>'
>>> element.remove(subelement)
- >>> serialize(ET, element) # 5
+ >>> serialize(element) # 5
'<tag key="value" />'
>>> element.remove(subelement)
Traceback (most recent call last):
ValueError: list.remove(x): x not in list
- >>> serialize(ET, element) # 6
+ >>> serialize(element) # 6
'<tag key="value" />'
+ >>> element[0:0] = [subelement, subelement, subelement]
+ >>> serialize(element[1])
+ '<subtag />'
+ >>> element[1:9] == [element[1], element[2]]
+ True
+ >>> element[:9:2] == [element[0], element[2]]
+ True
+ >>> del element[1:2]
+ >>> serialize(element)
+ '<tag key="value"><subtag /><subtag /></tag>'
"""
-def qname():
+def cdata():
"""
- Test QName handling.
-
- 1) decorated tags
+ Test CDATA handling (etc).
- >>> from xml.etree import ElementTree as ET
- >>> elem = ET.Element("{uri}tag")
- >>> serialize(ET, elem) # 1.1
- '<ns0:tag xmlns:ns0="uri" />'
- >>> elem = ET.Element(ET.QName("{uri}tag"))
- >>> serialize(ET, elem) # 1.2
- '<ns0:tag xmlns:ns0="uri" />'
- >>> elem = ET.Element(ET.QName("uri", "tag"))
- >>> serialize(ET, elem) # 1.3
- '<ns0:tag xmlns:ns0="uri" />'
- >>> elem = ET.Element(ET.QName("uri", "tag"))
- >>> subelem = ET.SubElement(elem, ET.QName("uri", "tag1"))
- >>> subelem = ET.SubElement(elem, ET.QName("uri", "tag2"))
- >>> serialize(ET, elem) # 1.4
- '<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>'
-
- 2) decorated attributes
-
- >>> elem.clear()
- >>> elem.attrib["{uri}key"] = "value"
- >>> serialize(ET, elem) # 2.1
- '<ns0:tag ns0:key="value" xmlns:ns0="uri" />'
-
- >>> elem.clear()
- >>> elem.attrib[ET.QName("{uri}key")] = "value"
- >>> serialize(ET, elem) # 2.2
- '<ns0:tag ns0:key="value" xmlns:ns0="uri" />'
+ >>> serialize(ET.XML("<tag>hello</tag>"))
+ '<tag>hello</tag>'
+ >>> serialize(ET.XML("<tag>&#104;&#101;&#108;&#108;&#111;</tag>"))
+ '<tag>hello</tag>'
+ >>> serialize(ET.XML("<tag><![CDATA[hello]]></tag>"))
+ '<tag>hello</tag>'
+ """
- 3) decorated values are not converted by default, but the
- QName wrapper can be used for values
+# Only with Python implementation
+def simplefind():
+ """
+ Test find methods using the elementpath fallback.
- >>> elem.clear()
- >>> elem.attrib["{uri}key"] = "{uri}value"
- >>> serialize(ET, elem) # 3.1
- '<ns0:tag ns0:key="{uri}value" xmlns:ns0="uri" />'
+ >>> from xml.etree import ElementTree
- >>> elem.clear()
- >>> elem.attrib["{uri}key"] = ET.QName("{uri}value")
- >>> serialize(ET, elem) # 3.2
- '<ns0:tag ns0:key="ns0:value" xmlns:ns0="uri" />'
+ >>> CurrentElementPath = ElementTree.ElementPath
+ >>> ElementTree.ElementPath = ElementTree._SimpleElementPath()
+ >>> elem = ElementTree.XML(SAMPLE_XML)
+ >>> elem.find("tag").tag
+ 'tag'
+ >>> ElementTree.ElementTree(elem).find("tag").tag
+ 'tag'
+ >>> elem.findtext("tag")
+ 'text'
+ >>> elem.findtext("tog")
+ >>> elem.findtext("tog", "default")
+ 'default'
+ >>> ElementTree.ElementTree(elem).findtext("tag")
+ 'text'
+ >>> summarize_list(elem.findall("tag"))
+ ['tag', 'tag']
+ >>> summarize_list(elem.findall(".//tag"))
+ ['tag', 'tag', 'tag']
- >>> elem.clear()
- >>> subelem = ET.Element("tag")
- >>> subelem.attrib["{uri1}key"] = ET.QName("{uri2}value")
- >>> elem.append(subelem)
- >>> elem.append(subelem)
- >>> serialize(ET, elem) # 3.3
- '<ns0:tag xmlns:ns0="uri"><tag ns1:key="ns2:value" xmlns:ns1="uri1" xmlns:ns2="uri2" /><tag ns1:key="ns2:value" xmlns:ns1="uri1" xmlns:ns2="uri2" /></ns0:tag>'
+ Path syntax doesn't work in this case.
- 4) Direct QName tests
+ >>> elem.find("section/tag")
+ >>> elem.findtext("section/tag")
+ >>> summarize_list(elem.findall("section/tag"))
+ []
- >>> str(ET.QName('ns', 'tag'))
- '{ns}tag'
- >>> str(ET.QName('{ns}tag'))
- '{ns}tag'
- >>> q1 = ET.QName('ns', 'tag')
- >>> q2 = ET.QName('ns', 'tag')
- >>> q1 == q2
- True
- >>> q2 = ET.QName('ns', 'other-tag')
- >>> q1 == q2
- False
- >>> q1 == 'ns:tag'
- False
- >>> q1 == '{ns}tag'
- True
+ >>> ElementTree.ElementPath = CurrentElementPath
"""
def find():
"""
Test find methods (including xpath syntax).
- >>> from xml.etree import ElementTree as ET
-
>>> elem = ET.XML(SAMPLE_XML)
>>> elem.find("tag").tag
'tag'
@@ -189,39 +317,67 @@ def find():
'tag'
>>> elem.find("section/tag").tag
'tag'
+ >>> elem.find("./tag").tag
+ 'tag'
+ >>> ET.ElementTree(elem).find("./tag").tag
+ 'tag'
+ >>> ET.ElementTree(elem).find("/tag").tag
+ 'tag'
+ >>> elem[2] = ET.XML(SAMPLE_SECTION)
+ >>> elem.find("section/nexttag").tag
+ 'nexttag'
>>> ET.ElementTree(elem).find("section/tag").tag
'tag'
+ >>> ET.ElementTree(elem).find("tog")
+ >>> ET.ElementTree(elem).find("tog/foo")
>>> elem.findtext("tag")
'text'
+ >>> elem.findtext("section/nexttag")
+ ''
+ >>> elem.findtext("section/nexttag", "default")
+ ''
>>> elem.findtext("tog")
>>> elem.findtext("tog", "default")
'default'
>>> ET.ElementTree(elem).findtext("tag")
'text'
+ >>> ET.ElementTree(elem).findtext("tog/foo")
+ >>> ET.ElementTree(elem).findtext("tog/foo", "default")
+ 'default'
+ >>> ET.ElementTree(elem).findtext("./tag")
+ 'text'
+ >>> ET.ElementTree(elem).findtext("/tag")
+ 'text'
>>> elem.findtext("section/tag")
'subtext'
>>> ET.ElementTree(elem).findtext("section/tag")
'subtext'
+ >>> summarize_list(elem.findall("."))
+ ['body']
>>> summarize_list(elem.findall("tag"))
['tag', 'tag']
+ >>> summarize_list(elem.findall("tog"))
+ []
+ >>> summarize_list(elem.findall("tog/foo"))
+ []
>>> summarize_list(elem.findall("*"))
['tag', 'tag', 'section']
>>> summarize_list(elem.findall(".//tag"))
- ['tag', 'tag', 'tag']
+ ['tag', 'tag', 'tag', 'tag']
>>> summarize_list(elem.findall("section/tag"))
['tag']
>>> summarize_list(elem.findall("section//tag"))
- ['tag']
+ ['tag', 'tag']
>>> summarize_list(elem.findall("section/*"))
- ['tag']
+ ['tag', 'nexttag', 'nextsection']
>>> summarize_list(elem.findall("section//*"))
- ['tag']
+ ['tag', 'nexttag', 'nextsection', 'tag']
>>> summarize_list(elem.findall("section/.//*"))
- ['tag']
+ ['tag', 'nexttag', 'nextsection', 'tag']
>>> summarize_list(elem.findall("*/*"))
- ['tag']
+ ['tag', 'nexttag', 'nextsection']
>>> summarize_list(elem.findall("*//*"))
- ['tag']
+ ['tag', 'nexttag', 'nextsection', 'tag']
>>> summarize_list(elem.findall("*/tag"))
['tag']
>>> summarize_list(elem.findall("*/./tag"))
@@ -229,13 +385,40 @@ def find():
>>> summarize_list(elem.findall("./tag"))
['tag', 'tag']
>>> summarize_list(elem.findall(".//tag"))
- ['tag', 'tag', 'tag']
+ ['tag', 'tag', 'tag', 'tag']
>>> summarize_list(elem.findall("././tag"))
['tag', 'tag']
- >>> summarize_list(ET.ElementTree(elem).findall("/tag"))
+ >>> summarize_list(elem.findall(".//tag[@class]"))
+ ['tag', 'tag', 'tag']
+ >>> summarize_list(elem.findall(".//tag[@class='a']"))
+ ['tag']
+ >>> summarize_list(elem.findall(".//tag[@class='b']"))
+ ['tag', 'tag']
+ >>> summarize_list(elem.findall(".//tag[@id]"))
+ ['tag']
+ >>> summarize_list(elem.findall(".//section[tag]"))
+ ['section']
+ >>> summarize_list(elem.findall(".//section[element]"))
+ []
+ >>> summarize_list(elem.findall("../tag"))
+ []
+ >>> summarize_list(elem.findall("section/../tag"))
['tag', 'tag']
>>> summarize_list(ET.ElementTree(elem).findall("./tag"))
['tag', 'tag']
+
+ Following example is invalid in 1.2.
+ A leading '*' is assumed in 1.3.
+
+ >>> elem.findall("section//") == elem.findall("section//*")
+ True
+
+ ET's Path module handles this case incorrectly; this gives
+ a warning in 1.3, and the behaviour will be modified in 1.4.
+
+ >>> summarize_list(ET.ElementTree(elem).findall("/tag"))
+ ['tag', 'tag']
+
>>> elem = ET.XML(SAMPLE_XML_NS)
>>> summarize_list(elem.findall("tag"))
[]
@@ -245,21 +428,230 @@ def find():
['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag']
"""
-def parseliteral():
- r"""
+def file_init():
+ """
+ >>> import io
- >>> from xml.etree import ElementTree as ET
+ >>> stringfile = io.BytesIO(SAMPLE_XML.encode("utf-8"))
+ >>> tree = ET.ElementTree(file=stringfile)
+ >>> tree.find("tag").tag
+ 'tag'
+ >>> tree.find("section/tag").tag
+ 'tag'
+
+ >>> tree = ET.ElementTree(file=SIMPLE_XMLFILE)
+ >>> tree.find("element").tag
+ 'element'
+ >>> tree.find("element/../empty-element").tag
+ 'empty-element'
+ """
+def bad_find():
+ """
+ Check bad or unsupported path expressions.
+
+ >>> elem = ET.XML(SAMPLE_XML)
+ >>> elem.findall("/tag")
+ Traceback (most recent call last):
+ SyntaxError: cannot use absolute path on element
+ """
+
+def path_cache():
+ """
+ Check that the path cache behaves sanely.
+
+ >>> elem = ET.XML(SAMPLE_XML)
+ >>> for i in range(10): ET.ElementTree(elem).find('./'+str(i))
+ >>> cache_len_10 = len(ET.ElementPath._cache)
+ >>> for i in range(10): ET.ElementTree(elem).find('./'+str(i))
+ >>> len(ET.ElementPath._cache) == cache_len_10
+ True
+ >>> for i in range(20): ET.ElementTree(elem).find('./'+str(i))
+ >>> len(ET.ElementPath._cache) > cache_len_10
+ True
+ >>> for i in range(600): ET.ElementTree(elem).find('./'+str(i))
+ >>> len(ET.ElementPath._cache) < 500
+ True
+ """
+
+def copy():
+ """
+ Test copy handling (etc).
+
+ >>> import copy
+ >>> e1 = ET.XML("<tag>hello<foo/></tag>")
+ >>> e2 = copy.copy(e1)
+ >>> e3 = copy.deepcopy(e1)
+ >>> e1.find("foo").tag = "bar"
+ >>> serialize(e1)
+ '<tag>hello<bar /></tag>'
+ >>> serialize(e2)
+ '<tag>hello<bar /></tag>'
+ >>> serialize(e3)
+ '<tag>hello<foo /></tag>'
+
+ """
+
+def attrib():
+ """
+ Test attribute handling.
+
+ >>> elem = ET.Element("tag")
+ >>> elem.get("key") # 1.1
+ >>> elem.get("key", "default") # 1.2
+ 'default'
+ >>> elem.set("key", "value")
+ >>> elem.get("key") # 1.3
+ 'value'
+
+ >>> elem = ET.Element("tag", key="value")
+ >>> elem.get("key") # 2.1
+ 'value'
+ >>> elem.attrib # 2.2
+ {'key': 'value'}
+
+ >>> attrib = {"key": "value"}
+ >>> elem = ET.Element("tag", attrib)
+ >>> attrib.clear() # check for aliasing issues
+ >>> elem.get("key") # 3.1
+ 'value'
+ >>> elem.attrib # 3.2
+ {'key': 'value'}
+
+ >>> attrib = {"key": "value"}
+ >>> elem = ET.Element("tag", **attrib)
+ >>> attrib.clear() # check for aliasing issues
+ >>> elem.get("key") # 4.1
+ 'value'
+ >>> elem.attrib # 4.2
+ {'key': 'value'}
+
+ >>> elem = ET.Element("tag", {"key": "other"}, key="value")
+ >>> elem.get("key") # 5.1
+ 'value'
+ >>> elem.attrib # 5.2
+ {'key': 'value'}
+
+ >>> elem = ET.Element('test')
+ >>> elem.text = "aa"
+ >>> elem.set('testa', 'testval')
+ >>> elem.set('testb', 'test2')
+ >>> ET.tostring(elem)
+ b'<test testa="testval" testb="test2">aa</test>'
+ >>> sorted(elem.keys())
+ ['testa', 'testb']
+ >>> sorted(elem.items())
+ [('testa', 'testval'), ('testb', 'test2')]
+ >>> elem.attrib['testb']
+ 'test2'
+ >>> elem.attrib['testb'] = 'test1'
+ >>> elem.attrib['testc'] = 'test2'
+ >>> ET.tostring(elem)
+ b'<test testa="testval" testb="test1" testc="test2">aa</test>'
+ """
+
+def makeelement():
+ """
+ Test makeelement handling.
+
+ >>> elem = ET.Element("tag")
+ >>> attrib = {"key": "value"}
+ >>> subelem = elem.makeelement("subtag", attrib)
+ >>> if subelem.attrib is attrib:
+ ... print("attrib aliasing")
+ >>> elem.append(subelem)
+ >>> serialize(elem)
+ '<tag><subtag key="value" /></tag>'
+
+ >>> elem.clear()
+ >>> serialize(elem)
+ '<tag />'
+ >>> elem.append(subelem)
+ >>> serialize(elem)
+ '<tag><subtag key="value" /></tag>'
+ >>> elem.extend([subelem, subelem])
+ >>> serialize(elem)
+ '<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>'
+ >>> elem[:] = [subelem]
+ >>> serialize(elem)
+ '<tag><subtag key="value" /></tag>'
+ >>> elem[:] = tuple([subelem])
+ >>> serialize(elem)
+ '<tag><subtag key="value" /></tag>'
+
+ """
+
+def parsefile():
+ """
+ Test parsing from file.
+
+ >>> tree = ET.parse(SIMPLE_XMLFILE)
+ >>> normalize_crlf(tree)
+ >>> tree.write(sys.stdout, encoding='unicode')
+ <root>
+ <element key="value">text</element>
+ <element>text</element>tail
+ <empty-element />
+ </root>
+ >>> tree = ET.parse(SIMPLE_NS_XMLFILE)
+ >>> normalize_crlf(tree)
+ >>> tree.write(sys.stdout, encoding='unicode')
+ <ns0:root xmlns:ns0="namespace">
+ <ns0:element key="value">text</ns0:element>
+ <ns0:element>text</ns0:element>tail
+ <ns0:empty-element />
+ </ns0:root>
+
+ >>> with open(SIMPLE_XMLFILE) as f:
+ ... data = f.read()
+
+ >>> parser = ET.XMLParser()
+ >>> parser.version # doctest: +ELLIPSIS
+ 'Expat ...'
+ >>> parser.feed(data)
+ >>> print(serialize(parser.close()))
+ <root>
+ <element key="value">text</element>
+ <element>text</element>tail
+ <empty-element />
+ </root>
+
+ >>> parser = ET.XMLTreeBuilder() # 1.2 compatibility
+ >>> parser.feed(data)
+ >>> print(serialize(parser.close()))
+ <root>
+ <element key="value">text</element>
+ <element>text</element>tail
+ <empty-element />
+ </root>
+
+ >>> target = ET.TreeBuilder()
+ >>> parser = ET.XMLParser(target=target)
+ >>> parser.feed(data)
+ >>> print(serialize(parser.close()))
+ <root>
+ <element key="value">text</element>
+ <element>text</element>tail
+ <empty-element />
+ </root>
+ """
+
+def parseliteral():
+ """
>>> element = ET.XML("<html><body>text</body></html>")
- >>> ET.ElementTree(element).write(sys.stdout)
+ >>> ET.ElementTree(element).write(sys.stdout, encoding='unicode')
<html><body>text</body></html>
>>> element = ET.fromstring("<html><body>text</body></html>")
- >>> ET.ElementTree(element).write(sys.stdout)
- <html><body>text</body></html>
- >>> print(ET.tostring(element))
+ >>> ET.ElementTree(element).write(sys.stdout, encoding='unicode')
<html><body>text</body></html>
- >>> print(repr(ET.tostring(element, "ascii")))
- b"<?xml version='1.0' encoding='ascii'?>\n<html><body>text</body></html>"
+ >>> sequence = ["<html><body>", "text</bo", "dy></html>"]
+ >>> element = ET.fromstringlist(sequence)
+ >>> ET.tostring(element)
+ b'<html><body>text</body></html>'
+ >>> b"".join(ET.tostringlist(element))
+ b'<html><body>text</body></html>'
+ >>> ET.tostring(element, "ascii")
+ b"<?xml version='1.0' encoding='ascii'?>\\n<html><body>text</body></html>"
>>> _, ids = ET.XMLID("<html><body>text</body></html>")
>>> len(ids)
0
@@ -270,30 +662,601 @@ def parseliteral():
'body'
"""
+def iterparse():
+ """
+ Test iterparse interface.
+
+ >>> iterparse = ET.iterparse
+
+ >>> context = iterparse(SIMPLE_XMLFILE)
+ >>> action, elem = next(context)
+ >>> print(action, elem.tag)
+ end element
+ >>> for action, elem in context:
+ ... print(action, elem.tag)
+ end element
+ end empty-element
+ end root
+ >>> context.root.tag
+ 'root'
+
+ >>> context = iterparse(SIMPLE_NS_XMLFILE)
+ >>> for action, elem in context:
+ ... print(action, elem.tag)
+ end {namespace}element
+ end {namespace}element
+ end {namespace}empty-element
+ end {namespace}root
+
+ >>> events = ()
+ >>> context = iterparse(SIMPLE_XMLFILE, events)
+ >>> for action, elem in context:
+ ... print(action, elem.tag)
+
+ >>> events = ()
+ >>> context = iterparse(SIMPLE_XMLFILE, events=events)
+ >>> for action, elem in context:
+ ... print(action, elem.tag)
+
+ >>> events = ("start", "end")
+ >>> context = iterparse(SIMPLE_XMLFILE, events)
+ >>> for action, elem in context:
+ ... print(action, elem.tag)
+ start root
+ start element
+ end element
+ start element
+ end element
+ start empty-element
+ end empty-element
+ end root
+
+ >>> events = ("start", "end", "start-ns", "end-ns")
+ >>> context = iterparse(SIMPLE_NS_XMLFILE, events)
+ >>> for action, elem in context:
+ ... if action in ("start", "end"):
+ ... print(action, elem.tag)
+ ... else:
+ ... print(action, elem)
+ start-ns ('', 'namespace')
+ start {namespace}root
+ start {namespace}element
+ end {namespace}element
+ start {namespace}element
+ end {namespace}element
+ start {namespace}empty-element
+ end {namespace}empty-element
+ end {namespace}root
+ end-ns None
+
+ >>> events = ("start", "end", "bogus")
+ >>> with open(SIMPLE_XMLFILE, "rb") as f:
+ ... iterparse(f, events)
+ Traceback (most recent call last):
+ ValueError: unknown event 'bogus'
+
+ >>> import io
-def check_encoding(ET, encoding):
+ >>> source = io.BytesIO(
+ ... b"<?xml version='1.0' encoding='iso-8859-1'?>\\n"
+ ... b"<body xmlns='http://&#233;ffbot.org/ns'\\n"
+ ... b" xmlns:cl\\xe9='http://effbot.org/ns'>text</body>\\n")
+ >>> events = ("start-ns",)
+ >>> context = iterparse(source, events)
+ >>> for action, elem in context:
+ ... print(action, elem)
+ start-ns ('', 'http://\\xe9ffbot.org/ns')
+ start-ns ('cl\\xe9', 'http://effbot.org/ns')
+
+ >>> source = io.StringIO("<document />junk")
+ >>> try:
+ ... for action, elem in iterparse(source):
+ ... print(action, elem.tag)
+ ... except ET.ParseError as v:
+ ... print(v)
+ junk after document element: line 1, column 12
"""
- >>> from xml.etree import ElementTree as ET
- >>> check_encoding(ET, "ascii")
- >>> check_encoding(ET, "us-ascii")
- >>> check_encoding(ET, "iso-8859-1")
- >>> check_encoding(ET, "iso-8859-15")
- >>> check_encoding(ET, "cp437")
- >>> check_encoding(ET, "mac-roman")
+def writefile():
+ """
+ >>> elem = ET.Element("tag")
+ >>> elem.text = "text"
+ >>> serialize(elem)
+ '<tag>text</tag>'
+ >>> ET.SubElement(elem, "subtag").text = "subtext"
+ >>> serialize(elem)
+ '<tag>text<subtag>subtext</subtag></tag>'
+
+ Test tag suppression
+ >>> elem.tag = None
+ >>> serialize(elem)
+ 'text<subtag>subtext</subtag>'
+ >>> elem.insert(0, ET.Comment("comment"))
+ >>> serialize(elem) # assumes 1.3
+ 'text<!--comment--><subtag>subtext</subtag>'
+ >>> elem[0] = ET.PI("key", "value")
+ >>> serialize(elem)
+ 'text<?key value?><subtag>subtext</subtag>'
+ """
+
+def custom_builder():
+ """
+ Test parser w. custom builder.
+
+ >>> with open(SIMPLE_XMLFILE) as f:
+ ... data = f.read()
+ >>> class Builder:
+ ... def start(self, tag, attrib):
+ ... print("start", tag)
+ ... def end(self, tag):
+ ... print("end", tag)
+ ... def data(self, text):
+ ... pass
+ >>> builder = Builder()
+ >>> parser = ET.XMLParser(target=builder)
+ >>> parser.feed(data)
+ start root
+ start element
+ end element
+ start element
+ end element
+ start empty-element
+ end empty-element
+ end root
+
+ >>> with open(SIMPLE_NS_XMLFILE) as f:
+ ... data = f.read()
+ >>> class Builder:
+ ... def start(self, tag, attrib):
+ ... print("start", tag)
+ ... def end(self, tag):
+ ... print("end", tag)
+ ... def data(self, text):
+ ... pass
+ ... def pi(self, target, data):
+ ... print("pi", target, repr(data))
+ ... def comment(self, data):
+ ... print("comment", repr(data))
+ >>> builder = Builder()
+ >>> parser = ET.XMLParser(target=builder)
+ >>> parser.feed(data)
+ pi pi 'data'
+ comment ' comment '
+ start {namespace}root
+ start {namespace}element
+ end {namespace}element
+ start {namespace}element
+ end {namespace}element
+ start {namespace}empty-element
+ end {namespace}empty-element
+ end {namespace}root
+
+ """
+
+def getchildren():
+ """
+ Test Element.getchildren()
+
+ >>> with open(SIMPLE_XMLFILE, "rb") as f:
+ ... tree = ET.parse(f)
+ >>> for elem in tree.getroot().iter():
+ ... summarize_list(elem.getchildren())
+ ['element', 'element', 'empty-element']
+ []
+ []
+ []
+ >>> for elem in tree.getiterator():
+ ... summarize_list(elem.getchildren())
+ ['element', 'element', 'empty-element']
+ []
+ []
+ []
+
+ >>> elem = ET.XML(SAMPLE_XML)
+ >>> len(elem.getchildren())
+ 3
+ >>> len(elem[2].getchildren())
+ 1
+ >>> elem[:] == elem.getchildren()
+ True
+ >>> child1 = elem[0]
+ >>> child2 = elem[2]
+ >>> del elem[1:2]
+ >>> len(elem.getchildren())
+ 2
+ >>> child1 == elem[0]
+ True
+ >>> child2 == elem[1]
+ True
+ >>> elem[0:2] = [child2, child1]
+ >>> child2 == elem[0]
+ True
+ >>> child1 == elem[1]
+ True
+ >>> child1 == elem[0]
+ False
+ >>> elem.clear()
+ >>> elem.getchildren()
+ []
+ """
+
+def writestring():
+ """
+ >>> elem = ET.XML("<html><body>text</body></html>")
+ >>> ET.tostring(elem)
+ b'<html><body>text</body></html>'
+ >>> elem = ET.fromstring("<html><body>text</body></html>")
+ >>> ET.tostring(elem)
+ b'<html><body>text</body></html>'
+ """
+
+def check_encoding(encoding):
+ """
+ >>> check_encoding("ascii")
+ >>> check_encoding("us-ascii")
+ >>> check_encoding("iso-8859-1")
+ >>> check_encoding("iso-8859-15")
+ >>> check_encoding("cp437")
+ >>> check_encoding("mac-roman")
"""
ET.XML("<?xml version='1.0' encoding='%s'?><xml />" % encoding)
-def check_issue6233():
+def encoding():
+ r"""
+ Test encoding issues.
+
+ >>> elem = ET.Element("tag")
+ >>> elem.text = "abc"
+ >>> serialize(elem)
+ '<tag>abc</tag>'
+ >>> serialize(elem, encoding="utf-8")
+ b'<tag>abc</tag>'
+ >>> serialize(elem, encoding="us-ascii")
+ b'<tag>abc</tag>'
+ >>> serialize(elem, encoding="iso-8859-1")
+ b"<?xml version='1.0' encoding='iso-8859-1'?>\n<tag>abc</tag>"
+
+ >>> elem.text = "<&\"\'>"
+ >>> serialize(elem)
+ '<tag>&lt;&amp;"\'&gt;</tag>'
+ >>> serialize(elem, encoding="utf-8")
+ b'<tag>&lt;&amp;"\'&gt;</tag>'
+ >>> serialize(elem, encoding="us-ascii") # cdata characters
+ b'<tag>&lt;&amp;"\'&gt;</tag>'
+ >>> serialize(elem, encoding="iso-8859-1")
+ b'<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag>&lt;&amp;"\'&gt;</tag>'
+
+ >>> elem.attrib["key"] = "<&\"\'>"
+ >>> elem.text = None
+ >>> serialize(elem)
+ '<tag key="&lt;&amp;&quot;\'&gt;" />'
+ >>> serialize(elem, encoding="utf-8")
+ b'<tag key="&lt;&amp;&quot;\'&gt;" />'
+ >>> serialize(elem, encoding="us-ascii")
+ b'<tag key="&lt;&amp;&quot;\'&gt;" />'
+ >>> serialize(elem, encoding="iso-8859-1")
+ b'<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag key="&lt;&amp;&quot;\'&gt;" />'
+
+ >>> elem.text = '\xe5\xf6\xf6<>'
+ >>> elem.attrib.clear()
+ >>> serialize(elem)
+ '<tag>\xe5\xf6\xf6&lt;&gt;</tag>'
+ >>> serialize(elem, encoding="utf-8")
+ b'<tag>\xc3\xa5\xc3\xb6\xc3\xb6&lt;&gt;</tag>'
+ >>> serialize(elem, encoding="us-ascii")
+ b'<tag>&#229;&#246;&#246;&lt;&gt;</tag>'
+ >>> serialize(elem, encoding="iso-8859-1")
+ b"<?xml version='1.0' encoding='iso-8859-1'?>\n<tag>\xe5\xf6\xf6&lt;&gt;</tag>"
+
+ >>> elem.attrib["key"] = '\xe5\xf6\xf6<>'
+ >>> elem.text = None
+ >>> serialize(elem)
+ '<tag key="\xe5\xf6\xf6&lt;&gt;" />'
+ >>> serialize(elem, encoding="utf-8")
+ b'<tag key="\xc3\xa5\xc3\xb6\xc3\xb6&lt;&gt;" />'
+ >>> serialize(elem, encoding="us-ascii")
+ b'<tag key="&#229;&#246;&#246;&lt;&gt;" />'
+ >>> serialize(elem, encoding="iso-8859-1")
+ b'<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag key="\xe5\xf6\xf6&lt;&gt;" />'
"""
- >>> from xml.etree import ElementTree as ET
- >>> e = ET.XML("<?xml version='1.0' encoding='utf-8'?><body>t\xe3g</body>")
- >>> ET.tostring(e, 'ascii')
- b"<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
- >>> e = ET.XML("<?xml version='1.0' encoding='iso-8859-1'?><body>t\xe3g</body>".encode('iso-8859-1')) # create byte string with the right encoding
- >>> ET.tostring(e, 'ascii')
- b"<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
+def methods():
+ r"""
+ Test serialization methods.
+
+ >>> e = ET.XML("<html><link/><script>1 &lt; 2</script></html>")
+ >>> e.tail = "\n"
+ >>> serialize(e)
+ '<html><link /><script>1 &lt; 2</script></html>\n'
+ >>> serialize(e, method=None)
+ '<html><link /><script>1 &lt; 2</script></html>\n'
+ >>> serialize(e, method="xml")
+ '<html><link /><script>1 &lt; 2</script></html>\n'
+ >>> serialize(e, method="html")
+ '<html><link><script>1 < 2</script></html>\n'
+ >>> serialize(e, method="text")
+ '1 < 2\n'
+ """
+
+def iterators():
+ """
+ Test iterators.
+
+ >>> e = ET.XML("<html><body>this is a <i>paragraph</i>.</body>..</html>")
+ >>> summarize_list(e.iter())
+ ['html', 'body', 'i']
+ >>> summarize_list(e.find("body").iter())
+ ['body', 'i']
+ >>> summarize(next(e.iter()))
+ 'html'
+ >>> "".join(e.itertext())
+ 'this is a paragraph...'
+ >>> "".join(e.find("body").itertext())
+ 'this is a paragraph.'
+ >>> next(e.itertext())
+ 'this is a '
+
+ Method iterparse should return an iterator. See bug 6472.
+
+ >>> sourcefile = serialize(e, to_string=False)
+ >>> next(ET.iterparse(sourcefile)) # doctest: +ELLIPSIS
+ ('end', <Element 'i' at 0x...>)
+
+ >>> tree = ET.ElementTree(None)
+ >>> tree.iter()
+ Traceback (most recent call last):
+ AttributeError: 'NoneType' object has no attribute 'iter'
+ """
+
+ENTITY_XML = """\
+<!DOCTYPE points [
+<!ENTITY % user-entities SYSTEM 'user-entities.xml'>
+%user-entities;
+]>
+<document>&entity;</document>
+"""
+
+def entity():
+ """
+ Test entity handling.
+
+ 1) good entities
+
+ >>> e = ET.XML("<document title='&#x8230;'>test</document>")
+ >>> serialize(e, encoding="us-ascii")
+ b'<document title="&#33328;">test</document>'
+ >>> serialize(e)
+ '<document title="\u8230">test</document>'
+
+ 2) bad entities
+
+ >>> normalize_exception(ET.XML, "<document>&entity;</document>")
+ Traceback (most recent call last):
+ ParseError: undefined entity: line 1, column 10
+
+ >>> normalize_exception(ET.XML, ENTITY_XML)
+ Traceback (most recent call last):
+ ParseError: undefined entity &entity;: line 5, column 10
+
+ 3) custom entity
+
+ >>> parser = ET.XMLParser()
+ >>> parser.entity["entity"] = "text"
+ >>> parser.feed(ENTITY_XML)
+ >>> root = parser.close()
+ >>> serialize(root)
+ '<document>text</document>'
+ """
+
+def error(xml):
+ """
+
+ Test error handling.
+
+ >>> issubclass(ET.ParseError, SyntaxError)
+ True
+ >>> error("foo").position
+ (1, 0)
+ >>> error("<tag>&foo;</tag>").position
+ (1, 5)
+ >>> error("foobar<").position
+ (1, 6)
+
+ """
+ try:
+ ET.XML(xml)
+ except ET.ParseError:
+ return sys.exc_info()[1]
+
+def namespace():
+ """
+ Test namespace issues.
+
+ 1) xml namespace
+
+ >>> elem = ET.XML("<tag xml:lang='en' />")
+ >>> serialize(elem) # 1.1
+ '<tag xml:lang="en" />'
+
+ 2) other "well-known" namespaces
+
+ >>> elem = ET.XML("<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' />")
+ >>> serialize(elem) # 2.1
+ '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />'
+
+ >>> elem = ET.XML("<html:html xmlns:html='http://www.w3.org/1999/xhtml' />")
+ >>> serialize(elem) # 2.2
+ '<html:html xmlns:html="http://www.w3.org/1999/xhtml" />'
+
+ >>> elem = ET.XML("<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope' />")
+ >>> serialize(elem) # 2.3
+ '<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope" />'
+
+ 3) unknown namespaces
+ >>> elem = ET.XML(SAMPLE_XML_NS)
+ >>> print(serialize(elem))
+ <ns0:body xmlns:ns0="http://effbot.org/ns">
+ <ns0:tag>text</ns0:tag>
+ <ns0:tag />
+ <ns0:section>
+ <ns0:tag>subtext</ns0:tag>
+ </ns0:section>
+ </ns0:body>
+ """
+
+def qname():
+ """
+ Test QName handling.
+
+ 1) decorated tags
+
+ >>> elem = ET.Element("{uri}tag")
+ >>> serialize(elem) # 1.1
+ '<ns0:tag xmlns:ns0="uri" />'
+ >>> elem = ET.Element(ET.QName("{uri}tag"))
+ >>> serialize(elem) # 1.2
+ '<ns0:tag xmlns:ns0="uri" />'
+ >>> elem = ET.Element(ET.QName("uri", "tag"))
+ >>> serialize(elem) # 1.3
+ '<ns0:tag xmlns:ns0="uri" />'
+ >>> elem = ET.Element(ET.QName("uri", "tag"))
+ >>> subelem = ET.SubElement(elem, ET.QName("uri", "tag1"))
+ >>> subelem = ET.SubElement(elem, ET.QName("uri", "tag2"))
+ >>> serialize(elem) # 1.4
+ '<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>'
+
+ 2) decorated attributes
+
+ >>> elem.clear()
+ >>> elem.attrib["{uri}key"] = "value"
+ >>> serialize(elem) # 2.1
+ '<ns0:tag xmlns:ns0="uri" ns0:key="value" />'
+
+ >>> elem.clear()
+ >>> elem.attrib[ET.QName("{uri}key")] = "value"
+ >>> serialize(elem) # 2.2
+ '<ns0:tag xmlns:ns0="uri" ns0:key="value" />'
+
+ 3) decorated values are not converted by default, but the
+ QName wrapper can be used for values
+
+ >>> elem.clear()
+ >>> elem.attrib["{uri}key"] = "{uri}value"
+ >>> serialize(elem) # 3.1
+ '<ns0:tag xmlns:ns0="uri" ns0:key="{uri}value" />'
+
+ >>> elem.clear()
+ >>> elem.attrib["{uri}key"] = ET.QName("{uri}value")
+ >>> serialize(elem) # 3.2
+ '<ns0:tag xmlns:ns0="uri" ns0:key="ns0:value" />'
+
+ >>> elem.clear()
+ >>> subelem = ET.Element("tag")
+ >>> subelem.attrib["{uri1}key"] = ET.QName("{uri2}value")
+ >>> elem.append(subelem)
+ >>> elem.append(subelem)
+ >>> serialize(elem) # 3.3
+ '<ns0:tag xmlns:ns0="uri" xmlns:ns1="uri1" xmlns:ns2="uri2"><tag ns1:key="ns2:value" /><tag ns1:key="ns2:value" /></ns0:tag>'
+
+ 4) Direct QName tests
+
+ >>> str(ET.QName('ns', 'tag'))
+ '{ns}tag'
+ >>> str(ET.QName('{ns}tag'))
+ '{ns}tag'
+ >>> q1 = ET.QName('ns', 'tag')
+ >>> q2 = ET.QName('ns', 'tag')
+ >>> q1 == q2
+ True
+ >>> q2 = ET.QName('ns', 'other-tag')
+ >>> q1 == q2
+ False
+ >>> q1 == 'ns:tag'
+ False
+ >>> q1 == '{ns}tag'
+ True
+ """
+
+def doctype_public():
+ """
+ Test PUBLIC doctype.
+
+ >>> elem = ET.XML('<!DOCTYPE html PUBLIC'
+ ... ' "-//W3C//DTD XHTML 1.0 Transitional//EN"'
+ ... ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
+ ... '<html>text</html>')
+
+ """
+
+def xpath_tokenizer(p):
+ """
+ Test the XPath tokenizer.
+
+ >>> # tests from the xml specification
+ >>> xpath_tokenizer("*")
+ ['*']
+ >>> xpath_tokenizer("text()")
+ ['text', '()']
+ >>> xpath_tokenizer("@name")
+ ['@', 'name']
+ >>> xpath_tokenizer("@*")
+ ['@', '*']
+ >>> xpath_tokenizer("para[1]")
+ ['para', '[', '1', ']']
+ >>> xpath_tokenizer("para[last()]")
+ ['para', '[', 'last', '()', ']']
+ >>> xpath_tokenizer("*/para")
+ ['*', '/', 'para']
+ >>> xpath_tokenizer("/doc/chapter[5]/section[2]")
+ ['/', 'doc', '/', 'chapter', '[', '5', ']', '/', 'section', '[', '2', ']']
+ >>> xpath_tokenizer("chapter//para")
+ ['chapter', '//', 'para']
+ >>> xpath_tokenizer("//para")
+ ['//', 'para']
+ >>> xpath_tokenizer("//olist/item")
+ ['//', 'olist', '/', 'item']
+ >>> xpath_tokenizer(".")
+ ['.']
+ >>> xpath_tokenizer(".//para")
+ ['.', '//', 'para']
+ >>> xpath_tokenizer("..")
+ ['..']
+ >>> xpath_tokenizer("../@lang")
+ ['..', '/', '@', 'lang']
+ >>> xpath_tokenizer("chapter[title]")
+ ['chapter', '[', 'title', ']']
+ >>> xpath_tokenizer("employee[@secretary and @assistant]")
+ ['employee', '[', '@', 'secretary', '', 'and', '', '@', 'assistant', ']']
+
+ >>> # additional tests
+ >>> xpath_tokenizer("{http://spam}egg")
+ ['{http://spam}egg']
+ >>> xpath_tokenizer("./spam.egg")
+ ['.', '/', 'spam.egg']
+ >>> xpath_tokenizer(".//{http://spam}egg")
+ ['.', '//', '{http://spam}egg']
+ """
+ from xml.etree import ElementPath
+ out = []
+ for op, tag in ElementPath.xpath_tokenizer(p):
+ out.append(op or tag)
+ return out
+
+def processinginstruction():
+ """
+ Test ProcessingInstruction directly
+
+ >>> ET.tostring(ET.ProcessingInstruction('test', 'instruction'))
+ b'<?test instruction?>'
+ >>> ET.tostring(ET.PI('test', 'instruction'))
+ b'<?test instruction?>'
+
+ Issue #2746
+
+ >>> ET.tostring(ET.PI('test', '<testing&>'))
+ b'<?test <testing&>?>'
+ >>> ET.tostring(ET.PI('test', '<testing&>\xe3'), 'latin1')
+ b"<?xml version='1.0' encoding='latin1'?>\\n<?test <testing&>\\xe3?>"
"""
#
@@ -328,6 +1291,14 @@ XINCLUDE["C2.xml"] = """\
XINCLUDE["count.txt"] = "324387"
+XINCLUDE["C2b.xml"] = """\
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>This document has been <em>accessed</em>
+ <xi:include href="count.txt" parse="text"/> times.</p>
+</document>
+"""
+
XINCLUDE["C3.xml"] = """\
<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
@@ -360,9 +1331,9 @@ XINCLUDE["default.xml"] = """\
<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
<p>Example.</p>
- <xi:include href="samples/simple.xml"/>
+ <xi:include href="{}"/>
</document>
-"""
+""".format(html.escape(SIMPLE_XMLFILE, True))
def xinclude_loader(href, parse="xml", encoding=None):
try:
@@ -383,7 +1354,7 @@ def xinclude():
>>> document = xinclude_loader("C1.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print(serialize(ET, document)) # C1
+ >>> print(serialize(document)) # C1
<document>
<p>120 Mz is adequate for an average home user.</p>
<disclaimer>
@@ -397,17 +1368,27 @@ def xinclude():
>>> document = xinclude_loader("C2.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print(serialize(ET, document)) # C2
+ >>> print(serialize(document)) # C2
<document>
<p>This document has been accessed
324387 times.</p>
</document>
+ Textual inclusion after sibling element (based on modified XInclude C.2)
+
+ >>> document = xinclude_loader("C2b.xml")
+ >>> ElementInclude.include(document, xinclude_loader)
+ >>> print(serialize(document)) # C2b
+ <document>
+ <p>This document has been <em>accessed</em>
+ 324387 times.</p>
+ </document>
+
Textual inclusion of XML example (XInclude C.3)
>>> document = xinclude_loader("C3.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print(serialize(ET, document)) # C3
+ >>> print(serialize(document)) # C3
<document>
<p>The following is the source of the "data.xml" resource:</p>
<example>&lt;?xml version='1.0'?&gt;
@@ -424,13 +1405,510 @@ def xinclude():
>>> ElementInclude.include(document, xinclude_loader)
Traceback (most recent call last):
IOError: resource not found
- >>> # print serialize(ET, document) # C5
+ >>> # print(serialize(document)) # C5
+ """
+
+def xinclude_default():
+ """
+ >>> from xml.etree import ElementInclude
+
+ >>> document = xinclude_loader("default.xml")
+ >>> ElementInclude.include(document)
+ >>> print(serialize(document)) # default
+ <document>
+ <p>Example.</p>
+ <root>
+ <element key="value">text</element>
+ <element>text</element>tail
+ <empty-element />
+ </root>
+ </document>
+ """
+
+#
+# badly formatted xi:include tags
+
+XINCLUDE_BAD = {}
+
+XINCLUDE_BAD["B1.xml"] = """\
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>120 Mz is adequate for an average home user.</p>
+ <xi:include href="disclaimer.xml" parse="BAD_TYPE"/>
+</document>
+"""
+
+XINCLUDE_BAD["B2.xml"] = """\
+<?xml version='1.0'?>
+<div xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:fallback></xi:fallback>
+</div>
+"""
+def xinclude_failures():
+ r"""
+ Test failure to locate included XML file.
+
+ >>> from xml.etree import ElementInclude
+
+ >>> def none_loader(href, parser, encoding=None):
+ ... return None
+
+ >>> document = ET.XML(XINCLUDE["C1.xml"])
+ >>> ElementInclude.include(document, loader=none_loader)
+ Traceback (most recent call last):
+ xml.etree.ElementInclude.FatalIncludeError: cannot load 'disclaimer.xml' as 'xml'
+
+ Test failure to locate included text file.
+
+ >>> document = ET.XML(XINCLUDE["C2.xml"])
+ >>> ElementInclude.include(document, loader=none_loader)
+ Traceback (most recent call last):
+ xml.etree.ElementInclude.FatalIncludeError: cannot load 'count.txt' as 'text'
+
+ Test bad parse type.
+
+ >>> document = ET.XML(XINCLUDE_BAD["B1.xml"])
+ >>> ElementInclude.include(document, loader=none_loader)
+ Traceback (most recent call last):
+ xml.etree.ElementInclude.FatalIncludeError: unknown parse type in xi:include tag ('BAD_TYPE')
+
+ Test xi:fallback outside xi:include.
+
+ >>> document = ET.XML(XINCLUDE_BAD["B2.xml"])
+ >>> ElementInclude.include(document, loader=none_loader)
+ Traceback (most recent call last):
+ xml.etree.ElementInclude.FatalIncludeError: xi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback')
"""
-def test_main():
+# --------------------------------------------------------------------
+# reported bugs
+
+def bug_xmltoolkit21():
+ """
+
+ marshaller gives obscure errors for non-string values
+
+ >>> elem = ET.Element(123)
+ >>> serialize(elem) # tag
+ Traceback (most recent call last):
+ TypeError: cannot serialize 123 (type int)
+ >>> elem = ET.Element("elem")
+ >>> elem.text = 123
+ >>> serialize(elem) # text
+ Traceback (most recent call last):
+ TypeError: cannot serialize 123 (type int)
+ >>> elem = ET.Element("elem")
+ >>> elem.tail = 123
+ >>> serialize(elem) # tail
+ Traceback (most recent call last):
+ TypeError: cannot serialize 123 (type int)
+ >>> elem = ET.Element("elem")
+ >>> elem.set(123, "123")
+ >>> serialize(elem) # attribute key
+ Traceback (most recent call last):
+ TypeError: cannot serialize 123 (type int)
+ >>> elem = ET.Element("elem")
+ >>> elem.set("123", 123)
+ >>> serialize(elem) # attribute value
+ Traceback (most recent call last):
+ TypeError: cannot serialize 123 (type int)
+
+ """
+
+def bug_xmltoolkit25():
+ """
+
+ typo in ElementTree.findtext
+
+ >>> elem = ET.XML(SAMPLE_XML)
+ >>> tree = ET.ElementTree(elem)
+ >>> tree.findtext("tag")
+ 'text'
+ >>> tree.findtext("section/tag")
+ 'subtext'
+
+ """
+
+def bug_xmltoolkit28():
+ """
+
+ .//tag causes exceptions
+
+ >>> tree = ET.XML("<doc><table><tbody/></table></doc>")
+ >>> summarize_list(tree.findall(".//thead"))
+ []
+ >>> summarize_list(tree.findall(".//tbody"))
+ ['tbody']
+
+ """
+
+def bug_xmltoolkitX1():
+ """
+
+ dump() doesn't flush the output buffer
+
+ >>> tree = ET.XML("<doc><table><tbody/></table></doc>")
+ >>> ET.dump(tree); print("tail")
+ <doc><table><tbody /></table></doc>
+ tail
+
+ """
+
+def bug_xmltoolkit39():
+ """
+
+ non-ascii element and attribute names doesn't work
+
+ >>> tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><t\\xe4g />")
+ >>> ET.tostring(tree, "utf-8")
+ b'<t\\xc3\\xa4g />'
+
+ >>> tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><tag \\xe4ttr='v&#228;lue' />")
+ >>> tree.attrib
+ {'\\xe4ttr': 'v\\xe4lue'}
+ >>> ET.tostring(tree, "utf-8")
+ b'<tag \\xc3\\xa4ttr="v\\xc3\\xa4lue" />'
+
+ >>> tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><t\\xe4g>text</t\\xe4g>")
+ >>> ET.tostring(tree, "utf-8")
+ b'<t\\xc3\\xa4g>text</t\\xc3\\xa4g>'
+
+ >>> tree = ET.Element("t\u00e4g")
+ >>> ET.tostring(tree, "utf-8")
+ b'<t\\xc3\\xa4g />'
+
+ >>> tree = ET.Element("tag")
+ >>> tree.set("\u00e4ttr", "v\u00e4lue")
+ >>> ET.tostring(tree, "utf-8")
+ b'<tag \\xc3\\xa4ttr="v\\xc3\\xa4lue" />'
+
+ """
+
+def bug_xmltoolkit54():
+ """
+
+ problems handling internally defined entities
+
+ >>> e = ET.XML("<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]><doc>&ldots;</doc>")
+ >>> serialize(e, encoding="us-ascii")
+ b'<doc>&#33328;</doc>'
+ >>> serialize(e)
+ '<doc>\u8230</doc>'
+
+ """
+
+def bug_xmltoolkit55():
+ """
+
+ make sure we're reporting the first error, not the last
+
+ >>> normalize_exception(ET.XML, b"<!DOCTYPE doc SYSTEM 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>")
+ Traceback (most recent call last):
+ ParseError: undefined entity &ldots;: line 1, column 36
+
+ """
+
+class ExceptionFile:
+ def read(self, x):
+ raise IOError
+
+def xmltoolkit60():
+ """
+
+ Handle crash in stream source.
+ >>> tree = ET.parse(ExceptionFile())
+ Traceback (most recent call last):
+ IOError
+
+ """
+
+XMLTOOLKIT62_DOC = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE patent-application-publication SYSTEM "pap-v15-2001-01-31.dtd" []>
+<patent-application-publication>
+<subdoc-abstract>
+<paragraph id="A-0001" lvl="0">A new cultivar of Begonia plant named &lsquo;BCT9801BEG&rsquo;.</paragraph>
+</subdoc-abstract>
+</patent-application-publication>"""
+
+
+def xmltoolkit62():
+ """
+
+ Don't crash when using custom entities.
+
+ >>> xmltoolkit62()
+ 'A new cultivar of Begonia plant named \u2018BCT9801BEG\u2019.'
+
+ """
+ ENTITIES = {'rsquo': '\u2019', 'lsquo': '\u2018'}
+ parser = ET.XMLTreeBuilder()
+ parser.entity.update(ENTITIES)
+ parser.feed(XMLTOOLKIT62_DOC)
+ t = parser.close()
+ return t.find('.//paragraph').text
+
+def xmltoolkit63():
+ """
+
+ Check reference leak.
+ >>> xmltoolkit63()
+ >>> count = sys.getrefcount(None)
+ >>> for i in range(1000):
+ ... xmltoolkit63()
+ >>> sys.getrefcount(None) - count
+ 0
+
+ """
+ tree = ET.TreeBuilder()
+ tree.start("tag", {})
+ tree.data("text")
+ tree.end("tag")
+
+# --------------------------------------------------------------------
+
+
+def bug_200708_newline():
+ r"""
+
+ Preserve newlines in attributes.
+
+ >>> e = ET.Element('SomeTag', text="def _f():\n return 3\n")
+ >>> ET.tostring(e)
+ b'<SomeTag text="def _f():&#10; return 3&#10;" />'
+ >>> ET.XML(ET.tostring(e)).get("text")
+ 'def _f():\n return 3\n'
+ >>> ET.tostring(ET.XML(ET.tostring(e)))
+ b'<SomeTag text="def _f():&#10; return 3&#10;" />'
+
+ """
+
+def bug_200708_close():
+ """
+
+ Test default builder.
+ >>> parser = ET.XMLParser() # default
+ >>> parser.feed("<element>some text</element>")
+ >>> summarize(parser.close())
+ 'element'
+
+ Test custom builder.
+ >>> class EchoTarget:
+ ... def close(self):
+ ... return ET.Element("element") # simulate root
+ >>> parser = ET.XMLParser(EchoTarget())
+ >>> parser.feed("<element>some text</element>")
+ >>> summarize(parser.close())
+ 'element'
+
+ """
+
+def bug_200709_default_namespace():
+ """
+
+ >>> e = ET.Element("{default}elem")
+ >>> s = ET.SubElement(e, "{default}elem")
+ >>> serialize(e, default_namespace="default") # 1
+ '<elem xmlns="default"><elem /></elem>'
+
+ >>> e = ET.Element("{default}elem")
+ >>> s = ET.SubElement(e, "{default}elem")
+ >>> s = ET.SubElement(e, "{not-default}elem")
+ >>> serialize(e, default_namespace="default") # 2
+ '<elem xmlns="default" xmlns:ns1="not-default"><elem /><ns1:elem /></elem>'
+
+ >>> e = ET.Element("{default}elem")
+ >>> s = ET.SubElement(e, "{default}elem")
+ >>> s = ET.SubElement(e, "elem") # unprefixed name
+ >>> serialize(e, default_namespace="default") # 3
+ Traceback (most recent call last):
+ ValueError: cannot use non-qualified names with default_namespace option
+
+ """
+
+def bug_200709_register_namespace():
+ """
+
+ >>> ET.tostring(ET.Element("{http://namespace.invalid/does/not/exist/}title"))
+ b'<ns0:title xmlns:ns0="http://namespace.invalid/does/not/exist/" />'
+ >>> ET.register_namespace("foo", "http://namespace.invalid/does/not/exist/")
+ >>> ET.tostring(ET.Element("{http://namespace.invalid/does/not/exist/}title"))
+ b'<foo:title xmlns:foo="http://namespace.invalid/does/not/exist/" />'
+
+ And the Dublin Core namespace is in the default list:
+
+ >>> ET.tostring(ET.Element("{http://purl.org/dc/elements/1.1/}title"))
+ b'<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/" />'
+
+ """
+
+def bug_200709_element_comment():
+ """
+
+ Not sure if this can be fixed, really (since the serializer needs
+ ET.Comment, not cET.comment).
+
+ >>> a = ET.Element('a')
+ >>> a.append(ET.Comment('foo'))
+ >>> a[0].tag == ET.Comment
+ True
+
+ >>> a = ET.Element('a')
+ >>> a.append(ET.PI('foo'))
+ >>> a[0].tag == ET.PI
+ True
+
+ """
+
+def bug_200709_element_insert():
+ """
+
+ >>> a = ET.Element('a')
+ >>> b = ET.SubElement(a, 'b')
+ >>> c = ET.SubElement(a, 'c')
+ >>> d = ET.Element('d')
+ >>> a.insert(0, d)
+ >>> summarize_list(a)
+ ['d', 'b', 'c']
+ >>> a.insert(-1, d)
+ >>> summarize_list(a)
+ ['d', 'b', 'd', 'c']
+
+ """
+
+def bug_200709_iter_comment():
+ """
+
+ >>> a = ET.Element('a')
+ >>> b = ET.SubElement(a, 'b')
+ >>> comment_b = ET.Comment("TEST-b")
+ >>> b.append(comment_b)
+ >>> summarize_list(a.iter(ET.Comment))
+ ['<Comment>']
+
+ """
+
+# --------------------------------------------------------------------
+# reported on bugs.python.org
+
+def bug_1534630():
+ """
+
+ >>> bob = ET.TreeBuilder()
+ >>> e = bob.data("data")
+ >>> e = bob.start("tag", {})
+ >>> e = bob.end("tag")
+ >>> e = bob.close()
+ >>> serialize(e)
+ '<tag />'
+
+ """
+
+def check_issue6233():
+ """
+
+ >>> e = ET.XML(b"<?xml version='1.0' encoding='utf-8'?><body>t\\xc3\\xa3g</body>")
+ >>> ET.tostring(e, 'ascii')
+ b"<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
+ >>> e = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><body>t\\xe3g</body>")
+ >>> ET.tostring(e, 'ascii')
+ b"<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
+
+ """
+
+def check_issue3151():
+ """
+
+ >>> e = ET.XML('<prefix:localname xmlns:prefix="${stuff}"/>')
+ >>> e.tag
+ '{${stuff}}localname'
+ >>> t = ET.ElementTree(e)
+ >>> ET.tostring(e)
+ b'<ns0:localname xmlns:ns0="${stuff}" />'
+
+ """
+
+def check_issue6565():
+ """
+
+ >>> elem = ET.XML("<body><tag/></body>")
+ >>> summarize_list(elem)
+ ['tag']
+ >>> newelem = ET.XML(SAMPLE_XML)
+ >>> elem[:] = newelem[:]
+ >>> summarize_list(elem)
+ ['tag', 'tag', 'section']
+
+ """
+
+def check_issue10777():
+ """
+ Registering a namespace twice caused a "dictionary changed size during
+ iteration" bug.
+
+ >>> ET.register_namespace('test10777', 'http://myuri/')
+ >>> ET.register_namespace('test10777', 'http://myuri/')
+ """
+
+# --------------------------------------------------------------------
+
+
+class CleanContext(object):
+ """Provide default namespace mapping and path cache."""
+ checkwarnings = None
+
+ def __init__(self, quiet=False):
+ if sys.flags.optimize >= 2:
+ # under -OO, doctests cannot be run and therefore not all warnings
+ # will be emitted
+ quiet = True
+ deprecations = (
+ # Search behaviour is broken if search path starts with "/".
+ ("This search is broken in 1.3 and earlier, and will be fixed "
+ "in a future version. If you rely on the current behaviour, "
+ "change it to '.+'", FutureWarning),
+ # Element.getchildren() and Element.getiterator() are deprecated.
+ ("This method will be removed in future versions. "
+ "Use .+ instead.", DeprecationWarning),
+ ("This method will be removed in future versions. "
+ "Use .+ instead.", PendingDeprecationWarning),
+ # XMLParser.doctype() is deprecated.
+ ("This method of XMLParser is deprecated. Define doctype.. "
+ "method on the TreeBuilder target.", DeprecationWarning))
+ self.checkwarnings = support.check_warnings(*deprecations, quiet=quiet)
+
+ def __enter__(self):
+ from xml.etree import ElementTree
+ self._nsmap = ElementTree._namespace_map
+ self._path_cache = ElementTree.ElementPath._cache
+ # Copy the default namespace mapping
+ ElementTree._namespace_map = self._nsmap.copy()
+ # Copy the path cache (should be empty)
+ ElementTree.ElementPath._cache = self._path_cache.copy()
+ self.checkwarnings.__enter__()
+
+ def __exit__(self, *args):
+ from xml.etree import ElementTree
+ # Restore mapping and path cache
+ ElementTree._namespace_map = self._nsmap
+ ElementTree.ElementPath._cache = self._path_cache
+ self.checkwarnings.__exit__(*args)
+
+
+def test_main(module_name='xml.etree.ElementTree'):
from test import test_xml_etree
- support.run_doctest(test_xml_etree, verbosity=True)
+
+ use_py_module = (module_name == 'xml.etree.ElementTree')
+
+ # The same doctests are used for both the Python and the C implementations
+ assert test_xml_etree.ET.__name__ == module_name
+
+ # XXX the C module should give the same warnings as the Python module
+ with CleanContext(quiet=not use_py_module):
+ support.run_doctest(test_xml_etree, verbosity=True)
+
+ # The module should not be changed by the tests
+ assert test_xml_etree.ET.__name__ == module_name
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index 71973ed234..db69e5f2c5 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -1,220 +1,73 @@
# xml.etree test for cElementTree
-import doctest
-import sys
-
from test import support
+from test.support import precisionbigmemtest, _2G
+import unittest
+
+cET = support.import_module('xml.etree.cElementTree')
+
-ET = support.import_module('xml.etree.cElementTree')
-
-SAMPLE_XML = """
-<body>
- <tag>text</tag>
- <tag />
- <section>
- <tag>subtext</tag>
- </section>
-</body>
-"""
-
-SAMPLE_XML_NS = """
-<body xmlns="http://effbot.org/ns">
- <tag>text</tag>
- <tag />
- <section>
- <tag>subtext</tag>
- </section>
-</body>
-"""
+# cElementTree specific tests
def sanity():
- """
+ r"""
Import sanity.
>>> from xml.etree import cElementTree
- """
-def check_method(method):
- if not hasattr(method, '__call__'):
- print(method, "not callable")
+ Issue #6697.
-def serialize(ET, elem):
- import io
- file = io.StringIO()
- tree = ET.ElementTree(elem)
- tree.write(file)
- return file.getvalue()
-
-def summarize(elem):
- return elem.tag
-
-def summarize_list(seq):
- return list(map(summarize, seq))
-
-def interface():
- """
- Test element tree interface.
-
- >>> element = ET.Element("tag", key="value")
- >>> tree = ET.ElementTree(element)
-
- Make sure all standard element methods exist.
-
- >>> check_method(element.append)
- >>> check_method(element.insert)
- >>> check_method(element.remove)
- >>> check_method(element.getchildren)
- >>> check_method(element.find)
- >>> check_method(element.findall)
- >>> check_method(element.findtext)
- >>> check_method(element.clear)
- >>> check_method(element.get)
- >>> check_method(element.set)
- >>> check_method(element.keys)
- >>> check_method(element.items)
- >>> check_method(element.getiterator)
-
- Basic method sanity checks.
-
- >>> serialize(ET, element) # 1
- '<tag key="value" />'
- >>> subelement = ET.Element("subtag")
- >>> element.append(subelement)
- >>> serialize(ET, element) # 2
- '<tag key="value"><subtag /></tag>'
- >>> element.insert(0, subelement)
- >>> serialize(ET, element) # 3
- '<tag key="value"><subtag /><subtag /></tag>'
- >>> element.remove(subelement)
- >>> serialize(ET, element) # 4
- '<tag key="value"><subtag /></tag>'
- >>> element.remove(subelement)
- >>> serialize(ET, element) # 5
- '<tag key="value" />'
- >>> element.remove(subelement)
+ >>> e = cElementTree.Element('a')
+ >>> getattr(e, '\uD800') # doctest: +ELLIPSIS
Traceback (most recent call last):
- ValueError: list.remove(x): x not in list
- >>> serialize(ET, element) # 6
- '<tag key="value" />'
- """
+ ...
+ UnicodeEncodeError: ...
-def find():
- """
- Test find methods (including xpath syntax).
-
- >>> elem = ET.XML(SAMPLE_XML)
- >>> elem.find("tag").tag
- 'tag'
- >>> ET.ElementTree(elem).find("tag").tag
- 'tag'
- >>> elem.find("section/tag").tag
- 'tag'
- >>> ET.ElementTree(elem).find("section/tag").tag
- 'tag'
- >>> elem.findtext("tag")
- 'text'
- >>> elem.findtext("tog")
- >>> elem.findtext("tog", "default")
- 'default'
- >>> ET.ElementTree(elem).findtext("tag")
- 'text'
- >>> elem.findtext("section/tag")
- 'subtext'
- >>> ET.ElementTree(elem).findtext("section/tag")
- 'subtext'
- >>> summarize_list(elem.findall("tag"))
- ['tag', 'tag']
- >>> summarize_list(elem.findall("*"))
- ['tag', 'tag', 'section']
- >>> summarize_list(elem.findall(".//tag"))
- ['tag', 'tag', 'tag']
- >>> summarize_list(elem.findall("section/tag"))
- ['tag']
- >>> summarize_list(elem.findall("section//tag"))
- ['tag']
- >>> summarize_list(elem.findall("section/*"))
- ['tag']
- >>> summarize_list(elem.findall("section//*"))
- ['tag']
- >>> summarize_list(elem.findall("section/.//*"))
- ['tag']
- >>> summarize_list(elem.findall("*/*"))
- ['tag']
- >>> summarize_list(elem.findall("*//*"))
- ['tag']
- >>> summarize_list(elem.findall("*/tag"))
- ['tag']
- >>> summarize_list(elem.findall("*/./tag"))
- ['tag']
- >>> summarize_list(elem.findall("./tag"))
- ['tag', 'tag']
- >>> summarize_list(elem.findall(".//tag"))
- ['tag', 'tag', 'tag']
- >>> summarize_list(elem.findall("././tag"))
- ['tag', 'tag']
- >>> summarize_list(ET.ElementTree(elem).findall("/tag"))
- ['tag', 'tag']
- >>> summarize_list(ET.ElementTree(elem).findall("./tag"))
- ['tag', 'tag']
- >>> elem = ET.XML(SAMPLE_XML_NS)
- >>> summarize_list(elem.findall("tag"))
- []
- >>> summarize_list(elem.findall("{http://effbot.org/ns}tag"))
- ['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag']
- >>> summarize_list(elem.findall(".//{http://effbot.org/ns}tag"))
- ['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag']
+ >>> p = cElementTree.XMLParser()
+ >>> p.version.split()[0]
+ 'Expat'
+ >>> getattr(p, '\uD800')
+ Traceback (most recent call last):
+ ...
+ AttributeError: 'XMLParser' object has no attribute '\ud800'
"""
-def parseliteral():
- r"""
- >>> element = ET.XML("<html><body>text</body></html>")
- >>> ET.ElementTree(element).write(sys.stdout)
- <html><body>text</body></html>
- >>> element = ET.fromstring("<html><body>text</body></html>")
- >>> ET.ElementTree(element).write(sys.stdout)
- <html><body>text</body></html>
- >>> print(ET.tostring(element))
- <html><body>text</body></html>
- >>> print(repr(ET.tostring(element, "ascii")))
- b"<?xml version='1.0' encoding='ascii'?>\n<html><body>text</body></html>"
- >>> _, ids = ET.XMLID("<html><body>text</body></html>")
- >>> len(ids)
- 0
- >>> _, ids = ET.XMLID("<html><body id='body'>text</body></html>")
- >>> len(ids)
- 1
- >>> ids["body"].tag
- 'body'
- """
+class MiscTests(unittest.TestCase):
+ # Issue #8651.
+ @support.precisionbigmemtest(size=support._2G + 100, memuse=1)
+ def test_length_overflow(self, size):
+ if size < support._2G + 100:
+ self.skipTest("not enough free memory, need at least 2 GB")
+ data = b'x' * size
+ parser = cET.XMLParser()
+ try:
+ self.assertRaises(OverflowError, parser.feed, data)
+ finally:
+ data = None
-def check_encoding(encoding):
- """
- >>> check_encoding("ascii")
- >>> check_encoding("us-ascii")
- >>> check_encoding("iso-8859-1")
- >>> check_encoding("iso-8859-15")
- >>> check_encoding("cp437")
- >>> check_encoding("mac-roman")
- """
- ET.XML(
- "<?xml version='1.0' encoding='%s'?><xml />" % encoding
- )
-
-def bug_1534630():
- """
- >>> bob = ET.TreeBuilder()
- >>> e = bob.data("data")
- >>> e = bob.start("tag", {})
- >>> e = bob.end("tag")
- >>> e = bob.close()
- >>> serialize(ET, e)
- '<tag />'
- """
def test_main():
- from test import test_xml_etree_c
+ from test import test_xml_etree, test_xml_etree_c
+
+ # Run the tests specific to the C implementation
support.run_doctest(test_xml_etree_c, verbosity=True)
+ support.run_unittest(MiscTests)
+
+ # Assign the C implementation before running the doctests
+ # Patch the __name__, to prevent confusion with the pure Python test
+ pyET = test_xml_etree.ET
+ py__name__ = test_xml_etree.__name__
+ test_xml_etree.ET = cET
+ if __name__ != '__main__':
+ test_xml_etree.__name__ = __name__
+ try:
+ # Run the same test suite as xml.etree.ElementTree
+ test_xml_etree.test_main(module_name='xml.etree.cElementTree')
+ finally:
+ test_xml_etree.ET = pyET
+ test_xml_etree.__name__ = py__name__
+
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 9833f2674f..102f892d47 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -5,13 +5,19 @@ import time
import unittest
import xmlrpc.client as xmlrpclib
import xmlrpc.server
-import threading
import http.client
import socket
import os
import re
+import io
+import contextlib
from test import support
+try:
+ import threading
+except ImportError:
+ threading = None
+
alist = [{'astring': 'foo@bar.baz.spam',
'afloat': 7283.43,
'anint': 2**20,
@@ -73,11 +79,11 @@ class XMLRPCTestCase(unittest.TestCase):
d = xmlrpclib.DateTime()
((new_d,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((d,),
methodresponse=True))
- self.assertTrue(isinstance(new_d.value, str))
+ self.assertIsInstance(new_d.value, str)
# Check that the output of dumps() is still an 8-bit string
s = xmlrpclib.dumps((new_d,), methodresponse=True)
- self.assertTrue(isinstance(s, str))
+ self.assertIsInstance(s, str)
def test_newstyle_class(self):
class T(object):
@@ -259,7 +265,7 @@ ADDR = PORT = URL = None
# The evt is set twice. First when the server is ready to serve.
# Second when the server has been shutdown. The user must clear
# the event after it has been set the first time to catch the second set.
-def http_server(evt, numrequests):
+def http_server(evt, numrequests, requestHandler=None):
class TestInstanceClass:
def div(self, x, y):
return x // y
@@ -280,7 +286,9 @@ def http_server(evt, numrequests):
s.setblocking(True)
return s, port
- serv = MyXMLRPCServer(("localhost", 0),
+ if not requestHandler:
+ requestHandler = xmlrpc.server.SimpleXMLRPCRequestHandler
+ serv = MyXMLRPCServer(("localhost", 0), requestHandler,
logRequests=False, bind_and_activate=False)
try:
serv.server_bind()
@@ -312,6 +320,66 @@ def http_server(evt, numrequests):
PORT = None
evt.set()
+def http_multi_server(evt, numrequests, requestHandler=None):
+ class TestInstanceClass:
+ def div(self, x, y):
+ return x // y
+
+ def _methodHelp(self, name):
+ if name == 'div':
+ return 'This is the div function'
+
+ def my_function():
+ '''This is my function'''
+ return True
+
+ class MyXMLRPCServer(xmlrpc.server.MultiPathXMLRPCServer):
+ def get_request(self):
+ # Ensure the socket is always non-blocking. On Linux, socket
+ # attributes are not inherited like they are on *BSD and Windows.
+ s, port = self.socket.accept()
+ s.setblocking(True)
+ return s, port
+
+ if not requestHandler:
+ requestHandler = xmlrpc.server.SimpleXMLRPCRequestHandler
+ class MyRequestHandler(requestHandler):
+ rpc_paths = []
+
+ serv = MyXMLRPCServer(("localhost", 0), MyRequestHandler,
+ logRequests=False, bind_and_activate=False)
+ serv.socket.settimeout(3)
+ serv.server_bind()
+ try:
+ global ADDR, PORT, URL
+ ADDR, PORT = serv.socket.getsockname()
+ #connect to IP address directly. This avoids socket.create_connection()
+ #trying to connect to to "localhost" using all address families, which
+ #causes slowdown e.g. on vista which supports AF_INET6. The server listens
+ #on AF_INET only.
+ URL = "http://%s:%d"%(ADDR, PORT)
+ serv.server_activate()
+ paths = ["/foo", "/foo/bar"]
+ for path in paths:
+ d = serv.add_dispatcher(path, xmlrpc.server.SimpleXMLRPCDispatcher())
+ d.register_introspection_functions()
+ d.register_multicall_functions()
+ serv.get_dispatcher(paths[0]).register_function(pow)
+ serv.get_dispatcher(paths[1]).register_function(lambda x,y: x+y, 'add')
+ evt.set()
+
+ # handle up to 'numrequests' requests
+ while numrequests > 0:
+ serv.handle_request()
+ numrequests -= 1
+
+ except socket.timeout:
+ pass
+ finally:
+ serv.socket.close()
+ PORT = None
+ evt.set()
+
# This function prevents errors like:
# <ProtocolError for localhost:57527/RPC2: 500 Internal Server Error>
def is_unavailable_exception(e):
@@ -331,15 +399,36 @@ def is_unavailable_exception(e):
if exc_mess and 'temporarily unavailable' in exc_mess.lower():
return True
-class SimpleServerTestCase(unittest.TestCase):
+def make_request_and_skipIf(condition, reason):
+ # If we skip the test, we have to make a request because the
+ # the server created in setUp blocks expecting one to come in.
+ if not condition:
+ return lambda func: func
+ def decorator(func):
+ def make_request_and_skip(self):
+ try:
+ xmlrpclib.ServerProxy(URL).my_function()
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ if not is_unavailable_exception(e):
+ raise
+ raise unittest.SkipTest(reason)
+ return make_request_and_skip
+ return decorator
+
+@unittest.skipUnless(threading, 'Threading required for this test.')
+class BaseServerTestCase(unittest.TestCase):
+ requestHandler = None
+ request_count = 1
+ threadFunc = staticmethod(http_server)
+
def setUp(self):
# enable traceback reporting
xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True
self.evt = threading.Event()
# start server thread to handle requests
- serv_args = (self.evt, 1)
- threading.Thread(target=http_server, args=serv_args).start()
+ serv_args = (self.evt, self.request_count, self.requestHandler)
+ threading.Thread(target=self.threadFunc, args=serv_args).start()
# wait for the server to be ready
self.evt.wait()
@@ -348,6 +437,7 @@ class SimpleServerTestCase(unittest.TestCase):
def tearDown(self):
# wait on the server thread to terminate
self.evt.wait(4.0)
+ # XXX this code does not work, and in fact stop_serving doesn't exist.
if not self.evt.is_set():
self.evt.set()
stop_serving()
@@ -356,6 +446,7 @@ class SimpleServerTestCase(unittest.TestCase):
# disable traceback reporting
xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = False
+class SimpleServerTestCase(BaseServerTestCase):
def test_simple1(self):
try:
p = xmlrpclib.ServerProxy(URL)
@@ -418,6 +509,8 @@ class SimpleServerTestCase(unittest.TestCase):
# protocol error; provide additional information in test output
self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
+ @make_request_and_skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_introspection3(self):
try:
# test native doc
@@ -491,6 +584,184 @@ class SimpleServerTestCase(unittest.TestCase):
# This avoids waiting for the socket timeout.
self.test_simple1()
+class MultiPathServerTestCase(BaseServerTestCase):
+ threadFunc = staticmethod(http_multi_server)
+ request_count = 2
+ def test_path1(self):
+ p = xmlrpclib.ServerProxy(URL+"/foo")
+ self.assertEqual(p.pow(6,8), 6**8)
+ self.assertRaises(xmlrpclib.Fault, p.add, 6, 8)
+ def test_path2(self):
+ p = xmlrpclib.ServerProxy(URL+"/foo/bar")
+ self.assertEqual(p.add(6,8), 6+8)
+ self.assertRaises(xmlrpclib.Fault, p.pow, 6, 8)
+
+#A test case that verifies that a server using the HTTP/1.1 keep-alive mechanism
+#does indeed serve subsequent requests on the same connection
+class BaseKeepaliveServerTestCase(BaseServerTestCase):
+ #a request handler that supports keep-alive and logs requests into a
+ #class variable
+ class RequestHandler(xmlrpc.server.SimpleXMLRPCRequestHandler):
+ parentClass = xmlrpc.server.SimpleXMLRPCRequestHandler
+ protocol_version = 'HTTP/1.1'
+ myRequests = []
+ def handle(self):
+ self.myRequests.append([])
+ self.reqidx = len(self.myRequests)-1
+ return self.parentClass.handle(self)
+ def handle_one_request(self):
+ result = self.parentClass.handle_one_request(self)
+ self.myRequests[self.reqidx].append(self.raw_requestline)
+ return result
+
+ requestHandler = RequestHandler
+ def setUp(self):
+ #clear request log
+ self.RequestHandler.myRequests = []
+ return BaseServerTestCase.setUp(self)
+
+#A test case that verifies that a server using the HTTP/1.1 keep-alive mechanism
+#does indeed serve subsequent requests on the same connection
+class KeepaliveServerTestCase1(BaseKeepaliveServerTestCase):
+ def test_two(self):
+ p = xmlrpclib.ServerProxy(URL)
+ #do three requests.
+ self.assertEqual(p.pow(6,8), 6**8)
+ self.assertEqual(p.pow(6,8), 6**8)
+ self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
+
+ #they should have all been handled by a single request handler
+ self.assertEqual(len(self.RequestHandler.myRequests), 1)
+
+ #check that we did at least two (the third may be pending append
+ #due to thread scheduling)
+ self.assertGreaterEqual(len(self.RequestHandler.myRequests[-1]), 2)
+
+
+#test special attribute access on the serverproxy, through the __call__
+#function.
+class KeepaliveServerTestCase2(BaseKeepaliveServerTestCase):
+ #ask for two keepalive requests to be handled.
+ request_count=2
+
+ def test_close(self):
+ p = xmlrpclib.ServerProxy(URL)
+ #do some requests with close.
+ self.assertEqual(p.pow(6,8), 6**8)
+ self.assertEqual(p.pow(6,8), 6**8)
+ self.assertEqual(p.pow(6,8), 6**8)
+ p("close")() #this should trigger a new keep-alive request
+ self.assertEqual(p.pow(6,8), 6**8)
+ self.assertEqual(p.pow(6,8), 6**8)
+ self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
+
+ #they should have all been two request handlers, each having logged at least
+ #two complete requests
+ self.assertEqual(len(self.RequestHandler.myRequests), 2)
+ self.assertGreaterEqual(len(self.RequestHandler.myRequests[-1]), 2)
+ self.assertGreaterEqual(len(self.RequestHandler.myRequests[-2]), 2)
+
+
+ def test_transport(self):
+ p = xmlrpclib.ServerProxy(URL)
+ #do some requests with close.
+ self.assertEqual(p.pow(6,8), 6**8)
+ p("transport").close() #same as above, really.
+ self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
+ self.assertEqual(len(self.RequestHandler.myRequests), 2)
+
+#A test case that verifies that gzip encoding works in both directions
+#(for a request and the response)
+class GzipServerTestCase(BaseServerTestCase):
+ #a request handler that supports keep-alive and logs requests into a
+ #class variable
+ class RequestHandler(xmlrpc.server.SimpleXMLRPCRequestHandler):
+ parentClass = xmlrpc.server.SimpleXMLRPCRequestHandler
+ protocol_version = 'HTTP/1.1'
+
+ def do_POST(self):
+ #store content of last request in class
+ self.__class__.content_length = int(self.headers["content-length"])
+ return self.parentClass.do_POST(self)
+ requestHandler = RequestHandler
+
+ class Transport(xmlrpclib.Transport):
+ #custom transport, stores the response length for our perusal
+ fake_gzip = False
+ def parse_response(self, response):
+ self.response_length=int(response.getheader("content-length", 0))
+ return xmlrpclib.Transport.parse_response(self, response)
+
+ def send_content(self, connection, body):
+ if self.fake_gzip:
+ #add a lone gzip header to induce decode error remotely
+ connection.putheader("Content-Encoding", "gzip")
+ return xmlrpclib.Transport.send_content(self, connection, body)
+
+ def setUp(self):
+ BaseServerTestCase.setUp(self)
+
+ def test_gzip_request(self):
+ t = self.Transport()
+ t.encode_threshold = None
+ p = xmlrpclib.ServerProxy(URL, transport=t)
+ self.assertEqual(p.pow(6,8), 6**8)
+ a = self.RequestHandler.content_length
+ t.encode_threshold = 0 #turn on request encoding
+ self.assertEqual(p.pow(6,8), 6**8)
+ b = self.RequestHandler.content_length
+ self.assertTrue(a>b)
+ p("close")()
+
+ def test_bad_gzip_request(self):
+ t = self.Transport()
+ t.encode_threshold = None
+ t.fake_gzip = True
+ p = xmlrpclib.ServerProxy(URL, transport=t)
+ cm = self.assertRaisesRegex(xmlrpclib.ProtocolError,
+ re.compile(r"\b400\b"))
+ with cm:
+ p.pow(6, 8)
+ p("close")()
+
+ def test_gsip_response(self):
+ t = self.Transport()
+ p = xmlrpclib.ServerProxy(URL, transport=t)
+ old = self.requestHandler.encode_threshold
+ self.requestHandler.encode_threshold = None #no encoding
+ self.assertEqual(p.pow(6,8), 6**8)
+ a = t.response_length
+ self.requestHandler.encode_threshold = 0 #always encode
+ self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
+ b = t.response_length
+ self.requestHandler.encode_threshold = old
+ self.assertTrue(a>b)
+
+#Test special attributes of the ServerProxy object
+class ServerProxyTestCase(unittest.TestCase):
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+ if threading:
+ self.url = URL
+ else:
+ # Without threading, http_server() and http_multi_server() will not
+ # be executed and URL is still equal to None. 'http://' is a just
+ # enough to choose the scheme (HTTP)
+ self.url = 'http://'
+
+ def test_close(self):
+ p = xmlrpclib.ServerProxy(self.url)
+ self.assertEqual(p('close')(), None)
+
+ def test_transport(self):
+ t = xmlrpclib.Transport()
+ p = xmlrpclib.ServerProxy(self.url, transport=t)
+ self.assertEqual(p('transport'), t)
+
# This is a contrived way to make a failure occur on the server side
# in order to test the _send_traceback_header flag on the server
class FailingMessageClass(http.client.HTTPMessage):
@@ -501,6 +772,7 @@ class FailingMessageClass(http.client.HTTPMessage):
return super().get(key, failobj)
+@unittest.skipUnless(threading, 'Threading required for this test.')
class FailingServerTestCase(unittest.TestCase):
def setUp(self):
self.evt = threading.Event()
@@ -576,6 +848,21 @@ class FailingServerTestCase(unittest.TestCase):
else:
self.fail('ProtocolError not raised')
+
+@contextlib.contextmanager
+def captured_stdout(encoding='utf-8'):
+ """A variation on support.captured_stdout() which gives a text stream
+ having a `buffer` attribute.
+ """
+ import io
+ orig_stdout = sys.stdout
+ sys.stdout = io.TextIOWrapper(io.BytesIO(), encoding=encoding)
+ try:
+ yield sys.stdout
+ finally:
+ sys.stdout = orig_stdout
+
+
class CGIHandlerTestCase(unittest.TestCase):
def setUp(self):
self.cgi = xmlrpc.server.CGIXMLRPCRequestHandler()
@@ -588,54 +875,45 @@ class CGIHandlerTestCase(unittest.TestCase):
env['REQUEST_METHOD'] = 'GET'
# if the method is GET and no request_text is given, it runs handle_get
# get sysout output
- tmp = sys.stdout
- sys.stdout = open(support.TESTFN, "w")
- self.cgi.handle_request()
- sys.stdout.close()
- sys.stdout = tmp
+ with captured_stdout(encoding=self.cgi.encoding) as data_out:
+ self.cgi.handle_request()
# parse Status header
- handle = open(support.TESTFN, "r").read()
+ data_out.seek(0)
+ handle = data_out.read()
status = handle.split()[1]
message = ' '.join(handle.split()[2:4])
self.assertEqual(status, '400')
self.assertEqual(message, 'Bad Request')
- os.remove(support.TESTFN)
def test_cgi_xmlrpc_response(self):
data = """<?xml version='1.0'?>
-<methodCall>
- <methodName>test_method</methodName>
- <params>
- <param>
- <value><string>foo</string></value>
- </param>
- <param>
- <value><string>bar</string></value>
- </param>
- </params>
-</methodCall>
-"""
- open("xmldata.txt", "w").write(data)
- tmp1 = sys.stdin
- tmp2 = sys.stdout
-
- sys.stdin = open("xmldata.txt", "r")
- sys.stdout = open(support.TESTFN, "w")
-
- with support.EnvironmentVarGuard() as env:
+ <methodCall>
+ <methodName>test_method</methodName>
+ <params>
+ <param>
+ <value><string>foo</string></value>
+ </param>
+ <param>
+ <value><string>bar</string></value>
+ </param>
+ </params>
+ </methodCall>
+ """
+
+ with support.EnvironmentVarGuard() as env, \
+ captured_stdout(encoding=self.cgi.encoding) as data_out, \
+ support.captured_stdin() as data_in:
+ data_in.write(data)
+ data_in.seek(0)
env['CONTENT_LENGTH'] = str(len(data))
self.cgi.handle_request()
-
- sys.stdin.close()
- sys.stdout.close()
- sys.stdin = tmp1
- sys.stdout = tmp2
+ data_out.seek(0)
# will respond exception, if so, our goal is achieved ;)
- handle = open(support.TESTFN, "r").read()
+ handle = data_out.read()
# start with 44th char so as not to get http header, we just
# need only xml
@@ -652,14 +930,21 @@ class CGIHandlerTestCase(unittest.TestCase):
int(re.search('Content-Length: (\d+)', handle).group(1)),
len(content))
- os.remove("xmldata.txt")
- os.remove(support.TESTFN)
-
+@support.reap_threads
def test_main():
xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
BinaryTestCase, FaultTestCase]
xmlrpc_tests.append(SimpleServerTestCase)
+ xmlrpc_tests.append(KeepaliveServerTestCase1)
+ xmlrpc_tests.append(KeepaliveServerTestCase2)
+ try:
+ import gzip
+ xmlrpc_tests.append(GzipServerTestCase)
+ except ImportError:
+ pass #gzip not supported in this build
+ xmlrpc_tests.append(MultiPathServerTestCase)
+ xmlrpc_tests.append(ServerProxyTestCase)
xmlrpc_tests.append(FailingServerTestCase)
xmlrpc_tests.append(CGIHandlerTestCase)
diff --git a/Lib/test/test_xmlrpc_net.py b/Lib/test/test_xmlrpc_net.py
index b8426acb5c..5df79f0fb6 100644
--- a/Lib/test/test_xmlrpc_net.py
+++ b/Lib/test/test_xmlrpc_net.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import collections
import errno
@@ -48,7 +48,7 @@ class CurrentTimeTest(unittest.TestCase):
# Perform a minimal sanity check on the result, just to be sure
# the request means what we think it means.
- self.assertTrue(isinstance(builders, collections.Sequence), type(builders))
+ self.assertIsInstance(builders, collections.Sequence)
self.assertTrue([x for x in builders if "3.x" in x], builders)
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 34d0fbcb72..90aab8689c 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -3,23 +3,35 @@ try:
import zlib
except ImportError:
zlib = None
-import zipfile, os, unittest, sys, shutil, struct, io
+
+import io
+import os
+import sys
+import imp
+import time
+import shutil
+import struct
+import zipfile
+import unittest
+
from tempfile import TemporaryFile
from random import randint, random
+from unittest import skipUnless
-import test.support as support
-from test.support import TESTFN, run_unittest, findfile
+from test.support import TESTFN, run_unittest, findfile, unlink
TESTFN2 = TESTFN + "2"
TESTFNDIR = TESTFN + "d"
FIXEDTEST_SIZE = 1000
+DATAFILES_DIR = 'zipfile_datafiles'
SMALL_TEST_DATA = [('_ziptest1', '1q2w3e4r5t'),
('ziptest2dir/_ziptest2', 'qawsedrftg'),
('/ziptest2dir/ziptest3dir/_ziptest3', 'azsxdcfvgb'),
('ziptest2dir/ziptest3dir/ziptest4dir/_ziptest3', '6y7u8i9o0p')]
+
class TestsWithSourceFile(unittest.TestCase):
def setUp(self):
self.line_gen = (bytes("Zipfile test line %d. random float: %f" %
@@ -28,368 +40,467 @@ class TestsWithSourceFile(unittest.TestCase):
self.data = b'\n'.join(self.line_gen) + b'\n'
# Make a source file with some lines
- fp = open(TESTFN, "wb")
- fp.write(self.data)
- fp.close()
+ with open(TESTFN, "wb") as fp:
+ fp.write(self.data)
- def makeTestArchive(self, f, compression):
+ def make_test_archive(self, f, compression):
# Create the ZIP archive
- zipfp = zipfile.ZipFile(f, "w", compression)
- zipfp.write(TESTFN, "another.name")
- zipfp.write(TESTFN, TESTFN)
- zipfp.writestr("strfile", self.data)
- zipfp.close()
+ with zipfile.ZipFile(f, "w", compression) as zipfp:
+ zipfp.write(TESTFN, "another.name")
+ zipfp.write(TESTFN, TESTFN)
+ zipfp.writestr("strfile", self.data)
- def zipTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def zip_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r", compression)
- self.assertEqual(zipfp.read(TESTFN), self.data)
- self.assertEqual(zipfp.read("another.name"), self.data)
- self.assertEqual(zipfp.read("strfile"), self.data)
-
- # Print the ZIP directory
- fp = io.StringIO()
- zipfp.printdir(file=fp)
-
- directory = fp.getvalue()
- lines = directory.splitlines()
- self.assertEqual(len(lines), 4) # Number of files + header
-
- self.assertTrue('File Name' in lines[0])
- self.assertTrue('Modified' in lines[0])
- self.assertTrue('Size' in lines[0])
-
- fn, date, time, size = lines[1].split()
- self.assertEqual(fn, 'another.name')
- # XXX: timestamp is not tested
- self.assertEqual(size, str(len(self.data)))
-
- # Check the namelist
- names = zipfp.namelist()
- self.assertEqual(len(names), 3)
- self.assertTrue(TESTFN in names)
- self.assertTrue("another.name" in names)
- self.assertTrue("strfile" in names)
-
- # Check infolist
- infos = zipfp.infolist()
- names = [ i.filename for i in infos ]
- self.assertEqual(len(names), 3)
- self.assertTrue(TESTFN in names)
- self.assertTrue("another.name" in names)
- self.assertTrue("strfile" in names)
- for i in infos:
- self.assertEqual(i.file_size, len(self.data))
-
- # check getinfo
- for nm in (TESTFN, "another.name", "strfile"):
- info = zipfp.getinfo(nm)
- self.assertEqual(info.filename, nm)
- self.assertEqual(info.file_size, len(self.data))
-
- # Check that testzip doesn't raise an exception
- zipfp.testzip()
- zipfp.close()
-
- def testStored(self):
+ with zipfile.ZipFile(f, "r", compression) as zipfp:
+ self.assertEqual(zipfp.read(TESTFN), self.data)
+ self.assertEqual(zipfp.read("another.name"), self.data)
+ self.assertEqual(zipfp.read("strfile"), self.data)
+
+ # Print the ZIP directory
+ fp = io.StringIO()
+ zipfp.printdir(file=fp)
+ directory = fp.getvalue()
+ lines = directory.splitlines()
+ self.assertEqual(len(lines), 4) # Number of files + header
+
+ self.assertIn('File Name', lines[0])
+ self.assertIn('Modified', lines[0])
+ self.assertIn('Size', lines[0])
+
+ fn, date, time_, size = lines[1].split()
+ self.assertEqual(fn, 'another.name')
+ self.assertTrue(time.strptime(date, '%Y-%m-%d'))
+ self.assertTrue(time.strptime(time_, '%H:%M:%S'))
+ self.assertEqual(size, str(len(self.data)))
+
+ # Check the namelist
+ names = zipfp.namelist()
+ self.assertEqual(len(names), 3)
+ self.assertIn(TESTFN, names)
+ self.assertIn("another.name", names)
+ self.assertIn("strfile", names)
+
+ # Check infolist
+ infos = zipfp.infolist()
+ names = [i.filename for i in infos]
+ self.assertEqual(len(names), 3)
+ self.assertIn(TESTFN, names)
+ self.assertIn("another.name", names)
+ self.assertIn("strfile", names)
+ for i in infos:
+ self.assertEqual(i.file_size, len(self.data))
+
+ # check getinfo
+ for nm in (TESTFN, "another.name", "strfile"):
+ info = zipfp.getinfo(nm)
+ self.assertEqual(info.filename, nm)
+ self.assertEqual(info.file_size, len(self.data))
+
+ # Check that testzip doesn't raise an exception
+ zipfp.testzip()
+ if not isinstance(f, str):
+ f.close()
+
+ def test_stored(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipTest(f, zipfile.ZIP_STORED)
+ self.zip_test(f, zipfile.ZIP_STORED)
- def zipOpenTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def zip_open_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r", compression)
- zipdata1 = []
- zipopen1 = zipfp.open(TESTFN)
- while 1:
- read_data = zipopen1.read(256)
- if not read_data:
- break
- zipdata1.append(read_data)
-
- zipdata2 = []
- zipopen2 = zipfp.open("another.name")
- while 1:
- read_data = zipopen2.read(256)
- if not read_data:
- break
- zipdata2.append(read_data)
-
- self.assertEqual(b''.join(zipdata1), self.data)
- self.assertEqual(b''.join(zipdata2), self.data)
- zipfp.close()
-
- def testOpenStored(self):
+ with zipfile.ZipFile(f, "r", compression) as zipfp:
+ zipdata1 = []
+ with zipfp.open(TESTFN) as zipopen1:
+ while True:
+ read_data = zipopen1.read(256)
+ if not read_data:
+ break
+ zipdata1.append(read_data)
+
+ zipdata2 = []
+ with zipfp.open("another.name") as zipopen2:
+ while True:
+ read_data = zipopen2.read(256)
+ if not read_data:
+ break
+ zipdata2.append(read_data)
+
+ self.assertEqual(b''.join(zipdata1), self.data)
+ self.assertEqual(b''.join(zipdata2), self.data)
+ if not isinstance(f, str):
+ f.close()
+
+ def test_open_stored(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipOpenTest(f, zipfile.ZIP_STORED)
+ self.zip_open_test(f, zipfile.ZIP_STORED)
- def testOpenViaZipInfo(self):
+ def test_open_via_zip_info(self):
# Create the ZIP archive
- zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED)
- zipfp.writestr("name", "foo")
- zipfp.writestr("name", "bar")
- zipfp.close()
+ with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
+ zipfp.writestr("name", "foo")
+ zipfp.writestr("name", "bar")
+
+ with zipfile.ZipFile(TESTFN2, "r") as zipfp:
+ infos = zipfp.infolist()
+ data = b""
+ for info in infos:
+ with zipfp.open(info) as zipopen:
+ data += zipopen.read()
+ self.assertTrue(data == b"foobar" or data == b"barfoo")
+ data = b""
+ for info in infos:
+ data += zipfp.read(info)
+ self.assertTrue(data == b"foobar" or data == b"barfoo")
+
+ def zip_random_open_test(self, f, compression):
+ self.make_test_archive(f, compression)
- zipfp = zipfile.ZipFile(TESTFN2, "r")
- infos = zipfp.infolist()
- data = b""
- for info in infos:
- data += zipfp.open(info).read()
- self.assertTrue(data == b"foobar" or data == b"barfoo")
- data = b""
- for info in infos:
- data += zipfp.read(info)
- self.assertTrue(data == b"foobar" or data == b"barfoo")
- zipfp.close()
+ # Read the ZIP archive
+ with zipfile.ZipFile(f, "r", compression) as zipfp:
+ zipdata1 = []
+ with zipfp.open(TESTFN) as zipopen1:
+ while True:
+ read_data = zipopen1.read(randint(1, 1024))
+ if not read_data:
+ break
+ zipdata1.append(read_data)
+
+ self.assertEqual(b''.join(zipdata1), self.data)
+ if not isinstance(f, str):
+ f.close()
+
+ def test_random_open_stored(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_random_open_test(f, zipfile.ZIP_STORED)
- def zipRandomOpenTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def test_univeral_readaheads(self):
+ f = io.BytesIO()
- # Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r", compression)
- zipdata1 = []
- zipopen1 = zipfp.open(TESTFN)
- while 1:
- read_data = zipopen1.read(randint(1, 1024))
- if not read_data:
- break
- zipdata1.append(read_data)
-
- self.assertEqual(b''.join(zipdata1), self.data)
+ data = b'a\r\n' * 16 * 1024
+ zipfp = zipfile.ZipFile(f, 'w', zipfile.ZIP_STORED)
+ zipfp.writestr(TESTFN, data)
zipfp.close()
- def testRandomOpenStored(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipRandomOpenTest(f, zipfile.ZIP_STORED)
+ data2 = b''
+ zipfp = zipfile.ZipFile(f, 'r')
+ with zipfp.open(TESTFN, 'rU') as zipopen:
+ for line in zipopen:
+ data2 += line
+ zipfp.close()
+
+ self.assertEqual(data, data2.replace(b'\n', b'\r\n'))
- def zipReadlineTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def zip_readline_read_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
zipfp = zipfile.ZipFile(f, "r")
- zipopen = zipfp.open(TESTFN)
- for line in self.line_gen:
- linedata = zipopen.readline()
- self.assertEqual(linedata, line + '\n')
-
+ with zipfp.open(TESTFN) as zipopen:
+ data = b''
+ while True:
+ read = zipopen.readline()
+ if not read:
+ break
+ data += read
+
+ read = zipopen.read(100)
+ if not read:
+ break
+ data += read
+
+ self.assertEqual(data, self.data)
zipfp.close()
+ if not isinstance(f, str):
+ f.close()
- def zipReadlinesTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def zip_readline_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r")
- ziplines = zipfp.open(TESTFN).readlines()
- for line, zipline in zip(self.line_gen, ziplines):
- self.assertEqual(zipline, line + '\n')
-
- zipfp.close()
+ with zipfile.ZipFile(f, "r") as zipfp:
+ with zipfp.open(TESTFN) as zipopen:
+ for line in self.line_gen:
+ linedata = zipopen.readline()
+ self.assertEqual(linedata, line + '\n')
+ if not isinstance(f, str):
+ f.close()
- def zipIterlinesTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def zip_readlines_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r")
- for line, zipline in zip(self.line_gen, zipfp.open(TESTFN)):
- self.assertEqual(zipline, line + '\n')
+ with zipfile.ZipFile(f, "r") as zipfp:
+ with zipfp.open(TESTFN) as zipopen:
+ ziplines = zipopen.readlines()
+ for line, zipline in zip(self.line_gen, ziplines):
+ self.assertEqual(zipline, line + '\n')
+ if not isinstance(f, str):
+ f.close()
- zipfp.close()
+ def zip_iterlines_test(self, f, compression):
+ self.make_test_archive(f, compression)
- def testReadlineStored(self):
+ # Read the ZIP archive
+ with zipfile.ZipFile(f, "r") as zipfp:
+ with zipfp.open(TESTFN) as zipopen:
+ for line, zipline in zip(self.line_gen, zipopen):
+ self.assertEqual(zipline, line + '\n')
+ if not isinstance(f, str):
+ f.close()
+
+ def test_readline_read_stored(self):
+ # Issue #7610: calls to readline() interleaved with calls to read().
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipReadlineTest(f, zipfile.ZIP_STORED)
+ self.zip_readline_read_test(f, zipfile.ZIP_STORED)
- def testReadlinesStored(self):
+ def test_readline_stored(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipReadlinesTest(f, zipfile.ZIP_STORED)
+ self.zip_readline_test(f, zipfile.ZIP_STORED)
- def testIterlinesStored(self):
+ def test_readlines_stored(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipIterlinesTest(f, zipfile.ZIP_STORED)
+ self.zip_readlines_test(f, zipfile.ZIP_STORED)
- if zlib:
- def testDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipTest(f, zipfile.ZIP_DEFLATED)
+ def test_iterlines_stored(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_iterlines_test(f, zipfile.ZIP_STORED)
- def testOpenDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipOpenTest(f, zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_test(f, zipfile.ZIP_DEFLATED)
- def testRandomOpenDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipRandomOpenTest(f, zipfile.ZIP_DEFLATED)
- def testReadlineDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipReadlineTest(f, zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_open_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_open_test(f, zipfile.ZIP_DEFLATED)
- def testReadlinesDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipReadlinesTest(f, zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_random_open_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_random_open_test(f, zipfile.ZIP_DEFLATED)
- def testIterlinesDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipIterlinesTest(f, zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_readline_read_deflated(self):
+ # Issue #7610: calls to readline() interleaved with calls to read().
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_readline_read_test(f, zipfile.ZIP_DEFLATED)
- def testLowCompression(self):
- # Checks for cases where compressed data is larger than original
- # Create the ZIP archive
- zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED)
- zipfp.writestr("strfile", '12')
- zipfp.close()
+ @skipUnless(zlib, "requires zlib")
+ def test_readline_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_readline_test(f, zipfile.ZIP_DEFLATED)
- # Get an open object for strfile
- zipfp = zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_DEFLATED)
- openobj = zipfp.open("strfile")
- self.assertEqual(openobj.read(1), b'1')
- self.assertEqual(openobj.read(1), b'2')
+ @skipUnless(zlib, "requires zlib")
+ def test_readlines_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_readlines_test(f, zipfile.ZIP_DEFLATED)
- def testAbsoluteArcnames(self):
- zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED)
- zipfp.write(TESTFN, "/absolute")
- zipfp.close()
+ @skipUnless(zlib, "requires zlib")
+ def test_iterlines_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_iterlines_test(f, zipfile.ZIP_DEFLATED)
- zipfp = zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED)
- self.assertEqual(zipfp.namelist(), ["absolute"])
- zipfp.close()
+ @skipUnless(zlib, "requires zlib")
+ def test_low_compression(self):
+ """Check for cases where compressed data is larger than original."""
+ # Create the ZIP archive
+ with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED) as zipfp:
+ zipfp.writestr("strfile", '12')
- def testAppendToZipFile(self):
- # Test appending to an existing zipfile
- zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED)
- zipfp.write(TESTFN, TESTFN)
- zipfp.close()
- zipfp = zipfile.ZipFile(TESTFN2, "a", zipfile.ZIP_STORED)
- zipfp.writestr("strfile", self.data)
- self.assertEqual(zipfp.namelist(), [TESTFN, "strfile"])
- zipfp.close()
+ # Get an open object for strfile
+ with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_DEFLATED) as zipfp:
+ with zipfp.open("strfile") as openobj:
+ self.assertEqual(openobj.read(1), b'1')
+ self.assertEqual(openobj.read(1), b'2')
- def testAppendToNonZipFile(self):
- # Test appending to an existing file that is not a zipfile
- # NOTE: this test fails if len(d) < 22 because of the first
- # line "fpin.seek(-22, 2)" in _EndRecData
- d = b'I am not a ZipFile!'*10
- f = open(TESTFN2, 'wb')
- f.write(d)
- f.close()
- zipfp = zipfile.ZipFile(TESTFN2, "a", zipfile.ZIP_STORED)
- zipfp.write(TESTFN, TESTFN)
- zipfp.close()
+ def test_absolute_arcnames(self):
+ with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
+ zipfp.write(TESTFN, "/absolute")
- f = open(TESTFN2, 'rb')
- f.seek(len(d))
- zipfp = zipfile.ZipFile(f, "r")
- self.assertEqual(zipfp.namelist(), [TESTFN])
- zipfp.close()
- f.close()
-
- def test_WriteDefaultName(self):
- # Check that calling ZipFile.write without arcname specified produces the expected result
- zipfp = zipfile.ZipFile(TESTFN2, "w")
- zipfp.write(TESTFN)
- self.assertEqual(zipfp.read(TESTFN), open(TESTFN, "rb").read())
- zipfp.close()
-
- def test_PerFileCompression(self):
- # Check that files within a Zip archive can have different compression options
- zipfp = zipfile.ZipFile(TESTFN2, "w")
- zipfp.write(TESTFN, 'storeme', zipfile.ZIP_STORED)
- zipfp.write(TESTFN, 'deflateme', zipfile.ZIP_DEFLATED)
- sinfo = zipfp.getinfo('storeme')
- dinfo = zipfp.getinfo('deflateme')
- self.assertEqual(sinfo.compress_type, zipfile.ZIP_STORED)
- self.assertEqual(dinfo.compress_type, zipfile.ZIP_DEFLATED)
- zipfp.close()
+ with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED) as zipfp:
+ self.assertEqual(zipfp.namelist(), ["absolute"])
- def test_WriteToReadonly(self):
- # Check that trying to call write() on a readonly ZipFile object
- # raises a RuntimeError
- zipf = zipfile.ZipFile(TESTFN2, mode="w")
- zipf.writestr("somefile.txt", "bogus")
- zipf.close()
- zipf = zipfile.ZipFile(TESTFN2, mode="r")
- self.assertRaises(RuntimeError, zipf.write, TESTFN)
- zipf.close()
+ def test_append_to_zip_file(self):
+ """Test appending to an existing zipfile."""
+ with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
+ zipfp.write(TESTFN, TESTFN)
- def testExtract(self):
- zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED)
- for fpath, fdata in SMALL_TEST_DATA:
- zipfp.writestr(fpath, fdata)
- zipfp.close()
+ with zipfile.ZipFile(TESTFN2, "a", zipfile.ZIP_STORED) as zipfp:
+ zipfp.writestr("strfile", self.data)
+ self.assertEqual(zipfp.namelist(), [TESTFN, "strfile"])
- zipfp = zipfile.ZipFile(TESTFN2, "r")
- for fpath, fdata in SMALL_TEST_DATA:
- writtenfile = zipfp.extract(fpath)
+ def test_append_to_non_zip_file(self):
+ """Test appending to an existing file that is not a zipfile."""
+ # NOTE: this test fails if len(d) < 22 because of the first
+ # line "fpin.seek(-22, 2)" in _EndRecData
+ data = b'I am not a ZipFile!'*10
+ with open(TESTFN2, 'wb') as f:
+ f.write(data)
+
+ with zipfile.ZipFile(TESTFN2, "a", zipfile.ZIP_STORED) as zipfp:
+ zipfp.write(TESTFN, TESTFN)
+
+ with open(TESTFN2, 'rb') as f:
+ f.seek(len(data))
+ with zipfile.ZipFile(f, "r") as zipfp:
+ self.assertEqual(zipfp.namelist(), [TESTFN])
+
+ def test_write_default_name(self):
+ """Check that calling ZipFile.write without arcname specified
+ produces the expected result."""
+ with zipfile.ZipFile(TESTFN2, "w") as zipfp:
+ zipfp.write(TESTFN)
+ with open(TESTFN, "rb") as f:
+ self.assertEqual(zipfp.read(TESTFN), f.read())
+
+ @skipUnless(zlib, "requires zlib")
+ def test_per_file_compression(self):
+ """Check that files within a Zip archive can have different
+ compression options."""
+ with zipfile.ZipFile(TESTFN2, "w") as zipfp:
+ zipfp.write(TESTFN, 'storeme', zipfile.ZIP_STORED)
+ zipfp.write(TESTFN, 'deflateme', zipfile.ZIP_DEFLATED)
+ sinfo = zipfp.getinfo('storeme')
+ dinfo = zipfp.getinfo('deflateme')
+ self.assertEqual(sinfo.compress_type, zipfile.ZIP_STORED)
+ self.assertEqual(dinfo.compress_type, zipfile.ZIP_DEFLATED)
+
+ def test_write_to_readonly(self):
+ """Check that trying to call write() on a readonly ZipFile object
+ raises a RuntimeError."""
+ with zipfile.ZipFile(TESTFN2, mode="w") as zipfp:
+ zipfp.writestr("somefile.txt", "bogus")
+
+ with zipfile.ZipFile(TESTFN2, mode="r") as zipfp:
+ self.assertRaises(RuntimeError, zipfp.write, TESTFN)
+
+ def test_extract(self):
+ with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
+ for fpath, fdata in SMALL_TEST_DATA:
+ zipfp.writestr(fpath, fdata)
+
+ with zipfile.ZipFile(TESTFN2, "r") as zipfp:
+ for fpath, fdata in SMALL_TEST_DATA:
+ writtenfile = zipfp.extract(fpath)
+
+ # make sure it was written to the right place
+ if os.path.isabs(fpath):
+ correctfile = os.path.join(os.getcwd(), fpath[1:])
+ else:
+ correctfile = os.path.join(os.getcwd(), fpath)
+ correctfile = os.path.normpath(correctfile)
+
+ self.assertEqual(writtenfile, correctfile)
+
+ # make sure correct data is in correct file
+ with open(writtenfile, "rb") as f:
+ self.assertEqual(fdata.encode(), f.read())
+
+ os.remove(writtenfile)
- # make sure it was written to the right place
- if os.path.isabs(fpath):
- correctfile = os.path.join(os.getcwd(), fpath[1:])
- else:
- correctfile = os.path.join(os.getcwd(), fpath)
- correctfile = os.path.normpath(correctfile)
+ # remove the test file subdirectories
+ shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir'))
- self.assertEqual(writtenfile, correctfile)
+ def test_extract_all(self):
+ with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
+ for fpath, fdata in SMALL_TEST_DATA:
+ zipfp.writestr(fpath, fdata)
- # make sure correct data is in correct file
- self.assertEqual(fdata.encode(), open(writtenfile, "rb").read())
+ with zipfile.ZipFile(TESTFN2, "r") as zipfp:
+ zipfp.extractall()
+ for fpath, fdata in SMALL_TEST_DATA:
+ if os.path.isabs(fpath):
+ outfile = os.path.join(os.getcwd(), fpath[1:])
+ else:
+ outfile = os.path.join(os.getcwd(), fpath)
- os.remove(writtenfile)
+ with open(outfile, "rb") as f:
+ self.assertEqual(fdata.encode(), f.read())
- zipfp.close()
+ os.remove(outfile)
# remove the test file subdirectories
shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir'))
- def testExtractAll(self):
- zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED)
- for fpath, fdata in SMALL_TEST_DATA:
- zipfp.writestr(fpath, fdata)
- zipfp.close()
-
- zipfp = zipfile.ZipFile(TESTFN2, "r")
- zipfp.extractall()
- for fpath, fdata in SMALL_TEST_DATA:
- if os.path.isabs(fpath):
- outfile = os.path.join(os.getcwd(), fpath[1:])
- else:
- outfile = os.path.join(os.getcwd(), fpath)
-
- self.assertEqual(fdata.encode(), open(outfile, "rb").read())
+ def test_writestr_compression(self):
+ zipfp = zipfile.ZipFile(TESTFN2, "w")
+ zipfp.writestr("a.txt", "hello world", compress_type=zipfile.ZIP_STORED)
+ if zlib:
+ zipfp.writestr("b.txt", "hello world", compress_type=zipfile.ZIP_DEFLATED)
- os.remove(outfile)
+ info = zipfp.getinfo('a.txt')
+ self.assertEqual(info.compress_type, zipfile.ZIP_STORED)
- zipfp.close()
+ if zlib:
+ info = zipfp.getinfo('b.txt')
+ self.assertEqual(info.compress_type, zipfile.ZIP_DEFLATED)
- # remove the test file subdirectories
- shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir'))
def zip_test_writestr_permissions(self, f, compression):
# Make sure that writestr creates files with mode 0600,
# when it is passed a name rather than a ZipInfo instance.
- self.makeTestArchive(f, compression)
- zipfp = zipfile.ZipFile(f, "r")
- zinfo = zipfp.getinfo('strfile')
- self.assertEqual(zinfo.external_attr, 0o600 << 16)
+ self.make_test_archive(f, compression)
+ with zipfile.ZipFile(f, "r") as zipfp:
+ zinfo = zipfp.getinfo('strfile')
+ self.assertEqual(zinfo.external_attr, 0o600 << 16)
+ if not isinstance(f, str):
+ f.close()
def test_writestr_permissions(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_test_writestr_permissions(f, zipfile.ZIP_STORED)
def test_writestr_extended_local_header_issue1202(self):
- orig_zip = zipfile.ZipFile(TESTFN2, 'w')
- for data in 'abcdefghijklmnop':
- zinfo = zipfile.ZipInfo(data)
- zinfo.flag_bits |= 0x08 # Include an extended local header.
- orig_zip.writestr(zinfo, data)
- orig_zip.close()
+ with zipfile.ZipFile(TESTFN2, 'w') as orig_zip:
+ for data in 'abcdefghijklmnop':
+ zinfo = zipfile.ZipInfo(data)
+ zinfo.flag_bits |= 0x08 # Include an extended local header.
+ orig_zip.writestr(zinfo, data)
+
+ def test_close(self):
+ """Check that the zipfile is closed after the 'with' block."""
+ with zipfile.ZipFile(TESTFN2, "w") as zipfp:
+ for fpath, fdata in SMALL_TEST_DATA:
+ zipfp.writestr(fpath, fdata)
+ self.assertTrue(zipfp.fp is not None, 'zipfp is not open')
+ self.assertTrue(zipfp.fp is None, 'zipfp is not closed')
+
+ with zipfile.ZipFile(TESTFN2, "r") as zipfp:
+ self.assertTrue(zipfp.fp is not None, 'zipfp is not open')
+ self.assertTrue(zipfp.fp is None, 'zipfp is not closed')
+
+ def test_close_on_exception(self):
+ """Check that the zipfile is closed if an exception is raised in the
+ 'with' block."""
+ with zipfile.ZipFile(TESTFN2, "w") as zipfp:
+ for fpath, fdata in SMALL_TEST_DATA:
+ zipfp.writestr(fpath, fdata)
+
+ try:
+ with zipfile.ZipFile(TESTFN2, "r") as zipfp2:
+ raise zipfile.BadZipFile()
+ except zipfile.BadZipFile:
+ self.assertTrue(zipfp2.fp is None, 'zipfp is not closed')
+
+ @skipUnless(zlib, "requires zlib")
+ def test_unicode_filenames(self):
+ # bug #10801
+ fname = findfile('zip_cp437_header.zip')
+ with zipfile.ZipFile(fname) as zipfp:
+ for name in zipfp.namelist():
+ zipfp.open(name).close()
def tearDown(self):
- os.remove(TESTFN)
- os.remove(TESTFN2)
+ unlink(TESTFN)
+ unlink(TESTFN2)
+
class TestZip64InSmallFiles(unittest.TestCase):
# These tests test the ZIP64 functionality without using large files,
@@ -404,181 +515,200 @@ class TestZip64InSmallFiles(unittest.TestCase):
self.data = b'\n'.join(line_gen)
# Make a source file with some lines
- fp = open(TESTFN, "wb")
- fp.write(self.data)
- fp.close()
-
- def largeFileExceptionTest(self, f, compression):
- zipfp = zipfile.ZipFile(f, "w", compression)
- self.assertRaises(zipfile.LargeZipFile,
- zipfp.write, TESTFN, "another.name")
- zipfp.close()
-
- def largeFileExceptionTest2(self, f, compression):
- zipfp = zipfile.ZipFile(f, "w", compression)
- self.assertRaises(zipfile.LargeZipFile,
- zipfp.writestr, "another.name", self.data)
- zipfp.close()
-
- def testLargeFileException(self):
+ with open(TESTFN, "wb") as fp:
+ fp.write(self.data)
+
+ def large_file_exception_test(self, f, compression):
+ with zipfile.ZipFile(f, "w", compression) as zipfp:
+ self.assertRaises(zipfile.LargeZipFile,
+ zipfp.write, TESTFN, "another.name")
+
+ def large_file_exception_test2(self, f, compression):
+ with zipfile.ZipFile(f, "w", compression) as zipfp:
+ self.assertRaises(zipfile.LargeZipFile,
+ zipfp.writestr, "another.name", self.data)
+ if not isinstance(f, str):
+ f.close()
+
+ def test_large_file_exception(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.largeFileExceptionTest(f, zipfile.ZIP_STORED)
- self.largeFileExceptionTest2(f, zipfile.ZIP_STORED)
+ self.large_file_exception_test(f, zipfile.ZIP_STORED)
+ self.large_file_exception_test2(f, zipfile.ZIP_STORED)
- def zipTest(self, f, compression):
+ def zip_test(self, f, compression):
# Create the ZIP archive
- zipfp = zipfile.ZipFile(f, "w", compression, allowZip64=True)
- zipfp.write(TESTFN, "another.name")
- zipfp.write(TESTFN, TESTFN)
- zipfp.writestr("strfile", self.data)
- zipfp.close()
+ with zipfile.ZipFile(f, "w", compression, allowZip64=True) as zipfp:
+ zipfp.write(TESTFN, "another.name")
+ zipfp.write(TESTFN, TESTFN)
+ zipfp.writestr("strfile", self.data)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r", compression)
- self.assertEqual(zipfp.read(TESTFN), self.data)
- self.assertEqual(zipfp.read("another.name"), self.data)
- self.assertEqual(zipfp.read("strfile"), self.data)
-
- # Print the ZIP directory
- fp = io.StringIO()
- zipfp.printdir(fp)
-
- directory = fp.getvalue()
- lines = directory.splitlines()
- self.assertEqual(len(lines), 4) # Number of files + header
-
- self.assertTrue('File Name' in lines[0])
- self.assertTrue('Modified' in lines[0])
- self.assertTrue('Size' in lines[0])
-
- fn, date, time, size = lines[1].split()
- self.assertEqual(fn, 'another.name')
- # XXX: timestamp is not tested
- self.assertEqual(size, str(len(self.data)))
-
- # Check the namelist
- names = zipfp.namelist()
- self.assertEqual(len(names), 3)
- self.assertTrue(TESTFN in names)
- self.assertTrue("another.name" in names)
- self.assertTrue("strfile" in names)
-
- # Check infolist
- infos = zipfp.infolist()
- names = [ i.filename for i in infos ]
- self.assertEqual(len(names), 3)
- self.assertTrue(TESTFN in names)
- self.assertTrue("another.name" in names)
- self.assertTrue("strfile" in names)
- for i in infos:
- self.assertEqual(i.file_size, len(self.data))
-
- # check getinfo
- for nm in (TESTFN, "another.name", "strfile"):
- info = zipfp.getinfo(nm)
- self.assertEqual(info.filename, nm)
- self.assertEqual(info.file_size, len(self.data))
-
- # Check that testzip doesn't raise an exception
- zipfp.testzip()
-
-
- zipfp.close()
-
- def testStored(self):
+ with zipfile.ZipFile(f, "r", compression) as zipfp:
+ self.assertEqual(zipfp.read(TESTFN), self.data)
+ self.assertEqual(zipfp.read("another.name"), self.data)
+ self.assertEqual(zipfp.read("strfile"), self.data)
+
+ # Print the ZIP directory
+ fp = io.StringIO()
+ zipfp.printdir(fp)
+
+ directory = fp.getvalue()
+ lines = directory.splitlines()
+ self.assertEqual(len(lines), 4) # Number of files + header
+
+ self.assertIn('File Name', lines[0])
+ self.assertIn('Modified', lines[0])
+ self.assertIn('Size', lines[0])
+
+ fn, date, time_, size = lines[1].split()
+ self.assertEqual(fn, 'another.name')
+ self.assertTrue(time.strptime(date, '%Y-%m-%d'))
+ self.assertTrue(time.strptime(time_, '%H:%M:%S'))
+ self.assertEqual(size, str(len(self.data)))
+
+ # Check the namelist
+ names = zipfp.namelist()
+ self.assertEqual(len(names), 3)
+ self.assertIn(TESTFN, names)
+ self.assertIn("another.name", names)
+ self.assertIn("strfile", names)
+
+ # Check infolist
+ infos = zipfp.infolist()
+ names = [i.filename for i in infos]
+ self.assertEqual(len(names), 3)
+ self.assertIn(TESTFN, names)
+ self.assertIn("another.name", names)
+ self.assertIn("strfile", names)
+ for i in infos:
+ self.assertEqual(i.file_size, len(self.data))
+
+ # check getinfo
+ for nm in (TESTFN, "another.name", "strfile"):
+ info = zipfp.getinfo(nm)
+ self.assertEqual(info.filename, nm)
+ self.assertEqual(info.file_size, len(self.data))
+
+ # Check that testzip doesn't raise an exception
+ zipfp.testzip()
+ if not isinstance(f, str):
+ f.close()
+
+ def test_stored(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipTest(f, zipfile.ZIP_STORED)
+ self.zip_test(f, zipfile.ZIP_STORED)
+ @skipUnless(zlib, "requires zlib")
+ def test_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_test(f, zipfile.ZIP_DEFLATED)
- if zlib:
- def testDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipTest(f, zipfile.ZIP_DEFLATED)
+ def test_absolute_arcnames(self):
+ with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED,
+ allowZip64=True) as zipfp:
+ zipfp.write(TESTFN, "/absolute")
- def testAbsoluteArcnames(self):
- zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED, allowZip64=True)
- zipfp.write(TESTFN, "/absolute")
- zipfp.close()
-
- zipfp = zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED)
- self.assertEqual(zipfp.namelist(), ["absolute"])
- zipfp.close()
+ with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED) as zipfp:
+ self.assertEqual(zipfp.namelist(), ["absolute"])
def tearDown(self):
zipfile.ZIP64_LIMIT = self._limit
- os.remove(TESTFN)
- os.remove(TESTFN2)
-
-class PyZipFileTests(unittest.TestCase):
- def testWritePyfile(self):
- zipfp = zipfile.PyZipFile(TemporaryFile(), "w")
- fn = __file__
- if fn.endswith('.pyc') or fn.endswith('.pyo'):
- fn = fn[:-1]
-
- zipfp.writepy(fn)
-
- bn = os.path.basename(fn)
- self.assertTrue(bn not in zipfp.namelist())
- self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
- zipfp.close()
+ unlink(TESTFN)
+ unlink(TESTFN2)
- zipfp = zipfile.PyZipFile(TemporaryFile(), "w")
- fn = __file__
- if fn.endswith('.pyc') or fn.endswith('.pyo'):
- fn = fn[:-1]
+class PyZipFileTests(unittest.TestCase):
+ def test_write_pyfile(self):
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
+ fn = __file__
+ if fn.endswith('.pyc') or fn.endswith('.pyo'):
+ path_split = fn.split(os.sep)
+ if os.altsep is not None:
+ path_split.extend(fn.split(os.altsep))
+ if '__pycache__' in path_split:
+ fn = imp.source_from_cache(fn)
+ else:
+ fn = fn[:-1]
+
+ zipfp.writepy(fn)
+
+ bn = os.path.basename(fn)
+ self.assertNotIn(bn, zipfp.namelist())
+ self.assertTrue(bn + 'o' in zipfp.namelist() or
+ bn + 'c' in zipfp.namelist())
+
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
+ fn = __file__
+ if fn.endswith(('.pyc', '.pyo')):
+ fn = fn[:-1]
+
+ zipfp.writepy(fn, "testpackage")
+
+ bn = "%s/%s" % ("testpackage", os.path.basename(fn))
+ self.assertNotIn(bn, zipfp.namelist())
+ self.assertTrue(bn + 'o' in zipfp.namelist() or
+ bn + 'c' in zipfp.namelist())
+
+ def test_write_python_package(self):
+ import email
+ packagedir = os.path.dirname(email.__file__)
- zipfp.writepy(fn, "testpackage")
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
+ zipfp.writepy(packagedir)
- bn = "%s/%s"%("testpackage", os.path.basename(fn))
- self.assertTrue(bn not in zipfp.namelist())
- self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
- zipfp.close()
+ # Check for a couple of modules at different levels of the
+ # hierarchy
+ names = zipfp.namelist()
+ self.assertTrue('email/__init__.pyo' in names or
+ 'email/__init__.pyc' in names)
+ self.assertTrue('email/mime/text.pyo' in names or
+ 'email/mime/text.pyc' in names)
- def testWritePythonPackage(self):
+ def test_write_with_optimization(self):
import email
packagedir = os.path.dirname(email.__file__)
+ # use .pyc if running test in optimization mode,
+ # use .pyo if running test in debug mode
+ optlevel = 1 if __debug__ else 0
+ ext = '.pyo' if optlevel == 1 else '.pyc'
- zipfp = zipfile.PyZipFile(TemporaryFile(), "w")
- zipfp.writepy(packagedir)
+ with TemporaryFile() as t, \
+ zipfile.PyZipFile(t, "w", optimize=optlevel) as zipfp:
+ zipfp.writepy(packagedir)
- # Check for a couple of modules at different levels of the hieararchy
- names = zipfp.namelist()
- self.assertTrue('email/__init__.pyo' in names or 'email/__init__.pyc' in names)
- self.assertTrue('email/mime/text.pyo' in names or 'email/mime/text.pyc' in names)
+ names = zipfp.namelist()
+ self.assertIn('email/__init__' + ext, names)
+ self.assertIn('email/mime/text' + ext, names)
- def testWritePythonDirectory(self):
+ def test_write_python_directory(self):
os.mkdir(TESTFN2)
try:
- fp = open(os.path.join(TESTFN2, "mod1.py"), "w")
- fp.write("print(42)\n")
- fp.close()
+ with open(os.path.join(TESTFN2, "mod1.py"), "w") as fp:
+ fp.write("print(42)\n")
- fp = open(os.path.join(TESTFN2, "mod2.py"), "w")
- fp.write("print(42 * 42)\n")
- fp.close()
+ with open(os.path.join(TESTFN2, "mod2.py"), "w") as fp:
+ fp.write("print(42 * 42)\n")
- fp = open(os.path.join(TESTFN2, "mod2.txt"), "w")
- fp.write("bla bla bla\n")
- fp.close()
+ with open(os.path.join(TESTFN2, "mod2.txt"), "w") as fp:
+ fp.write("bla bla bla\n")
- zipfp = zipfile.PyZipFile(TemporaryFile(), "w")
- zipfp.writepy(TESTFN2)
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
+ zipfp.writepy(TESTFN2)
- names = zipfp.namelist()
- self.assertTrue('mod1.pyc' in names or 'mod1.pyo' in names)
- self.assertTrue('mod2.pyc' in names or 'mod2.pyo' in names)
- self.assertTrue('mod2.txt' not in names)
+ names = zipfp.namelist()
+ self.assertTrue('mod1.pyc' in names or 'mod1.pyo' in names)
+ self.assertTrue('mod2.pyc' in names or 'mod2.pyo' in names)
+ self.assertNotIn('mod2.txt', names)
finally:
shutil.rmtree(TESTFN2)
- def testWriteNonPyfile(self):
- zipfp = zipfile.PyZipFile(TemporaryFile(), "w")
- open(TESTFN, 'w').write('most definitely not a python file')
- self.assertRaises(RuntimeError, zipfp.writepy, TESTFN)
- os.remove(TESTFN)
+ def test_write_non_pyfile(self):
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
+ with open(TESTFN, 'w') as f:
+ f.write('most definitely not a python file')
+ self.assertRaises(RuntimeError, zipfp.writepy, TESTFN)
+ os.remove(TESTFN)
class OtherTests(unittest.TestCase):
@@ -603,17 +733,17 @@ class OtherTests(unittest.TestCase):
b'\x01\x003\x00\x00\x003\x00\x00\x00\x00\x00'),
}
- def testUnicodeFilenames(self):
- zf = zipfile.ZipFile(TESTFN, "w")
- zf.writestr("foo.txt", "Test for unicode filename")
- zf.writestr("\xf6.txt", "Test for unicode filename")
- zf.close()
- zf = zipfile.ZipFile(TESTFN, "r")
- self.assertEqual(zf.filelist[0].filename, "foo.txt")
- self.assertEqual(zf.filelist[1].filename, "\xf6.txt")
- zf.close()
-
- def testCreateNonExistentFileForAppend(self):
+ def test_unicode_filenames(self):
+ with zipfile.ZipFile(TESTFN, "w") as zf:
+ zf.writestr("foo.txt", "Test for unicode filename")
+ zf.writestr("\xf6.txt", "Test for unicode filename")
+ self.assertIsInstance(zf.infolist()[0].filename, str)
+
+ with zipfile.ZipFile(TESTFN, "r") as zf:
+ self.assertEqual(zf.filelist[0].filename, "foo.txt")
+ self.assertEqual(zf.filelist[1].filename, "\xf6.txt")
+
+ def test_create_non_existent_file_for_append(self):
if os.path.exists(TESTFN):
os.unlink(TESTFN)
@@ -621,42 +751,38 @@ class OtherTests(unittest.TestCase):
content = b'hello, world. this is some content.'
try:
- zf = zipfile.ZipFile(TESTFN, 'a')
- zf.writestr(filename, content)
- zf.close()
+ with zipfile.ZipFile(TESTFN, 'a') as zf:
+ zf.writestr(filename, content)
except IOError:
self.fail('Could not append data to a non-existent zip file.')
self.assertTrue(os.path.exists(TESTFN))
- zf = zipfile.ZipFile(TESTFN, 'r')
- self.assertEqual(zf.read(filename), content)
- zf.close()
+ with zipfile.ZipFile(TESTFN, 'r') as zf:
+ self.assertEqual(zf.read(filename), content)
- def testCloseErroneousFile(self):
+ def test_close_erroneous_file(self):
# This test checks that the ZipFile constructor closes the file object
- # it opens if there's an error in the file. If it doesn't, the traceback
- # holds a reference to the ZipFile object and, indirectly, the file object.
+ # it opens if there's an error in the file. If it doesn't, the
+ # traceback holds a reference to the ZipFile object and, indirectly,
+ # the file object.
# On Windows, this causes the os.unlink() call to fail because the
# underlying file is still open. This is SF bug #412214.
#
- fp = open(TESTFN, "w")
- fp.write("this is not a legal zip file\n")
- fp.close()
+ with open(TESTFN, "w") as fp:
+ fp.write("this is not a legal zip file\n")
try:
zf = zipfile.ZipFile(TESTFN)
- except zipfile.BadZipfile:
+ except zipfile.BadZipFile:
pass
- def testIsZipErroneousFile(self):
- # This test checks that the is_zipfile function correctly identifies
- # a file that is not a zip file
-
+ def test_is_zip_erroneous_file(self):
+ """Check that is_zipfile() correctly identifies non-zip files."""
# - passing a filename
with open(TESTFN, "w") as fp:
fp.write("this is not a legal zip file\n")
chk = zipfile.is_zipfile(TESTFN)
- self.assertTrue(not chk)
+ self.assertFalse(chk)
# - passing a file object
with open(TESTFN, "rb") as fp:
chk = zipfile.is_zipfile(fp)
@@ -666,36 +792,34 @@ class OtherTests(unittest.TestCase):
fp.write(b"this is not a legal zip file\n")
chk = zipfile.is_zipfile(fp)
self.assertTrue(not chk)
- fp.seek(0,0)
+ fp.seek(0, 0)
chk = zipfile.is_zipfile(fp)
self.assertTrue(not chk)
- def testIsZipValidFile(self):
- # This test checks that the is_zipfile function correctly identifies
- # a file that is a zip file
-
+ def test_is_zip_valid_file(self):
+ """Check that is_zipfile() correctly identifies zip files."""
# - passing a filename
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- zipf.writestr("foo.txt", b"O, for a Muse of Fire!")
- zipf.close()
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ zipf.writestr("foo.txt", b"O, for a Muse of Fire!")
+
chk = zipfile.is_zipfile(TESTFN)
self.assertTrue(chk)
# - passing a file object
with open(TESTFN, "rb") as fp:
chk = zipfile.is_zipfile(fp)
self.assertTrue(chk)
- fp.seek(0,0)
+ fp.seek(0, 0)
zip_contents = fp.read()
# - passing a file-like object
fp = io.BytesIO()
fp.write(zip_contents)
chk = zipfile.is_zipfile(fp)
self.assertTrue(chk)
- fp.seek(0,0)
+ fp.seek(0, 0)
chk = zipfile.is_zipfile(fp)
self.assertTrue(chk)
- def testNonExistentFileRaisesIOError(self):
+ def test_non_existent_file_raises_IOError(self):
# make sure we don't raise an AttributeError when a partially-constructed
# ZipFile instance is finalized; this tests for regression on SF tracker
# bug #403871.
@@ -712,19 +836,17 @@ class OtherTests(unittest.TestCase):
def test_empty_file_raises_BadZipFile(self):
f = open(TESTFN, 'w')
f.close()
- self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN)
+ self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN)
- f = open(TESTFN, 'w')
- f.write("short file")
- f.close()
- self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN)
+ with open(TESTFN, 'w') as fp:
+ fp.write("short file")
+ self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN)
- def testClosedZipRaisesRuntimeError(self):
- # Verify that testzip() doesn't swallow inappropriate exceptions.
+ def test_closed_zip_raises_RuntimeError(self):
+ """Verify that testzip() doesn't swallow inappropriate exceptions."""
data = io.BytesIO()
- zipf = zipfile.ZipFile(data, mode="w")
- zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- zipf.close()
+ with zipfile.ZipFile(data, mode="w") as zipf:
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
# This is correct; calling .read on a closed ZipFile should throw
# a RuntimeError, and so should calling .testzip. An earlier
@@ -734,150 +856,139 @@ class OtherTests(unittest.TestCase):
self.assertRaises(RuntimeError, zipf.open, "foo.txt")
self.assertRaises(RuntimeError, zipf.testzip)
self.assertRaises(RuntimeError, zipf.writestr, "bogus.txt", "bogus")
- open(TESTFN, 'w').write('zipfile test data')
+ with open(TESTFN, 'w') as f:
+ f.write('zipfile test data')
self.assertRaises(RuntimeError, zipf.write, TESTFN)
- def test_BadConstructorMode(self):
- # Check that bad modes passed to ZipFile constructor are caught
+ def test_bad_constructor_mode(self):
+ """Check that bad modes passed to ZipFile constructor are caught."""
self.assertRaises(RuntimeError, zipfile.ZipFile, TESTFN, "q")
- def test_BadOpenMode(self):
- # Check that bad modes passed to ZipFile.open are caught
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- zipf.close()
- zipf = zipfile.ZipFile(TESTFN, mode="r")
- # read the data to make sure the file is there
- zipf.read("foo.txt")
- self.assertRaises(RuntimeError, zipf.open, "foo.txt", "q")
- zipf.close()
+ def test_bad_open_mode(self):
+ """Check that bad modes passed to ZipFile.open are caught."""
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- def test_Read0(self):
- # Check that calling read(0) on a ZipExtFile object returns an empty
- # string and doesn't advance file pointer
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ with zipfile.ZipFile(TESTFN, mode="r") as zipf:
# read the data to make sure the file is there
- f = zipf.open("foo.txt")
- for i in range(FIXEDTEST_SIZE):
- self.assertEqual(f.read(0), b'')
-
- self.assertEqual(f.read(), b"O, for a Muse of Fire!")
- zipf.close()
-
- def test_OpenNonexistentItem(self):
- # Check that attempting to call open() for an item that doesn't
- # exist in the archive raises a RuntimeError
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- self.assertRaises(KeyError, zipf.open, "foo.txt", "r")
-
- def test_BadCompressionMode(self):
- # Check that bad compression methods passed to ZipFile.open are caught
+ zipf.read("foo.txt")
+ self.assertRaises(RuntimeError, zipf.open, "foo.txt", "q")
+
+ def test_read0(self):
+ """Check that calling read(0) on a ZipExtFile object returns an empty
+ string and doesn't advance file pointer."""
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ # read the data to make sure the file is there
+ with zipf.open("foo.txt") as f:
+ for i in range(FIXEDTEST_SIZE):
+ self.assertEqual(f.read(0), b'')
+
+ self.assertEqual(f.read(), b"O, for a Muse of Fire!")
+
+ def test_open_non_existent_item(self):
+ """Check that attempting to call open() for an item that doesn't
+ exist in the archive raises a RuntimeError."""
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ self.assertRaises(KeyError, zipf.open, "foo.txt", "r")
+
+ def test_bad_compression_mode(self):
+ """Check that bad compression methods passed to ZipFile.open are
+ caught."""
self.assertRaises(RuntimeError, zipfile.ZipFile, TESTFN, "w", -1)
- def test_NullByteInFilename(self):
- # Check that a filename containing a null byte is properly terminated
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- zipf.writestr("foo.txt\x00qqq", b"O, for a Muse of Fire!")
- self.assertEqual(zipf.namelist(), ['foo.txt'])
+ def test_null_byte_in_filename(self):
+ """Check that a filename containing a null byte is properly
+ terminated."""
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ zipf.writestr("foo.txt\x00qqq", b"O, for a Muse of Fire!")
+ self.assertEqual(zipf.namelist(), ['foo.txt'])
- def test_StructSizes(self):
- # check that ZIP internal structure sizes are calculated correctly
+ def test_struct_sizes(self):
+ """Check that ZIP internal structure sizes are calculated correctly."""
self.assertEqual(zipfile.sizeEndCentDir, 22)
self.assertEqual(zipfile.sizeCentralDir, 46)
self.assertEqual(zipfile.sizeEndCentDir64, 56)
self.assertEqual(zipfile.sizeEndCentDir64Locator, 20)
- def testComments(self):
- # This test checks that comments on the archive are handled properly
+ def test_comments(self):
+ """Check that comments on the archive are handled properly."""
# check default comment is empty
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- self.assertEqual(zipf.comment, b'')
- zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- zipf.close()
- zipfr = zipfile.ZipFile(TESTFN, mode="r")
- self.assertEqual(zipfr.comment, b'')
- zipfr.close()
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ self.assertEqual(zipf.comment, b'')
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+
+ with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
+ self.assertEqual(zipfr.comment, b'')
# check a simple short comment
comment = b'Bravely taking to his feet, he beat a very brave retreat.'
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- zipf.comment = comment
- zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- zipf.close()
- zipfr = zipfile.ZipFile(TESTFN, mode="r")
- self.assertEqual(zipfr.comment, comment)
- zipfr.close()
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ zipf.comment = comment
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
+ self.assertEqual(zipf.comment, comment)
# check a comment of max length
comment2 = ''.join(['%d' % (i**3 % 10) for i in range((1 << 16)-1)])
comment2 = comment2.encode("ascii")
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- zipf.comment = comment2
- zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- zipf.close()
- zipfr = zipfile.ZipFile(TESTFN, mode="r")
- self.assertEqual(zipfr.comment, comment2)
- zipfr.close()
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ zipf.comment = comment2
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+
+ with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
+ self.assertEqual(zipfr.comment, comment2)
# check a comment that is too long is truncated
- zipf = zipfile.ZipFile(TESTFN, mode="w")
- zipf.comment = comment2 + b'oops'
- zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- zipf.close()
- zipfr = zipfile.ZipFile(TESTFN, mode="r")
- self.assertEqual(zipfr.comment, comment2)
- zipfr.close()
+ with zipfile.ZipFile(TESTFN, mode="w") as zipf:
+ zipf.comment = comment2 + b'oops'
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
+ self.assertEqual(zipfr.comment, comment2)
def check_testzip_with_bad_crc(self, compression):
"""Tests that files with bad CRCs return their name from testzip."""
zipdata = self.zips_with_bad_crc[compression]
- zipf = zipfile.ZipFile(io.BytesIO(zipdata), mode="r")
- # testzip returns the name of the first corrupt file, or None
- self.assertEqual('afile', zipf.testzip())
- zipf.close()
+ with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:
+ # testzip returns the name of the first corrupt file, or None
+ self.assertEqual('afile', zipf.testzip())
def test_testzip_with_bad_crc_stored(self):
self.check_testzip_with_bad_crc(zipfile.ZIP_STORED)
- if zlib:
- def test_testzip_with_bad_crc_deflated(self):
- self.check_testzip_with_bad_crc(zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_testzip_with_bad_crc_deflated(self):
+ self.check_testzip_with_bad_crc(zipfile.ZIP_DEFLATED)
def check_read_with_bad_crc(self, compression):
- """Tests that files with bad CRCs raise a BadZipfile exception when read."""
+ """Tests that files with bad CRCs raise a BadZipFile exception when read."""
zipdata = self.zips_with_bad_crc[compression]
# Using ZipFile.read()
- zipf = zipfile.ZipFile(io.BytesIO(zipdata), mode="r")
- self.assertRaises(zipfile.BadZipfile, zipf.read, 'afile')
- zipf.close()
+ with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:
+ self.assertRaises(zipfile.BadZipFile, zipf.read, 'afile')
# Using ZipExtFile.read()
- zipf = zipfile.ZipFile(io.BytesIO(zipdata), mode="r")
- corrupt_file = zipf.open('afile', 'r')
- self.assertRaises(zipfile.BadZipfile, corrupt_file.read)
- corrupt_file.close()
- zipf.close()
+ with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:
+ with zipf.open('afile', 'r') as corrupt_file:
+ self.assertRaises(zipfile.BadZipFile, corrupt_file.read)
# Same with small reads (in order to exercise the buffering logic)
- zipf = zipfile.ZipFile(io.BytesIO(zipdata), mode="r")
- corrupt_file = zipf.open('afile', 'r')
- corrupt_file.MIN_READ_SIZE = 2
- with self.assertRaises(zipfile.BadZipfile):
- while corrupt_file.read(2):
- pass
- corrupt_file.close()
- zipf.close()
+ with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:
+ with zipf.open('afile', 'r') as corrupt_file:
+ corrupt_file.MIN_READ_SIZE = 2
+ with self.assertRaises(zipfile.BadZipFile):
+ while corrupt_file.read(2):
+ pass
def test_read_with_bad_crc_stored(self):
self.check_read_with_bad_crc(zipfile.ZIP_STORED)
- if zlib:
- def test_read_with_bad_crc_deflated(self):
- self.check_read_with_bad_crc(zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_read_with_bad_crc_deflated(self):
+ self.check_read_with_bad_crc(zipfile.ZIP_DEFLATED)
def check_read_return_size(self, compression):
# Issue #9837: ZipExtFile.read() shouldn't return more bytes
@@ -886,21 +997,18 @@ class OtherTests(unittest.TestCase):
file_size = test_size + 1
junk = b''.join(struct.pack('B', randint(0, 255))
for x in range(file_size))
- zipf = zipfile.ZipFile(io.BytesIO(), "w", compression)
- try:
+ with zipfile.ZipFile(io.BytesIO(), "w", compression) as zipf:
zipf.writestr('foo', junk)
- fp = zipf.open('foo', 'r')
- buf = fp.read(test_size)
- self.assertEqual(len(buf), test_size)
- finally:
- zipf.close()
+ with zipf.open('foo', 'r') as fp:
+ buf = fp.read(test_size)
+ self.assertEqual(len(buf), test_size)
def test_read_return_size_stored(self):
self.check_read_return_size(zipfile.ZIP_STORED)
- if zlib:
- def test_read_return_size_deflated(self):
- self.check_read_return_size(zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_read_return_size_deflated(self):
+ self.check_read_return_size(zipfile.ZIP_DEFLATED)
def test_empty_zipfile(self):
# Check that creating a file in 'w' or 'a' mode and closing without
@@ -909,7 +1017,7 @@ class OtherTests(unittest.TestCase):
zipf.close()
try:
zipf = zipfile.ZipFile(TESTFN, mode="r")
- except zipfile.BadZipfile:
+ except zipfile.BadZipFile:
self.fail("Unable to create empty ZIP file in 'w' mode")
zipf = zipfile.ZipFile(TESTFN, mode="a")
@@ -921,20 +1029,21 @@ class OtherTests(unittest.TestCase):
def test_open_empty_file(self):
# Issue 1710703: Check that opening a file with less than 22 bytes
- # raises a BadZipfile exception (rather than the previously unhelpful
+ # raises a BadZipFile exception (rather than the previously unhelpful
# IOError)
f = open(TESTFN, 'w')
f.close()
- self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN, 'r')
+ self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN, 'r')
def tearDown(self):
- support.unlink(TESTFN)
- support.unlink(TESTFN2)
+ unlink(TESTFN)
+ unlink(TESTFN2)
+
class DecryptionTests(unittest.TestCase):
- # This test checks that ZIP decryption works. Since the library does not
- # support encryption at the moment, we use a pre-generated encrypted
- # ZIP file
+ """Check that ZIP decryption works. Since the library does not
+ support encryption at the moment, we use a pre-generated encrypted
+ ZIP file."""
data = (
b'PK\x03\x04\x14\x00\x01\x00\x00\x00n\x92i.#y\xef?&\x00\x00\x00\x1a\x00'
@@ -958,13 +1067,11 @@ class DecryptionTests(unittest.TestCase):
plain2 = b'\x00'*512
def setUp(self):
- fp = open(TESTFN, "wb")
- fp.write(self.data)
- fp.close()
+ with open(TESTFN, "wb") as fp:
+ fp.write(self.data)
self.zip = zipfile.ZipFile(TESTFN, "r")
- fp = open(TESTFN2, "wb")
- fp.write(self.data2)
- fp.close()
+ with open(TESTFN2, "wb") as fp:
+ fp.write(self.data2)
self.zip2 = zipfile.ZipFile(TESTFN2, "r")
def tearDown(self):
@@ -973,19 +1080,20 @@ class DecryptionTests(unittest.TestCase):
self.zip2.close()
os.unlink(TESTFN2)
- def testNoPassword(self):
+ def test_no_password(self):
# Reading the encrypted file without password
# must generate a RunTime exception
self.assertRaises(RuntimeError, self.zip.read, "test.txt")
self.assertRaises(RuntimeError, self.zip2.read, "zero")
- def testBadPassword(self):
+ def test_bad_password(self):
self.zip.setpassword(b"perl")
self.assertRaises(RuntimeError, self.zip.read, "test.txt")
self.zip2.setpassword(b"perl")
self.assertRaises(RuntimeError, self.zip2.read, "zero")
- def testGoodPassword(self):
+ @skipUnless(zlib, "requires zlib")
+ def test_good_password(self):
self.zip.setpassword(b"python")
self.assertEqual(self.zip.read("test.txt"), self.plain)
self.zip2.setpassword(b"12345")
@@ -1005,151 +1113,163 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
for i in range(datacount))
# Make a source file with some lines
- fp = open(TESTFN, "wb")
- fp.write(self.data)
- fp.close()
+ with open(TESTFN, "wb") as fp:
+ fp.write(self.data)
def tearDown(self):
- support.unlink(TESTFN)
- support.unlink(TESTFN2)
+ unlink(TESTFN)
+ unlink(TESTFN2)
- def makeTestArchive(self, f, compression):
+ def make_test_archive(self, f, compression):
# Create the ZIP archive
- zipfp = zipfile.ZipFile(f, "w", compression)
- zipfp.write(TESTFN, "another.name")
- zipfp.write(TESTFN, TESTFN)
- zipfp.close()
+ with zipfile.ZipFile(f, "w", compression) as zipfp:
+ zipfp.write(TESTFN, "another.name")
+ zipfp.write(TESTFN, TESTFN)
- def zipTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def zip_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r", compression)
- testdata = zipfp.read(TESTFN)
- self.assertEqual(len(testdata), len(self.data))
- self.assertEqual(testdata, self.data)
- self.assertEqual(zipfp.read("another.name"), self.data)
- zipfp.close()
+ with zipfile.ZipFile(f, "r", compression) as zipfp:
+ testdata = zipfp.read(TESTFN)
+ self.assertEqual(len(testdata), len(self.data))
+ self.assertEqual(testdata, self.data)
+ self.assertEqual(zipfp.read("another.name"), self.data)
+ if not isinstance(f, str):
+ f.close()
+
+ def test_stored(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_test(f, zipfile.ZIP_STORED)
- def testStored(self):
+ @skipUnless(zlib, "requires zlib")
+ def test_deflated(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipTest(f, zipfile.ZIP_STORED)
+ self.zip_test(f, zipfile.ZIP_DEFLATED)
- def zipOpenTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def zip_open_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r", compression)
- zipdata1 = []
- zipopen1 = zipfp.open(TESTFN)
- while 1:
- read_data = zipopen1.read(256)
- if not read_data:
- break
- zipdata1.append(read_data)
-
- zipdata2 = []
- zipopen2 = zipfp.open("another.name")
- while 1:
- read_data = zipopen2.read(256)
- if not read_data:
- break
- zipdata2.append(read_data)
-
- testdata1 = b''.join(zipdata1)
- self.assertEqual(len(testdata1), len(self.data))
- self.assertEqual(testdata1, self.data)
-
- testdata2 = b''.join(zipdata2)
- self.assertEqual(len(testdata1), len(self.data))
- self.assertEqual(testdata1, self.data)
- zipfp.close()
+ with zipfile.ZipFile(f, "r", compression) as zipfp:
+ zipdata1 = []
+ with zipfp.open(TESTFN) as zipopen1:
+ while True:
+ read_data = zipopen1.read(256)
+ if not read_data:
+ break
+ zipdata1.append(read_data)
+
+ zipdata2 = []
+ with zipfp.open("another.name") as zipopen2:
+ while True:
+ read_data = zipopen2.read(256)
+ if not read_data:
+ break
+ zipdata2.append(read_data)
+
+ testdata1 = b''.join(zipdata1)
+ self.assertEqual(len(testdata1), len(self.data))
+ self.assertEqual(testdata1, self.data)
+
+ testdata2 = b''.join(zipdata2)
+ self.assertEqual(len(testdata2), len(self.data))
+ self.assertEqual(testdata2, self.data)
+ if not isinstance(f, str):
+ f.close()
+
+ def test_open_stored(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_open_test(f, zipfile.ZIP_STORED)
- def testOpenStored(self):
+ @skipUnless(zlib, "requires zlib")
+ def test_open_deflated(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipOpenTest(f, zipfile.ZIP_STORED)
+ self.zip_open_test(f, zipfile.ZIP_DEFLATED)
- def zipRandomOpenTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def zip_random_open_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r", compression)
- zipdata1 = []
- zipopen1 = zipfp.open(TESTFN)
- while 1:
- read_data = zipopen1.read(randint(1, 1024))
- if not read_data:
- break
- zipdata1.append(read_data)
-
- testdata = b''.join(zipdata1)
- self.assertEqual(len(testdata), len(self.data))
- self.assertEqual(testdata, self.data)
- zipfp.close()
+ with zipfile.ZipFile(f, "r", compression) as zipfp:
+ zipdata1 = []
+ with zipfp.open(TESTFN) as zipopen1:
+ while True:
+ read_data = zipopen1.read(randint(1, 1024))
+ if not read_data:
+ break
+ zipdata1.append(read_data)
+
+ testdata = b''.join(zipdata1)
+ self.assertEqual(len(testdata), len(self.data))
+ self.assertEqual(testdata, self.data)
+ if not isinstance(f, str):
+ f.close()
+
+ def test_random_open_stored(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_random_open_test(f, zipfile.ZIP_STORED)
- def testRandomOpenStored(self):
+ @skipUnless(zlib, "requires zlib")
+ def test_random_open_deflated(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.zipRandomOpenTest(f, zipfile.ZIP_STORED)
+ self.zip_random_open_test(f, zipfile.ZIP_DEFLATED)
+
+@skipUnless(zlib, "requires zlib")
class TestsWithMultipleOpens(unittest.TestCase):
def setUp(self):
# Create the ZIP archive
- zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED)
- zipfp.writestr('ones', '1'*FIXEDTEST_SIZE)
- zipfp.writestr('twos', '2'*FIXEDTEST_SIZE)
- zipfp.close()
+ with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED) as zipfp:
+ zipfp.writestr('ones', '1'*FIXEDTEST_SIZE)
+ zipfp.writestr('twos', '2'*FIXEDTEST_SIZE)
- def testSameFile(self):
+ def test_same_file(self):
# Verify that (when the ZipFile is in control of creating file objects)
# multiple open() calls can be made without interfering with each other.
- zipf = zipfile.ZipFile(TESTFN2, mode="r")
- zopen1 = zipf.open('ones')
- zopen2 = zipf.open('ones')
- data1 = zopen1.read(500)
- data2 = zopen2.read(500)
- data1 += zopen1.read(500)
- data2 += zopen2.read(500)
- self.assertEqual(data1, data2)
- zipf.close()
-
- def testDifferentFile(self):
+ with zipfile.ZipFile(TESTFN2, mode="r") as zipf:
+ with zipf.open('ones') as zopen1, zipf.open('ones') as zopen2:
+ data1 = zopen1.read(500)
+ data2 = zopen2.read(500)
+ data1 += zopen1.read(500)
+ data2 += zopen2.read(500)
+ self.assertEqual(data1, data2)
+
+ def test_different_file(self):
# Verify that (when the ZipFile is in control of creating file objects)
# multiple open() calls can be made without interfering with each other.
- zipf = zipfile.ZipFile(TESTFN2, mode="r")
- zopen1 = zipf.open('ones')
- zopen2 = zipf.open('twos')
- data1 = zopen1.read(500)
- data2 = zopen2.read(500)
- data1 += zopen1.read(500)
- data2 += zopen2.read(500)
- self.assertEqual(data1, b'1'*FIXEDTEST_SIZE)
- self.assertEqual(data2, b'2'*FIXEDTEST_SIZE)
- zipf.close()
-
- def testInterleaved(self):
+ with zipfile.ZipFile(TESTFN2, mode="r") as zipf:
+ with zipf.open('ones') as zopen1, zipf.open('twos') as zopen2:
+ data1 = zopen1.read(500)
+ data2 = zopen2.read(500)
+ data1 += zopen1.read(500)
+ data2 += zopen2.read(500)
+ self.assertEqual(data1, b'1'*FIXEDTEST_SIZE)
+ self.assertEqual(data2, b'2'*FIXEDTEST_SIZE)
+
+ def test_interleaved(self):
# Verify that (when the ZipFile is in control of creating file objects)
# multiple open() calls can be made without interfering with each other.
- zipf = zipfile.ZipFile(TESTFN2, mode="r")
- zopen1 = zipf.open('ones')
- data1 = zopen1.read(500)
- zopen2 = zipf.open('twos')
- data2 = zopen2.read(500)
- data1 += zopen1.read(500)
- data2 += zopen2.read(500)
- self.assertEqual(data1, b'1'*FIXEDTEST_SIZE)
- self.assertEqual(data2, b'2'*FIXEDTEST_SIZE)
- zipf.close()
+ with zipfile.ZipFile(TESTFN2, mode="r") as zipf:
+ with zipf.open('ones') as zopen1, zipf.open('twos') as zopen2:
+ data1 = zopen1.read(500)
+ data2 = zopen2.read(500)
+ data1 += zopen1.read(500)
+ data2 += zopen2.read(500)
+ self.assertEqual(data1, b'1'*FIXEDTEST_SIZE)
+ self.assertEqual(data2, b'2'*FIXEDTEST_SIZE)
def tearDown(self):
- os.remove(TESTFN2)
+ unlink(TESTFN2)
+
class TestWithDirectory(unittest.TestCase):
def setUp(self):
os.mkdir(TESTFN2)
- def testExtractDir(self):
- zipf = zipfile.ZipFile(findfile("zipdir.zip"))
- zipf.extractall(TESTFN2)
+ def test_extract_dir(self):
+ with zipfile.ZipFile(findfile("zipdir.zip")) as zipf:
+ zipf.extractall(TESTFN2)
self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a")))
self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a", "b")))
self.assertTrue(os.path.exists(os.path.join(TESTFN2, "a", "b", "c")))
@@ -1157,9 +1277,9 @@ class TestWithDirectory(unittest.TestCase):
def test_bug_6050(self):
# Extraction should succeed if directories already exist
os.mkdir(os.path.join(TESTFN2, "a"))
- self.testExtractDir()
+ self.test_extract_dir()
- def testStoreDir(self):
+ def test_store_dir(self):
os.mkdir(os.path.join(TESTFN2, "x"))
zipf = zipfile.ZipFile(TESTFN, "w")
zipf.write(os.path.join(TESTFN2, "x"), "x")
@@ -1168,7 +1288,7 @@ class TestWithDirectory(unittest.TestCase):
def tearDown(self):
shutil.rmtree(TESTFN2)
if os.path.exists(TESTFN):
- os.remove(TESTFN)
+ unlink(TESTFN)
class UniversalNewlineTests(unittest.TestCase):
@@ -1187,105 +1307,145 @@ class UniversalNewlineTests(unittest.TestCase):
finally:
f.close()
- def makeTestArchive(self, f, compression):
+ def make_test_archive(self, f, compression):
# Create the ZIP archive
- zipfp = zipfile.ZipFile(f, "w", compression)
- for fn in self.arcfiles.values():
- zipfp.write(fn, fn)
- zipfp.close()
+ with zipfile.ZipFile(f, "w", compression) as zipfp:
+ for fn in self.arcfiles.values():
+ zipfp.write(fn, fn)
- def readTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def read_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r")
- for sep, fn in self.arcfiles.items():
- zipdata = zipfp.open(fn, "rU").read()
- self.assertEqual(self.arcdata[sep], zipdata)
+ with zipfile.ZipFile(f, "r") as zipfp:
+ for sep, fn in self.arcfiles.items():
+ with zipfp.open(fn, "rU") as fp:
+ zipdata = fp.read()
+ self.assertEqual(self.arcdata[sep], zipdata)
+ if not isinstance(f, str):
+ f.close()
- zipfp.close()
-
- def readlineTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ def readline_read_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r")
- for sep, fn in self.arcfiles.items():
- zipopen = zipfp.open(fn, "rU")
- for line in self.line_gen:
- linedata = zipopen.readline()
- self.assertEqual(linedata, line + b'\n')
+ with zipfile.ZipFile(f, "r") as zipfp:
+ for sep, fn in self.arcfiles.items():
+ with zipfp.open(fn, "rU") as zipopen:
+ data = b''
+ while True:
+ read = zipopen.readline()
+ if not read:
+ break
+ data += read
- zipfp.close()
+ read = zipopen.read(5)
+ if not read:
+ break
+ data += read
- def readlinesTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ self.assertEqual(data, self.arcdata['\n'])
- # Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r")
- for sep, fn in self.arcfiles.items():
- ziplines = zipfp.open(fn, "rU").readlines()
- for line, zipline in zip(self.line_gen, ziplines):
- self.assertEqual(zipline, line + b'\n')
+ if not isinstance(f, str):
+ f.close()
- zipfp.close()
+ def readline_test(self, f, compression):
+ self.make_test_archive(f, compression)
+
+ # Read the ZIP archive
+ with zipfile.ZipFile(f, "r") as zipfp:
+ for sep, fn in self.arcfiles.items():
+ with zipfp.open(fn, "rU") as zipopen:
+ for line in self.line_gen:
+ linedata = zipopen.readline()
+ self.assertEqual(linedata, line + b'\n')
+ if not isinstance(f, str):
+ f.close()
+
+ def readlines_test(self, f, compression):
+ self.make_test_archive(f, compression)
- def iterlinesTest(self, f, compression):
- self.makeTestArchive(f, compression)
+ # Read the ZIP archive
+ with zipfile.ZipFile(f, "r") as zipfp:
+ for sep, fn in self.arcfiles.items():
+ with zipfp.open(fn, "rU") as fp:
+ ziplines = fp.readlines()
+ for line, zipline in zip(self.line_gen, ziplines):
+ self.assertEqual(zipline, line + b'\n')
+ if not isinstance(f, str):
+ f.close()
+
+ def iterlines_test(self, f, compression):
+ self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r")
- for sep, fn in self.arcfiles.items():
- for line, zipline in zip(self.line_gen, zipfp.open(fn, "rU")):
- self.assertEqual(zipline, line + b'\n')
+ with zipfile.ZipFile(f, "r") as zipfp:
+ for sep, fn in self.arcfiles.items():
+ with zipfp.open(fn, "rU") as fp:
+ for line, zipline in zip(self.line_gen, fp):
+ self.assertEqual(zipline, line + b'\n')
+ if not isinstance(f, str):
+ f.close()
+
+ def test_read_stored(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.read_test(f, zipfile.ZIP_STORED)
- zipfp.close()
+ def test_readline_read_stored(self):
+ # Issue #7610: calls to readline() interleaved with calls to read().
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.readline_read_test(f, zipfile.ZIP_STORED)
- def testReadStored(self):
+ def test_readline_stored(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.readTest(f, zipfile.ZIP_STORED)
+ self.readline_test(f, zipfile.ZIP_STORED)
- def testReadlineStored(self):
+ def test_readlines_stored(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.readlineTest(f, zipfile.ZIP_STORED)
+ self.readlines_test(f, zipfile.ZIP_STORED)
- def testReadlinesStored(self):
+ def test_iterlines_stored(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.readlinesTest(f, zipfile.ZIP_STORED)
+ self.iterlines_test(f, zipfile.ZIP_STORED)
- def testIterlinesStored(self):
+ @skipUnless(zlib, "requires zlib")
+ def test_read_deflated(self):
for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.iterlinesTest(f, zipfile.ZIP_STORED)
+ self.read_test(f, zipfile.ZIP_DEFLATED)
- if zlib:
- def testReadDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.readTest(f, zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_readline_read_deflated(self):
+ # Issue #7610: calls to readline() interleaved with calls to read().
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.readline_read_test(f, zipfile.ZIP_DEFLATED)
- def testReadlineDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.readlineTest(f, zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_readline_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.readline_test(f, zipfile.ZIP_DEFLATED)
- def testReadlinesDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.readlinesTest(f, zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_readlines_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.readlines_test(f, zipfile.ZIP_DEFLATED)
- def testIterlinesDeflated(self):
- for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
- self.iterlinesTest(f, zipfile.ZIP_DEFLATED)
+ @skipUnless(zlib, "requires zlib")
+ def test_iterlines_deflated(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.iterlines_test(f, zipfile.ZIP_DEFLATED)
def tearDown(self):
for sep, fn in self.arcfiles.items():
os.remove(fn)
- support.unlink(TESTFN)
- support.unlink(TESTFN2)
+ unlink(TESTFN)
+ unlink(TESTFN2)
def test_main():
run_unittest(TestsWithSourceFile, TestZip64InSmallFiles, OtherTests,
PyZipFileTests, DecryptionTests, TestsWithMultipleOpens,
- TestWithDirectory,
- UniversalNewlineTests, TestsWithRandomBinaryFiles)
+ TestWithDirectory, UniversalNewlineTests,
+ TestsWithRandomBinaryFiles)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index ebf6ad4df2..090f0f3ecc 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -6,11 +6,17 @@ import struct
import time
import unittest
-import zlib # implied prerequisite
-from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED
from test import support
from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co
+# some tests can be ran even without zlib
+try:
+ import zlib
+except ImportError:
+ zlib = None
+
+from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED
+
import zipimport
import linecache
import doctest
@@ -42,17 +48,15 @@ NOW = time.time()
test_pyc = make_pyc(test_co, NOW)
-if __debug__:
- pyc_ext = ".pyc"
-else:
- pyc_ext = ".pyo"
-
-
TESTMOD = "ziptestmodule"
TESTPACK = "ziptestpackage"
TESTPACK2 = "ziptestpackage2"
TEMP_ZIP = os.path.abspath("junk95142.zip")
+pyc_file = imp.cache_from_source(TESTMOD + '.py')
+pyc_ext = ('.pyc' if __debug__ else '.pyo')
+
+
class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
compression = ZIP_STORED
@@ -76,14 +80,11 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
stuff = kw.get("stuff", None)
if stuff is not None:
# Prepend 'stuff' to the start of the zipfile
- f = open(TEMP_ZIP, "rb")
- data = f.read()
- f.close()
-
- f = open(TEMP_ZIP, "wb")
- f.write(stuff)
- f.write(data)
- f.close()
+ with open(TEMP_ZIP, "rb") as f:
+ data = f.read()
+ with open(TEMP_ZIP, "wb") as f:
+ f.write(stuff)
+ f.write(data)
sys.path.insert(0, TEMP_ZIP)
@@ -173,8 +174,9 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
def testBadMTime(self):
badtime_pyc = bytearray(test_pyc)
- badtime_pyc[7] ^= 0x02 # flip the second bit -- not the first as that one
- # isn't stored in the .py's mtime in the zip archive.
+ # flip the second bit -- not the first as that one isn't stored in the
+ # .py's mtime in the zip archive.
+ badtime_pyc[7] ^= 0x02
files = {TESTMOD + ".py": (NOW, test_src),
TESTMOD + pyc_ext: (NOW, badtime_pyc)}
self.doTest(".py", files, TESTMOD)
@@ -220,12 +222,13 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
mod_path = packdir2 + TESTMOD
mod_name = module_path_to_dotted_name(mod_path)
- pkg = __import__(mod_name)
+ __import__(mod_name)
mod = sys.modules[mod_name]
self.assertEqual(zi.get_source(TESTPACK), None)
self.assertEqual(zi.get_source(mod_path), None)
self.assertEqual(zi.get_filename(mod_path), mod.__file__)
- # To pass in the module name instead of the path, we must use the right importer
+ # To pass in the module name instead of the path, we must use the
+ # right importer
loader = mod.__loader__
self.assertEqual(loader.get_source(mod_name), None)
self.assertEqual(loader.get_filename(mod_name), mod.__file__)
@@ -259,17 +262,20 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
mod = zi.load_module(TESTPACK2)
self.assertEqual(zi.get_filename(TESTPACK2), mod.__file__)
- self.assertEqual(zi.is_package(TESTPACK2 + os.sep + '__init__'), False)
- self.assertEqual(zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
+ self.assertEqual(
+ zi.is_package(TESTPACK2 + os.sep + '__init__'), False)
+ self.assertEqual(
+ zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
mod_path = TESTPACK2 + os.sep + TESTMOD
mod_name = module_path_to_dotted_name(mod_path)
- pkg = __import__(mod_name)
+ __import__(mod_name)
mod = sys.modules[mod_name]
self.assertEqual(zi.get_source(TESTPACK2), None)
self.assertEqual(zi.get_source(mod_path), None)
self.assertEqual(zi.get_filename(mod_path), mod.__file__)
- # To pass in the module name instead of the path, we must use the right importer
+ # To pass in the module name instead of the path, we must use the
+ # right importer
loader = mod.__loader__
self.assertEqual(loader.get_source(mod_name), None)
self.assertEqual(loader.get_filename(mod_name), mod.__file__)
@@ -287,7 +293,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
z.close()
zi = zipimport.zipimporter(TEMP_ZIP)
self.assertEqual(data, zi.get_data(name))
- self.assertTrue('zipimporter object' in repr(zi))
+ self.assertIn('zipimporter object', repr(zi))
finally:
z.close()
os.remove(TEMP_ZIP)
@@ -354,7 +360,6 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
def testDoctestSuite(self):
self.runDoctest(self.doDoctestSuite)
-
def doTraceback(self, module):
try:
module.do_raise()
@@ -377,7 +382,22 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
files = {TESTMOD + ".py": (NOW, raise_src)}
self.doTest(None, files, TESTMOD, call=self.doTraceback)
+ @unittest.skipIf(support.TESTFN_UNENCODABLE is None,
+ "need an unencodable filename")
+ def testUnencodable(self):
+ filename = support.TESTFN_UNENCODABLE + ".zip"
+ z = ZipFile(filename, "w")
+ zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW))
+ zinfo.compress_type = self.compression
+ z.writestr(zinfo, test_src)
+ z.close()
+ try:
+ zipimport.zipimporter(filename)
+ finally:
+ os.remove(filename)
+
+@unittest.skipUnless(zlib, "requires zlib")
class CompressedZipImportTestCase(UncompressedZipImportTestCase):
compression = ZIP_DEFLATED
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
index 94a65fc7b2..610dfa0d0a 100644
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -2,7 +2,6 @@
# for working with modules located inside zipfiles
# The tests are centralised in this fashion to make it easy to drop them
# if a platform doesn't support zipimport
-import unittest
import test.support
import os
import os.path
@@ -14,6 +13,9 @@ import doctest
import inspect
import linecache
import pdb
+import unittest
+from test.script_helper import (spawn_python, kill_python, assert_python_ok,
+ temp_dir, make_script, make_zip_script)
verbose = test.support.verbose
@@ -28,12 +30,6 @@ verbose = test.support.verbose
# Retrieve some helpers from other test cases
from test import test_doctest, sample_doctest
-from test.test_importhooks import ImportHooksBaseTestCase
-from test.test_cmd_line_script import temp_dir, _run_python, \
- _spawn_python, _kill_python, \
- _make_test_script, \
- _compile_test_script, \
- _make_test_zip, _make_test_pkg
def _run_object_doctest(obj, module):
@@ -63,30 +59,44 @@ def _run_object_doctest(obj, module):
-class ZipSupportTests(ImportHooksBaseTestCase):
- # We use the ImportHooksBaseTestCase to restore
+class ZipSupportTests(unittest.TestCase):
+ # This used to use the ImportHooksBaseTestCase to restore
# the state of the import related information
- # in the sys module after each test
+ # in the sys module after each test. However, that restores
+ # *too much* information and breaks for the invocation of
+ # of test_doctest. So we do our own thing and leave
+ # sys.modules alone.
# We also clear the linecache and zipimport cache
# just to avoid any bogus errors due to name reuse in the tests
def setUp(self):
linecache.clearcache()
zipimport._zip_directory_cache.clear()
- ImportHooksBaseTestCase.setUp(self)
+ self.path = sys.path[:]
+ self.meta_path = sys.meta_path[:]
+ self.path_hooks = sys.path_hooks[:]
+ sys.path_importer_cache.clear()
+ def tearDown(self):
+ sys.path[:] = self.path
+ sys.meta_path[:] = self.meta_path
+ sys.path_hooks[:] = self.path_hooks
+ sys.path_importer_cache.clear()
def test_inspect_getsource_issue4223(self):
test_src = "def foo(): pass\n"
with temp_dir() as d:
- init_name = _make_test_script(d, '__init__', test_src)
+ init_name = make_script(d, '__init__', test_src)
name_in_zip = os.path.join('zip_pkg',
os.path.basename(init_name))
- zip_name, run_name = _make_test_zip(d, 'test_zip',
+ zip_name, run_name = make_zip_script(d, 'test_zip',
init_name, name_in_zip)
os.remove(init_name)
sys.path.insert(0, zip_name)
import zip_pkg
- self.assertEqual(inspect.getsource(zip_pkg.foo), test_src)
+ try:
+ self.assertEqual(inspect.getsource(zip_pkg.foo), test_src)
+ finally:
+ del sys.modules["zip_pkg"]
def test_doctest_issue4197(self):
# To avoid having to keep two copies of the doctest module's
@@ -106,9 +116,9 @@ class ZipSupportTests(ImportHooksBaseTestCase):
sample_src = sample_src.replace("test.test_doctest",
"test_zipped_doctest")
with temp_dir() as d:
- script_name = _make_test_script(d, 'test_zipped_doctest',
+ script_name = make_script(d, 'test_zipped_doctest',
test_src)
- zip_name, run_name = _make_test_zip(d, 'test_zip',
+ zip_name, run_name = make_zip_script(d, 'test_zip',
script_name)
z = zipfile.ZipFile(zip_name, 'a')
z.writestr("sample_zipped_doctest.py", sample_src)
@@ -121,53 +131,56 @@ class ZipSupportTests(ImportHooksBaseTestCase):
os.remove(script_name)
sys.path.insert(0, zip_name)
import test_zipped_doctest
- # Some of the doc tests depend on the colocated text files
- # which aren't available to the zipped version (the doctest
- # module currently requires real filenames for non-embedded
- # tests). So we're forced to be selective about which tests
- # to run.
- # doctest could really use some APIs which take a text
- # string or a file object instead of a filename...
- known_good_tests = [
- test_zipped_doctest.SampleClass,
- test_zipped_doctest.SampleClass.NestedClass,
- test_zipped_doctest.SampleClass.NestedClass.__init__,
- test_zipped_doctest.SampleClass.__init__,
- test_zipped_doctest.SampleClass.a_classmethod,
- test_zipped_doctest.SampleClass.a_property,
- test_zipped_doctest.SampleClass.a_staticmethod,
- test_zipped_doctest.SampleClass.double,
- test_zipped_doctest.SampleClass.get,
- test_zipped_doctest.SampleNewStyleClass,
- test_zipped_doctest.SampleNewStyleClass.__init__,
- test_zipped_doctest.SampleNewStyleClass.double,
- test_zipped_doctest.SampleNewStyleClass.get,
- test_zipped_doctest.sample_func,
- test_zipped_doctest.test_DocTest,
- test_zipped_doctest.test_DocTestParser,
- test_zipped_doctest.test_DocTestRunner.basics,
- test_zipped_doctest.test_DocTestRunner.exceptions,
- test_zipped_doctest.test_DocTestRunner.option_directives,
- test_zipped_doctest.test_DocTestRunner.optionflags,
- test_zipped_doctest.test_DocTestRunner.verbose_flag,
- test_zipped_doctest.test_Example,
- test_zipped_doctest.test_debug,
- test_zipped_doctest.test_pdb_set_trace,
- test_zipped_doctest.test_pdb_set_trace_nested,
- test_zipped_doctest.test_testsource,
- test_zipped_doctest.test_trailing_space_in_test,
- test_zipped_doctest.test_DocTestSuite,
- test_zipped_doctest.test_DocTestFinder,
- ]
- # These remaining tests are the ones which need access
- # to the data files, so we don't run them
- fail_due_to_missing_data_files = [
- test_zipped_doctest.test_DocFileSuite,
- test_zipped_doctest.test_testfile,
- test_zipped_doctest.test_unittest_reportflags,
- ]
- for obj in known_good_tests:
- _run_object_doctest(obj, test_zipped_doctest)
+ try:
+ # Some of the doc tests depend on the colocated text files
+ # which aren't available to the zipped version (the doctest
+ # module currently requires real filenames for non-embedded
+ # tests). So we're forced to be selective about which tests
+ # to run.
+ # doctest could really use some APIs which take a text
+ # string or a file object instead of a filename...
+ known_good_tests = [
+ test_zipped_doctest.SampleClass,
+ test_zipped_doctest.SampleClass.NestedClass,
+ test_zipped_doctest.SampleClass.NestedClass.__init__,
+ test_zipped_doctest.SampleClass.__init__,
+ test_zipped_doctest.SampleClass.a_classmethod,
+ test_zipped_doctest.SampleClass.a_property,
+ test_zipped_doctest.SampleClass.a_staticmethod,
+ test_zipped_doctest.SampleClass.double,
+ test_zipped_doctest.SampleClass.get,
+ test_zipped_doctest.SampleNewStyleClass,
+ test_zipped_doctest.SampleNewStyleClass.__init__,
+ test_zipped_doctest.SampleNewStyleClass.double,
+ test_zipped_doctest.SampleNewStyleClass.get,
+ test_zipped_doctest.sample_func,
+ test_zipped_doctest.test_DocTest,
+ test_zipped_doctest.test_DocTestParser,
+ test_zipped_doctest.test_DocTestRunner.basics,
+ test_zipped_doctest.test_DocTestRunner.exceptions,
+ test_zipped_doctest.test_DocTestRunner.option_directives,
+ test_zipped_doctest.test_DocTestRunner.optionflags,
+ test_zipped_doctest.test_DocTestRunner.verbose_flag,
+ test_zipped_doctest.test_Example,
+ test_zipped_doctest.test_debug,
+ test_zipped_doctest.test_pdb_set_trace,
+ test_zipped_doctest.test_pdb_set_trace_nested,
+ test_zipped_doctest.test_testsource,
+ test_zipped_doctest.test_trailing_space_in_test,
+ test_zipped_doctest.test_DocTestSuite,
+ test_zipped_doctest.test_DocTestFinder,
+ ]
+ # These remaining tests are the ones which need access
+ # to the data files, so we don't run them
+ fail_due_to_missing_data_files = [
+ test_zipped_doctest.test_DocFileSuite,
+ test_zipped_doctest.test_testfile,
+ test_zipped_doctest.test_unittest_reportflags,
+ ]
+ for obj in known_good_tests:
+ _run_object_doctest(obj, test_zipped_doctest)
+ finally:
+ del sys.modules["test_zipped_doctest"]
def test_doctest_main_issue4197(self):
test_src = textwrap.dedent("""\
@@ -180,23 +193,23 @@ class ZipSupportTests(ImportHooksBaseTestCase):
""")
pattern = 'File "%s", line 2, in %s'
with temp_dir() as d:
- script_name = _make_test_script(d, 'script', test_src)
- exit_code, data = _run_python(script_name)
+ script_name = make_script(d, 'script', test_src)
+ rc, out, err = assert_python_ok(script_name)
expected = pattern % (script_name, "__main__.Test")
if verbose:
print ("Expected line", expected)
print ("Got stdout:")
- print (data)
- self.assertTrue(expected in data)
- zip_name, run_name = _make_test_zip(d, "test_zip",
+ print (ascii(out))
+ self.assertIn(expected.encode('utf-8'), out)
+ zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
- exit_code, data = _run_python(zip_name)
+ rc, out, err = assert_python_ok(zip_name)
expected = pattern % (run_name, "__main__.Test")
if verbose:
print ("Expected line", expected)
print ("Got stdout:")
- print (data)
- self.assertTrue(expected in data)
+ print (ascii(out))
+ self.assertIn(expected.encode('utf-8'), out)
def test_pdb_issue4201(self):
test_src = textwrap.dedent("""\
@@ -204,20 +217,20 @@ class ZipSupportTests(ImportHooksBaseTestCase):
pass
import pdb
- pdb.runcall(f)
+ pdb.Pdb(nosigint=True).runcall(f)
""")
with temp_dir() as d:
- script_name = _make_test_script(d, 'script', test_src)
- p = _spawn_python(script_name)
+ script_name = make_script(d, 'script', test_src)
+ p = spawn_python(script_name)
p.stdin.write(b'l\n')
- data = _kill_python(p).decode()
- self.assertTrue(script_name in data)
- zip_name, run_name = _make_test_zip(d, "test_zip",
+ data = kill_python(p)
+ self.assertIn(script_name.encode('utf-8'), data)
+ zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
- p = _spawn_python(zip_name)
+ p = spawn_python(zip_name)
p.stdin.write(b'l\n')
- data = _kill_python(p).decode()
- self.assertTrue(run_name in data)
+ data = kill_python(p)
+ self.assertIn(run_name.encode('utf-8'), data)
def test_main():
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 48ac40a4f7..5d38d97836 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -66,10 +66,6 @@ class ChecksumTestCase(unittest.TestCase):
# Issue #10276 - check that inputs >=4GB are handled correctly.
class ChecksumBigBufferTestCase(unittest.TestCase):
- @unittest.skipUnless(mmap, "mmap() is not available.")
- @unittest.skipUnless(sys.maxsize > _4G, "Can't run on a 32-bit system.")
- @unittest.skipUnless(support.is_resource_enabled("largefile"),
- "May use lots of disk space.")
def setUp(self):
with open(support.TESTFN, "wb+") as f:
f.seek(_4G)
@@ -81,6 +77,10 @@ class ChecksumBigBufferTestCase(unittest.TestCase):
self.mapping.close()
support.unlink(support.TESTFN)
+ @unittest.skipUnless(mmap, "mmap() is not available.")
+ @unittest.skipUnless(sys.maxsize > _4G, "Can't run on a 32-bit system.")
+ @unittest.skipUnless(support.is_resource_enabled("largefile"),
+ "May use lots of disk space.")
def test_big_buffer(self):
self.assertEqual(zlib.crc32(self.mapping), 3058686908)
self.assertEqual(zlib.adler32(self.mapping), 82837919)
@@ -129,7 +129,7 @@ class BaseCompressTestCase(object):
# Generate 10MB worth of random, and expand it by repeating it.
# The assumption is that zlib's memory is not big enough to exploit
# such spread out redundancy.
- data = b''.join([binascii.a2b_hex(fmt % random.getrandbits(8 * _1M))
+ data = b''.join([random.getrandbits(8 * _1M).to_bytes(_1M, 'little')
for i in range(10)])
data = data * (size // len(data) + 1)
try:
@@ -171,7 +171,7 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
def test_incomplete_stream(self):
# An useful error message is given
x = zlib.compress(HAMLET_SCENE)
- self.assertRaisesRegexp(zlib.error,
+ self.assertRaisesRegex(zlib.error,
"Error -5 while decompressing data: incomplete or truncated stream",
zlib.decompress, x[:-1])
@@ -186,6 +186,16 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
def test_big_decompress_buffer(self, size):
self.check_big_decompress_buffer(size, zlib.decompress)
+ @precisionbigmemtest(size=_4G + 100, memuse=1)
+ def test_length_overflow(self, size):
+ if size < _4G + 100:
+ self.skipTest("not enough free memory, need at least 4 GB")
+ data = b'x' * size
+ try:
+ self.assertRaises(OverflowError, zlib.compress, data, 1)
+ finally:
+ data = None
+
class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
# Test compression object
@@ -205,8 +215,8 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
y1 = dco.decompress(v1 + v2)
y2 = dco.flush()
self.assertEqual(data, y1 + y2)
- self.assertTrue(isinstance(dco.unconsumed_tail, bytes))
- self.assertTrue(isinstance(dco.unused_data, bytes))
+ self.assertIsInstance(dco.unconsumed_tail, bytes)
+ self.assertIsInstance(dco.unused_data, bytes)
def test_compressoptions(self):
# specify lots of options to compressobj()
@@ -251,7 +261,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
decombuf = zlib.decompress(combuf)
# Test type of return value
- self.assertTrue(isinstance(decombuf, bytes))
+ self.assertIsInstance(decombuf, bytes)
self.assertEqual(data, decombuf)
@@ -463,7 +473,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
data = HAMLET_SCENE
comp = zlib.compress(data)
# Test type of return value
- self.assertTrue(isinstance(comp, bytes))
+ self.assertIsInstance(comp, bytes)
d0 = zlib.decompressobj()
bufs0 = []
diff --git a/Lib/test/testtar.tar b/Lib/test/testtar.tar
index b5bb46b16e..b93210453d 100644
--- a/Lib/test/testtar.tar
+++ b/Lib/test/testtar.tar
Binary files differ
diff --git a/Lib/test/threaded_import_hangers.py b/Lib/test/threaded_import_hangers.py
index d7508741d3..adf03e31ff 100644
--- a/Lib/test/threaded_import_hangers.py
+++ b/Lib/test/threaded_import_hangers.py
@@ -29,7 +29,7 @@ class Worker(threading.Thread):
for name, func, args in [
# Bug 147376: TemporaryFile hung on Windows, starting in Python 2.4.
- ("tempfile.TemporaryFile", tempfile.TemporaryFile, ()),
+ ("tempfile.TemporaryFile", lambda: tempfile.TemporaryFile().close(), ()),
# The real cause for bug 147376: ntpath.abspath() caused the hang.
("os.path.abspath", os.path.abspath, ('.',)),
diff --git a/Lib/test/win_console_handler.py b/Lib/test/win_console_handler.py
new file mode 100644
index 0000000000..e7779b9363
--- /dev/null
+++ b/Lib/test/win_console_handler.py
@@ -0,0 +1,49 @@
+"""Script used to test os.kill on Windows, for issue #1220212
+
+This script is started as a subprocess in test_os and is used to test the
+CTRL_C_EVENT and CTRL_BREAK_EVENT signals, which requires a custom handler
+to be written into the kill target.
+
+See http://msdn.microsoft.com/en-us/library/ms685049%28v=VS.85%29.aspx for a
+similar example in C.
+"""
+
+from ctypes import wintypes, WINFUNCTYPE
+import signal
+import ctypes
+import mmap
+import sys
+
+# Function prototype for the handler function. Returns BOOL, takes a DWORD.
+HandlerRoutine = WINFUNCTYPE(wintypes.BOOL, wintypes.DWORD)
+
+def _ctrl_handler(sig):
+ """Handle a sig event and return 0 to terminate the process"""
+ if sig == signal.CTRL_C_EVENT:
+ pass
+ elif sig == signal.CTRL_BREAK_EVENT:
+ pass
+ else:
+ print("UNKNOWN EVENT")
+ return 0
+
+ctrl_handler = HandlerRoutine(_ctrl_handler)
+
+
+SetConsoleCtrlHandler = ctypes.windll.kernel32.SetConsoleCtrlHandler
+SetConsoleCtrlHandler.argtypes = (HandlerRoutine, wintypes.BOOL)
+SetConsoleCtrlHandler.restype = wintypes.BOOL
+
+if __name__ == "__main__":
+ # Add our console control handling function with value 1
+ if not SetConsoleCtrlHandler(ctrl_handler, 1):
+ print("Unable to add SetConsoleCtrlHandler")
+ exit(-1)
+
+ # Awake main process
+ m = mmap.mmap(-1, 1, sys.argv[1])
+ m[0] = 1
+
+ # Do nothing but wait for the signal
+ while True:
+ pass
diff --git a/Lib/test/xmltestdata/simple-ns.xml b/Lib/test/xmltestdata/simple-ns.xml
new file mode 100644
index 0000000000..f1f34b2e29
--- /dev/null
+++ b/Lib/test/xmltestdata/simple-ns.xml
@@ -0,0 +1,7 @@
+<?pi data?>
+<!-- comment -->
+<root xmlns='namespace'>
+ <element key='value'>text</element>
+ <element>text</element>tail
+ <empty-element/>
+</root>
diff --git a/Lib/test/xmltestdata/simple.xml b/Lib/test/xmltestdata/simple.xml
new file mode 100644
index 0000000000..b88c2c7e69
--- /dev/null
+++ b/Lib/test/xmltestdata/simple.xml
@@ -0,0 +1,6 @@
+<!-- comment -->
+<root>
+ <element key='value'>text</element>
+ <element>text</element>tail
+ <empty-element/>
+</root>
diff --git a/Lib/test/test.xml b/Lib/test/xmltestdata/test.xml
index 9af92fb435..9af92fb435 100644
--- a/Lib/test/test.xml
+++ b/Lib/test/xmltestdata/test.xml
diff --git a/Lib/test/test.xml.out b/Lib/test/xmltestdata/test.xml.out
index d4ab1abcb6..d4ab1abcb6 100644
--- a/Lib/test/test.xml.out
+++ b/Lib/test/xmltestdata/test.xml.out
diff --git a/Lib/test/zip_cp437_header.zip b/Lib/test/zip_cp437_header.zip
new file mode 100644
index 0000000000..f7c6cf1704
--- /dev/null
+++ b/Lib/test/zip_cp437_header.zip
Binary files differ
diff --git a/Lib/threading.py b/Lib/threading.py
index c965c6f0f5..fd93f74333 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -17,24 +17,24 @@ from collections import deque
# with the multiprocessing module, which doesn't provide the old
# Java inspired names.
-
-# Rename some stuff so "from threading import *" is safe
__all__ = ['active_count', 'Condition', 'current_thread', 'enumerate', 'Event',
- 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
+ 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Barrier',
'Timer', 'setprofile', 'settrace', 'local', 'stack_size']
+# Rename some stuff so "from threading import *" is safe
_start_new_thread = _thread.start_new_thread
_allocate_lock = _thread.allocate_lock
_get_ident = _thread.get_ident
ThreadError = _thread.error
+try:
+ _CRLock = _thread.RLock
+except AttributeError:
+ _CRLock = None
+TIMEOUT_MAX = _thread.TIMEOUT_MAX
del _thread
# Debug support (adapted from ihooks.py).
-# All the major classes here derive from _Verbose. We force that to
-# be a new-style class so that all the major classes here are new-style.
-# This helps debugging (type(instance) is more revealing for instances
-# of new-style classes).
_VERBOSE = False
@@ -85,8 +85,12 @@ def settrace(func):
Lock = _allocate_lock
-def RLock(*args, **kwargs):
- return _RLock(*args, **kwargs)
+def RLock(verbose=None, *args, **kwargs):
+ if verbose is None:
+ verbose = _VERBOSE
+ if (__debug__ and verbose) or _CRLock is None:
+ return _PyRLock(verbose, *args, **kwargs)
+ return _CRLock(*args, **kwargs)
class _RLock(_Verbose):
@@ -105,14 +109,14 @@ class _RLock(_Verbose):
return "<%s owner=%r count=%d>" % (
self.__class__.__name__, owner, self._count)
- def acquire(self, blocking=True):
+ def acquire(self, blocking=True, timeout=-1):
me = _get_ident()
if self._owner == me:
self._count = self._count + 1
if __debug__:
self._note("%s.acquire(%s): recursive success", self, blocking)
return 1
- rc = self._block.acquire(blocking)
+ rc = self._block.acquire(blocking, timeout)
if rc:
self._owner = me
self._count = 1
@@ -162,6 +166,8 @@ class _RLock(_Verbose):
def _is_owned(self):
return self._owner == _get_ident()
+_PyRLock = _RLock
+
def Condition(*args, **kwargs):
return _Condition(*args, **kwargs)
@@ -227,25 +233,14 @@ class _Condition(_Verbose):
try: # restore state no matter what (e.g., KeyboardInterrupt)
if timeout is None:
waiter.acquire()
+ gotit = True
if __debug__:
self._note("%s.wait(): got it", self)
else:
- # Balancing act: We can't afford a pure busy loop, so we
- # have to sleep; but if we sleep the whole timeout time,
- # we'll be unresponsive. The scheme here sleeps very
- # little at first, longer as time goes on, but never longer
- # than 20 times per second (or the timeout time remaining).
- endtime = _time() + timeout
- delay = 0.0005 # 500 us -> initial delay of 1 ms
- while True:
- gotit = waiter.acquire(0)
- if gotit:
- break
- remaining = endtime - _time()
- if remaining <= 0:
- break
- delay = min(delay * 2, remaining, .05)
- _sleep(delay)
+ if timeout > 0:
+ gotit = waiter.acquire(True, timeout)
+ else:
+ gotit = waiter.acquire(False)
if not gotit:
if __debug__:
self._note("%s.wait(%s): timed out", self, timeout)
@@ -256,9 +251,36 @@ class _Condition(_Verbose):
else:
if __debug__:
self._note("%s.wait(%s): got it", self, timeout)
+ return gotit
finally:
self._acquire_restore(saved_state)
+ def wait_for(self, predicate, timeout=None):
+ endtime = None
+ waittime = timeout
+ result = predicate()
+ while not result:
+ if waittime is not None:
+ if endtime is None:
+ endtime = _time() + waittime
+ else:
+ waittime = endtime - _time()
+ if waittime <= 0:
+ if __debug__:
+ self._note("%s.wait_for(%r, %r): Timed out.",
+ self, predicate, timeout)
+ break
+ if __debug__:
+ self._note("%s.wait_for(%r, %r): Waiting with timeout=%s.",
+ self, predicate, timeout, waittime)
+ self.wait(waittime)
+ result = predicate()
+ else:
+ if __debug__:
+ self._note("%s.wait_for(%r, %r): Success.",
+ self, predicate, timeout)
+ return result
+
def notify(self, n=1):
if not self._is_owned():
raise RuntimeError("cannot notify on un-acquired lock")
@@ -297,8 +319,11 @@ class _Semaphore(_Verbose):
self._cond = Condition(Lock())
self._value = value
- def acquire(self, blocking=True):
+ def acquire(self, blocking=True, timeout=None):
+ if not blocking and timeout is not None:
+ raise ValueError("can't specify timeout for non-blocking acquire")
rc = False
+ endtime = None
self._cond.acquire()
while self._value == 0:
if not blocking:
@@ -306,7 +331,14 @@ class _Semaphore(_Verbose):
if __debug__:
self._note("%s.acquire(%s): blocked waiting, value=%s",
self, blocking, self._value)
- self._cond.wait()
+ if timeout is not None:
+ if endtime is None:
+ endtime = _time() + timeout
+ else:
+ timeout = endtime - _time()
+ if timeout <= 0:
+ break
+ self._cond.wait(timeout)
else:
self._value = self._value - 1
if __debug__:
@@ -391,6 +423,177 @@ class _Event(_Verbose):
finally:
self._cond.release()
+
+# A barrier class. Inspired in part by the pthread_barrier_* api and
+# the CyclicBarrier class from Java. See
+# http://sourceware.org/pthreads-win32/manual/pthread_barrier_init.html and
+# http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/
+# CyclicBarrier.html
+# for information.
+# We maintain two main states, 'filling' and 'draining' enabling the barrier
+# to be cyclic. Threads are not allowed into it until it has fully drained
+# since the previous cycle. In addition, a 'resetting' state exists which is
+# similar to 'draining' except that threads leave with a BrokenBarrierError,
+# and a 'broken' state in which all threads get get the exception.
+class Barrier(_Verbose):
+ """
+ Barrier. Useful for synchronizing a fixed number of threads
+ at known synchronization points. Threads block on 'wait()' and are
+ simultaneously once they have all made that call.
+ """
+ def __init__(self, parties, action=None, timeout=None, verbose=None):
+ """
+ Create a barrier, initialised to 'parties' threads.
+ 'action' is a callable which, when supplied, will be called
+ by one of the threads after they have all entered the
+ barrier and just prior to releasing them all.
+ If a 'timeout' is provided, it is uses as the default for
+ all subsequent 'wait()' calls.
+ """
+ _Verbose.__init__(self, verbose)
+ self._cond = Condition(Lock())
+ self._action = action
+ self._timeout = timeout
+ self._parties = parties
+ self._state = 0 #0 filling, 1, draining, -1 resetting, -2 broken
+ self._count = 0
+
+ def wait(self, timeout=None):
+ """
+ Wait for the barrier. When the specified number of threads have
+ started waiting, they are all simultaneously awoken. If an 'action'
+ was provided for the barrier, one of the threads will have executed
+ that callback prior to returning.
+ Returns an individual index number from 0 to 'parties-1'.
+ """
+ if timeout is None:
+ timeout = self._timeout
+ with self._cond:
+ self._enter() # Block while the barrier drains.
+ index = self._count
+ self._count += 1
+ try:
+ if index + 1 == self._parties:
+ # We release the barrier
+ self._release()
+ else:
+ # We wait until someone releases us
+ self._wait(timeout)
+ return index
+ finally:
+ self._count -= 1
+ # Wake up any threads waiting for barrier to drain.
+ self._exit()
+
+ # Block until the barrier is ready for us, or raise an exception
+ # if it is broken.
+ def _enter(self):
+ while self._state in (-1, 1):
+ # It is draining or resetting, wait until done
+ self._cond.wait()
+ #see if the barrier is in a broken state
+ if self._state < 0:
+ raise BrokenBarrierError
+ assert self._state == 0
+
+ # Optionally run the 'action' and release the threads waiting
+ # in the barrier.
+ def _release(self):
+ try:
+ if self._action:
+ self._action()
+ # enter draining state
+ self._state = 1
+ self._cond.notify_all()
+ except:
+ #an exception during the _action handler. Break and reraise
+ self._break()
+ raise
+
+ # Wait in the barrier until we are relased. Raise an exception
+ # if the barrier is reset or broken.
+ def _wait(self, timeout):
+ if not self._cond.wait_for(lambda : self._state != 0, timeout):
+ #timed out. Break the barrier
+ self._break()
+ raise BrokenBarrierError
+ if self._state < 0:
+ raise BrokenBarrierError
+ assert self._state == 1
+
+ # If we are the last thread to exit the barrier, signal any threads
+ # waiting for the barrier to drain.
+ def _exit(self):
+ if self._count == 0:
+ if self._state in (-1, 1):
+ #resetting or draining
+ self._state = 0
+ self._cond.notify_all()
+
+ def reset(self):
+ """
+ Reset the barrier to the initial state.
+ Any threads currently waiting will get the BrokenBarrier exception
+ raised.
+ """
+ with self._cond:
+ if self._count > 0:
+ if self._state == 0:
+ #reset the barrier, waking up threads
+ self._state = -1
+ elif self._state == -2:
+ #was broken, set it to reset state
+ #which clears when the last thread exits
+ self._state = -1
+ else:
+ self._state = 0
+ self._cond.notify_all()
+
+ def abort(self):
+ """
+ Place the barrier into a 'broken' state.
+ Useful in case of error. Any currently waiting threads and
+ threads attempting to 'wait()' will have BrokenBarrierError
+ raised.
+ """
+ with self._cond:
+ self._break()
+
+ def _break(self):
+ # An internal error was detected. The barrier is set to
+ # a broken state all parties awakened.
+ self._state = -2
+ self._cond.notify_all()
+
+ @property
+ def parties(self):
+ """
+ Return the number of threads required to trip the barrier.
+ """
+ return self._parties
+
+ @property
+ def n_waiting(self):
+ """
+ Return the number of threads that are currently waiting at the barrier.
+ """
+ # We don't need synchronization here since this is an ephemeral result
+ # anyway. It returns the correct value in the steady state.
+ if self._state == 0:
+ return self._count
+ return 0
+
+ @property
+ def broken(self):
+ """
+ Return True if the barrier is in a broken state
+ """
+ return self._state == -2
+
+#exception raised by the Barrier class
+class BrokenBarrierError(RuntimeError): pass
+
+
# Helper to generate new thread names
_counter = 0
def _newname(template="Thread-%d"):
@@ -881,91 +1084,3 @@ def _after_fork():
_active.clear()
_active.update(new_active)
assert len(_active) == 1
-
-
-# Self-test code
-
-def _test():
-
- class BoundedQueue(_Verbose):
-
- def __init__(self, limit):
- _Verbose.__init__(self)
- self.mon = RLock()
- self.rc = Condition(self.mon)
- self.wc = Condition(self.mon)
- self.limit = limit
- self.queue = deque()
-
- def put(self, item):
- self.mon.acquire()
- while len(self.queue) >= self.limit:
- self._note("put(%s): queue full", item)
- self.wc.wait()
- self.queue.append(item)
- self._note("put(%s): appended, length now %d",
- item, len(self.queue))
- self.rc.notify()
- self.mon.release()
-
- def get(self):
- self.mon.acquire()
- while not self.queue:
- self._note("get(): queue empty")
- self.rc.wait()
- item = self.queue.popleft()
- self._note("get(): got %s, %d left", item, len(self.queue))
- self.wc.notify()
- self.mon.release()
- return item
-
- class ProducerThread(Thread):
-
- def __init__(self, queue, quota):
- Thread.__init__(self, name="Producer")
- self.queue = queue
- self.quota = quota
-
- def run(self):
- from random import random
- counter = 0
- while counter < self.quota:
- counter = counter + 1
- self.queue.put("%s.%d" % (self.name, counter))
- _sleep(random() * 0.00001)
-
-
- class ConsumerThread(Thread):
-
- def __init__(self, queue, count):
- Thread.__init__(self, name="Consumer")
- self.queue = queue
- self.count = count
-
- def run(self):
- while self.count > 0:
- item = self.queue.get()
- print(item)
- self.count = self.count - 1
-
- NP = 3
- QL = 4
- NI = 5
-
- Q = BoundedQueue(QL)
- P = []
- for i in range(NP):
- t = ProducerThread(Q, NI)
- t.name = "Producer-%d" % (i+1)
- P.append(t)
- C = ConsumerThread(Q, NI*NP)
- for t in P:
- t.start()
- _sleep(0.000001)
- C.start()
- for t in P:
- t.join()
- C.join()
-
-if __name__ == '__main__':
- _test()
diff --git a/Lib/timeit.py b/Lib/timeit.py
index c3f6753c66..8e04645262 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Tool for measuring execution time of small code snippets.
@@ -232,10 +232,10 @@ def repeat(stmt="pass", setup="pass", timer=default_timer,
"""Convenience function to create Timer object and call repeat method."""
return Timer(stmt, setup, timer).repeat(repeat, number)
-def main(args=None):
+def main(args=None, *, _wrap_timer=None):
"""Main program, used when run as a script.
- The optional argument specifies the command line to be parsed,
+ The optional 'args' argument specifies the command line to be parsed,
defaulting to sys.argv[1:].
The return value is an exit code to be passed to sys.exit(); it
@@ -244,6 +244,10 @@ def main(args=None):
When an exception happens during timing, a traceback is printed to
stderr and the return value is 1. Exceptions at other times
(including the template compilation) are not caught.
+
+ '_wrap_timer' is an internal interface used for unit testing. If it
+ is not None, it must be a callable that accepts a timer function
+ and returns another timer function (used for unit testing).
"""
if args is None:
args = sys.argv[1:]
@@ -289,6 +293,8 @@ def main(args=None):
# directory)
import os
sys.path.insert(0, os.curdir)
+ if _wrap_timer is not None:
+ timer = _wrap_timer(timer)
t = Timer(stmt, setup, timer)
if number == 0:
# determine number so that 0.2 <= total time < 2.0
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index 0bccbfc1f5..e54c53f18e 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -1403,6 +1403,48 @@ class CallWrapper:
self.widget._report_exception()
+class XView:
+ """Mix-in class for querying and changing the horizontal position
+ of a widget's window."""
+
+ def xview(self, *args):
+ """Query and change the horizontal position of the view."""
+ res = self.tk.call(self._w, 'xview', *args)
+ if not args:
+ return self._getdoubles(res)
+
+ def xview_moveto(self, fraction):
+ """Adjusts the view in the window so that FRACTION of the
+ total width of the canvas is off-screen to the left."""
+ self.tk.call(self._w, 'xview', 'moveto', fraction)
+
+ def xview_scroll(self, number, what):
+ """Shift the x-view according to NUMBER which is measured in "units"
+ or "pages" (WHAT)."""
+ self.tk.call(self._w, 'xview', 'scroll', number, what)
+
+
+class YView:
+ """Mix-in class for querying and changing the vertical position
+ of a widget's window."""
+
+ def yview(self, *args):
+ """Query and change the vertical position of the view."""
+ res = self.tk.call(self._w, 'yview', *args)
+ if not args:
+ return self._getdoubles(res)
+
+ def yview_moveto(self, fraction):
+ """Adjusts the view in the window so that FRACTION of the
+ total height of the canvas is off-screen to the top."""
+ self.tk.call(self._w, 'yview', 'moveto', fraction)
+
+ def yview_scroll(self, number, what):
+ """Shift the y-view according to NUMBER which is measured in
+ "units" or "pages" (WHAT)."""
+ self.tk.call(self._w, 'yview', 'scroll', number, what)
+
+
class Wm:
"""Provides functions for the communication with the window manager."""
@@ -2041,7 +2083,7 @@ def At(x, y=None):
else:
return '@%r,%r' % (x, y)
-class Canvas(Widget):
+class Canvas(Widget, XView, YView):
"""Canvas widget to display graphical elements like lines or text."""
def __init__(self, master=None, cnf={}, **kw):
"""Construct a canvas widget with the parent MASTER.
@@ -2281,30 +2323,6 @@ class Canvas(Widget):
def type(self, tagOrId):
"""Return the type of the item TAGORID."""
return self.tk.call(self._w, 'type', tagOrId) or None
- def xview(self, *args):
- """Query and change horizontal position of the view."""
- if not args:
- return self._getdoubles(self.tk.call(self._w, 'xview'))
- self.tk.call((self._w, 'xview') + args)
- def xview_moveto(self, fraction):
- """Adjusts the view in the window so that FRACTION of the
- total width of the canvas is off-screen to the left."""
- self.tk.call(self._w, 'xview', 'moveto', fraction)
- def xview_scroll(self, number, what):
- """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
- self.tk.call(self._w, 'xview', 'scroll', number, what)
- def yview(self, *args):
- """Query and change vertical position of the view."""
- if not args:
- return self._getdoubles(self.tk.call(self._w, 'yview'))
- self.tk.call((self._w, 'yview') + args)
- def yview_moveto(self, fraction):
- """Adjusts the view in the window so that FRACTION of the
- total height of the canvas is off-screen to the top."""
- self.tk.call(self._w, 'yview', 'moveto', fraction)
- def yview_scroll(self, number, what):
- """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
- self.tk.call(self._w, 'yview', 'scroll', number, what)
class Checkbutton(Widget):
"""Checkbutton widget which is either in on- or off-state."""
@@ -2335,7 +2353,7 @@ class Checkbutton(Widget):
"""Toggle the button."""
self.tk.call(self._w, 'toggle')
-class Entry(Widget):
+class Entry(Widget, XView):
"""Entry widget which allows to display simple text."""
def __init__(self, master=None, cnf={}, **kw):
"""Construct an entry widget with the parent MASTER.
@@ -2386,7 +2404,8 @@ class Entry(Widget):
self.tk.call(self._w, 'selection', 'from', index)
select_from = selection_from
def selection_present(self):
- """Return whether the widget has the selection."""
+ """Return True if there are characters selected in the entry, False
+ otherwise."""
return self.tk.getboolean(
self.tk.call(self._w, 'selection', 'present'))
select_present = selection_present
@@ -2398,16 +2417,6 @@ class Entry(Widget):
"""Set the variable end of a selection to INDEX."""
self.tk.call(self._w, 'selection', 'to', index)
select_to = selection_to
- def xview(self, index):
- """Query and change horizontal position of the view."""
- self.tk.call(self._w, 'xview', index)
- def xview_moveto(self, fraction):
- """Adjust the view in the window so that FRACTION of the
- total width of the entry is off-screen to the left."""
- self.tk.call(self._w, 'xview', 'moveto', fraction)
- def xview_scroll(self, number, what):
- """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
- self.tk.call(self._w, 'xview', 'scroll', number, what)
class Frame(Widget):
"""Frame widget which may contain other widgets and can have a 3D border."""
@@ -2449,7 +2458,7 @@ class Label(Widget):
"""
Widget.__init__(self, master, 'label', cnf, kw)
-class Listbox(Widget):
+class Listbox(Widget, XView, YView):
"""Listbox widget which can display a list of strings."""
def __init__(self, master=None, cnf={}, **kw):
"""Construct a listbox widget with the parent MASTER.
@@ -2528,30 +2537,6 @@ class Listbox(Widget):
def size(self):
"""Return the number of elements in the listbox."""
return getint(self.tk.call(self._w, 'size'))
- def xview(self, *what):
- """Query and change horizontal position of the view."""
- if not what:
- return self._getdoubles(self.tk.call(self._w, 'xview'))
- self.tk.call((self._w, 'xview') + what)
- def xview_moveto(self, fraction):
- """Adjust the view in the window so that FRACTION of the
- total width of the entry is off-screen to the left."""
- self.tk.call(self._w, 'xview', 'moveto', fraction)
- def xview_scroll(self, number, what):
- """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
- self.tk.call(self._w, 'xview', 'scroll', number, what)
- def yview(self, *what):
- """Query and change vertical position of the view."""
- if not what:
- return self._getdoubles(self.tk.call(self._w, 'yview'))
- self.tk.call((self._w, 'yview') + what)
- def yview_moveto(self, fraction):
- """Adjust the view in the window so that FRACTION of the
- total width of the entry is off-screen to the top."""
- self.tk.call(self._w, 'yview', 'moveto', fraction)
- def yview_scroll(self, number, what):
- """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
- self.tk.call(self._w, 'yview', 'scroll', number, what)
def itemcget(self, index, option):
"""Return the resource value for an ITEM and an OPTION."""
return self.tk.call(
@@ -2798,7 +2783,7 @@ class Scrollbar(Widget):
-class Text(Widget):
+class Text(Widget, XView, YView):
"""Text widget which can display text in various forms."""
def __init__(self, master=None, cnf={}, **kw):
"""Construct a text widget with the parent MASTER.
@@ -3120,32 +3105,6 @@ class Text(Widget):
"""Return all names of embedded windows in this widget."""
return self.tk.splitlist(
self.tk.call(self._w, 'window', 'names'))
- def xview(self, *what):
- """Query and change horizontal position of the view."""
- if not what:
- return self._getdoubles(self.tk.call(self._w, 'xview'))
- self.tk.call((self._w, 'xview') + what)
- def xview_moveto(self, fraction):
- """Adjusts the view in the window so that FRACTION of the
- total width of the canvas is off-screen to the left."""
- self.tk.call(self._w, 'xview', 'moveto', fraction)
- def xview_scroll(self, number, what):
- """Shift the x-view according to NUMBER which is measured
- in "units" or "pages" (WHAT)."""
- self.tk.call(self._w, 'xview', 'scroll', number, what)
- def yview(self, *what):
- """Query and change vertical position of the view."""
- if not what:
- return self._getdoubles(self.tk.call(self._w, 'yview'))
- self.tk.call((self._w, 'yview') + what)
- def yview_moveto(self, fraction):
- """Adjusts the view in the window so that FRACTION of the
- total height of the canvas is off-screen to the top."""
- self.tk.call(self._w, 'yview', 'moveto', fraction)
- def yview_scroll(self, number, what):
- """Shift the y-view according to NUMBER which is measured
- in "units" or "pages" (WHAT)."""
- self.tk.call(self._w, 'yview', 'scroll', number, what)
def yview_pickplace(self, *what):
"""Obsolete function, use see."""
self.tk.call((self._w, 'yview', '-pickplace') + what)
@@ -3331,7 +3290,7 @@ def image_names(): return _default_root.tk.call('image', 'names')
def image_types(): return _default_root.tk.call('image', 'types')
-class Spinbox(Widget):
+class Spinbox(Widget, XView):
"""spinbox widget."""
def __init__(self, master=None, cnf={}, **kw):
"""Construct a spinbox widget with the parent MASTER.
diff --git a/Lib/tkinter/__main__.py b/Lib/tkinter/__main__.py
new file mode 100644
index 0000000000..757880d439
--- /dev/null
+++ b/Lib/tkinter/__main__.py
@@ -0,0 +1,7 @@
+"""Main entry point"""
+
+import sys
+if sys.argv[0].endswith("__main__.py"):
+ sys.argv[0] = "python -m tkinter"
+from . import _test as main
+main()
diff --git a/Lib/tkinter/font.py b/Lib/tkinter/font.py
index 1ec760ee88..5425b06013 100644
--- a/Lib/tkinter/font.py
+++ b/Lib/tkinter/font.py
@@ -97,7 +97,7 @@ class Font:
return self.name
def __eq__(self, other):
- return self.name == other.name and isinstance(other, Font)
+ return isinstance(other, Font) and self.name == other.name
def __getitem__(self, key):
return self.cget(key)
diff --git a/Lib/tkinter/scrolledtext.py b/Lib/tkinter/scrolledtext.py
index d9af67c1a2..9aa936ae94 100644
--- a/Lib/tkinter/scrolledtext.py
+++ b/Lib/tkinter/scrolledtext.py
@@ -27,8 +27,11 @@ class ScrolledText(Text):
self.pack(side=LEFT, fill=BOTH, expand=True)
self.vbar['command'] = self.yview
- # Copy geometry methods of self.frame -- hack!
- methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()
+ # Copy geometry methods of self.frame without overriding Text
+ # methods -- hack!
+ text_meths = vars(Text).keys()
+ methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
+ methods = methods.difference(text_meths)
for m in methods:
if m[0] != '_' and m != 'config' and m != 'configure':
diff --git a/Lib/tkinter/test/test_tkinter/test_font.py b/Lib/tkinter/test/test_tkinter/test_font.py
new file mode 100644
index 0000000000..dfd630b4de
--- /dev/null
+++ b/Lib/tkinter/test/test_tkinter/test_font.py
@@ -0,0 +1,33 @@
+import unittest
+import tkinter
+from tkinter import font
+from test.support import requires, run_unittest
+import tkinter.test.support as support
+
+requires('gui')
+
+class FontTest(unittest.TestCase):
+
+ def setUp(self):
+ support.root_deiconify()
+
+ def tearDown(self):
+ support.root_withdraw()
+
+ def test_font_eq(self):
+ fontname = "TkDefaultFont"
+ try:
+ f = font.Font(name=fontname, exists=True)
+ except tkinter._tkinter.TclError:
+ f = font.Font(name=fontname, exists=False)
+ font1 = font.nametofont(fontname)
+ font2 = font.nametofont(fontname)
+ self.assertIsNot(font1, font2)
+ self.assertEqual(font1, font2)
+ self.assertNotEqual(font1, font1.copy())
+ self.assertNotEqual(font1, 0)
+
+tests_gui = (FontTest, )
+
+if __name__ == "__main__":
+ run_unittest(*tests_gui)
diff --git a/Lib/tkinter/test/test_tkinter/test_loadtk.py b/Lib/tkinter/test/test_tkinter/test_loadtk.py
index 8f1a085b6d..bab7bcd37c 100644
--- a/Lib/tkinter/test/test_tkinter/test_loadtk.py
+++ b/Lib/tkinter/test/test_tkinter/test_loadtk.py
@@ -31,7 +31,8 @@ class TkLoadTest(unittest.TestCase):
# doesn't actually carry through to the process level
# because they don't support unsetenv
# If that's the case, abort.
- display = os.popen('echo $DISPLAY').read().strip()
+ with os.popen('echo $DISPLAY') as pipe:
+ display = pipe.read().strip()
if display:
return
diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py
index 35824eae1f..cd00a61f85 100644
--- a/Lib/tkinter/test/test_ttk/test_widgets.py
+++ b/Lib/tkinter/test/test_ttk/test_widgets.py
@@ -1,5 +1,6 @@
import unittest
import tkinter
+import os
from tkinter import ttk
from test.support import requires, run_unittest
@@ -925,7 +926,8 @@ class TreeviewTest(unittest.TestCase):
self.assertRaises(tkinter.TclError, self.tv.heading, '#0',
anchor=1)
-
+ # XXX skipping for now; should be fixed to work with newer ttk
+ @unittest.skip
def test_heading_callback(self):
def simulate_heading_click(x, y):
support.simulate_mouse_click(self.tv, x, y)
diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py
index b105278b97..be44a09e33 100644
--- a/Lib/tkinter/tix.py
+++ b/Lib/tkinter/tix.py
@@ -46,6 +46,21 @@ BALLOON = 'balloon'
AUTO = 'auto'
ACROSSTOP = 'acrosstop'
+# A few useful constants for the Grid widget
+ASCII = 'ascii'
+CELL = 'cell'
+COLUMN = 'column'
+DECREASING = 'decreasing'
+INCREASING = 'increasing'
+INTEGER = 'integer'
+MAIN = 'main'
+MAX = 'max'
+REAL = 'real'
+ROW = 'row'
+S_REGION = 's-region'
+X_REGION = 'x-region'
+Y_REGION = 'y-region'
+
# Some constants used by Tkinter dooneevent()
TCL_DONT_WAIT = 1 << 1
TCL_WINDOW_EVENTS = 1 << 2
@@ -850,7 +865,7 @@ class FileEntry(TixWidget):
# FIXME: return python object
pass
-class HList(TixWidget):
+class HList(TixWidget, XView, YView):
"""HList - Hierarchy display widget can be used to display any data
that have a hierarchical structure, for example, file system directory
trees. The list entries are indented and connected by branch lines
@@ -961,6 +976,10 @@ class HList(TixWidget):
def info_anchor(self):
return self.tk.call(self._w, 'info', 'anchor')
+ def info_bbox(self, entry):
+ return self._getints(
+ self.tk.call(self._w, 'info', 'bbox', entry)) or None
+
def info_children(self, entry=None):
c = self.tk.call(self._w, 'info', 'children', entry)
return self.tk.splitlist(c)
@@ -968,6 +987,12 @@ class HList(TixWidget):
def info_data(self, entry):
return self.tk.call(self._w, 'info', 'data', entry)
+ def info_dragsite(self):
+ return self.tk.call(self._w, 'info', 'dragsite')
+
+ def info_dropsite(self):
+ return self.tk.call(self._w, 'info', 'dropsite')
+
def info_exists(self, entry):
return self.tk.call(self._w, 'info', 'exists', entry)
@@ -1037,12 +1062,6 @@ class HList(TixWidget):
def show_entry(self, entry):
return self.tk.call(self._w, 'show', 'entry', entry)
- def xview(self, *args):
- self.tk.call(self._w, 'xview', *args)
-
- def yview(self, *args):
- self.tk.call(self._w, 'yview', *args)
-
class InputOnly(TixWidget):
"""InputOnly - Invisible widget. Unix only.
@@ -1241,11 +1260,8 @@ class PanedWindow(TixWidget):
self.tk.call(self._w, 'paneconfigure', entry, *self._options(cnf, kw))
def panes(self):
- names = self.tk.call(self._w, 'panes')
- ret = []
- for x in names:
- ret.append(self.subwidget(x))
- return ret
+ names = self.tk.splitlist(self.tk.call(self._w, 'panes'))
+ return [self.subwidget(x) for x in names]
class PopupMenu(TixWidget):
"""PopupMenu widget can be used as a replacement of the tk_popup command.
@@ -1419,7 +1435,7 @@ class StdButtonBox(TixWidget):
if name in self.subwidget_list:
self.tk.call(self._w, 'invoke', name)
-class TList(TixWidget):
+class TList(TixWidget, XView, YView):
"""TList - Hierarchy display widget which can be
used to display data in a tabular format. The list entries of a TList
widget are similar to the entries in the Tk listbox widget. The main
@@ -1502,12 +1518,6 @@ class TList(TixWidget):
def selection_set(self, first, last=None):
self.tk.call(self._w, 'selection', 'set', first, last)
- def xview(self, *args):
- self.tk.call(self._w, 'xview', *args)
-
- def yview(self, *args):
- self.tk.call(self._w, 'yview', *args)
-
class Tree(TixWidget):
"""Tree - The tixTree widget can be used to display hierarchical
data in a tree form. The user can adjust
@@ -1563,7 +1573,7 @@ class CheckList(TixWidget):
# FIXME: It should inherit -superclass tixTree
def __init__(self, master=None, cnf={}, **kw):
TixWidget.__init__(self, master, 'tixCheckList',
- ['options'], cnf, kw)
+ ['options', 'radio'], cnf, kw)
self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
@@ -1777,7 +1787,7 @@ class CObjView(TixWidget):
pass
-class Grid(TixWidget):
+class Grid(TixWidget, XView, YView):
'''The Tix Grid command creates a new window and makes it into a
tixGrid widget. Additional options, may be specified on the command
line or in the option database to configure aspects such as its cursor
@@ -1801,16 +1811,21 @@ class Grid(TixWidget):
TixWidget.__init__(self, master, 'tixGrid', static, cnf, kw)
# valid options as of Tk 8.4
- # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, edit
- # entryconfigure, format, geometryinfo, info, index, move, nearest, selection
- # set, size, unset, xview, yview
- # def anchor option ?args ...?
+ # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget,
+ # edit, entryconfigure, format, geometryinfo, info, index, move, nearest,
+ # selection, set, size, unset, xview, yview
+ def anchor_clear(self):
+ """Removes the selection anchor."""
+ self.tk.call(self, 'anchor', 'clear')
+
def anchor_get(self):
"Get the (x,y) coordinate of the current anchor cell"
return self._getints(self.tk.call(self, 'anchor', 'get'))
- # def bdtype
- # def delete dim from ?to?
+ def anchor_set(self, x, y):
+ """Set the selection anchor to the cell at (x, y)."""
+ self.tk.call(self, 'anchor', 'set', x, y)
+
def delete_row(self, from_, to=None):
"""Delete rows between from_ and to inclusive.
If to is not provided, delete only row at from_"""
@@ -1818,6 +1833,7 @@ class Grid(TixWidget):
self.tk.call(self, 'delete', 'row', from_)
else:
self.tk.call(self, 'delete', 'row', from_, to)
+
def delete_column(self, from_, to=None):
"""Delete columns between from_ and to inclusive.
If to is not provided, delete only column at from_"""
@@ -1825,26 +1841,49 @@ class Grid(TixWidget):
self.tk.call(self, 'delete', 'column', from_)
else:
self.tk.call(self, 'delete', 'column', from_, to)
- # def edit apply
- # def edit set x y
+
+ def edit_apply(self):
+ """If any cell is being edited, de-highlight the cell and applies
+ the changes."""
+ self.tk.call(self, 'edit', 'apply')
+
+ def edit_set(self, x, y):
+ """Highlights the cell at (x, y) for editing, if the -editnotify
+ command returns True for this cell."""
+ self.tk.call(self, 'edit', 'set', x, y)
def entrycget(self, x, y, option):
"Get the option value for cell at (x,y)"
+ if option and option[0] != '-':
+ option = '-' + option
return self.tk.call(self, 'entrycget', x, y, option)
- def entryconfigure(self, x, y, **kw):
- return self.tk.call(self, 'entryconfigure', x, y, *self._options(None, kw))
+ def entryconfigure(self, x, y, cnf=None, **kw):
+ return self._configure(('entryconfigure', x, y), cnf, kw)
+
# def format
# def index
def info_exists(self, x, y):
"Return True if display item exists at (x,y)"
- return bool(int(self.tk.call(self, 'info', 'exists', x, y)))
+ return self._getboolean(self.tk.call(self, 'info', 'exists', x, y))
def info_bbox(self, x, y):
# This seems to always return '', at least for 'text' displayitems
return self.tk.call(self, 'info', 'bbox', x, y)
+ def move_column(self, from_, to, offset):
+ """Moves the the range of columns from position FROM through TO by
+ the distance indicated by OFFSET. For example, move_column(2, 4, 1)
+ moves the columns 2,3,4 to columns 3,4,5."""
+ self.tk.call(self, 'move', 'column', from_, to, offset)
+
+ def move_row(self, from_, to, offset):
+ """Moves the the range of rows from position FROM through TO by
+ the distance indicated by OFFSET.
+ For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5."""
+ self.tk.call(self, 'move', 'row', from_, to, offset)
+
def nearest(self, x, y):
"Return coordinate of cell nearest pixel coordinate (x,y)"
return self._getints(self.tk.call(self, 'nearest', x, y))
@@ -1854,7 +1893,6 @@ class Grid(TixWidget):
# def selection includes
# def selection set
# def selection toggle
- # def move dim from to offset
def set(self, x, y, itemtype=None, **kw):
args= self._options(self.cnf, kw)
@@ -1862,24 +1900,59 @@ class Grid(TixWidget):
args= ('-itemtype', itemtype) + args
self.tk.call(self, 'set', x, y, *args)
- # def size dim index ?option value ...?
- # def unset x y
-
- def xview(self):
- return self._getdoubles(self.tk.call(self, 'xview'))
- def xview_moveto(self, fraction):
- self.tk.call(self,'xview', 'moveto', fraction)
- def xview_scroll(self, count, what="units"):
- "Scroll right (count>0) or left <count> of units|pages"
- self.tk.call(self, 'xview', 'scroll', count, what)
-
- def yview(self):
- return self._getdoubles(self.tk.call(self, 'yview'))
- def yview_moveto(self, fraction):
- self.tk.call(self,'ysview', 'moveto', fraction)
- def yview_scroll(self, count, what="units"):
- "Scroll down (count>0) or up <count> of units|pages"
- self.tk.call(self, 'yview', 'scroll', count, what)
+ def size_column(self, index, **kw):
+ """Queries or sets the size of the column given by
+ INDEX. INDEX may be any non-negative
+ integer that gives the position of a given column.
+ INDEX can also be the string "default"; in this case, this command
+ queries or sets the default size of all columns.
+ When no option-value pair is given, this command returns a tuple
+ containing the current size setting of the given column. When
+ option-value pairs are given, the corresponding options of the
+ size setting of the given column are changed. Options may be one
+ of the follwing:
+ pad0 pixels
+ Specifies the paddings to the left of a column.
+ pad1 pixels
+ Specifies the paddings to the right of a column.
+ size val
+ Specifies the width of a column .
+ Val may be: "auto" -- the width of the column is set the
+ the widest cell in the column; a valid Tk screen distance
+ unit; or a real number following by the word chars
+ (e.g. 3.4chars) that sets the width of the column to the
+ given number of characters."""
+ return self.tk.split(self.tk.call(self._w, 'size', 'column', index,
+ *self._options({}, kw)))
+
+ def size_row(self, index, **kw):
+ """Queries or sets the size of the row given by
+ INDEX. INDEX may be any non-negative
+ integer that gives the position of a given row .
+ INDEX can also be the string "default"; in this case, this command
+ queries or sets the default size of all rows.
+ When no option-value pair is given, this command returns a list con-
+ taining the current size setting of the given row . When option-value
+ pairs are given, the corresponding options of the size setting of the
+ given row are changed. Options may be one of the follwing:
+ pad0 pixels
+ Specifies the paddings to the top of a row.
+ pad1 pixels
+ Specifies the paddings to the the bottom of a row.
+ size val
+ Specifies the height of a row.
+ Val may be: "auto" -- the height of the row is set the
+ the highest cell in the row; a valid Tk screen distance
+ unit; or a real number following by the word chars
+ (e.g. 3.4chars) that sets the height of the row to the
+ given number of characters."""
+ return self.tk.split(self.tk.call(
+ self, 'size', 'row', index, *self._options({}, kw)))
+
+ def unset(self, x, y):
+ """Clears the cell at (x, y) by removing its display item."""
+ self.tk.call(self._w, 'unset', x, y)
+
class ScrolledGrid(Grid):
'''Scrolled Grid widgets'''
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
index 9213b62bc7..1a6a9f46d0 100644
--- a/Lib/tkinter/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -1170,7 +1170,7 @@ class Sizegrip(Widget):
Widget.__init__(self, master, "ttk::sizegrip", kw)
-class Treeview(Widget):
+class Treeview(Widget, tkinter.XView, tkinter.YView):
"""Ttk Treeview widget displays a hierarchical collection of items.
Each item has a textual label, an optional image, and an optional list
@@ -1480,16 +1480,6 @@ class Treeview(Widget):
return self.tk.call(self._w, "tag", "has", tagname, item)
- def xview(self, *args):
- """Query or modify horizontal position of the treeview."""
- return self.tk.call(self._w, "xview", *args)
-
-
- def yview(self, *args):
- """Query or modify vertical position of the treeview."""
- return self.tk.call(self._w, "yview", *args)
-
-
# Extensions
class LabeledScale(Frame):
diff --git a/Lib/token.py b/Lib/token.py
index da4d29b326..7e2bfcfaf2 100755
--- a/Lib/token.py
+++ b/Lib/token.py
@@ -1,7 +1,7 @@
-#! /usr/bin/env python
-
"""Token constants (from "token.h")."""
+__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
+
# This file is automatically generated; please don't muck it up!
#
# To update the symbols in this file, 'cd' to the top directory of
@@ -68,12 +68,10 @@ N_TOKENS = 55
NT_OFFSET = 256
#--end constants--
-tok_name = {}
-for _name, _value in list(globals().items()):
- if type(_value) is type(0):
- tok_name[_value] = _name
-del _name, _value
-
+tok_name = {value: name
+ for name, value in globals().items()
+ if isinstance(value, int)}
+__all__.extend(tok_name.values())
def ISTERMINAL(x):
return x < NT_OFFSET
@@ -85,7 +83,7 @@ def ISEOF(x):
return x == ENDMARKER
-def main():
+def _main():
import re
import sys
args = sys.argv[1:]
@@ -139,4 +137,4 @@ def main():
if __name__ == "__main__":
- main()
+ _main()
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index e711a21f35..f575e9bc23 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -1,12 +1,12 @@
"""Tokenization help for Python programs.
-tokenize(readline) is a generator that breaks a stream of
-bytes into Python tokens. It decodes the bytes according to
-PEP-0263 for determining source file encoding.
+tokenize(readline) is a generator that breaks a stream of bytes into
+Python tokens. It decodes the bytes according to PEP-0263 for
+determining source file encoding.
-It accepts a readline-like method which is called
-repeatedly to get the next line of input (or b"" for EOF). It generates
-5-tuples with these members:
+It accepts a readline-like method which is called repeatedly to get the
+next line of input (or b"" for EOF). It generates 5-tuples with these
+members:
the token type (see token.py)
the token (a string)
@@ -16,22 +16,26 @@ repeatedly to get the next line of input (or b"" for EOF). It generates
It is designed to match the working of the Python tokenizer exactly, except
that it produces COMMENT tokens for comments and gives type OP for all
-operators. Aditionally, all token lists start with an ENCODING token
-which tells you which encoding was used to decode the bytes stream."""
+operators. Additionally, all token lists start with an ENCODING token
+which tells you which encoding was used to decode the bytes stream.
+"""
__author__ = 'Ka-Ping Yee <ping@lfw.org>'
__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
'Michael Foord')
-import re, string, sys
+import builtins
+import re
+import sys
from token import *
from codecs import lookup, BOM_UTF8
+import collections
+from io import TextIOWrapper
cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
import token
-__all__ = [x for x in dir(token) if not x.startswith("_")]
-__all__.extend(["COMMENT", "tokenize", "detect_encoding", "NL", "untokenize",
- "ENCODING", "TokenInfo"])
+__all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding",
+ "NL", "untokenize", "ENCODING", "TokenInfo"]
del token
COMMENT = N_TOKENS
@@ -42,46 +46,11 @@ ENCODING = N_TOKENS + 2
tok_name[ENCODING] = 'ENCODING'
N_TOKENS += 3
-class TokenInfo(tuple):
- 'TokenInfo(type, string, start, end, line)'
-
- __slots__ = ()
-
- _fields = ('type', 'string', 'start', 'end', 'line')
-
- def __new__(cls, type, string, start, end, line):
- return tuple.__new__(cls, (type, string, start, end, line))
-
- @classmethod
- def _make(cls, iterable, new=tuple.__new__, len=len):
- 'Make a new TokenInfo object from a sequence or iterable'
- result = new(cls, iterable)
- if len(result) != 5:
- raise TypeError('Expected 5 arguments, got %d' % len(result))
- return result
-
+class TokenInfo(collections.namedtuple('TokenInfo', 'type string start end line')):
def __repr__(self):
- return 'TokenInfo(type=%r, string=%r, start=%r, end=%r, line=%r)' % self
-
- def _asdict(self):
- 'Return a new dict which maps field names to their values'
- return dict(zip(self._fields, self))
-
- def _replace(self, **kwds):
- 'Return a new TokenInfo object replacing specified fields with new values'
- result = self._make(map(kwds.pop, ('type', 'string', 'start', 'end', 'line'), self))
- if kwds:
- raise ValueError('Got unexpected field names: %r' % kwds.keys())
- return result
-
- def __getnewargs__(self):
- return tuple(self)
-
- type = property(lambda t: t[0])
- string = property(lambda t: t[1])
- start = property(lambda t: t[2])
- end = property(lambda t: t[3])
- line = property(lambda t: t[4])
+ annotated_type = '%d (%s)' % (self.type, tok_name[self.type])
+ return ('TokenInfo(type=%s, string=%r, start=%r, end=%r, line=%r)' %
+ self._replace(type=annotated_type))
def group(*choices): return '(' + '|'.join(choices) + ')'
def any(*choices): return group(*choices) + '*'
@@ -298,22 +267,23 @@ def _get_normal_name(orig_enc):
def detect_encoding(readline):
"""
The detect_encoding() function is used to detect the encoding that should
- be used to decode a Python source file. It requires one argment, readline,
+ be used to decode a Python source file. It requires one argment, readline,
in the same way as the tokenize() generator.
It will call readline a maximum of twice, and return the encoding used
- (as a string) and a list of any lines (left as bytes) it has read
- in.
+ (as a string) and a list of any lines (left as bytes) it has read in.
It detects the encoding from the presence of a utf-8 bom or an encoding
- cookie as specified in pep-0263. If both a bom and a cookie are present,
- but disagree, a SyntaxError will be raised. If the encoding cookie is an
- invalid charset, raise a SyntaxError.
+ cookie as specified in pep-0263. If both a bom and a cookie are present,
+ but disagree, a SyntaxError will be raised. If the encoding cookie is an
+ invalid charset, raise a SyntaxError. Note that if a utf-8 bom is found,
+ 'utf-8-sig' is returned.
If no encoding is specified, then the default of 'utf-8' will be returned.
"""
bom_found = False
encoding = None
+ default = 'utf-8'
def read_or_stop():
try:
return readline()
@@ -336,17 +306,20 @@ def detect_encoding(readline):
# This behaviour mimics the Python interpreter
raise SyntaxError("unknown encoding: " + encoding)
- if bom_found and codec.name != 'utf-8':
- # This behaviour mimics the Python interpreter
- raise SyntaxError('encoding problem: utf-8')
+ if bom_found:
+ if codec.name != 'utf-8':
+ # This behaviour mimics the Python interpreter
+ raise SyntaxError('encoding problem: utf-8')
+ encoding += '-sig'
return encoding
first = read_or_stop()
if first.startswith(BOM_UTF8):
bom_found = True
first = first[3:]
+ default = 'utf-8-sig'
if not first:
- return 'utf-8', []
+ return default, []
encoding = find_cookie(first)
if encoding:
@@ -354,20 +327,32 @@ def detect_encoding(readline):
second = read_or_stop()
if not second:
- return 'utf-8', [first]
+ return default, [first]
encoding = find_cookie(second)
if encoding:
return encoding, [first, second]
- return 'utf-8', [first, second]
+ return default, [first, second]
+
+
+def open(filename):
+ """Open a file in read only mode using the encoding detected by
+ detect_encoding().
+ """
+ buffer = builtins.open(filename, 'rb')
+ encoding, lines = detect_encoding(buffer.readline)
+ buffer.seek(0)
+ text = TextIOWrapper(buffer, encoding, line_buffering=True)
+ text.mode = 'r'
+ return text
def tokenize(readline):
"""
The tokenize() generator requires one argment, readline, which
must be a callable object which provides the same interface as the
- readline() method of built-in file objects. Each call to the function
+ readline() method of built-in file objects. Each call to the function
should return one line of input as bytes. Alternately, readline
can be a callable function terminating with StopIteration:
readline = open(myfile, 'rb').__next__ # Example of alternate readline
@@ -376,23 +361,19 @@ def tokenize(readline):
token string; a 2-tuple (srow, scol) of ints specifying the row and
column where the token begins in the source; a 2-tuple (erow, ecol) of
ints specifying the row and column where the token ends in the source;
- and the line on which the token was found. The line passed is the
+ and the line on which the token was found. The line passed is the
logical line; continuation lines are included.
The first token sequence will always be an ENCODING token
which tells you which encoding was used to decode the bytes stream.
"""
+ # This import is here to avoid problems when the itertools module is not
+ # built yet and tokenize is imported.
+ from itertools import chain, repeat
encoding, consumed = detect_encoding(readline)
- def readline_generator(consumed):
- for line in consumed:
- yield line
- while True:
- try:
- yield readline()
- except StopIteration:
- return
- chained = readline_generator(consumed)
- return _tokenize(chained.__next__, encoding)
+ rl_gen = iter(readline, b"")
+ empty = repeat(b"")
+ return _tokenize(chain(consumed, rl_gen, empty).__next__, encoding)
def _tokenize(readline, encoding):
@@ -403,6 +384,9 @@ def _tokenize(readline, encoding):
indents = [0]
if encoding is not None:
+ if encoding == "utf-8-sig":
+ # BOM will already have been stripped.
+ encoding = "utf-8"
yield TokenInfo(ENCODING, encoding, (0, 0), (0, 0), '')
while True: # loop over lines in stream
try:
@@ -545,3 +529,28 @@ def _tokenize(readline, encoding):
# library that expect to be able to use tokenize with strings
def generate_tokens(readline):
return _tokenize(readline, None)
+
+if __name__ == "__main__":
+ # Quick sanity check
+ s = b'''def parseline(self, line):
+ """Parse the line into a command name and a string containing
+ the arguments. Returns a tuple containing (command, args, line).
+ 'command' and 'args' may be None if the line couldn't be parsed.
+ """
+ line = line.strip()
+ if not line:
+ return None, None, line
+ elif line[0] == '?':
+ line = 'help ' + line[1:]
+ elif line[0] == '!':
+ if hasattr(self, 'do_shell'):
+ line = 'shell ' + line[1:]
+ else:
+ return None, None, line
+ i, n = 0, len(line)
+ while i < n and line[i] in self.identchars: i = i+1
+ cmd, arg = line[:i], line[i:].strip()
+ return cmd, arg, line
+ '''
+ for tok in tokenize(iter(s.splitlines()).__next__):
+ print(tok)
diff --git a/Lib/trace.py b/Lib/trace.py
index c01935f246..53c6150fd4 100644
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# portions copyright 2001, Autonomous Zones Industries, Inc., all rights...
# err... reserved and offered to the public under the terms of the
@@ -47,7 +47,7 @@ Sample use, programmatically
r = tracer.results()
r.write_results(show_missing=True, coverdir="/tmp")
"""
-
+__all__ = ['Trace', 'CoverageResults']
import io
import linecache
import os
@@ -60,6 +60,7 @@ import inspect
import gc
import dis
import pickle
+from warnings import warn as _warn
try:
import threading
@@ -77,7 +78,7 @@ else:
sys.settrace(None)
threading.settrace(None)
-def usage(outfile):
+def _usage(outfile):
outfile.write("""Usage: %s [OPTIONS] <file> [ARGS]
Meta-options:
@@ -127,12 +128,11 @@ PRAGMA_NOCOVER = "#pragma NO COVER"
# Simple rx to find lines with no code.
rx_blank = re.compile(r'^\s*(#.*)?$')
-class Ignore:
- def __init__(self, modules = None, dirs = None):
- self._mods = modules or []
- self._dirs = dirs or []
-
- self._dirs = list(map(os.path.normpath, self._dirs))
+class _Ignore:
+ def __init__(self, modules=None, dirs=None):
+ self._mods = set() if not modules else set(modules)
+ self._dirs = [] if not dirs else [os.path.normpath(d)
+ for d in dirs]
self._ignore = { '<string>': 1 }
def names(self, filename, modulename):
@@ -140,24 +140,22 @@ class Ignore:
return self._ignore[modulename]
# haven't seen this one before, so see if the module name is
- # on the ignore list. Need to take some care since ignoring
- # "cmp" musn't mean ignoring "cmpcache" but ignoring
- # "Spam" must also mean ignoring "Spam.Eggs".
+ # on the ignore list.
+ if modulename in self._mods: # Identical names, so ignore
+ self._ignore[modulename] = 1
+ return 1
+
+ # check if the module is a proper submodule of something on
+ # the ignore list
for mod in self._mods:
- if mod == modulename: # Identical names, so ignore
- self._ignore[modulename] = 1
- return 1
- # check if the module is a proper submodule of something on
- # the ignore list
- n = len(mod)
- # (will not overflow since if the first n characters are the
- # same and the name has not already occurred, then the size
- # of "name" is greater than that of "mod")
- if mod == modulename[:n] and modulename[n] == '.':
+ # Need to take some care since ignoring
+ # "cmp" mustn't mean ignoring "cmpcache" but ignoring
+ # "Spam" must also mean ignoring "Spam.Eggs".
+ if modulename.startswith(mod + '.'):
self._ignore[modulename] = 1
return 1
- # Now check that __file__ isn't in one of the directories
+ # Now check that filename isn't in one of the directories
if filename is None:
# must be a built-in, so we must ignore
self._ignore[modulename] = 1
@@ -180,14 +178,14 @@ class Ignore:
self._ignore[modulename] = 0
return 0
-def modname(path):
+def _modname(path):
"""Return a plausible module name for the patch."""
base = os.path.basename(path)
filename, ext = os.path.splitext(base)
return filename
-def fullmodname(path):
+def _fullmodname(path):
"""Return a plausible module name for the path."""
# If the file 'path' is part of a package, then the filename isn't
@@ -258,13 +256,13 @@ class CoverageResults:
other_calledfuncs = other.calledfuncs
other_callers = other.callers
- for key in other_counts.keys():
+ for key in other_counts:
counts[key] = counts.get(key, 0) + other_counts[key]
- for key in other_calledfuncs.keys():
+ for key in other_calledfuncs:
calledfuncs[key] = 1
- for key in other_callers.keys():
+ for key in other_callers:
callers[key] = 1
def write_results(self, show_missing=True, summary=False, coverdir=None):
@@ -274,7 +272,7 @@ class CoverageResults:
if self.calledfuncs:
print()
print("functions called:")
- calls = self.calledfuncs.keys()
+ calls = self.calledfuncs
for filename, modulename, funcname in sorted(calls):
print(("filename: %s, modulename: %s, funcname: %s"
% (filename, modulename, funcname)))
@@ -284,7 +282,7 @@ class CoverageResults:
print("calling relationships:")
lastfile = lastcfile = ""
for ((pfile, pmod, pfunc), (cfile, cmod, cfunc)) \
- in sorted(self.callers.keys()):
+ in sorted(self.callers):
if pfile != lastfile:
print()
print("***", pfile, "***")
@@ -298,7 +296,7 @@ class CoverageResults:
# turn the counts data ("(filename, lineno) = count") into something
# accessible on a per-file basis
per_file = {}
- for filename, lineno in self.counts.keys():
+ for filename, lineno in self.counts:
lines_hit = per_file[filename] = per_file.get(filename, {})
lines_hit[lineno] = self.counts[(filename, lineno)]
@@ -314,32 +312,33 @@ class CoverageResults:
if coverdir is None:
dir = os.path.dirname(os.path.abspath(filename))
- modulename = modname(filename)
+ modulename = _modname(filename)
else:
dir = coverdir
if not os.path.exists(dir):
os.makedirs(dir)
- modulename = fullmodname(filename)
+ modulename = _fullmodname(filename)
# If desired, get a list of the line numbers which represent
# executable content (returned as a dict for better lookup speed)
if show_missing:
- lnotab = find_executable_linenos(filename)
+ lnotab = _find_executable_linenos(filename)
else:
lnotab = {}
source = linecache.getlines(filename)
coverpath = os.path.join(dir, modulename + ".cover")
+ with open(filename, 'rb') as fp:
+ encoding, _ = tokenize.detect_encoding(fp.readline)
n_hits, n_lines = self.write_results_file(coverpath, source,
- lnotab, count)
-
+ lnotab, count, encoding)
if summary and n_lines:
percent = int(100 * n_hits / n_lines)
sums[modulename] = n_lines, percent, modulename, filename
if summary and sums:
print("lines cov% module (path)")
- for m in sorted(sums.keys()):
+ for m in sorted(sums):
n_lines, percent, modulename, filename = sums[m]
print("%5d %3d%% %s (%s)" % sums[m])
@@ -351,11 +350,11 @@ class CoverageResults:
except IOError as err:
print("Can't save counts files because %s" % err, file=sys.stderr)
- def write_results_file(self, path, lines, lnotab, lines_hit):
+ def write_results_file(self, path, lines, lnotab, lines_hit, encoding=None):
"""Return a coverage results file in path."""
try:
- outfile = open(path, "w")
+ outfile = open(path, "w", encoding=encoding)
except IOError as err:
print(("trace: Could not open %r for writing: %s"
"- skipping" % (path, err)), file=sys.stderr)
@@ -363,8 +362,7 @@ class CoverageResults:
n_lines = 0
n_hits = 0
- for i, line in enumerate(lines):
- lineno = i + 1
+ for lineno, line in enumerate(lines, 1):
# do the blank/comment match to try to mark more lines
# (help the reader find stuff that hasn't been covered)
if lineno in lines_hit:
@@ -377,17 +375,17 @@ class CoverageResults:
# lines preceded by no marks weren't hit
# Highlight them if so indicated, unless the line contains
# #pragma: NO COVER
- if lineno in lnotab and not PRAGMA_NOCOVER in lines[i]:
+ if lineno in lnotab and not PRAGMA_NOCOVER in line:
outfile.write(">>>>>> ")
n_lines += 1
else:
outfile.write(" ")
- outfile.write(lines[i].expandtabs(8))
+ outfile.write(line.expandtabs(8))
outfile.close()
return n_hits, n_lines
-def find_lines_from_code(code, strs):
+def _find_lines_from_code(code, strs):
"""Return dict where keys are lines in the line number table."""
linenos = {}
@@ -397,19 +395,19 @@ def find_lines_from_code(code, strs):
return linenos
-def find_lines(code, strs):
+def _find_lines(code, strs):
"""Return lineno dict for all code objects reachable from code."""
# get all of the lineno information from the code of this scope level
- linenos = find_lines_from_code(code, strs)
+ linenos = _find_lines_from_code(code, strs)
# and check the constants for references to other code objects
for c in code.co_consts:
if inspect.iscode(c):
# find another code object, so recurse into it
- linenos.update(find_lines(c, strs))
+ linenos.update(_find_lines(c, strs))
return linenos
-def find_strings(filename, encoding=None):
+def _find_strings(filename, encoding=None):
"""Return a dict of possible docstring positions.
The dict maps line numbers to strings. There is an entry for
@@ -420,31 +418,31 @@ def find_strings(filename, encoding=None):
# If the first token is a string, then it's the module docstring.
# Add this special case so that the test in the loop passes.
prev_ttype = token.INDENT
- f = open(filename, encoding=encoding)
- for ttype, tstr, start, end, line in tokenize.generate_tokens(f.readline):
- if ttype == token.STRING:
- if prev_ttype == token.INDENT:
- sline, scol = start
- eline, ecol = end
- for i in range(sline, eline + 1):
- d[i] = 1
- prev_ttype = ttype
- f.close()
+ with open(filename, encoding=encoding) as f:
+ tok = tokenize.generate_tokens(f.readline)
+ for ttype, tstr, start, end, line in tok:
+ if ttype == token.STRING:
+ if prev_ttype == token.INDENT:
+ sline, scol = start
+ eline, ecol = end
+ for i in range(sline, eline + 1):
+ d[i] = 1
+ prev_ttype = ttype
return d
-def find_executable_linenos(filename):
+def _find_executable_linenos(filename):
"""Return dict where keys are line numbers in the line number table."""
try:
- with io.FileIO(filename, 'r') as file:
- encoding, lines = tokenize.detect_encoding(file.readline)
- prog = open(filename, "r", encoding=encoding).read()
+ with tokenize.open(filename) as f:
+ prog = f.read()
+ encoding = f.encoding
except IOError as err:
print(("Not printing coverage data for %r: %s"
% (filename, err)), file=sys.stderr)
return {}
code = compile(prog, filename, "exec")
- strs = find_strings(filename, encoding)
- return find_lines(code, strs)
+ strs = _find_strings(filename, encoding)
+ return _find_lines(code, strs)
class Trace:
def __init__(self, count=1, trace=1, countfuncs=0, countcallers=0,
@@ -469,9 +467,8 @@ class Trace:
"""
self.infile = infile
self.outfile = outfile
- self.ignore = Ignore(ignoremods, ignoredirs)
+ self.ignore = _Ignore(ignoremods, ignoredirs)
self.counts = {} # keys are (filename, linenumber)
- self.blabbed = {} # for debugging
self.pathtobasename = {} # for memoizing os.path.basename
self.donothing = 0
self.trace = trace
@@ -501,15 +498,7 @@ class Trace:
def run(self, cmd):
import __main__
dict = __main__.__dict__
- if not self.donothing:
- threading.settrace(self.globaltrace)
- sys.settrace(self.globaltrace)
- try:
- exec(cmd, dict, dict)
- finally:
- if not self.donothing:
- sys.settrace(None)
- threading.settrace(None)
+ self.runctx(cmd, dict, dict)
def runctx(self, cmd, globals=None, locals=None):
if globals is None: globals = {}
@@ -537,7 +526,7 @@ class Trace:
code = frame.f_code
filename = code.co_filename
if filename:
- modulename = modname(filename)
+ modulename = _modname(filename)
else:
modulename = None
@@ -604,9 +593,9 @@ class Trace:
code = frame.f_code
filename = frame.f_globals.get('__file__', None)
if filename:
- # XXX modname() doesn't work right for packages, so
+ # XXX _modname() doesn't work right for packages, so
# the ignore support won't work right for packages
- modulename = modname(filename)
+ modulename = _modname(filename)
if modulename is not None:
ignore_it = self.ignore.names(filename, modulename)
if not ignore_it:
@@ -822,5 +811,47 @@ def main(argv=None):
if not no_report:
results.write_results(missing, summary=summary, coverdir=coverdir)
+# Deprecated API
+def usage(outfile):
+ _warn("The trace.usage() function is deprecated",
+ DeprecationWarning, 2)
+ _usage(outfile)
+
+class Ignore(_Ignore):
+ def __init__(self, modules=None, dirs=None):
+ _warn("The class trace.Ignore is deprecated",
+ DeprecationWarning, 2)
+ _Ignore.__init__(self, modules, dirs)
+
+def modname(path):
+ _warn("The trace.modname() function is deprecated",
+ DeprecationWarning, 2)
+ return _modname(path)
+
+def fullmodname(path):
+ _warn("The trace.fullmodname() function is deprecated",
+ DeprecationWarning, 2)
+ return _fullmodname(path)
+
+def find_lines_from_code(code, strs):
+ _warn("The trace.find_lines_from_code() function is deprecated",
+ DeprecationWarning, 2)
+ return _find_lines_from_code(code, strs)
+
+def find_lines(code, strs):
+ _warn("The trace.find_lines() function is deprecated",
+ DeprecationWarning, 2)
+ return _find_lines(code, strs)
+
+def find_strings(filename, encoding=None):
+ _warn("The trace.find_strings() function is deprecated",
+ DeprecationWarning, 2)
+ return _find_strings(filename, encoding=None)
+
+def find_executable_linenos(filename):
+ _warn("The trace.find_executable_linenos() function is deprecated",
+ DeprecationWarning, 2)
+ return _find_executable_linenos(filename)
+
if __name__=='__main__':
main()
diff --git a/Lib/turtle.py b/Lib/turtle.py
index 0c439f1e3b..2ff54278e2 100644
--- a/Lib/turtle.py
+++ b/Lib/turtle.py
@@ -109,6 +109,7 @@ import types
import math
import time
import os
+import inspect
from os.path import isfile, split, join
from copy import deepcopy
@@ -169,9 +170,8 @@ _CFG = {"width" : 0.5, # Screen
def config_dict(filename):
"""Convert content of config-file into dictionary."""
- f = open(filename, "r")
- cfglines = f.readlines()
- f.close()
+ with open(filename, "r") as f:
+ cfglines = f.readlines()
cfgdict = {}
for line in cfglines:
line = line.strip()
@@ -3147,7 +3147,7 @@ class RawTurtle(TPen, TNavigator):
if pen is down. All other methodes for turtle movement depend
on this one.
"""
- ## Version mit undo-stuff
+ ## Version with undo-stuff
go_modes = ( self._drawing,
self._pencolor,
self._pensize,
@@ -3893,31 +3893,35 @@ except:
def getmethparlist(ob):
- "Get strings describing the arguments for the given object"
- argText1 = argText2 = ""
+ """Get strings describing the arguments for the given object
+
+ Returns a pair of strings representing function parameter lists
+ including parenthesis. The first string is suitable for use in
+ function definition and the second is suitable for use in function
+ call. The "self" parameter is not included.
+ """
+ defText = callText = ""
# bit of a hack for methods - turn it into a function
# but we drop the "self" param.
# Try and build one for Python defined functions
- argOffset = 1
- counter = ob.__code__.co_argcount
- items2 = list(ob.__code__.co_varnames[argOffset:counter])
- realArgs = ob.__code__.co_varnames[argOffset:counter]
+ args, varargs, varkw = inspect.getargs(ob.__code__)
+ items2 = args[1:]
+ realArgs = args[1:]
defaults = ob.__defaults__ or []
- defaults = list(map(lambda name: "=%s" % repr(name), defaults))
+ defaults = ["=%r" % (value,) for value in defaults]
defaults = [""] * (len(realArgs)-len(defaults)) + defaults
- items1 = list(map(lambda arg, dflt: arg+dflt, realArgs, defaults))
- if ob.__code__.co_flags & 0x4:
- items1.append("*"+ob.__code__.co_varnames[counter])
- items2.append("*"+ob.__code__.co_varnames[counter])
- counter += 1
- if ob.__code__.co_flags & 0x8:
- items1.append("**"+ob.__code__.co_varnames[counter])
- items2.append("**"+ob.__code__.co_varnames[counter])
- argText1 = ", ".join(items1)
- argText1 = "(%s)" % argText1
- argText2 = ", ".join(items2)
- argText2 = "(%s)" % argText2
- return argText1, argText2
+ items1 = [arg + dflt for arg, dflt in zip(realArgs, defaults)]
+ if varargs is not None:
+ items1.append("*" + varargs)
+ items2.append("*" + varargs)
+ if varkw is not None:
+ items1.append("**" + varkw)
+ items2.append("**" + varkw)
+ defText = ", ".join(items1)
+ defText = "(%s)" % defText
+ callText = ", ".join(items2)
+ callText = "(%s)" % callText
+ return defText, callText
def _turtle_docrevise(docstr):
"""To reduce docstrings from RawTurtle class for functions
diff --git a/Lib/turtledemo/__init__.py b/Lib/turtledemo/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/Lib/turtledemo/__init__.py
diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py
new file mode 100755
index 0000000000..cbf3aeb692
--- /dev/null
+++ b/Lib/turtledemo/__main__.py
@@ -0,0 +1,266 @@
+#!/usr/bin/env python3
+import sys
+import os
+
+from tkinter import *
+from idlelib.Percolator import Percolator
+from idlelib.ColorDelegator import ColorDelegator
+from idlelib.textView import view_file # TextViewer
+from imp import reload
+
+import turtle
+import time
+
+demo_dir = os.path.dirname(os.path.abspath(__file__))
+
+STARTUP = 1
+READY = 2
+RUNNING = 3
+DONE = 4
+EVENTDRIVEN = 5
+
+menufont = ("Arial", 12, NORMAL)
+btnfont = ("Arial", 12, 'bold')
+txtfont = ('Lucida Console', 8, 'normal')
+
+def getExampleEntries():
+ return [entry[:-3] for entry in os.listdir(demo_dir) if
+ entry.endswith(".py") and entry[0] != '_']
+
+def showDemoHelp():
+ view_file(demo.root, "Help on turtleDemo",
+ os.path.join(demo_dir, "demohelp.txt"))
+
+def showAboutDemo():
+ view_file(demo.root, "About turtleDemo",
+ os.path.join(demo_dir, "about_turtledemo.txt"))
+
+def showAboutTurtle():
+ view_file(demo.root, "About the new turtle module.",
+ os.path.join(demo_dir, "about_turtle.txt"))
+
+class DemoWindow(object):
+
+ def __init__(self, filename=None): #, root=None):
+ self.root = root = turtle._root = Tk()
+ root.wm_protocol("WM_DELETE_WINDOW", self._destroy)
+
+ #################
+ self.mBar = Frame(root, relief=RAISED, borderwidth=2)
+ self.mBar.pack(fill=X)
+
+ self.ExamplesBtn = self.makeLoadDemoMenu()
+ self.OptionsBtn = self.makeHelpMenu()
+ self.mBar.tk_menuBar(self.ExamplesBtn, self.OptionsBtn) #, QuitBtn)
+
+ root.title('Python turtle-graphics examples')
+ #################
+ self.left_frame = left_frame = Frame(root)
+ self.text_frame = text_frame = Frame(left_frame)
+ self.vbar = vbar =Scrollbar(text_frame, name='vbar')
+ self.text = text = Text(text_frame,
+ name='text', padx=5, wrap='none',
+ width=45)
+ vbar['command'] = text.yview
+ vbar.pack(side=LEFT, fill=Y)
+ #####################
+ self.hbar = hbar =Scrollbar(text_frame, name='hbar', orient=HORIZONTAL)
+ hbar['command'] = text.xview
+ hbar.pack(side=BOTTOM, fill=X)
+ #####################
+ text['yscrollcommand'] = vbar.set
+ text.config(font=txtfont)
+ text.config(xscrollcommand=hbar.set)
+ text.pack(side=LEFT, fill=Y, expand=1)
+ #####################
+ self.output_lbl = Label(left_frame, height= 1,text=" --- ", bg = "#ddf",
+ font = ("Arial", 16, 'normal'))
+ self.output_lbl.pack(side=BOTTOM, expand=0, fill=X)
+ #####################
+ text_frame.pack(side=LEFT, fill=BOTH, expand=0)
+ left_frame.pack(side=LEFT, fill=BOTH, expand=0)
+ self.graph_frame = g_frame = Frame(root)
+
+ turtle._Screen._root = g_frame
+ turtle._Screen._canvas = turtle.ScrolledCanvas(g_frame, 800, 600, 1000, 800)
+ #xturtle.Screen._canvas.pack(expand=1, fill="both")
+ self.screen = _s_ = turtle.Screen()
+#####
+ turtle.TurtleScreen.__init__(_s_, _s_._canvas)
+#####
+ self.scanvas = _s_._canvas
+ #xturtle.RawTurtle.canvases = [self.scanvas]
+ turtle.RawTurtle.screens = [_s_]
+
+ self.scanvas.pack(side=TOP, fill=BOTH, expand=1)
+
+ self.btn_frame = btn_frame = Frame(g_frame, height=100)
+ self.start_btn = Button(btn_frame, text=" START ", font=btnfont, fg = "white",
+ disabledforeground = "#fed", command=self.startDemo)
+ self.start_btn.pack(side=LEFT, fill=X, expand=1)
+ self.stop_btn = Button(btn_frame, text=" STOP ", font=btnfont, fg = "white",
+ disabledforeground = "#fed", command = self.stopIt)
+ self.stop_btn.pack(side=LEFT, fill=X, expand=1)
+ self.clear_btn = Button(btn_frame, text=" CLEAR ", font=btnfont, fg = "white",
+ disabledforeground = "#fed", command = self.clearCanvas)
+ self.clear_btn.pack(side=LEFT, fill=X, expand=1)
+
+ self.btn_frame.pack(side=TOP, fill=BOTH, expand=0)
+ self.graph_frame.pack(side=TOP, fill=BOTH, expand=1)
+
+ Percolator(text).insertfilter(ColorDelegator())
+ self.dirty = False
+ self.exitflag = False
+ if filename:
+ self.loadfile(filename)
+ self.configGUI(NORMAL, DISABLED, DISABLED, DISABLED,
+ "Choose example from menu", "black")
+ self.state = STARTUP
+
+ def _destroy(self):
+ self.root.destroy()
+ sys.exit()
+
+ def configGUI(self, menu, start, stop, clear, txt="", color="blue"):
+ self.ExamplesBtn.config(state=menu)
+
+ self.start_btn.config(state=start)
+ if start == NORMAL:
+ self.start_btn.config(bg="#d00")
+ else:
+ self.start_btn.config(bg="#fca")
+
+ self.stop_btn.config(state=stop)
+ if stop == NORMAL:
+ self.stop_btn.config(bg="#d00")
+ else:
+ self.stop_btn.config(bg="#fca")
+ self.clear_btn.config(state=clear)
+
+ self.clear_btn.config(state=clear)
+ if clear == NORMAL:
+ self.clear_btn.config(bg="#d00")
+ else:
+ self.clear_btn.config(bg="#fca")
+
+ self.output_lbl.config(text=txt, fg=color)
+
+
+ def makeLoadDemoMenu(self):
+ CmdBtn = Menubutton(self.mBar, text='Examples', underline=0, font=menufont)
+ CmdBtn.pack(side=LEFT, padx="2m")
+ CmdBtn.menu = Menu(CmdBtn)
+
+ for entry in getExampleEntries():
+ def loadexample(x):
+ def emit():
+ self.loadfile(x)
+ return emit
+ CmdBtn.menu.add_command(label=entry, underline=0,
+ font=menufont, command=loadexample(entry))
+
+ CmdBtn['menu'] = CmdBtn.menu
+ return CmdBtn
+
+ def makeHelpMenu(self):
+ CmdBtn = Menubutton(self.mBar, text='Help', underline=0, font=menufont)
+ CmdBtn.pack(side=LEFT, padx='2m')
+ CmdBtn.menu = Menu(CmdBtn)
+
+ CmdBtn.menu.add_command(label='About turtle.py', font=menufont,
+ command=showAboutTurtle)
+ CmdBtn.menu.add_command(label='turtleDemo - Help', font=menufont,
+ command=showDemoHelp)
+ CmdBtn.menu.add_command(label='About turtleDemo', font=menufont,
+ command=showAboutDemo)
+
+ CmdBtn['menu'] = CmdBtn.menu
+ return CmdBtn
+
+ def refreshCanvas(self):
+ if not self.dirty: return
+ self.screen.clear()
+ #self.screen.mode("standard")
+ self.dirty=False
+
+ def loadfile(self, filename):
+ self.refreshCanvas()
+ modname = 'turtledemo.' + filename
+ __import__(modname)
+ self.module = sys.modules[modname]
+ with open(self.module.__file__, 'r') as f:
+ chars = f.read()
+ self.text.delete("1.0", "end")
+ self.text.insert("1.0", chars)
+ self.root.title(filename + " - a Python turtle graphics example")
+ reload(self.module)
+ self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED,
+ "Press start button", "red")
+ self.state = READY
+
+ def startDemo(self):
+ self.refreshCanvas()
+ self.dirty = True
+ turtle.TurtleScreen._RUNNING = True
+ self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
+ "demo running...", "black")
+ self.screen.clear()
+ self.screen.mode("standard")
+ self.state = RUNNING
+
+ try:
+ result = self.module.main()
+ if result == "EVENTLOOP":
+ self.state = EVENTDRIVEN
+ else:
+ self.state = DONE
+ except turtle.Terminator:
+ self.state = DONE
+ result = "stopped!"
+ if self.state == DONE:
+ self.configGUI(NORMAL, NORMAL, DISABLED, NORMAL,
+ result)
+ elif self.state == EVENTDRIVEN:
+ self.exitflag = True
+ self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
+ "use mouse/keys or STOP", "red")
+
+ def clearCanvas(self):
+ self.refreshCanvas()
+ self.screen._delete("all")
+ self.scanvas.config(cursor="")
+ self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED)
+
+ def stopIt(self):
+ if self.exitflag:
+ self.clearCanvas()
+ self.exitflag = False
+ self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED,
+ "STOPPED!", "red")
+ turtle.TurtleScreen._RUNNING = False
+ #print "stopIT: exitflag = True"
+ else:
+ turtle.TurtleScreen._RUNNING = False
+ #print "stopIt: exitflag = False"
+
+if __name__ == '__main__':
+ demo = DemoWindow()
+ RUN = True
+ while RUN:
+ try:
+ #print("ENTERING mainloop")
+ demo.root.mainloop()
+ except AttributeError:
+ #print("AttributeError!- WAIT A MOMENT!")
+ time.sleep(0.3)
+ print("GOING ON ..")
+ demo.ckearCanvas()
+ except TypeError:
+ demo.screen._delete("all")
+ #print("CRASH!!!- WAIT A MOMENT!")
+ time.sleep(0.3)
+ #print("GOING ON ..")
+ demo.clearCanvas()
+ except:
+ print("BYE!")
+ RUN = False
diff --git a/Lib/turtledemo/about_turtle.txt b/Lib/turtledemo/about_turtle.txt
new file mode 100644
index 0000000000..e4ba217c96
--- /dev/null
+++ b/Lib/turtledemo/about_turtle.txt
@@ -0,0 +1,76 @@
+
+========================================================
+ A new turtle module for Python
+========================================================
+
+Turtle graphics is a popular way for introducing programming to
+kids. It was part of the original Logo programming language developed
+by Wally Feurzig and Seymour Papert in 1966.
+
+Imagine a robotic turtle starting at (0, 0) in the x-y plane. Give it
+the command turtle.forward(15), and it moves (on-screen!) 15 pixels in
+the direction it is facing, drawing a line as it moves. Give it the
+command turtle.left(25), and it rotates in-place 25 degrees clockwise.
+
+By combining together these and similar commands, intricate shapes and
+pictures can easily be drawn.
+
+----- turtle.py
+
+This module is an extended reimplementation of turtle.py from the
+Python standard distribution up to Python 2.5. (See: http:\\www.python.org)
+
+It tries to keep the merits of turtle.py and to be (nearly) 100%
+compatible with it. This means in the first place to enable the
+learning programmer to use all the commands, classes and methods
+interactively when using the module from within IDLE run with
+the -n switch.
+
+Roughly it has the following features added:
+
+- Better animation of the turtle movements, especially of turning the
+ turtle. So the turtles can more easily be used as a visual feedback
+ instrument by the (beginning) programmer.
+
+- Different turtle shapes, gif-images as turtle shapes, user defined
+ and user controllable turtle shapes, among them compound
+ (multicolored) shapes. Turtle shapes can be stgretched and tilted, which
+ makes turtles zu very versatile geometrical objects.
+
+- Fine control over turtle movement and screen updates via delay(),
+ and enhanced tracer() and speed() methods.
+
+- Aliases for the most commonly used commands, like fd for forward etc.,
+ following the early Logo traditions. This reduces the boring work of
+ typing long sequences of commands, which often occur in a natural way
+ when kids try to program fancy pictures on their first encounter with
+ turtle graphcis.
+
+- Turtles now have an undo()-method with configurable undo-buffer.
+
+- Some simple commands/methods for creating event driven programs
+ (mouse-, key-, timer-events). Especially useful for programming games.
+
+- A scrollable Canvas class. The default scrollable Canvas can be
+ extended interactively as needed while playing around with the turtle(s).
+
+- A TurtleScreen class with methods controlling background color or
+ background image, window and canvas size and other properties of the
+ TurtleScreen.
+
+- There is a method, setworldcoordinates(), to install a user defined
+ coordinate-system for the TurtleScreen.
+
+- The implementation uses a 2-vector class named Vec2D, derived from tuple.
+ This class is public, so it can be imported by the application programmer,
+ which makes certain types of computations very natural and compact.
+
+- Appearance of the TurtleScreen and the Turtles at startup/import can be
+ configured by means of a turtle.cfg configuration file.
+ The default configuration mimics the appearance of the old turtle module.
+
+- If configured appropriately the module reads in docstrings from a docstring
+ dictionary in some different language, supplied separately and replaces
+ the english ones by those read in. There is a utility function
+ write_docstringdict() to write a dictionary with the original (english)
+ docstrings to disc, so it can serve as a template for translations.
diff --git a/Lib/turtledemo/about_turtledemo.txt b/Lib/turtledemo/about_turtledemo.txt
new file mode 100644
index 0000000000..a9009bd5fb
--- /dev/null
+++ b/Lib/turtledemo/about_turtledemo.txt
@@ -0,0 +1,13 @@
+
+ --------------------------------------
+ About this viewer
+ --------------------------------------
+
+ Tiny demo viewer to view turtle graphics example scripts.
+
+ Quickly and dirtyly assembled by Gregor Lingl.
+ June, 2006
+
+ For more information see: turtleDemo - Help
+
+ Have fun!
diff --git a/Lib/turtledemo/bytedesign.py b/Lib/turtledemo/bytedesign.py
new file mode 100644
index 0000000000..64b1d7d5b0
--- /dev/null
+++ b/Lib/turtledemo/bytedesign.py
@@ -0,0 +1,162 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_bytedesign.py
+
+An example adapted from the example-suite
+of PythonCard's turtle graphics.
+
+It's based on an article in BYTE magazine
+Problem Solving with Logo: Using Turtle
+Graphics to Redraw a Design
+November 1982, p. 118 - 134
+
+-------------------------------------------
+
+Due to the statement
+
+t.delay(0)
+
+in line 152, which sets the animation delay
+to 0, this animation runs in "line per line"
+mode as fast as possible.
+"""
+
+import math
+from turtle import Turtle, mainloop
+from time import clock
+
+# wrapper for any additional drawing routines
+# that need to know about each other
+class Designer(Turtle):
+
+ def design(self, homePos, scale):
+ self.up()
+ for i in range(5):
+ self.forward(64.65 * scale)
+ self.down()
+ self.wheel(self.position(), scale)
+ self.up()
+ self.backward(64.65 * scale)
+ self.right(72)
+ self.up()
+ self.goto(homePos)
+ self.right(36)
+ self.forward(24.5 * scale)
+ self.right(198)
+ self.down()
+ self.centerpiece(46 * scale, 143.4, scale)
+ self.getscreen().tracer(True)
+
+ def wheel(self, initpos, scale):
+ self.right(54)
+ for i in range(4):
+ self.pentpiece(initpos, scale)
+ self.down()
+ self.left(36)
+ for i in range(5):
+ self.tripiece(initpos, scale)
+ self.left(36)
+ for i in range(5):
+ self.down()
+ self.right(72)
+ self.forward(28 * scale)
+ self.up()
+ self.backward(28 * scale)
+ self.left(54)
+ self.getscreen().update()
+
+ def tripiece(self, initpos, scale):
+ oldh = self.heading()
+ self.down()
+ self.backward(2.5 * scale)
+ self.tripolyr(31.5 * scale, scale)
+ self.up()
+ self.goto(initpos)
+ self.setheading(oldh)
+ self.down()
+ self.backward(2.5 * scale)
+ self.tripolyl(31.5 * scale, scale)
+ self.up()
+ self.goto(initpos)
+ self.setheading(oldh)
+ self.left(72)
+ self.getscreen().update()
+
+ def pentpiece(self, initpos, scale):
+ oldh = self.heading()
+ self.up()
+ self.forward(29 * scale)
+ self.down()
+ for i in range(5):
+ self.forward(18 * scale)
+ self.right(72)
+ self.pentr(18 * scale, 75, scale)
+ self.up()
+ self.goto(initpos)
+ self.setheading(oldh)
+ self.forward(29 * scale)
+ self.down()
+ for i in range(5):
+ self.forward(18 * scale)
+ self.right(72)
+ self.pentl(18 * scale, 75, scale)
+ self.up()
+ self.goto(initpos)
+ self.setheading(oldh)
+ self.left(72)
+ self.getscreen().update()
+
+ def pentl(self, side, ang, scale):
+ if side < (2 * scale): return
+ self.forward(side)
+ self.left(ang)
+ self.pentl(side - (.38 * scale), ang, scale)
+
+ def pentr(self, side, ang, scale):
+ if side < (2 * scale): return
+ self.forward(side)
+ self.right(ang)
+ self.pentr(side - (.38 * scale), ang, scale)
+
+ def tripolyr(self, side, scale):
+ if side < (4 * scale): return
+ self.forward(side)
+ self.right(111)
+ self.forward(side / 1.78)
+ self.right(111)
+ self.forward(side / 1.3)
+ self.right(146)
+ self.tripolyr(side * .75, scale)
+
+ def tripolyl(self, side, scale):
+ if side < (4 * scale): return
+ self.forward(side)
+ self.left(111)
+ self.forward(side / 1.78)
+ self.left(111)
+ self.forward(side / 1.3)
+ self.left(146)
+ self.tripolyl(side * .75, scale)
+
+ def centerpiece(self, s, a, scale):
+ self.forward(s); self.left(a)
+ if s < (7.5 * scale):
+ return
+ self.centerpiece(s - (1.2 * scale), a, scale)
+
+def main():
+ t = Designer()
+ t.speed(0)
+ t.hideturtle()
+ t.getscreen().delay(0)
+ t.getscreen().tracer(0)
+ at = clock()
+ t.design(t.position(), 2)
+ et = clock()
+ return "runtime: %.2f sec." % (et-at)
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/chaos.py b/Lib/turtledemo/chaos.py
new file mode 100644
index 0000000000..d4656f8914
--- /dev/null
+++ b/Lib/turtledemo/chaos.py
@@ -0,0 +1,59 @@
+# File: tdemo_chaos.py
+# Author: Gregor Lingl
+# Date: 2009-06-24
+
+# A demonstration of chaos
+
+from turtle import *
+
+N = 80
+
+def f(x):
+ return 3.9*x*(1-x)
+
+def g(x):
+ return 3.9*(x-x**2)
+
+def h(x):
+ return 3.9*x-3.9*x*x
+
+def jumpto(x, y):
+ penup(); goto(x,y)
+
+def line(x1, y1, x2, y2):
+ jumpto(x1, y1)
+ pendown()
+ goto(x2, y2)
+
+def coosys():
+ line(-1, 0, N+1, 0)
+ line(0, -0.1, 0, 1.1)
+
+def plot(fun, start, colour):
+ pencolor(colour)
+ x = start
+ jumpto(0, x)
+ pendown()
+ dot(5)
+ for i in range(N):
+ x=fun(x)
+ goto(i+1,x)
+ dot(5)
+
+def main():
+ reset()
+ setworldcoordinates(-1.0,-0.1, N+1, 1.1)
+ speed(0)
+ hideturtle()
+ coosys()
+ plot(f, 0.35, "blue")
+ plot(g, 0.35, "green")
+ plot(h, 0.35, "red")
+ # Now zoom in:
+ for s in range(100):
+ setworldcoordinates(0.5*s,-0.1, N+1, 1.1)
+ return "Done!"
+
+if __name__ == "__main__":
+ main()
+ mainloop()
diff --git a/Lib/turtledemo/clock.py b/Lib/turtledemo/clock.py
new file mode 100644
index 0000000000..a0d157ba49
--- /dev/null
+++ b/Lib/turtledemo/clock.py
@@ -0,0 +1,132 @@
+#!/usr/bin/env python3
+# -*- coding: cp1252 -*-
+""" turtle-example-suite:
+
+ tdemo_clock.py
+
+Enhanced clock-program, showing date
+and time
+ ------------------------------------
+ Press STOP to exit the program!
+ ------------------------------------
+"""
+from turtle import *
+from datetime import datetime
+
+mode("logo")
+
+def jump(distanz, winkel=0):
+ penup()
+ right(winkel)
+ forward(distanz)
+ left(winkel)
+ pendown()
+
+def hand(laenge, spitze):
+ fd(laenge*1.15)
+ rt(90)
+ fd(spitze/2.0)
+ lt(120)
+ fd(spitze)
+ lt(120)
+ fd(spitze)
+ lt(120)
+ fd(spitze/2.0)
+
+def make_hand_shape(name, laenge, spitze):
+ reset()
+ jump(-laenge*0.15)
+ begin_poly()
+ hand(laenge, spitze)
+ end_poly()
+ hand_form = get_poly()
+ register_shape(name, hand_form)
+
+
+def clockface(radius):
+ reset()
+ pensize(7)
+ for i in range(60):
+ jump(radius)
+ if i % 5 == 0:
+ fd(25)
+ jump(-radius-25)
+ else:
+ dot(3)
+ jump(-radius)
+ rt(6)
+
+def setup():
+ global second_hand, minute_hand, hour_hand, writer
+ mode("logo")
+ make_hand_shape("second_hand", 125, 25)
+ make_hand_shape("minute_hand", 130, 25)
+ make_hand_shape("hour_hand", 90, 25)
+ clockface(160)
+ second_hand = Turtle()
+ second_hand.shape("second_hand")
+ second_hand.color("gray20", "gray80")
+ minute_hand = Turtle()
+ minute_hand.shape("minute_hand")
+ minute_hand.color("blue1", "red1")
+ hour_hand = Turtle()
+ hour_hand.shape("hour_hand")
+ hour_hand.color("blue3", "red3")
+ for hand in second_hand, minute_hand, hour_hand:
+ hand.resizemode("user")
+ hand.shapesize(1, 1, 3)
+ hand.speed(0)
+ ht()
+ writer = Turtle()
+ #writer.mode("logo")
+ writer.ht()
+ writer.pu()
+ writer.bk(85)
+
+
+def wochentag(t):
+ wochentag = ["Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday", "Sunday"]
+ return wochentag[t.weekday()]
+
+def datum(z):
+ monat = ["Jan.", "Feb.", "Mar.", "Apr.", "May", "June",
+ "July", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."]
+ j = z.year
+ m = monat[z.month - 1]
+ t = z.day
+ return "%s %d %d" % (m, t, j)
+
+def tick():
+ t = datetime.today()
+ sekunde = t.second + t.microsecond*0.000001
+ minute = t.minute + sekunde/60.0
+ stunde = t.hour + minute/60.0
+ tracer(False)
+ writer.clear()
+ writer.home()
+ writer.forward(65)
+ writer.write(wochentag(t),
+ align="center", font=("Courier", 14, "bold"))
+ writer.back(150)
+ writer.write(datum(t),
+ align="center", font=("Courier", 14, "bold"))
+ writer.forward(85)
+ tracer(True)
+ second_hand.setheading(6*sekunde)
+ minute_hand.setheading(6*minute)
+ hour_hand.setheading(30*stunde)
+ tracer(True)
+ ontimer(tick, 100)
+
+def main():
+ tracer(False)
+ setup()
+ tracer(True)
+ tick()
+ return "EVENTLOOP"
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/colormixer.py b/Lib/turtledemo/colormixer.py
new file mode 100644
index 0000000000..f5d308d443
--- /dev/null
+++ b/Lib/turtledemo/colormixer.py
@@ -0,0 +1,60 @@
+# colormixer
+
+from turtle import Screen, Turtle, mainloop
+import sys
+sys.setrecursionlimit(20000) # overcomes, for now, an instability of Python 3.0
+
+class ColorTurtle(Turtle):
+
+ def __init__(self, x, y):
+ Turtle.__init__(self)
+ self.shape("turtle")
+ self.resizemode("user")
+ self.shapesize(3,3,5)
+ self.pensize(10)
+ self._color = [0,0,0]
+ self.x = x
+ self._color[x] = y
+ self.color(self._color)
+ self.speed(0)
+ self.left(90)
+ self.pu()
+ self.goto(x,0)
+ self.pd()
+ self.sety(1)
+ self.pu()
+ self.sety(y)
+ self.pencolor("gray25")
+ self.ondrag(self.shift)
+
+ def shift(self, x, y):
+ self.sety(max(0,min(y,1)))
+ self._color[self.x] = self.ycor()
+ self.fillcolor(self._color)
+ setbgcolor()
+
+def setbgcolor():
+ screen.bgcolor(red.ycor(), green.ycor(), blue.ycor())
+
+def main():
+ global screen, red, green, blue
+ screen = Screen()
+ screen.delay(0)
+ screen.setworldcoordinates(-1, -0.3, 3, 1.3)
+
+ red = ColorTurtle(0, .5)
+ green = ColorTurtle(1, .5)
+ blue = ColorTurtle(2, .5)
+ setbgcolor()
+
+ writer = Turtle()
+ writer.ht()
+ writer.pu()
+ writer.goto(1,1.15)
+ writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
+ return "EVENTLOOP"
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/demohelp.txt b/Lib/turtledemo/demohelp.txt
new file mode 100644
index 0000000000..fe83bc7601
--- /dev/null
+++ b/Lib/turtledemo/demohelp.txt
@@ -0,0 +1,70 @@
+
+
+ ----------------------------------------------
+
+ turtleDemo - Help
+
+ ----------------------------------------------
+
+ This document has two sections:
+
+ (1) How to use the demo viewer
+ (2) How to add your own demos to the demo repository
+
+
+ (1) How to use the demo viewer.
+
+ Select a demoscript from the example menu.
+ The (syntax coloured) source code appears in the left
+ source code window. IT CANNOT BE EDITED, but ONLY VIEWED!
+
+ - Press START button to start the demo.
+ - Stop execution by pressing the STOP button.
+ - Clear screen by pressing the CLEAR button.
+ - Restart by pressing the START button again.
+
+ SPECIAL demos are those which run EVENTDRIVEN.
+ (For example clock.py - or oldTurtleDemo.py which
+ in the end expects a mouse click.):
+
+ Press START button to start the demo.
+
+ - Until the EVENTLOOP is entered everything works
+ as in an ordinary demo script.
+
+ - When the EVENTLOOP is entered, you control the
+ application by using the mouse and/or keys (or it's
+ controlled by some timer events)
+ To stop it you can and must press the STOP button.
+
+ While the EVENTLOOP is running, the examples menu is disabled.
+
+ - Only after having pressed the STOP button, you may
+ restart it or choose another example script.
+
+ * * * * * * * *
+ In some rare situations there may occur interferences/conflicts
+ between events concerning the demo script and those concerning the
+ demo-viewer. (They run in the same process.) Strange behaviour may be
+ the consequence and in the worst case you must close and restart the
+ viewer.
+ * * * * * * * *
+
+
+ (2) How to add your own demos to the demo repository
+
+ - place: same directory as turtledemo/__main__.py
+
+ - requirements on source code:
+ code must contain a main() function which will
+ be executed by the viewer (see provided example scripts)
+ main() may return a string which will be displayed
+ in the Label below the source code window (when execution
+ has finished.)
+
+ !! For programs, which are EVENT DRIVEN, main must return
+ !! the string "EVENTLOOP". This informs the viewer, that the
+ !! script is still running and must be stopped by the user!
+
+
+
diff --git a/Lib/turtledemo/forest.py b/Lib/turtledemo/forest.py
new file mode 100644
index 0000000000..a837d844c9
--- /dev/null
+++ b/Lib/turtledemo/forest.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python3
+""" turtlegraphics-example-suite:
+
+ tdemo_forest.py
+
+Displays a 'forest' of 3 'breadth-first-trees'
+similar to the one from example tree.
+For further remarks see xtx_tree.py
+
+This example is a 'breadth-first'-rewrite of
+a Logo program written by Erich Neuwirth. See:
+http://homepage.univie.ac.at/erich.neuwirth/
+"""
+from turtle import Turtle, colormode, tracer, mainloop
+from random import randrange
+from time import clock
+
+def symRandom(n):
+ return randrange(-n,n+1)
+
+def randomize( branchlist, angledist, sizedist ):
+ return [ (angle+symRandom(angledist),
+ sizefactor*1.01**symRandom(sizedist))
+ for angle, sizefactor in branchlist ]
+
+def randomfd( t, distance, parts, angledist ):
+ for i in range(parts):
+ t.left(symRandom(angledist))
+ t.forward( (1.0 * distance)/parts )
+
+def tree(tlist, size, level, widthfactor, branchlists, angledist=10, sizedist=5):
+ # benutzt Liste von turtles und Liste von Zweiglisten,
+ # fuer jede turtle eine!
+ if level > 0:
+ lst = []
+ brs = []
+ for t, branchlist in list(zip(tlist,branchlists)):
+ t.pensize( size * widthfactor )
+ t.pencolor( 255 - (180 - 11 * level + symRandom(15)),
+ 180 - 11 * level + symRandom(15),
+ 0 )
+ t.pendown()
+ randomfd(t, size, level, angledist )
+ yield 1
+ for angle, sizefactor in branchlist:
+ t.left(angle)
+ lst.append(t.clone())
+ brs.append(randomize(branchlist, angledist, sizedist))
+ t.right(angle)
+ for x in tree(lst, size*sizefactor, level-1, widthfactor, brs,
+ angledist, sizedist):
+ yield None
+
+
+def start(t,x,y):
+ colormode(255)
+ t.reset()
+ t.speed(0)
+ t.hideturtle()
+ t.left(90)
+ t.penup()
+ t.setpos(x,y)
+ t.pendown()
+
+def doit1(level, pen):
+ pen.hideturtle()
+ start(pen, 20, -208)
+ t = tree( [pen], 80, level, 0.1, [[ (45,0.69), (0,0.65), (-45,0.71) ]] )
+ return t
+
+def doit2(level, pen):
+ pen.hideturtle()
+ start(pen, -135, -130)
+ t = tree( [pen], 120, level, 0.1, [[ (45,0.69), (-45,0.71) ]] )
+ return t
+
+def doit3(level, pen):
+ pen.hideturtle()
+ start(pen, 190, -90)
+ t = tree( [pen], 100, level, 0.1, [[ (45,0.7), (0,0.72), (-45,0.65) ]] )
+ return t
+
+# Hier 3 Baumgeneratoren:
+def main():
+ p = Turtle()
+ p.ht()
+ tracer(75,0)
+ u = doit1(6, Turtle(undobuffersize=1))
+ s = doit2(7, Turtle(undobuffersize=1))
+ t = doit3(5, Turtle(undobuffersize=1))
+ a = clock()
+ while True:
+ done = 0
+ for b in u,s,t:
+ try:
+ b.__next__()
+ except:
+ done += 1
+ if done == 3:
+ break
+
+ tracer(1,10)
+ b = clock()
+ return "runtime: %.2f sec." % (b-a)
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/fractalcurves.py b/Lib/turtledemo/fractalcurves.py
new file mode 100644
index 0000000000..c49f8b88ea
--- /dev/null
+++ b/Lib/turtledemo/fractalcurves.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_fractalCurves.py
+
+This program draws two fractal-curve-designs:
+(1) A hilbert curve (in a box)
+(2) A combination of Koch-curves.
+
+The CurvesTurtle class and the fractal-curve-
+methods are taken from the PythonCard example
+scripts for turtle-graphics.
+"""
+from turtle import *
+from time import sleep, clock
+
+class CurvesTurtle(Pen):
+ # example derived from
+ # Turtle Geometry: The Computer as a Medium for Exploring Mathematics
+ # by Harold Abelson and Andrea diSessa
+ # p. 96-98
+ def hilbert(self, size, level, parity):
+ if level == 0:
+ return
+ # rotate and draw first subcurve with opposite parity to big curve
+ self.left(parity * 90)
+ self.hilbert(size, level - 1, -parity)
+ # interface to and draw second subcurve with same parity as big curve
+ self.forward(size)
+ self.right(parity * 90)
+ self.hilbert(size, level - 1, parity)
+ # third subcurve
+ self.forward(size)
+ self.hilbert(size, level - 1, parity)
+ # fourth subcurve
+ self.right(parity * 90)
+ self.forward(size)
+ self.hilbert(size, level - 1, -parity)
+ # a final turn is needed to make the turtle
+ # end up facing outward from the large square
+ self.left(parity * 90)
+
+ # Visual Modeling with Logo: A Structural Approach to Seeing
+ # by James Clayson
+ # Koch curve, after Helge von Koch who introduced this geometric figure in 1904
+ # p. 146
+ def fractalgon(self, n, rad, lev, dir):
+ import math
+
+ # if dir = 1 turn outward
+ # if dir = -1 turn inward
+ edge = 2 * rad * math.sin(math.pi / n)
+ self.pu()
+ self.fd(rad)
+ self.pd()
+ self.rt(180 - (90 * (n - 2) / n))
+ for i in range(n):
+ self.fractal(edge, lev, dir)
+ self.rt(360 / n)
+ self.lt(180 - (90 * (n - 2) / n))
+ self.pu()
+ self.bk(rad)
+ self.pd()
+
+ # p. 146
+ def fractal(self, dist, depth, dir):
+ if depth < 1:
+ self.fd(dist)
+ return
+ self.fractal(dist / 3, depth - 1, dir)
+ self.lt(60 * dir)
+ self.fractal(dist / 3, depth - 1, dir)
+ self.rt(120 * dir)
+ self.fractal(dist / 3, depth - 1, dir)
+ self.lt(60 * dir)
+ self.fractal(dist / 3, depth - 1, dir)
+
+def main():
+ ft = CurvesTurtle()
+
+ ft.reset()
+ ft.speed(0)
+ ft.ht()
+ ft.getscreen().tracer(1,0)
+ ft.pu()
+
+ size = 6
+ ft.setpos(-33*size, -32*size)
+ ft.pd()
+
+ ta=clock()
+ ft.fillcolor("red")
+ ft.begin_fill()
+ ft.fd(size)
+
+ ft.hilbert(size, 6, 1)
+
+ # frame
+ ft.fd(size)
+ for i in range(3):
+ ft.lt(90)
+ ft.fd(size*(64+i%2))
+ ft.pu()
+ for i in range(2):
+ ft.fd(size)
+ ft.rt(90)
+ ft.pd()
+ for i in range(4):
+ ft.fd(size*(66+i%2))
+ ft.rt(90)
+ ft.end_fill()
+ tb=clock()
+ res = "Hilbert: %.2fsec. " % (tb-ta)
+
+ sleep(3)
+
+ ft.reset()
+ ft.speed(0)
+ ft.ht()
+ ft.getscreen().tracer(1,0)
+
+ ta=clock()
+ ft.color("black", "blue")
+ ft.begin_fill()
+ ft.fractalgon(3, 250, 4, 1)
+ ft.end_fill()
+ ft.begin_fill()
+ ft.color("red")
+ ft.fractalgon(3, 200, 4, -1)
+ ft.end_fill()
+ tb=clock()
+ res += "Koch: %.2fsec." % (tb-ta)
+ return res
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/lindenmayer.py b/Lib/turtledemo/lindenmayer.py
new file mode 100644
index 0000000000..3925f25da6
--- /dev/null
+++ b/Lib/turtledemo/lindenmayer.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ xtx_lindenmayer_indian.py
+
+Each morning women in Tamil Nadu, in southern
+India, place designs, created by using rice
+flour and known as kolam on the thresholds of
+their homes.
+
+These can be described by Lindenmayer systems,
+which can easily be implemented with turtle
+graphics and Python.
+
+Two examples are shown here:
+(1) the snake kolam
+(2) anklets of Krishna
+
+Taken from Marcia Ascher: Mathematics
+Elsewhere, An Exploration of Ideas Across
+Cultures
+
+"""
+################################
+# Mini Lindenmayer tool
+###############################
+
+from turtle import *
+
+def replace( seq, replacementRules, n ):
+ for i in range(n):
+ newseq = ""
+ for element in seq:
+ newseq = newseq + replacementRules.get(element,element)
+ seq = newseq
+ return seq
+
+def draw( commands, rules ):
+ for b in commands:
+ try:
+ rules[b]()
+ except TypeError:
+ try:
+ draw(rules[b], rules)
+ except:
+ pass
+
+
+def main():
+ ################################
+ # Example 1: Snake kolam
+ ################################
+
+
+ def r():
+ right(45)
+
+ def l():
+ left(45)
+
+ def f():
+ forward(7.5)
+
+ snake_rules = {"-":r, "+":l, "f":f, "b":"f+f+f--f--f+f+f"}
+ snake_replacementRules = {"b": "b+f+b--f--b+f+b"}
+ snake_start = "b--f--b--f"
+
+ drawing = replace(snake_start, snake_replacementRules, 3)
+
+ reset()
+ speed(3)
+ tracer(1,0)
+ ht()
+ up()
+ backward(195)
+ down()
+ draw(drawing, snake_rules)
+
+ from time import sleep
+ sleep(3)
+
+ ################################
+ # Example 2: Anklets of Krishna
+ ################################
+
+ def A():
+ color("red")
+ circle(10,90)
+
+ def B():
+ from math import sqrt
+ color("black")
+ l = 5/sqrt(2)
+ forward(l)
+ circle(l, 270)
+ forward(l)
+
+ def F():
+ color("green")
+ forward(10)
+
+ krishna_rules = {"a":A, "b":B, "f":F}
+ krishna_replacementRules = {"a" : "afbfa", "b" : "afbfbfbfa" }
+ krishna_start = "fbfbfbfb"
+
+ reset()
+ speed(0)
+ tracer(3,0)
+ ht()
+ left(45)
+ drawing = replace(krishna_start, krishna_replacementRules, 3)
+ draw(drawing, krishna_rules)
+ tracer(1)
+ return "Done!"
+
+if __name__=='__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/minimal_hanoi.py b/Lib/turtledemo/minimal_hanoi.py
new file mode 100644
index 0000000000..cfb78dcac1
--- /dev/null
+++ b/Lib/turtledemo/minimal_hanoi.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_minimal_hanoi.py
+
+A minimal 'Towers of Hanoi' animation:
+A tower of 6 discs is transferred from the
+left to the right peg.
+
+An imho quite elegant and concise
+implementation using a tower class, which
+is derived from the built-in type list.
+
+Discs are turtles with shape "square", but
+stretched to rectangles by shapesize()
+ ---------------------------------------
+ To exit press STOP button
+ ---------------------------------------
+"""
+from turtle import *
+
+class Disc(Turtle):
+ def __init__(self, n):
+ Turtle.__init__(self, shape="square", visible=False)
+ self.pu()
+ self.shapesize(1.5, n*1.5, 2) # square-->rectangle
+ self.fillcolor(n/6., 0, 1-n/6.)
+ self.st()
+
+class Tower(list):
+ "Hanoi tower, a subclass of built-in type list"
+ def __init__(self, x):
+ "create an empty tower. x is x-position of peg"
+ self.x = x
+ def push(self, d):
+ d.setx(self.x)
+ d.sety(-150+34*len(self))
+ self.append(d)
+ def pop(self):
+ d = list.pop(self)
+ d.sety(150)
+ return d
+
+def hanoi(n, from_, with_, to_):
+ if n > 0:
+ hanoi(n-1, from_, to_, with_)
+ to_.push(from_.pop())
+ hanoi(n-1, with_, from_, to_)
+
+def play():
+ onkey(None,"space")
+ clear()
+ hanoi(6, t1, t2, t3)
+ write("press STOP button to exit",
+ align="center", font=("Courier", 16, "bold"))
+
+def main():
+ global t1, t2, t3
+ ht(); penup(); goto(0, -225) # writer turtle
+ t1 = Tower(-250)
+ t2 = Tower(0)
+ t3 = Tower(250)
+ # make tower of 6 discs
+ for i in range(6,0,-1):
+ t1.push(Disc(i))
+ # prepare spartanic user interface ;-)
+ write("press spacebar to start game",
+ align="center", font=("Courier", 16, "bold"))
+ onkey(play, "space")
+ listen()
+ return "EVENTLOOP"
+
+if __name__=="__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/nim.py b/Lib/turtledemo/nim.py
new file mode 100644
index 0000000000..792ba51534
--- /dev/null
+++ b/Lib/turtledemo/nim.py
@@ -0,0 +1,226 @@
+""" turtle-example-suite:
+
+ tdemo_nim.py
+
+Play nim against the computer. The player
+who takes the last stick is the winner.
+
+Implements the model-view-controller
+design pattern.
+"""
+
+
+import turtle
+import random
+import time
+
+SCREENWIDTH = 640
+SCREENHEIGHT = 480
+
+MINSTICKS = 7
+MAXSTICKS = 31
+
+HUNIT = SCREENHEIGHT // 12
+WUNIT = SCREENWIDTH // ((MAXSTICKS // 5) * 11 + (MAXSTICKS % 5) * 2)
+
+SCOLOR = (63, 63, 31)
+HCOLOR = (255, 204, 204)
+COLOR = (204, 204, 255)
+
+def randomrow():
+ return random.randint(MINSTICKS, MAXSTICKS)
+
+def computerzug(state):
+ xored = state[0] ^ state[1] ^ state[2]
+ if xored == 0:
+ return randommove(state)
+ for z in range(3):
+ s = state[z] ^ xored
+ if s <= state[z]:
+ move = (z, s)
+ return move
+
+def randommove(state):
+ m = max(state)
+ while True:
+ z = random.randint(0,2)
+ if state[z] > (m > 1):
+ break
+ rand = random.randint(m > 1, state[z]-1)
+ return z, rand
+
+
+class NimModel(object):
+ def __init__(self, game):
+ self.game = game
+
+ def setup(self):
+ if self.game.state not in [Nim.CREATED, Nim.OVER]:
+ return
+ self.sticks = [randomrow(), randomrow(), randomrow()]
+ self.player = 0
+ self.winner = None
+ self.game.view.setup()
+ self.game.state = Nim.RUNNING
+
+ def move(self, row, col):
+ maxspalte = self.sticks[row]
+ self.sticks[row] = col
+ self.game.view.notify_move(row, col, maxspalte, self.player)
+ if self.game_over():
+ self.game.state = Nim.OVER
+ self.winner = self.player
+ self.game.view.notify_over()
+ elif self.player == 0:
+ self.player = 1
+ row, col = computerzug(self.sticks)
+ self.move(row, col)
+ self.player = 0
+
+ def game_over(self):
+ return self.sticks == [0, 0, 0]
+
+ def notify_move(self, row, col):
+ if self.sticks[row] <= col:
+ return
+ self.move(row, col)
+
+
+class Stick(turtle.Turtle):
+ def __init__(self, row, col, game):
+ turtle.Turtle.__init__(self, visible=False)
+ self.row = row
+ self.col = col
+ self.game = game
+ x, y = self.coords(row, col)
+ self.shape("square")
+ self.shapesize(HUNIT/10.0, WUNIT/20.0)
+ self.speed(0)
+ self.pu()
+ self.goto(x,y)
+ self.color("white")
+ self.showturtle()
+
+ def coords(self, row, col):
+ packet, remainder = divmod(col, 5)
+ x = (3 + 11 * packet + 2 * remainder) * WUNIT
+ y = (2 + 3 * row) * HUNIT
+ return x - SCREENWIDTH // 2 + WUNIT // 2, SCREENHEIGHT // 2 - y - HUNIT // 2
+
+ def makemove(self, x, y):
+ if self.game.state != Nim.RUNNING:
+ return
+ self.game.controller.notify_move(self.row, self.col)
+
+
+class NimView(object):
+ def __init__(self, game):
+ self.game = game
+ self.screen = game.screen
+ self.model = game.model
+ self.screen.colormode(255)
+ self.screen.tracer(False)
+ self.screen.bgcolor((240, 240, 255))
+ self.writer = turtle.Turtle(visible=False)
+ self.writer.pu()
+ self.writer.speed(0)
+ self.sticks = {}
+ for row in range(3):
+ for col in range(MAXSTICKS):
+ self.sticks[(row, col)] = Stick(row, col, game)
+ self.display("... a moment please ...")
+ self.screen.tracer(True)
+
+ def display(self, msg1, msg2=None):
+ self.screen.tracer(False)
+ self.writer.clear()
+ if msg2 is not None:
+ self.writer.goto(0, - SCREENHEIGHT // 2 + 48)
+ self.writer.pencolor("red")
+ self.writer.write(msg2, align="center", font=("Courier",18,"bold"))
+ self.writer.goto(0, - SCREENHEIGHT // 2 + 20)
+ self.writer.pencolor("black")
+ self.writer.write(msg1, align="center", font=("Courier",14,"bold"))
+ self.screen.tracer(True)
+
+
+ def setup(self):
+ self.screen.tracer(False)
+ for row in range(3):
+ for col in range(self.model.sticks[row]):
+ self.sticks[(row, col)].color(SCOLOR)
+ for row in range(3):
+ for col in range(self.model.sticks[row], MAXSTICKS):
+ self.sticks[(row, col)].color("white")
+ self.display("Your turn! Click leftmost stick to remove.")
+ self.screen.tracer(True)
+
+ def notify_move(self, row, col, maxspalte, player):
+ if player == 0:
+ farbe = HCOLOR
+ for s in range(col, maxspalte):
+ self.sticks[(row, s)].color(farbe)
+ else:
+ self.display(" ... thinking ... ")
+ time.sleep(0.5)
+ self.display(" ... thinking ... aaah ...")
+ farbe = COLOR
+ for s in range(maxspalte-1, col-1, -1):
+ time.sleep(0.2)
+ self.sticks[(row, s)].color(farbe)
+ self.display("Your turn! Click leftmost stick to remove.")
+
+ def notify_over(self):
+ if self.game.model.winner == 0:
+ msg2 = "Congrats. You're the winner!!!"
+ else:
+ msg2 = "Sorry, the computer is the winner."
+ self.display("To play again press space bar. To leave press ESC.", msg2)
+
+ def clear(self):
+ if self.game.state == Nim.OVER:
+ self.screen.clear()
+
+class NimController(object):
+
+ def __init__(self, game):
+ self.game = game
+ self.sticks = game.view.sticks
+ self.BUSY = False
+ for stick in self.sticks.values():
+ stick.onclick(stick.makemove)
+ self.game.screen.onkey(self.game.model.setup, "space")
+ self.game.screen.onkey(self.game.view.clear, "Escape")
+ self.game.view.display("Press space bar to start game")
+ self.game.screen.listen()
+
+ def notify_move(self, row, col):
+ if self.BUSY:
+ return
+ self.BUSY = True
+ self.game.model.notify_move(row, col)
+ self.BUSY = False
+
+class Nim(object):
+ CREATED = 0
+ RUNNING = 1
+ OVER = 2
+ def __init__(self, screen):
+ self.state = Nim.CREATED
+ self.screen = screen
+ self.model = NimModel(self)
+ self.view = NimView(self)
+ self.controller = NimController(self)
+
+
+mainscreen = turtle.Screen()
+mainscreen.mode("standard")
+mainscreen.setup(SCREENWIDTH, SCREENHEIGHT)
+
+def main():
+ nim = Nim(mainscreen)
+ return "EVENTLOOP!"
+
+if __name__ == "__main__":
+ main()
+ turtle.mainloop()
diff --git a/Lib/turtledemo/paint.py b/Lib/turtledemo/paint.py
new file mode 100644
index 0000000000..68058ab6ac
--- /dev/null
+++ b/Lib/turtledemo/paint.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_paint.py
+
+A simple eventdriven paint program
+
+- use left mouse button to move turtle
+- middle mouse button to change color
+- right mouse button do turn filling on/off
+ -------------------------------------------
+ Play around by clicking into the canvas
+ using all three mouse buttons.
+ -------------------------------------------
+ To exit press STOP button
+ -------------------------------------------
+"""
+from turtle import *
+
+def switchupdown(x=0, y=0):
+ if pen()["pendown"]:
+ end_fill()
+ up()
+ else:
+ down()
+ begin_fill()
+
+def changecolor(x=0, y=0):
+ global colors
+ colors = colors[1:]+colors[:1]
+ color(colors[0])
+
+def main():
+ global colors
+ shape("circle")
+ resizemode("user")
+ shapesize(.5)
+ width(3)
+ colors=["red", "green", "blue", "yellow"]
+ color(colors[0])
+ switchupdown()
+ onscreenclick(goto,1)
+ onscreenclick(changecolor,2)
+ onscreenclick(switchupdown,3)
+ return "EVENTLOOP"
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/peace.py b/Lib/turtledemo/peace.py
new file mode 100644
index 0000000000..63cf7cc2e1
--- /dev/null
+++ b/Lib/turtledemo/peace.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_peace.py
+
+A very simple drawing suitable as a beginner's
+programming example.
+
+Uses only commands, which are also available in
+old turtle.py.
+
+Intentionally no variables are used except for the
+colorloop:
+"""
+
+from turtle import *
+
+def main():
+ peacecolors = ("red3", "orange", "yellow",
+ "seagreen4", "orchid4",
+ "royalblue1", "dodgerblue4")
+
+ reset()
+ s = Screen()
+ up()
+ goto(-320,-195)
+ width(70)
+
+ for pcolor in peacecolors:
+ color(pcolor)
+ down()
+ forward(640)
+ up()
+ backward(640)
+ left(90)
+ forward(66)
+ right(90)
+
+ width(25)
+ color("white")
+ goto(0,-170)
+ down()
+
+ circle(170)
+ left(90)
+ forward(340)
+ up()
+ left(180)
+ forward(170)
+ right(45)
+ down()
+ forward(170)
+ up()
+ backward(170)
+ left(90)
+ down()
+ forward(170)
+ up()
+
+ goto(0,300) # vanish if hideturtle() is not available ;-)
+ return "Done!!"
+
+if __name__ == "__main__":
+ main()
+ mainloop()
diff --git a/Lib/turtledemo/penrose.py b/Lib/turtledemo/penrose.py
new file mode 100644
index 0000000000..f73c864b7b
--- /dev/null
+++ b/Lib/turtledemo/penrose.py
@@ -0,0 +1,181 @@
+#!/usr/bin/env python3
+""" xturtle-example-suite:
+
+ xtx_kites_and_darts.py
+
+Constructs two aperiodic penrose-tilings,
+consisting of kites and darts, by the method
+of inflation in six steps.
+
+Starting points are the patterns "sun"
+consisting of five kites and "star"
+consisting of five darts.
+
+For more information see:
+ http://en.wikipedia.org/wiki/Penrose_tiling
+ -------------------------------------------
+"""
+from turtle import *
+from math import cos, pi
+from time import clock, sleep
+
+f = (5**0.5-1)/2.0 # (sqrt(5)-1)/2 -- golden ratio
+d = 2 * cos(3*pi/10)
+
+def kite(l):
+ fl = f * l
+ lt(36)
+ fd(l)
+ rt(108)
+ fd(fl)
+ rt(36)
+ fd(fl)
+ rt(108)
+ fd(l)
+ rt(144)
+
+def dart(l):
+ fl = f * l
+ lt(36)
+ fd(l)
+ rt(144)
+ fd(fl)
+ lt(36)
+ fd(fl)
+ rt(144)
+ fd(l)
+ rt(144)
+
+def inflatekite(l, n):
+ if n == 0:
+ px, py = pos()
+ h, x, y = int(heading()), round(px,3), round(py,3)
+ tiledict[(h,x,y)] = True
+ return
+ fl = f * l
+ lt(36)
+ inflatedart(fl, n-1)
+ fd(l)
+ rt(144)
+ inflatekite(fl, n-1)
+ lt(18)
+ fd(l*d)
+ rt(162)
+ inflatekite(fl, n-1)
+ lt(36)
+ fd(l)
+ rt(180)
+ inflatedart(fl, n-1)
+ lt(36)
+
+def inflatedart(l, n):
+ if n == 0:
+ px, py = pos()
+ h, x, y = int(heading()), round(px,3), round(py,3)
+ tiledict[(h,x,y)] = False
+ return
+ fl = f * l
+ inflatekite(fl, n-1)
+ lt(36)
+ fd(l)
+ rt(180)
+ inflatedart(fl, n-1)
+ lt(54)
+ fd(l*d)
+ rt(126)
+ inflatedart(fl, n-1)
+ fd(l)
+ rt(144)
+
+def draw(l, n, th=2):
+ clear()
+ l = l * f**n
+ shapesize(l/100.0, l/100.0, th)
+ for k in tiledict:
+ h, x, y = k
+ setpos(x, y)
+ setheading(h)
+ if tiledict[k]:
+ shape("kite")
+ color("black", (0, 0.75, 0))
+ else:
+ shape("dart")
+ color("black", (0.75, 0, 0))
+ stamp()
+
+def sun(l, n):
+ for i in range(5):
+ inflatekite(l, n)
+ lt(72)
+
+def star(l,n):
+ for i in range(5):
+ inflatedart(l, n)
+ lt(72)
+
+def makeshapes():
+ tracer(0)
+ begin_poly()
+ kite(100)
+ end_poly()
+ register_shape("kite", get_poly())
+ begin_poly()
+ dart(100)
+ end_poly()
+ register_shape("dart", get_poly())
+ tracer(1)
+
+def start():
+ reset()
+ ht()
+ pu()
+ makeshapes()
+ resizemode("user")
+
+def test(l=200, n=4, fun=sun, startpos=(0,0), th=2):
+ global tiledict
+ goto(startpos)
+ setheading(0)
+ tiledict = {}
+ a = clock()
+ tracer(0)
+ fun(l, n)
+ b = clock()
+ draw(l, n, th)
+ tracer(1)
+ c = clock()
+ print("Calculation: %7.4f s" % (b - a))
+ print("Drawing: %7.4f s" % (c - b))
+ print("Together: %7.4f s" % (c - a))
+ nk = len([x for x in tiledict if tiledict[x]])
+ nd = len([x for x in tiledict if not tiledict[x]])
+ print("%d kites and %d darts = %d pieces." % (nk, nd, nk+nd))
+
+def demo(fun=sun):
+ start()
+ for i in range(8):
+ a = clock()
+ test(300, i, fun)
+ b = clock()
+ t = b - a
+ if t < 2:
+ sleep(2 - t)
+
+def main():
+ #title("Penrose-tiling with kites and darts.")
+ mode("logo")
+ bgcolor(0.3, 0.3, 0)
+ demo(sun)
+ sleep(2)
+ demo(star)
+ pencolor("black")
+ goto(0,-200)
+ pencolor(0.7,0.7,1)
+ write("Please wait...",
+ align="center", font=('Arial Black', 36, 'bold'))
+ test(600, 8, startpos=(70, 117))
+ return "Done"
+
+if __name__ == "__main__":
+ msg = main()
+ mainloop()
diff --git a/Lib/turtledemo/planet_and_moon.py b/Lib/turtledemo/planet_and_moon.py
new file mode 100644
index 0000000000..14c4bbccc4
--- /dev/null
+++ b/Lib/turtledemo/planet_and_moon.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_planets_and_moon.py
+
+Gravitational system simulation using the
+approximation method from Feynman-lectures,
+p.9-8, using turtlegraphics.
+
+Example: heavy central body, light planet,
+very light moon!
+Planet has a circular orbit, moon a stable
+orbit around the planet.
+
+You can hold the movement temporarily by pressing
+the left mouse button with mouse over the
+scrollbar of the canvas.
+
+"""
+from turtle import Shape, Turtle, mainloop, Vec2D as Vec
+from time import sleep
+
+G = 8
+
+class GravSys(object):
+ def __init__(self):
+ self.planets = []
+ self.t = 0
+ self.dt = 0.01
+ def init(self):
+ for p in self.planets:
+ p.init()
+ def start(self):
+ for i in range(10000):
+ self.t += self.dt
+ for p in self.planets:
+ p.step()
+
+class Star(Turtle):
+ def __init__(self, m, x, v, gravSys, shape):
+ Turtle.__init__(self, shape=shape)
+ self.penup()
+ self.m = m
+ self.setpos(x)
+ self.v = v
+ gravSys.planets.append(self)
+ self.gravSys = gravSys
+ self.resizemode("user")
+ self.pendown()
+ def init(self):
+ dt = self.gravSys.dt
+ self.a = self.acc()
+ self.v = self.v + 0.5*dt*self.a
+ def acc(self):
+ a = Vec(0,0)
+ for planet in self.gravSys.planets:
+ if planet != self:
+ v = planet.pos()-self.pos()
+ a += (G*planet.m/abs(v)**3)*v
+ return a
+ def step(self):
+ dt = self.gravSys.dt
+ self.setpos(self.pos() + dt*self.v)
+ if self.gravSys.planets.index(self) != 0:
+ self.setheading(self.towards(self.gravSys.planets[0]))
+ self.a = self.acc()
+ self.v = self.v + dt*self.a
+
+## create compound yellow/blue turtleshape for planets
+
+def main():
+ s = Turtle()
+ s.reset()
+ s.getscreen().tracer(0,0)
+ s.ht()
+ s.pu()
+ s.fd(6)
+ s.lt(90)
+ s.begin_poly()
+ s.circle(6, 180)
+ s.end_poly()
+ m1 = s.get_poly()
+ s.begin_poly()
+ s.circle(6,180)
+ s.end_poly()
+ m2 = s.get_poly()
+
+ planetshape = Shape("compound")
+ planetshape.addcomponent(m1,"orange")
+ planetshape.addcomponent(m2,"blue")
+ s.getscreen().register_shape("planet", planetshape)
+ s.getscreen().tracer(1,0)
+
+ ## setup gravitational system
+ gs = GravSys()
+ sun = Star(1000000, Vec(0,0), Vec(0,-2.5), gs, "circle")
+ sun.color("yellow")
+ sun.shapesize(1.8)
+ sun.pu()
+ earth = Star(12500, Vec(210,0), Vec(0,195), gs, "planet")
+ earth.pencolor("green")
+ earth.shapesize(0.8)
+ moon = Star(1, Vec(220,0), Vec(0,295), gs, "planet")
+ moon.pencolor("blue")
+ moon.shapesize(0.5)
+ gs.init()
+ gs.start()
+ return "Done!"
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ #mainloop()
diff --git a/Lib/turtledemo/round_dance.py b/Lib/turtledemo/round_dance.py
new file mode 100644
index 0000000000..10383614c6
--- /dev/null
+++ b/Lib/turtledemo/round_dance.py
@@ -0,0 +1,86 @@
+""" turtle-example-suite:
+
+ tdemo_round_dance.py
+
+(Needs version 1.1 of the turtle module that
+comes with Python 3.1)
+
+Dancing turtles have a compound shape
+consisting of a series of triangles of
+decreasing size.
+
+Turtles march along a circle while rotating
+pairwise in opposite direction, with one
+exception. Does that breaking of symmetry
+enhance the attractiveness of the example?
+
+Press any key to stop the animation.
+
+Technically: demonstrates use of compound
+shapes, transformation of shapes as well as
+cloning turtles. The animation is
+controlled through update().
+"""
+
+from turtle import *
+
+def stop():
+ global running
+ running = False
+
+def main():
+ global running
+ clearscreen()
+ bgcolor("gray10")
+ tracer(False)
+ shape("triangle")
+ f = 0.793402
+ phi = 9.064678
+ s = 5
+ c = 1
+ # create compound shape
+ sh = Shape("compound")
+ for i in range(10):
+ shapesize(s)
+ p =get_shapepoly()
+ s *= f
+ c *= f
+ tilt(-phi)
+ sh.addcomponent(p, (c, 0.25, 1-c), "black")
+ register_shape("multitri", sh)
+ # create dancers
+ shapesize(1)
+ shape("multitri")
+ pu()
+ setpos(0, -200)
+ dancers = []
+ for i in range(180):
+ fd(7)
+ tilt(-4)
+ lt(2)
+ update()
+ if i % 12 == 0:
+ dancers.append(clone())
+ home()
+ # dance
+ running = True
+ onkeypress(stop)
+ listen()
+ cs = 1
+ while running:
+ ta = -4
+ for dancer in dancers:
+ dancer.fd(7)
+ dancer.lt(2)
+ dancer.tilt(ta)
+ ta = -4 if ta > 0 else 2
+ if cs < 180:
+ right(4)
+ shapesize(cs)
+ cs *= 1.005
+ update()
+ return "DONE!"
+
+if __name__=='__main__':
+ print(main())
+ mainloop()
diff --git a/Lib/turtledemo/tree.py b/Lib/turtledemo/tree.py
new file mode 100644
index 0000000000..9c0b1f7bb4
--- /dev/null
+++ b/Lib/turtledemo/tree.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_tree.py
+
+Displays a 'breadth-first-tree' - in contrast
+to the classical Logo tree drawing programs,
+which use a depth-first-algorithm.
+
+Uses:
+(1) a tree-generator, where the drawing is
+quasi the side-effect, whereas the generator
+always yields None.
+(2) Turtle-cloning: At each branching point the
+current pen is cloned. So in the end there
+are 1024 turtles.
+"""
+from turtle import Turtle, mainloop
+from time import clock
+
+def tree(plist, l, a, f):
+ """ plist is list of pens
+ l is length of branch
+ a is half of the angle between 2 branches
+ f is factor by which branch is shortened
+ from level to level."""
+ if l > 3:
+ lst = []
+ for p in plist:
+ p.forward(l)
+ q = p.clone()
+ p.left(a)
+ q.right(a)
+ lst.append(p)
+ lst.append(q)
+ for x in tree(lst, l*f, a, f):
+ yield None
+
+def maketree():
+ p = Turtle()
+ p.setundobuffer(None)
+ p.hideturtle()
+ p.speed(0)
+ p.getscreen().tracer(30,0)
+ p.left(90)
+ p.penup()
+ p.forward(-210)
+ p.pendown()
+ t = tree([p], 200, 65, 0.6375)
+ for x in t:
+ pass
+ print(len(p.getscreen().turtles()))
+
+def main():
+ a=clock()
+ maketree()
+ b=clock()
+ return "done: %.2f sec." % (b-a)
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/turtle.cfg b/Lib/turtledemo/turtle.cfg
new file mode 100644
index 0000000000..bd89a741f9
--- /dev/null
+++ b/Lib/turtledemo/turtle.cfg
@@ -0,0 +1,10 @@
+width = 800
+height = 600
+canvwidth = 1200
+canvheight = 900
+shape = arrow
+mode = standard
+resizemode = auto
+fillcolor = ""
+title = Python turtle graphics demo.
+
diff --git a/Lib/turtledemo/two_canvases.py b/Lib/turtledemo/two_canvases.py
new file mode 100644
index 0000000000..02d89db57e
--- /dev/null
+++ b/Lib/turtledemo/two_canvases.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+## DEMONSTRATES USE OF 2 CANVASES, SO CANNOT BE RUN IN DEMOVIEWER!
+"""turtle example: Using TurtleScreen and RawTurtle
+for drawing on two distinct canvases.
+"""
+from turtle import TurtleScreen, RawTurtle, TK
+
+root = TK.Tk()
+cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff")
+cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee")
+cv1.pack()
+cv2.pack()
+
+s1 = TurtleScreen(cv1)
+s1.bgcolor(0.85, 0.85, 1)
+s2 = TurtleScreen(cv2)
+s2.bgcolor(1, 0.85, 0.85)
+
+p = RawTurtle(s1)
+q = RawTurtle(s2)
+
+p.color("red", (1, 0.85, 0.85))
+p.width(3)
+q.color("blue", (0.85, 0.85, 1))
+q.width(3)
+
+for t in p,q:
+ t.shape("turtle")
+ t.lt(36)
+
+q.lt(180)
+
+for t in p, q:
+ t.begin_fill()
+for i in range(5):
+ for t in p, q:
+ t.fd(50)
+ t.lt(72)
+for t in p,q:
+ t.end_fill()
+ t.lt(54)
+ t.pu()
+ t.bk(50)
+
+## Want to get some info?
+
+#print(s1, s2)
+#print(p, q)
+#print(s1.turtles())
+#print(s2.turtles())
+
+TK.mainloop()
diff --git a/Lib/turtledemo/wikipedia.py b/Lib/turtledemo/wikipedia.py
new file mode 100644
index 0000000000..0f274420c8
--- /dev/null
+++ b/Lib/turtledemo/wikipedia.py
@@ -0,0 +1,65 @@
+""" turtle-example-suite:
+
+ tdemo_wikipedia3.py
+
+This example is
+inspired by the Wikipedia article on turtle
+graphics. (See example wikipedia1 for URLs)
+
+First we create (ne-1) (i.e. 35 in this
+example) copies of our first turtle p.
+Then we let them perform their steps in
+parallel.
+
+Followed by a complete undo().
+"""
+from turtle import Screen, Turtle, mainloop
+from time import clock, sleep
+
+def mn_eck(p, ne,sz):
+ turtlelist = [p]
+ #create ne-1 additional turtles
+ for i in range(1,ne):
+ q = p.clone()
+ q.rt(360.0/ne)
+ turtlelist.append(q)
+ p = q
+ for i in range(ne):
+ c = abs(ne/2.0-i)/(ne*.7)
+ # let those ne turtles make a step
+ # in parallel:
+ for t in turtlelist:
+ t.rt(360./ne)
+ t.pencolor(1-c,0,c)
+ t.fd(sz)
+
+def main():
+ s = Screen()
+ s.bgcolor("black")
+ p=Turtle()
+ p.speed(0)
+ p.hideturtle()
+ p.pencolor("red")
+ p.pensize(3)
+
+ s.tracer(36,0)
+
+ at = clock()
+ mn_eck(p, 36, 19)
+ et = clock()
+ z1 = et-at
+
+ sleep(1)
+
+ at = clock()
+ while any([t.undobufferentries() for t in s.turtles()]):
+ for t in s.turtles():
+ t.undo()
+ et = clock()
+ return "runtime: %.3f sec" % (z1+et-at)
+
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/yinyang.py b/Lib/turtledemo/yinyang.py
new file mode 100644
index 0000000000..11d1f47cae
--- /dev/null
+++ b/Lib/turtledemo/yinyang.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_yinyang.py
+
+Another drawing suitable as a beginner's
+programming example.
+
+The small circles are drawn by the circle
+command.
+
+"""
+
+from turtle import *
+
+def yin(radius, color1, color2):
+ width(3)
+ color("black", color1)
+ begin_fill()
+ circle(radius/2., 180)
+ circle(radius, 180)
+ left(180)
+ circle(-radius/2., 180)
+ end_fill()
+ left(90)
+ up()
+ forward(radius*0.35)
+ right(90)
+ down()
+ color(color1, color2)
+ begin_fill()
+ circle(radius*0.15)
+ end_fill()
+ left(90)
+ up()
+ backward(radius*0.35)
+ down()
+ left(90)
+
+def main():
+ reset()
+ yin(200, "black", "white")
+ yin(200, "white", "black")
+ ht()
+ return "Done!"
+
+if __name__ == '__main__':
+ main()
+ mainloop()
diff --git a/Lib/unittest.py b/Lib/unittest.py
deleted file mode 100644
index 03a11b7d1c..0000000000
--- a/Lib/unittest.py
+++ /dev/null
@@ -1,1623 +0,0 @@
-#!/usr/bin/env python
-'''
-Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
-Smalltalk testing framework.
-
-This module contains the core framework classes that form the basis of
-specific test cases and suites (TestCase, TestSuite etc.), and also a
-text-based utility class for running the tests and reporting the results
- (TextTestRunner).
-
-Simple usage:
-
- import unittest
-
- class IntegerArithmenticTestCase(unittest.TestCase):
- def testAdd(self): ## test method names begin 'test*'
- self.assertEqual((1 + 2), 3)
- self.assertEqual(0 + 1, 1)
- def testMultiply(self):
- self.assertEqual((0 * 10), 0)
- self.assertEqual((5 * 8), 40)
-
- if __name__ == '__main__':
- unittest.main()
-
-Further information is available in the bundled documentation, and from
-
- http://docs.python.org/library/unittest.html
-
-Copyright (c) 1999-2003 Steve Purcell
-Copyright (c) 2003-2009 Python Software Foundation
-This module is free software, and you may redistribute it and/or modify
-it under the same terms as Python itself, so long as this copyright message
-and disclaimer are retained in their original form.
-
-IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
-THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
-AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
-SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-'''
-
-import difflib
-import functools
-import os
-import pprint
-import re
-import sys
-import time
-import traceback
-import types
-import warnings
-
-##############################################################################
-# Exported classes and functions
-##############################################################################
-__all__ = ['TestResult', 'TestCase', 'TestSuite',
- 'TextTestRunner', 'TestLoader', 'FunctionTestCase', 'main',
- 'defaultTestLoader', 'SkipTest', 'skip', 'skipIf', 'skipUnless',
- 'expectedFailure']
-
-# Expose obsolete functions for backwards compatibility
-__all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])
-
-
-##############################################################################
-# Test framework core
-##############################################################################
-
-def _strclass(cls):
- return "%s.%s" % (cls.__module__, cls.__name__)
-
-
-class SkipTest(Exception):
- """
- Raise this exception in a test to skip it.
-
- Usually you can use TestResult.skip() or one of the skipping decorators
- instead of raising this directly.
- """
- pass
-
-class _ExpectedFailure(Exception):
- """
- Raise this when a test is expected to fail.
-
- This is an implementation detail.
- """
-
- def __init__(self, exc_info):
- super(_ExpectedFailure, self).__init__()
- self.exc_info = exc_info
-
-class _UnexpectedSuccess(Exception):
- """
- The test was supposed to fail, but it didn't!
- """
- pass
-
-def _id(obj):
- return obj
-
-def skip(reason):
- """
- Unconditionally skip a test.
- """
- def decorator(test_item):
- if isinstance(test_item, type) and issubclass(test_item, TestCase):
- test_item.__unittest_skip__ = True
- test_item.__unittest_skip_why__ = reason
- return test_item
- @functools.wraps(test_item)
- def skip_wrapper(*args, **kwargs):
- raise SkipTest(reason)
- return skip_wrapper
- return decorator
-
-def skipIf(condition, reason):
- """
- Skip a test if the condition is true.
- """
- if condition:
- return skip(reason)
- return _id
-
-def skipUnless(condition, reason):
- """
- Skip a test unless the condition is true.
- """
- if not condition:
- return skip(reason)
- return _id
-
-
-def expectedFailure(func):
- @functools.wraps(func)
- def wrapper(*args, **kwargs):
- try:
- func(*args, **kwargs)
- except Exception:
- raise _ExpectedFailure(sys.exc_info())
- raise _UnexpectedSuccess
- return wrapper
-
-__unittest = 1
-
-class TestResult(object):
- """Holder for test result information.
-
- Test results are automatically managed by the TestCase and TestSuite
- classes, and do not need to be explicitly manipulated by writers of tests.
-
- Each instance holds the total number of tests run, and collections of
- failures and errors that occurred among those test runs. The collections
- contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
- formatted traceback of the error that occurred.
- """
- def __init__(self):
- self.failures = []
- self.errors = []
- self.testsRun = 0
- self.skipped = []
- self.expectedFailures = []
- self.unexpectedSuccesses = []
- self.shouldStop = False
-
- def startTest(self, test):
- "Called when the given test is about to be run"
- self.testsRun = self.testsRun + 1
-
- def startTestRun(self):
- """Called once before any tests are executed.
-
- See startTest for a method called before each test.
- """
-
- def stopTest(self, test):
- "Called when the given test has been run"
- pass
-
- def stopTestRun(self):
- """Called once after all tests are executed.
-
- See stopTest for a method called after each test.
- """
-
- def addError(self, test, err):
- """Called when an error has occurred. 'err' is a tuple of values as
- returned by sys.exc_info().
- """
- self.errors.append((test, self._exc_info_to_string(err, test)))
-
- def addFailure(self, test, err):
- """Called when an error has occurred. 'err' is a tuple of values as
- returned by sys.exc_info()."""
- self.failures.append((test, self._exc_info_to_string(err, test)))
-
- def addSuccess(self, test):
- "Called when a test has completed successfully"
- pass
-
- def addSkip(self, test, reason):
- """Called when a test is skipped."""
- self.skipped.append((test, reason))
-
- def addExpectedFailure(self, test, err):
- """Called when an expected failure/error occured."""
- self.expectedFailures.append(
- (test, self._exc_info_to_string(err, test)))
-
- def addUnexpectedSuccess(self, test):
- """Called when a test was expected to fail, but succeed."""
- self.unexpectedSuccesses.append(test)
-
- def wasSuccessful(self):
- "Tells whether or not this result was a success"
- return len(self.failures) == len(self.errors) == 0
-
- def stop(self):
- "Indicates that the tests should be aborted"
- self.shouldStop = True
-
- def _exc_info_to_string(self, err, test):
- """Converts a sys.exc_info()-style tuple of values into a string."""
- exctype, value, tb = err
- # Skip test runner traceback levels
- while tb and self._is_relevant_tb_level(tb):
- tb = tb.tb_next
- if exctype is test.failureException:
- # Skip assert*() traceback levels
- length = self._count_relevant_tb_levels(tb)
- return ''.join(traceback.format_exception(exctype, value,
- tb, length))
- return ''.join(traceback.format_exception(exctype, value, tb))
-
- def _is_relevant_tb_level(self, tb):
- return '__unittest' in tb.tb_frame.f_globals
-
- def _count_relevant_tb_levels(self, tb):
- length = 0
- while tb and not self._is_relevant_tb_level(tb):
- length += 1
- tb = tb.tb_next
- return length
-
- def __repr__(self):
- return "<%s run=%i errors=%i failures=%i>" % \
- (_strclass(self.__class__), self.testsRun, len(self.errors),
- len(self.failures))
-
-
-class _AssertRaisesContext(object):
- """A context manager used to implement TestCase.assertRaises* methods."""
-
-
- def __init__(self, expected, test_case, callable_obj=None,
- expected_regexp=None):
- self.expected = expected
- self.failureException = test_case.failureException
- if callable_obj is not None:
- try:
- self.obj_name = callable_obj.__name__
- except AttributeError:
- self.obj_name = str(callable_obj)
- else:
- self.obj_name = None
- self.expected_regex = expected_regexp
-
- def __enter__(self):
- pass
-
- def __exit__(self, exc_type, exc_value, tb):
- if exc_type is None:
- try:
- exc_name = self.expected.__name__
- except AttributeError:
- exc_name = str(self.expected)
- if self.obj_name:
- raise self.failureException("{0} not raised by {1}"
- .format(exc_name, self.obj_name))
- else:
- raise self.failureException("{0} not raised"
- .format(exc_name))
- if not issubclass(exc_type, self.expected):
- # let unexpected exceptions pass through
- return False
- if self.expected_regex is None:
- return True
-
- expected_regexp = self.expected_regex
- if isinstance(expected_regexp, (bytes, str)):
- expected_regexp = re.compile(expected_regexp)
- if not expected_regexp.search(str(exc_value)):
- raise self.failureException('"%s" does not match "%s"' %
- (expected_regexp.pattern, str(exc_value)))
- return True
-
-
-class _AssertWrapper(object):
- """Wrap entries in the _type_equality_funcs registry to make them deep
- copyable."""
-
- def __init__(self, function):
- self.function = function
-
- def __deepcopy__(self, memo):
- memo[id(self)] = self
-
-
-class TestCase(object):
- """A class whose instances are single test cases.
-
- By default, the test code itself should be placed in a method named
- 'runTest'.
-
- If the fixture may be used for many test cases, create as
- many test methods as are needed. When instantiating such a TestCase
- subclass, specify in the constructor arguments the name of the test method
- that the instance is to execute.
-
- Test authors should subclass TestCase for their own tests. Construction
- and deconstruction of the test's environment ('fixture') can be
- implemented by overriding the 'setUp' and 'tearDown' methods respectively.
-
- If it is necessary to override the __init__ method, the base class
- __init__ method must always be called. It is important that subclasses
- should not change the signature of their __init__ method, since instances
- of the classes are instantiated automatically by parts of the framework
- in order to be run.
- """
-
- # This attribute determines which exception will be raised when
- # the instance's assertion methods fail; test methods raising this
- # exception will be deemed to have 'failed' rather than 'errored'
-
- failureException = AssertionError
-
- # This attribute determines whether long messages (including repr of
- # objects used in assert methods) will be printed on failure in *addition*
- # to any explicit message passed.
-
- longMessage = False
-
-
- def __init__(self, methodName='runTest'):
- """Create an instance of the class that will use the named test
- method when executed. Raises a ValueError if the instance does
- not have a method with the specified name.
- """
- self._testMethodName = methodName
- self._resultForDoCleanups = None
- try:
- testMethod = getattr(self, methodName)
- except AttributeError:
- raise ValueError("no such test method in %s: %s" % \
- (self.__class__, methodName))
- self._testMethodDoc = testMethod.__doc__
- self._cleanups = []
-
- # Map types to custom assertEqual functions that will compare
- # instances of said type in more detail to generate a more useful
- # error message.
- self._type_equality_funcs = {}
- self.addTypeEqualityFunc(dict, self.assertDictEqual)
- self.addTypeEqualityFunc(list, self.assertListEqual)
- self.addTypeEqualityFunc(tuple, self.assertTupleEqual)
- self.addTypeEqualityFunc(set, self.assertSetEqual)
- self.addTypeEqualityFunc(frozenset, self.assertSetEqual)
-
- def addTypeEqualityFunc(self, typeobj, function):
- """Add a type specific assertEqual style function to compare a type.
-
- This method is for use by TestCase subclasses that need to register
- their own type equality functions to provide nicer error messages.
-
- Args:
- typeobj: The data type to call this function on when both values
- are of the same type in assertEqual().
- function: The callable taking two arguments and an optional
- msg= argument that raises self.failureException with a
- useful error message when the two arguments are not equal.
- """
- self._type_equality_funcs[typeobj] = _AssertWrapper(function)
-
- def addCleanup(self, function, *args, **kwargs):
- """Add a function, with arguments, to be called when the test is
- completed. Functions added are called on a LIFO basis and are
- called after tearDown on test failure or success.
-
- Cleanup items are called even if setUp fails (unlike tearDown)."""
- self._cleanups.append((function, args, kwargs))
-
- def setUp(self):
- "Hook method for setting up the test fixture before exercising it."
- pass
-
- def tearDown(self):
- "Hook method for deconstructing the test fixture after testing it."
- pass
-
- def countTestCases(self):
- return 1
-
- def defaultTestResult(self):
- return TestResult()
-
- def shortDescription(self):
- """Returns both the test method name and first line of its docstring.
-
- If no docstring is given, only returns the method name.
-
- This method overrides unittest.TestCase.shortDescription(), which
- only returns the first line of the docstring, obscuring the name
- of the test upon failure.
- """
- desc = str(self)
- doc_first_line = None
-
- if self._testMethodDoc:
- doc_first_line = self._testMethodDoc.split("\n")[0].strip()
- if doc_first_line:
- desc = '\n'.join((desc, doc_first_line))
- return desc
-
- def id(self):
- return "%s.%s" % (_strclass(self.__class__), self._testMethodName)
-
- def __eq__(self, other):
- if type(self) is not type(other):
- return NotImplemented
-
- return self._testMethodName == other._testMethodName
-
- def __ne__(self, other):
- return not self == other
-
- def __hash__(self):
- return hash((type(self), self._testMethodName))
-
- def __str__(self):
- return "%s (%s)" % (self._testMethodName, _strclass(self.__class__))
-
- def __repr__(self):
- return "<%s testMethod=%s>" % \
- (_strclass(self.__class__), self._testMethodName)
-
- def run(self, result=None):
- orig_result = result
- if result is None:
- result = self.defaultTestResult()
- startTestRun = getattr(result, 'startTestRun', None)
- if startTestRun is not None:
- startTestRun()
-
- self._resultForDoCleanups = result
- result.startTest(self)
- if getattr(self.__class__, "__unittest_skip__", False):
- # If the whole class was skipped.
- try:
- result.addSkip(self, self.__class__.__unittest_skip_why__)
- finally:
- result.stopTest(self)
- return
- testMethod = getattr(self, self._testMethodName)
- try:
- success = False
- try:
- self.setUp()
- except SkipTest as e:
- result.addSkip(self, str(e))
- except Exception:
- result.addError(self, sys.exc_info())
- else:
- try:
- testMethod()
- except self.failureException:
- result.addFailure(self, sys.exc_info())
- except _ExpectedFailure as e:
- result.addExpectedFailure(self, e.exc_info)
- except _UnexpectedSuccess:
- result.addUnexpectedSuccess(self)
- except SkipTest as e:
- result.addSkip(self, str(e))
- except Exception:
- result.addError(self, sys.exc_info())
- else:
- success = True
-
- try:
- self.tearDown()
- except Exception:
- result.addError(self, sys.exc_info())
- success = False
-
- cleanUpSuccess = self.doCleanups()
- success = success and cleanUpSuccess
- if success:
- result.addSuccess(self)
- finally:
- result.stopTest(self)
- if orig_result is None:
- stopTestRun = getattr(result, 'stopTestRun', None)
- if stopTestRun is not None:
- stopTestRun()
-
- def doCleanups(self):
- """Execute all cleanup functions. Normally called for you after
- tearDown."""
- result = self._resultForDoCleanups
- ok = True
- while self._cleanups:
- function, args, kwargs = self._cleanups.pop(-1)
- try:
- function(*args, **kwargs)
- except Exception:
- ok = False
- result.addError(self, sys.exc_info())
- return ok
-
- def __call__(self, *args, **kwds):
- return self.run(*args, **kwds)
-
- def debug(self):
- """Run the test without collecting errors in a TestResult"""
- self.setUp()
- getattr(self, self._testMethodName)()
- self.tearDown()
-
- def skipTest(self, reason):
- """Skip this test."""
- raise SkipTest(reason)
-
- def fail(self, msg=None):
- """Fail immediately, with the given message."""
- raise self.failureException(msg)
-
- def assertFalse(self, expr, msg=None):
- """Check that the expression is false."""
- if expr:
- msg = self._formatMessage(msg, "%r is not false" % expr)
- raise self.failureException(msg)
-
- def assertTrue(self, expr, msg=None):
- """Check that the expression is true."""
- if not expr:
- msg = self._formatMessage(msg, "%r is not true" % expr)
- raise self.failureException(msg)
-
- def _formatMessage(self, msg, standardMsg):
- """Honour the longMessage attribute when generating failure messages.
- If longMessage is False this means:
- * Use only an explicit message if it is provided
- * Otherwise use the standard message for the assert
-
- If longMessage is True:
- * Use the standard message
- * If an explicit message is provided, plus ' : ' and the explicit message
- """
- if not self.longMessage:
- return msg or standardMsg
- if msg is None:
- return standardMsg
- return standardMsg + ' : ' + msg
-
-
- def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
- """Fail unless an exception of class excClass is thrown
- by callableObj when invoked with arguments args and keyword
- arguments kwargs. If a different type of exception is
- thrown, it will not be caught, and the test case will be
- deemed to have suffered an error, exactly as for an
- unexpected exception.
-
- If called with callableObj omitted or None, will return a
- context object used like this::
-
- with self.assertRaises(some_error_class):
- do_something()
- """
- context = _AssertRaisesContext(excClass, self, callableObj)
- if callableObj is None:
- return context
- with context:
- callableObj(*args, **kwargs)
-
- def _getAssertEqualityFunc(self, first, second):
- """Get a detailed comparison function for the types of the two args.
-
- Returns: A callable accepting (first, second, msg=None) that will
- raise a failure exception if first != second with a useful human
- readable error message for those types.
- """
- #
- # NOTE(gregory.p.smith): I considered isinstance(first, type(second))
- # and vice versa. I opted for the conservative approach in case
- # subclasses are not intended to be compared in detail to their super
- # class instances using a type equality func. This means testing
- # subtypes won't automagically use the detailed comparison. Callers
- # should use their type specific assertSpamEqual method to compare
- # subclasses if the detailed comparison is desired and appropriate.
- # See the discussion in http://bugs.python.org/issue2578.
- #
- if type(first) is type(second):
- asserter = self._type_equality_funcs.get(type(first))
- if asserter is not None:
- return asserter.function
-
- return self._baseAssertEqual
-
- def _baseAssertEqual(self, first, second, msg=None):
- """The default assertEqual implementation, not type specific."""
- if not first == second:
- standardMsg = '%r != %r' % (first, second)
- msg = self._formatMessage(msg, standardMsg)
- raise self.failureException(msg)
-
- def assertEqual(self, first, second, msg=None):
- """Fail if the two objects are unequal as determined by the '=='
- operator.
- """
- assertion_func = self._getAssertEqualityFunc(first, second)
- assertion_func(first, second, msg=msg)
-
- def assertNotEqual(self, first, second, msg=None):
- """Fail if the two objects are equal as determined by the '=='
- operator.
- """
- if not first != second:
- msg = self._formatMessage(msg, '%r == %r' % (first, second))
- raise self.failureException(msg)
-
- def assertAlmostEqual(self, first, second, places=7, msg=None):
- """Fail if the two objects are unequal as determined by their
- difference rounded to the given number of decimal places
- (default 7) and comparing to zero.
-
- Note that decimal places (from zero) are usually not the same
- as significant digits (measured from the most signficant digit).
- """
- if round(abs(second-first), places) != 0:
- standardMsg = '%r != %r within %r places' % (first, second, places)
- msg = self._formatMessage(msg, standardMsg)
- raise self.failureException(msg)
-
- def assertNotAlmostEqual(self, first, second, places=7, msg=None):
- """Fail if the two objects are equal as determined by their
- difference rounded to the given number of decimal places
- (default 7) and comparing to zero.
-
- Note that decimal places (from zero) are usually not the same
- as significant digits (measured from the most signficant digit).
- """
- if round(abs(second-first), places) == 0:
- standardMsg = '%r == %r within %r places' % (first, second, places)
- msg = self._formatMessage(msg, standardMsg)
- raise self.failureException(msg)
-
- # Synonyms for assertion methods
-
- # The plurals are undocumented. Keep them that way to discourage use.
- # Do not add more. Do not remove.
- # Going through a deprecation cycle on these would annoy many people.
- assertEquals = assertEqual
- assertNotEquals = assertNotEqual
- assertAlmostEquals = assertAlmostEqual
- assertNotAlmostEquals = assertNotAlmostEqual
- assert_ = assertTrue
-
- # These fail* assertion method names are pending deprecation and will
- # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578
- def _deprecate(original_func):
- def deprecated_func(*args, **kwargs):
- warnings.warn(
- 'Please use {0} instead.'.format(original_func.__name__),
- PendingDeprecationWarning, 2)
- return original_func(*args, **kwargs)
- return deprecated_func
-
- failUnlessEqual = _deprecate(assertEqual)
- failIfEqual = _deprecate(assertNotEqual)
- failUnlessAlmostEqual = _deprecate(assertAlmostEqual)
- failIfAlmostEqual = _deprecate(assertNotAlmostEqual)
- failUnless = _deprecate(assertTrue)
- failUnlessRaises = _deprecate(assertRaises)
- failIf = _deprecate(assertFalse)
-
- def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
- """An equality assertion for ordered sequences (like lists and tuples).
-
- For the purposes of this function, a valid ordered sequence type is one
- which can be indexed, has a length, and has an equality operator.
-
- Args:
- seq1: The first sequence to compare.
- seq2: The second sequence to compare.
- seq_type: The expected datatype of the sequences, or None if no
- datatype should be enforced.
- msg: Optional message to use on failure instead of a list of
- differences.
- """
- if seq_type != None:
- seq_type_name = seq_type.__name__
- if not isinstance(seq1, seq_type):
- raise self.failureException('First sequence is not a %s: %r'
- % (seq_type_name, seq1))
- if not isinstance(seq2, seq_type):
- raise self.failureException('Second sequence is not a %s: %r'
- % (seq_type_name, seq2))
- else:
- seq_type_name = "sequence"
-
- differing = None
- try:
- len1 = len(seq1)
- except (TypeError, NotImplementedError):
- differing = 'First %s has no length. Non-sequence?' % (
- seq_type_name)
-
- if differing is None:
- try:
- len2 = len(seq2)
- except (TypeError, NotImplementedError):
- differing = 'Second %s has no length. Non-sequence?' % (
- seq_type_name)
-
- if differing is None:
- if seq1 == seq2:
- return
-
- seq1_repr = repr(seq1)
- seq2_repr = repr(seq2)
- if len(seq1_repr) > 30:
- seq1_repr = seq1_repr[:30] + '...'
- if len(seq2_repr) > 30:
- seq2_repr = seq2_repr[:30] + '...'
- elements = (seq_type_name.capitalize(), seq1_repr, seq2_repr)
- differing = '%ss differ: %s != %s\n' % elements
-
- for i in range(min(len1, len2)):
- try:
- item1 = seq1[i]
- except (TypeError, IndexError, NotImplementedError):
- differing += ('\nUnable to index element %d of first %s\n' %
- (i, seq_type_name))
- break
-
- try:
- item2 = seq2[i]
- except (TypeError, IndexError, NotImplementedError):
- differing += ('\nUnable to index element %d of second %s\n' %
- (i, seq_type_name))
- break
-
- if item1 != item2:
- differing += ('\nFirst differing element %d:\n%s\n%s\n' %
- (i, item1, item2))
- break
- else:
- if (len1 == len2 and seq_type is None and
- type(seq1) != type(seq2)):
- # The sequences are the same, but have differing types.
- return
-
- if len1 > len2:
- differing += ('\nFirst %s contains %d additional '
- 'elements.\n' % (seq_type_name, len1 - len2))
- try:
- differing += ('First extra element %d:\n%s\n' %
- (len2, seq1[len2]))
- except (TypeError, IndexError, NotImplementedError):
- differing += ('Unable to index element %d '
- 'of first %s\n' % (len2, seq_type_name))
- elif len1 < len2:
- differing += ('\nSecond %s contains %d additional '
- 'elements.\n' % (seq_type_name, len2 - len1))
- try:
- differing += ('First extra element %d:\n%s\n' %
- (len1, seq2[len1]))
- except (TypeError, IndexError, NotImplementedError):
- differing += ('Unable to index element %d '
- 'of second %s\n' % (len1, seq_type_name))
- standardMsg = differing + '\n' + '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(),
- pprint.pformat(seq2).splitlines()))
- msg = self._formatMessage(msg, standardMsg)
- self.fail(msg)
-
- def assertListEqual(self, list1, list2, msg=None):
- """A list-specific equality assertion.
-
- Args:
- list1: The first list to compare.
- list2: The second list to compare.
- msg: Optional message to use on failure instead of a list of
- differences.
-
- """
- self.assertSequenceEqual(list1, list2, msg, seq_type=list)
-
- def assertTupleEqual(self, tuple1, tuple2, msg=None):
- """A tuple-specific equality assertion.
-
- Args:
- tuple1: The first tuple to compare.
- tuple2: The second tuple to compare.
- msg: Optional message to use on failure instead of a list of
- differences.
- """
- self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
-
- def assertSetEqual(self, set1, set2, msg=None):
- """A set-specific equality assertion.
-
- Args:
- set1: The first set to compare.
- set2: The second set to compare.
- msg: Optional message to use on failure instead of a list of
- differences.
-
- For more general containership equality, assertSameElements will work
- with things other than sets. This uses ducktyping to support
- different types of sets, and is optimized for sets specifically
- (parameters must support a difference method).
- """
- try:
- difference1 = set1.difference(set2)
- except TypeError as e:
- self.fail('invalid type when attempting set difference: %s' % e)
- except AttributeError as e:
- self.fail('first argument does not support set difference: %s' % e)
-
- try:
- difference2 = set2.difference(set1)
- except TypeError as e:
- self.fail('invalid type when attempting set difference: %s' % e)
- except AttributeError as e:
- self.fail('second argument does not support set difference: %s' % e)
-
- if not (difference1 or difference2):
- return
-
- lines = []
- if difference1:
- lines.append('Items in the first set but not the second:')
- for item in difference1:
- lines.append(repr(item))
- if difference2:
- lines.append('Items in the second set but not the first:')
- for item in difference2:
- lines.append(repr(item))
-
- standardMsg = '\n'.join(lines)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertIn(self, member, container, msg=None):
- """Just like self.assertTrue(a in b), but with a nicer default message."""
- if member not in container:
- standardMsg = '%r not found in %r' % (member, container)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertNotIn(self, member, container, msg=None):
- """Just like self.assertTrue(a not in b), but with a nicer default message."""
- if member in container:
- standardMsg = '%r unexpectedly found in %r' % (member, container)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertIs(self, expr1, expr2, msg=None):
- """Just like self.assertTrue(a is b), but with a nicer default message."""
- if expr1 is not expr2:
- standardMsg = '%r is not %r' % (expr1, expr2)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertIsNot(self, expr1, expr2, msg=None):
- """Just like self.assertTrue(a is not b), but with a nicer default message."""
- if expr1 is expr2:
- standardMsg = 'unexpectedly identical: %r' % (expr1,)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertDictEqual(self, d1, d2, msg=None):
- self.assertTrue(isinstance(d1, dict), 'First argument is not a dictionary')
- self.assertTrue(isinstance(d2, dict), 'Second argument is not a dictionary')
-
- if d1 != d2:
- standardMsg = ('\n' + '\n'.join(difflib.ndiff(
- pprint.pformat(d1).splitlines(),
- pprint.pformat(d2).splitlines())))
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertDictContainsSubset(self, expected, actual, msg=None):
- """Checks whether actual is a superset of expected."""
- missing = []
- mismatched = []
- for key, value in expected.items():
- if key not in actual:
- missing.append(key)
- elif value != actual[key]:
- mismatched.append('%s, expected: %s, actual: %s' % (key, value, actual[key]))
-
- if not (missing or mismatched):
- return
-
- standardMsg = ''
- if missing:
- standardMsg = 'Missing: %r' % ','.join(missing)
- if mismatched:
- if standardMsg:
- standardMsg += '; '
- standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
-
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertSameElements(self, expected_seq, actual_seq, msg=None):
- """An unordered sequence specific comparison.
-
- Raises with an error message listing which elements of expected_seq
- are missing from actual_seq and vice versa if any.
- """
- try:
- expected = set(expected_seq)
- actual = set(actual_seq)
- missing = list(expected.difference(actual))
- unexpected = list(actual.difference(expected))
- missing.sort()
- unexpected.sort()
- except TypeError:
- # Fall back to slower list-compare if any of the objects are
- # not hashable.
- expected = list(expected_seq)
- actual = list(actual_seq)
- try:
- expected.sort()
- actual.sort()
- except TypeError:
- missing, unexpected = _UnorderableListDifference(expected, actual)
- else:
- missing, unexpected = _SortedListDifference(expected, actual)
- errors = []
- if missing:
- errors.append('Expected, but missing:\n %r' % missing)
- if unexpected:
- errors.append('Unexpected, but present:\n %r' % unexpected)
- if errors:
- standardMsg = '\n'.join(errors)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertMultiLineEqual(self, first, second, msg=None):
- """Assert that two multi-line strings are equal."""
- self.assertTrue(isinstance(first, str), (
- 'First argument is not a string'))
- self.assertTrue(isinstance(second, str), (
- 'Second argument is not a string'))
-
- if first != second:
- standardMsg = '\n' + ''.join(difflib.ndiff(first.splitlines(True), second.splitlines(True)))
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertLess(self, a, b, msg=None):
- """Just like self.assertTrue(a < b), but with a nicer default message."""
- if not a < b:
- standardMsg = '%r not less than %r' % (a, b)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertLessEqual(self, a, b, msg=None):
- """Just like self.assertTrue(a <= b), but with a nicer default message."""
- if not a <= b:
- standardMsg = '%r not less than or equal to %r' % (a, b)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertGreater(self, a, b, msg=None):
- """Just like self.assertTrue(a > b), but with a nicer default message."""
- if not a > b:
- standardMsg = '%r not greater than %r' % (a, b)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertGreaterEqual(self, a, b, msg=None):
- """Just like self.assertTrue(a >= b), but with a nicer default message."""
- if not a >= b:
- standardMsg = '%r not greater than or equal to %r' % (a, b)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertIsNone(self, obj, msg=None):
- """Same as self.assertTrue(obj is None), with a nicer default message."""
- if obj is not None:
- standardMsg = '%r is not None' % obj
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertIsNotNone(self, obj, msg=None):
- """Included for symmetry with assertIsNone."""
- if obj is None:
- standardMsg = 'unexpectedly None'
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertRaisesRegexp(self, expected_exception, expected_regexp,
- callable_obj=None, *args, **kwargs):
- """Asserts that the message in a raised exception matches a regexp.
-
- Args:
- expected_exception: Exception class expected to be raised.
- expected_regexp: Regexp (re pattern object or string) expected
- to be found in error message.
- callable_obj: Function to be called.
- args: Extra args.
- kwargs: Extra kwargs.
- """
- context = _AssertRaisesContext(expected_exception, self, callable_obj,
- expected_regexp)
- if callable_obj is None:
- return context
- with context:
- callable_obj(*args, **kwargs)
-
- def assertRegexpMatches(self, text, expected_regex, msg=None):
- if isinstance(expected_regex, (str, bytes)):
- expected_regex = re.compile(expected_regex)
- if not expected_regex.search(text):
- msg = msg or "Regexp didn't match"
- msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
- raise self.failureException(msg)
-
-
-def _SortedListDifference(expected, actual):
- """Finds elements in only one or the other of two, sorted input lists.
-
- Returns a two-element tuple of lists. The first list contains those
- elements in the "expected" list but not in the "actual" list, and the
- second contains those elements in the "actual" list but not in the
- "expected" list. Duplicate elements in either input list are ignored.
- """
- i = j = 0
- missing = []
- unexpected = []
- while True:
- try:
- e = expected[i]
- a = actual[j]
- if e < a:
- missing.append(e)
- i += 1
- while expected[i] == e:
- i += 1
- elif e > a:
- unexpected.append(a)
- j += 1
- while actual[j] == a:
- j += 1
- else:
- i += 1
- try:
- while expected[i] == e:
- i += 1
- finally:
- j += 1
- while actual[j] == a:
- j += 1
- except IndexError:
- missing.extend(expected[i:])
- unexpected.extend(actual[j:])
- break
- return missing, unexpected
-
-def _UnorderableListDifference(expected, actual):
- """Same behavior as _SortedListDifference but
- for lists of unorderable items (like dicts).
-
- As it does a linear search per item (remove) it
- has O(n*n) performance."""
- missing = []
- while expected:
- item = expected.pop()
- try:
- actual.remove(item)
- except ValueError:
- missing.append(item)
-
- # anything left in actual is unexpected
- return missing, actual
-
-class TestSuite(object):
- """A test suite is a composite test consisting of a number of TestCases.
-
- For use, create an instance of TestSuite, then add test case instances.
- When all tests have been added, the suite can be passed to a test
- runner, such as TextTestRunner. It will run the individual test cases
- in the order in which they were added, aggregating the results. When
- subclassing, do not forget to call the base class constructor.
- """
- def __init__(self, tests=()):
- self._tests = []
- self.addTests(tests)
-
- def __repr__(self):
- return "<%s tests=%s>" % (_strclass(self.__class__), list(self))
-
- def __eq__(self, other):
- if not isinstance(other, self.__class__):
- return NotImplemented
- return list(self) == list(other)
-
- def __ne__(self, other):
- return not self == other
-
- def __iter__(self):
- return iter(self._tests)
-
- def countTestCases(self):
- cases = 0
- for test in self:
- cases += test.countTestCases()
- return cases
-
- def addTest(self, test):
- # sanity checks
- if not hasattr(test, '__call__'):
- raise TypeError("the test to add must be callable")
- if isinstance(test, type) and issubclass(test, (TestCase, TestSuite)):
- raise TypeError("TestCases and TestSuites must be instantiated "
- "before passing them to addTest()")
- self._tests.append(test)
-
- def addTests(self, tests):
- if isinstance(tests, str):
- raise TypeError("tests must be an iterable of tests, not a string")
- for test in tests:
- self.addTest(test)
-
- def run(self, result):
- for test in self:
- if result.shouldStop:
- break
- test(result)
- return result
-
- def __call__(self, *args, **kwds):
- return self.run(*args, **kwds)
-
- def debug(self):
- """Run the tests without collecting errors in a TestResult"""
- for test in self:
- test.debug()
-
-
-class FunctionTestCase(TestCase):
- """A test case that wraps a test function.
-
- This is useful for slipping pre-existing test functions into the
- unittest framework. Optionally, set-up and tidy-up functions can be
- supplied. As with TestCase, the tidy-up ('tearDown') function will
- always be called if the set-up ('setUp') function ran successfully.
- """
-
- def __init__(self, testFunc, setUp=None, tearDown=None, description=None):
- super(FunctionTestCase, self).__init__()
- self._setUpFunc = setUp
- self._tearDownFunc = tearDown
- self._testFunc = testFunc
- self._description = description
-
- def setUp(self):
- if self._setUpFunc is not None:
- self._setUpFunc()
-
- def tearDown(self):
- if self._tearDownFunc is not None:
- self._tearDownFunc()
-
- def runTest(self):
- self._testFunc()
-
- def id(self):
- return self._testFunc.__name__
-
- def __eq__(self, other):
- if not isinstance(other, self.__class__):
- return NotImplemented
-
- return self._setUpFunc == other._setUpFunc and \
- self._tearDownFunc == other._tearDownFunc and \
- self._testFunc == other._testFunc and \
- self._description == other._description
-
- def __ne__(self, other):
- return not self == other
-
- def __hash__(self):
- return hash((type(self), self._setUpFunc, self._tearDownFunc,
- self._testFunc, self._description))
-
- def __str__(self):
- return "%s (%s)" % (_strclass(self.__class__), self._testFunc.__name__)
-
- def __repr__(self):
- return "<%s testFunc=%s>" % (_strclass(self.__class__), self._testFunc)
-
- def shortDescription(self):
- if self._description is not None:
- return self._description
- doc = self._testFunc.__doc__
- return doc and doc.split("\n")[0].strip() or None
-
-
-
-##############################################################################
-# Locating and loading tests
-##############################################################################
-
-def CmpToKey(mycmp):
- 'Convert a cmp= function into a key= function'
- class K(object):
- def __init__(self, obj, *args):
- self.obj = obj
- def __lt__(self, other):
- return mycmp(self.obj, other.obj) == -1
- return K
-
-def three_way_cmp(x, y):
- """Return -1 if x < y, 0 if x == y and 1 if x > y"""
- return (x > y) - (x < y)
-
-class TestLoader(object):
- """
- This class is responsible for loading tests according to various criteria
- and returning them wrapped in a TestSuite
- """
- testMethodPrefix = 'test'
- sortTestMethodsUsing = staticmethod(three_way_cmp)
- suiteClass = TestSuite
-
- def loadTestsFromTestCase(self, testCaseClass):
- """Return a suite of all tests cases contained in testCaseClass"""
- if issubclass(testCaseClass, TestSuite):
- raise TypeError("Test cases should not be derived from TestSuite." \
- " Maybe you meant to derive from TestCase?")
- testCaseNames = self.getTestCaseNames(testCaseClass)
- if not testCaseNames and hasattr(testCaseClass, 'runTest'):
- testCaseNames = ['runTest']
- suite = self.suiteClass(map(testCaseClass, testCaseNames))
- return suite
-
- def loadTestsFromModule(self, module):
- """Return a suite of all tests cases contained in the given module"""
- tests = []
- for name in dir(module):
- obj = getattr(module, name)
- if isinstance(obj, type) and issubclass(obj, TestCase):
- tests.append(self.loadTestsFromTestCase(obj))
- return self.suiteClass(tests)
-
- def loadTestsFromName(self, name, module=None):
- """Return a suite of all tests cases given a string specifier.
-
- The name may resolve either to a module, a test case class, a
- test method within a test case class, or a callable object which
- returns a TestCase or TestSuite instance.
-
- The method optionally resolves the names relative to a given module.
- """
- parts = name.split('.')
- if module is None:
- parts_copy = parts[:]
- while parts_copy:
- try:
- module = __import__('.'.join(parts_copy))
- break
- except ImportError:
- del parts_copy[-1]
- if not parts_copy:
- raise
- parts = parts[1:]
- obj = module
- for part in parts:
- parent, obj = obj, getattr(obj, part)
-
- if isinstance(obj, types.ModuleType):
- return self.loadTestsFromModule(obj)
- elif isinstance(obj, type) and issubclass(obj, TestCase):
- return self.loadTestsFromTestCase(obj)
- elif (isinstance(obj, types.FunctionType) and
- isinstance(parent, type) and
- issubclass(parent, TestCase)):
- name = obj.__name__
- inst = parent(name)
- # static methods follow a different path
- if not isinstance(getattr(inst, name), types.FunctionType):
- return TestSuite([inst])
- elif isinstance(obj, TestSuite):
- return obj
-
- if hasattr(obj, '__call__'):
- test = obj()
- if isinstance(test, TestSuite):
- return test
- elif isinstance(test, TestCase):
- return TestSuite([test])
- else:
- raise TypeError("calling %s returned %s, not a test" %
- (obj, test))
- else:
- raise TypeError("don't know how to make test from: %s" % obj)
-
- def loadTestsFromNames(self, names, module=None):
- """Return a suite of all tests cases found using the given sequence
- of string specifiers. See 'loadTestsFromName()'.
- """
- suites = [self.loadTestsFromName(name, module) for name in names]
- return self.suiteClass(suites)
-
- def getTestCaseNames(self, testCaseClass):
- """Return a sorted sequence of method names found within testCaseClass
- """
- def isTestMethod(attrname, testCaseClass=testCaseClass,
- prefix=self.testMethodPrefix):
- return attrname.startswith(prefix) and \
- hasattr(getattr(testCaseClass, attrname), '__call__')
- testFnNames = list(filter(isTestMethod, dir(testCaseClass)))
- if self.sortTestMethodsUsing:
- testFnNames.sort(key=CmpToKey(self.sortTestMethodsUsing))
- return testFnNames
-
-
-
-defaultTestLoader = TestLoader()
-
-
-##############################################################################
-# Patches for old functions: these functions should be considered obsolete
-##############################################################################
-
-def _makeLoader(prefix, sortUsing, suiteClass=None):
- loader = TestLoader()
- loader.sortTestMethodsUsing = sortUsing
- loader.testMethodPrefix = prefix
- if suiteClass: loader.suiteClass = suiteClass
- return loader
-
-def getTestCaseNames(testCaseClass, prefix, sortUsing=three_way_cmp):
- return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass)
-
-def makeSuite(testCaseClass, prefix='test', sortUsing=three_way_cmp,
- suiteClass=TestSuite):
- return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(
- testCaseClass)
-
-def findTestCases(module, prefix='test', sortUsing=three_way_cmp,
- suiteClass=TestSuite):
- return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(
- module)
-
-
-##############################################################################
-# Text UI
-##############################################################################
-
-class _WritelnDecorator(object):
- """Used to decorate file-like objects with a handy 'writeln' method"""
- def __init__(self,stream):
- self.stream = stream
-
- def __getattr__(self, attr):
- return getattr(self.stream,attr)
-
- def writeln(self, arg=None):
- if arg:
- self.write(arg)
- self.write('\n') # text-mode streams translate to \r\n if needed
-
-
-class _TextTestResult(TestResult):
- """A test result class that can print formatted text results to a stream.
-
- Used by TextTestRunner.
- """
- separator1 = '=' * 70
- separator2 = '-' * 70
-
- def __init__(self, stream, descriptions, verbosity):
- super(_TextTestResult, self).__init__()
- self.stream = stream
- self.showAll = verbosity > 1
- self.dots = verbosity == 1
- self.descriptions = descriptions
-
- def getDescription(self, test):
- if self.descriptions:
- return test.shortDescription() or str(test)
- else:
- return str(test)
-
- def startTest(self, test):
- super(_TextTestResult, self).startTest(test)
- if self.showAll:
- self.stream.write(self.getDescription(test))
- self.stream.write(" ... ")
- self.stream.flush()
-
- def addSuccess(self, test):
- super(_TextTestResult, self).addSuccess(test)
- if self.showAll:
- self.stream.writeln("ok")
- elif self.dots:
- self.stream.write('.')
- self.stream.flush()
-
- def addError(self, test, err):
- super(_TextTestResult, self).addError(test, err)
- if self.showAll:
- self.stream.writeln("ERROR")
- elif self.dots:
- self.stream.write('E')
- self.stream.flush()
-
- def addFailure(self, test, err):
- super(_TextTestResult, self).addFailure(test, err)
- if self.showAll:
- self.stream.writeln("FAIL")
- elif self.dots:
- self.stream.write('F')
- self.stream.flush()
-
- def addSkip(self, test, reason):
- super(_TextTestResult, self).addSkip(test, reason)
- if self.showAll:
- self.stream.writeln("skipped {0!r}".format(reason))
- elif self.dots:
- self.stream.write("s")
- self.stream.flush()
-
- def addExpectedFailure(self, test, err):
- super(_TextTestResult, self).addExpectedFailure(test, err)
- if self.showAll:
- self.stream.writeln("expected failure")
- elif self.dots:
- self.stream.write("x")
- self.stream.flush()
-
- def addUnexpectedSuccess(self, test):
- super(_TextTestResult, self).addUnexpectedSuccess(test)
- if self.showAll:
- self.stream.writeln("unexpected success")
- elif self.dots:
- self.stream.write("u")
- self.stream.flush()
-
- def printErrors(self):
- if self.dots or self.showAll:
- self.stream.writeln()
- self.printErrorList('ERROR', self.errors)
- self.printErrorList('FAIL', self.failures)
-
- def printErrorList(self, flavour, errors):
- for test, err in errors:
- self.stream.writeln(self.separator1)
- self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
- self.stream.writeln(self.separator2)
- self.stream.writeln("%s" % err)
-
-
-class TextTestRunner(object):
- """A test runner class that displays results in textual form.
-
- It prints out the names of tests as they are run, errors as they
- occur, and a summary of the results at the end of the test run.
- """
- def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1):
- self.stream = _WritelnDecorator(stream)
- self.descriptions = descriptions
- self.verbosity = verbosity
-
- def _makeResult(self):
- return _TextTestResult(self.stream, self.descriptions, self.verbosity)
-
- def run(self, test):
- "Run the given test case or test suite."
- result = self._makeResult()
- startTime = time.time()
- startTestRun = getattr(result, 'startTestRun', None)
- if startTestRun is not None:
- startTestRun()
- try:
- test(result)
- finally:
- stopTestRun = getattr(result, 'stopTestRun', None)
- if stopTestRun is not None:
- stopTestRun()
- stopTime = time.time()
- timeTaken = stopTime - startTime
- result.printErrors()
- self.stream.writeln(result.separator2)
- run = result.testsRun
- self.stream.writeln("Ran %d test%s in %.3fs" %
- (run, run != 1 and "s" or "", timeTaken))
- self.stream.writeln()
- results = map(len, (result.expectedFailures,
- result.unexpectedSuccesses,
- result.skipped))
- expectedFails, unexpectedSuccesses, skipped = results
- infos = []
- if not result.wasSuccessful():
- self.stream.write("FAILED")
- failed, errored = len(result.failures), len(result.errors)
- if failed:
- infos.append("failures=%d" % failed)
- if errored:
- infos.append("errors=%d" % errored)
- else:
- self.stream.write("OK")
- if skipped:
- infos.append("skipped=%d" % skipped)
- if expectedFails:
- infos.append("expected failures=%d" % expectedFails)
- if unexpectedSuccesses:
- infos.append("unexpected successes=%d" % unexpectedSuccesses)
- if infos:
- self.stream.writeln(" (%s)" % (", ".join(infos),))
- else:
- self.stream.write("\n")
- return result
-
-
-
-##############################################################################
-# Facilities for running tests from the command line
-##############################################################################
-
-class TestProgram(object):
- """A command-line program that runs a set of tests; this is primarily
- for making test modules conveniently executable.
- """
- USAGE = """\
-Usage: %(progName)s [options] [test] [...]
-
-Options:
- -h, --help Show this message
- -v, --verbose Verbose output
- -q, --quiet Minimal output
-
-Examples:
- %(progName)s - run default set of tests
- %(progName)s MyTestSuite - run suite 'MyTestSuite'
- %(progName)s MyTestCase.testSomething - run MyTestCase.testSomething
- %(progName)s MyTestCase - run all 'test*' test methods
- in MyTestCase
-"""
- def __init__(self, module='__main__', defaultTest=None,
- argv=None, testRunner=TextTestRunner,
- testLoader=defaultTestLoader, exit=True):
- if isinstance(module, str):
- self.module = __import__(module)
- for part in module.split('.')[1:]:
- self.module = getattr(self.module, part)
- else:
- self.module = module
- if argv is None:
- argv = sys.argv
-
- self.exit = exit
- self.verbosity = 1
- self.defaultTest = defaultTest
- self.testRunner = testRunner
- self.testLoader = testLoader
- self.progName = os.path.basename(argv[0])
- self.parseArgs(argv)
- self.runTests()
-
- def usageExit(self, msg=None):
- if msg:
- print(msg)
- print(self.USAGE % self.__dict__)
- sys.exit(2)
-
- def parseArgs(self, argv):
- import getopt
- long_opts = ['help','verbose','quiet']
- try:
- options, args = getopt.getopt(argv[1:], 'hHvq', long_opts)
- for opt, value in options:
- if opt in ('-h','-H','--help'):
- self.usageExit()
- if opt in ('-q','--quiet'):
- self.verbosity = 0
- if opt in ('-v','--verbose'):
- self.verbosity = 2
- if len(args) == 0 and self.defaultTest is None:
- self.test = self.testLoader.loadTestsFromModule(self.module)
- return
- if len(args) > 0:
- self.testNames = args
- else:
- self.testNames = (self.defaultTest,)
- self.createTests()
- except getopt.error as msg:
- self.usageExit(msg)
-
- def createTests(self):
- self.test = self.testLoader.loadTestsFromNames(self.testNames,
- self.module)
-
- def runTests(self):
- if isinstance(self.testRunner, type):
- try:
- testRunner = self.testRunner(verbosity=self.verbosity)
- except TypeError:
- # didn't accept the verbosity argument
- testRunner = self.testRunner()
- else:
- # it is assumed to be a TestRunner instance
- testRunner = self.testRunner
- self.result = testRunner.run(self.test)
- if self.exit:
- sys.exit(not self.result.wasSuccessful())
-
-main = TestProgram
-
-
-##############################################################################
-# Executing this module from the command line
-##############################################################################
-
-if __name__ == "__main__":
- main(module=None)
diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py
new file mode 100644
index 0000000000..201a3f0d2d
--- /dev/null
+++ b/Lib/unittest/__init__.py
@@ -0,0 +1,69 @@
+"""
+Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
+Smalltalk testing framework.
+
+This module contains the core framework classes that form the basis of
+specific test cases and suites (TestCase, TestSuite etc.), and also a
+text-based utility class for running the tests and reporting the results
+ (TextTestRunner).
+
+Simple usage:
+
+ import unittest
+
+ class IntegerArithmenticTestCase(unittest.TestCase):
+ def testAdd(self): ## test method names begin 'test*'
+ self.assertEqual((1 + 2), 3)
+ self.assertEqual(0 + 1, 1)
+ def testMultiply(self):
+ self.assertEqual((0 * 10), 0)
+ self.assertEqual((5 * 8), 40)
+
+ if __name__ == '__main__':
+ unittest.main()
+
+Further information is available in the bundled documentation, and from
+
+ http://docs.python.org/library/unittest.html
+
+Copyright (c) 1999-2003 Steve Purcell
+Copyright (c) 2003-2010 Python Software Foundation
+This module is free software, and you may redistribute it and/or modify
+it under the same terms as Python itself, so long as this copyright message
+and disclaimer are retained in their original form.
+
+IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
+THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
+AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
+SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+"""
+
+__all__ = ['TestResult', 'TestCase', 'TestSuite',
+ 'TextTestRunner', 'TestLoader', 'FunctionTestCase', 'main',
+ 'defaultTestLoader', 'SkipTest', 'skip', 'skipIf', 'skipUnless',
+ 'expectedFailure', 'TextTestResult', 'installHandler',
+ 'registerResult', 'removeResult', 'removeHandler']
+
+# Expose obsolete functions for backwards compatibility
+__all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])
+
+__unittest = True
+
+from .result import TestResult
+from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
+ skipUnless, expectedFailure)
+from .suite import BaseTestSuite, TestSuite
+from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
+ findTestCases)
+from .main import TestProgram, main
+from .runner import TextTestRunner, TextTestResult
+from .signals import installHandler, registerResult, removeResult, removeHandler
+
+# deprecated
+_TextTestResult = TextTestResult
diff --git a/Lib/unittest/__main__.py b/Lib/unittest/__main__.py
new file mode 100644
index 0000000000..7320050ae9
--- /dev/null
+++ b/Lib/unittest/__main__.py
@@ -0,0 +1,12 @@
+"""Main entry point"""
+
+import sys
+if sys.argv[0].endswith("__main__.py"):
+ sys.argv[0] = "python -m unittest"
+
+__unittest = True
+
+from .main import main, TestProgram, USAGE_AS_MAIN
+TestProgram.USAGE = USAGE_AS_MAIN
+
+main(module=None)
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
new file mode 100644
index 0000000000..65af16bbca
--- /dev/null
+++ b/Lib/unittest/case.py
@@ -0,0 +1,1256 @@
+"""Test case implementation"""
+
+import sys
+import functools
+import difflib
+import pprint
+import re
+import warnings
+import collections
+
+from . import result
+from .util import (strclass, safe_repr, sorted_list_difference,
+ unorderable_list_difference, _count_diff_all_purpose,
+ _count_diff_hashable)
+
+__unittest = True
+
+
+DIFF_OMITTED = ('\nDiff is %s characters long. '
+ 'Set self.maxDiff to None to see it.')
+
+class SkipTest(Exception):
+ """
+ Raise this exception in a test to skip it.
+
+ Usually you can use TestResult.skip() or one of the skipping decorators
+ instead of raising this directly.
+ """
+
+class _ExpectedFailure(Exception):
+ """
+ Raise this when a test is expected to fail.
+
+ This is an implementation detail.
+ """
+
+ def __init__(self, exc_info):
+ super(_ExpectedFailure, self).__init__()
+ self.exc_info = exc_info
+
+class _UnexpectedSuccess(Exception):
+ """
+ The test was supposed to fail, but it didn't!
+ """
+
+
+class _Outcome(object):
+ def __init__(self):
+ self.success = True
+ self.skipped = None
+ self.unexpectedSuccess = None
+ self.expectedFailure = None
+ self.errors = []
+ self.failures = []
+
+
+def _id(obj):
+ return obj
+
+def skip(reason):
+ """
+ Unconditionally skip a test.
+ """
+ def decorator(test_item):
+ if not (isinstance(test_item, type) and issubclass(test_item, TestCase)):
+ @functools.wraps(test_item)
+ def skip_wrapper(*args, **kwargs):
+ raise SkipTest(reason)
+ test_item = skip_wrapper
+
+ test_item.__unittest_skip__ = True
+ test_item.__unittest_skip_why__ = reason
+ return test_item
+ return decorator
+
+def skipIf(condition, reason):
+ """
+ Skip a test if the condition is true.
+ """
+ if condition:
+ return skip(reason)
+ return _id
+
+def skipUnless(condition, reason):
+ """
+ Skip a test unless the condition is true.
+ """
+ if not condition:
+ return skip(reason)
+ return _id
+
+
+def expectedFailure(func):
+ @functools.wraps(func)
+ def wrapper(*args, **kwargs):
+ try:
+ func(*args, **kwargs)
+ except Exception:
+ raise _ExpectedFailure(sys.exc_info())
+ raise _UnexpectedSuccess
+ return wrapper
+
+
+class _AssertRaisesBaseContext(object):
+
+ def __init__(self, expected, test_case, callable_obj=None,
+ expected_regex=None):
+ self.expected = expected
+ self.failureException = test_case.failureException
+ if callable_obj is not None:
+ try:
+ self.obj_name = callable_obj.__name__
+ except AttributeError:
+ self.obj_name = str(callable_obj)
+ else:
+ self.obj_name = None
+ if isinstance(expected_regex, (bytes, str)):
+ expected_regex = re.compile(expected_regex)
+ self.expected_regex = expected_regex
+
+
+class _AssertRaisesContext(_AssertRaisesBaseContext):
+ """A context manager used to implement TestCase.assertRaises* methods."""
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_value, tb):
+ if exc_type is None:
+ try:
+ exc_name = self.expected.__name__
+ except AttributeError:
+ exc_name = str(self.expected)
+ if self.obj_name:
+ raise self.failureException("{0} not raised by {1}"
+ .format(exc_name, self.obj_name))
+ else:
+ raise self.failureException("{0} not raised"
+ .format(exc_name))
+ if not issubclass(exc_type, self.expected):
+ # let unexpected exceptions pass through
+ return False
+ # store exception, without traceback, for later retrieval
+ self.exception = exc_value.with_traceback(None)
+ if self.expected_regex is None:
+ return True
+
+ expected_regex = self.expected_regex
+ if not expected_regex.search(str(exc_value)):
+ raise self.failureException('"%s" does not match "%s"' %
+ (expected_regex.pattern, str(exc_value)))
+ return True
+
+
+class _AssertWarnsContext(_AssertRaisesBaseContext):
+ """A context manager used to implement TestCase.assertWarns* methods."""
+
+ def __enter__(self):
+ # The __warningregistry__'s need to be in a pristine state for tests
+ # to work properly.
+ for v in sys.modules.values():
+ if getattr(v, '__warningregistry__', None):
+ v.__warningregistry__ = {}
+ self.warnings_manager = warnings.catch_warnings(record=True)
+ self.warnings = self.warnings_manager.__enter__()
+ warnings.simplefilter("always", self.expected)
+ return self
+
+ def __exit__(self, exc_type, exc_value, tb):
+ self.warnings_manager.__exit__(exc_type, exc_value, tb)
+ if exc_type is not None:
+ # let unexpected exceptions pass through
+ return
+ try:
+ exc_name = self.expected.__name__
+ except AttributeError:
+ exc_name = str(self.expected)
+ first_matching = None
+ for m in self.warnings:
+ w = m.message
+ if not isinstance(w, self.expected):
+ continue
+ if first_matching is None:
+ first_matching = w
+ if (self.expected_regex is not None and
+ not self.expected_regex.search(str(w))):
+ continue
+ # store warning for later retrieval
+ self.warning = w
+ self.filename = m.filename
+ self.lineno = m.lineno
+ return
+ # Now we simply try to choose a helpful failure message
+ if first_matching is not None:
+ raise self.failureException('"%s" does not match "%s"' %
+ (self.expected_regex.pattern, str(first_matching)))
+ if self.obj_name:
+ raise self.failureException("{0} not triggered by {1}"
+ .format(exc_name, self.obj_name))
+ else:
+ raise self.failureException("{0} not triggered"
+ .format(exc_name))
+
+
+class _TypeEqualityDict(object):
+
+ def __init__(self, testcase):
+ self.testcase = testcase
+ self._store = {}
+
+ def __setitem__(self, key, value):
+ self._store[key] = value
+
+ def __getitem__(self, key):
+ value = self._store[key]
+ if isinstance(value, str):
+ return getattr(self.testcase, value)
+ return value
+
+ def get(self, key, default=None):
+ if key in self._store:
+ return self[key]
+ return default
+
+
+class TestCase(object):
+ """A class whose instances are single test cases.
+
+ By default, the test code itself should be placed in a method named
+ 'runTest'.
+
+ If the fixture may be used for many test cases, create as
+ many test methods as are needed. When instantiating such a TestCase
+ subclass, specify in the constructor arguments the name of the test method
+ that the instance is to execute.
+
+ Test authors should subclass TestCase for their own tests. Construction
+ and deconstruction of the test's environment ('fixture') can be
+ implemented by overriding the 'setUp' and 'tearDown' methods respectively.
+
+ If it is necessary to override the __init__ method, the base class
+ __init__ method must always be called. It is important that subclasses
+ should not change the signature of their __init__ method, since instances
+ of the classes are instantiated automatically by parts of the framework
+ in order to be run.
+ """
+
+ # This attribute determines which exception will be raised when
+ # the instance's assertion methods fail; test methods raising this
+ # exception will be deemed to have 'failed' rather than 'errored'
+
+ failureException = AssertionError
+
+ # This attribute determines whether long messages (including repr of
+ # objects used in assert methods) will be printed on failure in *addition*
+ # to any explicit message passed.
+
+ longMessage = True
+
+ # This attribute sets the maximum length of a diff in failure messages
+ # by assert methods using difflib. It is looked up as an instance attribute
+ # so can be configured by individual tests if required.
+
+ maxDiff = 80*8
+
+ # Attribute used by TestSuite for classSetUp
+
+ _classSetupFailed = False
+
+ def __init__(self, methodName='runTest'):
+ """Create an instance of the class that will use the named test
+ method when executed. Raises a ValueError if the instance does
+ not have a method with the specified name.
+ """
+ self._testMethodName = methodName
+ self._outcomeForDoCleanups = None
+ self._testMethodDoc = 'No test'
+ try:
+ testMethod = getattr(self, methodName)
+ except AttributeError:
+ if methodName != 'runTest':
+ # we allow instantiation with no explicit method name
+ # but not an *incorrect* or missing method name
+ raise ValueError("no such test method in %s: %s" %
+ (self.__class__, methodName))
+ else:
+ self._testMethodDoc = testMethod.__doc__
+ self._cleanups = []
+
+ # Map types to custom assertEqual functions that will compare
+ # instances of said type in more detail to generate a more useful
+ # error message.
+ self._type_equality_funcs = _TypeEqualityDict(self)
+ self.addTypeEqualityFunc(dict, 'assertDictEqual')
+ self.addTypeEqualityFunc(list, 'assertListEqual')
+ self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
+ self.addTypeEqualityFunc(set, 'assertSetEqual')
+ self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
+ self.addTypeEqualityFunc(str, 'assertMultiLineEqual')
+
+ def addTypeEqualityFunc(self, typeobj, function):
+ """Add a type specific assertEqual style function to compare a type.
+
+ This method is for use by TestCase subclasses that need to register
+ their own type equality functions to provide nicer error messages.
+
+ Args:
+ typeobj: The data type to call this function on when both values
+ are of the same type in assertEqual().
+ function: The callable taking two arguments and an optional
+ msg= argument that raises self.failureException with a
+ useful error message when the two arguments are not equal.
+ """
+ self._type_equality_funcs[typeobj] = function
+
+ def addCleanup(self, function, *args, **kwargs):
+ """Add a function, with arguments, to be called when the test is
+ completed. Functions added are called on a LIFO basis and are
+ called after tearDown on test failure or success.
+
+ Cleanup items are called even if setUp fails (unlike tearDown)."""
+ self._cleanups.append((function, args, kwargs))
+
+ def setUp(self):
+ "Hook method for setting up the test fixture before exercising it."
+ pass
+
+ def tearDown(self):
+ "Hook method for deconstructing the test fixture after testing it."
+ pass
+
+ @classmethod
+ def setUpClass(cls):
+ "Hook method for setting up class fixture before running tests in the class."
+
+ @classmethod
+ def tearDownClass(cls):
+ "Hook method for deconstructing the class fixture after running all tests in the class."
+
+ def countTestCases(self):
+ return 1
+
+ def defaultTestResult(self):
+ return result.TestResult()
+
+ def shortDescription(self):
+ """Returns a one-line description of the test, or None if no
+ description has been provided.
+
+ The default implementation of this method returns the first line of
+ the specified test method's docstring.
+ """
+ doc = self._testMethodDoc
+ return doc and doc.split("\n")[0].strip() or None
+
+
+ def id(self):
+ return "%s.%s" % (strclass(self.__class__), self._testMethodName)
+
+ def __eq__(self, other):
+ if type(self) is not type(other):
+ return NotImplemented
+
+ return self._testMethodName == other._testMethodName
+
+ def __hash__(self):
+ return hash((type(self), self._testMethodName))
+
+ def __str__(self):
+ return "%s (%s)" % (self._testMethodName, strclass(self.__class__))
+
+ def __repr__(self):
+ return "<%s testMethod=%s>" % \
+ (strclass(self.__class__), self._testMethodName)
+
+ def _addSkip(self, result, reason):
+ addSkip = getattr(result, 'addSkip', None)
+ if addSkip is not None:
+ addSkip(self, reason)
+ else:
+ warnings.warn("TestResult has no addSkip method, skips not reported",
+ RuntimeWarning, 2)
+ result.addSuccess(self)
+
+ def _executeTestPart(self, function, outcome, isTest=False):
+ try:
+ function()
+ except KeyboardInterrupt:
+ raise
+ except SkipTest as e:
+ outcome.success = False
+ outcome.skipped = str(e)
+ except _UnexpectedSuccess:
+ exc_info = sys.exc_info()
+ outcome.success = False
+ if isTest:
+ outcome.unexpectedSuccess = exc_info
+ else:
+ outcome.errors.append(exc_info)
+ except _ExpectedFailure:
+ outcome.success = False
+ exc_info = sys.exc_info()
+ if isTest:
+ outcome.expectedFailure = exc_info
+ else:
+ outcome.errors.append(exc_info)
+ except self.failureException:
+ outcome.success = False
+ outcome.failures.append(sys.exc_info())
+ exc_info = sys.exc_info()
+ except:
+ outcome.success = False
+ outcome.errors.append(sys.exc_info())
+
+ def run(self, result=None):
+ orig_result = result
+ if result is None:
+ result = self.defaultTestResult()
+ startTestRun = getattr(result, 'startTestRun', None)
+ if startTestRun is not None:
+ startTestRun()
+
+ result.startTest(self)
+
+ testMethod = getattr(self, self._testMethodName)
+ if (getattr(self.__class__, "__unittest_skip__", False) or
+ getattr(testMethod, "__unittest_skip__", False)):
+ # If the class or method was skipped.
+ try:
+ skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
+ or getattr(testMethod, '__unittest_skip_why__', ''))
+ self._addSkip(result, skip_why)
+ finally:
+ result.stopTest(self)
+ return
+ try:
+ outcome = _Outcome()
+ self._outcomeForDoCleanups = outcome
+
+ self._executeTestPart(self.setUp, outcome)
+ if outcome.success:
+ self._executeTestPart(testMethod, outcome, isTest=True)
+ self._executeTestPart(self.tearDown, outcome)
+
+ self.doCleanups()
+ if outcome.success:
+ result.addSuccess(self)
+ else:
+ if outcome.skipped is not None:
+ self._addSkip(result, outcome.skipped)
+ for exc_info in outcome.errors:
+ result.addError(self, exc_info)
+ for exc_info in outcome.failures:
+ result.addFailure(self, exc_info)
+ if outcome.unexpectedSuccess is not None:
+ addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
+ if addUnexpectedSuccess is not None:
+ addUnexpectedSuccess(self)
+ else:
+ warnings.warn("TestResult has no addUnexpectedSuccess method, reporting as failures",
+ RuntimeWarning)
+ result.addFailure(self, outcome.unexpectedSuccess)
+
+ if outcome.expectedFailure is not None:
+ addExpectedFailure = getattr(result, 'addExpectedFailure', None)
+ if addExpectedFailure is not None:
+ addExpectedFailure(self, outcome.expectedFailure)
+ else:
+ warnings.warn("TestResult has no addExpectedFailure method, reporting as passes",
+ RuntimeWarning)
+ result.addSuccess(self)
+
+ finally:
+ result.stopTest(self)
+ if orig_result is None:
+ stopTestRun = getattr(result, 'stopTestRun', None)
+ if stopTestRun is not None:
+ stopTestRun()
+
+ def doCleanups(self):
+ """Execute all cleanup functions. Normally called for you after
+ tearDown."""
+ outcome = self._outcomeForDoCleanups or _Outcome()
+ while self._cleanups:
+ function, args, kwargs = self._cleanups.pop()
+ part = lambda: function(*args, **kwargs)
+ self._executeTestPart(part, outcome)
+
+ # return this for backwards compatibility
+ # even though we no longer us it internally
+ return outcome.success
+
+ def __call__(self, *args, **kwds):
+ return self.run(*args, **kwds)
+
+ def debug(self):
+ """Run the test without collecting errors in a TestResult"""
+ self.setUp()
+ getattr(self, self._testMethodName)()
+ self.tearDown()
+ while self._cleanups:
+ function, args, kwargs = self._cleanups.pop(-1)
+ function(*args, **kwargs)
+
+ def skipTest(self, reason):
+ """Skip this test."""
+ raise SkipTest(reason)
+
+ def fail(self, msg=None):
+ """Fail immediately, with the given message."""
+ raise self.failureException(msg)
+
+ def assertFalse(self, expr, msg=None):
+ """Check that the expression is false."""
+ if expr:
+ msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
+ raise self.failureException(msg)
+
+ def assertTrue(self, expr, msg=None):
+ """Check that the expression is true."""
+ if not expr:
+ msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
+ raise self.failureException(msg)
+
+ def _formatMessage(self, msg, standardMsg):
+ """Honour the longMessage attribute when generating failure messages.
+ If longMessage is False this means:
+ * Use only an explicit message if it is provided
+ * Otherwise use the standard message for the assert
+
+ If longMessage is True:
+ * Use the standard message
+ * If an explicit message is provided, plus ' : ' and the explicit message
+ """
+ if not self.longMessage:
+ return msg or standardMsg
+ if msg is None:
+ return standardMsg
+ try:
+ # don't switch to '{}' formatting in Python 2.X
+ # it changes the way unicode input is handled
+ return '%s : %s' % (standardMsg, msg)
+ except UnicodeDecodeError:
+ return '%s : %s' % (safe_repr(standardMsg), safe_repr(msg))
+
+
+ def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
+ """Fail unless an exception of class excClass is thrown
+ by callableObj when invoked with arguments args and keyword
+ arguments kwargs. If a different type of exception is
+ thrown, it will not be caught, and the test case will be
+ deemed to have suffered an error, exactly as for an
+ unexpected exception.
+
+ If called with callableObj omitted or None, will return a
+ context object used like this::
+
+ with self.assertRaises(SomeException):
+ do_something()
+
+ The context manager keeps a reference to the exception as
+ the 'exception' attribute. This allows you to inspect the
+ exception after the assertion::
+
+ with self.assertRaises(SomeException) as cm:
+ do_something()
+ the_exception = cm.exception
+ self.assertEqual(the_exception.error_code, 3)
+ """
+ context = _AssertRaisesContext(excClass, self, callableObj)
+ if callableObj is None:
+ return context
+ with context:
+ callableObj(*args, **kwargs)
+
+ def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
+ """Fail unless a warning of class warnClass is triggered
+ by callableObj when invoked with arguments args and keyword
+ arguments kwargs. If a different type of warning is
+ triggered, it will not be handled: depending on the other
+ warning filtering rules in effect, it might be silenced, printed
+ out, or raised as an exception.
+
+ If called with callableObj omitted or None, will return a
+ context object used like this::
+
+ with self.assertWarns(SomeWarning):
+ do_something()
+
+ The context manager keeps a reference to the first matching
+ warning as the 'warning' attribute; similarly, the 'filename'
+ and 'lineno' attributes give you information about the line
+ of Python code from which the warning was triggered.
+ This allows you to inspect the warning after the assertion::
+
+ with self.assertWarns(SomeWarning) as cm:
+ do_something()
+ the_warning = cm.warning
+ self.assertEqual(the_warning.some_attribute, 147)
+ """
+ context = _AssertWarnsContext(expected_warning, self, callable_obj)
+ if callable_obj is None:
+ return context
+ with context:
+ callable_obj(*args, **kwargs)
+
+ def _getAssertEqualityFunc(self, first, second):
+ """Get a detailed comparison function for the types of the two args.
+
+ Returns: A callable accepting (first, second, msg=None) that will
+ raise a failure exception if first != second with a useful human
+ readable error message for those types.
+ """
+ #
+ # NOTE(gregory.p.smith): I considered isinstance(first, type(second))
+ # and vice versa. I opted for the conservative approach in case
+ # subclasses are not intended to be compared in detail to their super
+ # class instances using a type equality func. This means testing
+ # subtypes won't automagically use the detailed comparison. Callers
+ # should use their type specific assertSpamEqual method to compare
+ # subclasses if the detailed comparison is desired and appropriate.
+ # See the discussion in http://bugs.python.org/issue2578.
+ #
+ if type(first) is type(second):
+ asserter = self._type_equality_funcs.get(type(first))
+ if asserter is not None:
+ return asserter
+
+ return self._baseAssertEqual
+
+ def _baseAssertEqual(self, first, second, msg=None):
+ """The default assertEqual implementation, not type specific."""
+ if not first == second:
+ standardMsg = '%s != %s' % (safe_repr(first), safe_repr(second))
+ msg = self._formatMessage(msg, standardMsg)
+ raise self.failureException(msg)
+
+ def assertEqual(self, first, second, msg=None):
+ """Fail if the two objects are unequal as determined by the '=='
+ operator.
+ """
+ assertion_func = self._getAssertEqualityFunc(first, second)
+ assertion_func(first, second, msg=msg)
+
+ def assertNotEqual(self, first, second, msg=None):
+ """Fail if the two objects are equal as determined by the '=='
+ operator.
+ """
+ if not first != second:
+ msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first),
+ safe_repr(second)))
+ raise self.failureException(msg)
+
+ def assertAlmostEqual(self, first, second, places=None, msg=None,
+ delta=None):
+ """Fail if the two objects are unequal as determined by their
+ difference rounded to the given number of decimal places
+ (default 7) and comparing to zero, or by comparing that the
+ between the two objects is more than the given delta.
+
+ Note that decimal places (from zero) are usually not the same
+ as significant digits (measured from the most signficant digit).
+
+ If the two objects compare equal then they will automatically
+ compare almost equal.
+ """
+ if first == second:
+ # shortcut
+ return
+ if delta is not None and places is not None:
+ raise TypeError("specify delta or places not both")
+
+ if delta is not None:
+ if abs(first - second) <= delta:
+ return
+
+ standardMsg = '%s != %s within %s delta' % (safe_repr(first),
+ safe_repr(second),
+ safe_repr(delta))
+ else:
+ if places is None:
+ places = 7
+
+ if round(abs(second-first), places) == 0:
+ return
+
+ standardMsg = '%s != %s within %r places' % (safe_repr(first),
+ safe_repr(second),
+ places)
+ msg = self._formatMessage(msg, standardMsg)
+ raise self.failureException(msg)
+
+ def assertNotAlmostEqual(self, first, second, places=None, msg=None,
+ delta=None):
+ """Fail if the two objects are equal as determined by their
+ difference rounded to the given number of decimal places
+ (default 7) and comparing to zero, or by comparing that the
+ between the two objects is less than the given delta.
+
+ Note that decimal places (from zero) are usually not the same
+ as significant digits (measured from the most signficant digit).
+
+ Objects that are equal automatically fail.
+ """
+ if delta is not None and places is not None:
+ raise TypeError("specify delta or places not both")
+ if delta is not None:
+ if not (first == second) and abs(first - second) > delta:
+ return
+ standardMsg = '%s == %s within %s delta' % (safe_repr(first),
+ safe_repr(second),
+ safe_repr(delta))
+ else:
+ if places is None:
+ places = 7
+ if not (first == second) and round(abs(second-first), places) != 0:
+ return
+ standardMsg = '%s == %s within %r places' % (safe_repr(first),
+ safe_repr(second),
+ places)
+
+ msg = self._formatMessage(msg, standardMsg)
+ raise self.failureException(msg)
+
+
+ def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
+ """An equality assertion for ordered sequences (like lists and tuples).
+
+ For the purposes of this function, a valid ordered sequence type is one
+ which can be indexed, has a length, and has an equality operator.
+
+ Args:
+ seq1: The first sequence to compare.
+ seq2: The second sequence to compare.
+ seq_type: The expected datatype of the sequences, or None if no
+ datatype should be enforced.
+ msg: Optional message to use on failure instead of a list of
+ differences.
+ """
+ if seq_type != None:
+ seq_type_name = seq_type.__name__
+ if not isinstance(seq1, seq_type):
+ raise self.failureException('First sequence is not a %s: %s'
+ % (seq_type_name, safe_repr(seq1)))
+ if not isinstance(seq2, seq_type):
+ raise self.failureException('Second sequence is not a %s: %s'
+ % (seq_type_name, safe_repr(seq2)))
+ else:
+ seq_type_name = "sequence"
+
+ differing = None
+ try:
+ len1 = len(seq1)
+ except (TypeError, NotImplementedError):
+ differing = 'First %s has no length. Non-sequence?' % (
+ seq_type_name)
+
+ if differing is None:
+ try:
+ len2 = len(seq2)
+ except (TypeError, NotImplementedError):
+ differing = 'Second %s has no length. Non-sequence?' % (
+ seq_type_name)
+
+ if differing is None:
+ if seq1 == seq2:
+ return
+
+ seq1_repr = safe_repr(seq1)
+ seq2_repr = safe_repr(seq2)
+ if len(seq1_repr) > 30:
+ seq1_repr = seq1_repr[:30] + '...'
+ if len(seq2_repr) > 30:
+ seq2_repr = seq2_repr[:30] + '...'
+ elements = (seq_type_name.capitalize(), seq1_repr, seq2_repr)
+ differing = '%ss differ: %s != %s\n' % elements
+
+ for i in range(min(len1, len2)):
+ try:
+ item1 = seq1[i]
+ except (TypeError, IndexError, NotImplementedError):
+ differing += ('\nUnable to index element %d of first %s\n' %
+ (i, seq_type_name))
+ break
+
+ try:
+ item2 = seq2[i]
+ except (TypeError, IndexError, NotImplementedError):
+ differing += ('\nUnable to index element %d of second %s\n' %
+ (i, seq_type_name))
+ break
+
+ if item1 != item2:
+ differing += ('\nFirst differing element %d:\n%s\n%s\n' %
+ (i, item1, item2))
+ break
+ else:
+ if (len1 == len2 and seq_type is None and
+ type(seq1) != type(seq2)):
+ # The sequences are the same, but have differing types.
+ return
+
+ if len1 > len2:
+ differing += ('\nFirst %s contains %d additional '
+ 'elements.\n' % (seq_type_name, len1 - len2))
+ try:
+ differing += ('First extra element %d:\n%s\n' %
+ (len2, seq1[len2]))
+ except (TypeError, IndexError, NotImplementedError):
+ differing += ('Unable to index element %d '
+ 'of first %s\n' % (len2, seq_type_name))
+ elif len1 < len2:
+ differing += ('\nSecond %s contains %d additional '
+ 'elements.\n' % (seq_type_name, len2 - len1))
+ try:
+ differing += ('First extra element %d:\n%s\n' %
+ (len1, seq2[len1]))
+ except (TypeError, IndexError, NotImplementedError):
+ differing += ('Unable to index element %d '
+ 'of second %s\n' % (len1, seq_type_name))
+ standardMsg = differing
+ diffMsg = '\n' + '\n'.join(
+ difflib.ndiff(pprint.pformat(seq1).splitlines(),
+ pprint.pformat(seq2).splitlines()))
+
+ standardMsg = self._truncateMessage(standardMsg, diffMsg)
+ msg = self._formatMessage(msg, standardMsg)
+ self.fail(msg)
+
+ def _truncateMessage(self, message, diff):
+ max_diff = self.maxDiff
+ if max_diff is None or len(diff) <= max_diff:
+ return message + diff
+ return message + (DIFF_OMITTED % len(diff))
+
+ def assertListEqual(self, list1, list2, msg=None):
+ """A list-specific equality assertion.
+
+ Args:
+ list1: The first list to compare.
+ list2: The second list to compare.
+ msg: Optional message to use on failure instead of a list of
+ differences.
+
+ """
+ self.assertSequenceEqual(list1, list2, msg, seq_type=list)
+
+ def assertTupleEqual(self, tuple1, tuple2, msg=None):
+ """A tuple-specific equality assertion.
+
+ Args:
+ tuple1: The first tuple to compare.
+ tuple2: The second tuple to compare.
+ msg: Optional message to use on failure instead of a list of
+ differences.
+ """
+ self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
+
+ def assertSetEqual(self, set1, set2, msg=None):
+ """A set-specific equality assertion.
+
+ Args:
+ set1: The first set to compare.
+ set2: The second set to compare.
+ msg: Optional message to use on failure instead of a list of
+ differences.
+
+ assertSetEqual uses ducktyping to support different types of sets, and
+ is optimized for sets specifically (parameters must support a
+ difference method).
+ """
+ try:
+ difference1 = set1.difference(set2)
+ except TypeError as e:
+ self.fail('invalid type when attempting set difference: %s' % e)
+ except AttributeError as e:
+ self.fail('first argument does not support set difference: %s' % e)
+
+ try:
+ difference2 = set2.difference(set1)
+ except TypeError as e:
+ self.fail('invalid type when attempting set difference: %s' % e)
+ except AttributeError as e:
+ self.fail('second argument does not support set difference: %s' % e)
+
+ if not (difference1 or difference2):
+ return
+
+ lines = []
+ if difference1:
+ lines.append('Items in the first set but not the second:')
+ for item in difference1:
+ lines.append(repr(item))
+ if difference2:
+ lines.append('Items in the second set but not the first:')
+ for item in difference2:
+ lines.append(repr(item))
+
+ standardMsg = '\n'.join(lines)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertIn(self, member, container, msg=None):
+ """Just like self.assertTrue(a in b), but with a nicer default message."""
+ if member not in container:
+ standardMsg = '%s not found in %s' % (safe_repr(member),
+ safe_repr(container))
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertNotIn(self, member, container, msg=None):
+ """Just like self.assertTrue(a not in b), but with a nicer default message."""
+ if member in container:
+ standardMsg = '%s unexpectedly found in %s' % (safe_repr(member),
+ safe_repr(container))
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertIs(self, expr1, expr2, msg=None):
+ """Just like self.assertTrue(a is b), but with a nicer default message."""
+ if expr1 is not expr2:
+ standardMsg = '%s is not %s' % (safe_repr(expr1),
+ safe_repr(expr2))
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertIsNot(self, expr1, expr2, msg=None):
+ """Just like self.assertTrue(a is not b), but with a nicer default message."""
+ if expr1 is expr2:
+ standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertDictEqual(self, d1, d2, msg=None):
+ self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
+ self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
+
+ if d1 != d2:
+ standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
+ diff = ('\n' + '\n'.join(difflib.ndiff(
+ pprint.pformat(d1).splitlines(),
+ pprint.pformat(d2).splitlines())))
+ standardMsg = self._truncateMessage(standardMsg, diff)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertDictContainsSubset(self, subset, dictionary, msg=None):
+ """Checks whether dictionary is a superset of subset."""
+ warnings.warn('assertDictContainsSubset is deprecated',
+ DeprecationWarning)
+ missing = []
+ mismatched = []
+ for key, value in subset.items():
+ if key not in dictionary:
+ missing.append(key)
+ elif value != dictionary[key]:
+ mismatched.append('%s, expected: %s, actual: %s' %
+ (safe_repr(key), safe_repr(value),
+ safe_repr(dictionary[key])))
+
+ if not (missing or mismatched):
+ return
+
+ standardMsg = ''
+ if missing:
+ standardMsg = 'Missing: %s' % ','.join(safe_repr(m) for m in
+ missing)
+ if mismatched:
+ if standardMsg:
+ standardMsg += '; '
+ standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
+
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertSameElements(self, expected_seq, actual_seq, msg=None):
+ """An unordered sequence specific comparison.
+
+ Raises with an error message listing which elements of expected_seq
+ are missing from actual_seq and vice versa if any.
+
+ Duplicate elements are ignored when comparing *expected_seq* and
+ *actual_seq*. It is the equivalent of ``assertEqual(set(expected),
+ set(actual))`` but it works with sequences of unhashable objects as
+ well.
+ """
+ warnings.warn('assertSameElements is deprecated',
+ DeprecationWarning)
+ try:
+ expected = set(expected_seq)
+ actual = set(actual_seq)
+ missing = sorted(expected.difference(actual))
+ unexpected = sorted(actual.difference(expected))
+ except TypeError:
+ # Fall back to slower list-compare if any of the objects are
+ # not hashable.
+ expected = list(expected_seq)
+ actual = list(actual_seq)
+ try:
+ expected.sort()
+ actual.sort()
+ except TypeError:
+ missing, unexpected = unorderable_list_difference(expected,
+ actual)
+ else:
+ missing, unexpected = sorted_list_difference(expected, actual)
+ errors = []
+ if missing:
+ errors.append('Expected, but missing:\n %s' %
+ safe_repr(missing))
+ if unexpected:
+ errors.append('Unexpected, but present:\n %s' %
+ safe_repr(unexpected))
+ if errors:
+ standardMsg = '\n'.join(errors)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+
+ def assertCountEqual(self, first, second, msg=None):
+ """An unordered sequence comparison asserting that the same elements,
+ regardless of order. If the same element occurs more than once,
+ it verifies that the elements occur the same number of times.
+
+ self.assertEqual(Counter(list(first)),
+ Counter(list(second)))
+
+ Example:
+ - [0, 1, 1] and [1, 0, 1] compare equal.
+ - [0, 0, 1] and [0, 1] compare unequal.
+
+ """
+ first_seq, second_seq = list(first), list(second)
+ try:
+ first = collections.Counter(first_seq)
+ second = collections.Counter(second_seq)
+ except TypeError:
+ # Handle case with unhashable elements
+ differences = _count_diff_all_purpose(first_seq, second_seq)
+ else:
+ if first == second:
+ return
+ differences = _count_diff_hashable(first_seq, second_seq)
+
+ if differences:
+ standardMsg = 'Element counts were not equal:\n'
+ lines = ['First has %d, Second has %d: %r' % diff for diff in differences]
+ diffMsg = '\n'.join(lines)
+ standardMsg = self._truncateMessage(standardMsg, diffMsg)
+ msg = self._formatMessage(msg, standardMsg)
+ self.fail(msg)
+
+ def assertMultiLineEqual(self, first, second, msg=None):
+ """Assert that two multi-line strings are equal."""
+ self.assertIsInstance(first, str, 'First argument is not a string')
+ self.assertIsInstance(second, str, 'Second argument is not a string')
+
+ if first != second:
+ firstlines = first.splitlines(True)
+ secondlines = second.splitlines(True)
+ if len(firstlines) == 1 and first.strip('\r\n') == first:
+ firstlines = [first + '\n']
+ secondlines = [second + '\n']
+ standardMsg = '%s != %s' % (safe_repr(first, True),
+ safe_repr(second, True))
+ diff = '\n' + ''.join(difflib.ndiff(firstlines, secondlines))
+ standardMsg = self._truncateMessage(standardMsg, diff)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertLess(self, a, b, msg=None):
+ """Just like self.assertTrue(a < b), but with a nicer default message."""
+ if not a < b:
+ standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b))
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertLessEqual(self, a, b, msg=None):
+ """Just like self.assertTrue(a <= b), but with a nicer default message."""
+ if not a <= b:
+ standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b))
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertGreater(self, a, b, msg=None):
+ """Just like self.assertTrue(a > b), but with a nicer default message."""
+ if not a > b:
+ standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b))
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertGreaterEqual(self, a, b, msg=None):
+ """Just like self.assertTrue(a >= b), but with a nicer default message."""
+ if not a >= b:
+ standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b))
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertIsNone(self, obj, msg=None):
+ """Same as self.assertTrue(obj is None), with a nicer default message."""
+ if obj is not None:
+ standardMsg = '%s is not None' % (safe_repr(obj),)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertIsNotNone(self, obj, msg=None):
+ """Included for symmetry with assertIsNone."""
+ if obj is None:
+ standardMsg = 'unexpectedly None'
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertIsInstance(self, obj, cls, msg=None):
+ """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
+ default message."""
+ if not isinstance(obj, cls):
+ standardMsg = '%s is not an instance of %r' % (safe_repr(obj), cls)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertNotIsInstance(self, obj, cls, msg=None):
+ """Included for symmetry with assertIsInstance."""
+ if isinstance(obj, cls):
+ standardMsg = '%s is an instance of %r' % (safe_repr(obj), cls)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertRaisesRegex(self, expected_exception, expected_regex,
+ callable_obj=None, *args, **kwargs):
+ """Asserts that the message in a raised exception matches a regex.
+
+ Args:
+ expected_exception: Exception class expected to be raised.
+ expected_regex: Regex (re pattern object or string) expected
+ to be found in error message.
+ callable_obj: Function to be called.
+ args: Extra args.
+ kwargs: Extra kwargs.
+ """
+ context = _AssertRaisesContext(expected_exception, self, callable_obj,
+ expected_regex)
+ if callable_obj is None:
+ return context
+ with context:
+ callable_obj(*args, **kwargs)
+
+ def assertWarnsRegex(self, expected_warning, expected_regex,
+ callable_obj=None, *args, **kwargs):
+ """Asserts that the message in a triggered warning matches a regexp.
+ Basic functioning is similar to assertWarns() with the addition
+ that only warnings whose messages also match the regular expression
+ are considered successful matches.
+
+ Args:
+ expected_warning: Warning class expected to be triggered.
+ expected_regex: Regex (re pattern object or string) expected
+ to be found in error message.
+ callable_obj: Function to be called.
+ args: Extra args.
+ kwargs: Extra kwargs.
+ """
+ context = _AssertWarnsContext(expected_warning, self, callable_obj,
+ expected_regex)
+ if callable_obj is None:
+ return context
+ with context:
+ callable_obj(*args, **kwargs)
+
+ def assertRegex(self, text, expected_regex, msg=None):
+ """Fail the test unless the text matches the regular expression."""
+ if isinstance(expected_regex, (str, bytes)):
+ assert expected_regex, "expected_regex must not be empty."
+ expected_regex = re.compile(expected_regex)
+ if not expected_regex.search(text):
+ msg = msg or "Regex didn't match"
+ msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
+ raise self.failureException(msg)
+
+ def assertNotRegex(self, text, unexpected_regex, msg=None):
+ """Fail the test if the text matches the regular expression."""
+ if isinstance(unexpected_regex, (str, bytes)):
+ unexpected_regex = re.compile(unexpected_regex)
+ match = unexpected_regex.search(text)
+ if match:
+ msg = msg or "Regex matched"
+ msg = '%s: %r matches %r in %r' % (msg,
+ text[match.start():match.end()],
+ unexpected_regex.pattern,
+ text)
+ raise self.failureException(msg)
+
+
+ def _deprecate(original_func):
+ def deprecated_func(*args, **kwargs):
+ warnings.warn(
+ 'Please use {0} instead.'.format(original_func.__name__),
+ DeprecationWarning, 2)
+ return original_func(*args, **kwargs)
+ return deprecated_func
+
+ # The fail* methods can be removed in 3.3, the 5 assert* methods will
+ # have to stay around for a few more versions. See #9424.
+ failUnlessEqual = assertEquals = _deprecate(assertEqual)
+ failIfEqual = assertNotEquals = _deprecate(assertNotEqual)
+ failUnlessAlmostEqual = assertAlmostEquals = _deprecate(assertAlmostEqual)
+ failIfAlmostEqual = assertNotAlmostEquals = _deprecate(assertNotAlmostEqual)
+ failUnless = assert_ = _deprecate(assertTrue)
+ failUnlessRaises = _deprecate(assertRaises)
+ failIf = _deprecate(assertFalse)
+ assertRaisesRegexp = _deprecate(assertRaisesRegex)
+ assertRegexpMatches = _deprecate(assertRegex)
+
+
+
+class FunctionTestCase(TestCase):
+ """A test case that wraps a test function.
+
+ This is useful for slipping pre-existing test functions into the
+ unittest framework. Optionally, set-up and tidy-up functions can be
+ supplied. As with TestCase, the tidy-up ('tearDown') function will
+ always be called if the set-up ('setUp') function ran successfully.
+ """
+
+ def __init__(self, testFunc, setUp=None, tearDown=None, description=None):
+ super(FunctionTestCase, self).__init__()
+ self._setUpFunc = setUp
+ self._tearDownFunc = tearDown
+ self._testFunc = testFunc
+ self._description = description
+
+ def setUp(self):
+ if self._setUpFunc is not None:
+ self._setUpFunc()
+
+ def tearDown(self):
+ if self._tearDownFunc is not None:
+ self._tearDownFunc()
+
+ def runTest(self):
+ self._testFunc()
+
+ def id(self):
+ return self._testFunc.__name__
+
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ return NotImplemented
+
+ return self._setUpFunc == other._setUpFunc and \
+ self._tearDownFunc == other._tearDownFunc and \
+ self._testFunc == other._testFunc and \
+ self._description == other._description
+
+ def __ne__(self, other):
+ return not self == other
+
+ def __hash__(self):
+ return hash((type(self), self._setUpFunc, self._tearDownFunc,
+ self._testFunc, self._description))
+
+ def __str__(self):
+ return "%s (%s)" % (strclass(self.__class__),
+ self._testFunc.__name__)
+
+ def __repr__(self):
+ return "<%s tec=%s>" % (strclass(self.__class__),
+ self._testFunc)
+
+ def shortDescription(self):
+ if self._description is not None:
+ return self._description
+ doc = self._testFunc.__doc__
+ return doc and doc.split("\n")[0].strip() or None
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py
new file mode 100644
index 0000000000..afdff67164
--- /dev/null
+++ b/Lib/unittest/loader.py
@@ -0,0 +1,321 @@
+"""Loading unittests."""
+
+import os
+import re
+import sys
+import traceback
+import types
+import functools
+
+from fnmatch import fnmatch
+
+from . import case, suite, util
+
+__unittest = True
+
+# what about .pyc or .pyo (etc)
+# we would need to avoid loading the same tests multiple times
+# from '.py', '.pyc' *and* '.pyo'
+VALID_MODULE_NAME = re.compile(r'[_a-z]\w*\.py$', re.IGNORECASE)
+
+
+def _make_failed_import_test(name, suiteClass):
+ message = 'Failed to import test module: %s\n%s' % (name, traceback.format_exc())
+ return _make_failed_test('ModuleImportFailure', name, ImportError(message),
+ suiteClass)
+
+def _make_failed_load_tests(name, exception, suiteClass):
+ return _make_failed_test('LoadTestsFailure', name, exception, suiteClass)
+
+def _make_failed_test(classname, methodname, exception, suiteClass):
+ def testFailure(self):
+ raise exception
+ attrs = {methodname: testFailure}
+ TestClass = type(classname, (case.TestCase,), attrs)
+ return suiteClass((TestClass(methodname),))
+
+
+class TestLoader(object):
+ """
+ This class is responsible for loading tests according to various criteria
+ and returning them wrapped in a TestSuite
+ """
+ testMethodPrefix = 'test'
+ sortTestMethodsUsing = staticmethod(util.three_way_cmp)
+ suiteClass = suite.TestSuite
+ _top_level_dir = None
+
+ def loadTestsFromTestCase(self, testCaseClass):
+ """Return a suite of all tests cases contained in testCaseClass"""
+ if issubclass(testCaseClass, suite.TestSuite):
+ raise TypeError("Test cases should not be derived from TestSuite." \
+ " Maybe you meant to derive from TestCase?")
+ testCaseNames = self.getTestCaseNames(testCaseClass)
+ if not testCaseNames and hasattr(testCaseClass, 'runTest'):
+ testCaseNames = ['runTest']
+ loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
+ return loaded_suite
+
+ def loadTestsFromModule(self, module, use_load_tests=True):
+ """Return a suite of all tests cases contained in the given module"""
+ tests = []
+ for name in dir(module):
+ obj = getattr(module, name)
+ if isinstance(obj, type) and issubclass(obj, case.TestCase):
+ tests.append(self.loadTestsFromTestCase(obj))
+
+ load_tests = getattr(module, 'load_tests', None)
+ tests = self.suiteClass(tests)
+ if use_load_tests and load_tests is not None:
+ try:
+ return load_tests(self, tests, None)
+ except Exception as e:
+ return _make_failed_load_tests(module.__name__, e,
+ self.suiteClass)
+ return tests
+
+ def loadTestsFromName(self, name, module=None):
+ """Return a suite of all tests cases given a string specifier.
+
+ The name may resolve either to a module, a test case class, a
+ test method within a test case class, or a callable object which
+ returns a TestCase or TestSuite instance.
+
+ The method optionally resolves the names relative to a given module.
+ """
+ parts = name.split('.')
+ if module is None:
+ parts_copy = parts[:]
+ while parts_copy:
+ try:
+ module = __import__('.'.join(parts_copy))
+ break
+ except ImportError:
+ del parts_copy[-1]
+ if not parts_copy:
+ raise
+ parts = parts[1:]
+ obj = module
+ for part in parts:
+ parent, obj = obj, getattr(obj, part)
+
+ if isinstance(obj, types.ModuleType):
+ return self.loadTestsFromModule(obj)
+ elif isinstance(obj, type) and issubclass(obj, case.TestCase):
+ return self.loadTestsFromTestCase(obj)
+ elif (isinstance(obj, types.FunctionType) and
+ isinstance(parent, type) and
+ issubclass(parent, case.TestCase)):
+ name = obj.__name__
+ inst = parent(name)
+ # static methods follow a different path
+ if not isinstance(getattr(inst, name), types.FunctionType):
+ return self.suiteClass([inst])
+ elif isinstance(obj, suite.TestSuite):
+ return obj
+ if hasattr(obj, '__call__'):
+ test = obj()
+ if isinstance(test, suite.TestSuite):
+ return test
+ elif isinstance(test, case.TestCase):
+ return self.suiteClass([test])
+ else:
+ raise TypeError("calling %s returned %s, not a test" %
+ (obj, test))
+ else:
+ raise TypeError("don't know how to make test from: %s" % obj)
+
+ def loadTestsFromNames(self, names, module=None):
+ """Return a suite of all tests cases found using the given sequence
+ of string specifiers. See 'loadTestsFromName()'.
+ """
+ suites = [self.loadTestsFromName(name, module) for name in names]
+ return self.suiteClass(suites)
+
+ def getTestCaseNames(self, testCaseClass):
+ """Return a sorted sequence of method names found within testCaseClass
+ """
+ def isTestMethod(attrname, testCaseClass=testCaseClass,
+ prefix=self.testMethodPrefix):
+ return attrname.startswith(prefix) and \
+ hasattr(getattr(testCaseClass, attrname), '__call__')
+ testFnNames = testFnNames = list(filter(isTestMethod,
+ dir(testCaseClass)))
+ if self.sortTestMethodsUsing:
+ testFnNames.sort(key=functools.cmp_to_key(self.sortTestMethodsUsing))
+ return testFnNames
+
+ def discover(self, start_dir, pattern='test*.py', top_level_dir=None):
+ """Find and return all test modules from the specified start
+ directory, recursing into subdirectories to find them and return all
+ tests found within them. Only test files that match the pattern will
+ be loaded. (Using shell style pattern matching.)
+
+ All test modules must be importable from the top level of the project.
+ If the start directory is not the top level directory then the top
+ level directory must be specified separately.
+
+ If a test package name (directory with '__init__.py') matches the
+ pattern then the package will be checked for a 'load_tests' function. If
+ this exists then it will be called with loader, tests, pattern.
+
+ If load_tests exists then discovery does *not* recurse into the package,
+ load_tests is responsible for loading all tests in the package.
+
+ The pattern is deliberately not stored as a loader attribute so that
+ packages can continue discovery themselves. top_level_dir is stored so
+ load_tests does not need to pass this argument in to loader.discover().
+ """
+ set_implicit_top = False
+ if top_level_dir is None and self._top_level_dir is not None:
+ # make top_level_dir optional if called from load_tests in a package
+ top_level_dir = self._top_level_dir
+ elif top_level_dir is None:
+ set_implicit_top = True
+ top_level_dir = start_dir
+
+ top_level_dir = os.path.abspath(top_level_dir)
+
+ if not top_level_dir in sys.path:
+ # all test modules must be importable from the top level directory
+ # should we *unconditionally* put the start directory in first
+ # in sys.path to minimise likelihood of conflicts between installed
+ # modules and development versions?
+ sys.path.insert(0, top_level_dir)
+ self._top_level_dir = top_level_dir
+
+ is_not_importable = False
+ if os.path.isdir(os.path.abspath(start_dir)):
+ start_dir = os.path.abspath(start_dir)
+ if start_dir != top_level_dir:
+ is_not_importable = not os.path.isfile(os.path.join(start_dir, '__init__.py'))
+ else:
+ # support for discovery from dotted module names
+ try:
+ __import__(start_dir)
+ except ImportError:
+ is_not_importable = True
+ else:
+ the_module = sys.modules[start_dir]
+ top_part = start_dir.split('.')[0]
+ start_dir = os.path.abspath(os.path.dirname((the_module.__file__)))
+ if set_implicit_top:
+ self._top_level_dir = self._get_directory_containing_module(top_part)
+ sys.path.remove(top_level_dir)
+
+ if is_not_importable:
+ raise ImportError('Start directory is not importable: %r' % start_dir)
+
+ tests = list(self._find_tests(start_dir, pattern))
+ return self.suiteClass(tests)
+
+ def _get_directory_containing_module(self, module_name):
+ module = sys.modules[module_name]
+ full_path = os.path.abspath(module.__file__)
+
+ if os.path.basename(full_path).lower().startswith('__init__.py'):
+ return os.path.dirname(os.path.dirname(full_path))
+ else:
+ # here we have been given a module rather than a package - so
+ # all we can do is search the *same* directory the module is in
+ # should an exception be raised instead
+ return os.path.dirname(full_path)
+
+ def _get_name_from_path(self, path):
+ path = os.path.splitext(os.path.normpath(path))[0]
+
+ _relpath = os.path.relpath(path, self._top_level_dir)
+ assert not os.path.isabs(_relpath), "Path must be within the project"
+ assert not _relpath.startswith('..'), "Path must be within the project"
+
+ name = _relpath.replace(os.path.sep, '.')
+ return name
+
+ def _get_module_from_name(self, name):
+ __import__(name)
+ return sys.modules[name]
+
+ def _match_path(self, path, full_path, pattern):
+ # override this method to use alternative matching strategy
+ return fnmatch(path, pattern)
+
+ def _find_tests(self, start_dir, pattern):
+ """Used by discovery. Yields test suites it loads."""
+ paths = os.listdir(start_dir)
+
+ for path in paths:
+ full_path = os.path.join(start_dir, path)
+ if os.path.isfile(full_path):
+ if not VALID_MODULE_NAME.match(path):
+ # valid Python identifiers only
+ continue
+ if not self._match_path(path, full_path, pattern):
+ continue
+ # if the test file matches, load it
+ name = self._get_name_from_path(full_path)
+ try:
+ module = self._get_module_from_name(name)
+ except:
+ yield _make_failed_import_test(name, self.suiteClass)
+ else:
+ mod_file = os.path.abspath(getattr(module, '__file__', full_path))
+ realpath = os.path.splitext(mod_file)[0]
+ fullpath_noext = os.path.splitext(full_path)[0]
+ if realpath.lower() != fullpath_noext.lower():
+ module_dir = os.path.dirname(realpath)
+ mod_name = os.path.splitext(os.path.basename(full_path))[0]
+ expected_dir = os.path.dirname(full_path)
+ msg = ("%r module incorrectly imported from %r. Expected %r. "
+ "Is this module globally installed?")
+ raise ImportError(msg % (mod_name, module_dir, expected_dir))
+ yield self.loadTestsFromModule(module)
+ elif os.path.isdir(full_path):
+ if not os.path.isfile(os.path.join(full_path, '__init__.py')):
+ continue
+
+ load_tests = None
+ tests = None
+ if fnmatch(path, pattern):
+ # only check load_tests if the package directory itself matches the filter
+ name = self._get_name_from_path(full_path)
+ package = self._get_module_from_name(name)
+ load_tests = getattr(package, 'load_tests', None)
+ tests = self.loadTestsFromModule(package, use_load_tests=False)
+
+ if load_tests is None:
+ if tests is not None:
+ # tests loaded from package file
+ yield tests
+ # recurse into the package
+ for test in self._find_tests(full_path, pattern):
+ yield test
+ else:
+ try:
+ yield load_tests(self, tests, pattern)
+ except Exception as e:
+ yield _make_failed_load_tests(package.__name__, e,
+ self.suiteClass)
+
+defaultTestLoader = TestLoader()
+
+
+def _makeLoader(prefix, sortUsing, suiteClass=None):
+ loader = TestLoader()
+ loader.sortTestMethodsUsing = sortUsing
+ loader.testMethodPrefix = prefix
+ if suiteClass:
+ loader.suiteClass = suiteClass
+ return loader
+
+def getTestCaseNames(testCaseClass, prefix, sortUsing=util.three_way_cmp):
+ return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass)
+
+def makeSuite(testCaseClass, prefix='test', sortUsing=util.three_way_cmp,
+ suiteClass=suite.TestSuite):
+ return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(
+ testCaseClass)
+
+def findTestCases(module, prefix='test', sortUsing=util.three_way_cmp,
+ suiteClass=suite.TestSuite):
+ return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(\
+ module)
diff --git a/Lib/unittest/main.py b/Lib/unittest/main.py
new file mode 100644
index 0000000000..55d4e4be14
--- /dev/null
+++ b/Lib/unittest/main.py
@@ -0,0 +1,274 @@
+"""Unittest main program"""
+
+import sys
+import os
+import types
+
+from . import loader, runner
+from .signals import installHandler
+
+__unittest = True
+
+FAILFAST = " -f, --failfast Stop on first failure\n"
+CATCHBREAK = " -c, --catch Catch control-C and display results\n"
+BUFFEROUTPUT = " -b, --buffer Buffer stdout and stderr during test runs\n"
+
+USAGE_AS_MAIN = """\
+Usage: %(progName)s [options] [tests]
+
+Options:
+ -h, --help Show this message
+ -v, --verbose Verbose output
+ -q, --quiet Minimal output
+%(failfast)s%(catchbreak)s%(buffer)s
+Examples:
+ %(progName)s test_module - run tests from test_module
+ %(progName)s module.TestClass - run tests from module.TestClass
+ %(progName)s module.Class.test_method - run specified test method
+
+[tests] can be a list of any number of test modules, classes and test
+methods.
+
+Alternative Usage: %(progName)s discover [options]
+
+Options:
+ -v, --verbose Verbose output
+%(failfast)s%(catchbreak)s%(buffer)s -s directory Directory to start discovery ('.' default)
+ -p pattern Pattern to match test files ('test*.py' default)
+ -t directory Top level directory of project (default to
+ start directory)
+
+For test discovery all test modules must be importable from the top
+level directory of the project.
+"""
+
+USAGE_FROM_MODULE = """\
+Usage: %(progName)s [options] [test] [...]
+
+Options:
+ -h, --help Show this message
+ -v, --verbose Verbose output
+ -q, --quiet Minimal output
+%(failfast)s%(catchbreak)s%(buffer)s
+Examples:
+ %(progName)s - run default set of tests
+ %(progName)s MyTestSuite - run suite 'MyTestSuite'
+ %(progName)s MyTestCase.testSomething - run MyTestCase.testSomething
+ %(progName)s MyTestCase - run all 'test*' test methods
+ in MyTestCase
+"""
+
+def _convert_name(name):
+ # on Linux / Mac OS X 'foo.PY' is not importable, but on
+ # Windows it is. Simpler to do a case insensitive match
+ # a better check would be to check that the name is a
+ # valid Python module name.
+ if os.path.isfile(name) and name.lower().endswith('.py'):
+ if os.path.isabs(name):
+ rel_path = os.path.relpath(name, os.getcwd())
+ if os.path.isabs(rel_path) or rel_path.startswith(os.pardir):
+ return name
+ name = rel_path
+ # on Windows both '\' and '/' are used as path
+ # separators. Better to replace both than rely on os.path.sep
+ return name[:-3].replace('\\', '.').replace('/', '.')
+ return name
+
+def _convert_names(names):
+ return [_convert_name(name) for name in names]
+
+class TestProgram(object):
+ """A command-line program that runs a set of tests; this is primarily
+ for making test modules conveniently executable.
+ """
+ USAGE = USAGE_FROM_MODULE
+
+ # defaults for testing
+ failfast = catchbreak = buffer = progName = warnings = None
+
+ def __init__(self, module='__main__', defaultTest=None, argv=None,
+ testRunner=None, testLoader=loader.defaultTestLoader,
+ exit=True, verbosity=1, failfast=None, catchbreak=None,
+ buffer=None, warnings=None):
+ if isinstance(module, str):
+ self.module = __import__(module)
+ for part in module.split('.')[1:]:
+ self.module = getattr(self.module, part)
+ else:
+ self.module = module
+ if argv is None:
+ argv = sys.argv
+
+ self.exit = exit
+ self.failfast = failfast
+ self.catchbreak = catchbreak
+ self.verbosity = verbosity
+ self.buffer = buffer
+ if warnings is None and not sys.warnoptions:
+ # even if DreprecationWarnings are ignored by default
+ # print them anyway unless other warnings settings are
+ # specified by the warnings arg or the -W python flag
+ self.warnings = 'default'
+ else:
+ # here self.warnings is set either to the value passed
+ # to the warnings args or to None.
+ # If the user didn't pass a value self.warnings will
+ # be None. This means that the behavior is unchanged
+ # and depends on the values passed to -W.
+ self.warnings = warnings
+ self.defaultTest = defaultTest
+ self.testRunner = testRunner
+ self.testLoader = testLoader
+ self.progName = os.path.basename(argv[0])
+ self.parseArgs(argv)
+ self.runTests()
+
+ def usageExit(self, msg=None):
+ if msg:
+ print(msg)
+ usage = {'progName': self.progName, 'catchbreak': '', 'failfast': '',
+ 'buffer': ''}
+ if self.failfast != False:
+ usage['failfast'] = FAILFAST
+ if self.catchbreak != False:
+ usage['catchbreak'] = CATCHBREAK
+ if self.buffer != False:
+ usage['buffer'] = BUFFEROUTPUT
+ print(self.USAGE % usage)
+ sys.exit(2)
+
+ def parseArgs(self, argv):
+ if ((len(argv) > 1 and argv[1].lower() == 'discover') or
+ (len(argv) == 1 and self.module is None)):
+ self._do_discovery(argv[2:])
+ return
+
+ import getopt
+ long_opts = ['help', 'verbose', 'quiet', 'failfast', 'catch', 'buffer']
+ try:
+ options, args = getopt.getopt(argv[1:], 'hHvqfcb', long_opts)
+ except getopt.error as msg:
+ self.usageExit(msg)
+ return
+
+ for opt, value in options:
+ if opt in ('-h','-H','--help'):
+ self.usageExit()
+ if opt in ('-q','--quiet'):
+ self.verbosity = 0
+ if opt in ('-v','--verbose'):
+ self.verbosity = 2
+ if opt in ('-f','--failfast'):
+ if self.failfast is None:
+ self.failfast = True
+ # Should this raise an exception if -f is not valid?
+ if opt in ('-c','--catch'):
+ if self.catchbreak is None:
+ self.catchbreak = True
+ # Should this raise an exception if -c is not valid?
+ if opt in ('-b','--buffer'):
+ if self.buffer is None:
+ self.buffer = True
+ # Should this raise an exception if -b is not valid?
+
+ if len(args) == 0 and self.module is None:
+ # this allows "python -m unittest -v" to still work for
+ # test discovery. This means -c / -b / -v / -f options will
+ # be handled twice, which is harmless but not ideal.
+ self._do_discovery(argv[1:])
+ return
+
+ if len(args) == 0 and self.defaultTest is None:
+ # createTests will load tests from self.module
+ self.testNames = None
+ elif len(args) > 0:
+ self.testNames = _convert_names(args)
+ if __name__ == '__main__':
+ # to support python -m unittest ...
+ self.module = None
+ else:
+ self.testNames = (self.defaultTest,)
+ self.createTests()
+
+ def createTests(self):
+ if self.testNames is None:
+ self.test = self.testLoader.loadTestsFromModule(self.module)
+ else:
+ self.test = self.testLoader.loadTestsFromNames(self.testNames,
+ self.module)
+
+ def _do_discovery(self, argv, Loader=loader.TestLoader):
+ # handle command line args for test discovery
+ self.progName = '%s discover' % self.progName
+ import optparse
+ parser = optparse.OptionParser()
+ parser.prog = self.progName
+ parser.add_option('-v', '--verbose', dest='verbose', default=False,
+ help='Verbose output', action='store_true')
+ if self.failfast != False:
+ parser.add_option('-f', '--failfast', dest='failfast', default=False,
+ help='Stop on first fail or error',
+ action='store_true')
+ if self.catchbreak != False:
+ parser.add_option('-c', '--catch', dest='catchbreak', default=False,
+ help='Catch ctrl-C and display results so far',
+ action='store_true')
+ if self.buffer != False:
+ parser.add_option('-b', '--buffer', dest='buffer', default=False,
+ help='Buffer stdout and stderr during tests',
+ action='store_true')
+ parser.add_option('-s', '--start-directory', dest='start', default='.',
+ help="Directory to start discovery ('.' default)")
+ parser.add_option('-p', '--pattern', dest='pattern', default='test*.py',
+ help="Pattern to match tests ('test*.py' default)")
+ parser.add_option('-t', '--top-level-directory', dest='top', default=None,
+ help='Top level directory of project (defaults to start directory)')
+
+ options, args = parser.parse_args(argv)
+ if len(args) > 3:
+ self.usageExit()
+
+ for name, value in zip(('start', 'pattern', 'top'), args):
+ setattr(options, name, value)
+
+ # only set options from the parsing here
+ # if they weren't set explicitly in the constructor
+ if self.failfast is None:
+ self.failfast = options.failfast
+ if self.catchbreak is None:
+ self.catchbreak = options.catchbreak
+ if self.buffer is None:
+ self.buffer = options.buffer
+
+ if options.verbose:
+ self.verbosity = 2
+
+ start_dir = options.start
+ pattern = options.pattern
+ top_level_dir = options.top
+
+ loader = Loader()
+ self.test = loader.discover(start_dir, pattern, top_level_dir)
+
+ def runTests(self):
+ if self.catchbreak:
+ installHandler()
+ if self.testRunner is None:
+ self.testRunner = runner.TextTestRunner
+ if isinstance(self.testRunner, type):
+ try:
+ testRunner = self.testRunner(verbosity=self.verbosity,
+ failfast=self.failfast,
+ buffer=self.buffer,
+ warnings=self.warnings)
+ except TypeError:
+ # didn't accept the verbosity, buffer or failfast arguments
+ testRunner = self.testRunner()
+ else:
+ # it is assumed to be a TestRunner instance
+ testRunner = self.testRunner
+ self.result = testRunner.run(self.test)
+ if self.exit:
+ sys.exit(not self.result.wasSuccessful())
+
+main = TestProgram
diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py
new file mode 100644
index 0000000000..3dc7154b73
--- /dev/null
+++ b/Lib/unittest/result.py
@@ -0,0 +1,186 @@
+"""Test result object"""
+
+import os
+import io
+import sys
+import traceback
+
+from . import util
+from functools import wraps
+
+__unittest = True
+
+def failfast(method):
+ @wraps(method)
+ def inner(self, *args, **kw):
+ if getattr(self, 'failfast', False):
+ self.stop()
+ return method(self, *args, **kw)
+ return inner
+
+STDOUT_LINE = '\nStdout:\n%s'
+STDERR_LINE = '\nStderr:\n%s'
+
+
+class TestResult(object):
+ """Holder for test result information.
+
+ Test results are automatically managed by the TestCase and TestSuite
+ classes, and do not need to be explicitly manipulated by writers of tests.
+
+ Each instance holds the total number of tests run, and collections of
+ failures and errors that occurred among those test runs. The collections
+ contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
+ formatted traceback of the error that occurred.
+ """
+ _previousTestClass = None
+ _testRunEntered = False
+ _moduleSetUpFailed = False
+ def __init__(self, stream=None, descriptions=None, verbosity=None):
+ self.failfast = False
+ self.failures = []
+ self.errors = []
+ self.testsRun = 0
+ self.skipped = []
+ self.expectedFailures = []
+ self.unexpectedSuccesses = []
+ self.shouldStop = False
+ self.buffer = False
+ self._stdout_buffer = None
+ self._stderr_buffer = None
+ self._original_stdout = sys.stdout
+ self._original_stderr = sys.stderr
+ self._mirrorOutput = False
+
+ def printErrors(self):
+ "Called by TestRunner after test run"
+
+ def startTest(self, test):
+ "Called when the given test is about to be run"
+ self.testsRun += 1
+ self._mirrorOutput = False
+ if self.buffer:
+ if self._stderr_buffer is None:
+ self._stderr_buffer = io.StringIO()
+ self._stdout_buffer = io.StringIO()
+ sys.stdout = self._stdout_buffer
+ sys.stderr = self._stderr_buffer
+
+ def startTestRun(self):
+ """Called once before any tests are executed.
+
+ See startTest for a method called before each test.
+ """
+
+ def stopTest(self, test):
+ """Called when the given test has been run"""
+ if self.buffer:
+ if self._mirrorOutput:
+ output = sys.stdout.getvalue()
+ error = sys.stderr.getvalue()
+ if output:
+ if not output.endswith('\n'):
+ output += '\n'
+ self._original_stdout.write(STDOUT_LINE % output)
+ if error:
+ if not error.endswith('\n'):
+ error += '\n'
+ self._original_stderr.write(STDERR_LINE % error)
+
+ sys.stdout = self._original_stdout
+ sys.stderr = self._original_stderr
+ self._stdout_buffer.seek(0)
+ self._stdout_buffer.truncate()
+ self._stderr_buffer.seek(0)
+ self._stderr_buffer.truncate()
+ self._mirrorOutput = False
+
+ def stopTestRun(self):
+ """Called once after all tests are executed.
+
+ See stopTest for a method called after each test.
+ """
+
+ @failfast
+ def addError(self, test, err):
+ """Called when an error has occurred. 'err' is a tuple of values as
+ returned by sys.exc_info().
+ """
+ self.errors.append((test, self._exc_info_to_string(err, test)))
+ self._mirrorOutput = True
+
+ @failfast
+ def addFailure(self, test, err):
+ """Called when an error has occurred. 'err' is a tuple of values as
+ returned by sys.exc_info()."""
+ self.failures.append((test, self._exc_info_to_string(err, test)))
+ self._mirrorOutput = True
+
+ def addSuccess(self, test):
+ "Called when a test has completed successfully"
+ pass
+
+ def addSkip(self, test, reason):
+ """Called when a test is skipped."""
+ self.skipped.append((test, reason))
+
+ def addExpectedFailure(self, test, err):
+ """Called when an expected failure/error occured."""
+ self.expectedFailures.append(
+ (test, self._exc_info_to_string(err, test)))
+
+ @failfast
+ def addUnexpectedSuccess(self, test):
+ """Called when a test was expected to fail, but succeed."""
+ self.unexpectedSuccesses.append(test)
+
+ def wasSuccessful(self):
+ "Tells whether or not this result was a success"
+ return len(self.failures) == len(self.errors) == 0
+
+ def stop(self):
+ "Indicates that the tests should be aborted"
+ self.shouldStop = True
+
+ def _exc_info_to_string(self, err, test):
+ """Converts a sys.exc_info()-style tuple of values into a string."""
+ exctype, value, tb = err
+ # Skip test runner traceback levels
+ while tb and self._is_relevant_tb_level(tb):
+ tb = tb.tb_next
+
+ if exctype is test.failureException:
+ # Skip assert*() traceback levels
+ length = self._count_relevant_tb_levels(tb)
+ msgLines = traceback.format_exception(exctype, value, tb, length)
+ else:
+ msgLines = traceback.format_exception(exctype, value, tb)
+
+ if self.buffer:
+ output = sys.stdout.getvalue()
+ error = sys.stderr.getvalue()
+ if output:
+ if not output.endswith('\n'):
+ output += '\n'
+ msgLines.append(STDOUT_LINE % output)
+ if error:
+ if not error.endswith('\n'):
+ error += '\n'
+ msgLines.append(STDERR_LINE % error)
+ return ''.join(msgLines)
+
+
+ def _is_relevant_tb_level(self, tb):
+ return '__unittest' in tb.tb_frame.f_globals
+
+ def _count_relevant_tb_levels(self, tb):
+ length = 0
+ while tb and not self._is_relevant_tb_level(tb):
+ length += 1
+ tb = tb.tb_next
+ return length
+
+ def __repr__(self):
+ return ("<%s run=%i errors=%i failures=%i>" %
+ (util.strclass(self.__class__), self.testsRun, len(self.errors),
+ len(self.failures)))
diff --git a/Lib/unittest/runner.py b/Lib/unittest/runner.py
new file mode 100644
index 0000000000..10c4778434
--- /dev/null
+++ b/Lib/unittest/runner.py
@@ -0,0 +1,213 @@
+"""Running tests"""
+
+import sys
+import time
+import warnings
+
+from . import result
+from .signals import registerResult
+
+__unittest = True
+
+
+class _WritelnDecorator(object):
+ """Used to decorate file-like objects with a handy 'writeln' method"""
+ def __init__(self,stream):
+ self.stream = stream
+
+ def __getattr__(self, attr):
+ if attr in ('stream', '__getstate__'):
+ raise AttributeError(attr)
+ return getattr(self.stream,attr)
+
+ def writeln(self, arg=None):
+ if arg:
+ self.write(arg)
+ self.write('\n') # text-mode streams translate to \r\n if needed
+
+
+class TextTestResult(result.TestResult):
+ """A test result class that can print formatted text results to a stream.
+
+ Used by TextTestRunner.
+ """
+ separator1 = '=' * 70
+ separator2 = '-' * 70
+
+ def __init__(self, stream, descriptions, verbosity):
+ super(TextTestResult, self).__init__()
+ self.stream = stream
+ self.showAll = verbosity > 1
+ self.dots = verbosity == 1
+ self.descriptions = descriptions
+
+ def getDescription(self, test):
+ doc_first_line = test.shortDescription()
+ if self.descriptions and doc_first_line:
+ return '\n'.join((str(test), doc_first_line))
+ else:
+ return str(test)
+
+ def startTest(self, test):
+ super(TextTestResult, self).startTest(test)
+ if self.showAll:
+ self.stream.write(self.getDescription(test))
+ self.stream.write(" ... ")
+ self.stream.flush()
+
+ def addSuccess(self, test):
+ super(TextTestResult, self).addSuccess(test)
+ if self.showAll:
+ self.stream.writeln("ok")
+ elif self.dots:
+ self.stream.write('.')
+ self.stream.flush()
+
+ def addError(self, test, err):
+ super(TextTestResult, self).addError(test, err)
+ if self.showAll:
+ self.stream.writeln("ERROR")
+ elif self.dots:
+ self.stream.write('E')
+ self.stream.flush()
+
+ def addFailure(self, test, err):
+ super(TextTestResult, self).addFailure(test, err)
+ if self.showAll:
+ self.stream.writeln("FAIL")
+ elif self.dots:
+ self.stream.write('F')
+ self.stream.flush()
+
+ def addSkip(self, test, reason):
+ super(TextTestResult, self).addSkip(test, reason)
+ if self.showAll:
+ self.stream.writeln("skipped {0!r}".format(reason))
+ elif self.dots:
+ self.stream.write("s")
+ self.stream.flush()
+
+ def addExpectedFailure(self, test, err):
+ super(TextTestResult, self).addExpectedFailure(test, err)
+ if self.showAll:
+ self.stream.writeln("expected failure")
+ elif self.dots:
+ self.stream.write("x")
+ self.stream.flush()
+
+ def addUnexpectedSuccess(self, test):
+ super(TextTestResult, self).addUnexpectedSuccess(test)
+ if self.showAll:
+ self.stream.writeln("unexpected success")
+ elif self.dots:
+ self.stream.write("u")
+ self.stream.flush()
+
+ def printErrors(self):
+ if self.dots or self.showAll:
+ self.stream.writeln()
+ self.printErrorList('ERROR', self.errors)
+ self.printErrorList('FAIL', self.failures)
+
+ def printErrorList(self, flavour, errors):
+ for test, err in errors:
+ self.stream.writeln(self.separator1)
+ self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
+ self.stream.writeln(self.separator2)
+ self.stream.writeln("%s" % err)
+
+
+class TextTestRunner(object):
+ """A test runner class that displays results in textual form.
+
+ It prints out the names of tests as they are run, errors as they
+ occur, and a summary of the results at the end of the test run.
+ """
+ resultclass = TextTestResult
+
+ def __init__(self, stream=None, descriptions=True, verbosity=1,
+ failfast=False, buffer=False, resultclass=None, warnings=None):
+ if stream is None:
+ stream = sys.stderr
+ self.stream = _WritelnDecorator(stream)
+ self.descriptions = descriptions
+ self.verbosity = verbosity
+ self.failfast = failfast
+ self.buffer = buffer
+ self.warnings = warnings
+ if resultclass is not None:
+ self.resultclass = resultclass
+
+ def _makeResult(self):
+ return self.resultclass(self.stream, self.descriptions, self.verbosity)
+
+ def run(self, test):
+ "Run the given test case or test suite."
+ result = self._makeResult()
+ registerResult(result)
+ result.failfast = self.failfast
+ result.buffer = self.buffer
+ with warnings.catch_warnings():
+ if self.warnings:
+ # if self.warnings is set, use it to filter all the warnings
+ warnings.simplefilter(self.warnings)
+ # if the filter is 'default' or 'always', special-case the
+ # warnings from the deprecated unittest methods to show them
+ # no more than once per module, because they can be fairly
+ # noisy. The -Wd and -Wa flags can be used to bypass this
+ # only when self.warnings is None.
+ if self.warnings in ['default', 'always']:
+ warnings.filterwarnings('module',
+ category=DeprecationWarning,
+ message='Please use assert\w+ instead.')
+ startTime = time.time()
+ startTestRun = getattr(result, 'startTestRun', None)
+ if startTestRun is not None:
+ startTestRun()
+ try:
+ test(result)
+ finally:
+ stopTestRun = getattr(result, 'stopTestRun', None)
+ if stopTestRun is not None:
+ stopTestRun()
+ stopTime = time.time()
+ timeTaken = stopTime - startTime
+ result.printErrors()
+ if hasattr(result, 'separator2'):
+ self.stream.writeln(result.separator2)
+ run = result.testsRun
+ self.stream.writeln("Ran %d test%s in %.3fs" %
+ (run, run != 1 and "s" or "", timeTaken))
+ self.stream.writeln()
+
+ expectedFails = unexpectedSuccesses = skipped = 0
+ try:
+ results = map(len, (result.expectedFailures,
+ result.unexpectedSuccesses,
+ result.skipped))
+ except AttributeError:
+ pass
+ else:
+ expectedFails, unexpectedSuccesses, skipped = results
+
+ infos = []
+ if not result.wasSuccessful():
+ self.stream.write("FAILED")
+ failed, errored = len(result.failures), len(result.errors)
+ if failed:
+ infos.append("failures=%d" % failed)
+ if errored:
+ infos.append("errors=%d" % errored)
+ else:
+ self.stream.write("OK")
+ if skipped:
+ infos.append("skipped=%d" % skipped)
+ if expectedFails:
+ infos.append("expected failures=%d" % expectedFails)
+ if unexpectedSuccesses:
+ infos.append("unexpected successes=%d" % unexpectedSuccesses)
+ if infos:
+ self.stream.writeln(" (%s)" % (", ".join(infos),))
+ else:
+ self.stream.write("\n")
+ return result
diff --git a/Lib/unittest/signals.py b/Lib/unittest/signals.py
new file mode 100644
index 0000000000..fc31043283
--- /dev/null
+++ b/Lib/unittest/signals.py
@@ -0,0 +1,57 @@
+import signal
+import weakref
+
+from functools import wraps
+
+__unittest = True
+
+
+class _InterruptHandler(object):
+ def __init__(self, default_handler):
+ self.called = False
+ self.default_handler = default_handler
+
+ def __call__(self, signum, frame):
+ installed_handler = signal.getsignal(signal.SIGINT)
+ if installed_handler is not self:
+ # if we aren't the installed handler, then delegate immediately
+ # to the default handler
+ self.default_handler(signum, frame)
+
+ if self.called:
+ self.default_handler(signum, frame)
+ self.called = True
+ for result in _results.keys():
+ result.stop()
+
+_results = weakref.WeakKeyDictionary()
+def registerResult(result):
+ _results[result] = 1
+
+def removeResult(result):
+ return bool(_results.pop(result, None))
+
+_interrupt_handler = None
+def installHandler():
+ global _interrupt_handler
+ if _interrupt_handler is None:
+ default_handler = signal.getsignal(signal.SIGINT)
+ _interrupt_handler = _InterruptHandler(default_handler)
+ signal.signal(signal.SIGINT, _interrupt_handler)
+
+
+def removeHandler(method=None):
+ if method is not None:
+ @wraps(method)
+ def inner(*args, **kwargs):
+ initial = signal.getsignal(signal.SIGINT)
+ removeHandler()
+ try:
+ return method(*args, **kwargs)
+ finally:
+ signal.signal(signal.SIGINT, initial)
+ return inner
+
+ global _interrupt_handler
+ if _interrupt_handler is not None:
+ signal.signal(signal.SIGINT, _interrupt_handler.default_handler)
diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py
new file mode 100644
index 0000000000..77ce089187
--- /dev/null
+++ b/Lib/unittest/suite.py
@@ -0,0 +1,285 @@
+"""TestSuite"""
+
+import sys
+
+from . import case
+from . import util
+
+__unittest = True
+
+
+class BaseTestSuite(object):
+ """A simple test suite that doesn't provide class or module shared fixtures.
+ """
+ def __init__(self, tests=()):
+ self._tests = []
+ self.addTests(tests)
+
+ def __repr__(self):
+ return "<%s tests=%s>" % (util.strclass(self.__class__), list(self))
+
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ return NotImplemented
+ return list(self) == list(other)
+
+ def __ne__(self, other):
+ return not self == other
+
+ def __iter__(self):
+ return iter(self._tests)
+
+ def countTestCases(self):
+ cases = 0
+ for test in self:
+ cases += test.countTestCases()
+ return cases
+
+ def addTest(self, test):
+ # sanity checks
+ if not hasattr(test, '__call__'):
+ raise TypeError("{} is not callable".format(repr(test)))
+ if isinstance(test, type) and issubclass(test,
+ (case.TestCase, TestSuite)):
+ raise TypeError("TestCases and TestSuites must be instantiated "
+ "before passing them to addTest()")
+ self._tests.append(test)
+
+ def addTests(self, tests):
+ if isinstance(tests, str):
+ raise TypeError("tests must be an iterable of tests, not a string")
+ for test in tests:
+ self.addTest(test)
+
+ def run(self, result):
+ for test in self:
+ if result.shouldStop:
+ break
+ test(result)
+ return result
+
+ def __call__(self, *args, **kwds):
+ return self.run(*args, **kwds)
+
+ def debug(self):
+ """Run the tests without collecting errors in a TestResult"""
+ for test in self:
+ test.debug()
+
+
+class TestSuite(BaseTestSuite):
+ """A test suite is a composite test consisting of a number of TestCases.
+
+ For use, create an instance of TestSuite, then add test case instances.
+ When all tests have been added, the suite can be passed to a test
+ runner, such as TextTestRunner. It will run the individual test cases
+ in the order in which they were added, aggregating the results. When
+ subclassing, do not forget to call the base class constructor.
+ """
+
+ def run(self, result, debug=False):
+ topLevel = False
+ if getattr(result, '_testRunEntered', False) is False:
+ result._testRunEntered = topLevel = True
+
+ for test in self:
+ if result.shouldStop:
+ break
+
+ if _isnotsuite(test):
+ self._tearDownPreviousClass(test, result)
+ self._handleModuleFixture(test, result)
+ self._handleClassSetUp(test, result)
+ result._previousTestClass = test.__class__
+
+ if (getattr(test.__class__, '_classSetupFailed', False) or
+ getattr(result, '_moduleSetUpFailed', False)):
+ continue
+
+ if not debug:
+ test(result)
+ else:
+ test.debug()
+
+ if topLevel:
+ self._tearDownPreviousClass(None, result)
+ self._handleModuleTearDown(result)
+ result._testRunEntered = False
+ return result
+
+ def debug(self):
+ """Run the tests without collecting errors in a TestResult"""
+ debug = _DebugResult()
+ self.run(debug, True)
+
+ ################################
+
+ def _handleClassSetUp(self, test, result):
+ previousClass = getattr(result, '_previousTestClass', None)
+ currentClass = test.__class__
+ if currentClass == previousClass:
+ return
+ if result._moduleSetUpFailed:
+ return
+ if getattr(currentClass, "__unittest_skip__", False):
+ return
+
+ try:
+ currentClass._classSetupFailed = False
+ except TypeError:
+ # test may actually be a function
+ # so its class will be a builtin-type
+ pass
+
+ setUpClass = getattr(currentClass, 'setUpClass', None)
+ if setUpClass is not None:
+ try:
+ setUpClass()
+ except Exception as e:
+ if isinstance(result, _DebugResult):
+ raise
+ currentClass._classSetupFailed = True
+ className = util.strclass(currentClass)
+ errorName = 'setUpClass (%s)' % className
+ self._addClassOrModuleLevelException(result, e, errorName)
+
+ def _get_previous_module(self, result):
+ previousModule = None
+ previousClass = getattr(result, '_previousTestClass', None)
+ if previousClass is not None:
+ previousModule = previousClass.__module__
+ return previousModule
+
+
+ def _handleModuleFixture(self, test, result):
+ previousModule = self._get_previous_module(result)
+ currentModule = test.__class__.__module__
+ if currentModule == previousModule:
+ return
+
+ self._handleModuleTearDown(result)
+
+
+ result._moduleSetUpFailed = False
+ try:
+ module = sys.modules[currentModule]
+ except KeyError:
+ return
+ setUpModule = getattr(module, 'setUpModule', None)
+ if setUpModule is not None:
+ try:
+ setUpModule()
+ except Exception as e:
+ if isinstance(result, _DebugResult):
+ raise
+ result._moduleSetUpFailed = True
+ errorName = 'setUpModule (%s)' % currentModule
+ self._addClassOrModuleLevelException(result, e, errorName)
+
+ def _addClassOrModuleLevelException(self, result, exception, errorName):
+ error = _ErrorHolder(errorName)
+ addSkip = getattr(result, 'addSkip', None)
+ if addSkip is not None and isinstance(exception, case.SkipTest):
+ addSkip(error, str(exception))
+ else:
+ result.addError(error, sys.exc_info())
+
+ def _handleModuleTearDown(self, result):
+ previousModule = self._get_previous_module(result)
+ if previousModule is None:
+ return
+ if result._moduleSetUpFailed:
+ return
+
+ try:
+ module = sys.modules[previousModule]
+ except KeyError:
+ return
+
+ tearDownModule = getattr(module, 'tearDownModule', None)
+ if tearDownModule is not None:
+ try:
+ tearDownModule()
+ except Exception as e:
+ if isinstance(result, _DebugResult):
+ raise
+ errorName = 'tearDownModule (%s)' % previousModule
+ self._addClassOrModuleLevelException(result, e, errorName)
+
+ def _tearDownPreviousClass(self, test, result):
+ previousClass = getattr(result, '_previousTestClass', None)
+ currentClass = test.__class__
+ if currentClass == previousClass:
+ return
+ if getattr(previousClass, '_classSetupFailed', False):
+ return
+ if getattr(result, '_moduleSetUpFailed', False):
+ return
+ if getattr(previousClass, "__unittest_skip__", False):
+ return
+
+ tearDownClass = getattr(previousClass, 'tearDownClass', None)
+ if tearDownClass is not None:
+ try:
+ tearDownClass()
+ except Exception as e:
+ if isinstance(result, _DebugResult):
+ raise
+ className = util.strclass(previousClass)
+ errorName = 'tearDownClass (%s)' % className
+ self._addClassOrModuleLevelException(result, e, errorName)
+
+
+
+class _ErrorHolder(object):
+ """
+ Placeholder for a TestCase inside a result. As far as a TestResult
+ is concerned, this looks exactly like a unit test. Used to insert
+ arbitrary errors into a test suite run.
+ """
+ # Inspired by the ErrorHolder from Twisted:
+ # http://twistedmatrix.com/trac/browser/trunk/twisted/trial/runner.py
+
+ # attribute used by TestResult._exc_info_to_string
+ failureException = None
+
+ def __init__(self, description):
+ self.description = description
+
+ def id(self):
+ return self.description
+
+ def shortDescription(self):
+ return None
+
+ def __repr__(self):
+ return "<ErrorHolder description=%r>" % (self.description,)
+
+ def __str__(self):
+ return self.id()
+
+ def run(self, result):
+ # could call result.addError(...) - but this test-like object
+ # shouldn't be run anyway
+ pass
+
+ def __call__(self, result):
+ return self.run(result)
+
+ def countTestCases(self):
+ return 0
+
+def _isnotsuite(test):
+ "A crude way to tell apart testcases and suites with duck-typing"
+ try:
+ iter(test)
+ except TypeError:
+ return True
+ return False
+
+
+class _DebugResult(object):
+ "Used by the TestSuite to hold previous class when running in debug."
+ _previousTestClass = None
+ _moduleSetUpFailed = False
+ shouldStop = False
diff --git a/Lib/unittest/test/__init__.py b/Lib/unittest/test/__init__.py
new file mode 100644
index 0000000000..99b730b154
--- /dev/null
+++ b/Lib/unittest/test/__init__.py
@@ -0,0 +1,21 @@
+import os
+import sys
+import unittest
+
+
+here = os.path.dirname(__file__)
+loader = unittest.defaultTestLoader
+
+def suite():
+ suite = unittest.TestSuite()
+ for fn in os.listdir(here):
+ if fn.startswith("test") and fn.endswith(".py"):
+ modname = "unittest.test." + fn[:-3]
+ __import__(modname)
+ module = sys.modules[modname]
+ suite.addTest(loader.loadTestsFromModule(module))
+ return suite
+
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="suite")
diff --git a/Lib/unittest/test/_test_warnings.py b/Lib/unittest/test/_test_warnings.py
new file mode 100644
index 0000000000..d0be18d4ad
--- /dev/null
+++ b/Lib/unittest/test/_test_warnings.py
@@ -0,0 +1,74 @@
+# helper module for test_runner.Test_TextTestRunner.test_warnings
+
+"""
+This module has a number of tests that raise different kinds of warnings.
+When the tests are run, the warnings are caught and their messages are printed
+to stdout. This module also accepts an arg that is then passed to
+unittest.main to affect the behavior of warnings.
+Test_TextTestRunner.test_warnings executes this script with different
+combinations of warnings args and -W flags and check that the output is correct.
+See #10535.
+"""
+
+import io
+import sys
+import unittest
+import warnings
+
+def warnfun():
+ warnings.warn('rw', RuntimeWarning)
+
+class TestWarnings(unittest.TestCase):
+ # unittest warnings will be printed at most once per type (max one message
+ # for the fail* methods, and one for the assert* methods)
+ def test_assert(self):
+ self.assertEquals(2+2, 4)
+ self.assertEquals(2*2, 4)
+ self.assertEquals(2**2, 4)
+
+ def test_fail(self):
+ self.failUnless(1)
+ self.failUnless(True)
+
+ def test_other_unittest(self):
+ self.assertAlmostEqual(2+2, 4)
+ self.assertNotAlmostEqual(4+4, 2)
+
+ # these warnings are normally silenced, but they are printed in unittest
+ def test_deprecation(self):
+ warnings.warn('dw', DeprecationWarning)
+ warnings.warn('dw', DeprecationWarning)
+ warnings.warn('dw', DeprecationWarning)
+
+ def test_import(self):
+ warnings.warn('iw', ImportWarning)
+ warnings.warn('iw', ImportWarning)
+ warnings.warn('iw', ImportWarning)
+
+ # user warnings should always be printed
+ def test_warning(self):
+ warnings.warn('uw')
+ warnings.warn('uw')
+ warnings.warn('uw')
+
+ # these warnings come from the same place; they will be printed
+ # only once by default or three times if the 'always' filter is used
+ def test_function(self):
+
+ warnfun()
+ warnfun()
+ warnfun()
+
+
+
+if __name__ == '__main__':
+ with warnings.catch_warnings(record=True) as ws:
+ # if an arg is provided pass it to unittest.main as 'warnings'
+ if len(sys.argv) == 2:
+ unittest.main(exit=False, warnings=sys.argv.pop())
+ else:
+ unittest.main(exit=False)
+
+ # print all the warning messages collected
+ for w in ws:
+ print(w.message)
diff --git a/Lib/unittest/test/dummy.py b/Lib/unittest/test/dummy.py
new file mode 100644
index 0000000000..e4f14e4035
--- /dev/null
+++ b/Lib/unittest/test/dummy.py
@@ -0,0 +1 @@
+# Empty module for testing the loading of modules
diff --git a/Lib/unittest/test/support.py b/Lib/unittest/test/support.py
new file mode 100644
index 0000000000..dbe4ddcd0e
--- /dev/null
+++ b/Lib/unittest/test/support.py
@@ -0,0 +1,118 @@
+import unittest
+
+
+class TestEquality(object):
+ """Used as a mixin for TestCase"""
+
+ # Check for a valid __eq__ implementation
+ def test_eq(self):
+ for obj_1, obj_2 in self.eq_pairs:
+ self.assertEqual(obj_1, obj_2)
+ self.assertEqual(obj_2, obj_1)
+
+ # Check for a valid __ne__ implementation
+ def test_ne(self):
+ for obj_1, obj_2 in self.ne_pairs:
+ self.assertNotEqual(obj_1, obj_2)
+ self.assertNotEqual(obj_2, obj_1)
+
+class TestHashing(object):
+ """Used as a mixin for TestCase"""
+
+ # Check for a valid __hash__ implementation
+ def test_hash(self):
+ for obj_1, obj_2 in self.eq_pairs:
+ try:
+ if not hash(obj_1) == hash(obj_2):
+ self.fail("%r and %r do not hash equal" % (obj_1, obj_2))
+ except KeyboardInterrupt:
+ raise
+ except Exception as e:
+ self.fail("Problem hashing %r and %r: %s" % (obj_1, obj_2, e))
+
+ for obj_1, obj_2 in self.ne_pairs:
+ try:
+ if hash(obj_1) == hash(obj_2):
+ self.fail("%s and %s hash equal, but shouldn't" %
+ (obj_1, obj_2))
+ except KeyboardInterrupt:
+ raise
+ except Exception as e:
+ self.fail("Problem hashing %s and %s: %s" % (obj_1, obj_2, e))
+
+
+class LoggingResult(unittest.TestResult):
+ def __init__(self, log):
+ self._events = log
+ super().__init__()
+
+ def startTest(self, test):
+ self._events.append('startTest')
+ super().startTest(test)
+
+ def startTestRun(self):
+ self._events.append('startTestRun')
+ super(LoggingResult, self).startTestRun()
+
+ def stopTest(self, test):
+ self._events.append('stopTest')
+ super().stopTest(test)
+
+ def stopTestRun(self):
+ self._events.append('stopTestRun')
+ super(LoggingResult, self).stopTestRun()
+
+ def addFailure(self, *args):
+ self._events.append('addFailure')
+ super().addFailure(*args)
+
+ def addSuccess(self, *args):
+ self._events.append('addSuccess')
+ super(LoggingResult, self).addSuccess(*args)
+
+ def addError(self, *args):
+ self._events.append('addError')
+ super().addError(*args)
+
+ def addSkip(self, *args):
+ self._events.append('addSkip')
+ super(LoggingResult, self).addSkip(*args)
+
+ def addExpectedFailure(self, *args):
+ self._events.append('addExpectedFailure')
+ super(LoggingResult, self).addExpectedFailure(*args)
+
+ def addUnexpectedSuccess(self, *args):
+ self._events.append('addUnexpectedSuccess')
+ super(LoggingResult, self).addUnexpectedSuccess(*args)
+
+
+class ResultWithNoStartTestRunStopTestRun(object):
+ """An object honouring TestResult before startTestRun/stopTestRun."""
+
+ def __init__(self):
+ self.failures = []
+ self.errors = []
+ self.testsRun = 0
+ self.skipped = []
+ self.expectedFailures = []
+ self.unexpectedSuccesses = []
+ self.shouldStop = False
+
+ def startTest(self, test):
+ pass
+
+ def stopTest(self, test):
+ pass
+
+ def addError(self, test):
+ pass
+
+ def addFailure(self, test):
+ pass
+
+ def addSuccess(self, test):
+ pass
+
+ def wasSuccessful(self):
+ return True
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py
new file mode 100644
index 0000000000..a1d20ebf2d
--- /dev/null
+++ b/Lib/unittest/test/test_assertions.py
@@ -0,0 +1,286 @@
+import datetime
+import warnings
+import unittest
+
+
+class Test_Assertions(unittest.TestCase):
+ def test_AlmostEqual(self):
+ self.assertAlmostEqual(1.00000001, 1.0)
+ self.assertNotAlmostEqual(1.0000001, 1.0)
+ self.assertRaises(self.failureException,
+ self.assertAlmostEqual, 1.0000001, 1.0)
+ self.assertRaises(self.failureException,
+ self.assertNotAlmostEqual, 1.00000001, 1.0)
+
+ self.assertAlmostEqual(1.1, 1.0, places=0)
+ self.assertRaises(self.failureException,
+ self.assertAlmostEqual, 1.1, 1.0, places=1)
+
+ self.assertAlmostEqual(0, .1+.1j, places=0)
+ self.assertNotAlmostEqual(0, .1+.1j, places=1)
+ self.assertRaises(self.failureException,
+ self.assertAlmostEqual, 0, .1+.1j, places=1)
+ self.assertRaises(self.failureException,
+ self.assertNotAlmostEqual, 0, .1+.1j, places=0)
+
+ self.assertAlmostEqual(float('inf'), float('inf'))
+ self.assertRaises(self.failureException, self.assertNotAlmostEqual,
+ float('inf'), float('inf'))
+
+ def test_AmostEqualWithDelta(self):
+ self.assertAlmostEqual(1.1, 1.0, delta=0.5)
+ self.assertAlmostEqual(1.0, 1.1, delta=0.5)
+ self.assertNotAlmostEqual(1.1, 1.0, delta=0.05)
+ self.assertNotAlmostEqual(1.0, 1.1, delta=0.05)
+
+ self.assertRaises(self.failureException, self.assertAlmostEqual,
+ 1.1, 1.0, delta=0.05)
+ self.assertRaises(self.failureException, self.assertNotAlmostEqual,
+ 1.1, 1.0, delta=0.5)
+
+ self.assertRaises(TypeError, self.assertAlmostEqual,
+ 1.1, 1.0, places=2, delta=2)
+ self.assertRaises(TypeError, self.assertNotAlmostEqual,
+ 1.1, 1.0, places=2, delta=2)
+
+ first = datetime.datetime.now()
+ second = first + datetime.timedelta(seconds=10)
+ self.assertAlmostEqual(first, second,
+ delta=datetime.timedelta(seconds=20))
+ self.assertNotAlmostEqual(first, second,
+ delta=datetime.timedelta(seconds=5))
+
+ def test_assertRaises(self):
+ def _raise(e):
+ raise e
+ self.assertRaises(KeyError, _raise, KeyError)
+ self.assertRaises(KeyError, _raise, KeyError("key"))
+ try:
+ self.assertRaises(KeyError, lambda: None)
+ except self.failureException as e:
+ self.assertIn("KeyError not raised", str(e))
+ else:
+ self.fail("assertRaises() didn't fail")
+ try:
+ self.assertRaises(KeyError, _raise, ValueError)
+ except ValueError:
+ pass
+ else:
+ self.fail("assertRaises() didn't let exception pass through")
+ with self.assertRaises(KeyError) as cm:
+ try:
+ raise KeyError
+ except Exception as e:
+ exc = e
+ raise
+ self.assertIs(cm.exception, exc)
+
+ with self.assertRaises(KeyError):
+ raise KeyError("key")
+ try:
+ with self.assertRaises(KeyError):
+ pass
+ except self.failureException as e:
+ self.assertIn("KeyError not raised", str(e))
+ else:
+ self.fail("assertRaises() didn't fail")
+ try:
+ with self.assertRaises(KeyError):
+ raise ValueError
+ except ValueError:
+ pass
+ else:
+ self.fail("assertRaises() didn't let exception pass through")
+
+ def testAssertNotRegex(self):
+ self.assertNotRegex('Ala ma kota', r'r+')
+ try:
+ self.assertNotRegex('Ala ma kota', r'k.t', 'Message')
+ except self.failureException as e:
+ self.assertIn("'kot'", e.args[0])
+ self.assertIn('Message', e.args[0])
+ else:
+ self.fail('assertNotRegex should have failed.')
+
+
+class TestLongMessage(unittest.TestCase):
+ """Test that the individual asserts honour longMessage.
+ This actually tests all the message behaviour for
+ asserts that use longMessage."""
+
+ def setUp(self):
+ class TestableTestFalse(unittest.TestCase):
+ longMessage = False
+ failureException = self.failureException
+
+ def testTest(self):
+ pass
+
+ class TestableTestTrue(unittest.TestCase):
+ longMessage = True
+ failureException = self.failureException
+
+ def testTest(self):
+ pass
+
+ self.testableTrue = TestableTestTrue('testTest')
+ self.testableFalse = TestableTestFalse('testTest')
+
+ def testDefault(self):
+ self.assertTrue(unittest.TestCase.longMessage)
+
+ def test_formatMsg(self):
+ self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo")
+ self.assertEqual(self.testableFalse._formatMessage("foo", "bar"), "foo")
+
+ self.assertEqual(self.testableTrue._formatMessage(None, "foo"), "foo")
+ self.assertEqual(self.testableTrue._formatMessage("foo", "bar"), "bar : foo")
+
+ # This blows up if _formatMessage uses string concatenation
+ self.testableTrue._formatMessage(object(), 'foo')
+
+ def test_formatMessage_unicode_error(self):
+ one = ''.join(chr(i) for i in range(255))
+ # this used to cause a UnicodeDecodeError constructing msg
+ self.testableTrue._formatMessage(one, '\uFFFD')
+
+ def assertMessages(self, methodName, args, errors):
+ def getMethod(i):
+ useTestableFalse = i < 2
+ if useTestableFalse:
+ test = self.testableFalse
+ else:
+ test = self.testableTrue
+ return getattr(test, methodName)
+
+ for i, expected_regex in enumerate(errors):
+ testMethod = getMethod(i)
+ kwargs = {}
+ withMsg = i % 2
+ if withMsg:
+ kwargs = {"msg": "oops"}
+
+ with self.assertRaisesRegex(self.failureException,
+ expected_regex=expected_regex):
+ testMethod(*args, **kwargs)
+
+ def testAssertTrue(self):
+ self.assertMessages('assertTrue', (False,),
+ ["^False is not true$", "^oops$", "^False is not true$",
+ "^False is not true : oops$"])
+
+ def testAssertFalse(self):
+ self.assertMessages('assertFalse', (True,),
+ ["^True is not false$", "^oops$", "^True is not false$",
+ "^True is not false : oops$"])
+
+ def testNotEqual(self):
+ self.assertMessages('assertNotEqual', (1, 1),
+ ["^1 == 1$", "^oops$", "^1 == 1$",
+ "^1 == 1 : oops$"])
+
+ def testAlmostEqual(self):
+ self.assertMessages('assertAlmostEqual', (1, 2),
+ ["^1 != 2 within 7 places$", "^oops$",
+ "^1 != 2 within 7 places$", "^1 != 2 within 7 places : oops$"])
+
+ def testNotAlmostEqual(self):
+ self.assertMessages('assertNotAlmostEqual', (1, 1),
+ ["^1 == 1 within 7 places$", "^oops$",
+ "^1 == 1 within 7 places$", "^1 == 1 within 7 places : oops$"])
+
+ def test_baseAssertEqual(self):
+ self.assertMessages('_baseAssertEqual', (1, 2),
+ ["^1 != 2$", "^oops$", "^1 != 2$", "^1 != 2 : oops$"])
+
+ def testAssertSequenceEqual(self):
+ # Error messages are multiline so not testing on full message
+ # assertTupleEqual and assertListEqual delegate to this method
+ self.assertMessages('assertSequenceEqual', ([], [None]),
+ ["\+ \[None\]$", "^oops$", r"\+ \[None\]$",
+ r"\+ \[None\] : oops$"])
+
+ def testAssertSetEqual(self):
+ self.assertMessages('assertSetEqual', (set(), set([None])),
+ ["None$", "^oops$", "None$",
+ "None : oops$"])
+
+ def testAssertIn(self):
+ self.assertMessages('assertIn', (None, []),
+ ['^None not found in \[\]$', "^oops$",
+ '^None not found in \[\]$',
+ '^None not found in \[\] : oops$'])
+
+ def testAssertNotIn(self):
+ self.assertMessages('assertNotIn', (None, [None]),
+ ['^None unexpectedly found in \[None\]$', "^oops$",
+ '^None unexpectedly found in \[None\]$',
+ '^None unexpectedly found in \[None\] : oops$'])
+
+ def testAssertDictEqual(self):
+ self.assertMessages('assertDictEqual', ({}, {'key': 'value'}),
+ [r"\+ \{'key': 'value'\}$", "^oops$",
+ "\+ \{'key': 'value'\}$",
+ "\+ \{'key': 'value'\} : oops$"])
+
+ def testAssertDictContainsSubset(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+
+ self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}),
+ ["^Missing: 'key'$", "^oops$",
+ "^Missing: 'key'$",
+ "^Missing: 'key' : oops$"])
+
+ def testAssertMultiLineEqual(self):
+ self.assertMessages('assertMultiLineEqual', ("", "foo"),
+ [r"\+ foo$", "^oops$",
+ r"\+ foo$",
+ r"\+ foo : oops$"])
+
+ def testAssertLess(self):
+ self.assertMessages('assertLess', (2, 1),
+ ["^2 not less than 1$", "^oops$",
+ "^2 not less than 1$", "^2 not less than 1 : oops$"])
+
+ def testAssertLessEqual(self):
+ self.assertMessages('assertLessEqual', (2, 1),
+ ["^2 not less than or equal to 1$", "^oops$",
+ "^2 not less than or equal to 1$",
+ "^2 not less than or equal to 1 : oops$"])
+
+ def testAssertGreater(self):
+ self.assertMessages('assertGreater', (1, 2),
+ ["^1 not greater than 2$", "^oops$",
+ "^1 not greater than 2$",
+ "^1 not greater than 2 : oops$"])
+
+ def testAssertGreaterEqual(self):
+ self.assertMessages('assertGreaterEqual', (1, 2),
+ ["^1 not greater than or equal to 2$", "^oops$",
+ "^1 not greater than or equal to 2$",
+ "^1 not greater than or equal to 2 : oops$"])
+
+ def testAssertIsNone(self):
+ self.assertMessages('assertIsNone', ('not None',),
+ ["^'not None' is not None$", "^oops$",
+ "^'not None' is not None$",
+ "^'not None' is not None : oops$"])
+
+ def testAssertIsNotNone(self):
+ self.assertMessages('assertIsNotNone', (None,),
+ ["^unexpectedly None$", "^oops$",
+ "^unexpectedly None$",
+ "^unexpectedly None : oops$"])
+
+ def testAssertIs(self):
+ self.assertMessages('assertIs', (None, 'foo'),
+ ["^None is not 'foo'$", "^oops$",
+ "^None is not 'foo'$",
+ "^None is not 'foo' : oops$"])
+
+ def testAssertIsNot(self):
+ self.assertMessages('assertIsNot', (None, None),
+ ["^unexpectedly identical: None$", "^oops$",
+ "^unexpectedly identical: None$",
+ "^unexpectedly identical: None : oops$"])
diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py
new file mode 100644
index 0000000000..77ce20143b
--- /dev/null
+++ b/Lib/unittest/test/test_break.py
@@ -0,0 +1,252 @@
+import gc
+import io
+import os
+import sys
+import signal
+import weakref
+
+import unittest
+
+
+@unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill")
+@unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows")
+@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 "
+ "if threads have been used")
+class TestBreak(unittest.TestCase):
+
+ def setUp(self):
+ self._default_handler = signal.getsignal(signal.SIGINT)
+
+ def tearDown(self):
+ signal.signal(signal.SIGINT, self._default_handler)
+ unittest.signals._results = weakref.WeakKeyDictionary()
+ unittest.signals._interrupt_handler = None
+
+
+ def testInstallHandler(self):
+ default_handler = signal.getsignal(signal.SIGINT)
+ unittest.installHandler()
+ self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+ try:
+ pid = os.getpid()
+ os.kill(pid, signal.SIGINT)
+ except KeyboardInterrupt:
+ self.fail("KeyboardInterrupt not handled")
+
+ self.assertTrue(unittest.signals._interrupt_handler.called)
+
+ def testRegisterResult(self):
+ result = unittest.TestResult()
+ unittest.registerResult(result)
+
+ for ref in unittest.signals._results:
+ if ref is result:
+ break
+ elif ref is not result:
+ self.fail("odd object in result set")
+ else:
+ self.fail("result not found")
+
+
+ def testInterruptCaught(self):
+ default_handler = signal.getsignal(signal.SIGINT)
+
+ result = unittest.TestResult()
+ unittest.installHandler()
+ unittest.registerResult(result)
+
+ self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+ def test(result):
+ pid = os.getpid()
+ os.kill(pid, signal.SIGINT)
+ result.breakCaught = True
+ self.assertTrue(result.shouldStop)
+
+ try:
+ test(result)
+ except KeyboardInterrupt:
+ self.fail("KeyboardInterrupt not handled")
+ self.assertTrue(result.breakCaught)
+
+
+ def testSecondInterrupt(self):
+ result = unittest.TestResult()
+ unittest.installHandler()
+ unittest.registerResult(result)
+
+ def test(result):
+ pid = os.getpid()
+ os.kill(pid, signal.SIGINT)
+ result.breakCaught = True
+ self.assertTrue(result.shouldStop)
+ os.kill(pid, signal.SIGINT)
+ self.fail("Second KeyboardInterrupt not raised")
+
+ try:
+ test(result)
+ except KeyboardInterrupt:
+ pass
+ else:
+ self.fail("Second KeyboardInterrupt not raised")
+ self.assertTrue(result.breakCaught)
+
+
+ def testTwoResults(self):
+ unittest.installHandler()
+
+ result = unittest.TestResult()
+ unittest.registerResult(result)
+ new_handler = signal.getsignal(signal.SIGINT)
+
+ result2 = unittest.TestResult()
+ unittest.registerResult(result2)
+ self.assertEqual(signal.getsignal(signal.SIGINT), new_handler)
+
+ result3 = unittest.TestResult()
+
+ def test(result):
+ pid = os.getpid()
+ os.kill(pid, signal.SIGINT)
+
+ try:
+ test(result)
+ except KeyboardInterrupt:
+ self.fail("KeyboardInterrupt not handled")
+
+ self.assertTrue(result.shouldStop)
+ self.assertTrue(result2.shouldStop)
+ self.assertFalse(result3.shouldStop)
+
+
+ def testHandlerReplacedButCalled(self):
+ # If our handler has been replaced (is no longer installed) but is
+ # called by the *new* handler, then it isn't safe to delay the
+ # SIGINT and we should immediately delegate to the default handler
+ unittest.installHandler()
+
+ handler = signal.getsignal(signal.SIGINT)
+ def new_handler(frame, signum):
+ handler(frame, signum)
+ signal.signal(signal.SIGINT, new_handler)
+
+ try:
+ pid = os.getpid()
+ os.kill(pid, signal.SIGINT)
+ except KeyboardInterrupt:
+ pass
+ else:
+ self.fail("replaced but delegated handler doesn't raise interrupt")
+
+ def testRunner(self):
+ # Creating a TextTestRunner with the appropriate argument should
+ # register the TextTestResult it creates
+ runner = unittest.TextTestRunner(stream=io.StringIO())
+
+ result = runner.run(unittest.TestSuite())
+ self.assertIn(result, unittest.signals._results)
+
+ def testWeakReferences(self):
+ # Calling registerResult on a result should not keep it alive
+ result = unittest.TestResult()
+ unittest.registerResult(result)
+
+ ref = weakref.ref(result)
+ del result
+
+ # For non-reference counting implementations
+ gc.collect();gc.collect()
+ self.assertIsNone(ref())
+
+
+ def testRemoveResult(self):
+ result = unittest.TestResult()
+ unittest.registerResult(result)
+
+ unittest.installHandler()
+ self.assertTrue(unittest.removeResult(result))
+
+ # Should this raise an error instead?
+ self.assertFalse(unittest.removeResult(unittest.TestResult()))
+
+ try:
+ pid = os.getpid()
+ os.kill(pid, signal.SIGINT)
+ except KeyboardInterrupt:
+ pass
+
+ self.assertFalse(result.shouldStop)
+
+ def testMainInstallsHandler(self):
+ failfast = object()
+ test = object()
+ verbosity = object()
+ result = object()
+ default_handler = signal.getsignal(signal.SIGINT)
+
+ class FakeRunner(object):
+ initArgs = []
+ runArgs = []
+ def __init__(self, *args, **kwargs):
+ self.initArgs.append((args, kwargs))
+ def run(self, test):
+ self.runArgs.append(test)
+ return result
+
+ class Program(unittest.TestProgram):
+ def __init__(self, catchbreak):
+ self.exit = False
+ self.verbosity = verbosity
+ self.failfast = failfast
+ self.catchbreak = catchbreak
+ self.testRunner = FakeRunner
+ self.test = test
+ self.result = None
+
+ p = Program(False)
+ p.runTests()
+
+ self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None,
+ 'verbosity': verbosity,
+ 'failfast': failfast,
+ 'warnings': None})])
+ self.assertEqual(FakeRunner.runArgs, [test])
+ self.assertEqual(p.result, result)
+
+ self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+ FakeRunner.initArgs = []
+ FakeRunner.runArgs = []
+ p = Program(True)
+ p.runTests()
+
+ self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None,
+ 'verbosity': verbosity,
+ 'failfast': failfast,
+ 'warnings': None})])
+ self.assertEqual(FakeRunner.runArgs, [test])
+ self.assertEqual(p.result, result)
+
+ self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+ def testRemoveHandler(self):
+ default_handler = signal.getsignal(signal.SIGINT)
+ unittest.installHandler()
+ unittest.removeHandler()
+ self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+ # check that calling removeHandler multiple times has no ill-effect
+ unittest.removeHandler()
+ self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+ def testRemoveHandlerAsDecorator(self):
+ default_handler = signal.getsignal(signal.SIGINT)
+ unittest.installHandler()
+
+ @unittest.removeHandler
+ def test():
+ self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+ test()
+ self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py
new file mode 100644
index 0000000000..314aef3ac7
--- /dev/null
+++ b/Lib/unittest/test/test_case.py
@@ -0,0 +1,1236 @@
+import difflib
+import pprint
+import pickle
+import re
+import sys
+import warnings
+import inspect
+
+from copy import deepcopy
+from test import support
+
+import unittest
+
+from .support import (
+ TestEquality, TestHashing, LoggingResult,
+ ResultWithNoStartTestRunStopTestRun
+)
+
+
+class Test(object):
+ "Keep these TestCase classes out of the main namespace"
+
+ class Foo(unittest.TestCase):
+ def runTest(self): pass
+ def test1(self): pass
+
+ class Bar(Foo):
+ def test2(self): pass
+
+ class LoggingTestCase(unittest.TestCase):
+ """A test case which logs its calls."""
+
+ def __init__(self, events):
+ super(Test.LoggingTestCase, self).__init__('test')
+ self.events = events
+
+ def setUp(self):
+ self.events.append('setUp')
+
+ def test(self):
+ self.events.append('test')
+
+ def tearDown(self):
+ self.events.append('tearDown')
+
+
+class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
+
+ ### Set up attributes used by inherited tests
+ ################################################################
+
+ # Used by TestHashing.test_hash and TestEquality.test_eq
+ eq_pairs = [(Test.Foo('test1'), Test.Foo('test1'))]
+
+ # Used by TestEquality.test_ne
+ ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest')),
+ (Test.Foo('test1'), Test.Bar('test1')),
+ (Test.Foo('test1'), Test.Bar('test2'))]
+
+ ################################################################
+ ### /Set up attributes used by inherited tests
+
+
+ # "class TestCase([methodName])"
+ # ...
+ # "Each instance of TestCase will run a single test method: the
+ # method named methodName."
+ # ...
+ # "methodName defaults to "runTest"."
+ #
+ # Make sure it really is optional, and that it defaults to the proper
+ # thing.
+ def test_init__no_test_name(self):
+ class Test(unittest.TestCase):
+ def runTest(self): raise MyException()
+ def test(self): pass
+
+ self.assertEqual(Test().id()[-13:], '.Test.runTest')
+
+ # test that TestCase can be instantiated with no args
+ # primarily for use at the interactive interpreter
+ test = unittest.TestCase()
+ test.assertEqual(3, 3)
+ with test.assertRaises(test.failureException):
+ test.assertEqual(3, 2)
+
+ with self.assertRaises(AttributeError):
+ test.run()
+
+ # "class TestCase([methodName])"
+ # ...
+ # "Each instance of TestCase will run a single test method: the
+ # method named methodName."
+ def test_init__test_name__valid(self):
+ class Test(unittest.TestCase):
+ def runTest(self): raise MyException()
+ def test(self): pass
+
+ self.assertEqual(Test('test').id()[-10:], '.Test.test')
+
+ # "class TestCase([methodName])"
+ # ...
+ # "Each instance of TestCase will run a single test method: the
+ # method named methodName."
+ def test_init__test_name__invalid(self):
+ class Test(unittest.TestCase):
+ def runTest(self): raise MyException()
+ def test(self): pass
+
+ try:
+ Test('testfoo')
+ except ValueError:
+ pass
+ else:
+ self.fail("Failed to raise ValueError")
+
+ # "Return the number of tests represented by the this test object. For
+ # TestCase instances, this will always be 1"
+ def test_countTestCases(self):
+ class Foo(unittest.TestCase):
+ def test(self): pass
+
+ self.assertEqual(Foo('test').countTestCases(), 1)
+
+ # "Return the default type of test result object to be used to run this
+ # test. For TestCase instances, this will always be
+ # unittest.TestResult; subclasses of TestCase should
+ # override this as necessary."
+ def test_defaultTestResult(self):
+ class Foo(unittest.TestCase):
+ def runTest(self):
+ pass
+
+ result = Foo().defaultTestResult()
+ self.assertEqual(type(result), unittest.TestResult)
+
+ # "When a setUp() method is defined, the test runner will run that method
+ # prior to each test. Likewise, if a tearDown() method is defined, the
+ # test runner will invoke that method after each test. In the example,
+ # setUp() was used to create a fresh sequence for each test."
+ #
+ # Make sure the proper call order is maintained, even if setUp() raises
+ # an exception.
+ def test_run_call_order__error_in_setUp(self):
+ events = []
+ result = LoggingResult(events)
+
+ class Foo(Test.LoggingTestCase):
+ def setUp(self):
+ super(Foo, self).setUp()
+ raise RuntimeError('raised by Foo.setUp')
+
+ Foo(events).run(result)
+ expected = ['startTest', 'setUp', 'addError', 'stopTest']
+ self.assertEqual(events, expected)
+
+ # "With a temporary result stopTestRun is called when setUp errors.
+ def test_run_call_order__error_in_setUp_default_result(self):
+ events = []
+
+ class Foo(Test.LoggingTestCase):
+ def defaultTestResult(self):
+ return LoggingResult(self.events)
+
+ def setUp(self):
+ super(Foo, self).setUp()
+ raise RuntimeError('raised by Foo.setUp')
+
+ Foo(events).run()
+ expected = ['startTestRun', 'startTest', 'setUp', 'addError',
+ 'stopTest', 'stopTestRun']
+ self.assertEqual(events, expected)
+
+ # "When a setUp() method is defined, the test runner will run that method
+ # prior to each test. Likewise, if a tearDown() method is defined, the
+ # test runner will invoke that method after each test. In the example,
+ # setUp() was used to create a fresh sequence for each test."
+ #
+ # Make sure the proper call order is maintained, even if the test raises
+ # an error (as opposed to a failure).
+ def test_run_call_order__error_in_test(self):
+ events = []
+ result = LoggingResult(events)
+
+ class Foo(Test.LoggingTestCase):
+ def test(self):
+ super(Foo, self).test()
+ raise RuntimeError('raised by Foo.test')
+
+ expected = ['startTest', 'setUp', 'test', 'tearDown',
+ 'addError', 'stopTest']
+ Foo(events).run(result)
+ self.assertEqual(events, expected)
+
+ # "With a default result, an error in the test still results in stopTestRun
+ # being called."
+ def test_run_call_order__error_in_test_default_result(self):
+ events = []
+
+ class Foo(Test.LoggingTestCase):
+ def defaultTestResult(self):
+ return LoggingResult(self.events)
+
+ def test(self):
+ super(Foo, self).test()
+ raise RuntimeError('raised by Foo.test')
+
+ expected = ['startTestRun', 'startTest', 'setUp', 'test',
+ 'tearDown', 'addError', 'stopTest', 'stopTestRun']
+ Foo(events).run()
+ self.assertEqual(events, expected)
+
+ # "When a setUp() method is defined, the test runner will run that method
+ # prior to each test. Likewise, if a tearDown() method is defined, the
+ # test runner will invoke that method after each test. In the example,
+ # setUp() was used to create a fresh sequence for each test."
+ #
+ # Make sure the proper call order is maintained, even if the test signals
+ # a failure (as opposed to an error).
+ def test_run_call_order__failure_in_test(self):
+ events = []
+ result = LoggingResult(events)
+
+ class Foo(Test.LoggingTestCase):
+ def test(self):
+ super(Foo, self).test()
+ self.fail('raised by Foo.test')
+
+ expected = ['startTest', 'setUp', 'test', 'tearDown',
+ 'addFailure', 'stopTest']
+ Foo(events).run(result)
+ self.assertEqual(events, expected)
+
+ # "When a test fails with a default result stopTestRun is still called."
+ def test_run_call_order__failure_in_test_default_result(self):
+
+ class Foo(Test.LoggingTestCase):
+ def defaultTestResult(self):
+ return LoggingResult(self.events)
+ def test(self):
+ super(Foo, self).test()
+ self.fail('raised by Foo.test')
+
+ expected = ['startTestRun', 'startTest', 'setUp', 'test',
+ 'tearDown', 'addFailure', 'stopTest', 'stopTestRun']
+ events = []
+ Foo(events).run()
+ self.assertEqual(events, expected)
+
+ # "When a setUp() method is defined, the test runner will run that method
+ # prior to each test. Likewise, if a tearDown() method is defined, the
+ # test runner will invoke that method after each test. In the example,
+ # setUp() was used to create a fresh sequence for each test."
+ #
+ # Make sure the proper call order is maintained, even if tearDown() raises
+ # an exception.
+ def test_run_call_order__error_in_tearDown(self):
+ events = []
+ result = LoggingResult(events)
+
+ class Foo(Test.LoggingTestCase):
+ def tearDown(self):
+ super(Foo, self).tearDown()
+ raise RuntimeError('raised by Foo.tearDown')
+
+ Foo(events).run(result)
+ expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
+ 'stopTest']
+ self.assertEqual(events, expected)
+
+ # "When tearDown errors with a default result stopTestRun is still called."
+ def test_run_call_order__error_in_tearDown_default_result(self):
+
+ class Foo(Test.LoggingTestCase):
+ def defaultTestResult(self):
+ return LoggingResult(self.events)
+ def tearDown(self):
+ super(Foo, self).tearDown()
+ raise RuntimeError('raised by Foo.tearDown')
+
+ events = []
+ Foo(events).run()
+ expected = ['startTestRun', 'startTest', 'setUp', 'test', 'tearDown',
+ 'addError', 'stopTest', 'stopTestRun']
+ self.assertEqual(events, expected)
+
+ # "TestCase.run() still works when the defaultTestResult is a TestResult
+ # that does not support startTestRun and stopTestRun.
+ def test_run_call_order_default_result(self):
+
+ class Foo(unittest.TestCase):
+ def defaultTestResult(self):
+ return ResultWithNoStartTestRunStopTestRun()
+ def test(self):
+ pass
+
+ Foo('test').run()
+
+ # "This class attribute gives the exception raised by the test() method.
+ # If a test framework needs to use a specialized exception, possibly to
+ # carry additional information, it must subclass this exception in
+ # order to ``play fair'' with the framework. The initial value of this
+ # attribute is AssertionError"
+ def test_failureException__default(self):
+ class Foo(unittest.TestCase):
+ def test(self):
+ pass
+
+ self.assertTrue(Foo('test').failureException is AssertionError)
+
+ # "This class attribute gives the exception raised by the test() method.
+ # If a test framework needs to use a specialized exception, possibly to
+ # carry additional information, it must subclass this exception in
+ # order to ``play fair'' with the framework."
+ #
+ # Make sure TestCase.run() respects the designated failureException
+ def test_failureException__subclassing__explicit_raise(self):
+ events = []
+ result = LoggingResult(events)
+
+ class Foo(unittest.TestCase):
+ def test(self):
+ raise RuntimeError()
+
+ failureException = RuntimeError
+
+ self.assertTrue(Foo('test').failureException is RuntimeError)
+
+
+ Foo('test').run(result)
+ expected = ['startTest', 'addFailure', 'stopTest']
+ self.assertEqual(events, expected)
+
+ # "This class attribute gives the exception raised by the test() method.
+ # If a test framework needs to use a specialized exception, possibly to
+ # carry additional information, it must subclass this exception in
+ # order to ``play fair'' with the framework."
+ #
+ # Make sure TestCase.run() respects the designated failureException
+ def test_failureException__subclassing__implicit_raise(self):
+ events = []
+ result = LoggingResult(events)
+
+ class Foo(unittest.TestCase):
+ def test(self):
+ self.fail("foo")
+
+ failureException = RuntimeError
+
+ self.assertTrue(Foo('test').failureException is RuntimeError)
+
+
+ Foo('test').run(result)
+ expected = ['startTest', 'addFailure', 'stopTest']
+ self.assertEqual(events, expected)
+
+ # "The default implementation does nothing."
+ def test_setUp(self):
+ class Foo(unittest.TestCase):
+ def runTest(self):
+ pass
+
+ # ... and nothing should happen
+ Foo().setUp()
+
+ # "The default implementation does nothing."
+ def test_tearDown(self):
+ class Foo(unittest.TestCase):
+ def runTest(self):
+ pass
+
+ # ... and nothing should happen
+ Foo().tearDown()
+
+ # "Return a string identifying the specific test case."
+ #
+ # Because of the vague nature of the docs, I'm not going to lock this
+ # test down too much. Really all that can be asserted is that the id()
+ # will be a string (either 8-byte or unicode -- again, because the docs
+ # just say "string")
+ def test_id(self):
+ class Foo(unittest.TestCase):
+ def runTest(self):
+ pass
+
+ self.assertIsInstance(Foo().id(), str)
+
+
+ # "If result is omitted or None, a temporary result object is created
+ # and used, but is not made available to the caller. As TestCase owns the
+ # temporary result startTestRun and stopTestRun are called.
+
+ def test_run__uses_defaultTestResult(self):
+ events = []
+
+ class Foo(unittest.TestCase):
+ def test(self):
+ events.append('test')
+
+ def defaultTestResult(self):
+ return LoggingResult(events)
+
+ # Make run() find a result object on its own
+ Foo('test').run()
+
+ expected = ['startTestRun', 'startTest', 'test', 'addSuccess',
+ 'stopTest', 'stopTestRun']
+ self.assertEqual(events, expected)
+
+ def testShortDescriptionWithoutDocstring(self):
+ self.assertIsNone(self.shortDescription())
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def testShortDescriptionWithOneLineDocstring(self):
+ """Tests shortDescription() for a method with a docstring."""
+ self.assertEqual(
+ self.shortDescription(),
+ 'Tests shortDescription() for a method with a docstring.')
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def testShortDescriptionWithMultiLineDocstring(self):
+ """Tests shortDescription() for a method with a longer docstring.
+
+ This method ensures that only the first line of a docstring is
+ returned used in the short description, no matter how long the
+ whole thing is.
+ """
+ self.assertEqual(
+ self.shortDescription(),
+ 'Tests shortDescription() for a method with a longer '
+ 'docstring.')
+
+ def testAddTypeEqualityFunc(self):
+ class SadSnake(object):
+ """Dummy class for test_addTypeEqualityFunc."""
+ s1, s2 = SadSnake(), SadSnake()
+ self.assertFalse(s1 == s2)
+ def AllSnakesCreatedEqual(a, b, msg=None):
+ return type(a) == type(b) == SadSnake
+ self.addTypeEqualityFunc(SadSnake, AllSnakesCreatedEqual)
+ self.assertEqual(s1, s2)
+ # No this doesn't clean up and remove the SadSnake equality func
+ # from this TestCase instance but since its a local nothing else
+ # will ever notice that.
+
+ def testAssertIs(self):
+ thing = object()
+ self.assertIs(thing, thing)
+ self.assertRaises(self.failureException, self.assertIs, thing, object())
+
+ def testAssertIsNot(self):
+ thing = object()
+ self.assertIsNot(thing, object())
+ self.assertRaises(self.failureException, self.assertIsNot, thing, thing)
+
+ def testAssertIsInstance(self):
+ thing = []
+ self.assertIsInstance(thing, list)
+ self.assertRaises(self.failureException, self.assertIsInstance,
+ thing, dict)
+
+ def testAssertNotIsInstance(self):
+ thing = []
+ self.assertNotIsInstance(thing, dict)
+ self.assertRaises(self.failureException, self.assertNotIsInstance,
+ thing, list)
+
+ def testAssertIn(self):
+ animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'}
+
+ self.assertIn('a', 'abc')
+ self.assertIn(2, [1, 2, 3])
+ self.assertIn('monkey', animals)
+
+ self.assertNotIn('d', 'abc')
+ self.assertNotIn(0, [1, 2, 3])
+ self.assertNotIn('otter', animals)
+
+ self.assertRaises(self.failureException, self.assertIn, 'x', 'abc')
+ self.assertRaises(self.failureException, self.assertIn, 4, [1, 2, 3])
+ self.assertRaises(self.failureException, self.assertIn, 'elephant',
+ animals)
+
+ self.assertRaises(self.failureException, self.assertNotIn, 'c', 'abc')
+ self.assertRaises(self.failureException, self.assertNotIn, 1, [1, 2, 3])
+ self.assertRaises(self.failureException, self.assertNotIn, 'cow',
+ animals)
+
+ def testAssertDictContainsSubset(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+
+ self.assertDictContainsSubset({}, {})
+ self.assertDictContainsSubset({}, {'a': 1})
+ self.assertDictContainsSubset({'a': 1}, {'a': 1})
+ self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
+ self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})
+
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({1: "one"}, {})
+
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'a': 2}, {'a': 1})
+
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'c': 1}, {'a': 1})
+
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
+
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
+
+ one = ''.join(chr(i) for i in range(255))
+ # this used to cause a UnicodeDecodeError constructing the failure msg
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'foo': one}, {'foo': '\uFFFD'})
+
+ def testAssertEqual(self):
+ equal_pairs = [
+ ((), ()),
+ ({}, {}),
+ ([], []),
+ (set(), set()),
+ (frozenset(), frozenset())]
+ for a, b in equal_pairs:
+ # This mess of try excepts is to test the assertEqual behavior
+ # itself.
+ try:
+ self.assertEqual(a, b)
+ except self.failureException:
+ self.fail('assertEqual(%r, %r) failed' % (a, b))
+ try:
+ self.assertEqual(a, b, msg='foo')
+ except self.failureException:
+ self.fail('assertEqual(%r, %r) with msg= failed' % (a, b))
+ try:
+ self.assertEqual(a, b, 'foo')
+ except self.failureException:
+ self.fail('assertEqual(%r, %r) with third parameter failed' %
+ (a, b))
+
+ unequal_pairs = [
+ ((), []),
+ ({}, set()),
+ (set([4,1]), frozenset([4,2])),
+ (frozenset([4,5]), set([2,3])),
+ (set([3,4]), set([5,4]))]
+ for a, b in unequal_pairs:
+ self.assertRaises(self.failureException, self.assertEqual, a, b)
+ self.assertRaises(self.failureException, self.assertEqual, a, b,
+ 'foo')
+ self.assertRaises(self.failureException, self.assertEqual, a, b,
+ msg='foo')
+
+ def testEquality(self):
+ self.assertListEqual([], [])
+ self.assertTupleEqual((), ())
+ self.assertSequenceEqual([], ())
+
+ a = [0, 'a', []]
+ b = []
+ self.assertRaises(unittest.TestCase.failureException,
+ self.assertListEqual, a, b)
+ self.assertRaises(unittest.TestCase.failureException,
+ self.assertListEqual, tuple(a), tuple(b))
+ self.assertRaises(unittest.TestCase.failureException,
+ self.assertSequenceEqual, a, tuple(b))
+
+ b.extend(a)
+ self.assertListEqual(a, b)
+ self.assertTupleEqual(tuple(a), tuple(b))
+ self.assertSequenceEqual(a, tuple(b))
+ self.assertSequenceEqual(tuple(a), b)
+
+ self.assertRaises(self.failureException, self.assertListEqual,
+ a, tuple(b))
+ self.assertRaises(self.failureException, self.assertTupleEqual,
+ tuple(a), b)
+ self.assertRaises(self.failureException, self.assertListEqual, None, b)
+ self.assertRaises(self.failureException, self.assertTupleEqual, None,
+ tuple(b))
+ self.assertRaises(self.failureException, self.assertSequenceEqual,
+ None, tuple(b))
+ self.assertRaises(self.failureException, self.assertListEqual, 1, 1)
+ self.assertRaises(self.failureException, self.assertTupleEqual, 1, 1)
+ self.assertRaises(self.failureException, self.assertSequenceEqual,
+ 1, 1)
+
+ self.assertDictEqual({}, {})
+
+ c = { 'x': 1 }
+ d = {}
+ self.assertRaises(unittest.TestCase.failureException,
+ self.assertDictEqual, c, d)
+
+ d.update(c)
+ self.assertDictEqual(c, d)
+
+ d['x'] = 0
+ self.assertRaises(unittest.TestCase.failureException,
+ self.assertDictEqual, c, d, 'These are unequal')
+
+ self.assertRaises(self.failureException, self.assertDictEqual, None, d)
+ self.assertRaises(self.failureException, self.assertDictEqual, [], d)
+ self.assertRaises(self.failureException, self.assertDictEqual, 1, 1)
+
+ def testAssertSequenceEqualMaxDiff(self):
+ self.assertEqual(self.maxDiff, 80*8)
+ seq1 = 'a' + 'x' * 80**2
+ seq2 = 'b' + 'x' * 80**2
+ diff = '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(),
+ pprint.pformat(seq2).splitlines()))
+ # the +1 is the leading \n added by assertSequenceEqual
+ omitted = unittest.case.DIFF_OMITTED % (len(diff) + 1,)
+
+ self.maxDiff = len(diff)//2
+ try:
+
+ self.assertSequenceEqual(seq1, seq2)
+ except self.failureException as e:
+ msg = e.args[0]
+ else:
+ self.fail('assertSequenceEqual did not fail.')
+ self.assertTrue(len(msg) < len(diff))
+ self.assertIn(omitted, msg)
+
+ self.maxDiff = len(diff) * 2
+ try:
+ self.assertSequenceEqual(seq1, seq2)
+ except self.failureException as e:
+ msg = e.args[0]
+ else:
+ self.fail('assertSequenceEqual did not fail.')
+ self.assertTrue(len(msg) > len(diff))
+ self.assertNotIn(omitted, msg)
+
+ self.maxDiff = None
+ try:
+ self.assertSequenceEqual(seq1, seq2)
+ except self.failureException as e:
+ msg = e.args[0]
+ else:
+ self.fail('assertSequenceEqual did not fail.')
+ self.assertTrue(len(msg) > len(diff))
+ self.assertNotIn(omitted, msg)
+
+ def testTruncateMessage(self):
+ self.maxDiff = 1
+ message = self._truncateMessage('foo', 'bar')
+ omitted = unittest.case.DIFF_OMITTED % len('bar')
+ self.assertEqual(message, 'foo' + omitted)
+
+ self.maxDiff = None
+ message = self._truncateMessage('foo', 'bar')
+ self.assertEqual(message, 'foobar')
+
+ self.maxDiff = 4
+ message = self._truncateMessage('foo', 'bar')
+ self.assertEqual(message, 'foobar')
+
+ def testAssertDictEqualTruncates(self):
+ test = unittest.TestCase('assertEqual')
+ def truncate(msg, diff):
+ return 'foo'
+ test._truncateMessage = truncate
+ try:
+ test.assertDictEqual({}, {1: 0})
+ except self.failureException as e:
+ self.assertEqual(str(e), 'foo')
+ else:
+ self.fail('assertDictEqual did not fail')
+
+ def testAssertMultiLineEqualTruncates(self):
+ test = unittest.TestCase('assertEqual')
+ def truncate(msg, diff):
+ return 'foo'
+ test._truncateMessage = truncate
+ try:
+ test.assertMultiLineEqual('foo', 'bar')
+ except self.failureException as e:
+ self.assertEqual(str(e), 'foo')
+ else:
+ self.fail('assertMultiLineEqual did not fail')
+
+ def testAssertCountEqual(self):
+ a = object()
+ self.assertCountEqual([1, 2, 3], [3, 2, 1])
+ self.assertCountEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
+ self.assertCountEqual([a, a, 2, 2, 3], (a, 2, 3, a, 2))
+ self.assertCountEqual([1, "2", "a", "a"], ["a", "2", True, "a"])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [1, 2] + [3] * 100, [1] * 100 + [2, 3])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [1, "2", "a", "a"], ["a", "2", True, 1])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [10], [10, 11])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [10, 11], [10])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [10, 11, 10], [10, 11])
+
+ # Test that sequences of unhashable objects can be tested for sameness:
+ self.assertCountEqual([[1, 2], [3, 4], 0], [False, [3, 4], [1, 2]])
+ # Test that iterator of unhashable objects can be tested for sameness:
+ self.assertCountEqual(iter([1, 2, [], 3, 4]),
+ iter([1, 2, [], 3, 4]))
+
+ # hashable types, but not orderable
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [], [divmod, 'x', 1, 5j, 2j, frozenset()])
+ # comparing dicts
+ self.assertCountEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
+ # comparing heterogenous non-hashable sequences
+ self.assertCountEqual([1, 'x', divmod, []], [divmod, [], 'x', 1])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [], [divmod, [], 'x', 1, 5j, 2j, set()])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [[1]], [[2]])
+
+ # Same elements, but not same sequence length
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [1, 1, 2], [2, 1])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [1, 1, "2", "a", "a"], ["2", "2", True, "a"])
+ self.assertRaises(self.failureException, self.assertCountEqual,
+ [1, {'b': 2}, None, True], [{'b': 2}, True, None])
+
+ # Same elements which don't reliably compare, in
+ # different order, see issue 10242
+ a = [{2,4}, {1,2}]
+ b = a[::-1]
+ self.assertCountEqual(a, b)
+
+ # test utility functions supporting assertCountEqual()
+
+ diffs = set(unittest.util._count_diff_all_purpose('aaabccd', 'abbbcce'))
+ expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
+ self.assertEqual(diffs, expected)
+
+ diffs = unittest.util._count_diff_all_purpose([[]], [])
+ self.assertEqual(diffs, [(1, 0, [])])
+
+ diffs = set(unittest.util._count_diff_hashable('aaabccd', 'abbbcce'))
+ expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
+ self.assertEqual(diffs, expected)
+
+ def testAssertSetEqual(self):
+ set1 = set()
+ set2 = set()
+ self.assertSetEqual(set1, set2)
+
+ self.assertRaises(self.failureException, self.assertSetEqual, None, set2)
+ self.assertRaises(self.failureException, self.assertSetEqual, [], set2)
+ self.assertRaises(self.failureException, self.assertSetEqual, set1, None)
+ self.assertRaises(self.failureException, self.assertSetEqual, set1, [])
+
+ set1 = set(['a'])
+ set2 = set()
+ self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+ set1 = set(['a'])
+ set2 = set(['a'])
+ self.assertSetEqual(set1, set2)
+
+ set1 = set(['a'])
+ set2 = set(['a', 'b'])
+ self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+ set1 = set(['a'])
+ set2 = frozenset(['a', 'b'])
+ self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+ set1 = set(['a', 'b'])
+ set2 = frozenset(['a', 'b'])
+ self.assertSetEqual(set1, set2)
+
+ set1 = set()
+ set2 = "foo"
+ self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+ self.assertRaises(self.failureException, self.assertSetEqual, set2, set1)
+
+ # make sure any string formatting is tuple-safe
+ set1 = set([(0, 1), (2, 3)])
+ set2 = set([(4, 5)])
+ self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+ def testInequality(self):
+ # Try ints
+ self.assertGreater(2, 1)
+ self.assertGreaterEqual(2, 1)
+ self.assertGreaterEqual(1, 1)
+ self.assertLess(1, 2)
+ self.assertLessEqual(1, 2)
+ self.assertLessEqual(1, 1)
+ self.assertRaises(self.failureException, self.assertGreater, 1, 2)
+ self.assertRaises(self.failureException, self.assertGreater, 1, 1)
+ self.assertRaises(self.failureException, self.assertGreaterEqual, 1, 2)
+ self.assertRaises(self.failureException, self.assertLess, 2, 1)
+ self.assertRaises(self.failureException, self.assertLess, 1, 1)
+ self.assertRaises(self.failureException, self.assertLessEqual, 2, 1)
+
+ # Try Floats
+ self.assertGreater(1.1, 1.0)
+ self.assertGreaterEqual(1.1, 1.0)
+ self.assertGreaterEqual(1.0, 1.0)
+ self.assertLess(1.0, 1.1)
+ self.assertLessEqual(1.0, 1.1)
+ self.assertLessEqual(1.0, 1.0)
+ self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.1)
+ self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.0)
+ self.assertRaises(self.failureException, self.assertGreaterEqual, 1.0, 1.1)
+ self.assertRaises(self.failureException, self.assertLess, 1.1, 1.0)
+ self.assertRaises(self.failureException, self.assertLess, 1.0, 1.0)
+ self.assertRaises(self.failureException, self.assertLessEqual, 1.1, 1.0)
+
+ # Try Strings
+ self.assertGreater('bug', 'ant')
+ self.assertGreaterEqual('bug', 'ant')
+ self.assertGreaterEqual('ant', 'ant')
+ self.assertLess('ant', 'bug')
+ self.assertLessEqual('ant', 'bug')
+ self.assertLessEqual('ant', 'ant')
+ self.assertRaises(self.failureException, self.assertGreater, 'ant', 'bug')
+ self.assertRaises(self.failureException, self.assertGreater, 'ant', 'ant')
+ self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant', 'bug')
+ self.assertRaises(self.failureException, self.assertLess, 'bug', 'ant')
+ self.assertRaises(self.failureException, self.assertLess, 'ant', 'ant')
+ self.assertRaises(self.failureException, self.assertLessEqual, 'bug', 'ant')
+
+ # Try bytes
+ self.assertGreater(b'bug', b'ant')
+ self.assertGreaterEqual(b'bug', b'ant')
+ self.assertGreaterEqual(b'ant', b'ant')
+ self.assertLess(b'ant', b'bug')
+ self.assertLessEqual(b'ant', b'bug')
+ self.assertLessEqual(b'ant', b'ant')
+ self.assertRaises(self.failureException, self.assertGreater, b'ant', b'bug')
+ self.assertRaises(self.failureException, self.assertGreater, b'ant', b'ant')
+ self.assertRaises(self.failureException, self.assertGreaterEqual, b'ant',
+ b'bug')
+ self.assertRaises(self.failureException, self.assertLess, b'bug', b'ant')
+ self.assertRaises(self.failureException, self.assertLess, b'ant', b'ant')
+ self.assertRaises(self.failureException, self.assertLessEqual, b'bug', b'ant')
+
+ def testAssertMultiLineEqual(self):
+ sample_text = """\
+http://www.python.org/doc/2.3/lib/module-unittest.html
+test case
+ A test case is the smallest unit of testing. [...]
+"""
+ revised_sample_text = """\
+http://www.python.org/doc/2.4.1/lib/module-unittest.html
+test case
+ A test case is the smallest unit of testing. [...] You may provide your
+ own implementation that does not subclass from TestCase, of course.
+"""
+ sample_text_error = """\
+- http://www.python.org/doc/2.3/lib/module-unittest.html
+? ^
++ http://www.python.org/doc/2.4.1/lib/module-unittest.html
+? ^^^
+ test case
+- A test case is the smallest unit of testing. [...]
++ A test case is the smallest unit of testing. [...] You may provide your
+? +++++++++++++++++++++
++ own implementation that does not subclass from TestCase, of course.
+"""
+ self.maxDiff = None
+ try:
+ self.assertMultiLineEqual(sample_text, revised_sample_text)
+ except self.failureException as e:
+ # need to remove the first line of the error message
+ error = str(e).split('\n', 1)[1]
+
+ # no fair testing ourself with ourself, and assertEqual is used for strings
+ # so can't use assertEqual either. Just use assertTrue.
+ self.assertTrue(sample_text_error == error)
+
+ def testAsertEqualSingleLine(self):
+ sample_text = "laden swallows fly slowly"
+ revised_sample_text = "unladen swallows fly quickly"
+ sample_text_error = """\
+- laden swallows fly slowly
+? ^^^^
++ unladen swallows fly quickly
+? ++ ^^^^^
+"""
+ try:
+ self.assertEqual(sample_text, revised_sample_text)
+ except self.failureException as e:
+ error = str(e).split('\n', 1)[1]
+ self.assertTrue(sample_text_error == error)
+
+ def testAssertIsNone(self):
+ self.assertIsNone(None)
+ self.assertRaises(self.failureException, self.assertIsNone, False)
+ self.assertIsNotNone('DjZoPloGears on Rails')
+ self.assertRaises(self.failureException, self.assertIsNotNone, None)
+
+ def testAssertRegex(self):
+ self.assertRegex('asdfabasdf', r'ab+')
+ self.assertRaises(self.failureException, self.assertRegex,
+ 'saaas', r'aaaa')
+
+ def testAssertRaisesRegex(self):
+ class ExceptionMock(Exception):
+ pass
+
+ def Stub():
+ raise ExceptionMock('We expect')
+
+ self.assertRaisesRegex(ExceptionMock, re.compile('expect$'), Stub)
+ self.assertRaisesRegex(ExceptionMock, 'expect$', Stub)
+
+ def testAssertNotRaisesRegex(self):
+ self.assertRaisesRegex(
+ self.failureException, '^Exception not raised by <lambda>$',
+ self.assertRaisesRegex, Exception, re.compile('x'),
+ lambda: None)
+ self.assertRaisesRegex(
+ self.failureException, '^Exception not raised by <lambda>$',
+ self.assertRaisesRegex, Exception, 'x',
+ lambda: None)
+
+ def testAssertRaisesRegexMismatch(self):
+ def Stub():
+ raise Exception('Unexpected')
+
+ self.assertRaisesRegex(
+ self.failureException,
+ r'"\^Expected\$" does not match "Unexpected"',
+ self.assertRaisesRegex, Exception, '^Expected$',
+ Stub)
+ self.assertRaisesRegex(
+ self.failureException,
+ r'"\^Expected\$" does not match "Unexpected"',
+ self.assertRaisesRegex, Exception,
+ re.compile('^Expected$'), Stub)
+
+ def testAssertRaisesExcValue(self):
+ class ExceptionMock(Exception):
+ pass
+
+ def Stub(foo):
+ raise ExceptionMock(foo)
+ v = "particular value"
+
+ ctx = self.assertRaises(ExceptionMock)
+ with ctx:
+ Stub(v)
+ e = ctx.exception
+ self.assertIsInstance(e, ExceptionMock)
+ self.assertEqual(e.args[0], v)
+
+ def testAssertWarnsCallable(self):
+ def _runtime_warn():
+ warnings.warn("foo", RuntimeWarning)
+ # Success when the right warning is triggered, even several times
+ self.assertWarns(RuntimeWarning, _runtime_warn)
+ self.assertWarns(RuntimeWarning, _runtime_warn)
+ # A tuple of warning classes is accepted
+ self.assertWarns((DeprecationWarning, RuntimeWarning), _runtime_warn)
+ # *args and **kwargs also work
+ self.assertWarns(RuntimeWarning,
+ warnings.warn, "foo", category=RuntimeWarning)
+ # Failure when no warning is triggered
+ with self.assertRaises(self.failureException):
+ self.assertWarns(RuntimeWarning, lambda: 0)
+ # Failure when another warning is triggered
+ with warnings.catch_warnings():
+ # Force default filter (in case tests are run with -We)
+ warnings.simplefilter("default", RuntimeWarning)
+ with self.assertRaises(self.failureException):
+ self.assertWarns(DeprecationWarning, _runtime_warn)
+ # Filters for other warnings are not modified
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", RuntimeWarning)
+ with self.assertRaises(RuntimeWarning):
+ self.assertWarns(DeprecationWarning, _runtime_warn)
+
+ def testAssertWarnsContext(self):
+ # Believe it or not, it is preferrable to duplicate all tests above,
+ # to make sure the __warningregistry__ $@ is circumvented correctly.
+ def _runtime_warn():
+ warnings.warn("foo", RuntimeWarning)
+ _runtime_warn_lineno = inspect.getsourcelines(_runtime_warn)[1]
+ with self.assertWarns(RuntimeWarning) as cm:
+ _runtime_warn()
+ # A tuple of warning classes is accepted
+ with self.assertWarns((DeprecationWarning, RuntimeWarning)) as cm:
+ _runtime_warn()
+ # The context manager exposes various useful attributes
+ self.assertIsInstance(cm.warning, RuntimeWarning)
+ self.assertEqual(cm.warning.args[0], "foo")
+ self.assertIn("test_case.py", cm.filename)
+ self.assertEqual(cm.lineno, _runtime_warn_lineno + 1)
+ # Same with several warnings
+ with self.assertWarns(RuntimeWarning):
+ _runtime_warn()
+ _runtime_warn()
+ with self.assertWarns(RuntimeWarning):
+ warnings.warn("foo", category=RuntimeWarning)
+ # Failure when no warning is triggered
+ with self.assertRaises(self.failureException):
+ with self.assertWarns(RuntimeWarning):
+ pass
+ # Failure when another warning is triggered
+ with warnings.catch_warnings():
+ # Force default filter (in case tests are run with -We)
+ warnings.simplefilter("default", RuntimeWarning)
+ with self.assertRaises(self.failureException):
+ with self.assertWarns(DeprecationWarning):
+ _runtime_warn()
+ # Filters for other warnings are not modified
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", RuntimeWarning)
+ with self.assertRaises(RuntimeWarning):
+ with self.assertWarns(DeprecationWarning):
+ _runtime_warn()
+
+ def testAssertWarnsRegexCallable(self):
+ def _runtime_warn(msg):
+ warnings.warn(msg, RuntimeWarning)
+ self.assertWarnsRegex(RuntimeWarning, "o+",
+ _runtime_warn, "foox")
+ # Failure when no warning is triggered
+ with self.assertRaises(self.failureException):
+ self.assertWarnsRegex(RuntimeWarning, "o+",
+ lambda: 0)
+ # Failure when another warning is triggered
+ with warnings.catch_warnings():
+ # Force default filter (in case tests are run with -We)
+ warnings.simplefilter("default", RuntimeWarning)
+ with self.assertRaises(self.failureException):
+ self.assertWarnsRegex(DeprecationWarning, "o+",
+ _runtime_warn, "foox")
+ # Failure when message doesn't match
+ with self.assertRaises(self.failureException):
+ self.assertWarnsRegex(RuntimeWarning, "o+",
+ _runtime_warn, "barz")
+ # A little trickier: we ask RuntimeWarnings to be raised, and then
+ # check for some of them. It is implementation-defined whether
+ # non-matching RuntimeWarnings are simply re-raised, or produce a
+ # failureException.
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", RuntimeWarning)
+ with self.assertRaises((RuntimeWarning, self.failureException)):
+ self.assertWarnsRegex(RuntimeWarning, "o+",
+ _runtime_warn, "barz")
+
+ def testAssertWarnsRegexContext(self):
+ # Same as above, but with assertWarnsRegex as a context manager
+ def _runtime_warn(msg):
+ warnings.warn(msg, RuntimeWarning)
+ _runtime_warn_lineno = inspect.getsourcelines(_runtime_warn)[1]
+ with self.assertWarnsRegex(RuntimeWarning, "o+") as cm:
+ _runtime_warn("foox")
+ self.assertIsInstance(cm.warning, RuntimeWarning)
+ self.assertEqual(cm.warning.args[0], "foox")
+ self.assertIn("test_case.py", cm.filename)
+ self.assertEqual(cm.lineno, _runtime_warn_lineno + 1)
+ # Failure when no warning is triggered
+ with self.assertRaises(self.failureException):
+ with self.assertWarnsRegex(RuntimeWarning, "o+"):
+ pass
+ # Failure when another warning is triggered
+ with warnings.catch_warnings():
+ # Force default filter (in case tests are run with -We)
+ warnings.simplefilter("default", RuntimeWarning)
+ with self.assertRaises(self.failureException):
+ with self.assertWarnsRegex(DeprecationWarning, "o+"):
+ _runtime_warn("foox")
+ # Failure when message doesn't match
+ with self.assertRaises(self.failureException):
+ with self.assertWarnsRegex(RuntimeWarning, "o+"):
+ _runtime_warn("barz")
+ # A little trickier: we ask RuntimeWarnings to be raised, and then
+ # check for some of them. It is implementation-defined whether
+ # non-matching RuntimeWarnings are simply re-raised, or produce a
+ # failureException.
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", RuntimeWarning)
+ with self.assertRaises((RuntimeWarning, self.failureException)):
+ with self.assertWarnsRegex(RuntimeWarning, "o+"):
+ _runtime_warn("barz")
+
+ def testDeprecatedMethodNames(self):
+ """Test that the deprecated methods raise a DeprecationWarning.
+
+ The fail* methods will be removed in 3.3. The assert* methods will
+ have to stay around for a few more versions. See #9424.
+ """
+ old = (
+ (self.failIfEqual, (3, 5)),
+ (self.assertNotEquals, (3, 5)),
+ (self.failUnlessEqual, (3, 3)),
+ (self.assertEquals, (3, 3)),
+ (self.failUnlessAlmostEqual, (2.0, 2.0)),
+ (self.assertAlmostEquals, (2.0, 2.0)),
+ (self.failIfAlmostEqual, (3.0, 5.0)),
+ (self.assertNotAlmostEquals, (3.0, 5.0)),
+ (self.failUnless, (True,)),
+ (self.assert_, (True,)),
+ (self.failUnlessRaises, (TypeError, lambda _: 3.14 + 'spam')),
+ (self.failIf, (False,)),
+ (self.assertSameElements, ([1, 1, 2, 3], [1, 2, 3])),
+ (self.assertDictContainsSubset, (dict(a=1, b=2), dict(a=1, b=2, c=3))),
+ (self.assertRaisesRegexp, (KeyError, 'foo', lambda: {}['foo'])),
+ (self.assertRegexpMatches, ('bar', 'bar')),
+ )
+ for meth, args in old:
+ with self.assertWarns(DeprecationWarning):
+ meth(*args)
+
+ def testDeprecatedFailMethods(self):
+ """Test that the deprecated fail* methods get removed in 3.3"""
+ if sys.version_info[:2] < (3, 3):
+ return
+ deprecated_names = [
+ 'failIfEqual', 'failUnlessEqual', 'failUnlessAlmostEqual',
+ 'failIfAlmostEqual', 'failUnless', 'failUnlessRaises', 'failIf',
+ 'assertSameElements', 'assertDictContainsSubset',
+ ]
+ for deprecated_name in deprecated_names:
+ with self.assertRaises(AttributeError):
+ getattr(self, deprecated_name) # remove these in 3.3
+
+ def testDeepcopy(self):
+ # Issue: 5660
+ class TestableTest(unittest.TestCase):
+ def testNothing(self):
+ pass
+
+ test = TestableTest('testNothing')
+
+ # This shouldn't blow up
+ deepcopy(test)
+
+ def testPickle(self):
+ # Issue 10326
+
+ # Can't use TestCase classes defined in Test class as
+ # pickle does not work with inner classes
+ test = unittest.TestCase('run')
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
+
+ # blew up prior to fix
+ pickled_test = pickle.dumps(test, protocol=protocol)
+ unpickled_test = pickle.loads(pickled_test)
+ self.assertEqual(test, unpickled_test)
+
+ # exercise the TestCase instance in a way that will invoke
+ # the type equality lookup mechanism
+ unpickled_test.assertEqual(set(), set())
+
+ def testKeyboardInterrupt(self):
+ def _raise(self=None):
+ raise KeyboardInterrupt
+ def nothing(self):
+ pass
+
+ class Test1(unittest.TestCase):
+ test_something = _raise
+
+ class Test2(unittest.TestCase):
+ setUp = _raise
+ test_something = nothing
+
+ class Test3(unittest.TestCase):
+ test_something = nothing
+ tearDown = _raise
+
+ class Test4(unittest.TestCase):
+ def test_something(self):
+ self.addCleanup(_raise)
+
+ for klass in (Test1, Test2, Test3, Test4):
+ with self.assertRaises(KeyboardInterrupt):
+ klass('test_something').run()
+
+ def testSkippingEverywhere(self):
+ def _skip(self=None):
+ raise unittest.SkipTest('some reason')
+ def nothing(self):
+ pass
+
+ class Test1(unittest.TestCase):
+ test_something = _skip
+
+ class Test2(unittest.TestCase):
+ setUp = _skip
+ test_something = nothing
+
+ class Test3(unittest.TestCase):
+ test_something = nothing
+ tearDown = _skip
+
+ class Test4(unittest.TestCase):
+ def test_something(self):
+ self.addCleanup(_skip)
+
+ for klass in (Test1, Test2, Test3, Test4):
+ result = unittest.TestResult()
+ klass('test_something').run(result)
+ self.assertEqual(len(result.skipped), 1)
+ self.assertEqual(result.testsRun, 1)
+
+ def testSystemExit(self):
+ def _raise(self=None):
+ raise SystemExit
+ def nothing(self):
+ pass
+
+ class Test1(unittest.TestCase):
+ test_something = _raise
+
+ class Test2(unittest.TestCase):
+ setUp = _raise
+ test_something = nothing
+
+ class Test3(unittest.TestCase):
+ test_something = nothing
+ tearDown = _raise
+
+ class Test4(unittest.TestCase):
+ def test_something(self):
+ self.addCleanup(_raise)
+
+ for klass in (Test1, Test2, Test3, Test4):
+ result = unittest.TestResult()
+ klass('test_something').run(result)
+ self.assertEqual(len(result.errors), 1)
+ self.assertEqual(result.testsRun, 1)
diff --git a/Lib/unittest/test/test_discovery.py b/Lib/unittest/test/test_discovery.py
new file mode 100644
index 0000000000..e688f8e35a
--- /dev/null
+++ b/Lib/unittest/test/test_discovery.py
@@ -0,0 +1,395 @@
+import os
+import re
+import sys
+
+import unittest
+
+
+class TestableTestProgram(unittest.TestProgram):
+ module = '__main__'
+ exit = True
+ defaultTest = failfast = catchbreak = buffer = None
+ verbosity = 1
+ progName = ''
+ testRunner = testLoader = None
+
+ def __init__(self):
+ pass
+
+
+class TestDiscovery(unittest.TestCase):
+
+ # Heavily mocked tests so I can avoid hitting the filesystem
+ def test_get_name_from_path(self):
+ loader = unittest.TestLoader()
+ loader._top_level_dir = '/foo'
+ name = loader._get_name_from_path('/foo/bar/baz.py')
+ self.assertEqual(name, 'bar.baz')
+
+ if not __debug__:
+ # asserts are off
+ return
+
+ with self.assertRaises(AssertionError):
+ loader._get_name_from_path('/bar/baz.py')
+
+ def test_find_tests(self):
+ loader = unittest.TestLoader()
+
+ original_listdir = os.listdir
+ def restore_listdir():
+ os.listdir = original_listdir
+ original_isfile = os.path.isfile
+ def restore_isfile():
+ os.path.isfile = original_isfile
+ original_isdir = os.path.isdir
+ def restore_isdir():
+ os.path.isdir = original_isdir
+
+ path_lists = [['test1.py', 'test2.py', 'not_a_test.py', 'test_dir',
+ 'test.foo', 'test-not-a-module.py', 'another_dir'],
+ ['test3.py', 'test4.py', ]]
+ os.listdir = lambda path: path_lists.pop(0)
+ self.addCleanup(restore_listdir)
+
+ def isdir(path):
+ return path.endswith('dir')
+ os.path.isdir = isdir
+ self.addCleanup(restore_isdir)
+
+ def isfile(path):
+ # another_dir is not a package and so shouldn't be recursed into
+ return not path.endswith('dir') and not 'another_dir' in path
+ os.path.isfile = isfile
+ self.addCleanup(restore_isfile)
+
+ loader._get_module_from_name = lambda path: path + ' module'
+ loader.loadTestsFromModule = lambda module: module + ' tests'
+
+ top_level = os.path.abspath('/foo')
+ loader._top_level_dir = top_level
+ suite = list(loader._find_tests(top_level, 'test*.py'))
+
+ expected = [name + ' module tests' for name in
+ ('test1', 'test2')]
+ expected.extend([('test_dir.%s' % name) + ' module tests' for name in
+ ('test3', 'test4')])
+ self.assertEqual(suite, expected)
+
+ def test_find_tests_with_package(self):
+ loader = unittest.TestLoader()
+
+ original_listdir = os.listdir
+ def restore_listdir():
+ os.listdir = original_listdir
+ original_isfile = os.path.isfile
+ def restore_isfile():
+ os.path.isfile = original_isfile
+ original_isdir = os.path.isdir
+ def restore_isdir():
+ os.path.isdir = original_isdir
+
+ directories = ['a_directory', 'test_directory', 'test_directory2']
+ path_lists = [directories, [], [], []]
+ os.listdir = lambda path: path_lists.pop(0)
+ self.addCleanup(restore_listdir)
+
+ os.path.isdir = lambda path: True
+ self.addCleanup(restore_isdir)
+
+ os.path.isfile = lambda path: os.path.basename(path) not in directories
+ self.addCleanup(restore_isfile)
+
+ class Module(object):
+ paths = []
+ load_tests_args = []
+
+ def __init__(self, path):
+ self.path = path
+ self.paths.append(path)
+ if os.path.basename(path) == 'test_directory':
+ def load_tests(loader, tests, pattern):
+ self.load_tests_args.append((loader, tests, pattern))
+ return 'load_tests'
+ self.load_tests = load_tests
+
+ def __eq__(self, other):
+ return self.path == other.path
+
+ loader._get_module_from_name = lambda name: Module(name)
+ def loadTestsFromModule(module, use_load_tests):
+ if use_load_tests:
+ raise self.failureException('use_load_tests should be False for packages')
+ return module.path + ' module tests'
+ loader.loadTestsFromModule = loadTestsFromModule
+
+ loader._top_level_dir = '/foo'
+ # this time no '.py' on the pattern so that it can match
+ # a test package
+ suite = list(loader._find_tests('/foo', 'test*'))
+
+ # We should have loaded tests from the test_directory package by calling load_tests
+ # and directly from the test_directory2 package
+ self.assertEqual(suite,
+ ['load_tests', 'test_directory2' + ' module tests'])
+ self.assertEqual(Module.paths, ['test_directory', 'test_directory2'])
+
+ # load_tests should have been called once with loader, tests and pattern
+ self.assertEqual(Module.load_tests_args,
+ [(loader, 'test_directory' + ' module tests', 'test*')])
+
+ def test_discover(self):
+ loader = unittest.TestLoader()
+
+ original_isfile = os.path.isfile
+ original_isdir = os.path.isdir
+ def restore_isfile():
+ os.path.isfile = original_isfile
+
+ os.path.isfile = lambda path: False
+ self.addCleanup(restore_isfile)
+
+ orig_sys_path = sys.path[:]
+ def restore_path():
+ sys.path[:] = orig_sys_path
+ self.addCleanup(restore_path)
+
+ full_path = os.path.abspath(os.path.normpath('/foo'))
+ with self.assertRaises(ImportError):
+ loader.discover('/foo/bar', top_level_dir='/foo')
+
+ self.assertEqual(loader._top_level_dir, full_path)
+ self.assertIn(full_path, sys.path)
+
+ os.path.isfile = lambda path: True
+ os.path.isdir = lambda path: True
+
+ def restore_isdir():
+ os.path.isdir = original_isdir
+ self.addCleanup(restore_isdir)
+
+ _find_tests_args = []
+ def _find_tests(start_dir, pattern):
+ _find_tests_args.append((start_dir, pattern))
+ return ['tests']
+ loader._find_tests = _find_tests
+ loader.suiteClass = str
+
+ suite = loader.discover('/foo/bar/baz', 'pattern', '/foo/bar')
+
+ top_level_dir = os.path.abspath('/foo/bar')
+ start_dir = os.path.abspath('/foo/bar/baz')
+ self.assertEqual(suite, "['tests']")
+ self.assertEqual(loader._top_level_dir, top_level_dir)
+ self.assertEqual(_find_tests_args, [(start_dir, 'pattern')])
+ self.assertIn(top_level_dir, sys.path)
+
+ def test_discover_with_modules_that_fail_to_import(self):
+ loader = unittest.TestLoader()
+
+ listdir = os.listdir
+ os.listdir = lambda _: ['test_this_does_not_exist.py']
+ isfile = os.path.isfile
+ os.path.isfile = lambda _: True
+ orig_sys_path = sys.path[:]
+ def restore():
+ os.path.isfile = isfile
+ os.listdir = listdir
+ sys.path[:] = orig_sys_path
+ self.addCleanup(restore)
+
+ suite = loader.discover('.')
+ self.assertIn(os.getcwd(), sys.path)
+ self.assertEqual(suite.countTestCases(), 1)
+ test = list(list(suite)[0])[0] # extract test from suite
+
+ with self.assertRaises(ImportError):
+ test.test_this_does_not_exist()
+
+ def test_command_line_handling_parseArgs(self):
+ program = TestableTestProgram()
+
+ args = []
+ def do_discovery(argv):
+ args.extend(argv)
+ program._do_discovery = do_discovery
+ program.parseArgs(['something', 'discover'])
+ self.assertEqual(args, [])
+
+ program.parseArgs(['something', 'discover', 'foo', 'bar'])
+ self.assertEqual(args, ['foo', 'bar'])
+
+ def test_command_line_handling_discover_by_default(self):
+ program = TestableTestProgram()
+ program.module = None
+
+ self.called = False
+ def do_discovery(argv):
+ self.called = True
+ self.assertEqual(argv, [])
+ program._do_discovery = do_discovery
+ program.parseArgs(['something'])
+ self.assertTrue(self.called)
+
+ def test_command_line_handling_discover_by_default_with_options(self):
+ program = TestableTestProgram()
+ program.module = None
+
+ args = ['something', '-v', '-b', '-v', '-c', '-f']
+ self.called = False
+ def do_discovery(argv):
+ self.called = True
+ self.assertEqual(argv, args[1:])
+ program._do_discovery = do_discovery
+ program.parseArgs(args)
+ self.assertTrue(self.called)
+
+
+ def test_command_line_handling_do_discovery_too_many_arguments(self):
+ class Stop(Exception):
+ pass
+ def usageExit():
+ raise Stop
+
+ program = TestableTestProgram()
+ program.usageExit = usageExit
+
+ with self.assertRaises(Stop):
+ # too many args
+ program._do_discovery(['one', 'two', 'three', 'four'])
+
+
+ def test_command_line_handling_do_discovery_calls_loader(self):
+ program = TestableTestProgram()
+
+ class Loader(object):
+ args = []
+ def discover(self, start_dir, pattern, top_level_dir):
+ self.args.append((start_dir, pattern, top_level_dir))
+ return 'tests'
+
+ program._do_discovery(['-v'], Loader=Loader)
+ self.assertEqual(program.verbosity, 2)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('.', 'test*.py', None)])
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery(['--verbose'], Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('.', 'test*.py', None)])
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery([], Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('.', 'test*.py', None)])
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery(['fish'], Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('fish', 'test*.py', None)])
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery(['fish', 'eggs'], Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('fish', 'eggs', None)])
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery(['fish', 'eggs', 'ham'], Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('fish', 'eggs', 'ham')])
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery(['-s', 'fish'], Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('fish', 'test*.py', None)])
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery(['-t', 'fish'], Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('.', 'test*.py', 'fish')])
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery(['-p', 'fish'], Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('.', 'fish', None)])
+ self.assertFalse(program.failfast)
+ self.assertFalse(program.catchbreak)
+
+ Loader.args = []
+ program = TestableTestProgram()
+ program._do_discovery(['-p', 'eggs', '-s', 'fish', '-v', '-f', '-c'],
+ Loader=Loader)
+ self.assertEqual(program.test, 'tests')
+ self.assertEqual(Loader.args, [('fish', 'eggs', None)])
+ self.assertEqual(program.verbosity, 2)
+ self.assertTrue(program.failfast)
+ self.assertTrue(program.catchbreak)
+
+ def test_detect_module_clash(self):
+ class Module(object):
+ __file__ = 'bar/foo.py'
+ sys.modules['foo'] = Module
+ full_path = os.path.abspath('foo')
+ original_listdir = os.listdir
+ original_isfile = os.path.isfile
+ original_isdir = os.path.isdir
+
+ def cleanup():
+ os.listdir = original_listdir
+ os.path.isfile = original_isfile
+ os.path.isdir = original_isdir
+ del sys.modules['foo']
+ if full_path in sys.path:
+ sys.path.remove(full_path)
+ self.addCleanup(cleanup)
+
+ def listdir(_):
+ return ['foo.py']
+ def isfile(_):
+ return True
+ def isdir(_):
+ return True
+ os.listdir = listdir
+ os.path.isfile = isfile
+ os.path.isdir = isdir
+
+ loader = unittest.TestLoader()
+
+ mod_dir = os.path.abspath('bar')
+ expected_dir = os.path.abspath('foo')
+ msg = re.escape(r"'foo' module incorrectly imported from %r. Expected %r. "
+ "Is this module globally installed?" % (mod_dir, expected_dir))
+ self.assertRaisesRegex(
+ ImportError, '^%s$' % msg, loader.discover,
+ start_dir='foo', pattern='foo.py'
+ )
+ self.assertEqual(sys.path[0], full_path)
+
+
+ def test_discovery_from_dotted_path(self):
+ loader = unittest.TestLoader()
+
+ tests = [self]
+ expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__))
+
+ self.wasRun = False
+ def _find_tests(start_dir, pattern):
+ self.wasRun = True
+ self.assertEqual(start_dir, expectedPath)
+ return tests
+ loader._find_tests = _find_tests
+ suite = loader.discover('unittest.test')
+ self.assertTrue(self.wasRun)
+ self.assertEqual(suite._tests, tests)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/unittest/test/test_functiontestcase.py b/Lib/unittest/test/test_functiontestcase.py
new file mode 100644
index 0000000000..9ce5ee3556
--- /dev/null
+++ b/Lib/unittest/test/test_functiontestcase.py
@@ -0,0 +1,144 @@
+import unittest
+
+from .support import LoggingResult
+
+
+class Test_FunctionTestCase(unittest.TestCase):
+
+ # "Return the number of tests represented by the this test object. For
+ # TestCase instances, this will always be 1"
+ def test_countTestCases(self):
+ test = unittest.FunctionTestCase(lambda: None)
+
+ self.assertEqual(test.countTestCases(), 1)
+
+ # "When a setUp() method is defined, the test runner will run that method
+ # prior to each test. Likewise, if a tearDown() method is defined, the
+ # test runner will invoke that method after each test. In the example,
+ # setUp() was used to create a fresh sequence for each test."
+ #
+ # Make sure the proper call order is maintained, even if setUp() raises
+ # an exception.
+ def test_run_call_order__error_in_setUp(self):
+ events = []
+ result = LoggingResult(events)
+
+ def setUp():
+ events.append('setUp')
+ raise RuntimeError('raised by setUp')
+
+ def test():
+ events.append('test')
+
+ def tearDown():
+ events.append('tearDown')
+
+ expected = ['startTest', 'setUp', 'addError', 'stopTest']
+ unittest.FunctionTestCase(test, setUp, tearDown).run(result)
+ self.assertEqual(events, expected)
+
+ # "When a setUp() method is defined, the test runner will run that method
+ # prior to each test. Likewise, if a tearDown() method is defined, the
+ # test runner will invoke that method after each test. In the example,
+ # setUp() was used to create a fresh sequence for each test."
+ #
+ # Make sure the proper call order is maintained, even if the test raises
+ # an error (as opposed to a failure).
+ def test_run_call_order__error_in_test(self):
+ events = []
+ result = LoggingResult(events)
+
+ def setUp():
+ events.append('setUp')
+
+ def test():
+ events.append('test')
+ raise RuntimeError('raised by test')
+
+ def tearDown():
+ events.append('tearDown')
+
+ expected = ['startTest', 'setUp', 'test', 'tearDown',
+ 'addError', 'stopTest']
+ unittest.FunctionTestCase(test, setUp, tearDown).run(result)
+ self.assertEqual(events, expected)
+
+ # "When a setUp() method is defined, the test runner will run that method
+ # prior to each test. Likewise, if a tearDown() method is defined, the
+ # test runner will invoke that method after each test. In the example,
+ # setUp() was used to create a fresh sequence for each test."
+ #
+ # Make sure the proper call order is maintained, even if the test signals
+ # a failure (as opposed to an error).
+ def test_run_call_order__failure_in_test(self):
+ events = []
+ result = LoggingResult(events)
+
+ def setUp():
+ events.append('setUp')
+
+ def test():
+ events.append('test')
+ self.fail('raised by test')
+
+ def tearDown():
+ events.append('tearDown')
+
+ expected = ['startTest', 'setUp', 'test', 'tearDown',
+ 'addFailure', 'stopTest']
+ unittest.FunctionTestCase(test, setUp, tearDown).run(result)
+ self.assertEqual(events, expected)
+
+ # "When a setUp() method is defined, the test runner will run that method
+ # prior to each test. Likewise, if a tearDown() method is defined, the
+ # test runner will invoke that method after each test. In the example,
+ # setUp() was used to create a fresh sequence for each test."
+ #
+ # Make sure the proper call order is maintained, even if tearDown() raises
+ # an exception.
+ def test_run_call_order__error_in_tearDown(self):
+ events = []
+ result = LoggingResult(events)
+
+ def setUp():
+ events.append('setUp')
+
+ def test():
+ events.append('test')
+
+ def tearDown():
+ events.append('tearDown')
+ raise RuntimeError('raised by tearDown')
+
+ expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
+ 'stopTest']
+ unittest.FunctionTestCase(test, setUp, tearDown).run(result)
+ self.assertEqual(events, expected)
+
+ # "Return a string identifying the specific test case."
+ #
+ # Because of the vague nature of the docs, I'm not going to lock this
+ # test down too much. Really all that can be asserted is that the id()
+ # will be a string (either 8-byte or unicode -- again, because the docs
+ # just say "string")
+ def test_id(self):
+ test = unittest.FunctionTestCase(lambda: None)
+
+ self.assertIsInstance(test.id(), str)
+
+ # "Returns a one-line description of the test, or None if no description
+ # has been provided. The default implementation of this method returns
+ # the first line of the test method's docstring, if available, or None."
+ def test_shortDescription__no_docstring(self):
+ test = unittest.FunctionTestCase(lambda: None)
+
+ self.assertEqual(test.shortDescription(), None)
+
+ # "Returns a one-line description of the test, or None if no description
+ # has been provided. The default implementation of this method returns
+ # the first line of the test method's docstring, if available, or None."
+ def test_shortDescription__singleline_docstring(self):
+ desc = "this tests foo"
+ test = unittest.FunctionTestCase(lambda: None, description=desc)
+
+ self.assertEqual(test.shortDescription(), "this tests foo")
diff --git a/Lib/unittest/test/test_loader.py b/Lib/unittest/test/test_loader.py
new file mode 100644
index 0000000000..f7e31a57f1
--- /dev/null
+++ b/Lib/unittest/test/test_loader.py
@@ -0,0 +1,1292 @@
+import sys
+import types
+
+
+import unittest
+
+
+class Test_TestLoader(unittest.TestCase):
+
+ ### Tests for TestLoader.loadTestsFromTestCase
+ ################################################################
+
+ # "Return a suite of all tests cases contained in the TestCase-derived
+ # class testCaseClass"
+ def test_loadTestsFromTestCase(self):
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+
+ tests = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
+
+ loader = unittest.TestLoader()
+ self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
+
+ # "Return a suite of all tests cases contained in the TestCase-derived
+ # class testCaseClass"
+ #
+ # Make sure it does the right thing even if no tests were found
+ def test_loadTestsFromTestCase__no_matches(self):
+ class Foo(unittest.TestCase):
+ def foo_bar(self): pass
+
+ empty_suite = unittest.TestSuite()
+
+ loader = unittest.TestLoader()
+ self.assertEqual(loader.loadTestsFromTestCase(Foo), empty_suite)
+
+ # "Return a suite of all tests cases contained in the TestCase-derived
+ # class testCaseClass"
+ #
+ # What happens if loadTestsFromTestCase() is given an object
+ # that isn't a subclass of TestCase? Specifically, what happens
+ # if testCaseClass is a subclass of TestSuite?
+ #
+ # This is checked for specifically in the code, so we better add a
+ # test for it.
+ def test_loadTestsFromTestCase__TestSuite_subclass(self):
+ class NotATestCase(unittest.TestSuite):
+ pass
+
+ loader = unittest.TestLoader()
+ try:
+ loader.loadTestsFromTestCase(NotATestCase)
+ except TypeError:
+ pass
+ else:
+ self.fail('Should raise TypeError')
+
+ # "Return a suite of all tests cases contained in the TestCase-derived
+ # class testCaseClass"
+ #
+ # Make sure loadTestsFromTestCase() picks up the default test method
+ # name (as specified by TestCase), even though the method name does
+ # not match the default TestLoader.testMethodPrefix string
+ def test_loadTestsFromTestCase__default_method_name(self):
+ class Foo(unittest.TestCase):
+ def runTest(self):
+ pass
+
+ loader = unittest.TestLoader()
+ # This has to be false for the test to succeed
+ self.assertFalse('runTest'.startswith(loader.testMethodPrefix))
+
+ suite = loader.loadTestsFromTestCase(Foo)
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [Foo('runTest')])
+
+ ################################################################
+ ### /Tests for TestLoader.loadTestsFromTestCase
+
+ ### Tests for TestLoader.loadTestsFromModule
+ ################################################################
+
+ # "This method searches `module` for classes derived from TestCase"
+ def test_loadTestsFromModule__TestCase_subclass(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromModule(m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ expected = [loader.suiteClass([MyTestCase('test')])]
+ self.assertEqual(list(suite), expected)
+
+ # "This method searches `module` for classes derived from TestCase"
+ #
+ # What happens if no tests are found (no TestCase instances)?
+ def test_loadTestsFromModule__no_TestCase_instances(self):
+ m = types.ModuleType('m')
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromModule(m)
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [])
+
+ # "This method searches `module` for classes derived from TestCase"
+ #
+ # What happens if no tests are found (TestCases instances, but no tests)?
+ def test_loadTestsFromModule__no_TestCase_tests(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromModule(m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ self.assertEqual(list(suite), [loader.suiteClass()])
+
+ # "This method searches `module` for classes derived from TestCase"s
+ #
+ # What happens if loadTestsFromModule() is given something other
+ # than a module?
+ #
+ # XXX Currently, it succeeds anyway. This flexibility
+ # should either be documented or loadTestsFromModule() should
+ # raise a TypeError
+ #
+ # XXX Certain people are using this behaviour. We'll add a test for it
+ def test_loadTestsFromModule__not_a_module(self):
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+
+ class NotAModule(object):
+ test_2 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromModule(NotAModule)
+
+ reference = [unittest.TestSuite([MyTestCase('test')])]
+ self.assertEqual(list(suite), reference)
+
+
+ # Check that loadTestsFromModule honors (or not) a module
+ # with a load_tests function.
+ def test_loadTestsFromModule__load_tests(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ load_tests_args = []
+ def load_tests(loader, tests, pattern):
+ self.assertIsInstance(tests, unittest.TestSuite)
+ load_tests_args.extend((loader, tests, pattern))
+ return tests
+ m.load_tests = load_tests
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromModule(m)
+ self.assertIsInstance(suite, unittest.TestSuite)
+ self.assertEqual(load_tests_args, [loader, suite, None])
+
+ load_tests_args = []
+ suite = loader.loadTestsFromModule(m, use_load_tests=False)
+ self.assertEqual(load_tests_args, [])
+
+ def test_loadTestsFromModule__faulty_load_tests(self):
+ m = types.ModuleType('m')
+
+ def load_tests(loader, tests, pattern):
+ raise TypeError('some failure')
+ m.load_tests = load_tests
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromModule(m)
+ self.assertIsInstance(suite, unittest.TestSuite)
+ self.assertEqual(suite.countTestCases(), 1)
+ test = list(suite)[0]
+
+ self.assertRaisesRegex(TypeError, "some failure", test.m)
+
+ ################################################################
+ ### /Tests for TestLoader.loadTestsFromModule()
+
+ ### Tests for TestLoader.loadTestsFromName()
+ ################################################################
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # Is ValueError raised in response to an empty name?
+ def test_loadTestsFromName__empty_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromName('')
+ except ValueError as e:
+ self.assertEqual(str(e), "Empty module name")
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # What happens when the name contains invalid characters?
+ def test_loadTestsFromName__malformed_name(self):
+ loader = unittest.TestLoader()
+
+ # XXX Should this raise ValueError or ImportError?
+ try:
+ loader.loadTestsFromName('abc () //')
+ except ValueError:
+ pass
+ except ImportError:
+ pass
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to a
+ # module"
+ #
+ # What happens when a module by that name can't be found?
+ def test_loadTestsFromName__unknown_module_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromName('sdasfasfasdf')
+ except ImportError as e:
+ self.assertEqual(str(e), "No module named sdasfasfasdf")
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise ImportError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # What happens when the module is found, but the attribute can't?
+ def test_loadTestsFromName__unknown_attr_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromName('unittest.sdasfasfasdf')
+ except AttributeError as e:
+ self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # What happens when we provide the module, but the attribute can't be
+ # found?
+ def test_loadTestsFromName__relative_unknown_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromName('sdasfasfasdf', unittest)
+ except AttributeError as e:
+ self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ # ...
+ # "The method optionally resolves name relative to the given module"
+ #
+ # Does loadTestsFromName raise ValueError when passed an empty
+ # name relative to a provided module?
+ #
+ # XXX Should probably raise a ValueError instead of an AttributeError
+ def test_loadTestsFromName__relative_empty_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromName('', unittest)
+ except AttributeError as e:
+ pass
+ else:
+ self.fail("Failed to raise AttributeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ # ...
+ # "The method optionally resolves name relative to the given module"
+ #
+ # What happens when an impossible name is given, relative to the provided
+ # `module`?
+ def test_loadTestsFromName__relative_malformed_name(self):
+ loader = unittest.TestLoader()
+
+ # XXX Should this raise AttributeError or ValueError?
+ try:
+ loader.loadTestsFromName('abc () //', unittest)
+ except ValueError:
+ pass
+ except AttributeError:
+ pass
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
+
+ # "The method optionally resolves name relative to the given module"
+ #
+ # Does loadTestsFromName raise TypeError when the `module` argument
+ # isn't a module object?
+ #
+ # XXX Accepts the not-a-module object, ignorning the object's type
+ # This should raise an exception or the method name should be changed
+ #
+ # XXX Some people are relying on this, so keep it for now
+ def test_loadTestsFromName__relative_not_a_module(self):
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+
+ class NotAModule(object):
+ test_2 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromName('test_2', NotAModule)
+
+ reference = [MyTestCase('test')]
+ self.assertEqual(list(suite), reference)
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # Does it raise an exception if the name resolves to an invalid
+ # object?
+ def test_loadTestsFromName__relative_bad_object(self):
+ m = types.ModuleType('m')
+ m.testcase_1 = object()
+
+ loader = unittest.TestLoader()
+ try:
+ loader.loadTestsFromName('testcase_1', m)
+ except TypeError:
+ pass
+ else:
+ self.fail("Should have raised TypeError")
+
+ # "The specifier name is a ``dotted name'' that may
+ # resolve either to ... a test case class"
+ def test_loadTestsFromName__relative_TestCase_subclass(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromName('testcase_1', m)
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [MyTestCase('test')])
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ def test_loadTestsFromName__relative_TestSuite(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testsuite = unittest.TestSuite([MyTestCase('test')])
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromName('testsuite', m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ self.assertEqual(list(suite), [MyTestCase('test')])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a test method within a test case class"
+ def test_loadTestsFromName__relative_testmethod(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromName('testcase_1.test', m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ self.assertEqual(list(suite), [MyTestCase('test')])
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # Does loadTestsFromName() raise the proper exception when trying to
+ # resolve "a test method within a test case class" that doesn't exist
+ # for the given name (relative to a provided module)?
+ def test_loadTestsFromName__relative_invalid_testmethod(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ try:
+ loader.loadTestsFromName('testcase_1.testfoo', m)
+ except AttributeError as e:
+ self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
+ else:
+ self.fail("Failed to raise AttributeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a callable object which returns a ... TestSuite instance"
+ def test_loadTestsFromName__callable__TestSuite(self):
+ m = types.ModuleType('m')
+ testcase_1 = unittest.FunctionTestCase(lambda: None)
+ testcase_2 = unittest.FunctionTestCase(lambda: None)
+ def return_TestSuite():
+ return unittest.TestSuite([testcase_1, testcase_2])
+ m.return_TestSuite = return_TestSuite
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromName('return_TestSuite', m)
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [testcase_1, testcase_2])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a callable object which returns a TestCase ... instance"
+ def test_loadTestsFromName__callable__TestCase_instance(self):
+ m = types.ModuleType('m')
+ testcase_1 = unittest.FunctionTestCase(lambda: None)
+ def return_TestCase():
+ return testcase_1
+ m.return_TestCase = return_TestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromName('return_TestCase', m)
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [testcase_1])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a callable object which returns a TestCase ... instance"
+ #*****************************************************************
+ #Override the suiteClass attribute to ensure that the suiteClass
+ #attribute is used
+ def test_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass(self):
+ class SubTestSuite(unittest.TestSuite):
+ pass
+ m = types.ModuleType('m')
+ testcase_1 = unittest.FunctionTestCase(lambda: None)
+ def return_TestCase():
+ return testcase_1
+ m.return_TestCase = return_TestCase
+
+ loader = unittest.TestLoader()
+ loader.suiteClass = SubTestSuite
+ suite = loader.loadTestsFromName('return_TestCase', m)
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [testcase_1])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a test method within a test case class"
+ #*****************************************************************
+ #Override the suiteClass attribute to ensure that the suiteClass
+ #attribute is used
+ def test_loadTestsFromName__relative_testmethod_ProperSuiteClass(self):
+ class SubTestSuite(unittest.TestSuite):
+ pass
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ loader.suiteClass=SubTestSuite
+ suite = loader.loadTestsFromName('testcase_1.test', m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ self.assertEqual(list(suite), [MyTestCase('test')])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a callable object which returns a TestCase or TestSuite instance"
+ #
+ # What happens if the callable returns something else?
+ def test_loadTestsFromName__callable__wrong_type(self):
+ m = types.ModuleType('m')
+ def return_wrong():
+ return 6
+ m.return_wrong = return_wrong
+
+ loader = unittest.TestLoader()
+ try:
+ suite = loader.loadTestsFromName('return_wrong', m)
+ except TypeError:
+ pass
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise TypeError")
+
+ # "The specifier can refer to modules and packages which have not been
+ # imported; they will be imported as a side-effect"
+ def test_loadTestsFromName__module_not_loaded(self):
+ # We're going to try to load this module as a side-effect, so it
+ # better not be loaded before we try.
+ #
+ module_name = 'unittest.test.dummy'
+ sys.modules.pop(module_name, None)
+
+ loader = unittest.TestLoader()
+ try:
+ suite = loader.loadTestsFromName(module_name)
+
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [])
+
+ # module should now be loaded, thanks to loadTestsFromName()
+ self.assertIn(module_name, sys.modules)
+ finally:
+ if module_name in sys.modules:
+ del sys.modules[module_name]
+
+ ################################################################
+ ### Tests for TestLoader.loadTestsFromName()
+
+ ### Tests for TestLoader.loadTestsFromNames()
+ ################################################################
+
+ # "Similar to loadTestsFromName(), but takes a sequence of names rather
+ # than a single name."
+ #
+ # What happens if that sequence of names is empty?
+ def test_loadTestsFromNames__empty_name_list(self):
+ loader = unittest.TestLoader()
+
+ suite = loader.loadTestsFromNames([])
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [])
+
+ # "Similar to loadTestsFromName(), but takes a sequence of names rather
+ # than a single name."
+ # ...
+ # "The method optionally resolves name relative to the given module"
+ #
+ # What happens if that sequence of names is empty?
+ #
+ # XXX Should this raise a ValueError or just return an empty TestSuite?
+ def test_loadTestsFromNames__relative_empty_name_list(self):
+ loader = unittest.TestLoader()
+
+ suite = loader.loadTestsFromNames([], unittest)
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [])
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # Is ValueError raised in response to an empty name?
+ def test_loadTestsFromNames__empty_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromNames([''])
+ except ValueError as e:
+ self.assertEqual(str(e), "Empty module name")
+ else:
+ self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # What happens when presented with an impossible module name?
+ def test_loadTestsFromNames__malformed_name(self):
+ loader = unittest.TestLoader()
+
+ # XXX Should this raise ValueError or ImportError?
+ try:
+ loader.loadTestsFromNames(['abc () //'])
+ except ValueError:
+ pass
+ except ImportError:
+ pass
+ else:
+ self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # What happens when no module can be found for the given name?
+ def test_loadTestsFromNames__unknown_module_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromNames(['sdasfasfasdf'])
+ except ImportError as e:
+ self.assertEqual(str(e), "No module named sdasfasfasdf")
+ else:
+ self.fail("TestLoader.loadTestsFromNames failed to raise ImportError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # What happens when the module can be found, but not the attribute?
+ def test_loadTestsFromNames__unknown_attr_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromNames(['unittest.sdasfasfasdf', 'unittest'])
+ except AttributeError as e:
+ self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+ else:
+ self.fail("TestLoader.loadTestsFromNames failed to raise AttributeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ # ...
+ # "The method optionally resolves name relative to the given module"
+ #
+ # What happens when given an unknown attribute on a specified `module`
+ # argument?
+ def test_loadTestsFromNames__unknown_name_relative_1(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromNames(['sdasfasfasdf'], unittest)
+ except AttributeError as e:
+ self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ # ...
+ # "The method optionally resolves name relative to the given module"
+ #
+ # Do unknown attributes (relative to a provided module) still raise an
+ # exception even in the presence of valid attribute names?
+ def test_loadTestsFromNames__unknown_name_relative_2(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromNames(['TestCase', 'sdasfasfasdf'], unittest)
+ except AttributeError as e:
+ self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+ else:
+ self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ # ...
+ # "The method optionally resolves name relative to the given module"
+ #
+ # What happens when faced with the empty string?
+ #
+ # XXX This currently raises AttributeError, though ValueError is probably
+ # more appropriate
+ def test_loadTestsFromNames__relative_empty_name(self):
+ loader = unittest.TestLoader()
+
+ try:
+ loader.loadTestsFromNames([''], unittest)
+ except AttributeError:
+ pass
+ else:
+ self.fail("Failed to raise ValueError")
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ # ...
+ # "The method optionally resolves name relative to the given module"
+ #
+ # What happens when presented with an impossible attribute name?
+ def test_loadTestsFromNames__relative_malformed_name(self):
+ loader = unittest.TestLoader()
+
+ # XXX Should this raise AttributeError or ValueError?
+ try:
+ loader.loadTestsFromNames(['abc () //'], unittest)
+ except AttributeError:
+ pass
+ except ValueError:
+ pass
+ else:
+ self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
+
+ # "The method optionally resolves name relative to the given module"
+ #
+ # Does loadTestsFromNames() make sure the provided `module` is in fact
+ # a module?
+ #
+ # XXX This validation is currently not done. This flexibility should
+ # either be documented or a TypeError should be raised.
+ def test_loadTestsFromNames__relative_not_a_module(self):
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+
+ class NotAModule(object):
+ test_2 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromNames(['test_2'], NotAModule)
+
+ reference = [unittest.TestSuite([MyTestCase('test')])]
+ self.assertEqual(list(suite), reference)
+
+ # "The specifier name is a ``dotted name'' that may resolve either to
+ # a module, a test case class, a TestSuite instance, a test method
+ # within a test case class, or a callable object which returns a
+ # TestCase or TestSuite instance."
+ #
+ # Does it raise an exception if the name resolves to an invalid
+ # object?
+ def test_loadTestsFromNames__relative_bad_object(self):
+ m = types.ModuleType('m')
+ m.testcase_1 = object()
+
+ loader = unittest.TestLoader()
+ try:
+ loader.loadTestsFromNames(['testcase_1'], m)
+ except TypeError:
+ pass
+ else:
+ self.fail("Should have raised TypeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a test case class"
+ def test_loadTestsFromNames__relative_TestCase_subclass(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromNames(['testcase_1'], m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ expected = loader.suiteClass([MyTestCase('test')])
+ self.assertEqual(list(suite), [expected])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a TestSuite instance"
+ def test_loadTestsFromNames__relative_TestSuite(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testsuite = unittest.TestSuite([MyTestCase('test')])
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromNames(['testsuite'], m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ self.assertEqual(list(suite), [m.testsuite])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to ... a
+ # test method within a test case class"
+ def test_loadTestsFromNames__relative_testmethod(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromNames(['testcase_1.test'], m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ ref_suite = unittest.TestSuite([MyTestCase('test')])
+ self.assertEqual(list(suite), [ref_suite])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to ... a
+ # test method within a test case class"
+ #
+ # Does the method gracefully handle names that initially look like they
+ # resolve to "a test method within a test case class" but don't?
+ def test_loadTestsFromNames__relative_invalid_testmethod(self):
+ m = types.ModuleType('m')
+ class MyTestCase(unittest.TestCase):
+ def test(self):
+ pass
+ m.testcase_1 = MyTestCase
+
+ loader = unittest.TestLoader()
+ try:
+ loader.loadTestsFromNames(['testcase_1.testfoo'], m)
+ except AttributeError as e:
+ self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
+ else:
+ self.fail("Failed to raise AttributeError")
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a callable object which returns a ... TestSuite instance"
+ def test_loadTestsFromNames__callable__TestSuite(self):
+ m = types.ModuleType('m')
+ testcase_1 = unittest.FunctionTestCase(lambda: None)
+ testcase_2 = unittest.FunctionTestCase(lambda: None)
+ def return_TestSuite():
+ return unittest.TestSuite([testcase_1, testcase_2])
+ m.return_TestSuite = return_TestSuite
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromNames(['return_TestSuite'], m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ expected = unittest.TestSuite([testcase_1, testcase_2])
+ self.assertEqual(list(suite), [expected])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a callable object which returns a TestCase ... instance"
+ def test_loadTestsFromNames__callable__TestCase_instance(self):
+ m = types.ModuleType('m')
+ testcase_1 = unittest.FunctionTestCase(lambda: None)
+ def return_TestCase():
+ return testcase_1
+ m.return_TestCase = return_TestCase
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromNames(['return_TestCase'], m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ ref_suite = unittest.TestSuite([testcase_1])
+ self.assertEqual(list(suite), [ref_suite])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a callable object which returns a TestCase or TestSuite instance"
+ #
+ # Are staticmethods handled correctly?
+ def test_loadTestsFromNames__callable__call_staticmethod(self):
+ m = types.ModuleType('m')
+ class Test1(unittest.TestCase):
+ def test(self):
+ pass
+
+ testcase_1 = Test1('test')
+ class Foo(unittest.TestCase):
+ @staticmethod
+ def foo():
+ return testcase_1
+ m.Foo = Foo
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromNames(['Foo.foo'], m)
+ self.assertIsInstance(suite, loader.suiteClass)
+
+ ref_suite = unittest.TestSuite([testcase_1])
+ self.assertEqual(list(suite), [ref_suite])
+
+ # "The specifier name is a ``dotted name'' that may resolve ... to
+ # ... a callable object which returns a TestCase or TestSuite instance"
+ #
+ # What happens when the callable returns something else?
+ def test_loadTestsFromNames__callable__wrong_type(self):
+ m = types.ModuleType('m')
+ def return_wrong():
+ return 6
+ m.return_wrong = return_wrong
+
+ loader = unittest.TestLoader()
+ try:
+ suite = loader.loadTestsFromNames(['return_wrong'], m)
+ except TypeError:
+ pass
+ else:
+ self.fail("TestLoader.loadTestsFromNames failed to raise TypeError")
+
+ # "The specifier can refer to modules and packages which have not been
+ # imported; they will be imported as a side-effect"
+ def test_loadTestsFromNames__module_not_loaded(self):
+ # We're going to try to load this module as a side-effect, so it
+ # better not be loaded before we try.
+ #
+ module_name = 'unittest.test.dummy'
+ sys.modules.pop(module_name, None)
+
+ loader = unittest.TestLoader()
+ try:
+ suite = loader.loadTestsFromNames([module_name])
+
+ self.assertIsInstance(suite, loader.suiteClass)
+ self.assertEqual(list(suite), [unittest.TestSuite()])
+
+ # module should now be loaded, thanks to loadTestsFromName()
+ self.assertIn(module_name, sys.modules)
+ finally:
+ if module_name in sys.modules:
+ del sys.modules[module_name]
+
+ ################################################################
+ ### /Tests for TestLoader.loadTestsFromNames()
+
+ ### Tests for TestLoader.getTestCaseNames()
+ ################################################################
+
+ # "Return a sorted sequence of method names found within testCaseClass"
+ #
+ # Test.foobar is defined to make sure getTestCaseNames() respects
+ # loader.testMethodPrefix
+ def test_getTestCaseNames(self):
+ class Test(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foobar(self): pass
+
+ loader = unittest.TestLoader()
+
+ self.assertEqual(loader.getTestCaseNames(Test), ['test_1', 'test_2'])
+
+ # "Return a sorted sequence of method names found within testCaseClass"
+ #
+ # Does getTestCaseNames() behave appropriately if no tests are found?
+ def test_getTestCaseNames__no_tests(self):
+ class Test(unittest.TestCase):
+ def foobar(self): pass
+
+ loader = unittest.TestLoader()
+
+ self.assertEqual(loader.getTestCaseNames(Test), [])
+
+ # "Return a sorted sequence of method names found within testCaseClass"
+ #
+ # Are not-TestCases handled gracefully?
+ #
+ # XXX This should raise a TypeError, not return a list
+ #
+ # XXX It's too late in the 2.5 release cycle to fix this, but it should
+ # probably be revisited for 2.6
+ def test_getTestCaseNames__not_a_TestCase(self):
+ class BadCase(int):
+ def test_foo(self):
+ pass
+
+ loader = unittest.TestLoader()
+ names = loader.getTestCaseNames(BadCase)
+
+ self.assertEqual(names, ['test_foo'])
+
+ # "Return a sorted sequence of method names found within testCaseClass"
+ #
+ # Make sure inherited names are handled.
+ #
+ # TestP.foobar is defined to make sure getTestCaseNames() respects
+ # loader.testMethodPrefix
+ def test_getTestCaseNames__inheritance(self):
+ class TestP(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foobar(self): pass
+
+ class TestC(TestP):
+ def test_1(self): pass
+ def test_3(self): pass
+
+ loader = unittest.TestLoader()
+
+ names = ['test_1', 'test_2', 'test_3']
+ self.assertEqual(loader.getTestCaseNames(TestC), names)
+
+ ################################################################
+ ### /Tests for TestLoader.getTestCaseNames()
+
+ ### Tests for TestLoader.testMethodPrefix
+ ################################################################
+
+ # "String giving the prefix of method names which will be interpreted as
+ # test methods"
+ #
+ # Implicit in the documentation is that testMethodPrefix is respected by
+ # all loadTestsFrom* methods.
+ def test_testMethodPrefix__loadTestsFromTestCase(self):
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+
+ tests_1 = unittest.TestSuite([Foo('foo_bar')])
+ tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
+
+ loader = unittest.TestLoader()
+ loader.testMethodPrefix = 'foo'
+ self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_1)
+
+ loader.testMethodPrefix = 'test'
+ self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_2)
+
+ # "String giving the prefix of method names which will be interpreted as
+ # test methods"
+ #
+ # Implicit in the documentation is that testMethodPrefix is respected by
+ # all loadTestsFrom* methods.
+ def test_testMethodPrefix__loadTestsFromModule(self):
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+ m.Foo = Foo
+
+ tests_1 = [unittest.TestSuite([Foo('foo_bar')])]
+ tests_2 = [unittest.TestSuite([Foo('test_1'), Foo('test_2')])]
+
+ loader = unittest.TestLoader()
+ loader.testMethodPrefix = 'foo'
+ self.assertEqual(list(loader.loadTestsFromModule(m)), tests_1)
+
+ loader.testMethodPrefix = 'test'
+ self.assertEqual(list(loader.loadTestsFromModule(m)), tests_2)
+
+ # "String giving the prefix of method names which will be interpreted as
+ # test methods"
+ #
+ # Implicit in the documentation is that testMethodPrefix is respected by
+ # all loadTestsFrom* methods.
+ def test_testMethodPrefix__loadTestsFromName(self):
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+ m.Foo = Foo
+
+ tests_1 = unittest.TestSuite([Foo('foo_bar')])
+ tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
+
+ loader = unittest.TestLoader()
+ loader.testMethodPrefix = 'foo'
+ self.assertEqual(loader.loadTestsFromName('Foo', m), tests_1)
+
+ loader.testMethodPrefix = 'test'
+ self.assertEqual(loader.loadTestsFromName('Foo', m), tests_2)
+
+ # "String giving the prefix of method names which will be interpreted as
+ # test methods"
+ #
+ # Implicit in the documentation is that testMethodPrefix is respected by
+ # all loadTestsFrom* methods.
+ def test_testMethodPrefix__loadTestsFromNames(self):
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+ m.Foo = Foo
+
+ tests_1 = unittest.TestSuite([unittest.TestSuite([Foo('foo_bar')])])
+ tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
+ tests_2 = unittest.TestSuite([tests_2])
+
+ loader = unittest.TestLoader()
+ loader.testMethodPrefix = 'foo'
+ self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_1)
+
+ loader.testMethodPrefix = 'test'
+ self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_2)
+
+ # "The default value is 'test'"
+ def test_testMethodPrefix__default_value(self):
+ loader = unittest.TestLoader()
+ self.assertEqual(loader.testMethodPrefix, 'test')
+
+ ################################################################
+ ### /Tests for TestLoader.testMethodPrefix
+
+ ### Tests for TestLoader.sortTestMethodsUsing
+ ################################################################
+
+ # "Function to be used to compare method names when sorting them in
+ # getTestCaseNames() and all the loadTestsFromX() methods"
+ def test_sortTestMethodsUsing__loadTestsFromTestCase(self):
+ def reversed_cmp(x, y):
+ return -((x > y) - (x < y))
+
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+
+ loader = unittest.TestLoader()
+ loader.sortTestMethodsUsing = reversed_cmp
+
+ tests = loader.suiteClass([Foo('test_2'), Foo('test_1')])
+ self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
+
+ # "Function to be used to compare method names when sorting them in
+ # getTestCaseNames() and all the loadTestsFromX() methods"
+ def test_sortTestMethodsUsing__loadTestsFromModule(self):
+ def reversed_cmp(x, y):
+ return -((x > y) - (x < y))
+
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ m.Foo = Foo
+
+ loader = unittest.TestLoader()
+ loader.sortTestMethodsUsing = reversed_cmp
+
+ tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])]
+ self.assertEqual(list(loader.loadTestsFromModule(m)), tests)
+
+ # "Function to be used to compare method names when sorting them in
+ # getTestCaseNames() and all the loadTestsFromX() methods"
+ def test_sortTestMethodsUsing__loadTestsFromName(self):
+ def reversed_cmp(x, y):
+ return -((x > y) - (x < y))
+
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ m.Foo = Foo
+
+ loader = unittest.TestLoader()
+ loader.sortTestMethodsUsing = reversed_cmp
+
+ tests = loader.suiteClass([Foo('test_2'), Foo('test_1')])
+ self.assertEqual(loader.loadTestsFromName('Foo', m), tests)
+
+ # "Function to be used to compare method names when sorting them in
+ # getTestCaseNames() and all the loadTestsFromX() methods"
+ def test_sortTestMethodsUsing__loadTestsFromNames(self):
+ def reversed_cmp(x, y):
+ return -((x > y) - (x < y))
+
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ m.Foo = Foo
+
+ loader = unittest.TestLoader()
+ loader.sortTestMethodsUsing = reversed_cmp
+
+ tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])]
+ self.assertEqual(list(loader.loadTestsFromNames(['Foo'], m)), tests)
+
+ # "Function to be used to compare method names when sorting them in
+ # getTestCaseNames()"
+ #
+ # Does it actually affect getTestCaseNames()?
+ def test_sortTestMethodsUsing__getTestCaseNames(self):
+ def reversed_cmp(x, y):
+ return -((x > y) - (x < y))
+
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+
+ loader = unittest.TestLoader()
+ loader.sortTestMethodsUsing = reversed_cmp
+
+ test_names = ['test_2', 'test_1']
+ self.assertEqual(loader.getTestCaseNames(Foo), test_names)
+
+ # "The default value is the built-in cmp() function"
+ # Since cmp is now defunct, we simply verify that the results
+ # occur in the same order as they would with the default sort.
+ def test_sortTestMethodsUsing__default_value(self):
+ loader = unittest.TestLoader()
+
+ class Foo(unittest.TestCase):
+ def test_2(self): pass
+ def test_3(self): pass
+ def test_1(self): pass
+
+ test_names = ['test_2', 'test_3', 'test_1']
+ self.assertEqual(loader.getTestCaseNames(Foo), sorted(test_names))
+
+
+ # "it can be set to None to disable the sort."
+ #
+ # XXX How is this different from reassigning cmp? Are the tests returned
+ # in a random order or something? This behaviour should die
+ def test_sortTestMethodsUsing__None(self):
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+
+ loader = unittest.TestLoader()
+ loader.sortTestMethodsUsing = None
+
+ test_names = ['test_2', 'test_1']
+ self.assertEqual(set(loader.getTestCaseNames(Foo)), set(test_names))
+
+ ################################################################
+ ### /Tests for TestLoader.sortTestMethodsUsing
+
+ ### Tests for TestLoader.suiteClass
+ ################################################################
+
+ # "Callable object that constructs a test suite from a list of tests."
+ def test_suiteClass__loadTestsFromTestCase(self):
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+
+ tests = [Foo('test_1'), Foo('test_2')]
+
+ loader = unittest.TestLoader()
+ loader.suiteClass = list
+ self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
+
+ # It is implicit in the documentation for TestLoader.suiteClass that
+ # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
+ def test_suiteClass__loadTestsFromModule(self):
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+ m.Foo = Foo
+
+ tests = [[Foo('test_1'), Foo('test_2')]]
+
+ loader = unittest.TestLoader()
+ loader.suiteClass = list
+ self.assertEqual(loader.loadTestsFromModule(m), tests)
+
+ # It is implicit in the documentation for TestLoader.suiteClass that
+ # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
+ def test_suiteClass__loadTestsFromName(self):
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+ m.Foo = Foo
+
+ tests = [Foo('test_1'), Foo('test_2')]
+
+ loader = unittest.TestLoader()
+ loader.suiteClass = list
+ self.assertEqual(loader.loadTestsFromName('Foo', m), tests)
+
+ # It is implicit in the documentation for TestLoader.suiteClass that
+ # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
+ def test_suiteClass__loadTestsFromNames(self):
+ m = types.ModuleType('m')
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def foo_bar(self): pass
+ m.Foo = Foo
+
+ tests = [[Foo('test_1'), Foo('test_2')]]
+
+ loader = unittest.TestLoader()
+ loader.suiteClass = list
+ self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests)
+
+ # "The default value is the TestSuite class"
+ def test_suiteClass__default_value(self):
+ loader = unittest.TestLoader()
+ self.assertTrue(loader.suiteClass is unittest.TestSuite)
diff --git a/Lib/unittest/test/test_program.py b/Lib/unittest/test/test_program.py
new file mode 100644
index 0000000000..a50a2452c2
--- /dev/null
+++ b/Lib/unittest/test/test_program.py
@@ -0,0 +1,358 @@
+import io
+
+import os
+import sys
+import unittest
+
+
+class Test_TestProgram(unittest.TestCase):
+
+ def test_discovery_from_dotted_path(self):
+ loader = unittest.TestLoader()
+
+ tests = [self]
+ expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__))
+
+ self.wasRun = False
+ def _find_tests(start_dir, pattern):
+ self.wasRun = True
+ self.assertEqual(start_dir, expectedPath)
+ return tests
+ loader._find_tests = _find_tests
+ suite = loader.discover('unittest.test')
+ self.assertTrue(self.wasRun)
+ self.assertEqual(suite._tests, tests)
+
+ # Horrible white box test
+ def testNoExit(self):
+ result = object()
+ test = object()
+
+ class FakeRunner(object):
+ def run(self, test):
+ self.test = test
+ return result
+
+ runner = FakeRunner()
+
+ oldParseArgs = unittest.TestProgram.parseArgs
+ def restoreParseArgs():
+ unittest.TestProgram.parseArgs = oldParseArgs
+ unittest.TestProgram.parseArgs = lambda *args: None
+ self.addCleanup(restoreParseArgs)
+
+ def removeTest():
+ del unittest.TestProgram.test
+ unittest.TestProgram.test = test
+ self.addCleanup(removeTest)
+
+ program = unittest.TestProgram(testRunner=runner, exit=False, verbosity=2)
+
+ self.assertEqual(program.result, result)
+ self.assertEqual(runner.test, test)
+ self.assertEqual(program.verbosity, 2)
+
+ class FooBar(unittest.TestCase):
+ def testPass(self):
+ assert True
+ def testFail(self):
+ assert False
+
+ class FooBarLoader(unittest.TestLoader):
+ """Test loader that returns a suite containing FooBar."""
+ def loadTestsFromModule(self, module):
+ return self.suiteClass(
+ [self.loadTestsFromTestCase(Test_TestProgram.FooBar)])
+
+
+ def test_NonExit(self):
+ program = unittest.main(exit=False,
+ argv=["foobar"],
+ testRunner=unittest.TextTestRunner(stream=io.StringIO()),
+ testLoader=self.FooBarLoader())
+ self.assertTrue(hasattr(program, 'result'))
+
+
+ def test_Exit(self):
+ self.assertRaises(
+ SystemExit,
+ unittest.main,
+ argv=["foobar"],
+ testRunner=unittest.TextTestRunner(stream=io.StringIO()),
+ exit=True,
+ testLoader=self.FooBarLoader())
+
+
+ def test_ExitAsDefault(self):
+ self.assertRaises(
+ SystemExit,
+ unittest.main,
+ argv=["foobar"],
+ testRunner=unittest.TextTestRunner(stream=io.StringIO()),
+ testLoader=self.FooBarLoader())
+
+
+class InitialisableProgram(unittest.TestProgram):
+ exit = False
+ result = None
+ verbosity = 1
+ defaultTest = None
+ testRunner = None
+ testLoader = unittest.defaultTestLoader
+ module = '__main__'
+ progName = 'test'
+ test = 'test'
+ def __init__(self, *args):
+ pass
+
+RESULT = object()
+
+class FakeRunner(object):
+ initArgs = None
+ test = None
+ raiseError = False
+
+ def __init__(self, **kwargs):
+ FakeRunner.initArgs = kwargs
+ if FakeRunner.raiseError:
+ FakeRunner.raiseError = False
+ raise TypeError
+
+ def run(self, test):
+ FakeRunner.test = test
+ return RESULT
+
+class TestCommandLineArgs(unittest.TestCase):
+
+ def setUp(self):
+ self.program = InitialisableProgram()
+ self.program.createTests = lambda: None
+ FakeRunner.initArgs = None
+ FakeRunner.test = None
+ FakeRunner.raiseError = False
+
+ def testHelpAndUnknown(self):
+ program = self.program
+ def usageExit(msg=None):
+ program.msg = msg
+ program.exit = True
+ program.usageExit = usageExit
+
+ for opt in '-h', '-H', '--help':
+ program.exit = False
+ program.parseArgs([None, opt])
+ self.assertTrue(program.exit)
+ self.assertIsNone(program.msg)
+
+ program.parseArgs([None, '-$'])
+ self.assertTrue(program.exit)
+ self.assertIsNotNone(program.msg)
+
+ def testVerbosity(self):
+ program = self.program
+
+ for opt in '-q', '--quiet':
+ program.verbosity = 1
+ program.parseArgs([None, opt])
+ self.assertEqual(program.verbosity, 0)
+
+ for opt in '-v', '--verbose':
+ program.verbosity = 1
+ program.parseArgs([None, opt])
+ self.assertEqual(program.verbosity, 2)
+
+ def testBufferCatchFailfast(self):
+ program = self.program
+ for arg, attr in (('buffer', 'buffer'), ('failfast', 'failfast'),
+ ('catch', 'catchbreak')):
+ if attr == 'catch' and not hasInstallHandler:
+ continue
+
+ short_opt = '-%s' % arg[0]
+ long_opt = '--%s' % arg
+ for opt in short_opt, long_opt:
+ setattr(program, attr, None)
+
+ program.parseArgs([None, opt])
+ self.assertTrue(getattr(program, attr))
+
+ for opt in short_opt, long_opt:
+ not_none = object()
+ setattr(program, attr, not_none)
+
+ program.parseArgs([None, opt])
+ self.assertEqual(getattr(program, attr), not_none)
+
+ def testWarning(self):
+ """Test the warnings argument"""
+ # see #10535
+ class FakeTP(unittest.TestProgram):
+ def parseArgs(self, *args, **kw): pass
+ def runTests(self, *args, **kw): pass
+ warnoptions = sys.warnoptions
+ try:
+ sys.warnoptions[:] = []
+ # no warn options, no arg -> default
+ self.assertEqual(FakeTP().warnings, 'default')
+ # no warn options, w/ arg -> arg value
+ self.assertEqual(FakeTP(warnings='ignore').warnings, 'ignore')
+ sys.warnoptions[:] = ['somevalue']
+ # warn options, no arg -> None
+ # warn options, w/ arg -> arg value
+ self.assertEqual(FakeTP().warnings, None)
+ self.assertEqual(FakeTP(warnings='ignore').warnings, 'ignore')
+ finally:
+ sys.warnoptions[:] = warnoptions
+
+ def testRunTestsRunnerClass(self):
+ program = self.program
+
+ program.testRunner = FakeRunner
+ program.verbosity = 'verbosity'
+ program.failfast = 'failfast'
+ program.buffer = 'buffer'
+ program.warnings = 'warnings'
+
+ program.runTests()
+
+ self.assertEqual(FakeRunner.initArgs, {'verbosity': 'verbosity',
+ 'failfast': 'failfast',
+ 'buffer': 'buffer',
+ 'warnings': 'warnings'})
+ self.assertEqual(FakeRunner.test, 'test')
+ self.assertIs(program.result, RESULT)
+
+ def testRunTestsRunnerInstance(self):
+ program = self.program
+
+ program.testRunner = FakeRunner()
+ FakeRunner.initArgs = None
+
+ program.runTests()
+
+ # A new FakeRunner should not have been instantiated
+ self.assertIsNone(FakeRunner.initArgs)
+
+ self.assertEqual(FakeRunner.test, 'test')
+ self.assertIs(program.result, RESULT)
+
+ def testRunTestsOldRunnerClass(self):
+ program = self.program
+
+ FakeRunner.raiseError = True
+ program.testRunner = FakeRunner
+ program.verbosity = 'verbosity'
+ program.failfast = 'failfast'
+ program.buffer = 'buffer'
+ program.test = 'test'
+
+ program.runTests()
+
+ # If initialising raises a type error it should be retried
+ # without the new keyword arguments
+ self.assertEqual(FakeRunner.initArgs, {})
+ self.assertEqual(FakeRunner.test, 'test')
+ self.assertIs(program.result, RESULT)
+
+ def testCatchBreakInstallsHandler(self):
+ module = sys.modules['unittest.main']
+ original = module.installHandler
+ def restore():
+ module.installHandler = original
+ self.addCleanup(restore)
+
+ self.installed = False
+ def fakeInstallHandler():
+ self.installed = True
+ module.installHandler = fakeInstallHandler
+
+ program = self.program
+ program.catchbreak = True
+
+ program.testRunner = FakeRunner
+
+ program.runTests()
+ self.assertTrue(self.installed)
+
+ def _patch_isfile(self, names, exists=True):
+ def isfile(path):
+ return path in names
+ original = os.path.isfile
+ os.path.isfile = isfile
+ def restore():
+ os.path.isfile = original
+ self.addCleanup(restore)
+
+
+ def testParseArgsFileNames(self):
+ # running tests with filenames instead of module names
+ program = self.program
+ argv = ['progname', 'foo.py', 'bar.Py', 'baz.PY', 'wing.txt']
+ self._patch_isfile(argv)
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ # note that 'wing.txt' is not a Python file so the name should
+ # *not* be converted to a module name
+ expected = ['foo', 'bar', 'baz', 'wing.txt']
+ self.assertEqual(program.testNames, expected)
+
+
+ def testParseArgsFilePaths(self):
+ program = self.program
+ argv = ['progname', 'foo/bar/baz.py', 'green\\red.py']
+ self._patch_isfile(argv)
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ expected = ['foo.bar.baz', 'green.red']
+ self.assertEqual(program.testNames, expected)
+
+
+ def testParseArgsNonExistentFiles(self):
+ program = self.program
+ argv = ['progname', 'foo/bar/baz.py', 'green\\red.py']
+ self._patch_isfile([])
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ self.assertEqual(program.testNames, argv[1:])
+
+ def testParseArgsAbsolutePathsThatCanBeConverted(self):
+ cur_dir = os.getcwd()
+ program = self.program
+ def _join(name):
+ return os.path.join(cur_dir, name)
+ argv = ['progname', _join('foo/bar/baz.py'), _join('green\\red.py')]
+ self._patch_isfile(argv)
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ expected = ['foo.bar.baz', 'green.red']
+ self.assertEqual(program.testNames, expected)
+
+ def testParseArgsAbsolutePathsThatCannotBeConverted(self):
+ program = self.program
+ # even on Windows '/...' is considered absolute by os.path.abspath
+ argv = ['progname', '/foo/bar/baz.py', '/green/red.py']
+ self._patch_isfile(argv)
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ self.assertEqual(program.testNames, argv[1:])
+
+ # it may be better to use platform specific functions to normalise paths
+ # rather than accepting '.PY' and '\' as file seprator on Linux / Mac
+ # it would also be better to check that a filename is a valid module
+ # identifier (we have a regex for this in loader.py)
+ # for invalid filenames should we raise a useful error rather than
+ # leaving the current error message (import of filename fails) in place?
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/unittest/test/test_result.py b/Lib/unittest/test/test_result.py
new file mode 100644
index 0000000000..64798a1098
--- /dev/null
+++ b/Lib/unittest/test/test_result.py
@@ -0,0 +1,501 @@
+import io
+import sys
+import textwrap
+
+from test import support
+
+import traceback
+import unittest
+
+
+class Test_TestResult(unittest.TestCase):
+ # Note: there are not separate tests for TestResult.wasSuccessful(),
+ # TestResult.errors, TestResult.failures, TestResult.testsRun or
+ # TestResult.shouldStop because these only have meaning in terms of
+ # other TestResult methods.
+ #
+ # Accordingly, tests for the aforenamed attributes are incorporated
+ # in with the tests for the defining methods.
+ ################################################################
+
+ def test_init(self):
+ result = unittest.TestResult()
+
+ self.assertTrue(result.wasSuccessful())
+ self.assertEqual(len(result.errors), 0)
+ self.assertEqual(len(result.failures), 0)
+ self.assertEqual(result.testsRun, 0)
+ self.assertEqual(result.shouldStop, False)
+ self.assertIsNone(result._stdout_buffer)
+ self.assertIsNone(result._stderr_buffer)
+
+ # "This method can be called to signal that the set of tests being
+ # run should be aborted by setting the TestResult's shouldStop
+ # attribute to True."
+ def test_stop(self):
+ result = unittest.TestResult()
+
+ result.stop()
+
+ self.assertEqual(result.shouldStop, True)
+
+ # "Called when the test case test is about to be run. The default
+ # implementation simply increments the instance's testsRun counter."
+ def test_startTest(self):
+ class Foo(unittest.TestCase):
+ def test_1(self):
+ pass
+
+ test = Foo('test_1')
+
+ result = unittest.TestResult()
+
+ result.startTest(test)
+
+ self.assertTrue(result.wasSuccessful())
+ self.assertEqual(len(result.errors), 0)
+ self.assertEqual(len(result.failures), 0)
+ self.assertEqual(result.testsRun, 1)
+ self.assertEqual(result.shouldStop, False)
+
+ result.stopTest(test)
+
+ # "Called after the test case test has been executed, regardless of
+ # the outcome. The default implementation does nothing."
+ def test_stopTest(self):
+ class Foo(unittest.TestCase):
+ def test_1(self):
+ pass
+
+ test = Foo('test_1')
+
+ result = unittest.TestResult()
+
+ result.startTest(test)
+
+ self.assertTrue(result.wasSuccessful())
+ self.assertEqual(len(result.errors), 0)
+ self.assertEqual(len(result.failures), 0)
+ self.assertEqual(result.testsRun, 1)
+ self.assertEqual(result.shouldStop, False)
+
+ result.stopTest(test)
+
+ # Same tests as above; make sure nothing has changed
+ self.assertTrue(result.wasSuccessful())
+ self.assertEqual(len(result.errors), 0)
+ self.assertEqual(len(result.failures), 0)
+ self.assertEqual(result.testsRun, 1)
+ self.assertEqual(result.shouldStop, False)
+
+ # "Called before and after tests are run. The default implementation does nothing."
+ def test_startTestRun_stopTestRun(self):
+ result = unittest.TestResult()
+ result.startTestRun()
+ result.stopTestRun()
+
+ # "addSuccess(test)"
+ # ...
+ # "Called when the test case test succeeds"
+ # ...
+ # "wasSuccessful() - Returns True if all tests run so far have passed,
+ # otherwise returns False"
+ # ...
+ # "testsRun - The total number of tests run so far."
+ # ...
+ # "errors - A list containing 2-tuples of TestCase instances and
+ # formatted tracebacks. Each tuple represents a test which raised an
+ # unexpected exception. Contains formatted
+ # tracebacks instead of sys.exc_info() results."
+ # ...
+ # "failures - A list containing 2-tuples of TestCase instances and
+ # formatted tracebacks. Each tuple represents a test where a failure was
+ # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+ # methods. Contains formatted tracebacks instead
+ # of sys.exc_info() results."
+ def test_addSuccess(self):
+ class Foo(unittest.TestCase):
+ def test_1(self):
+ pass
+
+ test = Foo('test_1')
+
+ result = unittest.TestResult()
+
+ result.startTest(test)
+ result.addSuccess(test)
+ result.stopTest(test)
+
+ self.assertTrue(result.wasSuccessful())
+ self.assertEqual(len(result.errors), 0)
+ self.assertEqual(len(result.failures), 0)
+ self.assertEqual(result.testsRun, 1)
+ self.assertEqual(result.shouldStop, False)
+
+ # "addFailure(test, err)"
+ # ...
+ # "Called when the test case test signals a failure. err is a tuple of
+ # the form returned by sys.exc_info(): (type, value, traceback)"
+ # ...
+ # "wasSuccessful() - Returns True if all tests run so far have passed,
+ # otherwise returns False"
+ # ...
+ # "testsRun - The total number of tests run so far."
+ # ...
+ # "errors - A list containing 2-tuples of TestCase instances and
+ # formatted tracebacks. Each tuple represents a test which raised an
+ # unexpected exception. Contains formatted
+ # tracebacks instead of sys.exc_info() results."
+ # ...
+ # "failures - A list containing 2-tuples of TestCase instances and
+ # formatted tracebacks. Each tuple represents a test where a failure was
+ # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+ # methods. Contains formatted tracebacks instead
+ # of sys.exc_info() results."
+ def test_addFailure(self):
+ class Foo(unittest.TestCase):
+ def test_1(self):
+ pass
+
+ test = Foo('test_1')
+ try:
+ test.fail("foo")
+ except:
+ exc_info_tuple = sys.exc_info()
+
+ result = unittest.TestResult()
+
+ result.startTest(test)
+ result.addFailure(test, exc_info_tuple)
+ result.stopTest(test)
+
+ self.assertFalse(result.wasSuccessful())
+ self.assertEqual(len(result.errors), 0)
+ self.assertEqual(len(result.failures), 1)
+ self.assertEqual(result.testsRun, 1)
+ self.assertEqual(result.shouldStop, False)
+
+ test_case, formatted_exc = result.failures[0]
+ self.assertTrue(test_case is test)
+ self.assertIsInstance(formatted_exc, str)
+
+ # "addError(test, err)"
+ # ...
+ # "Called when the test case test raises an unexpected exception err
+ # is a tuple of the form returned by sys.exc_info():
+ # (type, value, traceback)"
+ # ...
+ # "wasSuccessful() - Returns True if all tests run so far have passed,
+ # otherwise returns False"
+ # ...
+ # "testsRun - The total number of tests run so far."
+ # ...
+ # "errors - A list containing 2-tuples of TestCase instances and
+ # formatted tracebacks. Each tuple represents a test which raised an
+ # unexpected exception. Contains formatted
+ # tracebacks instead of sys.exc_info() results."
+ # ...
+ # "failures - A list containing 2-tuples of TestCase instances and
+ # formatted tracebacks. Each tuple represents a test where a failure was
+ # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+ # methods. Contains formatted tracebacks instead
+ # of sys.exc_info() results."
+ def test_addError(self):
+ class Foo(unittest.TestCase):
+ def test_1(self):
+ pass
+
+ test = Foo('test_1')
+ try:
+ raise TypeError()
+ except:
+ exc_info_tuple = sys.exc_info()
+
+ result = unittest.TestResult()
+
+ result.startTest(test)
+ result.addError(test, exc_info_tuple)
+ result.stopTest(test)
+
+ self.assertFalse(result.wasSuccessful())
+ self.assertEqual(len(result.errors), 1)
+ self.assertEqual(len(result.failures), 0)
+ self.assertEqual(result.testsRun, 1)
+ self.assertEqual(result.shouldStop, False)
+
+ test_case, formatted_exc = result.errors[0]
+ self.assertTrue(test_case is test)
+ self.assertIsInstance(formatted_exc, str)
+
+ def testGetDescriptionWithoutDocstring(self):
+ result = unittest.TextTestResult(None, True, 1)
+ self.assertEqual(
+ result.getDescription(self),
+ 'testGetDescriptionWithoutDocstring (' + __name__ +
+ '.Test_TestResult)')
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def testGetDescriptionWithOneLineDocstring(self):
+ """Tests getDescription() for a method with a docstring."""
+ result = unittest.TextTestResult(None, True, 1)
+ self.assertEqual(
+ result.getDescription(self),
+ ('testGetDescriptionWithOneLineDocstring '
+ '(' + __name__ + '.Test_TestResult)\n'
+ 'Tests getDescription() for a method with a docstring.'))
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def testGetDescriptionWithMultiLineDocstring(self):
+ """Tests getDescription() for a method with a longer docstring.
+ The second line of the docstring.
+ """
+ result = unittest.TextTestResult(None, True, 1)
+ self.assertEqual(
+ result.getDescription(self),
+ ('testGetDescriptionWithMultiLineDocstring '
+ '(' + __name__ + '.Test_TestResult)\n'
+ 'Tests getDescription() for a method with a longer '
+ 'docstring.'))
+
+ def testStackFrameTrimming(self):
+ class Frame(object):
+ class tb_frame(object):
+ f_globals = {}
+ result = unittest.TestResult()
+ self.assertFalse(result._is_relevant_tb_level(Frame))
+
+ Frame.tb_frame.f_globals['__unittest'] = True
+ self.assertTrue(result._is_relevant_tb_level(Frame))
+
+ def testFailFast(self):
+ result = unittest.TestResult()
+ result._exc_info_to_string = lambda *_: ''
+ result.failfast = True
+ result.addError(None, None)
+ self.assertTrue(result.shouldStop)
+
+ result = unittest.TestResult()
+ result._exc_info_to_string = lambda *_: ''
+ result.failfast = True
+ result.addFailure(None, None)
+ self.assertTrue(result.shouldStop)
+
+ result = unittest.TestResult()
+ result._exc_info_to_string = lambda *_: ''
+ result.failfast = True
+ result.addUnexpectedSuccess(None)
+ self.assertTrue(result.shouldStop)
+
+ def testFailFastSetByRunner(self):
+ runner = unittest.TextTestRunner(stream=io.StringIO(), failfast=True)
+ def test(result):
+ self.assertTrue(result.failfast)
+ result = runner.run(test)
+
+
+classDict = dict(unittest.TestResult.__dict__)
+for m in ('addSkip', 'addExpectedFailure', 'addUnexpectedSuccess',
+ '__init__'):
+ del classDict[m]
+
+def __init__(self, stream=None, descriptions=None, verbosity=None):
+ self.failures = []
+ self.errors = []
+ self.testsRun = 0
+ self.shouldStop = False
+ self.buffer = False
+
+classDict['__init__'] = __init__
+OldResult = type('OldResult', (object,), classDict)
+
+class Test_OldTestResult(unittest.TestCase):
+
+ def assertOldResultWarning(self, test, failures):
+ with support.check_warnings(("TestResult has no add.+ method,",
+ RuntimeWarning)):
+ result = OldResult()
+ test.run(result)
+ self.assertEqual(len(result.failures), failures)
+
+ def testOldTestResult(self):
+ class Test(unittest.TestCase):
+ def testSkip(self):
+ self.skipTest('foobar')
+ @unittest.expectedFailure
+ def testExpectedFail(self):
+ raise TypeError
+ @unittest.expectedFailure
+ def testUnexpectedSuccess(self):
+ pass
+
+ for test_name, should_pass in (('testSkip', True),
+ ('testExpectedFail', True),
+ ('testUnexpectedSuccess', False)):
+ test = Test(test_name)
+ self.assertOldResultWarning(test, int(not should_pass))
+
+ def testOldTestTesultSetup(self):
+ class Test(unittest.TestCase):
+ def setUp(self):
+ self.skipTest('no reason')
+ def testFoo(self):
+ pass
+ self.assertOldResultWarning(Test('testFoo'), 0)
+
+ def testOldTestResultClass(self):
+ @unittest.skip('no reason')
+ class Test(unittest.TestCase):
+ def testFoo(self):
+ pass
+ self.assertOldResultWarning(Test('testFoo'), 0)
+
+ def testOldResultWithRunner(self):
+ class Test(unittest.TestCase):
+ def testFoo(self):
+ pass
+ runner = unittest.TextTestRunner(resultclass=OldResult,
+ stream=io.StringIO())
+ # This will raise an exception if TextTestRunner can't handle old
+ # test result objects
+ runner.run(Test('testFoo'))
+
+
+class MockTraceback(object):
+ @staticmethod
+ def format_exception(*_):
+ return ['A traceback']
+
+def restore_traceback():
+ unittest.result.traceback = traceback
+
+
+class TestOutputBuffering(unittest.TestCase):
+
+ def setUp(self):
+ self._real_out = sys.stdout
+ self._real_err = sys.stderr
+
+ def tearDown(self):
+ sys.stdout = self._real_out
+ sys.stderr = self._real_err
+
+ def testBufferOutputOff(self):
+ real_out = self._real_out
+ real_err = self._real_err
+
+ result = unittest.TestResult()
+ self.assertFalse(result.buffer)
+
+ self.assertIs(real_out, sys.stdout)
+ self.assertIs(real_err, sys.stderr)
+
+ result.startTest(self)
+
+ self.assertIs(real_out, sys.stdout)
+ self.assertIs(real_err, sys.stderr)
+
+ def testBufferOutputStartTestAddSuccess(self):
+ real_out = self._real_out
+ real_err = self._real_err
+
+ result = unittest.TestResult()
+ self.assertFalse(result.buffer)
+
+ result.buffer = True
+
+ self.assertIs(real_out, sys.stdout)
+ self.assertIs(real_err, sys.stderr)
+
+ result.startTest(self)
+
+ self.assertIsNot(real_out, sys.stdout)
+ self.assertIsNot(real_err, sys.stderr)
+ self.assertIsInstance(sys.stdout, io.StringIO)
+ self.assertIsInstance(sys.stderr, io.StringIO)
+ self.assertIsNot(sys.stdout, sys.stderr)
+
+ out_stream = sys.stdout
+ err_stream = sys.stderr
+
+ result._original_stdout = io.StringIO()
+ result._original_stderr = io.StringIO()
+
+ print('foo')
+ print('bar', file=sys.stderr)
+
+ self.assertEqual(out_stream.getvalue(), 'foo\n')
+ self.assertEqual(err_stream.getvalue(), 'bar\n')
+
+ self.assertEqual(result._original_stdout.getvalue(), '')
+ self.assertEqual(result._original_stderr.getvalue(), '')
+
+ result.addSuccess(self)
+ result.stopTest(self)
+
+ self.assertIs(sys.stdout, result._original_stdout)
+ self.assertIs(sys.stderr, result._original_stderr)
+
+ self.assertEqual(result._original_stdout.getvalue(), '')
+ self.assertEqual(result._original_stderr.getvalue(), '')
+
+ self.assertEqual(out_stream.getvalue(), '')
+ self.assertEqual(err_stream.getvalue(), '')
+
+
+ def getStartedResult(self):
+ result = unittest.TestResult()
+ result.buffer = True
+ result.startTest(self)
+ return result
+
+ def testBufferOutputAddErrorOrFailure(self):
+ unittest.result.traceback = MockTraceback
+ self.addCleanup(restore_traceback)
+
+ for message_attr, add_attr, include_error in [
+ ('errors', 'addError', True),
+ ('failures', 'addFailure', False),
+ ('errors', 'addError', True),
+ ('failures', 'addFailure', False)
+ ]:
+ result = self.getStartedResult()
+ buffered_out = sys.stdout
+ buffered_err = sys.stderr
+ result._original_stdout = io.StringIO()
+ result._original_stderr = io.StringIO()
+
+ print('foo', file=sys.stdout)
+ if include_error:
+ print('bar', file=sys.stderr)
+
+
+ addFunction = getattr(result, add_attr)
+ addFunction(self, (None, None, None))
+ result.stopTest(self)
+
+ result_list = getattr(result, message_attr)
+ self.assertEqual(len(result_list), 1)
+
+ test, message = result_list[0]
+ expectedOutMessage = textwrap.dedent("""
+ Stdout:
+ foo
+ """)
+ expectedErrMessage = ''
+ if include_error:
+ expectedErrMessage = textwrap.dedent("""
+ Stderr:
+ bar
+ """)
+
+ expectedFullMessage = 'A traceback%s%s' % (expectedOutMessage, expectedErrMessage)
+
+ self.assertIs(test, self)
+ self.assertEqual(result._original_stdout.getvalue(), expectedOutMessage)
+ self.assertEqual(result._original_stderr.getvalue(), expectedErrMessage)
+ self.assertMultiLineEqual(message, expectedFullMessage)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py
new file mode 100644
index 0000000000..8e95410e9e
--- /dev/null
+++ b/Lib/unittest/test/test_runner.py
@@ -0,0 +1,318 @@
+import io
+import os
+import sys
+import pickle
+import subprocess
+
+import unittest
+
+from .support import LoggingResult, ResultWithNoStartTestRunStopTestRun
+
+
+class TestCleanUp(unittest.TestCase):
+
+ def testCleanUp(self):
+ class TestableTest(unittest.TestCase):
+ def testNothing(self):
+ pass
+
+ test = TestableTest('testNothing')
+ self.assertEqual(test._cleanups, [])
+
+ cleanups = []
+
+ def cleanup1(*args, **kwargs):
+ cleanups.append((1, args, kwargs))
+
+ def cleanup2(*args, **kwargs):
+ cleanups.append((2, args, kwargs))
+
+ test.addCleanup(cleanup1, 1, 2, 3, four='hello', five='goodbye')
+ test.addCleanup(cleanup2)
+
+ self.assertEqual(test._cleanups,
+ [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')),
+ (cleanup2, (), {})])
+
+ self.assertTrue(test.doCleanups())
+ self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))])
+
+ def testCleanUpWithErrors(self):
+ class TestableTest(unittest.TestCase):
+ def testNothing(self):
+ pass
+
+ class MockOutcome(object):
+ success = True
+ errors = []
+
+ test = TestableTest('testNothing')
+ test._outcomeForDoCleanups = MockOutcome
+
+ exc1 = Exception('foo')
+ exc2 = Exception('bar')
+ def cleanup1():
+ raise exc1
+
+ def cleanup2():
+ raise exc2
+
+ test.addCleanup(cleanup1)
+ test.addCleanup(cleanup2)
+
+ self.assertFalse(test.doCleanups())
+ self.assertFalse(MockOutcome.success)
+
+ (Type1, instance1, _), (Type2, instance2, _) = reversed(MockOutcome.errors)
+ self.assertEqual((Type1, instance1), (Exception, exc1))
+ self.assertEqual((Type2, instance2), (Exception, exc2))
+
+ def testCleanupInRun(self):
+ blowUp = False
+ ordering = []
+
+ class TestableTest(unittest.TestCase):
+ def setUp(self):
+ ordering.append('setUp')
+ if blowUp:
+ raise Exception('foo')
+
+ def testNothing(self):
+ ordering.append('test')
+
+ def tearDown(self):
+ ordering.append('tearDown')
+
+ test = TestableTest('testNothing')
+
+ def cleanup1():
+ ordering.append('cleanup1')
+ def cleanup2():
+ ordering.append('cleanup2')
+ test.addCleanup(cleanup1)
+ test.addCleanup(cleanup2)
+
+ def success(some_test):
+ self.assertEqual(some_test, test)
+ ordering.append('success')
+
+ result = unittest.TestResult()
+ result.addSuccess = success
+
+ test.run(result)
+ self.assertEqual(ordering, ['setUp', 'test', 'tearDown',
+ 'cleanup2', 'cleanup1', 'success'])
+
+ blowUp = True
+ ordering = []
+ test = TestableTest('testNothing')
+ test.addCleanup(cleanup1)
+ test.run(result)
+ self.assertEqual(ordering, ['setUp', 'cleanup1'])
+
+ def testTestCaseDebugExecutesCleanups(self):
+ ordering = []
+
+ class TestableTest(unittest.TestCase):
+ def setUp(self):
+ ordering.append('setUp')
+ self.addCleanup(cleanup1)
+
+ def testNothing(self):
+ ordering.append('test')
+
+ def tearDown(self):
+ ordering.append('tearDown')
+
+ test = TestableTest('testNothing')
+
+ def cleanup1():
+ ordering.append('cleanup1')
+ test.addCleanup(cleanup2)
+ def cleanup2():
+ ordering.append('cleanup2')
+
+ test.debug()
+ self.assertEqual(ordering, ['setUp', 'test', 'tearDown', 'cleanup1', 'cleanup2'])
+
+
+class Test_TextTestRunner(unittest.TestCase):
+ """Tests for TextTestRunner."""
+
+ def test_init(self):
+ runner = unittest.TextTestRunner()
+ self.assertFalse(runner.failfast)
+ self.assertFalse(runner.buffer)
+ self.assertEqual(runner.verbosity, 1)
+ self.assertEqual(runner.warnings, None)
+ self.assertTrue(runner.descriptions)
+ self.assertEqual(runner.resultclass, unittest.TextTestResult)
+
+
+ def testBufferAndFailfast(self):
+ class Test(unittest.TestCase):
+ def testFoo(self):
+ pass
+ result = unittest.TestResult()
+ runner = unittest.TextTestRunner(stream=io.StringIO(), failfast=True,
+ buffer=True)
+ # Use our result object
+ runner._makeResult = lambda: result
+ runner.run(Test('testFoo'))
+
+ self.assertTrue(result.failfast)
+ self.assertTrue(result.buffer)
+
+ def testRunnerRegistersResult(self):
+ class Test(unittest.TestCase):
+ def testFoo(self):
+ pass
+ originalRegisterResult = unittest.runner.registerResult
+ def cleanup():
+ unittest.runner.registerResult = originalRegisterResult
+ self.addCleanup(cleanup)
+
+ result = unittest.TestResult()
+ runner = unittest.TextTestRunner(stream=io.StringIO())
+ # Use our result object
+ runner._makeResult = lambda: result
+
+ self.wasRegistered = 0
+ def fakeRegisterResult(thisResult):
+ self.wasRegistered += 1
+ self.assertEqual(thisResult, result)
+ unittest.runner.registerResult = fakeRegisterResult
+
+ runner.run(unittest.TestSuite())
+ self.assertEqual(self.wasRegistered, 1)
+
+ def test_works_with_result_without_startTestRun_stopTestRun(self):
+ class OldTextResult(ResultWithNoStartTestRunStopTestRun):
+ separator2 = ''
+ def printErrors(self):
+ pass
+
+ class Runner(unittest.TextTestRunner):
+ def __init__(self):
+ super(Runner, self).__init__(io.StringIO())
+
+ def _makeResult(self):
+ return OldTextResult()
+
+ runner = Runner()
+ runner.run(unittest.TestSuite())
+
+ def test_startTestRun_stopTestRun_called(self):
+ class LoggingTextResult(LoggingResult):
+ separator2 = ''
+ def printErrors(self):
+ pass
+
+ class LoggingRunner(unittest.TextTestRunner):
+ def __init__(self, events):
+ super(LoggingRunner, self).__init__(io.StringIO())
+ self._events = events
+
+ def _makeResult(self):
+ return LoggingTextResult(self._events)
+
+ events = []
+ runner = LoggingRunner(events)
+ runner.run(unittest.TestSuite())
+ expected = ['startTestRun', 'stopTestRun']
+ self.assertEqual(events, expected)
+
+ def test_pickle_unpickle(self):
+ # Issue #7197: a TextTestRunner should be (un)pickleable. This is
+ # required by test_multiprocessing under Windows (in verbose mode).
+ stream = io.StringIO("foo")
+ runner = unittest.TextTestRunner(stream)
+ for protocol in range(2, pickle.HIGHEST_PROTOCOL + 1):
+ s = pickle.dumps(runner, protocol)
+ obj = pickle.loads(s)
+ # StringIO objects never compare equal, a cheap test instead.
+ self.assertEqual(obj.stream.getvalue(), stream.getvalue())
+
+ def test_resultclass(self):
+ def MockResultClass(*args):
+ return args
+ STREAM = object()
+ DESCRIPTIONS = object()
+ VERBOSITY = object()
+ runner = unittest.TextTestRunner(STREAM, DESCRIPTIONS, VERBOSITY,
+ resultclass=MockResultClass)
+ self.assertEqual(runner.resultclass, MockResultClass)
+
+ expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
+ self.assertEqual(runner._makeResult(), expectedresult)
+
+ def test_warnings(self):
+ """
+ Check that warnings argument of TextTestRunner correctly affects the
+ behavior of the warnings.
+ """
+ # see #10535 and the _test_warnings file for more information
+
+ def get_parse_out_err(p):
+ return [b.splitlines() for b in p.communicate()]
+ opts = dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ cwd=os.path.dirname(__file__))
+ ae_msg = b'Please use assertEqual instead.'
+ at_msg = b'Please use assertTrue instead.'
+
+ # no args -> all the warnings are printed, unittest warnings only once
+ p = subprocess.Popen([sys.executable, '_test_warnings.py'], **opts)
+ out, err = get_parse_out_err(p)
+ self.assertIn(b'OK', err)
+ # check that the total number of warnings in the output is correct
+ self.assertEqual(len(out), 12)
+ # check that the numbers of the different kind of warnings is correct
+ for msg in [b'dw', b'iw', b'uw']:
+ self.assertEqual(out.count(msg), 3)
+ for msg in [ae_msg, at_msg, b'rw']:
+ self.assertEqual(out.count(msg), 1)
+
+ args_list = (
+ # passing 'ignore' as warnings arg -> no warnings
+ [sys.executable, '_test_warnings.py', 'ignore'],
+ # -W doesn't affect the result if the arg is passed
+ [sys.executable, '-Wa', '_test_warnings.py', 'ignore'],
+ # -W affects the result if the arg is not passed
+ [sys.executable, '-Wi', '_test_warnings.py']
+ )
+ # in all these cases no warnings are printed
+ for args in args_list:
+ p = subprocess.Popen(args, **opts)
+ out, err = get_parse_out_err(p)
+ self.assertIn(b'OK', err)
+ self.assertEqual(len(out), 0)
+
+
+ # passing 'always' as warnings arg -> all the warnings printed,
+ # unittest warnings only once
+ p = subprocess.Popen([sys.executable, '_test_warnings.py', 'always'],
+ **opts)
+ out, err = get_parse_out_err(p)
+ self.assertIn(b'OK', err)
+ self.assertEqual(len(out), 14)
+ for msg in [b'dw', b'iw', b'uw', b'rw']:
+ self.assertEqual(out.count(msg), 3)
+ for msg in [ae_msg, at_msg]:
+ self.assertEqual(out.count(msg), 1)
+
+ def testStdErrLookedUpAtInstantiationTime(self):
+ # see issue 10786
+ old_stderr = sys.stderr
+ f = io.StringIO()
+ sys.stderr = f
+ try:
+ runner = unittest.TextTestRunner()
+ self.assertTrue(runner.stream.stream is f)
+ finally:
+ sys.stderr = old_stderr
+
+ def testSpecifiedStreamUsed(self):
+ # see issue 10786
+ f = io.StringIO()
+ runner = unittest.TextTestRunner(f)
+ self.assertTrue(runner.stream.stream is f)
diff --git a/Lib/unittest/test/test_setups.py b/Lib/unittest/test/test_setups.py
new file mode 100644
index 0000000000..b8d5aa41e9
--- /dev/null
+++ b/Lib/unittest/test/test_setups.py
@@ -0,0 +1,507 @@
+import io
+import sys
+
+import unittest
+
+
+def resultFactory(*_):
+ return unittest.TestResult()
+
+
+class TestSetups(unittest.TestCase):
+
+ def getRunner(self):
+ return unittest.TextTestRunner(resultclass=resultFactory,
+ stream=io.StringIO())
+ def runTests(self, *cases):
+ suite = unittest.TestSuite()
+ for case in cases:
+ tests = unittest.defaultTestLoader.loadTestsFromTestCase(case)
+ suite.addTests(tests)
+
+ runner = self.getRunner()
+
+ # creating a nested suite exposes some potential bugs
+ realSuite = unittest.TestSuite()
+ realSuite.addTest(suite)
+ # adding empty suites to the end exposes potential bugs
+ suite.addTest(unittest.TestSuite())
+ realSuite.addTest(unittest.TestSuite())
+ return runner.run(realSuite)
+
+ def test_setup_class(self):
+ class Test(unittest.TestCase):
+ setUpCalled = 0
+ @classmethod
+ def setUpClass(cls):
+ Test.setUpCalled += 1
+ unittest.TestCase.setUpClass()
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ result = self.runTests(Test)
+
+ self.assertEqual(Test.setUpCalled, 1)
+ self.assertEqual(result.testsRun, 2)
+ self.assertEqual(len(result.errors), 0)
+
+ def test_teardown_class(self):
+ class Test(unittest.TestCase):
+ tearDownCalled = 0
+ @classmethod
+ def tearDownClass(cls):
+ Test.tearDownCalled += 1
+ unittest.TestCase.tearDownClass()
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ result = self.runTests(Test)
+
+ self.assertEqual(Test.tearDownCalled, 1)
+ self.assertEqual(result.testsRun, 2)
+ self.assertEqual(len(result.errors), 0)
+
+ def test_teardown_class_two_classes(self):
+ class Test(unittest.TestCase):
+ tearDownCalled = 0
+ @classmethod
+ def tearDownClass(cls):
+ Test.tearDownCalled += 1
+ unittest.TestCase.tearDownClass()
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ class Test2(unittest.TestCase):
+ tearDownCalled = 0
+ @classmethod
+ def tearDownClass(cls):
+ Test2.tearDownCalled += 1
+ unittest.TestCase.tearDownClass()
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ result = self.runTests(Test, Test2)
+
+ self.assertEqual(Test.tearDownCalled, 1)
+ self.assertEqual(Test2.tearDownCalled, 1)
+ self.assertEqual(result.testsRun, 4)
+ self.assertEqual(len(result.errors), 0)
+
+ def test_error_in_setupclass(self):
+ class BrokenTest(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ raise TypeError('foo')
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ result = self.runTests(BrokenTest)
+
+ self.assertEqual(result.testsRun, 0)
+ self.assertEqual(len(result.errors), 1)
+ error, _ = result.errors[0]
+ self.assertEqual(str(error),
+ 'setUpClass (%s.BrokenTest)' % __name__)
+
+ def test_error_in_teardown_class(self):
+ class Test(unittest.TestCase):
+ tornDown = 0
+ @classmethod
+ def tearDownClass(cls):
+ Test.tornDown += 1
+ raise TypeError('foo')
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ class Test2(unittest.TestCase):
+ tornDown = 0
+ @classmethod
+ def tearDownClass(cls):
+ Test2.tornDown += 1
+ raise TypeError('foo')
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ result = self.runTests(Test, Test2)
+ self.assertEqual(result.testsRun, 4)
+ self.assertEqual(len(result.errors), 2)
+ self.assertEqual(Test.tornDown, 1)
+ self.assertEqual(Test2.tornDown, 1)
+
+ error, _ = result.errors[0]
+ self.assertEqual(str(error),
+ 'tearDownClass (%s.Test)' % __name__)
+
+ def test_class_not_torndown_when_setup_fails(self):
+ class Test(unittest.TestCase):
+ tornDown = False
+ @classmethod
+ def setUpClass(cls):
+ raise TypeError
+ @classmethod
+ def tearDownClass(cls):
+ Test.tornDown = True
+ raise TypeError('foo')
+ def test_one(self):
+ pass
+
+ self.runTests(Test)
+ self.assertFalse(Test.tornDown)
+
+ def test_class_not_setup_or_torndown_when_skipped(self):
+ class Test(unittest.TestCase):
+ classSetUp = False
+ tornDown = False
+ @classmethod
+ def setUpClass(cls):
+ Test.classSetUp = True
+ @classmethod
+ def tearDownClass(cls):
+ Test.tornDown = True
+ def test_one(self):
+ pass
+
+ Test = unittest.skip("hop")(Test)
+ self.runTests(Test)
+ self.assertFalse(Test.classSetUp)
+ self.assertFalse(Test.tornDown)
+
+ def test_setup_teardown_order_with_pathological_suite(self):
+ results = []
+
+ class Module1(object):
+ @staticmethod
+ def setUpModule():
+ results.append('Module1.setUpModule')
+ @staticmethod
+ def tearDownModule():
+ results.append('Module1.tearDownModule')
+
+ class Module2(object):
+ @staticmethod
+ def setUpModule():
+ results.append('Module2.setUpModule')
+ @staticmethod
+ def tearDownModule():
+ results.append('Module2.tearDownModule')
+
+ class Test1(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ results.append('setup 1')
+ @classmethod
+ def tearDownClass(cls):
+ results.append('teardown 1')
+ def testOne(self):
+ results.append('Test1.testOne')
+ def testTwo(self):
+ results.append('Test1.testTwo')
+
+ class Test2(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ results.append('setup 2')
+ @classmethod
+ def tearDownClass(cls):
+ results.append('teardown 2')
+ def testOne(self):
+ results.append('Test2.testOne')
+ def testTwo(self):
+ results.append('Test2.testTwo')
+
+ class Test3(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ results.append('setup 3')
+ @classmethod
+ def tearDownClass(cls):
+ results.append('teardown 3')
+ def testOne(self):
+ results.append('Test3.testOne')
+ def testTwo(self):
+ results.append('Test3.testTwo')
+
+ Test1.__module__ = Test2.__module__ = 'Module'
+ Test3.__module__ = 'Module2'
+ sys.modules['Module'] = Module1
+ sys.modules['Module2'] = Module2
+
+ first = unittest.TestSuite((Test1('testOne'),))
+ second = unittest.TestSuite((Test1('testTwo'),))
+ third = unittest.TestSuite((Test2('testOne'),))
+ fourth = unittest.TestSuite((Test2('testTwo'),))
+ fifth = unittest.TestSuite((Test3('testOne'),))
+ sixth = unittest.TestSuite((Test3('testTwo'),))
+ suite = unittest.TestSuite((first, second, third, fourth, fifth, sixth))
+
+ runner = self.getRunner()
+ result = runner.run(suite)
+ self.assertEqual(result.testsRun, 6)
+ self.assertEqual(len(result.errors), 0)
+
+ self.assertEqual(results,
+ ['Module1.setUpModule', 'setup 1',
+ 'Test1.testOne', 'Test1.testTwo', 'teardown 1',
+ 'setup 2', 'Test2.testOne', 'Test2.testTwo',
+ 'teardown 2', 'Module1.tearDownModule',
+ 'Module2.setUpModule', 'setup 3',
+ 'Test3.testOne', 'Test3.testTwo',
+ 'teardown 3', 'Module2.tearDownModule'])
+
+ def test_setup_module(self):
+ class Module(object):
+ moduleSetup = 0
+ @staticmethod
+ def setUpModule():
+ Module.moduleSetup += 1
+
+ class Test(unittest.TestCase):
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+ Test.__module__ = 'Module'
+ sys.modules['Module'] = Module
+
+ result = self.runTests(Test)
+ self.assertEqual(Module.moduleSetup, 1)
+ self.assertEqual(result.testsRun, 2)
+ self.assertEqual(len(result.errors), 0)
+
+ def test_error_in_setup_module(self):
+ class Module(object):
+ moduleSetup = 0
+ moduleTornDown = 0
+ @staticmethod
+ def setUpModule():
+ Module.moduleSetup += 1
+ raise TypeError('foo')
+ @staticmethod
+ def tearDownModule():
+ Module.moduleTornDown += 1
+
+ class Test(unittest.TestCase):
+ classSetUp = False
+ classTornDown = False
+ @classmethod
+ def setUpClass(cls):
+ Test.classSetUp = True
+ @classmethod
+ def tearDownClass(cls):
+ Test.classTornDown = True
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ class Test2(unittest.TestCase):
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+ Test.__module__ = 'Module'
+ Test2.__module__ = 'Module'
+ sys.modules['Module'] = Module
+
+ result = self.runTests(Test, Test2)
+ self.assertEqual(Module.moduleSetup, 1)
+ self.assertEqual(Module.moduleTornDown, 0)
+ self.assertEqual(result.testsRun, 0)
+ self.assertFalse(Test.classSetUp)
+ self.assertFalse(Test.classTornDown)
+ self.assertEqual(len(result.errors), 1)
+ error, _ = result.errors[0]
+ self.assertEqual(str(error), 'setUpModule (Module)')
+
+ def test_testcase_with_missing_module(self):
+ class Test(unittest.TestCase):
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+ Test.__module__ = 'Module'
+ sys.modules.pop('Module', None)
+
+ result = self.runTests(Test)
+ self.assertEqual(result.testsRun, 2)
+
+ def test_teardown_module(self):
+ class Module(object):
+ moduleTornDown = 0
+ @staticmethod
+ def tearDownModule():
+ Module.moduleTornDown += 1
+
+ class Test(unittest.TestCase):
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+ Test.__module__ = 'Module'
+ sys.modules['Module'] = Module
+
+ result = self.runTests(Test)
+ self.assertEqual(Module.moduleTornDown, 1)
+ self.assertEqual(result.testsRun, 2)
+ self.assertEqual(len(result.errors), 0)
+
+ def test_error_in_teardown_module(self):
+ class Module(object):
+ moduleTornDown = 0
+ @staticmethod
+ def tearDownModule():
+ Module.moduleTornDown += 1
+ raise TypeError('foo')
+
+ class Test(unittest.TestCase):
+ classSetUp = False
+ classTornDown = False
+ @classmethod
+ def setUpClass(cls):
+ Test.classSetUp = True
+ @classmethod
+ def tearDownClass(cls):
+ Test.classTornDown = True
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ class Test2(unittest.TestCase):
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+ Test.__module__ = 'Module'
+ Test2.__module__ = 'Module'
+ sys.modules['Module'] = Module
+
+ result = self.runTests(Test, Test2)
+ self.assertEqual(Module.moduleTornDown, 1)
+ self.assertEqual(result.testsRun, 4)
+ self.assertTrue(Test.classSetUp)
+ self.assertTrue(Test.classTornDown)
+ self.assertEqual(len(result.errors), 1)
+ error, _ = result.errors[0]
+ self.assertEqual(str(error), 'tearDownModule (Module)')
+
+ def test_skiptest_in_setupclass(self):
+ class Test(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ raise unittest.SkipTest('foo')
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ result = self.runTests(Test)
+ self.assertEqual(result.testsRun, 0)
+ self.assertEqual(len(result.errors), 0)
+ self.assertEqual(len(result.skipped), 1)
+ skipped = result.skipped[0][0]
+ self.assertEqual(str(skipped), 'setUpClass (%s.Test)' % __name__)
+
+ def test_skiptest_in_setupmodule(self):
+ class Test(unittest.TestCase):
+ def test_one(self):
+ pass
+ def test_two(self):
+ pass
+
+ class Module(object):
+ @staticmethod
+ def setUpModule():
+ raise unittest.SkipTest('foo')
+
+ Test.__module__ = 'Module'
+ sys.modules['Module'] = Module
+
+ result = self.runTests(Test)
+ self.assertEqual(result.testsRun, 0)
+ self.assertEqual(len(result.errors), 0)
+ self.assertEqual(len(result.skipped), 1)
+ skipped = result.skipped[0][0]
+ self.assertEqual(str(skipped), 'setUpModule (Module)')
+
+ def test_suite_debug_executes_setups_and_teardowns(self):
+ ordering = []
+
+ class Module(object):
+ @staticmethod
+ def setUpModule():
+ ordering.append('setUpModule')
+ @staticmethod
+ def tearDownModule():
+ ordering.append('tearDownModule')
+
+ class Test(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ ordering.append('setUpClass')
+ @classmethod
+ def tearDownClass(cls):
+ ordering.append('tearDownClass')
+ def test_something(self):
+ ordering.append('test_something')
+
+ Test.__module__ = 'Module'
+ sys.modules['Module'] = Module
+
+ suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)
+ suite.debug()
+ expectedOrder = ['setUpModule', 'setUpClass', 'test_something', 'tearDownClass', 'tearDownModule']
+ self.assertEqual(ordering, expectedOrder)
+
+ def test_suite_debug_propagates_exceptions(self):
+ class Module(object):
+ @staticmethod
+ def setUpModule():
+ if phase == 0:
+ raise Exception('setUpModule')
+ @staticmethod
+ def tearDownModule():
+ if phase == 1:
+ raise Exception('tearDownModule')
+
+ class Test(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ if phase == 2:
+ raise Exception('setUpClass')
+ @classmethod
+ def tearDownClass(cls):
+ if phase == 3:
+ raise Exception('tearDownClass')
+ def test_something(self):
+ if phase == 4:
+ raise Exception('test_something')
+
+ Test.__module__ = 'Module'
+ sys.modules['Module'] = Module
+
+ _suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)
+ suite = unittest.TestSuite()
+ suite.addTest(_suite)
+
+ messages = ('setUpModule', 'tearDownModule', 'setUpClass', 'tearDownClass', 'test_something')
+ for phase, msg in enumerate(messages):
+ with self.assertRaisesRegex(Exception, msg):
+ suite.debug()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/unittest/test/test_skipping.py b/Lib/unittest/test/test_skipping.py
new file mode 100644
index 0000000000..b5924646c1
--- /dev/null
+++ b/Lib/unittest/test/test_skipping.py
@@ -0,0 +1,134 @@
+import unittest
+
+from .support import LoggingResult
+
+
+class Test_TestSkipping(unittest.TestCase):
+
+ def test_skipping(self):
+ class Foo(unittest.TestCase):
+ def test_skip_me(self):
+ self.skipTest("skip")
+ events = []
+ result = LoggingResult(events)
+ test = Foo("test_skip_me")
+ test.run(result)
+ self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
+ self.assertEqual(result.skipped, [(test, "skip")])
+
+ # Try letting setUp skip the test now.
+ class Foo(unittest.TestCase):
+ def setUp(self):
+ self.skipTest("testing")
+ def test_nothing(self): pass
+ events = []
+ result = LoggingResult(events)
+ test = Foo("test_nothing")
+ test.run(result)
+ self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
+ self.assertEqual(result.skipped, [(test, "testing")])
+ self.assertEqual(result.testsRun, 1)
+
+ def test_skipping_decorators(self):
+ op_table = ((unittest.skipUnless, False, True),
+ (unittest.skipIf, True, False))
+ for deco, do_skip, dont_skip in op_table:
+ class Foo(unittest.TestCase):
+ @deco(do_skip, "testing")
+ def test_skip(self): pass
+
+ @deco(dont_skip, "testing")
+ def test_dont_skip(self): pass
+ test_do_skip = Foo("test_skip")
+ test_dont_skip = Foo("test_dont_skip")
+ suite = unittest.TestSuite([test_do_skip, test_dont_skip])
+ events = []
+ result = LoggingResult(events)
+ suite.run(result)
+ self.assertEqual(len(result.skipped), 1)
+ expected = ['startTest', 'addSkip', 'stopTest',
+ 'startTest', 'addSuccess', 'stopTest']
+ self.assertEqual(events, expected)
+ self.assertEqual(result.testsRun, 2)
+ self.assertEqual(result.skipped, [(test_do_skip, "testing")])
+ self.assertTrue(result.wasSuccessful())
+
+ def test_skip_class(self):
+ @unittest.skip("testing")
+ class Foo(unittest.TestCase):
+ def test_1(self):
+ record.append(1)
+ record = []
+ result = unittest.TestResult()
+ test = Foo("test_1")
+ suite = unittest.TestSuite([test])
+ suite.run(result)
+ self.assertEqual(result.skipped, [(test, "testing")])
+ self.assertEqual(record, [])
+
+ def test_expected_failure(self):
+ class Foo(unittest.TestCase):
+ @unittest.expectedFailure
+ def test_die(self):
+ self.fail("help me!")
+ events = []
+ result = LoggingResult(events)
+ test = Foo("test_die")
+ test.run(result)
+ self.assertEqual(events,
+ ['startTest', 'addExpectedFailure', 'stopTest'])
+ self.assertEqual(result.expectedFailures[0][0], test)
+ self.assertTrue(result.wasSuccessful())
+
+ def test_unexpected_success(self):
+ class Foo(unittest.TestCase):
+ @unittest.expectedFailure
+ def test_die(self):
+ pass
+ events = []
+ result = LoggingResult(events)
+ test = Foo("test_die")
+ test.run(result)
+ self.assertEqual(events,
+ ['startTest', 'addUnexpectedSuccess', 'stopTest'])
+ self.assertFalse(result.failures)
+ self.assertEqual(result.unexpectedSuccesses, [test])
+ self.assertTrue(result.wasSuccessful())
+
+ def test_skip_doesnt_run_setup(self):
+ class Foo(unittest.TestCase):
+ wasSetUp = False
+ wasTornDown = False
+ def setUp(self):
+ Foo.wasSetUp = True
+ def tornDown(self):
+ Foo.wasTornDown = True
+ @unittest.skip('testing')
+ def test_1(self):
+ pass
+
+ result = unittest.TestResult()
+ test = Foo("test_1")
+ suite = unittest.TestSuite([test])
+ suite.run(result)
+ self.assertEqual(result.skipped, [(test, "testing")])
+ self.assertFalse(Foo.wasSetUp)
+ self.assertFalse(Foo.wasTornDown)
+
+ def test_decorated_skip(self):
+ def decorator(func):
+ def inner(*a):
+ return func(*a)
+ return inner
+
+ class Foo(unittest.TestCase):
+ @decorator
+ @unittest.skip('testing')
+ def test_1(self):
+ pass
+
+ result = unittest.TestResult()
+ test = Foo("test_1")
+ suite = unittest.TestSuite([test])
+ suite.run(result)
+ self.assertEqual(result.skipped, [(test, "testing")])
diff --git a/Lib/unittest/test/test_suite.py b/Lib/unittest/test/test_suite.py
new file mode 100644
index 0000000000..2db978ddb8
--- /dev/null
+++ b/Lib/unittest/test/test_suite.py
@@ -0,0 +1,368 @@
+import unittest
+
+import sys
+from .support import LoggingResult, TestEquality
+
+
+### Support code for Test_TestSuite
+################################################################
+
+class Test(object):
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+ def test_3(self): pass
+ def runTest(self): pass
+
+def _mk_TestSuite(*names):
+ return unittest.TestSuite(Test.Foo(n) for n in names)
+
+################################################################
+
+
+class Test_TestSuite(unittest.TestCase, TestEquality):
+
+ ### Set up attributes needed by inherited tests
+ ################################################################
+
+ # Used by TestEquality.test_eq
+ eq_pairs = [(unittest.TestSuite(), unittest.TestSuite())
+ ,(unittest.TestSuite(), unittest.TestSuite([]))
+ ,(_mk_TestSuite('test_1'), _mk_TestSuite('test_1'))]
+
+ # Used by TestEquality.test_ne
+ ne_pairs = [(unittest.TestSuite(), _mk_TestSuite('test_1'))
+ ,(unittest.TestSuite([]), _mk_TestSuite('test_1'))
+ ,(_mk_TestSuite('test_1', 'test_2'), _mk_TestSuite('test_1', 'test_3'))
+ ,(_mk_TestSuite('test_1'), _mk_TestSuite('test_2'))]
+
+ ################################################################
+ ### /Set up attributes needed by inherited tests
+
+ ### Tests for TestSuite.__init__
+ ################################################################
+
+ # "class TestSuite([tests])"
+ #
+ # The tests iterable should be optional
+ def test_init__tests_optional(self):
+ suite = unittest.TestSuite()
+
+ self.assertEqual(suite.countTestCases(), 0)
+
+ # "class TestSuite([tests])"
+ # ...
+ # "If tests is given, it must be an iterable of individual test cases
+ # or other test suites that will be used to build the suite initially"
+ #
+ # TestSuite should deal with empty tests iterables by allowing the
+ # creation of an empty suite
+ def test_init__empty_tests(self):
+ suite = unittest.TestSuite([])
+
+ self.assertEqual(suite.countTestCases(), 0)
+
+ # "class TestSuite([tests])"
+ # ...
+ # "If tests is given, it must be an iterable of individual test cases
+ # or other test suites that will be used to build the suite initially"
+ #
+ # TestSuite should allow any iterable to provide tests
+ def test_init__tests_from_any_iterable(self):
+ def tests():
+ yield unittest.FunctionTestCase(lambda: None)
+ yield unittest.FunctionTestCase(lambda: None)
+
+ suite_1 = unittest.TestSuite(tests())
+ self.assertEqual(suite_1.countTestCases(), 2)
+
+ suite_2 = unittest.TestSuite(suite_1)
+ self.assertEqual(suite_2.countTestCases(), 2)
+
+ suite_3 = unittest.TestSuite(set(suite_1))
+ self.assertEqual(suite_3.countTestCases(), 2)
+
+ # "class TestSuite([tests])"
+ # ...
+ # "If tests is given, it must be an iterable of individual test cases
+ # or other test suites that will be used to build the suite initially"
+ #
+ # Does TestSuite() also allow other TestSuite() instances to be present
+ # in the tests iterable?
+ def test_init__TestSuite_instances_in_tests(self):
+ def tests():
+ ftc = unittest.FunctionTestCase(lambda: None)
+ yield unittest.TestSuite([ftc])
+ yield unittest.FunctionTestCase(lambda: None)
+
+ suite = unittest.TestSuite(tests())
+ self.assertEqual(suite.countTestCases(), 2)
+
+ ################################################################
+ ### /Tests for TestSuite.__init__
+
+ # Container types should support the iter protocol
+ def test_iter(self):
+ test1 = unittest.FunctionTestCase(lambda: None)
+ test2 = unittest.FunctionTestCase(lambda: None)
+ suite = unittest.TestSuite((test1, test2))
+
+ self.assertEqual(list(suite), [test1, test2])
+
+ # "Return the number of tests represented by the this test object.
+ # ...this method is also implemented by the TestSuite class, which can
+ # return larger [greater than 1] values"
+ #
+ # Presumably an empty TestSuite returns 0?
+ def test_countTestCases_zero_simple(self):
+ suite = unittest.TestSuite()
+
+ self.assertEqual(suite.countTestCases(), 0)
+
+ # "Return the number of tests represented by the this test object.
+ # ...this method is also implemented by the TestSuite class, which can
+ # return larger [greater than 1] values"
+ #
+ # Presumably an empty TestSuite (even if it contains other empty
+ # TestSuite instances) returns 0?
+ def test_countTestCases_zero_nested(self):
+ class Test1(unittest.TestCase):
+ def test(self):
+ pass
+
+ suite = unittest.TestSuite([unittest.TestSuite()])
+
+ self.assertEqual(suite.countTestCases(), 0)
+
+ # "Return the number of tests represented by the this test object.
+ # ...this method is also implemented by the TestSuite class, which can
+ # return larger [greater than 1] values"
+ def test_countTestCases_simple(self):
+ test1 = unittest.FunctionTestCase(lambda: None)
+ test2 = unittest.FunctionTestCase(lambda: None)
+ suite = unittest.TestSuite((test1, test2))
+
+ self.assertEqual(suite.countTestCases(), 2)
+
+ # "Return the number of tests represented by the this test object.
+ # ...this method is also implemented by the TestSuite class, which can
+ # return larger [greater than 1] values"
+ #
+ # Make sure this holds for nested TestSuite instances, too
+ def test_countTestCases_nested(self):
+ class Test1(unittest.TestCase):
+ def test1(self): pass
+ def test2(self): pass
+
+ test2 = unittest.FunctionTestCase(lambda: None)
+ test3 = unittest.FunctionTestCase(lambda: None)
+ child = unittest.TestSuite((Test1('test2'), test2))
+ parent = unittest.TestSuite((test3, child, Test1('test1')))
+
+ self.assertEqual(parent.countTestCases(), 4)
+
+ # "Run the tests associated with this suite, collecting the result into
+ # the test result object passed as result."
+ #
+ # And if there are no tests? What then?
+ def test_run__empty_suite(self):
+ events = []
+ result = LoggingResult(events)
+
+ suite = unittest.TestSuite()
+
+ suite.run(result)
+
+ self.assertEqual(events, [])
+
+ # "Note that unlike TestCase.run(), TestSuite.run() requires the
+ # "result object to be passed in."
+ def test_run__requires_result(self):
+ suite = unittest.TestSuite()
+
+ try:
+ suite.run()
+ except TypeError:
+ pass
+ else:
+ self.fail("Failed to raise TypeError")
+
+ # "Run the tests associated with this suite, collecting the result into
+ # the test result object passed as result."
+ def test_run(self):
+ events = []
+ result = LoggingResult(events)
+
+ class LoggingCase(unittest.TestCase):
+ def run(self, result):
+ events.append('run %s' % self._testMethodName)
+
+ def test1(self): pass
+ def test2(self): pass
+
+ tests = [LoggingCase('test1'), LoggingCase('test2')]
+
+ unittest.TestSuite(tests).run(result)
+
+ self.assertEqual(events, ['run test1', 'run test2'])
+
+ # "Add a TestCase ... to the suite"
+ def test_addTest__TestCase(self):
+ class Foo(unittest.TestCase):
+ def test(self): pass
+
+ test = Foo('test')
+ suite = unittest.TestSuite()
+
+ suite.addTest(test)
+
+ self.assertEqual(suite.countTestCases(), 1)
+ self.assertEqual(list(suite), [test])
+
+ # "Add a ... TestSuite to the suite"
+ def test_addTest__TestSuite(self):
+ class Foo(unittest.TestCase):
+ def test(self): pass
+
+ suite_2 = unittest.TestSuite([Foo('test')])
+
+ suite = unittest.TestSuite()
+ suite.addTest(suite_2)
+
+ self.assertEqual(suite.countTestCases(), 1)
+ self.assertEqual(list(suite), [suite_2])
+
+ # "Add all the tests from an iterable of TestCase and TestSuite
+ # instances to this test suite."
+ #
+ # "This is equivalent to iterating over tests, calling addTest() for
+ # each element"
+ def test_addTests(self):
+ class Foo(unittest.TestCase):
+ def test_1(self): pass
+ def test_2(self): pass
+
+ test_1 = Foo('test_1')
+ test_2 = Foo('test_2')
+ inner_suite = unittest.TestSuite([test_2])
+
+ def gen():
+ yield test_1
+ yield test_2
+ yield inner_suite
+
+ suite_1 = unittest.TestSuite()
+ suite_1.addTests(gen())
+
+ self.assertEqual(list(suite_1), list(gen()))
+
+ # "This is equivalent to iterating over tests, calling addTest() for
+ # each element"
+ suite_2 = unittest.TestSuite()
+ for t in gen():
+ suite_2.addTest(t)
+
+ self.assertEqual(suite_1, suite_2)
+
+ # "Add all the tests from an iterable of TestCase and TestSuite
+ # instances to this test suite."
+ #
+ # What happens if it doesn't get an iterable?
+ def test_addTest__noniterable(self):
+ suite = unittest.TestSuite()
+
+ try:
+ suite.addTests(5)
+ except TypeError:
+ pass
+ else:
+ self.fail("Failed to raise TypeError")
+
+ def test_addTest__noncallable(self):
+ suite = unittest.TestSuite()
+ self.assertRaises(TypeError, suite.addTest, 5)
+
+ def test_addTest__casesuiteclass(self):
+ suite = unittest.TestSuite()
+ self.assertRaises(TypeError, suite.addTest, Test_TestSuite)
+ self.assertRaises(TypeError, suite.addTest, unittest.TestSuite)
+
+ def test_addTests__string(self):
+ suite = unittest.TestSuite()
+ self.assertRaises(TypeError, suite.addTests, "foo")
+
+ def test_function_in_suite(self):
+ def f(_):
+ pass
+ suite = unittest.TestSuite()
+ suite.addTest(f)
+
+ # when the bug is fixed this line will not crash
+ suite.run(unittest.TestResult())
+
+
+
+ def test_basetestsuite(self):
+ class Test(unittest.TestCase):
+ wasSetUp = False
+ wasTornDown = False
+ @classmethod
+ def setUpClass(cls):
+ cls.wasSetUp = True
+ @classmethod
+ def tearDownClass(cls):
+ cls.wasTornDown = True
+ def testPass(self):
+ pass
+ def testFail(self):
+ fail
+ class Module(object):
+ wasSetUp = False
+ wasTornDown = False
+ @staticmethod
+ def setUpModule():
+ Module.wasSetUp = True
+ @staticmethod
+ def tearDownModule():
+ Module.wasTornDown = True
+
+ Test.__module__ = 'Module'
+ sys.modules['Module'] = Module
+ self.addCleanup(sys.modules.pop, 'Module')
+
+ suite = unittest.BaseTestSuite()
+ suite.addTests([Test('testPass'), Test('testFail')])
+ self.assertEqual(suite.countTestCases(), 2)
+
+ result = unittest.TestResult()
+ suite.run(result)
+ self.assertFalse(Module.wasSetUp)
+ self.assertFalse(Module.wasTornDown)
+ self.assertFalse(Test.wasSetUp)
+ self.assertFalse(Test.wasTornDown)
+ self.assertEqual(len(result.errors), 1)
+ self.assertEqual(len(result.failures), 0)
+ self.assertEqual(result.testsRun, 2)
+
+
+ def test_overriding_call(self):
+ class MySuite(unittest.TestSuite):
+ called = False
+ def __call__(self, *args, **kw):
+ self.called = True
+ unittest.TestSuite.__call__(self, *args, **kw)
+
+ suite = MySuite()
+ result = unittest.TestResult()
+ wrapper = unittest.TestSuite()
+ wrapper.addTest(suite)
+ wrapper(result)
+ self.assertTrue(suite.called)
+
+ # reusing results should be permitted even if abominable
+ self.assertFalse(result._testRunEntered)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/unittest/util.py b/Lib/unittest/util.py
new file mode 100644
index 0000000000..ccdf0b81fa
--- /dev/null
+++ b/Lib/unittest/util.py
@@ -0,0 +1,140 @@
+"""Various utility functions."""
+
+from collections import namedtuple, OrderedDict
+
+__unittest = True
+
+_MAX_LENGTH = 80
+def safe_repr(obj, short=False):
+ try:
+ result = repr(obj)
+ except Exception:
+ result = object.__repr__(obj)
+ if not short or len(result) < _MAX_LENGTH:
+ return result
+ return result[:_MAX_LENGTH] + ' [truncated]...'
+
+def strclass(cls):
+ return "%s.%s" % (cls.__module__, cls.__name__)
+
+def sorted_list_difference(expected, actual):
+ """Finds elements in only one or the other of two, sorted input lists.
+
+ Returns a two-element tuple of lists. The first list contains those
+ elements in the "expected" list but not in the "actual" list, and the
+ second contains those elements in the "actual" list but not in the
+ "expected" list. Duplicate elements in either input list are ignored.
+ """
+ i = j = 0
+ missing = []
+ unexpected = []
+ while True:
+ try:
+ e = expected[i]
+ a = actual[j]
+ if e < a:
+ missing.append(e)
+ i += 1
+ while expected[i] == e:
+ i += 1
+ elif e > a:
+ unexpected.append(a)
+ j += 1
+ while actual[j] == a:
+ j += 1
+ else:
+ i += 1
+ try:
+ while expected[i] == e:
+ i += 1
+ finally:
+ j += 1
+ while actual[j] == a:
+ j += 1
+ except IndexError:
+ missing.extend(expected[i:])
+ unexpected.extend(actual[j:])
+ break
+ return missing, unexpected
+
+
+def unorderable_list_difference(expected, actual):
+ """Same behavior as sorted_list_difference but
+ for lists of unorderable items (like dicts).
+
+ As it does a linear search per item (remove) it
+ has O(n*n) performance."""
+ missing = []
+ while expected:
+ item = expected.pop()
+ try:
+ actual.remove(item)
+ except ValueError:
+ missing.append(item)
+
+ # anything left in actual is unexpected
+ return missing, actual
+
+def three_way_cmp(x, y):
+ """Return -1 if x < y, 0 if x == y and 1 if x > y"""
+ return (x > y) - (x < y)
+
+_Mismatch = namedtuple('Mismatch', 'actual expected value')
+
+def _count_diff_all_purpose(actual, expected):
+ 'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
+ # elements need not be hashable
+ s, t = list(actual), list(expected)
+ m, n = len(s), len(t)
+ NULL = object()
+ result = []
+ for i, elem in enumerate(s):
+ if elem is NULL:
+ continue
+ cnt_s = cnt_t = 0
+ for j in range(i, m):
+ if s[j] == elem:
+ cnt_s += 1
+ s[j] = NULL
+ for j, other_elem in enumerate(t):
+ if other_elem == elem:
+ cnt_t += 1
+ t[j] = NULL
+ if cnt_s != cnt_t:
+ diff = _Mismatch(cnt_s, cnt_t, elem)
+ result.append(diff)
+
+ for i, elem in enumerate(t):
+ if elem is NULL:
+ continue
+ cnt_t = 0
+ for j in range(i, n):
+ if t[j] == elem:
+ cnt_t += 1
+ t[j] = NULL
+ diff = _Mismatch(0, cnt_t, elem)
+ result.append(diff)
+ return result
+
+def _ordered_count(iterable):
+ 'Return dict of element counts, in the order they were first seen'
+ c = OrderedDict()
+ for elem in iterable:
+ c[elem] = c.get(elem, 0) + 1
+ return c
+
+def _count_diff_hashable(actual, expected):
+ 'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
+ # elements must be hashable
+ s, t = _ordered_count(actual), _ordered_count(expected)
+ result = []
+ for elem, cnt_s in s.items():
+ cnt_t = t.get(elem, 0)
+ if cnt_s != cnt_t:
+ diff = _Mismatch(cnt_s, cnt_t, elem)
+ result.append(diff)
+ for elem, cnt_t in t.items():
+ if elem not in s:
+ diff = _Mismatch(0, cnt_t, elem)
+ result.append(diff)
+ return result
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index b3494fa23a..9a3e42ee78 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -5,6 +5,9 @@ urlparse module is based upon the following RFC specifications.
RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding
and L. Masinter, January 2005.
+RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
+and L.Masinter, December 1999.
+
RFC 2396: "Uniform Resource Identifiers (URI)": Generic Syntax by T.
Berners-Lee, R. Fielding, and L. Masinter, August 1998.
@@ -28,8 +31,8 @@ import sys
import collections
__all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag",
- "urlsplit", "urlunsplit", "parse_qs", "parse_qsl",
- "quote", "quote_plus", "quote_from_bytes",
+ "urlsplit", "urlunsplit", "urlencode", "parse_qs",
+ "parse_qsl", "quote", "quote_plus", "quote_from_bytes",
"unquote", "unquote_plus", "unquote_to_bytes"]
# A classification of schemes ('' means apply by default)
@@ -57,6 +60,7 @@ scheme_chars = ('abcdefghijklmnopqrstuvwxyz'
'0123456789'
'+-.')
+# XXX: Consider replacing with functools.lru_cache
MAX_CACHE_SIZE = 20
_parse_cache = {}
@@ -66,64 +70,210 @@ def clear_cache():
_safe_quoters.clear()
-class ResultMixin(object):
- """Shared methods for the parsed result objects."""
+# Helpers for bytes handling
+# For 3.2, we deliberately require applications that
+# handle improperly quoted URLs to do their own
+# decoding and encoding. If valid use cases are
+# presented, we may relax this by using latin-1
+# decoding internally for 3.3
+_implicit_encoding = 'ascii'
+_implicit_errors = 'strict'
+
+def _noop(obj):
+ return obj
+
+def _encode_result(obj, encoding=_implicit_encoding,
+ errors=_implicit_errors):
+ return obj.encode(encoding, errors)
+
+def _decode_args(args, encoding=_implicit_encoding,
+ errors=_implicit_errors):
+ return tuple(x.decode(encoding, errors) if x else '' for x in args)
+
+def _coerce_args(*args):
+ # Invokes decode if necessary to create str args
+ # and returns the coerced inputs along with
+ # an appropriate result coercion function
+ # - noop for str inputs
+ # - encoding function otherwise
+ str_input = isinstance(args[0], str)
+ for arg in args[1:]:
+ # We special-case the empty string to support the
+ # "scheme=''" default argument to some functions
+ if arg and isinstance(arg, str) != str_input:
+ raise TypeError("Cannot mix str and non-str arguments")
+ if str_input:
+ return args + (_noop,)
+ return _decode_args(args) + (_encode_result,)
+
+# Result objects are more helpful than simple tuples
+class _ResultMixinStr(object):
+ """Standard approach to encoding parsed results from str to bytes"""
+ __slots__ = ()
+
+ def encode(self, encoding='ascii', errors='strict'):
+ return self._encoded_counterpart(*(x.encode(encoding, errors) for x in self))
+
+
+class _ResultMixinBytes(object):
+ """Standard approach to decoding parsed results from bytes to str"""
+ __slots__ = ()
+
+ def decode(self, encoding='ascii', errors='strict'):
+ return self._decoded_counterpart(*(x.decode(encoding, errors) for x in self))
+
+
+class _NetlocResultMixinBase(object):
+ """Shared methods for the parsed result objects containing a netloc element"""
+ __slots__ = ()
@property
def username(self):
- netloc = self.netloc
- if "@" in netloc:
- userinfo = netloc.rsplit("@", 1)[0]
- if ":" in userinfo:
- userinfo = userinfo.split(":", 1)[0]
- return userinfo
- return None
+ return self._userinfo[0]
@property
def password(self):
- netloc = self.netloc
- if "@" in netloc:
- userinfo = netloc.rsplit("@", 1)[0]
- if ":" in userinfo:
- return userinfo.split(":", 1)[1]
- return None
+ return self._userinfo[1]
@property
def hostname(self):
- netloc = self.netloc
- if "@" in netloc:
- netloc = netloc.rsplit("@", 1)[1]
- if ":" in netloc:
- netloc = netloc.split(":", 1)[0]
- return netloc.lower() or None
+ hostname = self._hostinfo[0]
+ if not hostname:
+ hostname = None
+ elif hostname is not None:
+ hostname = hostname.lower()
+ return hostname
@property
def port(self):
+ port = self._hostinfo[1]
+ if port is not None:
+ port = int(port, 10)
+ return port
+
+
+class _NetlocResultMixinStr(_NetlocResultMixinBase, _ResultMixinStr):
+ __slots__ = ()
+
+ @property
+ def _userinfo(self):
+ netloc = self.netloc
+ userinfo, have_info, hostinfo = netloc.rpartition('@')
+ if have_info:
+ username, have_password, password = userinfo.partition(':')
+ if not have_password:
+ password = None
+ else:
+ username = password = None
+ return username, password
+
+ @property
+ def _hostinfo(self):
+ netloc = self.netloc
+ _, _, hostinfo = netloc.rpartition('@')
+ _, have_open_br, bracketed = hostinfo.partition('[')
+ if have_open_br:
+ hostname, _, port = bracketed.partition(']')
+ _, have_port, port = port.partition(':')
+ else:
+ hostname, have_port, port = hostinfo.partition(':')
+ if not have_port:
+ port = None
+ return hostname, port
+
+
+class _NetlocResultMixinBytes(_NetlocResultMixinBase, _ResultMixinBytes):
+ __slots__ = ()
+
+ @property
+ def _userinfo(self):
netloc = self.netloc
- if "@" in netloc:
- netloc = netloc.rsplit("@", 1)[1]
- if ":" in netloc:
- port = netloc.split(":", 1)[1]
- return int(port, 10)
- return None
+ userinfo, have_info, hostinfo = netloc.rpartition(b'@')
+ if have_info:
+ username, have_password, password = userinfo.partition(b':')
+ if not have_password:
+ password = None
+ else:
+ username = password = None
+ return username, password
+
+ @property
+ def _hostinfo(self):
+ netloc = self.netloc
+ _, _, hostinfo = netloc.rpartition(b'@')
+ _, have_open_br, bracketed = hostinfo.partition(b'[')
+ if have_open_br:
+ hostname, _, port = bracketed.partition(b']')
+ _, have_port, port = port.partition(b':')
+ else:
+ hostname, have_port, port = hostinfo.partition(b':')
+ if not have_port:
+ port = None
+ return hostname, port
+
from collections import namedtuple
-class SplitResult(namedtuple('SplitResult', 'scheme netloc path query fragment'), ResultMixin):
+_DefragResultBase = namedtuple('DefragResult', 'url fragment')
+_SplitResultBase = namedtuple('SplitResult', 'scheme netloc path query fragment')
+_ParseResultBase = namedtuple('ParseResult', 'scheme netloc path params query fragment')
+
+# For backwards compatibility, alias _NetlocResultMixinStr
+# ResultBase is no longer part of the documented API, but it is
+# retained since deprecating it isn't worth the hassle
+ResultBase = _NetlocResultMixinStr
+# Structured result objects for string data
+class DefragResult(_DefragResultBase, _ResultMixinStr):
__slots__ = ()
+ def geturl(self):
+ if self.fragment:
+ return self.url + '#' + self.fragment
+ else:
+ return self.url
+class SplitResult(_SplitResultBase, _NetlocResultMixinStr):
+ __slots__ = ()
def geturl(self):
return urlunsplit(self)
+class ParseResult(_ParseResultBase, _NetlocResultMixinStr):
+ __slots__ = ()
+ def geturl(self):
+ return urlunparse(self)
-class ParseResult(namedtuple('ParseResult', 'scheme netloc path params query fragment'), ResultMixin):
+# Structured result objects for bytes data
+class DefragResultBytes(_DefragResultBase, _ResultMixinBytes):
+ __slots__ = ()
+ def geturl(self):
+ if self.fragment:
+ return self.url + b'#' + self.fragment
+ else:
+ return self.url
+class SplitResultBytes(_SplitResultBase, _NetlocResultMixinBytes):
__slots__ = ()
+ def geturl(self):
+ return urlunsplit(self)
+class ParseResultBytes(_ParseResultBase, _NetlocResultMixinBytes):
+ __slots__ = ()
def geturl(self):
return urlunparse(self)
+# Set up the encode/decode result pairs
+def _fix_result_transcoding():
+ _result_pairs = (
+ (DefragResult, DefragResultBytes),
+ (SplitResult, SplitResultBytes),
+ (ParseResult, ParseResultBytes),
+ )
+ for _decoded, _encoded in _result_pairs:
+ _decoded._encoded_counterpart = _encoded
+ _encoded._decoded_counterpart = _decoded
+
+_fix_result_transcoding()
+del _fix_result_transcoding
def urlparse(url, scheme='', allow_fragments=True):
"""Parse a URL into 6 components:
@@ -131,13 +281,15 @@ def urlparse(url, scheme='', allow_fragments=True):
Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't expand % escapes."""
+ url, scheme, _coerce_result = _coerce_args(url, scheme)
tuple = urlsplit(url, scheme, allow_fragments)
scheme, netloc, url, query, fragment = tuple
if scheme in uses_params and ';' in url:
url, params = _splitparams(url)
else:
params = ''
- return ParseResult(scheme, netloc, url, params, query, fragment)
+ result = ParseResult(scheme, netloc, url, params, query, fragment)
+ return _coerce_result(result)
def _splitparams(url):
if '/' in url:
@@ -162,11 +314,12 @@ def urlsplit(url, scheme='', allow_fragments=True):
Return a 5-tuple: (scheme, netloc, path, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't expand % escapes."""
+ url, scheme, _coerce_result = _coerce_args(url, scheme)
allow_fragments = bool(allow_fragments)
key = url, scheme, allow_fragments, type(url), type(scheme)
cached = _parse_cache.get(key, None)
if cached:
- return cached
+ return _coerce_result(cached)
if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth
clear_cache()
netloc = query = fragment = ''
@@ -177,13 +330,16 @@ def urlsplit(url, scheme='', allow_fragments=True):
url = url[i+1:]
if url[:2] == '//':
netloc, url = _splitnetloc(url, 2)
+ if (('[' in netloc and ']' not in netloc) or
+ (']' in netloc and '[' not in netloc)):
+ raise ValueError("Invalid IPv6 URL")
if allow_fragments and '#' in url:
url, fragment = url.split('#', 1)
if '?' in url:
url, query = url.split('?', 1)
v = SplitResult(scheme, netloc, url, query, fragment)
_parse_cache[key] = v
- return v
+ return _coerce_result(v)
if url.endswith(':') or not url[i+1].isdigit():
for c in url[:i]:
if c not in scheme_chars:
@@ -192,23 +348,27 @@ def urlsplit(url, scheme='', allow_fragments=True):
scheme, url = url[:i].lower(), url[i+1:]
if url[:2] == '//':
netloc, url = _splitnetloc(url, 2)
+ if (('[' in netloc and ']' not in netloc) or
+ (']' in netloc and '[' not in netloc)):
+ raise ValueError("Invalid IPv6 URL")
if allow_fragments and scheme in uses_fragment and '#' in url:
url, fragment = url.split('#', 1)
if scheme in uses_query and '?' in url:
url, query = url.split('?', 1)
v = SplitResult(scheme, netloc, url, query, fragment)
_parse_cache[key] = v
- return v
+ return _coerce_result(v)
def urlunparse(components):
"""Put a parsed URL back together again. This may result in a
slightly different, but equivalent URL, if the URL that was parsed
originally had redundant delimiters, e.g. a ? with an empty query
(the draft states that these are equivalent)."""
- scheme, netloc, url, params, query, fragment = components
+ scheme, netloc, url, params, query, fragment, _coerce_result = (
+ _coerce_args(*components))
if params:
url = "%s;%s" % (url, params)
- return urlunsplit((scheme, netloc, url, query, fragment))
+ return _coerce_result(urlunsplit((scheme, netloc, url, query, fragment)))
def urlunsplit(components):
"""Combine the elements of a tuple as returned by urlsplit() into a
@@ -216,7 +376,8 @@ def urlunsplit(components):
This may result in a slightly different, but equivalent URL, if the URL that
was parsed originally had unnecessary delimiters (for example, a ? with an
empty query; the RFC states that these are equivalent)."""
- scheme, netloc, url, query, fragment = components
+ scheme, netloc, url, query, fragment, _coerce_result = (
+ _coerce_args(*components))
if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
if url and url[:1] != '/': url = '/' + url
url = '//' + (netloc or '') + url
@@ -226,7 +387,7 @@ def urlunsplit(components):
url = url + '?' + query
if fragment:
url = url + '#' + fragment
- return url
+ return _coerce_result(url)
def urljoin(base, url, allow_fragments=True):
"""Join a base URL and a possibly relative URL to form an absolute
@@ -235,27 +396,28 @@ def urljoin(base, url, allow_fragments=True):
return url
if not url:
return base
+ base, url, _coerce_result = _coerce_args(base, url)
bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
urlparse(base, '', allow_fragments)
scheme, netloc, path, params, query, fragment = \
urlparse(url, bscheme, allow_fragments)
if scheme != bscheme or scheme not in uses_relative:
- return url
+ return _coerce_result(url)
if scheme in uses_netloc:
if netloc:
- return urlunparse((scheme, netloc, path,
- params, query, fragment))
+ return _coerce_result(urlunparse((scheme, netloc, path,
+ params, query, fragment)))
netloc = bnetloc
if path[:1] == '/':
- return urlunparse((scheme, netloc, path,
- params, query, fragment))
+ return _coerce_result(urlunparse((scheme, netloc, path,
+ params, query, fragment)))
if not path and not params:
path = bpath
params = bparams
if not query:
query = bquery
- return urlunparse((scheme, netloc, path,
- params, query, fragment))
+ return _coerce_result(urlunparse((scheme, netloc, path,
+ params, query, fragment)))
segments = bpath.split('/')[:-1] + path.split('/')
# XXX The stuff below is bogus in various ways...
if segments[-1] == '.':
@@ -277,8 +439,8 @@ def urljoin(base, url, allow_fragments=True):
segments[-1] = ''
elif len(segments) >= 2 and segments[-1] == '..':
segments[-2:] = ['']
- return urlunparse((scheme, netloc, '/'.join(segments),
- params, query, fragment))
+ return _coerce_result(urlunparse((scheme, netloc, '/'.join(segments),
+ params, query, fragment)))
def urldefrag(url):
"""Removes any existing fragment from URL.
@@ -287,12 +449,14 @@ def urldefrag(url):
the URL contained no fragments, the second element is the
empty string.
"""
+ url, _coerce_result = _coerce_args(url)
if '#' in url:
s, n, p, a, q, frag = urlparse(url)
defrag = urlunparse((s, n, p, a, q, ''))
- return defrag, frag
else:
- return url, ''
+ frag = ''
+ defrag = url
+ return _coerce_result(DefragResult(defrag, frag))
def unquote_to_bytes(string):
"""unquote_to_bytes('abc%20def') -> b'abc def'."""
@@ -359,7 +523,8 @@ def unquote(string, encoding='utf-8', errors='replace'):
string += pct_sequence.decode(encoding, errors)
return string
-def parse_qs(qs, keep_blank_values=False, strict_parsing=False):
+def parse_qs(qs, keep_blank_values=False, strict_parsing=False,
+ encoding='utf-8', errors='replace'):
"""Parse a query given as a string argument.
Arguments:
@@ -376,16 +541,22 @@ def parse_qs(qs, keep_blank_values=False, strict_parsing=False):
strict_parsing: flag indicating what to do with parsing errors.
If false (the default), errors are silently ignored.
If true, errors raise a ValueError exception.
+
+ encoding and errors: specify how to decode percent-encoded sequences
+ into Unicode characters, as accepted by the bytes.decode() method.
"""
dict = {}
- for name, value in parse_qsl(qs, keep_blank_values, strict_parsing):
+ pairs = parse_qsl(qs, keep_blank_values, strict_parsing,
+ encoding=encoding, errors=errors)
+ for name, value in pairs:
if name in dict:
dict[name].append(value)
else:
dict[name] = [value]
return dict
-def parse_qsl(qs, keep_blank_values=False, strict_parsing=False):
+def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
+ encoding='utf-8', errors='replace'):
"""Parse a query given as a string argument.
Arguments:
@@ -402,8 +573,12 @@ def parse_qsl(qs, keep_blank_values=False, strict_parsing=False):
false (the default), errors are silently ignored. If true,
errors raise a ValueError exception.
+ encoding and errors: specify how to decode percent-encoded sequences
+ into Unicode characters, as accepted by the bytes.decode() method.
+
Returns a list, as G-d intended.
"""
+ qs, _coerce_result = _coerce_args(qs)
pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
r = []
for name_value in pairs:
@@ -419,10 +594,13 @@ def parse_qsl(qs, keep_blank_values=False, strict_parsing=False):
else:
continue
if len(nv[1]) or keep_blank_values:
- name = unquote(nv[0].replace('+', ' '))
- value = unquote(nv[1].replace('+', ' '))
+ name = nv[0].replace('+', ' ')
+ name = unquote(name, encoding=encoding, errors=errors)
+ name = _coerce_result(name)
+ value = nv[1].replace('+', ' ')
+ value = unquote(value, encoding=encoding, errors=errors)
+ value = _coerce_result(value)
r.append((name, value))
-
return r
def unquote_plus(string, encoding='utf-8', errors='replace'):
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 087e9a606c..1e437b5b86 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -94,6 +94,7 @@ import re
import socket
import sys
import time
+import collections
from urllib.error import URLError, HTTPError, ContentTooShortError
from urllib.parse import (
@@ -114,11 +115,27 @@ else:
__version__ = sys.version[:3]
_opener = None
-def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
+def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+ *, cafile=None, capath=None):
global _opener
- if _opener is None:
- _opener = build_opener()
- return _opener.open(url, data, timeout)
+ if cafile or capath:
+ if not _have_ssl:
+ raise ValueError('SSL support not available')
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.options |= ssl.OP_NO_SSLv2
+ if cafile or capath:
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(cafile, capath)
+ check_hostname = True
+ else:
+ check_hostname = False
+ https_handler = HTTPSHandler(context=context, check_hostname=check_hostname)
+ opener = build_opener(https_handler)
+ elif _opener is None:
+ _opener = opener = build_opener()
+ else:
+ opener = _opener
+ return opener.open(url, data, timeout)
def install_opener(opener):
global _opener
@@ -1031,13 +1048,24 @@ class AbstractHTTPHandler(BaseHandler):
if request.data is not None: # POST
data = request.data
+ if isinstance(data, str):
+ raise TypeError("POST data should be bytes"
+ " or an iterable of bytes. It cannot be str.")
if not request.has_header('Content-type'):
request.add_unredirected_header(
'Content-type',
'application/x-www-form-urlencoded')
if not request.has_header('Content-length'):
- request.add_unredirected_header(
- 'Content-length', '%d' % len(data))
+ try:
+ mv = memoryview(data)
+ except TypeError:
+ if isinstance(data, collections.Iterable):
+ raise ValueError("Content-Length should be specified "
+ "for iterable data of type %r %r" % (type(data),
+ data))
+ else:
+ request.add_unredirected_header(
+ 'Content-length', '%d' % (len(mv) * mv.itemsize))
sel_host = host
if request.has_proxy():
@@ -1052,7 +1080,7 @@ class AbstractHTTPHandler(BaseHandler):
return request
- def do_open(self, http_class, req):
+ def do_open(self, http_class, req, **http_conn_args):
"""Return an HTTPResponse object for the request, using http_class.
http_class must implement the HTTPConnection API from http.client.
@@ -1061,7 +1089,8 @@ class AbstractHTTPHandler(BaseHandler):
if not host:
raise URLError('no host given')
- h = http_class(host, timeout=req.timeout) # will parse host:port
+ # will parse host:port
+ h = http_class(host, timeout=req.timeout, **http_conn_args)
headers = dict(req.unredirected_hdrs)
headers.update(dict((k, v) for k, v in req.headers.items()
@@ -1087,7 +1116,7 @@ class AbstractHTTPHandler(BaseHandler):
# Proxy-Authorization should not be sent to origin
# server.
del headers[proxy_auth_hdr]
- h._set_tunnel(req._tunnel_host, headers=tunnel_headers)
+ h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
try:
h.request(req.get_method(), req.selector, req.data, headers)
@@ -1113,10 +1142,18 @@ class HTTPHandler(AbstractHTTPHandler):
http_request = AbstractHTTPHandler.do_request_
if hasattr(http.client, 'HTTPSConnection'):
+ import ssl
+
class HTTPSHandler(AbstractHTTPHandler):
+ def __init__(self, debuglevel=0, context=None, check_hostname=None):
+ AbstractHTTPHandler.__init__(self, debuglevel)
+ self._context = context
+ self._check_hostname = check_hostname
+
def https_open(self, req):
- return self.do_open(http.client.HTTPSConnection, req)
+ return self.do_open(http.client.HTTPSConnection, req,
+ context=self._context, check_hostname=self._check_hostname)
https_request = AbstractHTTPHandler.do_request_
@@ -1202,8 +1239,8 @@ class FileHandler(BaseHandler):
url = req.selector
if url[:2] == '//' and url[2:3] != '/' and (req.host and
req.host != 'localhost'):
- req.type = 'ftp'
- return self.parent.open(req)
+ if not req.host is self.get_names():
+ raise URLError("file:// scheme is supported only on localhost")
else:
return self.open_local_file(req)
@@ -1364,9 +1401,7 @@ class CacheFTPHandler(FTPHandler):
MAXFTPCACHE = 10 # Trim the ftp cache beyond this size
# Helper for non-unix systems
-if os.name == 'mac':
- from macurl2path import url2pathname, pathname2url
-elif os.name == 'nt':
+if os.name == 'nt':
from nturl2path import url2pathname, pathname2url
else:
def url2pathname(pathname):
@@ -1505,7 +1540,7 @@ class URLopener:
try:
fp = self.open_local_file(url1)
hdrs = fp.info()
- del fp
+ fp.close()
return url2pathname(splithost(url1)[1]), hdrs
except IOError as msg:
pass
@@ -1549,8 +1584,6 @@ class URLopener:
tfp.close()
finally:
fp.close()
- del fp
- del tfp
# raise exception if actual size does not match content-length header
if size >= 0 and read < size:
@@ -1690,7 +1723,7 @@ class URLopener:
if not isinstance(url, str):
raise URLError('file error', 'proxy support for file protocol currently not implemented')
if url[:2] == '//' and url[2:3] != '/' and url[2:12].lower() != 'localhost/':
- return self.open_ftp(url)
+ raise ValueError("file:// scheme is supported only on localhost")
else:
return self.open_local_file(url)
diff --git a/Lib/uu.py b/Lib/uu.py
index 30c1ed8728..d68d29374a 100755
--- a/Lib/uu.py
+++ b/Lib/uu.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# Copyright 1994 by Lance Ellinghouse
# Cathedral City, California Republic, United States of America.
diff --git a/Lib/warnings.py b/Lib/warnings.py
index 9de2c6737b..5b5821b1c3 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -357,10 +357,10 @@ class catch_warnings(object):
# If either if the compiled regexs are None, match anything.
_warnings_defaults = False
try:
- from _warnings import (filters, default_action, once_registry,
+ from _warnings import (filters, _defaultaction, _onceregistry,
warn, warn_explicit)
- defaultaction = default_action
- onceregistry = once_registry
+ defaultaction = _defaultaction
+ onceregistry = _onceregistry
_warnings_defaults = True
except ImportError:
filters = []
@@ -371,8 +371,10 @@ except ImportError:
# Module initialization
_processoptions(sys.warnoptions)
if not _warnings_defaults:
- simplefilter("ignore", category=PendingDeprecationWarning, append=1)
- simplefilter("ignore", category=ImportWarning, append=1)
+ silence = [ImportWarning, PendingDeprecationWarning]
+ silence.append(DeprecationWarning)
+ for cls in silence:
+ simplefilter("ignore", category=cls)
bytes_warning = sys.flags.bytes_warning
if bytes_warning > 1:
bytes_action = "error"
@@ -381,4 +383,11 @@ if not _warnings_defaults:
else:
bytes_action = "ignore"
simplefilter(bytes_action, category=BytesWarning, append=1)
+ # resource usage warnings are enabled by default in pydebug mode
+ if hasattr(sys, 'gettotalrefcount'):
+ resource_action = "always"
+ else:
+ resource_action = "ignore"
+ simplefilter(resource_action, category=ResourceWarning, append=1)
+
del _warnings_defaults
diff --git a/Lib/wave.py b/Lib/wave.py
index 24839ca4ce..2877137add 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -248,7 +248,7 @@ class Wave_read:
chunk = chunk.file
chunk.size_read = chunk.size_read + nitems * self._sampwidth
data.byteswap()
- data = data.tostring()
+ data = data.tobytes()
else:
data = self._data_chunk.read(nframes * self._framesize)
if self._convert and data:
@@ -356,7 +356,7 @@ class Wave_write:
raise Error('cannot change parameters after starting to write')
if framerate <= 0:
raise Error('bad frame rate')
- self._framerate = framerate
+ self._framerate = int(round(framerate))
def getframerate(self):
if not self._framerate:
@@ -467,11 +467,11 @@ class Wave_write:
self._datalength = self._nframes * self._nchannels * self._sampwidth
self._form_length_pos = self._file.tell()
self._file.write(struct.pack('<l4s4slhhllhh4s',
- 36 + self._datalength, 'WAVE', 'fmt ', 16,
+ 36 + self._datalength, b'WAVE', b'fmt ', 16,
WAVE_FORMAT_PCM, self._nchannels, self._framerate,
self._nchannels * self._framerate * self._sampwidth,
self._nchannels * self._sampwidth,
- self._sampwidth * 8, 'data'))
+ self._sampwidth * 8, b'data'))
self._data_length_pos = self._file.tell()
self._file.write(struct.pack('<l', self._datalength))
self._headerwritten = True
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 66c4dc6ffb..468f8f1029 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -166,7 +166,7 @@ class WeakValueDictionary(collections.MutableMapping):
def popitem(self):
if self._pending_removals:
self._commit_removals()
- while 1:
+ while True:
key, wr = self.data.popitem()
o = wr()
if o is not None:
@@ -324,7 +324,7 @@ class WeakKeyDictionary(collections.MutableMapping):
try:
wr = ref(key)
except TypeError:
- return 0
+ return False
return wr in self.data
def items(self):
@@ -362,7 +362,7 @@ class WeakKeyDictionary(collections.MutableMapping):
return list(self.data)
def popitem(self):
- while 1:
+ while True:
key, value = self.data.popitem()
o = key()
if o is not None:
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index 19079858ca..415f12ac5f 100644
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Interfaces for launching and remotely controlling Web browsers."""
# Maintained by Georg Brandl.
@@ -228,15 +228,9 @@ class UnixBrowser(BaseBrowser):
else:
# for TTY browsers, we need stdin/out
inout = None
- # if possible, put browser in separate process group, so
- # keyboard interrupts don't affect browser as well as Python
- setsid = getattr(os, 'setsid', None)
- if not setsid:
- setsid = getattr(os, 'setpgrp', None)
-
p = subprocess.Popen(cmdline, close_fds=True, stdin=inout,
stdout=(self.redirect_stdout and inout or None),
- stderr=inout, preexec_fn=setsid)
+ stderr=inout, start_new_session=True)
if remote:
# wait five secons. If the subprocess is not finished, the
# remote invocation has (hopefully) started a new instance.
@@ -536,18 +530,6 @@ if sys.platform[:3] == "win":
# Platform support for MacOS
#
-try:
- import ic
-except ImportError:
- pass
-else:
- class InternetConfig(BaseBrowser):
- def open(self, url, new=0, autoraise=True):
- ic.launchurl(url)
- return True # Any way to get status?
-
- register("internet-config", InternetConfig, update_tryorder=-1)
-
if sys.platform == 'darwin':
# Adapted from patch submitted to SourceForge by Steven J. Burr
class MacOSX(BaseBrowser):
@@ -596,9 +578,35 @@ if sys.platform == 'darwin':
rc = osapipe.close()
return not rc
+ class MacOSXOSAScript(BaseBrowser):
+ def __init__(self, name):
+ self._name = name
+
+ def open(self, url, new=0, autoraise=True):
+ if self._name == 'default':
+ script = 'open location "%s"' % url.replace('"', '%22') # opens in default browser
+ else:
+ script = '''
+ tell application "%s"
+ activate
+ open location "%s"
+ end
+ '''%(self._name, url.replace('"', '%22'))
+
+ osapipe = os.popen("osascript", "w")
+ if osapipe is None:
+ return False
+
+ osapipe.write(script)
+ rc = osapipe.close()
+ return not rc
+
+
# Don't clear _tryorder or _browsers since OS X can use above Unix support
# (but we prefer using the OS X specific stuff)
- register("MacOSX", None, MacOSX('default'), -1)
+ register("safari", None, MacOSXOSAScript('safari'), -1)
+ register("firefox", None, MacOSXOSAScript('firefox'), -1)
+ register("MacOSX", None, MacOSXOSAScript('default'), -1)
#
diff --git a/Lib/wsgiref/handlers.py b/Lib/wsgiref/handlers.py
index 4a77137451..67064a6875 100644
--- a/Lib/wsgiref/handlers.py
+++ b/Lib/wsgiref/handlers.py
@@ -5,7 +5,10 @@ from .headers import Headers
import sys, os, time
-__all__ = ['BaseHandler', 'SimpleHandler', 'BaseCGIHandler', 'CGIHandler']
+__all__ = [
+ 'BaseHandler', 'SimpleHandler', 'BaseCGIHandler', 'CGIHandler',
+ 'IISCGIHandler', 'read_environ'
+]
# Weekday and month names for HTTP date/time formatting; always English!
_weekdayname = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
@@ -19,6 +22,73 @@ def format_date_time(timestamp):
_weekdayname[wd], day, _monthname[month], year, hh, mm, ss
)
+_is_request = {
+ 'SCRIPT_NAME', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_METHOD', 'AUTH_TYPE',
+ 'CONTENT_TYPE', 'CONTENT_LENGTH', 'HTTPS', 'REMOTE_USER', 'REMOTE_IDENT',
+}.__contains__
+
+def _needs_transcode(k):
+ return _is_request(k) or k.startswith('HTTP_') or k.startswith('SSL_') \
+ or (k.startswith('REDIRECT_') and _needs_transcode(k[9:]))
+
+def read_environ():
+ """Read environment, fixing HTTP variables"""
+ enc = sys.getfilesystemencoding()
+ esc = 'surrogateescape'
+ try:
+ ''.encode('utf-8', esc)
+ except LookupError:
+ esc = 'replace'
+ environ = {}
+
+ # Take the basic environment from native-unicode os.environ. Attempt to
+ # fix up the variables that come from the HTTP request to compensate for
+ # the bytes->unicode decoding step that will already have taken place.
+ for k, v in os.environ.items():
+ if _needs_transcode(k):
+
+ # On win32, the os.environ is natively Unicode. Different servers
+ # decode the request bytes using different encodings.
+ if sys.platform == 'win32':
+ software = os.environ.get('SERVER_SOFTWARE', '').lower()
+
+ # On IIS, the HTTP request will be decoded as UTF-8 as long
+ # as the input is a valid UTF-8 sequence. Otherwise it is
+ # decoded using the system code page (mbcs), with no way to
+ # detect this has happened. Because UTF-8 is the more likely
+ # encoding, and mbcs is inherently unreliable (an mbcs string
+ # that happens to be valid UTF-8 will not be decoded as mbcs)
+ # always recreate the original bytes as UTF-8.
+ if software.startswith('microsoft-iis/'):
+ v = v.encode('utf-8').decode('iso-8859-1')
+
+ # Apache mod_cgi writes bytes-as-unicode (as if ISO-8859-1) direct
+ # to the Unicode environ. No modification needed.
+ elif software.startswith('apache/'):
+ pass
+
+ # Python 3's http.server.CGIHTTPRequestHandler decodes
+ # using the urllib.unquote default of UTF-8, amongst other
+ # issues.
+ elif (
+ software.startswith('simplehttp/')
+ and 'python/3' in software
+ ):
+ v = v.encode('utf-8').decode('iso-8859-1')
+
+ # For other servers, guess that they have written bytes to
+ # the environ using stdio byte-oriented interfaces, ending up
+ # with the system code page.
+ else:
+ v = v.encode(enc, 'replace').decode('iso-8859-1')
+
+ # Recover bytes from unicode environ, using surrogate escapes
+ # where available (Python 3.1+).
+ else:
+ v = v.encode(enc, esc).decode('iso-8859-1')
+
+ environ[k] = v
+ return environ
class BaseHandler:
@@ -37,7 +107,7 @@ class BaseHandler:
# os_environ is used to supply configuration from the OS environment:
# by default it's a copy of 'os.environ' as of import time, but you can
# override this in e.g. your __init__ method.
- os_environ = dict(os.environ.items())
+ os_environ= read_environ()
# Collaborator classes
wsgi_file_wrapper = FileWrapper # set to None to disable
@@ -45,9 +115,9 @@ class BaseHandler:
# Error handling (also per-subclass or per-instance)
traceback_limit = None # Print entire traceback to self.get_stderr()
- error_status = "500 Dude, this is whack!"
+ error_status = "500 Internal Server Error"
error_headers = [('Content-Type','text/plain')]
- error_body = "A server error occurred. Please contact the administrator."
+ error_body = b"A server error occurred. Please contact the administrator."
# State variables (don't mess with these)
status = result = None
@@ -55,13 +125,6 @@ class BaseHandler:
headers = None
bytes_sent = 0
-
-
-
-
-
-
-
def run(self, application):
"""Invoke the application"""
# Note to self: don't move the close()! Asynchronous servers shouldn't
@@ -145,7 +208,7 @@ class BaseHandler:
self.set_content_length()
def start_response(self, status, headers,exc_info=None):
- """'start_response()' callable as specified by PEP 333"""
+ """'start_response()' callable as specified by PEP 3333"""
if exc_info:
try:
@@ -157,49 +220,48 @@ class BaseHandler:
elif self.headers is not None:
raise AssertionError("Headers already set!")
+ self.status = status
+ self.headers = self.headers_class(headers)
status = self._convert_string_type(status, "Status")
assert len(status)>=4,"Status must be at least 4 characters"
assert int(status[:3]),"Status message must begin w/3-digit code"
assert status[3]==" ", "Status message must have a space after code"
- str_headers = []
- for name,val in headers:
- name = self._convert_string_type(name, "Header name")
- val = self._convert_string_type(val, "Header value")
- str_headers.append((name, val))
- assert not is_hop_by_hop(name),"Hop-by-hop headers not allowed"
+ if __debug__:
+ for name, val in headers:
+ name = self._convert_string_type(name, "Header name")
+ val = self._convert_string_type(val, "Header value")
+ assert not is_hop_by_hop(name),"Hop-by-hop headers not allowed"
- self.status = status
- self.headers = self.headers_class(str_headers)
return self.write
def _convert_string_type(self, value, title):
"""Convert/check value type."""
- if isinstance(value, str):
+ if type(value) is str:
return value
- assert isinstance(value, bytes), \
- "{0} must be a string or bytes object (not {1})".format(title, value)
- return str(value, "iso-8859-1")
+ raise AssertionError(
+ "{0} must be of type str (got {1})".format(title, repr(value))
+ )
def send_preamble(self):
"""Transmit version/status/date/server, via self._write()"""
if self.origin_server:
if self.client_is_modern():
- self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
+ self._write(('HTTP/%s %s\r\n' % (self.http_version,self.status)).encode('iso-8859-1'))
if 'Date' not in self.headers:
self._write(
- 'Date: %s\r\n' % format_date_time(time.time())
+ ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
)
if self.server_software and 'Server' not in self.headers:
- self._write('Server: %s\r\n' % self.server_software)
+ self._write(('Server: %s\r\n' % self.server_software).encode('iso-8859-1'))
else:
- self._write('Status: %s\r\n' % self.status)
+ self._write(('Status: %s\r\n' % self.status).encode('iso-8859-1'))
def write(self, data):
- """'write()' callable as specified by PEP 333"""
+ """'write()' callable as specified by PEP 3333"""
- assert isinstance(data, (str, bytes)), \
- "write() argument must be a string or bytes"
+ assert type(data) is bytes, \
+ "write() argument must be a bytes instance"
if not self.status:
raise AssertionError("write() before start_response()")
@@ -266,7 +328,7 @@ class BaseHandler:
self.headers_sent = True
if not self.origin_server or self.client_is_modern():
self.send_preamble()
- self._write(str(self.headers))
+ self._write(bytes(self.headers))
def result_is_file(self):
@@ -353,15 +415,6 @@ class BaseHandler:
raise NotImplementedError
-
-
-
-
-
-
-
-
-
class SimpleHandler(BaseHandler):
"""Handler that's just initialized with streams, environment, etc.
@@ -395,12 +448,6 @@ class SimpleHandler(BaseHandler):
self.environ.update(self.base_env)
def _write(self,data):
- if isinstance(data, str):
- try:
- data = data.encode("iso-8859-1")
- except UnicodeEncodeError:
- raise ValueError("Unicode data must contain only code points"
- " representable in ISO-8859-1 encoding")
self.stdout.write(data)
def _flush(self):
@@ -432,23 +479,6 @@ class BaseCGIHandler(SimpleHandler):
origin_server = False
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
class CGIHandler(BaseCGIHandler):
"""CGI-based invocation via sys.stdin/stdout/stderr and os.environ
@@ -474,23 +504,42 @@ class CGIHandler(BaseCGIHandler):
def __init__(self):
BaseCGIHandler.__init__(
- self, sys.stdin, sys.stdout, sys.stderr, dict(os.environ.items()),
- multithread=False, multiprocess=True
+ self, sys.stdin.buffer, sys.stdout.buffer, sys.stderr,
+ read_environ(), multithread=False, multiprocess=True
)
+class IISCGIHandler(BaseCGIHandler):
+ """CGI-based invocation with workaround for IIS path bug
+ This handler should be used in preference to CGIHandler when deploying on
+ Microsoft IIS without having set the config allowPathInfo option (IIS>=7)
+ or metabase allowPathInfoForScriptMappings (IIS<7).
+ """
+ wsgi_run_once = True
+ os_environ = {}
+ # By default, IIS gives a PATH_INFO that duplicates the SCRIPT_NAME at
+ # the front, causing problems for WSGI applications that wish to implement
+ # routing. This handler strips any such duplicated path.
+ # IIS can be configured to pass the correct PATH_INFO, but this causes
+ # another bug where PATH_TRANSLATED is wrong. Luckily this variable is
+ # rarely used and is not guaranteed by WSGI. On IIS<7, though, the
+ # setting can only be made on a vhost level, affecting all other script
+ # mappings, many of which break when exposed to the PATH_TRANSLATED bug.
+ # For this reason IIS<7 is almost never deployed with the fix. (Even IIS7
+ # rarely uses it because there is still no UI for it.)
-
-
-
-
-
-
-
-
-
-
-#
+ # There is no way for CGI code to tell whether the option was set, so a
+ # separate handler class is provided.
+ def __init__(self):
+ environ= read_environ()
+ path = environ.get('PATH_INFO', '')
+ script = environ.get('SCRIPT_NAME', '')
+ if (path+'/').startswith(script+'/'):
+ environ['PATH_INFO'] = path[len(script):]
+ BaseCGIHandler.__init__(
+ self, sys.stdin.buffer, sys.stdout.buffer, sys.stderr,
+ environ, multithread=False, multiprocess=True
+ )
diff --git a/Lib/wsgiref/headers.py b/Lib/wsgiref/headers.py
index 025067a1ef..d93962831a 100644
--- a/Lib/wsgiref/headers.py
+++ b/Lib/wsgiref/headers.py
@@ -1,6 +1,6 @@
"""Manage HTTP Response Headers
-Much of this module is red-handedly pilfered from email.Message in the stdlib,
+Much of this module is red-handedly pilfered from email.message in the stdlib,
so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
"""
@@ -25,38 +25,25 @@ def _formatparam(param, value=None, quote=1):
return param
-
-
-
-
-
-
-
-
-
-
-
-
class Headers:
"""Manage a collection of HTTP response headers"""
def __init__(self,headers):
- if not isinstance(headers, list):
+ if type(headers) is not list:
raise TypeError("Headers must be a list of name/value tuples")
- self._headers = []
- for k, v in headers:
- k = self._convert_string_type(k)
- v = self._convert_string_type(v)
- self._headers.append((k, v))
+ self._headers = headers
+ if __debug__:
+ for k, v in headers:
+ self._convert_string_type(k)
+ self._convert_string_type(v)
def _convert_string_type(self, value):
"""Convert/check value type."""
- if isinstance(value, str):
+ if type(value) is str:
return value
- assert isinstance(value, bytes), ("Header names/values must be"
- " a string or bytes object (not {0})".format(value))
- return str(value, "iso-8859-1")
+ raise AssertionError("Header names/values must be"
+ " of type str (got {0})".format(repr(value)))
def __len__(self):
"""Return the total number of headers, including duplicates."""
@@ -87,10 +74,6 @@ class Headers:
"""
return self.get(name)
-
-
-
-
def __contains__(self, name):
"""Return true if the message contains the header."""
return self.get(name) is not None
@@ -127,9 +110,6 @@ class Headers:
"""
return [k for k, v in self._headers]
-
-
-
def values(self):
"""Return a list of all header values.
@@ -158,6 +138,9 @@ class Headers:
suitable for direct HTTP transmission."""
return '\r\n'.join(["%s: %s" % kv for kv in self._headers]+['',''])
+ def __bytes__(self):
+ return str(self).encode('iso-8859-1')
+
def setdefault(self,name,value):
"""Return first matching header value for 'name', or 'value'
@@ -171,7 +154,6 @@ class Headers:
else:
return result
-
def add_header(self, _name, _value, **_params):
"""Extended header setting.
@@ -184,7 +166,7 @@ class Headers:
h.add_header('content-disposition', 'attachment', filename='bud.gif')
- Note that unlike the corresponding 'email.Message' method, this does
+ Note that unlike the corresponding 'email.message' method, this does
*not* handle '(charset, language, value)' tuples: all values must be
strings or None.
"""
@@ -200,19 +182,3 @@ class Headers:
v = self._convert_string_type(v)
parts.append(_formatparam(k.replace('_', '-'), v))
self._headers.append((self._convert_string_type(_name), "; ".join(parts)))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#
diff --git a/Lib/wsgiref/simple_server.py b/Lib/wsgiref/simple_server.py
index da14144ad7..af82f953c5 100644
--- a/Lib/wsgiref/simple_server.py
+++ b/Lib/wsgiref/simple_server.py
@@ -1,4 +1,4 @@
-"""BaseHTTPServer that implements the Python WSGI protocol (PEP 333, rev 1.21)
+"""BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)
This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
@@ -15,7 +15,7 @@ import sys
import urllib.parse
from wsgiref.handlers import SimpleHandler
-__version__ = "0.1"
+__version__ = "0.2"
__all__ = ['WSGIServer', 'WSGIRequestHandler', 'demo_app', 'make_server']
@@ -38,8 +38,6 @@ class ServerHandler(SimpleHandler):
-
-
class WSGIServer(HTTPServer):
"""BaseHTTPServer that implements the Python WSGI protocol"""
@@ -69,18 +67,6 @@ class WSGIServer(HTTPServer):
-
-
-
-
-
-
-
-
-
-
-
-
class WSGIRequestHandler(BaseHTTPRequestHandler):
server_version = "WSGIServer/" + __version__
@@ -88,13 +74,14 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):
def get_environ(self):
env = self.server.base_environ.copy()
env['SERVER_PROTOCOL'] = self.request_version
+ env['SERVER_SOFTWARE'] = self.server_version
env['REQUEST_METHOD'] = self.command
if '?' in self.path:
path,query = self.path.split('?',1)
else:
path,query = self.path,''
- env['PATH_INFO'] = urllib.parse.unquote(path)
+ env['PATH_INFO'] = urllib.parse.unquote_to_bytes(path).decode('iso-8859-1')
env['QUERY_STRING'] = query
host = self.address_string()
@@ -139,29 +126,6 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
def demo_app(environ,start_response):
from io import StringIO
stdout = StringIO()
@@ -170,7 +134,7 @@ def demo_app(environ,start_response):
h = sorted(environ.items())
for k,v in h:
print(k,'=',repr(v), file=stdout)
- start_response(b"200 OK", [(b'Content-Type',b'text/plain; charset=utf-8')])
+ start_response("200 OK", [('Content-Type','text/plain; charset=utf-8')])
return [stdout.getvalue().encode("utf-8")]
@@ -190,16 +154,3 @@ if __name__ == '__main__':
import webbrowser
webbrowser.open('http://localhost:8000/xyz?abc')
httpd.handle_request() # serve one request, then exit
-
-
-
-
-
-
-
-
-
-
-
-
-#
diff --git a/Lib/wsgiref/util.py b/Lib/wsgiref/util.py
index 06eb956fdf..1f1e6cce17 100644
--- a/Lib/wsgiref/util.py
+++ b/Lib/wsgiref/util.py
@@ -32,13 +32,6 @@ class FileWrapper:
return data
raise StopIteration
-
-
-
-
-
-
-
def guess_scheme(environ):
"""Return a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
"""
@@ -161,7 +154,6 @@ def setup_testing_defaults(environ):
-
_hoppish = {
'connection':1, 'keep-alive':1, 'proxy-authenticate':1,
'proxy-authorization':1, 'te':1, 'trailers':1, 'transfer-encoding':1,
@@ -171,35 +163,3 @@ _hoppish = {
def is_hop_by_hop(header_name):
"""Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header"""
return _hoppish(header_name.lower())
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#
diff --git a/Lib/wsgiref/validate.py b/Lib/wsgiref/validate.py
index 2df3f9f7fe..05a485db7a 100644
--- a/Lib/wsgiref/validate.py
+++ b/Lib/wsgiref/validate.py
@@ -128,11 +128,10 @@ def assert_(cond, *args):
raise AssertionError(*args)
def check_string_type(value, title):
- if isinstance(value, str):
+ if type (value) is str:
return value
- assert isinstance(value, bytes), \
- "{0} must be a string or bytes object (not {1})".format(title, value)
- return str(value, "iso-8859-1")
+ raise AssertionError(
+ "{0} must be of type str (got {1})".format(title, repr(value)))
def validator(application):
@@ -197,20 +196,21 @@ class InputWrapper:
def read(self, *args):
assert_(len(args) == 1)
v = self.input.read(*args)
- assert_(isinstance(v, bytes))
+ assert_(type(v) is bytes)
return v
- def readline(self):
- v = self.input.readline()
- assert_(isinstance(v, bytes))
+ def readline(self, *args):
+ assert_(len(args) <= 1)
+ v = self.input.readline(*args)
+ assert_(type(v) is bytes)
return v
def readlines(self, *args):
assert_(len(args) <= 1)
lines = self.input.readlines(*args)
- assert_(isinstance(lines, list))
+ assert_(type(lines) is list)
for line in lines:
- assert_(isinstance(line, bytes))
+ assert_(type(line) is bytes)
return lines
def __iter__(self):
@@ -229,7 +229,7 @@ class ErrorWrapper:
self.errors = wsgi_errors
def write(self, s):
- assert_(isinstance(s, str))
+ assert_(type(s) is str)
self.errors.write(s)
def flush(self):
@@ -248,7 +248,7 @@ class WriteWrapper:
self.writer = wsgi_writer
def __call__(self, s):
- assert_(isinstance(s, (str, bytes)))
+ assert_(type(s) is bytes)
self.writer(s)
class PartialIteratorWrapper:
@@ -275,6 +275,8 @@ class IteratorWrapper:
assert_(not self.closed,
"Iterator read after closed")
v = next(self.iterator)
+ if type(v) is not bytes:
+ assert_(False, "Iterator yielded non-bytestring (%r)" % (v,))
if self.check_start_response is not None:
assert_(self.check_start_response,
"The application returns and we started iterating over its body, but start_response has not yet been called")
@@ -294,7 +296,7 @@ class IteratorWrapper:
"Iterator garbage collected without being closed")
def check_environ(environ):
- assert_(isinstance(environ, dict),
+ assert_(type(environ) is dict,
"Environment is not of the right type: %r (environment: %r)"
% (type(environ), environ))
@@ -321,11 +323,11 @@ def check_environ(environ):
if '.' in key:
# Extension, we don't care about its type
continue
- assert_(isinstance(environ[key], str),
+ assert_(type(environ[key]) is str,
"Environmental variable %s is not a string: %r (value: %r)"
% (key, type(environ[key]), environ[key]))
- assert_(isinstance(environ['wsgi.version'], tuple),
+ assert_(type(environ['wsgi.version']) is tuple,
"wsgi.version should be a tuple (%r)" % (environ['wsgi.version'],))
assert_(environ['wsgi.url_scheme'] in ('http', 'https'),
"wsgi.url_scheme unknown: %r" % environ['wsgi.url_scheme'])
@@ -385,12 +387,12 @@ def check_status(status):
% status, WSGIWarning)
def check_headers(headers):
- assert_(isinstance(headers, list),
+ assert_(type(headers) is list,
"Headers (%r) must be of type list: %r"
% (headers, type(headers)))
header_names = {}
for item in headers:
- assert_(isinstance(item, tuple),
+ assert_(type(item) is tuple,
"Individual headers (%r) must be of type tuple: %r"
% (item, type(item)))
assert_(len(item) == 2)
@@ -428,14 +430,14 @@ def check_content_type(status, headers):
assert_(0, "No Content-Type header found in headers (%s)" % headers)
def check_exc_info(exc_info):
- assert_(exc_info is None or isinstance(exc_info, tuple),
+ assert_(exc_info is None or type(exc_info) is tuple,
"exc_info (%r) is not a tuple: %r" % (exc_info, type(exc_info)))
# More exc_info checks?
def check_iterator(iterator):
- # Technically a string is legal, which is why it's a really bad
+ # Technically a bytestring is legal, which is why it's a really bad
# idea, because it may cause the response to be returned
# character-by-character
assert_(not isinstance(iterator, (str, bytes)),
"You should not return a string as your application iterator, "
- "instead return a single-item list containing that string.")
+ "instead return a single-item list containing a bytestring.")
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index d9c04d48ad..218c62ed5f 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -268,6 +268,14 @@ class Node(xml.dom.Node):
self.previousSibling = None
self.nextSibling = None
+ # A Node is its own context manager, to ensure that an unlink() call occurs.
+ # This is similar to how a file object works.
+ def __enter__(self):
+ return self
+
+ def __exit__(self, et, ev, tb):
+ self.unlink()
+
defproperty(Node, "firstChild", doc="First child node, or None.")
defproperty(Node, "lastChild", doc="Last child node, or None.")
defproperty(Node, "localName", doc="Namespace-local name of this node.")
@@ -913,6 +921,10 @@ class Childless:
raise xml.dom.NotFoundErr(
self.nodeName + " nodes do not have children")
+ def normalize(self):
+ # For childless nodes, normalize() has nothing to do.
+ pass
+
def replaceChild(self, newChild, oldChild):
raise xml.dom.HierarchyRequestErr(
self.nodeName + " nodes do not have children")
diff --git a/Lib/xml/etree/ElementInclude.py b/Lib/xml/etree/ElementInclude.py
index d7f85b3217..84fd7548b2 100644
--- a/Lib/xml/etree/ElementInclude.py
+++ b/Lib/xml/etree/ElementInclude.py
@@ -1,6 +1,6 @@
#
# ElementTree
-# $Id: ElementInclude.py 1862 2004-06-18 07:31:02Z Fredrik $
+# $Id: ElementInclude.py 3375 2008-02-13 08:05:08Z fredrik $
#
# limited xinclude support for element trees
#
@@ -16,7 +16,7 @@
# --------------------------------------------------------------------
# The ElementTree toolkit is
#
-# Copyright (c) 1999-2004 by Fredrik Lundh
+# Copyright (c) 1999-2008 by Fredrik Lundh
#
# By obtaining, using, and/or copying this software and/or its
# associated documentation, you agree that you have read, understood,
@@ -42,7 +42,7 @@
# --------------------------------------------------------------------
# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/2.4/license for licensing details.
+# See http://www.python.org/psf/license for licensing details.
##
# Limited XInclude support for the ElementTree package.
@@ -125,7 +125,7 @@ def include(elem, loader=None):
)
if i:
node = elem[i-1]
- node.tail = (node.tail or "") + text
+ node.tail = (node.tail or "") + text + (e.tail or "")
else:
elem.text = (elem.text or "") + text + (e.tail or "")
del elem[i]
diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py
index 00dbe9d546..52e65f063d 100644
--- a/Lib/xml/etree/ElementPath.py
+++ b/Lib/xml/etree/ElementPath.py
@@ -1,6 +1,6 @@
#
# ElementTree
-# $Id: ElementPath.py 1858 2004-06-17 21:31:41Z Fredrik $
+# $Id: ElementPath.py 3375 2008-02-13 08:05:08Z fredrik $
#
# limited xpath support for element trees
#
@@ -8,8 +8,13 @@
# 2003-05-23 fl created
# 2003-05-28 fl added support for // etc
# 2003-08-27 fl fixed parsing of periods in element names
+# 2007-09-10 fl new selection engine
+# 2007-09-12 fl fixed parent selector
+# 2007-09-13 fl added iterfind; changed findall to return a list
+# 2007-11-30 fl added namespaces support
+# 2009-10-30 fl added child element value filter
#
-# Copyright (c) 2003-2004 by Fredrik Lundh. All rights reserved.
+# Copyright (c) 2003-2009 by Fredrik Lundh. All rights reserved.
#
# fredrik@pythonware.com
# http://www.pythonware.com
@@ -17,7 +22,7 @@
# --------------------------------------------------------------------
# The ElementTree toolkit is
#
-# Copyright (c) 1999-2004 by Fredrik Lundh
+# Copyright (c) 1999-2009 by Fredrik Lundh
#
# By obtaining, using, and/or copying this software and/or its
# associated documentation, you agree that you have read, understood,
@@ -43,7 +48,7 @@
# --------------------------------------------------------------------
# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/2.4/license for licensing details.
+# See http://www.python.org/psf/license for licensing details.
##
# Implementation module for XPath support. There's usually no reason
@@ -53,146 +58,246 @@
import re
-xpath_tokenizer = re.compile(
- "(::|\.\.|\(\)|[/.*:\[\]\(\)@=])|((?:\{[^}]+\})?[^/:\[\]\(\)@=\s]+)|\s+"
- ).findall
+xpath_tokenizer_re = re.compile(
+ "("
+ "'[^']*'|\"[^\"]*\"|"
+ "::|"
+ "//?|"
+ "\.\.|"
+ "\(\)|"
+ "[/.*:\[\]\(\)@=])|"
+ "((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|"
+ "\s+"
+ )
-class xpath_descendant_or_self:
- pass
+def xpath_tokenizer(pattern, namespaces=None):
+ for token in xpath_tokenizer_re.findall(pattern):
+ tag = token[1]
+ if tag and tag[0] != "{" and ":" in tag:
+ try:
+ prefix, uri = tag.split(":", 1)
+ if not namespaces:
+ raise KeyError
+ yield token[0], "{%s}%s" % (namespaces[prefix], uri)
+ except KeyError:
+ raise SyntaxError("prefix %r not found in prefix map" % prefix)
+ else:
+ yield token
-##
-# Wrapper for a compiled XPath.
+def get_parent_map(context):
+ parent_map = context.parent_map
+ if parent_map is None:
+ context.parent_map = parent_map = {}
+ for p in context.root.iter():
+ for e in p:
+ parent_map[e] = p
+ return parent_map
-class Path:
+def prepare_child(next, token):
+ tag = token[1]
+ def select(context, result):
+ for elem in result:
+ for e in elem:
+ if e.tag == tag:
+ yield e
+ return select
- ##
- # Create an Path instance from an XPath expression.
+def prepare_star(next, token):
+ def select(context, result):
+ for elem in result:
+ for e in elem:
+ yield e
+ return select
- def __init__(self, path):
- tokens = xpath_tokenizer(path)
- # the current version supports 'path/path'-style expressions only
- self.path = []
- self.tag = None
- if tokens and tokens[0][0] == "/":
- raise SyntaxError("cannot use absolute path on element")
- while tokens:
- op, tag = tokens.pop(0)
- if tag or op == "*":
- self.path.append(tag or op)
- elif op == ".":
- pass
- elif op == "/":
- self.path.append(xpath_descendant_or_self())
- continue
- else:
- raise SyntaxError("unsupported path syntax (%s)" % op)
- if tokens:
- op, tag = tokens.pop(0)
- if op != "/":
- raise SyntaxError(
- "expected path separator (%s)" % (op or tag)
- )
- if self.path and isinstance(self.path[-1], xpath_descendant_or_self):
- raise SyntaxError("path cannot end with //")
- if len(self.path) == 1 and isinstance(self.path[0], type("")):
- self.tag = self.path[0]
-
- ##
- # Find first matching object.
-
- def find(self, element):
- tag = self.tag
- if tag is None:
- nodeset = self.findall(element)
- if not nodeset:
- return None
- return nodeset[0]
- for elem in element:
- if elem.tag == tag:
- return elem
- return None
+def prepare_self(next, token):
+ def select(context, result):
+ for elem in result:
+ yield elem
+ return select
- ##
- # Find text for first matching object.
-
- def findtext(self, element, default=None):
- tag = self.tag
- if tag is None:
- nodeset = self.findall(element)
- if not nodeset:
- return default
- return nodeset[0].text or ""
- for elem in element:
- if elem.tag == tag:
- return elem.text or ""
- return default
+def prepare_descendant(next, token):
+ token = next()
+ if token[0] == "*":
+ tag = "*"
+ elif not token[0]:
+ tag = token[1]
+ else:
+ raise SyntaxError("invalid descendant")
+ def select(context, result):
+ for elem in result:
+ for e in elem.iter(tag):
+ if e is not elem:
+ yield e
+ return select
- ##
- # Find all matching objects.
+def prepare_parent(next, token):
+ def select(context, result):
+ # FIXME: raise error if .. is applied at toplevel?
+ parent_map = get_parent_map(context)
+ result_map = {}
+ for elem in result:
+ if elem in parent_map:
+ parent = parent_map[elem]
+ if parent not in result_map:
+ result_map[parent] = None
+ yield parent
+ return select
- def findall(self, element):
- nodeset = [element]
- index = 0
- while 1:
- try:
- path = self.path[index]
- index = index + 1
- except IndexError:
- return nodeset
- set = []
- if isinstance(path, xpath_descendant_or_self):
+def prepare_predicate(next, token):
+ # FIXME: replace with real parser!!! refs:
+ # http://effbot.org/zone/simple-iterator-parser.htm
+ # http://javascript.crockford.com/tdop/tdop.html
+ signature = []
+ predicate = []
+ while 1:
+ token = next()
+ if token[0] == "]":
+ break
+ if token[0] and token[0][:1] in "'\"":
+ token = "'", token[0][1:-1]
+ signature.append(token[0] or "-")
+ predicate.append(token[1])
+ signature = "".join(signature)
+ # use signature to determine predicate type
+ if signature == "@-":
+ # [@attribute] predicate
+ key = predicate[1]
+ def select(context, result):
+ for elem in result:
+ if elem.get(key) is not None:
+ yield elem
+ return select
+ if signature == "@-='":
+ # [@attribute='value']
+ key = predicate[1]
+ value = predicate[-1]
+ def select(context, result):
+ for elem in result:
+ if elem.get(key) == value:
+ yield elem
+ return select
+ if signature == "-" and not re.match("\d+$", predicate[0]):
+ # [tag]
+ tag = predicate[0]
+ def select(context, result):
+ for elem in result:
+ if elem.find(tag) is not None:
+ yield elem
+ return select
+ if signature == "-='" and not re.match("\d+$", predicate[0]):
+ # [tag='value']
+ tag = predicate[0]
+ value = predicate[-1]
+ def select(context, result):
+ for elem in result:
+ for e in elem.findall(tag):
+ if "".join(e.itertext()) == value:
+ yield elem
+ break
+ return select
+ if signature == "-" or signature == "-()" or signature == "-()-":
+ # [index] or [last()] or [last()-index]
+ if signature == "-":
+ index = int(predicate[0]) - 1
+ else:
+ if predicate[0] != "last":
+ raise SyntaxError("unsupported function")
+ if signature == "-()-":
try:
- tag = self.path[index]
- if not isinstance(tag, type("")):
- tag = None
- else:
- index = index + 1
- except IndexError:
- tag = None # invalid path
- for node in nodeset:
- new = list(node.getiterator(tag))
- if new and new[0] is node:
- set.extend(new[1:])
- else:
- set.extend(new)
+ index = int(predicate[2]) - 1
+ except ValueError:
+ raise SyntaxError("unsupported expression")
else:
- for node in nodeset:
- for node in node:
- if path == "*" or node.tag == path:
- set.append(node)
- if not set:
- return []
- nodeset = set
+ index = -1
+ def select(context, result):
+ parent_map = get_parent_map(context)
+ for elem in result:
+ try:
+ parent = parent_map[elem]
+ # FIXME: what if the selector is "*" ?
+ elems = list(parent.findall(elem.tag))
+ if elems[index] is elem:
+ yield elem
+ except (IndexError, KeyError):
+ pass
+ return select
+ raise SyntaxError("invalid predicate")
+
+ops = {
+ "": prepare_child,
+ "*": prepare_star,
+ ".": prepare_self,
+ "..": prepare_parent,
+ "//": prepare_descendant,
+ "[": prepare_predicate,
+ }
_cache = {}
+class _SelectorContext:
+ parent_map = None
+ def __init__(self, root):
+ self.root = root
+
+# --------------------------------------------------------------------
+
##
-# (Internal) Compile path.
-
-def _compile(path):
- p = _cache.get(path)
- if p is not None:
- return p
- p = Path(path)
- if len(_cache) >= 100:
- _cache.clear()
- _cache[path] = p
- return p
+# Generate all matching objects.
+
+def iterfind(elem, path, namespaces=None):
+ # compile selector pattern
+ if path[-1:] == "/":
+ path = path + "*" # implicit all (FIXME: keep this?)
+ try:
+ selector = _cache[path]
+ except KeyError:
+ if len(_cache) > 100:
+ _cache.clear()
+ if path[:1] == "/":
+ raise SyntaxError("cannot use absolute path on element")
+ next = iter(xpath_tokenizer(path, namespaces)).__next__
+ token = next()
+ selector = []
+ while 1:
+ try:
+ selector.append(ops[token[0]](next, token))
+ except StopIteration:
+ raise SyntaxError("invalid path")
+ try:
+ token = next()
+ if token[0] == "/":
+ token = next()
+ except StopIteration:
+ break
+ _cache[path] = selector
+ # execute selector pattern
+ result = [elem]
+ context = _SelectorContext(elem)
+ for select in selector:
+ result = select(context, result)
+ return result
##
# Find first matching object.
-def find(element, path):
- return _compile(path).find(element)
+def find(elem, path, namespaces=None):
+ try:
+ return next(iterfind(elem, path, namespaces))
+ except StopIteration:
+ return None
##
-# Find text for first matching object.
+# Find all matching objects.
-def findtext(element, path, default=None):
- return _compile(path).findtext(element, default)
+def findall(elem, path, namespaces=None):
+ return list(iterfind(elem, path, namespaces))
##
-# Find all matching objects.
+# Find text for first matching object.
-def findall(element, path):
- return _compile(path).findall(element)
+def findtext(elem, path, default=None, namespaces=None):
+ try:
+ elem = next(iterfind(elem, path, namespaces))
+ return elem.text or ""
+ except StopIteration:
+ return default
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index c47573e313..ba33879784 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -1,40 +1,24 @@
#
# ElementTree
-# $Id: ElementTree.py 2326 2005-03-17 07:45:21Z fredrik $
+# $Id: ElementTree.py 3440 2008-07-18 14:45:01Z fredrik $
#
-# light-weight XML support for Python 1.5.2 and later.
+# light-weight XML support for Python 2.3 and later.
#
-# history:
-# 2001-10-20 fl created (from various sources)
-# 2001-11-01 fl return root from parse method
-# 2002-02-16 fl sort attributes in lexical order
-# 2002-04-06 fl TreeBuilder refactoring, added PythonDoc markup
-# 2002-05-01 fl finished TreeBuilder refactoring
-# 2002-07-14 fl added basic namespace support to ElementTree.write
-# 2002-07-25 fl added QName attribute support
-# 2002-10-20 fl fixed encoding in write
-# 2002-11-24 fl changed default encoding to ascii; fixed attribute encoding
-# 2002-11-27 fl accept file objects or file names for parse/write
-# 2002-12-04 fl moved XMLTreeBuilder back to this module
-# 2003-01-11 fl fixed entity encoding glitch for us-ascii
-# 2003-02-13 fl added XML literal factory
-# 2003-02-21 fl added ProcessingInstruction/PI factory
-# 2003-05-11 fl added tostring/fromstring helpers
-# 2003-05-26 fl added ElementPath support
-# 2003-07-05 fl added makeelement factory method
-# 2003-07-28 fl added more well-known namespace prefixes
-# 2003-08-15 fl fixed typo in ElementTree.findtext (Thomas Dartsch)
-# 2003-09-04 fl fall back on emulator if ElementPath is not installed
-# 2003-10-31 fl markup updates
-# 2003-11-15 fl fixed nested namespace bug
-# 2004-03-28 fl added XMLID helper
-# 2004-06-02 fl added default support to findtext
-# 2004-06-08 fl fixed encoding of non-ascii element/attribute names
-# 2004-08-23 fl take advantage of post-2.1 expat features
-# 2005-02-01 fl added iterparse implementation
-# 2005-03-02 fl fixed iterparse support for pre-2.2 versions
+# history (since 1.2.6):
+# 2005-11-12 fl added tostringlist/fromstringlist helpers
+# 2006-07-05 fl merged in selected changes from the 1.3 sandbox
+# 2006-07-05 fl removed support for 2.1 and earlier
+# 2007-06-21 fl added deprecation/future warnings
+# 2007-08-25 fl added doctype hook, added parser version attribute etc
+# 2007-08-26 fl added new serializer code (better namespace handling, etc)
+# 2007-08-27 fl warn for broken /tag searches on tree level
+# 2007-09-02 fl added html/text methods to serializer (experimental)
+# 2007-09-05 fl added method argument to tostring/tostringlist
+# 2007-09-06 fl improved error handling
+# 2007-09-13 fl added itertext, iterfind; assorted cleanups
+# 2007-12-15 fl added C14N hooks, copy method (experimental)
#
-# Copyright (c) 1999-2005 by Fredrik Lundh. All rights reserved.
+# Copyright (c) 1999-2008 by Fredrik Lundh. All rights reserved.
#
# fredrik@pythonware.com
# http://www.pythonware.com
@@ -42,7 +26,7 @@
# --------------------------------------------------------------------
# The ElementTree toolkit is
#
-# Copyright (c) 1999-2005 by Fredrik Lundh
+# Copyright (c) 1999-2008 by Fredrik Lundh
#
# By obtaining, using, and/or copying this software and/or its
# associated documentation, you agree that you have read, understood,
@@ -68,25 +52,28 @@
# --------------------------------------------------------------------
# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/2.4/license for licensing details.
+# See http://www.python.org/psf/license for licensing details.
__all__ = [
# public symbols
"Comment",
"dump",
"Element", "ElementTree",
- "fromstring",
+ "fromstring", "fromstringlist",
"iselement", "iterparse",
- "parse",
+ "parse", "ParseError",
"PI", "ProcessingInstruction",
"QName",
"SubElement",
- "tostring",
+ "tostring", "tostringlist",
"TreeBuilder",
- "VERSION", "XML",
+ "VERSION",
+ "XML",
"XMLParser", "XMLTreeBuilder",
]
+VERSION = "1.3.0"
+
##
# The <b>Element</b> type is a flexible container object, designed to
# store hierarchical data structures in memory. The type can be
@@ -102,36 +89,86 @@ __all__ = [
# <li>a number of <i>child elements</i>, stored in a Python sequence</li>
# </ul>
#
-# To create an element instance, use the {@link #Element} or {@link
-# #SubElement} factory functions.
+# To create an element instance, use the {@link #Element} constructor
+# or the {@link #SubElement} factory function.
# <p>
# The {@link #ElementTree} class can be used to wrap an element
# structure, and convert it from and to XML.
##
-import sys, re
+import sys
+import re
+import warnings
+
+
+class _SimpleElementPath:
+ # emulate pre-1.2 find/findtext/findall behaviour
+ def find(self, element, tag, namespaces=None):
+ for elem in element:
+ if elem.tag == tag:
+ return elem
+ return None
+ def findtext(self, element, tag, default=None, namespaces=None):
+ elem = self.find(element, tag)
+ if elem is None:
+ return default
+ return elem.text or ""
+ def iterfind(self, element, tag, namespaces=None):
+ if tag[:3] == ".//":
+ for elem in element.iter(tag[3:]):
+ yield elem
+ for elem in element:
+ if elem.tag == tag:
+ yield elem
+ def findall(self, element, tag, namespaces=None):
+ return list(self.iterfind(element, tag, namespaces))
+
+try:
+ from . import ElementPath
+except ImportError:
+ ElementPath = _SimpleElementPath()
+
+##
+# Parser error. This is a subclass of <b>SyntaxError</b>.
+# <p>
+# In addition to the exception value, an exception instance contains a
+# specific exception code in the <b>code</b> attribute, and the line and
+# column of the error in the <b>position</b> attribute.
+
+class ParseError(SyntaxError):
+ pass
-from . import ElementPath
+# --------------------------------------------------------------------
-# TODO: add support for custom namespace resolvers/default namespaces
-# TODO: add improved support for incremental parsing
+##
+# Checks if an object appears to be a valid element object.
+#
+# @param An element instance.
+# @return A true value if this is an element object.
+# @defreturn flag
-VERSION = "1.2.6"
+def iselement(element):
+ # FIXME: not sure about this; might be a better idea to look
+ # for tag/attrib/text attributes
+ return isinstance(element, Element) or hasattr(element, "tag")
##
-# Internal element class. This class defines the Element interface,
-# and provides a reference implementation of this interface.
+# Element class. This class defines the Element interface, and
+# provides a reference implementation of this interface.
# <p>
-# You should not create instances of this class directly. Use the
-# appropriate factory functions instead, such as {@link #Element}
-# and {@link #SubElement}.
+# The element name, attribute names, and attribute values can be
+# either ASCII strings (ordinary Python strings containing only 7-bit
+# ASCII characters) or Unicode strings.
#
+# @param tag The element name.
+# @param attrib An optional dictionary, containing element attributes.
+# @param **extra Additional attributes, given as keyword arguments.
# @see Element
# @see SubElement
# @see Comment
# @see ProcessingInstruction
-class _ElementInterface:
+class Element:
# <tag attrib>text<child/>...</tag>tail
##
@@ -141,34 +178,41 @@ class _ElementInterface:
##
# (Attribute) Element attribute dictionary. Where possible, use
- # {@link #_ElementInterface.get},
- # {@link #_ElementInterface.set},
- # {@link #_ElementInterface.keys}, and
- # {@link #_ElementInterface.items} to access
+ # {@link #Element.get},
+ # {@link #Element.set},
+ # {@link #Element.keys}, and
+ # {@link #Element.items} to access
# element attributes.
attrib = None
##
# (Attribute) Text before first subelement. This is either a
- # string or the value None, if there was no text.
+ # string or the value None. Note that if there was no text, this
+ # attribute may be either None or an empty string, depending on
+ # the parser.
text = None
##
# (Attribute) Text after this element's end tag, but before the
# next sibling element's start tag. This is either a string or
- # the value None, if there was no text.
+ # the value None. Note that if there was no text, this attribute
+ # may be either None or an empty string, depending on the parser.
tail = None # text after end tag, if any
- def __init__(self, tag, attrib):
+ # constructor
+
+ def __init__(self, tag, attrib={}, **extra):
+ attrib = attrib.copy()
+ attrib.update(extra)
self.tag = tag
self.attrib = attrib
self._children = []
def __repr__(self):
- return "<Element %s at %x>" % (self.tag, id(self))
+ return "<Element %s at 0x%x>" % (repr(self.tag), id(self))
##
# Creates a new element object of the same type as this element.
@@ -178,18 +222,41 @@ class _ElementInterface:
# @return A new element instance.
def makeelement(self, tag, attrib):
- return Element(tag, attrib)
+ return self.__class__(tag, attrib)
##
- # Returns the number of subelements.
+ # (Experimental) Copies the current element. This creates a
+ # shallow copy; subelements will be shared with the original tree.
+ #
+ # @return A new element instance.
+
+ def copy(self):
+ elem = self.makeelement(self.tag, self.attrib)
+ elem.text = self.text
+ elem.tail = self.tail
+ elem[:] = self
+ return elem
+
+ ##
+ # Returns the number of subelements. Note that this only counts
+ # full elements; to check if there's any content in an element, you
+ # have to check both the length and the <b>text</b> attribute.
#
# @return The number of subelements.
def __len__(self):
return len(self._children)
+ def __bool__(self):
+ warnings.warn(
+ "The behavior of this method will change in future versions. "
+ "Use specific 'len(elem)' or 'elem is not None' test instead.",
+ FutureWarning, stacklevel=2
+ )
+ return len(self._children) != 0 # emulate old behaviour, for now
+
##
- # Returns the given subelement.
+ # Returns the given subelement, by index.
#
# @param index What subelement to return.
# @return The given subelement.
@@ -199,19 +266,22 @@ class _ElementInterface:
return self._children[index]
##
- # Replaces the given subelement.
+ # Replaces the given subelement, by index.
#
# @param index What subelement to replace.
# @param element The new element value.
# @exception IndexError If the given element does not exist.
- # @exception AssertionError If element is not a valid object.
def __setitem__(self, index, element):
- assert iselement(element)
+ # if isinstance(index, slice):
+ # for elt in element:
+ # assert iselement(elt)
+ # else:
+ # assert iselement(element)
self._children[index] = element
##
- # Deletes the given subelement.
+ # Deletes the given subelement, by index.
#
# @param index What subelement to delete.
# @exception IndexError If the given element does not exist.
@@ -220,118 +290,121 @@ class _ElementInterface:
del self._children[index]
##
- # Returns a list containing subelements in the given range.
+ # Adds a subelement to the end of this element. In document order,
+ # the new element will appear after the last existing subelement (or
+ # directly after the text, if it's the first subelement), but before
+ # the end tag for this element.
#
- # @param start The first subelement to return.
- # @param stop The first subelement that shouldn't be returned.
- # @return A sequence object containing subelements.
+ # @param element The element to add.
- def __getslice__(self, start, stop):
- return self._children[start:stop]
+ def append(self, element):
+ # assert iselement(element)
+ self._children.append(element)
##
- # Replaces a number of subelements with elements from a sequence.
+ # Appends subelements from a sequence.
#
- # @param start The first subelement to replace.
- # @param stop The first subelement that shouldn't be replaced.
# @param elements A sequence object with zero or more elements.
- # @exception AssertionError If a sequence member is not a valid object.
+ # @since 1.3
- def __setslice__(self, start, stop, elements):
- for element in elements:
- assert iselement(element)
- self._children[start:stop] = list(elements)
-
- ##
- # Deletes a number of subelements.
- #
- # @param start The first subelement to delete.
- # @param stop The first subelement to leave in there.
-
- def __delslice__(self, start, stop):
- del self._children[start:stop]
-
- ##
- # Adds a subelement to the end of this element.
- #
- # @param element The element to add.
- # @exception AssertionError If a sequence member is not a valid object.
-
- def append(self, element):
- assert iselement(element)
- self._children.append(element)
+ def extend(self, elements):
+ # for element in elements:
+ # assert iselement(element)
+ self._children.extend(elements)
##
# Inserts a subelement at the given position in this element.
#
# @param index Where to insert the new subelement.
- # @exception AssertionError If the element is not a valid object.
def insert(self, index, element):
- assert iselement(element)
+ # assert iselement(element)
self._children.insert(index, element)
##
# Removes a matching subelement. Unlike the <b>find</b> methods,
# this method compares elements based on identity, not on tag
- # value or contents.
+ # value or contents. To remove subelements by other means, the
+ # easiest way is often to use a list comprehension to select what
+ # elements to keep, and use slice assignment to update the parent
+ # element.
#
# @param element What element to remove.
# @exception ValueError If a matching element could not be found.
- # @exception AssertionError If the element is not a valid object.
def remove(self, element):
- assert iselement(element)
+ # assert iselement(element)
self._children.remove(element)
##
- # Returns all subelements. The elements are returned in document
- # order.
+ # (Deprecated) Returns all subelements. The elements are returned
+ # in document order.
#
# @return A list of subelements.
# @defreturn list of Element instances
def getchildren(self):
+ warnings.warn(
+ "This method will be removed in future versions. "
+ "Use 'list(elem)' or iteration over elem instead.",
+ DeprecationWarning, stacklevel=2
+ )
return self._children
##
# Finds the first matching subelement, by tag name or path.
#
# @param path What element to look for.
+ # @keyparam namespaces Optional namespace prefix map.
# @return The first matching element, or None if no element was found.
# @defreturn Element or None
- def find(self, path):
- return ElementPath.find(self, path)
+ def find(self, path, namespaces=None):
+ return ElementPath.find(self, path, namespaces)
##
# Finds text for the first matching subelement, by tag name or path.
#
# @param path What element to look for.
# @param default What to return if the element was not found.
+ # @keyparam namespaces Optional namespace prefix map.
# @return The text content of the first matching element, or the
# default value no element was found. Note that if the element
- # has is found, but has no text content, this method returns an
+ # is found, but has no text content, this method returns an
# empty string.
# @defreturn string
- def findtext(self, path, default=None):
- return ElementPath.findtext(self, path, default)
+ def findtext(self, path, default=None, namespaces=None):
+ return ElementPath.findtext(self, path, default, namespaces)
##
# Finds all matching subelements, by tag name or path.
#
# @param path What element to look for.
- # @return A list or iterator containing all matching elements,
+ # @keyparam namespaces Optional namespace prefix map.
+ # @return A list or other sequence containing all matching elements,
# in document order.
# @defreturn list of Element instances
- def findall(self, path):
- return ElementPath.findall(self, path)
+ def findall(self, path, namespaces=None):
+ return ElementPath.findall(self, path, namespaces)
+
+ ##
+ # Finds all matching subelements, by tag name or path.
+ #
+ # @param path What element to look for.
+ # @keyparam namespaces Optional namespace prefix map.
+ # @return An iterator or sequence containing all matching elements,
+ # in document order.
+ # @defreturn a generated sequence of Element instances
+
+ def iterfind(self, path, namespaces=None):
+ return ElementPath.iterfind(self, path, namespaces)
##
# Resets an element. This function removes all subelements, clears
- # all attributes, and sets the text and tail attributes to None.
+ # all attributes, and sets the <b>text</b> and <b>tail</b> attributes
+ # to None.
def clear(self):
self.attrib.clear()
@@ -339,7 +412,8 @@ class _ElementInterface:
self.text = self.tail = None
##
- # Gets an element attribute.
+ # Gets an element attribute. Equivalent to <b>attrib.get</b>, but
+ # some implementations may handle this a bit more efficiently.
#
# @param key What attribute to look for.
# @param default What to return if the attribute was not found.
@@ -351,7 +425,8 @@ class _ElementInterface:
return self.attrib.get(key, default)
##
- # Sets an element attribute.
+ # Sets an element attribute. Equivalent to <b>attrib[key] = value</b>,
+ # but some implementations may handle this a bit more efficiently.
#
# @param key What attribute to set.
# @param value The attribute value.
@@ -362,6 +437,7 @@ class _ElementInterface:
##
# Gets a list of attribute names. The names are returned in an
# arbitrary order (just like for an ordinary Python dictionary).
+ # Equivalent to <b>attrib.keys()</b>.
#
# @return A list of element attribute names.
# @defreturn list of strings
@@ -371,7 +447,7 @@ class _ElementInterface:
##
# Gets element attributes, as a sequence. The attributes are
- # returned in an arbitrary order.
+ # returned in an arbitrary order. Equivalent to <b>attrib.items()</b>.
#
# @return A list of (name, value) tuples for all attributes.
# @defreturn list of (string, string) tuples
@@ -384,45 +460,55 @@ class _ElementInterface:
# and all subelements, in document order, and returns all elements
# with a matching tag.
# <p>
- # If the tree structure is modified during iteration, the result
- # is undefined.
+ # If the tree structure is modified during iteration, new or removed
+ # elements may or may not be included. To get a stable set, use the
+ # list() function on the iterator, and loop over the resulting list.
#
# @param tag What tags to look for (default is to return all elements).
- # @return A list or iterator containing all the matching elements.
- # @defreturn list or iterator
+ # @return An iterator containing all the matching elements.
+ # @defreturn iterator
- def getiterator(self, tag=None):
- nodes = []
+ def iter(self, tag=None):
if tag == "*":
tag = None
if tag is None or self.tag == tag:
- nodes.append(self)
- for node in self._children:
- nodes.extend(node.getiterator(tag))
- return nodes
+ yield self
+ for e in self._children:
+ for e in e.iter(tag):
+ yield e
-# compatibility
-_Element = _ElementInterface
+ # compatibility
+ def getiterator(self, tag=None):
+ # Change for a DeprecationWarning in 1.4
+ warnings.warn(
+ "This method will be removed in future versions. "
+ "Use 'elem.iter()' or 'list(elem.iter())' instead.",
+ PendingDeprecationWarning, stacklevel=2
+ )
+ return list(self.iter(tag))
-##
-# Element factory. This function returns an object implementing the
-# standard Element interface. The exact class or type of that object
-# is implementation dependent, but it will always be compatible with
-# the {@link #_ElementInterface} class in this module.
-# <p>
-# The element name, attribute names, and attribute values can be
-# either 8-bit ASCII strings or Unicode strings.
-#
-# @param tag The element name.
-# @param attrib An optional dictionary, containing element attributes.
-# @param **extra Additional attributes, given as keyword arguments.
-# @return An element instance.
-# @defreturn Element
+ ##
+ # Creates a text iterator. The iterator loops over this element
+ # and all subelements, in document order, and returns all inner
+ # text.
+ #
+ # @return An iterator containing all inner text.
+ # @defreturn iterator
-def Element(tag, attrib={}, **extra):
- attrib = attrib.copy()
- attrib.update(extra)
- return _ElementInterface(tag, attrib)
+ def itertext(self):
+ tag = self.tag
+ if not isinstance(tag, str) and tag is not None:
+ return
+ if self.text:
+ yield self.text
+ for e in self:
+ for s in e.itertext():
+ yield s
+ if e.tail:
+ yield e.tail
+
+# compatibility
+_Element = _ElementInterface = Element
##
# Subelement factory. This function creates an element instance, and
@@ -447,7 +533,8 @@ def SubElement(parent, tag, attrib={}, **extra):
##
# Comment element factory. This factory function creates a special
-# element that will be serialized as an XML comment.
+# element that will be serialized as an XML comment by the standard
+# serializer.
# <p>
# The comment string can be either an 8-bit ASCII string or a Unicode
# string.
@@ -463,7 +550,8 @@ def Comment(text=None):
##
# PI element factory. This factory function creates a special element
-# that will be serialized as an XML processing instruction.
+# that will be serialized as an XML processing instruction by the standard
+# serializer.
#
# @param target A string containing the PI target.
# @param text A string containing the PI contents, if any.
@@ -496,6 +584,8 @@ class QName:
self.text = text_or_uri
def __str__(self):
return self.text
+ def __repr__(self):
+ return '<QName %r>' % (self.text,)
def __hash__(self):
return hash(self.text)
def __le__(self, other):
@@ -523,19 +613,21 @@ class QName:
return self.text != other.text
return self.text != other
+# --------------------------------------------------------------------
+
##
# ElementTree wrapper class. This class represents an entire element
# hierarchy, and adds some extra support for serialization to and from
# standard XML.
#
# @param element Optional root element.
-# @keyparam file Optional file handle or name. If given, the
+# @keyparam file Optional file handle or file name. If given, the
# tree is initialized with the contents of this XML file.
class ElementTree:
def __init__(self, element=None, file=None):
- assert element is None or iselement(element)
+ # assert element is None or iselement(element)
self._root = element # first node
if file:
self.parse(file)
@@ -557,30 +649,38 @@ class ElementTree:
# @param element An element instance.
def _setroot(self, element):
- assert iselement(element)
+ # assert iselement(element)
self._root = element
##
# Loads an external XML document into this element tree.
#
- # @param source A file name or file object.
- # @param parser An optional parser instance. If not given, the
- # standard {@link XMLTreeBuilder} parser is used.
+ # @param source A file name or file object. If a file object is
+ # given, it only has to implement a <b>read(n)</b> method.
+ # @keyparam parser An optional parser instance. If not given, the
+ # standard {@link XMLParser} parser is used.
# @return The document root element.
# @defreturn Element
+ # @exception ParseError If the parser fails to parse the document.
def parse(self, source, parser=None):
+ close_source = False
if not hasattr(source, "read"):
source = open(source, "rb")
- if not parser:
- parser = XMLTreeBuilder()
- while 1:
- data = source.read(32768)
- if not data:
- break
- parser.feed(data)
- self._root = parser.close()
- return self._root
+ close_source = True
+ try:
+ if not parser:
+ parser = XMLParser(target=TreeBuilder())
+ while 1:
+ data = source.read(65536)
+ if not data:
+ break
+ parser.feed(data)
+ self._root = parser.close()
+ return self._root
+ finally:
+ if close_source:
+ source.close()
##
# Creates a tree iterator for the root element. The iterator loops
@@ -590,23 +690,40 @@ class ElementTree:
# @return An iterator.
# @defreturn iterator
+ def iter(self, tag=None):
+ # assert self._root is not None
+ return self._root.iter(tag)
+
+ # compatibility
def getiterator(self, tag=None):
- assert self._root is not None
- return self._root.getiterator(tag)
+ # Change for a DeprecationWarning in 1.4
+ warnings.warn(
+ "This method will be removed in future versions. "
+ "Use 'tree.iter()' or 'list(tree.iter())' instead.",
+ PendingDeprecationWarning, stacklevel=2
+ )
+ return list(self.iter(tag))
##
# Finds the first toplevel element with given tag.
# Same as getroot().find(path).
#
# @param path What element to look for.
+ # @keyparam namespaces Optional namespace prefix map.
# @return The first matching element, or None if no element was found.
# @defreturn Element or None
- def find(self, path):
- assert self._root is not None
+ def find(self, path, namespaces=None):
+ # assert self._root is not None
if path[:1] == "/":
path = "." + path
- return self._root.find(path)
+ warnings.warn(
+ "This search is broken in 1.3 and earlier, and will be "
+ "fixed in a future version. If you rely on the current "
+ "behaviour, change it to %r" % path,
+ FutureWarning, stacklevel=2
+ )
+ return self._root.find(path, namespaces)
##
# Finds the element text for the first toplevel element with given
@@ -614,153 +731,359 @@ class ElementTree:
#
# @param path What toplevel element to look for.
# @param default What to return if the element was not found.
+ # @keyparam namespaces Optional namespace prefix map.
# @return The text content of the first matching element, or the
# default value no element was found. Note that if the element
- # has is found, but has no text content, this method returns an
+ # is found, but has no text content, this method returns an
# empty string.
# @defreturn string
- def findtext(self, path, default=None):
- assert self._root is not None
+ def findtext(self, path, default=None, namespaces=None):
+ # assert self._root is not None
if path[:1] == "/":
path = "." + path
- return self._root.findtext(path, default)
+ warnings.warn(
+ "This search is broken in 1.3 and earlier, and will be "
+ "fixed in a future version. If you rely on the current "
+ "behaviour, change it to %r" % path,
+ FutureWarning, stacklevel=2
+ )
+ return self._root.findtext(path, default, namespaces)
##
# Finds all toplevel elements with the given tag.
# Same as getroot().findall(path).
#
# @param path What element to look for.
+ # @keyparam namespaces Optional namespace prefix map.
# @return A list or iterator containing all matching elements,
# in document order.
# @defreturn list of Element instances
- def findall(self, path):
- assert self._root is not None
+ def findall(self, path, namespaces=None):
+ # assert self._root is not None
if path[:1] == "/":
path = "." + path
- return self._root.findall(path)
+ warnings.warn(
+ "This search is broken in 1.3 and earlier, and will be "
+ "fixed in a future version. If you rely on the current "
+ "behaviour, change it to %r" % path,
+ FutureWarning, stacklevel=2
+ )
+ return self._root.findall(path, namespaces)
+
+ ##
+ # Finds all matching subelements, by tag name or path.
+ # Same as getroot().iterfind(path).
+ #
+ # @param path What element to look for.
+ # @keyparam namespaces Optional namespace prefix map.
+ # @return An iterator or sequence containing all matching elements,
+ # in document order.
+ # @defreturn a generated sequence of Element instances
+
+ def iterfind(self, path, namespaces=None):
+ # assert self._root is not None
+ if path[:1] == "/":
+ path = "." + path
+ warnings.warn(
+ "This search is broken in 1.3 and earlier, and will be "
+ "fixed in a future version. If you rely on the current "
+ "behaviour, change it to %r" % path,
+ FutureWarning, stacklevel=2
+ )
+ return self._root.iterfind(path, namespaces)
##
# Writes the element tree to a file, as XML.
#
+ # @def write(file, **options)
# @param file A file name, or a file object opened for writing.
- # @param encoding Optional output encoding (default is None)
-
- def write(self, file, encoding=None):
- assert self._root is not None
- if not hasattr(file, "write"):
- if encoding:
- file = open(file, "wb")
+ # @param **options Options, given as keyword arguments.
+ # @keyparam encoding Optional output encoding (default is US-ASCII).
+ # Use "unicode" to return a Unicode string.
+ # @keyparam method Optional output method ("xml", "html", "text" or
+ # "c14n"; default is "xml").
+ # @keyparam xml_declaration Controls if an XML declaration should
+ # be added to the file. Use False for never, True for always,
+ # None for only if not US-ASCII or UTF-8 or Unicode. None is default.
+
+ def write(self, file_or_filename,
+ # keyword arguments
+ encoding=None,
+ xml_declaration=None,
+ default_namespace=None,
+ method=None):
+ # assert self._root is not None
+ if not method:
+ method = "xml"
+ elif method not in _serialize:
+ # FIXME: raise an ImportError for c14n if ElementC14N is missing?
+ raise ValueError("unknown method %r" % method)
+ if not encoding:
+ if method == "c14n":
+ encoding = "utf-8"
else:
- file = open(file, "w")
- if encoding and encoding != "utf-8":
- file.write(_encode("<?xml version='1.0' encoding='%s'?>\n" % encoding, encoding))
- self._write(file, self._root, encoding, {})
-
- def _write(self, file, node, encoding, namespaces):
- # write XML to file
- tag = node.tag
- if tag is Comment:
- file.write(b"<!-- " + _encode_cdata(node.text, encoding) + b" -->")
- elif tag is ProcessingInstruction:
- file.write(b"<?" + _encode_cdata(node.text, encoding) + b"?>")
+ encoding = "us-ascii"
+ elif encoding == str: # lxml.etree compatibility.
+ encoding = "unicode"
else:
- items = list(node.items())
- xmlns_items = [] # new namespaces in this scope
- try:
- if isinstance(tag, QName) or tag[:1] == "{":
- tag, xmlns = fixtag(tag, namespaces)
- if xmlns: xmlns_items.append(xmlns)
- except TypeError:
- _raise_serialization_error(tag)
- file.write(_encode("<" + tag, encoding))
- if items or xmlns_items:
- items.sort() # lexical order
- for k, v in items:
- try:
- if isinstance(k, QName) or k[:1] == "{":
- k, xmlns = fixtag(k, namespaces)
- if xmlns: xmlns_items.append(xmlns)
- except TypeError:
- _raise_serialization_error(k)
- try:
- if isinstance(v, QName):
- v, xmlns = fixtag(v, namespaces)
- if xmlns: xmlns_items.append(xmlns)
- except TypeError:
- _raise_serialization_error(v)
- file.write(_encode(" %s=\"%s\"" % (k, _escape_attrib(v)), encoding))
- for k, v in xmlns_items:
- file.write(_encode(" %s=\"%s\"" % (k, _escape_attrib(v)), encoding))
- if node.text or len(node):
- file.write(_encode(">", encoding))
- if node.text:
- file.write(_encode_cdata(node.text, encoding))
- for n in node:
- self._write(file, n, encoding, namespaces)
- file.write(_encode("</" + tag + ">", encoding))
+ encoding = encoding.lower()
+ if hasattr(file_or_filename, "write"):
+ file = file_or_filename
+ else:
+ if encoding != "unicode":
+ file = open(file_or_filename, "wb")
else:
- file.write(_encode(" />", encoding))
- for k, v in xmlns_items:
- del namespaces[v]
- if node.tail:
- file.write(_encode_cdata(node.tail, encoding))
+ file = open(file_or_filename, "w")
+ if encoding != "unicode":
+ def write(text):
+ try:
+ return file.write(text.encode(encoding,
+ "xmlcharrefreplace"))
+ except (TypeError, AttributeError):
+ _raise_serialization_error(text)
+ else:
+ write = file.write
+ if method == "xml" and (xml_declaration or
+ (xml_declaration is None and
+ encoding not in ("utf-8", "us-ascii", "unicode"))):
+ declared_encoding = encoding
+ if encoding == "unicode":
+ # Retrieve the default encoding for the xml declaration
+ import locale
+ declared_encoding = locale.getpreferredencoding()
+ write("<?xml version='1.0' encoding='%s'?>\n" % declared_encoding)
+ if method == "text":
+ _serialize_text(write, self._root)
+ else:
+ qnames, namespaces = _namespaces(self._root, default_namespace)
+ serialize = _serialize[method]
+ serialize(write, self._root, qnames, namespaces)
+ if file_or_filename is not file:
+ file.close()
-# --------------------------------------------------------------------
-# helpers
+ def write_c14n(self, file):
+ # lxml.etree compatibility. use output method instead
+ return self.write(file, method="c14n")
-##
-# Checks if an object appears to be a valid element object.
-#
-# @param An element instance.
-# @return A true value if this is an element object.
-# @defreturn flag
+# --------------------------------------------------------------------
+# serialization support
-def iselement(element):
- # FIXME: not sure about this; might be a better idea to look
- # for tag/attrib/text attributes
- return isinstance(element, _ElementInterface) or hasattr(element, "tag")
+def _namespaces(elem, default_namespace=None):
+ # identify namespaces used in this tree
-##
-# Writes an element tree or element structure to sys.stdout. This
-# function should be used for debugging only.
-# <p>
-# The exact output format is implementation dependent. In this
-# version, it's written as an ordinary XML file.
-#
-# @param elem An element tree or an individual element.
+ # maps qnames to *encoded* prefix:local names
+ qnames = {None: None}
-def dump(elem):
- # debugging
- if not isinstance(elem, ElementTree):
- elem = ElementTree(elem)
- elem.write(sys.stdout)
- tail = elem.getroot().tail
- if not tail or tail[-1] != "\n":
- sys.stdout.write("\n")
+ # maps uri:s to prefixes
+ namespaces = {}
+ if default_namespace:
+ namespaces[default_namespace] = ""
-def _encode(s, encoding):
- if encoding:
- return s.encode(encoding)
+ def add_qname(qname):
+ # calculate serialized qname representation
+ try:
+ if qname[:1] == "{":
+ uri, tag = qname[1:].rsplit("}", 1)
+ prefix = namespaces.get(uri)
+ if prefix is None:
+ prefix = _namespace_map.get(uri)
+ if prefix is None:
+ prefix = "ns%d" % len(namespaces)
+ if prefix != "xml":
+ namespaces[uri] = prefix
+ if prefix:
+ qnames[qname] = "%s:%s" % (prefix, tag)
+ else:
+ qnames[qname] = tag # default element
+ else:
+ if default_namespace:
+ # FIXME: can this be handled in XML 1.0?
+ raise ValueError(
+ "cannot use non-qualified names with "
+ "default_namespace option"
+ )
+ qnames[qname] = qname
+ except TypeError:
+ _raise_serialization_error(qname)
+
+ # populate qname and namespaces table
+ try:
+ iterate = elem.iter
+ except AttributeError:
+ iterate = elem.getiterator # cET compatibility
+ for elem in iterate():
+ tag = elem.tag
+ if isinstance(tag, QName):
+ if tag.text not in qnames:
+ add_qname(tag.text)
+ elif isinstance(tag, str):
+ if tag not in qnames:
+ add_qname(tag)
+ elif tag is not None and tag is not Comment and tag is not PI:
+ _raise_serialization_error(tag)
+ for key, value in elem.items():
+ if isinstance(key, QName):
+ key = key.text
+ if key not in qnames:
+ add_qname(key)
+ if isinstance(value, QName) and value.text not in qnames:
+ add_qname(value.text)
+ text = elem.text
+ if isinstance(text, QName) and text.text not in qnames:
+ add_qname(text.text)
+ return qnames, namespaces
+
+def _serialize_xml(write, elem, qnames, namespaces):
+ tag = elem.tag
+ text = elem.text
+ if tag is Comment:
+ write("<!--%s-->" % text)
+ elif tag is ProcessingInstruction:
+ write("<?%s?>" % text)
else:
- return s
-
-_escape = re.compile(r"[&<>\"\u0080-\uffff]+")
-
-_escape_map = {
- "&": "&amp;",
- "<": "&lt;",
- ">": "&gt;",
- '"': "&quot;",
+ tag = qnames[tag]
+ if tag is None:
+ if text:
+ write(_escape_cdata(text))
+ for e in elem:
+ _serialize_xml(write, e, qnames, None)
+ else:
+ write("<" + tag)
+ items = list(elem.items())
+ if items or namespaces:
+ if namespaces:
+ for v, k in sorted(namespaces.items(),
+ key=lambda x: x[1]): # sort on prefix
+ if k:
+ k = ":" + k
+ write(" xmlns%s=\"%s\"" % (
+ k,
+ _escape_attrib(v)
+ ))
+ for k, v in sorted(items): # lexical order
+ if isinstance(k, QName):
+ k = k.text
+ if isinstance(v, QName):
+ v = qnames[v.text]
+ else:
+ v = _escape_attrib(v)
+ write(" %s=\"%s\"" % (qnames[k], v))
+ if text or len(elem):
+ write(">")
+ if text:
+ write(_escape_cdata(text))
+ for e in elem:
+ _serialize_xml(write, e, qnames, None)
+ write("</" + tag + ">")
+ else:
+ write(" />")
+ if elem.tail:
+ write(_escape_cdata(elem.tail))
+
+HTML_EMPTY = ("area", "base", "basefont", "br", "col", "frame", "hr",
+ "img", "input", "isindex", "link", "meta" "param")
+
+try:
+ HTML_EMPTY = set(HTML_EMPTY)
+except NameError:
+ pass
+
+def _serialize_html(write, elem, qnames, namespaces):
+ tag = elem.tag
+ text = elem.text
+ if tag is Comment:
+ write("<!--%s-->" % _escape_cdata(text))
+ elif tag is ProcessingInstruction:
+ write("<?%s?>" % _escape_cdata(text))
+ else:
+ tag = qnames[tag]
+ if tag is None:
+ if text:
+ write(_escape_cdata(text))
+ for e in elem:
+ _serialize_html(write, e, qnames, None)
+ else:
+ write("<" + tag)
+ items = list(elem.items())
+ if items or namespaces:
+ if namespaces:
+ for v, k in sorted(namespaces.items(),
+ key=lambda x: x[1]): # sort on prefix
+ if k:
+ k = ":" + k
+ write(" xmlns%s=\"%s\"" % (
+ k,
+ _escape_attrib(v)
+ ))
+ for k, v in sorted(items): # lexical order
+ if isinstance(k, QName):
+ k = k.text
+ if isinstance(v, QName):
+ v = qnames[v.text]
+ else:
+ v = _escape_attrib_html(v)
+ # FIXME: handle boolean attributes
+ write(" %s=\"%s\"" % (qnames[k], v))
+ write(">")
+ tag = tag.lower()
+ if text:
+ if tag == "script" or tag == "style":
+ write(text)
+ else:
+ write(_escape_cdata(text))
+ for e in elem:
+ _serialize_html(write, e, qnames, None)
+ if tag not in HTML_EMPTY:
+ write("</" + tag + ">")
+ if elem.tail:
+ write(_escape_cdata(elem.tail))
+
+def _serialize_text(write, elem):
+ for part in elem.itertext():
+ write(part)
+ if elem.tail:
+ write(elem.tail)
+
+_serialize = {
+ "xml": _serialize_xml,
+ "html": _serialize_html,
+ "text": _serialize_text,
+# this optional method is imported at the end of the module
+# "c14n": _serialize_c14n,
}
+##
+# Registers a namespace prefix. The registry is global, and any
+# existing mapping for either the given prefix or the namespace URI
+# will be removed.
+#
+# @param prefix Namespace prefix.
+# @param uri Namespace uri. Tags and attributes in this namespace
+# will be serialized with the given prefix, if at all possible.
+# @exception ValueError If the prefix is reserved, or is otherwise
+# invalid.
+
+def register_namespace(prefix, uri):
+ if re.match("ns\d+$", prefix):
+ raise ValueError("Prefix format reserved for internal use")
+ for k, v in list(_namespace_map.items()):
+ if k == uri or v == prefix:
+ del _namespace_map[k]
+ _namespace_map[uri] = prefix
+
_namespace_map = {
# "well-known" namespace prefixes
"http://www.w3.org/XML/1998/namespace": "xml",
"http://www.w3.org/1999/xhtml": "html",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf",
"http://schemas.xmlsoap.org/wsdl/": "wsdl",
+ # xml schema
+ "http://www.w3.org/2001/XMLSchema": "xs",
+ "http://www.w3.org/2001/XMLSchema-instance": "xsi",
+ # dublin core
+ "http://purl.org/dc/elements/1.1/": "dc",
}
def _raise_serialization_error(text):
@@ -768,77 +1091,131 @@ def _raise_serialization_error(text):
"cannot serialize %r (type %s)" % (text, type(text).__name__)
)
-def _encode_entity(text, pattern=_escape):
- # map reserved and non-ascii characters to numerical entities
- def escape_entities(m, map=_escape_map):
- out = []
- append = out.append
- for char in m.group():
- text = map.get(char)
- if text is None:
- text = "&#%d;" % ord(char)
- append(text)
- return "".join(out)
+def _escape_cdata(text):
+ # escape character data
try:
- return _encode(pattern.sub(escape_entities, text), "ascii")
- except TypeError:
+ # it's worth avoiding do-nothing calls for strings that are
+ # shorter than 500 character, or so. assume that's, by far,
+ # the most common case in most applications.
+ if "&" in text:
+ text = text.replace("&", "&amp;")
+ if "<" in text:
+ text = text.replace("<", "&lt;")
+ if ">" in text:
+ text = text.replace(">", "&gt;")
+ return text
+ except (TypeError, AttributeError):
_raise_serialization_error(text)
-#
-# the following functions assume an ascii-compatible encoding
-# (or "utf-16")
-
-def _encode_cdata(text, encoding):
- # escape character data
+def _escape_attrib(text):
+ # escape attribute value
try:
- text = text.replace("&", "&amp;")
- text = text.replace("<", "&lt;")
- text = text.replace(">", "&gt;")
- if encoding:
- return text.encode(encoding, "xmlcharrefreplace")
- else:
- return text
+ if "&" in text:
+ text = text.replace("&", "&amp;")
+ if "<" in text:
+ text = text.replace("<", "&lt;")
+ if ">" in text:
+ text = text.replace(">", "&gt;")
+ if "\"" in text:
+ text = text.replace("\"", "&quot;")
+ if "\n" in text:
+ text = text.replace("\n", "&#10;")
+ return text
except (TypeError, AttributeError):
_raise_serialization_error(text)
-def _escape_attrib(text):
+def _escape_attrib_html(text):
# escape attribute value
try:
- text = text.replace("&", "&amp;")
- text = text.replace("'", "&apos;") # FIXME: overkill
- text = text.replace("\"", "&quot;")
- text = text.replace("<", "&lt;")
- text = text.replace(">", "&gt;")
+ if "&" in text:
+ text = text.replace("&", "&amp;")
+ if ">" in text:
+ text = text.replace(">", "&gt;")
+ if "\"" in text:
+ text = text.replace("\"", "&quot;")
return text
except (TypeError, AttributeError):
_raise_serialization_error(text)
-def fixtag(tag, namespaces):
- # given a decorated tag (of the form {uri}tag), return prefixed
- # tag and namespace declaration, if any
- if isinstance(tag, QName):
- tag = tag.text
- namespace_uri, tag = tag[1:].split("}", 1)
- prefix = namespaces.get(namespace_uri)
- if prefix is None:
- prefix = _namespace_map.get(namespace_uri)
- if prefix is None:
- prefix = "ns%d" % len(namespaces)
- namespaces[namespace_uri] = prefix
- if prefix == "xml":
- xmlns = None
- else:
- xmlns = ("xmlns:%s" % prefix, namespace_uri)
+# --------------------------------------------------------------------
+
+##
+# Generates a string representation of an XML element, including all
+# subelements. If encoding is "unicode", the return type is a string;
+# otherwise it is a bytes array.
+#
+# @param element An Element instance.
+# @keyparam encoding Optional output encoding (default is US-ASCII).
+# Use "unicode" to return a Unicode string.
+# @keyparam method Optional output method ("xml", "html", "text" or
+# "c14n"; default is "xml").
+# @return An (optionally) encoded string containing the XML data.
+# @defreturn string
+
+def tostring(element, encoding=None, method=None):
+ class dummy:
+ pass
+ data = []
+ file = dummy()
+ file.write = data.append
+ ElementTree(element).write(file, encoding, method=method)
+ if encoding in (str, "unicode"):
+ return "".join(data)
else:
- xmlns = None
- return "%s:%s" % (prefix, tag), xmlns
+ return b"".join(data)
+
+##
+# Generates a string representation of an XML element, including all
+# subelements. If encoding is False, the string is returned as a
+# sequence of string fragments; otherwise it is a sequence of
+# bytestrings.
+#
+# @param element An Element instance.
+# @keyparam encoding Optional output encoding (default is US-ASCII).
+# Use "unicode" to return a Unicode string.
+# @keyparam method Optional output method ("xml", "html", "text" or
+# "c14n"; default is "xml").
+# @return A sequence object containing the XML data.
+# @defreturn sequence
+# @since 1.3
+
+def tostringlist(element, encoding=None, method=None):
+ class dummy:
+ pass
+ data = []
+ file = dummy()
+ file.write = data.append
+ ElementTree(element).write(file, encoding, method=method)
+ # FIXME: merge small fragments into larger parts
+ return data
+
+##
+# Writes an element tree or element structure to sys.stdout. This
+# function should be used for debugging only.
+# <p>
+# The exact output format is implementation dependent. In this
+# version, it's written as an ordinary XML file.
+#
+# @param elem An element tree or an individual element.
+
+def dump(elem):
+ # debugging
+ if not isinstance(elem, ElementTree):
+ elem = ElementTree(elem)
+ elem.write(sys.stdout, encoding="unicode")
+ tail = elem.getroot().tail
+ if not tail or tail[-1] != "\n":
+ sys.stdout.write("\n")
+
+# --------------------------------------------------------------------
+# parsing
##
# Parses an XML document into an element tree.
#
# @param source A filename or file object containing XML data.
# @param parser An optional parser instance. If not given, the
-# standard {@link XMLTreeBuilder} parser is used.
+# standard {@link XMLParser} parser is used.
# @return An ElementTree instance
def parse(source, parser=None):
@@ -853,18 +1230,28 @@ def parse(source, parser=None):
# @param source A filename or file object containing XML data.
# @param events A list of events to report back. If omitted, only "end"
# events are reported.
+# @param parser An optional parser instance. If not given, the
+# standard {@link XMLParser} parser is used.
# @return A (event, elem) iterator.
-class iterparse:
+def iterparse(source, events=None, parser=None):
+ close_source = False
+ if not hasattr(source, "read"):
+ source = open(source, "rb")
+ close_source = True
+ if not parser:
+ parser = XMLParser(target=TreeBuilder())
+ return _IterParseIterator(source, events, parser, close_source)
- def __init__(self, source, events=None):
- if not hasattr(source, "read"):
- source = open(source, "rb")
+class _IterParseIterator:
+
+ def __init__(self, source, events, parser, close_source=False):
self._file = source
+ self._close_file = close_source
self._events = []
self._index = 0
self.root = self._root = None
- self._parser = XMLTreeBuilder()
+ self._parser = parser
# wire up the parser for event reporting
parser = self._parser._parser
append = self._events.append
@@ -891,16 +1278,14 @@ class iterparse:
parser.EndElementHandler = handler
elif event == "start-ns":
def handler(prefix, uri, event=event, append=append):
- try:
- uri = _encode(uri, "ascii")
- except UnicodeError:
- pass
- append((event, (prefix or "", uri)))
+ append((event, (prefix or "", uri or "")))
parser.StartNamespaceDeclHandler = handler
elif event == "end-ns":
def handler(prefix, event=event, append=append):
append((event, None))
parser.EndNamespaceDeclHandler = handler
+ else:
+ raise ValueError("unknown event %r" % event)
def __next__(self):
while 1:
@@ -909,10 +1294,9 @@ class iterparse:
except IndexError:
if self._parser is None:
self.root = self._root
- try:
- raise StopIteration
- except NameError:
- raise IndexError
+ if self._close_file:
+ self._file.close()
+ raise StopIteration
# load event buffer
del self._events[:]
self._index = 0
@@ -926,24 +1310,22 @@ class iterparse:
self._index = self._index + 1
return item
- try:
- iter
- def __iter__(self):
- return self
- except NameError:
- def __getitem__(self, index):
- return self.__next__()
+ def __iter__(self):
+ return self
##
# Parses an XML document from a string constant. This function can
# be used to embed "XML literals" in Python code.
#
# @param source A string containing XML data.
+# @param parser An optional parser instance. If not given, the
+# standard {@link XMLParser} parser is used.
# @return An Element instance.
# @defreturn Element
-def XML(text):
- parser = XMLTreeBuilder()
+def XML(text, parser=None):
+ if not parser:
+ parser = XMLParser(target=TreeBuilder())
parser.feed(text)
return parser.close()
@@ -952,15 +1334,18 @@ def XML(text):
# a dictionary which maps from element id:s to elements.
#
# @param source A string containing XML data.
+# @param parser An optional parser instance. If not given, the
+# standard {@link XMLParser} parser is used.
# @return A tuple containing an Element instance and a dictionary.
# @defreturn (Element, dictionary)
-def XMLID(text):
- parser = XMLTreeBuilder()
+def XMLID(text, parser=None):
+ if not parser:
+ parser = XMLParser(target=TreeBuilder())
parser.feed(text)
tree = parser.close()
ids = {}
- for elem in tree.getiterator():
+ for elem in tree.iter():
id = elem.get("id")
if id:
ids[id] = elem
@@ -977,25 +1362,23 @@ def XMLID(text):
fromstring = XML
##
-# Generates a string representation of an XML element, including all
-# subelements. If encoding is None, the return type is a string;
-# otherwise it is a bytes array.
+# Parses an XML document from a sequence of string fragments.
#
-# @param element An Element instance.
-# @return An (optionally) encoded string containing the XML data.
-# @defreturn string
+# @param sequence A list or other sequence containing XML data fragments.
+# @param parser An optional parser instance. If not given, the
+# standard {@link XMLParser} parser is used.
+# @return An Element instance.
+# @defreturn Element
+# @since 1.3
-def tostring(element, encoding=None):
- class dummy:
- pass
- data = []
- file = dummy()
- file.write = data.append
- ElementTree(element).write(file, encoding)
- if encoding:
- return b"".join(data)
- else:
- return "".join(data)
+def fromstringlist(sequence, parser=None):
+ if not parser:
+ parser = XMLParser(target=TreeBuilder())
+ for text in sequence:
+ parser.feed(text)
+ return parser.close()
+
+# --------------------------------------------------------------------
##
# Generic element structure builder. This builder converts a sequence
@@ -1016,11 +1399,11 @@ class TreeBuilder:
self._last = None # last element
self._tail = None # true if we're after an end tag
if element_factory is None:
- element_factory = _ElementInterface
+ element_factory = Element
self._factory = element_factory
##
- # Flushes the parser buffers, and returns the toplevel documen
+ # Flushes the builder buffers, and returns the toplevel document
# element.
#
# @return An Element instance.
@@ -1028,7 +1411,7 @@ class TreeBuilder:
def close(self):
assert len(self._elem) == 0, "missing end tags"
- assert self._last != None, "missing toplevel element"
+ assert self._last is not None, "missing toplevel element"
return self._last
def _flush(self):
@@ -1093,28 +1476,39 @@ class TreeBuilder:
# instance of the standard {@link #TreeBuilder} class.
# @keyparam html Predefine HTML entities. This flag is not supported
# by the current implementation.
+# @keyparam encoding Optional encoding. If given, the value overrides
+# the encoding specified in the XML file.
# @see #ElementTree
# @see #TreeBuilder
-class XMLTreeBuilder:
+class XMLParser:
- def __init__(self, html=0, target=None):
+ def __init__(self, html=0, target=None, encoding=None):
try:
from xml.parsers import expat
except ImportError:
- raise ImportError(
- "No module named expat; use SimpleXMLTreeBuilder instead"
- )
- self._parser = parser = expat.ParserCreate(None, "}")
+ try:
+ import pyexpat as expat
+ except ImportError:
+ raise ImportError(
+ "No module named expat; use SimpleXMLTreeBuilder instead"
+ )
+ parser = expat.ParserCreate(encoding, "}")
if target is None:
target = TreeBuilder()
- self._target = target
+ # underscored names are provided for compatibility only
+ self.parser = self._parser = parser
+ self.target = self._target = target
+ self._error = expat.error
self._names = {} # name memo cache
# callbacks
parser.DefaultHandlerExpand = self._default
parser.StartElementHandler = self._start
parser.EndElementHandler = self._end
parser.CharacterDataHandler = self._data
+ # optional callbacks
+ parser.CommentHandler = self._comment
+ parser.ProcessingInstructionHandler = self._pi
# let expat do the buffering, if supported
try:
self._parser.buffer_text = 1
@@ -1127,10 +1521,18 @@ class XMLTreeBuilder:
parser.StartElementHandler = self._start_list
except AttributeError:
pass
- encoding = "utf-8"
- # target.xml(encoding, None)
self._doctype = None
self.entity = {}
+ try:
+ self.version = "Expat %d.%d.%d" % expat.version_info
+ except AttributeError:
+ pass # unknown
+
+ def _raiseerror(self, value):
+ err = ParseError(value)
+ err.code = value.code
+ err.position = value.lineno, value.offset
+ raise err
def _fixname(self, key):
# expand qname, and convert name string to ascii, if possible
@@ -1149,7 +1551,7 @@ class XMLTreeBuilder:
attrib = {}
for key, value in attrib_in.items():
attrib[fixname(key)] = value
- return self._target.start(tag, attrib)
+ return self.target.start(tag, attrib)
def _start_list(self, tag, attrib_in):
fixname = self._fixname
@@ -1158,27 +1560,47 @@ class XMLTreeBuilder:
if attrib_in:
for i in range(0, len(attrib_in), 2):
attrib[fixname(attrib_in[i])] = attrib_in[i+1]
- return self._target.start(tag, attrib)
+ return self.target.start(tag, attrib)
def _data(self, text):
- return self._target.data(text)
+ return self.target.data(text)
def _end(self, tag):
- return self._target.end(self._fixname(tag))
+ return self.target.end(self._fixname(tag))
+
+ def _comment(self, data):
+ try:
+ comment = self.target.comment
+ except AttributeError:
+ pass
+ else:
+ return comment(data)
+
+ def _pi(self, target, data):
+ try:
+ pi = self.target.pi
+ except AttributeError:
+ pass
+ else:
+ return pi(target, data)
def _default(self, text):
prefix = text[:1]
if prefix == "&":
# deal with undefined entities
try:
- self._target.data(self.entity[text[1:-1]])
+ self.target.data(self.entity[text[1:-1]])
except KeyError:
from xml.parsers import expat
- raise expat.error(
+ err = expat.error(
"undefined entity %s: line %d, column %d" %
(text, self._parser.ErrorLineNumber,
self._parser.ErrorColumnNumber)
)
+ err.code = 11 # XML_ERROR_UNDEFINED_ENTITY
+ err.lineno = self._parser.ErrorLineNumber
+ err.offset = self._parser.ErrorColumnNumber
+ raise err
elif prefix == "<" and text[:9] == "<!DOCTYPE":
self._doctype = [] # inside a doctype declaration
elif self._doctype is not None:
@@ -1202,18 +1624,31 @@ class XMLTreeBuilder:
return
if pubid:
pubid = pubid[1:-1]
- self.doctype(name, pubid, system[1:-1])
+ if hasattr(self.target, "doctype"):
+ self.target.doctype(name, pubid, system[1:-1])
+ elif self.doctype is not self._XMLParser__doctype:
+ # warn about deprecated call
+ self._XMLParser__doctype(name, pubid, system[1:-1])
+ self.doctype(name, pubid, system[1:-1])
self._doctype = None
##
- # Handles a doctype declaration.
+ # (Deprecated) Handles a doctype declaration.
#
# @param name Doctype name.
# @param pubid Public identifier.
# @param system System identifier.
def doctype(self, name, pubid, system):
- pass
+ """This method of XMLParser is deprecated."""
+ warnings.warn(
+ "This method of XMLParser is deprecated. Define doctype() "
+ "method on the TreeBuilder target.",
+ DeprecationWarning,
+ )
+
+ # sentinel, if doctype is redefined in a subclass
+ __doctype = doctype
##
# Feeds data to the parser.
@@ -1221,7 +1656,10 @@ class XMLTreeBuilder:
# @param data Encoded data.
def feed(self, data):
- self._parser.Parse(data, 0)
+ try:
+ self._parser.Parse(data, 0)
+ except self._error as v:
+ self._raiseerror(v)
##
# Finishes feeding data to the parser.
@@ -1230,10 +1668,20 @@ class XMLTreeBuilder:
# @defreturn Element
def close(self):
- self._parser.Parse("", 1) # end of data
- tree = self._target.close()
- del self._target, self._parser # get rid of circular references
+ try:
+ self._parser.Parse("", 1) # end of data
+ except self._error as v:
+ self._raiseerror(v)
+ tree = self.target.close()
+ del self.target, self._parser # get rid of circular references
return tree
# compatibility
-XMLParser = XMLTreeBuilder
+XMLTreeBuilder = XMLParser
+
+# workaround circular import.
+try:
+ from ElementC14N import _serialize_c14n
+ _serialize["c14n"] = _serialize_c14n
+except ImportError:
+ pass
diff --git a/Lib/xml/etree/__init__.py b/Lib/xml/etree/__init__.py
index 3dd2c929e8..27fd8f6d4e 100644
--- a/Lib/xml/etree/__init__.py
+++ b/Lib/xml/etree/__init__.py
@@ -1,10 +1,10 @@
-# $Id: __init__.py 1821 2004-06-03 16:57:49Z fredrik $
+# $Id: __init__.py 3375 2008-02-13 08:05:08Z fredrik $
# elementtree package
# --------------------------------------------------------------------
# The ElementTree toolkit is
#
-# Copyright (c) 1999-2004 by Fredrik Lundh
+# Copyright (c) 1999-2008 by Fredrik Lundh
#
# By obtaining, using, and/or copying this software and/or its
# associated documentation, you agree that you have read, understood,
@@ -30,4 +30,4 @@
# --------------------------------------------------------------------
# Licensed to PSF under a Contributor Agreement.
-# See http://www.python.org/2.4/license for licensing details.
+# See http://www.python.org/psf/license for licensing details.
diff --git a/Lib/xml/parsers/expat.py b/Lib/xml/parsers/expat.py
index 11359a0b27..a805b828d8 100644
--- a/Lib/xml/parsers/expat.py
+++ b/Lib/xml/parsers/expat.py
@@ -1,4 +1,10 @@
"""Interface to the Expat non-validating XML parser."""
__version__ = '$Revision$'
+import sys
+
from pyexpat import *
+
+# provide pyexpat submodules as xml.parsers.expat submodules
+sys.modules['xml.parsers.expat.model'] = model
+sys.modules['xml.parsers.expat.errors'] = errors
diff --git a/Lib/xml/sax/expatreader.py b/Lib/xml/sax/expatreader.py
index c9fc894cb0..a227cdab57 100644
--- a/Lib/xml/sax/expatreader.py
+++ b/Lib/xml/sax/expatreader.py
@@ -219,6 +219,9 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator):
self._parsing = 0
# break cycle created by expat handlers pointing to our methods
self._parser = None
+ bs = self._source.getByteStream()
+ if bs is not None:
+ bs.close()
def _reset_cont_handler(self):
self._parser.ProcessingInstructionHandler = \
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py
index b05e8150a6..625bc122ac 100644
--- a/Lib/xml/sax/saxutils.py
+++ b/Lib/xml/sax/saxutils.py
@@ -78,7 +78,7 @@ def quoteattr(data, entities={}):
class XMLGenerator(handler.ContentHandler):
- def __init__(self, out=None, encoding="iso-8859-1"):
+ def __init__(self, out=None, encoding="iso-8859-1", short_empty_elements=False):
if out is None:
import sys
out = sys.stdout
@@ -88,6 +88,8 @@ class XMLGenerator(handler.ContentHandler):
self._current_context = self._ns_contexts[-1]
self._undeclared_ns_maps = []
self._encoding = encoding
+ self._short_empty_elements = short_empty_elements
+ self._pending_start_element = False
def _write(self, text):
if isinstance(text, str):
@@ -112,6 +114,11 @@ class XMLGenerator(handler.ContentHandler):
# Return the unqualified name
return name[1]
+ def _finish_pending_start_element(self,endElement=False):
+ if self._pending_start_element:
+ self._write('>')
+ self._pending_start_element = False
+
# ContentHandler methods
def startDocument(self):
@@ -128,15 +135,24 @@ class XMLGenerator(handler.ContentHandler):
del self._ns_contexts[-1]
def startElement(self, name, attrs):
+ self._finish_pending_start_element()
self._write('<' + name)
for (name, value) in attrs.items():
self._write(' %s=%s' % (name, quoteattr(value)))
- self._write('>')
+ if self._short_empty_elements:
+ self._pending_start_element = True
+ else:
+ self._write(">")
def endElement(self, name):
- self._write('</%s>' % name)
+ if self._pending_start_element:
+ self._write('/>')
+ self._pending_start_element = False
+ else:
+ self._write('</%s>' % name)
def startElementNS(self, name, qname, attrs):
+ self._finish_pending_start_element()
self._write('<' + self._qname(name))
for prefix, uri in self._undeclared_ns_maps:
@@ -148,18 +164,30 @@ class XMLGenerator(handler.ContentHandler):
for (name, value) in attrs.items():
self._write(' %s=%s' % (self._qname(name), quoteattr(value)))
- self._write('>')
+ if self._short_empty_elements:
+ self._pending_start_element = True
+ else:
+ self._write(">")
def endElementNS(self, name, qname):
- self._write('</%s>' % self._qname(name))
+ if self._pending_start_element:
+ self._write('/>')
+ self._pending_start_element = False
+ else:
+ self._write('</%s>' % self._qname(name))
def characters(self, content):
- self._write(escape(content))
+ if content:
+ self._finish_pending_start_element()
+ self._write(escape(content))
def ignorableWhitespace(self, content):
- self._write(content)
+ if content:
+ self._finish_pending_start_element()
+ self._write(content)
def processingInstruction(self, target, data):
+ self._finish_pending_start_element()
self._write('<?%s %s?>' % (target, data))
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index 9357ac33e2..19d4d6986f 100644
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -136,6 +136,13 @@ Exported functions:
import re, time, operator
import http.client
from xml.parsers import expat
+import socket
+import errno
+from io import BytesIO
+try:
+ import gzip
+except ImportError:
+ gzip = None #python can be built without zlib/gzip support
# --------------------------------------------------------------------
# Internal stuff
@@ -145,24 +152,11 @@ try:
except ImportError:
datetime = None
-def _decode(data, encoding, is8bit=re.compile("[\x80-\xff]").search):
- # decode non-ascii string (if possible)
- if encoding and is8bit(data):
- data = str(data, encoding)
- return data
-
def escape(s):
s = s.replace("&", "&amp;")
s = s.replace("<", "&lt;")
return s.replace(">", "&gt;",)
-def _stringify(string):
- # convert to 7-bit ascii if possible
- try:
- return string.decode("ascii")
- except (UnicodeError, TypeError, AttributeError):
- return string
-
__version__ = "1.0.1"
# xmlrpc integer limits
@@ -748,8 +742,8 @@ class Unmarshaller:
def end_string(self, data):
if self._encoding:
- data = _decode(data, self._encoding)
- self.append(_stringify(data))
+ data = data.decode(self._encoding)
+ self.append(data)
self._value = 0
dispatch["string"] = end_string
dispatch["name"] = end_string # struct keys are always strings
@@ -767,7 +761,7 @@ class Unmarshaller:
dict = {}
items = self._stack[mark:]
for i in range(0, len(items), 2):
- dict[_stringify(items[i])] = items[i+1]
+ dict[items[i]] = items[i+1]
self._stack[mark:] = [dict]
self._value = 0
dispatch["struct"] = end_struct
@@ -804,7 +798,7 @@ class Unmarshaller:
def end_methodName(self, data):
if self._encoding:
- data = _decode(data, self._encoding)
+ data = data.decode(self._encoding)
self._methodname = data
self._type = "methodName" # no params
dispatch["methodName"] = end_methodName
@@ -1013,6 +1007,78 @@ def loads(data, use_datetime=False):
p.close()
return u.close(), u.getmethodname()
+##
+# Encode a string using the gzip content encoding such as specified by the
+# Content-Encoding: gzip
+# in the HTTP header, as described in RFC 1952
+#
+# @param data the unencoded data
+# @return the encoded data
+
+def gzip_encode(data):
+ """data -> gzip encoded data
+
+ Encode data using the gzip content encoding as described in RFC 1952
+ """
+ if not gzip:
+ raise NotImplementedError
+ f = BytesIO()
+ gzf = gzip.GzipFile(mode="wb", fileobj=f, compresslevel=1)
+ gzf.write(data)
+ gzf.close()
+ encoded = f.getvalue()
+ f.close()
+ return encoded
+
+##
+# Decode a string using the gzip content encoding such as specified by the
+# Content-Encoding: gzip
+# in the HTTP header, as described in RFC 1952
+#
+# @param data The encoded data
+# @return the unencoded data
+# @raises ValueError if data is not correctly coded.
+
+def gzip_decode(data):
+ """gzip encoded data -> unencoded data
+
+ Decode data using the gzip content encoding as described in RFC 1952
+ """
+ if not gzip:
+ raise NotImplementedError
+ f = BytesIO(data)
+ gzf = gzip.GzipFile(mode="rb", fileobj=f)
+ try:
+ decoded = gzf.read()
+ except IOError:
+ raise ValueError("invalid data")
+ f.close()
+ gzf.close()
+ return decoded
+
+##
+# Return a decoded file-like object for the gzip encoding
+# as described in RFC 1952.
+#
+# @param response A stream supporting a read() method
+# @return a file-like object that the decoded data can be read() from
+
+class GzipDecodedResponse(gzip.GzipFile if gzip else object):
+ """a file-like object to decode a response encoded with the gzip
+ method, as described in RFC 1952.
+ """
+ def __init__(self, response):
+ #response doesn't support tell() and read(), required by
+ #GzipFile
+ if not gzip:
+ raise NotImplementedError
+ self.io = BytesIO(response.read())
+ gzip.GzipFile.__init__(self, mode="rb", fileobj=self.io)
+
+ def close(self):
+ gzip.GzipFile.close(self)
+ self.io.close()
+
# --------------------------------------------------------------------
# request dispatcher
@@ -1040,11 +1106,22 @@ class Transport:
# client identifier (may be overridden)
user_agent = "xmlrpclib.py/%s (by www.pythonware.com)" % __version__
+ #if true, we'll request gzip encoding
+ accept_gzip_encoding = True
+
+ # if positive, encode request using gzip if it exceeds this threshold
+ # note that many server will get confused, so only use it if you know
+ # that they can decode such a request
+ encode_threshold = None #None = don't encode
+
def __init__(self, use_datetime=False):
self._use_datetime = use_datetime
+ self._connection = (None, None)
+ self._extra_headers = []
##
# Send a complete request, and parse the response.
+ # Retry request if a cached connection has disconnected.
#
# @param host Target host.
# @param handler Target PRC handler.
@@ -1053,21 +1130,44 @@ class Transport:
# @return Parsed response.
def request(self, host, handler, request_body, verbose=False):
+ #retry request once if cached connection has gone cold
+ for i in (0, 1):
+ try:
+ return self.single_request(host, handler, request_body, verbose)
+ except socket.error as e:
+ if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE):
+ raise
+ except http.client.BadStatusLine: #close after we sent request
+ if i:
+ raise
+
+ def single_request(self, host, handler, request_body, verbose=False):
# issue XML-RPC request
+ try:
+ http_conn = self.send_request(host, handler, request_body, verbose)
+ resp = http_conn.getresponse()
+ if resp.status == 200:
+ self.verbose = verbose
+ return self.parse_response(resp)
+
+ except Fault:
+ raise
+ except Exception:
+ #All unexpected errors leave connection in
+ # a strange state, so we clear it.
+ self.close()
+ raise
+
+ #We got an error response.
+ #Discard any response data and raise exception
+ if resp.getheader("content-length", ""):
+ resp.read()
+ raise ProtocolError(
+ host + handler,
+ resp.status, resp.reason,
+ dict(resp.getheaders())
+ )
- http_conn = self.send_request(host, handler, request_body, verbose)
- resp = http_conn.getresponse()
-
- if resp.status != 200:
- raise ProtocolError(
- host + handler,
- resp.status, resp.reason,
- dict(resp.getheaders())
- )
-
- self.verbose = verbose
-
- return self.parse_response(resp)
##
# Create parser.
@@ -1106,7 +1206,7 @@ class Transport:
("Authorization", "Basic " + auth)
]
else:
- extra_headers = None
+ extra_headers = []
return host, extra_headers, x509
@@ -1117,9 +1217,23 @@ class Transport:
# @return An HTTPConnection object
def make_connection(self, host):
+ #return an existing connection if possible. This allows
+ #HTTP/1.1 keep-alive.
+ if self._connection and host == self._connection[0]:
+ return self._connection[1]
# create a HTTP connection object from a host descriptor
- host, extra_headers, x509 = self.get_host_info(host)
+ chost, self._extra_headers, x509 = self.get_host_info(host)
+ self._connection = host, http.client.HTTPConnection(chost)
+ return self._connection[1]
+ ##
+ # Clear any cached connection object.
+ # Used in the event of socket errors.
+ #
+ def close(self):
+ if self._connection[1]:
+ self._connection[1].close()
+ self._connection = (None, None)
##
# Send HTTP request.
@@ -1131,39 +1245,79 @@ class Transport:
# @return An HTTPConnection.
def send_request(self, host, handler, request_body, debug):
- host, extra_headers, x509 = self.get_host_info(host)
- connection = http.client.HTTPConnection(host)
+ connection = self.make_connection(host)
+ headers = self._extra_headers[:]
if debug:
connection.set_debuglevel(1)
- headers = {}
- if extra_headers:
- for key, val in extra_headers:
- headers[key] = val
- headers["Content-Type"] = "text/xml"
- headers["User-Agent"] = self.user_agent
- connection.request("POST", handler, request_body, headers)
+ if self.accept_gzip_encoding and gzip:
+ connection.putrequest("POST", handler, skip_accept_encoding=True)
+ headers.append(("Accept-Encoding", "gzip"))
+ else:
+ connection.putrequest("POST", handler)
+ headers.append(("Content-Type", "text/xml"))
+ headers.append(("User-Agent", self.user_agent))
+ self.send_headers(connection, headers)
+ self.send_content(connection, request_body)
return connection
##
+ # Send request headers.
+ # This function provides a useful hook for subclassing
+ #
+ # @param connection httpConnection.
+ # @param headers list of key,value pairs for HTTP headers
+
+ def send_headers(self, connection, headers):
+ for key, val in headers:
+ connection.putheader(key, val)
+
+ ##
+ # Send request body.
+ # This function provides a useful hook for subclassing
+ #
+ # @param connection httpConnection.
+ # @param request_body XML-RPC request body.
+
+ def send_content(self, connection, request_body):
+ #optionally encode the request
+ if (self.encode_threshold is not None and
+ self.encode_threshold < len(request_body) and
+ gzip):
+ connection.putheader("Content-Encoding", "gzip")
+ request_body = gzip_encode(request_body)
+
+ connection.putheader("Content-Length", str(len(request_body)))
+ connection.endheaders(request_body)
+
+ ##
# Parse response.
#
# @param file Stream.
# @return Response tuple and target method.
- def parse_response(self, file):
- # read response from input file/socket, and parse it
+ def parse_response(self, response):
+ # read response data from httpresponse, and parse it
+ # Check for new http response object, otherwise it is a file object.
+ if hasattr(response, 'getheader'):
+ if response.getheader("Content-Encoding", "") == "gzip":
+ stream = GzipDecodedResponse(response)
+ else:
+ stream = response
+ else:
+ stream = response
p, u = self.getparser()
while 1:
- response = file.read(1024)
- if not response:
+ data = stream.read(1024)
+ if not data:
break
if self.verbose:
- print("body:", repr(response))
- p.feed(response)
+ print("body:", repr(data))
+ p.feed(data)
- file.close()
+ if stream is not response:
+ stream.close()
p.close()
return u.close()
@@ -1176,24 +1330,19 @@ class SafeTransport(Transport):
# FIXME: mostly untested
- def send_request(self, host, handler, request_body, debug):
- import socket
+ def make_connection(self, host):
+ if self._connection and host == self._connection[0]:
+ return self._connection[1]
+
if not hasattr(http.client, "HTTPSConnection"):
raise NotImplementedError(
- "your version of http.client doesn't support HTTPS")
-
- host, extra_headers, x509 = self.get_host_info(host)
- connection = http.client.HTTPSConnection(host, None, **(x509 or {}))
- if debug:
- connection.set_debuglevel(1)
- headers = {}
- if extra_headers:
- for key, val in extra_headers:
- headers[key] = val
- headers["Content-Type"] = "text/xml"
- headers["User-Agent"] = self.user_agent
- connection.request("POST", handler, request_body, headers)
- return connection
+ "your version of http.client doesn't support HTTPS")
+ # create a HTTPS connection object from a host descriptor
+ # host may be a string, or a (host, x509-dict) tuple
+ chost, self._extra_headers, x509 = self.get_host_info(host)
+ self._connection = host, http.client.HTTPSConnection(chost,
+ None, **(x509 or {}))
+ return self._connection[1]
##
# Standard server proxy. This class establishes a virtual connection
@@ -1258,6 +1407,9 @@ class ServerProxy:
self.__verbose = verbose
self.__allow_none = allow_none
+ def __close(self):
+ self.__transport.close()
+
def __request(self, methodname, params):
# call a method on the remote server
@@ -1291,6 +1443,16 @@ class ServerProxy:
# note: to call a remote object with an non-standard name, use
# result getattr(server, "strange-python-name")(args)
+ def __call__(self, attr):
+ """A workaround to get special attributes on the ServerProxy
+ without interfering with the magic __getattr__
+ """
+ if attr == "close":
+ return self.__close
+ elif attr == "transport":
+ return self.__transport
+ raise AttributeError("Attribute %r not found" % (attr,))
+
# compatibility
Server = ServerProxy
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
index 24d8a6a03e..9477309617 100644
--- a/Lib/xmlrpc/server.py
+++ b/Lib/xmlrpc/server.py
@@ -104,7 +104,7 @@ server.handle_request()
# Written by Brian Quinlan (brian@sweetapp.com).
# Based on code written by Fredrik Lundh.
-from xmlrpc.client import Fault, dumps, loads
+from xmlrpc.client import Fault, dumps, loads, gzip_encode, gzip_decode
from http.server import BaseHTTPRequestHandler
import http.server
import socketserver
@@ -155,8 +155,9 @@ class SimpleXMLRPCDispatcher:
"""Mix-in class that dispatches XML-RPC requests.
This class is used to register XML-RPC method handlers
- and then to dispatch them. There should never be any
- reason to instantiate this class directly.
+ and then to dispatch them. This class doesn't need to be
+ instanced directly when used by SimpleXMLRPCServer but it
+ can be instanced when used by the MultiPathXMLRPCServer
"""
def __init__(self, allow_none=False, encoding=None):
@@ -231,7 +232,7 @@ class SimpleXMLRPCDispatcher:
self.funcs.update({'system.multicall' : self.system_multicall})
- def _marshaled_dispatch(self, data, dispatch_method = None):
+ def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
"""Dispatches an XML-RPC method from marshalled (XML) data.
XML-RPC methods are dispatched from the marshalled (XML) data
@@ -420,6 +421,31 @@ class SimpleXMLRPCRequestHandler(BaseHTTPRequestHandler):
# paths not on this list will result in a 404 error.
rpc_paths = ('/', '/RPC2')
+ #if not None, encode responses larger than this, if possible
+ encode_threshold = 1400 #a common MTU
+
+ #Override form StreamRequestHandler: full buffering of output
+ #and no Nagle.
+ wbufsize = -1
+ disable_nagle_algorithm = True
+
+ # a re to match a gzip Accept-Encoding
+ aepattern = re.compile(r"""
+ \s* ([^\s;]+) \s* #content-coding
+ (;\s* q \s*=\s* ([0-9\.]+))? #q
+ """, re.VERBOSE | re.IGNORECASE)
+
+ def accept_encodings(self):
+ r = {}
+ ae = self.headers.get("Accept-Encoding", "")
+ for e in ae.split(","):
+ match = self.aepattern.match(e)
+ if match:
+ v = match.group(3)
+ v = float(v) if v else 1.0
+ r[match.group(1)] = v
+ return r
+
def is_rpc_path_valid(self):
if self.rpc_paths:
return self.path in self.rpc_paths
@@ -453,13 +479,17 @@ class SimpleXMLRPCRequestHandler(BaseHTTPRequestHandler):
size_remaining -= len(L[-1])
data = b''.join(L)
+ data = self.decode_request_content(data)
+ if data is None:
+ return #response has been sent
+
# In previous versions of SimpleXMLRPCServer, _dispatch
# could be overridden in this class, instead of in
# SimpleXMLRPCDispatcher. To maintain backwards compatibility,
# check to see if a subclass implements _dispatch and dispatch
# using that method if present.
response = self.server._marshaled_dispatch(
- data, getattr(self, '_dispatch', None)
+ data, getattr(self, '_dispatch', None), self.path
)
except Exception as e: # This should only happen if the module is buggy
# internal error, report as HTTP server error
@@ -473,17 +503,40 @@ class SimpleXMLRPCRequestHandler(BaseHTTPRequestHandler):
trace = str(trace.encode('ASCII', 'backslashreplace'), 'ASCII')
self.send_header("X-traceback", trace)
+ self.send_header("Content-length", "0")
self.end_headers()
else:
self.send_response(200)
self.send_header("Content-type", "text/xml")
+ if self.encode_threshold is not None:
+ if len(response) > self.encode_threshold:
+ q = self.accept_encodings().get("gzip", 0)
+ if q:
+ try:
+ response = gzip_encode(response)
+ self.send_header("Content-Encoding", "gzip")
+ except NotImplementedError:
+ pass
self.send_header("Content-length", str(len(response)))
self.end_headers()
self.wfile.write(response)
- # shut down the connection
- self.wfile.flush()
- self.connection.shutdown(1)
+ def decode_request_content(self, data):
+ #support gzip encoding of request
+ encoding = self.headers.get("content-encoding", "identity").lower()
+ if encoding == "identity":
+ return data
+ if encoding == "gzip":
+ try:
+ return gzip_decode(data)
+ except NotImplementedError:
+ self.send_response(501, "encoding %r not supported" % encoding)
+ except ValueError:
+ self.send_response(400, "error decoding gzip content")
+ else:
+ self.send_response(501, "encoding %r not supported" % encoding)
+ self.send_header("Content-length", "0")
+ self.end_headers()
def report_404 (self):
# Report a 404 error
@@ -493,9 +546,6 @@ class SimpleXMLRPCRequestHandler(BaseHTTPRequestHandler):
self.send_header("Content-length", str(len(response)))
self.end_headers()
self.wfile.write(response)
- # shut down the connection
- self.wfile.flush()
- self.connection.shutdown(1)
def log_request(self, code='-', size='-'):
"""Selectively log an accepted request."""
@@ -537,6 +587,44 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
flags |= fcntl.FD_CLOEXEC
fcntl.fcntl(self.fileno(), fcntl.F_SETFD, flags)
+class MultiPathXMLRPCServer(SimpleXMLRPCServer):
+ """Multipath XML-RPC Server
+ This specialization of SimpleXMLRPCServer allows the user to create
+ multiple Dispatcher instances and assign them to different
+ HTTP request paths. This makes it possible to run two or more
+ 'virtual XML-RPC servers' at the same port.
+ Make sure that the requestHandler accepts the paths in question.
+ """
+ def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
+ logRequests=True, allow_none=False, encoding=None, bind_and_activate=True):
+
+ SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests, allow_none,
+ encoding, bind_and_activate)
+ self.dispatchers = {}
+ self.allow_none = allow_none
+ self.encoding = encoding
+
+ def add_dispatcher(self, path, dispatcher):
+ self.dispatchers[path] = dispatcher
+ return dispatcher
+
+ def get_dispatcher(self, path):
+ return self.dispatchers[path]
+
+ def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
+ try:
+ response = self.dispatchers[path]._marshaled_dispatch(
+ data, dispatch_method, path)
+ except:
+ # report low level exception back to server
+ # (each dispatcher should have handled their own
+ # exceptions)
+ exc_type, exc_value = sys.exc_info()[:2]
+ response = xmlrpclib.dumps(
+ xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)),
+ encoding=self.encoding, allow_none=self.allow_none)
+ return response
+
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
"""Simple handler for XML-RPC data passed through CGI."""
@@ -826,10 +914,6 @@ class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
self.end_headers()
self.wfile.write(response)
- # shut down the connection
- self.wfile.flush()
- self.connection.shutdown(1)
-
class DocXMLRPCServer( SimpleXMLRPCServer,
XMLRPCDocGenerator):
"""XML-RPC and HTML documentation server.
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 2ec630605f..50f484873a 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -3,8 +3,17 @@ Read and write ZIP files.
XXX references to utf-8 need further investigation.
"""
-import struct, os, time, sys, shutil
-import binascii, io, stat
+import io
+import os
+import re
+import imp
+import sys
+import time
+import stat
+import shutil
+import struct
+import binascii
+
try:
import zlib # We may need its compression method
@@ -13,10 +22,10 @@ except ImportError:
zlib = None
crc32 = binascii.crc32
-__all__ = ["BadZipfile", "error", "ZIP_STORED", "ZIP_DEFLATED", "is_zipfile",
- "ZipInfo", "ZipFile", "PyZipFile", "LargeZipFile" ]
+__all__ = ["BadZipFile", "BadZipfile", "error", "ZIP_STORED", "ZIP_DEFLATED",
+ "is_zipfile", "ZipInfo", "ZipFile", "PyZipFile", "LargeZipFile"]
-class BadZipfile(Exception):
+class BadZipFile(Exception):
pass
@@ -26,7 +35,8 @@ class LargeZipFile(Exception):
and those extensions are disabled.
"""
-error = BadZipfile # The exception raised by this module
+error = BadZipfile = BadZipFile # Pre-3.2 compatibility names
+
ZIP64_LIMIT = (1 << 31) - 1
ZIP_FILECOUNT_LIMIT = 1 << 16
@@ -171,7 +181,7 @@ def _EndRecData64(fpin, offset, endrec):
return endrec
if diskno != 0 or disks != 1:
- raise BadZipfile("zipfiles that span multiple disks are not supported")
+ raise BadZipFile("zipfiles that span multiple disks are not supported")
# Assume no 'zip64 extensible data'
fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2)
@@ -449,133 +459,133 @@ class _ZipDecrypter:
self._UpdateKeys(c)
return c
-class ZipExtFile:
+class ZipExtFile(io.BufferedIOBase):
"""File-like object for reading an archive member.
Is returned by ZipFile.open().
"""
- def __init__(self, fileobj, zipinfo, decrypt=None):
- self.fileobj = fileobj
- self.decrypter = decrypt
- self.bytes_read = 0
- self.rawbuffer = b''
- self.readbuffer = b''
- self.linebuffer = b''
- self.eof = False
- self.univ_newlines = False
- self.nlSeps = (b"\n", )
- self.lastdiscard = b''
-
- self.compress_type = zipinfo.compress_type
- self.compress_size = zipinfo.compress_size
-
- self.closed = False
- self.mode = "r"
- self.name = zipinfo.filename
+ # Max size supported by decompressor.
+ MAX_N = 1 << 31 - 1
- # read from compressed files in 64k blocks
- self.compreadsize = 64*1024
- if self.compress_type == ZIP_DEFLATED:
- self.dc = zlib.decompressobj(-15)
+ # Read from compressed files in 4k blocks.
+ MIN_READ_SIZE = 4096
- if hasattr(zipinfo, 'CRC'):
- self._expected_crc = zipinfo.CRC
- self._running_crc = crc32(b'') & 0xffffffff
- else:
- self._expected_crc = None
+ # Search for universal newlines or line chunks.
+ PATTERN = re.compile(br'^(?P<chunk>[^\r\n]+)|(?P<newline>\n|\r\n?)')
- def set_univ_newlines(self, univ_newlines):
- self.univ_newlines = univ_newlines
+ def __init__(self, fileobj, mode, zipinfo, decrypter=None,
+ close_fileobj=False):
+ self._fileobj = fileobj
+ self._decrypter = decrypter
+ self._close_fileobj = close_fileobj
- # pick line separator char(s) based on universal newlines flag
- self.nlSeps = (b"\n", )
- if self.univ_newlines:
- self.nlSeps = (b"\r\n", b"\r", b"\n")
+ self._compress_type = zipinfo.compress_type
+ self._compress_size = zipinfo.compress_size
+ self._compress_left = zipinfo.compress_size
- def __iter__(self):
- return self
+ if self._compress_type == ZIP_DEFLATED:
+ self._decompressor = zlib.decompressobj(-15)
+ self._unconsumed = b''
- def __next__(self):
- nextline = self.readline()
- if not nextline:
- raise StopIteration()
+ self._readbuffer = b''
+ self._offset = 0
- return nextline
+ self._universal = 'U' in mode
+ self.newlines = None
- def close(self):
- self.closed = True
-
- def _checkfornewline(self):
- nl, nllen = -1, -1
- if self.linebuffer:
- # ugly check for cases where half of an \r\n pair was
- # read on the last pass, and the \r was discarded. In this
- # case we just throw away the \n at the start of the buffer.
- if (self.lastdiscard, self.linebuffer[:1]) == (b'\r', b'\n'):
- self.linebuffer = self.linebuffer[1:]
-
- for sep in self.nlSeps:
- nl = self.linebuffer.find(sep)
- if nl >= 0:
- nllen = len(sep)
- return nl, nllen
-
- return nl, nllen
-
- def readline(self, size = -1):
- """Read a line with approx. size. If size is negative,
- read a whole line.
- """
- if size < 0:
- size = sys.maxsize
- elif size == 0:
- return b''
+ # Adjust read size for encrypted files since the first 12 bytes
+ # are for the encryption/password information.
+ if self._decrypter is not None:
+ self._compress_left -= 12
- # check for a newline already in buffer
- nl, nllen = self._checkfornewline()
+ self.mode = mode
+ self.name = zipinfo.filename
- if nl >= 0:
- # the next line was already in the buffer
- nl = min(nl, size)
+ if hasattr(zipinfo, 'CRC'):
+ self._expected_crc = zipinfo.CRC
+ self._running_crc = crc32(b'') & 0xffffffff
else:
- # no line break in buffer - try to read more
- size -= len(self.linebuffer)
- while nl < 0 and size > 0:
- buf = self.read(min(size, 100))
- if not buf:
- break
- self.linebuffer += buf
- size -= len(buf)
-
- # check for a newline in buffer
- nl, nllen = self._checkfornewline()
-
- # we either ran out of bytes in the file, or
- # met the specified size limit without finding a newline,
- # so return current buffer
- if nl < 0:
- s = self.linebuffer
- self.linebuffer = b''
- return s
-
- buf = self.linebuffer[:nl]
- self.lastdiscard = self.linebuffer[nl:nl + nllen]
- self.linebuffer = self.linebuffer[nl + nllen:]
-
- # line is always returned with \n as newline char (except possibly
- # for a final incomplete line in the file, which is handled above).
- return buf + b"\n"
-
- def readlines(self, sizehint = -1):
- """Return a list with all (following) lines. The sizehint parameter
- is ignored in this implementation.
+ self._expected_crc = None
+
+ def readline(self, limit=-1):
+ """Read and return a line from the stream.
+
+ If limit is specified, at most limit bytes will be read.
"""
- result = []
+
+ if not self._universal and limit < 0:
+ # Shortcut common case - newline found in buffer.
+ i = self._readbuffer.find(b'\n', self._offset) + 1
+ if i > 0:
+ line = self._readbuffer[self._offset: i]
+ self._offset = i
+ return line
+
+ if not self._universal:
+ return io.BufferedIOBase.readline(self, limit)
+
+ line = b''
+ while limit < 0 or len(line) < limit:
+ readahead = self.peek(2)
+ if readahead == b'':
+ return line
+
+ #
+ # Search for universal newlines or line chunks.
+ #
+ # The pattern returns either a line chunk or a newline, but not
+ # both. Combined with peek(2), we are assured that the sequence
+ # '\r\n' is always retrieved completely and never split into
+ # separate newlines - '\r', '\n' due to coincidental readaheads.
+ #
+ match = self.PATTERN.search(readahead)
+ newline = match.group('newline')
+ if newline is not None:
+ if self.newlines is None:
+ self.newlines = []
+ if newline not in self.newlines:
+ self.newlines.append(newline)
+ self._offset += len(newline)
+ return line + b'\n'
+
+ chunk = match.group('chunk')
+ if limit >= 0:
+ chunk = chunk[: limit - len(line)]
+
+ self._offset += len(chunk)
+ line += chunk
+
+ return line
+
+ def peek(self, n=1):
+ """Returns buffered bytes without advancing the position."""
+ if n > len(self._readbuffer) - self._offset:
+ chunk = self.read(n)
+ self._offset -= len(chunk)
+
+ # Return up to 512 bytes to reduce allocation overhead for tight loops.
+ return self._readbuffer[self._offset: self._offset + 512]
+
+ def readable(self):
+ return True
+
+ def read(self, n=-1):
+ """Read and return up to n bytes.
+ If the argument is omitted, None, or negative, data is read and returned until EOF is reached..
+ """
+ buf = b''
+ if n is None:
+ n = -1
while True:
- line = self.readline()
- if not line: break
- result.append(line)
- return result
+ if n < 0:
+ data = self.read1(n)
+ elif n > len(buf):
+ data = self.read1(n - len(buf))
+ else:
+ return buf
+ if len(data) == 0:
+ return buf
+ buf += data
def _update_crc(self, newdata, eof):
# Update the CRC using the given data.
@@ -585,86 +595,67 @@ class ZipExtFile:
self._running_crc = crc32(newdata, self._running_crc) & 0xffffffff
# Check the CRC if we're at the end of the file
if eof and self._running_crc != self._expected_crc:
- raise BadZipfile("Bad CRC-32 for file %r" % self.name)
-
- def read(self, size = None):
- # act like file obj and return empty string if size is 0
- if size == 0:
- return b''
-
- # determine read size
- bytesToRead = self.compress_size - self.bytes_read
-
- # adjust read size for encrypted files since the first 12 bytes
- # are for the encryption/password information
- if self.decrypter is not None:
- bytesToRead -= 12
-
- if size is not None and size >= 0:
- if self.compress_type == ZIP_STORED:
- lr = len(self.readbuffer)
- bytesToRead = min(bytesToRead, size - lr)
- elif self.compress_type == ZIP_DEFLATED:
- if len(self.readbuffer) > size:
- # the user has requested fewer bytes than we've already
- # pulled through the decompressor; don't read any more
- bytesToRead = 0
- else:
- # user will use up the buffer, so read some more
- lr = len(self.rawbuffer)
- bytesToRead = min(bytesToRead, self.compreadsize - lr)
-
- # avoid reading past end of file contents
- if bytesToRead + self.bytes_read > self.compress_size:
- bytesToRead = self.compress_size - self.bytes_read
-
- # try to read from file (if necessary)
- if bytesToRead > 0:
- data = self.fileobj.read(bytesToRead)
- self.bytes_read += len(data)
- try:
- self.rawbuffer += data
- except:
- print(repr(self.fileobj), repr(self.rawbuffer),
- repr(data))
- raise
+ raise BadZipFile("Bad CRC-32 for file %r" % self.name)
- # handle contents of raw buffer
- if self.rawbuffer:
- newdata = self.rawbuffer
- self.rawbuffer = b''
-
- # decrypt new data if we were given an object to handle that
- if newdata and self.decrypter is not None:
- newdata = bytes(map(self.decrypter, newdata))
-
- # decompress newly read data if necessary
- if newdata and self.compress_type == ZIP_DEFLATED:
- newdata = self.dc.decompress(newdata)
- self.rawbuffer = self.dc.unconsumed_tail
- if self.eof and len(self.rawbuffer) == 0:
- # we're out of raw bytes (both from the file and
- # the local buffer); flush just to make sure the
- # decompressor is done
- newdata += self.dc.flush()
- # prevent decompressor from being used again
- self.dc = None
-
- self._update_crc(newdata, eof=(
- self.compress_size == self.bytes_read and
- len(self.rawbuffer) == 0))
- self.readbuffer += newdata
-
- # return what the user asked for
- if size is None or len(self.readbuffer) <= size:
- data = self.readbuffer
- self.readbuffer = b''
- else:
- data = self.readbuffer[:size]
- self.readbuffer = self.readbuffer[size:]
+ def read1(self, n):
+ """Read up to n bytes with at most one read() system call."""
+
+ # Simplify algorithm (branching) by transforming negative n to large n.
+ if n < 0 or n is None:
+ n = self.MAX_N
+
+ # Bytes available in read buffer.
+ len_readbuffer = len(self._readbuffer) - self._offset
+
+ # Read from file.
+ if self._compress_left > 0 and n > len_readbuffer + len(self._unconsumed):
+ nbytes = n - len_readbuffer - len(self._unconsumed)
+ nbytes = max(nbytes, self.MIN_READ_SIZE)
+ nbytes = min(nbytes, self._compress_left)
+
+ data = self._fileobj.read(nbytes)
+ self._compress_left -= len(data)
+ if data and self._decrypter is not None:
+ data = bytes(map(self._decrypter, data))
+
+ if self._compress_type == ZIP_STORED:
+ self._update_crc(data, eof=(self._compress_left==0))
+ self._readbuffer = self._readbuffer[self._offset:] + data
+ self._offset = 0
+ else:
+ # Prepare deflated bytes for decompression.
+ self._unconsumed += data
+
+ # Handle unconsumed data.
+ if (len(self._unconsumed) > 0 and n > len_readbuffer and
+ self._compress_type == ZIP_DEFLATED):
+ data = self._decompressor.decompress(
+ self._unconsumed,
+ max(n - len_readbuffer, self.MIN_READ_SIZE)
+ )
+
+ self._unconsumed = self._decompressor.unconsumed_tail
+ eof = len(self._unconsumed) == 0 and self._compress_left == 0
+ if eof:
+ data += self._decompressor.flush()
+
+ self._update_crc(data, eof=eof)
+ self._readbuffer = self._readbuffer[self._offset:] + data
+ self._offset = 0
+
+ # Read from buffer.
+ data = self._readbuffer[self._offset: self._offset + n]
+ self._offset += len(data)
return data
+ def close(self):
+ try:
+ if self._close_fileobj:
+ self._fileobj.close()
+ finally:
+ super().close()
+
class ZipFile:
""" Class with methods to open, read, write, close, list zip files.
@@ -738,7 +729,7 @@ class ZipFile:
self._RealGetContents()
# seek to start of directory and overwrite
self.fp.seek(self.start_dir, 0)
- except BadZipfile:
+ except BadZipFile:
# file is not a zip file, just append
self.fp.seek(0, 2)
@@ -751,12 +742,18 @@ class ZipFile:
self.fp = None
raise RuntimeError('Mode must be "r", "w" or "a"')
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.close()
+
def _GetContents(self):
"""Read the directory, making sure we close the file if the format
is bad."""
try:
self._RealGetContents()
- except BadZipfile:
+ except BadZipFile:
if not self._filePassed:
self.fp.close()
self.fp = None
@@ -768,9 +765,9 @@ class ZipFile:
try:
endrec = _EndRecData(fp)
except IOError:
- raise BadZipfile("File is not a zip file")
+ raise BadZipFile("File is not a zip file")
if not endrec:
- raise BadZipfile("File is not a zip file")
+ raise BadZipFile("File is not a zip file")
if self.debug > 1:
print(endrec)
size_cd = endrec[_ECD_SIZE] # bytes in central directory
@@ -795,7 +792,7 @@ class ZipFile:
while total < size_cd:
centdir = fp.read(sizeCentralDir)
if centdir[0:4] != stringCentralDir:
- raise BadZipfile("Bad magic number for central directory")
+ raise BadZipFile("Bad magic number for central directory")
centdir = struct.unpack(structCentralDir, centdir)
if self.debug > 2:
print(centdir)
@@ -866,7 +863,7 @@ class ZipFile:
f = self.open(zinfo.filename, "r")
while f.read(chunk_size): # Check CRC-32
pass
- except BadZipfile:
+ except BadZipFile:
return zinfo.filename
def getinfo(self, name):
@@ -889,7 +886,8 @@ class ZipFile:
def read(self, name, pwd=None):
"""Return file bytes (as a string) for name."""
- return self.open(name, "r", pwd).read()
+ with self.open(name, "r", pwd) as fp:
+ return fp.read()
def open(self, name, mode="r", pwd=None):
"""Return file-like object for 'name'."""
@@ -914,22 +912,34 @@ class ZipFile:
zinfo = name
else:
# Get info object for name
- zinfo = self.getinfo(name)
-
+ try:
+ zinfo = self.getinfo(name)
+ except KeyError:
+ if not self._filePassed:
+ zef_file.close()
+ raise
zef_file.seek(zinfo.header_offset, 0)
# Skip the file header:
fheader = zef_file.read(sizeFileHeader)
if fheader[0:4] != stringFileHeader:
- raise BadZipfile("Bad magic number for file header")
+ raise BadZipFile("Bad magic number for file header")
fheader = struct.unpack(structFileHeader, fheader)
fname = zef_file.read(fheader[_FH_FILENAME_LENGTH])
if fheader[_FH_EXTRA_FIELD_LENGTH]:
zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])
- if fname != zinfo.orig_filename.encode("utf-8"):
- raise BadZipfile(
+ if zinfo.flag_bits & 0x800:
+ # UTF-8 filename
+ fname_str = fname.decode("utf-8")
+ else:
+ fname_str = fname.decode("cp437")
+
+ if fname_str != zinfo.orig_filename:
+ if not self._filePassed:
+ zef_file.close()
+ raise BadZipFile(
'File name in directory %r and header %r differ.'
% (zinfo.orig_filename, fname))
@@ -940,6 +950,8 @@ class ZipFile:
if not pwd:
pwd = self.pwd
if not pwd:
+ if not self._filePassed:
+ zef_file.close()
raise RuntimeError("File %s is encrypted, "
"password required for extraction" % name)
@@ -958,18 +970,12 @@ class ZipFile:
# compare against the CRC otherwise
check_byte = (zinfo.CRC >> 24) & 0xff
if h[11] != check_byte:
+ if not self._filePassed:
+ zef_file.close()
raise RuntimeError("Bad password for file", name)
- # build and return a ZipExtFile
- if zd is None:
- zef = ZipExtFile(zef_file, zinfo)
- else:
- zef = ZipExtFile(zef_file, zinfo, zd)
-
- # set universal newlines on ZipExtFile if necessary
- if "U" in mode:
- zef.set_univ_newlines(True)
- return zef
+ return ZipExtFile(zef_file, mode, zinfo, zd,
+ close_fileobj=not self._filePassed)
def extract(self, member, path=None, pwd=None):
"""Extract a member from the archive to the current working directory,
@@ -1138,7 +1144,7 @@ class ZipFile:
self.filelist.append(zinfo)
self.NameToInfo[zinfo.filename] = zinfo
- def writestr(self, zinfo_or_arcname, data):
+ def writestr(self, zinfo_or_arcname, data, compress_type=None):
"""Write a file into the archive. The contents is 'data', which
may be either a 'str' or a 'bytes' instance; if it is a 'str',
it is encoded as UTF-8 first.
@@ -1160,6 +1166,9 @@ class ZipFile:
zinfo.file_size = len(data) # Uncompressed size
zinfo.header_offset = self.fp.tell() # Start of header data
+ if compress_type is not None:
+ zinfo.compress_type = compress_type
+
self._writecheck(zinfo)
self._didModify = True
zinfo.CRC = crc32(data) & 0xffffffff # CRC-32 checksum
@@ -1298,6 +1307,12 @@ class ZipFile:
class PyZipFile(ZipFile):
"""Class to create ZIP archives with Python library files and packages."""
+ def __init__(self, file, mode="r", compression=ZIP_STORED,
+ allowZip64=False, optimize=-1):
+ ZipFile.__init__(self, file, mode=mode, compression=compression,
+ allowZip64=allowZip64)
+ self._optimize = optimize
+
def writepy(self, pathname, basename=""):
"""Add all files from "pathname" to the ZIP archive.
@@ -1370,25 +1385,64 @@ class PyZipFile(ZipFile):
archive name, compiling if necessary. For example, given
/python/lib/string, return (/python/lib/string.pyc, string).
"""
- file_py = pathname + ".py"
- file_pyc = pathname + ".pyc"
- file_pyo = pathname + ".pyo"
- if os.path.isfile(file_pyo) and \
- os.stat(file_pyo).st_mtime >= os.stat(file_py).st_mtime:
- fname = file_pyo # Use .pyo file
- elif not os.path.isfile(file_pyc) or \
- os.stat(file_pyc).st_mtime < os.stat(file_py).st_mtime:
+ def _compile(file, optimize=-1):
import py_compile
if self.debug:
- print("Compiling", file_py)
+ print("Compiling", file)
try:
- py_compile.compile(file_py, file_pyc, None, True)
- except py_compile.PyCompileError as err:
+ py_compile.compile(file, doraise=True, optimize=optimize)
+ except py_compile.PyCompileError as error:
print(err.msg)
- fname = file_pyc
+ return False
+ return True
+
+ file_py = pathname + ".py"
+ file_pyc = pathname + ".pyc"
+ file_pyo = pathname + ".pyo"
+ pycache_pyc = imp.cache_from_source(file_py, True)
+ pycache_pyo = imp.cache_from_source(file_py, False)
+ if self._optimize == -1:
+ # legacy mode: use whatever file is present
+ if (os.path.isfile(file_pyo) and
+ os.stat(file_pyo).st_mtime >= os.stat(file_py).st_mtime):
+ # Use .pyo file.
+ arcname = fname = file_pyo
+ elif (os.path.isfile(file_pyc) and
+ os.stat(file_pyc).st_mtime >= os.stat(file_py).st_mtime):
+ # Use .pyc file.
+ arcname = fname = file_pyc
+ elif (os.path.isfile(pycache_pyc) and
+ os.stat(pycache_pyc).st_mtime >= os.stat(file_py).st_mtime):
+ # Use the __pycache__/*.pyc file, but write it to the legacy pyc
+ # file name in the archive.
+ fname = pycache_pyc
+ arcname = file_pyc
+ elif (os.path.isfile(pycache_pyo) and
+ os.stat(pycache_pyo).st_mtime >= os.stat(file_py).st_mtime):
+ # Use the __pycache__/*.pyo file, but write it to the legacy pyo
+ # file name in the archive.
+ fname = pycache_pyo
+ arcname = file_pyo
+ else:
+ # Compile py into PEP 3147 pyc file.
+ if _compile(file_py):
+ fname = (pycache_pyc if __debug__ else pycache_pyo)
+ arcname = (file_pyc if __debug__ else file_pyo)
+ else:
+ fname = arcname = file_py
else:
- fname = file_pyc
- archivename = os.path.split(fname)[1]
+ # new mode: use given optimization level
+ if self._optimize == 0:
+ fname = pycache_pyc
+ arcname = file_pyc
+ else:
+ fname = pycache_pyo
+ arcname = file_pyo
+ if not (os.path.isfile(fname) and
+ os.stat(fname).st_mtime >= os.stat(file_py).st_mtime):
+ if not _compile(file_py, optimize=self._optimize):
+ fname = arcname = file_py
+ archivename = os.path.split(arcname)[1]
if basename:
archivename = "%s/%s" % (basename, archivename)
return (fname, archivename)